remotion 4.0.0-alpha10 → 4.0.0-alpha12
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/Img.js +31 -28
- package/dist/cjs/RemotionRoot.js +5 -4
- package/dist/cjs/ResolveCompositionConfig.d.ts +2 -0
- package/dist/cjs/ResolveCompositionConfig.js +23 -7
- 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/delay-render.js +3 -3
- package/dist/cjs/get-preview-dom-element.d.ts +1 -0
- package/dist/cjs/get-preview-dom-element.js +3 -2
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/internals.d.ts +2 -1
- package/dist/cjs/internals.js +3 -1
- package/dist/cjs/nonce.js +6 -0
- package/dist/cjs/resolve-video-config.js +1 -1
- 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/warn-about-non-seekable-media.js +1 -1
- package/dist/cjs/wrap-remotion-context.d.ts +2 -0
- package/dist/cjs/wrap-remotion-context.js +9 -1
- package/dist/esm/index.mjs +185 -137
- 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
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { TAsset } from './CompositionManager.js';
|
|
3
|
+
export declare type AssetManagerContext = {
|
|
4
|
+
registerAsset: (asset: TAsset) => void;
|
|
5
|
+
unregisterAsset: (id: string) => void;
|
|
6
|
+
assets: TAsset[];
|
|
7
|
+
};
|
|
8
|
+
export declare const AssetManager: import("react").Context<AssetManagerContext>;
|
|
9
|
+
export declare const AssetManagerProvider: React.FC<{
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AssetManagerProvider = exports.AssetManager = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
exports.AssetManager = (0, react_1.createContext)({
|
|
7
|
+
registerAsset: () => undefined,
|
|
8
|
+
unregisterAsset: () => undefined,
|
|
9
|
+
assets: [],
|
|
10
|
+
});
|
|
11
|
+
const AssetManagerProvider = ({ children }) => {
|
|
12
|
+
const [assets, setAssets] = (0, react_1.useState)([]);
|
|
13
|
+
const registerAsset = (0, react_1.useCallback)((asset) => {
|
|
14
|
+
setAssets((assts) => {
|
|
15
|
+
return [...assts, asset];
|
|
16
|
+
});
|
|
17
|
+
}, []);
|
|
18
|
+
const unregisterAsset = (0, react_1.useCallback)((id) => {
|
|
19
|
+
setAssets((assts) => {
|
|
20
|
+
return assts.filter((a) => a.id !== id);
|
|
21
|
+
});
|
|
22
|
+
}, []);
|
|
23
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
24
|
+
if (typeof window !== 'undefined') {
|
|
25
|
+
window.remotion_collectAssets = () => {
|
|
26
|
+
setAssets([]); // clear assets at next render
|
|
27
|
+
return assets;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}, [assets]);
|
|
31
|
+
const contextValue = (0, react_1.useMemo)(() => {
|
|
32
|
+
return {
|
|
33
|
+
registerAsset,
|
|
34
|
+
unregisterAsset,
|
|
35
|
+
assets,
|
|
36
|
+
};
|
|
37
|
+
}, [assets, registerAsset, unregisterAsset]);
|
|
38
|
+
return ((0, jsx_runtime_1.jsx)(exports.AssetManager.Provider, { value: contextValue, children: children }));
|
|
39
|
+
};
|
|
40
|
+
exports.AssetManagerProvider = AssetManagerProvider;
|
|
@@ -26,9 +26,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.CompositionManagerProvider = exports.compositionsRef = void 0;
|
|
27
27
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
28
28
|
const react_1 = __importStar(require("react"));
|
|
29
|
+
const AssetManager_js_1 = require("./AssetManager.js");
|
|
29
30
|
const shared_audio_tags_js_1 = require("./audio/shared-audio-tags.js");
|
|
30
31
|
const CompositionManagerContext_js_1 = require("./CompositionManagerContext.js");
|
|
31
32
|
const ResolveCompositionConfig_js_1 = require("./ResolveCompositionConfig.js");
|
|
33
|
+
const SequenceManager_js_1 = require("./SequenceManager.js");
|
|
32
34
|
exports.compositionsRef = react_1.default.createRef();
|
|
33
35
|
const CompositionManagerProvider = ({ children, numberOfAudioTags }) => {
|
|
34
36
|
var _a;
|
|
@@ -37,9 +39,7 @@ const CompositionManagerProvider = ({ children, numberOfAudioTags }) => {
|
|
|
37
39
|
const [compositions, setCompositions] = (0, react_1.useState)([]);
|
|
38
40
|
const currentcompositionsRef = (0, react_1.useRef)(compositions);
|
|
39
41
|
const [currentComposition, setCurrentComposition] = (0, react_1.useState)(null);
|
|
40
|
-
const [assets, setAssets] = (0, react_1.useState)([]);
|
|
41
42
|
const [folders, setFolders] = (0, react_1.useState)([]);
|
|
42
|
-
const [sequences, setSequences] = (0, react_1.useState)([]);
|
|
43
43
|
const [currentCompositionMetadata, setCurrentCompositionMetadata] = (0, react_1.useState)(null);
|
|
44
44
|
const updateCompositions = (0, react_1.useCallback)((
|
|
45
45
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -62,29 +62,11 @@ const CompositionManagerProvider = ({ children, numberOfAudioTags }) => {
|
|
|
62
62
|
return value;
|
|
63
63
|
});
|
|
64
64
|
}, [updateCompositions]);
|
|
65
|
-
const registerSequence = (0, react_1.useCallback)((seq) => {
|
|
66
|
-
setSequences((seqs) => {
|
|
67
|
-
return [...seqs, seq];
|
|
68
|
-
});
|
|
69
|
-
}, []);
|
|
70
65
|
const unregisterComposition = (0, react_1.useCallback)((id) => {
|
|
71
66
|
setCompositions((comps) => {
|
|
72
67
|
return comps.filter((c) => c.id !== id);
|
|
73
68
|
});
|
|
74
69
|
}, []);
|
|
75
|
-
const unregisterSequence = (0, react_1.useCallback)((seq) => {
|
|
76
|
-
setSequences((seqs) => seqs.filter((s) => s.id !== seq));
|
|
77
|
-
}, []);
|
|
78
|
-
const registerAsset = (0, react_1.useCallback)((asset) => {
|
|
79
|
-
setAssets((assts) => {
|
|
80
|
-
return [...assts, asset];
|
|
81
|
-
});
|
|
82
|
-
}, []);
|
|
83
|
-
const unregisterAsset = (0, react_1.useCallback)((id) => {
|
|
84
|
-
setAssets((assts) => {
|
|
85
|
-
return assts.filter((a) => a.id !== id);
|
|
86
|
-
});
|
|
87
|
-
}, []);
|
|
88
70
|
const registerFolder = (0, react_1.useCallback)((name, parent) => {
|
|
89
71
|
setFolders((prevFolders) => {
|
|
90
72
|
return [
|
|
@@ -101,14 +83,6 @@ const CompositionManagerProvider = ({ children, numberOfAudioTags }) => {
|
|
|
101
83
|
return prevFolders.filter((p) => !(p.name === name && p.parent === parent));
|
|
102
84
|
});
|
|
103
85
|
}, []);
|
|
104
|
-
(0, react_1.useLayoutEffect)(() => {
|
|
105
|
-
if (typeof window !== 'undefined') {
|
|
106
|
-
window.remotion_collectAssets = () => {
|
|
107
|
-
setAssets([]); // clear assets at next render
|
|
108
|
-
return assets;
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
}, [assets]);
|
|
112
86
|
(0, react_1.useImperativeHandle)(exports.compositionsRef, () => {
|
|
113
87
|
return {
|
|
114
88
|
getCompositions: () => currentcompositionsRef.current,
|
|
@@ -122,12 +96,6 @@ const CompositionManagerProvider = ({ children, numberOfAudioTags }) => {
|
|
|
122
96
|
unregisterComposition,
|
|
123
97
|
currentComposition,
|
|
124
98
|
setCurrentComposition,
|
|
125
|
-
registerSequence,
|
|
126
|
-
unregisterSequence,
|
|
127
|
-
registerAsset,
|
|
128
|
-
unregisterAsset,
|
|
129
|
-
sequences,
|
|
130
|
-
assets,
|
|
131
99
|
folders,
|
|
132
100
|
registerFolder,
|
|
133
101
|
unregisterFolder,
|
|
@@ -139,17 +107,11 @@ const CompositionManagerProvider = ({ children, numberOfAudioTags }) => {
|
|
|
139
107
|
registerComposition,
|
|
140
108
|
unregisterComposition,
|
|
141
109
|
currentComposition,
|
|
142
|
-
registerSequence,
|
|
143
|
-
unregisterSequence,
|
|
144
|
-
registerAsset,
|
|
145
|
-
unregisterAsset,
|
|
146
|
-
sequences,
|
|
147
|
-
assets,
|
|
148
110
|
folders,
|
|
149
111
|
registerFolder,
|
|
150
112
|
unregisterFolder,
|
|
151
113
|
currentCompositionMetadata,
|
|
152
114
|
]);
|
|
153
|
-
return ((0, jsx_runtime_1.jsx)(CompositionManagerContext_js_1.CompositionManager.Provider, { value: contextValue, children: (0, jsx_runtime_1.jsx)(ResolveCompositionConfig_js_1.ResolveCompositionConfig, { children: (0, jsx_runtime_1.jsx)(shared_audio_tags_js_1.SharedAudioContextProvider, { numberOfAudioTags: numberOfAudioTags, component: (_a = composition === null || composition === void 0 ? void 0 : composition.component) !== null && _a !== void 0 ? _a : null, children: children }) }) }));
|
|
115
|
+
return ((0, jsx_runtime_1.jsx)(CompositionManagerContext_js_1.CompositionManager.Provider, { value: contextValue, children: (0, jsx_runtime_1.jsx)(SequenceManager_js_1.SequenceManagerProvider, { children: (0, jsx_runtime_1.jsx)(AssetManager_js_1.AssetManagerProvider, { children: (0, jsx_runtime_1.jsx)(ResolveCompositionConfig_js_1.ResolveCompositionConfig, { children: (0, jsx_runtime_1.jsx)(shared_audio_tags_js_1.SharedAudioContextProvider, { numberOfAudioTags: numberOfAudioTags, component: (_a = composition === null || composition === void 0 ? void 0 : composition.component) !== null && _a !== void 0 ? _a : null, children: children }) }) }) }) }));
|
|
154
116
|
};
|
|
155
117
|
exports.CompositionManagerProvider = CompositionManagerProvider;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { AnyZodObject } from 'zod';
|
|
3
|
-
import type { AnyCompMetadata, AnyComposition,
|
|
3
|
+
import type { AnyCompMetadata, AnyComposition, TComposition } from './CompositionManager.js';
|
|
4
4
|
import type { TFolder } from './Folder.js';
|
|
5
5
|
export declare type BaseMetadata = Pick<AnyCompMetadata, 'durationInFrames' | 'fps' | 'defaultProps' | 'height' | 'width'>;
|
|
6
6
|
export declare type CompositionManagerContext = {
|
|
@@ -13,12 +13,6 @@ export declare type CompositionManagerContext = {
|
|
|
13
13
|
setCurrentComposition: (curr: string) => void;
|
|
14
14
|
setCurrentCompositionMetadata: (metadata: BaseMetadata) => void;
|
|
15
15
|
currentCompositionMetadata: BaseMetadata | null;
|
|
16
|
-
registerSequence: (seq: TSequence) => void;
|
|
17
|
-
unregisterSequence: (id: string) => void;
|
|
18
|
-
registerAsset: (asset: TAsset) => void;
|
|
19
|
-
unregisterAsset: (id: string) => void;
|
|
20
|
-
sequences: TSequence[];
|
|
21
|
-
assets: TAsset[];
|
|
22
16
|
folders: TFolder[];
|
|
23
17
|
};
|
|
24
18
|
export declare const CompositionManager: import("react").Context<CompositionManagerContext>;
|
|
@@ -11,12 +11,6 @@ exports.CompositionManager = (0, react_1.createContext)({
|
|
|
11
11
|
currentComposition: null,
|
|
12
12
|
setCurrentComposition: () => undefined,
|
|
13
13
|
setCurrentCompositionMetadata: () => undefined,
|
|
14
|
-
registerSequence: () => undefined,
|
|
15
|
-
unregisterSequence: () => undefined,
|
|
16
|
-
registerAsset: () => undefined,
|
|
17
|
-
unregisterAsset: () => undefined,
|
|
18
|
-
sequences: [],
|
|
19
|
-
assets: [],
|
|
20
14
|
folders: [],
|
|
21
15
|
currentCompositionMetadata: null,
|
|
22
16
|
});
|
package/dist/cjs/Img.js
CHANGED
|
@@ -59,35 +59,38 @@ const ImgRefForwarding = ({ onError, maxRetries = 2, src, ...props }, ref) => {
|
|
|
59
59
|
}
|
|
60
60
|
(0, cancel_render_js_1.cancelRender)('Error loading image with src: ' + ((_l = imageRef.current) === null || _l === void 0 ? void 0 : _l.src));
|
|
61
61
|
}, [maxRetries, onError, retryIn]);
|
|
62
|
-
(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const { current } = imageRef;
|
|
68
|
-
const onComplete = () => {
|
|
69
|
-
var _a, _b, _c, _d;
|
|
70
|
-
if (((_b = errors.current[(_a = imageRef.current) === null || _a === void 0 ? void 0 : _a.src]) !== null && _b !== void 0 ? _b : 0) > 0) {
|
|
71
|
-
delete errors.current[(_c = imageRef.current) === null || _c === void 0 ? void 0 : _c.src];
|
|
72
|
-
console.info(`Retry successful - ${(_d = imageRef.current) === null || _d === void 0 ? void 0 : _d.src} is now loaded`);
|
|
62
|
+
if (typeof window !== 'undefined') {
|
|
63
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
64
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
65
|
+
if (process.env.NODE_ENV === 'test') {
|
|
66
|
+
return;
|
|
73
67
|
}
|
|
74
|
-
(0, delay_render_js_1.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
current === null || current === void 0 ? void 0 : current.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
68
|
+
const newHandle = (0, delay_render_js_1.delayRender)('Loading <Img> with src=' + src);
|
|
69
|
+
const { current } = imageRef;
|
|
70
|
+
const onComplete = () => {
|
|
71
|
+
var _a, _b, _c, _d;
|
|
72
|
+
if (((_b = errors.current[(_a = imageRef.current) === null || _a === void 0 ? void 0 : _a.src]) !== null && _b !== void 0 ? _b : 0) > 0) {
|
|
73
|
+
delete errors.current[(_c = imageRef.current) === null || _c === void 0 ? void 0 : _c.src];
|
|
74
|
+
console.info(`Retry successful - ${(_d = imageRef.current) === null || _d === void 0 ? void 0 : _d.src} is now loaded`);
|
|
75
|
+
}
|
|
76
|
+
(0, delay_render_js_1.continueRender)(newHandle);
|
|
77
|
+
};
|
|
78
|
+
const didLoad = () => {
|
|
79
|
+
onComplete();
|
|
80
|
+
};
|
|
81
|
+
if (current === null || current === void 0 ? void 0 : current.complete) {
|
|
82
|
+
onComplete();
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
current === null || current === void 0 ? void 0 : current.addEventListener('load', didLoad, { once: true });
|
|
86
|
+
}
|
|
87
|
+
// If tag gets unmounted, clear pending handles because image is not going to load
|
|
88
|
+
return () => {
|
|
89
|
+
current === null || current === void 0 ? void 0 : current.removeEventListener('load', didLoad);
|
|
90
|
+
(0, delay_render_js_1.continueRender)(newHandle);
|
|
91
|
+
};
|
|
92
|
+
}, [src]);
|
|
93
|
+
}
|
|
91
94
|
return ((0, jsx_runtime_1.jsx)("img", { ...props, ref: imageRef, src: actualSrc, onError: didGetError }));
|
|
92
95
|
};
|
|
93
96
|
/**
|
package/dist/cjs/RemotionRoot.js
CHANGED
|
@@ -21,16 +21,17 @@ const RemotionRoot = ({ children, numberOfAudioTags }) => {
|
|
|
21
21
|
const [fastRefreshes, setFastRefreshes] = (0, react_1.useState)(0);
|
|
22
22
|
const [playbackRate, setPlaybackRate] = (0, react_1.useState)(1);
|
|
23
23
|
const audioAndVideoTags = (0, react_1.useRef)([]);
|
|
24
|
-
(
|
|
25
|
-
|
|
24
|
+
if (typeof window !== 'undefined') {
|
|
25
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
26
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
26
27
|
window.remotion_setFrame = (f) => {
|
|
27
28
|
const id = (0, delay_render_js_1.delayRender)(`Setting the current frame to ${f}`);
|
|
28
29
|
setFrame(f);
|
|
29
30
|
requestAnimationFrame(() => (0, delay_render_js_1.continueRender)(id));
|
|
30
31
|
};
|
|
31
32
|
window.remotion_isPlayer = false;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
33
|
+
}, []);
|
|
34
|
+
}
|
|
34
35
|
const timelineContextValue = (0, react_1.useMemo)(() => {
|
|
35
36
|
return {
|
|
36
37
|
frame,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { PropsWithChildren } from 'react';
|
|
2
|
+
import type { AnyComposition } from './CompositionManager.js';
|
|
2
3
|
import type { VideoConfig } from './video-config.js';
|
|
3
4
|
declare type ResolveCompositionConfigContect = Record<string, VideoConfigState | undefined>;
|
|
4
5
|
export declare const ResolveCompositionContext: import("react").Context<ResolveCompositionConfigContect | null>;
|
|
@@ -18,5 +19,6 @@ declare type VideoConfigState = {
|
|
|
18
19
|
export declare const ResolveCompositionConfig: React.FC<PropsWithChildren<{
|
|
19
20
|
children: React.ReactNode;
|
|
20
21
|
}>>;
|
|
22
|
+
export declare const needsResolution: (composition: AnyComposition) => boolean;
|
|
21
23
|
export declare const useResolvedVideoConfig: (preferredCompositionId: string | null) => VideoConfigState | null;
|
|
22
24
|
export {};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useResolvedVideoConfig = exports.ResolveCompositionConfig = exports.resolveCompositionsRef = exports.ResolveCompositionContext = void 0;
|
|
3
|
+
exports.useResolvedVideoConfig = exports.needsResolution = exports.ResolveCompositionConfig = exports.resolveCompositionsRef = exports.ResolveCompositionContext = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const CompositionManagerContext_js_1 = require("./CompositionManagerContext.js");
|
|
7
|
+
const input_props_js_1 = require("./config/input-props.js");
|
|
7
8
|
const EditorProps_js_1 = require("./EditorProps.js");
|
|
8
9
|
const resolve_video_config_js_1 = require("./resolve-video-config.js");
|
|
9
10
|
exports.ResolveCompositionContext = (0, react_1.createContext)(null);
|
|
@@ -96,7 +97,7 @@ const ResolveCompositionConfig = ({ children }) => {
|
|
|
96
97
|
}, [allEditorProps, compositions, currentComposition, doResolution]);
|
|
97
98
|
const isTheSame = (selectedComposition === null || selectedComposition === void 0 ? void 0 : selectedComposition.id) === (renderModalComposition === null || renderModalComposition === void 0 ? void 0 : renderModalComposition.id);
|
|
98
99
|
(0, react_1.useEffect)(() => {
|
|
99
|
-
if (selectedComposition) {
|
|
100
|
+
if (selectedComposition && (0, exports.needsResolution)(selectedComposition)) {
|
|
100
101
|
const controller = doResolution(selectedComposition, selectedEditorProps);
|
|
101
102
|
return () => {
|
|
102
103
|
controller.abort();
|
|
@@ -132,27 +133,42 @@ const ResolveCompositionConfig = ({ children }) => {
|
|
|
132
133
|
return ((0, jsx_runtime_1.jsx)(exports.ResolveCompositionContext.Provider, { value: resolvedConfigsIncludingStaticOnes, children: children }));
|
|
133
134
|
};
|
|
134
135
|
exports.ResolveCompositionConfig = ResolveCompositionConfig;
|
|
136
|
+
const needsResolution = (composition) => {
|
|
137
|
+
return Boolean(composition.calculateMetadata);
|
|
138
|
+
};
|
|
139
|
+
exports.needsResolution = needsResolution;
|
|
135
140
|
const useResolvedVideoConfig = (preferredCompositionId) => {
|
|
136
141
|
const context = (0, react_1.useContext)(exports.ResolveCompositionContext);
|
|
142
|
+
const { props: allEditorProps } = (0, react_1.useContext)(EditorProps_js_1.EditorPropsContext);
|
|
137
143
|
const { compositions, currentComposition } = (0, react_1.useContext)(CompositionManagerContext_js_1.CompositionManager);
|
|
138
144
|
const compositionId = preferredCompositionId !== null && preferredCompositionId !== void 0 ? preferredCompositionId : currentComposition;
|
|
139
145
|
const composition = compositions.find((c) => c.id === compositionId);
|
|
140
|
-
|
|
146
|
+
const selectedEditorProps = (0, react_1.useMemo)(() => {
|
|
141
147
|
var _a;
|
|
148
|
+
return composition ? (_a = allEditorProps[composition.id]) !== null && _a !== void 0 ? _a : {} : {};
|
|
149
|
+
}, [allEditorProps, composition]);
|
|
150
|
+
return (0, react_1.useMemo)(() => {
|
|
151
|
+
var _a, _b;
|
|
142
152
|
if (!composition) {
|
|
143
153
|
return null;
|
|
144
154
|
}
|
|
145
|
-
|
|
146
|
-
if (needsResolution === null) {
|
|
155
|
+
if (!(0, exports.needsResolution)(composition)) {
|
|
147
156
|
return {
|
|
148
157
|
type: 'success',
|
|
149
|
-
result: {
|
|
158
|
+
result: {
|
|
159
|
+
...composition,
|
|
160
|
+
defaultProps: {
|
|
161
|
+
...((_a = composition.defaultProps) !== null && _a !== void 0 ? _a : {}),
|
|
162
|
+
...(selectedEditorProps !== null && selectedEditorProps !== void 0 ? selectedEditorProps : {}),
|
|
163
|
+
...(typeof window === 'undefined' ? {} : (_b = (0, input_props_js_1.getInputProps)()) !== null && _b !== void 0 ? _b : {}),
|
|
164
|
+
},
|
|
165
|
+
},
|
|
150
166
|
};
|
|
151
167
|
}
|
|
152
168
|
if (!context[composition.id]) {
|
|
153
169
|
return null;
|
|
154
170
|
}
|
|
155
171
|
return context[composition.id];
|
|
156
|
-
}, [composition, context]);
|
|
172
|
+
}, [composition, context, selectedEditorProps]);
|
|
157
173
|
};
|
|
158
174
|
exports.useResolvedVideoConfig = useResolvedVideoConfig;
|
package/dist/cjs/Sequence.js
CHANGED
|
@@ -4,11 +4,11 @@ exports.Sequence = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const AbsoluteFill_js_1 = require("./AbsoluteFill.js");
|
|
7
|
-
const CompositionManagerContext_js_1 = require("./CompositionManagerContext.js");
|
|
8
7
|
const get_environment_js_1 = require("./get-environment.js");
|
|
9
8
|
const get_timeline_clip_name_js_1 = require("./get-timeline-clip-name.js");
|
|
10
9
|
const nonce_js_1 = require("./nonce.js");
|
|
11
10
|
const SequenceContext_js_1 = require("./SequenceContext.js");
|
|
11
|
+
const SequenceManager_js_1 = require("./SequenceManager.js");
|
|
12
12
|
const timeline_position_state_js_1 = require("./timeline-position-state.js");
|
|
13
13
|
const use_video_config_js_1 = require("./use-video-config.js");
|
|
14
14
|
const SequenceRefForwardingFunction = ({ from = 0, durationInFrames = Infinity, children, name, showInTimeline = true, loopDisplay, ...other }, ref) => {
|
|
@@ -46,7 +46,7 @@ const SequenceRefForwardingFunction = ({ from = 0, durationInFrames = Infinity,
|
|
|
46
46
|
? Math.min(parentSequence.durationInFrames - from, durationInFrames)
|
|
47
47
|
: durationInFrames;
|
|
48
48
|
const actualDurationInFrames = Math.max(0, Math.min(videoConfig.durationInFrames - from, parentSequenceDuration));
|
|
49
|
-
const { registerSequence, unregisterSequence } = (0, react_1.useContext)(
|
|
49
|
+
const { registerSequence, unregisterSequence } = (0, react_1.useContext)(SequenceManager_js_1.SequenceManager);
|
|
50
50
|
const contextValue = (0, react_1.useMemo)(() => {
|
|
51
51
|
var _a;
|
|
52
52
|
return {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { TSequence } from './CompositionManager.js';
|
|
3
|
+
export declare type SequenceManagerContext = {
|
|
4
|
+
registerSequence: (seq: TSequence) => void;
|
|
5
|
+
unregisterSequence: (id: string) => void;
|
|
6
|
+
sequences: TSequence[];
|
|
7
|
+
};
|
|
8
|
+
export declare const SequenceManager: React.Context<SequenceManagerContext>;
|
|
9
|
+
export declare const SequenceManagerProvider: React.FC<{
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,57 @@
|
|
|
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.SequenceManagerProvider = exports.SequenceManager = void 0;
|
|
27
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
28
|
+
const react_1 = __importStar(require("react"));
|
|
29
|
+
exports.SequenceManager = react_1.default.createContext({
|
|
30
|
+
registerSequence: () => {
|
|
31
|
+
throw new Error('SequenceManagerContext not initialized');
|
|
32
|
+
},
|
|
33
|
+
unregisterSequence: () => {
|
|
34
|
+
throw new Error('SequenceManagerContext not initialized');
|
|
35
|
+
},
|
|
36
|
+
sequences: [],
|
|
37
|
+
});
|
|
38
|
+
const SequenceManagerProvider = ({ children }) => {
|
|
39
|
+
const [sequences, setSequences] = (0, react_1.useState)([]);
|
|
40
|
+
const registerSequence = (0, react_1.useCallback)((seq) => {
|
|
41
|
+
setSequences((seqs) => {
|
|
42
|
+
return [...seqs, seq];
|
|
43
|
+
});
|
|
44
|
+
}, []);
|
|
45
|
+
const unregisterSequence = (0, react_1.useCallback)((seq) => {
|
|
46
|
+
setSequences((seqs) => seqs.filter((s) => s.id !== seq));
|
|
47
|
+
}, []);
|
|
48
|
+
const context = (0, react_1.useMemo)(() => {
|
|
49
|
+
return {
|
|
50
|
+
registerSequence,
|
|
51
|
+
sequences,
|
|
52
|
+
unregisterSequence,
|
|
53
|
+
};
|
|
54
|
+
}, [registerSequence, sequences, unregisterSequence]);
|
|
55
|
+
return ((0, jsx_runtime_1.jsx)(exports.SequenceManager.Provider, { value: context, children: children }));
|
|
56
|
+
};
|
|
57
|
+
exports.SequenceManagerProvider = SequenceManagerProvider;
|
|
@@ -4,7 +4,7 @@ exports.AudioForRendering = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const absolute_src_js_1 = require("../absolute-src.js");
|
|
7
|
-
const
|
|
7
|
+
const AssetManager_js_1 = require("../AssetManager.js");
|
|
8
8
|
const delay_render_js_1 = require("../delay-render.js");
|
|
9
9
|
const get_environment_js_1 = require("../get-environment.js");
|
|
10
10
|
const random_js_1 = require("../random.js");
|
|
@@ -19,7 +19,7 @@ const AudioForRenderingRefForwardingFunction = (props, ref) => {
|
|
|
19
19
|
const volumePropFrame = (0, use_audio_frame_js_1.useFrameForVolumeProp)();
|
|
20
20
|
const frame = (0, use_current_frame_js_1.useCurrentFrame)();
|
|
21
21
|
const sequenceContext = (0, react_1.useContext)(SequenceContext_js_1.SequenceContext);
|
|
22
|
-
const { registerAsset, unregisterAsset } = (0, react_1.useContext)(
|
|
22
|
+
const { registerAsset, unregisterAsset } = (0, react_1.useContext)(AssetManager_js_1.AssetManager);
|
|
23
23
|
const environment = (0, get_environment_js_1.useRemotionEnvironment)();
|
|
24
24
|
// Generate a string that's as unique as possible for this asset
|
|
25
25
|
// but at the same time the same on all threads
|
package/dist/cjs/delay-render.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.continueRender = exports.delayRender = exports.DELAY_RENDER_CALLSTACK_TO
|
|
|
4
4
|
const get_environment_js_1 = require("./get-environment.js");
|
|
5
5
|
const truthy_js_1 = require("./truthy.js");
|
|
6
6
|
if (typeof window !== 'undefined') {
|
|
7
|
-
window.
|
|
7
|
+
window.remotion_renderReady = false;
|
|
8
8
|
}
|
|
9
9
|
let handles = [];
|
|
10
10
|
const timeouts = {};
|
|
@@ -43,7 +43,7 @@ const delayRender = (label) => {
|
|
|
43
43
|
}, timeoutToUse);
|
|
44
44
|
}
|
|
45
45
|
if (typeof window !== 'undefined') {
|
|
46
|
-
window.
|
|
46
|
+
window.remotion_renderReady = false;
|
|
47
47
|
}
|
|
48
48
|
return handle;
|
|
49
49
|
};
|
|
@@ -71,7 +71,7 @@ const continueRender = (handle) => {
|
|
|
71
71
|
return true;
|
|
72
72
|
});
|
|
73
73
|
if (handles.length === 0 && typeof window !== 'undefined') {
|
|
74
|
-
window.
|
|
74
|
+
window.remotion_renderReady = true;
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
77
|
exports.continueRender = continueRender;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPreviewDomElement = void 0;
|
|
3
|
+
exports.getPreviewDomElement = exports.REMOTION_STUDIO_CONTAINER_ELEMENT = void 0;
|
|
4
|
+
exports.REMOTION_STUDIO_CONTAINER_ELEMENT = '__remotion-studio-container';
|
|
4
5
|
const getPreviewDomElement = () => {
|
|
5
|
-
return document.getElementById(
|
|
6
|
+
return document.getElementById(exports.REMOTION_STUDIO_CONTAINER_ELEMENT);
|
|
6
7
|
};
|
|
7
8
|
exports.getPreviewDomElement = getPreviewDomElement;
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { ClipRegion } from './NativeLayers.js';
|
|
|
5
5
|
import type { VideoConfig } from './video-config.js';
|
|
6
6
|
declare global {
|
|
7
7
|
interface Window {
|
|
8
|
-
|
|
8
|
+
remotion_renderReady: boolean;
|
|
9
9
|
remotion_cancelledError: string | undefined;
|
|
10
10
|
getStaticCompositions: () => Promise<AnyCompMetadata[]>;
|
|
11
11
|
calculateComposition: (compId: string) => Promise<VideoConfig>;
|
package/dist/cjs/internals.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export declare const Internals: {
|
|
|
15
15
|
useUnsafeVideoConfig: () => import("./video-config.js").VideoConfig | null;
|
|
16
16
|
Timeline: typeof TimelinePosition;
|
|
17
17
|
CompositionManager: import("react").Context<CompositionManagerContext>;
|
|
18
|
+
SequenceManager: import("react").Context<import("./SequenceManager.js").SequenceManagerContext>;
|
|
18
19
|
RemotionRoot: import("react").FC<{
|
|
19
20
|
children: import("react").ReactNode;
|
|
20
21
|
numberOfAudioTags: number;
|
|
@@ -34,7 +35,6 @@ export declare const Internals: {
|
|
|
34
35
|
RemotionContextProvider: (props: import("./wrap-remotion-context.js").RemotionContextProviderProps) => JSX.Element;
|
|
35
36
|
CSSUtils: typeof CSSUtils;
|
|
36
37
|
setupEnvVariables: () => void;
|
|
37
|
-
ENV_VARIABLES_ENV_NAME: "ENV_VARIABLES";
|
|
38
38
|
MediaVolumeContext: import("react").Context<MediaVolumeContextValue>;
|
|
39
39
|
SetMediaVolumeContext: import("react").Context<SetMediaVolumeContextValue>;
|
|
40
40
|
validateDurationInFrames: ({ allowFloats, component, durationInFrames, }: {
|
|
@@ -124,5 +124,6 @@ export declare const Internals: {
|
|
|
124
124
|
ResolveCompositionConfig: import("react").FC<import("react").PropsWithChildren<{
|
|
125
125
|
children: import("react").ReactNode;
|
|
126
126
|
}>>;
|
|
127
|
+
REMOTION_STUDIO_CONTAINER_ELEMENT: string;
|
|
127
128
|
};
|
|
128
129
|
export type { TComposition, Timeline, TCompMetadata, TSequence, TAsset, TimelineContextValue, SetTimelineContextValue, CompProps, CompositionManagerContext, MediaVolumeContextValue, SetMediaVolumeContextValue, RemotionEnvironment, };
|
package/dist/cjs/internals.js
CHANGED
|
@@ -44,6 +44,7 @@ const RemotionRoot_js_1 = require("./RemotionRoot.js");
|
|
|
44
44
|
const resolve_video_config_js_1 = require("./resolve-video-config.js");
|
|
45
45
|
const ResolveCompositionConfig_js_1 = require("./ResolveCompositionConfig.js");
|
|
46
46
|
const SequenceContext_js_1 = require("./SequenceContext.js");
|
|
47
|
+
const SequenceManager_js_1 = require("./SequenceManager.js");
|
|
47
48
|
const setup_env_variables_js_1 = require("./setup-env-variables.js");
|
|
48
49
|
const TimelinePosition = __importStar(require("./timeline-position-state.js"));
|
|
49
50
|
const truthy_js_1 = require("./truthy.js");
|
|
@@ -66,6 +67,7 @@ exports.Internals = {
|
|
|
66
67
|
useUnsafeVideoConfig: use_unsafe_video_config_js_1.useUnsafeVideoConfig,
|
|
67
68
|
Timeline,
|
|
68
69
|
CompositionManager: CompositionManagerContext_js_1.CompositionManager,
|
|
70
|
+
SequenceManager: SequenceManager_js_1.SequenceManager,
|
|
69
71
|
RemotionRoot: RemotionRoot_js_1.RemotionRoot,
|
|
70
72
|
useVideo: use_video_js_1.useVideo,
|
|
71
73
|
getRoot: register_root_js_1.getRoot,
|
|
@@ -78,7 +80,6 @@ exports.Internals = {
|
|
|
78
80
|
RemotionContextProvider: wrap_remotion_context_js_1.RemotionContextProvider,
|
|
79
81
|
CSSUtils,
|
|
80
82
|
setupEnvVariables: setup_env_variables_js_1.setupEnvVariables,
|
|
81
|
-
ENV_VARIABLES_ENV_NAME: setup_env_variables_js_1.ENV_VARIABLES_ENV_NAME,
|
|
82
83
|
MediaVolumeContext: volume_position_state_js_1.MediaVolumeContext,
|
|
83
84
|
SetMediaVolumeContext: volume_position_state_js_1.SetMediaVolumeContext,
|
|
84
85
|
validateDurationInFrames: validate_duration_in_frames_js_1.validateDurationInFrames,
|
|
@@ -112,4 +113,5 @@ exports.Internals = {
|
|
|
112
113
|
useResolvedVideoConfig: ResolveCompositionConfig_js_1.useResolvedVideoConfig,
|
|
113
114
|
resolveCompositionsRef: ResolveCompositionConfig_js_1.resolveCompositionsRef,
|
|
114
115
|
ResolveCompositionConfig: ResolveCompositionConfig_js_1.ResolveCompositionConfig,
|
|
116
|
+
REMOTION_STUDIO_CONTAINER_ELEMENT: get_preview_dom_element_js_1.REMOTION_STUDIO_CONTAINER_ELEMENT,
|
|
115
117
|
};
|
package/dist/cjs/nonce.js
CHANGED
|
@@ -9,7 +9,13 @@ exports.NonceContext = (0, react_1.createContext)({
|
|
|
9
9
|
const useNonce = () => {
|
|
10
10
|
const context = (0, react_1.useContext)(exports.NonceContext);
|
|
11
11
|
const [nonce, setNonce] = (0, react_1.useState)(() => context.getNonce());
|
|
12
|
+
const lastContext = (0, react_1.useRef)(context);
|
|
13
|
+
// Only if context changes, but not initially
|
|
12
14
|
(0, react_1.useEffect)(() => {
|
|
15
|
+
if (lastContext.current === context) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
lastContext.current = context;
|
|
13
19
|
setNonce(context.getNonce);
|
|
14
20
|
}, [context]);
|
|
15
21
|
return nonce;
|
|
@@ -12,7 +12,7 @@ const resolveVideoConfig = ({ composition, editorProps: editorPropsOrUndefined,
|
|
|
12
12
|
props: {
|
|
13
13
|
...((_b = composition.defaultProps) !== null && _b !== void 0 ? _b : {}),
|
|
14
14
|
...(editorPropsOrUndefined !== null && editorPropsOrUndefined !== void 0 ? editorPropsOrUndefined : {}),
|
|
15
|
-
...((_c = (0, input_props_js_1.getInputProps)()) !== null && _c !== void 0 ? _c : {}),
|
|
15
|
+
...(typeof window === 'undefined' ? {} : (_c = (0, input_props_js_1.getInputProps)()) !== null && _c !== void 0 ? _c : {}),
|
|
16
16
|
},
|
|
17
17
|
abortSignal: signal,
|
|
18
18
|
})
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setupEnvVariables =
|
|
3
|
+
exports.setupEnvVariables = void 0;
|
|
4
4
|
const get_environment_js_1 = require("./get-environment.js");
|
|
5
|
-
exports.ENV_VARIABLES_ENV_NAME = 'ENV_VARIABLES';
|
|
6
5
|
const getEnvVariables = () => {
|
|
7
6
|
if ((0, get_environment_js_1.getRemotionEnvironment)() === 'rendering') {
|
|
8
7
|
const param = window.remotion_envVariables;
|
|
@@ -12,11 +11,10 @@ const getEnvVariables = () => {
|
|
|
12
11
|
return { ...JSON.parse(param), NODE_ENV: process.env.NODE_ENV };
|
|
13
12
|
}
|
|
14
13
|
if ((0, get_environment_js_1.getRemotionEnvironment)() === 'preview') {
|
|
15
|
-
//
|
|
16
|
-
//
|
|
14
|
+
// For the Preview, we already set the environment variables in index-html.ts.
|
|
15
|
+
// We just add NODE_ENV here.
|
|
17
16
|
return {
|
|
18
|
-
|
|
19
|
-
NODE_ENV: process.env.NODE_ENV,
|
|
17
|
+
NODE_ENV: 'development',
|
|
20
18
|
};
|
|
21
19
|
}
|
|
22
20
|
throw new Error('Can only call getEnvVariables() if environment is `rendering` or `preview`');
|