@remotion/studio-server 4.0.471 → 4.0.473
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 +11 -0
- package/dist/codemods/add-effect.js +14 -52
- package/dist/codemods/effect-param-expression.d.ts +15 -0
- package/dist/codemods/effect-param-expression.js +131 -0
- package/dist/codemods/format-file-content.js +1 -1
- package/dist/codemods/parse-ast.js +4 -1
- package/dist/codemods/paste-effects.d.ts +15 -0
- package/dist/codemods/paste-effects.js +147 -0
- package/dist/codemods/recast-mods.js +178 -31
- package/dist/codemods/reorder-sequence.d.ts +14 -0
- package/dist/codemods/reorder-sequence.js +109 -0
- package/dist/codemods/update-effect-props/update-effect-props.d.ts +7 -0
- package/dist/codemods/update-effect-props/update-effect-props.js +64 -16
- package/dist/codemods/update-keyframes/ensure-imports-and-frame-hook.d.ts +1 -1
- package/dist/codemods/update-keyframes/ensure-imports-and-frame-hook.js +7 -55
- package/dist/codemods/update-keyframes/update-keyframes.d.ts +24 -6
- package/dist/codemods/update-keyframes/update-keyframes.js +279 -16
- package/dist/helpers/get-ast-node-path.js +6 -1
- package/dist/helpers/import-agnostic-node-path.d.ts +10 -0
- package/dist/helpers/import-agnostic-node-path.js +154 -0
- package/dist/helpers/imports.d.ts +16 -0
- package/dist/helpers/imports.js +145 -0
- package/dist/helpers/resolve-composition-component.js +133 -51
- package/dist/preview-server/api-routes.js +16 -0
- package/dist/preview-server/routes/add-effect-keyframe.js +2 -0
- package/dist/preview-server/routes/add-sequence-keyframe.js +1 -0
- package/dist/preview-server/routes/apply-codemod.js +18 -0
- package/dist/preview-server/routes/can-update-effect-props.d.ts +3 -2
- package/dist/preview-server/routes/can-update-effect-props.js +78 -8
- package/dist/preview-server/routes/can-update-sequence-props.d.ts +1 -1
- package/dist/preview-server/routes/can-update-sequence-props.js +82 -43
- package/dist/preview-server/routes/delete-keyframes.js +1 -0
- package/dist/preview-server/routes/download-remote-asset.d.ts +7 -0
- package/dist/preview-server/routes/download-remote-asset.js +267 -0
- package/dist/preview-server/routes/insert-jsx-element.js +26 -0
- package/dist/preview-server/routes/log-studio-error.d.ts +3 -0
- package/dist/preview-server/routes/log-studio-error.js +58 -0
- package/dist/preview-server/routes/move-keyframes.d.ts +7 -0
- package/dist/preview-server/routes/move-keyframes.js +242 -0
- package/dist/preview-server/routes/paste-effects.d.ts +3 -0
- package/dist/preview-server/routes/paste-effects.js +78 -0
- package/dist/preview-server/routes/rename-static-file.d.ts +3 -0
- package/dist/preview-server/routes/rename-static-file.js +53 -0
- package/dist/preview-server/routes/reorder-sequence.d.ts +3 -0
- package/dist/preview-server/routes/reorder-sequence.js +67 -0
- package/dist/preview-server/routes/save-effect-props.js +25 -9
- package/dist/preview-server/routes/save-sequence-props.js +2 -34
- package/dist/preview-server/routes/update-effect-keyframe-settings.d.ts +3 -0
- package/dist/preview-server/routes/update-effect-keyframe-settings.js +90 -0
- package/dist/preview-server/routes/update-sequence-keyframe-settings.d.ts +3 -0
- package/dist/preview-server/routes/update-sequence-keyframe-settings.js +85 -0
- package/dist/preview-server/undo-stack.d.ts +9 -1
- package/package.json +6 -6
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { JSXOpeningElement } from '@babel/types';
|
|
1
|
+
import type { File, JSXOpeningElement } from '@babel/types';
|
|
2
2
|
import type { CanUpdateEffectPropsResponse, SequenceNodePath, SequenceSchema } from 'remotion';
|
|
3
|
-
export declare const computeEffectPropStatus: ({ jsx, effectIndex, keys, }: {
|
|
3
|
+
export declare const computeEffectPropStatus: ({ ast, jsx, effectIndex, keys, }: {
|
|
4
|
+
ast: File;
|
|
4
5
|
jsx: JSXOpeningElement;
|
|
5
6
|
effectIndex: number;
|
|
6
7
|
keys: string[];
|
|
@@ -6,6 +6,10 @@ const parse_ast_1 = require("../../codemods/parse-ast");
|
|
|
6
6
|
const update_effect_props_1 = require("../../codemods/update-effect-props/update-effect-props");
|
|
7
7
|
const resolve_file_inside_project_1 = require("../../helpers/resolve-file-inside-project");
|
|
8
8
|
const can_update_sequence_props_1 = require("./can-update-sequence-props");
|
|
9
|
+
const staticStatus = (codeValue) => ({
|
|
10
|
+
status: 'static',
|
|
11
|
+
codeValue,
|
|
12
|
+
});
|
|
9
13
|
const findEffectsAttr = (jsx) => {
|
|
10
14
|
for (const attr of jsx.attributes) {
|
|
11
15
|
if (attr.type !== 'JSXAttribute') {
|
|
@@ -27,7 +31,64 @@ const getEffectsArrayElements = (attr) => {
|
|
|
27
31
|
}
|
|
28
32
|
return (0, update_effect_props_1.enumerateEffectArrayElements)(expr);
|
|
29
33
|
};
|
|
30
|
-
const
|
|
34
|
+
const getImportedName = (specifier) => {
|
|
35
|
+
var _a, _b;
|
|
36
|
+
if (!specifier.imported) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
if (specifier.imported.type === 'Identifier') {
|
|
40
|
+
return (_a = specifier.imported.name) !== null && _a !== void 0 ? _a : null;
|
|
41
|
+
}
|
|
42
|
+
return (_b = specifier.imported.value) !== null && _b !== void 0 ? _b : null;
|
|
43
|
+
};
|
|
44
|
+
const resolveEffectImport = ({ ast, call, fallbackCallee, }) => {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
var _c;
|
|
47
|
+
const { callee } = call;
|
|
48
|
+
if (callee.type === 'Identifier') {
|
|
49
|
+
const localName = callee.name;
|
|
50
|
+
for (const node of ast.program.body) {
|
|
51
|
+
if (node.type !== 'ImportDeclaration') {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const matchingSpecifier = (_a = node.specifiers) === null || _a === void 0 ? void 0 : _a.find((specifier) => {
|
|
55
|
+
var _a;
|
|
56
|
+
return (specifier.type === 'ImportSpecifier' &&
|
|
57
|
+
((_a = specifier.local) === null || _a === void 0 ? void 0 : _a.name) === localName);
|
|
58
|
+
});
|
|
59
|
+
if ((matchingSpecifier === null || matchingSpecifier === void 0 ? void 0 : matchingSpecifier.type) === 'ImportSpecifier') {
|
|
60
|
+
return {
|
|
61
|
+
callee: (_c = getImportedName(matchingSpecifier)) !== null && _c !== void 0 ? _c : fallbackCallee,
|
|
62
|
+
importPath: String(node.source.value),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (callee.type === 'MemberExpression' &&
|
|
68
|
+
callee.object.type === 'Identifier' &&
|
|
69
|
+
callee.property.type === 'Identifier' &&
|
|
70
|
+
!callee.computed) {
|
|
71
|
+
const namespaceName = callee.object.name;
|
|
72
|
+
for (const node of ast.program.body) {
|
|
73
|
+
if (node.type !== 'ImportDeclaration') {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const matchingSpecifier = (_b = node.specifiers) === null || _b === void 0 ? void 0 : _b.find((specifier) => {
|
|
77
|
+
var _a;
|
|
78
|
+
return (specifier.type === 'ImportNamespaceSpecifier' &&
|
|
79
|
+
((_a = specifier.local) === null || _a === void 0 ? void 0 : _a.name) === namespaceName);
|
|
80
|
+
});
|
|
81
|
+
if (matchingSpecifier) {
|
|
82
|
+
return {
|
|
83
|
+
callee: callee.property.name,
|
|
84
|
+
importPath: String(node.source.value),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return { callee: fallbackCallee, importPath: null };
|
|
90
|
+
};
|
|
91
|
+
const getPropsFromObjectExpression = ({ ast, objExpr, keys, }) => {
|
|
31
92
|
const out = {};
|
|
32
93
|
for (const key of keys) {
|
|
33
94
|
const prop = objExpr.properties.find((p) => p.type === 'ObjectProperty' &&
|
|
@@ -35,22 +96,22 @@ const getPropsFromObjectExpression = ({ objExpr, keys, }) => {
|
|
|
35
96
|
(p.key.type === 'StringLiteral' &&
|
|
36
97
|
p.key.value === key)));
|
|
37
98
|
if (!prop) {
|
|
38
|
-
out[key] =
|
|
99
|
+
out[key] = staticStatus(undefined);
|
|
39
100
|
continue;
|
|
40
101
|
}
|
|
41
102
|
const valueExpr = prop.value;
|
|
42
103
|
if (!(0, can_update_sequence_props_1.isStaticValue)(valueExpr)) {
|
|
43
|
-
out[key] = (0, can_update_sequence_props_1.getComputedStatus)(valueExpr);
|
|
104
|
+
out[key] = (0, can_update_sequence_props_1.getComputedStatus)(valueExpr, ast);
|
|
44
105
|
continue;
|
|
45
106
|
}
|
|
46
107
|
out[key] = {
|
|
47
|
-
|
|
108
|
+
status: 'static',
|
|
48
109
|
codeValue: (0, can_update_sequence_props_1.extractStaticValue)(valueExpr),
|
|
49
110
|
};
|
|
50
111
|
}
|
|
51
112
|
return out;
|
|
52
113
|
};
|
|
53
|
-
const computeEffectPropStatus = ({ jsx, effectIndex, keys, }) => {
|
|
114
|
+
const computeEffectPropStatus = ({ ast, jsx, effectIndex, keys, }) => {
|
|
54
115
|
const attr = findEffectsAttr(jsx);
|
|
55
116
|
const elements = getEffectsArrayElements(attr);
|
|
56
117
|
if (!elements) {
|
|
@@ -76,14 +137,20 @@ const computeEffectPropStatus = ({ jsx, effectIndex, keys, }) => {
|
|
|
76
137
|
};
|
|
77
138
|
}
|
|
78
139
|
const call = target.node;
|
|
140
|
+
const effectImport = resolveEffectImport({
|
|
141
|
+
ast,
|
|
142
|
+
call,
|
|
143
|
+
fallbackCallee: target.callee,
|
|
144
|
+
});
|
|
79
145
|
if (call.arguments.length === 0) {
|
|
80
146
|
const emptyProps = {};
|
|
81
147
|
for (const key of keys) {
|
|
82
|
-
emptyProps[key] =
|
|
148
|
+
emptyProps[key] = staticStatus(undefined);
|
|
83
149
|
}
|
|
84
150
|
return {
|
|
85
151
|
canUpdate: true,
|
|
86
|
-
callee:
|
|
152
|
+
callee: effectImport.callee,
|
|
153
|
+
importPath: effectImport.importPath,
|
|
87
154
|
effectIndex,
|
|
88
155
|
props: emptyProps,
|
|
89
156
|
};
|
|
@@ -97,13 +164,15 @@ const computeEffectPropStatus = ({ jsx, effectIndex, keys, }) => {
|
|
|
97
164
|
};
|
|
98
165
|
}
|
|
99
166
|
const resolvedProps = getPropsFromObjectExpression({
|
|
167
|
+
ast,
|
|
100
168
|
objExpr: firstArg,
|
|
101
169
|
keys,
|
|
102
170
|
});
|
|
103
171
|
return {
|
|
104
172
|
canUpdate: true,
|
|
105
173
|
effectIndex,
|
|
106
|
-
callee:
|
|
174
|
+
callee: effectImport.callee,
|
|
175
|
+
importPath: effectImport.importPath,
|
|
107
176
|
props: resolvedProps,
|
|
108
177
|
};
|
|
109
178
|
};
|
|
@@ -119,6 +188,7 @@ const computeEffectPropsStatusesFromContent = ({ fileContents, sequenceNodePath,
|
|
|
119
188
|
}));
|
|
120
189
|
}
|
|
121
190
|
return effects.map((effect, effectIndex) => (0, exports.computeEffectPropStatus)({
|
|
191
|
+
ast,
|
|
122
192
|
jsx,
|
|
123
193
|
effectIndex,
|
|
124
194
|
keys: keysFor(effect),
|
|
@@ -3,7 +3,7 @@ import type { SubscribeToSequencePropsResponse } from '@remotion/studio-shared';
|
|
|
3
3
|
import type { CanUpdateSequencePropsResponseTrue, CanUpdateSequencePropStatus, SequenceNodePath } from 'remotion';
|
|
4
4
|
export declare const isStaticValue: (node: Expression) => boolean;
|
|
5
5
|
export declare const extractStaticValue: (node: Expression) => unknown;
|
|
6
|
-
export declare const getComputedStatus: (node: Expression) => CanUpdateSequencePropStatus;
|
|
6
|
+
export declare const getComputedStatus: (node: Expression, ast: File) => CanUpdateSequencePropStatus;
|
|
7
7
|
export declare const findJsxElementAtNodePath: (ast: File, nodePath: SequenceNodePath) => JSXOpeningElement | null;
|
|
8
8
|
export declare const findNodePathForJsxElement: (ast: File, target: JSXOpeningElement) => SequenceNodePath | null;
|
|
9
9
|
export declare const lineColumnToNodePath: (ast: File, targetLine: number) => SequenceNodePath | null;
|
|
@@ -36,12 +36,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.computeSequencePropsStatusFromFilenameByLine = exports.computeSequencePropsStatus = exports.computeSequencePropsStatusFromContent = exports.lineColumnToNodePath = exports.findNodePathForJsxElement = exports.findJsxElementAtNodePath = exports.getComputedStatus = exports.extractStaticValue = exports.isStaticValue = void 0;
|
|
37
37
|
const node_fs_1 = require("node:fs");
|
|
38
38
|
const renderer_1 = require("@remotion/renderer");
|
|
39
|
+
const studio_shared_1 = require("@remotion/studio-shared");
|
|
39
40
|
const recast = __importStar(require("recast"));
|
|
40
41
|
const parse_ast_1 = require("../../codemods/parse-ast");
|
|
41
42
|
const get_ast_node_path_1 = require("../../helpers/get-ast-node-path");
|
|
43
|
+
const import_agnostic_node_path_1 = require("../../helpers/import-agnostic-node-path");
|
|
42
44
|
const resolve_file_inside_project_1 = require("../../helpers/resolve-file-inside-project");
|
|
43
45
|
const jsx_element_not_found_at_location_error_1 = require("../jsx-element-not-found-at-location-error");
|
|
44
46
|
const can_update_effect_props_1 = require("./can-update-effect-props");
|
|
47
|
+
const staticStatus = (codeValue) => ({
|
|
48
|
+
status: 'static',
|
|
49
|
+
codeValue,
|
|
50
|
+
});
|
|
51
|
+
const computedStatus = () => ({
|
|
52
|
+
status: 'computed',
|
|
53
|
+
});
|
|
45
54
|
const isStaticValue = (node) => {
|
|
46
55
|
switch (node.type) {
|
|
47
56
|
case 'NumericLiteral':
|
|
@@ -296,23 +305,26 @@ const getInterpolationMetadata = (interpolationFunction, callExpression, keyfram
|
|
|
296
305
|
posterize,
|
|
297
306
|
};
|
|
298
307
|
};
|
|
299
|
-
const getInterpolationKeyframes = (node) => {
|
|
308
|
+
const getInterpolationKeyframes = (node, ast) => {
|
|
300
309
|
if (node.type === 'TSAsExpression') {
|
|
301
|
-
return getInterpolationKeyframes(node.expression);
|
|
310
|
+
return getInterpolationKeyframes(node.expression, ast);
|
|
302
311
|
}
|
|
303
312
|
if (node.type !== 'CallExpression') {
|
|
304
313
|
return undefined;
|
|
305
314
|
}
|
|
306
315
|
const callExpression = node;
|
|
307
316
|
if (callExpression.callee.type !== 'Identifier' ||
|
|
308
|
-
(callExpression.callee.name
|
|
309
|
-
callExpression.callee.name !== 'interpolateColors')) {
|
|
317
|
+
!(0, studio_shared_1.isKeyframeInterpolationFunction)(callExpression.callee.name)) {
|
|
310
318
|
return undefined;
|
|
311
319
|
}
|
|
312
320
|
const interpolationFunction = callExpression.callee.name;
|
|
321
|
+
const frameArg = callExpression.arguments[0];
|
|
313
322
|
const inputArg = callExpression.arguments[1];
|
|
314
323
|
const outputArg = callExpression.arguments[2];
|
|
315
|
-
if (!
|
|
324
|
+
if (!frameArg ||
|
|
325
|
+
frameArg.type === 'SpreadElement' ||
|
|
326
|
+
!isCurrentFrameIdentifier(frameArg, ast) ||
|
|
327
|
+
!inputArg ||
|
|
316
328
|
!outputArg ||
|
|
317
329
|
inputArg.type !== 'ArrayExpression' ||
|
|
318
330
|
outputArg.type !== 'ArrayExpression') {
|
|
@@ -355,14 +367,46 @@ const getInterpolationKeyframes = (node) => {
|
|
|
355
367
|
posterize: metadata.posterize,
|
|
356
368
|
};
|
|
357
369
|
};
|
|
358
|
-
const
|
|
359
|
-
|
|
370
|
+
const isUseCurrentFrameCall = (node) => {
|
|
371
|
+
return (node.type === 'CallExpression' &&
|
|
372
|
+
node.callee.type === 'Identifier' &&
|
|
373
|
+
node.callee.name === 'useCurrentFrame' &&
|
|
374
|
+
node.arguments.length === 0);
|
|
375
|
+
};
|
|
376
|
+
const isCurrentFrameIdentifier = (node, ast) => {
|
|
377
|
+
if (node.type === 'TSAsExpression') {
|
|
378
|
+
return isCurrentFrameIdentifier(node.expression, ast);
|
|
379
|
+
}
|
|
380
|
+
if (node.type !== 'Identifier') {
|
|
381
|
+
return false;
|
|
382
|
+
}
|
|
383
|
+
let hasUseCurrentFrameDeclaration = false;
|
|
384
|
+
let hasOtherDeclaration = false;
|
|
385
|
+
recast.types.visit(ast, {
|
|
386
|
+
visitVariableDeclarator(p) {
|
|
387
|
+
const { id, init } = p.node;
|
|
388
|
+
if (id.type !== 'Identifier' || id.name !== node.name) {
|
|
389
|
+
return this.traverse(p);
|
|
390
|
+
}
|
|
391
|
+
if (init && isUseCurrentFrameCall(init)) {
|
|
392
|
+
hasUseCurrentFrameDeclaration = true;
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
hasOtherDeclaration = true;
|
|
396
|
+
}
|
|
397
|
+
return false;
|
|
398
|
+
},
|
|
399
|
+
});
|
|
400
|
+
return hasUseCurrentFrameDeclaration && !hasOtherDeclaration;
|
|
401
|
+
};
|
|
402
|
+
const getComputedStatus = (node, ast) => {
|
|
403
|
+
const interpolation = getInterpolationKeyframes(node, ast);
|
|
360
404
|
if (!interpolation) {
|
|
361
|
-
return
|
|
405
|
+
return computedStatus();
|
|
362
406
|
}
|
|
363
407
|
return {
|
|
364
|
-
|
|
365
|
-
|
|
408
|
+
status: 'keyframed',
|
|
409
|
+
codeValue: undefined,
|
|
366
410
|
interpolationFunction: interpolation.interpolationFunction,
|
|
367
411
|
keyframes: interpolation.keyframes,
|
|
368
412
|
easing: interpolation.easing,
|
|
@@ -371,7 +415,7 @@ const getComputedStatus = (node) => {
|
|
|
371
415
|
};
|
|
372
416
|
};
|
|
373
417
|
exports.getComputedStatus = getComputedStatus;
|
|
374
|
-
const getPropsStatus = (jsxElement) => {
|
|
418
|
+
const getPropsStatus = (jsxElement, ast) => {
|
|
375
419
|
const props = {};
|
|
376
420
|
for (const attr of jsxElement.attributes) {
|
|
377
421
|
if (attr.type === 'JSXSpreadAttribute') {
|
|
@@ -386,39 +430,33 @@ const getPropsStatus = (jsxElement) => {
|
|
|
386
430
|
}
|
|
387
431
|
const { value } = attr;
|
|
388
432
|
if (!value) {
|
|
389
|
-
props[name] =
|
|
433
|
+
props[name] = staticStatus(true);
|
|
390
434
|
continue;
|
|
391
435
|
}
|
|
392
436
|
if (value.type === 'StringLiteral') {
|
|
393
|
-
props[name] =
|
|
394
|
-
canUpdate: true,
|
|
395
|
-
codeValue: value.value,
|
|
396
|
-
};
|
|
437
|
+
props[name] = staticStatus(value.value);
|
|
397
438
|
continue;
|
|
398
439
|
}
|
|
399
440
|
if (value.type === 'JSXExpressionContainer') {
|
|
400
441
|
const { expression } = value;
|
|
401
442
|
if (expression.type === 'JSXEmptyExpression') {
|
|
402
|
-
props[name] =
|
|
443
|
+
props[name] = computedStatus();
|
|
403
444
|
continue;
|
|
404
445
|
}
|
|
405
446
|
if (!(0, exports.isStaticValue)(expression)) {
|
|
406
|
-
props[name] = (0, exports.getComputedStatus)(expression);
|
|
447
|
+
props[name] = (0, exports.getComputedStatus)(expression, ast);
|
|
407
448
|
continue;
|
|
408
449
|
}
|
|
409
|
-
props[name] =
|
|
410
|
-
canUpdate: true,
|
|
411
|
-
codeValue: (0, exports.extractStaticValue)(expression),
|
|
412
|
-
};
|
|
450
|
+
props[name] = staticStatus((0, exports.extractStaticValue)(expression));
|
|
413
451
|
continue;
|
|
414
452
|
}
|
|
415
|
-
props[name] =
|
|
453
|
+
props[name] = computedStatus();
|
|
416
454
|
}
|
|
417
455
|
return props;
|
|
418
456
|
};
|
|
419
457
|
const getNodePathForRecastPath = (
|
|
420
458
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
421
|
-
recastPath) => {
|
|
459
|
+
recastPath, ast) => {
|
|
422
460
|
const segments = [];
|
|
423
461
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
424
462
|
let current = recastPath;
|
|
@@ -428,9 +466,9 @@ recastPath) => {
|
|
|
428
466
|
}
|
|
429
467
|
// Recast paths start with "root" which doesn't correspond to a real AST property
|
|
430
468
|
if (segments.length > 0 && segments[0] === 'root') {
|
|
431
|
-
return segments.slice(1);
|
|
469
|
+
return (0, import_agnostic_node_path_1.toImportAgnosticNodePath)({ ast, nodePath: segments.slice(1) });
|
|
432
470
|
}
|
|
433
|
-
return segments;
|
|
471
|
+
return (0, import_agnostic_node_path_1.toImportAgnosticNodePath)({ ast, nodePath: segments });
|
|
434
472
|
};
|
|
435
473
|
const findJsxElementAtNodePath = (ast, nodePath) => {
|
|
436
474
|
const current = (0, get_ast_node_path_1.getAstNodePath)(ast, nodePath);
|
|
@@ -448,7 +486,7 @@ const findNodePathForJsxElement = (ast, target) => {
|
|
|
448
486
|
recast.types.visit(ast, {
|
|
449
487
|
visitJSXOpeningElement(p) {
|
|
450
488
|
if (p.node === target) {
|
|
451
|
-
foundPath = getNodePathForRecastPath(p);
|
|
489
|
+
foundPath = getNodePathForRecastPath(p, ast);
|
|
452
490
|
return false;
|
|
453
491
|
}
|
|
454
492
|
return this.traverse(p);
|
|
@@ -463,7 +501,7 @@ const lineColumnToNodePath = (ast, targetLine) => {
|
|
|
463
501
|
visitJSXOpeningElement(p) {
|
|
464
502
|
const { node } = p;
|
|
465
503
|
if (node.loc && node.loc.start.line === targetLine) {
|
|
466
|
-
foundPath = getNodePathForRecastPath(p);
|
|
504
|
+
foundPath = getNodePathForRecastPath(p, ast);
|
|
467
505
|
return false;
|
|
468
506
|
}
|
|
469
507
|
return this.traverse(p);
|
|
@@ -486,22 +524,22 @@ const validateStyleValue = (childKey, value) => {
|
|
|
486
524
|
}
|
|
487
525
|
return true;
|
|
488
526
|
};
|
|
489
|
-
const getNestedPropStatus = (jsxElement, parentKey, childKey) => {
|
|
527
|
+
const getNestedPropStatus = (jsxElement, ast, parentKey, childKey) => {
|
|
490
528
|
const attr = jsxElement.attributes.find((a) => a.type !== 'JSXSpreadAttribute' &&
|
|
491
529
|
a.name.type !== 'JSXNamespacedName' &&
|
|
492
530
|
a.name.name === parentKey);
|
|
493
531
|
if (!attr || !attr.value) {
|
|
494
532
|
// Parent attribute doesn't exist, nested prop can be added
|
|
495
|
-
return
|
|
533
|
+
return staticStatus(undefined);
|
|
496
534
|
}
|
|
497
535
|
if (attr.value.type !== 'JSXExpressionContainer') {
|
|
498
|
-
return
|
|
536
|
+
return computedStatus();
|
|
499
537
|
}
|
|
500
538
|
const { expression } = attr.value;
|
|
501
539
|
if (expression.type === 'JSXEmptyExpression' ||
|
|
502
540
|
expression.type !== 'ObjectExpression') {
|
|
503
541
|
// Parent is not an object literal (e.g. style={myStyles})
|
|
504
|
-
return
|
|
542
|
+
return computedStatus();
|
|
505
543
|
}
|
|
506
544
|
const objExpr = expression;
|
|
507
545
|
const prop = objExpr.properties.find((p) => p.type === 'ObjectProperty' &&
|
|
@@ -509,38 +547,39 @@ const getNestedPropStatus = (jsxElement, parentKey, childKey) => {
|
|
|
509
547
|
(p.key.type === 'StringLiteral' && p.key.value === childKey)));
|
|
510
548
|
if (!prop) {
|
|
511
549
|
// Property not set in the object, can be added
|
|
512
|
-
return
|
|
550
|
+
return staticStatus(undefined);
|
|
513
551
|
}
|
|
514
552
|
const propValue = prop.value;
|
|
515
553
|
if (!(0, exports.isStaticValue)(propValue)) {
|
|
516
|
-
return (0, exports.getComputedStatus)(propValue);
|
|
554
|
+
return (0, exports.getComputedStatus)(propValue, ast);
|
|
517
555
|
}
|
|
518
556
|
const codeValue = (0, exports.extractStaticValue)(propValue);
|
|
519
557
|
if (!validateStyleValue(childKey, codeValue)) {
|
|
520
|
-
return
|
|
558
|
+
return computedStatus();
|
|
521
559
|
}
|
|
522
|
-
return
|
|
560
|
+
return staticStatus(codeValue);
|
|
523
561
|
};
|
|
524
|
-
const computeEffectsForJsx = ({ jsxElement, effects, }) => {
|
|
562
|
+
const computeEffectsForJsx = ({ ast, jsxElement, effects, }) => {
|
|
525
563
|
return effects.map((effect, effectIndex) => (0, can_update_effect_props_1.computeEffectPropStatus)({
|
|
564
|
+
ast,
|
|
526
565
|
jsx: jsxElement,
|
|
527
566
|
effectIndex,
|
|
528
567
|
keys: effect,
|
|
529
568
|
}));
|
|
530
569
|
};
|
|
531
|
-
const computeSequenceOnlyPropsRecord = ({ jsxElement, keys, }) => {
|
|
532
|
-
const allProps = getPropsStatus(jsxElement);
|
|
570
|
+
const computeSequenceOnlyPropsRecord = ({ jsxElement, ast, keys, }) => {
|
|
571
|
+
const allProps = getPropsStatus(jsxElement, ast);
|
|
533
572
|
const filteredProps = {};
|
|
534
573
|
for (const key of keys) {
|
|
535
574
|
const dotIndex = key.indexOf('.');
|
|
536
575
|
if (dotIndex !== -1) {
|
|
537
|
-
filteredProps[key] = getNestedPropStatus(jsxElement, key.slice(0, dotIndex), key.slice(dotIndex + 1));
|
|
576
|
+
filteredProps[key] = getNestedPropStatus(jsxElement, ast, key.slice(0, dotIndex), key.slice(dotIndex + 1));
|
|
538
577
|
}
|
|
539
578
|
else if (key in allProps) {
|
|
540
579
|
filteredProps[key] = allProps[key];
|
|
541
580
|
}
|
|
542
581
|
else {
|
|
543
|
-
filteredProps[key] =
|
|
582
|
+
filteredProps[key] = staticStatus(undefined);
|
|
544
583
|
}
|
|
545
584
|
}
|
|
546
585
|
return filteredProps;
|
|
@@ -551,8 +590,8 @@ const computeSequencePropsStatusFromContent = ({ fileContents, nodePath, keys, e
|
|
|
551
590
|
if (!jsxElement) {
|
|
552
591
|
throw new jsx_element_not_found_at_location_error_1.JsxElementNotFoundAtLocationError();
|
|
553
592
|
}
|
|
554
|
-
const filteredProps = computeSequenceOnlyPropsRecord({ jsxElement, keys });
|
|
555
|
-
const effectsStatuses = computeEffectsForJsx({ jsxElement, effects });
|
|
593
|
+
const filteredProps = computeSequenceOnlyPropsRecord({ jsxElement, ast, keys });
|
|
594
|
+
const effectsStatuses = computeEffectsForJsx({ ast, jsxElement, effects });
|
|
556
595
|
return {
|
|
557
596
|
canUpdate: true,
|
|
558
597
|
props: filteredProps,
|
|
@@ -241,6 +241,7 @@ const deleteKeyframes = async ({ sequenceKeyframes, effectKeyframes, clientId, r
|
|
|
241
241
|
};
|
|
242
242
|
}
|
|
243
243
|
return (0, can_update_effect_props_1.computeEffectPropStatus)({
|
|
244
|
+
ast,
|
|
244
245
|
jsx,
|
|
245
246
|
effectIndex: keyframe.effectIndex,
|
|
246
247
|
keys: (0, studio_shared_1.getAllSchemaKeys)(keyframe.schema),
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type DownloadRemoteAssetRequest, type DownloadRemoteAssetResponse, type ImageFileType } from '@remotion/studio-shared';
|
|
2
|
+
import type { ApiHandler } from '../api-types';
|
|
3
|
+
export declare const getRemoteAssetFilename: ({ fileType, url, }: {
|
|
4
|
+
fileType: ImageFileType;
|
|
5
|
+
url: URL;
|
|
6
|
+
}) => string;
|
|
7
|
+
export declare const downloadRemoteAssetHandler: ApiHandler<DownloadRemoteAssetRequest, DownloadRemoteAssetResponse>;
|