feat(producer): add shaderTransitionWorkerPool (hf#732 PR 3/5) (#758)

## Summary

PR 3 of 5 in the hf#732 decomposition stack. Adds a `worker_threads`-based pool that runs the shader-transition blend (one of 15 transition shaders) on a fixed-size worker pool. **No production wiring yet** — the pool stands alone; PR 4 wires it.

The shader blend is a hot inner loop over every pixel of every transition frame at 16bpc. Moving it off the main event loop removes the JS-event-loop ceiling that capped throughput in earlier hf#732 iterations.

### New files

- `packages/producer/src/services/shaderTransitionWorker.ts` — worker entry. Imports from `@hyperframes/engine/shader-transitions` (zero-import TS source).
- `packages/producer/src/services/shaderTransitionWorkerPool.ts` — fixed-size pool. Uses `transferList` so the 16bpc HDR `from`/`to`/`out` buffers move by ownership.
- `packages/producer/src/services/shaderTransitionWorkerPool.test.ts` — 6 vitest tests pinning byte-equivalence across all 15 shaders, transferList correctness, pool lifecycle. All pass.

### Build wiring

- `packages/cli/tsup.config.ts`: third tsup entry emits `dist/shaderTransitionWorker.js`.
- `packages/producer/build.mjs`: fourth esbuild entry for direct producer consumers.
- `packages/engine/package.json`: adds `./shader-transitions` subpath export.

## Stack

Stacked on top of #757 (PR 2: pngDecodeBlit pool). No behavior change in any render.

## Test plan

- [x] 6 pool tests pass
- [x] Producer + engine typecheck clean
- [x] oxlint clean

— Vai
This commit is contained in:
Vance Ingalls
2026-05-13 15:17:58 -07:00
committed by GitHub
parent a52c73ebe1
commit 30348af3f4
6 changed files with 860 additions and 1 deletions
+11
View File
@@ -19,6 +19,9 @@ export default defineConfig({
entry: {
cli: "src/cli.ts",
pngDecodeBlitWorker: "../producer/src/services/pngDecodeBlitWorker.ts",
// hf#677/#732: shader-blend worker. Same `new Worker(<path>)`
// bundling rationale as `pngDecodeBlitWorker` above.
shaderTransitionWorker: "../producer/src/services/shaderTransitionWorker.ts",
},
format: ["esm"],
outDir: "dist",
@@ -72,6 +75,14 @@ var __dirname = __hf_dirname(__filename);`,
// `alphaBlit.ts` is import-free (only zlib) so the worker survives
// the worker_thread loader boundary directly via this TS source.
"@hyperframes/engine/alpha-blit": resolve(__dirname, "../engine/src/utils/alphaBlit.ts"),
// hf#677 follow-up: the shader-blend worker imports from
// `@hyperframes/engine/shader-transitions` (subpath export) — a
// standalone TS file with zero internal imports that survives the
// worker_thread loader boundary.
"@hyperframes/engine/shader-transitions": resolve(
__dirname,
"../engine/src/utils/shaderTransitions.ts",
),
};
options.loader = { ...options.loader, ".browser.js": "text" };
},