Browser host, screenshots, docs, CI, README, LICENSE
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e0bde1d150
commit
de8abfaa26
17 files changed
+1019
-13
No files matched your search
@@ -0,0 +1,16 @@
|
||||
/** Loader for browsers: fetches the jco output under <base>/build/. */
|
||||
export function webLoader(base) {
|
||||
return async (name) => {
|
||||
const r = await fetch(`${base}/build/components/${name}.meta.json`);
|
||||
if (!r.ok) throw new Error(`cannot load ${name}.meta.json: HTTP ${r.status}`);
|
||||
const meta = await r.json();
|
||||
const dir = `${base}/build/jco/${name}`;
|
||||
const mod = await import(`${dir}/${name}.js`);
|
||||
const getCoreModule = async (p) => {
|
||||
const res = await fetch(`${dir}/${p}`);
|
||||
if (!res.ok) throw new Error(`cannot fetch ${p}: HTTP ${res.status}`);
|
||||
return WebAssembly.compile(await res.arrayBuffer());
|
||||
};
|
||||
return { meta, instantiate: (imports) => mod.instantiate(getCoreModule, imports) };
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user