@enegelai/bot-widget 1.12.2 → 1.12.4

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/dist/index.es.js CHANGED
@@ -806,7 +806,7 @@ A.setLevel("info");
806
806
  const ee = "cb_";
807
807
  class L extends kt {
808
808
  constructor() {
809
- super(...arguments), this.actionIdCounter = 0, this.prefilledFormValues = {}, this.wsClient = null, this.replyMessage = null, this.streamingResponseInProgress = !1, this.streamingResponseLastText = null, this.streamingResponseBuffer = null, this.streamingResponseTagStartPos = 0, this.streamingResponseCurrentTag = null;
809
+ super(...arguments), this.actionIdCounter = 0, this.currentLoadContext = {}, this.prefilledFormValues = {}, this.wsClient = null, this.replyMessage = null, this.streamingResponseInProgress = !1, this.streamingResponseLastText = null, this.streamingResponseBuffer = null, this.streamingResponseTagStartPos = 0, this.streamingResponseCurrentTag = null;
810
810
  }
811
811
  // this is called at startup
812
812
  setSetting(e) {
@@ -872,7 +872,8 @@ class L extends kt {
872
872
  }
873
873
  initConversation() {
874
874
  const e = Date.now(), a = this.setting.newConversationTimeoutInSec * 1e3;
875
- if (e - this.lastConversationUpdate > a) {
875
+ let n = this.lastConversationUpdate;
876
+ if (typeof n == "string" && (n = isNaN(n) ? 0 : parseInt(n, 10)), e - n > a) {
876
877
  this.clearConversation();
877
878
  return;
878
879
  }
@@ -880,7 +881,7 @@ class L extends kt {
880
881
  }
881
882
  clearConversation() {
882
883
  this.wsClient && (this.wsClient.stop().then(() => {
883
- }), this.wsClient = null), this.conversationId = xe(), this.lastConversationUpdate = Date.now(), this.connectWs = "false", this.shouldEngage = "true", this.messages = [], this.unreadMessages = 0, this.actions = [], this.context = {}, this.form = null, this.addMessage({
884
+ }), this.wsClient = null), this.conversationId = xe(), this.lastConversationUpdate = Date.now(), this.connectWs = "false", this.shouldEngage = "true", this.messages = [], this.unreadMessages = 0, this.actions = [], this.context = this.currentLoadContext, this.form = null, this.addMessage({
884
885
  author: "assistant",
885
886
  type: "text",
886
887
  data: {
@@ -896,12 +897,12 @@ class L extends kt {
896
897
  }
897
898
  // Set data in the context of the conversation
898
899
  async setContext(e) {
899
- if (!(!e || typeof e != "object")) {
900
- this.context || (this.context = {});
901
- for (const [a, n] of Object.entries(e))
902
- this.context[a] = n;
903
- this.wsClient && await this.sendContext();
904
- }
900
+ if (!e || typeof e != "object")
901
+ return;
902
+ const a = this.context ? this.context : {};
903
+ for (const [n, s] of Object.entries(e))
904
+ a[n] = s, this.currentLoadContext[n] = s;
905
+ this.context = a, this.wsClient && await this.sendContext();
905
906
  }
906
907
  async sendContext() {
907
908
  if (!this.context)
@@ -922,7 +923,7 @@ class L extends kt {
922
923
  return this.context;
923
924
  }
924
925
  clearContext() {
925
- this.context = {};
926
+ this.context = {}, this.currentLoadContext = {};
926
927
  }
927
928
  initStartupForm() {
928
929
  const e = wt(null, ["startupForm"], this.botSettings);
@@ -1477,7 +1478,7 @@ O([
1477
1478
  ], L.prototype, "setting");
1478
1479
  O([
1479
1480
  oe({ prefix: ee }),
1480
- q({ type: Object, value: null })
1481
+ q({ type: Object, value: {} })
1481
1482
  ], L.prototype, "context");
1482
1483
  O([
1483
1484
  q({ type: String, value: "top-end" })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enegelai/bot-widget",
3
- "version": "1.12.2",
3
+ "version": "1.12.4",
4
4
  "description": "Enegel.ai Bot Widget",
5
5
  "scripts": {
6
6
  "dev": "vite",