@hyperframes/parsers 0.8.98 → 0.8.100

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.
@@ -1,5 +1,5 @@
1
- import { P as ParsedGsap, c as GsapMethod, G as GsapAnimation } from './gsapSerialize-b8lNzSbI.js';
2
- export { A as ArcPathConfig, a as ArcPathSegment, e as GsapProvenance, f as GsapProvenanceKind, K as KeyframeEditability, M as MotionPathShape, m as buildArcPath, i as editabilityForProvenance } from './gsapSerialize-b8lNzSbI.js';
1
+ import { P as ParsedGsap, c as GsapMethod, G as GsapAnimation } from './gsapSerialize-D92cSJOu.js';
2
+ export { A as ArcPathConfig, a as ArcPathSegment, e as GsapProvenance, f as GsapProvenanceKind, K as KeyframeEditability, M as MotionPathShape, m as buildArcPath, i as editabilityForProvenance } from './gsapSerialize-D92cSJOu.js';
3
3
  import './types-Y0NXTiVo.js';
4
4
  import './gsapConstants.js';
5
5
 
@@ -9,6 +9,7 @@ interface TweenCallInfo {
9
9
  ancestors: any[];
10
10
  method: GsapMethod;
11
11
  selector: string;
12
+ selectorPartial?: boolean;
12
13
  varsArg: any;
13
14
  fromArg?: any;
14
15
  positionArg?: any;
@@ -34,6 +35,10 @@ declare function parseGsapScriptAcornForWrite(script: string): ParsedGsapAcornFo
34
35
  * Browser-safe equivalent of `parseGsapScript` (gsapParser.ts).
35
36
  * Uses acorn + acorn-walk instead of recast + @babel/parser.
36
37
  */
38
+ /** The script that holds a file's timeline: the first to declare one, else the first with tween calls. */
39
+ declare function findTimelineScript<T extends {
40
+ textContent: string | null;
41
+ }>(scripts: readonly T[]): T | null;
37
42
  declare function parseGsapScriptAcorn(script: string): ParsedGsap;
38
43
  /** Source offset of the first timeline or standalone GSAP MotionPathPlugin tween. */
39
44
  declare function gsapScriptMotionPathFirstUseIndex(script: string): number | null;
@@ -53,4 +58,4 @@ interface GsapLabelEntry {
53
58
  */
54
59
  declare function extractGsapLabels(script: string): GsapLabelEntry[];
55
60
 
56
- export { type GsapLabelEntry, type ParsedGsapAcornForWrite, type TweenCallInfo, extractGsapLabels, gsapScriptMotionPathFirstUseIndex, gsapScriptUsesMotionPath, parseGsapScriptAcorn, parseGsapScriptAcornForWrite };
61
+ export { type GsapLabelEntry, type ParsedGsapAcornForWrite, type TweenCallInfo, extractGsapLabels, findTimelineScript, gsapScriptMotionPathFirstUseIndex, gsapScriptUsesMotionPath, parseGsapScriptAcorn, parseGsapScriptAcornForWrite };
@@ -966,6 +966,11 @@ function resolveTargetSelector(node, ancestors, scope, bindings) {
966
966
  }
967
967
  return null;
968
968
  }
969
+ function hasUnresolvedArrayPart(node, ancestors, scope, bindings) {
970
+ return node?.type === "ArrayExpression" && node.elements.some(
971
+ (el) => !resolveTargetSelector(el, ancestors, scope, bindings) || hasUnresolvedArrayPart(el, ancestors, scope, bindings)
972
+ );
973
+ }
969
974
  function describeProxyTarget(targetNode, varsNode, scope) {
970
975
  const objNode = targetNode?.type === "ObjectExpression" ? targetNode : targetNode?.type === "Identifier" ? resolveConstNode(targetNode, scope) : void 0;
971
976
  if (objNode?.type !== "ObjectExpression") return null;
@@ -1153,12 +1158,14 @@ function findAllTweenCalls(ast, ref, scope, targetBindings) {
1153
1158
  const method = callee.property.name;
1154
1159
  const args = node.arguments;
1155
1160
  const selectorValue = args.length >= 1 ? resolveTargetSelector(args[0], nodeAncestors, scope, targetBindings) ?? "__unresolved__" : "__unresolved__";
1161
+ const partial = hasUnresolvedArrayPart(args[0], nodeAncestors, scope, targetBindings) ? { selectorPartial: true } : {};
1156
1162
  if (method === "fromTo" && args.length >= 3) {
1157
1163
  results.push({
1158
1164
  node,
1159
1165
  ancestors: nodeAncestors,
1160
1166
  method: "fromTo",
1161
1167
  selector: selectorValue,
1168
+ ...partial,
1162
1169
  fromArg: args[1],
1163
1170
  varsArg: args[2],
1164
1171
  positionArg: args[3]
@@ -1169,6 +1176,7 @@ function findAllTweenCalls(ast, ref, scope, targetBindings) {
1169
1176
  ancestors: nodeAncestors,
1170
1177
  method,
1171
1178
  selector: selectorValue,
1179
+ ...partial,
1172
1180
  varsArg: args[1],
1173
1181
  positionArg: args[2],
1174
1182
  ...isGlobalSet ? { global: true } : {}
@@ -1506,6 +1514,7 @@ function tweenCallToAnimation(call, scope, source, identifierBindings) {
1506
1514
  if (hasUnresolvedKeyframes) anim.hasUnresolvedKeyframes = true;
1507
1515
  if (durationUnresolved) anim.durationUnresolved = true;
1508
1516
  if (selector === "__unresolved__") anim.hasUnresolvedSelector = true;
1517
+ if (call.selectorPartial) anim.hasPartialSelector = true;
1509
1518
  if (provenance) anim.provenance = provenance;
1510
1519
  return anim;
1511
1520
  }
@@ -1798,6 +1807,10 @@ function parseGsapScriptAcornForWrite(script) {
1798
1807
  }
1799
1808
  var PARSE_MEMO_ENTRIES = 4;
1800
1809
  var parseMemo = /* @__PURE__ */ new Map();
1810
+ function findTimelineScript(scripts) {
1811
+ const text = (script) => script.textContent ?? "";
1812
+ return scripts.find((script) => text(script).includes("gsap.timeline")) ?? scripts.find((script) => /\.(set|to)\(/.test(text(script))) ?? null;
1813
+ }
1801
1814
  function parseGsapScriptAcorn(script) {
1802
1815
  const parsed = parseMemo.get(script) ?? parseGsapScriptAcornUncached(script);
1803
1816
  parseMemo.delete(script);
@@ -1957,6 +1970,7 @@ export {
1957
1970
  buildArcPath,
1958
1971
  editabilityForProvenance,
1959
1972
  extractGsapLabels,
1973
+ findTimelineScript,
1960
1974
  gsapScriptMotionPathFirstUseIndex,
1961
1975
  gsapScriptUsesMotionPath,
1962
1976
  parseGsapScriptAcorn,