Skip to content

Write HTML. Render video. Built for agents.

fix(core): revert Function constructor back to inline IIFE for composition scripts

Miguel Ángelccee8df4e135
diff --git a/packages/core/src/compiler/compositionScoping.ts b/packages/core/src/compiler/compositionScoping.ts
index 72e9cbbf8b..ba9412f300 100644
--- a/packages/core/src/compiler/compositionScoping.ts
+++ b/packages/core/src/compiler/compositionScoping.ts
@@ -216,7 +216,6 @@ export function wrapScopedCompositionScript(
const authoredRootIdFormsLiteral = JSON.stringify(
getAuthoredRootIdSelectorForms(authoredRootId?.trim() || ""),
);
- const sourceLiteral = JSON.stringify(source);
return `(function(){
var __hfCompId = ${compositionIdLiteral};
var __hfTimelineCompId = ${timelineCompositionIdLiteral};
@@ -486,8 +485,9 @@ export function wrapScopedCompositionScript(
});
var __hfRun = function() {
try {
- var __hfScript = Function("document", "gsap", "window", "__hyperframes", ${sourceLiteral});
- __hfScript.call(window, __hfScopedDocument, __hfScopedGsap, __hfScopedWindow, __hfScopedHyperframes);
+ (function(document, gsap, window, __hyperframes) {
+${source}
+ }).call(window, __hfScopedDocument, __hfScopedGsap, __hfScopedWindow, __hfScopedHyperframes);
} catch (_err) {
console.error(__hfErrorLabel, __hfCompId, _err);
}