34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
import Van from "npm:vanjs-core@^1.5.5";
|
|
globalThis.van = Van;
|
|
|
|
import * as VanX from "npm:vanjs-ext@^0.6.3";
|
|
globalThis.vanX = VanX;
|
|
|
|
import Gale from "../src/gale.js";
|
|
globalThis.Gale = Gale;
|
|
|
|
const args = new URL(import.meta.url).searchParams;
|
|
|
|
//Store
|
|
vanX.Store=(e,t)=>{const a=localStorage.getItem(t),r=vanX.reactive(a?JSON.parse(a):e);return van.derive((()=>localStorage.setItem(t,JSON.stringify(vanX.compact(r))))),r};
|
|
|
|
if(args.has("hmr"))
|
|
{
|
|
const path = "/proxy/"+"src/hmr.js";
|
|
await import(path);
|
|
}
|
|
|
|
const root = args.get("root")||"/";
|
|
fetch(root+"deno.json")
|
|
.then(text=>text.json())
|
|
.then(json=>{
|
|
const Script=(t,e)=>{let n=document.createElement("script"); n.type=t; n.textContent=e; document.head.appendChild(n); return n;};
|
|
const imports = json.imports;
|
|
for(let n in imports)
|
|
{
|
|
const path=imports[n];
|
|
path.startsWith("./")&&(imports[n]=root+path.substring(2))
|
|
}
|
|
args.has("map") && Script("importmap",JSON.stringify({imports}));
|
|
Script("module", "").src=imports["GALE@ENTRY"];
|
|
}); |