@remotion/studio-server 4.0.523 → 4.0.525
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas-capture/generate-canvas-capture-composition.d.ts +1 -1
- package/dist/canvas-capture/generate-canvas-capture-composition.js +77 -12
- 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 +8 -1
- 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/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/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 -56
- 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 +1 -0
- package/dist/preview-server/routes/insert-element.js +150 -29
- 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/save-multiple-effect-props.js +1 -0
- package/dist/preview-server/routes/save-sequence-props.js +1 -0
- package/dist/preview-server/studio-protocol/handle-discovery.js +1 -1
- package/dist/preview-server/studio-protocol/handle-element-library.js +1 -1
- package/dist/preview-server/studio-protocol/handle-install.js +4 -3
- package/dist/preview-server/studio-protocol/handle-license-key.js +1 -1
- package/dist/preview-server/studio-protocol/origin-policy.d.ts +1 -1
- package/dist/preview-server/studio-protocol/origin-policy.js +13 -6
- 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/package.json +8 -8
- 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,92 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const parse_ast_1 = require("./parse-ast");
|
|
8
|
-
const update_effect_props_1 = require("./update-effect-props/update-effect-props");
|
|
9
|
-
const getEffectsArray = (attr) => {
|
|
10
|
-
if (!attr.value || attr.value.type !== 'JSXExpressionContainer') {
|
|
11
|
-
throw new Error('Cannot duplicate effect: effects prop is not an array');
|
|
12
|
-
}
|
|
13
|
-
const expr = attr.value.expression;
|
|
14
|
-
if (expr.type !== 'ArrayExpression') {
|
|
15
|
-
throw new Error('Cannot duplicate effect: effects prop is not an array');
|
|
16
|
-
}
|
|
17
|
-
return expr;
|
|
18
|
-
};
|
|
19
|
-
const duplicateEffects = async ({ input, effects, prettierConfigOverride, }) => {
|
|
20
|
-
var _a, _b;
|
|
21
|
-
var _c, _d, _e;
|
|
22
|
-
if (effects.length === 0) {
|
|
23
|
-
throw new Error('No effects were specified for duplication');
|
|
24
|
-
}
|
|
25
|
-
const ast = (0, parse_ast_1.parseAst)(input);
|
|
26
|
-
const duplicationsByAttr = new Map();
|
|
27
|
-
for (const effect of effects) {
|
|
28
|
-
const { sequenceNodePath, effectIndex } = effect;
|
|
29
|
-
const jsx = (0, can_update_sequence_props_1.findJsxElementAtNodePath)(ast, sequenceNodePath);
|
|
30
|
-
if (!jsx) {
|
|
31
|
-
throw new Error('Could not find a JSX element at the specified location to duplicate effect');
|
|
32
|
-
}
|
|
33
|
-
const attr = (0, update_effect_props_1.findEffectsAttr)((_c = jsx.attributes) !== null && _c !== void 0 ? _c : []);
|
|
34
|
-
if (!attr) {
|
|
35
|
-
throw new Error('Could not find effects on the target JSX element');
|
|
36
|
-
}
|
|
37
|
-
const effectsArray = getEffectsArray(attr);
|
|
38
|
-
const existingDuplication = duplicationsByAttr.get(attr);
|
|
39
|
-
const duplication = existingDuplication !== null && existingDuplication !== void 0 ? existingDuplication : {
|
|
40
|
-
effectsArray,
|
|
41
|
-
effectIndices: new Set(),
|
|
42
|
-
effectLabels: [],
|
|
43
|
-
logLines: [],
|
|
44
|
-
};
|
|
45
|
-
duplicationsByAttr.set(attr, duplication);
|
|
46
|
-
if (duplication.effectIndices.has(effectIndex)) {
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
const found = (0, update_effect_props_1.findEffectCallExpression)({ attr, effectIndex });
|
|
50
|
-
if (found.kind === 'error') {
|
|
51
|
-
throw new Error(`Cannot duplicate effect: ${found.reason}`);
|
|
52
|
-
}
|
|
53
|
-
duplication.effectIndices.add(effectIndex);
|
|
54
|
-
duplication.effectLabels.push(`${found.callee}()`);
|
|
55
|
-
duplication.logLines.push((_e = (_d = (_a = found.call.loc) === null || _a === void 0 ? void 0 : _a.start.line) !== null && _d !== void 0 ? _d : (_b = jsx.loc) === null || _b === void 0 ? void 0 : _b.start.line) !== null && _e !== void 0 ? _e : 1);
|
|
56
|
-
}
|
|
57
|
-
for (const duplication of duplicationsByAttr.values()) {
|
|
58
|
-
for (const effectIndex of [...duplication.effectIndices].sort((a, b) => b - a)) {
|
|
59
|
-
const effect = duplication.effectsArray.elements[effectIndex];
|
|
60
|
-
if (!effect || effect.type !== 'CallExpression') {
|
|
61
|
-
throw new Error('Cannot duplicate effect: not-call-expression');
|
|
62
|
-
}
|
|
63
|
-
duplication.effectsArray.elements.splice(effectIndex + 1, 0, (0, types_1.cloneNode)(effect, true));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
const finalFile = (0, parse_ast_1.serializeAst)(ast);
|
|
67
|
-
const { output, formatted } = await (0, format_file_content_1.formatFileContent)({
|
|
68
|
-
input: finalFile,
|
|
69
|
-
prettierConfigOverride,
|
|
70
|
-
});
|
|
71
|
-
return {
|
|
72
|
-
output,
|
|
73
|
-
formatted,
|
|
74
|
-
effectLabels: [...duplicationsByAttr.values()].flatMap((duplication) => duplication.effectLabels),
|
|
75
|
-
logLines: [...duplicationsByAttr.values()].flatMap((duplication) => duplication.logLines),
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
exports.duplicateEffects = duplicateEffects;
|
|
79
|
-
const duplicateEffect = async ({ input, sequenceNodePath, effectIndex, prettierConfigOverride, }) => {
|
|
80
|
-
const { output, formatted, effectLabels, logLines } = await (0, exports.duplicateEffects)({
|
|
81
|
-
input,
|
|
82
|
-
effects: [{ sequenceNodePath, effectIndex }],
|
|
83
|
-
prettierConfigOverride,
|
|
84
|
-
});
|
|
85
|
-
return {
|
|
86
|
-
output,
|
|
87
|
-
formatted,
|
|
88
|
-
effectLabel: effectLabels[0],
|
|
89
|
-
logLine: logLines[0],
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
exports.duplicateEffect = duplicateEffect;
|
|
3
|
+
exports.duplicateEffects = exports.duplicateEffect = void 0;
|
|
4
|
+
const studio_codemods_1 = require("@remotion/studio-codemods");
|
|
5
|
+
Object.defineProperty(exports, "duplicateEffect", { enumerable: true, get: function () { return studio_codemods_1.duplicateEffect; } });
|
|
6
|
+
Object.defineProperty(exports, "duplicateEffects", { enumerable: true, get: function () { return studio_codemods_1.duplicateEffects; } });
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export declare const pasteEffects: ({ input, targetSequenceNodePath, type, effects, insertAtIndices, prettierConfigOverride, }: {
|
|
4
|
-
readonly input: string;
|
|
1
|
+
import { pasteEffects as pasteEffectsCodemod } from '@remotion/studio-codemods';
|
|
2
|
+
type PasteEffectsInput = Parameters<typeof pasteEffectsCodemod>[0] & {
|
|
5
3
|
readonly targetFileName: string;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
readonly output: string;
|
|
13
|
-
readonly formatted: boolean;
|
|
14
|
-
readonly effectLabels: string[];
|
|
15
|
-
readonly logLine: number;
|
|
4
|
+
};
|
|
5
|
+
export declare const pasteEffects: (input: PasteEffectsInput) => Promise<{
|
|
6
|
+
output: string;
|
|
7
|
+
formatted: boolean;
|
|
8
|
+
effectLabels: string[];
|
|
9
|
+
logLine: number;
|
|
16
10
|
}>;
|
|
11
|
+
export {};
|
|
@@ -1,174 +1,6 @@
|
|
|
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
3
|
exports.pasteEffects = void 0;
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const can_update_sequence_props_1 = require("../preview-server/routes/can-update-sequence-props");
|
|
40
|
-
const add_effect_1 = require("./add-effect");
|
|
41
|
-
const effect_param_expression_1 = require("./effect-param-expression");
|
|
42
|
-
const format_file_content_1 = require("./format-file-content");
|
|
43
|
-
const parse_ast_1 = require("./parse-ast");
|
|
44
|
-
const update_effect_props_1 = require("./update-effect-props/update-effect-props");
|
|
45
|
-
const ensure_imports_and_frame_hook_1 = require("./update-keyframes/ensure-imports-and-frame-hook");
|
|
46
|
-
const b = recast.types.builders;
|
|
47
|
-
const identifierRegex = /^[A-Za-z_$][0-9A-Za-z_$]*$/;
|
|
48
|
-
const getEffectsArray = (attr) => {
|
|
49
|
-
if (!attr.value || attr.value.type !== 'JSXExpressionContainer') {
|
|
50
|
-
throw new Error('Cannot append effects: effects prop is not an array');
|
|
51
|
-
}
|
|
52
|
-
const expr = attr.value.expression;
|
|
53
|
-
if (expr.type !== 'ArrayExpression') {
|
|
54
|
-
throw new Error('Cannot append effects: effects prop is not an array');
|
|
55
|
-
}
|
|
56
|
-
return expr;
|
|
57
|
-
};
|
|
58
|
-
const makeEffectsAttr = (array) => {
|
|
59
|
-
return b.jsxAttribute(b.jsxIdentifier('effects'), b.jsxExpressionContainer(array));
|
|
60
|
-
};
|
|
61
|
-
const makeEffectsArray = (calls) => {
|
|
62
|
-
return b.arrayExpression(calls);
|
|
63
|
-
};
|
|
64
|
-
const makeParamsObjectExpression = ({ params, remotionLocalNames, }) => {
|
|
65
|
-
return b.objectExpression(Object.entries(params).map(([key, param]) => {
|
|
66
|
-
const keyNode = identifierRegex.test(key)
|
|
67
|
-
? b.identifier(key)
|
|
68
|
-
: b.stringLiteral(key);
|
|
69
|
-
return b.objectProperty(keyNode, (0, effect_param_expression_1.makeParamExpression)({ param, remotionLocalNames }));
|
|
70
|
-
}));
|
|
71
|
-
};
|
|
72
|
-
const makeEffectCall = ({ ast, effect, remotionLocalNames, }) => {
|
|
73
|
-
(0, add_effect_1.assertValidEffect)({
|
|
74
|
-
effectName: effect.callee,
|
|
75
|
-
effectImportPath: effect.importPath,
|
|
76
|
-
});
|
|
77
|
-
const localName = (0, add_effect_1.ensureEffectImport)({
|
|
78
|
-
ast,
|
|
79
|
-
effectName: effect.callee,
|
|
80
|
-
effectImportPath: effect.importPath,
|
|
81
|
-
});
|
|
82
|
-
return b.callExpression(b.identifier(localName), [
|
|
83
|
-
makeParamsObjectExpression({
|
|
84
|
-
params: effect.params,
|
|
85
|
-
remotionLocalNames,
|
|
86
|
-
}),
|
|
87
|
-
]);
|
|
88
|
-
};
|
|
89
|
-
const removeEffectsAttr = (attributes, attr) => {
|
|
90
|
-
const index = attributes.indexOf(attr);
|
|
91
|
-
if (index !== -1) {
|
|
92
|
-
attributes.splice(index, 1);
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
const pasteEffects = async ({ input, targetSequenceNodePath, type, effects, insertAtIndices, prettierConfigOverride, }) => {
|
|
96
|
-
var _a;
|
|
97
|
-
var _b, _c, _d;
|
|
98
|
-
const ast = (0, parse_ast_1.parseAst)(input);
|
|
99
|
-
const targetJsxPath = (0, get_ast_node_path_1.getAstNodePath)(ast, targetSequenceNodePath);
|
|
100
|
-
const targetJsx = (0, can_update_sequence_props_1.findJsxElementAtNodePath)(ast, targetSequenceNodePath);
|
|
101
|
-
if (!targetJsx || !targetJsxPath) {
|
|
102
|
-
throw new Error('Could not find a JSX element at the specified location to paste effects');
|
|
103
|
-
}
|
|
104
|
-
const requiredRemotionImports = (0, effect_param_expression_1.getRequiredRemotionImports)(effects);
|
|
105
|
-
const remotionLocalNames = (0, effect_param_expression_1.ensureRemotionImportLocalNames)({
|
|
106
|
-
ast,
|
|
107
|
-
requiredImports: requiredRemotionImports,
|
|
108
|
-
});
|
|
109
|
-
if (requiredRemotionImports.has('useCurrentFrame')) {
|
|
110
|
-
const fnPath = (0, ensure_imports_and_frame_hook_1.findEnclosingFunctionPath)(targetJsxPath);
|
|
111
|
-
if (fnPath) {
|
|
112
|
-
(0, ensure_imports_and_frame_hook_1.ensureUseCurrentFrameHook)(fnPath, (_b = remotionLocalNames.useCurrentFrame) !== null && _b !== void 0 ? _b : 'useCurrentFrame');
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
const effectCalls = effects.map((effect) => makeEffectCall({ ast, effect, remotionLocalNames }));
|
|
116
|
-
const effectLabels = effects.map((effect) => `${effect.callee}()`);
|
|
117
|
-
const existingAttr = (0, update_effect_props_1.findEffectsAttr)((_c = targetJsx.attributes) !== null && _c !== void 0 ? _c : []);
|
|
118
|
-
if (insertAtIndices !== null) {
|
|
119
|
-
if (type !== 'effects-additive' ||
|
|
120
|
-
insertAtIndices.length !== effectCalls.length ||
|
|
121
|
-
new Set(insertAtIndices).size !== insertAtIndices.length ||
|
|
122
|
-
insertAtIndices.some((index) => !Number.isInteger(index) || index < 0)) {
|
|
123
|
-
throw new Error('Cannot paste effects: invalid insertion indices');
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
if (type === 'effects-replacing') {
|
|
127
|
-
if (existingAttr) {
|
|
128
|
-
removeEffectsAttr(targetJsx.attributes, existingAttr);
|
|
129
|
-
}
|
|
130
|
-
if (effectCalls.length > 0) {
|
|
131
|
-
targetJsx.attributes.push(makeEffectsAttr(makeEffectsArray(effectCalls)));
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
else if (effectCalls.length === 0) {
|
|
135
|
-
throw new Error('Cannot paste effects: no effects were copied');
|
|
136
|
-
}
|
|
137
|
-
else if (insertAtIndices === null) {
|
|
138
|
-
if (existingAttr) {
|
|
139
|
-
getEffectsArray(existingAttr).elements.push(...effectCalls);
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
targetJsx.attributes.push(makeEffectsAttr(makeEffectsArray(effectCalls)));
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
const elements = existingAttr
|
|
147
|
-
? getEffectsArray(existingAttr).elements
|
|
148
|
-
: [];
|
|
149
|
-
const indexedCalls = effectCalls
|
|
150
|
-
.map((effect, index) => ({
|
|
151
|
-
effect,
|
|
152
|
-
index: insertAtIndices[index],
|
|
153
|
-
}))
|
|
154
|
-
.sort((left, right) => left.index - right.index);
|
|
155
|
-
for (const indexedCall of indexedCalls) {
|
|
156
|
-
elements.splice(Math.min(indexedCall.index, elements.length), 0, indexedCall.effect);
|
|
157
|
-
}
|
|
158
|
-
if (!existingAttr) {
|
|
159
|
-
targetJsx.attributes.push(makeEffectsAttr(b.arrayExpression(elements)));
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
const finalFile = (0, parse_ast_1.serializeAst)(ast);
|
|
163
|
-
const { output, formatted } = await (0, format_file_content_1.formatFileContent)({
|
|
164
|
-
input: finalFile,
|
|
165
|
-
prettierConfigOverride,
|
|
166
|
-
});
|
|
167
|
-
return {
|
|
168
|
-
output,
|
|
169
|
-
formatted,
|
|
170
|
-
effectLabels,
|
|
171
|
-
logLine: (_d = (_a = targetJsx.loc) === null || _a === void 0 ? void 0 : _a.start.line) !== null && _d !== void 0 ? _d : 1,
|
|
172
|
-
};
|
|
173
|
-
};
|
|
4
|
+
const studio_codemods_1 = require("@remotion/studio-codemods");
|
|
5
|
+
const pasteEffects = (input) => (0, studio_codemods_1.pasteEffects)(input);
|
|
174
6
|
exports.pasteEffects = pasteEffects;
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const reorderEffect: ({ input, sequenceNodePath, fromIndex, toIndex, prettierConfigOverride, }: {
|
|
3
|
-
input: string;
|
|
4
|
-
sequenceNodePath: SequenceNodePath;
|
|
5
|
-
fromIndex: number;
|
|
6
|
-
toIndex: number;
|
|
7
|
-
prettierConfigOverride?: Record<string, unknown> | null | undefined;
|
|
8
|
-
}) => Promise<{
|
|
9
|
-
output: string;
|
|
10
|
-
formatted: boolean;
|
|
11
|
-
effectLabel: string;
|
|
12
|
-
logLine: number;
|
|
13
|
-
}>;
|
|
1
|
+
export { reorderEffect } from '@remotion/studio-codemods';
|
|
@@ -1,61 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.reorderEffect = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
const parse_ast_1 = require("./parse-ast");
|
|
7
|
-
const update_effect_props_1 = require("./update-effect-props/update-effect-props");
|
|
8
|
-
const getEffectsArray = (attr) => {
|
|
9
|
-
if (!attr.value || attr.value.type !== 'JSXExpressionContainer') {
|
|
10
|
-
throw new Error('Cannot reorder effect: effects prop is not an array');
|
|
11
|
-
}
|
|
12
|
-
const expr = attr.value.expression;
|
|
13
|
-
if (expr.type !== 'ArrayExpression') {
|
|
14
|
-
throw new Error('Cannot reorder effect: effects prop is not an array');
|
|
15
|
-
}
|
|
16
|
-
return expr;
|
|
17
|
-
};
|
|
18
|
-
const reorderEffect = async ({ input, sequenceNodePath, fromIndex, toIndex, prettierConfigOverride, }) => {
|
|
19
|
-
var _a, _b;
|
|
20
|
-
var _c, _d, _e;
|
|
21
|
-
const ast = (0, parse_ast_1.parseAst)(input);
|
|
22
|
-
const jsx = (0, can_update_sequence_props_1.findJsxElementAtNodePath)(ast, sequenceNodePath);
|
|
23
|
-
if (!jsx) {
|
|
24
|
-
throw new Error('Could not find a JSX element at the specified location to reorder effect');
|
|
25
|
-
}
|
|
26
|
-
const attr = (0, update_effect_props_1.findEffectsAttr)((_c = jsx.attributes) !== null && _c !== void 0 ? _c : []);
|
|
27
|
-
if (!attr) {
|
|
28
|
-
throw new Error('Could not find effects on the target JSX element');
|
|
29
|
-
}
|
|
30
|
-
const effectsArray = getEffectsArray(attr);
|
|
31
|
-
const elements = (0, update_effect_props_1.enumerateEffectArrayElements)(effectsArray);
|
|
32
|
-
if (fromIndex < 0 || fromIndex >= elements.length) {
|
|
33
|
-
throw new Error('Cannot reorder effect: source index not-found');
|
|
34
|
-
}
|
|
35
|
-
if (toIndex < 0 || toIndex >= elements.length) {
|
|
36
|
-
throw new Error('Cannot reorder effect: target index not-found');
|
|
37
|
-
}
|
|
38
|
-
const target = elements[fromIndex];
|
|
39
|
-
if (target.kind !== 'call') {
|
|
40
|
-
throw new Error('Cannot reorder effect: source effect is not-call-expression');
|
|
41
|
-
}
|
|
42
|
-
if (fromIndex !== toIndex) {
|
|
43
|
-
const [moved] = effectsArray.elements.splice(fromIndex, 1);
|
|
44
|
-
if (!moved) {
|
|
45
|
-
throw new Error('Cannot reorder effect: source effect is not-call-expression');
|
|
46
|
-
}
|
|
47
|
-
effectsArray.elements.splice(toIndex, 0, moved);
|
|
48
|
-
}
|
|
49
|
-
const finalFile = (0, parse_ast_1.serializeAst)(ast);
|
|
50
|
-
const { output, formatted } = await (0, format_file_content_1.formatFileContent)({
|
|
51
|
-
input: finalFile,
|
|
52
|
-
prettierConfigOverride,
|
|
53
|
-
});
|
|
54
|
-
return {
|
|
55
|
-
output,
|
|
56
|
-
formatted,
|
|
57
|
-
effectLabel: `${target.callee}()`,
|
|
58
|
-
logLine: (_e = (_d = (_a = target.node.loc) === null || _a === void 0 ? void 0 : _a.start.line) !== null && _d !== void 0 ? _d : (_b = jsx.loc) === null || _b === void 0 ? void 0 : _b.start.line) !== null && _e !== void 0 ? _e : 1,
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
exports.reorderEffect = reorderEffect;
|
|
4
|
+
const studio_codemods_1 = require("@remotion/studio-codemods");
|
|
5
|
+
Object.defineProperty(exports, "reorderEffect", { enumerable: true, get: function () { return studio_codemods_1.reorderEffect; } });
|
|
@@ -1,68 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
import type { SequenceNodePath, InteractivitySchema } from 'remotion';
|
|
4
|
-
export type EffectPropUpdate = {
|
|
5
|
-
key: string;
|
|
6
|
-
value: unknown;
|
|
7
|
-
defaultValue: unknown | null;
|
|
8
|
-
} | {
|
|
9
|
-
key: string;
|
|
10
|
-
effectParam: EffectClipboardParam;
|
|
11
|
-
defaultValue: unknown | null;
|
|
12
|
-
};
|
|
13
|
-
export type UpdateEffectPropsResult = {
|
|
14
|
-
output: string;
|
|
15
|
-
formatted: boolean;
|
|
16
|
-
oldValueString: string;
|
|
17
|
-
newValueString: string;
|
|
18
|
-
logLine: number;
|
|
19
|
-
effectCallee: string;
|
|
20
|
-
removedProps: PropDelta[];
|
|
21
|
-
};
|
|
22
|
-
export type PropDelta = {
|
|
23
|
-
key: string;
|
|
24
|
-
valueString: string;
|
|
25
|
-
};
|
|
1
|
+
import type { JSXAttribute } from '@babel/types';
|
|
2
|
+
export { enumerateEffectArrayElements, findEffectCallExpression, type EffectArrayElement, type EffectPropUpdate, type PropDelta, type UpdateEffectPropsResult, updateEffectProps, updateEffectPropsAst, } from '@remotion/studio-codemods';
|
|
26
3
|
export declare const findEffectsAttr: (attrs: readonly unknown[]) => JSXAttribute | null;
|
|
27
|
-
export type EffectArrayElement = {
|
|
28
|
-
kind: 'call';
|
|
29
|
-
callee: string;
|
|
30
|
-
node: CallExpression;
|
|
31
|
-
} | {
|
|
32
|
-
kind: 'unsupported';
|
|
33
|
-
reason: 'not-call-expression' | 'spread';
|
|
34
|
-
};
|
|
35
|
-
export declare const enumerateEffectArrayElements: (arr: ArrayExpression) => EffectArrayElement[];
|
|
36
|
-
export declare const findEffectCallExpression: ({ attr, effectIndex, }: {
|
|
37
|
-
attr: JSXAttribute;
|
|
38
|
-
effectIndex: number;
|
|
39
|
-
}) => {
|
|
40
|
-
kind: "ok";
|
|
41
|
-
call: CallExpression;
|
|
42
|
-
callee: string;
|
|
43
|
-
} | {
|
|
44
|
-
kind: "error";
|
|
45
|
-
reason: "not-call-expression" | "not-found";
|
|
46
|
-
};
|
|
47
|
-
export declare const updateEffectPropsAst: ({ input, sequenceNodePath, effectIndex, update, schema, }: {
|
|
48
|
-
input: string;
|
|
49
|
-
sequenceNodePath: SequenceNodePath;
|
|
50
|
-
effectIndex: number;
|
|
51
|
-
update: EffectPropUpdate;
|
|
52
|
-
schema: InteractivitySchema;
|
|
53
|
-
}) => {
|
|
54
|
-
serialized: string;
|
|
55
|
-
oldValueString: string;
|
|
56
|
-
newValueString: string;
|
|
57
|
-
logLine: number;
|
|
58
|
-
effectCallee: string;
|
|
59
|
-
removedProps: PropDelta[];
|
|
60
|
-
};
|
|
61
|
-
export declare const updateEffectProps: ({ input, sequenceNodePath, effectIndex, update, schema, prettierConfigOverride, }: {
|
|
62
|
-
input: string;
|
|
63
|
-
sequenceNodePath: SequenceNodePath;
|
|
64
|
-
effectIndex: number;
|
|
65
|
-
update: EffectPropUpdate;
|
|
66
|
-
schema: InteractivitySchema;
|
|
67
|
-
prettierConfigOverride?: Record<string, unknown> | null | undefined;
|
|
68
|
-
}) => Promise<UpdateEffectPropsResult>;
|