mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 16:08:56 +00:00
* perf(core): skip rendering preview scenes far from the playhead * refactor(core): split the far-scene pass into small helpers * perf(core): a first render reveals only the clips it reaches * fix(core): reveal the clips holding first-rendered tweens, wherever their window is * feat(core): a scene may load a project helper and wait for fonts and still swap * perf(core): the preview mounts only the scenes near the playhead * perf(core): a seek waits only for the scene it lands in; neighbours mount one per turn * feat(studio): selecting a clip in an unmounted scene mounts that scene first * fix(core): a source a play and a seek both need is fetched and decoded once * fix(core): a scene mounting during play joins the mix without restarting what plays * fix(studio): selecting a clip waits on a scene mount only in a preview that unmounts scenes * fix(core): far scenes still mount after an edit, and an edit to a parked scene keeps its styles * perf(core): web audio schedules a clip only as the playhead comes near it * chore(studio): trim the scene hold helper's comments to its package's share * fix(core): a scene the preview unmounts is freed, not kept by audio, caches or old roots * fix(studio): an unmounted scene's rows and their state come from the markup it mounts with * perf(core): the preview mounts scenes ahead of play and keeps recent ones mounted * refactor(core): keep the far-scene neighbour rule private to its module * style(core): format the far-scene neighbour rule * perf(core): the preview unmounts scenes the playhead leaves, as kept ones slowed each mount * fix(core): scenes that measure text, call their own animate or wait on font loads can unmount * fix(core): each preview scene carries the helpers it loads, so it mounts on its own * fix(core): a mounted scene shows though its stand-in was hidden by display * fix(core): a helper scenes share runs once for the film, and a remounted scene keeps showing * fix(core): a scene that also publishes its timeline under another id stays mounted * feat(core): scenes that draw in 2D or chain the timeline they register can unmount * perf(core): a play frame that draws nothing new skips the hidden-clip lookup * fix(core): a GSAP file copied into a project counts as the library for scene unmounting * style(core): drop an unneeded escape in the registered-chain pattern * chore: core and producer size budgets make room for the preview scene window * fix(core): a scene that draws on a 2D canvas stays mounted * fix(core): a scene the preview unmounts lets go of timelines it built after a font wait * perf(core): a scene leaving the playhead keeps its last rendered size, no forced layout at the cut * refactor(core): the far-scene skip keeps last-render boxes in their own helper * fix(core): a mounting scene never records the runtime's root timeline as its own * chore(producer): raise the size budget to the measured size with the preview runtime inlined * docs(core): keep the far-scene and scene-memory comments within the comment limits * perf(core): style each hidden clip visible once ahead of its cut, so the cut frame does not * fix(core): a seek into a scene still mounting as a neighbour waits for that mount * chore(core): keep comment share and size budgets to main plus the measured core growth
103 lines
3.7 KiB
TypeScript
103 lines
3.7 KiB
TypeScript
import { refreshSvgSelectorAliases } from "../compiler/svgSelectorAliases";
|
|
import { recordStartupError } from "./diagnostics";
|
|
import {
|
|
initSandboxRuntimeModular,
|
|
installAuthoredMediaCapture,
|
|
installFlatGsapTransforms,
|
|
} from "./init";
|
|
import { installAuthoredOpacityCapture } from "./colorGrading";
|
|
import { deferMediaUntilDue } from "./preloadMedia";
|
|
import { hideTimedClipsUntilFirstPass, keepInlineHideRulesForOlderShaders } from "./timedClipHide";
|
|
import { fitTextFontSize } from "../text/fitTextFontSize";
|
|
import { pretext } from "../text/pretext";
|
|
import { assetUrl } from "./assetUrl";
|
|
import { getVariables } from "./getVariables";
|
|
import { clearRuntimeData, registerRuntimeDataHandler, setRuntimeData } from "./runtimeData";
|
|
import { runScriptsAfterFonts } from "./afterFonts";
|
|
import { AFTER_FONTS_SCRIPTS } from "../compiler/scriptRuns";
|
|
import { hasFrameSources, registerFrameSource } from "./frameSources";
|
|
import { createFilmBridge } from "./filmBridge";
|
|
import { trackAcceleratedCanvases } from "./captureMotionBlur";
|
|
import { parkFarScenesAtBoot } from "./sceneWindow";
|
|
|
|
type HyperframeWindow = Window & {
|
|
__hyperframeRuntimeBootstrapped?: boolean;
|
|
__hyperframes?: {
|
|
assetUrl: typeof assetUrl;
|
|
fitTextFontSize: typeof fitTextFontSize;
|
|
getVariables: typeof getVariables;
|
|
pretext: typeof pretext;
|
|
registerRuntimeDataHandler: typeof registerRuntimeDataHandler;
|
|
setRuntimeData: typeof setRuntimeData;
|
|
clearRuntimeData: typeof clearRuntimeData;
|
|
registerFrameSource: typeof registerFrameSource;
|
|
createFilmBridge: typeof createFilmBridge;
|
|
};
|
|
};
|
|
|
|
// Inline composition scripts can run before DOMContentLoaded.
|
|
// Ensure timeline registry exists at script evaluation time.
|
|
(window as HyperframeWindow).__timelines = (window as HyperframeWindow).__timelines || {};
|
|
|
|
// Stamp color-graded elements with their authored inline opacity BEFORE the
|
|
// composition's animation scripts (and the grading hide) mutate it — must run
|
|
// at script evaluation time, while the document is still parsing.
|
|
installAuthoredOpacityCapture();
|
|
installAuthoredMediaCapture();
|
|
installFlatGsapTransforms();
|
|
trackAcceleratedCanvases();
|
|
window.__hfHasFrameSources = hasFrameSources;
|
|
|
|
hideTimedClipsUntilFirstPass();
|
|
deferMediaUntilDue();
|
|
|
|
// Expose runtime helpers immediately so composition scripts can use them
|
|
// before DOMContentLoaded (font sizing runs during script evaluation, and
|
|
// getVariables is read by composition setup before the timeline is built).
|
|
(window as HyperframeWindow).__hyperframes = {
|
|
assetUrl,
|
|
fitTextFontSize,
|
|
getVariables,
|
|
pretext,
|
|
registerRuntimeDataHandler,
|
|
setRuntimeData,
|
|
clearRuntimeData,
|
|
registerFrameSource,
|
|
createFilmBridge,
|
|
};
|
|
|
|
function bootstrapHyperframeRuntime(): void {
|
|
const win = window as HyperframeWindow;
|
|
if (win.__hyperframeRuntimeBootstrapped) {
|
|
return;
|
|
}
|
|
win.__hyperframeRuntimeBootstrapped = true;
|
|
keepInlineHideRulesForOlderShaders();
|
|
initSandboxRuntimeModular();
|
|
}
|
|
|
|
// Compiled composition scripts wait for web fonts, so what they measure matches every run.
|
|
function startAfterCompositionScripts(): void {
|
|
try {
|
|
parkFarScenesAtBoot();
|
|
refreshSvgSelectorAliases();
|
|
const deferred = Array.from(document.querySelectorAll(AFTER_FONTS_SCRIPTS));
|
|
if (deferred.length === 0) bootstrapHyperframeRuntime();
|
|
else {
|
|
void runScriptsAfterFonts(deferred, bootstrapHyperframeRuntime).catch((err: unknown) => {
|
|
recordStartupError(err);
|
|
reportError(err);
|
|
});
|
|
}
|
|
} catch (err) {
|
|
recordStartupError(err);
|
|
throw err;
|
|
}
|
|
}
|
|
|
|
if (document.readyState === "loading") {
|
|
document.addEventListener("DOMContentLoaded", startAfterCompositionScripts, { once: true });
|
|
} else {
|
|
startAfterCompositionScripts();
|
|
}
|