Repository navigation
fix(core): window.__hf has one type, owned by the runtime that sets it - #9114
Conversation
jrusso1020
left a comment
There was a problem hiding this comment.
Reviewed at c10298d. The change reads right; one check this PR itself turns red holds the approval.
Requesting changes for the Comments check only. The comment ratchet fails on the new file: packages/core/src/runtime/hfProtocol.ts is 36.4% comments (36/99) and the package carries 10.6%. Most of that is the per-field doc lines moved over from the two old declarations. Trim them (the field names already say most of it) or get the file under the share another way, and I approve on the green head with no further read of the rest.
What I checked in the diff, all five files read in full as changed:
HfProtocolin core is the oldwindow.d.tsshape field for field, plusmediaandtransitionsfrom the engine copy. Nothing dropped from either side.HfMediaElementandHfTransitionMetamatch the engine copies field for field; the shader-transitions copy matched too.window.d.tsloses only__hfand the four imports it alone used.- Engine keeps its four exported names;
HfSeekOptionsis nowRuntimeSeekOptions.durationandseekbecome optional for engine's callers, as the body says. Engine and producer readers I found already guard both (typeof ... === "function",?? 0). - shader-transitions imports the type only, uses it in a local type, and already has core as a dev dependency, so its bundle and its declarations do not gain a dependency.
fails without the fix:is in the body.
Not run: type checks, builds or the byte comparison (no installed packages on this box); those claims are taken from the body.
Need: yes, two declarations of one global · Size: +108/-144, right · Reuse: one type, three users · Simpler: no · Structure: the owner of the value owns the type
Risk: low, types only; the optional duration/seek is the one visible change for outside users of the engine types.
— Rames
Edit accuracy: accurate 275 (base branch 273), smooth 65 of thoseThe gate passes. Newly passing (2)
Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)
Quarantined, measured but not gated (0) |
|
Fixed at 608fe72, both red checks. Comments: Build (package size), and a correction to the body: the body called the three extra files in core's Measured at this head against main, from clean
Also run: |
jrusso1020
left a comment
There was a problem hiding this comment.
Reviewed at 608fe72 (re-review; prior change request at c10298d).
Prior point: the Comments check was red on packages/core/src/runtime/hfProtocol.ts. Resolved: the comments are trimmed and the check passes at this head.
Delta since c10298d, read whole (compared the PR's own diff at both heads):
colorGradingApi.tsis new and holds the four public types, moved byte for byte out ofruntime/colorGrading.ts. It imports only a type from../colorGrading.hfProtocol.ts,init.ts,colorGrading.tsand its test now import those types from the new file. No other importer of the four names exists in the packages.- The rest of the delta is main merged in (the Studio type-check slice); against main the PR touches no Studio file.
- No runtime line changed in the delta.
Not run: build, type check and tests (no installed packages on this machine). Build was still pending when I posted; the size claim (core +4.5 KB instead of +109 KB) is the author's number, not measured by me.
Need: yes · Size: fine · Reuse: one shape in core · Simpler: no · Structure: types file apart from the runtime is the right cut
Risk: low, types only.
— Rames
What
window.__hfnow has one type,HfProtocol, declared inpackages/core/src/runtime/hfProtocol.tstogether with the global that typeswindow.__hf. Engine re-exports it under its existing names, and shader-transitions importsHfTransitionMetainstead of keeping a copy.Why
The page's
__hfobject was typed twice: in core'sruntime/window.d.ts(what the runtime sets:seek,colorGrading,clipWindow, ...) and in engine'stypes.tsasHfProtocol(what the renderer reads:duration,seek,media,transitions). Each package checked fine alone. Any check that loads both fails:Subsequent property declarations must have the same type. Property '__hf' must be of type ...(TS2717). Studio's type check already loads engine, through the dev server's producer import. Its sealed tests reach core runtime files such aseditingAgent.ts, which readwindow.__playerand other globals fromwindow.d.ts, so checking those tests means loadingwindow.d.tstoo, and the two__hfdeclarations then collide. That blocks type-checking most of Studio's test folders. Loadingwindow.d.tsthere is the next change, not this one. shader-transitions held a third copy ofHfTransitionMeta, kept in step by a comment.How
runtime/hfProtocol.tsholdsHfMediaElement,HfTransitionMetaandHfProtocol: core's fields plus engine'smediaandtransitions. It also declaresWindow.__hf, so anything that imports the type gets the global too. Core's index exports the three types, plusRuntimeSeekOptions.window.d.tsno longer declares__hf.types.tsre-exportsHfMediaElement,HfProtocol,HfTransitionMetaandRuntimeSeekOptions as HfSeekOptionsfrom core, and drops its own__hfglobal.HfTransitionMetafrom core as a type only, so its CDN bundle does not change.One type change for engine's callers: engine's
HfProtocolhaddurationandseekrequired, and core's has them optional, as the runtime sets them during boot. Nothing in this repo relied on that: engine, producer, studio-server, Studio and shader-transitions type-check with no edits.HfSeekOptionsgains core's optionalexact.Test plan
runtime/window.d.tsand engine'ssrc/types.tstogether (a temporary tsconfig inpackages/enginewith those twofiles). On main it reports TS2717 atsrc/types.ts(483,5); here it reports nothing. The guard stays: engine's own typecheck now loads core's declaration, so a second__hfin engine fails there.tsc --noEmitpasses in core, engine, producer, studio-server, studio and shader-transitions, plus Studio'stsconfig.check.json.distfolders, at this commit and its parent: engine and shader-transitions emit identical files. Core emits the same files byte for byte, the runtime bundle included. It addsruntime/hfProtocol.js(export {}),runtime/colorGrading.jsandruntime/mutationRecords.js, which the new module's type imports bring into core's build. Nothing indistimports any of the three.No visible change
Type declarations only; no emitted JavaScript changes for any existing file.