mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-23 11:29:54 +00:00
* fix(core): paint no timed clip until the runtime decides its visibility Until its first visibility pass, a paused page showed every timed clip at once: an embed without a loader flashed a later scene before the first, and a player's hidden iframe still decoded every scene's images. The runtime now hides timed non-media clips from the moment its script runs, and the first pass that decides them removes that rule, so each clip is shown only by the pass. * refactor(core): name media with the realm-safe helper in the first-pass check * fix(core): share the first-pass hide across runtime copies and shader captures A second evaluation of the runtime (a sub-composition carrying its own runtime tag, or a page that includes it twice) added a hide rule nothing removed, so the film stayed invisible. The rule and its flag now live on the page: a copy that finds either, or finds the runtime already initialised, adds none, and the first pass removes every copy. HyperShader's capture clone forces its scene visible with !important, so a transition captured before the first pass still shows the scene's clips. The runtime test now also pins evaluation-time hiding, inline visibility, media, and two copies. * fix(core): grade media inside a clip once the first pass shows it Color grading registers only media it can see. Media with no timing of its own inside a timed clip inherited the first-pass hide, so grading skipped it, and lifting the rule is not a body mutation, so nothing registered it again: the image or video stayed ungraded. The pass now refreshes grading when it lifts the rule. The second-copy test now asserts on a paused page, before any seek. * chore(core): keep the comment share of the first-pass hide files at or under their base The comment ratchet counts one added comment line each in entry.ts, init.ts and capture.ts, and a new file above its package's share. The three lines are gone, and the one note that has to stay (why the hide runs at script evaluation) now lives in the new module's shorter header.
35 lines
1.5 KiB
TypeScript
35 lines
1.5 KiB
TypeScript
// Hides timed non-media clips from script evaluation until the first visibility pass decides them;
|
|
// before it, a paused page painted every clip at once. Media is left to init's media pass.
|
|
// The rule and its flag live on the page, so every runtime copy shares them.
|
|
const HIDE_ATTR = "data-hf-first-pass-hide";
|
|
const HIDE_UNTIL_FIRST_PASS =
|
|
"[data-start]:not(video, audio, img) { visibility: hidden !important; }";
|
|
|
|
type FirstPassWindow = Window & {
|
|
__hfFirstPassHidden?: boolean;
|
|
__hyperframeRuntimeBootstrapped?: boolean;
|
|
};
|
|
|
|
export function hideTimedClipsUntilFirstPass(): void {
|
|
if (typeof document === "undefined") return;
|
|
const win = window as FirstPassWindow;
|
|
// A runtime that already initialised may never run another pass to lift a new rule.
|
|
if (win.__hfFirstPassHidden || win.__hyperframeRuntimeBootstrapped) return;
|
|
const parent = document.head ?? document.documentElement;
|
|
if (!parent) return;
|
|
const style = document.createElement("style");
|
|
style.setAttribute(HIDE_ATTR, "");
|
|
style.textContent = HIDE_UNTIL_FIRST_PASS;
|
|
parent.appendChild(style);
|
|
win.__hfFirstPassHidden = true;
|
|
}
|
|
|
|
/** True when this call lifted the rule; callers then re-register what skipped hidden elements (grading). */
|
|
export function revealTimedClipsAfterFirstPass(): boolean {
|
|
const win = window as FirstPassWindow;
|
|
if (!win.__hfFirstPassHidden) return false;
|
|
win.__hfFirstPassHidden = false;
|
|
for (const style of document.querySelectorAll(`style[${HIDE_ATTR}]`)) style.remove();
|
|
return true;
|
|
}
|