remotion 4.0.155 → 4.0.157
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/Composition.d.ts +2 -2
- package/dist/cjs/CompositionManager.js +16 -1
- package/dist/cjs/CompositionManagerContext.d.ts +1 -0
- package/dist/cjs/CompositionManagerContext.js +1 -0
- package/dist/cjs/EditorProps.d.ts +1 -0
- package/dist/cjs/EditorProps.js +8 -2
- package/dist/cjs/ResolveCompositionConfig.d.ts +1 -0
- package/dist/cjs/ResolveCompositionConfig.js +137 -28
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/internals.d.ts +10 -4
- package/dist/cjs/internals.js +1 -0
- package/dist/cjs/resolve-video-config.d.ts +11 -5
- package/dist/cjs/resolve-video-config.js +34 -31
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/index.mjs +210 -65
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
|
@@ -49,8 +49,8 @@ export type StillProps<Schema extends AnyZodObject, Props extends Record<string,
|
|
|
49
49
|
} & StillCalculateMetadataOrExplicit<Schema, Props> & CompProps<Props> & PropsIfHasProps<Schema, Props>;
|
|
50
50
|
export declare const ClipComposition: React.FC<PropsWithChildren>;
|
|
51
51
|
export type CompositionProps<Schema extends AnyZodObject, Props extends Record<string, unknown>> = {
|
|
52
|
-
id: string;
|
|
53
|
-
schema?: Schema;
|
|
52
|
+
readonly id: string;
|
|
53
|
+
readonly schema?: Schema;
|
|
54
54
|
} & CompositionCalculateMetadataOrExplicit<Schema, Props> & CompProps<Props> & PropsIfHasProps<Schema, Props>;
|
|
55
55
|
/**
|
|
56
56
|
* @description This component is used to register a video to make it renderable and make it show in the sidebar, in dev mode.
|
|
@@ -91,6 +91,20 @@ const CompositionManagerProvider = ({ children, numberOfAudioTags }) => {
|
|
|
91
91
|
const composition = compositions.find((c) => (canvasContent === null || canvasContent === void 0 ? void 0 : canvasContent.type) === 'composition'
|
|
92
92
|
? c.id === canvasContent.compositionId
|
|
93
93
|
: null);
|
|
94
|
+
const updateCompositionDefaultProps = (0, react_1.useCallback)((id, newDefaultProps) => {
|
|
95
|
+
setCompositions((comps) => {
|
|
96
|
+
const updated = comps.map((c) => {
|
|
97
|
+
if (c.id === id) {
|
|
98
|
+
return {
|
|
99
|
+
...c,
|
|
100
|
+
defaultProps: newDefaultProps,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
return c;
|
|
104
|
+
});
|
|
105
|
+
return updated;
|
|
106
|
+
});
|
|
107
|
+
}, []);
|
|
94
108
|
const contextValue = (0, react_1.useMemo)(() => {
|
|
95
109
|
return {
|
|
96
110
|
compositions,
|
|
@@ -103,6 +117,7 @@ const CompositionManagerProvider = ({ children, numberOfAudioTags }) => {
|
|
|
103
117
|
setCurrentCompositionMetadata,
|
|
104
118
|
canvasContent,
|
|
105
119
|
setCanvasContent,
|
|
120
|
+
updateCompositionDefaultProps,
|
|
106
121
|
};
|
|
107
122
|
}, [
|
|
108
123
|
compositions,
|
|
@@ -113,7 +128,7 @@ const CompositionManagerProvider = ({ children, numberOfAudioTags }) => {
|
|
|
113
128
|
unregisterFolder,
|
|
114
129
|
currentCompositionMetadata,
|
|
115
130
|
canvasContent,
|
|
116
|
-
|
|
131
|
+
updateCompositionDefaultProps,
|
|
117
132
|
]);
|
|
118
133
|
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)(RenderAssetManager_js_1.RenderAssetManagerProvider, { 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 }) }) }) }) }));
|
|
119
134
|
};
|
|
@@ -17,6 +17,7 @@ export type CanvasContent = {
|
|
|
17
17
|
export type CompositionManagerContext = {
|
|
18
18
|
compositions: AnyComposition[];
|
|
19
19
|
registerComposition: <Schema extends AnyZodObject, Props extends Record<string, unknown>>(comp: TComposition<Schema, Props>) => void;
|
|
20
|
+
updateCompositionDefaultProps: (id: string, newDefaultProps: Record<string, unknown>) => void;
|
|
20
21
|
unregisterComposition: (name: string) => void;
|
|
21
22
|
registerFolder: (name: string, parent: string | null) => void;
|
|
22
23
|
unregisterFolder: (name: string, parent: string | null) => void;
|
|
@@ -9,6 +9,7 @@ exports.CompositionManager = (0, react_1.createContext)({
|
|
|
9
9
|
registerFolder: () => undefined,
|
|
10
10
|
unregisterFolder: () => undefined,
|
|
11
11
|
setCurrentCompositionMetadata: () => undefined,
|
|
12
|
+
updateCompositionDefaultProps: () => undefined,
|
|
12
13
|
folders: [],
|
|
13
14
|
currentCompositionMetadata: null,
|
|
14
15
|
canvasContent: null,
|
|
@@ -7,6 +7,7 @@ export type EditorPropsContextType = {
|
|
|
7
7
|
defaultProps: Record<string, unknown>;
|
|
8
8
|
newProps: Record<string, unknown> | ((oldProps: Record<string, unknown>) => Record<string, unknown>);
|
|
9
9
|
}) => void;
|
|
10
|
+
resetUnsaved: () => void;
|
|
10
11
|
};
|
|
11
12
|
export declare const EditorPropsContext: React.Context<EditorPropsContextType>;
|
|
12
13
|
export declare const editorPropsProviderRef: React.RefObject<{
|
package/dist/cjs/EditorProps.js
CHANGED
|
@@ -31,6 +31,9 @@ exports.EditorPropsContext = (0, react_1.createContext)({
|
|
|
31
31
|
updateProps: () => {
|
|
32
32
|
throw new Error('Not implemented');
|
|
33
33
|
},
|
|
34
|
+
resetUnsaved: () => {
|
|
35
|
+
throw new Error('Not implemented');
|
|
36
|
+
},
|
|
34
37
|
});
|
|
35
38
|
exports.editorPropsProviderRef = react_1.default.createRef();
|
|
36
39
|
const EditorPropsProvider = ({ children }) => {
|
|
@@ -46,6 +49,9 @@ const EditorPropsProvider = ({ children }) => {
|
|
|
46
49
|
};
|
|
47
50
|
});
|
|
48
51
|
}, []);
|
|
52
|
+
const resetUnsaved = (0, react_1.useCallback)(() => {
|
|
53
|
+
setProps({});
|
|
54
|
+
}, []);
|
|
49
55
|
(0, react_1.useImperativeHandle)(exports.editorPropsProviderRef, () => {
|
|
50
56
|
return {
|
|
51
57
|
getProps: () => props,
|
|
@@ -53,8 +59,8 @@ const EditorPropsProvider = ({ children }) => {
|
|
|
53
59
|
};
|
|
54
60
|
}, [props]);
|
|
55
61
|
const ctx = (0, react_1.useMemo)(() => {
|
|
56
|
-
return { props, updateProps };
|
|
57
|
-
}, [props, updateProps]);
|
|
62
|
+
return { props, updateProps, resetUnsaved };
|
|
63
|
+
}, [props, resetUnsaved, updateProps]);
|
|
58
64
|
return ((0, jsx_runtime_1.jsx)(exports.EditorPropsContext.Provider, { value: ctx, children: children }));
|
|
59
65
|
};
|
|
60
66
|
exports.EditorPropsProvider = EditorPropsProvider;
|
|
@@ -20,6 +20,7 @@ type VideoConfigState = {
|
|
|
20
20
|
error: Error;
|
|
21
21
|
};
|
|
22
22
|
export declare const needsResolution: (composition: AnyComposition) => boolean;
|
|
23
|
+
export declare const PROPS_UPDATED_EXTERNALLY = "remotion.propsUpdatedExternally";
|
|
23
24
|
export declare const ResolveCompositionConfig: React.FC<PropsWithChildren<{
|
|
24
25
|
children: React.ReactNode;
|
|
25
26
|
}>>;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useResolvedVideoConfig = exports.ResolveCompositionConfig = exports.needsResolution = exports.resolveCompositionsRef = exports.ResolveCompositionContext = void 0;
|
|
3
|
+
exports.useResolvedVideoConfig = exports.ResolveCompositionConfig = exports.PROPS_UPDATED_EXTERNALLY = exports.needsResolution = 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
7
|
const EditorProps_js_1 = require("./EditorProps.js");
|
|
8
8
|
const input_props_js_1 = require("./config/input-props.js");
|
|
9
9
|
const get_remotion_environment_js_1 = require("./get-remotion-environment.js");
|
|
10
|
+
const nonce_js_1 = require("./nonce.js");
|
|
10
11
|
const resolve_video_config_js_1 = require("./resolve-video-config.js");
|
|
11
12
|
const validate_dimensions_js_1 = require("./validation/validate-dimensions.js");
|
|
12
13
|
const validate_duration_in_frames_js_1 = require("./validation/validate-duration-in-frames.js");
|
|
@@ -17,14 +18,24 @@ const needsResolution = (composition) => {
|
|
|
17
18
|
return Boolean(composition.calculateMetadata);
|
|
18
19
|
};
|
|
19
20
|
exports.needsResolution = needsResolution;
|
|
21
|
+
exports.PROPS_UPDATED_EXTERNALLY = 'remotion.propsUpdatedExternally';
|
|
20
22
|
const ResolveCompositionConfig = ({ children }) => {
|
|
21
23
|
const [currentRenderModalComposition, setCurrentRenderModalComposition] = (0, react_1.useState)(null);
|
|
22
24
|
const { compositions, canvasContent, currentCompositionMetadata } = (0, react_1.useContext)(CompositionManagerContext_js_1.CompositionManager);
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
const { fastRefreshes } = (0, react_1.useContext)(nonce_js_1.NonceContext);
|
|
26
|
+
const selectedComposition = (0, react_1.useMemo)(() => {
|
|
27
|
+
return compositions.find((c) => canvasContent &&
|
|
28
|
+
canvasContent.type === 'composition' &&
|
|
29
|
+
canvasContent.compositionId === c.id);
|
|
30
|
+
}, [canvasContent, compositions]);
|
|
26
31
|
const renderModalComposition = compositions.find((c) => c.id === currentRenderModalComposition);
|
|
27
32
|
const { props: allEditorProps } = (0, react_1.useContext)(EditorProps_js_1.EditorPropsContext);
|
|
33
|
+
const inputProps = (0, react_1.useMemo)(() => {
|
|
34
|
+
var _a;
|
|
35
|
+
return typeof window === 'undefined' || (0, get_remotion_environment_js_1.getRemotionEnvironment)().isPlayer
|
|
36
|
+
? {}
|
|
37
|
+
: (_a = (0, input_props_js_1.getInputProps)()) !== null && _a !== void 0 ? _a : {};
|
|
38
|
+
}, []);
|
|
28
39
|
const [resolvedConfigs, setResolvedConfigs] = (0, react_1.useState)({});
|
|
29
40
|
const selectedEditorProps = (0, react_1.useMemo)(() => {
|
|
30
41
|
var _a;
|
|
@@ -38,30 +49,32 @@ const ResolveCompositionConfig = ({ children }) => {
|
|
|
38
49
|
? (_a = allEditorProps[renderModalComposition.id]) !== null && _a !== void 0 ? _a : {}
|
|
39
50
|
: {};
|
|
40
51
|
}, [allEditorProps, renderModalComposition]);
|
|
41
|
-
const
|
|
42
|
-
|
|
52
|
+
const hasResolution = Boolean(currentCompositionMetadata);
|
|
53
|
+
const doResolution = (0, react_1.useCallback)(({ calculateMetadata, combinedProps, compositionDurationInFrames, compositionFps, compositionHeight, compositionId, compositionWidth, defaultProps, }) => {
|
|
43
54
|
const controller = new AbortController();
|
|
44
|
-
if (
|
|
55
|
+
if (hasResolution) {
|
|
45
56
|
return controller;
|
|
46
57
|
}
|
|
47
|
-
const inputProps = typeof window === 'undefined' || (0, get_remotion_environment_js_1.getRemotionEnvironment)().isPlayer
|
|
48
|
-
? {}
|
|
49
|
-
: (_a = (0, input_props_js_1.getInputProps)()) !== null && _a !== void 0 ? _a : {};
|
|
50
58
|
const { signal } = controller;
|
|
51
59
|
const promOrNot = (0, resolve_video_config_js_1.resolveVideoConfig)({
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
60
|
+
compositionId,
|
|
61
|
+
calculateMetadata,
|
|
62
|
+
originalProps: combinedProps,
|
|
55
63
|
signal,
|
|
64
|
+
defaultProps,
|
|
65
|
+
compositionDurationInFrames,
|
|
66
|
+
compositionFps,
|
|
67
|
+
compositionHeight,
|
|
68
|
+
compositionWidth,
|
|
56
69
|
});
|
|
57
70
|
if (typeof promOrNot === 'object' && 'then' in promOrNot) {
|
|
58
71
|
setResolvedConfigs((r) => {
|
|
59
|
-
const prev = r[
|
|
72
|
+
const prev = r[compositionId];
|
|
60
73
|
if ((prev === null || prev === void 0 ? void 0 : prev.type) === 'success' ||
|
|
61
74
|
(prev === null || prev === void 0 ? void 0 : prev.type) === 'success-and-refreshing') {
|
|
62
75
|
return {
|
|
63
76
|
...r,
|
|
64
|
-
[
|
|
77
|
+
[compositionId]: {
|
|
65
78
|
type: 'success-and-refreshing',
|
|
66
79
|
result: prev.result,
|
|
67
80
|
},
|
|
@@ -69,7 +82,7 @@ const ResolveCompositionConfig = ({ children }) => {
|
|
|
69
82
|
}
|
|
70
83
|
return {
|
|
71
84
|
...r,
|
|
72
|
-
[
|
|
85
|
+
[compositionId]: {
|
|
73
86
|
type: 'loading',
|
|
74
87
|
},
|
|
75
88
|
};
|
|
@@ -81,7 +94,7 @@ const ResolveCompositionConfig = ({ children }) => {
|
|
|
81
94
|
}
|
|
82
95
|
setResolvedConfigs((r) => ({
|
|
83
96
|
...r,
|
|
84
|
-
[
|
|
97
|
+
[compositionId]: {
|
|
85
98
|
type: 'success',
|
|
86
99
|
result: c,
|
|
87
100
|
},
|
|
@@ -93,7 +106,7 @@ const ResolveCompositionConfig = ({ children }) => {
|
|
|
93
106
|
}
|
|
94
107
|
setResolvedConfigs((r) => ({
|
|
95
108
|
...r,
|
|
96
|
-
[
|
|
109
|
+
[compositionId]: {
|
|
97
110
|
type: 'error',
|
|
98
111
|
error: err,
|
|
99
112
|
},
|
|
@@ -103,14 +116,14 @@ const ResolveCompositionConfig = ({ children }) => {
|
|
|
103
116
|
else {
|
|
104
117
|
setResolvedConfigs((r) => ({
|
|
105
118
|
...r,
|
|
106
|
-
[
|
|
119
|
+
[compositionId]: {
|
|
107
120
|
type: 'success',
|
|
108
121
|
result: promOrNot,
|
|
109
122
|
},
|
|
110
123
|
}));
|
|
111
124
|
}
|
|
112
125
|
return controller;
|
|
113
|
-
}, [
|
|
126
|
+
}, [hasResolution]);
|
|
114
127
|
const currentComposition = (canvasContent === null || canvasContent === void 0 ? void 0 : canvasContent.type) === 'composition' ? canvasContent.compositionId : null;
|
|
115
128
|
(0, react_1.useImperativeHandle)(exports.resolveCompositionsRef, () => {
|
|
116
129
|
return {
|
|
@@ -118,7 +131,7 @@ const ResolveCompositionConfig = ({ children }) => {
|
|
|
118
131
|
setCurrentRenderModalComposition(id);
|
|
119
132
|
},
|
|
120
133
|
reloadCurrentlySelectedComposition: () => {
|
|
121
|
-
var _a;
|
|
134
|
+
var _a, _b, _c, _d, _e, _f;
|
|
122
135
|
if (!currentComposition) {
|
|
123
136
|
return;
|
|
124
137
|
}
|
|
@@ -127,27 +140,123 @@ const ResolveCompositionConfig = ({ children }) => {
|
|
|
127
140
|
throw new Error(`Could not find composition with id ${currentComposition}`);
|
|
128
141
|
}
|
|
129
142
|
const editorProps = (_a = allEditorProps[currentComposition]) !== null && _a !== void 0 ? _a : {};
|
|
130
|
-
|
|
143
|
+
const defaultProps = {
|
|
144
|
+
...((_b = composition.defaultProps) !== null && _b !== void 0 ? _b : {}),
|
|
145
|
+
...(editorProps !== null && editorProps !== void 0 ? editorProps : {}),
|
|
146
|
+
};
|
|
147
|
+
const props = {
|
|
148
|
+
...(inputProps !== null && inputProps !== void 0 ? inputProps : {}),
|
|
149
|
+
};
|
|
150
|
+
doResolution({
|
|
151
|
+
defaultProps,
|
|
152
|
+
calculateMetadata: composition.calculateMetadata,
|
|
153
|
+
combinedProps: props,
|
|
154
|
+
compositionDurationInFrames: (_c = composition.durationInFrames) !== null && _c !== void 0 ? _c : null,
|
|
155
|
+
compositionFps: (_d = composition.fps) !== null && _d !== void 0 ? _d : null,
|
|
156
|
+
compositionHeight: (_e = composition.height) !== null && _e !== void 0 ? _e : null,
|
|
157
|
+
compositionWidth: (_f = composition.width) !== null && _f !== void 0 ? _f : null,
|
|
158
|
+
compositionId: composition.id,
|
|
159
|
+
});
|
|
131
160
|
},
|
|
132
161
|
};
|
|
133
|
-
}, [
|
|
162
|
+
}, [
|
|
163
|
+
allEditorProps,
|
|
164
|
+
compositions,
|
|
165
|
+
currentComposition,
|
|
166
|
+
doResolution,
|
|
167
|
+
inputProps,
|
|
168
|
+
]);
|
|
134
169
|
const isTheSame = (selectedComposition === null || selectedComposition === void 0 ? void 0 : selectedComposition.id) === (renderModalComposition === null || renderModalComposition === void 0 ? void 0 : renderModalComposition.id);
|
|
170
|
+
const currentDefaultProps = (0, react_1.useMemo)(() => {
|
|
171
|
+
var _a;
|
|
172
|
+
return {
|
|
173
|
+
...((_a = selectedComposition === null || selectedComposition === void 0 ? void 0 : selectedComposition.defaultProps) !== null && _a !== void 0 ? _a : {}),
|
|
174
|
+
...(selectedEditorProps !== null && selectedEditorProps !== void 0 ? selectedEditorProps : {}),
|
|
175
|
+
};
|
|
176
|
+
}, [selectedComposition === null || selectedComposition === void 0 ? void 0 : selectedComposition.defaultProps, selectedEditorProps]);
|
|
177
|
+
const originalProps = (0, react_1.useMemo)(() => {
|
|
178
|
+
return {
|
|
179
|
+
...currentDefaultProps,
|
|
180
|
+
...(inputProps !== null && inputProps !== void 0 ? inputProps : {}),
|
|
181
|
+
};
|
|
182
|
+
}, [currentDefaultProps, inputProps]);
|
|
183
|
+
const canResolve = selectedComposition && (0, exports.needsResolution)(selectedComposition);
|
|
184
|
+
const shouldIgnoreUpdate = typeof window !== 'undefined' &&
|
|
185
|
+
window.remotion_ignoreFastRefreshUpdate &&
|
|
186
|
+
fastRefreshes <= window.remotion_ignoreFastRefreshUpdate;
|
|
135
187
|
(0, react_1.useEffect)(() => {
|
|
136
|
-
|
|
137
|
-
|
|
188
|
+
var _a, _b, _c, _d;
|
|
189
|
+
if (shouldIgnoreUpdate) {
|
|
190
|
+
// We already have the current state, we just saved it back
|
|
191
|
+
// to the file
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
if (canResolve) {
|
|
195
|
+
const controller = doResolution({
|
|
196
|
+
calculateMetadata: selectedComposition.calculateMetadata,
|
|
197
|
+
combinedProps: originalProps,
|
|
198
|
+
compositionDurationInFrames: (_a = selectedComposition.durationInFrames) !== null && _a !== void 0 ? _a : null,
|
|
199
|
+
compositionFps: (_b = selectedComposition.fps) !== null && _b !== void 0 ? _b : null,
|
|
200
|
+
compositionHeight: (_c = selectedComposition.height) !== null && _c !== void 0 ? _c : null,
|
|
201
|
+
compositionWidth: (_d = selectedComposition.width) !== null && _d !== void 0 ? _d : null,
|
|
202
|
+
defaultProps: currentDefaultProps,
|
|
203
|
+
compositionId: selectedComposition.id,
|
|
204
|
+
});
|
|
138
205
|
return () => {
|
|
139
206
|
controller.abort();
|
|
140
207
|
};
|
|
141
208
|
}
|
|
142
|
-
}, [
|
|
209
|
+
}, [
|
|
210
|
+
canResolve,
|
|
211
|
+
currentDefaultProps,
|
|
212
|
+
doResolution,
|
|
213
|
+
originalProps,
|
|
214
|
+
selectedComposition === null || selectedComposition === void 0 ? void 0 : selectedComposition.calculateMetadata,
|
|
215
|
+
selectedComposition === null || selectedComposition === void 0 ? void 0 : selectedComposition.durationInFrames,
|
|
216
|
+
selectedComposition === null || selectedComposition === void 0 ? void 0 : selectedComposition.fps,
|
|
217
|
+
selectedComposition === null || selectedComposition === void 0 ? void 0 : selectedComposition.height,
|
|
218
|
+
selectedComposition === null || selectedComposition === void 0 ? void 0 : selectedComposition.id,
|
|
219
|
+
selectedComposition === null || selectedComposition === void 0 ? void 0 : selectedComposition.width,
|
|
220
|
+
shouldIgnoreUpdate,
|
|
221
|
+
]);
|
|
222
|
+
(0, react_1.useEffect)(() => {
|
|
223
|
+
if (shouldIgnoreUpdate) {
|
|
224
|
+
// We already have the current state, we just saved it back
|
|
225
|
+
// to the file
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
window.dispatchEvent(new CustomEvent('remotion.propsUpdatedExternally'));
|
|
229
|
+
}, [fastRefreshes, shouldIgnoreUpdate]);
|
|
143
230
|
(0, react_1.useEffect)(() => {
|
|
231
|
+
var _a, _b, _c, _d, _e;
|
|
144
232
|
if (renderModalComposition && !isTheSame) {
|
|
145
|
-
const
|
|
233
|
+
const combinedProps = {
|
|
234
|
+
...((_a = renderModalComposition.defaultProps) !== null && _a !== void 0 ? _a : {}),
|
|
235
|
+
...(renderModalProps !== null && renderModalProps !== void 0 ? renderModalProps : {}),
|
|
236
|
+
...(inputProps !== null && inputProps !== void 0 ? inputProps : {}),
|
|
237
|
+
};
|
|
238
|
+
const controller = doResolution({
|
|
239
|
+
calculateMetadata: renderModalComposition.calculateMetadata,
|
|
240
|
+
compositionDurationInFrames: (_b = renderModalComposition.durationInFrames) !== null && _b !== void 0 ? _b : null,
|
|
241
|
+
compositionFps: (_c = renderModalComposition.fps) !== null && _c !== void 0 ? _c : null,
|
|
242
|
+
compositionHeight: (_d = renderModalComposition.height) !== null && _d !== void 0 ? _d : null,
|
|
243
|
+
compositionId: renderModalComposition.id,
|
|
244
|
+
compositionWidth: (_e = renderModalComposition.width) !== null && _e !== void 0 ? _e : null,
|
|
245
|
+
defaultProps: currentDefaultProps,
|
|
246
|
+
combinedProps,
|
|
247
|
+
});
|
|
146
248
|
return () => {
|
|
147
249
|
controller.abort();
|
|
148
250
|
};
|
|
149
251
|
}
|
|
150
|
-
}, [
|
|
252
|
+
}, [
|
|
253
|
+
currentDefaultProps,
|
|
254
|
+
doResolution,
|
|
255
|
+
inputProps,
|
|
256
|
+
isTheSame,
|
|
257
|
+
renderModalComposition,
|
|
258
|
+
renderModalProps,
|
|
259
|
+
]);
|
|
151
260
|
const resolvedConfigsIncludingStaticOnes = (0, react_1.useMemo)(() => {
|
|
152
261
|
const staticComps = compositions.filter((c) => {
|
|
153
262
|
return c.calculateMetadata === null;
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ declare global {
|
|
|
29
29
|
remotion_publicPath: string;
|
|
30
30
|
remotion_publicFolderExists: string | null;
|
|
31
31
|
remotion_editorName: string | null;
|
|
32
|
+
remotion_ignoreFastRefreshUpdate: number | null;
|
|
32
33
|
remotion_numberOfAudioTags: number;
|
|
33
34
|
remotion_projectName: string;
|
|
34
35
|
remotion_cwd: string;
|
package/dist/cjs/internals.d.ts
CHANGED
|
@@ -88,11 +88,16 @@ export declare const Internals: {
|
|
|
88
88
|
readonly EditorPropsContext: import("react").Context<import("./EditorProps.js").EditorPropsContextType>;
|
|
89
89
|
readonly usePreload: (src: string) => string;
|
|
90
90
|
readonly NonceContext: import("react").Context<import("./nonce.js").TNonceContext>;
|
|
91
|
-
readonly resolveVideoConfig: ({
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
readonly resolveVideoConfig: ({ calculateMetadata, signal, defaultProps, originalProps, compositionId, compositionDurationInFrames, compositionFps, compositionHeight, compositionWidth, }: {
|
|
92
|
+
compositionId: string;
|
|
93
|
+
compositionWidth: number | null;
|
|
94
|
+
compositionHeight: number | null;
|
|
95
|
+
compositionFps: number | null;
|
|
96
|
+
compositionDurationInFrames: number | null;
|
|
97
|
+
calculateMetadata: import("./Composition.js").CalculateMetadataFunction<Record<string, unknown>> | null;
|
|
94
98
|
signal: AbortSignal;
|
|
95
|
-
|
|
99
|
+
defaultProps: Record<string, unknown>;
|
|
100
|
+
originalProps: Record<string, unknown>;
|
|
96
101
|
}) => import("./video-config.js").VideoConfig | Promise<import("./video-config.js").VideoConfig>;
|
|
97
102
|
readonly useResolvedVideoConfig: (preferredCompositionId: string | null) => ({
|
|
98
103
|
type: "loading";
|
|
@@ -166,5 +171,6 @@ export declare const Internals: {
|
|
|
166
171
|
[x: string]: Record<string, unknown>;
|
|
167
172
|
}>>;
|
|
168
173
|
}>;
|
|
174
|
+
readonly PROPS_UPDATED_EXTERNALLY: "remotion.propsUpdatedExternally";
|
|
169
175
|
};
|
|
170
176
|
export type { CompositionManagerContext, CompProps, MediaVolumeContextValue, RemotionEnvironment, SerializedJSONWithCustomFields, SetMediaVolumeContextValue, SetTimelineContextValue, TRenderAsset as TAsset, TCompMetadata, TComposition, TimelinePosition as Timeline, TimelineContextValue, TSequence, WatchRemotionStaticFilesPayload, };
|
package/dist/cjs/internals.js
CHANGED
|
@@ -125,4 +125,5 @@ exports.Internals = {
|
|
|
125
125
|
PreviewSizeContext: use_current_scale_js_1.PreviewSizeContext,
|
|
126
126
|
calculateScale: use_current_scale_js_1.calculateScale,
|
|
127
127
|
editorPropsProviderRef: EditorProps_js_1.editorPropsProviderRef,
|
|
128
|
+
PROPS_UPDATED_EXTERNALLY: ResolveCompositionConfig_js_1.PROPS_UPDATED_EXTERNALLY,
|
|
128
129
|
};
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import type { AnyZodObject } from 'zod';
|
|
2
|
-
import type {
|
|
2
|
+
import type { CalculateMetadataFunction } from './Composition.js';
|
|
3
|
+
import type { InferProps } from './props-if-has-props.js';
|
|
3
4
|
import type { VideoConfig } from './video-config.js';
|
|
4
|
-
export declare const resolveVideoConfig: ({
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
export declare const resolveVideoConfig: ({ calculateMetadata, signal, defaultProps, originalProps, compositionId, compositionDurationInFrames, compositionFps, compositionHeight, compositionWidth, }: {
|
|
6
|
+
compositionId: string;
|
|
7
|
+
compositionWidth: number | null;
|
|
8
|
+
compositionHeight: number | null;
|
|
9
|
+
compositionFps: number | null;
|
|
10
|
+
compositionDurationInFrames: number | null;
|
|
11
|
+
calculateMetadata: CalculateMetadataFunction<InferProps<AnyZodObject, Record<string, unknown>>> | null;
|
|
7
12
|
signal: AbortSignal;
|
|
8
|
-
|
|
13
|
+
defaultProps: Record<string, unknown>;
|
|
14
|
+
originalProps: Record<string, unknown>;
|
|
9
15
|
}) => VideoConfig | Promise<VideoConfig>;
|
|
@@ -5,80 +5,83 @@ const validate_default_codec_js_1 = require("./validation/validate-default-codec
|
|
|
5
5
|
const validate_dimensions_js_1 = require("./validation/validate-dimensions.js");
|
|
6
6
|
const validate_duration_in_frames_js_1 = require("./validation/validate-duration-in-frames.js");
|
|
7
7
|
const validate_fps_js_1 = require("./validation/validate-fps.js");
|
|
8
|
-
const validateCalculated = ({
|
|
8
|
+
const validateCalculated = ({ calculated, compositionId, compositionFps, compositionHeight, compositionWidth, compositionDurationInFrames, }) => {
|
|
9
9
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
10
|
-
const calculateMetadataErrorLocation = `calculated by calculateMetadata() for the composition "${
|
|
11
|
-
const defaultErrorLocation = `of the "<Composition />" component with the id "${
|
|
12
|
-
const width = (_b = (_a = calculated === null || calculated === void 0 ? void 0 : calculated.width) !== null && _a !== void 0 ? _a :
|
|
10
|
+
const calculateMetadataErrorLocation = `calculated by calculateMetadata() for the composition "${compositionId}"`;
|
|
11
|
+
const defaultErrorLocation = `of the "<Composition />" component with the id "${compositionId}"`;
|
|
12
|
+
const width = (_b = (_a = calculated === null || calculated === void 0 ? void 0 : calculated.width) !== null && _a !== void 0 ? _a : compositionWidth) !== null && _b !== void 0 ? _b : undefined;
|
|
13
13
|
(0, validate_dimensions_js_1.validateDimension)(width, 'width', (calculated === null || calculated === void 0 ? void 0 : calculated.width) ? calculateMetadataErrorLocation : defaultErrorLocation);
|
|
14
|
-
const height = (_d = (_c = calculated === null || calculated === void 0 ? void 0 : calculated.height) !== null && _c !== void 0 ? _c :
|
|
14
|
+
const height = (_d = (_c = calculated === null || calculated === void 0 ? void 0 : calculated.height) !== null && _c !== void 0 ? _c : compositionHeight) !== null && _d !== void 0 ? _d : undefined;
|
|
15
15
|
(0, validate_dimensions_js_1.validateDimension)(height, 'height', (calculated === null || calculated === void 0 ? void 0 : calculated.height) ? calculateMetadataErrorLocation : defaultErrorLocation);
|
|
16
|
-
const fps = (_f = (_e = calculated === null || calculated === void 0 ? void 0 : calculated.fps) !== null && _e !== void 0 ? _e :
|
|
16
|
+
const fps = (_f = (_e = calculated === null || calculated === void 0 ? void 0 : calculated.fps) !== null && _e !== void 0 ? _e : compositionFps) !== null && _f !== void 0 ? _f : null;
|
|
17
17
|
(0, validate_fps_js_1.validateFps)(fps, (calculated === null || calculated === void 0 ? void 0 : calculated.fps) ? calculateMetadataErrorLocation : defaultErrorLocation, false);
|
|
18
|
-
const durationInFrames = (_h = (_g = calculated === null || calculated === void 0 ? void 0 : calculated.durationInFrames) !== null && _g !== void 0 ? _g :
|
|
18
|
+
const durationInFrames = (_h = (_g = calculated === null || calculated === void 0 ? void 0 : calculated.durationInFrames) !== null && _g !== void 0 ? _g : compositionDurationInFrames) !== null && _h !== void 0 ? _h : null;
|
|
19
19
|
(0, validate_duration_in_frames_js_1.validateDurationInFrames)(durationInFrames, {
|
|
20
20
|
allowFloats: false,
|
|
21
|
-
component: `of the "<Composition />" component with the id "${
|
|
21
|
+
component: `of the "<Composition />" component with the id "${compositionId}"`,
|
|
22
22
|
});
|
|
23
23
|
const defaultCodec = calculated === null || calculated === void 0 ? void 0 : calculated.defaultCodec;
|
|
24
24
|
(0, validate_default_codec_js_1.validateDefaultCodec)(defaultCodec, calculateMetadataErrorLocation);
|
|
25
25
|
return { width, height, fps, durationInFrames, defaultCodec };
|
|
26
26
|
};
|
|
27
|
-
const resolveVideoConfig = ({
|
|
28
|
-
var _a, _b
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
...(inputProps !== null && inputProps !== void 0 ? inputProps : {}),
|
|
33
|
-
};
|
|
34
|
-
const calculatedProm = composition.calculateMetadata
|
|
35
|
-
? composition.calculateMetadata({
|
|
36
|
-
defaultProps: (_b = composition.defaultProps) !== null && _b !== void 0 ? _b : {},
|
|
27
|
+
const resolveVideoConfig = ({ calculateMetadata, signal, defaultProps, originalProps, compositionId, compositionDurationInFrames, compositionFps, compositionHeight, compositionWidth, }) => {
|
|
28
|
+
var _a, _b;
|
|
29
|
+
const calculatedProm = calculateMetadata
|
|
30
|
+
? calculateMetadata({
|
|
31
|
+
defaultProps,
|
|
37
32
|
props: originalProps,
|
|
38
33
|
abortSignal: signal,
|
|
39
|
-
compositionId
|
|
34
|
+
compositionId,
|
|
40
35
|
})
|
|
41
36
|
: null;
|
|
42
37
|
if (calculatedProm !== null &&
|
|
43
38
|
typeof calculatedProm === 'object' &&
|
|
44
39
|
'then' in calculatedProm) {
|
|
45
40
|
return calculatedProm.then((c) => {
|
|
46
|
-
var _a
|
|
41
|
+
var _a;
|
|
47
42
|
const { height, width, durationInFrames, fps, defaultCodec } = validateCalculated({
|
|
48
43
|
calculated: c,
|
|
49
|
-
|
|
44
|
+
compositionDurationInFrames,
|
|
45
|
+
compositionFps,
|
|
46
|
+
compositionHeight,
|
|
47
|
+
compositionWidth,
|
|
48
|
+
compositionId,
|
|
50
49
|
});
|
|
51
50
|
return {
|
|
52
51
|
width,
|
|
53
52
|
height,
|
|
54
53
|
fps,
|
|
55
54
|
durationInFrames,
|
|
56
|
-
id:
|
|
57
|
-
defaultProps
|
|
58
|
-
props: (
|
|
55
|
+
id: compositionId,
|
|
56
|
+
defaultProps,
|
|
57
|
+
props: (_a = c.props) !== null && _a !== void 0 ? _a : originalProps,
|
|
59
58
|
defaultCodec: defaultCodec !== null && defaultCodec !== void 0 ? defaultCodec : null,
|
|
60
59
|
};
|
|
61
60
|
});
|
|
62
61
|
}
|
|
63
62
|
const data = validateCalculated({
|
|
64
63
|
calculated: calculatedProm,
|
|
65
|
-
|
|
64
|
+
compositionDurationInFrames,
|
|
65
|
+
compositionFps,
|
|
66
|
+
compositionHeight,
|
|
67
|
+
compositionWidth,
|
|
68
|
+
compositionId,
|
|
66
69
|
});
|
|
67
70
|
if (calculatedProm === null) {
|
|
68
71
|
return {
|
|
69
72
|
...data,
|
|
70
|
-
id:
|
|
71
|
-
defaultProps:
|
|
73
|
+
id: compositionId,
|
|
74
|
+
defaultProps: defaultProps !== null && defaultProps !== void 0 ? defaultProps : {},
|
|
72
75
|
props: originalProps,
|
|
73
76
|
defaultCodec: null,
|
|
74
77
|
};
|
|
75
78
|
}
|
|
76
79
|
return {
|
|
77
80
|
...data,
|
|
78
|
-
id:
|
|
79
|
-
defaultProps:
|
|
80
|
-
props: (
|
|
81
|
-
defaultCodec: (
|
|
81
|
+
id: compositionId,
|
|
82
|
+
defaultProps: defaultProps !== null && defaultProps !== void 0 ? defaultProps : {},
|
|
83
|
+
props: (_a = calculatedProm.props) !== null && _a !== void 0 ? _a : originalProps,
|
|
84
|
+
defaultCodec: (_b = calculatedProm.defaultCodec) !== null && _b !== void 0 ? _b : null,
|
|
82
85
|
};
|
|
83
86
|
};
|
|
84
87
|
exports.resolveVideoConfig = resolveVideoConfig;
|
package/dist/cjs/version.d.ts
CHANGED
package/dist/cjs/version.js
CHANGED
package/dist/esm/index.mjs
CHANGED
|
@@ -132,7 +132,7 @@ function truthy(value) {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
// src/version.ts
|
|
135
|
-
var VERSION = "4.0.
|
|
135
|
+
var VERSION = "4.0.157";
|
|
136
136
|
|
|
137
137
|
// src/multiple-versions-warning.ts
|
|
138
138
|
var checkMultipleRemotionVersions = () => {
|
|
@@ -359,6 +359,9 @@ var CompositionManager = createContext5({
|
|
|
359
359
|
setCurrentCompositionMetadata: () => {
|
|
360
360
|
return;
|
|
361
361
|
},
|
|
362
|
+
updateCompositionDefaultProps: () => {
|
|
363
|
+
return;
|
|
364
|
+
},
|
|
362
365
|
folders: [],
|
|
363
366
|
currentCompositionMetadata: null,
|
|
364
367
|
canvasContent: null,
|
|
@@ -393,6 +396,9 @@ var EditorPropsContext = createContext6({
|
|
|
393
396
|
props: {},
|
|
394
397
|
updateProps: () => {
|
|
395
398
|
throw new Error("Not implemented");
|
|
399
|
+
},
|
|
400
|
+
resetUnsaved: () => {
|
|
401
|
+
throw new Error("Not implemented");
|
|
396
402
|
}
|
|
397
403
|
});
|
|
398
404
|
var editorPropsProviderRef = React4.createRef();
|
|
@@ -410,6 +416,9 @@ var EditorPropsProvider = ({ children }) => {
|
|
|
410
416
|
};
|
|
411
417
|
});
|
|
412
418
|
}, []);
|
|
419
|
+
const resetUnsaved = useCallback2(() => {
|
|
420
|
+
setProps({});
|
|
421
|
+
}, []);
|
|
413
422
|
useImperativeHandle(editorPropsProviderRef, () => {
|
|
414
423
|
return {
|
|
415
424
|
getProps: () => props,
|
|
@@ -417,8 +426,8 @@ var EditorPropsProvider = ({ children }) => {
|
|
|
417
426
|
};
|
|
418
427
|
}, [props]);
|
|
419
428
|
const ctx = useMemo4(() => {
|
|
420
|
-
return { props, updateProps };
|
|
421
|
-
}, [props, updateProps]);
|
|
429
|
+
return { props, updateProps, resetUnsaved };
|
|
430
|
+
}, [props, resetUnsaved, updateProps]);
|
|
422
431
|
return jsx5(EditorPropsContext.Provider, {
|
|
423
432
|
value: ctx,
|
|
424
433
|
children
|
|
@@ -639,56 +648,64 @@ function validateFps(fps, location, isGif) {
|
|
|
639
648
|
|
|
640
649
|
// src/resolve-video-config.ts
|
|
641
650
|
var validateCalculated = ({
|
|
642
|
-
|
|
643
|
-
|
|
651
|
+
calculated,
|
|
652
|
+
compositionId,
|
|
653
|
+
compositionFps,
|
|
654
|
+
compositionHeight,
|
|
655
|
+
compositionWidth,
|
|
656
|
+
compositionDurationInFrames
|
|
644
657
|
}) => {
|
|
645
|
-
const calculateMetadataErrorLocation = `calculated by calculateMetadata() for the composition "${
|
|
646
|
-
const defaultErrorLocation = `of the "<Composition />" component with the id "${
|
|
647
|
-
const width = calculated?.width ??
|
|
658
|
+
const calculateMetadataErrorLocation = `calculated by calculateMetadata() for the composition "${compositionId}"`;
|
|
659
|
+
const defaultErrorLocation = `of the "<Composition />" component with the id "${compositionId}"`;
|
|
660
|
+
const width = calculated?.width ?? compositionWidth ?? undefined;
|
|
648
661
|
validateDimension(width, "width", calculated?.width ? calculateMetadataErrorLocation : defaultErrorLocation);
|
|
649
|
-
const height = calculated?.height ??
|
|
662
|
+
const height = calculated?.height ?? compositionHeight ?? undefined;
|
|
650
663
|
validateDimension(height, "height", calculated?.height ? calculateMetadataErrorLocation : defaultErrorLocation);
|
|
651
|
-
const fps = calculated?.fps ??
|
|
664
|
+
const fps = calculated?.fps ?? compositionFps ?? null;
|
|
652
665
|
validateFps(fps, calculated?.fps ? calculateMetadataErrorLocation : defaultErrorLocation, false);
|
|
653
|
-
const durationInFrames = calculated?.durationInFrames ??
|
|
666
|
+
const durationInFrames = calculated?.durationInFrames ?? compositionDurationInFrames ?? null;
|
|
654
667
|
validateDurationInFrames(durationInFrames, {
|
|
655
668
|
allowFloats: false,
|
|
656
|
-
component: `of the "<Composition />" component with the id "${
|
|
669
|
+
component: `of the "<Composition />" component with the id "${compositionId}"`
|
|
657
670
|
});
|
|
658
671
|
const defaultCodec = calculated?.defaultCodec;
|
|
659
672
|
validateDefaultCodec(defaultCodec, calculateMetadataErrorLocation);
|
|
660
673
|
return { width, height, fps, durationInFrames, defaultCodec };
|
|
661
674
|
};
|
|
662
675
|
var resolveVideoConfig = ({
|
|
663
|
-
|
|
664
|
-
editorProps: editorPropsOrUndefined,
|
|
676
|
+
calculateMetadata,
|
|
665
677
|
signal,
|
|
666
|
-
|
|
678
|
+
defaultProps,
|
|
679
|
+
originalProps,
|
|
680
|
+
compositionId,
|
|
681
|
+
compositionDurationInFrames,
|
|
682
|
+
compositionFps,
|
|
683
|
+
compositionHeight,
|
|
684
|
+
compositionWidth
|
|
667
685
|
}) => {
|
|
668
|
-
const
|
|
669
|
-
|
|
670
|
-
...editorPropsOrUndefined ?? {},
|
|
671
|
-
...inputProps ?? {}
|
|
672
|
-
};
|
|
673
|
-
const calculatedProm = composition.calculateMetadata ? composition.calculateMetadata({
|
|
674
|
-
defaultProps: composition.defaultProps ?? {},
|
|
686
|
+
const calculatedProm = calculateMetadata ? calculateMetadata({
|
|
687
|
+
defaultProps,
|
|
675
688
|
props: originalProps,
|
|
676
689
|
abortSignal: signal,
|
|
677
|
-
compositionId
|
|
690
|
+
compositionId
|
|
678
691
|
}) : null;
|
|
679
692
|
if (calculatedProm !== null && typeof calculatedProm === "object" && "then" in calculatedProm) {
|
|
680
693
|
return calculatedProm.then((c) => {
|
|
681
694
|
const { height, width, durationInFrames, fps, defaultCodec } = validateCalculated({
|
|
682
695
|
calculated: c,
|
|
683
|
-
|
|
696
|
+
compositionDurationInFrames,
|
|
697
|
+
compositionFps,
|
|
698
|
+
compositionHeight,
|
|
699
|
+
compositionWidth,
|
|
700
|
+
compositionId
|
|
684
701
|
});
|
|
685
702
|
return {
|
|
686
703
|
width,
|
|
687
704
|
height,
|
|
688
705
|
fps,
|
|
689
706
|
durationInFrames,
|
|
690
|
-
id:
|
|
691
|
-
defaultProps
|
|
707
|
+
id: compositionId,
|
|
708
|
+
defaultProps,
|
|
692
709
|
props: c.props ?? originalProps,
|
|
693
710
|
defaultCodec: defaultCodec ?? null
|
|
694
711
|
};
|
|
@@ -696,21 +713,25 @@ var resolveVideoConfig = ({
|
|
|
696
713
|
}
|
|
697
714
|
const data = validateCalculated({
|
|
698
715
|
calculated: calculatedProm,
|
|
699
|
-
|
|
716
|
+
compositionDurationInFrames,
|
|
717
|
+
compositionFps,
|
|
718
|
+
compositionHeight,
|
|
719
|
+
compositionWidth,
|
|
720
|
+
compositionId
|
|
700
721
|
});
|
|
701
722
|
if (calculatedProm === null) {
|
|
702
723
|
return {
|
|
703
724
|
...data,
|
|
704
|
-
id:
|
|
705
|
-
defaultProps:
|
|
725
|
+
id: compositionId,
|
|
726
|
+
defaultProps: defaultProps ?? {},
|
|
706
727
|
props: originalProps,
|
|
707
728
|
defaultCodec: null
|
|
708
729
|
};
|
|
709
730
|
}
|
|
710
731
|
return {
|
|
711
732
|
...data,
|
|
712
|
-
id:
|
|
713
|
-
defaultProps:
|
|
733
|
+
id: compositionId,
|
|
734
|
+
defaultProps: defaultProps ?? {},
|
|
714
735
|
props: calculatedProm.props ?? originalProps,
|
|
715
736
|
defaultCodec: calculatedProm.defaultCodec ?? null
|
|
716
737
|
};
|
|
@@ -725,12 +746,19 @@ var resolveCompositionsRef = createRef();
|
|
|
725
746
|
var needsResolution = (composition) => {
|
|
726
747
|
return Boolean(composition.calculateMetadata);
|
|
727
748
|
};
|
|
749
|
+
var PROPS_UPDATED_EXTERNALLY = "remotion.propsUpdatedExternally";
|
|
728
750
|
var ResolveCompositionConfig = ({ children }) => {
|
|
729
751
|
const [currentRenderModalComposition, setCurrentRenderModalComposition] = useState4(null);
|
|
730
752
|
const { compositions, canvasContent, currentCompositionMetadata } = useContext5(CompositionManager);
|
|
731
|
-
const
|
|
753
|
+
const { fastRefreshes } = useContext5(NonceContext);
|
|
754
|
+
const selectedComposition = useMemo5(() => {
|
|
755
|
+
return compositions.find((c) => canvasContent && canvasContent.type === "composition" && canvasContent.compositionId === c.id);
|
|
756
|
+
}, [canvasContent, compositions]);
|
|
732
757
|
const renderModalComposition = compositions.find((c) => c.id === currentRenderModalComposition);
|
|
733
758
|
const { props: allEditorProps } = useContext5(EditorPropsContext);
|
|
759
|
+
const inputProps = useMemo5(() => {
|
|
760
|
+
return typeof window === "undefined" || getRemotionEnvironment().isPlayer ? {} : getInputProps() ?? {};
|
|
761
|
+
}, []);
|
|
734
762
|
const [resolvedConfigs, setResolvedConfigs] = useState4({});
|
|
735
763
|
const selectedEditorProps = useMemo5(() => {
|
|
736
764
|
return selectedComposition ? allEditorProps[selectedComposition.id] ?? {} : {};
|
|
@@ -738,26 +766,40 @@ var ResolveCompositionConfig = ({ children }) => {
|
|
|
738
766
|
const renderModalProps = useMemo5(() => {
|
|
739
767
|
return renderModalComposition ? allEditorProps[renderModalComposition.id] ?? {} : {};
|
|
740
768
|
}, [allEditorProps, renderModalComposition]);
|
|
741
|
-
const
|
|
769
|
+
const hasResolution = Boolean(currentCompositionMetadata);
|
|
770
|
+
const doResolution = useCallback3(({
|
|
771
|
+
calculateMetadata,
|
|
772
|
+
combinedProps,
|
|
773
|
+
compositionDurationInFrames,
|
|
774
|
+
compositionFps,
|
|
775
|
+
compositionHeight,
|
|
776
|
+
compositionId,
|
|
777
|
+
compositionWidth,
|
|
778
|
+
defaultProps
|
|
779
|
+
}) => {
|
|
742
780
|
const controller = new AbortController;
|
|
743
|
-
if (
|
|
781
|
+
if (hasResolution) {
|
|
744
782
|
return controller;
|
|
745
783
|
}
|
|
746
|
-
const inputProps = typeof window === "undefined" || getRemotionEnvironment().isPlayer ? {} : getInputProps() ?? {};
|
|
747
784
|
const { signal } = controller;
|
|
748
785
|
const promOrNot = resolveVideoConfig({
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
signal
|
|
786
|
+
compositionId,
|
|
787
|
+
calculateMetadata,
|
|
788
|
+
originalProps: combinedProps,
|
|
789
|
+
signal,
|
|
790
|
+
defaultProps,
|
|
791
|
+
compositionDurationInFrames,
|
|
792
|
+
compositionFps,
|
|
793
|
+
compositionHeight,
|
|
794
|
+
compositionWidth
|
|
753
795
|
});
|
|
754
796
|
if (typeof promOrNot === "object" && "then" in promOrNot) {
|
|
755
797
|
setResolvedConfigs((r) => {
|
|
756
|
-
const prev = r[
|
|
798
|
+
const prev = r[compositionId];
|
|
757
799
|
if (prev?.type === "success" || prev?.type === "success-and-refreshing") {
|
|
758
800
|
return {
|
|
759
801
|
...r,
|
|
760
|
-
[
|
|
802
|
+
[compositionId]: {
|
|
761
803
|
type: "success-and-refreshing",
|
|
762
804
|
result: prev.result
|
|
763
805
|
}
|
|
@@ -765,7 +807,7 @@ var ResolveCompositionConfig = ({ children }) => {
|
|
|
765
807
|
}
|
|
766
808
|
return {
|
|
767
809
|
...r,
|
|
768
|
-
[
|
|
810
|
+
[compositionId]: {
|
|
769
811
|
type: "loading"
|
|
770
812
|
}
|
|
771
813
|
};
|
|
@@ -776,7 +818,7 @@ var ResolveCompositionConfig = ({ children }) => {
|
|
|
776
818
|
}
|
|
777
819
|
setResolvedConfigs((r) => ({
|
|
778
820
|
...r,
|
|
779
|
-
[
|
|
821
|
+
[compositionId]: {
|
|
780
822
|
type: "success",
|
|
781
823
|
result: c
|
|
782
824
|
}
|
|
@@ -787,7 +829,7 @@ var ResolveCompositionConfig = ({ children }) => {
|
|
|
787
829
|
}
|
|
788
830
|
setResolvedConfigs((r) => ({
|
|
789
831
|
...r,
|
|
790
|
-
[
|
|
832
|
+
[compositionId]: {
|
|
791
833
|
type: "error",
|
|
792
834
|
error: err
|
|
793
835
|
}
|
|
@@ -796,14 +838,14 @@ var ResolveCompositionConfig = ({ children }) => {
|
|
|
796
838
|
} else {
|
|
797
839
|
setResolvedConfigs((r) => ({
|
|
798
840
|
...r,
|
|
799
|
-
[
|
|
841
|
+
[compositionId]: {
|
|
800
842
|
type: "success",
|
|
801
843
|
result: promOrNot
|
|
802
844
|
}
|
|
803
845
|
}));
|
|
804
846
|
}
|
|
805
847
|
return controller;
|
|
806
|
-
}, [
|
|
848
|
+
}, [hasResolution]);
|
|
807
849
|
const currentComposition = canvasContent?.type === "composition" ? canvasContent.compositionId : null;
|
|
808
850
|
useImperativeHandle2(resolveCompositionsRef, () => {
|
|
809
851
|
return {
|
|
@@ -819,27 +861,114 @@ var ResolveCompositionConfig = ({ children }) => {
|
|
|
819
861
|
throw new Error(`Could not find composition with id ${currentComposition}`);
|
|
820
862
|
}
|
|
821
863
|
const editorProps = allEditorProps[currentComposition] ?? {};
|
|
822
|
-
|
|
864
|
+
const defaultProps = {
|
|
865
|
+
...composition.defaultProps ?? {},
|
|
866
|
+
...editorProps ?? {}
|
|
867
|
+
};
|
|
868
|
+
const props = {
|
|
869
|
+
...inputProps ?? {}
|
|
870
|
+
};
|
|
871
|
+
doResolution({
|
|
872
|
+
defaultProps,
|
|
873
|
+
calculateMetadata: composition.calculateMetadata,
|
|
874
|
+
combinedProps: props,
|
|
875
|
+
compositionDurationInFrames: composition.durationInFrames ?? null,
|
|
876
|
+
compositionFps: composition.fps ?? null,
|
|
877
|
+
compositionHeight: composition.height ?? null,
|
|
878
|
+
compositionWidth: composition.width ?? null,
|
|
879
|
+
compositionId: composition.id
|
|
880
|
+
});
|
|
823
881
|
}
|
|
824
882
|
};
|
|
825
|
-
}, [
|
|
883
|
+
}, [
|
|
884
|
+
allEditorProps,
|
|
885
|
+
compositions,
|
|
886
|
+
currentComposition,
|
|
887
|
+
doResolution,
|
|
888
|
+
inputProps
|
|
889
|
+
]);
|
|
826
890
|
const isTheSame = selectedComposition?.id === renderModalComposition?.id;
|
|
891
|
+
const currentDefaultProps = useMemo5(() => {
|
|
892
|
+
return {
|
|
893
|
+
...selectedComposition?.defaultProps ?? {},
|
|
894
|
+
...selectedEditorProps ?? {}
|
|
895
|
+
};
|
|
896
|
+
}, [selectedComposition?.defaultProps, selectedEditorProps]);
|
|
897
|
+
const originalProps = useMemo5(() => {
|
|
898
|
+
return {
|
|
899
|
+
...currentDefaultProps,
|
|
900
|
+
...inputProps ?? {}
|
|
901
|
+
};
|
|
902
|
+
}, [currentDefaultProps, inputProps]);
|
|
903
|
+
const canResolve = selectedComposition && needsResolution(selectedComposition);
|
|
904
|
+
const shouldIgnoreUpdate = typeof window !== "undefined" && window.remotion_ignoreFastRefreshUpdate && fastRefreshes <= window.remotion_ignoreFastRefreshUpdate;
|
|
827
905
|
useEffect4(() => {
|
|
828
|
-
if (
|
|
829
|
-
|
|
906
|
+
if (shouldIgnoreUpdate) {
|
|
907
|
+
return;
|
|
908
|
+
}
|
|
909
|
+
if (canResolve) {
|
|
910
|
+
const controller = doResolution({
|
|
911
|
+
calculateMetadata: selectedComposition.calculateMetadata,
|
|
912
|
+
combinedProps: originalProps,
|
|
913
|
+
compositionDurationInFrames: selectedComposition.durationInFrames ?? null,
|
|
914
|
+
compositionFps: selectedComposition.fps ?? null,
|
|
915
|
+
compositionHeight: selectedComposition.height ?? null,
|
|
916
|
+
compositionWidth: selectedComposition.width ?? null,
|
|
917
|
+
defaultProps: currentDefaultProps,
|
|
918
|
+
compositionId: selectedComposition.id
|
|
919
|
+
});
|
|
830
920
|
return () => {
|
|
831
921
|
controller.abort();
|
|
832
922
|
};
|
|
833
923
|
}
|
|
834
|
-
}, [
|
|
924
|
+
}, [
|
|
925
|
+
canResolve,
|
|
926
|
+
currentDefaultProps,
|
|
927
|
+
doResolution,
|
|
928
|
+
originalProps,
|
|
929
|
+
selectedComposition?.calculateMetadata,
|
|
930
|
+
selectedComposition?.durationInFrames,
|
|
931
|
+
selectedComposition?.fps,
|
|
932
|
+
selectedComposition?.height,
|
|
933
|
+
selectedComposition?.id,
|
|
934
|
+
selectedComposition?.width,
|
|
935
|
+
shouldIgnoreUpdate
|
|
936
|
+
]);
|
|
937
|
+
useEffect4(() => {
|
|
938
|
+
if (shouldIgnoreUpdate) {
|
|
939
|
+
return;
|
|
940
|
+
}
|
|
941
|
+
window.dispatchEvent(new CustomEvent("remotion.propsUpdatedExternally"));
|
|
942
|
+
}, [fastRefreshes, shouldIgnoreUpdate]);
|
|
835
943
|
useEffect4(() => {
|
|
836
944
|
if (renderModalComposition && !isTheSame) {
|
|
837
|
-
const
|
|
945
|
+
const combinedProps = {
|
|
946
|
+
...renderModalComposition.defaultProps ?? {},
|
|
947
|
+
...renderModalProps ?? {},
|
|
948
|
+
...inputProps ?? {}
|
|
949
|
+
};
|
|
950
|
+
const controller = doResolution({
|
|
951
|
+
calculateMetadata: renderModalComposition.calculateMetadata,
|
|
952
|
+
compositionDurationInFrames: renderModalComposition.durationInFrames ?? null,
|
|
953
|
+
compositionFps: renderModalComposition.fps ?? null,
|
|
954
|
+
compositionHeight: renderModalComposition.height ?? null,
|
|
955
|
+
compositionId: renderModalComposition.id,
|
|
956
|
+
compositionWidth: renderModalComposition.width ?? null,
|
|
957
|
+
defaultProps: currentDefaultProps,
|
|
958
|
+
combinedProps
|
|
959
|
+
});
|
|
838
960
|
return () => {
|
|
839
961
|
controller.abort();
|
|
840
962
|
};
|
|
841
963
|
}
|
|
842
|
-
}, [
|
|
964
|
+
}, [
|
|
965
|
+
currentDefaultProps,
|
|
966
|
+
doResolution,
|
|
967
|
+
inputProps,
|
|
968
|
+
isTheSame,
|
|
969
|
+
renderModalComposition,
|
|
970
|
+
renderModalProps
|
|
971
|
+
]);
|
|
843
972
|
const resolvedConfigsIncludingStaticOnes = useMemo5(() => {
|
|
844
973
|
const staticComps = compositions.filter((c) => {
|
|
845
974
|
return c.calculateMetadata === null;
|
|
@@ -1182,7 +1311,7 @@ var RegularSequenceRefForwardingFunction = ({
|
|
|
1182
1311
|
const parentSequence = useContext12(SequenceContext);
|
|
1183
1312
|
const { rootId } = useContext12(TimelineContext);
|
|
1184
1313
|
const cumulatedFrom = parentSequence ? parentSequence.cumulatedFrom + parentSequence.relativeFrom : 0;
|
|
1185
|
-
const
|
|
1314
|
+
const nonce3 = useNonce();
|
|
1186
1315
|
if (layout !== "absolute-fill" && layout !== "none") {
|
|
1187
1316
|
throw new TypeError(`The layout prop of <Sequence /> expects either "absolute-fill" or "none", but you passed: ${layout}`);
|
|
1188
1317
|
}
|
|
@@ -1247,7 +1376,7 @@ var RegularSequenceRefForwardingFunction = ({
|
|
|
1247
1376
|
type: "sequence",
|
|
1248
1377
|
rootId,
|
|
1249
1378
|
showInTimeline,
|
|
1250
|
-
nonce:
|
|
1379
|
+
nonce: nonce3,
|
|
1251
1380
|
loopDisplay,
|
|
1252
1381
|
stack: stack ?? null,
|
|
1253
1382
|
premountDisplay: premountDisplay ?? null
|
|
@@ -1267,7 +1396,7 @@ var RegularSequenceRefForwardingFunction = ({
|
|
|
1267
1396
|
rootId,
|
|
1268
1397
|
from,
|
|
1269
1398
|
showInTimeline,
|
|
1270
|
-
|
|
1399
|
+
nonce3,
|
|
1271
1400
|
loopDisplay,
|
|
1272
1401
|
stack,
|
|
1273
1402
|
premountDisplay
|
|
@@ -2044,7 +2173,7 @@ var useMediaInTimeline = ({
|
|
|
2044
2173
|
const startsAt = useMediaStartsAt();
|
|
2045
2174
|
const { registerSequence, unregisterSequence } = useContext16(SequenceManager);
|
|
2046
2175
|
const [initialVolume] = useState8(() => volume);
|
|
2047
|
-
const
|
|
2176
|
+
const nonce4 = useNonce();
|
|
2048
2177
|
const duration = parentSequence ? Math.min(parentSequence.durationInFrames, videoConfig.durationInFrames) : videoConfig.durationInFrames;
|
|
2049
2178
|
const doesVolumeChange = typeof volume === "function";
|
|
2050
2179
|
const volumes = useMemo15(() => {
|
|
@@ -2089,7 +2218,7 @@ var useMediaInTimeline = ({
|
|
|
2089
2218
|
rootId,
|
|
2090
2219
|
volume: volumes,
|
|
2091
2220
|
showInTimeline: true,
|
|
2092
|
-
nonce:
|
|
2221
|
+
nonce: nonce4,
|
|
2093
2222
|
startMediaFrom: 0 - startsAt,
|
|
2094
2223
|
doesVolumeChange,
|
|
2095
2224
|
loopDisplay: undefined,
|
|
@@ -2112,7 +2241,7 @@ var useMediaInTimeline = ({
|
|
|
2112
2241
|
videoConfig,
|
|
2113
2242
|
volumes,
|
|
2114
2243
|
doesVolumeChange,
|
|
2115
|
-
|
|
2244
|
+
nonce4,
|
|
2116
2245
|
mediaRef,
|
|
2117
2246
|
mediaType,
|
|
2118
2247
|
startsAt,
|
|
@@ -3490,7 +3619,7 @@ var Composition = ({
|
|
|
3490
3619
|
const { registerComposition, unregisterComposition } = useContext24(CompositionManager);
|
|
3491
3620
|
const video = useVideo();
|
|
3492
3621
|
const lazy = useLazyComponent(compProps);
|
|
3493
|
-
const
|
|
3622
|
+
const nonce5 = useNonce();
|
|
3494
3623
|
const isPlayer = useIsPlayer();
|
|
3495
3624
|
const environment = getRemotionEnvironment();
|
|
3496
3625
|
const canUseComposition = useContext24(CanUseRemotionHooks);
|
|
@@ -3516,7 +3645,7 @@ var Composition = ({
|
|
|
3516
3645
|
folderName,
|
|
3517
3646
|
component: lazy,
|
|
3518
3647
|
defaultProps,
|
|
3519
|
-
nonce:
|
|
3648
|
+
nonce: nonce5,
|
|
3520
3649
|
parentFolderName: parentName,
|
|
3521
3650
|
schema: schema ?? null,
|
|
3522
3651
|
calculateMetadata: compProps.calculateMetadata ?? null
|
|
@@ -3535,7 +3664,7 @@ var Composition = ({
|
|
|
3535
3664
|
registerComposition,
|
|
3536
3665
|
unregisterComposition,
|
|
3537
3666
|
width,
|
|
3538
|
-
|
|
3667
|
+
nonce5,
|
|
3539
3668
|
parentName,
|
|
3540
3669
|
schema,
|
|
3541
3670
|
compProps.calculateMetadata
|
|
@@ -3634,6 +3763,20 @@ var CompositionManagerProvider = ({ children, numberOfAudioTags }) => {
|
|
|
3634
3763
|
};
|
|
3635
3764
|
}, []);
|
|
3636
3765
|
const composition = compositions.find((c) => canvasContent?.type === "composition" ? c.id === canvasContent.compositionId : null);
|
|
3766
|
+
const updateCompositionDefaultProps = useCallback8((id, newDefaultProps) => {
|
|
3767
|
+
setCompositions((comps) => {
|
|
3768
|
+
const updated = comps.map((c) => {
|
|
3769
|
+
if (c.id === id) {
|
|
3770
|
+
return {
|
|
3771
|
+
...c,
|
|
3772
|
+
defaultProps: newDefaultProps
|
|
3773
|
+
};
|
|
3774
|
+
}
|
|
3775
|
+
return c;
|
|
3776
|
+
});
|
|
3777
|
+
return updated;
|
|
3778
|
+
});
|
|
3779
|
+
}, []);
|
|
3637
3780
|
const contextValue = useMemo24(() => {
|
|
3638
3781
|
return {
|
|
3639
3782
|
compositions,
|
|
@@ -3645,7 +3788,8 @@ var CompositionManagerProvider = ({ children, numberOfAudioTags }) => {
|
|
|
3645
3788
|
currentCompositionMetadata,
|
|
3646
3789
|
setCurrentCompositionMetadata,
|
|
3647
3790
|
canvasContent,
|
|
3648
|
-
setCanvasContent
|
|
3791
|
+
setCanvasContent,
|
|
3792
|
+
updateCompositionDefaultProps
|
|
3649
3793
|
};
|
|
3650
3794
|
}, [
|
|
3651
3795
|
compositions,
|
|
@@ -3656,7 +3800,7 @@ var CompositionManagerProvider = ({ children, numberOfAudioTags }) => {
|
|
|
3656
3800
|
unregisterFolder,
|
|
3657
3801
|
currentCompositionMetadata,
|
|
3658
3802
|
canvasContent,
|
|
3659
|
-
|
|
3803
|
+
updateCompositionDefaultProps
|
|
3660
3804
|
]);
|
|
3661
3805
|
return jsx22(CompositionManager.Provider, {
|
|
3662
3806
|
value: contextValue,
|
|
@@ -4509,7 +4653,8 @@ var Internals = {
|
|
|
4509
4653
|
CurrentScaleContext,
|
|
4510
4654
|
PreviewSizeContext,
|
|
4511
4655
|
calculateScale,
|
|
4512
|
-
editorPropsProviderRef
|
|
4656
|
+
editorPropsProviderRef,
|
|
4657
|
+
PROPS_UPDATED_EXTERNALLY
|
|
4513
4658
|
};
|
|
4514
4659
|
// src/interpolate-colors.ts
|
|
4515
4660
|
var call = function(...args) {
|
package/dist/esm/version.mjs
CHANGED