Skip to content

🎥 Make videos programmatically with React

`@remotion/studio`: Batch delete keyframes (#7977)

Jonny Burger61ce94ac23de
diff --git a/packages/studio-server/src/preview-server/api-routes.ts b/packages/studio-server/src/preview-server/api-routes.ts
index 6e8bf8dbee..60b2f5c52e 100644
--- a/packages/studio-server/src/preview-server/api-routes.ts
+++ b/packages/studio-server/src/preview-server/api-routes.ts
@@ -9,9 +9,8 @@ import {applyVisualControlHandler} from './routes/apply-visual-control-change';
import {handleCancelRender} from './routes/cancel-render';
import {compositionComponentInfoHandler} from './routes/composition-component-info';
import {deleteEffectHandler} from './routes/delete-effect';
-import {deleteEffectKeyframeHandler} from './routes/delete-effect-keyframe';
import {deleteJsxNodeHandler} from './routes/delete-jsx-node';
-import {deleteSequenceKeyframeHandler} from './routes/delete-sequence-keyframe';
+import {deleteKeyframesHandler} from './routes/delete-keyframes';
import {deleteStaticFileHandler} from './routes/delete-static-file';
import {duplicateJsxNodeHandler} from './routes/duplicate-jsx-node';
import {insertJsxElementHandler} from './routes/insert-jsx-element';
@@ -64,9 +63,8 @@ export const allApiRoutes: {
'/api/save-effect-props': saveEffectPropsHandler,
'/api/add-effect': addEffectHandler,
'/api/reorder-effect': reorderEffectHandler,
- '/api/delete-sequence-keyframe': deleteSequenceKeyframeHandler,
+ '/api/delete-keyframes': deleteKeyframesHandler,
'/api/add-sequence-keyframe': addSequenceKeyframeHandler,
- '/api/delete-effect-keyframe': deleteEffectKeyframeHandler,
'/api/add-effect-keyframe': addEffectKeyframeHandler,
'/api/delete-effect': deleteEffectHandler,
'/api/delete-jsx-node': deleteJsxNodeHandler,
diff --git a/packages/studio-server/src/preview-server/routes/delete-effect-keyframe.ts b/packages/studio-server/src/preview-server/routes/delete-effect-keyframe.ts
deleted file mode 100644
index e7b0ade59e..0000000000
--- a/packages/studio-server/src/preview-server/routes/delete-effect-keyframe.ts
+++ /dev/null
@@ -1,130 +0,0 @@
-import {readFileSync} from 'node:fs';
-import {RenderInternals} from '@remotion/renderer';
-import type {
- DeleteEffectKeyframeRequest,
- DeleteEffectKeyframeResponse,
-} from '@remotion/studio-shared';
-import {getAllSchemaKeys} from '@remotion/studio-shared';
-import {parseAst} from '../../codemods/parse-ast';
-import {updateEffectKeyframes} from '../../codemods/update-keyframes/update-keyframes';
-import {writeFileAndNotifyFileWatchers} from '../../file-watcher';
-import {resolveFileInsideProject} from '../../helpers/resolve-file-inside-project';
-import type {ApiHandler} from '../api-types';
-import {
- printUndoHint,
- pushToUndoStack,
- suppressUndoStackInvalidation,
-} from '../undo-stack';
-import {suppressBundlerUpdateForFile} from '../watch-ignore-next-change';
-import {computeEffectPropStatus} from './can-update-effect-props';
-import {findJsxElementAtNodePath} from './can-update-sequence-props';
-import {logEffectUpdate} from './log-updates/log-effect-update';
-import {withSavePropsLock} from './save-props-mutex';
-
-export const deleteEffectKeyframeHandler: ApiHandler<
- DeleteEffectKeyframeRequest,
- DeleteEffectKeyframeResponse
-> = ({
- input: {
- fileName,
- sequenceNodePath,
- effectIndex,
- key,
- frame,
- schema,
- clientId,
- },
- remotionRoot,
- logLevel,
-}) =>
- withSavePropsLock(async () => {
- RenderInternals.Log.trace(
- {indent: false, logLevel},
- `[delete-effect-keyframe] Received request for fileName="${fileName}" effectIndex=${effectIndex} key="${key}" frame=${frame}`,
- );
- const {absolutePath, fileRelativeToRoot} = resolveFileInsideProject({
- remotionRoot,
- fileName,
- action: 'modify',
- });
-
- const fileContents = readFileSync(absolutePath, 'utf-8');
-
- const {
- output,
- oldValueStrings,
- newValueStrings,
- formatted,
- logLine,
- effectCallee,
- } = await updateEffectKeyframes({
- input: fileContents,
- sequenceNodePath: sequenceNodePath.nodePath,
- effectIndex,
- updates: [
- {
- key,
- operation: {
- type: 'remove',
- frame,
- },
- },
- ],
- });
-
- const oldValueString = oldValueStrings[0];
- const newValueString = newValueStrings[0];
-
- const undoPropChange = `${key} keyframe restored at frame ${frame}`;
- const redoPropChange = `${key} keyframe deleted at frame ${frame}`;
-
- pushToUndoStack({
- filePath: absolutePath,
- oldContents: fileContents,
- newContents: null,
- logLevel,
- remotionRoot,
- logLine,
- description: {
- undoMessage: `↩️ ${undoPropChange}`,
- redoMessage: `↪️ ${redoPropChange}`,
- },
- entryType: 'effect-props',
- suppressHmrOnFileRestore: true,
- });
- suppressUndoStackInvalidation(absolutePath);
- suppressBundlerUpdateForFile(absolutePath);
- writeFileAndNotifyFileWatchers(absolutePath, output, clientId);
-
- logEffectUpdate({
- fileRelativeToRoot,
- line: logLine,
- effectName: effectCallee,
- propKey: key,
- oldValueString,
- newValueString,
- defaultValueString: null,
- formatted,
- logLevel,
- removedProps: [],
- addedProps: [],
- });
-
- printUndoHint(logLevel);
-
- const ast = parseAst(readFileSync(absolutePath, 'utf-8'));
- const jsx = findJsxElementAtNodePath(ast, sequenceNodePath.nodePath);
- if (!jsx) {
- return {
- canUpdate: false,
- effectIndex,
- reason: 'not-found',
- };
- }
-
- return computeEffectPropStatus({
- jsx,
- effectIndex,
- keys: getAllSchemaKeys(schema),
- });
- });
diff --git a/packages/studio-server/src/preview-server/routes/delete-keyframes.ts b/packages/studio-server/src/preview-server/routes/delete-keyframes.ts
new file mode 100644
index 0000000000..6a0e7ff281
--- /dev/null
+++ b/packages/studio-server/src/preview-server/routes/delete-keyframes.ts
@@ -0,0 +1,401 @@
+import {readFileSync} from 'node:fs';
+import type {LogLevel} from '@remotion/renderer';
+import {RenderInternals} from '@remotion/renderer';
+import type {
+ DeleteEffectKeyframe,
+ DeleteKeyframesRequest,
+ DeleteKeyframesResponse,
+ DeleteSequenceKeyframe,
+ SaveEffectPropsResponse,
+ SaveSequencePropsResult,
+} from '@remotion/studio-shared';
+import {getAllSchemaKeys} from '@remotion/studio-shared';
+import {parseAst} from '../../codemods/parse-ast';
+import {
+ updateEffectKeyframes,
+ updateSequenceKeyframes,
+} from '../../codemods/update-keyframes/update-keyframes';
+import {writeFileAndNotifyFileWatchers} from '../../file-watcher';
+import {resolveFileInsideProject} from '../../helpers/resolve-file-inside-project';
+import type {ApiHandler} from '../api-types';
+import {
+ printUndoHint,
+ pushTransactionToUndoStack,
+ suppressUndoStackInvalidation,
+} from '../undo-stack';
+import {suppressBundlerUpdateForFile} from '../watch-ignore-next-change';
+import {computeEffectPropStatus} from './can-update-effect-props';
+import {
+ computeSequencePropsStatusFromContent,
+ findJsxElementAtNodePath,
+} from './can-update-sequence-props';
+import {logEffectUpdate} from './log-updates/log-effect-update';
+import {logUpdate} from './log-updates/log-update';
+import {withSavePropsLock} from './save-props-mutex';
+
+type ResolvedSequenceKeyframe = DeleteSequenceKeyframe & {
+ index: number;
+ absolutePath: string;
+ fileRelativeToRoot: string;
+};
+
+type ResolvedEffectKeyframe = DeleteEffectKeyframe & {
+ index: number;
+ absolutePath: string;
+ fileRelativeToRoot: string;
+};
+
+type FileGroup = {
+ fileRelativeToRoot: string;
+ sequenceKeyframes: ResolvedSequenceKeyframe[];
+ effectKeyframes: ResolvedEffectKeyframe[];
+};
+
+type UndoSnapshot = {
+ filePath: string;
+ oldContents: string;
+ newContents: string;
+ logLine: number;
+};
+
+type SequenceLog = {
+ fileRelativeToRoot: string;
+ line: number;
+ key: string;
+ oldValueString: string;
+ newValueString: string;
+ formatted: boolean;
+};
+
+type EffectLog = {
+ fileRelativeToRoot: string;
+ line: number;
+ effectName: string;
+ propKey: string;
+ oldValueString: string;
+ newValueString: string;
+ formatted: boolean;
+};
+
+const groupBy = <T>(items: T[], getKey: (item: T) => string): T[][] => {
+ const groups = new Map<string, T[]>();
+ for (const item of items) {
+ const key = getKey(item);
+ const group = groups.get(key) ?? [];
+ group.push(item);
+ groups.set(key, group);
+ }
+
+ return [...groups.values()];
+};
+
+const getBatchDescription = ({
+ totalKeyframes,
+ firstKeyframe,
+}: {
+ totalKeyframes: number;
+ firstKeyframe: {key: string; frame: number};
+}) => {
+ if (totalKeyframes === 1) {
+ return {
+ undoMessage: `↩️ ${firstKeyframe.key} keyframe restored at frame ${firstKeyframe.frame}`,
+ redoMessage: `↪️ ${firstKeyframe.key} keyframe deleted at frame ${firstKeyframe.frame}`,
+ };
+ }
+
+ return {
+ undoMessage: `↩️ ${totalKeyframes} keyframes restored`,
+ redoMessage: `↪️ ${totalKeyframes} keyframes deleted`,
+ };
+};
+
+export const deleteKeyframes = async ({
+ sequenceKeyframes,
+ effectKeyframes,
+ clientId,
+ remotionRoot,
+ logLevel,
+}: {
+ sequenceKeyframes: DeleteSequenceKeyframe[];
+ effectKeyframes: DeleteEffectKeyframe[];
+ clientId: string;
+ remotionRoot: string;
+ logLevel: LogLevel;
+}): Promise<{
+ sequenceResults: SaveSequencePropsResult[];
+ effectResults: SaveEffectPropsResponse[];
+}> => {
+ const totalKeyframes = sequenceKeyframes.length + effectKeyframes.length;
+ if (totalKeyframes === 0) {
+ throw new Error('No keyframes were specified for deletion');
+ }
+
+ const fileGroups = new Map<string, FileGroup>();
+ const resolvedSequenceKeyframes: ResolvedSequenceKeyframe[] = [];
+ const resolvedEffectKeyframes: ResolvedEffectKeyframe[] = [];
+
+ for (const [index, keyframe] of sequenceKeyframes.entries()) {
+ const {absolutePath, fileRelativeToRoot} = resolveFileInsideProject({
+ remotionRoot,
+ fileName: keyframe.fileName,
+ action: 'modify',
+ });
+ const group = fileGroups.get(absolutePath) ?? {
+ fileRelativeToRoot,
+ sequenceKeyframes: [],
+ effectKeyframes: [],
+ };
+ const resolved = {...keyframe, index, absolutePath, fileRelativeToRoot};
+ group.sequenceKeyframes.push(resolved);
+ resolvedSequenceKeyframes.push(resolved);
+ fileGroups.set(absolutePath, group);
+ }
+
+ for (const [index, keyframe] of effectKeyframes.entries()) {
+ const {absolutePath, fileRelativeToRoot} = resolveFileInsideProject({
+ remotionRoot,
+ fileName: keyframe.fileName,
+ action: 'modify',
+ });
+ const group = fileGroups.get(absolutePath) ?? {
+ fileRelativeToRoot,
+ sequenceKeyframes: [],
+ effectKeyframes: [],
+ };
+ const resolved = {...keyframe, index, absolutePath, fileRelativeToRoot};
+ group.effectKeyframes.push(resolved);
+ resolvedEffectKeyframes.push(resolved);
+ fileGroups.set(absolutePath, group);
+ }
+
+ const snapshots: UndoSnapshot[] = [];
+ const outputByPath = new Map<string, string>();
+ const sequenceLogs: SequenceLog[] = [];
+ const effectLogs: EffectLog[] = [];
+
+ for (const [absolutePath, group] of fileGroups) {
+ const fileContents = readFileSync(absolutePath, 'utf-8');
+ let output = fileContents;
+ let firstLogLine = Number.POSITIVE_INFINITY;
+
+ for (const keyframeGroup of groupBy(group.sequenceKeyframes, (keyframe) =>
+ JSON.stringify(keyframe.nodePath.nodePath),
+ )) {
+ const [firstSequenceKeyframe] = keyframeGroup;
+ if (!firstSequenceKeyframe) {
+ continue;
+ }
+
+ const result = await updateSequenceKeyframes({
+ input: output,
+ nodePath: firstSequenceKeyframe.nodePath.nodePath,
+ updates: keyframeGroup.map((keyframe) => ({
+ key: keyframe.key,
+ operation: {
+ type: 'remove',
+ frame: keyframe.frame,
+ },
+ })),
+ });
+ output = result.output;
+ firstLogLine = Math.min(firstLogLine, result.logLine);
+
+ for (const [keyframeIndex, keyframe] of keyframeGroup.entries()) {
+ sequenceLogs.push({
+ fileRelativeToRoot: keyframe.fileRelativeToRoot,
+ line: result.logLine,
+ key: keyframe.key,
+ oldValueString: result.oldValueStrings[keyframeIndex],
+ newValueString: result.newValueStrings[keyframeIndex],
+ formatted: result.formatted,
+ });
+ }
+ }
+
+ for (const keyframeGroup of groupBy(
+ group.effectKeyframes,
+ (keyframe) =>
+ `${JSON.stringify(keyframe.sequenceNodePath.nodePath)}:${keyframe.effectIndex}`,
+ )) {
+ const [firstEffectKeyframe] = keyframeGroup;
+ if (!firstEffectKeyframe) {
+ continue;
+ }
+
+ const result = await updateEffectKeyframes({
+ input: output,
+ sequenceNodePath: firstEffectKeyframe.sequenceNodePath.nodePath,
+ effectIndex: firstEffectKeyframe.effectIndex,
+ updates: keyframeGroup.map((keyframe) => ({
+ key: keyframe.key,
+ operation: {
+ type: 'remove',
+ frame: keyframe.frame,
+ },
+ })),
+ });
+ output = result.output;
+ firstLogLine = Math.min(firstLogLine, result.logLine);
+
+ for (const [keyframeIndex, keyframe] of keyframeGroup.entries()) {
+ effectLogs.push({
+ fileRelativeToRoot: keyframe.fileRelativeToRoot,
+ line: result.logLine,
+ effectName: result.effectCallee,
+ propKey: keyframe.key,
+ oldValueString: result.oldValueStrings[keyframeIndex],
+ newValueString: result.newValueStrings[keyframeIndex],
+ formatted: result.formatted,
+ });
+ }
+ }
+
+ snapshots.push({
+ filePath: absolutePath,
+ oldContents: fileContents,
+ newContents: output,
+ logLine: Number.isFinite(firstLogLine) ? firstLogLine : 1,
+ });
+ outputByPath.set(absolutePath, output);
+ }
+
+ const [firstKeyframe] =
+ sequenceKeyframes.length > 0 ? sequenceKeyframes : effectKeyframes;
+ if (!firstKeyframe) {
+ throw new Error('No keyframes were specified for deletion');
+ }
+
+ pushTransactionToUndoStack({
+ snapshots,
+ logLevel,
+ remotionRoot,
+ description: getBatchDescription({totalKeyframes, firstKeyframe}),
+ entryType:
+ sequenceKeyframes.length > 0 && effectKeyframes.length > 0
+ ? 'keyframe-delete'
+ : sequenceKeyframes.length > 0
+ ? 'sequence-props'
+ : 'effect-props',
+ suppressHmrOnFileRestore: true,
+ });
+
+ for (const snapshot of snapshots) {
+ suppressUndoStackInvalidation(snapshot.filePath);
+ suppressBundlerUpdateForFile(snapshot.filePath);
+ writeFileAndNotifyFileWatchers(
+ snapshot.filePath,
+ snapshot.newContents,
+ clientId,
+ );
+ }
+
+ for (const log of sequenceLogs) {
+ logUpdate({
+ fileRelativeToRoot: log.fileRelativeToRoot,
+ line: log.line,
+ key: log.key,
+ oldValueString: log.oldValueString,
+ newValueString: log.newValueString,
+ defaultValueString: null,
+ formatted: log.formatted,
+ logLevel,
+ removedProps: [],
+ addedProps: [],
+ });
+ }
+
+ for (const log of effectLogs) {
+ logEffectUpdate({
+ fileRelativeToRoot: log.fileRelativeToRoot,
+ line: log.line,
+ effectName: log.effectName,
+ propKey: log.propKey,
+ oldValueString: log.oldValueString,
+ newValueString: log.newValueString,
+ defaultValueString: null,
+ formatted: log.formatted,
+ logLevel,
+ removedProps: [],
+ addedProps: [],
+ });
+ }
+
+ printUndoHint(logLevel);
+
+ const sequenceResults = resolvedSequenceKeyframes.map((keyframe) => {
+ const output = outputByPath.get(keyframe.absolutePath);
+ if (!output) {
+ throw new Error('Could not compute sequence keyframe deletion status');
+ }
+
+ const status = computeSequencePropsStatusFromContent({
+ fileContents: output,
+ keys: getAllSchemaKeys(keyframe.schema),
+ nodePath: keyframe.nodePath.nodePath,
+ effects: [],
+ });
+
+ return {
+ fileName: keyframe.fileName,
+ nodePath: keyframe.nodePath,
+ props: status.props,
+ };
+ });
+
+ const astByPath = new Map<string, ReturnType<typeof parseAst>>();
+ const effectResults = resolvedEffectKeyframes.map((keyframe) => {
+ const output = outputByPath.get(keyframe.absolutePath);
+ if (!output) {
+ throw new Error('Could not compute effect keyframe deletion status');
+ }
+
+ const ast = astByPath.get(keyframe.absolutePath) ?? parseAst(output);
+ astByPath.set(keyframe.absolutePath, ast);
+ const jsx = findJsxElementAtNodePath(
+ ast,
+ keyframe.sequenceNodePath.nodePath,
+ );
+ if (!jsx) {
+ return {
+ canUpdate: false as const,
+ effectIndex: keyframe.effectIndex,
+ reason: 'not-found' as const,
+ };
+ }
+
+ return computeEffectPropStatus({
+ jsx,
+ effectIndex: keyframe.effectIndex,
+ keys: getAllSchemaKeys(keyframe.schema),
+ });
+ });
+
+ return {sequenceResults, effectResults};
+};
+
+export const deleteKeyframesHandler: ApiHandler<
+ DeleteKeyframesRequest,
+ DeleteKeyframesResponse
+> = ({
+ input: {sequenceKeyframes, effectKeyframes, clientId},
+ remotionRoot,
+ logLevel,
+}) =>
+ withSavePropsLock(async () => {
+ RenderInternals.Log.trace(
+ {indent: false, logLevel},
+ `[delete-keyframes] Received request to delete ${
+ sequenceKeyframes.length + effectKeyframes.length
+ } keyframe(s)`,
+ );
+
+ await deleteKeyframes({
+ sequenceKeyframes,
+ effectKeyframes,
+ clientId,
+ remotionRoot,
+ logLevel,
+ });
+
+ return {success: true};
+ });
diff --git a/packages/studio-server/src/preview-server/routes/delete-sequence-keyframe.ts b/packages/studio-server/src/preview-server/routes/delete-sequence-keyframe.ts
deleted file mode 100644
index 16818f4f89..0000000000
--- a/packages/studio-server/src/preview-server/routes/delete-sequence-keyframe.ts
+++ /dev/null
@@ -1,109 +0,0 @@
-import {readFileSync} from 'node:fs';
-import {RenderInternals} from '@remotion/renderer';
-import type {
- DeleteSequenceKeyframeRequest,
- DeleteSequenceKeyframeResponse,
-} from '@remotion/studio-shared';
-import {getAllSchemaKeys} from '@remotion/studio-shared';
-import {updateSequenceKeyframes} from '../../codemods/update-keyframes/update-keyframes';
-import {writeFileAndNotifyFileWatchers} from '../../file-watcher';
-import {resolveFileInsideProject} from '../../helpers/resolve-file-inside-project';
-import type {ApiHandler} from '../api-types';
-import {
- printUndoHint,
- pushToUndoStack,
- suppressUndoStackInvalidation,
-} from '../undo-stack';
-import {suppressBundlerUpdateForFile} from '../watch-ignore-next-change';
-import {computeSequencePropsStatusFromContent} from './can-update-sequence-props';
-import {logUpdate} from './log-updates/log-update';
-import {withSavePropsLock} from './save-props-mutex';
-
-export const deleteSequenceKeyframeHandler: ApiHandler<
- DeleteSequenceKeyframeRequest,
- DeleteSequenceKeyframeResponse
-> = ({
- input: {fileName, nodePath, key, frame, schema, clientId},
- remotionRoot,
- logLevel,
-}) =>
- withSavePropsLock(async () => {
- RenderInternals.Log.trace(
- {indent: false, logLevel},
- `[delete-sequence-keyframe] Received request for fileName="${fileName}" key="${key}" frame=${frame}`,
- );
- const {absolutePath, fileRelativeToRoot} = resolveFileInsideProject({
- remotionRoot,
- fileName,
- action: 'modify',
- });
-
- const fileContents = readFileSync(absolutePath, 'utf-8');
-
- const {output, oldValueStrings, newValueStrings, formatted, logLine} =
- await updateSequenceKeyframes({
- input: fileContents,
- nodePath: nodePath.nodePath,
- updates: [
- {
- key,
- operation: {
- type: 'remove',
- frame,
- },
- },
- ],
- });
-
- const oldValueString = oldValueStrings[0];
- const newValueString = newValueStrings[0];
-
- const undoPropChange = `${key} keyframe restored at frame ${frame}`;
- const redoPropChange = `${key} keyframe deleted at frame ${frame}`;
-
- pushToUndoStack({
- filePath: absolutePath,
- oldContents: fileContents,
- newContents: null,
- logLevel,
- remotionRoot,
- logLine,
- description: {
- undoMessage: `↩️ ${undoPropChange}`,
- redoMessage: `↪️ ${redoPropChange}`,
- },
- entryType: 'sequence-props',
- suppressHmrOnFileRestore: true,
- });
- suppressUndoStackInvalidation(absolutePath);
- suppressBundlerUpdateForFile(absolutePath);
- writeFileAndNotifyFileWatchers(absolutePath, output, clientId);
-
- logUpdate({
- fileRelativeToRoot,
- line: logLine,
- key,
- oldValueString,
- newValueString,
- defaultValueString: null,
- formatted,
- logLevel,
- removedProps: [],
- addedProps: [],
- });
-
- printUndoHint(logLevel);
-
- const status = computeSequencePropsStatusFromContent({
- fileContents: output,
- keys: getAllSchemaKeys(schema),
- nodePath: nodePath.nodePath,
- effects: [],
- });
-
- return {
- canUpdate: true,
- props: status.props,
- results: [{fileName, nodePath, props: status.props}],
- };
- });
diff --git a/packages/studio-server/src/preview-server/undo-stack.ts b/packages/studio-server/src/preview-server/undo-stack.ts
index 683adcf75e..1abde54fd8 100644
--- a/packages/studio-server/src/preview-server/undo-stack.ts
+++ b/packages/studio-server/src/preview-server/undo-stack.ts
@@ -21,6 +21,7 @@ type UndoEntryType =
| 'default-props'
| 'sequence-props'
| 'effect-props'
+ | 'keyframe-delete'
| 'add-effect'
| 'delete-effect'
| 'reorder-effect'
@@ -52,6 +53,7 @@ type UndoEntry = {
| {entryType: 'default-props'}
| {entryType: 'sequence-props'}
| {entryType: 'effect-props'}
+ | {entryType: 'keyframe-delete'}
| {entryType: 'add-effect'}
| {entryType: 'delete-effect'}
| {entryType: 'reorder-effect'}
diff --git a/packages/studio-server/src/test/delete-keyframes.test.ts b/packages/studio-server/src/test/delete-keyframes.test.ts
new file mode 100644
index 0000000000..f74b640dbe
--- /dev/null
+++ b/packages/studio-server/src/test/delete-keyframes.test.ts
@@ -0,0 +1,101 @@
+import {expect, test} from 'bun:test';
+import {mkdtempSync, readFileSync, rmSync, writeFileSync} from 'node:fs';
+import {tmpdir} from 'node:os';
+import {join} from 'node:path';
+import {NoReactInternals} from 'remotion/no-react';
+import {
+ createFileWatcherRegistry,
+ setFileWatcherRegistry,
+} from '../file-watcher';
+import {setLiveEventsListener} from '../preview-server/live-events';
+import {deleteKeyframes} from '../preview-server/routes/delete-keyframes';
+import {
+ clearUndoStackForTests,
+ getUndoStack,
+ popRedo,
+ popUndo,
+} from '../preview-server/undo-stack';
+import {lineColumnToNodePath} from './test-utils';
+
+const input = `import {tint} from '@remotion/effects/tint';
+import {AbsoluteFill, interpolate, useCurrentFrame} from 'remotion';
+
+export const Comp = () => {
+\tconst frame = useCurrentFrame();
+\treturn (
+\t\t<AbsoluteFill
+\t\t\tstyle={{opacity: interpolate(frame, [0, 10], [0, 1])}}
+\t\t\teffects={[tint({amount: interpolate(frame, [0, 20], [0.2, 0.8])})]}
+\t\t/>
+\t);
+};
+`;
+
+test('deleteKeyframes batches sequence and effect deletes into one undo entry', async () => {
+ const cleanupFileWatcher = setFileWatcherRegistry(
+ createFileWatcherRegistry(),
+ );
+ const cleanupLiveEvents = setLiveEventsListener({
+ addNewClientListener: () => () => undefined,
+ closeConnections: () => Promise.resolve(),
+ router: () => Promise.resolve(),
+ sendEventToClient: () => undefined,
+ sendEventToClientId: () => undefined,
+ });
+ const dir = mkdtempSync(join(tmpdir(), 'remotion-delete-keyframes-'));
+ const fileName = 'Comp.tsx';
+ const filePath = join(dir, fileName);
+ const nodePath = {
+ absolutePath: fileName,
+ nodePath: lineColumnToNodePath(input, 7),
+ sequenceKeys: ['style.opacity'],
+ effectKeys: [['amount']],
+ };
+
+ try {
+ writeFileSync(filePath, input);
+
+ await deleteKeyframes({
+ sequenceKeyframes: [
+ {
+ fileName,
+ nodePath,
+ key: 'style.opacity',
+ frame: 0,
+ schema: NoReactInternals.sequenceSchema,
+ },
+ ],
+ effectKeyframes: [
+ {
+ fileName,
+ sequenceNodePath: nodePath,
+ effectIndex: 0,
+ key: 'amount',
+ frame: 20,
+ schema: NoReactInternals.sequenceSchema,
+ },
+ ],
+ clientId: 'test-client',
+ remotionRoot: dir,
+ logLevel: 'error',
+ });
+
+ const output = readFileSync(filePath, 'utf-8');
+ expect(output).toContain(
+ 'style={{opacity: interpolate(frame, [10], [1])}}',
+ );
+ expect(output).toContain('amount: interpolate(frame, [0], [0.2])');
+ expect(getUndoStack()).toHaveLength(1);
+
+ expect(popUndo()).toEqual({success: true});
+ expect(readFileSync(filePath, 'utf-8')).toBe(input);
+
+ expect(popRedo()).toEqual({success: true});
+ expect(readFileSync(filePath, 'utf-8')).toBe(output);
+ } finally {
+ clearUndoStackForTests();
+ cleanupLiveEvents();
+ cleanupFileWatcher();
+ rmSync(dir, {force: true, recursive: true});
+ }
+});
diff --git a/packages/studio-shared/src/api-requests.ts b/packages/studio-shared/src/api-requests.ts
index 24b4875fdf..359c9faa59 100644
--- a/packages/studio-shared/src/api-requests.ts
+++ b/packages/studio-shared/src/api-requests.ts
@@ -357,17 +357,14 @@ export type ReorderEffectResponse =
stack: string;
};
-export type DeleteSequenceKeyframeRequest = {
+export type DeleteSequenceKeyframe = {
fileName: string;
nodePath: SequencePropsSubscriptionKey;
key: string;
frame: number;
schema: SequenceSchema;
- clientId: string;
};
-export type DeleteSequenceKeyframeResponse = SaveSequencePropsResponse;
-
export type AddSequenceKeyframeRequest = {
fileName: string;
nodePath: SequencePropsSubscriptionKey;
@@ -380,17 +377,24 @@ export type AddSequenceKeyframeRequest = {
export type AddSequenceKeyframeResponse = SaveSequencePropsResponse;
-export type DeleteEffectKeyframeRequest = {
+export type DeleteEffectKeyframe = {
fileName: string;
sequenceNodePath: SequencePropsSubscriptionKey;
effectIndex: number;
key: string;
frame: number;
schema: SequenceSchema;
+};
+
+export type DeleteKeyframesRequest = {
+ sequenceKeyframes: DeleteSequenceKeyframe[];
+ effectKeyframes: DeleteEffectKeyframe[];
clientId: string;
};
-export type DeleteEffectKeyframeResponse = SaveEffectPropsResponse;
+export type DeleteKeyframesResponse = {
+ success: true;
+};
export type AddEffectKeyframeRequest = {
fileName: string;
@@ -583,18 +587,14 @@ export type ApiRoutes = {
>;
'/api/add-effect': ReqAndRes<AddEffectRequest, AddEffectResponse>;
'/api/reorder-effect': ReqAndRes<ReorderEffectRequest, ReorderEffectResponse>;
- '/api/delete-sequence-keyframe': ReqAndRes<
- DeleteSequenceKeyframeRequest,
- DeleteSequenceKeyframeResponse
+ '/api/delete-keyframes': ReqAndRes<
+ DeleteKeyframesRequest,
+ DeleteKeyframesResponse
>;
'/api/add-sequence-keyframe': ReqAndRes<
AddSequenceKeyframeRequest,
AddSequenceKeyframeResponse
>;
- '/api/delete-effect-keyframe': ReqAndRes<
- DeleteEffectKeyframeRequest,
- DeleteEffectKeyframeResponse
- >;
'/api/add-effect-keyframe': ReqAndRes<
AddEffectKeyframeRequest,
AddEffectKeyframeResponse
diff --git a/packages/studio-shared/src/index.ts b/packages/studio-shared/src/index.ts
index 3e76aa3545..06d689c909 100644
--- a/packages/studio-shared/src/index.ts
+++ b/packages/studio-shared/src/index.ts
@@ -19,16 +19,16 @@ export {
CompositionComponentInfoRequest,
CompositionComponentInfoResponse,
CopyStillToClipboardRequest,
- DeleteEffectKeyframeRequest,
- DeleteEffectKeyframeResponse,
+ DeleteEffectKeyframe,
DeleteEffectRequest,
DeleteEffectRequestItem,
DeleteEffectResponse,
DeleteJsxNodeRequest,
DeleteJsxNodeRequestItem,
DeleteJsxNodeResponse,
- DeleteSequenceKeyframeRequest,
- DeleteSequenceKeyframeResponse,
+ DeleteKeyframesRequest,
+ DeleteKeyframesResponse,
+ DeleteSequenceKeyframe,
DeleteStaticFileRequest,
DeleteStaticFileResponse,
DuplicateJsxNodeRequest,
@@ -155,7 +155,9 @@ export {
} from './optimistic-add-keyframe';
export {
optimisticDeleteEffectKeyframe,
+ optimisticDeleteEffectKeyframes,
optimisticDeleteSequenceKeyframe,
+ optimisticDeleteSequenceKeyframes,
} from './optimistic-delete-keyframe';
export {optimisticUpdateForCodeValues} from './optimistic-update-for-code-values';
export {optimisticUpdateForEffectCodeValues} from './optimistic-update-for-effect-code-values';
diff --git a/packages/studio-shared/src/optimistic-delete-keyframe.ts b/packages/studio-shared/src/optimistic-delete-keyframe.ts
index c8f05876f4..e90d026164 100644
--- a/packages/studio-shared/src/optimistic-delete-keyframe.ts
+++ b/packages/studio-shared/src/optimistic-delete-keyframe.ts
@@ -74,6 +74,24 @@ export const optimisticDeleteSequenceKeyframe = ({
};
};
+export const optimisticDeleteSequenceKeyframes = ({
+ previous,
+ keyframes,
+}: {
+ previous: CanUpdateSequencePropsResponse;
+ keyframes: {fieldKey: string; frame: number}[];
+}): CanUpdateSequencePropsResponse => {
+ return keyframes.reduce(
+ (current, keyframe) =>
+ optimisticDeleteSequenceKeyframe({
+ previous: current,
+ fieldKey: keyframe.fieldKey,
+ frame: keyframe.frame,
+ }),
+ previous,
+ );
+};
+
export const optimisticDeleteEffectKeyframe = ({
previous,
effectIndex,
@@ -122,3 +140,22 @@ export const optimisticDeleteEffectKeyframe = ({
effects,
};
};
+
+export const optimisticDeleteEffectKeyframes = ({
+ previous,
+ keyframes,
+}: {
+ previous: CanUpdateSequencePropsResponse;
+ keyframes: {effectIndex: number; fieldKey: string; frame: number}[];
+}): CanUpdateSequencePropsResponse => {
+ return keyframes.reduce(
+ (current, keyframe) =>
+ optimisticDeleteEffectKeyframe({
+ previous: current,
+ effectIndex: keyframe.effectIndex,
+ fieldKey: keyframe.fieldKey,
+ frame: keyframe.frame,
+ }),
+ previous,
+ );
+};
diff --git a/packages/studio-shared/src/test/optimistic-delete-keyframe.test.ts b/packages/studio-shared/src/test/optimistic-delete-keyframe.test.ts
index 8725da896f..d92a354d15 100644
--- a/packages/studio-shared/src/test/optimistic-delete-keyframe.test.ts
+++ b/packages/studio-shared/src/test/optimistic-delete-keyframe.test.ts
@@ -2,7 +2,9 @@ import {expect, test} from 'bun:test';
import type {CanUpdateSequencePropsResponse} from 'remotion';
import {
optimisticDeleteEffectKeyframe,
+ optimisticDeleteEffectKeyframes,
optimisticDeleteSequenceKeyframe,
+ optimisticDeleteSequenceKeyframes,
} from '../optimistic-delete-keyframe';
test('optimisticDeleteSequenceKeyframe removes the matching keyframe and an easing segment', () => {
@@ -124,6 +126,48 @@ test('optimisticDeleteSequenceKeyframe is a no-op when sequence is not updateabl
expect(result).toBe(previous);
});
+test('optimisticDeleteSequenceKeyframes deletes multiple keyframes in one pass', () => {
+ const previous: CanUpdateSequencePropsResponse = {
+ canUpdate: true,
+ props: {
+ width: {
+ canUpdate: false,
+ reason: 'keyframed',
+ interpolationFunction: 'interpolate',
+ keyframes: [
+ {frame: 0, value: 100},
+ {frame: 30, value: 200},
+ {frame: 60, value: 300},
+ ],
+ easing: ['linear', 'linear'],
+ clamping: {left: 'extend', right: 'extend'},
+ posterize: undefined,
+ },
+ },
+ effects: [],
+ };
+
+ const updated = optimisticDeleteSequenceKeyframes({
+ previous,
+ keyframes: [
+ {fieldKey: 'width', frame: 0},
+ {fieldKey: 'width', frame: 60},
+ ],
+ });
+
+ if (!updated.canUpdate) {
+ throw new Error('expected canUpdate true');
+ }
+
+ const status = updated.props.width;
+ if (status.canUpdate || status.reason !== 'keyframed') {
+ throw new Error('expected keyframed status');
+ }
+
+ expect(status.keyframes).toEqual([{frame: 30, value: 200}]);
+ expect(status.easing).toEqual([]);
+});
+
test('optimisticDeleteEffectKeyframe removes the matching keyframe on the target effect', () => {
const previous: CanUpdateSequencePropsResponse = {
canUpdate: true,
@@ -238,3 +282,57 @@ test('optimisticDeleteEffectKeyframe is a no-op when effect index not found', ()
expect(result).toBe(previous);
});
+
+test('optimisticDeleteEffectKeyframes deletes multiple keyframes in one pass', () => {
+ const previous: CanUpdateSequencePropsResponse = {
+ canUpdate: true,
+ props: {},
+ effects: [
+ {
+ canUpdate: true,
+ effectIndex: 0,
+ callee: 'tint',
+ props: {
+ amount: {
+ canUpdate: false,
+ reason: 'keyframed',
+ interpolationFunction: 'interpolate',
+ keyframes: [
+ {frame: 0, value: 0},
+ {frame: 30, value: 0.5},
+ {frame: 60, value: 1},
+ ],
+ easing: ['linear', 'linear'],
+ clamping: {left: 'extend', right: 'extend'},
+ posterize: undefined,
+ },
+ },
+ },
+ ],
+ };
+
+ const updated = optimisticDeleteEffectKeyframes({
+ previous,
+ keyframes: [
+ {effectIndex: 0, fieldKey: 'amount', frame: 0},
+ {effectIndex: 0, fieldKey: 'amount', frame: 60},
+ ],
+ });
+
+ if (!updated.canUpdate) {
+ throw new Error('expected canUpdate true');
+ }
+
+ const effect = updated.effects[0];
+ if (!effect.canUpdate) {
+ throw new Error('expected effect canUpdate true');
+ }
+
+ const status = effect.props.amount;
+ if (status.canUpdate || status.reason !== 'keyframed') {
+ throw new Error('expected keyframed status');
+ }
+
+ expect(status.keyframes).toEqual([{frame: 30, value: 0.5}]);
+ expect(status.easing).toEqual([]);
+});
diff --git a/packages/studio/src/components/Timeline/call-delete-keyframe.ts b/packages/studio/src/components/Timeline/call-delete-keyframe.ts
index e114fa3e41..83127652e3 100644
--- a/packages/studio/src/components/Timeline/call-delete-keyframe.ts
+++ b/packages/studio/src/components/Timeline/call-delete-keyframe.ts
@@ -1,12 +1,40 @@
import {
optimisticDeleteEffectKeyframe,
+ optimisticDeleteEffectKeyframes,
optimisticDeleteSequenceKeyframe,
+ optimisticDeleteSequenceKeyframes,
} from '@remotion/studio-shared';
import type {SequencePropsSubscriptionKey, SequenceSchema} from 'remotion';
import {callApi} from '../call-api';
import {enqueueSavePropChange} from './save-prop-queue';
import type {SetCodeValues} from './save-sequence-prop';
+export type DeleteSequenceKeyframeChange = {
+ fileName: string;
+ nodePath: SequencePropsSubscriptionKey;
+ fieldKey: string;
+ sourceFrame: number;
+ schema: SequenceSchema;
+};
+
+export type DeleteEffectKeyframeChange = DeleteSequenceKeyframeChange & {
+ effectIndex: number;
+};
+
+const groupByNodePath = <T extends {nodePath: SequencePropsSubscriptionKey}>(
+ keyframes: T[],
+): T[][] => {
+ const groups = new Map<string, T[]>();
+ for (const keyframe of keyframes) {
+ const key = JSON.stringify(keyframe.nodePath);
+ const group = groups.get(key) ?? [];
+ group.push(keyframe);
+ groups.set(key, group);
+ }
+
+ return [...groups.values()];
+};
+
export const callDeleteSequenceKeyframe = ({
fileName,
nodePath,
@@ -34,12 +62,17 @@ export const callDeleteSequenceKeyframe = ({
frame: sourceFrame,
}),
apiCall: () =>
- callApi('/api/delete-sequence-keyframe', {
- fileName,
- nodePath,
- key: fieldKey,
- frame: sourceFrame,
- schema,
+ callApi('/api/delete-keyframes', {
+ sequenceKeyframes: [
+ {
+ fileName,
+ nodePath,
+ key: fieldKey,
+ frame: sourceFrame,
+ schema,
+ },
+ ],
+ effectKeyframes: [],
clientId,
}),
errorLabel: 'Could not delete keyframe',
@@ -76,15 +109,90 @@ export const callDeleteEffectKeyframe = ({
frame: sourceFrame,
}),
apiCall: () =>
- callApi('/api/delete-effect-keyframe', {
- fileName,
- sequenceNodePath: nodePath,
- effectIndex,
- key: fieldKey,
- frame: sourceFrame,
- schema,
+ callApi('/api/delete-keyframes', {
+ sequenceKeyframes: [],
+ effectKeyframes: [
+ {
+ fileName,
+ sequenceNodePath: nodePath,
+ effectIndex,
+ key: fieldKey,
+ frame: sourceFrame,
+ schema,
+ },
+ ],
clientId,
}),
errorLabel: 'Could not delete keyframe',
});
};
+
+export const callDeleteKeyframes = ({
+ sequenceKeyframes,
+ effectKeyframes,
+ setCodeValues,
+ clientId,
+}: {
+ sequenceKeyframes: DeleteSequenceKeyframeChange[];
+ effectKeyframes: DeleteEffectKeyframeChange[];
+ setCodeValues: SetCodeValues;
+ clientId: string;
+}): Promise<void> => {
+ if (sequenceKeyframes.length === 0 && effectKeyframes.length === 0) {
+ return Promise.resolve();
+ }
+
+ for (const keyframes of groupByNodePath(sequenceKeyframes)) {
+ const [firstKeyframe] = keyframes;
+ if (!firstKeyframe) {
+ continue;
+ }
+
+ setCodeValues(firstKeyframe.nodePath, (prev) =>
+ optimisticDeleteSequenceKeyframes({
+ previous: prev,
+ keyframes: keyframes.map((keyframe) => ({
+ fieldKey: keyframe.fieldKey,
+ frame: keyframe.sourceFrame,
+ })),
+ }),
+ );
+ }
+
+ for (const keyframes of groupByNodePath(effectKeyframes)) {
+ const [firstKeyframe] = keyframes;
+ if (!firstKeyframe) {
+ continue;
+ }
+
+ setCodeValues(firstKeyframe.nodePath, (prev) =>
+ optimisticDeleteEffectKeyframes({
+ previous: prev,
+ keyframes: keyframes.map((keyframe) => ({
+ effectIndex: keyframe.effectIndex,
+ fieldKey: keyframe.fieldKey,
+ frame: keyframe.sourceFrame,
+ })),
+ }),
+ );
+ }
+
+ return callApi('/api/delete-keyframes', {
+ sequenceKeyframes: sequenceKeyframes.map((keyframe) => ({
+ fileName: keyframe.fileName,
+ nodePath: keyframe.nodePath,
+ key: keyframe.fieldKey,
+ frame: keyframe.sourceFrame,
+ schema: keyframe.schema,
+ })),
+ effectKeyframes: effectKeyframes.map((keyframe) => ({
+ fileName: keyframe.fileName,
+ sequenceNodePath: keyframe.nodePath,
+ effectIndex: keyframe.effectIndex,
+ key: keyframe.fieldKey,
+ frame: keyframe.sourceFrame,
+ schema: keyframe.schema,
+ })),
+ clientId,
+ }).then(() => undefined);
+};
diff --git a/packages/studio/src/components/Timeline/delete-selected-keyframe.ts b/packages/studio/src/components/Timeline/delete-selected-keyframe.ts
index 1abe4dd078..d7b35c875d 100644
--- a/packages/studio/src/components/Timeline/delete-selected-keyframe.ts
+++ b/packages/studio/src/components/Timeline/delete-selected-keyframe.ts
@@ -1,28 +1,31 @@
import type {OverrideIdToNodePaths, TSequence} from 'remotion';
import type {SequenceNodePathInfo} from '../../helpers/get-timeline-sequence-sort-key';
import {
+ callDeleteKeyframes,
callDeleteEffectKeyframe,
callDeleteSequenceKeyframe,
+ type DeleteEffectKeyframeChange,
+ type DeleteSequenceKeyframeChange,
} from './call-delete-keyframe';
import {findTrackForNodePathInfo} from './find-track-for-node-path-info';
import {parseKeyframeFieldFromNodePath} from './parse-keyframe-field-from-node-path';
import type {SetCodeValues} from './save-sequence-prop';
-export const deleteSelectedKeyframe = ({
+type SelectedKeyframeDeletion =
+ | ({type: 'sequence'} & DeleteSequenceKeyframeChange)
+ | ({type: 'effect'} & DeleteEffectKeyframeChange);
+
+const getSelectedKeyframeDeletion = ({
nodePathInfo,
frame,
sequences,
overrideIdsToNodePaths,
- setCodeValues,
- clientId,
}: {
nodePathInfo: SequenceNodePathInfo;
frame: number;
sequences: TSequence[];
overrideIdsToNodePaths: OverrideIdToNodePaths;
- setCodeValues: SetCodeValues;
- clientId: string;
-}): Promise<void> | null => {
+}): SelectedKeyframeDeletion | null => {
const field = parseKeyframeFieldFromNodePath(nodePathInfo.auxiliaryKeys);
if (field === null) {
return null;
@@ -48,24 +51,115 @@ export const deleteSelectedKeyframe = ({
return null;
}
- return callDeleteEffectKeyframe({
+ return {
+ type: 'effect',
fileName,
nodePath,
effectIndex: field.effectIndex,
fieldKey: field.fieldKey,
sourceFrame,
schema: effect.schema,
- setCodeValues,
- clientId,
- });
+ };
}
- return callDeleteSequenceKeyframe({
+ return {
+ type: 'sequence',
fileName,
nodePath,
fieldKey: field.fieldKey,
sourceFrame,
schema: sequence.controls.schema,
+ };
+};
+
+export const deleteSelectedKeyframe = ({
+ nodePathInfo,
+ frame,
+ sequences,
+ overrideIdsToNodePaths,
+ setCodeValues,
+ clientId,
+}: {
+ nodePathInfo: SequenceNodePathInfo;
+ frame: number;
+ sequences: TSequence[];
+ overrideIdsToNodePaths: OverrideIdToNodePaths;
+ setCodeValues: SetCodeValues;
+ clientId: string;
+}): Promise<void> | null => {
+ const deletion = getSelectedKeyframeDeletion({
+ nodePathInfo,
+ frame,
+ sequences,
+ overrideIdsToNodePaths,
+ });
+ if (deletion === null) {
+ return null;
+ }
+
+ if (deletion.type === 'effect') {
+ return callDeleteEffectKeyframe({
+ ...deletion,
+ setCodeValues,
+ clientId,
+ });
+ }
+
+ return callDeleteSequenceKeyframe({
+ ...deletion,
+ setCodeValues,
+ clientId,
+ });
+};
+
+export const deleteSelectedKeyframes = ({
+ keyframes,
+ sequences,
+ overrideIdsToNodePaths,
+ setCodeValues,
+ clientId,
+}: {
+ keyframes: {
+ nodePathInfo: SequenceNodePathInfo;
+ frame: number;
+ }[];
+ sequences: TSequence[];
+ overrideIdsToNodePaths: OverrideIdToNodePaths;
+ setCodeValues: SetCodeValues;
+ clientId: string;
+}): Promise<void> | null => {
+ const deletions = keyframes
+ .map((keyframe) =>
+ getSelectedKeyframeDeletion({
+ nodePathInfo: keyframe.nodePathInfo,
+ frame: keyframe.frame,
+ sequences,
+ overrideIdsToNodePaths,
+ }),
+ )
+ .filter(
+ (deletion): deletion is SelectedKeyframeDeletion => deletion !== null,
+ );
+
+ if (deletions.length === 0) {
+ return null;
+ }
+
+ return callDeleteKeyframes({
+ sequenceKeyframes: deletions.filter(
+ (
+ deletion,
+ ): deletion is SelectedKeyframeDeletion & {
+ type: 'sequence';
+ } => deletion.type === 'sequence',
+ ),
+ effectKeyframes: deletions.filter(
+ (
+ deletion,
+ ): deletion is SelectedKeyframeDeletion & {
+ type: 'effect';
+ } => deletion.type === 'effect',
+ ),
setCodeValues,
clientId,
});
diff --git a/packages/studio/src/components/Timeline/delete-selected-timeline-item.ts b/packages/studio/src/components/Timeline/delete-selected-timeline-item.ts
index 056b29c164..bcb1fe93df 100644
--- a/packages/studio/src/components/Timeline/delete-selected-timeline-item.ts
+++ b/packages/studio/src/components/Timeline/delete-selected-timeline-item.ts
@@ -2,7 +2,10 @@ import type {OverrideIdToNodePaths, TSequence} from 'remotion';
import type {SequenceNodePathInfo} from '../../helpers/get-timeline-sequence-sort-key';
import {callApi} from '../call-api';
import {showNotification} from '../Notifications/NotificationCenter';
-import {deleteSelectedKeyframe} from './delete-selected-keyframe';
+import {
+ deleteSelectedKeyframe,
+ deleteSelectedKeyframes,
+} from './delete-selected-keyframe';
import type {SetCodeValues} from './save-sequence-prop';
import type {TimelineSelection} from './TimelineSelection';
@@ -248,25 +251,16 @@ export const deleteSelectedTimelineItems = ({
})),
);
case 'keyframe': {
- const deletePromises = selections
- .filter(isKeyframeSelection)
- .map((selection) =>
- deleteSelectedKeyframe({
- nodePathInfo: selection.nodePathInfo,
- frame: selection.frame,
- sequences,
- overrideIdsToNodePaths,
- setCodeValues,
- clientId,
- }),
- )
- .filter((promise): promise is Promise<void> => promise !== null);
-
- if (deletePromises.length === 0) {
- return null;
- }
-
- return Promise.all(deletePromises).then(() => undefined);
+ return deleteSelectedKeyframes({
+ keyframes: selections.filter(isKeyframeSelection).map((selection) => ({
+ nodePathInfo: selection.nodePathInfo,
+ frame: selection.frame,
+ })),
+ sequences,
+ overrideIdsToNodePaths,
+ setCodeValues,
+ clientId,
+ });
}
case 'sequence-prop':