@hyperframes/parsers 0.7.18 → 0.7.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1765,20 +1765,23 @@ function findEnclosingExpressionStatement(ancestors) {
1765
1765
  }
1766
1766
  return null;
1767
1767
  }
1768
- function removeAnimationFromScript(script, animationId) {
1769
- const parsed = parseGsapScriptAcornForWrite(script);
1770
- if (!parsed) return script;
1771
- const target = parsed.located.find((l) => l.id === animationId);
1772
- if (!target) return script;
1773
- const ms = new MagicString(script);
1774
- const N = target.call.node;
1775
- const exprStmt = findEnclosingExpressionStatement(target.call.ancestors);
1768
+ function removeCallFromMagicString(ms, call, script) {
1769
+ const N = call.node;
1770
+ const exprStmt = findEnclosingExpressionStatement(call.ancestors);
1776
1771
  if (N.callee?.object?.type !== "CallExpression" && exprStmt?.expression === N) {
1777
1772
  const end = exprStmt.end < script.length && script[exprStmt.end] === "\n" ? exprStmt.end + 1 : exprStmt.end;
1778
1773
  ms.remove(exprStmt.start, end);
1779
1774
  } else {
1780
1775
  ms.remove(N.callee.object.end, N.end);
1781
1776
  }
1777
+ }
1778
+ function removeAnimationFromScript(script, animationId) {
1779
+ const parsed = parseGsapScriptAcornForWrite(script);
1780
+ if (!parsed) return script;
1781
+ const target = parsed.located.find((l) => l.id === animationId);
1782
+ if (!target) return script;
1783
+ const ms = new MagicString(script);
1784
+ removeCallFromMagicString(ms, target.call, script);
1782
1785
  return ms.toString();
1783
1786
  }
1784
1787