@bobfrankston/rmfmail 1.2.228 → 1.2.229

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.
@@ -2415,7 +2415,11 @@ async function showMessage(accountId, uid, folderId, specialUse, isRetry = false
2415
2415
  } else if (msg.bodyText) {
2416
2416
  const pre = document.createElement("pre");
2417
2417
  pre.style.cssText = "padding: 1rem; white-space: pre-wrap; word-break: break-word; font-family: system-ui, sans-serif; font-size: 17.5px; line-height: 1.5; color: #1a1a2e; background: #fff; margin: 0; height: 100%; overflow: auto;";
2418
- pre.innerHTML = linkifyText(msg.bodyText);
2418
+ if (msg.bodyText.length > PROGRESSIVE_TEXT_THRESHOLD) {
2419
+ renderTextProgressively(pre, msg.bodyText, gen);
2420
+ } else {
2421
+ pre.innerHTML = linkifyText(msg.bodyText);
2422
+ }
2419
2423
  const trunc = msg.bodyTruncated;
2420
2424
  if (trunc) {
2421
2425
  const mb = (n) => `${(n / 1048576).toFixed(1)} MB`;
@@ -2681,6 +2685,32 @@ function renderHeaderFromEnvelope(headerEl, env) {
2681
2685
  function escapeHtml2(s) {
2682
2686
  return (s || "").replace(/[&<>"']/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[c]);
2683
2687
  }
2688
+ function renderTextProgressively(pre, text, gen) {
2689
+ const chunks = [];
2690
+ let at = 0;
2691
+ while (at < text.length) {
2692
+ let end = Math.min(at + TEXT_CHUNK_BYTES, text.length);
2693
+ if (end < text.length) {
2694
+ const nl = text.lastIndexOf("\n", end);
2695
+ if (nl > at)
2696
+ end = nl + 1;
2697
+ }
2698
+ chunks.push(text.slice(at, end));
2699
+ at = end;
2700
+ }
2701
+ let i = 0;
2702
+ const step = () => {
2703
+ if (gen !== showMessageGeneration)
2704
+ return;
2705
+ if (i >= chunks.length)
2706
+ return;
2707
+ const span = document.createElement("span");
2708
+ span.innerHTML = linkifyText(chunks[i++]);
2709
+ pre.appendChild(span);
2710
+ requestAnimationFrame(step);
2711
+ };
2712
+ step();
2713
+ }
2684
2714
  function linkifyText(text) {
2685
2715
  const escaped = text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
2686
2716
  return escaped.replace(/(https?:\/\/[^\s<>"')\]]+)/g, (match) => {
@@ -3318,7 +3348,7 @@ function spawnDesktopPopout(msg, accountId) {
3318
3348
  function escapeHtmlLocal(s) {
3319
3349
  return (s || "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
3320
3350
  }
3321
- var currentMessage, currentAccountId, dragOutUrls, showMessageGeneration, retryCount, lastEnvelope, PARSED_CACHE_LIMIT, parsedCache, sessionAllowedRemote, recentFetchErrors, ZOOM_KEY, ZOOM_MIN, ZOOM_MAX, ZOOM_STEP, previewZoom, RENDER_MARK_KEY, RENDER_MARK_MAX_AGE_MS, poisonedMessages, renderKey;
3351
+ var currentMessage, currentAccountId, dragOutUrls, showMessageGeneration, retryCount, lastEnvelope, PARSED_CACHE_LIMIT, parsedCache, sessionAllowedRemote, recentFetchErrors, ZOOM_KEY, ZOOM_MIN, ZOOM_MAX, ZOOM_STEP, previewZoom, RENDER_MARK_KEY, RENDER_MARK_MAX_AGE_MS, poisonedMessages, renderKey, PROGRESSIVE_TEXT_THRESHOLD, TEXT_CHUNK_BYTES;
3322
3352
  var init_message_viewer = __esm({
3323
3353
  "client/components/message-viewer.js"() {
3324
3354
  "use strict";
@@ -3385,6 +3415,8 @@ var init_message_viewer = __esm({
3385
3415
  } catch {
3386
3416
  }
3387
3417
  })();
3418
+ PROGRESSIVE_TEXT_THRESHOLD = 200 * 1024;
3419
+ TEXT_CHUNK_BYTES = 64 * 1024;
3388
3420
  subscribeStore("*", (ev) => {
3389
3421
  if (ev.kind !== "bodyFetchError")
3390
3422
  return;