@remotion/studio-server 4.0.507 → 4.0.509

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 (76) hide show
  1. package/dist/canvas-capture/generate-canvas-capture-composition.d.ts +14 -0
  2. package/dist/canvas-capture/generate-canvas-capture-composition.js +174 -0
  3. package/dist/codemods/delete-jsx-node.d.ts +4 -0
  4. package/dist/codemods/delete-jsx-node.js +8 -0
  5. package/dist/codemods/duplicate-composition.js +8 -6
  6. package/dist/codemods/duplicate-jsx-node.d.ts +2 -0
  7. package/dist/codemods/duplicate-jsx-node.js +8 -0
  8. package/dist/codemods/get-node-path-remappings.d.ts +16 -0
  9. package/dist/codemods/get-node-path-remappings.js +88 -0
  10. package/dist/codemods/recast-mods.js +13 -0
  11. package/dist/codemods/reorder-sequence.d.ts +2 -1
  12. package/dist/codemods/reorder-sequence.js +8 -0
  13. package/dist/codemods/split-jsx-sequence.d.ts +2 -0
  14. package/dist/codemods/split-jsx-sequence.js +8 -0
  15. package/dist/codemods/update-keyframes/update-keyframes.js +17 -10
  16. package/dist/file-watcher.d.ts +11 -1
  17. package/dist/file-watcher.js +16 -5
  18. package/dist/helpers/coding-agent-registry.d.ts +0 -1
  19. package/dist/helpers/coding-agent-registry.js +1 -5
  20. package/dist/helpers/finder-artwork.d.ts +1 -0
  21. package/dist/helpers/finder-artwork.js +4 -0
  22. package/dist/helpers/resolve-composition-component.d.ts +4 -1
  23. package/dist/helpers/resolve-composition-component.js +63 -69
  24. package/dist/helpers/terminal-artwork.d.ts +6 -0
  25. package/dist/helpers/terminal-artwork.js +14 -0
  26. package/dist/helpers/terminal-registry.d.ts +36 -0
  27. package/dist/helpers/terminal-registry.js +401 -0
  28. package/dist/index.d.ts +8 -2
  29. package/dist/preview-server/api-routes.js +2 -0
  30. package/dist/preview-server/live-events.d.ts +1 -0
  31. package/dist/preview-server/live-events.js +3 -1
  32. package/dist/preview-server/routes/add-effect-keyframe.js +7 -1
  33. package/dist/preview-server/routes/add-effect.js +7 -1
  34. package/dist/preview-server/routes/add-keyframes.js +10 -2
  35. package/dist/preview-server/routes/add-sequence-keyframe.js +7 -1
  36. package/dist/preview-server/routes/app-icon.d.ts +6 -0
  37. package/dist/preview-server/routes/app-icon.js +66 -0
  38. package/dist/preview-server/routes/apply-codemod.js +34 -5
  39. package/dist/preview-server/routes/apply-visual-control-change.js +7 -1
  40. package/dist/preview-server/routes/batch-update-keyframe-settings.js +10 -2
  41. package/dist/preview-server/routes/can-update-sequence-props.d.ts +1 -0
  42. package/dist/preview-server/routes/can-update-sequence-props.js +5 -4
  43. package/dist/preview-server/routes/default-coding-agent.js +4 -2
  44. package/dist/preview-server/routes/delete-effect.js +7 -1
  45. package/dist/preview-server/routes/delete-jsx-node.js +16 -2
  46. package/dist/preview-server/routes/delete-keyframes.js +10 -2
  47. package/dist/preview-server/routes/duplicate-effect.js +7 -1
  48. package/dist/preview-server/routes/duplicate-jsx-node.js +17 -5
  49. package/dist/preview-server/routes/insert-element.js +23 -3
  50. package/dist/preview-server/routes/insert-jsx-element.js +23 -2
  51. package/dist/preview-server/routes/move-keyframes.js +10 -2
  52. package/dist/preview-server/routes/open-in-terminal.d.ts +3 -0
  53. package/dist/preview-server/routes/open-in-terminal.js +17 -0
  54. package/dist/preview-server/routes/paste-effects.js +7 -1
  55. package/dist/preview-server/routes/reorder-effect.js +7 -1
  56. package/dist/preview-server/routes/reorder-sequence.js +17 -2
  57. package/dist/preview-server/routes/save-effect-props.js +7 -1
  58. package/dist/preview-server/routes/save-multiple-effect-props.js +10 -2
  59. package/dist/preview-server/routes/save-sequence-props.js +29 -5
  60. package/dist/preview-server/routes/split-jsx-sequence.js +17 -6
  61. package/dist/preview-server/routes/update-config.js +6 -1
  62. package/dist/preview-server/routes/update-default-props.js +7 -1
  63. package/dist/preview-server/routes/update-effect-keyframe-settings.js +7 -1
  64. package/dist/preview-server/routes/update-sequence-keyframe-settings.js +7 -1
  65. package/dist/preview-server/sequence-node-path-mutation.d.ts +7 -0
  66. package/dist/preview-server/sequence-node-path-mutation.js +21 -0
  67. package/dist/preview-server/sequence-props-watchers.js +15 -6
  68. package/dist/preview-server/start-server.d.ts +1 -0
  69. package/dist/preview-server/start-server.js +1 -0
  70. package/dist/preview-server/undo-stack.d.ts +7 -13
  71. package/dist/preview-server/undo-stack.js +58 -5
  72. package/dist/routes.d.ts +2 -1
  73. package/dist/routes.js +12 -2
  74. package/dist/start-studio.d.ts +2 -1
  75. package/dist/start-studio.js +2 -1
  76. package/package.json +8 -8
@@ -7,6 +7,7 @@ exports.applyCodemodHandler = exports.getCodemodLogMessage = void 0;
7
7
  const node_fs_1 = require("node:fs");
8
8
  const node_path_1 = __importDefault(require("node:path"));
9
9
  const renderer_1 = require("@remotion/renderer");
10
+ const generate_canvas_capture_composition_1 = require("../../canvas-capture/generate-canvas-capture-composition");
10
11
  const apply_codemod_to_file_1 = require("../../codemods/apply-codemod-to-file");
11
12
  const duplicate_composition_1 = require("../../codemods/duplicate-composition");
12
13
  const simple_diff_1 = require("../../codemods/simple-diff");
@@ -16,10 +17,25 @@ const project_info_1 = require("../project-info");
16
17
  const undo_stack_1 = require("../undo-stack");
17
18
  const can_update_default_props_1 = require("./can-update-default-props");
18
19
  const source_file_write_queue_1 = require("./source-file-write-queue");
19
- const formatNewCompositionFile = (componentName) => {
20
+ const formatNewCompositionFile = (codemod) => {
21
+ if (codemod.canvasCapture !== null) {
22
+ return (0, generate_canvas_capture_composition_1.generateCanvasCaptureComposition)({
23
+ componentName: codemod.componentName,
24
+ compositionId: codemod.newId,
25
+ data: codemod.canvasCapture.data,
26
+ durationInFrames: codemod.newDurationInFrames,
27
+ fps: codemod.newFps,
28
+ height: codemod.newHeight,
29
+ keyframeFps: codemod.canvasCapture.keyframeFps,
30
+ videoFileName: codemod.canvasCapture.videoFileName,
31
+ videoHeight: codemod.canvasCapture.videoHeight,
32
+ videoWidth: codemod.canvasCapture.videoWidth,
33
+ width: codemod.newWidth,
34
+ });
35
+ }
20
36
  return (0, duplicate_composition_1.formatOutput)(`import React from 'react';
21
37
 
22
- export const ${componentName}: React.FC = () => {
38
+ export const ${codemod.componentName}: React.FC = () => {
23
39
  return null;
24
40
  };
25
41
  `);
@@ -190,6 +206,7 @@ const applyCodemodHandler = ({ input: { codemod, dryRun, symbolicatedStack }, lo
190
206
  oldContents: input,
191
207
  newContents: null,
192
208
  logLine,
209
+ nodePathRemappings: null,
193
210
  },
194
211
  ];
195
212
  let componentFilePath = null;
@@ -199,12 +216,13 @@ const applyCodemodHandler = ({ input: { codemod, dryRun, symbolicatedStack }, lo
199
216
  if (componentFilePath === null) {
200
217
  throw new Error('Could not determine the new component file path');
201
218
  }
202
- componentFileContents = await formatNewCompositionFile(codemod.componentName);
219
+ componentFileContents = await formatNewCompositionFile(codemod);
203
220
  snapshots.push({
204
221
  filePath: componentFilePath,
205
222
  oldContents: null,
206
223
  newContents: componentFileContents,
207
224
  logLine: 1,
225
+ nodePathRemappings: null,
208
226
  });
209
227
  (0, undo_stack_1.pushTransactionToUndoStack)({
210
228
  snapshots,
@@ -232,15 +250,26 @@ const applyCodemodHandler = ({ input: { codemod, dryRun, symbolicatedStack }, lo
232
250
  },
233
251
  entryType,
234
252
  suppressHmrOnFileRestore: false,
253
+ nodePathRemappings: null,
235
254
  });
236
255
  }
237
256
  (0, undo_stack_1.suppressUndoStackInvalidation)(filePath);
238
257
  if (componentFilePath) {
239
258
  (0, undo_stack_1.suppressUndoStackInvalidation)(componentFilePath);
240
259
  }
241
- (0, file_watcher_1.writeFileAndNotifyFileWatchers)(filePath, formatted, undefined);
260
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)({
261
+ file: filePath,
262
+ content: formatted,
263
+ originatorClientId: undefined,
264
+ metadata: null,
265
+ });
242
266
  if (componentFilePath && componentFileContents !== null) {
243
- (0, file_watcher_1.writeFileAndNotifyFileWatchers)(componentFilePath, componentFileContents, undefined);
267
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)({
268
+ file: componentFilePath,
269
+ content: componentFileContents,
270
+ originatorClientId: undefined,
271
+ metadata: null,
272
+ });
244
273
  }
245
274
  const logMessage = (0, exports.getCodemodLogMessage)(codemod);
246
275
  const editMessage = `${renderer_1.RenderInternals.chalk.blueBright((0, format_log_file_location_1.formatLogFileLocation)({
@@ -123,10 +123,16 @@ const applyVisualControlHandler = ({ input: { fileName, changes }, remotionRoot,
123
123
  },
124
124
  entryType: 'visual-control',
125
125
  suppressHmrOnFileRestore: true,
126
+ nodePathRemappings: null,
126
127
  });
127
128
  (0, undo_stack_1.suppressUndoStackInvalidation)(absolutePath);
128
129
  (0, watch_ignore_next_change_1.suppressBundlerUpdateForFile)(absolutePath);
129
- (0, file_watcher_1.writeFileAndNotifyFileWatchers)(absolutePath, output, undefined);
130
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)({
131
+ file: absolutePath,
132
+ content: output,
133
+ originatorClientId: undefined,
134
+ metadata: null,
135
+ });
130
136
  (0, live_events_1.waitForLiveEventsListener)().then((listener) => {
131
137
  listener.sendEventToClient({
132
138
  type: 'visual-control-values-changed',
@@ -134,7 +134,10 @@ const batchUpdateKeyframeSettings = async ({ sequenceKeyframes, effectKeyframes,
134
134
  });
135
135
  }
136
136
  (0, undo_stack_1.pushTransactionToUndoStack)({
137
- snapshots,
137
+ snapshots: snapshots.map((snapshot) => ({
138
+ ...snapshot,
139
+ nodePathRemappings: null,
140
+ })),
138
141
  logLevel,
139
142
  remotionRoot,
140
143
  description: totalUpdates === 1
@@ -152,7 +155,12 @@ const batchUpdateKeyframeSettings = async ({ sequenceKeyframes, effectKeyframes,
152
155
  for (const snapshot of snapshots) {
153
156
  (0, undo_stack_1.suppressUndoStackInvalidation)(snapshot.filePath);
154
157
  (0, watch_ignore_next_change_1.suppressBundlerUpdateForFile)(snapshot.filePath);
155
- (0, file_watcher_1.writeFileAndNotifyFileWatchers)(snapshot.filePath, snapshot.newContents, clientId);
158
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)({
159
+ file: snapshot.filePath,
160
+ content: snapshot.newContents,
161
+ originatorClientId: clientId,
162
+ metadata: null,
163
+ });
156
164
  }
157
165
  for (const log of sequenceLogs) {
158
166
  (0, log_update_1.logUpdate)({
@@ -8,6 +8,7 @@ type StaticValueOptions = {
8
8
  export declare const isStaticValue: (node: Expression, options?: StaticValueOptions) => boolean;
9
9
  export declare const extractStaticValue: (node: Expression, options?: StaticValueOptions) => unknown;
10
10
  export declare const getComputedStatus: (node: Expression, ast: File, videoConfigValues: VideoConfigIdentifierValues) => CanUpdateSequencePropStatus;
11
+ export declare const getNodePathForRecastPath: (recastPath: any, ast: File) => SequenceNodePath;
11
12
  export declare const findJsxElementPathAtNodePath: (ast: File, nodePath: SequenceNodePath) => import("ast-types/lib/node-path").NodePath<N, V> | null;
12
13
  export declare const findJsxElementAtNodePath: (ast: File, nodePath: SequenceNodePath) => JSXOpeningElement | null;
13
14
  export declare const findJsxElementNodeAtNodePath: (ast: File, nodePath: SequenceNodePath) => JSXElement | null;
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.computeSequencePropsStatusFromFilenameByLocation = exports.computeSequencePropsStatus = exports.computeSequencePropsStatusFromContent = exports.lineColumnToNodePath = exports.findNodePathForJsxElement = exports.getStaticJsxTextContent = exports.hasJsxChildrenAttribute = exports.getStaticJsxChildrenAttribute = exports.findJsxElementNodeAtNodePath = exports.findJsxElementAtNodePath = exports.findJsxElementPathAtNodePath = exports.getComputedStatus = exports.extractStaticValue = exports.isStaticValue = void 0;
36
+ exports.computeSequencePropsStatusFromFilenameByLocation = exports.computeSequencePropsStatus = exports.computeSequencePropsStatusFromContent = exports.lineColumnToNodePath = exports.findNodePathForJsxElement = exports.getStaticJsxTextContent = exports.hasJsxChildrenAttribute = exports.getStaticJsxChildrenAttribute = exports.findJsxElementNodeAtNodePath = exports.findJsxElementAtNodePath = exports.findJsxElementPathAtNodePath = exports.getNodePathForRecastPath = exports.getComputedStatus = exports.extractStaticValue = exports.isStaticValue = void 0;
37
37
  const node_fs_1 = require("node:fs");
38
38
  const renderer_1 = require("@remotion/renderer");
39
39
  const studio_shared_1 = require("@remotion/studio-shared");
@@ -550,6 +550,7 @@ recastPath, ast) => {
550
550
  }
551
551
  return (0, import_agnostic_node_path_1.toImportAgnosticNodePath)({ ast, nodePath: segments });
552
552
  };
553
+ exports.getNodePathForRecastPath = getNodePathForRecastPath;
553
554
  const findJsxElementPathAtNodePath = (ast, nodePath) => {
554
555
  const current = (0, get_ast_node_path_1.getAstNodePath)(ast, nodePath);
555
556
  if (!current) {
@@ -637,7 +638,7 @@ const findNodePathForJsxElement = (ast, target) => {
637
638
  recast.types.visit(ast, {
638
639
  visitJSXOpeningElement(p) {
639
640
  if (p.node === target) {
640
- foundPath = getNodePathForRecastPath(p, ast);
641
+ foundPath = (0, exports.getNodePathForRecastPath)(p, ast);
641
642
  return false;
642
643
  }
643
644
  return this.traverse(p);
@@ -678,7 +679,7 @@ const lineColumnToNodePath = (ast, targetLine, targetColumn, fileContents) => {
678
679
  visitJSXOpeningElement(p) {
679
680
  const { node } = p;
680
681
  if (node.loc && node.loc.start.line === targetLine) {
681
- const nodePath = getNodePathForRecastPath(p, ast);
682
+ const nodePath = (0, exports.getNodePathForRecastPath)(p, ast);
682
683
  lineMatches.push(nodePath);
683
684
  if (node.loc.start.column === recastTargetColumn) {
684
685
  exactMatches.push(nodePath);
@@ -696,7 +697,7 @@ exports.lineColumnToNodePath = lineColumnToNodePath;
696
697
  const PIXEL_VALUE_REGEX = /^-?\d+(\.\d+)?px$/;
697
698
  const isSupportedTranslateValue = (value) => {
698
699
  const parts = value.split(/\s+/);
699
- if (parts.length === 1 || parts.length === 2) {
700
+ if (parts.length >= 1 && parts.length <= 3) {
700
701
  return parts.every((part) => PIXEL_VALUE_REGEX.test(part));
701
702
  }
702
703
  return false;
@@ -2,16 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.openInCodingAgentHandler = exports.getDefaultCodingAgentInfoHandler = void 0;
4
4
  const coding_agent_registry_1 = require("../../helpers/coding-agent-registry");
5
+ const terminal_registry_1 = require("../../helpers/terminal-registry");
5
6
  const getDefaultCodingAgentInfoHandler = async ({ getDefaultCodingAgent }) => {
6
7
  const installedCodingAgents = await (0, coding_agent_registry_1.getAvailableCodingAgents)();
8
+ const installedTerminals = await (0, terminal_registry_1.getAvailableTerminals)();
7
9
  return {
8
10
  defaultCodingAgent: getDefaultCodingAgent(),
9
- installedCodingAgents: installedCodingAgents.map(({ iconDataUrl, id, name, nameWithType }) => ({
10
- iconDataUrl,
11
+ installedCodingAgents: installedCodingAgents.map(({ id, name, nameWithType }) => ({
11
12
  id,
12
13
  name,
13
14
  nameWithType,
14
15
  })),
16
+ installedTerminals: installedTerminals.map(({ id, name }) => ({ id, name })),
15
17
  };
16
18
  };
17
19
  exports.getDefaultCodingAgentInfoHandler = getDefaultCodingAgentInfoHandler;
@@ -76,9 +76,15 @@ const deleteEffectHandler = ({ input: effects, remotionRoot, logLevel }) => {
76
76
  },
77
77
  entryType: 'delete-effect',
78
78
  suppressHmrOnFileRestore: false,
79
+ nodePathRemappings: null,
79
80
  });
80
81
  (0, undo_stack_1.suppressUndoStackInvalidation)(update.absolutePath);
81
- (0, file_watcher_1.writeFileAndNotifyFileWatchers)(update.absolutePath, update.output, undefined);
82
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)({
83
+ file: update.absolutePath,
84
+ content: update.output,
85
+ originatorClientId: undefined,
86
+ metadata: null,
87
+ });
82
88
  const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
83
89
  remotionRoot,
84
90
  absolutePath: update.absolutePath,
@@ -7,6 +7,7 @@ const delete_jsx_node_1 = require("../../codemods/delete-jsx-node");
7
7
  const file_watcher_1 = require("../../file-watcher");
8
8
  const resolve_file_inside_project_1 = require("../../helpers/resolve-file-inside-project");
9
9
  const format_log_file_location_1 = require("../format-log-file-location");
10
+ const sequence_node_path_mutation_1 = require("../sequence-node-path-mutation");
10
11
  const undo_stack_1 = require("../undo-stack");
11
12
  const log_update_1 = require("./log-updates/log-update");
12
13
  const source_file_write_queue_1 = require("./source-file-write-queue");
@@ -37,7 +38,7 @@ const deleteJsxNodeHandler = ({ input: { nodes }, remotionRoot, logLevel }) => {
37
38
  action: 'modify',
38
39
  });
39
40
  const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
40
- const { output, formatted, nodeLabels, logLines } = await (0, delete_jsx_node_1.deleteJsxNodes)({
41
+ const { output, formatted, nodeLabels, logLines, nodePathRemappings } = await (0, delete_jsx_node_1.deleteJsxNodes)({
41
42
  input: fileContents,
42
43
  nodePaths: fileItems.map((item) => item.nodePath),
43
44
  });
@@ -48,9 +49,15 @@ const deleteJsxNodeHandler = ({ input: { nodes }, remotionRoot, logLevel }) => {
48
49
  output,
49
50
  formatted,
50
51
  nodeLabels,
52
+ nodePathRemappings,
51
53
  logLine: Math.min(...logLines),
52
54
  };
53
55
  }));
56
+ const nodePathMutation = (0, sequence_node_path_mutation_1.broadcastSequenceNodePathMutation)(updates.map((update) => ({
57
+ absolutePath: update.absolutePath,
58
+ remappings: update.nodePathRemappings,
59
+ restoredNodePaths: [],
60
+ })));
54
61
  for (const update of updates) {
55
62
  const deletedNodeDescription = getDeletedNodeDescription(update.nodeLabels);
56
63
  (0, undo_stack_1.pushToUndoStack)({
@@ -66,9 +73,15 @@ const deleteJsxNodeHandler = ({ input: { nodes }, remotionRoot, logLevel }) => {
66
73
  },
67
74
  entryType: 'delete-jsx-node',
68
75
  suppressHmrOnFileRestore: false,
76
+ nodePathRemappings: update.nodePathRemappings,
69
77
  });
70
78
  (0, undo_stack_1.suppressUndoStackInvalidation)(update.absolutePath);
71
- (0, file_watcher_1.writeFileAndNotifyFileWatchers)(update.absolutePath, update.output, undefined);
79
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)({
80
+ file: update.absolutePath,
81
+ content: update.output,
82
+ originatorClientId: undefined,
83
+ metadata: { skipSequencePropsUpdate: true },
84
+ });
72
85
  const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
73
86
  remotionRoot,
74
87
  absolutePath: update.absolutePath,
@@ -83,6 +96,7 @@ const deleteJsxNodeHandler = ({ input: { nodes }, remotionRoot, logLevel }) => {
83
96
  (0, undo_stack_1.printUndoHint)(logLevel);
84
97
  return {
85
98
  success: true,
99
+ nodePathMutation,
86
100
  };
87
101
  }
88
102
  catch (err) {
@@ -173,7 +173,10 @@ const deleteKeyframes = async ({ sequenceKeyframes, effectKeyframes, clientId, r
173
173
  throw new Error('No keyframes were specified for deletion');
174
174
  }
175
175
  (0, undo_stack_1.pushTransactionToUndoStack)({
176
- snapshots,
176
+ snapshots: snapshots.map((snapshot) => ({
177
+ ...snapshot,
178
+ nodePathRemappings: null,
179
+ })),
177
180
  logLevel,
178
181
  remotionRoot,
179
182
  description: getBatchDescription({ totalKeyframes, firstKeyframe }),
@@ -187,7 +190,12 @@ const deleteKeyframes = async ({ sequenceKeyframes, effectKeyframes, clientId, r
187
190
  for (const snapshot of snapshots) {
188
191
  (0, undo_stack_1.suppressUndoStackInvalidation)(snapshot.filePath);
189
192
  (0, watch_ignore_next_change_1.suppressBundlerUpdateForFile)(snapshot.filePath);
190
- (0, file_watcher_1.writeFileAndNotifyFileWatchers)(snapshot.filePath, snapshot.newContents, clientId);
193
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)({
194
+ file: snapshot.filePath,
195
+ content: snapshot.newContents,
196
+ originatorClientId: clientId,
197
+ metadata: null,
198
+ });
191
199
  }
192
200
  for (const log of sequenceLogs) {
193
201
  (0, log_update_1.logUpdate)({
@@ -70,9 +70,15 @@ const duplicateEffectHandler = ({ input: effects, remotionRoot, logLevel }) => {
70
70
  },
71
71
  entryType: 'duplicate-effect',
72
72
  suppressHmrOnFileRestore: false,
73
+ nodePathRemappings: null,
73
74
  });
74
75
  (0, undo_stack_1.suppressUndoStackInvalidation)(update.absolutePath);
75
- (0, file_watcher_1.writeFileAndNotifyFileWatchers)(update.absolutePath, update.output, undefined);
76
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)({
77
+ file: update.absolutePath,
78
+ content: update.output,
79
+ originatorClientId: undefined,
80
+ metadata: null,
81
+ });
76
82
  const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
77
83
  remotionRoot,
78
84
  absolutePath: update.absolutePath,
@@ -7,6 +7,7 @@ const duplicate_jsx_node_1 = require("../../codemods/duplicate-jsx-node");
7
7
  const file_watcher_1 = require("../../file-watcher");
8
8
  const resolve_file_inside_project_1 = require("../../helpers/resolve-file-inside-project");
9
9
  const format_log_file_location_1 = require("../format-log-file-location");
10
+ const sequence_node_path_mutation_1 = require("../sequence-node-path-mutation");
10
11
  const undo_stack_1 = require("../undo-stack");
11
12
  const log_update_1 = require("./log-updates/log-update");
12
13
  const source_file_write_queue_1 = require("./source-file-write-queue");
@@ -20,10 +21,14 @@ const duplicateJsxNodeHandler = ({ input: { fileName, nodePath }, remotionRoot,
20
21
  action: 'modify',
21
22
  });
22
23
  const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
23
- const { output, formatted, nodeLabel, logLine } = await (0, duplicate_jsx_node_1.duplicateJsxNode)({
24
- input: fileContents,
25
- nodePath,
26
- });
24
+ const { output, formatted, nodeLabel, logLine, nodePathRemappings } = await (0, duplicate_jsx_node_1.duplicateJsxNode)({ input: fileContents, nodePath });
25
+ const nodePathMutation = (0, sequence_node_path_mutation_1.broadcastSequenceNodePathMutation)([
26
+ {
27
+ absolutePath,
28
+ remappings: nodePathRemappings,
29
+ restoredNodePaths: [],
30
+ },
31
+ ]);
27
32
  (0, undo_stack_1.pushToUndoStack)({
28
33
  filePath: absolutePath,
29
34
  oldContents: fileContents,
@@ -37,9 +42,15 @@ const duplicateJsxNodeHandler = ({ input: { fileName, nodePath }, remotionRoot,
37
42
  },
38
43
  entryType: 'duplicate-jsx-node',
39
44
  suppressHmrOnFileRestore: false,
45
+ nodePathRemappings,
40
46
  });
41
47
  (0, undo_stack_1.suppressUndoStackInvalidation)(absolutePath);
42
- (0, file_watcher_1.writeFileAndNotifyFileWatchers)(absolutePath, output, undefined);
48
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)({
49
+ file: absolutePath,
50
+ content: output,
51
+ originatorClientId: undefined,
52
+ metadata: { skipSequencePropsUpdate: true },
53
+ });
43
54
  const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
44
55
  remotionRoot,
45
56
  absolutePath,
@@ -53,6 +64,7 @@ const duplicateJsxNodeHandler = ({ input: { fileName, nodePath }, remotionRoot,
53
64
  (0, undo_stack_1.printUndoHint)(logLevel);
54
65
  return {
55
66
  success: true,
67
+ nodePathMutation,
56
68
  };
57
69
  }
58
70
  catch (err) {
@@ -5,6 +5,7 @@ const renderer_1 = require("@remotion/renderer");
5
5
  const file_watcher_1 = require("../../file-watcher");
6
6
  const resolve_composition_component_1 = require("../../helpers/resolve-composition-component");
7
7
  const format_log_file_location_1 = require("../format-log-file-location");
8
+ const sequence_node_path_mutation_1 = require("../sequence-node-path-mutation");
8
9
  const undo_stack_1 = require("../undo-stack");
9
10
  const element_install_plan_1 = require("./element-install-plan");
10
11
  const log_update_1 = require("./log-updates/log-update");
@@ -126,6 +127,13 @@ const insertElementHandler = ({ input: { compositionFile, compositionId, element
126
127
  })) {
127
128
  throw new Error('Element source changed during installation');
128
129
  }
130
+ const nodePathMutation = (0, sequence_node_path_mutation_1.broadcastSequenceNodePathMutation)([
131
+ {
132
+ absolutePath: inserted.fileName,
133
+ remappings: inserted.nodePathRemappings,
134
+ restoredNodePaths: [],
135
+ },
136
+ ]);
129
137
  (0, undo_stack_1.pushTransactionToUndoStack)({
130
138
  snapshots: [
131
139
  ...(shouldWriteElementFile
@@ -135,6 +143,7 @@ const insertElementHandler = ({ input: { compositionFile, compositionId, element
135
143
  oldContents: plan.existingElementSource,
136
144
  newContents: element.sourceCode,
137
145
  logLine: 1,
146
+ nodePathRemappings: null,
138
147
  },
139
148
  ]
140
149
  : []),
@@ -143,6 +152,7 @@ const insertElementHandler = ({ input: { compositionFile, compositionId, element
143
152
  oldContents: inserted.oldContents,
144
153
  newContents: inserted.output,
145
154
  logLine: inserted.logLine,
155
+ nodePathRemappings: inserted.nodePathRemappings,
146
156
  },
147
157
  ],
148
158
  logLevel,
@@ -159,9 +169,19 @@ const insertElementHandler = ({ input: { compositionFile, compositionId, element
159
169
  }
160
170
  (0, undo_stack_1.suppressUndoStackInvalidation)(inserted.fileName);
161
171
  if (shouldWriteElementFile) {
162
- (0, file_watcher_1.writeFileAndNotifyFileWatchers)(plan.elementFileName, element.sourceCode, undefined);
172
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)({
173
+ file: plan.elementFileName,
174
+ content: element.sourceCode,
175
+ originatorClientId: undefined,
176
+ metadata: null,
177
+ });
163
178
  }
164
- (0, file_watcher_1.writeFileAndNotifyFileWatchers)(inserted.fileName, inserted.output, undefined);
179
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)({
180
+ file: inserted.fileName,
181
+ content: inserted.output,
182
+ originatorClientId: undefined,
183
+ metadata: { skipSequencePropsUpdate: true },
184
+ });
165
185
  const compositionLocationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
166
186
  remotionRoot,
167
187
  absolutePath: inserted.fileName,
@@ -183,7 +203,7 @@ const insertElementHandler = ({ input: { compositionFile, compositionId, element
183
203
  (0, log_update_1.warnAboutPrettierOnce)(logLevel);
184
204
  }
185
205
  (0, undo_stack_1.printUndoHint)(logLevel);
186
- return { success: true };
206
+ return { success: true, nodePathMutation };
187
207
  }
188
208
  catch (err) {
189
209
  return {
@@ -11,6 +11,7 @@ const studio_shared_1 = require("@remotion/studio-shared");
11
11
  const file_watcher_1 = require("../../file-watcher");
12
12
  const resolve_composition_component_1 = require("../../helpers/resolve-composition-component");
13
13
  const format_log_file_location_1 = require("../format-log-file-location");
14
+ const sequence_node_path_mutation_1 = require("../sequence-node-path-mutation");
14
15
  const undo_stack_1 = require("../undo-stack");
15
16
  const log_update_1 = require("./log-updates/log-update");
16
17
  const source_file_write_queue_1 = require("./source-file-write-queue");
@@ -158,7 +159,7 @@ const insertJsxElementHandler = ({ input: { compositionFile, compositionId, elem
158
159
  }
159
160
  const elementLabel = getElementLabel(element);
160
161
  renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[insert-jsx-element] Received request for compositionFile="${compositionFile}" compositionId="${compositionId}" element="${element.type}"`);
161
- const { fileName, source, oldContents, output, formatted, logLine } = await (0, resolve_composition_component_1.insertJsxElementIntoComposition)({
162
+ const { fileName, source, oldContents, output, formatted, insertedNodePath, logLine, nodePathRemappings, } = await (0, resolve_composition_component_1.insertJsxElementIntoComposition)({
162
163
  remotionRoot,
163
164
  compositionFile,
164
165
  compositionId,
@@ -166,6 +167,16 @@ const insertJsxElementHandler = ({ input: { compositionFile, compositionId, elem
166
167
  from,
167
168
  prettierConfigOverride: null,
168
169
  });
170
+ const nodePathMutation = (0, sequence_node_path_mutation_1.broadcastSequenceNodePathMutation)([
171
+ {
172
+ absolutePath: fileName,
173
+ remappings: nodePathRemappings,
174
+ restoredNodePaths: [],
175
+ },
176
+ ]);
177
+ if (insertedNodePath === null) {
178
+ renderer_1.RenderInternals.Log.warn({ indent: false, logLevel }, 'Could not determine the inserted JSX element node path. Skipping automatic selection.');
179
+ }
169
180
  (0, undo_stack_1.pushToUndoStack)({
170
181
  filePath: fileName,
171
182
  oldContents,
@@ -179,9 +190,15 @@ const insertJsxElementHandler = ({ input: { compositionFile, compositionId, elem
179
190
  },
180
191
  entryType: 'insert-jsx-element',
181
192
  suppressHmrOnFileRestore: false,
193
+ nodePathRemappings,
182
194
  });
183
195
  (0, undo_stack_1.suppressUndoStackInvalidation)(fileName);
184
- (0, file_watcher_1.writeFileAndNotifyFileWatchers)(fileName, output, undefined);
196
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)({
197
+ file: fileName,
198
+ content: output,
199
+ originatorClientId: undefined,
200
+ metadata: { skipSequencePropsUpdate: true },
201
+ });
185
202
  const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
186
203
  remotionRoot,
187
204
  absolutePath: fileName,
@@ -195,6 +212,10 @@ const insertJsxElementHandler = ({ input: { compositionFile, compositionId, elem
195
212
  (0, undo_stack_1.printUndoHint)(logLevel);
196
213
  return {
197
214
  success: true,
215
+ insertedNodePath: insertedNodePath === null
216
+ ? null
217
+ : { absolutePath: fileName, nodePath: insertedNodePath },
218
+ nodePathMutation,
198
219
  };
199
220
  }
200
221
  catch (err) {
@@ -182,7 +182,10 @@ const moveKeyframes = async ({ sequenceKeyframes, effectKeyframes, clientId, rem
182
182
  throw new Error('No keyframes were specified for moving');
183
183
  }
184
184
  (0, undo_stack_1.pushTransactionToUndoStack)({
185
- snapshots,
185
+ snapshots: snapshots.map((snapshot) => ({
186
+ ...snapshot,
187
+ nodePathRemappings: null,
188
+ })),
186
189
  logLevel,
187
190
  remotionRoot,
188
191
  description: getBatchDescription({ totalKeyframes, firstKeyframe }),
@@ -196,7 +199,12 @@ const moveKeyframes = async ({ sequenceKeyframes, effectKeyframes, clientId, rem
196
199
  for (const snapshot of snapshots) {
197
200
  (0, undo_stack_1.suppressUndoStackInvalidation)(snapshot.filePath);
198
201
  (0, watch_ignore_next_change_1.suppressBundlerUpdateForFile)(snapshot.filePath);
199
- (0, file_watcher_1.writeFileAndNotifyFileWatchers)(snapshot.filePath, snapshot.newContents, clientId);
202
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)({
203
+ file: snapshot.filePath,
204
+ content: snapshot.newContents,
205
+ originatorClientId: clientId,
206
+ metadata: null,
207
+ });
200
208
  }
201
209
  for (const log of sequenceLogs) {
202
210
  (0, log_update_1.logUpdate)({
@@ -0,0 +1,3 @@
1
+ import type { OpenInTerminalRequest, OpenInTerminalResponse } from '@remotion/studio-shared';
2
+ import type { ApiHandler } from '../api-types';
3
+ export declare const openInTerminalHandler: ApiHandler<OpenInTerminalRequest, OpenInTerminalResponse>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.openInTerminalHandler = void 0;
4
+ const terminal_registry_1 = require("../../helpers/terminal-registry");
5
+ const openInTerminalHandler = async ({ input, remotionRoot }) => {
6
+ const terminal = (await (0, terminal_registry_1.getAvailableTerminals)()).find(({ id }) => id === input.terminalId);
7
+ if (!terminal) {
8
+ return { success: false };
9
+ }
10
+ await (0, terminal_registry_1.launchTerminal)({
11
+ allowedDirectory: remotionRoot,
12
+ directory: input.directory,
13
+ terminal,
14
+ });
15
+ return { success: true };
16
+ };
17
+ exports.openInTerminalHandler = openInTerminalHandler;
@@ -52,9 +52,15 @@ const pasteEffectsHandler = ({ input: { targetFileName, targetSequenceNodePath,
52
52
  },
53
53
  entryType: 'paste-effects',
54
54
  suppressHmrOnFileRestore: false,
55
+ nodePathRemappings: null,
55
56
  });
56
57
  (0, undo_stack_1.suppressUndoStackInvalidation)(absolutePath);
57
- (0, file_watcher_1.writeFileAndNotifyFileWatchers)(absolutePath, output, clientId);
58
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)({
59
+ file: absolutePath,
60
+ content: output,
61
+ originatorClientId: clientId,
62
+ metadata: null,
63
+ });
58
64
  const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
59
65
  remotionRoot,
60
66
  absolutePath,
@@ -40,9 +40,15 @@ const reorderEffectHandler = ({ input: { fileName, sequenceNodePath, fromIndex,
40
40
  },
41
41
  entryType: 'reorder-effect',
42
42
  suppressHmrOnFileRestore: false,
43
+ nodePathRemappings: null,
43
44
  });
44
45
  (0, undo_stack_1.suppressUndoStackInvalidation)(absolutePath);
45
- (0, file_watcher_1.writeFileAndNotifyFileWatchers)(absolutePath, output, clientId);
46
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)({
47
+ file: absolutePath,
48
+ content: output,
49
+ originatorClientId: clientId,
50
+ metadata: null,
51
+ });
46
52
  const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
47
53
  remotionRoot,
48
54
  absolutePath,
@@ -7,6 +7,7 @@ const reorder_sequence_1 = require("../../codemods/reorder-sequence");
7
7
  const file_watcher_1 = require("../../file-watcher");
8
8
  const resolve_file_inside_project_1 = require("../../helpers/resolve-file-inside-project");
9
9
  const format_log_file_location_1 = require("../format-log-file-location");
10
+ const sequence_node_path_mutation_1 = require("../sequence-node-path-mutation");
10
11
  const undo_stack_1 = require("../undo-stack");
11
12
  const formatting_1 = require("./log-updates/formatting");
12
13
  const log_update_1 = require("./log-updates/log-update");
@@ -21,12 +22,19 @@ const reorderSequenceHandler = ({ input: { fileName, sourceNodePath, targetNodeP
21
22
  action: 'modify',
22
23
  });
23
24
  const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
24
- const { output, formatted, sequenceLabel, logLine } = await (0, reorder_sequence_1.reorderSequence)({
25
+ const { output, formatted, sequenceLabel, logLine, nodePathRemappings } = await (0, reorder_sequence_1.reorderSequence)({
25
26
  input: fileContents,
26
27
  sourceNodePath: sourceNodePath.nodePath,
27
28
  targetNodePath: targetNodePath.nodePath,
28
29
  position,
29
30
  });
31
+ const nodePathMutation = (0, sequence_node_path_mutation_1.broadcastSequenceNodePathMutation)([
32
+ {
33
+ absolutePath,
34
+ remappings: nodePathRemappings,
35
+ restoredNodePaths: [],
36
+ },
37
+ ]);
30
38
  (0, undo_stack_1.pushToUndoStack)({
31
39
  filePath: absolutePath,
32
40
  oldContents: fileContents,
@@ -40,9 +48,15 @@ const reorderSequenceHandler = ({ input: { fileName, sourceNodePath, targetNodeP
40
48
  },
41
49
  entryType: 'reorder-sequence',
42
50
  suppressHmrOnFileRestore: false,
51
+ nodePathRemappings,
43
52
  });
44
53
  (0, undo_stack_1.suppressUndoStackInvalidation)(absolutePath);
45
- (0, file_watcher_1.writeFileAndNotifyFileWatchers)(absolutePath, output, clientId);
54
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)({
55
+ file: absolutePath,
56
+ content: output,
57
+ originatorClientId: clientId,
58
+ metadata: { skipSequencePropsUpdate: true },
59
+ });
46
60
  const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
47
61
  remotionRoot,
48
62
  absolutePath,
@@ -56,6 +70,7 @@ const reorderSequenceHandler = ({ input: { fileName, sourceNodePath, targetNodeP
56
70
  (0, undo_stack_1.printUndoHint)(logLevel);
57
71
  return {
58
72
  success: true,
73
+ nodePathMutation,
59
74
  };
60
75
  }
61
76
  catch (err) {