remote hosting fixes

This commit is contained in:
Seth Trowbridge 2025-08-06 15:43:10 -04:00
parent f5b22582e7
commit b50cae600a
7 changed files with 28 additions and 26 deletions

View File

@ -3,7 +3,7 @@
{ {
"checkJs": true, "checkJs": true,
"lib": ["deno.window", "DOM"], "lib": ["deno.window", "DOM"],
"types": ["GALE@HOST/dist/core.d.ts"] "types": ["GALE@HOST/types.d.ts"]
}, },
"tasks": "tasks":
{ {

File diff suppressed because one or more lines are too long

View File

@ -3,9 +3,6 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- css reset -->
<style>*{margin:0;padding:0;box-sizing:border-box;}html, body{height:100%;width:100%;font-family:Arial, sans-serif;line-height:1.6;}body{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;}img, video{max-width:100%;height:auto;}a{text-decoration:none;color:inherit;}ul, ol{list-style:none;}button, input, textarea{font-family:inherit;font-size:inherit;line-height:inherit;border:none;background:none;padding:0;margin:0;outline:none;}table{border-collapse:collapse;width:100%;}</style>
</head> </head>
<body></body> <body></body>
</html> </html>

View File

@ -1,7 +1,13 @@
export const Root = import.meta.resolve("../"); export const Root = import.meta.resolve("../");
const bundle = await fetch(Root + "dist/core.js").then(r=>r.text());
const index = await fetch(Root + "index.html").then(r=>r.text());
export const HTML = index.replace(`</head>`, `<script type="module" src="/dist/bundle_entry.js?map&hmr"></script></head>`);
export const Load =async(file:string)=> await fetch(Root + file).then(resp=>resp.text()); export const Load =async(file:string)=> await fetch(Root + file).then(resp=>resp.text());
export const Save =async(text:string, name:string)=> await Deno.writeTextFile(name, text); export const Save =async(text:string, name:string)=> await Deno.writeTextFile(name, text);
const index = await Load("index.html");
export const HTML = index.replace(
`</head>`,
`
<style>*{margin:0;padding:0;box-sizing:border-box;}html, body{height:100%;width:100%;font-family:Arial, sans-serif;line-height:1.6;}body{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;}img, video{max-width:100%;height:auto;}a{text-decoration:none;color:inherit;}ul, ol{list-style:none;}button, input, textarea{font-family:inherit;font-size:inherit;line-height:inherit;border:none;background:none;padding:0;margin:0;outline:none;}table{border-collapse:collapse;width:100%;}</style>
<script type="module" src="${Root+"dist/bundle_entry.js?hmr&map"}"></script>
</head>`);

View File

@ -29,5 +29,5 @@ fetch(root+"deno.json")
path.startsWith("./")&&(imports[n]=root+path.substring(2)) path.startsWith("./")&&(imports[n]=root+path.substring(2))
} }
args.has("map") && Script("importmap",JSON.stringify({imports})); args.has("map") && Script("importmap",JSON.stringify({imports}));
Script("module").src=imports.entry; Script("module", "").src=imports["GALE@ENTRY"];
}); });

View File

@ -5,12 +5,7 @@ import {HTML} from "./assemble_files.ts";
const port = parseInt(Deno.args[0] || "8000", 10); const port = parseInt(Deno.args[0] || "8000", 10);
const sockets: WebSocket[] = []; const sockets: WebSocket[] = [];
let html: string; let html = HTML;
try {
html = Deno.readTextFileSync("./index.html");
} catch (_) {
html = HTML;
}
function extension(path: string): string { function extension(path: string): string {
// Remove trailing slash if it exists // Remove trailing slash if it exists

View File

@ -6,13 +6,17 @@ async function main()
const denoJson = JSON.parse(await Deno.readTextFile("./deno.json")); const denoJson = JSON.parse(await Deno.readTextFile("./deno.json"));
// Check if compilerOptions and types are defined // Check if compilerOptions and types are defined
if (denoJson.compilerOptions?.types) { if (denoJson.compilerOptions?.types)
{
const types:string[] = denoJson.compilerOptions.types; const types:string[] = denoJson.compilerOptions.types;
// Iterate over each type file and cache it // Iterate over each type file and cache it
for (const typeFile of types) { for (const typeFile of types)
{
let lookup:string = typeFile; let lookup:string = typeFile;
if(!typeFile.startsWith("http")) console.log(`found ambient type file`, lookup);
if(typeFile.startsWith("."))
{ {
lookup = toFileUrl(resolve(Deno.cwd(), typeFile)).href; lookup = toFileUrl(resolve(Deno.cwd(), typeFile)).href;
} }