@alan-ai/alan-sdk-web 1.8.70 → 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 +76 -32
- package/dist/alan_lib.min.js +1 -1
- package/package.json +1 -1
package/dist/alan_lib.js
CHANGED
|
@@ -89679,6 +89679,13 @@
|
|
|
89679
89679
|
let replaceLoader = false;
|
|
89680
89680
|
let msgInd = null;
|
|
89681
89681
|
let updateResponse = false;
|
|
89682
|
+
if (msg.type === "connection-separator") {
|
|
89683
|
+
messages.push({ ...msg });
|
|
89684
|
+
return {
|
|
89685
|
+
isNew: true,
|
|
89686
|
+
msgInd: messages.length - 1
|
|
89687
|
+
};
|
|
89688
|
+
}
|
|
89682
89689
|
const msgReqId = msg.reqId || msg?.ctx?.reqId;
|
|
89683
89690
|
const msgResponseId = msg?.ctx?.responseId;
|
|
89684
89691
|
if (msg.type === "response" && msg.name === "loading") {
|
|
@@ -89691,7 +89698,7 @@
|
|
|
89691
89698
|
messages[msgInd] = {
|
|
89692
89699
|
...msg,
|
|
89693
89700
|
queryProgress: [
|
|
89694
|
-
...messages[msgInd]
|
|
89701
|
+
...messages[msgInd]?.queryProgress || [],
|
|
89695
89702
|
...msg.queryProgress
|
|
89696
89703
|
]
|
|
89697
89704
|
};
|
|
@@ -90482,6 +90489,7 @@
|
|
|
90482
90489
|
const responseBubbleRightPadding = getNumPropVal(textChatOptions?.bubbles?.response?.padding?.right, 20);
|
|
90483
90490
|
const responseBubbleBottomPadding = getNumPropVal(textChatOptions?.bubbles?.response?.padding?.bottom, 9);
|
|
90484
90491
|
const responseBubbleLeftPadding = getNumPropVal(textChatOptions?.bubbles?.response?.padding?.left, 20);
|
|
90492
|
+
const newDialogSeparatorColor = textChatOptions?.bubbles?.newDialog?.separator?.color || `#d3dae2`;
|
|
90485
90493
|
const waitingResponseBubbleLayout = textChatOptions?.bubbles?.waitingResponse?.layout || "default";
|
|
90486
90494
|
const responseBubbleBorderRadiusTopLeft = getNumPropVal(textChatOptions?.bubbles?.response?.borderRadius?.topLeft, defaultBubbleBorderRadius);
|
|
90487
90495
|
const responseBubbleBorderRadiusTopRight = getNumPropVal(textChatOptions?.bubbles?.response?.borderRadius?.topRight, defaultBubbleBorderRadius);
|
|
@@ -91589,6 +91597,14 @@
|
|
|
91589
91597
|
box-shadow: none;
|
|
91590
91598
|
border-color:transparent;` : ``}
|
|
91591
91599
|
}`;
|
|
91600
|
+
keyFrames += getStyleSheetMarker() + `.alan-btn__chat-connection-separator {
|
|
91601
|
+
width: 100%;
|
|
91602
|
+
height: 1px;
|
|
91603
|
+
min-height: 1px;
|
|
91604
|
+
max-height: 1px;
|
|
91605
|
+
background-color: ${newDialogSeparatorColor};
|
|
91606
|
+
margin: 50px 0;
|
|
91607
|
+
}`;
|
|
91592
91608
|
keyFrames += getStyleSheetMarker() + `.alan-btn__chat-buttons {
|
|
91593
91609
|
margin-bottom: 16px;
|
|
91594
91610
|
display:flex;
|
|
@@ -93910,7 +93926,7 @@ code.hljs {
|
|
|
93910
93926
|
|
|
93911
93927
|
// alan_btn/alan_btn.ts
|
|
93912
93928
|
(function(ns) {
|
|
93913
|
-
uiState.lib.version = "alan-version.1.8.
|
|
93929
|
+
uiState.lib.version = "alan-version.1.8.72".replace("alan-version.", "");
|
|
93914
93930
|
if (window.alanBtn) {
|
|
93915
93931
|
console.warn("Alan: the Alan Button source code has already added (v." + uiState.lib.version + ")");
|
|
93916
93932
|
}
|
|
@@ -94038,7 +94054,7 @@ code.hljs {
|
|
|
94038
94054
|
closeTextChat();
|
|
94039
94055
|
},
|
|
94040
94056
|
clear: () => {
|
|
94041
|
-
|
|
94057
|
+
onClearTextChatBtnClick();
|
|
94042
94058
|
}
|
|
94043
94059
|
},
|
|
94044
94060
|
//deprecated
|
|
@@ -95000,7 +95016,7 @@ code.hljs {
|
|
|
95000
95016
|
if (isLocalStorageAvailable) {
|
|
95001
95017
|
return localStorage.getItem(getDialogIdSessionKey());
|
|
95002
95018
|
}
|
|
95003
|
-
return
|
|
95019
|
+
return void 0;
|
|
95004
95020
|
}
|
|
95005
95021
|
function saveDialogId(dialogId) {
|
|
95006
95022
|
if (isLocalStorageAvailable && dialogId) {
|
|
@@ -95497,14 +95513,16 @@ code.hljs {
|
|
|
95497
95513
|
switchState(getDefaultBtnState());
|
|
95498
95514
|
}
|
|
95499
95515
|
const { dialogId } = window.tutorProject.getSettings();
|
|
95500
|
-
if (getSavedDialogId() !== dialogId) {
|
|
95501
|
-
clearChatAndChatHistory();
|
|
95502
|
-
}
|
|
95503
95516
|
console.info("Alan: connected to dialog - ", dialogId, "prev. dialog: ", getSavedDialogId() || "-");
|
|
95504
95517
|
curDialogId = dialogId;
|
|
95505
|
-
|
|
95506
|
-
|
|
95507
|
-
|
|
95518
|
+
if (getSavedDialogId() !== dialogId) {
|
|
95519
|
+
saveDialogId(dialogId);
|
|
95520
|
+
onNewDialogAutoReconnect();
|
|
95521
|
+
} else {
|
|
95522
|
+
saveDialogId(dialogId);
|
|
95523
|
+
restoreMessageList(true);
|
|
95524
|
+
}
|
|
95525
|
+
console.info("Alan: curDialogId", curDialogId);
|
|
95508
95526
|
if (!isTutorMode()) {
|
|
95509
95527
|
sendSyncPageState();
|
|
95510
95528
|
}
|
|
@@ -96150,6 +96168,7 @@ ${LEARN_MORE_LABEL}
|
|
|
96150
96168
|
let innerMsgPart = "";
|
|
96151
96169
|
let msgHtml = "";
|
|
96152
96170
|
const msgHolder = document.getElementById("chatMessages");
|
|
96171
|
+
const msgsScrollableContainer = document.getElementById("chatMessagesWrapper");
|
|
96153
96172
|
if (msg.type === "response" && msg.name === "text") {
|
|
96154
96173
|
if (window.fakeMsg) {
|
|
96155
96174
|
msg.text = window.fakeMsg?.text || msg.text;
|
|
@@ -96176,6 +96195,8 @@ ${LEARN_MORE_LABEL}
|
|
|
96176
96195
|
if (msg?.buttons) {
|
|
96177
96196
|
msgHtml = renderButtons(msg?.buttons);
|
|
96178
96197
|
}
|
|
96198
|
+
} else if (msg.type === "connection-separator") {
|
|
96199
|
+
msgHtml = `<div class="alan-btn__chat-connection-separator"></div>`;
|
|
96179
96200
|
} else if (msg.type === "chat") {
|
|
96180
96201
|
msgHtml = `<div class="alan-btn__chat-popup">${msg.html}</div>`;
|
|
96181
96202
|
} else {
|
|
@@ -96209,15 +96230,19 @@ ${LEARN_MORE_LABEL}
|
|
|
96209
96230
|
addPopupStyle(msg, div);
|
|
96210
96231
|
}
|
|
96211
96232
|
var avatarHtml = `<div class="alan-btn__chat-avatar ${msg.type}">` + (msg.type === "request" ? `<div class="alan-btn__chat-request-avatar"></div>` : `<div class="alan-btn__chat-response-avatar"></div>`) + "</div>";
|
|
96212
|
-
|
|
96233
|
+
if (msg.type === "connection-separator") {
|
|
96234
|
+
div.innerHTML = msgHtml;
|
|
96235
|
+
} else {
|
|
96236
|
+
div.innerHTML = `${msg.name !== "loading" ? getMsgBubbleLabel(msg) : ""}<div class="alan-btn__chat-bubble-holder">${(msg.type === "chat" || msg.type === "buttons" ? "" : avatarHtml) + msgHtml}</div>`;
|
|
96237
|
+
}
|
|
96213
96238
|
msgHolder.appendChild(div);
|
|
96214
96239
|
if (uiState.textChat.available && textChatIsHidden && msg.type === "response" && msg.read !== true) {
|
|
96215
96240
|
unreadChatMsgCount++;
|
|
96216
96241
|
}
|
|
96217
96242
|
if (immidiateScroll !== true) {
|
|
96218
|
-
scrollTextChat(
|
|
96243
|
+
scrollTextChat(msgsScrollableContainer, "smooth");
|
|
96219
96244
|
} else {
|
|
96220
|
-
scrollTextChat(
|
|
96245
|
+
scrollTextChat(msgsScrollableContainer);
|
|
96221
96246
|
}
|
|
96222
96247
|
if (msg.ctx?.final !== false) {
|
|
96223
96248
|
processFormulas(getMsgElForMathJax(msgInd));
|
|
@@ -96245,7 +96270,7 @@ ${LEARN_MORE_LABEL}
|
|
|
96245
96270
|
if (msg.type === "response" && isMsgContainsIFrame(innerEl?.innerHTML)) {
|
|
96246
96271
|
innerEl.classList.add("with-table");
|
|
96247
96272
|
}
|
|
96248
|
-
scrollTextChat(
|
|
96273
|
+
scrollTextChat(msgsScrollableContainer, "smooth");
|
|
96249
96274
|
}
|
|
96250
96275
|
} else if (updateResponse && msg.type !== "chat") {
|
|
96251
96276
|
let innerEl = msgEl.querySelector(".alan-btn__chat-inner-msg");
|
|
@@ -96281,7 +96306,7 @@ ${LEARN_MORE_LABEL}
|
|
|
96281
96306
|
innerEl.classList.add("with-table");
|
|
96282
96307
|
}
|
|
96283
96308
|
setTimeout(() => {
|
|
96284
|
-
scrollTextChat(
|
|
96309
|
+
scrollTextChat(msgsScrollableContainer, "smooth");
|
|
96285
96310
|
});
|
|
96286
96311
|
}
|
|
96287
96312
|
} else {
|
|
@@ -96296,6 +96321,9 @@ ${LEARN_MORE_LABEL}
|
|
|
96296
96321
|
} else {
|
|
96297
96322
|
msgEl.innerHTML = msgHtml;
|
|
96298
96323
|
}
|
|
96324
|
+
setTimeout(() => {
|
|
96325
|
+
scrollTextChat(msgsScrollableContainer);
|
|
96326
|
+
});
|
|
96299
96327
|
}
|
|
96300
96328
|
}
|
|
96301
96329
|
if (msg.ctx?.final !== false) {
|
|
@@ -96320,7 +96348,7 @@ ${LEARN_MORE_LABEL}
|
|
|
96320
96348
|
}
|
|
96321
96349
|
function updateMessageProgressStatus(msgInd, loaderContentEl) {
|
|
96322
96350
|
return setInterval(() => {
|
|
96323
|
-
if (loaderContentEl) {
|
|
96351
|
+
if (loaderContentEl && textChatMessages[msgInd]) {
|
|
96324
96352
|
const index = (0, import_lodash2.findIndex)(textChatMessages[msgInd].queryProgress, { isShown: false });
|
|
96325
96353
|
if (index >= 0) {
|
|
96326
96354
|
textChatMessages[msgInd].queryProgress[index].isShown = true;
|
|
@@ -96329,9 +96357,9 @@ ${LEARN_MORE_LABEL}
|
|
|
96329
96357
|
}
|
|
96330
96358
|
}, 500);
|
|
96331
96359
|
}
|
|
96332
|
-
function scrollTextChat(
|
|
96360
|
+
function scrollTextChat(scrollableEl, behavior) {
|
|
96333
96361
|
const scrollOptions = {
|
|
96334
|
-
top:
|
|
96362
|
+
top: scrollableEl.scrollHeight + 500,
|
|
96335
96363
|
left: 0
|
|
96336
96364
|
};
|
|
96337
96365
|
if (textChatScrollPosition !== null)
|
|
@@ -96339,15 +96367,15 @@ ${LEARN_MORE_LABEL}
|
|
|
96339
96367
|
if (behavior) {
|
|
96340
96368
|
scrollOptions.behavior = "smooth";
|
|
96341
96369
|
}
|
|
96342
|
-
|
|
96370
|
+
scrollableEl.scroll(scrollOptions);
|
|
96343
96371
|
}
|
|
96344
96372
|
function onTextChatScroll(e) {
|
|
96345
|
-
const
|
|
96346
|
-
if (
|
|
96347
|
-
if (
|
|
96373
|
+
const el = e.currentTarget;
|
|
96374
|
+
if (el) {
|
|
96375
|
+
if (el.scrollTop + el.clientHeight >= el.scrollHeight) {
|
|
96348
96376
|
textChatScrollPosition = null;
|
|
96349
96377
|
} else {
|
|
96350
|
-
textChatScrollPosition =
|
|
96378
|
+
textChatScrollPosition = el.scrollTop;
|
|
96351
96379
|
}
|
|
96352
96380
|
}
|
|
96353
96381
|
}
|
|
@@ -96362,7 +96390,7 @@ ${LEARN_MORE_LABEL}
|
|
|
96362
96390
|
function getKeyForSavingTextChatMessages() {
|
|
96363
96391
|
return `alan-btn-text-chat-msgs-for-dialogId-${curDialogId}`;
|
|
96364
96392
|
}
|
|
96365
|
-
function
|
|
96393
|
+
function clearDOMChat() {
|
|
96366
96394
|
unreadChatMsgCount = 0;
|
|
96367
96395
|
textChatMessages = [];
|
|
96368
96396
|
if (uiState.textChat.available) {
|
|
@@ -96372,7 +96400,7 @@ ${LEARN_MORE_LABEL}
|
|
|
96372
96400
|
}
|
|
96373
96401
|
}
|
|
96374
96402
|
}
|
|
96375
|
-
function
|
|
96403
|
+
function onClearTextChatBtnClick() {
|
|
96376
96404
|
clearDialogId();
|
|
96377
96405
|
if (window.tutorProject) {
|
|
96378
96406
|
window.tutorProject.close();
|
|
@@ -96387,14 +96415,26 @@ ${LEARN_MORE_LABEL}
|
|
|
96387
96415
|
btnIsReady = false;
|
|
96388
96416
|
connectProject();
|
|
96389
96417
|
}
|
|
96390
|
-
|
|
96391
|
-
}
|
|
96392
|
-
function clearChatAndChatHistory() {
|
|
96393
|
-
clearChat();
|
|
96418
|
+
clearDOMChat();
|
|
96394
96419
|
clearChatHistoryStorage();
|
|
96395
96420
|
manageSaveChatHistoryBtn();
|
|
96396
96421
|
}
|
|
96422
|
+
function onNewDialogAutoReconnect() {
|
|
96423
|
+
console.info("onNewDialogAutoReconnect");
|
|
96424
|
+
if (textChatMessages?.length === 0)
|
|
96425
|
+
return;
|
|
96426
|
+
if (textChatMessages?.at(-1)?.type === "connection-separator")
|
|
96427
|
+
return;
|
|
96428
|
+
const event = {
|
|
96429
|
+
type: "connection-separator"
|
|
96430
|
+
};
|
|
96431
|
+
renderMessageInTextChat(event);
|
|
96432
|
+
}
|
|
96433
|
+
window.onNewDialogAutoReconnect = onNewDialogAutoReconnect;
|
|
96397
96434
|
function syncChatHistoryBetweenTabs() {
|
|
96435
|
+
if (isTutorMode()) {
|
|
96436
|
+
return;
|
|
96437
|
+
}
|
|
96398
96438
|
tabActive = true;
|
|
96399
96439
|
saveTabId();
|
|
96400
96440
|
restoreMessageList(false);
|
|
@@ -96417,8 +96457,10 @@ ${LEARN_MORE_LABEL}
|
|
|
96417
96457
|
return;
|
|
96418
96458
|
}
|
|
96419
96459
|
savedMsgs = JSON.parse(savedMsgs);
|
|
96420
|
-
clearChat();
|
|
96421
96460
|
if (Array.isArray(savedMsgs)) {
|
|
96461
|
+
if (savedMsgs?.length > 0) {
|
|
96462
|
+
clearDOMChat();
|
|
96463
|
+
}
|
|
96422
96464
|
for (let i2 = 0; i2 < savedMsgs.length; i2++) {
|
|
96423
96465
|
if (initLoad === true) {
|
|
96424
96466
|
if (savedMsgs[i2].name !== "loading") {
|
|
@@ -96621,6 +96663,8 @@ ${LEARN_MORE_LABEL}
|
|
|
96621
96663
|
if (isLocalStorageAvailable) {
|
|
96622
96664
|
const maxSavedForHistoryMsgCount = 25;
|
|
96623
96665
|
const key = getRestoreMsgsLsKey();
|
|
96666
|
+
if (sentMessages?.indexOf(text) > -1)
|
|
96667
|
+
return;
|
|
96624
96668
|
sentMessages.push(text);
|
|
96625
96669
|
if (sentMessages.length > 50) {
|
|
96626
96670
|
sentMessages = sentMessages.slice(Math.max(sentMessages.length - maxSavedForHistoryMsgCount, 0));
|
|
@@ -96838,7 +96882,7 @@ ${LEARN_MORE_LABEL}
|
|
|
96838
96882
|
headerInnerDiv = createDiv({ id: "chat-header-inner", class: "alan-btn__chat-header-inner" });
|
|
96839
96883
|
var headerDivGr = createDiv({ class: "alan-btn__chat-header-gradient" });
|
|
96840
96884
|
var clearChatBtn = createDivWithSvg(chatIcons.clear, { id: "clear-chat-btn", class: "alan-btn__chat-clear-btn" });
|
|
96841
|
-
clearChatBtn.addEventListener("click",
|
|
96885
|
+
clearChatBtn.addEventListener("click", onClearTextChatBtnClick);
|
|
96842
96886
|
headerTille = document.createElement("span");
|
|
96843
96887
|
headerTille.id = "chat-header-title";
|
|
96844
96888
|
headerTille.classList.add("alan-btn__chat-header-title");
|
|
@@ -96886,7 +96930,7 @@ ${LEARN_MORE_LABEL}
|
|
|
96886
96930
|
headerInnerDiv.appendChild(headerTille);
|
|
96887
96931
|
headerInnerDiv.appendChild(rightHeaderIconsHolder);
|
|
96888
96932
|
headerDiv.appendChild(headerInnerDiv);
|
|
96889
|
-
fillSideBarContent(chatSideBar, { clearTextChat, expandCollapseChatSidePanel, closeTextChat });
|
|
96933
|
+
fillSideBarContent(chatSideBar, { clearTextChat: onClearTextChatBtnClick, expandCollapseChatSidePanel, closeTextChat });
|
|
96890
96934
|
textareaInnerDiv = createDiv({ id: "textarea-inner-holder", class: "alan-btn__chat-textarea-inner-holder" });
|
|
96891
96935
|
textareaHolderDiv = createDiv({ id: "textarea-holder-content", class: "alan-btn__chat-textarea-holder-outer-content" });
|
|
96892
96936
|
textareaDiv = createDiv({ id: "textarea-holder", class: "alan-btn__chat-textarea-holder" });
|