@barabel324/react-player 0.0.7 → 0.0.8
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/README.md +2 -2
- package/dist/{index-Cqi0pvqf.js → index-B8sUd3YU.js} +13 -13
- package/dist/{index-Cr0yHksH.js → index-C8oYhGns.js} +1 -1
- package/dist/{index-Bu1TBomL.js → index-CczXORYY.js} +1 -1
- package/dist/{index-DECHm14m.js → index-Dj9G-CFc.js} +1 -1
- package/dist/{index-pr5RFd69.js → index-P3WMQDqC.js} +1 -1
- package/dist/react-player.d.ts +6 -5
- package/dist/react-player.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as o, jsxs as d } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as b, useContext as f, useReducer as k, lazy as v, useMemo as
|
|
2
|
+
import { createContext as b, useContext as f, useReducer as k, lazy as v, useMemo as C, useRef as N } from "react";
|
|
3
3
|
function h() {
|
|
4
4
|
let e, t = "", r = 0;
|
|
5
5
|
for (; r < arguments.length; ) (e = arguments[r++]) && typeof e == "string" && (t && (t += " "), t += e);
|
|
@@ -71,8 +71,8 @@ const a = {
|
|
|
71
71
|
preview: t,
|
|
72
72
|
onPlay: r,
|
|
73
73
|
children: n,
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
renderButton: u,
|
|
75
|
+
renderPreviewPicture: l
|
|
76
76
|
}) => {
|
|
77
77
|
const { showButton: p, showPreview: c, canplay: _ } = S(), i = T(), P = () => {
|
|
78
78
|
_ && (i({
|
|
@@ -93,13 +93,13 @@ const a = {
|
|
|
93
93
|
className: y.playerPreview__wrapper,
|
|
94
94
|
onClick: P,
|
|
95
95
|
children: [
|
|
96
|
-
p && (u ?
|
|
96
|
+
p && (u ? u() : /* @__PURE__ */ o(
|
|
97
97
|
V,
|
|
98
98
|
{
|
|
99
99
|
className: y.playerPreview__button
|
|
100
100
|
}
|
|
101
101
|
)),
|
|
102
|
-
w && c && (l ?
|
|
102
|
+
w && c && (l ? l() : t && /* @__PURE__ */ o("img", { className: y.playerPreview__preview, src: t.src, alt: t.alt ?? "preview" }))
|
|
103
103
|
]
|
|
104
104
|
}
|
|
105
105
|
),
|
|
@@ -113,10 +113,10 @@ const a = {
|
|
|
113
113
|
video: "video",
|
|
114
114
|
vk: "vk"
|
|
115
115
|
}, I = {
|
|
116
|
-
[s.youtube]: v(async () => await import("./index-
|
|
117
|
-
[s.rutube]: v(async () => await import("./index-
|
|
118
|
-
[s.video]: v(async () => await import("./index-
|
|
119
|
-
[s.vk]: v(async () => await import("./index-
|
|
116
|
+
[s.youtube]: v(async () => await import("./index-Dj9G-CFc.js")),
|
|
117
|
+
[s.rutube]: v(async () => await import("./index-P3WMQDqC.js")),
|
|
118
|
+
[s.video]: v(async () => await import("./index-CczXORYY.js")),
|
|
119
|
+
[s.vk]: v(async () => await import("./index-C8oYhGns.js"))
|
|
120
120
|
}, M = (e) => {
|
|
121
121
|
const t = /^(?:https?:\/\/)?(?:m\.|www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/, r = /^(?:https?:\/\/)?(?:rutu\.be\/|rutube\.ru(\/play\/))/, n = /^(?:https?:\/\/)?(?:www\.|m\.)?(?:vk\.com|vkvideo\.ru)\/.+$/;
|
|
122
122
|
return r.test(e) ? s.rutube : t.test(e) ? s.youtube : n.test(e) ? s.vk : s.video;
|
|
@@ -139,10 +139,10 @@ const a = {
|
|
|
139
139
|
classNames: n,
|
|
140
140
|
components: u
|
|
141
141
|
}) => {
|
|
142
|
-
const l = n?.player, p = u?.button, c = u?.previewPicture, _ =
|
|
142
|
+
const l = n?.player, p = u?.button, c = u?.previewPicture, _ = C(() => {
|
|
143
143
|
const g = M(t);
|
|
144
144
|
return I[g];
|
|
145
|
-
}, [t]), i =
|
|
145
|
+
}, [t]), i = N(null), P = () => {
|
|
146
146
|
i.current && i.current.play();
|
|
147
147
|
}, w = !!r || !!c;
|
|
148
148
|
return /* @__PURE__ */ o(
|
|
@@ -152,8 +152,8 @@ const a = {
|
|
|
152
152
|
className: e,
|
|
153
153
|
preview: r,
|
|
154
154
|
onPlay: P,
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
renderButton: p,
|
|
156
|
+
renderPreviewPicture: c,
|
|
157
157
|
children: /* @__PURE__ */ o(
|
|
158
158
|
_,
|
|
159
159
|
{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as d } from "react/jsx-runtime";
|
|
2
2
|
import { useRef as a, useImperativeHandle as l, useEffect as u } from "react";
|
|
3
|
-
import { u as p } from "./index-
|
|
3
|
+
import { u as p } from "./index-B8sUd3YU.js";
|
|
4
4
|
const m = async () => new Promise((t, n) => {
|
|
5
5
|
if (window.VK?.VideoPlayer) {
|
|
6
6
|
t(window.VK);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as l } from "react/jsx-runtime";
|
|
2
2
|
import { useRef as s, useImperativeHandle as p, useEffect as y } from "react";
|
|
3
|
-
import { u as f } from "./index-
|
|
3
|
+
import { u as f } from "./index-B8sUd3YU.js";
|
|
4
4
|
const m = (t) => {
|
|
5
5
|
const n = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*/, o = t.match(n);
|
|
6
6
|
return o && o[7].length === 11 ? o[7] : "";
|
package/dist/react-player.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
1
2
|
import { RefObject } from 'react';
|
|
2
3
|
|
|
3
4
|
/** Утилитарный дженерик для обозначения функционального компонента с пропсами children и className */
|
|
@@ -13,7 +14,7 @@ declare type KeysWithClassNames = {
|
|
|
13
14
|
|
|
14
15
|
declare type KeysWithComponent = {
|
|
15
16
|
[K in keyof TMapComponents]: TMapComponents[K] extends {
|
|
16
|
-
component:
|
|
17
|
+
component: () => ReactNode;
|
|
17
18
|
} ? K : never;
|
|
18
19
|
}[keyof TMapComponents];
|
|
19
20
|
|
|
@@ -31,12 +32,12 @@ declare type TMapComponents = {
|
|
|
31
32
|
/** изображение превью */
|
|
32
33
|
previewPicture: {
|
|
33
34
|
/** компонент изображения */
|
|
34
|
-
component:
|
|
35
|
+
component: () => ReactNode;
|
|
35
36
|
};
|
|
36
37
|
/** кнопка, которая отображаентся, когда видео загрузилось */
|
|
37
38
|
button: {
|
|
38
39
|
/** компонент кнопки */
|
|
39
|
-
component:
|
|
40
|
+
component: () => ReactNode;
|
|
40
41
|
};
|
|
41
42
|
/** Плеер */
|
|
42
43
|
player: {
|
|
@@ -72,8 +73,8 @@ declare type TPlayerPreview = {
|
|
|
72
73
|
/** Альт изображения */
|
|
73
74
|
alt: string;
|
|
74
75
|
};
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
renderPreviewPicture?: () => ReactNode;
|
|
77
|
+
renderButton?: () => ReactNode;
|
|
77
78
|
onPlay?: () => void;
|
|
78
79
|
};
|
|
79
80
|
|
package/dist/react-player.js
CHANGED