Skip to content

Commit 4bf2fa5

Browse files
committed
fix: revert flattenInnerRoot, use host-level authored-id + count-based rebind
Three changes to fix regression failures without breaking baselines: 1. Revert flattenInnerRoot in producer — use the original innerHTML inlining that preserves the existing DOM structure. Instead, set data-hf-authored-id on the HOST element so the scoped proxy can still rewrite #id selectors for sub-composition scripts. 2. Revert compiled.html baselines to main (no DOM structure changes). 3. Use timeline-count comparison instead of poll duration to decide whether to call __hfForceTimelineRebind. Compare timeline count before vs after the poll — rebind only when new timelines appeared during polling. This correctly identifies async compositions regardless of fetch speed, while leaving sync compositions untouched.
1 parent 0ff6296 commit 4bf2fa5

4 files changed

Lines changed: 119 additions & 1806 deletions

File tree

‎packages/engine/src/services/frameCapture.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,14 @@ async function pollSubCompositionTimelines(
365365
}
366366
return true;
367367
})()`;
368-
const beforePoll = Date.now();
368+
const timelinesBeforePoll = Number(
369+
await page.evaluate(`Object.keys(window.__timelines || {}).length`),
370+
);
369371
const ready = await pollPageExpression(page, expression, timeoutMs, intervalMs);
370-
const pollDurationMs = Date.now() - beforePoll;
371-
if (ready && pollDurationMs > intervalMs * 2) {
372+
const timelinesAfterPoll = Number(
373+
await page.evaluate(`Object.keys(window.__timelines || {}).length`),
374+
);
375+
if (ready && timelinesAfterPoll > timelinesBeforePoll) {
372376
await page.evaluate(`(function() {
373377
if (typeof window.__hfForceTimelineRebind === "function") {
374378
window.__hfForceTimelineRebind();

‎packages/producer/src/services/htmlCompiler.ts‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ import {
2121
type ResolvedDuration,
2222
type UnresolvedElement,
2323
} from "@hyperframes/core";
24-
import {
25-
inlineSubCompositions as inlineSubCompositionsShared,
26-
prepareFlattenedInnerRoot,
27-
} from "@hyperframes/core/compiler";
24+
import { inlineSubCompositions as inlineSubCompositionsShared } from "@hyperframes/core/compiler";
2825
import { extractMediaMetadata, extractAudioMetadata } from "../utils/ffprobe.js";
2926
import { isPathInside, toExternalAssetKey } from "../utils/paths.js";
3027
import {
@@ -577,11 +574,22 @@ function inlineSubCompositions(
577574
return compHtml;
578575
},
579576
parseHtml: (htmlStr: string) => parseHTML(htmlStr).document as unknown as Document,
580-
flattenInnerRoot: prepareFlattenedInnerRoot as (innerRoot: Element) => Element,
581577
scriptErrorLabel: "[Compiler] Composition script failed",
582578
},
583579
);
584580

581+
// Set data-hf-authored-id on host elements so the scoped script proxy
582+
// can rewrite #id selectors (e.g. #us-map → [data-hf-authored-id="us-map"]).
583+
// Unlike flattenInnerRoot (which changes DOM structure and breaks baselines),
584+
// this preserves the existing innerHTML-based inlining while enabling the
585+
// authored-id selector contract.
586+
for (const hostEl of hosts) {
587+
const compId = hostEl.getAttribute("data-composition-id");
588+
if (compId && !hostEl.getAttribute("data-hf-authored-id")) {
589+
hostEl.setAttribute("data-hf-authored-id", compId);
590+
}
591+
}
592+
585593
// Producer-specific: set explicit pixel dimensions on host elements so
586594
// children using width/height: 100% resolve correctly. The runtime does
587595
// this automatically but compiled HTML needs it inline.

0 commit comments

Comments
 (0)