@talkjs/core 1.8.1 → 1.8.2

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.
@@ -378,9 +378,13 @@ class C {
378
378
  }
379
379
  renewSession() {
380
380
  return __async(this, null, function* () {
381
- const e2 = yield this.authProvider.getToken().catch(() => {
382
- });
383
- if (!e2) return;
381
+ let e2;
382
+ try {
383
+ const t3 = this.authProvider.getCachedToken();
384
+ e2 = t3 || (yield this.authProvider.getToken());
385
+ } catch (e3) {
386
+ return;
387
+ }
384
388
  const t2 = yield this.connection.call({ method: "POST", path: ["session", "renew"], data: { token: e2 }, headers: {} });
385
389
  if (!t2.ok && "client" === t2.where) return;
386
390
  const s2 = t2.value;
@@ -399,7 +403,7 @@ class C {
399
403
  });
400
404
  }
401
405
  }
402
- class I {
406
+ class T {
403
407
  constructor(e2, t2, s2) {
404
408
  this.handlers = s2, this.stateMachine = new i("StopStartConnection", ["STOPPED", "WAITING_FOR_WS", "READY", "TERMINATED"], { unexpectedDisconnect: { from: ["READY"], to: "WAITING_FOR_WS", afterTransition: () => {
405
409
  this.inactivityTimer.stop(), this.handlers.onNotReady();
@@ -452,7 +456,7 @@ class I {
452
456
  logTrace(e2, t2, s2) {
453
457
  }
454
458
  }
455
- class T {
459
+ class I {
456
460
  constructor(e2, t2, s2) {
457
461
  this.handlers = s2, this.stateMachine = new i("QueuedConnection", ["NOT_READY", "PROCESSING_QUEUE", "READY", "TERMINATED"], { processQueue: { from: ["NOT_READY"], to: "PROCESSING_QUEUE", afterTransition: () => {
458
462
  this.sendQueuedCalls();
@@ -467,7 +471,7 @@ class T {
467
471
  e3 == null ? void 0 : e3.clientErr("SESSION_DESTROYED");
468
472
  }
469
473
  this.connection.destroy();
470
- } } }), this.subscribeQueue = {}, this.callQueue = [], this.connection = new I(e2, t2, { onUpstreamRestarting: () => {
474
+ } } }), this.subscribeQueue = {}, this.callQueue = [], this.connection = new T(e2, t2, { onUpstreamRestarting: () => {
471
475
  this.handlers.onUpstreamRestarting();
472
476
  }, onReady: () => {
473
477
  this.stateMachine.transition("processQueue");
@@ -669,7 +673,7 @@ class j extends O {
669
673
  }
670
674
  class $ {
671
675
  constructor(e2, t2, s2) {
672
- this.pendingBatch = null, this.connection = new T(e2, t2, s2);
676
+ this.pendingBatch = null, this.connection = new I(e2, t2, s2);
673
677
  }
674
678
  sync() {
675
679
  return __async(this, null, function* () {
@@ -1693,13 +1697,13 @@ function Ce(e2, t2, s2) {
1693
1697
  return n2.ok ? o(n2.value.data) : "server" === n2.where && 404 === n2.value.status || "server" === n2.where && 403 === n2.value.status && "NOT_A_PARTICIPANT" === n2.value.errorCode ? o(null) : n2;
1694
1698
  });
1695
1699
  }
1696
- class Ie extends Y {
1700
+ class Te extends Y {
1697
1701
  constructor(e2, t2, s2, n2, a2, r2) {
1698
1702
  super(e2, a2, r2), this.getParticipantDataStore = t2, this.conversationId = s2, this.realtimeClient = n2, this.handlers = r2, this.unsubscribeDebounceMs = 3e4, this.pendingLoadMore = void 0;
1699
1703
  }
1700
1704
  fetchInitial(e2) {
1701
1705
  return __async(this, null, function* () {
1702
- const t2 = yield Te({ realtimeClient: this.realtimeClient, conversationId: this.conversationId, count: 10 });
1706
+ const t2 = yield Ie({ realtimeClient: this.realtimeClient, conversationId: this.conversationId, count: 10 });
1703
1707
  return t2.ok ? null === t2.value.participants ? o({ lastChanged: e2, stores: null, inWindow: null, windowEnd: null }) : xe({ seq: e2, participants: t2.value.participants, cursor: t2.value.nextCursor, getParticipantDataStore: this.getParticipantDataStore }) : t2;
1704
1708
  });
1705
1709
  }
@@ -1742,7 +1746,7 @@ class Ie extends Y {
1742
1746
  }
1743
1747
  }
1744
1748
  if (null === s2.value.windowEnd) return t2.resolve(), void (this.pendingLoadMore = void 0);
1745
- const n2 = s2.value.windowEnd.cursor, a2 = yield Te({ count: e2, cursor: n2, conversationId: this.conversationId, realtimeClient: this.realtimeClient });
1749
+ const n2 = s2.value.windowEnd.cursor, a2 = yield Ie({ count: e2, cursor: n2, conversationId: this.conversationId, realtimeClient: this.realtimeClient });
1746
1750
  t2.resolve(), this.pendingLoadMore = void 0, yield this.handlers.onLoadedMore({ type: "virtual.participants.loadedmore", conversationId: this.conversationId, data: a2 });
1747
1751
  });
1748
1752
  }
@@ -1774,7 +1778,7 @@ class Ie extends Y {
1774
1778
  this.mutate(e2, (t3) => null === t3.value.stores ? t3 : (this.teardownNested(t3.value), o({ lastChanged: e2, stores: null, inWindow: null, windowEnd: null })));
1775
1779
  }
1776
1780
  }
1777
- function Te(_0) {
1781
+ function Ie(_0) {
1778
1782
  return __async(this, arguments, function* ({ cursor: e2, realtimeClient: t2, conversationId: s2, count: n2 }) {
1779
1783
  const a2 = { limit: n2, cursor: e2 }, r2 = yield t2.call({ method: "GET", path: ["me", "conversations", s2, "participants"], data: a2, flags: { bypassCache: true } });
1780
1784
  if (r2.ok) {
@@ -2231,7 +2235,7 @@ class Oe {
2231
2235
  if (e(t2, ["users", "*"])) return new ue(this.virtualSeq, t2[1], this.realtimeClient, this.emitMutex, { onTeardown: s2 });
2232
2236
  if (e(t2, ["me", "conversations", "*"])) return new be(this.virtualSeq, this.subscribeConvData(t2[2]), this.realtimeClient, this.emitMutex, { onTeardown: s2 });
2233
2237
  if (e(t2, ["me", "conversations", "*", "messages"])) return new fe(this.virtualSeq, t2[2], this.realtimeClient, this.emitMutex, { onTeardown: s2, onLoadedMore: (e2) => this.onVirtualPublish(e2) });
2234
- if (e(t2, ["me", "conversations", "*", "participants"])) return new Ie(this.virtualSeq, (e2) => this.subscribeParticipantData(t2[2], e2), t2[2], this.realtimeClient, this.emitMutex, { onTeardown: s2, onLoadedMore: (e2) => this.onVirtualPublish(e2) });
2238
+ if (e(t2, ["me", "conversations", "*", "participants"])) return new Te(this.virtualSeq, (e2) => this.subscribeParticipantData(t2[2], e2), t2[2], this.realtimeClient, this.emitMutex, { onTeardown: s2, onLoadedMore: (e2) => this.onVirtualPublish(e2) });
2235
2239
  if (e(t2, ["me", "conversations", "*", "participants", "*"])) return new Re(this.virtualSeq, this.subscribeParticipantData(t2[2], t2[4]), this.realtimeClient, this.emitMutex, { onTeardown: s2 });
2236
2240
  if (e(t2, ["me", "conversations", "*", "typing"])) return new ke(this.virtualSeq, t2[2], this.realtimeClient, this.emitMutex, { onTeardown: s2 });
2237
2241
  if (e(t2, ["me", "conversations"])) return new Ee(this.virtualSeq, (e2) => this.subscribeConvData(e2), this.realtimeClient, this.emitMutex, { onTeardown: s2, onLoadedMore: (e2) => this.onVirtualPublish(e2) });
@@ -2602,11 +2606,11 @@ var St = ht;
2602
2606
  function Ct(e2) {
2603
2607
  return 95 === e2 || St(e2);
2604
2608
  }
2605
- function It(e2) {
2609
+ function Tt(e2) {
2606
2610
  return ht(e2) || ((t2 = e2) < 91 ? t2 < 47 ? t2 >= 35 && t2 <= 43 || 45 == t2 : t2 < 61 ? 47 == t2 : 61 == t2 || 64 == t2 : t2 < 95 ? 91 == t2 || 93 == t2 : t2 < 123 ? 95 == t2 : t2 >= 123 && t2 <= 126 || 10003 == t2) || ut(e2);
2607
2611
  var t2;
2608
2612
  }
2609
- function Tt(e2) {
2613
+ function It(e2) {
2610
2614
  return 47 === e2 || 63 === e2 || 35 === e2;
2611
2615
  }
2612
2616
  function xt(e2) {
@@ -2810,7 +2814,7 @@ function Zt(e2, t2, s2) {
2810
2814
  47 === s2 ? t2.state = 3 : 46 === s2 ? e2.removeMachine(t2) : St(s2) ? (t2.state = 5, yt(s2) && e2.addMachine(Ls(n2, 0))) : e2.removeMachine(t2);
2811
2815
  }
2812
2816
  function Xt(e2, t2, s2) {
2813
- 47 === s2 ? t2.state = 4 : It(s2) ? (t2.state = 10, t2.acceptStateReached = true) : Us(e2, t2);
2817
+ 47 === s2 ? t2.state = 4 : Tt(s2) ? (t2.state = 10, t2.acceptStateReached = true) : Us(e2, t2);
2814
2818
  }
2815
2819
  function es(e2, t2, s2, n2) {
2816
2820
  47 === n2 ? (t2.state = 10, t2.acceptStateReached = true) : St(n2) ? (t2.state = 5, t2.acceptStateReached = true) : e2.removeMachine(t2);
@@ -2822,7 +2826,7 @@ function ss(e2, t2, s2) {
2822
2826
  St(s2) ? t2.state = 5 : e2.removeMachine(t2);
2823
2827
  }
2824
2828
  function ns(e2, t2, s2) {
2825
- 46 === s2 ? t2.state = 7 : 45 === s2 ? t2.state = 6 : 58 === s2 ? t2.state = 8 : Tt(s2) ? t2.state = 10 : Ct(s2) || Us(e2, t2);
2829
+ 46 === s2 ? t2.state = 7 : 45 === s2 ? t2.state = 6 : 58 === s2 ? t2.state = 8 : It(s2) ? t2.state = 10 : Ct(s2) || Us(e2, t2);
2826
2830
  }
2827
2831
  function as(e2, t2, s2, n2) {
2828
2832
  45 === n2 || (46 === n2 ? Us(e2, t2) : St(n2) ? t2.state = 5 : Us(e2, t2));
@@ -2831,7 +2835,7 @@ function rs(e2, t2, s2, n2) {
2831
2835
  46 === n2 ? Us(e2, t2) : St(n2) ? (t2.state = 5, t2.acceptStateReached = true) : Us(e2, t2);
2832
2836
  }
2833
2837
  function is(e2, t2, s2) {
2834
- 46 === s2 ? t2.state = 14 : 58 === s2 ? t2.state = 8 : ot(s2) || (Tt(s2) ? t2.state = 10 : ht(s2) ? e2.removeMachine(t2) : Us(e2, t2));
2838
+ 46 === s2 ? t2.state = 14 : 58 === s2 ? t2.state = 8 : ot(s2) || (It(s2) ? t2.state = 10 : ht(s2) ? e2.removeMachine(t2) : Us(e2, t2));
2835
2839
  }
2836
2840
  function os(e2, t2, s2) {
2837
2841
  ot(s2) ? (t2.octetsEncountered++, 4 === t2.octetsEncountered && (t2.acceptStateReached = true), t2.state = 13) : Us(e2, t2);
@@ -2840,10 +2844,10 @@ function cs(e2, t2, s2) {
2840
2844
  ot(s2) ? t2.state = 9 : Us(e2, t2);
2841
2845
  }
2842
2846
  function ls(e2, t2, s2) {
2843
- ot(s2) || (Tt(s2) ? t2.state = 10 : Us(e2, t2));
2847
+ ot(s2) || (It(s2) ? t2.state = 10 : Us(e2, t2));
2844
2848
  }
2845
2849
  function hs(e2, t2, s2) {
2846
- It(s2) || Us(e2, t2);
2850
+ Tt(s2) || Us(e2, t2);
2847
2851
  }
2848
2852
  function us(e2, t2, s2, n2) {
2849
2853
  "a" === s2.toLowerCase() ? t2.state = 16 : bs(e2, t2, n2);
@@ -2884,10 +2888,10 @@ function Ss(e2, t2, s2) {
2884
2888
  function Cs(e2, t2, s2) {
2885
2889
  46 === s2 || 45 === s2 ? Us(e2, t2) : St(s2) ? (t2.state = 25, t2.acceptStateReached = true) : Us(e2, t2);
2886
2890
  }
2887
- function Is(e2, t2, s2) {
2891
+ function Ts(e2, t2, s2) {
2888
2892
  jt(s2) ? (t2.state = 29, t2.acceptStateReached = true) : e2.removeMachine(t2);
2889
2893
  }
2890
- function Ts(e2, t2, s2) {
2894
+ function Is(e2, t2, s2) {
2891
2895
  jt(s2) || Us(e2, t2);
2892
2896
  }
2893
2897
  function xs(e2, t2, s2) {
@@ -3370,10 +3374,10 @@ var yn = (function() {
3370
3374
  Cs(s3, i2, a3);
3371
3375
  break;
3372
3376
  case 28:
3373
- Is(s3, i2, a3);
3377
+ Ts(s3, i2, a3);
3374
3378
  break;
3375
3379
  case 29:
3376
- Ts(s3, i2, a3);
3380
+ Is(s3, i2, a3);
3377
3381
  break;
3378
3382
  case 30:
3379
3383
  xs(s3, i2, a3);
@@ -3451,9 +3455,9 @@ function Sn(e2, t2 = e2) {
3451
3455
  }
3452
3456
  const Cn = We(/<!!mention:([^>\s]*?)\|(.*?)>/gm, ([e2, t2, s2]) => /* @__PURE__ */ (function(e3, t3) {
3453
3457
  return { type: "mention", id: e3, text: t3 };
3454
- })(decodeURIComponent(t2), s2)), In = We(/<!!customemoji:(.*?)>/gm, ([e2, t2]) => /* @__PURE__ */ (function(e3) {
3458
+ })(decodeURIComponent(t2), s2)), Tn = We(/<!!customemoji:(.*?)>/gm, ([e2, t2]) => /* @__PURE__ */ (function(e3) {
3455
3459
  return { type: "customemoji", text: e3 };
3456
- })(t2)), Tn = We(/<((?:https?|mailto):.*?)\|(.*?)>/gi, ([e2, t2, s2]) => /* @__PURE__ */ (function(e3, t3 = []) {
3460
+ })(t2)), In = We(/<((?:https?|mailto):.*?)\|(.*?)>/gi, ([e2, t2, s2]) => /* @__PURE__ */ (function(e3, t3 = []) {
3457
3461
  return { type: "link", url: e3, children: t3 };
3458
3462
  })(t2, [s2])), xn = We(/<actionlink:([^|]+)[|]([^>]*)>/gi, ([e2, t2, s2]) => {
3459
3463
  const { action: n2, params: a2 } = Mn(t2);
@@ -3484,7 +3488,7 @@ const _n = We(/(?:^|\n)(?:\s*[-*+]\s+[^\n]+(?:\n|$))+/g, ([e2]) => /* @__PURE__
3484
3488
  n2.push(o2), s2 = i2 + r2.length;
3485
3489
  }
3486
3490
  return s2 < e2.length && n2.push(e2.substring(s2)), n2;
3487
- }, Dn = (e2) => Tn(e2).flatMap((e3) => "string" == typeof e3 ? Rn(e3) : ["<", ...Rn(e3.url), ...Rn("|" + e3.children[0] + ">")]), Rn = (e2) => {
3491
+ }, Dn = (e2) => In(e2).flatMap((e3) => "string" == typeof e3 ? Rn(e3) : ["<", ...Rn(e3.url), ...Rn("|" + e3.children[0] + ">")]), Rn = (e2) => {
3488
3492
  const t2 = yn.parse(e2, { urls: true, email: true, phone: false, hashtag: false, mention: false }), s2 = [];
3489
3493
  let n2 = 0;
3490
3494
  for (const a2 of t2) {
@@ -3497,7 +3501,7 @@ const _n = We(/(?:^|\n)(?:\s*[-*+]\s+[^\n]+(?:\n|$))+/g, ([e2]) => /* @__PURE__
3497
3501
  function Pn(e2 = { except: [] }) {
3498
3502
  var _a2;
3499
3503
  const t2 = { multilineSteps: [], singlelineSteps: [] }, s2 = (_a2 = e2.except) != null ? _a2 : On.filter((t3) => !e2.only.includes(t3));
3500
- return s2.includes("BulletPoint") || t2.multilineSteps.push(_n, An), s2.includes("Mention") || t2.singlelineSteps.push(Cn), s2.includes("CustomEmoji") || t2.singlelineSteps.push(In), s2.includes("Codespan") || t2.multilineSteps.push(We(/```([^]+?)```/g, ([e3, t3]) => ({ type: "codespan", text: t3.replace(/<!!mention:.*?\|([^>]*)>/gim, "@$1").replace(/<!!customemoji:(.*?)>/gim, "$1") }))), s2.includes("FormattedLink") || t2.singlelineSteps.push(Tn), s2.includes("Actions") || (t2.singlelineSteps.push(xn), t2.singlelineSteps.push(En)), s2.includes("Wikitext") || t2.singlelineSteps.push(Fe), s2.includes("Autolink") || t2.singlelineSteps.push(Dn, Nn), t2;
3504
+ return s2.includes("BulletPoint") || t2.multilineSteps.push(_n, An), s2.includes("Mention") || t2.singlelineSteps.push(Cn), s2.includes("CustomEmoji") || t2.singlelineSteps.push(Tn), s2.includes("Codespan") || t2.multilineSteps.push(We(/```([^]+?)```/g, ([e3, t3]) => ({ type: "codespan", text: t3.replace(/<!!mention:.*?\|([^>]*)>/gim, "@$1").replace(/<!!customemoji:(.*?)>/gim, "$1") }))), s2.includes("FormattedLink") || t2.singlelineSteps.push(In), s2.includes("Actions") || (t2.singlelineSteps.push(xn), t2.singlelineSteps.push(En)), s2.includes("Wikitext") || t2.singlelineSteps.push(Fe), s2.includes("Autolink") || t2.singlelineSteps.push(Dn, Nn), t2;
3501
3505
  }
3502
3506
  const jn = (function(e2) {
3503
3507
  const t2 = RegExp(`[^${e2}]+${e2}?|${e2}`, "g");
@@ -3559,7 +3563,8 @@ function Fn(e2, t2) {
3559
3563
  }
3560
3564
  class Hn {
3561
3565
  constructor(e2, t2, s2, n2, a2) {
3562
- this._onSnapshot = t2, this._pageSize = s2, this._maxPageSize = n2, this._sort = a2, this._windowStatus = void 0, this._loadMoreDeferred = void 0, this._connectedDefer = r(), this._underlyingSubscription = e2(this.handleSnapshot.bind(this)), this._underlyingSubscription.connected.catch((e3) => this._connectedDefer.reject(e3));
3566
+ this._onSnapshot = t2, this._pageSize = s2, this._maxPageSize = n2, this._sort = a2, this._windowStatus = void 0, this._loadMoreDeferred = void 0, this._connectedDefer = r(), this._connectedDefer.promise.catch(() => {
3567
+ }), this._underlyingSubscription = e2(this.handleSnapshot.bind(this)), this._underlyingSubscription.connected.catch((e3) => this._connectedDefer.reject(e3));
3563
3568
  }
3564
3569
  updateWindowStatusAndGetState(e2, t2) {
3565
3570
  var _a2, _b2;
@@ -4058,7 +4063,7 @@ class la {
4058
4063
  function ha({ method: e2, url: t2, data: s2, options: n2, attempts: r2, shouldRetry: i2, authProvider: o2, errorTracker: c2, abortSignal: l2 }) {
4059
4064
  var _a2;
4060
4065
  (!r2 || r2 <= 0) && (r2 = 1);
4061
- const h2 = { "x-talkjs-client-build": "jssdk-dev", "x-talkjs-client-date": "2026-02-03T10:48:11.175Z" };
4066
+ const h2 = { "x-talkjs-client-build": "jssdk-dev", "x-talkjs-client-date": "2026-02-17T14:50:53.383Z" };
4062
4067
  s2 instanceof FormData || (h2["Content-Type"] = (_a2 = n2 == null ? void 0 : n2.contentType) != null ? _a2 : "application/json");
4063
4068
  return a(r2, () => __async(null, null, function* () {
4064
4069
  if (o2) {
@@ -4087,7 +4092,7 @@ class ua {
4087
4092
  __privateAdd(this, _e2);
4088
4093
  __privateAdd(this, _t2);
4089
4094
  var _a2, _b2, _c, _d;
4090
- this._timeCreated = Date.now(), __privateSet(this, _e2, (_b2 = (_a2 = globalThis.document) == null ? void 0 : _a2.referrer) != null ? _b2 : ""), __privateSet(this, _t2, ((_d = (_c = globalThis.location) == null ? void 0 : _c.href) != null ? _d : globalThis.HermesInternal) ? "React Native Hermes" : ""), this._trackJSData = { customer: { application: "", correlationId: "", sessionId: "", token: "", userId: "", version: "dev-2026-02-03T10:48:11.175Z" }, entry: "direct", environment: { age: Date.now() - this._timeCreated, dependencies: {}, originalUrl: __privateGet(this, _t2), referrer: __privateGet(this, _e2), userAgent: window.navigator.userAgent }, metadata: [], nav: [], network: [], url: __privateGet(this, _t2), stack: "", timestamp: (/* @__PURE__ */ new Date()).toISOString(), version: "dev-2026-02-03T10:48:11.175Z", throttled: 0 }, this._url = `https://capture.trackjs.com/capture?token=${e2}`, this._trackJSData.customer.token = e2;
4095
+ this._timeCreated = Date.now(), __privateSet(this, _e2, (_b2 = (_a2 = globalThis.document) == null ? void 0 : _a2.referrer) != null ? _b2 : ""), __privateSet(this, _t2, ((_d = (_c = globalThis.location) == null ? void 0 : _c.href) != null ? _d : globalThis.HermesInternal) ? "React Native Hermes" : ""), this._trackJSData = { customer: { application: "", correlationId: "", sessionId: "", token: "", userId: "", version: "dev-2026-02-17T14:50:53.383Z" }, entry: "direct", environment: { age: Date.now() - this._timeCreated, dependencies: {}, originalUrl: __privateGet(this, _t2), referrer: __privateGet(this, _e2), userAgent: window.navigator.userAgent }, metadata: [], nav: [], network: [], url: __privateGet(this, _t2), stack: "", timestamp: (/* @__PURE__ */ new Date()).toISOString(), version: "dev-2026-02-17T14:50:53.383Z", throttled: 0 }, this._url = `https://capture.trackjs.com/capture?token=${e2}`, this._trackJSData.customer.token = e2;
4091
4096
  }
4092
4097
  setData({ appId: e2, meId: t2, sessionId: s2 }) {
4093
4098
  this._trackJSData.customer.userId = e2, this._trackJSData.customer.sessionId = `${e2}/${t2}`, this._trackJSData.customer.correlationId = s2;
@@ -4165,6 +4170,9 @@ class ma {
4165
4170
  return this.pendingToken = e2, this.handlers.onNeedToken(), e2.promise;
4166
4171
  });
4167
4172
  }
4173
+ getCachedTokenResult() {
4174
+ return this.tokenResult ? this.tokenResult : void 0;
4175
+ }
4168
4176
  setTokenResult(e2) {
4169
4177
  this.pendingToken && (this.pendingToken.resolve(e2), this.pendingToken = null), this.tokenResult = e2, this.handlers.onChange(e2);
4170
4178
  }
@@ -4198,11 +4206,13 @@ class fa {
4198
4206
  }
4199
4207
  getToken() {
4200
4208
  return __async(this, null, function* () {
4201
- const e2 = yield this.inner.getTokenResult();
4202
- if (e2.ok) return e2.value;
4203
- throw e2.value;
4209
+ return va(yield this.inner.getTokenResult());
4204
4210
  });
4205
4211
  }
4212
+ getCachedToken() {
4213
+ const e2 = this.inner.getCachedTokenResult();
4214
+ if (void 0 !== e2) return va(e2);
4215
+ }
4206
4216
  checkCanSetAuth() {
4207
4217
  if (this._calledBokens) throw new Error("[TalkJS] Cannot switch to JWT authentication once connected to TalkJS servers. To use JWTs, call `setToken` or set `onNeedToken` before triggering any requests or mounting any components. We recommend setting up authentication in your app's entry point (App.jsx, main.js, or similar) so it runs first.");
4208
4218
  }
@@ -4331,14 +4341,18 @@ function ga(e2) {
4331
4341
  throw `Could not base64-decode and JSON-parse token section: ${e2}. Check that you base-64 encoded the section correctly.`;
4332
4342
  }
4333
4343
  }
4334
- const va = new class {
4344
+ function va(e2) {
4345
+ if (e2.ok) return e2.value;
4346
+ throw e2.value;
4347
+ }
4348
+ const ba = new class {
4335
4349
  constructor() {
4336
4350
  this.registry = {};
4337
4351
  }
4338
4352
  getOrCreate(e2) {
4339
4353
  const t2 = this.key(e2), s2 = this.registry[t2];
4340
4354
  if (s2) return s2;
4341
- const n2 = new wa(e2);
4355
+ const n2 = new ya(e2);
4342
4356
  return this.registry[t2] = n2, n2;
4343
4357
  }
4344
4358
  deregister(e2, t2) {
@@ -4349,11 +4363,11 @@ const va = new class {
4349
4363
  return `${e2}:${t2}`;
4350
4364
  }
4351
4365
  }();
4352
- function ba(e2) {
4366
+ function wa(e2) {
4353
4367
  if (!e2) throw new Error("[TalkJS] Must provide an options object to `getTalkSession`");
4354
- return e2.forceCreateNew ? new wa(e2) : va.getOrCreate(e2);
4368
+ return e2.forceCreateNew ? new ya(e2) : ba.getOrCreate(e2);
4355
4369
  }
4356
- class wa {
4370
+ class ya {
4357
4371
  constructor(e2) {
4358
4372
  this._onNeedToken = void 0, (function(e3) {
4359
4373
  function t3(e4, t4) {
@@ -4372,7 +4386,7 @@ class wa {
4372
4386
  }
4373
4387
  }));
4374
4388
  const o2 = Math.random().toString().split(".")[1];
4375
- this._realtimeClient = new ia(this._apiUrls.getRealtimeWsUrl(t2, s2, "1.8.0", o2, e2.clientBuild), s2, this._authProvider), this.currentUser = this.user(s2), this._terminationReason = r(), this._terminationReason.promise.then((e3) => {
4389
+ this._realtimeClient = new ia(this._apiUrls.getRealtimeWsUrl(t2, s2, "1.8.1", o2, e2.clientBuild), s2, this._authProvider), this.currentUser = this.user(s2), this._terminationReason = r(), this._terminationReason.promise.then((e3) => {
4376
4390
  console.error(`[TalkJS] ${e3}`);
4377
4391
  }), (function(e3, t3) {
4378
4392
  return __async(this, null, function* () {
@@ -4428,14 +4442,14 @@ class wa {
4428
4442
  }
4429
4443
  searchMessages(e2) {
4430
4444
  let t2;
4431
- return { setQuery: (s2) => t2 && t2.searchString === s2 ? t2.currentState : (t2 && t2.cancel(), s2 && "" !== s2 ? (t2 = new ka(e2, s2, `${this._apiUrls.restApiHttpUrl}/${this._appId}/me/messages/search`, (e3) => __async(this, null, function* () {
4445
+ return { setQuery: (s2) => t2 && t2.searchString === s2 ? t2.currentState : (t2 && t2.cancel(), s2 && "" !== s2 ? (t2 = new Sa(e2, s2, `${this._apiUrls.restApiHttpUrl}/${this._appId}/me/messages/search`, (e3) => __async(this, null, function* () {
4432
4446
  const [t3, s3] = yield Promise.all([this.conversation(e3.conversationId).get(), this._realtimeClient.hydrateMessageData(e3, e3.conversationId)]);
4433
4447
  return null === t3 ? c("Message belongs to nonexistent conversation") : s3.ok ? o({ conversation: t3, message: s3.value }) : s3;
4434
4448
  }), this._authProvider), t2.loadMore(3)) : (t2 = void 0, e2 == null ? void 0 : e2([], "loadedAll"), Promise.resolve({ results: [], loadedAll: true }))), loadMore: (e3) => t2 ? t2.loadMore(e3 != null ? e3 : 10) : Promise.resolve({ results: [], loadedAll: true }) };
4435
4449
  }
4436
4450
  searchConversations(e2) {
4437
4451
  let t2;
4438
- return { setQuery: (s2) => t2 && t2.searchString === s2 ? t2.currentState : (t2 && t2.cancel(), s2 && "" !== s2 ? (t2 = new ka(e2, s2, `${this._apiUrls.restApiHttpUrl}/${this._appId}/me/conversations/search`, (e3) => __async(this, null, function* () {
4452
+ return { setQuery: (s2) => t2 && t2.searchString === s2 ? t2.currentState : (t2 && t2.cancel(), s2 && "" !== s2 ? (t2 = new Sa(e2, s2, `${this._apiUrls.restApiHttpUrl}/${this._appId}/me/conversations/search`, (e3) => __async(this, null, function* () {
4439
4453
  const t3 = yield this._realtimeClient.hydrateConvData(e3);
4440
4454
  if (!t3.ok) return t3;
4441
4455
  const s3 = t3.value;
@@ -4443,28 +4457,28 @@ class wa {
4443
4457
  }), this._authProvider), t2.loadMore(3)) : (t2 = void 0, e2 == null ? void 0 : e2([], "loadedAll"), Promise.resolve({ results: [], loadedAll: true }))), loadMore: (e3) => t2 ? t2.loadMore(e3 != null ? e3 : 10) : Promise.resolve({ results: [], loadedAll: true }) };
4444
4458
  }
4445
4459
  terminate(e2) {
4446
- va.deregister(this._appId, this.currentUser.id), this._terminationReason.resolve(e2), this._realtimeClient.destroy();
4460
+ ba.deregister(this._appId, this.currentUser.id), this._terminationReason.resolve(e2), this._realtimeClient.destroy();
4447
4461
  }
4448
4462
  _isConnected() {
4449
4463
  return this._realtimeClient.isConnected();
4450
4464
  }
4451
4465
  uploadFile(e2, t2) {
4452
- return ya(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, this._realtimeClient, e2, t2);
4466
+ return ka(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, this._realtimeClient, e2, t2);
4453
4467
  }
4454
4468
  uploadImage(e2, t2) {
4455
- return ya(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, this._realtimeClient, e2, __spreadValues({ subtype: "image" }, t2));
4469
+ return ka(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, this._realtimeClient, e2, __spreadValues({ subtype: "image" }, t2));
4456
4470
  }
4457
4471
  uploadVideo(e2, t2) {
4458
- return ya(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, this._realtimeClient, e2, __spreadValues({ subtype: "video" }, t2));
4472
+ return ka(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, this._realtimeClient, e2, __spreadValues({ subtype: "video" }, t2));
4459
4473
  }
4460
4474
  uploadAudio(e2, t2) {
4461
- return ya(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, this._realtimeClient, e2, __spreadValues({ subtype: "audio" }, t2));
4475
+ return ka(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, this._realtimeClient, e2, __spreadValues({ subtype: "audio" }, t2));
4462
4476
  }
4463
4477
  uploadVoice(e2, t2) {
4464
- return ya(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, this._realtimeClient, e2, __spreadValues({ subtype: "voice" }, t2));
4478
+ return ka(`${this._apiUrls.restApiHttpUrl}/${this._appId}/files`, this._authProvider, this._realtimeClient, e2, __spreadValues({ subtype: "voice" }, t2));
4465
4479
  }
4466
4480
  }
4467
- function ya(_0, _1, _2, _3, _4) {
4481
+ function ka(_0, _1, _2, _3, _4) {
4468
4482
  return __async(this, arguments, function* (e2, t2, s2, n2, { subtype: a2, filename: r2, width: i2, height: o2, duration: c2 }) {
4469
4483
  d("Upload file", yield s2.call({ method: "POST", path: ["files", "validate"], data: { filename: r2, filesize: n2.size } }));
4470
4484
  const l2 = new FormData();
@@ -4477,7 +4491,7 @@ function ya(_0, _1, _2, _3, _4) {
4477
4491
  }));
4478
4492
  });
4479
4493
  }
4480
- class ka {
4494
+ class Sa {
4481
4495
  constructor(e2, t2, s2, n2, a2) {
4482
4496
  this.onResults = e2, this.searchString = t2, this.baseUrl = s2, this.hydrateData = n2, this.authProvider = a2, this.error = void 0, this.lastCompletedQueryState = { results: [], loadedAll: false }, this.currentCursor = void 0, this.cancelQuery = () => {
4483
4497
  }, e2 == null ? void 0 : e2([], "searching");
@@ -4565,7 +4579,7 @@ class ka {
4565
4579
  }
4566
4580
  }
4567
4581
  export {
4568
- ba as getTalkSession,
4582
+ wa as getTalkSession,
4569
4583
  f as registerPolyfills
4570
4584
  };
4571
4585
  //# sourceMappingURL=talkSession.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@talkjs/core",
3
- "version": "1.8.1",
3
+ "version": "1.8.2",
4
4
  "description": "Lets you connect to your TalkJS chat as a user and read, subscribe to, and update your chat data.",
5
5
  "bugs": {
6
6
  "url": "https://talkjs.com/?chat"