@remotion/studio 4.0.232 → 4.0.233

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.
@@ -1,5 +1,5 @@
1
1
 
2
2
  
3
- > @remotion/studio@4.0.231 make /Users/jonathanburger/remotion/packages/studio
3
+ > @remotion/studio@4.0.232 make /Users/jonathanburger/remotion/packages/studio
4
4
  > tsc -d && bun --env-file=../.env.bundle bundle.ts
5
5
 
@@ -0,0 +1 @@
1
+ export declare const CanvasIfSizeIsAvailable: React.FC;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CanvasIfSizeIsAvailable = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const remotion_1 = require("remotion");
7
+ const editor_rulers_1 = require("../state/editor-rulers");
8
+ const CanvasOrLoading_1 = require("./CanvasOrLoading");
9
+ const use_is_ruler_visible_1 = require("./EditorRuler/use-is-ruler-visible");
10
+ const CanvasIfSizeIsAvailable = () => {
11
+ const rulersAreVisible = (0, use_is_ruler_visible_1.useIsRulerVisible)();
12
+ const context = (0, react_1.useContext)(remotion_1.Internals.CurrentScaleContext);
13
+ const sizeWithRulersApplied = (0, react_1.useMemo)(() => {
14
+ const size = context && context.type === 'canvas-size' ? context.canvasSize : null;
15
+ if (!rulersAreVisible) {
16
+ return size;
17
+ }
18
+ if (!size) {
19
+ return null;
20
+ }
21
+ return {
22
+ ...size,
23
+ width: size.width - editor_rulers_1.RULER_WIDTH,
24
+ height: size.height - editor_rulers_1.RULER_WIDTH,
25
+ };
26
+ }, [context, rulersAreVisible]);
27
+ if (!sizeWithRulersApplied) {
28
+ return null;
29
+ }
30
+ return (0, jsx_runtime_1.jsx)(CanvasOrLoading_1.CanvasOrLoading, { size: sizeWithRulersApplied });
31
+ };
32
+ exports.CanvasIfSizeIsAvailable = CanvasIfSizeIsAvailable;
@@ -11,9 +11,9 @@ const video_1 = require("../icons/video");
11
11
  const modals_1 = require("../state/modals");
12
12
  const CompositionContextButton_1 = require("./CompositionContextButton");
13
13
  const ContextMenu_1 = require("./ContextMenu");
14
+ const layout_1 = require("./layout");
14
15
  const NotificationCenter_1 = require("./Notifications/NotificationCenter");
15
16
  const SidebarRenderButton_1 = require("./SidebarRenderButton");
16
- const layout_1 = require("./layout");
17
17
  const COMPOSITION_ITEM_HEIGHT = 32;
18
18
  const itemStyle = {
19
19
  paddingRight: 10,
@@ -86,6 +86,6 @@ const Editor = ({ Root, readOnlyStudio }) => {
86
86
  const MemoRoot = (0, react_1.useMemo)(() => {
87
87
  return react_1.default.memo(Root);
88
88
  }, [Root]);
89
- return ((0, jsx_runtime_1.jsx)(z_index_1.HigherZIndex, { onEscape: noop_1.noop, onOutsideClick: noop_1.noop, children: (0, jsx_runtime_1.jsxs)(timeline_zoom_1.TimelineZoomContext, { children: [(0, jsx_runtime_1.jsx)(remotion_1.Internals.CurrentScaleContext.Provider, { value: value, children: (0, jsx_runtime_1.jsxs)("div", { style: background, children: [canvasMounted ? (0, jsx_runtime_1.jsx)(MemoRoot, {}) : null, (0, jsx_runtime_1.jsxs)(remotion_1.Internals.CanUseRemotionHooksProvider, { children: [(0, jsx_runtime_1.jsx)(EditorContent_1.EditorContent, { readOnlyStudio: readOnlyStudio, children: (0, jsx_runtime_1.jsx)(TopPanel_1.TopPanel, { size: size, drawRef: canvas_ref_1.drawRef, bufferStateDelayInMilliseconds: exports.BUFFER_STATE_DELAY_IN_MILLISECONDS, onMounted: onMounted, readOnlyStudio: readOnlyStudio }) }), (0, jsx_runtime_1.jsx)(GlobalKeybindings_1.GlobalKeybindings, {})] })] }) }), (0, jsx_runtime_1.jsx)(Modals_1.Modals, { readOnlyStudio: readOnlyStudio }), (0, jsx_runtime_1.jsx)(NotificationCenter_1.NotificationCenter, {})] }) }));
89
+ return ((0, jsx_runtime_1.jsx)(z_index_1.HigherZIndex, { onEscape: noop_1.noop, onOutsideClick: noop_1.noop, children: (0, jsx_runtime_1.jsxs)(timeline_zoom_1.TimelineZoomContext, { children: [(0, jsx_runtime_1.jsx)(remotion_1.Internals.CurrentScaleContext.Provider, { value: value, children: (0, jsx_runtime_1.jsxs)("div", { style: background, children: [canvasMounted ? (0, jsx_runtime_1.jsx)(MemoRoot, {}) : null, (0, jsx_runtime_1.jsxs)(remotion_1.Internals.CanUseRemotionHooksProvider, { children: [(0, jsx_runtime_1.jsx)(EditorContent_1.EditorContent, { readOnlyStudio: readOnlyStudio, children: (0, jsx_runtime_1.jsx)(TopPanel_1.TopPanel, { drawRef: canvas_ref_1.drawRef, bufferStateDelayInMilliseconds: exports.BUFFER_STATE_DELAY_IN_MILLISECONDS, onMounted: onMounted, readOnlyStudio: readOnlyStudio }) }), (0, jsx_runtime_1.jsx)(GlobalKeybindings_1.GlobalKeybindings, {})] })] }) }), (0, jsx_runtime_1.jsx)(Modals_1.Modals, { readOnlyStudio: readOnlyStudio }), (0, jsx_runtime_1.jsx)(NotificationCenter_1.NotificationCenter, {})] }) }));
90
90
  };
91
91
  exports.Editor = Editor;
@@ -39,7 +39,7 @@ const useSelectComposition = () => {
39
39
  const { setCanvasContent } = (0, react_1.useContext)(remotion_1.Internals.CompositionManager);
40
40
  const isMobileLayout = (0, mobile_layout_1.useMobileLayout)();
41
41
  const { setSidebarCollapsedState } = (0, react_1.useContext)(sidebar_1.SidebarContext);
42
- return (c, push) => {
42
+ return (0, react_1.useCallback)((c, push) => {
43
43
  var _a;
44
44
  if (push) {
45
45
  (0, url_state_1.pushUrl)(`/${c.id}`);
@@ -62,7 +62,12 @@ const useSelectComposition = () => {
62
62
  setSidebarCollapsedState({ left: 'collapsed', right: 'collapsed' });
63
63
  }
64
64
  }
65
- };
65
+ }, [
66
+ isMobileLayout,
67
+ setCanvasContent,
68
+ setCompositionFoldersExpanded,
69
+ setSidebarCollapsedState,
70
+ ]);
66
71
  };
67
72
  exports.useSelectComposition = useSelectComposition;
68
73
  const InitialCompositionLoader = () => {
@@ -33,14 +33,14 @@ const PlayPause = ({ playbackRate, loop, bufferStateDelayInMilliseconds }) => {
33
33
  const { inFrame, outFrame } = (0, in_out_1.useTimelineInOutFramePosition)();
34
34
  const videoConfig = remotion_1.Internals.useUnsafeVideoConfig();
35
35
  const [showBufferIndicator, setShowBufferState] = (0, react_1.useState)(false);
36
- const { playing, play, pause, pauseAndReturnToPlayStart, frameBack, seek, frameForward, isLastFrame, isFirstFrame, remotionInternal_currentFrameRef, emitter, } = player_1.PlayerInternals.usePlayer();
36
+ const { playing, play, pause, pauseAndReturnToPlayStart, frameBack, seek, frameForward, isLastFrame, isFirstFrame, emitter, getCurrentFrame, } = player_1.PlayerInternals.usePlayer();
37
37
  player_1.PlayerInternals.usePlayback({
38
38
  loop,
39
39
  playbackRate,
40
40
  moveToBeginningWhenEnded: true,
41
41
  inFrame,
42
42
  outFrame,
43
- frameRef: remotionInternal_currentFrameRef,
43
+ getCurrentFrame,
44
44
  browserMediaControlsBehavior: {
45
45
  mode: 'register-media-session',
46
46
  },
@@ -82,7 +82,7 @@ const PlayPause = ({ playbackRate, loop, bufferStateDelayInMilliseconds }) => {
82
82
  (0, timeline_scroll_logic_1.ensureFrameIsInViewport)({
83
83
  direction: 'fit-left',
84
84
  durationInFrames: (0, imperative_state_1.getCurrentDuration)(),
85
- frame: Math.max(0, (0, imperative_state_1.getCurrentFrame)() - (0, imperative_state_1.getCurrentFps)()),
85
+ frame: Math.max(0, getCurrentFrame() - (0, imperative_state_1.getCurrentFps)()),
86
86
  });
87
87
  }
88
88
  else {
@@ -90,10 +90,10 @@ const PlayPause = ({ playbackRate, loop, bufferStateDelayInMilliseconds }) => {
90
90
  (0, timeline_scroll_logic_1.ensureFrameIsInViewport)({
91
91
  direction: 'fit-left',
92
92
  durationInFrames: (0, imperative_state_1.getCurrentDuration)(),
93
- frame: Math.max(0, (0, imperative_state_1.getCurrentFrame)() - 1),
93
+ frame: Math.max(0, getCurrentFrame() - 1),
94
94
  });
95
95
  }
96
- }, [frameBack, seek]);
96
+ }, [frameBack, seek, getCurrentFrame]);
97
97
  const onArrowRight = (0, react_1.useCallback)((e) => {
98
98
  if (e.altKey) {
99
99
  seek((0, imperative_state_1.getCurrentDuration)() - 1);
@@ -108,7 +108,7 @@ const PlayPause = ({ playbackRate, loop, bufferStateDelayInMilliseconds }) => {
108
108
  (0, timeline_scroll_logic_1.ensureFrameIsInViewport)({
109
109
  direction: 'fit-right',
110
110
  durationInFrames: (0, imperative_state_1.getCurrentDuration)(),
111
- frame: Math.min((0, imperative_state_1.getCurrentDuration)() - 1, (0, imperative_state_1.getCurrentFrame)() + (0, imperative_state_1.getCurrentFps)()),
111
+ frame: Math.min((0, imperative_state_1.getCurrentDuration)() - 1, getCurrentFrame() + (0, imperative_state_1.getCurrentFps)()),
112
112
  });
113
113
  }
114
114
  else {
@@ -116,11 +116,11 @@ const PlayPause = ({ playbackRate, loop, bufferStateDelayInMilliseconds }) => {
116
116
  (0, timeline_scroll_logic_1.ensureFrameIsInViewport)({
117
117
  direction: 'fit-right',
118
118
  durationInFrames: (0, imperative_state_1.getCurrentDuration)(),
119
- frame: Math.min((0, imperative_state_1.getCurrentDuration)() - 1, (0, imperative_state_1.getCurrentFrame)() + 1),
119
+ frame: Math.min((0, imperative_state_1.getCurrentDuration)() - 1, getCurrentFrame() + 1),
120
120
  });
121
121
  }
122
122
  e.preventDefault();
123
- }, [frameForward, seek]);
123
+ }, [frameForward, seek, getCurrentFrame]);
124
124
  const oneFrameBack = (0, react_1.useCallback)(() => {
125
125
  frameBack(1);
126
126
  }, [frameBack]);
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RenderButton = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const player_1 = require("@remotion/player");
5
6
  const react_1 = require("react");
6
7
  const remotion_1 = require("remotion");
7
8
  const client_id_1 = require("../helpers/client-id");
@@ -38,7 +39,7 @@ const RenderButton = () => {
38
39
  };
39
40
  }, []);
40
41
  const video = remotion_1.Internals.useVideo();
41
- const frame = (0, remotion_1.useCurrentFrame)();
42
+ const getCurrentFrame = player_1.PlayerInternals.useFrameImperative();
42
43
  const { props } = (0, react_1.useContext)(remotion_1.Internals.EditorPropsContext);
43
44
  const onClick = (0, react_1.useCallback)(() => {
44
45
  var _a, _b, _c;
@@ -52,7 +53,7 @@ const RenderButton = () => {
52
53
  setSelectedModal({
53
54
  type: 'render',
54
55
  compositionId: video.id,
55
- initialFrame: frame,
56
+ initialFrame: getCurrentFrame(),
56
57
  initialStillImageFormat: defaults.stillImageFormat,
57
58
  initialVideoImageFormat: defaults.videoImageFormat,
58
59
  initialJpegQuality: defaults.jpegQuality,
@@ -94,7 +95,7 @@ const RenderButton = () => {
94
95
  defaulMetadata: defaults.metadata,
95
96
  initialHardwareAcceleration: defaults.hardwareAcceleration,
96
97
  });
97
- }, [video, setSelectedModal, frame, props, inFrame, outFrame]);
98
+ }, [video, setSelectedModal, getCurrentFrame, props, inFrame, outFrame]);
98
99
  if (!video) {
99
100
  return null;
100
101
  }
@@ -21,30 +21,12 @@ exports.containerColumn = {
21
21
  const SplitterContainer = ({ orientation, children, defaultFlex, maxFlex, minFlex, id }) => {
22
22
  const [initialTimelineFlex, persistFlex] = (0, timeline_1.useTimelineFlex)(id);
23
23
  const [flexValue, setFlexValue] = (0, react_1.useState)(initialTimelineFlex !== null && initialTimelineFlex !== void 0 ? initialTimelineFlex : defaultFlex);
24
- const [domRect, setDomRect] = (0, react_1.useState)(null);
25
24
  const ref = (0, react_1.useRef)(null);
26
25
  const isDragging = (0, react_1.useRef)(false);
27
- const [resizeObserver] = (0, react_1.useState)(() => {
28
- return new ResizeObserver((entries) => {
29
- setDomRect(entries[0].contentRect);
30
- });
31
- });
32
- (0, react_1.useEffect)(() => {
33
- const { current } = ref;
34
- if (!current) {
35
- return;
36
- }
37
- resizeObserver.observe(current);
38
- return () => resizeObserver.unobserve(current);
39
- }, [resizeObserver]);
40
- (0, react_1.useEffect)(() => {
41
- var _a, _b;
42
- setDomRect((_b = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) !== null && _b !== void 0 ? _b : null);
43
- }, []);
44
26
  const value = (0, react_1.useMemo)(() => {
45
27
  return {
46
28
  flexValue,
47
- domRect,
29
+ ref,
48
30
  setFlexValue,
49
31
  isDragging,
50
32
  orientation,
@@ -56,13 +38,13 @@ const SplitterContainer = ({ orientation, children, defaultFlex, maxFlex, minFle
56
38
  };
57
39
  }, [
58
40
  defaultFlex,
59
- domRect,
60
41
  flexValue,
61
42
  id,
62
43
  maxFlex,
63
44
  minFlex,
64
45
  orientation,
65
46
  persistFlex,
47
+ ref,
66
48
  ]);
67
49
  return ((0, jsx_runtime_1.jsx)(SplitterContext_1.SplitterContext.Provider, { value: value, children: (0, jsx_runtime_1.jsx)("div", { ref: ref, style: orientation === 'horizontal' ? exports.containerColumn : containerRow, children: children }) }));
68
50
  };
@@ -7,8 +7,8 @@ export type SplitterOrientation = 'horizontal' | 'vertical';
7
7
  export type TSplitterContext = {
8
8
  flexValue: number;
9
9
  setFlexValue: React.Dispatch<React.SetStateAction<number>>;
10
- domRect: DOMRect | DOMRectReadOnly | null;
11
10
  orientation: SplitterOrientation;
11
+ ref: React.RefObject<HTMLDivElement>;
12
12
  maxFlex: number;
13
13
  minFlex: number;
14
14
  defaultFlex: number;
@@ -7,7 +7,7 @@ exports.SplitterContext = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  exports.SplitterContext = react_1.default.createContext({
9
9
  flexValue: 1,
10
- domRect: null,
10
+ ref: { current: null },
11
11
  setFlexValue: () => undefined,
12
12
  isDragging: { current: false },
13
13
  orientation: 'horizontal',
@@ -25,9 +25,6 @@ const SplitterHandle = ({ allowToCollapse, onCollapse }) => {
25
25
  if (context.isDragging.current) {
26
26
  return;
27
27
  }
28
- if (!context.domRect) {
29
- return;
30
- }
31
28
  const { current } = ref;
32
29
  if (!current) {
33
30
  return;
@@ -36,10 +33,10 @@ const SplitterHandle = ({ allowToCollapse, onCollapse }) => {
36
33
  if (!context.isDragging.current) {
37
34
  throw new Error('cannot get value if not dragging');
38
35
  }
39
- if (!context.domRect) {
36
+ if (!context.ref.current) {
40
37
  throw new Error('domRect is not mounted');
41
38
  }
42
- const { width, height } = context.domRect;
39
+ const { width, height } = context.ref.current.getBoundingClientRect();
43
40
  const change = (() => {
44
41
  if (context.orientation === 'vertical') {
45
42
  return ((e.clientX - context.isDragging.current.x) /
@@ -110,14 +107,7 @@ const SplitterHandle = ({ allowToCollapse, onCollapse }) => {
110
107
  cleanup();
111
108
  }
112
109
  };
113
- }, [
114
- allowToCollapse,
115
- context,
116
- context.domRect,
117
- context.flexValue,
118
- lastPointerUp,
119
- onCollapse,
120
- ]);
110
+ }, [allowToCollapse, context, context.flexValue, lastPointerUp, onCollapse]);
121
111
  return ((0, jsx_runtime_1.jsx)("div", { ref: ref, className: [
122
112
  'remotion-splitter',
123
113
  context.orientation === 'horizontal'
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TimelineInOutPointToggle = exports.defaultInOutValue = exports.inOutHandles = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const player_1 = require("@remotion/player");
5
6
  const react_1 = require("react");
6
7
  const remotion_1 = require("remotion");
7
8
  const no_react_1 = require("remotion/no-react");
@@ -24,11 +25,11 @@ const style = {
24
25
  exports.inOutHandles = (0, react_1.createRef)();
25
26
  exports.defaultInOutValue = { inFrame: null, outFrame: null };
26
27
  const TimelineInOutPointToggle = () => {
27
- const timelinePosition = remotion_1.Internals.Timeline.useTimelinePosition();
28
28
  const { inFrame, outFrame } = (0, in_out_1.useTimelineInOutFramePosition)();
29
29
  const { setInAndOutFrames } = (0, in_out_1.useTimelineSetInOutFramePosition)();
30
30
  const videoConfig = remotion_1.Internals.useUnsafeVideoConfig();
31
31
  const keybindings = (0, use_keybinding_1.useKeybinding)();
32
+ const { getCurrentFrame, isFirstFrame, isLastFrame } = player_1.PlayerInternals.usePlayer();
32
33
  const onInOutClear = (0, react_1.useCallback)((composition) => {
33
34
  setInAndOutFrames((prev) => {
34
35
  return {
@@ -61,7 +62,7 @@ const TimelineInOutPointToggle = () => {
61
62
  var _a, _b, _c, _d, _e;
62
63
  const prevOut = (_a = prev[videoConfig.id]) === null || _a === void 0 ? void 0 : _a.outFrame;
63
64
  const biggestPossible = prevOut === undefined || prevOut === null ? Infinity : prevOut - 1;
64
- const selected = Math.min(timelinePosition, biggestPossible);
65
+ const selected = Math.min(getCurrentFrame(), biggestPossible);
65
66
  if (selected === 0) {
66
67
  return {
67
68
  ...prev,
@@ -92,7 +93,7 @@ const TimelineInOutPointToggle = () => {
92
93
  },
93
94
  };
94
95
  });
95
- }, [setInAndOutFrames, timelinePosition, videoConfig]);
96
+ }, [getCurrentFrame, setInAndOutFrames, videoConfig]);
96
97
  const clearInMark = (0, react_1.useCallback)((e) => {
97
98
  if (!videoConfig) {
98
99
  return null;
@@ -148,7 +149,7 @@ const TimelineInOutPointToggle = () => {
148
149
  const smallestPossible = prevInFrame === null || prevInFrame === undefined
149
150
  ? -Infinity
150
151
  : prevInFrame + 1;
151
- const selected = Math.max(timelinePosition, smallestPossible);
152
+ const selected = Math.max(getCurrentFrame(), smallestPossible);
152
153
  if (selected === videoConfig.durationInFrames - 1) {
153
154
  return {
154
155
  ...prev,
@@ -178,7 +179,7 @@ const TimelineInOutPointToggle = () => {
178
179
  },
179
180
  };
180
181
  });
181
- }, [setInAndOutFrames, timelinePosition, videoConfig]);
182
+ }, [getCurrentFrame, setInAndOutFrames, videoConfig]);
182
183
  const confId = videoConfig === null || videoConfig === void 0 ? void 0 : videoConfig.id;
183
184
  (0, react_1.useEffect)(() => {
184
185
  if (!confId) {
@@ -235,6 +236,6 @@ const TimelineInOutPointToggle = () => {
235
236
  outMarkClick: onOutMark,
236
237
  };
237
238
  }, [confId, onInMark, onInOutClear, onOutMark]);
238
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ControlButton_1.ControlButton, { title: getTooltipText('In', 'I'), "aria-label": getTooltipText('In', 'I'), onClick: (e) => onInMark(e), onContextMenu: clearInMark, disabled: !videoConfig || timelinePosition === 0, children: (0, jsx_runtime_1.jsx)(timelineInOutPointer_1.TimelineInPointer, { color: inFrame === null ? 'white' : colors_1.BLUE, style: style }) }), (0, jsx_runtime_1.jsx)(ControlButton_1.ControlButton, { title: getTooltipText('Out', 'O'), "aria-label": getTooltipText('Out', 'O'), onClick: onOutMark, onContextMenu: clearOutMark, disabled: !videoConfig || timelinePosition === videoConfig.durationInFrames - 1, children: (0, jsx_runtime_1.jsx)(timelineInOutPointer_1.TimelineOutPointer, { color: outFrame === null ? 'white' : colors_1.BLUE, style: style }) })] }));
239
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ControlButton_1.ControlButton, { title: getTooltipText('In', 'I'), "aria-label": getTooltipText('In', 'I'), onClick: onInMark, onContextMenu: clearInMark, disabled: !videoConfig || isFirstFrame, children: (0, jsx_runtime_1.jsx)(timelineInOutPointer_1.TimelineInPointer, { color: inFrame === null ? 'white' : colors_1.BLUE, style: style }) }), (0, jsx_runtime_1.jsx)(ControlButton_1.ControlButton, { title: getTooltipText('Out', 'O'), "aria-label": getTooltipText('Out', 'O'), onClick: onOutMark, onContextMenu: clearOutMark, disabled: !videoConfig || isLastFrame, children: (0, jsx_runtime_1.jsx)(timelineInOutPointer_1.TimelineOutPointer, { color: outFrame === null ? 'white' : colors_1.BLUE, style: style }) })] }));
239
240
  };
240
241
  exports.TimelineInOutPointToggle = TimelineInOutPointToggle;
@@ -1,10 +1,8 @@
1
- import type { Size } from '@remotion/player';
2
1
  import React from 'react';
3
2
  export declare const useResponsiveSidebarStatus: () => "collapsed" | "expanded";
4
3
  export declare const TopPanel: React.FC<{
5
4
  readonly readOnlyStudio: boolean;
6
5
  readonly onMounted: () => void;
7
- readonly size: Size | null;
8
6
  readonly drawRef: React.RefObject<HTMLDivElement>;
9
7
  readonly bufferStateDelayInMilliseconds: number;
10
8
  }>;
@@ -10,7 +10,7 @@ const mobile_layout_1 = require("../helpers/mobile-layout");
10
10
  const use_breakpoint_1 = require("../helpers/use-breakpoint");
11
11
  const editor_rulers_1 = require("../state/editor-rulers");
12
12
  const sidebar_1 = require("../state/sidebar");
13
- const CanvasOrLoading_1 = require("./CanvasOrLoading");
13
+ const CanvasIfSizeIsAvailable_1 = require("./CanvasIfSizeIsAvailable");
14
14
  const CurrentCompositionSideEffects_1 = require("./CurrentCompositionSideEffects");
15
15
  const use_is_ruler_visible_1 = require("./EditorRuler/use-is-ruler-visible");
16
16
  const ExplorerPanel_1 = require("./ExplorerPanel");
@@ -48,7 +48,7 @@ const useResponsiveSidebarStatus = () => {
48
48
  return actualStateLeft;
49
49
  };
50
50
  exports.useResponsiveSidebarStatus = useResponsiveSidebarStatus;
51
- const TopPanel = ({ readOnlyStudio, onMounted, size, drawRef, bufferStateDelayInMilliseconds, }) => {
51
+ const TopPanel = ({ readOnlyStudio, onMounted, drawRef, bufferStateDelayInMilliseconds }) => {
52
52
  const { setSidebarCollapsedState, sidebarCollapsedStateRight } = (0, react_1.useContext)(sidebar_1.SidebarContext);
53
53
  const rulersAreVisible = (0, use_is_ruler_visible_1.useIsRulerVisible)();
54
54
  const actualStateLeft = (0, exports.useResponsiveSidebarStatus)();
@@ -58,29 +58,15 @@ const TopPanel = ({ readOnlyStudio, onMounted, size, drawRef, bufferStateDelayIn
58
58
  }
59
59
  return 'expanded';
60
60
  }, [sidebarCollapsedStateRight]);
61
- const hasSize = size !== null;
62
61
  (0, react_1.useEffect)(() => {
63
62
  onMounted();
64
- }, [hasSize, onMounted]);
63
+ }, [onMounted]);
65
64
  const canvasContainerStyle = (0, react_1.useMemo)(() => ({
66
65
  flex: 1,
67
66
  display: 'flex',
68
67
  paddingTop: rulersAreVisible ? editor_rulers_1.RULER_WIDTH : 0,
69
68
  paddingLeft: rulersAreVisible ? editor_rulers_1.RULER_WIDTH : 0,
70
69
  }), [rulersAreVisible]);
71
- const sizeWithRulersApplied = (0, react_1.useMemo)(() => {
72
- if (!rulersAreVisible) {
73
- return size;
74
- }
75
- if (!size) {
76
- return null;
77
- }
78
- return {
79
- ...size,
80
- width: size.width - editor_rulers_1.RULER_WIDTH,
81
- height: size.height - editor_rulers_1.RULER_WIDTH,
82
- };
83
- }, [rulersAreVisible, size]);
84
70
  const onCollapseLeft = (0, react_1.useCallback)(() => {
85
71
  setSidebarCollapsedState({ left: 'collapsed', right: null });
86
72
  }, [setSidebarCollapsedState]);
@@ -88,6 +74,6 @@ const TopPanel = ({ readOnlyStudio, onMounted, size, drawRef, bufferStateDelayIn
88
74
  setSidebarCollapsedState({ left: null, right: 'collapsed' });
89
75
  }, [setSidebarCollapsedState]);
90
76
  const isMobileLayout = (0, mobile_layout_1.useMobileLayout)();
91
- return ((0, jsx_runtime_1.jsxs)("div", { style: container, children: [(0, jsx_runtime_1.jsx)("div", { style: row, children: (0, jsx_runtime_1.jsxs)(SplitterContainer_1.SplitterContainer, { minFlex: 0.15, maxFlex: 0.4, defaultFlex: 0.2, id: "sidebar-to-preview", orientation: "vertical", children: [actualStateLeft === 'expanded' ? (isMobileLayout ? ((0, jsx_runtime_1.jsx)(MobilePanel_1.default, { onClose: onCollapseLeft, children: (0, jsx_runtime_1.jsx)(ExplorerPanel_1.ExplorerPanel, { readOnlyStudio: readOnlyStudio }) })) : ((0, jsx_runtime_1.jsx)(SplitterElement_1.SplitterElement, { sticky: null, type: "flexer", children: (0, jsx_runtime_1.jsx)(ExplorerPanel_1.ExplorerPanel, { readOnlyStudio: readOnlyStudio }) }))) : null, actualStateLeft === 'expanded' ? ((0, jsx_runtime_1.jsx)(SplitterHandle_1.SplitterHandle, { allowToCollapse: "left", onCollapse: onCollapseLeft })) : null, (0, jsx_runtime_1.jsx)(SplitterElement_1.SplitterElement, { sticky: null, type: "anti-flexer", children: (0, jsx_runtime_1.jsxs)(SplitterContainer_1.SplitterContainer, { minFlex: 0.5, maxFlex: 0.8, defaultFlex: 0.7, id: "canvas-to-right-sidebar", orientation: "vertical", children: [(0, jsx_runtime_1.jsx)(SplitterElement_1.SplitterElement, { sticky: null, type: "flexer", children: (0, jsx_runtime_1.jsx)("div", { ref: drawRef, style: canvasContainerStyle, children: sizeWithRulersApplied ? ((0, jsx_runtime_1.jsx)(CanvasOrLoading_1.CanvasOrLoading, { size: sizeWithRulersApplied })) : null }) }), actualStateRight === 'expanded' ? ((0, jsx_runtime_1.jsx)(SplitterHandle_1.SplitterHandle, { allowToCollapse: "right", onCollapse: onCollapseRight })) : null, actualStateRight === 'expanded' ? (isMobileLayout ? ((0, jsx_runtime_1.jsx)(MobilePanel_1.default, { onClose: onCollapseRight, children: (0, jsx_runtime_1.jsx)(OptionsPanel_1.OptionsPanel, { readOnlyStudio: readOnlyStudio }) })) : ((0, jsx_runtime_1.jsx)(SplitterElement_1.SplitterElement, { sticky: null, type: "anti-flexer", children: (0, jsx_runtime_1.jsx)(OptionsPanel_1.OptionsPanel, { readOnlyStudio: readOnlyStudio }) }))) : null] }) })] }) }), (0, jsx_runtime_1.jsx)(PreviewToolbar_1.PreviewToolbar, { bufferStateDelayInMilliseconds: bufferStateDelayInMilliseconds, readOnlyStudio: readOnlyStudio }), (0, jsx_runtime_1.jsx)(CurrentCompositionSideEffects_1.CurrentCompositionKeybindings, { readOnlyStudio: readOnlyStudio }), (0, jsx_runtime_1.jsx)(CurrentCompositionSideEffects_1.TitleUpdater, {})] }));
77
+ return ((0, jsx_runtime_1.jsxs)("div", { style: container, children: [(0, jsx_runtime_1.jsx)("div", { style: row, children: (0, jsx_runtime_1.jsxs)(SplitterContainer_1.SplitterContainer, { minFlex: 0.15, maxFlex: 0.4, defaultFlex: 0.2, id: "sidebar-to-preview", orientation: "vertical", children: [actualStateLeft === 'expanded' ? (isMobileLayout ? ((0, jsx_runtime_1.jsx)(MobilePanel_1.default, { onClose: onCollapseLeft, children: (0, jsx_runtime_1.jsx)(ExplorerPanel_1.ExplorerPanel, { readOnlyStudio: readOnlyStudio }) })) : ((0, jsx_runtime_1.jsx)(SplitterElement_1.SplitterElement, { sticky: null, type: "flexer", children: (0, jsx_runtime_1.jsx)(ExplorerPanel_1.ExplorerPanel, { readOnlyStudio: readOnlyStudio }) }))) : null, actualStateLeft === 'expanded' ? ((0, jsx_runtime_1.jsx)(SplitterHandle_1.SplitterHandle, { allowToCollapse: "left", onCollapse: onCollapseLeft })) : null, (0, jsx_runtime_1.jsx)(SplitterElement_1.SplitterElement, { sticky: null, type: "anti-flexer", children: (0, jsx_runtime_1.jsxs)(SplitterContainer_1.SplitterContainer, { minFlex: 0.5, maxFlex: 0.8, defaultFlex: 0.7, id: "canvas-to-right-sidebar", orientation: "vertical", children: [(0, jsx_runtime_1.jsx)(SplitterElement_1.SplitterElement, { sticky: null, type: "flexer", children: (0, jsx_runtime_1.jsx)("div", { ref: drawRef, style: canvasContainerStyle, children: (0, jsx_runtime_1.jsx)(CanvasIfSizeIsAvailable_1.CanvasIfSizeIsAvailable, {}) }) }), actualStateRight === 'expanded' ? ((0, jsx_runtime_1.jsx)(SplitterHandle_1.SplitterHandle, { allowToCollapse: "right", onCollapse: onCollapseRight })) : null, actualStateRight === 'expanded' ? (isMobileLayout ? ((0, jsx_runtime_1.jsx)(MobilePanel_1.default, { onClose: onCollapseRight, children: (0, jsx_runtime_1.jsx)(OptionsPanel_1.OptionsPanel, { readOnlyStudio: readOnlyStudio }) })) : ((0, jsx_runtime_1.jsx)(SplitterElement_1.SplitterElement, { sticky: null, type: "anti-flexer", children: (0, jsx_runtime_1.jsx)(OptionsPanel_1.OptionsPanel, { readOnlyStudio: readOnlyStudio }) }))) : null] }) })] }) }), (0, jsx_runtime_1.jsx)(PreviewToolbar_1.PreviewToolbar, { bufferStateDelayInMilliseconds: bufferStateDelayInMilliseconds, readOnlyStudio: readOnlyStudio }), (0, jsx_runtime_1.jsx)(CurrentCompositionSideEffects_1.CurrentCompositionKeybindings, { readOnlyStudio: readOnlyStudio }), (0, jsx_runtime_1.jsx)(CurrentCompositionSideEffects_1.TitleUpdater, {})] }));
92
78
  };
93
79
  exports.TopPanel = TopPanel;