()
| 11 | |
| 12 | // Terminate the shared worker and reset state so the next run respawns cold. |
| 13 | async function killWorker() { |
| 14 | const wp = workerPromise |
| 15 | workerPromise = null |
| 16 | workerReady = false |
| 17 | activeSink = null |
| 18 | try { (await wp)?.dispose() } catch {} |
| 19 | } |
| 20 | |
| 21 | // `onPhase` only matters for the first (cold) call: 'runtime' (downloading the ESM) then 'worker' (spawn + wasm fetch/instantiate). |
| 22 | function getWorker(onPhase) { |