@remotion/studio-server 4.0.524 → 4.0.526
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.
- package/dist/codemods/add-effect.d.ts +1 -26
- package/dist/codemods/add-effect.js +6 -191
- package/dist/codemods/apply-codemod-to-file.js +4 -11
- package/dist/codemods/delete-effect.d.ts +1 -30
- package/dist/codemods/delete-effect.js +4 -126
- package/dist/codemods/duplicate-effect.d.ts +1 -26
- package/dist/codemods/duplicate-effect.js +4 -90
- package/dist/codemods/paste-effects.d.ts +9 -14
- package/dist/codemods/paste-effects.js +2 -170
- package/dist/codemods/reorder-effect.d.ts +1 -13
- package/dist/codemods/reorder-effect.js +2 -58
- package/dist/codemods/reorder-sequence.d.ts +1 -15
- package/dist/codemods/reorder-sequence.js +1 -13
- package/dist/codemods/split-video-from-audio.d.ts +1 -12
- package/dist/codemods/split-video-from-audio.js +1 -11
- package/dist/codemods/update-default-props.d.ts +1 -11
- package/dist/codemods/update-default-props.js +2 -12
- package/dist/codemods/update-effect-props/update-effect-props.d.ts +2 -67
- package/dist/codemods/update-effect-props/update-effect-props.js +8 -312
- package/dist/codemods/update-keyframes/update-keyframes.js +2 -7
- package/dist/codemods/update-sequence-props/update-sequence-props.js +20 -58
- package/dist/helpers/resolve-composition-component.d.ts +2 -1
- package/dist/helpers/resolve-composition-component.js +13 -7
- package/dist/index.d.ts +2 -4
- package/dist/index.js +2 -3
- package/dist/preview-server/api-routes.js +5 -0
- package/dist/preview-server/routes/add-keyframes.js +1 -0
- package/dist/preview-server/routes/apply-codemod.d.ts +19 -0
- package/dist/preview-server/routes/apply-codemod.js +17 -55
- package/dist/preview-server/routes/apply-visual-control-change.js +5 -33
- package/dist/preview-server/routes/batch-update-keyframe-settings.js +1 -0
- package/dist/preview-server/routes/delete-keyframes.js +1 -0
- package/dist/preview-server/routes/duplicate-jsx-node.js +4 -8
- package/dist/preview-server/routes/insert-element.js +122 -19
- package/dist/preview-server/routes/insert-jsx-element.js +1 -0
- package/dist/preview-server/routes/install-remotion-skill.d.ts +4 -0
- package/dist/preview-server/routes/install-remotion-skill.js +108 -0
- package/dist/preview-server/routes/invalidate-bundle.d.ts +3 -0
- package/dist/preview-server/routes/invalidate-bundle.js +11 -0
- package/dist/preview-server/routes/move-keyframes.js +1 -0
- package/dist/preview-server/routes/reorder-sequence.js +2 -6
- package/dist/preview-server/routes/save-multiple-effect-props.js +1 -0
- package/dist/preview-server/routes/save-sequence-props.js +1 -0
- package/dist/preview-server/routes/update-default-props.js +1 -5
- package/dist/preview-server/undo-stack.d.ts +4 -2
- package/dist/preview-server/undo-stack.js +22 -4
- package/dist/preview-server/watch-ignore-next-change.d.ts +1 -0
- package/dist/preview-server/watch-ignore-next-change.js +20 -12
- package/dist/start-studio.d.ts +1 -0
- package/dist/start-studio.js +1 -1
- package/package.json +9 -9
- package/dist/preview-server/routes/delete-effect-keyframe.d.ts +0 -3
- package/dist/preview-server/routes/delete-effect-keyframe.js +0 -89
- package/dist/preview-server/routes/delete-sequence-keyframe.d.ts +0 -3
- package/dist/preview-server/routes/delete-sequence-keyframe.js +0 -82
- package/dist/preview-server/routes/save-props-mutex.d.ts +0 -1
- package/dist/preview-server/routes/save-props-mutex.js +0 -11
|
@@ -3,12 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.applyCodemodHandler = exports.getCodemodLogMessage = void 0;
|
|
6
|
+
exports.applyCodemodHandler = exports.getCodemodLogMessage = exports.formatNewCompositionFile = void 0;
|
|
7
7
|
const node_fs_1 = require("node:fs");
|
|
8
8
|
const node_path_1 = __importDefault(require("node:path"));
|
|
9
9
|
const renderer_1 = require("@remotion/renderer");
|
|
10
10
|
const studio_codemods_1 = require("@remotion/studio-codemods");
|
|
11
|
-
const generate_canvas_capture_composition_1 = require("../../canvas-capture/generate-canvas-capture-composition");
|
|
12
11
|
const apply_codemod_to_file_1 = require("../../codemods/apply-codemod-to-file");
|
|
13
12
|
const file_watcher_1 = require("../../file-watcher");
|
|
14
13
|
const format_log_file_location_1 = require("../format-log-file-location");
|
|
@@ -16,29 +15,8 @@ const project_info_1 = require("../project-info");
|
|
|
16
15
|
const undo_stack_1 = require("../undo-stack");
|
|
17
16
|
const can_update_default_props_1 = require("./can-update-default-props");
|
|
18
17
|
const source_file_write_queue_1 = require("./source-file-write-queue");
|
|
19
|
-
const formatNewCompositionFile = (codemod) =>
|
|
20
|
-
|
|
21
|
-
return (0, generate_canvas_capture_composition_1.generateCanvasCaptureComposition)({
|
|
22
|
-
componentName: codemod.componentName,
|
|
23
|
-
compositionId: codemod.newId,
|
|
24
|
-
data: codemod.canvasCapture.data,
|
|
25
|
-
durationInFrames: codemod.newDurationInFrames,
|
|
26
|
-
fps: codemod.newFps,
|
|
27
|
-
height: codemod.newHeight,
|
|
28
|
-
keyframeFps: codemod.canvasCapture.keyframeFps,
|
|
29
|
-
videoFileName: codemod.canvasCapture.videoFileName,
|
|
30
|
-
videoHeight: codemod.canvasCapture.videoHeight,
|
|
31
|
-
videoWidth: codemod.canvasCapture.videoWidth,
|
|
32
|
-
width: codemod.newWidth,
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
return `import React from 'react';
|
|
36
|
-
|
|
37
|
-
export const ${codemod.componentName}: React.FC = () => {
|
|
38
|
-
return null;
|
|
39
|
-
};
|
|
40
|
-
`;
|
|
41
|
-
};
|
|
18
|
+
const formatNewCompositionFile = (codemod) => (0, studio_codemods_1.makeNewCompositionComponentSource)(codemod);
|
|
19
|
+
exports.formatNewCompositionFile = formatNewCompositionFile;
|
|
42
20
|
const getFolderPath = (parentName, folderName) => {
|
|
43
21
|
return parentName ? `${parentName}/${folderName}` : folderName;
|
|
44
22
|
};
|
|
@@ -184,7 +162,7 @@ const getCodemodUndoDescription = (codemod) => {
|
|
|
184
162
|
entryType: 'visual-control',
|
|
185
163
|
};
|
|
186
164
|
};
|
|
187
|
-
const applyCodemodHandler = ({ input: { codemod, dryRun, symbolicatedStack }, logLevel, remotionRoot, entryPoint, }) => {
|
|
165
|
+
const applyCodemodHandler = ({ input: { codemod, dryRun, symbolicatedStack, undoRedoNavigation }, logLevel, remotionRoot, entryPoint, }) => {
|
|
188
166
|
return (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
|
|
189
167
|
var _a;
|
|
190
168
|
try {
|
|
@@ -231,7 +209,7 @@ const applyCodemodHandler = ({ input: { codemod, dryRun, symbolicatedStack }, lo
|
|
|
231
209
|
if (componentFilePath === null) {
|
|
232
210
|
throw new Error('Could not determine the new component file path');
|
|
233
211
|
}
|
|
234
|
-
componentFileContents = await formatNewCompositionFile(codemod);
|
|
212
|
+
componentFileContents = await (0, exports.formatNewCompositionFile)(codemod);
|
|
235
213
|
snapshots.push({
|
|
236
214
|
filePath: componentFilePath,
|
|
237
215
|
oldContents: null,
|
|
@@ -239,35 +217,19 @@ const applyCodemodHandler = ({ input: { codemod, dryRun, symbolicatedStack }, lo
|
|
|
239
217
|
logLine: 1,
|
|
240
218
|
nodePathRemappings: null,
|
|
241
219
|
});
|
|
242
|
-
(0, undo_stack_1.pushTransactionToUndoStack)({
|
|
243
|
-
snapshots,
|
|
244
|
-
logLevel,
|
|
245
|
-
remotionRoot,
|
|
246
|
-
description: {
|
|
247
|
-
undoMessage,
|
|
248
|
-
redoMessage,
|
|
249
|
-
},
|
|
250
|
-
entryType,
|
|
251
|
-
suppressHmrOnFileRestore: false,
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
else {
|
|
255
|
-
(0, undo_stack_1.pushToUndoStack)({
|
|
256
|
-
filePath,
|
|
257
|
-
oldContents: input,
|
|
258
|
-
newContents: null,
|
|
259
|
-
logLevel,
|
|
260
|
-
remotionRoot,
|
|
261
|
-
logLine,
|
|
262
|
-
description: {
|
|
263
|
-
undoMessage,
|
|
264
|
-
redoMessage,
|
|
265
|
-
},
|
|
266
|
-
entryType,
|
|
267
|
-
suppressHmrOnFileRestore: false,
|
|
268
|
-
nodePathRemappings: null,
|
|
269
|
-
});
|
|
270
220
|
}
|
|
221
|
+
(0, undo_stack_1.pushTransactionToUndoStack)({
|
|
222
|
+
snapshots,
|
|
223
|
+
logLevel,
|
|
224
|
+
remotionRoot,
|
|
225
|
+
description: {
|
|
226
|
+
undoMessage,
|
|
227
|
+
redoMessage,
|
|
228
|
+
},
|
|
229
|
+
entryType,
|
|
230
|
+
suppressHmrOnFileRestore: false,
|
|
231
|
+
undoRedoNavigation,
|
|
232
|
+
});
|
|
271
233
|
(0, undo_stack_1.suppressUndoStackInvalidation)(filePath);
|
|
272
234
|
if (componentFilePath) {
|
|
273
235
|
(0, undo_stack_1.suppressUndoStackInvalidation)(componentFilePath);
|
|
@@ -45,7 +45,6 @@ const format_log_file_location_1 = require("../format-log-file-location");
|
|
|
45
45
|
const live_events_1 = require("../live-events");
|
|
46
46
|
const undo_stack_1 = require("../undo-stack");
|
|
47
47
|
const watch_ignore_next_change_1 = require("../watch-ignore-next-change");
|
|
48
|
-
const log_update_1 = require("./log-updates/log-update");
|
|
49
48
|
const source_file_write_queue_1 = require("./source-file-write-queue");
|
|
50
49
|
const getVisualControlChangeLine = (file, changeId) => {
|
|
51
50
|
let line = 1;
|
|
@@ -68,7 +67,7 @@ const getVisualControlChangeLine = (file, changeId) => {
|
|
|
68
67
|
return line;
|
|
69
68
|
};
|
|
70
69
|
const applyVisualControlHandler = ({ input: { fileName, changes }, remotionRoot, logLevel }) => {
|
|
71
|
-
return (0, source_file_write_queue_1.withSourceFileWriteQueue)(
|
|
70
|
+
return (0, source_file_write_queue_1.withSourceFileWriteQueue)(() => {
|
|
72
71
|
renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[apply-visual-control] Received request for ${fileName} with ${changes.length} changes`);
|
|
73
72
|
const { absolutePath } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
|
|
74
73
|
remotionRoot,
|
|
@@ -78,9 +77,9 @@ const applyVisualControlHandler = ({ input: { fileName, changes }, remotionRoot,
|
|
|
78
77
|
const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
|
|
79
78
|
const ast = (0, parse_ast_1.parseAst)(fileContents);
|
|
80
79
|
const logLine = changes.length > 0 ? getVisualControlChangeLine(ast, changes[0].id) : 1;
|
|
81
|
-
const {
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
const { newContents: output, changesMade } = (0, studio_codemods_1.applyVisualControl)({
|
|
81
|
+
input: fileContents,
|
|
82
|
+
transformation: {
|
|
84
83
|
type: 'apply-visual-control',
|
|
85
84
|
changes,
|
|
86
85
|
},
|
|
@@ -88,28 +87,6 @@ const applyVisualControlHandler = ({ input: { fileName, changes }, remotionRoot,
|
|
|
88
87
|
if (changesMade.length === 0) {
|
|
89
88
|
throw new Error('No changes were made to the file');
|
|
90
89
|
}
|
|
91
|
-
let output = (0, parse_ast_1.serializeAst)(newAst);
|
|
92
|
-
let formatted = false;
|
|
93
|
-
try {
|
|
94
|
-
const prettier = await Promise.resolve().then(() => __importStar(require('prettier')));
|
|
95
|
-
const { format, resolveConfig, resolveConfigFile } = prettier;
|
|
96
|
-
const configFilePath = await resolveConfigFile();
|
|
97
|
-
if (configFilePath) {
|
|
98
|
-
const prettierConfig = await resolveConfig(configFilePath);
|
|
99
|
-
if (prettierConfig) {
|
|
100
|
-
output = await format(output, {
|
|
101
|
-
...prettierConfig,
|
|
102
|
-
filepath: 'test.tsx',
|
|
103
|
-
plugins: [],
|
|
104
|
-
endOfLine: 'auto',
|
|
105
|
-
});
|
|
106
|
-
formatted = true;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
catch (_a) {
|
|
111
|
-
// Prettier not available, use unformatted output
|
|
112
|
-
}
|
|
113
90
|
(0, undo_stack_1.pushToUndoStack)({
|
|
114
91
|
filePath: absolutePath,
|
|
115
92
|
oldContents: fileContents,
|
|
@@ -151,13 +128,8 @@ const applyVisualControlHandler = ({ input: { fileName, changes }, remotionRoot,
|
|
|
151
128
|
line: logLine,
|
|
152
129
|
});
|
|
153
130
|
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${(0, source_file_write_queue_1.getCodemodTimingPrefix)(logLevel)}${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Applied visual control changes`);
|
|
154
|
-
if (!formatted) {
|
|
155
|
-
(0, log_update_1.warnAboutPrettierOnce)(logLevel);
|
|
156
|
-
}
|
|
157
131
|
(0, undo_stack_1.printUndoHint)(logLevel);
|
|
158
|
-
return {
|
|
159
|
-
success: true,
|
|
160
|
-
};
|
|
132
|
+
return Promise.resolve({ success: true });
|
|
161
133
|
});
|
|
162
134
|
};
|
|
163
135
|
exports.applyVisualControlHandler = applyVisualControlHandler;
|
|
@@ -151,6 +151,7 @@ const batchUpdateKeyframeSettings = async ({ sequenceKeyframes, effectKeyframes,
|
|
|
151
151
|
},
|
|
152
152
|
entryType: sequenceKeyframes.length > 0 ? 'sequence-props' : 'effect-props',
|
|
153
153
|
suppressHmrOnFileRestore: true,
|
|
154
|
+
undoRedoNavigation: null,
|
|
154
155
|
});
|
|
155
156
|
for (const snapshot of snapshots) {
|
|
156
157
|
(0, undo_stack_1.suppressUndoStackInvalidation)(snapshot.filePath);
|
|
@@ -186,6 +186,7 @@ const deleteKeyframes = async ({ sequenceKeyframes, effectKeyframes, clientId, r
|
|
|
186
186
|
? 'sequence-props'
|
|
187
187
|
: 'effect-props',
|
|
188
188
|
suppressHmrOnFileRestore: true,
|
|
189
|
+
undoRedoNavigation: null,
|
|
189
190
|
});
|
|
190
191
|
for (const snapshot of snapshots) {
|
|
191
192
|
(0, undo_stack_1.suppressUndoStackInvalidation)(snapshot.filePath);
|
|
@@ -3,13 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.duplicateJsxNodeHandler = void 0;
|
|
4
4
|
const node_fs_1 = require("node:fs");
|
|
5
5
|
const renderer_1 = require("@remotion/renderer");
|
|
6
|
-
const
|
|
6
|
+
const studio_codemods_1 = require("@remotion/studio-codemods");
|
|
7
7
|
const file_watcher_1 = require("../../file-watcher");
|
|
8
8
|
const resolve_file_inside_project_1 = require("../../helpers/resolve-file-inside-project");
|
|
9
9
|
const format_log_file_location_1 = require("../format-log-file-location");
|
|
10
10
|
const sequence_node_path_mutation_1 = require("../sequence-node-path-mutation");
|
|
11
11
|
const undo_stack_1 = require("../undo-stack");
|
|
12
|
-
const log_update_1 = require("./log-updates/log-update");
|
|
13
12
|
const source_file_write_queue_1 = require("./source-file-write-queue");
|
|
14
13
|
const duplicateJsxNodeHandler = ({ input: { nodes }, remotionRoot, logLevel }) => {
|
|
15
14
|
return (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
|
|
@@ -32,7 +31,7 @@ const duplicateJsxNodeHandler = ({ input: { nodes }, remotionRoot, logLevel }) =
|
|
|
32
31
|
action: 'modify',
|
|
33
32
|
});
|
|
34
33
|
const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
|
|
35
|
-
const { output,
|
|
34
|
+
const { output, nodeLabels, logLines, nodePathRemappings } = await (0, studio_codemods_1.duplicateJsxNodes)({
|
|
36
35
|
input: fileContents,
|
|
37
36
|
nodePaths: fileItems.map((item) => item.nodePath),
|
|
38
37
|
});
|
|
@@ -40,7 +39,6 @@ const duplicateJsxNodeHandler = ({ input: { nodes }, remotionRoot, logLevel }) =
|
|
|
40
39
|
absolutePath,
|
|
41
40
|
fileRelativeToRoot,
|
|
42
41
|
fileContents,
|
|
43
|
-
formatted,
|
|
44
42
|
logLine: Math.min(...logLines),
|
|
45
43
|
nodeLabels,
|
|
46
44
|
nodePathRemappings,
|
|
@@ -70,6 +68,7 @@ const duplicateJsxNodeHandler = ({ input: { nodes }, remotionRoot, logLevel }) =
|
|
|
70
68
|
},
|
|
71
69
|
entryType: 'duplicate-jsx-node',
|
|
72
70
|
suppressHmrOnFileRestore: false,
|
|
71
|
+
undoRedoNavigation: null,
|
|
73
72
|
});
|
|
74
73
|
for (const update of updates) {
|
|
75
74
|
(0, undo_stack_1.suppressUndoStackInvalidation)(update.absolutePath);
|
|
@@ -88,10 +87,7 @@ const duplicateJsxNodeHandler = ({ input: { nodes }, remotionRoot, logLevel }) =
|
|
|
88
87
|
? update.nodeLabels[0]
|
|
89
88
|
: `${update.nodeLabels.length} JSX nodes`;
|
|
90
89
|
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${(0, source_file_write_queue_1.getCodemodTimingPrefix)(logLevel)}${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Duplicated ${fileDescription}`);
|
|
91
|
-
|
|
92
|
-
(0, log_update_1.warnAboutPrettierOnce)(logLevel);
|
|
93
|
-
}
|
|
94
|
-
renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `[duplicate-jsx-node] Wrote ${update.fileRelativeToRoot}${update.formatted ? ' (formatted)' : ''}`);
|
|
90
|
+
renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `[duplicate-jsx-node] Wrote ${update.fileRelativeToRoot}`);
|
|
95
91
|
}
|
|
96
92
|
(0, undo_stack_1.printUndoHint)(logLevel);
|
|
97
93
|
return {
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.insertElementHandler = void 0;
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
4
9
|
const renderer_1 = require("@remotion/renderer");
|
|
10
|
+
const apply_codemod_to_file_1 = require("../../codemods/apply-codemod-to-file");
|
|
5
11
|
const file_watcher_1 = require("../../file-watcher");
|
|
6
12
|
const resolve_composition_component_1 = require("../../helpers/resolve-composition-component");
|
|
7
13
|
const format_log_file_location_1 = require("../format-log-file-location");
|
|
14
|
+
const project_info_1 = require("../project-info");
|
|
8
15
|
const sequence_node_path_mutation_1 = require("../sequence-node-path-mutation");
|
|
9
16
|
const undo_stack_1 = require("../undo-stack");
|
|
17
|
+
const apply_codemod_1 = require("./apply-codemod");
|
|
18
|
+
const can_update_default_props_1 = require("./can-update-default-props");
|
|
10
19
|
const element_install_plan_1 = require("./element-install-plan");
|
|
11
20
|
const source_file_write_queue_1 = require("./source-file-write-queue");
|
|
12
21
|
const hasExpectedFileState = ({ expected, actual, }) => {
|
|
@@ -21,9 +30,9 @@ const hasExpectedFileState = ({ expected, actual, }) => {
|
|
|
21
30
|
}
|
|
22
31
|
return actual.sourceHash === expected.sourceHash;
|
|
23
32
|
};
|
|
24
|
-
const insertElementHandler = ({ input: { compositionFile, compositionId, element, installationName, expectedFileState, from, position, overwriteExisting, }, entryPoint, remotionRoot, logLevel, }) => (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
|
|
25
|
-
var _a;
|
|
26
|
-
var
|
|
33
|
+
const insertElementHandler = ({ input: { compositionFile, compositionId, element, installationName, expectedFileState, from, position, overwriteExisting, undoRedoNavigation, newComposition, }, entryPoint, remotionRoot, logLevel, }) => (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
|
|
34
|
+
var _a, _b, _c;
|
|
35
|
+
var _d, _e, _f;
|
|
27
36
|
try {
|
|
28
37
|
(0, element_install_plan_1.validateElementInstallPosition)(position);
|
|
29
38
|
if (from !== null &&
|
|
@@ -50,13 +59,57 @@ const insertElementHandler = ({ input: { compositionFile, compositionId, element
|
|
|
50
59
|
throw new Error('Component-owned Element initial style must be an object');
|
|
51
60
|
}
|
|
52
61
|
renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[insert-element] Received request for compositionFile="${compositionFile}" compositionId="${compositionId}" element="${element.slug}"`);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
62
|
+
let compositionCreation = null;
|
|
63
|
+
let sourceFileOverrides = null;
|
|
64
|
+
if (newComposition !== null) {
|
|
65
|
+
if (newComposition.codemod.newId !== compositionId) {
|
|
66
|
+
throw new Error('New composition ID does not match installation target');
|
|
67
|
+
}
|
|
68
|
+
const registrationFilePath = newComposition.symbolicatedStack
|
|
69
|
+
? (0, apply_codemod_to_file_1.resolveFilePathFromSymbolicatedStack)(remotionRoot, newComposition.symbolicatedStack)
|
|
70
|
+
: (await (0, project_info_1.getProjectInfo)(remotionRoot, entryPoint)).rootFile;
|
|
71
|
+
if (registrationFilePath === null) {
|
|
72
|
+
throw new Error('Cannot find file for composition in project');
|
|
73
|
+
}
|
|
74
|
+
(0, can_update_default_props_1.checkIfTypeScriptFile)(registrationFilePath);
|
|
75
|
+
if (node_path_1.default.resolve(remotionRoot, compositionFile) !== registrationFilePath) {
|
|
76
|
+
throw new Error('New composition source does not match installation target');
|
|
77
|
+
}
|
|
78
|
+
const componentFilePath = node_path_1.default.join(node_path_1.default.dirname(registrationFilePath), `${newComposition.codemod.componentName}.tsx`);
|
|
79
|
+
if ((0, node_fs_1.existsSync)(componentFilePath)) {
|
|
80
|
+
throw new Error(`Cannot create ${node_path_1.default.relative(remotionRoot, componentFilePath)} because it already exists`);
|
|
81
|
+
}
|
|
82
|
+
const registrationFileOldContents = (0, node_fs_1.readFileSync)(registrationFilePath, 'utf-8');
|
|
83
|
+
const registrationFileNewContents = await (0, apply_codemod_to_file_1.applyCodemodToFile)({
|
|
84
|
+
filePath: registrationFilePath,
|
|
85
|
+
codeMod: newComposition.codemod,
|
|
86
|
+
});
|
|
87
|
+
const componentFileContents = await (0, apply_codemod_1.formatNewCompositionFile)(newComposition.codemod);
|
|
88
|
+
compositionCreation = {
|
|
89
|
+
componentFileContents,
|
|
90
|
+
componentFilePath,
|
|
91
|
+
registrationFileNewContents,
|
|
92
|
+
registrationFileOldContents,
|
|
93
|
+
registrationFilePath,
|
|
94
|
+
};
|
|
95
|
+
sourceFileOverrides = new Map([
|
|
96
|
+
[registrationFilePath, registrationFileNewContents],
|
|
97
|
+
[componentFilePath, componentFileContents],
|
|
98
|
+
]);
|
|
99
|
+
}
|
|
100
|
+
const installDestination = newComposition === null
|
|
101
|
+
? {
|
|
56
102
|
type: 'current-composition',
|
|
57
103
|
compositionFile,
|
|
58
104
|
compositionId,
|
|
59
|
-
}
|
|
105
|
+
}
|
|
106
|
+
: {
|
|
107
|
+
type: 'new-composition',
|
|
108
|
+
compositionFile,
|
|
109
|
+
};
|
|
110
|
+
const plan = await (0, element_install_plan_1.getElementInstallPlan)({
|
|
111
|
+
installationName,
|
|
112
|
+
destination: installDestination,
|
|
60
113
|
element,
|
|
61
114
|
entryPoint,
|
|
62
115
|
remotionRoot,
|
|
@@ -93,8 +146,13 @@ const insertElementHandler = ({ input: { compositionFile, compositionId, element
|
|
|
93
146
|
},
|
|
94
147
|
};
|
|
95
148
|
}
|
|
149
|
+
if (compositionCreation !== null &&
|
|
150
|
+
plan.elementFileName ===
|
|
151
|
+
node_path_1.default.join(node_path_1.default.dirname(plan.safePaths.compositionFileName), node_path_1.default.basename(compositionCreation.componentFilePath))) {
|
|
152
|
+
throw new Error('Element source file conflicts with the new composition file');
|
|
153
|
+
}
|
|
96
154
|
const shouldWriteElementFile = !plan.elementFileExists || elementSourcesDiffer;
|
|
97
|
-
const
|
|
155
|
+
const insertionInput = {
|
|
98
156
|
remotionRoot,
|
|
99
157
|
compositionFile,
|
|
100
158
|
compositionId,
|
|
@@ -104,7 +162,7 @@ const insertElementHandler = ({ input: { compositionFile, compositionId, element
|
|
|
104
162
|
importName: plan.componentName,
|
|
105
163
|
importPath: plan.importPath,
|
|
106
164
|
props: [
|
|
107
|
-
...Object.entries((
|
|
165
|
+
...Object.entries((_d = element.initialProps) !== null && _d !== void 0 ? _d : {}).map(([name, value]) => ({ name, value })),
|
|
108
166
|
...(componentOwnsSequence && element.durationInFrames !== null
|
|
109
167
|
? [
|
|
110
168
|
{
|
|
@@ -130,14 +188,18 @@ const insertElementHandler = ({ input: { compositionFile, compositionId, element
|
|
|
130
188
|
name: element.displayName,
|
|
131
189
|
position,
|
|
132
190
|
},
|
|
191
|
+
};
|
|
192
|
+
const inserted = await (0, resolve_composition_component_1.insertJsxElementIntoComposition)({
|
|
193
|
+
...insertionInput,
|
|
194
|
+
sourceFileOverrides,
|
|
133
195
|
});
|
|
196
|
+
if (compositionCreation !== null &&
|
|
197
|
+
inserted.fileName !== compositionCreation.componentFilePath) {
|
|
198
|
+
throw new Error('New composition component does not match installation target');
|
|
199
|
+
}
|
|
134
200
|
const finalPlan = await (0, element_install_plan_1.getElementInstallPlan)({
|
|
135
201
|
installationName,
|
|
136
|
-
destination:
|
|
137
|
-
type: 'current-composition',
|
|
138
|
-
compositionFile,
|
|
139
|
-
compositionId,
|
|
140
|
-
},
|
|
202
|
+
destination: installDestination,
|
|
141
203
|
element,
|
|
142
204
|
entryPoint,
|
|
143
205
|
remotionRoot,
|
|
@@ -152,6 +214,12 @@ const insertElementHandler = ({ input: { compositionFile, compositionId, element
|
|
|
152
214
|
})) {
|
|
153
215
|
throw new Error('Element source changed during installation');
|
|
154
216
|
}
|
|
217
|
+
if (compositionCreation !== null &&
|
|
218
|
+
((0, node_fs_1.readFileSync)(compositionCreation.registrationFilePath, 'utf-8') !==
|
|
219
|
+
compositionCreation.registrationFileOldContents ||
|
|
220
|
+
(0, node_fs_1.existsSync)(compositionCreation.componentFilePath))) {
|
|
221
|
+
throw new Error('Composition source changed during Element installation');
|
|
222
|
+
}
|
|
155
223
|
const nodePathMutation = (0, sequence_node_path_mutation_1.broadcastSequenceNodePathMutation)([
|
|
156
224
|
{
|
|
157
225
|
absolutePath: inserted.fileName,
|
|
@@ -160,6 +228,17 @@ const insertElementHandler = ({ input: { compositionFile, compositionId, element
|
|
|
160
228
|
], null);
|
|
161
229
|
(0, undo_stack_1.pushTransactionToUndoStack)({
|
|
162
230
|
snapshots: [
|
|
231
|
+
...(compositionCreation === null
|
|
232
|
+
? []
|
|
233
|
+
: [
|
|
234
|
+
{
|
|
235
|
+
filePath: compositionCreation.registrationFilePath,
|
|
236
|
+
oldContents: compositionCreation.registrationFileOldContents,
|
|
237
|
+
newContents: compositionCreation.registrationFileNewContents,
|
|
238
|
+
logLine: (_e = (_b = newComposition === null || newComposition === void 0 ? void 0 : newComposition.symbolicatedStack) === null || _b === void 0 ? void 0 : _b.originalLineNumber) !== null && _e !== void 0 ? _e : 1,
|
|
239
|
+
nodePathRemappings: null,
|
|
240
|
+
},
|
|
241
|
+
]),
|
|
163
242
|
...(shouldWriteElementFile
|
|
164
243
|
? [
|
|
165
244
|
{
|
|
@@ -173,7 +252,7 @@ const insertElementHandler = ({ input: { compositionFile, compositionId, element
|
|
|
173
252
|
: []),
|
|
174
253
|
{
|
|
175
254
|
filePath: inserted.fileName,
|
|
176
|
-
oldContents: inserted.oldContents,
|
|
255
|
+
oldContents: compositionCreation === null ? inserted.oldContents : null,
|
|
177
256
|
newContents: inserted.output,
|
|
178
257
|
logLine: inserted.logLine,
|
|
179
258
|
nodePathRemappings: inserted.nodePathRemappings,
|
|
@@ -181,17 +260,34 @@ const insertElementHandler = ({ input: { compositionFile, compositionId, element
|
|
|
181
260
|
],
|
|
182
261
|
logLevel,
|
|
183
262
|
remotionRoot,
|
|
184
|
-
description:
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
263
|
+
description: newComposition === null
|
|
264
|
+
? {
|
|
265
|
+
undoMessage: `↩️ Added ${element.displayName}`,
|
|
266
|
+
redoMessage: `↪️ Added ${element.displayName}`,
|
|
267
|
+
}
|
|
268
|
+
: {
|
|
269
|
+
undoMessage: `↩️ Installation of ${element.displayName} into composition "${compositionId}"`,
|
|
270
|
+
redoMessage: `↪️ Installation of ${element.displayName} into composition "${compositionId}"`,
|
|
271
|
+
},
|
|
188
272
|
entryType: 'insert-jsx-element',
|
|
189
273
|
suppressHmrOnFileRestore: false,
|
|
274
|
+
undoRedoNavigation,
|
|
190
275
|
});
|
|
276
|
+
if (compositionCreation !== null) {
|
|
277
|
+
(0, undo_stack_1.suppressUndoStackInvalidation)(compositionCreation.registrationFilePath);
|
|
278
|
+
}
|
|
191
279
|
if (shouldWriteElementFile) {
|
|
192
280
|
(0, undo_stack_1.suppressUndoStackInvalidation)(plan.elementFileName);
|
|
193
281
|
}
|
|
194
282
|
(0, undo_stack_1.suppressUndoStackInvalidation)(inserted.fileName);
|
|
283
|
+
if (compositionCreation !== null) {
|
|
284
|
+
(0, file_watcher_1.writeFileAndNotifyFileWatchers)({
|
|
285
|
+
file: compositionCreation.registrationFilePath,
|
|
286
|
+
content: compositionCreation.registrationFileNewContents,
|
|
287
|
+
originatorClientId: undefined,
|
|
288
|
+
metadata: null,
|
|
289
|
+
});
|
|
290
|
+
}
|
|
195
291
|
if (shouldWriteElementFile) {
|
|
196
292
|
(0, file_watcher_1.writeFileAndNotifyFileWatchers)({
|
|
197
293
|
file: plan.elementFileName,
|
|
@@ -206,6 +302,13 @@ const insertElementHandler = ({ input: { compositionFile, compositionId, element
|
|
|
206
302
|
originatorClientId: undefined,
|
|
207
303
|
metadata: { skipSequencePropsUpdate: true },
|
|
208
304
|
});
|
|
305
|
+
if (newComposition !== null && compositionCreation !== null) {
|
|
306
|
+
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${(0, source_file_write_queue_1.getCodemodTimingPrefix)(logLevel)}${renderer_1.RenderInternals.chalk.blueBright((0, format_log_file_location_1.formatLogFileLocation)({
|
|
307
|
+
remotionRoot,
|
|
308
|
+
absolutePath: compositionCreation.registrationFilePath,
|
|
309
|
+
line: (_f = (_c = newComposition.symbolicatedStack) === null || _c === void 0 ? void 0 : _c.originalLineNumber) !== null && _f !== void 0 ? _f : 1,
|
|
310
|
+
}))} Created composition "${compositionId}"`);
|
|
311
|
+
}
|
|
209
312
|
const compositionLocationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
|
|
210
313
|
remotionRoot,
|
|
211
314
|
absolutePath: inserted.fileName,
|
|
@@ -165,6 +165,7 @@ const insertJsxElementHandler = ({ input: { compositionFile, compositionId, elem
|
|
|
165
165
|
element,
|
|
166
166
|
from,
|
|
167
167
|
prettierConfigOverride: null,
|
|
168
|
+
sourceFileOverrides: null,
|
|
168
169
|
});
|
|
169
170
|
const nodePathMutation = (0, sequence_node_path_mutation_1.broadcastSequenceNodePathMutation)([
|
|
170
171
|
{
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { GetRemotionSkillsInfoResponse, InstallRemotionSkillRequest, RemoveRemotionSkillRequest } from '@remotion/studio-shared';
|
|
2
|
+
import type { ApiHandler } from '../api-types';
|
|
3
|
+
export declare const installRemotionSkillHandler: ApiHandler<InstallRemotionSkillRequest, GetRemotionSkillsInfoResponse>;
|
|
4
|
+
export declare const removeRemotionSkillHandler: ApiHandler<RemoveRemotionSkillRequest, GetRemotionSkillsInfoResponse>;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeRemotionSkillHandler = exports.installRemotionSkillHandler = void 0;
|
|
4
|
+
const node_child_process_1 = require("node:child_process");
|
|
5
|
+
const renderer_1 = require("@remotion/renderer");
|
|
6
|
+
const package_manager_spawn_options_1 = require("../../helpers/package-manager-spawn-options");
|
|
7
|
+
const remotion_skill_names_1 = require("../../remotion-skill-names");
|
|
8
|
+
const get_package_manager_1 = require("../get-package-manager");
|
|
9
|
+
const remotion_skills_info_1 = require("./remotion-skills-info");
|
|
10
|
+
const changingSkillsInProjects = new Set();
|
|
11
|
+
const changeRemotionSkill = async ({ action, remotionRoot, input: { skill }, logLevel, }) => {
|
|
12
|
+
if (!remotion_skill_names_1.remotionSkillNames.some((name) => name === skill)) {
|
|
13
|
+
throw new Error(`Unknown Remotion skill: ${JSON.stringify(skill)}`);
|
|
14
|
+
}
|
|
15
|
+
if (changingSkillsInProjects.has(remotionRoot)) {
|
|
16
|
+
throw new Error('A skill is already being installed or removed. Please try again once it finishes.');
|
|
17
|
+
}
|
|
18
|
+
changingSkillsInProjects.add(remotionRoot);
|
|
19
|
+
try {
|
|
20
|
+
const installedSkill = (0, remotion_skills_info_1.getRemotionSkillsInfo)({ remotionRoot }).skills.find(({ name }) => name === skill);
|
|
21
|
+
const removingGlobally = action === 'remove' &&
|
|
22
|
+
(installedSkill === null || installedSkill === void 0 ? void 0 : installedSkill.installedInProject) === false &&
|
|
23
|
+
installedSkill.installedGlobally;
|
|
24
|
+
if (action === 'remove' &&
|
|
25
|
+
!removingGlobally &&
|
|
26
|
+
!(installedSkill === null || installedSkill === void 0 ? void 0 : installedSkill.installedInProject)) {
|
|
27
|
+
throw new Error(`${skill} is not installed.`);
|
|
28
|
+
}
|
|
29
|
+
const packageManager = (0, get_package_manager_1.getPackageManager)({
|
|
30
|
+
remotionRoot,
|
|
31
|
+
packageManager: undefined,
|
|
32
|
+
dirUp: 0,
|
|
33
|
+
logLevel,
|
|
34
|
+
});
|
|
35
|
+
const useBunx = packageManager !== 'unknown' && packageManager.manager === 'bun';
|
|
36
|
+
const executable = useBunx
|
|
37
|
+
? 'bunx'
|
|
38
|
+
: process.platform === 'win32'
|
|
39
|
+
? 'npx.cmd'
|
|
40
|
+
: 'npx';
|
|
41
|
+
const commandArgs = action === 'install'
|
|
42
|
+
? ['add', `remotion-dev/skills@${skill}`, '--yes']
|
|
43
|
+
: ['remove', ...(removingGlobally ? ['--global'] : []), skill, '--yes'];
|
|
44
|
+
const args = useBunx
|
|
45
|
+
? ['--silent', 'skills@1.5.26', ...commandArgs]
|
|
46
|
+
: ['--yes', '--loglevel=error', 'skills@1.5.26', ...commandArgs];
|
|
47
|
+
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, renderer_1.RenderInternals.chalk.gray(`╭─ ${executable} ${args.join(' ')}`));
|
|
48
|
+
const time = Date.now();
|
|
49
|
+
try {
|
|
50
|
+
await new Promise((resolve, reject) => {
|
|
51
|
+
const child = (0, node_child_process_1.spawn)(executable, args, {
|
|
52
|
+
cwd: remotionRoot,
|
|
53
|
+
env: { ...process.env, DISABLE_TELEMETRY: '1' },
|
|
54
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
55
|
+
...(0, package_manager_spawn_options_1.getPackageManagerSpawnOptions)(),
|
|
56
|
+
});
|
|
57
|
+
let output = '';
|
|
58
|
+
const onData = (data) => {
|
|
59
|
+
output = (output + data.toString()).slice(-8000);
|
|
60
|
+
data
|
|
61
|
+
.toString()
|
|
62
|
+
.trim()
|
|
63
|
+
.split('\n')
|
|
64
|
+
.forEach((line) => renderer_1.RenderInternals.Log.info({ indent: true, logLevel }, line));
|
|
65
|
+
};
|
|
66
|
+
child.stdout.on('data', onData);
|
|
67
|
+
child.stderr.on('data', onData);
|
|
68
|
+
child.on('error', reject);
|
|
69
|
+
child.on('close', (code, signal) => {
|
|
70
|
+
if (code === 0) {
|
|
71
|
+
resolve();
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
reject(new Error(`Could not ${action} ${skill} (exit code ${code}, signal ${signal}). ${output.trim()}`));
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
const info = (0, remotion_skills_info_1.getRemotionSkillsInfo)({ remotionRoot });
|
|
79
|
+
const updatedSkill = info.skills.find(({ name }) => name === skill);
|
|
80
|
+
if (action === 'install' && !(updatedSkill === null || updatedSkill === void 0 ? void 0 : updatedSkill.installedInProject)) {
|
|
81
|
+
throw new Error(`The installer finished, but ${skill} was not found in the project. Please try again.`);
|
|
82
|
+
}
|
|
83
|
+
if (action === 'remove' &&
|
|
84
|
+
(removingGlobally
|
|
85
|
+
? updatedSkill === null || updatedSkill === void 0 ? void 0 : updatedSkill.installedGlobally
|
|
86
|
+
: updatedSkill === null || updatedSkill === void 0 ? void 0 : updatedSkill.installedInProject)) {
|
|
87
|
+
throw new Error(`The remover finished, but ${skill} is still installed ${removingGlobally ? 'globally' : 'in the project'}. Please try again.`);
|
|
88
|
+
}
|
|
89
|
+
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, renderer_1.RenderInternals.chalk.gray('╰─ '), `Done in ${Date.now() - time}ms`);
|
|
90
|
+
return info;
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, renderer_1.RenderInternals.chalk.gray('╰─ '), renderer_1.RenderInternals.chalk.red(`Errored in ${Date.now() - time}ms`));
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
finally {
|
|
98
|
+
changingSkillsInProjects.delete(remotionRoot);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const installRemotionSkillHandler = (input) => {
|
|
102
|
+
return changeRemotionSkill({ ...input, action: 'install' });
|
|
103
|
+
};
|
|
104
|
+
exports.installRemotionSkillHandler = installRemotionSkillHandler;
|
|
105
|
+
const removeRemotionSkillHandler = (input) => {
|
|
106
|
+
return changeRemotionSkill({ ...input, action: 'remove' });
|
|
107
|
+
};
|
|
108
|
+
exports.removeRemotionSkillHandler = removeRemotionSkillHandler;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.invalidateBundleHandler = void 0;
|
|
4
|
+
const watch_ignore_next_change_1 = require("../watch-ignore-next-change");
|
|
5
|
+
const source_file_write_queue_1 = require("./source-file-write-queue");
|
|
6
|
+
const invalidateBundleHandler = () => {
|
|
7
|
+
return (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
|
|
8
|
+
return { didInvalidate: await (0, watch_ignore_next_change_1.invalidatePreviouslySuppressedFiles)() };
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
exports.invalidateBundleHandler = invalidateBundleHandler;
|
|
@@ -195,6 +195,7 @@ const moveKeyframes = async ({ sequenceKeyframes, effectKeyframes, clientId, rem
|
|
|
195
195
|
? 'sequence-props'
|
|
196
196
|
: 'effect-props',
|
|
197
197
|
suppressHmrOnFileRestore: true,
|
|
198
|
+
undoRedoNavigation: null,
|
|
198
199
|
});
|
|
199
200
|
for (const snapshot of snapshots) {
|
|
200
201
|
(0, undo_stack_1.suppressUndoStackInvalidation)(snapshot.filePath);
|