remotion 4.0.139 → 4.0.140

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.
Files changed (38) hide show
  1. package/dist/cjs/CompositionManager.d.ts +1 -0
  2. package/dist/cjs/IFrame.d.ts +4 -1
  3. package/dist/cjs/IFrame.js +5 -2
  4. package/dist/cjs/Img.d.ts +5 -3
  5. package/dist/cjs/Img.js +16 -4
  6. package/dist/cjs/RemotionRoot.d.ts +2 -2
  7. package/dist/cjs/RemotionRoot.js +2 -1
  8. package/dist/cjs/Sequence.d.ts +11 -2
  9. package/dist/cjs/Sequence.js +41 -1
  10. package/dist/cjs/SequenceContext.d.ts +1 -0
  11. package/dist/cjs/audio/Audio.d.ts +2 -0
  12. package/dist/cjs/audio/AudioForPreview.js +6 -1
  13. package/dist/cjs/audio/AudioForRendering.d.ts +3 -1
  14. package/dist/cjs/audio/AudioForRendering.js +12 -3
  15. package/dist/cjs/audio/props.d.ts +2 -0
  16. package/dist/cjs/delay-render.d.ts +7 -1
  17. package/dist/cjs/delay-render.js +12 -6
  18. package/dist/cjs/freeze.js +5 -9
  19. package/dist/cjs/index.d.ts +2 -1
  20. package/dist/cjs/internals.d.ts +2 -2
  21. package/dist/cjs/loop/index.js +1 -1
  22. package/dist/cjs/no-react.d.ts +2 -0
  23. package/dist/cjs/no-react.js +2 -0
  24. package/dist/cjs/use-media-buffering.d.ts +5 -1
  25. package/dist/cjs/use-media-buffering.js +5 -2
  26. package/dist/cjs/use-media-in-timeline.d.ts +2 -1
  27. package/dist/cjs/use-media-in-timeline.js +3 -1
  28. package/dist/cjs/version.d.ts +1 -1
  29. package/dist/cjs/version.js +1 -1
  30. package/dist/cjs/video/Video.d.ts +2 -0
  31. package/dist/cjs/video/VideoForPreview.js +6 -1
  32. package/dist/cjs/video/VideoForRendering.d.ts +3 -1
  33. package/dist/cjs/video/VideoForRendering.js +12 -4
  34. package/dist/cjs/video/props.d.ts +2 -0
  35. package/dist/esm/index.mjs +185 -100
  36. package/dist/esm/no-react.mjs +4 -0
  37. package/dist/esm/version.mjs +1 -1
  38. package/package.json +1 -1
@@ -54,6 +54,7 @@ export type TSequence = {
54
54
  nonce: number;
55
55
  loopDisplay: LoopDisplay | undefined;
56
56
  stack: string | null;
57
+ premountDisplay: number | null;
57
58
  } & EnhancedTSequenceData;
58
59
  export type TRenderAsset = {
59
60
  type: 'audio' | 'video';
@@ -3,4 +3,7 @@ import React from 'react';
3
3
  * @description The <IFrame /> can be used like a regular <iframe> HTML tag.
4
4
  * @see [Documentation](https://www.remotion.dev/docs/iframe)
5
5
  */
6
- export declare const IFrame: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.IframeHTMLAttributes<HTMLIFrameElement>, HTMLIFrameElement>, "ref"> & React.RefAttributes<HTMLIFrameElement>>;
6
+ export declare const IFrame: React.ForwardRefExoticComponent<Omit<React.ClassAttributes<HTMLIFrameElement> & React.IframeHTMLAttributes<HTMLIFrameElement> & {
7
+ readonly delayRenderRetries?: number | undefined;
8
+ readonly delayRenderTimeoutInMilliseconds?: number | undefined;
9
+ }, "ref"> & React.RefAttributes<HTMLIFrameElement>>;
@@ -4,8 +4,11 @@ exports.IFrame = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const delay_render_js_1 = require("./delay-render.js");
7
- const IFrameRefForwarding = ({ onLoad, onError, ...props }, ref) => {
8
- const [handle] = (0, react_1.useState)(() => (0, delay_render_js_1.delayRender)(`Loading <IFrame> with source ${props.src}`));
7
+ const IFrameRefForwarding = ({ onLoad, onError, delayRenderRetries, delayRenderTimeoutInMilliseconds, ...props }, ref) => {
8
+ const [handle] = (0, react_1.useState)(() => (0, delay_render_js_1.delayRender)(`Loading <IFrame> with source ${props.src}`, {
9
+ retries: delayRenderRetries !== null && delayRenderRetries !== void 0 ? delayRenderRetries : undefined,
10
+ timeoutInMilliseconds: delayRenderTimeoutInMilliseconds !== null && delayRenderTimeoutInMilliseconds !== void 0 ? delayRenderTimeoutInMilliseconds : undefined,
11
+ }));
9
12
  const didLoad = (0, react_1.useCallback)((e) => {
10
13
  (0, delay_render_js_1.continueRender)(handle);
11
14
  onLoad === null || onLoad === void 0 ? void 0 : onLoad(e);
package/dist/cjs/Img.d.ts CHANGED
@@ -1,8 +1,10 @@
1
1
  import React from 'react';
2
2
  export type ImgProps = Omit<React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, 'src'> & {
3
- maxRetries?: number;
4
- pauseWhenLoading?: boolean;
5
- src: string;
3
+ readonly maxRetries?: number;
4
+ readonly pauseWhenLoading?: boolean;
5
+ readonly delayRenderRetries?: number;
6
+ readonly delayRenderTimeoutInMilliseconds?: number;
7
+ readonly src: string;
6
8
  };
7
9
  /**
8
10
  * @description Works just like a regular HTML img tag. When you use the <Img> tag, Remotion will ensure that the image is loaded before rendering the frame.
package/dist/cjs/Img.js CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Img = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
+ const SequenceContext_js_1 = require("./SequenceContext.js");
6
7
  const cancel_render_js_1 = require("./cancel-render.js");
7
8
  const delay_render_js_1 = require("./delay-render.js");
8
9
  const prefetch_js_1 = require("./prefetch.js");
@@ -10,10 +11,11 @@ const use_buffer_state_js_1 = require("./use-buffer-state.js");
10
11
  function exponentialBackoff(errorCount) {
11
12
  return 1000 * 2 ** (errorCount - 1);
12
13
  }
13
- const ImgRefForwarding = ({ onError, maxRetries = 2, src, pauseWhenLoading, ...props }, ref) => {
14
+ const ImgRefForwarding = ({ onError, maxRetries = 2, src, pauseWhenLoading, delayRenderRetries, delayRenderTimeoutInMilliseconds, ...props }, ref) => {
14
15
  const imageRef = (0, react_1.useRef)(null);
15
16
  const errors = (0, react_1.useRef)({});
16
17
  const { delayPlayback } = (0, use_buffer_state_js_1.useBufferState)();
18
+ const sequenceContext = (0, react_1.useContext)(SequenceContext_js_1.SequenceContext);
17
19
  if (!src) {
18
20
  throw new Error('No "src" prop was passed to <Img>.');
19
21
  }
@@ -68,8 +70,11 @@ const ImgRefForwarding = ({ onError, maxRetries = 2, src, pauseWhenLoading, ...p
68
70
  if (process.env.NODE_ENV === 'test') {
69
71
  return;
70
72
  }
71
- const newHandle = (0, delay_render_js_1.delayRender)('Loading <Img> with src=' + actualSrc);
72
- const unblock = pauseWhenLoading
73
+ const newHandle = (0, delay_render_js_1.delayRender)('Loading <Img> with src=' + actualSrc, {
74
+ retries: delayRenderRetries !== null && delayRenderRetries !== void 0 ? delayRenderRetries : undefined,
75
+ timeoutInMilliseconds: delayRenderTimeoutInMilliseconds !== null && delayRenderTimeoutInMilliseconds !== void 0 ? delayRenderTimeoutInMilliseconds : undefined,
76
+ });
77
+ const unblock = pauseWhenLoading && !(sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.premounting)
73
78
  ? delayPlayback().unblock
74
79
  : () => undefined;
75
80
  const { current } = imageRef;
@@ -98,7 +103,14 @@ const ImgRefForwarding = ({ onError, maxRetries = 2, src, pauseWhenLoading, ...p
98
103
  unblock();
99
104
  (0, delay_render_js_1.continueRender)(newHandle);
100
105
  };
101
- }, [actualSrc, delayPlayback, pauseWhenLoading]);
106
+ }, [
107
+ actualSrc,
108
+ delayPlayback,
109
+ delayRenderRetries,
110
+ delayRenderTimeoutInMilliseconds,
111
+ pauseWhenLoading,
112
+ sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.premounting,
113
+ ]);
102
114
  }
103
115
  return ((0, jsx_runtime_1.jsx)("img", { ...props, ref: imageRef, src: actualSrc, onError: didGetError }));
104
116
  };
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  export declare const RemotionRoot: React.FC<{
3
- children: React.ReactNode;
4
- numberOfAudioTags: number;
3
+ readonly children: React.ReactNode;
4
+ readonly numberOfAudioTags: number;
5
5
  }>;
@@ -24,7 +24,8 @@ const RemotionRoot = ({ children, numberOfAudioTags }) => {
24
24
  if (typeof window !== 'undefined') {
25
25
  // eslint-disable-next-line react-hooks/rules-of-hooks
26
26
  (0, react_1.useLayoutEffect)(() => {
27
- window.remotion_setFrame = (f, composition) => {
27
+ window.remotion_setFrame = (f, composition, attempt) => {
28
+ window.remotion_attempt = attempt;
28
29
  const id = (0, delay_render_js_1.delayRender)(`Setting the current frame to ${f}`);
29
30
  setFrame((s) => ({
30
31
  ...s,
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import type { LoopDisplay } from './CompositionManager.js';
3
3
  export type LayoutAndStyle = {
4
4
  layout?: 'absolute-fill';
5
+ premountFor?: number;
5
6
  style?: React.CSSProperties;
6
7
  className?: string;
7
8
  } | {
@@ -17,11 +18,19 @@ export type SequencePropsWithoutDuration = {
17
18
  /**
18
19
  * @deprecated For internal use only.
19
20
  */
20
- loopDisplay?: LoopDisplay;
21
+ _remotionInternalLoopDisplay?: LoopDisplay;
21
22
  /**
22
23
  * @deprecated For internal use only.
23
24
  */
24
- stack?: string;
25
+ _remotionInternalPremountDisplay?: number | null;
26
+ /**
27
+ * @deprecated For internal use only.
28
+ */
29
+ _remotionInternalStack?: string;
30
+ /**
31
+ * @deprecated For internal use only.
32
+ */
33
+ _remotionInternalIsPremounting?: boolean;
25
34
  } & LayoutAndStyle;
26
35
  export type SequenceProps = {
27
36
  durationInFrames?: number;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Sequence = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ /* eslint-disable @typescript-eslint/no-use-before-define */
5
6
  const react_1 = require("react");
6
7
  const AbsoluteFill_js_1 = require("./AbsoluteFill.js");
7
8
  const SequenceContext_js_1 = require("./SequenceContext.js");
@@ -10,7 +11,9 @@ const get_remotion_environment_js_1 = require("./get-remotion-environment.js");
10
11
  const nonce_js_1 = require("./nonce.js");
11
12
  const timeline_position_state_js_1 = require("./timeline-position-state.js");
12
13
  const use_video_config_js_1 = require("./use-video-config.js");
13
- const SequenceRefForwardingFunction = ({ from = 0, durationInFrames = Infinity, children, name, height, width, showInTimeline = true, loopDisplay, stack, ...other }, ref) => {
14
+ const freeze_js_1 = require("./freeze.js");
15
+ const use_current_frame_1 = require("./use-current-frame");
16
+ const RegularSequenceRefForwardingFunction = ({ from = 0, durationInFrames = Infinity, children, name, height, width, showInTimeline = true, _remotionInternalLoopDisplay: loopDisplay, _remotionInternalStack: stack, _remotionInternalPremountDisplay: premountDisplay, ...other }, ref) => {
14
17
  var _a;
15
18
  const { layout = 'absolute-fill' } = other;
16
19
  const [id] = (0, react_1.useState)(() => String(Math.random()));
@@ -47,6 +50,10 @@ const SequenceRefForwardingFunction = ({ from = 0, durationInFrames = Infinity,
47
50
  const actualDurationInFrames = Math.max(0, Math.min(videoConfig.durationInFrames - from, parentSequenceDuration));
48
51
  const { registerSequence, unregisterSequence } = (0, react_1.useContext)(SequenceManager_js_1.SequenceManager);
49
52
  const { hidden } = (0, react_1.useContext)(SequenceManager_js_1.SequenceVisibilityToggleContext);
53
+ const premounting = (0, react_1.useMemo)(() => {
54
+ var _a;
55
+ return ((_a = parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.premounting) !== null && _a !== void 0 ? _a : Boolean(other._remotionInternalIsPremounting));
56
+ }, [other._remotionInternalIsPremounting, parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.premounting]);
50
57
  const contextValue = (0, react_1.useMemo)(() => {
51
58
  var _a, _b, _c;
52
59
  return {
@@ -57,6 +64,7 @@ const SequenceRefForwardingFunction = ({ from = 0, durationInFrames = Infinity,
57
64
  id,
58
65
  height: (_b = height !== null && height !== void 0 ? height : parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.height) !== null && _b !== void 0 ? _b : null,
59
66
  width: (_c = width !== null && width !== void 0 ? width : parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.width) !== null && _c !== void 0 ? _c : null,
67
+ premounting,
60
68
  };
61
69
  }, [
62
70
  cumulatedFrom,
@@ -66,6 +74,7 @@ const SequenceRefForwardingFunction = ({ from = 0, durationInFrames = Infinity,
66
74
  id,
67
75
  height,
68
76
  width,
77
+ premounting,
69
78
  ]);
70
79
  const timelineClipName = (0, react_1.useMemo)(() => {
71
80
  return name !== null && name !== void 0 ? name : '';
@@ -87,6 +96,7 @@ const SequenceRefForwardingFunction = ({ from = 0, durationInFrames = Infinity,
87
96
  nonce,
88
97
  loopDisplay,
89
98
  stack: stack !== null && stack !== void 0 ? stack : null,
99
+ premountDisplay: premountDisplay !== null && premountDisplay !== void 0 ? premountDisplay : null,
90
100
  });
91
101
  return () => {
92
102
  unregisterSequence(id);
@@ -106,6 +116,7 @@ const SequenceRefForwardingFunction = ({ from = 0, durationInFrames = Infinity,
106
116
  nonce,
107
117
  loopDisplay,
108
118
  stack,
119
+ premountDisplay,
109
120
  ]);
110
121
  // Ceil to support floats
111
122
  // https://github.com/remotion-dev/remotion/issues/2958
@@ -133,6 +144,35 @@ const SequenceRefForwardingFunction = ({ from = 0, durationInFrames = Infinity,
133
144
  }
134
145
  return ((0, jsx_runtime_1.jsx)(SequenceContext_js_1.SequenceContext.Provider, { value: contextValue, children: content === null ? null : other.layout === 'none' ? (content) : ((0, jsx_runtime_1.jsx)(AbsoluteFill_js_1.AbsoluteFill, { ref: ref, style: defaultStyle, className: other.className, children: content })) }));
135
146
  };
147
+ const RegularSequence = (0, react_1.forwardRef)(RegularSequenceRefForwardingFunction);
148
+ const PremountedSequenceRefForwardingFunction = (props, ref) => {
149
+ const frame = (0, use_current_frame_1.useCurrentFrame)();
150
+ if (props.layout === 'none') {
151
+ throw new Error('`<Sequence>` with `premountFor` prop does not support layout="none"');
152
+ }
153
+ const { style: passedStyle, from = 0, premountFor = 0, name, ...otherProps } = props;
154
+ const premountingActive = frame < from && frame >= from - premountFor;
155
+ const style = (0, react_1.useMemo)(() => {
156
+ var _a;
157
+ return {
158
+ ...passedStyle,
159
+ opacity: premountingActive ? 0 : 1,
160
+ pointerEvents: premountingActive
161
+ ? 'none'
162
+ : (_a = passedStyle === null || passedStyle === void 0 ? void 0 : passedStyle.pointerEvents) !== null && _a !== void 0 ? _a : undefined,
163
+ };
164
+ }, [premountingActive, passedStyle]);
165
+ return ((0, jsx_runtime_1.jsx)(freeze_js_1.Freeze, { frame: from, active: premountingActive, children: (0, jsx_runtime_1.jsx)(exports.Sequence, { ref: ref, from: from, style: style, _remotionInternalPremountDisplay: premountFor, _remotionInternalIsPremounting: premountingActive, ...otherProps }) }));
166
+ };
167
+ const PremountedSequence = (0, react_1.forwardRef)(PremountedSequenceRefForwardingFunction);
168
+ const SequenceRefForwardingFunction = (props, ref) => {
169
+ if (props.layout !== 'none' &&
170
+ props.premountFor &&
171
+ !(0, get_remotion_environment_js_1.getRemotionEnvironment)().isRendering) {
172
+ return (0, jsx_runtime_1.jsx)(PremountedSequence, { ...props, ref: ref });
173
+ }
174
+ return (0, jsx_runtime_1.jsx)(RegularSequence, { ...props, ref: ref });
175
+ };
136
176
  /**
137
177
  * @description A component that time-shifts its children and wraps them in an absolutely positioned <div>.
138
178
  * @see [Documentation](https://www.remotion.dev/docs/sequence)
@@ -8,4 +8,5 @@ export type SequenceContextType = {
8
8
  id: string;
9
9
  width: number | null;
10
10
  height: number | null;
11
+ premounting: boolean;
11
12
  };
@@ -15,6 +15,8 @@ export declare const Audio: React.ForwardRefExoticComponent<Omit<Omit<React.Deta
15
15
  toneFrequency?: number | undefined;
16
16
  pauseWhenBuffering?: boolean | undefined;
17
17
  showInTimeline?: boolean | undefined;
18
+ delayRenderTimeoutInMilliseconds?: number | undefined;
19
+ delayRenderRetries?: number | undefined;
18
20
  } & RemotionMainAudioProps & {
19
21
  /**
20
22
  * @deprecated For internal use only
@@ -78,6 +78,7 @@ const AudioForDevelopmentForwardRefFunction = (props, ref) => {
78
78
  id: timelineId,
79
79
  stack: _remotionInternalStack,
80
80
  showInTimeline,
81
+ premountDisplay: null,
81
82
  });
82
83
  (0, use_media_playback_js_1.useMediaPlayback)({
83
84
  mediaRef: audioRef,
@@ -87,7 +88,11 @@ const AudioForDevelopmentForwardRefFunction = (props, ref) => {
87
88
  onlyWarnForMediaSeekingError: false,
88
89
  acceptableTimeshift: acceptableTimeShiftInSeconds !== null && acceptableTimeShiftInSeconds !== void 0 ? acceptableTimeShiftInSeconds : use_media_playback_js_1.DEFAULT_ACCEPTABLE_TIMESHIFT,
89
90
  });
90
- (0, use_media_buffering_js_1.useMediaBuffering)(audioRef, pauseWhenBuffering);
91
+ (0, use_media_buffering_js_1.useMediaBuffering)({
92
+ element: audioRef,
93
+ shouldBuffer: pauseWhenBuffering,
94
+ isPremounting: Boolean(sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.premounting),
95
+ });
91
96
  (0, react_1.useImperativeHandle)(ref, () => {
92
97
  return audioRef.current;
93
98
  }, [audioRef]);
@@ -11,6 +11,8 @@ export declare const AudioForRendering: ForwardRefExoticComponent<Omit<React.Det
11
11
  toneFrequency?: number | undefined;
12
12
  pauseWhenBuffering?: boolean | undefined;
13
13
  showInTimeline?: boolean | undefined;
14
+ delayRenderTimeoutInMilliseconds?: number | undefined;
15
+ delayRenderRetries?: number | undefined;
14
16
  } & {
15
- onDuration: (src: string, durationInSeconds: number) => void;
17
+ readonly onDuration: (src: string, durationInSeconds: number) => void;
16
18
  } & RefAttributes<HTMLAudioElement>>;
@@ -30,7 +30,7 @@ const AudioForRenderingRefForwardingFunction = (props, ref) => {
30
30
  sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.cumulatedFrom,
31
31
  sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.durationInFrames,
32
32
  ]);
33
- const { volume: volumeProp, playbackRate, allowAmplificationDuringRender, onDuration, toneFrequency, _remotionInternalNeedsDurationCalculation, _remotionInternalNativeLoopPassed, acceptableTimeShiftInSeconds, name, onError, ...nativeProps } = props;
33
+ const { volume: volumeProp, playbackRate, allowAmplificationDuringRender, onDuration, toneFrequency, _remotionInternalNeedsDurationCalculation, _remotionInternalNativeLoopPassed, acceptableTimeShiftInSeconds, name, onError, delayRenderRetries, delayRenderTimeoutInMilliseconds, ...nativeProps } = props;
34
34
  const volume = (0, volume_prop_js_1.evaluateVolume)({
35
35
  volume: volumeProp,
36
36
  frame: volumePropFrame,
@@ -93,7 +93,10 @@ const AudioForRenderingRefForwardingFunction = (props, ref) => {
93
93
  if (!needsToRenderAudioTag) {
94
94
  return;
95
95
  }
96
- const newHandle = (0, delay_render_js_1.delayRender)('Loading <Audio> duration with src=' + src);
96
+ const newHandle = (0, delay_render_js_1.delayRender)('Loading <Audio> duration with src=' + src, {
97
+ retries: delayRenderRetries !== null && delayRenderRetries !== void 0 ? delayRenderRetries : undefined,
98
+ timeoutInMilliseconds: delayRenderTimeoutInMilliseconds !== null && delayRenderTimeoutInMilliseconds !== void 0 ? delayRenderTimeoutInMilliseconds : undefined,
99
+ });
97
100
  const { current } = audioRef;
98
101
  const didLoad = () => {
99
102
  if (current === null || current === void 0 ? void 0 : current.duration) {
@@ -113,7 +116,13 @@ const AudioForRenderingRefForwardingFunction = (props, ref) => {
113
116
  current === null || current === void 0 ? void 0 : current.removeEventListener('loadedmetadata', didLoad);
114
117
  (0, delay_render_js_1.continueRender)(newHandle);
115
118
  };
116
- }, [src, onDuration, needsToRenderAudioTag]);
119
+ }, [
120
+ src,
121
+ onDuration,
122
+ needsToRenderAudioTag,
123
+ delayRenderRetries,
124
+ delayRenderTimeoutInMilliseconds,
125
+ ]);
117
126
  if (!needsToRenderAudioTag) {
118
127
  return null;
119
128
  }
@@ -15,4 +15,6 @@ export type RemotionAudioProps = Omit<React.DetailedHTMLProps<React.AudioHTMLAtt
15
15
  toneFrequency?: number;
16
16
  pauseWhenBuffering?: boolean;
17
17
  showInTimeline?: boolean;
18
+ delayRenderTimeoutInMilliseconds?: number;
19
+ delayRenderRetries?: number;
18
20
  };
@@ -1,11 +1,17 @@
1
1
  export declare const DELAY_RENDER_CALLSTACK_TOKEN = "The delayRender was called:";
2
+ export declare const DELAY_RENDER_RETRIES_LEFT = "Retries left: ";
3
+ export declare const DELAY_RENDER_RETRY_TOKEN = "- Rendering the frame will be retried.";
4
+ export type DelayRenderOptions = {
5
+ timeoutInMilliseconds?: number;
6
+ retries?: number;
7
+ };
2
8
  /**
3
9
  * @description Call this function to tell Remotion to wait before capturing this frame until data has loaded. Use continueRender() to unblock the render.
4
10
  * @param label _optional_ A label to identify the call in case it does time out.
5
11
  * @returns {number} An identifier to be passed to continueRender().
6
12
  * @see [Documentation](https://www.remotion.dev/docs/delay-render)
7
13
  */
8
- export declare const delayRender: (label?: string) => number;
14
+ export declare const delayRender: (label?: string, options?: DelayRenderOptions) => number;
9
15
  /**
10
16
  * @description Unblock a render that has been blocked by delayRender()
11
17
  * @param handle The return value of delayRender().
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.continueRender = exports.delayRender = exports.DELAY_RENDER_CALLSTACK_TOKEN = void 0;
3
+ exports.continueRender = exports.delayRender = exports.DELAY_RENDER_RETRY_TOKEN = exports.DELAY_RENDER_RETRIES_LEFT = exports.DELAY_RENDER_CALLSTACK_TOKEN = void 0;
4
+ const cancel_render_js_1 = require("./cancel-render.js");
4
5
  const get_remotion_environment_js_1 = require("./get-remotion-environment.js");
5
6
  const truthy_js_1 = require("./truthy.js");
6
7
  if (typeof window !== 'undefined') {
@@ -11,6 +12,8 @@ if (typeof window !== 'undefined') {
11
12
  window.remotion_delayRenderTimeouts = {};
12
13
  }
13
14
  exports.DELAY_RENDER_CALLSTACK_TOKEN = 'The delayRender was called:';
15
+ exports.DELAY_RENDER_RETRIES_LEFT = 'Retries left: ';
16
+ exports.DELAY_RENDER_RETRY_TOKEN = '- Rendering the frame will be retried.';
14
17
  const defaultTimeout = 30000;
15
18
  /**
16
19
  * @description Call this function to tell Remotion to wait before capturing this frame until data has loaded. Use continueRender() to unblock the render.
@@ -18,8 +21,8 @@ const defaultTimeout = 30000;
18
21
  * @returns {number} An identifier to be passed to continueRender().
19
22
  * @see [Documentation](https://www.remotion.dev/docs/delay-render)
20
23
  */
21
- const delayRender = (label) => {
22
- var _a, _b, _c;
24
+ const delayRender = (label, options) => {
25
+ var _a, _b, _c, _d, _e;
23
26
  if (typeof label !== 'string' && typeof label !== 'undefined') {
24
27
  throw new Error('The label parameter of delayRender() must be a string or undefined, got: ' +
25
28
  JSON.stringify(label));
@@ -28,10 +31,11 @@ const delayRender = (label) => {
28
31
  handles.push(handle);
29
32
  const called = (_b = (_a = Error().stack) === null || _a === void 0 ? void 0 : _a.replace(/^Error/g, '')) !== null && _b !== void 0 ? _b : '';
30
33
  if ((0, get_remotion_environment_js_1.getRemotionEnvironment)().isRendering) {
31
- const timeoutToUse = typeof window === 'undefined'
34
+ const timeoutToUse = ((_c = options === null || options === void 0 ? void 0 : options.timeoutInMilliseconds) !== null && _c !== void 0 ? _c : (typeof window === 'undefined'
32
35
  ? defaultTimeout
33
- : ((_c = window.remotion_puppeteerTimeout) !== null && _c !== void 0 ? _c : defaultTimeout) - 2000;
36
+ : (_d = window.remotion_puppeteerTimeout) !== null && _d !== void 0 ? _d : defaultTimeout)) - 2000;
34
37
  if (typeof window !== 'undefined') {
38
+ const retriesLeft = ((_e = options === null || options === void 0 ? void 0 : options.retries) !== null && _e !== void 0 ? _e : 0) - (window.remotion_attempt - 1);
35
39
  window.remotion_delayRenderTimeouts[handle] = {
36
40
  label: label !== null && label !== void 0 ? label : null,
37
41
  timeout: setTimeout(() => {
@@ -39,12 +43,14 @@ const delayRender = (label) => {
39
43
  `A delayRender()`,
40
44
  label ? `"${label}"` : null,
41
45
  `was called but not cleared after ${timeoutToUse}ms. See https://remotion.dev/docs/timeout for help.`,
46
+ retriesLeft > 0 ? exports.DELAY_RENDER_RETRIES_LEFT + retriesLeft : null,
47
+ retriesLeft > 0 ? exports.DELAY_RENDER_RETRY_TOKEN : null,
42
48
  exports.DELAY_RENDER_CALLSTACK_TOKEN,
43
49
  called,
44
50
  ]
45
51
  .filter(truthy_js_1.truthy)
46
52
  .join(' ');
47
- throw new Error(message);
53
+ (0, cancel_render_js_1.cancelRender)(Error(message));
48
54
  }, timeoutToUse),
49
55
  };
50
56
  }
@@ -12,6 +12,7 @@ const use_video_config_js_1 = require("./use-video-config.js");
12
12
  * @see [Documentation](https://www.remotion.dev/docs/freeze)
13
13
  */
14
14
  const Freeze = ({ frame: frameToFreeze, children, active = true, }) => {
15
+ var _a;
15
16
  const frame = (0, use_current_frame_js_1.useCurrentFrame)();
16
17
  const videoConfig = (0, use_video_config_js_1.useVideoConfig)();
17
18
  if (typeof frameToFreeze === 'undefined') {
@@ -36,6 +37,7 @@ const Freeze = ({ frame: frameToFreeze, children, active = true, }) => {
36
37
  }, [active, frame]);
37
38
  const timelineContext = (0, react_1.useContext)(timeline_position_state_js_1.TimelineContext);
38
39
  const sequenceContext = (0, react_1.useContext)(SequenceContext_js_1.SequenceContext);
40
+ const relativeFrom = (_a = sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom) !== null && _a !== void 0 ? _a : 0;
39
41
  const timelineValue = (0, react_1.useMemo)(() => {
40
42
  if (!isActive) {
41
43
  return timelineContext;
@@ -47,16 +49,10 @@ const Freeze = ({ frame: frameToFreeze, children, active = true, }) => {
47
49
  current: false,
48
50
  },
49
51
  frame: {
50
- [videoConfig.id]: frameToFreeze,
52
+ [videoConfig.id]: frameToFreeze + relativeFrom,
51
53
  },
52
54
  };
53
- }, [timelineContext, frameToFreeze, isActive, videoConfig.id]);
54
- const sequenceValue = (0, react_1.useMemo)(() => {
55
- if (isActive) {
56
- return null;
57
- }
58
- return sequenceContext;
59
- }, [isActive, sequenceContext]);
60
- return ((0, jsx_runtime_1.jsx)(timeline_position_state_js_1.TimelineContext.Provider, { value: timelineValue, children: (0, jsx_runtime_1.jsx)(SequenceContext_js_1.SequenceContext.Provider, { value: sequenceValue, children: children }) }));
55
+ }, [isActive, timelineContext, videoConfig.id, frameToFreeze, relativeFrom]);
56
+ return ((0, jsx_runtime_1.jsx)(timeline_position_state_js_1.TimelineContext.Provider, { value: timelineValue, children: children }));
61
57
  };
62
58
  exports.Freeze = Freeze;
@@ -33,7 +33,8 @@ declare global {
33
33
  remotion_projectName: string;
34
34
  remotion_cwd: string;
35
35
  remotion_studioServerCommand: string;
36
- remotion_setFrame: (frame: number, composition: string) => void;
36
+ remotion_setFrame: (frame: number, composition: string, attempt: number) => void;
37
+ remotion_attempt: number;
37
38
  remotion_initialFrame: number;
38
39
  remotion_proxyPort: number;
39
40
  remotion_audioEnabled: boolean;
@@ -18,8 +18,8 @@ export declare const Internals: {
18
18
  readonly SequenceManager: import("react").Context<import("./SequenceManager.js").SequenceManagerContext>;
19
19
  readonly SequenceVisibilityToggleContext: import("react").Context<import("./SequenceManager.js").SequenceVisibilityToggleState>;
20
20
  readonly RemotionRoot: import("react").FC<{
21
- children: import("react").ReactNode;
22
- numberOfAudioTags: number;
21
+ readonly children: import("react").ReactNode;
22
+ readonly numberOfAudioTags: number;
23
23
  }>;
24
24
  readonly useVideo: () => (import("./video-config.js").VideoConfig & {
25
25
  component: import("react").LazyExoticComponent<import("react").ComponentType<Record<string, unknown>>>;
@@ -40,6 +40,6 @@ const Loop = ({ durationInFrames, times = Infinity, children, name, ...props })
40
40
  durationInFrames,
41
41
  };
42
42
  }, [actualTimes, durationInFrames, from]);
43
- return ((0, jsx_runtime_1.jsx)(Sequence_js_1.Sequence, { durationInFrames: durationInFrames, from: from, name: name !== null && name !== void 0 ? name : '<Loop>', loopDisplay: loopDisplay, layout: props.layout, style: style, children: children }));
43
+ return ((0, jsx_runtime_1.jsx)(Sequence_js_1.Sequence, { durationInFrames: durationInFrames, from: from, name: name !== null && name !== void 0 ? name : '<Loop>', _remotionInternalLoopDisplay: loopDisplay, layout: props.layout, style: style, children: children }));
44
44
  };
45
45
  exports.Loop = Loop;
@@ -29,6 +29,8 @@ export declare const NoReactInternals: {
29
29
  bundleMapName: string;
30
30
  deserializeJSONWithCustomFields: <T = Record<string, unknown>>(data: string) => T;
31
31
  DELAY_RENDER_CALLSTACK_TOKEN: string;
32
+ DELAY_RENDER_RETRY_TOKEN: string;
33
+ DELAY_RENDER_ATTEMPT_TOKEN: string;
32
34
  getOffthreadVideoSource: ({ src, transparent, currentTime, toneMapped, }: {
33
35
  src: string;
34
36
  transparent: boolean;
@@ -29,6 +29,8 @@ exports.NoReactInternals = {
29
29
  bundleMapName: 'bundle.js.map',
30
30
  deserializeJSONWithCustomFields: input_props_serialization_1.deserializeJSONWithCustomFields,
31
31
  DELAY_RENDER_CALLSTACK_TOKEN: delay_render_1.DELAY_RENDER_CALLSTACK_TOKEN,
32
+ DELAY_RENDER_RETRY_TOKEN: delay_render_1.DELAY_RENDER_RETRY_TOKEN,
33
+ DELAY_RENDER_ATTEMPT_TOKEN: delay_render_1.DELAY_RENDER_RETRIES_LEFT,
32
34
  getOffthreadVideoSource: offthread_video_source_1.getOffthreadVideoSource,
33
35
  getExpectedMediaFrameUncorrected: get_current_time_1.getExpectedMediaFrameUncorrected,
34
36
  };
@@ -1,2 +1,6 @@
1
1
  import type React from 'react';
2
- export declare const useMediaBuffering: (element: React.RefObject<HTMLVideoElement | HTMLAudioElement>, shouldBuffer: boolean) => void;
2
+ export declare const useMediaBuffering: ({ element, shouldBuffer, isPremounting, }: {
3
+ element: React.RefObject<HTMLVideoElement | HTMLAudioElement>;
4
+ shouldBuffer: boolean;
5
+ isPremounting: boolean;
6
+ }) => void;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useMediaBuffering = void 0;
4
4
  const react_1 = require("react");
5
5
  const use_buffer_state_1 = require("./use-buffer-state");
6
- const useMediaBuffering = (element, shouldBuffer) => {
6
+ const useMediaBuffering = ({ element, shouldBuffer, isPremounting, }) => {
7
7
  const buffer = (0, use_buffer_state_1.useBufferState)();
8
8
  (0, react_1.useEffect)(() => {
9
9
  let cleanup = () => undefined;
@@ -14,6 +14,9 @@ const useMediaBuffering = (element, shouldBuffer) => {
14
14
  if (!shouldBuffer) {
15
15
  return;
16
16
  }
17
+ if (isPremounting) {
18
+ return;
19
+ }
17
20
  const onWaiting = () => {
18
21
  const { unblock } = buffer.delayPlayback();
19
22
  const onCanPlay = () => {
@@ -37,6 +40,6 @@ const useMediaBuffering = (element, shouldBuffer) => {
37
40
  return () => {
38
41
  cleanup();
39
42
  };
40
- }, [buffer, element, shouldBuffer]);
43
+ }, [buffer, element, isPremounting, shouldBuffer]);
41
44
  };
42
45
  exports.useMediaBuffering = useMediaBuffering;
@@ -1,6 +1,6 @@
1
1
  import type { RefObject } from 'react';
2
2
  import type { VolumeProp } from './volume-prop.js';
3
- export declare const useMediaInTimeline: ({ volume, mediaVolume, mediaRef, src, mediaType, playbackRate, displayName, id, stack, showInTimeline, }: {
3
+ export declare const useMediaInTimeline: ({ volume, mediaVolume, mediaRef, src, mediaType, playbackRate, displayName, id, stack, showInTimeline, premountDisplay, }: {
4
4
  volume: VolumeProp | undefined;
5
5
  mediaVolume: number;
6
6
  mediaRef: RefObject<HTMLAudioElement | HTMLVideoElement>;
@@ -11,4 +11,5 @@ export declare const useMediaInTimeline: ({ volume, mediaVolume, mediaRef, src,
11
11
  id: string;
12
12
  stack: string | null;
13
13
  showInTimeline: boolean;
14
+ premountDisplay: number | null;
14
15
  }) => void;
@@ -21,7 +21,7 @@ const warnOnce = (message) => {
21
21
  console.warn(message);
22
22
  didWarn[message] = true;
23
23
  };
24
- const useMediaInTimeline = ({ volume, mediaVolume, mediaRef, src, mediaType, playbackRate, displayName, id, stack, showInTimeline, }) => {
24
+ const useMediaInTimeline = ({ volume, mediaVolume, mediaRef, src, mediaType, playbackRate, displayName, id, stack, showInTimeline, premountDisplay, }) => {
25
25
  const videoConfig = (0, use_video_config_js_1.useVideoConfig)();
26
26
  const { rootId, audioAndVideoTags } = (0, react_1.useContext)(timeline_position_state_js_1.TimelineContext);
27
27
  const parentSequence = (0, react_1.useContext)(SequenceContext_js_1.SequenceContext);
@@ -89,6 +89,7 @@ const useMediaInTimeline = ({ volume, mediaVolume, mediaRef, src, mediaType, pla
89
89
  loopDisplay: undefined,
90
90
  playbackRate,
91
91
  stack,
92
+ premountDisplay,
92
93
  });
93
94
  return () => {
94
95
  unregisterSequence(id);
@@ -113,6 +114,7 @@ const useMediaInTimeline = ({ volume, mediaVolume, mediaRef, src, mediaType, pla
113
114
  displayName,
114
115
  stack,
115
116
  showInTimeline,
117
+ premountDisplay,
116
118
  ]);
117
119
  (0, react_1.useEffect)(() => {
118
120
  const tag = {
@@ -1 +1 @@
1
- export declare const VERSION = "4.0.139";
1
+ export declare const VERSION = "4.0.140";
@@ -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.139';
5
+ exports.VERSION = '4.0.140';
@@ -13,6 +13,8 @@ export declare const Video: React.ForwardRefExoticComponent<Omit<Omit<React.Deta
13
13
  toneFrequency?: number | undefined;
14
14
  pauseWhenBuffering?: boolean | undefined;
15
15
  showInTimeline?: boolean | undefined;
16
+ delayRenderTimeoutInMilliseconds?: number | undefined;
17
+ delayRenderRetries?: number | undefined;
16
18
  } & RemotionMainVideoProps & {
17
19
  /**
18
20
  * @deprecated For internal use only
@@ -44,6 +44,7 @@ const VideoForDevelopmentRefForwardingFunction = (props, ref) => {
44
44
  id: timelineId,
45
45
  stack: _remotionInternalStack,
46
46
  showInTimeline,
47
+ premountDisplay: null,
47
48
  });
48
49
  (0, use_sync_volume_with_media_tag_js_1.useSyncVolumeWithMediaTag)({
49
50
  volumePropFrame,
@@ -60,7 +61,11 @@ const VideoForDevelopmentRefForwardingFunction = (props, ref) => {
60
61
  onlyWarnForMediaSeekingError,
61
62
  acceptableTimeshift: acceptableTimeShiftInSeconds !== null && acceptableTimeShiftInSeconds !== void 0 ? acceptableTimeShiftInSeconds : use_media_playback_js_1.DEFAULT_ACCEPTABLE_TIMESHIFT,
62
63
  });
63
- (0, use_media_buffering_js_1.useMediaBuffering)(videoRef, pauseWhenBuffering);
64
+ (0, use_media_buffering_js_1.useMediaBuffering)({
65
+ element: videoRef,
66
+ shouldBuffer: pauseWhenBuffering,
67
+ isPremounting: Boolean(parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.premounting),
68
+ });
64
69
  const actualFrom = parentSequence
65
70
  ? parentSequence.relativeFrom + parentSequence.cumulatedFrom
66
71
  : 0;