@remotion/studio-server 4.0.513 → 4.0.515
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/delete-jsx-node.d.ts +2 -5
- package/dist/codemods/delete-jsx-node.js +23 -341
- package/dist/codemods/duplicate-composition.d.ts +1 -9
- package/dist/codemods/duplicate-composition.js +3 -49
- package/dist/codemods/format-inline-content.d.ts +0 -4
- package/dist/codemods/format-inline-content.js +7 -46
- package/dist/codemods/recast-mods.js +0 -18
- package/dist/codemods/reorder-sequence.d.ts +2 -2
- package/dist/codemods/reorder-sequence.js +12 -112
- package/dist/codemods/split-jsx-sequence.d.ts +1 -2
- package/dist/codemods/split-jsx-sequence.js +11 -298
- package/dist/codemods/split-video-from-audio.d.ts +15 -0
- package/dist/codemods/split-video-from-audio.js +15 -0
- package/dist/codemods/update-default-props.d.ts +2 -6
- package/dist/codemods/update-default-props.js +12 -220
- package/dist/codemods/update-keyframes/ensure-imports-and-frame-hook.d.ts +1 -4
- package/dist/codemods/update-keyframes/ensure-imports-and-frame-hook.js +5 -102
- package/dist/codemods/update-keyframes/update-keyframes.d.ts +8 -93
- package/dist/codemods/update-keyframes/update-keyframes.js +11 -1302
- package/dist/detect-outdated-remotion-skills.d.ts +7 -0
- package/dist/detect-outdated-remotion-skills.js +11 -5
- package/dist/helpers/open-file-for-writing-without-symlinks.d.ts +4 -0
- package/dist/helpers/open-file-for-writing-without-symlinks.js +52 -0
- package/dist/helpers/resolve-composition-component.d.ts +3 -11
- package/dist/helpers/resolve-composition-component.js +38 -1495
- package/dist/helpers/video-config-values.js +25 -6
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -0
- package/dist/max-timeline-tracks.d.ts +2 -1
- package/dist/max-timeline-tracks.js +10 -4
- package/dist/preview-server/api-routes.js +4 -0
- package/dist/preview-server/routes/add-effect.js +1 -1
- package/dist/preview-server/routes/apply-codemod.js +3 -3
- package/dist/preview-server/routes/apply-visual-control-change.js +3 -3
- package/dist/preview-server/routes/can-update-sequence-props.js +107 -24
- package/dist/preview-server/routes/delete-effect-keyframe.d.ts +3 -0
- package/dist/preview-server/routes/delete-effect-keyframe.js +89 -0
- package/dist/preview-server/routes/delete-effect.js +1 -1
- package/dist/preview-server/routes/delete-jsx-node.js +1 -1
- package/dist/preview-server/routes/delete-sequence-keyframe.d.ts +3 -0
- package/dist/preview-server/routes/delete-sequence-keyframe.js +82 -0
- package/dist/preview-server/routes/duplicate-effect.js +1 -1
- package/dist/preview-server/routes/duplicate-jsx-node.js +1 -1
- package/dist/preview-server/routes/element-install-plan.d.ts +1 -1
- package/dist/preview-server/routes/insert-element.js +2 -2
- package/dist/preview-server/routes/insert-jsx-element.js +1 -1
- package/dist/preview-server/routes/install-dependency.js +8 -2
- package/dist/preview-server/routes/log-updates/log-effect-update.js +2 -1
- package/dist/preview-server/routes/log-updates/log-update.js +2 -1
- package/dist/preview-server/routes/paste-effects.js +1 -1
- package/dist/preview-server/routes/remotion-skills-info.d.ts +7 -0
- package/dist/preview-server/routes/remotion-skills-info.js +24 -0
- package/dist/preview-server/routes/reorder-effect.js +1 -1
- package/dist/preview-server/routes/reorder-sequence.js +1 -1
- package/dist/preview-server/routes/save-props-mutex.d.ts +1 -0
- package/dist/preview-server/routes/save-props-mutex.js +11 -0
- package/dist/preview-server/routes/source-file-write-queue.d.ts +1 -0
- package/dist/preview-server/routes/source-file-write-queue.js +11 -2
- package/dist/preview-server/routes/split-jsx-sequence.js +1 -1
- package/dist/preview-server/routes/split-video-from-audio.d.ts +3 -0
- package/dist/preview-server/routes/split-video-from-audio.js +80 -0
- package/dist/preview-server/routes/update-default-props.js +1 -1
- package/dist/preview-server/start-server.js +188 -140
- package/dist/preview-server/undo-stack.d.ts +3 -52
- package/dist/preview-server/update-available.js +4 -4
- package/dist/routes.js +36 -5
- package/package.json +8 -8
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { deleteJsxElementAtPath, findJsxElementPathForDeletion, getJsxElementTagLabel } from '@remotion/studio-codemods';
|
|
2
2
|
import type { SequenceNodePath } from 'remotion';
|
|
3
|
-
|
|
4
|
-
export declare const getJsxElementTagLabel: (element: JSXElement) => string;
|
|
5
|
-
export declare const findJsxElementPathForDeletion: (ast: File, nodePath: SequenceNodePath) => import("ast-types/lib/node-path").NodePath<N, V> | null;
|
|
6
|
-
export declare const deleteJsxElementAtPath: (jsxPath: import("ast-types/lib/node-path").NodePath<N, V>) => void;
|
|
3
|
+
export { deleteJsxElementAtPath, findJsxElementPathForDeletion, getJsxElementTagLabel, };
|
|
7
4
|
export declare const deleteJsxNodes: ({ input, nodePaths, prettierConfigOverride, }: {
|
|
8
5
|
input: string;
|
|
9
6
|
nodePaths: SequenceNodePath[];
|
|
@@ -1,346 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.deleteJsxNode = exports.deleteJsxNodes = exports.
|
|
37
|
-
const
|
|
38
|
-
|
|
3
|
+
exports.deleteJsxNode = exports.deleteJsxNodes = exports.getJsxElementTagLabel = exports.findJsxElementPathForDeletion = exports.deleteJsxElementAtPath = void 0;
|
|
4
|
+
const studio_codemods_1 = require("@remotion/studio-codemods");
|
|
5
|
+
Object.defineProperty(exports, "deleteJsxElementAtPath", { enumerable: true, get: function () { return studio_codemods_1.deleteJsxElementAtPath; } });
|
|
6
|
+
Object.defineProperty(exports, "findJsxElementPathForDeletion", { enumerable: true, get: function () { return studio_codemods_1.findJsxElementPathForDeletion; } });
|
|
7
|
+
Object.defineProperty(exports, "getJsxElementTagLabel", { enumerable: true, get: function () { return studio_codemods_1.getJsxElementTagLabel; } });
|
|
39
8
|
const format_file_content_1 = require("./format-file-content");
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (name.type === 'JSXNamespacedName') {
|
|
50
|
-
return `${name.namespace.name}:${name.name.name}`;
|
|
51
|
-
}
|
|
52
|
-
if (name.type === 'JSXMemberExpression') {
|
|
53
|
-
const memberToString = (expr) => {
|
|
54
|
-
if (expr.type === 'JSXIdentifier') {
|
|
55
|
-
return expr.name;
|
|
56
|
-
}
|
|
57
|
-
return `${memberToString(expr.object)}.${expr.property.name}`;
|
|
58
|
-
};
|
|
59
|
-
return memberToString(name);
|
|
60
|
-
}
|
|
61
|
-
return 'Unknown';
|
|
62
|
-
};
|
|
63
|
-
/** e.g. `<Video>` or `<Remotion.Sequence>` for logs and undo copy. */
|
|
64
|
-
const getJsxElementTagLabel = (element) => {
|
|
65
|
-
return `<${jsxOpeningNameToString(element.openingElement.name)}>`;
|
|
66
|
-
};
|
|
67
|
-
exports.getJsxElementTagLabel = getJsxElementTagLabel;
|
|
68
|
-
const findJsxElementPathForDeletion = (ast, nodePath) => {
|
|
69
|
-
const current = (0, get_ast_node_path_1.getAstNodePath)(ast, nodePath);
|
|
70
|
-
if (!current) {
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
if (namedTypes.JSXOpeningElement.check(current.value)) {
|
|
74
|
-
const parent = current.parentPath;
|
|
75
|
-
if (parent && namedTypes.JSXElement.check(parent.value)) {
|
|
76
|
-
return parent;
|
|
77
|
-
}
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
if (namedTypes.JSXElement.check(current.value)) {
|
|
81
|
-
return current;
|
|
82
|
-
}
|
|
83
|
-
return null;
|
|
84
|
-
};
|
|
85
|
-
exports.findJsxElementPathForDeletion = findJsxElementPathForDeletion;
|
|
86
|
-
const replaceInLogicalExpression = (parent, node) => {
|
|
87
|
-
const nl = nullLiteralExpr();
|
|
88
|
-
if (parent.left === node) {
|
|
89
|
-
parent.left = nl;
|
|
90
|
-
return true;
|
|
91
|
-
}
|
|
92
|
-
if (parent.right === node) {
|
|
93
|
-
parent.right = nl;
|
|
94
|
-
return true;
|
|
95
|
-
}
|
|
96
|
-
return false;
|
|
97
|
-
};
|
|
98
|
-
const replaceInConditionalExpression = (parent, node) => {
|
|
99
|
-
const nl = nullLiteralExpr();
|
|
100
|
-
if (parent.consequent === node) {
|
|
101
|
-
parent.consequent = nl;
|
|
102
|
-
return true;
|
|
103
|
-
}
|
|
104
|
-
if (parent.alternate === node) {
|
|
105
|
-
parent.alternate = nl;
|
|
106
|
-
return true;
|
|
107
|
-
}
|
|
108
|
-
return false;
|
|
109
|
-
};
|
|
110
|
-
const replaceInArrowFunctionExpression = (parent, node) => {
|
|
111
|
-
if (parent.body === node) {
|
|
112
|
-
parent.body = nullLiteralExpr();
|
|
113
|
-
return true;
|
|
114
|
-
}
|
|
115
|
-
return false;
|
|
116
|
-
};
|
|
117
|
-
const replaceInReturnStatement = (parent, node) => {
|
|
118
|
-
if (parent.argument === node) {
|
|
119
|
-
parent.argument = nullLiteralExpr();
|
|
120
|
-
return true;
|
|
121
|
-
}
|
|
122
|
-
return false;
|
|
123
|
-
};
|
|
124
|
-
const replaceInCallExpression = (parent, node) => {
|
|
125
|
-
const idx = parent.arguments.indexOf(node);
|
|
126
|
-
if (idx !== -1) {
|
|
127
|
-
parent.arguments[idx] = nullLiteralExpr();
|
|
128
|
-
return true;
|
|
129
|
-
}
|
|
130
|
-
return false;
|
|
131
|
-
};
|
|
132
|
-
const replaceInOptionalCallExpression = (parent, node) => {
|
|
133
|
-
const idx = parent.arguments.indexOf(node);
|
|
134
|
-
if (idx !== -1) {
|
|
135
|
-
parent.arguments[idx] = nullLiteralExpr();
|
|
136
|
-
return true;
|
|
137
|
-
}
|
|
138
|
-
return false;
|
|
139
|
-
};
|
|
140
|
-
const replaceInArrayExpression = (parent, node) => {
|
|
141
|
-
const idx = parent.elements.indexOf(node);
|
|
142
|
-
if (idx !== -1) {
|
|
143
|
-
parent.elements[idx] = nullLiteralExpr();
|
|
144
|
-
return true;
|
|
145
|
-
}
|
|
146
|
-
return false;
|
|
147
|
-
};
|
|
148
|
-
const replaceInAssignmentExpression = (parent, node) => {
|
|
149
|
-
if (parent.right === node) {
|
|
150
|
-
parent.right = nullLiteralExpr();
|
|
151
|
-
return true;
|
|
152
|
-
}
|
|
153
|
-
return false;
|
|
154
|
-
};
|
|
155
|
-
const replaceInVariableDeclarator = (parent, node) => {
|
|
156
|
-
if (parent.init === node) {
|
|
157
|
-
parent.init = nullLiteralExpr();
|
|
158
|
-
return true;
|
|
159
|
-
}
|
|
160
|
-
return false;
|
|
161
|
-
};
|
|
162
|
-
const replaceInExportDefaultDeclaration = (parent, node) => {
|
|
163
|
-
if (parent.declaration === node) {
|
|
164
|
-
parent.declaration = nullLiteralExpr();
|
|
165
|
-
return true;
|
|
166
|
-
}
|
|
167
|
-
return false;
|
|
168
|
-
};
|
|
169
|
-
const replaceInSequenceExpression = (parent, node) => {
|
|
170
|
-
const idx = parent.expressions.indexOf(node);
|
|
171
|
-
if (idx !== -1) {
|
|
172
|
-
parent.expressions[idx] = nullLiteralExpr();
|
|
173
|
-
return true;
|
|
174
|
-
}
|
|
175
|
-
return false;
|
|
176
|
-
};
|
|
177
|
-
const replaceInNewExpression = (parent, node) => {
|
|
178
|
-
const idx = parent.arguments.indexOf(node);
|
|
179
|
-
if (idx !== -1) {
|
|
180
|
-
parent.arguments[idx] = nullLiteralExpr();
|
|
181
|
-
return true;
|
|
182
|
-
}
|
|
183
|
-
return false;
|
|
184
|
-
};
|
|
185
|
-
const replaceInExpressionStatement = (parent, node) => {
|
|
186
|
-
if (parent.expression === node) {
|
|
187
|
-
parent.expression = nullLiteralExpr();
|
|
188
|
-
return true;
|
|
189
|
-
}
|
|
190
|
-
return false;
|
|
191
|
-
};
|
|
192
|
-
const replaceInParenthesizedExpression = (parent, node) => {
|
|
193
|
-
if (parent.expression === node) {
|
|
194
|
-
parent.expression = nullLiteralExpr();
|
|
195
|
-
return true;
|
|
196
|
-
}
|
|
197
|
-
return false;
|
|
198
|
-
};
|
|
199
|
-
const replaceInJSXExpressionContainer = (parent, node) => {
|
|
200
|
-
if (parent.expression === node) {
|
|
201
|
-
parent.expression = nullLiteralExpr();
|
|
202
|
-
return true;
|
|
203
|
-
}
|
|
204
|
-
return false;
|
|
205
|
-
};
|
|
206
|
-
const replaceInTSAsExpression = (parent, node) => {
|
|
207
|
-
if (parent.expression === node) {
|
|
208
|
-
parent.expression = nullLiteralExpr();
|
|
209
|
-
return true;
|
|
210
|
-
}
|
|
211
|
-
return false;
|
|
212
|
-
};
|
|
213
|
-
const replaceInJSXParentChildren = (parent, node) => {
|
|
214
|
-
const idx = parent.children.indexOf(node);
|
|
215
|
-
if (idx !== -1) {
|
|
216
|
-
parent.children.splice(idx, 1);
|
|
217
|
-
return true;
|
|
218
|
-
}
|
|
219
|
-
return false;
|
|
220
|
-
};
|
|
221
|
-
const replaceNodeWithNull = (parentNode, node) => {
|
|
222
|
-
if (namedTypes.LogicalExpression.check(parentNode)) {
|
|
223
|
-
return replaceInLogicalExpression(parentNode, node);
|
|
224
|
-
}
|
|
225
|
-
if (namedTypes.ConditionalExpression.check(parentNode)) {
|
|
226
|
-
return replaceInConditionalExpression(parentNode, node);
|
|
227
|
-
}
|
|
228
|
-
if (namedTypes.ArrowFunctionExpression.check(parentNode)) {
|
|
229
|
-
return replaceInArrowFunctionExpression(parentNode, node);
|
|
230
|
-
}
|
|
231
|
-
if (namedTypes.ReturnStatement.check(parentNode)) {
|
|
232
|
-
return replaceInReturnStatement(parentNode, node);
|
|
233
|
-
}
|
|
234
|
-
if (namedTypes.CallExpression.check(parentNode)) {
|
|
235
|
-
return replaceInCallExpression(parentNode, node);
|
|
236
|
-
}
|
|
237
|
-
if (parentNode.type === 'OptionalCallExpression') {
|
|
238
|
-
return replaceInOptionalCallExpression(parentNode, node);
|
|
239
|
-
}
|
|
240
|
-
if (namedTypes.ArrayExpression.check(parentNode)) {
|
|
241
|
-
return replaceInArrayExpression(parentNode, node);
|
|
242
|
-
}
|
|
243
|
-
if (namedTypes.AssignmentExpression.check(parentNode)) {
|
|
244
|
-
return replaceInAssignmentExpression(parentNode, node);
|
|
245
|
-
}
|
|
246
|
-
if (namedTypes.VariableDeclarator.check(parentNode)) {
|
|
247
|
-
return replaceInVariableDeclarator(parentNode, node);
|
|
248
|
-
}
|
|
249
|
-
if (namedTypes.ExportDefaultDeclaration.check(parentNode)) {
|
|
250
|
-
return replaceInExportDefaultDeclaration(parentNode, node);
|
|
251
|
-
}
|
|
252
|
-
if (namedTypes.SequenceExpression.check(parentNode)) {
|
|
253
|
-
return replaceInSequenceExpression(parentNode, node);
|
|
254
|
-
}
|
|
255
|
-
if (namedTypes.NewExpression.check(parentNode)) {
|
|
256
|
-
return replaceInNewExpression(parentNode, node);
|
|
257
|
-
}
|
|
258
|
-
if (namedTypes.ExpressionStatement.check(parentNode)) {
|
|
259
|
-
return replaceInExpressionStatement(parentNode, node);
|
|
260
|
-
}
|
|
261
|
-
if (namedTypes.ParenthesizedExpression.check(parentNode)) {
|
|
262
|
-
return replaceInParenthesizedExpression(parentNode, node);
|
|
263
|
-
}
|
|
264
|
-
if (namedTypes.JSXExpressionContainer.check(parentNode)) {
|
|
265
|
-
return replaceInJSXExpressionContainer(parentNode, node);
|
|
266
|
-
}
|
|
267
|
-
if (namedTypes.TSAsExpression.check(parentNode)) {
|
|
268
|
-
return replaceInTSAsExpression(parentNode, node);
|
|
269
|
-
}
|
|
270
|
-
if (namedTypes.JSXElement.check(parentNode)) {
|
|
271
|
-
return replaceInJSXParentChildren(parentNode, node);
|
|
272
|
-
}
|
|
273
|
-
if (namedTypes.JSXFragment.check(parentNode)) {
|
|
274
|
-
return replaceInJSXParentChildren(parentNode, node);
|
|
275
|
-
}
|
|
276
|
-
return false;
|
|
277
|
-
};
|
|
278
|
-
const deleteJsxElementAtPath = (jsxPath) => {
|
|
279
|
-
const { node, parentPath } = jsxPath;
|
|
280
|
-
if (!parentPath) {
|
|
281
|
-
throw new Error('Cannot delete JSX element with no parent');
|
|
282
|
-
}
|
|
283
|
-
const jsxNode = node;
|
|
284
|
-
if (replaceNodeWithNull(parentPath.node, jsxNode)) {
|
|
285
|
-
return;
|
|
286
|
-
}
|
|
287
|
-
// Recast can replace this node in arbitrary parent contexts.
|
|
288
|
-
jsxPath.replace(b.nullLiteral());
|
|
289
|
-
};
|
|
290
|
-
exports.deleteJsxElementAtPath = deleteJsxElementAtPath;
|
|
291
|
-
const deleteJsxNodes = async ({ input, nodePaths, prettierConfigOverride, }) => {
|
|
292
|
-
if (nodePaths.length === 0) {
|
|
293
|
-
throw new Error('No JSX nodes were specified for deletion');
|
|
294
|
-
}
|
|
295
|
-
const ast = (0, parse_ast_1.parseAst)(input);
|
|
296
|
-
const capturedNodePaths = (0, get_node_path_remappings_1.captureJsxNodePaths)(ast);
|
|
297
|
-
const pathsToDelete = nodePaths.map((nodePath) => {
|
|
298
|
-
var _a, _b;
|
|
299
|
-
var _c, _d;
|
|
300
|
-
const jsxPath = (0, exports.findJsxElementPathForDeletion)(ast, nodePath);
|
|
301
|
-
if (!jsxPath) {
|
|
302
|
-
throw new Error('Could not find a JSX element at the specified location to delete');
|
|
303
|
-
}
|
|
304
|
-
const jsxElement = jsxPath.node;
|
|
305
|
-
return {
|
|
306
|
-
jsxPath,
|
|
307
|
-
nodeLabel: (0, exports.getJsxElementTagLabel)(jsxElement),
|
|
308
|
-
logLine: (_d = (_c = (_a = jsxElement.openingElement.loc) === null || _a === void 0 ? void 0 : _a.start.line) !== null && _c !== void 0 ? _c : (_b = jsxElement.loc) === null || _b === void 0 ? void 0 : _b.start.line) !== null && _d !== void 0 ? _d : 1,
|
|
309
|
-
};
|
|
310
|
-
});
|
|
311
|
-
for (const { jsxPath } of pathsToDelete) {
|
|
312
|
-
(0, exports.deleteJsxElementAtPath)(jsxPath);
|
|
313
|
-
}
|
|
314
|
-
const finalFile = (0, parse_ast_1.serializeAst)(ast);
|
|
315
|
-
const { output, formatted } = await (0, format_file_content_1.formatFileContent)({
|
|
316
|
-
input: finalFile,
|
|
317
|
-
prettierConfigOverride,
|
|
318
|
-
});
|
|
319
|
-
const { nodePathRemappings } = (0, get_node_path_remappings_1.getNodePathRemappings)({
|
|
320
|
-
ast,
|
|
321
|
-
captured: capturedNodePaths,
|
|
322
|
-
output,
|
|
323
|
-
});
|
|
324
|
-
return {
|
|
325
|
-
output,
|
|
326
|
-
formatted,
|
|
327
|
-
nodeLabels: pathsToDelete.map(({ nodeLabel }) => nodeLabel),
|
|
328
|
-
logLines: pathsToDelete.map(({ logLine }) => logLine),
|
|
329
|
-
nodePathRemappings,
|
|
330
|
-
};
|
|
331
|
-
};
|
|
9
|
+
const deleteJsxNodes = ({ input, nodePaths, prettierConfigOverride, }) => (0, studio_codemods_1.deleteJsxNodes)({
|
|
10
|
+
input,
|
|
11
|
+
nodePaths,
|
|
12
|
+
formatFile: ({ contents, prettierConfigOverride: override }) => (0, format_file_content_1.formatFileContent)({
|
|
13
|
+
input: contents,
|
|
14
|
+
prettierConfigOverride: override,
|
|
15
|
+
}),
|
|
16
|
+
prettierConfigOverride,
|
|
17
|
+
});
|
|
332
18
|
exports.deleteJsxNodes = deleteJsxNodes;
|
|
333
|
-
const deleteJsxNode =
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
nodeLabel: nodeLabels[0],
|
|
343
|
-
logLine: logLines[0],
|
|
344
|
-
};
|
|
345
|
-
};
|
|
19
|
+
const deleteJsxNode = ({ input, nodePath, prettierConfigOverride, }) => (0, studio_codemods_1.deleteJsxNode)({
|
|
20
|
+
input,
|
|
21
|
+
nodePath,
|
|
22
|
+
formatFile: ({ contents, prettierConfigOverride: override }) => (0, format_file_content_1.formatFileContent)({
|
|
23
|
+
input: contents,
|
|
24
|
+
prettierConfigOverride: override,
|
|
25
|
+
}),
|
|
26
|
+
prettierConfigOverride,
|
|
27
|
+
});
|
|
346
28
|
exports.deleteJsxNode = deleteJsxNode;
|
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import type { Change } from './recast-mods';
|
|
1
|
+
export { parseAndApplyCodemod } from '@remotion/studio-codemods';
|
|
3
2
|
export declare const formatOutput: (tsContent: string) => Promise<string>;
|
|
4
|
-
export declare const parseAndApplyCodemod: ({ input, codeMod, }: {
|
|
5
|
-
input: string;
|
|
6
|
-
codeMod: RecastCodemod;
|
|
7
|
-
}) => {
|
|
8
|
-
newContents: string;
|
|
9
|
-
changesMade: Change[];
|
|
10
|
-
};
|
|
@@ -33,10 +33,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
const recast_mods_1 = require("./recast-mods");
|
|
36
|
+
exports.formatOutput = exports.parseAndApplyCodemod = void 0;
|
|
37
|
+
const studio_codemods_1 = require("@remotion/studio-codemods");
|
|
38
|
+
Object.defineProperty(exports, "parseAndApplyCodemod", { enumerable: true, get: function () { return studio_codemods_1.parseAndApplyCodemod; } });
|
|
40
39
|
const getPrettier = async () => {
|
|
41
40
|
try {
|
|
42
41
|
return await Promise.resolve().then(() => __importStar(require('prettier')));
|
|
@@ -63,48 +62,3 @@ const formatOutput = async (tsContent) => {
|
|
|
63
62
|
return newContents;
|
|
64
63
|
};
|
|
65
64
|
exports.formatOutput = formatOutput;
|
|
66
|
-
const parseAndApplyCodemod = ({ input, codeMod, }) => {
|
|
67
|
-
const ast = (0, parse_ast_1.parseAst)(input);
|
|
68
|
-
const { newAst, changesMade } = (0, recast_mods_1.applyCodemod)({
|
|
69
|
-
file: ast,
|
|
70
|
-
codeMod,
|
|
71
|
-
});
|
|
72
|
-
if (changesMade.length === 0) {
|
|
73
|
-
throw new Error('Unable to calculate the changes needed for this file. Edit the file manually.');
|
|
74
|
-
}
|
|
75
|
-
if (codeMod.type === 'duplicate-composition' && codeMod.tag) {
|
|
76
|
-
(0, imports_1.ensureNamedImport)({
|
|
77
|
-
ast: newAst,
|
|
78
|
-
importedName: codeMod.tag,
|
|
79
|
-
sourcePath: 'remotion',
|
|
80
|
-
localName: codeMod.tag,
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
if (codeMod.type === 'new-composition') {
|
|
84
|
-
if (codeMod.canvasCapture === null) {
|
|
85
|
-
(0, imports_1.ensureNamedImport)({
|
|
86
|
-
ast: newAst,
|
|
87
|
-
importedName: 'Composition',
|
|
88
|
-
sourcePath: 'remotion',
|
|
89
|
-
localName: 'Composition',
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
(0, imports_1.ensureNamedImport)({
|
|
93
|
-
ast: newAst,
|
|
94
|
-
importedName: codeMod.componentName,
|
|
95
|
-
sourcePath: codeMod.componentImportPath,
|
|
96
|
-
localName: codeMod.componentName,
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
if (codeMod.type === 'new-folder') {
|
|
100
|
-
(0, imports_1.ensureNamedImport)({
|
|
101
|
-
ast: newAst,
|
|
102
|
-
importedName: 'Folder',
|
|
103
|
-
sourcePath: 'remotion',
|
|
104
|
-
localName: 'Folder',
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
const output = (0, parse_ast_1.serializeAst)(newAst);
|
|
108
|
-
return { changesMade, newContents: output };
|
|
109
|
-
};
|
|
110
|
-
exports.parseAndApplyCodemod = parseAndApplyCodemod;
|
|
@@ -6,10 +6,6 @@
|
|
|
6
6
|
* @param linePrefix - Everything from the start of the line to where
|
|
7
7
|
* inlineContent will appear (used to calculate column offset and indentation)
|
|
8
8
|
* @param endOfLine - Prettier endOfLine option
|
|
9
|
-
*
|
|
10
|
-
* We wrap the content in `const __x__ = CONTENT;` and adjust printWidth
|
|
11
|
-
* so prettier makes the same line-breaking decisions as if the content
|
|
12
|
-
* were at its actual column position in the file.
|
|
13
9
|
*/
|
|
14
10
|
export declare const formatInlineContent: ({ inlineContent, linePrefix, endOfLine, prettierConfigOverride, }: {
|
|
15
11
|
inlineContent: string;
|
|
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.formatInlineContent = void 0;
|
|
37
|
+
const studio_codemods_1 = require("@remotion/studio-codemods");
|
|
37
38
|
/**
|
|
38
39
|
* Instead of running prettier on the entire file (which is slow),
|
|
39
40
|
* format only a small snippet of inline content (e.g. stringified defaultProps).
|
|
@@ -42,19 +43,13 @@ exports.formatInlineContent = void 0;
|
|
|
42
43
|
* @param linePrefix - Everything from the start of the line to where
|
|
43
44
|
* inlineContent will appear (used to calculate column offset and indentation)
|
|
44
45
|
* @param endOfLine - Prettier endOfLine option
|
|
45
|
-
*
|
|
46
|
-
* We wrap the content in `const __x__ = CONTENT;` and adjust printWidth
|
|
47
|
-
* so prettier makes the same line-breaking decisions as if the content
|
|
48
|
-
* were at its actual column position in the file.
|
|
49
46
|
*/
|
|
50
47
|
const formatInlineContent = async ({ inlineContent, linePrefix, endOfLine, prettierConfigOverride, }) => {
|
|
51
|
-
var _a;
|
|
52
|
-
var _b, _c, _d;
|
|
53
48
|
let prettier = null;
|
|
54
49
|
try {
|
|
55
50
|
prettier = await Promise.resolve().then(() => __importStar(require('prettier')));
|
|
56
51
|
}
|
|
57
|
-
catch (
|
|
52
|
+
catch (_a) {
|
|
58
53
|
return { formatted: inlineContent, didFormat: false };
|
|
59
54
|
}
|
|
60
55
|
const { format, resolveConfig, resolveConfigFile } = prettier;
|
|
@@ -72,46 +67,12 @@ const formatInlineContent = async ({ inlineContent, linePrefix, endOfLine, prett
|
|
|
72
67
|
return { formatted: inlineContent, didFormat: false };
|
|
73
68
|
}
|
|
74
69
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const columnOffset = [...linePrefix].reduce((col, ch) => (ch === '\t' ? col + tabWidth : col + 1), 0);
|
|
79
|
-
// Adjust printWidth so the wrapper prefix occupies the same visual
|
|
80
|
-
// width as the actual file prefix, ensuring identical line breaks.
|
|
81
|
-
const configPrintWidth = (_d = prettierConfig.printWidth) !== null && _d !== void 0 ? _d : 80;
|
|
82
|
-
const wrapperPrefix = 'const __x__ = ';
|
|
83
|
-
const effectivePrintWidth = Math.max(configPrintWidth - columnOffset + wrapperPrefix.length, 20);
|
|
84
|
-
const wrappedSource = `${wrapperPrefix}${inlineContent};\n`;
|
|
85
|
-
const formattedWrapped = await format(wrappedSource, {
|
|
86
|
-
...prettierConfig,
|
|
87
|
-
printWidth: effectivePrintWidth,
|
|
88
|
-
filepath: 'test.tsx',
|
|
89
|
-
plugins: [],
|
|
70
|
+
return (0, studio_codemods_1.formatInlineContentWithFormatter)({
|
|
71
|
+
inlineContent,
|
|
72
|
+
linePrefix,
|
|
90
73
|
endOfLine,
|
|
74
|
+
prettierConfig,
|
|
75
|
+
format: (source, options) => format(source, { ...options, plugins: [] }),
|
|
91
76
|
});
|
|
92
|
-
// Extract the formatted value from the wrapper
|
|
93
|
-
const withoutSemicolon = formattedWrapped.replace(/;\s*$/, '');
|
|
94
|
-
const wrappedInParentheses = withoutSemicolon.startsWith(`${wrapperPrefix}(\n`);
|
|
95
|
-
let formattedProps;
|
|
96
|
-
if (withoutSemicolon.startsWith(wrapperPrefix) && !wrappedInParentheses) {
|
|
97
|
-
formattedProps = withoutSemicolon.slice(wrapperPrefix.length);
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
// Prettier broke the line after `=` — extract and dedent one level
|
|
101
|
-
const lines = withoutSemicolon
|
|
102
|
-
.split('\n')
|
|
103
|
-
.slice(1, wrappedInParentheses ? -1 : undefined);
|
|
104
|
-
const useTabs = prettierConfig.useTabs;
|
|
105
|
-
const oneIndent = useTabs ? '\t' : ' '.repeat(tabWidth);
|
|
106
|
-
formattedProps = lines
|
|
107
|
-
.map((l) => (l.startsWith(oneIndent) ? l.slice(oneIndent.length) : l))
|
|
108
|
-
.join('\n');
|
|
109
|
-
}
|
|
110
|
-
// Add base indentation to all lines except the first
|
|
111
|
-
const indentedProps = formattedProps
|
|
112
|
-
.split('\n')
|
|
113
|
-
.map((line, i) => i === 0 ? line : line.length > 0 ? baseIndent + line : line)
|
|
114
|
-
.join('\n');
|
|
115
|
-
return { formatted: indentedProps, didFormat: true };
|
|
116
77
|
};
|
|
117
78
|
exports.formatInlineContent = formatInlineContent;
|
|
@@ -438,8 +438,6 @@ const transformLoneJsxElement = (expression, transformation, changesMade, parent
|
|
|
438
438
|
compId === transformation.idToRename) ||
|
|
439
439
|
(transformation.type === 'update-composition-metadata' &&
|
|
440
440
|
compId === transformation.idToUpdate) ||
|
|
441
|
-
(transformation.type === 'duplicate-composition' &&
|
|
442
|
-
compId === transformation.idToDuplicate) ||
|
|
443
441
|
(transformation.type === 'delete-folder' &&
|
|
444
442
|
folderName === transformation.folderName &&
|
|
445
443
|
parentFolderName === transformation.parentName) ||
|
|
@@ -485,22 +483,6 @@ const mapJsxChild = (c, transformation, changesMade, parentFolderName) => {
|
|
|
485
483
|
if (transformation === null) {
|
|
486
484
|
return [c];
|
|
487
485
|
}
|
|
488
|
-
if (transformation.type === 'duplicate-composition' &&
|
|
489
|
-
compId === transformation.idToDuplicate) {
|
|
490
|
-
return [
|
|
491
|
-
c,
|
|
492
|
-
changeComposition({
|
|
493
|
-
jsxElement: c,
|
|
494
|
-
newCompositionId: transformation.newId,
|
|
495
|
-
newCompositionFps: transformation.newFps,
|
|
496
|
-
newCompositionDurationInFrames: transformation.newDurationInFrames,
|
|
497
|
-
newCompositionHeight: transformation.newHeight,
|
|
498
|
-
newCompositionWidth: transformation.newWidth,
|
|
499
|
-
newTagToUse: transformation.tag,
|
|
500
|
-
changesMade,
|
|
501
|
-
}),
|
|
502
|
-
];
|
|
503
|
-
}
|
|
504
486
|
if (transformation.type === 'rename-composition' &&
|
|
505
487
|
compId === transformation.idToRename) {
|
|
506
488
|
return [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ReorderSequencePosition
|
|
1
|
+
import type { ReorderSequencePosition } from '@remotion/studio-shared';
|
|
2
2
|
import type { SequenceNodePath } from 'remotion';
|
|
3
3
|
export declare const reorderSequence: ({ input, sourceNodePath, targetNodePath, position, prettierConfigOverride, }: {
|
|
4
4
|
input: string;
|
|
@@ -11,5 +11,5 @@ export declare const reorderSequence: ({ input, sourceNodePath, targetNodePath,
|
|
|
11
11
|
formatted: boolean;
|
|
12
12
|
sequenceLabel: string;
|
|
13
13
|
logLine: number;
|
|
14
|
-
nodePathRemappings: SequenceNodePathRemapping[];
|
|
14
|
+
nodePathRemappings: import("@remotion/studio-shared").SequenceNodePathRemapping[];
|
|
15
15
|
}>;
|