dont inline library bundle
This commit is contained in:
parent
5ba5a4e6e3
commit
33625e2f80
16
dist/core.js
vendored
16
dist/core.js
vendored
@ -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"; ')}))})();
|
||||
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"; ');
|
||||
})
|
@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<script src="./dist/core.js"></script>
|
||||
<script src="./dist/core.js?/deno.json" type="module"></script>
|
||||
<script src="./src/gale.js"></script>
|
||||
</head>
|
||||
<body></body>
|
||||
|
@ -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(`</head>`, `<script>${bundle}</script></head>`);
|
||||
export const Root = import.meta.resolve("../");
|
||||
const index = await fetch(Root + "dist/index.html").then(r=>r.text());
|
||||
export const HTML = index.replace(`</head>`, `<script type="module" src="${Root + "dist/core.js?/deno.json"}"></script></head>`);
|
||||
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);
|
@ -12,7 +12,7 @@ try {
|
||||
} catch (_) {
|
||||
html = HTML;
|
||||
}
|
||||
html = html.replace("</head>", `<script>${devinc}</script></head>`);
|
||||
html = html.replace("</head>", `<script type="module">${devinc}</script></head>`);
|
||||
|
||||
function extension(path: string): string {
|
||||
// Remove trailing slash if it exists
|
||||
|
15
src/boot.js
15
src/boot.js
@ -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"; ');
|
||||
})
|
||||
)();
|
Loading…
Reference in New Issue
Block a user