Skip to content

refactor(types): tighten type safety, dedupe HfTransitionMeta, prune dead LUT export#366

Merged
vanceingalls merged 2 commits intomainfrom
vance/type-safety
Apr 22, 2026
Merged

refactor(types): tighten type safety, dedupe HfTransitionMeta, prune dead LUT export#366
vanceingalls merged 2 commits intomainfrom
vance/type-safety

Conversation

@vanceingalls
Copy link
Copy Markdown
Collaborator

@vanceingalls vanceingalls commented Apr 21, 2026

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

  • bun run --filter @hyperframes/engine typecheck
  • bun run --filter @hyperframes/producer typecheck
  • bun run --filter @hyperframes/shader-transitions typecheck
  • 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.

Copy link
Copy Markdown
Collaborator Author

vanceingalls commented Apr 21, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

This was referenced Apr 21, 2026
@vanceingalls vanceingalls marked this pull request as ready for review April 21, 2026 20:57
@vanceingalls vanceingalls force-pushed the vance/hdr-regression-tests branch from a54acd2 to ebe1483 Compare April 22, 2026 02:03
Copy link
Copy Markdown
Collaborator

@jrusso1020 jrusso1020 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean dedupe + hygiene. HfTransitionMeta was genuinely declared twice in the same file (the second declaration a duplicate of the first) — Typescript accepted it because the shapes matched but any future drift would have been a silent landmine. Pruning getSrgbToHdrLut from the package exports is fine — the LUT tables are still used internally via the two cached instances. The for..of entries() refactor in renderOrchestrator reads equivalently and avoids the non-null assertion.

One substantive note worth calling out: the comment you added on the shader-transitions local HfTransitionMeta ("Locally redeclared because @hyperframes/shader-transitions ships as a standalone CDN bundle and must not depend on @hyperframes/engine") is load-bearing. That kind of "this is the shape contract between two packages that deliberately don't share types" gotcha is exactly the thing that rots silently unless it's documented in code. Glad it's pinned in the diff.

Approved.

Rames Jusso

@vanceingalls vanceingalls force-pushed the vance/type-safety branch 2 times, most recently from 640cc95 to 57d7248 Compare April 22, 2026 05:09
@vanceingalls vanceingalls force-pushed the vance/hdr-regression-tests branch from 04e4040 to b03abc3 Compare April 22, 2026 05:09
@vanceingalls
Copy link
Copy Markdown
Collaborator Author

Thanks. The local-redeclare comment on HfTransitionMeta in @hyperframes/shader-transitions is intentional and load-bearing — shader-transitions ships as a standalone CDN bundle (per its package design) and can't take a dep on @hyperframes/engine, so the type duplication is the documented escape hatch rather than an oversight to clean up later. Will keep that note in the diff.

@vanceingalls vanceingalls force-pushed the vance/hdr-regression-tests branch from b03abc3 to 632e75f Compare April 22, 2026 06:21
@vanceingalls vanceingalls force-pushed the vance/hdr-regression-tests branch 2 times, most recently from 3734a6c to e9cfefd Compare April 22, 2026 16:29
@vanceingalls vanceingalls changed the base branch from vance/hdr-regression-tests to graphite-base/366 April 22, 2026 17:07
@vanceingalls vanceingalls changed the base branch from graphite-base/366 to vance/hdr-regression-tests April 22, 2026 17:19
@vanceingalls vanceingalls force-pushed the vance/hdr-regression-tests branch from 8c73295 to 8d3b778 Compare April 22, 2026 17:30
@vanceingalls vanceingalls force-pushed the vance/hdr-regression-tests branch from 8d3b778 to 3495f7a Compare April 22, 2026 18:50
@vanceingalls vanceingalls force-pushed the vance/hdr-regression-tests branch 2 times, most recently from 7334041 to 6b49885 Compare April 22, 2026 19:34
@vanceingalls vanceingalls force-pushed the vance/type-safety branch 2 times, most recently from 5a76392 to d315596 Compare April 22, 2026 20:45
@vanceingalls vanceingalls force-pushed the vance/hdr-regression-tests branch from 6b49885 to 35b9f0a Compare April 22, 2026 20:48
@vanceingalls vanceingalls force-pushed the vance/hdr-regression-tests branch from 35b9f0a to bfbc709 Compare April 22, 2026 22:13
@vanceingalls vanceingalls changed the base branch from vance/hdr-regression-tests to graphite-base/366 April 22, 2026 22:43
…dead LUT export

Four focused cleanups across engine, producer, and shader-transitions.

* renderOrchestrator: replace `layers[layerIdx]!` non-null assertion with
  `for (const [layerIdx, layer] of layers.entries())` so both index and
  element come from the iterator and the assertion goes away.
* engine/types.ts: remove duplicate `HfTransitionMeta` interface that
  arrived as a rebase artifact; the original definition above it is the
  one with documentation. The orphaned doc comment now correctly
  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 definition 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.

Verified with `bun run --filter @hyperframes/engine typecheck`,
`bun run --filter @hyperframes/producer typecheck`,
`bun run --filter @hyperframes/shader-transitions typecheck`,
and `bun run --filter @hyperframes/engine test` (308 pass).
@graphite-app graphite-app Bot changed the base branch from graphite-base/366 to main April 22, 2026 22:43
@vanceingalls vanceingalls merged commit 5de5df7 into main Apr 22, 2026
30 checks passed
Copy link
Copy Markdown
Collaborator Author

Merge activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants