( call: TweenCallInfo, scope: ScopeBindings, )
| 917 | |
| 918 | // fallow-ignore-next-line complexity |
| 919 | function tweenCallToAnimation( |
| 920 | call: TweenCallInfo, |
| 921 | scope: ScopeBindings, |
| 922 | ): Omit<GsapAnimation, "id"> { |
| 923 | const vars = objectExpressionToRecord(call.varsArg, scope); |
| 924 | const properties: Record<string, number | string> = {}; |
| 925 | const extras: Record<string, unknown> = {}; |
| 926 | let keyframesData: GsapKeyframesData | undefined; |
| 927 | let hasUnresolvedKeyframes = false; |
| 928 | let motionPathResult: MotionPathParseResult | undefined; |
| 929 | |
| 930 | for (const [key, val] of Object.entries(vars)) { |
| 931 | if (BUILTIN_VAR_KEYS.has(key)) continue; |
| 932 | if (DROPPED_VAR_KEYS.has(key)) continue; |
| 933 | |
| 934 | if (key === "keyframes") { |
| 935 | const kfNode = findPropertyNode(call.varsArg, "keyframes"); |
| 936 | keyframesData = parseKeyframesNode(kfNode, scope); |
| 937 | if (!keyframesData && kfNode) hasUnresolvedKeyframes = true; |
| 938 | continue; |
| 939 | } |
| 940 | |
| 941 | if (key === "motionPath") { |
| 942 | const mpNode = findPropertyNode(call.varsArg, "motionPath"); |
| 943 | motionPathResult = parseMotionPathNode(mpNode, scope); |
| 944 | continue; |
| 945 | } |
| 946 | |
| 947 | if (key === "easeEach") { |
| 948 | // easeEach is only meaningful alongside keyframes — handled below. |
| 949 | continue; |
| 950 | } |
| 951 | |
| 952 | if (EXTRAS_KEYS.has(key)) { |
| 953 | // For extras, prefer the raw AST source so complex objects like |
| 954 | // `stagger: { each: 0.15, from: "start" }` survive verbatim. |
| 955 | const rawSource = extractRawPropertySource(call.varsArg, key); |
| 956 | if (rawSource !== undefined) { |
| 957 | extras[key] = `__raw:${rawSource}`; |
| 958 | } else if (val !== undefined) { |
| 959 | extras[key] = val; |
| 960 | } |
| 961 | continue; |
| 962 | } |
| 963 | |
| 964 | if (typeof val === "number" || typeof val === "string") { |
| 965 | properties[key] = val; |
| 966 | } |
| 967 | } |
| 968 | |
| 969 | // Apply tween-level easeEach to keyframes data. |
| 970 | if (keyframesData && typeof vars.easeEach === "string") { |
| 971 | keyframesData.easeEach = vars.easeEach as string; |
| 972 | } |
| 973 | |
| 974 | // When motionPath is present, reconstruct x/y as keyframe waypoints. |
| 975 | if (motionPathResult) { |
| 976 | const { waypoints } = motionPathResult; |
no test coverage detected