remotion 3.3.82 → 3.3.84
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/CompositionManager.d.ts +1 -0
- package/dist/cjs/CompositionManager.js +5 -2
- package/dist/cjs/RemotionRoot.js +1 -6
- package/dist/cjs/audio/Audio.d.ts +1 -1
- package/dist/cjs/audio/shared-audio-tags.d.ts +2 -0
- package/dist/cjs/audio/shared-audio-tags.js +17 -1
- package/dist/cjs/config.d.ts +5 -0
- package/dist/cjs/internals.d.ts +1 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/video/get-current-time.js +10 -9
- package/dist/cjs/z-color.d.ts +9 -0
- package/dist/cjs/z-color.js +28 -0
- package/dist/esm/index.mjs +230 -215
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
|
@@ -26,6 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.CompositionManagerProvider = exports.compositionsRef = exports.CompositionManager = void 0;
|
|
27
27
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
28
28
|
const react_1 = __importStar(require("react"));
|
|
29
|
+
const shared_audio_tags_js_1 = require("./audio/shared-audio-tags.js");
|
|
29
30
|
exports.CompositionManager = (0, react_1.createContext)({
|
|
30
31
|
compositions: [],
|
|
31
32
|
registerComposition: () => undefined,
|
|
@@ -45,7 +46,8 @@ exports.CompositionManager = (0, react_1.createContext)({
|
|
|
45
46
|
currentCompositionMetadata: null,
|
|
46
47
|
});
|
|
47
48
|
exports.compositionsRef = react_1.default.createRef();
|
|
48
|
-
const CompositionManagerProvider = ({ children }) => {
|
|
49
|
+
const CompositionManagerProvider = ({ children, numberOfAudioTags }) => {
|
|
50
|
+
var _a;
|
|
49
51
|
// Wontfix, expected to have
|
|
50
52
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
51
53
|
const [compositions, setCompositions] = (0, react_1.useState)([]);
|
|
@@ -159,6 +161,7 @@ const CompositionManagerProvider = ({ children }) => {
|
|
|
159
161
|
unregisterFolder,
|
|
160
162
|
currentCompositionMetadata,
|
|
161
163
|
]);
|
|
162
|
-
|
|
164
|
+
const composition = (_a = compositions.find((c) => c.id === currentComposition)) === null || _a === void 0 ? void 0 : _a.component;
|
|
165
|
+
return ((0, jsx_runtime_1.jsx)(exports.CompositionManager.Provider, { value: contextValue, children: (0, jsx_runtime_1.jsx)(shared_audio_tags_js_1.SharedAudioContextProvider, { numberOfAudioTags: numberOfAudioTags, component: composition !== null && composition !== void 0 ? composition : null, children: children }) }));
|
|
163
166
|
};
|
|
164
167
|
exports.CompositionManagerProvider = CompositionManagerProvider;
|
package/dist/cjs/RemotionRoot.js
CHANGED
|
@@ -3,7 +3,6 @@ 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 shared_audio_tags_js_1 = require("./audio/shared-audio-tags.js");
|
|
7
6
|
const CompositionManager_js_1 = require("./CompositionManager.js");
|
|
8
7
|
const delay_render_js_1 = require("./delay-render.js");
|
|
9
8
|
const NativeLayers_js_1 = require("./NativeLayers.js");
|
|
@@ -67,10 +66,6 @@ const RemotionRoot = ({ children, numberOfAudioTags }) => {
|
|
|
67
66
|
}
|
|
68
67
|
}
|
|
69
68
|
}, []);
|
|
70
|
-
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)(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, { children: (0, jsx_runtime_1.jsx)(duration_state_js_1.DurationsContextProvider, { children:
|
|
71
|
-
// In the preview, which is mostly played on Desktop, we opt out of the autoplay policy fix as described in https://github.com/remotion-dev/remotion/pull/554, as it mostly applies to mobile.
|
|
72
|
-
, {
|
|
73
|
-
// In the preview, which is mostly played on Desktop, we opt out of the autoplay policy fix as described in https://github.com/remotion-dev/remotion/pull/554, as it mostly applies to mobile.
|
|
74
|
-
numberOfAudioTags: numberOfAudioTags, children: children }) }) }) }) }) }) }) }));
|
|
69
|
+
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)(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 }) }) }) }) }) }) }));
|
|
75
70
|
};
|
|
76
71
|
exports.RemotionRoot = RemotionRoot;
|
|
@@ -9,4 +9,4 @@ export declare const Audio: React.ForwardRefExoticComponent<Pick<Omit<React.Deta
|
|
|
9
9
|
playbackRate?: number | undefined;
|
|
10
10
|
acceptableTimeShiftInSeconds?: number | undefined;
|
|
11
11
|
allowAmplificationDuringRender?: boolean | undefined;
|
|
12
|
-
} & RemotionMainAudioProps, "id" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "lang" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "
|
|
12
|
+
} & RemotionMainAudioProps, "id" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "lang" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "volume" | "allowAmplificationDuringRender" | "controlsList" | "crossOrigin" | "loop" | "mediaGroup" | "muted" | "playsInline" | "preload" | "src" | "playbackRate" | "acceptableTimeShiftInSeconds" | keyof RemotionMainAudioProps> & React.RefAttributes<HTMLAudioElement>>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ComponentType, LazyExoticComponent } from 'react';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import type { RemotionAudioProps } from './props.js';
|
|
3
4
|
/**
|
|
@@ -32,6 +33,7 @@ export declare const SharedAudioContext: React.Context<SharedContext | null>;
|
|
|
32
33
|
export declare const SharedAudioContextProvider: React.FC<{
|
|
33
34
|
numberOfAudioTags: number;
|
|
34
35
|
children: React.ReactNode;
|
|
36
|
+
component: LazyExoticComponent<ComponentType<unknown>> | null;
|
|
35
37
|
}>;
|
|
36
38
|
export declare const useSharedAudio: (aud: RemotionAudioProps, audioId: string) => AudioElem;
|
|
37
39
|
export {};
|
|
@@ -59,7 +59,7 @@ const didPropChange = (key, newProp, prevProp) => {
|
|
|
59
59
|
return true;
|
|
60
60
|
};
|
|
61
61
|
exports.SharedAudioContext = (0, react_1.createContext)(null);
|
|
62
|
-
const SharedAudioContextProvider = ({ children, numberOfAudioTags }) => {
|
|
62
|
+
const SharedAudioContextProvider = ({ children, numberOfAudioTags, component }) => {
|
|
63
63
|
const audios = (0, react_1.useRef)([]);
|
|
64
64
|
const [initialNumberOfAudioTags] = (0, react_1.useState)(numberOfAudioTags);
|
|
65
65
|
if (numberOfAudioTags !== initialNumberOfAudioTags) {
|
|
@@ -176,6 +176,22 @@ const SharedAudioContextProvider = ({ children, numberOfAudioTags }) => {
|
|
|
176
176
|
unregisterAudio,
|
|
177
177
|
updateAudio,
|
|
178
178
|
]);
|
|
179
|
+
// Fixing a bug: In React, if a component is unmounted using useInsertionEffect, then
|
|
180
|
+
// the cleanup function does sometimes not work properly. That is why when we
|
|
181
|
+
// are changing the composition, we reset the audio state.
|
|
182
|
+
// TODO: Possibly this does not save the problem completely, since the
|
|
183
|
+
// if an audio tag that is inside a sequence will also not be removed
|
|
184
|
+
// from the shared audios.
|
|
185
|
+
const resetAudio = (0, react_1.useCallback)(() => {
|
|
186
|
+
takenAudios.current = new Array(numberOfAudioTags).fill(false);
|
|
187
|
+
audios.current = [];
|
|
188
|
+
rerenderAudios();
|
|
189
|
+
}, [numberOfAudioTags, rerenderAudios]);
|
|
190
|
+
(0, react_1.useEffect)(() => {
|
|
191
|
+
return () => {
|
|
192
|
+
resetAudio();
|
|
193
|
+
};
|
|
194
|
+
}, [component, resetAudio]);
|
|
179
195
|
return ((0, jsx_runtime_1.jsxs)(exports.SharedAudioContext.Provider, { value: value, children: [refs.map(({ id, ref }) => {
|
|
180
196
|
return (0, jsx_runtime_1.jsx)("audio", { ref: ref, src: EMPTY_AUDIO }, id);
|
|
181
197
|
}), children] }));
|
package/dist/cjs/config.d.ts
CHANGED
|
@@ -139,6 +139,11 @@ declare global {
|
|
|
139
139
|
* Default: 'swangle' in Lambda, null elsewhere.
|
|
140
140
|
*/
|
|
141
141
|
readonly setChromiumOpenGlRenderer: (renderer: 'swangle' | 'angle' | 'egl' | 'swiftshader') => void;
|
|
142
|
+
/**
|
|
143
|
+
* Set the user agent for Chrome. Only works during rendering.
|
|
144
|
+
* Default:
|
|
145
|
+
*/
|
|
146
|
+
readonly setChromiumUserAgent: (userAgent: string | null) => void;
|
|
142
147
|
};
|
|
143
148
|
/**
|
|
144
149
|
* @deprecated New flat config format: You can now replace `Config.Rendering.` with `Config.`
|
package/dist/cjs/internals.d.ts
CHANGED
|
@@ -71,6 +71,7 @@ export declare const Internals: {
|
|
|
71
71
|
SharedAudioContextProvider: import("react").FC<{
|
|
72
72
|
numberOfAudioTags: number;
|
|
73
73
|
children: import("react").ReactNode;
|
|
74
|
+
component: import("react").LazyExoticComponent<import("react").ComponentType<unknown>> | null;
|
|
74
75
|
}>;
|
|
75
76
|
invalidCompositionErrorMessage: string;
|
|
76
77
|
isCompositionIdValid: (id: string) => RegExpMatchArray | null;
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "3.3.
|
|
1
|
+
export declare const VERSION = "3.3.84";
|
package/dist/cjs/version.js
CHANGED
|
@@ -13,19 +13,20 @@ const getMediaTime = ({ fps, frame, src, playbackRate, startFrom, mediaType, })
|
|
|
13
13
|
playbackRate,
|
|
14
14
|
startFrom,
|
|
15
15
|
});
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (mediaType === 'video') {
|
|
16
|
+
const isChrome = typeof window !== 'undefined' &&
|
|
17
|
+
window.navigator.userAgent.match(/Chrome\/([0-9]+)/);
|
|
18
|
+
if (isChrome &&
|
|
19
|
+
Number(isChrome[1]) < 112 &&
|
|
20
|
+
mediaType === 'video' &&
|
|
21
|
+
src.endsWith('.mp4')) {
|
|
23
22
|
// In Chrome, for MP4s, if 30fps, the first frame is still displayed at 0.033333
|
|
24
23
|
// even though after that it increases by 0.033333333 each.
|
|
25
24
|
// So frame = 0 in Remotion is like frame = 1 for the browser
|
|
26
25
|
return (expectedFrame + 1) / fps;
|
|
27
26
|
}
|
|
28
|
-
// For
|
|
29
|
-
|
|
27
|
+
// For WebM videos, we need to add a little bit of shift to get the right frame.
|
|
28
|
+
const msPerFrame = 1000 / fps;
|
|
29
|
+
const msShift = msPerFrame / 2;
|
|
30
|
+
return (expectedFrame * msPerFrame + msShift) / 1000;
|
|
30
31
|
};
|
|
31
32
|
exports.getMediaTime = getMediaTime;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const REMOTION_COLOR_BRAND = "__remotion-color";
|
|
3
|
+
export declare const parseColor: (value: string) => {
|
|
4
|
+
a: number;
|
|
5
|
+
r: number;
|
|
6
|
+
g: number;
|
|
7
|
+
b: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const zColor: () => z.ZodEffects<z.ZodString, string, string>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.zColor = exports.parseColor = exports.REMOTION_COLOR_BRAND = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const interpolate_colors_js_1 = require("./interpolate-colors.js");
|
|
6
|
+
exports.REMOTION_COLOR_BRAND = '__remotion-color';
|
|
7
|
+
const parseColor = (value) => {
|
|
8
|
+
const colored = (0, interpolate_colors_js_1.processColor)(value).toString(16).padStart(8, '0');
|
|
9
|
+
const opacity = parseInt(colored.slice(0, 2), 16);
|
|
10
|
+
const r = parseInt(colored.slice(2, 4), 16);
|
|
11
|
+
const g = parseInt(colored.slice(4, 6), 16);
|
|
12
|
+
const b = parseInt(colored.slice(6, 8), 16);
|
|
13
|
+
return { a: opacity, r, g, b };
|
|
14
|
+
};
|
|
15
|
+
exports.parseColor = parseColor;
|
|
16
|
+
const zColor = () => zod_1.z
|
|
17
|
+
.string()
|
|
18
|
+
.refine((value) => {
|
|
19
|
+
try {
|
|
20
|
+
(0, exports.parseColor)(value);
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}, { message: 'Invalid color' })
|
|
27
|
+
.describe(exports.REMOTION_COLOR_BRAND);
|
|
28
|
+
exports.zColor = zColor;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { createContext, useState, useMemo, useLayoutEffect, useContext, useEffect, forwardRef, useRef, useCallback, useImperativeHandle, Children, isValidElement, useReducer,
|
|
2
|
-
import { jsx,
|
|
1
|
+
import React, { createContext, useState, useMemo, useLayoutEffect, useContext, useEffect, forwardRef, useRef, createRef, useCallback, useImperativeHandle, Children, isValidElement, useReducer, Suspense } from 'react';
|
|
2
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
4
|
|
|
5
5
|
const NativeLayersContext = createContext({
|
|
@@ -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.84';
|
|
62
62
|
|
|
63
63
|
const checkMultipleRemotionVersions = () => {
|
|
64
64
|
if (typeof globalThis === 'undefined') {
|
|
@@ -160,6 +160,218 @@ const useRemotionEnvironment = () => {
|
|
|
160
160
|
return getRemotionEnvironment();
|
|
161
161
|
};
|
|
162
162
|
|
|
163
|
+
const EMPTY_AUDIO = 'data:audio/mp3;base64,/+MYxAAJcAV8AAgAABn//////+/gQ5BAMA+D4Pg+BAQBAEAwD4Pg+D4EBAEAQDAPg++hYBH///hUFQVBUFREDQNHmf///////+MYxBUGkAGIMAAAAP/29Xt6lUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV/+MYxDUAAANIAAAAAFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV';
|
|
164
|
+
const compareProps = (obj1, obj2) => {
|
|
165
|
+
const keysA = Object.keys(obj1).sort();
|
|
166
|
+
const keysB = Object.keys(obj2).sort();
|
|
167
|
+
if (keysA.length !== keysB.length) {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
for (let i = 0; i < keysA.length; i++) {
|
|
171
|
+
// Not the same keys
|
|
172
|
+
if (keysA[i] !== keysB[i]) {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
// Not the same values
|
|
176
|
+
if (obj1[keysA[i]] !== obj2[keysB[i]]) {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return true;
|
|
181
|
+
};
|
|
182
|
+
const didPropChange = (key, newProp, prevProp) => {
|
|
183
|
+
// /music.mp3 and http://localhost:3000/music.mp3 are the same
|
|
184
|
+
if (key === 'src' &&
|
|
185
|
+
!prevProp.startsWith('data:') &&
|
|
186
|
+
!newProp.startsWith('data:')) {
|
|
187
|
+
return (new URL(prevProp, window.location.origin).toString() !==
|
|
188
|
+
new URL(newProp, window.location.origin).toString());
|
|
189
|
+
}
|
|
190
|
+
if (prevProp === newProp) {
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
return true;
|
|
194
|
+
};
|
|
195
|
+
const SharedAudioContext = createContext(null);
|
|
196
|
+
const SharedAudioContextProvider = ({ children, numberOfAudioTags, component }) => {
|
|
197
|
+
const audios = useRef([]);
|
|
198
|
+
const [initialNumberOfAudioTags] = useState(numberOfAudioTags);
|
|
199
|
+
if (numberOfAudioTags !== initialNumberOfAudioTags) {
|
|
200
|
+
throw new Error('The number of shared audio tags has changed dynamically. Once you have set this property, you cannot change it afterwards.');
|
|
201
|
+
}
|
|
202
|
+
const refs = useMemo(() => {
|
|
203
|
+
return new Array(numberOfAudioTags).fill(true).map(() => {
|
|
204
|
+
return { id: Math.random(), ref: createRef() };
|
|
205
|
+
});
|
|
206
|
+
}, [numberOfAudioTags]);
|
|
207
|
+
const takenAudios = useRef(new Array(numberOfAudioTags).fill(false));
|
|
208
|
+
const rerenderAudios = useCallback(() => {
|
|
209
|
+
refs.forEach(({ ref, id }) => {
|
|
210
|
+
var _a;
|
|
211
|
+
const data = (_a = audios.current) === null || _a === void 0 ? void 0 : _a.find((a) => a.id === id);
|
|
212
|
+
const { current } = ref;
|
|
213
|
+
if (!current) {
|
|
214
|
+
// Whole player has been unmounted, the refs don't exist anymore.
|
|
215
|
+
// It is not an error anymore though
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
if (data === undefined) {
|
|
219
|
+
current.src = EMPTY_AUDIO;
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
if (!data) {
|
|
223
|
+
throw new TypeError('Expected audio data to be there');
|
|
224
|
+
}
|
|
225
|
+
Object.keys(data.props).forEach((key) => {
|
|
226
|
+
// @ts-expect-error
|
|
227
|
+
if (didPropChange(key, data.props[key], current[key])) {
|
|
228
|
+
// @ts-expect-error
|
|
229
|
+
current[key] = data.props[key];
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
}, [refs]);
|
|
234
|
+
const registerAudio = useCallback((aud, audioId) => {
|
|
235
|
+
var _a, _b;
|
|
236
|
+
const found = (_a = audios.current) === null || _a === void 0 ? void 0 : _a.find((a) => a.audioId === audioId);
|
|
237
|
+
if (found) {
|
|
238
|
+
return found;
|
|
239
|
+
}
|
|
240
|
+
const firstFreeAudio = takenAudios.current.findIndex((a) => a === false);
|
|
241
|
+
if (firstFreeAudio === -1) {
|
|
242
|
+
throw new Error(`Tried to simultaneously mount ${numberOfAudioTags + 1} <Audio /> tags at the same time. With the current settings, the maximum amount of <Audio /> tags is limited to ${numberOfAudioTags} at the same time. Remotion pre-mounts silent audio tags to help avoid browser autoplay restrictions. See https://remotion.dev/docs/player/autoplay#use-the-numberofsharedaudiotags-property for more information on how to increase this limit.`);
|
|
243
|
+
}
|
|
244
|
+
const { id, ref } = refs[firstFreeAudio];
|
|
245
|
+
const cloned = [...takenAudios.current];
|
|
246
|
+
cloned[firstFreeAudio] = id;
|
|
247
|
+
takenAudios.current = cloned;
|
|
248
|
+
const newElem = {
|
|
249
|
+
props: aud,
|
|
250
|
+
id,
|
|
251
|
+
el: ref,
|
|
252
|
+
audioId,
|
|
253
|
+
};
|
|
254
|
+
(_b = audios.current) === null || _b === void 0 ? void 0 : _b.push(newElem);
|
|
255
|
+
rerenderAudios();
|
|
256
|
+
return newElem;
|
|
257
|
+
}, [numberOfAudioTags, refs, rerenderAudios]);
|
|
258
|
+
const unregisterAudio = useCallback((id) => {
|
|
259
|
+
var _a;
|
|
260
|
+
const cloned = [...takenAudios.current];
|
|
261
|
+
const index = refs.findIndex((r) => r.id === id);
|
|
262
|
+
if (index === -1) {
|
|
263
|
+
throw new TypeError('Error occured in ');
|
|
264
|
+
}
|
|
265
|
+
cloned[index] = false;
|
|
266
|
+
takenAudios.current = cloned;
|
|
267
|
+
audios.current = (_a = audios.current) === null || _a === void 0 ? void 0 : _a.filter((a) => a.id !== id);
|
|
268
|
+
rerenderAudios();
|
|
269
|
+
}, [refs, rerenderAudios]);
|
|
270
|
+
const updateAudio = useCallback(({ aud, audioId, id, }) => {
|
|
271
|
+
var _a;
|
|
272
|
+
let changed = false;
|
|
273
|
+
audios.current = (_a = audios.current) === null || _a === void 0 ? void 0 : _a.map((prevA) => {
|
|
274
|
+
if (prevA.id === id) {
|
|
275
|
+
const isTheSame = compareProps(aud, prevA.props);
|
|
276
|
+
if (isTheSame) {
|
|
277
|
+
return prevA;
|
|
278
|
+
}
|
|
279
|
+
changed = true;
|
|
280
|
+
return {
|
|
281
|
+
...prevA,
|
|
282
|
+
props: aud,
|
|
283
|
+
audioId,
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
return prevA;
|
|
287
|
+
});
|
|
288
|
+
if (changed) {
|
|
289
|
+
rerenderAudios();
|
|
290
|
+
}
|
|
291
|
+
}, [rerenderAudios]);
|
|
292
|
+
const playAllAudios = useCallback(() => {
|
|
293
|
+
refs.forEach((ref) => {
|
|
294
|
+
var _a;
|
|
295
|
+
(_a = ref.ref.current) === null || _a === void 0 ? void 0 : _a.play();
|
|
296
|
+
});
|
|
297
|
+
}, [refs]);
|
|
298
|
+
const value = useMemo(() => {
|
|
299
|
+
return {
|
|
300
|
+
registerAudio,
|
|
301
|
+
unregisterAudio,
|
|
302
|
+
updateAudio,
|
|
303
|
+
playAllAudios,
|
|
304
|
+
numberOfAudioTags,
|
|
305
|
+
};
|
|
306
|
+
}, [
|
|
307
|
+
numberOfAudioTags,
|
|
308
|
+
playAllAudios,
|
|
309
|
+
registerAudio,
|
|
310
|
+
unregisterAudio,
|
|
311
|
+
updateAudio,
|
|
312
|
+
]);
|
|
313
|
+
// Fixing a bug: In React, if a component is unmounted using useInsertionEffect, then
|
|
314
|
+
// the cleanup function does sometimes not work properly. That is why when we
|
|
315
|
+
// are changing the composition, we reset the audio state.
|
|
316
|
+
// TODO: Possibly this does not save the problem completely, since the
|
|
317
|
+
// if an audio tag that is inside a sequence will also not be removed
|
|
318
|
+
// from the shared audios.
|
|
319
|
+
const resetAudio = useCallback(() => {
|
|
320
|
+
takenAudios.current = new Array(numberOfAudioTags).fill(false);
|
|
321
|
+
audios.current = [];
|
|
322
|
+
rerenderAudios();
|
|
323
|
+
}, [numberOfAudioTags, rerenderAudios]);
|
|
324
|
+
useEffect(() => {
|
|
325
|
+
return () => {
|
|
326
|
+
resetAudio();
|
|
327
|
+
};
|
|
328
|
+
}, [component, resetAudio]);
|
|
329
|
+
return (jsxs(SharedAudioContext.Provider, { value: value, children: [refs.map(({ id, ref }) => {
|
|
330
|
+
return jsx("audio", { ref: ref, src: EMPTY_AUDIO }, id);
|
|
331
|
+
}), children] }));
|
|
332
|
+
};
|
|
333
|
+
const useSharedAudio = (aud, audioId) => {
|
|
334
|
+
var _a;
|
|
335
|
+
const ctx = useContext(SharedAudioContext);
|
|
336
|
+
/**
|
|
337
|
+
* We work around this in React 18 so an audio tag will only register itself once
|
|
338
|
+
*/
|
|
339
|
+
const [elem] = useState(() => {
|
|
340
|
+
if (ctx && ctx.numberOfAudioTags > 0) {
|
|
341
|
+
return ctx.registerAudio(aud, audioId);
|
|
342
|
+
}
|
|
343
|
+
return {
|
|
344
|
+
el: React.createRef(),
|
|
345
|
+
id: Math.random(),
|
|
346
|
+
props: aud,
|
|
347
|
+
audioId,
|
|
348
|
+
};
|
|
349
|
+
});
|
|
350
|
+
/**
|
|
351
|
+
* Effects in React 18 fire twice, and we are looking for a way to only fire it once.
|
|
352
|
+
* - useInsertionEffect only fires once. If it's available we are in React 18.
|
|
353
|
+
* - useLayoutEffect only fires once in React 17.
|
|
354
|
+
*
|
|
355
|
+
* Need to import it from React to fix React 17 ESM support.
|
|
356
|
+
*/
|
|
357
|
+
const effectToUse = (_a = React.useInsertionEffect) !== null && _a !== void 0 ? _a : React.useLayoutEffect;
|
|
358
|
+
if (typeof document !== 'undefined') {
|
|
359
|
+
effectToUse(() => {
|
|
360
|
+
if (ctx && ctx.numberOfAudioTags > 0) {
|
|
361
|
+
ctx.updateAudio({ id: elem.id, aud, audioId });
|
|
362
|
+
}
|
|
363
|
+
}, [aud, ctx, elem.id, audioId]);
|
|
364
|
+
effectToUse(() => {
|
|
365
|
+
return () => {
|
|
366
|
+
if (ctx && ctx.numberOfAudioTags > 0) {
|
|
367
|
+
ctx.unregisterAudio(elem.id);
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
}, [ctx, elem.id]);
|
|
371
|
+
}
|
|
372
|
+
return elem;
|
|
373
|
+
};
|
|
374
|
+
|
|
163
375
|
const CompositionManager = createContext({
|
|
164
376
|
compositions: [],
|
|
165
377
|
registerComposition: () => undefined,
|
|
@@ -179,7 +391,8 @@ const CompositionManager = createContext({
|
|
|
179
391
|
currentCompositionMetadata: null,
|
|
180
392
|
});
|
|
181
393
|
const compositionsRef = React.createRef();
|
|
182
|
-
const CompositionManagerProvider = ({ children }) => {
|
|
394
|
+
const CompositionManagerProvider = ({ children, numberOfAudioTags }) => {
|
|
395
|
+
var _a;
|
|
183
396
|
// Wontfix, expected to have
|
|
184
397
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
185
398
|
const [compositions, setCompositions] = useState([]);
|
|
@@ -293,7 +506,8 @@ const CompositionManagerProvider = ({ children }) => {
|
|
|
293
506
|
unregisterFolder,
|
|
294
507
|
currentCompositionMetadata,
|
|
295
508
|
]);
|
|
296
|
-
|
|
509
|
+
const composition = (_a = compositions.find((c) => c.id === currentComposition)) === null || _a === void 0 ? void 0 : _a.component;
|
|
510
|
+
return (jsx(CompositionManager.Provider, { value: contextValue, children: jsx(SharedAudioContextProvider, { numberOfAudioTags: numberOfAudioTags, component: composition !== null && composition !== void 0 ? composition : null, children: children }) }));
|
|
297
511
|
};
|
|
298
512
|
|
|
299
513
|
const HIDDEN_NAMES = ['__WEBPACK_DEFAULT_EXPORT__'];
|
|
@@ -1197,20 +1411,21 @@ const getMediaTime = ({ fps, frame, src, playbackRate, startFrom, mediaType, })
|
|
|
1197
1411
|
playbackRate,
|
|
1198
1412
|
startFrom,
|
|
1199
1413
|
});
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
if (mediaType === 'video') {
|
|
1414
|
+
const isChrome = typeof window !== 'undefined' &&
|
|
1415
|
+
window.navigator.userAgent.match(/Chrome\/([0-9]+)/);
|
|
1416
|
+
if (isChrome &&
|
|
1417
|
+
Number(isChrome[1]) < 112 &&
|
|
1418
|
+
mediaType === 'video' &&
|
|
1419
|
+
src.endsWith('.mp4')) {
|
|
1207
1420
|
// In Chrome, for MP4s, if 30fps, the first frame is still displayed at 0.033333
|
|
1208
1421
|
// even though after that it increases by 0.033333333 each.
|
|
1209
1422
|
// So frame = 0 in Remotion is like frame = 1 for the browser
|
|
1210
1423
|
return (expectedFrame + 1) / fps;
|
|
1211
1424
|
}
|
|
1212
|
-
// For
|
|
1213
|
-
|
|
1425
|
+
// For WebM videos, we need to add a little bit of shift to get the right frame.
|
|
1426
|
+
const msPerFrame = 1000 / fps;
|
|
1427
|
+
const msShift = msPerFrame / 2;
|
|
1428
|
+
return (expectedFrame * msPerFrame + msShift) / 1000;
|
|
1214
1429
|
};
|
|
1215
1430
|
|
|
1216
1431
|
const alreadyWarned = {};
|
|
@@ -1384,202 +1599,6 @@ const useMediaMutedState = () => {
|
|
|
1384
1599
|
}, [mediaMuted, setMediaMuted]);
|
|
1385
1600
|
};
|
|
1386
1601
|
|
|
1387
|
-
const EMPTY_AUDIO = 'data:audio/mp3;base64,/+MYxAAJcAV8AAgAABn//////+/gQ5BAMA+D4Pg+BAQBAEAwD4Pg+D4EBAEAQDAPg++hYBH///hUFQVBUFREDQNHmf///////+MYxBUGkAGIMAAAAP/29Xt6lUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV/+MYxDUAAANIAAAAAFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV';
|
|
1388
|
-
const compareProps = (obj1, obj2) => {
|
|
1389
|
-
const keysA = Object.keys(obj1).sort();
|
|
1390
|
-
const keysB = Object.keys(obj2).sort();
|
|
1391
|
-
if (keysA.length !== keysB.length) {
|
|
1392
|
-
return false;
|
|
1393
|
-
}
|
|
1394
|
-
for (let i = 0; i < keysA.length; i++) {
|
|
1395
|
-
// Not the same keys
|
|
1396
|
-
if (keysA[i] !== keysB[i]) {
|
|
1397
|
-
return false;
|
|
1398
|
-
}
|
|
1399
|
-
// Not the same values
|
|
1400
|
-
if (obj1[keysA[i]] !== obj2[keysB[i]]) {
|
|
1401
|
-
return false;
|
|
1402
|
-
}
|
|
1403
|
-
}
|
|
1404
|
-
return true;
|
|
1405
|
-
};
|
|
1406
|
-
const didPropChange = (key, newProp, prevProp) => {
|
|
1407
|
-
// /music.mp3 and http://localhost:3000/music.mp3 are the same
|
|
1408
|
-
if (key === 'src' &&
|
|
1409
|
-
!prevProp.startsWith('data:') &&
|
|
1410
|
-
!newProp.startsWith('data:')) {
|
|
1411
|
-
return (new URL(prevProp, window.location.origin).toString() !==
|
|
1412
|
-
new URL(newProp, window.location.origin).toString());
|
|
1413
|
-
}
|
|
1414
|
-
if (prevProp === newProp) {
|
|
1415
|
-
return false;
|
|
1416
|
-
}
|
|
1417
|
-
return true;
|
|
1418
|
-
};
|
|
1419
|
-
const SharedAudioContext = createContext(null);
|
|
1420
|
-
const SharedAudioContextProvider = ({ children, numberOfAudioTags }) => {
|
|
1421
|
-
const audios = useRef([]);
|
|
1422
|
-
const [initialNumberOfAudioTags] = useState(numberOfAudioTags);
|
|
1423
|
-
if (numberOfAudioTags !== initialNumberOfAudioTags) {
|
|
1424
|
-
throw new Error('The number of shared audio tags has changed dynamically. Once you have set this property, you cannot change it afterwards.');
|
|
1425
|
-
}
|
|
1426
|
-
const refs = useMemo(() => {
|
|
1427
|
-
return new Array(numberOfAudioTags).fill(true).map(() => {
|
|
1428
|
-
return { id: Math.random(), ref: createRef() };
|
|
1429
|
-
});
|
|
1430
|
-
}, [numberOfAudioTags]);
|
|
1431
|
-
const takenAudios = useRef(new Array(numberOfAudioTags).fill(false));
|
|
1432
|
-
const rerenderAudios = useCallback(() => {
|
|
1433
|
-
refs.forEach(({ ref, id }) => {
|
|
1434
|
-
var _a;
|
|
1435
|
-
const data = (_a = audios.current) === null || _a === void 0 ? void 0 : _a.find((a) => a.id === id);
|
|
1436
|
-
const { current } = ref;
|
|
1437
|
-
if (!current) {
|
|
1438
|
-
// Whole player has been unmounted, the refs don't exist anymore.
|
|
1439
|
-
// It is not an error anymore though
|
|
1440
|
-
return;
|
|
1441
|
-
}
|
|
1442
|
-
if (data === undefined) {
|
|
1443
|
-
current.src = EMPTY_AUDIO;
|
|
1444
|
-
return;
|
|
1445
|
-
}
|
|
1446
|
-
if (!data) {
|
|
1447
|
-
throw new TypeError('Expected audio data to be there');
|
|
1448
|
-
}
|
|
1449
|
-
Object.keys(data.props).forEach((key) => {
|
|
1450
|
-
// @ts-expect-error
|
|
1451
|
-
if (didPropChange(key, data.props[key], current[key])) {
|
|
1452
|
-
// @ts-expect-error
|
|
1453
|
-
current[key] = data.props[key];
|
|
1454
|
-
}
|
|
1455
|
-
});
|
|
1456
|
-
});
|
|
1457
|
-
}, [refs]);
|
|
1458
|
-
const registerAudio = useCallback((aud, audioId) => {
|
|
1459
|
-
var _a, _b;
|
|
1460
|
-
const found = (_a = audios.current) === null || _a === void 0 ? void 0 : _a.find((a) => a.audioId === audioId);
|
|
1461
|
-
if (found) {
|
|
1462
|
-
return found;
|
|
1463
|
-
}
|
|
1464
|
-
const firstFreeAudio = takenAudios.current.findIndex((a) => a === false);
|
|
1465
|
-
if (firstFreeAudio === -1) {
|
|
1466
|
-
throw new Error(`Tried to simultaneously mount ${numberOfAudioTags + 1} <Audio /> tags at the same time. With the current settings, the maximum amount of <Audio /> tags is limited to ${numberOfAudioTags} at the same time. Remotion pre-mounts silent audio tags to help avoid browser autoplay restrictions. See https://remotion.dev/docs/player/autoplay#use-the-numberofsharedaudiotags-property for more information on how to increase this limit.`);
|
|
1467
|
-
}
|
|
1468
|
-
const { id, ref } = refs[firstFreeAudio];
|
|
1469
|
-
const cloned = [...takenAudios.current];
|
|
1470
|
-
cloned[firstFreeAudio] = id;
|
|
1471
|
-
takenAudios.current = cloned;
|
|
1472
|
-
const newElem = {
|
|
1473
|
-
props: aud,
|
|
1474
|
-
id,
|
|
1475
|
-
el: ref,
|
|
1476
|
-
audioId,
|
|
1477
|
-
};
|
|
1478
|
-
(_b = audios.current) === null || _b === void 0 ? void 0 : _b.push(newElem);
|
|
1479
|
-
rerenderAudios();
|
|
1480
|
-
return newElem;
|
|
1481
|
-
}, [numberOfAudioTags, refs, rerenderAudios]);
|
|
1482
|
-
const unregisterAudio = useCallback((id) => {
|
|
1483
|
-
var _a;
|
|
1484
|
-
const cloned = [...takenAudios.current];
|
|
1485
|
-
const index = refs.findIndex((r) => r.id === id);
|
|
1486
|
-
if (index === -1) {
|
|
1487
|
-
throw new TypeError('Error occured in ');
|
|
1488
|
-
}
|
|
1489
|
-
cloned[index] = false;
|
|
1490
|
-
takenAudios.current = cloned;
|
|
1491
|
-
audios.current = (_a = audios.current) === null || _a === void 0 ? void 0 : _a.filter((a) => a.id !== id);
|
|
1492
|
-
rerenderAudios();
|
|
1493
|
-
}, [refs, rerenderAudios]);
|
|
1494
|
-
const updateAudio = useCallback(({ aud, audioId, id, }) => {
|
|
1495
|
-
var _a;
|
|
1496
|
-
let changed = false;
|
|
1497
|
-
audios.current = (_a = audios.current) === null || _a === void 0 ? void 0 : _a.map((prevA) => {
|
|
1498
|
-
if (prevA.id === id) {
|
|
1499
|
-
const isTheSame = compareProps(aud, prevA.props);
|
|
1500
|
-
if (isTheSame) {
|
|
1501
|
-
return prevA;
|
|
1502
|
-
}
|
|
1503
|
-
changed = true;
|
|
1504
|
-
return {
|
|
1505
|
-
...prevA,
|
|
1506
|
-
props: aud,
|
|
1507
|
-
audioId,
|
|
1508
|
-
};
|
|
1509
|
-
}
|
|
1510
|
-
return prevA;
|
|
1511
|
-
});
|
|
1512
|
-
if (changed) {
|
|
1513
|
-
rerenderAudios();
|
|
1514
|
-
}
|
|
1515
|
-
}, [rerenderAudios]);
|
|
1516
|
-
const playAllAudios = useCallback(() => {
|
|
1517
|
-
refs.forEach((ref) => {
|
|
1518
|
-
var _a;
|
|
1519
|
-
(_a = ref.ref.current) === null || _a === void 0 ? void 0 : _a.play();
|
|
1520
|
-
});
|
|
1521
|
-
}, [refs]);
|
|
1522
|
-
const value = useMemo(() => {
|
|
1523
|
-
return {
|
|
1524
|
-
registerAudio,
|
|
1525
|
-
unregisterAudio,
|
|
1526
|
-
updateAudio,
|
|
1527
|
-
playAllAudios,
|
|
1528
|
-
numberOfAudioTags,
|
|
1529
|
-
};
|
|
1530
|
-
}, [
|
|
1531
|
-
numberOfAudioTags,
|
|
1532
|
-
playAllAudios,
|
|
1533
|
-
registerAudio,
|
|
1534
|
-
unregisterAudio,
|
|
1535
|
-
updateAudio,
|
|
1536
|
-
]);
|
|
1537
|
-
return (jsxs(SharedAudioContext.Provider, { value: value, children: [refs.map(({ id, ref }) => {
|
|
1538
|
-
return jsx("audio", { ref: ref, src: EMPTY_AUDIO }, id);
|
|
1539
|
-
}), children] }));
|
|
1540
|
-
};
|
|
1541
|
-
const useSharedAudio = (aud, audioId) => {
|
|
1542
|
-
var _a;
|
|
1543
|
-
const ctx = useContext(SharedAudioContext);
|
|
1544
|
-
/**
|
|
1545
|
-
* We work around this in React 18 so an audio tag will only register itself once
|
|
1546
|
-
*/
|
|
1547
|
-
const [elem] = useState(() => {
|
|
1548
|
-
if (ctx && ctx.numberOfAudioTags > 0) {
|
|
1549
|
-
return ctx.registerAudio(aud, audioId);
|
|
1550
|
-
}
|
|
1551
|
-
return {
|
|
1552
|
-
el: React.createRef(),
|
|
1553
|
-
id: Math.random(),
|
|
1554
|
-
props: aud,
|
|
1555
|
-
audioId,
|
|
1556
|
-
};
|
|
1557
|
-
});
|
|
1558
|
-
/**
|
|
1559
|
-
* Effects in React 18 fire twice, and we are looking for a way to only fire it once.
|
|
1560
|
-
* - useInsertionEffect only fires once. If it's available we are in React 18.
|
|
1561
|
-
* - useLayoutEffect only fires once in React 17.
|
|
1562
|
-
*
|
|
1563
|
-
* Need to import it from React to fix React 17 ESM support.
|
|
1564
|
-
*/
|
|
1565
|
-
const effectToUse = (_a = React.useInsertionEffect) !== null && _a !== void 0 ? _a : React.useLayoutEffect;
|
|
1566
|
-
if (typeof document !== 'undefined') {
|
|
1567
|
-
effectToUse(() => {
|
|
1568
|
-
if (ctx && ctx.numberOfAudioTags > 0) {
|
|
1569
|
-
ctx.updateAudio({ id: elem.id, aud, audioId });
|
|
1570
|
-
}
|
|
1571
|
-
}, [aud, ctx, elem.id, audioId]);
|
|
1572
|
-
effectToUse(() => {
|
|
1573
|
-
return () => {
|
|
1574
|
-
if (ctx && ctx.numberOfAudioTags > 0) {
|
|
1575
|
-
ctx.unregisterAudio(elem.id);
|
|
1576
|
-
}
|
|
1577
|
-
};
|
|
1578
|
-
}, [ctx, elem.id]);
|
|
1579
|
-
}
|
|
1580
|
-
return elem;
|
|
1581
|
-
};
|
|
1582
|
-
|
|
1583
1602
|
const AudioForDevelopmentForwardRefFunction = (props, ref) => {
|
|
1584
1603
|
const [initialShouldPreMountAudioElements] = useState(props.shouldPreMountAudioTags);
|
|
1585
1604
|
if (props.shouldPreMountAudioTags !== initialShouldPreMountAudioElements) {
|
|
@@ -2169,11 +2188,7 @@ const RemotionRoot = ({ children, numberOfAudioTags }) => {
|
|
|
2169
2188
|
}
|
|
2170
2189
|
}
|
|
2171
2190
|
}, []);
|
|
2172
|
-
return (jsx(NonceContext.Provider, { value: nonceContext, children: jsx(TimelineContext.Provider, { value: timelineContextValue, children: jsx(SetTimelineContext.Provider, { value: setTimelineContextValue, children: jsx(PrefetchProvider, { children: jsx(NativeLayersProvider, { children: jsx(CompositionManagerProvider, { children: jsx(DurationsContextProvider, { children:
|
|
2173
|
-
// In the preview, which is mostly played on Desktop, we opt out of the autoplay policy fix as described in https://github.com/remotion-dev/remotion/pull/554, as it mostly applies to mobile.
|
|
2174
|
-
, {
|
|
2175
|
-
// In the preview, which is mostly played on Desktop, we opt out of the autoplay policy fix as described in https://github.com/remotion-dev/remotion/pull/554, as it mostly applies to mobile.
|
|
2176
|
-
numberOfAudioTags: numberOfAudioTags, children: children }) }) }) }) }) }) }) }));
|
|
2191
|
+
return (jsx(NonceContext.Provider, { value: nonceContext, children: jsx(TimelineContext.Provider, { value: timelineContextValue, children: jsx(SetTimelineContext.Provider, { value: setTimelineContextValue, children: jsx(PrefetchProvider, { children: jsx(NativeLayersProvider, { children: jsx(CompositionManagerProvider, { numberOfAudioTags: numberOfAudioTags, children: jsx(DurationsContextProvider, { children: children }) }) }) }) }) }) }));
|
|
2177
2192
|
};
|
|
2178
2193
|
|
|
2179
2194
|
const ENV_VARIABLES_ENV_NAME = 'ENV_VARIABLES';
|
package/dist/esm/version.mjs
CHANGED