remotion 4.0.325 → 4.0.327

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.
@@ -15,6 +15,7 @@ export declare const Audio: React.ForwardRefExoticComponent<Omit<import("./props
15
15
  delayRenderTimeoutInMilliseconds?: number;
16
16
  delayRenderRetries?: number;
17
17
  loopVolumeCurveBehavior?: import("./use-audio-frame.js").LoopVolumeCurveBehavior;
18
+ onError?: (err: Error) => void;
18
19
  } & RemotionMainAudioProps & {
19
20
  /**
20
21
  * @deprecated For internal use only
@@ -22,7 +22,7 @@ const shared_audio_tags_js_1 = require("./shared-audio-tags.js");
22
22
  const AudioRefForwardingFunction = (props, ref) => {
23
23
  var _a, _b, _c;
24
24
  const audioContext = (0, react_1.useContext)(shared_audio_tags_js_1.SharedAudioContext);
25
- const { startFrom, endAt, trimBefore, trimAfter, name, stack, pauseWhenBuffering, showInTimeline, ...otherProps } = props;
25
+ const { startFrom, endAt, trimBefore, trimAfter, name, stack, pauseWhenBuffering, showInTimeline, onError: onRemotionError, ...otherProps } = props;
26
26
  const { loop, ...propsOtherThanLoop } = props;
27
27
  const { fps } = (0, use_video_config_js_1.useVideoConfig)();
28
28
  const environment = (0, get_remotion_environment_js_1.getRemotionEnvironment)();
@@ -38,13 +38,18 @@ const AudioRefForwardingFunction = (props, ref) => {
38
38
  // and this does not need to be a fatal error
39
39
  const errMessage = `Could not play audio with src ${preloadedSrc}: ${e.currentTarget.error}. See https://remotion.dev/docs/media-playback-error for help.`;
40
40
  if (loop) {
41
+ if (onRemotionError) {
42
+ onRemotionError(new Error(errMessage));
43
+ return;
44
+ }
41
45
  (0, cancel_render_js_1.cancelRender)(new Error(errMessage));
42
46
  }
43
47
  else {
48
+ onRemotionError === null || onRemotionError === void 0 ? void 0 : onRemotionError(new Error(errMessage));
44
49
  // eslint-disable-next-line no-console
45
50
  console.warn(errMessage);
46
51
  }
47
- }, [loop, preloadedSrc]);
52
+ }, [loop, onRemotionError, preloadedSrc]);
48
53
  const onDuration = (0, react_1.useCallback)((src, durationInSeconds) => {
49
54
  setDurations({ type: 'got-duration', durationInSeconds, src });
50
55
  }, [setDurations]);
@@ -74,9 +79,9 @@ const AudioRefForwardingFunction = (props, ref) => {
74
79
  }
75
80
  (0, validate_media_props_js_1.validateMediaProps)(props, 'Audio');
76
81
  if (environment.isRendering) {
77
- return ((0, jsx_runtime_1.jsx)(AudioForRendering_js_1.AudioForRendering, { onDuration: onDuration, ...props, ref: ref, onError: onError, _remotionInternalNeedsDurationCalculation: Boolean(loop) }));
82
+ return ((0, jsx_runtime_1.jsx)(AudioForRendering_js_1.AudioForRendering, { onDuration: onDuration, ...props, ref: ref, onNativeError: onError, _remotionInternalNeedsDurationCalculation: Boolean(loop) }));
78
83
  }
79
- return ((0, jsx_runtime_1.jsx)(AudioForPreview_js_1.AudioForPreview, { _remotionInternalNativeLoopPassed: (_c = props._remotionInternalNativeLoopPassed) !== null && _c !== void 0 ? _c : false, _remotionInternalStack: stack !== null && stack !== void 0 ? stack : null, shouldPreMountAudioTags: audioContext !== null && audioContext.numberOfAudioTags > 0, ...props, ref: ref, onError: onError, onDuration: onDuration,
84
+ return ((0, jsx_runtime_1.jsx)(AudioForPreview_js_1.AudioForPreview, { _remotionInternalNativeLoopPassed: (_c = props._remotionInternalNativeLoopPassed) !== null && _c !== void 0 ? _c : false, _remotionInternalStack: stack !== null && stack !== void 0 ? stack : null, shouldPreMountAudioTags: audioContext !== null && audioContext.numberOfAudioTags > 0, ...props, ref: ref, onNativeError: onError, onDuration: onDuration,
80
85
  // Proposal: Make this default to true in v5
81
86
  pauseWhenBuffering: pauseWhenBuffering !== null && pauseWhenBuffering !== void 0 ? pauseWhenBuffering : false, _remotionInternalNeedsDurationCalculation: Boolean(loop), showInTimeline: showInTimeline !== null && showInTimeline !== void 0 ? showInTimeline : true }));
82
87
  };
@@ -8,6 +8,7 @@ type AudioForPreviewProps = RemotionAudioProps & {
8
8
  readonly _remotionInternalStack: string | null;
9
9
  readonly showInTimeline: boolean;
10
10
  readonly stack?: string | undefined;
11
+ readonly onNativeError: React.ReactEventHandler<HTMLAudioElement>;
11
12
  };
12
13
  export declare const AudioForPreview: React.ForwardRefExoticComponent<Omit<AudioForPreviewProps, "ref"> & React.RefAttributes<HTMLAudioElement>>;
13
14
  export {};
@@ -23,7 +23,7 @@ const AudioForDevelopmentForwardRefFunction = (props, ref) => {
23
23
  throw new Error('Cannot change the behavior for pre-mounting audio tags dynamically.');
24
24
  }
25
25
  const logLevel = (0, log_level_context_js_1.useLogLevel)();
26
- const { volume, muted, playbackRate, shouldPreMountAudioTags, src, onDuration, acceptableTimeShiftInSeconds, _remotionInternalNeedsDurationCalculation, _remotionInternalNativeLoopPassed, _remotionInternalStack, allowAmplificationDuringRender, name, pauseWhenBuffering, showInTimeline, loopVolumeCurveBehavior, stack, crossOrigin, delayRenderRetries, delayRenderTimeoutInMilliseconds, toneFrequency, useWebAudioApi, ...nativeProps } = props;
26
+ const { volume, muted, playbackRate, shouldPreMountAudioTags, src, onDuration, acceptableTimeShiftInSeconds, _remotionInternalNeedsDurationCalculation, _remotionInternalNativeLoopPassed, _remotionInternalStack, allowAmplificationDuringRender, name, pauseWhenBuffering, showInTimeline, loopVolumeCurveBehavior, stack, crossOrigin, delayRenderRetries, delayRenderTimeoutInMilliseconds, toneFrequency, useWebAudioApi, onError, onNativeError, ...nativeProps } = props;
27
27
  // Typecheck that we are not accidentially passing unrecognized props
28
28
  // to the DOM
29
29
  const _propsValid = true;
@@ -1,7 +1,9 @@
1
1
  import type { ForwardRefExoticComponent, RefAttributes } from 'react';
2
+ import React from 'react';
2
3
  import type { RemotionAudioProps } from './props.js';
3
4
  type AudioForRenderingProps = RemotionAudioProps & {
4
5
  readonly onDuration: (src: string, durationInSeconds: number) => void;
6
+ readonly onNativeError: React.ReactEventHandler<HTMLAudioElement>;
5
7
  };
6
8
  export declare const AudioForRendering: ForwardRefExoticComponent<AudioForRenderingProps & RefAttributes<HTMLAudioElement>>;
7
9
  export {};
@@ -14,7 +14,7 @@ const volume_prop_js_1 = require("../volume-prop.js");
14
14
  const use_audio_frame_js_1 = require("./use-audio-frame.js");
15
15
  const AudioForRenderingRefForwardingFunction = (props, ref) => {
16
16
  const audioRef = (0, react_1.useRef)(null);
17
- const { volume: volumeProp, playbackRate, allowAmplificationDuringRender, onDuration, toneFrequency, _remotionInternalNeedsDurationCalculation, _remotionInternalNativeLoopPassed, acceptableTimeShiftInSeconds, name, onError, delayRenderRetries, delayRenderTimeoutInMilliseconds, loopVolumeCurveBehavior, pauseWhenBuffering, ...nativeProps } = props;
17
+ const { volume: volumeProp, playbackRate, allowAmplificationDuringRender, onDuration, toneFrequency, _remotionInternalNeedsDurationCalculation, _remotionInternalNativeLoopPassed, acceptableTimeShiftInSeconds, name, onNativeError, delayRenderRetries, delayRenderTimeoutInMilliseconds, loopVolumeCurveBehavior, pauseWhenBuffering, ...nativeProps } = props;
18
18
  const absoluteFrame = (0, timeline_position_state_js_1.useTimelinePosition)();
19
19
  const volumePropFrame = (0, use_audio_frame_js_1.useFrameForVolumeProp)(loopVolumeCurveBehavior !== null && loopVolumeCurveBehavior !== void 0 ? loopVolumeCurveBehavior : 'repeat');
20
20
  const frame = (0, use_current_frame_js_1.useCurrentFrame)();
@@ -126,6 +126,6 @@ const AudioForRenderingRefForwardingFunction = (props, ref) => {
126
126
  if (!needsToRenderAudioTag) {
127
127
  return null;
128
128
  }
129
- return (0, jsx_runtime_1.jsx)("audio", { ref: audioRef, ...nativeProps });
129
+ return (0, jsx_runtime_1.jsx)("audio", { ref: audioRef, ...nativeProps, onError: onNativeError });
130
130
  };
131
131
  exports.AudioForRendering = (0, react_1.forwardRef)(AudioForRenderingRefForwardingFunction);
@@ -18,7 +18,7 @@ export type RemotionMainAudioProps = {
18
18
  */
19
19
  trimAfter?: number;
20
20
  };
21
- export type NativeAudioProps = Omit<React.DetailedHTMLProps<React.AudioHTMLAttributes<HTMLAudioElement>, HTMLAudioElement>, 'autoPlay' | 'controls' | 'onEnded' | 'nonce' | 'onResize' | 'onResizeCapture'>;
21
+ export type NativeAudioProps = Omit<React.DetailedHTMLProps<React.AudioHTMLAttributes<HTMLAudioElement>, HTMLAudioElement>, 'autoPlay' | 'controls' | 'onEnded' | 'nonce' | 'onResize' | 'onResizeCapture' | 'onError'>;
22
22
  export type RemotionAudioProps = NativeAudioProps & {
23
23
  name?: string;
24
24
  volume?: VolumeProp;
@@ -37,6 +37,7 @@ export type RemotionAudioProps = NativeAudioProps & {
37
37
  delayRenderTimeoutInMilliseconds?: number;
38
38
  delayRenderRetries?: number;
39
39
  loopVolumeCurveBehavior?: LoopVolumeCurveBehavior;
40
+ onError?: (err: Error) => void;
40
41
  };
41
42
  type IsNever<T> = [T] extends [never] ? true : false;
42
43
  export type IsExact<T, U> = (<G>() => G extends T ? 1 : 2) extends <G>() => G extends U ? 1 : 2 ? IsNever<Exclude<keyof T, keyof U>> extends true ? IsNever<Exclude<keyof U, keyof T>> extends true ? true : false : false : false;
@@ -1,6 +1,5 @@
1
- import type { ComponentType, LazyExoticComponent } from 'react';
1
+ import type { AudioHTMLAttributes, ComponentType, LazyExoticComponent } from 'react';
2
2
  import React from 'react';
3
- import type { RemotionAudioProps } from './props.js';
4
3
  import type { SharedElementSourceNode } from './shared-element-source-node.js';
5
4
  /**
6
5
  * This functionality of Remotion will keep a certain amount
@@ -15,7 +14,7 @@ import type { SharedElementSourceNode } from './shared-element-source-node.js';
15
14
  */
16
15
  type AudioElem = {
17
16
  id: number;
18
- props: RemotionAudioProps;
17
+ props: AudioHTMLAttributes<HTMLAudioElement>;
19
18
  el: React.RefObject<HTMLAudioElement | null>;
20
19
  audioId: string;
21
20
  mediaElementSourceNode: SharedElementSourceNode | null;
@@ -23,14 +22,14 @@ type AudioElem = {
23
22
  };
24
23
  type SharedContext = {
25
24
  registerAudio: (options: {
26
- aud: RemotionAudioProps;
25
+ aud: AudioHTMLAttributes<HTMLAudioElement>;
27
26
  audioId: string;
28
27
  premounting: boolean;
29
28
  }) => AudioElem;
30
29
  unregisterAudio: (id: number) => void;
31
30
  updateAudio: (options: {
32
31
  id: number;
33
- aud: RemotionAudioProps;
32
+ aud: AudioHTMLAttributes<HTMLAudioElement>;
34
33
  audioId: string;
35
34
  premounting: boolean;
36
35
  }) => void;
@@ -46,7 +45,7 @@ export declare const SharedAudioContextProvider: React.FC<{
46
45
  readonly audioLatencyHint: AudioContextLatencyCategory;
47
46
  }>;
48
47
  export declare const useSharedAudio: ({ aud, audioId, premounting, }: {
49
- aud: RemotionAudioProps;
48
+ aud: AudioHTMLAttributes<HTMLAudioElement>;
50
49
  audioId: string;
51
50
  premounting: boolean;
52
51
  }) => AudioElem;
@@ -50,12 +50,12 @@ export declare const Internals: {
50
50
  readonly getRemotionEnvironment: () => RemotionEnvironment;
51
51
  readonly SharedAudioContext: import("react").Context<{
52
52
  registerAudio: (options: {
53
- aud: import("./index.js").RemotionAudioProps;
53
+ aud: import("react").AudioHTMLAttributes<HTMLAudioElement>;
54
54
  audioId: string;
55
55
  premounting: boolean;
56
56
  }) => {
57
57
  id: number;
58
- props: import("./index.js").RemotionAudioProps;
58
+ props: import("react").AudioHTMLAttributes<HTMLAudioElement>;
59
59
  el: React.RefObject<HTMLAudioElement | null>;
60
60
  audioId: string;
61
61
  mediaElementSourceNode: import("./audio/shared-element-source-node.js").SharedElementSourceNode | null;
@@ -64,7 +64,7 @@ export declare const Internals: {
64
64
  unregisterAudio: (id: number) => void;
65
65
  updateAudio: (options: {
66
66
  id: number;
67
- aud: import("./index.js").RemotionAudioProps;
67
+ aud: import("react").AudioHTMLAttributes<HTMLAudioElement>;
68
68
  audioId: string;
69
69
  premounting: boolean;
70
70
  }) => void;
@@ -46,7 +46,14 @@ const calculateScale = ({ canvasSize, compositionHeight, compositionWidth, previ
46
46
  const heightRatio = canvasSize.height / compositionHeight;
47
47
  const widthRatio = canvasSize.width / compositionWidth;
48
48
  const ratio = Math.min(heightRatio, widthRatio);
49
- return previewSize === 'auto' ? ratio : Number(previewSize);
49
+ if (previewSize === 'auto') {
50
+ // Container may be 0x0 because it doesn't have any content yet.
51
+ if (ratio === 0) {
52
+ return 1;
53
+ }
54
+ return ratio;
55
+ }
56
+ return Number(previewSize);
50
57
  };
51
58
  exports.calculateScale = calculateScale;
52
59
  /*
@@ -3,4 +3,4 @@
3
3
  * @see [Documentation](https://remotion.dev/docs/version)
4
4
  * @returns {string} The current version of the remotion package
5
5
  */
6
- export declare const VERSION = "4.0.325";
6
+ export declare const VERSION = "4.0.327";
@@ -7,4 +7,4 @@ exports.VERSION = void 0;
7
7
  * @see [Documentation](https://remotion.dev/docs/version)
8
8
  * @returns {string} The current version of the remotion package
9
9
  */
10
- exports.VERSION = '4.0.325';
10
+ exports.VERSION = '4.0.327';
@@ -104,7 +104,7 @@ function truthy(value) {
104
104
  }
105
105
 
106
106
  // src/version.ts
107
- var VERSION = "4.0.325";
107
+ var VERSION = "4.0.327";
108
108
 
109
109
  // src/multiple-versions-warning.ts
110
110
  var checkMultipleRemotionVersions = () => {
@@ -4363,6 +4363,8 @@ var AudioForDevelopmentForwardRefFunction = (props, ref) => {
4363
4363
  delayRenderTimeoutInMilliseconds,
4364
4364
  toneFrequency,
4365
4365
  useWebAudioApi,
4366
+ onError,
4367
+ onNativeError,
4366
4368
  ...nativeProps
4367
4369
  } = props;
4368
4370
  const _propsValid = true;
@@ -4514,7 +4516,7 @@ var AudioForRenderingRefForwardingFunction = (props, ref) => {
4514
4516
  _remotionInternalNativeLoopPassed,
4515
4517
  acceptableTimeShiftInSeconds,
4516
4518
  name,
4517
- onError,
4519
+ onNativeError,
4518
4520
  delayRenderRetries,
4519
4521
  delayRenderTimeoutInMilliseconds,
4520
4522
  loopVolumeCurveBehavior,
@@ -4622,7 +4624,8 @@ var AudioForRenderingRefForwardingFunction = (props, ref) => {
4622
4624
  }
4623
4625
  return /* @__PURE__ */ jsx18("audio", {
4624
4626
  ref: audioRef,
4625
- ...nativeProps
4627
+ ...nativeProps,
4628
+ onError: onNativeError
4626
4629
  });
4627
4630
  };
4628
4631
  var AudioForRendering = forwardRef5(AudioForRenderingRefForwardingFunction);
@@ -4640,6 +4643,7 @@ var AudioRefForwardingFunction = (props, ref) => {
4640
4643
  stack,
4641
4644
  pauseWhenBuffering,
4642
4645
  showInTimeline,
4646
+ onError: onRemotionError,
4643
4647
  ...otherProps
4644
4648
  } = props;
4645
4649
  const { loop, ...propsOtherThanLoop } = props;
@@ -4654,11 +4658,16 @@ var AudioRefForwardingFunction = (props, ref) => {
4654
4658
  console.log(e.currentTarget.error);
4655
4659
  const errMessage = `Could not play audio with src ${preloadedSrc}: ${e.currentTarget.error}. See https://remotion.dev/docs/media-playback-error for help.`;
4656
4660
  if (loop) {
4661
+ if (onRemotionError) {
4662
+ onRemotionError(new Error(errMessage));
4663
+ return;
4664
+ }
4657
4665
  cancelRender(new Error(errMessage));
4658
4666
  } else {
4667
+ onRemotionError?.(new Error(errMessage));
4659
4668
  console.warn(errMessage);
4660
4669
  }
4661
- }, [loop, preloadedSrc]);
4670
+ }, [loop, onRemotionError, preloadedSrc]);
4662
4671
  const onDuration = useCallback10((src, durationInSeconds) => {
4663
4672
  setDurations({ type: "got-duration", durationInSeconds, src });
4664
4673
  }, [setDurations]);
@@ -4715,7 +4724,7 @@ var AudioRefForwardingFunction = (props, ref) => {
4715
4724
  onDuration,
4716
4725
  ...props,
4717
4726
  ref,
4718
- onError,
4727
+ onNativeError: onError,
4719
4728
  _remotionInternalNeedsDurationCalculation: Boolean(loop)
4720
4729
  });
4721
4730
  }
@@ -4725,7 +4734,7 @@ var AudioRefForwardingFunction = (props, ref) => {
4725
4734
  shouldPreMountAudioTags: audioContext !== null && audioContext.numberOfAudioTags > 0,
4726
4735
  ...props,
4727
4736
  ref,
4728
- onError,
4737
+ onNativeError: onError,
4729
4738
  onDuration,
4730
4739
  pauseWhenBuffering: pauseWhenBuffering ?? false,
4731
4740
  _remotionInternalNeedsDurationCalculation: Boolean(loop),
@@ -5840,7 +5849,13 @@ var calculateScale = ({
5840
5849
  const heightRatio = canvasSize.height / compositionHeight;
5841
5850
  const widthRatio = canvasSize.width / compositionWidth;
5842
5851
  const ratio = Math.min(heightRatio, widthRatio);
5843
- return previewSize === "auto" ? ratio : Number(previewSize);
5852
+ if (previewSize === "auto") {
5853
+ if (ratio === 0) {
5854
+ return 1;
5855
+ }
5856
+ return ratio;
5857
+ }
5858
+ return Number(previewSize);
5844
5859
  };
5845
5860
  var useCurrentScale = (options) => {
5846
5861
  const hasContext = React25.useContext(CurrentScaleContext);
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var VERSION = "4.0.325";
2
+ var VERSION = "4.0.327";
3
3
  export {
4
4
  VERSION
5
5
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/core"
4
4
  },
5
5
  "name": "remotion",
6
- "version": "4.0.325",
6
+ "version": "4.0.327",
7
7
  "description": "Make videos programmatically",
8
8
  "main": "dist/cjs/index.js",
9
9
  "types": "dist/cjs/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "webpack": "5.96.1",
29
29
  "zod": "3.22.3",
30
30
  "eslint": "9.19.0",
31
- "@remotion/eslint-config-internal": "4.0.325"
31
+ "@remotion/eslint-config-internal": "4.0.327"
32
32
  },
33
33
  "keywords": [
34
34
  "remotion",