(
parsed: ParsedDocument,
op: Extract<EditOp, { type: "addWithKeyframes" }>,
)
| 909 | // ─── addWithKeyframes / replaceWithKeyframes handlers ──────────────────────── |
| 910 | |
| 911 | function handleAddWithKeyframes( |
| 912 | parsed: ParsedDocument, |
| 913 | op: Extract<EditOp, { type: "addWithKeyframes" }>, |
| 914 | ): MutationResult { |
| 915 | const script = getGsapScript(parsed.document); |
| 916 | if (!script) throw new Error("No GSAP script block found in the composition."); |
| 917 | // Dispatch skips validateOp — re-enforce the empty-keyframes guard here so we |
| 918 | // never emit a degenerate `keyframes: {}` tween. |
| 919 | if (op.keyframes.length === 0) return EMPTY; |
| 920 | const { script: newScript, id: animationId } = addAnimationWithKeyframesToScript( |
| 921 | script, |
| 922 | op.targetSelector, |
| 923 | op.position, |
| 924 | op.duration, |
| 925 | op.keyframes, |
| 926 | op.ease, |
| 927 | ); |
| 928 | if (!animationId) return EMPTY; |
| 929 | setGsapScript(parsed.document, newScript); |
| 930 | return { ...gsapScriptChange(script, newScript), meta: { animationId } }; |
| 931 | } |
| 932 | |
| 933 | function handleReplaceWithKeyframes( |
| 934 | parsed: ParsedDocument, |
no test coverage detected