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