remotion 4.0.310 → 4.0.312
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/audio/AudioForPreview.js +5 -1
- package/dist/cjs/audio/shared-audio-tags.d.ts +12 -2
- package/dist/cjs/audio/shared-audio-tags.js +15 -7
- package/dist/cjs/internals.d.ts +7 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/index.mjs +28 -11
- package/dist/esm/version.mjs +1 -1
- package/package.json +2 -2
|
@@ -82,7 +82,11 @@ const AudioForDevelopmentForwardRefFunction = (props, ref) => {
|
|
|
82
82
|
if (!context) {
|
|
83
83
|
throw new Error('SharedAudioContext not found');
|
|
84
84
|
}
|
|
85
|
-
const { el: audioRef, mediaElementSourceNode } = (0, shared_audio_tags_js_1.useSharedAudio)(
|
|
85
|
+
const { el: audioRef, mediaElementSourceNode } = (0, shared_audio_tags_js_1.useSharedAudio)({
|
|
86
|
+
aud: propsToPass,
|
|
87
|
+
audioId: id,
|
|
88
|
+
premounting: Boolean(sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.premounting),
|
|
89
|
+
});
|
|
86
90
|
(0, use_media_in_timeline_js_1.useMediaInTimeline)({
|
|
87
91
|
volume,
|
|
88
92
|
mediaVolume,
|
|
@@ -19,14 +19,20 @@ type AudioElem = {
|
|
|
19
19
|
el: React.RefObject<HTMLAudioElement | null>;
|
|
20
20
|
audioId: string;
|
|
21
21
|
mediaElementSourceNode: SharedElementSourceNode | null;
|
|
22
|
+
premounting: boolean;
|
|
22
23
|
};
|
|
23
24
|
type SharedContext = {
|
|
24
|
-
registerAudio: (
|
|
25
|
+
registerAudio: (options: {
|
|
26
|
+
aud: RemotionAudioProps;
|
|
27
|
+
audioId: string;
|
|
28
|
+
premounting: boolean;
|
|
29
|
+
}) => AudioElem;
|
|
25
30
|
unregisterAudio: (id: number) => void;
|
|
26
31
|
updateAudio: (options: {
|
|
27
32
|
id: number;
|
|
28
33
|
aud: RemotionAudioProps;
|
|
29
34
|
audioId: string;
|
|
35
|
+
premounting: boolean;
|
|
30
36
|
}) => void;
|
|
31
37
|
playAllAudios: () => void;
|
|
32
38
|
numberOfAudioTags: number;
|
|
@@ -39,5 +45,9 @@ export declare const SharedAudioContextProvider: React.FC<{
|
|
|
39
45
|
readonly component: LazyExoticComponent<ComponentType<Record<string, unknown>>> | null;
|
|
40
46
|
readonly audioLatencyHint: AudioContextLatencyCategory;
|
|
41
47
|
}>;
|
|
42
|
-
export declare const useSharedAudio: (aud
|
|
48
|
+
export declare const useSharedAudio: ({ aud, audioId, premounting, }: {
|
|
49
|
+
aud: RemotionAudioProps;
|
|
50
|
+
audioId: string;
|
|
51
|
+
premounting: boolean;
|
|
52
|
+
}) => AudioElem;
|
|
43
53
|
export {};
|
|
@@ -123,8 +123,9 @@ const SharedAudioContextProvider = ({ children, numberOfAudioTags, component, au
|
|
|
123
123
|
});
|
|
124
124
|
});
|
|
125
125
|
}, [refs]);
|
|
126
|
-
const registerAudio = (0, react_1.useCallback)((
|
|
126
|
+
const registerAudio = (0, react_1.useCallback)((options) => {
|
|
127
127
|
var _a, _b;
|
|
128
|
+
const { aud, audioId, premounting } = options;
|
|
128
129
|
const found = (_a = audios.current) === null || _a === void 0 ? void 0 : _a.find((a) => a.audioId === audioId);
|
|
129
130
|
if (found) {
|
|
130
131
|
return found;
|
|
@@ -143,6 +144,7 @@ const SharedAudioContextProvider = ({ children, numberOfAudioTags, component, au
|
|
|
143
144
|
el: ref,
|
|
144
145
|
audioId,
|
|
145
146
|
mediaElementSourceNode,
|
|
147
|
+
premounting,
|
|
146
148
|
};
|
|
147
149
|
(_b = audios.current) === null || _b === void 0 ? void 0 : _b.push(newElem);
|
|
148
150
|
rerenderAudios();
|
|
@@ -160,12 +162,12 @@ const SharedAudioContextProvider = ({ children, numberOfAudioTags, component, au
|
|
|
160
162
|
audios.current = (_a = audios.current) === null || _a === void 0 ? void 0 : _a.filter((a) => a.id !== id);
|
|
161
163
|
rerenderAudios();
|
|
162
164
|
}, [refs, rerenderAudios]);
|
|
163
|
-
const updateAudio = (0, react_1.useCallback)(({ aud, audioId, id, }) => {
|
|
165
|
+
const updateAudio = (0, react_1.useCallback)(({ aud, audioId, id, premounting, }) => {
|
|
164
166
|
var _a;
|
|
165
167
|
let changed = false;
|
|
166
168
|
audios.current = (_a = audios.current) === null || _a === void 0 ? void 0 : _a.map((prevA) => {
|
|
167
169
|
if (prevA.id === id) {
|
|
168
|
-
const isTheSame = compareProps(aud, prevA.props);
|
|
170
|
+
const isTheSame = compareProps(aud, prevA.props) && prevA.premounting === premounting;
|
|
169
171
|
if (isTheSame) {
|
|
170
172
|
return prevA;
|
|
171
173
|
}
|
|
@@ -173,6 +175,7 @@ const SharedAudioContextProvider = ({ children, numberOfAudioTags, component, au
|
|
|
173
175
|
return {
|
|
174
176
|
...prevA,
|
|
175
177
|
props: aud,
|
|
178
|
+
premounting,
|
|
176
179
|
audioId,
|
|
177
180
|
};
|
|
178
181
|
}
|
|
@@ -185,6 +188,10 @@ const SharedAudioContextProvider = ({ children, numberOfAudioTags, component, au
|
|
|
185
188
|
const mountTime = (0, log_level_context_js_1.useMountTime)();
|
|
186
189
|
const playAllAudios = (0, react_1.useCallback)(() => {
|
|
187
190
|
refs.forEach((ref) => {
|
|
191
|
+
const audio = audios.current.find((a) => a.el === ref.ref);
|
|
192
|
+
if (audio === null || audio === void 0 ? void 0 : audio.premounting) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
188
195
|
(0, play_and_handle_not_allowed_error_js_1.playAndHandleNotAllowedError)({
|
|
189
196
|
mediaRef: ref.ref,
|
|
190
197
|
mediaType: 'audio',
|
|
@@ -238,7 +245,7 @@ const SharedAudioContextProvider = ({ children, numberOfAudioTags, component, au
|
|
|
238
245
|
}), children] }));
|
|
239
246
|
};
|
|
240
247
|
exports.SharedAudioContextProvider = SharedAudioContextProvider;
|
|
241
|
-
const useSharedAudio = (aud, audioId) => {
|
|
248
|
+
const useSharedAudio = ({ aud, audioId, premounting, }) => {
|
|
242
249
|
var _a;
|
|
243
250
|
const ctx = (0, react_1.useContext)(exports.SharedAudioContext);
|
|
244
251
|
/**
|
|
@@ -246,7 +253,7 @@ const useSharedAudio = (aud, audioId) => {
|
|
|
246
253
|
*/
|
|
247
254
|
const [elem] = (0, react_1.useState)(() => {
|
|
248
255
|
if (ctx && ctx.numberOfAudioTags > 0) {
|
|
249
|
-
return ctx.registerAudio(aud, audioId);
|
|
256
|
+
return ctx.registerAudio({ aud, audioId, premounting });
|
|
250
257
|
}
|
|
251
258
|
const el = react_1.default.createRef();
|
|
252
259
|
const mediaElementSourceNode = (ctx === null || ctx === void 0 ? void 0 : ctx.audioContext)
|
|
@@ -261,6 +268,7 @@ const useSharedAudio = (aud, audioId) => {
|
|
|
261
268
|
props: aud,
|
|
262
269
|
audioId,
|
|
263
270
|
mediaElementSourceNode,
|
|
271
|
+
premounting,
|
|
264
272
|
};
|
|
265
273
|
});
|
|
266
274
|
/**
|
|
@@ -274,9 +282,9 @@ const useSharedAudio = (aud, audioId) => {
|
|
|
274
282
|
if (typeof document !== 'undefined') {
|
|
275
283
|
effectToUse(() => {
|
|
276
284
|
if (ctx && ctx.numberOfAudioTags > 0) {
|
|
277
|
-
ctx.updateAudio({ id: elem.id, aud, audioId });
|
|
285
|
+
ctx.updateAudio({ id: elem.id, aud, audioId, premounting });
|
|
278
286
|
}
|
|
279
|
-
}, [aud, ctx, elem.id, audioId]);
|
|
287
|
+
}, [aud, ctx, elem.id, audioId, premounting]);
|
|
280
288
|
effectToUse(() => {
|
|
281
289
|
return () => {
|
|
282
290
|
if (ctx && ctx.numberOfAudioTags > 0) {
|
package/dist/cjs/internals.d.ts
CHANGED
|
@@ -49,18 +49,24 @@ export declare const Internals: {
|
|
|
49
49
|
readonly SetMediaVolumeContext: import("react").Context<SetMediaVolumeContextValue>;
|
|
50
50
|
readonly getRemotionEnvironment: () => RemotionEnvironment;
|
|
51
51
|
readonly SharedAudioContext: import("react").Context<{
|
|
52
|
-
registerAudio: (
|
|
52
|
+
registerAudio: (options: {
|
|
53
|
+
aud: import("./index.js").RemotionAudioProps;
|
|
54
|
+
audioId: string;
|
|
55
|
+
premounting: boolean;
|
|
56
|
+
}) => {
|
|
53
57
|
id: number;
|
|
54
58
|
props: import("./index.js").RemotionAudioProps;
|
|
55
59
|
el: React.RefObject<HTMLAudioElement | null>;
|
|
56
60
|
audioId: string;
|
|
57
61
|
mediaElementSourceNode: import("./audio/shared-element-source-node.js").SharedElementSourceNode | null;
|
|
62
|
+
premounting: boolean;
|
|
58
63
|
};
|
|
59
64
|
unregisterAudio: (id: number) => void;
|
|
60
65
|
updateAudio: (options: {
|
|
61
66
|
id: number;
|
|
62
67
|
aud: import("./index.js").RemotionAudioProps;
|
|
63
68
|
audioId: string;
|
|
69
|
+
premounting: boolean;
|
|
64
70
|
}) => void;
|
|
65
71
|
playAllAudios: () => void;
|
|
66
72
|
numberOfAudioTags: number;
|
package/dist/cjs/version.d.ts
CHANGED
package/dist/cjs/version.js
CHANGED
package/dist/esm/index.mjs
CHANGED
|
@@ -104,7 +104,7 @@ function truthy(value) {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
// src/version.ts
|
|
107
|
-
var VERSION = "4.0.
|
|
107
|
+
var VERSION = "4.0.312";
|
|
108
108
|
|
|
109
109
|
// src/multiple-versions-warning.ts
|
|
110
110
|
var checkMultipleRemotionVersions = () => {
|
|
@@ -2803,7 +2803,8 @@ var SharedAudioContextProvider = ({ children, numberOfAudioTags, component, audi
|
|
|
2803
2803
|
});
|
|
2804
2804
|
});
|
|
2805
2805
|
}, [refs]);
|
|
2806
|
-
const registerAudio = useCallback6((
|
|
2806
|
+
const registerAudio = useCallback6((options) => {
|
|
2807
|
+
const { aud, audioId, premounting } = options;
|
|
2807
2808
|
const found = audios.current?.find((a) => a.audioId === audioId);
|
|
2808
2809
|
if (found) {
|
|
2809
2810
|
return found;
|
|
@@ -2821,7 +2822,8 @@ var SharedAudioContextProvider = ({ children, numberOfAudioTags, component, audi
|
|
|
2821
2822
|
id,
|
|
2822
2823
|
el: ref,
|
|
2823
2824
|
audioId,
|
|
2824
|
-
mediaElementSourceNode
|
|
2825
|
+
mediaElementSourceNode,
|
|
2826
|
+
premounting
|
|
2825
2827
|
};
|
|
2826
2828
|
audios.current?.push(newElem);
|
|
2827
2829
|
rerenderAudios();
|
|
@@ -2841,12 +2843,13 @@ var SharedAudioContextProvider = ({ children, numberOfAudioTags, component, audi
|
|
|
2841
2843
|
const updateAudio = useCallback6(({
|
|
2842
2844
|
aud,
|
|
2843
2845
|
audioId,
|
|
2844
|
-
id
|
|
2846
|
+
id,
|
|
2847
|
+
premounting
|
|
2845
2848
|
}) => {
|
|
2846
2849
|
let changed = false;
|
|
2847
2850
|
audios.current = audios.current?.map((prevA) => {
|
|
2848
2851
|
if (prevA.id === id) {
|
|
2849
|
-
const isTheSame = compareProps(aud, prevA.props);
|
|
2852
|
+
const isTheSame = compareProps(aud, prevA.props) && prevA.premounting === premounting;
|
|
2850
2853
|
if (isTheSame) {
|
|
2851
2854
|
return prevA;
|
|
2852
2855
|
}
|
|
@@ -2854,6 +2857,7 @@ var SharedAudioContextProvider = ({ children, numberOfAudioTags, component, audi
|
|
|
2854
2857
|
return {
|
|
2855
2858
|
...prevA,
|
|
2856
2859
|
props: aud,
|
|
2860
|
+
premounting,
|
|
2857
2861
|
audioId
|
|
2858
2862
|
};
|
|
2859
2863
|
}
|
|
@@ -2866,6 +2870,10 @@ var SharedAudioContextProvider = ({ children, numberOfAudioTags, component, audi
|
|
|
2866
2870
|
const mountTime = useMountTime();
|
|
2867
2871
|
const playAllAudios = useCallback6(() => {
|
|
2868
2872
|
refs.forEach((ref) => {
|
|
2873
|
+
const audio = audios.current.find((a) => a.el === ref.ref);
|
|
2874
|
+
if (audio?.premounting) {
|
|
2875
|
+
return;
|
|
2876
|
+
}
|
|
2869
2877
|
playAndHandleNotAllowedError({
|
|
2870
2878
|
mediaRef: ref.ref,
|
|
2871
2879
|
mediaType: "audio",
|
|
@@ -2918,11 +2926,15 @@ var SharedAudioContextProvider = ({ children, numberOfAudioTags, component, audi
|
|
|
2918
2926
|
]
|
|
2919
2927
|
});
|
|
2920
2928
|
};
|
|
2921
|
-
var useSharedAudio = (
|
|
2929
|
+
var useSharedAudio = ({
|
|
2930
|
+
aud,
|
|
2931
|
+
audioId,
|
|
2932
|
+
premounting
|
|
2933
|
+
}) => {
|
|
2922
2934
|
const ctx = useContext14(SharedAudioContext);
|
|
2923
2935
|
const [elem] = useState9(() => {
|
|
2924
2936
|
if (ctx && ctx.numberOfAudioTags > 0) {
|
|
2925
|
-
return ctx.registerAudio(aud, audioId);
|
|
2937
|
+
return ctx.registerAudio({ aud, audioId, premounting });
|
|
2926
2938
|
}
|
|
2927
2939
|
const el = React13.createRef();
|
|
2928
2940
|
const mediaElementSourceNode = ctx?.audioContext ? makeSharedElementSourceNode({
|
|
@@ -2934,16 +2946,17 @@ var useSharedAudio = (aud, audioId) => {
|
|
|
2934
2946
|
id: Math.random(),
|
|
2935
2947
|
props: aud,
|
|
2936
2948
|
audioId,
|
|
2937
|
-
mediaElementSourceNode
|
|
2949
|
+
mediaElementSourceNode,
|
|
2950
|
+
premounting
|
|
2938
2951
|
};
|
|
2939
2952
|
});
|
|
2940
2953
|
const effectToUse = React13.useInsertionEffect ?? React13.useLayoutEffect;
|
|
2941
2954
|
if (typeof document !== "undefined") {
|
|
2942
2955
|
effectToUse(() => {
|
|
2943
2956
|
if (ctx && ctx.numberOfAudioTags > 0) {
|
|
2944
|
-
ctx.updateAudio({ id: elem.id, aud, audioId });
|
|
2957
|
+
ctx.updateAudio({ id: elem.id, aud, audioId, premounting });
|
|
2945
2958
|
}
|
|
2946
|
-
}, [aud, ctx, elem.id, audioId]);
|
|
2959
|
+
}, [aud, ctx, elem.id, audioId, premounting]);
|
|
2947
2960
|
effectToUse(() => {
|
|
2948
2961
|
return () => {
|
|
2949
2962
|
if (ctx && ctx.numberOfAudioTags > 0) {
|
|
@@ -4322,7 +4335,11 @@ var AudioForDevelopmentForwardRefFunction = (props, ref) => {
|
|
|
4322
4335
|
if (!context) {
|
|
4323
4336
|
throw new Error("SharedAudioContext not found");
|
|
4324
4337
|
}
|
|
4325
|
-
const { el: audioRef, mediaElementSourceNode } = useSharedAudio(
|
|
4338
|
+
const { el: audioRef, mediaElementSourceNode } = useSharedAudio({
|
|
4339
|
+
aud: propsToPass,
|
|
4340
|
+
audioId: id,
|
|
4341
|
+
premounting: Boolean(sequenceContext?.premounting)
|
|
4342
|
+
});
|
|
4326
4343
|
useMediaInTimeline({
|
|
4327
4344
|
volume,
|
|
4328
4345
|
mediaVolume,
|
package/dist/esm/version.mjs
CHANGED
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"url": "https://github.com/remotion-dev/remotion/tree/main/packages/core"
|
|
4
4
|
},
|
|
5
5
|
"name": "remotion",
|
|
6
|
-
"version": "4.0.
|
|
6
|
+
"version": "4.0.312",
|
|
7
7
|
"description": "Make videos programmatically",
|
|
8
8
|
"main": "dist/cjs/index.js",
|
|
9
9
|
"types": "dist/cjs/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"webpack": "5.96.1",
|
|
29
29
|
"zod": "3.22.3",
|
|
30
30
|
"eslint": "9.19.0",
|
|
31
|
-
"@remotion/eslint-config-internal": "4.0.
|
|
31
|
+
"@remotion/eslint-config-internal": "4.0.312"
|
|
32
32
|
},
|
|
33
33
|
"keywords": [
|
|
34
34
|
"remotion",
|