@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.
@@ -49,6 +49,8 @@ interface GsapAnimation {
49
49
  properties: Record<string, number | string>;
50
50
  fromProperties?: Record<string, number | string>;
51
51
  duration?: number;
52
+ /** A `duration` was authored but is not a static number: unknown, not the 0.5s default. */
53
+ durationUnresolved?: boolean;
52
54
  ease?: string;
53
55
  /** Non-editable GSAP config (stagger, yoyo, repeat, etc.) preserved for round-trips. */
54
56
  extras?: Record<string, unknown>;
@@ -1,4 +1,4 @@
1
- import { G as GsapAnimation, A as ArcPathConfig, g as SplitAnimationsOptions, h as SplitAnimationsResult, a as ArcPathSegment } from './gsapSerialize-QZcXUoVf.js';
1
+ import { G as GsapAnimation, A as ArcPathConfig, g as SplitAnimationsOptions, h as SplitAnimationsResult, a as ArcPathSegment } from './gsapSerialize-b8lNzSbI.js';
2
2
  import './types-Y0NXTiVo.js';
3
3
  import './gsapConstants.js';
4
4
 
@@ -631,6 +631,14 @@ function objectExpressionToRecord(node, scope, source) {
631
631
  function isGsapTimelineCall(node) {
632
632
  return node?.type === "CallExpression" && node.callee?.type === "MemberExpression" && node.callee.object?.name === "gsap" && node.callee.property?.name === "timeline";
633
633
  }
634
+ function hasUnknownDuration(varsNode, scope) {
635
+ if (!varsNode) return false;
636
+ if (varsNode.type !== "ObjectExpression") return true;
637
+ const props = varsNode.properties ?? [];
638
+ if (props.some((p) => p.type === "SpreadElement")) return true;
639
+ const prop = props.find((p) => isObjectProperty(p) && propKeyName(p) === "duration");
640
+ return prop !== void 0 && typeof resolveNode(prop.value, scope) !== "number";
641
+ }
634
642
  function staticMemberKey(node) {
635
643
  if (!node || node.type !== "MemberExpression") return null;
636
644
  if (node.computed) {
@@ -669,7 +677,10 @@ function extractTimelineDefaults(callNode, scope) {
669
677
  const key = propKeyName(prop);
670
678
  const val = resolveNode(prop.value, scope);
671
679
  if (key === "ease" && typeof val === "string") result.ease = val;
672
- if (key === "duration" && typeof val === "number") result.duration = val;
680
+ if (key === "duration") {
681
+ if (typeof val === "number") result.duration = val;
682
+ else result.durationUnresolved = true;
683
+ }
673
684
  }
674
685
  return Object.keys(result).length > 0 ? result : void 0;
675
686
  }
@@ -1044,6 +1055,7 @@ function tweenCallToAnimation(call, scope, source, identifierBindings) {
1044
1055
  if (duration === void 0 && keyframesData) {
1045
1056
  duration = computeKeyframesTotalDuration(call.varsArg, scope, source);
1046
1057
  }
1058
+ const durationUnresolved = call.method !== "set" && duration === void 0 && hasUnknownDuration(call.varsArg, scope);
1047
1059
  let selector = call.selector;
1048
1060
  let targetIdentity;
1049
1061
  if (selector === "__unresolved__") {
@@ -1091,6 +1103,7 @@ function tweenCallToAnimation(call, scope, source, identifierBindings) {
1091
1103
  if (keyframesData) anim.keyframes = keyframesData;
1092
1104
  if (motionPathResult) anim.arcPath = motionPathResult.arcPath;
1093
1105
  if (hasUnresolvedKeyframes) anim.hasUnresolvedKeyframes = true;
1106
+ if (durationUnresolved) anim.durationUnresolved = true;
1094
1107
  if (selector === "__unresolved__") anim.hasUnresolvedSelector = true;
1095
1108
  if (provenance) anim.provenance = provenance;
1096
1109
  return anim;
@@ -1124,8 +1137,9 @@ function applyTimelineDefaults(anims, defaults) {
1124
1137
  if (!defaults) return;
1125
1138
  for (const anim of anims) {
1126
1139
  if (anim.method === "set") continue;
1127
- if (anim.duration === void 0 && defaults.duration !== void 0) {
1128
- anim.duration = defaults.duration;
1140
+ if (anim.duration === void 0 && !anim.durationUnresolved) {
1141
+ if (defaults.duration !== void 0) anim.duration = defaults.duration;
1142
+ else if (defaults.durationUnresolved) anim.durationUnresolved = true;
1129
1143
  }
1130
1144
  if (anim.ease === void 0 && defaults.ease !== void 0) {
1131
1145
  anim.ease = defaults.ease;
@@ -1158,12 +1172,14 @@ function resolveAnimStart(anim, cursor, prevStart, labels) {
1158
1172
  function resolveTimelinePositions(anims, labelDefs = []) {
1159
1173
  let cursor = 0;
1160
1174
  let prevStart = 0;
1175
+ let cursorKnown = true;
1161
1176
  const labels = /* @__PURE__ */ new Map();
1162
1177
  let labelIdx = 0;
1163
1178
  const sortedLabels = [...labelDefs].sort((a, b) => a.order - b.order);
1164
1179
  const defineLabel = (def) => {
1165
1180
  let value;
1166
1181
  if (typeof def.position === "number") value = def.position;
1182
+ else if (!cursorKnown) return;
1167
1183
  else if (typeof def.position === "string") {
1168
1184
  value = resolveLabelPosition(def.position, labels, cursor) ?? cursor;
1169
1185
  } else value = cursor;
@@ -1179,7 +1195,9 @@ function resolveTimelinePositions(anims, labelDefs = []) {
1179
1195
  return;
1180
1196
  }
1181
1197
  const duration = anim.method === "set" ? 0 : anim.duration ?? GSAP_DEFAULT_DURATION;
1182
- const start = resolveAnimStart(anim, cursor, prevStart, labels);
1198
+ const readsCursor = anim.implicitPosition || typeof anim.position !== "number";
1199
+ const start = cursorKnown || !readsCursor ? resolveAnimStart(anim, cursor, prevStart, labels) : null;
1200
+ if (start == null || anim.durationUnresolved) cursorKnown = false;
1183
1201
  if (start != null) {
1184
1202
  anim.resolvedStart = Math.max(0, start);
1185
1203
  prevStart = anim.resolvedStart;
@@ -1194,13 +1212,17 @@ function compareByLoc(a, b) {
1194
1212
  if (!aLoc || !bLoc) return 0;
1195
1213
  return aLoc.line - bLoc.line || aLoc.column - bLoc.column;
1196
1214
  }
1215
+ function callSiteStart(call) {
1216
+ return call.node.__hfSiteStart ?? call.node.callee?.property?.start;
1217
+ }
1197
1218
  function compareCallOrder(a, b) {
1219
+ const aSite = callSiteStart(a);
1220
+ const bSite = callSiteStart(b);
1221
+ if (aSite !== void 0 && bSite !== void 0 && aSite !== bSite) return aSite - bSite;
1198
1222
  const ao = a.node.__hfOrder;
1199
1223
  const bo = b.node.__hfOrder;
1200
- if (ao === void 0 && bo === void 0) return compareByLoc(a, b);
1201
- if (ao === void 0) return -1;
1202
- if (bo === void 0) return 1;
1203
- return ao - bo;
1224
+ if (ao !== void 0 && bo !== void 0) return ao - bo;
1225
+ return compareByLoc(a, b);
1204
1226
  }
1205
1227
  function sortBySourcePosition(calls) {
1206
1228
  calls.sort(compareCallOrder);