@remotion/studio 4.0.444 → 4.0.446

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 (35) hide show
  1. package/dist/components/AssetSelectorItem.js +11 -1
  2. package/dist/components/Canvas.js +197 -42
  3. package/dist/components/CanvasOrLoading.js +4 -4
  4. package/dist/components/CompositionSelectorItem.js +15 -1
  5. package/dist/components/FilePreview.js +3 -0
  6. package/dist/components/InitialCompositionLoader.js +10 -4
  7. package/dist/components/Preview.d.ts +1 -0
  8. package/dist/components/Preview.js +14 -1
  9. package/dist/components/Timeline/Timeline.js +8 -5
  10. package/dist/components/Timeline/TimelineListItem.js +53 -2
  11. package/dist/components/Timeline/TimelinePinchZoom.d.ts +2 -0
  12. package/dist/components/Timeline/TimelinePinchZoom.js +240 -0
  13. package/dist/components/Timeline/TimelineSlider.js +22 -8
  14. package/dist/components/Timeline/TimelineZoomControls.js +6 -3
  15. package/dist/components/Timeline/timeline-scroll-logic.d.ts +13 -1
  16. package/dist/components/Timeline/timeline-scroll-logic.js +20 -6
  17. package/dist/components/Timeline/use-sequence-props-subscription.d.ts +4 -1
  18. package/dist/components/Timeline/use-sequence-props-subscription.js +10 -1
  19. package/dist/error-overlay/remotion-overlay/ErrorDisplay.js +1 -1
  20. package/dist/error-overlay/remotion-overlay/Retry.d.ts +1 -0
  21. package/dist/error-overlay/remotion-overlay/Retry.js +2 -2
  22. package/dist/esm/{chunk-1zvzzrkf.js → chunk-2dkkw8x5.js} +6255 -5577
  23. package/dist/esm/internals.mjs +6255 -5577
  24. package/dist/esm/previewEntry.mjs +2250 -1574
  25. package/dist/esm/renderEntry.mjs +1 -1
  26. package/dist/helpers/get-asset-metadata.d.ts +3 -0
  27. package/dist/helpers/get-asset-metadata.js +51 -43
  28. package/dist/helpers/get-effective-translation.d.ts +13 -1
  29. package/dist/helpers/get-effective-translation.js +45 -1
  30. package/dist/helpers/sidebar-scroll-into-view.d.ts +13 -0
  31. package/dist/helpers/sidebar-scroll-into-view.js +83 -0
  32. package/dist/helpers/use-studio-canvas-dimensions.js +3 -1
  33. package/dist/state/timeline-zoom.d.ts +5 -1
  34. package/dist/state/timeline-zoom.js +21 -16
  35. package/package.json +9 -9
@@ -44,6 +44,7 @@ const no_react_1 = require("remotion/no-react");
44
44
  const colors_1 = require("../helpers/colors");
45
45
  const copy_text_1 = require("../helpers/copy-text");
46
46
  const mobile_layout_1 = require("../helpers/mobile-layout");
47
+ const sidebar_scroll_into_view_1 = require("../helpers/sidebar-scroll-into-view");
47
48
  const url_state_1 = require("../helpers/url-state");
48
49
  const use_asset_drag_events_1 = __importDefault(require("../helpers/use-asset-drag-events"));
49
50
  const clipboard_1 = require("../icons/clipboard");
@@ -173,7 +174,16 @@ const AssetSelectorItem = ({ item, tabIndex, level, parentFolder, readOnlyStudio
173
174
  const onPointerLeave = (0, react_1.useCallback)(() => {
174
175
  setHovered(false);
175
176
  }, []);
177
+ const rowRef = (0, react_1.useRef)(null);
178
+ (0, react_1.useLayoutEffect)(() => {
179
+ (0, sidebar_scroll_into_view_1.maybeScrollAssetSidebarRowIntoView)({
180
+ element: rowRef.current,
181
+ assetPath: relativePath,
182
+ selected,
183
+ });
184
+ }, [relativePath, selected]);
176
185
  const onClick = (0, react_1.useCallback)(() => {
186
+ (0, sidebar_scroll_into_view_1.markAssetSidebarScrollFromRowClick)(relativePath);
177
187
  setCanvasContent({ type: 'asset', asset: relativePath });
178
188
  (0, url_state_1.pushUrl)(`/assets/${relativePath}`);
179
189
  if (isMobileLayout) {
@@ -234,7 +244,7 @@ const AssetSelectorItem = ({ item, tabIndex, level, parentFolder, readOnlyStudio
234
244
  (0, NotificationCenter_1.showNotification)(`Could not copy: ${err.message}`, 2000);
235
245
  });
236
246
  }, [item.name, parentFolder]);
237
- return (jsx_runtime_1.jsx(layout_1.Row, { align: "center", children: jsx_runtime_1.jsxs("div", { style: style, onPointerEnter: onPointerEnter, onPointerLeave: onPointerLeave, onClick: onClick, tabIndex: tabIndex, title: item.name, children: [
247
+ return (jsx_runtime_1.jsx(layout_1.Row, { align: "center", children: jsx_runtime_1.jsxs("div", { ref: rowRef, style: style, onPointerEnter: onPointerEnter, onPointerLeave: onPointerLeave, onClick: onClick, tabIndex: tabIndex, title: item.name, children: [
238
248
  jsx_runtime_1.jsx(file_1.FileIcon, { style: iconStyle, color: colors_1.LIGHT_TEXT }), jsx_runtime_1.jsx(layout_1.Spacing, { x: 1 }), jsx_runtime_1.jsx("div", { style: label, children: item.name }), hovered ? (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [
239
249
  jsx_runtime_1.jsx(layout_1.Spacing, { x: 0.5 }), jsx_runtime_1.jsx(InlineAction_1.InlineAction, { title: "Copy staticFile() name", renderAction: renderCopyAction, onClick: copyToClipboard }), readOnlyStudio ? null : (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [
240
250
  jsx_runtime_1.jsx(layout_1.Spacing, { x: 0.5 }), jsx_runtime_1.jsx(InlineAction_1.InlineAction, { title: "Open in Explorer", renderAction: renderFileExplorerAction, onClick: revealInExplorer })
@@ -21,13 +21,14 @@ const use_is_ruler_visible_1 = require("./EditorRuler/use-is-ruler-visible");
21
21
  const layout_1 = require("./layout");
22
22
  const Preview_1 = require("./Preview");
23
23
  const ResetZoomButton_1 = require("./ResetZoomButton");
24
- const container = {
24
+ const getContainerStyle = (editorZoomGestures) => ({
25
25
  flex: 1,
26
26
  display: 'flex',
27
27
  overflow: 'hidden',
28
28
  position: 'relative',
29
29
  backgroundColor: colors_1.BACKGROUND,
30
- };
30
+ ...(editorZoomGestures ? { touchAction: 'none' } : {}),
31
+ });
31
32
  const resetZoom = {
32
33
  position: 'absolute',
33
34
  top: layout_1.SPACING_UNIT * 2,
@@ -37,6 +38,14 @@ const ZOOM_PX_FACTOR = 0.003;
37
38
  const Canvas = ({ canvasContent, size }) => {
38
39
  const { setSize, size: previewSize } = (0, react_1.useContext)(remotion_1.Internals.PreviewSizeContext);
39
40
  const { editorZoomGestures } = (0, react_1.useContext)(editor_zoom_gestures_1.EditorZoomGesturesContext);
41
+ const previewSnapshotRef = (0, react_1.useRef)({
42
+ previewSize,
43
+ canvasSize: size,
44
+ contentDimensions: null,
45
+ });
46
+ const pinchBaseZoomRef = (0, react_1.useRef)(null);
47
+ const suppressWheelFromWebKitPinchRef = (0, react_1.useRef)(false);
48
+ const touchPinchRef = (0, react_1.useRef)(null);
40
49
  const keybindings = (0, use_keybinding_1.useKeybinding)();
41
50
  const config = remotion_1.Internals.useUnsafeVideoConfig();
42
51
  const areRulersVisible = (0, use_is_ruler_visible_1.useIsRulerVisible)();
@@ -56,7 +65,13 @@ const Canvas = ({ canvasContent, size }) => {
56
65
  return null;
57
66
  }, [assetResolution, config, canvasContent]);
58
67
  const isFit = previewSize.size === 'auto';
68
+ previewSnapshotRef.current = {
69
+ previewSize,
70
+ canvasSize: size,
71
+ contentDimensions,
72
+ };
59
73
  const onWheel = (0, react_1.useCallback)((e) => {
74
+ const ev = e;
60
75
  if (!editorZoomGestures) {
61
76
  return;
62
77
  }
@@ -66,11 +81,15 @@ const Canvas = ({ canvasContent, size }) => {
66
81
  if (!contentDimensions || contentDimensions === 'none') {
67
82
  return;
68
83
  }
69
- const wantsToZoom = e.ctrlKey || e.metaKey;
84
+ const wantsToZoom = ev.ctrlKey || ev.metaKey;
70
85
  if (!wantsToZoom && isFit) {
71
86
  return;
72
87
  }
73
- e.preventDefault();
88
+ if (suppressWheelFromWebKitPinchRef.current && wantsToZoom) {
89
+ ev.preventDefault();
90
+ return;
91
+ }
92
+ ev.preventDefault();
74
93
  setSize((prevSize) => {
75
94
  const scale = remotion_1.Internals.calculateScale({
76
95
  canvasSize: size,
@@ -78,41 +97,20 @@ const Canvas = ({ canvasContent, size }) => {
78
97
  compositionWidth: contentDimensions.width,
79
98
  previewSize: prevSize.size,
80
99
  });
81
- // Zoom in/out
82
100
  if (wantsToZoom) {
83
101
  const oldSize = prevSize.size === 'auto' ? scale : prevSize.size;
84
102
  const smoothened = (0, smooth_zoom_1.smoothenZoom)(oldSize);
85
- const added = smoothened + e.deltaY * ZOOM_PX_FACTOR;
103
+ const added = smoothened + ev.deltaY * ZOOM_PX_FACTOR;
86
104
  const unsmoothened = (0, smooth_zoom_1.unsmoothenZoom)(added);
87
- const { centerX, centerY } = (0, get_effective_translation_1.getCenterPointWhileScrolling)({
88
- size,
89
- clientX: e.clientX,
90
- clientY: e.clientY,
91
- compositionWidth: contentDimensions.width,
92
- compositionHeight: contentDimensions.height,
93
- scale,
94
- translation: prevSize.translation,
105
+ return (0, get_effective_translation_1.applyZoomAroundFocalPoint)({
106
+ canvasSize: size,
107
+ contentDimensions,
108
+ previewSizeBefore: prevSize,
109
+ oldNumericSize: oldSize,
110
+ newNumericSize: unsmoothened,
111
+ clientX: ev.clientX,
112
+ clientY: ev.clientY,
95
113
  });
96
- const zoomDifference = unsmoothened - oldSize;
97
- const uvCoordinatesX = centerX / contentDimensions.width;
98
- const uvCoordinatesY = centerY / contentDimensions.height;
99
- const correctionLeft = -uvCoordinatesX * (zoomDifference * contentDimensions.width) +
100
- (1 - uvCoordinatesX) * zoomDifference * contentDimensions.width;
101
- const correctionTop = -uvCoordinatesY * (zoomDifference * contentDimensions.height) +
102
- (1 - uvCoordinatesY) * zoomDifference * contentDimensions.height;
103
- return {
104
- translation: (0, get_effective_translation_1.getEffectiveTranslation)({
105
- translation: {
106
- x: prevSize.translation.x - correctionLeft / 2,
107
- y: prevSize.translation.y - correctionTop / 2,
108
- },
109
- canvasSize: size,
110
- compositionHeight: contentDimensions.height,
111
- compositionWidth: contentDimensions.width,
112
- scale,
113
- }),
114
- size: unsmoothened,
115
- };
116
114
  }
117
115
  const effectiveTranslation = (0, get_effective_translation_1.getEffectiveTranslation)({
118
116
  translation: prevSize.translation,
@@ -121,13 +119,12 @@ const Canvas = ({ canvasContent, size }) => {
121
119
  compositionWidth: contentDimensions.width,
122
120
  scale,
123
121
  });
124
- // Pan
125
122
  return {
126
123
  ...prevSize,
127
124
  translation: (0, get_effective_translation_1.getEffectiveTranslation)({
128
125
  translation: {
129
- x: effectiveTranslation.x + e.deltaX,
130
- y: effectiveTranslation.y + e.deltaY,
126
+ x: effectiveTranslation.x + ev.deltaX,
127
+ y: effectiveTranslation.y + ev.deltaY,
131
128
  },
132
129
  canvasSize: size,
133
130
  compositionHeight: contentDimensions.height,
@@ -143,12 +140,170 @@ const Canvas = ({ canvasContent, size }) => {
143
140
  return;
144
141
  }
145
142
  current.addEventListener('wheel', onWheel, { passive: false });
146
- return () =>
147
- // @ts-expect-error
148
- current.removeEventListener('wheel', onWheel, {
143
+ return () => {
144
+ current.removeEventListener('wheel', onWheel);
145
+ };
146
+ }, [onWheel]);
147
+ const supportsWebKitPinch = typeof window !== 'undefined' && 'GestureEvent' in window;
148
+ (0, react_1.useEffect)(() => {
149
+ const { current } = canvas_ref_1.canvasRef;
150
+ if (!current || !editorZoomGestures || !supportsWebKitPinch) {
151
+ return;
152
+ }
153
+ const endWebKitPinch = () => {
154
+ pinchBaseZoomRef.current = null;
155
+ suppressWheelFromWebKitPinchRef.current = false;
156
+ };
157
+ const onGestureStart = (event) => {
158
+ const e = event;
159
+ const snap = previewSnapshotRef.current;
160
+ const canvasSz = snap.canvasSize;
161
+ const cdim = snap.contentDimensions;
162
+ if (!canvasSz || !cdim || cdim === 'none') {
163
+ return;
164
+ }
165
+ e.preventDefault();
166
+ suppressWheelFromWebKitPinchRef.current = true;
167
+ const fitted = remotion_1.Internals.calculateScale({
168
+ canvasSize: canvasSz,
169
+ compositionHeight: cdim.height,
170
+ compositionWidth: cdim.width,
171
+ previewSize: snap.previewSize.size,
172
+ });
173
+ pinchBaseZoomRef.current =
174
+ snap.previewSize.size === 'auto' ? fitted : snap.previewSize.size;
175
+ };
176
+ const onGestureChange = (event) => {
177
+ const e = event;
178
+ const base = pinchBaseZoomRef.current;
179
+ const snap = previewSnapshotRef.current;
180
+ const canvasSz = snap.canvasSize;
181
+ const cdim = snap.contentDimensions;
182
+ if (base === null || !canvasSz || !cdim || cdim === 'none') {
183
+ return;
184
+ }
185
+ const dimensions = cdim;
186
+ e.preventDefault();
187
+ setSize((prevSize) => {
188
+ const scale = remotion_1.Internals.calculateScale({
189
+ canvasSize: canvasSz,
190
+ compositionHeight: dimensions.height,
191
+ compositionWidth: dimensions.width,
192
+ previewSize: prevSize.size,
193
+ });
194
+ const oldNumeric = prevSize.size === 'auto' ? scale : prevSize.size;
195
+ return (0, get_effective_translation_1.applyZoomAroundFocalPoint)({
196
+ canvasSize: canvasSz,
197
+ contentDimensions: dimensions,
198
+ previewSizeBefore: prevSize,
199
+ oldNumericSize: oldNumeric,
200
+ newNumericSize: base * e.scale,
201
+ clientX: e.clientX,
202
+ clientY: e.clientY,
203
+ });
204
+ });
205
+ };
206
+ const onGestureEnd = () => {
207
+ endWebKitPinch();
208
+ };
209
+ current.addEventListener('gesturestart', onGestureStart, {
149
210
  passive: false,
150
211
  });
151
- }, [onWheel]);
212
+ current.addEventListener('gesturechange', onGestureChange, {
213
+ passive: false,
214
+ });
215
+ current.addEventListener('gestureend', onGestureEnd);
216
+ current.addEventListener('gesturecancel', onGestureEnd);
217
+ return () => {
218
+ current.removeEventListener('gesturestart', onGestureStart);
219
+ current.removeEventListener('gesturechange', onGestureChange);
220
+ current.removeEventListener('gestureend', onGestureEnd);
221
+ current.removeEventListener('gesturecancel', onGestureEnd);
222
+ };
223
+ }, [editorZoomGestures, setSize, supportsWebKitPinch]);
224
+ (0, react_1.useEffect)(() => {
225
+ const { current } = canvas_ref_1.canvasRef;
226
+ if (!current || !editorZoomGestures) {
227
+ return;
228
+ }
229
+ const onTouchStart = (event) => {
230
+ if (event.touches.length !== 2) {
231
+ touchPinchRef.current = null;
232
+ return;
233
+ }
234
+ const snap = previewSnapshotRef.current;
235
+ if (!snap.canvasSize ||
236
+ !snap.contentDimensions ||
237
+ snap.contentDimensions === 'none') {
238
+ return;
239
+ }
240
+ const [t0, t1] = [event.touches[0], event.touches[1]];
241
+ const initialDistance = Math.hypot(t1.clientX - t0.clientX, t1.clientY - t0.clientY);
242
+ if (initialDistance < 1e-6) {
243
+ return;
244
+ }
245
+ const fitted = remotion_1.Internals.calculateScale({
246
+ canvasSize: snap.canvasSize,
247
+ compositionHeight: snap.contentDimensions.height,
248
+ compositionWidth: snap.contentDimensions.width,
249
+ previewSize: snap.previewSize.size,
250
+ });
251
+ const initialZoom = snap.previewSize.size === 'auto' ? fitted : snap.previewSize.size;
252
+ touchPinchRef.current = { initialDistance, initialZoom };
253
+ };
254
+ const onTouchMove = (event) => {
255
+ const pinch = touchPinchRef.current;
256
+ const snap = previewSnapshotRef.current;
257
+ if (pinch === null ||
258
+ event.touches.length !== 2 ||
259
+ !snap.canvasSize ||
260
+ !snap.contentDimensions ||
261
+ snap.contentDimensions === 'none') {
262
+ return;
263
+ }
264
+ event.preventDefault();
265
+ const [t0, t1] = [event.touches[0], event.touches[1]];
266
+ const dist = Math.hypot(t1.clientX - t0.clientX, t1.clientY - t0.clientY);
267
+ const ratio = dist / pinch.initialDistance;
268
+ const clientX = (t0.clientX + t1.clientX) / 2;
269
+ const clientY = (t0.clientY + t1.clientY) / 2;
270
+ setSize((prevSize) => {
271
+ const canvasSz = snap.canvasSize;
272
+ const cdim = snap.contentDimensions;
273
+ const scale = remotion_1.Internals.calculateScale({
274
+ canvasSize: canvasSz,
275
+ compositionHeight: cdim.height,
276
+ compositionWidth: cdim.width,
277
+ previewSize: prevSize.size,
278
+ });
279
+ const oldNumeric = prevSize.size === 'auto' ? scale : prevSize.size;
280
+ return (0, get_effective_translation_1.applyZoomAroundFocalPoint)({
281
+ canvasSize: canvasSz,
282
+ contentDimensions: cdim,
283
+ previewSizeBefore: prevSize,
284
+ oldNumericSize: oldNumeric,
285
+ newNumericSize: pinch.initialZoom * ratio,
286
+ clientX,
287
+ clientY,
288
+ });
289
+ });
290
+ };
291
+ const onTouchEnd = (event) => {
292
+ if (event.touches.length < 2) {
293
+ touchPinchRef.current = null;
294
+ }
295
+ };
296
+ current.addEventListener('touchstart', onTouchStart, { passive: true });
297
+ current.addEventListener('touchmove', onTouchMove, { passive: false });
298
+ current.addEventListener('touchend', onTouchEnd);
299
+ current.addEventListener('touchcancel', onTouchEnd);
300
+ return () => {
301
+ current.removeEventListener('touchstart', onTouchStart);
302
+ current.removeEventListener('touchmove', onTouchMove);
303
+ current.removeEventListener('touchend', onTouchEnd);
304
+ current.removeEventListener('touchcancel', onTouchEnd);
305
+ };
306
+ }, [editorZoomGestures, setSize]);
152
307
  const onReset = (0, react_1.useCallback)(() => {
153
308
  setSize(() => {
154
309
  return {
@@ -263,6 +418,6 @@ const Canvas = ({ canvasContent, size }) => {
263
418
  fetchMetadata();
264
419
  }, [fetchMetadata]);
265
420
  return (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [
266
- jsx_runtime_1.jsxs("div", { ref: canvas_ref_1.canvasRef, style: container, children: [size ? (jsx_runtime_1.jsx(Preview_1.VideoPreview, { canvasContent: canvasContent, contentDimensions: contentDimensions, canvasSize: size, assetMetadata: assetResolution })) : null, isFit ? null : (jsx_runtime_1.jsx("div", { style: resetZoom, className: "css-reset", children: jsx_runtime_1.jsx(ResetZoomButton_1.ResetZoomButton, { onClick: onReset }) })), editorShowGuides && canvasContent.type === 'composition' && (jsx_runtime_1.jsx(EditorGuides_1.default, { canvasSize: size, contentDimensions: contentDimensions, assetMetadata: assetResolution }))] }), areRulersVisible && (jsx_runtime_1.jsx(EditorRuler_1.EditorRulers, { contentDimensions: contentDimensions, canvasSize: size, assetMetadata: assetResolution, containerRef: canvas_ref_1.canvasRef }))] }));
421
+ jsx_runtime_1.jsxs("div", { ref: canvas_ref_1.canvasRef, style: getContainerStyle(editorZoomGestures), children: [size ? (jsx_runtime_1.jsx(Preview_1.VideoPreview, { canvasContent: canvasContent, contentDimensions: contentDimensions, canvasSize: size, assetMetadata: assetResolution, onRetryAssetMetadata: fetchMetadata })) : null, isFit ? null : (jsx_runtime_1.jsx("div", { style: resetZoom, className: "css-reset", children: jsx_runtime_1.jsx(ResetZoomButton_1.ResetZoomButton, { onClick: onReset }) })), editorShowGuides && canvasContent.type === 'composition' && (jsx_runtime_1.jsx(EditorGuides_1.default, { canvasSize: size, contentDimensions: contentDimensions, assetMetadata: assetResolution }))] }), areRulersVisible && (jsx_runtime_1.jsx(EditorRuler_1.EditorRulers, { contentDimensions: contentDimensions, canvasSize: size, assetMetadata: assetResolution, containerRef: canvas_ref_1.canvasRef }))] }));
267
422
  };
268
423
  exports.Canvas = Canvas;
@@ -45,7 +45,7 @@ const CanvasOrLoading = ({ size }) => {
45
45
  });
46
46
  }, [resolved, setZoom]);
47
47
  if (renderError) {
48
- return jsx_runtime_1.jsx(ErrorLoading, { error: renderError });
48
+ return (jsx_runtime_1.jsx(ErrorLoading, { error: renderError, calculateMetadataContext: false }));
49
49
  }
50
50
  if (!canvasContent) {
51
51
  const compname = window.location.pathname.replace('/', '');
@@ -65,7 +65,7 @@ const CanvasOrLoading = ({ size }) => {
65
65
  return (jsx_runtime_1.jsx("div", { style: container, className: "css-reset", children: jsx_runtime_1.jsx(RunningCalculateMetadata_1.RunningCalculateMetadata, {}) }));
66
66
  }
67
67
  if (resolved.type === 'error') {
68
- return jsx_runtime_1.jsx(ErrorLoading, { error: resolved.error });
68
+ return jsx_runtime_1.jsx(ErrorLoading, { error: resolved.error, calculateMetadataContext: true });
69
69
  }
70
70
  return (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [
71
71
  jsx_runtime_1.jsx(FramePersistor_1.FramePersistor, {}),
@@ -80,9 +80,9 @@ const loaderContainer = {
80
80
  height: '100%',
81
81
  overflowY: 'auto',
82
82
  };
83
- const ErrorLoading = ({ error }) => {
83
+ const ErrorLoading = ({ error, calculateMetadataContext }) => {
84
84
  return (jsx_runtime_1.jsx("div", { style: loaderContainer, className: is_menu_item_1.VERTICAL_SCROLLBAR_CLASSNAME, children: jsx_runtime_1.jsx(ErrorLoader_1.ErrorLoader, { canHaveDismissButton: false, keyboardShortcuts: false, error: error, onRetry: () => {
85
85
  var _a;
86
86
  return (_a = remotion_1.Internals.resolveCompositionsRef.current) === null || _a === void 0 ? void 0 : _a.reloadCurrentlySelectedComposition();
87
- }, calculateMetadata: true }, error.stack) }));
87
+ }, calculateMetadata: calculateMetadataContext }, error.stack) }));
88
88
  };
@@ -5,6 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const colors_1 = require("../helpers/colors");
7
7
  const is_composition_still_1 = require("../helpers/is-composition-still");
8
+ const sidebar_scroll_into_view_1 = require("../helpers/sidebar-scroll-into-view");
8
9
  const folder_1 = require("../icons/folder");
9
10
  const still_1 = require("../icons/still");
10
11
  const video_1 = require("../icons/video");
@@ -61,6 +62,18 @@ const CompositionSelectorItem = ({ item, level, currentComposition, tabIndex, se
61
62
  const onPointerLeave = (0, react_1.useCallback)(() => {
62
63
  setHovered(false);
63
64
  }, []);
65
+ const compositionRowRef = (0, react_1.useRef)(null);
66
+ const compositionId = item.type === 'composition' ? item.composition.id : null;
67
+ (0, react_1.useLayoutEffect)(() => {
68
+ if (compositionId === null) {
69
+ return;
70
+ }
71
+ (0, sidebar_scroll_into_view_1.maybeScrollCompositionSidebarRowIntoView)({
72
+ element: compositionRowRef.current,
73
+ compositionId,
74
+ selected,
75
+ });
76
+ }, [compositionId, selected]);
64
77
  const style = (0, react_1.useMemo)(() => {
65
78
  return {
66
79
  ...itemStyle,
@@ -77,6 +90,7 @@ const CompositionSelectorItem = ({ item, level, currentComposition, tabIndex, se
77
90
  const onClick = (0, react_1.useCallback)((evt) => {
78
91
  evt.preventDefault();
79
92
  if (item.type === 'composition') {
93
+ (0, sidebar_scroll_into_view_1.markCompositionSidebarScrollFromRowClick)(item.composition.id);
80
94
  selectComposition(item.composition, true);
81
95
  }
82
96
  else {
@@ -180,7 +194,7 @@ const CompositionSelectorItem = ({ item, level, currentComposition, tabIndex, se
180
194
  })
181
195
  : null] }));
182
196
  }
183
- return (jsx_runtime_1.jsx(ContextMenu_1.ContextMenu, { values: contextMenu, children: jsx_runtime_1.jsx(layout_1.Row, { align: "center", children: jsx_runtime_1.jsxs("a", { style: style, onPointerEnter: onPointerEnter, onPointerLeave: onPointerLeave, tabIndex: tabIndex, onClick: onClick, onKeyPress: onKeyPress, type: "button", title: item.composition.id, className: "__remotion-composition", "data-compname": item.composition.id, children: [(0, is_composition_still_1.isCompositionStill)(item.composition) ? (jsx_runtime_1.jsx(still_1.StillIcon, { color: hovered || selected ? 'white' : colors_1.LIGHT_TEXT, style: iconStyle })) : (jsx_runtime_1.jsx(video_1.FilmIcon, { color: hovered || selected ? 'white' : colors_1.LIGHT_TEXT, style: iconStyle })), jsx_runtime_1.jsx(layout_1.Spacing, { x: 1 }), jsx_runtime_1.jsx("div", { style: label, children: item.composition.id }), jsx_runtime_1.jsx(layout_1.Spacing, { x: 0.5 }), jsx_runtime_1.jsx(CompositionContextButton_1.CompositionContextButton, { values: contextMenu, visible: hovered }), jsx_runtime_1.jsx(SidebarRenderButton_1.SidebarRenderButton, { visible: hovered, composition: item.composition })
197
+ return (jsx_runtime_1.jsx(ContextMenu_1.ContextMenu, { values: contextMenu, children: jsx_runtime_1.jsx(layout_1.Row, { align: "center", children: jsx_runtime_1.jsxs("a", { ref: compositionRowRef, style: style, onPointerEnter: onPointerEnter, onPointerLeave: onPointerLeave, tabIndex: tabIndex, onClick: onClick, onKeyPress: onKeyPress, type: "button", title: item.composition.id, className: "__remotion-composition", "data-compname": item.composition.id, children: [(0, is_composition_still_1.isCompositionStill)(item.composition) ? (jsx_runtime_1.jsx(still_1.StillIcon, { color: hovered || selected ? 'white' : colors_1.LIGHT_TEXT, style: iconStyle })) : (jsx_runtime_1.jsx(video_1.FilmIcon, { color: hovered || selected ? 'white' : colors_1.LIGHT_TEXT, style: iconStyle })), jsx_runtime_1.jsx(layout_1.Spacing, { x: 1 }), jsx_runtime_1.jsx("div", { style: label, children: item.composition.id }), jsx_runtime_1.jsx(layout_1.Spacing, { x: 0.5 }), jsx_runtime_1.jsx(CompositionContextButton_1.CompositionContextButton, { values: contextMenu, visible: hovered }), jsx_runtime_1.jsx(SidebarRenderButton_1.SidebarRenderButton, { visible: hovered, composition: item.composition })
184
198
  ] }) }) }));
185
199
  };
186
200
  exports.CompositionSelectorItem = CompositionSelectorItem;
@@ -20,6 +20,9 @@ const FilePreview = ({ fileType, src, currentAsset, assetMetadata }) => {
20
20
  if (assetMetadata.type === 'not-found') {
21
21
  throw new Error('expected to have assetMetadata, got "not-found"');
22
22
  }
23
+ if (assetMetadata.type === 'metadata-error') {
24
+ throw new Error('unexpected metadata-error in FilePreview');
25
+ }
23
26
  if (fileType === 'audio') {
24
27
  return jsx_runtime_1.jsx("audio", { src: src, controls: true });
25
28
  }
@@ -14,7 +14,7 @@ const use_static_files_1 = require("./use-static-files");
14
14
  const useSelectAsset = () => {
15
15
  const { setCanvasContent } = (0, react_1.useContext)(remotion_1.Internals.CompositionSetters);
16
16
  const { setAssetFoldersExpanded } = (0, react_1.useContext)(folders_1.FolderContext);
17
- return (asset) => {
17
+ return (0, react_1.useCallback)((asset) => {
18
18
  var _a;
19
19
  setCanvasContent({ type: 'asset', asset });
20
20
  (_a = ExplorerPanel_1.explorerSidebarTabs.current) === null || _a === void 0 ? void 0 : _a.selectAssetsPanel();
@@ -31,7 +31,7 @@ const useSelectAsset = () => {
31
31
  }
32
32
  return newState;
33
33
  });
34
- };
34
+ }, [setAssetFoldersExpanded, setCanvasContent]);
35
35
  };
36
36
  exports.useSelectAsset = useSelectAsset;
37
37
  const useSelectComposition = () => {
@@ -134,7 +134,7 @@ const InitialCompositionLoader = () => {
134
134
  return file.name === newCanvas.asset;
135
135
  });
136
136
  if (exists) {
137
- setCanvasContent(newCanvas);
137
+ selectAsset(newCanvas.asset);
138
138
  }
139
139
  return;
140
140
  }
@@ -142,7 +142,13 @@ const InitialCompositionLoader = () => {
142
142
  };
143
143
  window.addEventListener('popstate', onchange);
144
144
  return () => window.removeEventListener('popstate', onchange);
145
- }, [compositions, selectComposition, setCanvasContent, staticFiles]);
145
+ }, [
146
+ compositions,
147
+ selectAsset,
148
+ selectComposition,
149
+ setCanvasContent,
150
+ staticFiles,
151
+ ]);
146
152
  return null;
147
153
  };
148
154
  exports.InitialCompositionLoader = InitialCompositionLoader;
@@ -10,4 +10,5 @@ export declare const VideoPreview: React.FC<{
10
10
  readonly contentDimensions: Dimensions | 'none' | null;
11
11
  readonly canvasContent: CanvasContent;
12
12
  readonly assetMetadata: AssetMetadata | null;
13
+ readonly onRetryAssetMetadata?: () => void;
13
14
  }>;
@@ -5,9 +5,11 @@ const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const player_1 = require("@remotion/player");
6
6
  const react_1 = require("react");
7
7
  const remotion_1 = require("remotion");
8
+ const ErrorLoader_1 = require("../error-overlay/remotion-overlay/ErrorLoader");
8
9
  const checkerboard_background_1 = require("../helpers/checkerboard-background");
9
10
  const colors_1 = require("../helpers/colors");
10
11
  const checkerboard_1 = require("../state/checkerboard");
12
+ const is_menu_item_1 = require("./Menu/is-menu-item");
11
13
  const RenderPreview_1 = require("./RenderPreview");
12
14
  const Spinner_1 = require("./Spinner");
13
15
  const StaticFilePreview_1 = require("./StaticFilePreview");
@@ -22,6 +24,14 @@ const label = {
22
24
  fontSize: 14,
23
25
  color: colors_1.LIGHT_TEXT,
24
26
  };
27
+ const assetMetadataErrorContainer = {
28
+ marginLeft: 'auto',
29
+ marginRight: 'auto',
30
+ width: '100%',
31
+ position: 'absolute',
32
+ height: '100%',
33
+ overflowY: 'auto',
34
+ };
25
35
  const getPreviewFileType = (fileName) => {
26
36
  var _a;
27
37
  if (!fileName) {
@@ -68,10 +78,13 @@ const containerStyle = (options) => {
68
78
  backgroundPosition: (0, checkerboard_background_1.getCheckerboardBackgroundPos)(checkerboardSize) /* Must be half of one side of the square */,
69
79
  };
70
80
  };
71
- const VideoPreview = ({ canvasSize, contentDimensions, canvasContent, assetMetadata }) => {
81
+ const VideoPreview = ({ canvasSize, contentDimensions, canvasContent, assetMetadata, onRetryAssetMetadata, }) => {
72
82
  if (assetMetadata && assetMetadata.type === 'not-found') {
73
83
  return (jsx_runtime_1.jsx("div", { style: centeredContainer, children: jsx_runtime_1.jsx("div", { style: label, children: "File does not exist" }) }));
74
84
  }
85
+ if (assetMetadata && assetMetadata.type === 'metadata-error') {
86
+ return (jsx_runtime_1.jsx("div", { style: assetMetadataErrorContainer, className: is_menu_item_1.VERTICAL_SCROLLBAR_CLASSNAME, children: jsx_runtime_1.jsx(ErrorLoader_1.ErrorLoader, { canHaveDismissButton: false, keyboardShortcuts: false, error: assetMetadata.error, onRetry: onRetryAssetMetadata !== null && onRetryAssetMetadata !== void 0 ? onRetryAssetMetadata : null, calculateMetadata: false }, assetMetadata.error.stack) }));
87
+ }
75
88
  if (contentDimensions === null) {
76
89
  return (jsx_runtime_1.jsx("div", { style: centeredContainer, children: jsx_runtime_1.jsx(Spinner_1.Spinner, { duration: 0.5, size: 24 }) }));
77
90
  }
@@ -52,6 +52,7 @@ const timeline_refs_1 = require("./timeline-refs");
52
52
  const TimelineDragHandler_1 = require("./TimelineDragHandler");
53
53
  const TimelineInOutPointer_1 = require("./TimelineInOutPointer");
54
54
  const TimelineList_1 = require("./TimelineList");
55
+ const TimelinePinchZoom_1 = require("./TimelinePinchZoom");
55
56
  const TimelinePlayCursorSyncer_1 = require("./TimelinePlayCursorSyncer");
56
57
  const TimelineScrollable_1 = require("./TimelineScrollable");
57
58
  const TimelineSlider_1 = require("./TimelineSlider");
@@ -116,10 +117,12 @@ const TimelineInner = () => {
116
117
  overflowX: 'hidden',
117
118
  };
118
119
  }, [hasBeenCut, shown, expandedTracks, visualModeEnabled]);
119
- return (jsx_runtime_1.jsx("div", { ref: timeline_refs_1.timelineVerticalScroll, style: container, className: 'css-reset ' + is_menu_item_1.VERTICAL_SCROLLBAR_CLASSNAME, children: jsx_runtime_1.jsx(TimelineWidthProvider_1.TimelineWidthProvider, { children: jsx_runtime_1.jsx("div", { style: inner, children: jsx_runtime_1.jsxs(SplitterContainer_1.SplitterContainer, { orientation: "vertical", defaultFlex: 0.2, id: "names-to-timeline", maxFlex: 0.5, minFlex: 0.15, children: [
120
- jsx_runtime_1.jsx(SplitterElement_1.SplitterElement, { type: "flexer", sticky: jsx_runtime_1.jsx(TimelineTimeIndicators_1.TimelineTimePlaceholders, {}), children: jsx_runtime_1.jsx(TimelineList_1.TimelineList, { timeline: shown }) }), jsx_runtime_1.jsx(SplitterHandle_1.SplitterHandle, { onCollapse: noop, allowToCollapse: "none" }), jsx_runtime_1.jsx(SplitterElement_1.SplitterElement, { type: "anti-flexer", sticky: null, children: jsx_runtime_1.jsxs(TimelineScrollable_1.TimelineScrollable, { children: [
121
- jsx_runtime_1.jsx(TimelineTracks_1.TimelineTracks, { timeline: shown, hasBeenCut: hasBeenCut }), jsx_runtime_1.jsx(TimelineInOutPointer_1.TimelineInOutPointer, {}), jsx_runtime_1.jsx(TimelinePlayCursorSyncer_1.TimelinePlayCursorSyncer, {}), jsx_runtime_1.jsx(TimelineDragHandler_1.TimelineDragHandler, {}), jsx_runtime_1.jsx(TimelineTimeIndicators_1.TimelineTimeIndicators, {}), jsx_runtime_1.jsx(TimelineSlider_1.TimelineSlider, {})
122
- ] }) })
123
- ] }) }) }) }));
120
+ return (jsx_runtime_1.jsx("div", { ref: timeline_refs_1.timelineVerticalScroll, style: container, className: 'css-reset ' + is_menu_item_1.VERTICAL_SCROLLBAR_CLASSNAME, children: jsx_runtime_1.jsxs(TimelineWidthProvider_1.TimelineWidthProvider, { children: [
121
+ jsx_runtime_1.jsx(TimelinePinchZoom_1.TimelinePinchZoom, {}), jsx_runtime_1.jsx("div", { style: inner, children: jsx_runtime_1.jsxs(SplitterContainer_1.SplitterContainer, { orientation: "vertical", defaultFlex: 0.2, id: "names-to-timeline", maxFlex: 0.5, minFlex: 0.15, children: [
122
+ jsx_runtime_1.jsx(SplitterElement_1.SplitterElement, { type: "flexer", sticky: jsx_runtime_1.jsx(TimelineTimeIndicators_1.TimelineTimePlaceholders, {}), children: jsx_runtime_1.jsx(TimelineList_1.TimelineList, { timeline: shown }) }), jsx_runtime_1.jsx(SplitterHandle_1.SplitterHandle, { onCollapse: noop, allowToCollapse: "none" }), jsx_runtime_1.jsx(SplitterElement_1.SplitterElement, { type: "anti-flexer", sticky: null, children: jsx_runtime_1.jsxs(TimelineScrollable_1.TimelineScrollable, { children: [
123
+ jsx_runtime_1.jsx(TimelineTracks_1.TimelineTracks, { timeline: shown, hasBeenCut: hasBeenCut }), jsx_runtime_1.jsx(TimelineInOutPointer_1.TimelineInOutPointer, {}), jsx_runtime_1.jsx(TimelinePlayCursorSyncer_1.TimelinePlayCursorSyncer, {}), jsx_runtime_1.jsx(TimelineDragHandler_1.TimelineDragHandler, {}), jsx_runtime_1.jsx(TimelineTimeIndicators_1.TimelineTimeIndicators, {}), jsx_runtime_1.jsx(TimelineSlider_1.TimelineSlider, {})
124
+ ] }) })
125
+ ] }) })
126
+ ] }) }));
124
127
  };
125
128
  exports.Timeline = react_1.default.memo(TimelineInner);
@@ -48,7 +48,7 @@ const TimelineListItem = ({ nestedDepth, sequence, isCompact }) => {
48
48
  const { hidden, setHidden } = (0, react_1.useContext)(remotion_1.Internals.SequenceVisibilityToggleContext);
49
49
  const { expandedTracks, toggleTrack } = (0, react_1.useContext)(ExpandedTracksProvider_1.ExpandedTracksContext);
50
50
  const originalLocation = (0, use_resolved_stack_1.useResolvedStack)((_a = sequence.stack) !== null && _a !== void 0 ? _a : null);
51
- const nodePath = (0, use_sequence_props_subscription_1.useSequencePropsSubscription)(sequence, originalLocation, visualModeActive);
51
+ const { nodePath, jsxInMapCallback } = (0, use_sequence_props_subscription_1.useSequencePropsSubscription)(sequence, originalLocation, visualModeActive);
52
52
  const validatedLocation = (0, react_1.useMemo)(() => {
53
53
  var _a;
54
54
  if (!originalLocation ||
@@ -64,6 +64,34 @@ const TimelineListItem = ({ nestedDepth, sequence, isCompact }) => {
64
64
  }, [originalLocation]);
65
65
  const canDeleteFromSource = Boolean(nodePath && (validatedLocation === null || validatedLocation === void 0 ? void 0 : validatedLocation.source));
66
66
  const deleteDisabled = (0, react_1.useMemo)(() => !previewConnected || !sequence.controls || !canDeleteFromSource, [previewConnected, sequence.controls, canDeleteFromSource]);
67
+ const duplicateDisabled = deleteDisabled;
68
+ const onDuplicateSequenceFromSource = (0, react_1.useCallback)(async () => {
69
+ if (!(validatedLocation === null || validatedLocation === void 0 ? void 0 : validatedLocation.source) || !nodePath) {
70
+ return;
71
+ }
72
+ if (jsxInMapCallback) {
73
+ const message = 'This sequence is rendered inside a .map() callback. Duplicating inserts another copy in that callback (affecting each list item). Continue?';
74
+ // eslint-disable-next-line no-alert -- native confirm before applying duplicate codemod in .map callbacks
75
+ if (!window.confirm(message)) {
76
+ return;
77
+ }
78
+ }
79
+ try {
80
+ const result = await (0, call_api_1.callApi)('/api/duplicate-jsx-node', {
81
+ fileName: validatedLocation.source,
82
+ nodePath,
83
+ });
84
+ if (result.success) {
85
+ (0, NotificationCenter_1.showNotification)('Duplicated sequence in source file', 2000);
86
+ }
87
+ else {
88
+ (0, NotificationCenter_1.showNotification)(result.reason, 4000);
89
+ }
90
+ }
91
+ catch (err) {
92
+ (0, NotificationCenter_1.showNotification)(err.message, 4000);
93
+ }
94
+ }, [jsxInMapCallback, nodePath, validatedLocation === null || validatedLocation === void 0 ? void 0 : validatedLocation.source]);
67
95
  const onDeleteSequenceFromSource = (0, react_1.useCallback)(async () => {
68
96
  if (!(validatedLocation === null || validatedLocation === void 0 ? void 0 : validatedLocation.source) || !nodePath) {
69
97
  return;
@@ -89,6 +117,23 @@ const TimelineListItem = ({ nestedDepth, sequence, isCompact }) => {
89
117
  return [];
90
118
  }
91
119
  return [
120
+ {
121
+ type: 'item',
122
+ id: 'duplicate-sequence',
123
+ keyHint: null,
124
+ label: 'Duplicate',
125
+ leftItem: null,
126
+ disabled: duplicateDisabled,
127
+ onClick: () => {
128
+ if (duplicateDisabled) {
129
+ return;
130
+ }
131
+ onDuplicateSequenceFromSource();
132
+ },
133
+ quickSwitcherLabel: null,
134
+ subMenu: null,
135
+ value: 'duplicate-sequence',
136
+ },
92
137
  {
93
138
  type: 'item',
94
139
  id: 'delete-sequence',
@@ -107,7 +152,13 @@ const TimelineListItem = ({ nestedDepth, sequence, isCompact }) => {
107
152
  value: 'delete-sequence',
108
153
  },
109
154
  ];
110
- }, [deleteDisabled, onDeleteSequenceFromSource, visualModeEnvEnabled]);
155
+ }, [
156
+ deleteDisabled,
157
+ duplicateDisabled,
158
+ onDeleteSequenceFromSource,
159
+ onDuplicateSequenceFromSource,
160
+ visualModeEnvEnabled,
161
+ ]);
111
162
  const isExpanded = visualModeActive && ((_b = expandedTracks[sequence.id]) !== null && _b !== void 0 ? _b : false);
112
163
  const onToggleExpand = (0, react_1.useCallback)(() => {
113
164
  toggleTrack(sequence.id);
@@ -0,0 +1,2 @@
1
+ import { type FC } from 'react';
2
+ export declare const TimelinePinchZoom: FC;