M0: WIT package, MoonBit components, JS host, docs, CI (#1)
CI / test (push) Successful in 19s

This commit was merged in pull request #1.
This commit is contained in:
nandi committed 2026-11-24 23:51:26 +00:00
1 parent e5548fc067
commit 880ecd4102
141 files changed
+9681 -1

No files matched your search

+16
View File
@@ -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) };
};
}