@remotion/studio-server 4.0.472 → 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/effect-param-expression.d.ts +15 -0
- package/dist/codemods/effect-param-expression.js +131 -0
- package/dist/codemods/paste-effects.js +4 -91
- 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/update-keyframes.d.ts +14 -1
- package/dist/codemods/update-keyframes/update-keyframes.js +152 -0
- package/dist/helpers/resolve-composition-component.js +24 -5
- package/dist/preview-server/api-routes.js +14 -0
- package/dist/preview-server/routes/can-update-effect-props.js +3 -2
- package/dist/preview-server/routes/can-update-sequence-props.d.ts +1 -1
- package/dist/preview-server/routes/can-update-sequence-props.js +49 -13
- 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 +3 -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/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 +24 -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 +3 -1
- package/package.json +6 -6
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { File } from '@babel/types';
|
|
2
|
+
import type { EffectClipboardParam, EffectClipboardSnapshot } from '@remotion/studio-shared';
|
|
3
|
+
import type { ExpressionKind } from 'ast-types/lib/gen/kinds';
|
|
4
|
+
export type RemotionImportName = 'Easing' | 'interpolate' | 'interpolateColors' | 'useCurrentFrame';
|
|
5
|
+
export type RemotionLocalNames = Partial<Record<RemotionImportName, string>>;
|
|
6
|
+
export declare const getRequiredRemotionImportsForEffectParams: (params: Iterable<EffectClipboardParam>) => Set<RemotionImportName>;
|
|
7
|
+
export declare const getRequiredRemotionImports: (effects: EffectClipboardSnapshot[]) => Set<RemotionImportName>;
|
|
8
|
+
export declare const ensureRemotionImportLocalNames: ({ ast, requiredImports, }: {
|
|
9
|
+
ast: File;
|
|
10
|
+
requiredImports: Set<RemotionImportName>;
|
|
11
|
+
}) => Partial<Record<RemotionImportName, string>>;
|
|
12
|
+
export declare const makeParamExpression: ({ param, remotionLocalNames, }: {
|
|
13
|
+
param: EffectClipboardParam;
|
|
14
|
+
remotionLocalNames: Partial<Record<RemotionImportName, string>>;
|
|
15
|
+
}) => ExpressionKind;
|
|
@@ -0,0 +1,131 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.makeParamExpression = exports.ensureRemotionImportLocalNames = exports.getRequiredRemotionImports = exports.getRequiredRemotionImportsForEffectParams = void 0;
|
|
37
|
+
const recast = __importStar(require("recast"));
|
|
38
|
+
const imports_1 = require("../helpers/imports");
|
|
39
|
+
const update_nested_prop_1 = require("./update-nested-prop");
|
|
40
|
+
const b = recast.types.builders;
|
|
41
|
+
const isNonLinearEasing = (easing) => easing !== 'linear';
|
|
42
|
+
const keyframedParamNeedsEasingImport = (param) => {
|
|
43
|
+
return (param.interpolationFunction !== 'interpolateColors' &&
|
|
44
|
+
param.easing.some(isNonLinearEasing));
|
|
45
|
+
};
|
|
46
|
+
const getRequiredRemotionImportsForEffectParams = (params) => {
|
|
47
|
+
const requiredImports = new Set();
|
|
48
|
+
for (const param of params) {
|
|
49
|
+
if (param.type !== 'keyframed') {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
requiredImports.add('useCurrentFrame');
|
|
53
|
+
requiredImports.add(param.interpolationFunction);
|
|
54
|
+
if (keyframedParamNeedsEasingImport(param)) {
|
|
55
|
+
requiredImports.add('Easing');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return requiredImports;
|
|
59
|
+
};
|
|
60
|
+
exports.getRequiredRemotionImportsForEffectParams = getRequiredRemotionImportsForEffectParams;
|
|
61
|
+
const getRequiredRemotionImports = (effects) => {
|
|
62
|
+
return (0, exports.getRequiredRemotionImportsForEffectParams)(effects.flatMap((effect) => Object.values(effect.params)));
|
|
63
|
+
};
|
|
64
|
+
exports.getRequiredRemotionImports = getRequiredRemotionImports;
|
|
65
|
+
const ensureRemotionImportLocalNames = ({ ast, requiredImports, }) => {
|
|
66
|
+
const localNames = {};
|
|
67
|
+
for (const importedName of requiredImports) {
|
|
68
|
+
localNames[importedName] = (0, imports_1.ensureNamedImport)({
|
|
69
|
+
ast,
|
|
70
|
+
importedName,
|
|
71
|
+
sourcePath: 'remotion',
|
|
72
|
+
localName: importedName,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return localNames;
|
|
76
|
+
};
|
|
77
|
+
exports.ensureRemotionImportLocalNames = ensureRemotionImportLocalNames;
|
|
78
|
+
const makeEasingExpression = ({ easing, easingLocalName, }) => {
|
|
79
|
+
if (easing === 'linear') {
|
|
80
|
+
return b.memberExpression(b.identifier(easingLocalName), b.identifier('linear'));
|
|
81
|
+
}
|
|
82
|
+
return b.callExpression(b.memberExpression(b.identifier(easingLocalName), b.identifier('bezier')), easing.map((value) => (0, update_nested_prop_1.parseValueExpression)(value)));
|
|
83
|
+
};
|
|
84
|
+
const makeKeyframedOptions = ({ param, remotionLocalNames, }) => {
|
|
85
|
+
var _a;
|
|
86
|
+
const properties = [];
|
|
87
|
+
if (param.interpolationFunction !== 'interpolateColors') {
|
|
88
|
+
if (param.clamping.left !== 'extend') {
|
|
89
|
+
properties.push(b.objectProperty(b.identifier('extrapolateLeft'), b.stringLiteral(param.clamping.left)));
|
|
90
|
+
}
|
|
91
|
+
if (param.clamping.right !== 'extend') {
|
|
92
|
+
properties.push(b.objectProperty(b.identifier('extrapolateRight'), b.stringLiteral(param.clamping.right)));
|
|
93
|
+
}
|
|
94
|
+
if (keyframedParamNeedsEasingImport(param)) {
|
|
95
|
+
const easingLocalName = (_a = remotionLocalNames.Easing) !== null && _a !== void 0 ? _a : 'Easing';
|
|
96
|
+
properties.push(b.objectProperty(b.identifier('easing'), b.arrayExpression(param.easing.map((easing) => makeEasingExpression({ easing, easingLocalName })))));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (param.posterize !== undefined) {
|
|
100
|
+
properties.push(b.objectProperty(b.identifier('posterize'), (0, update_nested_prop_1.parseValueExpression)(param.posterize)));
|
|
101
|
+
}
|
|
102
|
+
if (properties.length === 0) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
return b.objectExpression(properties);
|
|
106
|
+
};
|
|
107
|
+
const makeKeyframedExpression = ({ param, remotionLocalNames, }) => {
|
|
108
|
+
var _a;
|
|
109
|
+
const expectedEasingCount = Math.max(0, param.keyframes.length - 1);
|
|
110
|
+
if (param.easing.length !== expectedEasingCount) {
|
|
111
|
+
throw new Error('Cannot paste keyframed effect: invalid easing metadata');
|
|
112
|
+
}
|
|
113
|
+
const calleeName = (_a = remotionLocalNames[param.interpolationFunction]) !== null && _a !== void 0 ? _a : param.interpolationFunction;
|
|
114
|
+
const args = [
|
|
115
|
+
b.identifier('frame'),
|
|
116
|
+
b.arrayExpression(param.keyframes.map((keyframe) => (0, update_nested_prop_1.parseValueExpression)(keyframe.frame))),
|
|
117
|
+
b.arrayExpression(param.keyframes.map((keyframe) => (0, update_nested_prop_1.parseValueExpression)(keyframe.value))),
|
|
118
|
+
];
|
|
119
|
+
const options = makeKeyframedOptions({ param, remotionLocalNames });
|
|
120
|
+
if (options) {
|
|
121
|
+
args.push(options);
|
|
122
|
+
}
|
|
123
|
+
return b.callExpression(b.identifier(calleeName), args);
|
|
124
|
+
};
|
|
125
|
+
const makeParamExpression = ({ param, remotionLocalNames, }) => {
|
|
126
|
+
if (param.type === 'static') {
|
|
127
|
+
return (0, update_nested_prop_1.parseValueExpression)(param.value);
|
|
128
|
+
}
|
|
129
|
+
return makeKeyframedExpression({ param, remotionLocalNames });
|
|
130
|
+
};
|
|
131
|
+
exports.makeParamExpression = makeParamExpression;
|
|
@@ -36,14 +36,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.pasteEffects = void 0;
|
|
37
37
|
const recast = __importStar(require("recast"));
|
|
38
38
|
const get_ast_node_path_1 = require("../helpers/get-ast-node-path");
|
|
39
|
-
const imports_1 = require("../helpers/imports");
|
|
40
39
|
const can_update_sequence_props_1 = require("../preview-server/routes/can-update-sequence-props");
|
|
41
40
|
const add_effect_1 = require("./add-effect");
|
|
41
|
+
const effect_param_expression_1 = require("./effect-param-expression");
|
|
42
42
|
const format_file_content_1 = require("./format-file-content");
|
|
43
43
|
const parse_ast_1 = require("./parse-ast");
|
|
44
44
|
const update_effect_props_1 = require("./update-effect-props/update-effect-props");
|
|
45
45
|
const ensure_imports_and_frame_hook_1 = require("./update-keyframes/ensure-imports-and-frame-hook");
|
|
46
|
-
const update_nested_prop_1 = require("./update-nested-prop");
|
|
47
46
|
const b = recast.types.builders;
|
|
48
47
|
const identifierRegex = /^[A-Za-z_$][0-9A-Za-z_$]*$/;
|
|
49
48
|
const getEffectsArray = (attr) => {
|
|
@@ -62,98 +61,12 @@ const makeEffectsAttr = (array) => {
|
|
|
62
61
|
const makeEffectsArray = (calls) => {
|
|
63
62
|
return b.arrayExpression(calls);
|
|
64
63
|
};
|
|
65
|
-
const isNonLinearEasing = (easing) => easing !== 'linear';
|
|
66
|
-
const keyframedParamNeedsEasingImport = (param) => {
|
|
67
|
-
return (param.interpolationFunction !== 'interpolateColors' &&
|
|
68
|
-
param.easing.some(isNonLinearEasing));
|
|
69
|
-
};
|
|
70
|
-
const getRequiredRemotionImports = (effects) => {
|
|
71
|
-
const requiredImports = new Set();
|
|
72
|
-
for (const effect of effects) {
|
|
73
|
-
for (const param of Object.values(effect.params)) {
|
|
74
|
-
if (param.type !== 'keyframed') {
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
requiredImports.add('useCurrentFrame');
|
|
78
|
-
requiredImports.add(param.interpolationFunction);
|
|
79
|
-
if (keyframedParamNeedsEasingImport(param)) {
|
|
80
|
-
requiredImports.add('Easing');
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return requiredImports;
|
|
85
|
-
};
|
|
86
|
-
const ensureRemotionImportLocalNames = ({ ast, requiredImports, }) => {
|
|
87
|
-
const localNames = {};
|
|
88
|
-
for (const importedName of requiredImports) {
|
|
89
|
-
localNames[importedName] = (0, imports_1.ensureNamedImport)({
|
|
90
|
-
ast,
|
|
91
|
-
importedName,
|
|
92
|
-
sourcePath: 'remotion',
|
|
93
|
-
localName: importedName,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
return localNames;
|
|
97
|
-
};
|
|
98
|
-
const makeEasingExpression = ({ easing, easingLocalName, }) => {
|
|
99
|
-
if (easing === 'linear') {
|
|
100
|
-
return b.memberExpression(b.identifier(easingLocalName), b.identifier('linear'));
|
|
101
|
-
}
|
|
102
|
-
return b.callExpression(b.memberExpression(b.identifier(easingLocalName), b.identifier('bezier')), easing.map((value) => (0, update_nested_prop_1.parseValueExpression)(value)));
|
|
103
|
-
};
|
|
104
|
-
const makeKeyframedOptions = ({ param, remotionLocalNames, }) => {
|
|
105
|
-
var _a;
|
|
106
|
-
const properties = [];
|
|
107
|
-
if (param.interpolationFunction !== 'interpolateColors') {
|
|
108
|
-
if (param.clamping.left !== 'extend') {
|
|
109
|
-
properties.push(b.objectProperty(b.identifier('extrapolateLeft'), b.stringLiteral(param.clamping.left)));
|
|
110
|
-
}
|
|
111
|
-
if (param.clamping.right !== 'extend') {
|
|
112
|
-
properties.push(b.objectProperty(b.identifier('extrapolateRight'), b.stringLiteral(param.clamping.right)));
|
|
113
|
-
}
|
|
114
|
-
if (keyframedParamNeedsEasingImport(param)) {
|
|
115
|
-
const easingLocalName = (_a = remotionLocalNames.Easing) !== null && _a !== void 0 ? _a : 'Easing';
|
|
116
|
-
properties.push(b.objectProperty(b.identifier('easing'), b.arrayExpression(param.easing.map((easing) => makeEasingExpression({ easing, easingLocalName })))));
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
if (param.posterize !== undefined) {
|
|
120
|
-
properties.push(b.objectProperty(b.identifier('posterize'), (0, update_nested_prop_1.parseValueExpression)(param.posterize)));
|
|
121
|
-
}
|
|
122
|
-
if (properties.length === 0) {
|
|
123
|
-
return null;
|
|
124
|
-
}
|
|
125
|
-
return b.objectExpression(properties);
|
|
126
|
-
};
|
|
127
|
-
const makeKeyframedExpression = ({ param, remotionLocalNames, }) => {
|
|
128
|
-
var _a;
|
|
129
|
-
const expectedEasingCount = Math.max(0, param.keyframes.length - 1);
|
|
130
|
-
if (param.easing.length !== expectedEasingCount) {
|
|
131
|
-
throw new Error('Cannot paste keyframed effect: invalid easing metadata');
|
|
132
|
-
}
|
|
133
|
-
const calleeName = (_a = remotionLocalNames[param.interpolationFunction]) !== null && _a !== void 0 ? _a : param.interpolationFunction;
|
|
134
|
-
const args = [
|
|
135
|
-
b.identifier('frame'),
|
|
136
|
-
b.arrayExpression(param.keyframes.map((keyframe) => (0, update_nested_prop_1.parseValueExpression)(keyframe.frame))),
|
|
137
|
-
b.arrayExpression(param.keyframes.map((keyframe) => (0, update_nested_prop_1.parseValueExpression)(keyframe.value))),
|
|
138
|
-
];
|
|
139
|
-
const options = makeKeyframedOptions({ param, remotionLocalNames });
|
|
140
|
-
if (options) {
|
|
141
|
-
args.push(options);
|
|
142
|
-
}
|
|
143
|
-
return b.callExpression(b.identifier(calleeName), args);
|
|
144
|
-
};
|
|
145
|
-
const makeParamExpression = ({ param, remotionLocalNames, }) => {
|
|
146
|
-
if (param.type === 'static') {
|
|
147
|
-
return (0, update_nested_prop_1.parseValueExpression)(param.value);
|
|
148
|
-
}
|
|
149
|
-
return makeKeyframedExpression({ param, remotionLocalNames });
|
|
150
|
-
};
|
|
151
64
|
const makeParamsObjectExpression = ({ params, remotionLocalNames, }) => {
|
|
152
65
|
return b.objectExpression(Object.entries(params).map(([key, param]) => {
|
|
153
66
|
const keyNode = identifierRegex.test(key)
|
|
154
67
|
? b.identifier(key)
|
|
155
68
|
: b.stringLiteral(key);
|
|
156
|
-
return b.objectProperty(keyNode, makeParamExpression({ param, remotionLocalNames }));
|
|
69
|
+
return b.objectProperty(keyNode, (0, effect_param_expression_1.makeParamExpression)({ param, remotionLocalNames }));
|
|
157
70
|
}));
|
|
158
71
|
};
|
|
159
72
|
const makeEffectCall = ({ ast, effect, remotionLocalNames, }) => {
|
|
@@ -188,8 +101,8 @@ const pasteEffects = async ({ input, targetSequenceNodePath, type, effects, pret
|
|
|
188
101
|
if (!targetJsx || !targetJsxPath) {
|
|
189
102
|
throw new Error('Could not find a JSX element at the specified location to paste effects');
|
|
190
103
|
}
|
|
191
|
-
const requiredRemotionImports = getRequiredRemotionImports(effects);
|
|
192
|
-
const remotionLocalNames = ensureRemotionImportLocalNames({
|
|
104
|
+
const requiredRemotionImports = (0, effect_param_expression_1.getRequiredRemotionImports)(effects);
|
|
105
|
+
const remotionLocalNames = (0, effect_param_expression_1.ensureRemotionImportLocalNames)({
|
|
193
106
|
ast,
|
|
194
107
|
requiredImports: requiredRemotionImports,
|
|
195
108
|
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ReorderSequencePosition } from '@remotion/studio-shared';
|
|
2
|
+
import type { SequenceNodePath } from 'remotion';
|
|
3
|
+
export declare const reorderSequence: ({ input, sourceNodePath, targetNodePath, position, prettierConfigOverride, }: {
|
|
4
|
+
input: string;
|
|
5
|
+
sourceNodePath: SequenceNodePath;
|
|
6
|
+
targetNodePath: SequenceNodePath;
|
|
7
|
+
position: ReorderSequencePosition;
|
|
8
|
+
prettierConfigOverride?: Record<string, unknown> | null | undefined;
|
|
9
|
+
}) => Promise<{
|
|
10
|
+
output: string;
|
|
11
|
+
formatted: boolean;
|
|
12
|
+
sequenceLabel: string;
|
|
13
|
+
logLine: number;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,109 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.reorderSequence = void 0;
|
|
37
|
+
const recast = __importStar(require("recast"));
|
|
38
|
+
const delete_jsx_node_1 = require("./delete-jsx-node");
|
|
39
|
+
const format_file_content_1 = require("./format-file-content");
|
|
40
|
+
const parse_ast_1 = require("./parse-ast");
|
|
41
|
+
const { namedTypes } = recast.types;
|
|
42
|
+
const getJsxChildrenParent = (path) => {
|
|
43
|
+
var _a;
|
|
44
|
+
const parent = (_a = path.parentPath) === null || _a === void 0 ? void 0 : _a.node;
|
|
45
|
+
if (!parent) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
if (namedTypes.JSXElement.check(parent)) {
|
|
49
|
+
return parent;
|
|
50
|
+
}
|
|
51
|
+
if (namedTypes.JSXFragment.check(parent)) {
|
|
52
|
+
return parent;
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
};
|
|
56
|
+
const reorderSequence = async ({ input, sourceNodePath, targetNodePath, position, prettierConfigOverride, }) => {
|
|
57
|
+
var _a, _b;
|
|
58
|
+
var _c, _d;
|
|
59
|
+
const ast = (0, parse_ast_1.parseAst)(input);
|
|
60
|
+
const sourcePath = (0, delete_jsx_node_1.findJsxElementPathForDeletion)(ast, sourceNodePath);
|
|
61
|
+
if (!sourcePath) {
|
|
62
|
+
throw new Error('Could not find a JSX element at the source location to reorder sequence');
|
|
63
|
+
}
|
|
64
|
+
const targetPath = (0, delete_jsx_node_1.findJsxElementPathForDeletion)(ast, targetNodePath);
|
|
65
|
+
if (!targetPath) {
|
|
66
|
+
throw new Error('Could not find a JSX element at the target location to reorder sequence');
|
|
67
|
+
}
|
|
68
|
+
const sourceParent = getJsxChildrenParent(sourcePath);
|
|
69
|
+
const targetParent = getJsxChildrenParent(targetPath);
|
|
70
|
+
if (!sourceParent || !targetParent || sourceParent !== targetParent) {
|
|
71
|
+
throw new Error('Cannot reorder sequence: source and target are not JSX siblings');
|
|
72
|
+
}
|
|
73
|
+
const sourceElement = sourcePath.node;
|
|
74
|
+
const targetElement = targetPath.node;
|
|
75
|
+
if (sourceElement === targetElement) {
|
|
76
|
+
throw new Error('Cannot reorder sequence: source and target are identical');
|
|
77
|
+
}
|
|
78
|
+
const { children } = sourceParent;
|
|
79
|
+
const sourceIndex = children.indexOf(sourceElement);
|
|
80
|
+
const targetIndex = children.indexOf(targetElement);
|
|
81
|
+
if (sourceIndex === -1 || targetIndex === -1) {
|
|
82
|
+
throw new Error('Cannot reorder sequence: JSX sibling was not found');
|
|
83
|
+
}
|
|
84
|
+
const sequenceLabel = (0, delete_jsx_node_1.getJsxElementTagLabel)(sourceElement);
|
|
85
|
+
const logLine = (_d = (_c = (_a = sourceElement.openingElement.loc) === null || _a === void 0 ? void 0 : _a.start.line) !== null && _c !== void 0 ? _c : (_b = sourceElement.loc) === null || _b === void 0 ? void 0 : _b.start.line) !== null && _d !== void 0 ? _d : 1;
|
|
86
|
+
const [moved] = children.splice(sourceIndex, 1);
|
|
87
|
+
if (!moved) {
|
|
88
|
+
throw new Error('Cannot reorder sequence: source sequence was not found');
|
|
89
|
+
}
|
|
90
|
+
const targetIndexAfterRemoval = children.indexOf(targetElement);
|
|
91
|
+
if (targetIndexAfterRemoval === -1) {
|
|
92
|
+
throw new Error('Cannot reorder sequence: target sequence was not found');
|
|
93
|
+
}
|
|
94
|
+
children.splice(position === 'before'
|
|
95
|
+
? targetIndexAfterRemoval
|
|
96
|
+
: targetIndexAfterRemoval + 1, 0, moved);
|
|
97
|
+
const finalFile = (0, parse_ast_1.serializeAst)(ast);
|
|
98
|
+
const { output, formatted } = await (0, format_file_content_1.formatFileContent)({
|
|
99
|
+
input: finalFile,
|
|
100
|
+
prettierConfigOverride,
|
|
101
|
+
});
|
|
102
|
+
return {
|
|
103
|
+
output,
|
|
104
|
+
formatted,
|
|
105
|
+
sequenceLabel,
|
|
106
|
+
logLine,
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
exports.reorderSequence = reorderSequence;
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import type { ArrayExpression, CallExpression, JSXAttribute } from '@babel/types';
|
|
2
|
+
import type { EffectClipboardParam } from '@remotion/studio-shared';
|
|
2
3
|
import type { SequenceNodePath, SequenceSchema } from 'remotion';
|
|
3
4
|
export type EffectPropUpdate = {
|
|
4
5
|
key: string;
|
|
5
6
|
value: unknown;
|
|
6
7
|
defaultValue: unknown | null;
|
|
8
|
+
} | {
|
|
9
|
+
key: string;
|
|
10
|
+
effectParam: EffectClipboardParam;
|
|
11
|
+
defaultValue: unknown | null;
|
|
7
12
|
};
|
|
8
13
|
export type UpdateEffectPropsResult = {
|
|
9
14
|
output: string;
|
|
10
15
|
formatted: boolean;
|
|
11
16
|
oldValueString: string;
|
|
17
|
+
newValueString: string;
|
|
12
18
|
logLine: number;
|
|
13
19
|
effectCallee: string;
|
|
14
20
|
removedProps: PropDelta[];
|
|
@@ -47,6 +53,7 @@ export declare const updateEffectPropsAst: ({ input, sequenceNodePath, effectInd
|
|
|
47
53
|
}) => {
|
|
48
54
|
serialized: string;
|
|
49
55
|
oldValueString: string;
|
|
56
|
+
newValueString: string;
|
|
50
57
|
logLine: number;
|
|
51
58
|
effectCallee: string;
|
|
52
59
|
removedProps: PropDelta[];
|
|
@@ -34,23 +34,16 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.updateEffectProps = exports.updateEffectPropsAst = exports.findEffectCallExpression = exports.enumerateEffectArrayElements = exports.findEffectsAttr = void 0;
|
|
37
|
-
const studio_shared_1 = require("@remotion/studio-shared");
|
|
38
37
|
const recast = __importStar(require("recast"));
|
|
39
38
|
const no_react_1 = require("remotion/no-react");
|
|
39
|
+
const get_ast_node_path_1 = require("../../helpers/get-ast-node-path");
|
|
40
40
|
const can_update_sequence_props_1 = require("../../preview-server/routes/can-update-sequence-props");
|
|
41
|
+
const effect_param_expression_1 = require("../effect-param-expression");
|
|
41
42
|
const format_file_content_1 = require("../format-file-content");
|
|
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");
|
|
43
46
|
const b = recast.types.builders;
|
|
44
|
-
const parseValueExpression = (value) => {
|
|
45
|
-
const code = `a = ${(0, studio_shared_1.stringifyDefaultProps)({ props: value, enumPaths: [] })}`;
|
|
46
|
-
const ast = (0, parse_ast_1.parseAst)(code);
|
|
47
|
-
const stmt = ast.program.body[0];
|
|
48
|
-
if (stmt.type !== 'ExpressionStatement' ||
|
|
49
|
-
stmt.expression.type !== 'AssignmentExpression') {
|
|
50
|
-
throw new Error('Failed to parse effect prop value expression');
|
|
51
|
-
}
|
|
52
|
-
return stmt.expression.right;
|
|
53
|
-
};
|
|
54
47
|
const findEffectsAttr = (attrs) => {
|
|
55
48
|
for (const attr of attrs) {
|
|
56
49
|
if (attr.type !== 'JSXAttribute') {
|
|
@@ -138,6 +131,47 @@ const printObjectPropertyValue = (prop) => recast
|
|
|
138
131
|
.code.replace(/[\n\r\t]+/g, ' ')
|
|
139
132
|
.replace(/,(\s*[}\]])/g, '$1')
|
|
140
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
|
+
};
|
|
141
175
|
const removeObjectProperty = ({ objExpr, propertyName, }) => {
|
|
142
176
|
const { propIndex, prop } = findObjectProperty(objExpr, propertyName);
|
|
143
177
|
if (!prop || propIndex === -1) {
|
|
@@ -170,7 +204,8 @@ const updateEffectPropsAst = ({ input, sequenceNodePath, effectIndex, update, sc
|
|
|
170
204
|
throw new Error(`Cannot update effect prop: ${found.reason}`);
|
|
171
205
|
}
|
|
172
206
|
const { call, callee: effectCallee } = found;
|
|
173
|
-
const isDefault = update
|
|
207
|
+
const isDefault = !updateHasEffectParam(update) &&
|
|
208
|
+
update.defaultValue !== null &&
|
|
174
209
|
JSON.stringify(update.value) === JSON.stringify(update.defaultValue);
|
|
175
210
|
let objExpr;
|
|
176
211
|
if (call.arguments.length === 0) {
|
|
@@ -178,6 +213,7 @@ const updateEffectPropsAst = ({ input, sequenceNodePath, effectIndex, update, sc
|
|
|
178
213
|
return {
|
|
179
214
|
serialized: (0, parse_ast_1.serializeAst)(ast),
|
|
180
215
|
oldValueString: '',
|
|
216
|
+
newValueString: JSON.stringify(update.defaultValue),
|
|
181
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,
|
|
182
218
|
effectCallee,
|
|
183
219
|
removedProps: [],
|
|
@@ -201,7 +237,9 @@ const updateEffectPropsAst = ({ input, sequenceNodePath, effectIndex, update, sc
|
|
|
201
237
|
else if (update.defaultValue !== null) {
|
|
202
238
|
oldValueString = JSON.stringify(update.defaultValue);
|
|
203
239
|
}
|
|
240
|
+
let newValueString = '';
|
|
204
241
|
if (isDefault) {
|
|
242
|
+
newValueString = JSON.stringify(update.defaultValue);
|
|
205
243
|
if (prop) {
|
|
206
244
|
const idx = objExpr.properties.indexOf(prop);
|
|
207
245
|
if (idx !== -1) {
|
|
@@ -210,7 +248,12 @@ const updateEffectPropsAst = ({ input, sequenceNodePath, effectIndex, update, sc
|
|
|
210
248
|
}
|
|
211
249
|
}
|
|
212
250
|
else {
|
|
213
|
-
const newValueExpr =
|
|
251
|
+
const newValueExpr = makeUpdateValueExpression({
|
|
252
|
+
ast,
|
|
253
|
+
sequenceNodePath,
|
|
254
|
+
update,
|
|
255
|
+
});
|
|
256
|
+
newValueString = recast.print(newValueExpr).code;
|
|
214
257
|
if (prop) {
|
|
215
258
|
prop.value = newValueExpr;
|
|
216
259
|
}
|
|
@@ -219,11 +262,14 @@ const updateEffectPropsAst = ({ input, sequenceNodePath, effectIndex, update, sc
|
|
|
219
262
|
}
|
|
220
263
|
}
|
|
221
264
|
const fieldSchema = schema[update.key];
|
|
222
|
-
|
|
265
|
+
const staticUpdateValue = getStaticUpdateValue(update);
|
|
266
|
+
if (fieldSchema &&
|
|
267
|
+
fieldSchema.type === 'enum' &&
|
|
268
|
+
staticUpdateValue !== null) {
|
|
223
269
|
const propsToDelete = no_react_1.NoReactInternals.findPropsToDelete({
|
|
224
270
|
schema,
|
|
225
271
|
key: update.key,
|
|
226
|
-
value:
|
|
272
|
+
value: staticUpdateValue,
|
|
227
273
|
});
|
|
228
274
|
for (const propToDelete of propsToDelete) {
|
|
229
275
|
const removed = removeObjectProperty({
|
|
@@ -239,6 +285,7 @@ const updateEffectPropsAst = ({ input, sequenceNodePath, effectIndex, update, sc
|
|
|
239
285
|
return {
|
|
240
286
|
serialized: (0, parse_ast_1.serializeAst)(ast),
|
|
241
287
|
oldValueString,
|
|
288
|
+
newValueString,
|
|
242
289
|
logLine,
|
|
243
290
|
effectCallee,
|
|
244
291
|
removedProps,
|
|
@@ -246,7 +293,7 @@ const updateEffectPropsAst = ({ input, sequenceNodePath, effectIndex, update, sc
|
|
|
246
293
|
};
|
|
247
294
|
exports.updateEffectPropsAst = updateEffectPropsAst;
|
|
248
295
|
const updateEffectProps = async ({ input, sequenceNodePath, effectIndex, update, schema, prettierConfigOverride, }) => {
|
|
249
|
-
const { serialized, oldValueString, logLine, effectCallee, removedProps } = (0, exports.updateEffectPropsAst)({
|
|
296
|
+
const { serialized, oldValueString, newValueString, logLine, effectCallee, removedProps, } = (0, exports.updateEffectPropsAst)({
|
|
250
297
|
input,
|
|
251
298
|
sequenceNodePath,
|
|
252
299
|
effectIndex,
|
|
@@ -260,6 +307,7 @@ const updateEffectProps = async ({ input, sequenceNodePath, effectIndex, update,
|
|
|
260
307
|
return {
|
|
261
308
|
output,
|
|
262
309
|
oldValueString,
|
|
310
|
+
newValueString,
|
|
263
311
|
formatted,
|
|
264
312
|
logLine,
|
|
265
313
|
effectCallee,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type KeyframeInterpolationFunction } from '@remotion/studio-shared';
|
|
2
|
-
import type { SequenceNodePath, SequenceSchema } from 'remotion';
|
|
2
|
+
import type { ExtrapolateType, SequenceNodePath, SequenceSchema } from 'remotion';
|
|
3
3
|
export type KeyframeOperation = {
|
|
4
4
|
type: 'add';
|
|
5
5
|
frame: number;
|
|
@@ -7,6 +7,19 @@ export type KeyframeOperation = {
|
|
|
7
7
|
} | {
|
|
8
8
|
type: 'remove';
|
|
9
9
|
frame: number;
|
|
10
|
+
} | {
|
|
11
|
+
type: 'settings';
|
|
12
|
+
clamping: {
|
|
13
|
+
left: ExtrapolateType;
|
|
14
|
+
right: ExtrapolateType;
|
|
15
|
+
} | undefined;
|
|
16
|
+
posterize: number | undefined;
|
|
17
|
+
} | {
|
|
18
|
+
type: 'move';
|
|
19
|
+
moves: {
|
|
20
|
+
fromFrame: number;
|
|
21
|
+
toFrame: number;
|
|
22
|
+
}[];
|
|
10
23
|
};
|
|
11
24
|
export type SequenceKeyframeUpdate = {
|
|
12
25
|
key: string;
|