@streamlayer/react 0.24.10 → 0.25.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.
@@ -0,0 +1,396 @@
1
+ import { jsx as t, jsxs as c, Fragment as g } from "react/jsx-runtime";
2
+ import { s as o, Y as y, o as E, X as w, f as C, x as Q, u as F, v as O, h as b, p as R, d as M, j as q, e as G, S as H, a as N, b as j } from "../provider-a6b36c89.js";
3
+ import { useState as h, useMemo as B, useCallback as D, useEffect as L, useContext as P } from "react";
4
+ import { QuestionType as T, FeatureType as A } from "@streamlayer/sdk-web-types";
5
+ import { useStore as d } from "@nanostores/react";
6
+ import { FeatureStatus as v } from "@streamlayer/sdk-web-interfaces";
7
+ import "react-countdown-circle-timer";
8
+ import "react-auth-code-input";
9
+ import "react-phone-number-input";
10
+ import "@connectrpc/connect";
11
+ import "@connectrpc/connect-web";
12
+ import "@streamlayer/sl-eslib/users/users_connect";
13
+ import "@streamlayer/sdk-web-features";
14
+ import "@streamlayer/sdk-web-api";
15
+ import "@streamlayer/sdk-web-storage";
16
+ import "@streamlayer/sdk-web-notifications";
17
+ import "@streamlayer/sl-eslib/interactive/interactive.common_pb";
18
+ import "@streamlayer/sl-eslib/interactive/feed/interactive.feed_pb";
19
+ import "@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb";
20
+ import "@streamlayer/sl-eslib/sports/events/events_connect";
21
+ import "@streamlayer/sl-eslib/sdkSettings/client/client_connect";
22
+ import "./useStreamLayerApp.js";
23
+ import "@streamlayer/sdk-web";
24
+ const _ = ({
25
+ feature: e,
26
+ sdk: s,
27
+ children: n
28
+ }) => {
29
+ const r = d(e.status), { slStreamId: a } = d(s.sdkStore);
30
+ return a != null && a.loading ? /* @__PURE__ */ t("div", { children: "event is loading..." }) : a != null && a.data ? r !== v.Ready ? /* @__PURE__ */ t("div", { children: "wait feature..." }) : n : /* @__PURE__ */ t("div", { children: "event is forbidden..." });
31
+ };
32
+ const z = () => x, Y = /* @__PURE__ */ o("div")({
33
+ name: "i",
34
+ class: "idhrx8x",
35
+ propsAsIs: !1
36
+ }), $ = /* @__PURE__ */ o("div")({
37
+ name: "r",
38
+ class: "r1k6v4ep",
39
+ propsAsIs: !1
40
+ }), x = /* @__PURE__ */ o("div")({
41
+ name: "t",
42
+ class: "t1v8kucd",
43
+ propsAsIs: !1
44
+ }), U = /* @__PURE__ */ o(z())({
45
+ name: "o",
46
+ class: "o16yw7z1",
47
+ propsAsIs: !0
48
+ });
49
+ const X = /* @__PURE__ */ o("div")({
50
+ name: "n",
51
+ class: "n1aopxp8",
52
+ propsAsIs: !1
53
+ }), K = ({
54
+ children: e,
55
+ style: s,
56
+ className: n
57
+ }) => /* @__PURE__ */ t(X, {
58
+ style: s,
59
+ className: n,
60
+ children: e
61
+ });
62
+ const W = () => y, J = () => y, V = /* @__PURE__ */ o("div")({
63
+ name: "a",
64
+ class: "acysrl1",
65
+ propsAsIs: !1
66
+ }), Z = /* @__PURE__ */ o("div")({
67
+ name: "l",
68
+ class: "lo57cjm",
69
+ propsAsIs: !1
70
+ }), ee = /* @__PURE__ */ o(W())({
71
+ name: "p",
72
+ class: "p14kwh4y",
73
+ propsAsIs: !0
74
+ }), se = /* @__PURE__ */ o("span")({
75
+ name: "s",
76
+ class: "sxun7sq",
77
+ propsAsIs: !1
78
+ }), te = /* @__PURE__ */ o("button")({
79
+ name: "c",
80
+ class: "c1i8ida8",
81
+ propsAsIs: !1
82
+ }), ne = /* @__PURE__ */ o(J())({
83
+ name: "g",
84
+ class: "g1m0xfmw",
85
+ propsAsIs: !0
86
+ }), ae = ({ type: e, close: s }) => {
87
+ const n = E[e];
88
+ return /* @__PURE__ */ c(V, { children: [
89
+ /* @__PURE__ */ c(Z, { children: [
90
+ (n == null ? void 0 : n.iconName) && /* @__PURE__ */ t(ee, { name: n.iconName }),
91
+ (n == null ? void 0 : n.label) && /* @__PURE__ */ t(se, { children: n.label })
92
+ ] }),
93
+ /* @__PURE__ */ t(te, { onClick: s, children: /* @__PURE__ */ t(ne, { name: "icon-cross" }) })
94
+ ] });
95
+ };
96
+ const oe = /* @__PURE__ */ o("div")({
97
+ name: "r",
98
+ class: "ruyb9yw",
99
+ propsAsIs: !1
100
+ }), re = /* @__PURE__ */ o("img")({
101
+ name: "i",
102
+ class: "imbcgl0",
103
+ propsAsIs: !1
104
+ }), ie = ({
105
+ sponsorLogo: e
106
+ }) => e && /* @__PURE__ */ t(oe, {
107
+ children: /* @__PURE__ */ t(re, {
108
+ alt: "sponsor-logo",
109
+ src: e
110
+ })
111
+ });
112
+ const le = /* @__PURE__ */ o("div")({
113
+ name: "x",
114
+ class: "xk8r1eq",
115
+ propsAsIs: !1
116
+ }), ce = ({
117
+ openedQuestion: e,
118
+ closeQuestion: s,
119
+ vote: n
120
+ }) => {
121
+ var r;
122
+ return /* @__PURE__ */ c(le, {
123
+ children: [/* @__PURE__ */ t(ae, {
124
+ close: s,
125
+ type: (e == null ? void 0 : e.type) || T.UNSET
126
+ }), e && /* @__PURE__ */ t(w, {
127
+ vote: n,
128
+ openedQuestion: e
129
+ }), /* @__PURE__ */ t(ie, {
130
+ sponsorLogo: (r = e == null ? void 0 : e.sponsorship) == null ? void 0 : r.logo
131
+ })]
132
+ });
133
+ }, de = ({ leaderboardList: e }) => {
134
+ const { data: s } = d(e.$store), [n, r] = h(void 0), a = (l) => {
135
+ const i = s.find((p) => p.userId === l);
136
+ r(i);
137
+ };
138
+ return /* @__PURE__ */ c(g, { children: [
139
+ n && /* @__PURE__ */ t(C, { comeBack: () => a(null), ...n }),
140
+ !n && /* @__PURE__ */ t(Q, { fetchMore: e.fetchMore, items: s, openItemDetail: a })
141
+ ] });
142
+ }, pe = ({ store: e, openQuestion: s }) => {
143
+ const n = d(e);
144
+ return n != null && n.data ? /* @__PURE__ */ t(F, { openQuestion: s, questions: n.data }) : /* @__PURE__ */ t("div", { children: "wait questions..." });
145
+ }, ue = ({ store: e }) => {
146
+ const { data: s } = d(e);
147
+ return s != null && s.summary ? /* @__PURE__ */ t(O, { ...s.summary, ...s.percentage }) : /* @__PURE__ */ t("div", { children: "wait user..." });
148
+ }, me = ({ gamification: e }) => {
149
+ const [s, n] = h(b.HOME);
150
+ return /* @__PURE__ */ c(g, { children: [
151
+ /* @__PURE__ */ c(U, { children: [
152
+ /* @__PURE__ */ t(R, { activePage: s, toggleActivePage: n }),
153
+ s === b.HOME && /* @__PURE__ */ t(ue, { store: e.userSummary.getStore() })
154
+ ] }),
155
+ s === b.HOME && /* @__PURE__ */ t(x, { children: /* @__PURE__ */ t(pe, { openQuestion: e.openQuestion, store: e.questions.getStore() }) }),
156
+ s === b.LEADERBOARD && /* @__PURE__ */ t(x, { style: { flex: "1 1 auto" }, children: /* @__PURE__ */ t(de, { leaderboardList: e.leaderboardList }) })
157
+ ] });
158
+ };
159
+ const ve = () => K, he = /* @__PURE__ */ o(ve())({
160
+ name: "u",
161
+ class: "u1ph66cs",
162
+ propsAsIs: !0
163
+ }), fe = ({
164
+ gamification: e
165
+ }) => {
166
+ const {
167
+ loading: s,
168
+ data: n
169
+ } = d(e.openedQuestion);
170
+ return /* @__PURE__ */ c(g, {
171
+ children: [(s || n) && /* @__PURE__ */ t(he, {
172
+ children: /* @__PURE__ */ t(ce, {
173
+ closeQuestion: e.closeQuestion,
174
+ vote: e.submitAnswer,
175
+ openedQuestion: n
176
+ })
177
+ }), /* @__PURE__ */ t($, {
178
+ "data-nav": "true",
179
+ style: {
180
+ display: "flex",
181
+ flexDirection: "column"
182
+ },
183
+ children: /* @__PURE__ */ t(me, {
184
+ gamification: e
185
+ })
186
+ })]
187
+ });
188
+ }, ge = ({ highlights: e }) => {
189
+ const s = d(e.openedInsight);
190
+ return /* @__PURE__ */ c(g, { children: [
191
+ !s && e.insights && /* @__PURE__ */ t(M, { highlights: e, store: e.insights.getStore() }),
192
+ s && /* @__PURE__ */ t(
193
+ q,
194
+ {
195
+ openedInsight: s,
196
+ closeHighlights: e.closeFeature,
197
+ closeInsight: e.closeHighlight
198
+ }
199
+ )
200
+ ] });
201
+ }, ye = ({ sdk: e, feature: s }) => B(() => s ? s.featureConfig.get().type === A.GAMES ? /* @__PURE__ */ t(_, { sdk: e, feature: s, children: /* @__PURE__ */ t(fe, { gamification: s, sdk: e }) }) : s.featureConfig.get().type === A.HIGHLIGHTS ? /* @__PURE__ */ t(_, { sdk: e, feature: s, children: /* @__PURE__ */ t(ge, { highlights: s, sdk: e }) }) : null : null, [e, s]);
202
+ const be = /* @__PURE__ */ o("button")({
203
+ name: "e",
204
+ class: "enu64b2",
205
+ propsAsIs: !1
206
+ }), ke = /* @__PURE__ */ o("span")({
207
+ name: "t",
208
+ class: "tw2meku",
209
+ propsAsIs: !1
210
+ }), Se = /* @__PURE__ */ o("span")({
211
+ name: "a",
212
+ class: "aka8vam",
213
+ propsAsIs: !1
214
+ }), I = ({ disabled: e, active: s, onClick: n, label: r, icon: a }) => /* @__PURE__ */ t(be, { onClick: n, disabled: e, "data-selected": s, children: /* @__PURE__ */ c(g, { children: [
215
+ a && /* @__PURE__ */ t(ke, { children: a }),
216
+ /* @__PURE__ */ t(Se, { children: r })
217
+ ] }) });
218
+ const Ae = () => y, $e = /* @__PURE__ */ o(Ae())({
219
+ name: "a",
220
+ class: "a10lggiw",
221
+ propsAsIs: !0
222
+ }), f = "channels", xe = (e) => {
223
+ var s;
224
+ return /* @__PURE__ */ t(I, {
225
+ ...e,
226
+ id: "channels",
227
+ label: "Channels",
228
+ icon: /* @__PURE__ */ t($e, {
229
+ name: "icon-btn-channels",
230
+ "data-selected": (s = e.active) == null ? void 0 : s.toString()
231
+ })
232
+ });
233
+ };
234
+ const Ie = () => y, _e = /* @__PURE__ */ o(Ie())({
235
+ name: "d",
236
+ class: "d1x5s8ie",
237
+ propsAsIs: !0
238
+ }), u = "featuredGroups", Le = (e) => {
239
+ var s;
240
+ return /* @__PURE__ */ t(I, {
241
+ ...e,
242
+ label: "FG+",
243
+ id: "featuredGroups",
244
+ icon: /* @__PURE__ */ t(_e, {
245
+ name: "icon-btn-feature-groups",
246
+ "data-selected": (s = e.active) == null ? void 0 : s.toString()
247
+ })
248
+ });
249
+ };
250
+ const Ee = () => y, we = /* @__PURE__ */ o(Ee())({
251
+ name: "n",
252
+ class: "ntav86o",
253
+ propsAsIs: !0
254
+ }), k = "leaderboard", Ce = (e) => {
255
+ var s;
256
+ return /* @__PURE__ */ t(I, {
257
+ ...e,
258
+ label: "Leader Board",
259
+ id: "leaderboard",
260
+ icon: /* @__PURE__ */ t(we, {
261
+ name: "icon-btn-leaderboard",
262
+ "data-selected": (s = e.active) == null ? void 0 : s.toString()
263
+ })
264
+ });
265
+ };
266
+ const Qe = /* @__PURE__ */ o("div")({
267
+ name: "n",
268
+ class: "n1rlvhvz",
269
+ propsAsIs: !1
270
+ }), Fe = ({
271
+ children: e,
272
+ className: s
273
+ }) => /* @__PURE__ */ t(Qe, {
274
+ className: s,
275
+ children: e
276
+ });
277
+ const Oe = () => Fe, Re = /* @__PURE__ */ o(Oe())({
278
+ name: "n",
279
+ class: "n9bnom",
280
+ propsAsIs: !0
281
+ }), Me = ({ activeOverlay: e, setActiveOverlay: s, sdkReady: n }) => /* @__PURE__ */ c(Re, { children: [
282
+ /* @__PURE__ */ t(xe, { active: e === f, onClick: () => s(f) }),
283
+ /* @__PURE__ */ t(
284
+ Le,
285
+ {
286
+ active: e === u,
287
+ disabled: !n,
288
+ onClick: () => {
289
+ s(u);
290
+ }
291
+ }
292
+ ),
293
+ /* @__PURE__ */ t(
294
+ Ce,
295
+ {
296
+ active: e === k,
297
+ onClick: () => s(k)
298
+ }
299
+ )
300
+ ] }), qe = (e, s) => {
301
+ const [n, r] = h(!1), a = d(e.status) === "ready", [l, i] = h(u), p = D(
302
+ (m) => {
303
+ i(m), m === u ? (e.createEventSession(s), e.openFeature(A.GAMES)) : e.closeFeature();
304
+ },
305
+ [s, e]
306
+ );
307
+ return L(() => {
308
+ !a && l === u && (i(f), e.closeFeature());
309
+ }, [a, l, e]), {
310
+ sdkEnabled: n,
311
+ sdkReady: a,
312
+ activeOverlay: l,
313
+ activateAndLoadOverlay: p,
314
+ enableSdk: () => {
315
+ e.initializeApp().then(({ enabled: m, err: S }) => {
316
+ if (r(!0), S) {
317
+ p(f);
318
+ return;
319
+ }
320
+ if (m) {
321
+ p(u);
322
+ return;
323
+ }
324
+ });
325
+ },
326
+ disableSdk: () => {
327
+ r(!1), e.disableApp();
328
+ }
329
+ };
330
+ }, Ge = (e) => {
331
+ const s = d(e.getActiveFeature()), [n, r] = h(null);
332
+ return L(() => {
333
+ const a = e.getFeatures();
334
+ if (s)
335
+ for (const [l, i] of a)
336
+ l === s ? i.status.get() === v.Suspended && (i.enable(), r(i)) : i.status.get() === v.Ready && i.disable();
337
+ else {
338
+ for (const [, l] of a)
339
+ l.status.get() === v.Ready && l.disable();
340
+ r(null);
341
+ }
342
+ return () => {
343
+ for (const [, l] of a)
344
+ l.status.get() === v.Ready && l.disable();
345
+ };
346
+ }, [s, e]), [s, n];
347
+ }, He = ({ sdk: e }) => {
348
+ const [, s] = Ge(e);
349
+ return /* @__PURE__ */ t(ye, { feature: s, sdk: e });
350
+ }, Ne = ({ sdk: e, overlays: s, children: n, event: r }) => {
351
+ const { sdkEnabled: a, sdkReady: l, activeOverlay: i, activateAndLoadOverlay: p, enableSdk: m, disableSdk: S } = qe(
352
+ e,
353
+ r
354
+ );
355
+ return /* @__PURE__ */ t(G, { style: { height: "100%" }, children: /* @__PURE__ */ c(Y, { children: [
356
+ a && /* @__PURE__ */ t(
357
+ Me,
358
+ {
359
+ sdkReady: l,
360
+ activeOverlay: i,
361
+ setActiveOverlay: p
362
+ }
363
+ ),
364
+ /* @__PURE__ */ t(
365
+ $,
366
+ {
367
+ "data-nav": a.toString(),
368
+ style: { display: !a || i === f ? "block" : "none" },
369
+ children: n && n({ enableSdk: m, disableSdk: S })
370
+ }
371
+ ),
372
+ /* @__PURE__ */ t(
373
+ $,
374
+ {
375
+ "data-nav": a.toString(),
376
+ style: { display: i === k ? "block" : "none" },
377
+ children: s && i === k && s[i]
378
+ }
379
+ ),
380
+ a && i === u && /* @__PURE__ */ t(He, { sdk: e })
381
+ ] }) });
382
+ }, cs = ({
383
+ sdkKey: e,
384
+ plugins: s,
385
+ children: n,
386
+ production: r = !0
387
+ }) => /* @__PURE__ */ t(H, { sdkKey: e, plugins: s, production: r, autoEnable: !1, children: n }), ds = ({ children: e, event: s, overlays: n }) => {
388
+ const { sdk: r, status: a } = P(N);
389
+ if (a === j.UNSET)
390
+ throw new Error("Wrap app in `StreamLayerProvider`");
391
+ return r ? /* @__PURE__ */ t(Ne, { sdk: r, event: s, overlays: n, children: e }) : e({});
392
+ };
393
+ export {
394
+ cs as MastersStreamLayerProvider,
395
+ ds as MastersStreamLayerSDKReact
396
+ };
@@ -0,0 +1,68 @@
1
+ import { jsxs as m, jsx as t } from "react/jsx-runtime";
2
+ import { FeatureType as n } from "@streamlayer/sdk-web-types";
3
+ import { useMemo as p } from "react";
4
+ import { s, Y as l, c } from "../provider-a6b36c89.js";
5
+ import "react-auth-code-input";
6
+ import "react-phone-number-input";
7
+ import "@connectrpc/connect";
8
+ import "@connectrpc/connect-web";
9
+ import "@streamlayer/sl-eslib/users/users_connect";
10
+ import "react-countdown-circle-timer";
11
+ import "@streamlayer/sdk-web-interfaces";
12
+ import "@streamlayer/sdk-web-features";
13
+ import "@streamlayer/sdk-web-api";
14
+ import "@streamlayer/sdk-web-storage";
15
+ import { useStore as a } from "@nanostores/react";
16
+ import "@streamlayer/sdk-web-notifications";
17
+ import { u } from "../app-43e52907.js";
18
+ import "@streamlayer/sl-eslib/interactive/interactive.common_pb";
19
+ import "@streamlayer/sl-eslib/interactive/feed/interactive.feed_pb";
20
+ import "@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb";
21
+ import "@streamlayer/sl-eslib/sports/events/events_connect";
22
+ import "@streamlayer/sl-eslib/sdkSettings/client/client_connect";
23
+ import "./useStreamLayerApp.js";
24
+ import "@streamlayer/sdk-web";
25
+ const d = () => l, f = /* @__PURE__ */ s("div")({
26
+ name: "l",
27
+ class: "l4qld3l",
28
+ propsAsIs: !1
29
+ }), S = /* @__PURE__ */ s("div")({
30
+ name: "a",
31
+ class: "ainhtok",
32
+ propsAsIs: !1
33
+ }), y = /* @__PURE__ */ s(d())({
34
+ name: "x",
35
+ class: "xk8yd5t",
36
+ propsAsIs: !0
37
+ }), h = /* @__PURE__ */ s("div")({
38
+ name: "h",
39
+ class: "h6rf9gb",
40
+ propsAsIs: !1
41
+ }), x = /* @__PURE__ */ s("div")({
42
+ name: "c",
43
+ class: "c18f5pxx",
44
+ propsAsIs: !1
45
+ }), v = /* @__PURE__ */ s("div")({
46
+ name: "m",
47
+ class: "m1jwsyj1",
48
+ propsAsIs: !1
49
+ }), g = ({ points: r }) => /* @__PURE__ */ m(f, { children: [
50
+ /* @__PURE__ */ t(S, { children: /* @__PURE__ */ t(y, { name: "icon-trophy" }) }),
51
+ /* @__PURE__ */ m(h, { children: [
52
+ /* @__PURE__ */ t(x, { children: "Total points" }),
53
+ /* @__PURE__ */ t(v, { children: c(r) })
54
+ ] })
55
+ ] }), A = ({ userSummary: r }) => {
56
+ var e, o;
57
+ const i = a(r.getStore());
58
+ return ((o = (e = i.data) == null ? void 0 : e.summary) == null ? void 0 : o.points) === void 0 ? null : /* @__PURE__ */ t(g, { points: i.data.summary.points });
59
+ }, I = ({ sdk: r }) => {
60
+ const { organizationSettings: i, streamSettings: e } = a(r.sdkStore), o = p(() => r.getFeature(n.GAMES), [r, i, e]);
61
+ return o ? /* @__PURE__ */ t(A, { userSummary: o.userSummary }) : null;
62
+ }, Q = () => {
63
+ const r = u();
64
+ return r ? /* @__PURE__ */ t(I, { sdk: r }) : null;
65
+ };
66
+ export {
67
+ Q as StreamLayerSDKPoints
68
+ };
@@ -0,0 +1,27 @@
1
+ import { StreamLayer as a } from "@streamlayer/sdk-web";
2
+ import { useState as i, useEffect as c } from "react";
3
+ const m = (t, n, s, f) => {
4
+ const [u, l] = i(null);
5
+ return c(() => {
6
+ let r = !1;
7
+ if (!t)
8
+ return console.error("streamlayer sdk key should be provided"), l((e) => (e !== null && typeof e.disableApp == "function" && e.disableApp(), null)), () => {
9
+ r = !0;
10
+ };
11
+ const o = a(t, s, f);
12
+ if (n)
13
+ for (const e of n)
14
+ o.use(e);
15
+ return o.ready().then((e) => {
16
+ r || l(e.sdk);
17
+ }).catch((e) => console.log(e)), () => {
18
+ r = !0, o.close(function(e) {
19
+ if (e)
20
+ throw e;
21
+ });
22
+ };
23
+ }, [t, s]), u;
24
+ };
25
+ export {
26
+ m as useStreamLayerApp
27
+ };
package/lib/index.d.ts CHANGED
@@ -9,6 +9,3 @@ import '@streamlayer/sdk-web-notifications';
9
9
  import '@streamlayer/feature-gamification';
10
10
  export { StreamLayerProvider } from './app/provider';
11
11
  export { StreamLayerSDKReact, useStreamLayer } from './app/app';
12
- export { useStreamLayerApp } from './app/useStreamLayerApp';
13
- export { StreamLayerSDKPoints } from './app/points';
14
- export { MastersStreamLayerSDKReact } from './app/masters';