remotion 4.0.154 → 4.0.156

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.
@@ -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
- setCanvasContent,
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<{
@@ -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 selectedComposition = compositions.find((c) => canvasContent &&
24
- canvasContent.type === 'composition' &&
25
- canvasContent.compositionId === c.id);
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 doResolution = (0, react_1.useCallback)((composition, editorProps) => {
42
- var _a;
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 (currentCompositionMetadata) {
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
- composition,
53
- editorProps,
54
- inputProps,
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[composition.id];
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
- [composition.id]: {
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
- [composition.id]: {
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
- [composition.id]: {
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
- [composition.id]: {
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
- [composition.id]: {
119
+ [compositionId]: {
107
120
  type: 'success',
108
121
  result: promOrNot,
109
122
  },
110
123
  }));
111
124
  }
112
125
  return controller;
113
- }, [currentCompositionMetadata]);
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
- doResolution(composition, editorProps);
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
- }, [allEditorProps, compositions, currentComposition, doResolution]);
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
- if (selectedComposition && (0, exports.needsResolution)(selectedComposition)) {
137
- const controller = doResolution(selectedComposition, selectedEditorProps);
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
- }, [doResolution, selectedComposition, selectedEditorProps]);
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 controller = doResolution(renderModalComposition, renderModalProps);
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
- }, [doResolution, isTheSame, renderModalComposition, renderModalProps]);
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;
@@ -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;
@@ -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: ({ composition, editorProps: editorPropsOrUndefined, signal, inputProps, }: {
92
- composition: import("./CompositionManager.js").TCompMetadataWithCalcFunction<import("zod").AnyZodObject, Record<string, unknown>>;
93
- editorProps: object;
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
- inputProps: Record<string, unknown>;
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, };
@@ -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 { TCompMetadataWithCalcFunction } from './CompositionManager.js';
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: ({ composition, editorProps: editorPropsOrUndefined, signal, inputProps, }: {
5
- composition: TCompMetadataWithCalcFunction<AnyZodObject, Record<string, unknown>>;
6
- editorProps: object;
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
- inputProps: Record<string, unknown>;
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 = ({ composition, calculated, }) => {
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 "${composition.id}"`;
11
- const defaultErrorLocation = `of the "<Composition />" component with the id "${composition.id}"`;
12
- const width = (_b = (_a = calculated === null || calculated === void 0 ? void 0 : calculated.width) !== null && _a !== void 0 ? _a : composition.width) !== null && _b !== void 0 ? _b : undefined;
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 : composition.height) !== null && _d !== void 0 ? _d : undefined;
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 : composition.fps) !== null && _f !== void 0 ? _f : null;
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 : composition.durationInFrames) !== null && _h !== void 0 ? _h : null;
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 "${composition.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 = ({ composition, editorProps: editorPropsOrUndefined, signal, inputProps, }) => {
28
- var _a, _b, _c, _d, _e, _f;
29
- const originalProps = {
30
- ...((_a = composition.defaultProps) !== null && _a !== void 0 ? _a : {}),
31
- ...(editorPropsOrUndefined !== null && editorPropsOrUndefined !== void 0 ? editorPropsOrUndefined : {}),
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: composition.id,
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, _b;
41
+ var _a;
47
42
  const { height, width, durationInFrames, fps, defaultCodec } = validateCalculated({
48
43
  calculated: c,
49
- composition,
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: composition.id,
57
- defaultProps: (_a = composition.defaultProps) !== null && _a !== void 0 ? _a : {},
58
- props: (_b = c.props) !== null && _b !== void 0 ? _b : originalProps,
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
- composition,
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: composition.id,
71
- defaultProps: (_c = composition.defaultProps) !== null && _c !== void 0 ? _c : {},
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: composition.id,
79
- defaultProps: (_d = composition.defaultProps) !== null && _d !== void 0 ? _d : {},
80
- props: (_e = calculatedProm.props) !== null && _e !== void 0 ? _e : originalProps,
81
- defaultCodec: (_f = calculatedProm.defaultCodec) !== null && _f !== void 0 ? _f : null,
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;
@@ -3,4 +3,4 @@
3
3
  * @see [Documentation](https://remotion.dev/docs/version)
4
4
  * @returns {string} The current version of the remotion package
5
5
  */
6
- export declare const VERSION = "4.0.154";
6
+ export declare const VERSION = "4.0.156";
@@ -7,4 +7,4 @@ exports.VERSION = void 0;
7
7
  * @see [Documentation](https://remotion.dev/docs/version)
8
8
  * @returns {string} The current version of the remotion package
9
9
  */
10
- exports.VERSION = '4.0.154';
10
+ exports.VERSION = '4.0.156';
@@ -132,7 +132,7 @@ function truthy(value) {
132
132
  }
133
133
 
134
134
  // src/version.ts
135
- var VERSION = "4.0.154";
135
+ var VERSION = "4.0.156";
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
- composition,
643
- calculated
651
+ calculated,
652
+ compositionId,
653
+ compositionFps,
654
+ compositionHeight,
655
+ compositionWidth,
656
+ compositionDurationInFrames
644
657
  }) => {
645
- const calculateMetadataErrorLocation = `calculated by calculateMetadata() for the composition "${composition.id}"`;
646
- const defaultErrorLocation = `of the "<Composition />" component with the id "${composition.id}"`;
647
- const width = calculated?.width ?? composition.width ?? undefined;
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 ?? composition.height ?? undefined;
662
+ const height = calculated?.height ?? compositionHeight ?? undefined;
650
663
  validateDimension(height, "height", calculated?.height ? calculateMetadataErrorLocation : defaultErrorLocation);
651
- const fps = calculated?.fps ?? composition.fps ?? null;
664
+ const fps = calculated?.fps ?? compositionFps ?? null;
652
665
  validateFps(fps, calculated?.fps ? calculateMetadataErrorLocation : defaultErrorLocation, false);
653
- const durationInFrames = calculated?.durationInFrames ?? composition.durationInFrames ?? null;
666
+ const durationInFrames = calculated?.durationInFrames ?? compositionDurationInFrames ?? null;
654
667
  validateDurationInFrames(durationInFrames, {
655
668
  allowFloats: false,
656
- component: `of the "<Composition />" component with the id "${composition.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
- composition,
664
- editorProps: editorPropsOrUndefined,
676
+ calculateMetadata,
665
677
  signal,
666
- inputProps
678
+ defaultProps,
679
+ originalProps,
680
+ compositionId,
681
+ compositionDurationInFrames,
682
+ compositionFps,
683
+ compositionHeight,
684
+ compositionWidth
667
685
  }) => {
668
- const originalProps = {
669
- ...composition.defaultProps ?? {},
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: composition.id
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
- composition
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: composition.id,
691
- defaultProps: composition.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
- composition
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: composition.id,
705
- defaultProps: composition.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: composition.id,
713
- defaultProps: composition.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 selectedComposition = compositions.find((c) => canvasContent && canvasContent.type === "composition" && canvasContent.compositionId === c.id);
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 doResolution = useCallback3((composition, editorProps) => {
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 (currentCompositionMetadata) {
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
- composition,
750
- editorProps,
751
- inputProps,
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[composition.id];
798
+ const prev = r[compositionId];
757
799
  if (prev?.type === "success" || prev?.type === "success-and-refreshing") {
758
800
  return {
759
801
  ...r,
760
- [composition.id]: {
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
- [composition.id]: {
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
- [composition.id]: {
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
- [composition.id]: {
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
- [composition.id]: {
841
+ [compositionId]: {
800
842
  type: "success",
801
843
  result: promOrNot
802
844
  }
803
845
  }));
804
846
  }
805
847
  return controller;
806
- }, [currentCompositionMetadata]);
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
- doResolution(composition, editorProps);
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
- }, [allEditorProps, compositions, currentComposition, doResolution]);
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 (selectedComposition && needsResolution(selectedComposition)) {
829
- const controller = doResolution(selectedComposition, selectedEditorProps);
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
- }, [doResolution, selectedComposition, selectedEditorProps]);
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 controller = doResolution(renderModalComposition, renderModalProps);
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
- }, [doResolution, isTheSame, renderModalComposition, renderModalProps]);
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 nonce2 = useNonce();
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: nonce2,
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
- nonce2,
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 nonce3 = useNonce();
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: nonce3,
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
- nonce3,
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 nonce4 = useNonce();
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: nonce4,
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
- nonce4,
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
- setCanvasContent
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) {
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var VERSION = "4.0.154";
2
+ var VERSION = "4.0.156";
3
3
  export {
4
4
  VERSION
5
5
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remotion",
3
- "version": "4.0.154",
3
+ "version": "4.0.156",
4
4
  "description": "Render videos in React",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/cjs/index.d.ts",