mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 04:38:33 +00:00
refactor(core): apply /simplify findings on sub-comp scoping PR
- compositionLoader.ts: drop the redundant inline `Window` cast; the
ambient `__hfVariablesByComp?` declaration in runtime/window.d.ts
already covers it within the same package.
- compositionScoping.test.ts: drop the `__captured: undefined as unknown`
initializers — `Record<string, unknown>` already permits the key, the
init was noise.
Reuse + efficiency reviews returned clean. The scoped getVariables's
per-call Object.assign({}, scoped) is consistent with the file's
existing scoped-utility conventions (gsap proxy returns fresh bound
functions per access) and acceptable since the idiomatic usage
destructures once at script init.
All 44 touched core tests still green.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
committed by
James Russo
co-authored by
Claude Opus 4.7
parent
484ab54442
commit
1da6f456b7
@@ -64,7 +64,6 @@ body { margin: 0; }
|
|||||||
getVariables: () => ({ title: "TOP-LEVEL-LEAK" }),
|
getVariables: () => ({ title: "TOP-LEVEL-LEAK" }),
|
||||||
fitTextFontSize: () => undefined,
|
fitTextFontSize: () => undefined,
|
||||||
},
|
},
|
||||||
__captured: undefined as unknown,
|
|
||||||
};
|
};
|
||||||
const wrapped = wrapScopedCompositionScript(
|
const wrapped = wrapScopedCompositionScript(
|
||||||
`window.__captured = __hyperframes.getVariables();`,
|
`window.__captured = __hyperframes.getVariables();`,
|
||||||
@@ -85,7 +84,6 @@ body { margin: 0; }
|
|||||||
getVariables: () => ({ title: "TOP-LEVEL-LEAK" }),
|
getVariables: () => ({ title: "TOP-LEVEL-LEAK" }),
|
||||||
fitTextFontSize: () => undefined,
|
fitTextFontSize: () => undefined,
|
||||||
},
|
},
|
||||||
__captured: undefined as unknown,
|
|
||||||
};
|
};
|
||||||
const wrapped = wrapScopedCompositionScript(
|
const wrapped = wrapScopedCompositionScript(
|
||||||
`window.__captured = __hyperframes.getVariables();`,
|
`window.__captured = __hyperframes.getVariables();`,
|
||||||
|
|||||||
@@ -244,11 +244,8 @@ async function mountCompositionContent(params: {
|
|||||||
...parseHostVariableValues(params.host),
|
...parseHostVariableValues(params.host),
|
||||||
};
|
};
|
||||||
if (Object.keys(merged).length > 0) {
|
if (Object.keys(merged).length > 0) {
|
||||||
const w = window as Window & {
|
if (!window.__hfVariablesByComp) window.__hfVariablesByComp = {};
|
||||||
__hfVariablesByComp?: Record<string, Record<string, unknown>>;
|
window.__hfVariablesByComp[scopeCompositionId] = merged;
|
||||||
};
|
|
||||||
if (!w.__hfVariablesByComp) w.__hfVariablesByComp = {};
|
|
||||||
w.__hfVariablesByComp[scopeCompositionId] = merged;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user