remotion 3.3.80 → 3.3.82
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/cjs/Img.d.ts +3 -1
- package/dist/cjs/Img.js +69 -32
- package/dist/cjs/internals.d.ts +1 -0
- package/dist/cjs/internals.js +2 -0
- package/dist/cjs/static-file.js +14 -0
- package/dist/cjs/use-media-in-timeline.js +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/index.mjs +86 -33
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
package/dist/cjs/Img.d.ts
CHANGED
|
@@ -3,4 +3,6 @@ import React from 'react';
|
|
|
3
3
|
* @description Works just like a regular HTML img tag. When you use the <Img> tag, Remotion will ensure that the image is loaded before rendering the frame.
|
|
4
4
|
* @see [Documentation](https://www.remotion.dev/docs/img)
|
|
5
5
|
*/
|
|
6
|
-
export declare const Img: React.ForwardRefExoticComponent<Pick<React.
|
|
6
|
+
export declare const Img: React.ForwardRefExoticComponent<Pick<React.ClassAttributes<HTMLImageElement> & React.ImgHTMLAttributes<HTMLImageElement> & {
|
|
7
|
+
maxRetries?: number | undefined;
|
|
8
|
+
}, "key" | "maxRetries" | keyof React.ImgHTMLAttributes<HTMLImageElement>> & React.RefAttributes<HTMLImageElement>>;
|
package/dist/cjs/Img.js
CHANGED
|
@@ -4,49 +4,86 @@ exports.Img = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const delay_render_js_1 = require("./delay-render.js");
|
|
7
|
-
const get_environment_js_1 = require("./get-environment.js");
|
|
8
7
|
const prefetch_js_1 = require("./prefetch.js");
|
|
9
|
-
|
|
8
|
+
function exponentialBackoff(errorCount) {
|
|
9
|
+
return 1000 * 2 ** (errorCount - 1);
|
|
10
|
+
}
|
|
11
|
+
const ImgRefForwarding = ({ onError, maxRetries = 2, src, ...props }, ref) => {
|
|
10
12
|
const imageRef = (0, react_1.useRef)(null);
|
|
11
|
-
const
|
|
13
|
+
const errors = (0, react_1.useRef)({});
|
|
12
14
|
(0, react_1.useImperativeHandle)(ref, () => {
|
|
13
15
|
return imageRef.current;
|
|
14
16
|
}, []);
|
|
15
17
|
const actualSrc = (0, prefetch_js_1.usePreload)(src);
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
onError(e);
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
console.error('Error loading image with src:', (_a = imageRef.current) === null || _a === void 0 ? void 0 : _a.src, e, 'Handle the event using the onError() prop to make this message disappear.');
|
|
18
|
+
const retryIn = (0, react_1.useCallback)((timeout) => {
|
|
19
|
+
if (!imageRef.current) {
|
|
20
|
+
return;
|
|
23
21
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (process.env.NODE_ENV === 'test') {
|
|
22
|
+
const currentSrc = imageRef.current.src;
|
|
23
|
+
setTimeout(() => {
|
|
24
|
+
var _a;
|
|
25
|
+
if (!imageRef.current) {
|
|
26
|
+
// Component has been unmounted, do not retry
|
|
30
27
|
return;
|
|
31
28
|
}
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
};
|
|
37
|
-
if (current === null || current === void 0 ? void 0 : current.complete) {
|
|
38
|
-
(0, delay_render_js_1.continueRender)(newHandle);
|
|
29
|
+
const newSrc = (_a = imageRef.current) === null || _a === void 0 ? void 0 : _a.src;
|
|
30
|
+
if (newSrc !== currentSrc) {
|
|
31
|
+
// src has changed, do not retry
|
|
32
|
+
return;
|
|
39
33
|
}
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
imageRef.current.removeAttribute('src');
|
|
35
|
+
imageRef.current.setAttribute('src', newSrc);
|
|
36
|
+
}, timeout);
|
|
37
|
+
}, []);
|
|
38
|
+
const didGetError = (0, react_1.useCallback)((e) => {
|
|
39
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
40
|
+
if (!errors.current) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
errors.current[(_a = imageRef.current) === null || _a === void 0 ? void 0 : _a.src] =
|
|
44
|
+
((_c = errors.current[(_b = imageRef.current) === null || _b === void 0 ? void 0 : _b.src]) !== null && _c !== void 0 ? _c : 0) + 1;
|
|
45
|
+
if (onError &&
|
|
46
|
+
((_e = errors.current[(_d = imageRef.current) === null || _d === void 0 ? void 0 : _d.src]) !== null && _e !== void 0 ? _e : 0) > maxRetries) {
|
|
47
|
+
onError(e);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (((_g = errors.current[(_f = imageRef.current) === null || _f === void 0 ? void 0 : _f.src]) !== null && _g !== void 0 ? _g : 0) <= maxRetries) {
|
|
51
|
+
const backoff = exponentialBackoff((_j = errors.current[(_h = imageRef.current) === null || _h === void 0 ? void 0 : _h.src]) !== null && _j !== void 0 ? _j : 0);
|
|
52
|
+
console.warn(`Could not load image with source ${(_k = imageRef.current) === null || _k === void 0 ? void 0 : _k.src}, retrying again in ${backoff}ms`);
|
|
53
|
+
retryIn(backoff);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
console.error('Error loading image with src:', (_l = imageRef.current) === null || _l === void 0 ? void 0 : _l.src, e, 'Handle the event using the onError() prop to make this message disappear.');
|
|
57
|
+
}, [maxRetries, onError, retryIn]);
|
|
58
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
59
|
+
if (process.env.NODE_ENV === 'test') {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const newHandle = (0, delay_render_js_1.delayRender)('Loading <Img> with src=' + src);
|
|
63
|
+
const { current } = imageRef;
|
|
64
|
+
const onComplete = () => {
|
|
65
|
+
var _a, _b, _c, _d;
|
|
66
|
+
if (((_b = errors.current[(_a = imageRef.current) === null || _a === void 0 ? void 0 : _a.src]) !== null && _b !== void 0 ? _b : 0) > 0) {
|
|
67
|
+
delete errors.current[(_c = imageRef.current) === null || _c === void 0 ? void 0 : _c.src];
|
|
68
|
+
console.info(`Retry successful - ${(_d = imageRef.current) === null || _d === void 0 ? void 0 : _d.src} is now loaded`);
|
|
42
69
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
70
|
+
(0, delay_render_js_1.continueRender)(newHandle);
|
|
71
|
+
};
|
|
72
|
+
const didLoad = () => {
|
|
73
|
+
onComplete();
|
|
74
|
+
};
|
|
75
|
+
if (current === null || current === void 0 ? void 0 : current.complete) {
|
|
76
|
+
onComplete();
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
current === null || current === void 0 ? void 0 : current.addEventListener('load', didLoad, { once: true });
|
|
80
|
+
}
|
|
81
|
+
// If tag gets unmounted, clear pending handles because image is not going to load
|
|
82
|
+
return () => {
|
|
83
|
+
current === null || current === void 0 ? void 0 : current.removeEventListener('load', didLoad);
|
|
84
|
+
(0, delay_render_js_1.continueRender)(newHandle);
|
|
85
|
+
};
|
|
86
|
+
}, [src]);
|
|
50
87
|
return ((0, jsx_runtime_1.jsx)("img", { ...props, ref: imageRef, src: actualSrc, onError: didGetError }));
|
|
51
88
|
};
|
|
52
89
|
/**
|
package/dist/cjs/internals.d.ts
CHANGED
|
@@ -103,5 +103,6 @@ export declare const Internals: {
|
|
|
103
103
|
durationInFrames: number;
|
|
104
104
|
allowFloats: boolean;
|
|
105
105
|
}) => void;
|
|
106
|
+
usePreload: (src: string) => string;
|
|
106
107
|
};
|
|
107
108
|
export type { TComposition, Timeline, TCompMetadata, TSequence, TAsset, TimelineContextValue, SetTimelineContextValue, CompProps, CompositionManagerContext, MediaVolumeContextValue, SetMediaVolumeContextValue, RemotionEnvironment, };
|
package/dist/cjs/internals.js
CHANGED
|
@@ -35,6 +35,7 @@ const get_preview_dom_element_js_1 = require("./get-preview-dom-element.js");
|
|
|
35
35
|
const is_player_js_1 = require("./is-player.js");
|
|
36
36
|
const portal_node_js_1 = require("./portal-node.js");
|
|
37
37
|
const prefetch_state_js_1 = require("./prefetch-state.js");
|
|
38
|
+
const prefetch_js_1 = require("./prefetch.js");
|
|
38
39
|
const register_root_js_1 = require("./register-root.js");
|
|
39
40
|
const RemotionRoot_js_1 = require("./RemotionRoot.js");
|
|
40
41
|
const SequenceContext_js_1 = require("./SequenceContext.js");
|
|
@@ -98,4 +99,5 @@ exports.Internals = {
|
|
|
98
99
|
useIsPlayer: is_player_js_1.useIsPlayer,
|
|
99
100
|
useRemotionEnvironment: get_environment_js_1.useRemotionEnvironment,
|
|
100
101
|
validateFrame: validate_frame_js_1.validateFrame,
|
|
102
|
+
usePreload: prefetch_js_1.usePreload,
|
|
101
103
|
};
|
package/dist/cjs/static-file.js
CHANGED
|
@@ -24,6 +24,20 @@ const staticFile = (path) => {
|
|
|
24
24
|
if (path.startsWith('..') || path.startsWith('./')) {
|
|
25
25
|
throw new TypeError(`staticFile() does not support relative paths - got "${path}". Instead, pass the name of a file that is inside the public/ folder. See: https://remotion.dev/docs/staticfile-relative-paths`);
|
|
26
26
|
}
|
|
27
|
+
if (path.startsWith('/Users') ||
|
|
28
|
+
path.startsWith('/home') ||
|
|
29
|
+
path.startsWith('/tmp') ||
|
|
30
|
+
path.startsWith('/etc') ||
|
|
31
|
+
path.startsWith('/opt') ||
|
|
32
|
+
path.startsWith('/var') ||
|
|
33
|
+
path.startsWith('C:') ||
|
|
34
|
+
path.startsWith('D:') ||
|
|
35
|
+
path.startsWith('E:')) {
|
|
36
|
+
throw new TypeError(`staticFile() does not support absolute paths - got "${path}". Instead, pass the name of a file that is inside the public/ folder. See: https://remotion.dev/docs/staticfile-relative-paths`);
|
|
37
|
+
}
|
|
38
|
+
if (path.startsWith('public/')) {
|
|
39
|
+
throw new TypeError(`Do not include the public/ prefix when using staticFile() - got "${path}". See: https://remotion.dev/docs/staticfile-relative-paths`);
|
|
40
|
+
}
|
|
27
41
|
const preparsed = inner(path);
|
|
28
42
|
if (!preparsed.startsWith('/')) {
|
|
29
43
|
return `/${preparsed}`;
|
|
@@ -42,7 +42,7 @@ const useMediaInTimeline = ({ volume, mediaVolume, mediaRef, src, mediaType, pla
|
|
|
42
42
|
if (typeof volume === 'number') {
|
|
43
43
|
return volume;
|
|
44
44
|
}
|
|
45
|
-
return new Array(Math.max(0, duration + startsAt))
|
|
45
|
+
return new Array(Math.floor(Math.max(0, duration + startsAt)))
|
|
46
46
|
.fill(true)
|
|
47
47
|
.map((_, i) => {
|
|
48
48
|
return (0, volume_prop_js_1.evaluateVolume)({
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "3.3.
|
|
1
|
+
export declare const VERSION = "3.3.82";
|
package/dist/cjs/version.js
CHANGED
package/dist/esm/index.mjs
CHANGED
|
@@ -58,7 +58,7 @@ function truthy(value) {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
// Automatically generated on publish
|
|
61
|
-
const VERSION = '3.3.
|
|
61
|
+
const VERSION = '3.3.82';
|
|
62
62
|
|
|
63
63
|
const checkMultipleRemotionVersions = () => {
|
|
64
64
|
if (typeof globalThis === 'undefined') {
|
|
@@ -988,7 +988,7 @@ const useMediaInTimeline = ({ volume, mediaVolume, mediaRef, src, mediaType, pla
|
|
|
988
988
|
if (typeof volume === 'number') {
|
|
989
989
|
return volume;
|
|
990
990
|
}
|
|
991
|
-
return new Array(Math.max(0, duration + startsAt))
|
|
991
|
+
return new Array(Math.floor(Math.max(0, duration + startsAt)))
|
|
992
992
|
.fill(true)
|
|
993
993
|
.map((_, i) => {
|
|
994
994
|
return evaluateVolume({
|
|
@@ -2387,6 +2387,7 @@ const Internals = {
|
|
|
2387
2387
|
useIsPlayer,
|
|
2388
2388
|
useRemotionEnvironment,
|
|
2389
2389
|
validateFrame,
|
|
2390
|
+
usePreload,
|
|
2390
2391
|
};
|
|
2391
2392
|
|
|
2392
2393
|
const rotate = {
|
|
@@ -2789,47 +2790,85 @@ const IFrameRefForwarding = ({ onLoad, onError, ...props }, ref) => {
|
|
|
2789
2790
|
*/
|
|
2790
2791
|
const IFrame = forwardRef(IFrameRefForwarding);
|
|
2791
2792
|
|
|
2792
|
-
|
|
2793
|
+
function exponentialBackoff(errorCount) {
|
|
2794
|
+
return 1000 * 2 ** (errorCount - 1);
|
|
2795
|
+
}
|
|
2796
|
+
const ImgRefForwarding = ({ onError, maxRetries = 2, src, ...props }, ref) => {
|
|
2793
2797
|
const imageRef = useRef(null);
|
|
2794
|
-
const
|
|
2798
|
+
const errors = useRef({});
|
|
2795
2799
|
useImperativeHandle(ref, () => {
|
|
2796
2800
|
return imageRef.current;
|
|
2797
2801
|
}, []);
|
|
2798
2802
|
const actualSrc = usePreload(src);
|
|
2799
|
-
const
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
onError(e);
|
|
2803
|
-
}
|
|
2804
|
-
else {
|
|
2805
|
-
console.error('Error loading image with src:', (_a = imageRef.current) === null || _a === void 0 ? void 0 : _a.src, e, 'Handle the event using the onError() prop to make this message disappear.');
|
|
2803
|
+
const retryIn = useCallback((timeout) => {
|
|
2804
|
+
if (!imageRef.current) {
|
|
2805
|
+
return;
|
|
2806
2806
|
}
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
if (process.env.NODE_ENV === 'test') {
|
|
2807
|
+
const currentSrc = imageRef.current.src;
|
|
2808
|
+
setTimeout(() => {
|
|
2809
|
+
var _a;
|
|
2810
|
+
if (!imageRef.current) {
|
|
2811
|
+
// Component has been unmounted, do not retry
|
|
2813
2812
|
return;
|
|
2814
2813
|
}
|
|
2815
|
-
const
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
};
|
|
2820
|
-
if (current === null || current === void 0 ? void 0 : current.complete) {
|
|
2821
|
-
continueRender(newHandle);
|
|
2814
|
+
const newSrc = (_a = imageRef.current) === null || _a === void 0 ? void 0 : _a.src;
|
|
2815
|
+
if (newSrc !== currentSrc) {
|
|
2816
|
+
// src has changed, do not retry
|
|
2817
|
+
return;
|
|
2822
2818
|
}
|
|
2823
|
-
|
|
2824
|
-
|
|
2819
|
+
imageRef.current.removeAttribute('src');
|
|
2820
|
+
imageRef.current.setAttribute('src', newSrc);
|
|
2821
|
+
}, timeout);
|
|
2822
|
+
}, []);
|
|
2823
|
+
const didGetError = useCallback((e) => {
|
|
2824
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
2825
|
+
if (!errors.current) {
|
|
2826
|
+
return;
|
|
2827
|
+
}
|
|
2828
|
+
errors.current[(_a = imageRef.current) === null || _a === void 0 ? void 0 : _a.src] =
|
|
2829
|
+
((_c = errors.current[(_b = imageRef.current) === null || _b === void 0 ? void 0 : _b.src]) !== null && _c !== void 0 ? _c : 0) + 1;
|
|
2830
|
+
if (onError &&
|
|
2831
|
+
((_e = errors.current[(_d = imageRef.current) === null || _d === void 0 ? void 0 : _d.src]) !== null && _e !== void 0 ? _e : 0) > maxRetries) {
|
|
2832
|
+
onError(e);
|
|
2833
|
+
return;
|
|
2834
|
+
}
|
|
2835
|
+
if (((_g = errors.current[(_f = imageRef.current) === null || _f === void 0 ? void 0 : _f.src]) !== null && _g !== void 0 ? _g : 0) <= maxRetries) {
|
|
2836
|
+
const backoff = exponentialBackoff((_j = errors.current[(_h = imageRef.current) === null || _h === void 0 ? void 0 : _h.src]) !== null && _j !== void 0 ? _j : 0);
|
|
2837
|
+
console.warn(`Could not load image with source ${(_k = imageRef.current) === null || _k === void 0 ? void 0 : _k.src}, retrying again in ${backoff}ms`);
|
|
2838
|
+
retryIn(backoff);
|
|
2839
|
+
return;
|
|
2840
|
+
}
|
|
2841
|
+
console.error('Error loading image with src:', (_l = imageRef.current) === null || _l === void 0 ? void 0 : _l.src, e, 'Handle the event using the onError() prop to make this message disappear.');
|
|
2842
|
+
}, [maxRetries, onError, retryIn]);
|
|
2843
|
+
useLayoutEffect(() => {
|
|
2844
|
+
if (process.env.NODE_ENV === 'test') {
|
|
2845
|
+
return;
|
|
2846
|
+
}
|
|
2847
|
+
const newHandle = delayRender('Loading <Img> with src=' + src);
|
|
2848
|
+
const { current } = imageRef;
|
|
2849
|
+
const onComplete = () => {
|
|
2850
|
+
var _a, _b, _c, _d;
|
|
2851
|
+
if (((_b = errors.current[(_a = imageRef.current) === null || _a === void 0 ? void 0 : _a.src]) !== null && _b !== void 0 ? _b : 0) > 0) {
|
|
2852
|
+
delete errors.current[(_c = imageRef.current) === null || _c === void 0 ? void 0 : _c.src];
|
|
2853
|
+
console.info(`Retry successful - ${(_d = imageRef.current) === null || _d === void 0 ? void 0 : _d.src} is now loaded`);
|
|
2825
2854
|
}
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2855
|
+
continueRender(newHandle);
|
|
2856
|
+
};
|
|
2857
|
+
const didLoad = () => {
|
|
2858
|
+
onComplete();
|
|
2859
|
+
};
|
|
2860
|
+
if (current === null || current === void 0 ? void 0 : current.complete) {
|
|
2861
|
+
onComplete();
|
|
2862
|
+
}
|
|
2863
|
+
else {
|
|
2864
|
+
current === null || current === void 0 ? void 0 : current.addEventListener('load', didLoad, { once: true });
|
|
2865
|
+
}
|
|
2866
|
+
// If tag gets unmounted, clear pending handles because image is not going to load
|
|
2867
|
+
return () => {
|
|
2868
|
+
current === null || current === void 0 ? void 0 : current.removeEventListener('load', didLoad);
|
|
2869
|
+
continueRender(newHandle);
|
|
2870
|
+
};
|
|
2871
|
+
}, [src]);
|
|
2833
2872
|
return (jsx("img", { ...props, ref: imageRef, src: actualSrc, onError: didGetError }));
|
|
2834
2873
|
};
|
|
2835
2874
|
/**
|
|
@@ -3560,6 +3599,20 @@ const staticFile = (path) => {
|
|
|
3560
3599
|
if (path.startsWith('..') || path.startsWith('./')) {
|
|
3561
3600
|
throw new TypeError(`staticFile() does not support relative paths - got "${path}". Instead, pass the name of a file that is inside the public/ folder. See: https://remotion.dev/docs/staticfile-relative-paths`);
|
|
3562
3601
|
}
|
|
3602
|
+
if (path.startsWith('/Users') ||
|
|
3603
|
+
path.startsWith('/home') ||
|
|
3604
|
+
path.startsWith('/tmp') ||
|
|
3605
|
+
path.startsWith('/etc') ||
|
|
3606
|
+
path.startsWith('/opt') ||
|
|
3607
|
+
path.startsWith('/var') ||
|
|
3608
|
+
path.startsWith('C:') ||
|
|
3609
|
+
path.startsWith('D:') ||
|
|
3610
|
+
path.startsWith('E:')) {
|
|
3611
|
+
throw new TypeError(`staticFile() does not support absolute paths - got "${path}". Instead, pass the name of a file that is inside the public/ folder. See: https://remotion.dev/docs/staticfile-relative-paths`);
|
|
3612
|
+
}
|
|
3613
|
+
if (path.startsWith('public/')) {
|
|
3614
|
+
throw new TypeError(`Do not include the public/ prefix when using staticFile() - got "${path}". See: https://remotion.dev/docs/staticfile-relative-paths`);
|
|
3615
|
+
}
|
|
3563
3616
|
const preparsed = inner(path);
|
|
3564
3617
|
if (!preparsed.startsWith('/')) {
|
|
3565
3618
|
return `/${preparsed}`;
|
package/dist/esm/version.mjs
CHANGED