@alan-ai/alan-sdk-web 1.8.74 → 1.8.76
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/AlanButton.d.ts +4 -0
- package/dist/alan_lib.js +117 -64
- package/dist/alan_lib.min.js +1 -1
- package/package.json +1 -1
package/dist/AlanButton.d.ts
CHANGED
|
@@ -8,6 +8,10 @@ export interface AlanButton {
|
|
|
8
8
|
isActive: () => boolean;
|
|
9
9
|
remove: () => void;
|
|
10
10
|
sendText: (text: string) => void;
|
|
11
|
+
theme: {
|
|
12
|
+
setTheme: (theme: 'light' | 'dark') => void;
|
|
13
|
+
getTheme: () => string,
|
|
14
|
+
};
|
|
11
15
|
textChat: {
|
|
12
16
|
setAudioOutputEnabled: (value: boolean) => void,
|
|
13
17
|
isAudioOutputEnabled: () => boolean,
|
package/dist/alan_lib.js
CHANGED
|
@@ -341,7 +341,7 @@
|
|
|
341
341
|
this._cleanups.push(f);
|
|
342
342
|
};
|
|
343
343
|
|
|
344
|
-
function fillAuth(values, ext,
|
|
344
|
+
function fillAuth(values, ext, connectionConfig) {
|
|
345
345
|
var auth = {};
|
|
346
346
|
for (var k in ext) {
|
|
347
347
|
auth[k] = ext[k];
|
|
@@ -365,7 +365,8 @@
|
|
|
365
365
|
}
|
|
366
366
|
|
|
367
367
|
if (auth && auth.withEdgeUrl) {
|
|
368
|
-
auth.
|
|
368
|
+
delete auth.withEdgeUrl;
|
|
369
|
+
auth.edgeUrl = connectionConfig ? connectionConfig.url : undefined;
|
|
369
370
|
}
|
|
370
371
|
return auth;
|
|
371
372
|
}
|
|
@@ -89451,6 +89452,7 @@
|
|
|
89451
89452
|
|
|
89452
89453
|
// alan_btn/src/state.ts
|
|
89453
89454
|
var uiState = {
|
|
89455
|
+
currentTheme: null,
|
|
89454
89456
|
lib: {
|
|
89455
89457
|
version: ""
|
|
89456
89458
|
},
|
|
@@ -93705,10 +93707,28 @@ code.hljs {
|
|
|
93705
93707
|
}
|
|
93706
93708
|
}
|
|
93707
93709
|
}
|
|
93710
|
+
function broadcastThemeToIframes() {
|
|
93711
|
+
const theme = uiState.currentTheme;
|
|
93712
|
+
const iframes = window.frames;
|
|
93713
|
+
const message = {
|
|
93714
|
+
type: "alanThemeEvent",
|
|
93715
|
+
theme
|
|
93716
|
+
};
|
|
93717
|
+
for (let i = 0; i < iframes.length; i++) {
|
|
93718
|
+
try {
|
|
93719
|
+
iframes[i].postMessage(message, "*");
|
|
93720
|
+
} catch (error) {
|
|
93721
|
+
console.error(`Failed to send message to iframe ${i}`, error);
|
|
93722
|
+
}
|
|
93723
|
+
}
|
|
93724
|
+
}
|
|
93708
93725
|
function onIFrameSizeListener(event) {
|
|
93709
93726
|
if (event.data && event.data.source !== "alan-chat-iframe") {
|
|
93710
93727
|
return;
|
|
93711
93728
|
}
|
|
93729
|
+
if (broadcastThemeToIframes) {
|
|
93730
|
+
broadcastThemeToIframes();
|
|
93731
|
+
}
|
|
93712
93732
|
if (event.data?.height) {
|
|
93713
93733
|
adjustIFrameSize(event.data);
|
|
93714
93734
|
}
|
|
@@ -93985,7 +94005,7 @@ code.hljs {
|
|
|
93985
94005
|
|
|
93986
94006
|
// alan_btn/alan_btn.ts
|
|
93987
94007
|
(function(ns) {
|
|
93988
|
-
uiState.lib.version = "alan-version.1.8.
|
|
94008
|
+
uiState.lib.version = "alan-version.1.8.76".replace("alan-version.", "");
|
|
93989
94009
|
if (window.alanBtn) {
|
|
93990
94010
|
console.warn("Alan: the Alan Button source code has already added (v." + uiState.lib.version + ")");
|
|
93991
94011
|
}
|
|
@@ -94092,6 +94112,14 @@ code.hljs {
|
|
|
94092
94112
|
sendText: (text) => {
|
|
94093
94113
|
_sendText(text);
|
|
94094
94114
|
},
|
|
94115
|
+
theme: {
|
|
94116
|
+
setTheme: (theme) => {
|
|
94117
|
+
changeTheme(theme);
|
|
94118
|
+
},
|
|
94119
|
+
getTheme: () => {
|
|
94120
|
+
return uiState.currentTheme;
|
|
94121
|
+
}
|
|
94122
|
+
},
|
|
94095
94123
|
textChat: {
|
|
94096
94124
|
setAudioOutputEnabled: (value) => {
|
|
94097
94125
|
if (value === true) {
|
|
@@ -94439,6 +94467,7 @@ code.hljs {
|
|
|
94439
94467
|
}
|
|
94440
94468
|
return value;
|
|
94441
94469
|
}
|
|
94470
|
+
uiState.currentTheme = options?.theme || null;
|
|
94442
94471
|
uiState.btn.zIndex = options.zIndex || findHighestZIndex() + 1;
|
|
94443
94472
|
btnIconsZIndex = uiState.btn.zIndex - 2;
|
|
94444
94473
|
btnTextPanelsZIndex = uiState.btn.zIndex - 1;
|
|
@@ -94920,7 +94949,7 @@ code.hljs {
|
|
|
94920
94949
|
createAlanStyleSheet(options);
|
|
94921
94950
|
function connectProject() {
|
|
94922
94951
|
uiState.project.id = options.key;
|
|
94923
|
-
|
|
94952
|
+
applyOptionsFromLocalStorage();
|
|
94924
94953
|
switchState(getDefaultBtnState(DISCONNECTED));
|
|
94925
94954
|
window.tutorProject = window.alan.project(options.key, getAuthData(options.authData), options.host, null, {
|
|
94926
94955
|
platform: mode === "demo" ? "alanplayground" : null,
|
|
@@ -95477,12 +95506,10 @@ code.hljs {
|
|
|
95477
95506
|
if (isTutorMode()) {
|
|
95478
95507
|
manageSyncPageStateListeners(true);
|
|
95479
95508
|
}
|
|
95480
|
-
function
|
|
95481
|
-
|
|
95482
|
-
|
|
95483
|
-
|
|
95484
|
-
if (data && data.web) {
|
|
95485
|
-
keepButtonPositionAfterDnD = data.web.alanButtonDragAndDrop?.keepButtonPositionAfterDnD || data.web.keepButtonPositionAfterDnD;
|
|
95509
|
+
function changeOptions(options2) {
|
|
95510
|
+
manageSyncPageStateListeners(options2?.pageState?.autoSync !== false);
|
|
95511
|
+
if (options2) {
|
|
95512
|
+
keepButtonPositionAfterDnD = options2.alanButtonDragAndDrop?.keepButtonPositionAfterDnD || options2.keepButtonPositionAfterDnD;
|
|
95486
95513
|
if (!keepButtonPositionAfterDnD) {
|
|
95487
95514
|
clearSavedBtnPosition();
|
|
95488
95515
|
}
|
|
@@ -95490,39 +95517,37 @@ code.hljs {
|
|
|
95490
95517
|
} else {
|
|
95491
95518
|
setButtonPosition();
|
|
95492
95519
|
}
|
|
95493
|
-
|
|
95494
|
-
|
|
95495
|
-
}
|
|
95496
|
-
if (data && data.web && data.web.hideS2TPanel === true) {
|
|
95520
|
+
dragAndDropEnabled = options2?.alanButtonDragAndDrop?.dragAndDropEnabled;
|
|
95521
|
+
if (options2?.hideS2TPanel === true) {
|
|
95497
95522
|
hideSpeach2TextPanel();
|
|
95498
95523
|
} else {
|
|
95499
95524
|
showSpeach2TextPanel();
|
|
95500
95525
|
}
|
|
95501
|
-
if (
|
|
95526
|
+
if (options2?.alanButtonPopup?.popupEnabled === true || options2?.popupEnabled === true) {
|
|
95502
95527
|
popupEnabled = true;
|
|
95503
95528
|
} else {
|
|
95504
95529
|
popupEnabled = false;
|
|
95505
95530
|
hidePopup();
|
|
95506
95531
|
}
|
|
95507
95532
|
if (!isTutorMode()) {
|
|
95508
|
-
if (
|
|
95533
|
+
if (options2?.chatOptions?.textChat?.enabled === true) {
|
|
95509
95534
|
uiState.textChat.available = true;
|
|
95510
|
-
voiceEnabledInTextChat =
|
|
95511
|
-
const
|
|
95512
|
-
const
|
|
95513
|
-
if (
|
|
95514
|
-
initHighlightJs(
|
|
95515
|
-
}
|
|
95516
|
-
uiState.textChat.options =
|
|
95517
|
-
if (getVoiceEnabledFlag() !==
|
|
95518
|
-
if (
|
|
95535
|
+
voiceEnabledInTextChat = options2.chatOptions?.textChat?.voice?.enabled;
|
|
95536
|
+
const codeThemeFromOptions = options2.chatOptions?.textChat?.bubbles?.response?.codeTheme || "light";
|
|
95537
|
+
const currentCodeTheme = uiState.textChat.options?.bubbles?.response?.codeTheme;
|
|
95538
|
+
if (currentCodeTheme !== codeThemeFromOptions) {
|
|
95539
|
+
initHighlightJs(codeThemeFromOptions);
|
|
95540
|
+
}
|
|
95541
|
+
uiState.textChat.options = options2?.chatOptions?.textChat;
|
|
95542
|
+
if (getVoiceEnabledFlag() !== options2?.chatOptions?.textChat?.audio?.enabled) {
|
|
95543
|
+
if (options2?.chatOptions?.textChat?.audio?.enabled) {
|
|
95519
95544
|
enableAudio(false);
|
|
95520
95545
|
} else {
|
|
95521
95546
|
disableAudio(false);
|
|
95522
95547
|
}
|
|
95523
95548
|
}
|
|
95524
95549
|
initTextChat();
|
|
95525
|
-
if (isInlinedMode() ||
|
|
95550
|
+
if (isInlinedMode() || options2?.chatOptions?.textChat?.popup?.openByDefualt === true || isTextChatSavedStateOpened()) {
|
|
95526
95551
|
if (!textChatWasClosedManually) {
|
|
95527
95552
|
showTextChat(true);
|
|
95528
95553
|
}
|
|
@@ -95532,26 +95557,21 @@ code.hljs {
|
|
|
95532
95557
|
hideTextChat();
|
|
95533
95558
|
}
|
|
95534
95559
|
}
|
|
95535
|
-
if (
|
|
95536
|
-
turnOffTimeout =
|
|
95560
|
+
if (options2?.timeout !== void 0) {
|
|
95561
|
+
turnOffTimeout = options2.timeout;
|
|
95537
95562
|
setTurnOffVoiceTimeout();
|
|
95538
95563
|
}
|
|
95539
|
-
if (
|
|
95540
|
-
|
|
95541
|
-
|
|
95542
|
-
|
|
95543
|
-
|
|
95544
|
-
if (data && data.web) {
|
|
95545
|
-
applyBtnSizeOptions(data.web.buttonSize || btnModes[mode].btnSize);
|
|
95564
|
+
if (!isTutorMode()) {
|
|
95565
|
+
if (options2) {
|
|
95566
|
+
applyLogoOptions(options2);
|
|
95567
|
+
applyBtnOptions(options2);
|
|
95568
|
+
applyBtnSizeOptions(options2.buttonSize || btnModes[mode].btnSize);
|
|
95546
95569
|
}
|
|
95547
95570
|
}
|
|
95548
|
-
if (
|
|
95549
|
-
|
|
95571
|
+
if (options2?.playReadyToListenSound !== void 0) {
|
|
95572
|
+
applyPlayReadyToListenSoundOptions(options2.playReadyToListenSound);
|
|
95550
95573
|
}
|
|
95551
|
-
if (
|
|
95552
|
-
applyPlayReadyToListenSoundOptions(data.web.playReadyToListenSound);
|
|
95553
|
-
}
|
|
95554
|
-
if (data && data.web && data.web.hidden === true) {
|
|
95574
|
+
if (options2?.hidden === true) {
|
|
95555
95575
|
hideBtn();
|
|
95556
95576
|
} else {
|
|
95557
95577
|
if (btnDisabled) {
|
|
@@ -95563,6 +95583,32 @@ code.hljs {
|
|
|
95563
95583
|
}
|
|
95564
95584
|
}
|
|
95565
95585
|
}
|
|
95586
|
+
function saveOptions(fullOptions) {
|
|
95587
|
+
if (isLocalStorageAvailable && fullOptions) {
|
|
95588
|
+
alanBtnSavedOptions = fullOptions;
|
|
95589
|
+
localStorage.setItem(getBtnOptionsStorageKey(), JSON.stringify(fullOptions));
|
|
95590
|
+
}
|
|
95591
|
+
}
|
|
95592
|
+
function onOptionsReceived(data) {
|
|
95593
|
+
console.log("Alan: options received");
|
|
95594
|
+
console.timeEnd("Alan: receiving options time");
|
|
95595
|
+
saveOptions(data);
|
|
95596
|
+
changeOptions(getOptionsByTheme(data?.web, uiState.currentTheme || options.theme));
|
|
95597
|
+
}
|
|
95598
|
+
function changeTheme(theme) {
|
|
95599
|
+
const options2 = getOptionsByTheme(alanBtnSavedOptions?.web, theme);
|
|
95600
|
+
if (options2) {
|
|
95601
|
+
changeOptions(options2);
|
|
95602
|
+
}
|
|
95603
|
+
uiState.currentTheme = theme;
|
|
95604
|
+
broadcastThemeToIframes();
|
|
95605
|
+
}
|
|
95606
|
+
function getOptionsByTheme(options2, theme) {
|
|
95607
|
+
if (theme) {
|
|
95608
|
+
return options2?.themes?.[theme]?.options || options2;
|
|
95609
|
+
}
|
|
95610
|
+
return options2;
|
|
95611
|
+
}
|
|
95566
95612
|
function onConnectStatusChange(res) {
|
|
95567
95613
|
if (res === "disconnected") {
|
|
95568
95614
|
if (previousState !== OFFLINE) {
|
|
@@ -96220,6 +96266,14 @@ ${LEARN_MORE_LABEL}
|
|
|
96220
96266
|
return "";
|
|
96221
96267
|
}
|
|
96222
96268
|
var progressUpdateIntervalId = null;
|
|
96269
|
+
function hideLoadingMessages() {
|
|
96270
|
+
document.querySelectorAll(".alan-incoming-msg").forEach((div) => {
|
|
96271
|
+
const parent = div.closest("[data-msg-index]");
|
|
96272
|
+
if (parent) {
|
|
96273
|
+
parent.classList.add("alan-hide-msg-immidiatelly");
|
|
96274
|
+
}
|
|
96275
|
+
});
|
|
96276
|
+
}
|
|
96223
96277
|
function renderMessageInTextChat(msg, noAnimation, immidiateScroll) {
|
|
96224
96278
|
if (!uiState.textChat.available)
|
|
96225
96279
|
return;
|
|
@@ -96492,6 +96546,7 @@ ${LEARN_MORE_LABEL}
|
|
|
96492
96546
|
const event = {
|
|
96493
96547
|
type: "connection-separator"
|
|
96494
96548
|
};
|
|
96549
|
+
hideLoadingMessages();
|
|
96495
96550
|
renderMessageInTextChat(event);
|
|
96496
96551
|
}
|
|
96497
96552
|
window.onNewDialogAutoReconnect = onNewDialogAutoReconnect;
|
|
@@ -97684,7 +97739,7 @@ ${LEARN_MORE_LABEL}
|
|
|
97684
97739
|
}
|
|
97685
97740
|
}
|
|
97686
97741
|
}
|
|
97687
|
-
function
|
|
97742
|
+
function getBtnOptionsStorageKey() {
|
|
97688
97743
|
var key = "";
|
|
97689
97744
|
if (options && options.key) {
|
|
97690
97745
|
key = options.key;
|
|
@@ -97724,39 +97779,39 @@ ${LEARN_MORE_LABEL}
|
|
|
97724
97779
|
createAlanStyleSheet(options);
|
|
97725
97780
|
}
|
|
97726
97781
|
}
|
|
97727
|
-
function applyLogoOptions(
|
|
97728
|
-
if (
|
|
97729
|
-
if (
|
|
97730
|
-
listenStateBtnIconImg.src =
|
|
97731
|
-
processStateBtnIconImg.src =
|
|
97732
|
-
replyStateBtnIconImg.src =
|
|
97782
|
+
function applyLogoOptions(options2) {
|
|
97783
|
+
if (options2) {
|
|
97784
|
+
if (options2.logoUrl && !options2.logoIdle && !options2.logoListen && !options2.logoProcess && !options2.logoReply && !options2.logoTextChat) {
|
|
97785
|
+
listenStateBtnIconImg.src = options2.logoUrl;
|
|
97786
|
+
processStateBtnIconImg.src = options2.logoUrl;
|
|
97787
|
+
replyStateBtnIconImg.src = options2.logoUrl;
|
|
97733
97788
|
} else {
|
|
97734
97789
|
if (uiState.textChat.available) {
|
|
97735
|
-
if (
|
|
97736
|
-
defaultStateBtnIconImg.src =
|
|
97790
|
+
if (options2.logoTextChat) {
|
|
97791
|
+
defaultStateBtnIconImg.src = options2.logoTextChat;
|
|
97737
97792
|
} else {
|
|
97738
97793
|
defaultStateBtnIconImg.src = btnIcons.alanLogoIconSrc;
|
|
97739
97794
|
}
|
|
97740
97795
|
} else {
|
|
97741
|
-
if (
|
|
97742
|
-
defaultStateBtnIconImg.src =
|
|
97796
|
+
if (options2.logoIdle) {
|
|
97797
|
+
defaultStateBtnIconImg.src = options2.logoIdle;
|
|
97743
97798
|
} else {
|
|
97744
97799
|
defaultStateBtnIconImg.src = btnIcons.micIconSrc;
|
|
97745
97800
|
}
|
|
97746
|
-
if (
|
|
97747
|
-
listenStateBtnIconImg.src =
|
|
97801
|
+
if (options2.logoListen) {
|
|
97802
|
+
listenStateBtnIconImg.src = options2.logoListen;
|
|
97748
97803
|
} else {
|
|
97749
97804
|
listenStateBtnIconImg.removeAttribute("src");
|
|
97750
97805
|
listenStateBtnIconImg.style.opacity = "0";
|
|
97751
97806
|
}
|
|
97752
|
-
if (
|
|
97753
|
-
processStateBtnIconImg.src =
|
|
97807
|
+
if (options2.logoProcess) {
|
|
97808
|
+
processStateBtnIconImg.src = options2.logoProcess;
|
|
97754
97809
|
} else {
|
|
97755
97810
|
processStateBtnIconImg.removeAttribute("src");
|
|
97756
97811
|
processStateBtnIconImg.style.opacity = "0";
|
|
97757
97812
|
}
|
|
97758
|
-
if (
|
|
97759
|
-
replyStateBtnIconImg.src =
|
|
97813
|
+
if (options2.logoReply) {
|
|
97814
|
+
replyStateBtnIconImg.src = options2.logoReply;
|
|
97760
97815
|
} else {
|
|
97761
97816
|
replyStateBtnIconImg.removeAttribute("src");
|
|
97762
97817
|
replyStateBtnIconImg.style.opacity = "0";
|
|
@@ -97776,19 +97831,17 @@ ${LEARN_MORE_LABEL}
|
|
|
97776
97831
|
} else {
|
|
97777
97832
|
if (isLocalStorageAvailable) {
|
|
97778
97833
|
try {
|
|
97779
|
-
|
|
97834
|
+
applyOptionsFromLocalStorage();
|
|
97780
97835
|
} catch (e) {
|
|
97781
97836
|
}
|
|
97782
97837
|
}
|
|
97783
97838
|
}
|
|
97784
|
-
function
|
|
97839
|
+
function applyOptionsFromLocalStorage() {
|
|
97785
97840
|
if (isLocalStorageAvailable) {
|
|
97786
97841
|
try {
|
|
97787
|
-
alanBtnSavedOptions = JSON.parse(localStorage.getItem(
|
|
97842
|
+
alanBtnSavedOptions = JSON.parse(localStorage.getItem(getBtnOptionsStorageKey()));
|
|
97788
97843
|
if (alanBtnSavedOptions && alanBtnSavedOptions.web) {
|
|
97789
|
-
|
|
97790
|
-
applyBtnOptions(alanBtnSavedOptions.web);
|
|
97791
|
-
}
|
|
97844
|
+
applyBtnOptions(getOptionsByTheme(alanBtnSavedOptions.web, options.theme));
|
|
97792
97845
|
}
|
|
97793
97846
|
} catch (e) {
|
|
97794
97847
|
}
|