@remotion/studio-server 4.0.469 → 4.0.471

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.
Files changed (68) hide show
  1. package/dist/codemods/add-effect.d.ts +15 -0
  2. package/dist/codemods/add-effect.js +231 -0
  3. package/dist/codemods/delete-effect.d.ts +18 -0
  4. package/dist/codemods/delete-effect.js +95 -21
  5. package/dist/codemods/delete-jsx-node.d.ts +10 -0
  6. package/dist/codemods/delete-jsx-node.js +38 -14
  7. package/dist/codemods/reorder-effect.d.ts +13 -0
  8. package/dist/codemods/reorder-effect.js +61 -0
  9. package/dist/codemods/update-keyframes/ensure-imports-and-frame-hook.d.ts +4 -0
  10. package/dist/codemods/update-keyframes/ensure-imports-and-frame-hook.js +152 -0
  11. package/dist/codemods/update-keyframes/update-keyframes.d.ts +12 -0
  12. package/dist/codemods/update-keyframes/update-keyframes.js +116 -31
  13. package/dist/codemods/update-sequence-props/update-sequence-props.d.ts +32 -10
  14. package/dist/codemods/update-sequence-props/update-sequence-props.js +39 -7
  15. package/dist/helpers/open-in-editor.d.ts +2 -2
  16. package/dist/helpers/open-in-editor.js +35 -2
  17. package/dist/helpers/resolve-composition-component.d.ts +15 -0
  18. package/dist/helpers/resolve-composition-component.js +269 -31
  19. package/dist/index.d.ts +2 -1
  20. package/dist/preview-server/api-routes.js +20 -0
  21. package/dist/preview-server/routes/add-effect-keyframe.d.ts +3 -0
  22. package/dist/preview-server/routes/add-effect-keyframe.js +91 -0
  23. package/dist/preview-server/routes/add-effect.d.ts +3 -0
  24. package/dist/preview-server/routes/add-effect.js +68 -0
  25. package/dist/preview-server/routes/add-sequence-keyframe.d.ts +3 -0
  26. package/dist/preview-server/routes/add-sequence-keyframe.js +87 -0
  27. package/dist/preview-server/routes/apply-codemod.js +1 -0
  28. package/dist/preview-server/routes/apply-visual-control-change.js +1 -0
  29. package/dist/preview-server/routes/can-update-sequence-props.d.ts +1 -0
  30. package/dist/preview-server/routes/can-update-sequence-props.js +48 -14
  31. package/dist/preview-server/routes/composition-component-info.d.ts +3 -0
  32. package/dist/preview-server/routes/composition-component-info.js +26 -0
  33. package/dist/preview-server/routes/delete-effect-keyframe.d.ts +3 -0
  34. package/dist/preview-server/routes/delete-effect-keyframe.js +89 -0
  35. package/dist/preview-server/routes/delete-effect.js +76 -37
  36. package/dist/preview-server/routes/delete-jsx-node.js +67 -36
  37. package/dist/preview-server/routes/delete-keyframes.d.ts +13 -0
  38. package/dist/preview-server/routes/delete-keyframes.js +263 -0
  39. package/dist/preview-server/routes/delete-sequence-keyframe.d.ts +3 -0
  40. package/dist/preview-server/routes/delete-sequence-keyframe.js +82 -0
  41. package/dist/preview-server/routes/duplicate-jsx-node.js +1 -0
  42. package/dist/preview-server/routes/insert-jsx-element.d.ts +3 -0
  43. package/dist/preview-server/routes/insert-jsx-element.js +79 -0
  44. package/dist/preview-server/routes/open-in-editor.d.ts +4 -0
  45. package/dist/preview-server/routes/open-in-editor.js +40 -0
  46. package/dist/preview-server/routes/register-client-render.d.ts +3 -0
  47. package/dist/preview-server/routes/register-client-render.js +11 -0
  48. package/dist/preview-server/routes/reorder-effect.d.ts +3 -0
  49. package/dist/preview-server/routes/reorder-effect.js +67 -0
  50. package/dist/preview-server/routes/save-effect-props.js +1 -0
  51. package/dist/preview-server/routes/save-sequence-props.js +158 -72
  52. package/dist/preview-server/routes/subscribe-to-sequence-props.js +2 -1
  53. package/dist/preview-server/routes/unregister-client-render.d.ts +4 -0
  54. package/dist/preview-server/routes/unregister-client-render.js +11 -0
  55. package/dist/preview-server/routes/update-default-props.js +1 -0
  56. package/dist/preview-server/sequence-props-watchers.d.ts +2 -1
  57. package/dist/preview-server/sequence-props-watchers.js +22 -2
  58. package/dist/preview-server/start-server.d.ts +1 -0
  59. package/dist/preview-server/start-server.js +1 -0
  60. package/dist/preview-server/undo-stack.d.ts +35 -4
  61. package/dist/preview-server/undo-stack.js +130 -42
  62. package/dist/preview-server/validate-same-origin.d.ts +2 -0
  63. package/dist/preview-server/validate-same-origin.js +13 -0
  64. package/dist/routes.d.ts +2 -1
  65. package/dist/routes.js +9 -136
  66. package/dist/start-studio.d.ts +2 -1
  67. package/dist/start-studio.js +2 -1
  68. package/package.json +6 -6
@@ -0,0 +1,152 @@
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.ensureUseCurrentFrameHook = exports.ensureRemotionImports = exports.findEnclosingFunctionPath = void 0;
37
+ const recast = __importStar(require("recast"));
38
+ const b = recast.types.builders;
39
+ const n = recast.types.namedTypes;
40
+ const isFunctionNode = (value) => {
41
+ return (n.FunctionDeclaration.check(value) ||
42
+ n.FunctionExpression.check(value) ||
43
+ n.ArrowFunctionExpression.check(value));
44
+ };
45
+ const findEnclosingFunctionPath = (path) => {
46
+ let current = path.parentPath;
47
+ while (current) {
48
+ if (isFunctionNode(current.value)) {
49
+ return current;
50
+ }
51
+ current = current.parentPath;
52
+ }
53
+ return null;
54
+ };
55
+ exports.findEnclosingFunctionPath = findEnclosingFunctionPath;
56
+ const findRemotionImport = (ast) => {
57
+ for (const stmt of ast.program.body) {
58
+ if (stmt.type === 'ImportDeclaration' &&
59
+ stmt.source.type === 'StringLiteral' &&
60
+ stmt.source.value === 'remotion') {
61
+ return stmt;
62
+ }
63
+ }
64
+ return null;
65
+ };
66
+ const insertImportDeclaration = (ast, importDecl) => {
67
+ const { body } = ast.program;
68
+ let lastImportIndex = -1;
69
+ for (let i = 0; i < body.length; i++) {
70
+ if (body[i].type === 'ImportDeclaration') {
71
+ lastImportIndex = i;
72
+ }
73
+ }
74
+ body.splice(lastImportIndex + 1, 0, importDecl);
75
+ };
76
+ const ensureRemotionImports = (ast, names) => {
77
+ var _a, _b;
78
+ if (names.size === 0) {
79
+ return;
80
+ }
81
+ let remotionImport = findRemotionImport(ast);
82
+ if (!remotionImport) {
83
+ remotionImport = b.importDeclaration([], b.stringLiteral('remotion'));
84
+ insertImportDeclaration(ast, remotionImport);
85
+ }
86
+ const existingNames = new Set();
87
+ for (const specifier of (_a = remotionImport.specifiers) !== null && _a !== void 0 ? _a : []) {
88
+ if (specifier.type !== 'ImportSpecifier') {
89
+ continue;
90
+ }
91
+ const { imported } = specifier;
92
+ if (imported.type === 'Identifier') {
93
+ existingNames.add(imported.name);
94
+ }
95
+ else if (imported.type === 'StringLiteral') {
96
+ existingNames.add(imported.value);
97
+ }
98
+ }
99
+ for (const name of names) {
100
+ if (existingNames.has(name)) {
101
+ continue;
102
+ }
103
+ remotionImport.specifiers = (_b = remotionImport.specifiers) !== null && _b !== void 0 ? _b : [];
104
+ remotionImport.specifiers.push(b.importSpecifier(b.identifier(name)));
105
+ existingNames.add(name);
106
+ }
107
+ };
108
+ exports.ensureRemotionImports = ensureRemotionImports;
109
+ const componentBodyHasFrameDeclaration = (body) => {
110
+ if (!n.BlockStatement.check(body)) {
111
+ return false;
112
+ }
113
+ for (const stmt of body.body) {
114
+ if (stmt.type !== 'VariableDeclaration') {
115
+ continue;
116
+ }
117
+ for (const decl of stmt.declarations) {
118
+ if (decl.type !== 'VariableDeclarator') {
119
+ continue;
120
+ }
121
+ if (decl.id.type === 'Identifier' &&
122
+ decl.id.name === 'frame' &&
123
+ decl.init &&
124
+ decl.init.type === 'CallExpression' &&
125
+ decl.init.callee.type === 'Identifier' &&
126
+ decl.init.callee.name === 'useCurrentFrame') {
127
+ return true;
128
+ }
129
+ }
130
+ }
131
+ return false;
132
+ };
133
+ const ensureUseCurrentFrameHook = (functionPath) => {
134
+ const fn = functionPath.value;
135
+ if (!n.BlockStatement.check(fn.body)) {
136
+ // Arrow function with expression body: wrap the expression in a block so
137
+ // we can prepend the hook call before returning the original expression.
138
+ const expression = fn.body;
139
+ fn.body = b.blockStatement([
140
+ b.returnStatement(expression),
141
+ ]);
142
+ }
143
+ if (componentBodyHasFrameDeclaration(fn.body)) {
144
+ return;
145
+ }
146
+ const block = fn.body;
147
+ const frameDecl = b.variableDeclaration('const', [
148
+ b.variableDeclarator(b.identifier('frame'), b.callExpression(b.identifier('useCurrentFrame'), [])),
149
+ ]);
150
+ block.body.unshift(frameDecl);
151
+ };
152
+ exports.ensureUseCurrentFrameHook = ensureUseCurrentFrameHook;
@@ -15,6 +15,10 @@ export type EffectKeyframeUpdate = {
15
15
  key: string;
16
16
  operation: KeyframeOperation;
17
17
  };
18
+ export type IntroducedKeyframeIdentifiers = {
19
+ calleeName: 'interpolate' | 'interpolateColors' | null;
20
+ needsFrameHook: boolean;
21
+ };
18
22
  export declare const updateSequenceKeyframesAst: ({ input, nodePath, updates, }: {
19
23
  input: string;
20
24
  nodePath: SequenceNodePath;
@@ -22,7 +26,9 @@ export declare const updateSequenceKeyframesAst: ({ input, nodePath, updates, }:
22
26
  }) => {
23
27
  serialized: string;
24
28
  oldValueStrings: string[];
29
+ newValueStrings: string[];
25
30
  logLine: number;
31
+ updatedNodePath: SequenceNodePath;
26
32
  };
27
33
  export declare const updateSequenceKeyframes: ({ input, nodePath, updates, prettierConfigOverride, }: {
28
34
  input: string;
@@ -33,7 +39,9 @@ export declare const updateSequenceKeyframes: ({ input, nodePath, updates, prett
33
39
  output: string;
34
40
  formatted: boolean;
35
41
  oldValueStrings: string[];
42
+ newValueStrings: string[];
36
43
  logLine: number;
44
+ updatedNodePath: SequenceNodePath;
37
45
  }>;
38
46
  export declare const updateEffectKeyframesAst: ({ input, sequenceNodePath, effectIndex, updates, }: {
39
47
  input: string;
@@ -43,8 +51,10 @@ export declare const updateEffectKeyframesAst: ({ input, sequenceNodePath, effec
43
51
  }) => {
44
52
  serialized: string;
45
53
  oldValueStrings: string[];
54
+ newValueStrings: string[];
46
55
  logLine: number;
47
56
  effectCallee: string;
57
+ updatedSequenceNodePath: SequenceNodePath;
48
58
  };
49
59
  export declare const updateEffectKeyframes: ({ input, sequenceNodePath, effectIndex, updates, prettierConfigOverride, }: {
50
60
  input: string;
@@ -56,6 +66,8 @@ export declare const updateEffectKeyframes: ({ input, sequenceNodePath, effectIn
56
66
  output: string;
57
67
  formatted: boolean;
58
68
  oldValueStrings: string[];
69
+ newValueStrings: string[];
59
70
  logLine: number;
60
71
  effectCallee: string;
72
+ updatedSequenceNodePath: SequenceNodePath;
61
73
  }>;
@@ -35,11 +35,13 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.updateEffectKeyframes = exports.updateEffectKeyframesAst = exports.updateSequenceKeyframes = exports.updateSequenceKeyframesAst = void 0;
37
37
  const recast = __importStar(require("recast"));
38
+ const get_ast_node_path_1 = require("../../helpers/get-ast-node-path");
38
39
  const can_update_sequence_props_1 = require("../../preview-server/routes/can-update-sequence-props");
39
40
  const format_file_content_1 = require("../format-file-content");
40
41
  const parse_ast_1 = require("../parse-ast");
41
42
  const update_effect_props_1 = require("../update-effect-props/update-effect-props");
42
43
  const update_nested_prop_1 = require("../update-nested-prop");
44
+ const ensure_imports_and_frame_hook_1 = require("./ensure-imports-and-frame-hook");
43
45
  const b = recast.types.builders;
44
46
  const getSupportedCallArgument = (arg) => {
45
47
  if (arg === undefined ||
@@ -139,6 +141,10 @@ const createInterpolateExpression = ({ callee, input, extraArgs, keyframes, }) =
139
141
  ...extraArgs,
140
142
  ]);
141
143
  };
144
+ const noIntroducedIdentifiers = {
145
+ calleeName: null,
146
+ needsFrameHook: false,
147
+ };
142
148
  const addKeyframe = ({ expression, frame, value, }) => {
143
149
  const existing = getInterpolationExpression(expression);
144
150
  const newOutput = (0, update_nested_prop_1.parseValueExpression)(value);
@@ -149,33 +155,39 @@ const addKeyframe = ({ expression, frame, value, }) => {
149
155
  : existing.keyframes.map((keyframe, index) => index === existingIndex
150
156
  ? { frame, output: newOutput, value }
151
157
  : keyframe);
152
- return createInterpolateExpression({
153
- callee: existing.callee,
154
- input: existing.input,
155
- extraArgs: existing.extraArgs,
156
- keyframes: nextKeyframes,
157
- });
158
+ return {
159
+ expression: createInterpolateExpression({
160
+ callee: existing.callee,
161
+ input: existing.input,
162
+ extraArgs: existing.extraArgs,
163
+ keyframes: nextKeyframes,
164
+ }),
165
+ introduced: noIntroducedIdentifiers,
166
+ };
158
167
  }
159
168
  if (!(0, can_update_sequence_props_1.isStaticValue)(expression)) {
160
169
  throw new Error('Cannot add keyframe to computed expression');
161
170
  }
162
171
  const staticValue = (0, can_update_sequence_props_1.extractStaticValue)(expression);
163
- const staticOutput = (0, update_nested_prop_1.parseValueExpression)(staticValue);
164
- const keyframes = frame === 0
165
- ? [{ frame, output: newOutput, value }]
166
- : [
167
- { frame: 0, output: staticOutput, value: staticValue },
168
- { frame, output: newOutput, value },
169
- ];
170
- return createInterpolateExpression({
171
- callee: getInterpolationCalleeForValues({
172
- staticValue,
173
- newValue: value,
174
- }),
175
- input: b.identifier('frame'),
176
- extraArgs: [],
177
- keyframes,
172
+ const keyframes = [{ frame, output: newOutput, value }];
173
+ const callee = getInterpolationCalleeForValues({
174
+ staticValue,
175
+ newValue: value,
178
176
  });
177
+ return {
178
+ expression: createInterpolateExpression({
179
+ callee,
180
+ input: b.identifier('frame'),
181
+ extraArgs: [],
182
+ keyframes,
183
+ }),
184
+ introduced: {
185
+ calleeName: callee.type === 'Identifier'
186
+ ? callee.name
187
+ : null,
188
+ needsFrameHook: true,
189
+ },
190
+ };
179
191
  };
180
192
  const removeKeyframe = ({ expression, frame, }) => {
181
193
  const existing = getInterpolationExpression(expression);
@@ -187,6 +199,9 @@ const removeKeyframe = ({ expression, frame, }) => {
187
199
  throw new Error(`Cannot remove keyframe at frame ${frame}: not found`);
188
200
  }
189
201
  const nextKeyframes = existing.keyframes.filter((_keyframe, index) => index !== keyframeIndex);
202
+ if (nextKeyframes.length === 0) {
203
+ return existing.keyframes[keyframeIndex].output;
204
+ }
190
205
  return createInterpolateExpression({
191
206
  callee: existing.callee,
192
207
  input: existing.input,
@@ -202,7 +217,10 @@ const applyKeyframeOperation = ({ expression, operation, }) => {
202
217
  value: operation.value,
203
218
  });
204
219
  }
205
- return removeKeyframe({ expression, frame: operation.frame });
220
+ return {
221
+ expression: removeKeyframe({ expression, frame: operation.frame }),
222
+ introduced: noIntroducedIdentifiers,
223
+ };
206
224
  };
207
225
  const getExpressionFromJsxAttribute = (attr) => {
208
226
  if (!attr.value) {
@@ -301,34 +319,60 @@ const updateSequenceKeyframesAst = ({ input, nodePath, updates, }) => {
301
319
  var _a;
302
320
  var _b;
303
321
  const ast = (0, parse_ast_1.parseAst)(input);
322
+ const jsxPath = (0, get_ast_node_path_1.getAstNodePath)(ast, nodePath);
304
323
  const node = (0, can_update_sequence_props_1.findJsxElementAtNodePath)(ast, nodePath);
305
- if (!node) {
324
+ if (!node || !jsxPath) {
306
325
  throw new Error('Could not find a JSX element at the specified location to update keyframes');
307
326
  }
308
327
  if (!node.attributes) {
309
328
  node.attributes = [];
310
329
  }
330
+ const requiredImports = new Set();
331
+ let needsFrameHook = false;
311
332
  const oldValueStrings = [];
333
+ const newValueStrings = [];
312
334
  for (const update of updates) {
313
335
  const prop = getSequenceWritableProp({
314
336
  attributes: node.attributes,
315
337
  key: update.key,
316
338
  });
317
339
  oldValueStrings.push(recast.print(prop.expression).code);
318
- prop.setExpression(applyKeyframeOperation({
340
+ const { expression: nextExpression, introduced } = applyKeyframeOperation({
319
341
  expression: prop.expression,
320
342
  operation: update.operation,
321
- }));
343
+ });
344
+ newValueStrings.push(recast.print(nextExpression).code);
345
+ prop.setExpression(nextExpression);
346
+ if (introduced.calleeName) {
347
+ requiredImports.add(introduced.calleeName);
348
+ }
349
+ if (introduced.needsFrameHook) {
350
+ requiredImports.add('useCurrentFrame');
351
+ needsFrameHook = true;
352
+ }
353
+ }
354
+ if (needsFrameHook) {
355
+ const fnPath = (0, ensure_imports_and_frame_hook_1.findEnclosingFunctionPath)(jsxPath);
356
+ if (fnPath) {
357
+ (0, ensure_imports_and_frame_hook_1.ensureUseCurrentFrameHook)(fnPath);
358
+ }
359
+ }
360
+ (0, ensure_imports_and_frame_hook_1.ensureRemotionImports)(ast, requiredImports);
361
+ const updatedNodePath = (0, can_update_sequence_props_1.findNodePathForJsxElement)(ast, node);
362
+ if (!updatedNodePath) {
363
+ throw new Error('Could not find updated JSX element location after updating keyframes');
322
364
  }
323
365
  return {
324
366
  serialized: (0, parse_ast_1.serializeAst)(ast),
325
367
  oldValueStrings,
368
+ newValueStrings,
326
369
  logLine: (_b = (_a = node.loc) === null || _a === void 0 ? void 0 : _a.start.line) !== null && _b !== void 0 ? _b : 1,
370
+ updatedNodePath,
327
371
  };
328
372
  };
329
373
  exports.updateSequenceKeyframesAst = updateSequenceKeyframesAst;
330
374
  const updateSequenceKeyframes = async ({ input, nodePath, updates, prettierConfigOverride, }) => {
331
- const { serialized, oldValueStrings, logLine } = (0, exports.updateSequenceKeyframesAst)({
375
+ const { serialized, oldValueStrings, newValueStrings, logLine, updatedNodePath, } = (0, exports.updateSequenceKeyframesAst)({
332
376
  input,
333
377
  nodePath,
334
378
  updates,
@@ -337,15 +381,23 @@ const updateSequenceKeyframes = async ({ input, nodePath, updates, prettierConfi
337
381
  input: serialized,
338
382
  prettierConfigOverride,
339
383
  });
340
- return { output, formatted, oldValueStrings, logLine };
384
+ return {
385
+ output,
386
+ formatted,
387
+ oldValueStrings,
388
+ newValueStrings,
389
+ logLine,
390
+ updatedNodePath,
391
+ };
341
392
  };
342
393
  exports.updateSequenceKeyframes = updateSequenceKeyframes;
343
394
  const updateEffectKeyframesAst = ({ input, sequenceNodePath, effectIndex, updates, }) => {
344
395
  var _a, _b;
345
396
  var _c, _d, _e;
346
397
  const ast = (0, parse_ast_1.parseAst)(input);
398
+ const jsxPath = (0, get_ast_node_path_1.getAstNodePath)(ast, sequenceNodePath);
347
399
  const jsx = (0, can_update_sequence_props_1.findJsxElementAtNodePath)(ast, sequenceNodePath);
348
- if (!jsx) {
400
+ if (!jsx || !jsxPath) {
349
401
  throw new Error('Could not find a JSX element at the specified location to update effect keyframes');
350
402
  }
351
403
  const attr = (0, update_effect_props_1.findEffectsAttr)((_c = jsx.attributes) !== null && _c !== void 0 ? _c : []);
@@ -363,27 +415,52 @@ const updateEffectKeyframesAst = ({ input, sequenceNodePath, effectIndex, update
363
415
  }
364
416
  const objExpr = call.arguments[0];
365
417
  const oldValueStrings = [];
418
+ const newValueStrings = [];
419
+ const requiredImports = new Set();
420
+ let needsFrameHook = false;
366
421
  for (const update of updates) {
367
422
  const { prop } = findObjectProperty(objExpr, update.key);
368
423
  if (!prop) {
369
424
  throw new Error(`Cannot update keyframes: "${update.key}" is not set`);
370
425
  }
371
426
  oldValueStrings.push(recast.print(prop.value).code);
372
- prop.value = applyKeyframeOperation({
427
+ const { expression: nextExpression, introduced } = applyKeyframeOperation({
373
428
  expression: prop.value,
374
429
  operation: update.operation,
375
430
  });
431
+ newValueStrings.push(recast.print(nextExpression).code);
432
+ prop.value = nextExpression;
433
+ if (introduced.calleeName) {
434
+ requiredImports.add(introduced.calleeName);
435
+ }
436
+ if (introduced.needsFrameHook) {
437
+ requiredImports.add('useCurrentFrame');
438
+ needsFrameHook = true;
439
+ }
440
+ }
441
+ if (needsFrameHook) {
442
+ const fnPath = (0, ensure_imports_and_frame_hook_1.findEnclosingFunctionPath)(jsxPath);
443
+ if (fnPath) {
444
+ (0, ensure_imports_and_frame_hook_1.ensureUseCurrentFrameHook)(fnPath);
445
+ }
446
+ }
447
+ (0, ensure_imports_and_frame_hook_1.ensureRemotionImports)(ast, requiredImports);
448
+ const updatedSequenceNodePath = (0, can_update_sequence_props_1.findNodePathForJsxElement)(ast, jsx);
449
+ if (!updatedSequenceNodePath) {
450
+ throw new Error('Could not find updated JSX element location after updating effect keyframes');
376
451
  }
377
452
  return {
378
453
  serialized: (0, parse_ast_1.serializeAst)(ast),
379
454
  oldValueStrings,
455
+ newValueStrings,
380
456
  logLine: (_e = (_d = (_a = 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,
381
457
  effectCallee,
458
+ updatedSequenceNodePath,
382
459
  };
383
460
  };
384
461
  exports.updateEffectKeyframesAst = updateEffectKeyframesAst;
385
462
  const updateEffectKeyframes = async ({ input, sequenceNodePath, effectIndex, updates, prettierConfigOverride, }) => {
386
- const { serialized, oldValueStrings, logLine, effectCallee } = (0, exports.updateEffectKeyframesAst)({
463
+ const { serialized, oldValueStrings, newValueStrings, logLine, effectCallee, updatedSequenceNodePath, } = (0, exports.updateEffectKeyframesAst)({
387
464
  input,
388
465
  sequenceNodePath,
389
466
  effectIndex,
@@ -393,6 +470,14 @@ const updateEffectKeyframes = async ({ input, sequenceNodePath, effectIndex, upd
393
470
  input: serialized,
394
471
  prettierConfigOverride,
395
472
  });
396
- return { output, formatted, oldValueStrings, logLine, effectCallee };
473
+ return {
474
+ output,
475
+ formatted,
476
+ oldValueStrings,
477
+ newValueStrings,
478
+ logLine,
479
+ effectCallee,
480
+ updatedSequenceNodePath,
481
+ };
397
482
  };
398
483
  exports.updateEffectKeyframes = updateEffectKeyframes;
@@ -1,5 +1,4 @@
1
- import type { SequenceNodePath } from 'remotion';
2
- import type { SequenceSchema } from 'remotion';
1
+ import type { SequenceNodePath, SequenceSchema } from 'remotion';
3
2
  export type SequencePropUpdate = {
4
3
  key: string;
5
4
  value: unknown;
@@ -9,6 +8,29 @@ export type RemovedProp = {
9
8
  key: string;
10
9
  valueString: string;
11
10
  };
11
+ export type SequencePropsNodeUpdate = {
12
+ nodePath: SequenceNodePath;
13
+ updates: SequencePropUpdate[];
14
+ schema: SequenceSchema;
15
+ };
16
+ export type SequencePropsNodeUpdateResult = {
17
+ oldValueStrings: string[];
18
+ logLine: number;
19
+ removedProps: RemovedProp[];
20
+ };
21
+ type PrettierConfigOverride = Record<string, unknown> | null;
22
+ type UpdateMultipleSequencePropsResult = {
23
+ output: string;
24
+ formatted: boolean;
25
+ results: SequencePropsNodeUpdateResult[];
26
+ };
27
+ type UpdateSequencePropsResult = {
28
+ output: string;
29
+ oldValueStrings: string[];
30
+ formatted: boolean;
31
+ logLine: number;
32
+ removedProps: RemovedProp[];
33
+ };
12
34
  export declare const updateSequencePropsAst: ({ input, nodePath, updates, schema, }: {
13
35
  input: string;
14
36
  nodePath: SequenceNodePath;
@@ -20,16 +42,16 @@ export declare const updateSequencePropsAst: ({ input, nodePath, updates, schema
20
42
  logLine: number;
21
43
  removedProps: RemovedProp[];
22
44
  };
45
+ export declare const updateMultipleSequenceProps: ({ input, changes, prettierConfigOverride, }: {
46
+ input: string;
47
+ changes: SequencePropsNodeUpdate[];
48
+ prettierConfigOverride: PrettierConfigOverride;
49
+ }) => Promise<UpdateMultipleSequencePropsResult>;
23
50
  export declare const updateSequenceProps: ({ input, nodePath, updates, schema, prettierConfigOverride, }: {
24
51
  input: string;
25
52
  nodePath: SequenceNodePath;
26
53
  updates: SequencePropUpdate[];
27
54
  schema: SequenceSchema;
28
- prettierConfigOverride?: Record<string, unknown> | null | undefined;
29
- }) => Promise<{
30
- output: string;
31
- oldValueStrings: string[];
32
- formatted: boolean;
33
- logLine: number;
34
- removedProps: RemovedProp[];
35
- }>;
55
+ prettierConfigOverride: PrettierConfigOverride;
56
+ }) => Promise<UpdateSequencePropsResult>;
57
+ export {};
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.updateSequenceProps = exports.updateSequencePropsAst = void 0;
36
+ exports.updateSequenceProps = exports.updateMultipleSequenceProps = exports.updateSequencePropsAst = void 0;
37
37
  const recast = __importStar(require("recast"));
38
38
  const no_react_1 = require("remotion/no-react");
39
39
  const can_update_sequence_props_1 = require("../../preview-server/routes/can-update-sequence-props");
@@ -85,14 +85,9 @@ const snapshotTopLevelAttrs = (node) => {
85
85
  }
86
86
  return result;
87
87
  };
88
- const updateSequencePropsAst = ({ input, nodePath, updates, schema, }) => {
88
+ const updateSequencePropsNode = ({ node, updates, schema, }) => {
89
89
  var _a, _b, _c;
90
90
  var _d, _e;
91
- const ast = (0, parse_ast_1.parseAst)(input);
92
- const node = (0, can_update_sequence_props_1.findJsxElementAtNodePath)(ast, nodePath);
93
- if (!node) {
94
- throw new Error('Could not find a JSX element at the specified line to update');
95
- }
96
91
  const logLine = (_d = (_a = node.loc) === null || _a === void 0 ? void 0 : _a.start.line) !== null && _d !== void 0 ? _d : 1;
97
92
  const oldValueStrings = [];
98
93
  const initialAttrs = snapshotTopLevelAttrs(node);
@@ -194,6 +189,23 @@ const updateSequencePropsAst = ({ input, nodePath, updates, schema, }) => {
194
189
  }
195
190
  removedProps.push({ key: name, valueString });
196
191
  }
192
+ return {
193
+ oldValueStrings,
194
+ logLine,
195
+ removedProps,
196
+ };
197
+ };
198
+ const updateSequencePropsAst = ({ input, nodePath, updates, schema, }) => {
199
+ const ast = (0, parse_ast_1.parseAst)(input);
200
+ const node = (0, can_update_sequence_props_1.findJsxElementAtNodePath)(ast, nodePath);
201
+ if (!node) {
202
+ throw new Error('Could not find a JSX element at the specified line to update');
203
+ }
204
+ const { oldValueStrings, logLine, removedProps } = updateSequencePropsNode({
205
+ node,
206
+ updates,
207
+ schema,
208
+ });
197
209
  return {
198
210
  serialized: (0, parse_ast_1.serializeAst)(ast),
199
211
  oldValueStrings,
@@ -202,6 +214,26 @@ const updateSequencePropsAst = ({ input, nodePath, updates, schema, }) => {
202
214
  };
203
215
  };
204
216
  exports.updateSequencePropsAst = updateSequencePropsAst;
217
+ const updateMultipleSequenceProps = async ({ input, changes, prettierConfigOverride, }) => {
218
+ const ast = (0, parse_ast_1.parseAst)(input);
219
+ const results = changes.map(({ nodePath, updates, schema }) => {
220
+ const node = (0, can_update_sequence_props_1.findJsxElementAtNodePath)(ast, nodePath);
221
+ if (!node) {
222
+ throw new Error('Could not find a JSX element at the specified line to update');
223
+ }
224
+ return updateSequencePropsNode({ node, updates, schema });
225
+ });
226
+ const { output, formatted } = await (0, format_file_content_1.formatFileContent)({
227
+ input: (0, parse_ast_1.serializeAst)(ast),
228
+ prettierConfigOverride,
229
+ });
230
+ return {
231
+ output,
232
+ formatted,
233
+ results,
234
+ };
235
+ };
236
+ exports.updateMultipleSequenceProps = updateMultipleSequenceProps;
205
237
  const updateSequenceProps = async ({ input, nodePath, updates, schema, prettierConfigOverride, }) => {
206
238
  const { serialized, oldValueStrings, logLine, removedProps } = (0, exports.updateSequencePropsAst)({
207
239
  input,
@@ -5,8 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { LogLevel } from '@remotion/renderer';
8
- declare const editorNames: readonly ["atom", "/Applications/Atom Beta.app/Contents/MacOS/Atom Beta", "brackets", "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl", "/Applications/Sublime Text Dev.app/Contents/SharedSupport/bin/subl", "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl", "code", "code-insiders", "vscodium", "/Applications/AppCode.app/Contents/MacOS/appcode", "/Applications/CLion.app/Contents/MacOS/clion", "/Applications/IntelliJ IDEA.app/Contents/MacOS/idea", "/Applications/PhpStorm.app/Contents/MacOS/phpstorm", "/Applications/PyCharm.app/Contents/MacOS/pycharm", "/Applications/PyCharm CE.app/Contents/MacOS/pycharm", "/Applications/RubyMine.app/Contents/MacOS/rubymine", "/Applications/WebStorm.app/Contents/MacOS/webstorm", "/Applications/GoLand.app/Contents/MacOS/goland", "/Applications/Rider.app/Contents/MacOS/rider", "mvim", "emacs", "gvim", "idea", "phpstorm", "pycharm", "rubymine", "subl", "sublime_text", "vim", "webstorm", "goland", "rider", "Brackets.exe", "Code.exe", "Code - Insiders.exe", "VSCodium.exe", "atom.exe", "sublime_text.exe", "notepad++.exe", "clion.exe", "clion64.exe", "idea.exe", "idea64.exe", "phpstorm.exe", "phpstorm64.exe", "pycharm.exe", "pycharm64.exe", "rubymine.exe", "rubymine64.exe", "webstorm.exe", "webstorm64.exe", "goland.exe", "goland64.exe", "rider.exe", "rider64.exe", "nano", "cursor", "/Applications/Cursor.app/Contents/MacOS/Cursor", "Cursor.exe", "windsurf", "/Applications/Windsurf.app/Contents/MacOS/Windsurf", "Windsurf.exe", "zed"];
9
- export declare const getDisplayNameForEditor: (editor: "/Applications/AppCode.app/Contents/MacOS/appcode" | "/Applications/Atom Beta.app/Contents/MacOS/Atom Beta" | "/Applications/CLion.app/Contents/MacOS/clion" | "/Applications/Cursor.app/Contents/MacOS/Cursor" | "/Applications/GoLand.app/Contents/MacOS/goland" | "/Applications/IntelliJ IDEA.app/Contents/MacOS/idea" | "/Applications/PhpStorm.app/Contents/MacOS/phpstorm" | "/Applications/PyCharm CE.app/Contents/MacOS/pycharm" | "/Applications/PyCharm.app/Contents/MacOS/pycharm" | "/Applications/Rider.app/Contents/MacOS/rider" | "/Applications/RubyMine.app/Contents/MacOS/rubymine" | "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" | "/Applications/Sublime Text Dev.app/Contents/SharedSupport/bin/subl" | "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" | "/Applications/WebStorm.app/Contents/MacOS/webstorm" | "/Applications/Windsurf.app/Contents/MacOS/Windsurf" | "Brackets.exe" | "Code - Insiders.exe" | "Code.exe" | "Cursor.exe" | "VSCodium.exe" | "Windsurf.exe" | "atom" | "atom.exe" | "brackets" | "clion.exe" | "clion64.exe" | "code" | "code-insiders" | "cursor" | "emacs" | "goland" | "goland.exe" | "goland64.exe" | "gvim" | "idea" | "idea.exe" | "idea64.exe" | "mvim" | "nano" | "notepad++.exe" | "phpstorm" | "phpstorm.exe" | "phpstorm64.exe" | "pycharm" | "pycharm.exe" | "pycharm64.exe" | "rider" | "rider.exe" | "rider64.exe" | "rubymine" | "rubymine.exe" | "rubymine64.exe" | "subl" | "sublime_text" | "sublime_text.exe" | "vim" | "vscodium" | "webstorm" | "webstorm.exe" | "webstorm64.exe" | "windsurf" | "zed" | null) => string | null;
8
+ declare const editorNames: readonly ["atom", "/Applications/Atom Beta.app/Contents/MacOS/Atom Beta", "brackets", "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl", "/Applications/Sublime Text Dev.app/Contents/SharedSupport/bin/subl", "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl", "code", "code-insiders", "vscodium", "/Applications/AppCode.app/Contents/MacOS/appcode", "/Applications/CLion.app/Contents/MacOS/clion", "/Applications/IntelliJ IDEA.app/Contents/MacOS/idea", "/Applications/PhpStorm.app/Contents/MacOS/phpstorm", "/Applications/PyCharm.app/Contents/MacOS/pycharm", "/Applications/PyCharm CE.app/Contents/MacOS/pycharm", "/Applications/RubyMine.app/Contents/MacOS/rubymine", "/Applications/WebStorm.app/Contents/MacOS/webstorm", "/Applications/GoLand.app/Contents/MacOS/goland", "/Applications/Rider.app/Contents/MacOS/rider", "mvim", "emacs", "gvim", "idea", "phpstorm", "pycharm", "rubymine", "subl", "sublime_text", "vim", "webstorm", "goland", "rider", "Brackets.exe", "Code.exe", "Code - Insiders.exe", "VSCodium.exe", "atom.exe", "sublime_text.exe", "notepad++.exe", "clion.exe", "clion64.exe", "idea.exe", "idea64.exe", "phpstorm.exe", "phpstorm64.exe", "pycharm.exe", "pycharm64.exe", "rubymine.exe", "rubymine64.exe", "webstorm.exe", "webstorm64.exe", "goland.exe", "goland64.exe", "rider.exe", "rider64.exe", "nano", "cursor", "/Applications/Cursor.app/Contents/MacOS/Cursor", "Cursor.exe", "windsurf", "/Applications/Windsurf.app/Contents/MacOS/Windsurf", "Windsurf.exe", "zed", "zedit", "zeditor", "zed-editor", "/Applications/Zed.app/Contents/MacOS/zed", "/Applications/Zed.app/Contents/MacOS/cli", "/Applications/Zed Preview.app/Contents/MacOS/zed", "/Applications/Zed Preview.app/Contents/MacOS/cli", "/Applications/Zed Preview.app/Contents/MacOS/Zed Preview", "Zed.exe"];
9
+ export declare const getDisplayNameForEditor: (editor: "/Applications/AppCode.app/Contents/MacOS/appcode" | "/Applications/Atom Beta.app/Contents/MacOS/Atom Beta" | "/Applications/CLion.app/Contents/MacOS/clion" | "/Applications/Cursor.app/Contents/MacOS/Cursor" | "/Applications/GoLand.app/Contents/MacOS/goland" | "/Applications/IntelliJ IDEA.app/Contents/MacOS/idea" | "/Applications/PhpStorm.app/Contents/MacOS/phpstorm" | "/Applications/PyCharm CE.app/Contents/MacOS/pycharm" | "/Applications/PyCharm.app/Contents/MacOS/pycharm" | "/Applications/Rider.app/Contents/MacOS/rider" | "/Applications/RubyMine.app/Contents/MacOS/rubymine" | "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" | "/Applications/Sublime Text Dev.app/Contents/SharedSupport/bin/subl" | "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" | "/Applications/WebStorm.app/Contents/MacOS/webstorm" | "/Applications/Windsurf.app/Contents/MacOS/Windsurf" | "/Applications/Zed Preview.app/Contents/MacOS/Zed Preview" | "/Applications/Zed Preview.app/Contents/MacOS/cli" | "/Applications/Zed Preview.app/Contents/MacOS/zed" | "/Applications/Zed.app/Contents/MacOS/cli" | "/Applications/Zed.app/Contents/MacOS/zed" | "Brackets.exe" | "Code - Insiders.exe" | "Code.exe" | "Cursor.exe" | "VSCodium.exe" | "Windsurf.exe" | "Zed.exe" | "atom" | "atom.exe" | "brackets" | "clion.exe" | "clion64.exe" | "code" | "code-insiders" | "cursor" | "emacs" | "goland" | "goland.exe" | "goland64.exe" | "gvim" | "idea" | "idea.exe" | "idea64.exe" | "mvim" | "nano" | "notepad++.exe" | "phpstorm" | "phpstorm.exe" | "phpstorm64.exe" | "pycharm" | "pycharm.exe" | "pycharm64.exe" | "rider" | "rider.exe" | "rider64.exe" | "rubymine" | "rubymine.exe" | "rubymine64.exe" | "subl" | "sublime_text" | "sublime_text.exe" | "vim" | "vscodium" | "webstorm" | "webstorm.exe" | "webstorm64.exe" | "windsurf" | "zed" | "zed-editor" | "zedit" | "zeditor" | null) => string | null;
10
10
  type Editor = (typeof editorNames)[number];
11
11
  type ProcessAndCommand = {
12
12
  process: string;