remotion 4.0.129 → 4.0.131

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.
@@ -0,0 +1,17 @@
1
+ import type { ForwardRefExoticComponent, RefAttributes } from 'react';
2
+ import React from 'react';
3
+ export declare const AudioForDevelopment: ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.AudioHTMLAttributes<HTMLAudioElement>, HTMLAudioElement>, "nonce" | "onEnded" | "onResize" | "onResizeCapture" | "autoPlay" | "controls"> & {
4
+ name?: string | undefined;
5
+ volume?: import("../volume-prop.js").VolumeProp | undefined;
6
+ playbackRate?: number | undefined;
7
+ acceptableTimeShiftInSeconds?: number | undefined;
8
+ allowAmplificationDuringRender?: boolean | undefined;
9
+ _remotionInternalNeedsDurationCalculation?: boolean | undefined;
10
+ _remotionInternalNativeLoopPassed?: boolean | undefined;
11
+ toneFrequency?: number | undefined;
12
+ } & {
13
+ shouldPreMountAudioTags: boolean;
14
+ onDuration: (src: string, durationInSeconds: number) => void;
15
+ _remotionInternalNativeLoopPassed: boolean;
16
+ _remotionInternalStack: string | null;
17
+ } & RefAttributes<HTMLAudioElement>>;
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AudioForDevelopment = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const prefetch_js_1 = require("../prefetch.js");
7
+ const random_js_1 = require("../random.js");
8
+ const SequenceContext_js_1 = require("../SequenceContext.js");
9
+ const SequenceManager_js_1 = require("../SequenceManager.js");
10
+ const use_media_in_timeline_js_1 = require("../use-media-in-timeline.js");
11
+ const use_media_playback_js_1 = require("../use-media-playback.js");
12
+ const use_media_tag_volume_js_1 = require("../use-media-tag-volume.js");
13
+ const use_sync_volume_with_media_tag_js_1 = require("../use-sync-volume-with-media-tag.js");
14
+ const volume_position_state_js_1 = require("../volume-position-state.js");
15
+ const shared_audio_tags_js_1 = require("./shared-audio-tags.js");
16
+ const use_audio_frame_js_1 = require("./use-audio-frame.js");
17
+ const AudioForDevelopmentForwardRefFunction = (props, ref) => {
18
+ var _a;
19
+ const [initialShouldPreMountAudioElements] = (0, react_1.useState)(props.shouldPreMountAudioTags);
20
+ if (props.shouldPreMountAudioTags !== initialShouldPreMountAudioElements) {
21
+ throw new Error('Cannot change the behavior for pre-mounting audio tags dynamically.');
22
+ }
23
+ const [mediaVolume] = (0, volume_position_state_js_1.useMediaVolumeState)();
24
+ const [mediaMuted] = (0, volume_position_state_js_1.useMediaMutedState)();
25
+ const volumePropFrame = (0, use_audio_frame_js_1.useFrameForVolumeProp)();
26
+ const { volume, muted, playbackRate, shouldPreMountAudioTags, src, onDuration, acceptableTimeShiftInSeconds, _remotionInternalNeedsDurationCalculation, _remotionInternalNativeLoopPassed, _remotionInternalStack, allowAmplificationDuringRender, name, ...nativeProps } = props;
27
+ const { hidden } = (0, react_1.useContext)(SequenceManager_js_1.SequenceVisibilityToggleContext);
28
+ if (!src) {
29
+ throw new TypeError("No 'src' was passed to <Audio>.");
30
+ }
31
+ const preloadedSrc = (0, prefetch_js_1.usePreload)(src);
32
+ const sequenceContext = (0, react_1.useContext)(SequenceContext_js_1.SequenceContext);
33
+ const [timelineId] = (0, react_1.useState)(() => String(Math.random()));
34
+ const isSequenceHidden = (_a = hidden[timelineId]) !== null && _a !== void 0 ? _a : false;
35
+ const propsToPass = (0, react_1.useMemo)(() => {
36
+ return {
37
+ muted: muted || mediaMuted || isSequenceHidden,
38
+ src: preloadedSrc,
39
+ loop: _remotionInternalNativeLoopPassed,
40
+ ...nativeProps,
41
+ };
42
+ }, [
43
+ _remotionInternalNativeLoopPassed,
44
+ isSequenceHidden,
45
+ mediaMuted,
46
+ muted,
47
+ nativeProps,
48
+ preloadedSrc,
49
+ ]);
50
+ // Generate a string that's as unique as possible for this asset
51
+ // but at the same time deterministic. We use it to combat strict mode issues.
52
+ const id = (0, react_1.useMemo)(() => `audio-${(0, random_js_1.random)(src !== null && src !== void 0 ? src : '')}-${sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom}-${sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.cumulatedFrom}-${sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.durationInFrames}-muted:${props.muted}-loop:${props.loop}`, [
53
+ src,
54
+ sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.relativeFrom,
55
+ sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.cumulatedFrom,
56
+ sequenceContext === null || sequenceContext === void 0 ? void 0 : sequenceContext.durationInFrames,
57
+ props.muted,
58
+ props.loop,
59
+ ]);
60
+ const audioRef = (0, shared_audio_tags_js_1.useSharedAudio)(propsToPass, id).el;
61
+ const actualVolume = (0, use_media_tag_volume_js_1.useMediaTagVolume)(audioRef);
62
+ (0, use_sync_volume_with_media_tag_js_1.useSyncVolumeWithMediaTag)({
63
+ volumePropFrame,
64
+ actualVolume,
65
+ volume,
66
+ mediaVolume,
67
+ mediaRef: audioRef,
68
+ });
69
+ (0, use_media_in_timeline_js_1.useMediaInTimeline)({
70
+ volume,
71
+ mediaVolume,
72
+ mediaRef: audioRef,
73
+ src,
74
+ mediaType: 'audio',
75
+ playbackRate: playbackRate !== null && playbackRate !== void 0 ? playbackRate : 1,
76
+ displayName: name !== null && name !== void 0 ? name : null,
77
+ id: timelineId,
78
+ stack: props._remotionInternalStack,
79
+ });
80
+ (0, use_media_playback_js_1.useMediaPlayback)({
81
+ mediaRef: audioRef,
82
+ src,
83
+ mediaType: 'audio',
84
+ playbackRate: playbackRate !== null && playbackRate !== void 0 ? playbackRate : 1,
85
+ onlyWarnForMediaSeekingError: false,
86
+ acceptableTimeshift: acceptableTimeShiftInSeconds !== null && acceptableTimeShiftInSeconds !== void 0 ? acceptableTimeShiftInSeconds : use_media_playback_js_1.DEFAULT_ACCEPTABLE_TIMESHIFT,
87
+ });
88
+ (0, react_1.useImperativeHandle)(ref, () => {
89
+ return audioRef.current;
90
+ }, [audioRef]);
91
+ const currentOnDurationCallback = (0, react_1.useRef)();
92
+ currentOnDurationCallback.current = onDuration;
93
+ (0, react_1.useEffect)(() => {
94
+ var _a;
95
+ const { current } = audioRef;
96
+ if (!current) {
97
+ return;
98
+ }
99
+ if (current.duration) {
100
+ (_a = currentOnDurationCallback.current) === null || _a === void 0 ? void 0 : _a.call(currentOnDurationCallback, current.src, current.duration);
101
+ return;
102
+ }
103
+ const onLoadedMetadata = () => {
104
+ var _a;
105
+ (_a = currentOnDurationCallback.current) === null || _a === void 0 ? void 0 : _a.call(currentOnDurationCallback, current.src, current.duration);
106
+ };
107
+ current.addEventListener('loadedmetadata', onLoadedMetadata);
108
+ return () => {
109
+ current.removeEventListener('loadedmetadata', onLoadedMetadata);
110
+ };
111
+ }, [audioRef, src]);
112
+ if (initialShouldPreMountAudioElements) {
113
+ return null;
114
+ }
115
+ return (0, jsx_runtime_1.jsx)("audio", { ref: audioRef, preload: "metadata", ...propsToPass });
116
+ };
117
+ exports.AudioForDevelopment = (0, react_1.forwardRef)(AudioForDevelopmentForwardRefFunction);
@@ -0,0 +1 @@
1
+ export declare const getTimelineClipName: (children: React.ReactNode) => string;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTimelineClipName = void 0;
4
+ const react_1 = require("react");
5
+ const HIDDEN_NAMES = ['__WEBPACK_DEFAULT_EXPORT__'];
6
+ const getTimelineClipName = (children) => {
7
+ var _a;
8
+ const tree = (_a = react_1.Children.map(children, (ch) => {
9
+ if (!(0, react_1.isValidElement)(ch)) {
10
+ return null;
11
+ }
12
+ // Must be name, not ID
13
+ const name = typeof ch.type !== 'string' && ch.type.name;
14
+ if (name && !HIDDEN_NAMES.includes(name)) {
15
+ return name;
16
+ }
17
+ if (ch.props.children) {
18
+ const chName = (0, exports.getTimelineClipName)(ch.props.children);
19
+ return chName;
20
+ }
21
+ return null;
22
+ })) === null || _a === void 0 ? void 0 : _a.filter(Boolean);
23
+ return (tree === null || tree === void 0 ? void 0 : tree.length) ? tree[0] : '';
24
+ };
25
+ exports.getTimelineClipName = getTimelineClipName;
@@ -1 +1 @@
1
- export declare const VERSION = "4.0.129";
1
+ export declare const VERSION = "4.0.131";
@@ -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.129';
5
+ exports.VERSION = '4.0.131';
@@ -0,0 +1,15 @@
1
+ import type { ForwardRefExoticComponent, RefAttributes } from 'react';
2
+ import React from 'react';
3
+ export declare const VideoForDevelopment: ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>, "nonce" | "onEnded" | "autoPlay" | "controls"> & {
4
+ name?: string | undefined;
5
+ volume?: import("../volume-prop.js").VolumeProp | undefined;
6
+ playbackRate?: number | undefined;
7
+ acceptableTimeShiftInSeconds?: number | undefined;
8
+ allowAmplificationDuringRender?: boolean | undefined;
9
+ toneFrequency?: number | undefined;
10
+ } & {
11
+ onlyWarnForMediaSeekingError: boolean;
12
+ onDuration: (src: string, durationInSeconds: number) => void;
13
+ _remotionInternalNativeLoopPassed: boolean;
14
+ _remotionInternalStack: string | null;
15
+ } & RefAttributes<HTMLVideoElement>>;
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VideoForDevelopment = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const use_audio_frame_js_1 = require("../audio/use-audio-frame.js");
7
+ const prefetch_js_1 = require("../prefetch.js");
8
+ const SequenceContext_js_1 = require("../SequenceContext.js");
9
+ const SequenceManager_js_1 = require("../SequenceManager.js");
10
+ const use_media_in_timeline_js_1 = require("../use-media-in-timeline.js");
11
+ const use_media_playback_js_1 = require("../use-media-playback.js");
12
+ const use_media_tag_volume_js_1 = require("../use-media-tag-volume.js");
13
+ const use_sync_volume_with_media_tag_js_1 = require("../use-sync-volume-with-media-tag.js");
14
+ const use_video_config_js_1 = require("../use-video-config.js");
15
+ const volume_position_state_js_1 = require("../volume-position-state.js");
16
+ const video_fragment_js_1 = require("./video-fragment.js");
17
+ const VideoForDevelopmentRefForwardingFunction = (props, ref) => {
18
+ var _a, _b, _c;
19
+ const videoRef = (0, react_1.useRef)(null);
20
+ const volumePropFrame = (0, use_audio_frame_js_1.useFrameForVolumeProp)();
21
+ const { fps, durationInFrames } = (0, use_video_config_js_1.useVideoConfig)();
22
+ const parentSequence = (0, react_1.useContext)(SequenceContext_js_1.SequenceContext);
23
+ const { hidden } = (0, react_1.useContext)(SequenceManager_js_1.SequenceVisibilityToggleContext);
24
+ const [timelineId] = (0, react_1.useState)(() => String(Math.random()));
25
+ const isSequenceHidden = (_a = hidden[timelineId]) !== null && _a !== void 0 ? _a : false;
26
+ const { volume, muted, playbackRate, onlyWarnForMediaSeekingError, src, onDuration,
27
+ // @ts-expect-error
28
+ acceptableTimeShift, acceptableTimeShiftInSeconds, toneFrequency, name, _remotionInternalNativeLoopPassed, _remotionInternalStack, style, ...nativeProps } = props;
29
+ if (typeof acceptableTimeShift !== 'undefined') {
30
+ throw new Error('acceptableTimeShift has been removed. Use acceptableTimeShiftInSeconds instead.');
31
+ }
32
+ const actualVolume = (0, use_media_tag_volume_js_1.useMediaTagVolume)(videoRef);
33
+ const [mediaVolume] = (0, volume_position_state_js_1.useMediaVolumeState)();
34
+ const [mediaMuted] = (0, volume_position_state_js_1.useMediaMutedState)();
35
+ (0, use_media_in_timeline_js_1.useMediaInTimeline)({
36
+ mediaRef: videoRef,
37
+ volume,
38
+ mediaVolume,
39
+ mediaType: 'video',
40
+ src,
41
+ playbackRate: (_b = props.playbackRate) !== null && _b !== void 0 ? _b : 1,
42
+ displayName: name !== null && name !== void 0 ? name : null,
43
+ id: timelineId,
44
+ stack: props._remotionInternalStack,
45
+ });
46
+ (0, use_sync_volume_with_media_tag_js_1.useSyncVolumeWithMediaTag)({
47
+ volumePropFrame,
48
+ actualVolume,
49
+ volume,
50
+ mediaVolume,
51
+ mediaRef: videoRef,
52
+ });
53
+ (0, use_media_playback_js_1.useMediaPlayback)({
54
+ mediaRef: videoRef,
55
+ src,
56
+ mediaType: 'video',
57
+ playbackRate: (_c = props.playbackRate) !== null && _c !== void 0 ? _c : 1,
58
+ onlyWarnForMediaSeekingError,
59
+ acceptableTimeshift: acceptableTimeShiftInSeconds !== null && acceptableTimeShiftInSeconds !== void 0 ? acceptableTimeShiftInSeconds : use_media_playback_js_1.DEFAULT_ACCEPTABLE_TIMESHIFT,
60
+ });
61
+ const actualFrom = parentSequence
62
+ ? parentSequence.relativeFrom + parentSequence.cumulatedFrom
63
+ : 0;
64
+ const duration = parentSequence
65
+ ? Math.min(parentSequence.durationInFrames, durationInFrames)
66
+ : durationInFrames;
67
+ const actualSrc = (0, video_fragment_js_1.useAppendVideoFragment)({
68
+ actualSrc: (0, prefetch_js_1.usePreload)(src),
69
+ actualFrom,
70
+ duration,
71
+ fps,
72
+ });
73
+ (0, react_1.useImperativeHandle)(ref, () => {
74
+ return videoRef.current;
75
+ }, []);
76
+ (0, react_1.useEffect)(() => {
77
+ const { current } = videoRef;
78
+ if (!current) {
79
+ return;
80
+ }
81
+ const errorHandler = () => {
82
+ var _a;
83
+ if (current === null || current === void 0 ? void 0 : current.error) {
84
+ // eslint-disable-next-line no-console
85
+ console.error('Error occurred in video', current === null || current === void 0 ? void 0 : current.error);
86
+ // If user is handling the error, we don't cause an unhandled exception
87
+ if (props.onError) {
88
+ return;
89
+ }
90
+ throw new Error(`The browser threw an error while playing the video ${src}: Code ${current.error.code} - ${(_a = current === null || current === void 0 ? void 0 : current.error) === null || _a === void 0 ? void 0 : _a.message}. See https://remotion.dev/docs/media-playback-error for help. Pass an onError() prop to handle the error.`);
91
+ }
92
+ else {
93
+ throw new Error('The browser threw an error');
94
+ }
95
+ };
96
+ current.addEventListener('error', errorHandler, { once: true });
97
+ return () => {
98
+ current.removeEventListener('error', errorHandler);
99
+ };
100
+ }, [props.onError, src]);
101
+ const currentOnDurationCallback = (0, react_1.useRef)();
102
+ currentOnDurationCallback.current = onDuration;
103
+ (0, react_1.useEffect)(() => {
104
+ var _a;
105
+ const { current } = videoRef;
106
+ if (!current) {
107
+ return;
108
+ }
109
+ if (current.duration) {
110
+ (_a = currentOnDurationCallback.current) === null || _a === void 0 ? void 0 : _a.call(currentOnDurationCallback, src, current.duration);
111
+ return;
112
+ }
113
+ const onLoadedMetadata = () => {
114
+ var _a;
115
+ (_a = currentOnDurationCallback.current) === null || _a === void 0 ? void 0 : _a.call(currentOnDurationCallback, src, current.duration);
116
+ };
117
+ current.addEventListener('loadedmetadata', onLoadedMetadata);
118
+ return () => {
119
+ current.removeEventListener('loadedmetadata', onLoadedMetadata);
120
+ };
121
+ }, [src]);
122
+ (0, react_1.useEffect)(() => {
123
+ const { current } = videoRef;
124
+ if (!current) {
125
+ return;
126
+ }
127
+ // Without this, on iOS Safari, the video cannot be seeked.
128
+ // if a seek is triggered before `loadedmetadata` is fired,
129
+ // the video will not seek, even if `loadedmetadata` is fired afterwards.
130
+ // Also, this needs to happen in a useEffect, because otherwise
131
+ // the SSR props will be applied.
132
+ if ((0, video_fragment_js_1.isIosSafari)()) {
133
+ current.preload = 'metadata';
134
+ }
135
+ else {
136
+ current.preload = 'auto';
137
+ }
138
+ }, []);
139
+ const actualStyle = (0, react_1.useMemo)(() => {
140
+ var _a;
141
+ return {
142
+ ...style,
143
+ opacity: isSequenceHidden ? 0 : (_a = style === null || style === void 0 ? void 0 : style.opacity) !== null && _a !== void 0 ? _a : 1,
144
+ };
145
+ }, [isSequenceHidden, style]);
146
+ return ((0, jsx_runtime_1.jsx)("video", { ref: videoRef, muted: muted || mediaMuted, playsInline: true, src: actualSrc, loop: _remotionInternalNativeLoopPassed, style: actualStyle, ...nativeProps }));
147
+ };
148
+ // Copy types from forwardRef but not necessary to remove ref
149
+ exports.VideoForDevelopment = (0, react_1.forwardRef)(VideoForDevelopmentRefForwardingFunction);
@@ -105,7 +105,7 @@ function truthy(value) {
105
105
  }
106
106
 
107
107
  // Automatically generated on publish
108
- const VERSION = '4.0.129';
108
+ const VERSION = '4.0.131';
109
109
 
110
110
  const checkMultipleRemotionVersions = () => {
111
111
  if (typeof globalThis === 'undefined') {
@@ -1,4 +1,4 @@
1
1
  // Automatically generated on publish
2
- const VERSION = '4.0.129';
2
+ const VERSION = '4.0.131';
3
3
 
4
4
  export { VERSION };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remotion",
3
- "version": "4.0.129",
3
+ "version": "4.0.131",
4
4
  "description": "Render videos in React",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/cjs/index.d.ts",