@remotion/studio-server 4.0.484 → 4.0.486

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 (41) hide show
  1. package/dist/codemods/duplicate-composition.js +8 -0
  2. package/dist/codemods/recast-mods.js +246 -5
  3. package/dist/codemods/split-jsx-sequence.d.ts +14 -0
  4. package/dist/codemods/split-jsx-sequence.js +345 -0
  5. package/dist/codemods/update-sequence-props/update-sequence-props.d.ts +3 -1
  6. package/dist/codemods/update-sequence-props/update-sequence-props.js +406 -9
  7. package/dist/helpers/import-agnostic-node-path.js +30 -4
  8. package/dist/helpers/resolve-composition-component.d.ts +1 -0
  9. package/dist/helpers/resolve-composition-component.js +206 -9
  10. package/dist/preview-server/api-routes.js +2 -0
  11. package/dist/preview-server/routes/add-effect-keyframe.js +2 -2
  12. package/dist/preview-server/routes/add-effect.js +56 -53
  13. package/dist/preview-server/routes/add-keyframes.js +2 -2
  14. package/dist/preview-server/routes/add-sequence-keyframe.js +2 -2
  15. package/dist/preview-server/routes/apply-codemod.js +123 -101
  16. package/dist/preview-server/routes/apply-visual-control-change.js +83 -80
  17. package/dist/preview-server/routes/can-update-sequence-props.d.ts +13 -1
  18. package/dist/preview-server/routes/can-update-sequence-props.js +101 -7
  19. package/dist/preview-server/routes/delete-effect.js +83 -80
  20. package/dist/preview-server/routes/delete-jsx-node.js +74 -71
  21. package/dist/preview-server/routes/delete-keyframes.js +2 -2
  22. package/dist/preview-server/routes/duplicate-effect.js +77 -74
  23. package/dist/preview-server/routes/duplicate-jsx-node.js +53 -50
  24. package/dist/preview-server/routes/insert-element.js +2 -2
  25. package/dist/preview-server/routes/insert-jsx-element.js +53 -4
  26. package/dist/preview-server/routes/move-keyframes.js +2 -2
  27. package/dist/preview-server/routes/paste-effects.js +59 -56
  28. package/dist/preview-server/routes/reorder-effect.js +55 -52
  29. package/dist/preview-server/routes/reorder-sequence.js +55 -52
  30. package/dist/preview-server/routes/save-effect-props.js +2 -2
  31. package/dist/preview-server/routes/save-sequence-props.d.ts +3 -1
  32. package/dist/preview-server/routes/save-sequence-props.js +208 -24
  33. package/dist/preview-server/routes/source-file-write-queue.d.ts +1 -0
  34. package/dist/preview-server/routes/source-file-write-queue.js +11 -0
  35. package/dist/preview-server/routes/split-jsx-sequence.d.ts +3 -0
  36. package/dist/preview-server/routes/split-jsx-sequence.js +66 -0
  37. package/dist/preview-server/routes/update-default-props.js +58 -55
  38. package/dist/preview-server/routes/update-effect-keyframe-settings.js +2 -2
  39. package/dist/preview-server/routes/update-sequence-keyframe-settings.js +2 -2
  40. package/dist/preview-server/undo-stack.d.ts +7 -1
  41. package/package.json +6 -6
@@ -10,95 +10,98 @@ const format_log_file_location_1 = require("../format-log-file-location");
10
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
+ const source_file_write_queue_1 = require("./source-file-write-queue");
13
14
  const getDeletedEffectDescription = (effectLabels) => {
14
15
  if (effectLabels.length === 1) {
15
16
  return effectLabels[0];
16
17
  }
17
18
  return `${effectLabels.length} effects`;
18
19
  };
19
- const deleteEffectHandler = async ({ input: effects, remotionRoot, logLevel }) => {
20
- var _a;
21
- try {
22
- if (effects.length === 0) {
23
- throw new Error('No effects were specified for deletion');
24
- }
25
- renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[delete-effect] Received request to delete ${effects.length} effect target${effects.length === 1 ? '' : 's'}`);
26
- const itemsByFileName = new Map();
27
- for (const item of effects) {
28
- const fileItems = (_a = itemsByFileName.get(item.fileName)) !== null && _a !== void 0 ? _a : [];
29
- fileItems.push(item);
30
- itemsByFileName.set(item.fileName, fileItems);
20
+ const deleteEffectHandler = ({ input: effects, remotionRoot, logLevel }) => {
21
+ return (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
22
+ var _a;
23
+ try {
24
+ if (effects.length === 0) {
25
+ throw new Error('No effects were specified for deletion');
26
+ }
27
+ renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[delete-effect] Received request to delete ${effects.length} effect target${effects.length === 1 ? '' : 's'}`);
28
+ const itemsByFileName = new Map();
29
+ for (const item of effects) {
30
+ const fileItems = (_a = itemsByFileName.get(item.fileName)) !== null && _a !== void 0 ? _a : [];
31
+ fileItems.push(item);
32
+ itemsByFileName.set(item.fileName, fileItems);
33
+ }
34
+ const updates = await Promise.all([...itemsByFileName.entries()].map(async ([fileName, fileItems]) => {
35
+ const { absolutePath, fileRelativeToRoot } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
36
+ remotionRoot,
37
+ fileName,
38
+ action: 'modify',
39
+ });
40
+ const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
41
+ const { output, formatted, effectLabels, logLines } = await (0, delete_effect_1.deleteEffects)({
42
+ input: fileContents,
43
+ effects: fileItems.map((item) => item.type === 'single-effect'
44
+ ? {
45
+ type: 'single-effect',
46
+ sequenceNodePath: item.sequenceNodePath.nodePath,
47
+ effectIndex: item.effectIndex,
48
+ }
49
+ : {
50
+ type: 'all-effects',
51
+ sequenceNodePath: item.sequenceNodePath.nodePath,
52
+ }),
53
+ });
54
+ return {
55
+ absolutePath,
56
+ fileRelativeToRoot,
57
+ fileContents,
58
+ output,
59
+ formatted,
60
+ effectLabels,
61
+ logLine: Math.min(...logLines),
62
+ };
63
+ }));
64
+ for (const update of updates) {
65
+ const deletedEffectDescription = getDeletedEffectDescription(update.effectLabels);
66
+ (0, undo_stack_1.pushToUndoStack)({
67
+ filePath: update.absolutePath,
68
+ oldContents: update.fileContents,
69
+ newContents: null,
70
+ logLevel,
71
+ remotionRoot,
72
+ logLine: update.logLine,
73
+ description: {
74
+ undoMessage: `↩️ Deletion of ${deletedEffectDescription}`,
75
+ redoMessage: `↪️ Deletion of ${deletedEffectDescription}`,
76
+ },
77
+ entryType: 'delete-effect',
78
+ suppressHmrOnFileRestore: false,
79
+ });
80
+ (0, undo_stack_1.suppressUndoStackInvalidation)(update.absolutePath);
81
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)(update.absolutePath, update.output, undefined);
82
+ const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
83
+ remotionRoot,
84
+ absolutePath: update.absolutePath,
85
+ line: update.logLine,
86
+ });
87
+ renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} ${(0, formatting_1.strikeThroughOrRemovedPrefix)(deletedEffectDescription)}`);
88
+ if (!update.formatted) {
89
+ (0, log_update_1.warnAboutPrettierOnce)(logLevel);
90
+ }
91
+ renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `[delete-effect] Wrote ${update.fileRelativeToRoot}${update.formatted ? ' (formatted)' : ''}`);
92
+ }
93
+ (0, undo_stack_1.printUndoHint)(logLevel);
94
+ return {
95
+ success: true,
96
+ };
31
97
  }
32
- const updates = await Promise.all([...itemsByFileName.entries()].map(async ([fileName, fileItems]) => {
33
- const { absolutePath, fileRelativeToRoot } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
34
- remotionRoot,
35
- fileName,
36
- action: 'modify',
37
- });
38
- const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
39
- const { output, formatted, effectLabels, logLines } = await (0, delete_effect_1.deleteEffects)({
40
- input: fileContents,
41
- effects: fileItems.map((item) => item.type === 'single-effect'
42
- ? {
43
- type: 'single-effect',
44
- sequenceNodePath: item.sequenceNodePath.nodePath,
45
- effectIndex: item.effectIndex,
46
- }
47
- : {
48
- type: 'all-effects',
49
- sequenceNodePath: item.sequenceNodePath.nodePath,
50
- }),
51
- });
98
+ catch (err) {
52
99
  return {
53
- absolutePath,
54
- fileRelativeToRoot,
55
- fileContents,
56
- output,
57
- formatted,
58
- effectLabels,
59
- logLine: Math.min(...logLines),
100
+ success: false,
101
+ reason: err.message,
102
+ stack: err.stack,
60
103
  };
61
- }));
62
- for (const update of updates) {
63
- const deletedEffectDescription = getDeletedEffectDescription(update.effectLabels);
64
- (0, undo_stack_1.pushToUndoStack)({
65
- filePath: update.absolutePath,
66
- oldContents: update.fileContents,
67
- newContents: null,
68
- logLevel,
69
- remotionRoot,
70
- logLine: update.logLine,
71
- description: {
72
- undoMessage: `↩️ Deletion of ${deletedEffectDescription}`,
73
- redoMessage: `↪️ Deletion of ${deletedEffectDescription}`,
74
- },
75
- entryType: 'delete-effect',
76
- suppressHmrOnFileRestore: false,
77
- });
78
- (0, undo_stack_1.suppressUndoStackInvalidation)(update.absolutePath);
79
- (0, file_watcher_1.writeFileAndNotifyFileWatchers)(update.absolutePath, update.output, undefined);
80
- const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
81
- remotionRoot,
82
- absolutePath: update.absolutePath,
83
- line: update.logLine,
84
- });
85
- renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} ${(0, formatting_1.strikeThroughOrRemovedPrefix)(deletedEffectDescription)}`);
86
- if (!update.formatted) {
87
- (0, log_update_1.warnAboutPrettierOnce)(logLevel);
88
- }
89
- renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `[delete-effect] Wrote ${update.fileRelativeToRoot}${update.formatted ? ' (formatted)' : ''}`);
90
104
  }
91
- (0, undo_stack_1.printUndoHint)(logLevel);
92
- return {
93
- success: true,
94
- };
95
- }
96
- catch (err) {
97
- return {
98
- success: false,
99
- reason: err.message,
100
- stack: err.stack,
101
- };
102
- }
105
+ });
103
106
  };
104
107
  exports.deleteEffectHandler = deleteEffectHandler;
@@ -9,86 +9,89 @@ const resolve_file_inside_project_1 = require("../../helpers/resolve-file-inside
9
9
  const format_log_file_location_1 = require("../format-log-file-location");
10
10
  const undo_stack_1 = require("../undo-stack");
11
11
  const log_update_1 = require("./log-updates/log-update");
12
+ const source_file_write_queue_1 = require("./source-file-write-queue");
12
13
  const getDeletedNodeDescription = (nodeLabels) => {
13
14
  if (nodeLabels.length === 1) {
14
15
  return nodeLabels[0];
15
16
  }
16
17
  return `${nodeLabels.length} JSX nodes`;
17
18
  };
18
- const deleteJsxNodeHandler = async ({ input: { nodes }, remotionRoot, logLevel }) => {
19
- var _a;
20
- try {
21
- if (nodes.length === 0) {
22
- throw new Error('No JSX nodes were specified for deletion');
23
- }
24
- renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[delete-jsx-node] Received request to delete ${nodes.length} JSX node${nodes.length === 1 ? '' : 's'}`);
25
- const itemsByFileName = new Map();
26
- for (const item of nodes) {
27
- const fileItems = (_a = itemsByFileName.get(item.fileName)) !== null && _a !== void 0 ? _a : [];
28
- fileItems.push(item);
29
- itemsByFileName.set(item.fileName, fileItems);
19
+ const deleteJsxNodeHandler = ({ input: { nodes }, remotionRoot, logLevel }) => {
20
+ return (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
21
+ var _a;
22
+ try {
23
+ if (nodes.length === 0) {
24
+ throw new Error('No JSX nodes were specified for deletion');
25
+ }
26
+ renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[delete-jsx-node] Received request to delete ${nodes.length} JSX node${nodes.length === 1 ? '' : 's'}`);
27
+ const itemsByFileName = new Map();
28
+ for (const item of nodes) {
29
+ const fileItems = (_a = itemsByFileName.get(item.fileName)) !== null && _a !== void 0 ? _a : [];
30
+ fileItems.push(item);
31
+ itemsByFileName.set(item.fileName, fileItems);
32
+ }
33
+ const updates = await Promise.all([...itemsByFileName.entries()].map(async ([fileName, fileItems]) => {
34
+ const { absolutePath, fileRelativeToRoot } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
35
+ remotionRoot,
36
+ fileName,
37
+ action: 'modify',
38
+ });
39
+ const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
40
+ const { output, formatted, nodeLabels, logLines } = await (0, delete_jsx_node_1.deleteJsxNodes)({
41
+ input: fileContents,
42
+ nodePaths: fileItems.map((item) => item.nodePath),
43
+ });
44
+ return {
45
+ absolutePath,
46
+ fileRelativeToRoot,
47
+ fileContents,
48
+ output,
49
+ formatted,
50
+ nodeLabels,
51
+ logLine: Math.min(...logLines),
52
+ };
53
+ }));
54
+ for (const update of updates) {
55
+ const deletedNodeDescription = getDeletedNodeDescription(update.nodeLabels);
56
+ (0, undo_stack_1.pushToUndoStack)({
57
+ filePath: update.absolutePath,
58
+ oldContents: update.fileContents,
59
+ newContents: null,
60
+ logLevel,
61
+ remotionRoot,
62
+ logLine: update.logLine,
63
+ description: {
64
+ undoMessage: `↩️ Deletion of ${deletedNodeDescription}`,
65
+ redoMessage: `↪️ Deletion of ${deletedNodeDescription}`,
66
+ },
67
+ entryType: 'delete-jsx-node',
68
+ suppressHmrOnFileRestore: false,
69
+ });
70
+ (0, undo_stack_1.suppressUndoStackInvalidation)(update.absolutePath);
71
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)(update.absolutePath, update.output, undefined);
72
+ const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
73
+ remotionRoot,
74
+ absolutePath: update.absolutePath,
75
+ line: update.logLine,
76
+ });
77
+ renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Deleted ${deletedNodeDescription}`);
78
+ if (!update.formatted) {
79
+ (0, log_update_1.warnAboutPrettierOnce)(logLevel);
80
+ }
81
+ renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `[delete-jsx-node] Wrote ${update.fileRelativeToRoot}${update.formatted ? ' (formatted)' : ''}`);
82
+ }
83
+ (0, undo_stack_1.printUndoHint)(logLevel);
84
+ return {
85
+ success: true,
86
+ };
30
87
  }
31
- const updates = await Promise.all([...itemsByFileName.entries()].map(async ([fileName, fileItems]) => {
32
- const { absolutePath, fileRelativeToRoot } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
33
- remotionRoot,
34
- fileName,
35
- action: 'modify',
36
- });
37
- const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
38
- const { output, formatted, nodeLabels, logLines } = await (0, delete_jsx_node_1.deleteJsxNodes)({
39
- input: fileContents,
40
- nodePaths: fileItems.map((item) => item.nodePath),
41
- });
88
+ catch (err) {
42
89
  return {
43
- absolutePath,
44
- fileRelativeToRoot,
45
- fileContents,
46
- output,
47
- formatted,
48
- nodeLabels,
49
- logLine: Math.min(...logLines),
90
+ success: false,
91
+ reason: err.message,
92
+ stack: err.stack,
50
93
  };
51
- }));
52
- for (const update of updates) {
53
- const deletedNodeDescription = getDeletedNodeDescription(update.nodeLabels);
54
- (0, undo_stack_1.pushToUndoStack)({
55
- filePath: update.absolutePath,
56
- oldContents: update.fileContents,
57
- newContents: null,
58
- logLevel,
59
- remotionRoot,
60
- logLine: update.logLine,
61
- description: {
62
- undoMessage: `↩️ Deletion of ${deletedNodeDescription}`,
63
- redoMessage: `↪️ Deletion of ${deletedNodeDescription}`,
64
- },
65
- entryType: 'delete-jsx-node',
66
- suppressHmrOnFileRestore: false,
67
- });
68
- (0, undo_stack_1.suppressUndoStackInvalidation)(update.absolutePath);
69
- (0, file_watcher_1.writeFileAndNotifyFileWatchers)(update.absolutePath, update.output, undefined);
70
- const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
71
- remotionRoot,
72
- absolutePath: update.absolutePath,
73
- line: update.logLine,
74
- });
75
- renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Deleted ${deletedNodeDescription}`);
76
- if (!update.formatted) {
77
- (0, log_update_1.warnAboutPrettierOnce)(logLevel);
78
- }
79
- renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `[delete-jsx-node] Wrote ${update.fileRelativeToRoot}${update.formatted ? ' (formatted)' : ''}`);
80
94
  }
81
- (0, undo_stack_1.printUndoHint)(logLevel);
82
- return {
83
- success: true,
84
- };
85
- }
86
- catch (err) {
87
- return {
88
- success: false,
89
- reason: err.message,
90
- stack: err.stack,
91
- };
92
- }
95
+ });
93
96
  };
94
97
  exports.deleteJsxNodeHandler = deleteJsxNodeHandler;
@@ -14,7 +14,7 @@ const can_update_effect_props_1 = require("./can-update-effect-props");
14
14
  const can_update_sequence_props_1 = require("./can-update-sequence-props");
15
15
  const log_effect_update_1 = require("./log-updates/log-effect-update");
16
16
  const log_update_1 = require("./log-updates/log-update");
17
- const save_props_mutex_1 = require("./save-props-mutex");
17
+ const source_file_write_queue_1 = require("./source-file-write-queue");
18
18
  const groupBy = (items, getKey) => {
19
19
  var _a;
20
20
  const groups = new Map();
@@ -251,7 +251,7 @@ const deleteKeyframes = async ({ sequenceKeyframes, effectKeyframes, clientId, r
251
251
  return { sequenceResults, effectResults };
252
252
  };
253
253
  exports.deleteKeyframes = deleteKeyframes;
254
- const deleteKeyframesHandler = ({ input: { sequenceKeyframes, effectKeyframes, clientId }, remotionRoot, logLevel, }) => (0, save_props_mutex_1.withSavePropsLock)(async () => {
254
+ const deleteKeyframesHandler = ({ input: { sequenceKeyframes, effectKeyframes, clientId }, remotionRoot, logLevel, }) => (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
255
255
  renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[delete-keyframes] Received request to delete ${sequenceKeyframes.length + effectKeyframes.length} keyframe(s)`);
256
256
  await (0, exports.deleteKeyframes)({
257
257
  sequenceKeyframes,
@@ -10,89 +10,92 @@ const format_log_file_location_1 = require("../format-log-file-location");
10
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
+ const source_file_write_queue_1 = require("./source-file-write-queue");
13
14
  const getDuplicatedEffectDescription = (effectLabels) => {
14
15
  if (effectLabels.length === 1) {
15
16
  return effectLabels[0];
16
17
  }
17
18
  return `${effectLabels.length} effects`;
18
19
  };
19
- const duplicateEffectHandler = async ({ input: effects, remotionRoot, logLevel }) => {
20
- var _a;
21
- try {
22
- if (effects.length === 0) {
23
- throw new Error('No effects were specified for duplication');
24
- }
25
- renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[duplicate-effect] Received request to duplicate ${effects.length} effect target${effects.length === 1 ? '' : 's'}`);
26
- const itemsByFileName = new Map();
27
- for (const item of effects) {
28
- const fileItems = (_a = itemsByFileName.get(item.fileName)) !== null && _a !== void 0 ? _a : [];
29
- fileItems.push(item);
30
- itemsByFileName.set(item.fileName, fileItems);
20
+ const duplicateEffectHandler = ({ input: effects, remotionRoot, logLevel }) => {
21
+ return (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
22
+ var _a;
23
+ try {
24
+ if (effects.length === 0) {
25
+ throw new Error('No effects were specified for duplication');
26
+ }
27
+ renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[duplicate-effect] Received request to duplicate ${effects.length} effect target${effects.length === 1 ? '' : 's'}`);
28
+ const itemsByFileName = new Map();
29
+ for (const item of effects) {
30
+ const fileItems = (_a = itemsByFileName.get(item.fileName)) !== null && _a !== void 0 ? _a : [];
31
+ fileItems.push(item);
32
+ itemsByFileName.set(item.fileName, fileItems);
33
+ }
34
+ const updates = await Promise.all([...itemsByFileName.entries()].map(async ([fileName, fileItems]) => {
35
+ const { absolutePath, fileRelativeToRoot } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
36
+ remotionRoot,
37
+ fileName,
38
+ action: 'modify',
39
+ });
40
+ const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
41
+ const { output, formatted, effectLabels, logLines } = await (0, duplicate_effect_1.duplicateEffects)({
42
+ input: fileContents,
43
+ effects: fileItems.map((item) => ({
44
+ sequenceNodePath: item.sequenceNodePath.nodePath,
45
+ effectIndex: item.effectIndex,
46
+ })),
47
+ });
48
+ return {
49
+ absolutePath,
50
+ fileRelativeToRoot,
51
+ fileContents,
52
+ output,
53
+ formatted,
54
+ effectLabels,
55
+ logLine: Math.min(...logLines),
56
+ };
57
+ }));
58
+ for (const update of updates) {
59
+ const duplicatedEffectDescription = getDuplicatedEffectDescription(update.effectLabels);
60
+ (0, undo_stack_1.pushToUndoStack)({
61
+ filePath: update.absolutePath,
62
+ oldContents: update.fileContents,
63
+ newContents: null,
64
+ logLevel,
65
+ remotionRoot,
66
+ logLine: update.logLine,
67
+ description: {
68
+ undoMessage: `↩️ Duplication of ${duplicatedEffectDescription}`,
69
+ redoMessage: `↪️ Duplication of ${duplicatedEffectDescription}`,
70
+ },
71
+ entryType: 'duplicate-effect',
72
+ suppressHmrOnFileRestore: false,
73
+ });
74
+ (0, undo_stack_1.suppressUndoStackInvalidation)(update.absolutePath);
75
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)(update.absolutePath, update.output, undefined);
76
+ const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
77
+ remotionRoot,
78
+ absolutePath: update.absolutePath,
79
+ line: update.logLine,
80
+ });
81
+ renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Duplicated ${(0, formatting_1.attrName)(duplicatedEffectDescription)}`);
82
+ if (!update.formatted) {
83
+ (0, log_update_1.warnAboutPrettierOnce)(logLevel);
84
+ }
85
+ renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `[duplicate-effect] Wrote ${update.fileRelativeToRoot}${update.formatted ? ' (formatted)' : ''}`);
86
+ }
87
+ (0, undo_stack_1.printUndoHint)(logLevel);
88
+ return {
89
+ success: true,
90
+ };
31
91
  }
32
- const updates = await Promise.all([...itemsByFileName.entries()].map(async ([fileName, fileItems]) => {
33
- const { absolutePath, fileRelativeToRoot } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
34
- remotionRoot,
35
- fileName,
36
- action: 'modify',
37
- });
38
- const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
39
- const { output, formatted, effectLabels, logLines } = await (0, duplicate_effect_1.duplicateEffects)({
40
- input: fileContents,
41
- effects: fileItems.map((item) => ({
42
- sequenceNodePath: item.sequenceNodePath.nodePath,
43
- effectIndex: item.effectIndex,
44
- })),
45
- });
92
+ catch (err) {
46
93
  return {
47
- absolutePath,
48
- fileRelativeToRoot,
49
- fileContents,
50
- output,
51
- formatted,
52
- effectLabels,
53
- logLine: Math.min(...logLines),
94
+ success: false,
95
+ reason: err.message,
96
+ stack: err.stack,
54
97
  };
55
- }));
56
- for (const update of updates) {
57
- const duplicatedEffectDescription = getDuplicatedEffectDescription(update.effectLabels);
58
- (0, undo_stack_1.pushToUndoStack)({
59
- filePath: update.absolutePath,
60
- oldContents: update.fileContents,
61
- newContents: null,
62
- logLevel,
63
- remotionRoot,
64
- logLine: update.logLine,
65
- description: {
66
- undoMessage: `↩️ Duplication of ${duplicatedEffectDescription}`,
67
- redoMessage: `↪️ Duplication of ${duplicatedEffectDescription}`,
68
- },
69
- entryType: 'duplicate-effect',
70
- suppressHmrOnFileRestore: false,
71
- });
72
- (0, undo_stack_1.suppressUndoStackInvalidation)(update.absolutePath);
73
- (0, file_watcher_1.writeFileAndNotifyFileWatchers)(update.absolutePath, update.output, undefined);
74
- const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
75
- remotionRoot,
76
- absolutePath: update.absolutePath,
77
- line: update.logLine,
78
- });
79
- renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Duplicated ${(0, formatting_1.attrName)(duplicatedEffectDescription)}`);
80
- if (!update.formatted) {
81
- (0, log_update_1.warnAboutPrettierOnce)(logLevel);
82
- }
83
- renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `[duplicate-effect] Wrote ${update.fileRelativeToRoot}${update.formatted ? ' (formatted)' : ''}`);
84
98
  }
85
- (0, undo_stack_1.printUndoHint)(logLevel);
86
- return {
87
- success: true,
88
- };
89
- }
90
- catch (err) {
91
- return {
92
- success: false,
93
- reason: err.message,
94
- stack: err.stack,
95
- };
96
- }
99
+ });
97
100
  };
98
101
  exports.duplicateEffectHandler = duplicateEffectHandler;
@@ -9,56 +9,59 @@ const resolve_file_inside_project_1 = require("../../helpers/resolve-file-inside
9
9
  const format_log_file_location_1 = require("../format-log-file-location");
10
10
  const undo_stack_1 = require("../undo-stack");
11
11
  const log_update_1 = require("./log-updates/log-update");
12
- const duplicateJsxNodeHandler = async ({ input: { fileName, nodePath }, remotionRoot, logLevel }) => {
13
- try {
14
- renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[duplicate-jsx-node] Received request for fileName="${fileName}"`);
15
- const { absolutePath, fileRelativeToRoot } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
16
- remotionRoot,
17
- fileName,
18
- action: 'modify',
19
- });
20
- const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
21
- const { output, formatted, nodeLabel, logLine } = await (0, duplicate_jsx_node_1.duplicateJsxNode)({
22
- input: fileContents,
23
- nodePath,
24
- });
25
- (0, undo_stack_1.pushToUndoStack)({
26
- filePath: absolutePath,
27
- oldContents: fileContents,
28
- newContents: null,
29
- logLevel,
30
- remotionRoot,
31
- logLine,
32
- description: {
33
- undoMessage: `↩️ Duplication of ${nodeLabel}`,
34
- redoMessage: `↪️ Duplication of ${nodeLabel}`,
35
- },
36
- entryType: 'duplicate-jsx-node',
37
- suppressHmrOnFileRestore: false,
38
- });
39
- (0, undo_stack_1.suppressUndoStackInvalidation)(absolutePath);
40
- (0, file_watcher_1.writeFileAndNotifyFileWatchers)(absolutePath, output, undefined);
41
- const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
42
- remotionRoot,
43
- absolutePath,
44
- line: logLine,
45
- });
46
- renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Duplicated ${nodeLabel}`);
47
- if (!formatted) {
48
- (0, log_update_1.warnAboutPrettierOnce)(logLevel);
12
+ const source_file_write_queue_1 = require("./source-file-write-queue");
13
+ const duplicateJsxNodeHandler = ({ input: { fileName, nodePath }, remotionRoot, logLevel }) => {
14
+ return (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
15
+ try {
16
+ renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[duplicate-jsx-node] Received request for fileName="${fileName}"`);
17
+ const { absolutePath, fileRelativeToRoot } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
18
+ remotionRoot,
19
+ fileName,
20
+ action: 'modify',
21
+ });
22
+ const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
23
+ const { output, formatted, nodeLabel, logLine } = await (0, duplicate_jsx_node_1.duplicateJsxNode)({
24
+ input: fileContents,
25
+ nodePath,
26
+ });
27
+ (0, undo_stack_1.pushToUndoStack)({
28
+ filePath: absolutePath,
29
+ oldContents: fileContents,
30
+ newContents: null,
31
+ logLevel,
32
+ remotionRoot,
33
+ logLine,
34
+ description: {
35
+ undoMessage: `↩️ Duplication of ${nodeLabel}`,
36
+ redoMessage: `↪️ Duplication of ${nodeLabel}`,
37
+ },
38
+ entryType: 'duplicate-jsx-node',
39
+ suppressHmrOnFileRestore: false,
40
+ });
41
+ (0, undo_stack_1.suppressUndoStackInvalidation)(absolutePath);
42
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)(absolutePath, output, undefined);
43
+ const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
44
+ remotionRoot,
45
+ absolutePath,
46
+ line: logLine,
47
+ });
48
+ renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Duplicated ${nodeLabel}`);
49
+ if (!formatted) {
50
+ (0, log_update_1.warnAboutPrettierOnce)(logLevel);
51
+ }
52
+ renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `[duplicate-jsx-node] Wrote ${fileRelativeToRoot}${formatted ? ' (formatted)' : ''}`);
53
+ (0, undo_stack_1.printUndoHint)(logLevel);
54
+ return {
55
+ success: true,
56
+ };
49
57
  }
50
- renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `[duplicate-jsx-node] Wrote ${fileRelativeToRoot}${formatted ? ' (formatted)' : ''}`);
51
- (0, undo_stack_1.printUndoHint)(logLevel);
52
- return {
53
- success: true,
54
- };
55
- }
56
- catch (err) {
57
- return {
58
- success: false,
59
- reason: err.message,
60
- stack: err.stack,
61
- };
62
- }
58
+ catch (err) {
59
+ return {
60
+ success: false,
61
+ reason: err.message,
62
+ stack: err.stack,
63
+ };
64
+ }
65
+ });
63
66
  };
64
67
  exports.duplicateJsxNodeHandler = duplicateJsxNodeHandler;
@@ -13,7 +13,7 @@ const resolve_composition_component_1 = require("../../helpers/resolve-compositi
13
13
  const format_log_file_location_1 = require("../format-log-file-location");
14
14
  const undo_stack_1 = require("../undo-stack");
15
15
  const log_update_1 = require("./log-updates/log-update");
16
- const save_props_mutex_1 = require("./save-props-mutex");
16
+ const source_file_write_queue_1 = require("./source-file-write-queue");
17
17
  const validatePosition = (position) => {
18
18
  if (position === null) {
19
19
  return;
@@ -66,7 +66,7 @@ const validateElement = (element) => {
66
66
  }
67
67
  validateDimensions(element.dimensions);
68
68
  };
69
- const insertElementHandler = ({ input: { compositionFile, compositionId, element, position }, remotionRoot, logLevel, }) => (0, save_props_mutex_1.withSavePropsLock)(async () => {
69
+ const insertElementHandler = ({ input: { compositionFile, compositionId, element, position }, remotionRoot, logLevel, }) => (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
70
70
  try {
71
71
  validateElement(element);
72
72
  validatePosition(position);