@streamlayer/react-ui 1.31.7 → 1.32.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/webos/ExposedPauseAd/PauseAd.d.ts +6 -3
- package/lib/app/webos/ExposedPauseAd/PauseAd.js +99 -77
- package/lib/app/webos/index.d.ts +5 -2
- package/lib/app/webos/index.js +22 -21
- package/lib/assets/style.css +1 -1
- package/lib/ui/advertisement/overlay/externalAd/vast-player/useGAMStatic.d.ts +1 -0
- package/lib/ui/advertisement/overlay/externalAd/vast-player/useGAMStatic.js +56 -31
- package/package.json +16 -16
|
@@ -1,17 +1,20 @@
|
|
|
1
|
+
import { StreamLayerSDK } from '@streamlayer/sdk-web-interfaces';
|
|
1
2
|
import { StreamLayerSDKTvOptions } from '..';
|
|
2
3
|
export interface PauseAdProps {
|
|
3
4
|
vastUrls: Array<{
|
|
4
5
|
template?: 'default';
|
|
5
6
|
url: string;
|
|
6
7
|
}>;
|
|
7
|
-
onClose
|
|
8
|
+
onClose?: () => void;
|
|
8
9
|
title?: string;
|
|
9
10
|
caption?: string;
|
|
10
|
-
onPlay?: () => void;
|
|
11
11
|
showPauseAd?: boolean;
|
|
12
12
|
onRender?: (params: {
|
|
13
13
|
rendered: boolean;
|
|
14
14
|
}) => void;
|
|
15
15
|
options?: StreamLayerSDKTvOptions;
|
|
16
|
+
isDesktop?: boolean;
|
|
16
17
|
}
|
|
17
|
-
export declare const PauseAd: React.FC<PauseAdProps
|
|
18
|
+
export declare const PauseAd: React.FC<PauseAdProps & {
|
|
19
|
+
sdk: StreamLayerSDK;
|
|
20
|
+
}>;
|
|
@@ -1,116 +1,138 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { cx as
|
|
3
|
-
import { useFocusable as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { useStore as
|
|
6
|
-
import { eventBus as
|
|
7
|
-
import { useLoadGAMStatic as
|
|
8
|
-
import { PauseAdOverlay as
|
|
9
|
-
const
|
|
10
|
-
var
|
|
11
|
-
const [,
|
|
12
|
-
return (
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { jsx as r, jsxs as x } from "react/jsx-runtime";
|
|
2
|
+
import { cx as M } from "@linaria/core";
|
|
3
|
+
import { useFocusable as F } from "@noriginmedia/norigin-spatial-navigation";
|
|
4
|
+
import { useState as b, useRef as B, useCallback as D, useEffect as P } from "react";
|
|
5
|
+
import { useStore as I } from "@streamlayer/react-polyfills";
|
|
6
|
+
import { eventBus as g } from "@streamlayer/sdk-web-interfaces";
|
|
7
|
+
import { useLoadGAMStatic as C } from "../../../ui/advertisement/overlay/externalAd/vast-player/useGAMStatic.js";
|
|
8
|
+
import { PauseAdOverlay as j, PauseAdContent as K, PauseAdGradientRight as N, PauseAdGradientBottom as O, PauseAdTopLeft as V, PauseAdTitle as $, PauseAdCaption as q, PauseAdBottomLeft as z, PauseAdPlayButton as H, PauseAdSidebar as J, PauseAdTitleDescription as Q, ExternalAdContainer as L } from "./styles.js";
|
|
9
|
+
const W = ({ vastUrl: t, isDesktop: n }) => {
|
|
10
|
+
var u;
|
|
11
|
+
const [, y] = C(), e = I(y, { keys: [t] });
|
|
12
|
+
return P(() => {
|
|
13
|
+
e && e[t] && e[t].imageSrc && e[t].id && g.emit("exposedPauseAd", {
|
|
14
|
+
action: "rendered",
|
|
15
|
+
payload: {
|
|
16
|
+
id: e[t].id
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}, [e, t]), (u = e == null ? void 0 : e[t]) != null && u.imageSrc ? !e[t].adUrl || !n ? /* @__PURE__ */ r(L, { src: e[t].imageSrc }) : /* @__PURE__ */ r(
|
|
20
|
+
"a",
|
|
21
|
+
{
|
|
22
|
+
onClick: () => {
|
|
23
|
+
g.emit("exposedPauseAd", {
|
|
24
|
+
action: "navigated",
|
|
25
|
+
payload: {
|
|
26
|
+
id: e[t].id
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
href: e[t].adUrl,
|
|
31
|
+
target: "_blank",
|
|
32
|
+
rel: "noopener noreferrer",
|
|
33
|
+
children: /* @__PURE__ */ r(L, { src: e[t].imageSrc })
|
|
34
|
+
}
|
|
35
|
+
) : null;
|
|
36
|
+
}, X = ({ isClosing: t, title: n, caption: y, onPlay: e, onClose: u, vastUrl: f, options: a, isDesktop: m }) => {
|
|
37
|
+
const T = (a == null ? void 0 : a.showPauseButton) ?? !0, { ref: d, focusSelf: p } = F({
|
|
15
38
|
focusKey: "sl-pause-ad-play",
|
|
16
|
-
onEnterRelease:
|
|
39
|
+
onEnterRelease: e,
|
|
17
40
|
isFocusBoundary: !0,
|
|
18
41
|
forceFocus: !0
|
|
19
42
|
});
|
|
20
|
-
return
|
|
21
|
-
|
|
22
|
-
}, [
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
43
|
+
return P(() => {
|
|
44
|
+
d.current && p();
|
|
45
|
+
}, [d, p]), P(() => {
|
|
46
|
+
if (!u)
|
|
47
|
+
return () => {
|
|
48
|
+
};
|
|
49
|
+
const h = (A) => {
|
|
50
|
+
const s = A.keyCode;
|
|
51
|
+
if (s === 461 || s === 10009 || s === 27 || s === 8) {
|
|
52
|
+
A.preventDefault(), A.stopPropagation(), A.stopImmediatePropagation(), u();
|
|
27
53
|
return;
|
|
28
54
|
}
|
|
29
55
|
};
|
|
30
|
-
return window.addEventListener("keydown",
|
|
31
|
-
}, [
|
|
32
|
-
/* @__PURE__ */
|
|
33
|
-
/* @__PURE__ */
|
|
34
|
-
/* @__PURE__ */
|
|
35
|
-
/* @__PURE__ */
|
|
36
|
-
/* @__PURE__ */
|
|
56
|
+
return window.addEventListener("keydown", h, { capture: !0 }), () => window.removeEventListener("keydown", h, { capture: !0 });
|
|
57
|
+
}, [u]), /* @__PURE__ */ r(j, { className: M("SL_PauseAdOverlay", t && "pause-ad-closing"), children: /* @__PURE__ */ x(K, { children: [
|
|
58
|
+
/* @__PURE__ */ r(N, {}),
|
|
59
|
+
/* @__PURE__ */ r(O, {}),
|
|
60
|
+
/* @__PURE__ */ x(V, { children: [
|
|
61
|
+
/* @__PURE__ */ r($, { children: n }),
|
|
62
|
+
/* @__PURE__ */ r(q, { children: y })
|
|
37
63
|
] }),
|
|
38
|
-
|
|
39
|
-
|
|
64
|
+
T && /* @__PURE__ */ r(z, { children: /* @__PURE__ */ r(
|
|
65
|
+
H,
|
|
40
66
|
{
|
|
41
|
-
ref:
|
|
42
|
-
onClick:
|
|
43
|
-
onMouseEnter: () =>
|
|
67
|
+
ref: d,
|
|
68
|
+
onClick: e,
|
|
69
|
+
onMouseEnter: () => d.current.focus(),
|
|
44
70
|
"aria-label": "Resume playback"
|
|
45
71
|
}
|
|
46
72
|
) }),
|
|
47
|
-
/* @__PURE__ */
|
|
48
|
-
|
|
49
|
-
/* @__PURE__ */
|
|
73
|
+
/* @__PURE__ */ x(J, { children: [
|
|
74
|
+
f && /* @__PURE__ */ r(W, { isDesktop: m, vastUrl: f }),
|
|
75
|
+
/* @__PURE__ */ r(Q, { children: "ADVERTISEMENT" })
|
|
50
76
|
] })
|
|
51
77
|
] }) });
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const [T, E] = B();
|
|
65
|
-
return h(() => {
|
|
78
|
+
}, re = ({ showPauseAd: t, vastUrls: n, title: y, caption: e, sdk: u, onClose: f, onRender: a, options: m, isDesktop: T }) => {
|
|
79
|
+
const d = (m == null ? void 0 : m.pauseAdDelay) ?? 5e3, [p, h] = b(!1), [A, s] = b(!1), c = B(), i = n == null ? void 0 : n[0].url, S = B(i);
|
|
80
|
+
S.current = i;
|
|
81
|
+
const [E, k] = C(), o = D(() => {
|
|
82
|
+
f && (g.emit("exposedPauseAd", {
|
|
83
|
+
action: "closed",
|
|
84
|
+
payload: {}
|
|
85
|
+
}), f());
|
|
86
|
+
}, [f]), G = D(() => {
|
|
87
|
+
u.controlVideoPlayer({ play: !0 });
|
|
88
|
+
}, [u]);
|
|
89
|
+
return P(() => {
|
|
66
90
|
if (t && i) {
|
|
67
|
-
|
|
91
|
+
g.emit("exposedPauseAd", {
|
|
68
92
|
action: "enabled",
|
|
69
93
|
payload: {}
|
|
70
|
-
}),
|
|
71
|
-
|
|
94
|
+
}), E(i).then((l) => {
|
|
95
|
+
S.current === i && (l == null ? void 0 : l.success) !== !0 && (clearTimeout(c.current), o == null || o());
|
|
72
96
|
}).catch(() => {
|
|
73
|
-
|
|
97
|
+
S.current === i && (clearTimeout(c.current), o == null || o());
|
|
74
98
|
});
|
|
75
99
|
const w = () => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
action: "rendered",
|
|
79
|
-
payload: {}
|
|
80
|
-
})) : c.current = setTimeout(() => {
|
|
100
|
+
const l = k.get()[S.current];
|
|
101
|
+
l != null && l.imageSrc ? (clearTimeout(c.current), s(!1), h(!0)) : c.current = setTimeout(() => {
|
|
81
102
|
w();
|
|
82
103
|
}, 200);
|
|
83
104
|
};
|
|
84
105
|
c.current = setTimeout(() => {
|
|
85
106
|
w();
|
|
86
|
-
},
|
|
107
|
+
}, d);
|
|
87
108
|
} else
|
|
88
|
-
|
|
109
|
+
g.emit("exposedPauseAd", {
|
|
89
110
|
action: "disabled",
|
|
90
111
|
payload: {}
|
|
91
|
-
}),
|
|
92
|
-
|
|
112
|
+
}), s(!0), c.current = setTimeout(() => {
|
|
113
|
+
h(!1);
|
|
93
114
|
}, 400);
|
|
94
115
|
return () => {
|
|
95
116
|
c.current && clearTimeout(c.current);
|
|
96
117
|
};
|
|
97
|
-
}, [
|
|
98
|
-
|
|
99
|
-
}, [
|
|
100
|
-
|
|
101
|
-
}, [
|
|
102
|
-
|
|
118
|
+
}, [k, E, o, d, t, i]), P(() => {
|
|
119
|
+
a == null || a({ rendered: p });
|
|
120
|
+
}, [p, a]), P(() => () => {
|
|
121
|
+
a == null || a({ rendered: !1 });
|
|
122
|
+
}, [a]), p ? /* @__PURE__ */ r(
|
|
123
|
+
X,
|
|
103
124
|
{
|
|
104
|
-
onClose:
|
|
105
|
-
isClosing:
|
|
106
|
-
title:
|
|
107
|
-
caption:
|
|
108
|
-
onPlay:
|
|
125
|
+
onClose: o,
|
|
126
|
+
isClosing: A,
|
|
127
|
+
title: y,
|
|
128
|
+
caption: e,
|
|
129
|
+
onPlay: G,
|
|
109
130
|
vastUrl: i,
|
|
110
|
-
options: m
|
|
131
|
+
options: m,
|
|
132
|
+
isDesktop: T
|
|
111
133
|
}
|
|
112
134
|
) : null;
|
|
113
135
|
};
|
|
114
136
|
export {
|
|
115
|
-
|
|
137
|
+
re as PauseAd
|
|
116
138
|
};
|
package/lib/app/webos/index.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { Component } from 'react';
|
|
2
2
|
import { StreamLayerSDK } from '@streamlayer/sdk-web-interfaces';
|
|
3
|
-
import {
|
|
3
|
+
import { StreamLayerSDKAdvertisementWebOS } from './Advertisement';
|
|
4
|
+
import { PauseAd, PauseAdProps } from './ExposedPauseAd/PauseAd';
|
|
5
|
+
import { StreamLayerSDKQuestionWebOS } from './Question';
|
|
6
|
+
export { StreamLayerSDKAdvertisementWebOS, StreamLayerSDKQuestionWebOS, PauseAd, type PauseAdProps };
|
|
4
7
|
export type StreamLayerSDKTvOptions = {
|
|
5
8
|
showPauseButton?: boolean;
|
|
6
9
|
pauseAdDelay?: number;
|
|
7
10
|
};
|
|
8
11
|
export type StreamLayerSDKTvProps = {
|
|
9
12
|
persistent?: boolean;
|
|
10
|
-
children
|
|
13
|
+
children?: React.ReactNode;
|
|
11
14
|
sdk: StreamLayerSDK;
|
|
12
15
|
showPauseAd?: boolean;
|
|
13
16
|
pauseAdVastUrl?: PauseAdProps['vastUrls'];
|
package/lib/app/webos/index.js
CHANGED
|
@@ -1,47 +1,45 @@
|
|
|
1
|
-
import { jsx as t, jsxs as
|
|
2
|
-
import { init as
|
|
1
|
+
import { jsx as t, jsxs as h } from "react/jsx-runtime";
|
|
2
|
+
import { init as l } from "@noriginmedia/norigin-spatial-navigation";
|
|
3
3
|
import { Layout as b } from "../app/Layout/index.js";
|
|
4
|
-
import { Component as
|
|
4
|
+
import { Component as d, useCallback as D } from "react";
|
|
5
5
|
import { useStore as x } from "@streamlayer/react-polyfills";
|
|
6
6
|
import { StreamLayerSDKAdvertisementWebOS as u } from "./Advertisement/index.js";
|
|
7
7
|
import { PauseAd as v } from "./ExposedPauseAd/PauseAd.js";
|
|
8
|
-
import { StreamLayerSDKQuestionWebOS as
|
|
9
|
-
|
|
8
|
+
import { StreamLayerSDKQuestionWebOS as c } from "./Question/index.js";
|
|
9
|
+
l({
|
|
10
10
|
shouldFocusDOMNode: !0
|
|
11
11
|
});
|
|
12
|
-
const
|
|
12
|
+
const y = ({
|
|
13
13
|
persistent: e,
|
|
14
14
|
children: o,
|
|
15
15
|
sdk: r,
|
|
16
|
-
showPauseAd:
|
|
16
|
+
showPauseAd: s,
|
|
17
17
|
pauseAdVastUrl: m,
|
|
18
|
-
onClosePauseAd:
|
|
18
|
+
onClosePauseAd: i,
|
|
19
19
|
onRenderPauseAd: f,
|
|
20
20
|
options: S
|
|
21
21
|
}) => {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
}, [
|
|
25
|
-
|
|
26
|
-
}, [r]);
|
|
27
|
-
return /* @__PURE__ */ d(
|
|
22
|
+
const n = x(r.uiState), p = D(() => {
|
|
23
|
+
i == null || i();
|
|
24
|
+
}, [i]);
|
|
25
|
+
return /* @__PURE__ */ h(
|
|
28
26
|
b,
|
|
29
27
|
{
|
|
30
28
|
sdk: r,
|
|
31
|
-
sidebar: ({ promo:
|
|
32
|
-
notification: ({ promo:
|
|
33
|
-
banner:
|
|
29
|
+
sidebar: ({ promo: a }) => n.exposedPauseAd ? null : a ? /* @__PURE__ */ t(u, { sdk: r, persistent: e, sidebar: "right" }) : /* @__PURE__ */ t(c, { sdk: r, persistent: e }),
|
|
30
|
+
notification: ({ promo: a }) => n.exposedPauseAd ? null : a ? /* @__PURE__ */ t(u, { sdk: r, notification: !0, persistent: e }) : /* @__PURE__ */ t(c, { notification: !0, sdk: r, persistent: e }),
|
|
31
|
+
banner: n.exposedPauseAd ? null : /* @__PURE__ */ t(u, { sdk: r, persistent: e, banner: "bottom" }),
|
|
34
32
|
webos: !0,
|
|
35
33
|
children: [
|
|
36
34
|
o,
|
|
37
35
|
m && /* @__PURE__ */ t(
|
|
38
36
|
v,
|
|
39
37
|
{
|
|
40
|
-
showPauseAd:
|
|
38
|
+
showPauseAd: s,
|
|
41
39
|
vastUrls: m,
|
|
40
|
+
sdk: r,
|
|
42
41
|
onClose: p,
|
|
43
42
|
onRender: f,
|
|
44
|
-
onPlay: h,
|
|
45
43
|
options: S
|
|
46
44
|
}
|
|
47
45
|
)
|
|
@@ -49,7 +47,7 @@ const L = ({
|
|
|
49
47
|
}
|
|
50
48
|
);
|
|
51
49
|
};
|
|
52
|
-
class W extends
|
|
50
|
+
class W extends d {
|
|
53
51
|
constructor(o) {
|
|
54
52
|
super(o), this.state = { hasError: !1 };
|
|
55
53
|
}
|
|
@@ -60,9 +58,12 @@ class W extends D {
|
|
|
60
58
|
console.error("StreamLayerSDKTv error:", o, r.componentStack);
|
|
61
59
|
}
|
|
62
60
|
render() {
|
|
63
|
-
return this.state.hasError ? this.props.children : /* @__PURE__ */ t(
|
|
61
|
+
return this.state.hasError ? this.props.children : /* @__PURE__ */ t(y, { ...this.props });
|
|
64
62
|
}
|
|
65
63
|
}
|
|
66
64
|
export {
|
|
65
|
+
v as PauseAd,
|
|
66
|
+
u as StreamLayerSDKAdvertisementWebOS,
|
|
67
|
+
c as StreamLayerSDKQuestionWebOS,
|
|
67
68
|
W as StreamLayerSDKTv
|
|
68
69
|
};
|