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

Function buildAnimationIdMap

packages/sdk/src/document.ts:62–83  ·  view source on GitHub ↗

* Map each element's data-hf-id → the GSAP tween ids targeting it. Tween ids * come from the acorn parser's stable `targetSelector-method-position` scheme — * the SAME id-space the studio-api read path and the SDK GSAP ops use, so these * ids are dispatchable as-is via setGsapTween/removeGsapTwee

(document: Document)

Source from the content-addressed store, hash-verified

60 * malformed selector or unparseable script yields no entries (animationIds: []).
61 */
62function buildAnimationIdMap(document: Document): Map<string, string[]> {
63 const map = new Map<string, string[]>();
64 const script = extractGsapScript(document);
65 if (!script) return map;
66 for (const { id, selector } of parseLocatedCached(script)) {
67 if (!selector) continue;
68 let matches: Element[] = [];
69 try {
70 matches = Array.from(document.querySelectorAll(selector));
71 } catch {
72 continue; // selector not valid for querySelectorAll — skip
73 }
74 for (const el of matches) {
75 const hfId = el.getAttribute("data-hf-id");
76 if (!hfId) continue;
77 const list = map.get(hfId);
78 if (list) list.push(id);
79 else map.set(hfId, [id]);
80 }
81 }
82 return map;
83}
84
85// fallow-ignore-next-line complexity
86function buildElement(

Callers 1

buildRootsFunction · 0.85

Calls 6

parseLocatedCachedFunction · 0.85
fromMethod · 0.80
getMethod · 0.80
extractGsapScriptFunction · 0.70
getAttributeMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected