@zaclinley/dsh-mailharbor 0.7.2 → 0.9.0
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/CHANGELOG.md +27 -0
- package/lib/client.js +478 -111
- package/lib/client.js.map +2 -2
- package/lib/index.js +14 -3
- package/lib/index.js.map +2 -2
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -225,6 +225,7 @@ var init_imap = __esm({
|
|
|
225
225
|
mailboxCache = null;
|
|
226
226
|
countCache = /* @__PURE__ */ new Map();
|
|
227
227
|
pageCache = /* @__PURE__ */ new Map();
|
|
228
|
+
readCache = /* @__PURE__ */ new Map();
|
|
228
229
|
keepalive = null;
|
|
229
230
|
static MAILBOX_TTL_MS = 6e4;
|
|
230
231
|
constructor(settings, credentials, options = {}) {
|
|
@@ -426,6 +427,9 @@ var init_imap = __esm({
|
|
|
426
427
|
});
|
|
427
428
|
}
|
|
428
429
|
async read(mailbox, uid) {
|
|
430
|
+
const cacheKey = `${mailbox}:${String(uid)}`;
|
|
431
|
+
const cached = this.readCache.get(cacheKey);
|
|
432
|
+
if (cached !== void 0 && Date.now() - cached.at < 3e5) return cached.message;
|
|
429
433
|
return this.run(async (client) => {
|
|
430
434
|
const lock = await client.getMailboxLock(mailbox);
|
|
431
435
|
try {
|
|
@@ -440,7 +444,7 @@ var init_imap = __esm({
|
|
|
440
444
|
const parsed = await simpleParser2(message.source);
|
|
441
445
|
const base = toMessage(message);
|
|
442
446
|
const html = typeof parsed.html === "string" ? parsed.html : Buffer.isBuffer(parsed.html) ? parsed.html.toString("utf8") : null;
|
|
443
|
-
|
|
447
|
+
const detail = {
|
|
444
448
|
...base,
|
|
445
449
|
text: typeof parsed.text === "string" ? parsed.text : "",
|
|
446
450
|
html: html === "" ? null : html,
|
|
@@ -448,6 +452,12 @@ var init_imap = __esm({
|
|
|
448
452
|
inReplyTo: normalizeId2(parsed.inReplyTo),
|
|
449
453
|
references: String(parsed.references ?? "").split(/\s+/).map(normalizeId2).filter((item) => item !== "")
|
|
450
454
|
};
|
|
455
|
+
this.readCache.set(cacheKey, { at: Date.now(), message: detail });
|
|
456
|
+
if (this.readCache.size > 40) {
|
|
457
|
+
const oldest = this.readCache.keys().next().value;
|
|
458
|
+
if (oldest !== void 0) this.readCache.delete(oldest);
|
|
459
|
+
}
|
|
460
|
+
return detail;
|
|
451
461
|
} finally {
|
|
452
462
|
lock.release();
|
|
453
463
|
}
|
|
@@ -537,6 +547,7 @@ var init_imap = __esm({
|
|
|
537
547
|
async dispose() {
|
|
538
548
|
this.disposed = true;
|
|
539
549
|
this.pageCache.clear();
|
|
550
|
+
this.readCache.clear();
|
|
540
551
|
this.stopKeepalive();
|
|
541
552
|
await this.reset("dispose");
|
|
542
553
|
}
|
|
@@ -1781,7 +1792,7 @@ var SEARCH_SYSTEM = `\u4F60\u662F\u90AE\u4EF6\u641C\u7D22\u52A9\u624B\u3002\u628
|
|
|
1781
1792
|
var TASK_SYSTEM = `\u4F60\u662F\u4EFB\u52A1\u63D0\u53D6\u52A9\u624B\u3002\u4ECE\u90AE\u4EF6\u4E2D\u63D0\u53D6\u9700\u8981\u7528\u6237\u5904\u7406\u7684\u5177\u4F53\u4E8B\u9879\u3002
|
|
1782
1793
|
|
|
1783
1794
|
\u53EA\u8F93\u51FA\u4E00\u4E2A JSON \u6570\u7EC4\uFF0C\u4E0D\u8981\u8F93\u51FA\u89E3\u91CA\u3001Markdown \u6216\u4EE3\u7801\u5757\u6807\u8BB0\u3002\u6BCF\u4E2A\u5143\u7D20\uFF1A
|
|
1784
|
-
{"title": "\u4EFB\u52A1\u6807\u9898\uFF08\u52A8\u8BCD\u5F00\u5934\uFF0C\u5C3D\u91CF\u5177\u4F53\uFF09", "due": "YYYY-MM-DD \u6216\u7A7A\u5B57\u7B26\u4E32", "priority": 0 \u5230 9 \u7684\u6574\u6570, "owner": "\
|
|
1795
|
+
{"title": "\u4EFB\u52A1\u6807\u9898\uFF08\u52A8\u8BCD\u5F00\u5934\uFF0C\u5C3D\u91CF\u5177\u4F53\uFF09", "due": "YYYY-MM-DD \u6216\u7A7A\u5B57\u7B26\u4E32", "priority": 0 \u5230 9 \u7684\u6574\u6570, "owner": "\u8FD9\u4E2A\u4E8B\u8BE5\u8054\u7CFB\u8C01\uFF08\u90AE\u4EF6\u91CC\u7684\u8054\u7CFB\u4EBA\uFF09\u6216\u7A7A\u5B57\u7B26\u4E32", "notes": "\u4E00\u53E5\u6765\u6E90\u4F9D\u636E"}
|
|
1785
1796
|
|
|
1786
1797
|
\u89C4\u5219\uFF1A
|
|
1787
1798
|
- \u53EA\u63D0\u53D6\u90AE\u4EF6\u91CC\u660E\u786E\u8981\u6C42\u3001\u6216\u660E\u663E\u9700\u8981\u8DDF\u8FDB\u7684\u4E8B\u9879
|
|
@@ -2338,7 +2349,7 @@ ${conversation.trim()}
|
|
|
2338
2349
|
}
|
|
2339
2350
|
|
|
2340
2351
|
// src/host/version.ts
|
|
2341
|
-
var VERSION = "0.
|
|
2352
|
+
var VERSION = "0.9.0";
|
|
2342
2353
|
|
|
2343
2354
|
// src/host/api.ts
|
|
2344
2355
|
init_smtp();
|