diff --git a/dist/alan_lib.js b/dist/alan_lib.js index 734d494..a7424fa 100644 --- a/dist/alan_lib.js +++ b/dist/alan_lib.js @@ -35706,7 +35706,7 @@ function replaceUnsafeChar(ch) { return HTML_REPLACEMENTS[ch]; } - function escapeHtml2(str) { + function escapeHtml(str) { if (HTML_ESCAPE_TEST_RE.test(str)) { return str.replace(HTML_ESCAPE_REPLACE_RE, replaceUnsafeChar); } @@ -35801,7 +35801,7 @@ __proto__: null, arrayReplaceAt, assign, - escapeHtml: escapeHtml2, + escapeHtml, escapeRE, fromCodePoint, has, @@ -35975,11 +35975,11 @@ var default_rules = {}; default_rules.code_inline = function(tokens, idx, options, env, slf) { const token = tokens[idx]; - return "" + escapeHtml2(token.content) + ""; + return "" + escapeHtml(token.content) + ""; }; default_rules.code_block = function(tokens, idx, options, env, slf) { const token = tokens[idx]; - return "" + escapeHtml2(tokens[idx].content) + "\n"; + return "" + escapeHtml(tokens[idx].content) + "\n"; }; default_rules.fence = function(tokens, idx, options, env, slf) { const token = tokens[idx]; @@ -35993,9 +35993,9 @@ } let highlighted; if (options.highlight) { - highlighted = options.highlight(token.content, langName, langAttrs) || escapeHtml2(token.content); + highlighted = options.highlight(token.content, langName, langAttrs) || escapeHtml(token.content); } else { - highlighted = escapeHtml2(token.content); + highlighted = escapeHtml(token.content); } if (highlighted.indexOf("\n" : "
\n" : "\n"; }; default_rules.text = function(tokens, idx) { - return escapeHtml2(tokens[idx].content); + return escapeHtml(tokens[idx].content); }; default_rules.html_block = function(tokens, idx) { return tokens[idx].content; @@ -36048,7 +36048,7 @@ } result = ""; for (i = 0, l = token.attrs.length; i < l; i++) { - result += " " + escapeHtml2(token.attrs[i][0]) + '="' + escapeHtml2(token.attrs[i][1]) + '"'; + result += " " + escapeHtml(token.attrs[i][0]) + '="' + escapeHtml(token.attrs[i][1]) + '"'; } return result; }; @@ -89509,12 +89509,53 @@ `, + msgLoader: ` + + + + + + + + + + + +`, stopResponse: ` - - - + + - `, mic: ` @@ -89608,7 +89649,8 @@ const isQueryProgressEnabled = textChatOptions?.bubbles?.waitingResponse?.queryProgress?.enabled; const waitingResponseBubbleLayout = textChatOptions?.bubbles?.waitingResponse?.layout || "default"; const isDefaultLayout = waitingResponseBubbleLayout === "default"; - let waitingResponseBubbleLabel = !isDefaultLayout || isQueryProgressEnabled ? isDefaultLayout ? "" : textChatOptions?.bubbles?.waitingResponse?.label || "Generating result" : ""; + const hasCustomLoaderSvg = textChatOptions?.bubbles?.waitingResponse?.icon?.svg; + let waitingResponseBubbleLabel = textChatOptions?.bubbles?.waitingResponse?.label || "Generating result"; if (message?.queryProgress) { const unshownStatuses = message?.queryProgress?.filter((s) => s.isShown === false); waitingResponseBubbleLabel = unshownStatuses?.length > 0 ? unshownStatuses[0].text : message?.queryProgress[message?.queryProgress?.length - 1].text || ""; @@ -89617,18 +89659,15 @@ if (onlyLoader) { waitingResponseBubbleLabel = ""; } - const content = isDefaultLayout ? ` - ${getMsgStopBtn(textChatOptions, true)} - ${waitingResponseBubbleLabel || ""} -
 
 
 
` : ` - ${getMsgStopBtn(textChatOptions, false)} + const content = ` + ${!hasCustomLoaderSvg ? chatIcons.msgLoader : ""}${getMsgStopBtn(textChatOptions)} - ${waitingResponseBubbleLabel}`; + ${waitingResponseBubbleLabel}`; return `
${content}
`; } - function getMsgStopBtn(textChatOptions, shouldBeWrapped) { - const content = `
${getStopChatIcon(textChatOptions)}
`; - return shouldBeWrapped ? `
${content}
` : content; + function getMsgStopBtn(textChatOptions) { + const content = `
${getStopChatIcon(textChatOptions)}
`; + return content; } function capitalize(str) { return str.charAt(0).toUpperCase() + str.substring(1); @@ -91247,6 +91286,9 @@ keyFrames += getStyleSheetMarker() + `.alan-btn__chat .alan-btn__chat-stop-response-holder { cursor: pointer; display: flex; + justify-content: center; + align-items: center; + poisiton: relative; }`; keyFrames += getStyleSheetMarker() + `.alan-btn__chat .alan-btn__chat-stop-response-holder .alan-btn__stop-response-btn svg path { stroke: ${stopResponseIconDefaultColor}; @@ -92177,6 +92219,15 @@ const responseBubbleBg = textChatOptions?.bubbles?.response?.backgroundColor || `#ffffff`; const responseBubbleFontColor = textChatOptions?.bubbles?.response?.color || `#171717`; const [responseLabelWidth, responseLabelHeight] = parseSvgSize(waitingResponseBubbleLoaderIcon); + keyFrames += styleSheetMarker + `.alan-text-chat__msg-loader-svg { + color: ${responseBubbleFontColor}; + min-width: 22px; + max-width: 22px; + width: 22px; + min-height: 22px; + max-height: 22px; + height: 22px; + }`; keyFrames += styleSheetMarker + `.alan-btn__chat-incomming-msg-wrapper { display: flex; max-width: 100%; @@ -92349,21 +92400,26 @@ // alan_btn/src/textChat/alanMarkdown.ts var iterator = require_index_cjs(); var markdownItScrollTable = require_markdown_it_scrolltable(); - var ESCAPE_TAG_MAP = { - "": '<thinking>', - "": '</thinking>', - "": '<reasoning>', - "": '</reasoning>' + var ESCAPE_CUSTOM_TAG_MAP = { + "": '
<thinking>', + "": '</thinking>
', + "": '
<reasoning>', + "": '</reasoning>
' }; function alanMarkdown(str = "") { var md = require_index_cjs5()({ html: true }).use(require_index_cjs6()).use(markdownItScrollTable).use(iterator, "url_new_win", "link_open", function(tokens, idx) { tokens[idx].attrSet("target", "_blank"); }); - return sanitize(md.render(str || "")); + return sanitize(md.render(sanitizeCustomTags(str || ""))); + } + function sanitizeCustomTags(str) { + let result = str; + for (const [tag, replacement] of Object.entries(ESCAPE_CUSTOM_TAG_MAP)) { + const tagRegex = new RegExp(tag.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"); + result = result.replace(tagRegex, replacement); + } + console.info("result", result); + return result; } function sanitize(str) { let tag = ""; @@ -92378,16 +92434,6 @@ break; } } - for (const escapedTag in ESCAPE_TAG_MAP) { - if (tag.startsWith(escapedTag)) { - result += escapeHtml(tag); - tag = ""; - if (str[i + 1] === "\n" && str[i + 2] === "<") { - result += "
"; - } - break; - } - } if (tag !== "") { result += tag; tag = ""; @@ -92398,14 +92444,6 @@ } return result; } - function escapeHtml(text) { - let resultStr = text; - for (const key in ESCAPE_TAG_MAP) { - var r = new RegExp(`${key}`, "gi"); - resultStr = String(resultStr).replace(r, ESCAPE_TAG_MAP[key]); - } - return resultStr; - } // alan_btn/src/textChat/helpers/getLinkIcon.ts function getLinkIcon(link) { @@ -93924,9 +93962,14 @@ code.hljs { ; } + // alan_btn/src/textChat/helpers/shouldTextBeSavedInChatHistory.ts + function shouldTextBeSavedInChatHistory(text, sentMessages) { + return sentMessages?.at(-1) !== text; + } + // alan_btn/alan_btn.ts (function(ns) { - uiState.lib.version = "alan-version.1.8.72".replace("alan-version.", ""); + uiState.lib.version = "alan-version.1.8.73".replace("alan-version.", ""); if (window.alanBtn) { console.warn("Alan: the Alan Button source code has already added (v." + uiState.lib.version + ")"); } @@ -95826,7 +95869,7 @@ code.hljs { logosToHide[i2].style.opacity = 0; } } - function escapeHtml2(text) { + function escapeHtml(text) { let resultStr = text; var entityMap = { "