remotion 4.0.43 → 4.0.44

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.
@@ -38,8 +38,8 @@ const CompositionManagerProvider = ({ children, numberOfAudioTags }) => {
38
38
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
39
  const [compositions, setCompositions] = (0, react_1.useState)([]);
40
40
  const currentcompositionsRef = (0, react_1.useRef)(compositions);
41
- const [currentComposition, setCurrentComposition] = (0, react_1.useState)(null);
42
41
  const [folders, setFolders] = (0, react_1.useState)([]);
42
+ const [canvasContent, setCanvasContent] = (0, react_1.useState)(null);
43
43
  const [currentCompositionMetadata, setCurrentCompositionMetadata] = (0, react_1.useState)(null);
44
44
  const updateCompositions = (0, react_1.useCallback)((
45
45
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -88,29 +88,32 @@ const CompositionManagerProvider = ({ children, numberOfAudioTags }) => {
88
88
  getCompositions: () => currentcompositionsRef.current,
89
89
  };
90
90
  }, []);
91
- const composition = compositions.find((c) => c.id === currentComposition);
91
+ const composition = compositions.find((c) => (canvasContent === null || canvasContent === void 0 ? void 0 : canvasContent.type) === 'composition'
92
+ ? c.id === canvasContent.compositionId
93
+ : null);
92
94
  const contextValue = (0, react_1.useMemo)(() => {
93
95
  return {
94
96
  compositions,
95
97
  registerComposition,
96
98
  unregisterComposition,
97
- currentComposition,
98
- setCurrentComposition,
99
99
  folders,
100
100
  registerFolder,
101
101
  unregisterFolder,
102
102
  currentCompositionMetadata,
103
103
  setCurrentCompositionMetadata,
104
+ canvasContent,
105
+ setCanvasContent,
104
106
  };
105
107
  }, [
106
108
  compositions,
107
109
  registerComposition,
108
110
  unregisterComposition,
109
- currentComposition,
110
111
  folders,
111
112
  registerFolder,
112
113
  unregisterFolder,
113
114
  currentCompositionMetadata,
115
+ canvasContent,
116
+ setCanvasContent,
114
117
  ]);
115
118
  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 }) }) }) }) }));
116
119
  };
@@ -4,16 +4,23 @@ import type { AnyComposition, TComposition } from './CompositionManager.js';
4
4
  import type { TFolder } from './Folder.js';
5
5
  import type { VideoConfig } from './video-config.js';
6
6
  export type BaseMetadata = Pick<VideoConfig, 'durationInFrames' | 'fps' | 'props' | 'height' | 'width'>;
7
+ export type CanvasContent = {
8
+ type: 'composition';
9
+ compositionId: string;
10
+ } | {
11
+ type: 'asset';
12
+ asset: string;
13
+ };
7
14
  export type CompositionManagerContext = {
8
15
  compositions: AnyComposition[];
9
16
  registerComposition: <Schema extends AnyZodObject, Props extends Record<string, unknown>>(comp: TComposition<Schema, Props>) => void;
10
17
  unregisterComposition: (name: string) => void;
11
18
  registerFolder: (name: string, parent: string | null) => void;
12
19
  unregisterFolder: (name: string, parent: string | null) => void;
13
- currentComposition: string | null;
14
- setCurrentComposition: (curr: string) => void;
15
20
  setCurrentCompositionMetadata: (metadata: BaseMetadata) => void;
16
21
  currentCompositionMetadata: BaseMetadata | null;
17
22
  folders: TFolder[];
23
+ canvasContent: CanvasContent | null;
24
+ setCanvasContent: (canvasContent: CanvasContent | null) => void;
18
25
  };
19
26
  export declare const CompositionManager: import("react").Context<CompositionManagerContext>;
@@ -8,9 +8,9 @@ exports.CompositionManager = (0, react_1.createContext)({
8
8
  unregisterComposition: () => undefined,
9
9
  registerFolder: () => undefined,
10
10
  unregisterFolder: () => undefined,
11
- currentComposition: null,
12
- setCurrentComposition: () => undefined,
13
11
  setCurrentCompositionMetadata: () => undefined,
14
12
  folders: [],
15
13
  currentCompositionMetadata: null,
14
+ canvasContent: null,
15
+ setCanvasContent: () => undefined,
16
16
  });
@@ -4,6 +4,7 @@ exports.RenderAssetManagerProvider = exports.RenderAssetManager = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  exports.RenderAssetManager = (0, react_1.createContext)({
7
+ // Must be undefined, otherwise error in Player
7
8
  registerRenderAsset: () => undefined,
8
9
  unregisterRenderAsset: () => undefined,
9
10
  renderAssets: [],
@@ -12,8 +12,10 @@ exports.ResolveCompositionContext = (0, react_1.createContext)(null);
12
12
  exports.resolveCompositionsRef = (0, react_1.createRef)();
13
13
  const ResolveCompositionConfig = ({ children }) => {
14
14
  const [currentRenderModalComposition, setCurrentRenderModalComposition] = (0, react_1.useState)(null);
15
- const { compositions, currentComposition, currentCompositionMetadata } = (0, react_1.useContext)(CompositionManagerContext_js_1.CompositionManager);
16
- const selectedComposition = compositions.find((c) => c.id === currentComposition);
15
+ const { compositions, canvasContent, currentCompositionMetadata } = (0, react_1.useContext)(CompositionManagerContext_js_1.CompositionManager);
16
+ const selectedComposition = compositions.find((c) => canvasContent &&
17
+ canvasContent.type === 'composition' &&
18
+ canvasContent.compositionId === c.id);
17
19
  const renderModalComposition = compositions.find((c) => c.id === currentRenderModalComposition);
18
20
  const { props: allEditorProps } = (0, react_1.useContext)(EditorProps_js_1.EditorPropsContext);
19
21
  const [resolvedConfigs, setResolvedConfigs] = (0, react_1.useState)({});
@@ -89,6 +91,7 @@ const ResolveCompositionConfig = ({ children }) => {
89
91
  }
90
92
  return controller;
91
93
  }, [currentCompositionMetadata]);
94
+ const currentComposition = (canvasContent === null || canvasContent === void 0 ? void 0 : canvasContent.type) === 'composition' ? canvasContent.compositionId : null;
92
95
  (0, react_1.useImperativeHandle)(exports.resolveCompositionsRef, () => {
93
96
  return {
94
97
  setCurrentRenderModalComposition: (id) => {
@@ -153,7 +156,8 @@ exports.needsResolution = needsResolution;
153
156
  const useResolvedVideoConfig = (preferredCompositionId) => {
154
157
  const context = (0, react_1.useContext)(exports.ResolveCompositionContext);
155
158
  const { props: allEditorProps } = (0, react_1.useContext)(EditorProps_js_1.EditorPropsContext);
156
- const { compositions, currentComposition, currentCompositionMetadata } = (0, react_1.useContext)(CompositionManagerContext_js_1.CompositionManager);
159
+ const { compositions, canvasContent, currentCompositionMetadata } = (0, react_1.useContext)(CompositionManagerContext_js_1.CompositionManager);
160
+ const currentComposition = (canvasContent === null || canvasContent === void 0 ? void 0 : canvasContent.type) === 'composition' ? canvasContent.compositionId : null;
157
161
  const compositionId = preferredCompositionId !== null && preferredCompositionId !== void 0 ? preferredCompositionId : currentComposition;
158
162
  const composition = compositions.find((c) => c.id === compositionId);
159
163
  const selectedEditorProps = (0, react_1.useMemo)(() => {
@@ -67,6 +67,7 @@ export * from './audio/index.js';
67
67
  export { cancelRender } from './cancel-render.js';
68
68
  export { CalculateMetadataFunction, Composition, CompositionProps, CompProps, StillProps, } from './Composition.js';
69
69
  export { AnyCompMetadata, AnyComposition, SmallTCompMetadata, TCompMetadata, TRenderAsset, } from './CompositionManager.js';
70
+ export type { CanvasContent } from './CompositionManagerContext.js';
70
71
  export { getInputProps } from './config/input-props.js';
71
72
  export { continueRender, delayRender } from './delay-render.js';
72
73
  export * from './easing.js';
@@ -5,13 +5,15 @@ const react_1 = require("react");
5
5
  const CompositionManagerContext_js_1 = require("./CompositionManagerContext.js");
6
6
  const ResolveCompositionConfig_js_1 = require("./ResolveCompositionConfig.js");
7
7
  const useVideo = () => {
8
- const context = (0, react_1.useContext)(CompositionManagerContext_js_1.CompositionManager);
9
- const selected = context.compositions.find((c) => {
10
- return c.id === context.currentComposition;
8
+ var _a;
9
+ const { canvasContent, compositions, currentCompositionMetadata } = (0, react_1.useContext)(CompositionManagerContext_js_1.CompositionManager);
10
+ const selected = compositions.find((c) => {
11
+ return ((canvasContent === null || canvasContent === void 0 ? void 0 : canvasContent.type) === 'composition' &&
12
+ c.id === canvasContent.compositionId);
11
13
  });
12
- const resolved = (0, ResolveCompositionConfig_js_1.useResolvedVideoConfig)(context.currentComposition);
14
+ const resolved = (0, ResolveCompositionConfig_js_1.useResolvedVideoConfig)((_a = selected === null || selected === void 0 ? void 0 : selected.id) !== null && _a !== void 0 ? _a : null);
13
15
  return (0, react_1.useMemo)(() => {
14
- var _a, _b;
16
+ var _a;
15
17
  if (!resolved) {
16
18
  return null;
17
19
  }
@@ -30,9 +32,9 @@ const useVideo = () => {
30
32
  id: selected.id,
31
33
  // We override the selected metadata with the metadata that was passed to renderMedia(),
32
34
  // and don't allow it to be changed during render anymore
33
- ...((_b = context.currentCompositionMetadata) !== null && _b !== void 0 ? _b : {}),
35
+ ...(currentCompositionMetadata !== null && currentCompositionMetadata !== void 0 ? currentCompositionMetadata : {}),
34
36
  component: selected.component,
35
37
  };
36
- }, [context.currentCompositionMetadata, resolved, selected]);
38
+ }, [currentCompositionMetadata, resolved, selected]);
37
39
  };
38
40
  exports.useVideo = useVideo;
@@ -1 +1 @@
1
- export declare const VERSION = "4.0.43";
1
+ export declare const VERSION = "4.0.44";
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // Automatically generated on publish
5
- exports.VERSION = '4.0.43';
5
+ exports.VERSION = '4.0.44';
@@ -37,7 +37,7 @@ const VideoForwardingFunction = (props, ref) => {
37
37
  mediaDuration,
38
38
  playbackRate: (_a = props.playbackRate) !== null && _a !== void 0 ? _a : 1,
39
39
  startFrom,
40
- }), children: (0, jsx_runtime_1.jsx)(exports.Video, { ...propsOtherThanLoop, ref: ref }) }));
40
+ }), layout: "none", children: (0, jsx_runtime_1.jsx)(exports.Video, { ...propsOtherThanLoop, ref: ref }) }));
41
41
  }
42
42
  if (typeof startFrom !== 'undefined' || typeof endAt !== 'undefined') {
43
43
  (0, validate_start_from_props_js_1.validateStartFromProps)(startFrom, endAt);
@@ -59,7 +59,7 @@ function truthy(value) {
59
59
  }
60
60
 
61
61
  // Automatically generated on publish
62
- const VERSION = '4.0.43';
62
+ const VERSION = '4.0.44';
63
63
 
64
64
  const checkMultipleRemotionVersions = () => {
65
65
  if (typeof globalThis === 'undefined') {
@@ -318,11 +318,11 @@ const CompositionManager = createContext({
318
318
  unregisterComposition: () => undefined,
319
319
  registerFolder: () => undefined,
320
320
  unregisterFolder: () => undefined,
321
- currentComposition: null,
322
- setCurrentComposition: () => undefined,
323
321
  setCurrentCompositionMetadata: () => undefined,
324
322
  folders: [],
325
323
  currentCompositionMetadata: null,
324
+ canvasContent: null,
325
+ setCanvasContent: () => undefined,
326
326
  });
327
327
 
328
328
  const problematicCharacters = {
@@ -648,8 +648,10 @@ const ResolveCompositionContext = createContext(null);
648
648
  const resolveCompositionsRef = createRef();
649
649
  const ResolveCompositionConfig = ({ children }) => {
650
650
  const [currentRenderModalComposition, setCurrentRenderModalComposition] = useState(null);
651
- const { compositions, currentComposition, currentCompositionMetadata } = useContext(CompositionManager);
652
- const selectedComposition = compositions.find((c) => c.id === currentComposition);
651
+ const { compositions, canvasContent, currentCompositionMetadata } = useContext(CompositionManager);
652
+ const selectedComposition = compositions.find((c) => canvasContent &&
653
+ canvasContent.type === 'composition' &&
654
+ canvasContent.compositionId === c.id);
653
655
  const renderModalComposition = compositions.find((c) => c.id === currentRenderModalComposition);
654
656
  const { props: allEditorProps } = useContext(EditorPropsContext);
655
657
  const [resolvedConfigs, setResolvedConfigs] = useState({});
@@ -725,6 +727,7 @@ const ResolveCompositionConfig = ({ children }) => {
725
727
  }
726
728
  return controller;
727
729
  }, [currentCompositionMetadata]);
730
+ const currentComposition = (canvasContent === null || canvasContent === void 0 ? void 0 : canvasContent.type) === 'composition' ? canvasContent.compositionId : null;
728
731
  useImperativeHandle(resolveCompositionsRef, () => {
729
732
  return {
730
733
  setCurrentRenderModalComposition: (id) => {
@@ -787,7 +790,8 @@ const needsResolution = (composition) => {
787
790
  const useResolvedVideoConfig = (preferredCompositionId) => {
788
791
  const context = useContext(ResolveCompositionContext);
789
792
  const { props: allEditorProps } = useContext(EditorPropsContext);
790
- const { compositions, currentComposition, currentCompositionMetadata } = useContext(CompositionManager);
793
+ const { compositions, canvasContent, currentCompositionMetadata } = useContext(CompositionManager);
794
+ const currentComposition = (canvasContent === null || canvasContent === void 0 ? void 0 : canvasContent.type) === 'composition' ? canvasContent.compositionId : null;
791
795
  const compositionId = preferredCompositionId !== null && preferredCompositionId !== void 0 ? preferredCompositionId : currentComposition;
792
796
  const composition = compositions.find((c) => c.id === compositionId);
793
797
  const selectedEditorProps = useMemo(() => {
@@ -839,13 +843,15 @@ const useResolvedVideoConfig = (preferredCompositionId) => {
839
843
  };
840
844
 
841
845
  const useVideo = () => {
842
- const context = useContext(CompositionManager);
843
- const selected = context.compositions.find((c) => {
844
- return c.id === context.currentComposition;
846
+ var _a;
847
+ const { canvasContent, compositions, currentCompositionMetadata } = useContext(CompositionManager);
848
+ const selected = compositions.find((c) => {
849
+ return ((canvasContent === null || canvasContent === void 0 ? void 0 : canvasContent.type) === 'composition' &&
850
+ c.id === canvasContent.compositionId);
845
851
  });
846
- const resolved = useResolvedVideoConfig(context.currentComposition);
852
+ const resolved = useResolvedVideoConfig((_a = selected === null || selected === void 0 ? void 0 : selected.id) !== null && _a !== void 0 ? _a : null);
847
853
  return useMemo(() => {
848
- var _a, _b;
854
+ var _a;
849
855
  if (!resolved) {
850
856
  return null;
851
857
  }
@@ -864,10 +870,10 @@ const useVideo = () => {
864
870
  id: selected.id,
865
871
  // We override the selected metadata with the metadata that was passed to renderMedia(),
866
872
  // and don't allow it to be changed during render anymore
867
- ...((_b = context.currentCompositionMetadata) !== null && _b !== void 0 ? _b : {}),
873
+ ...(currentCompositionMetadata !== null && currentCompositionMetadata !== void 0 ? currentCompositionMetadata : {}),
868
874
  component: selected.component,
869
875
  };
870
- }, [context.currentCompositionMetadata, resolved, selected]);
876
+ }, [currentCompositionMetadata, resolved, selected]);
871
877
  };
872
878
 
873
879
  const TimelineContext = createContext({
@@ -2397,6 +2403,7 @@ const continueRender = (handle) => {
2397
2403
  };
2398
2404
 
2399
2405
  const RenderAssetManager = createContext({
2406
+ // Must be undefined, otherwise error in Player
2400
2407
  registerRenderAsset: () => undefined,
2401
2408
  unregisterRenderAsset: () => undefined,
2402
2409
  renderAssets: [],
@@ -3199,8 +3206,8 @@ const CompositionManagerProvider = ({ children, numberOfAudioTags }) => {
3199
3206
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3200
3207
  const [compositions, setCompositions] = useState([]);
3201
3208
  const currentcompositionsRef = useRef(compositions);
3202
- const [currentComposition, setCurrentComposition] = useState(null);
3203
3209
  const [folders, setFolders] = useState([]);
3210
+ const [canvasContent, setCanvasContent] = useState(null);
3204
3211
  const [currentCompositionMetadata, setCurrentCompositionMetadata] = useState(null);
3205
3212
  const updateCompositions = useCallback((
3206
3213
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -3249,29 +3256,32 @@ const CompositionManagerProvider = ({ children, numberOfAudioTags }) => {
3249
3256
  getCompositions: () => currentcompositionsRef.current,
3250
3257
  };
3251
3258
  }, []);
3252
- const composition = compositions.find((c) => c.id === currentComposition);
3259
+ const composition = compositions.find((c) => (canvasContent === null || canvasContent === void 0 ? void 0 : canvasContent.type) === 'composition'
3260
+ ? c.id === canvasContent.compositionId
3261
+ : null);
3253
3262
  const contextValue = useMemo(() => {
3254
3263
  return {
3255
3264
  compositions,
3256
3265
  registerComposition,
3257
3266
  unregisterComposition,
3258
- currentComposition,
3259
- setCurrentComposition,
3260
3267
  folders,
3261
3268
  registerFolder,
3262
3269
  unregisterFolder,
3263
3270
  currentCompositionMetadata,
3264
3271
  setCurrentCompositionMetadata,
3272
+ canvasContent,
3273
+ setCanvasContent,
3265
3274
  };
3266
3275
  }, [
3267
3276
  compositions,
3268
3277
  registerComposition,
3269
3278
  unregisterComposition,
3270
- currentComposition,
3271
3279
  folders,
3272
3280
  registerFolder,
3273
3281
  unregisterFolder,
3274
3282
  currentCompositionMetadata,
3283
+ canvasContent,
3284
+ setCanvasContent,
3275
3285
  ]);
3276
3286
  return (jsx(CompositionManager.Provider, { value: contextValue, children: jsx(SequenceManagerProvider, { children: jsx(RenderAssetManagerProvider, { children: jsx(ResolveCompositionConfig, { children: jsx(SharedAudioContextProvider, { numberOfAudioTags: numberOfAudioTags, component: (_a = composition === null || composition === void 0 ? void 0 : composition.component) !== null && _a !== void 0 ? _a : null, children: children }) }) }) }) }));
3277
3287
  };
@@ -4751,7 +4761,7 @@ const VideoForwardingFunction = (props, ref) => {
4751
4761
  mediaDuration,
4752
4762
  playbackRate: (_a = props.playbackRate) !== null && _a !== void 0 ? _a : 1,
4753
4763
  startFrom,
4754
- }), children: jsx(Video, { ...propsOtherThanLoop, ref: ref }) }));
4764
+ }), layout: "none", children: jsx(Video, { ...propsOtherThanLoop, ref: ref }) }));
4755
4765
  }
4756
4766
  if (typeof startFrom !== 'undefined' || typeof endAt !== 'undefined') {
4757
4767
  validateStartFromProps(startFrom, endAt);
@@ -1,4 +1,4 @@
1
1
  // Automatically generated on publish
2
- const VERSION = '4.0.43';
2
+ const VERSION = '4.0.44';
3
3
 
4
4
  export { VERSION };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remotion",
3
- "version": "4.0.43",
3
+ "version": "4.0.44",
4
4
  "description": "Render videos in React",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/cjs/index.d.ts",
@@ -1,3 +0,0 @@
1
- export type RemotionEnvironment = 'preview' | 'rendering' | 'player-development' | 'player-production';
2
- export declare const getRemotionEnvironment: () => RemotionEnvironment;
3
- export declare const useRemotionEnvironment: () => RemotionEnvironment;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useRemotionEnvironment = exports.getRemotionEnvironment = void 0;
4
- const is_player_js_1 = require("./is-player.js");
5
- const getRemotionEnvironment = () => {
6
- if (process.env.NODE_ENV === 'production') {
7
- if (typeof window !== 'undefined' && window.remotion_isPlayer) {
8
- return 'player-production';
9
- }
10
- return 'rendering';
11
- }
12
- // The Vitest framework sets NODE_ENV as test.
13
- // Right now we don't need to treat it in a special
14
- // way which is good - defaulting to `rendering`.
15
- if (process.env.NODE_ENV === 'test') {
16
- return 'rendering';
17
- }
18
- if (typeof window !== 'undefined' && window.remotion_isPlayer) {
19
- return 'player-development';
20
- }
21
- return 'preview';
22
- };
23
- exports.getRemotionEnvironment = getRemotionEnvironment;
24
- const useRemotionEnvironment = () => {
25
- const isPlayer = (0, is_player_js_1.useIsPlayer)();
26
- if (isPlayer) {
27
- if (process.env.NODE_ENV === 'production') {
28
- return 'player-production';
29
- }
30
- return 'player-development';
31
- }
32
- return (0, exports.getRemotionEnvironment)();
33
- };
34
- exports.useRemotionEnvironment = useRemotionEnvironment;