@alan-ai/alan-sdk-web 1.8.64 → 1.8.65

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 CHANGED
@@ -8739,11 +8739,11 @@
8739
8739
  if (href2) {
8740
8740
  entry.link = href2;
8741
8741
  }
8742
- var description = fetch("summary", children) || fetch("content", children);
8742
+ var description = fetch2("summary", children) || fetch2("content", children);
8743
8743
  if (description) {
8744
8744
  entry.description = description;
8745
8745
  }
8746
- var pubDate = fetch("updated", children);
8746
+ var pubDate = fetch2("updated", children);
8747
8747
  if (pubDate) {
8748
8748
  entry.pubDate = new Date(pubDate);
8749
8749
  }
@@ -8757,7 +8757,7 @@
8757
8757
  feed.link = href;
8758
8758
  }
8759
8759
  addConditionally(feed, "description", "subtitle", childs);
8760
- var updated = fetch("updated", childs);
8760
+ var updated = fetch2("updated", childs);
8761
8761
  if (updated) {
8762
8762
  feed.updated = new Date(updated);
8763
8763
  }
@@ -8777,7 +8777,7 @@
8777
8777
  addConditionally(entry, "title", "title", children);
8778
8778
  addConditionally(entry, "link", "link", children);
8779
8779
  addConditionally(entry, "description", "description", children);
8780
- var pubDate = fetch("pubDate", children) || fetch("dc:date", children);
8780
+ var pubDate = fetch2("pubDate", children) || fetch2("dc:date", children);
8781
8781
  if (pubDate)
8782
8782
  entry.pubDate = new Date(pubDate);
8783
8783
  return entry;
@@ -8786,7 +8786,7 @@
8786
8786
  addConditionally(feed, "title", "title", childs);
8787
8787
  addConditionally(feed, "link", "link", childs);
8788
8788
  addConditionally(feed, "description", "description", childs);
8789
- var updated = fetch("lastBuildDate", childs);
8789
+ var updated = fetch2("lastBuildDate", childs);
8790
8790
  if (updated) {
8791
8791
  feed.updated = new Date(updated);
8792
8792
  }
@@ -8832,7 +8832,7 @@
8832
8832
  function getOneElement(tagName, node) {
8833
8833
  return (0, legacy_js_1.getElementsByTagName)(tagName, node, true, 1)[0];
8834
8834
  }
8835
- function fetch(tagName, where, recurse) {
8835
+ function fetch2(tagName, where, recurse) {
8836
8836
  if (recurse === void 0) {
8837
8837
  recurse = false;
8838
8838
  }
@@ -8842,7 +8842,7 @@
8842
8842
  if (recurse === void 0) {
8843
8843
  recurse = false;
8844
8844
  }
8845
- var val = fetch(tagName, where, recurse);
8845
+ var val = fetch2(tagName, where, recurse);
8846
8846
  if (val)
8847
8847
  obj[prop] = val;
8848
8848
  }
@@ -12311,11 +12311,11 @@
12311
12311
  if (href2) {
12312
12312
  entry.link = href2;
12313
12313
  }
12314
- var description = fetch("summary", children) || fetch("content", children);
12314
+ var description = fetch2("summary", children) || fetch2("content", children);
12315
12315
  if (description) {
12316
12316
  entry.description = description;
12317
12317
  }
12318
- var pubDate = fetch("updated", children);
12318
+ var pubDate = fetch2("updated", children);
12319
12319
  if (pubDate) {
12320
12320
  entry.pubDate = new Date(pubDate);
12321
12321
  }
@@ -12329,7 +12329,7 @@
12329
12329
  feed.link = href;
12330
12330
  }
12331
12331
  addConditionally(feed, "description", "subtitle", childs);
12332
- var updated = fetch("updated", childs);
12332
+ var updated = fetch2("updated", childs);
12333
12333
  if (updated) {
12334
12334
  feed.updated = new Date(updated);
12335
12335
  }
@@ -12349,7 +12349,7 @@
12349
12349
  addConditionally(entry, "title", "title", children);
12350
12350
  addConditionally(entry, "link", "link", children);
12351
12351
  addConditionally(entry, "description", "description", children);
12352
- var pubDate = fetch("pubDate", children) || fetch("dc:date", children);
12352
+ var pubDate = fetch2("pubDate", children) || fetch2("dc:date", children);
12353
12353
  if (pubDate)
12354
12354
  entry.pubDate = new Date(pubDate);
12355
12355
  return entry;
@@ -12358,7 +12358,7 @@
12358
12358
  addConditionally(feed, "title", "title", childs);
12359
12359
  addConditionally(feed, "link", "link", childs);
12360
12360
  addConditionally(feed, "description", "description", childs);
12361
- var updated = fetch("lastBuildDate", childs);
12361
+ var updated = fetch2("lastBuildDate", childs);
12362
12362
  if (updated) {
12363
12363
  feed.updated = new Date(updated);
12364
12364
  }
@@ -12404,7 +12404,7 @@
12404
12404
  function getOneElement(tagName, node) {
12405
12405
  return (0, legacy_js_1.getElementsByTagName)(tagName, node, true, 1)[0];
12406
12406
  }
12407
- function fetch(tagName, where, recurse) {
12407
+ function fetch2(tagName, where, recurse) {
12408
12408
  if (recurse === void 0) {
12409
12409
  recurse = false;
12410
12410
  }
@@ -12414,7 +12414,7 @@
12414
12414
  if (recurse === void 0) {
12415
12415
  recurse = false;
12416
12416
  }
12417
- var val = fetch(tagName, where, recurse);
12417
+ var val = fetch2(tagName, where, recurse);
12418
12418
  if (val)
12419
12419
  obj[prop] = val;
12420
12420
  }
@@ -93484,8 +93484,25 @@ code.hljs {
93484
93484
  }
93485
93485
 
93486
93486
  // alan_btn/src/textChat/saveChatStateToFile.ts
93487
- function saveChatState(chatName, chatEl, projectId, headContent, codeContent) {
93488
- const alanBtnContent = chatEl.outerHTML;
93487
+ async function saveChatState(chatName, chatEl, width, projectId, headContent, codeContent) {
93488
+ const chatConteiner = chatEl.cloneNode(true);
93489
+ const iframes = Array.from(chatConteiner.querySelectorAll("iframe"));
93490
+ for (let iframe of iframes) {
93491
+ const srcUrl = iframe.getAttribute("src");
93492
+ try {
93493
+ const response = await fetch(srcUrl);
93494
+ if (!response.ok) {
93495
+ console.error(`Error fetching content from ${srcUrl}: ${response.statusText}`);
93496
+ continue;
93497
+ }
93498
+ const htmlContent = await response.text();
93499
+ iframe.removeAttribute("src");
93500
+ iframe.setAttribute("srcdoc", htmlContent);
93501
+ iframe.setAttribute("sandbox", "allow-scripts allow-same-origin");
93502
+ } catch (error) {
93503
+ console.error(`Failed to fetch or process iframe from ${srcUrl}:`, error);
93504
+ }
93505
+ }
93489
93506
  const alanMainClass = "alan-" + projectId;
93490
93507
  const newHtmlContent = `
93491
93508
  <!DOCTYPE html>
@@ -93508,11 +93525,15 @@ code.hljs {
93508
93525
  }
93509
93526
  .alan-btn__history-chat-header {
93510
93527
  margin: 0px auto;
93511
- max-width: 500px;
93528
+ max-width: ${width}px;
93529
+ width: ${width}px;
93530
+ min-width: ${width}px;
93512
93531
  }
93513
93532
  .alan-history-inner-content {
93514
93533
  margin: 0px auto;
93515
- max-width: 500px;
93534
+ max-width: ${width}px;
93535
+ width: ${width}px;
93536
+ min-width: ${width}px;
93516
93537
  height:100%;
93517
93538
  box-shadow: 0px 1px 3px rgba(16, 39, 126, 0.2);
93518
93539
  }
@@ -93524,7 +93545,7 @@ code.hljs {
93524
93545
  <h1>Alan Text Chat History</h1>
93525
93546
  </div>
93526
93547
  <div class="alan-btn__history-chat alan-history-inner-content">
93527
- ${alanBtnContent}
93548
+ ${chatConteiner.outerHTML}
93528
93549
  </div>
93529
93550
  </div>
93530
93551
  ${codeContent ? codeContent : ""}
@@ -93560,8 +93581,8 @@ code.hljs {
93560
93581
  function adjustIFrameSize(iframeMsgData) {
93561
93582
  const maxIFrameHeight = 1400;
93562
93583
  var { height, width, iframeId } = iframeMsgData;
93563
- height = height + 20;
93564
- width = width + 20;
93584
+ height = height;
93585
+ width = width;
93565
93586
  const iframeEls = document.querySelectorAll("#" + iframeId);
93566
93587
  iframeEls.forEach((iframeEl) => {
93567
93588
  iframeEl.style.height = (+height > maxIFrameHeight ? maxIFrameHeight : height) + "px";
@@ -93578,7 +93599,7 @@ code.hljs {
93578
93599
  // alan_btn/alan_btn.ts
93579
93600
  var import_lodash2 = __toESM(require_lodash());
93580
93601
  (function(ns) {
93581
- uiState.lib.version = "alan-version.1.8.64".replace("alan-version.", "");
93602
+ uiState.lib.version = "alan-version.1.8.65".replace("alan-version.", "");
93582
93603
  if (window.alanBtn) {
93583
93604
  console.warn("Alan: the Alan Button source code has already added (v." + uiState.lib.version + ")");
93584
93605
  }
@@ -96495,7 +96516,11 @@ ${LEARN_MORE_LABEL}
96495
96516
  rightHeaderIconsHolder.appendChild(expandCollapseChatBtnImg);
96496
96517
  saveChatStateBtnImg.addEventListener("click", () => {
96497
96518
  const headContent = document.head.innerHTML;
96498
- saveChatState(title, document.querySelector("#chatMessagesWrapper"), getProjectId(), headContent);
96519
+ const initChat = document.querySelector("#chatMessagesWrapper");
96520
+ if (!initChat)
96521
+ return;
96522
+ const chatWidth2 = initChat.clientWidth;
96523
+ saveChatState(title, initChat, chatWidth2, getProjectId(), headContent);
96499
96524
  });
96500
96525
  expandCollapseChatBtnImg.addEventListener("click", expandCollapseTextChat);
96501
96526
  addNeedClassesToExpandCollapseBtn(expandCollapseChatBtnImg);