@streamlayer/sdk-web 1.5.6 → 1.6.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/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { pino as bi } from "pino";
2
- import { QuestionType as C, QuestionStatus as Y, PromotionType as re, NotificationEnabled as Rr, SilenceSetting as vi } from "@streamlayer/sl-eslib/interactive/interactive.common_pb";
2
+ import { QuestionType as C, QuestionStatus as J, PromotionType as re, NotificationEnabled as Rr, SilenceSetting as vi } from "@streamlayer/sl-eslib/interactive/interactive.common_pb";
3
3
  import { PickHistoryStatus as ct } from "@streamlayer/sl-eslib/interactive/feed/interactive.feed_pb";
4
4
  import { SdkOverlayType as D } from "@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb";
5
5
  import { InvitationCategory as Vr, InvitationFrom as $r } from "@streamlayer/sl-eslib/analytics/v1/invitations/invitations_pb";
@@ -203,7 +203,7 @@ class Ce extends kt {
203
203
  subscribe = (...e) => this.getStore().subscribe(...e);
204
204
  unsubscribe = () => this.getStore().off();
205
205
  }
206
- const J = (t) => wi(t);
206
+ const W = (t) => wi(t);
207
207
  var ye;
208
208
  (function(t) {
209
209
  t.ORGANIZATION = "ORGANIZATION", t.STREAM = "STREAM";
@@ -226,7 +226,7 @@ class kn {
226
226
  listeners = /* @__PURE__ */ new Set();
227
227
  settingsKey;
228
228
  constructor({ settings: e, ...r }, n) {
229
- this.settingsKey = Di[r.type], this.status = Lt(Xe.Suspended), this.config = new Ce(J(r), `feature:config:${this.settingsKey}`), this.settingsKey !== void 0 && e?.overlaySettings.case === this.settingsKey ? this.settings = new Ce(J(e.overlaySettings.value), `feature:settings:${this.settingsKey}`) : this.settings = new Ce(J({}), `feature:settings:${this.settingsKey}`), this.source = n;
229
+ this.settingsKey = Di[r.type], this.status = Lt(Xe.Suspended), this.config = new Ce(W(r), `feature:config:${this.settingsKey}`), this.settingsKey !== void 0 && e?.overlaySettings.case === this.settingsKey ? this.settings = new Ce(W(e.overlaySettings.value), `feature:settings:${this.settingsKey}`) : this.settings = new Ce(W({}), `feature:settings:${this.settingsKey}`), this.source = n;
230
230
  }
231
231
  get featureConfig() {
232
232
  return this.config.getStore();
@@ -283,7 +283,7 @@ class X extends kt {
283
283
  return this.getStore().get();
284
284
  }
285
285
  }
286
- const U = (t) => Lt(t);
286
+ const j = (t) => Lt(t);
287
287
  class le extends kt {
288
288
  atomStore;
289
289
  constructor(e, r, n) {
@@ -438,13 +438,13 @@ class $i {
438
438
  ts: /* @__PURE__ */ new Date(),
439
439
  log: []
440
440
  };
441
- this.state = new Ce(J(o), `subscription:${i.name}:state`), this.options = {
441
+ this.state = new Ce(W(o), `subscription:${i.name}:state`), this.options = {
442
442
  ...i,
443
443
  reconnectDelay: i.reconnectDelay ?? 1e3,
444
444
  reconnectMaxDelay: i.reconnectMaxDelay ?? 3e4,
445
445
  reconnectMaxAttempts: i.reconnectMaxAttempts ?? 10,
446
446
  withStore: i.withStore ?? !1
447
- }, this.headers = e, this.listeners = /* @__PURE__ */ new Map(), this.params = n, this.method = r, i.withStore && (this.store = new X(U(null), `subscription:${i.name}:store`)), "subscribe" in n && typeof n.subscribe == "function" && (this.paramsListener = n.subscribe((s) => {
447
+ }, this.headers = e, this.listeners = /* @__PURE__ */ new Map(), this.params = n, this.method = r, i.withStore && (this.store = new X(j(null), `subscription:${i.name}:store`)), "subscribe" in n && typeof n.subscribe == "function" && (this.paramsListener = n.subscribe((s) => {
448
448
  this.state.getValue("status") === te.Connected && (this.addStateLog(`params updated, reconnect => ${JSON.stringify(s)}`), this.reconnect());
449
449
  })), this.updateState(te.Ready);
450
450
  }
@@ -580,7 +580,7 @@ class zr {
580
580
  subscriptions;
581
581
  opts;
582
582
  constructor(e, r) {
583
- this.host = e, this.opts = r, this.$headers = new Ce(J({
583
+ this.host = e, this.opts = r, this.$headers = new Ce(W({
584
584
  "sl-device-id": Bi(),
585
585
  "sl-device-os": Ui()
586
586
  }), "transport:headers"), this.initInterceptors(), this.clients = /* @__PURE__ */ new Map(), this.streamClients = /* @__PURE__ */ new Map(), this.subscriptions = /* @__PURE__ */ new Map();
@@ -793,7 +793,7 @@ var me;
793
793
  t.DISABLED = "disabled", t.INITIALIZATION = "initialization", t.READY = "ready", t.FAILED = "failed", t.SUSPENDED = "suspended";
794
794
  })(me || (me = {}));
795
795
  const Ji = (t) => {
796
- const e = new Be(), r = new X(U(e.getExternalToken()), "userKey"), n = new X(U(e.getToken()), "userToken"), i = new le(Gi(n.getStore(), t), "user", ({ data: s, error: a, loading: u }, l) => {
796
+ const e = new Be(), r = new X(j(e.getExternalToken()), "userKey"), n = new X(j(e.getToken()), "userToken"), i = new le(Gi(n.getStore(), t), "user", ({ data: s, error: a, loading: u }, l) => {
797
797
  if (!a)
798
798
  return s?.data?.id ? s.data.id : u === !1 ? void 0 : l;
799
799
  }), o = new le(zi(n.getStore(), t), "userSettings");
@@ -804,7 +804,7 @@ const Ji = (t) => {
804
804
  userSettings: o
805
805
  };
806
806
  }, Xi = (t) => {
807
- const e = new X(U(void 0), "providerStreamId"), r = new le(qi(e.getStore(), t), "slStreamId", (o) => o?.data), n = new le(xi(r.getAtomStore(), t), "streamSettings"), i = new le(Qi(r.getAtomStore(), t), "streamSettings");
807
+ const e = new X(j(void 0), "providerStreamId"), r = new le(qi(e.getStore(), t), "slStreamId", (o) => o?.data), n = new le(xi(r.getAtomStore(), t), "streamSettings"), i = new le(Qi(r.getAtomStore(), t), "streamSettings");
808
808
  return r.getAtomStore().listen((o) => {
809
809
  (o === "" || o === void 0) && (n.getStore().mutate(void 0), i.getStore().mutate(void 0));
810
810
  }), {
@@ -814,7 +814,7 @@ const Ji = (t) => {
814
814
  streamSummary: i
815
815
  };
816
816
  }, Zi = (t) => {
817
- const e = new X(U(void 0), "enabled"), r = new X(U(me.DISABLED), "status"), n = new le(Hi(e.getStore(), t), "organizationSettings", (a) => a?.data?.id), i = new le(Wi(n.getAtomStore(), t), "organizationAdvertising"), o = Ji(t), s = Xi(t);
817
+ const e = new X(j(void 0), "enabled"), r = new X(j(me.DISABLED), "status"), n = new le(Hi(e.getStore(), t), "organizationSettings", (a) => a?.data?.id), i = new le(Wi(n.getAtomStore(), t), "organizationAdvertising"), o = Ji(t), s = Xi(t);
818
818
  return {
819
819
  enabled: e,
820
820
  status: r,
@@ -953,7 +953,7 @@ const to = (t, e, r) => {
953
953
  eventId: a,
954
954
  filter: {
955
955
  types: u === Le.ALLOWED ? [] : [C.FACTOID, C.PROMOTION, C.TWEET],
956
- statuses: [Y.ACTIVE, Y.RESOLVED]
956
+ statuses: [J.ACTIVE, J.RESOLVED]
957
957
  }
958
958
  })).data : [],
959
959
  dedupeTime: 0,
@@ -972,7 +972,7 @@ const to = (t, e, r) => {
972
972
  eventId: s,
973
973
  filter: {
974
974
  types: [C.PROMOTION],
975
- statuses: [Y.ACTIVE]
975
+ statuses: [J.ACTIVE]
976
976
  },
977
977
  pagination: {
978
978
  page: 0,
@@ -1058,7 +1058,7 @@ const yo = (t) => {
1058
1058
  return r + n.join("&");
1059
1059
  }, go = (t, e, r) => {
1060
1060
  let n = !1;
1061
- const i = r.transport, o = Se("advertisement"), s = new ho(), a = J({}), u = fo(t, i), l = () => {
1061
+ const i = r.transport, o = Se("advertisement"), s = new ho(), a = W({}), u = fo(t, i), l = () => {
1062
1062
  a.setKey("hasNotification", !1);
1063
1063
  const g = a.get(), b = g.data?.question.id, S = g.data?.promotion?.type;
1064
1064
  b && G.emit("advertisement", {
@@ -1131,11 +1131,11 @@ const yo = (t) => {
1131
1131
  }), e.addListener("promotion", (g) => {
1132
1132
  const b = yo(g);
1133
1133
  if (b) {
1134
- if (b.question.status === Y.RESOLVED) {
1134
+ if (b.question.status === J.RESOLVED) {
1135
1135
  p(b.question.id), o.debug({ promotion: b }, "resolved: %o");
1136
1136
  return;
1137
1137
  }
1138
- if (b.question.status === Y.ACTIVE) {
1138
+ if (b.question.status === J.ACTIVE) {
1139
1139
  o.debug({ promotion: b }, "active: %o"), f(b.question.id, b);
1140
1140
  return;
1141
1141
  }
@@ -1181,14 +1181,14 @@ class bo {
1181
1181
  transport;
1182
1182
  cancels = /* @__PURE__ */ new Set();
1183
1183
  constructor(e) {
1184
- this.transport = e.transport, this.log = Se("gamification-background"), this.slStreamId = e.stores.slStreamId.getAtomStore(), this.organizationId = e.stores.organizationSettings.getAtomStore(), this.userId = e.stores.user.getAtomStore(), this.moderationId = new X(U(void 0), "moderationId").getStore(), this.interactiveAllowed = new X(U(Le.DISALLOWED), "interactiveAllowed").getStore(), this.openedQuestionId = new X(U(void 0), "openedQuestionId").getStore(), this.notifications = e.notifications, this.moderation = new le(io(this.slStreamId, e.transport), "gamification:moderation"), this.feedList = new le(lo(this.slStreamId, this.interactiveAllowed, e.transport), "gamification:feedList"), this.activeQuestionId = oo(this.slStreamId, e.transport), this.openedQuestion = po(e.transport, this.openedQuestionId, this.feedList.getStore()), this.cancels.add(this.openedQuestionId.listen((r) => {
1184
+ this.transport = e.transport, this.log = Se("gamification-background"), this.slStreamId = e.stores.slStreamId.getAtomStore(), this.organizationId = e.stores.organizationSettings.getAtomStore(), this.userId = e.stores.user.getAtomStore(), this.moderationId = new X(j(void 0), "moderationId").getStore(), this.interactiveAllowed = new X(j(Le.DISALLOWED), "interactiveAllowed").getStore(), this.openedQuestionId = new X(j(void 0), "openedQuestionId").getStore(), this.notifications = e.notifications, this.moderation = new le(io(this.slStreamId, e.transport), "gamification:moderation"), this.feedList = new le(lo(this.slStreamId, this.interactiveAllowed, e.transport), "gamification:feedList"), this.activeQuestionId = oo(this.slStreamId, e.transport), this.openedQuestion = po(e.transport, this.openedQuestionId, this.feedList.getStore()), this.cancels.add(this.openedQuestionId.listen((r) => {
1185
1185
  this.log.debug({ item: r }, "received question"), r?.questionId ? (this.questionSubscription = uo(r.questionId, e.transport), this.questionSubscription.addListener("feed-subscription-opened-question", (n) => {
1186
1186
  this.openedQuestion.updateExtendedQuestion(n.data?.attributes?.question);
1187
1187
  }), this.questionSubscription.connect()) : (this.log.info("cleanup on close question"), this.questionSubscription !== void 0 && (e.transport.removeSubscription(this.questionSubscription), this.questionSubscription = void 0));
1188
1188
  })), this.feedSubscription = ao(this.slStreamId, e.transport), this.cancels.add(this.feedSubscription.addListener("feed-subscription-active-question", (r) => {
1189
1189
  const n = this.activeQuestionId.get().data?.question?.id, i = r.data?.attributes?.question;
1190
1190
  if (!(!i || i.type === C.PROMOTION)) {
1191
- if (i.status === Y.RESOLVED) {
1191
+ if (i.status === J.RESOLVED) {
1192
1192
  n === i.id && this.activeQuestionId.mutate(void 0);
1193
1193
  return;
1194
1194
  }
@@ -1267,7 +1267,7 @@ class vo {
1267
1267
  options;
1268
1268
  logger;
1269
1269
  constructor(e) {
1270
- this.options = e, this.logger = Se("notifications"), this.store = /* @__PURE__ */ new Map(), this.timeouts = /* @__PURE__ */ new Map(), this.waitingQueue = /* @__PURE__ */ new Set(), this.activeQueue = /* @__PURE__ */ new Set(), this.notificationsList = U(/* @__PURE__ */ new Map());
1270
+ this.options = e, this.logger = Se("notifications"), this.store = /* @__PURE__ */ new Map(), this.timeouts = /* @__PURE__ */ new Map(), this.waitingQueue = /* @__PURE__ */ new Set(), this.activeQueue = /* @__PURE__ */ new Set(), this.notificationsList = j(/* @__PURE__ */ new Map());
1271
1271
  }
1272
1272
  addToQueue = (e) => {
1273
1273
  if (this.store.has(e.id)) {
@@ -1464,7 +1464,7 @@ const Oo = {
1464
1464
  pageSize: 10
1465
1465
  }, _o = (t, e, r, n, i) => {
1466
1466
  let o = 0;
1467
- const s = U({ pageSize: Oo.pageSize, page: 0 }), a = J({
1467
+ const s = j({ pageSize: Oo.pageSize, page: 0 }), a = W({
1468
1468
  data: [],
1469
1469
  key: Date.now(),
1470
1470
  hasMore: !0,
@@ -1564,7 +1564,7 @@ const Hr = "sldl", Pt = "sldl_uid", Vn = "sldl_eid", $n = "sldl_e_eid", Lo = /*
1564
1564
  ce.debug(a);
1565
1565
  }
1566
1566
  t.deepLink = {
1567
- $store: new Ce(J(o), "deep-link-context"),
1567
+ $store: new Ce(W(o), "deep-link-context"),
1568
1568
  getDeepLinkData: () => {
1569
1569
  const { data: a, used: u } = t.deepLink.$store.getValues();
1570
1570
  return { data: a, used: u };
@@ -1727,7 +1727,7 @@ const Je = new Be(), Ro = (t, e, r) => {
1727
1727
  [C.PREDICTION]: "prediction",
1728
1728
  [C.TWEET]: "tweet"
1729
1729
  }, Mo = (t, e, r) => {
1730
- t.sdk.uiState = J({}), t.ui = {
1730
+ t.sdk.uiState = W({}), t.ui = {
1731
1731
  enableAppNotification: function() {
1732
1732
  t.sdk.uiState.setKey("appNotification", !0);
1733
1733
  },
@@ -1829,7 +1829,7 @@ const Je = new Be(), Ro = (t, e, r) => {
1829
1829
  }), r();
1830
1830
  }, jo = (t, e, r) => {
1831
1831
  const n = { onMountedFired: !1 }, i = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
1832
- t.sdk = /* @__PURE__ */ Object.create(null), t.sdk.withAuth = !1, t.sdk.onMount = ({ name: s, clear: a }, u) => {
1832
+ t.sdk = /* @__PURE__ */ Object.create(null), t.sdk.options = W(e), t.sdk.withAuth = !1, t.sdk.onMount = ({ name: s, clear: a }, u) => {
1833
1833
  if (i.has(s)) {
1834
1834
  const l = o.get(s);
1835
1835
  l && l(), i.delete(s), o.delete(s);
@@ -1884,7 +1884,7 @@ const Je = new Be(), Ro = (t, e, r) => {
1884
1884
  r.append(n, i);
1885
1885
  return r.toString();
1886
1886
  }, qo = (t, e, r, n) => {
1887
- const i = J({});
1887
+ const i = W({});
1888
1888
  return br(i, () => Bo(t, [e, r]).subscribe(async ({ data: a, loading: u }) => {
1889
1889
  const l = a === void 0 && u === !1 ? "https://streamlayer.io" : a?.url, c = n.get() || "", f = e.get() || "", p = r.get() || "", v = {
1890
1890
  [Pt]: c,
@@ -1966,7 +1966,7 @@ const xo = (t, e, r, n) => {
1966
1966
  }
1967
1967
  }, Qo = (t, e, r, n) => {
1968
1968
  let i = !1;
1969
- const o = new Rn(), s = U(M.Unset);
1969
+ const o = new Rn(), s = j(M.Unset);
1970
1970
  s.subscribe((l) => {
1971
1971
  l !== M.Unset && (l === M.Optional || l === M.Required ? i === !1 && (xo(t, e, n, o), i = !0) : t.onboardingProcessed.set(!0), l === M.Completed && e.activeQuestionId.invalidate(), o.setOnboardingInstantOpen({
1972
1972
  userId: e.userId.get() || "",
@@ -1997,7 +1997,7 @@ const xo = (t, e, r, n) => {
1997
1997
  }
1998
1998
  } };
1999
1999
  }, Go = (t, e, r, n) => {
2000
- const i = J(void 0), o = Fn(n), s = async () => {
2000
+ const i = W(void 0), o = Fn(n), s = async () => {
2001
2001
  const u = t.get(), l = e.get(), c = r.getStore().get().data?.map((v) => v.slId);
2002
2002
  if (!c)
2003
2003
  return;
@@ -2051,6 +2051,7 @@ class Ho extends kn {
2051
2051
  openedQuestionId;
2052
2052
  advertisement;
2053
2053
  onboardingProcessed;
2054
+ friendsTabEnabled;
2054
2055
  notifications;
2055
2056
  transport;
2056
2057
  /** gamification background class, handle subscriptions and notifications for closed overlay */
@@ -2061,11 +2062,15 @@ class Ho extends kn {
2061
2062
  cancels = /* @__PURE__ */ new Set();
2062
2063
  onQuestionActivate;
2063
2064
  constructor(e, r, n) {
2064
- super(e, r), this.background = new bo(n), this.advertisement = this.background.advertisement, this.onQuestionActivate = n.onQuestionActivate, this.feedSubscription = this.background.feedSubscription, this.activeQuestionId = this.background.activeQuestionId, this.openedQuestionId = this.background.openedQuestionId, this.storage = new Rn(), this.feedList = this.background.feedList, this.friends = new le(no(this.background.userId, n.transport), "gamification:friends"), this.currentUserId = this.background.userId, this.openedUser = U(void 0), this.onboardingProcessed = U(!n.sdk.withAuth), this.leaderboardId = new X(U(this.settings.getValue("pinnedLeaderboardId")), "pinnedLeaderboardId").getStore(), this.onboardingStatus = Qo(this, this.background, n.transport, n.notifications), this.notifications = n.notifications, this.transport = n.transport, this.closeFeature = (i = !0) => n.sdk.closeFeature(i), this.openFeature = () => n.sdk.openFeature(D.GAMES), this.openedQuestion = this.background.openedQuestion, this.deepLink = qo(this.transport, this.background.slStreamId, n.stores.providerStreamId.getStore(), this.background.userId), this.userSummary = Go(this.background.slStreamId, this.background.userId, this.friends, this.transport), this.leaderboardList = _o(this.transport, this.background.slStreamId, this.background.userId, this.friends), this.connect(), this.cancels.add(this.userSummary.$store.listen((i, o) => {
2065
+ super(e, r), this.background = new bo(n), this.advertisement = this.background.advertisement, this.onQuestionActivate = n.onQuestionActivate, this.feedSubscription = this.background.feedSubscription, this.activeQuestionId = this.background.activeQuestionId, this.openedQuestionId = this.background.openedQuestionId, this.storage = new Rn(), this.feedList = this.background.feedList, this.friends = new le(no(this.background.userId, n.transport), "gamification:friends"), this.currentUserId = this.background.userId, this.openedUser = j(void 0), this.onboardingProcessed = j(!n.sdk.withAuth), this.leaderboardId = new X(j(this.settings.getValue("pinnedLeaderboardId")), "pinnedLeaderboardId").getStore(), this.onboardingStatus = Qo(this, this.background, n.transport, n.notifications), this.notifications = n.notifications, this.transport = n.transport, this.closeFeature = (i = !0) => n.sdk.closeFeature(i), this.openFeature = () => n.sdk.openFeature(D.GAMES), this.openedQuestion = this.background.openedQuestion, this.deepLink = qo(this.transport, this.background.slStreamId, n.stores.providerStreamId.getStore(), this.background.userId), this.userSummary = Go(this.background.slStreamId, this.background.userId, this.friends, this.transport), this.leaderboardList = _o(this.transport, this.background.slStreamId, this.background.userId, this.friends), this.connect(), this.cancels.add(this.userSummary.$store.listen((i, o) => {
2065
2066
  o?.summary && i?.summary && this.leaderboardList.invalidate();
2066
2067
  })), this.cancels.add(this.onboardingStatus.$store.listen(this.checkInteractiveFlag)), this.cancels.add(this.background.moderation.getStore().listen(this.checkInteractiveFlag)), this.cancels.add(this.settings.subscribe(this.checkInteractiveFlag)), this.cancels.add(this.onboardingStatus.$store.listen((i, o) => {
2067
2068
  (o === void 0 || i !== M.Unset) && this.background.activeQuestionId.invalidate();
2068
- })), this.background.activeQuestionId.listen(this.showInApp), n.sdk.onMount({ name: "gamification", clear: !0 }, () => () => {
2069
+ })), this.background.activeQuestionId.listen(this.showInApp), this.friendsTabEnabled = j(!1), this.cancels.add(n.sdk.options.subscribe((i) => {
2070
+ i.friendsTab === "disabled" ? this.friendsTabEnabled.set(!1) : i.friendsTab === "enabled" && this.friendsTabEnabled.set(!0);
2071
+ })), this.cancels.add(this.settings.subscribe((i) => {
2072
+ n.sdk.options.get().friendsTab === "activatedGame" && this.friendsTabEnabled.set(!!i.inplayGame?.titleCard?.optIn);
2073
+ })), n.sdk.onMount({ name: "gamification", clear: !0 }, () => () => {
2069
2074
  for (const i of this.cancels)
2070
2075
  i(), this.cancels.delete(i);
2071
2076
  });
@@ -2087,7 +2092,7 @@ class Ho extends kn {
2087
2092
  if (!r || !n?.attributes)
2088
2093
  return;
2089
2094
  const { status: i, type: o, id: s, answers: a } = r;
2090
- if (i === Y.RESOLVED && o === C.PREDICTION) {
2095
+ if (i === J.RESOLVED && o === C.PREDICTION) {
2091
2096
  const u = this.background.getCurrentSessionId({
2092
2097
  prefix: `notification-id:${s}`
2093
2098
  }), l = [...this.feedList.getValues().data || []], c = l.findIndex((K) => K.id === s), f = l[c];
@@ -2127,7 +2132,7 @@ class Ho extends kn {
2127
2132
  },
2128
2133
  correctAnswerTitle: S?.text,
2129
2134
  correct: !!$,
2130
- predictionResult: i === Y.RESOLVED,
2135
+ predictionResult: i === J.RESOLVED,
2131
2136
  questionTitle: r?.subject
2132
2137
  }
2133
2138
  }
@@ -2135,7 +2140,7 @@ class Ho extends kn {
2135
2140
  }
2136
2141
  })), this.cancels.add(this.background.feedSubscription.addListener("feed-subscription-questions-list", (e) => {
2137
2142
  const r = [...this.feedList.getStore().value?.data || []], n = e.data?.attributes?.feedItem, i = r.findIndex((o) => o.id === n?.id);
2138
- if (n?.attributes && n.attributes.attributes.case !== "promotion" && !(n.attributes.status !== Y.ACTIVE && n.attributes.status !== Y.RESOLVED)) {
2143
+ if (n?.attributes && n.attributes.attributes.case !== "promotion" && !(n.attributes.status !== J.ACTIVE && n.attributes.status !== J.RESOLVED)) {
2139
2144
  if (i !== -1)
2140
2145
  if (n.attributes.attributes.case === "question" && r[i].attributes?.attributes.case === "question") {
2141
2146
  const o = r[i];
@@ -2215,7 +2220,7 @@ class Ho extends kn {
2215
2220
  const p = f.answers.find((S) => S.correct === !0), v = f.answers.findIndex((S) => S.id === r), g = f.answers[v], b = f.answers.every(({ percentageDecimal: S }, O) => S === o?.answers[O].percentageDecimal);
2216
2221
  a[u].attributes.attributes.value.answerId = r, a[u].attributes.attributes.value.openForVoting = !1, a[u].attributes.attributes.value.text = g?.text || "", p && (a[u].attributes.attributes.value.status = p.id === r ? ct.WON : ct.LOST), this.feedList.getStore().mutate([...a]), f.answers[v].correct = p?.id === r, f.answers[v].youVoted = !0, b && f.answers.forEach((S) => {
2217
2222
  S.percentageDecimal = 0;
2218
- }), p?.id === r && (f.answers[v].pointsEarned = f.status === Y.RESOLVED ? 0 : p.points), n.mutate({ ...f });
2223
+ }), p?.id === r && (f.answers[v].pointsEarned = f.status === J.RESOLVED ? 0 : p.points), n.mutate({ ...f });
2219
2224
  }
2220
2225
  this.submitAnswerTimeout && clearTimeout(this.submitAnswerTimeout), this.submitAnswerTimeout = setTimeout(() => {
2221
2226
  this.userSummary.invalidate();
@@ -2294,7 +2299,7 @@ class Ho extends kn {
2294
2299
  */
2295
2300
  showInApp = (e) => {
2296
2301
  const r = this.onboardingStatus.$store.get();
2297
- if (e && e.data && r && r !== M.Unset && e.data.question?.id !== void 0 && e.data.question.notification !== void 0 && e.data.question?.bypassNotifications?.inAppSilence !== vi.ON && e.data.question.status === Y.ACTIVE && !e.data.question.marketClosed) {
2302
+ if (e && e.data && r && r !== M.Unset && e.data.question?.id !== void 0 && e.data.question.notification !== void 0 && e.data.question?.bypassNotifications?.inAppSilence !== vi.ON && e.data.question.status === J.ACTIVE && !e.data.question.marketClosed) {
2298
2303
  if (zo.has(e.data.question.type))
2299
2304
  this.isInteractiveAllowed && this.notifications.add({
2300
2305
  type: Ee.QUESTION,
@@ -2379,7 +2384,7 @@ class Yo extends kn {
2379
2384
  }
2380
2385
  }
2381
2386
  const Jo = (t, e, r) => t.type === D.GAMES ? new Ho(t, e, r) : new Yo(t, e), Xo = (t, e, r) => {
2382
- t.features = /* @__PURE__ */ new Map(), t.sdk.featuresList = new X(U(/* @__PURE__ */ new Set()), "features-list"), t.activeFeature = new X(U(D.UNSET), "activeFeature"), t.sdk.getFeatures = () => t.features, t.sdk.getFeature = (n) => t.features.get(n), t.sdk.getActiveFeature = () => t.activeFeature.getStore(), t.sdk.openFeature = (n) => {
2387
+ t.features = /* @__PURE__ */ new Map(), t.sdk.featuresList = new X(j(/* @__PURE__ */ new Set()), "features-list"), t.activeFeature = new X(j(D.UNSET), "activeFeature"), t.sdk.getFeatures = () => t.features, t.sdk.getFeature = (n) => t.features.get(n), t.sdk.getActiveFeature = () => t.activeFeature.getStore(), t.sdk.openFeature = (n) => {
2383
2388
  t.activeFeature.setValue(n);
2384
2389
  }, t.sdk.closeFeature = (n = !1) => {
2385
2390
  const i = t.activeFeature.getValue();
@@ -2774,7 +2779,7 @@ class os {
2774
2779
  }
2775
2780
  const ss = ({ transport: t, $commonStore: e }) => {
2776
2781
  let r;
2777
- const n = U(!1), i = 5e3, { client: o, queryKey: s } = t.createPromiseClient(Tn, {
2782
+ const n = j(!1), i = 5e3, { client: o, queryKey: s } = t.createPromiseClient(Tn, {
2778
2783
  method: "send",
2779
2784
  params: [n]
2780
2785
  }), a = t.nanoquery.createFetcherStore(s, {
@@ -2823,7 +2828,7 @@ class as {
2823
2828
  listenersCancels;
2824
2829
  connected = !1;
2825
2830
  constructor(e) {
2826
- this.listeners = /* @__PURE__ */ new Set(), this.listenersCancels = /* @__PURE__ */ new Set(), this.commonStore = new Ce(J({}), "common-analytics"), this.connectToSDK(e), this.heartbeat = ss({ transport: e.analyticsTransport, $commonStore: this.commonStore }), this.notifications = new is(this), this.polls = new os(this), this.invitation = new Zo(this), this.interactions = new es(this), this.advertisement = new rs(this);
2831
+ this.listeners = /* @__PURE__ */ new Set(), this.listenersCancels = /* @__PURE__ */ new Set(), this.commonStore = new Ce(W({}), "common-analytics"), this.connectToSDK(e), this.heartbeat = ss({ transport: e.analyticsTransport, $commonStore: this.commonStore }), this.notifications = new is(this), this.polls = new os(this), this.invitation = new Zo(this), this.interactions = new es(this), this.advertisement = new rs(this);
2827
2832
  const { client: r } = e.analyticsTransport.createPromiseClient(Tn, {
2828
2833
  method: "send"
2829
2834
  });
@@ -2896,8 +2901,8 @@ function Mn(t, e, r) {
2896
2901
  throw new Error("fastqueue concurrency must be equal to or greater than 1");
2897
2902
  var n = fs(ps), i = null, o = null, s = 0, a = null, u = {
2898
2903
  push: b,
2899
- drain: W,
2900
- saturated: W,
2904
+ drain: Y,
2905
+ saturated: Y,
2901
2906
  pause: c,
2902
2907
  paused: !1,
2903
2908
  get concurrency() {
@@ -2916,7 +2921,7 @@ function Mn(t, e, r) {
2916
2921
  length: f,
2917
2922
  getQueue: p,
2918
2923
  unshift: S,
2919
- empty: W,
2924
+ empty: Y,
2920
2925
  kill: $,
2921
2926
  killAndDrain: K,
2922
2927
  error: ee
@@ -2953,11 +2958,11 @@ function Mn(t, e, r) {
2953
2958
  }
2954
2959
  function b(P, R) {
2955
2960
  var T = n.get();
2956
- T.context = t, T.release = O, T.value = P, T.callback = R || W, T.errorHandler = a, s >= r || u.paused ? o ? (o.next = T, o = T) : (i = T, o = T, u.saturated()) : (s++, e.call(t, T.value, T.worked));
2961
+ T.context = t, T.release = O, T.value = P, T.callback = R || Y, T.errorHandler = a, s >= r || u.paused ? o ? (o.next = T, o = T) : (i = T, o = T, u.saturated()) : (s++, e.call(t, T.value, T.worked));
2957
2962
  }
2958
2963
  function S(P, R) {
2959
2964
  var T = n.get();
2960
- T.context = t, T.release = O, T.value = P, T.callback = R || W, T.errorHandler = a, s >= r || u.paused ? i ? (T.next = i, i = T) : (i = T, o = T, u.saturated()) : (s++, e.call(t, T.value, T.worked));
2965
+ T.context = t, T.release = O, T.value = P, T.callback = R || Y, T.errorHandler = a, s >= r || u.paused ? i ? (T.next = i, i = T) : (i = T, o = T, u.saturated()) : (s++, e.call(t, T.value, T.worked));
2961
2966
  }
2962
2967
  function O(P) {
2963
2968
  P && n.release(P);
@@ -2965,23 +2970,23 @@ function Mn(t, e, r) {
2965
2970
  R && s <= r ? u.paused ? s-- : (o === i && (o = null), i = R.next, R.next = null, e.call(t, R.value, R.worked), o === null && u.empty()) : --s === 0 && u.drain();
2966
2971
  }
2967
2972
  function $() {
2968
- i = null, o = null, u.drain = W;
2973
+ i = null, o = null, u.drain = Y;
2969
2974
  }
2970
2975
  function K() {
2971
- i = null, o = null, u.drain(), u.drain = W;
2976
+ i = null, o = null, u.drain(), u.drain = Y;
2972
2977
  }
2973
2978
  function ee(P) {
2974
2979
  a = P;
2975
2980
  }
2976
2981
  }
2977
- function W() {
2982
+ function Y() {
2978
2983
  }
2979
2984
  function ps() {
2980
- this.value = null, this.callback = W, this.next = null, this.release = W, this.context = null, this.errorHandler = null;
2985
+ this.value = null, this.callback = Y, this.next = null, this.release = Y, this.context = null, this.errorHandler = null;
2981
2986
  var t = this;
2982
2987
  this.worked = function(r, n) {
2983
2988
  var i = t.callback, o = t.errorHandler, s = t.value;
2984
- t.value = null, t.callback = W, t.errorHandler && o(r, s), i.call(t.context, r, n), t.release(t);
2989
+ t.value = null, t.callback = Y, t.errorHandler && o(r, s), i.call(t.context, r, n), t.release(t);
2985
2990
  };
2986
2991
  }
2987
2992
  function hs(t, e, r) {
@@ -3003,7 +3008,7 @@ function hs(t, e, r) {
3003
3008
  p(b);
3004
3009
  });
3005
3010
  });
3006
- return f.catch(W), f;
3011
+ return f.catch(Y), f;
3007
3012
  }
3008
3013
  function u(c) {
3009
3014
  var f = new Promise(function(p, v) {
@@ -3015,7 +3020,7 @@ function hs(t, e, r) {
3015
3020
  p(b);
3016
3021
  });
3017
3022
  });
3018
- return f.catch(W), f;
3023
+ return f.catch(Y), f;
3019
3024
  }
3020
3025
  function l() {
3021
3026
  if (i.idle())
@@ -3349,14 +3354,14 @@ var qt = function() {
3349
3354
  return qt;
3350
3355
  }
3351
3356
  }
3352
- }() : qt, $e = Cs(), Ws = ks(), j = Object.getPrototypeOf || (Ws ? function(t) {
3357
+ }() : qt, $e = Cs(), Ws = ks(), B = Object.getPrototypeOf || (Ws ? function(t) {
3353
3358
  return t.__proto__;
3354
- } : null), je = {}, Ys = typeof Uint8Array > "u" || !j ? I : j(Uint8Array), Pe = {
3359
+ } : null), je = {}, Ys = typeof Uint8Array > "u" || !B ? I : B(Uint8Array), Pe = {
3355
3360
  __proto__: null,
3356
3361
  "%AggregateError%": typeof AggregateError > "u" ? I : AggregateError,
3357
3362
  "%Array%": Array,
3358
3363
  "%ArrayBuffer%": typeof ArrayBuffer > "u" ? I : ArrayBuffer,
3359
- "%ArrayIteratorPrototype%": $e && j ? j([][Symbol.iterator]()) : I,
3364
+ "%ArrayIteratorPrototype%": $e && B ? B([][Symbol.iterator]()) : I,
3360
3365
  "%AsyncFromSyncIteratorPrototype%": I,
3361
3366
  "%AsyncFunction%": je,
3362
3367
  "%AsyncGenerator%": je,
@@ -3387,10 +3392,10 @@ var qt = function() {
3387
3392
  "%Int32Array%": typeof Int32Array > "u" ? I : Int32Array,
3388
3393
  "%isFinite%": isFinite,
3389
3394
  "%isNaN%": isNaN,
3390
- "%IteratorPrototype%": $e && j ? j(j([][Symbol.iterator]())) : I,
3395
+ "%IteratorPrototype%": $e && B ? B(B([][Symbol.iterator]())) : I,
3391
3396
  "%JSON%": typeof JSON == "object" ? JSON : I,
3392
3397
  "%Map%": typeof Map > "u" ? I : Map,
3393
- "%MapIteratorPrototype%": typeof Map > "u" || !$e || !j ? I : j((/* @__PURE__ */ new Map())[Symbol.iterator]()),
3398
+ "%MapIteratorPrototype%": typeof Map > "u" || !$e || !B ? I : B((/* @__PURE__ */ new Map())[Symbol.iterator]()),
3394
3399
  "%Math%": Math,
3395
3400
  "%Number%": Number,
3396
3401
  "%Object%": Object,
@@ -3403,10 +3408,10 @@ var qt = function() {
3403
3408
  "%Reflect%": typeof Reflect > "u" ? I : Reflect,
3404
3409
  "%RegExp%": RegExp,
3405
3410
  "%Set%": typeof Set > "u" ? I : Set,
3406
- "%SetIteratorPrototype%": typeof Set > "u" || !$e || !j ? I : j((/* @__PURE__ */ new Set())[Symbol.iterator]()),
3411
+ "%SetIteratorPrototype%": typeof Set > "u" || !$e || !B ? I : B((/* @__PURE__ */ new Set())[Symbol.iterator]()),
3407
3412
  "%SharedArrayBuffer%": typeof SharedArrayBuffer > "u" ? I : SharedArrayBuffer,
3408
3413
  "%String%": String,
3409
- "%StringIteratorPrototype%": $e && j ? j(""[Symbol.iterator]()) : I,
3414
+ "%StringIteratorPrototype%": $e && B ? B(""[Symbol.iterator]()) : I,
3410
3415
  "%Symbol%": $e ? Symbol : I,
3411
3416
  "%SyntaxError%": Ke,
3412
3417
  "%ThrowTypeError%": Hs,
@@ -3421,11 +3426,11 @@ var qt = function() {
3421
3426
  "%WeakRef%": typeof WeakRef > "u" ? I : WeakRef,
3422
3427
  "%WeakSet%": typeof WeakSet > "u" ? I : WeakSet
3423
3428
  };
3424
- if (j)
3429
+ if (B)
3425
3430
  try {
3426
3431
  null.error;
3427
3432
  } catch (t) {
3428
- var Js = j(j(t));
3433
+ var Js = B(B(t));
3429
3434
  Pe["%Error.prototype%"] = Js;
3430
3435
  }
3431
3436
  var Xs = function t(e) {
@@ -3441,7 +3446,7 @@ var Xs = function t(e) {
3441
3446
  n && (r = n.prototype);
3442
3447
  } else if (e === "%AsyncIteratorPrototype%") {
3443
3448
  var i = t("%AsyncGenerator%");
3444
- i && j && (r = j(i.prototype));
3449
+ i && B && (r = B(i.prototype));
3445
3450
  }
3446
3451
  return Pe[e] = r, r;
3447
3452
  }, nn = {
@@ -4900,7 +4905,7 @@ var fu = du;
4900
4905
  };
4901
4906
  })(mr, mr.exports);
4902
4907
  var fi = mr.exports;
4903
- const pu = jn, hu = Hn.EventEmitter, yu = Ft.inherits, B = fi("avvio"), { AVV_ERR_READY_TIMEOUT: mu } = di, Zt = Symbol.for("plugin-meta");
4908
+ const pu = jn, hu = Hn.EventEmitter, yu = Ft.inherits, U = fi("avvio"), { AVV_ERR_READY_TIMEOUT: mu } = di, Zt = Symbol.for("plugin-meta");
4904
4909
  function gu(t, e) {
4905
4910
  return t[Zt] && t[Zt].name ? t[Zt].name : typeof e < "u" && typeof e != "function" && e.name ? e.name : t.name ? t.name : t.toString().split(`
4906
4911
  `).slice(0, 2).map((r) => r.trim()).join(" -- ");
@@ -4920,7 +4925,7 @@ We.prototype.exec = function(t, e) {
4920
4925
  let n = !1;
4921
4926
  const i = this.name;
4922
4927
  if (this.parent._error && !this.isAfter) {
4923
- B("skipping loading of plugin as parent errored and it is not an after", i), A.nextTick(e);
4928
+ U("skipping loading of plugin as parent errored and it is not an after", i), A.nextTick(e);
4924
4929
  return;
4925
4930
  }
4926
4931
  if (this.isAfter)
@@ -4929,24 +4934,24 @@ We.prototype.exec = function(t, e) {
4929
4934
  try {
4930
4935
  this.server = this.parent.override(t, r, this.opts);
4931
4936
  } catch (u) {
4932
- return B("override errored", i), e(u);
4937
+ return U("override errored", i), e(u);
4933
4938
  }
4934
- this.opts = typeof this.opts == "function" ? this.opts(this.server) : this.opts, B("exec", i);
4939
+ this.opts = typeof this.opts == "function" ? this.opts(this.server) : this.opts, U("exec", i);
4935
4940
  let o;
4936
4941
  const s = (u) => {
4937
4942
  if (n) {
4938
- B("loading complete", i);
4943
+ U("loading complete", i);
4939
4944
  return;
4940
4945
  }
4941
- this._error = u, B(u ? "exec errored" : "exec completed", i), n = !0, o && clearTimeout(o), e(u);
4946
+ this._error = u, U(u ? "exec errored" : "exec completed", i), n = !0, o && clearTimeout(o), e(u);
4942
4947
  };
4943
- this.timeout > 0 && (B("setting up timeout", i, this.timeout), o = setTimeout(function() {
4944
- B("timed out", i), o = null;
4948
+ this.timeout > 0 && (U("setting up timeout", i, this.timeout), o = setTimeout(function() {
4949
+ U("timed out", i), o = null;
4945
4950
  const u = new mu(i);
4946
4951
  u.fn = r, s(u);
4947
4952
  }, this.timeout)), this.started = !0, this.emit("start", this.server ? this.server.name : null, this.name, Date.now());
4948
4953
  const a = r(this.server, this.opts, s);
4949
- a && typeof a.then == "function" && (B("exec: resolving promise", i), a.then(
4954
+ a && typeof a.then == "function" && (U("exec: resolving promise", i), a.then(
4950
4955
  () => A.nextTick(s),
4951
4956
  (u) => A.nextTick(s, u)
4952
4957
  ));
@@ -4956,36 +4961,36 @@ We.prototype.loadedSoFar = function() {
4956
4961
  return Promise.resolve();
4957
4962
  const t = () => {
4958
4963
  this.server.after((r, n) => {
4959
- this._error = r, this.q.pause(), r ? (B("rejecting promise", this.name, r), this._promise.reject(r)) : (B("resolving promise", this.name), this._promise.resolve()), this._promise = null, A.nextTick(n, r);
4964
+ this._error = r, this.q.pause(), r ? (U("rejecting promise", this.name, r), this._promise.reject(r)) : (U("resolving promise", this.name), this._promise.resolve()), this._promise = null, A.nextTick(n, r);
4960
4965
  }), this.q.resume();
4961
4966
  };
4962
4967
  let e;
4963
4968
  return this._promise ? e = Promise.resolve() : (this._promise = bu(), e = this._promise.promise, this.server ? t() : this.on("start", t)), e;
4964
4969
  };
4965
4970
  We.prototype.enqueue = function(t, e) {
4966
- B("enqueue", this.name, t.name), this.emit("enqueue", this.server ? this.server.name : null, this.name, Date.now()), this.q.push(t, e);
4971
+ U("enqueue", this.name, t.name), this.emit("enqueue", this.server ? this.server.name : null, this.name, Date.now()), this.q.push(t, e);
4967
4972
  };
4968
4973
  We.prototype.finish = function(t, e) {
4969
- B("finish", this.name, t);
4974
+ U("finish", this.name, t);
4970
4975
  const r = () => {
4971
- this.loaded || (B("loaded", this.name), this.emit("loaded", this.server ? this.server.name : null, this.name, Date.now()), this.loaded = !0, e(t));
4976
+ this.loaded || (U("loaded", this.name), this.emit("loaded", this.server ? this.server.name : null, this.name, Date.now()), this.loaded = !0, e(t));
4972
4977
  };
4973
4978
  if (t) {
4974
4979
  this._promise && (this._promise.reject(t), this._promise = null), r();
4975
4980
  return;
4976
4981
  }
4977
4982
  const n = () => {
4978
- if (B("check", this.name, this.q.length(), this.q.running(), this._promise), this.q.length() === 0 && this.q.running() === 0)
4983
+ if (U("check", this.name, this.q.length(), this.q.running(), this._promise), this.q.length() === 0 && this.q.running() === 0)
4979
4984
  if (this._promise) {
4980
4985
  const i = () => {
4981
- B("wrap"), queueMicrotask(n);
4986
+ U("wrap"), queueMicrotask(n);
4982
4987
  };
4983
4988
  this._promise.resolve(), this._promise.promise.then(i, i), this._promise = null;
4984
4989
  } else
4985
4990
  r();
4986
4991
  else
4987
- B("delayed", this.name), this.q.drain = () => {
4988
- B("drain", this.name), this.q.drain = Su, queueMicrotask(n);
4992
+ U("delayed", this.name), this.q.drain = () => {
4993
+ U("drain", this.name), this.q.drain = Su, queueMicrotask(n);
4989
4994
  };
4990
4995
  };
4991
4996
  queueMicrotask(n), this.q.resume();
@@ -5270,9 +5275,9 @@ const Ru = /* @__PURE__ */ cs(Du);
5270
5275
  }, window.cancelAnimationFrame = clearTimeout;
5271
5276
  }
5272
5277
  })();
5273
- function oc(t, e = !0, r = !0, n) {
5278
+ function oc(t, e = !0, r = !0, n = { friendsTab: "enabled" }) {
5274
5279
  const i = e ? "https://grpc-sdk.streamlayer.io:443" : "https://grpc-sdk.next.streamlayer.io:443", o = e ? "https://grpc.streamlayer.io:443" : "https://grpc.next.streamlayer.io:443", s = Ru(/* @__PURE__ */ Object.create({}), { autostart: !1 });
5275
- return s.use(jo), s.use(No, { onDeepLinkHandled: n?.onDeepLinkHandled }), s.use(Vo, { videoPlayerController: n?.videoPlayerController }), s.use(Mo, {
5280
+ return s.use(jo, { friendsTab: n.friendsTab }), s.use(No, { onDeepLinkHandled: n?.onDeepLinkHandled }), s.use(Vo, { videoPlayerController: n?.videoPlayerController }), s.use(Mo, {
5276
5281
  onContentActivate: n?.onContentActivate,
5277
5282
  withAd: n?.withAd,
5278
5283
  withAdNotification: n?.withAdNotification
package/lib/index.d.ts CHANGED
@@ -11,5 +11,6 @@ export declare function StreamLayer(sdkKey: string, production?: boolean, autoEn
11
11
  onContentActivate?: OnContentActivateCallback;
12
12
  withAdNotification?: boolean;
13
13
  withAd?: boolean;
14
+ friendsTab: 'enabled' | 'disabled' | 'activatedGame';
14
15
  }): avvio.Avvio<StreamLayerContext>;
15
16
  export {};
package/package.json CHANGED
@@ -24,18 +24,18 @@
24
24
  "devDependencies": {
25
25
  "avvio": "=8.2.1",
26
26
  "tslib": "^2.7.0",
27
- "@streamlayer/feature-gamification": "^1.9.1",
28
- "@streamlayer/sdk-web-analytics": "^1.4.7",
29
- "@streamlayer/sdk-web-api": "^1.6.7",
30
- "@streamlayer/sdk-web-core": "^1.6.6",
31
- "@streamlayer/sdk-web-features": "^1.0.28",
32
- "@streamlayer/sdk-web-interfaces": "^1.2.7",
33
- "@streamlayer/sdk-web-logger": "^1.0.28",
34
- "@streamlayer/sdk-web-notifications": "^1.2.7",
35
- "@streamlayer/sdk-web-storage": "^1.0.28",
36
- "@streamlayer/sdk-web-types": "^1.8.1"
27
+ "@streamlayer/feature-gamification": "^1.9.2",
28
+ "@streamlayer/sdk-web-analytics": "^1.4.8",
29
+ "@streamlayer/sdk-web-api": "^1.6.8",
30
+ "@streamlayer/sdk-web-core": "^1.7.0",
31
+ "@streamlayer/sdk-web-features": "^1.0.29",
32
+ "@streamlayer/sdk-web-interfaces": "^1.2.8",
33
+ "@streamlayer/sdk-web-logger": "^1.0.29",
34
+ "@streamlayer/sdk-web-notifications": "^1.2.8",
35
+ "@streamlayer/sdk-web-storage": "^1.0.29",
36
+ "@streamlayer/sdk-web-types": "^1.8.2"
37
37
  },
38
- "version": "1.5.6",
38
+ "version": "1.6.0",
39
39
  "type": "module",
40
40
  "main": "./src/index.js",
41
41
  "typings": "./src/index.d.ts"