@remotion/studio-server 4.0.524 → 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/codemods/add-effect.d.ts +1 -26
- package/dist/codemods/add-effect.js +6 -191
- 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 -55
- 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 +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/save-multiple-effect-props.js +1 -0
- package/dist/preview-server/routes/save-sequence-props.js +1 -0
- 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,26 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { SequenceNodePath } from 'remotion';
|
|
3
|
-
export declare const assertValidEffect: ({ effectName, effectImportPath, }: {
|
|
4
|
-
effectName: string;
|
|
5
|
-
effectImportPath: string;
|
|
6
|
-
}) => void;
|
|
7
|
-
export declare const ensureEffectImport: ({ ast, effectName, effectImportPath, }: {
|
|
8
|
-
ast: File;
|
|
9
|
-
effectName: string;
|
|
10
|
-
effectImportPath: string;
|
|
11
|
-
}) => string;
|
|
12
|
-
export declare const makeConfigObjectExpression: (config: Record<string, unknown>) => ObjectExpression;
|
|
13
|
-
export declare const addEffect: ({ input, sequenceNodePath, effectName, effectImportPath, effectConfig, prettierConfigOverride, }: {
|
|
14
|
-
input: string;
|
|
15
|
-
sequenceNodePath: SequenceNodePath;
|
|
16
|
-
effectName: string;
|
|
17
|
-
effectImportPath: string;
|
|
18
|
-
effectConfig: Record<string, unknown>;
|
|
19
|
-
prettierConfigOverride?: Record<string, unknown> | null | undefined;
|
|
20
|
-
}) => Promise<{
|
|
21
|
-
output: string;
|
|
22
|
-
formatted: boolean;
|
|
23
|
-
effectLabel: string;
|
|
24
|
-
nodeLabel: string;
|
|
25
|
-
logLine: number;
|
|
26
|
-
}>;
|
|
1
|
+
export { addEffect, assertValidEffect, ensureEffectImport, makeConfigObjectExpression, } from '@remotion/studio-codemods';
|
|
@@ -1,193 +1,8 @@
|
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const parse_ast_1 = require("./parse-ast");
|
|
43
|
-
const update_effect_props_1 = require("./update-effect-props/update-effect-props");
|
|
44
|
-
const b = recast.types.builders;
|
|
45
|
-
const identifierRegex = /^[A-Za-z_$][0-9A-Za-z_$]*$/;
|
|
46
|
-
const assertValidEffect = ({ effectName, effectImportPath, }) => {
|
|
47
|
-
if (!identifierRegex.test(effectName)) {
|
|
48
|
-
throw new Error(`Invalid effect name "${effectName}"`);
|
|
49
|
-
}
|
|
50
|
-
const allowedImport = effectImportPath.startsWith('@remotion/effects/') ||
|
|
51
|
-
effectImportPath === '@remotion/light-leaks' ||
|
|
52
|
-
effectImportPath === '@remotion/starburst';
|
|
53
|
-
if (!allowedImport) {
|
|
54
|
-
throw new Error(`Unsupported effect import "${effectImportPath}"`);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
exports.assertValidEffect = assertValidEffect;
|
|
58
|
-
const parseValueExpression = (value) => {
|
|
59
|
-
const code = `a = ${(0, studio_shared_1.stringifyDefaultProps)({ props: value, enumPaths: [] })}`;
|
|
60
|
-
const ast = (0, parse_ast_1.parseAst)(code);
|
|
61
|
-
const stmt = ast.program.body[0];
|
|
62
|
-
if (stmt.type !== 'ExpressionStatement' ||
|
|
63
|
-
stmt.expression.type !== 'AssignmentExpression') {
|
|
64
|
-
throw new Error('Failed to parse effect config value');
|
|
65
|
-
}
|
|
66
|
-
return stmt.expression.right;
|
|
67
|
-
};
|
|
68
|
-
const declarationBindsName = (declaration, name) => {
|
|
69
|
-
var _a, _b;
|
|
70
|
-
if (declaration.type === 'ClassDeclaration') {
|
|
71
|
-
return ((_a = declaration.id) === null || _a === void 0 ? void 0 : _a.name) === name;
|
|
72
|
-
}
|
|
73
|
-
if (declaration.type === 'FunctionDeclaration') {
|
|
74
|
-
return ((_b = declaration.id) === null || _b === void 0 ? void 0 : _b.name) === name;
|
|
75
|
-
}
|
|
76
|
-
return declaration.declarations.some((variableDeclaration) => {
|
|
77
|
-
return (variableDeclaration.id.type === 'Identifier' &&
|
|
78
|
-
variableDeclaration.id.name === name);
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
const hasTopLevelBinding = ({ ast, name }) => {
|
|
82
|
-
return ast.program.body.some((node) => {
|
|
83
|
-
var _a;
|
|
84
|
-
if (node.type === 'FunctionDeclaration' ||
|
|
85
|
-
node.type === 'ClassDeclaration' ||
|
|
86
|
-
node.type === 'VariableDeclaration') {
|
|
87
|
-
return declarationBindsName(node, name);
|
|
88
|
-
}
|
|
89
|
-
if (node.type === 'ExportNamedDeclaration' &&
|
|
90
|
-
node.declaration &&
|
|
91
|
-
(node.declaration.type === 'FunctionDeclaration' ||
|
|
92
|
-
node.declaration.type === 'ClassDeclaration' ||
|
|
93
|
-
node.declaration.type === 'VariableDeclaration')) {
|
|
94
|
-
return declarationBindsName(node.declaration, name);
|
|
95
|
-
}
|
|
96
|
-
if (node.type !== 'ImportDeclaration') {
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
return (_a = node.specifiers) === null || _a === void 0 ? void 0 : _a.some((specifier) => {
|
|
100
|
-
var _a;
|
|
101
|
-
return ((_a = specifier.local) === null || _a === void 0 ? void 0 : _a.name) === name;
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
};
|
|
105
|
-
const getAvailableLocalName = ({ ast, effectName, }) => {
|
|
106
|
-
if (!hasTopLevelBinding({ ast, name: effectName })) {
|
|
107
|
-
return effectName;
|
|
108
|
-
}
|
|
109
|
-
const base = `${effectName}Effect`;
|
|
110
|
-
if (!hasTopLevelBinding({ ast, name: base })) {
|
|
111
|
-
return base;
|
|
112
|
-
}
|
|
113
|
-
for (let i = 2; i < 100; i++) {
|
|
114
|
-
const candidate = `${base}${i}`;
|
|
115
|
-
if (!hasTopLevelBinding({ ast, name: candidate })) {
|
|
116
|
-
return candidate;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
throw new Error(`Cannot find a local name for ${effectName}`);
|
|
120
|
-
};
|
|
121
|
-
const ensureEffectImport = ({ ast, effectName, effectImportPath, }) => {
|
|
122
|
-
const localName = getAvailableLocalName({ ast, effectName });
|
|
123
|
-
return (0, imports_1.ensureNamedImport)({
|
|
124
|
-
ast,
|
|
125
|
-
importedName: effectName,
|
|
126
|
-
sourcePath: effectImportPath,
|
|
127
|
-
localName,
|
|
128
|
-
});
|
|
129
|
-
};
|
|
130
|
-
exports.ensureEffectImport = ensureEffectImport;
|
|
131
|
-
const getEffectsArray = (attr) => {
|
|
132
|
-
if (!attr.value || attr.value.type !== 'JSXExpressionContainer') {
|
|
133
|
-
throw new Error('Cannot add effect: effects prop is not an array');
|
|
134
|
-
}
|
|
135
|
-
const expr = attr.value.expression;
|
|
136
|
-
if (expr.type !== 'ArrayExpression') {
|
|
137
|
-
throw new Error('Cannot add effect: effects prop is not an array');
|
|
138
|
-
}
|
|
139
|
-
return expr;
|
|
140
|
-
};
|
|
141
|
-
const makeEffectsAttr = (array) => {
|
|
142
|
-
return b.jsxAttribute(b.jsxIdentifier('effects'), b.jsxExpressionContainer(array));
|
|
143
|
-
};
|
|
144
|
-
const makeConfigObjectExpression = (config) => {
|
|
145
|
-
return b.objectExpression(Object.entries(config).map(([key, value]) => {
|
|
146
|
-
const keyNode = identifierRegex.test(key)
|
|
147
|
-
? b.identifier(key)
|
|
148
|
-
: b.stringLiteral(key);
|
|
149
|
-
return b.objectProperty(keyNode, parseValueExpression(value));
|
|
150
|
-
}));
|
|
151
|
-
};
|
|
152
|
-
exports.makeConfigObjectExpression = makeConfigObjectExpression;
|
|
153
|
-
const getJsxTagLabel = (name) => {
|
|
154
|
-
if (name.type === 'JSXIdentifier') {
|
|
155
|
-
return `<${name.name}>`;
|
|
156
|
-
}
|
|
157
|
-
return 'element';
|
|
158
|
-
};
|
|
159
|
-
const addEffect = async ({ input, sequenceNodePath, effectName, effectImportPath, effectConfig, prettierConfigOverride, }) => {
|
|
160
|
-
var _a;
|
|
161
|
-
var _b, _c;
|
|
162
|
-
(0, exports.assertValidEffect)({ effectName, effectImportPath });
|
|
163
|
-
const ast = (0, parse_ast_1.parseAst)(input);
|
|
164
|
-
const jsx = (0, can_update_sequence_props_1.findJsxElementAtNodePath)(ast, sequenceNodePath);
|
|
165
|
-
if (!jsx) {
|
|
166
|
-
throw new Error('Could not find a JSX element at the specified location to add effect');
|
|
167
|
-
}
|
|
168
|
-
const localName = (0, exports.ensureEffectImport)({ ast, effectName, effectImportPath });
|
|
169
|
-
const effectCall = b.callExpression(b.identifier(localName), [
|
|
170
|
-
(0, exports.makeConfigObjectExpression)(effectConfig),
|
|
171
|
-
]);
|
|
172
|
-
const attr = (0, update_effect_props_1.findEffectsAttr)((_b = jsx.attributes) !== null && _b !== void 0 ? _b : []);
|
|
173
|
-
if (attr) {
|
|
174
|
-
getEffectsArray(attr).elements.push(effectCall);
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
const effectsArray = b.arrayExpression([effectCall]);
|
|
178
|
-
jsx.attributes.push(makeEffectsAttr(effectsArray));
|
|
179
|
-
}
|
|
180
|
-
const finalFile = (0, parse_ast_1.serializeAst)(ast);
|
|
181
|
-
const { output, formatted } = await (0, format_file_content_1.formatFileContent)({
|
|
182
|
-
input: finalFile,
|
|
183
|
-
prettierConfigOverride,
|
|
184
|
-
});
|
|
185
|
-
return {
|
|
186
|
-
output,
|
|
187
|
-
formatted,
|
|
188
|
-
effectLabel: `${effectName}()`,
|
|
189
|
-
nodeLabel: getJsxTagLabel(jsx.name),
|
|
190
|
-
logLine: (_c = (_a = jsx.loc) === null || _a === void 0 ? void 0 : _a.start.line) !== null && _c !== void 0 ? _c : 1,
|
|
191
|
-
};
|
|
192
|
-
};
|
|
193
|
-
exports.addEffect = addEffect;
|
|
3
|
+
exports.makeConfigObjectExpression = exports.ensureEffectImport = exports.assertValidEffect = exports.addEffect = void 0;
|
|
4
|
+
const studio_codemods_1 = require("@remotion/studio-codemods");
|
|
5
|
+
Object.defineProperty(exports, "addEffect", { enumerable: true, get: function () { return studio_codemods_1.addEffect; } });
|
|
6
|
+
Object.defineProperty(exports, "assertValidEffect", { enumerable: true, get: function () { return studio_codemods_1.assertValidEffect; } });
|
|
7
|
+
Object.defineProperty(exports, "ensureEffectImport", { enumerable: true, get: function () { return studio_codemods_1.ensureEffectImport; } });
|
|
8
|
+
Object.defineProperty(exports, "makeConfigObjectExpression", { enumerable: true, get: function () { return studio_codemods_1.makeConfigObjectExpression; } });
|
|
@@ -1,30 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export type EffectDeletionTarget = {
|
|
3
|
-
sequenceNodePath: SequenceNodePath;
|
|
4
|
-
} & ({
|
|
5
|
-
type: 'single-effect';
|
|
6
|
-
effectIndex: number;
|
|
7
|
-
} | {
|
|
8
|
-
type: 'all-effects';
|
|
9
|
-
});
|
|
10
|
-
export declare const deleteEffects: ({ input, effects, prettierConfigOverride, }: {
|
|
11
|
-
input: string;
|
|
12
|
-
effects: EffectDeletionTarget[];
|
|
13
|
-
prettierConfigOverride?: Record<string, unknown> | null | undefined;
|
|
14
|
-
}) => Promise<{
|
|
15
|
-
output: string;
|
|
16
|
-
formatted: boolean;
|
|
17
|
-
effectLabels: string[];
|
|
18
|
-
logLines: number[];
|
|
19
|
-
}>;
|
|
20
|
-
export declare const deleteEffect: ({ input, sequenceNodePath, effectIndex, prettierConfigOverride, }: {
|
|
21
|
-
input: string;
|
|
22
|
-
sequenceNodePath: SequenceNodePath;
|
|
23
|
-
effectIndex: number;
|
|
24
|
-
prettierConfigOverride?: Record<string, unknown> | null | undefined;
|
|
25
|
-
}) => Promise<{
|
|
26
|
-
output: string;
|
|
27
|
-
formatted: boolean;
|
|
28
|
-
effectLabel: string;
|
|
29
|
-
logLine: number;
|
|
30
|
-
}>;
|
|
1
|
+
export { deleteEffect, deleteEffects, type EffectDeletionTarget, } from '@remotion/studio-codemods';
|
|
@@ -1,128 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
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 delete effect: effects prop is not an array');
|
|
11
|
-
}
|
|
12
|
-
const expr = attr.value.expression;
|
|
13
|
-
if (expr.type !== 'ArrayExpression') {
|
|
14
|
-
throw new Error('Cannot delete effect: effects prop is not an array');
|
|
15
|
-
}
|
|
16
|
-
return expr;
|
|
17
|
-
};
|
|
18
|
-
const getAllEffectLabels = (effectsArray, attr) => {
|
|
19
|
-
if (effectsArray.elements.length === 0) {
|
|
20
|
-
throw new Error('Cannot delete effect: no effects found');
|
|
21
|
-
}
|
|
22
|
-
const elements = (0, update_effect_props_1.enumerateEffectArrayElements)(effectsArray);
|
|
23
|
-
return {
|
|
24
|
-
effectLabels: elements.map((effect) => effect.kind === 'call' ? `${effect.callee}()` : 'effect'),
|
|
25
|
-
logLines: elements.map((effect) => {
|
|
26
|
-
var _a, _b, _c;
|
|
27
|
-
var _d, _e, _f;
|
|
28
|
-
return effect.kind === 'call'
|
|
29
|
-
? ((_e = (_d = (_a = effect.node.loc) === null || _a === void 0 ? void 0 : _a.start.line) !== null && _d !== void 0 ? _d : (_b = attr.loc) === null || _b === void 0 ? void 0 : _b.start.line) !== null && _e !== void 0 ? _e : 1)
|
|
30
|
-
: ((_f = (_c = attr.loc) === null || _c === void 0 ? void 0 : _c.start.line) !== null && _f !== void 0 ? _f : 1);
|
|
31
|
-
}),
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
const deleteEffects = async ({ input, effects, prettierConfigOverride, }) => {
|
|
35
|
-
var _a, _b;
|
|
36
|
-
var _c, _d, _e;
|
|
37
|
-
if (effects.length === 0) {
|
|
38
|
-
throw new Error('No effects were specified for deletion');
|
|
39
|
-
}
|
|
40
|
-
const ast = (0, parse_ast_1.parseAst)(input);
|
|
41
|
-
const deletionsByAttr = new Map();
|
|
42
|
-
for (const effect of effects) {
|
|
43
|
-
const { sequenceNodePath } = effect;
|
|
44
|
-
const jsx = (0, can_update_sequence_props_1.findJsxElementAtNodePath)(ast, sequenceNodePath);
|
|
45
|
-
if (!jsx) {
|
|
46
|
-
throw new Error('Could not find a JSX element at the specified location to delete effect');
|
|
47
|
-
}
|
|
48
|
-
const attr = (0, update_effect_props_1.findEffectsAttr)((_c = jsx.attributes) !== null && _c !== void 0 ? _c : []);
|
|
49
|
-
if (!attr) {
|
|
50
|
-
throw new Error('Could not find effects on the target JSX element');
|
|
51
|
-
}
|
|
52
|
-
const effectsArray = getEffectsArray(attr);
|
|
53
|
-
const existingDeletion = deletionsByAttr.get(attr);
|
|
54
|
-
const deletion = existingDeletion !== null && existingDeletion !== void 0 ? existingDeletion : {
|
|
55
|
-
jsxAttributes: jsx.attributes,
|
|
56
|
-
attr,
|
|
57
|
-
effectsArray,
|
|
58
|
-
allEffects: false,
|
|
59
|
-
effectIndices: new Set(),
|
|
60
|
-
effectLabels: [],
|
|
61
|
-
logLines: [],
|
|
62
|
-
};
|
|
63
|
-
deletionsByAttr.set(attr, deletion);
|
|
64
|
-
if (effect.type === 'all-effects') {
|
|
65
|
-
const { effectLabels, logLines } = getAllEffectLabels(effectsArray, attr);
|
|
66
|
-
deletion.allEffects = true;
|
|
67
|
-
deletion.effectIndices.clear();
|
|
68
|
-
deletion.effectLabels = effectLabels;
|
|
69
|
-
deletion.logLines = logLines;
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
const { effectIndex } = effect;
|
|
73
|
-
if (deletion.allEffects || deletion.effectIndices.has(effectIndex)) {
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
const found = (0, update_effect_props_1.findEffectCallExpression)({ attr, effectIndex });
|
|
77
|
-
if (found.kind === 'error') {
|
|
78
|
-
throw new Error(`Cannot delete effect: ${found.reason}`);
|
|
79
|
-
}
|
|
80
|
-
deletion.effectIndices.add(effectIndex);
|
|
81
|
-
deletion.effectLabels.push(`${found.callee}()`);
|
|
82
|
-
deletion.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);
|
|
83
|
-
}
|
|
84
|
-
for (const deletion of deletionsByAttr.values()) {
|
|
85
|
-
if (deletion.allEffects) {
|
|
86
|
-
const attrIndex = deletion.jsxAttributes.indexOf(deletion.attr);
|
|
87
|
-
if (attrIndex !== -1) {
|
|
88
|
-
deletion.jsxAttributes.splice(attrIndex, 1);
|
|
89
|
-
}
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
for (const effectIndex of [...deletion.effectIndices].sort((a, b) => b - a)) {
|
|
93
|
-
deletion.effectsArray.elements.splice(effectIndex, 1);
|
|
94
|
-
}
|
|
95
|
-
if (deletion.effectsArray.elements.length === 0) {
|
|
96
|
-
const attrIndex = deletion.jsxAttributes.indexOf(deletion.attr);
|
|
97
|
-
if (attrIndex !== -1) {
|
|
98
|
-
deletion.jsxAttributes.splice(attrIndex, 1);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
const finalFile = (0, parse_ast_1.serializeAst)(ast);
|
|
103
|
-
const { output, formatted } = await (0, format_file_content_1.formatFileContent)({
|
|
104
|
-
input: finalFile,
|
|
105
|
-
prettierConfigOverride,
|
|
106
|
-
});
|
|
107
|
-
return {
|
|
108
|
-
output,
|
|
109
|
-
formatted,
|
|
110
|
-
effectLabels: [...deletionsByAttr.values()].flatMap((deletion) => deletion.effectLabels),
|
|
111
|
-
logLines: [...deletionsByAttr.values()].flatMap((deletion) => deletion.logLines),
|
|
112
|
-
};
|
|
113
|
-
};
|
|
114
|
-
exports.deleteEffects = deleteEffects;
|
|
115
|
-
const deleteEffect = async ({ input, sequenceNodePath, effectIndex, prettierConfigOverride, }) => {
|
|
116
|
-
const { output, formatted, effectLabels, logLines } = await (0, exports.deleteEffects)({
|
|
117
|
-
input,
|
|
118
|
-
effects: [{ type: 'single-effect', sequenceNodePath, effectIndex }],
|
|
119
|
-
prettierConfigOverride,
|
|
120
|
-
});
|
|
121
|
-
return {
|
|
122
|
-
output,
|
|
123
|
-
formatted,
|
|
124
|
-
effectLabel: effectLabels[0],
|
|
125
|
-
logLine: logLines[0],
|
|
126
|
-
};
|
|
127
|
-
};
|
|
128
|
-
exports.deleteEffect = deleteEffect;
|
|
3
|
+
exports.deleteEffects = exports.deleteEffect = void 0;
|
|
4
|
+
const studio_codemods_1 = require("@remotion/studio-codemods");
|
|
5
|
+
Object.defineProperty(exports, "deleteEffect", { enumerable: true, get: function () { return studio_codemods_1.deleteEffect; } });
|
|
6
|
+
Object.defineProperty(exports, "deleteEffects", { enumerable: true, get: function () { return studio_codemods_1.deleteEffects; } });
|
|
@@ -1,26 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export type EffectDuplicationTarget = {
|
|
3
|
-
sequenceNodePath: SequenceNodePath;
|
|
4
|
-
effectIndex: number;
|
|
5
|
-
};
|
|
6
|
-
export declare const duplicateEffects: ({ input, effects, prettierConfigOverride, }: {
|
|
7
|
-
input: string;
|
|
8
|
-
effects: EffectDuplicationTarget[];
|
|
9
|
-
prettierConfigOverride?: Record<string, unknown> | null | undefined;
|
|
10
|
-
}) => Promise<{
|
|
11
|
-
output: string;
|
|
12
|
-
formatted: boolean;
|
|
13
|
-
effectLabels: string[];
|
|
14
|
-
logLines: number[];
|
|
15
|
-
}>;
|
|
16
|
-
export declare const duplicateEffect: ({ input, sequenceNodePath, effectIndex, prettierConfigOverride, }: {
|
|
17
|
-
input: string;
|
|
18
|
-
sequenceNodePath: SequenceNodePath;
|
|
19
|
-
effectIndex: number;
|
|
20
|
-
prettierConfigOverride?: Record<string, unknown> | null | undefined;
|
|
21
|
-
}) => Promise<{
|
|
22
|
-
output: string;
|
|
23
|
-
formatted: boolean;
|
|
24
|
-
effectLabel: string;
|
|
25
|
-
logLine: number;
|
|
26
|
-
}>;
|
|
1
|
+
export { duplicateEffect, duplicateEffects, type EffectTarget as EffectDuplicationTarget, } from '@remotion/studio-codemods';
|
|
@@ -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 {};
|