remotion 4.0.109 → 4.0.111
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 +1 -0
- package/dist/cjs/Img.js +9 -2
- package/dist/cjs/RemotionRoot.js +2 -1
- package/dist/cjs/Sequence.d.ts +0 -3
- package/dist/cjs/audio/Audio.d.ts +1 -0
- package/dist/cjs/audio/Audio.js +5 -3
- package/dist/cjs/audio/AudioForDevelopment.d.ts +1 -1
- package/dist/cjs/audio/AudioForPreview.d.ts +11 -0
- package/dist/cjs/audio/AudioForPreview.js +119 -0
- package/dist/cjs/audio/AudioForRendering.d.ts +1 -0
- package/dist/cjs/audio/props.d.ts +1 -0
- package/dist/cjs/buffering.d.ts +26 -0
- package/dist/cjs/buffering.js +75 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +5 -1
- package/dist/cjs/internals.d.ts +28 -0
- package/dist/cjs/internals.js +7 -0
- package/dist/cjs/use-buffer-state.d.ts +5 -0
- package/dist/cjs/use-buffer-state.js +20 -0
- package/dist/cjs/use-buffer.d.ts +5 -0
- package/dist/cjs/use-buffer.js +28 -0
- package/dist/cjs/use-current-scale.d.ts +43 -0
- package/dist/cjs/use-current-scale.js +70 -0
- package/dist/cjs/use-media-buffering.d.ts +2 -0
- package/dist/cjs/use-media-buffering.js +42 -0
- package/dist/cjs/use-media-playback.js +10 -5
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/video/OffthreadVideo.js +3 -3
- package/dist/cjs/video/Video.d.ts +1 -0
- package/dist/cjs/video/Video.js +5 -3
- package/dist/cjs/video/VideoForDevelopment.d.ts +1 -1
- package/dist/cjs/video/VideoForPreview.d.ts +11 -0
- package/dist/cjs/video/VideoForPreview.js +150 -0
- package/dist/cjs/video/VideoForRendering.d.ts +1 -0
- package/dist/cjs/video/props.d.ts +2 -0
- package/dist/cjs/video/seek-until-right.js +10 -3
- package/dist/cjs/wrap-remotion-context.d.ts +14 -0
- package/dist/cjs/wrap-remotion-context.js +5 -1
- package/dist/esm/index.mjs +195 -25
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
- package/dist/cjs/get-timeline-clip-name.d.ts +0 -1
- package/dist/cjs/get-timeline-clip-name.js +0 -25
package/dist/cjs/Img.d.ts
CHANGED
package/dist/cjs/Img.js
CHANGED
|
@@ -6,12 +6,14 @@ const react_1 = require("react");
|
|
|
6
6
|
const cancel_render_js_1 = require("./cancel-render.js");
|
|
7
7
|
const delay_render_js_1 = require("./delay-render.js");
|
|
8
8
|
const prefetch_js_1 = require("./prefetch.js");
|
|
9
|
+
const use_buffer_state_js_1 = require("./use-buffer-state.js");
|
|
9
10
|
function exponentialBackoff(errorCount) {
|
|
10
11
|
return 1000 * 2 ** (errorCount - 1);
|
|
11
12
|
}
|
|
12
|
-
const ImgRefForwarding = ({ onError, maxRetries = 2, src, ...props }, ref) => {
|
|
13
|
+
const ImgRefForwarding = ({ onError, maxRetries = 2, src, pauseWhenLoading, ...props }, ref) => {
|
|
13
14
|
const imageRef = (0, react_1.useRef)(null);
|
|
14
15
|
const errors = (0, react_1.useRef)({});
|
|
16
|
+
const { delayPlayback } = (0, use_buffer_state_js_1.useBufferState)();
|
|
15
17
|
if (!src) {
|
|
16
18
|
throw new Error('No "src" prop was passed to <Img>.');
|
|
17
19
|
}
|
|
@@ -67,6 +69,9 @@ const ImgRefForwarding = ({ onError, maxRetries = 2, src, ...props }, ref) => {
|
|
|
67
69
|
return;
|
|
68
70
|
}
|
|
69
71
|
const newHandle = (0, delay_render_js_1.delayRender)('Loading <Img> with src=' + actualSrc);
|
|
72
|
+
const unblock = pauseWhenLoading
|
|
73
|
+
? delayPlayback().unblock
|
|
74
|
+
: () => undefined;
|
|
70
75
|
const { current } = imageRef;
|
|
71
76
|
const onComplete = () => {
|
|
72
77
|
var _a, _b, _c, _d;
|
|
@@ -75,6 +80,7 @@ const ImgRefForwarding = ({ onError, maxRetries = 2, src, ...props }, ref) => {
|
|
|
75
80
|
// eslint-disable-next-line no-console
|
|
76
81
|
console.info(`Retry successful - ${(_d = imageRef.current) === null || _d === void 0 ? void 0 : _d.src} is now loaded`);
|
|
77
82
|
}
|
|
83
|
+
unblock();
|
|
78
84
|
(0, delay_render_js_1.continueRender)(newHandle);
|
|
79
85
|
};
|
|
80
86
|
const didLoad = () => {
|
|
@@ -89,9 +95,10 @@ const ImgRefForwarding = ({ onError, maxRetries = 2, src, ...props }, ref) => {
|
|
|
89
95
|
// If tag gets unmounted, clear pending handles because image is not going to load
|
|
90
96
|
return () => {
|
|
91
97
|
current === null || current === void 0 ? void 0 : current.removeEventListener('load', didLoad);
|
|
98
|
+
unblock();
|
|
92
99
|
(0, delay_render_js_1.continueRender)(newHandle);
|
|
93
100
|
};
|
|
94
|
-
}, [actualSrc]);
|
|
101
|
+
}, [actualSrc, delayPlayback, pauseWhenLoading]);
|
|
95
102
|
}
|
|
96
103
|
return ((0, jsx_runtime_1.jsx)("img", { ...props, ref: imageRef, src: actualSrc, onError: didGetError }));
|
|
97
104
|
};
|
package/dist/cjs/RemotionRoot.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RemotionRoot = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
+
const buffering_js_1 = require("./buffering.js");
|
|
6
7
|
const CompositionManager_js_1 = require("./CompositionManager.js");
|
|
7
8
|
const delay_render_js_1 = require("./delay-render.js");
|
|
8
9
|
const EditorProps_js_1 = require("./EditorProps.js");
|
|
@@ -69,6 +70,6 @@ const RemotionRoot = ({ children, numberOfAudioTags }) => {
|
|
|
69
70
|
}
|
|
70
71
|
}
|
|
71
72
|
}, []);
|
|
72
|
-
return ((0, jsx_runtime_1.jsx)(nonce_js_1.NonceContext.Provider, { value: nonceContext, children: (0, jsx_runtime_1.jsx)(timeline_position_state_js_1.TimelineContext.Provider, { value: timelineContextValue, children: (0, jsx_runtime_1.jsx)(timeline_position_state_js_1.SetTimelineContext.Provider, { value: setTimelineContextValue, children: (0, jsx_runtime_1.jsx)(EditorProps_js_1.EditorPropsProvider, { children: (0, jsx_runtime_1.jsx)(prefetch_state_js_1.PrefetchProvider, { children: (0, jsx_runtime_1.jsx)(NativeLayers_js_1.NativeLayersProvider, { children: (0, jsx_runtime_1.jsx)(CompositionManager_js_1.CompositionManagerProvider, { numberOfAudioTags: numberOfAudioTags, children: (0, jsx_runtime_1.jsx)(duration_state_js_1.DurationsContextProvider, { children: children }) }) }) }) }) }) }) }));
|
|
73
|
+
return ((0, jsx_runtime_1.jsx)(nonce_js_1.NonceContext.Provider, { value: nonceContext, children: (0, jsx_runtime_1.jsx)(timeline_position_state_js_1.TimelineContext.Provider, { value: timelineContextValue, children: (0, jsx_runtime_1.jsx)(timeline_position_state_js_1.SetTimelineContext.Provider, { value: setTimelineContextValue, children: (0, jsx_runtime_1.jsx)(EditorProps_js_1.EditorPropsProvider, { children: (0, jsx_runtime_1.jsx)(prefetch_state_js_1.PrefetchProvider, { children: (0, jsx_runtime_1.jsx)(NativeLayers_js_1.NativeLayersProvider, { children: (0, jsx_runtime_1.jsx)(CompositionManager_js_1.CompositionManagerProvider, { numberOfAudioTags: numberOfAudioTags, children: (0, jsx_runtime_1.jsx)(duration_state_js_1.DurationsContextProvider, { children: (0, jsx_runtime_1.jsx)(buffering_js_1.BufferingProvider, { children: children }) }) }) }) }) }) }) }) }));
|
|
73
74
|
};
|
|
74
75
|
exports.RemotionRoot = RemotionRoot;
|
package/dist/cjs/Sequence.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare const Audio: React.ForwardRefExoticComponent<Omit<Omit<React.Deta
|
|
|
13
13
|
_remotionInternalNeedsDurationCalculation?: boolean | undefined;
|
|
14
14
|
_remotionInternalNativeLoopPassed?: boolean | undefined;
|
|
15
15
|
toneFrequency?: number | undefined;
|
|
16
|
+
pauseWhenBuffering?: boolean | undefined;
|
|
16
17
|
} & RemotionMainAudioProps & {
|
|
17
18
|
/**
|
|
18
19
|
* @deprecated For internal use only
|
package/dist/cjs/audio/Audio.js
CHANGED
|
@@ -16,13 +16,13 @@ const use_video_config_js_1 = require("../use-video-config.js");
|
|
|
16
16
|
const validate_media_props_js_1 = require("../validate-media-props.js");
|
|
17
17
|
const validate_start_from_props_js_1 = require("../validate-start-from-props.js");
|
|
18
18
|
const duration_state_js_1 = require("../video/duration-state.js");
|
|
19
|
-
const
|
|
19
|
+
const AudioForPreview_js_1 = require("./AudioForPreview.js");
|
|
20
20
|
const AudioForRendering_js_1 = require("./AudioForRendering.js");
|
|
21
21
|
const shared_audio_tags_js_1 = require("./shared-audio-tags.js");
|
|
22
22
|
const AudioRefForwardingFunction = (props, ref) => {
|
|
23
23
|
var _a, _b, _c;
|
|
24
24
|
const audioContext = (0, react_1.useContext)(shared_audio_tags_js_1.SharedAudioContext);
|
|
25
|
-
const { startFrom, endAt, name, stack, ...otherProps } = props;
|
|
25
|
+
const { startFrom, endAt, name, stack, pauseWhenBuffering, ...otherProps } = props;
|
|
26
26
|
const { loop, ...propsOtherThanLoop } = props;
|
|
27
27
|
const { fps } = (0, use_video_config_js_1.useVideoConfig)();
|
|
28
28
|
const environment = (0, get_remotion_environment_js_1.getRemotionEnvironment)();
|
|
@@ -68,7 +68,9 @@ const AudioRefForwardingFunction = (props, ref) => {
|
|
|
68
68
|
if (environment.isRendering) {
|
|
69
69
|
return ((0, jsx_runtime_1.jsx)(AudioForRendering_js_1.AudioForRendering, { onDuration: onDuration, ...props, ref: ref, onError: onError, _remotionInternalNeedsDurationCalculation: Boolean(loop) }));
|
|
70
70
|
}
|
|
71
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
71
|
+
return ((0, jsx_runtime_1.jsx)(AudioForPreview_js_1.AudioForPreview, { _remotionInternalNativeLoopPassed: (_c = props._remotionInternalNativeLoopPassed) !== null && _c !== void 0 ? _c : false, _remotionInternalStack: stack !== null && stack !== void 0 ? stack : null, shouldPreMountAudioTags: audioContext !== null && audioContext.numberOfAudioTags > 0, ...props, ref: ref, onError: onError, onDuration: onDuration,
|
|
72
|
+
// Proposal: Make this default to true in v5
|
|
73
|
+
pauseWhenBuffering: pauseWhenBuffering !== null && pauseWhenBuffering !== void 0 ? pauseWhenBuffering : false, _remotionInternalNeedsDurationCalculation: Boolean(loop) }));
|
|
72
74
|
};
|
|
73
75
|
/**
|
|
74
76
|
* @description With this component, you can add audio to your video. All audio formats which are supported by Chromium are supported by the component.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
export declare const AudioForDevelopment: ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.AudioHTMLAttributes<HTMLAudioElement>, HTMLAudioElement>, "
|
|
3
|
+
export declare const AudioForDevelopment: ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.AudioHTMLAttributes<HTMLAudioElement>, HTMLAudioElement>, "autoPlay" | "controls" | "onEnded" | "nonce" | "onResize" | "onResizeCapture"> & {
|
|
4
4
|
name?: string | undefined;
|
|
5
5
|
volume?: import("../volume-prop.js").VolumeProp | undefined;
|
|
6
6
|
playbackRate?: number | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { RemotionAudioProps } from './props.js';
|
|
3
|
+
type AudioForPreviewProps = RemotionAudioProps & {
|
|
4
|
+
shouldPreMountAudioTags: boolean;
|
|
5
|
+
onDuration: (src: string, durationInSeconds: number) => void;
|
|
6
|
+
pauseWhenBuffering: boolean;
|
|
7
|
+
_remotionInternalNativeLoopPassed: boolean;
|
|
8
|
+
_remotionInternalStack: string | null;
|
|
9
|
+
};
|
|
10
|
+
export declare const AudioForPreview: React.ForwardRefExoticComponent<Omit<AudioForPreviewProps, "ref"> & React.RefAttributes<HTMLAudioElement>>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AudioForPreview = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const prefetch_js_1 = require("../prefetch.js");
|
|
7
|
+
const random_js_1 = require("../random.js");
|
|
8
|
+
const SequenceContext_js_1 = require("../SequenceContext.js");
|
|
9
|
+
const SequenceManager_js_1 = require("../SequenceManager.js");
|
|
10
|
+
const use_media_buffering_js_1 = require("../use-media-buffering.js");
|
|
11
|
+
const use_media_in_timeline_js_1 = require("../use-media-in-timeline.js");
|
|
12
|
+
const use_media_playback_js_1 = require("../use-media-playback.js");
|
|
13
|
+
const use_media_tag_volume_js_1 = require("../use-media-tag-volume.js");
|
|
14
|
+
const use_sync_volume_with_media_tag_js_1 = require("../use-sync-volume-with-media-tag.js");
|
|
15
|
+
const volume_position_state_js_1 = require("../volume-position-state.js");
|
|
16
|
+
const shared_audio_tags_js_1 = require("./shared-audio-tags.js");
|
|
17
|
+
const use_audio_frame_js_1 = require("./use-audio-frame.js");
|
|
18
|
+
const AudioForDevelopmentForwardRefFunction = (props, ref) => {
|
|
19
|
+
var _a;
|
|
20
|
+
const [initialShouldPreMountAudioElements] = (0, react_1.useState)(props.shouldPreMountAudioTags);
|
|
21
|
+
if (props.shouldPreMountAudioTags !== initialShouldPreMountAudioElements) {
|
|
22
|
+
throw new Error('Cannot change the behavior for pre-mounting audio tags dynamically.');
|
|
23
|
+
}
|
|
24
|
+
const [mediaVolume] = (0, volume_position_state_js_1.useMediaVolumeState)();
|
|
25
|
+
const [mediaMuted] = (0, volume_position_state_js_1.useMediaMutedState)();
|
|
26
|
+
const volumePropFrame = (0, use_audio_frame_js_1.useFrameForVolumeProp)();
|
|
27
|
+
const { volume, muted, playbackRate, shouldPreMountAudioTags, src, onDuration, acceptableTimeShiftInSeconds, _remotionInternalNeedsDurationCalculation, _remotionInternalNativeLoopPassed, _remotionInternalStack, allowAmplificationDuringRender, name, pauseWhenBuffering, ...nativeProps } = props;
|
|
28
|
+
const { hidden } = (0, react_1.useContext)(SequenceManager_js_1.SequenceVisibilityToggleContext);
|
|
29
|
+
if (!src) {
|
|
30
|
+
throw new TypeError("No 'src' was passed to <Audio>.");
|
|
31
|
+
}
|
|
32
|
+
const preloadedSrc = (0, prefetch_js_1.usePreload)(src);
|
|
33
|
+
const sequenceContext = (0, react_1.useContext)(SequenceContext_js_1.SequenceContext);
|
|
34
|
+
const [timelineId] = (0, react_1.useState)(() => String(Math.random()));
|
|
35
|
+
const isSequenceHidden = (_a = hidden[timelineId]) !== null && _a !== void 0 ? _a : false;
|
|
36
|
+
const propsToPass = (0, react_1.useMemo)(() => {
|
|
37
|
+
return {
|
|
38
|
+
muted: muted || mediaMuted || isSequenceHidden,
|
|
39
|
+
src: preloadedSrc,
|
|
40
|
+
loop: _remotionInternalNativeLoopPassed,
|
|
41
|
+
...nativeProps,
|
|
42
|
+
};
|
|
43
|
+
}, [
|
|
44
|
+
_remotionInternalNativeLoopPassed,
|
|
45
|
+
isSequenceHidden,
|
|
46
|
+
mediaMuted,
|
|
47
|
+
muted,
|
|
48
|
+
nativeProps,
|
|
49
|
+
preloadedSrc,
|
|
50
|
+
]);
|
|
51
|
+
// Generate a string that's as unique as possible for this asset
|
|
52
|
+
// but at the same time deterministic. We use it to combat strict mode issues.
|
|
53
|
+
const id = (0, react_1.useMemo)(() => `audio-${(0, random_js_1.random)(src !== null && src !== void 0 ? src : '')}-${sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom}-${sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.cumulatedFrom}-${sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.durationInFrames}-muted:${props.muted}-loop:${props.loop}`, [
|
|
54
|
+
src,
|
|
55
|
+
sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom,
|
|
56
|
+
sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.cumulatedFrom,
|
|
57
|
+
sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.durationInFrames,
|
|
58
|
+
props.muted,
|
|
59
|
+
props.loop,
|
|
60
|
+
]);
|
|
61
|
+
const audioRef = (0, shared_audio_tags_js_1.useSharedAudio)(propsToPass, id).el;
|
|
62
|
+
const actualVolume = (0, use_media_tag_volume_js_1.useMediaTagVolume)(audioRef);
|
|
63
|
+
(0, use_sync_volume_with_media_tag_js_1.useSyncVolumeWithMediaTag)({
|
|
64
|
+
volumePropFrame,
|
|
65
|
+
actualVolume,
|
|
66
|
+
volume,
|
|
67
|
+
mediaVolume,
|
|
68
|
+
mediaRef: audioRef,
|
|
69
|
+
});
|
|
70
|
+
(0, use_media_in_timeline_js_1.useMediaInTimeline)({
|
|
71
|
+
volume,
|
|
72
|
+
mediaVolume,
|
|
73
|
+
mediaRef: audioRef,
|
|
74
|
+
src,
|
|
75
|
+
mediaType: 'audio',
|
|
76
|
+
playbackRate: playbackRate !== null && playbackRate !== void 0 ? playbackRate : 1,
|
|
77
|
+
displayName: name !== null && name !== void 0 ? name : null,
|
|
78
|
+
id: timelineId,
|
|
79
|
+
stack: props._remotionInternalStack,
|
|
80
|
+
});
|
|
81
|
+
(0, use_media_playback_js_1.useMediaPlayback)({
|
|
82
|
+
mediaRef: audioRef,
|
|
83
|
+
src,
|
|
84
|
+
mediaType: 'audio',
|
|
85
|
+
playbackRate: playbackRate !== null && playbackRate !== void 0 ? playbackRate : 1,
|
|
86
|
+
onlyWarnForMediaSeekingError: false,
|
|
87
|
+
acceptableTimeshift: acceptableTimeShiftInSeconds !== null && acceptableTimeShiftInSeconds !== void 0 ? acceptableTimeShiftInSeconds : use_media_playback_js_1.DEFAULT_ACCEPTABLE_TIMESHIFT,
|
|
88
|
+
});
|
|
89
|
+
(0, use_media_buffering_js_1.useMediaBuffering)(audioRef, pauseWhenBuffering);
|
|
90
|
+
(0, react_1.useImperativeHandle)(ref, () => {
|
|
91
|
+
return audioRef.current;
|
|
92
|
+
}, [audioRef]);
|
|
93
|
+
const currentOnDurationCallback = (0, react_1.useRef)();
|
|
94
|
+
currentOnDurationCallback.current = onDuration;
|
|
95
|
+
(0, react_1.useEffect)(() => {
|
|
96
|
+
var _a;
|
|
97
|
+
const { current } = audioRef;
|
|
98
|
+
if (!current) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (current.duration) {
|
|
102
|
+
(_a = currentOnDurationCallback.current) === null || _a === void 0 ? void 0 : _a.call(currentOnDurationCallback, current.src, current.duration);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const onLoadedMetadata = () => {
|
|
106
|
+
var _a;
|
|
107
|
+
(_a = currentOnDurationCallback.current) === null || _a === void 0 ? void 0 : _a.call(currentOnDurationCallback, current.src, current.duration);
|
|
108
|
+
};
|
|
109
|
+
current.addEventListener('loadedmetadata', onLoadedMetadata);
|
|
110
|
+
return () => {
|
|
111
|
+
current.removeEventListener('loadedmetadata', onLoadedMetadata);
|
|
112
|
+
};
|
|
113
|
+
}, [audioRef, src]);
|
|
114
|
+
if (initialShouldPreMountAudioElements) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
return (0, jsx_runtime_1.jsx)("audio", { ref: audioRef, preload: "metadata", ...propsToPass });
|
|
118
|
+
};
|
|
119
|
+
exports.AudioForPreview = (0, react_1.forwardRef)(AudioForDevelopmentForwardRefFunction);
|
|
@@ -9,6 +9,7 @@ export declare const AudioForRendering: ForwardRefExoticComponent<Omit<React.Det
|
|
|
9
9
|
_remotionInternalNeedsDurationCalculation?: boolean | undefined;
|
|
10
10
|
_remotionInternalNativeLoopPassed?: boolean | undefined;
|
|
11
11
|
toneFrequency?: number | undefined;
|
|
12
|
+
pauseWhenBuffering?: boolean | undefined;
|
|
12
13
|
} & {
|
|
13
14
|
onDuration: (src: string, durationInSeconds: number) => void;
|
|
14
15
|
} & RefAttributes<HTMLAudioElement>>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type Block = {
|
|
3
|
+
id: string;
|
|
4
|
+
};
|
|
5
|
+
type OnBufferingCallback = () => void;
|
|
6
|
+
type OnResumeCallback = () => void;
|
|
7
|
+
type ListenForBuffering = (callback: OnBufferingCallback) => {
|
|
8
|
+
remove: () => void;
|
|
9
|
+
};
|
|
10
|
+
type ListenForResume = (callback: OnResumeCallback) => {
|
|
11
|
+
remove: () => void;
|
|
12
|
+
};
|
|
13
|
+
type AddBlock = (block: Block) => {
|
|
14
|
+
unblock: () => void;
|
|
15
|
+
};
|
|
16
|
+
type BufferManager = {
|
|
17
|
+
addBlock: AddBlock;
|
|
18
|
+
listenForBuffering: ListenForBuffering;
|
|
19
|
+
listenForResume: ListenForResume;
|
|
20
|
+
buffering: React.MutableRefObject<boolean>;
|
|
21
|
+
};
|
|
22
|
+
export declare const BufferingContextReact: React.Context<BufferManager | null>;
|
|
23
|
+
export declare const BufferingProvider: React.FC<{
|
|
24
|
+
children: React.ReactNode;
|
|
25
|
+
}>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.BufferingProvider = exports.BufferingContextReact = void 0;
|
|
27
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
28
|
+
const react_1 = __importStar(require("react"));
|
|
29
|
+
const useBufferManager = () => {
|
|
30
|
+
const [blocks, setBlocks] = (0, react_1.useState)([]);
|
|
31
|
+
const [onBufferingCallbacks, setOnBufferingCallbacks] = (0, react_1.useState)([]);
|
|
32
|
+
const [onResumeCallbacks, setOnResumeCallbacks] = (0, react_1.useState)([]);
|
|
33
|
+
const buffering = (0, react_1.useRef)(false);
|
|
34
|
+
const addBlock = (0, react_1.useCallback)((block) => {
|
|
35
|
+
setBlocks((b) => [...b, block]);
|
|
36
|
+
return {
|
|
37
|
+
unblock: () => {
|
|
38
|
+
setBlocks((b) => b.filter((bx) => bx !== block));
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}, []);
|
|
42
|
+
const listenForBuffering = (0, react_1.useCallback)((callback) => {
|
|
43
|
+
setOnBufferingCallbacks((c) => [...c, callback]);
|
|
44
|
+
return {
|
|
45
|
+
remove: () => {
|
|
46
|
+
setOnBufferingCallbacks((c) => c.filter((cb) => cb !== callback));
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}, []);
|
|
50
|
+
const listenForResume = (0, react_1.useCallback)((callback) => {
|
|
51
|
+
setOnResumeCallbacks((c) => [...c, callback]);
|
|
52
|
+
return {
|
|
53
|
+
remove: () => {
|
|
54
|
+
setOnResumeCallbacks((c) => c.filter((cb) => cb !== callback));
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}, []);
|
|
58
|
+
(0, react_1.useEffect)(() => {
|
|
59
|
+
if (blocks.length > 0) {
|
|
60
|
+
onBufferingCallbacks.forEach((c) => c());
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
onResumeCallbacks.forEach((c) => c());
|
|
64
|
+
}
|
|
65
|
+
}, [blocks, onBufferingCallbacks, onResumeCallbacks]);
|
|
66
|
+
return (0, react_1.useMemo)(() => {
|
|
67
|
+
return { addBlock, listenForBuffering, listenForResume, buffering };
|
|
68
|
+
}, [addBlock, buffering, listenForBuffering, listenForResume]);
|
|
69
|
+
};
|
|
70
|
+
exports.BufferingContextReact = react_1.default.createContext(null);
|
|
71
|
+
const BufferingProvider = ({ children }) => {
|
|
72
|
+
const bufferManager = useBufferManager();
|
|
73
|
+
return ((0, jsx_runtime_1.jsx)(exports.BufferingContextReact.Provider, { value: bufferManager, children: children }));
|
|
74
|
+
};
|
|
75
|
+
exports.BufferingProvider = BufferingProvider;
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -93,7 +93,9 @@ export * from './spring/index.js';
|
|
|
93
93
|
export { staticFile } from './static-file.js';
|
|
94
94
|
export * from './Still.js';
|
|
95
95
|
export type { PlayableMediaTag } from './timeline-position-state.js';
|
|
96
|
+
export { useBufferState } from './use-buffer-state';
|
|
96
97
|
export { useCurrentFrame } from './use-current-frame.js';
|
|
98
|
+
export { CurrentScaleContextType, PreviewSize, PreviewSizeCtx, Translation, useCurrentScale, } from './use-current-scale';
|
|
97
99
|
export * from './use-video-config.js';
|
|
98
100
|
export * from './version.js';
|
|
99
101
|
export * from './video-config.js';
|
package/dist/cjs/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.Config = exports.Experimental = exports.watchStaticFile = exports.useCurrentFrame = exports.staticFile = exports.Series = exports.Sequence = exports.registerRoot = exports.prefetch = exports.random = exports.interpolate = exports.Loop = exports.interpolateColors = exports.Img = exports.getStaticFiles = exports.getRemotionEnvironment = exports.delayRender = exports.continueRender = exports.getInputProps = exports.Composition = exports.cancelRender = void 0;
|
|
17
|
+
exports.Config = exports.Experimental = exports.watchStaticFile = exports.useCurrentScale = exports.useCurrentFrame = exports.useBufferState = exports.staticFile = exports.Series = exports.Sequence = exports.registerRoot = exports.prefetch = exports.random = exports.interpolate = exports.Loop = exports.interpolateColors = exports.Img = exports.getStaticFiles = exports.getRemotionEnvironment = exports.delayRender = exports.continueRender = exports.getInputProps = exports.Composition = exports.cancelRender = void 0;
|
|
18
18
|
require("./asset-types.js");
|
|
19
19
|
const Clipper_js_1 = require("./Clipper.js");
|
|
20
20
|
const enable_sequence_stack_traces_js_1 = require("./enable-sequence-stack-traces.js");
|
|
@@ -64,8 +64,12 @@ __exportStar(require("./spring/index.js"), exports);
|
|
|
64
64
|
var static_file_js_1 = require("./static-file.js");
|
|
65
65
|
Object.defineProperty(exports, "staticFile", { enumerable: true, get: function () { return static_file_js_1.staticFile; } });
|
|
66
66
|
__exportStar(require("./Still.js"), exports);
|
|
67
|
+
var use_buffer_state_1 = require("./use-buffer-state");
|
|
68
|
+
Object.defineProperty(exports, "useBufferState", { enumerable: true, get: function () { return use_buffer_state_1.useBufferState; } });
|
|
67
69
|
var use_current_frame_js_1 = require("./use-current-frame.js");
|
|
68
70
|
Object.defineProperty(exports, "useCurrentFrame", { enumerable: true, get: function () { return use_current_frame_js_1.useCurrentFrame; } });
|
|
71
|
+
var use_current_scale_1 = require("./use-current-scale");
|
|
72
|
+
Object.defineProperty(exports, "useCurrentScale", { enumerable: true, get: function () { return use_current_scale_1.useCurrentScale; } });
|
|
69
73
|
__exportStar(require("./use-video-config.js"), exports);
|
|
70
74
|
__exportStar(require("./version.js"), exports);
|
|
71
75
|
__exportStar(require("./video-config.js"), exports);
|
package/dist/cjs/internals.d.ts
CHANGED
|
@@ -128,9 +128,37 @@ export declare const Internals: {
|
|
|
128
128
|
readonly WATCH_REMOTION_STATIC_FILES: "remotion_staticFilesChanged";
|
|
129
129
|
readonly addSequenceStackTraces: (component: unknown) => void;
|
|
130
130
|
readonly useMediaStartsAt: () => number;
|
|
131
|
+
readonly BufferingProvider: import("react").FC<{
|
|
132
|
+
children: import("react").ReactNode;
|
|
133
|
+
}>;
|
|
134
|
+
readonly BufferingContextReact: import("react").Context<{
|
|
135
|
+
addBlock: (block: {
|
|
136
|
+
id: string;
|
|
137
|
+
}) => {
|
|
138
|
+
unblock: () => void;
|
|
139
|
+
};
|
|
140
|
+
listenForBuffering: (callback: () => void) => {
|
|
141
|
+
remove: () => void;
|
|
142
|
+
};
|
|
143
|
+
listenForResume: (callback: () => void) => {
|
|
144
|
+
remove: () => void;
|
|
145
|
+
};
|
|
146
|
+
buffering: import("react").MutableRefObject<boolean>;
|
|
147
|
+
} | null>;
|
|
131
148
|
readonly enableSequenceStackTraces: () => void;
|
|
132
149
|
readonly colorNames: {
|
|
133
150
|
[key: string]: number;
|
|
134
151
|
};
|
|
152
|
+
readonly CurrentScaleContext: import("react").Context<import("./use-current-scale.js").CurrentScaleContextType | null>;
|
|
153
|
+
readonly PreviewSizeContext: import("react").Context<import("./use-current-scale.js").PreviewSizeCtx>;
|
|
154
|
+
readonly calculateScale: ({ canvasSize, compositionHeight, compositionWidth, previewSize, }: {
|
|
155
|
+
previewSize: number | "auto";
|
|
156
|
+
compositionWidth: number;
|
|
157
|
+
compositionHeight: number;
|
|
158
|
+
canvasSize: {
|
|
159
|
+
width: number;
|
|
160
|
+
height: number;
|
|
161
|
+
};
|
|
162
|
+
}) => number;
|
|
135
163
|
};
|
|
136
164
|
export type { TComposition, TimelinePosition as Timeline, TCompMetadata, TSequence, TRenderAsset as TAsset, TimelineContextValue, SetTimelineContextValue, CompProps, CompositionManagerContext, MediaVolumeContextValue, SetMediaVolumeContextValue, RemotionEnvironment, SerializedJSONWithCustomFields, WatchRemotionStaticFilesPayload, };
|
package/dist/cjs/internals.js
CHANGED
|
@@ -26,6 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.Internals = void 0;
|
|
27
27
|
const shared_audio_tags_js_1 = require("./audio/shared-audio-tags.js");
|
|
28
28
|
const use_audio_frame_js_1 = require("./audio/use-audio-frame.js");
|
|
29
|
+
const buffering_js_1 = require("./buffering.js");
|
|
29
30
|
const CanUseRemotionHooks_js_1 = require("./CanUseRemotionHooks.js");
|
|
30
31
|
const Composition_js_1 = require("./Composition.js");
|
|
31
32
|
const CompositionManager_js_1 = require("./CompositionManager.js");
|
|
@@ -54,6 +55,7 @@ const setup_env_variables_js_1 = require("./setup-env-variables.js");
|
|
|
54
55
|
const TimelinePosition = __importStar(require("./timeline-position-state.js"));
|
|
55
56
|
const timeline_position_state_js_1 = require("./timeline-position-state.js");
|
|
56
57
|
const truthy_js_1 = require("./truthy.js");
|
|
58
|
+
const use_current_scale_js_1 = require("./use-current-scale.js");
|
|
57
59
|
const use_lazy_component_js_1 = require("./use-lazy-component.js");
|
|
58
60
|
const use_unsafe_video_config_js_1 = require("./use-unsafe-video-config.js");
|
|
59
61
|
const use_video_js_1 = require("./use-video.js");
|
|
@@ -120,6 +122,11 @@ exports.Internals = {
|
|
|
120
122
|
WATCH_REMOTION_STATIC_FILES: watch_static_file_js_1.WATCH_REMOTION_STATIC_FILES,
|
|
121
123
|
addSequenceStackTraces: enable_sequence_stack_traces_js_1.addSequenceStackTraces,
|
|
122
124
|
useMediaStartsAt: use_audio_frame_js_1.useMediaStartsAt,
|
|
125
|
+
BufferingProvider: buffering_js_1.BufferingProvider,
|
|
126
|
+
BufferingContextReact: buffering_js_1.BufferingContextReact,
|
|
123
127
|
enableSequenceStackTraces: enable_sequence_stack_traces_js_1.enableSequenceStackTraces,
|
|
124
128
|
colorNames: interpolate_colors_js_1.colorNames,
|
|
129
|
+
CurrentScaleContext: use_current_scale_js_1.CurrentScaleContext,
|
|
130
|
+
PreviewSizeContext: use_current_scale_js_1.PreviewSizeContext,
|
|
131
|
+
calculateScale: use_current_scale_js_1.calculateScale,
|
|
125
132
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useBufferState = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const buffering_1 = require("./buffering");
|
|
6
|
+
const useBufferState = () => {
|
|
7
|
+
const buffer = (0, react_1.useContext)(buffering_1.BufferingContextReact);
|
|
8
|
+
return (0, react_1.useMemo)(() => ({
|
|
9
|
+
delayPlayback: () => {
|
|
10
|
+
if (!buffer) {
|
|
11
|
+
throw new Error('Tried to enable the buffering state, but a Remotion context was not found. This API can only be called in a component that was passed to the Remotion Player or a <Composition>. Or you might have experienced a version mismatch - run `npx remotion versions` and ensure all packages have the same version. This error is thrown by the buffer state https://remotion.dev/docs/player/buffer-state');
|
|
12
|
+
}
|
|
13
|
+
const { unblock } = buffer.addBlock({
|
|
14
|
+
id: String(Math.random()),
|
|
15
|
+
});
|
|
16
|
+
return { unblock };
|
|
17
|
+
},
|
|
18
|
+
}), [buffer]);
|
|
19
|
+
};
|
|
20
|
+
exports.useBufferState = useBufferState;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useBufferState = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const buffering_1 = require("./buffering");
|
|
6
|
+
const CanUseRemotionHooks_1 = require("./CanUseRemotionHooks");
|
|
7
|
+
const useBufferState = () => {
|
|
8
|
+
const canUseRemotionHooks = (0, react_1.useContext)(CanUseRemotionHooks_1.CanUseRemotionHooks);
|
|
9
|
+
if (!canUseRemotionHooks) {
|
|
10
|
+
if (typeof window !== 'undefined' && window.remotion_isPlayer) {
|
|
11
|
+
throw new Error(`useCurrentFrame can only be called inside a component that was passed to <Player>. See: https://www.remotion.dev/docs/player/examples`);
|
|
12
|
+
}
|
|
13
|
+
throw new Error(`useCurrentFrame() can only be called inside a component that was registered as a composition. See https://www.remotion.dev/docs/the-fundamentals#defining-compositions`);
|
|
14
|
+
}
|
|
15
|
+
const buffer = (0, react_1.useContext)(buffering_1.BufferingContextReact);
|
|
16
|
+
if (!buffer) {
|
|
17
|
+
throw new Error('BufferingContextReact was unexpectedly not found. Most likely your Remotion versions are mismatching.');
|
|
18
|
+
}
|
|
19
|
+
return (0, react_1.useMemo)(() => ({
|
|
20
|
+
delayPlayback: () => {
|
|
21
|
+
const { unblock } = buffer.addBlock({
|
|
22
|
+
id: String(Math.random()),
|
|
23
|
+
});
|
|
24
|
+
return { unblock };
|
|
25
|
+
},
|
|
26
|
+
}), [buffer]);
|
|
27
|
+
};
|
|
28
|
+
exports.useBufferState = useBufferState;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type CurrentScaleContextType = {
|
|
3
|
+
type: 'scale';
|
|
4
|
+
scale: number;
|
|
5
|
+
} | {
|
|
6
|
+
type: 'canvas-size';
|
|
7
|
+
canvasSize: {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export declare const CurrentScaleContext: React.Context<CurrentScaleContextType | null>;
|
|
13
|
+
type Options = {
|
|
14
|
+
dontThrowIfOutsideOfRemotion: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type Translation = {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
};
|
|
20
|
+
export type PreviewSize = {
|
|
21
|
+
size: number | 'auto';
|
|
22
|
+
translation: Translation;
|
|
23
|
+
};
|
|
24
|
+
export type PreviewSizeCtx = {
|
|
25
|
+
size: PreviewSize;
|
|
26
|
+
setSize: (cb: (oldSize: PreviewSize) => PreviewSize) => void;
|
|
27
|
+
};
|
|
28
|
+
export declare const PreviewSizeContext: React.Context<PreviewSizeCtx>;
|
|
29
|
+
export declare const calculateScale: ({ canvasSize, compositionHeight, compositionWidth, previewSize, }: {
|
|
30
|
+
previewSize: PreviewSize['size'];
|
|
31
|
+
compositionWidth: number;
|
|
32
|
+
compositionHeight: number;
|
|
33
|
+
canvasSize: {
|
|
34
|
+
width: number;
|
|
35
|
+
height: number;
|
|
36
|
+
};
|
|
37
|
+
}) => number;
|
|
38
|
+
/**
|
|
39
|
+
* Gets the current scale of the container in which the component is being rendered.
|
|
40
|
+
* Only works in the Remotion Studio and in the Remotion Player.
|
|
41
|
+
*/
|
|
42
|
+
export declare const useCurrentScale: (options?: Options) => number;
|
|
43
|
+
export {};
|