@remotion/cli 3.2.14 → 3.2.16
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.
- package/dist/editor/components/Button.d.ts +4 -0
- package/dist/editor/components/Button.js +24 -0
- package/dist/editor/components/Canvas.js +189 -1
- package/dist/editor/components/CopyButton.js +3 -16
- package/dist/editor/components/EditorContexts.js +1 -15
- package/dist/editor/components/KeyboardShortcutsModal.js +1 -1
- package/dist/editor/components/MenuToolbar.js +9 -7
- package/dist/editor/components/PlaybackRateSelector.js +5 -0
- package/dist/editor/components/Preview.d.ts +1 -0
- package/dist/editor/components/Preview.js +17 -9
- package/dist/editor/components/PreviewZoomControls.d.ts +2 -0
- package/dist/editor/components/PreviewZoomControls.js +67 -0
- package/dist/editor/components/ResetZoomButton.d.ts +4 -0
- package/dist/editor/components/ResetZoomButton.js +9 -0
- package/dist/editor/components/SizeSelector.d.ts +2 -1
- package/dist/editor/components/SizeSelector.js +58 -18
- package/dist/editor/helpers/get-effective-translation.d.ts +26 -0
- package/dist/editor/helpers/get-effective-translation.js +45 -0
- package/dist/editor/helpers/is-current-selected-still.d.ts +4 -0
- package/dist/editor/helpers/is-current-selected-still.js +15 -1
- package/dist/editor/helpers/normalize-wheel.d.ts +5 -0
- package/dist/editor/helpers/normalize-wheel.js +20 -0
- package/dist/editor/helpers/normalize-zoom.d.ts +1 -0
- package/dist/editor/helpers/normalize-zoom.js +16 -0
- package/dist/editor/state/preview-size.d.ts +5 -2
- package/dist/editor/state/preview-size.js +39 -5
- package/dist/smooth-zoom.d.ts +4 -0
- package/dist/smooth-zoom.js +20 -0
- package/package.json +7 -7
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Button = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const colors_1 = require("../helpers/colors");
|
|
6
|
+
const layout_1 = require("./layout");
|
|
7
|
+
const container = {
|
|
8
|
+
padding: 10,
|
|
9
|
+
cursor: 'pointer',
|
|
10
|
+
fontSize: 14,
|
|
11
|
+
};
|
|
12
|
+
const button = {
|
|
13
|
+
border: `1px solid ${colors_1.INPUT_BORDER_COLOR_UNHOVERED}`,
|
|
14
|
+
borderRadius: 4,
|
|
15
|
+
backgroundColor: colors_1.INPUT_BACKGROUND,
|
|
16
|
+
appearance: 'none',
|
|
17
|
+
fontFamily: 'inherit',
|
|
18
|
+
fontSize: 14,
|
|
19
|
+
color: 'white',
|
|
20
|
+
};
|
|
21
|
+
const Button = ({ children, ...props }) => {
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)("button", { ...props, style: button, type: "button", children: (0, jsx_runtime_1.jsx)(layout_1.Row, { style: container, children: children }) }));
|
|
23
|
+
};
|
|
24
|
+
exports.Button = Button;
|
|
@@ -4,8 +4,15 @@ exports.Canvas = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const player_1 = require("@remotion/player");
|
|
6
6
|
const react_1 = require("react");
|
|
7
|
+
const smooth_zoom_1 = require("../../smooth-zoom");
|
|
7
8
|
const colors_1 = require("../helpers/colors");
|
|
9
|
+
const get_effective_translation_1 = require("../helpers/get-effective-translation");
|
|
10
|
+
const is_current_selected_still_1 = require("../helpers/is-current-selected-still");
|
|
11
|
+
const use_keybinding_1 = require("../helpers/use-keybinding");
|
|
12
|
+
const preview_size_1 = require("../state/preview-size");
|
|
13
|
+
const layout_1 = require("./layout");
|
|
8
14
|
const Preview_1 = require("./Preview");
|
|
15
|
+
const ResetZoomButton_1 = require("./ResetZoomButton");
|
|
9
16
|
const container = {
|
|
10
17
|
flex: 1,
|
|
11
18
|
display: 'flex',
|
|
@@ -13,12 +20,193 @@ const container = {
|
|
|
13
20
|
position: 'relative',
|
|
14
21
|
backgroundColor: colors_1.BACKGROUND,
|
|
15
22
|
};
|
|
23
|
+
const resetZoom = {
|
|
24
|
+
position: 'absolute',
|
|
25
|
+
top: layout_1.SPACING_UNIT * 2,
|
|
26
|
+
right: layout_1.SPACING_UNIT * 2,
|
|
27
|
+
};
|
|
28
|
+
const ZOOM_PX_FACTOR = 0.003;
|
|
16
29
|
const Canvas = () => {
|
|
30
|
+
const dimensions = (0, is_current_selected_still_1.useDimensions)();
|
|
17
31
|
const ref = (0, react_1.useRef)(null);
|
|
32
|
+
const { setSize, size: previewSize } = (0, react_1.useContext)(preview_size_1.PreviewSizeContext);
|
|
33
|
+
const keybindings = (0, use_keybinding_1.useKeybinding)();
|
|
18
34
|
const size = player_1.PlayerInternals.useElementSize(ref, {
|
|
19
35
|
triggerOnWindowResize: false,
|
|
20
36
|
shouldApplyCssTransforms: true,
|
|
21
37
|
});
|
|
22
|
-
|
|
38
|
+
const isFit = previewSize.size === 'auto' ||
|
|
39
|
+
(previewSize.size === 1 &&
|
|
40
|
+
previewSize.translation.x === 0 &&
|
|
41
|
+
previewSize.translation.y === 0);
|
|
42
|
+
const onWheel = (0, react_1.useCallback)((e) => {
|
|
43
|
+
if (!size) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (!dimensions) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const wantsToZoom = e.ctrlKey || e.metaKey;
|
|
50
|
+
if (!wantsToZoom && isFit) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
e.preventDefault();
|
|
54
|
+
setSize((prevSize) => {
|
|
55
|
+
const scale = player_1.PlayerInternals.calculateScale({
|
|
56
|
+
canvasSize: size,
|
|
57
|
+
compositionHeight: dimensions.height,
|
|
58
|
+
compositionWidth: dimensions.width,
|
|
59
|
+
previewSize: prevSize.size,
|
|
60
|
+
});
|
|
61
|
+
// Zoom in/out
|
|
62
|
+
if (wantsToZoom) {
|
|
63
|
+
const oldSize = prevSize.size === 'auto' ? scale : prevSize.size;
|
|
64
|
+
const smoothened = (0, smooth_zoom_1.smoothenZoom)(oldSize);
|
|
65
|
+
const added = smoothened + e.deltaY * ZOOM_PX_FACTOR;
|
|
66
|
+
const unsmoothened = (0, smooth_zoom_1.unsmoothenZoom)(added);
|
|
67
|
+
const { centerX, centerY } = (0, get_effective_translation_1.getCenterPointWhileScrolling)({
|
|
68
|
+
size,
|
|
69
|
+
clientX: e.clientX,
|
|
70
|
+
clientY: e.clientY,
|
|
71
|
+
compositionWidth: dimensions.width,
|
|
72
|
+
compositionHeight: dimensions.height,
|
|
73
|
+
scale,
|
|
74
|
+
translation: prevSize.translation,
|
|
75
|
+
});
|
|
76
|
+
const zoomDifference = unsmoothened - oldSize;
|
|
77
|
+
const uvCoordinatesX = centerX / dimensions.width;
|
|
78
|
+
const uvCoordinatesY = centerY / dimensions.height;
|
|
79
|
+
const correctionLeft = -uvCoordinatesX * (zoomDifference * dimensions.width) +
|
|
80
|
+
(1 - uvCoordinatesX) * zoomDifference * dimensions.width;
|
|
81
|
+
const correctionTop = -uvCoordinatesY * (zoomDifference * dimensions.height) +
|
|
82
|
+
(1 - uvCoordinatesY) * zoomDifference * dimensions.height;
|
|
83
|
+
return {
|
|
84
|
+
translation: (0, get_effective_translation_1.getEffectiveTranslation)({
|
|
85
|
+
translation: {
|
|
86
|
+
x: prevSize.translation.x - correctionLeft / 2,
|
|
87
|
+
y: prevSize.translation.y - correctionTop / 2,
|
|
88
|
+
},
|
|
89
|
+
canvasSize: size,
|
|
90
|
+
compositionHeight: dimensions.height,
|
|
91
|
+
compositionWidth: dimensions.width,
|
|
92
|
+
scale,
|
|
93
|
+
}),
|
|
94
|
+
size: unsmoothened,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
const effectiveTranslation = (0, get_effective_translation_1.getEffectiveTranslation)({
|
|
98
|
+
translation: prevSize.translation,
|
|
99
|
+
canvasSize: size,
|
|
100
|
+
compositionHeight: dimensions.height,
|
|
101
|
+
compositionWidth: dimensions.width,
|
|
102
|
+
scale,
|
|
103
|
+
});
|
|
104
|
+
// Pan
|
|
105
|
+
return {
|
|
106
|
+
...prevSize,
|
|
107
|
+
translation: (0, get_effective_translation_1.getEffectiveTranslation)({
|
|
108
|
+
translation: {
|
|
109
|
+
x: effectiveTranslation.x + e.deltaX,
|
|
110
|
+
y: effectiveTranslation.y + e.deltaY,
|
|
111
|
+
},
|
|
112
|
+
canvasSize: size,
|
|
113
|
+
compositionHeight: dimensions.height,
|
|
114
|
+
compositionWidth: dimensions.width,
|
|
115
|
+
scale,
|
|
116
|
+
}),
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
}, [dimensions, isFit, setSize, size]);
|
|
120
|
+
(0, react_1.useEffect)(() => {
|
|
121
|
+
const { current } = ref;
|
|
122
|
+
if (!current) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
current.addEventListener('wheel', onWheel);
|
|
126
|
+
return () => current.removeEventListener('wheel', onWheel);
|
|
127
|
+
}, [onWheel]);
|
|
128
|
+
const onReset = (0, react_1.useCallback)(() => {
|
|
129
|
+
setSize(() => {
|
|
130
|
+
return {
|
|
131
|
+
translation: {
|
|
132
|
+
x: 0,
|
|
133
|
+
y: 0,
|
|
134
|
+
},
|
|
135
|
+
size: 'auto',
|
|
136
|
+
};
|
|
137
|
+
});
|
|
138
|
+
}, [setSize]);
|
|
139
|
+
const onZoomIn = (0, react_1.useCallback)(() => {
|
|
140
|
+
if (!dimensions) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (!size) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
setSize((prevSize) => {
|
|
147
|
+
const scale = player_1.PlayerInternals.calculateScale({
|
|
148
|
+
canvasSize: size,
|
|
149
|
+
compositionHeight: dimensions.height,
|
|
150
|
+
compositionWidth: dimensions.width,
|
|
151
|
+
previewSize: prevSize.size,
|
|
152
|
+
});
|
|
153
|
+
return {
|
|
154
|
+
translation: {
|
|
155
|
+
x: 0,
|
|
156
|
+
y: 0,
|
|
157
|
+
},
|
|
158
|
+
size: Math.min(smooth_zoom_1.MAX_ZOOM, scale * 2),
|
|
159
|
+
};
|
|
160
|
+
});
|
|
161
|
+
}, [dimensions, setSize, size]);
|
|
162
|
+
const onZoomOut = (0, react_1.useCallback)(() => {
|
|
163
|
+
if (!dimensions) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (!size) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
setSize((prevSize) => {
|
|
170
|
+
const scale = player_1.PlayerInternals.calculateScale({
|
|
171
|
+
canvasSize: size,
|
|
172
|
+
compositionHeight: dimensions.height,
|
|
173
|
+
compositionWidth: dimensions.width,
|
|
174
|
+
previewSize: prevSize.size,
|
|
175
|
+
});
|
|
176
|
+
return {
|
|
177
|
+
translation: {
|
|
178
|
+
x: 0,
|
|
179
|
+
y: 0,
|
|
180
|
+
},
|
|
181
|
+
size: Math.max(smooth_zoom_1.MIN_ZOOM, scale / 2),
|
|
182
|
+
};
|
|
183
|
+
});
|
|
184
|
+
}, [dimensions, setSize, size]);
|
|
185
|
+
(0, react_1.useEffect)(() => {
|
|
186
|
+
const resetBinding = keybindings.registerKeybinding({
|
|
187
|
+
event: 'keydown',
|
|
188
|
+
key: '0',
|
|
189
|
+
commandCtrlKey: false,
|
|
190
|
+
callback: onReset,
|
|
191
|
+
});
|
|
192
|
+
const zoomIn = keybindings.registerKeybinding({
|
|
193
|
+
event: 'keydown',
|
|
194
|
+
key: '+',
|
|
195
|
+
commandCtrlKey: false,
|
|
196
|
+
callback: onZoomIn,
|
|
197
|
+
});
|
|
198
|
+
const zoomOut = keybindings.registerKeybinding({
|
|
199
|
+
event: 'keydown',
|
|
200
|
+
key: '-',
|
|
201
|
+
commandCtrlKey: false,
|
|
202
|
+
callback: onZoomOut,
|
|
203
|
+
});
|
|
204
|
+
return () => {
|
|
205
|
+
resetBinding.unregister();
|
|
206
|
+
zoomIn.unregister();
|
|
207
|
+
zoomOut.unregister();
|
|
208
|
+
};
|
|
209
|
+
}, [keybindings, onReset, onZoomIn, onZoomOut]);
|
|
210
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: ref, style: container, children: [size ? (0, jsx_runtime_1.jsx)(Preview_1.VideoPreview, { canvasSize: size }) : null, isFit ? null : ((0, jsx_runtime_1.jsx)("div", { style: resetZoom, children: (0, jsx_runtime_1.jsx)(ResetZoomButton_1.ResetZoomButton, { onClick: onReset }) }))] }));
|
|
23
211
|
};
|
|
24
212
|
exports.Canvas = Canvas;
|
|
@@ -3,29 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CopyButton = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
-
const
|
|
6
|
+
const Button_1 = require("../../preview-server/error-overlay/remotion-overlay/Button");
|
|
7
7
|
const copy_text_1 = require("../helpers/copy-text");
|
|
8
8
|
const layout_1 = require("./layout");
|
|
9
9
|
const iconStyle = {
|
|
10
10
|
width: 16,
|
|
11
11
|
height: 16,
|
|
12
12
|
color: 'white',
|
|
13
|
+
verticalAlign: 'sub',
|
|
13
14
|
};
|
|
14
15
|
const copyIcon = ((0, jsx_runtime_1.jsx)("svg", { "aria-hidden": "true", focusable: "false", "data-prefix": "far", "data-icon": "clipboard", className: "svg-inline--fa fa-clipboard fa-w-12", role: "img", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 384 512", style: iconStyle, children: (0, jsx_runtime_1.jsx)("path", { fill: "currentColor", d: "M336 64h-80c0-35.3-28.7-64-64-64s-64 28.7-64 64H48C21.5 64 0 85.5 0 112v352c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V112c0-26.5-21.5-48-48-48zM192 40c13.3 0 24 10.7 24 24s-10.7 24-24 24-24-10.7-24-24 10.7-24 24-24zm144 418c0 3.3-2.7 6-6 6H54c-3.3 0-6-2.7-6-6V118c0-3.3 2.7-6 6-6h42v36c0 6.6 5.4 12 12 12h168c6.6 0 12-5.4 12-12v-36h42c3.3 0 6 2.7 6 6z" }) }));
|
|
15
|
-
const container = {
|
|
16
|
-
padding: 10,
|
|
17
|
-
cursor: 'pointer',
|
|
18
|
-
fontSize: 14,
|
|
19
|
-
};
|
|
20
|
-
const button = {
|
|
21
|
-
border: `1px solid ${colors_1.INPUT_BORDER_COLOR_UNHOVERED}`,
|
|
22
|
-
borderRadius: 4,
|
|
23
|
-
backgroundColor: colors_1.INPUT_BACKGROUND,
|
|
24
|
-
appearance: 'none',
|
|
25
|
-
fontFamily: 'inherit',
|
|
26
|
-
fontSize: 14,
|
|
27
|
-
color: 'white',
|
|
28
|
-
};
|
|
29
16
|
const labelStyle = {
|
|
30
17
|
fontSize: 14,
|
|
31
18
|
};
|
|
@@ -42,6 +29,6 @@ const CopyButton = ({ textToCopy, label, labelWhenCopied }) => {
|
|
|
42
29
|
const to = setTimeout(() => setCopied(false), 2000);
|
|
43
30
|
return () => clearTimeout(to);
|
|
44
31
|
}, [copied]);
|
|
45
|
-
return ((0, jsx_runtime_1.
|
|
32
|
+
return ((0, jsx_runtime_1.jsxs)(Button_1.Button, { onClick: onClick, children: [copyIcon, (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 1.5 }), ' ', (0, jsx_runtime_1.jsx)("span", { style: labelStyle, children: copied ? labelWhenCopied : label })] }));
|
|
46
33
|
};
|
|
47
34
|
exports.CopyButton = CopyButton;
|
|
@@ -24,7 +24,6 @@ const EditorContexts = ({ children }) => {
|
|
|
24
24
|
return inAndOutFrames;
|
|
25
25
|
}, [inAndOutFrames]);
|
|
26
26
|
const [emitter] = (0, react_1.useState)(() => new player_1.PlayerInternals.PlayerEmitter());
|
|
27
|
-
const [size, setSizeState] = (0, react_1.useState)(() => (0, preview_size_1.loadPreviewSizeOption)());
|
|
28
27
|
const setTimelineInOutContextValue = (0, react_1.useMemo)(() => {
|
|
29
28
|
return {
|
|
30
29
|
setInAndOutFrames,
|
|
@@ -46,22 +45,9 @@ const EditorContexts = ({ children }) => {
|
|
|
46
45
|
return newVal;
|
|
47
46
|
});
|
|
48
47
|
}, []);
|
|
49
|
-
const setSize = (0, react_1.useCallback)((newValue) => {
|
|
50
|
-
setSizeState((prevState) => {
|
|
51
|
-
const newVal = newValue(prevState);
|
|
52
|
-
(0, preview_size_1.persistPreviewSizeOption)(newVal);
|
|
53
|
-
return newVal;
|
|
54
|
-
});
|
|
55
|
-
}, []);
|
|
56
48
|
const [mediaMuted, setMediaMuted] = (0, react_1.useState)(() => (0, mute_1.loadMuteOption)());
|
|
57
49
|
const [mediaVolume, setMediaVolume] = (0, react_1.useState)(1);
|
|
58
50
|
const [modalContextType, setModalContextType] = (0, react_1.useState)(null);
|
|
59
|
-
const previewSizeCtx = (0, react_1.useMemo)(() => {
|
|
60
|
-
return {
|
|
61
|
-
size,
|
|
62
|
-
setSize,
|
|
63
|
-
};
|
|
64
|
-
}, [setSize, size]);
|
|
65
51
|
const checkerboardCtx = (0, react_1.useMemo)(() => {
|
|
66
52
|
return {
|
|
67
53
|
checkerboard,
|
|
@@ -92,6 +78,6 @@ const EditorContexts = ({ children }) => {
|
|
|
92
78
|
setSelectedModal: setModalContextType,
|
|
93
79
|
};
|
|
94
80
|
}, [modalContextType]);
|
|
95
|
-
return ((0, jsx_runtime_1.jsx)(keybindings_1.KeybindingContextProvider, { children: (0, jsx_runtime_1.jsx)(rich_timeline_1.RichTimelineContext.Provider, { value: richTimelineCtx, children: (0, jsx_runtime_1.jsx)(checkerboard_1.CheckerboardContext.Provider, { value: checkerboardCtx, children: (0, jsx_runtime_1.jsx)(preview_size_1.
|
|
81
|
+
return ((0, jsx_runtime_1.jsx)(keybindings_1.KeybindingContextProvider, { children: (0, jsx_runtime_1.jsx)(rich_timeline_1.RichTimelineContext.Provider, { value: richTimelineCtx, children: (0, jsx_runtime_1.jsx)(checkerboard_1.CheckerboardContext.Provider, { value: checkerboardCtx, children: (0, jsx_runtime_1.jsx)(preview_size_1.PreviewSizeProvider, { children: (0, jsx_runtime_1.jsx)(modals_1.ModalsContext.Provider, { value: modalsContext, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.MediaVolumeContext.Provider, { value: mediaVolumeContextValue, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.SetMediaVolumeContext.Provider, { value: setMediaVolumeContextValue, children: (0, jsx_runtime_1.jsx)(player_1.PlayerInternals.PlayerEventEmitterContext.Provider, { value: emitter, children: (0, jsx_runtime_1.jsx)(sidebar_1.SidebarContextProvider, { children: (0, jsx_runtime_1.jsx)(folders_1.FolderContextProvider, { children: (0, jsx_runtime_1.jsx)(highest_z_index_1.HighestZIndexProvider, { children: (0, jsx_runtime_1.jsx)(in_out_1.TimelineInOutContext.Provider, { value: timelineInOutContextValue, children: (0, jsx_runtime_1.jsx)(in_out_1.SetTimelineInOutContext.Provider, { value: setTimelineInOutContextValue, children: children }) }) }) }) }) }) }) }) }) }) }) }) }));
|
|
96
82
|
};
|
|
97
83
|
exports.EditorContexts = EditorContexts;
|
|
@@ -62,6 +62,6 @@ const KeyboardShortcuts = () => {
|
|
|
62
62
|
const onQuit = (0, react_1.useCallback)(() => {
|
|
63
63
|
setSelectedModal(null);
|
|
64
64
|
}, [setSelectedModal]);
|
|
65
|
-
return ((0, jsx_runtime_1.jsxs)(ModalContainer_1.ModalContainer, { onEscape: onQuit, onOutsideClick: onQuit, children: [(0, jsx_runtime_1.jsx)(ModalHeader_1.NewCompHeader, { title: "Keyboard shortcuts" }), (0, use_keybinding_1.areKeyboardShortcutsDisabled)() ? ((0, jsx_runtime_1.jsxs)("div", { style: keyboardShortcutsDisabled, children: ["Keyboard shortcuts disabled either due to:", (0, jsx_runtime_1.jsxs)("ul", { style: ul, children: [(0, jsx_runtime_1.jsx)("li", { style: li, children: "a) --disable-keyboard-shortcuts being passed" }), (0, jsx_runtime_1.jsx)("li", { style: li, children: "b) Config.Preview.setKeyboardShortcutsEnabled(false) being set or" }), (0, jsx_runtime_1.jsx)("li", { style: li, children: " c) a Remotion version mismatch." })] })] })) : null, (0, jsx_runtime_1.jsxs)(layout_1.Row, { style: container, children: [(0, jsx_runtime_1.jsxs)(layout_1.Column, { children: [(0, jsx_runtime_1.jsx)("div", { style: title, children: "Playback" }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsxs)("div", { style: left, children: [(0, jsx_runtime_1.jsx)("kbd", { style: key, children: (0, jsx_runtime_1.jsx)(keys_1.ShiftIcon, {}) }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 0.3 }), (0, jsx_runtime_1.jsx)("kbd", { style: key, children: (0, jsx_runtime_1.jsx)(keys_1.ArrowLeft, {}) })] }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "1 second back" })] }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: left, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: (0, jsx_runtime_1.jsx)(keys_1.ArrowLeft, {}) }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Previous frame" })] }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: left, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: "Space" }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Play / Pause" })] }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: left, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: (0, jsx_runtime_1.jsx)(keys_1.ArrowRight, {}) }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Next frame" })] }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsxs)("div", { style: left, children: [(0, jsx_runtime_1.jsx)("kbd", { style: key, children: (0, jsx_runtime_1.jsx)(keys_1.ShiftIcon, {}) }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 0.3 }), (0, jsx_runtime_1.jsx)("kbd", { style: key, children: (0, jsx_runtime_1.jsx)(keys_1.ArrowRight, {}) })] }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "1 second forward" })] }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: left, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: "A" }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Jump to beginning" })] }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: left, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: "E" }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Jump to end" })] }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: left, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: "J" }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Reverse playback" })] }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: left, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: "K" }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Pause" })] }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: left, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: "L" }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Play / Speed up" })] }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: left, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: "Enter" }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Pause & return to playback start" })] })] }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 8 }), (0, jsx_runtime_1.jsxs)(layout_1.Column, { children: [(0, jsx_runtime_1.jsx)("div", { style: title, children: "Navigation" }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: shortLeft, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: "N" }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "New composition" })] }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: shortLeft, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: "T" }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Toggle checkerboard transparency" })] }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: shortLeft, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: "?" }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Show keyboard shortcuts" })] }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("div", { style: title, children: "Playback range" }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: shortLeft, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: "I" }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Set In Point" })] }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: shortLeft, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: "O" }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Set Out Point" })] }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: shortLeft, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: "X" }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Clear In/Out Points" })] })] })] })] }));
|
|
65
|
+
return ((0, jsx_runtime_1.jsxs)(ModalContainer_1.ModalContainer, { onEscape: onQuit, onOutsideClick: onQuit, children: [(0, jsx_runtime_1.jsx)(ModalHeader_1.NewCompHeader, { title: "Keyboard shortcuts" }), (0, use_keybinding_1.areKeyboardShortcutsDisabled)() ? ((0, jsx_runtime_1.jsxs)("div", { style: keyboardShortcutsDisabled, children: ["Keyboard shortcuts disabled either due to:", (0, jsx_runtime_1.jsxs)("ul", { style: ul, children: [(0, jsx_runtime_1.jsx)("li", { style: li, children: "a) --disable-keyboard-shortcuts being passed" }), (0, jsx_runtime_1.jsx)("li", { style: li, children: "b) Config.Preview.setKeyboardShortcutsEnabled(false) being set or" }), (0, jsx_runtime_1.jsx)("li", { style: li, children: " c) a Remotion version mismatch." })] })] })) : null, (0, jsx_runtime_1.jsxs)(layout_1.Row, { style: container, children: [(0, jsx_runtime_1.jsxs)(layout_1.Column, { children: [(0, jsx_runtime_1.jsx)("div", { style: title, children: "Playback" }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsxs)("div", { style: left, children: [(0, jsx_runtime_1.jsx)("kbd", { style: key, children: (0, jsx_runtime_1.jsx)(keys_1.ShiftIcon, {}) }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 0.3 }), (0, jsx_runtime_1.jsx)("kbd", { style: key, children: (0, jsx_runtime_1.jsx)(keys_1.ArrowLeft, {}) })] }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "1 second back" })] }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: left, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: (0, jsx_runtime_1.jsx)(keys_1.ArrowLeft, {}) }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Previous frame" })] }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: left, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: "Space" }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Play / Pause" })] }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: left, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: (0, jsx_runtime_1.jsx)(keys_1.ArrowRight, {}) }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Next frame" })] }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsxs)("div", { style: left, children: [(0, jsx_runtime_1.jsx)("kbd", { style: key, children: (0, jsx_runtime_1.jsx)(keys_1.ShiftIcon, {}) }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 0.3 }), (0, jsx_runtime_1.jsx)("kbd", { style: key, children: (0, jsx_runtime_1.jsx)(keys_1.ArrowRight, {}) })] }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "1 second forward" })] }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: left, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: "A" }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Jump to beginning" })] }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: left, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: "E" }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Jump to end" })] }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: left, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: "J" }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Reverse playback" })] }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: left, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: "K" }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Pause" })] }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: left, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: "L" }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Play / Speed up" })] }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: left, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: "Enter" }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Pause & return to playback start" })] })] }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 8 }), (0, jsx_runtime_1.jsxs)(layout_1.Column, { children: [(0, jsx_runtime_1.jsx)("div", { style: title, children: "Navigation" }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: shortLeft, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: "N" }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "New composition" })] }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: shortLeft, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: "T" }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Toggle checkerboard transparency" })] }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: shortLeft, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: "?" }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Show keyboard shortcuts" })] }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("div", { style: title, children: "Playback range" }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: shortLeft, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: "I" }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Set In Point" })] }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: shortLeft, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: "O" }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Set Out Point" })] }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: shortLeft, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: "X" }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Clear In/Out Points" })] }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("div", { style: title, children: "Zoom" }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: shortLeft, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: "+" }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Zoom in" })] }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: shortLeft, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: "-" }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Zoom out" })] }), (0, jsx_runtime_1.jsxs)(layout_1.Row, { align: "center", children: [(0, jsx_runtime_1.jsx)("div", { style: shortLeft, children: (0, jsx_runtime_1.jsx)("kbd", { style: key, children: "0" }) }), (0, jsx_runtime_1.jsx)("div", { style: right, children: "Reset zoom" })] })] })] })] }));
|
|
66
66
|
};
|
|
67
67
|
exports.KeyboardShortcuts = KeyboardShortcuts;
|
|
@@ -59,6 +59,7 @@ const MenuToolbar = () => {
|
|
|
59
59
|
const close = (0, react_1.useCallback)(() => {
|
|
60
60
|
setSelected(null);
|
|
61
61
|
}, []);
|
|
62
|
+
const sizes = (0, SizeSelector_1.getUniqueSizes)(size);
|
|
62
63
|
const structure = (0, react_1.useMemo)(() => {
|
|
63
64
|
const struct = [
|
|
64
65
|
{
|
|
@@ -161,19 +162,19 @@ const MenuToolbar = () => {
|
|
|
161
162
|
leftItem: null,
|
|
162
163
|
subMenu: {
|
|
163
164
|
leaveLeftSpace: true,
|
|
164
|
-
preselectIndex:
|
|
165
|
-
items:
|
|
166
|
-
id: String(newSize),
|
|
167
|
-
keyHint: null,
|
|
165
|
+
preselectIndex: sizes.findIndex((s) => String(size.size) === String(s.size)),
|
|
166
|
+
items: sizes.map((newSize) => ({
|
|
167
|
+
id: String(newSize.size),
|
|
168
|
+
keyHint: newSize.size === 1 ? '0' : null,
|
|
168
169
|
label: (0, SizeSelector_1.getPreviewSizeLabel)(newSize),
|
|
169
|
-
leftItem: String(newSize) === String(size) ? (0, jsx_runtime_1.jsx)(Checkmark_1.Checkmark, {}) : null,
|
|
170
|
+
leftItem: String(newSize.size) === String(size.size) ? ((0, jsx_runtime_1.jsx)(Checkmark_1.Checkmark, {})) : null,
|
|
170
171
|
onClick: () => {
|
|
171
172
|
close();
|
|
172
173
|
setSize(() => newSize);
|
|
173
174
|
},
|
|
174
175
|
subMenu: null,
|
|
175
176
|
type: 'item',
|
|
176
|
-
value: newSize,
|
|
177
|
+
value: newSize.size,
|
|
177
178
|
})),
|
|
178
179
|
},
|
|
179
180
|
},
|
|
@@ -479,7 +480,8 @@ const MenuToolbar = () => {
|
|
|
479
480
|
setSidebarCollapsedState,
|
|
480
481
|
setSize,
|
|
481
482
|
sidebarCollapsedState,
|
|
482
|
-
size,
|
|
483
|
+
size.size,
|
|
484
|
+
sizes,
|
|
483
485
|
]);
|
|
484
486
|
const menus = (0, react_1.useMemo)(() => {
|
|
485
487
|
return structure.map((s) => s.id);
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PlaybackRateSelector = exports.getPlaybackRateLabel = exports.commonPlaybackRates = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
+
const is_current_selected_still_1 = require("../helpers/is-current-selected-still");
|
|
6
7
|
const Checkmark_1 = require("../icons/Checkmark");
|
|
7
8
|
const playbackrate_1 = require("../state/playbackrate");
|
|
8
9
|
const ControlButton_1 = require("./ControlButton");
|
|
@@ -17,6 +18,7 @@ exports.getPlaybackRateLabel = getPlaybackRateLabel;
|
|
|
17
18
|
const accessibilityLabel = 'Change the playback rate';
|
|
18
19
|
const comboStyle = { width: 80 };
|
|
19
20
|
const PlaybackRateSelector = ({ playbackRate, setPlaybackRate }) => {
|
|
21
|
+
const isStill = (0, is_current_selected_still_1.useIsStill)();
|
|
20
22
|
const style = (0, react_1.useMemo)(() => {
|
|
21
23
|
return {
|
|
22
24
|
padding: ControlButton_1.CONTROL_BUTTON_PADDING,
|
|
@@ -47,6 +49,9 @@ const PlaybackRateSelector = ({ playbackRate, setPlaybackRate }) => {
|
|
|
47
49
|
const middle = Math.floor(exports.commonPlaybackRates.length / 2);
|
|
48
50
|
return [...values.slice(0, middle), divider, ...values.slice(middle)];
|
|
49
51
|
}, [playbackRate, setPlaybackRate]);
|
|
52
|
+
if (isStill) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
50
55
|
return ((0, jsx_runtime_1.jsx)("div", { style: style, "aria-label": accessibilityLabel, children: (0, jsx_runtime_1.jsx)(ComboBox_1.Combobox, { title: accessibilityLabel, style: comboStyle, selectedId: String(playbackRate), values: items }) }));
|
|
51
56
|
};
|
|
52
57
|
exports.PlaybackRateSelector = PlaybackRateSelector;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VideoPreview = void 0;
|
|
3
|
+
exports.VideoPreview = exports.checkerboardSize = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const player_1 = require("@remotion/player");
|
|
6
6
|
const react_1 = require("react");
|
|
@@ -8,7 +8,7 @@ const remotion_1 = require("remotion");
|
|
|
8
8
|
const checkerboard_background_1 = require("../helpers/checkerboard-background");
|
|
9
9
|
const checkerboard_1 = require("../state/checkerboard");
|
|
10
10
|
const preview_size_1 = require("../state/preview-size");
|
|
11
|
-
|
|
11
|
+
exports.checkerboardSize = 49;
|
|
12
12
|
const containerStyle = (options) => {
|
|
13
13
|
return {
|
|
14
14
|
transform: `scale(${options.scale})`,
|
|
@@ -20,8 +20,8 @@ const containerStyle = (options) => {
|
|
|
20
20
|
position: 'absolute',
|
|
21
21
|
backgroundColor: (0, checkerboard_background_1.checkerboardBackgroundColor)(options.checkerboard),
|
|
22
22
|
backgroundImage: (0, checkerboard_background_1.checkerboardBackgroundImage)(options.checkerboard),
|
|
23
|
-
backgroundSize: (0, checkerboard_background_1.getCheckerboardBackgroundSize)(checkerboardSize) /* Must be a square */,
|
|
24
|
-
backgroundPosition: (0, checkerboard_background_1.getCheckerboardBackgroundPos)(checkerboardSize) /* Must be half of one side of the square */,
|
|
23
|
+
backgroundSize: (0, checkerboard_background_1.getCheckerboardBackgroundSize)(exports.checkerboardSize) /* Must be a square */,
|
|
24
|
+
backgroundPosition: (0, checkerboard_background_1.getCheckerboardBackgroundPos)(exports.checkerboardSize) /* Must be half of one side of the square */,
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
27
|
const Inner = ({ canvasSize }) => {
|
|
@@ -29,11 +29,11 @@ const Inner = ({ canvasSize }) => {
|
|
|
29
29
|
const portalContainer = (0, react_1.useRef)(null);
|
|
30
30
|
const config = (0, remotion_1.useVideoConfig)();
|
|
31
31
|
const { checkerboard } = (0, react_1.useContext)(checkerboard_1.CheckerboardContext);
|
|
32
|
-
const { centerX, centerY, yCorrection, xCorrection, scale } = player_1.PlayerInternals.
|
|
32
|
+
const { centerX, centerY, yCorrection, xCorrection, scale } = player_1.PlayerInternals.calculateCanvasTransformation({
|
|
33
33
|
canvasSize,
|
|
34
34
|
compositionHeight: config.height,
|
|
35
35
|
compositionWidth: config.width,
|
|
36
|
-
previewSize,
|
|
36
|
+
previewSize: previewSize.size,
|
|
37
37
|
});
|
|
38
38
|
const outer = (0, react_1.useMemo)(() => {
|
|
39
39
|
return {
|
|
@@ -42,11 +42,19 @@ const Inner = ({ canvasSize }) => {
|
|
|
42
42
|
display: 'flex',
|
|
43
43
|
flexDirection: 'column',
|
|
44
44
|
position: 'absolute',
|
|
45
|
-
left: centerX,
|
|
46
|
-
top: centerY,
|
|
45
|
+
left: centerX - previewSize.translation.x,
|
|
46
|
+
top: centerY - previewSize.translation.y,
|
|
47
47
|
overflow: 'hidden',
|
|
48
48
|
};
|
|
49
|
-
}, [
|
|
49
|
+
}, [
|
|
50
|
+
centerX,
|
|
51
|
+
centerY,
|
|
52
|
+
config.height,
|
|
53
|
+
config.width,
|
|
54
|
+
previewSize.translation.x,
|
|
55
|
+
previewSize.translation.y,
|
|
56
|
+
scale,
|
|
57
|
+
]);
|
|
50
58
|
const style = (0, react_1.useMemo)(() => {
|
|
51
59
|
return containerStyle({
|
|
52
60
|
checkerboard,
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PreviewZoomControls = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const minus_1 = require("../icons/minus");
|
|
7
|
+
const plus_1 = require("../icons/plus");
|
|
8
|
+
const preview_size_1 = require("../state/preview-size");
|
|
9
|
+
const ControlButton_1 = require("./ControlButton");
|
|
10
|
+
const layout_1 = require("./layout");
|
|
11
|
+
const container = {
|
|
12
|
+
color: 'black',
|
|
13
|
+
flexDirection: 'row',
|
|
14
|
+
display: 'flex',
|
|
15
|
+
};
|
|
16
|
+
const buttonStyle = {
|
|
17
|
+
fontSize: 24,
|
|
18
|
+
};
|
|
19
|
+
const iconStyle = {
|
|
20
|
+
color: 'white',
|
|
21
|
+
width: 14,
|
|
22
|
+
};
|
|
23
|
+
const slider = {
|
|
24
|
+
width: 120,
|
|
25
|
+
accentColor: 'var(--blue)',
|
|
26
|
+
};
|
|
27
|
+
const PreviewZoomControls = () => {
|
|
28
|
+
const { size, setSize } = (0, react_1.useContext)(preview_size_1.PreviewSizeContext);
|
|
29
|
+
const onZoomOutClicked = (0, react_1.useCallback)(() => {
|
|
30
|
+
setSize((z) => {
|
|
31
|
+
if (z === 'auto')
|
|
32
|
+
return 1 - preview_size_1.ZOOM_BUTTON_STEP;
|
|
33
|
+
const newSize = Number((Number(z) - preview_size_1.ZOOM_BUTTON_STEP).toFixed(2));
|
|
34
|
+
return Math.max(preview_size_1.PREVIEW_MIN_ZOOM, newSize);
|
|
35
|
+
});
|
|
36
|
+
}, [setSize]);
|
|
37
|
+
const onZoomInClicked = (0, react_1.useCallback)(() => {
|
|
38
|
+
setSize((z) => {
|
|
39
|
+
if (z === 'auto')
|
|
40
|
+
return 1 + preview_size_1.ZOOM_BUTTON_STEP;
|
|
41
|
+
const newSize = Number((Number(z) + preview_size_1.ZOOM_BUTTON_STEP).toFixed(2));
|
|
42
|
+
return Math.min(preview_size_1.PREVIEW_MAX_ZOOM, newSize);
|
|
43
|
+
});
|
|
44
|
+
}, [setSize]);
|
|
45
|
+
const onChange = (0, react_1.useCallback)((e) => {
|
|
46
|
+
setSize(() => Number(e.target.value));
|
|
47
|
+
}, [setSize]);
|
|
48
|
+
const onWheel = (0, react_1.useCallback)((e) => {
|
|
49
|
+
setSize((z) => {
|
|
50
|
+
if (e.deltaY > 0) {
|
|
51
|
+
if (z === 'auto')
|
|
52
|
+
return 1 - preview_size_1.ZOOM_SLIDER_STEP;
|
|
53
|
+
const newSize = Number((Number(z) - preview_size_1.ZOOM_SLIDER_STEP).toFixed(2));
|
|
54
|
+
return Math.max(preview_size_1.PREVIEW_MIN_ZOOM, newSize);
|
|
55
|
+
}
|
|
56
|
+
if (e.deltaY < 0) {
|
|
57
|
+
if (z === 'auto')
|
|
58
|
+
return 1 + preview_size_1.ZOOM_SLIDER_STEP;
|
|
59
|
+
const newSize = Number((Number(z) + preview_size_1.ZOOM_SLIDER_STEP).toFixed(2));
|
|
60
|
+
return Math.min(preview_size_1.PREVIEW_MAX_ZOOM, newSize);
|
|
61
|
+
}
|
|
62
|
+
return z;
|
|
63
|
+
});
|
|
64
|
+
}, [setSize]);
|
|
65
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: container, children: [(0, jsx_runtime_1.jsx)(ControlButton_1.ControlButton, { onClick: onZoomOutClicked, style: buttonStyle, title: "Zoom out preview", role: 'ControlButton', type: "button", disabled: preview_size_1.PREVIEW_MIN_ZOOM === size, children: (0, jsx_runtime_1.jsx)(minus_1.Minus, { style: iconStyle }) }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 0.5 }), (0, jsx_runtime_1.jsx)("input", { title: `Preview size (${size}x)`, alt: `Preview size (${size}x)`, type: 'range', min: preview_size_1.PREVIEW_MIN_ZOOM, step: preview_size_1.ZOOM_SLIDER_STEP, value: size, max: preview_size_1.PREVIEW_MAX_ZOOM, onChange: onChange, onWheel: onWheel, style: slider }), (0, jsx_runtime_1.jsx)(layout_1.Spacing, { x: 0.5 }), (0, jsx_runtime_1.jsx)(ControlButton_1.ControlButton, { onClick: onZoomInClicked, style: buttonStyle, title: "Zoom in preview", role: 'button', type: "button", disabled: preview_size_1.PREVIEW_MAX_ZOOM === size, children: (0, jsx_runtime_1.jsx)(plus_1.Plus, { style: iconStyle }) })] }));
|
|
66
|
+
};
|
|
67
|
+
exports.PreviewZoomControls = PreviewZoomControls;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResetZoomButton = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const Button_1 = require("../../preview-server/error-overlay/remotion-overlay/Button");
|
|
6
|
+
const ResetZoomButton = ({ onClick }) => {
|
|
7
|
+
return (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: onClick, children: "Reset zoom" });
|
|
8
|
+
};
|
|
9
|
+
exports.ResetZoomButton = ResetZoomButton;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PreviewSize } from '@remotion/player';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
export declare const commonPreviewSizes: PreviewSize[];
|
|
4
|
-
export declare const getPreviewSizeLabel: (previewSize: PreviewSize) =>
|
|
4
|
+
export declare const getPreviewSizeLabel: (previewSize: PreviewSize) => string;
|
|
5
|
+
export declare const getUniqueSizes: (size: PreviewSize) => PreviewSize[];
|
|
5
6
|
export declare const SizeSelector: React.FC;
|
|
@@ -1,30 +1,70 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SizeSelector = exports.getPreviewSizeLabel = exports.commonPreviewSizes = void 0;
|
|
3
|
+
exports.SizeSelector = exports.getUniqueSizes = exports.getPreviewSizeLabel = exports.commonPreviewSizes = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const Checkmark_1 = require("../icons/Checkmark");
|
|
7
7
|
const preview_size_1 = require("../state/preview-size");
|
|
8
8
|
const ControlButton_1 = require("./ControlButton");
|
|
9
9
|
const ComboBox_1 = require("./NewComposition/ComboBox");
|
|
10
|
-
exports.commonPreviewSizes = [
|
|
10
|
+
exports.commonPreviewSizes = [
|
|
11
|
+
{
|
|
12
|
+
size: 'auto',
|
|
13
|
+
translation: {
|
|
14
|
+
x: 0,
|
|
15
|
+
y: 0,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
size: 0.25,
|
|
20
|
+
translation: {
|
|
21
|
+
x: 0,
|
|
22
|
+
y: 0,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
size: 0.5,
|
|
27
|
+
translation: {
|
|
28
|
+
x: 0,
|
|
29
|
+
y: 0,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
size: 1,
|
|
34
|
+
translation: {
|
|
35
|
+
x: 0,
|
|
36
|
+
y: 0,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
];
|
|
11
40
|
const getPreviewSizeLabel = (previewSize) => {
|
|
12
|
-
if (previewSize ===
|
|
13
|
-
return '100%';
|
|
14
|
-
}
|
|
15
|
-
if (previewSize === 0.5) {
|
|
16
|
-
return '50%';
|
|
17
|
-
}
|
|
18
|
-
if (previewSize === 0.25) {
|
|
19
|
-
return '25%';
|
|
20
|
-
}
|
|
21
|
-
if (previewSize === 'auto') {
|
|
41
|
+
if (previewSize.size === 'auto') {
|
|
22
42
|
return 'Fit';
|
|
23
43
|
}
|
|
44
|
+
return `${(previewSize.size * 100).toFixed(0)}%`;
|
|
24
45
|
};
|
|
25
46
|
exports.getPreviewSizeLabel = getPreviewSizeLabel;
|
|
26
47
|
const accessibilityLabel = 'Preview Size';
|
|
27
48
|
const comboStyle = { width: 80 };
|
|
49
|
+
const getUniqueSizes = (size) => {
|
|
50
|
+
const customPreviewSizes = [size, ...exports.commonPreviewSizes];
|
|
51
|
+
const uniqueSizes = [];
|
|
52
|
+
customPreviewSizes.forEach((p) => {
|
|
53
|
+
if (!uniqueSizes.find((s) => s.size === p.size)) {
|
|
54
|
+
uniqueSizes.push(p);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return uniqueSizes.sort((a, b) => {
|
|
58
|
+
if (a.size === 'auto') {
|
|
59
|
+
return -1;
|
|
60
|
+
}
|
|
61
|
+
if (b.size === 'auto') {
|
|
62
|
+
return 1;
|
|
63
|
+
}
|
|
64
|
+
return a.size - b.size;
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
exports.getUniqueSizes = getUniqueSizes;
|
|
28
68
|
const SizeSelector = () => {
|
|
29
69
|
const { size, setSize } = (0, react_1.useContext)(preview_size_1.PreviewSizeContext);
|
|
30
70
|
const style = (0, react_1.useMemo)(() => {
|
|
@@ -33,9 +73,9 @@ const SizeSelector = () => {
|
|
|
33
73
|
};
|
|
34
74
|
}, []);
|
|
35
75
|
const items = (0, react_1.useMemo)(() => {
|
|
36
|
-
return exports.
|
|
76
|
+
return (0, exports.getUniqueSizes)(size).map((newSize) => {
|
|
37
77
|
return {
|
|
38
|
-
id: String(newSize),
|
|
78
|
+
id: String(newSize.size),
|
|
39
79
|
label: (0, exports.getPreviewSizeLabel)(newSize),
|
|
40
80
|
onClick: () => {
|
|
41
81
|
return setSize(() => {
|
|
@@ -43,13 +83,13 @@ const SizeSelector = () => {
|
|
|
43
83
|
});
|
|
44
84
|
},
|
|
45
85
|
type: 'item',
|
|
46
|
-
value: newSize,
|
|
47
|
-
keyHint: null,
|
|
48
|
-
leftItem: String(size) === String(newSize) ? (0, jsx_runtime_1.jsx)(Checkmark_1.Checkmark, {}) : null,
|
|
86
|
+
value: newSize.size,
|
|
87
|
+
keyHint: newSize.size ? '0' : null,
|
|
88
|
+
leftItem: String(size.size) === String(newSize.size) ? (0, jsx_runtime_1.jsx)(Checkmark_1.Checkmark, {}) : null,
|
|
49
89
|
subMenu: null,
|
|
50
90
|
};
|
|
51
91
|
});
|
|
52
92
|
}, [setSize, size]);
|
|
53
|
-
return ((0, jsx_runtime_1.jsx)("div", { style: style, "aria-label": accessibilityLabel, children: (0, jsx_runtime_1.jsx)(ComboBox_1.Combobox, { title: accessibilityLabel, style: comboStyle, selectedId: String(size), values: items }) }));
|
|
93
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: style, "aria-label": accessibilityLabel, children: (0, jsx_runtime_1.jsx)(ComboBox_1.Combobox, { title: accessibilityLabel, style: comboStyle, selectedId: String(size.size), values: items }) }));
|
|
54
94
|
};
|
|
55
95
|
exports.SizeSelector = SizeSelector;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Size, Translation } from '@remotion/player';
|
|
2
|
+
export declare const getEffectiveTranslation: ({ canvasSize, scale, compositionHeight, compositionWidth, translation, }: {
|
|
3
|
+
canvasSize: Size;
|
|
4
|
+
scale: number;
|
|
5
|
+
compositionWidth: number;
|
|
6
|
+
compositionHeight: number;
|
|
7
|
+
translation: {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
};
|
|
11
|
+
}) => {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
};
|
|
15
|
+
export declare const getCenterPointWhileScrolling: ({ size, clientX, clientY, compositionWidth, compositionHeight, scale, translation, }: {
|
|
16
|
+
size: Size;
|
|
17
|
+
clientX: number;
|
|
18
|
+
clientY: number;
|
|
19
|
+
compositionWidth: number;
|
|
20
|
+
compositionHeight: number;
|
|
21
|
+
scale: number;
|
|
22
|
+
translation: Translation;
|
|
23
|
+
}) => {
|
|
24
|
+
centerX: number;
|
|
25
|
+
centerY: number;
|
|
26
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCenterPointWhileScrolling = exports.getEffectiveTranslation = void 0;
|
|
4
|
+
const getEffectiveXTranslation = ({ canvasSize, scale, compositionWidth, translation, }) => {
|
|
5
|
+
const maxTranslation = Math.abs(canvasSize.width / 2 +
|
|
6
|
+
(scale * compositionWidth) / 2 -
|
|
7
|
+
MUST_BE_INSIDE_CANVAS);
|
|
8
|
+
return Math.max(-maxTranslation, Math.min(translation.x, maxTranslation));
|
|
9
|
+
};
|
|
10
|
+
const MUST_BE_INSIDE_CANVAS = 50;
|
|
11
|
+
const getEffectiveYTranslation = ({ canvasSize, scale, compositionHeight, translation, }) => {
|
|
12
|
+
const maxTranslation = Math.abs(canvasSize.height / 2 + (scale * compositionHeight) / 2) -
|
|
13
|
+
MUST_BE_INSIDE_CANVAS;
|
|
14
|
+
return Math.max(-maxTranslation, Math.min(translation.y, maxTranslation));
|
|
15
|
+
};
|
|
16
|
+
const getEffectiveTranslation = ({ canvasSize, scale, compositionHeight, compositionWidth, translation, }) => {
|
|
17
|
+
return {
|
|
18
|
+
x: getEffectiveXTranslation({
|
|
19
|
+
canvasSize,
|
|
20
|
+
compositionWidth,
|
|
21
|
+
scale,
|
|
22
|
+
translation,
|
|
23
|
+
}),
|
|
24
|
+
y: getEffectiveYTranslation({
|
|
25
|
+
canvasSize,
|
|
26
|
+
compositionHeight,
|
|
27
|
+
scale,
|
|
28
|
+
translation,
|
|
29
|
+
}),
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
exports.getEffectiveTranslation = getEffectiveTranslation;
|
|
33
|
+
const getCenterPointWhileScrolling = ({ size, clientX, clientY, compositionWidth, compositionHeight, scale, translation, }) => {
|
|
34
|
+
const mouseLeft = clientX - size.left;
|
|
35
|
+
const mouseTop = clientY - size.top;
|
|
36
|
+
const contentLeftPoint = size.width / 2 - (compositionWidth * scale) / 2 - translation.x;
|
|
37
|
+
const contentTopPoint = size.height / 2 - (compositionHeight * scale) / 2 - translation.y;
|
|
38
|
+
const offsetFromVideoLeft = Math.min(compositionWidth, Math.max(0, (mouseLeft - contentLeftPoint) / scale));
|
|
39
|
+
const offsetFromVideoTop = Math.min(compositionHeight, Math.max(0, (mouseTop - contentTopPoint) / scale));
|
|
40
|
+
return {
|
|
41
|
+
centerX: offsetFromVideoLeft,
|
|
42
|
+
centerY: offsetFromVideoTop,
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
exports.getCenterPointWhileScrolling = getCenterPointWhileScrolling;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useIsStill = void 0;
|
|
3
|
+
exports.useDimensions = exports.useIsStill = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const remotion_1 = require("remotion");
|
|
6
6
|
const is_composition_still_1 = require("./is-composition-still");
|
|
@@ -13,3 +13,17 @@ const useIsStill = () => {
|
|
|
13
13
|
return (0, is_composition_still_1.isCompositionStill)(selected);
|
|
14
14
|
};
|
|
15
15
|
exports.useIsStill = useIsStill;
|
|
16
|
+
const useDimensions = () => {
|
|
17
|
+
const { compositions, currentComposition } = (0, react_1.useContext)(remotion_1.Internals.CompositionManager);
|
|
18
|
+
const selected = (0, react_1.useMemo)(() => compositions.find((c) => c.id === currentComposition), [compositions, currentComposition]);
|
|
19
|
+
return (0, react_1.useMemo)(() => {
|
|
20
|
+
if (!selected) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
width: selected.width,
|
|
25
|
+
height: selected.height,
|
|
26
|
+
};
|
|
27
|
+
}, [selected]);
|
|
28
|
+
};
|
|
29
|
+
exports.useDimensions = useDimensions;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeWheel = void 0;
|
|
4
|
+
// Taken from https://github.com/tldraw/tldraw/blob/254dfdfd77c4abde53240f7d8ca3558e08688493/packages/core/src/hooks/useZoomEvents.ts which is adapted from https://stackoverflow.com/a/13650579
|
|
5
|
+
const MAX_ZOOM_STEP = 10;
|
|
6
|
+
function normalizeWheel(event) {
|
|
7
|
+
const { deltaY, deltaX } = event;
|
|
8
|
+
let deltaZ = 0;
|
|
9
|
+
if (event.ctrlKey || event.metaKey) {
|
|
10
|
+
const signY = Math.sign(event.deltaY);
|
|
11
|
+
const absDeltaY = Math.abs(event.deltaY);
|
|
12
|
+
let dy = deltaY;
|
|
13
|
+
if (absDeltaY > MAX_ZOOM_STEP) {
|
|
14
|
+
dy = MAX_ZOOM_STEP * signY;
|
|
15
|
+
}
|
|
16
|
+
deltaZ = dy;
|
|
17
|
+
}
|
|
18
|
+
return { deltaX, deltaY, deltaZ };
|
|
19
|
+
}
|
|
20
|
+
exports.normalizeWheel = normalizeWheel;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare function normalizeWheel(event: WheelEvent): number[];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Adapted from https://stackoverflow.com/a/13650579
|
|
3
|
+
function normalizeWheel(event) {
|
|
4
|
+
const { deltaY, deltaX } = event;
|
|
5
|
+
let deltaZ = 0;
|
|
6
|
+
if (event.ctrlKey || event.metaKey) {
|
|
7
|
+
const signY = Math.sign(event.deltaY);
|
|
8
|
+
const absDeltaY = Math.abs(event.deltaY);
|
|
9
|
+
let dy = deltaY;
|
|
10
|
+
if (absDeltaY > MAX_ZOOM_STEP) {
|
|
11
|
+
dy = MAX_ZOOM_STEP * signY;
|
|
12
|
+
}
|
|
13
|
+
deltaZ = dy;
|
|
14
|
+
}
|
|
15
|
+
return [deltaX, deltaY, deltaZ];
|
|
16
|
+
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { PreviewSize } from '@remotion/player';
|
|
2
|
+
import React from 'react';
|
|
3
3
|
declare type PreviewSizeCtx = {
|
|
4
4
|
size: PreviewSize;
|
|
5
5
|
setSize: (cb: (oldSize: PreviewSize) => PreviewSize) => void;
|
|
6
6
|
};
|
|
7
7
|
export declare const persistPreviewSizeOption: (option: PreviewSize) => void;
|
|
8
8
|
export declare const loadPreviewSizeOption: () => PreviewSize;
|
|
9
|
-
export declare const PreviewSizeContext:
|
|
9
|
+
export declare const PreviewSizeContext: React.Context<PreviewSizeCtx>;
|
|
10
|
+
export declare const PreviewSizeProvider: React.FC<{
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
}>;
|
|
10
13
|
export {};
|
|
@@ -1,20 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PreviewSizeContext = exports.loadPreviewSizeOption = exports.persistPreviewSizeOption = void 0;
|
|
3
|
+
exports.PreviewSizeProvider = exports.PreviewSizeContext = exports.loadPreviewSizeOption = exports.persistPreviewSizeOption = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
5
|
const react_1 = require("react");
|
|
6
|
+
const key = 'remotion.previewSize';
|
|
5
7
|
const persistPreviewSizeOption = (option) => {
|
|
6
|
-
localStorage.setItem(
|
|
8
|
+
localStorage.setItem(key, JSON.stringify(option));
|
|
7
9
|
};
|
|
8
10
|
exports.persistPreviewSizeOption = persistPreviewSizeOption;
|
|
9
11
|
const loadPreviewSizeOption = () => {
|
|
10
|
-
const item = localStorage.getItem(
|
|
12
|
+
const item = localStorage.getItem(key);
|
|
11
13
|
if (item === null) {
|
|
12
|
-
return
|
|
14
|
+
return {
|
|
15
|
+
size: 'auto',
|
|
16
|
+
translation: {
|
|
17
|
+
x: 0,
|
|
18
|
+
y: 0,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
13
21
|
}
|
|
14
|
-
return item;
|
|
22
|
+
return JSON.parse(item);
|
|
15
23
|
};
|
|
16
24
|
exports.loadPreviewSizeOption = loadPreviewSizeOption;
|
|
17
25
|
exports.PreviewSizeContext = (0, react_1.createContext)({
|
|
18
26
|
setSize: () => undefined,
|
|
19
27
|
size: (0, exports.loadPreviewSizeOption)(),
|
|
20
28
|
});
|
|
29
|
+
const PreviewSizeProvider = ({ children }) => {
|
|
30
|
+
const [size, setSizeState] = (0, react_1.useState)(() => (0, exports.loadPreviewSizeOption)());
|
|
31
|
+
const [translation, setTranslation] = (0, react_1.useState)(() => {
|
|
32
|
+
return {
|
|
33
|
+
x: 0,
|
|
34
|
+
y: 0,
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
const setSize = (0, react_1.useCallback)((newValue) => {
|
|
38
|
+
setSizeState((prevState) => {
|
|
39
|
+
const newVal = newValue(prevState);
|
|
40
|
+
(0, exports.persistPreviewSizeOption)(newVal);
|
|
41
|
+
return newVal;
|
|
42
|
+
});
|
|
43
|
+
}, []);
|
|
44
|
+
const previewSizeCtx = (0, react_1.useMemo)(() => {
|
|
45
|
+
return {
|
|
46
|
+
size,
|
|
47
|
+
setSize,
|
|
48
|
+
translation,
|
|
49
|
+
setTranslation,
|
|
50
|
+
};
|
|
51
|
+
}, [setSize, size, translation, setTranslation]);
|
|
52
|
+
return ((0, jsx_runtime_1.jsx)(exports.PreviewSizeContext.Provider, { value: previewSizeCtx, children: children }));
|
|
53
|
+
};
|
|
54
|
+
exports.PreviewSizeProvider = PreviewSizeProvider;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.unsmoothenZoom = exports.smoothenZoom = exports.MAX_ZOOM = exports.MIN_ZOOM = void 0;
|
|
4
|
+
const BASE = Math.E / 4;
|
|
5
|
+
exports.MIN_ZOOM = 0.05;
|
|
6
|
+
exports.MAX_ZOOM = 10;
|
|
7
|
+
function logN(val) {
|
|
8
|
+
return Math.log(val) / Math.log(BASE);
|
|
9
|
+
}
|
|
10
|
+
const smoothenZoom = (input) => {
|
|
11
|
+
return BASE ** (input - 1);
|
|
12
|
+
};
|
|
13
|
+
exports.smoothenZoom = smoothenZoom;
|
|
14
|
+
const unsmoothenZoom = (input) => {
|
|
15
|
+
if (input < 0) {
|
|
16
|
+
return exports.MAX_ZOOM;
|
|
17
|
+
}
|
|
18
|
+
return Math.min(exports.MAX_ZOOM, Math.max(exports.MIN_ZOOM, logN(input) + 1));
|
|
19
|
+
};
|
|
20
|
+
exports.unsmoothenZoom = unsmoothenZoom;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/cli",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.16",
|
|
4
4
|
"description": "CLI for Remotion",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -23,15 +23,15 @@
|
|
|
23
23
|
"author": "Jonny Burger <jonny@remotion.dev>",
|
|
24
24
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@remotion/bundler": "3.2.
|
|
27
|
-
"@remotion/media-utils": "3.2.
|
|
28
|
-
"@remotion/player": "3.2.
|
|
29
|
-
"@remotion/renderer": "3.2.
|
|
26
|
+
"@remotion/bundler": "3.2.16",
|
|
27
|
+
"@remotion/media-utils": "3.2.16",
|
|
28
|
+
"@remotion/player": "3.2.16",
|
|
29
|
+
"@remotion/renderer": "3.2.16",
|
|
30
30
|
"better-opn": "2.1.1",
|
|
31
31
|
"dotenv": "9.0.2",
|
|
32
32
|
"memfs": "3.4.3",
|
|
33
33
|
"minimist": "1.2.6",
|
|
34
|
-
"remotion": "3.2.
|
|
34
|
+
"remotion": "3.2.16",
|
|
35
35
|
"semver": "7.3.5",
|
|
36
36
|
"source-map": "0.6.1"
|
|
37
37
|
},
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"publishConfig": {
|
|
72
72
|
"access": "public"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "3c64e274a2c74e1b791d4a24b3af2ae456c0fd9e"
|
|
75
75
|
}
|