@bobfrankston/mailx 1.0.144 → 1.0.146

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
@@ -488,17 +488,8 @@ async function main() {
488
488
  console.log("No mailx configuration found.");
489
489
  await runSetup();
490
490
  }
491
- // Redirect console to log file keep terminal clean
492
- if (!verbose) {
493
- const home = process.env.USERPROFILE || process.env.HOME || ".";
494
- const logDir = path.join(home, ".mailx", "logs");
495
- fs.mkdirSync(logDir, { recursive: true });
496
- const logDate = new Date().toISOString().slice(0, 10);
497
- const logPath = path.join(logDir, `mailx-${logDate}.log`);
498
- const logStream = fs.createWriteStream(logPath, { flags: "a" });
499
- console.log = (...a) => { logStream.write(a.join(" ") + "\n"); };
500
- console.error = (...a) => { logStream.write("ERROR " + a.join(" ") + "\n"); };
501
- }
491
+ // TODO: re-enable console redirect once wry crash is fixed
492
+ // The redirect itself somehow causes wry WebView2 to crash with InvalidUri
502
493
  // --server mode: Express + HTTP (for dev/remote access)
503
494
  if (serverMode) {
504
495
  console.log("Starting mailx HTTP server...");
@@ -529,12 +520,11 @@ async function main() {
529
520
  const imapManager = new ImapManager(db);
530
521
  imapManager.useNativeClient = true;
531
522
  const svc = new MailxService(db, imapManager);
532
- // Read mailxapi.js for injection into WebView
533
- const mailxapiPath = path.join(import.meta.dirname, "..", "client", "lib", "mailxapi.js");
534
- const mailxapiScript = fs.readFileSync(mailxapiPath, "utf-8");
535
523
  // Open msger in service mode — file:// URL, no HTTP
536
524
  const clientDir = path.join(import.meta.dirname, "..", "client");
537
525
  const indexPath = path.join(clientDir, "index.html");
526
+ const mailxapiPath = path.join(clientDir, "lib", "mailxapi.js");
527
+ const mailxapiScript = fs.readFileSync(mailxapiPath, "utf-8");
538
528
  const handle = showService({
539
529
  url: indexPath,
540
530
  initScript: mailxapiScript,
@@ -558,6 +548,8 @@ async function main() {
558
548
  imapManager.on("accountError", (accountId, error, hint, isOAuth) => {
559
549
  handle.send({ _event: "accountError", type: "accountError", accountId, error, hint, isOAuth });
560
550
  });
551
+ // Wait for WebView2 initialization before starting IMAP (stdin writes during init crash wry)
552
+ await new Promise(r => setTimeout(r, 2000));
561
553
  // Add accounts and start sync
562
554
  for (const account of settings.accounts) {
563
555
  if (!account.enabled)
package/client/app.js CHANGED
@@ -900,7 +900,8 @@ optAutocomplete?.addEventListener("change", () => {
900
900
  }).catch(() => { });
901
901
  });
902
902
  const isApp = typeof mailxapi !== "undefined" && mailxapi?.isApp;
903
- fetch("/api/version").then(r => r.json()).then(d => {
903
+ const versionPromise = isApp ? mailxapi.getVersion() : fetch("/api/version").then(r => r.json());
904
+ versionPromise.then((d) => {
904
905
  const el = document.getElementById("app-version");
905
906
  const storage = d.storage || {};
906
907
  const storageLabel = storage.provider && storage.provider !== "local"
@@ -947,56 +948,54 @@ fetch("/api/version").then(r => r.json()).then(d => {
947
948
  else if (storage.cloudError) {
948
949
  showAlert(`Cloud storage error: ${storage.cloudError}`, "cloud-error");
949
950
  }
950
- }).catch(async () => {
951
- // Server not runningtry to start it if we're in the app
952
- const startupStatus = document.getElementById("startup-status");
953
- if (isApp) {
954
- if (startupStatus)
955
- startupStatus.textContent = "Starting server...";
956
- await mailxapi.ensureServer();
957
- location.reload();
958
- }
959
- else {
951
+ }).catch(() => {
952
+ // Version fetch failedin IPC mode this means service isn't responding yet
953
+ if (!isApp) {
960
954
  const el = document.getElementById("app-version");
961
955
  if (el)
962
956
  el.textContent = "mailx [server offline]";
957
+ const startupStatus = document.getElementById("startup-status");
963
958
  if (startupStatus)
964
959
  startupStatus.textContent = "Server offline — start with: node packages/mailx-server/index.js";
965
960
  }
966
961
  });
967
- // ── Sync pending indicator + server health check ──
962
+ // ── Sync pending indicator + server health check (HTTP mode only) ──
968
963
  let serverDown = false;
969
- setInterval(async () => {
970
- try {
971
- const res = await fetch("/api/sync/pending");
972
- if (!res.ok)
973
- return;
974
- const data = await res.json();
975
- const el = document.getElementById("status-pending");
976
- if (el) {
977
- el.textContent = data.pending > 0 ? `↻ ${data.pending} pending` : "";
978
- el.style.color = data.pending > 0 ? "oklch(0.75 0.15 60)" : "";
979
- }
980
- // Server is back — reload if it was down
981
- if (serverDown) {
982
- serverDown = false;
983
- const statusEl = document.getElementById("status-sync");
984
- if (statusEl)
985
- statusEl.textContent = "Server reconnected";
986
- location.reload();
964
+ if (isApp) {
965
+ // IPC mode: events come via push, no polling needed
966
+ }
967
+ else
968
+ setInterval(async () => {
969
+ try {
970
+ const res = await fetch("/api/sync/pending");
971
+ if (!res.ok)
972
+ return;
973
+ const data = await res.json();
974
+ const el = document.getElementById("status-pending");
975
+ if (el) {
976
+ el.textContent = data.pending > 0 ? `↻ ${data.pending} pending` : "";
977
+ el.style.color = data.pending > 0 ? "oklch(0.75 0.15 60)" : "";
978
+ }
979
+ // Server is back — reload if it was down
980
+ if (serverDown) {
981
+ serverDown = false;
982
+ const statusEl = document.getElementById("status-sync");
983
+ if (statusEl)
984
+ statusEl.textContent = "Server reconnected";
985
+ location.reload();
986
+ }
987
987
  }
988
- }
989
- catch {
990
- if (!serverDown) {
991
- serverDown = true;
992
- const statusEl = document.getElementById("status-sync");
993
- if (statusEl) {
994
- statusEl.textContent = "SERVER OFFLINE";
995
- statusEl.style.color = "oklch(0.65 0.2 25)";
988
+ catch {
989
+ if (!serverDown) {
990
+ serverDown = true;
991
+ const statusEl = document.getElementById("status-sync");
992
+ if (statusEl) {
993
+ statusEl.textContent = "SERVER OFFLINE";
994
+ statusEl.style.color = "oklch(0.65 0.2 25)";
995
+ }
996
996
  }
997
997
  }
998
- }
999
- }, 5000);
998
+ }, 5000);
1000
999
  console.log("mailx client initialized, location:", location.href);
1001
1000
  updateNewMessageCount();
1002
1001
  // ── Midnight refresh — update date display when day changes ──
@@ -1011,7 +1010,7 @@ function scheduleMiddnightRefresh() {
1011
1010
  }
1012
1011
  scheduleMiddnightRefresh();
1013
1012
  // ── Apply theme from settings ──
1014
- fetch("/api/version").then(r => r.json()).then(d => {
1013
+ (isApp ? mailxapi.getVersion() : fetch("/api/version").then(r => r.json())).then((d) => {
1015
1014
  if (d.theme === "dark")
1016
1015
  document.documentElement.classList.add("theme-dark");
1017
1016
  else if (d.theme === "light")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/mailx",
3
- "version": "1.0.144",
3
+ "version": "1.0.146",
4
4
  "description": "Local-first email client with IMAP sync and standalone native app",
5
5
  "type": "module",
6
6
  "main": "bin/mailx.js",
@@ -23,7 +23,7 @@
23
23
  "@bobfrankston/iflow": "^1.0.52",
24
24
  "@bobfrankston/miscinfo": "^1.0.7",
25
25
  "@bobfrankston/oauthsupport": "^1.0.20",
26
- "@bobfrankston/msger": "^0.1.196",
26
+ "@bobfrankston/msger": "^0.1.198",
27
27
  "@capacitor/android": "^8.3.0",
28
28
  "@capacitor/cli": "^8.3.0",
29
29
  "@capacitor/core": "^8.3.0",
package/rebuild.cmd CHANGED
@@ -1,6 +1,6 @@
1
1
  setlocal
2
2
  : set MAILX_NATIVE_IMAP=1
3
3
  call npmglobalize
4
- call killmail.cmd
5
- launch.ps1
4
+ : call killmail.cmd
5
+ : launch.ps1
6
6
  endlocal
File without changes