remotion 3.3.36 → 3.3.38

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.
@@ -34,9 +34,11 @@ const Composition = ({ width, height, fps, durationInFrames, id, defaultProps, .
34
34
  const video = (0, use_video_1.useVideo)();
35
35
  const lazy = (0, use_lazy_component_1.useLazyComponent)(compProps);
36
36
  const nonce = (0, nonce_1.useNonce)();
37
+ const environment = (0, get_environment_1.useRemotionEnvironment)();
37
38
  const canUseComposition = (0, react_1.useContext)(internals_1.Internals.CanUseRemotionHooks);
38
39
  if (canUseComposition) {
39
- if (typeof window !== 'undefined' && window.remotion_isPlayer) {
40
+ if (environment === 'player-development' ||
41
+ environment === 'player-production') {
40
42
  throw new Error('<Composition> was mounted inside the `component` that was passed to the <Player>. See https://remotion.dev/docs/wrong-composition-mount for help.');
41
43
  }
42
44
  throw new Error('<Composition> mounted inside another composition. See https://remotion.dev/docs/wrong-composition-mount for help.');
@@ -81,16 +83,12 @@ const Composition = ({ width, height, fps, durationInFrames, id, defaultProps, .
81
83
  nonce,
82
84
  parentName,
83
85
  ]);
84
- if ((0, get_environment_1.getRemotionEnvironment)() === 'preview' &&
85
- video &&
86
- video.component === lazy) {
86
+ if (environment === 'preview' && video && video.component === lazy) {
87
87
  const Comp = lazy;
88
88
  const inputProps = (0, input_props_1.getInputProps)();
89
89
  return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(exports.ClipComposition, { children: (0, jsx_runtime_1.jsx)(CanUseRemotionHooks_1.CanUseRemotionHooksProvider, { children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: (0, jsx_runtime_1.jsx)(loading_indicator_1.Loading, {}), children: (0, jsx_runtime_1.jsx)(Comp, { ...defaultProps, ...inputProps }) }) }) }), (0, portal_node_1.portalNode)());
90
90
  }
91
- if ((0, get_environment_1.getRemotionEnvironment)() === 'rendering' &&
92
- video &&
93
- video.component === lazy) {
91
+ if (environment === 'rendering' && video && video.component === lazy) {
94
92
  const Comp = lazy;
95
93
  const inputProps = (0, input_props_1.getInputProps)();
96
94
  return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(CanUseRemotionHooks_1.CanUseRemotionHooksProvider, { children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: (0, jsx_runtime_1.jsx)(Fallback, {}), children: (0, jsx_runtime_1.jsx)(Comp, { ...defaultProps, ...inputProps }) }) }), (0, portal_node_1.portalNode)());
package/dist/Img.js CHANGED
@@ -8,6 +8,7 @@ const get_environment_1 = require("./get-environment");
8
8
  const prefetch_1 = require("./prefetch");
9
9
  const ImgRefForwarding = ({ onError, src, ...props }, ref) => {
10
10
  const imageRef = (0, react_1.useRef)(null);
11
+ const environment = (0, get_environment_1.useRemotionEnvironment)();
11
12
  (0, react_1.useImperativeHandle)(ref, () => {
12
13
  return imageRef.current;
13
14
  }, []);
@@ -22,7 +23,7 @@ const ImgRefForwarding = ({ onError, src, ...props }, ref) => {
22
23
  }
23
24
  }, [onError]);
24
25
  // If image source switches, make new handle
25
- if ((0, get_environment_1.getRemotionEnvironment)() === 'rendering') {
26
+ if (environment === 'rendering') {
26
27
  // eslint-disable-next-line react-hooks/rules-of-hooks
27
28
  (0, react_1.useLayoutEffect)(() => {
28
29
  if (process.env.NODE_ENV === 'test') {
package/dist/Sequence.js CHANGED
@@ -20,6 +20,7 @@ const SequenceRefForwardingFunction = ({ from = 0, durationInFrames = Infinity,
20
20
  ? parentSequence.cumulatedFrom + parentSequence.relativeFrom
21
21
  : 0;
22
22
  const nonce = (0, nonce_1.useNonce)();
23
+ const environment = (0, get_environment_1.useRemotionEnvironment)();
23
24
  if (layout !== 'absolute-fill' && layout !== 'none') {
24
25
  throw new TypeError(`The layout prop of <Sequence /> expects either "absolute-fill" or "none", but you passed: ${layout}`);
25
26
  }
@@ -71,7 +72,7 @@ const SequenceRefForwardingFunction = ({ from = 0, durationInFrames = Infinity,
71
72
  }, [children, name]);
72
73
  (0, react_1.useEffect)(() => {
73
74
  var _a;
74
- if ((0, get_environment_1.getRemotionEnvironment)() !== 'preview') {
75
+ if (environment !== 'preview') {
75
76
  return;
76
77
  }
77
78
  registerSequence({
@@ -103,6 +104,7 @@ const SequenceRefForwardingFunction = ({ from = 0, durationInFrames = Infinity,
103
104
  showInTimeline,
104
105
  nonce,
105
106
  showLoopTimesInTimeline,
107
+ environment,
106
108
  ]);
107
109
  const endThreshold = cumulatedFrom + from + durationInFrames - 1;
108
110
  const content = absoluteFrame < cumulatedFrom + from
@@ -19,6 +19,7 @@ const AudioRefForwardingFunction = (props, ref) => {
19
19
  const { startFrom, endAt, ...otherProps } = props;
20
20
  const { loop, ...propsOtherThanLoop } = props;
21
21
  const { fps } = (0, use_video_config_1.useVideoConfig)();
22
+ const environment = (0, get_environment_1.useRemotionEnvironment)();
22
23
  const { durations, setDurations } = (0, react_1.useContext)(duration_state_1.DurationsContext);
23
24
  if (typeof props.src !== 'string') {
24
25
  throw new TypeError(`The \`<Audio>\` tag requires a string for \`src\`, but got ${JSON.stringify(props.src)} instead.`);
@@ -43,7 +44,7 @@ const AudioRefForwardingFunction = (props, ref) => {
43
44
  return ((0, jsx_runtime_1.jsx)(Sequence_1.Sequence, { layout: "none", from: 0 - startFromFrameNo, showInTimeline: false, durationInFrames: endAtFrameNo, children: (0, jsx_runtime_1.jsx)(exports.Audio, { ...otherProps, ref: ref }) }));
44
45
  }
45
46
  (0, validate_media_props_1.validateMediaProps)(props, 'Audio');
46
- if ((0, get_environment_1.getRemotionEnvironment)() === 'rendering') {
47
+ if (environment === 'rendering') {
47
48
  return ((0, jsx_runtime_1.jsx)(AudioForRendering_1.AudioForRendering, { onDuration: onDuration, ...props, ref: ref, onError: onError }));
48
49
  }
49
50
  return ((0, jsx_runtime_1.jsx)(AudioForDevelopment_1.AudioForDevelopment, { shouldPreMountAudioTags: audioContext !== null && audioContext.numberOfAudioTags > 0, ...props, ref: ref, onError: onError, onDuration: onDuration }));
@@ -20,6 +20,7 @@ const AudioForRenderingRefForwardingFunction = (props, ref) => {
20
20
  const frame = (0, use_current_frame_1.useCurrentFrame)();
21
21
  const sequenceContext = (0, react_1.useContext)(Sequence_1.SequenceContext);
22
22
  const { registerAsset, unregisterAsset } = (0, react_1.useContext)(CompositionManager_1.CompositionManager);
23
+ const environment = (0, get_environment_1.useRemotionEnvironment)();
23
24
  // Generate a string that's as unique as possible for this asset
24
25
  // but at the same time the same on all threads
25
26
  const id = (0, react_1.useMemo)(() => {
@@ -77,7 +78,7 @@ const AudioForRenderingRefForwardingFunction = (props, ref) => {
77
78
  ]);
78
79
  const { src, onDuration } = props;
79
80
  // If audio source switches, make new handle
80
- if ((0, get_environment_1.getRemotionEnvironment)() === 'rendering') {
81
+ if (environment === 'rendering') {
81
82
  // eslint-disable-next-line react-hooks/rules-of-hooks
82
83
  (0, react_1.useLayoutEffect)(() => {
83
84
  if (process.env.NODE_ENV === 'test') {
@@ -1,2 +1,3 @@
1
1
  export declare type RemotionEnvironment = 'preview' | 'rendering' | 'player-development' | 'player-production';
2
2
  export declare const getRemotionEnvironment: () => RemotionEnvironment;
3
+ export declare const useRemotionEnvironment: () => RemotionEnvironment;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRemotionEnvironment = void 0;
3
+ exports.useRemotionEnvironment = exports.getRemotionEnvironment = void 0;
4
+ const is_player_1 = require("./is-player");
4
5
  const getRemotionEnvironment = () => {
5
6
  if (process.env.NODE_ENV === 'production') {
6
7
  if (typeof window !== 'undefined' && window.remotion_isPlayer) {
@@ -20,3 +21,14 @@ const getRemotionEnvironment = () => {
20
21
  return 'preview';
21
22
  };
22
23
  exports.getRemotionEnvironment = getRemotionEnvironment;
24
+ const useRemotionEnvironment = () => {
25
+ const isPlayer = (0, is_player_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;
package/dist/index.d.ts CHANGED
@@ -85,4 +85,5 @@ export declare const Experimental: {
85
85
  y: number;
86
86
  }>;
87
87
  Null: import("react").FC<{}>;
88
+ useIsPlayer: () => boolean;
88
89
  };
package/dist/index.js CHANGED
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.Experimental = exports.useCurrentFrame = exports.staticFile = exports.Series = exports.Sequence = exports.registerRoot = exports.random = exports.prefetch = exports.Loop = exports.interpolateColors = exports.getStaticFiles = exports.getInputProps = exports.Config = void 0;
18
18
  require("./asset-types");
19
19
  const Clipper_1 = require("./Clipper");
20
+ const is_player_1 = require("./is-player");
20
21
  const multiple_versions_warning_1 = require("./multiple-versions-warning");
21
22
  const Null_1 = require("./Null");
22
23
  (0, multiple_versions_warning_1.checkMultipleRemotionVersions)();
@@ -64,4 +65,5 @@ __exportStar(require("./video-config"), exports);
64
65
  exports.Experimental = {
65
66
  Clipper: Clipper_1.Clipper,
66
67
  Null: Null_1.Null,
68
+ useIsPlayer: is_player_1.useIsPlayer,
67
69
  };
@@ -86,6 +86,11 @@ export declare const Internals: {
86
86
  DurationsContextProvider: import("react").FC<{
87
87
  children: import("react").ReactNode;
88
88
  }>;
89
+ IsPlayerContextProvider: import("react").FC<{
90
+ children?: import("react").ReactNode;
91
+ }>;
92
+ useIsPlayer: () => boolean;
93
+ useRemotionEnvironment: () => RemotionEnvironment;
89
94
  };
90
95
  declare type WebpackConfiguration = Configuration;
91
96
  declare type WebpackOverrideFn = (currentConfiguration: WebpackConfiguration) => WebpackConfiguration;
package/dist/internals.js CHANGED
@@ -32,6 +32,7 @@ const CSSUtils = __importStar(require("./default-css"));
32
32
  const delay_render_1 = require("./delay-render");
33
33
  const get_environment_1 = require("./get-environment");
34
34
  const get_preview_dom_element_1 = require("./get-preview-dom-element");
35
+ const is_player_1 = require("./is-player");
35
36
  const portal_node_1 = require("./portal-node");
36
37
  const prefetch_state_1 = require("./prefetch-state");
37
38
  const register_root_1 = require("./register-root");
@@ -92,4 +93,7 @@ exports.Internals = {
92
93
  enableLegacyRemotionConfig: config_1.enableLegacyRemotionConfig,
93
94
  PrefetchProvider: prefetch_state_1.PrefetchProvider,
94
95
  DurationsContextProvider: duration_state_1.DurationsContextProvider,
96
+ IsPlayerContextProvider: is_player_1.IsPlayerContextProvider,
97
+ useIsPlayer: is_player_1.useIsPlayer,
98
+ useRemotionEnvironment: get_environment_1.useRemotionEnvironment,
95
99
  };
@@ -0,0 +1,3 @@
1
+ import type { PropsWithChildren } from 'react';
2
+ export declare const IsPlayerContextProvider: React.FC<PropsWithChildren>;
3
+ export declare const useIsPlayer: () => boolean;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useIsPlayer = exports.IsPlayerContextProvider = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const IsPlayerContext = (0, react_1.createContext)(false);
7
+ const IsPlayerContextProvider = ({ children, }) => {
8
+ return (0, jsx_runtime_1.jsx)(IsPlayerContext.Provider, { value: true, children: children });
9
+ };
10
+ exports.IsPlayerContextProvider = IsPlayerContextProvider;
11
+ const useIsPlayer = () => {
12
+ return (0, react_1.useContext)(IsPlayerContext);
13
+ };
14
+ exports.useIsPlayer = useIsPlayer;
@@ -37,6 +37,7 @@ const useMediaInTimeline = ({ volume, mediaVolume, mediaRef, src, mediaType, pla
37
37
  ? Math.min(parentSequence.durationInFrames, videoConfig.durationInFrames)
38
38
  : videoConfig.durationInFrames;
39
39
  const doesVolumeChange = typeof volume === 'function';
40
+ const environment = (0, get_environment_1.useRemotionEnvironment)();
40
41
  const volumes = (0, react_1.useMemo)(() => {
41
42
  if (typeof volume === 'number') {
42
43
  return volume;
@@ -66,8 +67,7 @@ const useMediaInTimeline = ({ volume, mediaVolume, mediaRef, src, mediaType, pla
66
67
  if (!src) {
67
68
  throw new Error('No src passed');
68
69
  }
69
- if ((0, get_environment_1.getRemotionEnvironment)() !== 'preview' &&
70
- process.env.NODE_ENV !== 'test') {
70
+ if (environment !== 'preview' && process.env.NODE_ENV !== 'test') {
71
71
  return;
72
72
  }
73
73
  registerSequence({
@@ -107,6 +107,7 @@ const useMediaInTimeline = ({ volume, mediaVolume, mediaRef, src, mediaType, pla
107
107
  mediaType,
108
108
  startsAt,
109
109
  playbackRate,
110
+ environment,
110
111
  ]);
111
112
  (0, react_1.useEffect)(() => {
112
113
  const tag = {
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useVideoConfig = void 0;
4
4
  const react_1 = require("react");
5
5
  const CanUseRemotionHooks_1 = require("./CanUseRemotionHooks");
6
+ const is_player_1 = require("./is-player");
6
7
  const use_unsafe_video_config_1 = require("./use-unsafe-video-config");
7
8
  /**
8
9
  * Get some info about the context of the video that you are making.
@@ -12,8 +13,10 @@ const use_unsafe_video_config_1 = require("./use-unsafe-video-config");
12
13
  const useVideoConfig = () => {
13
14
  const videoConfig = (0, use_unsafe_video_config_1.useUnsafeVideoConfig)();
14
15
  const context = (0, react_1.useContext)(CanUseRemotionHooks_1.CanUseRemotionHooks);
16
+ const isPlayer = (0, is_player_1.useIsPlayer)();
15
17
  if (!videoConfig) {
16
- if (typeof window !== 'undefined' && window.remotion_isPlayer) {
18
+ if ((typeof window !== 'undefined' && window.remotion_isPlayer) ||
19
+ isPlayer) {
17
20
  throw new Error('No video config found. You are probably calling useVideoConfig() from outside the component passed to <Player />. See https://www.remotion.dev/docs/player/examples for how to set up the Player correctly.');
18
21
  }
19
22
  throw new Error('No video config found. You are probably calling useVideoConfig() from a component which has not been registered as a <Composition />. See https://www.remotion.dev/docs/the-fundamentals#defining-compositions for more information.');
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "3.3.36";
1
+ export declare const VERSION = "3.3.38";
package/dist/version.js CHANGED
@@ -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 = '3.3.36';
5
+ exports.VERSION = '3.3.38';
@@ -12,6 +12,7 @@ const OffthreadVideoForRendering_1 = require("./OffthreadVideoForRendering");
12
12
  const VideoForDevelopment_1 = require("./VideoForDevelopment");
13
13
  const OffthreadVideo = (props) => {
14
14
  const { startFrom, endAt, ...otherProps } = props;
15
+ const environment = (0, get_environment_1.useRemotionEnvironment)();
15
16
  const onDuration = (0, react_1.useCallback)(() => undefined, []);
16
17
  if (typeof props.src !== 'string') {
17
18
  throw new TypeError(`The \`<OffthreadVideo>\` tag requires a string for \`src\`, but got ${JSON.stringify(props.src)} instead.`);
@@ -24,7 +25,7 @@ const OffthreadVideo = (props) => {
24
25
  }
25
26
  (0, validate_media_props_1.validateMediaProps)(props, 'Video');
26
27
  (0, validate_offthreadvideo_image_format_1.validateOffthreadVideoImageFormat)(props.imageFormat);
27
- if ((0, get_environment_1.getRemotionEnvironment)() === 'rendering') {
28
+ if (environment === 'rendering') {
28
29
  return (0, jsx_runtime_1.jsx)(OffthreadVideoForRendering_1.OffthreadVideoForRendering, { ...otherProps });
29
30
  }
30
31
  return ((0, jsx_runtime_1.jsx)(VideoForDevelopment_1.VideoForDevelopment, { onDuration: onDuration, onlyWarnForMediaSeekingError: true, ...otherProps }));
@@ -17,6 +17,7 @@ const VideoForwardingFunction = (props, ref) => {
17
17
  const { startFrom, endAt, ...otherProps } = props;
18
18
  const { loop, ...propsOtherThanLoop } = props;
19
19
  const { fps } = (0, use_video_config_1.useVideoConfig)();
20
+ const environment = (0, get_environment_1.useRemotionEnvironment)();
20
21
  const { durations, setDurations } = (0, react_1.useContext)(duration_state_1.DurationsContext);
21
22
  if (typeof ref === 'string') {
22
23
  throw new Error('string refs are not supported');
@@ -40,7 +41,7 @@ const VideoForwardingFunction = (props, ref) => {
40
41
  return ((0, jsx_runtime_1.jsx)(Sequence_1.Sequence, { layout: "none", from: 0 - startFromFrameNo, showInTimeline: false, durationInFrames: endAtFrameNo, children: (0, jsx_runtime_1.jsx)(exports.Video, { ...otherProps, ref: ref }) }));
41
42
  }
42
43
  (0, validate_media_props_1.validateMediaProps)(props, 'Video');
43
- if ((0, get_environment_1.getRemotionEnvironment)() === 'rendering') {
44
+ if (environment === 'rendering') {
44
45
  return ((0, jsx_runtime_1.jsx)(VideoForRendering_1.VideoForRendering, { onDuration: onDuration, ...otherProps, ref: ref }));
45
46
  }
46
47
  return ((0, jsx_runtime_1.jsx)(VideoForDevelopment_1.VideoForDevelopment, { onlyWarnForMediaSeekingError: false, ...otherProps, ref: ref, onDuration: onDuration }));
@@ -25,6 +25,7 @@ const VideoForRenderingForwardFunction = ({ onError, volume: volumeProp, allowAm
25
25
  const videoRef = (0, react_1.useRef)(null);
26
26
  const sequenceContext = (0, react_1.useContext)(Sequence_1.SequenceContext);
27
27
  const mediaStartsAt = (0, use_audio_frame_1.useMediaStartsAt)();
28
+ const environment = (0, get_environment_1.useRemotionEnvironment)();
28
29
  const { registerAsset, unregisterAsset } = (0, react_1.useContext)(CompositionManager_1.CompositionManager);
29
30
  // Generate a string that's as unique as possible for this asset
30
31
  // but at the same time the same on all threads
@@ -169,7 +170,7 @@ const VideoForRenderingForwardFunction = ({ onError, volume: volumeProp, allowAm
169
170
  ]);
170
171
  const { src } = props;
171
172
  // If video source switches, make new handle
172
- if ((0, get_environment_1.getRemotionEnvironment)() === 'rendering') {
173
+ if (environment === 'rendering') {
173
174
  // eslint-disable-next-line react-hooks/rules-of-hooks
174
175
  (0, react_1.useLayoutEffect)(() => {
175
176
  if (process.env.NODE_ENV === 'test') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remotion",
3
- "version": "3.3.36",
3
+ "version": "3.3.38",
4
4
  "description": "Render videos in React",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -65,5 +65,5 @@
65
65
  ]
66
66
  }
67
67
  },
68
- "gitHead": "623bf1e883e7b26b9d02458037c930ccbe8857e4"
68
+ "gitHead": "ac58695e452e58deb5c010f09bcc94d036930e6c"
69
69
  }