@streamlayer/react 1.19.1 → 1.20.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.
Files changed (38) hide show
  1. package/lib/app/pause-ad.d.ts +38 -0
  2. package/lib/cjs/advertisement.js +38 -42
  3. package/lib/cjs/index-l-eyvmpL.js +5 -0
  4. package/lib/cjs/pause-ad.js +1 -0
  5. package/lib/cjs/provider.js +23 -23
  6. package/lib/cjs/useStreamLayerApp2.js +4 -4
  7. package/lib/cjs/vast-client.min-B0NUra1B.js +1 -0
  8. package/lib/classic/app/pause-ad.d.ts +38 -0
  9. package/lib/classic/cjs/advertisement.js +38 -42
  10. package/lib/classic/cjs/index-l-eyvmpL.js +5 -0
  11. package/lib/classic/cjs/pause-ad.js +1 -0
  12. package/lib/classic/cjs/provider.js +17 -17
  13. package/lib/classic/cjs/useStreamLayerApp2.js +4 -4
  14. package/lib/classic/cjs/vast-client.min-B0NUra1B.js +1 -0
  15. package/lib/classic/es/advertisement.js +10211 -15019
  16. package/lib/classic/es/bet-pack.js +1 -1
  17. package/lib/classic/es/index-l-eyvmpL.js +3758 -0
  18. package/lib/classic/es/index.js +3 -3
  19. package/lib/classic/es/notification.js +1 -1
  20. package/lib/classic/es/pause-ad.js +250 -0
  21. package/lib/classic/es/provider.js +6182 -5725
  22. package/lib/classic/es/useStreamLayerApp2.js +90 -90
  23. package/lib/classic/es/vast-client.min-B0NUra1B.js +1060 -0
  24. package/lib/dist/cjs/masters.js +9 -9
  25. package/lib/dist/es/masters.js +112 -112
  26. package/lib/dist/style.css +1 -1
  27. package/lib/es/advertisement.js +10211 -15019
  28. package/lib/es/index-l-eyvmpL.js +3758 -0
  29. package/lib/es/index.js +1 -1
  30. package/lib/es/index2.js +1 -1
  31. package/lib/es/masters2.js +1 -1
  32. package/lib/es/notification.js +53 -53
  33. package/lib/es/pause-ad.js +250 -0
  34. package/lib/es/provider.js +5846 -5412
  35. package/lib/es/useStreamLayerApp2.js +90 -90
  36. package/lib/es/vast-client.min-B0NUra1B.js +1060 -0
  37. package/lib/style.css +1 -1
  38. package/package.json +28 -18
@@ -1,11 +1,11 @@
1
- import { w as m, S, z as o, h as i, u as s, b as y, p as L } from "./provider.js";
1
+ import { z as m, S, A as o, h as i, u as s, b as y, r as L } from "./provider.js";
2
2
  import "react/jsx-runtime";
3
3
  import "react";
4
- import { StreamLayerSDKNotification as f, StreamLayerSDKNotificationUI as u } from "./notification.js";
4
+ import { StreamLayerSDKNotification as p, StreamLayerSDKNotificationUI as u } from "./notification.js";
5
5
  export {
6
6
  m as StreamLayerProvider,
7
7
  S as StreamLayerSDKEvent,
8
- f as StreamLayerSDKNotification,
8
+ p as StreamLayerSDKNotification,
9
9
  u as StreamLayerSDKNotificationUI,
10
10
  o as StreamLayerSDKReact,
11
11
  i as StreamLayerThemeProvider,
@@ -1,4 +1,4 @@
1
- import { s as n, B as A, D as As, r as Is, x as _, t as K, v as hs, E as $s, O as x, y as gs, d as ws, a as ys, e as Ts, N as O, u as bs, b as Cs, p as fs, h as ks } from "./provider.js";
1
+ import { s as n, B as A, D as As, t as Is, x as _, v as K, w as hs, E as $s, O as x, y as gs, d as ws, a as ys, e as Ts, N as O, u as bs, b as Cs, r as fs, h as ks } from "./provider.js";
2
2
  import { jsxs as l, jsx as s } from "react/jsx-runtime";
3
3
  import { useState as w, useRef as G, useEffect as y, useCallback as Ns, useMemo as qs } from "react";
4
4
  import { l as v, Q as h, m as H, r as L, S as Es, A as R } from "./useStreamLayerApp2.js";
@@ -0,0 +1,250 @@
1
+ import { jsx as n, jsxs as I } from "react/jsx-runtime";
2
+ import { c as K, i as V, s as p, e as x, f as F, j as M, a as _, u as j, b as q, h as z } from "./provider.js";
3
+ import { useRef as L, useCallback as C, useState as R, useEffect as b, Component as G } from "react";
4
+ import { c as N } from "./vast-client.min-B0NUra1B.js";
5
+ const H = {}, O = new N(), w = V(H), E = K("ui:gam-static"), U = (r) => new Promise((e, a) => {
6
+ const s = new Image();
7
+ s.onload = () => e(r), s.onerror = () => a(), s.src = r;
8
+ }), D = () => {
9
+ const r = L(0);
10
+ return [C(async (e) => {
11
+ var a, s, c, o, l, t, u, i, f, m, h;
12
+ if ((a = w.get()[e]) != null && a.imageSrc)
13
+ return { success: !0 };
14
+ const v = Date.now();
15
+ r.current = v, w.setKey(e, { url: e });
16
+ try {
17
+ const d = await O.get(e);
18
+ if (E.debug(d, "parsedVAST"), r.current === v && w.get()[e].url) {
19
+ const y = d.ads.find((g) => g.creatives.length > 0);
20
+ if (y) {
21
+ E.debug(y, "validAd");
22
+ const g = y.creatives.find((S) => S.type === "nonlinear");
23
+ if (g) {
24
+ E.debug(g, "nonlinear");
25
+ const S = (c = (s = g.variations) == null ? void 0 : s[0]) == null ? void 0 : c.staticResource, B = (l = (o = g.variations) == null ? void 0 : o[0]) == null ? void 0 : l.nonlinearClickThroughURLTemplate;
26
+ if (S)
27
+ return await U(S), w.setKey(e, { url: e, imageSrc: S, adUrl: B }), { success: !0 };
28
+ }
29
+ const A = y.creatives.find((S) => S.type === "companion");
30
+ E.debug(A, "companion");
31
+ const T = (f = (i = (u = (t = A == null ? void 0 : A.variations) == null ? void 0 : t[0]) == null ? void 0 : u.staticResources) == null ? void 0 : i[0]) == null ? void 0 : f.url, P = (h = (m = A == null ? void 0 : A.variations) == null ? void 0 : m[0]) == null ? void 0 : h.companionClickThroughURLTemplate;
32
+ if (T)
33
+ return await U(T), w.setKey(e, { url: e, imageSrc: T, adUrl: P }), { success: !0 };
34
+ }
35
+ }
36
+ } catch (d) {
37
+ console.error("Error parsing VAST", d);
38
+ }
39
+ return { success: !1 };
40
+ }, []), w];
41
+ }, J = /* @__PURE__ */ p("div")({
42
+ name: "PauseAdOverlay",
43
+ class: "pw9gih8",
44
+ propsAsIs: !1
45
+ }), Q = /* @__PURE__ */ p("div")({
46
+ name: "PauseAdContent",
47
+ class: "p8lpomy",
48
+ propsAsIs: !1
49
+ }), W = /* @__PURE__ */ p("div")({
50
+ name: "PauseAdGradientLeft",
51
+ class: "pv7u167",
52
+ propsAsIs: !1
53
+ }), X = /* @__PURE__ */ p("div")({
54
+ name: "PauseAdGradientRight",
55
+ class: "p1kh2yb0",
56
+ propsAsIs: !1
57
+ }), Y = /* @__PURE__ */ p("div")({
58
+ name: "PauseAdGradientBottom",
59
+ class: "pl8f94x",
60
+ propsAsIs: !1
61
+ }), Z = /* @__PURE__ */ p("div")({
62
+ name: "PauseAdTopLeft",
63
+ class: "p1m6zmrt",
64
+ propsAsIs: !1
65
+ }), $ = /* @__PURE__ */ p("h2")({
66
+ name: "PauseAdTitle",
67
+ class: "pm3vwfa",
68
+ propsAsIs: !1
69
+ }), ee = /* @__PURE__ */ p("p")({
70
+ name: "PauseAdCaption",
71
+ class: "p1tibuhw",
72
+ propsAsIs: !1
73
+ }), re = /* @__PURE__ */ p("div")({
74
+ name: "PauseAdBottomLeft",
75
+ class: "ptqqrqd",
76
+ propsAsIs: !1
77
+ }), se = /* @__PURE__ */ p("button")({
78
+ name: "PauseAdPlayButton",
79
+ class: "p14estxv",
80
+ propsAsIs: !1
81
+ }), te = /* @__PURE__ */ p("div")({
82
+ name: "PauseAdSidebar",
83
+ class: "p1dpvfl1",
84
+ propsAsIs: !1
85
+ }), k = /* @__PURE__ */ p("img")({
86
+ name: "ExternalAdContainer",
87
+ class: "ezfmabr",
88
+ propsAsIs: !1
89
+ }), ne = ({ vastUrl: r }) => {
90
+ var e;
91
+ const [, a] = D(), s = _(a, { keys: [r] });
92
+ return (e = s == null ? void 0 : s[r]) != null && e.imageSrc ? s[r].adUrl ? /* @__PURE__ */ n("a", { href: s[r].adUrl, target: "_blank", rel: "noopener noreferrer", children: /* @__PURE__ */ n(k, { src: s[r].imageSrc }) }) : /* @__PURE__ */ n(k, { src: s[r].imageSrc }) : null;
93
+ }, ae = ({ isClosing: r, title: e, caption: a, onPlay: s, onClose: c, vastUrl: o, options: l }) => {
94
+ const t = (l == null ? void 0 : l.showPauseButton) ?? !0, { ref: u, focusSelf: i } = F.useFocusable({
95
+ focusKey: "sl-pause-ad-play",
96
+ onEnterRelease: s,
97
+ isFocusBoundary: !0,
98
+ forceFocus: !0
99
+ });
100
+ return b(() => {
101
+ u.current && i();
102
+ }, [u, i]), b(() => {
103
+ const f = (m) => {
104
+ const h = m.keyCode;
105
+ if (h === 461 || h === 10009 || h === 27) {
106
+ m.preventDefault(), m.stopPropagation(), m.stopImmediatePropagation(), c == null || c();
107
+ return;
108
+ }
109
+ };
110
+ return window.addEventListener("keydown", f, { capture: !0 }), () => window.removeEventListener("keydown", f, { capture: !0 });
111
+ }, [c]), /* @__PURE__ */ n(J, { className: M(r && "pause-ad-closing"), children: /* @__PURE__ */ I(Q, { children: [
112
+ /* @__PURE__ */ n(W, {}),
113
+ /* @__PURE__ */ n(X, {}),
114
+ /* @__PURE__ */ n(Y, {}),
115
+ /* @__PURE__ */ I(Z, { children: [
116
+ /* @__PURE__ */ n($, { children: e }),
117
+ /* @__PURE__ */ n(ee, { children: a })
118
+ ] }),
119
+ t && /* @__PURE__ */ n(re, { children: /* @__PURE__ */ n(
120
+ se,
121
+ {
122
+ ref: u,
123
+ onClick: s,
124
+ onMouseEnter: () => u.current.focus(),
125
+ "aria-label": "Resume playback"
126
+ }
127
+ ) }),
128
+ /* @__PURE__ */ I(te, { children: [
129
+ o && /* @__PURE__ */ n(ne, { vastUrl: o }),
130
+ /* @__PURE__ */ n("span", { children: "ADVERTISEMENT" })
131
+ ] })
132
+ ] }) });
133
+ }, oe = ({
134
+ showPauseAd: r,
135
+ vastUrls: e,
136
+ title: a,
137
+ caption: s,
138
+ onPlay: c,
139
+ onClose: o,
140
+ onRender: l,
141
+ options: t
142
+ }) => {
143
+ const u = (t == null ? void 0 : t.pauseAdDelay) ?? 5e3, [i, f] = R(!1), [m, h] = R(!1), v = L(), d = e == null ? void 0 : e[0].url, y = L(d);
144
+ y.current = d;
145
+ const [g, A] = D();
146
+ return b(() => {
147
+ if (r && d) {
148
+ x.emit("exposedPauseAd", {
149
+ action: "enabled",
150
+ payload: {}
151
+ }), g(d).then((P) => {
152
+ y.current === d && (P == null ? void 0 : P.success) !== !0 && (clearTimeout(v.current), o == null || o());
153
+ }).catch(() => {
154
+ y.current === d && (clearTimeout(v.current), o == null || o());
155
+ });
156
+ const T = () => {
157
+ var P;
158
+ (P = A.get()[y.current]) != null && P.imageSrc ? (clearTimeout(v.current), h(!1), f(!0), x.emit("exposedPauseAd", {
159
+ action: "rendered",
160
+ payload: {}
161
+ })) : v.current = setTimeout(() => {
162
+ T();
163
+ }, 200);
164
+ };
165
+ v.current = setTimeout(() => {
166
+ T();
167
+ }, u);
168
+ } else
169
+ x.emit("exposedPauseAd", {
170
+ action: "disabled",
171
+ payload: {}
172
+ }), h(!0), v.current = setTimeout(() => {
173
+ f(!1);
174
+ }, 400);
175
+ return () => {
176
+ v.current && clearTimeout(v.current);
177
+ };
178
+ }, [A, g, o, u, r, d]), b(() => {
179
+ l == null || l({ rendered: i });
180
+ }, [i, l]), b(() => () => {
181
+ l == null || l({ rendered: !1 });
182
+ }, [l]), i ? /* @__PURE__ */ n(
183
+ ae,
184
+ {
185
+ onClose: o,
186
+ isClosing: m,
187
+ title: a,
188
+ caption: s,
189
+ onPlay: c,
190
+ vastUrl: d,
191
+ options: t
192
+ }
193
+ ) : null;
194
+ }, le = ({
195
+ showPauseAd: r,
196
+ pauseAdVastUrl: e,
197
+ videoPlayerController: a,
198
+ onRenderPauseAd: s,
199
+ onClosePauseAd: c,
200
+ children: o,
201
+ options: l
202
+ }) => {
203
+ const t = j(), u = q(), i = L(), f = C(() => {
204
+ c == null || c();
205
+ }, [c]), m = C(() => {
206
+ t == null || t.controlVideoPlayer({ play: !0 });
207
+ }, [t]);
208
+ return b(() => t ? (a && (i.current = a, t.addVideoPlayerController(i.current)), () => {
209
+ i.current && t.removeVideoPlayerController(i.current);
210
+ }) : () => {
211
+ }, [t, a]), t ? /* @__PURE__ */ n("div", { className: "StreamLayerSDK", children: /* @__PURE__ */ I(
212
+ z,
213
+ {
214
+ style: { position: "relative" },
215
+ customTheme: u.theme,
216
+ themeMode: u.themeMode,
217
+ children: [
218
+ o,
219
+ e && /* @__PURE__ */ n(
220
+ oe,
221
+ {
222
+ showPauseAd: r,
223
+ vastUrls: e,
224
+ onClose: f,
225
+ onRender: s,
226
+ onPlay: m,
227
+ options: l
228
+ }
229
+ )
230
+ ]
231
+ }
232
+ ) }) : o;
233
+ };
234
+ class pe extends G {
235
+ constructor(e) {
236
+ super(e), this.state = { hasError: !1 };
237
+ }
238
+ static getDerivedStateFromError() {
239
+ return { hasError: !0 };
240
+ }
241
+ componentDidCatch(e, a) {
242
+ console.error(e, a.componentStack);
243
+ }
244
+ render() {
245
+ return this.state.hasError ? this.props.children : /* @__PURE__ */ n(le, { ...this.props });
246
+ }
247
+ }
248
+ export {
249
+ pe as StreamLayerPauseAd
250
+ };