@barabel324/react-player 0.0.1 → 0.0.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/dist/{index-DY6LmZAq.js → index-1pgUfxhC.js} +1 -1
- package/dist/{index-CtwCLqA8.js → index-BKNjwSFg.js} +1 -1
- package/dist/{index-B4aQ3fZe.js → index-Cu3vJcLM.js} +1 -1
- package/dist/{index-DqNJQSqH.js → index-Dnbs5lXl.js} +35 -36
- package/dist/{index-CEYCN7W2.js → index-DsBO-KZz.js} +1 -1
- package/dist/react-player.js +1 -1
- package/package.json +1 -2
|
@@ -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-Dnbs5lXl.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] : "";
|
|
@@ -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-Dnbs5lXl.js";
|
|
4
4
|
const m = async () => new Promise((t, n) => {
|
|
5
5
|
if (window.VK?.VideoPlayer) {
|
|
6
6
|
t(window.VK);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsx as s, jsxs as y } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as d, useContext as v, useReducer as
|
|
3
|
-
import m from "classix";
|
|
2
|
+
import { createContext as d, useContext as v, useReducer as _, lazy as p, useMemo as $, useRef as C } from "react";
|
|
4
3
|
const n = {
|
|
5
4
|
show: "show",
|
|
6
5
|
hide: "hide",
|
|
@@ -11,7 +10,7 @@ const n = {
|
|
|
11
10
|
showButton: !1,
|
|
12
11
|
showPreview: !0,
|
|
13
12
|
canplay: !1
|
|
14
|
-
},
|
|
13
|
+
}, k = (e, t) => {
|
|
15
14
|
const { type: r } = t;
|
|
16
15
|
switch (r) {
|
|
17
16
|
case n.show:
|
|
@@ -27,29 +26,29 @@ const n = {
|
|
|
27
26
|
default:
|
|
28
27
|
return e;
|
|
29
28
|
}
|
|
30
|
-
},
|
|
31
|
-
}),
|
|
32
|
-
const [t, r] =
|
|
33
|
-
return /* @__PURE__ */ s(
|
|
34
|
-
},
|
|
35
|
-
const e = v(
|
|
29
|
+
}, m = d(P), b = d(() => {
|
|
30
|
+
}), N = ({ children: e }) => {
|
|
31
|
+
const [t, r] = _(k, P);
|
|
32
|
+
return /* @__PURE__ */ s(m.Provider, { value: t, children: /* @__PURE__ */ s(b.Provider, { value: r, children: e }) });
|
|
33
|
+
}, E = () => {
|
|
34
|
+
const e = v(m);
|
|
36
35
|
if (e === void 0)
|
|
37
36
|
throw new Error("usePlayerState нужно использовать внутри PlayerProvider");
|
|
38
37
|
return e;
|
|
39
|
-
},
|
|
40
|
-
const e = v(
|
|
38
|
+
}, R = () => {
|
|
39
|
+
const e = v(b);
|
|
41
40
|
if (e === void 0)
|
|
42
41
|
throw new Error("usePlayerDispatch нужно использовать внутри PlayerProvider");
|
|
43
42
|
return e;
|
|
44
|
-
},
|
|
45
|
-
parent:
|
|
46
|
-
},
|
|
43
|
+
}, S = "idmrp-button-play", T = {
|
|
44
|
+
parent: S
|
|
45
|
+
}, g = ({
|
|
47
46
|
className: e,
|
|
48
47
|
onClick: t
|
|
49
48
|
}) => /* @__PURE__ */ s(
|
|
50
49
|
"button",
|
|
51
50
|
{
|
|
52
|
-
className:
|
|
51
|
+
className: [T.parent, e].join(" "),
|
|
53
52
|
type: "button",
|
|
54
53
|
onClick: t
|
|
55
54
|
}
|
|
@@ -59,26 +58,26 @@ const n = {
|
|
|
59
58
|
button: `${c}__button`,
|
|
60
59
|
preview: `${c}__preview`,
|
|
61
60
|
player: `${c}__player`
|
|
62
|
-
},
|
|
61
|
+
}, j = ({
|
|
63
62
|
className: e,
|
|
64
63
|
preview: t,
|
|
65
64
|
onPlay: r,
|
|
66
65
|
children: a
|
|
67
66
|
}) => {
|
|
68
|
-
const { showButton: i, showPreview: l, canplay:
|
|
69
|
-
|
|
67
|
+
const { showButton: i, showPreview: l, canplay: f } = E(), B = R(), x = () => {
|
|
68
|
+
f && (B({
|
|
70
69
|
type: n.hide
|
|
71
70
|
}), r && r());
|
|
72
71
|
};
|
|
73
|
-
return /* @__PURE__ */ y("div", { className:
|
|
72
|
+
return /* @__PURE__ */ y("div", { className: [u.parent, e].join(" "), children: [
|
|
74
73
|
(i || t && l) && /* @__PURE__ */ y(
|
|
75
74
|
"div",
|
|
76
75
|
{
|
|
77
76
|
className: u.wrapper,
|
|
78
|
-
onClick:
|
|
77
|
+
onClick: x,
|
|
79
78
|
children: [
|
|
80
79
|
i && /* @__PURE__ */ s(
|
|
81
|
-
|
|
80
|
+
g,
|
|
82
81
|
{
|
|
83
82
|
className: u.button
|
|
84
83
|
}
|
|
@@ -94,29 +93,29 @@ const n = {
|
|
|
94
93
|
rutube: "rutube",
|
|
95
94
|
video: "video",
|
|
96
95
|
vk: "vk"
|
|
97
|
-
},
|
|
98
|
-
[o.youtube]: p(async () => await import("./index-
|
|
99
|
-
[o.rutube]: p(async () => await import("./index-
|
|
100
|
-
[o.video]: p(async () => await import("./index-
|
|
101
|
-
[o.vk]: p(async () => await import("./index-
|
|
102
|
-
},
|
|
96
|
+
}, D = {
|
|
97
|
+
[o.youtube]: p(async () => await import("./index-1pgUfxhC.js")),
|
|
98
|
+
[o.rutube]: p(async () => await import("./index-DsBO-KZz.js")),
|
|
99
|
+
[o.video]: p(async () => await import("./index-Cu3vJcLM.js")),
|
|
100
|
+
[o.vk]: p(async () => await import("./index-BKNjwSFg.js"))
|
|
101
|
+
}, V = (e) => {
|
|
103
102
|
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\/))/, a = /^(?:https?:\/\/)?(?:www\.|m\.)?(?:vk\.com|vkvideo\.ru)\/.+$/;
|
|
104
103
|
return r.test(e) ? o.rutube : t.test(e) ? o.youtube : a.test(e) ? o.vk : o.video;
|
|
105
104
|
}, w = "idmrp-player", h = {
|
|
106
105
|
parent: w,
|
|
107
106
|
player: `${w}__player`
|
|
108
|
-
},
|
|
107
|
+
}, A = ({
|
|
109
108
|
url: e,
|
|
110
109
|
preview: t
|
|
111
110
|
}) => {
|
|
112
|
-
const r =
|
|
113
|
-
const l =
|
|
114
|
-
return
|
|
115
|
-
}, [e]), a =
|
|
111
|
+
const r = $(() => {
|
|
112
|
+
const l = V(e);
|
|
113
|
+
return D[l];
|
|
114
|
+
}, [e]), a = C(null), i = () => {
|
|
116
115
|
a.current && a.current.play();
|
|
117
116
|
};
|
|
118
117
|
return /* @__PURE__ */ s(
|
|
119
|
-
|
|
118
|
+
j,
|
|
120
119
|
{
|
|
121
120
|
className: h.parent,
|
|
122
121
|
preview: t,
|
|
@@ -131,9 +130,9 @@ const n = {
|
|
|
131
130
|
)
|
|
132
131
|
}
|
|
133
132
|
);
|
|
134
|
-
},
|
|
133
|
+
}, Y = (e) => /* @__PURE__ */ s(N, { children: /* @__PURE__ */ s(A, { ...e }) });
|
|
135
134
|
export {
|
|
136
135
|
n as P,
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
Y as a,
|
|
137
|
+
R as u
|
|
139
138
|
};
|
package/dist/react-player.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barabel324/react-player",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/react-player.js",
|
|
6
6
|
"exports": {
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
"@types/react": "^19.1.10",
|
|
30
30
|
"@types/react-dom": "^19.1.7",
|
|
31
31
|
"@vitejs/plugin-react": "^5.0.0",
|
|
32
|
-
"classix": "^2.2.2",
|
|
33
32
|
"eslint": "^9.33.0",
|
|
34
33
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
35
34
|
"eslint-plugin-react-refresh": "^0.4.20",
|