@remotion/studio-server 4.0.513 → 4.0.515

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 (67) hide show
  1. package/dist/codemods/delete-jsx-node.d.ts +2 -5
  2. package/dist/codemods/delete-jsx-node.js +23 -341
  3. package/dist/codemods/duplicate-composition.d.ts +1 -9
  4. package/dist/codemods/duplicate-composition.js +3 -49
  5. package/dist/codemods/format-inline-content.d.ts +0 -4
  6. package/dist/codemods/format-inline-content.js +7 -46
  7. package/dist/codemods/recast-mods.js +0 -18
  8. package/dist/codemods/reorder-sequence.d.ts +2 -2
  9. package/dist/codemods/reorder-sequence.js +12 -112
  10. package/dist/codemods/split-jsx-sequence.d.ts +1 -2
  11. package/dist/codemods/split-jsx-sequence.js +11 -298
  12. package/dist/codemods/split-video-from-audio.d.ts +15 -0
  13. package/dist/codemods/split-video-from-audio.js +15 -0
  14. package/dist/codemods/update-default-props.d.ts +2 -6
  15. package/dist/codemods/update-default-props.js +12 -220
  16. package/dist/codemods/update-keyframes/ensure-imports-and-frame-hook.d.ts +1 -4
  17. package/dist/codemods/update-keyframes/ensure-imports-and-frame-hook.js +5 -102
  18. package/dist/codemods/update-keyframes/update-keyframes.d.ts +8 -93
  19. package/dist/codemods/update-keyframes/update-keyframes.js +11 -1302
  20. package/dist/detect-outdated-remotion-skills.d.ts +7 -0
  21. package/dist/detect-outdated-remotion-skills.js +11 -5
  22. package/dist/helpers/open-file-for-writing-without-symlinks.d.ts +4 -0
  23. package/dist/helpers/open-file-for-writing-without-symlinks.js +52 -0
  24. package/dist/helpers/resolve-composition-component.d.ts +3 -11
  25. package/dist/helpers/resolve-composition-component.js +38 -1495
  26. package/dist/helpers/video-config-values.js +25 -6
  27. package/dist/index.d.ts +3 -2
  28. package/dist/index.js +1 -0
  29. package/dist/max-timeline-tracks.d.ts +2 -1
  30. package/dist/max-timeline-tracks.js +10 -4
  31. package/dist/preview-server/api-routes.js +4 -0
  32. package/dist/preview-server/routes/add-effect.js +1 -1
  33. package/dist/preview-server/routes/apply-codemod.js +3 -3
  34. package/dist/preview-server/routes/apply-visual-control-change.js +3 -3
  35. package/dist/preview-server/routes/can-update-sequence-props.js +107 -24
  36. package/dist/preview-server/routes/delete-effect-keyframe.d.ts +3 -0
  37. package/dist/preview-server/routes/delete-effect-keyframe.js +89 -0
  38. package/dist/preview-server/routes/delete-effect.js +1 -1
  39. package/dist/preview-server/routes/delete-jsx-node.js +1 -1
  40. package/dist/preview-server/routes/delete-sequence-keyframe.d.ts +3 -0
  41. package/dist/preview-server/routes/delete-sequence-keyframe.js +82 -0
  42. package/dist/preview-server/routes/duplicate-effect.js +1 -1
  43. package/dist/preview-server/routes/duplicate-jsx-node.js +1 -1
  44. package/dist/preview-server/routes/element-install-plan.d.ts +1 -1
  45. package/dist/preview-server/routes/insert-element.js +2 -2
  46. package/dist/preview-server/routes/insert-jsx-element.js +1 -1
  47. package/dist/preview-server/routes/install-dependency.js +8 -2
  48. package/dist/preview-server/routes/log-updates/log-effect-update.js +2 -1
  49. package/dist/preview-server/routes/log-updates/log-update.js +2 -1
  50. package/dist/preview-server/routes/paste-effects.js +1 -1
  51. package/dist/preview-server/routes/remotion-skills-info.d.ts +7 -0
  52. package/dist/preview-server/routes/remotion-skills-info.js +24 -0
  53. package/dist/preview-server/routes/reorder-effect.js +1 -1
  54. package/dist/preview-server/routes/reorder-sequence.js +1 -1
  55. package/dist/preview-server/routes/save-props-mutex.d.ts +1 -0
  56. package/dist/preview-server/routes/save-props-mutex.js +11 -0
  57. package/dist/preview-server/routes/source-file-write-queue.d.ts +1 -0
  58. package/dist/preview-server/routes/source-file-write-queue.js +11 -2
  59. package/dist/preview-server/routes/split-jsx-sequence.js +1 -1
  60. package/dist/preview-server/routes/split-video-from-audio.d.ts +3 -0
  61. package/dist/preview-server/routes/split-video-from-audio.js +80 -0
  62. package/dist/preview-server/routes/update-default-props.js +1 -1
  63. package/dist/preview-server/start-server.js +188 -140
  64. package/dist/preview-server/undo-stack.d.ts +3 -52
  65. package/dist/preview-server/update-available.js +4 -4
  66. package/dist/routes.js +36 -5
  67. package/package.json +8 -8
@@ -36,15 +36,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.getVideoConfigIdentifierValues = void 0;
37
37
  const recast = __importStar(require("recast"));
38
38
  const getVideoConfigIdentifierValues = ({ ast, videoConfigValues, }) => {
39
- if (videoConfigValues === null) {
40
- return {};
41
- }
42
39
  const candidates = new Map();
43
40
  const otherDeclarations = new Set();
41
+ const addCandidate = (identifier, value) => {
42
+ if (candidates.has(identifier) || otherDeclarations.has(identifier)) {
43
+ candidates.delete(identifier);
44
+ otherDeclarations.add(identifier);
45
+ return;
46
+ }
47
+ candidates.set(identifier, value);
48
+ };
44
49
  recast.types.visit(ast, {
45
50
  visitVariableDeclarator(path) {
46
51
  const { id, init } = path.node;
47
- const isVideoConfigDeclaration = id.type === 'ObjectPattern' &&
52
+ const isVideoConfigDeclaration = videoConfigValues !== null &&
53
+ id.type === 'ObjectPattern' &&
48
54
  (init === null || init === void 0 ? void 0 : init.type) === 'CallExpression' &&
49
55
  init.callee.type === 'Identifier' &&
50
56
  init.callee.name === 'useVideoConfig' &&
@@ -66,12 +72,25 @@ const getVideoConfigIdentifierValues = ({ ast, videoConfigValues, }) => {
66
72
  }
67
73
  const value = videoConfigValues[configKey];
68
74
  if (Number.isFinite(value)) {
69
- candidates.set(property.value.name, value);
75
+ addCandidate(property.value.name, value);
70
76
  }
71
77
  }
72
78
  }
73
79
  else if (id.type === 'Identifier') {
74
- otherDeclarations.add(id.name);
80
+ const declaration = path.parentPath.node;
81
+ const numericConstant = declaration.type === 'VariableDeclaration' &&
82
+ declaration.kind === 'const' &&
83
+ (init === null || init === void 0 ? void 0 : init.type) === 'NumericLiteral' &&
84
+ Number.isFinite(init.value)
85
+ ? init.value
86
+ : null;
87
+ if (numericConstant !== null) {
88
+ addCandidate(id.name, numericConstant);
89
+ }
90
+ else {
91
+ candidates.delete(id.name);
92
+ otherDeclarations.add(id.name);
93
+ }
75
94
  }
76
95
  this.traverse(path);
77
96
  },
package/dist/index.d.ts CHANGED
@@ -60,7 +60,8 @@ export declare const StudioServerInternals: {
60
60
  installCommand: string;
61
61
  startCommand: string;
62
62
  };
63
- getMaxTimelineTracks: () => number;
63
+ getMaxTimelineTracks: () => number | null;
64
+ getConfiguredMaxTimelineTracks: () => number | null;
64
65
  setMaxTimelineTracks: (maxTracks: number) => void;
65
66
  resetMaxTimelineTracks: () => void;
66
67
  getLatestRemotionVersion: () => Promise<any>;
@@ -92,7 +93,7 @@ export declare const StudioServerInternals: {
92
93
  codeMod: import("@remotion/studio-shared").RecastCodemod;
93
94
  }) => {
94
95
  newContents: string;
95
- changesMade: import("./codemods/recast-mods").Change[];
96
+ changesMade: import("@remotion/studio-codemods").Change[];
96
97
  };
97
98
  applyCodemodToFile: ({ filePath, codeMod, }: {
98
99
  filePath: string;
package/dist/index.js CHANGED
@@ -32,6 +32,7 @@ exports.StudioServerInternals = {
32
32
  lockFilePaths: get_package_manager_1.lockFilePaths,
33
33
  getPackageManager: get_package_manager_1.getPackageManager,
34
34
  getMaxTimelineTracks: max_timeline_tracks_1.getMaxTimelineTracks,
35
+ getConfiguredMaxTimelineTracks: max_timeline_tracks_1.getConfiguredMaxTimelineTracks,
35
36
  setMaxTimelineTracks: max_timeline_tracks_1.setMaxTimelineTracks,
36
37
  resetMaxTimelineTracks: max_timeline_tracks_1.resetMaxTimelineTracks,
37
38
  getLatestRemotionVersion: get_latest_remotion_version_1.getLatestRemotionVersion,
@@ -1,3 +1,4 @@
1
1
  export declare const setMaxTimelineTracks: (maxTracks: number) => void;
2
- export declare const getMaxTimelineTracks: () => number;
2
+ export declare const getMaxTimelineTracks: () => number | null;
3
+ export declare const getConfiguredMaxTimelineTracks: () => number | null;
3
4
  export declare const resetMaxTimelineTracks: () => void;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resetMaxTimelineTracks = exports.getMaxTimelineTracks = exports.setMaxTimelineTracks = void 0;
4
- const studio_shared_1 = require("@remotion/studio-shared");
5
- let maxTimelineTracks = studio_shared_1.DEFAULT_TIMELINE_TRACKS;
3
+ exports.resetMaxTimelineTracks = exports.getConfiguredMaxTimelineTracks = exports.getMaxTimelineTracks = exports.setMaxTimelineTracks = void 0;
4
+ let maxTimelineTracks = null;
5
+ let configuredMaxTimelineTracks = null;
6
6
  const setMaxTimelineTracks = (maxTracks) => {
7
7
  if (typeof maxTracks !== 'number') {
8
8
  throw new Error(`Need to pass a number to Config.setMaxTimelineTracks(), got ${typeof maxTracks}`);
@@ -17,13 +17,19 @@ const setMaxTimelineTracks = (maxTracks) => {
17
17
  throw new Error(`Need to pass a non-negative number to Config.setMaxTimelineTracks(), got ${maxTracks}`);
18
18
  }
19
19
  maxTimelineTracks = maxTracks;
20
+ configuredMaxTimelineTracks = maxTracks;
20
21
  };
21
22
  exports.setMaxTimelineTracks = setMaxTimelineTracks;
22
23
  const getMaxTimelineTracks = () => {
23
24
  return maxTimelineTracks;
24
25
  };
25
26
  exports.getMaxTimelineTracks = getMaxTimelineTracks;
27
+ const getConfiguredMaxTimelineTracks = () => {
28
+ return configuredMaxTimelineTracks;
29
+ };
30
+ exports.getConfiguredMaxTimelineTracks = getConfiguredMaxTimelineTracks;
26
31
  const resetMaxTimelineTracks = () => {
27
- maxTimelineTracks = studio_shared_1.DEFAULT_TIMELINE_TRACKS;
32
+ maxTimelineTracks = null;
33
+ configuredMaxTimelineTracks = null;
28
34
  };
29
35
  exports.resetMaxTimelineTracks = resetMaxTimelineTracks;
@@ -37,6 +37,7 @@ const prepare_element_install_1 = require("./routes/prepare-element-install");
37
37
  const project_info_1 = require("./routes/project-info");
38
38
  const redo_1 = require("./routes/redo");
39
39
  const register_client_render_1 = require("./routes/register-client-render");
40
+ const remotion_skills_info_1 = require("./routes/remotion-skills-info");
40
41
  const remove_render_1 = require("./routes/remove-render");
41
42
  const rename_static_file_1 = require("./routes/rename-static-file");
42
43
  const reorder_effect_1 = require("./routes/reorder-effect");
@@ -46,6 +47,7 @@ const save_effect_props_1 = require("./routes/save-effect-props");
46
47
  const save_multiple_effect_props_1 = require("./routes/save-multiple-effect-props");
47
48
  const save_sequence_props_1 = require("./routes/save-sequence-props");
48
49
  const split_jsx_sequence_1 = require("./routes/split-jsx-sequence");
50
+ const split_video_from_audio_1 = require("./routes/split-video-from-audio");
49
51
  const subscribe_to_default_props_1 = require("./routes/subscribe-to-default-props");
50
52
  const subscribe_to_file_existence_1 = require("./routes/subscribe-to-file-existence");
51
53
  const subscribe_to_sequence_props_1 = require("./routes/subscribe-to-sequence-props");
@@ -104,7 +106,9 @@ exports.allApiRoutes = {
104
106
  '/api/delete-jsx-node': delete_jsx_node_1.deleteJsxNodeHandler,
105
107
  '/api/duplicate-jsx-node': duplicate_jsx_node_1.duplicateJsxNodeHandler,
106
108
  '/api/split-jsx-sequence': split_jsx_sequence_1.splitJsxSequenceHandler,
109
+ '/api/split-video-from-audio': split_video_from_audio_1.splitVideoFromAudioHandler,
107
110
  '/api/update-available': update_available_1.handleUpdate,
111
+ '/api/remotion-skills-info': remotion_skills_info_1.remotionSkillsInfoHandler,
108
112
  '/api/project-info': project_info_1.projectInfoHandler,
109
113
  '/api/delete-static-file': delete_static_file_1.deleteStaticFileHandler,
110
114
  '/api/rename-static-file': rename_static_file_1.renameStaticFileHandler,
@@ -55,7 +55,7 @@ const addEffectHandler = ({ input: { fileName, sequenceNodePath, effectName, eff
55
55
  absolutePath,
56
56
  line: logLine,
57
57
  });
58
- renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Added ${(0, formatting_1.attrName)(effectLabel)} to ${nodeLabel}`);
58
+ renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${(0, source_file_write_queue_1.getCodemodTimingPrefix)(logLevel)}${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Added ${(0, formatting_1.attrName)(effectLabel)} to ${nodeLabel}`);
59
59
  if (!formatted) {
60
60
  (0, log_update_1.warnAboutPrettierOnce)(logLevel);
61
61
  }
@@ -7,10 +7,10 @@ exports.applyCodemodHandler = exports.getCodemodLogMessage = void 0;
7
7
  const node_fs_1 = require("node:fs");
8
8
  const node_path_1 = __importDefault(require("node:path"));
9
9
  const renderer_1 = require("@remotion/renderer");
10
+ const studio_codemods_1 = require("@remotion/studio-codemods");
10
11
  const generate_canvas_capture_composition_1 = require("../../canvas-capture/generate-canvas-capture-composition");
11
12
  const apply_codemod_to_file_1 = require("../../codemods/apply-codemod-to-file");
12
13
  const duplicate_composition_1 = require("../../codemods/duplicate-composition");
13
- const simple_diff_1 = require("../../codemods/simple-diff");
14
14
  const file_watcher_1 = require("../../file-watcher");
15
15
  const format_log_file_location_1 = require("../format-log-file-location");
16
16
  const project_info_1 = require("../project-info");
@@ -194,7 +194,7 @@ const applyCodemodHandler = ({ input: { codemod, dryRun, symbolicatedStack }, lo
194
194
  filePath,
195
195
  codeMod: codemod,
196
196
  });
197
- const diff = (0, simple_diff_1.simpleDiff)({
197
+ const diff = (0, studio_codemods_1.simpleDiff)({
198
198
  oldLines: input.split('\n'),
199
199
  newLines: formatted.split('\n'),
200
200
  });
@@ -272,7 +272,7 @@ const applyCodemodHandler = ({ input: { codemod, dryRun, symbolicatedStack }, lo
272
272
  });
273
273
  }
274
274
  const logMessage = (0, exports.getCodemodLogMessage)(codemod);
275
- const editMessage = `${renderer_1.RenderInternals.chalk.blueBright((0, format_log_file_location_1.formatLogFileLocation)({
275
+ const editMessage = `${(0, source_file_write_queue_1.getCodemodTimingPrefix)(logLevel)}${renderer_1.RenderInternals.chalk.blueBright((0, format_log_file_location_1.formatLogFileLocation)({
276
276
  remotionRoot,
277
277
  absolutePath: filePath,
278
278
  line: logLine,
@@ -36,9 +36,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.applyVisualControlHandler = void 0;
37
37
  const node_fs_1 = require("node:fs");
38
38
  const renderer_1 = require("@remotion/renderer");
39
+ const studio_codemods_1 = require("@remotion/studio-codemods");
39
40
  const recast = __importStar(require("recast"));
40
41
  const parse_ast_1 = require("../../codemods/parse-ast");
41
- const recast_mods_1 = require("../../codemods/recast-mods");
42
42
  const file_watcher_1 = require("../../file-watcher");
43
43
  const resolve_file_inside_project_1 = require("../../helpers/resolve-file-inside-project");
44
44
  const format_log_file_location_1 = require("../format-log-file-location");
@@ -78,7 +78,7 @@ const applyVisualControlHandler = ({ input: { fileName, changes }, remotionRoot,
78
78
  const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
79
79
  const ast = (0, parse_ast_1.parseAst)(fileContents);
80
80
  const logLine = changes.length > 0 ? getVisualControlChangeLine(ast, changes[0].id) : 1;
81
- const { newAst, changesMade } = (0, recast_mods_1.applyCodemod)({
81
+ const { newAst, changesMade } = (0, studio_codemods_1.applyCodemod)({
82
82
  file: ast,
83
83
  codeMod: {
84
84
  type: 'apply-visual-control',
@@ -150,7 +150,7 @@ const applyVisualControlHandler = ({ input: { fileName, changes }, remotionRoot,
150
150
  absolutePath,
151
151
  line: logLine,
152
152
  });
153
- renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Applied visual control changes`);
153
+ renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${(0, source_file_write_queue_1.getCodemodTimingPrefix)(logLevel)}${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Applied visual control changes`);
154
154
  if (!formatted) {
155
155
  (0, log_update_1.warnAboutPrettierOnce)(logLevel);
156
156
  }
@@ -603,12 +603,8 @@ const getFrameDisplayOffsetAdjustmentBetweenPaths = ({ startPath, endPath, video
603
603
  }
604
604
  return current ? { adjustment, hasEnclosingElement } : null;
605
605
  };
606
- const getDefaultFrameDisplayOffsetAdjustment = ({ jsxElement, ast, videoConfigValues, }) => {
606
+ const getDefaultFrameDisplayOffsetAdjustment = ({ jsxPath, videoConfigValues, }) => {
607
607
  var _a;
608
- const jsxPath = findNodePath(ast, jsxElement);
609
- if (!jsxPath) {
610
- return null;
611
- }
612
608
  let functionPath = jsxPath.parentPath;
613
609
  while (functionPath) {
614
610
  const node = functionPath.value;
@@ -629,15 +625,50 @@ const getDefaultFrameDisplayOffsetAdjustment = ({ jsxElement, ast, videoConfigVa
629
625
  });
630
626
  return (_a = result === null || result === void 0 ? void 0 : result.adjustment) !== null && _a !== void 0 ? _a : null;
631
627
  };
632
- const getCurrentFrameDisplayOffsetAdjustment = ({ node, ast, videoConfigValues, }) => {
628
+ const resolveCurrentFrameExpression = ({ node, ast, seenDeclarations, }) => {
633
629
  var _a;
634
630
  if (node.type === 'TSAsExpression') {
635
- return getCurrentFrameDisplayOffsetAdjustment({
631
+ return resolveCurrentFrameExpression({
636
632
  node: node.expression,
637
633
  ast,
638
- videoConfigValues,
634
+ seenDeclarations,
639
635
  });
640
636
  }
637
+ if (node.type === 'BinaryExpression' &&
638
+ (node.operator === '+' || node.operator === '-')) {
639
+ const rightValue = getNumericValue(node.right);
640
+ if (rightValue !== null && Number.isFinite(rightValue)) {
641
+ const resolvedLeft = resolveCurrentFrameExpression({
642
+ node: node.left,
643
+ ast,
644
+ seenDeclarations,
645
+ });
646
+ if (resolvedLeft !== null) {
647
+ return {
648
+ ...resolvedLeft,
649
+ offset: resolvedLeft.offset +
650
+ (node.operator === '+' ? rightValue : -rightValue),
651
+ };
652
+ }
653
+ }
654
+ if (node.operator === '+') {
655
+ const leftValue = getNumericValue(node.left);
656
+ if (leftValue !== null && Number.isFinite(leftValue)) {
657
+ const resolvedRight = resolveCurrentFrameExpression({
658
+ node: node.right,
659
+ ast,
660
+ seenDeclarations,
661
+ });
662
+ if (resolvedRight !== null) {
663
+ return {
664
+ ...resolvedRight,
665
+ offset: resolvedRight.offset + leftValue,
666
+ };
667
+ }
668
+ }
669
+ }
670
+ return null;
671
+ }
641
672
  if (node.type !== 'Identifier') {
642
673
  return null;
643
674
  }
@@ -647,7 +678,9 @@ const getCurrentFrameDisplayOffsetAdjustment = ({ node, ast, videoConfigValues,
647
678
  return null;
648
679
  }
649
680
  let matchingDeclarations = 0;
650
- let isCurrentFrameBinding = false;
681
+ let matchingDeclaration = null;
682
+ let initializer = null;
683
+ let isConstDeclaration = false;
651
684
  recast.types.visit(bindingScope.path, {
652
685
  visitVariableDeclarator(p) {
653
686
  var _a;
@@ -658,18 +691,68 @@ const getCurrentFrameDisplayOffsetAdjustment = ({ node, ast, videoConfigValues,
658
691
  return this.traverse(p);
659
692
  }
660
693
  matchingDeclarations++;
661
- isCurrentFrameBinding = Boolean(init && isUseCurrentFrameCall(init, ast));
694
+ const declaration = p.parentPath.node;
695
+ if (init) {
696
+ matchingDeclaration = p.node;
697
+ initializer = init;
698
+ isConstDeclaration =
699
+ declaration.type === 'VariableDeclaration' &&
700
+ declaration.kind === 'const';
701
+ }
662
702
  return false;
663
703
  },
664
704
  });
665
- if (matchingDeclarations !== 1 || !isCurrentFrameBinding) {
705
+ if (matchingDeclarations !== 1 ||
706
+ matchingDeclaration === null ||
707
+ initializer === null ||
708
+ seenDeclarations.has(matchingDeclaration)) {
709
+ return null;
710
+ }
711
+ if (isUseCurrentFrameCall(initializer, ast)) {
712
+ return { bindingScopePath: bindingScope.path, offset: 0 };
713
+ }
714
+ if (!isConstDeclaration) {
715
+ return null;
716
+ }
717
+ const nextSeenDeclarations = new Set(seenDeclarations);
718
+ nextSeenDeclarations.add(matchingDeclaration);
719
+ return resolveCurrentFrameExpression({
720
+ node: initializer,
721
+ ast,
722
+ seenDeclarations: nextSeenDeclarations,
723
+ });
724
+ };
725
+ const getCurrentFrameDisplayOffsetAdjustment = ({ node, ast, videoConfigValues, }) => {
726
+ if (node.type === 'TSAsExpression') {
727
+ return getCurrentFrameDisplayOffsetAdjustment({
728
+ node: node.expression,
729
+ ast,
730
+ videoConfigValues,
731
+ });
732
+ }
733
+ const nodePath = findNodePath(ast, node);
734
+ const resolved = resolveCurrentFrameExpression({
735
+ node,
736
+ ast,
737
+ seenDeclarations: new Set(),
738
+ });
739
+ if (!nodePath || resolved === null) {
666
740
  return null;
667
741
  }
668
- return getFrameDisplayOffsetAdjustmentBetweenPaths({
742
+ const frameDisplayOffset = getFrameDisplayOffsetAdjustmentBetweenPaths({
669
743
  startPath: nodePath,
670
- endPath: bindingScope.path,
744
+ endPath: resolved.bindingScopePath,
671
745
  videoConfigValues,
672
746
  });
747
+ if (frameDisplayOffset === null) {
748
+ return null;
749
+ }
750
+ return {
751
+ ...frameDisplayOffset,
752
+ // interpolate(frame + offset, [keyframe], ...) reaches the keyframe at
753
+ // composition frame `keyframe - offset`.
754
+ adjustment: frameDisplayOffset.adjustment - resolved.offset,
755
+ };
673
756
  };
674
757
  const getComputedStatus = (node, ast, videoConfigValues) => {
675
758
  const interpolation = getInterpolationKeyframes(node, ast, videoConfigValues);
@@ -769,17 +852,17 @@ const findJsxElementAtNodePath = (ast, nodePath) => {
769
852
  return current ? current.value : null;
770
853
  };
771
854
  exports.findJsxElementAtNodePath = findJsxElementAtNodePath;
772
- const findJsxElementNodeAtNodePath = (ast, nodePath) => {
855
+ const getJsxElementNodeFromJsxPath = (jsxPath) => {
773
856
  var _a;
774
- const current = (0, exports.findJsxElementPathAtNodePath)(ast, nodePath);
775
- if (!current) {
776
- return null;
777
- }
778
- if (recast.types.namedTypes.JSXElement.check((_a = current.parentPath) === null || _a === void 0 ? void 0 : _a.value)) {
779
- return current.parentPath.value;
857
+ if (recast.types.namedTypes.JSXElement.check((_a = jsxPath.parentPath) === null || _a === void 0 ? void 0 : _a.value)) {
858
+ return jsxPath.parentPath.value;
780
859
  }
781
860
  return null;
782
861
  };
862
+ const findJsxElementNodeAtNodePath = (ast, nodePath) => {
863
+ const current = (0, exports.findJsxElementPathAtNodePath)(ast, nodePath);
864
+ return current ? getJsxElementNodeFromJsxPath(current) : null;
865
+ };
783
866
  exports.findJsxElementNodeAtNodePath = findJsxElementNodeAtNodePath;
784
867
  const findJsxChildrenAttribute = (jsxElement) => {
785
868
  const childrenAttr = jsxElement.attributes.find((attr) => {
@@ -1175,9 +1258,10 @@ const computeSequenceOnlyPropsRecord = ({ jsxElement, jsxElementNode, ast, keys,
1175
1258
  };
1176
1259
  const computeSequencePropsStatusFromAstAndIdentifiers = ({ ast, nodePath, componentIdentity, keys, assetKeys, effects, videoConfigIdentifierValues, }) => {
1177
1260
  var _a;
1178
- const jsxElementNode = (0, exports.findJsxElementNodeAtNodePath)(ast, nodePath);
1261
+ const jsxPath = (0, exports.findJsxElementPathAtNodePath)(ast, nodePath);
1262
+ const jsxElementNode = jsxPath ? getJsxElementNodeFromJsxPath(jsxPath) : null;
1179
1263
  const jsxElement = (_a = jsxElementNode === null || jsxElementNode === void 0 ? void 0 : jsxElementNode.openingElement) !== null && _a !== void 0 ? _a : null;
1180
- if (!jsxElement || !jsxElementNode) {
1264
+ if (!jsxPath || !jsxElement || !jsxElementNode) {
1181
1265
  throw new jsx_element_not_found_at_location_error_1.JsxElementNotFoundAtLocationError();
1182
1266
  }
1183
1267
  if (!(0, jsx_component_identity_1.jsxComponentIdentitiesMatch)({
@@ -1201,8 +1285,7 @@ const computeSequencePropsStatusFromAstAndIdentifiers = ({ ast, nodePath, compon
1201
1285
  videoConfigValues: videoConfigIdentifierValues,
1202
1286
  });
1203
1287
  const defaultKeyframeDisplayOffsetAdjustment = getDefaultFrameDisplayOffsetAdjustment({
1204
- jsxElement,
1205
- ast,
1288
+ jsxPath,
1206
1289
  videoConfigValues: videoConfigIdentifierValues,
1207
1290
  });
1208
1291
  const addDefaultKeyframeDisplayOffsetAdjustment = (status) => {
@@ -0,0 +1,3 @@
1
+ import type { DeleteEffectKeyframeRequest, DeleteEffectKeyframeResponse } from '@remotion/studio-shared';
2
+ import type { ApiHandler } from '../api-types';
3
+ export declare const deleteEffectKeyframeHandler: ApiHandler<DeleteEffectKeyframeRequest, DeleteEffectKeyframeResponse>;
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteEffectKeyframeHandler = void 0;
4
+ const node_fs_1 = require("node:fs");
5
+ const renderer_1 = require("@remotion/renderer");
6
+ const studio_shared_1 = require("@remotion/studio-shared");
7
+ const parse_ast_1 = require("../../codemods/parse-ast");
8
+ const update_keyframes_1 = require("../../codemods/update-keyframes/update-keyframes");
9
+ const file_watcher_1 = require("../../file-watcher");
10
+ const resolve_file_inside_project_1 = require("../../helpers/resolve-file-inside-project");
11
+ const undo_stack_1 = require("../undo-stack");
12
+ const watch_ignore_next_change_1 = require("../watch-ignore-next-change");
13
+ const can_update_effect_props_1 = require("./can-update-effect-props");
14
+ const can_update_sequence_props_1 = require("./can-update-sequence-props");
15
+ const log_effect_update_1 = require("./log-updates/log-effect-update");
16
+ const save_props_mutex_1 = require("./save-props-mutex");
17
+ const deleteEffectKeyframeHandler = ({ input: { fileName, sequenceNodePath, effectIndex, key, frame, schema, clientId, }, remotionRoot, logLevel, }) => (0, save_props_mutex_1.withSavePropsLock)(async () => {
18
+ renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[delete-effect-keyframe] Received request for fileName="${fileName}" effectIndex=${effectIndex} key="${key}" frame=${frame}`);
19
+ const { absolutePath, fileRelativeToRoot } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
20
+ remotionRoot,
21
+ fileName,
22
+ action: 'modify',
23
+ });
24
+ const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
25
+ const { output, oldValueStrings, newValueStrings, formatted, logLine, effectCallee, } = await (0, update_keyframes_1.updateEffectKeyframes)({
26
+ input: fileContents,
27
+ sequenceNodePath: sequenceNodePath.nodePath,
28
+ effectIndex,
29
+ updates: [
30
+ {
31
+ key,
32
+ operation: {
33
+ type: 'remove',
34
+ frame,
35
+ },
36
+ },
37
+ ],
38
+ });
39
+ const oldValueString = oldValueStrings[0];
40
+ const newValueString = newValueStrings[0];
41
+ const undoPropChange = `${key} keyframe restored at frame ${frame}`;
42
+ const redoPropChange = `${key} keyframe deleted at frame ${frame}`;
43
+ (0, undo_stack_1.pushToUndoStack)({
44
+ filePath: absolutePath,
45
+ oldContents: fileContents,
46
+ newContents: null,
47
+ logLevel,
48
+ remotionRoot,
49
+ logLine,
50
+ description: {
51
+ undoMessage: `↩️ ${undoPropChange}`,
52
+ redoMessage: `↪️ ${redoPropChange}`,
53
+ },
54
+ entryType: 'effect-props',
55
+ suppressHmrOnFileRestore: true,
56
+ });
57
+ (0, undo_stack_1.suppressUndoStackInvalidation)(absolutePath);
58
+ (0, watch_ignore_next_change_1.suppressBundlerUpdateForFile)(absolutePath);
59
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)(absolutePath, output, clientId);
60
+ (0, log_effect_update_1.logEffectUpdate)({
61
+ fileRelativeToRoot,
62
+ line: logLine,
63
+ effectName: effectCallee,
64
+ propKey: key,
65
+ oldValueString,
66
+ newValueString,
67
+ defaultValueString: null,
68
+ formatted,
69
+ logLevel,
70
+ removedProps: [],
71
+ addedProps: [],
72
+ });
73
+ (0, undo_stack_1.printUndoHint)(logLevel);
74
+ const ast = (0, parse_ast_1.parseAst)((0, node_fs_1.readFileSync)(absolutePath, 'utf-8'));
75
+ const jsx = (0, can_update_sequence_props_1.findJsxElementAtNodePath)(ast, sequenceNodePath.nodePath);
76
+ if (!jsx) {
77
+ return {
78
+ canUpdate: false,
79
+ effectIndex,
80
+ reason: 'not-found',
81
+ };
82
+ }
83
+ return (0, can_update_effect_props_1.computeEffectPropStatus)({
84
+ jsx,
85
+ effectIndex,
86
+ keys: (0, studio_shared_1.getAllSchemaKeys)(schema),
87
+ });
88
+ });
89
+ exports.deleteEffectKeyframeHandler = deleteEffectKeyframeHandler;
@@ -90,7 +90,7 @@ const deleteEffectHandler = ({ input: effects, remotionRoot, logLevel }) => {
90
90
  absolutePath: update.absolutePath,
91
91
  line: update.logLine,
92
92
  });
93
- renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} ${(0, formatting_1.strikeThroughOrRemovedPrefix)(deletedEffectDescription)}`);
93
+ renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${(0, source_file_write_queue_1.getCodemodTimingPrefix)(logLevel)}${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} ${(0, formatting_1.strikeThroughOrRemovedPrefix)(deletedEffectDescription)}`);
94
94
  if (!update.formatted) {
95
95
  (0, log_update_1.warnAboutPrettierOnce)(logLevel);
96
96
  }
@@ -87,7 +87,7 @@ const deleteJsxNodeHandler = ({ input: { nodes }, remotionRoot, logLevel }) => {
87
87
  absolutePath: update.absolutePath,
88
88
  line: update.logLine,
89
89
  });
90
- renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Deleted ${deletedNodeDescription}`);
90
+ renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${(0, source_file_write_queue_1.getCodemodTimingPrefix)(logLevel)}${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Deleted ${deletedNodeDescription}`);
91
91
  if (!update.formatted) {
92
92
  (0, log_update_1.warnAboutPrettierOnce)(logLevel);
93
93
  }
@@ -0,0 +1,3 @@
1
+ import type { DeleteSequenceKeyframeRequest, DeleteSequenceKeyframeResponse } from '@remotion/studio-shared';
2
+ import type { ApiHandler } from '../api-types';
3
+ export declare const deleteSequenceKeyframeHandler: ApiHandler<DeleteSequenceKeyframeRequest, DeleteSequenceKeyframeResponse>;
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteSequenceKeyframeHandler = void 0;
4
+ const node_fs_1 = require("node:fs");
5
+ const renderer_1 = require("@remotion/renderer");
6
+ const studio_shared_1 = require("@remotion/studio-shared");
7
+ const update_keyframes_1 = require("../../codemods/update-keyframes/update-keyframes");
8
+ const file_watcher_1 = require("../../file-watcher");
9
+ const resolve_file_inside_project_1 = require("../../helpers/resolve-file-inside-project");
10
+ const undo_stack_1 = require("../undo-stack");
11
+ const watch_ignore_next_change_1 = require("../watch-ignore-next-change");
12
+ const can_update_sequence_props_1 = require("./can-update-sequence-props");
13
+ const log_update_1 = require("./log-updates/log-update");
14
+ const save_props_mutex_1 = require("./save-props-mutex");
15
+ const deleteSequenceKeyframeHandler = ({ input: { fileName, nodePath, key, frame, schema, clientId }, remotionRoot, logLevel, }) => (0, save_props_mutex_1.withSavePropsLock)(async () => {
16
+ renderer_1.RenderInternals.Log.trace({ indent: false, logLevel }, `[delete-sequence-keyframe] Received request for fileName="${fileName}" key="${key}" frame=${frame}`);
17
+ const { absolutePath, fileRelativeToRoot } = (0, resolve_file_inside_project_1.resolveFileInsideProject)({
18
+ remotionRoot,
19
+ fileName,
20
+ action: 'modify',
21
+ });
22
+ const fileContents = (0, node_fs_1.readFileSync)(absolutePath, 'utf-8');
23
+ const { output, oldValueStrings, newValueStrings, formatted, logLine } = await (0, update_keyframes_1.updateSequenceKeyframes)({
24
+ input: fileContents,
25
+ nodePath: nodePath.nodePath,
26
+ updates: [
27
+ {
28
+ key,
29
+ operation: {
30
+ type: 'remove',
31
+ frame,
32
+ },
33
+ },
34
+ ],
35
+ });
36
+ const oldValueString = oldValueStrings[0];
37
+ const newValueString = newValueStrings[0];
38
+ const undoPropChange = `${key} keyframe restored at frame ${frame}`;
39
+ const redoPropChange = `${key} keyframe deleted at frame ${frame}`;
40
+ (0, undo_stack_1.pushToUndoStack)({
41
+ filePath: absolutePath,
42
+ oldContents: fileContents,
43
+ newContents: null,
44
+ logLevel,
45
+ remotionRoot,
46
+ logLine,
47
+ description: {
48
+ undoMessage: `↩️ ${undoPropChange}`,
49
+ redoMessage: `↪️ ${redoPropChange}`,
50
+ },
51
+ entryType: 'sequence-props',
52
+ suppressHmrOnFileRestore: true,
53
+ });
54
+ (0, undo_stack_1.suppressUndoStackInvalidation)(absolutePath);
55
+ (0, watch_ignore_next_change_1.suppressBundlerUpdateForFile)(absolutePath);
56
+ (0, file_watcher_1.writeFileAndNotifyFileWatchers)(absolutePath, output, clientId);
57
+ (0, log_update_1.logUpdate)({
58
+ fileRelativeToRoot,
59
+ line: logLine,
60
+ key,
61
+ oldValueString,
62
+ newValueString,
63
+ defaultValueString: null,
64
+ formatted,
65
+ logLevel,
66
+ removedProps: [],
67
+ addedProps: [],
68
+ });
69
+ (0, undo_stack_1.printUndoHint)(logLevel);
70
+ const status = (0, can_update_sequence_props_1.computeSequencePropsStatusFromContent)({
71
+ fileContents: output,
72
+ keys: (0, studio_shared_1.getAllSchemaKeys)(schema),
73
+ nodePath: nodePath.nodePath,
74
+ effects: [],
75
+ });
76
+ return {
77
+ canUpdate: true,
78
+ props: status.props,
79
+ results: [{ fileName, nodePath, props: status.props }],
80
+ };
81
+ });
82
+ exports.deleteSequenceKeyframeHandler = deleteSequenceKeyframeHandler;
@@ -84,7 +84,7 @@ const duplicateEffectHandler = ({ input: effects, remotionRoot, logLevel }) => {
84
84
  absolutePath: update.absolutePath,
85
85
  line: update.logLine,
86
86
  });
87
- renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Duplicated ${(0, formatting_1.attrName)(duplicatedEffectDescription)}`);
87
+ renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${(0, source_file_write_queue_1.getCodemodTimingPrefix)(logLevel)}${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Duplicated ${(0, formatting_1.attrName)(duplicatedEffectDescription)}`);
88
88
  if (!update.formatted) {
89
89
  (0, log_update_1.warnAboutPrettierOnce)(logLevel);
90
90
  }
@@ -56,7 +56,7 @@ const duplicateJsxNodeHandler = ({ input: { fileName, nodePath }, remotionRoot,
56
56
  absolutePath,
57
57
  line: logLine,
58
58
  });
59
- renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Duplicated ${nodeLabel}`);
59
+ renderer_1.RenderInternals.Log.info({ indent: false, logLevel }, `${(0, source_file_write_queue_1.getCodemodTimingPrefix)(logLevel)}${renderer_1.RenderInternals.chalk.blueBright(`${locationLabel}`)} Duplicated ${nodeLabel}`);
60
60
  if (!formatted) {
61
61
  (0, log_update_1.warnAboutPrettierOnce)(logLevel);
62
62
  }
@@ -25,7 +25,7 @@ export declare const getElementInstallPlan: ({ compositionFile, compositionId, e
25
25
  expectedFileState: ElementInstallExpectedFileState;
26
26
  filePath: string;
27
27
  importPath: string;
28
- location: import("../../helpers/resolve-composition-component").ResolvedCompositionComponentWithFile;
28
+ location: import("@remotion/studio-codemods").ResolvedCompositionComponentWithFile;
29
29
  safePaths: {
30
30
  compositionFileName: string;
31
31
  elementFileName: string;