@micromag/element-video 0.4.71 → 0.4.74
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.
- package/es/index.d.ts +33 -5
- package/es/index.js +556 -290
- package/package.json +10 -8
package/es/index.d.ts
CHANGED
|
@@ -1,8 +1,36 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { HTMLAttributes, ForwardedRef } from 'react';
|
|
3
|
+
import { VideoMedia, ImageMedia } from '@micromag/core';
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
interface VideoProps extends HTMLAttributes<HTMLVideoElement> {
|
|
6
|
+
media?: VideoMedia | null;
|
|
7
|
+
thumbnail?: ImageMedia | null;
|
|
8
|
+
width?: number | null;
|
|
9
|
+
height?: number | null;
|
|
10
|
+
ref?: ForwardedRef<HTMLVideoElement> | null;
|
|
11
|
+
mediaRef?: ForwardedRef<HTMLVideoElement> | null;
|
|
12
|
+
muted?: boolean;
|
|
13
|
+
autoPlay?: boolean;
|
|
14
|
+
paused?: boolean;
|
|
15
|
+
loop?: boolean;
|
|
16
|
+
playsInline?: boolean;
|
|
17
|
+
preload?: 'auto' | 'metadata' | 'none' | null;
|
|
18
|
+
disablePictureInPicture?: boolean;
|
|
19
|
+
shouldLoad?: boolean;
|
|
20
|
+
withoutCors?: boolean;
|
|
21
|
+
className?: string | null;
|
|
22
|
+
innerClassName?: string | null;
|
|
23
|
+
onReady?: ((...args: unknown[]) => void) | null;
|
|
24
|
+
onSeeked?: ((...args: unknown[]) => void) | null;
|
|
25
|
+
onProgressStep?: ((...args: unknown[]) => void) | null;
|
|
26
|
+
onDurationChange?: ((...args: unknown[]) => void) | null;
|
|
27
|
+
onVolumeChange?: ((...args: unknown[]) => void) | null;
|
|
28
|
+
onSuspended?: ((...args: unknown[]) => void) | null;
|
|
29
|
+
onPlayError?: ((...args: unknown[]) => void) | null;
|
|
30
|
+
focusable?: boolean;
|
|
31
|
+
withPoster?: boolean;
|
|
32
|
+
withLoading?: boolean;
|
|
33
|
+
}
|
|
34
|
+
declare function Video({ media, thumbnail, width, height, mediaRef, ref: externalRef, muted, autoPlay, paused, loop, playsInline, preload, shouldLoad, withoutCors, className, innerClassName, onReady, onPlay: customOnPlay, onPlaying: customOnPlaying, onPause, onEnded, onSeeked, onTimeUpdate, onProgressStep, onDurationChange: customOnDurationChange, onVolumeChange: customOnVolumeChange, onSuspend: customOnSuspend, onSuspended, onPlayError, focusable, withPoster, withLoading, disablePictureInPicture, }: VideoProps): react_jsx_runtime.JSX.Element;
|
|
7
35
|
|
|
8
|
-
export {
|
|
36
|
+
export { Video as default };
|
package/es/index.js
CHANGED
|
@@ -1,70 +1,57 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
3
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
4
|
-
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
1
|
+
import { c } from 'react/compiler-runtime';
|
|
5
2
|
import classNames from 'classnames';
|
|
6
|
-
import
|
|
7
|
-
import { useMemo, useState, useEffect, useRef, useCallback } from 'react';
|
|
3
|
+
import { useMemo, useState, useEffect, useRef } from 'react';
|
|
8
4
|
import { Spinner } from '@micromag/core/components';
|
|
9
|
-
import {
|
|
5
|
+
import { useMediaCurrentTime, useMediaDuration, useMediaReady, useProgressSteps } from '@micromag/core/hooks';
|
|
6
|
+
import { getMediaFilesAsArray, getVideoSupportedMimes, getMediaThumbnail, mergeRefs } from '@micromag/core/utils';
|
|
10
7
|
import { useSetting } from '@micromag/core/contexts';
|
|
11
|
-
import { getMediaFilesAsArray, getVideoSupportedMimes } from '@micromag/core/utils';
|
|
12
8
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
13
9
|
|
|
14
10
|
// Disabled webm for now
|
|
15
11
|
// const defaultPossibleMimes = ['video/mp4', 'video/webm', 'video/ogg', 'application/vnd.apple.mpegurl'];
|
|
16
12
|
|
|
17
|
-
function useSources() {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}, [possibleMimes, settingsPossibleMimes]);
|
|
35
|
-
var files = useMemo(function () {
|
|
36
|
-
return getMediaFilesAsArray(mediaFiles);
|
|
37
|
-
}, [mediaFiles]);
|
|
38
|
-
var _useState = useState(finalPossibleMimes),
|
|
39
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
40
|
-
supportedMimes = _useState2[0],
|
|
41
|
-
setSupportedMimes = _useState2[1];
|
|
42
|
-
useEffect(function () {
|
|
43
|
-
var newMimes = getVideoSupportedMimes(finalPossibleMimes);
|
|
13
|
+
function useSources(media = null, options = null) {
|
|
14
|
+
const {
|
|
15
|
+
possibleMimes = null
|
|
16
|
+
} = options || {};
|
|
17
|
+
const {
|
|
18
|
+
files: mediaFiles = null,
|
|
19
|
+
metadata = null
|
|
20
|
+
} = media || {};
|
|
21
|
+
const {
|
|
22
|
+
mime: mediaMime = null
|
|
23
|
+
} = metadata || {};
|
|
24
|
+
const settingsPossibleMimes = useSetting('supportedVideoMimes');
|
|
25
|
+
const finalPossibleMimes = useMemo(() => possibleMimes || settingsPossibleMimes || ['video/mp4'], [possibleMimes, settingsPossibleMimes]);
|
|
26
|
+
const files = useMemo(() => getMediaFilesAsArray(mediaFiles), [mediaFiles]);
|
|
27
|
+
const [supportedMimes, setSupportedMimes] = useState(finalPossibleMimes);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
let newMimes = getVideoSupportedMimes(finalPossibleMimes);
|
|
44
30
|
if (newMimes.length === 0) {
|
|
45
31
|
newMimes = ['video/mp4'];
|
|
46
32
|
}
|
|
47
33
|
setSupportedMimes(newMimes);
|
|
48
34
|
}, [finalPossibleMimes]);
|
|
49
|
-
|
|
35
|
+
const sources = useMemo(() => {
|
|
50
36
|
if (files.length === 0) {
|
|
51
37
|
return null;
|
|
52
38
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
mime =
|
|
39
|
+
const supportedFiles = files.filter(file => {
|
|
40
|
+
const fileHandle = file.handle || file.id;
|
|
41
|
+
const {
|
|
42
|
+
mime = `video/${fileHandle === 'h264' ? 'mp4' : fileHandle}`
|
|
43
|
+
} = file;
|
|
57
44
|
return supportedMimes.indexOf(mime) !== -1;
|
|
58
45
|
});
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return
|
|
46
|
+
const supportedFilesWithoutOriginal = supportedFiles.filter(file_0 => {
|
|
47
|
+
const fileHandle_0 = file_0.handle || file_0.id;
|
|
48
|
+
return fileHandle_0 !== 'original';
|
|
62
49
|
});
|
|
63
|
-
return (supportedFilesWithoutOriginal.length > 0 ? supportedFilesWithoutOriginal : supportedFiles).sort(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
50
|
+
return (supportedFilesWithoutOriginal.length > 0 ? supportedFilesWithoutOriginal : supportedFiles).sort(({
|
|
51
|
+
size: a = Infinity
|
|
52
|
+
}, {
|
|
53
|
+
size: b = Infinity
|
|
54
|
+
}) => {
|
|
68
55
|
if (a === b) {
|
|
69
56
|
return 0;
|
|
70
57
|
}
|
|
@@ -73,252 +60,476 @@ function useSources() {
|
|
|
73
60
|
}, [files, supportedMimes]);
|
|
74
61
|
|
|
75
62
|
// @NOTE: Media is an animated image and doesn't have source files in video formats
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
originalMime = _ref6$mime === void 0 ? mediaMime : _ref6$mime;
|
|
84
|
-
var originalFileIsImage = originalType === 'image' || originalMime !== null && originalMime.indexOf('image/') === 0;
|
|
63
|
+
const {
|
|
64
|
+
type: originalType = null,
|
|
65
|
+
mime: originalMime = mediaMime
|
|
66
|
+
} = files.find(({
|
|
67
|
+
handle
|
|
68
|
+
}) => handle === 'original') || {};
|
|
69
|
+
const originalFileIsImage = originalType === 'image' || originalMime !== null && originalMime.indexOf('image/') === 0;
|
|
85
70
|
return {
|
|
86
71
|
sources: sources !== null && sources.length > 0 ? sources : null,
|
|
87
|
-
files
|
|
72
|
+
files,
|
|
88
73
|
isImage: originalFileIsImage
|
|
89
74
|
};
|
|
90
75
|
}
|
|
91
76
|
|
|
92
77
|
var styles = {"container":"micromag-element-video-container","media":"micromag-element-video-media","spinner":"micromag-element-video-spinner","withSize":"micromag-element-video-withSize"};
|
|
93
78
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
autoPlay
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
79
|
+
function resetForcePlaying(element) {
|
|
80
|
+
if (element.dataset.forcePlaying === 'true') {
|
|
81
|
+
element.dataset.forcePlaying = 'false';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function Video(t0) {
|
|
85
|
+
const $ = c(113);
|
|
86
|
+
const {
|
|
87
|
+
media: t1,
|
|
88
|
+
thumbnail: t2,
|
|
89
|
+
width: t3,
|
|
90
|
+
height: t4,
|
|
91
|
+
mediaRef: t5,
|
|
92
|
+
ref: t6,
|
|
93
|
+
muted: t7,
|
|
94
|
+
autoPlay: t8,
|
|
95
|
+
paused: t9,
|
|
96
|
+
loop: t10,
|
|
97
|
+
playsInline: t11,
|
|
98
|
+
preload: t12,
|
|
99
|
+
shouldLoad: t13,
|
|
100
|
+
withoutCors: t14,
|
|
101
|
+
className: t15,
|
|
102
|
+
innerClassName: t16,
|
|
103
|
+
onReady: t17,
|
|
104
|
+
onPlay: t18,
|
|
105
|
+
onPlaying: t19,
|
|
106
|
+
onPause: t20,
|
|
107
|
+
onEnded: t21,
|
|
108
|
+
onSeeked: t22,
|
|
109
|
+
onTimeUpdate: t23,
|
|
110
|
+
onProgressStep: t24,
|
|
111
|
+
onDurationChange: t25,
|
|
112
|
+
onVolumeChange: t26,
|
|
113
|
+
onSuspend: t27,
|
|
114
|
+
onSuspended: t28,
|
|
115
|
+
onPlayError: t29,
|
|
116
|
+
focusable: t30,
|
|
117
|
+
withPoster: t31,
|
|
118
|
+
withLoading: t32,
|
|
119
|
+
disablePictureInPicture: t33
|
|
120
|
+
} = t0;
|
|
121
|
+
const media = t1 === undefined ? null : t1;
|
|
122
|
+
const thumbnail = t2 === undefined ? null : t2;
|
|
123
|
+
const width = t3 === undefined ? null : t3;
|
|
124
|
+
const height = t4 === undefined ? null : t4;
|
|
125
|
+
const mediaRef = t5 === undefined ? null : t5;
|
|
126
|
+
const externalRef = t6 === undefined ? null : t6;
|
|
127
|
+
const muted = t7 === undefined ? false : t7;
|
|
128
|
+
const autoPlay = t8 === undefined ? false : t8;
|
|
129
|
+
const paused = t9 === undefined ? false : t9;
|
|
130
|
+
const loop = t10 === undefined ? false : t10;
|
|
131
|
+
const playsInline = t11 === undefined ? true : t11;
|
|
132
|
+
const preload = t12 === undefined ? "auto" : t12;
|
|
133
|
+
const shouldLoad = t13 === undefined ? true : t13;
|
|
134
|
+
const withoutCors = t14 === undefined ? false : t14;
|
|
135
|
+
const className = t15 === undefined ? null : t15;
|
|
136
|
+
const innerClassName = t16 === undefined ? null : t16;
|
|
137
|
+
const onReady = t17 === undefined ? null : t17;
|
|
138
|
+
const customOnPlay = t18 === undefined ? null : t18;
|
|
139
|
+
const customOnPlaying = t19 === undefined ? null : t19;
|
|
140
|
+
const onPause = t20 === undefined ? null : t20;
|
|
141
|
+
const onEnded = t21 === undefined ? null : t21;
|
|
142
|
+
const onSeeked = t22 === undefined ? null : t22;
|
|
143
|
+
const onTimeUpdate = t23 === undefined ? null : t23;
|
|
144
|
+
const onProgressStep = t24 === undefined ? null : t24;
|
|
145
|
+
const customOnDurationChange = t25 === undefined ? null : t25;
|
|
146
|
+
const customOnVolumeChange = t26 === undefined ? null : t26;
|
|
147
|
+
const customOnSuspend = t27 === undefined ? null : t27;
|
|
148
|
+
const onSuspended = t28 === undefined ? null : t28;
|
|
149
|
+
const onPlayError = t29 === undefined ? null : t29;
|
|
150
|
+
const focusable = t30 === undefined ? true : t30;
|
|
151
|
+
const withPoster = t31 === undefined ? false : t31;
|
|
152
|
+
const withLoading = t32 === undefined ? false : t32;
|
|
153
|
+
const disablePictureInPicture = t33 === undefined ? true : t33;
|
|
154
|
+
let t34;
|
|
155
|
+
if ($[0] !== media) {
|
|
156
|
+
t34 = media || {};
|
|
157
|
+
$[0] = media;
|
|
158
|
+
$[1] = t34;
|
|
159
|
+
} else {
|
|
160
|
+
t34 = $[1];
|
|
161
|
+
}
|
|
162
|
+
const {
|
|
163
|
+
url: t35,
|
|
164
|
+
metadata: t36
|
|
165
|
+
} = t34;
|
|
166
|
+
const mediaUrl = t35 === undefined ? null : t35;
|
|
167
|
+
const metadata = t36 === undefined ? null : t36;
|
|
168
|
+
let t37;
|
|
169
|
+
if ($[2] !== metadata) {
|
|
170
|
+
t37 = metadata || {};
|
|
171
|
+
$[2] = metadata;
|
|
172
|
+
$[3] = t37;
|
|
173
|
+
} else {
|
|
174
|
+
t37 = $[3];
|
|
175
|
+
}
|
|
176
|
+
const {
|
|
177
|
+
description: t38,
|
|
178
|
+
has_audio: t39
|
|
179
|
+
} = t37;
|
|
180
|
+
const description = t38 === undefined ? null : t38;
|
|
181
|
+
const hasAudio = t39 === undefined ? null : t39;
|
|
182
|
+
let t40;
|
|
183
|
+
if ($[4] !== media || $[5] !== thumbnail) {
|
|
184
|
+
t40 = getMediaThumbnail(media, thumbnail);
|
|
185
|
+
$[4] = media;
|
|
186
|
+
$[5] = thumbnail;
|
|
187
|
+
$[6] = t40;
|
|
188
|
+
} else {
|
|
189
|
+
t40 = $[6];
|
|
190
|
+
}
|
|
191
|
+
const finalThumbnail = t40;
|
|
192
|
+
const {
|
|
193
|
+
sources,
|
|
194
|
+
isImage
|
|
195
|
+
} = useSources(media);
|
|
196
|
+
const isImageWithoutSourceFile = isImage && (sources === null || sources.length === 0);
|
|
197
|
+
const ref = useRef(null);
|
|
198
|
+
const [mediaElement, setMediaElement] = useState(null);
|
|
199
|
+
const t41 = paused || onProgressStep === null;
|
|
200
|
+
let t42;
|
|
201
|
+
if ($[7] !== mediaUrl || $[8] !== t41) {
|
|
202
|
+
t42 = {
|
|
203
|
+
id: mediaUrl,
|
|
204
|
+
disabled: t41
|
|
205
|
+
};
|
|
206
|
+
$[7] = mediaUrl;
|
|
207
|
+
$[8] = t41;
|
|
208
|
+
$[9] = t42;
|
|
209
|
+
} else {
|
|
210
|
+
t42 = $[9];
|
|
211
|
+
}
|
|
212
|
+
const currentTime = useMediaCurrentTime(mediaElement, t42);
|
|
213
|
+
let t43;
|
|
214
|
+
if ($[10] !== mediaUrl) {
|
|
215
|
+
t43 = {
|
|
216
|
+
id: mediaUrl
|
|
217
|
+
};
|
|
218
|
+
$[10] = mediaUrl;
|
|
219
|
+
$[11] = t43;
|
|
220
|
+
} else {
|
|
221
|
+
t43 = $[11];
|
|
222
|
+
}
|
|
223
|
+
const duration = useMediaDuration(mediaElement, t43);
|
|
224
|
+
const [showLoading, setShowLoading] = useState(false);
|
|
225
|
+
let t44;
|
|
226
|
+
if ($[12] !== mediaUrl) {
|
|
227
|
+
t44 = {
|
|
228
|
+
id: mediaUrl
|
|
229
|
+
};
|
|
230
|
+
$[12] = mediaUrl;
|
|
231
|
+
$[13] = t44;
|
|
232
|
+
} else {
|
|
233
|
+
t44 = $[13];
|
|
234
|
+
}
|
|
235
|
+
const ready = useMediaReady(mediaElement, t44);
|
|
236
|
+
let t45;
|
|
237
|
+
if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
|
|
238
|
+
t45 = () => {
|
|
239
|
+
const {
|
|
240
|
+
current: t46
|
|
241
|
+
} = ref;
|
|
242
|
+
const element = t46 === undefined ? null : t46;
|
|
243
|
+
setMediaElement(element);
|
|
244
|
+
};
|
|
245
|
+
$[14] = t45;
|
|
246
|
+
} else {
|
|
247
|
+
t45 = $[14];
|
|
248
|
+
}
|
|
249
|
+
let t46;
|
|
250
|
+
if ($[15] !== isImageWithoutSourceFile || $[16] !== mediaUrl) {
|
|
251
|
+
t46 = [isImageWithoutSourceFile, mediaUrl, ref];
|
|
252
|
+
$[15] = isImageWithoutSourceFile;
|
|
253
|
+
$[16] = mediaUrl;
|
|
254
|
+
$[17] = t46;
|
|
255
|
+
} else {
|
|
256
|
+
t46 = $[17];
|
|
257
|
+
}
|
|
258
|
+
useEffect(t45, t46);
|
|
259
|
+
let t47;
|
|
260
|
+
let t48;
|
|
261
|
+
if ($[18] !== mediaUrl || $[19] !== withLoading) {
|
|
262
|
+
t47 = () => {
|
|
263
|
+
if (mediaUrl === null || !withLoading) {
|
|
264
|
+
return _temp;
|
|
265
|
+
}
|
|
266
|
+
setShowLoading(false);
|
|
267
|
+
const id = setTimeout(() => {
|
|
195
268
|
setShowLoading(true);
|
|
196
269
|
}, 2000);
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
270
|
+
return () => {
|
|
271
|
+
clearTimeout(id);
|
|
272
|
+
};
|
|
200
273
|
};
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
// Manage suspend
|
|
220
|
-
var _useState3 = useState(false),
|
|
221
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
222
|
-
isSuspended = _useState4[0],
|
|
223
|
-
setIsSuspended = _useState4[1];
|
|
224
|
-
var onPlay = useCallback(function (e) {
|
|
225
|
-
if (isSuspended) {
|
|
226
|
-
setIsSuspended(false);
|
|
227
|
-
}
|
|
228
|
-
if (customOnPlay !== null) {
|
|
229
|
-
customOnPlay(e);
|
|
230
|
-
}
|
|
231
|
-
}, [isSuspended, setIsSuspended, customOnPlay]);
|
|
232
|
-
var onPlaying = useCallback(function () {
|
|
233
|
-
if (isSuspended) {
|
|
234
|
-
setIsSuspended(false);
|
|
235
|
-
}
|
|
236
|
-
}, [isSuspended, setIsSuspended]);
|
|
237
|
-
var onSuspend = useCallback(function (e) {
|
|
238
|
-
if (e.currentTarget.paused && !paused && !isSuspended) {
|
|
239
|
-
setIsSuspended(true);
|
|
240
|
-
if (onSuspended !== null) {
|
|
241
|
-
onSuspended();
|
|
274
|
+
t48 = [mediaUrl, withLoading];
|
|
275
|
+
$[18] = mediaUrl;
|
|
276
|
+
$[19] = withLoading;
|
|
277
|
+
$[20] = t47;
|
|
278
|
+
$[21] = t48;
|
|
279
|
+
} else {
|
|
280
|
+
t47 = $[20];
|
|
281
|
+
t48 = $[21];
|
|
282
|
+
}
|
|
283
|
+
useEffect(t47, t48);
|
|
284
|
+
const withSize = width !== null && height !== null;
|
|
285
|
+
let t49;
|
|
286
|
+
let t50;
|
|
287
|
+
if ($[22] !== customOnDurationChange || $[23] !== duration) {
|
|
288
|
+
t49 = () => {
|
|
289
|
+
if (duration > 0 && customOnDurationChange !== null) {
|
|
290
|
+
customOnDurationChange(duration);
|
|
242
291
|
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
292
|
+
};
|
|
293
|
+
t50 = [duration, customOnDurationChange];
|
|
294
|
+
$[22] = customOnDurationChange;
|
|
295
|
+
$[23] = duration;
|
|
296
|
+
$[24] = t49;
|
|
297
|
+
$[25] = t50;
|
|
298
|
+
} else {
|
|
299
|
+
t49 = $[24];
|
|
300
|
+
t50 = $[25];
|
|
301
|
+
}
|
|
302
|
+
useEffect(t49, t50);
|
|
303
|
+
let t51;
|
|
304
|
+
if ($[26] !== customOnVolumeChange) {
|
|
305
|
+
t51 = e => {
|
|
306
|
+
if (customOnVolumeChange !== null) {
|
|
307
|
+
customOnVolumeChange(e.currentTarget.volume);
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
$[26] = customOnVolumeChange;
|
|
311
|
+
$[27] = t51;
|
|
312
|
+
} else {
|
|
313
|
+
t51 = $[27];
|
|
314
|
+
}
|
|
315
|
+
const onVolumeChange = t51;
|
|
316
|
+
const [isSuspended, setIsSuspended] = useState(false);
|
|
317
|
+
let t52;
|
|
318
|
+
if ($[28] !== customOnPlay || $[29] !== isSuspended) {
|
|
319
|
+
t52 = e_0 => {
|
|
320
|
+
if (isSuspended) {
|
|
321
|
+
setIsSuspended(false);
|
|
322
|
+
}
|
|
323
|
+
if (customOnPlay !== null) {
|
|
324
|
+
customOnPlay(e_0);
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
$[28] = customOnPlay;
|
|
328
|
+
$[29] = isSuspended;
|
|
329
|
+
$[30] = t52;
|
|
330
|
+
} else {
|
|
331
|
+
t52 = $[30];
|
|
332
|
+
}
|
|
333
|
+
const onPlay = t52;
|
|
334
|
+
let t53;
|
|
335
|
+
if ($[31] !== customOnPlaying || $[32] !== isSuspended) {
|
|
336
|
+
t53 = e_1 => {
|
|
337
|
+
if (isSuspended) {
|
|
338
|
+
setIsSuspended(false);
|
|
339
|
+
}
|
|
340
|
+
if (customOnPlaying !== null) {
|
|
341
|
+
customOnPlaying(e_1);
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
$[31] = customOnPlaying;
|
|
345
|
+
$[32] = isSuspended;
|
|
346
|
+
$[33] = t53;
|
|
347
|
+
} else {
|
|
348
|
+
t53 = $[33];
|
|
349
|
+
}
|
|
350
|
+
const onPlaying = t53;
|
|
351
|
+
let t54;
|
|
352
|
+
if ($[34] !== customOnSuspend || $[35] !== isSuspended || $[36] !== onSuspended || $[37] !== paused) {
|
|
353
|
+
t54 = e_2 => {
|
|
354
|
+
if (e_2.currentTarget.paused && !paused && !isSuspended) {
|
|
355
|
+
setIsSuspended(true);
|
|
356
|
+
if (onSuspended !== null) {
|
|
357
|
+
onSuspended();
|
|
281
358
|
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
359
|
+
}
|
|
360
|
+
if (customOnSuspend !== null) {
|
|
361
|
+
customOnSuspend(e_2);
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
$[34] = customOnSuspend;
|
|
365
|
+
$[35] = isSuspended;
|
|
366
|
+
$[36] = onSuspended;
|
|
367
|
+
$[37] = paused;
|
|
368
|
+
$[38] = t54;
|
|
369
|
+
} else {
|
|
370
|
+
t54 = $[38];
|
|
371
|
+
}
|
|
372
|
+
const onSuspend = t54;
|
|
373
|
+
let t55;
|
|
374
|
+
let t56;
|
|
375
|
+
if ($[39] !== onReady || $[40] !== ready) {
|
|
376
|
+
t55 = () => {
|
|
377
|
+
if (ready && onReady !== null) {
|
|
378
|
+
onReady();
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
t56 = [ready, onReady];
|
|
382
|
+
$[39] = onReady;
|
|
383
|
+
$[40] = ready;
|
|
384
|
+
$[41] = t55;
|
|
385
|
+
$[42] = t56;
|
|
386
|
+
} else {
|
|
387
|
+
t55 = $[41];
|
|
388
|
+
t56 = $[42];
|
|
389
|
+
}
|
|
390
|
+
useEffect(t55, t56);
|
|
391
|
+
const finalPreload = shouldLoad ? preload : "none";
|
|
392
|
+
const [wasPreloaded, setWasPreloaded] = useState(finalPreload === "auto" || finalPreload === "metadata");
|
|
393
|
+
let t57;
|
|
394
|
+
let t58;
|
|
395
|
+
if ($[43] !== shouldLoad || $[44] !== wasPreloaded) {
|
|
396
|
+
t57 = () => {
|
|
397
|
+
const {
|
|
398
|
+
current: t59
|
|
399
|
+
} = ref;
|
|
400
|
+
const element_0 = t59 === undefined ? null : t59;
|
|
401
|
+
if (shouldLoad && !wasPreloaded && element_0 !== null) {
|
|
402
|
+
try {
|
|
403
|
+
element_0.load();
|
|
404
|
+
} catch {}
|
|
405
|
+
setWasPreloaded(true);
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
t58 = [shouldLoad, wasPreloaded];
|
|
409
|
+
$[43] = shouldLoad;
|
|
410
|
+
$[44] = wasPreloaded;
|
|
411
|
+
$[45] = t57;
|
|
412
|
+
$[46] = t58;
|
|
413
|
+
} else {
|
|
414
|
+
t57 = $[45];
|
|
415
|
+
t58 = $[46];
|
|
416
|
+
}
|
|
417
|
+
useEffect(t57, t58);
|
|
418
|
+
let t59;
|
|
419
|
+
if ($[47] !== mediaUrl || $[48] !== onPlayError || $[49] !== paused) {
|
|
420
|
+
t59 = () => {
|
|
421
|
+
const {
|
|
422
|
+
current: t60
|
|
423
|
+
} = ref;
|
|
424
|
+
const element_1 = t60 === undefined ? null : t60;
|
|
425
|
+
if (element_1 === null || mediaUrl === null) {
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
const isPaused = element_1?.paused || false;
|
|
429
|
+
if (paused && !isPaused) {
|
|
430
|
+
element_1.pause();
|
|
431
|
+
} else {
|
|
432
|
+
if (!paused && isPaused && element_1.dataset.forcePlaying !== "true") {
|
|
433
|
+
element_1.play().catch(e_3 => {
|
|
434
|
+
if (onPlayError !== null) {
|
|
435
|
+
onPlayError(e_3);
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
resetForcePlaying(element_1);
|
|
441
|
+
};
|
|
442
|
+
$[47] = mediaUrl;
|
|
443
|
+
$[48] = onPlayError;
|
|
444
|
+
$[49] = paused;
|
|
445
|
+
$[50] = t59;
|
|
446
|
+
} else {
|
|
447
|
+
t59 = $[50];
|
|
448
|
+
}
|
|
449
|
+
let t60;
|
|
450
|
+
if ($[51] !== media || $[52] !== mediaUrl || $[53] !== onPlayError || $[54] !== paused) {
|
|
451
|
+
t60 = [paused, media, mediaUrl, onPlayError];
|
|
452
|
+
$[51] = media;
|
|
453
|
+
$[52] = mediaUrl;
|
|
454
|
+
$[53] = onPlayError;
|
|
455
|
+
$[54] = paused;
|
|
456
|
+
$[55] = t60;
|
|
457
|
+
} else {
|
|
458
|
+
t60 = $[55];
|
|
459
|
+
}
|
|
460
|
+
useEffect(t59, t60);
|
|
461
|
+
let t61;
|
|
462
|
+
if ($[56] !== currentTime || $[57] !== duration || $[58] !== onProgressStep || $[59] !== paused) {
|
|
463
|
+
t61 = {
|
|
464
|
+
currentTime,
|
|
465
|
+
duration,
|
|
466
|
+
disabled: paused,
|
|
467
|
+
onStep: onProgressStep
|
|
468
|
+
};
|
|
469
|
+
$[56] = currentTime;
|
|
470
|
+
$[57] = duration;
|
|
471
|
+
$[58] = onProgressStep;
|
|
472
|
+
$[59] = paused;
|
|
473
|
+
$[60] = t61;
|
|
474
|
+
} else {
|
|
475
|
+
t61 = $[60];
|
|
476
|
+
}
|
|
477
|
+
useProgressSteps(t61);
|
|
478
|
+
let t62;
|
|
479
|
+
if ($[61] !== className || $[62] !== withSize) {
|
|
480
|
+
t62 = classNames([styles.container, {
|
|
481
|
+
[styles.withSize]: withSize
|
|
482
|
+
}, className]);
|
|
483
|
+
$[61] = className;
|
|
484
|
+
$[62] = withSize;
|
|
485
|
+
$[63] = t62;
|
|
486
|
+
} else {
|
|
487
|
+
t62 = $[63];
|
|
488
|
+
}
|
|
489
|
+
let t63;
|
|
490
|
+
if ($[64] !== height || $[65] !== width || $[66] !== withSize) {
|
|
491
|
+
t63 = withSize ? {
|
|
492
|
+
width,
|
|
493
|
+
height
|
|
494
|
+
} : null;
|
|
495
|
+
$[64] = height;
|
|
496
|
+
$[65] = width;
|
|
497
|
+
$[66] = withSize;
|
|
498
|
+
$[67] = t63;
|
|
499
|
+
} else {
|
|
500
|
+
t63 = $[67];
|
|
501
|
+
}
|
|
502
|
+
let t64;
|
|
503
|
+
if ($[68] !== description || $[69] !== innerClassName || $[70] !== isImageWithoutSourceFile || $[71] !== mediaUrl || $[72] !== shouldLoad) {
|
|
504
|
+
t64 = isImageWithoutSourceFile && shouldLoad ? /*#__PURE__*/jsx("img", {
|
|
299
505
|
src: mediaUrl,
|
|
300
506
|
alt: description,
|
|
301
|
-
tabIndex:
|
|
507
|
+
tabIndex: -1,
|
|
302
508
|
className: classNames([styles.media, innerClassName])
|
|
303
|
-
}) : null
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
509
|
+
}) : null;
|
|
510
|
+
$[68] = description;
|
|
511
|
+
$[69] = innerClassName;
|
|
512
|
+
$[70] = isImageWithoutSourceFile;
|
|
513
|
+
$[71] = mediaUrl;
|
|
514
|
+
$[72] = shouldLoad;
|
|
515
|
+
$[73] = t64;
|
|
516
|
+
} else {
|
|
517
|
+
t64 = $[73];
|
|
518
|
+
}
|
|
519
|
+
let t65;
|
|
520
|
+
if ($[74] !== autoPlay || $[75] !== disablePictureInPicture || $[76] !== externalRef || $[77] !== finalPreload || $[78] !== finalThumbnail || $[79] !== focusable || $[80] !== hasAudio || $[81] !== innerClassName || $[82] !== isImageWithoutSourceFile || $[83] !== isSuspended || $[84] !== loop || $[85] !== mediaRef || $[86] !== mediaUrl || $[87] !== muted || $[88] !== onEnded || $[89] !== onPause || $[90] !== onPlay || $[91] !== onPlaying || $[92] !== onSeeked || $[93] !== onSuspend || $[94] !== onTimeUpdate || $[95] !== onVolumeChange || $[96] !== paused || $[97] !== playsInline || $[98] !== shouldLoad || $[99] !== sources || $[100] !== withPoster || $[101] !== withoutCors) {
|
|
521
|
+
t65 = !isImageWithoutSourceFile ? /*#__PURE__*/jsx("video", {
|
|
522
|
+
ref: mergeRefs(ref, mediaRef, externalRef),
|
|
523
|
+
src: sources === null && shouldLoad ? `${mediaUrl}#t=0.001` : undefined,
|
|
313
524
|
autoPlay: autoPlay && !paused,
|
|
314
525
|
loop: loop,
|
|
315
526
|
muted: muted,
|
|
316
527
|
poster: shouldLoad && withPoster && finalThumbnail !== null ? finalThumbnail.url || null : null,
|
|
317
528
|
preload: finalPreload,
|
|
318
529
|
playsInline: playsInline,
|
|
319
|
-
crossOrigin: withoutCors ?
|
|
530
|
+
crossOrigin: withoutCors ? "anonymous" : null,
|
|
320
531
|
disablePictureInPicture: disablePictureInPicture,
|
|
321
|
-
tabIndex: focusable ?
|
|
532
|
+
tabIndex: focusable ? 0 : -1,
|
|
322
533
|
className: classNames([styles.media, innerClassName]),
|
|
323
534
|
onPlay: onPlay,
|
|
324
535
|
onPlaying: onPlaying,
|
|
@@ -331,25 +542,80 @@ function Video(_ref) {
|
|
|
331
542
|
"data-has-audio": hasAudio,
|
|
332
543
|
"data-is-suspended": isSuspended,
|
|
333
544
|
"aria-hidden": true,
|
|
334
|
-
children: (shouldLoad && sources !== null ? sources : []).map(
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
545
|
+
children: (shouldLoad && sources !== null ? sources : []).map(_temp2)
|
|
546
|
+
}, mediaUrl) : null;
|
|
547
|
+
$[74] = autoPlay;
|
|
548
|
+
$[75] = disablePictureInPicture;
|
|
549
|
+
$[76] = externalRef;
|
|
550
|
+
$[77] = finalPreload;
|
|
551
|
+
$[78] = finalThumbnail;
|
|
552
|
+
$[79] = focusable;
|
|
553
|
+
$[80] = hasAudio;
|
|
554
|
+
$[81] = innerClassName;
|
|
555
|
+
$[82] = isImageWithoutSourceFile;
|
|
556
|
+
$[83] = isSuspended;
|
|
557
|
+
$[84] = loop;
|
|
558
|
+
$[85] = mediaRef;
|
|
559
|
+
$[86] = mediaUrl;
|
|
560
|
+
$[87] = muted;
|
|
561
|
+
$[88] = onEnded;
|
|
562
|
+
$[89] = onPause;
|
|
563
|
+
$[90] = onPlay;
|
|
564
|
+
$[91] = onPlaying;
|
|
565
|
+
$[92] = onSeeked;
|
|
566
|
+
$[93] = onSuspend;
|
|
567
|
+
$[94] = onTimeUpdate;
|
|
568
|
+
$[95] = onVolumeChange;
|
|
569
|
+
$[96] = paused;
|
|
570
|
+
$[97] = playsInline;
|
|
571
|
+
$[98] = shouldLoad;
|
|
572
|
+
$[99] = sources;
|
|
573
|
+
$[100] = withPoster;
|
|
574
|
+
$[101] = withoutCors;
|
|
575
|
+
$[102] = t65;
|
|
576
|
+
} else {
|
|
577
|
+
t65 = $[102];
|
|
578
|
+
}
|
|
579
|
+
let t66;
|
|
580
|
+
if ($[103] !== isImageWithoutSourceFile || $[104] !== ready || $[105] !== showLoading) {
|
|
581
|
+
t66 = !isImageWithoutSourceFile && !ready && showLoading ? /*#__PURE__*/jsx(Spinner, {
|
|
343
582
|
className: styles.spinner
|
|
344
|
-
}) : null
|
|
345
|
-
|
|
583
|
+
}) : null;
|
|
584
|
+
$[103] = isImageWithoutSourceFile;
|
|
585
|
+
$[104] = ready;
|
|
586
|
+
$[105] = showLoading;
|
|
587
|
+
$[106] = t66;
|
|
588
|
+
} else {
|
|
589
|
+
t66 = $[106];
|
|
590
|
+
}
|
|
591
|
+
let t67;
|
|
592
|
+
if ($[107] !== t62 || $[108] !== t63 || $[109] !== t64 || $[110] !== t65 || $[111] !== t66) {
|
|
593
|
+
t67 = /*#__PURE__*/jsxs("div", {
|
|
594
|
+
className: t62,
|
|
595
|
+
style: t63,
|
|
596
|
+
children: [t64, t65, t66]
|
|
597
|
+
});
|
|
598
|
+
$[107] = t62;
|
|
599
|
+
$[108] = t63;
|
|
600
|
+
$[109] = t64;
|
|
601
|
+
$[110] = t65;
|
|
602
|
+
$[111] = t66;
|
|
603
|
+
$[112] = t67;
|
|
604
|
+
} else {
|
|
605
|
+
t67 = $[112];
|
|
606
|
+
}
|
|
607
|
+
return t67;
|
|
608
|
+
}
|
|
609
|
+
function _temp2(t0) {
|
|
610
|
+
const {
|
|
611
|
+
url: sourceUrl,
|
|
612
|
+
mime: sourceMime
|
|
613
|
+
} = t0;
|
|
614
|
+
return /*#__PURE__*/jsx("source", {
|
|
615
|
+
src: sourceUrl !== null ? `${sourceUrl}#t=0.001` : null,
|
|
616
|
+
type: sourceMime
|
|
617
|
+
}, `source-${sourceUrl}-${sourceMime}`);
|
|
346
618
|
}
|
|
347
|
-
|
|
348
|
-
var ref = _ref7.ref,
|
|
349
|
-
props = _objectWithoutProperties(_ref7, _excluded);
|
|
350
|
-
return /*#__PURE__*/jsx(Video, _objectSpread({
|
|
351
|
-
mediaRef: ref
|
|
352
|
-
}, props));
|
|
353
|
-
});
|
|
619
|
+
function _temp() {}
|
|
354
620
|
|
|
355
|
-
export {
|
|
621
|
+
export { Video as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/element-video",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.74",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -32,9 +32,11 @@
|
|
|
32
32
|
"license": "ISC",
|
|
33
33
|
"type": "module",
|
|
34
34
|
"module": "es/index.js",
|
|
35
|
+
"style": "./assets/css/styles.css",
|
|
35
36
|
"exports": {
|
|
36
37
|
".": {
|
|
37
38
|
"types": "./es/index.d.ts",
|
|
39
|
+
"style": "./assets/css/styles.css",
|
|
38
40
|
"import": "./es/index.js"
|
|
39
41
|
},
|
|
40
42
|
"./assets/css/styles": "./assets/css/styles.css",
|
|
@@ -51,17 +53,17 @@
|
|
|
51
53
|
"build": "../../scripts/prepare-package.sh --types"
|
|
52
54
|
},
|
|
53
55
|
"devDependencies": {
|
|
54
|
-
"react": "^
|
|
55
|
-
"react-dom": "^
|
|
56
|
+
"react": "^19.0.0",
|
|
57
|
+
"react-dom": "^19.0.0"
|
|
56
58
|
},
|
|
57
59
|
"peerDependencies": {
|
|
58
|
-
"react": "^
|
|
59
|
-
"react-dom": "^
|
|
60
|
+
"react": "^19.0.0",
|
|
61
|
+
"react-dom": "^19.0.0"
|
|
60
62
|
},
|
|
61
63
|
"dependencies": {
|
|
62
64
|
"@babel/runtime": "^7.28.6",
|
|
63
|
-
"@micromag/core": "^0.4.
|
|
64
|
-
"@micromag/element-closed-captions": "^0.4.
|
|
65
|
+
"@micromag/core": "^0.4.74",
|
|
66
|
+
"@micromag/element-closed-captions": "^0.4.74",
|
|
65
67
|
"classnames": "^2.2.6",
|
|
66
68
|
"hls.js": "^1.5.15",
|
|
67
69
|
"lodash": "^4.17.23",
|
|
@@ -72,6 +74,6 @@
|
|
|
72
74
|
"access": "public",
|
|
73
75
|
"registry": "https://registry.npmjs.org/"
|
|
74
76
|
},
|
|
75
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "fe510ee87845280d0760cb292aef9d2eb69e67c1",
|
|
76
78
|
"types": "es/index.d.ts"
|
|
77
79
|
}
|