// 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 = `
Ziran web core — proof of life
Ziran web core — proof of life
The browser-platform bundle of the portable core, executing right here.
`;
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');