@remotion/studio 4.0.519 → 4.0.520

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 (79) hide show
  1. package/dist/api/visual-control.js +2 -2
  2. package/dist/components/AudioWaveform.js +6 -1
  3. package/dist/components/Canvas.js +30 -36
  4. package/dist/components/CompositionSelector.js +6 -10
  5. package/dist/components/CompositionSelectorItem.js +7 -12
  6. package/dist/components/CurrentCompositionSideEffects.js +5 -0
  7. package/dist/components/ElementInstallConfirmation.d.ts +2 -23
  8. package/dist/components/ElementInstallConfirmation.js +16 -2
  9. package/dist/components/FpsCounter.js +1 -1
  10. package/dist/components/FramePersistor.js +1 -1
  11. package/dist/components/InspectorPanel/SequenceSelectionInspector.js +4 -3
  12. package/dist/components/InspectorPanel/use-composition-actions.js +5 -8
  13. package/dist/components/Modals.js +1 -1
  14. package/dist/components/NewComposition/NewComposition.js +2 -2
  15. package/dist/components/PlayPause.js +2 -13
  16. package/dist/components/PreviewToolbar.js +1 -1
  17. package/dist/components/QuickSwitcher/QuickSwitcherContent.js +29 -15
  18. package/dist/components/QuickSwitcher/QuickSwitcherResult.d.ts +14 -1
  19. package/dist/components/QuickSwitcher/QuickSwitcherResult.js +64 -9
  20. package/dist/components/QuickSwitcher/composition-search.d.ts +16 -0
  21. package/dist/components/QuickSwitcher/composition-search.js +136 -0
  22. package/dist/components/ResetZoomButton.js +17 -2
  23. package/dist/components/SelectedOutlineElement.js +10 -30
  24. package/dist/components/Timeline/Timeline.js +2 -1
  25. package/dist/components/Timeline/TimelineAssetField.js +1 -0
  26. package/dist/components/Timeline/TimelineDeleteKeybindings.js +5 -90
  27. package/dist/components/Timeline/TimelineDragHandler.js +18 -8
  28. package/dist/components/Timeline/TimelineInOutDragHandler.js +2 -3
  29. package/dist/components/Timeline/TimelinePinchZoom.js +14 -4
  30. package/dist/components/Timeline/TimelinePlayCursorSyncer.js +8 -4
  31. package/dist/components/Timeline/TimelineSequence.js +16 -41
  32. package/dist/components/Timeline/TimelineSequenceItem.js +14 -35
  33. package/dist/components/Timeline/TimelineSequenceRightEdgeDragHandle.js +3 -3
  34. package/dist/components/Timeline/TimelineSlider.js +2 -2
  35. package/dist/components/Timeline/TimelineWidthProvider.js +15 -8
  36. package/dist/components/Timeline/TimelineZoomControls.js +25 -8
  37. package/dist/components/Timeline/delete-selected-timeline-item.js +2 -2
  38. package/dist/components/Timeline/timeline-scroll-logic.d.ts +1 -0
  39. package/dist/components/Timeline/timeline-scroll-logic.js +21 -17
  40. package/dist/components/Timeline/use-delete-timeline-items.d.ts +1 -0
  41. package/dist/components/Timeline/use-delete-timeline-items.js +118 -0
  42. package/dist/components/Timeline/use-timeline-asset-drop.js +8 -14
  43. package/dist/components/WebMcp.js +61 -8
  44. package/dist/components/ZoomPersistor.js +2 -2
  45. package/dist/components/composition-drag-data.d.ts +36 -0
  46. package/dist/components/composition-drag-data.js +232 -0
  47. package/dist/components/drop-handler-data.d.ts +2 -1
  48. package/dist/components/drop-handler-data.js +6 -4
  49. package/dist/components/effect-drag-and-drop.d.ts +2 -5
  50. package/dist/components/handle-drop.js +6 -2
  51. package/dist/components/import-assets.d.ts +5 -13
  52. package/dist/error-overlay/current-error.d.ts +13 -0
  53. package/dist/error-overlay/current-error.js +21 -0
  54. package/dist/error-overlay/remotion-overlay/ErrorLoader.js +5 -1
  55. package/dist/esm/{chunk-1fkq5bfq.js → chunk-np6q13k5.js} +21571 -18952
  56. package/dist/esm/index.mjs +4 -1
  57. package/dist/esm/internals.mjs +17206 -14587
  58. package/dist/esm/previewEntry.mjs +19510 -16804
  59. package/dist/esm/renderEntry.mjs +1 -1
  60. package/dist/helpers/create-folder-tree.js +2 -5
  61. package/dist/helpers/document-title.d.ts +2 -0
  62. package/dist/helpers/document-title.js +14 -3
  63. package/dist/helpers/get-timeline-max-zoom.d.ts +34 -28
  64. package/dist/helpers/get-timeline-max-zoom.js +46 -29
  65. package/dist/helpers/install-fiber-sequence-order-observer.d.ts +37 -0
  66. package/dist/helpers/install-fiber-sequence-order-observer.js +109 -0
  67. package/dist/helpers/open-in-editor.js +2 -1
  68. package/dist/helpers/use-runtime-values.d.ts +1 -1
  69. package/dist/helpers/use-runtime-values.js +5 -4
  70. package/dist/helpers/use-sync-external-store.d.ts +3 -0
  71. package/dist/helpers/use-sync-external-store.js +5 -0
  72. package/dist/previewEntry.js +2 -0
  73. package/dist/state/modals.d.ts +18 -2
  74. package/dist/state/timeline-sequence-hover.js +3 -2
  75. package/dist/state/timeline-zoom.d.ts +0 -1
  76. package/dist/state/timeline-zoom.js +13 -6
  77. package/package.json +16 -16
  78. package/dist/helpers/sort-by-nonce-history.d.ts +0 -1
  79. package/dist/helpers/sort-by-nonce-history.js +0 -6
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.TimelineZoomControls = void 0;
37
37
  const jsx_runtime_1 = require("react/jsx-runtime");
38
+ const player_1 = require("@remotion/player");
38
39
  const react_1 = __importStar(require("react"));
39
40
  const remotion_1 = require("remotion");
40
41
  const colors_1 = require("../../helpers/colors");
@@ -45,6 +46,7 @@ const timeline_zoom_1 = require("../../state/timeline-zoom");
45
46
  const z_index_1 = require("../../state/z-index");
46
47
  const ControlButton_1 = require("../ControlButton");
47
48
  const layout_1 = require("../layout");
49
+ const timeline_refs_1 = require("./timeline-refs");
48
50
  const TIMELINE_ZOOM_BUTTON_FACTOR = 1.2;
49
51
  const container = {
50
52
  color: colors_1.BLACK,
@@ -55,10 +57,11 @@ const container = {
55
57
  const buttonStyle = {
56
58
  fontSize: 24,
57
59
  };
58
- const TimelineZoomSlider = ({ maxWidth, maxZoom }) => {
59
- var _a;
60
+ const TimelineZoomSlider = ({ maxWidth, minZoom, timelineViewportWidth }) => {
61
+ var _a, _b;
60
62
  const { canvasContent } = (0, react_1.useContext)(remotion_1.Internals.CompositionManager);
61
63
  const { setZoom, zoom: zoomMap } = (0, react_1.useContext)(timeline_zoom_1.TimelineZoomCtx);
64
+ const videoConfig = remotion_1.Internals.useUnsafeVideoConfig();
62
65
  const { tabIndex } = (0, z_index_1.useZIndex)();
63
66
  const isStill = (0, is_current_selected_still_1.useIsStill)();
64
67
  const onChange = (0, react_1.useCallback)((e) => {
@@ -67,26 +70,40 @@ const TimelineZoomSlider = ({ maxWidth, maxZoom }) => {
67
70
  }
68
71
  setZoom(canvasContent.compositionId, () => (0, get_timeline_max_zoom_1.sliderValueToTimelineZoom)({
69
72
  sliderValue: Number(e.target.value),
70
- maxZoom,
73
+ minZoom,
71
74
  }), {
72
75
  anchorFrame: null,
73
76
  anchorContentX: null,
74
77
  });
75
- }, [canvasContent, maxZoom, setZoom]);
78
+ }, [canvasContent, minZoom, setZoom]);
76
79
  if (isStill ||
77
80
  canvasContent === null ||
78
81
  canvasContent.type !== 'composition') {
79
82
  return null;
80
83
  }
81
- const zoom = (_a = zoomMap[canvasContent.compositionId]) !== null && _a !== void 0 ? _a : get_timeline_max_zoom_1.TIMELINE_MIN_ZOOM;
82
- return (jsx_runtime_1.jsx("input", { style: maxWidth === undefined ? undefined : { maxWidth }, title: `Timeline zoom (${zoom}x)`, alt: `Timeline zoom (${zoom}x)`, type: "range", min: get_timeline_max_zoom_1.TIMELINE_ZOOM_SLIDER_PROPS.min, max: get_timeline_max_zoom_1.TIMELINE_ZOOM_SLIDER_PROPS.max, step: get_timeline_max_zoom_1.TIMELINE_ZOOM_SLIDER_PROPS.step, value: (0, get_timeline_max_zoom_1.timelineZoomToSliderValue)({ zoom, maxZoom }), onChange: onChange, className: "__remotion-timeline-slider", tabIndex: tabIndex }));
84
+ const zoom = (0, get_timeline_max_zoom_1.getTimelineZoom)({
85
+ durationInFrames: (_a = videoConfig === null || videoConfig === void 0 ? void 0 : videoConfig.durationInFrames) !== null && _a !== void 0 ? _a : 1,
86
+ timelineViewportWidth,
87
+ zoom: (_b = zoomMap[canvasContent.compositionId]) !== null && _b !== void 0 ? _b : null,
88
+ });
89
+ const roundedZoom = Math.round(zoom * 100) / 100;
90
+ return (jsx_runtime_1.jsx("input", { style: maxWidth === undefined ? undefined : { maxWidth }, title: `Timeline zoom (${roundedZoom}px/frame)`, alt: `Timeline zoom (${roundedZoom}px/frame)`, type: "range", min: get_timeline_max_zoom_1.TIMELINE_ZOOM_SLIDER_PROPS.min, max: get_timeline_max_zoom_1.TIMELINE_ZOOM_SLIDER_PROPS.max, step: get_timeline_max_zoom_1.TIMELINE_ZOOM_SLIDER_PROPS.step, value: (0, get_timeline_max_zoom_1.timelineZoomToSliderValue)({ zoom, minZoom }), onChange: onChange, className: "__remotion-timeline-slider", tabIndex: tabIndex }));
83
91
  };
84
92
  const TimelineZoomControlsInner = ({ sliderMaxWidth }) => {
85
93
  var _a;
94
+ var _b, _c, _d;
86
95
  const { canvasContent } = (0, react_1.useContext)(remotion_1.Internals.CompositionManager);
87
96
  const { setZoom } = (0, react_1.useContext)(timeline_zoom_1.TimelineZoomCtx);
88
97
  const videoConfig = remotion_1.Internals.useUnsafeVideoConfig();
89
- const maxZoom = (0, get_timeline_max_zoom_1.getTimelineMaxZoom)((_a = videoConfig === null || videoConfig === void 0 ? void 0 : videoConfig.durationInFrames) !== null && _a !== void 0 ? _a : 1);
98
+ const timelineSize = player_1.PlayerInternals.useElementSize(timeline_refs_1.scrollableRef, {
99
+ triggerOnWindowResize: true,
100
+ shouldApplyCssTransforms: true,
101
+ });
102
+ const timelineViewportWidth = (_c = (_b = timelineSize === null || timelineSize === void 0 ? void 0 : timelineSize.width) !== null && _b !== void 0 ? _b : (_a = timeline_refs_1.scrollableRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth) !== null && _c !== void 0 ? _c : 0;
103
+ const minZoom = (0, get_timeline_max_zoom_1.getTimelineMinZoom)({
104
+ durationInFrames: (_d = videoConfig === null || videoConfig === void 0 ? void 0 : videoConfig.durationInFrames) !== null && _d !== void 0 ? _d : 1,
105
+ timelineViewportWidth,
106
+ });
90
107
  const onMinusClicked = (0, react_1.useCallback)(() => {
91
108
  if (canvasContent === null || canvasContent.type !== 'composition') {
92
109
  return;
@@ -106,7 +123,7 @@ const TimelineZoomControlsInner = ({ sliderMaxWidth }) => {
106
123
  return null;
107
124
  }
108
125
  return (jsx_runtime_1.jsxs("div", { style: container, children: [
109
- jsx_runtime_1.jsx(ControlButton_1.ControlButton, { onClick: onMinusClicked, style: buttonStyle, title: "Zoom out timeline", role: 'ControlButton', type: "button", children: (color) => jsx_runtime_1.jsx(canvas_zoom_1.CanvasZoomOutIcon, { color: color }) }), jsx_runtime_1.jsx(layout_1.Spacing, { x: 0.5 }), jsx_runtime_1.jsx(TimelineZoomSlider, { maxWidth: sliderMaxWidth, maxZoom: maxZoom }), jsx_runtime_1.jsx(layout_1.Spacing, { x: 0.5 }), jsx_runtime_1.jsx(ControlButton_1.ControlButton, { onClick: onPlusClicked, style: buttonStyle, title: "Zoom in timeline", role: 'button', type: "button", children: (color) => jsx_runtime_1.jsx(canvas_zoom_1.CanvasZoomIcon, { color: color }) })
126
+ jsx_runtime_1.jsx(ControlButton_1.ControlButton, { onClick: onMinusClicked, style: buttonStyle, title: "Zoom out timeline", role: 'ControlButton', type: "button", children: (color) => jsx_runtime_1.jsx(canvas_zoom_1.CanvasZoomOutIcon, { color: color }) }), jsx_runtime_1.jsx(layout_1.Spacing, { x: 0.5 }), jsx_runtime_1.jsx(TimelineZoomSlider, { maxWidth: sliderMaxWidth, minZoom: minZoom, timelineViewportWidth: timelineViewportWidth }), jsx_runtime_1.jsx(layout_1.Spacing, { x: 0.5 }), jsx_runtime_1.jsx(ControlButton_1.ControlButton, { onClick: onPlusClicked, style: buttonStyle, title: "Zoom in timeline", role: 'button', type: "button", children: (color) => jsx_runtime_1.jsx(canvas_zoom_1.CanvasZoomIcon, { color: color }) })
110
127
  ] }));
111
128
  };
112
129
  exports.TimelineZoomControls = react_1.default.memo(TimelineZoomControlsInner);
@@ -52,11 +52,11 @@ const deleteSequencesFromSource = async (nodePathInfos, confirm) => {
52
52
  if (!result.success) {
53
53
  (0, NotificationCenter_1.showNotification)(result.reason, 4000);
54
54
  }
55
- return true;
55
+ return result.success;
56
56
  })
57
57
  .catch((err) => {
58
58
  (0, NotificationCenter_1.showNotification)(err.message, 4000);
59
- return true;
59
+ return false;
60
60
  });
61
61
  };
62
62
  exports.deleteSequencesFromSource = deleteSequencesFromSource;
@@ -3,6 +3,7 @@ export declare const canScrollTimelineIntoDirection: () => {
3
3
  canScrollLeft: boolean;
4
4
  };
5
5
  export declare const SCROLL_INCREMENT = 200;
6
+ export declare const getTimelineContentWidth: () => number;
6
7
  export declare const EDGE_SCROLL_VERTICAL_INCREMENT = 60;
7
8
  export type TimelineEdgeScrollDirections = {
8
9
  x: 'left' | 'right' | null;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.prepareToPreserveTimelineCursor = exports.getScrollLeftToKeepCursorInPlace = exports.viewportClientXToScrollContentX = exports.getFrameFromTimelineDrop = exports.getFrameFromX = exports.getFrameWhileScrollingRight = exports.getFrameIncrementFromWidth = exports.getScrollPositionForCursorOnRightEdge = exports.getScrollPositionForCursorOnLeftEdge = exports.scrollToTimelineXOffset = exports.ensureFrameIsInViewport = exports.isCursorInViewport = exports.getFrameWhileScrollingLeft = exports.startTimelineEdgeAutoScroll = exports.EDGE_SCROLL_VERTICAL_INCREMENT = exports.SCROLL_INCREMENT = exports.canScrollTimelineIntoDirection = void 0;
3
+ exports.prepareToPreserveTimelineCursor = exports.getScrollLeftToKeepCursorInPlace = exports.viewportClientXToScrollContentX = exports.getFrameFromTimelineDrop = exports.getFrameFromX = exports.getFrameWhileScrollingRight = exports.getFrameIncrementFromWidth = exports.getScrollPositionForCursorOnRightEdge = exports.getScrollPositionForCursorOnLeftEdge = exports.scrollToTimelineXOffset = exports.ensureFrameIsInViewport = exports.isCursorInViewport = exports.getFrameWhileScrollingLeft = exports.startTimelineEdgeAutoScroll = exports.EDGE_SCROLL_VERTICAL_INCREMENT = exports.getTimelineContentWidth = exports.SCROLL_INCREMENT = exports.canScrollTimelineIntoDirection = void 0;
4
4
  const remotion_1 = require("remotion");
5
5
  const timeline_layout_1 = require("../../helpers/timeline-layout");
6
6
  const imperative_state_1 = require("./imperative-state");
@@ -15,6 +15,12 @@ const canScrollTimelineIntoDirection = () => {
15
15
  };
16
16
  exports.canScrollTimelineIntoDirection = canScrollTimelineIntoDirection;
17
17
  exports.SCROLL_INCREMENT = 200;
18
+ const getTimelineContentWidth = () => {
19
+ var _a, _b;
20
+ var _c, _d;
21
+ return ((_d = (_c = (_a = timeline_refs_1.sliderAreaRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth) !== null && _c !== void 0 ? _c : (_b = timeline_refs_1.scrollableRef.current) === null || _b === void 0 ? void 0 : _b.scrollWidth) !== null && _d !== void 0 ? _d : 0);
22
+ };
23
+ exports.getTimelineContentWidth = getTimelineContentWidth;
18
24
  exports.EDGE_SCROLL_VERTICAL_INCREMENT = 60;
19
25
  const EDGE_SCROLL_INTERVAL_MS = 100;
20
26
  // Once edge-scrolling has started, the pointer must move this many pixels
@@ -169,10 +175,10 @@ const getFrameWhileScrollingLeft = ({ durationInFrames, width, }) => {
169
175
  };
170
176
  exports.getFrameWhileScrollingLeft = getFrameWhileScrollingLeft;
171
177
  const isCursorInViewport = ({ frame, durationInFrames, }) => {
172
- var _a, _b;
173
- var _c, _d;
174
- const width = (_c = (_a = timeline_refs_1.scrollableRef.current) === null || _a === void 0 ? void 0 : _a.scrollWidth) !== null && _c !== void 0 ? _c : 0;
175
- const scrollLeft = (_d = (_b = timeline_refs_1.scrollableRef.current) === null || _b === void 0 ? void 0 : _b.scrollLeft) !== null && _d !== void 0 ? _d : 0;
178
+ var _a;
179
+ var _b;
180
+ const width = (0, exports.getTimelineContentWidth)();
181
+ const scrollLeft = (_b = (_a = timeline_refs_1.scrollableRef.current) === null || _a === void 0 ? void 0 : _a.scrollLeft) !== null && _b !== void 0 ? _b : 0;
176
182
  const scrollPosOnRightEdge = (0, exports.getScrollPositionForCursorOnRightEdge)({
177
183
  nextFrame: frame,
178
184
  durationInFrames,
@@ -194,14 +200,14 @@ const isCursorInViewport = ({ frame, durationInFrames, }) => {
194
200
  };
195
201
  exports.isCursorInViewport = isCursorInViewport;
196
202
  const ensureFrameIsInViewport = ({ direction, durationInFrames, frame, }) => {
197
- var _a, _b, _c;
198
- var _d, _e;
203
+ var _a, _b;
204
+ var _c;
199
205
  // Sync the imperative frame first: scrolling below triggers the scroll
200
206
  // listener in TimelineSlider, which reads the frame imperatively.
201
207
  (0, imperative_state_1.setCurrentFrame)(frame);
202
208
  (_a = TimelineSlider_1.redrawTimelineSliderFast.current) === null || _a === void 0 ? void 0 : _a.draw(frame);
203
- const width = (_d = (_b = timeline_refs_1.scrollableRef.current) === null || _b === void 0 ? void 0 : _b.scrollWidth) !== null && _d !== void 0 ? _d : 0;
204
- const scrollLeft = (_e = (_c = timeline_refs_1.scrollableRef.current) === null || _c === void 0 ? void 0 : _c.scrollLeft) !== null && _e !== void 0 ? _e : 0;
209
+ const width = (0, exports.getTimelineContentWidth)();
210
+ const scrollLeft = (_c = (_b = timeline_refs_1.scrollableRef.current) === null || _b === void 0 ? void 0 : _b.scrollLeft) !== null && _c !== void 0 ? _c : 0;
205
211
  if (direction === 'fit-left') {
206
212
  const currentFrameLeft = (0, exports.getFrameFromX)({
207
213
  clientX: scrollLeft,
@@ -281,22 +287,20 @@ const getScrollPositionForCursorOnLeftEdge = ({ nextFrame, durationInFrames, })
281
287
  };
282
288
  exports.getScrollPositionForCursorOnLeftEdge = getScrollPositionForCursorOnLeftEdge;
283
289
  const getScrollPositionForCursorOnRightEdge = ({ nextFrame, durationInFrames, }) => {
284
- var _a, _b;
290
+ var _a;
285
291
  const frameIncrement = getFrameIncrement(durationInFrames);
286
292
  const framesRemaining = durationInFrames - 1 - nextFrame;
287
293
  const fromRight = framesRemaining * frameIncrement + timeline_layout_1.TIMELINE_PADDING;
288
- const scrollPos = ((_a = timeline_refs_1.scrollableRef.current) === null || _a === void 0 ? void 0 : _a.scrollWidth) -
294
+ const scrollPos = (0, exports.getTimelineContentWidth)() -
289
295
  fromRight -
290
- ((_b = timeline_refs_1.scrollableRef.current) === null || _b === void 0 ? void 0 : _b.clientWidth) +
296
+ ((_a = timeline_refs_1.scrollableRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth) +
291
297
  timeline_layout_1.TIMELINE_PADDING +
292
298
  4; // clearfix;
293
299
  return scrollPos;
294
300
  };
295
301
  exports.getScrollPositionForCursorOnRightEdge = getScrollPositionForCursorOnRightEdge;
296
302
  const getFrameIncrement = (durationInFrames) => {
297
- var _a;
298
- var _b;
299
- const width = (_b = (_a = timeline_refs_1.scrollableRef.current) === null || _a === void 0 ? void 0 : _a.scrollWidth) !== null && _b !== void 0 ? _b : 0;
303
+ const width = (0, exports.getTimelineContentWidth)();
300
304
  return (0, exports.getFrameIncrementFromWidth)(durationInFrames, width);
301
305
  };
302
306
  const getFrameIncrementFromWidth = (durationInFrames, width) => {
@@ -366,7 +370,7 @@ const prepareToPreserveTimelineCursor = ({ currentFrame, currentDurationInFrames
366
370
  if (!current) {
367
371
  return () => undefined;
368
372
  }
369
- const oldTimelineWidth = current.scrollWidth;
373
+ const oldTimelineWidth = (0, exports.getTimelineContentWidth)();
370
374
  const oldScrollLeft = current.scrollLeft;
371
375
  const frameIncrement = (0, exports.getFrameIncrementFromWidth)(currentDurationInFrames, oldTimelineWidth);
372
376
  const frameForScroll = anchorFrame !== null && anchorFrame !== void 0 ? anchorFrame : currentFrame;
@@ -381,7 +385,7 @@ const prepareToPreserveTimelineCursor = ({ currentFrame, currentDurationInFrames
381
385
  anchorContentX: prevCursorPosition,
382
386
  oldScrollLeft,
383
387
  oldTimelineWidth,
384
- newTimelineWidth: current.scrollWidth,
388
+ newTimelineWidth: (0, exports.getTimelineContentWidth)(),
385
389
  });
386
390
  };
387
391
  };
@@ -0,0 +1 @@
1
+ export declare const useDeleteTimelineItems: () => (selectedItemsOverride: readonly import("@remotion/canvas").CanvasSelectionItem[] | null) => void;
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useDeleteTimelineItems = void 0;
4
+ const studio_shared_1 = require("@remotion/studio-shared");
5
+ const react_1 = require("react");
6
+ const remotion_1 = require("remotion");
7
+ const client_id_1 = require("../../helpers/client-id");
8
+ const editor_guides_1 = require("../../state/editor-guides");
9
+ const ConfirmationDialog_1 = require("../ConfirmationDialog");
10
+ const delete_selected_timeline_item_1 = require("./delete-selected-timeline-item");
11
+ const imperative_state_1 = require("./imperative-state");
12
+ const reset_selected_timeline_props_1 = require("./reset-selected-timeline-props");
13
+ const TimelineSelection_1 = require("./TimelineSelection");
14
+ const update_selected_easing_1 = require("./update-selected-easing");
15
+ const useDeleteTimelineItems = () => {
16
+ const { previewServerState } = (0, react_1.useContext)(client_id_1.StudioServerConnectionCtx);
17
+ const sequencesRef = (0, react_1.useContext)(remotion_1.Internals.SequenceManagerRefContext);
18
+ const { overrideIdToNodePathMappings } = (0, react_1.useContext)(remotion_1.Internals.OverrideIdsToNodePathsGettersContext);
19
+ const propStatusesRef = (0, react_1.useContext)(remotion_1.Internals.VisualModePropStatusesRefContext);
20
+ const { setPropStatuses } = (0, react_1.useContext)(remotion_1.Internals.VisualModeSettersContext);
21
+ const { setGuidesList } = (0, react_1.useContext)(editor_guides_1.EditorShowGuidesContext);
22
+ const currentSelection = (0, TimelineSelection_1.useCurrentTimelineSelectionStateAsRef)();
23
+ const confirm = (0, ConfirmationDialog_1.useConfirmationDialog)();
24
+ return (0, react_1.useCallback)((selectedItemsOverride) => {
25
+ if (previewServerState.type !== 'connected') {
26
+ return;
27
+ }
28
+ const { clientId } = previewServerState;
29
+ const { selectedItems: currentSelectedItems, clearSelection, selectItems, } = currentSelection.current;
30
+ const selectedItems = selectedItemsOverride !== null && selectedItemsOverride !== void 0 ? selectedItemsOverride : currentSelectedItems;
31
+ const sequences = sequencesRef.current;
32
+ const propStatuses = propStatusesRef.current;
33
+ const timelinePosition = (0, imperative_state_1.getCurrentFrame)();
34
+ if (selectedItems.length === 0) {
35
+ return;
36
+ }
37
+ const selectedGuide = selectedItems.find((item) => item.type === 'guide');
38
+ if (selectedGuide) {
39
+ setGuidesList((prevGuides) => {
40
+ const newGuides = prevGuides.filter((guide) => guide.id !== selectedGuide.guideId);
41
+ (0, editor_guides_1.persistGuidesList)(newGuides);
42
+ return newGuides;
43
+ });
44
+ clearSelection();
45
+ return;
46
+ }
47
+ const deletePromise = (0, delete_selected_timeline_item_1.deleteSelectedTimelineItems)({
48
+ selections: selectedItems,
49
+ sequences,
50
+ overrideIdsToNodePaths: overrideIdToNodePathMappings,
51
+ setPropStatuses,
52
+ clientId,
53
+ confirm,
54
+ propStatuses,
55
+ timelinePosition,
56
+ });
57
+ if (deletePromise !== null) {
58
+ deletePromise
59
+ .then((deleted) => {
60
+ if (!deleted) {
61
+ return;
62
+ }
63
+ const nextSelection = (0, delete_selected_timeline_item_1.getTimelineSelectionAfterDeletingItems)({
64
+ selections: selectedItems,
65
+ sequences,
66
+ overrideIdsToNodePaths: overrideIdToNodePathMappings,
67
+ propStatuses,
68
+ timelinePosition,
69
+ });
70
+ if (nextSelection.length === 0) {
71
+ clearSelection();
72
+ }
73
+ else {
74
+ selectItems(nextSelection);
75
+ }
76
+ })
77
+ .catch(() => undefined);
78
+ return;
79
+ }
80
+ const easingSelections = (0, update_selected_easing_1.getEasingSelections)(selectedItems);
81
+ if (easingSelections.length === selectedItems.length) {
82
+ const resetEasingPromise = (0, update_selected_easing_1.updateSelectedTimelineEasings)({
83
+ selections: easingSelections,
84
+ sequences,
85
+ overrideIdsToNodePaths: overrideIdToNodePathMappings,
86
+ propStatuses,
87
+ setPropStatuses,
88
+ clientId,
89
+ easing: studio_shared_1.LINEAR_KEYFRAME_EASING,
90
+ });
91
+ if (resetEasingPromise !== null) {
92
+ resetEasingPromise.catch(() => undefined);
93
+ return;
94
+ }
95
+ }
96
+ const resetPromise = (0, reset_selected_timeline_props_1.resetSelectedTimelineProps)({
97
+ selections: selectedItems,
98
+ sequences,
99
+ overrideIdsToNodePaths: overrideIdToNodePathMappings,
100
+ propStatuses,
101
+ setPropStatuses,
102
+ clientId,
103
+ });
104
+ if (resetPromise !== null) {
105
+ resetPromise.catch(() => undefined);
106
+ }
107
+ }, [
108
+ confirm,
109
+ currentSelection,
110
+ overrideIdToNodePathMappings,
111
+ previewServerState,
112
+ propStatusesRef,
113
+ sequencesRef,
114
+ setGuidesList,
115
+ setPropStatuses,
116
+ ]);
117
+ };
118
+ exports.useDeleteTimelineItems = useDeleteTimelineItems;
@@ -17,15 +17,8 @@ const imperative_state_1 = require("./imperative-state");
17
17
  const timeline_refs_1 = require("./timeline-refs");
18
18
  const timeline_scroll_logic_1 = require("./timeline-scroll-logic");
19
19
  const use_resolved_stack_1 = require("./use-resolved-stack");
20
- const isEventInsideElement = (event, element) => {
21
- if (event.target instanceof Node && element.contains(event.target)) {
22
- return true;
23
- }
24
- const rect = element.getBoundingClientRect();
25
- return (event.clientX >= rect.left &&
26
- event.clientX <= rect.right &&
27
- event.clientY >= rect.top &&
28
- event.clientY <= rect.bottom);
20
+ const isEventTargetInsideElement = (event, element) => {
21
+ return event.target instanceof Node && element.contains(event.target);
29
22
  };
30
23
  const useTimelineAssetDrop = () => {
31
24
  var _a, _b;
@@ -60,13 +53,14 @@ const useTimelineAssetDrop = () => {
60
53
  return null;
61
54
  }
62
55
  const scrollable = timeline_refs_1.scrollableRef.current;
63
- return scrollable !== null && isEventInsideElement(event, scrollable)
56
+ return scrollable !== null &&
57
+ isEventTargetInsideElement(event, scrollable)
64
58
  ? (0, timeline_scroll_logic_1.getFrameFromTimelineDrop)({
65
59
  clientX: event.clientX,
66
60
  durationInFrames: videoConfig.durationInFrames,
67
61
  scrollLeft: scrollable.scrollLeft,
68
62
  timelineLeft: scrollable.getBoundingClientRect().left,
69
- timelineWidth: scrollable.scrollWidth,
63
+ timelineWidth: (0, timeline_scroll_logic_1.getTimelineContentWidth)(),
70
64
  })
71
65
  : (0, imperative_state_1.getCurrentFrame)();
72
66
  }, [videoConfig]);
@@ -76,7 +70,7 @@ const useTimelineAssetDrop = () => {
76
70
  if (timeline === null ||
77
71
  dataTransfer === null ||
78
72
  !(0, drop_handler_data_1.isSupportedDropEvent)(event) ||
79
- !isEventInsideElement(event, timeline)) {
73
+ !isEventTargetInsideElement(event, timeline)) {
80
74
  setAssetDropFrame(null);
81
75
  return;
82
76
  }
@@ -86,7 +80,7 @@ const useTimelineAssetDrop = () => {
86
80
  const scrollable = timeline_refs_1.scrollableRef.current;
87
81
  const shouldShowDropFrame = canInsertAsset &&
88
82
  scrollable !== null &&
89
- isEventInsideElement(event, scrollable);
83
+ isEventTargetInsideElement(event, scrollable);
90
84
  setAssetDropFrame(shouldShowDropFrame ? getDropFrame(event) : null);
91
85
  }, [canInsertAsset, getDropFrame]);
92
86
  const onAssetDrop = (0, react_1.useCallback)(async (event) => {
@@ -96,7 +90,7 @@ const useTimelineAssetDrop = () => {
96
90
  if (timeline === null ||
97
91
  dataTransfer === null ||
98
92
  !(0, drop_handler_data_1.isSupportedDropEvent)(event) ||
99
- !isEventInsideElement(event, timeline)) {
93
+ !isEventTargetInsideElement(event, timeline)) {
100
94
  return;
101
95
  }
102
96
  const localFiles = (0, drop_handler_data_1.isFileDragEvent)(event)
@@ -6,6 +6,7 @@ const remotion_1 = require("remotion");
6
6
  const pause_1 = require("../api/pause");
7
7
  const play_1 = require("../api/play");
8
8
  const seek_1 = require("../api/seek");
9
+ const current_error_1 = require("../error-overlay/current-error");
9
10
  const calculate_timeline_1 = require("../helpers/calculate-timeline");
10
11
  const create_folder_tree_1 = require("../helpers/create-folder-tree");
11
12
  const format_file_location_1 = require("../helpers/format-file-location");
@@ -21,6 +22,7 @@ const find_track_for_node_path_info_1 = require("./Timeline/find-track-for-node-
21
22
  const imperative_state_1 = require("./Timeline/imperative-state");
22
23
  const parse_keyframe_field_from_node_path_1 = require("./Timeline/parse-keyframe-field-from-node-path");
23
24
  const should_show_track_in_timeline_1 = require("./Timeline/should-show-track-in-timeline");
25
+ const timeline_refs_1 = require("./Timeline/timeline-refs");
24
26
  const TimelineSelection_1 = require("./Timeline/TimelineSelection");
25
27
  const get_stack_1 = require("./Timeline/TimelineStack/get-stack");
26
28
  const use_resolved_stack_react_to_change_1 = require("./Timeline/use-resolved-stack-react-to-change");
@@ -64,7 +66,7 @@ const WebMcp = () => {
64
66
  const { canSelect, clearSelection, selectedItems, selectItems } = (0, TimelineSelection_1.useTimelineSelection)();
65
67
  const { canvasContent, compositions, currentCompositionMetadata, folders } = (0, react_1.useContext)(remotion_1.Internals.CompositionManager);
66
68
  const { playbackRate: currentPlaybackRate, setPlaybackRate } = remotion_1.Internals.usePlaybackRate();
67
- const [, , imperativePlaying] = remotion_1.Internals.Timeline.usePlayingState();
69
+ const { isPlaying } = remotion_1.Internals.Timeline.useTimelineContext();
68
70
  const { mediaVolume, playerMuted } = (0, react_1.useContext)(remotion_1.Internals.MediaVolumeContext);
69
71
  const { setPlayerMuted } = (0, react_1.useContext)(remotion_1.Internals.SetMediaVolumeContext);
70
72
  const { setZoom: setTimelineZoom, zoom: timelineZoomMap } = (0, react_1.useContext)(timeline_zoom_1.TimelineZoomCtx);
@@ -201,6 +203,38 @@ const WebMcp = () => {
201
203
  }).filter((timelineTrack) => (0, should_show_track_in_timeline_1.shouldShowTrackInTimeline)(timelineTrack, durationInFrames));
202
204
  };
203
205
  Promise.all([
206
+ modelContext.registerTool({
207
+ name: 'get_current_error',
208
+ title: 'Get current Studio error',
209
+ description: 'Read the error currently shown in the Remotion Studio error overlay. Returns null when the overlay is not visible and includes symbolicated stack frames when symbolication succeeds.',
210
+ inputSchema: {
211
+ type: 'object',
212
+ properties: {},
213
+ additionalProperties: false,
214
+ },
215
+ annotations: { readOnlyHint: true },
216
+ execute: async () => {
217
+ var _a, _b;
218
+ const currentError = (0, current_error_1.getCurrentError)();
219
+ if (currentError === null) {
220
+ return null;
221
+ }
222
+ let symbolicatedStackFrames = null;
223
+ try {
224
+ const record = await currentError.symbolication;
225
+ symbolicatedStackFrames = (_a = record === null || record === void 0 ? void 0 : record.stackFrames) !== null && _a !== void 0 ? _a : null;
226
+ }
227
+ catch (_c) {
228
+ // Fall back to the original stack if symbolication fails.
229
+ }
230
+ return {
231
+ name: currentError.error.name,
232
+ message: currentError.error.message,
233
+ stack: (_b = currentError.error.stack) !== null && _b !== void 0 ? _b : null,
234
+ symbolicatedStackFrames,
235
+ };
236
+ },
237
+ }, { signal: controller.signal }),
204
238
  modelContext.registerTool({
205
239
  name: 'get_compositions',
206
240
  title: 'Get Studio compositions',
@@ -496,6 +530,7 @@ const WebMcp = () => {
496
530
  annotations: { readOnlyHint: true },
497
531
  execute: () => {
498
532
  var _a;
533
+ var _b, _c;
499
534
  const compositionId = currentCompositionRef.current;
500
535
  if (compositionId === null) {
501
536
  return Promise.resolve({
@@ -509,17 +544,28 @@ const WebMcp = () => {
509
544
  timelineZoom: null,
510
545
  });
511
546
  }
547
+ const durationInFrames = (0, imperative_state_1.getCurrentDuration)();
548
+ const timelineViewportWidth = (_b = (_a = timeline_refs_1.scrollableRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth) !== null && _b !== void 0 ? _b : 0;
549
+ const minZoom = (0, get_timeline_max_zoom_1.getTimelineMinZoom)({
550
+ durationInFrames,
551
+ timelineViewportWidth,
552
+ });
553
+ const timelineZoom = (0, get_timeline_max_zoom_1.getTimelineZoom)({
554
+ durationInFrames,
555
+ timelineViewportWidth,
556
+ zoom: (_c = timelineZoomRef.current[compositionId]) !== null && _c !== void 0 ? _c : null,
557
+ });
512
558
  return Promise.resolve({
513
559
  currentComposition: compositionId,
514
560
  currentFrame: (0, imperative_state_1.getCurrentFrame)(),
515
- playing: imperativePlaying.current,
561
+ playing: isPlaying(),
516
562
  muted: playerMutedRef.current,
517
563
  volume: mediaVolumeRef.current,
518
564
  playbackRate: playbackRateRef.current,
519
565
  looping: (0, loop_1.loadLoopOption)(),
520
566
  timelineZoom: (0, get_timeline_max_zoom_1.timelineZoomToNormalized)({
521
- zoom: (_a = timelineZoomRef.current[compositionId]) !== null && _a !== void 0 ? _a : get_timeline_max_zoom_1.TIMELINE_MIN_ZOOM,
522
- maxZoom: (0, get_timeline_max_zoom_1.getTimelineMaxZoom)((0, imperative_state_1.getCurrentDuration)()),
567
+ zoom: timelineZoom,
568
+ minZoom,
523
569
  }),
524
570
  });
525
571
  },
@@ -823,6 +869,8 @@ const WebMcp = () => {
823
869
  },
824
870
  annotations: { readOnlyHint: false },
825
871
  execute: ({ zoom }) => {
872
+ var _a;
873
+ var _b;
826
874
  if (typeof zoom !== 'number' ||
827
875
  !Number.isFinite(zoom) ||
828
876
  zoom < 0 ||
@@ -837,13 +885,18 @@ const WebMcp = () => {
837
885
  if (durationInFrames <= 1) {
838
886
  throw new Error('The current composition is a still and has no timeline zoom.');
839
887
  }
840
- const maxZoom = (0, get_timeline_max_zoom_1.getTimelineMaxZoom)(durationInFrames);
888
+ const timelineViewportWidth = (_b = (_a = timeline_refs_1.scrollableRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth) !== null && _b !== void 0 ? _b : 0;
889
+ const minZoom = (0, get_timeline_max_zoom_1.getTimelineMinZoom)({
890
+ durationInFrames,
891
+ timelineViewportWidth,
892
+ });
841
893
  const timelineZoom = (0, get_timeline_max_zoom_1.clampTimelineZoom)({
842
894
  zoom: (0, get_timeline_max_zoom_1.normalizedToTimelineZoom)({
843
895
  normalized: zoom,
844
- maxZoom,
896
+ minZoom,
845
897
  }),
846
898
  durationInFrames,
899
+ timelineViewportWidth,
847
900
  });
848
901
  setTimelineZoom(compositionId, () => timelineZoom, {
849
902
  anchorFrame: null,
@@ -853,7 +906,7 @@ const WebMcp = () => {
853
906
  currentComposition: compositionId,
854
907
  timelineZoom: (0, get_timeline_max_zoom_1.timelineZoomToNormalized)({
855
908
  zoom: timelineZoom,
856
- maxZoom,
909
+ minZoom,
857
910
  }),
858
911
  });
859
912
  },
@@ -931,7 +984,7 @@ const WebMcp = () => {
931
984
  };
932
985
  }, [
933
986
  clearSelection,
934
- imperativePlaying,
987
+ isPlaying,
935
988
  selectComposition,
936
989
  selectItems,
937
990
  setEditorShowGuides,
@@ -6,7 +6,7 @@ const remotion_1 = require("remotion");
6
6
  const timeline_zoom_1 = require("../state/timeline-zoom");
7
7
  const load_canvas_content_from_url_1 = require("./load-canvas-content-from-url");
8
8
  const makeKey = () => {
9
- return `remotion.zoom-map`;
9
+ return `remotion.zoom-map-pixels-per-frame`;
10
10
  };
11
11
  const persistCurrentZoom = (zoom) => {
12
12
  localStorage.setItem(makeKey(), JSON.stringify(zoom));
@@ -17,7 +17,7 @@ const getZoomFromLocalStorage = () => {
17
17
  };
18
18
  exports.getZoomFromLocalStorage = getZoomFromLocalStorage;
19
19
  const ZoomPersistor = () => {
20
- const [playing] = remotion_1.Internals.Timeline.usePlayingState();
20
+ const playing = remotion_1.Internals.usePlaying();
21
21
  const { zoom } = (0, react_1.useContext)(timeline_zoom_1.TimelineZoomCtx);
22
22
  const { canvasContent } = (0, react_1.useContext)(remotion_1.Internals.CompositionManager);
23
23
  const urlState = (0, load_canvas_content_from_url_1.deriveCanvasContentFromUrl)();
@@ -0,0 +1,36 @@
1
+ import type { SymbolicatedStackFrame } from '@remotion/studio-shared';
2
+ export type CompositionDragData = {
3
+ readonly type: 'remotion-composition';
4
+ readonly version: 1;
5
+ readonly compositionId: string;
6
+ readonly compositionFile: string | null;
7
+ };
8
+ export type CompositionDragPreviewMetadata = {
9
+ readonly type: 'composition';
10
+ readonly width: number | null;
11
+ readonly height: number | null;
12
+ readonly durationInFrames: number | null;
13
+ readonly mimeType: string;
14
+ };
15
+ type MakeCompositionDragDataInput = {
16
+ readonly compositionFile: string | null;
17
+ readonly compositionId: string;
18
+ readonly width: number | null;
19
+ readonly height: number | null;
20
+ readonly durationInFrames: number | null;
21
+ };
22
+ type SerializedCompositionDragData = {
23
+ readonly mimeType: string;
24
+ readonly payload: string;
25
+ };
26
+ type CompositionDragDataTransfer = {
27
+ readonly types: ArrayLike<string>;
28
+ readonly getData: (mimeType: string) => string;
29
+ };
30
+ export declare const makeCompositionDragData: ({ compositionFile, compositionId, width, height, durationInFrames, }: MakeCompositionDragDataInput) => SerializedCompositionDragData & {
31
+ readonly data: CompositionDragData;
32
+ };
33
+ export declare const getCompositionDragPreviewMetadata: (mimeTypes: ArrayLike<string>) => CompositionDragPreviewMetadata | null;
34
+ export declare const parseCompositionDragData: (source: CompositionDragDataTransfer | SerializedCompositionDragData) => CompositionDragData | null;
35
+ export declare const compositionDragDataToSymbolicatedStack: (dragData: CompositionDragData) => SymbolicatedStackFrame | null;
36
+ export {};