remotion 4.0.455 → 4.0.457

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 (58) hide show
  1. package/dist/cjs/HtmlInCanvas.d.ts +1 -1
  2. package/dist/cjs/HtmlInCanvas.js +8 -3
  3. package/dist/cjs/Img.js +1 -1
  4. package/dist/cjs/Sequence.d.ts +9 -1
  5. package/dist/cjs/Sequence.js +31 -3
  6. package/dist/cjs/audio/Audio.d.ts +34 -34
  7. package/dist/cjs/audio/Audio.js +6 -6
  8. package/dist/cjs/audio/html5-audio.d.ts +56 -0
  9. package/dist/cjs/audio/html5-audio.js +101 -0
  10. package/dist/cjs/audio/index.d.ts +1 -1
  11. package/dist/cjs/audio/index.js +3 -3
  12. package/dist/cjs/audio/shared-audio-tags.js +14 -4
  13. package/dist/cjs/canvas-effects/HtmlInCanvas.d.ts +12 -0
  14. package/dist/cjs/canvas-effects/HtmlInCanvas.js +188 -0
  15. package/dist/cjs/canvas-effects/Solid.d.ts +12 -0
  16. package/dist/cjs/canvas-effects/Solid.js +93 -0
  17. package/dist/cjs/canvas-effects/canvas-pool.d.ts +13 -0
  18. package/dist/cjs/canvas-effects/canvas-pool.js +85 -0
  19. package/dist/cjs/canvas-effects/define-effect.d.ts +3 -0
  20. package/dist/cjs/canvas-effects/define-effect.js +28 -0
  21. package/dist/cjs/canvas-effects/effect-internals.d.ts +7 -0
  22. package/dist/cjs/canvas-effects/effect-internals.js +42 -0
  23. package/dist/cjs/canvas-effects/effect-types.d.ts +31 -0
  24. package/dist/cjs/canvas-effects/effect-types.js +12 -0
  25. package/dist/cjs/canvas-effects/gpu-device.d.ts +2 -0
  26. package/dist/cjs/canvas-effects/gpu-device.js +36 -0
  27. package/dist/cjs/canvas-effects/index.d.ts +1 -0
  28. package/dist/cjs/canvas-effects/index.js +2 -0
  29. package/dist/cjs/canvas-effects/run-effect-chain.d.ts +23 -0
  30. package/dist/cjs/canvas-effects/run-effect-chain.js +119 -0
  31. package/dist/cjs/canvas-effects/use-effect-chain-state.d.ts +3 -0
  32. package/dist/cjs/canvas-effects/use-effect-chain-state.js +38 -0
  33. package/dist/cjs/canvas-effects/use-effect-chain.d.ts +13 -0
  34. package/dist/cjs/canvas-effects/use-effect-chain.js +200 -0
  35. package/dist/cjs/canvas-effects/use-memoized-effects.d.ts +2 -0
  36. package/dist/cjs/canvas-effects/use-memoized-effects.js +21 -0
  37. package/dist/cjs/enable-effects.d.ts +1 -0
  38. package/dist/cjs/enable-effects.js +4 -0
  39. package/dist/cjs/get-timeline-duration.d.ts +2 -1
  40. package/dist/cjs/get-timeline-duration.js +4 -1
  41. package/dist/cjs/internals.d.ts +8 -3
  42. package/dist/cjs/loop/index.d.ts +2 -2
  43. package/dist/cjs/loop/index.js +2 -2
  44. package/dist/cjs/use-media-in-timeline.d.ts +8 -2
  45. package/dist/cjs/use-media-in-timeline.js +41 -15
  46. package/dist/cjs/version.d.ts +1 -1
  47. package/dist/cjs/version.js +1 -1
  48. package/dist/cjs/video/Video.d.ts +32 -32
  49. package/dist/cjs/video/Video.js +7 -7
  50. package/dist/cjs/video/html5-video.d.ts +53 -0
  51. package/dist/cjs/video/html5-video.js +85 -0
  52. package/dist/cjs/video/index.d.ts +1 -1
  53. package/dist/cjs/video/index.js +3 -3
  54. package/dist/cjs/wrap-in-schema.d.ts +1 -1
  55. package/dist/cjs/wrap-in-schema.js +2 -2
  56. package/dist/esm/index.mjs +209 -129
  57. package/dist/esm/version.mjs +1 -1
  58. package/package.json +2 -2
@@ -55,5 +55,5 @@ export type HtmlInCanvasProps = Omit<SequenceProps, 'children' | 'durationInFram
55
55
  readonly onInit?: HtmlInCanvasOnInit;
56
56
  };
57
57
  export declare const HtmlInCanvas: React.ForwardRefExoticComponent<HtmlInCanvasProps & React.RefAttributes<HTMLCanvasElement>> & {
58
- readonly isHtmlInCanvasSupported: typeof isHtmlInCanvasSupported;
58
+ readonly isSupported: typeof isHtmlInCanvasSupported;
59
59
  };
@@ -53,6 +53,7 @@ const defaultOnPaint = ({ canvas, element, elementImage, }) => {
53
53
  element.style.transform = transform.toString();
54
54
  };
55
55
  /* eslint-enable react/require-default-props */
56
+ const HtmlInCanvasAncestorContext = (0, react_1.createContext)(false);
56
57
  const htmlInCanvasSchema = {
57
58
  'style.translate': {
58
59
  type: 'translate',
@@ -83,7 +84,8 @@ const htmlInCanvasSchema = {
83
84
  description: 'Opacity',
84
85
  },
85
86
  };
86
- const HtmlInCanvasInner = (0, react_1.forwardRef)(({ width, height, _experimentalEffects: experimentalEffects = [], children, onPaint, onInit, controls, style, durationInFrames, ...sequenceProps }, ref) => {
87
+ const HtmlInCanvasInner = (0, react_1.forwardRef)(({ width, height, _experimentalEffects: experimentalEffects = [], children, onPaint, onInit, _experimentalControls: controls, style, durationInFrames, ...sequenceProps }, ref) => {
88
+ const isInsideAncestorHtmlInCanvas = (0, react_1.useContext)(HtmlInCanvasAncestorContext);
87
89
  assertHtmlInCanvasDimensions(width, height);
88
90
  const { continueRender, cancelRender } = (0, use_delay_render_js_1.useDelayRender)();
89
91
  if (!(0, exports.isHtmlInCanvasSupported)()) {
@@ -246,12 +248,15 @@ const HtmlInCanvasInner = (0, react_1.forwardRef)(({ width, height, _experimenta
246
248
  ...style,
247
249
  };
248
250
  }, [width, height, style]);
249
- return ((0, jsx_runtime_1.jsx)(Sequence_js_1.Sequence, { durationInFrames: resolvedDuration, name: "<HtmlInCanvas>", controls: controls, layout: "none", ...sequenceProps, children: (0, jsx_runtime_1.jsx)("canvas", { ref: setLayoutCanvasRef, width: width, height: height, children: (0, jsx_runtime_1.jsx)("div", { ref: divRef, style: innerStyle, children: children }) }) }));
251
+ if (isInsideAncestorHtmlInCanvas) {
252
+ throw new Error('<HtmlInCanvas> effects cannot be nested together. Chrome will only display the outer effect. Consider merging the effects into one if you can.');
253
+ }
254
+ return ((0, jsx_runtime_1.jsx)(Sequence_js_1.Sequence, { durationInFrames: resolvedDuration, name: "<HtmlInCanvas>", _experimentalControls: controls, layout: "none", ...sequenceProps, children: (0, jsx_runtime_1.jsx)(HtmlInCanvasAncestorContext.Provider, { value: true, children: (0, jsx_runtime_1.jsx)("canvas", { ref: setLayoutCanvasRef, width: width, height: height, children: (0, jsx_runtime_1.jsx)("div", { ref: divRef, style: innerStyle, children: children }) }) }) }));
250
255
  });
251
256
  HtmlInCanvasInner.displayName = 'HtmlInCanvas';
252
257
  const HtmlInCanvasWrapped = (0, wrap_in_schema_js_1.wrapInSchema)(HtmlInCanvasInner, htmlInCanvasSchema);
253
258
  exports.HtmlInCanvas = Object.assign(HtmlInCanvasWrapped, {
254
- isHtmlInCanvasSupported: exports.isHtmlInCanvasSupported,
259
+ isSupported: exports.isHtmlInCanvasSupported,
255
260
  });
256
261
  exports.HtmlInCanvas.displayName = 'HtmlInCanvas';
257
262
  (0, enable_sequence_stack_traces_js_1.addSequenceStackTraces)(exports.HtmlInCanvas);
package/dist/cjs/Img.js CHANGED
@@ -54,7 +54,7 @@ const imgSchema = {
54
54
  description: 'Opacity',
55
55
  },
56
56
  };
57
- const ImgInner = ({ onError, maxRetries = 2, src, pauseWhenLoading, delayRenderRetries, delayRenderTimeoutInMilliseconds, onImageFrame, crossOrigin, showInTimeline, name, stack, ref, controls, ...props }) => {
57
+ const ImgInner = ({ onError, maxRetries = 2, src, pauseWhenLoading, delayRenderRetries, delayRenderTimeoutInMilliseconds, onImageFrame, crossOrigin, showInTimeline, name, stack, ref, _experimentalControls: controls, ...props }) => {
58
58
  var _a, _b;
59
59
  const imageRef = (0, react_1.useRef)(null);
60
60
  const errors = (0, react_1.useRef)({});
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { LoopDisplay, SequenceControls } from './CompositionManager.js';
3
3
  import type { EffectsProp } from './effects/effect-types.js';
4
+ import type { BasicMediaInTimelineReturnType } from './use-media-in-timeline.js';
4
5
  export type AbsoluteFillLayout = {
5
6
  layout?: 'absolute-fill';
6
7
  premountFor?: number;
@@ -20,7 +21,7 @@ export type SequencePropsWithoutDuration = {
20
21
  readonly from?: number;
21
22
  readonly name?: string;
22
23
  readonly showInTimeline?: boolean;
23
- readonly controls?: SequenceControls;
24
+ readonly _experimentalControls?: SequenceControls;
24
25
  readonly _experimentalEffects?: EffectsProp;
25
26
  /**
26
27
  * @deprecated For internal use only.
@@ -46,6 +47,13 @@ export type SequencePropsWithoutDuration = {
46
47
  * @deprecated For internal use only.
47
48
  */
48
49
  readonly _remotionInternalIsPostmounting?: boolean;
50
+ /**
51
+ * @deprecated For internal use only.
52
+ */
53
+ readonly _remotionInternalIsMedia?: {
54
+ type: 'video' | 'audio';
55
+ data: BasicMediaInTimelineReturnType;
56
+ };
49
57
  } & LayoutAndStyle;
50
58
  export type SequenceProps = {
51
59
  readonly durationInFrames?: number;
@@ -17,7 +17,7 @@ const use_current_frame_1 = require("./use-current-frame");
17
17
  const use_remotion_environment_js_1 = require("./use-remotion-environment.js");
18
18
  const use_video_config_js_1 = require("./use-video-config.js");
19
19
  const v5_flag_js_1 = require("./v5-flag.js");
20
- const RegularSequenceRefForwardingFunction = ({ from = 0, durationInFrames = Infinity, children, name, height, width, showInTimeline = true, controls, _experimentalEffects, _remotionInternalLoopDisplay: loopDisplay, _remotionInternalStack: stack, _remotionInternalPremountDisplay: premountDisplay, _remotionInternalPostmountDisplay: postmountDisplay, ...other }, ref) => {
20
+ const RegularSequenceRefForwardingFunction = ({ from = 0, durationInFrames = Infinity, children, name, height, width, showInTimeline = true, _experimentalControls: controls, _experimentalEffects, _remotionInternalLoopDisplay: loopDisplay, _remotionInternalStack: stack, _remotionInternalPremountDisplay: premountDisplay, _remotionInternalPostmountDisplay: postmountDisplay, _remotionInternalIsMedia: isMedia, ...other }, ref) => {
21
21
  var _a, _b;
22
22
  const { layout = 'absolute-fill' } = other;
23
23
  const [id] = (0, react_1.useState)(() => String(Math.random()));
@@ -99,16 +99,43 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, durationInFrames = Inf
99
99
  const inheritedStack = (_a = other === null || other === void 0 ? void 0 : other.stack) !== null && _a !== void 0 ? _a : null;
100
100
  const memoizedEffects = (0, use_memoized_effects_js_1.useMemoizedEffects)((0, effect_internals_js_1.flattenEffects)(_experimentalEffects !== null && _experimentalEffects !== void 0 ? _experimentalEffects : []));
101
101
  (0, react_1.useEffect)(() => {
102
- var _a;
102
+ var _a, _b;
103
103
  if (!env.isStudio) {
104
104
  return;
105
105
  }
106
+ if (isMedia) {
107
+ registerSequence({
108
+ type: isMedia.type,
109
+ controls: controls !== null && controls !== void 0 ? controls : null,
110
+ effects: memoizedEffects,
111
+ displayName: timelineClipName,
112
+ doesVolumeChange: isMedia.data.doesVolumeChange,
113
+ duration: actualDurationInFrames,
114
+ from,
115
+ id,
116
+ loopDisplay,
117
+ nonce: nonce.get(),
118
+ parent: (_a = parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.id) !== null && _a !== void 0 ? _a : null,
119
+ playbackRate: isMedia.data.playbackRate,
120
+ postmountDisplay: postmountDisplay !== null && postmountDisplay !== void 0 ? postmountDisplay : null,
121
+ premountDisplay: premountDisplay !== null && premountDisplay !== void 0 ? premountDisplay : null,
122
+ rootId,
123
+ showInTimeline,
124
+ src: isMedia.data.src,
125
+ stack: stack !== null && stack !== void 0 ? stack : inheritedStack,
126
+ startMediaFrom: isMedia.data.startMediaFrom,
127
+ volume: isMedia.data.volumes,
128
+ });
129
+ return () => {
130
+ unregisterSequence(id);
131
+ };
132
+ }
106
133
  registerSequence({
107
134
  from,
108
135
  duration: actualDurationInFrames,
109
136
  id,
110
137
  displayName: timelineClipName,
111
- parent: (_a = parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.id) !== null && _a !== void 0 ? _a : null,
138
+ parent: (_b = parentSequence === null || parentSequence === void 0 ? void 0 : parentSequence.id) !== null && _b !== void 0 ? _b : null,
112
139
  type: 'sequence',
113
140
  rootId,
114
141
  showInTimeline,
@@ -144,6 +171,7 @@ const RegularSequenceRefForwardingFunction = ({ from = 0, durationInFrames = Inf
144
171
  inheritedStack,
145
172
  controls,
146
173
  memoizedEffects,
174
+ isMedia,
147
175
  ]);
148
176
  // Ceil to support floats
149
177
  // https://github.com/remotion-dev/remotion/issues/2958
@@ -5,52 +5,52 @@ import type { RemotionMainAudioProps } from './props.js';
5
5
  * @see [Documentation](https://remotion.dev/docs/html5-audio)
6
6
  */
7
7
  export declare const Html5Audio: React.ForwardRefExoticComponent<Omit<import("./props.js").NativeAudioProps & {
8
- name?: string;
9
- volume?: import("../volume-prop.js").VolumeProp;
10
- playbackRate?: number;
11
- acceptableTimeShiftInSeconds?: number;
12
- allowAmplificationDuringRender?: boolean;
13
- _remotionInternalNeedsDurationCalculation?: boolean;
14
- _remotionInternalNativeLoopPassed?: boolean;
15
- toneFrequency?: number;
16
- useWebAudioApi?: boolean;
17
- pauseWhenBuffering?: boolean;
18
- showInTimeline?: boolean;
19
- delayRenderTimeoutInMilliseconds?: number;
20
- delayRenderRetries?: number;
21
- loopVolumeCurveBehavior?: import("./use-audio-frame.js").LoopVolumeCurveBehavior;
22
- onError?: (err: Error) => void;
23
- audioStreamIndex?: number;
8
+ name?: string | undefined;
9
+ volume?: import("../volume-prop.js").VolumeProp | undefined;
10
+ playbackRate?: number | undefined;
11
+ acceptableTimeShiftInSeconds?: number | undefined;
12
+ allowAmplificationDuringRender?: boolean | undefined;
13
+ _remotionInternalNeedsDurationCalculation?: boolean | undefined;
14
+ _remotionInternalNativeLoopPassed?: boolean | undefined;
15
+ toneFrequency?: number | undefined;
16
+ useWebAudioApi?: boolean | undefined;
17
+ pauseWhenBuffering?: boolean | undefined;
18
+ showInTimeline?: boolean | undefined;
19
+ delayRenderTimeoutInMilliseconds?: number | undefined;
20
+ delayRenderRetries?: number | undefined;
21
+ loopVolumeCurveBehavior?: import("./use-audio-frame.js").LoopVolumeCurveBehavior | undefined;
22
+ onError?: ((err: Error) => void) | undefined;
23
+ audioStreamIndex?: number | undefined;
24
24
  } & RemotionMainAudioProps & {
25
25
  /**
26
26
  * @deprecated For internal use only
27
27
  */
28
- readonly stack?: string;
28
+ readonly stack?: string | undefined;
29
29
  }, "ref"> & React.RefAttributes<HTMLAudioElement>>;
30
30
  /**
31
31
  * @deprecated This component has been renamed to `Html5Audio`.
32
32
  * @see [Documentation](https://remotion.dev/docs/mediabunny/new-video)
33
33
  */
34
34
  export declare const Audio: React.ForwardRefExoticComponent<Omit<import("./props.js").NativeAudioProps & {
35
- name?: string;
36
- volume?: import("../volume-prop.js").VolumeProp;
37
- playbackRate?: number;
38
- acceptableTimeShiftInSeconds?: number;
39
- allowAmplificationDuringRender?: boolean;
40
- _remotionInternalNeedsDurationCalculation?: boolean;
41
- _remotionInternalNativeLoopPassed?: boolean;
42
- toneFrequency?: number;
43
- useWebAudioApi?: boolean;
44
- pauseWhenBuffering?: boolean;
45
- showInTimeline?: boolean;
46
- delayRenderTimeoutInMilliseconds?: number;
47
- delayRenderRetries?: number;
48
- loopVolumeCurveBehavior?: import("./use-audio-frame.js").LoopVolumeCurveBehavior;
49
- onError?: (err: Error) => void;
50
- audioStreamIndex?: number;
35
+ name?: string | undefined;
36
+ volume?: import("../volume-prop.js").VolumeProp | undefined;
37
+ playbackRate?: number | undefined;
38
+ acceptableTimeShiftInSeconds?: number | undefined;
39
+ allowAmplificationDuringRender?: boolean | undefined;
40
+ _remotionInternalNeedsDurationCalculation?: boolean | undefined;
41
+ _remotionInternalNativeLoopPassed?: boolean | undefined;
42
+ toneFrequency?: number | undefined;
43
+ useWebAudioApi?: boolean | undefined;
44
+ pauseWhenBuffering?: boolean | undefined;
45
+ showInTimeline?: boolean | undefined;
46
+ delayRenderTimeoutInMilliseconds?: number | undefined;
47
+ delayRenderRetries?: number | undefined;
48
+ loopVolumeCurveBehavior?: import("./use-audio-frame.js").LoopVolumeCurveBehavior | undefined;
49
+ onError?: ((err: Error) => void) | undefined;
50
+ audioStreamIndex?: number | undefined;
51
51
  } & RemotionMainAudioProps & {
52
52
  /**
53
53
  * @deprecated For internal use only
54
54
  */
55
- readonly stack?: string;
55
+ readonly stack?: string | undefined;
56
56
  }, "ref"> & React.RefAttributes<HTMLAudioElement>>;
@@ -66,25 +66,25 @@ const AudioRefForwardingFunction = (props, ref) => {
66
66
  });
67
67
  if (loop && durationFetched !== undefined) {
68
68
  if (!Number.isFinite(durationFetched)) {
69
- return ((0, jsx_runtime_1.jsx)(exports.Html5Audio, { ...propsOtherThanLoop, ref: ref, _remotionInternalNativeLoopPassed: true }));
69
+ return (jsx_runtime_1.jsx(exports.Html5Audio, { ...propsOtherThanLoop, ref: ref, _remotionInternalNativeLoopPassed: true }));
70
70
  }
71
71
  const duration = durationFetched * fps;
72
- return ((0, jsx_runtime_1.jsx)(index_js_1.Loop, { layout: "none", durationInFrames: (0, calculate_media_duration_js_1.calculateMediaDuration)({
72
+ return (jsx_runtime_1.jsx(index_js_1.Loop, { layout: "none", durationInFrames: (0, calculate_media_duration_js_1.calculateMediaDuration)({
73
73
  trimAfter: trimAfterValue,
74
74
  mediaDurationInFrames: duration,
75
75
  playbackRate: (_b = props.playbackRate) !== null && _b !== void 0 ? _b : 1,
76
76
  trimBefore: trimBeforeValue,
77
- }), children: (0, jsx_runtime_1.jsx)(exports.Html5Audio, { ...propsOtherThanLoop, ref: ref, _remotionInternalNativeLoopPassed: true }) }));
77
+ }), children: jsx_runtime_1.jsx(exports.Html5Audio, { ...propsOtherThanLoop, ref: ref, _remotionInternalNativeLoopPassed: true }) }));
78
78
  }
79
79
  if (typeof trimBeforeValue !== 'undefined' ||
80
80
  typeof trimAfterValue !== 'undefined') {
81
- return ((0, jsx_runtime_1.jsx)(Sequence_js_1.Sequence, { layout: "none", from: 0 - (trimBeforeValue !== null && trimBeforeValue !== void 0 ? trimBeforeValue : 0), showInTimeline: false, durationInFrames: trimAfterValue, name: name, children: (0, jsx_runtime_1.jsx)(exports.Html5Audio, { _remotionInternalNeedsDurationCalculation: Boolean(loop), pauseWhenBuffering: pauseWhenBuffering !== null && pauseWhenBuffering !== void 0 ? pauseWhenBuffering : false, ...otherProps, ref: ref }) }));
81
+ return (jsx_runtime_1.jsx(Sequence_js_1.Sequence, { layout: "none", from: 0 - (trimBeforeValue !== null && trimBeforeValue !== void 0 ? trimBeforeValue : 0), showInTimeline: false, durationInFrames: trimAfterValue, name: name, children: jsx_runtime_1.jsx(exports.Html5Audio, { _remotionInternalNeedsDurationCalculation: Boolean(loop), pauseWhenBuffering: pauseWhenBuffering !== null && pauseWhenBuffering !== void 0 ? pauseWhenBuffering : false, ...otherProps, ref: ref }) }));
82
82
  }
83
83
  (0, validate_media_props_js_1.validateMediaProps)({ playbackRate: props.playbackRate, volume: props.volume }, 'Html5Audio');
84
84
  if (environment.isRendering) {
85
- return ((0, jsx_runtime_1.jsx)(AudioForRendering_js_1.AudioForRendering, { onDuration: onDuration, ...props, ref: ref, onNativeError: onError, _remotionInternalNeedsDurationCalculation: Boolean(loop) }));
85
+ return (jsx_runtime_1.jsx(AudioForRendering_js_1.AudioForRendering, { onDuration: onDuration, ...props, ref: ref, onNativeError: onError, _remotionInternalNeedsDurationCalculation: Boolean(loop) }));
86
86
  }
87
- 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: audioTagsContext !== null && audioTagsContext.numberOfAudioTags > 0, ...props, ref: ref, onNativeError: onError, onDuration: onDuration,
87
+ return (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: audioTagsContext !== null && audioTagsContext.numberOfAudioTags > 0, ...props, ref: ref, onNativeError: onError, onDuration: onDuration,
88
88
  // Proposal: Make this default to true in v5
89
89
  pauseWhenBuffering: pauseWhenBuffering !== null && pauseWhenBuffering !== void 0 ? pauseWhenBuffering : false, _remotionInternalNeedsDurationCalculation: Boolean(loop), showInTimeline: showInTimeline !== null && showInTimeline !== void 0 ? showInTimeline : true }));
90
90
  };
@@ -0,0 +1,56 @@
1
+ import React from 'react';
2
+ import type { RemotionMainAudioProps } from './props.js';
3
+ /**
4
+ * @description With this component, you can add audio to your video. All audio formats which are supported by Chromium are supported by the component.
5
+ * @see [Documentation](https://remotion.dev/docs/html5-audio)
6
+ */
7
+ export declare const Html5Audio: React.ForwardRefExoticComponent<Omit<import("./props.js").NativeAudioProps & {
8
+ name?: string;
9
+ volume?: import("../volume-prop.js").VolumeProp;
10
+ playbackRate?: number;
11
+ acceptableTimeShiftInSeconds?: number;
12
+ allowAmplificationDuringRender?: boolean;
13
+ _remotionInternalNeedsDurationCalculation?: boolean;
14
+ _remotionInternalNativeLoopPassed?: boolean;
15
+ toneFrequency?: number;
16
+ useWebAudioApi?: boolean;
17
+ pauseWhenBuffering?: boolean;
18
+ showInTimeline?: boolean;
19
+ delayRenderTimeoutInMilliseconds?: number;
20
+ delayRenderRetries?: number;
21
+ loopVolumeCurveBehavior?: import("./use-audio-frame.js").LoopVolumeCurveBehavior;
22
+ onError?: (err: Error) => void;
23
+ audioStreamIndex?: number;
24
+ } & RemotionMainAudioProps & {
25
+ /**
26
+ * @deprecated For internal use only
27
+ */
28
+ readonly stack?: string;
29
+ }, "ref"> & React.RefAttributes<HTMLAudioElement>>;
30
+ /**
31
+ * @deprecated This component has been renamed to `Html5Audio`.
32
+ * @see [Documentation](https://remotion.dev/docs/mediabunny/new-video)
33
+ */
34
+ export declare const Audio: React.ForwardRefExoticComponent<Omit<import("./props.js").NativeAudioProps & {
35
+ name?: string;
36
+ volume?: import("../volume-prop.js").VolumeProp;
37
+ playbackRate?: number;
38
+ acceptableTimeShiftInSeconds?: number;
39
+ allowAmplificationDuringRender?: boolean;
40
+ _remotionInternalNeedsDurationCalculation?: boolean;
41
+ _remotionInternalNativeLoopPassed?: boolean;
42
+ toneFrequency?: number;
43
+ useWebAudioApi?: boolean;
44
+ pauseWhenBuffering?: boolean;
45
+ showInTimeline?: boolean;
46
+ delayRenderTimeoutInMilliseconds?: number;
47
+ delayRenderRetries?: number;
48
+ loopVolumeCurveBehavior?: import("./use-audio-frame.js").LoopVolumeCurveBehavior;
49
+ onError?: (err: Error) => void;
50
+ audioStreamIndex?: number;
51
+ } & RemotionMainAudioProps & {
52
+ /**
53
+ * @deprecated For internal use only
54
+ */
55
+ readonly stack?: string;
56
+ }, "ref"> & React.RefAttributes<HTMLAudioElement>>;
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Audio = exports.Html5Audio = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ /* eslint-disable @typescript-eslint/no-use-before-define */
6
+ const react_1 = require("react");
7
+ const absolute_src_js_1 = require("../absolute-src.js");
8
+ const calculate_media_duration_js_1 = require("../calculate-media-duration.js");
9
+ const cancel_render_js_1 = require("../cancel-render.js");
10
+ const enable_sequence_stack_traces_js_1 = require("../enable-sequence-stack-traces.js");
11
+ const index_js_1 = require("../loop/index.js");
12
+ const prefetch_js_1 = require("../prefetch.js");
13
+ const Sequence_js_1 = require("../Sequence.js");
14
+ const use_remotion_environment_js_1 = require("../use-remotion-environment.js");
15
+ const use_video_config_js_1 = require("../use-video-config.js");
16
+ const validate_media_props_js_1 = require("../validate-media-props.js");
17
+ const validate_start_from_props_js_1 = require("../validate-start-from-props.js");
18
+ const duration_state_js_1 = require("../video/duration-state.js");
19
+ const AudioForPreview_js_1 = require("./AudioForPreview.js");
20
+ const AudioForRendering_js_1 = require("./AudioForRendering.js");
21
+ const shared_audio_tags_js_1 = require("./shared-audio-tags.js");
22
+ const AudioRefForwardingFunction = (props, ref) => {
23
+ var _a, _b, _c;
24
+ const audioTagsContext = (0, react_1.useContext)(shared_audio_tags_js_1.SharedAudioTagsContext);
25
+ const { startFrom, endAt, trimBefore, trimAfter, name, stack, pauseWhenBuffering, showInTimeline, onError: onRemotionError, ...otherProps } = props;
26
+ const { loop, ...propsOtherThanLoop } = props;
27
+ const { fps } = (0, use_video_config_js_1.useVideoConfig)();
28
+ const environment = (0, use_remotion_environment_js_1.useRemotionEnvironment)();
29
+ if (environment.isClientSideRendering) {
30
+ throw new Error('<Html5Audio> is not supported in @remotion/web-renderer. Use <Audio> from @remotion/media instead. See https://remotion.dev/docs/client-side-rendering/limitations');
31
+ }
32
+ const { durations, setDurations } = (0, react_1.useContext)(duration_state_js_1.DurationsContext);
33
+ if (typeof props.src !== 'string') {
34
+ throw new TypeError(`The \`<Html5Audio>\` tag requires a string for \`src\`, but got ${JSON.stringify(props.src)} instead.`);
35
+ }
36
+ const preloadedSrc = (0, prefetch_js_1.usePreload)(props.src);
37
+ const onError = (0, react_1.useCallback)((e) => {
38
+ // eslint-disable-next-line no-console
39
+ console.log(e.currentTarget.error);
40
+ // If there is no `loop` property, we don't need to get the duration
41
+ // and this does not need to be a fatal error
42
+ const errMessage = `Could not play audio with src ${preloadedSrc}: ${e.currentTarget.error}. See https://remotion.dev/docs/media-playback-error for help.`;
43
+ if (loop) {
44
+ if (onRemotionError) {
45
+ onRemotionError(new Error(errMessage));
46
+ return;
47
+ }
48
+ (0, cancel_render_js_1.cancelRender)(new Error(errMessage));
49
+ }
50
+ else {
51
+ onRemotionError === null || onRemotionError === void 0 ? void 0 : onRemotionError(new Error(errMessage));
52
+ // eslint-disable-next-line no-console
53
+ console.warn(errMessage);
54
+ }
55
+ }, [loop, onRemotionError, preloadedSrc]);
56
+ const onDuration = (0, react_1.useCallback)((src, durationInSeconds) => {
57
+ setDurations({ type: 'got-duration', durationInSeconds, src });
58
+ }, [setDurations]);
59
+ const durationFetched = (_a = durations[(0, absolute_src_js_1.getAbsoluteSrc)(preloadedSrc)]) !== null && _a !== void 0 ? _a : durations[(0, absolute_src_js_1.getAbsoluteSrc)(props.src)];
60
+ (0, validate_start_from_props_js_1.validateMediaTrimProps)({ startFrom, endAt, trimBefore, trimAfter });
61
+ const { trimBeforeValue, trimAfterValue } = (0, validate_start_from_props_js_1.resolveTrimProps)({
62
+ startFrom,
63
+ endAt,
64
+ trimBefore,
65
+ trimAfter,
66
+ });
67
+ if (loop && durationFetched !== undefined) {
68
+ if (!Number.isFinite(durationFetched)) {
69
+ return ((0, jsx_runtime_1.jsx)(exports.Html5Audio, { ...propsOtherThanLoop, ref: ref, _remotionInternalNativeLoopPassed: true }));
70
+ }
71
+ const duration = durationFetched * fps;
72
+ return ((0, jsx_runtime_1.jsx)(index_js_1.Loop, { layout: "none", durationInFrames: (0, calculate_media_duration_js_1.calculateMediaDuration)({
73
+ trimAfter: trimAfterValue,
74
+ mediaDurationInFrames: duration,
75
+ playbackRate: (_b = props.playbackRate) !== null && _b !== void 0 ? _b : 1,
76
+ trimBefore: trimBeforeValue,
77
+ }), children: (0, jsx_runtime_1.jsx)(exports.Html5Audio, { ...propsOtherThanLoop, ref: ref, _remotionInternalNativeLoopPassed: true }) }));
78
+ }
79
+ if (typeof trimBeforeValue !== 'undefined' ||
80
+ typeof trimAfterValue !== 'undefined') {
81
+ return ((0, jsx_runtime_1.jsx)(Sequence_js_1.Sequence, { layout: "none", from: 0 - (trimBeforeValue !== null && trimBeforeValue !== void 0 ? trimBeforeValue : 0), showInTimeline: false, durationInFrames: trimAfterValue, name: name, children: (0, jsx_runtime_1.jsx)(exports.Html5Audio, { _remotionInternalNeedsDurationCalculation: Boolean(loop), pauseWhenBuffering: pauseWhenBuffering !== null && pauseWhenBuffering !== void 0 ? pauseWhenBuffering : false, ...otherProps, ref: ref }) }));
82
+ }
83
+ (0, validate_media_props_js_1.validateMediaProps)({ playbackRate: props.playbackRate, volume: props.volume }, 'Html5Audio');
84
+ if (environment.isRendering) {
85
+ return ((0, jsx_runtime_1.jsx)(AudioForRendering_js_1.AudioForRendering, { onDuration: onDuration, ...props, ref: ref, onNativeError: onError, _remotionInternalNeedsDurationCalculation: Boolean(loop) }));
86
+ }
87
+ 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: audioTagsContext !== null && audioTagsContext.numberOfAudioTags > 0, ...props, ref: ref, onNativeError: onError, onDuration: onDuration,
88
+ // Proposal: Make this default to true in v5
89
+ pauseWhenBuffering: pauseWhenBuffering !== null && pauseWhenBuffering !== void 0 ? pauseWhenBuffering : false, _remotionInternalNeedsDurationCalculation: Boolean(loop), showInTimeline: showInTimeline !== null && showInTimeline !== void 0 ? showInTimeline : true }));
90
+ };
91
+ /**
92
+ * @description With this component, you can add audio to your video. All audio formats which are supported by Chromium are supported by the component.
93
+ * @see [Documentation](https://remotion.dev/docs/html5-audio)
94
+ */
95
+ exports.Html5Audio = (0, react_1.forwardRef)(AudioRefForwardingFunction);
96
+ (0, enable_sequence_stack_traces_js_1.addSequenceStackTraces)(exports.Html5Audio);
97
+ /**
98
+ * @deprecated This component has been renamed to `Html5Audio`.
99
+ * @see [Documentation](https://remotion.dev/docs/mediabunny/new-video)
100
+ */
101
+ exports.Audio = exports.Html5Audio;
@@ -1,2 +1,2 @@
1
- export { Audio, Html5Audio } from './Audio.js';
1
+ export { Audio, Html5Audio } from './html5-audio.js';
2
2
  export * from './props.js';
@@ -15,7 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.Html5Audio = exports.Audio = void 0;
18
- var Audio_js_1 = require("./Audio.js");
19
- Object.defineProperty(exports, "Audio", { enumerable: true, get: function () { return Audio_js_1.Audio; } });
20
- Object.defineProperty(exports, "Html5Audio", { enumerable: true, get: function () { return Audio_js_1.Html5Audio; } });
18
+ var html5_audio_js_1 = require("./html5-audio.js");
19
+ Object.defineProperty(exports, "Audio", { enumerable: true, get: function () { return html5_audio_js_1.Audio; } });
20
+ Object.defineProperty(exports, "Html5Audio", { enumerable: true, get: function () { return html5_audio_js_1.Html5Audio; } });
21
21
  __exportStar(require("./props.js"), exports);
@@ -169,17 +169,27 @@ const SharedAudioContextProvider = ({ children, audioLatencyHint, audioEnabled }
169
169
  return Promise.resolve();
170
170
  }
171
171
  audioContextIsPlayingEventually.current = true;
172
- isResuming.current = (0, wait_until_actually_resumed_js_1.waitUntilActuallyResumed)(ctxAndGain.audioContext, logLevel)
173
- .then(() => { })
174
- .finally(() => {
172
+ const resumePromise = ctxAndGain.audioContext.resume();
173
+ isResuming.current = new Promise((resolve) => {
174
+ (0, wait_until_actually_resumed_js_1.waitUntilActuallyResumed)(ctxAndGain.audioContext, logLevel).then(resolve);
175
+ resumePromise.catch((err) => {
176
+ log_js_1.Log.warn({ logLevel, tag: 'audio' }, 'AudioContext resume rejected, continuing without audio sync', err);
177
+ resolve();
178
+ });
179
+ }).finally(() => {
175
180
  isResuming.current = null;
176
181
  });
177
182
  ctxAndGain.gainNode.gain.cancelScheduledValues(ctxAndGain.audioContext.currentTime);
178
183
  (_a = ctxAndGain.gainNode) === null || _a === void 0 ? void 0 : _a.gain.setValueAtTime(0, ctxAndGain.audioContext.currentTime);
179
184
  (_b = ctxAndGain.gainNode) === null || _b === void 0 ? void 0 : _b.gain.linearRampToValueAtTime(1, ctxAndGain.audioContext.currentTime + 0.03);
180
- return ctxAndGain.audioContext.resume().then(() => {
185
+ return resumePromise
186
+ .then(() => {
181
187
  nodesToResume.current.forEach((r, node) => node.start(r.scheduledTime, r.offset, r.duration));
182
188
  nodesToResume.current.clear();
189
+ })
190
+ .catch(() => {
191
+ // Already logged above; swallow to avoid unhandled rejection
192
+ // since callers (e.g. use-playback.ts) do not await this.
183
193
  });
184
194
  }, [ctxAndGain, logLevel]);
185
195
  const getIsResumingAudioContext = (0, react_1.useCallback)(() => {
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import type { EffectsProp } from './effect-types.js';
3
+ export type HtmlInCanvasProps = {
4
+ readonly width: number;
5
+ readonly height: number;
6
+ readonly effects?: EffectsProp;
7
+ readonly children: React.ReactNode;
8
+ readonly className?: string;
9
+ readonly style?: React.CSSProperties;
10
+ readonly pixelRatio?: number;
11
+ };
12
+ export declare const HtmlInCanvas: React.ComponentType<HtmlInCanvasProps>;