@barabel324/react-player 0.0.10 → 0.0.11

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.
@@ -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-DUNavqhH.js";
3
+ import { u as f } from "./index-CbgYp99p.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,73 +1,54 @@
1
1
  import { jsx as a, jsxs as d } from "react/jsx-runtime";
2
- import { createContext as b, useContext as m, useReducer as g, lazy as _, useMemo as k, useRef as q } from "react";
2
+ import { createContext as b, useContext as m, lazy as _, useReducer as g, useMemo as k, useRef as q } from "react";
3
3
  function v() {
4
4
  let e, r = "", t = 0;
5
5
  for (; t < arguments.length; ) (e = arguments[t++]) && typeof e == "string" && (r && (r += " "), r += e);
6
6
  return r;
7
7
  }
8
- const c = {
9
- show: "show",
10
- hide: "hide",
11
- showButton: "showButton",
12
- hideButton: "hideButton",
13
- canplay: "canplay"
14
- }, f = {
8
+ const E = "_button_1xali_2", R = {
9
+ button: E
10
+ }, S = ({
11
+ className: e,
12
+ onClick: r
13
+ }) => /* @__PURE__ */ a(
14
+ "button",
15
+ {
16
+ className: v(
17
+ R.button,
18
+ e
19
+ ),
20
+ type: "button",
21
+ onClick: r
22
+ }
23
+ ), f = {
15
24
  showButton: !1,
16
25
  showPreview: !0,
17
26
  canplay: !1
18
- }, E = (e, r) => {
19
- const { type: t } = r;
20
- switch (t) {
21
- case c.show:
22
- return { ...e, showButton: !0, showPreview: !0 };
23
- case c.hide:
24
- return { ...e, showButton: !1, showPreview: !1 };
25
- case c.showButton:
26
- return { ...e, showButton: !0 };
27
- case c.hideButton:
28
- return { ...e, showButton: !1 };
29
- case c.canplay:
30
- return { ...e, canplay: !0, showButton: !0 };
31
- default:
32
- return e;
33
- }
34
27
  }, B = b(f), x = b(() => {
35
- }), R = ({ children: e }) => {
36
- const [r, t] = g(E, f);
37
- return /* @__PURE__ */ a(B.Provider, { value: r, children: /* @__PURE__ */ a(x.Provider, { value: t, children: e }) });
38
- }, S = () => {
28
+ }), T = () => {
39
29
  const e = m(B);
40
30
  if (e === void 0)
41
31
  throw new Error("usePlayerState нужно использовать внутри PlayerProvider");
42
32
  return e;
43
- }, T = () => {
33
+ }, C = () => {
44
34
  const e = m(x);
45
35
  if (e === void 0)
46
36
  throw new Error("usePlayerDispatch нужно использовать внутри PlayerProvider");
47
37
  return e;
48
- }, C = "_button_1xali_2", $ = {
49
- button: C
50
- }, D = ({
51
- className: e,
52
- onClick: r
53
- }) => /* @__PURE__ */ a(
54
- "button",
55
- {
56
- className: v(
57
- $.button,
58
- e
59
- ),
60
- type: "button",
61
- onClick: r
62
- }
63
- ), V = "_playerPreview_lqhcw_1", j = "_playerPreview__wrapper_lqhcw_7", A = "_playerPreview__wrapper_cursor_lqhcw_11", L = "_playerPreview__button_lqhcw_14", O = "_playerPreview__preview_lqhcw_21", Y = "_playerPreview__player_lqhcw_30", o = {
64
- playerPreview: V,
65
- playerPreview__wrapper: j,
66
- playerPreview__wrapper_cursor: A,
67
- playerPreview__button: L,
68
- playerPreview__preview: O,
69
- playerPreview__player: Y
70
- }, z = ({
38
+ }, c = {
39
+ show: "show",
40
+ hide: "hide",
41
+ showButton: "showButton",
42
+ hideButton: "hideButton",
43
+ canplay: "canplay"
44
+ }, $ = "_playerPreview_lqhcw_1", D = "_playerPreview__wrapper_lqhcw_7", V = "_playerPreview__wrapper_cursor_lqhcw_11", j = "_playerPreview__button_lqhcw_14", A = "_playerPreview__preview_lqhcw_21", L = "_playerPreview__player_lqhcw_30", o = {
45
+ playerPreview: $,
46
+ playerPreview__wrapper: D,
47
+ playerPreview__wrapper_cursor: V,
48
+ playerPreview__button: j,
49
+ playerPreview__preview: A,
50
+ playerPreview__player: L
51
+ }, O = ({
71
52
  className: e,
72
53
  preview: r,
73
54
  onPlay: t,
@@ -75,7 +56,7 @@ const c = {
75
56
  buttonComponent: n,
76
57
  previewPictureComponent: l
77
58
  }) => {
78
- const { showButton: i, showPreview: p, canplay: P } = S(), y = T(), h = () => {
59
+ const { showButton: i, showPreview: p, canplay: P } = T(), y = C(), h = () => {
79
60
  P && (y({
80
61
  type: c.hide
81
62
  }), t && t());
@@ -98,7 +79,7 @@ const c = {
98
79
  onClick: h,
99
80
  children: [
100
81
  i && (n ? /* @__PURE__ */ a(n.component, { className: o.playerPreview__button, ...n.props }) : /* @__PURE__ */ a(
101
- D,
82
+ S,
102
83
  {
103
84
  className: o.playerPreview__button
104
85
  }
@@ -116,22 +97,41 @@ const c = {
116
97
  rutube: "rutube",
117
98
  video: "video",
118
99
  vk: "vk"
119
- }, I = {
120
- [s.youtube]: _(async () => await import("./index-FsQN9AUJ.js")),
121
- [s.rutube]: _(async () => await import("./index-C4BbrYIr.js")),
122
- [s.video]: _(async () => await import("./index-DSFxsWiZ.js")),
123
- [s.vk]: _(async () => await import("./index-Bpmt5HjW.js"))
124
- }, M = (e) => {
100
+ }, Y = {
101
+ [s.youtube]: _(async () => await import("./index-CLC2KZWC.js")),
102
+ [s.rutube]: _(async () => await import("./index-DKL3JxMY.js")),
103
+ [s.video]: _(async () => await import("./index-hAoMgMeI.js")),
104
+ [s.vk]: _(async () => await import("./index-DsPXrYFA.js"))
105
+ }, z = (e) => {
125
106
  const r = /^(?:https?:\/\/)?(?:m\.|www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/, t = /^(?:https?:\/\/)?(?:rutu\.be\/|rutube\.ru(\/play\/))/, u = /^(?:https?:\/\/)?(?:www\.|m\.)?(?:vk\.com|vkvideo\.ru)\/.+$/;
126
107
  return t.test(e) ? s.rutube : r.test(e) ? s.youtube : u.test(e) ? s.vk : s.video;
127
- }, U = "_player_1afml_1", F = {
128
- player: U
108
+ }, I = "_player_1afml_1", M = {
109
+ player: I
110
+ }, U = (e, r) => {
111
+ const { type: t } = r;
112
+ switch (t) {
113
+ case c.show:
114
+ return { ...e, showButton: !0, showPreview: !0 };
115
+ case c.hide:
116
+ return { ...e, showButton: !1, showPreview: !1 };
117
+ case c.showButton:
118
+ return { ...e, showButton: !0 };
119
+ case c.hideButton:
120
+ return { ...e, showButton: !1 };
121
+ case c.canplay:
122
+ return { ...e, canplay: !0, showButton: !0 };
123
+ default:
124
+ return e;
125
+ }
126
+ }, F = ({ children: e }) => {
127
+ const [r, t] = g(U, f);
128
+ return /* @__PURE__ */ a(B.Provider, { value: r, children: /* @__PURE__ */ a(x.Provider, { value: t, children: e }) });
129
129
  }, G = ({
130
130
  children: e,
131
131
  hasPreview: r,
132
132
  ...t
133
133
  }) => r ? /* @__PURE__ */ a(
134
- z,
134
+ O,
135
135
  {
136
136
  ...t,
137
137
  children: e
@@ -144,8 +144,8 @@ const c = {
144
144
  components: n
145
145
  }) => {
146
146
  const l = u?.player, i = n?.button, p = n?.previewPicture, P = k(() => {
147
- const N = M(r);
148
- return I[N];
147
+ const N = z(r);
148
+ return Y[N];
149
149
  }, [r]), y = q(null), h = () => {
150
150
  y.current && y.current.play();
151
151
  }, w = !!t || !!p;
@@ -162,7 +162,7 @@ const c = {
162
162
  P,
163
163
  {
164
164
  className: v(
165
- l ?? F.player,
165
+ l ?? M.player,
166
166
  !w && e
167
167
  ),
168
168
  ref: y,
@@ -171,9 +171,9 @@ const c = {
171
171
  )
172
172
  }
173
173
  );
174
- }, Q = (e) => /* @__PURE__ */ a(R, { children: /* @__PURE__ */ a(H, { ...e }) });
174
+ }, Q = (e) => /* @__PURE__ */ a(F, { children: /* @__PURE__ */ a(H, { ...e }) });
175
175
  export {
176
176
  c as P,
177
177
  Q as a,
178
- T as u
178
+ C as u
179
179
  };
@@ -1,5 +1,5 @@
1
1
  import { jsx as i } from "react/jsx-runtime";
2
- import { u as p } from "./index-DUNavqhH.js";
2
+ import { u as p } from "./index-CbgYp99p.js";
3
3
  import { useRef as c, useImperativeHandle as f, useEffect as l } from "react";
4
4
  const w = ({
5
5
  className: t,
@@ -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-DUNavqhH.js";
3
+ import { u as p } from "./index-CbgYp99p.js";
4
4
  const m = async () => new Promise((t, n) => {
5
5
  if (window.VK?.VideoPlayer) {
6
6
  t(window.VK);
@@ -1,5 +1,5 @@
1
1
  import { jsx as y } from "react/jsx-runtime";
2
- import { u as d, P as t } from "./index-DUNavqhH.js";
2
+ import { u as d, P as t } from "./index-CbgYp99p.js";
3
3
  import { useRef as i, useImperativeHandle as P } from "react";
4
4
  const v = ({
5
5
  className: n,
@@ -1,4 +1,4 @@
1
- import { a as e } from "./index-DUNavqhH.js";
1
+ import { a as e } from "./index-CbgYp99p.js";
2
2
  export {
3
3
  e as Player
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barabel324/react-player",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "type": "module",
5
5
  "main": "./dist/react-player.js",
6
6
  "types": "./dist/react-player.d.ts",