@hyperframes/parsers 0.7.71 → 0.7.73
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/colorGradingContract.d.ts +58 -3
- package/dist/colorGradingContract.js +271 -16
- package/dist/colorGradingContract.js.map +1 -1
- package/dist/gsapConstants.js +4 -0
- package/dist/gsapConstants.js.map +1 -1
- package/dist/gsapParser.d.ts +3 -4
- package/dist/gsapParser.js +201 -86
- package/dist/gsapParser.js.map +1 -1
- package/dist/gsapParserAcorn.js +41 -29
- package/dist/gsapParserAcorn.js.map +1 -1
- package/dist/gsapParserExports.js +45 -29
- package/dist/gsapParserExports.js.map +1 -1
- package/dist/gsapWriterAcorn.d.ts +3 -4
- package/dist/gsapWriterAcorn.js +167 -69
- package/dist/gsapWriterAcorn.js.map +1 -1
- package/dist/index.js +45 -29
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -176,14 +176,18 @@ var SUPPORTED_EASES = [
|
|
|
176
176
|
"bounce.in",
|
|
177
177
|
"bounce.out",
|
|
178
178
|
"bounce.inOut",
|
|
179
|
+
"circ.inOut",
|
|
179
180
|
"expo.in",
|
|
180
181
|
"expo.out",
|
|
181
182
|
"expo.inOut",
|
|
183
|
+
"elastic.out(1,0.3)",
|
|
184
|
+
"elastic.inOut(1,0.3)",
|
|
182
185
|
"spring-gentle",
|
|
183
186
|
"spring-bouncy",
|
|
184
187
|
"spring-stiff",
|
|
185
188
|
"spring-wobbly",
|
|
186
189
|
"spring-heavy",
|
|
190
|
+
"hold",
|
|
187
191
|
"steps(1)"
|
|
188
192
|
];
|
|
189
193
|
|
|
@@ -411,6 +415,34 @@ function gsapAnimationsToKeyframes(animations, elementStartTime, options) {
|
|
|
411
415
|
import * as recast from "recast";
|
|
412
416
|
import { parse as babelParse } from "@babel/parser";
|
|
413
417
|
|
|
418
|
+
// src/gsapObjectArrayTiming.ts
|
|
419
|
+
var roundPercentage = (percentage) => Math.round(percentage * 10) / 10;
|
|
420
|
+
function getObjectArrayKeyframeTiming(durations) {
|
|
421
|
+
const hasAuthoredDuration = durations.some((duration) => duration !== void 0);
|
|
422
|
+
if (hasAuthoredDuration) {
|
|
423
|
+
if (!durations.every(
|
|
424
|
+
(duration) => typeof duration === "number" && Number.isFinite(duration) && duration > 0
|
|
425
|
+
)) {
|
|
426
|
+
return null;
|
|
427
|
+
}
|
|
428
|
+
const totalDuration = durations.reduce((sum, duration) => sum + duration, 0);
|
|
429
|
+
let cumulative = 0;
|
|
430
|
+
return {
|
|
431
|
+
percentages: durations.map((duration) => {
|
|
432
|
+
cumulative += duration;
|
|
433
|
+
return roundPercentage(cumulative / totalDuration * 100);
|
|
434
|
+
}),
|
|
435
|
+
totalDuration
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
const lastIndex = durations.length - 1;
|
|
439
|
+
return {
|
|
440
|
+
percentages: durations.map(
|
|
441
|
+
(_, index) => lastIndex > 0 ? roundPercentage(index / lastIndex * 100) : 0
|
|
442
|
+
)
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
|
|
414
446
|
// src/springEase.ts
|
|
415
447
|
var SPRING_PRESETS = [
|
|
416
448
|
{ name: "spring-gentle", label: "Gentle", mass: 1, stiffness: 100, damping: 15 },
|
|
@@ -1451,6 +1483,8 @@ function parsePercentageKeyframes(node, scope, source) {
|
|
|
1451
1483
|
for (const [k, v] of Object.entries(record)) {
|
|
1452
1484
|
if (k === "ease" && typeof v === "string") {
|
|
1453
1485
|
kfEase = v;
|
|
1486
|
+
} else if (k === "duration") {
|
|
1487
|
+
continue;
|
|
1454
1488
|
} else if (typeof v === "number" || typeof v === "string") {
|
|
1455
1489
|
properties[k] = v;
|
|
1456
1490
|
}
|
|
@@ -1475,13 +1509,13 @@ function computeKeyframesTotalDuration(varsNode, scope, source) {
|
|
|
1475
1509
|
(p) => (p.key?.name ?? p.key?.value) === "keyframes"
|
|
1476
1510
|
)?.value;
|
|
1477
1511
|
if (!kfNode || kfNode.type !== "ArrayExpression") return void 0;
|
|
1478
|
-
|
|
1512
|
+
const durations = [];
|
|
1479
1513
|
for (const el of kfNode.elements ?? []) {
|
|
1480
1514
|
if (!el || el.type !== "ObjectExpression") continue;
|
|
1481
1515
|
const r = objectExpressionToRecord(el, scope, source);
|
|
1482
|
-
|
|
1516
|
+
durations.push(r.duration);
|
|
1483
1517
|
}
|
|
1484
|
-
return
|
|
1518
|
+
return getObjectArrayKeyframeTiming(durations)?.totalDuration;
|
|
1485
1519
|
}
|
|
1486
1520
|
function parseObjectArrayKeyframes(node, scope, source) {
|
|
1487
1521
|
const elements = node.elements ?? [];
|
|
@@ -1493,7 +1527,7 @@ function parseObjectArrayKeyframes(node, scope, source) {
|
|
|
1493
1527
|
let duration;
|
|
1494
1528
|
let ease;
|
|
1495
1529
|
for (const [k, v] of Object.entries(record)) {
|
|
1496
|
-
if (k === "duration"
|
|
1530
|
+
if (k === "duration") {
|
|
1497
1531
|
duration = v;
|
|
1498
1532
|
} else if (k === "ease" && typeof v === "string") {
|
|
1499
1533
|
ease = v;
|
|
@@ -1503,31 +1537,13 @@ function parseObjectArrayKeyframes(node, scope, source) {
|
|
|
1503
1537
|
}
|
|
1504
1538
|
raw.push({ properties, duration, ease });
|
|
1505
1539
|
}
|
|
1506
|
-
const
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
keyframes.push({
|
|
1514
|
-
percentage,
|
|
1515
|
-
properties: entry.properties,
|
|
1516
|
-
...entry.ease ? { ease: entry.ease } : {}
|
|
1517
|
-
});
|
|
1518
|
-
}
|
|
1519
|
-
} else {
|
|
1520
|
-
for (let i = 0; i < raw.length; i++) {
|
|
1521
|
-
const entry = raw[i];
|
|
1522
|
-
if (!entry) continue;
|
|
1523
|
-
const percentage = raw.length > 1 ? Math.round(i / (raw.length - 1) * 100) : 0;
|
|
1524
|
-
keyframes.push({
|
|
1525
|
-
percentage,
|
|
1526
|
-
properties: entry.properties,
|
|
1527
|
-
...entry.ease ? { ease: entry.ease } : {}
|
|
1528
|
-
});
|
|
1529
|
-
}
|
|
1530
|
-
}
|
|
1540
|
+
const timing = getObjectArrayKeyframeTiming(raw.map((entry) => entry.duration));
|
|
1541
|
+
if (!timing) return void 0;
|
|
1542
|
+
const keyframes = raw.map((entry, index) => ({
|
|
1543
|
+
percentage: timing.percentages[index],
|
|
1544
|
+
properties: entry.properties,
|
|
1545
|
+
...entry.ease ? { ease: entry.ease } : {}
|
|
1546
|
+
}));
|
|
1531
1547
|
return { format: "object-array", keyframes };
|
|
1532
1548
|
}
|
|
1533
1549
|
function parseSimpleArrayKeyframes(node, scope) {
|