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

Function removeAnimationFromScript

packages/parsers/src/gsapParser.ts:1613–1629  ·  view source on GitHub ↗
(script: string, animationId: string)

Source from the content-addressed store, hash-verified

1611}
1612
1613export function removeAnimationFromScript(script: string, animationId: string): string {
1614 let parsed: ParsedGsapAst;
1615 try {
1616 parsed = parseGsapAst(script);
1617 } catch (e) {
1618 console.warn("[gsap-parser] removeAnimationFromScript parse failed:", e);
1619 return script;
1620 }
1621 let target = parsed.located.find((l) => l.id === animationId);
1622 if (!target) {
1623 const convertedId = animationId.replace(/-from-|-fromTo-/, "-to-");
1624 target = parsed.located.find((l) => l.id === convertedId);
1625 }
1626 if (!target) return script;
1627 removeCallFromAst(target.call);
1628 return recast.print(parsed.ast).code;
1629}
1630
1631/** Remove a single located tween call from the AST (standalone stmt or chain link). */
1632function removeCallFromAst(call: TweenCallInfo): void {

Calls 4

parseGsapAstFunction · 0.85
removeCallFromAstFunction · 0.85
warnMethod · 0.80
findMethod · 0.65

Tested by

no test coverage detected