* 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)
| 60 | * malformed selector or unparseable script yields no entries (animationIds: []). |
| 61 | */ |
| 62 | function 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 |
| 86 | function buildElement( |
no test coverage detected