@streamlayer/react-ui 1.28.3 → 1.29.0
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/app/Layout/styles.d.ts +1 -0
- package/lib/app/app/Layout/styles.js +33 -24
- package/lib/app/webos/ExposedPauseAd/PauseAd.d.ts +2 -0
- package/lib/app/webos/ExposedPauseAd/PauseAd.js +92 -70
- package/lib/app/webos/ExposedPauseAd/styles.d.ts +1 -1
- package/lib/app/webos/ExposedPauseAd/styles.js +5 -5
- package/lib/app/webos/index.d.ts +4 -0
- package/lib/app/webos/index.js +38 -36
- package/lib/app/webos/story.js +29 -25
- package/lib/app/webos/ui/Sidebar/PromoAction.js +38 -34
- package/lib/app/webos/ui/Sidebar/index.js +24 -24
- package/lib/app/webos/ui/Sidebar/styles.d.ts +1 -0
- package/lib/app/webos/ui/Sidebar/styles.js +120 -115
- package/lib/assets/style.css +1 -1
- package/lib/{index-DXvAPWiE.js → index-l-eyvmpL.js} +296 -281
- package/lib/ui/advertisement/notification/index.js +24 -24
- package/lib/ui/advertisement/notification/lower-third/index.js +48 -40
- package/lib/ui/advertisement/overlay/externalAd/vast-player/useGAMPlayer.js +8 -7
- package/lib/ui/advertisement/overlay/externalAd/vast-player/useGAMStatic.d.ts +9 -0
- package/lib/ui/advertisement/overlay/externalAd/vast-player/useGAMStatic.js +44 -0
- package/lib/ui/advertisement/overlay/externalAd/vast-player/useVastAds.js +240 -6
- package/lib/{useVastAds-CakWRNKN.js → vast-client.min-B0NUra1B.js} +358 -594
- package/package.json +17 -17
- package/lib/app/webos/ui/Layout/index.d.ts +0 -21
- package/lib/app/webos/ui/Layout/index.js +0 -78
- package/lib/app/webos/ui/Layout/styles.d.ts +0 -11
- package/lib/app/webos/ui/Layout/styles.js +0 -59
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
import { jsx as i, jsxs as m } from "react/jsx-runtime";
|
|
2
2
|
import { withFocusable as N } from "../../../app/webos/useTvButton.js";
|
|
3
|
-
import { NotificationPromotionImagePosition as
|
|
3
|
+
import { NotificationPromotionImagePosition as e, NotificationEnabled as E, NotificationPromotionMode as L, NotificationSponsorLogoMode as S, CtaIconMode as _ } from "@streamlayer/sdk-web-types";
|
|
4
4
|
import { SlideIn as D } from "../../slide-in/index.js";
|
|
5
5
|
import { LowerThirdNotification as R } from "./lower-third/index.js";
|
|
6
|
-
import { MediaImgFit as I, MediaImgCentered as P, MediaImgBottom as
|
|
6
|
+
import { MediaImgFit as I, MediaImgCentered as P, MediaImgBottom as A, MediaImgSolid as F, MediaImgMiddle as b, NotificationContainer as x, Logo as k, NotificationContent as u, Body as y, Title as W, Text as j, CtaIcon as v, StyledChevronRight as G, DismissButton as H, OpenButton as U } from "./styles.js";
|
|
7
7
|
const q = {
|
|
8
|
-
[
|
|
9
|
-
[
|
|
10
|
-
[
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
}, z = ({ src:
|
|
15
|
-
const c = q[
|
|
16
|
-
return /* @__PURE__ */ i(c, { children: /* @__PURE__ */ i("img", { src:
|
|
17
|
-
}, J = N(H), K = N(U), w = ({ notification:
|
|
18
|
-
if (!
|
|
8
|
+
[e.UNSET]: I,
|
|
9
|
+
[e.FIT]: I,
|
|
10
|
+
[e.CENTERED]: P,
|
|
11
|
+
[e.BOTTOM]: A,
|
|
12
|
+
[e.SOLID]: F,
|
|
13
|
+
[e.MIDDLE]: b
|
|
14
|
+
}, z = ({ src: n, imagePosition: t }) => {
|
|
15
|
+
const c = q[t];
|
|
16
|
+
return /* @__PURE__ */ i(c, { children: /* @__PURE__ */ i("img", { src: n, alt: "" }) });
|
|
17
|
+
}, J = N(H), K = N(U), w = ({ notification: n, open: t, promotionId: c, hiding: p, direction: g = "left", close: d, webos: r }) => {
|
|
18
|
+
if (!n || !n.promotion || n.enabled !== E.NOTIFICATION_ENABLED)
|
|
19
19
|
return null;
|
|
20
|
-
if (
|
|
21
|
-
return /* @__PURE__ */ i(R, { notification:
|
|
22
|
-
const { title: l, body: s, image: h, promotion: C } =
|
|
20
|
+
if (n.promotion.mode === L.LOWER_THIRD)
|
|
21
|
+
return /* @__PURE__ */ i(R, { notification: n, open: t, close: d, webos: r });
|
|
22
|
+
const { title: l, body: s, image: h, promotion: C } = n, { sponsorLogo: a, sponsorLogoMode: O, imagePosition: M, ctaButton: o } = C, T = (f) => {
|
|
23
23
|
f.stopPropagation(), d == null || d();
|
|
24
24
|
};
|
|
25
|
-
return /* @__PURE__ */ i(D, { className: "SL_Rich_Notification", direction: g, hiding: p, children: /* @__PURE__ */ m(
|
|
26
|
-
} :
|
|
27
|
-
O !== S.NOTIFICATION_SPONSOR_LOGO_NONE && a && /* @__PURE__ */ i(
|
|
28
|
-
/* @__PURE__ */ m(
|
|
25
|
+
return /* @__PURE__ */ i(D, { className: "SL_Rich_Notification", direction: g, hiding: p, children: /* @__PURE__ */ m(x, { onClick: r ? () => {
|
|
26
|
+
} : t, children: [
|
|
27
|
+
O !== S.NOTIFICATION_SPONSOR_LOGO_NONE && a && /* @__PURE__ */ i(k, { children: /* @__PURE__ */ i("img", { src: a, alt: l }) }),
|
|
28
|
+
/* @__PURE__ */ m(u, { children: [
|
|
29
29
|
/* @__PURE__ */ i(z, { src: h, imagePosition: M }),
|
|
30
30
|
/* @__PURE__ */ m(y, { children: [
|
|
31
31
|
l && /* @__PURE__ */ i(W, { children: l }),
|
|
32
32
|
s && /* @__PURE__ */ i(j, { children: s })
|
|
33
33
|
] }),
|
|
34
|
-
|
|
34
|
+
r && /* @__PURE__ */ i(J, { webos: !0, onClick: T, children: "Dismiss" }),
|
|
35
35
|
/* @__PURE__ */ m(
|
|
36
36
|
K,
|
|
37
37
|
{
|
|
38
|
-
webos:
|
|
39
|
-
autoFocus:
|
|
40
|
-
onClick:
|
|
38
|
+
webos: r,
|
|
39
|
+
autoFocus: r,
|
|
40
|
+
onClick: r ? t : () => {
|
|
41
41
|
},
|
|
42
42
|
name: "promo-button",
|
|
43
43
|
style: { color: o == null ? void 0 : o.textColor, backgroundColor: o == null ? void 0 : o.color },
|
|
@@ -1,51 +1,59 @@
|
|
|
1
1
|
import { jsx as i, jsxs as e, Fragment as m } from "react/jsx-runtime";
|
|
2
|
-
import { withFocusable as
|
|
2
|
+
import { withFocusable as O } from "../../../../app/webos/useTvButton.js";
|
|
3
3
|
import { NotificationPromotionImagePosition as N, NotificationEnabled as t, NotificationSponsorLogoMode as _, CtaIconMode as I } from "@streamlayer/sdk-web-types";
|
|
4
|
-
import { MediaImgBottom as
|
|
4
|
+
import { MediaImgBottom as C, MediaImgMiddle as f, NotificationContainer as L, NotificationContent as A, Body as S, Title as E, Text as P, Footer as x, Logo as D, Vector as F, CtaIcon as a, OpenButton as h, DismissButton as k } from "./styles.js";
|
|
5
5
|
const R = {
|
|
6
|
-
[N.BOTTOM]:
|
|
6
|
+
[N.BOTTOM]: C,
|
|
7
7
|
[N.MIDDLE]: f
|
|
8
8
|
}, w = ({ src: r, imagePosition: n }) => {
|
|
9
|
-
const l = R[n] ||
|
|
9
|
+
const l = R[n] || C;
|
|
10
10
|
return /* @__PURE__ */ i(l, { children: /* @__PURE__ */ i("img", { src: r, alt: "" }) });
|
|
11
|
-
}, y =
|
|
11
|
+
}, y = O(k), j = O(h), q = ({ notification: r, open: n, close: l, webos: s }) => {
|
|
12
12
|
if (!r || !r.promotion || r.enabled !== t.NOTIFICATION_ENABLED)
|
|
13
13
|
return null;
|
|
14
|
-
const { title:
|
|
15
|
-
return /* @__PURE__ */ e(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
/* @__PURE__ */
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
14
|
+
const { title: c, body: d, image: T, promotion: p } = r, { sponsorLogo: g, sponsorLogoMode: M, imagePosition: b, ctaButton: o } = p;
|
|
15
|
+
return /* @__PURE__ */ e(
|
|
16
|
+
L,
|
|
17
|
+
{
|
|
18
|
+
"data-webos": s,
|
|
19
|
+
className: "SL_Lower_Third_Notification",
|
|
20
|
+
onClick: s ? void 0 : n,
|
|
21
|
+
children: [
|
|
22
|
+
/* @__PURE__ */ e(A, { children: [
|
|
23
|
+
/* @__PURE__ */ i(w, { src: T, imagePosition: b }),
|
|
24
|
+
/* @__PURE__ */ e(S, { children: [
|
|
25
|
+
c && /* @__PURE__ */ i(E, { children: c }),
|
|
26
|
+
d && /* @__PURE__ */ i(P, { children: d })
|
|
27
|
+
] })
|
|
28
|
+
] }),
|
|
29
|
+
/* @__PURE__ */ e(x, { children: [
|
|
30
|
+
M !== _.NOTIFICATION_SPONSOR_LOGO_NONE && /* @__PURE__ */ e(m, { children: [
|
|
31
|
+
/* @__PURE__ */ i(D, { children: /* @__PURE__ */ i("img", { src: g, alt: c }) }),
|
|
32
|
+
/* @__PURE__ */ i(F, {})
|
|
33
|
+
] }),
|
|
34
|
+
s ? /* @__PURE__ */ e(m, { children: [
|
|
35
|
+
/* @__PURE__ */ i(y, { webos: !0, onClick: l, children: "Dismiss" }),
|
|
36
|
+
/* @__PURE__ */ e(
|
|
37
|
+
j,
|
|
38
|
+
{
|
|
39
|
+
webos: !0,
|
|
40
|
+
autoFocus: !0,
|
|
41
|
+
style: { color: o == null ? void 0 : o.textColor, backgroundColor: o == null ? void 0 : o.color },
|
|
42
|
+
onClick: n,
|
|
43
|
+
children: [
|
|
44
|
+
(o == null ? void 0 : o.ctaIcon) && (o == null ? void 0 : o.ctaIconMode) === I.CTA_ICON_TRANSPARENT && /* @__PURE__ */ i(a, { src: o == null ? void 0 : o.ctaIcon, alt: "cta-icon" }),
|
|
45
|
+
(o == null ? void 0 : o.label) || "Open"
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
] }) : /* @__PURE__ */ e(h, { name: "promo-button", style: { color: o == null ? void 0 : o.textColor, backgroundColor: o == null ? void 0 : o.color }, children: [
|
|
50
|
+
(o == null ? void 0 : o.ctaIcon) && (o == null ? void 0 : o.ctaIconMode) === I.CTA_ICON_TRANSPARENT && /* @__PURE__ */ i(a, { src: o == null ? void 0 : o.ctaIcon, alt: "cta-icon" }),
|
|
51
|
+
(o == null ? void 0 : o.label) || "Open"
|
|
52
|
+
] })
|
|
53
|
+
] })
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
);
|
|
49
57
|
};
|
|
50
58
|
export {
|
|
51
59
|
q as LowerThirdNotification,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { z as pg } from "../../../../../vast-client.min-B0NUra1B.js";
|
|
2
2
|
import { useRef as Qr, useCallback as Ui, useEffect as js } from "react";
|
|
3
|
-
import { D as
|
|
3
|
+
import { D as gg } from "../../../../../index-l-eyvmpL.js";
|
|
4
|
+
import { useVastAds as mg } from "./useVastAds.js";
|
|
4
5
|
import { m as _g } from "../../../../../index-DSi8Qgfs.js";
|
|
5
6
|
var tn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
6
7
|
function nr(s) {
|
|
@@ -4589,7 +4590,7 @@ const tr = ({
|
|
|
4589
4590
|
}, Rc = (s) => {
|
|
4590
4591
|
if (s === "")
|
|
4591
4592
|
throw new Error(es.DASH_EMPTY_MANIFEST);
|
|
4592
|
-
const e = new
|
|
4593
|
+
const e = new gg();
|
|
4593
4594
|
let t, i;
|
|
4594
4595
|
try {
|
|
4595
4596
|
t = e.parseFromString(s, "application/xml"), i = t && t.documentElement.tagName === "MPD" ? t.documentElement : null;
|
|
@@ -33146,8 +33147,8 @@ const fv = (s) => {
|
|
|
33146
33147
|
return 0;
|
|
33147
33148
|
const e = s.duration(), t = s.currentTime();
|
|
33148
33149
|
return e === void 0 || isNaN(e) || t === void 0 || isNaN(t) ? 0 : Math.round(e - t);
|
|
33149
|
-
},
|
|
33150
|
-
const t =
|
|
33150
|
+
}, vv = (s, e) => {
|
|
33151
|
+
const t = mg(s, e), i = fv(s), r = Qr(), n = Qr(!1), a = Qr(!1), l = Ui(() => {
|
|
33151
33152
|
if (a.current)
|
|
33152
33153
|
return;
|
|
33153
33154
|
const I = t.get().nonceManager;
|
|
@@ -33174,7 +33175,7 @@ const fv = (s) => {
|
|
|
33174
33175
|
if (I < P) {
|
|
33175
33176
|
const U = I + 1, { ads: N, muted: F, autoplay: D, nonceManager: V } = t.get(), X = N[U - 1];
|
|
33176
33177
|
if (X) {
|
|
33177
|
-
(v = r.current) == null || v.complete(), r.current = new
|
|
33178
|
+
(v = r.current) == null || v.complete(), r.current = new pg(null, X.ad, X.creative), r.current.on("clickthrough", (G) => {
|
|
33178
33179
|
if (V)
|
|
33179
33180
|
try {
|
|
33180
33181
|
V.sendAdClick();
|
|
@@ -33241,5 +33242,5 @@ const fv = (s) => {
|
|
|
33241
33242
|
}, [d]), [ye, g, T, w, r];
|
|
33242
33243
|
};
|
|
33243
33244
|
export {
|
|
33244
|
-
|
|
33245
|
+
vv as useGAMPlayer
|
|
33245
33246
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type GAMStaticCore = Record<string, {
|
|
2
|
+
url: string;
|
|
3
|
+
imageSrc?: string;
|
|
4
|
+
adUrl?: string;
|
|
5
|
+
}>;
|
|
6
|
+
export declare const useLoadGAMStatic: () => readonly [(adUrl: string) => Promise<{
|
|
7
|
+
success: boolean;
|
|
8
|
+
}>, import('nanostores').PreinitializedMapStore<GAMStaticCore> & object];
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { _ as C } from "../../../../../vast-client.min-B0NUra1B.js";
|
|
2
|
+
import { useRef as k, useCallback as I } from "react";
|
|
3
|
+
import { createLogger as K } from "@streamlayer/sdk-web-logger";
|
|
4
|
+
import { m as V } from "../../../../../index-DSi8Qgfs.js";
|
|
5
|
+
const x = {}, D = new C(), a = V(x), u = K("ui:gam-static"), A = (n) => new Promise((m, e) => {
|
|
6
|
+
const s = new Image();
|
|
7
|
+
s.onload = () => m(n), s.onerror = () => e(), s.src = n;
|
|
8
|
+
}), _ = () => {
|
|
9
|
+
const n = k(0);
|
|
10
|
+
return [I(async (e) => {
|
|
11
|
+
var g, d, f, p, v, T, R, S, w, y, h;
|
|
12
|
+
if ((g = a.get()[e]) != null && g.imageSrc)
|
|
13
|
+
return { success: !0 };
|
|
14
|
+
const s = Date.now();
|
|
15
|
+
n.current = s, a.setKey(e, { url: e });
|
|
16
|
+
try {
|
|
17
|
+
const c = await D.get(e);
|
|
18
|
+
if (u.debug(c, "parsedVAST"), n.current === s && a.get()[e].url) {
|
|
19
|
+
const i = c.ads.find((o) => o.creatives.length > 0);
|
|
20
|
+
if (i) {
|
|
21
|
+
u.debug(i, "validAd");
|
|
22
|
+
const o = i.creatives.find((r) => r.type === "nonlinear");
|
|
23
|
+
if (o) {
|
|
24
|
+
u.debug(o, "nonlinear");
|
|
25
|
+
const r = (f = (d = o.variations) == null ? void 0 : d[0]) == null ? void 0 : f.staticResource, L = (v = (p = o.variations) == null ? void 0 : p[0]) == null ? void 0 : v.nonlinearClickThroughURLTemplate;
|
|
26
|
+
if (r)
|
|
27
|
+
return await A(r), a.setKey(e, { url: e, imageSrc: r, adUrl: L }), { success: !0 };
|
|
28
|
+
}
|
|
29
|
+
const t = i.creatives.find((r) => r.type === "companion");
|
|
30
|
+
u.debug(t, "companion");
|
|
31
|
+
const l = (w = (S = (R = (T = t == null ? void 0 : t.variations) == null ? void 0 : T[0]) == null ? void 0 : R.staticResources) == null ? void 0 : S[0]) == null ? void 0 : w.url, b = (h = (y = t == null ? void 0 : t.variations) == null ? void 0 : y[0]) == null ? void 0 : h.companionClickThroughURLTemplate;
|
|
32
|
+
if (l)
|
|
33
|
+
return await A(l), a.setKey(e, { url: e, imageSrc: l, adUrl: b }), { success: !0 };
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
} catch (c) {
|
|
37
|
+
console.error("Error parsing VAST", c);
|
|
38
|
+
}
|
|
39
|
+
return { success: !1 };
|
|
40
|
+
}, []), a];
|
|
41
|
+
};
|
|
42
|
+
export {
|
|
43
|
+
_ as useLoadGAMStatic
|
|
44
|
+
};
|
|
@@ -1,8 +1,242 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "react";
|
|
3
|
-
import "
|
|
1
|
+
import { _ as D } from "../../../../../vast-client.min-B0NUra1B.js";
|
|
2
|
+
import { useState as M, useRef as A, useEffect as w } from "react";
|
|
3
|
+
import { v4 as b, validate as R, v5 as k } from "uuid";
|
|
4
|
+
import { a as I } from "../../../../../index-tnt2CtQe.js";
|
|
5
|
+
class U {
|
|
6
|
+
constructor(e) {
|
|
7
|
+
this.id = e.getAttribute("id"), this.allowMultipleAds = e.getAttribute("allowMultipleAds"), this.followRedirects = e.getAttribute("followRedirects"), this.vastAdData = null, this.adTagURI = null, this.customData = null;
|
|
8
|
+
for (const s in e.childNodes) {
|
|
9
|
+
const t = e.childNodes[s];
|
|
10
|
+
switch (t.localName) {
|
|
11
|
+
case "AdTagURI":
|
|
12
|
+
this.adTagURI = {
|
|
13
|
+
templateType: t.getAttribute("templateType"),
|
|
14
|
+
uri: (t.textContent || t.text || "").trim()
|
|
15
|
+
};
|
|
16
|
+
break;
|
|
17
|
+
case "VASTAdData":
|
|
18
|
+
for (this.vastAdData = t.firstChild; this.vastAdData && this.vastAdData.nodeType !== 1; )
|
|
19
|
+
this.vastAdData = this.vastAdData.nextSibling;
|
|
20
|
+
break;
|
|
21
|
+
case "CustomAdData":
|
|
22
|
+
this.customData = t;
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function y(r, e) {
|
|
29
|
+
const s = [];
|
|
30
|
+
for (const t in r.childNodes) {
|
|
31
|
+
const n = r.childNodes[t];
|
|
32
|
+
(n.nodeName === e || e === `vmap:${n.nodeName}` || n.nodeName === `vmap:${e}`) && s.push(n);
|
|
33
|
+
}
|
|
34
|
+
return s;
|
|
35
|
+
}
|
|
36
|
+
function T(r) {
|
|
37
|
+
if (!r || !r.childNodes)
|
|
38
|
+
return {};
|
|
39
|
+
const e = r.childNodes, s = [];
|
|
40
|
+
for (const n in e) {
|
|
41
|
+
const a = e[n];
|
|
42
|
+
a.nodeName === "#cdata-section" && s.push(a);
|
|
43
|
+
}
|
|
44
|
+
if (s && s.length > 0)
|
|
45
|
+
try {
|
|
46
|
+
return JSON.parse(s[0].data);
|
|
47
|
+
} catch {
|
|
48
|
+
}
|
|
49
|
+
let t = "";
|
|
50
|
+
for (const n in e) {
|
|
51
|
+
const a = e[n];
|
|
52
|
+
switch (a.nodeName) {
|
|
53
|
+
case "#text":
|
|
54
|
+
t += a.textContent.trim();
|
|
55
|
+
break;
|
|
56
|
+
case "#cdata-section":
|
|
57
|
+
t += a.data;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return t;
|
|
62
|
+
}
|
|
63
|
+
function N(r) {
|
|
64
|
+
const e = {
|
|
65
|
+
attributes: {},
|
|
66
|
+
children: {},
|
|
67
|
+
value: {}
|
|
68
|
+
};
|
|
69
|
+
e.value = T(r);
|
|
70
|
+
const s = r.attributes;
|
|
71
|
+
if (s)
|
|
72
|
+
for (const n in s) {
|
|
73
|
+
const a = s[n];
|
|
74
|
+
a.nodeName && a.nodeValue !== void 0 && a.nodeValue !== null && (e.attributes[a.nodeName] = a.nodeValue);
|
|
75
|
+
}
|
|
76
|
+
const t = r.childNodes;
|
|
77
|
+
if (t)
|
|
78
|
+
for (const n in t) {
|
|
79
|
+
const a = t[n];
|
|
80
|
+
a.nodeName && a.nodeName.substring(0, 1) !== "#" && (e.children[a.nodeName] = N(a));
|
|
81
|
+
}
|
|
82
|
+
return e;
|
|
83
|
+
}
|
|
84
|
+
class K {
|
|
85
|
+
constructor(e) {
|
|
86
|
+
this.timeOffset = e.getAttribute("timeOffset"), this.breakType = e.getAttribute("breakType"), this.breakId = e.getAttribute("breakId"), this.repeatAfter = e.getAttribute("repeatAfter"), this.adSource = null, this.trackingEvents = [], this.extensions = [];
|
|
87
|
+
for (const s in e.childNodes) {
|
|
88
|
+
const t = e.childNodes[s];
|
|
89
|
+
switch (t.localName) {
|
|
90
|
+
case "AdSource":
|
|
91
|
+
this.adSource = new U(t);
|
|
92
|
+
break;
|
|
93
|
+
case "TrackingEvents":
|
|
94
|
+
for (const n in t.childNodes) {
|
|
95
|
+
const a = t.childNodes[n];
|
|
96
|
+
a.localName === "Tracking" && this.trackingEvents.push({
|
|
97
|
+
event: a.getAttribute("event"),
|
|
98
|
+
uri: (a.textContent || a.text || "").trim()
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
break;
|
|
102
|
+
case "Extensions":
|
|
103
|
+
this.extensions = y(t, "Extension").map(
|
|
104
|
+
(n) => N(n)
|
|
105
|
+
);
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
track(e, s) {
|
|
111
|
+
for (const t in this.trackingEvents) {
|
|
112
|
+
const n = this.trackingEvents[t];
|
|
113
|
+
if (n.event === e) {
|
|
114
|
+
let { uri: a } = n;
|
|
115
|
+
n.event === "error" && (a = a.replace("[ERRORCODE]", s)), this.tracker(a);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// Easy to overwrite tracker client for unit testing
|
|
120
|
+
tracker(e) {
|
|
121
|
+
if (typeof window < "u" && window !== null) {
|
|
122
|
+
const s = new Image();
|
|
123
|
+
s.src = e;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
class V {
|
|
128
|
+
constructor(e) {
|
|
129
|
+
if (!e || !e.documentElement || e.documentElement.localName !== "VMAP")
|
|
130
|
+
throw new Error("Not a VMAP document");
|
|
131
|
+
this.version = e.documentElement.getAttribute("version"), this.adBreaks = [], this.extensions = [];
|
|
132
|
+
for (const s in e.documentElement.childNodes) {
|
|
133
|
+
const t = e.documentElement.childNodes[s];
|
|
134
|
+
switch (t.localName) {
|
|
135
|
+
case "AdBreak":
|
|
136
|
+
this.adBreaks.push(new K(t));
|
|
137
|
+
break;
|
|
138
|
+
case "Extensions":
|
|
139
|
+
this.extensions = y(t, "Extension").map(
|
|
140
|
+
(n) => N(n)
|
|
141
|
+
);
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const C = (r, e) => {
|
|
148
|
+
const s = goog.pal, t = new s.ConsentSettings();
|
|
149
|
+
t.allowStorage = !1;
|
|
150
|
+
const n = new s.NonceLoader(t);
|
|
151
|
+
return async () => {
|
|
152
|
+
try {
|
|
153
|
+
const o = new URL(e), i = new s.NonceRequest();
|
|
154
|
+
let c = localStorage.getItem("sl-device-id") || b(), d = sessionStorage.getItem("sl-ad-session-id");
|
|
155
|
+
d || (d = b(), sessionStorage.setItem("sl-ad-session-id", d)), R(c) || (c = k(`https://${c}`, k.URL)), o.searchParams.get("url") || o.searchParams.set("url", "https://streamlayer.io"), o.searchParams.get("description_url") || o.searchParams.set("description_url", "https://streamlayer.io"), i.adWillAutoPlay = o.searchParams.get("vpa") === "auto", i.adWillPlayMuted = o.searchParams.get("vpmute") === "1", i.continuousPlayback = !0, i.descriptionUrl = o.searchParams.get("description_url"), i.iconsSupported = !0, i.sessionId = c, i.supportedApiFrameworks = "2,7,9", i.videoHeight = r.clientHeight, i.videoWidth = r.clientWidth;
|
|
156
|
+
const m = await n.loadNonceManager(i);
|
|
157
|
+
return o.searchParams.get("is_lat") === "[placeholder]" && o.searchParams.set("is_lat", "1"), o.searchParams.get("rdid") === "[placeholder]" && o.searchParams.set("rdid", c), o.searchParams.get("correlator") === "[placeholder]" && o.searchParams.set("correlator", d), o.searchParams.set("wta", "1"), o.searchParams.set("givn", m.getNonce()), {
|
|
158
|
+
url: o,
|
|
159
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
160
|
+
manager: m
|
|
161
|
+
};
|
|
162
|
+
} catch (o) {
|
|
163
|
+
console.log("AdsManager could not be started", o);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
}, L = new D(), x = (r) => r.creatives.find((e) => e.mediaFiles), B = (r) => {
|
|
168
|
+
var s;
|
|
169
|
+
const e = r == null ? void 0 : r.mediaFiles;
|
|
170
|
+
return e != null && e.length && ((s = e.find((t) => t.fileURL)) == null ? void 0 : s.fileURL) || "";
|
|
171
|
+
}, h = I({
|
|
172
|
+
ads: [],
|
|
173
|
+
autoplay: !0,
|
|
174
|
+
muted: !1,
|
|
175
|
+
nonceManager: void 0
|
|
176
|
+
}), $ = (r, e) => {
|
|
177
|
+
const [s, t] = M(), n = A(Date.now()), a = A(Date.now());
|
|
178
|
+
return w(() => {
|
|
179
|
+
if (!e || !(r != null && r.current))
|
|
180
|
+
return;
|
|
181
|
+
const o = C(r.current, e), i = Date.now();
|
|
182
|
+
n.current = i, h.set({
|
|
183
|
+
ads: [],
|
|
184
|
+
autoplay: !0,
|
|
185
|
+
muted: !1,
|
|
186
|
+
nonceManager: void 0
|
|
187
|
+
}), o().then((c) => {
|
|
188
|
+
n.current === i && c && (t(c.url), h.set({
|
|
189
|
+
ads: [],
|
|
190
|
+
autoplay: !0,
|
|
191
|
+
muted: !1,
|
|
192
|
+
nonceManager: c.manager
|
|
193
|
+
}));
|
|
194
|
+
}).catch((c) => {
|
|
195
|
+
console.error(c);
|
|
196
|
+
});
|
|
197
|
+
}, [r, e]), w(() => {
|
|
198
|
+
const o = async (i, c) => {
|
|
199
|
+
let d = [];
|
|
200
|
+
if (i.searchParams.get("output") === "vmap") {
|
|
201
|
+
const l = await fetch(i.toString()), g = new DOMParser(), f = await l.text(), u = g.parseFromString(f, "text/xml");
|
|
202
|
+
d = new V(u).adBreaks.map((v) => v.adSource.adTagURI.uri);
|
|
203
|
+
} else
|
|
204
|
+
d = [i.toString()];
|
|
205
|
+
const m = await Promise.all(
|
|
206
|
+
d.map((l, g) => L.get(l).then((f) => {
|
|
207
|
+
if (a.current === c) {
|
|
208
|
+
const u = f.ads.find((S) => S.creatives.length > 0);
|
|
209
|
+
if (!u)
|
|
210
|
+
return;
|
|
211
|
+
const p = x(u), v = B(p);
|
|
212
|
+
return {
|
|
213
|
+
creative: p,
|
|
214
|
+
order: g,
|
|
215
|
+
mediaFileUrl: v,
|
|
216
|
+
ad: u,
|
|
217
|
+
raw: f
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
}))
|
|
221
|
+
), P = i.searchParams.get("vpa") !== "click", E = i.searchParams.get("vpmute") === "1";
|
|
222
|
+
h.set({
|
|
223
|
+
...h.get(),
|
|
224
|
+
ads: m.filter((l) => !!l),
|
|
225
|
+
autoplay: P,
|
|
226
|
+
muted: E
|
|
227
|
+
});
|
|
228
|
+
};
|
|
229
|
+
if (s) {
|
|
230
|
+
const i = Date.now();
|
|
231
|
+
a.current = i, o(s, i);
|
|
232
|
+
}
|
|
233
|
+
return () => {
|
|
234
|
+
a.current = 0;
|
|
235
|
+
};
|
|
236
|
+
}, [s]), h;
|
|
237
|
+
};
|
|
4
238
|
export {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
239
|
+
x as getCreative,
|
|
240
|
+
B as getMediaFileUrl,
|
|
241
|
+
$ as useVastAds
|
|
8
242
|
};
|