( node: AstNode | undefined, scope: ScopeBindings, )
| 631 | */ |
| 632 | // fallow-ignore-next-line complexity |
| 633 | function parseKeyframesNode( |
| 634 | node: AstNode | undefined, |
| 635 | scope: ScopeBindings, |
| 636 | ): GsapKeyframesData | undefined { |
| 637 | if (!node) return undefined; |
| 638 | |
| 639 | // ── Object array format: keyframes: [ { x: 0, duration: 0.5 }, ... ] ── |
| 640 | if (node.type === "ArrayExpression") { |
| 641 | return parseObjectArrayKeyframes(node, scope); |
| 642 | } |
| 643 | |
| 644 | if (node.type !== "ObjectExpression") return undefined; |
| 645 | |
| 646 | // Distinguish percentage vs simple-array by inspecting property keys/values. |
| 647 | const props = node.properties ?? []; |
| 648 | let hasPercentageKey = false; |
| 649 | let hasArrayValue = false; |
| 650 | |
| 651 | for (const prop of props) { |
| 652 | if (prop.type !== "ObjectProperty" && prop.type !== "Property") continue; |
| 653 | const key = prop.key?.value ?? prop.key?.name; |
| 654 | if (typeof key === "string" && PERCENTAGE_KEY_RE.test(key)) { |
| 655 | hasPercentageKey = true; |
| 656 | break; |
| 657 | } |
| 658 | if (prop.value?.type === "ArrayExpression") { |
| 659 | hasArrayValue = true; |
| 660 | } |
| 661 | } |
| 662 | |
| 663 | if (hasPercentageKey) return parsePercentageKeyframes(node, scope); |
| 664 | if (hasArrayValue) return parseSimpleArrayKeyframes(node, scope); |
| 665 | |
| 666 | return undefined; |
| 667 | } |
| 668 | |
| 669 | // fallow-ignore-next-line complexity |
| 670 | function parsePercentageKeyframes(node: AstNode, scope: ScopeBindings): GsapKeyframesData { |
no test coverage detected