@remotion/player 4.0.0-bitrate.18 → 4.0.0-clippath.7
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/LICENSE.md +8 -8
- package/README.md +1 -1
- package/dist/{MediaVolumeSlider.d.ts → cjs/MediaVolumeSlider.d.ts} +0 -0
- package/dist/{MediaVolumeSlider.js → cjs/MediaVolumeSlider.js} +15 -15
- package/dist/{Player.d.ts → cjs/Player.d.ts} +12 -13
- package/dist/{Player.js → cjs/Player.js} +24 -80
- package/dist/{PlayerControls.d.ts → cjs/PlayerControls.d.ts} +11 -4
- package/dist/{PlayerControls.js → cjs/PlayerControls.js} +32 -19
- package/dist/{PlayerSeekBar.d.ts → cjs/PlayerSeekBar.d.ts} +0 -0
- package/dist/{PlayerSeekBar.js → cjs/PlayerSeekBar.js} +6 -6
- package/dist/{PlayerUI.d.ts → cjs/PlayerUI.d.ts} +8 -8
- package/dist/{PlayerUI.js → cjs/PlayerUI.js} +32 -68
- package/dist/cjs/SharedPlayerContext.d.ts +14 -0
- package/dist/cjs/SharedPlayerContext.js +72 -0
- package/dist/cjs/Thumbnail.d.ts +24 -0
- package/dist/cjs/Thumbnail.js +46 -0
- package/dist/cjs/ThumbnailUI.d.ts +11 -0
- package/dist/cjs/ThumbnailUI.js +107 -0
- package/dist/{calculate-next-frame.d.ts → cjs/calculate-next-frame.d.ts} +0 -0
- package/dist/{calculate-next-frame.js → cjs/calculate-next-frame.js} +0 -0
- package/dist/cjs/calculate-scale.d.ts +39 -0
- package/dist/cjs/calculate-scale.js +85 -0
- package/dist/cjs/emitter-context.d.ts +4 -0
- package/dist/{emitter-context.js → cjs/emitter-context.js} +2 -1
- package/dist/{error-boundary.d.ts → cjs/error-boundary.d.ts} +0 -0
- package/dist/{error-boundary.js → cjs/error-boundary.js} +0 -0
- package/dist/{event-emitter.d.ts → cjs/event-emitter.d.ts} +23 -9
- package/dist/{event-emitter.js → cjs/event-emitter.js} +25 -1
- package/dist/{format-time.d.ts → cjs/format-time.d.ts} +0 -0
- package/dist/{format-time.js → cjs/format-time.js} +0 -0
- package/dist/{icons.d.ts → cjs/icons.d.ts} +1 -1
- package/dist/{icons.js → cjs/icons.js} +4 -4
- package/dist/{index.d.ts → cjs/index.d.ts} +13 -11
- package/dist/cjs/index.js +25 -0
- package/dist/{player-css-classname.d.ts → cjs/player-css-classname.d.ts} +0 -0
- package/dist/{player-css-classname.js → cjs/player-css-classname.js} +0 -0
- package/dist/{player-methods.d.ts → cjs/player-methods.d.ts} +7 -4
- package/dist/{player-methods.js → cjs/player-methods.js} +0 -0
- package/dist/{test → cjs/test}/index.test.d.ts +0 -0
- package/dist/cjs/test/index.test.js +9 -0
- package/dist/{test → cjs/test}/test-utils.d.ts +0 -0
- package/dist/{test → cjs/test}/test-utils.js +0 -0
- package/dist/{test → cjs/test}/validate-in-out-frames.test.d.ts +0 -0
- package/dist/{test → cjs/test}/validate-in-out-frames.test.js +13 -12
- package/dist/{test → cjs/test}/validate-prop.test.d.ts +0 -0
- package/dist/cjs/test/validate-prop.test.js +131 -0
- package/dist/{use-hover-state.d.ts → cjs/use-hover-state.d.ts} +0 -0
- package/dist/{use-hover-state.js → cjs/use-hover-state.js} +0 -0
- package/dist/{use-playback.d.ts → cjs/use-playback.d.ts} +0 -0
- package/dist/{use-playback.js → cjs/use-playback.js} +4 -4
- package/dist/{use-player.d.ts → cjs/use-player.d.ts} +1 -1
- package/dist/{use-player.js → cjs/use-player.js} +2 -2
- package/dist/cjs/use-thumbnail.d.ts +6 -0
- package/dist/cjs/use-thumbnail.js +18 -0
- package/dist/{use-video-controls-resize.d.ts → cjs/use-video-controls-resize.d.ts} +8 -4
- package/dist/{use-video-controls-resize.js → cjs/use-video-controls-resize.js} +16 -13
- package/dist/{utils → cjs/utils}/calculate-player-size.d.ts +1 -1
- package/dist/{utils → cjs/utils}/calculate-player-size.js +9 -10
- package/dist/{utils → cjs/utils}/cancellable-promise.d.ts +0 -0
- package/dist/{utils → cjs/utils}/cancellable-promise.js +0 -0
- package/dist/{utils → cjs/utils}/delay.d.ts +0 -0
- package/dist/{utils → cjs/utils}/delay.js +0 -0
- package/dist/{utils → cjs/utils}/is-node.d.ts +0 -0
- package/dist/{utils → cjs/utils}/is-node.js +0 -0
- package/dist/{utils → cjs/utils}/preview-size.d.ts +0 -0
- package/dist/{utils → cjs/utils}/preview-size.js +0 -0
- package/dist/cjs/utils/props-if-has-props.d.ts +5 -0
- package/dist/cjs/utils/props-if-has-props.js +2 -0
- package/dist/{utils → cjs/utils}/use-cancellable-promises.d.ts +1 -1
- package/dist/{utils → cjs/utils}/use-cancellable-promises.js +0 -0
- package/dist/{utils → cjs/utils}/use-click-prevention-on-double-click.d.ts +0 -0
- package/dist/{utils → cjs/utils}/use-click-prevention-on-double-click.js +5 -5
- package/dist/{utils → cjs/utils}/use-element-size.d.ts +1 -0
- package/dist/{utils → cjs/utils}/use-element-size.js +1 -1
- package/dist/{utils → cjs/utils}/validate-in-out-frame.d.ts +1 -1
- package/dist/{utils → cjs/utils}/validate-in-out-frame.js +13 -13
- package/dist/{utils → cjs/utils}/validate-initial-frame.d.ts +0 -0
- package/dist/{utils → cjs/utils}/validate-initial-frame.js +0 -0
- package/dist/{utils → cjs/utils}/validate-playbackrate.d.ts +0 -0
- package/dist/{utils → cjs/utils}/validate-playbackrate.js +0 -0
- package/dist/{volume-persistance.d.ts → cjs/volume-persistance.d.ts} +0 -0
- package/dist/{volume-persistance.js → cjs/volume-persistance.js} +0 -0
- package/dist/esm/MediaVolumeSlider.d.ts +5 -0
- package/dist/esm/Player.d.ts +48 -0
- package/dist/esm/PlayerControls.d.ts +40 -0
- package/dist/esm/PlayerSeekBar.d.ts +8 -0
- package/dist/esm/PlayerUI.d.ts +39 -0
- package/dist/esm/SharedPlayerContext.d.ts +14 -0
- package/dist/esm/Thumbnail.d.ts +24 -0
- package/dist/esm/ThumbnailUI.d.ts +11 -0
- package/dist/esm/calculate-next-frame.d.ts +14 -0
- package/dist/esm/calculate-scale.d.ts +39 -0
- package/dist/esm/emitter-context.d.ts +4 -0
- package/dist/esm/error-boundary.d.ts +19 -0
- package/dist/esm/event-emitter.d.ts +66 -0
- package/dist/esm/format-time.d.ts +1 -0
- package/dist/esm/icons.d.ts +10 -0
- package/dist/esm/index.d.ts +61 -0
- package/dist/esm/index.mjs +1830 -0
- package/dist/esm/player-css-classname.d.ts +1 -0
- package/dist/esm/player-methods.d.ts +24 -0
- package/dist/esm/test/index.test.d.ts +1 -0
- package/dist/esm/test/test-utils.d.ts +6 -0
- package/dist/esm/test/validate-in-out-frames.test.d.ts +1 -0
- package/dist/esm/test/validate-prop.test.d.ts +1 -0
- package/dist/esm/use-hover-state.d.ts +1 -0
- package/dist/esm/use-playback.d.ts +7 -0
- package/dist/esm/use-player.d.ts +19 -0
- package/dist/esm/use-thumbnail.d.ts +6 -0
- package/dist/esm/use-video-controls-resize.d.ts +11 -0
- package/dist/esm/utils/calculate-player-size.d.ts +9 -0
- package/dist/esm/utils/cancellable-promise.d.ts +5 -0
- package/dist/esm/utils/delay.d.ts +1 -0
- package/dist/esm/utils/is-node.d.ts +1 -0
- package/dist/esm/utils/preview-size.d.ts +8 -0
- package/dist/esm/utils/props-if-has-props.d.ts +5 -0
- package/dist/esm/utils/use-cancellable-promises.d.ts +7 -0
- package/dist/esm/utils/use-click-prevention-on-double-click.d.ts +3 -0
- package/dist/esm/utils/use-element-size.d.ts +16 -0
- package/dist/esm/utils/validate-in-out-frame.d.ts +6 -0
- package/dist/esm/utils/validate-initial-frame.d.ts +4 -0
- package/dist/esm/utils/validate-playbackrate.d.ts +1 -0
- package/dist/esm/volume-persistance.d.ts +2 -0
- package/dist/tsconfig-esm.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +28 -16
- package/dist/calculate-scale.d.ts +0 -20
- package/dist/calculate-scale.js +0 -33
- package/dist/emitter-context.d.ts +0 -3
- package/dist/index.js +0 -23
- package/dist/test/index.test.js +0 -8
- package/dist/test/validate-prop.test.js +0 -130
|
@@ -26,29 +26,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
27
27
|
const react_1 = __importStar(require("react"));
|
|
28
28
|
const remotion_1 = require("remotion");
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const use_element_size_1 = require("./utils/use-element-size");
|
|
29
|
+
const calculate_scale_js_1 = require("./calculate-scale.js");
|
|
30
|
+
const error_boundary_js_1 = require("./error-boundary.js");
|
|
31
|
+
const player_css_classname_js_1 = require("./player-css-classname.js");
|
|
32
|
+
const PlayerControls_js_1 = require("./PlayerControls.js");
|
|
33
|
+
const use_hover_state_js_1 = require("./use-hover-state.js");
|
|
34
|
+
const use_playback_js_1 = require("./use-playback.js");
|
|
35
|
+
const use_player_js_1 = require("./use-player.js");
|
|
36
|
+
const is_node_js_1 = require("./utils/is-node.js");
|
|
37
|
+
const use_click_prevention_on_double_click_js_1 = require("./utils/use-click-prevention-on-double-click.js");
|
|
38
|
+
const use_element_size_js_1 = require("./utils/use-element-size.js");
|
|
40
39
|
const reactVersion = react_1.default.version.split('.')[0];
|
|
41
40
|
if (reactVersion === '0') {
|
|
42
41
|
throw new Error(`Version ${reactVersion} of "react" is not supported by Remotion`);
|
|
43
42
|
}
|
|
44
43
|
const doesReactVersionSupportSuspense = parseInt(reactVersion, 10) >= 18;
|
|
45
|
-
const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps, clickToPlay, showVolumeControls,
|
|
44
|
+
const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps, clickToPlay, showVolumeControls, doubleClickToFullscreen, spaceKeyToPlayOrPause, errorFallback, playbackRate, renderLoading, renderPoster, className, moveToBeginningWhenEnded, showPosterWhenUnplayed, showPosterWhenEnded, showPosterWhenPaused, inFrame, outFrame, initiallyShowControls, renderFullscreen: renderFullscreenButton, renderPlayPauseButton, alwaysShowControls, }, ref) => {
|
|
46
45
|
var _a, _b, _c, _d, _e;
|
|
47
46
|
const config = remotion_1.Internals.useUnsafeVideoConfig();
|
|
48
47
|
const video = remotion_1.Internals.useVideo();
|
|
49
48
|
const container = (0, react_1.useRef)(null);
|
|
50
|
-
const hovered = (0,
|
|
51
|
-
const canvasSize = (0,
|
|
49
|
+
const hovered = (0, use_hover_state_js_1.useHoverState)(container);
|
|
50
|
+
const canvasSize = (0, use_element_size_js_1.useElementSize)(container, {
|
|
52
51
|
triggerOnWindowResize: false,
|
|
53
52
|
shouldApplyCssTransforms: false,
|
|
54
53
|
});
|
|
@@ -56,14 +55,14 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
|
|
|
56
55
|
const [shouldAutoplay, setShouldAutoPlay] = (0, react_1.useState)(autoPlay);
|
|
57
56
|
const [isFullscreen, setIsFullscreen] = (0, react_1.useState)(() => false);
|
|
58
57
|
const [seeking, setSeeking] = (0, react_1.useState)(false);
|
|
59
|
-
(0,
|
|
58
|
+
(0, use_playback_js_1.usePlayback)({
|
|
60
59
|
loop,
|
|
61
60
|
playbackRate,
|
|
62
61
|
moveToBeginningWhenEnded,
|
|
63
62
|
inFrame,
|
|
64
63
|
outFrame,
|
|
65
64
|
});
|
|
66
|
-
const player = (0,
|
|
65
|
+
const player = (0, use_player_js_1.usePlayer)();
|
|
67
66
|
(0, react_1.useEffect)(() => {
|
|
68
67
|
if (hasPausedToResume && !player.playing) {
|
|
69
68
|
setHasPausedToResume(false);
|
|
@@ -151,7 +150,7 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
|
|
|
151
150
|
if (!config || !canvasSize) {
|
|
152
151
|
return null;
|
|
153
152
|
}
|
|
154
|
-
return (0,
|
|
153
|
+
return (0, calculate_scale_js_1.calculateCanvasTransformation)({
|
|
155
154
|
canvasSize,
|
|
156
155
|
compositionHeight: config.height,
|
|
157
156
|
compositionWidth: config.width,
|
|
@@ -159,6 +158,8 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
|
|
|
159
158
|
});
|
|
160
159
|
}, [canvasSize, config]);
|
|
161
160
|
const scale = (_b = layout === null || layout === void 0 ? void 0 : layout.scale) !== null && _b !== void 0 ? _b : 1;
|
|
161
|
+
const { setMediaVolume, setMediaMuted } = (0, react_1.useContext)(remotion_1.Internals.SetMediaVolumeContext);
|
|
162
|
+
const { mediaMuted, mediaVolume } = (0, react_1.useContext)(remotion_1.Internals.MediaVolumeContext);
|
|
162
163
|
(0, react_1.useImperativeHandle)(ref, () => {
|
|
163
164
|
const methods = {
|
|
164
165
|
play: player.play,
|
|
@@ -227,52 +228,13 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
|
|
|
227
228
|
]);
|
|
228
229
|
const VideoComponent = video ? video.component : null;
|
|
229
230
|
const outerStyle = (0, react_1.useMemo)(() => {
|
|
230
|
-
|
|
231
|
-
return {};
|
|
232
|
-
}
|
|
233
|
-
return {
|
|
234
|
-
position: 'relative',
|
|
235
|
-
overflow: 'hidden',
|
|
236
|
-
...(0, calculate_player_size_1.calculatePlayerSize)({
|
|
237
|
-
compositionHeight: config.height,
|
|
238
|
-
compositionWidth: config.width,
|
|
239
|
-
currentSize: canvasSize,
|
|
240
|
-
height: style === null || style === void 0 ? void 0 : style.height,
|
|
241
|
-
width: style === null || style === void 0 ? void 0 : style.width,
|
|
242
|
-
}),
|
|
243
|
-
...style,
|
|
244
|
-
};
|
|
231
|
+
return (0, calculate_scale_js_1.calculateOuterStyle)({ canvasSize, config, style });
|
|
245
232
|
}, [canvasSize, config, style]);
|
|
246
233
|
const outer = (0, react_1.useMemo)(() => {
|
|
247
|
-
|
|
248
|
-
return {};
|
|
249
|
-
}
|
|
250
|
-
const { centerX, centerY } = layout;
|
|
251
|
-
return {
|
|
252
|
-
width: config.width * scale,
|
|
253
|
-
height: config.height * scale,
|
|
254
|
-
display: 'flex',
|
|
255
|
-
flexDirection: 'column',
|
|
256
|
-
position: 'absolute',
|
|
257
|
-
left: centerX,
|
|
258
|
-
top: centerY,
|
|
259
|
-
overflow: 'hidden',
|
|
260
|
-
};
|
|
234
|
+
return (0, calculate_scale_js_1.calculateOuter)({ config, layout, scale });
|
|
261
235
|
}, [config, layout, scale]);
|
|
262
236
|
const containerStyle = (0, react_1.useMemo)(() => {
|
|
263
|
-
|
|
264
|
-
return {};
|
|
265
|
-
}
|
|
266
|
-
return {
|
|
267
|
-
position: 'absolute',
|
|
268
|
-
width: config.width,
|
|
269
|
-
height: config.height,
|
|
270
|
-
display: 'flex',
|
|
271
|
-
transform: `scale(${scale})`,
|
|
272
|
-
marginLeft: layout.xCorrection,
|
|
273
|
-
marginTop: layout.yCorrection,
|
|
274
|
-
overflow: 'hidden',
|
|
275
|
-
};
|
|
237
|
+
return (0, calculate_scale_js_1.calculateContainerStyle)({ canvasSize, config, layout, scale });
|
|
276
238
|
}, [canvasSize, config, layout, scale]);
|
|
277
239
|
const onError = (0, react_1.useCallback)((error) => {
|
|
278
240
|
player.pause();
|
|
@@ -304,13 +266,21 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
|
|
|
304
266
|
requestFullscreen();
|
|
305
267
|
}
|
|
306
268
|
}, [exitFullscreen, isFullscreen, requestFullscreen]);
|
|
307
|
-
const [handleClick, handleDoubleClick] = (0,
|
|
269
|
+
const [handleClick, handleDoubleClick] = (0, use_click_prevention_on_double_click_js_1.useClickPreventionOnDoubleClick)(onSingleClick, onDoubleClick, doubleClickToFullscreen);
|
|
308
270
|
(0, react_1.useEffect)(() => {
|
|
309
271
|
if (shouldAutoplay) {
|
|
310
272
|
player.play();
|
|
311
273
|
setShouldAutoPlay(false);
|
|
312
274
|
}
|
|
313
275
|
}, [shouldAutoplay, player]);
|
|
276
|
+
const loadingMarkup = (0, react_1.useMemo)(() => {
|
|
277
|
+
return renderLoading
|
|
278
|
+
? renderLoading({
|
|
279
|
+
height: outerStyle.height,
|
|
280
|
+
width: outerStyle.width,
|
|
281
|
+
})
|
|
282
|
+
: null;
|
|
283
|
+
}, [outerStyle.height, outerStyle.width, renderLoading]);
|
|
314
284
|
if (!config) {
|
|
315
285
|
return null;
|
|
316
286
|
}
|
|
@@ -329,16 +299,10 @@ const PlayerUI = ({ controls, style, loop, autoPlay, allowFullscreen, inputProps
|
|
|
329
299
|
showPosterWhenEnded && player.isLastFrame && !player.isPlaying(),
|
|
330
300
|
showPosterWhenUnplayed && !player.hasPlayed && !player.isPlaying(),
|
|
331
301
|
].some(Boolean);
|
|
332
|
-
const content = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { style: outer, onClick: clickToPlay ? handleClick : undefined, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, children: (0, jsx_runtime_1.jsx)("div", { style: containerStyle, className:
|
|
333
|
-
if (
|
|
302
|
+
const content = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { style: outer, onClick: clickToPlay ? handleClick : undefined, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, children: (0, jsx_runtime_1.jsx)("div", { style: containerStyle, className: player_css_classname_js_1.PLAYER_CSS_CLASSNAME, children: VideoComponent ? ((0, jsx_runtime_1.jsx)(error_boundary_js_1.ErrorBoundary, { onError: onError, errorFallback: errorFallback, children: (0, jsx_runtime_1.jsx)(VideoComponent, { ...((_c = video === null || video === void 0 ? void 0 : video.defaultProps) !== null && _c !== void 0 ? _c : {}), ...((_d = inputProps) !== null && _d !== void 0 ? _d : {}) }) })) : null }) }), shouldShowPoster ? ((0, jsx_runtime_1.jsx)("div", { style: outer, onClick: clickToPlay ? handleClick : undefined, onDoubleClick: doubleClickToFullscreen ? handleDoubleClick : undefined, children: poster })) : null, controls ? ((0, jsx_runtime_1.jsx)(PlayerControls_js_1.Controls, { fps: config.fps, durationInFrames: config.durationInFrames, hovered: hovered, player: player, onFullscreenButtonClick: onFullscreenButtonClick, isFullscreen: isFullscreen, allowFullscreen: allowFullscreen, showVolumeControls: showVolumeControls, onExitFullscreenButtonClick: onExitFullscreenButtonClick, spaceKeyToPlayOrPause: spaceKeyToPlayOrPause, onSeekEnd: onSeekEnd, onSeekStart: onSeekStart, inFrame: inFrame, outFrame: outFrame, initiallyShowControls: initiallyShowControls, playerWidth: (_e = canvasSize === null || canvasSize === void 0 ? void 0 : canvasSize.width) !== null && _e !== void 0 ? _e : 0, renderFullscreenButton: renderFullscreenButton, renderPlayPauseButton: renderPlayPauseButton, alwaysShowControls: alwaysShowControls })) : null] }));
|
|
303
|
+
if (is_node_js_1.IS_NODE && !doesReactVersionSupportSuspense) {
|
|
334
304
|
return ((0, jsx_runtime_1.jsx)("div", { ref: container, style: outerStyle, className: className, children: content }));
|
|
335
305
|
}
|
|
336
|
-
const loadingMarkup = renderLoading
|
|
337
|
-
? renderLoading({
|
|
338
|
-
height: outerStyle.height,
|
|
339
|
-
width: outerStyle.width,
|
|
340
|
-
})
|
|
341
|
-
: null;
|
|
342
306
|
return ((0, jsx_runtime_1.jsx)("div", { ref: container, style: outerStyle, className: className, children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: loadingMarkup, children: content }) }));
|
|
343
307
|
};
|
|
344
308
|
exports.default = (0, react_1.forwardRef)(PlayerUI);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ComponentType, LazyExoticComponent } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { TimelineContextValue } from 'remotion';
|
|
4
|
+
export declare const SharedPlayerContexts: React.FC<{
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
timelineContext: TimelineContextValue;
|
|
7
|
+
inputProps?: unknown;
|
|
8
|
+
fps: number;
|
|
9
|
+
compositionWidth: number;
|
|
10
|
+
compositionHeight: number;
|
|
11
|
+
durationInFrames: number;
|
|
12
|
+
component: LazyExoticComponent<ComponentType<unknown>>;
|
|
13
|
+
numberOfSharedAudioTags: number;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SharedPlayerContexts = 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 volume_persistance_js_1 = require("./volume-persistance.js");
|
|
8
|
+
const SharedPlayerContexts = ({ children, timelineContext, inputProps, fps, compositionHeight, compositionWidth, durationInFrames, component, numberOfSharedAudioTags, }) => {
|
|
9
|
+
const compositionManagerContext = (0, react_1.useMemo)(() => {
|
|
10
|
+
return {
|
|
11
|
+
compositions: [
|
|
12
|
+
{
|
|
13
|
+
component: component,
|
|
14
|
+
durationInFrames,
|
|
15
|
+
height: compositionHeight,
|
|
16
|
+
width: compositionWidth,
|
|
17
|
+
fps,
|
|
18
|
+
id: 'player-comp',
|
|
19
|
+
props: inputProps,
|
|
20
|
+
nonce: 777,
|
|
21
|
+
scale: 1,
|
|
22
|
+
folderName: null,
|
|
23
|
+
defaultProps: undefined,
|
|
24
|
+
parentFolderName: null,
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
folders: [],
|
|
28
|
+
registerFolder: () => undefined,
|
|
29
|
+
unregisterFolder: () => undefined,
|
|
30
|
+
currentComposition: 'player-comp',
|
|
31
|
+
registerComposition: () => undefined,
|
|
32
|
+
registerSequence: () => undefined,
|
|
33
|
+
sequences: [],
|
|
34
|
+
setCurrentComposition: () => undefined,
|
|
35
|
+
unregisterComposition: () => undefined,
|
|
36
|
+
unregisterSequence: () => undefined,
|
|
37
|
+
registerAsset: () => undefined,
|
|
38
|
+
unregisterAsset: () => undefined,
|
|
39
|
+
currentCompositionMetadata: null,
|
|
40
|
+
setCurrentCompositionMetadata: () => undefined,
|
|
41
|
+
assets: [],
|
|
42
|
+
setClipRegion: () => undefined,
|
|
43
|
+
};
|
|
44
|
+
}, [
|
|
45
|
+
component,
|
|
46
|
+
durationInFrames,
|
|
47
|
+
compositionHeight,
|
|
48
|
+
compositionWidth,
|
|
49
|
+
fps,
|
|
50
|
+
inputProps,
|
|
51
|
+
]);
|
|
52
|
+
const [mediaMuted, setMediaMuted] = (0, react_1.useState)(false);
|
|
53
|
+
const [mediaVolume, setMediaVolume] = (0, react_1.useState)((0, volume_persistance_js_1.getPreferredVolume)());
|
|
54
|
+
const mediaVolumeContextValue = (0, react_1.useMemo)(() => {
|
|
55
|
+
return {
|
|
56
|
+
mediaMuted,
|
|
57
|
+
mediaVolume,
|
|
58
|
+
};
|
|
59
|
+
}, [mediaMuted, mediaVolume]);
|
|
60
|
+
const setMediaVolumeAndPersist = (0, react_1.useCallback)((vol) => {
|
|
61
|
+
setMediaVolume(vol);
|
|
62
|
+
(0, volume_persistance_js_1.persistVolume)(vol);
|
|
63
|
+
}, []);
|
|
64
|
+
const setMediaVolumeContextValue = (0, react_1.useMemo)(() => {
|
|
65
|
+
return {
|
|
66
|
+
setMediaMuted,
|
|
67
|
+
setMediaVolume: setMediaVolumeAndPersist,
|
|
68
|
+
};
|
|
69
|
+
}, [setMediaVolumeAndPersist]);
|
|
70
|
+
return ((0, jsx_runtime_1.jsx)(remotion_1.Internals.CanUseRemotionHooksProvider, { children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.Timeline.TimelineContext.Provider, { value: timelineContext, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.CompositionManager.Provider, { value: compositionManagerContext, children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.PrefetchProvider, { children: (0, jsx_runtime_1.jsx)(remotion_1.Internals.DurationsContextProvider, { 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)(remotion_1.Internals.SharedAudioContextProvider, { numberOfAudioTags: numberOfSharedAudioTags, children: children }) }) }) }) }) }) }) }));
|
|
71
|
+
};
|
|
72
|
+
exports.SharedPlayerContexts = SharedPlayerContexts;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { CSSProperties, MutableRefObject } from 'react';
|
|
2
|
+
import type { CompProps } from 'remotion';
|
|
3
|
+
import type { ThumbnailMethods } from './player-methods.js';
|
|
4
|
+
import type { ErrorFallback, RenderLoading } from './PlayerUI.js';
|
|
5
|
+
import type { PropsIfHasProps } from './utils/props-if-has-props.js';
|
|
6
|
+
declare type ThumbnailProps<T> = PropsIfHasProps<T> & CompProps<T> & {
|
|
7
|
+
frameToDisplay: number;
|
|
8
|
+
style?: CSSProperties;
|
|
9
|
+
durationInFrames: number;
|
|
10
|
+
compositionWidth: number;
|
|
11
|
+
compositionHeight: number;
|
|
12
|
+
inputProps?: unknown;
|
|
13
|
+
fps: number;
|
|
14
|
+
errorFallback?: ErrorFallback;
|
|
15
|
+
renderLoading?: RenderLoading;
|
|
16
|
+
className?: string;
|
|
17
|
+
};
|
|
18
|
+
export declare const ThumbnailFn: <T>({ frameToDisplay, style, inputProps, compositionHeight, compositionWidth, durationInFrames, fps, className, errorFallback, renderLoading, ...componentProps }: ThumbnailProps<T>, ref: MutableRefObject<ThumbnailMethods>) => JSX.Element;
|
|
19
|
+
/**
|
|
20
|
+
* @description A component which can be rendered in a regular React App (for example: Create React App, Next.js) to display a single frame of a video.
|
|
21
|
+
* @see [Documentation](https://www.remotion.dev/docs/player/thumbnail)
|
|
22
|
+
*/
|
|
23
|
+
export declare const Thumbnail: <T>(props: ThumbnailProps<T> & import("react").RefAttributes<ThumbnailMethods>) => React.ReactElement | null;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Thumbnail = exports.ThumbnailFn = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const remotion_1 = require("remotion");
|
|
10
|
+
const emitter_context_js_1 = require("./emitter-context.js");
|
|
11
|
+
const event_emitter_js_1 = require("./event-emitter.js");
|
|
12
|
+
const SharedPlayerContext_js_1 = require("./SharedPlayerContext.js");
|
|
13
|
+
const ThumbnailUI_js_1 = __importDefault(require("./ThumbnailUI.js"));
|
|
14
|
+
const ThumbnailFn = ({ frameToDisplay, style, inputProps, compositionHeight, compositionWidth, durationInFrames, fps, className, errorFallback = () => '⚠️', renderLoading, ...componentProps }, ref) => {
|
|
15
|
+
const [thumbnailId] = (0, react_1.useState)(() => String((0, remotion_1.random)(null)));
|
|
16
|
+
const rootRef = (0, react_1.useRef)(null);
|
|
17
|
+
const timelineState = (0, react_1.useMemo)(() => {
|
|
18
|
+
return {
|
|
19
|
+
playing: false,
|
|
20
|
+
frame: frameToDisplay,
|
|
21
|
+
rootId: thumbnailId,
|
|
22
|
+
imperativePlaying: {
|
|
23
|
+
current: false,
|
|
24
|
+
},
|
|
25
|
+
playbackRate: 1,
|
|
26
|
+
setPlaybackRate: () => {
|
|
27
|
+
throw new Error('thumbnail');
|
|
28
|
+
},
|
|
29
|
+
audioAndVideoTags: { current: [] },
|
|
30
|
+
};
|
|
31
|
+
}, [frameToDisplay, thumbnailId]);
|
|
32
|
+
(0, react_1.useImperativeHandle)(ref, () => rootRef.current, []);
|
|
33
|
+
const Component = remotion_1.Internals.useLazyComponent(componentProps);
|
|
34
|
+
const [emitter] = (0, react_1.useState)(() => new event_emitter_js_1.ThumbnailEmitter());
|
|
35
|
+
const passedInputProps = (0, react_1.useMemo)(() => {
|
|
36
|
+
return inputProps !== null && inputProps !== void 0 ? inputProps : {};
|
|
37
|
+
}, [inputProps]);
|
|
38
|
+
return ((0, jsx_runtime_1.jsx)(remotion_1.Internals.IsPlayerContextProvider, { children: (0, jsx_runtime_1.jsx)(SharedPlayerContext_js_1.SharedPlayerContexts, { timelineContext: timelineState, component: Component, compositionHeight: compositionHeight, compositionWidth: compositionWidth, durationInFrames: durationInFrames, fps: fps, inputProps: inputProps, numberOfSharedAudioTags: 0, children: (0, jsx_runtime_1.jsx)(emitter_context_js_1.ThumbnailEmitterContext.Provider, { value: emitter, children: (0, jsx_runtime_1.jsx)(ThumbnailUI_js_1.default, { className: className, errorFallback: errorFallback, inputProps: passedInputProps, renderLoading: renderLoading, style: style }) }) }) }));
|
|
39
|
+
};
|
|
40
|
+
exports.ThumbnailFn = ThumbnailFn;
|
|
41
|
+
const forward = react_1.forwardRef;
|
|
42
|
+
/**
|
|
43
|
+
* @description A component which can be rendered in a regular React App (for example: Create React App, Next.js) to display a single frame of a video.
|
|
44
|
+
* @see [Documentation](https://www.remotion.dev/docs/player/thumbnail)
|
|
45
|
+
*/
|
|
46
|
+
exports.Thumbnail = forward(exports.ThumbnailFn);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ThumbnailMethods } from './player-methods.js';
|
|
3
|
+
import type { ErrorFallback, RenderLoading } from './PlayerUI.js';
|
|
4
|
+
declare const _default: React.ForwardRefExoticComponent<{
|
|
5
|
+
inputProps: unknown;
|
|
6
|
+
style?: React.CSSProperties | undefined;
|
|
7
|
+
errorFallback: ErrorFallback;
|
|
8
|
+
renderLoading: RenderLoading | undefined;
|
|
9
|
+
className: string | undefined;
|
|
10
|
+
} & React.RefAttributes<ThumbnailMethods>>;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
const remotion_1 = require("remotion");
|
|
29
|
+
const calculate_scale_js_1 = require("./calculate-scale.js");
|
|
30
|
+
const error_boundary_js_1 = require("./error-boundary.js");
|
|
31
|
+
const player_css_classname_js_1 = require("./player-css-classname.js");
|
|
32
|
+
const use_thumbnail_js_1 = require("./use-thumbnail.js");
|
|
33
|
+
const is_node_js_1 = require("./utils/is-node.js");
|
|
34
|
+
const use_element_size_js_1 = require("./utils/use-element-size.js");
|
|
35
|
+
const reactVersion = react_1.default.version.split('.')[0];
|
|
36
|
+
if (reactVersion === '0') {
|
|
37
|
+
throw new Error(`Version ${reactVersion} of "react" is not supported by Remotion`);
|
|
38
|
+
}
|
|
39
|
+
const doesReactVersionSupportSuspense = parseInt(reactVersion, 10) >= 18;
|
|
40
|
+
const ThumbnailUI = ({ style, inputProps, errorFallback, renderLoading, className }, ref) => {
|
|
41
|
+
var _a, _b, _c;
|
|
42
|
+
const config = remotion_1.Internals.useUnsafeVideoConfig();
|
|
43
|
+
const video = remotion_1.Internals.useVideo();
|
|
44
|
+
const container = (0, react_1.useRef)(null);
|
|
45
|
+
const canvasSize = (0, use_element_size_js_1.useElementSize)(container, {
|
|
46
|
+
triggerOnWindowResize: false,
|
|
47
|
+
shouldApplyCssTransforms: false,
|
|
48
|
+
});
|
|
49
|
+
const layout = (0, react_1.useMemo)(() => {
|
|
50
|
+
if (!config || !canvasSize) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
return (0, calculate_scale_js_1.calculateCanvasTransformation)({
|
|
54
|
+
canvasSize,
|
|
55
|
+
compositionHeight: config.height,
|
|
56
|
+
compositionWidth: config.width,
|
|
57
|
+
previewSize: 'auto',
|
|
58
|
+
});
|
|
59
|
+
}, [canvasSize, config]);
|
|
60
|
+
const scale = (_a = layout === null || layout === void 0 ? void 0 : layout.scale) !== null && _a !== void 0 ? _a : 1;
|
|
61
|
+
const thumbnail = (0, use_thumbnail_js_1.useThumbnail)();
|
|
62
|
+
(0, react_1.useImperativeHandle)(ref, () => {
|
|
63
|
+
const methods = {
|
|
64
|
+
getContainerNode: () => container.current,
|
|
65
|
+
getScale: () => scale,
|
|
66
|
+
};
|
|
67
|
+
return Object.assign(thumbnail.emitter, methods);
|
|
68
|
+
}, [scale, thumbnail.emitter]);
|
|
69
|
+
const VideoComponent = video ? video.component : null;
|
|
70
|
+
const outerStyle = (0, react_1.useMemo)(() => {
|
|
71
|
+
return (0, calculate_scale_js_1.calculateOuterStyle)({ config, style, canvasSize });
|
|
72
|
+
}, [canvasSize, config, style]);
|
|
73
|
+
const outer = (0, react_1.useMemo)(() => {
|
|
74
|
+
return (0, calculate_scale_js_1.calculateOuter)({ config, layout, scale });
|
|
75
|
+
}, [config, layout, scale]);
|
|
76
|
+
const containerStyle = (0, react_1.useMemo)(() => {
|
|
77
|
+
return (0, calculate_scale_js_1.calculateContainerStyle)({
|
|
78
|
+
canvasSize,
|
|
79
|
+
config,
|
|
80
|
+
layout,
|
|
81
|
+
scale,
|
|
82
|
+
});
|
|
83
|
+
}, [canvasSize, config, layout, scale]);
|
|
84
|
+
const onError = (0, react_1.useCallback)((error) => {
|
|
85
|
+
// Pay attention to `this context`
|
|
86
|
+
thumbnail.emitter.dispatchError(error);
|
|
87
|
+
}, [thumbnail.emitter]);
|
|
88
|
+
const rootRef = (0, react_1.useRef)(null);
|
|
89
|
+
(0, react_1.useImperativeHandle)(ref, () => rootRef.current, []);
|
|
90
|
+
const loadingMarkup = (0, react_1.useMemo)(() => {
|
|
91
|
+
return renderLoading
|
|
92
|
+
? renderLoading({
|
|
93
|
+
height: outerStyle.height,
|
|
94
|
+
width: outerStyle.width,
|
|
95
|
+
})
|
|
96
|
+
: null;
|
|
97
|
+
}, [outerStyle.height, outerStyle.width, renderLoading]);
|
|
98
|
+
if (!config) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
const content = ((0, jsx_runtime_1.jsx)("div", { style: outer, children: (0, jsx_runtime_1.jsx)("div", { style: containerStyle, className: player_css_classname_js_1.PLAYER_CSS_CLASSNAME, children: VideoComponent ? ((0, jsx_runtime_1.jsx)(error_boundary_js_1.ErrorBoundary, { onError: onError, errorFallback: errorFallback, children: (0, jsx_runtime_1.jsx)(VideoComponent, { ...((_b = video === null || video === void 0 ? void 0 : video.defaultProps) !== null && _b !== void 0 ? _b : {}), ...((_c = inputProps) !== null && _c !== void 0 ? _c : {}) }) })) : null }) }));
|
|
102
|
+
if (is_node_js_1.IS_NODE && !doesReactVersionSupportSuspense) {
|
|
103
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: container, style: outerStyle, className: className, children: content }));
|
|
104
|
+
}
|
|
105
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: container, style: outerStyle, className: className, children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: loadingMarkup, children: content }) }));
|
|
106
|
+
};
|
|
107
|
+
exports.default = (0, react_1.forwardRef)(ThumbnailUI);
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { VideoConfig } from 'remotion';
|
|
2
|
+
import type { PreviewSize } from './utils/preview-size.js';
|
|
3
|
+
import type { Size } from './utils/use-element-size.js';
|
|
4
|
+
export declare const calculateScale: ({ canvasSize, compositionHeight, compositionWidth, previewSize, }: {
|
|
5
|
+
previewSize: PreviewSize['size'];
|
|
6
|
+
compositionWidth: number;
|
|
7
|
+
compositionHeight: number;
|
|
8
|
+
canvasSize: Size;
|
|
9
|
+
}) => number;
|
|
10
|
+
declare type Layout = {
|
|
11
|
+
centerX: number;
|
|
12
|
+
centerY: number;
|
|
13
|
+
xCorrection: number;
|
|
14
|
+
yCorrection: number;
|
|
15
|
+
scale: number;
|
|
16
|
+
};
|
|
17
|
+
export declare const calculateCanvasTransformation: ({ previewSize, compositionWidth, compositionHeight, canvasSize, }: {
|
|
18
|
+
previewSize: PreviewSize['size'];
|
|
19
|
+
compositionWidth: number;
|
|
20
|
+
compositionHeight: number;
|
|
21
|
+
canvasSize: Size;
|
|
22
|
+
}) => Layout;
|
|
23
|
+
export declare const calculateOuterStyle: ({ config, style, canvasSize, }: {
|
|
24
|
+
config: VideoConfig | null;
|
|
25
|
+
style: React.CSSProperties | undefined;
|
|
26
|
+
canvasSize: Size | null;
|
|
27
|
+
}) => React.CSSProperties;
|
|
28
|
+
export declare const calculateContainerStyle: ({ config, canvasSize, layout, scale, }: {
|
|
29
|
+
config: VideoConfig | null;
|
|
30
|
+
canvasSize: Size | null;
|
|
31
|
+
layout: Layout | null;
|
|
32
|
+
scale: number;
|
|
33
|
+
}) => React.CSSProperties;
|
|
34
|
+
export declare const calculateOuter: ({ layout, scale, config, }: {
|
|
35
|
+
layout: Layout | null;
|
|
36
|
+
scale: number;
|
|
37
|
+
config: VideoConfig | null;
|
|
38
|
+
}) => React.CSSProperties;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateOuter = exports.calculateContainerStyle = exports.calculateOuterStyle = exports.calculateCanvasTransformation = exports.calculateScale = void 0;
|
|
4
|
+
const calculate_player_size_js_1 = require("./utils/calculate-player-size.js");
|
|
5
|
+
const calculateScale = ({ canvasSize, compositionHeight, compositionWidth, previewSize, }) => {
|
|
6
|
+
const heightRatio = canvasSize.height / compositionHeight;
|
|
7
|
+
const widthRatio = canvasSize.width / compositionWidth;
|
|
8
|
+
const ratio = Math.min(heightRatio, widthRatio);
|
|
9
|
+
return previewSize === 'auto' ? ratio : Number(previewSize);
|
|
10
|
+
};
|
|
11
|
+
exports.calculateScale = calculateScale;
|
|
12
|
+
const calculateCanvasTransformation = ({ previewSize, compositionWidth, compositionHeight, canvasSize, }) => {
|
|
13
|
+
const scale = (0, exports.calculateScale)({
|
|
14
|
+
canvasSize,
|
|
15
|
+
compositionHeight,
|
|
16
|
+
compositionWidth,
|
|
17
|
+
previewSize,
|
|
18
|
+
});
|
|
19
|
+
const correction = 0 - (1 - scale) / 2;
|
|
20
|
+
const xCorrection = correction * compositionWidth;
|
|
21
|
+
const yCorrection = correction * compositionHeight;
|
|
22
|
+
const width = compositionWidth * scale;
|
|
23
|
+
const height = compositionHeight * scale;
|
|
24
|
+
const centerX = canvasSize.width / 2 - width / 2;
|
|
25
|
+
const centerY = canvasSize.height / 2 - height / 2;
|
|
26
|
+
return {
|
|
27
|
+
centerX,
|
|
28
|
+
centerY,
|
|
29
|
+
xCorrection,
|
|
30
|
+
yCorrection,
|
|
31
|
+
scale,
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
exports.calculateCanvasTransformation = calculateCanvasTransformation;
|
|
35
|
+
const calculateOuterStyle = ({ config, style, canvasSize, }) => {
|
|
36
|
+
if (!config) {
|
|
37
|
+
return {};
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
position: 'relative',
|
|
41
|
+
overflow: 'hidden',
|
|
42
|
+
...(0, calculate_player_size_js_1.calculatePlayerSize)({
|
|
43
|
+
compositionHeight: config.height,
|
|
44
|
+
compositionWidth: config.width,
|
|
45
|
+
currentSize: canvasSize,
|
|
46
|
+
height: style === null || style === void 0 ? void 0 : style.height,
|
|
47
|
+
width: style === null || style === void 0 ? void 0 : style.width,
|
|
48
|
+
}),
|
|
49
|
+
...style,
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
exports.calculateOuterStyle = calculateOuterStyle;
|
|
53
|
+
const calculateContainerStyle = ({ config, canvasSize, layout, scale, }) => {
|
|
54
|
+
if (!config || !canvasSize || !layout) {
|
|
55
|
+
return {};
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
position: 'absolute',
|
|
59
|
+
width: config.width,
|
|
60
|
+
height: config.height,
|
|
61
|
+
display: 'flex',
|
|
62
|
+
transform: `scale(${scale})`,
|
|
63
|
+
marginLeft: layout.xCorrection,
|
|
64
|
+
marginTop: layout.yCorrection,
|
|
65
|
+
overflow: 'hidden',
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
exports.calculateContainerStyle = calculateContainerStyle;
|
|
69
|
+
const calculateOuter = ({ layout, scale, config, }) => {
|
|
70
|
+
if (!layout || !config) {
|
|
71
|
+
return {};
|
|
72
|
+
}
|
|
73
|
+
const { centerX, centerY } = layout;
|
|
74
|
+
return {
|
|
75
|
+
width: config.width * scale,
|
|
76
|
+
height: config.height * scale,
|
|
77
|
+
display: 'flex',
|
|
78
|
+
flexDirection: 'column',
|
|
79
|
+
position: 'absolute',
|
|
80
|
+
left: centerX,
|
|
81
|
+
top: centerY,
|
|
82
|
+
overflow: 'hidden',
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
exports.calculateOuter = calculateOuter;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { PlayerEmitter, ThumbnailEmitter } from './event-emitter.js';
|
|
3
|
+
export declare const PlayerEventEmitterContext: React.Context<PlayerEmitter | undefined>;
|
|
4
|
+
export declare const ThumbnailEmitterContext: React.Context<ThumbnailEmitter | undefined>;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.PlayerEventEmitterContext = void 0;
|
|
6
|
+
exports.ThumbnailEmitterContext = exports.PlayerEventEmitterContext = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
exports.PlayerEventEmitterContext = react_1.default.createContext(undefined);
|
|
9
|
+
exports.ThumbnailEmitterContext = react_1.default.createContext(undefined);
|
|
File without changes
|
|
File without changes
|