@alan-ai/alan-sdk-web 1.8.70 → 1.8.71
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 +61 -19
- 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") {
|
|
@@ -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.71".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
|
}
|
|
@@ -96176,6 +96194,8 @@ ${LEARN_MORE_LABEL}
|
|
|
96176
96194
|
if (msg?.buttons) {
|
|
96177
96195
|
msgHtml = renderButtons(msg?.buttons);
|
|
96178
96196
|
}
|
|
96197
|
+
} else if (msg.type === "connection-separator") {
|
|
96198
|
+
msgHtml = `<div class="alan-btn__chat-connection-separator"></div>`;
|
|
96179
96199
|
} else if (msg.type === "chat") {
|
|
96180
96200
|
msgHtml = `<div class="alan-btn__chat-popup">${msg.html}</div>`;
|
|
96181
96201
|
} else {
|
|
@@ -96209,7 +96229,11 @@ ${LEARN_MORE_LABEL}
|
|
|
96209
96229
|
addPopupStyle(msg, div);
|
|
96210
96230
|
}
|
|
96211
96231
|
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
|
-
|
|
96232
|
+
if (msg.type === "connection-separator") {
|
|
96233
|
+
div.innerHTML = msgHtml;
|
|
96234
|
+
} else {
|
|
96235
|
+
div.innerHTML = `${msg.name !== "loading" ? getMsgBubbleLabel(msg) : ""}<div class="alan-btn__chat-bubble-holder">${(msg.type === "chat" || msg.type === "buttons" ? "" : avatarHtml) + msgHtml}</div>`;
|
|
96236
|
+
}
|
|
96213
96237
|
msgHolder.appendChild(div);
|
|
96214
96238
|
if (uiState.textChat.available && textChatIsHidden && msg.type === "response" && msg.read !== true) {
|
|
96215
96239
|
unreadChatMsgCount++;
|
|
@@ -96362,7 +96386,7 @@ ${LEARN_MORE_LABEL}
|
|
|
96362
96386
|
function getKeyForSavingTextChatMessages() {
|
|
96363
96387
|
return `alan-btn-text-chat-msgs-for-dialogId-${curDialogId}`;
|
|
96364
96388
|
}
|
|
96365
|
-
function
|
|
96389
|
+
function clearDOMChat() {
|
|
96366
96390
|
unreadChatMsgCount = 0;
|
|
96367
96391
|
textChatMessages = [];
|
|
96368
96392
|
if (uiState.textChat.available) {
|
|
@@ -96372,7 +96396,7 @@ ${LEARN_MORE_LABEL}
|
|
|
96372
96396
|
}
|
|
96373
96397
|
}
|
|
96374
96398
|
}
|
|
96375
|
-
function
|
|
96399
|
+
function onClearTextChatBtnClick() {
|
|
96376
96400
|
clearDialogId();
|
|
96377
96401
|
if (window.tutorProject) {
|
|
96378
96402
|
window.tutorProject.close();
|
|
@@ -96387,16 +96411,29 @@ ${LEARN_MORE_LABEL}
|
|
|
96387
96411
|
btnIsReady = false;
|
|
96388
96412
|
connectProject();
|
|
96389
96413
|
}
|
|
96390
|
-
|
|
96391
|
-
}
|
|
96392
|
-
function clearChatAndChatHistory() {
|
|
96393
|
-
clearChat();
|
|
96414
|
+
clearDOMChat();
|
|
96394
96415
|
clearChatHistoryStorage();
|
|
96395
96416
|
manageSaveChatHistoryBtn();
|
|
96396
96417
|
}
|
|
96418
|
+
function onNewDialogAutoReconnect() {
|
|
96419
|
+
console.info("onNewDialogAutoReconnect");
|
|
96420
|
+
if (textChatMessages?.length === 0)
|
|
96421
|
+
return;
|
|
96422
|
+
if (textChatMessages?.at(-1)?.type === "connection-separator")
|
|
96423
|
+
return;
|
|
96424
|
+
const event = {
|
|
96425
|
+
type: "connection-separator"
|
|
96426
|
+
};
|
|
96427
|
+
renderMessageInTextChat(event);
|
|
96428
|
+
}
|
|
96429
|
+
window.onNewDialogAutoReconnect = onNewDialogAutoReconnect;
|
|
96397
96430
|
function syncChatHistoryBetweenTabs() {
|
|
96431
|
+
if (isTutorMode()) {
|
|
96432
|
+
return;
|
|
96433
|
+
}
|
|
96398
96434
|
tabActive = true;
|
|
96399
96435
|
saveTabId();
|
|
96436
|
+
console.info("syncChatHistoryBetweenTabs");
|
|
96400
96437
|
restoreMessageList(false);
|
|
96401
96438
|
}
|
|
96402
96439
|
function saveTabId() {
|
|
@@ -96412,13 +96449,16 @@ ${LEARN_MORE_LABEL}
|
|
|
96412
96449
|
if (isLocalStorageAvailable) {
|
|
96413
96450
|
if (curDialogId) {
|
|
96414
96451
|
savedMsgs = localStorage.getItem(getKeyForSavingTextChatMessages());
|
|
96452
|
+
console.info("restoreMessageList", savedMsgs, curDialogId, getKeyForSavingTextChatMessages());
|
|
96415
96453
|
try {
|
|
96416
96454
|
if (savedMsgs === JSON.stringify(textChatMessages)) {
|
|
96417
96455
|
return;
|
|
96418
96456
|
}
|
|
96419
96457
|
savedMsgs = JSON.parse(savedMsgs);
|
|
96420
|
-
clearChat();
|
|
96421
96458
|
if (Array.isArray(savedMsgs)) {
|
|
96459
|
+
if (savedMsgs?.length > 0) {
|
|
96460
|
+
clearDOMChat();
|
|
96461
|
+
}
|
|
96422
96462
|
for (let i2 = 0; i2 < savedMsgs.length; i2++) {
|
|
96423
96463
|
if (initLoad === true) {
|
|
96424
96464
|
if (savedMsgs[i2].name !== "loading") {
|
|
@@ -96621,6 +96661,8 @@ ${LEARN_MORE_LABEL}
|
|
|
96621
96661
|
if (isLocalStorageAvailable) {
|
|
96622
96662
|
const maxSavedForHistoryMsgCount = 25;
|
|
96623
96663
|
const key = getRestoreMsgsLsKey();
|
|
96664
|
+
if (sentMessages?.indexOf(text) > -1)
|
|
96665
|
+
return;
|
|
96624
96666
|
sentMessages.push(text);
|
|
96625
96667
|
if (sentMessages.length > 50) {
|
|
96626
96668
|
sentMessages = sentMessages.slice(Math.max(sentMessages.length - maxSavedForHistoryMsgCount, 0));
|
|
@@ -96838,7 +96880,7 @@ ${LEARN_MORE_LABEL}
|
|
|
96838
96880
|
headerInnerDiv = createDiv({ id: "chat-header-inner", class: "alan-btn__chat-header-inner" });
|
|
96839
96881
|
var headerDivGr = createDiv({ class: "alan-btn__chat-header-gradient" });
|
|
96840
96882
|
var clearChatBtn = createDivWithSvg(chatIcons.clear, { id: "clear-chat-btn", class: "alan-btn__chat-clear-btn" });
|
|
96841
|
-
clearChatBtn.addEventListener("click",
|
|
96883
|
+
clearChatBtn.addEventListener("click", onClearTextChatBtnClick);
|
|
96842
96884
|
headerTille = document.createElement("span");
|
|
96843
96885
|
headerTille.id = "chat-header-title";
|
|
96844
96886
|
headerTille.classList.add("alan-btn__chat-header-title");
|
|
@@ -96886,7 +96928,7 @@ ${LEARN_MORE_LABEL}
|
|
|
96886
96928
|
headerInnerDiv.appendChild(headerTille);
|
|
96887
96929
|
headerInnerDiv.appendChild(rightHeaderIconsHolder);
|
|
96888
96930
|
headerDiv.appendChild(headerInnerDiv);
|
|
96889
|
-
fillSideBarContent(chatSideBar, { clearTextChat, expandCollapseChatSidePanel, closeTextChat });
|
|
96931
|
+
fillSideBarContent(chatSideBar, { clearTextChat: onClearTextChatBtnClick, expandCollapseChatSidePanel, closeTextChat });
|
|
96890
96932
|
textareaInnerDiv = createDiv({ id: "textarea-inner-holder", class: "alan-btn__chat-textarea-inner-holder" });
|
|
96891
96933
|
textareaHolderDiv = createDiv({ id: "textarea-holder-content", class: "alan-btn__chat-textarea-holder-outer-content" });
|
|
96892
96934
|
textareaDiv = createDiv({ id: "textarea-holder", class: "alan-btn__chat-textarea-holder" });
|