@bobfrankston/mailx 1.0.173 → 1.0.174

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/bin/mailx.js CHANGED
@@ -740,10 +740,13 @@ async function main() {
740
740
  console.log(`${reason} — shutting down`);
741
741
  imapManager.stopPeriodicSync();
742
742
  imapManager.stopOutboxWorker();
743
+ // 3s hard timeout — don't hang on broken IMAP connections
744
+ const forceExit = setTimeout(() => { console.log("Forced exit"); process.exit(0); }, 3000);
743
745
  try {
744
746
  await imapManager.shutdown();
745
747
  }
746
748
  catch { /* proceed */ }
749
+ clearTimeout(forceExit);
747
750
  db.close();
748
751
  process.exit(0);
749
752
  }
package/client/app.js CHANGED
@@ -286,8 +286,14 @@ async function openCompose(mode) {
286
286
  }
287
287
  // Store init data for compose window to pick up
288
288
  sessionStorage.setItem("composeInit", JSON.stringify(init));
289
- // Use relative URL so it works with both HTTP and custom protocol (msger://)
290
- window.open("compose/compose.html", "_blank", "width=800,height=600,menubar=no,toolbar=no,status=no");
289
+ // IPC mode: navigate in same window (popups don't have custom protocol)
290
+ // HTTP mode: open as popup window
291
+ if (typeof mailxapi !== "undefined") {
292
+ window.location.href = "compose/compose.html";
293
+ }
294
+ else {
295
+ window.open("compose/compose.html", "_blank", "width=800,height=600,menubar=no,toolbar=no,status=no");
296
+ }
291
297
  }
292
298
  function quoteBody(msg) {
293
299
  const date = new Date(msg.date).toLocaleString();
@@ -135,7 +135,12 @@ export async function showMessage(accountId, uid, folderId, specialUse, isRetry
135
135
  draftFolderId: msg.folderId,
136
136
  };
137
137
  sessionStorage.setItem("composeInit", JSON.stringify(init));
138
- window.open("compose/compose.html", "_blank", "width=800,height=600,menubar=no,toolbar=no,status=no");
138
+ if (typeof window.mailxapi !== "undefined") {
139
+ window.location.href = "compose/compose.html";
140
+ }
141
+ else {
142
+ window.open("compose/compose.html", "_blank", "width=800,height=600,menubar=no,toolbar=no,status=no");
143
+ }
139
144
  };
140
145
  }
141
146
  else {
@@ -5,6 +5,15 @@
5
5
  */
6
6
  import { createEditor } from "./editor.js";
7
7
  import { getVersion, getSettings, getAccounts, searchContacts, sendMessage, saveDraft as apiSaveDraft, deleteDraft } from "../lib/api-client.js";
8
+ /** Close compose — navigate back in IPC mode, window.close() in HTTP mode */
9
+ function closeCompose() {
10
+ if (typeof window.mailxapi !== "undefined") {
11
+ window.location.href = "../index.html";
12
+ }
13
+ else {
14
+ closeCompose();
15
+ }
16
+ }
8
17
  // ── Load editor scripts dynamically ──
9
18
  function loadScript(src) {
10
19
  return new Promise((resolve, reject) => {
@@ -349,7 +358,7 @@ document.getElementById("btn-send")?.addEventListener("click", async () => {
349
358
  if (draftUid) {
350
359
  deleteDraft(getFromAccountId(), draftUid).catch(() => { });
351
360
  }
352
- window.close();
361
+ closeCompose();
353
362
  }
354
363
  catch (e) {
355
364
  btn.disabled = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/mailx",
3
- "version": "1.0.173",
3
+ "version": "1.0.174",
4
4
  "description": "Local-first email client with IMAP sync and standalone native app",
5
5
  "type": "module",
6
6
  "main": "bin/mailx.js",
@@ -20,11 +20,11 @@
20
20
  "postinstall": "node bin/postinstall.js"
21
21
  },
22
22
  "dependencies": {
23
- "@bobfrankston/iflow-direct": "^0.1.4",
23
+ "@bobfrankston/iflow-direct": "^0.1.5",
24
24
  "@bobfrankston/iflow-node": "^0.1.1",
25
25
  "@bobfrankston/miscinfo": "^1.0.7",
26
26
  "@bobfrankston/oauthsupport": "^1.0.20",
27
- "@bobfrankston/msger": "^0.1.222",
27
+ "@bobfrankston/msger": "^0.1.223",
28
28
  "@capacitor/android": "^8.3.0",
29
29
  "@capacitor/cli": "^8.3.0",
30
30
  "@capacitor/core": "^8.3.0",
@@ -291,8 +291,15 @@ export class ImapManager extends EventEmitter {
291
291
  const client = this.opsClients.get(accountId);
292
292
  this.opsClients.delete(accountId);
293
293
  if (client) {
294
+ // Force-close: don't wait for LOGOUT on a possibly dead socket
294
295
  try {
295
- await (client._realLogout || client.logout)();
296
+ const timeout = new Promise(r => setTimeout(r, 2000));
297
+ await Promise.race([(client._realLogout || client.logout)(), timeout]);
298
+ }
299
+ catch { /* */ }
300
+ // Destroy underlying socket if still open
301
+ try {
302
+ client.destroy?.();
296
303
  }
297
304
  catch { /* */ }
298
305
  console.log(` [conn] ${accountId}: disconnected`);