@alan-ai/alan-sdk-web 1.8.71 → 1.8.72

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/alan_lib.js CHANGED
@@ -89698,7 +89698,7 @@
89698
89698
  messages[msgInd] = {
89699
89699
  ...msg,
89700
89700
  queryProgress: [
89701
- ...messages[msgInd].queryProgress || [],
89701
+ ...messages[msgInd]?.queryProgress || [],
89702
89702
  ...msg.queryProgress
89703
89703
  ]
89704
89704
  };
@@ -93926,7 +93926,7 @@ code.hljs {
93926
93926
 
93927
93927
  // alan_btn/alan_btn.ts
93928
93928
  (function(ns) {
93929
- uiState.lib.version = "alan-version.1.8.71".replace("alan-version.", "");
93929
+ uiState.lib.version = "alan-version.1.8.72".replace("alan-version.", "");
93930
93930
  if (window.alanBtn) {
93931
93931
  console.warn("Alan: the Alan Button source code has already added (v." + uiState.lib.version + ")");
93932
93932
  }
@@ -96168,6 +96168,7 @@ ${LEARN_MORE_LABEL}
96168
96168
  let innerMsgPart = "";
96169
96169
  let msgHtml = "";
96170
96170
  const msgHolder = document.getElementById("chatMessages");
96171
+ const msgsScrollableContainer = document.getElementById("chatMessagesWrapper");
96171
96172
  if (msg.type === "response" && msg.name === "text") {
96172
96173
  if (window.fakeMsg) {
96173
96174
  msg.text = window.fakeMsg?.text || msg.text;
@@ -96239,9 +96240,9 @@ ${LEARN_MORE_LABEL}
96239
96240
  unreadChatMsgCount++;
96240
96241
  }
96241
96242
  if (immidiateScroll !== true) {
96242
- scrollTextChat(msgHolder, "smooth");
96243
+ scrollTextChat(msgsScrollableContainer, "smooth");
96243
96244
  } else {
96244
- scrollTextChat(msgHolder);
96245
+ scrollTextChat(msgsScrollableContainer);
96245
96246
  }
96246
96247
  if (msg.ctx?.final !== false) {
96247
96248
  processFormulas(getMsgElForMathJax(msgInd));
@@ -96269,7 +96270,7 @@ ${LEARN_MORE_LABEL}
96269
96270
  if (msg.type === "response" && isMsgContainsIFrame(innerEl?.innerHTML)) {
96270
96271
  innerEl.classList.add("with-table");
96271
96272
  }
96272
- scrollTextChat(msgHolder, "smooth");
96273
+ scrollTextChat(msgsScrollableContainer, "smooth");
96273
96274
  }
96274
96275
  } else if (updateResponse && msg.type !== "chat") {
96275
96276
  let innerEl = msgEl.querySelector(".alan-btn__chat-inner-msg");
@@ -96305,7 +96306,7 @@ ${LEARN_MORE_LABEL}
96305
96306
  innerEl.classList.add("with-table");
96306
96307
  }
96307
96308
  setTimeout(() => {
96308
- scrollTextChat(msgHolder, "smooth");
96309
+ scrollTextChat(msgsScrollableContainer, "smooth");
96309
96310
  });
96310
96311
  }
96311
96312
  } else {
@@ -96320,6 +96321,9 @@ ${LEARN_MORE_LABEL}
96320
96321
  } else {
96321
96322
  msgEl.innerHTML = msgHtml;
96322
96323
  }
96324
+ setTimeout(() => {
96325
+ scrollTextChat(msgsScrollableContainer);
96326
+ });
96323
96327
  }
96324
96328
  }
96325
96329
  if (msg.ctx?.final !== false) {
@@ -96344,7 +96348,7 @@ ${LEARN_MORE_LABEL}
96344
96348
  }
96345
96349
  function updateMessageProgressStatus(msgInd, loaderContentEl) {
96346
96350
  return setInterval(() => {
96347
- if (loaderContentEl) {
96351
+ if (loaderContentEl && textChatMessages[msgInd]) {
96348
96352
  const index = (0, import_lodash2.findIndex)(textChatMessages[msgInd].queryProgress, { isShown: false });
96349
96353
  if (index >= 0) {
96350
96354
  textChatMessages[msgInd].queryProgress[index].isShown = true;
@@ -96353,9 +96357,9 @@ ${LEARN_MORE_LABEL}
96353
96357
  }
96354
96358
  }, 500);
96355
96359
  }
96356
- function scrollTextChat(msgHolder, behavior) {
96360
+ function scrollTextChat(scrollableEl, behavior) {
96357
96361
  const scrollOptions = {
96358
- top: msgHolder.scrollHeight + 500,
96362
+ top: scrollableEl.scrollHeight + 500,
96359
96363
  left: 0
96360
96364
  };
96361
96365
  if (textChatScrollPosition !== null)
@@ -96363,15 +96367,15 @@ ${LEARN_MORE_LABEL}
96363
96367
  if (behavior) {
96364
96368
  scrollOptions.behavior = "smooth";
96365
96369
  }
96366
- msgHolder.scroll(scrollOptions);
96370
+ scrollableEl.scroll(scrollOptions);
96367
96371
  }
96368
96372
  function onTextChatScroll(e) {
96369
- const chatMessagesEl = document.getElementById("chatMessages");
96370
- if (chatMessagesEl) {
96371
- if (chatMessagesEl.scrollTop + chatMessagesEl.clientHeight >= chatMessagesEl.scrollHeight) {
96373
+ const el = e.currentTarget;
96374
+ if (el) {
96375
+ if (el.scrollTop + el.clientHeight >= el.scrollHeight) {
96372
96376
  textChatScrollPosition = null;
96373
96377
  } else {
96374
- textChatScrollPosition = chatMessagesEl.scrollTop;
96378
+ textChatScrollPosition = el.scrollTop;
96375
96379
  }
96376
96380
  }
96377
96381
  }
@@ -96433,7 +96437,6 @@ ${LEARN_MORE_LABEL}
96433
96437
  }
96434
96438
  tabActive = true;
96435
96439
  saveTabId();
96436
- console.info("syncChatHistoryBetweenTabs");
96437
96440
  restoreMessageList(false);
96438
96441
  }
96439
96442
  function saveTabId() {
@@ -96449,7 +96452,6 @@ ${LEARN_MORE_LABEL}
96449
96452
  if (isLocalStorageAvailable) {
96450
96453
  if (curDialogId) {
96451
96454
  savedMsgs = localStorage.getItem(getKeyForSavingTextChatMessages());
96452
- console.info("restoreMessageList", savedMsgs, curDialogId, getKeyForSavingTextChatMessages());
96453
96455
  try {
96454
96456
  if (savedMsgs === JSON.stringify(textChatMessages)) {
96455
96457
  return;