@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
|
@@ -1,317 +1,13 @@
|
|
|
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.
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const parse_ast_1 = require("../parse-ast");
|
|
44
|
-
const ensure_imports_and_frame_hook_1 = require("../update-keyframes/ensure-imports-and-frame-hook");
|
|
45
|
-
const update_nested_prop_1 = require("../update-nested-prop");
|
|
46
|
-
const b = recast.types.builders;
|
|
3
|
+
exports.findEffectsAttr = exports.updateEffectPropsAst = exports.updateEffectProps = exports.findEffectCallExpression = exports.enumerateEffectArrayElements = void 0;
|
|
4
|
+
const studio_codemods_1 = require("@remotion/studio-codemods");
|
|
5
|
+
const studio_codemods_2 = require("@remotion/studio-codemods");
|
|
6
|
+
Object.defineProperty(exports, "enumerateEffectArrayElements", { enumerable: true, get: function () { return studio_codemods_2.enumerateEffectArrayElements; } });
|
|
7
|
+
Object.defineProperty(exports, "findEffectCallExpression", { enumerable: true, get: function () { return studio_codemods_2.findEffectCallExpression; } });
|
|
8
|
+
Object.defineProperty(exports, "updateEffectProps", { enumerable: true, get: function () { return studio_codemods_2.updateEffectProps; } });
|
|
9
|
+
Object.defineProperty(exports, "updateEffectPropsAst", { enumerable: true, get: function () { return studio_codemods_2.updateEffectPropsAst; } });
|
|
47
10
|
const findEffectsAttr = (attrs) => {
|
|
48
|
-
|
|
49
|
-
if (attr.type !== 'JSXAttribute') {
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
const a = attr;
|
|
53
|
-
if (a.name.type === 'JSXIdentifier' && a.name.name === 'effects') {
|
|
54
|
-
return a;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return null;
|
|
11
|
+
return (0, studio_codemods_1.findEffectsAttr)(attrs);
|
|
58
12
|
};
|
|
59
13
|
exports.findEffectsAttr = findEffectsAttr;
|
|
60
|
-
const getCalleeName = (call) => {
|
|
61
|
-
const { callee } = call;
|
|
62
|
-
if (callee.type === 'Identifier') {
|
|
63
|
-
return callee.name;
|
|
64
|
-
}
|
|
65
|
-
if (callee.type === 'MemberExpression' &&
|
|
66
|
-
!callee.computed &&
|
|
67
|
-
callee.property.type === 'Identifier') {
|
|
68
|
-
return callee.property.name;
|
|
69
|
-
}
|
|
70
|
-
return null;
|
|
71
|
-
};
|
|
72
|
-
const enumerateEffectArrayElements = (arr) => {
|
|
73
|
-
const out = [];
|
|
74
|
-
for (const el of arr.elements) {
|
|
75
|
-
if (el === null) {
|
|
76
|
-
out.push({ kind: 'unsupported', reason: 'not-call-expression' });
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
if (el.type === 'SpreadElement') {
|
|
80
|
-
out.push({ kind: 'unsupported', reason: 'spread' });
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
if (el.type !== 'CallExpression') {
|
|
84
|
-
out.push({ kind: 'unsupported', reason: 'not-call-expression' });
|
|
85
|
-
continue;
|
|
86
|
-
}
|
|
87
|
-
const call = el;
|
|
88
|
-
const callee = getCalleeName(call);
|
|
89
|
-
if (callee === null) {
|
|
90
|
-
out.push({ kind: 'unsupported', reason: 'not-call-expression' });
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
out.push({ kind: 'call', callee, node: call });
|
|
94
|
-
}
|
|
95
|
-
return out;
|
|
96
|
-
};
|
|
97
|
-
exports.enumerateEffectArrayElements = enumerateEffectArrayElements;
|
|
98
|
-
const findEffectCallExpression = ({ attr, effectIndex, }) => {
|
|
99
|
-
if (!attr.value || attr.value.type !== 'JSXExpressionContainer') {
|
|
100
|
-
return { kind: 'error', reason: 'not-call-expression' };
|
|
101
|
-
}
|
|
102
|
-
const expr = attr.value.expression;
|
|
103
|
-
if (expr.type !== 'ArrayExpression') {
|
|
104
|
-
return { kind: 'error', reason: 'not-call-expression' };
|
|
105
|
-
}
|
|
106
|
-
const elements = (0, exports.enumerateEffectArrayElements)(expr);
|
|
107
|
-
if (effectIndex < 0 || effectIndex >= elements.length) {
|
|
108
|
-
return { kind: 'error', reason: 'not-found' };
|
|
109
|
-
}
|
|
110
|
-
const target = elements[effectIndex];
|
|
111
|
-
if (target.kind !== 'call') {
|
|
112
|
-
return { kind: 'error', reason: 'not-call-expression' };
|
|
113
|
-
}
|
|
114
|
-
return { kind: 'ok', call: target.node, callee: target.callee };
|
|
115
|
-
};
|
|
116
|
-
exports.findEffectCallExpression = findEffectCallExpression;
|
|
117
|
-
const findObjectProperty = (objExpr, propertyName) => {
|
|
118
|
-
const propIndex = objExpr.properties.findIndex((p) => p.type === 'ObjectProperty' &&
|
|
119
|
-
((p.key.type === 'Identifier' && p.key.name === propertyName) ||
|
|
120
|
-
(p.key.type === 'StringLiteral' &&
|
|
121
|
-
p.key.value === propertyName)));
|
|
122
|
-
return {
|
|
123
|
-
propIndex,
|
|
124
|
-
prop: propIndex !== -1
|
|
125
|
-
? objExpr.properties[propIndex]
|
|
126
|
-
: undefined,
|
|
127
|
-
};
|
|
128
|
-
};
|
|
129
|
-
const printObjectPropertyValue = (prop) => recast
|
|
130
|
-
.print(prop.value)
|
|
131
|
-
.code.replace(/[\n\r\t]+/g, ' ')
|
|
132
|
-
.replace(/,(\s*[}\]])/g, '$1')
|
|
133
|
-
.trim();
|
|
134
|
-
const updateHasEffectParam = (update) => 'effectParam' in update;
|
|
135
|
-
const getStaticUpdateValue = (update) => {
|
|
136
|
-
if (updateHasEffectParam(update)) {
|
|
137
|
-
return update.effectParam.type === 'static'
|
|
138
|
-
? update.effectParam.value
|
|
139
|
-
: null;
|
|
140
|
-
}
|
|
141
|
-
return update.value;
|
|
142
|
-
};
|
|
143
|
-
const ensureClipboardParamImports = ({ ast, sequenceNodePath, param, }) => {
|
|
144
|
-
var _a;
|
|
145
|
-
const requiredImports = (0, effect_param_expression_1.getRequiredRemotionImportsForEffectParams)([param]);
|
|
146
|
-
const remotionLocalNames = (0, effect_param_expression_1.ensureRemotionImportLocalNames)({
|
|
147
|
-
ast,
|
|
148
|
-
requiredImports,
|
|
149
|
-
});
|
|
150
|
-
if (requiredImports.has('useCurrentFrame')) {
|
|
151
|
-
const targetJsxPath = (0, get_ast_node_path_1.getAstNodePath)(ast, sequenceNodePath);
|
|
152
|
-
if (targetJsxPath) {
|
|
153
|
-
const fnPath = (0, ensure_imports_and_frame_hook_1.findEnclosingFunctionPath)(targetJsxPath);
|
|
154
|
-
if (fnPath) {
|
|
155
|
-
(0, ensure_imports_and_frame_hook_1.ensureUseCurrentFrameHook)(fnPath, (_a = remotionLocalNames.useCurrentFrame) !== null && _a !== void 0 ? _a : 'useCurrentFrame');
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
return remotionLocalNames;
|
|
160
|
-
};
|
|
161
|
-
const makeUpdateValueExpression = ({ ast, sequenceNodePath, update, }) => {
|
|
162
|
-
if (!updateHasEffectParam(update)) {
|
|
163
|
-
return (0, update_nested_prop_1.parseValueExpression)(update.value);
|
|
164
|
-
}
|
|
165
|
-
const remotionLocalNames = ensureClipboardParamImports({
|
|
166
|
-
ast,
|
|
167
|
-
sequenceNodePath,
|
|
168
|
-
param: update.effectParam,
|
|
169
|
-
});
|
|
170
|
-
return (0, effect_param_expression_1.makeParamExpression)({
|
|
171
|
-
param: update.effectParam,
|
|
172
|
-
remotionLocalNames,
|
|
173
|
-
});
|
|
174
|
-
};
|
|
175
|
-
const removeObjectProperty = ({ objExpr, propertyName, }) => {
|
|
176
|
-
const { propIndex, prop } = findObjectProperty(objExpr, propertyName);
|
|
177
|
-
if (!prop || propIndex === -1) {
|
|
178
|
-
return null;
|
|
179
|
-
}
|
|
180
|
-
const valueString = printObjectPropertyValue(prop);
|
|
181
|
-
objExpr.properties.splice(propIndex, 1);
|
|
182
|
-
return {
|
|
183
|
-
key: propertyName,
|
|
184
|
-
valueString,
|
|
185
|
-
};
|
|
186
|
-
};
|
|
187
|
-
const updateEffectPropsAst = ({ input, sequenceNodePath, effectIndex, update, schema, }) => {
|
|
188
|
-
var _a, _b, _c, _d;
|
|
189
|
-
var _e, _f, _g, _h, _j;
|
|
190
|
-
const ast = (0, parse_ast_1.parseAst)(input);
|
|
191
|
-
const jsx = (0, can_update_sequence_props_1.findJsxElementAtNodePath)(ast, sequenceNodePath);
|
|
192
|
-
if (!jsx) {
|
|
193
|
-
throw new Error('Could not find a JSX element at the specified location to update effects');
|
|
194
|
-
}
|
|
195
|
-
const attr = (0, exports.findEffectsAttr)((_e = jsx.attributes) !== null && _e !== void 0 ? _e : []);
|
|
196
|
-
if (!attr) {
|
|
197
|
-
throw new Error('Could not find effects on the target JSX element');
|
|
198
|
-
}
|
|
199
|
-
const found = (0, exports.findEffectCallExpression)({
|
|
200
|
-
attr,
|
|
201
|
-
effectIndex,
|
|
202
|
-
});
|
|
203
|
-
if (found.kind === 'error') {
|
|
204
|
-
throw new Error(`Cannot update effect prop: ${found.reason}`);
|
|
205
|
-
}
|
|
206
|
-
const { call, callee: effectCallee } = found;
|
|
207
|
-
const isDefault = !updateHasEffectParam(update) &&
|
|
208
|
-
update.defaultValue !== null &&
|
|
209
|
-
JSON.stringify(update.value) === JSON.stringify(update.defaultValue);
|
|
210
|
-
let objExpr;
|
|
211
|
-
if (call.arguments.length === 0) {
|
|
212
|
-
if (isDefault) {
|
|
213
|
-
return {
|
|
214
|
-
serialized: (0, parse_ast_1.serializeAst)(ast),
|
|
215
|
-
oldValueString: '',
|
|
216
|
-
newValueString: JSON.stringify(update.defaultValue),
|
|
217
|
-
logLine: (_g = (_f = (_a = call.loc) === null || _a === void 0 ? void 0 : _a.start.line) !== null && _f !== void 0 ? _f : (_b = jsx.loc) === null || _b === void 0 ? void 0 : _b.start.line) !== null && _g !== void 0 ? _g : 1,
|
|
218
|
-
effectCallee,
|
|
219
|
-
removedProps: [],
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
objExpr = b.objectExpression([]);
|
|
223
|
-
call.arguments.push(objExpr);
|
|
224
|
-
}
|
|
225
|
-
else if (call.arguments[0].type !== 'ObjectExpression') {
|
|
226
|
-
throw new Error('Cannot update effect prop: computed');
|
|
227
|
-
}
|
|
228
|
-
else {
|
|
229
|
-
objExpr = call.arguments[0];
|
|
230
|
-
}
|
|
231
|
-
const { prop } = findObjectProperty(objExpr, update.key);
|
|
232
|
-
const removedProps = [];
|
|
233
|
-
let oldValueString = '';
|
|
234
|
-
if (prop) {
|
|
235
|
-
oldValueString = recast.print(prop.value).code;
|
|
236
|
-
}
|
|
237
|
-
else if (update.defaultValue !== null) {
|
|
238
|
-
oldValueString = JSON.stringify(update.defaultValue);
|
|
239
|
-
}
|
|
240
|
-
let newValueString = '';
|
|
241
|
-
if (isDefault) {
|
|
242
|
-
newValueString = JSON.stringify(update.defaultValue);
|
|
243
|
-
if (prop) {
|
|
244
|
-
const idx = objExpr.properties.indexOf(prop);
|
|
245
|
-
if (idx !== -1) {
|
|
246
|
-
objExpr.properties.splice(idx, 1);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
else {
|
|
251
|
-
const newValueExpr = makeUpdateValueExpression({
|
|
252
|
-
ast,
|
|
253
|
-
sequenceNodePath,
|
|
254
|
-
update,
|
|
255
|
-
});
|
|
256
|
-
newValueString = recast.print(newValueExpr).code;
|
|
257
|
-
if (prop) {
|
|
258
|
-
prop.value = newValueExpr;
|
|
259
|
-
}
|
|
260
|
-
else {
|
|
261
|
-
objExpr.properties.push(b.objectProperty(b.identifier(update.key), newValueExpr));
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
const fieldSchema = schema[update.key];
|
|
265
|
-
const staticUpdateValue = getStaticUpdateValue(update);
|
|
266
|
-
if (fieldSchema &&
|
|
267
|
-
fieldSchema.type === 'enum' &&
|
|
268
|
-
staticUpdateValue !== null) {
|
|
269
|
-
const propsToDelete = no_react_1.NoReactInternals.findPropsToDelete({
|
|
270
|
-
schema,
|
|
271
|
-
key: update.key,
|
|
272
|
-
value: staticUpdateValue,
|
|
273
|
-
});
|
|
274
|
-
for (const propToDelete of propsToDelete) {
|
|
275
|
-
const removed = removeObjectProperty({
|
|
276
|
-
objExpr,
|
|
277
|
-
propertyName: propToDelete,
|
|
278
|
-
});
|
|
279
|
-
if (removed) {
|
|
280
|
-
removedProps.push(removed);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
const logLine = (_j = (_h = (_c = call.loc) === null || _c === void 0 ? void 0 : _c.start.line) !== null && _h !== void 0 ? _h : (_d = jsx.loc) === null || _d === void 0 ? void 0 : _d.start.line) !== null && _j !== void 0 ? _j : 1;
|
|
285
|
-
return {
|
|
286
|
-
serialized: (0, parse_ast_1.serializeAst)(ast),
|
|
287
|
-
oldValueString,
|
|
288
|
-
newValueString,
|
|
289
|
-
logLine,
|
|
290
|
-
effectCallee,
|
|
291
|
-
removedProps,
|
|
292
|
-
};
|
|
293
|
-
};
|
|
294
|
-
exports.updateEffectPropsAst = updateEffectPropsAst;
|
|
295
|
-
const updateEffectProps = async ({ input, sequenceNodePath, effectIndex, update, schema, prettierConfigOverride, }) => {
|
|
296
|
-
const { serialized, oldValueString, newValueString, logLine, effectCallee, removedProps, } = (0, exports.updateEffectPropsAst)({
|
|
297
|
-
input,
|
|
298
|
-
sequenceNodePath,
|
|
299
|
-
effectIndex,
|
|
300
|
-
update,
|
|
301
|
-
schema,
|
|
302
|
-
});
|
|
303
|
-
const { output, formatted } = await (0, format_file_content_1.formatFileContent)({
|
|
304
|
-
input: serialized,
|
|
305
|
-
prettierConfigOverride,
|
|
306
|
-
});
|
|
307
|
-
return {
|
|
308
|
-
output,
|
|
309
|
-
oldValueString,
|
|
310
|
-
newValueString,
|
|
311
|
-
formatted,
|
|
312
|
-
logLine,
|
|
313
|
-
effectCallee,
|
|
314
|
-
removedProps,
|
|
315
|
-
};
|
|
316
|
-
};
|
|
317
|
-
exports.updateEffectProps = updateEffectProps;
|
|
@@ -2,15 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.updateEffectKeyframes = exports.updateSequenceKeyframes = exports.updateSequenceKeyframesAst = exports.updateEffectKeyframesAst = void 0;
|
|
4
4
|
const studio_codemods_1 = require("@remotion/studio-codemods");
|
|
5
|
-
const format_file_content_1 = require("../format-file-content");
|
|
6
5
|
const studio_codemods_2 = require("@remotion/studio-codemods");
|
|
7
6
|
Object.defineProperty(exports, "updateEffectKeyframesAst", { enumerable: true, get: function () { return studio_codemods_2.updateEffectKeyframesAst; } });
|
|
8
7
|
Object.defineProperty(exports, "updateSequenceKeyframesAst", { enumerable: true, get: function () { return studio_codemods_2.updateSequenceKeyframesAst; } });
|
|
9
|
-
const
|
|
10
|
-
input: contents,
|
|
11
|
-
prettierConfigOverride,
|
|
12
|
-
});
|
|
13
|
-
const updateSequenceKeyframes = (input) => (0, studio_codemods_1.updateSequenceKeyframes)({ ...input, formatFile: formatKeyframesFile });
|
|
8
|
+
const updateSequenceKeyframes = (input) => (0, studio_codemods_1.updateSequenceKeyframes)(input);
|
|
14
9
|
exports.updateSequenceKeyframes = updateSequenceKeyframes;
|
|
15
|
-
const updateEffectKeyframes = (input) => (0, studio_codemods_1.updateEffectKeyframes)(
|
|
10
|
+
const updateEffectKeyframes = (input) => (0, studio_codemods_1.updateEffectKeyframes)(input);
|
|
16
11
|
exports.updateEffectKeyframes = updateEffectKeyframes;
|
|
@@ -3,72 +3,34 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.updateSequenceProps = exports.updateMultipleSequenceProps = exports.updateSequencePropsAst = void 0;
|
|
4
4
|
const studio_codemods_1 = require("@remotion/studio-codemods");
|
|
5
5
|
Object.defineProperty(exports, "updateSequencePropsAst", { enumerable: true, get: function () { return studio_codemods_1.updateSequencePropsAst; } });
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
ast: providedAst,
|
|
13
|
-
});
|
|
14
|
-
if (unformattedOutput === input) {
|
|
15
|
-
return { output: input, formatted: true, results, ast };
|
|
16
|
-
}
|
|
17
|
-
if ((openingElementRanges === null || openingElementRanges === void 0 ? void 0 : openingElementRanges.length) === 1) {
|
|
18
|
-
const [range] = openingElementRanges;
|
|
19
|
-
const openingElement = unformattedOutput.slice(range.start, range.end);
|
|
20
|
-
const formattableOpeningElement = range.selfClosing
|
|
21
|
-
? openingElement
|
|
22
|
-
: openingElement.slice(0, -1) + ' />';
|
|
23
|
-
const lineStart = unformattedOutput.lastIndexOf('\n', range.start) + 1;
|
|
24
|
-
const linePrefix = unformattedOutput.slice(lineStart, range.start);
|
|
25
|
-
const { formatted: formattedOpeningElement, didFormat } = await (0, format_inline_content_1.formatInlineContent)({
|
|
26
|
-
inlineContent: formattableOpeningElement,
|
|
27
|
-
linePrefix,
|
|
28
|
-
endOfLine: 'lf',
|
|
6
|
+
const updateMultipleSequenceProps = ({ input, changes, prettierConfigOverride, ast: providedAst, }) => {
|
|
7
|
+
return Promise.resolve().then(() => {
|
|
8
|
+
const { output, results, ast } = (0, studio_codemods_1.updateMultipleSequenceProps)({
|
|
9
|
+
input,
|
|
10
|
+
changes,
|
|
11
|
+
ast: providedAst,
|
|
29
12
|
prettierConfigOverride,
|
|
30
13
|
});
|
|
31
|
-
|
|
32
|
-
if (!range.selfClosing) {
|
|
33
|
-
const slashIndex = finalOpeningElement.lastIndexOf('/>');
|
|
34
|
-
if (slashIndex !== finalOpeningElement.length - 2) {
|
|
35
|
-
throw new Error('Could not format JSX opening element');
|
|
36
|
-
}
|
|
37
|
-
const lastLineStart = finalOpeningElement.lastIndexOf('\n') + 1;
|
|
38
|
-
const beforeSlash = finalOpeningElement.slice(lastLineStart, slashIndex);
|
|
39
|
-
finalOpeningElement =
|
|
40
|
-
beforeSlash.trim().length === 0
|
|
41
|
-
? finalOpeningElement.slice(0, slashIndex) + '>'
|
|
42
|
-
: finalOpeningElement.slice(0, slashIndex).trimEnd() + '>';
|
|
43
|
-
}
|
|
44
|
-
return {
|
|
45
|
-
output: unformattedOutput.slice(0, range.start) +
|
|
46
|
-
finalOpeningElement +
|
|
47
|
-
unformattedOutput.slice(range.end),
|
|
48
|
-
formatted: didFormat,
|
|
49
|
-
results,
|
|
50
|
-
ast,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
const { output, formatted } = await (0, format_file_content_1.formatFileContent)({
|
|
54
|
-
input: unformattedOutput,
|
|
55
|
-
prettierConfigOverride,
|
|
14
|
+
return { output, formatted: true, results, ast };
|
|
56
15
|
});
|
|
57
|
-
return { output, formatted, results, ast };
|
|
58
16
|
};
|
|
59
17
|
exports.updateMultipleSequenceProps = updateMultipleSequenceProps;
|
|
60
18
|
const updateSequenceProps = async ({ input, nodePath, updates, schema, prettierConfigOverride, videoConfigValues, }) => {
|
|
61
|
-
const {
|
|
19
|
+
const { output, results } = await (0, exports.updateMultipleSequenceProps)({
|
|
62
20
|
input,
|
|
63
|
-
nodePath,
|
|
64
|
-
updates,
|
|
65
|
-
schema,
|
|
66
|
-
videoConfigValues,
|
|
67
|
-
});
|
|
68
|
-
const { output, formatted } = await (0, format_file_content_1.formatFileContent)({
|
|
69
|
-
input: serialized,
|
|
21
|
+
changes: [{ nodePath, updates, schema, videoConfigValues }],
|
|
70
22
|
prettierConfigOverride,
|
|
71
23
|
});
|
|
72
|
-
|
|
24
|
+
const result = results[0];
|
|
25
|
+
if (!result) {
|
|
26
|
+
throw new Error('Expected sequence prop update result');
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
output,
|
|
30
|
+
oldValueStrings: result.oldValueStrings,
|
|
31
|
+
formatted: true,
|
|
32
|
+
logLine: result.logLine,
|
|
33
|
+
removedProps: result.removedProps,
|
|
34
|
+
};
|
|
73
35
|
};
|
|
74
36
|
exports.updateSequenceProps = updateSequenceProps;
|
|
@@ -12,7 +12,7 @@ export declare const resolveCompositionComponent: ({ remotionRoot, compositionFi
|
|
|
12
12
|
compositionFile: string;
|
|
13
13
|
compositionId: string;
|
|
14
14
|
}) => Promise<ResolvedCompositionComponent>;
|
|
15
|
-
export declare const insertJsxElementIntoComposition: ({ remotionRoot, compositionFile, compositionId, element, from, prettierConfigOverride, wrapInSequence, }: {
|
|
15
|
+
export declare const insertJsxElementIntoComposition: ({ remotionRoot, compositionFile, compositionId, element, from, prettierConfigOverride, wrapInSequence, sourceFileOverrides, }: {
|
|
16
16
|
remotionRoot: string;
|
|
17
17
|
compositionFile: string;
|
|
18
18
|
compositionId: string;
|
|
@@ -29,6 +29,7 @@ export declare const insertJsxElementIntoComposition: ({ remotionRoot, compositi
|
|
|
29
29
|
name: string | null;
|
|
30
30
|
position: InsertableCompositionElementPosition | null;
|
|
31
31
|
} | null | undefined;
|
|
32
|
+
sourceFileOverrides: ReadonlyMap<string, string> | null;
|
|
32
33
|
}) => Promise<{
|
|
33
34
|
fileName: string;
|
|
34
35
|
source: string;
|
|
@@ -8,14 +8,20 @@ const node_fs_1 = __importDefault(require("node:fs"));
|
|
|
8
8
|
const node_path_1 = __importDefault(require("node:path"));
|
|
9
9
|
const studio_codemods_1 = require("@remotion/studio-codemods");
|
|
10
10
|
const svg_to_jsx_1 = require("./svg-to-jsx");
|
|
11
|
-
const makeCodemodEnvironment = (remotionRoot) => ({
|
|
11
|
+
const makeCodemodEnvironment = (remotionRoot, sourceFileOverrides) => ({
|
|
12
12
|
dirname: node_path_1.default.dirname,
|
|
13
13
|
extname: node_path_1.default.extname,
|
|
14
|
-
fileExists: (fileName) =>
|
|
14
|
+
fileExists: (fileName) => (sourceFileOverrides === null || sourceFileOverrides === void 0 ? void 0 : sourceFileOverrides.has(node_path_1.default.resolve(fileName))) === true ||
|
|
15
|
+
(node_fs_1.default.existsSync(fileName) && node_fs_1.default.statSync(fileName).isFile()),
|
|
15
16
|
isAbsolute: node_path_1.default.isAbsolute,
|
|
16
17
|
join: node_path_1.default.join,
|
|
17
18
|
pathSeparator: node_path_1.default.sep,
|
|
18
|
-
readFile: (fileName) =>
|
|
19
|
+
readFile: (fileName) => {
|
|
20
|
+
const override = sourceFileOverrides === null || sourceFileOverrides === void 0 ? void 0 : sourceFileOverrides.get(node_path_1.default.resolve(fileName));
|
|
21
|
+
return override === undefined
|
|
22
|
+
? node_fs_1.default.promises.readFile(fileName, 'utf-8')
|
|
23
|
+
: Promise.resolve(override);
|
|
24
|
+
},
|
|
19
25
|
relative: node_path_1.default.relative,
|
|
20
26
|
resolve: node_path_1.default.resolve,
|
|
21
27
|
rootDir: remotionRoot,
|
|
@@ -24,22 +30,22 @@ const makeCodemodEnvironment = (remotionRoot) => ({
|
|
|
24
30
|
const resolveCompositionComponentWithFile = ({ remotionRoot, compositionFile, compositionId, }) => (0, studio_codemods_1.resolveCompositionComponentWithFile)({
|
|
25
31
|
compositionFile,
|
|
26
32
|
compositionId,
|
|
27
|
-
environment: makeCodemodEnvironment(remotionRoot),
|
|
33
|
+
environment: makeCodemodEnvironment(remotionRoot, null),
|
|
28
34
|
});
|
|
29
35
|
exports.resolveCompositionComponentWithFile = resolveCompositionComponentWithFile;
|
|
30
36
|
const resolveCompositionComponent = ({ remotionRoot, compositionFile, compositionId, }) => (0, studio_codemods_1.resolveCompositionComponent)({
|
|
31
37
|
compositionFile,
|
|
32
38
|
compositionId,
|
|
33
|
-
environment: makeCodemodEnvironment(remotionRoot),
|
|
39
|
+
environment: makeCodemodEnvironment(remotionRoot, null),
|
|
34
40
|
});
|
|
35
41
|
exports.resolveCompositionComponent = resolveCompositionComponent;
|
|
36
|
-
const insertJsxElementIntoComposition = ({ remotionRoot, compositionFile, compositionId, element, from, prettierConfigOverride, wrapInSequence = null, }) => {
|
|
42
|
+
const insertJsxElementIntoComposition = ({ remotionRoot, compositionFile, compositionId, element, from, prettierConfigOverride, wrapInSequence = null, sourceFileOverrides, }) => {
|
|
37
43
|
var _a;
|
|
38
44
|
return (0, studio_codemods_1.insertJsxElementIntoComposition)({
|
|
39
45
|
compositionFile,
|
|
40
46
|
compositionId,
|
|
41
47
|
element,
|
|
42
|
-
environment: makeCodemodEnvironment(remotionRoot),
|
|
48
|
+
environment: makeCodemodEnvironment(remotionRoot, sourceFileOverrides),
|
|
43
49
|
from,
|
|
44
50
|
prettierConfigOverride,
|
|
45
51
|
wrapInSequence: wrapInSequence === null
|
package/dist/index.d.ts
CHANGED
|
@@ -99,16 +99,14 @@ export declare const StudioServerInternals: {
|
|
|
99
99
|
filePath: string;
|
|
100
100
|
codeMod: import("@remotion/studio-shared").RecastCodemod;
|
|
101
101
|
}) => Promise<string>;
|
|
102
|
-
formatOutput: (tsContent: string) => Promise<string>;
|
|
103
102
|
updateDefaultProps: ({ input, compositionId, newDefaultProps, enumPaths, }: {
|
|
104
103
|
input: string;
|
|
105
104
|
compositionId: string;
|
|
106
105
|
newDefaultProps: Record<string, unknown>;
|
|
107
106
|
enumPaths: import("@remotion/studio-shared").EnumPath[];
|
|
108
|
-
}) =>
|
|
107
|
+
}) => {
|
|
109
108
|
output: string;
|
|
110
|
-
|
|
111
|
-
}>;
|
|
109
|
+
};
|
|
112
110
|
getInstalledDependencies: (remotionRoot: string) => {
|
|
113
111
|
dependencies: string[];
|
|
114
112
|
devDependencies: string[];
|
package/dist/index.js
CHANGED
|
@@ -4,10 +4,10 @@ exports.StudioServerInternals = exports.remotionSkillNames = exports.parseRemoti
|
|
|
4
4
|
const studio_shared_1 = require("@remotion/studio-shared");
|
|
5
5
|
const studio_shared_2 = require("@remotion/studio-shared");
|
|
6
6
|
Object.defineProperty(exports, "getDefaultOutLocation", { enumerable: true, get: function () { return studio_shared_2.getDefaultOutLocation; } });
|
|
7
|
+
const studio_codemods_1 = require("@remotion/studio-codemods");
|
|
7
8
|
const ansi_diff_1 = require("./ansi-diff");
|
|
8
9
|
const client_render_queue_1 = require("./client-render-queue");
|
|
9
10
|
const apply_codemod_to_file_1 = require("./codemods/apply-codemod-to-file");
|
|
10
|
-
const duplicate_composition_1 = require("./codemods/duplicate-composition");
|
|
11
11
|
const update_default_props_1 = require("./codemods/update-default-props");
|
|
12
12
|
const detect_outdated_remotion_skills_1 = require("./detect-outdated-remotion-skills");
|
|
13
13
|
Object.defineProperty(exports, "detectOutdatedRemotionSkills", { enumerable: true, get: function () { return detect_outdated_remotion_skills_1.detectOutdatedRemotionSkills; } });
|
|
@@ -42,9 +42,8 @@ exports.StudioServerInternals = {
|
|
|
42
42
|
setFileWatcherRegistry: file_watcher_1.setFileWatcherRegistry,
|
|
43
43
|
AnsiDiff: ansi_diff_1.AnsiDiff,
|
|
44
44
|
formatBytes: studio_shared_1.formatBytes,
|
|
45
|
-
parseAndApplyCodemod:
|
|
45
|
+
parseAndApplyCodemod: studio_codemods_1.parseAndApplyCodemod,
|
|
46
46
|
applyCodemodToFile: apply_codemod_to_file_1.applyCodemodToFile,
|
|
47
|
-
formatOutput: duplicate_composition_1.formatOutput,
|
|
48
47
|
updateDefaultProps: update_default_props_1.updateDefaultProps,
|
|
49
48
|
getInstalledDependencies: get_installed_dependencies_1.getInstalledDependencies,
|
|
50
49
|
getInstalledDependenciesWithVersions: get_installed_dependencies_1.getInstalledDependenciesWithVersions,
|
|
@@ -25,6 +25,8 @@ const duplicate_jsx_node_1 = require("./routes/duplicate-jsx-node");
|
|
|
25
25
|
const find_in_file_1 = require("./routes/find-in-file");
|
|
26
26
|
const insert_element_1 = require("./routes/insert-element");
|
|
27
27
|
const insert_jsx_element_1 = require("./routes/insert-jsx-element");
|
|
28
|
+
const install_remotion_skill_1 = require("./routes/install-remotion-skill");
|
|
29
|
+
const invalidate_bundle_1 = require("./routes/invalidate-bundle");
|
|
28
30
|
const log_studio_error_1 = require("./routes/log-studio-error");
|
|
29
31
|
const move_keyframes_1 = require("./routes/move-keyframes");
|
|
30
32
|
const open_in_editor_1 = require("./routes/open-in-editor");
|
|
@@ -64,6 +66,7 @@ const update_element_install_target_1 = require("./routes/update-element-install
|
|
|
64
66
|
const update_sequence_keyframe_settings_1 = require("./routes/update-sequence-keyframe-settings");
|
|
65
67
|
const upgrade_remotion_1 = require("./routes/upgrade-remotion");
|
|
66
68
|
exports.allApiRoutes = {
|
|
69
|
+
'/api/invalidate-bundle': invalidate_bundle_1.invalidateBundleHandler,
|
|
67
70
|
'/api/composition-component-info': composition_component_info_1.compositionComponentInfoHandler,
|
|
68
71
|
'/api/copy-render-output-to-asset': copy_render_output_to_asset_1.copyRenderOutputToAssetHandler,
|
|
69
72
|
'/api/convert-figma-clipboard-to-svg': convert_figma_clipboard_to_svg_1.convertFigmaClipboardToSvgHandler,
|
|
@@ -111,6 +114,8 @@ exports.allApiRoutes = {
|
|
|
111
114
|
'/api/update-available': update_available_1.handleUpdate,
|
|
112
115
|
'/api/release-notes': release_notes_1.getReleaseNotesHandler,
|
|
113
116
|
'/api/remotion-skills-info': remotion_skills_info_1.remotionSkillsInfoHandler,
|
|
117
|
+
'/api/install-remotion-skill': install_remotion_skill_1.installRemotionSkillHandler,
|
|
118
|
+
'/api/remove-remotion-skill': install_remotion_skill_1.removeRemotionSkillHandler,
|
|
114
119
|
'/api/project-info': project_info_1.projectInfoHandler,
|
|
115
120
|
'/api/delete-static-file': delete_static_file_1.deleteStaticFileHandler,
|
|
116
121
|
'/api/rename-static-file': rename_static_file_1.renameStaticFileHandler,
|
|
@@ -179,6 +179,7 @@ const addKeyframes = async ({ sequenceKeyframes, effectKeyframes, clientId, remo
|
|
|
179
179
|
? 'sequence-props'
|
|
180
180
|
: 'effect-props',
|
|
181
181
|
suppressHmrOnFileRestore: true,
|
|
182
|
+
undoRedoNavigation: null,
|
|
182
183
|
});
|
|
183
184
|
for (const snapshot of snapshots) {
|
|
184
185
|
(0, undo_stack_1.suppressUndoStackInvalidation)(snapshot.filePath);
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
import type { ApplyCodemodRequest, ApplyCodemodResponse } from '@remotion/studio-shared';
|
|
2
2
|
import type { ApiHandler } from '../api-types';
|
|
3
|
+
export declare const formatNewCompositionFile: (codemod: {
|
|
4
|
+
type: "new-composition";
|
|
5
|
+
newId: string;
|
|
6
|
+
componentName: string;
|
|
7
|
+
componentImportPath: string;
|
|
8
|
+
folderName: string | null;
|
|
9
|
+
parentName: string | null;
|
|
10
|
+
newHeight: number;
|
|
11
|
+
newWidth: number;
|
|
12
|
+
newFps: number;
|
|
13
|
+
newDurationInFrames: number;
|
|
14
|
+
canvasCapture: {
|
|
15
|
+
readonly videoFileName: string;
|
|
16
|
+
readonly videoHeight: number;
|
|
17
|
+
readonly videoWidth: number;
|
|
18
|
+
readonly keyframeFps: number;
|
|
19
|
+
readonly data: import("@remotion/studio-shared").CanvasCaptureData;
|
|
20
|
+
} | null;
|
|
21
|
+
}) => string;
|
|
3
22
|
export declare const getCodemodLogMessage: (codemod: import("@remotion/studio-shared").RecastCodemod) => string;
|
|
4
23
|
export declare const applyCodemodHandler: ApiHandler<ApplyCodemodRequest, ApplyCodemodResponse>;
|