Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879// The Phase A browser-matrix check (docs/WEB-APP.md): bundles the web// runtime core and serves a page that executes it IN THE BROWSER — tile// engine round-trip on the memory store, plus availability of the APIs the// web app leans on (SharedWorker, Web Locks, Cache API). Open the printed// URL in each browser you care about; everything runs locally, no network,// no credentials.// Run: deno run -A tools/web-proof.ts (then open http://127.0.0.1:4187)
const PAGE = `<!doctype html><html lang="en"><meta charset="utf-8"><title>Ziran web core — proof of life</title><style> body { font-family: system-ui, sans-serif; max-width: 44rem; margin: 3rem auto; padding: 0 1rem; color: oklch(0.28 0.012 352); } h1 { font-size: 1.3rem; } li { margin: 0.35rem 0; } .pass::before { content: "PASS "; color: oklch(0.45 0.12 165); font-weight: 600; } .fail::before { content: "FAIL "; color: oklch(0.55 0.19 25); font-weight: 600; } .pending::before { content: "… "; color: oklch(0.5 0.014 352); }</style><h1>Ziran web core — proof of life</h1><p>The browser-platform bundle of the portable core, executing right here.</p><ul id="out"></ul><script type="module"> const out = document.getElementById('out'); const report = (label, ok, detail = '') => { const li = document.createElement('li'); li.className = ok ? 'pass' : 'fail'; li.textContent = label + (detail ? ' — ' + detail : ''); out.appendChild(li); }; report('SharedWorker available', typeof SharedWorker === 'function'); report('Web Locks available', Boolean(navigator.locks)); report('Cache API available', typeof caches === 'object'); report('crypto.subtle available', Boolean(crypto?.subtle)); try { const core = await import('./web-core.js'); report('the browser bundle imports', true); core.setZiranFs(new core.MemoryFs()); const path = '/proof/doc.tile'; await core.writeTile( { name: 'Browser Proof', model: { id: 'com.berjon.ziran.testtile' }, resources: {} }, new Map([ ['/', new TextEncoder().encode('<!doctype html><title>p</title>')], ['/.well-known/web-tiles-storage/state', new TextEncoder().encode('{}')], ]), path, ); const parsed = await core.parseTile(path); report('tile engine round-trips on the memory store (CID-verified)', !parsed.damaged && parsed.manifest.name === 'Browser Proof'); const id = await core.docIdForPath(path); report('doc ids derive', typeof id === 'string' && id.length === 16, id); report('scope string exported', core.ZIRAN_SCOPE.includes('include:space.ziran.permissions')); } catch (err) { report('the browser bundle executes', false, String(err)); }</script>`;
const ROOT = new URL('..', import.meta.url);const tmp = await Deno.makeTempDir({ prefix: 'ziran-web-proof-' });const bundle = await new Deno.Command(Deno.execPath(), { args: ['bundle', '--platform', 'browser', '--output', `${tmp}/web-core.js`, 'src/web/runtime-core.ts'], cwd: ROOT.pathname, stdout: 'inherit', stderr: 'inherit',}).output();if (!bundle.success) Deno.exit(1);const coreJs = await Deno.readFile(`${tmp}/web-core.js`);await Deno.remove(tmp, { recursive: true }).catch(() => {});
Deno.serve({ port: 4187, hostname: '127.0.0.1' }, (req) => { const path = new URL(req.url).pathname; if (path === '/web-core.js') { return new Response(coreJs as BodyInit, { headers: { 'content-type': 'text/javascript' } }); } return new Response(PAGE, { headers: { 'content-type': 'text/html; charset=utf-8' } });});console.log('web proof: open http://127.0.0.1:4187 in each browser you care about');