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:
James
2026-05-04 19:42:04 +00:00
committed by James Russo
co-authored by Claude Opus 4.7
parent 484ab54442
commit 1da6f456b7
2 changed files with 2 additions and 7 deletions
@@ -64,7 +64,6 @@ body { margin: 0; }
getVariables: () => ({ title: "TOP-LEVEL-LEAK" }),
fitTextFontSize: () => undefined,
},
__captured: undefined as unknown,
};
const wrapped = wrapScopedCompositionScript(
`window.__captured = __hyperframes.getVariables();`,
@@ -85,7 +84,6 @@ body { margin: 0; }
getVariables: () => ({ title: "TOP-LEVEL-LEAK" }),
fitTextFontSize: () => undefined,
},
__captured: undefined as unknown,
};
const wrapped = wrapScopedCompositionScript(
`window.__captured = __hyperframes.getVariables();`,
@@ -244,11 +244,8 @@ async function mountCompositionContent(params: {
...parseHostVariableValues(params.host),
};
if (Object.keys(merged).length > 0) {
const w = window as Window & {
__hfVariablesByComp?: Record<string, Record<string, unknown>>;
};
if (!w.__hfVariablesByComp) w.__hfVariablesByComp = {};
w.__hfVariablesByComp[scopeCompositionId] = merged;
if (!window.__hfVariablesByComp) window.__hfVariablesByComp = {};
window.__hfVariablesByComp[scopeCompositionId] = merged;
}
}