mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-14 18:01:20 +08:00
4279ba20e5
hf#677 follow-up. 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 and the hybrid path in PR 4 wires it up. Why a separate pool: the shader blend is a hot inner loop iterated over every pixel of every transition frame at 16bpc. Running it on the main event loop was previously the dominant wall-time bottleneck once DOM capture parallelism was reached. Moving it to `worker_threads` unblocks the main thread for CDP dispatch and pipelined decode/blit. Pieces: * `shaderTransitionWorker.ts` — the worker entry. Imports `TRANSITIONS` + `crossfade` from `@hyperframes/engine/shader-transitions` (the subpath added here on the engine package). Like the alpha-blit subpath, this is a zero-import TS file so it survives the `new Worker(<path>)` loader boundary without dragging in the producer module graph. * `shaderTransitionWorkerPool.ts` — fixed-size pool with `run()` API. Uses `transferList` so the 16bpc HDR `from`/`to`/`out` buffers move by ownership across the boundary instead of being copied. * `shaderTransitionWorkerPool.test.ts` — 6 vitest tests pinning byte- equivalence across all 15 shaders against an inline reference, transferList correctness, and pool lifecycle (concurrent dispatch + termination). All pass. Build wiring: * `packages/cli/tsup.config.ts`: third tsup entry emits `dist/shaderTransitionWorker.js` alongside `dist/cli.js`. Same rationale as the pngDecodeBlitWorker entry in PR 2 — the pool's `new Worker(<path>)` resolver probes for that file next to its loaded module. * `packages/producer/build.mjs`: fourth esbuild entry emits the worker as `dist/services/shaderTransitionWorker.js` for direct producer consumers. Adds the `@hyperframes/engine/shader-transitions` workspace alias to the existing `workspaceAliasPlugin`. * `packages/engine/package.json`: adds `./shader-transitions` subpath export pointing at `src/utils/shaderTransitions.ts`. The file is already import-free so the worker can consume the TS source directly. No behavior change in any render. PR 3 of 5 in the hf#732 decomposition stack; stacked on top of PR 2 (pngDecodeBlit pool). -- Vai Co-Authored-By: Vai <vai@heygen.com>
41 lines
1002 B
JSON
41 lines
1002 B
JSON
{
|
|
"name": "@hyperframes/engine",
|
|
"version": "0.6.4",
|
|
"description": "Seekable web page to video rendering engine (Puppeteer + FFmpeg)",
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "https://github.com/heygen-com/hyperframes",
|
|
"directory": "packages/engine"
|
|
},
|
|
"type": "module",
|
|
"main": "./src/index.ts",
|
|
"types": "./src/index.ts",
|
|
"exports": {
|
|
".": "./src/index.ts",
|
|
"./alpha-blit": "./src/utils/alphaBlit.ts",
|
|
"./shader-transitions": "./src/utils/shaderTransitions.ts"
|
|
},
|
|
"scripts": {
|
|
"build": "tsc",
|
|
"test": "vitest run",
|
|
"typecheck": "tsc --noEmit"
|
|
},
|
|
"dependencies": {
|
|
"@hono/node-server": "^1.13.0",
|
|
"@hyperframes/core": "workspace:^",
|
|
"hono": "^4.6.0",
|
|
"linkedom": "^0.18.12",
|
|
"puppeteer": "^24.0.0",
|
|
"puppeteer-core": "^24.39.1"
|
|
},
|
|
"devDependencies": {
|
|
"@types/node": "^25.0.10",
|
|
"@webgpu/types": "^0.1.69",
|
|
"typescript": "^5.7.2",
|
|
"vitest": "^3.2.4"
|
|
},
|
|
"engines": {
|
|
"node": ">=22"
|
|
}
|
|
}
|