From 33625e2f803172e51edda91e1b6a5116b22afe69 Mon Sep 17 00:00:00 2001 From: Seth Trowbridge Date: Fri, 11 Apr 2025 15:15:32 -0400 Subject: [PATCH] dont inline library bundle --- dist/core.js | 16 +++++++++++++++- index.html | 2 +- scripts/assemble_files.ts | 5 ++--- scripts/dev_server.ts | 2 +- src/boot.js | 15 --------------- 5 files changed, 19 insertions(+), 21 deletions(-) delete mode 100644 src/boot.js diff --git a/dist/core.js b/dist/core.js index 203fb48..83ec791 100644 --- a/dist/core.js +++ b/dist/core.js @@ -11,4 +11,18 @@ vanX.Store=(e,t)=>{const a=localStorage.getItem(t),r=vanX.reactive(a?JSON.parse( globalThis.Gale=(e,t="")=>{const n=(e,t,o)=>`${e}{${Object.keys(t).map((e=>{const a=t[e];switch(e[0]){case"@":return n(`@media(max-width:${e.substring(1)})`,a,o);case":":return n(`&${e}`,a,o);case".":return n(`${e}${o}`,a,o);case"^":return n(`&:hover .${e.substring(1)}${o}`,a,o)}return`${e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}: ${a};`})).join("\n")}}`,o=(e,t)=>{const n=t.lastIndexOf(e)+e.length;return n?t.substring(n):t},a=e=>{const t=van.tags[e];let n=[];const o=new Proxy(((...e)=>{const o=t(...e);return o.className=n.join(i+" ")+i+" "+o.className,n=[],o}),{get:(e,t)=>(n.push(t.substring(t.lastIndexOf(".")+1)),o)});return o},i=t?"_"+t:"",r=Object.keys(e).map((t=>n("."+t+i,e[t],i))).join("\n"),s=document.createElement("style");return s.setAttribute("data-sheet",i),s.textContent=r+"*{margin:0;padding:0;box-sizing:border-box;}html, :host{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%;}",globalThis.document?.head.appendChild(s),{Tag:(...e)=>e.map((e=>o("^",o(".",e)))).join(i+" ")+i,CSS:r,App(e,...t){const n=document.querySelector(e).attachShadow({mode:"open"});return n.appendChild(s),van.add(n,...t),n},DOM:new Proxy({},{get:(e,t)=>a(t)}),H:new Proxy({},{get:(e,t)=>a("div")[t]})}}; //boot -((t="/")=>{fetch(t+"deno.json").then((t=>t.json())).then((e=>{const n=(t,e)=>{let n=document.createElement("script");n.type=t,n.textContent=e,document.head.appendChild(n)},o=e.imports;for(let e in o){const n=o[e];n.startsWith("./")&&(o[e]=t+n.substring(2))}n("importmap",JSON.stringify({imports:o})),n("module",'import "entry"; ')}))})(); \ No newline at end of file +const configFile = import.meta.url.split("?")[1] || window.location+"deno.json"; +const configFolder = configFile.substring(0, configFile.lastIndexOf("/")+1); +fetch(configFile) +.then(text=>text.json()) +.then(json=>{ + const n=(t,e)=>{let n=document.createElement("script");n.type=t,n.textContent=e,document.head.appendChild(n)}; + const imports = json.imports; + for(let n in imports) + { + const path=imports[n]; + path.startsWith("./")&&(imports[n]=configFolder+path.substring(2)) + } + n("importmap",JSON.stringify({imports})); + n("module",'import "entry"; '); +}) \ No newline at end of file diff --git a/index.html b/index.html index 0f4d254..2df7d2f 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ - + diff --git a/scripts/assemble_files.ts b/scripts/assemble_files.ts index 97e93f6..5d04d48 100644 --- a/scripts/assemble_files.ts +++ b/scripts/assemble_files.ts @@ -1,6 +1,5 @@ -const bundle = await fetch(import.meta.resolve("../dist/core.js")).then(r=>r.text()); -const index = await fetch(import.meta.resolve("../dist/index.html")).then(r=>r.text()); -export const HTML = index.replace(``, ``); export const Root = import.meta.resolve("../"); +const index = await fetch(Root + "dist/index.html").then(r=>r.text()); +export const HTML = index.replace(``, ``); 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); \ No newline at end of file diff --git a/scripts/dev_server.ts b/scripts/dev_server.ts index d6e82cf..fb287ff 100644 --- a/scripts/dev_server.ts +++ b/scripts/dev_server.ts @@ -12,7 +12,7 @@ try { } catch (_) { html = HTML; } -html = html.replace("", ``); +html = html.replace("", ``); function extension(path: string): string { // Remove trailing slash if it exists diff --git a/src/boot.js b/src/boot.js deleted file mode 100644 index 863c73e..0000000 --- a/src/boot.js +++ /dev/null @@ -1,15 +0,0 @@ -( - (root="/")=>fetch(root+"deno.json") - .then(text=>text.json()) - .then(json=>{ - const n=(t,e)=>{let n=document.createElement("script");n.type=t,n.textContent=e,document.head.appendChild(n)}; - const imports = json.imports; - for(let n in imports) - { - const path=imports[n]; - path.startsWith("./")&&(imports[n]=root+path.substring(2)) - } - n("importmap",JSON.stringify({imports})); - n("module",'import "entry"; '); - }) -)(); \ No newline at end of file