@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.
- package/lib/cjs/pause-ad.js +1 -1
- package/lib/cjs/useStreamLayerApp2.js +1 -1
- package/lib/classic/cjs/pause-ad.js +1 -1
- package/lib/classic/cjs/useStreamLayerApp2.js +1 -1
- package/lib/classic/es/pause-ad.js +108 -114
- package/lib/classic/es/useStreamLayerApp2.js +1 -1
- package/lib/dist/cjs/masters.js +1 -1
- package/lib/dist/es/masters.js +1 -1
- package/lib/dist/style.css +1 -1
- package/lib/es/pause-ad.js +104 -110
- package/lib/es/useStreamLayerApp2.js +1 -1
- package/lib/style.css +1 -1
- package/package.json +14 -14
package/lib/es/pause-ad.js
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { j as K, k as
|
|
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
|
|
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
|
|
11
|
-
const
|
|
12
|
-
|
|
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 [
|
|
16
|
-
var t,
|
|
17
|
-
if ((t =
|
|
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,
|
|
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
|
|
27
|
-
if (E.debug(u, "parsedVAST"), e.current === v &&
|
|
28
|
-
const o = u.ads.find((
|
|
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
|
|
32
|
-
if (
|
|
33
|
-
E.debug(
|
|
34
|
-
const A = (r = (
|
|
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),
|
|
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
|
|
51
|
-
if (
|
|
52
|
-
return await U(
|
|
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:
|
|
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
|
-
}, []),
|
|
70
|
-
},
|
|
69
|
+
}, []), w];
|
|
70
|
+
}, Q = /* @__PURE__ */ m("div")({
|
|
71
71
|
name: "PauseAdOverlay",
|
|
72
72
|
class: "pw9gih8",
|
|
73
73
|
propsAsIs: !1
|
|
74
|
-
}), H = /* @__PURE__ */
|
|
74
|
+
}), H = /* @__PURE__ */ m("div")({
|
|
75
75
|
name: "PauseAdContent",
|
|
76
76
|
class: "p8lpomy",
|
|
77
77
|
propsAsIs: !1
|
|
78
|
-
}),
|
|
79
|
-
name: "
|
|
78
|
+
}), W = /* @__PURE__ */ m("div")({
|
|
79
|
+
name: "PauseAdTopLeft",
|
|
80
80
|
class: "pv7u167",
|
|
81
81
|
propsAsIs: !1
|
|
82
|
-
}),
|
|
83
|
-
name: "
|
|
82
|
+
}), X = /* @__PURE__ */ m("h2")({
|
|
83
|
+
name: "PauseAdTitle",
|
|
84
84
|
class: "p1kh2yb0",
|
|
85
85
|
propsAsIs: !1
|
|
86
|
-
}), Y = /* @__PURE__ */
|
|
87
|
-
name: "
|
|
86
|
+
}), Y = /* @__PURE__ */ m("p")({
|
|
87
|
+
name: "PauseAdCaption",
|
|
88
88
|
class: "pl8f94x",
|
|
89
89
|
propsAsIs: !1
|
|
90
|
-
}), Z = /* @__PURE__ */
|
|
91
|
-
name: "
|
|
90
|
+
}), Z = /* @__PURE__ */ m("div")({
|
|
91
|
+
name: "PauseAdBottomLeft",
|
|
92
92
|
class: "p1m6zmrt",
|
|
93
93
|
propsAsIs: !1
|
|
94
|
-
}), ee = /* @__PURE__ */
|
|
95
|
-
name: "
|
|
94
|
+
}), ee = /* @__PURE__ */ m("button")({
|
|
95
|
+
name: "PauseAdPlayButton",
|
|
96
96
|
class: "pm3vwfa",
|
|
97
97
|
propsAsIs: !1
|
|
98
|
-
}), se = /* @__PURE__ */
|
|
99
|
-
name: "
|
|
98
|
+
}), se = /* @__PURE__ */ m("div")({
|
|
99
|
+
name: "PauseAdSidebarGradient",
|
|
100
100
|
class: "p1tibuhw",
|
|
101
101
|
propsAsIs: !1
|
|
102
|
-
}), re = /* @__PURE__ */
|
|
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: "
|
|
104
|
+
class: "ptqqrqd",
|
|
109
105
|
propsAsIs: !1
|
|
110
|
-
}),
|
|
106
|
+
}), te = /* @__PURE__ */ m("span")({
|
|
111
107
|
name: "PauseAdTitleDescription",
|
|
112
|
-
class: "
|
|
108
|
+
class: "p14estxv",
|
|
113
109
|
propsAsIs: !1
|
|
114
|
-
}), B = /* @__PURE__ */
|
|
110
|
+
}), B = /* @__PURE__ */ m("img")({
|
|
115
111
|
name: "ExternalAdContainer",
|
|
116
|
-
class: "
|
|
112
|
+
class: "e1dpvfl1",
|
|
117
113
|
propsAsIs: !1
|
|
118
|
-
}),
|
|
114
|
+
}), oe = ({ vastUrl: e, isDesktop: s }) => {
|
|
119
115
|
var t;
|
|
120
|
-
const [,
|
|
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__ */
|
|
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__ */
|
|
138
|
+
children: /* @__PURE__ */ l(B, { src: r[e].imageSrc })
|
|
143
139
|
}
|
|
144
140
|
) : null;
|
|
145
|
-
},
|
|
146
|
-
const h = (
|
|
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:
|
|
144
|
+
onEnterRelease: a,
|
|
149
145
|
isFocusBoundary: !0,
|
|
150
146
|
forceFocus: !0
|
|
151
147
|
});
|
|
152
148
|
return T(() => {
|
|
153
|
-
|
|
154
|
-
}, [
|
|
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__ */
|
|
167
|
-
/* @__PURE__ */
|
|
168
|
-
|
|
169
|
-
|
|
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__ */
|
|
174
|
-
|
|
167
|
+
h && /* @__PURE__ */ l(Z, { children: /* @__PURE__ */ l(
|
|
168
|
+
ee,
|
|
175
169
|
{
|
|
176
|
-
ref:
|
|
177
|
-
onClick:
|
|
178
|
-
onMouseEnter: () =>
|
|
170
|
+
ref: i,
|
|
171
|
+
onClick: a,
|
|
172
|
+
onMouseEnter: () => i.current.focus(),
|
|
179
173
|
"aria-label": "Resume playback"
|
|
180
174
|
}
|
|
181
175
|
) }),
|
|
182
|
-
/* @__PURE__ */
|
|
183
|
-
|
|
184
|
-
/* @__PURE__ */
|
|
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
|
-
},
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
const [P,
|
|
191
|
-
|
|
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
|
-
}),
|
|
195
|
-
}, [
|
|
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
|
-
|
|
198
|
+
p.current === o && (x == null ? void 0 : x.success) !== !0 && (clearTimeout(u.current), S == null || S());
|
|
205
199
|
}).catch(() => {
|
|
206
|
-
|
|
200
|
+
p.current === o && (clearTimeout(u.current), S == null || S());
|
|
207
201
|
});
|
|
208
202
|
const C = () => {
|
|
209
|
-
const x =
|
|
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
|
-
},
|
|
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
|
-
}, [
|
|
228
|
-
|
|
229
|
-
}, [f,
|
|
230
|
-
|
|
231
|
-
}, [
|
|
232
|
-
|
|
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:
|
|
231
|
+
caption: a,
|
|
238
232
|
onPlay: A,
|
|
239
233
|
vastUrl: o,
|
|
240
|
-
options:
|
|
234
|
+
options: n,
|
|
241
235
|
isDesktop: h
|
|
242
236
|
}
|
|
243
237
|
) : null;
|
|
244
|
-
},
|
|
238
|
+
}, ie = ({
|
|
245
239
|
showPauseAd: e,
|
|
246
240
|
pauseAdVastUrl: s,
|
|
247
241
|
videoPlayerController: t,
|
|
248
|
-
onRenderPauseAd:
|
|
242
|
+
onRenderPauseAd: a,
|
|
249
243
|
onClosePauseAd: r,
|
|
250
|
-
children:
|
|
251
|
-
options:
|
|
244
|
+
children: c,
|
|
245
|
+
options: d
|
|
252
246
|
}) => {
|
|
253
|
-
const
|
|
254
|
-
return T(() =>
|
|
255
|
-
|
|
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
|
-
}, [
|
|
258
|
-
|
|
251
|
+
}, [n, t]), n ? /* @__PURE__ */ l("div", { className: "StreamLayerSDK", children: /* @__PURE__ */ L(
|
|
252
|
+
q,
|
|
259
253
|
{
|
|
260
|
-
style:
|
|
254
|
+
style: c ? { position: "relative" } : {},
|
|
261
255
|
customTheme: h.theme,
|
|
262
256
|
themeMode: h.themeMode,
|
|
263
257
|
children: [
|
|
264
|
-
|
|
265
|
-
s && /* @__PURE__ */
|
|
266
|
-
|
|
258
|
+
c,
|
|
259
|
+
s && /* @__PURE__ */ l(
|
|
260
|
+
ne,
|
|
267
261
|
{
|
|
268
|
-
sdk:
|
|
262
|
+
sdk: n,
|
|
269
263
|
showPauseAd: e,
|
|
270
264
|
vastUrls: s,
|
|
271
265
|
onClose: r,
|
|
272
|
-
onRender:
|
|
273
|
-
options:
|
|
266
|
+
onRender: a,
|
|
267
|
+
options: d,
|
|
274
268
|
isDesktop: !0
|
|
275
269
|
}
|
|
276
270
|
)
|
|
277
271
|
]
|
|
278
272
|
}
|
|
279
|
-
) }) :
|
|
273
|
+
) }) : c;
|
|
280
274
|
};
|
|
281
|
-
class
|
|
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__ */
|
|
286
|
+
return this.state.hasError ? this.props.children : /* @__PURE__ */ l(ie, { ...this.props });
|
|
293
287
|
}
|
|
294
288
|
}
|
|
295
289
|
export {
|
|
296
|
-
|
|
290
|
+
ye as StreamLayerPauseAd
|
|
297
291
|
};
|