(script: string, animationId: string)
| 1611 | } |
| 1612 | |
| 1613 | export 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). */ |
| 1632 | function removeCallFromAst(call: TweenCallInfo): void { |
no test coverage detected