fix(core): wrap bundled composition scripts as string literals

This commit is contained in:
func25
2026-05-25 15:41:13 +07:00
parent e101b47be4
commit 3bb0d1efd9
5 changed files with 53 additions and 10 deletions
@@ -216,6 +216,7 @@ export function wrapScopedCompositionScript(
const authoredRootIdFormsLiteral = JSON.stringify(
getAuthoredRootIdSelectorForms(authoredRootId?.trim() || ""),
);
const sourceLiteral = JSON.stringify(source);
return `(function(){
var __hfCompId = ${compositionIdLiteral};
var __hfTimelineCompId = ${timelineCompositionIdLiteral};
@@ -485,9 +486,8 @@ export function wrapScopedCompositionScript(
});
var __hfRun = function() {
try {
(function(document, gsap, window, __hyperframes) {
${source}
}).call(window, __hfScopedDocument, __hfScopedGsap, __hfScopedWindow, __hfScopedHyperframes);
var __hfScript = Function("document", "gsap", "window", "__hyperframes", ${sourceLiteral});
__hfScript.call(window, __hfScopedDocument, __hfScopedGsap, __hfScopedWindow, __hfScopedHyperframes);
} catch (_err) {
console.error(__hfErrorLabel, __hfCompId, _err);
}
@@ -496,3 +496,7 @@ ${source}
__hfRun();
})();`;
}
export function wrapInlineScriptWithErrorBoundary(source: string, errorLabel: string): string {
return `(function(){ try { Function(${JSON.stringify(source)}).call(window); } catch (_err) { console.error(${JSON.stringify(errorLabel)}, _err); } })();`;
}