@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.
@@ -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-DqNJQSqH.js";
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-DqNJQSqH.js";
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,5 +1,5 @@
1
1
  import { jsx as y } from "react/jsx-runtime";
2
- import { u as d, P as t } from "./index-DqNJQSqH.js";
2
+ import { u as d, P as t } from "./index-Dnbs5lXl.js";
3
3
  import { useRef as i, useImperativeHandle as P } from "react";
4
4
  const v = ({
5
5
  className: n,
@@ -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 $, lazy as p, useMemo as C, useRef as k } from "react";
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
- }, N = (e, t) => {
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
- }, b = d(P), f = d(() => {
31
- }), E = ({ children: e }) => {
32
- const [t, r] = $(N, P);
33
- return /* @__PURE__ */ s(b.Provider, { value: t, children: /* @__PURE__ */ s(f.Provider, { value: r, children: e }) });
34
- }, R = () => {
35
- const e = v(b);
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
- }, S = () => {
40
- const e = v(f);
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
- }, T = "idmrp-button-play", g = {
45
- parent: T
46
- }, D = ({
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: m(g.parent, e),
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
- }, V = ({
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: B } = R(), x = S(), _ = () => {
69
- B && (x({
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: m(u.parent, e), children: [
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
- D,
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
- }, j = {
98
- [o.youtube]: p(async () => await import("./index-DY6LmZAq.js")),
99
- [o.rutube]: p(async () => await import("./index-CEYCN7W2.js")),
100
- [o.video]: p(async () => await import("./index-B4aQ3fZe.js")),
101
- [o.vk]: p(async () => await import("./index-CtwCLqA8.js"))
102
- }, A = (e) => {
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
- }, L = ({
107
+ }, A = ({
109
108
  url: e,
110
109
  preview: t
111
110
  }) => {
112
- const r = C(() => {
113
- const l = A(e);
114
- return j[l];
115
- }, [e]), a = k(null), i = () => {
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
- V,
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
- }, I = (e) => /* @__PURE__ */ s(E, { children: /* @__PURE__ */ s(L, { ...e }) });
133
+ }, Y = (e) => /* @__PURE__ */ s(N, { children: /* @__PURE__ */ s(A, { ...e }) });
135
134
  export {
136
135
  n as P,
137
- I as a,
138
- S as u
136
+ Y as a,
137
+ R as u
139
138
  };
@@ -1,5 +1,5 @@
1
1
  import { jsx as i } from "react/jsx-runtime";
2
- import { u as p } from "./index-DqNJQSqH.js";
2
+ import { u as p } from "./index-Dnbs5lXl.js";
3
3
  import { useRef as c, useImperativeHandle as f, useEffect as l } from "react";
4
4
  const w = ({
5
5
  className: t,
@@ -1,4 +1,4 @@
1
- import { a as e } from "./index-DqNJQSqH.js";
1
+ import { a as e } from "./index-Dnbs5lXl.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.1",
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",