// Containment proof for the TypeScript engine: this page imports the host tagged // ?nib-selftest=ts-engine-off — the query rides to the kernel worker, whose strip // init fails (as it would under a CSP without 'wasm-unsafe-eval'; this Chromium // does not bind that directive to module workers, so the genuine failure cannot be // staged). The kernel must still boot — plain JS keeps running — while every .ts // load fails with the named ERR_NIB_TS_ENGINE. import { boot } from "@nibling/kernel-off"; const out = document.getElementById("out"); const errEl = document.getElementById("err"); const exitEl = document.getElementById("exit"); const dec = new TextDecoder(); try { const runtime = await boot(); runtime.writeTree({ "/app/plain.js": "module.exports = 'plain js still runs';\n", "/app/js-main.cjs": "const tag = require('./plain.js');\nconsole.log(tag);\n", "/app/stripped.ts": "const tag: string = 'never';\nmodule.exports = tag;\n", "/app/ts-main.cjs": "const t = require('./stripped.ts');\nconsole.log(t);\n", }); const codes = []; for (const plan of [ { label: "js", entry: "/app/js-main.cjs" }, { label: "ts", entry: "/app/ts-main.cjs" }, ]) { 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 = "?"; }