Skip to content

Commit 5de5df7

Browse files
authored
refactor(types): tighten type safety, dedupe HfTransitionMeta, prune dead LUT export (heygen-com#366)
## Summary Four small, mechanical type-safety cleanups across `engine`, `producer`, and `shader-transitions`. Zero behavior change — pure pre-cleanup so the rest of the stack ships against a tighter baseline. ## Why `Chunk 6` of `plans/hdr-followups.md`. Several non-null assertions and a duplicate interface had accumulated as rebase artifacts and leftover work-in-progress; lands first because it touches files later chunks edit and removes friction during review. ## What changed - `renderOrchestrator.ts`: replace `layers[layerIdx]!` with a `for (const [layerIdx, layer] of layers.entries())` so both index and element come from the iterator. - `engine/types.ts`: drop the duplicate `HfTransitionMeta` interface (rebase artifact); the original definition above it is the documented one. The orphaned doc comment now precedes `HfProtocol`. - `shader-transitions/hyper-shader.ts`: keep the local `HfTransitionMeta` declaration (the package ships as a standalone CDN bundle and must not depend on `@hyperframes/engine`), but add a sync comment pointing at the source of truth in `engine/src/types.ts`. - `alphaBlit.ts` + `engine/index.ts`: drop `export` from `getSrgbToHdrLut` and remove its re-export. It was only ever called by the internal `blitRgba8OverRgb48le`; the public surface was dead code. ## Test plan - [x] `bun run --filter @hyperframes/engine typecheck` - [x] `bun run --filter @hyperframes/producer typecheck` - [x] `bun run --filter @hyperframes/shader-transitions typecheck` - [x] `bun run --filter @hyperframes/engine test` — 308/308 pass (no test changes; assertions removed in code only). ## Stack Chunk 6 of `plans/hdr-followups.md`. Mechanical cleanup landed early per the suggested merge order.
1 parent a6e14da commit 5de5df7

5 files changed

Lines changed: 5 additions & 13 deletions

File tree

packages/engine/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ export {
170170
blitRgb48leRegion,
171171
blitRgb48leAffine,
172172
parseTransformMatrix,
173-
getSrgbToHdrLut,
174173
roundedRectAlpha,
175174
resampleRgb48leObjectFit,
176175
normalizeObjectFit,

packages/engine/src/types.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,6 @@ export interface HfTransitionMeta {
6565
* GSAP, Framer Motion, CSS animations, Three.js — anything works as long
6666
* as `seek()` produces deterministic visual output for a given time.
6767
*/
68-
export interface HfTransitionMeta {
69-
time: number;
70-
duration: number;
71-
shader: string;
72-
ease: string;
73-
fromScene: string;
74-
toScene: string;
75-
}
76-
7768
export interface HfProtocol {
7869
/** Total duration of the composition in seconds */
7970
duration: number;

packages/engine/src/utils/alphaBlit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ const SRGB_TO_HLG = buildSrgbToHdrLut("hlg");
292292
const SRGB_TO_PQ = buildSrgbToHdrLut("pq");
293293

294294
/** Select the correct sRGB→HDR LUT for the given transfer function. */
295-
export function getSrgbToHdrLut(transfer: "hlg" | "pq"): Uint16Array {
295+
function getSrgbToHdrLut(transfer: "hlg" | "pq"): Uint16Array {
296296
return transfer === "pq" ? SRGB_TO_PQ : SRGB_TO_HLG;
297297
}
298298

packages/producer/src/services/renderOrchestrator.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,8 +1562,7 @@ export async function executeRenderJob(
15621562
}
15631563

15641564
// Composite layers bottom-to-top
1565-
for (let layerIdx = 0; layerIdx < layers.length; layerIdx++) {
1566-
const layer = layers[layerIdx]!;
1565+
for (const [layerIdx, layer] of layers.entries()) {
15671566
if (layer.type === "hdr") {
15681567
const before = shouldLog ? countNonZeroRgb48(canvas) : 0;
15691568
const isHdrImage = nativeHdrImageIds.has(layer.element.id);

packages/shader-transitions/src/hyper-shader.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ export function init(config: HyperShaderConfig): GsapTimeline {
113113
}
114114
}
115115

116+
// Locally redeclared (not imported) because @hyperframes/shader-transitions
117+
// ships as a standalone CDN bundle and must not depend on @hyperframes/engine.
118+
// Keep this in sync with HfTransitionMeta in packages/engine/src/types.ts.
116119
interface HfTransitionMeta {
117120
time: number;
118121
duration: number;

0 commit comments

Comments
 (0)