@bobfrankston/mailx 1.0.164 → 1.0.165
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
|
@@ -645,7 +645,8 @@ async function main() {
|
|
|
645
645
|
}
|
|
646
646
|
}
|
|
647
647
|
const db = new MailxDB(getConfigDir());
|
|
648
|
-
const
|
|
648
|
+
const { NodeTransport } = await import("@bobfrankston/iflow-node");
|
|
649
|
+
const imapManager = new ImapManager(db, () => new NodeTransport());
|
|
649
650
|
// Native client is the only option (iflow-direct)
|
|
650
651
|
const svc = new MailxService(db, imapManager);
|
|
651
652
|
// Open msger in service mode — custom protocol serves files from client dir
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bobfrankston/mailx",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.165",
|
|
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.
|
|
24
|
-
"@bobfrankston/iflow-node": "^0.1.
|
|
23
|
+
"@bobfrankston/iflow-direct": "^0.1.2",
|
|
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.
|
|
27
|
+
"@bobfrankston/msger": "^0.1.215",
|
|
28
28
|
"@capacitor/android": "^8.3.0",
|
|
29
29
|
"@capacitor/cli": "^8.3.0",
|
|
30
30
|
"@capacitor/core": "^8.3.0",
|
|
@@ -9,7 +9,7 @@ import type { ComposeMessage } from "@bobfrankston/mailx-types";
|
|
|
9
9
|
declare let db: MailxDB;
|
|
10
10
|
declare let imapManager: ImapManager;
|
|
11
11
|
export declare function onEvent(handler: (event: any) => void): void;
|
|
12
|
-
export declare function initialize(): Promise<void>;
|
|
12
|
+
export declare function initialize(transportFactory?: any): Promise<void>;
|
|
13
13
|
export declare function shutdown(): Promise<void>;
|
|
14
14
|
export declare function getAccounts(): {
|
|
15
15
|
id: string;
|
|
@@ -22,11 +22,11 @@ function emit(event) {
|
|
|
22
22
|
catch { /* ignore handler errors */ }
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
export async function initialize() {
|
|
25
|
+
export async function initialize(transportFactory) {
|
|
26
26
|
initLocalConfig();
|
|
27
27
|
const dbDir = getConfigDir();
|
|
28
28
|
db = new MailxDB(dbDir);
|
|
29
|
-
imapManager = new ImapManager(db);
|
|
29
|
+
imapManager = new ImapManager(db, transportFactory || (() => { throw new Error("No transport factory provided"); }));
|
|
30
30
|
// Seed contacts
|
|
31
31
|
const seeded = db.seedContactsFromMessages();
|
|
32
32
|
if (seeded > 0)
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Multi-account IMAP management wrapping iflow.
|
|
4
4
|
* Syncs messages to local store, emits events for new mail.
|
|
5
5
|
*/
|
|
6
|
+
import { type TransportFactory } from "@bobfrankston/iflow-direct";
|
|
6
7
|
import { MailxDB, FileMessageStore } from "@bobfrankston/mailx-store";
|
|
7
8
|
import type { AccountConfig, MessageEnvelope, Folder } from "@bobfrankston/mailx-types";
|
|
8
9
|
import { EventEmitter } from "node:events";
|
|
@@ -33,7 +34,8 @@ export declare class ImapManager extends EventEmitter {
|
|
|
33
34
|
useNativeClient: boolean;
|
|
34
35
|
/** Accounts hitting connection limits — back off until this time */
|
|
35
36
|
private connectionBackoff;
|
|
36
|
-
|
|
37
|
+
private transportFactory;
|
|
38
|
+
constructor(db: MailxDB, transportFactory: TransportFactory);
|
|
37
39
|
/** Get OAuth access token for an account (for SMTP auth) */
|
|
38
40
|
getOAuthToken(accountId: string): Promise<string | null>;
|
|
39
41
|
/** Accounts currently re-authenticating — all operations skip these */
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* Syncs messages to local store, emits events for new mail.
|
|
5
5
|
*/
|
|
6
6
|
import { createAutoImapConfig, CompatImapClient } from "@bobfrankston/iflow-direct";
|
|
7
|
-
import { NodeTransport } from "@bobfrankston/iflow-node";
|
|
8
7
|
import { FileMessageStore } from "@bobfrankston/mailx-store";
|
|
9
8
|
import { loadSettings, getStorePath, getConfigDir, getHistoryDays } from "@bobfrankston/mailx-settings";
|
|
10
9
|
import { EventEmitter } from "node:events";
|
|
@@ -108,9 +107,11 @@ export class ImapManager extends EventEmitter {
|
|
|
108
107
|
/** Accounts hitting connection limits — back off until this time */
|
|
109
108
|
connectionBackoff = new Map();
|
|
110
109
|
// Connection management: see withConnection() below — no semaphore needed
|
|
111
|
-
|
|
110
|
+
transportFactory;
|
|
111
|
+
constructor(db, transportFactory) {
|
|
112
112
|
super();
|
|
113
113
|
this.db = db;
|
|
114
|
+
this.transportFactory = transportFactory;
|
|
114
115
|
const storePath = getStorePath();
|
|
115
116
|
this.bodyStore = new FileMessageStore(storePath);
|
|
116
117
|
}
|
|
@@ -281,7 +282,7 @@ export class ImapManager extends EventEmitter {
|
|
|
281
282
|
const config = this.configs.get(accountId);
|
|
282
283
|
if (!config)
|
|
283
284
|
throw new Error(`No config for account ${accountId}`);
|
|
284
|
-
return new CompatImapClient(config,
|
|
285
|
+
return new CompatImapClient(config, this.transportFactory);
|
|
285
286
|
}
|
|
286
287
|
/** Disconnect the persistent operational connection for an account */
|
|
287
288
|
async disconnectOps(accountId) {
|
|
@@ -61,15 +61,8 @@ if (settings.accounts.length === 0) {
|
|
|
61
61
|
}
|
|
62
62
|
const dbDir = getConfigDir();
|
|
63
63
|
const db = new MailxDB(dbDir);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (process.argv.includes("--legacy-imap") || process.argv.includes("-legacy-imap") || process.env.MAILX_LEGACY_IMAP) {
|
|
67
|
-
console.log(" Using legacy IMAP client (imapflow)");
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
imapManager.useNativeClient = true;
|
|
71
|
-
console.log(" Using native IMAP client (transport-agnostic)");
|
|
72
|
-
}
|
|
64
|
+
import { NodeTransport } from "@bobfrankston/iflow-node";
|
|
65
|
+
const imapManager = new ImapManager(db, () => new NodeTransport());
|
|
73
66
|
// ── Express App ──
|
|
74
67
|
const app = express();
|
|
75
68
|
app.use(express.json({ limit: "Infinity" }));
|