@devix-technologies/react-gjirafa-vp-player 1.0.15 → 1.0.17

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.
@@ -100,11 +100,11 @@ function xt() {
100
100
  }
101
101
  if (v) {
102
102
  v = console;
103
- var T = v.error, L = typeof Symbol == "function" && Symbol.toStringTag && o[Symbol.toStringTag] || o.constructor.name || "Object";
103
+ var T = v.error, F = typeof Symbol == "function" && Symbol.toStringTag && o[Symbol.toStringTag] || o.constructor.name || "Object";
104
104
  return T.call(
105
105
  v,
106
106
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
107
- L
107
+ F
108
108
  ), t(o);
109
109
  }
110
110
  }
@@ -151,7 +151,7 @@ function xt() {
151
151
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
152
152
  )), o = this.props.ref, o !== void 0 ? o : null;
153
153
  }
154
- function m(o, v, T, L, te, G, _e, Se) {
154
+ function m(o, v, T, F, te, G, _e, Se) {
155
155
  return T = G.ref, o = {
156
156
  $$typeof: x,
157
157
  type: o,
@@ -183,13 +183,13 @@ function xt() {
183
183
  value: Se
184
184
  }), Object.freeze && (Object.freeze(o.props), Object.freeze(o)), o;
185
185
  }
186
- function l(o, v, T, L, te, G, _e, Se) {
186
+ function l(o, v, T, F, te, G, _e, Se) {
187
187
  var V = v.children;
188
188
  if (V !== void 0)
189
- if (L)
189
+ if (F)
190
190
  if (j(V)) {
191
- for (L = 0; L < V.length; L++)
192
- p(V[L]);
191
+ for (F = 0; F < V.length; F++)
192
+ p(V[F]);
193
193
  Object.freeze && Object.freeze(V);
194
194
  } else
195
195
  console.error(
@@ -201,18 +201,18 @@ function xt() {
201
201
  var re = Object.keys(v).filter(function(mt) {
202
202
  return mt !== "key";
203
203
  });
204
- L = 0 < re.length ? "{key: someKey, " + re.join(": ..., ") + ": ...}" : "{key: someKey}", ee[V + L] || (re = 0 < re.length ? "{" + re.join(": ..., ") + ": ...}" : "{}", console.error(
204
+ F = 0 < re.length ? "{key: someKey, " + re.join(": ..., ") + ": ...}" : "{key: someKey}", ee[V + F] || (re = 0 < re.length ? "{" + re.join(": ..., ") + ": ...}" : "{}", console.error(
205
205
  `A props object containing a "key" prop is being spread into JSX:
206
206
  let props = %s;
207
207
  <%s {...props} />
208
208
  React keys must be passed directly to JSX without using spread:
209
209
  let props = %s;
210
210
  <%s key={someKey} {...props} />`,
211
- L,
211
+ F,
212
212
  V,
213
213
  re,
214
214
  V
215
- ), ee[V + L] = !0);
215
+ ), ee[V + F] = !0);
216
216
  }
217
217
  if (V = null, T !== void 0 && (r(T), V = "" + T), s(v) && (r(v.key), V = "" + v.key), "key" in v) {
218
218
  T = {};
@@ -248,26 +248,26 @@ React keys must be passed directly to JSX without using spread:
248
248
  b,
249
249
  i
250
250
  )(), Q = U(n(i)), ee = {};
251
- ce.Fragment = f, ce.jsx = function(o, v, T, L, te) {
251
+ ce.Fragment = f, ce.jsx = function(o, v, T, F, te) {
252
252
  var G = 1e4 > $.recentlyCreatedOwnerStacks++;
253
253
  return l(
254
254
  o,
255
255
  v,
256
256
  T,
257
257
  !1,
258
- L,
258
+ F,
259
259
  te,
260
260
  G ? Error("react-stack-top-frame") : J,
261
261
  G ? U(n(o)) : Q
262
262
  );
263
- }, ce.jsxs = function(o, v, T, L, te) {
263
+ }, ce.jsxs = function(o, v, T, F, te) {
264
264
  var G = 1e4 > $.recentlyCreatedOwnerStacks++;
265
265
  return l(
266
266
  o,
267
267
  v,
268
268
  T,
269
269
  !0,
270
- L,
270
+ F,
271
271
  te,
272
272
  G ? Error("react-stack-top-frame") : J,
273
273
  G ? U(n(o)) : Q
@@ -329,9 +329,9 @@ var Et = /* @__PURE__ */ function() {
329
329
  return (a = n.parentNode) == null ? void 0 : a.removeChild(n);
330
330
  }), this.tags = [], this.ctr = 0;
331
331
  }, e;
332
- }(), B = "-ms-", we = "-moz-", k = "-webkit-", nt = "comm", Fe = "rule", Le = "decl", _t = "@import", at = "@keyframes", St = "@layer", Rt = Math.abs, ke = String.fromCharCode, At = Object.assign;
332
+ }(), B = "-ms-", we = "-moz-", k = "-webkit-", nt = "comm", Le = "rule", Fe = "decl", _t = "@import", at = "@keyframes", St = "@layer", Rt = Math.abs, ke = String.fromCharCode, At = Object.assign;
333
333
  function Ct(e, t) {
334
- return F(e, 0) ^ 45 ? (((t << 2 ^ F(e, 0)) << 2 ^ F(e, 1)) << 2 ^ F(e, 2)) << 2 ^ F(e, 3) : 0;
334
+ return L(e, 0) ^ 45 ? (((t << 2 ^ L(e, 0)) << 2 ^ L(e, 1)) << 2 ^ L(e, 2)) << 2 ^ L(e, 3) : 0;
335
335
  }
336
336
  function it(e) {
337
337
  return e.trim();
@@ -345,7 +345,7 @@ function P(e, t, r) {
345
345
  function je(e, t) {
346
346
  return e.indexOf(t);
347
347
  }
348
- function F(e, t) {
348
+ function L(e, t) {
349
349
  return e.charCodeAt(t) | 0;
350
350
  }
351
351
  function de(e, t, r) {
@@ -374,13 +374,13 @@ function Ot() {
374
374
  return O;
375
375
  }
376
376
  function jt() {
377
- return O = M > 0 ? F(oe, --M) : 0, ae--, O === 10 && (ae = 1, Pe--), O;
377
+ return O = M > 0 ? L(oe, --M) : 0, ae--, O === 10 && (ae = 1, Pe--), O;
378
378
  }
379
379
  function z() {
380
- return O = M < ot ? F(oe, M++) : 0, ae++, O === 10 && (ae = 1, Pe++), O;
380
+ return O = M < ot ? L(oe, M++) : 0, ae++, O === 10 && (ae = 1, Pe++), O;
381
381
  }
382
382
  function K() {
383
- return F(oe, M);
383
+ return L(oe, M);
384
384
  }
385
385
  function ge() {
386
386
  return M;
@@ -467,13 +467,13 @@ function $e(e) {
467
467
  }
468
468
  return M;
469
469
  }
470
- function Ft(e, t) {
470
+ function Lt(e, t) {
471
471
  for (; z() && e + O !== 57; )
472
472
  if (e + O === 84 && K() === 47)
473
473
  break;
474
474
  return "/*" + he(t, M - 1) + "*" + ke(e === 47 ? e : z());
475
475
  }
476
- function Lt(e) {
476
+ function Ft(e) {
477
477
  for (; !fe(K()); )
478
478
  z();
479
479
  return he(e, M);
@@ -486,7 +486,7 @@ function be(e, t, r, n, a, i, s, c, u) {
486
486
  switch (g = w, w = z()) {
487
487
  // (
488
488
  case 40:
489
- if (g != 108 && F(d, p - 1) == 58) {
489
+ if (g != 108 && L(d, p - 1) == 58) {
490
490
  je(d += P(ve(w), "&", "&\f"), "&\f") != -1 && (y = -1);
491
491
  break;
492
492
  }
@@ -512,7 +512,7 @@ function be(e, t, r, n, a, i, s, c, u) {
512
512
  switch (K()) {
513
513
  case 42:
514
514
  case 47:
515
- ye(Bt(Ft(z(), ge()), t, r), u);
515
+ ye(Bt(Lt(z(), ge()), t, r), u);
516
516
  break;
517
517
  default:
518
518
  d += "/";
@@ -543,7 +543,7 @@ function be(e, t, r, n, a, i, s, c, u) {
543
543
  if (l === 0)
544
544
  be(d, t, R, R, A, i, p, c, S);
545
545
  else
546
- switch (b === 99 && F(d, 3) === 110 ? 100 : b) {
546
+ switch (b === 99 && L(d, 3) === 110 ? 100 : b) {
547
547
  // d l m s
548
548
  case 100:
549
549
  case 108:
@@ -578,7 +578,7 @@ function be(e, t, r, n, a, i, s, c, u) {
578
578
  break;
579
579
  // @
580
580
  case 64:
581
- K() === 45 && (d += ve(z())), b = K(), l = p = H(_ = d += Lt(ge())), w++;
581
+ K() === 45 && (d += ve(z())), b = K(), l = p = H(_ = d += Ft(ge())), w++;
582
582
  break;
583
583
  // -
584
584
  case 45:
@@ -591,13 +591,13 @@ function Ye(e, t, r, n, a, i, s, c, u, m, l) {
591
591
  for (var p = a - 1, b = a === 0 ? i : [""], x = Ve(b), g = 0, f = 0, h = 0; g < n; ++g)
592
592
  for (var y = 0, w = de(e, p + 1, p = Rt(f = s[g])), _ = e; y < x; ++y)
593
593
  (_ = it(f > 0 ? b[y] + " " + w : P(w, /&\f/g, b[y]))) && (u[h++] = _);
594
- return Ee(e, t, r, a === 0 ? Fe : c, u, m, l);
594
+ return Ee(e, t, r, a === 0 ? Le : c, u, m, l);
595
595
  }
596
596
  function Bt(e, t, r) {
597
597
  return Ee(e, t, r, nt, ke(Ot()), de(e, 2, -2), 0);
598
598
  }
599
599
  function qe(e, t, r, n) {
600
- return Ee(e, t, r, Le, de(e, 0, n), de(e, n + 1, -1), n);
600
+ return Ee(e, t, r, Fe, de(e, 0, n), de(e, n + 1, -1), n);
601
601
  }
602
602
  function ne(e, t) {
603
603
  for (var r = "", n = Ve(e), a = 0; a < n; a++)
@@ -609,13 +609,13 @@ function Mt(e, t, r, n) {
609
609
  case St:
610
610
  if (e.children.length) break;
611
611
  case _t:
612
- case Le:
612
+ case Fe:
613
613
  return e.return = e.return || e.value;
614
614
  case nt:
615
615
  return "";
616
616
  case at:
617
617
  return e.return = e.value + "{" + ne(e.children, n) + "}";
618
- case Fe:
618
+ case Le:
619
619
  e.value = e.props.join(",");
620
620
  }
621
621
  return H(r = ne(e.children, n)) ? e.return = e.value + "{" + r + "}" : "";
@@ -786,13 +786,13 @@ function ut(e, t) {
786
786
  case 5789:
787
787
  case 5021:
788
788
  case 4765:
789
- if (H(e) - 1 - t > 6) switch (F(e, t + 1)) {
789
+ if (H(e) - 1 - t > 6) switch (L(e, t + 1)) {
790
790
  // (m)ax-content, (m)in-content
791
791
  case 109:
792
- if (F(e, t + 4) !== 45) break;
792
+ if (L(e, t + 4) !== 45) break;
793
793
  // (f)ill-available, (f)it-content
794
794
  case 102:
795
- return P(e, /(.+:)(.+)-([^]+)/, "$1" + k + "$2-$3$1" + we + (F(e, t + 3) == 108 ? "$3" : "$2-$3")) + e;
795
+ return P(e, /(.+:)(.+)-([^]+)/, "$1" + k + "$2-$3$1" + we + (L(e, t + 3) == 108 ? "$3" : "$2-$3")) + e;
796
796
  // (s)tretch
797
797
  case 115:
798
798
  return ~je(e, "stretch") ? ut(P(e, "stretch", "fill-available"), t) + e : e;
@@ -800,21 +800,21 @@ function ut(e, t) {
800
800
  break;
801
801
  // position: sticky
802
802
  case 4949:
803
- if (F(e, t + 1) !== 115) break;
803
+ if (L(e, t + 1) !== 115) break;
804
804
  // display: (flex|inline-flex)
805
805
  case 6444:
806
- switch (F(e, H(e) - 3 - (~je(e, "!important") && 10))) {
806
+ switch (L(e, H(e) - 3 - (~je(e, "!important") && 10))) {
807
807
  // stic(k)y
808
808
  case 107:
809
809
  return P(e, ":", ":" + k) + e;
810
810
  // (inline-)?fl(e)x
811
811
  case 101:
812
- return P(e, /(.+:)([^;!]+)(;|!.+)?/, "$1" + k + (F(e, 14) === 45 ? "inline-" : "") + "box$3$1" + k + "$2$3$1" + B + "$2box$3") + e;
812
+ return P(e, /(.+:)([^;!]+)(;|!.+)?/, "$1" + k + (L(e, 14) === 45 ? "inline-" : "") + "box$3$1" + k + "$2$3$1" + B + "$2box$3") + e;
813
813
  }
814
814
  break;
815
815
  // writing-mode
816
816
  case 5936:
817
- switch (F(e, t + 11)) {
817
+ switch (L(e, t + 11)) {
818
818
  // vertical-l(r)
819
819
  case 114:
820
820
  return k + e + B + P(e, /[svh]\w+-[tblr]{2}/, "tb") + e;
@@ -831,14 +831,14 @@ function ut(e, t) {
831
831
  }
832
832
  var Ht = function(t, r, n, a) {
833
833
  if (t.length > -1 && !t.return) switch (t.type) {
834
- case Le:
834
+ case Fe:
835
835
  t.return = ut(t.value, t.length);
836
836
  break;
837
837
  case at:
838
838
  return ne([le(t, {
839
839
  value: P(t.value, "@", "@" + k)
840
840
  })], a);
841
- case Fe:
841
+ case Le:
842
842
  if (t.length) return It(t.props, function(i) {
843
843
  switch (Tt(i, /(::plac\w+|:read-\w+)/)) {
844
844
  // :read-(only|write)
@@ -1402,31 +1402,15 @@ const vr = ie.div`
1402
1402
  `, Ne = ({ type: e, children: t, className: r, icon: n, action: a }) => N.jsxs(vr, { type: e, className: r, children: [n && N.jsx("span", { children: n }), N.jsx("span", { children: t }), a && N.jsx("span", { children: a })] }), Qe = ie.div`
1403
1403
  width: ${({ width: e }) => e || "100%"};
1404
1404
  height: ${({ height: e }) => e || "100%"};
1405
- border-radius: 0px !important; /* Force remove rounded corners */
1406
- box-shadow: none !important; /* Force remove shadow */
1405
+ border-radius: 0px !important; /* Force remove rounded corners on container */
1406
+ box-shadow: none !important; /* Remove default border/halo */
1407
+ border: none !important;
1408
+ background: transparent !important;
1407
1409
  position: relative;
1408
1410
  z-index: 1002;
1409
1411
 
1410
1412
  /* Hide specific elements inside the player */
1411
1413
  ${({ $hiddenClasses: e }) => (e == null ? void 0 : e.length) && e.map((t) => `.${t} { display: none !important; }`).join("")}
1412
-
1413
- /* Remove rounded corners from all child elements */
1414
- * {
1415
- border-radius: 0px !important;
1416
- }
1417
-
1418
- /* Remove rounded corners from video element */
1419
- video {
1420
- border-radius: 0px !important;
1421
- }
1422
-
1423
- /* Remove rounded corners from control elements */
1424
- [class*="control"],
1425
- [class*="button"],
1426
- button,
1427
- [role="button"] {
1428
- border-radius: 0px !important;
1429
- }
1430
1414
  `, br = ie.div`
1431
1415
  position: fixed;
1432
1416
  top: 0;
@@ -1440,17 +1424,17 @@ const vr = ie.div`
1440
1424
  z-index: 1000;
1441
1425
  pointer-events: auto;
1442
1426
  `, xr = ie.div`
1443
- position: relative;
1444
- width: 100%; /* Default for mobile */
1445
- max-width: 100%;
1446
- aspect-ratio: 9/16;
1447
- height: auto;
1448
- z-index: 1001;
1427
+ position: relative;
1428
+ width: min(360px, 100%);
1429
+ max-width: 360px;
1430
+ aspect-ratio: 9 / 16;
1431
+ height: auto;
1432
+ z-index: 1001;
1449
1433
 
1450
- /* Desktop styles (min-width: 768px) */
1451
- @media (min-width: 768px) {
1452
- width: min(70vw, 960px); /* Responsive width for desktop, capped at 960px */
1453
- }
1434
+ @media (max-width: 420px) {
1435
+ width: 100%;
1436
+ max-width: 100%;
1437
+ }
1454
1438
  `, wr = (e, t) => `https://vp-api.gjirafa.tech/api/v2/projects/${e}/videos?search=${t}`, et = (e, t) => `https://vp-api.gjirafa.tech/api/projects/${e}/playlists/${t}/videos`, kr = (e, t) => `https://vp-api.gjirafa.tech/api/projects/${e}/playlists/${t}`, Pr = (e) => `https://host.vpplayer.tech/player/${e}/vpplayer.js`, Be = (e, t) => `vp-player-${e || "default"}-${t || ""}`, Ce = /* @__PURE__ */ new Map(), Er = (e, t) => {
1455
1439
  const [r, n] = Y(!1), [a, i] = Y(null);
1456
1440
  return xe(() => {
@@ -1912,7 +1896,7 @@ const vr = ie.div`
1912
1896
  if (!e)
1913
1897
  throw new Error("useVPPlayer must be used within a VPPlayerProvider");
1914
1898
  return e;
1915
- }, Fr = {
1899
+ }, Lr = {
1916
1900
  projectId: "vp-player-projectId",
1917
1901
  video: {
1918
1902
  file: "",
@@ -1945,7 +1929,7 @@ const vr = ie.div`
1945
1929
  shareButton: !0
1946
1930
  }
1947
1931
  }
1948
- }, Lr = {
1932
+ }, Fr = {
1949
1933
  config: {
1950
1934
  autostartOnLoad: { state: !0, onMobile: !0, onData: !0 },
1951
1935
  muted: !0
@@ -1998,11 +1982,11 @@ export {
1998
1982
  xr as PlayerWrapper,
1999
1983
  Or as VPPlayer,
2000
1984
  $r as VPPlayerProvider,
2001
- Lr as baseConfig,
1985
+ Fr as baseConfig,
2002
1986
  Ie as baseConfigWithAds,
2003
1987
  Vr as baseConfigWithAutoplay,
2004
1988
  Cr as buildVPPlayerConfig,
2005
- Fr as defaultVPPlayerConfig,
1989
+ Lr as defaultVPPlayerConfig,
2006
1990
  Tr as extractVideoId,
2007
1991
  Br as getAdConfig,
2008
1992
  Nr as useVPPlayer,
@@ -50,31 +50,15 @@ React keys must be passed directly to JSX without using spread:
50
50
  `,je=({type:e,children:t,className:r,icon:n,action:a})=>N.jsxs(vr,{type:e,className:r,children:[n&&N.jsx("span",{children:n}),N.jsx("span",{children:t}),a&&N.jsx("span",{children:a})]}),$e=oe.div`
51
51
  width: ${({width:e})=>e||"100%"};
52
52
  height: ${({height:e})=>e||"100%"};
53
- border-radius: 0px !important; /* Force remove rounded corners */
54
- box-shadow: none !important; /* Force remove shadow */
53
+ border-radius: 0px !important; /* Force remove rounded corners on container */
54
+ box-shadow: none !important; /* Remove default border/halo */
55
+ border: none !important;
56
+ background: transparent !important;
55
57
  position: relative;
56
58
  z-index: 1002;
57
59
 
58
60
  /* Hide specific elements inside the player */
59
61
  ${({$hiddenClasses:e})=>(e==null?void 0:e.length)&&e.map(t=>`.${t} { display: none !important; }`).join("")}
60
-
61
- /* Remove rounded corners from all child elements */
62
- * {
63
- border-radius: 0px !important;
64
- }
65
-
66
- /* Remove rounded corners from video element */
67
- video {
68
- border-radius: 0px !important;
69
- }
70
-
71
- /* Remove rounded corners from control elements */
72
- [class*="control"],
73
- [class*="button"],
74
- button,
75
- [role="button"] {
76
- border-radius: 0px !important;
77
- }
78
62
  `,lt=oe.div`
79
63
  position: fixed;
80
64
  top: 0;
@@ -88,15 +72,15 @@ React keys must be passed directly to JSX without using spread:
88
72
  z-index: 1000;
89
73
  pointer-events: auto;
90
74
  `,ut=oe.div`
91
- position: relative;
92
- width: 100%; /* Default for mobile */
93
- max-width: 100%;
94
- aspect-ratio: 9/16;
95
- height: auto;
96
- z-index: 1001;
75
+ position: relative;
76
+ width: min(360px, 100%);
77
+ max-width: 360px;
78
+ aspect-ratio: 9 / 16;
79
+ height: auto;
80
+ z-index: 1001;
97
81
 
98
- /* Desktop styles (min-width: 768px) */
99
- @media (min-width: 768px) {
100
- width: min(70vw, 960px); /* Responsive width for desktop, capped at 960px */
101
- }
82
+ @media (max-width: 420px) {
83
+ width: 100%;
84
+ max-width: 100%;
85
+ }
102
86
  `,wr=(e,t)=>`https://vp-api.gjirafa.tech/api/v2/projects/${e}/videos?search=${t}`,dt=(e,t)=>`https://vp-api.gjirafa.tech/api/projects/${e}/playlists/${t}/videos`,xr=(e,t)=>`https://vp-api.gjirafa.tech/api/projects/${e}/playlists/${t}`,Pr=e=>`https://host.vpplayer.tech/player/${e}/vpplayer.js`,Le=(e,t)=>`vp-player-${e||"default"}-${t||""}`,Ne=new Map,ft=(e,t)=>{const[r,n]=P.useState(!1),[a,i]=P.useState(null);return P.useEffect(()=>{let s=null,c,u=0;const m=3;let l;try{l=t||Pr(e||"latest")}catch(w){const g=w instanceof Error?w.message:String(w);i(`Failed to resolve script URL: ${g}`),n(!1);return}if(Ne.get(l)){n(!0),i(null);return}if(document.querySelector(`script[src="${l}"]`)){Ne.set(l,!0),n(!0),i(null);return}const v=()=>{s=document.createElement("script"),s.src=l,s.async=!0,c=window.setTimeout(()=>{n(!1),i(`Loading script timed out: ${l}`)},1e4),s.onload=()=>{clearTimeout(c),Ne.set(l,!0),n(!0),i(null)},s.onerror=()=>{clearTimeout(c),u++,u<m?setTimeout(v,1e3*u):(n(!1),i(`Failed to load VP Player script after ${m} attempts: ${l}`))},document.body.appendChild(s)};return v(),()=>{clearTimeout(c),s&&document.body.contains(s)&&document.body.removeChild(s)}},[e,t]),{isLoaded:r,error:a}},kr={},me=new Map,Er=3e4,Ve=5,pt=({projectId:e,videoId:t,playlistId:r,videoUrl:n,apiKey:a})=>{const[i,s]=P.useState(null),[c,u]=P.useState(null),[m,l]=P.useState(!1),[p,v]=P.useState(null),w=a||(typeof kr<"u"?"1CFC4B619E9342B6BAC4879BA8C30CF216C4BA9D3F084B11825F4AB2D5CF845E":void 0);return P.useEffect(()=>{const g=t?`video:${t}`:r?`playlist:${r}`:null;if(!e||n||!t&&!r){s(n||null),u(null),l(!1),v(null);return}if(!w){l(!1),v("No API key provided");return}if(g&&me.has(g)){const R=me.get(g);s(R.url),u(R.playlist),l(!1),v(null);return}let f=!0;const h=new AbortController,y=h.signal,A=setTimeout(async()=>{var C,T,d,$;if(!f)return;l(!0),v(null);let R=0;for(;R<Ve&&f;)try{const I=t&&!r?wr(e,t):dt(e,r),_=setTimeout(()=>h.abort(),Er),V=await fetch(I,{method:"GET",headers:{"api-key":w,Accept:"application/json","Cache-Control":"no-cache"},signal:y});if(clearTimeout(_),!V.ok)throw new Error(`Fetch failed with status ${V.status}`);const Y=await V.json();if(!f)return;if(t&&!r){const L=(T=(C=Y.result)==null?void 0:C.items)==null?void 0:T.find(W=>W.mediaId===t);if(!(L!=null&&L.playbackUrl))throw new Error("Invalid video data");s(L.playbackUrl),u(null),g&&me.set(g,{url:L.playbackUrl,playlist:null})}else{if(!Array.isArray(Y.result))throw new Error("Invalid playlist format");const L=xr(e,r),W=await fetch(L,{method:"GET",headers:{"api-key":w,Accept:"application/json","Cache-Control":"no-cache"},signal:y});if(W.ok){const K=await W.json();let G=[...Y.result];if((d=K.result)!=null&&d.playlistBackupState&&(($=K.result)!=null&&$.playlistBackupId)){const Q=dt(e,K.result.playlistBackupId),ee=await fetch(Q,{method:"GET",headers:{"api-key":w,Accept:"application/json","Cache-Control":"no-cache"},signal:y});if(ee.ok){const te=await ee.json();if(Array.isArray(te.result)){const o=te.result.map(b=>({...b,isBackupPlaylist:!0}));G=[...G,...o]}}}u(G),s(null),g&&me.set(g,{url:null,playlist:G})}else u(Y.result),s(null),g&&me.set(g,{url:null,playlist:Y.result})}break}catch(I){if(y.aborted){f&&v("Request timed out");break}if(R++,R>=Ve){const _=I instanceof Error?I.message:String(I);f&&v(`Failed after ${Ve} attempts: ${_}`)}else await new Promise(_=>setTimeout(_,2e3))}f&&l(!1)},100);return()=>{f=!1,clearTimeout(A),h.abort()}},[w,e,t,r,n]),{fetchedPlaybackUrl:i,fetchedPlaylist:c,isLoading:m,error:p}},_r={projectId:"vp-player-projectId",video:{file:"",playlist:{state:!0,playlistVideoIndex:0,videos:[]}},config:{autoplay:!0,muted:!0,loop:!1,size:{width:"100%",height:"30vh"},controls:{settingsButton:!0,chromecastButton:!1,nextButton:!0,fullscreenButton:!0,airplayButton:!1,bigPlayButton:!1,autopausePlayButton:!0,pictureInPictureButton:!1,relatedButton:!1,volumeButton:!0,shareButton:!0}}},ht=({videoUrl:e,fetchedPlaybackUrl:t,fetchedPlaylist:r,projectId:n,config:a={},isVerticalPlayer:i})=>{var l,p,v,w,g,f,h,y,x,A,R,C,T;const s={..._r,...a},c={...s.config,...a.config};if(e)return{...s,video:{...s.video,file:e,playlist:void 0},config:c};if(t)return{...s,video:{...s.video,file:t,playlist:void 0},config:c};if(r&&r.length>0){const d=((p=(l=a==null?void 0:a.video)==null?void 0:l.playlist)==null?void 0:p.playlistVideoIndex)??((v=a==null?void 0:a.config)==null?void 0:v.playlistVideoIndex)??0;return i?{...s,projectId:n||"vp-player-projectId",video:{...s.video,file:(w=r[0])==null?void 0:w.hlsUrl,title:(g=r[0])==null?void 0:g.title,playlist:{state:!0,playlistId:"",playlistVideoIndex:Number(d),videos:r.slice(1).map((I,_)=>({videoId:String(_+1),title:I.title,file:I.hlsUrl,thumbnailUrl:I.thumbnailUrl,duration:I.duration}))}},config:c}:{...s,projectId:n||"vp-player-projectId",video:{...s.video,file:((f=r[Number(d)])==null?void 0:f.hlsUrl)||((h=r[0])==null?void 0:h.hlsUrl)||"",title:((y=r[Number(d)])==null?void 0:y.title)||((x=r[0])==null?void 0:x.title),thumbnail:((A=r[Number(d)])==null?void 0:A.thumbnailUrl)||((R=r[0])==null?void 0:R.thumbnailUrl),playlist:{state:!0,playlistVideoIndex:Number(d),videos:r.map((I,_)=>({videoId:String(_),title:I.title,file:I.hlsUrl,thumbnailUrl:I.thumbnailUrl,duration:I.duration}))}},config:c}}const u=((C=a==null?void 0:a.video)==null?void 0:C.playlist)||s.video.playlist,m=(T=a==null?void 0:a.video)==null?void 0:T.file;if(m)return{...s,video:{...s.video,file:m,playlist:void 0},config:c};if(u!=null&&u.videos&&u.videos.length>0){const d=u.videos[Number(u.playlistVideoIndex)||0];return{...s,video:{...s.video,file:(d==null?void 0:d.file)||"",playlist:{...u,state:u.state??!0,playlistVideoIndex:Number(u.playlistVideoIndex||0),videos:u.videos}},config:{...s.config,...a==null?void 0:a.config}}}throw new Error("No valid video source found. Provide videoUrl, videoId, playlistId, or config with video.file or playlist.")},mt=e=>{if(!e)return;const t=/https:\/\/host\.vpplayer\.tech\/player\/([^/]+)\/([^/]+)(?:\/[^/]+)?\.js/,r=e.match(t);return r?r[2]:void 0},yt=({playerId:e,videoId:t,version:r,videoUrl:n,projectId:a,playlistId:i,scriptUrl:s,config:c={},apiKey:u,isReels:m=!1})=>{const l=P.useRef(null),p=P.useRef(null),{isLoaded:v,error:w}=ft(r,s),g=t||mt(s),[f,h]=P.useState(null),{fetchedPlaybackUrl:y,fetchedPlaylist:x,isLoading:A,error:R}=pt({projectId:a,videoId:g,playlistId:i,videoUrl:n,apiKey:u}),C=Le(e,g),T=P.useMemo(()=>{const d=c.config||{},$=m&&!d.size?{sizeType:"RESPONSIVE",aspectRatio:"9:16"}:d.size||{sizeType:"FIXED",width:"100%"};return{...c,config:{...d,size:$}}},[c,m]);return P.useEffect(()=>{if(w){h(w);return}if(!v||A&&!n)return;let d=!0;const I=setTimeout(async()=>{try{const _=s==null?void 0:s.includes("vertical-player");if(document.querySelectorAll('[id*="player"]').forEach(G=>{var ee,te;const Q=G.id;if(Q!==C)try{const o=_?(ee=window.vpVerticalPlayer)==null?void 0:ee.call(window,Q):(te=window.vpPlayer)==null?void 0:te.call(window,Q);o!=null&&o.destroy&&o.destroy()}catch(o){console.warn(`Failed to destroy existing player ${Q}:`,o)}}),await new Promise(G=>setTimeout(G,100)),!d||!l.current)return;if(!document.getElementById(C)){h("DOM element not found after cleanup.");return}if(!window.vpPlayer&&!window.vpVerticalPlayer){h("VP Player script not loaded.");return}const L=_?window.vpVerticalPlayer:window.vpPlayer;if(!L){h(`VP ${_?"Vertical ":""}Player script not loaded.`);return}const W=ht({videoUrl:n,fetchedPlaybackUrl:y??void 0,fetchedPlaylist:x??void 0,projectId:a,config:T,isVerticalPlayer:_}),K=L(C);if(!K){h(`Failed to create VP ${_?"Vertical ":""}Player instance.`);return}d&&l.current&&(K.setup(W),p.current=K,h(null))}catch(_){if(d){const V=_ instanceof Error?_.message:String(_);h(V),console.error("VP Player initialization error:",_)}}},150);return()=>{d=!1,clearTimeout(I)}},[v,A,n,y,x,a,T,C,w,s]),P.useEffect(()=>()=>{if(p.current){try{p.current.destroy&&p.current.destroy()}catch($){console.warn(`Failed to destroy player ${C}:`,$)}p.current=null}const d=document.getElementById(C);d&&(d.innerHTML="")},[C]),{playerRef:l,playerInstanceRef:p,isScriptLoaded:v,isLoading:A,error:R||f||w}},gt=({playerId:e,videoId:t,version:r,videoUrl:n,projectId:a,playlistId:i,scriptUrl:s,config:c={},apiKey:u,isReels:m=!1,hiddenClasses:l=[],onClose:p,className:v})=>{var I,_,V,Y;const{playerRef:w,playerInstanceRef:g,isScriptLoaded:f,isLoading:h,error:y}=yt({playerId:e,videoId:t,version:r,videoUrl:n,projectId:a,playlistId:i,scriptUrl:s,config:c,apiKey:u,isReels:m}),[x,A]=P.useState(!0),R=()=>m&&A(!0),C=()=>{var L,W;A(!1),(W=(L=g.current)==null?void 0:L.play)==null||W.call(L),p==null||p()},T=(_=(I=c==null?void 0:c.config)==null?void 0:I.size)!=null&&_.width?typeof c.config.size.width=="number"?`${c.config.size.width}px`:c.config.size.width:void 0,d=(Y=(V=c==null?void 0:c.config)==null?void 0:V.size)!=null&&Y.height?typeof c.config.size.height=="number"?`${c.config.size.height}px`:c.config.size.height:void 0,$=Le(e,t);return y?N.jsxs(je,{type:"error",children:["An error occurred: ",y]}):h||!f?N.jsx(je,{type:"loading",children:"Loading..."}):N.jsxs(N.Fragment,{children:[m&&!x?N.jsx("div",{onClick:R}):null,!m&&N.jsx("div",{children:N.jsx($e,{id:$,ref:w,width:T||"100%",height:d||"auto",$hiddenClasses:l,className:v})},$),m&&x&&N.jsx(lt,{onClick:C,className:v,children:N.jsx(ut,{className:v,onClick:L=>L.stopPropagation(),children:N.jsx("div",{children:N.jsx($e,{id:$,ref:w,width:"100%",height:"auto",$hiddenClasses:l,className:v})},$)})})]})},bt=P.createContext(void 0),Sr=({children:e})=>{const[t,r]=P.useState(!1),[n,a]=P.useState(null),[i,s]=P.useState(null),c=P.useCallback(l=>{try{const p=Le(l.playerId,l.videoId);a({...l,playerId:p}),r(!0),s(null)}catch{s("Failed to show player.")}},[]),u=P.useCallback(()=>{r(!1),a(null),s(null)},[]),m=P.useMemo(()=>({showPlayer:c,hidePlayer:u,isPlayerVisible:t,playerParams:n}),[c,u,t,n]);return N.jsxs(bt.Provider,{value:m,children:[e,i&&N.jsx(je,{type:"error",children:i}),t&&(n==null?void 0:n.playerId)&&N.jsx(gt,{playerId:n.playerId,videoId:n.videoId,projectId:n.projectId,videoUrl:n.videoUrl,version:n.version,playlistId:n.playlistId,scriptUrl:n.scriptUrl,config:n.config,isReels:n.isReels,thumbnailUrl:n.thumbnailUrl,onClose:u,hiddenClasses:n.hiddenClasses||[],apiKey:n.apiKey,className:n.className})]})},Ar=()=>{const e=P.useContext(bt);if(!e)throw new Error("useVPPlayer must be used within a VPPlayerProvider");return e},Cr={projectId:"vp-player-projectId",video:{file:"",playlist:{state:!0,playlistVideoIndex:0,videos:[]}},config:{autoplay:!0,pauseOtherVideos:!0,focusOnAutostart:!1,muted:!0,loop:!1,size:{width:"100%"},controls:{settingsButton:!0,chromecastButton:!1,nextButton:!1,fullscreenButton:!0,airplayButton:!1,bigPlayButton:!1,autopausePlayButton:!0,pictureInPictureButton:!1,relatedButton:!1,volumeButton:!0,shareButton:!0}}},Tr={config:{autostartOnLoad:{state:!0,onMobile:!0,onData:!0},muted:!0}},Rr={config:{autoplay:!0,muted:!0}},_e={video:{advertising:!0,ads:{skipAd:{state:!0,skipFrom:5}}},config:{adAnnouncement:{state:!0,timeBeforeAd:5},adsRequireInteraction:!1}},Ir=(e,t,r="time",n=0)=>{var a;return{..._e,video:{..._e.video,ads:{...(a=_e.video)==null?void 0:a.ads,adBreaks:[{adTagUrl:t,breakType:e,breakTimingType:r,breakTimingValue:n}]}}}},Or="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4",jr="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4",$r="https://videos.pexels.com/video-files/4678261/4678261-hd_1080_1920_25fps.mp4",Lr="https://images.pexels.com/videos/4678261/pexels-photo-4678261.jpeg?auto=compress&cs=tinysrgb&w=600",Nr="https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/single_ad_samples&ciu_szs=300x250&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ct%3Dlinear&correlator=",Vr="https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/single_ad_samples&ciu_szs=300x250&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ct%3Dskippablelinear&correlator=";S.AD_TAG_LINEAR_URL=Nr,S.AD_TAG_SKIPPABLE_LINEAR_URL=Vr,S.BIG_BUCK_BUNNY_URL=Or,S.ELEPHANTS_DREAM_URL=jr,S.Overlay=lt,S.PEXELS_THUMBNAIL_URL=Lr,S.PEXELS_VERTICAL_VIDEO_URL=$r,S.PlayerContainer=$e,S.PlayerWrapper=ut,S.VPPlayer=gt,S.VPPlayerProvider=Sr,S.baseConfig=Tr,S.baseConfigWithAds=_e,S.baseConfigWithAutoplay=Rr,S.buildVPPlayerConfig=ht,S.defaultVPPlayerConfig=Cr,S.extractVideoId=mt,S.getAdConfig=Ir,S.useVPPlayer=Ar,S.useVPPlayerLogic=yt,S.useVPPlayerScript=ft,S.useVideoData=pt,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devix-technologies/react-gjirafa-vp-player",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "type": "module",
5
5
  "main": "./dist/react-gjirafa-vp-player.umd.js",
6
6
  "module": "./dist/react-gjirafa-vp-player.es.js",