@alan-ai/alan-sdk-web 1.8.131 → 1.8.133
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 +110 -43
- package/dist/alan_lib.min.js +1 -1
- package/package.json +1 -1
package/dist/alan_lib.js
CHANGED
|
@@ -85739,6 +85739,7 @@
|
|
|
85739
85739
|
function copyTextToBuffer(text3) {
|
|
85740
85740
|
const el = document.createElement("textarea");
|
|
85741
85741
|
el.value = text3;
|
|
85742
|
+
el.setAttribute("name", "alan-copy-textarea-" + Date.now());
|
|
85742
85743
|
document.body.appendChild(el);
|
|
85743
85744
|
el.select();
|
|
85744
85745
|
document.execCommand("copy");
|
|
@@ -85772,7 +85773,7 @@
|
|
|
85772
85773
|
const placeholderText = iframeText ? `Embedded content: ${iframeText}` : "Embedded content";
|
|
85773
85774
|
const placeholderDiv = document.createElement("div");
|
|
85774
85775
|
placeholderDiv.style.cssText = "width: 100%; min-height: 20px; border: 1px solid #ccc; padding: 10px; box-sizing: border-box; font-style: italic; color: #666;";
|
|
85775
|
-
placeholderDiv.innerHTML = `${placeholderText}<br><br><
|
|
85776
|
+
placeholderDiv.innerHTML = `${placeholderText}<br><br><a href="${iframe.src}" target="_blank">${iframe.src}</a>`;
|
|
85776
85777
|
embedContainer.replaceWith(placeholderDiv);
|
|
85777
85778
|
}
|
|
85778
85779
|
});
|
|
@@ -85805,9 +85806,35 @@
|
|
|
85805
85806
|
font-weight: bold !important;
|
|
85806
85807
|
}
|
|
85807
85808
|
`;
|
|
85808
|
-
|
|
85809
|
+
let inlinedHtml;
|
|
85810
|
+
try {
|
|
85811
|
+
inlinedHtml = juice.inlineContent(rawHtml, css2);
|
|
85812
|
+
} catch (err) {
|
|
85813
|
+
console.warn("Failed to inline styles with Juice (possible DOM clobbering):", err);
|
|
85814
|
+
inlinedHtml = rawHtml;
|
|
85815
|
+
}
|
|
85809
85816
|
const blobHtml = new Blob([inlinedHtml], { type: "text/html" });
|
|
85810
|
-
const
|
|
85817
|
+
const codeBlocks = [];
|
|
85818
|
+
const tempElement = bubbleToCopy.cloneNode(true);
|
|
85819
|
+
tempElement.querySelectorAll("pre").forEach((pre, index2) => {
|
|
85820
|
+
const placeholder = `<<<CODE_BLOCK_${index2}>>>`;
|
|
85821
|
+
codeBlocks.push(pre.textContent || "");
|
|
85822
|
+
pre.textContent = placeholder;
|
|
85823
|
+
});
|
|
85824
|
+
let plainText = tempElement.innerText;
|
|
85825
|
+
const lines = plainText.split("\n");
|
|
85826
|
+
const processedLines = lines.map((line) => {
|
|
85827
|
+
if (line.includes("<<<CODE_BLOCK_")) {
|
|
85828
|
+
return line;
|
|
85829
|
+
}
|
|
85830
|
+
return line.replace(/[ \t]+/g, " ").trim();
|
|
85831
|
+
});
|
|
85832
|
+
plainText = processedLines.join("\n");
|
|
85833
|
+
codeBlocks.forEach((code2, index2) => {
|
|
85834
|
+
const placeholder = `<<<CODE_BLOCK_${index2}>>>`;
|
|
85835
|
+
plainText = plainText.replace(placeholder, "\n\n" + code2);
|
|
85836
|
+
});
|
|
85837
|
+
plainText = plainText.replace(/\n{3,}/g, "\n\n").trim();
|
|
85811
85838
|
const blobText = new Blob([plainText], { type: "text/plain" });
|
|
85812
85839
|
const data3 = [new ClipboardItem({
|
|
85813
85840
|
"text/html": blobHtml,
|
|
@@ -89356,7 +89383,7 @@
|
|
|
89356
89383
|
hasFooterLinks = !!tempNode.querySelector(".footnotes");
|
|
89357
89384
|
tempNode.remove();
|
|
89358
89385
|
}
|
|
89359
|
-
const links = msg.links?.filter((link) =>
|
|
89386
|
+
const links = msg.links?.filter((link) => isValidUrl(link?.href));
|
|
89360
89387
|
for (let i = 0; i < links?.length; i++) {
|
|
89361
89388
|
const curLink = links[i];
|
|
89362
89389
|
const target = getLinkTarget(curLink);
|
|
@@ -89383,7 +89410,7 @@
|
|
|
89383
89410
|
return "_blank";
|
|
89384
89411
|
}
|
|
89385
89412
|
}
|
|
89386
|
-
function
|
|
89413
|
+
function isValidUrl(url) {
|
|
89387
89414
|
try {
|
|
89388
89415
|
const parsedUrl = new URL(url);
|
|
89389
89416
|
const hasValidProtocol = parsedUrl.protocol === "http:" || parsedUrl.protocol === "https:";
|
|
@@ -98713,6 +98740,7 @@ var hljs=function(){"use strict";function e(n){return n instanceof Map?n.clear=n
|
|
|
98713
98740
|
inlineScript.setAttribute(attr2.name, attr2.value);
|
|
98714
98741
|
}
|
|
98715
98742
|
});
|
|
98743
|
+
inlineScript.setAttribute("inlined-resource-name", src);
|
|
98716
98744
|
inlineScript.textContent = scriptContent;
|
|
98717
98745
|
scriptTag.parentNode.replaceChild(inlineScript, scriptTag);
|
|
98718
98746
|
console.log(`Inlined script from ${src}`);
|
|
@@ -98726,6 +98754,7 @@ var hljs=function(){"use strict";function e(n){return n instanceof Map?n.clear=n
|
|
|
98726
98754
|
try {
|
|
98727
98755
|
const cssContent = await fetchResourceWithCache(href);
|
|
98728
98756
|
const inlineStyle = doc.createElement("style");
|
|
98757
|
+
inlineStyle.setAttribute("inlined-resource-name", href);
|
|
98729
98758
|
inlineStyle.textContent = cssContent;
|
|
98730
98759
|
linkTag.parentNode.replaceChild(inlineStyle, linkTag);
|
|
98731
98760
|
console.log(`Inlined stylesheet from ${href}`);
|
|
@@ -98762,48 +98791,58 @@ var hljs=function(){"use strict";function e(n){return n instanceof Map?n.clear=n
|
|
|
98762
98791
|
const getStudioResourceUrlFn = extractFunction(code, "getStudioResourceUrl");
|
|
98763
98792
|
const getProjectResourceUrlFn = extractFunction(code, "getProjectResourceUrl");
|
|
98764
98793
|
const getDefaultResourcesFn = extractFunction(code, "getDefaultResources");
|
|
98765
|
-
let
|
|
98766
|
-
let
|
|
98767
|
-
let
|
|
98768
|
-
let
|
|
98769
|
-
let
|
|
98794
|
+
let iframeGetResourceUrl = null;
|
|
98795
|
+
let iframeGetStudioResourceUrl = null;
|
|
98796
|
+
let iframeGetProjectResourceUrl = null;
|
|
98797
|
+
let iframeIsValidUrl = null;
|
|
98798
|
+
let iframeGetDefaultResources = null;
|
|
98770
98799
|
try {
|
|
98771
|
-
|
|
98772
|
-
|
|
98773
|
-
|
|
98774
|
-
|
|
98775
|
-
|
|
98776
|
-
|
|
98777
|
-
|
|
98778
|
-
|
|
98779
|
-
|
|
98780
|
-
|
|
98781
|
-
|
|
98782
|
-
|
|
98783
|
-
|
|
98784
|
-
|
|
98800
|
+
const extracted = eval(`
|
|
98801
|
+
(function() {
|
|
98802
|
+
const isValidUrl = ${isValidUrlFn || "null"};
|
|
98803
|
+
const getResourceUrl = ${getResourceUrlFn || "null"};
|
|
98804
|
+
const getStudioResourceUrl = ${getStudioResourceUrlFn || "null"};
|
|
98805
|
+
const getProjectResourceUrl = ${getProjectResourceUrlFn || "null"};
|
|
98806
|
+
const getDefaultResources = ${getDefaultResourcesFn || "null"};
|
|
98807
|
+
|
|
98808
|
+
return {
|
|
98809
|
+
isValidUrl,
|
|
98810
|
+
getResourceUrl,
|
|
98811
|
+
getStudioResourceUrl,
|
|
98812
|
+
getProjectResourceUrl,
|
|
98813
|
+
getDefaultResources
|
|
98814
|
+
};
|
|
98815
|
+
})()
|
|
98816
|
+
`);
|
|
98817
|
+
if (extracted) {
|
|
98818
|
+
iframeIsValidUrl = extracted.isValidUrl;
|
|
98819
|
+
iframeGetResourceUrl = extracted.getResourceUrl;
|
|
98820
|
+
iframeGetStudioResourceUrl = extracted.getStudioResourceUrl;
|
|
98821
|
+
iframeGetProjectResourceUrl = extracted.getProjectResourceUrl;
|
|
98822
|
+
iframeGetDefaultResources = extracted.getDefaultResources;
|
|
98785
98823
|
}
|
|
98786
98824
|
} catch (error) {
|
|
98787
98825
|
console.error("Failed to parse resource-related functions using eval:", error);
|
|
98788
98826
|
}
|
|
98789
98827
|
let hasInternalFunctions = true;
|
|
98790
|
-
if (!
|
|
98828
|
+
if (!iframeGetResourceUrl || !iframeGetStudioResourceUrl || !iframeGetProjectResourceUrl || !iframeIsValidUrl || !iframeGetDefaultResources) {
|
|
98791
98829
|
hasInternalFunctions = false;
|
|
98792
98830
|
console.error("Unable to parse resource-related functions from the iframe code. Some iframes may appear without content.");
|
|
98793
98831
|
}
|
|
98794
98832
|
allInitIframeResourcesInlined = true;
|
|
98795
98833
|
if (hasInternalFunctions) {
|
|
98796
98834
|
const addDefaultStylesOptions = extractAddDefaultStylesParams(initIframeBody);
|
|
98797
|
-
if (addDefaultStylesOptions &&
|
|
98835
|
+
if (addDefaultStylesOptions && iframeGetDefaultResources) {
|
|
98798
98836
|
try {
|
|
98799
|
-
const basicResources =
|
|
98837
|
+
const basicResources = iframeGetDefaultResources(addDefaultStylesOptions);
|
|
98800
98838
|
await Promise.all(basicResources.map(async (resource) => {
|
|
98801
98839
|
try {
|
|
98802
98840
|
const resourceType = resource.type;
|
|
98803
98841
|
if (resourceType === "stylesheet" && resource.href) {
|
|
98804
|
-
const resourceUrl =
|
|
98842
|
+
const resourceUrl = iframeGetResourceUrl(resource.href);
|
|
98805
98843
|
const resourceContent = await fetchResourceWithCache(resourceUrl);
|
|
98806
98844
|
const inlineStyle = doc.createElement("style");
|
|
98845
|
+
inlineStyle.setAttribute("inlined-resource-name", resource.href);
|
|
98807
98846
|
inlineStyle.textContent = resourceContent;
|
|
98808
98847
|
doc.head.appendChild(inlineStyle);
|
|
98809
98848
|
console.log(`Inlined basic style from getDefaultResources: ${resourceUrl}`);
|
|
@@ -98816,12 +98855,36 @@ var hljs=function(){"use strict";function e(n){return n instanceof Map?n.clear=n
|
|
|
98816
98855
|
console.error("Failed to get or inline basic resources:", error);
|
|
98817
98856
|
}
|
|
98818
98857
|
}
|
|
98819
|
-
await Promise.all(resourceUrls.map(async (resource) => {
|
|
98858
|
+
const resourceResults = await Promise.all(resourceUrls.map(async (resource) => {
|
|
98820
98859
|
try {
|
|
98821
|
-
const resourceUrl =
|
|
98860
|
+
const resourceUrl = iframeGetResourceUrl(resource.url);
|
|
98822
98861
|
const resourceContent = await fetchResourceWithCache(resourceUrl);
|
|
98862
|
+
return {
|
|
98863
|
+
success: true,
|
|
98864
|
+
resource,
|
|
98865
|
+
resourceUrl,
|
|
98866
|
+
resourceContent
|
|
98867
|
+
};
|
|
98868
|
+
} catch (error) {
|
|
98869
|
+
console.error(`Failed to fetch resource from ${resource.url}:`, error);
|
|
98870
|
+
return {
|
|
98871
|
+
success: false,
|
|
98872
|
+
resource,
|
|
98873
|
+
error
|
|
98874
|
+
};
|
|
98875
|
+
}
|
|
98876
|
+
}));
|
|
98877
|
+
let insertionPoint = doc.head.firstChild;
|
|
98878
|
+
for (const result of resourceResults) {
|
|
98879
|
+
if (!result.success) {
|
|
98880
|
+
allInitIframeResourcesInlined = false;
|
|
98881
|
+
continue;
|
|
98882
|
+
}
|
|
98883
|
+
const { resource, resourceUrl, resourceContent } = result;
|
|
98884
|
+
try {
|
|
98823
98885
|
if (resource.type === "addScript" || resource.url.endsWith(".js")) {
|
|
98824
98886
|
const inlineScript = doc.createElement("script");
|
|
98887
|
+
inlineScript.setAttribute("inlined-resource-name", resource.url);
|
|
98825
98888
|
inlineScript.textContent = resourceContent;
|
|
98826
98889
|
if (resource.options) {
|
|
98827
98890
|
const optionsObj = safelyParseScriptOptions(resource.options);
|
|
@@ -98835,19 +98898,22 @@ var hljs=function(){"use strict";function e(n){return n instanceof Map?n.clear=n
|
|
|
98835
98898
|
if (optionsObj.crossOrigin) inlineScript.setAttribute("crossorigin", optionsObj.crossOrigin);
|
|
98836
98899
|
}
|
|
98837
98900
|
}
|
|
98838
|
-
doc.head.
|
|
98901
|
+
doc.head.insertBefore(inlineScript, insertionPoint);
|
|
98902
|
+
insertionPoint = inlineScript.nextSibling;
|
|
98839
98903
|
console.log(`Inlined script: ${resourceUrl}${inlineScript.type ? " (type=" + inlineScript.type + ")" : ""}`);
|
|
98840
98904
|
} else if (resource.type === "addStyleSheet" || resource.url.endsWith(".css")) {
|
|
98841
98905
|
const inlineStyle = doc.createElement("style");
|
|
98906
|
+
inlineStyle.setAttribute("inlined-resource-name", resource.url);
|
|
98842
98907
|
inlineStyle.textContent = resourceContent;
|
|
98843
|
-
doc.head.
|
|
98908
|
+
doc.head.insertBefore(inlineStyle, insertionPoint);
|
|
98909
|
+
insertionPoint = inlineStyle.nextSibling;
|
|
98844
98910
|
console.log(`Inlined stylesheet: ${resourceUrl}`);
|
|
98845
98911
|
}
|
|
98846
98912
|
} catch (error) {
|
|
98847
98913
|
console.error(`Failed to inline resource from ${resource.url}:`, error);
|
|
98848
98914
|
allInitIframeResourcesInlined = false;
|
|
98849
98915
|
}
|
|
98850
|
-
}
|
|
98916
|
+
}
|
|
98851
98917
|
}
|
|
98852
98918
|
}
|
|
98853
98919
|
return {
|
|
@@ -99026,7 +99092,7 @@ var hljs=function(){"use strict";function e(n){return n instanceof Map?n.clear=n
|
|
|
99026
99092
|
}
|
|
99027
99093
|
|
|
99028
99094
|
// alan_btn/src/textChat/helpers/resources.ts
|
|
99029
|
-
function
|
|
99095
|
+
function isValidUrl2(url) {
|
|
99030
99096
|
try {
|
|
99031
99097
|
new URL(url);
|
|
99032
99098
|
return true;
|
|
@@ -99034,21 +99100,21 @@ var hljs=function(){"use strict";function e(n){return n instanceof Map?n.clear=n
|
|
|
99034
99100
|
return false;
|
|
99035
99101
|
}
|
|
99036
99102
|
}
|
|
99037
|
-
function
|
|
99103
|
+
function getProjectResourceUrl(resourcePath) {
|
|
99038
99104
|
const resourceBaseUrl = uiState.resourceBaseUrl;
|
|
99039
99105
|
return `${resourceBaseUrl}/` + resourcePath;
|
|
99040
99106
|
}
|
|
99041
|
-
function
|
|
99107
|
+
function getResourceUrl(resourceUrl) {
|
|
99042
99108
|
const resourceBaseUrl = uiState.resourceBaseUrl;
|
|
99043
99109
|
const projectResPrefix = "resource://";
|
|
99044
99110
|
const studioResPrefix = "studio-resource://";
|
|
99045
|
-
const withPublicUrl =
|
|
99111
|
+
const withPublicUrl = isValidUrl2(resourceUrl);
|
|
99046
99112
|
if (!resourceUrl) {
|
|
99047
99113
|
return `${resourceBaseUrl}`;
|
|
99048
99114
|
}
|
|
99049
99115
|
if (!withPublicUrl || resourceUrl.startsWith(projectResPrefix)) {
|
|
99050
99116
|
const cleanResource = resourceUrl.startsWith(projectResPrefix) ? resourceUrl.slice(projectResPrefix.length) : resourceUrl;
|
|
99051
|
-
return
|
|
99117
|
+
return getProjectResourceUrl(cleanResource);
|
|
99052
99118
|
}
|
|
99053
99119
|
return resourceUrl;
|
|
99054
99120
|
}
|
|
@@ -99057,19 +99123,19 @@ var hljs=function(){"use strict";function e(n){return n instanceof Map?n.clear=n
|
|
|
99057
99123
|
let el;
|
|
99058
99124
|
if (resource.type === "script" && resource.src) {
|
|
99059
99125
|
el = document.createElement("script");
|
|
99060
|
-
el.src =
|
|
99126
|
+
el.src = getResourceUrl(resource.src);
|
|
99061
99127
|
el.onload = () => resolve(resource);
|
|
99062
99128
|
el.onerror = () => reject(new Error("Failed to load script:", resource.src));
|
|
99063
99129
|
} else if (resource.type === "stylesheet" && resource.href) {
|
|
99064
99130
|
el = document.createElement("link");
|
|
99065
99131
|
el.rel = "stylesheet";
|
|
99066
|
-
el.href =
|
|
99132
|
+
el.href = getResourceUrl(resource.href);
|
|
99067
99133
|
el.onload = () => resolve(resource);
|
|
99068
99134
|
el.onerror = () => reject(new Error("Failed to load stylesheet:", resource.href));
|
|
99069
99135
|
} else if (resource.type === "font" && resource.href) {
|
|
99070
99136
|
el = document.createElement("link");
|
|
99071
99137
|
el.rel = "stylesheet";
|
|
99072
|
-
el.href =
|
|
99138
|
+
el.href = getResourceUrl(resource.href);
|
|
99073
99139
|
el.onload = () => resolve(resource);
|
|
99074
99140
|
el.onerror = () => reject(new Error("Failed to load stylesheet:", resource.href));
|
|
99075
99141
|
}
|
|
@@ -99113,7 +99179,7 @@ var hljs=function(){"use strict";function e(n){return n instanceof Map?n.clear=n
|
|
|
99113
99179
|
// alan_btn/alan_btn.ts
|
|
99114
99180
|
(function(ns) {
|
|
99115
99181
|
const uiState10 = getUIState();
|
|
99116
|
-
const version2 = "alan-version.1.8.
|
|
99182
|
+
const version2 = "alan-version.1.8.133".replace("alan-version.", "");
|
|
99117
99183
|
uiState10.lib.version = version2;
|
|
99118
99184
|
window.alanLib = { version: version2 };
|
|
99119
99185
|
if (window.alanBtn) {
|
|
@@ -101675,7 +101741,8 @@ ${curDialogId}`);
|
|
|
101675
101741
|
".alan-btn__chat-graph",
|
|
101676
101742
|
".alan-btn__chat-suggestions",
|
|
101677
101743
|
".alan-btn__chat-response-imgs-wrapper-right-arrow",
|
|
101678
|
-
".alan-btn__chat-response-imgs-wrapper-left-arrow"
|
|
101744
|
+
".alan-btn__chat-response-imgs-wrapper-left-arrow",
|
|
101745
|
+
".alan-btn__chat-response__copy-code-btn"
|
|
101679
101746
|
],
|
|
101680
101747
|
[
|
|
101681
101748
|
".alan-btn__chat-response-img"
|