remotion 4.0.43 → 4.0.45

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
  };
@@ -1,19 +1,29 @@
1
- /// <reference types="react" />
1
+ import type React from 'react';
2
2
  import type { AnyZodObject } from 'zod';
3
3
  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
+ } | {
14
+ type: 'output';
15
+ path: string;
16
+ };
7
17
  export type CompositionManagerContext = {
8
18
  compositions: AnyComposition[];
9
19
  registerComposition: <Schema extends AnyZodObject, Props extends Record<string, unknown>>(comp: TComposition<Schema, Props>) => void;
10
20
  unregisterComposition: (name: string) => void;
11
21
  registerFolder: (name: string, parent: string | null) => void;
12
22
  unregisterFolder: (name: string, parent: string | null) => void;
13
- currentComposition: string | null;
14
- setCurrentComposition: (curr: string) => void;
15
23
  setCurrentCompositionMetadata: (metadata: BaseMetadata) => void;
16
24
  currentCompositionMetadata: BaseMetadata | null;
17
25
  folders: TFolder[];
26
+ canvasContent: CanvasContent | null;
27
+ setCanvasContent: React.Dispatch<React.SetStateAction<CanvasContent | null>>;
18
28
  };
19
- export declare const CompositionManager: import("react").Context<CompositionManagerContext>;
29
+ export declare const CompositionManager: 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)(() => {
@@ -100,7 +100,9 @@ const SequenceRefForwardingFunction = ({ from = 0, durationInFrames = Infinity,
100
100
  nonce,
101
101
  loopDisplay,
102
102
  ]);
103
- const endThreshold = cumulatedFrom + from + durationInFrames - 1;
103
+ // Ceil to support floats
104
+ // https://github.com/remotion-dev/remotion/issues/2958
105
+ const endThreshold = Math.ceil(cumulatedFrom + from + durationInFrames - 1);
104
106
  const content = absoluteFrame < cumulatedFrom + from
105
107
  ? null
106
108
  : absoluteFrame > endThreshold
@@ -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.45";
@@ -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.45';
@@ -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.45';
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({
@@ -1082,7 +1088,9 @@ const SequenceRefForwardingFunction = ({ from = 0, durationInFrames = Infinity,
1082
1088
  nonce,
1083
1089
  loopDisplay,
1084
1090
  ]);
1085
- const endThreshold = cumulatedFrom + from + durationInFrames - 1;
1091
+ // Ceil to support floats
1092
+ // https://github.com/remotion-dev/remotion/issues/2958
1093
+ const endThreshold = Math.ceil(cumulatedFrom + from + durationInFrames - 1);
1086
1094
  const content = absoluteFrame < cumulatedFrom + from
1087
1095
  ? null
1088
1096
  : absoluteFrame > endThreshold
@@ -2397,6 +2405,7 @@ const continueRender = (handle) => {
2397
2405
  };
2398
2406
 
2399
2407
  const RenderAssetManager = createContext({
2408
+ // Must be undefined, otherwise error in Player
2400
2409
  registerRenderAsset: () => undefined,
2401
2410
  unregisterRenderAsset: () => undefined,
2402
2411
  renderAssets: [],
@@ -3199,8 +3208,8 @@ const CompositionManagerProvider = ({ children, numberOfAudioTags }) => {
3199
3208
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3200
3209
  const [compositions, setCompositions] = useState([]);
3201
3210
  const currentcompositionsRef = useRef(compositions);
3202
- const [currentComposition, setCurrentComposition] = useState(null);
3203
3211
  const [folders, setFolders] = useState([]);
3212
+ const [canvasContent, setCanvasContent] = useState(null);
3204
3213
  const [currentCompositionMetadata, setCurrentCompositionMetadata] = useState(null);
3205
3214
  const updateCompositions = useCallback((
3206
3215
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -3249,29 +3258,32 @@ const CompositionManagerProvider = ({ children, numberOfAudioTags }) => {
3249
3258
  getCompositions: () => currentcompositionsRef.current,
3250
3259
  };
3251
3260
  }, []);
3252
- const composition = compositions.find((c) => c.id === currentComposition);
3261
+ const composition = compositions.find((c) => (canvasContent === null || canvasContent === void 0 ? void 0 : canvasContent.type) === 'composition'
3262
+ ? c.id === canvasContent.compositionId
3263
+ : null);
3253
3264
  const contextValue = useMemo(() => {
3254
3265
  return {
3255
3266
  compositions,
3256
3267
  registerComposition,
3257
3268
  unregisterComposition,
3258
- currentComposition,
3259
- setCurrentComposition,
3260
3269
  folders,
3261
3270
  registerFolder,
3262
3271
  unregisterFolder,
3263
3272
  currentCompositionMetadata,
3264
3273
  setCurrentCompositionMetadata,
3274
+ canvasContent,
3275
+ setCanvasContent,
3265
3276
  };
3266
3277
  }, [
3267
3278
  compositions,
3268
3279
  registerComposition,
3269
3280
  unregisterComposition,
3270
- currentComposition,
3271
3281
  folders,
3272
3282
  registerFolder,
3273
3283
  unregisterFolder,
3274
3284
  currentCompositionMetadata,
3285
+ canvasContent,
3286
+ setCanvasContent,
3275
3287
  ]);
3276
3288
  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
3289
  };
@@ -4751,7 +4763,7 @@ const VideoForwardingFunction = (props, ref) => {
4751
4763
  mediaDuration,
4752
4764
  playbackRate: (_a = props.playbackRate) !== null && _a !== void 0 ? _a : 1,
4753
4765
  startFrom,
4754
- }), children: jsx(Video, { ...propsOtherThanLoop, ref: ref }) }));
4766
+ }), layout: "none", children: jsx(Video, { ...propsOtherThanLoop, ref: ref }) }));
4755
4767
  }
4756
4768
  if (typeof startFrom !== 'undefined' || typeof endAt !== 'undefined') {
4757
4769
  validateStartFromProps(startFrom, endAt);
@@ -1,4 +1,4 @@
1
1
  // Automatically generated on publish
2
- const VERSION = '4.0.43';
2
+ const VERSION = '4.0.45';
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.45",
4
4
  "description": "Render videos in React",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/cjs/index.d.ts",