@react-scrollytelling/video 0.1.1 → 0.3.0
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/dist/index.cjs +215 -0
- package/dist/index.d.cts +38 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +38 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +186 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +30 -23
- package/dist/index.cjs.js +0 -31
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.es.js +0 -719
- package/dist/index.es.js.map +0 -1
- package/dist/src/components/Video.d.ts +0 -25
- package/dist/src/components/Video.d.ts.map +0 -1
- package/dist/src/components/index.d.ts +0 -2
- package/dist/src/components/index.d.ts.map +0 -1
- package/dist/src/index.d.ts +0 -2
- package/dist/src/index.d.ts.map +0 -1
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
+
key = keys[i];
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
14
|
+
__defProp(to, key, {
|
|
15
|
+
get: ((k) => from[k]).bind(null, key),
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
+
value: mod,
|
|
25
|
+
enumerable: true
|
|
26
|
+
}) : target, mod));
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
let react_compiler_runtime = require("react/compiler-runtime");
|
|
30
|
+
let react = require("react");
|
|
31
|
+
react = __toESM(react);
|
|
32
|
+
let _react_scrollytelling_core = require("@react-scrollytelling/core");
|
|
33
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
+
|
|
35
|
+
//#region src/components/Video.tsx
|
|
36
|
+
const Video = (t0) => {
|
|
37
|
+
const $ = (0, react_compiler_runtime.c)(11);
|
|
38
|
+
const { src, srcWebm, width, height, thumbnail, ratio: t1, className, loadingOverlay } = t0;
|
|
39
|
+
const ratio = t1 === void 0 ? 0 : t1;
|
|
40
|
+
const videoRef = (0, react.useRef)(null);
|
|
41
|
+
let t2;
|
|
42
|
+
let t3;
|
|
43
|
+
if ($[0] !== ratio) {
|
|
44
|
+
t2 = () => {
|
|
45
|
+
if (!videoRef.current) return;
|
|
46
|
+
videoRef.current.setRatio(ratio);
|
|
47
|
+
};
|
|
48
|
+
t3 = [ratio];
|
|
49
|
+
$[0] = ratio;
|
|
50
|
+
$[1] = t2;
|
|
51
|
+
$[2] = t3;
|
|
52
|
+
} else {
|
|
53
|
+
t2 = $[1];
|
|
54
|
+
t3 = $[2];
|
|
55
|
+
}
|
|
56
|
+
(0, react.useEffect)(t2, t3);
|
|
57
|
+
let t4;
|
|
58
|
+
if ($[3] !== className || $[4] !== height || $[5] !== loadingOverlay || $[6] !== src || $[7] !== srcWebm || $[8] !== thumbnail || $[9] !== width) {
|
|
59
|
+
t4 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VideoWithImperativeHandle, {
|
|
60
|
+
ref: videoRef,
|
|
61
|
+
width,
|
|
62
|
+
height,
|
|
63
|
+
src,
|
|
64
|
+
srcWebm,
|
|
65
|
+
className,
|
|
66
|
+
thumbnail,
|
|
67
|
+
loadingOverlay
|
|
68
|
+
});
|
|
69
|
+
$[3] = className;
|
|
70
|
+
$[4] = height;
|
|
71
|
+
$[5] = loadingOverlay;
|
|
72
|
+
$[6] = src;
|
|
73
|
+
$[7] = srcWebm;
|
|
74
|
+
$[8] = thumbnail;
|
|
75
|
+
$[9] = width;
|
|
76
|
+
$[10] = t4;
|
|
77
|
+
} else t4 = $[10];
|
|
78
|
+
return t4;
|
|
79
|
+
};
|
|
80
|
+
const VideoWithImperativeHandle = /* @__PURE__ */ react.default.memo(/* @__PURE__ */ react.default.forwardRef((t0, ref) => {
|
|
81
|
+
const $ = (0, react_compiler_runtime.c)(25);
|
|
82
|
+
const { src, srcWebm, width, height, thumbnail, className, loadingOverlay } = t0;
|
|
83
|
+
const videoRef = (0, react.useRef)(null);
|
|
84
|
+
const [isLoading, setIsLoading] = (0, react.useState)(true);
|
|
85
|
+
let t1;
|
|
86
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
87
|
+
t1 = (ratio) => {
|
|
88
|
+
const videoElement = videoRef.current;
|
|
89
|
+
if (!videoElement) return;
|
|
90
|
+
const duration = videoElement.duration;
|
|
91
|
+
if (!isNaN(duration)) requestAnimationFrame(() => {
|
|
92
|
+
videoElement.currentTime = Math.round(ratio * duration * 100) / 100;
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
$[0] = t1;
|
|
96
|
+
} else t1 = $[0];
|
|
97
|
+
const setVideoRatioThrottled = (0, _react_scrollytelling_core.useRafThrottle)(t1);
|
|
98
|
+
let t2;
|
|
99
|
+
let t3;
|
|
100
|
+
if ($[1] !== setVideoRatioThrottled) {
|
|
101
|
+
t2 = () => ({ setRatio: setVideoRatioThrottled });
|
|
102
|
+
t3 = [setVideoRatioThrottled];
|
|
103
|
+
$[1] = setVideoRatioThrottled;
|
|
104
|
+
$[2] = t2;
|
|
105
|
+
$[3] = t3;
|
|
106
|
+
} else {
|
|
107
|
+
t2 = $[2];
|
|
108
|
+
t3 = $[3];
|
|
109
|
+
}
|
|
110
|
+
(0, react.useImperativeHandle)(ref, t2, t3);
|
|
111
|
+
let t4;
|
|
112
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
113
|
+
t4 = () => {
|
|
114
|
+
setIsLoading(true);
|
|
115
|
+
};
|
|
116
|
+
$[4] = t4;
|
|
117
|
+
} else t4 = $[4];
|
|
118
|
+
const handleWaiting = t4;
|
|
119
|
+
let t5;
|
|
120
|
+
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
121
|
+
t5 = () => {
|
|
122
|
+
setIsLoading(false);
|
|
123
|
+
};
|
|
124
|
+
$[5] = t5;
|
|
125
|
+
} else t5 = $[5];
|
|
126
|
+
const handleCanPlay = t5;
|
|
127
|
+
let t6;
|
|
128
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
129
|
+
t6 = {
|
|
130
|
+
position: "relative",
|
|
131
|
+
width: "100%",
|
|
132
|
+
height: "100%"
|
|
133
|
+
};
|
|
134
|
+
$[6] = t6;
|
|
135
|
+
} else t6 = $[6];
|
|
136
|
+
let t7;
|
|
137
|
+
if ($[7] !== srcWebm || $[8] !== thumbnail) {
|
|
138
|
+
t7 = srcWebm && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("source", {
|
|
139
|
+
src: thumbnail ? srcWebm : `${srcWebm}#t=0.1`,
|
|
140
|
+
type: "video/webm"
|
|
141
|
+
});
|
|
142
|
+
$[7] = srcWebm;
|
|
143
|
+
$[8] = thumbnail;
|
|
144
|
+
$[9] = t7;
|
|
145
|
+
} else t7 = $[9];
|
|
146
|
+
const t8 = thumbnail ? src : `${src}#t=0.1`;
|
|
147
|
+
let t9;
|
|
148
|
+
if ($[10] !== t8) {
|
|
149
|
+
t9 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("source", {
|
|
150
|
+
src: t8,
|
|
151
|
+
type: "video/mp4"
|
|
152
|
+
});
|
|
153
|
+
$[10] = t8;
|
|
154
|
+
$[11] = t9;
|
|
155
|
+
} else t9 = $[11];
|
|
156
|
+
let t10;
|
|
157
|
+
if ($[12] !== className || $[13] !== height || $[14] !== t7 || $[15] !== t9 || $[16] !== thumbnail || $[17] !== width) {
|
|
158
|
+
t10 = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("video", {
|
|
159
|
+
ref: videoRef,
|
|
160
|
+
width,
|
|
161
|
+
height,
|
|
162
|
+
className,
|
|
163
|
+
muted: true,
|
|
164
|
+
disablePictureInPicture: true,
|
|
165
|
+
disableRemotePlayback: true,
|
|
166
|
+
playsInline: true,
|
|
167
|
+
controls: false,
|
|
168
|
+
preload: "auto",
|
|
169
|
+
onWaiting: handleWaiting,
|
|
170
|
+
onCanPlay: handleCanPlay,
|
|
171
|
+
poster: thumbnail,
|
|
172
|
+
children: [t7, t9]
|
|
173
|
+
});
|
|
174
|
+
$[12] = className;
|
|
175
|
+
$[13] = height;
|
|
176
|
+
$[14] = t7;
|
|
177
|
+
$[15] = t9;
|
|
178
|
+
$[16] = thumbnail;
|
|
179
|
+
$[17] = width;
|
|
180
|
+
$[18] = t10;
|
|
181
|
+
} else t10 = $[18];
|
|
182
|
+
let t11;
|
|
183
|
+
if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
|
|
184
|
+
t11 = {
|
|
185
|
+
position: "absolute",
|
|
186
|
+
inset: 0
|
|
187
|
+
};
|
|
188
|
+
$[19] = t11;
|
|
189
|
+
} else t11 = $[19];
|
|
190
|
+
const t12 = isLoading && loadingOverlay;
|
|
191
|
+
let t13;
|
|
192
|
+
if ($[20] !== t12) {
|
|
193
|
+
t13 = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
194
|
+
style: t11,
|
|
195
|
+
children: t12
|
|
196
|
+
});
|
|
197
|
+
$[20] = t12;
|
|
198
|
+
$[21] = t13;
|
|
199
|
+
} else t13 = $[21];
|
|
200
|
+
let t14;
|
|
201
|
+
if ($[22] !== t10 || $[23] !== t13) {
|
|
202
|
+
t14 = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
203
|
+
style: t6,
|
|
204
|
+
children: [t10, t13]
|
|
205
|
+
});
|
|
206
|
+
$[22] = t10;
|
|
207
|
+
$[23] = t13;
|
|
208
|
+
$[24] = t14;
|
|
209
|
+
} else t14 = $[24];
|
|
210
|
+
return t14;
|
|
211
|
+
}));
|
|
212
|
+
|
|
213
|
+
//#endregion
|
|
214
|
+
exports.Video = Video;
|
|
215
|
+
exports.VideoWithImperativeHandle = VideoWithImperativeHandle;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/Video.d.ts
|
|
5
|
+
interface VideoProps {
|
|
6
|
+
/** Source of the mp4 video */
|
|
7
|
+
src: string;
|
|
8
|
+
/** Source of the webm video */
|
|
9
|
+
srcWebm?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Thumbnail URL of the video.
|
|
12
|
+
* If not specified, it will use the first frame of the video as the thumbnail.
|
|
13
|
+
*/
|
|
14
|
+
thumbnail?: string;
|
|
15
|
+
className?: string;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
ratio?: number;
|
|
19
|
+
/** Overlay content to show when the video is loading */
|
|
20
|
+
loadingOverlay?: React.ReactNode;
|
|
21
|
+
}
|
|
22
|
+
declare const Video: ({
|
|
23
|
+
src,
|
|
24
|
+
srcWebm,
|
|
25
|
+
width,
|
|
26
|
+
height,
|
|
27
|
+
thumbnail,
|
|
28
|
+
ratio,
|
|
29
|
+
className,
|
|
30
|
+
loadingOverlay
|
|
31
|
+
}: VideoProps) => react_jsx_runtime0.JSX.Element;
|
|
32
|
+
interface VideoRef {
|
|
33
|
+
setRatio: (ratio: number) => void;
|
|
34
|
+
}
|
|
35
|
+
declare const VideoWithImperativeHandle: React.NamedExoticComponent<VideoProps & React.RefAttributes<VideoRef>>;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { Video, VideoProps, VideoRef, VideoWithImperativeHandle };
|
|
38
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/components/Video.tsx"],"mappings":";;;;UAUiB,UAAA;;EAEf,GAAA;EAFe;EAKf,OAAA;;;;;EAMA,SAAA;EAEA,SAAA;EACA,KAAA;EACA,MAAA;EACA,KAAA;EAGA;EAAA,cAAA,GAAiB,KAAA,CAAM,SAAA;AAAA;AAAA,cAGZ,KAAA;EAAK,GAAA;EAAA,OAAA;EAAA,KAAA;EAAA,MAAA;EAAA,SAAA;EAAA,KAAA;EAAA,SAAA;EAAA;AAAA,GASf,UAAA,KAAU,kBAAA,CAAA,GAAA,CAAA,OAAA;AAAA,UAyBI,QAAA;EACf,QAAA,GAAW,KAAA;AAAA;AAAA,cAGA,yBAAA,EAAyB,KAAA,CAAA,oBAAA,CAAA,UAAA,GAAA,KAAA,CAAA,aAAA,CAAA,QAAA"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/components/Video.d.ts
|
|
5
|
+
interface VideoProps {
|
|
6
|
+
/** Source of the mp4 video */
|
|
7
|
+
src: string;
|
|
8
|
+
/** Source of the webm video */
|
|
9
|
+
srcWebm?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Thumbnail URL of the video.
|
|
12
|
+
* If not specified, it will use the first frame of the video as the thumbnail.
|
|
13
|
+
*/
|
|
14
|
+
thumbnail?: string;
|
|
15
|
+
className?: string;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
ratio?: number;
|
|
19
|
+
/** Overlay content to show when the video is loading */
|
|
20
|
+
loadingOverlay?: React.ReactNode;
|
|
21
|
+
}
|
|
22
|
+
declare const Video: ({
|
|
23
|
+
src,
|
|
24
|
+
srcWebm,
|
|
25
|
+
width,
|
|
26
|
+
height,
|
|
27
|
+
thumbnail,
|
|
28
|
+
ratio,
|
|
29
|
+
className,
|
|
30
|
+
loadingOverlay
|
|
31
|
+
}: VideoProps) => react_jsx_runtime0.JSX.Element;
|
|
32
|
+
interface VideoRef {
|
|
33
|
+
setRatio: (ratio: number) => void;
|
|
34
|
+
}
|
|
35
|
+
declare const VideoWithImperativeHandle: React.NamedExoticComponent<VideoProps & React.RefAttributes<VideoRef>>;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { Video, VideoProps, VideoRef, VideoWithImperativeHandle };
|
|
38
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/components/Video.tsx"],"mappings":";;;;UAUiB,UAAA;;EAEf,GAAA;EAFe;EAKf,OAAA;;;;;EAMA,SAAA;EAEA,SAAA;EACA,KAAA;EACA,MAAA;EACA,KAAA;EAGA;EAAA,cAAA,GAAiB,KAAA,CAAM,SAAA;AAAA;AAAA,cAGZ,KAAA;EAAK,GAAA;EAAA,OAAA;EAAA,KAAA;EAAA,MAAA;EAAA,SAAA;EAAA,KAAA;EAAA,SAAA;EAAA;AAAA,GASf,UAAA,KAAU,kBAAA,CAAA,GAAA,CAAA,OAAA;AAAA,UAyBI,QAAA;EACf,QAAA,GAAW,KAAA;AAAA;AAAA,cAGA,yBAAA,EAAyB,KAAA,CAAA,oBAAA,CAAA,UAAA,GAAA,KAAA,CAAA,aAAA,CAAA,QAAA"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { c } from "react/compiler-runtime";
|
|
2
|
+
import React, { useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
3
|
+
import { useRafThrottle } from "@react-scrollytelling/core";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/components/Video.tsx
|
|
7
|
+
const Video = (t0) => {
|
|
8
|
+
const $ = c(11);
|
|
9
|
+
const { src, srcWebm, width, height, thumbnail, ratio: t1, className, loadingOverlay } = t0;
|
|
10
|
+
const ratio = t1 === void 0 ? 0 : t1;
|
|
11
|
+
const videoRef = useRef(null);
|
|
12
|
+
let t2;
|
|
13
|
+
let t3;
|
|
14
|
+
if ($[0] !== ratio) {
|
|
15
|
+
t2 = () => {
|
|
16
|
+
if (!videoRef.current) return;
|
|
17
|
+
videoRef.current.setRatio(ratio);
|
|
18
|
+
};
|
|
19
|
+
t3 = [ratio];
|
|
20
|
+
$[0] = ratio;
|
|
21
|
+
$[1] = t2;
|
|
22
|
+
$[2] = t3;
|
|
23
|
+
} else {
|
|
24
|
+
t2 = $[1];
|
|
25
|
+
t3 = $[2];
|
|
26
|
+
}
|
|
27
|
+
useEffect(t2, t3);
|
|
28
|
+
let t4;
|
|
29
|
+
if ($[3] !== className || $[4] !== height || $[5] !== loadingOverlay || $[6] !== src || $[7] !== srcWebm || $[8] !== thumbnail || $[9] !== width) {
|
|
30
|
+
t4 = /* @__PURE__ */ jsx(VideoWithImperativeHandle, {
|
|
31
|
+
ref: videoRef,
|
|
32
|
+
width,
|
|
33
|
+
height,
|
|
34
|
+
src,
|
|
35
|
+
srcWebm,
|
|
36
|
+
className,
|
|
37
|
+
thumbnail,
|
|
38
|
+
loadingOverlay
|
|
39
|
+
});
|
|
40
|
+
$[3] = className;
|
|
41
|
+
$[4] = height;
|
|
42
|
+
$[5] = loadingOverlay;
|
|
43
|
+
$[6] = src;
|
|
44
|
+
$[7] = srcWebm;
|
|
45
|
+
$[8] = thumbnail;
|
|
46
|
+
$[9] = width;
|
|
47
|
+
$[10] = t4;
|
|
48
|
+
} else t4 = $[10];
|
|
49
|
+
return t4;
|
|
50
|
+
};
|
|
51
|
+
const VideoWithImperativeHandle = /* @__PURE__ */ React.memo(/* @__PURE__ */ React.forwardRef((t0, ref) => {
|
|
52
|
+
const $ = c(25);
|
|
53
|
+
const { src, srcWebm, width, height, thumbnail, className, loadingOverlay } = t0;
|
|
54
|
+
const videoRef = useRef(null);
|
|
55
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
56
|
+
let t1;
|
|
57
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
58
|
+
t1 = (ratio) => {
|
|
59
|
+
const videoElement = videoRef.current;
|
|
60
|
+
if (!videoElement) return;
|
|
61
|
+
const duration = videoElement.duration;
|
|
62
|
+
if (!isNaN(duration)) requestAnimationFrame(() => {
|
|
63
|
+
videoElement.currentTime = Math.round(ratio * duration * 100) / 100;
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
$[0] = t1;
|
|
67
|
+
} else t1 = $[0];
|
|
68
|
+
const setVideoRatioThrottled = useRafThrottle(t1);
|
|
69
|
+
let t2;
|
|
70
|
+
let t3;
|
|
71
|
+
if ($[1] !== setVideoRatioThrottled) {
|
|
72
|
+
t2 = () => ({ setRatio: setVideoRatioThrottled });
|
|
73
|
+
t3 = [setVideoRatioThrottled];
|
|
74
|
+
$[1] = setVideoRatioThrottled;
|
|
75
|
+
$[2] = t2;
|
|
76
|
+
$[3] = t3;
|
|
77
|
+
} else {
|
|
78
|
+
t2 = $[2];
|
|
79
|
+
t3 = $[3];
|
|
80
|
+
}
|
|
81
|
+
useImperativeHandle(ref, t2, t3);
|
|
82
|
+
let t4;
|
|
83
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
84
|
+
t4 = () => {
|
|
85
|
+
setIsLoading(true);
|
|
86
|
+
};
|
|
87
|
+
$[4] = t4;
|
|
88
|
+
} else t4 = $[4];
|
|
89
|
+
const handleWaiting = t4;
|
|
90
|
+
let t5;
|
|
91
|
+
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
92
|
+
t5 = () => {
|
|
93
|
+
setIsLoading(false);
|
|
94
|
+
};
|
|
95
|
+
$[5] = t5;
|
|
96
|
+
} else t5 = $[5];
|
|
97
|
+
const handleCanPlay = t5;
|
|
98
|
+
let t6;
|
|
99
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
100
|
+
t6 = {
|
|
101
|
+
position: "relative",
|
|
102
|
+
width: "100%",
|
|
103
|
+
height: "100%"
|
|
104
|
+
};
|
|
105
|
+
$[6] = t6;
|
|
106
|
+
} else t6 = $[6];
|
|
107
|
+
let t7;
|
|
108
|
+
if ($[7] !== srcWebm || $[8] !== thumbnail) {
|
|
109
|
+
t7 = srcWebm && /* @__PURE__ */ jsx("source", {
|
|
110
|
+
src: thumbnail ? srcWebm : `${srcWebm}#t=0.1`,
|
|
111
|
+
type: "video/webm"
|
|
112
|
+
});
|
|
113
|
+
$[7] = srcWebm;
|
|
114
|
+
$[8] = thumbnail;
|
|
115
|
+
$[9] = t7;
|
|
116
|
+
} else t7 = $[9];
|
|
117
|
+
const t8 = thumbnail ? src : `${src}#t=0.1`;
|
|
118
|
+
let t9;
|
|
119
|
+
if ($[10] !== t8) {
|
|
120
|
+
t9 = /* @__PURE__ */ jsx("source", {
|
|
121
|
+
src: t8,
|
|
122
|
+
type: "video/mp4"
|
|
123
|
+
});
|
|
124
|
+
$[10] = t8;
|
|
125
|
+
$[11] = t9;
|
|
126
|
+
} else t9 = $[11];
|
|
127
|
+
let t10;
|
|
128
|
+
if ($[12] !== className || $[13] !== height || $[14] !== t7 || $[15] !== t9 || $[16] !== thumbnail || $[17] !== width) {
|
|
129
|
+
t10 = /* @__PURE__ */ jsxs("video", {
|
|
130
|
+
ref: videoRef,
|
|
131
|
+
width,
|
|
132
|
+
height,
|
|
133
|
+
className,
|
|
134
|
+
muted: true,
|
|
135
|
+
disablePictureInPicture: true,
|
|
136
|
+
disableRemotePlayback: true,
|
|
137
|
+
playsInline: true,
|
|
138
|
+
controls: false,
|
|
139
|
+
preload: "auto",
|
|
140
|
+
onWaiting: handleWaiting,
|
|
141
|
+
onCanPlay: handleCanPlay,
|
|
142
|
+
poster: thumbnail,
|
|
143
|
+
children: [t7, t9]
|
|
144
|
+
});
|
|
145
|
+
$[12] = className;
|
|
146
|
+
$[13] = height;
|
|
147
|
+
$[14] = t7;
|
|
148
|
+
$[15] = t9;
|
|
149
|
+
$[16] = thumbnail;
|
|
150
|
+
$[17] = width;
|
|
151
|
+
$[18] = t10;
|
|
152
|
+
} else t10 = $[18];
|
|
153
|
+
let t11;
|
|
154
|
+
if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
|
|
155
|
+
t11 = {
|
|
156
|
+
position: "absolute",
|
|
157
|
+
inset: 0
|
|
158
|
+
};
|
|
159
|
+
$[19] = t11;
|
|
160
|
+
} else t11 = $[19];
|
|
161
|
+
const t12 = isLoading && loadingOverlay;
|
|
162
|
+
let t13;
|
|
163
|
+
if ($[20] !== t12) {
|
|
164
|
+
t13 = /* @__PURE__ */ jsx("div", {
|
|
165
|
+
style: t11,
|
|
166
|
+
children: t12
|
|
167
|
+
});
|
|
168
|
+
$[20] = t12;
|
|
169
|
+
$[21] = t13;
|
|
170
|
+
} else t13 = $[21];
|
|
171
|
+
let t14;
|
|
172
|
+
if ($[22] !== t10 || $[23] !== t13) {
|
|
173
|
+
t14 = /* @__PURE__ */ jsxs("div", {
|
|
174
|
+
style: t6,
|
|
175
|
+
children: [t10, t13]
|
|
176
|
+
});
|
|
177
|
+
$[22] = t10;
|
|
178
|
+
$[23] = t13;
|
|
179
|
+
$[24] = t14;
|
|
180
|
+
} else t14 = $[24];
|
|
181
|
+
return t14;
|
|
182
|
+
}));
|
|
183
|
+
|
|
184
|
+
//#endregion
|
|
185
|
+
export { Video, VideoWithImperativeHandle };
|
|
186
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["React","useEffect","useImperativeHandle","useCallback","useRef","useState","useRafThrottle","jsx","_jsx","jsxs","_jsxs","Video","t0","$","_c","src","srcWebm","width","height","thumbnail","ratio","t1","className","loadingOverlay","undefined","videoRef","t2","t3","current","setRatio","t4","VideoWithImperativeHandle","memo","forwardRef","ref","isLoading","setIsLoading","Symbol","for","videoElement","duration","isNaN","requestAnimationFrame","currentTime","Math","round","setVideoRatio","setVideoRatioThrottled","handleWaiting","t5","handleCanPlay","t6","position","t7","type","t8","t9","t10","muted","disablePictureInPicture","disableRemotePlayback","playsInline","controls","preload","children","t11","inset","t12","t13","style","t14"],"sources":["../src/components/Video.tsx"],"sourcesContent":["import React, {\n useEffect,\n useImperativeHandle,\n useCallback,\n useRef,\n useState,\n} from \"react\";\n\nimport { useRafThrottle } from \"@react-scrollytelling/core\";\n\nexport interface VideoProps {\n /** Source of the mp4 video */\n src: string;\n\n /** Source of the webm video */\n srcWebm?: string;\n\n /**\n * Thumbnail URL of the video.\n * If not specified, it will use the first frame of the video as the thumbnail.\n */\n thumbnail?: string;\n\n className?: string;\n width: number;\n height: number;\n ratio?: number;\n\n /** Overlay content to show when the video is loading */\n loadingOverlay?: React.ReactNode;\n}\n\nexport const Video = ({\n src,\n srcWebm,\n width,\n height,\n thumbnail,\n ratio = 0,\n className,\n loadingOverlay,\n}: VideoProps) => {\n const videoRef = useRef<VideoRef>(null);\n\n useEffect(() => {\n // update currentTime when the ratio prop changes\n if (!videoRef.current) {\n return;\n }\n videoRef.current.setRatio(ratio);\n }, [ratio]);\n\n return (\n <VideoWithImperativeHandle\n ref={videoRef}\n width={width}\n height={height}\n src={src}\n srcWebm={srcWebm}\n className={className}\n thumbnail={thumbnail}\n loadingOverlay={loadingOverlay}\n ></VideoWithImperativeHandle>\n );\n};\n\nexport interface VideoRef {\n setRatio: (ratio: number) => void;\n}\n\nexport const VideoWithImperativeHandle = React.memo(\n React.forwardRef<VideoRef, VideoProps>(\n (\n { src, srcWebm, width, height, thumbnail, className, loadingOverlay },\n ref\n ) => {\n const videoRef = useRef<HTMLVideoElement>(null);\n const [isLoading, setIsLoading] = useState(true);\n\n const setVideoRatio = useCallback((ratio: number) => {\n const videoElement = videoRef.current;\n if (!videoElement) {\n return;\n }\n\n const duration = videoElement.duration;\n if (!isNaN(duration)) {\n requestAnimationFrame(() => {\n videoElement.currentTime = Math.round(ratio * duration * 100) / 100;\n });\n }\n }, []);\n const setVideoRatioThrottled = useRafThrottle(setVideoRatio);\n\n useImperativeHandle(ref, () => {\n return {\n setRatio: setVideoRatioThrottled,\n };\n }, [setVideoRatioThrottled]);\n\n const handleWaiting = useCallback(() => {\n setIsLoading(true);\n }, []);\n\n const handleCanPlay = useCallback(() => {\n setIsLoading(false);\n }, []);\n\n return (\n <div style={{ position: \"relative\", width: \"100%\", height: \"100%\" }}>\n <video\n ref={videoRef}\n width={width}\n height={height}\n className={className}\n muted\n disablePictureInPicture\n disableRemotePlayback\n playsInline\n controls={false}\n // preload the video\n preload=\"auto\"\n onWaiting={handleWaiting}\n onCanPlay={handleCanPlay}\n poster={thumbnail}\n >\n {srcWebm && (\n <source\n src={thumbnail ? srcWebm : `${srcWebm}#t=0.1`}\n type=\"video/webm\"\n />\n )}\n <source src={thumbnail ? src : `${src}#t=0.1`} type=\"video/mp4\" />\n </video>\n <div style={{ position: \"absolute\", inset: 0 }}>\n {isLoading && loadingOverlay}\n </div>\n </div>\n );\n }\n )\n);\n"],"mappings":";;;;;;AAgCA,MAAaW,SAAQC,OAAA;CAAA,MAAAC,IAAAC,EAAA,GAAA;CAAC,MAAA,EAAAC,KAAAC,SAAAC,OAAAC,QAAAC,WAAAC,OAAAC,IAAAC,WAAAC,mBAAAX;CAMpB,MAAAQ,QAAAC,OAAAG,SAAA,IAAAH;CAIA,MAAAI,WAAiBrB,OAAiB,KAAK;CAAC,IAAAsB;CAAA,IAAAC;AAAA,KAAAd,EAAA,OAAAO,OAAA;AAE9BM,aAAA;AAER,OAA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AAlB;GAAuDa,UAAA,CACjEP,KAwBAW,IAEM;GACH,CAAC;AAAAvD,IAAA,MAAA4C;AAAA5C,IAAA,MAAAuD;AAAAvD,IAAA,MAAAyD;OAAAA,OAAAzD,EAAA;AAAA,QA5BNyD;EAgCR,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-scrollytelling/video",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "@hsunpei",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,24 +8,33 @@
|
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
10
10
|
"homepage": "https://github.com/hsunpei/react-scrollytelling#readme",
|
|
11
|
-
"main": "dist/index.cjs
|
|
12
|
-
"module": "dist/index.
|
|
13
|
-
"types": "
|
|
11
|
+
"main": "dist/index.cjs",
|
|
12
|
+
"module": "dist/index.mjs",
|
|
13
|
+
"types": "dist/index.d.mts",
|
|
14
14
|
"sideEffects": false,
|
|
15
15
|
"files": [
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"import": {
|
|
21
|
+
"types": "./dist/index.d.mts",
|
|
22
|
+
"default": "./dist/index.mjs"
|
|
23
|
+
},
|
|
24
|
+
"require": {
|
|
25
|
+
"types": "./dist/index.d.cts",
|
|
26
|
+
"default": "./dist/index.cjs"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
18
30
|
"repository": {
|
|
19
31
|
"type": "git",
|
|
20
|
-
"url": "git+https://github.com/hsunpei/react-scrollytelling.git"
|
|
32
|
+
"url": "git+https://github.com/hsunpei/react-scrollytelling.git",
|
|
33
|
+
"directory": "packages/video"
|
|
21
34
|
},
|
|
22
35
|
"scripts": {
|
|
23
|
-
"dev": "
|
|
24
|
-
"
|
|
25
|
-
"dev:declarations": "tsc -p . --emitDeclarationOnly --watch --outDir dist_types",
|
|
26
|
-
"build": "run-s build:dist build:declarations",
|
|
27
|
-
"build:dist": "vite build",
|
|
28
|
-
"build:declarations": "tsc -p . --emitDeclarationOnly --outDir dist_types",
|
|
36
|
+
"dev": "tsdown --watch",
|
|
37
|
+
"build": "tsdown",
|
|
29
38
|
"clean": "rimraf -rf ./dist && rimraf -rf ./dist_types",
|
|
30
39
|
"test": "jest",
|
|
31
40
|
"test:watch": "jest --watch"
|
|
@@ -34,18 +43,16 @@
|
|
|
34
43
|
"url": "https://github.com/hsunpei/react-scrollytelling/issues"
|
|
35
44
|
},
|
|
36
45
|
"devDependencies": {
|
|
37
|
-
"@testing-library/dom": "
|
|
38
|
-
"@testing-library/jest-dom": "
|
|
39
|
-
"@testing-library/react": "
|
|
40
|
-
"jest": "
|
|
41
|
-
"jest-environment-jsdom": "
|
|
42
|
-
"ts-jest": "
|
|
43
|
-
"vite": "^5.2.11"
|
|
46
|
+
"@testing-library/dom": "catalog:",
|
|
47
|
+
"@testing-library/jest-dom": "catalog:",
|
|
48
|
+
"@testing-library/react": "catalog:",
|
|
49
|
+
"jest": "catalog:",
|
|
50
|
+
"jest-environment-jsdom": "catalog:",
|
|
51
|
+
"ts-jest": "catalog:"
|
|
44
52
|
},
|
|
45
53
|
"peerDependencies": {
|
|
46
|
-
"@react-scrollytelling/core": "workspace
|
|
47
|
-
"react": "
|
|
48
|
-
"react-dom": "
|
|
49
|
-
}
|
|
50
|
-
"gitHead": "b4dc4bd312e4d1d3de0f344764b9b67dadac18a8"
|
|
54
|
+
"@react-scrollytelling/core": "workspace:*",
|
|
55
|
+
"react": "catalog:",
|
|
56
|
+
"react-dom": "catalog:"
|
|
57
|
+
}
|
|
51
58
|
}
|
package/dist/index.cjs.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react"),dr=require("@react-scrollytelling/core");var ne={exports:{}},L={};/**
|
|
2
|
-
* @license React
|
|
3
|
-
* react-jsx-runtime.production.min.js
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var we;function vr(){if(we)return L;we=1;var C=g,h=Symbol.for("react.element"),j=Symbol.for("react.fragment"),E=Object.prototype.hasOwnProperty,m=C.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,O={key:!0,ref:!0,__self:!0,__source:!0};function P(R,s,w){var c,b={},_=null,D=null;w!==void 0&&(_=""+w),s.key!==void 0&&(_=""+s.key),s.ref!==void 0&&(D=s.ref);for(c in s)E.call(s,c)&&!O.hasOwnProperty(c)&&(b[c]=s[c]);if(R&&R.defaultProps)for(c in s=R.defaultProps,s)b[c]===void 0&&(b[c]=s[c]);return{$$typeof:h,type:R,key:_,ref:D,props:b,_owner:m.current}}return L.Fragment=j,L.jsx=P,L.jsxs=P,L}var M={};/**
|
|
10
|
-
* @license React
|
|
11
|
-
* react-jsx-runtime.development.js
|
|
12
|
-
*
|
|
13
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the MIT license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var je;function pr(){return je||(je=1,process.env.NODE_ENV!=="production"&&function(){var C=g,h=Symbol.for("react.element"),j=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),m=Symbol.for("react.strict_mode"),O=Symbol.for("react.profiler"),P=Symbol.for("react.provider"),R=Symbol.for("react.context"),s=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),c=Symbol.for("react.suspense_list"),b=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),D=Symbol.for("react.offscreen"),U=Symbol.iterator,K="@@iterator";function W(e){if(e===null||typeof e!="object")return null;var r=U&&e[U]||e[K];return typeof r=="function"?r:null}var S=C.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function d(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];ke("error",e,t)}}function ke(e,r,t){{var n=S.ReactDebugCurrentFrame,o=n.getStackAddendum();o!==""&&(r+="%s",t=t.concat([o]));var u=t.map(function(i){return String(i)});u.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,u)}}var De=!1,Fe=!1,Ae=!1,Ie=!1,We=!1,ae;ae=Symbol.for("react.module.reference");function $e(e){return!!(typeof e=="string"||typeof e=="function"||e===E||e===O||We||e===m||e===w||e===c||Ie||e===D||De||Fe||Ae||typeof e=="object"&&e!==null&&(e.$$typeof===_||e.$$typeof===b||e.$$typeof===P||e.$$typeof===R||e.$$typeof===s||e.$$typeof===ae||e.getModuleId!==void 0))}function Ve(e,r,t){var n=e.displayName;if(n)return n;var o=r.displayName||r.name||"";return o!==""?t+"("+o+")":t}function ie(e){return e.displayName||"Context"}function T(e){if(e==null)return null;if(typeof e.tag=="number"&&d("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case E:return"Fragment";case j:return"Portal";case O:return"Profiler";case m:return"StrictMode";case w:return"Suspense";case c:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case R:var r=e;return ie(r)+".Consumer";case P:var t=e;return ie(t._context)+".Provider";case s:return Ve(e,e.render,"ForwardRef");case b:var n=e.displayName||null;return n!==null?n:T(e.type)||"Memo";case _:{var o=e,u=o._payload,i=o._init;try{return T(i(u))}catch(a){return null}}}return null}var x=Object.assign,$=0,oe,ue,se,le,fe,ce,de;function ve(){}ve.__reactDisabledLog=!0;function Ye(){{if($===0){oe=console.log,ue=console.info,se=console.warn,le=console.error,fe=console.group,ce=console.groupCollapsed,de=console.groupEnd;var e={configurable:!0,enumerable:!0,value:ve,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}$++}}function Le(){{if($--,$===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:x({},e,{value:oe}),info:x({},e,{value:ue}),warn:x({},e,{value:se}),error:x({},e,{value:le}),group:x({},e,{value:fe}),groupCollapsed:x({},e,{value:ce}),groupEnd:x({},e,{value:de})})}$<0&&d("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var G=S.ReactCurrentDispatcher,H;function N(e,r,t){{if(H===void 0)try{throw Error()}catch(o){var n=o.stack.trim().match(/\n( *(at )?)/);H=n&&n[1]||""}return`
|
|
18
|
-
`+H+e}}var z=!1,q;{var Me=typeof WeakMap=="function"?WeakMap:Map;q=new Me}function pe(e,r){if(!e||z)return"";{var t=q.get(e);if(t!==void 0)return t}var n;z=!0;var o=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var u;u=G.current,G.current=null,Ye();try{if(r){var i=function(){throw Error()};if(Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(i,[])}catch(p){n=p}Reflect.construct(e,[],i)}else{try{i.call()}catch(p){n=p}e.call(i.prototype)}}else{try{throw Error()}catch(p){n=p}e()}}catch(p){if(p&&n&&typeof p.stack=="string"){for(var a=p.stack.split(`
|
|
19
|
-
`),v=n.stack.split(`
|
|
20
|
-
`),l=a.length-1,f=v.length-1;l>=1&&f>=0&&a[l]!==v[f];)f--;for(;l>=1&&f>=0;l--,f--)if(a[l]!==v[f]){if(l!==1||f!==1)do if(l--,f--,f<0||a[l]!==v[f]){var y=`
|
|
21
|
-
`+a[l].replace(" at new "," at ");return e.displayName&&y.includes("<anonymous>")&&(y=y.replace("<anonymous>",e.displayName)),typeof e=="function"&&q.set(e,y),y}while(l>=1&&f>=0);break}}}finally{z=!1,G.current=u,Le(),Error.prepareStackTrace=o}var A=e?e.displayName||e.name:"",k=A?N(A):"";return typeof e=="function"&&q.set(e,k),k}function Ue(e,r,t){return pe(e,!1)}function Ne(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function B(e,r,t){if(e==null)return"";if(typeof e=="function")return pe(e,Ne(e));if(typeof e=="string")return N(e);switch(e){case w:return N("Suspense");case c:return N("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case s:return Ue(e.render);case b:return B(e.type,r,t);case _:{var n=e,o=n._payload,u=n._init;try{return B(u(o),r,t)}catch(i){}}}return""}var V=Object.prototype.hasOwnProperty,ye={},ge=S.ReactDebugCurrentFrame;function J(e){if(e){var r=e._owner,t=B(e.type,e._source,r?r.type:null);ge.setExtraStackFrame(t)}else ge.setExtraStackFrame(null)}function qe(e,r,t,n,o){{var u=Function.call.bind(V);for(var i in e)if(u(e,i)){var a=void 0;try{if(typeof e[i]!="function"){var v=Error((n||"React class")+": "+t+" type `"+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[i]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw v.name="Invariant Violation",v}a=e[i](r,i,n,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(l){a=l}a&&!(a instanceof Error)&&(J(o),d("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",t,i,typeof a),J(null)),a instanceof Error&&!(a.message in ye)&&(ye[a.message]=!0,J(o),d("Failed %s type: %s",t,a.message),J(null))}}}var Be=Array.isArray;function X(e){return Be(e)}function Je(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function Ke(e){try{return he(e),!1}catch(r){return!0}}function he(e){return""+e}function Re(e){if(Ke(e))return d("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Je(e)),he(e)}var Y=S.ReactCurrentOwner,Ge={key:!0,ref:!0,__self:!0,__source:!0},be,Ee,Z;Z={};function He(e){if(V.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function ze(e){if(V.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function Xe(e,r){if(typeof e.ref=="string"&&Y.current&&r&&Y.current.stateNode!==r){var t=T(Y.current.type);Z[t]||(d('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',T(Y.current.type),e.ref),Z[t]=!0)}}function Ze(e,r){{var t=function(){be||(be=!0,d("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}}function Qe(e,r){{var t=function(){Ee||(Ee=!0,d("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}}var er=function(e,r,t,n,o,u,i){var a={$$typeof:h,type:e,key:r,ref:t,props:i,_owner:u};return a._store={},Object.defineProperty(a._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(a,"_self",{configurable:!1,enumerable:!1,writable:!1,value:n}),Object.defineProperty(a,"_source",{configurable:!1,enumerable:!1,writable:!1,value:o}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a};function rr(e,r,t,n,o){{var u,i={},a=null,v=null;t!==void 0&&(Re(t),a=""+t),ze(r)&&(Re(r.key),a=""+r.key),He(r)&&(v=r.ref,Xe(r,o));for(u in r)V.call(r,u)&&!Ge.hasOwnProperty(u)&&(i[u]=r[u]);if(e&&e.defaultProps){var l=e.defaultProps;for(u in l)i[u]===void 0&&(i[u]=l[u])}if(a||v){var f=typeof e=="function"?e.displayName||e.name||"Unknown":e;a&&Ze(i,f),v&&Qe(i,f)}return er(e,a,v,o,n,Y.current,i)}}var Q=S.ReactCurrentOwner,me=S.ReactDebugCurrentFrame;function F(e){if(e){var r=e._owner,t=B(e.type,e._source,r?r.type:null);me.setExtraStackFrame(t)}else me.setExtraStackFrame(null)}var ee;ee=!1;function re(e){return typeof e=="object"&&e!==null&&e.$$typeof===h}function _e(){{if(Q.current){var e=T(Q.current.type);if(e)return`
|
|
22
|
-
|
|
23
|
-
Check the render method of \``+e+"`."}return""}}function tr(e){return""}var Te={};function nr(e){{var r=_e();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=`
|
|
24
|
-
|
|
25
|
-
Check the top-level render call using <`+t+">.")}return r}}function Oe(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=nr(r);if(Te[t])return;Te[t]=!0;var n="";e&&e._owner&&e._owner!==Q.current&&(n=" It was passed a child from "+T(e._owner.type)+"."),F(e),d('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),F(null)}}function Pe(e,r){{if(typeof e!="object")return;if(X(e))for(var t=0;t<e.length;t++){var n=e[t];re(n)&&Oe(n,r)}else if(re(e))e._store&&(e._store.validated=!0);else if(e){var o=W(e);if(typeof o=="function"&&o!==e.entries)for(var u=o.call(e),i;!(i=u.next()).done;)re(i.value)&&Oe(i.value,r)}}}function ar(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===s||r.$$typeof===b))t=r.propTypes;else return;if(t){var n=T(r);qe(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!ee){ee=!0;var o=T(r);d("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",o||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&d("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ir(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if(n!=="children"&&n!=="key"){F(e),d("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),F(null);break}}e.ref!==null&&(F(e),d("Invalid attribute `ref` supplied to `React.Fragment`."),F(null))}}var Se={};function Ce(e,r,t,n,o,u){{var i=$e(e);if(!i){var a="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(a+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var v=tr();v?a+=v:a+=_e();var l;e===null?l="null":X(e)?l="array":e!==void 0&&e.$$typeof===h?(l="<"+(T(e.type)||"Unknown")+" />",a=" Did you accidentally export a JSX literal instead of a component?"):l=typeof e,d("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",l,a)}var f=rr(e,r,t,o,u);if(f==null)return f;if(i){var y=r.children;if(y!==void 0)if(n)if(X(y)){for(var A=0;A<y.length;A++)Pe(y[A],e);Object.freeze&&Object.freeze(y)}else d("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Pe(y,e)}if(V.call(r,"key")){var k=T(e),p=Object.keys(r).filter(function(cr){return cr!=="key"}),te=p.length>0?"{key: someKey, "+p.join(": ..., ")+": ...}":"{key: someKey}";if(!Se[k+te]){var fr=p.length>0?"{"+p.join(": ..., ")+": ...}":"{}";d(`A props object containing a "key" prop is being spread into JSX:
|
|
26
|
-
let props = %s;
|
|
27
|
-
<%s {...props} />
|
|
28
|
-
React keys must be passed directly to JSX without using spread:
|
|
29
|
-
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,te,k,fr,k),Se[k+te]=!0}}return e===E?ir(f):ar(f),f}}function or(e,r,t){return Ce(e,r,t,!0)}function ur(e,r,t){return Ce(e,r,t,!1)}var sr=ur,lr=or;M.Fragment=E,M.jsx=sr,M.jsxs=lr}()),M}process.env.NODE_ENV==="production"?ne.exports=vr():ne.exports=pr();var I=ne.exports;const yr=({src:C,srcWebm:h,width:j,height:E,thumbnail:m,ratio:O=0,className:P,loadingOverlay:R})=>{const s=g.useRef(null);return g.useEffect(()=>{s.current&&s.current.setRatio(O)},[O]),I.jsx(xe,{ref:s,width:j,height:E,src:C,srcWebm:h,className:P,thumbnail:m,loadingOverlay:R})},xe=g.memo(g.forwardRef(({src:C,srcWebm:h,width:j,height:E,thumbnail:m,className:O,loadingOverlay:P},R)=>{const s=g.useRef(null),[w,c]=g.useState(!0),b=g.useCallback(K=>{const W=s.current;if(!W)return;const S=W.duration;isNaN(S)||requestAnimationFrame(()=>{W.currentTime=Math.round(K*S*100)/100})},[]),_=dr.useRafThrottle(b);g.useImperativeHandle(R,()=>({setRatio:_}),[_]);const D=g.useCallback(()=>{c(!0)},[]),U=g.useCallback(()=>{c(!1)},[]);return I.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[I.jsxs("video",{ref:s,width:j,height:E,className:O,muted:!0,disablePictureInPicture:!0,disableRemotePlayback:!0,playsInline:!0,controls:!1,preload:"auto",onWaiting:D,onCanPlay:U,poster:m,children:[h&&I.jsx("source",{src:m?h:`${h}#t=0.1`,type:"video/webm"}),I.jsx("source",{src:m?C:`${C}#t=0.1`,type:"video/mp4"})]}),I.jsx("div",{style:{position:"absolute",inset:0},children:w&&P})]})}));exports.Video=yr;exports.VideoWithImperativeHandle=xe;
|
|
31
|
-
//# sourceMappingURL=index.cjs.js.map
|