// fallow-ignore-file unused-file complexity /** * HyperFrames early stub — injected at the very start of `` before any * other scripts run. Compiled to an IIFE by scripts/build-hf-early-stub.ts. * * This file lives outside `src/` intentionally: it is compiled by a separate * esbuild step, NOT by the producer's tsc. Only the generated output * (src/generated/hf-early-stub-inline.ts) is type-checked by tsc. * * Responsibilities * ───────────────────────────────────────────────────────────────────────────── * 1. Create `window.__hf` so page scripts can write to it before the bridge * loads (e.g. @hyperframes/shader-transitions writes transition metadata * during its init() call, which runs before end-of-body scripts). * * 2. Intercept `window.gsap` assignment and batch `timeline.to/from/fromTo/set` * calls via requestAnimationFrame to prevent the main-thread hang described * in https://github.com/heygen-com/hyperframes/issues/1231. * * GSAP batching background * ───────────────────────────────────────────────────────────────────────────── * Compositions with very large tween counts (thousands of `tl.to()` calls) block * Chrome's main thread synchronously during HTML parsing, preventing * DOMContentLoaded from firing before Puppeteer's navigation timeout. Each * `tl.to()` triggers a synchronous GSAP state recomputation; 8 000+ calls in a * row have been observed to hold the thread for >60 s. * * Fix: intercept `gsap.timeline()` via an `Object.defineProperty` trap on * `window`. GSAP is not yet loaded when this stub runs — it loads via a * `