remotion 4.0.344 → 4.0.346
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/Composition.js +5 -4
- package/dist/cjs/IFrame.js +7 -6
- package/dist/cjs/Img.js +8 -5
- package/dist/cjs/RemotionRoot.js +6 -5
- package/dist/cjs/animated-image/AnimatedImage.js +25 -10
- package/dist/cjs/audio/AudioForRendering.js +8 -5
- package/dist/cjs/get-remotion-environment.d.ts +3 -0
- package/dist/cjs/get-remotion-environment.js +7 -1
- package/dist/cjs/internals.d.ts +1 -0
- package/dist/cjs/internals.js +1 -0
- package/dist/cjs/use-remotion-environment.js +2 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/video/OffthreadVideoForRendering.js +8 -5
- package/dist/cjs/video/VideoForRendering.js +23 -13
- package/dist/cjs/video/use-audio-channel-index.d.ts +4 -0
- package/dist/cjs/video/use-audio-channel-index.js +13 -0
- package/dist/esm/index.mjs +286 -241
- package/dist/esm/no-react.mjs +4 -0
- package/dist/esm/version.mjs +1 -1
- package/package.json +2 -2
package/dist/cjs/Composition.js
CHANGED
|
@@ -8,22 +8,23 @@ const CanUseRemotionHooks_js_1 = require("./CanUseRemotionHooks.js");
|
|
|
8
8
|
const CompositionManagerContext_js_1 = require("./CompositionManagerContext.js");
|
|
9
9
|
const Folder_js_1 = require("./Folder.js");
|
|
10
10
|
const ResolveCompositionConfig_js_1 = require("./ResolveCompositionConfig.js");
|
|
11
|
-
const delay_render_js_1 = require("./delay-render.js");
|
|
12
11
|
const input_props_serialization_js_1 = require("./input-props-serialization.js");
|
|
13
12
|
const is_player_js_1 = require("./is-player.js");
|
|
14
13
|
const loading_indicator_js_1 = require("./loading-indicator.js");
|
|
15
14
|
const nonce_js_1 = require("./nonce.js");
|
|
16
15
|
const portal_node_js_1 = require("./portal-node.js");
|
|
16
|
+
const use_delay_render_js_1 = require("./use-delay-render.js");
|
|
17
17
|
const use_lazy_component_js_1 = require("./use-lazy-component.js");
|
|
18
18
|
const use_remotion_environment_js_1 = require("./use-remotion-environment.js");
|
|
19
19
|
const use_video_js_1 = require("./use-video.js");
|
|
20
20
|
const validate_composition_id_js_1 = require("./validation/validate-composition-id.js");
|
|
21
21
|
const validate_default_props_js_1 = require("./validation/validate-default-props.js");
|
|
22
22
|
const Fallback = () => {
|
|
23
|
+
const { continueRender, delayRender } = (0, use_delay_render_js_1.useDelayRender)();
|
|
23
24
|
(0, react_1.useEffect)(() => {
|
|
24
|
-
const fallback =
|
|
25
|
-
return () =>
|
|
26
|
-
}, []);
|
|
25
|
+
const fallback = delayRender('Waiting for Root component to unsuspend');
|
|
26
|
+
return () => continueRender(fallback);
|
|
27
|
+
}, [continueRender, delayRender]);
|
|
27
28
|
return null;
|
|
28
29
|
};
|
|
29
30
|
const InnerComposition = ({ width, height, fps, durationInFrames, id, defaultProps, schema, ...compProps }) => {
|
package/dist/cjs/IFrame.js
CHANGED
|
@@ -3,18 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.IFrame = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
-
const
|
|
6
|
+
const use_delay_render_js_1 = require("./use-delay-render.js");
|
|
7
7
|
const IFrameRefForwarding = ({ onLoad, onError, delayRenderRetries, delayRenderTimeoutInMilliseconds, ...props }, ref) => {
|
|
8
|
-
const
|
|
8
|
+
const { delayRender, continueRender } = (0, use_delay_render_js_1.useDelayRender)();
|
|
9
|
+
const [handle] = (0, react_1.useState)(() => delayRender(`Loading <IFrame> with source ${props.src}`, {
|
|
9
10
|
retries: delayRenderRetries !== null && delayRenderRetries !== void 0 ? delayRenderRetries : undefined,
|
|
10
11
|
timeoutInMilliseconds: delayRenderTimeoutInMilliseconds !== null && delayRenderTimeoutInMilliseconds !== void 0 ? delayRenderTimeoutInMilliseconds : undefined,
|
|
11
12
|
}));
|
|
12
13
|
const didLoad = (0, react_1.useCallback)((e) => {
|
|
13
|
-
|
|
14
|
+
continueRender(handle);
|
|
14
15
|
onLoad === null || onLoad === void 0 ? void 0 : onLoad(e);
|
|
15
|
-
}, [handle, onLoad]);
|
|
16
|
+
}, [handle, onLoad, continueRender]);
|
|
16
17
|
const didGetError = (0, react_1.useCallback)((e) => {
|
|
17
|
-
|
|
18
|
+
continueRender(handle);
|
|
18
19
|
if (onError) {
|
|
19
20
|
onError(e);
|
|
20
21
|
}
|
|
@@ -22,7 +23,7 @@ const IFrameRefForwarding = ({ onLoad, onError, delayRenderRetries, delayRenderT
|
|
|
22
23
|
// eslint-disable-next-line no-console
|
|
23
24
|
console.error('Error loading iframe:', e, 'Handle the event using the onError() prop to make this message disappear.');
|
|
24
25
|
}
|
|
25
|
-
}, [handle, onError]);
|
|
26
|
+
}, [handle, onError, continueRender]);
|
|
26
27
|
return (0, jsx_runtime_1.jsx)("iframe", { ...props, ref: ref, onError: didGetError, onLoad: didLoad });
|
|
27
28
|
};
|
|
28
29
|
/*
|
package/dist/cjs/Img.js
CHANGED
|
@@ -5,10 +5,10 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const SequenceContext_js_1 = require("./SequenceContext.js");
|
|
7
7
|
const cancel_render_js_1 = require("./cancel-render.js");
|
|
8
|
-
const delay_render_js_1 = require("./delay-render.js");
|
|
9
8
|
const get_cross_origin_value_js_1 = require("./get-cross-origin-value.js");
|
|
10
9
|
const prefetch_js_1 = require("./prefetch.js");
|
|
11
10
|
const use_buffer_state_js_1 = require("./use-buffer-state.js");
|
|
11
|
+
const use_delay_render_js_1 = require("./use-delay-render.js");
|
|
12
12
|
function exponentialBackoff(errorCount) {
|
|
13
13
|
return 1000 * 2 ** (errorCount - 1);
|
|
14
14
|
}
|
|
@@ -69,6 +69,7 @@ const ImgRefForwarding = ({ onError, maxRetries = 2, src, pauseWhenLoading, dela
|
|
|
69
69
|
}
|
|
70
70
|
(0, cancel_render_js_1.cancelRender)('Error loading image with src: ' + ((_l = imageRef.current) === null || _l === void 0 ? void 0 : _l.src));
|
|
71
71
|
}, [maxRetries, onError, retryIn]);
|
|
72
|
+
const { delayRender, continueRender } = (0, use_delay_render_js_1.useDelayRender)();
|
|
72
73
|
if (typeof window !== 'undefined') {
|
|
73
74
|
const isPremounting = Boolean(sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.premounting);
|
|
74
75
|
const isPostmounting = Boolean(sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.postmounting);
|
|
@@ -85,7 +86,7 @@ const ImgRefForwarding = ({ onError, maxRetries = 2, src, pauseWhenLoading, dela
|
|
|
85
86
|
if (!current) {
|
|
86
87
|
return;
|
|
87
88
|
}
|
|
88
|
-
const newHandle =
|
|
89
|
+
const newHandle = delayRender('Loading <Img> with src=' + actualSrc, {
|
|
89
90
|
retries: delayRenderRetries !== null && delayRenderRetries !== void 0 ? delayRenderRetries : undefined,
|
|
90
91
|
timeoutInMilliseconds: delayRenderTimeoutInMilliseconds !== null && delayRenderTimeoutInMilliseconds !== void 0 ? delayRenderTimeoutInMilliseconds : undefined,
|
|
91
92
|
});
|
|
@@ -97,7 +98,7 @@ const ImgRefForwarding = ({ onError, maxRetries = 2, src, pauseWhenLoading, dela
|
|
|
97
98
|
var _a, _b, _c, _d;
|
|
98
99
|
// the decode() promise isn't cancelable -- it may still resolve after unmounting
|
|
99
100
|
if (unmounted) {
|
|
100
|
-
|
|
101
|
+
continueRender(newHandle);
|
|
101
102
|
return;
|
|
102
103
|
}
|
|
103
104
|
if (((_b = errors.current[(_a = imageRef.current) === null || _a === void 0 ? void 0 : _a.src]) !== null && _b !== void 0 ? _b : 0) > 0) {
|
|
@@ -109,7 +110,7 @@ const ImgRefForwarding = ({ onError, maxRetries = 2, src, pauseWhenLoading, dela
|
|
|
109
110
|
onImageFrame === null || onImageFrame === void 0 ? void 0 : onImageFrame(current);
|
|
110
111
|
}
|
|
111
112
|
unblock();
|
|
112
|
-
|
|
113
|
+
continueRender(newHandle);
|
|
113
114
|
};
|
|
114
115
|
if (!imageRef.current) {
|
|
115
116
|
onComplete();
|
|
@@ -140,7 +141,7 @@ const ImgRefForwarding = ({ onError, maxRetries = 2, src, pauseWhenLoading, dela
|
|
|
140
141
|
unmounted = true;
|
|
141
142
|
current.removeEventListener('load', onComplete);
|
|
142
143
|
unblock();
|
|
143
|
-
|
|
144
|
+
continueRender(newHandle);
|
|
144
145
|
};
|
|
145
146
|
}, [
|
|
146
147
|
actualSrc,
|
|
@@ -151,6 +152,8 @@ const ImgRefForwarding = ({ onError, maxRetries = 2, src, pauseWhenLoading, dela
|
|
|
151
152
|
isPremounting,
|
|
152
153
|
isPostmounting,
|
|
153
154
|
onImageFrame,
|
|
155
|
+
continueRender,
|
|
156
|
+
delayRender,
|
|
154
157
|
]);
|
|
155
158
|
}
|
|
156
159
|
const crossOriginValue = (0, get_cross_origin_value_js_1.getCrossOriginValue)({
|
package/dist/cjs/RemotionRoot.js
CHANGED
|
@@ -6,12 +6,12 @@ const react_1 = require("react");
|
|
|
6
6
|
const CompositionManager_js_1 = require("./CompositionManager.js");
|
|
7
7
|
const EditorProps_js_1 = require("./EditorProps.js");
|
|
8
8
|
const buffering_js_1 = require("./buffering.js");
|
|
9
|
-
const delay_render_js_1 = require("./delay-render.js");
|
|
10
9
|
const log_level_context_js_1 = require("./log-level-context.js");
|
|
11
10
|
const nonce_js_1 = require("./nonce.js");
|
|
12
11
|
const prefetch_state_js_1 = require("./prefetch-state.js");
|
|
13
12
|
const random_js_1 = require("./random.js");
|
|
14
13
|
const timeline_position_state_js_1 = require("./timeline-position-state.js");
|
|
14
|
+
const use_delay_render_js_1 = require("./use-delay-render.js");
|
|
15
15
|
const duration_state_js_1 = require("./video/duration-state.js");
|
|
16
16
|
const RemotionRoot = ({ children, numberOfAudioTags, logLevel, onlyRenderComposition, currentCompositionMetadata, audioLatencyHint, }) => {
|
|
17
17
|
const [remotionRootId] = (0, react_1.useState)(() => String((0, random_js_1.random)(null)));
|
|
@@ -22,12 +22,13 @@ const RemotionRoot = ({ children, numberOfAudioTags, logLevel, onlyRenderComposi
|
|
|
22
22
|
const [manualRefreshes, setManualRefreshes] = (0, react_1.useState)(0);
|
|
23
23
|
const [playbackRate, setPlaybackRate] = (0, react_1.useState)(1);
|
|
24
24
|
const audioAndVideoTags = (0, react_1.useRef)([]);
|
|
25
|
+
const { delayRender, continueRender } = (0, use_delay_render_js_1.useDelayRender)();
|
|
25
26
|
if (typeof window !== 'undefined') {
|
|
26
27
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
27
28
|
(0, react_1.useLayoutEffect)(() => {
|
|
28
29
|
window.remotion_setFrame = (f, composition, attempt) => {
|
|
29
30
|
window.remotion_attempt = attempt;
|
|
30
|
-
const id =
|
|
31
|
+
const id = delayRender(`Setting the current frame to ${f}`);
|
|
31
32
|
let asyncUpdate = true;
|
|
32
33
|
setFrame((s) => {
|
|
33
34
|
var _a;
|
|
@@ -44,14 +45,14 @@ const RemotionRoot = ({ children, numberOfAudioTags, logLevel, onlyRenderComposi
|
|
|
44
45
|
});
|
|
45
46
|
// After setting the state, need to wait until it is applied in the next cycle
|
|
46
47
|
if (asyncUpdate) {
|
|
47
|
-
requestAnimationFrame(() =>
|
|
48
|
+
requestAnimationFrame(() => continueRender(id));
|
|
48
49
|
}
|
|
49
50
|
else {
|
|
50
|
-
|
|
51
|
+
continueRender(id);
|
|
51
52
|
}
|
|
52
53
|
};
|
|
53
54
|
window.remotion_isPlayer = false;
|
|
54
|
-
}, []);
|
|
55
|
+
}, [continueRender, delayRender]);
|
|
55
56
|
}
|
|
56
57
|
const timelineContextValue = (0, react_1.useMemo)(() => {
|
|
57
58
|
return {
|
|
@@ -4,8 +4,8 @@ exports.AnimatedImage = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const cancel_render_js_1 = require("../cancel-render.js");
|
|
7
|
-
const delay_render_js_1 = require("../delay-render.js");
|
|
8
7
|
const use_current_frame_js_1 = require("../use-current-frame.js");
|
|
8
|
+
const use_delay_render_js_1 = require("../use-delay-render.js");
|
|
9
9
|
const use_video_config_js_1 = require("../use-video-config.js");
|
|
10
10
|
const canvas_1 = require("./canvas");
|
|
11
11
|
const decode_image_js_1 = require("./decode-image.js");
|
|
@@ -21,7 +21,8 @@ exports.AnimatedImage = (0, react_1.forwardRef)(({ src, width, height, onError,
|
|
|
21
21
|
}, []);
|
|
22
22
|
const resolvedSrc = (0, resolve_image_source_1.resolveAnimatedImageSource)(src);
|
|
23
23
|
const [imageDecoder, setImageDecoder] = (0, react_1.useState)(null);
|
|
24
|
-
const
|
|
24
|
+
const { delayRender, continueRender } = (0, use_delay_render_js_1.useDelayRender)();
|
|
25
|
+
const [decodeHandle] = (0, react_1.useState)(() => delayRender(`Rendering <AnimatedImage/> with src="${resolvedSrc}"`));
|
|
25
26
|
const frame = (0, use_current_frame_js_1.useCurrentFrame)();
|
|
26
27
|
const { fps } = (0, use_video_config_js_1.useVideoConfig)();
|
|
27
28
|
const currentTime = frame / playbackRate / fps;
|
|
@@ -47,16 +48,16 @@ exports.AnimatedImage = (0, react_1.forwardRef)(({ src, width, height, onError,
|
|
|
47
48
|
})
|
|
48
49
|
.then((d) => {
|
|
49
50
|
setImageDecoder(d);
|
|
50
|
-
|
|
51
|
+
continueRender(decodeHandle);
|
|
51
52
|
})
|
|
52
53
|
.catch((err) => {
|
|
53
54
|
if (err.name === 'AbortError') {
|
|
54
|
-
|
|
55
|
+
continueRender(decodeHandle);
|
|
55
56
|
return;
|
|
56
57
|
}
|
|
57
58
|
if (onError) {
|
|
58
59
|
onError === null || onError === void 0 ? void 0 : onError(err);
|
|
59
|
-
|
|
60
|
+
continueRender(decodeHandle);
|
|
60
61
|
}
|
|
61
62
|
else {
|
|
62
63
|
(0, cancel_render_js_1.cancelRender)(err);
|
|
@@ -65,12 +66,18 @@ exports.AnimatedImage = (0, react_1.forwardRef)(({ src, width, height, onError,
|
|
|
65
66
|
return () => {
|
|
66
67
|
controller.abort();
|
|
67
68
|
};
|
|
68
|
-
}, [
|
|
69
|
+
}, [
|
|
70
|
+
resolvedSrc,
|
|
71
|
+
decodeHandle,
|
|
72
|
+
onError,
|
|
73
|
+
initialLoopBehavior,
|
|
74
|
+
continueRender,
|
|
75
|
+
]);
|
|
69
76
|
(0, react_1.useLayoutEffect)(() => {
|
|
70
77
|
if (!imageDecoder) {
|
|
71
78
|
return;
|
|
72
79
|
}
|
|
73
|
-
const delay =
|
|
80
|
+
const delay = delayRender(`Rendering frame at ${currentTime} of <AnimatedImage src="${src}"/>`);
|
|
74
81
|
imageDecoder
|
|
75
82
|
.getFrame(currentTime, loopBehavior)
|
|
76
83
|
.then((videoFrame) => {
|
|
@@ -83,17 +90,25 @@ exports.AnimatedImage = (0, react_1.forwardRef)(({ src, width, height, onError,
|
|
|
83
90
|
(_b = ref.current) === null || _b === void 0 ? void 0 : _b.draw(videoFrame.frame);
|
|
84
91
|
}
|
|
85
92
|
}
|
|
86
|
-
|
|
93
|
+
continueRender(delay);
|
|
87
94
|
})
|
|
88
95
|
.catch((err) => {
|
|
89
96
|
if (onError) {
|
|
90
97
|
onError(err);
|
|
91
|
-
|
|
98
|
+
continueRender(delay);
|
|
92
99
|
}
|
|
93
100
|
else {
|
|
94
101
|
(0, cancel_render_js_1.cancelRender)(err);
|
|
95
102
|
}
|
|
96
103
|
});
|
|
97
|
-
}, [
|
|
104
|
+
}, [
|
|
105
|
+
currentTime,
|
|
106
|
+
imageDecoder,
|
|
107
|
+
loopBehavior,
|
|
108
|
+
onError,
|
|
109
|
+
src,
|
|
110
|
+
continueRender,
|
|
111
|
+
delayRender,
|
|
112
|
+
]);
|
|
98
113
|
return ((0, jsx_runtime_1.jsx)(canvas_1.Canvas, { ref: ref, width: width, height: height, fit: fit, ...props }));
|
|
99
114
|
});
|
|
@@ -6,10 +6,10 @@ const react_1 = require("react");
|
|
|
6
6
|
const RenderAssetManager_js_1 = require("../RenderAssetManager.js");
|
|
7
7
|
const SequenceContext_js_1 = require("../SequenceContext.js");
|
|
8
8
|
const absolute_src_js_1 = require("../absolute-src.js");
|
|
9
|
-
const delay_render_js_1 = require("../delay-render.js");
|
|
10
9
|
const random_js_1 = require("../random.js");
|
|
11
10
|
const timeline_position_state_js_1 = require("../timeline-position-state.js");
|
|
12
11
|
const use_current_frame_js_1 = require("../use-current-frame.js");
|
|
12
|
+
const use_delay_render_js_1 = require("../use-delay-render.js");
|
|
13
13
|
const volume_prop_js_1 = require("../volume-prop.js");
|
|
14
14
|
const use_audio_frame_js_1 = require("./use-audio-frame.js");
|
|
15
15
|
const AudioForRenderingRefForwardingFunction = (props, ref) => {
|
|
@@ -20,6 +20,7 @@ const AudioForRenderingRefForwardingFunction = (props, ref) => {
|
|
|
20
20
|
const frame = (0, use_current_frame_js_1.useCurrentFrame)();
|
|
21
21
|
const sequenceContext = (0, react_1.useContext)(SequenceContext_js_1.SequenceContext);
|
|
22
22
|
const { registerRenderAsset, unregisterRenderAsset } = (0, react_1.useContext)(RenderAssetManager_js_1.RenderAssetManager);
|
|
23
|
+
const { delayRender, continueRender } = (0, use_delay_render_js_1.useDelayRender)();
|
|
23
24
|
// Generate a string that's as unique as possible for this asset
|
|
24
25
|
// but at the same time the same on all threads
|
|
25
26
|
const id = (0, react_1.useMemo)(() => {
|
|
@@ -95,7 +96,7 @@ const AudioForRenderingRefForwardingFunction = (props, ref) => {
|
|
|
95
96
|
if (!needsToRenderAudioTag) {
|
|
96
97
|
return;
|
|
97
98
|
}
|
|
98
|
-
const newHandle =
|
|
99
|
+
const newHandle = delayRender('Loading <Audio> duration with src=' + src, {
|
|
99
100
|
retries: delayRenderRetries !== null && delayRenderRetries !== void 0 ? delayRenderRetries : undefined,
|
|
100
101
|
timeoutInMilliseconds: delayRenderTimeoutInMilliseconds !== null && delayRenderTimeoutInMilliseconds !== void 0 ? delayRenderTimeoutInMilliseconds : undefined,
|
|
101
102
|
});
|
|
@@ -104,11 +105,11 @@ const AudioForRenderingRefForwardingFunction = (props, ref) => {
|
|
|
104
105
|
if (current === null || current === void 0 ? void 0 : current.duration) {
|
|
105
106
|
onDuration(current.src, current.duration);
|
|
106
107
|
}
|
|
107
|
-
|
|
108
|
+
continueRender(newHandle);
|
|
108
109
|
};
|
|
109
110
|
if (current === null || current === void 0 ? void 0 : current.duration) {
|
|
110
111
|
onDuration(current.src, current.duration);
|
|
111
|
-
|
|
112
|
+
continueRender(newHandle);
|
|
112
113
|
}
|
|
113
114
|
else {
|
|
114
115
|
current === null || current === void 0 ? void 0 : current.addEventListener('loadedmetadata', didLoad, { once: true });
|
|
@@ -116,7 +117,7 @@ const AudioForRenderingRefForwardingFunction = (props, ref) => {
|
|
|
116
117
|
// If tag gets unmounted, clear pending handles because video metadata is not going to load
|
|
117
118
|
return () => {
|
|
118
119
|
current === null || current === void 0 ? void 0 : current.removeEventListener('loadedmetadata', didLoad);
|
|
119
|
-
|
|
120
|
+
continueRender(newHandle);
|
|
120
121
|
};
|
|
121
122
|
}, [
|
|
122
123
|
src,
|
|
@@ -124,6 +125,8 @@ const AudioForRenderingRefForwardingFunction = (props, ref) => {
|
|
|
124
125
|
needsToRenderAudioTag,
|
|
125
126
|
delayRenderRetries,
|
|
126
127
|
delayRenderTimeoutInMilliseconds,
|
|
128
|
+
continueRender,
|
|
129
|
+
delayRender,
|
|
127
130
|
]);
|
|
128
131
|
if (!needsToRenderAudioTag) {
|
|
129
132
|
return null;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
export type RemotionEnvironment = {
|
|
2
3
|
isStudio: boolean;
|
|
3
4
|
isRendering: boolean;
|
|
5
|
+
isClientSideRendering: boolean;
|
|
4
6
|
isPlayer: boolean;
|
|
5
7
|
isReadOnlyStudio: boolean;
|
|
6
8
|
};
|
|
7
9
|
export declare const getRemotionEnvironment: () => RemotionEnvironment;
|
|
10
|
+
export declare const RemotionEnvironmentContext: React.Context<RemotionEnvironment | null>;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getRemotionEnvironment = void 0;
|
|
6
|
+
exports.RemotionEnvironmentContext = exports.getRemotionEnvironment = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
4
8
|
// Avoid VITE obfuscation
|
|
5
9
|
function getNodeEnvString() {
|
|
6
10
|
return ['NOD', 'E_EN', 'V'].join('');
|
|
@@ -29,6 +33,8 @@ const getRemotionEnvironment = () => {
|
|
|
29
33
|
isRendering,
|
|
30
34
|
isPlayer,
|
|
31
35
|
isReadOnlyStudio,
|
|
36
|
+
isClientSideRendering: false,
|
|
32
37
|
};
|
|
33
38
|
};
|
|
34
39
|
exports.getRemotionEnvironment = getRemotionEnvironment;
|
|
40
|
+
exports.RemotionEnvironmentContext = react_1.default.createContext(null);
|
package/dist/cjs/internals.d.ts
CHANGED
|
@@ -263,5 +263,6 @@ export declare const Internals: {
|
|
|
263
263
|
selectComposition: (compName: string) => void;
|
|
264
264
|
toggleFolder: (folderName: string, parentName: string | null) => void;
|
|
265
265
|
} | null>;
|
|
266
|
+
readonly RemotionEnvironmentContext: import("react").Context<RemotionEnvironment | null>;
|
|
266
267
|
};
|
|
267
268
|
export type { CompositionManagerContext, CompProps, LoggingContextValue, MediaVolumeContextValue, RemotionEnvironment, SerializedJSONWithCustomFields, SetMediaVolumeContextValue, SetTimelineContextValue, TCompMetadata, TComposition, TimelineContextValue, TRenderAsset, TSequence, WatchRemotionStaticFilesPayload, };
|
package/dist/cjs/internals.js
CHANGED
|
@@ -8,7 +8,8 @@ const get_remotion_environment_1 = require("./get-remotion-environment");
|
|
|
8
8
|
* @see [Documentation](https://remotion.dev/docs/use-remotion-environment)
|
|
9
9
|
*/
|
|
10
10
|
const useRemotionEnvironment = () => {
|
|
11
|
+
const context = (0, react_1.useContext)(get_remotion_environment_1.RemotionEnvironmentContext);
|
|
11
12
|
const [env] = (0, react_1.useState)(() => (0, get_remotion_environment_1.getRemotionEnvironment)());
|
|
12
|
-
return env;
|
|
13
|
+
return context !== null && context !== void 0 ? context : env;
|
|
13
14
|
};
|
|
14
15
|
exports.useRemotionEnvironment = useRemotionEnvironment;
|
package/dist/cjs/version.d.ts
CHANGED
package/dist/cjs/version.js
CHANGED
|
@@ -10,11 +10,11 @@ const absolute_src_js_1 = require("../absolute-src.js");
|
|
|
10
10
|
const use_audio_frame_js_1 = require("../audio/use-audio-frame.js");
|
|
11
11
|
const cancel_render_js_1 = require("../cancel-render.js");
|
|
12
12
|
const default_css_js_1 = require("../default-css.js");
|
|
13
|
-
const delay_render_js_1 = require("../delay-render.js");
|
|
14
13
|
const random_js_1 = require("../random.js");
|
|
15
14
|
const timeline_position_state_js_1 = require("../timeline-position-state.js");
|
|
16
15
|
const truthy_js_1 = require("../truthy.js");
|
|
17
16
|
const use_current_frame_js_1 = require("../use-current-frame.js");
|
|
17
|
+
const use_delay_render_js_1 = require("../use-delay-render.js");
|
|
18
18
|
const use_unsafe_video_config_js_1 = require("../use-unsafe-video-config.js");
|
|
19
19
|
const volume_prop_js_1 = require("../volume-prop.js");
|
|
20
20
|
const get_current_time_js_1 = require("./get-current-time.js");
|
|
@@ -106,6 +106,7 @@ crossOrigin, audioStreamIndex, ...props }) => {
|
|
|
106
106
|
});
|
|
107
107
|
}, [toneMapped, currentTime, src, transparent]);
|
|
108
108
|
const [imageSrc, setImageSrc] = (0, react_1.useState)(null);
|
|
109
|
+
const { delayRender, continueRender } = (0, use_delay_render_js_1.useDelayRender)();
|
|
109
110
|
(0, react_1.useLayoutEffect)(() => {
|
|
110
111
|
if (!window.remotion_videoEnabled) {
|
|
111
112
|
return;
|
|
@@ -113,7 +114,7 @@ crossOrigin, audioStreamIndex, ...props }) => {
|
|
|
113
114
|
const cleanup = [];
|
|
114
115
|
setImageSrc(null);
|
|
115
116
|
const controller = new AbortController();
|
|
116
|
-
const newHandle =
|
|
117
|
+
const newHandle = delayRender(`Fetching ${actualSrc} from server`, {
|
|
117
118
|
retries: delayRenderRetries !== null && delayRenderRetries !== void 0 ? delayRenderRetries : undefined,
|
|
118
119
|
timeoutInMilliseconds: delayRenderTimeoutInMilliseconds !== null && delayRenderTimeoutInMilliseconds !== void 0 ? delayRenderTimeoutInMilliseconds : undefined,
|
|
119
120
|
});
|
|
@@ -144,11 +145,11 @@ crossOrigin, audioStreamIndex, ...props }) => {
|
|
|
144
145
|
catch (err) {
|
|
145
146
|
// If component is unmounted, we should not throw
|
|
146
147
|
if (err.message.includes('aborted')) {
|
|
147
|
-
|
|
148
|
+
continueRender(newHandle);
|
|
148
149
|
return;
|
|
149
150
|
}
|
|
150
151
|
if (controller.signal.aborted) {
|
|
151
|
-
|
|
152
|
+
continueRender(newHandle);
|
|
152
153
|
return;
|
|
153
154
|
}
|
|
154
155
|
if (err.message.includes('Failed to fetch')) {
|
|
@@ -178,6 +179,8 @@ crossOrigin, audioStreamIndex, ...props }) => {
|
|
|
178
179
|
delayRenderRetries,
|
|
179
180
|
delayRenderTimeoutInMilliseconds,
|
|
180
181
|
onError,
|
|
182
|
+
continueRender,
|
|
183
|
+
delayRender,
|
|
181
184
|
]);
|
|
182
185
|
const onErr = (0, react_1.useCallback)(() => {
|
|
183
186
|
if (onError) {
|
|
@@ -200,7 +203,7 @@ crossOrigin, audioStreamIndex, ...props }) => {
|
|
|
200
203
|
if (!imageSrc || !window.remotion_videoEnabled) {
|
|
201
204
|
return null;
|
|
202
205
|
}
|
|
203
|
-
|
|
206
|
+
continueRender(imageSrc.handle);
|
|
204
207
|
return ((0, jsx_runtime_1.jsx)(Img_js_1.Img, { src: imageSrc.src, className: className, delayRenderRetries: delayRenderRetries, delayRenderTimeoutInMilliseconds: delayRenderTimeoutInMilliseconds, onImageFrame: onImageFrame, ...props, onError: onErr }));
|
|
205
208
|
};
|
|
206
209
|
exports.OffthreadVideoForRendering = OffthreadVideoForRendering;
|
|
@@ -7,12 +7,12 @@ const RenderAssetManager_js_1 = require("../RenderAssetManager.js");
|
|
|
7
7
|
const SequenceContext_js_1 = require("../SequenceContext.js");
|
|
8
8
|
const absolute_src_js_1 = require("../absolute-src.js");
|
|
9
9
|
const use_audio_frame_js_1 = require("../audio/use-audio-frame.js");
|
|
10
|
-
const delay_render_js_1 = require("../delay-render.js");
|
|
11
10
|
const is_approximately_the_same_js_1 = require("../is-approximately-the-same.js");
|
|
12
11
|
const log_level_context_js_1 = require("../log-level-context.js");
|
|
13
12
|
const random_js_1 = require("../random.js");
|
|
14
13
|
const timeline_position_state_js_1 = require("../timeline-position-state.js");
|
|
15
14
|
const use_current_frame_js_1 = require("../use-current-frame.js");
|
|
15
|
+
const use_delay_render_js_1 = require("../use-delay-render.js");
|
|
16
16
|
const use_remotion_environment_js_1 = require("../use-remotion-environment.js");
|
|
17
17
|
const use_unsafe_video_config_js_1 = require("../use-unsafe-video-config.js");
|
|
18
18
|
const volume_prop_js_1 = require("../volume-prop.js");
|
|
@@ -29,6 +29,7 @@ const VideoForRenderingForwardFunction = ({ onError, volume: volumeProp, allowAm
|
|
|
29
29
|
const environment = (0, use_remotion_environment_js_1.useRemotionEnvironment)();
|
|
30
30
|
const logLevel = (0, log_level_context_js_1.useLogLevel)();
|
|
31
31
|
const mountTime = (0, log_level_context_js_1.useMountTime)();
|
|
32
|
+
const { delayRender, continueRender } = (0, use_delay_render_js_1.useDelayRender)();
|
|
32
33
|
const { registerRenderAsset, unregisterRenderAsset } = (0, react_1.useContext)(RenderAssetManager_js_1.RenderAssetManager);
|
|
33
34
|
// Generate a string that's as unique as possible for this asset
|
|
34
35
|
// but at the same time the same on all threads
|
|
@@ -108,21 +109,21 @@ const VideoForRenderingForwardFunction = ({ onError, volume: volumeProp, allowAm
|
|
|
108
109
|
startFrom: -mediaStartsAt,
|
|
109
110
|
fps: videoConfig.fps,
|
|
110
111
|
});
|
|
111
|
-
const handle =
|
|
112
|
+
const handle = delayRender(`Rendering <Video /> with src="${props.src}" at time ${currentTime}`, {
|
|
112
113
|
retries: delayRenderRetries !== null && delayRenderRetries !== void 0 ? delayRenderRetries : undefined,
|
|
113
114
|
timeoutInMilliseconds: delayRenderTimeoutInMilliseconds !== null && delayRenderTimeoutInMilliseconds !== void 0 ? delayRenderTimeoutInMilliseconds : undefined,
|
|
114
115
|
});
|
|
115
116
|
if (((_b = (_a = window.process) === null || _a === void 0 ? void 0 : _a.env) === null || _b === void 0 ? void 0 : _b.NODE_ENV) === 'test') {
|
|
116
|
-
|
|
117
|
+
continueRender(handle);
|
|
117
118
|
return;
|
|
118
119
|
}
|
|
119
120
|
if ((0, is_approximately_the_same_js_1.isApproximatelyTheSame)(current.currentTime, currentTime)) {
|
|
120
121
|
if (current.readyState >= 2) {
|
|
121
|
-
|
|
122
|
+
continueRender(handle);
|
|
122
123
|
return;
|
|
123
124
|
}
|
|
124
125
|
const loadedDataHandler = () => {
|
|
125
|
-
|
|
126
|
+
continueRender(handle);
|
|
126
127
|
};
|
|
127
128
|
current.addEventListener('loadeddata', loadedDataHandler, { once: true });
|
|
128
129
|
return () => {
|
|
@@ -130,7 +131,7 @@ const VideoForRenderingForwardFunction = ({ onError, volume: volumeProp, allowAm
|
|
|
130
131
|
};
|
|
131
132
|
}
|
|
132
133
|
const endedHandler = () => {
|
|
133
|
-
|
|
134
|
+
continueRender(handle);
|
|
134
135
|
};
|
|
135
136
|
const seek = (0, seek_until_right_js_1.seekToTimeMultipleUntilRight)({
|
|
136
137
|
element: current,
|
|
@@ -140,7 +141,7 @@ const VideoForRenderingForwardFunction = ({ onError, volume: volumeProp, allowAm
|
|
|
140
141
|
mountTime,
|
|
141
142
|
});
|
|
142
143
|
seek.prom.then(() => {
|
|
143
|
-
|
|
144
|
+
continueRender(handle);
|
|
144
145
|
});
|
|
145
146
|
current.addEventListener('ended', endedHandler, { once: true });
|
|
146
147
|
const errorHandler = () => {
|
|
@@ -164,7 +165,7 @@ const VideoForRenderingForwardFunction = ({ onError, volume: volumeProp, allowAm
|
|
|
164
165
|
seek.cancel();
|
|
165
166
|
current.removeEventListener('ended', endedHandler);
|
|
166
167
|
current.removeEventListener('error', errorHandler);
|
|
167
|
-
|
|
168
|
+
continueRender(handle);
|
|
168
169
|
};
|
|
169
170
|
}, [
|
|
170
171
|
volumePropsFrame,
|
|
@@ -178,6 +179,8 @@ const VideoForRenderingForwardFunction = ({ onError, volume: volumeProp, allowAm
|
|
|
178
179
|
delayRenderTimeoutInMilliseconds,
|
|
179
180
|
logLevel,
|
|
180
181
|
mountTime,
|
|
182
|
+
continueRender,
|
|
183
|
+
delayRender,
|
|
181
184
|
]);
|
|
182
185
|
const { src } = props;
|
|
183
186
|
// If video source switches, make new handle
|
|
@@ -188,7 +191,7 @@ const VideoForRenderingForwardFunction = ({ onError, volume: volumeProp, allowAm
|
|
|
188
191
|
if (((_b = (_a = window.process) === null || _a === void 0 ? void 0 : _a.env) === null || _b === void 0 ? void 0 : _b.NODE_ENV) === 'test') {
|
|
189
192
|
return;
|
|
190
193
|
}
|
|
191
|
-
const newHandle =
|
|
194
|
+
const newHandle = delayRender('Loading <Video> duration with src=' + src, {
|
|
192
195
|
retries: delayRenderRetries !== null && delayRenderRetries !== void 0 ? delayRenderRetries : undefined,
|
|
193
196
|
timeoutInMilliseconds: delayRenderTimeoutInMilliseconds !== null && delayRenderTimeoutInMilliseconds !== void 0 ? delayRenderTimeoutInMilliseconds : undefined,
|
|
194
197
|
});
|
|
@@ -197,11 +200,11 @@ const VideoForRenderingForwardFunction = ({ onError, volume: volumeProp, allowAm
|
|
|
197
200
|
if (current === null || current === void 0 ? void 0 : current.duration) {
|
|
198
201
|
onDuration(src, current.duration);
|
|
199
202
|
}
|
|
200
|
-
|
|
203
|
+
continueRender(newHandle);
|
|
201
204
|
};
|
|
202
205
|
if (current === null || current === void 0 ? void 0 : current.duration) {
|
|
203
206
|
onDuration(src, current.duration);
|
|
204
|
-
|
|
207
|
+
continueRender(newHandle);
|
|
205
208
|
}
|
|
206
209
|
else {
|
|
207
210
|
current === null || current === void 0 ? void 0 : current.addEventListener('loadedmetadata', didLoad, { once: true });
|
|
@@ -209,9 +212,16 @@ const VideoForRenderingForwardFunction = ({ onError, volume: volumeProp, allowAm
|
|
|
209
212
|
// If tag gets unmounted, clear pending handles because video metadata is not going to load
|
|
210
213
|
return () => {
|
|
211
214
|
current === null || current === void 0 ? void 0 : current.removeEventListener('loadedmetadata', didLoad);
|
|
212
|
-
|
|
215
|
+
continueRender(newHandle);
|
|
213
216
|
};
|
|
214
|
-
}, [
|
|
217
|
+
}, [
|
|
218
|
+
src,
|
|
219
|
+
onDuration,
|
|
220
|
+
delayRenderRetries,
|
|
221
|
+
delayRenderTimeoutInMilliseconds,
|
|
222
|
+
continueRender,
|
|
223
|
+
delayRender,
|
|
224
|
+
]);
|
|
215
225
|
}
|
|
216
226
|
return (0, jsx_runtime_1.jsx)("video", { ref: videoRef, disableRemotePlayback: true, ...props });
|
|
217
227
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useAudioChannelIndex = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const useAudioChannelIndex = ({ ref, audioChannelIndex, }) => {
|
|
6
|
+
(0, react_1.useEffect)(() => {
|
|
7
|
+
var _a;
|
|
8
|
+
// @ts-expect-error
|
|
9
|
+
const audioChannels = (_a = ref === null || ref === void 0 ? void 0 : ref.current) === null || _a === void 0 ? void 0 : _a.audioTracks;
|
|
10
|
+
console.log({ audioChannels, audioChannelIndex });
|
|
11
|
+
}, [ref, audioChannelIndex]);
|
|
12
|
+
};
|
|
13
|
+
exports.useAudioChannelIndex = useAudioChannelIndex;
|