/** * Sandbox Web Worker entry. * * Import order is load-bearing: `./lockdown` MUST come first — ESM executes * imports in order, so the network/storage stubs are installed before the * engine module (and its dependency `pinets`) is evaluated. * * This file is the only place PineTS reaches the browser, bundled into its * own worker chunk (see README-user-scripts.md for the licensing rationale). */ import "./lockdown"; import { PinetsEngine } from "../engine/pinets-engine"; import { createState, handleMessage } from "./worker-core"; import type { ToWorker } from "./protocol"; const engine = new PinetsEngine(); const state = createState(); self.onmessage = async (ev: MessageEvent) => { const response = await handleMessage(engine, state, ev.data); (self as unknown as Worker).postMessage(response); };