lawsynth/apps/playground/examples/worker.example.ts
2026-08-16 23:40:41 +03:00

15 lines
576 B
TypeScript

import { installPlaygroundWorker, type WorkerSimulationHost } from "../src/worker.js";
export interface PlaygroundWorkerScope {
addEventListener(type: "message", listener: (event: MessageEvent) => void): void;
postMessage(value: unknown): void;
}
/**
* Connect the browser worker protocol to a real simulation host.
* The host must be backed by generated `lawsynth-wasm` bindings; this adapter does not emulate one.
*/
export function connectPlaygroundWorker(scope: PlaygroundWorkerScope, host: WorkerSimulationHost): void {
installPlaygroundWorker(scope, host);
}