@react-scrollytelling/video 0.3.0 → 0.3.2
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/package.json +5 -11
- package/dist/index.cjs +0 -215
- package/dist/index.d.cts +0 -38
- package/dist/index.d.cts.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-scrollytelling/video",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "@hsunpei",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
10
10
|
"homepage": "https://github.com/hsunpei/react-scrollytelling#readme",
|
|
11
|
-
"
|
|
12
|
-
"
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "dist/index.mjs",
|
|
13
13
|
"types": "dist/index.d.mts",
|
|
14
14
|
"sideEffects": false,
|
|
15
15
|
"files": [
|
|
@@ -17,14 +17,8 @@
|
|
|
17
17
|
],
|
|
18
18
|
"exports": {
|
|
19
19
|
".": {
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
"default": "./dist/index.mjs"
|
|
23
|
-
},
|
|
24
|
-
"require": {
|
|
25
|
-
"types": "./dist/index.d.cts",
|
|
26
|
-
"default": "./dist/index.cjs"
|
|
27
|
-
}
|
|
20
|
+
"types": "./dist/index.d.mts",
|
|
21
|
+
"import": "./dist/index.mjs"
|
|
28
22
|
}
|
|
29
23
|
},
|
|
30
24
|
"repository": {
|
package/dist/index.cjs
DELETED
|
@@ -1,215 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
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
|
package/dist/index.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|