@remotion/studio-server 4.0.529 → 4.0.531
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/canvas-capture/generate-canvas-capture-composition.d.ts +14 -0
- package/dist/canvas-capture/generate-canvas-capture-composition.js +239 -0
- package/dist/codemods/add-composition-to-file.d.ts +7 -0
- package/dist/codemods/add-composition-to-file.js +63 -0
- package/dist/codemods/add-effect.d.ts +1 -0
- package/dist/codemods/add-effect.js +8 -0
- package/dist/codemods/apply-codemod-to-file.js +6 -1
- package/dist/codemods/apply-visual-control.d.ts +8 -0
- package/dist/codemods/apply-visual-control.js +89 -0
- package/dist/codemods/delete-effect.d.ts +1 -0
- package/dist/codemods/delete-effect.js +6 -0
- package/dist/codemods/delete-jsx-node.d.ts +22 -0
- package/dist/codemods/delete-jsx-node.js +17 -0
- package/dist/codemods/duplicate-composition.d.ts +2 -0
- package/dist/codemods/duplicate-composition.js +64 -0
- package/dist/codemods/duplicate-effect.d.ts +1 -0
- package/dist/codemods/duplicate-effect.js +6 -0
- package/dist/codemods/duplicate-jsx-node.d.ts +25 -0
- package/dist/codemods/duplicate-jsx-node.js +26 -0
- package/dist/codemods/format-file-content.d.ts +7 -0
- package/dist/codemods/format-file-content.js +80 -0
- package/dist/codemods/format-inline-content.d.ts +18 -0
- package/dist/codemods/format-inline-content.js +78 -0
- package/dist/codemods/insert-video-layers.d.ts +11 -0
- package/dist/codemods/insert-video-layers.js +5 -0
- package/dist/codemods/recast-mods.d.ts +13 -0
- package/dist/codemods/recast-mods.js +902 -0
- package/dist/codemods/reorder-effect.d.ts +1 -0
- package/dist/codemods/reorder-effect.js +5 -0
- package/dist/codemods/reorder-sequence.d.ts +1 -0
- package/dist/codemods/reorder-sequence.js +5 -0
- package/dist/codemods/simple-diff.d.ts +5 -0
- package/dist/codemods/simple-diff.js +39 -0
- package/dist/codemods/split-video-from-audio.d.ts +1 -0
- package/dist/codemods/split-video-from-audio.js +5 -0
- package/dist/codemods/update-default-props.d.ts +1 -0
- package/dist/codemods/update-default-props.js +6 -0
- package/dist/codemods/update-inline-caption-patches.d.ts +1 -0
- package/dist/codemods/update-inline-caption-patches.js +5 -0
- package/dist/codemods/update-keyframes/ensure-imports-and-frame-hook.d.ts +1 -0
- package/dist/codemods/update-keyframes/ensure-imports-and-frame-hook.js +7 -0
- package/dist/codemods/update-keyframes/update-keyframes.d.ts +3 -3
- package/dist/codemods/update-keyframes/update-keyframes.js +1 -1
- package/dist/codemods/update-sequence-props/update-sequence-props.js +1 -1
- package/dist/helpers/get-file-source.js +6 -4
- package/dist/helpers/get-local-package-override.d.ts +5 -0
- package/dist/helpers/get-local-package-override.js +39 -0
- package/dist/helpers/install-command.js +1 -0
- package/dist/helpers/resolve-composition-component.d.ts +2 -1
- package/dist/helpers/resolve-composition-component.js +66 -15
- package/dist/index.d.ts +5 -0
- package/dist/index.js +3 -0
- package/dist/open-directory-in-finder.js +11 -9
- package/dist/preview-server/api-routes.js +32 -12
- package/dist/preview-server/element-install-state.js +10 -2
- package/dist/preview-server/routes/add-composition.d.ts +3 -0
- package/dist/preview-server/routes/add-composition.js +97 -0
- package/dist/preview-server/routes/add-folder.d.ts +3 -0
- package/dist/preview-server/routes/add-folder.js +107 -0
- package/dist/preview-server/routes/add-keyframes.d.ts +2 -2
- package/dist/preview-server/routes/add-keyframes.js +49 -6
- package/dist/preview-server/routes/can-update-sequence-props.js +27 -5
- package/dist/preview-server/routes/delete-composition.d.ts +3 -0
- package/dist/preview-server/routes/delete-composition.js +104 -0
- package/dist/preview-server/routes/delete-jsx-node.d.ts +3 -0
- package/dist/preview-server/routes/delete-jsx-node.js +126 -0
- package/dist/preview-server/routes/delete-nodes.d.ts +3 -0
- package/dist/preview-server/routes/delete-nodes.js +142 -0
- package/dist/preview-server/routes/duplicate-composition.d.ts +3 -0
- package/dist/preview-server/routes/duplicate-composition.js +114 -0
- package/dist/preview-server/routes/duplicate-nodes.d.ts +3 -0
- package/dist/preview-server/routes/duplicate-nodes.js +123 -0
- package/dist/preview-server/routes/insert-basic-captions.js +2 -1
- package/dist/preview-server/routes/insert-composition-element.d.ts +3 -0
- package/dist/preview-server/routes/insert-composition-element.js +236 -0
- package/dist/preview-server/routes/insert-element.js +26 -19
- package/dist/preview-server/routes/insert-video-layers.d.ts +3 -0
- package/dist/preview-server/routes/insert-video-layers.js +68 -0
- package/dist/preview-server/routes/install-dependency.js +10 -1
- package/dist/preview-server/routes/move-composition.d.ts +3 -0
- package/dist/preview-server/routes/move-composition.js +148 -0
- package/dist/preview-server/routes/move-folder.d.ts +3 -0
- package/dist/preview-server/routes/move-folder.js +151 -0
- package/dist/preview-server/routes/precompose-jsx-nodes.d.ts +3 -0
- package/dist/preview-server/routes/precompose-jsx-nodes.js +209 -0
- package/dist/preview-server/routes/rename-composition.d.ts +3 -0
- package/dist/preview-server/routes/rename-composition.js +105 -0
- package/dist/preview-server/routes/rename-folder.d.ts +3 -0
- package/dist/preview-server/routes/rename-folder.js +111 -0
- package/dist/preview-server/routes/reorder-sequence.js +7 -2
- package/dist/preview-server/routes/replace-video-source.js +7 -2
- package/dist/preview-server/routes/save-sequence-props.js +6 -3
- package/dist/preview-server/routes/split-sequences.d.ts +3 -0
- package/dist/preview-server/routes/split-sequences.js +122 -0
- package/dist/preview-server/routes/split-video-from-audio.js +6 -1
- package/dist/preview-server/routes/unwrap-folder.d.ts +3 -0
- package/dist/preview-server/routes/unwrap-folder.js +107 -0
- package/dist/preview-server/routes/update-composition-metadata.d.ts +3 -0
- package/dist/preview-server/routes/update-composition-metadata.js +110 -0
- package/dist/preview-server/routes/update-public-license.d.ts +11 -0
- package/dist/preview-server/routes/update-public-license.js +97 -0
- package/dist/preview-server/routes/wrap-node.d.ts +3 -0
- package/dist/preview-server/routes/wrap-node.js +108 -0
- package/dist/preview-server/studio-protocol/handle-discovery.js +3 -10
- package/dist/preview-server/studio-protocol/handle-install.js +0 -3
- package/dist/preview-server/undo-stack.d.ts +1 -1
- package/dist/preview-server/undo-stack.js +6 -0
- package/dist/start-studio.js +1 -1
- package/package.json +8 -8
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.moveFolderHandler = void 0;
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const codemods_1 = require("@remotion/codemods");
|
|
10
|
+
const renderer_1 = require("@remotion/renderer");
|
|
11
|
+
const file_watcher_1 = require("../../file-watcher");
|
|
12
|
+
const resolve_file_inside_project_1 = require("../../helpers/resolve-file-inside-project");
|
|
13
|
+
const format_log_file_location_1 = require("../format-log-file-location");
|
|
14
|
+
const project_info_1 = require("../project-info");
|
|
15
|
+
const sequence_node_path_mutation_1 = require("../sequence-node-path-mutation");
|
|
16
|
+
const undo_stack_1 = require("../undo-stack");
|
|
17
|
+
const can_update_default_props_1 = require("./can-update-default-props");
|
|
18
|
+
const source_file_write_queue_1 = require("./source-file-write-queue");
|
|
19
|
+
const moveFolderHandler = ({ input: request, logLevel, remotionRoot, entryPoint }) => (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
var _c, _d;
|
|
22
|
+
try {
|
|
23
|
+
let filePath;
|
|
24
|
+
if ((_a = request.symbolicatedStack) === null || _a === void 0 ? void 0 : _a.originalFileName) {
|
|
25
|
+
filePath = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
|
|
26
|
+
remotionRoot,
|
|
27
|
+
fileName: request.symbolicatedStack.originalFileName,
|
|
28
|
+
action: 'move a folder in',
|
|
29
|
+
}).absolutePath;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
const { rootFile } = await (0, project_info_1.getProjectInfo)(remotionRoot, entryPoint);
|
|
33
|
+
if (rootFile === null) {
|
|
34
|
+
throw new Error('Cannot find the Remotion root file');
|
|
35
|
+
}
|
|
36
|
+
filePath = rootFile;
|
|
37
|
+
}
|
|
38
|
+
(0, can_update_default_props_1.checkIfTypeScriptFile)(filePath);
|
|
39
|
+
const destination = request.destination.type === 'folder'
|
|
40
|
+
? {
|
|
41
|
+
type: 'folder',
|
|
42
|
+
folder: {
|
|
43
|
+
name: request.destination.folderName,
|
|
44
|
+
parentName: request.destination.parentName,
|
|
45
|
+
},
|
|
46
|
+
}
|
|
47
|
+
: request.destination.type === 'root'
|
|
48
|
+
? request.destination
|
|
49
|
+
: {
|
|
50
|
+
type: request.destination.type,
|
|
51
|
+
target: request.destination.target.type === 'composition'
|
|
52
|
+
? request.destination.target
|
|
53
|
+
: {
|
|
54
|
+
type: 'folder',
|
|
55
|
+
name: request.destination.target.folderName,
|
|
56
|
+
parentName: request.destination.target.parentName,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
const result = (0, codemods_1.moveFolder)({
|
|
60
|
+
project: {
|
|
61
|
+
files: { [filePath]: (0, node_fs_1.readFileSync)(filePath, 'utf-8') },
|
|
62
|
+
rootDir: node_path_1.default.dirname(filePath),
|
|
63
|
+
},
|
|
64
|
+
compositionFile: filePath,
|
|
65
|
+
folder: { name: request.folderName, parentName: request.parentName },
|
|
66
|
+
destination,
|
|
67
|
+
});
|
|
68
|
+
for (const change of result.changes) {
|
|
69
|
+
const currentContents = (0, node_fs_1.existsSync)(change.filePath)
|
|
70
|
+
? (0, node_fs_1.readFileSync)(change.filePath, 'utf-8')
|
|
71
|
+
: null;
|
|
72
|
+
if (currentContents !== change.previousContents) {
|
|
73
|
+
throw new Error(`Source changed before moving folder: ${change.filePath}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const mutationFiles = [
|
|
77
|
+
...new Set(result.nodePathRemappings.map((remapping) => remapping.filePath)),
|
|
78
|
+
].map((absolutePath) => ({
|
|
79
|
+
absolutePath,
|
|
80
|
+
remappings: result.nodePathRemappings
|
|
81
|
+
.filter((remapping) => remapping.filePath === absolutePath)
|
|
82
|
+
.map(({ oldNodePath, newNodePath, oldJsxName, newJsxName }) => ({
|
|
83
|
+
oldNodePath,
|
|
84
|
+
newNodePath,
|
|
85
|
+
oldJsxName,
|
|
86
|
+
newJsxName,
|
|
87
|
+
})),
|
|
88
|
+
}));
|
|
89
|
+
const nodePathMutation = mutationFiles.length === 0
|
|
90
|
+
? null
|
|
91
|
+
: (0, sequence_node_path_mutation_1.broadcastSequenceNodePathMutation)(mutationFiles, null);
|
|
92
|
+
if (result.changes.length > 0) {
|
|
93
|
+
const logLine = (_c = (_b = request.symbolicatedStack) === null || _b === void 0 ? void 0 : _b.originalLineNumber) !== null && _c !== void 0 ? _c : 1;
|
|
94
|
+
const folderPath = request.parentName
|
|
95
|
+
? `${request.parentName}/${request.folderName}`
|
|
96
|
+
: request.folderName;
|
|
97
|
+
(0, undo_stack_1.pushTransactionToUndoStack)({
|
|
98
|
+
snapshots: result.changes.map((change) => {
|
|
99
|
+
var _a;
|
|
100
|
+
var _b;
|
|
101
|
+
return ({
|
|
102
|
+
filePath: change.filePath,
|
|
103
|
+
oldContents: change.previousContents,
|
|
104
|
+
newContents: change.nextContents,
|
|
105
|
+
logLine: change.filePath === filePath ? logLine : 1,
|
|
106
|
+
nodePathRemappings: (_b = (_a = mutationFiles.find((mutation) => mutation.absolutePath === change.filePath)) === null || _a === void 0 ? void 0 : _a.remappings) !== null && _b !== void 0 ? _b : null,
|
|
107
|
+
});
|
|
108
|
+
}),
|
|
109
|
+
logLevel,
|
|
110
|
+
remotionRoot,
|
|
111
|
+
description: {
|
|
112
|
+
undoMessage: `↩️ Move of folder "${folderPath}"`,
|
|
113
|
+
redoMessage: `↪️ Move of folder "${folderPath}"`,
|
|
114
|
+
},
|
|
115
|
+
entryType: 'move-composition-or-folder',
|
|
116
|
+
suppressHmrOnFileRestore: false,
|
|
117
|
+
undoRedoNavigation: request.undoRedoNavigation,
|
|
118
|
+
});
|
|
119
|
+
for (const change of result.changes) {
|
|
120
|
+
if (change.nextContents === null) {
|
|
121
|
+
throw new Error('Moving a folder cannot remove source files');
|
|
122
|
+
}
|
|
123
|
+
(0, undo_stack_1.suppressUndoStackInvalidation)(change.filePath);
|
|
124
|
+
(0, file_watcher_1.writeFileAndNotifyFileWatchers)({
|
|
125
|
+
file: change.filePath,
|
|
126
|
+
content: change.nextContents,
|
|
127
|
+
originatorClientId: undefined,
|
|
128
|
+
metadata: mutationFiles.some((mutation) => mutation.absolutePath === change.filePath)
|
|
129
|
+
? { skipSequencePropsUpdate: true }
|
|
130
|
+
: null,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
|
|
134
|
+
remotionRoot,
|
|
135
|
+
absolutePath: filePath,
|
|
136
|
+
line: logLine,
|
|
137
|
+
});
|
|
138
|
+
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${(0, source_file_write_queue_1.getCodemodTimingPrefix)(logLevel)}${renderer_1.RenderInternals.chalk.blueBright(locationLabel)} Moved folder "${folderPath}"`);
|
|
139
|
+
(0, undo_stack_1.printUndoHint)(logLevel);
|
|
140
|
+
}
|
|
141
|
+
return { success: true, nodePathMutation };
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
return {
|
|
145
|
+
success: false,
|
|
146
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
147
|
+
stack: error instanceof Error ? ((_d = error.stack) !== null && _d !== void 0 ? _d : '') : '',
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
exports.moveFolderHandler = moveFolderHandler;
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.precomposeJsxNodesHandler = void 0;
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const codemods_1 = require("@remotion/codemods");
|
|
6
|
+
const renderer_1 = require("@remotion/renderer");
|
|
7
|
+
const file_watcher_1 = require("../../file-watcher");
|
|
8
|
+
const resolve_file_inside_project_1 = require("../../helpers/resolve-file-inside-project");
|
|
9
|
+
const format_log_file_location_1 = require("../format-log-file-location");
|
|
10
|
+
const sequence_node_path_mutation_1 = require("../sequence-node-path-mutation");
|
|
11
|
+
const undo_stack_1 = require("../undo-stack");
|
|
12
|
+
const source_file_write_queue_1 = require("./source-file-write-queue");
|
|
13
|
+
const precomposeJsxNodesHandler = ({ input: { nodes, dryRun, compositionFile, compositionId, metadata, existingCompositionIds, }, remotionRoot, logLevel, }) => (0, source_file_write_queue_1.withSourceFileWriteQueue)(() => {
|
|
14
|
+
var _a;
|
|
15
|
+
const attemptedWrites = [];
|
|
16
|
+
let undoEntryPushed = false;
|
|
17
|
+
try {
|
|
18
|
+
if (nodes.length === 0) {
|
|
19
|
+
throw new Error('No JSX sequences were selected');
|
|
20
|
+
}
|
|
21
|
+
const resolved = nodes.map(({ fileName, nodePath }) => ({
|
|
22
|
+
...(0, resolve_file_inside_project_1.resolveFileInsideProject)({
|
|
23
|
+
remotionRoot,
|
|
24
|
+
fileName,
|
|
25
|
+
action: 'modify',
|
|
26
|
+
}),
|
|
27
|
+
nodePath,
|
|
28
|
+
}));
|
|
29
|
+
const { absolutePath } = resolved[0];
|
|
30
|
+
if (resolved.some((node) => node.absolutePath !== absolutePath)) {
|
|
31
|
+
throw new Error('Selected sequences must be in the same source file');
|
|
32
|
+
}
|
|
33
|
+
const registration = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
|
|
34
|
+
remotionRoot,
|
|
35
|
+
fileName: compositionFile,
|
|
36
|
+
action: 'modify',
|
|
37
|
+
});
|
|
38
|
+
const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
|
|
39
|
+
const registrationContents = registration.absolutePath === absolutePath
|
|
40
|
+
? fileContents
|
|
41
|
+
: (0, node_fs_1.readFileSync)(registration.absolutePath, 'utf-8');
|
|
42
|
+
const files = {
|
|
43
|
+
[absolutePath]: fileContents,
|
|
44
|
+
[registration.absolutePath]: registrationContents,
|
|
45
|
+
};
|
|
46
|
+
const project = { files, rootDir: remotionRoot };
|
|
47
|
+
const codemodInput = {
|
|
48
|
+
project,
|
|
49
|
+
nodes: resolved.map(({ nodePath }) => ({
|
|
50
|
+
filePath: absolutePath,
|
|
51
|
+
nodePath,
|
|
52
|
+
})),
|
|
53
|
+
compositionFile: registration.absolutePath,
|
|
54
|
+
compositionId,
|
|
55
|
+
metadata,
|
|
56
|
+
existingCompositionIds,
|
|
57
|
+
};
|
|
58
|
+
if (dryRun) {
|
|
59
|
+
const eligibility = (0, codemods_1.canPrecomposeJsxNodes)(codemodInput);
|
|
60
|
+
return Promise.resolve({
|
|
61
|
+
success: true,
|
|
62
|
+
...eligibility,
|
|
63
|
+
nodePathMutation: null,
|
|
64
|
+
newCompositionId: null,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
let result;
|
|
68
|
+
try {
|
|
69
|
+
result = (0, codemods_1.precomposeJsxNodes)(codemodInput);
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
return Promise.resolve({
|
|
73
|
+
success: true,
|
|
74
|
+
canPrecompose: false,
|
|
75
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
76
|
+
nodePathMutation: null,
|
|
77
|
+
newCompositionId: null,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
const changes = [...result.changes].sort((a, b) => Number(b.filePath === absolutePath) -
|
|
81
|
+
Number(a.filePath === absolutePath));
|
|
82
|
+
if (!changes.some(({ filePath }) => filePath === absolutePath) ||
|
|
83
|
+
!changes.some(({ filePath }) => filePath === registration.absolutePath)) {
|
|
84
|
+
throw new Error('Could not pre-compose selected sequences');
|
|
85
|
+
}
|
|
86
|
+
for (const change of changes) {
|
|
87
|
+
if (!Object.hasOwn(files, change.filePath) ||
|
|
88
|
+
change.previousContents !== files[change.filePath] ||
|
|
89
|
+
change.nextContents === null ||
|
|
90
|
+
(0, node_fs_1.readFileSync)(change.filePath, 'utf-8') !== change.previousContents) {
|
|
91
|
+
throw new Error('Source changed before applying pre-compose');
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const remappingsByFile = changes.map(({ filePath }) => ({
|
|
95
|
+
absolutePath: filePath,
|
|
96
|
+
remappings: result.nodePathRemappings
|
|
97
|
+
.filter((remapping) => remapping.filePath === filePath)
|
|
98
|
+
.map(({ oldNodePath, newNodePath, oldJsxName, newJsxName }) => ({
|
|
99
|
+
oldNodePath,
|
|
100
|
+
newNodePath,
|
|
101
|
+
oldJsxName,
|
|
102
|
+
newJsxName,
|
|
103
|
+
})),
|
|
104
|
+
}));
|
|
105
|
+
const mutationFiles = remappingsByFile.filter(({ remappings }) => remappings.length > 0);
|
|
106
|
+
(0, undo_stack_1.pushTransactionToUndoStack)({
|
|
107
|
+
snapshots: changes.map((change) => {
|
|
108
|
+
var _a;
|
|
109
|
+
const remappings = (_a = remappingsByFile.find(({ absolutePath: filePath }) => filePath === change.filePath)) === null || _a === void 0 ? void 0 : _a.remappings;
|
|
110
|
+
return {
|
|
111
|
+
filePath: change.filePath,
|
|
112
|
+
oldContents: change.previousContents,
|
|
113
|
+
newContents: change.nextContents,
|
|
114
|
+
logLine: change.filePath === absolutePath ? result.logLine : 1,
|
|
115
|
+
nodePathRemappings: remappings && remappings.length > 0 ? remappings : null,
|
|
116
|
+
};
|
|
117
|
+
}),
|
|
118
|
+
logLevel,
|
|
119
|
+
remotionRoot,
|
|
120
|
+
description: {
|
|
121
|
+
undoMessage: '↩️ Pre-compose sequences',
|
|
122
|
+
redoMessage: '↪️ Pre-compose sequences',
|
|
123
|
+
},
|
|
124
|
+
entryType: 'precompose-jsx-nodes',
|
|
125
|
+
suppressHmrOnFileRestore: false,
|
|
126
|
+
undoRedoNavigation: {
|
|
127
|
+
undoRoute: `/${compositionId}`,
|
|
128
|
+
redoRoute: `/${result.newCompositionId}`,
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
undoEntryPushed = true;
|
|
132
|
+
for (const change of changes) {
|
|
133
|
+
const { nextContents: output, previousContents } = change;
|
|
134
|
+
if (output === null || previousContents === null) {
|
|
135
|
+
throw new Error('Could not write a pre-composed source file');
|
|
136
|
+
}
|
|
137
|
+
const skipSequencePropsUpdate = remappingsByFile.some(({ absolutePath: filePath, remappings }) => filePath === change.filePath && remappings.length > 0);
|
|
138
|
+
attemptedWrites.push({
|
|
139
|
+
filePath: change.filePath,
|
|
140
|
+
previousContents,
|
|
141
|
+
nextContents: output,
|
|
142
|
+
skipSequencePropsUpdate,
|
|
143
|
+
});
|
|
144
|
+
(0, undo_stack_1.suppressUndoStackInvalidation)(change.filePath);
|
|
145
|
+
(0, file_watcher_1.writeFileAndNotifyFileWatchers)({
|
|
146
|
+
file: change.filePath,
|
|
147
|
+
content: output,
|
|
148
|
+
originatorClientId: undefined,
|
|
149
|
+
metadata: skipSequencePropsUpdate
|
|
150
|
+
? { skipSequencePropsUpdate: true }
|
|
151
|
+
: null,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
|
|
155
|
+
remotionRoot,
|
|
156
|
+
absolutePath,
|
|
157
|
+
line: result.logLine,
|
|
158
|
+
});
|
|
159
|
+
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${(0, source_file_write_queue_1.getCodemodTimingPrefix)(logLevel)}${renderer_1.RenderInternals.chalk.blueBright(locationLabel)} Pre-composed ${nodes.length} sequence${nodes.length === 1 ? '' : 's'}`);
|
|
160
|
+
for (const change of changes) {
|
|
161
|
+
renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, `[precompose-jsx-nodes] Wrote ${(0, resolve_file_inside_project_1.resolveFileInsideProject)({
|
|
162
|
+
remotionRoot,
|
|
163
|
+
fileName: change.filePath,
|
|
164
|
+
action: 'modify',
|
|
165
|
+
}).fileRelativeToRoot}`);
|
|
166
|
+
}
|
|
167
|
+
(0, undo_stack_1.printUndoHint)(logLevel);
|
|
168
|
+
const nodePathMutation = mutationFiles.length === 0
|
|
169
|
+
? null
|
|
170
|
+
: (0, sequence_node_path_mutation_1.broadcastSequenceNodePathMutation)(mutationFiles, null);
|
|
171
|
+
return Promise.resolve({
|
|
172
|
+
success: true,
|
|
173
|
+
canPrecompose: true,
|
|
174
|
+
reason: null,
|
|
175
|
+
nodePathMutation,
|
|
176
|
+
newCompositionId: result.newCompositionId,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
catch (err) {
|
|
180
|
+
for (const change of attemptedWrites.reverse()) {
|
|
181
|
+
try {
|
|
182
|
+
if ((0, node_fs_1.readFileSync)(change.filePath, 'utf-8') !== change.nextContents) {
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
(0, undo_stack_1.suppressUndoStackInvalidation)(change.filePath);
|
|
186
|
+
(0, file_watcher_1.writeFileAndNotifyFileWatchers)({
|
|
187
|
+
file: change.filePath,
|
|
188
|
+
content: change.previousContents,
|
|
189
|
+
originatorClientId: undefined,
|
|
190
|
+
metadata: change.skipSequencePropsUpdate
|
|
191
|
+
? { skipSequencePropsUpdate: true }
|
|
192
|
+
: null,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
catch (_b) {
|
|
196
|
+
// Preserve subsequent edits and the original pre-compose error.
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (undoEntryPushed) {
|
|
200
|
+
(0, undo_stack_1.discardLastUndoEntryAfterFailedCommit)();
|
|
201
|
+
}
|
|
202
|
+
return Promise.resolve({
|
|
203
|
+
success: false,
|
|
204
|
+
reason: err.message,
|
|
205
|
+
stack: (_a = err.stack) !== null && _a !== void 0 ? _a : '',
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
exports.precomposeJsxNodesHandler = precomposeJsxNodesHandler;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.renameCompositionHandler = void 0;
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const codemods_1 = require("@remotion/codemods");
|
|
10
|
+
const renderer_1 = require("@remotion/renderer");
|
|
11
|
+
const file_watcher_1 = require("../../file-watcher");
|
|
12
|
+
const resolve_file_inside_project_1 = require("../../helpers/resolve-file-inside-project");
|
|
13
|
+
const format_log_file_location_1 = require("../format-log-file-location");
|
|
14
|
+
const project_info_1 = require("../project-info");
|
|
15
|
+
const undo_stack_1 = require("../undo-stack");
|
|
16
|
+
const can_update_default_props_1 = require("./can-update-default-props");
|
|
17
|
+
const source_file_write_queue_1 = require("./source-file-write-queue");
|
|
18
|
+
const renameCompositionHandler = ({ input: request, logLevel, remotionRoot, entryPoint }) => (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
var _c, _d;
|
|
21
|
+
try {
|
|
22
|
+
let filePath;
|
|
23
|
+
if ((_a = request.symbolicatedStack) === null || _a === void 0 ? void 0 : _a.originalFileName) {
|
|
24
|
+
filePath = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
|
|
25
|
+
remotionRoot,
|
|
26
|
+
fileName: request.symbolicatedStack.originalFileName,
|
|
27
|
+
action: 'rename a composition in',
|
|
28
|
+
}).absolutePath;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
const { rootFile } = await (0, project_info_1.getProjectInfo)(remotionRoot, entryPoint);
|
|
32
|
+
if (rootFile === null) {
|
|
33
|
+
throw new Error('Cannot find the Remotion root file');
|
|
34
|
+
}
|
|
35
|
+
filePath = rootFile;
|
|
36
|
+
}
|
|
37
|
+
(0, can_update_default_props_1.checkIfTypeScriptFile)(filePath);
|
|
38
|
+
const result = (0, codemods_1.renameComposition)({
|
|
39
|
+
project: {
|
|
40
|
+
files: { [filePath]: (0, node_fs_1.readFileSync)(filePath, 'utf-8') },
|
|
41
|
+
rootDir: node_path_1.default.dirname(filePath),
|
|
42
|
+
},
|
|
43
|
+
compositionFile: filePath,
|
|
44
|
+
compositionId: request.idToRename,
|
|
45
|
+
newId: request.newId,
|
|
46
|
+
});
|
|
47
|
+
for (const change of result.changes) {
|
|
48
|
+
const currentContents = (0, node_fs_1.existsSync)(change.filePath)
|
|
49
|
+
? (0, node_fs_1.readFileSync)(change.filePath, 'utf-8')
|
|
50
|
+
: null;
|
|
51
|
+
if (currentContents !== change.previousContents) {
|
|
52
|
+
throw new Error(`Source changed before renaming composition: ${change.filePath}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (result.changes.length > 0) {
|
|
56
|
+
const logLine = (_c = (_b = request.symbolicatedStack) === null || _b === void 0 ? void 0 : _b.originalLineNumber) !== null && _c !== void 0 ? _c : 1;
|
|
57
|
+
(0, undo_stack_1.pushTransactionToUndoStack)({
|
|
58
|
+
snapshots: result.changes.map((change) => ({
|
|
59
|
+
filePath: change.filePath,
|
|
60
|
+
oldContents: change.previousContents,
|
|
61
|
+
newContents: change.nextContents,
|
|
62
|
+
logLine: change.filePath === filePath ? logLine : 1,
|
|
63
|
+
nodePathRemappings: null,
|
|
64
|
+
})),
|
|
65
|
+
logLevel,
|
|
66
|
+
remotionRoot,
|
|
67
|
+
description: {
|
|
68
|
+
undoMessage: `↩️ Rename of composition "${request.idToRename}" to "${request.newId}"`,
|
|
69
|
+
redoMessage: `↪️ Rename of composition "${request.idToRename}" to "${request.newId}"`,
|
|
70
|
+
},
|
|
71
|
+
entryType: 'rename-composition',
|
|
72
|
+
suppressHmrOnFileRestore: false,
|
|
73
|
+
undoRedoNavigation: request.undoRedoNavigation,
|
|
74
|
+
});
|
|
75
|
+
for (const change of result.changes) {
|
|
76
|
+
if (change.nextContents === null) {
|
|
77
|
+
throw new Error('Renaming a composition cannot remove source files');
|
|
78
|
+
}
|
|
79
|
+
(0, undo_stack_1.suppressUndoStackInvalidation)(change.filePath);
|
|
80
|
+
(0, file_watcher_1.writeFileAndNotifyFileWatchers)({
|
|
81
|
+
file: change.filePath,
|
|
82
|
+
content: change.nextContents,
|
|
83
|
+
originatorClientId: undefined,
|
|
84
|
+
metadata: null,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
|
|
88
|
+
remotionRoot,
|
|
89
|
+
absolutePath: filePath,
|
|
90
|
+
line: logLine,
|
|
91
|
+
});
|
|
92
|
+
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${(0, source_file_write_queue_1.getCodemodTimingPrefix)(logLevel)}${renderer_1.RenderInternals.chalk.blueBright(locationLabel)} Renamed composition "${request.idToRename}" to "${request.newId}"`);
|
|
93
|
+
(0, undo_stack_1.printUndoHint)(logLevel);
|
|
94
|
+
}
|
|
95
|
+
return { success: true, nodePathMutation: null };
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
return {
|
|
99
|
+
success: false,
|
|
100
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
101
|
+
stack: error instanceof Error ? ((_d = error.stack) !== null && _d !== void 0 ? _d : '') : '',
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
exports.renameCompositionHandler = renameCompositionHandler;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.renameFolderHandler = void 0;
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const codemods_1 = require("@remotion/codemods");
|
|
10
|
+
const renderer_1 = require("@remotion/renderer");
|
|
11
|
+
const file_watcher_1 = require("../../file-watcher");
|
|
12
|
+
const resolve_file_inside_project_1 = require("../../helpers/resolve-file-inside-project");
|
|
13
|
+
const format_log_file_location_1 = require("../format-log-file-location");
|
|
14
|
+
const project_info_1 = require("../project-info");
|
|
15
|
+
const undo_stack_1 = require("../undo-stack");
|
|
16
|
+
const can_update_default_props_1 = require("./can-update-default-props");
|
|
17
|
+
const source_file_write_queue_1 = require("./source-file-write-queue");
|
|
18
|
+
const renameFolderHandler = ({ input: request, logLevel, remotionRoot, entryPoint }) => (0, source_file_write_queue_1.withSourceFileWriteQueue)(async () => {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
var _c, _d;
|
|
21
|
+
try {
|
|
22
|
+
let filePath;
|
|
23
|
+
if ((_a = request.symbolicatedStack) === null || _a === void 0 ? void 0 : _a.originalFileName) {
|
|
24
|
+
filePath = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
|
|
25
|
+
remotionRoot,
|
|
26
|
+
fileName: request.symbolicatedStack.originalFileName,
|
|
27
|
+
action: 'rename a folder in',
|
|
28
|
+
}).absolutePath;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
const { rootFile } = await (0, project_info_1.getProjectInfo)(remotionRoot, entryPoint);
|
|
32
|
+
if (rootFile === null) {
|
|
33
|
+
throw new Error('Cannot find the Remotion root file');
|
|
34
|
+
}
|
|
35
|
+
filePath = rootFile;
|
|
36
|
+
}
|
|
37
|
+
(0, can_update_default_props_1.checkIfTypeScriptFile)(filePath);
|
|
38
|
+
const result = (0, codemods_1.renameFolder)({
|
|
39
|
+
project: {
|
|
40
|
+
files: { [filePath]: (0, node_fs_1.readFileSync)(filePath, 'utf-8') },
|
|
41
|
+
rootDir: node_path_1.default.dirname(filePath),
|
|
42
|
+
},
|
|
43
|
+
compositionFile: filePath,
|
|
44
|
+
folder: { name: request.folderName, parentName: request.parentName },
|
|
45
|
+
newName: request.newName,
|
|
46
|
+
});
|
|
47
|
+
for (const change of result.changes) {
|
|
48
|
+
const currentContents = (0, node_fs_1.existsSync)(change.filePath)
|
|
49
|
+
? (0, node_fs_1.readFileSync)(change.filePath, 'utf-8')
|
|
50
|
+
: null;
|
|
51
|
+
if (currentContents !== change.previousContents) {
|
|
52
|
+
throw new Error(`Source changed before renaming folder: ${change.filePath}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (result.changes.length > 0) {
|
|
56
|
+
const logLine = (_c = (_b = request.symbolicatedStack) === null || _b === void 0 ? void 0 : _b.originalLineNumber) !== null && _c !== void 0 ? _c : 1;
|
|
57
|
+
const oldPath = request.parentName
|
|
58
|
+
? `${request.parentName}/${request.folderName}`
|
|
59
|
+
: request.folderName;
|
|
60
|
+
const newPath = request.parentName
|
|
61
|
+
? `${request.parentName}/${request.newName}`
|
|
62
|
+
: request.newName;
|
|
63
|
+
(0, undo_stack_1.pushTransactionToUndoStack)({
|
|
64
|
+
snapshots: result.changes.map((change) => ({
|
|
65
|
+
filePath: change.filePath,
|
|
66
|
+
oldContents: change.previousContents,
|
|
67
|
+
newContents: change.nextContents,
|
|
68
|
+
logLine: change.filePath === filePath ? logLine : 1,
|
|
69
|
+
nodePathRemappings: null,
|
|
70
|
+
})),
|
|
71
|
+
logLevel,
|
|
72
|
+
remotionRoot,
|
|
73
|
+
description: {
|
|
74
|
+
undoMessage: `↩️ Rename of folder "${oldPath}" to "${newPath}"`,
|
|
75
|
+
redoMessage: `↪️ Rename of folder "${oldPath}" to "${newPath}"`,
|
|
76
|
+
},
|
|
77
|
+
entryType: 'rename-folder',
|
|
78
|
+
suppressHmrOnFileRestore: false,
|
|
79
|
+
undoRedoNavigation: request.undoRedoNavigation,
|
|
80
|
+
});
|
|
81
|
+
for (const change of result.changes) {
|
|
82
|
+
if (change.nextContents === null) {
|
|
83
|
+
throw new Error('Renaming a folder cannot remove source files');
|
|
84
|
+
}
|
|
85
|
+
(0, undo_stack_1.suppressUndoStackInvalidation)(change.filePath);
|
|
86
|
+
(0, file_watcher_1.writeFileAndNotifyFileWatchers)({
|
|
87
|
+
file: change.filePath,
|
|
88
|
+
content: change.nextContents,
|
|
89
|
+
originatorClientId: undefined,
|
|
90
|
+
metadata: null,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
const locationLabel = (0, format_log_file_location_1.formatLogFileLocation)({
|
|
94
|
+
remotionRoot,
|
|
95
|
+
absolutePath: filePath,
|
|
96
|
+
line: logLine,
|
|
97
|
+
});
|
|
98
|
+
renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${(0, source_file_write_queue_1.getCodemodTimingPrefix)(logLevel)}${renderer_1.RenderInternals.chalk.blueBright(locationLabel)} Renamed folder "${oldPath}"`);
|
|
99
|
+
(0, undo_stack_1.printUndoHint)(logLevel);
|
|
100
|
+
}
|
|
101
|
+
return { success: true, nodePathMutation: null };
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
return {
|
|
105
|
+
success: false,
|
|
106
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
107
|
+
stack: error instanceof Error ? ((_d = error.stack) !== null && _d !== void 0 ? _d : '') : '',
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
exports.renameFolderHandler = renameFolderHandler;
|
|
@@ -23,7 +23,7 @@ const reorderSequenceHandler = ({ input: { fileName, sourceNodePath, targetNodeP
|
|
|
23
23
|
action: 'modify',
|
|
24
24
|
});
|
|
25
25
|
const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
|
|
26
|
-
const result = await (0, codemods_1.
|
|
26
|
+
const result = await (0, codemods_1.reorderNode)({
|
|
27
27
|
project: { files: { [absolutePath]: fileContents }, rootDir: remotionRoot },
|
|
28
28
|
node: { filePath: absolutePath, nodePath: sourceNodePath.nodePath },
|
|
29
29
|
target: { filePath: absolutePath, nodePath: targetNodePath.nodePath },
|
|
@@ -31,7 +31,12 @@ const reorderSequenceHandler = ({ input: { fileName, sourceNodePath, targetNodeP
|
|
|
31
31
|
});
|
|
32
32
|
const output = (_b = (_a = result.changes[0]) === null || _a === void 0 ? void 0 : _a.nextContents) !== null && _b !== void 0 ? _b : fileContents;
|
|
33
33
|
const { sequenceLabel, logLine } = result.editDetails[0];
|
|
34
|
-
const nodePathRemappings = result.nodePathRemappings.map(({ oldNodePath, newNodePath }) => ({
|
|
34
|
+
const nodePathRemappings = result.nodePathRemappings.map(({ oldNodePath, newNodePath, oldJsxName, newJsxName }) => ({
|
|
35
|
+
oldNodePath,
|
|
36
|
+
newNodePath,
|
|
37
|
+
oldJsxName,
|
|
38
|
+
newJsxName,
|
|
39
|
+
}));
|
|
35
40
|
const nodePathMutation = (0, sequence_node_path_mutation_1.broadcastSequenceNodePathMutation)([
|
|
36
41
|
{
|
|
37
42
|
absolutePath,
|
|
@@ -21,7 +21,7 @@ const replaceVideoSourceHandler = ({ input: { fileName, nodePath, src }, remotio
|
|
|
21
21
|
action: 'modify',
|
|
22
22
|
});
|
|
23
23
|
const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
|
|
24
|
-
const result = (0, codemods_1.
|
|
24
|
+
const result = (0, codemods_1.updateNodeProps)({
|
|
25
25
|
project: {
|
|
26
26
|
files: { [absolutePath]: fileContents },
|
|
27
27
|
rootDir: remotionRoot,
|
|
@@ -37,7 +37,12 @@ const replaceVideoSourceHandler = ({ input: { fileName, nodePath, src }, remotio
|
|
|
37
37
|
});
|
|
38
38
|
const output = (_b = (_a = result.changes[0]) === null || _a === void 0 ? void 0 : _a.nextContents) !== null && _b !== void 0 ? _b : fileContents;
|
|
39
39
|
const { logLine } = result;
|
|
40
|
-
const nodePathRemappings = result.nodePathRemappings.map(({ oldNodePath, newNodePath }) => ({
|
|
40
|
+
const nodePathRemappings = result.nodePathRemappings.map(({ oldNodePath, newNodePath, oldJsxName, newJsxName }) => ({
|
|
41
|
+
oldNodePath,
|
|
42
|
+
newNodePath,
|
|
43
|
+
oldJsxName,
|
|
44
|
+
newJsxName,
|
|
45
|
+
}));
|
|
41
46
|
const nodePathMutation = (0, sequence_node_path_mutation_1.broadcastSequenceNodePathMutation)([{ absolutePath, remappings: nodePathRemappings }], null);
|
|
42
47
|
(0, undo_stack_1.pushToUndoStack)({
|
|
43
48
|
filePath: absolutePath,
|
|
@@ -49,7 +49,7 @@ const groupBy = (items, getKey) => {
|
|
|
49
49
|
return [...groups.values()];
|
|
50
50
|
};
|
|
51
51
|
const convertSequencePropEditToCodemodChange = (edit) => {
|
|
52
|
-
var _a, _b;
|
|
52
|
+
var _a, _b, _c;
|
|
53
53
|
return {
|
|
54
54
|
nodePath: edit.nodePath.nodePath,
|
|
55
55
|
updates: [
|
|
@@ -57,8 +57,11 @@ const convertSequencePropEditToCodemodChange = (edit) => {
|
|
|
57
57
|
key: edit.key,
|
|
58
58
|
value: edit.value,
|
|
59
59
|
defaultValue: edit.defaultValue,
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
...(((_a = edit.sourceEdit) === null || _a === void 0 ? void 0 : _a.type) === 'playback-rate'
|
|
61
|
+
? { retimeKeyframes: true }
|
|
62
|
+
: {}),
|
|
63
|
+
googleFont: ((_b = edit.sourceEdit) === null || _b === void 0 ? void 0 : _b.type) === 'google-font' ? edit.sourceEdit.font : null,
|
|
64
|
+
clipboardParam: ((_c = edit.sourceEdit) === null || _c === void 0 ? void 0 : _c.type) === 'clipboard-param'
|
|
62
65
|
? edit.sourceEdit.param
|
|
63
66
|
: null,
|
|
64
67
|
},
|