mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 04:38:33 +00:00
feat(studio): timeline inline expansion + __clipTree runtime primitive
When a child element inside a sub-composition is selected, the timeline replaces the parent scene clip with the deepest-level siblings. Deselect or selecting outside collapses back. Expanded clips are fully editable — move, resize, delete, and split — addressed by their real DOM id with timeline time rebased onto the sub-comp they live in. Runtime: - New window.__clipTree API: a read-only hierarchical ClipNode tree (id/parentId/children + backing element) so Studio can derive parent/child relationships for inline expansion. Studio: - useExpandedTimelineElements derives the expanded view from selectedElementId + clipParentMap (pure useMemo, no useEffect). Each child rebases onto its immediate sub-comp host (start + sourceFile), so multi-level nesting targets the right file. - NLELayout routes expanded-clip edits through the same handlers top-level clips use, in local coordinates — edits save to the sub-comp source and reflect via reloadPreview (no separate DOM-patch path). This is the canonical update; there is no reactive observer. - findMatchingTimelineElementId resolves sub-comp children with no top-level element to `sourceFile#id`. - Razor tool enabled by default; studio_razor_split analytics event fired on single and split-all. - O(n²) isElementGsapTargeted extracted to gsapTargetCache.ts with a cached Set+WeakSet O(1) lookup.
This commit is contained in:
@@ -20,6 +20,7 @@ import { createRuntimePlayer } from "./player";
|
||||
import { createRuntimeState } from "./state";
|
||||
import { collectRuntimeTimelinePayload } from "./timeline";
|
||||
import { createRuntimeStartTimeResolver } from "./startResolver";
|
||||
import { createClipTree } from "./clipTree";
|
||||
import { loadExternalCompositions, loadInlineTemplateCompositions } from "./compositionLoader";
|
||||
import { applyCaptionOverrides } from "./captionOverrides";
|
||||
import { TransportClock } from "./clock";
|
||||
@@ -1560,6 +1561,18 @@ export function initSandboxRuntimeModular(): void {
|
||||
});
|
||||
};
|
||||
|
||||
// Signature the live __clipTree was built from; rebuild only when the set of
|
||||
// timed elements changes (e.g. a sub-composition finishes loading), not every
|
||||
// transport tick. A plain count misses same-count swaps (one sub-comp unloads
|
||||
// as another loads), so the signature keys on id+tag in document order.
|
||||
let clipTreeSignature = "";
|
||||
const computeClipTreeSignature = (): string => {
|
||||
let sig = "";
|
||||
for (const el of document.querySelectorAll("[data-start]")) {
|
||||
sig += `${el.id}:${el.tagName}|`;
|
||||
}
|
||||
return sig;
|
||||
};
|
||||
const postTimeline = () => {
|
||||
sanitizeCompositionDurationAttributes();
|
||||
applyCompositionSizing();
|
||||
@@ -1580,6 +1593,23 @@ export function initSandboxRuntimeModular(): void {
|
||||
canonicalFps: state.canonicalFps,
|
||||
});
|
||||
window.__clipManifest = payload;
|
||||
|
||||
const currentSignature = computeClipTreeSignature();
|
||||
if (!window.__clipTree || clipTreeSignature !== currentSignature) {
|
||||
const runtimeWindow = window as Window & {
|
||||
__timelines?: Record<string, RuntimeTimelineLike | undefined>;
|
||||
};
|
||||
window.__clipTree = createClipTree({
|
||||
startResolver: createRuntimeStartTimeResolver({
|
||||
timelineRegistry: runtimeWindow.__timelines ?? {},
|
||||
includeAuthoredTimingAttrs: true,
|
||||
}),
|
||||
timelineRegistry: runtimeWindow.__timelines ?? {},
|
||||
rootDuration: payload.durationInFrames / state.canonicalFps,
|
||||
});
|
||||
clipTreeSignature = currentSignature;
|
||||
}
|
||||
|
||||
postRuntimeMessage(payload);
|
||||
scheduleRootStageLayoutDiagnostics();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user