@remotion/studio-server 4.0.523 → 4.0.525

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/canvas-capture/generate-canvas-capture-composition.d.ts +1 -1
  2. package/dist/canvas-capture/generate-canvas-capture-composition.js +77 -12
  3. package/dist/codemods/add-effect.d.ts +1 -26
  4. package/dist/codemods/add-effect.js +6 -191
  5. package/dist/codemods/apply-codemod-to-file.js +8 -1
  6. package/dist/codemods/delete-effect.d.ts +1 -30
  7. package/dist/codemods/delete-effect.js +4 -126
  8. package/dist/codemods/duplicate-effect.d.ts +1 -26
  9. package/dist/codemods/duplicate-effect.js +4 -90
  10. package/dist/codemods/paste-effects.d.ts +9 -14
  11. package/dist/codemods/paste-effects.js +2 -170
  12. package/dist/codemods/reorder-effect.d.ts +1 -13
  13. package/dist/codemods/reorder-effect.js +2 -58
  14. package/dist/codemods/update-effect-props/update-effect-props.d.ts +2 -67
  15. package/dist/codemods/update-effect-props/update-effect-props.js +8 -312
  16. package/dist/codemods/update-keyframes/update-keyframes.js +2 -7
  17. package/dist/codemods/update-sequence-props/update-sequence-props.js +20 -58
  18. package/dist/helpers/resolve-composition-component.d.ts +2 -1
  19. package/dist/helpers/resolve-composition-component.js +13 -7
  20. package/dist/preview-server/api-routes.js +5 -0
  21. package/dist/preview-server/routes/add-keyframes.js +1 -0
  22. package/dist/preview-server/routes/apply-codemod.d.ts +19 -0
  23. package/dist/preview-server/routes/apply-codemod.js +17 -56
  24. package/dist/preview-server/routes/batch-update-keyframe-settings.js +1 -0
  25. package/dist/preview-server/routes/delete-keyframes.js +1 -0
  26. package/dist/preview-server/routes/duplicate-jsx-node.js +1 -0
  27. package/dist/preview-server/routes/insert-element.js +150 -29
  28. package/dist/preview-server/routes/insert-jsx-element.js +1 -0
  29. package/dist/preview-server/routes/install-remotion-skill.d.ts +4 -0
  30. package/dist/preview-server/routes/install-remotion-skill.js +108 -0
  31. package/dist/preview-server/routes/invalidate-bundle.d.ts +3 -0
  32. package/dist/preview-server/routes/invalidate-bundle.js +11 -0
  33. package/dist/preview-server/routes/move-keyframes.js +1 -0
  34. package/dist/preview-server/routes/save-multiple-effect-props.js +1 -0
  35. package/dist/preview-server/routes/save-sequence-props.js +1 -0
  36. package/dist/preview-server/studio-protocol/handle-discovery.js +1 -1
  37. package/dist/preview-server/studio-protocol/handle-element-library.js +1 -1
  38. package/dist/preview-server/studio-protocol/handle-install.js +4 -3
  39. package/dist/preview-server/studio-protocol/handle-license-key.js +1 -1
  40. package/dist/preview-server/studio-protocol/origin-policy.d.ts +1 -1
  41. package/dist/preview-server/studio-protocol/origin-policy.js +13 -6
  42. package/dist/preview-server/undo-stack.d.ts +4 -2
  43. package/dist/preview-server/undo-stack.js +22 -4
  44. package/dist/preview-server/watch-ignore-next-change.d.ts +1 -0
  45. package/dist/preview-server/watch-ignore-next-change.js +20 -12
  46. package/package.json +8 -8
  47. package/dist/preview-server/routes/delete-effect-keyframe.d.ts +0 -3
  48. package/dist/preview-server/routes/delete-effect-keyframe.js +0 -89
  49. package/dist/preview-server/routes/delete-sequence-keyframe.d.ts +0 -3
  50. package/dist/preview-server/routes/delete-sequence-keyframe.js +0 -82
  51. package/dist/preview-server/routes/save-props-mutex.d.ts +0 -1
  52. package/dist/preview-server/routes/save-props-mutex.js +0 -11
@@ -3,11 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.handleStudioProtocolOptions = exports.setStudioProtocolCorsHeaders = exports.getAllowedStudioProtocolOrigin = void 0;
4
4
  const isLoopbackHttp = (url) => url.protocol === 'http:' &&
5
5
  (url.hostname === 'localhost' || url.hostname === '127.0.0.1');
6
- const getAllowedStudioProtocolOrigin = (origin) => {
7
- if (!origin) {
8
- return null;
9
- }
6
+ const getAllowedStudioProtocolOrigin = (request) => {
10
7
  try {
8
+ const { origin, referer, host } = request.headers;
9
+ if (origin === undefined) {
10
+ // Browsers omit Origin on same-origin GET requests. Only trust a
11
+ // Referer matching this local HTTP Studio, never an arbitrary site.
12
+ const refererUrl = new URL(referer !== null && referer !== void 0 ? referer : '');
13
+ return isLoopbackHttp(refererUrl) &&
14
+ refererUrl.origin === `http://${host}`
15
+ ? refererUrl.origin
16
+ : null;
17
+ }
11
18
  const url = new URL(origin);
12
19
  if (url.protocol !== 'https:' && !isLoopbackHttp(url)) {
13
20
  return null;
@@ -20,7 +27,7 @@ const getAllowedStudioProtocolOrigin = (origin) => {
20
27
  };
21
28
  exports.getAllowedStudioProtocolOrigin = getAllowedStudioProtocolOrigin;
22
29
  const setStudioProtocolCorsHeaders = ({ request, response, }) => {
23
- const origin = (0, exports.getAllowedStudioProtocolOrigin)(request.headers.origin);
30
+ const origin = (0, exports.getAllowedStudioProtocolOrigin)(request);
24
31
  if (origin === null) {
25
32
  return;
26
33
  }
@@ -34,7 +41,7 @@ const setStudioProtocolCorsHeaders = ({ request, response, }) => {
34
41
  exports.setStudioProtocolCorsHeaders = setStudioProtocolCorsHeaders;
35
42
  const handleStudioProtocolOptions = ({ request, response, }) => {
36
43
  (0, exports.setStudioProtocolCorsHeaders)({ request, response });
37
- const origin = (0, exports.getAllowedStudioProtocolOrigin)(request.headers.origin);
44
+ const origin = (0, exports.getAllowedStudioProtocolOrigin)(request);
38
45
  response.writeHead(origin === null ? 403 : 204);
39
46
  response.end();
40
47
  return Promise.resolve();
@@ -1,5 +1,5 @@
1
1
  import type { LogLevel } from '@remotion/renderer';
2
- import type { RedoResponse, SequenceNodePathRemapping, UndoResponse } from '@remotion/studio-shared';
2
+ import type { RedoResponse, SequenceNodePathRemapping, UndoRedoNavigation, UndoResponse } from '@remotion/studio-shared';
3
3
  export interface UndoEntryDescription {
4
4
  undoMessage: string;
5
5
  redoMessage: string;
@@ -22,6 +22,7 @@ type UndoEntry = {
22
22
  /** When true, undo/redo file restores call `suppressBundlerUpdateForFile` (skip HMR refresh). */
23
23
  suppressHmrOnFileRestore: boolean;
24
24
  entryType: UndoEntryType;
25
+ undoRedoNavigation: UndoRedoNavigation | null;
25
26
  };
26
27
  export declare function pushToUndoStack({ filePath, oldContents, newContents, logLevel, remotionRoot, logLine, description, entryType, suppressHmrOnFileRestore, nodePathRemappings }: {
27
28
  filePath: string;
@@ -35,7 +36,7 @@ export declare function pushToUndoStack({ filePath, oldContents, newContents, lo
35
36
  suppressHmrOnFileRestore: boolean;
36
37
  nodePathRemappings: SequenceNodePathRemapping[] | null;
37
38
  }): void;
38
- export declare function pushTransactionToUndoStack({ snapshots, logLevel, remotionRoot, description, entryType, suppressHmrOnFileRestore }: {
39
+ export declare function pushTransactionToUndoStack({ snapshots, logLevel, remotionRoot, description, entryType, suppressHmrOnFileRestore, undoRedoNavigation }: {
39
40
  snapshots: Array<{
40
41
  filePath: string;
41
42
  oldContents: string | null;
@@ -48,6 +49,7 @@ export declare function pushTransactionToUndoStack({ snapshots, logLevel, remoti
48
49
  description: UndoEntryDescription;
49
50
  entryType: UndoEntryType;
50
51
  suppressHmrOnFileRestore: boolean;
52
+ undoRedoNavigation: UndoRedoNavigation | null;
51
53
  }): void;
52
54
  export declare function printUndoHint(logLevel: LogLevel): void;
53
55
  export declare function pushToRedoStack({ filePath, oldContents, newContents, logLine, description, entryType, suppressHmrOnFileRestore }: {
@@ -44,7 +44,7 @@ const entryTouchesFile = (entry, filePath) => {
44
44
  const getEntryFilePaths = (entry) => {
45
45
  return entry.snapshots.map((snapshot) => snapshot.filePath);
46
46
  };
47
- const makeUndoEntry = ({ snapshots, description, entryType, suppressHmrOnFileRestore, }) => {
47
+ const makeUndoEntry = ({ snapshots, description, entryType, suppressHmrOnFileRestore, undoRedoNavigation, }) => {
48
48
  if (snapshots.length === 0) {
49
49
  throw new Error('Cannot create an undo entry without snapshots');
50
50
  }
@@ -55,6 +55,7 @@ const makeUndoEntry = ({ snapshots, description, entryType, suppressHmrOnFileRes
55
55
  description,
56
56
  entryType,
57
57
  suppressHmrOnFileRestore,
58
+ undoRedoNavigation,
58
59
  };
59
60
  };
60
61
  function pushToUndoStack({ filePath, oldContents, newContents, logLevel, remotionRoot, logLine, description, entryType, suppressHmrOnFileRestore, nodePathRemappings, }) {
@@ -73,9 +74,10 @@ function pushToUndoStack({ filePath, oldContents, newContents, logLevel, remotio
73
74
  description,
74
75
  entryType,
75
76
  suppressHmrOnFileRestore,
77
+ undoRedoNavigation: null,
76
78
  });
77
79
  }
78
- function pushTransactionToUndoStack({ snapshots, logLevel, remotionRoot, description, entryType, suppressHmrOnFileRestore, }) {
80
+ function pushTransactionToUndoStack({ snapshots, logLevel, remotionRoot, description, entryType, suppressHmrOnFileRestore, undoRedoNavigation, }) {
79
81
  storedLogLevel = logLevel;
80
82
  storedRemotionRoot = remotionRoot;
81
83
  const entry = makeUndoEntry({
@@ -83,6 +85,7 @@ function pushTransactionToUndoStack({ snapshots, logLevel, remotionRoot, descrip
83
85
  description,
84
86
  entryType,
85
87
  suppressHmrOnFileRestore,
88
+ undoRedoNavigation,
86
89
  });
87
90
  undoStack.push(entry);
88
91
  if (undoStack.length > MAX_ENTRIES) {
@@ -116,6 +119,7 @@ function pushToRedoStack({ filePath, oldContents, newContents, logLine, descript
116
119
  description,
117
120
  entryType,
118
121
  suppressHmrOnFileRestore,
122
+ undoRedoNavigation: null,
119
123
  });
120
124
  redoStack.push(entry);
121
125
  if (redoStack.length > MAX_ENTRIES) {
@@ -228,6 +232,8 @@ function logFileAction(action, filePath, logLine) {
228
232
  renderer_1.RenderInternals.Log.info({ indent: false, logLevel: storedLogLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} ${action}`);
229
233
  }
230
234
  function popUndo() {
235
+ var _a;
236
+ var _b;
231
237
  const entry = undoStack.pop();
232
238
  if (!entry) {
233
239
  return { success: false, reason: 'Nothing to undo' };
@@ -246,6 +252,7 @@ function popUndo() {
246
252
  description: entry.description,
247
253
  entryType: entry.entryType,
248
254
  suppressHmrOnFileRestore: entry.suppressHmrOnFileRestore,
255
+ undoRedoNavigation: entry.undoRedoNavigation,
249
256
  }));
250
257
  if (redoStack.length > MAX_ENTRIES) {
251
258
  redoStack.shift();
@@ -297,9 +304,15 @@ function popUndo() {
297
304
  ensureWatching(filePath);
298
305
  }
299
306
  broadcastState();
300
- return { success: true, nodePathMutation };
307
+ return {
308
+ success: true,
309
+ nodePathMutation,
310
+ route: (_b = (_a = entry.undoRedoNavigation) === null || _a === void 0 ? void 0 : _a.undoRoute) !== null && _b !== void 0 ? _b : null,
311
+ };
301
312
  }
302
313
  function popRedo() {
314
+ var _a;
315
+ var _b;
303
316
  const entry = redoStack.pop();
304
317
  if (!entry) {
305
318
  return { success: false, reason: 'Nothing to redo' };
@@ -319,6 +332,7 @@ function popRedo() {
319
332
  description: entry.description,
320
333
  entryType: entry.entryType,
321
334
  suppressHmrOnFileRestore: entry.suppressHmrOnFileRestore,
335
+ undoRedoNavigation: entry.undoRedoNavigation,
322
336
  }));
323
337
  if (undoStack.length > MAX_ENTRIES) {
324
338
  undoStack.shift();
@@ -362,7 +376,11 @@ function popRedo() {
362
376
  ensureWatching(filePath);
363
377
  }
364
378
  broadcastState();
365
- return { success: true, nodePathMutation };
379
+ return {
380
+ success: true,
381
+ nodePathMutation,
382
+ route: (_b = (_a = entry.undoRedoNavigation) === null || _a === void 0 ? void 0 : _a.redoRoute) !== null && _b !== void 0 ? _b : null,
383
+ };
366
384
  }
367
385
  /*
368
386
  * Keep stack accessors typed as readonly arrays so callers can only inspect
@@ -1,4 +1,5 @@
1
1
  import type { WatchIgnoreNextChangePlugin } from '@remotion/bundler';
2
2
  export declare const setWatchIgnoreNextChangePlugin: (plugin: WatchIgnoreNextChangePlugin) => void;
3
3
  export declare const suppressBundlerUpdateForFile: (absolutePath: string) => void;
4
+ export declare const invalidatePreviouslySuppressedFiles: () => Promise<boolean>;
4
5
  export declare const reloadPreviouslySuppressedFiles: () => Promise<void>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.reloadPreviouslySuppressedFiles = exports.suppressBundlerUpdateForFile = exports.setWatchIgnoreNextChangePlugin = void 0;
3
+ exports.reloadPreviouslySuppressedFiles = exports.invalidatePreviouslySuppressedFiles = exports.suppressBundlerUpdateForFile = exports.setWatchIgnoreNextChangePlugin = void 0;
4
4
  const node_fs_1 = require("node:fs");
5
5
  let currentPlugin = null;
6
6
  const setWatchIgnoreNextChangePlugin = (plugin) => {
@@ -11,6 +11,24 @@ const suppressBundlerUpdateForFile = (absolutePath) => {
11
11
  currentPlugin === null || currentPlugin === void 0 ? void 0 : currentPlugin.ignoreNextChange(absolutePath);
12
12
  };
13
13
  exports.suppressBundlerUpdateForFile = suppressBundlerUpdateForFile;
14
+ const invalidatePreviouslySuppressedFiles = async () => {
15
+ if (!currentPlugin) {
16
+ return false;
17
+ }
18
+ const files = currentPlugin.consumeSuppressedFilesForRebuild();
19
+ const now = new Date();
20
+ const touchedFiles = await Promise.all(files.map(async (file) => {
21
+ try {
22
+ await node_fs_1.promises.utimes(file, now, now);
23
+ return true;
24
+ }
25
+ catch (_a) {
26
+ return false;
27
+ }
28
+ }));
29
+ return touchedFiles.some(Boolean);
30
+ };
31
+ exports.invalidatePreviouslySuppressedFiles = invalidatePreviouslySuppressedFiles;
14
32
  // Why do we need this?
15
33
  // Consider we have a <Sequence>.
16
34
  // 1. In visual mode, we update it to layout='none'. This is reflected in the browser and in the code,
@@ -21,16 +39,6 @@ exports.suppressBundlerUpdateForFile = suppressBundlerUpdateForFile;
21
39
  // The same happens again - infinite loop!
22
40
  // --> When reloading the Studio, it is a good idea to reset Webpack to a non-hacked state.
23
41
  const reloadPreviouslySuppressedFiles = async () => {
24
- if (!currentPlugin) {
25
- return;
26
- }
27
- const files = currentPlugin.consumeSuppressedFilesHistory();
28
- const now = new Date();
29
- await Promise.all(files.map(async (file) => {
30
- try {
31
- await node_fs_1.promises.utimes(file, now, now);
32
- }
33
- catch (_a) { }
34
- }));
42
+ await (0, exports.invalidatePreviouslySuppressedFiles)();
35
43
  };
36
44
  exports.reloadPreviouslySuppressedFiles = reloadPreviouslySuppressedFiles;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/studio-server"
4
4
  },
5
5
  "name": "@remotion/studio-server",
6
- "version": "4.0.523",
6
+ "version": "4.0.525",
7
7
  "description": "Run a Remotion Studio with a server backend",
8
8
  "main": "dist",
9
9
  "scripts": {
@@ -23,7 +23,7 @@
23
23
  "access": "public"
24
24
  },
25
25
  "dependencies": {
26
- "@remotion/studio-protocol": "4.0.523",
26
+ "@remotion/studio-protocol": "4.0.525",
27
27
  "@babel/types": "7.24.0",
28
28
  "@babel/parser": "7.24.1",
29
29
  "@svgr/core": "8.1.0",
@@ -32,12 +32,12 @@
32
32
  "semver": "7.5.3",
33
33
  "zod": "4.5.4",
34
34
  "prettier": "3.8.1",
35
- "remotion": "4.0.523",
35
+ "remotion": "4.0.525",
36
36
  "recast": "0.23.21",
37
- "@remotion/bundler": "4.0.523",
38
- "@remotion/renderer": "4.0.523",
39
- "@remotion/studio-codemods": "4.0.523",
40
- "@remotion/studio-shared": "4.0.523",
37
+ "@remotion/bundler": "4.0.525",
38
+ "@remotion/renderer": "4.0.525",
39
+ "@remotion/studio-codemods": "4.0.525",
40
+ "@remotion/studio-shared": "4.0.525",
41
41
  "memfs": "3.4.3",
42
42
  "open": "8.4.2"
43
43
  },
@@ -45,7 +45,7 @@
45
45
  "ast-types": "0.16.1",
46
46
  "react": "19.2.3",
47
47
  "@types/semver": "7.5.3",
48
- "@remotion/eslint-config-internal": "4.0.523",
48
+ "@remotion/eslint-config-internal": "4.0.525",
49
49
  "eslint": "9.19.0",
50
50
  "@types/node": "20.12.14",
51
51
  "@typescript/native-preview": "7.0.0-dev.20260217.1"
@@ -1,3 +0,0 @@
1
- import type { DeleteEffectKeyframeRequest, DeleteEffectKeyframeResponse } from '@remotion/studio-shared';
2
- import type { ApiHandler } from '../api-types';
3
- export declare const deleteEffectKeyframeHandler: ApiHandler<DeleteEffectKeyframeRequest, DeleteEffectKeyframeResponse>;
@@ -1,89 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deleteEffectKeyframeHandler = void 0;
4
- const node_fs_1 = require("node:fs");
5
- const renderer_1 = require("@remotion/renderer");
6
- const studio_shared_1 = require("@remotion/studio-shared");
7
- const parse_ast_1 = require("../../codemods/parse-ast");
8
- const update_keyframes_1 = require("../../codemods/update-keyframes/update-keyframes");
9
- const file_watcher_1 = require("../../file-watcher");
10
- const resolve_file_inside_project_1 = require("../../helpers/resolve-file-inside-project");
11
- const undo_stack_1 = require("../undo-stack");
12
- const watch_ignore_next_change_1 = require("../watch-ignore-next-change");
13
- const can_update_effect_props_1 = require("./can-update-effect-props");
14
- const can_update_sequence_props_1 = require("./can-update-sequence-props");
15
- const log_effect_update_1 = require("./log-updates/log-effect-update");
16
- const save_props_mutex_1 = require("./save-props-mutex");
17
- const deleteEffectKeyframeHandler = ({ input: { fileName, sequenceNodePath, effectIndex, key, frame, schema, clientId, }, remotionRoot, logLevel, }) => (0, save_props_mutex_1.withSavePropsLock)(async () => {
18
- renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[delete-effect-keyframe] Received request for fileName="${fileName}" effectIndex=${effectIndex} key="${key}" frame=${frame}`);
19
- const { absolutePath, fileRelativeToRoot } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
20
- remotionRoot,
21
- fileName,
22
- action: 'modify',
23
- });
24
- const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
25
- const { output, oldValueStrings, newValueStrings, formatted, logLine, effectCallee, } = await (0, update_keyframes_1.updateEffectKeyframes)({
26
- input: fileContents,
27
- sequenceNodePath: sequenceNodePath.nodePath,
28
- effectIndex,
29
- updates: [
30
- {
31
- key,
32
- operation: {
33
- type: 'remove',
34
- frame,
35
- },
36
- },
37
- ],
38
- });
39
- const oldValueString = oldValueStrings[0];
40
- const newValueString = newValueStrings[0];
41
- const undoPropChange = `${key} keyframe restored at frame ${frame}`;
42
- const redoPropChange = `${key} keyframe deleted at frame ${frame}`;
43
- (0, undo_stack_1.pushToUndoStack)({
44
- filePath: absolutePath,
45
- oldContents: fileContents,
46
- newContents: null,
47
- logLevel,
48
- remotionRoot,
49
- logLine,
50
- description: {
51
- undoMessage: `↩️ ${undoPropChange}`,
52
- redoMessage: `↪️ ${redoPropChange}`,
53
- },
54
- entryType: 'effect-props',
55
- suppressHmrOnFileRestore: true,
56
- });
57
- (0, undo_stack_1.suppressUndoStackInvalidation)(absolutePath);
58
- (0, watch_ignore_next_change_1.suppressBundlerUpdateForFile)(absolutePath);
59
- (0, file_watcher_1.writeFileAndNotifyFileWatchers)(absolutePath, output, clientId);
60
- (0, log_effect_update_1.logEffectUpdate)({
61
- fileRelativeToRoot,
62
- line: logLine,
63
- effectName: effectCallee,
64
- propKey: key,
65
- oldValueString,
66
- newValueString,
67
- defaultValueString: null,
68
- formatted,
69
- logLevel,
70
- removedProps: [],
71
- addedProps: [],
72
- });
73
- (0, undo_stack_1.printUndoHint)(logLevel);
74
- const ast = (0, parse_ast_1.parseAst)((0, node_fs_1.readFileSync)(absolutePath, 'utf-8'));
75
- const jsx = (0, can_update_sequence_props_1.findJsxElementAtNodePath)(ast, sequenceNodePath.nodePath);
76
- if (!jsx) {
77
- return {
78
- canUpdate: false,
79
- effectIndex,
80
- reason: 'not-found',
81
- };
82
- }
83
- return (0, can_update_effect_props_1.computeEffectPropStatus)({
84
- jsx,
85
- effectIndex,
86
- keys: (0, studio_shared_1.getAllSchemaKeys)(schema),
87
- });
88
- });
89
- exports.deleteEffectKeyframeHandler = deleteEffectKeyframeHandler;
@@ -1,3 +0,0 @@
1
- import type { DeleteSequenceKeyframeRequest, DeleteSequenceKeyframeResponse } from '@remotion/studio-shared';
2
- import type { ApiHandler } from '../api-types';
3
- export declare const deleteSequenceKeyframeHandler: ApiHandler<DeleteSequenceKeyframeRequest, DeleteSequenceKeyframeResponse>;
@@ -1,82 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deleteSequenceKeyframeHandler = void 0;
4
- const node_fs_1 = require("node:fs");
5
- const renderer_1 = require("@remotion/renderer");
6
- const studio_shared_1 = require("@remotion/studio-shared");
7
- const update_keyframes_1 = require("../../codemods/update-keyframes/update-keyframes");
8
- const file_watcher_1 = require("../../file-watcher");
9
- const resolve_file_inside_project_1 = require("../../helpers/resolve-file-inside-project");
10
- const undo_stack_1 = require("../undo-stack");
11
- const watch_ignore_next_change_1 = require("../watch-ignore-next-change");
12
- const can_update_sequence_props_1 = require("./can-update-sequence-props");
13
- const log_update_1 = require("./log-updates/log-update");
14
- const save_props_mutex_1 = require("./save-props-mutex");
15
- const deleteSequenceKeyframeHandler = ({ input: { fileName, nodePath, key, frame, schema, clientId }, remotionRoot, logLevel, }) => (0, save_props_mutex_1.withSavePropsLock)(async () => {
16
- renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[delete-sequence-keyframe] Received request for fileName="${fileName}" key="${key}" frame=${frame}`);
17
- const { absolutePath, fileRelativeToRoot } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
18
- remotionRoot,
19
- fileName,
20
- action: 'modify',
21
- });
22
- const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
23
- const { output, oldValueStrings, newValueStrings, formatted, logLine } = await (0, update_keyframes_1.updateSequenceKeyframes)({
24
- input: fileContents,
25
- nodePath: nodePath.nodePath,
26
- updates: [
27
- {
28
- key,
29
- operation: {
30
- type: 'remove',
31
- frame,
32
- },
33
- },
34
- ],
35
- });
36
- const oldValueString = oldValueStrings[0];
37
- const newValueString = newValueStrings[0];
38
- const undoPropChange = `${key} keyframe restored at frame ${frame}`;
39
- const redoPropChange = `${key} keyframe deleted at frame ${frame}`;
40
- (0, undo_stack_1.pushToUndoStack)({
41
- filePath: absolutePath,
42
- oldContents: fileContents,
43
- newContents: null,
44
- logLevel,
45
- remotionRoot,
46
- logLine,
47
- description: {
48
- undoMessage: `↩️ ${undoPropChange}`,
49
- redoMessage: `↪️ ${redoPropChange}`,
50
- },
51
- entryType: 'sequence-props',
52
- suppressHmrOnFileRestore: true,
53
- });
54
- (0, undo_stack_1.suppressUndoStackInvalidation)(absolutePath);
55
- (0, watch_ignore_next_change_1.suppressBundlerUpdateForFile)(absolutePath);
56
- (0, file_watcher_1.writeFileAndNotifyFileWatchers)(absolutePath, output, clientId);
57
- (0, log_update_1.logUpdate)({
58
- fileRelativeToRoot,
59
- line: logLine,
60
- key,
61
- oldValueString,
62
- newValueString,
63
- defaultValueString: null,
64
- formatted,
65
- logLevel,
66
- removedProps: [],
67
- addedProps: [],
68
- });
69
- (0, undo_stack_1.printUndoHint)(logLevel);
70
- const status = (0, can_update_sequence_props_1.computeSequencePropsStatusFromContent)({
71
- fileContents: output,
72
- keys: (0, studio_shared_1.getAllSchemaKeys)(schema),
73
- nodePath: nodePath.nodePath,
74
- effects: [],
75
- });
76
- return {
77
- canUpdate: true,
78
- props: status.props,
79
- results: [{ fileName, nodePath, props: status.props }],
80
- };
81
- });
82
- exports.deleteSequenceKeyframeHandler = deleteSequenceKeyframeHandler;
@@ -1 +0,0 @@
1
- export declare const withSavePropsLock: <T>(fn: () => Promise<T>) => Promise<T>;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.withSavePropsLock = void 0;
4
- let chain = Promise.resolve();
5
- const withSavePropsLock = (fn) => {
6
- const run = () => fn();
7
- const next = chain.then(run, run);
8
- chain = next.then(() => undefined, () => undefined);
9
- return next;
10
- };
11
- exports.withSavePropsLock = withSavePropsLock;