@remotion/studio-server 4.0.507 → 4.0.508

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 (66) hide show
  1. package/dist/codemods/delete-jsx-node.d.ts +4 -0
  2. package/dist/codemods/delete-jsx-node.js +8 -0
  3. package/dist/codemods/duplicate-jsx-node.d.ts +2 -0
  4. package/dist/codemods/duplicate-jsx-node.js +8 -0
  5. package/dist/codemods/get-node-path-remappings.d.ts +13 -0
  6. package/dist/codemods/get-node-path-remappings.js +87 -0
  7. package/dist/codemods/reorder-sequence.d.ts +2 -1
  8. package/dist/codemods/reorder-sequence.js +8 -0
  9. package/dist/codemods/split-jsx-sequence.d.ts +2 -0
  10. package/dist/codemods/split-jsx-sequence.js +8 -0
  11. package/dist/file-watcher.d.ts +11 -1
  12. package/dist/file-watcher.js +16 -5
  13. package/dist/helpers/coding-agent-registry.d.ts +0 -1
  14. package/dist/helpers/coding-agent-registry.js +1 -5
  15. package/dist/helpers/finder-artwork.d.ts +1 -0
  16. package/dist/helpers/finder-artwork.js +4 -0
  17. package/dist/helpers/resolve-composition-component.d.ts +2 -1
  18. package/dist/helpers/resolve-composition-component.js +60 -68
  19. package/dist/helpers/terminal-artwork.d.ts +6 -0
  20. package/dist/helpers/terminal-artwork.js +14 -0
  21. package/dist/helpers/terminal-registry.d.ts +36 -0
  22. package/dist/helpers/terminal-registry.js +401 -0
  23. package/dist/index.d.ts +6 -1
  24. package/dist/preview-server/api-routes.js +2 -0
  25. package/dist/preview-server/live-events.d.ts +1 -0
  26. package/dist/preview-server/live-events.js +3 -1
  27. package/dist/preview-server/routes/add-effect-keyframe.js +7 -1
  28. package/dist/preview-server/routes/add-effect.js +7 -1
  29. package/dist/preview-server/routes/add-keyframes.js +10 -2
  30. package/dist/preview-server/routes/add-sequence-keyframe.js +7 -1
  31. package/dist/preview-server/routes/app-icon.d.ts +6 -0
  32. package/dist/preview-server/routes/app-icon.js +66 -0
  33. package/dist/preview-server/routes/apply-codemod.js +15 -2
  34. package/dist/preview-server/routes/apply-visual-control-change.js +7 -1
  35. package/dist/preview-server/routes/batch-update-keyframe-settings.js +10 -2
  36. package/dist/preview-server/routes/can-update-sequence-props.d.ts +1 -0
  37. package/dist/preview-server/routes/can-update-sequence-props.js +5 -4
  38. package/dist/preview-server/routes/default-coding-agent.js +4 -2
  39. package/dist/preview-server/routes/delete-effect.js +7 -1
  40. package/dist/preview-server/routes/delete-jsx-node.js +16 -2
  41. package/dist/preview-server/routes/delete-keyframes.js +10 -2
  42. package/dist/preview-server/routes/duplicate-effect.js +7 -1
  43. package/dist/preview-server/routes/duplicate-jsx-node.js +17 -5
  44. package/dist/preview-server/routes/insert-element.js +23 -3
  45. package/dist/preview-server/routes/insert-jsx-element.js +17 -2
  46. package/dist/preview-server/routes/move-keyframes.js +10 -2
  47. package/dist/preview-server/routes/open-in-terminal.d.ts +3 -0
  48. package/dist/preview-server/routes/open-in-terminal.js +17 -0
  49. package/dist/preview-server/routes/paste-effects.js +7 -1
  50. package/dist/preview-server/routes/reorder-effect.js +7 -1
  51. package/dist/preview-server/routes/reorder-sequence.js +17 -2
  52. package/dist/preview-server/routes/save-effect-props.js +7 -1
  53. package/dist/preview-server/routes/save-multiple-effect-props.js +10 -2
  54. package/dist/preview-server/routes/save-sequence-props.js +10 -2
  55. package/dist/preview-server/routes/split-jsx-sequence.js +17 -6
  56. package/dist/preview-server/routes/update-config.js +6 -1
  57. package/dist/preview-server/routes/update-default-props.js +7 -1
  58. package/dist/preview-server/routes/update-effect-keyframe-settings.js +7 -1
  59. package/dist/preview-server/routes/update-sequence-keyframe-settings.js +7 -1
  60. package/dist/preview-server/sequence-node-path-mutation.d.ts +7 -0
  61. package/dist/preview-server/sequence-node-path-mutation.js +21 -0
  62. package/dist/preview-server/sequence-props-watchers.js +15 -6
  63. package/dist/preview-server/undo-stack.d.ts +7 -13
  64. package/dist/preview-server/undo-stack.js +58 -5
  65. package/dist/routes.js +8 -0
  66. package/package.json +8 -8
@@ -41,9 +41,15 @@ const addEffectHandler = ({ input: { fileName, sequenceNodePath, effectName, eff
41
41
  },
42
42
  entryType: 'add-effect',
43
43
  suppressHmrOnFileRestore: false,
44
+ nodePathRemappings: null,
44
45
  });
45
46
  (0, undo_stack_1.suppressUndoStackInvalidation)(absolutePath);
46
- (0, file_watcher_1.writeFileAndNotifyFileWatchers)(absolutePath, output, clientId);
47
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)({
48
+ file: absolutePath,
49
+ content: output,
50
+ originatorClientId: clientId,
51
+ metadata: null,
52
+ });
47
53
  const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
48
54
  remotionRoot,
49
55
  absolutePath,
@@ -164,7 +164,10 @@ const addKeyframes = async ({ sequenceKeyframes, effectKeyframes, clientId, remo
164
164
  throw new Error('No keyframes were specified for adding');
165
165
  }
166
166
  (0, undo_stack_1.pushTransactionToUndoStack)({
167
- snapshots,
167
+ snapshots: snapshots.map((snapshot) => ({
168
+ ...snapshot,
169
+ nodePathRemappings: null,
170
+ })),
168
171
  logLevel,
169
172
  remotionRoot,
170
173
  description: getBatchDescription({ totalKeyframes, firstKeyframe }),
@@ -180,7 +183,12 @@ const addKeyframes = async ({ sequenceKeyframes, effectKeyframes, clientId, remo
180
183
  for (const snapshot of snapshots) {
181
184
  (0, undo_stack_1.suppressUndoStackInvalidation)(snapshot.filePath);
182
185
  (0, watch_ignore_next_change_1.suppressBundlerUpdateForFile)(snapshot.filePath);
183
- (0, file_watcher_1.writeFileAndNotifyFileWatchers)(snapshot.filePath, snapshot.newContents, clientId);
186
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)({
187
+ file: snapshot.filePath,
188
+ content: snapshot.newContents,
189
+ originatorClientId: clientId,
190
+ metadata: null,
191
+ });
184
192
  }
185
193
  for (const log of sequenceLogs) {
186
194
  (0, log_update_1.logUpdate)({
@@ -54,10 +54,16 @@ const addSequenceKeyframeHandler = ({ input: { fileName, nodePath, key, frame, v
54
54
  },
55
55
  entryType: 'sequence-props',
56
56
  suppressHmrOnFileRestore: true,
57
+ nodePathRemappings: null,
57
58
  });
58
59
  (0, undo_stack_1.suppressUndoStackInvalidation)(absolutePath);
59
60
  (0, watch_ignore_next_change_1.suppressBundlerUpdateForFile)(absolutePath);
60
- (0, file_watcher_1.writeFileAndNotifyFileWatchers)(absolutePath, output, clientId);
61
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)({
62
+ file: absolutePath,
63
+ content: output,
64
+ originatorClientId: clientId,
65
+ metadata: null,
66
+ });
61
67
  (0, log_update_1.logUpdate)({
62
68
  fileRelativeToRoot,
63
69
  line: logLine,
@@ -0,0 +1,6 @@
1
+ import type { IncomingMessage, ServerResponse } from 'node:http';
2
+ export declare const handleAppIcon: ({ request, response, pathname, }: {
3
+ request: IncomingMessage;
4
+ response: ServerResponse<IncomingMessage>;
5
+ pathname: string;
6
+ }) => Promise<void>;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.handleAppIcon = void 0;
7
+ const node_buffer_1 = require("node:buffer");
8
+ const node_fs_1 = require("node:fs");
9
+ const node_path_1 = __importDefault(require("node:path"));
10
+ const renderer_1 = require("@remotion/renderer");
11
+ const finder_artwork_1 = require("../../helpers/finder-artwork");
12
+ const terminal_artwork_1 = require("../../helpers/terminal-artwork");
13
+ const validate_same_origin_1 = require("../validate-same-origin");
14
+ const respondWithNotFound = (response) => {
15
+ response.writeHead(404);
16
+ response.end('App icon not found.');
17
+ };
18
+ const handleAppIcon = ({ request, response, pathname, }) => {
19
+ if (request.method !== 'GET') {
20
+ response.writeHead(405, { Allow: 'GET' });
21
+ response.end('Method not allowed.');
22
+ return Promise.resolve();
23
+ }
24
+ (0, validate_same_origin_1.validateSameOrigin)(request);
25
+ const match = /^\/api\/app-icon\/(coding-agent|file-manager|terminal)\/([a-z0-9-]+)\.png$/.exec(pathname);
26
+ if (!match) {
27
+ respondWithNotFound(response);
28
+ return Promise.resolve();
29
+ }
30
+ const [, kind, id] = match;
31
+ if (kind === 'coding-agent') {
32
+ if (!renderer_1.defaultCodingAgentIds.includes(id)) {
33
+ respondWithNotFound(response);
34
+ return Promise.resolve();
35
+ }
36
+ const filePath = node_path_1.default.join(__dirname, '..', '..', '..', 'web', 'coding-agent-icons', `${id}.png`);
37
+ const stat = (0, node_fs_1.statSync)(filePath);
38
+ response.writeHead(200, {
39
+ 'Cache-Control': 'public, max-age=3600',
40
+ 'Content-Length': stat.size,
41
+ 'Content-Type': 'image/png',
42
+ });
43
+ (0, node_fs_1.createReadStream)(filePath).pipe(response);
44
+ return Promise.resolve();
45
+ }
46
+ const dataUrl = kind === 'file-manager'
47
+ ? id === 'finder'
48
+ ? finder_artwork_1.finderArtworkDataUrl
49
+ : null
50
+ : Object.hasOwn(terminal_artwork_1.terminalArtworkDataUrls, id)
51
+ ? terminal_artwork_1.terminalArtworkDataUrls[id]
52
+ : null;
53
+ if (dataUrl === null) {
54
+ respondWithNotFound(response);
55
+ return Promise.resolve();
56
+ }
57
+ const image = node_buffer_1.Buffer.from(dataUrl.slice(dataUrl.indexOf(',') + 1), 'base64');
58
+ response.writeHead(200, {
59
+ 'Cache-Control': 'public, max-age=3600',
60
+ 'Content-Length': image.length,
61
+ 'Content-Type': 'image/png',
62
+ });
63
+ response.end(image);
64
+ return Promise.resolve();
65
+ };
66
+ exports.handleAppIcon = handleAppIcon;
@@ -190,6 +190,7 @@ const applyCodemodHandler = ({ input: { codemod, dryRun, symbolicatedStack }, lo
190
190
  oldContents: input,
191
191
  newContents: null,
192
192
  logLine,
193
+ nodePathRemappings: null,
193
194
  },
194
195
  ];
195
196
  let componentFilePath = null;
@@ -205,6 +206,7 @@ const applyCodemodHandler = ({ input: { codemod, dryRun, symbolicatedStack }, lo
205
206
  oldContents: null,
206
207
  newContents: componentFileContents,
207
208
  logLine: 1,
209
+ nodePathRemappings: null,
208
210
  });
209
211
  (0, undo_stack_1.pushTransactionToUndoStack)({
210
212
  snapshots,
@@ -232,15 +234,26 @@ const applyCodemodHandler = ({ input: { codemod, dryRun, symbolicatedStack }, lo
232
234
  },
233
235
  entryType,
234
236
  suppressHmrOnFileRestore: false,
237
+ nodePathRemappings: null,
235
238
  });
236
239
  }
237
240
  (0, undo_stack_1.suppressUndoStackInvalidation)(filePath);
238
241
  if (componentFilePath) {
239
242
  (0, undo_stack_1.suppressUndoStackInvalidation)(componentFilePath);
240
243
  }
241
- (0, file_watcher_1.writeFileAndNotifyFileWatchers)(filePath, formatted, undefined);
244
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)({
245
+ file: filePath,
246
+ content: formatted,
247
+ originatorClientId: undefined,
248
+ metadata: null,
249
+ });
242
250
  if (componentFilePath && componentFileContents !== null) {
243
- (0, file_watcher_1.writeFileAndNotifyFileWatchers)(componentFilePath, componentFileContents, undefined);
251
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)({
252
+ file: componentFilePath,
253
+ content: componentFileContents,
254
+ originatorClientId: undefined,
255
+ metadata: null,
256
+ });
244
257
  }
245
258
  const logMessage = (0, exports.getCodemodLogMessage)(codemod);
246
259
  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, logLine, nodePathRemappings, } = await (0, resolve_composition_component_1.insertJsxElementIntoComposition)({
162
163
  remotionRoot,
163
164
  compositionFile,
164
165
  compositionId,
@@ -166,6 +167,13 @@ 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
+ ]);
169
177
  (0, undo_stack_1.pushToUndoStack)({
170
178
  filePath: fileName,
171
179
  oldContents,
@@ -179,9 +187,15 @@ const insertJsxElementHandler = ({ input: { compositionFile, compositionId, elem
179
187
  },
180
188
  entryType: 'insert-jsx-element',
181
189
  suppressHmrOnFileRestore: false,
190
+ nodePathRemappings,
182
191
  });
183
192
  (0, undo_stack_1.suppressUndoStackInvalidation)(fileName);
184
- (0, file_watcher_1.writeFileAndNotifyFileWatchers)(fileName, output, undefined);
193
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)({
194
+ file: fileName,
195
+ content: output,
196
+ originatorClientId: undefined,
197
+ metadata: { skipSequencePropsUpdate: true },
198
+ });
185
199
  const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
186
200
  remotionRoot,
187
201
  absolutePath: fileName,
@@ -195,6 +209,7 @@ const insertJsxElementHandler = ({ input: { compositionFile, compositionId, elem
195
209
  (0, undo_stack_1.printUndoHint)(logLevel);
196
210
  return {
197
211
  success: true,
212
+ nodePathMutation,
198
213
  };
199
214
  }
200
215
  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;