@hyperframes/parsers 0.9.27 → 0.9.28-alpha.1
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/gsapParserAcorn.d.ts +0 -33
- package/dist/gsapParserAcorn.js +2 -11
- package/dist/gsapParserExports.d.ts +0 -1
- package/dist/gsapParserExports.js +1 -4
- package/dist/gsapWriterAcorn.d.ts +1 -2
- package/dist/gsapWriterAcorn.js +4 -64
- package/dist/index.d.ts +0 -1
- package/dist/index.js +16 -66
- package/package.json +2 -2
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as acorn from 'acorn';
|
|
2
1
|
import { P as ParsedGsap, d as GsapMethod, G as GsapAnimation } from './gsapSerialize-BXsRZWdm.js';
|
|
3
2
|
export { A as ArcPathConfig, a as ArcPathSegment, n as GsapProvenance, o as GsapProvenanceKind, K as KeyframeEditability, M as MotionPathShape, p as buildArcPath, q as editabilityForProvenance } from './gsapSerialize-BXsRZWdm.js';
|
|
4
3
|
import './types-C1bWHQbs.js';
|
|
@@ -9,37 +8,6 @@ import './types-C1bWHQbs.js';
|
|
|
9
8
|
*/
|
|
10
9
|
declare function scriptShape(code: string, maskNumbers?: boolean): string | null;
|
|
11
10
|
|
|
12
|
-
/**
|
|
13
|
-
* Browser-safe GSAP read path — acorn + acorn-walk.
|
|
14
|
-
*
|
|
15
|
-
* T6b oracle: produces identical ParsedGsap output to gsapParser.ts (recast).
|
|
16
|
-
* Replaces recast as the shared implementation once T6d passes.
|
|
17
|
-
*
|
|
18
|
-
* Write path (T6c) will add magic-string splice once read parity is confirmed.
|
|
19
|
-
* No Node globals, no fs, no require — safe to bundle for browser use.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
interface TimelineDefaults {
|
|
23
|
-
ease?: string;
|
|
24
|
-
duration?: number;
|
|
25
|
-
durationUnresolved?: boolean;
|
|
26
|
-
}
|
|
27
|
-
type TimelineRef = {
|
|
28
|
-
kind: "identifier";
|
|
29
|
-
name: string;
|
|
30
|
-
} | {
|
|
31
|
-
kind: "member";
|
|
32
|
-
node: any;
|
|
33
|
-
};
|
|
34
|
-
interface TimelineDetection {
|
|
35
|
-
/** Identifier name for the canonical form, else null for member/none. */
|
|
36
|
-
timelineVar: string | null;
|
|
37
|
-
/** Structural reference: identifier or member expression. Null when none found. */
|
|
38
|
-
ref: TimelineRef | null;
|
|
39
|
-
timelineCount: number;
|
|
40
|
-
defaults?: TimelineDefaults;
|
|
41
|
-
declaration?: Pick<acorn.Node, "start" | "end">;
|
|
42
|
-
}
|
|
43
11
|
interface TweenCallInfo {
|
|
44
12
|
node: any;
|
|
45
13
|
/** acorn-walk ancestor array at the call site (root→call, call is last). */
|
|
@@ -57,7 +25,6 @@ interface ParsedGsapAcornForWrite {
|
|
|
57
25
|
ast: any;
|
|
58
26
|
timelineVar: string;
|
|
59
27
|
hasTimeline: boolean;
|
|
60
|
-
timelineDeclaration?: TimelineDetection["declaration"];
|
|
61
28
|
located: Array<{
|
|
62
29
|
id: string;
|
|
63
30
|
call: TweenCallInfo;
|
package/dist/gsapParserAcorn.js
CHANGED
|
@@ -1170,7 +1170,6 @@ function findTimelineVar(ast, scope) {
|
|
|
1170
1170
|
let ref = null;
|
|
1171
1171
|
let timelineCount = 0;
|
|
1172
1172
|
let defaults;
|
|
1173
|
-
let declaration;
|
|
1174
1173
|
const emptyScope = scope ?? /* @__PURE__ */ new Map();
|
|
1175
1174
|
acornWalk.simple(ast, {
|
|
1176
1175
|
VariableDeclarator(node) {
|
|
@@ -1180,7 +1179,6 @@ function findTimelineVar(ast, scope) {
|
|
|
1180
1179
|
timelineVar = node.id.name;
|
|
1181
1180
|
ref = { kind: "identifier", name: node.id.name };
|
|
1182
1181
|
defaults = extractTimelineDefaults(node.init, emptyScope);
|
|
1183
|
-
declaration = { start: node.start, end: node.end };
|
|
1184
1182
|
}
|
|
1185
1183
|
}
|
|
1186
1184
|
},
|
|
@@ -1197,12 +1195,11 @@ function findTimelineVar(ast, scope) {
|
|
|
1197
1195
|
ref = { kind: "member", node: left };
|
|
1198
1196
|
defaults = extractTimelineDefaults(node.right, emptyScope);
|
|
1199
1197
|
}
|
|
1200
|
-
if (ref) declaration = { start: node.start, end: node.end };
|
|
1201
1198
|
}
|
|
1202
1199
|
}
|
|
1203
1200
|
}
|
|
1204
1201
|
});
|
|
1205
|
-
return { timelineVar, ref, timelineCount, defaults
|
|
1202
|
+
return { timelineVar, ref, timelineCount, defaults };
|
|
1206
1203
|
}
|
|
1207
1204
|
function isTimelineRootedCall(callNode, ref) {
|
|
1208
1205
|
let obj = callNode.callee?.object;
|
|
@@ -1906,13 +1903,7 @@ function parseGsapScriptAcornForWrite(script) {
|
|
|
1906
1903
|
call,
|
|
1907
1904
|
animation: animations[i]
|
|
1908
1905
|
}));
|
|
1909
|
-
return {
|
|
1910
|
-
ast,
|
|
1911
|
-
timelineVar,
|
|
1912
|
-
hasTimeline: detection.ref !== null,
|
|
1913
|
-
timelineDeclaration: detection.declaration,
|
|
1914
|
-
located
|
|
1915
|
-
};
|
|
1906
|
+
return { ast, timelineVar, hasTimeline: detection.ref !== null, located };
|
|
1916
1907
|
} catch {
|
|
1917
1908
|
return null;
|
|
1918
1909
|
}
|
|
@@ -3,7 +3,6 @@ export { isStudioHoldSet } from './gsapParser.js';
|
|
|
3
3
|
export { SPRING_PRESETS, SpringPreset, generateSpringEaseData } from './springEase.js';
|
|
4
4
|
export { parseGsapScriptAcorn as parseGsapScript } from './gsapParserAcorn.js';
|
|
5
5
|
import './types-C1bWHQbs.js';
|
|
6
|
-
import 'acorn';
|
|
7
6
|
|
|
8
7
|
interface ObjectArrayKeyframeTiming {
|
|
9
8
|
percentages: number[];
|
|
@@ -1461,7 +1461,6 @@ function findTimelineVar(ast, scope) {
|
|
|
1461
1461
|
let ref = null;
|
|
1462
1462
|
let timelineCount = 0;
|
|
1463
1463
|
let defaults;
|
|
1464
|
-
let declaration;
|
|
1465
1464
|
const emptyScope = scope ?? /* @__PURE__ */ new Map();
|
|
1466
1465
|
acornWalk.simple(ast, {
|
|
1467
1466
|
VariableDeclarator(node) {
|
|
@@ -1471,7 +1470,6 @@ function findTimelineVar(ast, scope) {
|
|
|
1471
1470
|
timelineVar = node.id.name;
|
|
1472
1471
|
ref = { kind: "identifier", name: node.id.name };
|
|
1473
1472
|
defaults = extractTimelineDefaults(node.init, emptyScope);
|
|
1474
|
-
declaration = { start: node.start, end: node.end };
|
|
1475
1473
|
}
|
|
1476
1474
|
}
|
|
1477
1475
|
},
|
|
@@ -1488,12 +1486,11 @@ function findTimelineVar(ast, scope) {
|
|
|
1488
1486
|
ref = { kind: "member", node: left };
|
|
1489
1487
|
defaults = extractTimelineDefaults(node.right, emptyScope);
|
|
1490
1488
|
}
|
|
1491
|
-
if (ref) declaration = { start: node.start, end: node.end };
|
|
1492
1489
|
}
|
|
1493
1490
|
}
|
|
1494
1491
|
}
|
|
1495
1492
|
});
|
|
1496
|
-
return { timelineVar, ref, timelineCount, defaults
|
|
1493
|
+
return { timelineVar, ref, timelineCount, defaults };
|
|
1497
1494
|
}
|
|
1498
1495
|
function isTimelineRootedCall(callNode, ref) {
|
|
1499
1496
|
let obj = callNode.callee?.object;
|
|
@@ -55,7 +55,6 @@ declare function addAnimationToScript(script: string, animation: Omit<GsapAnimat
|
|
|
55
55
|
script: string;
|
|
56
56
|
id: string;
|
|
57
57
|
};
|
|
58
|
-
declare function removeAnimationsForSelectors(script: string, selectors: ReadonlySet<string>): string;
|
|
59
58
|
declare function removeAnimationFromScript(script: string, animationId: string): string;
|
|
60
59
|
/**
|
|
61
60
|
* Enforce "exactly one position write per element". Position commits (drag, add
|
|
@@ -201,4 +200,4 @@ type UnrollElement = {
|
|
|
201
200
|
*/
|
|
202
201
|
declare function unrollDynamicAnimations(script: string, animationId: string, elements: UnrollElement[]): string;
|
|
203
202
|
|
|
204
|
-
export { type ClipTweenRetime, type UnrollElement, addAnimationToScript, addAnimationWithKeyframesToScript, addKeyframeToScript, addLabelToScript, addMotionPathPointInScript, addMotionPathToScript, clipQueryRoot, clipTweenMatcher, convertToKeyframesFromScript, copyAnimationsInScript, dedupePositionWritesInScript, hasExplicitTime, materializeKeyframesFromScript, moveKeyframeInScript, removeAllKeyframesFromScript, removeAnimationFromScript,
|
|
203
|
+
export { type ClipTweenRetime, type UnrollElement, addAnimationToScript, addAnimationWithKeyframesToScript, addKeyframeToScript, addLabelToScript, addMotionPathPointInScript, addMotionPathToScript, clipQueryRoot, clipTweenMatcher, convertToKeyframesFromScript, copyAnimationsInScript, dedupePositionWritesInScript, hasExplicitTime, materializeKeyframesFromScript, moveKeyframeInScript, removeAllKeyframesFromScript, removeAnimationFromScript, removeArcPathFromScript, removeKeyframeFromScript, removeLabelFromScript, removeMotionPathPointInScript, removePropertyFromAnimation, replaceTweenWithKeyframesInScript, resizeKeyframedTweenInScript, retimeClipTweensInScript, scalePositionsInScript, setArcPathInScript, shiftPositionsInScript, splitAnimationsInScript, splitIntoPropertyGroupsFromScript, syncPositionHoldsBeforeKeyframes, trimTrailingKeyframeSpans, unrollDynamicAnimations, updateAnimationInScript, updateArcSegmentInScript, updateKeyframeInScript, updateMotionPathPointInScript };
|
package/dist/gsapWriterAcorn.js
CHANGED
|
@@ -784,7 +784,6 @@ function findTimelineVar(ast, scope) {
|
|
|
784
784
|
let ref = null;
|
|
785
785
|
let timelineCount = 0;
|
|
786
786
|
let defaults;
|
|
787
|
-
let declaration;
|
|
788
787
|
const emptyScope = scope ?? /* @__PURE__ */ new Map();
|
|
789
788
|
acornWalk.simple(ast, {
|
|
790
789
|
VariableDeclarator(node) {
|
|
@@ -794,7 +793,6 @@ function findTimelineVar(ast, scope) {
|
|
|
794
793
|
timelineVar = node.id.name;
|
|
795
794
|
ref = { kind: "identifier", name: node.id.name };
|
|
796
795
|
defaults = extractTimelineDefaults(node.init, emptyScope);
|
|
797
|
-
declaration = { start: node.start, end: node.end };
|
|
798
796
|
}
|
|
799
797
|
}
|
|
800
798
|
},
|
|
@@ -811,12 +809,11 @@ function findTimelineVar(ast, scope) {
|
|
|
811
809
|
ref = { kind: "member", node: left };
|
|
812
810
|
defaults = extractTimelineDefaults(node.right, emptyScope);
|
|
813
811
|
}
|
|
814
|
-
if (ref) declaration = { start: node.start, end: node.end };
|
|
815
812
|
}
|
|
816
813
|
}
|
|
817
814
|
}
|
|
818
815
|
});
|
|
819
|
-
return { timelineVar, ref, timelineCount, defaults
|
|
816
|
+
return { timelineVar, ref, timelineCount, defaults };
|
|
820
817
|
}
|
|
821
818
|
function isTimelineRootedCall(callNode, ref) {
|
|
822
819
|
let obj = callNode.callee?.object;
|
|
@@ -1423,13 +1420,7 @@ function parseGsapScriptAcornForWrite(script) {
|
|
|
1423
1420
|
call,
|
|
1424
1421
|
animation: animations[i]
|
|
1425
1422
|
}));
|
|
1426
|
-
return {
|
|
1427
|
-
ast,
|
|
1428
|
-
timelineVar,
|
|
1429
|
-
hasTimeline: detection.ref !== null,
|
|
1430
|
-
timelineDeclaration: detection.declaration,
|
|
1431
|
-
located
|
|
1432
|
-
};
|
|
1423
|
+
return { ast, timelineVar, hasTimeline: detection.ref !== null, located };
|
|
1433
1424
|
} catch {
|
|
1434
1425
|
return null;
|
|
1435
1426
|
}
|
|
@@ -1882,62 +1873,12 @@ function removeCallFromMagicString(ms, call, script) {
|
|
|
1882
1873
|
const N = call.node;
|
|
1883
1874
|
const exprStmt = findEnclosingExpressionStatement(call.ancestors);
|
|
1884
1875
|
if (N.callee?.object?.type !== "CallExpression" && exprStmt?.expression === N) {
|
|
1885
|
-
|
|
1876
|
+
const end = exprStmt.end < script.length && script[exprStmt.end] === "\n" ? exprStmt.end + 1 : exprStmt.end;
|
|
1877
|
+
ms.remove(exprStmt.start, end);
|
|
1886
1878
|
} else {
|
|
1887
1879
|
ms.remove(N.callee.object.end, N.end);
|
|
1888
1880
|
}
|
|
1889
1881
|
}
|
|
1890
|
-
function removeStatementFromMagicString(ms, statement, script) {
|
|
1891
|
-
const end = statement.end + (script[statement.end] === "\n" ? 1 : 0);
|
|
1892
|
-
ms.remove(statement.start, end);
|
|
1893
|
-
}
|
|
1894
|
-
function removeAnimationsForSelectors(script, selectors) {
|
|
1895
|
-
let current = script;
|
|
1896
|
-
for (; ; ) {
|
|
1897
|
-
const parsed = parseGsapScriptAcornForWrite(current);
|
|
1898
|
-
if (!parsed) return current;
|
|
1899
|
-
const selected = parsed.located.filter(
|
|
1900
|
-
({ animation }) => selectors.has(animation.targetSelector)
|
|
1901
|
-
);
|
|
1902
|
-
const first = selected[0];
|
|
1903
|
-
if (!first) return current;
|
|
1904
|
-
const declaration = parsed.timelineDeclaration;
|
|
1905
|
-
if (declaration && selected.some(
|
|
1906
|
-
({ call }) => call.node.start <= declaration.start && call.node.end >= declaration.end
|
|
1907
|
-
)) {
|
|
1908
|
-
const updated = removeAnimationFromScript(current, first.id);
|
|
1909
|
-
if (updated === current) return current;
|
|
1910
|
-
current = updated;
|
|
1911
|
-
continue;
|
|
1912
|
-
}
|
|
1913
|
-
return removeCallsFromScript(
|
|
1914
|
-
current,
|
|
1915
|
-
selected.map(({ call }) => call)
|
|
1916
|
-
);
|
|
1917
|
-
}
|
|
1918
|
-
}
|
|
1919
|
-
function removeCallsFromScript(script, calls) {
|
|
1920
|
-
const removedNodes = new Set(calls.map(({ node }) => node));
|
|
1921
|
-
const statements = /* @__PURE__ */ new Set();
|
|
1922
|
-
for (const call of calls) {
|
|
1923
|
-
const statement = fullyRemovedStatement(call, removedNodes);
|
|
1924
|
-
if (statement) statements.add(statement);
|
|
1925
|
-
}
|
|
1926
|
-
const ms = new MagicString(script);
|
|
1927
|
-
for (const statement of statements) removeStatementFromMagicString(ms, statement, script);
|
|
1928
|
-
for (const call of calls) {
|
|
1929
|
-
if (statements.has(findEnclosingExpressionStatement(call.ancestors))) continue;
|
|
1930
|
-
removeCallFromMagicString(ms, call, script);
|
|
1931
|
-
}
|
|
1932
|
-
return ms.toString();
|
|
1933
|
-
}
|
|
1934
|
-
function fullyRemovedStatement(call, removedNodes) {
|
|
1935
|
-
const statement = findEnclosingExpressionStatement(call.ancestors);
|
|
1936
|
-
if (statement?.expression !== call.node) return null;
|
|
1937
|
-
let root = call.node;
|
|
1938
|
-
while (root?.type === "CallExpression" && removedNodes.has(root)) root = root.callee.object;
|
|
1939
|
-
return root && root.type !== "CallExpression" ? statement : null;
|
|
1940
|
-
}
|
|
1941
1882
|
function removeAnimationFromScript(script, animationId) {
|
|
1942
1883
|
const parsed = parseGsapScriptAcornForWrite(script);
|
|
1943
1884
|
if (!parsed) return script;
|
|
@@ -3427,7 +3368,6 @@ export {
|
|
|
3427
3368
|
moveKeyframeInScript,
|
|
3428
3369
|
removeAllKeyframesFromScript,
|
|
3429
3370
|
removeAnimationFromScript,
|
|
3430
|
-
removeAnimationsForSelectors,
|
|
3431
3371
|
removeArcPathFromScript,
|
|
3432
3372
|
removeKeyframeFromScript,
|
|
3433
3373
|
removeLabelFromScript,
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,6 @@ export { AttrReader, DEFAULT_IMAGE_TIMELINE_DURATION_SECONDS, MAX_PLAYBACK_RATE,
|
|
|
14
14
|
export { CompositionDurationResult, CompositionDurationSource, ResolveCompositionDurationInput, TIMING_TOLERANCE_SECONDS, resolveCompositionDuration } from './compositionDuration.js';
|
|
15
15
|
export { d as decodeUrlPathVariants, c as decodedUrlPath, e as encodeUrlPath } from './urlPath-CYK47t9W.js';
|
|
16
16
|
export { HTML_ATTRIBUTE_ENTITIES, HtmlAttributeSpan, HtmlOpeningTagSpan, decodeAuthoredAttribute, scanHtmlOpeningTags } from './htmlAttributeSpans.js';
|
|
17
|
-
import 'acorn';
|
|
18
17
|
|
|
19
18
|
/**
|
|
20
19
|
* Thrown by htmlParser functions when the input HTML is empty or does not
|
package/dist/index.js
CHANGED
|
@@ -1578,7 +1578,6 @@ function findTimelineVar(ast, scope) {
|
|
|
1578
1578
|
let ref = null;
|
|
1579
1579
|
let timelineCount = 0;
|
|
1580
1580
|
let defaults;
|
|
1581
|
-
let declaration;
|
|
1582
1581
|
const emptyScope = scope ?? /* @__PURE__ */ new Map();
|
|
1583
1582
|
acornWalk.simple(ast, {
|
|
1584
1583
|
VariableDeclarator(node) {
|
|
@@ -1588,7 +1587,6 @@ function findTimelineVar(ast, scope) {
|
|
|
1588
1587
|
timelineVar = node.id.name;
|
|
1589
1588
|
ref = { kind: "identifier", name: node.id.name };
|
|
1590
1589
|
defaults = extractTimelineDefaults(node.init, emptyScope);
|
|
1591
|
-
declaration = { start: node.start, end: node.end };
|
|
1592
1590
|
}
|
|
1593
1591
|
}
|
|
1594
1592
|
},
|
|
@@ -1605,12 +1603,11 @@ function findTimelineVar(ast, scope) {
|
|
|
1605
1603
|
ref = { kind: "member", node: left };
|
|
1606
1604
|
defaults = extractTimelineDefaults(node.right, emptyScope);
|
|
1607
1605
|
}
|
|
1608
|
-
if (ref) declaration = { start: node.start, end: node.end };
|
|
1609
1606
|
}
|
|
1610
1607
|
}
|
|
1611
1608
|
}
|
|
1612
1609
|
});
|
|
1613
|
-
return { timelineVar, ref, timelineCount, defaults
|
|
1610
|
+
return { timelineVar, ref, timelineCount, defaults };
|
|
1614
1611
|
}
|
|
1615
1612
|
function isTimelineRootedCall(callNode, ref) {
|
|
1616
1613
|
let obj = callNode.callee?.object;
|
|
@@ -2314,13 +2311,7 @@ function parseGsapScriptAcornForWrite(script) {
|
|
|
2314
2311
|
call,
|
|
2315
2312
|
animation: animations[i]
|
|
2316
2313
|
}));
|
|
2317
|
-
return {
|
|
2318
|
-
ast,
|
|
2319
|
-
timelineVar,
|
|
2320
|
-
hasTimeline: detection.ref !== null,
|
|
2321
|
-
timelineDeclaration: detection.declaration,
|
|
2322
|
-
located
|
|
2323
|
-
};
|
|
2314
|
+
return { ast, timelineVar, hasTimeline: detection.ref !== null, located };
|
|
2324
2315
|
} catch {
|
|
2325
2316
|
return null;
|
|
2326
2317
|
}
|
|
@@ -2717,62 +2708,12 @@ function removeCallFromMagicString(ms, call, script) {
|
|
|
2717
2708
|
const N = call.node;
|
|
2718
2709
|
const exprStmt = findEnclosingExpressionStatement(call.ancestors);
|
|
2719
2710
|
if (N.callee?.object?.type !== "CallExpression" && exprStmt?.expression === N) {
|
|
2720
|
-
|
|
2711
|
+
const end = exprStmt.end < script.length && script[exprStmt.end] === "\n" ? exprStmt.end + 1 : exprStmt.end;
|
|
2712
|
+
ms.remove(exprStmt.start, end);
|
|
2721
2713
|
} else {
|
|
2722
2714
|
ms.remove(N.callee.object.end, N.end);
|
|
2723
2715
|
}
|
|
2724
2716
|
}
|
|
2725
|
-
function removeStatementFromMagicString(ms, statement, script) {
|
|
2726
|
-
const end = statement.end + (script[statement.end] === "\n" ? 1 : 0);
|
|
2727
|
-
ms.remove(statement.start, end);
|
|
2728
|
-
}
|
|
2729
|
-
function removeAnimationsForSelectors(script, selectors) {
|
|
2730
|
-
let current = script;
|
|
2731
|
-
for (; ; ) {
|
|
2732
|
-
const parsed = parseGsapScriptAcornForWrite(current);
|
|
2733
|
-
if (!parsed) return current;
|
|
2734
|
-
const selected = parsed.located.filter(
|
|
2735
|
-
({ animation }) => selectors.has(animation.targetSelector)
|
|
2736
|
-
);
|
|
2737
|
-
const first = selected[0];
|
|
2738
|
-
if (!first) return current;
|
|
2739
|
-
const declaration = parsed.timelineDeclaration;
|
|
2740
|
-
if (declaration && selected.some(
|
|
2741
|
-
({ call }) => call.node.start <= declaration.start && call.node.end >= declaration.end
|
|
2742
|
-
)) {
|
|
2743
|
-
const updated = removeAnimationFromScript(current, first.id);
|
|
2744
|
-
if (updated === current) return current;
|
|
2745
|
-
current = updated;
|
|
2746
|
-
continue;
|
|
2747
|
-
}
|
|
2748
|
-
return removeCallsFromScript(
|
|
2749
|
-
current,
|
|
2750
|
-
selected.map(({ call }) => call)
|
|
2751
|
-
);
|
|
2752
|
-
}
|
|
2753
|
-
}
|
|
2754
|
-
function removeCallsFromScript(script, calls) {
|
|
2755
|
-
const removedNodes = new Set(calls.map(({ node }) => node));
|
|
2756
|
-
const statements = /* @__PURE__ */ new Set();
|
|
2757
|
-
for (const call of calls) {
|
|
2758
|
-
const statement = fullyRemovedStatement(call, removedNodes);
|
|
2759
|
-
if (statement) statements.add(statement);
|
|
2760
|
-
}
|
|
2761
|
-
const ms = new MagicString(script);
|
|
2762
|
-
for (const statement of statements) removeStatementFromMagicString(ms, statement, script);
|
|
2763
|
-
for (const call of calls) {
|
|
2764
|
-
if (statements.has(findEnclosingExpressionStatement(call.ancestors))) continue;
|
|
2765
|
-
removeCallFromMagicString(ms, call, script);
|
|
2766
|
-
}
|
|
2767
|
-
return ms.toString();
|
|
2768
|
-
}
|
|
2769
|
-
function fullyRemovedStatement(call, removedNodes) {
|
|
2770
|
-
const statement = findEnclosingExpressionStatement(call.ancestors);
|
|
2771
|
-
if (statement?.expression !== call.node) return null;
|
|
2772
|
-
let root = call.node;
|
|
2773
|
-
while (root?.type === "CallExpression" && removedNodes.has(root)) root = root.callee.object;
|
|
2774
|
-
return root && root.type !== "CallExpression" ? statement : null;
|
|
2775
|
-
}
|
|
2776
2717
|
function removeAnimationFromScript(script, animationId) {
|
|
2777
2718
|
const parsed = parseGsapScriptAcornForWrite(script);
|
|
2778
2719
|
if (!parsed) return script;
|
|
@@ -3601,10 +3542,19 @@ function removeElementWithGsapCascade(doc, element) {
|
|
|
3601
3542
|
});
|
|
3602
3543
|
if (removedSelectors.size === 0) return;
|
|
3603
3544
|
for (const script of findScriptElementsDeep(doc)) {
|
|
3604
|
-
|
|
3545
|
+
let current = script.textContent ?? "";
|
|
3605
3546
|
if (!current.includes("gsap") && !current.includes("ScrollTrigger")) continue;
|
|
3606
|
-
|
|
3607
|
-
|
|
3547
|
+
for (; ; ) {
|
|
3548
|
+
const parsed = parseGsapScriptAcornForWrite(current);
|
|
3549
|
+
const match = parsed?.located.find(
|
|
3550
|
+
(located) => removedSelectors.has(located.animation.targetSelector)
|
|
3551
|
+
);
|
|
3552
|
+
if (!match) break;
|
|
3553
|
+
const updated = removeAnimationFromScript(current, match.id);
|
|
3554
|
+
if (updated === current) break;
|
|
3555
|
+
current = updated;
|
|
3556
|
+
}
|
|
3557
|
+
if (current !== script.textContent) script.textContent = current;
|
|
3608
3558
|
}
|
|
3609
3559
|
}
|
|
3610
3560
|
function removeElementFromHtml(html, elementId) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/parsers",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.28-alpha.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/heygen-com/hyperframes",
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
"tsx": "^4.21.0",
|
|
140
140
|
"typescript": "^5.0.0",
|
|
141
141
|
"vitest": "^4.1.11",
|
|
142
|
-
"@hyperframes/core": "0.9.
|
|
142
|
+
"@hyperframes/core": "0.9.28-alpha.1"
|
|
143
143
|
},
|
|
144
144
|
"scripts": {
|
|
145
145
|
"build": "tsup",
|