@hyperframes/parsers 0.8.49 → 0.8.51
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/assetResolution.d.ts +3 -1
- package/dist/assetResolution.js +24 -2
- package/dist/assetResolution.js.map +1 -1
- package/dist/compositionDuration.d.ts +19 -0
- package/dist/compositionDuration.js +22 -0
- package/dist/compositionDuration.js.map +1 -0
- package/dist/gsapParser.d.ts +2 -2
- package/dist/gsapParser.js.map +1 -1
- package/dist/gsapParserAcorn.d.ts +2 -2
- package/dist/gsapParserAcorn.js +71 -21
- package/dist/gsapParserAcorn.js.map +1 -1
- package/dist/gsapParserExports.d.ts +1 -1
- package/dist/gsapParserExports.js +71 -21
- package/dist/gsapParserExports.js.map +1 -1
- package/dist/{gsapSerialize-QZcXUoVf.d.ts → gsapSerialize-b8lNzSbI.d.ts} +2 -0
- package/dist/gsapWriterAcorn.d.ts +1 -1
- package/dist/gsapWriterAcorn.js +30 -8
- package/dist/gsapWriterAcorn.js.map +1 -1
- package/dist/index.d.ts +38 -7
- package/dist/index.js +440 -40
- package/dist/index.js.map +1 -1
- package/dist/mediaDuration.d.ts +48 -0
- package/dist/mediaDuration.js +104 -0
- package/dist/mediaDuration.js.map +1 -0
- package/dist/mediaDurationFixtures.d.ts +14 -0
- package/dist/mediaDurationFixtures.js +84 -0
- package/dist/mediaDurationFixtures.js.map +1 -0
- package/dist/topLevelElements.d.ts +22 -0
- package/dist/topLevelElements.js +40 -0
- package/dist/topLevelElements.js.map +1 -0
- package/package.json +18 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as ParsedGsap, c as GsapMethod, G as GsapAnimation } from './gsapSerialize-
|
|
2
|
-
export { A as ArcPathConfig, a as ArcPathSegment, e as GsapProvenance, f as GsapProvenanceKind, K as KeyframeEditability, M as MotionPathShape, m as buildArcPath, i as editabilityForProvenance } from './gsapSerialize-
|
|
1
|
+
import { P as ParsedGsap, c as GsapMethod, G as GsapAnimation } from './gsapSerialize-b8lNzSbI.js';
|
|
2
|
+
export { A as ArcPathConfig, a as ArcPathSegment, e as GsapProvenance, f as GsapProvenanceKind, K as KeyframeEditability, M as MotionPathShape, m as buildArcPath, i as editabilityForProvenance } from './gsapSerialize-b8lNzSbI.js';
|
|
3
3
|
import './types-Y0NXTiVo.js';
|
|
4
4
|
import './gsapConstants.js';
|
|
5
5
|
|
package/dist/gsapParserAcorn.js
CHANGED
|
@@ -58,7 +58,16 @@ function buildArcPath(coords, curviness, autoRotate, isCubic) {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
// src/gsapInline.ts
|
|
61
|
-
var SKIP_KEYS = /* @__PURE__ */ new Set([
|
|
61
|
+
var SKIP_KEYS = /* @__PURE__ */ new Set([
|
|
62
|
+
"type",
|
|
63
|
+
"start",
|
|
64
|
+
"end",
|
|
65
|
+
"loc",
|
|
66
|
+
"range",
|
|
67
|
+
"__hfProvenance",
|
|
68
|
+
"__hfOrder",
|
|
69
|
+
"__hfSiteStart"
|
|
70
|
+
]);
|
|
62
71
|
var FUNCTION_TYPES = /* @__PURE__ */ new Set([
|
|
63
72
|
"ArrowFunctionExpression",
|
|
64
73
|
"FunctionExpression",
|
|
@@ -161,6 +170,9 @@ function isTimelineRooted(call, timelineVar) {
|
|
|
161
170
|
if (timelineRootName(call) !== timelineVar) return false;
|
|
162
171
|
return call.callee?.property?.type === "Identifier" && GSAP_METHODS.has(call.callee.property.name);
|
|
163
172
|
}
|
|
173
|
+
function isAddLabelCall(call, timelineVar) {
|
|
174
|
+
return timelineRootName(call) === timelineVar && call.callee?.property?.name === "addLabel";
|
|
175
|
+
}
|
|
164
176
|
function containsTimelineCall(node, timelineVar) {
|
|
165
177
|
let found = false;
|
|
166
178
|
walkNodes(node, (n) => {
|
|
@@ -367,12 +379,17 @@ function bodyStatements(node) {
|
|
|
367
379
|
}
|
|
368
380
|
function tagTimelineCalls(stmts, prov, ctx) {
|
|
369
381
|
for (const stmt of stmts) {
|
|
382
|
+
const calls = [];
|
|
370
383
|
walkNodes(stmt, (n) => {
|
|
371
|
-
if (n.type === "CallExpression" && isTimelineRooted(n, ctx.timelineVar))
|
|
372
|
-
|
|
373
|
-
n.__hfOrder = ctx.order.n++;
|
|
374
|
-
}
|
|
384
|
+
if (n.type === "CallExpression" && (isTimelineRooted(n, ctx.timelineVar) || isAddLabelCall(n, ctx.timelineVar)))
|
|
385
|
+
calls.push(n);
|
|
375
386
|
});
|
|
387
|
+
calls.sort((a, b) => a.callee.property.start - b.callee.property.start);
|
|
388
|
+
for (const n of calls) {
|
|
389
|
+
tagProvenance(n, { ...prov });
|
|
390
|
+
n.__hfOrder = ctx.order.n++;
|
|
391
|
+
n.__hfSiteStart = ctx.rootStart;
|
|
392
|
+
}
|
|
376
393
|
}
|
|
377
394
|
}
|
|
378
395
|
function expandBody(bodyStmts, bindings, prov, ctx) {
|
|
@@ -559,10 +576,14 @@ function inlineComputedTimelines(ast, timelineVar, resolve) {
|
|
|
559
576
|
resolve,
|
|
560
577
|
depth: 0,
|
|
561
578
|
site: { n: 0 },
|
|
562
|
-
order: { n: 0 }
|
|
579
|
+
order: { n: 0 },
|
|
580
|
+
rootStart: 0
|
|
563
581
|
};
|
|
564
582
|
const body = (ast.body ?? []).filter((stmt) => !isHelperDecl(stmt, helpers));
|
|
565
|
-
ast.body =
|
|
583
|
+
ast.body = body.flatMap((stmt) => {
|
|
584
|
+
ctx.rootStart = stmt.start;
|
|
585
|
+
return expandStatements([stmt], ctx);
|
|
586
|
+
});
|
|
566
587
|
}
|
|
567
588
|
|
|
568
589
|
// src/gsapObjectArrayTiming.ts
|
|
@@ -1008,6 +1029,14 @@ function objectExpressionToRecord(node, scope, source) {
|
|
|
1008
1029
|
function isGsapTimelineCall(node) {
|
|
1009
1030
|
return node?.type === "CallExpression" && node.callee?.type === "MemberExpression" && node.callee.object?.name === "gsap" && node.callee.property?.name === "timeline";
|
|
1010
1031
|
}
|
|
1032
|
+
function hasUnknownDuration(varsNode, scope) {
|
|
1033
|
+
if (!varsNode) return false;
|
|
1034
|
+
if (varsNode.type !== "ObjectExpression") return true;
|
|
1035
|
+
const props = varsNode.properties ?? [];
|
|
1036
|
+
if (props.some((p) => p.type === "SpreadElement")) return true;
|
|
1037
|
+
const prop = props.find((p) => isObjectProperty(p) && propKeyName(p) === "duration");
|
|
1038
|
+
return prop !== void 0 && typeof resolveNode(prop.value, scope) !== "number";
|
|
1039
|
+
}
|
|
1011
1040
|
function staticMemberKey(node) {
|
|
1012
1041
|
if (!node || node.type !== "MemberExpression") return null;
|
|
1013
1042
|
if (node.computed) {
|
|
@@ -1049,7 +1078,10 @@ function extractTimelineDefaults(callNode, scope) {
|
|
|
1049
1078
|
const key = propKeyName(prop);
|
|
1050
1079
|
const val = resolveNode(prop.value, scope);
|
|
1051
1080
|
if (key === "ease" && typeof val === "string") result.ease = val;
|
|
1052
|
-
if (key === "duration"
|
|
1081
|
+
if (key === "duration") {
|
|
1082
|
+
if (typeof val === "number") result.duration = val;
|
|
1083
|
+
else result.durationUnresolved = true;
|
|
1084
|
+
}
|
|
1053
1085
|
}
|
|
1054
1086
|
return Object.keys(result).length > 0 ? result : void 0;
|
|
1055
1087
|
}
|
|
@@ -1424,6 +1456,7 @@ function tweenCallToAnimation(call, scope, source, identifierBindings) {
|
|
|
1424
1456
|
if (duration === void 0 && keyframesData) {
|
|
1425
1457
|
duration = computeKeyframesTotalDuration(call.varsArg, scope, source);
|
|
1426
1458
|
}
|
|
1459
|
+
const durationUnresolved = call.method !== "set" && duration === void 0 && hasUnknownDuration(call.varsArg, scope);
|
|
1427
1460
|
let selector = call.selector;
|
|
1428
1461
|
let targetIdentity;
|
|
1429
1462
|
if (selector === "__unresolved__") {
|
|
@@ -1471,6 +1504,7 @@ function tweenCallToAnimation(call, scope, source, identifierBindings) {
|
|
|
1471
1504
|
if (keyframesData) anim.keyframes = keyframesData;
|
|
1472
1505
|
if (motionPathResult) anim.arcPath = motionPathResult.arcPath;
|
|
1473
1506
|
if (hasUnresolvedKeyframes) anim.hasUnresolvedKeyframes = true;
|
|
1507
|
+
if (durationUnresolved) anim.durationUnresolved = true;
|
|
1474
1508
|
if (selector === "__unresolved__") anim.hasUnresolvedSelector = true;
|
|
1475
1509
|
if (provenance) anim.provenance = provenance;
|
|
1476
1510
|
return anim;
|
|
@@ -1594,8 +1628,9 @@ function applyTimelineDefaults(anims, defaults) {
|
|
|
1594
1628
|
if (!defaults) return;
|
|
1595
1629
|
for (const anim of anims) {
|
|
1596
1630
|
if (anim.method === "set") continue;
|
|
1597
|
-
if (anim.duration === void 0 &&
|
|
1598
|
-
anim.duration = defaults.duration;
|
|
1631
|
+
if (anim.duration === void 0 && !anim.durationUnresolved) {
|
|
1632
|
+
if (defaults.duration !== void 0) anim.duration = defaults.duration;
|
|
1633
|
+
else if (defaults.durationUnresolved) anim.durationUnresolved = true;
|
|
1599
1634
|
}
|
|
1600
1635
|
if (anim.ease === void 0 && defaults.ease !== void 0) {
|
|
1601
1636
|
anim.ease = defaults.ease;
|
|
@@ -1628,12 +1663,14 @@ function resolveAnimStart(anim, cursor, prevStart, labels) {
|
|
|
1628
1663
|
function resolveTimelinePositions(anims, labelDefs = []) {
|
|
1629
1664
|
let cursor = 0;
|
|
1630
1665
|
let prevStart = 0;
|
|
1666
|
+
let cursorKnown = true;
|
|
1631
1667
|
const labels = /* @__PURE__ */ new Map();
|
|
1632
1668
|
let labelIdx = 0;
|
|
1633
1669
|
const sortedLabels = [...labelDefs].sort((a, b) => a.order - b.order);
|
|
1634
1670
|
const defineLabel = (def) => {
|
|
1635
1671
|
let value;
|
|
1636
1672
|
if (typeof def.position === "number") value = def.position;
|
|
1673
|
+
else if (!cursorKnown) return;
|
|
1637
1674
|
else if (typeof def.position === "string") {
|
|
1638
1675
|
value = resolveLabelPosition(def.position, labels, cursor) ?? cursor;
|
|
1639
1676
|
} else value = cursor;
|
|
@@ -1649,7 +1686,9 @@ function resolveTimelinePositions(anims, labelDefs = []) {
|
|
|
1649
1686
|
return;
|
|
1650
1687
|
}
|
|
1651
1688
|
const duration = anim.method === "set" ? 0 : anim.duration ?? GSAP_DEFAULT_DURATION;
|
|
1652
|
-
const
|
|
1689
|
+
const readsCursor = anim.implicitPosition || typeof anim.position !== "number";
|
|
1690
|
+
const start = cursorKnown || !readsCursor ? resolveAnimStart(anim, cursor, prevStart, labels) : null;
|
|
1691
|
+
if (start == null || anim.durationUnresolved) cursorKnown = false;
|
|
1653
1692
|
if (start != null) {
|
|
1654
1693
|
anim.resolvedStart = Math.max(0, start);
|
|
1655
1694
|
prevStart = anim.resolvedStart;
|
|
@@ -1659,7 +1698,15 @@ function resolveTimelinePositions(anims, labelDefs = []) {
|
|
|
1659
1698
|
while (labelIdx < sortedLabels.length) defineLabel(sortedLabels[labelIdx++]);
|
|
1660
1699
|
}
|
|
1661
1700
|
function collectAddLabelDefs(ast, ref, scope, sortedCalls) {
|
|
1662
|
-
const
|
|
1701
|
+
const callKeys = sortedCalls.map((c) => ({
|
|
1702
|
+
site: callSiteStart(c),
|
|
1703
|
+
order: c.node.__hfOrder
|
|
1704
|
+
}));
|
|
1705
|
+
const comesAfter = (site, order, labelSite, labelOrder) => {
|
|
1706
|
+
if (site === void 0) return false;
|
|
1707
|
+
if (site !== labelSite) return site > labelSite;
|
|
1708
|
+
return (order ?? -Infinity) > (labelOrder ?? -Infinity);
|
|
1709
|
+
};
|
|
1663
1710
|
const defs = [];
|
|
1664
1711
|
acornWalk.simple(ast, {
|
|
1665
1712
|
// fallow-ignore-next-line complexity
|
|
@@ -1673,12 +1720,11 @@ function collectAddLabelDefs(ast, ref, scope, sortedCalls) {
|
|
|
1673
1720
|
if (!name) return;
|
|
1674
1721
|
const posVal = resolveNode(node.arguments?.[1], scope);
|
|
1675
1722
|
const position = typeof posVal === "number" || typeof posVal === "string" ? posVal : void 0;
|
|
1676
|
-
const
|
|
1723
|
+
const labelStart = node.__hfSiteStart ?? callee.property?.start;
|
|
1724
|
+
const labelOrder = node.__hfOrder;
|
|
1677
1725
|
let order = sortedCalls.length;
|
|
1678
|
-
if (
|
|
1679
|
-
order =
|
|
1680
|
-
(l) => l && (l.line > labelLoc.line || l.line === labelLoc.line && l.column > labelLoc.column)
|
|
1681
|
-
);
|
|
1726
|
+
if (labelStart !== void 0) {
|
|
1727
|
+
order = callKeys.findIndex((k) => comesAfter(k.site, k.order, labelStart, labelOrder));
|
|
1682
1728
|
if (order === -1) order = sortedCalls.length;
|
|
1683
1729
|
}
|
|
1684
1730
|
defs.push({ name, position, order });
|
|
@@ -1692,13 +1738,17 @@ function compareByLoc(a, b) {
|
|
|
1692
1738
|
if (!aLoc || !bLoc) return 0;
|
|
1693
1739
|
return aLoc.line - bLoc.line || aLoc.column - bLoc.column;
|
|
1694
1740
|
}
|
|
1741
|
+
function callSiteStart(call) {
|
|
1742
|
+
return call.node.__hfSiteStart ?? call.node.callee?.property?.start;
|
|
1743
|
+
}
|
|
1695
1744
|
function compareCallOrder(a, b) {
|
|
1745
|
+
const aSite = callSiteStart(a);
|
|
1746
|
+
const bSite = callSiteStart(b);
|
|
1747
|
+
if (aSite !== void 0 && bSite !== void 0 && aSite !== bSite) return aSite - bSite;
|
|
1696
1748
|
const ao = a.node.__hfOrder;
|
|
1697
1749
|
const bo = b.node.__hfOrder;
|
|
1698
|
-
if (ao
|
|
1699
|
-
|
|
1700
|
-
if (bo === void 0) return 1;
|
|
1701
|
-
return ao - bo;
|
|
1750
|
+
if (ao !== void 0 && bo !== void 0) return ao - bo;
|
|
1751
|
+
return compareByLoc(a, b);
|
|
1702
1752
|
}
|
|
1703
1753
|
function sortBySourcePosition(calls) {
|
|
1704
1754
|
calls.sort(compareCallOrder);
|