@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.
@@ -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: () => void;
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 e, jsxs as g } from "react/jsx-runtime";
2
- import { cx as D } from "@linaria/core";
3
- import { useFocusable as L } from "@noriginmedia/norigin-spatial-navigation";
4
- import { useState as x, useRef as k, useEffect as h } from "react";
5
- import { useStore as G } from "@streamlayer/react-polyfills";
6
- import { eventBus as S } from "@streamlayer/sdk-web-interfaces";
7
- import { useLoadGAMStatic as B } from "../../../ui/advertisement/overlay/externalAd/vast-player/useGAMStatic.js";
8
- import { PauseAdOverlay as M, PauseAdContent as F, PauseAdGradientRight as I, PauseAdGradientBottom as j, PauseAdTopLeft as K, PauseAdTitle as N, PauseAdCaption as $, PauseAdBottomLeft as O, PauseAdPlayButton as V, PauseAdSidebar as _, PauseAdTitleDescription as q, ExternalAdContainer as b } from "./styles.js";
9
- const z = ({ vastUrl: t }) => {
10
- var s;
11
- const [, d] = B(), u = G(d, { keys: [t] });
12
- return (s = u == null ? void 0 : u[t]) != null && s.imageSrc ? u[t].adUrl ? /* @__PURE__ */ e("a", { href: u[t].adUrl, target: "_blank", rel: "noopener noreferrer", children: /* @__PURE__ */ e(b, { src: u[t].imageSrc }) }) : /* @__PURE__ */ e(b, { src: u[t].imageSrc }) : null;
13
- }, H = ({ isClosing: t, title: d, caption: u, onPlay: s, onClose: f, vastUrl: a, options: r }) => {
14
- const m = (r == null ? void 0 : r.showPauseButton) ?? !0, { ref: n, focusSelf: l } = L({
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: s,
39
+ onEnterRelease: e,
17
40
  isFocusBoundary: !0,
18
41
  forceFocus: !0
19
42
  });
20
- return h(() => {
21
- n.current && l();
22
- }, [n, l]), h(() => {
23
- const P = (p) => {
24
- const o = p.keyCode;
25
- if (o === 461 || o === 10009 || o === 27 || o === 8) {
26
- p.preventDefault(), p.stopPropagation(), p.stopImmediatePropagation(), f == null || f();
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", P, { capture: !0 }), () => window.removeEventListener("keydown", P, { capture: !0 });
31
- }, [f]), /* @__PURE__ */ e(M, { className: D(t && "pause-ad-closing"), children: /* @__PURE__ */ g(F, { children: [
32
- /* @__PURE__ */ e(I, {}),
33
- /* @__PURE__ */ e(j, {}),
34
- /* @__PURE__ */ g(K, { children: [
35
- /* @__PURE__ */ e(N, { children: d }),
36
- /* @__PURE__ */ e($, { children: u })
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
- m && /* @__PURE__ */ e(O, { children: /* @__PURE__ */ e(
39
- V,
64
+ T && /* @__PURE__ */ r(z, { children: /* @__PURE__ */ r(
65
+ H,
40
66
  {
41
- ref: n,
42
- onClick: s,
43
- onMouseEnter: () => n.current.focus(),
67
+ ref: d,
68
+ onClick: e,
69
+ onMouseEnter: () => d.current.focus(),
44
70
  "aria-label": "Resume playback"
45
71
  }
46
72
  ) }),
47
- /* @__PURE__ */ g(_, { children: [
48
- a && /* @__PURE__ */ e(z, { vastUrl: a }),
49
- /* @__PURE__ */ e(q, { children: "ADVERTISEMENT" })
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
- }, U = ({
53
- showPauseAd: t,
54
- vastUrls: d,
55
- title: u,
56
- caption: s,
57
- onPlay: f,
58
- onClose: a,
59
- onRender: r,
60
- options: m
61
- }) => {
62
- const n = (m == null ? void 0 : m.pauseAdDelay) ?? 5e3, [l, P] = x(!1), [p, o] = x(!1), c = k(), i = d == null ? void 0 : d[0].url, y = k(i);
63
- y.current = i;
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
- S.emit("exposedPauseAd", {
91
+ g.emit("exposedPauseAd", {
68
92
  action: "enabled",
69
93
  payload: {}
70
- }), T(i).then((A) => {
71
- y.current === i && (A == null ? void 0 : A.success) !== !0 && (clearTimeout(c.current), a == null || a());
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
- y.current === i && (clearTimeout(c.current), a == null || a());
97
+ S.current === i && (clearTimeout(c.current), o == null || o());
74
98
  });
75
99
  const w = () => {
76
- var A;
77
- (A = E.get()[y.current]) != null && A.imageSrc ? (clearTimeout(c.current), o(!1), P(!0), S.emit("exposedPauseAd", {
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
- }, n);
107
+ }, d);
87
108
  } else
88
- S.emit("exposedPauseAd", {
109
+ g.emit("exposedPauseAd", {
89
110
  action: "disabled",
90
111
  payload: {}
91
- }), o(!0), c.current = setTimeout(() => {
92
- P(!1);
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
- }, [E, T, a, n, t, i]), h(() => {
98
- r == null || r({ rendered: l });
99
- }, [l, r]), h(() => () => {
100
- r == null || r({ rendered: !1 });
101
- }, [r]), l ? /* @__PURE__ */ e(
102
- H,
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: a,
105
- isClosing: p,
106
- title: u,
107
- caption: s,
108
- onPlay: f,
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
- U as PauseAd
137
+ re as PauseAd
116
138
  };
@@ -1,13 +1,16 @@
1
1
  import { Component } from 'react';
2
2
  import { StreamLayerSDK } from '@streamlayer/sdk-web-interfaces';
3
- import { PauseAdProps } from './ExposedPauseAd/PauseAd';
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: React.ReactNode;
13
+ children?: React.ReactNode;
11
14
  sdk: StreamLayerSDK;
12
15
  showPauseAd?: boolean;
13
16
  pauseAdVastUrl?: PauseAdProps['vastUrls'];
@@ -1,47 +1,45 @@
1
- import { jsx as t, jsxs as d } from "react/jsx-runtime";
2
- import { init as y } from "@noriginmedia/norigin-spatial-navigation";
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 D, useCallback as c } from "react";
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 s } from "./Question/index.js";
9
- y({
8
+ import { StreamLayerSDKQuestionWebOS as c } from "./Question/index.js";
9
+ l({
10
10
  shouldFocusDOMNode: !0
11
11
  });
12
- const L = ({
12
+ const y = ({
13
13
  persistent: e,
14
14
  children: o,
15
15
  sdk: r,
16
- showPauseAd: l,
16
+ showPauseAd: s,
17
17
  pauseAdVastUrl: m,
18
- onClosePauseAd: n,
18
+ onClosePauseAd: i,
19
19
  onRenderPauseAd: f,
20
20
  options: S
21
21
  }) => {
22
- const a = x(r.uiState), p = c(() => {
23
- n == null || n();
24
- }, [n]), h = c(() => {
25
- r.controlVideoPlayer({ play: !0 });
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: i }) => a.exposedPauseAd ? null : i ? /* @__PURE__ */ t(u, { sdk: r, persistent: e, sidebar: "right" }) : /* @__PURE__ */ t(s, { sdk: r, persistent: e }),
32
- notification: ({ promo: i }) => a.exposedPauseAd ? null : i ? /* @__PURE__ */ t(u, { sdk: r, notification: !0, persistent: e }) : /* @__PURE__ */ t(s, { notification: !0, sdk: r, persistent: e }),
33
- banner: a.exposedPauseAd ? null : /* @__PURE__ */ t(u, { sdk: r, persistent: e, banner: "bottom" }),
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: l,
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 D {
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(L, { ...this.props });
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
  };