@bobfrankston/rmfmail 1.1.2 → 1.1.4

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.
Files changed (91) hide show
  1. package/bin/mailx.js +10 -13
  2. package/bin/mailx.js.map +1 -1
  3. package/bin/mailx.ts +11 -13
  4. package/client/android-bootstrap.bundle.js +1 -1
  5. package/client/android-bootstrap.bundle.js.map +2 -2
  6. package/client/app.bundle.js +88 -17
  7. package/client/app.bundle.js.map +2 -2
  8. package/client/app.js +20 -20
  9. package/client/app.js.map +1 -1
  10. package/client/app.ts +20 -20
  11. package/client/components/context-menu.js +9 -0
  12. package/client/components/context-menu.js.map +1 -1
  13. package/client/components/context-menu.ts +8 -0
  14. package/client/components/message-viewer.js +21 -5
  15. package/client/components/message-viewer.js.map +1 -1
  16. package/client/components/message-viewer.ts +21 -5
  17. package/client/compose/compose.bundle.js +45 -1
  18. package/client/compose/compose.bundle.js.map +2 -2
  19. package/client/index.html +23 -4
  20. package/client/lib/api-client.js +41 -0
  21. package/client/lib/api-client.js.map +1 -1
  22. package/client/lib/api-client.ts +29 -0
  23. package/client/lib/mailxapi.js +11 -7
  24. package/client/lib/message-state.js +23 -0
  25. package/client/lib/message-state.js.map +1 -1
  26. package/client/lib/message-state.ts +21 -0
  27. package/package.json +9 -9
  28. package/packages/mailx-bus/index.d.ts +2 -0
  29. package/packages/mailx-bus/index.d.ts.map +1 -1
  30. package/packages/mailx-bus/index.js +9 -0
  31. package/packages/mailx-bus/index.js.map +1 -1
  32. package/packages/mailx-bus/index.ts +11 -0
  33. package/packages/mailx-bus/package.json +1 -1
  34. package/packages/mailx-bus/store-events.d.ts +79 -0
  35. package/packages/mailx-bus/store-events.d.ts.map +1 -0
  36. package/packages/mailx-bus/store-events.js +155 -0
  37. package/packages/mailx-bus/store-events.js.map +1 -0
  38. package/packages/mailx-bus/store-events.ts +165 -0
  39. package/packages/mailx-core/index.d.ts.map +1 -1
  40. package/packages/mailx-core/index.js +25 -3
  41. package/packages/mailx-core/index.js.map +1 -1
  42. package/packages/mailx-core/index.ts +23 -3
  43. package/packages/mailx-host/package.json +1 -1
  44. package/packages/mailx-imap/index.d.ts +0 -37
  45. package/packages/mailx-imap/index.d.ts.map +1 -1
  46. package/packages/mailx-imap/index.js +17 -172
  47. package/packages/mailx-imap/index.js.map +1 -1
  48. package/packages/mailx-imap/index.ts +17 -179
  49. package/packages/mailx-imap/package-lock.json +2 -2
  50. package/packages/mailx-imap/package.json +1 -1
  51. package/packages/mailx-service/index.d.ts +16 -0
  52. package/packages/mailx-service/index.d.ts.map +1 -1
  53. package/packages/mailx-service/index.js +89 -77
  54. package/packages/mailx-service/index.js.map +1 -1
  55. package/packages/mailx-service/index.ts +83 -75
  56. package/packages/mailx-service/local-store.d.ts +54 -2
  57. package/packages/mailx-service/local-store.d.ts.map +1 -1
  58. package/packages/mailx-service/local-store.js +147 -2
  59. package/packages/mailx-service/local-store.js.map +1 -1
  60. package/packages/mailx-service/local-store.ts +147 -3
  61. package/packages/mailx-service/reconciler.d.ts.map +1 -1
  62. package/packages/mailx-service/reconciler.js +28 -8
  63. package/packages/mailx-service/reconciler.js.map +1 -1
  64. package/packages/mailx-service/reconciler.ts +28 -8
  65. package/packages/mailx-service/sync-queue.d.ts +16 -0
  66. package/packages/mailx-service/sync-queue.d.ts.map +1 -1
  67. package/packages/mailx-service/sync-queue.js +33 -3
  68. package/packages/mailx-service/sync-queue.js.map +1 -1
  69. package/packages/mailx-service/sync-queue.ts +33 -3
  70. package/packages/mailx-settings/package.json +1 -1
  71. package/packages/mailx-store/bus.d.ts +79 -0
  72. package/packages/mailx-store/bus.d.ts.map +1 -0
  73. package/packages/mailx-store/bus.js +155 -0
  74. package/packages/mailx-store/bus.js.map +1 -0
  75. package/packages/mailx-store/index.d.ts +2 -0
  76. package/packages/mailx-store/index.d.ts.map +1 -1
  77. package/packages/mailx-store/index.js +5 -0
  78. package/packages/mailx-store/index.js.map +1 -1
  79. package/packages/mailx-store/index.ts +7 -0
  80. package/packages/mailx-store/package.json +2 -1
  81. package/packages/mailx-store-web/db.d.ts.map +1 -1
  82. package/packages/mailx-store-web/db.js +9 -1
  83. package/packages/mailx-store-web/db.js.map +1 -1
  84. package/packages/mailx-store-web/db.ts +9 -1
  85. package/packages/mailx-store-web/package.json +2 -1
  86. package/packages/mailx-store-web/sync-manager.d.ts +4 -0
  87. package/packages/mailx-store-web/sync-manager.d.ts.map +1 -1
  88. package/packages/mailx-store-web/sync-manager.js +32 -4
  89. package/packages/mailx-store-web/sync-manager.js.map +1 -1
  90. package/packages/mailx-store-web/sync-manager.ts +28 -4
  91. /package/packages/mailx-imap/{node_modules.npmglobalize-stash-36832 → node_modules.npmglobalize-stash-39436}/.package-lock.json +0 -0
@@ -91,6 +91,7 @@ __export(api_client_exports, {
91
91
  setPrioritySender: () => setPrioritySender,
92
92
  setupAccount: () => setupAccount,
93
93
  showReminderPopup: () => showReminderPopup,
94
+ subscribeStore: () => subscribeStore,
94
95
  syncAccount: () => syncAccount,
95
96
  triggerSync: () => triggerSync,
96
97
  undeleteMessage: () => undeleteMessage,
@@ -384,8 +385,46 @@ function onEvent(handler) {
384
385
  eventHandlers.splice(i, 1);
385
386
  };
386
387
  }
388
+ function subscribeStore(topic, handler) {
389
+ let set = storeSubs.get(topic);
390
+ if (!set) {
391
+ set = /* @__PURE__ */ new Set();
392
+ storeSubs.set(topic, set);
393
+ }
394
+ set.add(handler);
395
+ return () => {
396
+ const s = storeSubs.get(topic);
397
+ if (s) {
398
+ s.delete(handler);
399
+ if (s.size === 0)
400
+ storeSubs.delete(topic);
401
+ }
402
+ };
403
+ }
404
+ function deliverStore(event) {
405
+ const exact = storeSubs.get(event.topic);
406
+ if (exact)
407
+ for (const h of exact) {
408
+ try {
409
+ h(event);
410
+ } catch (e) {
411
+ console.error("[store-bus]", e);
412
+ }
413
+ }
414
+ const wild = storeSubs.get("*");
415
+ if (wild)
416
+ for (const h of wild) {
417
+ try {
418
+ h(event);
419
+ } catch (e) {
420
+ console.error("[store-bus]", e);
421
+ }
422
+ }
423
+ }
387
424
  function connectEvents() {
388
425
  ipc().onEvent((event) => {
426
+ if (event && event._event === "store")
427
+ deliverStore(event);
389
428
  for (const h of eventHandlers)
390
429
  h(event);
391
430
  });
@@ -459,13 +498,14 @@ async function getAttachment(accountId, uid, attachmentId, folderId) {
459
498
  async function getDeviceAccounts() {
460
499
  return ipc().getDeviceAccounts?.() ?? [];
461
500
  }
462
- var cachedRelayBridge, messageListAbort, eventHandlers, connectWebSocket, onWsEvent;
501
+ var cachedRelayBridge, messageListAbort, eventHandlers, storeSubs, connectWebSocket, onWsEvent;
463
502
  var init_api_client = __esm({
464
503
  "client/lib/api-client.js"() {
465
504
  "use strict";
466
505
  cachedRelayBridge = null;
467
506
  messageListAbort = null;
468
507
  eventHandlers = [];
508
+ storeSubs = /* @__PURE__ */ new Map();
469
509
  connectWebSocket = connectEvents;
470
510
  onWsEvent = onEvent;
471
511
  }
@@ -551,6 +591,10 @@ var init_context_menu = __esm({
551
591
  document.addEventListener("scroll", closeContextMenu, true);
552
592
  document.addEventListener("contextmenu", () => {
553
593
  });
594
+ window.addEventListener("message", (e) => {
595
+ if (e.data && e.data.type === "iframePointerDown")
596
+ closeContextMenu();
597
+ });
554
598
  }
555
599
  });
556
600
 
@@ -641,8 +685,25 @@ var messages, listeners;
641
685
  var init_message_state = __esm({
642
686
  "client/lib/message-state.js"() {
643
687
  "use strict";
688
+ init_api_client();
644
689
  messages = [];
645
690
  listeners = [];
691
+ subscribeStore("*", (event) => {
692
+ if (event.kind !== "flagsChanged")
693
+ return;
694
+ const accountId = event.accountId;
695
+ const uid = event.uid;
696
+ const flags = event.flags;
697
+ if (!accountId || typeof uid !== "number" || !Array.isArray(flags))
698
+ return;
699
+ const msg = messages.find((m) => m.uid === uid && m.accountId === accountId);
700
+ if (!msg)
701
+ return;
702
+ const before = JSON.stringify(msg.flags);
703
+ msg.flags = flags;
704
+ if (before !== JSON.stringify(flags))
705
+ notify();
706
+ });
646
707
  }
647
708
  });
648
709
 
@@ -1082,8 +1143,8 @@ async function showMessage(accountId, uid, folderId, specialUse, isRetry = false
1082
1143
  const previewText = (msg.preview || cached?.preview || "").trim();
1083
1144
  bodyEl.innerHTML = previewText ? `<div class="mv-preview-placeholder">${escapeHtml(previewText)}</div>` : `<div class="mv-empty">Fetching body from server\u2026</div>`;
1084
1145
  const captureGen = gen;
1085
- const off = onEvent((ev) => {
1086
- if (!ev || ev.type !== "bodyAvailable")
1146
+ const off = subscribeStore("*", (ev) => {
1147
+ if (ev.kind !== "bodyAvailable")
1087
1148
  return;
1088
1149
  if (ev.accountId !== accountId || ev.uid !== uid)
1089
1150
  return;
@@ -1927,6 +1988,18 @@ ${csp}
1927
1988
  iframeLeft: rect.left, iframeTop: rect.top
1928
1989
  }, "*");
1929
1990
  });
1991
+ // Iframe pointerdown \u2192 tell the parent to dismiss any open context menu.
1992
+ // The parent's dismissListener listens to its own document's pointerdown,
1993
+ // but iframe events don't bubble across the boundary; without this, a
1994
+ // click in the message body to dismiss the menu would be invisible to
1995
+ // the parent and the menu would stick open.
1996
+ document.addEventListener("pointerdown", function (e) {
1997
+ // The contextmenu handler above ALSO fires pointerdown on right-click;
1998
+ // that one opens a fresh menu, which already closes the previous.
1999
+ // Skip right-click (button 2) to avoid a publish/close race.
2000
+ if (e.button === 2) return;
2001
+ try { window.parent.postMessage({ type: "iframePointerDown" }, "*"); } catch (_) {}
2002
+ }, true);
1930
2003
  // Key forwarding \u2014 Delete, Ctrl+D, arrow keys, etc. need to reach app.ts
1931
2004
  // even when focus is inside the sandboxed iframe. Parent-side
1932
2005
  // contentDocument listeners (see installPreviewControls) work on
@@ -2095,8 +2168,8 @@ var init_message_viewer = __esm({
2095
2168
  ZOOM_MAX = 3;
2096
2169
  ZOOM_STEP = 0.1;
2097
2170
  previewZoom = clampZoom(parseFloat(localStorage.getItem(ZOOM_KEY) || "1"));
2098
- onEvent((ev) => {
2099
- if (!ev || ev.type !== "bodyFetchError")
2171
+ subscribeStore("*", (ev) => {
2172
+ if (ev.kind !== "bodyFetchError")
2100
2173
  return;
2101
2174
  recentFetchErrors.set(`${ev.accountId}:${ev.uid}`, {
2102
2175
  error: String(ev.error || "fetch failed"),
@@ -7739,18 +7812,7 @@ onWsEvent((event) => {
7739
7812
  case "bodyCached":
7740
7813
  markBodiesCached(event.items || []);
7741
7814
  break;
7742
- case "bodyAvailable":
7743
- if (event.accountId && event.uid) {
7744
- markBodiesCached([{ accountId: event.accountId, uid: event.uid }]);
7745
- }
7746
- break;
7747
- case "messageRemoved":
7748
- if (event.accountId && event.uid) {
7749
- document.dispatchEvent(new CustomEvent("mailx-remove-stale", {
7750
- detail: { accountId: event.accountId, uid: event.uid }
7751
- }));
7752
- }
7753
- break;
7815
+ // bodyAvailable and messageRemoved migrated to subscribeStore below.
7754
7816
  case "syncStateChanged": {
7755
7817
  if (!statusSync) break;
7756
7818
  const msgs = event.messageActions ?? 0;
@@ -7919,6 +7981,15 @@ onWsEvent((event) => {
7919
7981
  }
7920
7982
  }
7921
7983
  });
7984
+ subscribeStore("*", (ev) => {
7985
+ if (ev.kind === "bodyAvailable" && ev.accountId && ev.uid) {
7986
+ markBodiesCached([{ accountId: ev.accountId, uid: ev.uid }]);
7987
+ } else if (ev.kind === "messageRemoved" && ev.accountId && ev.uid) {
7988
+ document.dispatchEvent(new CustomEvent("mailx-remove-stale", {
7989
+ detail: { accountId: ev.accountId, uid: ev.uid }
7990
+ }));
7991
+ }
7992
+ });
7922
7993
  async function openComposeFromMailto(m) {
7923
7994
  const accountsP = getAccounts();
7924
7995
  const frame = showComposeOverlay(m.subject ? `Compose: ${m.subject}` : "Compose");