@remotion/studio-server 4.0.483 → 4.0.485

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 (36) hide show
  1. package/dist/codemods/recast-mods.js +37 -0
  2. package/dist/codemods/split-jsx-sequence.d.ts +14 -0
  3. package/dist/codemods/split-jsx-sequence.js +345 -0
  4. package/dist/codemods/update-sequence-props/update-sequence-props.d.ts +1 -1
  5. package/dist/codemods/update-sequence-props/update-sequence-props.js +62 -7
  6. package/dist/preview-server/api-routes.js +2 -0
  7. package/dist/preview-server/routes/add-effect-keyframe.js +2 -2
  8. package/dist/preview-server/routes/add-effect.js +56 -53
  9. package/dist/preview-server/routes/add-keyframes.js +2 -2
  10. package/dist/preview-server/routes/add-sequence-keyframe.js +2 -2
  11. package/dist/preview-server/routes/apply-codemod.js +104 -101
  12. package/dist/preview-server/routes/apply-visual-control-change.js +83 -80
  13. package/dist/preview-server/routes/can-update-sequence-props.d.ts +13 -1
  14. package/dist/preview-server/routes/can-update-sequence-props.js +101 -7
  15. package/dist/preview-server/routes/delete-effect.js +83 -80
  16. package/dist/preview-server/routes/delete-jsx-node.js +74 -71
  17. package/dist/preview-server/routes/delete-keyframes.js +2 -2
  18. package/dist/preview-server/routes/duplicate-effect.js +77 -74
  19. package/dist/preview-server/routes/duplicate-jsx-node.js +53 -50
  20. package/dist/preview-server/routes/insert-element.js +2 -2
  21. package/dist/preview-server/routes/insert-jsx-element.js +2 -2
  22. package/dist/preview-server/routes/move-keyframes.js +2 -2
  23. package/dist/preview-server/routes/paste-effects.js +59 -56
  24. package/dist/preview-server/routes/reorder-effect.js +55 -52
  25. package/dist/preview-server/routes/reorder-sequence.js +55 -52
  26. package/dist/preview-server/routes/save-effect-props.js +2 -2
  27. package/dist/preview-server/routes/save-sequence-props.js +2 -2
  28. package/dist/preview-server/routes/source-file-write-queue.d.ts +1 -0
  29. package/dist/preview-server/routes/source-file-write-queue.js +11 -0
  30. package/dist/preview-server/routes/split-jsx-sequence.d.ts +3 -0
  31. package/dist/preview-server/routes/split-jsx-sequence.js +66 -0
  32. package/dist/preview-server/routes/update-default-props.js +58 -55
  33. package/dist/preview-server/routes/update-effect-keyframe-settings.js +2 -2
  34. package/dist/preview-server/routes/update-sequence-keyframe-settings.js +2 -2
  35. package/dist/preview-server/undo-stack.d.ts +3 -1
  36. package/package.json +6 -6
@@ -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);
@@ -8,7 +8,7 @@ const resolve_composition_component_1 = require("../../helpers/resolve-compositi
8
8
  const format_log_file_location_1 = require("../format-log-file-location");
9
9
  const undo_stack_1 = require("../undo-stack");
10
10
  const log_update_1 = require("./log-updates/log-update");
11
- const save_props_mutex_1 = require("./save-props-mutex");
11
+ const source_file_write_queue_1 = require("./source-file-write-queue");
12
12
  const validateDimension = (name, value) => {
13
13
  if (!Number.isFinite(value) || value < 1) {
14
14
  throw new Error(`${name} must be a positive number`);
@@ -87,7 +87,7 @@ const getElementLabel = (element) => {
87
87
  }
88
88
  throw new Error('Unsupported element type');
89
89
  };
90
- const insertJsxElementHandler = ({ input: { compositionFile, compositionId, element }, remotionRoot, logLevel, }) => (0, save_props_mutex_1.withSavePropsLock)(async () => {
90
+ const insertJsxElementHandler = ({ input: { compositionFile, compositionId, element }, remotionRoot, logLevel, }) => (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
91
91
  try {
92
92
  validateElement(element);
93
93
  const elementLabel = getElementLabel(element);
@@ -10,7 +10,7 @@ const undo_stack_1 = require("../undo-stack");
10
10
  const watch_ignore_next_change_1 = require("../watch-ignore-next-change");
11
11
  const log_effect_update_1 = require("./log-updates/log-effect-update");
12
12
  const log_update_1 = require("./log-updates/log-update");
13
- const save_props_mutex_1 = require("./save-props-mutex");
13
+ const source_file_write_queue_1 = require("./source-file-write-queue");
14
14
  const groupBy = (items, getKey) => {
15
15
  var _a;
16
16
  const groups = new Map();
@@ -228,7 +228,7 @@ const moveKeyframes = async ({ sequenceKeyframes, effectKeyframes, clientId, rem
228
228
  (0, undo_stack_1.printUndoHint)(logLevel);
229
229
  };
230
230
  exports.moveKeyframes = moveKeyframes;
231
- const moveKeyframesHandler = ({ input: { sequenceKeyframes, effectKeyframes, clientId }, remotionRoot, logLevel, }) => (0, save_props_mutex_1.withSavePropsLock)(async () => {
231
+ const moveKeyframesHandler = ({ input: { sequenceKeyframes, effectKeyframes, clientId }, remotionRoot, logLevel, }) => (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
232
232
  renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[move-keyframes] Received request to move ${sequenceKeyframes.length + effectKeyframes.length} keyframe(s)`);
233
233
  await (0, exports.moveKeyframes)({
234
234
  sequenceKeyframes,
@@ -10,69 +10,72 @@ 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 getPastedEffectDescription = (effectLabels) => {
14
15
  if (effectLabels.length === 1) {
15
16
  return effectLabels[0];
16
17
  }
17
18
  return `${effectLabels.length} effects`;
18
19
  };
19
- const pasteEffectsHandler = async ({ input: { targetFileName, targetSequenceNodePath, type, effects, clientId }, remotionRoot, logLevel, }) => {
20
- try {
21
- if (effects.length === 0 && type !== 'effects-replacing') {
22
- throw new Error('No effects were specified for pasting');
20
+ const pasteEffectsHandler = ({ input: { targetFileName, targetSequenceNodePath, type, effects, clientId }, remotionRoot, logLevel, }) => {
21
+ return (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
22
+ try {
23
+ if (effects.length === 0 && type !== 'effects-replacing') {
24
+ throw new Error('No effects were specified for pasting');
25
+ }
26
+ renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[paste-effects] Received request to paste ${effects.length} effect${effects.length === 1 ? '' : 's'} into fileName="${targetFileName}"`);
27
+ const { absolutePath, fileRelativeToRoot } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
28
+ remotionRoot,
29
+ fileName: targetFileName,
30
+ action: 'modify',
31
+ });
32
+ const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
33
+ const { output, formatted, effectLabels, logLine } = await (0, paste_effects_1.pasteEffects)({
34
+ input: fileContents,
35
+ targetFileName,
36
+ targetSequenceNodePath: targetSequenceNodePath.nodePath,
37
+ type,
38
+ effects,
39
+ });
40
+ const effectDescription = getPastedEffectDescription(effectLabels);
41
+ (0, undo_stack_1.pushToUndoStack)({
42
+ filePath: absolutePath,
43
+ oldContents: fileContents,
44
+ newContents: null,
45
+ logLevel,
46
+ remotionRoot,
47
+ logLine,
48
+ description: {
49
+ undoMessage: `↩️ Pasting of ${effectDescription}`,
50
+ redoMessage: `↪️ Pasting of ${effectDescription}`,
51
+ },
52
+ entryType: 'paste-effects',
53
+ suppressHmrOnFileRestore: false,
54
+ });
55
+ (0, undo_stack_1.suppressUndoStackInvalidation)(absolutePath);
56
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)(absolutePath, output, clientId);
57
+ const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
58
+ remotionRoot,
59
+ absolutePath,
60
+ line: logLine,
61
+ });
62
+ renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Pasted ${(0, formatting_1.attrName)(effectDescription)}`);
63
+ if (!formatted) {
64
+ (0, log_update_1.warnAboutPrettierOnce)(logLevel);
65
+ }
66
+ renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `[paste-effects] Wrote ${fileRelativeToRoot}${formatted ? ' (formatted)' : ''}`);
67
+ (0, undo_stack_1.printUndoHint)(logLevel);
68
+ return {
69
+ success: true,
70
+ };
23
71
  }
24
- renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[paste-effects] Received request to paste ${effects.length} effect${effects.length === 1 ? '' : 's'} into fileName="${targetFileName}"`);
25
- const { absolutePath, fileRelativeToRoot } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
26
- remotionRoot,
27
- fileName: targetFileName,
28
- action: 'modify',
29
- });
30
- const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
31
- const { output, formatted, effectLabels, logLine } = await (0, paste_effects_1.pasteEffects)({
32
- input: fileContents,
33
- targetFileName,
34
- targetSequenceNodePath: targetSequenceNodePath.nodePath,
35
- type,
36
- effects,
37
- });
38
- const effectDescription = getPastedEffectDescription(effectLabels);
39
- (0, undo_stack_1.pushToUndoStack)({
40
- filePath: absolutePath,
41
- oldContents: fileContents,
42
- newContents: null,
43
- logLevel,
44
- remotionRoot,
45
- logLine,
46
- description: {
47
- undoMessage: `↩️ Pasting of ${effectDescription}`,
48
- redoMessage: `↪️ Pasting of ${effectDescription}`,
49
- },
50
- entryType: 'paste-effects',
51
- suppressHmrOnFileRestore: false,
52
- });
53
- (0, undo_stack_1.suppressUndoStackInvalidation)(absolutePath);
54
- (0, file_watcher_1.writeFileAndNotifyFileWatchers)(absolutePath, output, clientId);
55
- const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
56
- remotionRoot,
57
- absolutePath,
58
- line: logLine,
59
- });
60
- renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Pasted ${(0, formatting_1.attrName)(effectDescription)}`);
61
- if (!formatted) {
62
- (0, log_update_1.warnAboutPrettierOnce)(logLevel);
72
+ catch (err) {
73
+ return {
74
+ success: false,
75
+ reason: err.message,
76
+ stack: err.stack,
77
+ };
63
78
  }
64
- renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `[paste-effects] Wrote ${fileRelativeToRoot}${formatted ? ' (formatted)' : ''}`);
65
- (0, undo_stack_1.printUndoHint)(logLevel);
66
- return {
67
- success: true,
68
- };
69
- }
70
- catch (err) {
71
- return {
72
- success: false,
73
- reason: err.message,
74
- stack: err.stack,
75
- };
76
- }
79
+ });
77
80
  };
78
81
  exports.pasteEffectsHandler = pasteEffectsHandler;
@@ -10,58 +10,61 @@ 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 reorderEffectHandler = async ({ input: { fileName, sequenceNodePath, fromIndex, toIndex, clientId }, remotionRoot, logLevel, }) => {
14
- try {
15
- renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[reorder-effect] Received request for fileName="${fileName}" fromIndex=${fromIndex} toIndex=${toIndex}`);
16
- const { absolutePath, fileRelativeToRoot } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
17
- remotionRoot,
18
- fileName,
19
- action: 'modify',
20
- });
21
- const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
22
- const { output, formatted, effectLabel, logLine } = await (0, reorder_effect_1.reorderEffect)({
23
- input: fileContents,
24
- sequenceNodePath: sequenceNodePath.nodePath,
25
- fromIndex,
26
- toIndex,
27
- });
28
- (0, undo_stack_1.pushToUndoStack)({
29
- filePath: absolutePath,
30
- oldContents: fileContents,
31
- newContents: null,
32
- logLevel,
33
- remotionRoot,
34
- logLine,
35
- description: {
36
- undoMessage: `↩️ Reordering of ${effectLabel}`,
37
- redoMessage: `↪️ Reordering of ${effectLabel}`,
38
- },
39
- entryType: 'reorder-effect',
40
- suppressHmrOnFileRestore: false,
41
- });
42
- (0, undo_stack_1.suppressUndoStackInvalidation)(absolutePath);
43
- (0, file_watcher_1.writeFileAndNotifyFileWatchers)(absolutePath, output, clientId);
44
- const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
45
- remotionRoot,
46
- absolutePath,
47
- line: logLine,
48
- });
49
- renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Reordered ${(0, formatting_1.attrName)(effectLabel)}`);
50
- if (!formatted) {
51
- (0, log_update_1.warnAboutPrettierOnce)(logLevel);
13
+ const source_file_write_queue_1 = require("./source-file-write-queue");
14
+ const reorderEffectHandler = ({ input: { fileName, sequenceNodePath, fromIndex, toIndex, clientId }, remotionRoot, logLevel, }) => {
15
+ return (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
16
+ try {
17
+ renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[reorder-effect] Received request for fileName="${fileName}" fromIndex=${fromIndex} toIndex=${toIndex}`);
18
+ const { absolutePath, fileRelativeToRoot } = (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 { output, formatted, effectLabel, logLine } = await (0, reorder_effect_1.reorderEffect)({
25
+ input: fileContents,
26
+ sequenceNodePath: sequenceNodePath.nodePath,
27
+ fromIndex,
28
+ toIndex,
29
+ });
30
+ (0, undo_stack_1.pushToUndoStack)({
31
+ filePath: absolutePath,
32
+ oldContents: fileContents,
33
+ newContents: null,
34
+ logLevel,
35
+ remotionRoot,
36
+ logLine,
37
+ description: {
38
+ undoMessage: `↩️ Reordering of ${effectLabel}`,
39
+ redoMessage: `↪️ Reordering of ${effectLabel}`,
40
+ },
41
+ entryType: 'reorder-effect',
42
+ suppressHmrOnFileRestore: false,
43
+ });
44
+ (0, undo_stack_1.suppressUndoStackInvalidation)(absolutePath);
45
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)(absolutePath, output, clientId);
46
+ const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
47
+ remotionRoot,
48
+ absolutePath,
49
+ line: logLine,
50
+ });
51
+ renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Reordered ${(0, formatting_1.attrName)(effectLabel)}`);
52
+ if (!formatted) {
53
+ (0, log_update_1.warnAboutPrettierOnce)(logLevel);
54
+ }
55
+ renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `[reorder-effect] Wrote ${fileRelativeToRoot}${formatted ? ' (formatted)' : ''}`);
56
+ (0, undo_stack_1.printUndoHint)(logLevel);
57
+ return {
58
+ success: true,
59
+ };
52
60
  }
53
- renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `[reorder-effect] Wrote ${fileRelativeToRoot}${formatted ? ' (formatted)' : ''}`);
54
- (0, undo_stack_1.printUndoHint)(logLevel);
55
- return {
56
- success: true,
57
- };
58
- }
59
- catch (err) {
60
- return {
61
- success: false,
62
- reason: err.message,
63
- stack: err.stack,
64
- };
65
- }
61
+ catch (err) {
62
+ return {
63
+ success: false,
64
+ reason: err.message,
65
+ stack: err.stack,
66
+ };
67
+ }
68
+ });
66
69
  };
67
70
  exports.reorderEffectHandler = reorderEffectHandler;