Something went wrong. Try again.
Monorepo for the nibling.run platform
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132// Demo page logic for the ws fixture: load the snapshot (scripts/snapshot.mjs output),// mount it (recorded mtimes kept), run the app's entry, and mount the server in an iframe.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 res = await fetch("/dist/fixtures/ws.snap"); if (!res.ok) throw new Error(`fixture missing (${res.status}): run npm run fixtures`); runtime.mountSnapshot(await res.arrayBuffer()); const proc = runtime.exec("/app/server.mjs"); proc.stdout.pipeTo(new WritableStream({ write: (c) => { out.textContent += dec.decode(c); } })); proc.stderr.pipeTo(new WritableStream({ write: (c) => { errEl.textContent += dec.decode(c); } })); proc.exited.then((code) => { exitEl.textContent = String(code); });
const url = await runtime.waitForPort(3000); const frame = document.createElement("iframe"); frame.id = "app"; frame.title = "WebSocket app on port 3000"; // The app page takes this page's query: ?manual (the specs drive the sockets) or // ?crash (the whole recorded exchange). frame.src = url + location.search; document.body.append(frame);} catch (e) { errEl.textContent = "BOOT FAILED: " + (e?.message ?? String(e)); exitEl.textContent = "?";}