@remotion/player 4.0.0-webhook.26 → 4.1.0-alpha1
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} +41 -17
- package/dist/cjs/PlaybackrateControl.d.ts +8 -0
- package/dist/cjs/PlaybackrateControl.js +163 -0
- package/dist/cjs/Player.d.ts +52 -0
- package/dist/{Player.js → cjs/Player.js} +41 -87
- package/dist/{PlayerControls.d.ts → cjs/PlayerControls.d.ts} +14 -5
- package/dist/cjs/PlayerControls.js +161 -0
- 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} +13 -12
- package/dist/{PlayerUI.js → cjs/PlayerUI.js} +54 -72
- package/dist/cjs/SharedPlayerContext.d.ts +15 -0
- package/dist/cjs/SharedPlayerContext.js +75 -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/cjs/event-emitter.d.ts +81 -0
- package/dist/{event-emitter.js → cjs/event-emitter.js} +43 -3
- 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/cjs/is-backgrounded.d.ts +2 -0
- package/dist/cjs/is-backgrounded.js +24 -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} +9 -6
- 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} +46 -9
- package/dist/{use-player.d.ts → cjs/use-player.d.ts} +2 -2
- 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 +1 -1
- 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 +2 -2
- package/dist/{utils → cjs/utils}/preview-size.js +0 -0
- package/dist/cjs/utils/props-if-has-props.d.ts +10 -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/cjs/utils/use-component-visible.d.ts +6 -0
- package/dist/cjs/utils/use-component-visible.js +21 -0
- package/dist/{utils → cjs/utils}/use-element-size.d.ts +2 -1
- package/dist/{utils → cjs/utils}/use-element-size.js +29 -12
- 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/PlaybackrateControl.d.ts +8 -0
- package/dist/esm/Player.d.ts +52 -0
- package/dist/esm/PlayerControls.d.ts +42 -0
- package/dist/esm/PlayerSeekBar.d.ts +8 -0
- package/dist/esm/PlayerUI.d.ts +40 -0
- package/dist/esm/SharedPlayerContext.d.ts +15 -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 +81 -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 +2132 -0
- package/dist/esm/is-backgrounded.d.ts +2 -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 +10 -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-component-visible.d.ts +6 -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 +80 -66
- package/dist/Player.d.ts +0 -49
- package/dist/PlayerControls.js +0 -137
- 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/event-emitter.d.ts +0 -52
- package/dist/index.js +0 -23
- package/dist/test/index.test.js +0 -8
- package/dist/test/validate-prop.test.js +0 -130
|
@@ -1,53 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const validate_in_out_frame_js_1 = require("../utils/validate-in-out-frame.js");
|
|
5
|
+
(0, vitest_1.test)('Validate in out frames', () => {
|
|
6
|
+
(0, vitest_1.expect)(() => (0, validate_in_out_frame_js_1.validateInOutFrames)({
|
|
6
7
|
durationInFrames: 200,
|
|
7
8
|
inFrame: 201,
|
|
8
9
|
outFrame: undefined,
|
|
9
10
|
})).toThrow(/inFrame must be less than \(durationInFrames - 1\)/);
|
|
10
|
-
expect(() => (0,
|
|
11
|
+
(0, vitest_1.expect)(() => (0, validate_in_out_frame_js_1.validateInOutFrames)({
|
|
11
12
|
durationInFrames: 200,
|
|
12
13
|
inFrame: 199,
|
|
13
14
|
outFrame: 201,
|
|
14
15
|
})).toThrow(/outFrame must be less than \(durationInFrames - 1\)/);
|
|
15
|
-
expect(() => (0,
|
|
16
|
+
(0, vitest_1.expect)(() => (0, validate_in_out_frame_js_1.validateInOutFrames)({
|
|
16
17
|
durationInFrames: 200,
|
|
17
18
|
inFrame: -10,
|
|
18
19
|
outFrame: null,
|
|
19
20
|
})).toThrow(/inFrame must be greater than 0, but is -10/);
|
|
20
|
-
expect(() => (0,
|
|
21
|
+
(0, vitest_1.expect)(() => (0, validate_in_out_frame_js_1.validateInOutFrames)({
|
|
21
22
|
durationInFrames: 200,
|
|
22
23
|
inFrame: null,
|
|
23
24
|
outFrame: -10,
|
|
24
25
|
})).toThrow(/outFrame must be greater than 0, but is -10/);
|
|
25
|
-
expect(() => (0,
|
|
26
|
+
(0, vitest_1.expect)(() => (0, validate_in_out_frame_js_1.validateInOutFrames)({
|
|
26
27
|
durationInFrames: 200,
|
|
27
28
|
inFrame: 1.5,
|
|
28
29
|
outFrame: null,
|
|
29
30
|
})).toThrow(/"inFrame" must be an integer, but is 1.5/);
|
|
30
|
-
expect(() => (0,
|
|
31
|
+
(0, vitest_1.expect)(() => (0, validate_in_out_frame_js_1.validateInOutFrames)({
|
|
31
32
|
durationInFrames: 200,
|
|
32
33
|
inFrame: 20,
|
|
33
34
|
outFrame: 20,
|
|
34
35
|
})).toThrow(/outFrame must be greater than inFrame, but is 20/);
|
|
35
|
-
expect(() => (0,
|
|
36
|
+
(0, vitest_1.expect)(() => (0, validate_in_out_frame_js_1.validateInOutFrames)({
|
|
36
37
|
durationInFrames: 200,
|
|
37
38
|
inFrame: 21,
|
|
38
39
|
outFrame: 20,
|
|
39
40
|
})).toThrow(/outFrame must be greater than inFrame, but is 20 <= 21/);
|
|
40
|
-
expect(() => (0,
|
|
41
|
+
(0, vitest_1.expect)(() => (0, validate_in_out_frame_js_1.validateInOutFrames)({
|
|
41
42
|
durationInFrames: 200,
|
|
42
43
|
inFrame: null,
|
|
43
44
|
outFrame: 20,
|
|
44
45
|
})).not.toThrow();
|
|
45
|
-
expect(() => (0,
|
|
46
|
+
(0, vitest_1.expect)(() => (0, validate_in_out_frame_js_1.validateInOutFrames)({
|
|
46
47
|
durationInFrames: 200,
|
|
47
48
|
inFrame: null,
|
|
48
49
|
outFrame: null,
|
|
49
50
|
})).not.toThrow();
|
|
50
|
-
expect(() => (0,
|
|
51
|
+
(0, vitest_1.expect)(() => (0, validate_in_out_frame_js_1.validateInOutFrames)({
|
|
51
52
|
durationInFrames: 200,
|
|
52
53
|
inFrame: 10,
|
|
53
54
|
outFrame: 20,
|
|
File without changes
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const remotion_1 = require("remotion");
|
|
5
|
+
const vitest_1 = require("vitest");
|
|
6
|
+
const index_js_1 = require("../index.js");
|
|
7
|
+
const test_utils_js_1 = require("./test-utils.js");
|
|
8
|
+
(0, vitest_1.test)('no compositionWidth should give errors', () => {
|
|
9
|
+
try {
|
|
10
|
+
(0, test_utils_js_1.render)((0, jsx_runtime_1.jsx)(index_js_1.Player
|
|
11
|
+
// @ts-expect-error
|
|
12
|
+
, {
|
|
13
|
+
// @ts-expect-error
|
|
14
|
+
compositionWidth: null, errorFallback: () => 'something went wrong', compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_js_1.HelloWorld, controls: true, showVolumeControls: true }));
|
|
15
|
+
}
|
|
16
|
+
catch (e) {
|
|
17
|
+
(0, vitest_1.expect)(e.message).toMatch(/'compositionWidth' must be a number but got 'object' instead/);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
(0, vitest_1.test)('no compositionHeight should give errors', () => {
|
|
21
|
+
try {
|
|
22
|
+
(0, test_utils_js_1.render)((0, jsx_runtime_1.jsx)(index_js_1.Player, { compositionWidth: 400, errorFallback: () => 'something went wrong',
|
|
23
|
+
// @ts-expect-error
|
|
24
|
+
compositionHeight: undefined, fps: 30, durationInFrames: 500, component: test_utils_js_1.HelloWorld, controls: true, showVolumeControls: true }));
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
(0, vitest_1.expect)(e.message).toMatch(/'compositionHeight' must be a number but got 'undefined' instead/);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
(0, vitest_1.test)('No fps should give errors', () => {
|
|
31
|
+
try {
|
|
32
|
+
(0, test_utils_js_1.render)((0, jsx_runtime_1.jsx)(index_js_1.Player, { compositionWidth: 500, compositionHeight: 400, errorFallback: () => 'something went wrong',
|
|
33
|
+
// @ts-expect-error
|
|
34
|
+
fps: null, durationInFrames: 500, component: test_utils_js_1.HelloWorld, controls: true, showVolumeControls: true }));
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
(0, vitest_1.expect)(e.message).toMatch(/"fps" must be a number, but you passed a value of type object/);
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
(0, test_utils_js_1.render)((0, jsx_runtime_1.jsx)(index_js_1.Player, { compositionWidth: 500, compositionHeight: 400, errorFallback: () => 'something went wrong',
|
|
41
|
+
// @ts-expect-error
|
|
42
|
+
fps: undefined, durationInFrames: 500, component: test_utils_js_1.HelloWorld, controls: true, showVolumeControls: true }));
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
(0, vitest_1.expect)(e.message).toMatch(/"fps" must be a number, but you passed a value of type undefined/);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
(0, vitest_1.test)('No durationInFrames should give errors', () => {
|
|
49
|
+
try {
|
|
50
|
+
(0, test_utils_js_1.render)((0, jsx_runtime_1.jsx)(index_js_1.Player, { compositionWidth: 500, compositionHeight: 400, errorFallback: () => 'something went wrong', fps: 30,
|
|
51
|
+
// @ts-expect-error
|
|
52
|
+
durationInFrames: undefined, component: test_utils_js_1.HelloWorld, controls: true, showVolumeControls: true }));
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
(0, vitest_1.expect)(e.message).toMatch(/durationInFrames` must be a number, but is undefined/);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
(0, vitest_1.test)('Invalid playbackRate should give error', () => {
|
|
59
|
+
try {
|
|
60
|
+
(0, test_utils_js_1.render)((0, jsx_runtime_1.jsx)(index_js_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_js_1.HelloWorld, controls: true, showVolumeControls: true, playbackRate: -5, inputProps: {} }));
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
(0, vitest_1.expect)(e.message).toMatch(/The lowest possible playback rate is -4. You passed: -5/);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
(0, vitest_1.test)('playbackRate of 0 should not be possible', () => {
|
|
67
|
+
try {
|
|
68
|
+
(0, test_utils_js_1.render)((0, jsx_runtime_1.jsx)(index_js_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_js_1.HelloWorld, controls: true, showVolumeControls: true, playbackRate: 0 }));
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
(0, vitest_1.expect)(e.message).toMatch(/A playback rate of 0 is not supported./);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
(0, vitest_1.test)('playbackRate of wrong type should not be possible', () => {
|
|
75
|
+
try {
|
|
76
|
+
(0, test_utils_js_1.render)((0, jsx_runtime_1.jsx)(index_js_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_js_1.HelloWorld, controls: true, showVolumeControls: true,
|
|
77
|
+
// @ts-expect-error
|
|
78
|
+
playbackRate: 'hi' }));
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
(0, vitest_1.expect)(e.message).toMatch(/A playback rate of 0 is not supported./);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
(0, vitest_1.test)('playbackRate of undefined should be okay', () => {
|
|
85
|
+
(0, test_utils_js_1.render)((0, jsx_runtime_1.jsx)(index_js_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500, component: test_utils_js_1.HelloWorld, controls: true, showVolumeControls: true }));
|
|
86
|
+
(0, vitest_1.expect)(true).toBe(true);
|
|
87
|
+
});
|
|
88
|
+
(0, vitest_1.test)('passing in <Composition /> instance should not be possible', () => {
|
|
89
|
+
(0, vitest_1.expect)(() => {
|
|
90
|
+
(0, test_utils_js_1.render)((0, jsx_runtime_1.jsx)(index_js_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500, component: remotion_1.Composition, controls: true, showVolumeControls: true, inputProps: {
|
|
91
|
+
id: 'HelloWorld',
|
|
92
|
+
width: 500,
|
|
93
|
+
height: 400,
|
|
94
|
+
fps: 30,
|
|
95
|
+
durationInFrames: 500,
|
|
96
|
+
component: test_utils_js_1.HelloWorld,
|
|
97
|
+
} }));
|
|
98
|
+
}).toThrow(/'component' must not be the 'Composition' component\. Pass your own React/);
|
|
99
|
+
});
|
|
100
|
+
(0, vitest_1.test)('passing in <Composition /> instance should not be possible', () => {
|
|
101
|
+
(0, vitest_1.expect)(() => {
|
|
102
|
+
(0, test_utils_js_1.render)((0, jsx_runtime_1.jsx)(index_js_1.Player, { compositionWidth: 500, compositionHeight: 400, fps: 30, durationInFrames: 500,
|
|
103
|
+
// @ts-expect-error
|
|
104
|
+
component: (0, jsx_runtime_1.jsx)(remotion_1.Composition, { durationInFrames: 30, fps: 30, height: 10, width: 10, id: "hello", component: test_utils_js_1.HelloWorld }), controls: true, showVolumeControls: true, inputProps: {
|
|
105
|
+
id: 'HelloWorld',
|
|
106
|
+
width: 500,
|
|
107
|
+
height: 400,
|
|
108
|
+
fps: 30,
|
|
109
|
+
durationInFrames: 500,
|
|
110
|
+
component: test_utils_js_1.HelloWorld,
|
|
111
|
+
} }));
|
|
112
|
+
}).toThrow(/'component' should not be an instance of <Composition\/>\. Pass the React component dir/);
|
|
113
|
+
});
|
|
114
|
+
vitest_1.test.each([
|
|
115
|
+
['controls'],
|
|
116
|
+
['loop'],
|
|
117
|
+
['autoPlay'],
|
|
118
|
+
['showVolumeControls'],
|
|
119
|
+
['allowFullscreen'],
|
|
120
|
+
['clickToPlay'],
|
|
121
|
+
['doubleClickToFullscreen'],
|
|
122
|
+
])('No durationInFrames should give errors %s', (a) => {
|
|
123
|
+
const props = {};
|
|
124
|
+
props[a] = 'hey';
|
|
125
|
+
try {
|
|
126
|
+
(0, test_utils_js_1.render)((0, jsx_runtime_1.jsx)(index_js_1.Player, { compositionWidth: 500, compositionHeight: 400, errorFallback: () => 'something went wrong', fps: 30, durationInFrames: 100, component: test_utils_js_1.HelloWorld, ...props }));
|
|
127
|
+
}
|
|
128
|
+
catch (e) {
|
|
129
|
+
(0, vitest_1.expect)(e.message).toMatch(`'${a}' must be a boolean or undefined but got 'string' instead`);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -3,13 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.usePlayback = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const remotion_1 = require("remotion");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
6
|
+
const calculate_next_frame_js_1 = require("./calculate-next-frame.js");
|
|
7
|
+
const is_backgrounded_js_1 = require("./is-backgrounded.js");
|
|
8
|
+
const use_player_js_1 = require("./use-player.js");
|
|
8
9
|
const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, outFrame, }) => {
|
|
9
10
|
const frame = remotion_1.Internals.Timeline.useTimelinePosition();
|
|
10
11
|
const config = remotion_1.Internals.useUnsafeVideoConfig();
|
|
11
|
-
const { playing, pause, emitter } = (0,
|
|
12
|
+
const { playing, pause, emitter } = (0, use_player_js_1.usePlayer)();
|
|
12
13
|
const setFrame = remotion_1.Internals.Timeline.useTimelineSetFrame();
|
|
14
|
+
// requestAnimationFrame() does not work if the tab is not active.
|
|
15
|
+
// This means that audio will keep playing even if it has ended.
|
|
16
|
+
// In that case, we use setTimeout() instead.
|
|
17
|
+
const isBackgroundedRef = (0, is_backgrounded_js_1.useIsBackgrounded)();
|
|
13
18
|
const frameRef = (0, react_1.useRef)(frame);
|
|
14
19
|
frameRef.current = frame;
|
|
15
20
|
const lastTimeUpdateEvent = (0, react_1.useRef)(null);
|
|
@@ -24,17 +29,25 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
24
29
|
let reqAnimFrameCall = null;
|
|
25
30
|
const startedTime = performance.now();
|
|
26
31
|
let framesAdvanced = 0;
|
|
27
|
-
const
|
|
28
|
-
hasBeenStopped = true;
|
|
32
|
+
const cancelQueuedFrame = () => {
|
|
29
33
|
if (reqAnimFrameCall !== null) {
|
|
30
|
-
|
|
34
|
+
if (reqAnimFrameCall.type === 'raf') {
|
|
35
|
+
cancelAnimationFrame(reqAnimFrameCall.id);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
clearTimeout(reqAnimFrameCall.id);
|
|
39
|
+
}
|
|
31
40
|
}
|
|
32
41
|
};
|
|
42
|
+
const stop = () => {
|
|
43
|
+
hasBeenStopped = true;
|
|
44
|
+
cancelQueuedFrame();
|
|
45
|
+
};
|
|
33
46
|
const callback = () => {
|
|
34
47
|
const time = performance.now() - startedTime;
|
|
35
48
|
const actualLastFrame = outFrame !== null && outFrame !== void 0 ? outFrame : config.durationInFrames - 1;
|
|
36
49
|
const actualFirstFrame = inFrame !== null && inFrame !== void 0 ? inFrame : 0;
|
|
37
|
-
const { nextFrame, framesToAdvance, hasEnded } = (0,
|
|
50
|
+
const { nextFrame, framesToAdvance, hasEnded } = (0, calculate_next_frame_js_1.calculateNextFrame)({
|
|
38
51
|
time,
|
|
39
52
|
currentFrame: frameRef.current,
|
|
40
53
|
playbackSpeed: playbackRate,
|
|
@@ -56,11 +69,34 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
56
69
|
return;
|
|
57
70
|
}
|
|
58
71
|
if (!hasBeenStopped) {
|
|
59
|
-
|
|
72
|
+
queueNextFrame();
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const queueNextFrame = () => {
|
|
76
|
+
if (isBackgroundedRef.current) {
|
|
77
|
+
reqAnimFrameCall = {
|
|
78
|
+
type: 'timeout',
|
|
79
|
+
// Note: Most likely, this will not be 1000 / fps, but the browser will throttle it to ~1/sec.
|
|
80
|
+
id: setTimeout(callback, 1000 / config.fps),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
reqAnimFrameCall = { type: 'raf', id: requestAnimationFrame(callback) };
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
queueNextFrame();
|
|
88
|
+
const onVisibilityChange = () => {
|
|
89
|
+
if (document.visibilityState === 'visible') {
|
|
90
|
+
return;
|
|
60
91
|
}
|
|
92
|
+
// If tab goes into the background, cancel requestAnimationFrame() and update immediately.
|
|
93
|
+
// , so the transition to setTimeout() can be fulfilled.
|
|
94
|
+
cancelQueuedFrame();
|
|
95
|
+
callback();
|
|
61
96
|
};
|
|
62
|
-
|
|
97
|
+
window.addEventListener('visibilitychange', onVisibilityChange);
|
|
63
98
|
return () => {
|
|
99
|
+
window.removeEventListener('visibilitychange', onVisibilityChange);
|
|
64
100
|
stop();
|
|
65
101
|
};
|
|
66
102
|
}, [
|
|
@@ -74,6 +110,7 @@ const usePlayback = ({ loop, playbackRate, moveToBeginningWhenEnded, inFrame, ou
|
|
|
74
110
|
inFrame,
|
|
75
111
|
outFrame,
|
|
76
112
|
moveToBeginningWhenEnded,
|
|
113
|
+
isBackgroundedRef,
|
|
77
114
|
]);
|
|
78
115
|
(0, react_1.useEffect)(() => {
|
|
79
116
|
const interval = setInterval(() => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SyntheticEvent } from 'react';
|
|
2
|
-
import type { PlayerEmitter } from './event-emitter';
|
|
3
|
-
|
|
2
|
+
import type { PlayerEmitter } from './event-emitter.js';
|
|
3
|
+
type UsePlayerMethods = {
|
|
4
4
|
frameBack: (frames: number) => void;
|
|
5
5
|
frameForward: (frames: number) => void;
|
|
6
6
|
isLastFrame: boolean;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.usePlayer = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const remotion_1 = require("remotion");
|
|
6
|
-
const
|
|
6
|
+
const emitter_context_js_1 = require("./emitter-context.js");
|
|
7
7
|
const usePlayer = () => {
|
|
8
8
|
var _a;
|
|
9
9
|
const [playing, setPlaying, imperativePlaying] = remotion_1.Internals.Timeline.usePlayingState();
|
|
@@ -18,7 +18,7 @@ const usePlayer = () => {
|
|
|
18
18
|
frameRef.current = frame;
|
|
19
19
|
const video = remotion_1.Internals.useVideo();
|
|
20
20
|
const config = remotion_1.Internals.useUnsafeVideoConfig();
|
|
21
|
-
const emitter = (0, react_1.useContext)(
|
|
21
|
+
const emitter = (0, react_1.useContext)(emitter_context_js_1.PlayerEventEmitterContext);
|
|
22
22
|
const lastFrame = ((_a = config === null || config === void 0 ? void 0 : config.durationInFrames) !== null && _a !== void 0 ? _a : 1) - 1;
|
|
23
23
|
const isLastFrame = frame === lastFrame;
|
|
24
24
|
const isFirstFrame = frame === 0;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useThumbnail = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const emitter_context_js_1 = require("./emitter-context.js");
|
|
6
|
+
const useThumbnail = () => {
|
|
7
|
+
const emitter = (0, react_1.useContext)(emitter_context_js_1.ThumbnailEmitterContext);
|
|
8
|
+
if (!emitter) {
|
|
9
|
+
throw new TypeError('Expected Player event emitter context');
|
|
10
|
+
}
|
|
11
|
+
const returnValue = (0, react_1.useMemo)(() => {
|
|
12
|
+
return {
|
|
13
|
+
emitter,
|
|
14
|
+
};
|
|
15
|
+
}, [emitter]);
|
|
16
|
+
return returnValue;
|
|
17
|
+
};
|
|
18
|
+
exports.useThumbnail = useThumbnail;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
type Info = {
|
|
2
|
+
maxTimeLabelWidth: number | null;
|
|
3
|
+
displayVerticalVolumeSlider: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare const X_SPACER = 10;
|
|
6
|
+
export declare const X_PADDING = 12;
|
|
1
7
|
export declare const useVideoControlsResize: ({ allowFullscreen: allowFullScreen, playerWidth, }: {
|
|
2
8
|
allowFullscreen: boolean;
|
|
3
9
|
playerWidth: number;
|
|
4
|
-
}) =>
|
|
5
|
-
|
|
6
|
-
displayVerticalVolumeSlider: boolean;
|
|
7
|
-
};
|
|
10
|
+
}) => Info;
|
|
11
|
+
export {};
|
|
@@ -1,33 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useVideoControlsResize = void 0;
|
|
3
|
+
exports.useVideoControlsResize = exports.X_PADDING = exports.X_SPACER = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
5
|
+
const icons_js_1 = require("./icons.js");
|
|
6
|
+
const MediaVolumeSlider_js_1 = require("./MediaVolumeSlider.js");
|
|
7
|
+
exports.X_SPACER = 10;
|
|
8
|
+
exports.X_PADDING = 12;
|
|
8
9
|
const useVideoControlsResize = ({ allowFullscreen: allowFullScreen, playerWidth, }) => {
|
|
9
10
|
const resizeInfo = (0, react_1.useMemo)(() => {
|
|
10
|
-
const playPauseIconSize =
|
|
11
|
-
const volumeIconSize =
|
|
12
|
-
const _fullscreenIconSize = allowFullScreen ?
|
|
11
|
+
const playPauseIconSize = icons_js_1.ICON_SIZE;
|
|
12
|
+
const volumeIconSize = icons_js_1.ICON_SIZE;
|
|
13
|
+
const _fullscreenIconSize = allowFullScreen ? icons_js_1.fullscreenIconSize : 0;
|
|
13
14
|
const elementsSize = volumeIconSize +
|
|
14
15
|
playPauseIconSize +
|
|
15
16
|
_fullscreenIconSize +
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
exports.X_PADDING * 2 +
|
|
18
|
+
exports.X_SPACER * 2;
|
|
18
19
|
const maxTimeLabelWidth = playerWidth - elementsSize;
|
|
19
20
|
const maxTimeLabelWidthWithoutNegativeValue = Math.max(maxTimeLabelWidth, 0);
|
|
20
|
-
const availableTimeLabelWidthIfVolumeOpen = maxTimeLabelWidthWithoutNegativeValue -
|
|
21
|
+
const availableTimeLabelWidthIfVolumeOpen = maxTimeLabelWidthWithoutNegativeValue - MediaVolumeSlider_js_1.VOLUME_SLIDER_WIDTH;
|
|
21
22
|
// If max label width is lower than the volume width
|
|
22
23
|
// then it means we need to take it's width as the max label width
|
|
23
24
|
// otherwise we took the available width when volume open
|
|
24
|
-
const computedLabelWidth = availableTimeLabelWidthIfVolumeOpen <
|
|
25
|
+
const computedLabelWidth = availableTimeLabelWidthIfVolumeOpen < MediaVolumeSlider_js_1.VOLUME_SLIDER_WIDTH
|
|
25
26
|
? maxTimeLabelWidthWithoutNegativeValue
|
|
26
27
|
: availableTimeLabelWidthIfVolumeOpen;
|
|
27
|
-
const minWidthForHorizontalDisplay = computedLabelWidth + elementsSize +
|
|
28
|
+
const minWidthForHorizontalDisplay = computedLabelWidth + elementsSize + MediaVolumeSlider_js_1.VOLUME_SLIDER_WIDTH;
|
|
28
29
|
const displayVerticalVolumeSlider = playerWidth < minWidthForHorizontalDisplay;
|
|
29
30
|
return {
|
|
30
|
-
maxTimeLabelWidth: maxTimeLabelWidthWithoutNegativeValue
|
|
31
|
+
maxTimeLabelWidth: maxTimeLabelWidthWithoutNegativeValue === 0
|
|
32
|
+
? null
|
|
33
|
+
: maxTimeLabelWidthWithoutNegativeValue,
|
|
31
34
|
displayVerticalVolumeSlider,
|
|
32
35
|
};
|
|
33
36
|
}, [allowFullScreen, playerWidth]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StandardLonghandProperties } from 'csstype';
|
|
2
|
-
import type { Size } from './use-element-size';
|
|
2
|
+
import type { Size } from './use-element-size.js';
|
|
3
3
|
export declare const calculatePlayerSize: ({ currentSize, width, height, compositionWidth, compositionHeight, }: {
|
|
4
4
|
currentSize: Size | null;
|
|
5
5
|
width: StandardLonghandProperties['width'] | undefined;
|
|
@@ -2,23 +2,22 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.calculatePlayerSize = void 0;
|
|
4
4
|
const calculatePlayerSize = ({ currentSize, width, height, compositionWidth, compositionHeight, }) => {
|
|
5
|
-
const aspectRatio = compositionWidth / compositionHeight;
|
|
6
|
-
if (!currentSize) {
|
|
7
|
-
return {
|
|
8
|
-
width: compositionWidth,
|
|
9
|
-
height: compositionHeight,
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
// If has width specified, but no height, specify a default height that satisfies the aspect ratio.
|
|
13
5
|
if (width !== undefined && height === undefined) {
|
|
14
6
|
return {
|
|
15
|
-
|
|
7
|
+
aspectRatio: [compositionWidth, compositionHeight].join('/'),
|
|
16
8
|
};
|
|
17
9
|
}
|
|
18
10
|
// Opposite: If has height specified, evaluate the height and specify a default width.
|
|
19
11
|
if (height !== undefined && width === undefined) {
|
|
20
12
|
return {
|
|
21
|
-
|
|
13
|
+
// Aspect ratio CSS prop will work
|
|
14
|
+
aspectRatio: [compositionWidth, compositionHeight].join('/'),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
if (!currentSize) {
|
|
18
|
+
return {
|
|
19
|
+
width: compositionWidth,
|
|
20
|
+
height: compositionHeight,
|
|
22
21
|
};
|
|
23
22
|
}
|
|
24
23
|
return {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AnyZodObject, z } from 'zod';
|
|
2
|
+
export type PropsIfHasProps<Schema extends AnyZodObject, Props> = AnyZodObject extends Schema ? {} extends Props ? {
|
|
3
|
+
inputProps?: z.infer<Schema> & Props;
|
|
4
|
+
} : {
|
|
5
|
+
inputProps: Props;
|
|
6
|
+
} : {} extends Props ? {
|
|
7
|
+
inputProps: z.infer<Schema>;
|
|
8
|
+
} : {
|
|
9
|
+
inputProps: z.infer<Schema> & Props;
|
|
10
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CancellablePromise } from './cancellable-promise';
|
|
1
|
+
import type { CancellablePromise } from './cancellable-promise.js';
|
|
2
2
|
declare const useCancellablePromises: () => {
|
|
3
3
|
appendPendingPromise: (promise: CancellablePromise) => void;
|
|
4
4
|
removePendingPromise: (promise: CancellablePromise) => void;
|
|
File without changes
|
|
File without changes
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useClickPreventionOnDoubleClick = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
5
|
+
const cancellable_promise_js_1 = require("./cancellable-promise.js");
|
|
6
|
+
const delay_js_1 = require("./delay.js");
|
|
7
|
+
const use_cancellable_promises_js_1 = require("./use-cancellable-promises.js");
|
|
8
8
|
const useClickPreventionOnDoubleClick = (onClick, onDoubleClick, doubleClickToFullscreen) => {
|
|
9
|
-
const api = (0,
|
|
9
|
+
const api = (0, use_cancellable_promises_js_1.useCancellablePromises)();
|
|
10
10
|
const handleClick = (0, react_1.useCallback)(async (e) => {
|
|
11
11
|
api.clearPendingPromises();
|
|
12
|
-
const waitForClick = (0,
|
|
12
|
+
const waitForClick = (0, cancellable_promise_js_1.cancellablePromise)((0, delay_js_1.delay)(200));
|
|
13
13
|
api.appendPendingPromise(waitForClick);
|
|
14
14
|
try {
|
|
15
15
|
await waitForClick.promise;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export default function useComponentVisible(initialIsVisible: boolean): {
|
|
3
|
+
ref: import("react").RefObject<HTMLDivElement>;
|
|
4
|
+
isComponentVisible: boolean;
|
|
5
|
+
setIsComponentVisible: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
6
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const react_1 = require("react");
|
|
4
|
+
// hook to hide a popup/modal when clicked outside
|
|
5
|
+
function useComponentVisible(initialIsVisible) {
|
|
6
|
+
const [isComponentVisible, setIsComponentVisible] = (0, react_1.useState)(initialIsVisible);
|
|
7
|
+
const ref = (0, react_1.useRef)(null);
|
|
8
|
+
(0, react_1.useEffect)(() => {
|
|
9
|
+
const handleClickOutside = (event) => {
|
|
10
|
+
if (ref.current && !ref.current.contains(event.target)) {
|
|
11
|
+
setIsComponentVisible(false);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
document.addEventListener('pointerup', handleClickOutside, true);
|
|
15
|
+
return () => {
|
|
16
|
+
document.removeEventListener('pointerup', handleClickOutside, true);
|
|
17
|
+
};
|
|
18
|
+
}, []);
|
|
19
|
+
return { ref, isComponentVisible, setIsComponentVisible };
|
|
20
|
+
}
|
|
21
|
+
exports.default = useComponentVisible;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type Size = {
|
|
2
2
|
width: number;
|
|
3
3
|
height: number;
|
|
4
4
|
left: number;
|
|
@@ -7,6 +7,7 @@ export declare type Size = {
|
|
|
7
7
|
width: number;
|
|
8
8
|
height: number;
|
|
9
9
|
};
|
|
10
|
+
refresh: () => void;
|
|
10
11
|
};
|
|
11
12
|
export declare const updateAllElementsSizes: () => void;
|
|
12
13
|
export declare const useElementSize: (ref: React.RefObject<HTMLElement>, options: {
|