@hyperframes/parsers 0.8.134 → 0.8.136

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.
@@ -222,4 +222,4 @@ declare function gsapAnimationsToKeyframes(animations: GsapAnimation[], elementS
222
222
  skipBaseSet?: boolean;
223
223
  }): Keyframe[];
224
224
 
225
- export { type ArcPathConfig as A, BUILTIN_VAR_KEYS as B, keyframeHoldForAnimation as C, DROPPED_VAR_KEYS as D, EXTRAS_KEYS as E, type GsapMethod as G, type HoldScope as H, type KeyframeEditability as K, type MotionPathShape as M, type ParsedGsap as P, SUPPORTED_EASES as S, type GsapAnimation as a, type ArcPathSegment as b, type GsapProvenance as c, type GsapProvenanceKind as d, buildArcPath as e, editabilityForProvenance as f, type GsapKeyframeFormat as g, type GsapKeyframesData as h, type GsapPercentageKeyframe as i, PROPERTY_GROUPS as j, type PropertyGroupName as k, SUPPORTED_PROPS as l, classifyPropertyGroup as m, classifyTweenPropertyGroup as n, getAnimationsForElementId as o, gsapAnimationsToKeyframes as p, keyframesToGsapAnimations as q, type SplitAnimationsOptions as r, serializeGsapAnimations as s, type SplitAnimationsResult as t, GSAP_DEFAULT_DURATION as u, validateCompositionGsap as v, type SourcedGsapPercentageKeyframe as w, holdScope as x, isTweenConfigKey as y, isXYPositionWrite as z };
225
+ export { type ArcPathConfig as A, BUILTIN_VAR_KEYS as B, keyframeHoldForAnimation as C, DROPPED_VAR_KEYS as D, EXTRAS_KEYS as E, type GsapAnimation as G, type HoldScope as H, type KeyframeEditability as K, type MotionPathShape as M, type ParsedGsap as P, SUPPORTED_EASES as S, type ArcPathSegment as a, type GsapKeyframeFormat as b, type GsapKeyframesData as c, type GsapMethod as d, type GsapPercentageKeyframe as e, PROPERTY_GROUPS as f, type PropertyGroupName as g, SUPPORTED_PROPS as h, classifyPropertyGroup as i, classifyTweenPropertyGroup as j, getAnimationsForElementId as k, gsapAnimationsToKeyframes as l, keyframesToGsapAnimations as m, type GsapProvenance as n, type GsapProvenanceKind as o, buildArcPath as p, editabilityForProvenance as q, type SplitAnimationsOptions as r, serializeGsapAnimations as s, type SplitAnimationsResult as t, GSAP_DEFAULT_DURATION as u, validateCompositionGsap as v, type SourcedGsapPercentageKeyframe as w, holdScope as x, isTweenConfigKey as y, isXYPositionWrite as z };
@@ -1,4 +1,4 @@
1
- import { a as GsapAnimation, A as ArcPathConfig, r as SplitAnimationsOptions, t as SplitAnimationsResult, b as ArcPathSegment } from './gsapSerialize-_tuK-qvB.js';
1
+ import { G as GsapAnimation, A as ArcPathConfig, r as SplitAnimationsOptions, t as SplitAnimationsResult, a as ArcPathSegment } from './gsapSerialize-WJrRO8uT.js';
2
2
  import './types-Ejqndkej.js';
3
3
 
4
4
  type TweenTarget = Pick<GsapAnimation, "targetSelector" | "hasPartialSelector">;
@@ -138,6 +138,10 @@ function buildArcPath(coords, curviness, autoRotate, isCubic) {
138
138
  }
139
139
  return { arcPath: { enabled: true, autoRotate, segments }, waypoints };
140
140
  }
141
+ function plainPercentKey(percentage) {
142
+ const text = Math.abs(percentage) < 1e-6 ? percentage.toFixed(20).replace(/\.?0+$/, "") : String(percentage);
143
+ return `${text}%`;
144
+ }
141
145
  var CSS_IDENTITY = {
142
146
  opacity: 1,
143
147
  autoAlpha: 1,
@@ -1087,9 +1091,6 @@ function tweenCallToAnimation(call, scope, source, identifierBindings) {
1087
1091
  properties[key] = val;
1088
1092
  }
1089
1093
  }
1090
- if (keyframesData && typeof vars.easeEach === "string") {
1091
- keyframesData.easeEach = vars.easeEach;
1092
- }
1093
1094
  if (motionPathResult) {
1094
1095
  const { waypoints } = motionPathResult;
1095
1096
  if (!keyframesData) {
@@ -2155,7 +2156,7 @@ function convertArrayKeyframesToObject(script, target) {
2155
2156
  if (!timing) return script;
2156
2157
  const entries = els.map((el, i) => {
2157
2158
  const { duration: _duration, ...record } = records[i];
2158
- return `${JSON.stringify(`${timing.percentages[i]}%`)}: ${recordToCode(record)}`;
2159
+ return `${JSON.stringify(plainPercentKey(timing.percentages[i]))}: ${recordToCode(record)}`;
2159
2160
  });
2160
2161
  const ms = new MagicString(script);
2161
2162
  ms.overwrite(
@@ -2217,7 +2218,13 @@ function addKeyframeToScript(script, animationId, percentage, properties, ease,
2217
2218
  ms.overwrite(existing.prop.value.start, existing.prop.value.end, recordToCode(targetRecord));
2218
2219
  }
2219
2220
  } else {
2220
- insertNewKeyframe(ms, kfNode, percentage, `${percentage}%`, recordToCode(targetRecord));
2221
+ insertNewKeyframe(
2222
+ ms,
2223
+ kfNode,
2224
+ percentage,
2225
+ plainPercentKey(percentage),
2226
+ recordToCode(targetRecord)
2227
+ );
2221
2228
  }
2222
2229
  for (const [prop, rec] of [...endpointOverwrites, ...backfillOverwrites]) {
2223
2230
  ms.overwrite(prop.value.start, prop.value.end, recordToCode(rec));
@@ -2316,7 +2323,12 @@ function moveKeyframeInScript(script, animationId, fromPercentage, toPercentage)
2316
2323
  }
2317
2324
  entries.push({ pct: toPercentage, record: valueNodeToRecord(match.prop.value, src) });
2318
2325
  entries.sort((a, b) => a.pct - b.pct);
2319
- const body = entries.map((e) => `${JSON.stringify(`${e.pct}%`)}: ${recordToCode(e.record)}`).join(", ");
2326
+ const pctProps = new Set(percentagePropsOf(kfNode));
2327
+ const kept = (kfNode.properties ?? []).filter((p) => !pctProps.has(p)).map((p) => src.slice(p.start, p.end));
2328
+ const body = [
2329
+ ...entries.map((e) => `${JSON.stringify(plainPercentKey(e.pct))}: ${recordToCode(e.record)}`),
2330
+ ...kept
2331
+ ].join(", ");
2320
2332
  const ms = new MagicString(src);
2321
2333
  ms.overwrite(kfNode.start, kfNode.end, `{ ${body} }`);
2322
2334
  return ms.toString();
@@ -2335,7 +2347,7 @@ function resizeKeyframedTweenInScript(script, animationId, newPosition, newDurat
2335
2347
  }
2336
2348
  const ms = new MagicString(src);
2337
2349
  for (const { keyNode, to } of edits) {
2338
- ms.overwrite(keyNode.start, keyNode.end, JSON.stringify(`${to}%`));
2350
+ ms.overwrite(keyNode.start, keyNode.end, JSON.stringify(plainPercentKey(to)));
2339
2351
  }
2340
2352
  overwritePosition(ms, target.call, newPosition);
2341
2353
  upsertProp(ms, target.call.varsArg, "duration", newDuration);
@@ -2453,7 +2465,7 @@ function buildKeyframeObjectCode(keyframes, easeEach) {
2453
2465
  const props = Object.entries(kf.properties).map(([k, v]) => `${safeKey(k)}: ${valueToCode(v)}`);
2454
2466
  if (kf.ease) props.push(`ease: ${valueToCode(kf.ease)}`);
2455
2467
  if (kf.auto) props.push(`_auto: 1`);
2456
- return `${JSON.stringify(`${kf.percentage}%`)}: { ${props.join(", ")} }`;
2468
+ return `${JSON.stringify(plainPercentKey(kf.percentage))}: { ${props.join(", ")} }`;
2457
2469
  });
2458
2470
  if (easeEach) entries.push(`easeEach: ${valueToCode(easeEach)}`);
2459
2471
  return `{ ${entries.join(", ")} }`;
@@ -2607,7 +2619,8 @@ function addGroupAnimToScript(script, anim, propSet) {
2607
2619
  pos,
2608
2620
  anim.duration ?? 0.5,
2609
2621
  groupKeyframes,
2610
- anim.keyframes.easeEach ?? anim.ease
2622
+ anim.keyframes.ease ?? anim.ease,
2623
+ anim.keyframes.easeEach
2611
2624
  );
2612
2625
  }
2613
2626
  const groupProperties = filterGroupProperties(anim.properties, propSet);