@alan-ai/alan-sdk-web 1.8.72 → 1.8.73
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 +98 -55
- package/dist/alan_lib.min.js +1 -1
- package/package.json +1 -1
package/dist/alan_lib.js
CHANGED
|
@@ -35706,7 +35706,7 @@
|
|
|
35706
35706
|
function replaceUnsafeChar(ch) {
|
|
35707
35707
|
return HTML_REPLACEMENTS[ch];
|
|
35708
35708
|
}
|
|
35709
|
-
function
|
|
35709
|
+
function escapeHtml(str) {
|
|
35710
35710
|
if (HTML_ESCAPE_TEST_RE.test(str)) {
|
|
35711
35711
|
return str.replace(HTML_ESCAPE_REPLACE_RE, replaceUnsafeChar);
|
|
35712
35712
|
}
|
|
@@ -35801,7 +35801,7 @@
|
|
|
35801
35801
|
__proto__: null,
|
|
35802
35802
|
arrayReplaceAt,
|
|
35803
35803
|
assign,
|
|
35804
|
-
escapeHtml
|
|
35804
|
+
escapeHtml,
|
|
35805
35805
|
escapeRE,
|
|
35806
35806
|
fromCodePoint,
|
|
35807
35807
|
has,
|
|
@@ -35975,11 +35975,11 @@
|
|
|
35975
35975
|
var default_rules = {};
|
|
35976
35976
|
default_rules.code_inline = function(tokens, idx, options, env, slf) {
|
|
35977
35977
|
const token = tokens[idx];
|
|
35978
|
-
return "<code" + slf.renderAttrs(token) + ">" +
|
|
35978
|
+
return "<code" + slf.renderAttrs(token) + ">" + escapeHtml(token.content) + "</code>";
|
|
35979
35979
|
};
|
|
35980
35980
|
default_rules.code_block = function(tokens, idx, options, env, slf) {
|
|
35981
35981
|
const token = tokens[idx];
|
|
35982
|
-
return "<pre" + slf.renderAttrs(token) + "><code>" +
|
|
35982
|
+
return "<pre" + slf.renderAttrs(token) + "><code>" + escapeHtml(tokens[idx].content) + "</code></pre>\n";
|
|
35983
35983
|
};
|
|
35984
35984
|
default_rules.fence = function(tokens, idx, options, env, slf) {
|
|
35985
35985
|
const token = tokens[idx];
|
|
@@ -35993,9 +35993,9 @@
|
|
|
35993
35993
|
}
|
|
35994
35994
|
let highlighted;
|
|
35995
35995
|
if (options.highlight) {
|
|
35996
|
-
highlighted = options.highlight(token.content, langName, langAttrs) ||
|
|
35996
|
+
highlighted = options.highlight(token.content, langName, langAttrs) || escapeHtml(token.content);
|
|
35997
35997
|
} else {
|
|
35998
|
-
highlighted =
|
|
35998
|
+
highlighted = escapeHtml(token.content);
|
|
35999
35999
|
}
|
|
36000
36000
|
if (highlighted.indexOf("<pre") === 0) {
|
|
36001
36001
|
return highlighted + "\n";
|
|
@@ -36030,7 +36030,7 @@
|
|
|
36030
36030
|
return options.breaks ? options.xhtmlOut ? "<br />\n" : "<br>\n" : "\n";
|
|
36031
36031
|
};
|
|
36032
36032
|
default_rules.text = function(tokens, idx) {
|
|
36033
|
-
return
|
|
36033
|
+
return escapeHtml(tokens[idx].content);
|
|
36034
36034
|
};
|
|
36035
36035
|
default_rules.html_block = function(tokens, idx) {
|
|
36036
36036
|
return tokens[idx].content;
|
|
@@ -36048,7 +36048,7 @@
|
|
|
36048
36048
|
}
|
|
36049
36049
|
result = "";
|
|
36050
36050
|
for (i = 0, l = token.attrs.length; i < l; i++) {
|
|
36051
|
-
result += " " +
|
|
36051
|
+
result += " " + escapeHtml(token.attrs[i][0]) + '="' + escapeHtml(token.attrs[i][1]) + '"';
|
|
36052
36052
|
}
|
|
36053
36053
|
return result;
|
|
36054
36054
|
};
|
|
@@ -89509,12 +89509,53 @@
|
|
|
89509
89509
|
<path d="M17.2915 17.7085L29.3026 5.69727M17.4375 18.0837L20.4438 25.8143C20.7086 26.4954 20.8411 26.8358 21.0319 26.9352C21.1973 27.0215 21.3944 27.0216 21.5598 26.9356C21.7507 26.8364 21.8836 26.4961 22.1493 25.8153L29.688 6.4971C29.9279 5.88261 30.0478 5.57536 29.9821 5.37903C29.9252 5.20853 29.7914 5.07473 29.6209 5.01777C29.4246 4.95219 29.1173 5.07209 28.5028 5.31188L9.18467 12.8507C8.50392 13.1164 8.16361 13.2492 8.06444 13.4401C7.97841 13.6056 7.97852 13.8027 8.06477 13.9681C8.16418 14.1589 8.50473 14.2913 9.18571 14.5562L16.9163 17.5625C17.0545 17.6163 17.1236 17.6432 17.1818 17.6847C17.2334 17.7214 17.2784 17.7666 17.3153 17.8182C17.3568 17.8763 17.3837 17.9455 17.4375 18.0837Z" stroke="#4A515D" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
89510
89510
|
</svg>
|
|
89511
89511
|
`,
|
|
89512
|
+
msgLoader: `<svg xmlns="http://www.w3.org/2000/svg" class="alan-text-chat__msg-loader-svg" viewBox="0 0 200 200">
|
|
89513
|
+
<radialGradient id="a12" cx=".66" fx=".66" cy=".3125" fy=".3125" gradientTransform="scale(1.5)">
|
|
89514
|
+
<stop offset="0" stop-color="currentColor"></stop>
|
|
89515
|
+
<stop offset=".3" stop-color="currentColor" stop-opacity=".9"></stop>
|
|
89516
|
+
<stop offset=".6" stop-color="currentColor" stop-opacity=".6"></stop>
|
|
89517
|
+
<stop offset=".8" stop-color="currentColor" stop-opacity=".3"></stop>
|
|
89518
|
+
<stop offset="1" stop-color="currentColor" stop-opacity="0"></stop>
|
|
89519
|
+
</radialGradient>
|
|
89520
|
+
<circle
|
|
89521
|
+
transform-origin="center"
|
|
89522
|
+
fill="none"
|
|
89523
|
+
stroke="url(#a12)"
|
|
89524
|
+
stroke-width="15"
|
|
89525
|
+
stroke-linecap="round"
|
|
89526
|
+
stroke-dasharray="200 1000"
|
|
89527
|
+
stroke-dashoffset="0"
|
|
89528
|
+
cx="100"
|
|
89529
|
+
cy="100"
|
|
89530
|
+
r="70"
|
|
89531
|
+
>
|
|
89532
|
+
<animateTransform
|
|
89533
|
+
type="rotate"
|
|
89534
|
+
attributeName="transform"
|
|
89535
|
+
calcMode="spline"
|
|
89536
|
+
dur="2"
|
|
89537
|
+
values="360;0"
|
|
89538
|
+
keyTimes="0;1"
|
|
89539
|
+
keySplines="0 0 1 1"
|
|
89540
|
+
repeatCount="indefinite"
|
|
89541
|
+
></animateTransform>
|
|
89542
|
+
</circle>
|
|
89543
|
+
<circle
|
|
89544
|
+
transform-origin="center"
|
|
89545
|
+
fill="none"
|
|
89546
|
+
opacity=".2"
|
|
89547
|
+
stroke="currentColor"
|
|
89548
|
+
stroke-width="15"
|
|
89549
|
+
stroke-linecap="round"
|
|
89550
|
+
cx="100"
|
|
89551
|
+
cy="100"
|
|
89552
|
+
r="70"
|
|
89553
|
+
></circle>
|
|
89554
|
+
</svg>`,
|
|
89512
89555
|
stopResponse: `
|
|
89513
|
-
<svg width="
|
|
89514
|
-
<
|
|
89515
|
-
<circle cx="11" cy="11" r="10" stroke="black"/>
|
|
89556
|
+
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
89557
|
+
<rect x="6" y="6" width="8" height="8" rx="1" fill="#64AED5"/>
|
|
89516
89558
|
</svg>
|
|
89517
|
-
|
|
89518
89559
|
`,
|
|
89519
89560
|
mic: `
|
|
89520
89561
|
<svg width="28" height="28" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
@@ -89608,7 +89649,8 @@
|
|
|
89608
89649
|
const isQueryProgressEnabled = textChatOptions?.bubbles?.waitingResponse?.queryProgress?.enabled;
|
|
89609
89650
|
const waitingResponseBubbleLayout = textChatOptions?.bubbles?.waitingResponse?.layout || "default";
|
|
89610
89651
|
const isDefaultLayout = waitingResponseBubbleLayout === "default";
|
|
89611
|
-
|
|
89652
|
+
const hasCustomLoaderSvg = textChatOptions?.bubbles?.waitingResponse?.icon?.svg;
|
|
89653
|
+
let waitingResponseBubbleLabel = textChatOptions?.bubbles?.waitingResponse?.label || "Generating result";
|
|
89612
89654
|
if (message?.queryProgress) {
|
|
89613
89655
|
const unshownStatuses = message?.queryProgress?.filter((s) => s.isShown === false);
|
|
89614
89656
|
waitingResponseBubbleLabel = unshownStatuses?.length > 0 ? unshownStatuses[0].text : message?.queryProgress[message?.queryProgress?.length - 1].text || "";
|
|
@@ -89617,18 +89659,15 @@
|
|
|
89617
89659
|
if (onlyLoader) {
|
|
89618
89660
|
waitingResponseBubbleLabel = "";
|
|
89619
89661
|
}
|
|
89620
|
-
const content =
|
|
89621
|
-
|
|
89622
|
-
${waitingResponseBubbleLabel || ""}</span>
|
|
89623
|
-
<div class="alan-btn__chat-incomming-msg-inner-wrapper ${waitingResponseBubbleLabel === "" ? "" : "with-text"}"><div class="alan-btn__chat-incomming-msg msg-1"> </div> <div class="alan-btn__chat-incomming-msg msg-2"> </div> <div class="alan-btn__chat-incomming-msg msg-3"> </div></div>` : `<span class="alan-btn__chat-incomming-msg-loader-icon alan-btn__chat-stop-response-holder">
|
|
89624
|
-
${getMsgStopBtn(textChatOptions, false)}
|
|
89662
|
+
const content = `<span class="alan-btn__chat-incomming-msg-loader-icon alan-btn__chat-stop-response-holder">
|
|
89663
|
+
${!hasCustomLoaderSvg ? chatIcons.msgLoader : ""}${getMsgStopBtn(textChatOptions)}
|
|
89625
89664
|
</span>
|
|
89626
|
-
|
|
89665
|
+
<span class="alan-btn__chat-incomming-msg-loader-label">${waitingResponseBubbleLabel}</span>`;
|
|
89627
89666
|
return `<div class="alan-btn__chat-incomming-msg-wrapper">${content}</div>`;
|
|
89628
89667
|
}
|
|
89629
|
-
function getMsgStopBtn(textChatOptions
|
|
89630
|
-
const content = `<div class="alan-btn__stop-response-btn">${getStopChatIcon(textChatOptions)}</div>`;
|
|
89631
|
-
return
|
|
89668
|
+
function getMsgStopBtn(textChatOptions) {
|
|
89669
|
+
const content = `<div style="position:absolute;" class="alan-btn__stop-response-btn" title="Stop response generation">${getStopChatIcon(textChatOptions)}</div>`;
|
|
89670
|
+
return content;
|
|
89632
89671
|
}
|
|
89633
89672
|
function capitalize(str) {
|
|
89634
89673
|
return str.charAt(0).toUpperCase() + str.substring(1);
|
|
@@ -91247,6 +91286,9 @@
|
|
|
91247
91286
|
keyFrames += getStyleSheetMarker() + `.alan-btn__chat .alan-btn__chat-stop-response-holder {
|
|
91248
91287
|
cursor: pointer;
|
|
91249
91288
|
display: flex;
|
|
91289
|
+
justify-content: center;
|
|
91290
|
+
align-items: center;
|
|
91291
|
+
poisiton: relative;
|
|
91250
91292
|
}`;
|
|
91251
91293
|
keyFrames += getStyleSheetMarker() + `.alan-btn__chat .alan-btn__chat-stop-response-holder .alan-btn__stop-response-btn svg path {
|
|
91252
91294
|
stroke: ${stopResponseIconDefaultColor};
|
|
@@ -92177,6 +92219,15 @@
|
|
|
92177
92219
|
const responseBubbleBg = textChatOptions?.bubbles?.response?.backgroundColor || `#ffffff`;
|
|
92178
92220
|
const responseBubbleFontColor = textChatOptions?.bubbles?.response?.color || `#171717`;
|
|
92179
92221
|
const [responseLabelWidth, responseLabelHeight] = parseSvgSize(waitingResponseBubbleLoaderIcon);
|
|
92222
|
+
keyFrames += styleSheetMarker + `.alan-text-chat__msg-loader-svg {
|
|
92223
|
+
color: ${responseBubbleFontColor};
|
|
92224
|
+
min-width: 22px;
|
|
92225
|
+
max-width: 22px;
|
|
92226
|
+
width: 22px;
|
|
92227
|
+
min-height: 22px;
|
|
92228
|
+
max-height: 22px;
|
|
92229
|
+
height: 22px;
|
|
92230
|
+
}`;
|
|
92180
92231
|
keyFrames += styleSheetMarker + `.alan-btn__chat-incomming-msg-wrapper {
|
|
92181
92232
|
display: flex;
|
|
92182
92233
|
max-width: 100%;
|
|
@@ -92349,21 +92400,26 @@
|
|
|
92349
92400
|
// alan_btn/src/textChat/alanMarkdown.ts
|
|
92350
92401
|
var iterator = require_index_cjs();
|
|
92351
92402
|
var markdownItScrollTable = require_markdown_it_scrolltable();
|
|
92352
|
-
var
|
|
92353
|
-
"<
|
|
92354
|
-
"
|
|
92355
|
-
"<
|
|
92356
|
-
"
|
|
92357
|
-
"<thinking>": '<span class="alan-special-markdown-tag-hl-green"><thinking></span>',
|
|
92358
|
-
"</thinking>": '<span class="alan-special-markdown-tag-hl-green"></thinking></span>',
|
|
92359
|
-
"<reasoning>": '<span class="alan-special-markdown-tag-hl-green"><reasoning></span>',
|
|
92360
|
-
"</reasoning>": '<span class="alan-special-markdown-tag-hl-green"></reasoning></span>'
|
|
92403
|
+
var ESCAPE_CUSTOM_TAG_MAP = {
|
|
92404
|
+
"<thinking>": '<div class="alan-special-markdown-tag-wrapper"><span class="alan-special-markdown-tag-hl-green"><thinking></span>',
|
|
92405
|
+
"</thinking>": '<span class="alan-special-markdown-tag-hl-green"></thinking></span></div>',
|
|
92406
|
+
"<reasoning>": '<div class="alan-special-markdown-tag-wrapper"><span class="alan-special-markdown-tag-hl-green"><reasoning></span>',
|
|
92407
|
+
"</reasoning>": '<span class="alan-special-markdown-tag-hl-green"></reasoning></span></div>'
|
|
92361
92408
|
};
|
|
92362
92409
|
function alanMarkdown(str = "") {
|
|
92363
92410
|
var md = require_index_cjs5()({ html: true }).use(require_index_cjs6()).use(markdownItScrollTable).use(iterator, "url_new_win", "link_open", function(tokens, idx) {
|
|
92364
92411
|
tokens[idx].attrSet("target", "_blank");
|
|
92365
92412
|
});
|
|
92366
|
-
return sanitize(md.render(str || ""));
|
|
92413
|
+
return sanitize(md.render(sanitizeCustomTags(str || "")));
|
|
92414
|
+
}
|
|
92415
|
+
function sanitizeCustomTags(str) {
|
|
92416
|
+
let result = str;
|
|
92417
|
+
for (const [tag, replacement] of Object.entries(ESCAPE_CUSTOM_TAG_MAP)) {
|
|
92418
|
+
const tagRegex = new RegExp(tag.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g");
|
|
92419
|
+
result = result.replace(tagRegex, replacement);
|
|
92420
|
+
}
|
|
92421
|
+
console.info("result", result);
|
|
92422
|
+
return result;
|
|
92367
92423
|
}
|
|
92368
92424
|
function sanitize(str) {
|
|
92369
92425
|
let tag = "";
|
|
@@ -92378,16 +92434,6 @@
|
|
|
92378
92434
|
break;
|
|
92379
92435
|
}
|
|
92380
92436
|
}
|
|
92381
|
-
for (const escapedTag in ESCAPE_TAG_MAP) {
|
|
92382
|
-
if (tag.startsWith(escapedTag)) {
|
|
92383
|
-
result += escapeHtml(tag);
|
|
92384
|
-
tag = "";
|
|
92385
|
-
if (str[i + 1] === "\n" && str[i + 2] === "<") {
|
|
92386
|
-
result += "<br/>";
|
|
92387
|
-
}
|
|
92388
|
-
break;
|
|
92389
|
-
}
|
|
92390
|
-
}
|
|
92391
92437
|
if (tag !== "") {
|
|
92392
92438
|
result += tag;
|
|
92393
92439
|
tag = "";
|
|
@@ -92398,14 +92444,6 @@
|
|
|
92398
92444
|
}
|
|
92399
92445
|
return result;
|
|
92400
92446
|
}
|
|
92401
|
-
function escapeHtml(text) {
|
|
92402
|
-
let resultStr = text;
|
|
92403
|
-
for (const key in ESCAPE_TAG_MAP) {
|
|
92404
|
-
var r = new RegExp(`${key}`, "gi");
|
|
92405
|
-
resultStr = String(resultStr).replace(r, ESCAPE_TAG_MAP[key]);
|
|
92406
|
-
}
|
|
92407
|
-
return resultStr;
|
|
92408
|
-
}
|
|
92409
92447
|
|
|
92410
92448
|
// alan_btn/src/textChat/helpers/getLinkIcon.ts
|
|
92411
92449
|
function getLinkIcon(link) {
|
|
@@ -93924,9 +93962,14 @@ code.hljs {
|
|
|
93924
93962
|
;
|
|
93925
93963
|
}
|
|
93926
93964
|
|
|
93965
|
+
// alan_btn/src/textChat/helpers/shouldTextBeSavedInChatHistory.ts
|
|
93966
|
+
function shouldTextBeSavedInChatHistory(text, sentMessages) {
|
|
93967
|
+
return sentMessages?.at(-1) !== text;
|
|
93968
|
+
}
|
|
93969
|
+
|
|
93927
93970
|
// alan_btn/alan_btn.ts
|
|
93928
93971
|
(function(ns) {
|
|
93929
|
-
uiState.lib.version = "alan-version.1.8.
|
|
93972
|
+
uiState.lib.version = "alan-version.1.8.73".replace("alan-version.", "");
|
|
93930
93973
|
if (window.alanBtn) {
|
|
93931
93974
|
console.warn("Alan: the Alan Button source code has already added (v." + uiState.lib.version + ")");
|
|
93932
93975
|
}
|
|
@@ -95826,7 +95869,7 @@ code.hljs {
|
|
|
95826
95869
|
logosToHide[i2].style.opacity = 0;
|
|
95827
95870
|
}
|
|
95828
95871
|
}
|
|
95829
|
-
function
|
|
95872
|
+
function escapeHtml(text) {
|
|
95830
95873
|
let resultStr = text;
|
|
95831
95874
|
var entityMap = {
|
|
95832
95875
|
"<script>": "<script>",
|
|
@@ -96092,7 +96135,7 @@ code.hljs {
|
|
|
96092
96135
|
if (msg.ctx?.format === "markdown") {
|
|
96093
96136
|
result = alanMarkdown(msg.text || "");
|
|
96094
96137
|
} else {
|
|
96095
|
-
result =
|
|
96138
|
+
result = escapeHtml(msg.text);
|
|
96096
96139
|
}
|
|
96097
96140
|
return result ? `<span class="alan-btn__chat-response-text-wrapper">${fixTargetForLinks(result)}</span>` : "";
|
|
96098
96141
|
}
|
|
@@ -96202,7 +96245,7 @@ ${LEARN_MORE_LABEL}
|
|
|
96202
96245
|
} else {
|
|
96203
96246
|
if (msg.name === "text" || msg.name === "parsed" || msg.name === "recognized") {
|
|
96204
96247
|
if (msg.type === "request") {
|
|
96205
|
-
innerMsgPart =
|
|
96248
|
+
innerMsgPart = escapeHtml(msg.text);
|
|
96206
96249
|
} else {
|
|
96207
96250
|
innerMsgPart = buildMsgContent(msg);
|
|
96208
96251
|
}
|
|
@@ -96663,7 +96706,7 @@ ${LEARN_MORE_LABEL}
|
|
|
96663
96706
|
if (isLocalStorageAvailable) {
|
|
96664
96707
|
const maxSavedForHistoryMsgCount = 25;
|
|
96665
96708
|
const key = getRestoreMsgsLsKey();
|
|
96666
|
-
if (
|
|
96709
|
+
if (!shouldTextBeSavedInChatHistory(text, sentMessages))
|
|
96667
96710
|
return;
|
|
96668
96711
|
sentMessages.push(text);
|
|
96669
96712
|
if (sentMessages.length > 50) {
|