Write HTML. Render video. Built for agents.
JavaScript aiai-agentsanimationclaude-codeffmpegframeworkgsaphtmlhtml-to-videomcpmotion-graphicspuppeteerrenderingtypescriptvideo-editor
fix(core): preserve static methods on classes exposed through scoped window
func25d3127a7507aa
diff --git a/packages/core/src/compiler/compositionScoping.test.ts b/packages/core/src/compiler/compositionScoping.test.tsindex ddd9a1ab60..07c7faf01a 100644--- a/packages/core/src/compiler/compositionScoping.test.ts+++ b/packages/core/src/compiler/compositionScoping.test.ts@@ -146,6 +146,28 @@ body { margin: 0; }expect(variablesByComp["card-1"]).toEqual({ title: "Pro" });});+ it("preserves static methods on classes exposed through window", () => {+ const { document } = parseHTML(`<div data-composition-id="scene"></div>`);+ class FakeTexts {+ static mountChars() {+ return "ok";+ }+ }+ const fakeWindow: Record<string, unknown> = {+ document,+ __timelines: {},+ Texts: FakeTexts,+ };+ const wrapped = wrapScopedCompositionScript(+ `window.__capturedMountCharsType = typeof window.Texts?.mountChars;`,+ "scene",+ );++ new Function("window", wrapped)(fakeWindow);++ expect(fakeWindow.__capturedMountCharsType).toBe("function");+ });+it("executes document and GSAP selectors inside the composition root", () => {const { document } = parseHTML(`<div data-composition-id="scene" data-start="intro"><h1 class="title">Scene</h1></div>diff --git a/packages/core/src/compiler/compositionScoping.ts b/packages/core/src/compiler/compositionScoping.tsindex 876ab59bc2..280fe5df82 100644--- a/packages/core/src/compiler/compositionScoping.ts+++ b/packages/core/src/compiler/compositionScoping.ts@@ -383,8 +383,7 @@ export function wrapScopedCompositionScript(? new Proxy(window, {get: function(target, prop, receiver) {if (prop === "__timelines") return __hfGetTimelineRegistry();- var value = Reflect.get(target, prop, target);- return typeof value === "function" ? value.bind(target) : value;+ return Reflect.get(target, prop, target);},set: function(target, prop, value, receiver) {if (prop === "__timelines") {