@streamlayer/react 1.21.0 → 1.21.1

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,39 +1,39 @@
1
- import { jsx as a, jsxs as I } from "react/jsx-runtime";
2
- import { j as K, k as F, e as k, s as p, l as M, n as _, f as j, u as q, d as G, h as N } from "./provider.js";
1
+ import { jsx as l, jsxs as L } from "react/jsx-runtime";
2
+ import { j as K, k as M, e as k, s as m, l as _, n as $, f as F, u as N, d as j, h as q } from "./provider.js";
3
3
  import "nanostores";
4
- import { useRef as D, useCallback as L, useState as R, useEffect as T, Component as $ } from "react";
4
+ import { useRef as D, useCallback as I, useState as R, useEffect as T, Component as O } from "react";
5
5
  import "@nanostores/react";
6
6
  import "lodash.throttle";
7
7
  import "react-dom";
8
8
  import "react-countup";
9
9
  import { c as z } from "./vast-client.min-B0NUra1B.js";
10
- const O = {}, W = new z(), b = F(O), E = K("ui:gam-static"), U = (e) => new Promise((s, t) => {
11
- const n = new Image();
12
- n.onload = () => s(e), n.onerror = () => t(), n.src = e;
10
+ const G = {}, J = new z(), w = M(G), E = K("ui:gam-static"), U = (e) => new Promise((s, t) => {
11
+ const a = new Image();
12
+ a.onload = () => s(e), a.onerror = () => t(), a.src = e;
13
13
  }), V = () => {
14
14
  const e = D(0);
15
- return [L(async (s) => {
16
- var t, n, r, d, c, i, h, l, f, g, y;
17
- if ((t = b.get()[s]) != null && t.imageSrc)
15
+ return [I(async (s) => {
16
+ var t, a, r, c, d, n, h, i, f, g, y;
17
+ if ((t = w.get()[s]) != null && t.imageSrc)
18
18
  return { success: !0 };
19
19
  const v = Date.now();
20
- e.current = v, b.setKey(s, { id: "", url: s });
20
+ e.current = v, w.setKey(s, { id: "", url: s });
21
21
  try {
22
22
  k.emit("exposedPauseAd", {
23
23
  action: "load",
24
24
  payload: {}
25
25
  });
26
- const u = await W.get(s);
27
- if (E.debug(u, "parsedVAST"), e.current === v && b.get()[s].url) {
28
- const o = u.ads.find((m) => m.creatives.length > 0);
26
+ const u = await J.get(s);
27
+ if (E.debug(u, "parsedVAST"), e.current === v && w.get()[s].url) {
28
+ const o = u.ads.find((p) => p.creatives.length > 0);
29
29
  if (o) {
30
30
  E.debug(o, "validAd");
31
- const m = o.creatives.find((A) => A.type === "nonlinear");
32
- if (m) {
33
- E.debug(m, "nonlinear");
34
- const A = (r = (n = m.variations) == null ? void 0 : n[0]) == null ? void 0 : r.staticResource, C = (c = (d = m.variations) == null ? void 0 : d[0]) == null ? void 0 : c.nonlinearClickThroughURLTemplate;
31
+ const p = o.creatives.find((A) => A.type === "nonlinear");
32
+ if (p) {
33
+ E.debug(p, "nonlinear");
34
+ const A = (r = (a = p.variations) == null ? void 0 : a[0]) == null ? void 0 : r.staticResource, C = (d = (c = p.variations) == null ? void 0 : c[0]) == null ? void 0 : d.nonlinearClickThroughURLTemplate;
35
35
  if (A)
36
- return await U(A), b.setKey(s, {
36
+ return await U(A), w.setKey(s, {
37
37
  id: o.id || "",
38
38
  url: s,
39
39
  imageSrc: A,
@@ -47,12 +47,12 @@ const O = {}, W = new z(), b = F(O), E = K("ui:gam-static"), U = (e) => new Prom
47
47
  }
48
48
  const P = o.creatives.find((A) => A.type === "companion");
49
49
  E.debug(P, "companion");
50
- const w = (f = (l = (h = (i = P == null ? void 0 : P.variations) == null ? void 0 : i[0]) == null ? void 0 : h.staticResources) == null ? void 0 : l[0]) == null ? void 0 : f.url, S = (y = (g = P == null ? void 0 : P.variations) == null ? void 0 : g[0]) == null ? void 0 : y.companionClickThroughURLTemplate;
51
- if (w)
52
- return await U(w), b.setKey(s, {
50
+ const b = (f = (i = (h = (n = P == null ? void 0 : P.variations) == null ? void 0 : n[0]) == null ? void 0 : h.staticResources) == null ? void 0 : i[0]) == null ? void 0 : f.url, S = (y = (g = P == null ? void 0 : P.variations) == null ? void 0 : g[0]) == null ? void 0 : y.companionClickThroughURLTemplate;
51
+ if (b)
52
+ return await U(b), w.setKey(s, {
53
53
  id: o.id || "",
54
54
  url: s,
55
- imageSrc: w,
55
+ imageSrc: b,
56
56
  adUrl: S
57
57
  }), k.emit("exposedPauseAd", {
58
58
  action: "loaded",
@@ -66,58 +66,54 @@ const O = {}, W = new z(), b = F(O), E = K("ui:gam-static"), U = (e) => new Prom
66
66
  console.error("Error parsing VAST", u);
67
67
  }
68
68
  return { success: !1 };
69
- }, []), b];
70
- }, X = /* @__PURE__ */ p("div")({
69
+ }, []), w];
70
+ }, Q = /* @__PURE__ */ m("div")({
71
71
  name: "PauseAdOverlay",
72
72
  class: "pw9gih8",
73
73
  propsAsIs: !1
74
- }), H = /* @__PURE__ */ p("div")({
74
+ }), H = /* @__PURE__ */ m("div")({
75
75
  name: "PauseAdContent",
76
76
  class: "p8lpomy",
77
77
  propsAsIs: !1
78
- }), J = /* @__PURE__ */ p("div")({
79
- name: "PauseAdGradientRight",
78
+ }), W = /* @__PURE__ */ m("div")({
79
+ name: "PauseAdTopLeft",
80
80
  class: "pv7u167",
81
81
  propsAsIs: !1
82
- }), Q = /* @__PURE__ */ p("div")({
83
- name: "PauseAdGradientBottom",
82
+ }), X = /* @__PURE__ */ m("h2")({
83
+ name: "PauseAdTitle",
84
84
  class: "p1kh2yb0",
85
85
  propsAsIs: !1
86
- }), Y = /* @__PURE__ */ p("div")({
87
- name: "PauseAdTopLeft",
86
+ }), Y = /* @__PURE__ */ m("p")({
87
+ name: "PauseAdCaption",
88
88
  class: "pl8f94x",
89
89
  propsAsIs: !1
90
- }), Z = /* @__PURE__ */ p("h2")({
91
- name: "PauseAdTitle",
90
+ }), Z = /* @__PURE__ */ m("div")({
91
+ name: "PauseAdBottomLeft",
92
92
  class: "p1m6zmrt",
93
93
  propsAsIs: !1
94
- }), ee = /* @__PURE__ */ p("p")({
95
- name: "PauseAdCaption",
94
+ }), ee = /* @__PURE__ */ m("button")({
95
+ name: "PauseAdPlayButton",
96
96
  class: "pm3vwfa",
97
97
  propsAsIs: !1
98
- }), se = /* @__PURE__ */ p("div")({
99
- name: "PauseAdBottomLeft",
98
+ }), se = /* @__PURE__ */ m("div")({
99
+ name: "PauseAdSidebarGradient",
100
100
  class: "p1tibuhw",
101
101
  propsAsIs: !1
102
- }), re = /* @__PURE__ */ p("button")({
103
- name: "PauseAdPlayButton",
104
- class: "ptqqrqd",
105
- propsAsIs: !1
106
- }), te = /* @__PURE__ */ p("div")({
102
+ }), re = /* @__PURE__ */ m("div")({
107
103
  name: "PauseAdSidebar",
108
- class: "p14estxv",
104
+ class: "ptqqrqd",
109
105
  propsAsIs: !1
110
- }), oe = /* @__PURE__ */ p("span")({
106
+ }), te = /* @__PURE__ */ m("span")({
111
107
  name: "PauseAdTitleDescription",
112
- class: "p1dpvfl1",
108
+ class: "p14estxv",
113
109
  propsAsIs: !1
114
- }), B = /* @__PURE__ */ p("img")({
110
+ }), B = /* @__PURE__ */ m("img")({
115
111
  name: "ExternalAdContainer",
116
- class: "ezfmabr",
112
+ class: "e1dpvfl1",
117
113
  propsAsIs: !1
118
- }), ae = ({ vastUrl: e, isDesktop: s }) => {
114
+ }), oe = ({ vastUrl: e, isDesktop: s }) => {
119
115
  var t;
120
- const [, n] = V(), r = j(n, { keys: [e] });
116
+ const [, a] = V(), r = F(a, { keys: [e] });
121
117
  return T(() => {
122
118
  r && r[e] && r[e].imageSrc && r[e].id && k.emit("exposedPauseAd", {
123
119
  action: "rendered",
@@ -125,7 +121,7 @@ const O = {}, W = new z(), b = F(O), E = K("ui:gam-static"), U = (e) => new Prom
125
121
  id: r[e].id
126
122
  }
127
123
  });
128
- }, [r, e]), (t = r == null ? void 0 : r[e]) != null && t.imageSrc ? !r[e].adUrl || !s ? /* @__PURE__ */ a(B, { src: r[e].imageSrc }) : /* @__PURE__ */ a(
124
+ }, [r, e]), (t = r == null ? void 0 : r[e]) != null && t.imageSrc ? !r[e].adUrl || !s ? /* @__PURE__ */ l(B, { src: r[e].imageSrc }) : /* @__PURE__ */ l(
129
125
  "a",
130
126
  {
131
127
  onClick: () => {
@@ -139,19 +135,19 @@ const O = {}, W = new z(), b = F(O), E = K("ui:gam-static"), U = (e) => new Prom
139
135
  href: r[e].adUrl,
140
136
  target: "_blank",
141
137
  rel: "noopener noreferrer",
142
- children: /* @__PURE__ */ a(B, { src: r[e].imageSrc })
138
+ children: /* @__PURE__ */ l(B, { src: r[e].imageSrc })
143
139
  }
144
140
  ) : null;
145
- }, ne = ({ isClosing: e, title: s, caption: t, onPlay: n, onClose: r, vastUrl: d, options: c, isDesktop: i }) => {
146
- const h = (c == null ? void 0 : c.showPauseButton) ?? !0, { ref: l, focusSelf: f } = M.useFocusable({
141
+ }, ae = ({ isClosing: e, title: s, caption: t, onPlay: a, onClose: r, vastUrl: c, options: d, isDesktop: n }) => {
142
+ const h = (d == null ? void 0 : d.showPauseButton) ?? !0, { ref: i, focusSelf: f } = _.useFocusable({
147
143
  focusKey: "sl-pause-ad-play",
148
- onEnterRelease: n,
144
+ onEnterRelease: a,
149
145
  isFocusBoundary: !0,
150
146
  forceFocus: !0
151
147
  });
152
148
  return T(() => {
153
- l.current && f();
154
- }, [l, f]), T(() => {
149
+ i.current && f();
150
+ }, [i, f]), T(() => {
155
151
  if (!r)
156
152
  return () => {
157
153
  };
@@ -163,36 +159,34 @@ const O = {}, W = new z(), b = F(O), E = K("ui:gam-static"), U = (e) => new Prom
163
159
  }
164
160
  };
165
161
  return window.addEventListener("keydown", g, { capture: !0 }), () => window.removeEventListener("keydown", g, { capture: !0 });
166
- }, [r]), /* @__PURE__ */ a(X, { className: _("SL_PauseAdOverlay", e && "pause-ad-closing"), children: /* @__PURE__ */ I(H, { children: [
167
- /* @__PURE__ */ a(J, {}),
168
- /* @__PURE__ */ a(Q, {}),
169
- /* @__PURE__ */ I(Y, { children: [
170
- /* @__PURE__ */ a(Z, { children: s }),
171
- /* @__PURE__ */ a(ee, { children: t })
162
+ }, [r]), /* @__PURE__ */ l(Q, { className: $("SL_PauseAdOverlay", e && "pause-ad-closing"), children: /* @__PURE__ */ L(H, { children: [
163
+ /* @__PURE__ */ L(W, { children: [
164
+ /* @__PURE__ */ l(X, { children: s }),
165
+ /* @__PURE__ */ l(Y, { children: t })
172
166
  ] }),
173
- h && /* @__PURE__ */ a(se, { children: /* @__PURE__ */ a(
174
- re,
167
+ h && /* @__PURE__ */ l(Z, { children: /* @__PURE__ */ l(
168
+ ee,
175
169
  {
176
- ref: l,
177
- onClick: n,
178
- onMouseEnter: () => l.current.focus(),
170
+ ref: i,
171
+ onClick: a,
172
+ onMouseEnter: () => i.current.focus(),
179
173
  "aria-label": "Resume playback"
180
174
  }
181
175
  ) }),
182
- /* @__PURE__ */ I(te, { children: [
183
- d && /* @__PURE__ */ a(ae, { isDesktop: i, vastUrl: d }),
184
- /* @__PURE__ */ a(oe, { children: "ADVERTISEMENT" })
185
- ] })
176
+ /* @__PURE__ */ l(se, { className: "SL_PauseAdSidebar", children: /* @__PURE__ */ L(re, { children: [
177
+ c && /* @__PURE__ */ l(oe, { isDesktop: n, vastUrl: c }),
178
+ /* @__PURE__ */ l(te, { children: "ADVERTISEMENT" })
179
+ ] }) })
186
180
  ] }) });
187
- }, ie = ({ showPauseAd: e, vastUrls: s, title: t, caption: n, sdk: r, onClose: d, onRender: c, options: i, isDesktop: h }) => {
188
- const l = (i == null ? void 0 : i.pauseAdDelay) ?? 5e3, [f, g] = R(!1), [y, v] = R(!1), u = D(), o = s == null ? void 0 : s[0].url, m = D(o);
189
- m.current = o;
190
- const [P, w] = V(), S = L(() => {
191
- d && (k.emit("exposedPauseAd", {
181
+ }, ne = ({ showPauseAd: e, vastUrls: s, title: t, caption: a, sdk: r, onClose: c, onRender: d, options: n, isDesktop: h }) => {
182
+ const i = (n == null ? void 0 : n.pauseAdDelay) ?? 5e3, [f, g] = R(!1), [y, v] = R(!1), u = D(), o = s == null ? void 0 : s[0].url, p = D(o);
183
+ p.current = o;
184
+ const [P, b] = V(), S = I(() => {
185
+ c && (k.emit("exposedPauseAd", {
192
186
  action: "closed",
193
187
  payload: {}
194
- }), d());
195
- }, [d]), A = L(() => {
188
+ }), c());
189
+ }, [c]), A = I(() => {
196
190
  r.controlVideoPlayer({ play: !0 });
197
191
  }, [r]);
198
192
  return T(() => {
@@ -201,19 +195,19 @@ const O = {}, W = new z(), b = F(O), E = K("ui:gam-static"), U = (e) => new Prom
201
195
  action: "enabled",
202
196
  payload: {}
203
197
  }), P(o).then((x) => {
204
- m.current === o && (x == null ? void 0 : x.success) !== !0 && (clearTimeout(u.current), S == null || S());
198
+ p.current === o && (x == null ? void 0 : x.success) !== !0 && (clearTimeout(u.current), S == null || S());
205
199
  }).catch(() => {
206
- m.current === o && (clearTimeout(u.current), S == null || S());
200
+ p.current === o && (clearTimeout(u.current), S == null || S());
207
201
  });
208
202
  const C = () => {
209
- const x = w.get()[m.current];
203
+ const x = b.get()[p.current];
210
204
  x != null && x.imageSrc ? (clearTimeout(u.current), v(!1), g(!0)) : u.current = setTimeout(() => {
211
205
  C();
212
206
  }, 200);
213
207
  };
214
208
  u.current = setTimeout(() => {
215
209
  C();
216
- }, l);
210
+ }, i);
217
211
  } else
218
212
  k.emit("exposedPauseAd", {
219
213
  action: "disabled",
@@ -224,61 +218,61 @@ const O = {}, W = new z(), b = F(O), E = K("ui:gam-static"), U = (e) => new Prom
224
218
  return () => {
225
219
  u.current && clearTimeout(u.current);
226
220
  };
227
- }, [w, P, S, l, e, o]), T(() => {
228
- c == null || c({ rendered: f });
229
- }, [f, c]), T(() => () => {
230
- c == null || c({ rendered: !1 });
231
- }, [c]), f ? /* @__PURE__ */ a(
232
- ne,
221
+ }, [b, P, S, i, e, o]), T(() => {
222
+ d == null || d({ rendered: f });
223
+ }, [f, d]), T(() => () => {
224
+ d == null || d({ rendered: !1 });
225
+ }, [d]), f ? /* @__PURE__ */ l(
226
+ ae,
233
227
  {
234
228
  onClose: S,
235
229
  isClosing: y,
236
230
  title: t,
237
- caption: n,
231
+ caption: a,
238
232
  onPlay: A,
239
233
  vastUrl: o,
240
- options: i,
234
+ options: n,
241
235
  isDesktop: h
242
236
  }
243
237
  ) : null;
244
- }, le = ({
238
+ }, ie = ({
245
239
  showPauseAd: e,
246
240
  pauseAdVastUrl: s,
247
241
  videoPlayerController: t,
248
- onRenderPauseAd: n,
242
+ onRenderPauseAd: a,
249
243
  onClosePauseAd: r,
250
- children: d,
251
- options: c
244
+ children: c,
245
+ options: d
252
246
  }) => {
253
- const i = q(), h = G(), l = D();
254
- return T(() => i ? (t && (l.current = t, i.addVideoPlayerController(l.current)), () => {
255
- l.current && i.removeVideoPlayerController(l.current);
247
+ const n = N(), h = j(), i = D();
248
+ return T(() => n ? (t && (i.current = t, n.addVideoPlayerController(i.current)), () => {
249
+ i.current && n.removeVideoPlayerController(i.current);
256
250
  }) : () => {
257
- }, [i, t]), i ? /* @__PURE__ */ a("div", { className: "StreamLayerSDK", children: /* @__PURE__ */ I(
258
- N,
251
+ }, [n, t]), n ? /* @__PURE__ */ l("div", { className: "StreamLayerSDK", children: /* @__PURE__ */ L(
252
+ q,
259
253
  {
260
- style: d ? { position: "relative" } : {},
254
+ style: c ? { position: "relative" } : {},
261
255
  customTheme: h.theme,
262
256
  themeMode: h.themeMode,
263
257
  children: [
264
- d,
265
- s && /* @__PURE__ */ a(
266
- ie,
258
+ c,
259
+ s && /* @__PURE__ */ l(
260
+ ne,
267
261
  {
268
- sdk: i,
262
+ sdk: n,
269
263
  showPauseAd: e,
270
264
  vastUrls: s,
271
265
  onClose: r,
272
- onRender: n,
273
- options: c,
266
+ onRender: a,
267
+ options: d,
274
268
  isDesktop: !0
275
269
  }
276
270
  )
277
271
  ]
278
272
  }
279
- ) }) : d;
273
+ ) }) : c;
280
274
  };
281
- class Ae extends $ {
275
+ class ye extends O {
282
276
  constructor(s) {
283
277
  super(s), this.state = { hasError: !1 };
284
278
  }
@@ -289,9 +283,9 @@ class Ae extends $ {
289
283
  console.error(s, t.componentStack);
290
284
  }
291
285
  render() {
292
- return this.state.hasError ? this.props.children : /* @__PURE__ */ a(le, { ...this.props });
286
+ return this.state.hasError ? this.props.children : /* @__PURE__ */ l(ie, { ...this.props });
293
287
  }
294
288
  }
295
289
  export {
296
- Ae as StreamLayerPauseAd
290
+ ye as StreamLayerPauseAd
297
291
  };
@@ -8321,7 +8321,7 @@ const aR = ({
8321
8321
  p = !0;
8322
8322
  };
8323
8323
  const W = zb(e, n, l, {
8324
- version: "1.21.0",
8324
+ version: "1.21.1",
8325
8325
  onDeepLinkHandled: o,
8326
8326
  videoPlayerController: i,
8327
8327
  onContentActivate: a,