@bobfrankston/rmfmail 1.2.227 → 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`;
@@ -2424,7 +2428,7 @@ async function showMessage(accountId, uid, folderId, specialUse, isRetry = false
2424
2428
  note.style.cssText = "margin: 0 0 12px 0;";
2425
2429
  note.innerHTML = `<div class="mv-system-tag">mailx</div>
2426
2430
  <div class="mv-system-title">Showing the first ${mb(trunc.sentBytes)} of a ${mb(trunc.totalBytes)} message</div>
2427
- <div class="mv-system-body">This body is too large to render in the app window${trunc.hadHtml ? " (its HTML part was dropped \u2014 a partial HTML document renders as garbage)" : ""}.
2431
+ <div class="mv-system-body">This message has no MIME structure, so its entire payload is one plain-text part; the remainder is almost always the base64 of a returned attachment.
2428
2432
  The complete message is on disk:<br>
2429
2433
  <code style="user-select:all;font-size:0.9em">${escapeHtml2(trunc.emlPath || "(path unavailable)")}</code></div>`;
2430
2434
  bodyEl.appendChild(note);
@@ -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;