@aikaara/chat-sdk 1.4.9 → 1.4.10

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,4 +1,4 @@
1
- import { H as p } from "./MountTenant-wGTIJ3mp.mjs";
1
+ import { H as p } from "./MountTenant-BKF848dH.mjs";
2
2
  class c extends HTMLElement {
3
3
  shadow;
4
4
  payload = null;
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./MountTenant-DRfdLtS5.cjs");class l extends HTMLElement{shadow;payload=null;constructor(){super(),this.shadow=this.attachShadow({mode:"open"})}connectedCallback(){this.render()}setPayload(e){this.payload=e,this.render()}render(){const e=this.payload;this.shadow.innerHTML=`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./MountTenant-NxL-nR2d.cjs");class l extends HTMLElement{shadow;payload=null;constructor(){super(),this.shadow=this.attachShadow({mode:"open"})}connectedCallback(){this.render()}setPayload(e){this.payload=e,this.render()}render(){const e=this.payload;this.shadow.innerHTML=`
2
2
  <style>
3
3
  :host { display: block; margin-top: 8px; }
4
4
  button {
@@ -176,14 +176,15 @@ class zl extends qs {
176
176
  this.client = new bo(t);
177
177
  }
178
178
  async connect() {
179
+ const e = this.reconnectAttempt > 0;
179
180
  this.setState("connecting");
180
181
  try {
181
- await this.client.connect(), this.setState("connected"), this.reconnectAttempt = 0;
182
- } catch (e) {
182
+ await this.client.connect(), this.setState("connected"), this.reconnectAttempt = 0, e && this.emit("reconnected", void 0);
183
+ } catch (t) {
183
184
  if (this.setState("disconnected"), this.config.reconnect !== !1)
184
185
  this.scheduleReconnect();
185
186
  else
186
- throw e;
187
+ throw t;
187
188
  }
188
189
  }
189
190
  async disconnect() {
@@ -230,7 +231,7 @@ class zl extends qs {
230
231
  this.reconnectAttempt++, this.reconnectTimer = setTimeout(async () => {
231
232
  try {
232
233
  const o = this.buildWsUrl(this.config.baseUrl, this.config.userToken);
233
- this.client = new bo(o), await this.connect();
234
+ this.client.disconnect(), this.client = new bo(o), await this.connect();
234
235
  } catch {
235
236
  }
236
237
  }, r);
@@ -11435,6 +11436,8 @@ class fh extends qs {
11435
11436
  this.emit("connection:state", r), this.config.onConnectionStateChange?.(r);
11436
11437
  }), this.connection.on("error", (r) => {
11437
11438
  this.emit("error", r), this.config.onError?.(r);
11439
+ }), this.connection.on("reconnected", () => {
11440
+ this.resubscribeAfterReconnect();
11438
11441
  })), this.usesTiledesk() && this.initTiledeskTransport();
11439
11442
  }
11440
11443
  usesAikaara() {
@@ -11702,6 +11705,17 @@ class fh extends qs {
11702
11705
  } catch {
11703
11706
  }
11704
11707
  }
11708
+ async resubscribeAfterReconnect() {
11709
+ const e = this.conversationManager.conversationId;
11710
+ if (!(!e || !this.connection))
11711
+ try {
11712
+ this.subscription = await this.connection.subscribeToConversation(e), this.subscription.onReceived((t) => {
11713
+ this.handleBroadcast(t);
11714
+ });
11715
+ } catch (t) {
11716
+ this.emit("error", t instanceof Error ? t : new Error(String(t))), this.config.onError?.(t instanceof Error ? t : new Error(String(t)));
11717
+ }
11718
+ }
11705
11719
  handleBroadcast(e) {
11706
11720
  const t = this.conversationManager.conversationId;
11707
11721
  switch (e.type) {
@@ -14552,7 +14566,7 @@ class _d extends HTMLElement {
14552
14566
  */
14553
14567
  mountLinkButton(e) {
14554
14568
  const t = this.renderGen;
14555
- import("./AikaaraLinkButton-CnQoe1id.mjs").then(({ registerAikaaraLinkButton: r, AikaaraLinkButton: o }) => {
14569
+ import("./AikaaraLinkButton-C0AQPULt.mjs").then(({ registerAikaaraLinkButton: r, AikaaraLinkButton: o }) => {
14556
14570
  if (t !== this.renderGen) return;
14557
14571
  r();
14558
14572
  const n = document.createElement("aikaara-link-button");