@remotion/player 3.3.55 → 3.3.56
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/esm/calculate-scale.d.ts +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/test/test-utils.d.ts +2 -2
- package/dist/esm/utils/delay.d.ts +1 -1
- package/dist/esm/utils/use-cancellable-promises.d.ts +1 -1
- package/dist/{tsconfig-cjs.tsbuildinfo → tsconfig-esm.tsbuildinfo} +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/dist/esm/MediaVolumeSlider.js +0 -114
- package/dist/esm/Player.js +0 -140
- package/dist/esm/PlayerControls.js +0 -146
- package/dist/esm/PlayerSeekBar.js +0 -142
- package/dist/esm/PlayerUI.js +0 -283
- package/dist/esm/SharedPlayerContext.js +0 -68
- package/dist/esm/Thumbnail.js +0 -39
- package/dist/esm/ThumbnailUI.js +0 -82
- package/dist/esm/calculate-next-frame.js +0 -24
- package/dist/esm/calculate-scale.js +0 -77
- package/dist/esm/emitter-context.js +0 -3
- package/dist/esm/error-boundary.js +0 -32
- package/dist/esm/event-emitter.js +0 -82
- package/dist/esm/format-time.js +0 -5
- package/dist/esm/icons.js +0 -42
- package/dist/esm/index.js +0 -20
- package/dist/esm/player-css-classname.js +0 -1
- package/dist/esm/player-methods.js +0 -1
- package/dist/esm/test/index.test.js +0 -7
- package/dist/esm/test/test-utils.js +0 -14
- package/dist/esm/test/validate-in-out-frames.test.js +0 -54
- package/dist/esm/test/validate-prop.test.js +0 -129
- package/dist/esm/use-hover-state.js +0 -23
- package/dist/esm/use-playback.js +0 -88
- package/dist/esm/use-player.js +0 -128
- package/dist/esm/use-thumbnail.js +0 -14
- package/dist/esm/use-video-controls-resize.js +0 -35
- package/dist/esm/utils/calculate-player-size.js +0 -24
- package/dist/esm/utils/cancellable-promise.js +0 -22
- package/dist/esm/utils/delay.js +0 -2
- package/dist/esm/utils/is-node.js +0 -1
- package/dist/esm/utils/preview-size.js +0 -1
- package/dist/esm/utils/props-if-has-props.js +0 -1
- package/dist/esm/utils/use-cancellable-promises.js +0 -18
- package/dist/esm/utils/use-click-prevention-on-double-click.js +0 -42
- package/dist/esm/utils/use-element-size.js +0 -93
- package/dist/esm/utils/validate-in-out-frame.js +0 -49
- package/dist/esm/utils/validate-initial-frame.js +0 -23
- package/dist/esm/utils/validate-playbackrate.js +0 -14
- package/dist/esm/volume-persistance.js +0 -14
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export const calculatePlayerSize = ({ currentSize, width, height, compositionWidth, compositionHeight, }) => {
|
|
2
|
-
if (width !== undefined && height === undefined) {
|
|
3
|
-
return {
|
|
4
|
-
aspectRatio: [compositionWidth, compositionHeight].join('/'),
|
|
5
|
-
};
|
|
6
|
-
}
|
|
7
|
-
// Opposite: If has height specified, evaluate the height and specify a default width.
|
|
8
|
-
if (height !== undefined && width === undefined) {
|
|
9
|
-
return {
|
|
10
|
-
// Aspect ratio CSS prop will work
|
|
11
|
-
aspectRatio: [compositionWidth, compositionHeight].join('/'),
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
if (!currentSize) {
|
|
15
|
-
return {
|
|
16
|
-
width: compositionWidth,
|
|
17
|
-
height: compositionHeight,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
return {
|
|
21
|
-
width: compositionWidth,
|
|
22
|
-
height: compositionHeight,
|
|
23
|
-
};
|
|
24
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export const cancellablePromise = (promise) => {
|
|
2
|
-
let isCanceled = false;
|
|
3
|
-
const wrappedPromise = new Promise((resolve, reject) => {
|
|
4
|
-
promise
|
|
5
|
-
.then((value) => {
|
|
6
|
-
if (isCanceled) {
|
|
7
|
-
reject({ isCanceled, value });
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
resolve(value);
|
|
11
|
-
})
|
|
12
|
-
.catch((error) => {
|
|
13
|
-
reject({ isCanceled, error });
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
return {
|
|
17
|
-
promise: wrappedPromise,
|
|
18
|
-
cancel: () => {
|
|
19
|
-
isCanceled = true;
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
};
|
package/dist/esm/utils/delay.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const IS_NODE = typeof document === 'undefined';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { useCallback, useMemo, useRef } from 'react';
|
|
2
|
-
const useCancellablePromises = () => {
|
|
3
|
-
const pendingPromises = useRef([]);
|
|
4
|
-
const appendPendingPromise = useCallback((promise) => {
|
|
5
|
-
pendingPromises.current = [...pendingPromises.current, promise];
|
|
6
|
-
}, []);
|
|
7
|
-
const removePendingPromise = useCallback((promise) => {
|
|
8
|
-
pendingPromises.current = pendingPromises.current.filter((p) => p !== promise);
|
|
9
|
-
}, []);
|
|
10
|
-
const clearPendingPromises = useCallback(() => pendingPromises.current.map((p) => p.cancel()), []);
|
|
11
|
-
const api = useMemo(() => ({
|
|
12
|
-
appendPendingPromise,
|
|
13
|
-
removePendingPromise,
|
|
14
|
-
clearPendingPromises,
|
|
15
|
-
}), [appendPendingPromise, clearPendingPromises, removePendingPromise]);
|
|
16
|
-
return api;
|
|
17
|
-
};
|
|
18
|
-
export { useCancellablePromises };
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { useCallback, useMemo } from 'react';
|
|
2
|
-
import { cancellablePromise } from './cancellable-promise.js';
|
|
3
|
-
import { delay } from './delay.js';
|
|
4
|
-
import { useCancellablePromises } from './use-cancellable-promises.js';
|
|
5
|
-
const useClickPreventionOnDoubleClick = (onClick, onDoubleClick, doubleClickToFullscreen) => {
|
|
6
|
-
const api = useCancellablePromises();
|
|
7
|
-
const handleClick = useCallback(async (e) => {
|
|
8
|
-
api.clearPendingPromises();
|
|
9
|
-
const waitForClick = cancellablePromise(delay(200));
|
|
10
|
-
api.appendPendingPromise(waitForClick);
|
|
11
|
-
try {
|
|
12
|
-
await waitForClick.promise;
|
|
13
|
-
api.removePendingPromise(waitForClick);
|
|
14
|
-
onClick(e);
|
|
15
|
-
}
|
|
16
|
-
catch (errorInfo) {
|
|
17
|
-
const info = errorInfo;
|
|
18
|
-
api.removePendingPromise(waitForClick);
|
|
19
|
-
if (!info.isCanceled) {
|
|
20
|
-
throw info.error;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}, [api, onClick]);
|
|
24
|
-
const handleDoubleClick = useCallback(() => {
|
|
25
|
-
api.clearPendingPromises();
|
|
26
|
-
onDoubleClick();
|
|
27
|
-
}, [api, onDoubleClick]);
|
|
28
|
-
const returnValue = useMemo(() => {
|
|
29
|
-
if (!doubleClickToFullscreen) {
|
|
30
|
-
return [onClick, onDoubleClick];
|
|
31
|
-
}
|
|
32
|
-
return [handleClick, handleDoubleClick];
|
|
33
|
-
}, [
|
|
34
|
-
doubleClickToFullscreen,
|
|
35
|
-
handleClick,
|
|
36
|
-
handleDoubleClick,
|
|
37
|
-
onClick,
|
|
38
|
-
onDoubleClick,
|
|
39
|
-
]);
|
|
40
|
-
return returnValue;
|
|
41
|
-
};
|
|
42
|
-
export { useClickPreventionOnDoubleClick };
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
|
-
let elementSizeHooks = [];
|
|
3
|
-
export const updateAllElementsSizes = () => {
|
|
4
|
-
for (const listener of elementSizeHooks) {
|
|
5
|
-
listener();
|
|
6
|
-
}
|
|
7
|
-
};
|
|
8
|
-
export const useElementSize = (ref, options) => {
|
|
9
|
-
const [size, setSize] = useState(null);
|
|
10
|
-
const observer = useMemo(() => {
|
|
11
|
-
if (typeof ResizeObserver === 'undefined') {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
return new ResizeObserver((entries) => {
|
|
15
|
-
// The contentRect returns the width without any `scale()`'s being applied. The height is wrong
|
|
16
|
-
const { contentRect } = entries[0];
|
|
17
|
-
// The clientRect returns the size with `scale()` being applied.
|
|
18
|
-
const newSize = entries[0].target.getClientRects();
|
|
19
|
-
if (!newSize || !newSize[0]) {
|
|
20
|
-
setSize(null);
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
const probableCssParentScale = newSize[0].width / contentRect.width;
|
|
24
|
-
const width = options.shouldApplyCssTransforms
|
|
25
|
-
? newSize[0].width
|
|
26
|
-
: newSize[0].width * (1 / probableCssParentScale);
|
|
27
|
-
const height = options.shouldApplyCssTransforms
|
|
28
|
-
? newSize[0].height
|
|
29
|
-
: newSize[0].height * (1 / probableCssParentScale);
|
|
30
|
-
setSize({
|
|
31
|
-
width,
|
|
32
|
-
height,
|
|
33
|
-
left: newSize[0].x,
|
|
34
|
-
top: newSize[0].y,
|
|
35
|
-
windowSize: {
|
|
36
|
-
height: window.innerHeight,
|
|
37
|
-
width: window.innerWidth,
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
}, [options.shouldApplyCssTransforms]);
|
|
42
|
-
const updateSize = useCallback(() => {
|
|
43
|
-
if (!ref.current) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const rect = ref.current.getClientRects();
|
|
47
|
-
if (!rect[0]) {
|
|
48
|
-
setSize(null);
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
setSize({
|
|
52
|
-
width: rect[0].width,
|
|
53
|
-
height: rect[0].height,
|
|
54
|
-
left: rect[0].x,
|
|
55
|
-
top: rect[0].y,
|
|
56
|
-
windowSize: {
|
|
57
|
-
height: window.innerHeight,
|
|
58
|
-
width: window.innerWidth,
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
}, [ref]);
|
|
62
|
-
useEffect(() => {
|
|
63
|
-
if (!observer) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
updateSize();
|
|
67
|
-
const { current } = ref;
|
|
68
|
-
if (ref.current) {
|
|
69
|
-
observer.observe(ref.current);
|
|
70
|
-
}
|
|
71
|
-
return () => {
|
|
72
|
-
if (current) {
|
|
73
|
-
observer.unobserve(current);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
}, [observer, ref, updateSize]);
|
|
77
|
-
useEffect(() => {
|
|
78
|
-
if (!options.triggerOnWindowResize) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
window.addEventListener('resize', updateSize);
|
|
82
|
-
return () => {
|
|
83
|
-
window.removeEventListener('resize', updateSize);
|
|
84
|
-
};
|
|
85
|
-
}, [options.triggerOnWindowResize, updateSize]);
|
|
86
|
-
useEffect(() => {
|
|
87
|
-
elementSizeHooks.push(updateSize);
|
|
88
|
-
return () => {
|
|
89
|
-
elementSizeHooks = elementSizeHooks.filter((e) => e !== updateSize);
|
|
90
|
-
};
|
|
91
|
-
}, [updateSize]);
|
|
92
|
-
return size ? { ...size, refresh: updateSize } : null;
|
|
93
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
export const validateSingleFrame = (frame, variableName) => {
|
|
2
|
-
if (typeof frame === 'undefined' || frame === null) {
|
|
3
|
-
return frame !== null && frame !== void 0 ? frame : null;
|
|
4
|
-
}
|
|
5
|
-
if (typeof frame !== 'number') {
|
|
6
|
-
throw new TypeError(`"${variableName}" must be a number, but is ${JSON.stringify(frame)}`);
|
|
7
|
-
}
|
|
8
|
-
if (Number.isNaN(frame)) {
|
|
9
|
-
throw new TypeError(`"${variableName}" must not be NaN, but is ${JSON.stringify(frame)}`);
|
|
10
|
-
}
|
|
11
|
-
if (!Number.isFinite(frame)) {
|
|
12
|
-
throw new TypeError(`"${variableName}" must be finite, but is ${JSON.stringify(frame)}`);
|
|
13
|
-
}
|
|
14
|
-
if (frame % 1 !== 0) {
|
|
15
|
-
throw new TypeError(`"${variableName}" must be an integer, but is ${JSON.stringify(frame)}`);
|
|
16
|
-
}
|
|
17
|
-
return frame;
|
|
18
|
-
};
|
|
19
|
-
export const validateInOutFrames = ({ inFrame, durationInFrames, outFrame, }) => {
|
|
20
|
-
const validatedInFrame = validateSingleFrame(inFrame, 'inFrame');
|
|
21
|
-
const validatedOutFrame = validateSingleFrame(outFrame, 'outFrame');
|
|
22
|
-
if (validatedInFrame === null && validatedOutFrame === null) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
// Must not be over the duration
|
|
26
|
-
if (validatedInFrame !== null && validatedInFrame > durationInFrames - 1) {
|
|
27
|
-
throw new Error('inFrame must be less than (durationInFrames - 1), but is ' +
|
|
28
|
-
validatedInFrame);
|
|
29
|
-
}
|
|
30
|
-
if (validatedOutFrame !== null && validatedOutFrame > durationInFrames - 1) {
|
|
31
|
-
throw new Error('outFrame must be less than (durationInFrames - 1), but is ' +
|
|
32
|
-
validatedOutFrame);
|
|
33
|
-
}
|
|
34
|
-
// Must not be under 0
|
|
35
|
-
if (validatedInFrame !== null && validatedInFrame < 0) {
|
|
36
|
-
throw new Error('inFrame must be greater than 0, but is ' + validatedInFrame);
|
|
37
|
-
}
|
|
38
|
-
if (validatedOutFrame !== null && validatedOutFrame <= 0) {
|
|
39
|
-
throw new Error(`outFrame must be greater than 0, but is ${validatedOutFrame}. If you want to render a single frame, use <Thumbnail /> instead.`);
|
|
40
|
-
}
|
|
41
|
-
if (validatedOutFrame !== null &&
|
|
42
|
-
validatedInFrame !== null &&
|
|
43
|
-
validatedOutFrame <= validatedInFrame) {
|
|
44
|
-
throw new Error('outFrame must be greater than inFrame, but is ' +
|
|
45
|
-
validatedOutFrame +
|
|
46
|
-
' <= ' +
|
|
47
|
-
validatedInFrame);
|
|
48
|
-
}
|
|
49
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export const validateInitialFrame = ({ initialFrame, durationInFrames, }) => {
|
|
2
|
-
if (typeof durationInFrames !== 'number') {
|
|
3
|
-
throw new Error(`\`durationInFrames\` must be a number, but is ${JSON.stringify(durationInFrames)}`);
|
|
4
|
-
}
|
|
5
|
-
if (typeof initialFrame === 'undefined') {
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
if (typeof initialFrame !== 'number') {
|
|
9
|
-
throw new Error(`\`initialFrame\` must be a number, but is ${JSON.stringify(initialFrame)}`);
|
|
10
|
-
}
|
|
11
|
-
if (Number.isNaN(initialFrame)) {
|
|
12
|
-
throw new Error(`\`initialFrame\` must be a number, but is NaN`);
|
|
13
|
-
}
|
|
14
|
-
if (!Number.isFinite(initialFrame)) {
|
|
15
|
-
throw new Error(`\`initialFrame\` must be a number, but is Infinity`);
|
|
16
|
-
}
|
|
17
|
-
if (initialFrame % 1 !== 0) {
|
|
18
|
-
throw new Error(`\`initialFrame\` must be an integer, but is ${JSON.stringify(initialFrame)}`);
|
|
19
|
-
}
|
|
20
|
-
if (initialFrame > durationInFrames - 1) {
|
|
21
|
-
throw new Error(`\`initialFrame\` must be less or equal than \`durationInFrames - 1\`, but is ${JSON.stringify(initialFrame)}`);
|
|
22
|
-
}
|
|
23
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export const validatePlaybackRate = (playbackRate) => {
|
|
2
|
-
if (playbackRate === undefined) {
|
|
3
|
-
return;
|
|
4
|
-
}
|
|
5
|
-
if (playbackRate > 4) {
|
|
6
|
-
throw new Error(`The highest possible playback rate is 4. You passed: ${playbackRate}`);
|
|
7
|
-
}
|
|
8
|
-
if (playbackRate < -4) {
|
|
9
|
-
throw new Error(`The lowest possible playback rate is -4. You passed: ${playbackRate}`);
|
|
10
|
-
}
|
|
11
|
-
if (playbackRate === 0) {
|
|
12
|
-
throw new Error(`A playback rate of 0 is not supported.`);
|
|
13
|
-
}
|
|
14
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const VOLUME_PERSISTANCE_KEY = 'remotion.volumePreference';
|
|
2
|
-
export const persistVolume = (volume) => {
|
|
3
|
-
if (typeof window === 'undefined') {
|
|
4
|
-
return;
|
|
5
|
-
}
|
|
6
|
-
window.localStorage.setItem(VOLUME_PERSISTANCE_KEY, String(volume));
|
|
7
|
-
};
|
|
8
|
-
export const getPreferredVolume = () => {
|
|
9
|
-
if (typeof window === 'undefined') {
|
|
10
|
-
return 1;
|
|
11
|
-
}
|
|
12
|
-
const val = window.localStorage.getItem(VOLUME_PERSISTANCE_KEY);
|
|
13
|
-
return val ? Number(val) : 1;
|
|
14
|
-
};
|