@remotion/studio-server 4.0.527 → 4.0.528

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 (47) hide show
  1. package/dist/codemods/apply-codemod-to-file.d.ts +2 -1
  2. package/dist/codemods/apply-codemod-to-file.js +141 -8
  3. package/dist/codemods/update-effect-props/update-effect-props.d.ts +6 -33
  4. package/dist/codemods/update-effect-props/update-effect-props.js +16 -6
  5. package/dist/codemods/update-keyframes/update-keyframes.d.ts +24 -65
  6. package/dist/codemods/update-keyframes/update-keyframes.js +23 -5
  7. package/dist/codemods/update-sequence-props/update-sequence-props.d.ts +2 -17
  8. package/dist/codemods/update-sequence-props/update-sequence-props.js +15 -8
  9. package/dist/helpers/open-file-for-writing-without-symlinks.d.ts +6 -1
  10. package/dist/helpers/open-file-for-writing-without-symlinks.js +9 -6
  11. package/dist/index.d.ts +0 -22
  12. package/dist/index.js +0 -7
  13. package/dist/preview-server/api-routes.js +4 -0
  14. package/dist/preview-server/hot-middleware/index.js +13 -46
  15. package/dist/preview-server/routes/add-effect.js +16 -8
  16. package/dist/preview-server/routes/apply-codemod.d.ts +0 -19
  17. package/dist/preview-server/routes/apply-codemod.js +22 -25
  18. package/dist/preview-server/routes/apply-visual-control-change.js +12 -65
  19. package/dist/preview-server/routes/can-update-sequence-props.d.ts +0 -10
  20. package/dist/preview-server/routes/can-update-sequence-props.js +39 -505
  21. package/dist/preview-server/routes/delete-effect.js +14 -13
  22. package/dist/preview-server/routes/delete-jsx-nodes.js +15 -4
  23. package/dist/preview-server/routes/download-remote-asset.d.ts +5 -0
  24. package/dist/preview-server/routes/download-remote-asset.js +25 -20
  25. package/dist/preview-server/routes/duplicate-effect.js +11 -4
  26. package/dist/preview-server/routes/duplicate-jsx-node.js +14 -4
  27. package/dist/preview-server/routes/insert-element.js +399 -280
  28. package/dist/preview-server/routes/install-dependency.js +14 -4
  29. package/dist/preview-server/routes/prepare-element-install.js +3 -0
  30. package/dist/preview-server/routes/reorder-effect.js +11 -5
  31. package/dist/preview-server/routes/reorder-sequence.js +9 -5
  32. package/dist/preview-server/routes/replace-video-source.d.ts +3 -0
  33. package/dist/preview-server/routes/replace-video-source.js +81 -0
  34. package/dist/preview-server/routes/save-sequence-props.js +5 -26
  35. package/dist/preview-server/routes/split-jsx-sequence.js +13 -5
  36. package/dist/preview-server/routes/split-video-from-audio.js +8 -4
  37. package/dist/preview-server/routes/subscribe-to-sequence-props.js +6 -10
  38. package/dist/preview-server/routes/update-config.js +38 -2
  39. package/dist/preview-server/routes/update-default-props.js +11 -8
  40. package/dist/preview-server/routes/wrap-jsx-node.d.ts +3 -0
  41. package/dist/preview-server/routes/wrap-jsx-node.js +97 -0
  42. package/dist/preview-server/studio-protocol/handle-discovery.js +1 -1
  43. package/dist/preview-server/studio-protocol/handle-element-library.js +3 -3
  44. package/dist/preview-server/undo-stack.d.ts +2 -1
  45. package/dist/preview-server/undo-stack.js +19 -0
  46. package/dist/routes.js +2 -0
  47. package/package.json +8 -8
@@ -72,16 +72,26 @@ const handleInstallPackage = async ({ logLevel, remotionRoot, input: { dependenc
72
72
  YARN_ENABLE_SCRIPTS: 'false',
73
73
  },
74
74
  });
75
+ let stderr = '';
75
76
  cmd.on('error', reject);
76
77
  cmd.stdout.on('data', (d) => d
77
78
  .toString()
78
79
  .trim()
79
80
  .split('\n')
80
81
  .forEach((line) => renderer_1.RenderInternals.Log.info({ indent: true, logLevel }, line)));
81
- cmd.stdout.on('end', resolve);
82
- cmd.on('close', (code, signal) => code === 0
83
- ? resolve()
84
- : reject(new Error(`Command exited with code ${code} and signal ${signal}`)));
82
+ cmd.stderr.on('data', (data) => {
83
+ stderr += data.toString();
84
+ });
85
+ cmd.on('close', (code, signal) => {
86
+ if (code === 0) {
87
+ resolve();
88
+ return;
89
+ }
90
+ const packageManagerError = stderr.trim();
91
+ reject(new Error(packageManagerError.length > 0
92
+ ? `Package installation failed:\n${packageManagerError}`
93
+ : `Package installation failed: Command exited with code ${code} and signal ${signal}`));
94
+ });
85
95
  });
86
96
  await invalidateBundle();
87
97
  renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, renderer_1.RenderInternals.chalk.gray('╰─ '), `Done in ${Date.now() - time}ms`);
@@ -1,10 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.prepareElementInstallHandler = void 0;
4
+ const studio_protocol_1 = require("@remotion/studio-protocol");
4
5
  const element_install_plan_1 = require("./element-install-plan");
5
6
  const source_file_write_queue_1 = require("./source-file-write-queue");
6
7
  const prepareElementInstallHandler = ({ entryPoint, input, remotionRoot }) => (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
7
8
  try {
9
+ studio_protocol_1.StudioProtocolInternals.assertElementAssets(input.element.assets);
10
+ studio_protocol_1.StudioProtocolInternals.assertElementAssetReferences(input.element);
8
11
  const plan = await (0, element_install_plan_1.getElementInstallPlan)({
9
12
  ...input,
10
13
  entryPoint,
@@ -11,9 +11,10 @@ const undo_stack_1 = require("../undo-stack");
11
11
  const formatting_1 = require("./log-updates/formatting");
12
12
  const log_update_1 = require("./log-updates/log-update");
13
13
  const source_file_write_queue_1 = require("./source-file-write-queue");
14
- const { reorderEffect } = codemods_1.CodemodsInternals;
15
14
  const reorderEffectHandler = ({ input: { fileName, sequenceNodePath, fromIndex, toIndex, clientId }, remotionRoot, logLevel, }) => {
16
15
  return (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
16
+ var _a;
17
+ var _b;
17
18
  try {
18
19
  renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[reorder-effect] Received request for fileName="${fileName}" fromIndex=${fromIndex} toIndex=${toIndex}`);
19
20
  const { absolutePath, fileRelativeToRoot } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
@@ -22,12 +23,17 @@ const reorderEffectHandler = ({ input: { fileName, sequenceNodePath, fromIndex,
22
23
  action: 'modify',
23
24
  });
24
25
  const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
25
- const { output, formatted, effectLabel, logLine } = await reorderEffect({
26
- input: fileContents,
27
- sequenceNodePath: sequenceNodePath.nodePath,
28
- fromIndex,
26
+ const result = await (0, codemods_1.reorderEffect)({
27
+ project: { files: { [absolutePath]: fileContents }, rootDir: remotionRoot },
28
+ effect: {
29
+ filePath: absolutePath,
30
+ nodePath: sequenceNodePath.nodePath,
31
+ effectIndex: fromIndex,
32
+ },
29
33
  toIndex,
30
34
  });
35
+ const output = (_b = (_a = result.changes[0]) === null || _a === void 0 ? void 0 : _a.nextContents) !== null && _b !== void 0 ? _b : fileContents;
36
+ const { formatted, effectLabel, logLine } = result.editDetails[0];
31
37
  (0, undo_stack_1.pushToUndoStack)({
32
38
  filePath: absolutePath,
33
39
  oldContents: fileContents,
@@ -11,9 +11,10 @@ const sequence_node_path_mutation_1 = require("../sequence-node-path-mutation");
11
11
  const undo_stack_1 = require("../undo-stack");
12
12
  const formatting_1 = require("./log-updates/formatting");
13
13
  const source_file_write_queue_1 = require("./source-file-write-queue");
14
- const { reorderSequence } = codemods_1.CodemodsInternals;
15
14
  const reorderSequenceHandler = ({ input: { fileName, sourceNodePath, targetNodePath, position, clientId }, remotionRoot, logLevel, }) => {
16
15
  return (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
16
+ var _a;
17
+ var _b;
17
18
  try {
18
19
  renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[reorder-sequence] Received request for fileName="${fileName}" position=${position}`);
19
20
  const { absolutePath, fileRelativeToRoot } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
@@ -22,12 +23,15 @@ const reorderSequenceHandler = ({ input: { fileName, sourceNodePath, targetNodeP
22
23
  action: 'modify',
23
24
  });
24
25
  const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
25
- const { output, sequenceLabel, logLine, nodePathRemappings } = await reorderSequence({
26
- input: fileContents,
27
- sourceNodePath: sourceNodePath.nodePath,
28
- targetNodePath: targetNodePath.nodePath,
26
+ const result = await (0, codemods_1.reorderJsxNode)({
27
+ project: { files: { [absolutePath]: fileContents }, rootDir: remotionRoot },
28
+ node: { filePath: absolutePath, nodePath: sourceNodePath.nodePath },
29
+ target: { filePath: absolutePath, nodePath: targetNodePath.nodePath },
29
30
  position,
30
31
  });
32
+ const output = (_b = (_a = result.changes[0]) === null || _a === void 0 ? void 0 : _a.nextContents) !== null && _b !== void 0 ? _b : fileContents;
33
+ const { sequenceLabel, logLine } = result.editDetails[0];
34
+ const nodePathRemappings = result.nodePathRemappings.map(({ oldNodePath, newNodePath }) => ({ oldNodePath, newNodePath }));
31
35
  const nodePathMutation = (0, sequence_node_path_mutation_1.broadcastSequenceNodePathMutation)([
32
36
  {
33
37
  absolutePath,
@@ -0,0 +1,3 @@
1
+ import type { ReplaceVideoSourceRequest, ReplaceVideoSourceResponse } from '@remotion/studio-shared';
2
+ import type { ApiHandler } from '../api-types';
3
+ export declare const replaceVideoSourceHandler: ApiHandler<ReplaceVideoSourceRequest, ReplaceVideoSourceResponse>;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.replaceVideoSourceHandler = void 0;
4
+ const node_fs_1 = require("node:fs");
5
+ const codemods_1 = require("@remotion/codemods");
6
+ const renderer_1 = require("@remotion/renderer");
7
+ const no_react_1 = require("remotion/no-react");
8
+ const file_watcher_1 = require("../../file-watcher");
9
+ const resolve_file_inside_project_1 = require("../../helpers/resolve-file-inside-project");
10
+ const format_log_file_location_1 = require("../format-log-file-location");
11
+ const sequence_node_path_mutation_1 = require("../sequence-node-path-mutation");
12
+ const undo_stack_1 = require("../undo-stack");
13
+ const source_file_write_queue_1 = require("./source-file-write-queue");
14
+ const replaceVideoSourceHandler = ({ input: { fileName, nodePath, src }, remotionRoot, logLevel }) => (0, source_file_write_queue_1.withSourceFileWriteQueue)(() => {
15
+ var _a;
16
+ var _b, _c;
17
+ try {
18
+ const { absolutePath } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
19
+ remotionRoot,
20
+ fileName,
21
+ action: 'modify',
22
+ });
23
+ const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
24
+ const result = (0, codemods_1.updateJsxNodeProps)({
25
+ project: {
26
+ files: { [absolutePath]: fileContents },
27
+ rootDir: remotionRoot,
28
+ },
29
+ node: { filePath: absolutePath, nodePath },
30
+ updates: [
31
+ {
32
+ key: 'src',
33
+ value: `${no_react_1.NoReactInternals.FILE_TOKEN}${src.split('/').map(encodeURIComponent).join('/')}`,
34
+ defaultValue: null,
35
+ },
36
+ ],
37
+ });
38
+ const output = (_b = (_a = result.changes[0]) === null || _a === void 0 ? void 0 : _a.nextContents) !== null && _b !== void 0 ? _b : fileContents;
39
+ const { logLine } = result;
40
+ const nodePathRemappings = result.nodePathRemappings.map(({ oldNodePath, newNodePath }) => ({ oldNodePath, newNodePath }));
41
+ const nodePathMutation = (0, sequence_node_path_mutation_1.broadcastSequenceNodePathMutation)([{ absolutePath, remappings: nodePathRemappings }], null);
42
+ (0, undo_stack_1.pushToUndoStack)({
43
+ filePath: absolutePath,
44
+ oldContents: fileContents,
45
+ newContents: null,
46
+ logLevel,
47
+ remotionRoot,
48
+ logLine,
49
+ description: {
50
+ undoMessage: '↩️ Removed video background',
51
+ redoMessage: '↪️ Removed video background',
52
+ },
53
+ entryType: 'replace-video-source',
54
+ suppressHmrOnFileRestore: false,
55
+ nodePathRemappings,
56
+ });
57
+ (0, undo_stack_1.suppressUndoStackInvalidation)(absolutePath);
58
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)({
59
+ file: absolutePath,
60
+ content: output,
61
+ originatorClientId: undefined,
62
+ metadata: { skipSequencePropsUpdate: true },
63
+ });
64
+ const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
65
+ remotionRoot,
66
+ absolutePath,
67
+ line: logLine,
68
+ });
69
+ renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${(0, source_file_write_queue_1.getCodemodTimingPrefix)(logLevel)}${renderer_1.RenderInternals.chalk.blueBright(locationLabel)} Replaced video source`);
70
+ (0, undo_stack_1.printUndoHint)(logLevel);
71
+ return Promise.resolve({ success: true, nodePathMutation });
72
+ }
73
+ catch (error) {
74
+ return Promise.resolve({
75
+ success: false,
76
+ reason: error.message,
77
+ stack: (_c = error.stack) !== null && _c !== void 0 ? _c : '',
78
+ });
79
+ }
80
+ });
81
+ exports.replaceVideoSourceHandler = replaceVideoSourceHandler;
@@ -191,7 +191,6 @@ const saveSequencePropsHandler = ({ input: { edits, addedKeyframes, movedKeyfram
191
191
  }
192
192
  const snapshots = [];
193
193
  const outputByPath = new Map();
194
- const statusAstByPath = new Map();
195
194
  const resultByIndex = new Map();
196
195
  const updatedNodePaths = new Map();
197
196
  const sequenceKeyframeLogs = [];
@@ -200,20 +199,14 @@ const saveSequencePropsHandler = ({ input: { edits, addedKeyframes, movedKeyfram
200
199
  for (const [absolutePath, group] of editGroups) {
201
200
  const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
202
201
  let output = fileContents;
203
- const cachedStatusAst = group.edits.length > 0
204
- ? (0, can_update_sequence_props_1.takeCachedSequencePropsStatusAst)(fileContents)
205
- : null;
206
- let sequencePropsAst = null;
207
202
  let firstLogLine = Number.POSITIVE_INFINITY;
208
203
  if (group.edits.length > 0) {
209
- const { output: sequencePropsOutput, formatted, results: updateResults, ast, } = await (0, update_sequence_props_1.updateMultipleSequenceProps)({
204
+ const { output: sequencePropsOutput, formatted, results: updateResults, } = await (0, update_sequence_props_1.updateMultipleSequenceProps)({
210
205
  input: output,
211
206
  changes: group.edits.map(exports.convertSequencePropEditToCodemodChange),
212
207
  prettierConfigOverride: null,
213
- ast: cachedStatusAst !== null && cachedStatusAst !== void 0 ? cachedStatusAst : undefined,
214
208
  });
215
209
  output = sequencePropsOutput;
216
- sequencePropsAst = ast;
217
210
  const firstUpdate = updateResults[0];
218
211
  if (firstUpdate) {
219
212
  firstLogLine = Math.min(firstLogLine, firstUpdate.logLine);
@@ -373,13 +366,6 @@ const saveSequencePropsHandler = ({ input: { edits, addedKeyframes, movedKeyfram
373
366
  });
374
367
  }
375
368
  }
376
- if (sequencePropsAst &&
377
- group.captionPatches.length === 0 &&
378
- group.addedKeyframes.length === 0 &&
379
- group.movedSequenceKeyframes.length === 0 &&
380
- group.effectKeyframes.length === 0) {
381
- statusAstByPath.set(absolutePath, sequencePropsAst);
382
- }
383
369
  outputByPath.set(absolutePath, output);
384
370
  snapshots.push({
385
371
  filePath: absolutePath,
@@ -505,16 +491,10 @@ const saveSequencePropsHandler = ({ input: { edits, addedKeyframes, movedKeyfram
505
491
  effects: [],
506
492
  videoConfigValues: target.nodePath.videoConfigValues,
507
493
  };
508
- const statusAst = statusAstByPath.get(absolutePath);
509
- const newStatus = statusAst
510
- ? (0, can_update_sequence_props_1.computeSequencePropsStatusFromAst)({
511
- ...statusInput,
512
- ast: statusAst,
513
- })
514
- : (0, can_update_sequence_props_1.computeSequencePropsStatusFromContent)({
515
- ...statusInput,
516
- fileContents: output,
517
- });
494
+ const newStatus = (0, can_update_sequence_props_1.computeSequencePropsStatusFromContent)({
495
+ ...statusInput,
496
+ fileContents: output,
497
+ });
518
498
  return {
519
499
  fileName: target.fileName,
520
500
  nodePath: target.nodePath,
@@ -527,7 +507,6 @@ const saveSequencePropsHandler = ({ input: { edits, addedKeyframes, movedKeyfram
527
507
  }
528
508
  return {
529
509
  canUpdate: true,
530
- props: firstResult.props,
531
510
  results,
532
511
  };
533
512
  });
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.splitJsxSequenceHandler = void 0;
4
4
  const node_fs_1 = require("node:fs");
5
+ const codemods_1 = require("@remotion/codemods");
5
6
  const renderer_1 = require("@remotion/renderer");
6
- const split_jsx_sequence_1 = require("../../codemods/split-jsx-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");
@@ -24,20 +24,28 @@ const splitJsxSequenceHandler = ({ input: { sequences }, remotionRoot, logLevel
24
24
  sequencesByFileName.set(sequence.fileName, fileSequences);
25
25
  }
26
26
  const updates = await Promise.all([...sequencesByFileName].map(async ([fileName, fileSequences]) => {
27
+ var _a;
28
+ var _b;
27
29
  const { absolutePath, fileRelativeToRoot } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
28
30
  remotionRoot,
29
31
  fileName,
30
32
  action: 'modify',
31
33
  });
32
34
  const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
33
- const { output, nodeLabels, logLines, nodePathRemappings } = await (0, split_jsx_sequence_1.splitJsxSequences)({
34
- input: fileContents,
35
+ const result = await (0, codemods_1.splitSequences)({
36
+ project: {
37
+ files: { [absolutePath]: fileContents },
38
+ rootDir: remotionRoot,
39
+ },
35
40
  splits: fileSequences.map(({ nodePath, sequenceKeys, splitFrame }) => ({
36
- nodePath,
41
+ node: { filePath: absolutePath, nodePath },
37
42
  sequenceKeys,
38
- splitFrame,
43
+ frame: splitFrame,
39
44
  })),
40
45
  });
46
+ const output = (_b = (_a = result.changes[0]) === null || _a === void 0 ? void 0 : _a.nextContents) !== null && _b !== void 0 ? _b : fileContents;
47
+ const { nodeLabels, logLines } = result.editDetails[0];
48
+ const nodePathRemappings = result.nodePathRemappings.map(({ oldNodePath, newNodePath }) => ({ oldNodePath, newNodePath }));
41
49
  return {
42
50
  absolutePath,
43
51
  fileContents,
@@ -11,8 +11,9 @@ const sequence_node_path_mutation_1 = require("../sequence-node-path-mutation");
11
11
  const undo_stack_1 = require("../undo-stack");
12
12
  const log_update_1 = require("./log-updates/log-update");
13
13
  const source_file_write_queue_1 = require("./source-file-write-queue");
14
- const { splitVideoFromAudio } = codemods_1.CodemodsInternals;
15
14
  const splitVideoFromAudioHandler = ({ input: { fileName, nodePath }, remotionRoot, logLevel }) => (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
15
+ var _a;
16
+ var _b;
16
17
  try {
17
18
  renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[split-video-from-audio] Received request for fileName="${fileName}"`);
18
19
  const { absolutePath, fileRelativeToRoot } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
@@ -21,10 +22,13 @@ const splitVideoFromAudioHandler = ({ input: { fileName, nodePath }, remotionRoo
21
22
  action: 'modify',
22
23
  });
23
24
  const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
24
- const { output, formatted, nodeLabel, logLine, nodePathRemappings } = await splitVideoFromAudio({
25
- input: fileContents,
26
- nodePath,
25
+ const result = await (0, codemods_1.detachAudio)({
26
+ project: { files: { [absolutePath]: fileContents }, rootDir: remotionRoot },
27
+ node: { filePath: absolutePath, nodePath },
27
28
  });
29
+ const output = (_b = (_a = result.changes[0]) === null || _a === void 0 ? void 0 : _a.nextContents) !== null && _b !== void 0 ? _b : fileContents;
30
+ const { formatted, nodeLabel, logLine } = result.editDetails[0];
31
+ const nodePathRemappings = result.nodePathRemappings.map(({ oldNodePath, newNodePath }) => ({ oldNodePath, newNodePath }));
28
32
  const nodePathMutation = (0, sequence_node_path_mutation_1.broadcastSequenceNodePathMutation)([
29
33
  {
30
34
  absolutePath,
@@ -4,14 +4,13 @@ exports.subscribeToSequenceProps = void 0;
4
4
  const sequence_props_watchers_1 = require("../sequence-props-watchers");
5
5
  const can_update_sequence_props_1 = require("./can-update-sequence-props");
6
6
  const subscribeToSequenceProps = ({ input, remotionRoot, logLevel }) => {
7
- var _a, _b;
8
- const requests = (_a = input.requests) !== null && _a !== void 0 ? _a : [input];
7
+ var _a;
9
8
  const unresolvedByFile = new Map();
10
- for (const [index, request] of requests.entries()) {
9
+ for (const [index, request] of input.requests.entries()) {
11
10
  if (request.nodePath !== null) {
12
11
  continue;
13
12
  }
14
- const unresolved = (_b = unresolvedByFile.get(request.fileName)) !== null && _b !== void 0 ? _b : [];
13
+ const unresolved = (_a = unresolvedByFile.get(request.fileName)) !== null && _a !== void 0 ? _a : [];
15
14
  unresolved.push({ index, line: request.line, column: request.column });
16
15
  unresolvedByFile.set(request.fileName, unresolved);
17
16
  }
@@ -29,11 +28,11 @@ const subscribeToSequenceProps = ({ input, remotionRoot, logLevel }) => {
29
28
  }
30
29
  }
31
30
  }
32
- catch (_c) {
31
+ catch (_b) {
33
32
  // Let each subscription produce its usual not-found response.
34
33
  }
35
34
  }
36
- const results = requests.map(({ fileName, line, column, nodePath, componentIdentity, keys, assetKeys = [], effects, clientId, videoConfigValues, }, index) => (0, sequence_props_watchers_1.subscribeToSequencePropsWatchers)({
35
+ const results = input.requests.map(({ fileName, line, column, nodePath, componentIdentity, keys, assetKeys, effects, clientId, videoConfigValues, }, index) => (0, sequence_props_watchers_1.subscribeToSequencePropsWatchers)({
37
36
  fileName,
38
37
  line,
39
38
  column,
@@ -48,9 +47,6 @@ const subscribeToSequenceProps = ({ input, remotionRoot, logLevel }) => {
48
47
  videoConfigValues,
49
48
  logLevel,
50
49
  }));
51
- return Promise.resolve({
52
- ...results[0],
53
- results,
54
- });
50
+ return Promise.resolve({ results });
55
51
  };
56
52
  exports.subscribeToSequenceProps = subscribeToSequenceProps;
@@ -83,6 +83,22 @@ const validateUpdates = (updates) => {
83
83
  }
84
84
  setters.add(setter);
85
85
  if (setter === 'addElementLibrary') {
86
+ if (type === 'delete') {
87
+ if (typeof update.value !== 'string') {
88
+ return 'Deleting an Element Library requires its URL.';
89
+ }
90
+ try {
91
+ const parsedUrl = new URL(update.value);
92
+ if (parsedUrl.protocol !== 'http:' &&
93
+ parsedUrl.protocol !== 'https:') {
94
+ return 'Deleting an Element Library requires an HTTP or HTTPS URL.';
95
+ }
96
+ }
97
+ catch (_a) {
98
+ return 'Deleting an Element Library requires an HTTP or HTTPS URL.';
99
+ }
100
+ continue;
101
+ }
86
102
  if (type !== 'set' ||
87
103
  !('value' in update) ||
88
104
  typeof update.value !== 'object' ||
@@ -101,7 +117,7 @@ const validateUpdates = (updates) => {
101
117
  return 'Config.addElementLibrary() expects an HTTP or HTTPS URL.';
102
118
  }
103
119
  }
104
- catch (_a) {
120
+ catch (_b) {
105
121
  return 'Config.addElementLibrary() expects an HTTP or HTTPS URL.';
106
122
  }
107
123
  if (displayName !== undefined &&
@@ -111,6 +127,9 @@ const validateUpdates = (updates) => {
111
127
  continue;
112
128
  }
113
129
  if (type === 'delete') {
130
+ if (update.value !== undefined) {
131
+ return `Config.${setter}() does not accept a value when deleting.`;
132
+ }
114
133
  continue;
115
134
  }
116
135
  if (type !== 'set' ||
@@ -122,13 +141,18 @@ const validateUpdates = (updates) => {
122
141
  return null;
123
142
  };
124
143
  const updateConfigFile = ({ configContents, existingElementLibraryUrls, updates, }) => {
144
+ var _a;
125
145
  const setters = new Set(updates.map(({ setter }) => setter));
146
+ const deletedElementLibraryValue = (_a = updates.find((update) => update.setter === 'addElementLibrary' && update.type === 'delete')) === null || _a === void 0 ? void 0 : _a.value;
147
+ const deletedElementLibraryUrl = typeof deletedElementLibraryValue === 'string'
148
+ ? new URL(deletedElementLibraryValue).href
149
+ : null;
126
150
  const elementLibraryUrls = new Set();
127
151
  for (const url of existingElementLibraryUrls) {
128
152
  try {
129
153
  elementLibraryUrls.add(new URL(url).href);
130
154
  }
131
- catch (_a) {
155
+ catch (_b) {
132
156
  // Runtime config only contains validated URLs.
133
157
  }
134
158
  }
@@ -163,6 +187,12 @@ const updateConfigFile = ({ configContents, existingElementLibraryUrls, updates,
163
187
  urlProperty.value.type === 'StringLiteral') {
164
188
  try {
165
189
  const parsedUrl = new URL(urlProperty.value.value);
190
+ if (deletedElementLibraryUrl !== null &&
191
+ parsedUrl.href === deletedElementLibraryUrl) {
192
+ path.prune();
193
+ changed = true;
194
+ return false;
195
+ }
166
196
  if (parsedUrl.protocol === 'http:' ||
167
197
  parsedUrl.protocol === 'https:') {
168
198
  elementLibraryUrls.add(parsedUrl.href);
@@ -285,6 +315,12 @@ const updateConfigHandler = async ({ input, configFile, getStudioRuntimeConfig,
285
315
  updates: input.updates,
286
316
  });
287
317
  if (updatedConfig === configContents) {
318
+ if (input.updates.some((update) => update.setter === 'addElementLibrary' && update.type === 'delete')) {
319
+ return {
320
+ success: false,
321
+ reason: 'Could not find a matching literal Element Library URL in the config file.',
322
+ };
323
+ }
288
324
  return { success: true };
289
325
  }
290
326
  (0, file_watcher_1.writeFileAndNotifyFileWatchers)({
@@ -11,9 +11,10 @@ const undo_stack_1 = require("../undo-stack");
11
11
  const watch_ignore_next_change_1 = require("../watch-ignore-next-change");
12
12
  const can_update_default_props_1 = require("./can-update-default-props");
13
13
  const source_file_write_queue_1 = require("./source-file-write-queue");
14
- const { getCompositionDefaultPropsLine, updateDefaultProps } = codemods_1.CodemodsInternals;
15
14
  const updateDefaultPropsHandler = ({ input: { compositionId, defaultProps, enumPaths }, remotionRoot, entryPoint, logLevel, }) => {
16
15
  return (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
16
+ var _a;
17
+ var _b;
17
18
  try {
18
19
  renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[update-default-props] Received request for compositionId="${compositionId}"`);
19
20
  const projectInfo = await (0, project_info_1.getProjectInfo)(remotionRoot, entryPoint);
@@ -22,16 +23,18 @@ const updateDefaultPropsHandler = ({ input: { compositionId, defaultProps, enumP
22
23
  }
23
24
  (0, can_update_default_props_1.checkIfTypeScriptFile)(projectInfo.rootFile);
24
25
  const fileContents = (0, node_fs_1.readFileSync)(projectInfo.rootFile, 'utf-8');
25
- const logLine = getCompositionDefaultPropsLine({
26
- input: fileContents,
27
- compositionId,
28
- });
29
- const { output } = updateDefaultProps({
26
+ const result = (0, codemods_1.setCompositionDefaultProps)({
27
+ project: {
28
+ files: { [projectInfo.rootFile]: fileContents },
29
+ rootDir: remotionRoot,
30
+ },
31
+ compositionFile: projectInfo.rootFile,
30
32
  compositionId,
31
- input: fileContents,
32
- newDefaultProps: JSON.parse(defaultProps),
33
+ defaultProps: JSON.parse(defaultProps),
33
34
  enumPaths,
34
35
  });
36
+ const { logLine } = result;
37
+ const output = (_b = (_a = result.changes[0]) === null || _a === void 0 ? void 0 : _a.nextContents) !== null && _b !== void 0 ? _b : fileContents;
35
38
  (0, undo_stack_1.pushToUndoStack)({
36
39
  filePath: projectInfo.rootFile,
37
40
  oldContents: fileContents,
@@ -0,0 +1,3 @@
1
+ import type { WrapJsxNodeRequest, WrapJsxNodeResponse } from '@remotion/studio-shared';
2
+ import type { ApiHandler } from '../api-types';
3
+ export declare const wrapJsxNodeHandler: ApiHandler<WrapJsxNodeRequest, WrapJsxNodeResponse>;
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.wrapJsxNodeHandler = void 0;
4
+ const node_fs_1 = require("node:fs");
5
+ const codemods_1 = require("@remotion/codemods");
6
+ const renderer_1 = require("@remotion/renderer");
7
+ const file_watcher_1 = require("../../file-watcher");
8
+ const resolve_file_inside_project_1 = require("../../helpers/resolve-file-inside-project");
9
+ const format_log_file_location_1 = require("../format-log-file-location");
10
+ const sequence_node_path_mutation_1 = require("../sequence-node-path-mutation");
11
+ const undo_stack_1 = require("../undo-stack");
12
+ const source_file_write_queue_1 = require("./source-file-write-queue");
13
+ const wrapJsxNodeHandler = ({ input: { fileName, nodePath, wrapper, width, height }, remotionRoot, logLevel, }) => {
14
+ return (0, source_file_write_queue_1.withSourceFileWriteQueue)(() => {
15
+ var _a;
16
+ try {
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 eligibility = (0, codemods_1.canWrapJsxNode)({ input: fileContents, nodePath });
24
+ if (wrapper === null) {
25
+ return Promise.resolve({
26
+ success: true,
27
+ ...eligibility,
28
+ nodePathMutation: null,
29
+ });
30
+ }
31
+ if (!eligibility.canWrap ||
32
+ (wrapper === 'HtmlInCanvas' && !eligibility.canWrapHtmlInCanvas)) {
33
+ throw new Error('This JSX element cannot be wrapped');
34
+ }
35
+ const result = (0, codemods_1.wrapJsxNode)({
36
+ project: { files: { [absolutePath]: fileContents }, rootDir: remotionRoot },
37
+ node: { filePath: absolutePath, nodePath },
38
+ wrapper,
39
+ width: width !== null && width !== void 0 ? width : 0,
40
+ height: height !== null && height !== void 0 ? height : 0,
41
+ });
42
+ const change = result.changes.find(({ filePath }) => filePath === absolutePath);
43
+ if ((change === null || change === void 0 ? void 0 : change.previousContents) !== fileContents ||
44
+ change.nextContents === null) {
45
+ throw new Error('Could not wrap JSX node');
46
+ }
47
+ const output = change.nextContents;
48
+ const remappings = result.nodePathRemappings.map(({ oldNodePath, newNodePath }) => ({ oldNodePath, newNodePath }));
49
+ const nodePathMutation = (0, sequence_node_path_mutation_1.broadcastSequenceNodePathMutation)([{ absolutePath, remappings }], null);
50
+ const line = result.logLine;
51
+ (0, undo_stack_1.pushTransactionToUndoStack)({
52
+ snapshots: [
53
+ {
54
+ filePath: absolutePath,
55
+ oldContents: fileContents,
56
+ newContents: null,
57
+ logLine: line,
58
+ nodePathRemappings: remappings,
59
+ },
60
+ ],
61
+ logLevel,
62
+ remotionRoot,
63
+ description: {
64
+ undoMessage: `↩️ Wrapping in ${wrapper}`,
65
+ redoMessage: `↪️ Wrapping in ${wrapper}`,
66
+ },
67
+ entryType: 'wrap-jsx-node',
68
+ suppressHmrOnFileRestore: false,
69
+ undoRedoNavigation: null,
70
+ });
71
+ (0, undo_stack_1.suppressUndoStackInvalidation)(absolutePath);
72
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)({
73
+ file: absolutePath,
74
+ content: output,
75
+ originatorClientId: undefined,
76
+ metadata: { skipSequencePropsUpdate: true },
77
+ });
78
+ const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
79
+ remotionRoot,
80
+ absolutePath,
81
+ line,
82
+ });
83
+ renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${(0, source_file_write_queue_1.getCodemodTimingPrefix)(logLevel)}${renderer_1.RenderInternals.chalk.blueBright(locationLabel)} Wrapped JSX in <${wrapper}>`);
84
+ renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `[wrap-jsx-node] Wrote ${fileRelativeToRoot}`);
85
+ (0, undo_stack_1.printUndoHint)(logLevel);
86
+ return Promise.resolve({ success: true, ...eligibility, nodePathMutation });
87
+ }
88
+ catch (err) {
89
+ return Promise.resolve({
90
+ success: false,
91
+ reason: err.message,
92
+ stack: (_a = err.stack) !== null && _a !== void 0 ? _a : '',
93
+ });
94
+ }
95
+ });
96
+ };
97
+ exports.wrapJsxNodeHandler = wrapJsxNodeHandler;
@@ -105,7 +105,7 @@ const handleStudioProtocolDiscovery = ({ gitSource, liveEventsServer, remotionRo
105
105
  {
106
106
  type: 'install-element',
107
107
  payloadType: 'remotion-element',
108
- payloadVersions: [1],
108
+ payloadVersions: [1, 2],
109
109
  target: issuedInstallTarget === null || installTarget === null
110
110
  ? null
111
111
  : {