@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 CHANGED
@@ -41,8 +41,8 @@ const PreviewImage = () => (
41
41
  <Player
42
42
  url={url}
43
43
  components={{
44
- button: PlayButton,
45
- previewPicture: PreviewImage,
44
+ button: () => PlayButton,
45
+ previewPicture: () => PreviewImage,
46
46
  }}
47
47
  />
48
48
  ```
@@ -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 N, useRef as C } from "react";
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
- ButtonComponent: u,
75
- PreviewPictureComponent: l
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 ? /* @__PURE__ */ o(u, {}) : /* @__PURE__ */ o(
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 ? /* @__PURE__ */ o(l, {}) : t && /* @__PURE__ */ o("img", { className: y.playerPreview__preview, src: t.src, alt: t.alt ?? "preview" }))
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-DECHm14m.js")),
117
- [s.rutube]: v(async () => await import("./index-pr5RFd69.js")),
118
- [s.video]: v(async () => await import("./index-Bu1TBomL.js")),
119
- [s.vk]: v(async () => await import("./index-Cr0yHksH.js"))
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, _ = N(() => {
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 = C(null), P = () => {
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
- ButtonComponent: p,
156
- PreviewPictureComponent: c,
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-Cqi0pvqf.js";
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,5 +1,5 @@
1
1
  import { jsx as y } from "react/jsx-runtime";
2
- import { u as d, P as t } from "./index-Cqi0pvqf.js";
2
+ import { u as d, P as t } from "./index-B8sUd3YU.js";
3
3
  import { useRef as i, useImperativeHandle as P } from "react";
4
4
  const v = ({
5
5
  className: n,
@@ -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-Cqi0pvqf.js";
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] : "";
@@ -1,5 +1,5 @@
1
1
  import { jsx as i } from "react/jsx-runtime";
2
- import { u as p } from "./index-Cqi0pvqf.js";
2
+ import { u as p } from "./index-B8sUd3YU.js";
3
3
  import { useRef as c, useImperativeHandle as f, useEffect as l } from "react";
4
4
  const w = ({
5
5
  className: a,
@@ -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: FCClass;
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: FCClass;
35
+ component: () => ReactNode;
35
36
  };
36
37
  /** кнопка, которая отображаентся, когда видео загрузилось */
37
38
  button: {
38
39
  /** компонент кнопки */
39
- component: FCClass;
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
- PreviewPictureComponent?: FCClass<Record<string, any>>;
76
- ButtonComponent?: FCClass<Record<string, any>>;
76
+ renderPreviewPicture?: () => ReactNode;
77
+ renderButton?: () => ReactNode;
77
78
  onPlay?: () => void;
78
79
  };
79
80
 
@@ -1,4 +1,4 @@
1
- import { a as e } from "./index-Cqi0pvqf.js";
1
+ import { a as e } from "./index-B8sUd3YU.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.7",
3
+ "version": "0.0.8",
4
4
  "type": "module",
5
5
  "main": "./dist/react-player.js",
6
6
  "types": "./dist/react-player.d.ts",