@bobfrankston/mailx 1.0.12 → 1.0.14
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 +52 -28
- package/client/app.js +113 -30
- package/client/components/folder-tree.js +84 -3
- package/client/components/message-list.js +164 -10
- package/client/components/message-viewer.js +130 -13
- package/client/compose/compose.html +4 -4
- package/client/compose/compose.js +53 -34
- package/client/index.html +50 -21
- package/client/lib/api-client.js +112 -31
- package/client/lib/mailxapi.js +123 -0
- package/client/package.json +1 -1
- package/client/styles/components.css +206 -16
- package/client/styles/layout.css +2 -1
- package/killmail.cmd +6 -0
- package/launch.ps1 +47 -5
- package/launcher/bin/mailx-app-linux +0 -0
- package/launcher/bin/mailx-app.exe +0 -0
- package/launcher/builder/build-config.json +11 -0
- package/launcher/builder/postinstall.js +81 -0
- package/package.json +2 -4
- package/packages/mailx-api/index.js +125 -29
- package/packages/mailx-core/index.d.ts +129 -0
- package/packages/mailx-core/index.js +323 -0
- package/packages/mailx-core/ipc.d.ts +13 -0
- package/packages/mailx-core/ipc.js +56 -0
- package/packages/mailx-core/package.json +18 -0
- package/packages/mailx-imap/index.d.ts +7 -1
- package/packages/mailx-imap/index.js +89 -14
- package/packages/mailx-server/index.js +42 -31
- package/packages/mailx-server/package.json +1 -2
- package/packages/mailx-settings/index.d.ts +1 -1
- package/packages/mailx-settings/index.js +21 -12
- package/packages/mailx-store/db.d.ts +6 -2
- package/packages/mailx-store/db.js +78 -16
- package/packages/mailx-store/file-store.d.ts +2 -8
- package/packages/mailx-store/file-store.js +7 -31
- package/packages/mailx-types/index.d.ts +3 -1
- package/.tswalk.json +0 -7396
- package/launcher/release.cmd +0 -4
- package/mailx.json +0 -9
- package/packages/mailx-api/node_modules/nodemailer/.ncurc.js +0 -9
- package/packages/mailx-api/node_modules/nodemailer/.prettierignore +0 -8
- package/packages/mailx-api/node_modules/nodemailer/.prettierrc +0 -12
- package/packages/mailx-api/node_modules/nodemailer/.prettierrc.js +0 -10
- package/packages/mailx-api/node_modules/nodemailer/.release-please-config.json +0 -9
- package/packages/mailx-api/node_modules/nodemailer/LICENSE +0 -16
- package/packages/mailx-api/node_modules/nodemailer/README.md +0 -86
- package/packages/mailx-api/node_modules/nodemailer/SECURITY.txt +0 -22
- package/packages/mailx-api/node_modules/nodemailer/eslint.config.js +0 -88
- package/packages/mailx-api/node_modules/nodemailer/lib/addressparser/index.js +0 -383
- package/packages/mailx-api/node_modules/nodemailer/lib/base64/index.js +0 -139
- package/packages/mailx-api/node_modules/nodemailer/lib/dkim/index.js +0 -253
- package/packages/mailx-api/node_modules/nodemailer/lib/dkim/message-parser.js +0 -155
- package/packages/mailx-api/node_modules/nodemailer/lib/dkim/relaxed-body.js +0 -154
- package/packages/mailx-api/node_modules/nodemailer/lib/dkim/sign.js +0 -117
- package/packages/mailx-api/node_modules/nodemailer/lib/fetch/cookies.js +0 -281
- package/packages/mailx-api/node_modules/nodemailer/lib/fetch/index.js +0 -280
- package/packages/mailx-api/node_modules/nodemailer/lib/json-transport/index.js +0 -82
- package/packages/mailx-api/node_modules/nodemailer/lib/mail-composer/index.js +0 -629
- package/packages/mailx-api/node_modules/nodemailer/lib/mailer/index.js +0 -441
- package/packages/mailx-api/node_modules/nodemailer/lib/mailer/mail-message.js +0 -316
- package/packages/mailx-api/node_modules/nodemailer/lib/mime-funcs/index.js +0 -625
- package/packages/mailx-api/node_modules/nodemailer/lib/mime-funcs/mime-types.js +0 -2113
- package/packages/mailx-api/node_modules/nodemailer/lib/mime-node/index.js +0 -1316
- package/packages/mailx-api/node_modules/nodemailer/lib/mime-node/last-newline.js +0 -33
- package/packages/mailx-api/node_modules/nodemailer/lib/mime-node/le-unix.js +0 -43
- package/packages/mailx-api/node_modules/nodemailer/lib/mime-node/le-windows.js +0 -52
- package/packages/mailx-api/node_modules/nodemailer/lib/nodemailer.js +0 -157
- package/packages/mailx-api/node_modules/nodemailer/lib/punycode/index.js +0 -460
- package/packages/mailx-api/node_modules/nodemailer/lib/qp/index.js +0 -227
- package/packages/mailx-api/node_modules/nodemailer/lib/sendmail-transport/index.js +0 -210
- package/packages/mailx-api/node_modules/nodemailer/lib/ses-transport/index.js +0 -234
- package/packages/mailx-api/node_modules/nodemailer/lib/shared/index.js +0 -754
- package/packages/mailx-api/node_modules/nodemailer/lib/smtp-connection/data-stream.js +0 -108
- package/packages/mailx-api/node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js +0 -143
- package/packages/mailx-api/node_modules/nodemailer/lib/smtp-connection/index.js +0 -1870
- package/packages/mailx-api/node_modules/nodemailer/lib/smtp-pool/index.js +0 -652
- package/packages/mailx-api/node_modules/nodemailer/lib/smtp-pool/pool-resource.js +0 -259
- package/packages/mailx-api/node_modules/nodemailer/lib/smtp-transport/index.js +0 -421
- package/packages/mailx-api/node_modules/nodemailer/lib/stream-transport/index.js +0 -135
- package/packages/mailx-api/node_modules/nodemailer/lib/well-known/index.js +0 -47
- package/packages/mailx-api/node_modules/nodemailer/lib/well-known/services.json +0 -611
- package/packages/mailx-api/node_modules/nodemailer/lib/xoauth2/index.js +0 -427
- package/packages/mailx-api/node_modules/nodemailer/package.json +0 -47
- package/packages/mailx-imap/node_modules/nodemailer/.ncurc.js +0 -9
- package/packages/mailx-imap/node_modules/nodemailer/.prettierignore +0 -8
- package/packages/mailx-imap/node_modules/nodemailer/.prettierrc +0 -12
- package/packages/mailx-imap/node_modules/nodemailer/.prettierrc.js +0 -10
- package/packages/mailx-imap/node_modules/nodemailer/.release-please-config.json +0 -9
- package/packages/mailx-imap/node_modules/nodemailer/LICENSE +0 -16
- package/packages/mailx-imap/node_modules/nodemailer/README.md +0 -86
- package/packages/mailx-imap/node_modules/nodemailer/SECURITY.txt +0 -22
- package/packages/mailx-imap/node_modules/nodemailer/eslint.config.js +0 -88
- package/packages/mailx-imap/node_modules/nodemailer/lib/addressparser/index.js +0 -383
- package/packages/mailx-imap/node_modules/nodemailer/lib/base64/index.js +0 -139
- package/packages/mailx-imap/node_modules/nodemailer/lib/dkim/index.js +0 -253
- package/packages/mailx-imap/node_modules/nodemailer/lib/dkim/message-parser.js +0 -155
- package/packages/mailx-imap/node_modules/nodemailer/lib/dkim/relaxed-body.js +0 -154
- package/packages/mailx-imap/node_modules/nodemailer/lib/dkim/sign.js +0 -117
- package/packages/mailx-imap/node_modules/nodemailer/lib/fetch/cookies.js +0 -281
- package/packages/mailx-imap/node_modules/nodemailer/lib/fetch/index.js +0 -280
- package/packages/mailx-imap/node_modules/nodemailer/lib/json-transport/index.js +0 -82
- package/packages/mailx-imap/node_modules/nodemailer/lib/mail-composer/index.js +0 -629
- package/packages/mailx-imap/node_modules/nodemailer/lib/mailer/index.js +0 -441
- package/packages/mailx-imap/node_modules/nodemailer/lib/mailer/mail-message.js +0 -316
- package/packages/mailx-imap/node_modules/nodemailer/lib/mime-funcs/index.js +0 -625
- package/packages/mailx-imap/node_modules/nodemailer/lib/mime-funcs/mime-types.js +0 -2113
- package/packages/mailx-imap/node_modules/nodemailer/lib/mime-node/index.js +0 -1316
- package/packages/mailx-imap/node_modules/nodemailer/lib/mime-node/last-newline.js +0 -33
- package/packages/mailx-imap/node_modules/nodemailer/lib/mime-node/le-unix.js +0 -43
- package/packages/mailx-imap/node_modules/nodemailer/lib/mime-node/le-windows.js +0 -52
- package/packages/mailx-imap/node_modules/nodemailer/lib/nodemailer.js +0 -157
- package/packages/mailx-imap/node_modules/nodemailer/lib/punycode/index.js +0 -460
- package/packages/mailx-imap/node_modules/nodemailer/lib/qp/index.js +0 -227
- package/packages/mailx-imap/node_modules/nodemailer/lib/sendmail-transport/index.js +0 -210
- package/packages/mailx-imap/node_modules/nodemailer/lib/ses-transport/index.js +0 -234
- package/packages/mailx-imap/node_modules/nodemailer/lib/shared/index.js +0 -754
- package/packages/mailx-imap/node_modules/nodemailer/lib/smtp-connection/data-stream.js +0 -108
- package/packages/mailx-imap/node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js +0 -143
- package/packages/mailx-imap/node_modules/nodemailer/lib/smtp-connection/index.js +0 -1870
- package/packages/mailx-imap/node_modules/nodemailer/lib/smtp-pool/index.js +0 -652
- package/packages/mailx-imap/node_modules/nodemailer/lib/smtp-pool/pool-resource.js +0 -259
- package/packages/mailx-imap/node_modules/nodemailer/lib/smtp-transport/index.js +0 -421
- package/packages/mailx-imap/node_modules/nodemailer/lib/stream-transport/index.js +0 -135
- package/packages/mailx-imap/node_modules/nodemailer/lib/well-known/index.js +0 -47
- package/packages/mailx-imap/node_modules/nodemailer/lib/well-known/services.json +0 -611
- package/packages/mailx-imap/node_modules/nodemailer/lib/xoauth2/index.js +0 -427
- package/packages/mailx-imap/node_modules/nodemailer/package.json +0 -47
- package/packages/mailx-send/node_modules/nodemailer/.ncurc.js +0 -9
- package/packages/mailx-send/node_modules/nodemailer/.prettierignore +0 -8
- package/packages/mailx-send/node_modules/nodemailer/.prettierrc +0 -12
- package/packages/mailx-send/node_modules/nodemailer/.prettierrc.js +0 -10
- package/packages/mailx-send/node_modules/nodemailer/.release-please-config.json +0 -9
- package/packages/mailx-send/node_modules/nodemailer/LICENSE +0 -16
- package/packages/mailx-send/node_modules/nodemailer/README.md +0 -86
- package/packages/mailx-send/node_modules/nodemailer/SECURITY.txt +0 -22
- package/packages/mailx-send/node_modules/nodemailer/eslint.config.js +0 -88
- package/packages/mailx-send/node_modules/nodemailer/lib/addressparser/index.js +0 -383
- package/packages/mailx-send/node_modules/nodemailer/lib/base64/index.js +0 -139
- package/packages/mailx-send/node_modules/nodemailer/lib/dkim/index.js +0 -253
- package/packages/mailx-send/node_modules/nodemailer/lib/dkim/message-parser.js +0 -155
- package/packages/mailx-send/node_modules/nodemailer/lib/dkim/relaxed-body.js +0 -154
- package/packages/mailx-send/node_modules/nodemailer/lib/dkim/sign.js +0 -117
- package/packages/mailx-send/node_modules/nodemailer/lib/fetch/cookies.js +0 -281
- package/packages/mailx-send/node_modules/nodemailer/lib/fetch/index.js +0 -280
- package/packages/mailx-send/node_modules/nodemailer/lib/json-transport/index.js +0 -82
- package/packages/mailx-send/node_modules/nodemailer/lib/mail-composer/index.js +0 -629
- package/packages/mailx-send/node_modules/nodemailer/lib/mailer/index.js +0 -441
- package/packages/mailx-send/node_modules/nodemailer/lib/mailer/mail-message.js +0 -316
- package/packages/mailx-send/node_modules/nodemailer/lib/mime-funcs/index.js +0 -625
- package/packages/mailx-send/node_modules/nodemailer/lib/mime-funcs/mime-types.js +0 -2113
- package/packages/mailx-send/node_modules/nodemailer/lib/mime-node/index.js +0 -1316
- package/packages/mailx-send/node_modules/nodemailer/lib/mime-node/last-newline.js +0 -33
- package/packages/mailx-send/node_modules/nodemailer/lib/mime-node/le-unix.js +0 -43
- package/packages/mailx-send/node_modules/nodemailer/lib/mime-node/le-windows.js +0 -52
- package/packages/mailx-send/node_modules/nodemailer/lib/nodemailer.js +0 -157
- package/packages/mailx-send/node_modules/nodemailer/lib/punycode/index.js +0 -460
- package/packages/mailx-send/node_modules/nodemailer/lib/qp/index.js +0 -227
- package/packages/mailx-send/node_modules/nodemailer/lib/sendmail-transport/index.js +0 -210
- package/packages/mailx-send/node_modules/nodemailer/lib/ses-transport/index.js +0 -234
- package/packages/mailx-send/node_modules/nodemailer/lib/shared/index.js +0 -754
- package/packages/mailx-send/node_modules/nodemailer/lib/smtp-connection/data-stream.js +0 -108
- package/packages/mailx-send/node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js +0 -143
- package/packages/mailx-send/node_modules/nodemailer/lib/smtp-connection/index.js +0 -1870
- package/packages/mailx-send/node_modules/nodemailer/lib/smtp-pool/index.js +0 -652
- package/packages/mailx-send/node_modules/nodemailer/lib/smtp-pool/pool-resource.js +0 -259
- package/packages/mailx-send/node_modules/nodemailer/lib/smtp-transport/index.js +0 -421
- package/packages/mailx-send/node_modules/nodemailer/lib/stream-transport/index.js +0 -135
- package/packages/mailx-send/node_modules/nodemailer/lib/well-known/index.js +0 -47
- package/packages/mailx-send/node_modules/nodemailer/lib/well-known/services.json +0 -611
- package/packages/mailx-send/node_modules/nodemailer/lib/xoauth2/index.js +0 -427
- package/packages/mailx-send/node_modules/nodemailer/package.json +0 -47
package/client/index.html
CHANGED
|
@@ -13,24 +13,24 @@
|
|
|
13
13
|
<body>
|
|
14
14
|
<header class="toolbar">
|
|
15
15
|
<div class="toolbar-left">
|
|
16
|
-
<button class="tb-btn" id="btn-compose" title="Compose">
|
|
17
|
-
<span class="tb-icon"
|
|
16
|
+
<button class="tb-btn" id="btn-compose" title="Compose (Ctrl+N)">
|
|
17
|
+
<span class="tb-icon">✏</span> Compose
|
|
18
18
|
</button>
|
|
19
|
-
<button class="tb-btn" id="btn-reply" title="Reply" disabled>
|
|
20
|
-
<span class="tb-icon"
|
|
19
|
+
<button class="tb-btn" id="btn-reply" title="Reply (Ctrl+R)" disabled>
|
|
20
|
+
<span class="tb-icon">↩</span>
|
|
21
21
|
</button>
|
|
22
|
-
<button class="tb-btn" id="btn-reply-all" title="Reply All" disabled>
|
|
23
|
-
<span class="tb-icon"
|
|
22
|
+
<button class="tb-btn" id="btn-reply-all" title="Reply All (Ctrl+Shift+R)" disabled>
|
|
23
|
+
<span class="tb-icon">↩↩</span>
|
|
24
24
|
</button>
|
|
25
25
|
<button class="tb-btn" id="btn-forward" title="Forward" disabled>
|
|
26
|
-
<span class="tb-icon"
|
|
26
|
+
<span class="tb-icon">→</span>
|
|
27
27
|
</button>
|
|
28
28
|
<span class="tb-sep"></span>
|
|
29
|
-
<button class="tb-btn" id="btn-delete" title="Delete" disabled>
|
|
30
|
-
<span class="tb-icon"
|
|
29
|
+
<button class="tb-btn" id="btn-delete" title="Delete (Del)" disabled>
|
|
30
|
+
<span class="tb-icon">🗑</span>
|
|
31
31
|
</button>
|
|
32
32
|
<button class="tb-btn" id="btn-flag" title="Flag" disabled>
|
|
33
|
-
<span class="tb-icon"
|
|
33
|
+
<span class="tb-icon">⚑</span>
|
|
34
34
|
</button>
|
|
35
35
|
</div>
|
|
36
36
|
<div class="toolbar-center">
|
|
@@ -45,24 +45,37 @@
|
|
|
45
45
|
<span id="app-version" class="app-version"></span>
|
|
46
46
|
</div>
|
|
47
47
|
<div class="toolbar-right">
|
|
48
|
-
<search>
|
|
49
|
-
<
|
|
48
|
+
<search class="search-bar">
|
|
49
|
+
<select id="search-scope" title="Search scope">
|
|
50
|
+
<option value="all">All folders</option>
|
|
51
|
+
<option value="current">This folder</option>
|
|
52
|
+
<option value="server">IMAP server</option>
|
|
53
|
+
</select>
|
|
54
|
+
<input type="search" id="search-input" placeholder="Search... (/regex/)" autocomplete="off" title="Search messages. /pattern/ for regex. Qualifiers: from: to: subject:">
|
|
50
55
|
</search>
|
|
51
|
-
<button class="tb-btn" id="btn-sync" title="Sync">
|
|
52
|
-
<span class="tb-icon"
|
|
56
|
+
<button class="tb-btn" id="btn-sync" title="Sync all folders (F5)">
|
|
57
|
+
<span class="tb-icon">↻</span> Sync
|
|
53
58
|
</button>
|
|
54
|
-
<button class="tb-btn" id="btn-restart" title="Restart server
|
|
55
|
-
<span class="tb-icon"
|
|
59
|
+
<button class="tb-btn" id="btn-restart" title="Restart server and reload page">
|
|
60
|
+
<span class="tb-icon">⚡</span> Restart
|
|
56
61
|
</button>
|
|
57
62
|
</div>
|
|
58
63
|
</header>
|
|
59
64
|
|
|
60
|
-
<
|
|
61
|
-
<div class="
|
|
62
|
-
|
|
65
|
+
<div class="folder-panel">
|
|
66
|
+
<div class="ft-filter">
|
|
67
|
+
<input type="text" id="ft-filter-input" placeholder="Find folder..." autocomplete="off">
|
|
68
|
+
</div>
|
|
69
|
+
<nav class="folder-tree" id="folder-tree">
|
|
70
|
+
<div class="folder-loading">Loading accounts...</div>
|
|
71
|
+
</nav>
|
|
72
|
+
</div>
|
|
63
73
|
|
|
64
74
|
<main class="main-area">
|
|
65
75
|
<section class="message-list" id="message-list">
|
|
76
|
+
<div class="ml-filter">
|
|
77
|
+
<input type="text" id="ml-filter-input" placeholder="Filter..." autocomplete="off">
|
|
78
|
+
</div>
|
|
66
79
|
<div class="ml-header">
|
|
67
80
|
<span class="ml-col ml-col-flag"></span>
|
|
68
81
|
<span class="ml-col ml-col-from" data-sort="from">From</span>
|
|
@@ -78,8 +91,17 @@
|
|
|
78
91
|
|
|
79
92
|
<section class="message-viewer" id="message-viewer">
|
|
80
93
|
<div class="mv-header" id="mv-header" hidden>
|
|
81
|
-
<div class="mv-
|
|
82
|
-
|
|
94
|
+
<div class="mv-header-top">
|
|
95
|
+
<div class="mv-header-info">
|
|
96
|
+
<div class="mv-from"></div>
|
|
97
|
+
<div class="mv-to"></div>
|
|
98
|
+
</div>
|
|
99
|
+
<div class="mv-header-actions">
|
|
100
|
+
<button class="mv-action mv-action-primary" id="mv-edit-draft" hidden>Edit & Send</button>
|
|
101
|
+
<a class="mv-unsubscribe" id="mv-unsubscribe" hidden>Unsubscribe</a>
|
|
102
|
+
<button class="mv-action" id="mv-view-source" title="View source (.eml)" hidden>Source</button>
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
83
105
|
<div class="mv-subject"></div>
|
|
84
106
|
<div class="mv-date"></div>
|
|
85
107
|
</div>
|
|
@@ -96,5 +118,12 @@
|
|
|
96
118
|
<span id="status-pending"></span>
|
|
97
119
|
<span id="status-queue">Queue: empty</span>
|
|
98
120
|
</footer>
|
|
121
|
+
|
|
122
|
+
<div id="startup-overlay" class="startup-overlay">
|
|
123
|
+
<div class="startup-content">
|
|
124
|
+
<div class="startup-spinner"></div>
|
|
125
|
+
<div id="startup-status">Connecting to server...</div>
|
|
126
|
+
</div>
|
|
127
|
+
</div>
|
|
99
128
|
</body>
|
|
100
129
|
</html>
|
package/client/lib/api-client.js
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* API client — auto-detects IPC (WebView) vs HTTP (browser).
|
|
3
|
+
* When mailxapi is available (injected by launcher), calls go directly via IPC.
|
|
4
|
+
* Otherwise falls back to REST/WebSocket.
|
|
4
5
|
*/
|
|
5
|
-
|
|
6
|
+
const hasIPC = typeof mailxapi !== "undefined" && mailxapi?.isApp;
|
|
7
|
+
// ── HTTP fallback ──
|
|
8
|
+
// Abort controller for message-list requests — cancel stale fetches when folder changes
|
|
9
|
+
let messageListAbort = null;
|
|
10
|
+
export function abortMessageListRequests() {
|
|
11
|
+
if (messageListAbort) {
|
|
12
|
+
messageListAbort.abort();
|
|
13
|
+
messageListAbort = null;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function newMessageListSignal() {
|
|
17
|
+
abortMessageListRequests();
|
|
18
|
+
messageListAbort = new AbortController();
|
|
19
|
+
return messageListAbort.signal;
|
|
20
|
+
}
|
|
6
21
|
async function api(path, options) {
|
|
7
22
|
const res = await fetch(`/api${path}`, {
|
|
8
23
|
headers: { "Content-Type": "application/json" },
|
|
@@ -14,54 +29,120 @@ async function api(path, options) {
|
|
|
14
29
|
}
|
|
15
30
|
return res.json();
|
|
16
31
|
}
|
|
17
|
-
// ──
|
|
32
|
+
// ── API Methods (IPC or HTTP) ──
|
|
18
33
|
export function getAccounts() {
|
|
34
|
+
if (hasIPC)
|
|
35
|
+
return mailxapi.getAccounts();
|
|
19
36
|
return api("/accounts");
|
|
20
37
|
}
|
|
21
38
|
export function getFolders(accountId) {
|
|
39
|
+
if (hasIPC)
|
|
40
|
+
return mailxapi.getFolders(accountId);
|
|
22
41
|
return api(`/folders/${accountId}`);
|
|
23
42
|
}
|
|
24
43
|
export function getMessages(accountId, folderId, page = 1, pageSize = 50) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return api(`/
|
|
44
|
+
if (hasIPC)
|
|
45
|
+
return mailxapi.getMessages(accountId, folderId, page, pageSize);
|
|
46
|
+
const signal = newMessageListSignal();
|
|
47
|
+
return api(`/messages/${accountId}/${folderId}?page=${page}&pageSize=${pageSize}`, { signal });
|
|
29
48
|
}
|
|
30
49
|
export function getUnifiedInbox(page = 1, pageSize = 50) {
|
|
31
|
-
|
|
50
|
+
if (hasIPC)
|
|
51
|
+
return mailxapi.getUnifiedInbox(page, pageSize);
|
|
52
|
+
const signal = newMessageListSignal();
|
|
53
|
+
return api(`/messages/unified/inbox?page=${page}&pageSize=${pageSize}`, { signal });
|
|
32
54
|
}
|
|
33
|
-
export function
|
|
34
|
-
|
|
55
|
+
export function searchMessages(query, page = 1, pageSize = 50, scope = "all", accountId = "", folderId = 0) {
|
|
56
|
+
if (hasIPC)
|
|
57
|
+
return mailxapi.searchMessages(query, page, pageSize);
|
|
58
|
+
const params = new URLSearchParams({ q: query, page: String(page), pageSize: String(pageSize), scope });
|
|
59
|
+
if (scope === "current" && accountId) {
|
|
60
|
+
params.set("accountId", accountId);
|
|
61
|
+
params.set("folderId", String(folderId));
|
|
62
|
+
}
|
|
63
|
+
if (scope === "server" && accountId) {
|
|
64
|
+
params.set("accountId", accountId);
|
|
65
|
+
params.set("folderId", String(folderId));
|
|
66
|
+
}
|
|
67
|
+
return api(`/search?${params}`);
|
|
68
|
+
}
|
|
69
|
+
export function getMessage(accountId, uid, allowRemote = false, folderId) {
|
|
70
|
+
if (hasIPC)
|
|
71
|
+
return mailxapi.getMessage(accountId, uid, allowRemote, folderId);
|
|
72
|
+
const params = new URLSearchParams();
|
|
73
|
+
if (allowRemote)
|
|
74
|
+
params.set("allowRemote", "true");
|
|
75
|
+
if (folderId != null)
|
|
76
|
+
params.set("folderId", String(folderId));
|
|
77
|
+
const q = params.toString() ? `?${params}` : "";
|
|
35
78
|
return api(`/message/${accountId}/${uid}${q}`);
|
|
36
79
|
}
|
|
37
80
|
export function updateFlags(accountId, uid, flags) {
|
|
81
|
+
if (hasIPC)
|
|
82
|
+
return mailxapi.updateFlags(accountId, uid, flags);
|
|
38
83
|
return api(`/message/${accountId}/${uid}/flags`, {
|
|
39
84
|
method: "PATCH",
|
|
40
85
|
body: JSON.stringify({ flags })
|
|
41
86
|
});
|
|
42
87
|
}
|
|
43
88
|
export function triggerSync() {
|
|
89
|
+
if (hasIPC)
|
|
90
|
+
return mailxapi.syncAll();
|
|
44
91
|
return api("/sync", { method: "POST" });
|
|
45
92
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
93
|
+
export function getVersion() {
|
|
94
|
+
if (hasIPC)
|
|
95
|
+
return mailxapi.getVersion();
|
|
96
|
+
return api("/version");
|
|
97
|
+
}
|
|
98
|
+
export function getSyncPending() {
|
|
99
|
+
if (hasIPC)
|
|
100
|
+
return mailxapi.getSyncPending();
|
|
101
|
+
return api("/sync/pending");
|
|
102
|
+
}
|
|
103
|
+
export function searchContacts(query) {
|
|
104
|
+
if (hasIPC)
|
|
105
|
+
return mailxapi.searchContacts(query);
|
|
106
|
+
return api(`/contacts?q=${encodeURIComponent(query)}`);
|
|
107
|
+
}
|
|
108
|
+
export function allowRemoteContent(type, value) {
|
|
109
|
+
if (hasIPC)
|
|
110
|
+
return mailxapi.allowRemoteContent(type, value);
|
|
111
|
+
return api("/settings/allow-remote", {
|
|
112
|
+
method: "POST",
|
|
113
|
+
body: JSON.stringify({ type, value })
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
const eventHandlers = [];
|
|
117
|
+
export function onEvent(handler) {
|
|
118
|
+
eventHandlers.push(handler);
|
|
119
|
+
}
|
|
120
|
+
export function connectEvents() {
|
|
121
|
+
if (hasIPC) {
|
|
122
|
+
// IPC events come via mailxapi.onEvent
|
|
123
|
+
mailxapi.onEvent((event) => {
|
|
124
|
+
for (const h of eventHandlers)
|
|
125
|
+
h(event);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
// WebSocket for HTTP mode
|
|
130
|
+
const protocol = location.protocol === "https:" ? "wss:" : "ws:";
|
|
131
|
+
const ws = new WebSocket(`${protocol}//${location.host}`);
|
|
132
|
+
ws.onmessage = (ev) => {
|
|
133
|
+
try {
|
|
134
|
+
const event = JSON.parse(ev.data);
|
|
135
|
+
for (const h of eventHandlers)
|
|
136
|
+
h(event);
|
|
137
|
+
}
|
|
138
|
+
catch { /* ignore */ }
|
|
139
|
+
};
|
|
140
|
+
ws.onclose = () => {
|
|
141
|
+
setTimeout(connectEvents, 3000);
|
|
142
|
+
};
|
|
143
|
+
}
|
|
66
144
|
}
|
|
145
|
+
// Legacy exports for backward compatibility
|
|
146
|
+
export const connectWebSocket = connectEvents;
|
|
147
|
+
export const onWsEvent = onEvent;
|
|
67
148
|
//# sourceMappingURL=api-client.js.map
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mailxapi — IPC bridge injected into WebView by the Rust launcher.
|
|
3
|
+
* Follows the msgapi pattern: callNode → Promise → _mailxapiResolve/Reject.
|
|
4
|
+
*
|
|
5
|
+
* When running in a browser (no IPC), this file is not loaded.
|
|
6
|
+
* api-client.ts auto-detects and falls back to HTTP fetch.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
(function() {
|
|
10
|
+
"use strict";
|
|
11
|
+
|
|
12
|
+
var _callbacks = {};
|
|
13
|
+
var _callbackId = 0;
|
|
14
|
+
var _eventHandlers = [];
|
|
15
|
+
|
|
16
|
+
function callNode(action, params) {
|
|
17
|
+
var id = String(++_callbackId);
|
|
18
|
+
return new Promise(function(resolve, reject) {
|
|
19
|
+
var timer = setTimeout(function() {
|
|
20
|
+
delete _callbacks[id];
|
|
21
|
+
reject(new Error("mailxapi timeout: " + action));
|
|
22
|
+
}, 30000);
|
|
23
|
+
_callbacks[id] = { resolve: resolve, reject: reject, timer: timer };
|
|
24
|
+
var msg = Object.assign({ _action: action, _cbid: id }, params || {});
|
|
25
|
+
if (window.ipc && window.ipc.postMessage) {
|
|
26
|
+
window.ipc.postMessage(JSON.stringify(msg));
|
|
27
|
+
} else {
|
|
28
|
+
// Fallback: should not happen in WebView
|
|
29
|
+
clearTimeout(timer);
|
|
30
|
+
delete _callbacks[id];
|
|
31
|
+
reject(new Error("No IPC channel available"));
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Called by Rust to resolve promises
|
|
37
|
+
window._mailxapiResolve = function(id, value) {
|
|
38
|
+
var cb = _callbacks[id];
|
|
39
|
+
if (!cb) return;
|
|
40
|
+
delete _callbacks[id];
|
|
41
|
+
clearTimeout(cb.timer);
|
|
42
|
+
cb.resolve(value);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// Called by Rust to reject promises
|
|
46
|
+
window._mailxapiReject = function(id, error) {
|
|
47
|
+
var cb = _callbacks[id];
|
|
48
|
+
if (!cb) return;
|
|
49
|
+
delete _callbacks[id];
|
|
50
|
+
clearTimeout(cb.timer);
|
|
51
|
+
cb.reject(new Error(error));
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// Called by Rust to push events (new mail, sync progress, etc.)
|
|
55
|
+
window._mailxapiEvent = function(event) {
|
|
56
|
+
for (var i = 0; i < _eventHandlers.length; i++) {
|
|
57
|
+
try { _eventHandlers[i](event); } catch(e) { /* ignore */ }
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
window.mailxapi = {
|
|
62
|
+
isApp: true,
|
|
63
|
+
platform: "webview2",
|
|
64
|
+
|
|
65
|
+
// Accounts
|
|
66
|
+
getAccounts: function() { return callNode("getAccounts"); },
|
|
67
|
+
getFolders: function(accountId) { return callNode("getFolders", { accountId: accountId }); },
|
|
68
|
+
|
|
69
|
+
// Messages
|
|
70
|
+
getMessages: function(accountId, folderId, page, pageSize) {
|
|
71
|
+
return callNode("getMessages", { accountId: accountId, folderId: folderId, page: page, pageSize: pageSize });
|
|
72
|
+
},
|
|
73
|
+
getUnifiedInbox: function(page, pageSize) {
|
|
74
|
+
return callNode("getUnifiedInbox", { page: page, pageSize: pageSize });
|
|
75
|
+
},
|
|
76
|
+
getMessage: function(accountId, uid, allowRemote) {
|
|
77
|
+
return callNode("getMessage", { accountId: accountId, uid: uid, allowRemote: allowRemote });
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
// Actions
|
|
81
|
+
updateFlags: function(accountId, uid, flags) {
|
|
82
|
+
return callNode("updateFlags", { accountId: accountId, uid: uid, flags: flags });
|
|
83
|
+
},
|
|
84
|
+
deleteMessage: function(accountId, uid) {
|
|
85
|
+
return callNode("deleteMessage", { accountId: accountId, uid: uid });
|
|
86
|
+
},
|
|
87
|
+
undeleteMessage: function(accountId, uid, folderId) {
|
|
88
|
+
return callNode("undeleteMessage", { accountId: accountId, uid: uid, folderId: folderId });
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
// Compose
|
|
92
|
+
sendMessage: function(msg) { return callNode("sendMessage", msg); },
|
|
93
|
+
saveDraft: function(params) { return callNode("saveDraft", params); },
|
|
94
|
+
deleteDraft: function(accountId, draftUid) {
|
|
95
|
+
return callNode("deleteDraft", { accountId: accountId, draftUid: draftUid });
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
// Search
|
|
99
|
+
searchMessages: function(query, page, pageSize) {
|
|
100
|
+
return callNode("searchMessages", { query: query, page: page, pageSize: pageSize });
|
|
101
|
+
},
|
|
102
|
+
searchContacts: function(query) {
|
|
103
|
+
return callNode("searchContacts", { query: query });
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
// Sync
|
|
107
|
+
syncAll: function() { return callNode("syncAll"); },
|
|
108
|
+
getSyncPending: function() { return callNode("getSyncPending"); },
|
|
109
|
+
|
|
110
|
+
// Settings
|
|
111
|
+
allowRemoteContent: function(type, value) {
|
|
112
|
+
return callNode("allowRemoteContent", { type: type, value: value });
|
|
113
|
+
},
|
|
114
|
+
getSettings: function() { return callNode("getSettings"); },
|
|
115
|
+
saveSettings: function(data) { return callNode("saveSettingsData", data); },
|
|
116
|
+
getVersion: function() { return callNode("getVersion"); },
|
|
117
|
+
|
|
118
|
+
// Events
|
|
119
|
+
onEvent: function(handler) { _eventHandlers.push(handler); },
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
window.dispatchEvent(new CustomEvent("mailxapiready"));
|
|
123
|
+
})();
|