MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / createClipTree

Function createClipTree

packages/core/src/runtime/clipTree.ts:109–138  ·  view source on GitHub ↗
(params: {
  startResolver: StartResolverLike;
  timelineRegistry: Record<string, RuntimeTimelineLike | undefined>;
  rootDuration: number;
})

Source from the content-addressed store, hash-verified

107}
108
109export function createClipTree(params: {
110 startResolver: StartResolverLike;
111 timelineRegistry: Record<string, RuntimeTimelineLike | undefined>;
112 rootDuration: number;
113}): ClipTree {
114 const { startResolver, timelineRegistry, rootDuration } = params;
115 const elementToNode = new Map<Element, MutableClipNode>();
116
117 const root = document.querySelector("[data-composition-id]");
118 let ordinal = 0;
119
120 for (const el of document.querySelectorAll("[data-start]")) {
121 if (el === root || DECORATIVE_TAGS.has(el.tagName)) continue;
122 const absoluteStart = startResolver.resolveStartForElement(el, 0);
123 if (resolveDuration(el, timelineRegistry, rootDuration, absoluteStart) <= 0) continue;
124 const node: MutableClipNode = {
125 id: stableClipId(el) ?? `__clip-${ordinal++}`,
126 element: el,
127 parentId: null,
128 children: [],
129 };
130 elementToNode.set(el, node);
131 }
132
133 linkParentChild(elementToNode);
134
135 return {
136 roots: Array.from(elementToNode.values()).filter((n) => n.parentId === null),
137 };
138}

Callers 2

postTimelineFunction · 0.90
clipTree.test.tsFile · 0.90

Calls 6

resolveDurationFunction · 0.85
stableClipIdFunction · 0.85
linkParentChildFunction · 0.85
fromMethod · 0.80
querySelectorMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected