@hyperframes/parsers 0.8.121 → 0.8.122
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.js +6 -5
- package/dist/gsapParserAcorn.js.map +1 -1
- package/dist/gsapParserExports.js +6 -5
- package/dist/gsapParserExports.js.map +1 -1
- package/dist/gsapWriterAcorn.js +14 -13
- package/dist/gsapWriterAcorn.js.map +1 -1
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/gsapWriterAcorn.js
CHANGED
|
@@ -829,9 +829,10 @@ function findAllTweenCalls(ast, ref, scope, targetBindings) {
|
|
|
829
829
|
return results;
|
|
830
830
|
}
|
|
831
831
|
var PERCENTAGE_KEY_RE = /^(\d+(?:\.\d+)?)%$/;
|
|
832
|
-
function tryResolveStringProp(propValue, scope) {
|
|
832
|
+
function tryResolveStringProp(propValue, scope, source) {
|
|
833
833
|
const val = resolveNode(propValue, scope);
|
|
834
|
-
|
|
834
|
+
if (typeof val === "string") return val;
|
|
835
|
+
return source === void 0 ? void 0 : `__raw:${source.slice(propValue.start, propValue.end)}`;
|
|
835
836
|
}
|
|
836
837
|
function parsePercentageKeyframes(node, scope, source) {
|
|
837
838
|
const keyframes = [];
|
|
@@ -858,9 +859,9 @@ function parsePercentageKeyframes(node, scope, source) {
|
|
|
858
859
|
}
|
|
859
860
|
keyframes.push({ percentage, properties, ...kfEase ? { ease: kfEase } : {} });
|
|
860
861
|
} else if (key === "ease") {
|
|
861
|
-
ease = tryResolveStringProp(prop.value, scope) ?? ease;
|
|
862
|
+
ease = tryResolveStringProp(prop.value, scope, source) ?? ease;
|
|
862
863
|
} else if (key === "easeEach") {
|
|
863
|
-
easeEach = tryResolveStringProp(prop.value, scope) ?? easeEach;
|
|
864
|
+
easeEach = tryResolveStringProp(prop.value, scope, source) ?? easeEach;
|
|
864
865
|
}
|
|
865
866
|
}
|
|
866
867
|
keyframes.sort((a, b) => a.percentage - b.percentage);
|
|
@@ -1180,7 +1181,7 @@ function applyTimelineDefaults(anims, defaults) {
|
|
|
1180
1181
|
if (defaults.duration !== void 0) anim.duration = defaults.duration;
|
|
1181
1182
|
else if (defaults.durationUnresolved) anim.durationUnresolved = true;
|
|
1182
1183
|
}
|
|
1183
|
-
if (anim.ease === void 0 && defaults.ease !== void 0) {
|
|
1184
|
+
if (anim.ease === void 0 && defaults.ease !== void 0 && !anim.keyframes) {
|
|
1184
1185
|
anim.ease = defaults.ease;
|
|
1185
1186
|
}
|
|
1186
1187
|
}
|
|
@@ -1853,7 +1854,7 @@ function preservedVarsEntries(varsNode, source) {
|
|
|
1853
1854
|
function buildConvertedVarsCode(animation, varsNode, source) {
|
|
1854
1855
|
const { fromProps, toProps } = conversionEndpoints(animation);
|
|
1855
1856
|
const easeEach = animation.ease;
|
|
1856
|
-
const easeEachEntry = easeEach ? `, easeEach: ${
|
|
1857
|
+
const easeEachEntry = easeEach ? `, easeEach: ${valueToCode(easeEach)}` : "";
|
|
1857
1858
|
const kfCode = `{ "0%": ${recordToCode(fromProps)}, "100%": ${recordToCode(toProps)}${easeEachEntry} }`;
|
|
1858
1859
|
const entries = [`keyframes: ${kfCode}`, ...preservedVarsEntries(varsNode, source)];
|
|
1859
1860
|
if (easeEach) entries.push(`ease: "none"`);
|
|
@@ -2330,7 +2331,7 @@ function buildCollapsedFlatVars(animation, collapse) {
|
|
|
2330
2331
|
function buildKeyframesVarsCode(animation, fromProps, toProps, varsNode, source, setDuration) {
|
|
2331
2332
|
const fromEntries = Object.entries(fromProps).map(([k, v]) => `${safeKey(k)}: ${valueToCode(v)}`);
|
|
2332
2333
|
const toEntries = Object.entries(toProps).map(([k, v]) => `${safeKey(k)}: ${valueToCode(v)}`);
|
|
2333
|
-
const easeEntry = animation.ease ? `, easeEach: ${
|
|
2334
|
+
const easeEntry = animation.ease ? `, easeEach: ${valueToCode(animation.ease)}` : "";
|
|
2334
2335
|
const kfCode = `{ "0%": { ${fromEntries.join(", ")} }, "100%": { ${toEntries.join(", ")} }${easeEntry} }`;
|
|
2335
2336
|
let preserved = preservedVarsEntries(varsNode, source);
|
|
2336
2337
|
if (setDuration !== void 0) {
|
|
@@ -2384,11 +2385,11 @@ function convertToKeyframesFromScript(script, animationId, resolvedFromValues, s
|
|
|
2384
2385
|
function buildKeyframeObjectCode(keyframes, easeEach) {
|
|
2385
2386
|
const entries = mergePercentageKeyframes(keyframes).map((kf) => {
|
|
2386
2387
|
const props = Object.entries(kf.properties).map(([k, v]) => `${safeKey(k)}: ${valueToCode(v)}`);
|
|
2387
|
-
if (kf.ease) props.push(`ease: ${
|
|
2388
|
+
if (kf.ease) props.push(`ease: ${valueToCode(kf.ease)}`);
|
|
2388
2389
|
if (kf.auto) props.push(`_auto: 1`);
|
|
2389
2390
|
return `${JSON.stringify(`${kf.percentage}%`)}: { ${props.join(", ")} }`;
|
|
2390
2391
|
});
|
|
2391
|
-
if (easeEach) entries.push(`easeEach: ${
|
|
2392
|
+
if (easeEach) entries.push(`easeEach: ${valueToCode(easeEach)}`);
|
|
2392
2393
|
return `{ ${entries.join(", ")} }`;
|
|
2393
2394
|
}
|
|
2394
2395
|
function materializeKeyframesFromScript(script, animationId, keyframes, easeEach, resolvedSelector) {
|
|
@@ -2441,7 +2442,7 @@ function replaceTweenWithKeyframesInScript(script, animationId, edit) {
|
|
|
2441
2442
|
const sorted = [...edit.keyframes].sort((a, b) => a.percentage - b.percentage);
|
|
2442
2443
|
const parts = [`keyframes: ${buildKeyframeObjectCode(sorted, edit.easeEach)}`, ...kept];
|
|
2443
2444
|
parts.push(`duration: ${valueToCode(edit.duration)}`);
|
|
2444
|
-
if (edit.ease) parts.push(`ease: ${
|
|
2445
|
+
if (edit.ease) parts.push(`ease: ${valueToCode(edit.ease)}`);
|
|
2445
2446
|
if (animation.hasUnresolvedSelector || animation.targetSelector !== edit.targetSelector) {
|
|
2446
2447
|
const selectorArg = call.node.arguments[0];
|
|
2447
2448
|
ms.overwrite(selectorArg.start, selectorArg.end, JSON.stringify(edit.targetSelector));
|
|
@@ -2459,7 +2460,7 @@ function addAnimationWithKeyframesToScript(script, targetSelector, position, dur
|
|
|
2459
2460
|
const sorted = [...keyframes].sort((a, b) => a.percentage - b.percentage);
|
|
2460
2461
|
const kfObjCode = buildKeyframeObjectCode(sorted, easeEach);
|
|
2461
2462
|
const varParts = [`keyframes: ${kfObjCode}`, `duration: ${valueToCode(duration)}`];
|
|
2462
|
-
if (ease) varParts.push(`ease: ${
|
|
2463
|
+
if (ease) varParts.push(`ease: ${valueToCode(ease)}`);
|
|
2463
2464
|
const stmtCode = `${parsed.timelineVar}.to(${JSON.stringify(targetSelector)}, { ${varParts.join(", ")} }, ${valueToCode(position)});`;
|
|
2464
2465
|
const ms = new MagicString(script);
|
|
2465
2466
|
ms.appendLeft(insertionPoint, "\n" + stmtCode);
|
|
@@ -3063,7 +3064,7 @@ function buildUnrollReplacement(timelineVar, animation, elements) {
|
|
|
3063
3064
|
const calls = elements.map((el) => {
|
|
3064
3065
|
const sorted = [...el.keyframes].sort((a, b) => a.percentage - b.percentage);
|
|
3065
3066
|
const kfCode = buildKeyframeObjectCode(sorted, el.easeEach);
|
|
3066
|
-
return `${timelineVar}.to(${JSON.stringify(el.selector)}, { keyframes: ${kfCode}, duration: ${duration}, ease: ${
|
|
3067
|
+
return `${timelineVar}.to(${JSON.stringify(el.selector)}, { keyframes: ${kfCode}, duration: ${duration}, ease: ${valueToCode(ease)} }, ${posCode});`;
|
|
3067
3068
|
});
|
|
3068
3069
|
return calls.join("\n ");
|
|
3069
3070
|
}
|
|
@@ -3074,7 +3075,7 @@ function buildUnrollCallForElement(timelineVar, animation, el) {
|
|
|
3074
3075
|
const posCode = typeof pos === "number" ? String(pos) : JSON.stringify(pos);
|
|
3075
3076
|
const sorted = [...el.keyframes].sort((a, b) => a.percentage - b.percentage);
|
|
3076
3077
|
const kfCode = buildKeyframeObjectCode(sorted, el.easeEach);
|
|
3077
|
-
return `${timelineVar}.to(${JSON.stringify(el.selector)}, { keyframes: ${kfCode}, duration: ${duration}, ease: ${
|
|
3078
|
+
return `${timelineVar}.to(${JSON.stringify(el.selector)}, { keyframes: ${kfCode}, duration: ${duration}, ease: ${valueToCode(ease)} }, ${posCode});`;
|
|
3078
3079
|
}
|
|
3079
3080
|
var REFUSE_UNROLL = /* @__PURE__ */ Symbol("refuse-unroll");
|
|
3080
3081
|
function loopBodyRawStatements(loopNode) {
|