remotion 4.0.0-alpha11 → 4.0.0-alpha13
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/AssetManager.d.ts +11 -0
- package/dist/cjs/AssetManager.js +40 -0
- package/dist/cjs/CompositionManager.js +3 -41
- package/dist/cjs/CompositionManagerContext.d.ts +1 -7
- package/dist/cjs/CompositionManagerContext.js +0 -6
- package/dist/cjs/RemotionRoot.js +5 -4
- package/dist/cjs/ResolveCompositionConfig.d.ts +2 -0
- package/dist/cjs/ResolveCompositionConfig.js +13 -5
- package/dist/cjs/Sequence.js +2 -2
- package/dist/cjs/SequenceManager.d.ts +11 -0
- package/dist/cjs/SequenceManager.js +57 -0
- package/dist/cjs/audio/AudioForRendering.js +2 -2
- package/dist/cjs/internals.d.ts +2 -1
- package/dist/cjs/internals.js +4 -1
- package/dist/cjs/nonce.js +6 -0
- package/dist/cjs/resolve-video-config.js +9 -4
- package/dist/cjs/setup-env-variables.d.ts +0 -1
- package/dist/cjs/setup-env-variables.js +4 -6
- package/dist/cjs/use-media-in-timeline.js +2 -2
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/video/OffthreadVideoForRendering.js +2 -2
- package/dist/cjs/video/VideoForRendering.js +2 -2
- package/dist/cjs/wrap-remotion-context.d.ts +2 -0
- package/dist/cjs/wrap-remotion-context.js +9 -1
- package/dist/esm/index.mjs +126 -86
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
- package/dist/cjs/config.d.ts +0 -294
- package/dist/cjs/config.js +0 -21
- package/dist/cjs/validation/validate-offthreadvideo-image-format.d.ts +0 -1
- package/dist/cjs/validation/validate-offthreadvideo-image-format.js +0 -15
|
@@ -29,6 +29,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
29
29
|
// such as in React Three Fiber. All the contexts need to be passed again
|
|
30
30
|
// for them to be useable
|
|
31
31
|
const react_1 = __importStar(require("react"));
|
|
32
|
+
const AssetManager_js_1 = require("./AssetManager.js");
|
|
32
33
|
const CanUseRemotionHooks_js_1 = require("./CanUseRemotionHooks.js");
|
|
33
34
|
const CompositionManagerContext_js_1 = require("./CompositionManagerContext.js");
|
|
34
35
|
const NativeLayers_js_1 = require("./NativeLayers.js");
|
|
@@ -36,6 +37,7 @@ const nonce_js_1 = require("./nonce.js");
|
|
|
36
37
|
const prefetch_state_js_1 = require("./prefetch-state.js");
|
|
37
38
|
const ResolveCompositionConfig_js_1 = require("./ResolveCompositionConfig.js");
|
|
38
39
|
const SequenceContext_js_1 = require("./SequenceContext.js");
|
|
40
|
+
const SequenceManager_js_1 = require("./SequenceManager.js");
|
|
39
41
|
const timeline_position_state_js_1 = require("./timeline-position-state.js");
|
|
40
42
|
function useRemotionContexts() {
|
|
41
43
|
const compositionManagerCtx = react_1.default.useContext(CompositionManagerContext_js_1.CompositionManager);
|
|
@@ -47,6 +49,8 @@ function useRemotionContexts() {
|
|
|
47
49
|
const nativeLayersContext = react_1.default.useContext(NativeLayers_js_1.NativeLayersContext);
|
|
48
50
|
const preloadContext = react_1.default.useContext(prefetch_state_js_1.PreloadContext);
|
|
49
51
|
const resolveCompositionContext = react_1.default.useContext(ResolveCompositionConfig_js_1.ResolveCompositionContext);
|
|
52
|
+
const assetManagerContext = react_1.default.useContext(AssetManager_js_1.AssetManager);
|
|
53
|
+
const sequenceManagerContext = react_1.default.useContext(SequenceManager_js_1.SequenceManager);
|
|
50
54
|
return (0, react_1.useMemo)(() => ({
|
|
51
55
|
compositionManagerCtx,
|
|
52
56
|
timelineContext,
|
|
@@ -57,6 +61,8 @@ function useRemotionContexts() {
|
|
|
57
61
|
nativeLayersContext,
|
|
58
62
|
preloadContext,
|
|
59
63
|
resolveCompositionContext,
|
|
64
|
+
assetManagerContext,
|
|
65
|
+
sequenceManagerContext,
|
|
60
66
|
}), [
|
|
61
67
|
compositionManagerCtx,
|
|
62
68
|
nonceContext,
|
|
@@ -67,11 +73,13 @@ function useRemotionContexts() {
|
|
|
67
73
|
nativeLayersContext,
|
|
68
74
|
preloadContext,
|
|
69
75
|
resolveCompositionContext,
|
|
76
|
+
assetManagerContext,
|
|
77
|
+
sequenceManagerContext,
|
|
70
78
|
]);
|
|
71
79
|
}
|
|
72
80
|
exports.useRemotionContexts = useRemotionContexts;
|
|
73
81
|
const RemotionContextProvider = (props) => {
|
|
74
82
|
const { children, contexts } = props;
|
|
75
|
-
return ((0, jsx_runtime_1.jsx)(CanUseRemotionHooks_js_1.CanUseRemotionHooks.Provider, { value: contexts.canUseRemotionHooksContext, children: (0, jsx_runtime_1.jsx)(nonce_js_1.NonceContext.Provider, { value: contexts.nonceContext, children: (0, jsx_runtime_1.jsx)(NativeLayers_js_1.NativeLayersContext.Provider, { value: contexts.nativeLayersContext, children: (0, jsx_runtime_1.jsx)(prefetch_state_js_1.PreloadContext.Provider, { value: contexts.preloadContext, children: (0, jsx_runtime_1.jsx)(CompositionManagerContext_js_1.CompositionManager.Provider, { value: contexts.compositionManagerCtx, children: (0, jsx_runtime_1.jsx)(ResolveCompositionConfig_js_1.ResolveCompositionContext.Provider, { value: contexts.resolveCompositionContext, children: (0, jsx_runtime_1.jsx)(timeline_position_state_js_1.TimelineContext.Provider, { value: contexts.timelineContext, children: (0, jsx_runtime_1.jsx)(timeline_position_state_js_1.SetTimelineContext.Provider, { value: contexts.setTimelineContext, children: (0, jsx_runtime_1.jsx)(SequenceContext_js_1.SequenceContext.Provider, { value: contexts.sequenceContext, children: children }) }) }) }) }) }) }) }) }));
|
|
83
|
+
return ((0, jsx_runtime_1.jsx)(CanUseRemotionHooks_js_1.CanUseRemotionHooks.Provider, { value: contexts.canUseRemotionHooksContext, children: (0, jsx_runtime_1.jsx)(nonce_js_1.NonceContext.Provider, { value: contexts.nonceContext, children: (0, jsx_runtime_1.jsx)(NativeLayers_js_1.NativeLayersContext.Provider, { value: contexts.nativeLayersContext, children: (0, jsx_runtime_1.jsx)(prefetch_state_js_1.PreloadContext.Provider, { value: contexts.preloadContext, children: (0, jsx_runtime_1.jsx)(CompositionManagerContext_js_1.CompositionManager.Provider, { value: contexts.compositionManagerCtx, children: (0, jsx_runtime_1.jsx)(SequenceManager_js_1.SequenceManager.Provider, { value: contexts.sequenceManagerContext, children: (0, jsx_runtime_1.jsx)(AssetManager_js_1.AssetManager.Provider, { value: contexts.assetManagerContext, children: (0, jsx_runtime_1.jsx)(ResolveCompositionConfig_js_1.ResolveCompositionContext.Provider, { value: contexts.resolveCompositionContext, children: (0, jsx_runtime_1.jsx)(timeline_position_state_js_1.TimelineContext.Provider, { value: contexts.timelineContext, children: (0, jsx_runtime_1.jsx)(timeline_position_state_js_1.SetTimelineContext.Provider, { value: contexts.setTimelineContext, children: (0, jsx_runtime_1.jsx)(SequenceContext_js_1.SequenceContext.Provider, { value: contexts.sequenceContext, children: children }) }) }) }) }) }) }) }) }) }) }));
|
|
76
84
|
};
|
|
77
85
|
exports.RemotionContextProvider = RemotionContextProvider;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { createContext, useState, useMemo, useLayoutEffect, useContext, useEffect, forwardRef, Children, isValidElement, useCallback, createRef, useImperativeHandle, useReducer,
|
|
1
|
+
import React, { createContext, useState, useMemo, useLayoutEffect, useContext, useEffect, forwardRef, Children, isValidElement, useRef, useCallback, createRef, useImperativeHandle, useReducer, Suspense } from 'react';
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
4
|
|
|
@@ -58,7 +58,7 @@ function truthy(value) {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
// Automatically generated on publish
|
|
61
|
-
const VERSION = '4.0.0-
|
|
61
|
+
const VERSION = '4.0.0-alpha13';
|
|
62
62
|
|
|
63
63
|
const checkMultipleRemotionVersions = () => {
|
|
64
64
|
if (typeof globalThis === 'undefined') {
|
|
@@ -208,25 +208,6 @@ const useRemotionEnvironment = () => {
|
|
|
208
208
|
return getRemotionEnvironment();
|
|
209
209
|
};
|
|
210
210
|
|
|
211
|
-
const CompositionManager = createContext({
|
|
212
|
-
compositions: [],
|
|
213
|
-
registerComposition: () => undefined,
|
|
214
|
-
unregisterComposition: () => undefined,
|
|
215
|
-
registerFolder: () => undefined,
|
|
216
|
-
unregisterFolder: () => undefined,
|
|
217
|
-
currentComposition: null,
|
|
218
|
-
setCurrentComposition: () => undefined,
|
|
219
|
-
setCurrentCompositionMetadata: () => undefined,
|
|
220
|
-
registerSequence: () => undefined,
|
|
221
|
-
unregisterSequence: () => undefined,
|
|
222
|
-
registerAsset: () => undefined,
|
|
223
|
-
unregisterAsset: () => undefined,
|
|
224
|
-
sequences: [],
|
|
225
|
-
assets: [],
|
|
226
|
-
folders: [],
|
|
227
|
-
currentCompositionMetadata: null,
|
|
228
|
-
});
|
|
229
|
-
|
|
230
211
|
const HIDDEN_NAMES = ['__WEBPACK_DEFAULT_EXPORT__'];
|
|
231
212
|
const getTimelineClipName = (children) => {
|
|
232
213
|
var _a;
|
|
@@ -255,7 +236,13 @@ const NonceContext = createContext({
|
|
|
255
236
|
const useNonce = () => {
|
|
256
237
|
const context = useContext(NonceContext);
|
|
257
238
|
const [nonce, setNonce] = useState(() => context.getNonce());
|
|
239
|
+
const lastContext = useRef(context);
|
|
240
|
+
// Only if context changes, but not initially
|
|
258
241
|
useEffect(() => {
|
|
242
|
+
if (lastContext.current === context) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
lastContext.current = context;
|
|
259
246
|
setNonce(context.getNonce);
|
|
260
247
|
}, [context]);
|
|
261
248
|
return nonce;
|
|
@@ -263,6 +250,48 @@ const useNonce = () => {
|
|
|
263
250
|
|
|
264
251
|
const SequenceContext = createContext(null);
|
|
265
252
|
|
|
253
|
+
const SequenceManager = React.createContext({
|
|
254
|
+
registerSequence: () => {
|
|
255
|
+
throw new Error('SequenceManagerContext not initialized');
|
|
256
|
+
},
|
|
257
|
+
unregisterSequence: () => {
|
|
258
|
+
throw new Error('SequenceManagerContext not initialized');
|
|
259
|
+
},
|
|
260
|
+
sequences: [],
|
|
261
|
+
});
|
|
262
|
+
const SequenceManagerProvider = ({ children }) => {
|
|
263
|
+
const [sequences, setSequences] = useState([]);
|
|
264
|
+
const registerSequence = useCallback((seq) => {
|
|
265
|
+
setSequences((seqs) => {
|
|
266
|
+
return [...seqs, seq];
|
|
267
|
+
});
|
|
268
|
+
}, []);
|
|
269
|
+
const unregisterSequence = useCallback((seq) => {
|
|
270
|
+
setSequences((seqs) => seqs.filter((s) => s.id !== seq));
|
|
271
|
+
}, []);
|
|
272
|
+
const context = useMemo(() => {
|
|
273
|
+
return {
|
|
274
|
+
registerSequence,
|
|
275
|
+
sequences,
|
|
276
|
+
unregisterSequence,
|
|
277
|
+
};
|
|
278
|
+
}, [registerSequence, sequences, unregisterSequence]);
|
|
279
|
+
return (jsx(SequenceManager.Provider, { value: context, children: children }));
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
const CompositionManager = createContext({
|
|
283
|
+
compositions: [],
|
|
284
|
+
registerComposition: () => undefined,
|
|
285
|
+
unregisterComposition: () => undefined,
|
|
286
|
+
registerFolder: () => undefined,
|
|
287
|
+
unregisterFolder: () => undefined,
|
|
288
|
+
currentComposition: null,
|
|
289
|
+
setCurrentComposition: () => undefined,
|
|
290
|
+
setCurrentCompositionMetadata: () => undefined,
|
|
291
|
+
folders: [],
|
|
292
|
+
currentCompositionMetadata: null,
|
|
293
|
+
});
|
|
294
|
+
|
|
266
295
|
let didWarnSSRImport = false;
|
|
267
296
|
const warnOnceSSRImport = () => {
|
|
268
297
|
if (didWarnSSRImport) {
|
|
@@ -349,14 +378,18 @@ const validateDurationInFrames = ({ allowFloats, component, durationInFrames, })
|
|
|
349
378
|
};
|
|
350
379
|
|
|
351
380
|
const resolveVideoConfig = ({ composition, editorProps: editorPropsOrUndefined, signal, }) => {
|
|
352
|
-
var _a, _b, _c;
|
|
381
|
+
var _a, _b, _c, _d;
|
|
353
382
|
const calculatedProm = composition.calculateMetadata
|
|
354
383
|
? composition.calculateMetadata({
|
|
355
384
|
defaultProps: (_a = composition.defaultProps) !== null && _a !== void 0 ? _a : {},
|
|
356
385
|
props: {
|
|
357
386
|
...((_b = composition.defaultProps) !== null && _b !== void 0 ? _b : {}),
|
|
358
387
|
...(editorPropsOrUndefined !== null && editorPropsOrUndefined !== void 0 ? editorPropsOrUndefined : {}),
|
|
359
|
-
...(typeof window === 'undefined'
|
|
388
|
+
...(typeof window === 'undefined' ||
|
|
389
|
+
getRemotionEnvironment() === 'player-development' ||
|
|
390
|
+
getRemotionEnvironment() === 'player-production'
|
|
391
|
+
? {}
|
|
392
|
+
: (_c = getInputProps()) !== null && _c !== void 0 ? _c : {}),
|
|
360
393
|
},
|
|
361
394
|
abortSignal: signal,
|
|
362
395
|
})
|
|
@@ -375,7 +408,7 @@ const resolveVideoConfig = ({ composition, editorProps: editorPropsOrUndefined,
|
|
|
375
408
|
fps,
|
|
376
409
|
durationInFrames,
|
|
377
410
|
id: composition.id,
|
|
378
|
-
defaultProps:
|
|
411
|
+
defaultProps: c.props,
|
|
379
412
|
};
|
|
380
413
|
});
|
|
381
414
|
}
|
|
@@ -386,7 +419,7 @@ const resolveVideoConfig = ({ composition, editorProps: editorPropsOrUndefined,
|
|
|
386
419
|
return {
|
|
387
420
|
...data,
|
|
388
421
|
id: composition.id,
|
|
389
|
-
defaultProps:
|
|
422
|
+
defaultProps: ((_d = calculatedProm === null || calculatedProm === void 0 ? void 0 : calculatedProm.props) !== null && _d !== void 0 ? _d : {}),
|
|
390
423
|
};
|
|
391
424
|
};
|
|
392
425
|
const validateCalculated = ({ composition, calculated, }) => {
|
|
@@ -508,7 +541,7 @@ const ResolveCompositionConfig = ({ children }) => {
|
|
|
508
541
|
}, [allEditorProps, compositions, currentComposition, doResolution]);
|
|
509
542
|
const isTheSame = (selectedComposition === null || selectedComposition === void 0 ? void 0 : selectedComposition.id) === (renderModalComposition === null || renderModalComposition === void 0 ? void 0 : renderModalComposition.id);
|
|
510
543
|
useEffect(() => {
|
|
511
|
-
if (selectedComposition) {
|
|
544
|
+
if (selectedComposition && needsResolution(selectedComposition)) {
|
|
512
545
|
const controller = doResolution(selectedComposition, selectedEditorProps);
|
|
513
546
|
return () => {
|
|
514
547
|
controller.abort();
|
|
@@ -543,6 +576,9 @@ const ResolveCompositionConfig = ({ children }) => {
|
|
|
543
576
|
}, [compositions, resolvedConfigs]);
|
|
544
577
|
return (jsx(ResolveCompositionContext.Provider, { value: resolvedConfigsIncludingStaticOnes, children: children }));
|
|
545
578
|
};
|
|
579
|
+
const needsResolution = (composition) => {
|
|
580
|
+
return Boolean(composition.calculateMetadata);
|
|
581
|
+
};
|
|
546
582
|
const useResolvedVideoConfig = (preferredCompositionId) => {
|
|
547
583
|
const context = useContext(ResolveCompositionContext);
|
|
548
584
|
const { props: allEditorProps } = useContext(EditorPropsContext);
|
|
@@ -558,8 +594,7 @@ const useResolvedVideoConfig = (preferredCompositionId) => {
|
|
|
558
594
|
if (!composition) {
|
|
559
595
|
return null;
|
|
560
596
|
}
|
|
561
|
-
|
|
562
|
-
if (needsResolution === null) {
|
|
597
|
+
if (!needsResolution(composition)) {
|
|
563
598
|
return {
|
|
564
599
|
type: 'success',
|
|
565
600
|
result: {
|
|
@@ -567,7 +602,11 @@ const useResolvedVideoConfig = (preferredCompositionId) => {
|
|
|
567
602
|
defaultProps: {
|
|
568
603
|
...((_a = composition.defaultProps) !== null && _a !== void 0 ? _a : {}),
|
|
569
604
|
...(selectedEditorProps !== null && selectedEditorProps !== void 0 ? selectedEditorProps : {}),
|
|
570
|
-
...(typeof window === 'undefined'
|
|
605
|
+
...(typeof window === 'undefined' ||
|
|
606
|
+
getRemotionEnvironment() === 'player-development' ||
|
|
607
|
+
getRemotionEnvironment() === 'player-production'
|
|
608
|
+
? {}
|
|
609
|
+
: (_b = getInputProps()) !== null && _b !== void 0 ? _b : {}),
|
|
571
610
|
},
|
|
572
611
|
},
|
|
573
612
|
};
|
|
@@ -750,7 +789,7 @@ const SequenceRefForwardingFunction = ({ from = 0, durationInFrames = Infinity,
|
|
|
750
789
|
? Math.min(parentSequence.durationInFrames - from, durationInFrames)
|
|
751
790
|
: durationInFrames;
|
|
752
791
|
const actualDurationInFrames = Math.max(0, Math.min(videoConfig.durationInFrames - from, parentSequenceDuration));
|
|
753
|
-
const { registerSequence, unregisterSequence } = useContext(
|
|
792
|
+
const { registerSequence, unregisterSequence } = useContext(SequenceManager);
|
|
754
793
|
const contextValue = useMemo(() => {
|
|
755
794
|
var _a;
|
|
756
795
|
return {
|
|
@@ -1234,7 +1273,7 @@ const useMediaInTimeline = ({ volume, mediaVolume, mediaRef, src, mediaType, pla
|
|
|
1234
1273
|
: 0;
|
|
1235
1274
|
const [playing] = usePlayingState();
|
|
1236
1275
|
const startsAt = useMediaStartsAt();
|
|
1237
|
-
const { registerSequence, unregisterSequence } = useContext(
|
|
1276
|
+
const { registerSequence, unregisterSequence } = useContext(SequenceManager);
|
|
1238
1277
|
const [id] = useState(() => String(Math.random()));
|
|
1239
1278
|
const [initialVolume] = useState(() => volume);
|
|
1240
1279
|
const nonce = useNonce();
|
|
@@ -1952,6 +1991,41 @@ const AudioForDevelopmentForwardRefFunction = (props, ref) => {
|
|
|
1952
1991
|
};
|
|
1953
1992
|
const AudioForDevelopment = forwardRef(AudioForDevelopmentForwardRefFunction);
|
|
1954
1993
|
|
|
1994
|
+
const AssetManager = createContext({
|
|
1995
|
+
registerAsset: () => undefined,
|
|
1996
|
+
unregisterAsset: () => undefined,
|
|
1997
|
+
assets: [],
|
|
1998
|
+
});
|
|
1999
|
+
const AssetManagerProvider = ({ children }) => {
|
|
2000
|
+
const [assets, setAssets] = useState([]);
|
|
2001
|
+
const registerAsset = useCallback((asset) => {
|
|
2002
|
+
setAssets((assts) => {
|
|
2003
|
+
return [...assts, asset];
|
|
2004
|
+
});
|
|
2005
|
+
}, []);
|
|
2006
|
+
const unregisterAsset = useCallback((id) => {
|
|
2007
|
+
setAssets((assts) => {
|
|
2008
|
+
return assts.filter((a) => a.id !== id);
|
|
2009
|
+
});
|
|
2010
|
+
}, []);
|
|
2011
|
+
useLayoutEffect(() => {
|
|
2012
|
+
if (typeof window !== 'undefined') {
|
|
2013
|
+
window.remotion_collectAssets = () => {
|
|
2014
|
+
setAssets([]); // clear assets at next render
|
|
2015
|
+
return assets;
|
|
2016
|
+
};
|
|
2017
|
+
}
|
|
2018
|
+
}, [assets]);
|
|
2019
|
+
const contextValue = useMemo(() => {
|
|
2020
|
+
return {
|
|
2021
|
+
registerAsset,
|
|
2022
|
+
unregisterAsset,
|
|
2023
|
+
assets,
|
|
2024
|
+
};
|
|
2025
|
+
}, [assets, registerAsset, unregisterAsset]);
|
|
2026
|
+
return (jsx(AssetManager.Provider, { value: contextValue, children: children }));
|
|
2027
|
+
};
|
|
2028
|
+
|
|
1955
2029
|
if (typeof window !== 'undefined') {
|
|
1956
2030
|
window.remotion_renderReady = false;
|
|
1957
2031
|
}
|
|
@@ -2029,7 +2103,7 @@ const AudioForRenderingRefForwardingFunction = (props, ref) => {
|
|
|
2029
2103
|
const volumePropFrame = useFrameForVolumeProp();
|
|
2030
2104
|
const frame = useCurrentFrame();
|
|
2031
2105
|
const sequenceContext = useContext(SequenceContext);
|
|
2032
|
-
const { registerAsset, unregisterAsset } = useContext(
|
|
2106
|
+
const { registerAsset, unregisterAsset } = useContext(AssetManager);
|
|
2033
2107
|
const environment = useRemotionEnvironment();
|
|
2034
2108
|
// Generate a string that's as unique as possible for this asset
|
|
2035
2109
|
// but at the same time the same on all threads
|
|
@@ -2799,9 +2873,7 @@ const CompositionManagerProvider = ({ children, numberOfAudioTags }) => {
|
|
|
2799
2873
|
const [compositions, setCompositions] = useState([]);
|
|
2800
2874
|
const currentcompositionsRef = useRef(compositions);
|
|
2801
2875
|
const [currentComposition, setCurrentComposition] = useState(null);
|
|
2802
|
-
const [assets, setAssets] = useState([]);
|
|
2803
2876
|
const [folders, setFolders] = useState([]);
|
|
2804
|
-
const [sequences, setSequences] = useState([]);
|
|
2805
2877
|
const [currentCompositionMetadata, setCurrentCompositionMetadata] = useState(null);
|
|
2806
2878
|
const updateCompositions = useCallback((
|
|
2807
2879
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -2824,29 +2896,11 @@ const CompositionManagerProvider = ({ children, numberOfAudioTags }) => {
|
|
|
2824
2896
|
return value;
|
|
2825
2897
|
});
|
|
2826
2898
|
}, [updateCompositions]);
|
|
2827
|
-
const registerSequence = useCallback((seq) => {
|
|
2828
|
-
setSequences((seqs) => {
|
|
2829
|
-
return [...seqs, seq];
|
|
2830
|
-
});
|
|
2831
|
-
}, []);
|
|
2832
2899
|
const unregisterComposition = useCallback((id) => {
|
|
2833
2900
|
setCompositions((comps) => {
|
|
2834
2901
|
return comps.filter((c) => c.id !== id);
|
|
2835
2902
|
});
|
|
2836
2903
|
}, []);
|
|
2837
|
-
const unregisterSequence = useCallback((seq) => {
|
|
2838
|
-
setSequences((seqs) => seqs.filter((s) => s.id !== seq));
|
|
2839
|
-
}, []);
|
|
2840
|
-
const registerAsset = useCallback((asset) => {
|
|
2841
|
-
setAssets((assts) => {
|
|
2842
|
-
return [...assts, asset];
|
|
2843
|
-
});
|
|
2844
|
-
}, []);
|
|
2845
|
-
const unregisterAsset = useCallback((id) => {
|
|
2846
|
-
setAssets((assts) => {
|
|
2847
|
-
return assts.filter((a) => a.id !== id);
|
|
2848
|
-
});
|
|
2849
|
-
}, []);
|
|
2850
2904
|
const registerFolder = useCallback((name, parent) => {
|
|
2851
2905
|
setFolders((prevFolders) => {
|
|
2852
2906
|
return [
|
|
@@ -2863,14 +2917,6 @@ const CompositionManagerProvider = ({ children, numberOfAudioTags }) => {
|
|
|
2863
2917
|
return prevFolders.filter((p) => !(p.name === name && p.parent === parent));
|
|
2864
2918
|
});
|
|
2865
2919
|
}, []);
|
|
2866
|
-
useLayoutEffect(() => {
|
|
2867
|
-
if (typeof window !== 'undefined') {
|
|
2868
|
-
window.remotion_collectAssets = () => {
|
|
2869
|
-
setAssets([]); // clear assets at next render
|
|
2870
|
-
return assets;
|
|
2871
|
-
};
|
|
2872
|
-
}
|
|
2873
|
-
}, [assets]);
|
|
2874
2920
|
useImperativeHandle(compositionsRef, () => {
|
|
2875
2921
|
return {
|
|
2876
2922
|
getCompositions: () => currentcompositionsRef.current,
|
|
@@ -2884,12 +2930,6 @@ const CompositionManagerProvider = ({ children, numberOfAudioTags }) => {
|
|
|
2884
2930
|
unregisterComposition,
|
|
2885
2931
|
currentComposition,
|
|
2886
2932
|
setCurrentComposition,
|
|
2887
|
-
registerSequence,
|
|
2888
|
-
unregisterSequence,
|
|
2889
|
-
registerAsset,
|
|
2890
|
-
unregisterAsset,
|
|
2891
|
-
sequences,
|
|
2892
|
-
assets,
|
|
2893
2933
|
folders,
|
|
2894
2934
|
registerFolder,
|
|
2895
2935
|
unregisterFolder,
|
|
@@ -2901,18 +2941,12 @@ const CompositionManagerProvider = ({ children, numberOfAudioTags }) => {
|
|
|
2901
2941
|
registerComposition,
|
|
2902
2942
|
unregisterComposition,
|
|
2903
2943
|
currentComposition,
|
|
2904
|
-
registerSequence,
|
|
2905
|
-
unregisterSequence,
|
|
2906
|
-
registerAsset,
|
|
2907
|
-
unregisterAsset,
|
|
2908
|
-
sequences,
|
|
2909
|
-
assets,
|
|
2910
2944
|
folders,
|
|
2911
2945
|
registerFolder,
|
|
2912
2946
|
unregisterFolder,
|
|
2913
2947
|
currentCompositionMetadata,
|
|
2914
2948
|
]);
|
|
2915
|
-
return (jsx(CompositionManager.Provider, { value: contextValue, children: jsx(ResolveCompositionConfig, { children: jsx(SharedAudioContextProvider, { numberOfAudioTags: numberOfAudioTags, component: (_a = composition === null || composition === void 0 ? void 0 : composition.component) !== null && _a !== void 0 ? _a : null, children: children }) }) }));
|
|
2949
|
+
return (jsx(CompositionManager.Provider, { value: contextValue, children: jsx(SequenceManagerProvider, { children: jsx(AssetManagerProvider, { children: jsx(ResolveCompositionConfig, { children: jsx(SharedAudioContextProvider, { numberOfAudioTags: numberOfAudioTags, component: (_a = composition === null || composition === void 0 ? void 0 : composition.component) !== null && _a !== void 0 ? _a : null, children: children }) }) }) }) }));
|
|
2916
2950
|
};
|
|
2917
2951
|
|
|
2918
2952
|
const injected = {};
|
|
@@ -3408,16 +3442,17 @@ const RemotionRoot = ({ children, numberOfAudioTags }) => {
|
|
|
3408
3442
|
const [fastRefreshes, setFastRefreshes] = useState(0);
|
|
3409
3443
|
const [playbackRate, setPlaybackRate] = useState(1);
|
|
3410
3444
|
const audioAndVideoTags = useRef([]);
|
|
3411
|
-
|
|
3412
|
-
|
|
3445
|
+
if (typeof window !== 'undefined') {
|
|
3446
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
3447
|
+
useLayoutEffect(() => {
|
|
3413
3448
|
window.remotion_setFrame = (f) => {
|
|
3414
3449
|
const id = delayRender(`Setting the current frame to ${f}`);
|
|
3415
3450
|
setFrame(f);
|
|
3416
3451
|
requestAnimationFrame(() => continueRender(id));
|
|
3417
3452
|
};
|
|
3418
3453
|
window.remotion_isPlayer = false;
|
|
3419
|
-
}
|
|
3420
|
-
}
|
|
3454
|
+
}, []);
|
|
3455
|
+
}
|
|
3421
3456
|
const timelineContextValue = useMemo(() => {
|
|
3422
3457
|
return {
|
|
3423
3458
|
frame,
|
|
@@ -3457,7 +3492,6 @@ const RemotionRoot = ({ children, numberOfAudioTags }) => {
|
|
|
3457
3492
|
return (jsx(NonceContext.Provider, { value: nonceContext, children: jsx(TimelineContext.Provider, { value: timelineContextValue, children: jsx(SetTimelineContext.Provider, { value: setTimelineContextValue, children: jsx(EditorPropsProvider, { children: jsx(PrefetchProvider, { children: jsx(NativeLayersProvider, { children: jsx(CompositionManagerProvider, { numberOfAudioTags: numberOfAudioTags, children: jsx(DurationsContextProvider, { children: children }) }) }) }) }) }) }) }));
|
|
3458
3493
|
};
|
|
3459
3494
|
|
|
3460
|
-
const ENV_VARIABLES_ENV_NAME = 'ENV_VARIABLES';
|
|
3461
3495
|
const getEnvVariables = () => {
|
|
3462
3496
|
if (getRemotionEnvironment() === 'rendering') {
|
|
3463
3497
|
const param = window.remotion_envVariables;
|
|
@@ -3467,11 +3501,10 @@ const getEnvVariables = () => {
|
|
|
3467
3501
|
return { ...JSON.parse(param), NODE_ENV: process.env.NODE_ENV };
|
|
3468
3502
|
}
|
|
3469
3503
|
if (getRemotionEnvironment() === 'preview') {
|
|
3470
|
-
//
|
|
3471
|
-
//
|
|
3504
|
+
// For the Preview, we already set the environment variables in index-html.ts.
|
|
3505
|
+
// We just add NODE_ENV here.
|
|
3472
3506
|
return {
|
|
3473
|
-
|
|
3474
|
-
NODE_ENV: process.env.NODE_ENV,
|
|
3507
|
+
NODE_ENV: 'development',
|
|
3475
3508
|
};
|
|
3476
3509
|
}
|
|
3477
3510
|
throw new Error('Can only call getEnvVariables() if environment is `rendering` or `preview`');
|
|
@@ -3520,6 +3553,8 @@ function useRemotionContexts() {
|
|
|
3520
3553
|
const nativeLayersContext = React.useContext(NativeLayersContext);
|
|
3521
3554
|
const preloadContext = React.useContext(PreloadContext);
|
|
3522
3555
|
const resolveCompositionContext = React.useContext(ResolveCompositionContext);
|
|
3556
|
+
const assetManagerContext = React.useContext(AssetManager);
|
|
3557
|
+
const sequenceManagerContext = React.useContext(SequenceManager);
|
|
3523
3558
|
return useMemo(() => ({
|
|
3524
3559
|
compositionManagerCtx,
|
|
3525
3560
|
timelineContext,
|
|
@@ -3530,6 +3565,8 @@ function useRemotionContexts() {
|
|
|
3530
3565
|
nativeLayersContext,
|
|
3531
3566
|
preloadContext,
|
|
3532
3567
|
resolveCompositionContext,
|
|
3568
|
+
assetManagerContext,
|
|
3569
|
+
sequenceManagerContext,
|
|
3533
3570
|
}), [
|
|
3534
3571
|
compositionManagerCtx,
|
|
3535
3572
|
nonceContext,
|
|
@@ -3540,11 +3577,13 @@ function useRemotionContexts() {
|
|
|
3540
3577
|
nativeLayersContext,
|
|
3541
3578
|
preloadContext,
|
|
3542
3579
|
resolveCompositionContext,
|
|
3580
|
+
assetManagerContext,
|
|
3581
|
+
sequenceManagerContext,
|
|
3543
3582
|
]);
|
|
3544
3583
|
}
|
|
3545
3584
|
const RemotionContextProvider = (props) => {
|
|
3546
3585
|
const { children, contexts } = props;
|
|
3547
|
-
return (jsx(CanUseRemotionHooks.Provider, { value: contexts.canUseRemotionHooksContext, children: jsx(NonceContext.Provider, { value: contexts.nonceContext, children: jsx(NativeLayersContext.Provider, { value: contexts.nativeLayersContext, children: jsx(PreloadContext.Provider, { value: contexts.preloadContext, children: jsx(CompositionManager.Provider, { value: contexts.compositionManagerCtx, children: jsx(ResolveCompositionContext.Provider, { value: contexts.resolveCompositionContext, children: jsx(TimelineContext.Provider, { value: contexts.timelineContext, children: jsx(SetTimelineContext.Provider, { value: contexts.setTimelineContext, children: jsx(SequenceContext.Provider, { value: contexts.sequenceContext, children: children }) }) }) }) }) }) }) }) }));
|
|
3586
|
+
return (jsx(CanUseRemotionHooks.Provider, { value: contexts.canUseRemotionHooksContext, children: jsx(NonceContext.Provider, { value: contexts.nonceContext, children: jsx(NativeLayersContext.Provider, { value: contexts.nativeLayersContext, children: jsx(PreloadContext.Provider, { value: contexts.preloadContext, children: jsx(CompositionManager.Provider, { value: contexts.compositionManagerCtx, children: jsx(SequenceManager.Provider, { value: contexts.sequenceManagerContext, children: jsx(AssetManager.Provider, { value: contexts.assetManagerContext, children: jsx(ResolveCompositionContext.Provider, { value: contexts.resolveCompositionContext, children: jsx(TimelineContext.Provider, { value: contexts.timelineContext, children: jsx(SetTimelineContext.Provider, { value: contexts.setTimelineContext, children: jsx(SequenceContext.Provider, { value: contexts.sequenceContext, children: children }) }) }) }) }) }) }) }) }) }) }));
|
|
3548
3587
|
};
|
|
3549
3588
|
|
|
3550
3589
|
const Timeline = TimelinePosition;
|
|
@@ -3554,6 +3593,7 @@ const Internals = {
|
|
|
3554
3593
|
useUnsafeVideoConfig,
|
|
3555
3594
|
Timeline,
|
|
3556
3595
|
CompositionManager,
|
|
3596
|
+
SequenceManager,
|
|
3557
3597
|
RemotionRoot,
|
|
3558
3598
|
useVideo,
|
|
3559
3599
|
getRoot,
|
|
@@ -3566,7 +3606,6 @@ const Internals = {
|
|
|
3566
3606
|
RemotionContextProvider,
|
|
3567
3607
|
CSSUtils,
|
|
3568
3608
|
setupEnvVariables,
|
|
3569
|
-
ENV_VARIABLES_ENV_NAME,
|
|
3570
3609
|
MediaVolumeContext,
|
|
3571
3610
|
SetMediaVolumeContext,
|
|
3572
3611
|
validateDurationInFrames,
|
|
@@ -3601,6 +3640,7 @@ const Internals = {
|
|
|
3601
3640
|
resolveCompositionsRef,
|
|
3602
3641
|
ResolveCompositionConfig,
|
|
3603
3642
|
REMOTION_STUDIO_CONTAINER_ELEMENT,
|
|
3643
|
+
AssetManager,
|
|
3604
3644
|
};
|
|
3605
3645
|
|
|
3606
3646
|
const flattenChildren = (children) => {
|
|
@@ -4026,7 +4066,7 @@ const OffthreadVideoForRendering = ({ onError, volume: volumeProp, playbackRate,
|
|
|
4026
4066
|
const videoConfig = useUnsafeVideoConfig();
|
|
4027
4067
|
const sequenceContext = useContext(SequenceContext);
|
|
4028
4068
|
const mediaStartsAt = useMediaStartsAt();
|
|
4029
|
-
const { registerAsset, unregisterAsset } = useContext(
|
|
4069
|
+
const { registerAsset, unregisterAsset } = useContext(AssetManager);
|
|
4030
4070
|
if (!src) {
|
|
4031
4071
|
throw new TypeError('No `src` was passed to <OffthreadVideo>.');
|
|
4032
4072
|
}
|
|
@@ -4298,7 +4338,7 @@ const VideoForRenderingForwardFunction = ({ onError, volume: volumeProp, allowAm
|
|
|
4298
4338
|
const sequenceContext = useContext(SequenceContext);
|
|
4299
4339
|
const mediaStartsAt = useMediaStartsAt();
|
|
4300
4340
|
const environment = useRemotionEnvironment();
|
|
4301
|
-
const { registerAsset, unregisterAsset } = useContext(
|
|
4341
|
+
const { registerAsset, unregisterAsset } = useContext(AssetManager);
|
|
4302
4342
|
// Generate a string that's as unique as possible for this asset
|
|
4303
4343
|
// but at the same time the same on all threads
|
|
4304
4344
|
const id = useMemo(() => {
|
package/dist/esm/version.mjs
CHANGED