@hyperframes/parsers 0.8.126 → 0.8.128
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/composition.d.ts +1 -1
- package/dist/composition.js.map +1 -1
- package/dist/gsapConstants.d.ts +1 -1
- package/dist/gsapConstants.js +28 -5
- package/dist/gsapConstants.js.map +1 -1
- package/dist/gsapParser.d.ts +2 -2
- package/dist/gsapParser.js +83 -53
- package/dist/gsapParser.js.map +1 -1
- package/dist/gsapParserAcorn.d.ts +2 -2
- package/dist/gsapParserAcorn.js +50 -40
- package/dist/gsapParserAcorn.js.map +1 -1
- package/dist/gsapParserExports.d.ts +15 -1
- package/dist/gsapParserExports.js +52 -40
- package/dist/gsapParserExports.js.map +1 -1
- package/dist/{gsapSerialize-CVwsMItk.d.ts → gsapSerialize-CfSXM_Ez.d.ts} +10 -2
- package/dist/gsapWriterAcorn.d.ts +23 -3
- package/dist/gsapWriterAcorn.js +169 -116
- package/dist/gsapWriterAcorn.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +53 -41
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { A as ArcPathConfig,
|
|
1
|
+
import { P as ParsedGsap, G as GsapMethod, a as GsapAnimation } from './gsapSerialize-CfSXM_Ez.js';
|
|
2
|
+
export { A as ArcPathConfig, b as ArcPathSegment, c as GsapProvenance, d as GsapProvenanceKind, K as KeyframeEditability, M as MotionPathShape, e as buildArcPath, f as editabilityForProvenance } from './gsapSerialize-CfSXM_Ez.js';
|
|
3
3
|
import './types-Ejqndkej.js';
|
|
4
4
|
|
|
5
5
|
interface TweenCallInfo {
|
package/dist/gsapParserAcorn.js
CHANGED
|
@@ -3,6 +3,23 @@ import * as acorn from "acorn";
|
|
|
3
3
|
import * as acornWalk from "acorn-walk";
|
|
4
4
|
|
|
5
5
|
// src/gsapConstants.ts
|
|
6
|
+
var GSAP_DEFAULT_DURATION = 0.5;
|
|
7
|
+
var BUILTIN_VAR_KEYS = /* @__PURE__ */ new Set(["duration", "ease", "delay"]);
|
|
8
|
+
var DROPPED_VAR_KEYS = /* @__PURE__ */ new Set([
|
|
9
|
+
"onComplete",
|
|
10
|
+
"onStart",
|
|
11
|
+
"onUpdate",
|
|
12
|
+
"onRepeat"
|
|
13
|
+
]);
|
|
14
|
+
var EXTRAS_KEYS = /* @__PURE__ */ new Set([
|
|
15
|
+
"stagger",
|
|
16
|
+
"yoyo",
|
|
17
|
+
"repeat",
|
|
18
|
+
"repeatDelay",
|
|
19
|
+
"snap",
|
|
20
|
+
"overwrite",
|
|
21
|
+
"immediateRender"
|
|
22
|
+
]);
|
|
6
23
|
var PROPERTY_GROUPS = {
|
|
7
24
|
position: /* @__PURE__ */ new Set(["x", "y", "xPercent", "yPercent"]),
|
|
8
25
|
scale: /* @__PURE__ */ new Set(["scale", "scaleX", "scaleY"]),
|
|
@@ -589,28 +606,20 @@ function inlineComputedTimelines(ast, timelineVar, resolve) {
|
|
|
589
606
|
// src/gsapObjectArrayTiming.ts
|
|
590
607
|
var roundPercentage = (percentage) => Math.round(percentage * 10) / 10;
|
|
591
608
|
function getObjectArrayKeyframeTiming(durations) {
|
|
592
|
-
const
|
|
593
|
-
if (
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
return null;
|
|
598
|
-
}
|
|
599
|
-
const totalDuration = durations.reduce((sum, duration) => sum + duration, 0);
|
|
600
|
-
let cumulative = 0;
|
|
601
|
-
return {
|
|
602
|
-
percentages: durations.map((duration) => {
|
|
603
|
-
cumulative += duration;
|
|
604
|
-
return roundPercentage(cumulative / totalDuration * 100);
|
|
605
|
-
}),
|
|
606
|
-
totalDuration
|
|
607
|
-
};
|
|
609
|
+
const steps = durations.map((duration) => duration ?? GSAP_DEFAULT_DURATION);
|
|
610
|
+
if (!steps.every(
|
|
611
|
+
(duration) => typeof duration === "number" && Number.isFinite(duration) && duration > 0
|
|
612
|
+
)) {
|
|
613
|
+
return null;
|
|
608
614
|
}
|
|
609
|
-
const
|
|
615
|
+
const totalDuration = steps.reduce((sum, duration) => sum + duration, 0);
|
|
616
|
+
let cumulative = 0;
|
|
610
617
|
return {
|
|
611
|
-
percentages:
|
|
612
|
-
|
|
613
|
-
|
|
618
|
+
percentages: steps.map((duration) => {
|
|
619
|
+
cumulative += duration;
|
|
620
|
+
return roundPercentage(cumulative / totalDuration * 100);
|
|
621
|
+
}),
|
|
622
|
+
totalDuration
|
|
614
623
|
};
|
|
615
624
|
}
|
|
616
625
|
|
|
@@ -1126,17 +1135,6 @@ function findTimelineVar(ast, scope) {
|
|
|
1126
1135
|
});
|
|
1127
1136
|
return { timelineVar, ref, timelineCount, defaults };
|
|
1128
1137
|
}
|
|
1129
|
-
var BUILTIN_VAR_KEYS = /* @__PURE__ */ new Set(["duration", "ease", "delay"]);
|
|
1130
|
-
var DROPPED_VAR_KEYS = /* @__PURE__ */ new Set(["onComplete", "onStart", "onUpdate", "onRepeat"]);
|
|
1131
|
-
var EXTRAS_KEYS = /* @__PURE__ */ new Set([
|
|
1132
|
-
"stagger",
|
|
1133
|
-
"yoyo",
|
|
1134
|
-
"repeat",
|
|
1135
|
-
"repeatDelay",
|
|
1136
|
-
"snap",
|
|
1137
|
-
"overwrite",
|
|
1138
|
-
"immediateRender"
|
|
1139
|
-
]);
|
|
1140
1138
|
function isTimelineRootedCall(callNode, ref) {
|
|
1141
1139
|
let obj = callNode.callee?.object;
|
|
1142
1140
|
while (obj?.type === "CallExpression") {
|
|
@@ -1215,6 +1213,7 @@ function parsePercentageKeyframes(node, scope, source) {
|
|
|
1215
1213
|
if (typeof key !== "string") continue;
|
|
1216
1214
|
const pctMatch = PERCENTAGE_KEY_RE.exec(key);
|
|
1217
1215
|
if (pctMatch) {
|
|
1216
|
+
if (!isPlainStep(prop.value)) return void 0;
|
|
1218
1217
|
const percentage = Number.parseFloat(pctMatch[1] ?? "0");
|
|
1219
1218
|
const record = objectExpressionToRecord(prop.value, scope, source);
|
|
1220
1219
|
const properties = {};
|
|
@@ -1233,6 +1232,8 @@ function parsePercentageKeyframes(node, scope, source) {
|
|
|
1233
1232
|
ease = tryResolveStringProp(prop.value, scope, source) ?? ease;
|
|
1234
1233
|
} else if (key === "easeEach") {
|
|
1235
1234
|
easeEach = tryResolveStringProp(prop.value, scope, source) ?? easeEach;
|
|
1235
|
+
} else {
|
|
1236
|
+
return void 0;
|
|
1236
1237
|
}
|
|
1237
1238
|
}
|
|
1238
1239
|
keyframes.sort((a, b) => a.percentage - b.percentage);
|
|
@@ -1256,11 +1257,19 @@ function computeKeyframesTotalDuration(varsNode, scope, source) {
|
|
|
1256
1257
|
}
|
|
1257
1258
|
return getObjectArrayKeyframeTiming(durations)?.totalDuration;
|
|
1258
1259
|
}
|
|
1260
|
+
function staticKeyName(prop) {
|
|
1261
|
+
if (prop.type !== "ObjectProperty" && prop.type !== "Property") return void 0;
|
|
1262
|
+
if (prop.method || prop.kind && prop.kind !== "init") return void 0;
|
|
1263
|
+
const key = prop.computed ? prop.key?.type === "Literal" && prop.key.value : prop.key?.name ?? prop.key?.value;
|
|
1264
|
+
return typeof key === "string" ? key : void 0;
|
|
1265
|
+
}
|
|
1266
|
+
var isPlainObject = (node) => node?.type === "ObjectExpression" && (node.properties ?? []).every((p) => staticKeyName(p) !== void 0);
|
|
1267
|
+
var isPlainStep = (node) => node?.type === "Literal" || isPlainObject(node);
|
|
1259
1268
|
function parseObjectArrayKeyframes(node, scope, source) {
|
|
1260
1269
|
const elements = node.elements ?? [];
|
|
1261
1270
|
const raw = [];
|
|
1262
1271
|
for (const el of elements) {
|
|
1263
|
-
if (!el
|
|
1272
|
+
if (!isPlainObject(el)) return void 0;
|
|
1264
1273
|
const record = objectExpressionToRecord(el, scope, source);
|
|
1265
1274
|
const properties = {};
|
|
1266
1275
|
let duration;
|
|
@@ -1272,6 +1281,8 @@ function parseObjectArrayKeyframes(node, scope, source) {
|
|
|
1272
1281
|
ease = v;
|
|
1273
1282
|
} else if (typeof v === "number" || typeof v === "string") {
|
|
1274
1283
|
properties[k] = v;
|
|
1284
|
+
} else {
|
|
1285
|
+
return void 0;
|
|
1275
1286
|
}
|
|
1276
1287
|
}
|
|
1277
1288
|
raw.push({ properties, duration, ease });
|
|
@@ -1297,9 +1308,8 @@ function parseSimpleArrayKeyframes(node, scope) {
|
|
|
1297
1308
|
const values = [];
|
|
1298
1309
|
for (const el of prop.value.elements ?? []) {
|
|
1299
1310
|
const val = resolveNode(el, scope);
|
|
1300
|
-
if (typeof val
|
|
1301
|
-
|
|
1302
|
-
}
|
|
1311
|
+
if (typeof val !== "number" && typeof val !== "string") return void 0;
|
|
1312
|
+
values.push(val);
|
|
1303
1313
|
}
|
|
1304
1314
|
if (values.length > 0) arrayProps.set(key, values);
|
|
1305
1315
|
} else if (key === "ease") {
|
|
@@ -1332,6 +1342,7 @@ function parseKeyframesNode(node, scope, source) {
|
|
|
1332
1342
|
}
|
|
1333
1343
|
if (node.type !== "ObjectExpression") return void 0;
|
|
1334
1344
|
const props = node.properties ?? [];
|
|
1345
|
+
if (!props.every((p) => staticKeyName(p) !== void 0)) return void 0;
|
|
1335
1346
|
let hasPercentageKey = false;
|
|
1336
1347
|
let hasArrayValue = false;
|
|
1337
1348
|
for (const prop of props) {
|
|
@@ -1432,7 +1443,7 @@ function tweenCallToAnimation(call, scope, source, identifierBindings) {
|
|
|
1432
1443
|
percentage: waypoints.length > 1 ? Math.round(i / (waypoints.length - 1) * 100) : 0,
|
|
1433
1444
|
properties: { x: wp.x, y: wp.y }
|
|
1434
1445
|
}));
|
|
1435
|
-
keyframesData = { format: "percentage", keyframes: kf };
|
|
1446
|
+
keyframesData = { format: "percentage", keyframes: kf, fromMotionPath: true };
|
|
1436
1447
|
} else {
|
|
1437
1448
|
const kfs = keyframesData.keyframes;
|
|
1438
1449
|
if (kfs.length === waypoints.length) {
|
|
@@ -1462,10 +1473,10 @@ function tweenCallToAnimation(call, scope, source, identifierBindings) {
|
|
|
1462
1473
|
const position = typeof posVal === "number" ? posVal : typeof posVal === "string" ? posVal : hasPositionArg ? `__raw:${source.slice(call.positionArg.start, call.positionArg.end)}` : 0;
|
|
1463
1474
|
let duration = typeof vars.duration === "number" ? vars.duration : void 0;
|
|
1464
1475
|
const ease = typeof vars.ease === "string" ? vars.ease : void 0;
|
|
1465
|
-
|
|
1476
|
+
const durationUnresolved = call.method !== "set" && duration === void 0 && hasUnknownDuration(call.varsArg, scope);
|
|
1477
|
+
if (duration === void 0 && keyframesData && !durationUnresolved) {
|
|
1466
1478
|
duration = computeKeyframesTotalDuration(call.varsArg, scope, source);
|
|
1467
1479
|
}
|
|
1468
|
-
const durationUnresolved = call.method !== "set" && duration === void 0 && hasUnknownDuration(call.varsArg, scope);
|
|
1469
1480
|
let selector = call.selector;
|
|
1470
1481
|
let targetIdentity;
|
|
1471
1482
|
if (selector === "__unresolved__") {
|
|
@@ -1560,7 +1571,6 @@ function annotateStaggeredCollections(anims) {
|
|
|
1560
1571
|
anim.keyframes = { format: "percentage", keyframes: staggeredKeyframes(anim, each) };
|
|
1561
1572
|
}
|
|
1562
1573
|
}
|
|
1563
|
-
var GSAP_DEFAULT_DURATION = 0.5;
|
|
1564
1574
|
function resolvePositionString(pos, cursor, prevStart) {
|
|
1565
1575
|
const trimmed = pos.trim();
|
|
1566
1576
|
if (trimmed === "") return cursor;
|
|
@@ -1642,7 +1652,7 @@ function applyTimelineDefaults(anims, defaults) {
|
|
|
1642
1652
|
if (defaults.duration !== void 0) anim.duration = defaults.duration;
|
|
1643
1653
|
else if (defaults.durationUnresolved) anim.durationUnresolved = true;
|
|
1644
1654
|
}
|
|
1645
|
-
if (anim.ease === void 0 && defaults.ease !== void 0 && !anim.keyframes) {
|
|
1655
|
+
if (anim.ease === void 0 && defaults.ease !== void 0 && (!anim.keyframes || anim.keyframes.fromMotionPath)) {
|
|
1646
1656
|
anim.ease = defaults.ease;
|
|
1647
1657
|
}
|
|
1648
1658
|
}
|