🎥 Make videos programmatically with React
Add interpolatePaths and interactive path keyframes
Jonny Burger9d7caad11439
diff --git a/bun.lock b/bun.lockindex 95b917d6c2..a49fb4032d 100644--- a/bun.lock+++ b/bun.lock@@ -1440,6 +1440,9 @@"packages/paths": {"name": "@remotion/paths","version": "4.0.527",+ "dependencies": {+ "remotion": "workspace:*",+ },"devDependencies": {"@remotion/eslint-config-internal": "workspace:*","@typescript/native-preview": "catalog:",diff --git a/packages/codemods/src/index.ts b/packages/codemods/src/index.tsindex beecf916c3..03a448ae51 100644--- a/packages/codemods/src/index.ts+++ b/packages/codemods/src/index.ts@@ -23,6 +23,7 @@ import {import {computeSequencePropsSubscriptionFromContent} from './sequence-props';import {JsxElementIdentityMismatchError} from './sequence-props/jsx-component-identity';import {JsxElementNotFoundAtLocationError} from './sequence-props/jsx-element-not-found-at-location-error';+import {getKeyframeInterpolationFunctionForCallee} from './sequence-props/keyframe-interpolation-function';import {simpleDiff} from './simple-diff';import {updateInlineCaptionPatches} from './update-inline-caption-patches';@@ -172,6 +173,7 @@ export const CodemodsInternals = {getCompositionComponentInfo,getCompositionFile,getFolderFile,+ getKeyframeInterpolationFunctionForCallee,getRootFileForProject,insertBasicCaptions,insertJsxElementIntoComposition,diff --git a/packages/codemods/src/sequence-props.ts b/packages/codemods/src/sequence-props.tsindex 6a37accd1b..a3dbd68933 100644--- a/packages/codemods/src/sequence-props.ts+++ b/packages/codemods/src/sequence-props.ts@@ -14,7 +14,6 @@ import type {} from '@babel/types';import type {SubscribeToSequencePropsResponse} from '@remotion/studio-shared';import {LINEAR_KEYFRAME_EASING} from '@remotion/studio-shared/keyframe-easing-presets';-import {isKeyframeInterpolationFunction} from '@remotion/studio-shared/keyframe-interpolation-function';import * as recast from 'recast';import type {CanUpdateSequencePropsResponseTrue,@@ -39,6 +38,7 @@ import {JsxElementIdentityMismatchError,} from './sequence-props/jsx-component-identity';import {JsxElementNotFoundAtLocationError} from './sequence-props/jsx-element-not-found-at-location-error';+import {getKeyframeInterpolationFunctionForCallee} from './sequence-props/keyframe-interpolation-function';import {parseBorderRadiusShorthand} from './sequence-props/parse-border-radius-shorthand';import {parseKeyframeEasingExpression} from './sequence-props/parse-keyframe-easing-expression';import {parseVideoConfigNumericExpression} from './sequence-props/video-config-numeric-expression';@@ -453,7 +453,11 @@ const getInterpolationMetadata = (}const extrapolateType = getExtrapolateType(value);- if (!extrapolateType) {+ if (+ !extrapolateType ||+ (interpolationFunction === 'interpolatePaths' &&+ extrapolateType === 'identity')+ ) {return null;}@@ -479,7 +483,7 @@ const getInterpolationMetadata = (}if (key === 'output') {- if (interpolationFunction === 'interpolateColors') {+ if (interpolationFunction !== 'interpolate') {return null;}@@ -494,7 +498,7 @@ const getInterpolationMetadata = (if (key === 'outputType') {if (- interpolationFunction === 'interpolateColors' ||+ interpolationFunction !== 'interpolate' ||getInterpolateOutputType(value) === null) {return null;@@ -964,14 +968,17 @@ const getInterpolationKeyframes = (}const callExpression = node as CallExpression;- if (- callExpression.callee.type !== 'Identifier' ||- !isKeyframeInterpolationFunction(callExpression.callee.name)- ) {+ if (callExpression.callee.type !== 'Identifier') {return undefined;}- const interpolationFunction = callExpression.callee.name;+ const interpolationFunction = getKeyframeInterpolationFunctionForCallee({+ ast,+ callee: callExpression.callee,+ });+ if (interpolationFunction === null) {+ return undefined;+ }const frameArg = callExpression.arguments[0];const inputArg = callExpression.arguments[1];diff --git a/packages/codemods/src/sequence-props/clipboard-param-expression.ts b/packages/codemods/src/sequence-props/clipboard-param-expression.tsindex cf3abbed17..df27852917 100644--- a/packages/codemods/src/sequence-props/clipboard-param-expression.ts+++ b/packages/codemods/src/sequence-props/clipboard-param-expression.ts@@ -14,6 +14,7 @@ export type ClipboardParamRemotionImportName =| 'Easing'| 'interpolate'| 'interpolateColors'+ | 'interpolatePaths'| 'useCurrentFrame';export type ClipboardParamRemotionLocalNames = Partial<@@ -51,7 +52,8 @@ export const ensureClipboardParamRemotionImports = ({localNames[importedName] = ensureNamedImport({ast,importedName,- sourcePath: 'remotion',+ sourcePath:+ importedName === 'interpolatePaths' ? '@remotion/paths' : 'remotion',localName: importedName,});}@@ -164,7 +166,10 @@ const makeOptionsExpression = ({);}- if (param.output === 'perceptual-scale') {+ if (+ param.interpolationFunction === 'interpolate' &&+ param.output === 'perceptual-scale'+ ) {properties.push(b.objectProperty(b.identifier('output'),diff --git a/packages/codemods/src/sequence-props/keyframe-interpolation-function.ts b/packages/codemods/src/sequence-props/keyframe-interpolation-function.tsnew file mode 100644index 0000000000..95bb9ef494--- /dev/null+++ b/packages/codemods/src/sequence-props/keyframe-interpolation-function.ts@@ -0,0 +1,75 @@+import type {File, Identifier} from '@babel/types';+import {+ isKeyframeInterpolationFunction,+ type KeyframeInterpolationFunction,+} from '@remotion/studio-shared/keyframe-interpolation-function';+import * as recast from 'recast';+import {getImportedName} from './imports';++export const getKeyframeInterpolationFunctionForCallee = ({+ ast,+ callee,+}: {+ ast: File;+ callee: Identifier;+}): KeyframeInterpolationFunction | null => {+ let bindings: recast.types.NodePath[] | null = null;+ recast.types.visit(ast, {+ visitIdentifier(path) {+ if (path.node !== callee) {+ return this.traverse(path);+ }++ bindings =+ path.scope?.lookup(callee.name)?.getBindings()[callee.name] ?? null;+ this.abort();+ return false;+ },+ });+ for (const statement of ast.program.body) {+ if (+ statement.type !== 'ImportDeclaration' ||+ statement.importKind === 'type'+ ) {+ continue;+ }++ for (const specifier of statement.specifiers) {+ if (+ specifier.local.name !== callee.name ||+ (specifier.type === 'ImportSpecifier' &&+ specifier.importKind === 'type')+ ) {+ continue;+ }++ if (specifier.type !== 'ImportSpecifier') {+ return null;+ }++ if (+ bindings !== null &&+ !(bindings as recast.types.NodePath[]).some(+ (binding) => binding.node === specifier.local,+ )+ ) {+ return null;+ }++ const importedName = getImportedName(specifier);+ if (+ isKeyframeInterpolationFunction(importedName) &&+ statement.source.value ===+ (importedName === 'interpolatePaths' ? '@remotion/paths' : 'remotion')+ ) {+ return importedName;+ }++ return null;+ }+ }++ return bindings === null && isKeyframeInterpolationFunction(callee.name)+ ? callee.name+ : null;+};diff --git a/packages/codemods/src/update-keyframes.ts b/packages/codemods/src/update-keyframes.tsindex d8886b7645..bcbd6fc5db 100644--- a/packages/codemods/src/update-keyframes.ts+++ b/packages/codemods/src/update-keyframes.ts@@ -19,7 +19,6 @@ import {getKeyframeInterpolationFunctionForSchemaField,getKeyframeOutputTypeForSchemaField,HOLD_KEYFRAME_EASING,- isKeyframeInterpolationFunction,isSchemaFieldHoldOnly,isSchemaFieldKeyframable,LINEAR_KEYFRAME_EASING,@@ -62,6 +61,8 @@ import {findEffectsAttr,} from './sequence-props/can-update-effect-props';import {getAstNodePath} from './sequence-props/get-ast-node-path';+import {ensureNamedImport} from './sequence-props/imports';+import {getKeyframeInterpolationFunctionForCallee} from './sequence-props/keyframe-interpolation-function';import {parseAst} from './sequence-props/parse-ast';import {parseKeyframeEasingExpression} from './sequence-props/parse-keyframe-easing-expression';import {@@ -406,6 +407,7 @@ type InterpolateKeyframe = {};type InterpolateExpression = {+ interpolationFunction: KeyframeInterpolationFunction;callee: ExpressionKind;input: ExpressionKind | SpreadElementKind;extraArgs: (ExpressionKind | SpreadElementKind)[];@@ -428,20 +430,26 @@ const getSupportedCallArgument = (const getInterpolationExpression = (node: Expression,+ ast: File,videoConfigValues: VideoConfigIdentifierValues,): InterpolateExpression | null => {if (node.type === 'TSAsExpression') {return getInterpolationExpression(node.expression as Expression,+ ast,videoConfigValues,);}- if (- node.type !== 'CallExpression' ||- node.callee.type !== 'Identifier' ||- !isKeyframeInterpolationFunction(node.callee.name)- ) {+ if (node.type !== 'CallExpression' || node.callee.type !== 'Identifier') {+ return null;+ }++ const interpolationFunction = getKeyframeInterpolationFunctionForCallee({+ ast,+ callee: node.callee,+ });+ if (interpolationFunction === null) {return null;}@@ -505,6 +513,7 @@ const getInterpolationExpression = (}return {+ interpolationFunction,callee: node.callee as unknown as ExpressionKind,input: frameArg,extraArgs,@@ -1064,6 +1073,7 @@ const validateOutput = (output: InterpolateOutputOption | undefined) => {};const updateKeyframeSettings = ({+ ast,expression,clamping,posterize,@@ -1080,18 +1090,29 @@ const updateKeyframeSettings = ({posterize: number | undefined;output: InterpolateOutputOption | undefined;videoConfigValues: VideoConfigIdentifierValues;+ ast: File;}): ExpressionKind => {validatePosterize(posterize);validateOutput(output);- const existing = getInterpolationExpression(expression, videoConfigValues);+ const existing = getInterpolationExpression(+ expression,+ ast,+ videoConfigValues,+ );if (!existing) {throw new Error('Cannot update keyframe settings on non-keyframed value');}- const calleeName =- existing.callee.type === 'Identifier' ? existing.callee.name : null;- const isColorInterpolation = calleeName === 'interpolateColors';+ const isColorInterpolation =+ existing.interpolationFunction === 'interpolateColors';+ if (+ existing.interpolationFunction === 'interpolatePaths' &&+ (clamping?.left === 'identity' || clamping?.right === 'identity')+ ) {+ throw new Error('Cannot use identity extrapolation for path keyframes');+ }+const extraArgs = [...existing.extraArgs];const existingOptions = extraArgs[0];if (existingOptions && existingOptions.type !== 'ObjectExpression') {@@ -1124,7 +1145,15 @@ const updateKeyframeSettings = ({});}- if (!isColorInterpolation && output !== undefined) {+ if (existing.interpolationFunction === 'interpolatePaths') {+ setOptionsProperty({options, propertyName: 'output', value: null});+ setOptionsProperty({options, propertyName: 'outputType', value: null});+ }++ if (+ existing.interpolationFunction === 'interpolate' &&+ output !== undefined+ ) {setOptionsProperty({options,propertyName: 'output',@@ -1152,6 +1181,7 @@ const updateKeyframeSettings = ({};const updateKeyframeEasing = ({+ ast,expression,segmentIndex,easing,@@ -1161,8 +1191,13 @@ const updateKeyframeEasing = ({segmentIndex: number;easing: KeyframeEasing;videoConfigValues: VideoConfigIdentifierValues;+ ast: File;}): {expression: ExpressionKind; needsEasingImport: boolean} => {- const existing = getInterpolationExpression(expression, videoConfigValues);+ const existing = getInterpolationExpression(+ expression,+ ast,+ videoConfigValues,+ );if (!existing) {throw new Error('Cannot update easing on non-keyframed value');}@@ -1258,6 +1293,7 @@ const noIntroducedIdentifiers: IntroducedKeyframeIdentifiers = {};const addKeyframe = ({+ ast,expression,key,frame,@@ -1271,22 +1307,24 @@ const addKeyframe = ({value: unknown;schema: InteractivitySchema | null;videoConfigValues: VideoConfigIdentifierValues;+ ast: File;}): {expression: ExpressionKind; introduced: IntroducedKeyframeIdentifiers} => {if (!isSchemaFieldKeyframable({schema, key})) {throw new Error(`Cannot add keyframe: "${key}" is not keyframable`);}- const existing = getInterpolationExpression(expression, videoConfigValues);+ const existing = getInterpolationExpression(+ expression,+ ast,+ videoConfigValues,+ );const newOutput = parseValueExpression(value);if (existing) {const defaultEasing = isSchemaFieldHoldOnly({schema, key})? HOLD_KEYFRAME_EASING: LINEAR_KEYFRAME_EASING;- const existingCalleeName =- existing.callee.type === 'Identifier'- ? (existing.callee.name as KeyframeInterpolationFunction)- : 'interpolate';+ const existingCalleeName = existing.interpolationFunction;const schemaCalleeName = getKeyframeInterpolationFunctionForSchemaField({schema,key,@@ -1333,7 +1371,10 @@ const addKeyframe = ({return {expression: createInterpolateExpression({- callee: b.identifier(nextCalleeName),+ callee:+ nextCalleeName === existingCalleeName+ ? existing.callee+ : b.identifier(nextCalleeName),input: existing.input,extraArgs: updatedExtraArgs,keyframes: nextKeyframes,@@ -1405,6 +1446,7 @@ const addKeyframe = ({};const removeKeyframe = ({+ ast,expression,frame,videoConfigValues,@@ -1413,9 +1455,14 @@ const removeKeyframe = ({expression: Expression;frame: number;videoConfigValues: VideoConfigIdentifierValues;+ ast: File;valueWhenLastKeyframeDeleted: unknown | null;}): {expression: ExpressionKind; introduced: IntroducedKeyframeIdentifiers} => {- const existing = getInterpolationExpression(expression, videoConfigValues);+ const existing = getInterpolationExpression(+ expression,+ ast,+ videoConfigValues,+ );if (!existing) {throw new Error('Cannot remove keyframe from non-interpolated expression');}@@ -1463,6 +1510,7 @@ const removeKeyframe = ({};const moveKeyframes = ({+ ast,expression,moves,videoConfigValues,@@ -1473,8 +1521,13 @@ const moveKeyframes = ({toFrame: number;}[];videoConfigValues: VideoConfigIdentifierValues;+ ast: File;}): ExpressionKind => {- const existing = getInterpolationExpression(expression, videoConfigValues);+ const existing = getInterpolationExpression(+ expression,+ ast,+ videoConfigValues,+ );if (!existing) {throw new Error('Cannot move keyframe in non-interpolated expression');}@@ -1550,6 +1603,7 @@ const moveKeyframes = ({};const applyKeyframeOperation = ({+ ast,expression,key,operation,@@ -1561,9 +1615,11 @@ const applyKeyframeOperation = ({operation: KeyframeOperation;schema: InteractivitySchema | null;videoConfigValues: VideoConfigIdentifierValues;+ ast: File;}): {expression: ExpressionKind; introduced: IntroducedKeyframeIdentifiers} => {if (operation.type === 'add') {- return addKeyframe({+ const result = addKeyframe({+ ast,expression,key,frame: operation.frame,@@ -1571,11 +1627,27 @@ const applyKeyframeOperation = ({schema,videoConfigValues,});+ if (+ result.introduced.calleeName === 'interpolatePaths' &&+ result.expression.type === 'CallExpression'+ ) {+ result.expression.callee = b.identifier(+ ensureNamedImport({+ ast,+ importedName: 'interpolatePaths',+ sourcePath: '@remotion/paths',+ localName: 'interpolatePaths',+ }),+ );+ }++ return result;}if (operation.type === 'settings') {return {expression: updateKeyframeSettings({+ ast,expression,clamping: operation.clamping,posterize: operation.posterize,@@ -1597,6 +1669,7 @@ const applyKeyframeOperation = ({}const updated = updateKeyframeEasing({+ ast,expression,segmentIndex: operation.segmentIndex,easing: operation.easing,@@ -1614,6 +1687,7 @@ const applyKeyframeOperation = ({if (operation.type === 'move') {return {expression: moveKeyframes({+ ast,expression,moves: operation.moves,videoConfigValues,@@ -1623,6 +1697,7 @@ const applyKeyframeOperation = ({}return removeKeyframe({+ ast,expression,frame: operation.frame,videoConfigValues,@@ -1759,6 +1834,7 @@ const getInitialValueForMissingProp = ({};const shouldRemovePropAfterKeyframeOperation = ({+ ast,expression,key,operation,@@ -1770,12 +1846,17 @@ const shouldRemovePropAfterKeyframeOperation = ({operation: KeyframeOperation;schema: InteractivitySchema | null;videoConfigValues: VideoConfigIdentifierValues;+ ast: File;}) => {if (operation.type !== 'remove' || !schema) {return false;}- const existing = getInterpolationExpression(expression, videoConfigValues);+ const existing = getInterpolationExpression(+ expression,+ ast,+ videoConfigValues,+ );if (!existing || existing.keyframes.length !== 1) {return false;}@@ -2072,6 +2153,7 @@ export const updateSequenceKeyframesAst = ({});oldValueStrings.push(recast.print(prop.expression).code);const {expression: nextExpression, introduced} = applyKeyframeOperation({+ ast,expression: prop.expression,key: update.key,operation: update.operation,@@ -2081,6 +2163,7 @@ export const updateSequenceKeyframesAst = ({newValueStrings.push(recast.print(nextExpression).code);if (shouldRemovePropAfterKeyframeOperation({+ ast,expression: prop.expression,key: update.key,operation: update.operation,@@ -2093,7 +2176,7 @@ export const updateSequenceKeyframesAst = ({prop.setExpression(nextExpression);}- if (introduced.calleeName) {+ if (introduced.calleeName && introduced.calleeName !== 'interpolatePaths') {requiredImports.add(introduced.calleeName);}@@ -2276,6 +2359,7 @@ export const updateEffectKeyframesAst = ({});oldValueStrings.push(recast.print(prop.expression).code);const {expression: nextExpression, introduced} = applyKeyframeOperation({+ ast,expression: prop.expression,key: update.key,operation: update.operation,@@ -2285,6 +2369,7 @@ export const updateEffectKeyframesAst = ({newValueStrings.push(recast.print(nextExpression).code);if (shouldRemovePropAfterKeyframeOperation({+ ast,expression: prop.expression,key: update.key,operation: update.operation,@@ -2297,7 +2382,7 @@ export const updateEffectKeyframesAst = ({prop.setExpression(nextExpression);}- if (introduced.calleeName) {+ if (introduced.calleeName && introduced.calleeName !== 'interpolatePaths') {requiredImports.add(introduced.calleeName);}diff --git a/packages/core/src/Interactive.tsx b/packages/core/src/Interactive.tsxindex b52b6bd880..3095ad8b86 100644--- a/packages/core/src/Interactive.tsx+++ b/packages/core/src/Interactive.tsx@@ -191,7 +191,7 @@ const interactiveSvgPathElementSchema = {type: 'svg-path',default: undefined,description: 'Path',- keyframable: false,+ keyframable: true,},} as const satisfies InteractivitySchema;diff --git a/packages/core/src/interactivity-schema.ts b/packages/core/src/interactivity-schema.tsindex 01569d9ee0..3a89b32934 100644--- a/packages/core/src/interactivity-schema.ts+++ b/packages/core/src/interactivity-schema.ts@@ -110,7 +110,7 @@ export type SvgPathFieldSchema = {type: 'svg-path';default: string | undefined;description?: string;- keyframable?: false;+ keyframable?: boolean;};export type FontFamilyFieldSchema = {diff --git a/packages/core/src/internals.ts b/packages/core/src/internals.tsindex 1e9a23555b..57a3dc3f6d 100644--- a/packages/core/src/internals.ts+++ b/packages/core/src/internals.ts@@ -113,7 +113,10 @@ import {type InteractivitySchema,type VisibleFieldSchema,} from './interactivity-schema.js';-import {interpolateKeyframedStatus} from './interpolate-keyframed-status.js';+import {+ interpolateKeyframedStatus,+ setInterpolatePaths,+} from './interpolate-keyframed-status.js';import {IsPlayerContextProvider, useIsPlayer} from './is-player.js';import type {LoggingContextValue} from './log-level-context.js';import {LogLevelContext, useLogLevel} from './log-level-context.js';@@ -457,6 +460,7 @@ export const Internals = {createWebGL2ContextError,computeEffectiveSchemaValuesDotNotation,interpolateKeyframedStatus,+ setInterpolatePaths,makeStaticDragOverride,makeKeyframedDragOverride,resolveDragOverrideValue,diff --git a/packages/core/src/interpolate-keyframed-status.ts b/packages/core/src/interpolate-keyframed-status.tsindex 9f0626bb12..1d64efc2ff 100644--- a/packages/core/src/interpolate-keyframed-status.ts+++ b/packages/core/src/interpolate-keyframed-status.ts@@ -1,7 +1,11 @@import {bezier} from './bezier.js';import {Easing} from './easing.js';import {interpolateColors} from './interpolate-colors.js';-import type {EasingFunction} from './interpolate.js';+import type {+ EasingFunction,+ ExtrapolateType,+ InterpolateOptions,+} from './interpolate.js';import {interpolate} from './interpolate.js';import type {CanUpdateSequencePropStatusEasing,@@ -14,6 +18,24 @@ type InterpolateKeyframedStatusResult =| readonly number[]| null;+type PathInterpolator = (+ input: number,+ inputRange: readonly number[],+ outputRange: readonly string[],+ options: Pick<InterpolateOptions, 'easing' | 'posterize'> & {+ extrapolateLeft: Exclude<ExtrapolateType, 'identity'>;+ extrapolateRight: Exclude<ExtrapolateType, 'identity'>;+ },+) => string;++// Studio supplies the path interpolator to avoid a dependency from remotion+// to @remotion/paths, which itself uses remotion's interpolation timing.+let interpolatePaths: PathInterpolator | null = null;++export const setInterpolatePaths = (interpolator: PathInterpolator): void => {+ interpolatePaths = interpolator;+};+const easingToFn = ({easing,forceSpringAllowTail,@@ -62,6 +84,37 @@ export const interpolateKeyframedStatus = ({const inputRange = sortedKeyframes.map((k) => k.frame);const outputs = sortedKeyframes.map((k) => k.value);+ if (interpolationFunction === 'interpolatePaths') {+ if (!outputs.every((v): v is string => typeof v === 'string')) {+ return null;+ }++ if (keyframes.length === 1) {+ return outputs[0];+ }++ if (+ !interpolatePaths ||+ clamping.left === 'identity' ||+ clamping.right === 'identity'+ ) {+ return null;+ }++ try {+ return interpolatePaths(frame, inputRange, outputs, {+ easing: easing.map((e) =>+ easingToFn({easing: e, forceSpringAllowTail}),+ ),+ extrapolateLeft: clamping.left,+ extrapolateRight: clamping.right,+ posterize: status.posterize,+ });+ } catch {+ return null;+ }+ }+if (interpolationFunction === 'interpolateColors') {if (!outputs.every((v) => typeof v === 'string')) {return null;diff --git a/packages/core/src/use-schema.ts b/packages/core/src/use-schema.tsindex 2bb1e0b4d7..29123995bc 100644--- a/packages/core/src/use-schema.ts+++ b/packages/core/src/use-schema.ts@@ -120,7 +120,8 @@ export type CanUpdateSequencePropStatusClamping = {export type CanUpdateSequencePropStatusInterpolationFunction =| 'interpolate'- | 'interpolateColors';+ | 'interpolateColors'+ | 'interpolatePaths';export type CanUpdateSequencePropStatusComputed = {status: 'computed';diff --git a/packages/docs/docs/paths/index.mdx b/packages/docs/docs/paths/index.mdxindex 65dad3403a..a12fabfadf 100644--- a/packages/docs/docs/paths/index.mdx+++ b/packages/docs/docs/paths/index.mdx@@ -1,7 +1,7 @@---image: /generated/articles-docs-paths-index.png-title: "@remotion/paths"-crumb: "SVG"+title: '@remotion/paths'+crumb: 'SVG'---import {TableOfContents} from './table-of-contents';@@ -13,7 +13,7 @@ A package providing utility functions for dealing with SVG paths. This package i- Documentation with examples- ESM import style-This package has no dependencies, meaning this package can be used without Remotion.+These utilities can be used outside a Remotion composition.import Tabs from '@theme/Tabs';import TabItem from '@theme/TabItem';diff --git a/packages/docs/docs/paths/interpolate-path.mdx b/packages/docs/docs/paths/interpolate-path.mdxindex 98919e154e..8c8e605de8 100644--- a/packages/docs/docs/paths/interpolate-path.mdx+++ b/packages/docs/docs/paths/interpolate-path.mdx@@ -1,7 +1,7 @@---image: /generated/articles-docs-paths-interpolate-path.pngtitle: interpolatePath()-crumb: "@remotion/paths"+crumb: '@remotion/paths'---_Part of the [`@remotion/paths`](/docs/paths) package._@@ -16,9 +16,9 @@ Interpolates between two SVG paths. The function takes three arguments:- `secondPath`, which must be a valid SVG path.```tsx twoslash-import { interpolatePath } from "@remotion/paths";+import {interpolatePath} from '@remotion/paths';-const interpolated = interpolatePath(0.5, "M 0 0 L 100 0", "M 100 0 L 0 0");+const interpolated = interpolatePath(0.5, 'M 0 0 L 100 0', 'M 100 0 L 0 0');console.log(interpolated); // "M 50 0 L 50 0"```@@ -32,5 +32,6 @@ Source code stems mostly from [d3-interpolate-path](https://github.com/pbeshai/d## See also+- [`interpolatePaths()`](/docs/paths/interpolate-paths) for multiple keyframes, easing, and posterization- [`@remotion/paths`](/docs/paths)- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/paths/src/interpolate-path/interpolate-path.ts)diff --git a/packages/docs/docs/paths/interpolate-paths.mdx b/packages/docs/docs/paths/interpolate-paths.mdxnew file mode 100644index 0000000000..80c8f6742d--- /dev/null+++ b/packages/docs/docs/paths/interpolate-paths.mdx@@ -0,0 +1,92 @@+---+image: /generated/articles-docs-paths-interpolate-paths.png+title: interpolatePaths()+crumb: '@remotion/paths'+---++# interpolatePaths()<AvailableFrom v="4.0.528" />++Interpolates between SVG paths across multiple keyframes. Uses the same input range, easing, and posterization behavior as [`interpolate()`](/docs/interpolate).++```tsx twoslash title="MorphingPath.tsx"+import {interpolatePaths} from '@remotion/paths';+import {Easing, Interactive, useCurrentFrame} from 'remotion';++export const MorphingPath = () => {+ const frame = useCurrentFrame();++ return (+ <Interactive.Svg width={300} height={300} viewBox="0 0 300 300">+ <Interactive.Path+ d={interpolatePaths(+ frame,+ [0, 30, 60],+ [+ 'M 40 40 L 260 40 L 150 260 Z',+ 'M 40 150 L 150 40 L 260 150 Z',+ 'M 40 260 L 150 40 L 260 260 Z',+ ],+ {+ easing: [Easing.bezier(0.42, 0, 0.58, 1), Easing.linear],+ extrapolateLeft: 'clamp',+ extrapolateRight: 'clamp',+ },+ )}+ fill="#0b84f3"+ />+ </Interactive.Svg>+ );+};+```++## Arguments++### input++The number to interpolate, usually the current [frame](/docs/terminology#frame).++### inputRange++A non-empty array of finite numbers in strictly increasing order. Each value corresponds to a path in `outputRange`.++### outputRange++An array of valid SVG path strings with the same length as `inputRange`. Paths may have different numbers of points. A single keyframe returns its path for every input.++When spring tails blend more than two paths at once, their subpaths must have matching move and close commands after normalization.++### options?++#### easing?++An easing function, or an array with one easing function per segment (`inputRange.length - 1`). Defaults to linear easing. See [`Easing`](/docs/easing), including [`Easing.spring()`](/docs/easing#spring).++#### extrapolateLeft?++Controls inputs before the first keyframe: `'extend'`, `'clamp'`, or `'wrap'`. Defaults to `'extend'`. See [extrapolation](/docs/interpolate#extrapolateleft).++#### extrapolateRight?++Controls inputs after the last keyframe: `'extend'`, `'clamp'`, or `'wrap'`. Defaults to `'extend'`. Spring easing can continue beyond its segment when `allowTail` is enabled, as with [`interpolate()`](/docs/interpolate).++#### posterize?++Rounds the input down to a multiple of this positive number before interpolation. For example, `posterize: 3` updates the animation every three frames. Defaults to no posterization.++## Return value++An SVG path string suitable for a `<path>` element's `d` attribute.++## Editing in Studio++Use `interpolatePaths()` for the `d` prop of [`<Interactive.Path>`](/docs/interactive). In Studio, you can add and move path keyframes, adjust their easing, and drag anchors and Bézier handles to update the path at the current frame.++## Compatibility++<CompatibilityTable chrome firefox safari nodejs bun serverlessFunctions clientSideRendering serverSideRendering player studio />++## See also++- [`interpolatePath()`](/docs/paths/interpolate-path)+- [`interpolate()`](/docs/interpolate)+- [`@remotion/paths`](/docs/paths)diff --git a/packages/docs/docs/paths/table-of-contents.tsx b/packages/docs/docs/paths/table-of-contents.tsxindex 714658d9e9..eb096d3fbe 100644--- a/packages/docs/docs/paths/table-of-contents.tsx+++ b/packages/docs/docs/paths/table-of-contents.tsx@@ -37,15 +37,17 @@ export const TableOfContents: React.FC = () => {<strong>interpolatePath()</strong><div>Interpolates between two SVG paths</div></TOCItem>+ <TOCItem link="/docs/paths/interpolate-paths">+ <strong>interpolatePaths()</strong>+ <div>Interpolate SVG paths across multiple keyframes</div>+ </TOCItem><TOCItem link="/docs/paths/evolve-path"><strong>evolvePath()</strong><div>Animate an SVG path</div></TOCItem><TOCItem link="/docs/paths/center-path"><strong>centerPath()</strong>- <div>- Translates an SVG path to center it around a target point- </div>+ <div>Translates an SVG path to center it around a target point</div></TOCItem><TOCItem link="/docs/paths/translate-path"><strong>translatePath()</strong>diff --git a/packages/docs/sidebars.ts b/packages/docs/sidebars.tsindex c1213441ed..cfec0d5af5 100644--- a/packages/docs/sidebars.ts+++ b/packages/docs/sidebars.ts@@ -601,6 +601,7 @@ const sidebars: SidebarsConfig = {'paths/reverse-path','paths/normalize-path','paths/interpolate-path',+ 'paths/interpolate-paths','paths/evolve-path','paths/reset-path','paths/center-path',diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.tsindex 614bf4d8af..f6ec965a18 100644--- a/packages/docs/src/data/articles.ts+++ b/packages/docs/src/data/articles.ts@@ -5778,6 +5778,15 @@ export const articles = [noAi: false,slug: 'paths/interpolate-path',},+ {+ id: 'paths/interpolate-paths',+ title: 'interpolatePaths()',+ relativePath: 'docs/paths/interpolate-paths.mdx',+ compId: 'articles-docs-paths-interpolate-paths',+ crumb: '@remotion/paths',+ noAi: false,+ slug: 'paths/interpolate-paths',+ },{id: 'paths/normalize-path',title: 'normalizePath()',diff --git a/packages/docs/static/generated/articles-docs-paths-interpolate-paths.png b/packages/docs/static/generated/articles-docs-paths-interpolate-paths.pngnew file mode 100644index 0000000000..c09f359be5Binary files /dev/null and b/packages/docs/static/generated/articles-docs-paths-interpolate-paths.png differdiff --git a/packages/paths/package.json b/packages/paths/package.jsonindex 5486271024..a487a5a8f5 100644--- a/packages/paths/package.json+++ b/packages/paths/package.json@@ -30,6 +30,9 @@"eslint": "catalog:","@typescript/native-preview": "catalog:"},+ "dependencies": {+ "remotion": "workspace:*"+ },"exports": {"./package.json": "./package.json",".": {diff --git a/packages/paths/src/index.ts b/packages/paths/src/index.tsindex 315a0b53cb..23eb956e2f 100644--- a/packages/paths/src/index.ts+++ b/packages/paths/src/index.ts@@ -20,6 +20,10 @@ export {ReducedInstruction,} from './helpers/types';export {interpolatePath} from './interpolate-path/interpolate-path';+export {+ interpolatePaths,+ type InterpolatePathsOptions,+} from './interpolate-paths';export {normalizePath} from './normalize-path';export {parsePath} from './parse-path';export {reduceInstructions} from './reduce-instructions';diff --git a/packages/paths/src/interpolate-paths.ts b/packages/paths/src/interpolate-paths.tsnew file mode 100644index 0000000000..4aff940f42--- /dev/null+++ b/packages/paths/src/interpolate-paths.ts@@ -0,0 +1,184 @@+import {+ interpolate,+ type ExtrapolateType,+ type InterpolateOptions,+} from 'remotion/no-react';+import {getEndPosition} from './get-end-position';+import type {ReducedInstruction} from './helpers/types';+import {convertToSameInstructionType} from './interpolate-path/convert-to-same-instruction-type';+import {extendInstruction} from './interpolate-path/extend-command';+import {interpolatePath} from './interpolate-path/interpolate-path';+import {parsePath} from './parse-path';+import {reduceInstructions} from './reduce-instructions';+import {serializeInstructions} from './serialize-instructions';++export type InterpolatePathsOptions = Pick<+ InterpolateOptions,+ 'easing' | 'posterize'+> & {+ extrapolateLeft?: Exclude<ExtrapolateType, 'identity'>;+ extrapolateRight?: Exclude<ExtrapolateType, 'identity'>;+};++/*+ * @description Interpolates between multiple SVG paths, with keyframes, easing, and extrapolation.+ * @see [Documentation](https://www.remotion.dev/docs/paths/interpolate-paths)+ */+export const interpolatePaths = (+ input: number,+ inputRange: readonly number[],+ outputRange: readonly string[],+ options?: InterpolatePathsOptions,+): string => {+ if (!Array.isArray(outputRange)) {+ throw new TypeError('outputRange must be an array of SVG path strings');+ }++ for (const path of outputRange) {+ if (typeof path !== 'string') {+ throw new TypeError('outputRange must contain only SVG path strings');+ }+ }++ for (const side of ['extrapolateLeft', 'extrapolateRight'] as const) {+ const extrapolation = options?.[side];+ if (+ extrapolation !== undefined &&+ extrapolation !== 'extend' &&+ extrapolation !== 'clamp' &&+ extrapolation !== 'wrap'+ ) {+ throw new TypeError(+ `${side} must be "extend", "clamp", or "wrap" for interpolatePaths()`,+ );+ }+ }++ // Interpolating a basis vector for each path preserves segment selection,+ // easing overshoot, and the contributions of earlier spring segments.+ const weights = interpolate(+ input,+ inputRange,+ outputRange.map((_, pathIndex) =>+ outputRange.map((__, index) => (index === pathIndex ? 1 : 0)),+ ),+ options,+ );+ const exactPathIndex = weights.findIndex(+ (weight, index) =>+ weight === 1 &&+ weights.every((otherWeight, otherIndex) =>+ otherIndex === index ? true : otherWeight === 0,+ ),+ );+ if (exactPathIndex !== -1) {+ return outputRange[exactPathIndex];+ }++ const contributingPaths = outputRange+ .map((path, index) => ({path, weight: weights[index]}))+ .filter(({weight}) => weight !== 0);+ if (contributingPaths.length === 2) {+ return interpolatePath(+ contributingPaths[1].weight,+ contributingPaths[0].path,+ contributingPaths[1].path,+ );+ }++ const paths = contributingPaths.map(({path}) => {+ const commands = reduceInstructions(parsePath(path));+ if (commands.length === 0) {+ throw new TypeError(`SVG Path "${path}" is not valid`);+ }++ return commands;+ });+ const closed = paths.every(+ (commands) => commands[commands.length - 1].type === 'Z',+ );+ const openPaths = paths.map((commands) =>+ commands[commands.length - 1].type === 'Z'+ ? commands.slice(0, -1)+ : commands,+ );+ const reference = openPaths.reduce((longest, commands) =>+ commands.length > longest.length ? commands : longest,+ );+ const extendedPaths = openPaths.map((commands) =>+ commands.length < reference.length+ ? extendInstruction(commands, reference)+ : commands,+ );+ const result: ReducedInstruction[] = reference.map((_, instructionIndex) => {+ const commands = extendedPaths.map((path) => path[instructionIndex]);+ if (commands.some((command) => command.type === 'Z')) {+ if (commands.every((command) => command.type === 'Z')) {+ return {type: 'Z'};+ }++ throw new TypeError(+ 'Cannot interpolate SVG paths with different subpath structures',+ );+ }++ // A common cubic command preserves every curve while allowing paths with+ // different instruction types to share the same coordinate interpolation.+ const target =+ commands.find((command) => command.type === 'C') ?? commands[0];+ const normalized = commands.map((command, pathIndex) => {+ if ((command.type === 'M') !== (target.type === 'M')) {+ throw new TypeError(+ 'Cannot interpolate SVG paths with different subpath structures',+ );+ }++ return convertToSameInstructionType(+ command,+ target,+ getEndPosition(extendedPaths[pathIndex].slice(0, instructionIndex)),+ );+ });+ const coordinates = normalized.map((command) => {+ if (command.type === 'Z') {+ return [];+ }++ return command.type === 'C'+ ? [+ command.x,+ command.y,+ command.cp1x,+ command.cp1y,+ command.cp2x,+ command.cp2y,+ ]+ : [command.x, command.y];+ });+ const values = coordinates[0].map((__, coordinateIndex) =>+ coordinates.reduce(+ (value, path, pathIndex) =>+ value + path[coordinateIndex] * contributingPaths[pathIndex].weight,+ 0,+ ),+ );+ if (target.type === 'C') {+ return {+ type: 'C',+ x: values[0],+ y: values[1],+ cp1x: values[2],+ cp1y: values[3],+ cp2x: values[4],+ cp2y: values[5],+ };+ }++ return {type: target.type, x: values[0], y: values[1]};+ });+ if (closed) {+ result.push({type: 'Z'});+ }++ return serializeInstructions(result);+};diff --git a/packages/studio-server/src/codemods/effect-param-expression.ts b/packages/studio-server/src/codemods/effect-param-expression.tsindex 7998012dbd..ee1120a7f0 100644--- a/packages/studio-server/src/codemods/effect-param-expression.ts+++ b/packages/studio-server/src/codemods/effect-param-expression.ts@@ -15,6 +15,7 @@ export type RemotionImportName =| 'Easing'| 'interpolate'| 'interpolateColors'+ | 'interpolatePaths'| 'useCurrentFrame';export type RemotionLocalNames = Partial<Record<RemotionImportName, string>>;@@ -67,7 +68,8 @@ export const ensureRemotionImportLocalNames = ({localNames[importedName] = ensureNamedImport({ast,importedName,- sourcePath: 'remotion',+ sourcePath:+ importedName === 'interpolatePaths' ? '@remotion/paths' : 'remotion',localName: importedName,});}@@ -181,7 +183,10 @@ const makeKeyframedOptions = ({);}- if (param.output === 'perceptual-scale') {+ if (+ param.interpolationFunction === 'interpolate' &&+ param.output === 'perceptual-scale'+ ) {properties.push(b.objectProperty(b.identifier('output'),diff --git a/packages/studio-server/src/preview-server/routes/can-update-sequence-props.ts b/packages/studio-server/src/preview-server/routes/can-update-sequence-props.tsindex 85dc305de0..6301554508 100644--- a/packages/studio-server/src/preview-server/routes/can-update-sequence-props.ts+++ b/packages/studio-server/src/preview-server/routes/can-update-sequence-props.ts@@ -20,10 +20,7 @@ import {} from '@remotion/codemods';import {RenderInternals} from '@remotion/renderer';import type {SubscribeToSequencePropsResponse} from '@remotion/studio-shared';-import {- isKeyframeInterpolationFunction,- LINEAR_KEYFRAME_EASING,-} from '@remotion/studio-shared';+import {LINEAR_KEYFRAME_EASING} from '@remotion/studio-shared';import * as recast from 'recast';import type {CanUpdateSequencePropsResponseTrue,@@ -443,7 +440,11 @@ const getInterpolationMetadata = (}const extrapolateType = getExtrapolateType(value);- if (!extrapolateType) {+ if (+ !extrapolateType ||+ (interpolationFunction === 'interpolatePaths' &&+ extrapolateType === 'identity')+ ) {return null;}@@ -469,7 +470,7 @@ const getInterpolationMetadata = (}if (key === 'output') {- if (interpolationFunction === 'interpolateColors') {+ if (interpolationFunction !== 'interpolate') {return null;}@@ -484,7 +485,7 @@ const getInterpolationMetadata = (if (key === 'outputType') {if (- interpolationFunction === 'interpolateColors' ||+ interpolationFunction !== 'interpolate' ||getInterpolateOutputType(value) === null) {return null;@@ -559,14 +560,18 @@ const getInterpolationKeyframes = (}const callExpression = node as CallExpression;- if (- callExpression.callee.type !== 'Identifier' ||- !isKeyframeInterpolationFunction(callExpression.callee.name)- ) {+ if (callExpression.callee.type !== 'Identifier') {return undefined;}- const interpolationFunction = callExpression.callee.name;+ const interpolationFunction =+ CodemodsInternals.getKeyframeInterpolationFunctionForCallee({+ ast,+ callee: callExpression.callee,+ });+ if (interpolationFunction === null) {+ return undefined;+ }const frameArg = callExpression.arguments[0];const inputArg = callExpression.arguments[1];diff --git a/packages/studio-shared/src/keyframe-clipboard-data.ts b/packages/studio-shared/src/keyframe-clipboard-data.tsindex 56fd187820..ef4c447a0f 100644--- a/packages/studio-shared/src/keyframe-clipboard-data.ts+++ b/packages/studio-shared/src/keyframe-clipboard-data.ts@@ -21,7 +21,7 @@ const KEYFRAME_CLIPBOARD_FIELD_TYPE_SUPPORT = {'rotation-css': true,'rotation-degrees': true,scale: true,- 'svg-path': false,+ 'svg-path': true,'text-content': false,'transform-origin': true,translate: true,diff --git a/packages/studio-shared/src/keyframe-interpolation-function.ts b/packages/studio-shared/src/keyframe-interpolation-function.tsindex 3e4317f114..807c1b8776 100644--- a/packages/studio-shared/src/keyframe-interpolation-function.ts+++ b/packages/studio-shared/src/keyframe-interpolation-function.ts@@ -7,6 +7,7 @@ import type {export const keyframeInterpolationFunctions = ['interpolate','interpolateColors',+ 'interpolatePaths',] as const;export type KeyframeInterpolationFunction =@@ -28,7 +29,7 @@ const KEYFRAME_FIELD_TYPE_SUPPORT = {'rotation-css': true,'rotation-degrees': true,scale: true,- 'svg-path': false,+ 'svg-path': true,'text-content': false,'transform-origin': true,translate: true,@@ -54,7 +55,7 @@ const KEYFRAME_FIELD_TYPE_INTERPOLATION = {'rotation-css': 'interpolate','rotation-degrees': 'infer',scale: 'interpolate',- 'svg-path': 'unsupported',+ 'svg-path': 'interpolatePaths','text-content': 'unsupported','transform-origin': 'interpolate',translate: 'interpolate',@@ -91,6 +92,7 @@ const KEYFRAME_FIELD_TYPE_OUTPUT_TYPE = {const KEYFRAME_INTERPOLATION_EASING_SUPPORT = {interpolate: true,interpolateColors: true,+ interpolatePaths: true,} as const satisfies Record<KeyframeInterpolationFunction, boolean>;export const isKeyframeInterpolationFunction = (diff --git a/packages/studio/src/Studio.tsx b/packages/studio/src/Studio.tsxindex 524390589f..949fe61da5 100644--- a/packages/studio/src/Studio.tsx+++ b/packages/studio/src/Studio.tsx@@ -1,3 +1,4 @@+import {interpolatePaths} from '@remotion/paths';import React, {useLayoutEffect} from 'react';import {createPortal} from 'react-dom';import {Internals} from 'remotion';@@ -10,6 +11,8 @@ import {injectCSS} from './helpers/inject-css';import {ResolveCompositionConfigInStudio} from './ResolveCompositionConfigInStudio';import {CompositionListProvider} from './state/composition-list';+Internals.setInterpolatePaths(interpolatePaths);+declare global {interface Window {remotion_experimentalKeepAudioContextAlive: boolean | undefined;diff --git a/packages/studio/src/components/InspectorPanel/KeyframeSettings.tsx b/packages/studio/src/components/InspectorPanel/KeyframeSettings.tsxindex 67d362da9e..3934c46336 100644--- a/packages/studio/src/components/InspectorPanel/KeyframeSettings.tsx+++ b/packages/studio/src/components/InspectorPanel/KeyframeSettings.tsx@@ -42,19 +42,22 @@ const labelForExtrapolate = (value: ExtrapolateType) =>const getExtrapolateValues = (onSelect: (value: ExtrapolateType) => void,disabled: boolean,+ allowIdentity: boolean,): ComboboxValue[] => {- return extrapolateOptions.map((value) => ({- type: 'item',- id: value,- keyHint: null,- label: labelForExtrapolate(value),- leftItem: null,- disabled,- onClick: () => onSelect(value),- quickSwitcherLabel: null,- subMenu: null,- value,- }));+ return extrapolateOptions+ .filter((value) => allowIdentity || value !== 'identity')+ .map((value) => ({+ type: 'item',+ id: value,+ keyHint: null,+ label: labelForExtrapolate(value),+ leftItem: null,+ disabled,+ onClick: () => onSelect(value),+ quickSwitcherLabel: null,+ subMenu: null,+ value,+ }));};const outputOptions = [@@ -91,8 +94,10 @@ export const KeyframeSettings: React.FC<{const {previewServerState} = useContext(StudioServerConnectionCtx);const {propStatus} = update;const [posterize, setPosterize] = useState(propStatus.posterize ?? 0);- const canEditInterpolationSettings =- propStatus.interpolationFunction === 'interpolate';+ const canEditExtrapolation =+ propStatus.interpolationFunction === 'interpolate' ||+ propStatus.interpolationFunction === 'interpolatePaths';+ const canEditOutput = propStatus.interpolationFunction === 'interpolate';const disabled = previewServerState.type !== 'connected';useEffect(() => {@@ -146,13 +151,14 @@ export const KeyframeSettings: React.FC<{}) => {save({type: 'settings',- clamping: canEditInterpolationSettings ? {left, right} : undefined,- output: canEditInterpolationSettings ? output : undefined,+ clamping: canEditExtrapolation ? {left, right} : undefined,+ output: canEditOutput ? output : undefined,posterize: nextPosterize <= 0 ? undefined : nextPosterize,});},[- canEditInterpolationSettings,+ canEditExtrapolation,+ canEditOutput,propStatus.clamping.left,propStatus.clamping.right,propStatus.output,@@ -174,12 +180,12 @@ export const KeyframeSettings: React.FC<{[saveSettings],);const leftValues = useMemo(- () => getExtrapolateValues(onSelectLeft, disabled),- [disabled, onSelectLeft],+ () => getExtrapolateValues(onSelectLeft, disabled, canEditOutput),+ [canEditOutput, disabled, onSelectLeft],);const rightValues = useMemo(- () => getExtrapolateValues(onSelectRight, disabled),- [disabled, onSelectRight],+ () => getExtrapolateValues(onSelectRight, disabled, canEditOutput),+ [canEditOutput, disabled, onSelectRight],);const outputValues = useMemo(() => getOutputValues(onSelectOutput, disabled),@@ -208,7 +214,7 @@ export const KeyframeSettings: React.FC<{sectionId="keyframe-settings"><div style={keyframeSettingsContainer}>- {canEditInterpolationSettings ? (+ {canEditExtrapolation ? (<><InspectorDetailRow label="Extrapolate left"><Combobox@@ -228,17 +234,19 @@ export const KeyframeSettings: React.FC<{size="small"/></InspectorDetailRow>- <InspectorDetailRow label="Output">- <Combobox- values={outputValues}- selectedId={propStatus.output ?? 'linear'}- title="Output"- style={comboStyle}- size="small"- />- </InspectorDetailRow></>) : null}+ {canEditOutput ? (+ <InspectorDetailRow label="Output">+ <Combobox+ values={outputValues}+ selectedId={propStatus.output ?? 'linear'}+ title="Output"+ style={comboStyle}+ size="small"+ />+ </InspectorDetailRow>+ ) : null}<InspectorDetailRow label="Posterize"><InputDraggertype="number"diff --git a/packages/studio/src/components/SelectedOutlineOverlay.tsx b/packages/studio/src/components/SelectedOutlineOverlay.tsxindex 7d35ac2317..a8007e3c3a 100644--- a/packages/studio/src/components/SelectedOutlineOverlay.tsx+++ b/packages/studio/src/components/SelectedOutlineOverlay.tsx@@ -497,12 +497,25 @@ const calculateOutlineTargets = ({previewInteractive &&controls !== null &&pathFieldSchema?.type === 'svg-path' &&- pathPropStatus?.status === 'static' &&- typeof pathPropStatus.codeValue === 'string'+ ((pathPropStatus?.status === 'static' &&+ typeof pathPropStatus.codeValue === 'string') ||+ (pathPropStatus?.status === 'keyframed' &&+ pathFieldSchema.keyframable !== false &&+ pathPropStatus.interpolationFunction === 'interpolatePaths'))? {clientId: connectedClientId,nodePath,+ propStatus: pathPropStatus,schema: controls.schema,+ sourceFrame: {+ displayFrame: targetTimelinePosition,+ keyframeDisplayOffset: getKeyframeDisplayOffset({+ propStatus: pathPropStatus,+ keyframeDisplayOffset,+ keyframePlaybackRate,+ }),+ keyframePlaybackRate,+ },}: null,canCrop: previewInteractive && controls !== null && cropFields !== null,diff --git a/packages/studio/src/components/SelectedOutlinePathPoints.tsx b/packages/studio/src/components/SelectedOutlinePathPoints.tsxindex fc341e0798..94b0f0e263 100644--- a/packages/studio/src/components/SelectedOutlinePathPoints.tsx+++ b/packages/studio/src/components/SelectedOutlinePathPoints.tsx@@ -14,6 +14,8 @@ import {import {showNotification} from './Notifications/NotificationCenter';import type {SelectedOutline} from './selected-outline-geometry';import type {SelectedOutlinePathDragTarget} from './selected-outline-types';+import {callAddSequenceKeyframe} from './Timeline/call-add-keyframe';+import {resolveKeyframeSourceFrame} from './Timeline/get-timeline-keyframes';import {saveSequenceProps} from './Timeline/save-sequence-prop';type PathPointRole = 'end' | 'cp1' | 'cp2' | 'cp' | 'reflected-cp';@@ -302,7 +304,24 @@ export const SelectedOutlinePathPoints: React.FC<{const startX = event.clientX;const startY = event.clientY;const originalD = serializeInstructions(instructions);+ const sourceFrame = resolveKeyframeSourceFrame(+ pathDrag.sourceFrame,+ pathDrag.propStatus,+ );let lastD = originalD;+ const updatePathOverride = (value: string) => {+ setDragOverrides(+ pathDrag.nodePath,+ 'd',+ pathDrag.propStatus.status === 'keyframed'+ ? Internals.makeKeyframedDragOverride({+ status: pathDrag.propStatus,+ frame: sourceFrame,+ value,+ })+ : Internals.makeStaticDragOverride(value),+ );+ };startCapturedPointerSession({event,@@ -318,11 +337,7 @@ export const SelectedOutlinePathPoints: React.FC<{if (localDeltaX === 0 && localDeltaY === 0) {if (lastD !== originalD) {lastD = originalD;- setDragOverrides(- pathDrag.nodePath,- 'd',- Internals.makeStaticDragOverride(originalD),- );+ updatePathOverride(originalD);}return;@@ -452,11 +467,7 @@ export const SelectedOutlinePathPoints: React.FC<{}lastD = nextD;- setDragOverrides(- pathDrag.nodePath,- 'd',- Internals.makeStaticDragOverride(nextD),- );+ updatePathOverride(nextD);},onEnd: (reason, endEvent) => {onDraggingChange(false);@@ -465,24 +476,38 @@ export const SelectedOutlinePathPoints: React.FC<{return;}- saveSequenceProps({- changes: [- {- fileName: pathDrag.nodePath.absolutePath,- nodePath: pathDrag.nodePath,- fieldKey: 'd',- value: lastD,- defaultValue: null,- schema: pathDrag.schema,- },- ],- addedKeyframes: null,- movedKeyframes: null,- setPropStatuses,- clientId: pathDrag.clientId,- undoLabel: 'Edit path point',- redoLabel: 'Edit path point back',- })+ const promise =+ pathDrag.propStatus.status === 'keyframed'+ ? callAddSequenceKeyframe({+ fileName: pathDrag.nodePath.absolutePath,+ nodePath: pathDrag.nodePath,+ fieldKey: 'd',+ sourceFrame,+ value: lastD,+ schema: pathDrag.schema,+ setPropStatuses,+ clientId: pathDrag.clientId,+ })+ : saveSequenceProps({+ changes: [+ {+ fileName: pathDrag.nodePath.absolutePath,+ nodePath: pathDrag.nodePath,+ fieldKey: 'd',+ value: lastD,+ defaultValue: null,+ schema: pathDrag.schema,+ },+ ],+ addedKeyframes: null,+ movedKeyframes: null,+ setPropStatuses,+ clientId: pathDrag.clientId,+ undoLabel: 'Edit path point',+ redoLabel: 'Edit path point back',+ });++ promise.catch((error) => {showNotification(`Could not save path: ${error instanceof Error ? error.message : String(error)}`,diff --git a/packages/studio/src/components/SelectedOutlineRenderer.tsx b/packages/studio/src/components/SelectedOutlineRenderer.tsxindex e9f83fcd54..7da2061625 100644--- a/packages/studio/src/components/SelectedOutlineRenderer.tsx+++ b/packages/studio/src/components/SelectedOutlineRenderer.tsx@@ -266,7 +266,7 @@ const SelectedOutlineRendererUnmemoized: React.FC<{))}{outlinesForRendering.map((outline) => {const target = targetsByKey.get(outline.key);- const pathDrag = target?.selected+ const pathDrag = target?.containsSelection? (getLatestOutlineTargetByKey(outline.key)?.pathDrag ?? null): null;return outline.path !== null && pathDrag !== null ? (diff --git a/packages/studio/src/components/selected-outline-types.ts b/packages/studio/src/components/selected-outline-types.tsindex fb05c765f2..8b14f3fadf 100644--- a/packages/studio/src/components/selected-outline-types.ts+++ b/packages/studio/src/components/selected-outline-types.ts@@ -44,7 +44,11 @@ export type SelectedOutlineTarget = SelectedOutlineLayoutTarget & {export type SelectedOutlinePathDragTarget = {readonly clientId: string;readonly nodePath: SequencePropsSubscriptionKey;+ readonly propStatus:+ | CanUpdateSequencePropStatusStatic+ | CanUpdateSequencePropStatusKeyframed;readonly schema: InteractivitySchema;+ readonly sourceFrame: KeyframeSourceFrame;};export const cropFieldKeys = {diff --git a/packages/svg-3d-engine/bundle.ts b/packages/svg-3d-engine/bundle.tsindex c6efbad60c..3fdb253dd6 100644--- a/packages/svg-3d-engine/bundle.ts+++ b/packages/svg-3d-engine/bundle.ts@@ -7,7 +7,7 @@ if (process.env.NODE_ENV !== 'production') {const output = await build({entrypoints: ['src/index.ts'],naming: '[name].mjs',- external: ['remotion', 'remotion/no-react'],+ external: ['@remotion/paths', 'remotion', 'remotion/no-react'],});if (!output.success) {