Something went wrong. Try again.
Monorepo for the nibling.run platform
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364// Demo page logic for the TypeScript slice: five sequential guest processes over// one runtime — the happy ESM path, the happy CJS path, and the three named// refusal paths (.tsx via require, enums via strip-only, .tsx via the ESM graph).// Runs on the page (host side).import { boot } from "@nibling/kernel";
const out = document.getElementById("out");const errEl = document.getElementById("err");const exitEl = document.getElementById("exit");const dec = new TextDecoder();
try { const runtime = await boot(); const read = async (p) => await (await fetch(p)).text(); runtime.writeTree({ "/app/main.mts": await read("/demo/app/main.mts"), "/app/greet.mts": await read("/demo/app/greet.mts"), "/app/types.mts": await read("/demo/app/types.mts"), "/app/legacy-ts.ts": await read("/demo/app/legacy-ts.ts"), "/app/legacy-main.cjs": await read("/demo/app/legacy-main.cjs"), "/app/pkg/package.json": await read("/demo/app/typed-pkg/package.json"), "/app/pkg/mod.ts": await read("/demo/app/typed-pkg/mod.ts"), "/app/pkg/main.mjs": await read("/demo/app/typed-pkg/main.mjs"), "/app/nm-main.cjs": await read("/demo/app/nm-main.cjs"), "/app/node_modules/badpkg/package.json": await read("/demo/app/node_modules/badpkg/package.json"), "/app/node_modules/badpkg/index.ts": await read("/demo/app/node_modules/badpkg/index.ts"), "/app/comp.tsx": await read("/demo/app/comp.tsx"), "/app/tsx-main.cjs": await read("/demo/app/tsx-main.cjs"), "/app/enum-main.mts": await read("/demo/app/enum-main.mts"), "/app/tsx-esm-main.mts": await read("/demo/app/tsx-esm-main.mts"), "/app/name.txt": await read("/demo/app/name.txt"), "/app/node_modules/leftpad/package.json": await read("/demo/app/node_modules/leftpad/package.json"), "/app/node_modules/leftpad/index.js": await read("/demo/app/node_modules/leftpad/index.js"), });
const codes = []; for (const plan of [ { label: "esm", entry: "/app/main.mts" }, { label: "cjs", entry: "/app/legacy-main.cjs" }, { label: "typed", entry: "/app/pkg/main.mjs" }, { label: "nm-ts", entry: "/app/nm-main.cjs" }, { label: "tsx", entry: "/app/tsx-main.cjs" }, { label: "enum", entry: "/app/enum-main.mts" }, { label: "tsx-esm", entry: "/app/tsx-esm-main.mts" }, ]) { const proc = runtime.exec(plan.entry); const drained = Promise.all([ proc.stdout.pipeTo(new WritableStream({ write: (c) => { out.textContent += dec.decode(c); }, })), proc.stderr.pipeTo(new WritableStream({ write: (c) => { errEl.textContent += dec.decode(c); }, })), ]); const code = await proc.exited; await drained; codes.push(`${plan.label}=${code}`); } exitEl.textContent = codes.join(" ");} catch (e) { errEl.textContent = "BOOT FAILED: " + (e?.message ?? String(e)); exitEl.textContent = "?";}