mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 04:38:33 +00:00
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.
This commit is contained in:
@@ -365,10 +365,14 @@ async function pollSubCompositionTimelines(
|
||||
}
|
||||
return true;
|
||||
})()`;
|
||||
const beforePoll = Date.now();
|
||||
const timelinesBeforePoll = Number(
|
||||
await page.evaluate(`Object.keys(window.__timelines || {}).length`),
|
||||
);
|
||||
const ready = await pollPageExpression(page, expression, timeoutMs, intervalMs);
|
||||
const pollDurationMs = Date.now() - beforePoll;
|
||||
if (ready && pollDurationMs > intervalMs * 2) {
|
||||
const timelinesAfterPoll = Number(
|
||||
await page.evaluate(`Object.keys(window.__timelines || {}).length`),
|
||||
);
|
||||
if (ready && timelinesAfterPoll > timelinesBeforePoll) {
|
||||
await page.evaluate(`(function() {
|
||||
if (typeof window.__hfForceTimelineRebind === "function") {
|
||||
window.__hfForceTimelineRebind();
|
||||
|
||||
@@ -21,10 +21,7 @@ import {
|
||||
type ResolvedDuration,
|
||||
type UnresolvedElement,
|
||||
} from "@hyperframes/core";
|
||||
import {
|
||||
inlineSubCompositions as inlineSubCompositionsShared,
|
||||
prepareFlattenedInnerRoot,
|
||||
} from "@hyperframes/core/compiler";
|
||||
import { inlineSubCompositions as inlineSubCompositionsShared } from "@hyperframes/core/compiler";
|
||||
import { extractMediaMetadata, extractAudioMetadata } from "../utils/ffprobe.js";
|
||||
import { isPathInside, toExternalAssetKey } from "../utils/paths.js";
|
||||
import {
|
||||
@@ -577,11 +574,22 @@ function inlineSubCompositions(
|
||||
return compHtml;
|
||||
},
|
||||
parseHtml: (htmlStr: string) => parseHTML(htmlStr).document as unknown as Document,
|
||||
flattenInnerRoot: prepareFlattenedInnerRoot as (innerRoot: Element) => Element,
|
||||
scriptErrorLabel: "[Compiler] Composition script failed",
|
||||
},
|
||||
);
|
||||
|
||||
// Set data-hf-authored-id on host elements so the scoped script proxy
|
||||
// can rewrite #id selectors (e.g. #us-map → [data-hf-authored-id="us-map"]).
|
||||
// Unlike flattenInnerRoot (which changes DOM structure and breaks baselines),
|
||||
// this preserves the existing innerHTML-based inlining while enabling the
|
||||
// authored-id selector contract.
|
||||
for (const hostEl of hosts) {
|
||||
const compId = hostEl.getAttribute("data-composition-id");
|
||||
if (compId && !hostEl.getAttribute("data-hf-authored-id")) {
|
||||
hostEl.setAttribute("data-hf-authored-id", compId);
|
||||
}
|
||||
}
|
||||
|
||||
// Producer-specific: set explicit pixel dimensions on host elements so
|
||||
// children using width/height: 100% resolve correctly. The runtime does
|
||||
// this automatically but compiled HTML needs it inline.
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user