@im-more/dsh-mail 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/cordis.patch.yml +14 -0
- package/lib/index.js +1334 -0
- package/lib/index.js.map +1 -0
- package/lib/types/bot.d.ts +49 -0
- package/lib/types/bot.d.ts.map +1 -0
- package/lib/types/bot.js +189 -0
- package/lib/types/bot.js.map +1 -0
- package/lib/types/config.d.ts +51 -0
- package/lib/types/config.d.ts.map +1 -0
- package/lib/types/config.js +55 -0
- package/lib/types/config.js.map +1 -0
- package/lib/types/decode.d.ts +60 -0
- package/lib/types/decode.d.ts.map +1 -0
- package/lib/types/decode.js +195 -0
- package/lib/types/decode.js.map +1 -0
- package/lib/types/errors.d.ts +33 -0
- package/lib/types/errors.d.ts.map +1 -0
- package/lib/types/errors.js +156 -0
- package/lib/types/errors.js.map +1 -0
- package/lib/types/html.d.ts +30 -0
- package/lib/types/html.d.ts.map +1 -0
- package/lib/types/html.js +121 -0
- package/lib/types/html.js.map +1 -0
- package/lib/types/index.d.ts +11 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +10 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/mail.d.ts +24 -0
- package/lib/types/mail.d.ts.map +1 -0
- package/lib/types/mail.js +26 -0
- package/lib/types/mail.js.map +1 -0
- package/lib/types/media.d.ts +52 -0
- package/lib/types/media.d.ts.map +1 -0
- package/lib/types/media.js +81 -0
- package/lib/types/media.js.map +1 -0
- package/lib/types/modes/html.d.ts +13 -0
- package/lib/types/modes/html.d.ts.map +1 -0
- package/lib/types/modes/html.js +70 -0
- package/lib/types/modes/html.js.map +1 -0
- package/lib/types/modes/shared.d.ts +114 -0
- package/lib/types/modes/shared.d.ts.map +1 -0
- package/lib/types/modes/shared.js +185 -0
- package/lib/types/modes/shared.js.map +1 -0
- package/lib/types/send.d.ts +26 -0
- package/lib/types/send.d.ts.map +1 -0
- package/lib/types/send.js +58 -0
- package/lib/types/send.js.map +1 -0
- package/lib/types/transport/imap.d.ts +95 -0
- package/lib/types/transport/imap.d.ts.map +1 -0
- package/lib/types/transport/imap.js +354 -0
- package/lib/types/transport/imap.js.map +1 -0
- package/package.json +70 -3
- package/src/bot.ts +264 -0
- package/src/config.ts +98 -0
- package/src/decode.ts +275 -0
- package/src/errors.ts +199 -0
- package/src/html.ts +137 -0
- package/src/index.ts +32 -0
- package/src/mail.ts +46 -0
- package/src/media.ts +102 -0
- package/src/modes/html.ts +105 -0
- package/src/modes/shared.ts +285 -0
- package/src/send.ts +87 -0
- package/src/transport/imap.ts +418 -0
- package/README.md +0 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAA;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,MAAM,IAAI,UAAU,EAAE,MAAM,aAAa,CAAA;AAC1E,OAAO,EACL,cAAc,EACd,aAAa,EACb,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,UAAU,GAChB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,iBAAiB,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AACjE,OAAO,EACL,YAAY,EACZ,KAAK,WAAW,EAChB,KAAK,gBAAgB,GACtB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,YAAY,EACV,SAAS,EACT,aAAa,EACb,QAAQ,EACR,WAAW,EACX,qBAAqB,GACtB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAA;AAC1D,OAAO,EACL,aAAa,EACb,KAAK,SAAS,EACd,KAAK,oBAAoB,EACzB,KAAK,UAAU,GAChB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,IAAI,EAAE,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { MailBot, MailBot as default } from "./bot.js";
|
|
2
|
+
export { addressOf, Config } from "./config.js";
|
|
3
|
+
export { attachmentKind, decodeMessage, } from "./decode.js";
|
|
4
|
+
export { classifyMailError } from "./errors.js";
|
|
5
|
+
export { MediaStaging, } from "./media.js";
|
|
6
|
+
export { createHtmlMode } from "./modes/html.js";
|
|
7
|
+
export { sendPayload } from "./send.js";
|
|
8
|
+
export { ImapTransport, } from "./transport/imap.js";
|
|
9
|
+
export { SMTP } from "./mail.js";
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAkB,MAAM,UAAU,CAAA;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,EAA6B,MAAM,aAAa,CAAA;AAC1E,OAAO,EACL,cAAc,EACd,aAAa,GAKd,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,iBAAiB,EAAoB,MAAM,aAAa,CAAA;AACjE,OAAO,EACL,YAAY,GAGb,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAQhD,OAAO,EAAE,WAAW,EAAqB,MAAM,WAAW,CAAA;AAC1D,OAAO,EACL,aAAa,GAId,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,IAAI,EAAqC,MAAM,WAAW,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Transporter } from 'nodemailer';
|
|
2
|
+
import type { Config } from './config.ts';
|
|
3
|
+
export interface Attachment {
|
|
4
|
+
filename?: string;
|
|
5
|
+
content: Buffer;
|
|
6
|
+
contentType: string;
|
|
7
|
+
cid?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface SendOptions {
|
|
10
|
+
to: string;
|
|
11
|
+
html: string;
|
|
12
|
+
text?: string;
|
|
13
|
+
attachments?: Attachment[];
|
|
14
|
+
subject?: string;
|
|
15
|
+
inReplyTo?: string;
|
|
16
|
+
references?: string[];
|
|
17
|
+
}
|
|
18
|
+
export declare class SMTP {
|
|
19
|
+
transporter: Transporter;
|
|
20
|
+
from: string;
|
|
21
|
+
constructor(config: Config);
|
|
22
|
+
send(options: SendOptions): Promise<string>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=mail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mail.d.ts","sourceRoot":"","sources":["../../src/mail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,WAAW,EAAE,MAAM,YAAY,CAAA;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,UAAU,EAAE,CAAA;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;CACtB;AAED,qBAAa,IAAI;IACf,WAAW,EAAE,WAAW,CAAA;IACxB,IAAI,EAAE,MAAM,CAAA;gBAEA,MAAM,EAAE,MAAM;IAcpB,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;CAOlD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createTransport } from 'nodemailer';
|
|
2
|
+
export class SMTP {
|
|
3
|
+
transporter;
|
|
4
|
+
from;
|
|
5
|
+
constructor(config) {
|
|
6
|
+
this.transporter = createTransport({
|
|
7
|
+
host: config.smtp.host,
|
|
8
|
+
port: config.smtp.port,
|
|
9
|
+
secure: config.smtp.tls,
|
|
10
|
+
auth: {
|
|
11
|
+
user: config.username,
|
|
12
|
+
pass: config.password,
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
const address = config.selfId || config.username;
|
|
16
|
+
this.from = config.name ? `${config.name} <${address}>` : address;
|
|
17
|
+
}
|
|
18
|
+
async send(options) {
|
|
19
|
+
const info = await this.transporter.sendMail({
|
|
20
|
+
...options,
|
|
21
|
+
from: this.from,
|
|
22
|
+
});
|
|
23
|
+
return info.messageId;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=mail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mail.js","sourceRoot":"","sources":["../../src/mail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAe,MAAM,YAAY,CAAA;AAoBzD,MAAM,OAAO,IAAI;IACf,WAAW,CAAa;IACxB,IAAI,CAAQ;IAEZ,YAAY,MAAc;QACxB,IAAI,CAAC,WAAW,GAAG,eAAe,CAAC;YACjC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI;YACtB,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI;YACtB,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG;YACvB,IAAI,EAAE;gBACJ,IAAI,EAAE,MAAM,CAAC,QAAQ;gBACrB,IAAI,EAAE,MAAM,CAAC,QAAQ;aACtB;SACF,CAAC,CAAA;QACF,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAA;QAChD,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,KAAK,OAAO,GAAG,CAAC,CAAC,CAAC,OAAO,CAAA;IACnE,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,OAAoB;QAC7B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;YAC3C,GAAG,OAAO;YACV,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC,CAAA;QACF,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC;CACF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { ResolvedResource } from '@deepseek-ai/cordis-plugin-im-core';
|
|
2
|
+
/** Bytes staged for one outbound attachment. */
|
|
3
|
+
export interface StagedMedia {
|
|
4
|
+
data: Uint8Array;
|
|
5
|
+
/** Name the source suggested, if any; the payload decides the final file name. */
|
|
6
|
+
name: string;
|
|
7
|
+
mime?: string | undefined;
|
|
8
|
+
}
|
|
9
|
+
/** What a staged resource carries beyond its key. */
|
|
10
|
+
export interface StagedMediaExtra {
|
|
11
|
+
name?: string | undefined;
|
|
12
|
+
mime?: string | undefined;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Bounded in-memory staging for outbound attachments.
|
|
16
|
+
*
|
|
17
|
+
* SMTP has no upload step: the bytes must ride the MIME body of the message that references them, and `serialize` is
|
|
18
|
+
* pure, so `upload` fetches and stages the bytes and `sendPayload` reads them back by key. Entries expire and the
|
|
19
|
+
* whole store is bounded. A key is the Content-ID of its attachment (and the `cid:` target of the HTML part), which
|
|
20
|
+
* makes it safe inside a `Message-ID`-style bracket.
|
|
21
|
+
*
|
|
22
|
+
* A key is single-use: the resolved resource carries `expiresAt: 0`, so the pipeline cache never reuses a key whose
|
|
23
|
+
* bytes a successful send released.
|
|
24
|
+
*/
|
|
25
|
+
export declare class MediaStaging {
|
|
26
|
+
private readonly ttlMs;
|
|
27
|
+
private readonly maxBytes;
|
|
28
|
+
private readonly entries;
|
|
29
|
+
private bytes;
|
|
30
|
+
constructor(ttlMs: number, maxBytes: number);
|
|
31
|
+
/**
|
|
32
|
+
* Stage bytes under a fresh Content-ID.
|
|
33
|
+
* @param media - the bytes, their suggested name and MIME type.
|
|
34
|
+
* @returns the resource key `prepare` hands to `serialize`; it is also the `cid`.
|
|
35
|
+
*/
|
|
36
|
+
stage(media: StagedMedia): ResolvedResource;
|
|
37
|
+
/**
|
|
38
|
+
* Read staged bytes without releasing them.
|
|
39
|
+
* @param key - a key returned by {@link stage}.
|
|
40
|
+
* @returns the staged media, or undefined once expired, evicted or released.
|
|
41
|
+
*/
|
|
42
|
+
get(key: string): StagedMedia | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Read staged bytes and release them (a published message needs them no more).
|
|
45
|
+
* @param key - a key returned by {@link stage}.
|
|
46
|
+
* @returns the staged media, or undefined once expired, evicted or released.
|
|
47
|
+
*/
|
|
48
|
+
take(key: string): StagedMedia | undefined;
|
|
49
|
+
private prune;
|
|
50
|
+
private evict;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=media.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../src/media.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAA;AAG1E,gDAAgD;AAChD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,UAAU,CAAA;IAChB,kFAAkF;IAClF,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC1B;AAED,qDAAqD;AACrD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC1B;AAQD;;;;;;;;;;GAUG;AACH,qBAAa,YAAY;IAKrB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAL3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2B;IACnD,OAAO,CAAC,KAAK,CAAI;gBAGE,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM;IAGnC;;;;OAIG;IACH,KAAK,CAAC,KAAK,EAAE,WAAW,GAAG,gBAAgB;IAY3C;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAKzC;;;;OAIG;IACH,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAS1C,OAAO,CAAC,KAAK;IAQb,OAAO,CAAC,KAAK;CASd"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
/**
|
|
3
|
+
* Bounded in-memory staging for outbound attachments.
|
|
4
|
+
*
|
|
5
|
+
* SMTP has no upload step: the bytes must ride the MIME body of the message that references them, and `serialize` is
|
|
6
|
+
* pure, so `upload` fetches and stages the bytes and `sendPayload` reads them back by key. Entries expire and the
|
|
7
|
+
* whole store is bounded. A key is the Content-ID of its attachment (and the `cid:` target of the HTML part), which
|
|
8
|
+
* makes it safe inside a `Message-ID`-style bracket.
|
|
9
|
+
*
|
|
10
|
+
* A key is single-use: the resolved resource carries `expiresAt: 0`, so the pipeline cache never reuses a key whose
|
|
11
|
+
* bytes a successful send released.
|
|
12
|
+
*/
|
|
13
|
+
export class MediaStaging {
|
|
14
|
+
ttlMs;
|
|
15
|
+
maxBytes;
|
|
16
|
+
entries = new Map();
|
|
17
|
+
bytes = 0;
|
|
18
|
+
constructor(ttlMs, maxBytes) {
|
|
19
|
+
this.ttlMs = ttlMs;
|
|
20
|
+
this.maxBytes = maxBytes;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Stage bytes under a fresh Content-ID.
|
|
24
|
+
* @param media - the bytes, their suggested name and MIME type.
|
|
25
|
+
* @returns the resource key `prepare` hands to `serialize`; it is also the `cid`.
|
|
26
|
+
*/
|
|
27
|
+
stage(media) {
|
|
28
|
+
const now = Date.now();
|
|
29
|
+
this.prune(now);
|
|
30
|
+
const key = randomUUID().replaceAll('-', '');
|
|
31
|
+
const bytes = media.data.byteLength;
|
|
32
|
+
this.entries.set(key, { media, bytes, expiresAt: now + this.ttlMs });
|
|
33
|
+
this.bytes += bytes;
|
|
34
|
+
this.evict();
|
|
35
|
+
const extra = { name: media.name, mime: media.mime };
|
|
36
|
+
return { key, expiresAt: 0, extra };
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Read staged bytes without releasing them.
|
|
40
|
+
* @param key - a key returned by {@link stage}.
|
|
41
|
+
* @returns the staged media, or undefined once expired, evicted or released.
|
|
42
|
+
*/
|
|
43
|
+
get(key) {
|
|
44
|
+
this.prune(Date.now());
|
|
45
|
+
return this.entries.get(key)?.media;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Read staged bytes and release them (a published message needs them no more).
|
|
49
|
+
* @param key - a key returned by {@link stage}.
|
|
50
|
+
* @returns the staged media, or undefined once expired, evicted or released.
|
|
51
|
+
*/
|
|
52
|
+
take(key) {
|
|
53
|
+
this.prune(Date.now());
|
|
54
|
+
const entry = this.entries.get(key);
|
|
55
|
+
if (entry === undefined)
|
|
56
|
+
return undefined;
|
|
57
|
+
this.entries.delete(key);
|
|
58
|
+
this.bytes -= entry.bytes;
|
|
59
|
+
return entry.media;
|
|
60
|
+
}
|
|
61
|
+
prune(now) {
|
|
62
|
+
for (const [key, entry] of this.entries) {
|
|
63
|
+
if (entry.expiresAt > now)
|
|
64
|
+
continue;
|
|
65
|
+
this.entries.delete(key);
|
|
66
|
+
this.bytes -= entry.bytes;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
evict() {
|
|
70
|
+
while (this.bytes > this.maxBytes) {
|
|
71
|
+
const oldest = this.entries.keys().next();
|
|
72
|
+
if (oldest.done === true)
|
|
73
|
+
return;
|
|
74
|
+
const entry = this.entries.get(oldest.value);
|
|
75
|
+
this.entries.delete(oldest.value);
|
|
76
|
+
if (entry !== undefined)
|
|
77
|
+
this.bytes -= entry.bytes;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=media.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.js","sourceRoot":"","sources":["../../src/media.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAsBxC;;;;;;;;;;GAUG;AACH,MAAM,OAAO,YAAY;IAKJ;IACA;IALF,OAAO,GAAG,IAAI,GAAG,EAAiB,CAAA;IAC3C,KAAK,GAAG,CAAC,CAAA;IAEjB,YACmB,KAAa,EACb,QAAgB;QADhB,UAAK,GAAL,KAAK,CAAQ;QACb,aAAQ,GAAR,QAAQ,CAAQ;IAChC,CAAC;IAEJ;;;;OAIG;IACH,KAAK,CAAC,KAAkB;QACtB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QACtB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACf,MAAM,GAAG,GAAG,UAAU,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;QAC5C,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAA;QACnC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,CAAA;QACpE,IAAI,CAAC,KAAK,IAAI,KAAK,CAAA;QACnB,IAAI,CAAC,KAAK,EAAE,CAAA;QACZ,MAAM,KAAK,GAAqB,EAAE,IAAI,EAAE,KAAK,CAA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IAAI;gBAAE,OAAM;YAChC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;YAC5C,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;YACjC,IAAI,KAAK,KAAK,SAAS;gBAAE,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAA;QACpD,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `html` mode: the only mode, a single MIME message per logical message.
|
|
3
|
+
*
|
|
4
|
+
* Native tags are the inline subset a mail body can express (`b`/`i`/`u`/`s`/`code`/`pre`/`a`/`p`/`blockquote`/
|
|
5
|
+
* lists and media). Everything else takes the core fallback and is reported as degraded. `assemble` always returns
|
|
6
|
+
* one draft — mail has no message splitting — and `serialize` writes the `<pre>`-wrapped HTML, the plain-text
|
|
7
|
+
* alternative and the attachments.
|
|
8
|
+
*/
|
|
9
|
+
import type { Mode } from '@deepseek-ai/cordis-plugin-im-core';
|
|
10
|
+
import type { MailModeTypes } from './shared.ts';
|
|
11
|
+
/** Build the `html` mode. */
|
|
12
|
+
export declare function createHtmlMode(): Mode<MailModeTypes>;
|
|
13
|
+
//# sourceMappingURL=html.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../../src/modes/html.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAiB,MAAM,oCAAoC,CAAA;AAY7E,OAAO,KAAK,EAAE,aAAa,EAAY,MAAM,aAAa,CAAA;AAe1D,6BAA6B;AAC7B,wBAAgB,cAAc,IAAI,IAAI,CAAC,aAAa,CAAC,CAkEpD"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `html` mode: the only mode, a single MIME message per logical message.
|
|
3
|
+
*
|
|
4
|
+
* Native tags are the inline subset a mail body can express (`b`/`i`/`u`/`s`/`code`/`pre`/`a`/`p`/`blockquote`/
|
|
5
|
+
* lists and media). Everything else takes the core fallback and is reported as degraded. `assemble` always returns
|
|
6
|
+
* one draft — mail has no message splitting — and `serialize` writes the `<pre>`-wrapped HTML, the plain-text
|
|
7
|
+
* alternative and the attachments.
|
|
8
|
+
*/
|
|
9
|
+
import { ElementRegistry } from '@deepseek-ai/cordis-plugin-im-core';
|
|
10
|
+
import { assembleDraft, escapeAttribute, escapeHtml, inlineNode, inlineRun, inlineWrapper, mediaNode, serializeDraft, } from "./shared.js";
|
|
11
|
+
/** An address a `mailto:` link can carry. */
|
|
12
|
+
const MAIL_ADDRESS = /^[^\s@<>]+@[^\s@<>]+$/;
|
|
13
|
+
/** Wrap the inline text of `children` in one tag, letting media of the subtree follow it. */
|
|
14
|
+
function wrap(tag, ctx, children, textSuffix = '') {
|
|
15
|
+
return inlineWrapper(tag, ctx.render(children), textSuffix);
|
|
16
|
+
}
|
|
17
|
+
/** Build the `html` mode. */
|
|
18
|
+
export function createHtmlMode() {
|
|
19
|
+
const elements = new ElementRegistry()
|
|
20
|
+
.register('text', (el) => inlineNode(escapeHtml(el.attrs.content), el.attrs.content))
|
|
21
|
+
.register('br', () => inlineNode('<br>', '\n'))
|
|
22
|
+
.register('p', (el, ctx) => wrap('p', ctx, el.children, '\n\n'))
|
|
23
|
+
.register('b', (el, ctx) => wrap('b', ctx, el.children))
|
|
24
|
+
.register('i', (el, ctx) => wrap('i', ctx, el.children))
|
|
25
|
+
.register('u', (el, ctx) => wrap('u', ctx, el.children))
|
|
26
|
+
.register('s', (el, ctx) => wrap('s', ctx, el.children))
|
|
27
|
+
.register('code', (el, ctx) => {
|
|
28
|
+
const content = ctx.text(el.children);
|
|
29
|
+
return inlineNode(`<code>${escapeHtml(content)}</code>`, content);
|
|
30
|
+
})
|
|
31
|
+
.register('pre', (el, ctx) => {
|
|
32
|
+
const content = ctx.text(el.children);
|
|
33
|
+
return inlineNode(`<pre>${escapeHtml(content)}</pre>`, `${content}\n\n`);
|
|
34
|
+
})
|
|
35
|
+
.register('blockquote', (el, ctx) => wrap('blockquote', ctx, el.children, '\n\n'))
|
|
36
|
+
.register('ul', (el, ctx) => wrap('ul', ctx, el.children))
|
|
37
|
+
.register('ol', (el, ctx) => wrap('ol', ctx, el.children))
|
|
38
|
+
.register('li', (el, ctx) => wrap('li', ctx, el.children, '\n'))
|
|
39
|
+
.register('a', (el, ctx) => {
|
|
40
|
+
const { html, text, rest } = inlineRun(ctx.render(el.children));
|
|
41
|
+
const href = el.attrs.href;
|
|
42
|
+
const label = html === '' ? escapeHtml(href) : html;
|
|
43
|
+
const plain = text === '' ? href : text;
|
|
44
|
+
const plainText = plain === href ? href : `${plain} (${href})`;
|
|
45
|
+
return [
|
|
46
|
+
inlineNode(`<a href="${escapeAttribute(href)}">${label}</a>`, plainText),
|
|
47
|
+
...rest,
|
|
48
|
+
];
|
|
49
|
+
})
|
|
50
|
+
.register('at', (el) => {
|
|
51
|
+
const id = el.attrs.id;
|
|
52
|
+
const label = el.attrs.name ?? id ?? el.attrs.type;
|
|
53
|
+
if (id !== undefined && MAIL_ADDRESS.test(id)) {
|
|
54
|
+
return inlineNode(`<a href="mailto:${escapeAttribute(id)}">@${escapeHtml(id)}</a>`, `@${id}`);
|
|
55
|
+
}
|
|
56
|
+
return inlineNode(escapeHtml(`@${label}`), `@${label}`);
|
|
57
|
+
}, { variants: ['user'] })
|
|
58
|
+
.register('img', (el, ctx) => mediaNode(el, ctx), { variants: ['inline'] })
|
|
59
|
+
.register('audio', (el, ctx) => mediaNode(el, ctx))
|
|
60
|
+
.register('video', (el, ctx) => mediaNode(el, ctx))
|
|
61
|
+
.register('file', (el, ctx) => mediaNode(el, ctx));
|
|
62
|
+
return {
|
|
63
|
+
id: 'html',
|
|
64
|
+
elements,
|
|
65
|
+
limits: {},
|
|
66
|
+
assemble: (nodes, envelope) => assembleDraft(nodes, envelope.quote),
|
|
67
|
+
serialize: (prepared, ctx) => serializeDraft(prepared, ctx),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=html.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.js","sourceRoot":"","sources":["../../../src/modes/html.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAA;AAGpE,OAAO,EACL,aAAa,EACb,eAAe,EACf,UAAU,EACV,UAAU,EACV,SAAS,EACT,aAAa,EACb,SAAS,EACT,cAAc,GACf,MAAM,aAAa,CAAA;AAGpB,6CAA6C;AAC7C,MAAM,YAAY,GAAG,uBAAuB,CAAA;AAE5C,6FAA6F;AAC7F,SAAS,IAAI,CACX,GAAW,EACX,GAAiC,EACjC,QAA4B,EAC5B,UAAU,GAAG,EAAE;IAEf,OAAO,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC,CAAA;AAC7D,CAAC;AAED,6BAA6B;AAC7B,MAAM,UAAU,cAAc;IAC5B,MAAM,QAAQ,GAAG,IAAI,eAAe,EAAiB;SAClD,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,CACvB,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAC3D;SACA,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;SAC9C,QAAQ,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;SAC/D,QAAQ,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,GAAG,E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AAE,CAAC,cAAc,CAAC,QAAQ,EAAE,GAAG,CAAC;KAC5D,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The single `html` mode's node, draft and payload types, HTML escaping, media promotion and MIME payload assembly.
|
|
3
|
+
*
|
|
4
|
+
* A mail message is one MIME document, so `assemble` always returns exactly one draft: inline nodes accumulate into
|
|
5
|
+
* the HTML and plain-text parts, while media become `multipart/related` (`cid:`) or `multipart/mixed` attachments. A
|
|
6
|
+
* media element standing in phrasing content is lifted out of the text run and reported as `moved` (nothing is lost,
|
|
7
|
+
* only repositioned), which is the `mail-media-split` entry of the render report.
|
|
8
|
+
*/
|
|
9
|
+
import type { ModeTypes, Prepared, RenderContext, ResourceKind, ResourceRef, SerializeContext } from '@deepseek-ai/cordis-plugin-im-core';
|
|
10
|
+
import type { Element } from '@deepseek-ai/satori-element';
|
|
11
|
+
/** Media elements a mail message turns into attachments. */
|
|
12
|
+
export type MailMediaTag = 'img' | 'audio' | 'video' | 'file';
|
|
13
|
+
/** One node a mode handler produces. */
|
|
14
|
+
export type MailNode =
|
|
15
|
+
/** A run of inline HTML plus its plain-text projection. */
|
|
16
|
+
{
|
|
17
|
+
type: 'inline';
|
|
18
|
+
html: string;
|
|
19
|
+
text: string;
|
|
20
|
+
}
|
|
21
|
+
/** One attachment; the HTML position is a `cid:` reference for inline media and nothing for a file. */
|
|
22
|
+
| {
|
|
23
|
+
type: 'media';
|
|
24
|
+
tag: MailMediaTag;
|
|
25
|
+
ref: ResourceRef;
|
|
26
|
+
};
|
|
27
|
+
/** One mail message before resource resolution. */
|
|
28
|
+
export interface MailDraft {
|
|
29
|
+
/** Inline runs and media, in source order. */
|
|
30
|
+
nodes: MailNode[];
|
|
31
|
+
/** From `<quote id>`: the `Message-ID` this message answers. */
|
|
32
|
+
quote?: string;
|
|
33
|
+
}
|
|
34
|
+
/** One attachment of a serialized payload. */
|
|
35
|
+
export interface MailPayloadAttachment {
|
|
36
|
+
/** Staged resource key (`sendPayload` reads the bytes back by it). */
|
|
37
|
+
key: string;
|
|
38
|
+
/** Content-ID of an inline media attachment; absent on a plain file attachment. */
|
|
39
|
+
cid?: string;
|
|
40
|
+
filename: string;
|
|
41
|
+
contentType: string;
|
|
42
|
+
}
|
|
43
|
+
/** Exactly what one `sendMail` call carries. */
|
|
44
|
+
export interface MailPayload {
|
|
45
|
+
/** Recipient address (the `private:` prefix already stripped). */
|
|
46
|
+
to: string;
|
|
47
|
+
subject: string;
|
|
48
|
+
/** The inline markup, wrapped in `<pre>`. */
|
|
49
|
+
html: string;
|
|
50
|
+
/** Plain-text alternative, generated from the same node stream. */
|
|
51
|
+
text: string;
|
|
52
|
+
/** `In-Reply-To`, with angle brackets. */
|
|
53
|
+
inReplyTo?: string;
|
|
54
|
+
/** `References`, oldest first, with angle brackets. */
|
|
55
|
+
references?: string[];
|
|
56
|
+
attachments: MailPayloadAttachment[];
|
|
57
|
+
}
|
|
58
|
+
/** Mode types of the `html` mode. */
|
|
59
|
+
export interface MailModeTypes extends ModeTypes {
|
|
60
|
+
node: MailNode;
|
|
61
|
+
draft: MailDraft;
|
|
62
|
+
payload: MailPayload;
|
|
63
|
+
}
|
|
64
|
+
/** Escape character data of the HTML part. */
|
|
65
|
+
export declare function escapeHtml(text: string): string;
|
|
66
|
+
/** Escape one HTML attribute value (double-quoted). */
|
|
67
|
+
export declare function escapeAttribute(text: string): string;
|
|
68
|
+
/** One inline node. */
|
|
69
|
+
export declare function inlineNode(html: string, text: string): MailNode;
|
|
70
|
+
/** The inline HTML and plain text of rendered children, and the nodes that cannot ride inside a text run. */
|
|
71
|
+
export interface InlineRun {
|
|
72
|
+
html: string;
|
|
73
|
+
text: string;
|
|
74
|
+
rest: MailNode[];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Split rendered children into one inline run and the media nodes that follow it.
|
|
78
|
+
* @param nodes - rendered children.
|
|
79
|
+
* @returns the concatenated HTML/text of the run and the media nodes, in source order.
|
|
80
|
+
*/
|
|
81
|
+
export declare function inlineRun(nodes: readonly MailNode[]): InlineRun;
|
|
82
|
+
/**
|
|
83
|
+
* Wrap the inline text of rendered children in one HTML tag; media of the subtree follows the wrapper.
|
|
84
|
+
* @param tag - the HTML tag name.
|
|
85
|
+
* @param nodes - rendered children.
|
|
86
|
+
* @param textSuffix - plain-text separator this block adds after its inline text.
|
|
87
|
+
* @returns the wrapper (when it has text) and the media nodes.
|
|
88
|
+
*/
|
|
89
|
+
export declare function inlineWrapper(tag: string, nodes: readonly MailNode[], textSuffix?: string): MailNode[];
|
|
90
|
+
/** Resource kind of one media tag. */
|
|
91
|
+
export declare function resourceKindOf(tag: MailMediaTag): ResourceKind;
|
|
92
|
+
/**
|
|
93
|
+
* Turn one media element into its node.
|
|
94
|
+
*
|
|
95
|
+
* An `http(s)` image, audio or video stays a reference to the remote URL: the recipient's client fetches it, so the
|
|
96
|
+
* sent message carries no copy. Everything else (and every file, which has no markup to carry a URL) is fetched and
|
|
97
|
+
* becomes an attachment. Media lifted out of phrasing content is reported as `moved`.
|
|
98
|
+
*
|
|
99
|
+
* @param el - one of `img`/`audio`/`video`/`file`.
|
|
100
|
+
* @param ctx - render context of the mode.
|
|
101
|
+
* @returns the inline node of a remote media reference, or the media node of an attachment.
|
|
102
|
+
*/
|
|
103
|
+
export declare function mediaNode(el: Element<MailMediaTag>, ctx: RenderContext<MailModeTypes>): MailNode;
|
|
104
|
+
/** Fold a node stream into the one draft a mail message is. */
|
|
105
|
+
export declare function assembleDraft(nodes: MailNode[], quote?: string): MailDraft[];
|
|
106
|
+
/**
|
|
107
|
+
* Build the `sendMail` options of one draft.
|
|
108
|
+
*
|
|
109
|
+
* The recipient is the chat's address, unless the message being answered named a `Reply-To`. A reply carries
|
|
110
|
+
* `In-Reply-To` (the quoted `Message-ID`) and `References` (the answered message's chain plus that id), and its
|
|
111
|
+
* subject is the answered subject with one `Re: ` prefix.
|
|
112
|
+
*/
|
|
113
|
+
export declare function serializeDraft(prepared: Prepared<MailDraft>, ctx: SerializeContext): MailPayload;
|
|
114
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/modes/shared.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EACV,SAAS,EACT,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,WAAW,EAEX,gBAAgB,EACjB,MAAM,oCAAoC,CAAA;AAE3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA;AAK1D,4DAA4D;AAC5D,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAA;AAE7D,wCAAwC;AACxC,MAAM,MAAM,QAAQ;AAClB,2DAA2D;AACzD;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE;AAChD,uGAAuG;GACrG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,YAAY,CAAC;IAAC,GAAG,EAAE,WAAW,CAAA;CAAE,CAAA;AAE1D,mDAAmD;AACnD,MAAM,WAAW,SAAS;IACxB,8CAA8C;IAC9C,KAAK,EAAE,QAAQ,EAAE,CAAA;IACjB,gEAAgE;IAChE,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,8CAA8C;AAC9C,MAAM,WAAW,qBAAqB;IACpC,sEAAsE;IACtE,GAAG,EAAE,MAAM,CAAA;IACX,mFAAmF;IACnF,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,gDAAgD;AAChD,MAAM,WAAW,WAAW;IAC1B,kEAAkE;IAClE,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,6CA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CV;AAiBD,+DAA+D;AAC/D,wBAAgB,aAAa,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,EAAE,CAE5E;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,QAAQ,CAAC,SAAS,CAAC,EAC7B,GAAG,EAAE,gBAAgB,GACpB,WAAW,CAmDb"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The single `html` mode's node, draft and payload types, HTML escaping, media promotion and MIME payload assembly.
|
|
3
|
+
*
|
|
4
|
+
* A mail message is one MIME document, so `assemble` always returns exactly one draft: inline nodes accumulate into
|
|
5
|
+
* the HTML and plain-text parts, while media become `multipart/related` (`cid:`) or `multipart/mixed` attachments. A
|
|
6
|
+
* media element standing in phrasing content is lifted out of the text run and reported as `moved` (nothing is lost,
|
|
7
|
+
* only repositioned), which is the `mail-media-split` entry of the render report.
|
|
8
|
+
*/
|
|
9
|
+
import { PlatformError } from '@deepseek-ai/cordis-plugin-im-core';
|
|
10
|
+
import { isPhrasingContainer } from '@deepseek-ai/satori-element';
|
|
11
|
+
/** Escape character data of the HTML part. */
|
|
12
|
+
export function escapeHtml(text) {
|
|
13
|
+
return text
|
|
14
|
+
.replaceAll('&', '&')
|
|
15
|
+
.replaceAll('<', '<')
|
|
16
|
+
.replaceAll('>', '>');
|
|
17
|
+
}
|
|
18
|
+
/** Escape one HTML attribute value (double-quoted). */
|
|
19
|
+
export function escapeAttribute(text) {
|
|
20
|
+
return escapeHtml(text).replaceAll('"', '"');
|
|
21
|
+
}
|
|
22
|
+
/** One inline node. */
|
|
23
|
+
export function inlineNode(html, text) {
|
|
24
|
+
return { type: 'inline', html, text };
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Split rendered children into one inline run and the media nodes that follow it.
|
|
28
|
+
* @param nodes - rendered children.
|
|
29
|
+
* @returns the concatenated HTML/text of the run and the media nodes, in source order.
|
|
30
|
+
*/
|
|
31
|
+
export function inlineRun(nodes) {
|
|
32
|
+
let html = '';
|
|
33
|
+
let text = '';
|
|
34
|
+
const rest = [];
|
|
35
|
+
for (const node of nodes) {
|
|
36
|
+
if (node.type === 'media') {
|
|
37
|
+
rest.push(node);
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
html += node.html;
|
|
41
|
+
text += node.text;
|
|
42
|
+
}
|
|
43
|
+
return { html, text, rest };
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Wrap the inline text of rendered children in one HTML tag; media of the subtree follows the wrapper.
|
|
47
|
+
* @param tag - the HTML tag name.
|
|
48
|
+
* @param nodes - rendered children.
|
|
49
|
+
* @param textSuffix - plain-text separator this block adds after its inline text.
|
|
50
|
+
* @returns the wrapper (when it has text) and the media nodes.
|
|
51
|
+
*/
|
|
52
|
+
export function inlineWrapper(tag, nodes, textSuffix = '') {
|
|
53
|
+
const { html, text, rest } = inlineRun(nodes);
|
|
54
|
+
if (html === '')
|
|
55
|
+
return rest;
|
|
56
|
+
return [inlineNode(`<${tag}>${html}</${tag}>`, text + textSuffix), ...rest];
|
|
57
|
+
}
|
|
58
|
+
/** Resource kind of one media tag. */
|
|
59
|
+
export function resourceKindOf(tag) {
|
|
60
|
+
switch (tag) {
|
|
61
|
+
case 'img':
|
|
62
|
+
return 'image';
|
|
63
|
+
case 'audio':
|
|
64
|
+
return 'audio';
|
|
65
|
+
case 'video':
|
|
66
|
+
return 'video';
|
|
67
|
+
case 'file':
|
|
68
|
+
return 'file';
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Turn one media element into its node.
|
|
73
|
+
*
|
|
74
|
+
* An `http(s)` image, audio or video stays a reference to the remote URL: the recipient's client fetches it, so the
|
|
75
|
+
* sent message carries no copy. Everything else (and every file, which has no markup to carry a URL) is fetched and
|
|
76
|
+
* becomes an attachment. Media lifted out of phrasing content is reported as `moved`.
|
|
77
|
+
*
|
|
78
|
+
* @param el - one of `img`/`audio`/`video`/`file`.
|
|
79
|
+
* @param ctx - render context of the mode.
|
|
80
|
+
* @returns the inline node of a remote media reference, or the media node of an attachment.
|
|
81
|
+
*/
|
|
82
|
+
export function mediaNode(el, ctx) {
|
|
83
|
+
const tag = el.type;
|
|
84
|
+
const src = el.attrs.src;
|
|
85
|
+
if (src === '') {
|
|
86
|
+
throw new PlatformError('invalid', `mail: <${tag}> has no src, so nothing could be sent`, { published: 'no' });
|
|
87
|
+
}
|
|
88
|
+
if (tag !== 'file' && /^https?:\/\//i.test(src)) {
|
|
89
|
+
const escaped = escapeAttribute(src);
|
|
90
|
+
const html = tag === 'img'
|
|
91
|
+
? `<img src="${escaped}">`
|
|
92
|
+
: `<${tag} src="${escaped}" controls>`;
|
|
93
|
+
return inlineNode(html, '');
|
|
94
|
+
}
|
|
95
|
+
const parent = ctx.ancestors[ctx.ancestors.length - 1];
|
|
96
|
+
if (parent !== undefined && isPhrasingContainer(parent.type)) {
|
|
97
|
+
ctx.report.moved.push({
|
|
98
|
+
tag,
|
|
99
|
+
reason: 'mail-media-split',
|
|
100
|
+
path: ctx.stableId(el),
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
const meta = {};
|
|
104
|
+
if (el.type === 'audio' || el.type === 'video' || el.type === 'file') {
|
|
105
|
+
if (el.attrs.name !== undefined)
|
|
106
|
+
meta.name = el.attrs.name;
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
type: 'media',
|
|
110
|
+
tag,
|
|
111
|
+
ref: ctx.resource(resourceKindOf(tag), src, meta),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/** The recipient address of a chat id (`private:` is the direct-chat idiom of this platform). */
|
|
115
|
+
function addressOfChat(chatId) {
|
|
116
|
+
const prefix = 'private:';
|
|
117
|
+
return chatId.startsWith(prefix) ? chatId.slice(prefix.length) : chatId;
|
|
118
|
+
}
|
|
119
|
+
/** The adapter-private reply context of a publication, when the target carries one. */
|
|
120
|
+
function referrerOf(target) {
|
|
121
|
+
const referrer = target.referrer;
|
|
122
|
+
if (typeof referrer !== 'object' || referrer === null)
|
|
123
|
+
return undefined;
|
|
124
|
+
return referrer;
|
|
125
|
+
}
|
|
126
|
+
/** Fold a node stream into the one draft a mail message is. */
|
|
127
|
+
export function assembleDraft(nodes, quote) {
|
|
128
|
+
return [{ nodes, ...(quote === undefined ? {} : { quote }) }];
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Build the `sendMail` options of one draft.
|
|
132
|
+
*
|
|
133
|
+
* The recipient is the chat's address, unless the message being answered named a `Reply-To`. A reply carries
|
|
134
|
+
* `In-Reply-To` (the quoted `Message-ID`) and `References` (the answered message's chain plus that id), and its
|
|
135
|
+
* subject is the answered subject with one `Re: ` prefix.
|
|
136
|
+
*/
|
|
137
|
+
export function serializeDraft(prepared, ctx) {
|
|
138
|
+
const draft = prepared.draft;
|
|
139
|
+
const config = ctx.bot.config;
|
|
140
|
+
const referrer = referrerOf(ctx.target);
|
|
141
|
+
const quote = draft.quote ?? ctx.quote;
|
|
142
|
+
let html = '';
|
|
143
|
+
let text = '';
|
|
144
|
+
const attachments = [];
|
|
145
|
+
for (const node of draft.nodes) {
|
|
146
|
+
if (node.type === 'inline') {
|
|
147
|
+
html += node.html;
|
|
148
|
+
text += node.text;
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
const resolved = prepared.resolved.get(node.ref);
|
|
152
|
+
if (resolved === undefined)
|
|
153
|
+
throw new Error('mail: an attachment was not prepared before serialize');
|
|
154
|
+
const extra = resolved.extra;
|
|
155
|
+
const cid = node.tag === 'file' ? undefined : resolved.key;
|
|
156
|
+
if (cid !== undefined) {
|
|
157
|
+
const escaped = escapeAttribute(cid);
|
|
158
|
+
html +=
|
|
159
|
+
node.tag === 'img'
|
|
160
|
+
? `<img src="cid:${escaped}">`
|
|
161
|
+
: `<${node.tag} src="cid:${escaped}" controls>`;
|
|
162
|
+
}
|
|
163
|
+
const suggested = node.ref.meta.name ?? extra?.name;
|
|
164
|
+
attachments.push({
|
|
165
|
+
key: resolved.key,
|
|
166
|
+
...(cid === undefined ? {} : { cid }),
|
|
167
|
+
filename: suggested !== undefined && suggested !== ''
|
|
168
|
+
? suggested
|
|
169
|
+
: `attachment-${attachments.length + 1}`,
|
|
170
|
+
contentType: node.ref.meta.mime ?? extra?.mime ?? 'application/octet-stream',
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
to: referrer?.replyTo ?? addressOfChat(ctx.target.chat.id),
|
|
175
|
+
subject: referrer?.subject ? `Re: ${referrer.subject}` : config.subject,
|
|
176
|
+
html: `<pre>${html}</pre>`,
|
|
177
|
+
text: text.trim() === '' ? '' : text,
|
|
178
|
+
...(quote === undefined ? {} : { inReplyTo: quote }),
|
|
179
|
+
...(quote === undefined || referrer === undefined
|
|
180
|
+
? {}
|
|
181
|
+
: { references: [...(referrer.references ?? []), quote] }),
|
|
182
|
+
attachments,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/modes/shared.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAA;AAUlE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAyDjE,8CAA8C;AAC9C,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,IAAI;SACR,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC;SACxB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;SACvB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;AAC5B,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,G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