@im-more/dsh-slack 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 +13 -0
- package/lib/index.js +2659 -0
- package/lib/index.js.map +1 -0
- package/lib/types/bot.d.ts +66 -0
- package/lib/types/bot.d.ts.map +1 -0
- package/lib/types/bot.js +165 -0
- package/lib/types/bot.js.map +1 -0
- package/lib/types/config.d.ts +49 -0
- package/lib/types/config.d.ts.map +1 -0
- package/lib/types/config.js +54 -0
- package/lib/types/config.js.map +1 -0
- package/lib/types/decode.d.ts +126 -0
- package/lib/types/decode.d.ts.map +1 -0
- package/lib/types/decode.js +396 -0
- package/lib/types/decode.js.map +1 -0
- package/lib/types/errors.d.ts +61 -0
- package/lib/types/errors.d.ts.map +1 -0
- package/lib/types/errors.js +196 -0
- package/lib/types/errors.js.map +1 -0
- package/lib/types/identity.d.ts +27 -0
- package/lib/types/identity.d.ts.map +1 -0
- package/lib/types/identity.js +35 -0
- package/lib/types/identity.js.map +1 -0
- package/lib/types/index.d.ts +14 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +14 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/modes/mrkdwn.d.ts +17 -0
- package/lib/types/modes/mrkdwn.d.ts.map +1 -0
- package/lib/types/modes/mrkdwn.js +123 -0
- package/lib/types/modes/mrkdwn.js.map +1 -0
- package/lib/types/modes/shared.d.ts +164 -0
- package/lib/types/modes/shared.d.ts.map +1 -0
- package/lib/types/modes/shared.js +411 -0
- package/lib/types/modes/shared.js.map +1 -0
- package/lib/types/mrkdwn.d.ts +41 -0
- package/lib/types/mrkdwn.d.ts.map +1 -0
- package/lib/types/mrkdwn.js +137 -0
- package/lib/types/mrkdwn.js.map +1 -0
- package/lib/types/request.d.ts +225 -0
- package/lib/types/request.d.ts.map +1 -0
- package/lib/types/request.js +330 -0
- package/lib/types/request.js.map +1 -0
- package/lib/types/send.d.ts +74 -0
- package/lib/types/send.d.ts.map +1 -0
- package/lib/types/send.js +200 -0
- package/lib/types/send.js.map +1 -0
- package/lib/types/transport/socket.d.ts +58 -0
- package/lib/types/transport/socket.d.ts.map +1 -0
- package/lib/types/transport/socket.js +297 -0
- package/lib/types/transport/socket.js.map +1 -0
- package/lib/types/transport/webhook.d.ts +48 -0
- package/lib/types/transport/webhook.d.ts.map +1 -0
- package/lib/types/transport/webhook.js +210 -0
- package/lib/types/transport/webhook.js.map +1 -0
- package/lib/types/types/admin.d.ts +682 -0
- package/lib/types/types/admin.d.ts.map +1 -0
- package/lib/types/types/admin.js +172 -0
- package/lib/types/types/admin.js.map +1 -0
- package/lib/types/types/api.d.ts +20 -0
- package/lib/types/types/api.d.ts.map +1 -0
- package/lib/types/types/api.js +7 -0
- package/lib/types/types/api.js.map +1 -0
- package/lib/types/types/apps.d.ts +138 -0
- package/lib/types/types/apps.d.ts.map +1 -0
- package/lib/types/types/apps.js +28 -0
- package/lib/types/types/apps.js.map +1 -0
- package/lib/types/types/auth.d.ts +36 -0
- package/lib/types/types/auth.d.ts.map +1 -0
- package/lib/types/types/auth.js +10 -0
- package/lib/types/types/auth.js.map +1 -0
- package/lib/types/types/bots.d.ts +32 -0
- package/lib/types/types/bots.d.ts.map +1 -0
- package/lib/types/types/bots.js +7 -0
- package/lib/types/types/bots.js.map +1 -0
- package/lib/types/types/calls.d.ts +82 -0
- package/lib/types/types/calls.d.ts.map +1 -0
- package/lib/types/types/calls.js +22 -0
- package/lib/types/types/calls.js.map +1 -0
- package/lib/types/types/chat.d.ts +208 -0
- package/lib/types/types/chat.d.ts.map +1 -0
- package/lib/types/types/chat.js +34 -0
- package/lib/types/types/chat.js.map +1 -0
- package/lib/types/types/conversations.d.ts +266 -0
- package/lib/types/types/conversations.d.ts.map +1 -0
- package/lib/types/types/conversations.js +58 -0
- package/lib/types/types/conversations.js.map +1 -0
- package/lib/types/types/definition.d.ts +505 -0
- package/lib/types/types/definition.d.ts.map +1 -0
- package/lib/types/types/definition.js +2 -0
- package/lib/types/types/definition.js.map +1 -0
- package/lib/types/types/dialog.d.ts +20 -0
- package/lib/types/types/dialog.d.ts.map +1 -0
- package/lib/types/types/dialog.js +7 -0
- package/lib/types/types/dialog.js.map +1 -0
- package/lib/types/types/dnd.d.ts +70 -0
- package/lib/types/types/dnd.d.ts.map +1 -0
- package/lib/types/types/dnd.js +19 -0
- package/lib/types/types/dnd.js.map +1 -0
- package/lib/types/types/emoji.d.ts +18 -0
- package/lib/types/types/emoji.d.ts.map +1 -0
- package/lib/types/types/emoji.js +7 -0
- package/lib/types/types/emoji.js.map +1 -0
- package/lib/types/types/events/base-events.d.ts +235 -0
- package/lib/types/types/events/base-events.d.ts.map +1 -0
- package/lib/types/types/events/base-events.js +3 -0
- package/lib/types/types/events/base-events.js.map +1 -0
- package/lib/types/types/events/index.d.ts +97 -0
- package/lib/types/types/events/index.d.ts.map +1 -0
- package/lib/types/types/events/index.js +3 -0
- package/lib/types/types/events/index.js.map +1 -0
- package/lib/types/types/events/message-events.d.ts +215 -0
- package/lib/types/types/events/message-events.d.ts.map +1 -0
- package/lib/types/types/events/message-events.js +3 -0
- package/lib/types/types/events/message-events.js.map +1 -0
- package/lib/types/types/files.d.ts +189 -0
- package/lib/types/types/files.d.ts.map +1 -0
- package/lib/types/types/files.js +43 -0
- package/lib/types/types/files.js.map +1 -0
- package/lib/types/types/index.d.ts +82 -0
- package/lib/types/types/index.d.ts.map +1 -0
- package/lib/types/types/index.js +29 -0
- package/lib/types/types/index.js.map +1 -0
- package/lib/types/types/internal.d.ts +17 -0
- package/lib/types/types/internal.d.ts.map +1 -0
- package/lib/types/types/internal.js +60 -0
- package/lib/types/types/internal.js.map +1 -0
- package/lib/types/types/migration.d.ts +25 -0
- package/lib/types/types/migration.d.ts.map +1 -0
- package/lib/types/types/migration.js +7 -0
- package/lib/types/types/migration.js.map +1 -0
- package/lib/types/types/oauth.d.ts +50 -0
- package/lib/types/types/oauth.d.ts.map +1 -0
- package/lib/types/types/oauth.js +13 -0
- package/lib/types/types/oauth.js.map +1 -0
- package/lib/types/types/pins.d.ts +39 -0
- package/lib/types/types/pins.d.ts.map +1 -0
- package/lib/types/types/pins.js +13 -0
- package/lib/types/types/pins.js.map +1 -0
- package/lib/types/types/reactions.d.ts +75 -0
- package/lib/types/types/reactions.d.ts.map +1 -0
- package/lib/types/types/reactions.js +16 -0
- package/lib/types/types/reactions.js.map +1 -0
- package/lib/types/types/reminders.d.ts +64 -0
- package/lib/types/types/reminders.d.ts.map +1 -0
- package/lib/types/types/reminders.js +19 -0
- package/lib/types/types/reminders.js.map +1 -0
- package/lib/types/types/rtm.d.ts +30 -0
- package/lib/types/types/rtm.d.ts.map +1 -0
- package/lib/types/types/rtm.js +7 -0
- package/lib/types/types/rtm.js.map +1 -0
- package/lib/types/types/search.d.ts +24 -0
- package/lib/types/types/search.d.ts.map +1 -0
- package/lib/types/types/search.js +7 -0
- package/lib/types/types/search.js.map +1 -0
- package/lib/types/types/stars.d.ts +56 -0
- package/lib/types/types/stars.d.ts.map +1 -0
- package/lib/types/types/stars.js +13 -0
- package/lib/types/types/stars.js.map +1 -0
- package/lib/types/types/team.d.ts +98 -0
- package/lib/types/types/team.d.ts.map +1 -0
- package/lib/types/types/team.js +19 -0
- package/lib/types/types/team.js.map +1 -0
- package/lib/types/types/usergroups.d.ts +103 -0
- package/lib/types/types/usergroups.d.ts.map +1 -0
- package/lib/types/types/usergroups.js +25 -0
- package/lib/types/types/usergroups.js.map +1 -0
- package/lib/types/types/users.d.ts +169 -0
- package/lib/types/types/users.d.ts.map +1 -0
- package/lib/types/types/users.js +40 -0
- package/lib/types/types/users.js.map +1 -0
- package/lib/types/types/views.d.ts +56 -0
- package/lib/types/types/views.d.ts.map +1 -0
- package/lib/types/types/views.js +16 -0
- package/lib/types/types/views.js.map +1 -0
- package/lib/types/types/workflows.d.ts +45 -0
- package/lib/types/types/workflows.d.ts.map +1 -0
- package/lib/types/types/workflows.js +13 -0
- package/lib/types/types/workflows.js.map +1 -0
- package/package.json +65 -3
- package/src/bot.ts +273 -0
- package/src/config.ts +92 -0
- package/src/decode.ts +489 -0
- package/src/errors.ts +230 -0
- package/src/identity.ts +59 -0
- package/src/index.ts +64 -0
- package/src/modes/mrkdwn.ts +159 -0
- package/src/modes/shared.ts +515 -0
- package/src/mrkdwn.ts +146 -0
- package/src/request.ts +449 -0
- package/src/send.ts +300 -0
- package/src/transport/socket.ts +393 -0
- package/src/transport/webhook.ts +269 -0
- package/src/types/admin.ts +910 -0
- package/src/types/api.ts +28 -0
- package/src/types/apps.ts +175 -0
- package/src/types/auth.ts +49 -0
- package/src/types/bots.ts +40 -0
- package/src/types/calls.ts +110 -0
- package/src/types/chat.ts +255 -0
- package/src/types/conversations.ts +342 -0
- package/src/types/definition.ts +530 -0
- package/src/types/dialog.ts +28 -0
- package/src/types/dnd.ts +94 -0
- package/src/types/emoji.ts +26 -0
- package/src/types/events/base-events.ts +281 -0
- package/src/types/events/index.ts +125 -0
- package/src/types/events/message-events.ts +253 -0
- package/src/types/files.ts +245 -0
- package/src/types/index.ts +84 -0
- package/src/types/internal.ts +60 -0
- package/src/types/migration.ts +34 -0
- package/src/types/oauth.ts +66 -0
- package/src/types/pins.ts +55 -0
- package/src/types/reactions.ts +95 -0
- package/src/types/reminders.ts +88 -0
- package/src/types/rtm.ts +38 -0
- package/src/types/search.ts +32 -0
- package/src/types/stars.ts +72 -0
- package/src/types/team.ts +122 -0
- package/src/types/usergroups.ts +135 -0
- package/src/types/users.ts +221 -0
- package/src/types/views.ts +76 -0
- package/src/types/workflows.ts +61 -0
- package/README.md +0 -3
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Draft model of the single `mrkdwn` mode: the node stream, the paragraph and media splitting, the 4,000-character
|
|
3
|
+
* split that never loses a character, and the exact request payload of one platform message.
|
|
4
|
+
*
|
|
5
|
+
* A run keeps its markup as data (`marks`) instead of embedding it in the text. That is what makes splitting exact: a
|
|
6
|
+
* cut closes the open markers and reopens them in the next chunk, because the markers are not part of the text being
|
|
7
|
+
* counted.
|
|
8
|
+
*/
|
|
9
|
+
import { isPhrasingContainer } from '@deepseek-ai/satori-element';
|
|
10
|
+
/** Slack's documented `text` bound: longer text is split into messages of about that size. */
|
|
11
|
+
export const SLACK_LIMITS = { text: 4_000 };
|
|
12
|
+
/** A paragraph break node. */
|
|
13
|
+
export const BREAK = { type: 'break' };
|
|
14
|
+
/**
|
|
15
|
+
* Drop the paragraph break a container put in front of its content, so a list marker is not followed by a newline.
|
|
16
|
+
* @param nodes - rendered children.
|
|
17
|
+
* @returns the children without leading break nodes.
|
|
18
|
+
*/
|
|
19
|
+
export function withoutLeadingBreaks(nodes) {
|
|
20
|
+
let start = 0;
|
|
21
|
+
while (start < nodes.length && nodes[start].type === 'break')
|
|
22
|
+
start += 1;
|
|
23
|
+
return nodes.slice(start);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* One text node under the given marks.
|
|
27
|
+
* @param text - the already escaped text.
|
|
28
|
+
* @param marks - the marks wrapping it, outermost first.
|
|
29
|
+
* @returns the node.
|
|
30
|
+
*/
|
|
31
|
+
export function textNode(text, marks = []) {
|
|
32
|
+
return { type: 'text', run: { text, marks } };
|
|
33
|
+
}
|
|
34
|
+
/** Identity of one mark, for comparing two stacks. */
|
|
35
|
+
function markKey(mark) {
|
|
36
|
+
switch (mark.kind) {
|
|
37
|
+
case 'link':
|
|
38
|
+
return `link:${mark.href}`;
|
|
39
|
+
case 'fence':
|
|
40
|
+
return `fence:${mark.lang ?? ''}`;
|
|
41
|
+
default:
|
|
42
|
+
return mark.kind;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Wrap every text run of a subtree with one mark.
|
|
47
|
+
*
|
|
48
|
+
* A run already carrying the same mark right above it is left alone, so `<b><b>x</b></b>` does not emit `**x**`.
|
|
49
|
+
*
|
|
50
|
+
* @param nodes - rendered children.
|
|
51
|
+
* @param mark - the mark to add.
|
|
52
|
+
* @returns the children with the mark added to their text runs.
|
|
53
|
+
*/
|
|
54
|
+
export function withMark(nodes, mark) {
|
|
55
|
+
const key = markKey(mark);
|
|
56
|
+
return nodes.map((node) => {
|
|
57
|
+
if (node.type !== 'text')
|
|
58
|
+
return node;
|
|
59
|
+
const { marks } = node.run;
|
|
60
|
+
const last = marks[marks.length - 1];
|
|
61
|
+
if (last !== undefined && markKey(last) === key)
|
|
62
|
+
return node;
|
|
63
|
+
return {
|
|
64
|
+
type: 'text',
|
|
65
|
+
run: { text: node.run.text, marks: [...marks, mark] },
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/** The opening marker of one mark. */
|
|
70
|
+
function markOpen(mark) {
|
|
71
|
+
switch (mark.kind) {
|
|
72
|
+
case 'bold':
|
|
73
|
+
return '*';
|
|
74
|
+
case 'italic':
|
|
75
|
+
return '_';
|
|
76
|
+
case 'strike':
|
|
77
|
+
return '~';
|
|
78
|
+
case 'code':
|
|
79
|
+
return '`';
|
|
80
|
+
case 'link':
|
|
81
|
+
return `<${mark.href}|`;
|
|
82
|
+
case 'fence':
|
|
83
|
+
return `\`\`\`${mark.lang ?? ''}\n`;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/** The closing marker of one mark. */
|
|
87
|
+
function markClose(mark) {
|
|
88
|
+
switch (mark.kind) {
|
|
89
|
+
case 'link':
|
|
90
|
+
return '>';
|
|
91
|
+
case 'fence':
|
|
92
|
+
return '\n```';
|
|
93
|
+
default:
|
|
94
|
+
return markOpen(mark);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/** How many marks two stacks share from the outside in. */
|
|
98
|
+
function sharedMarks(left, right) {
|
|
99
|
+
const limit = Math.min(left.length, right.length);
|
|
100
|
+
for (let index = 0; index < limit; index++) {
|
|
101
|
+
if (markKey(left[index]) !== markKey(right[index]))
|
|
102
|
+
return index;
|
|
103
|
+
}
|
|
104
|
+
return limit;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Render a run list as one message body, closing and reopening marks only where the stack changes.
|
|
108
|
+
* @param runs - the runs of one message.
|
|
109
|
+
* @returns the message body.
|
|
110
|
+
*/
|
|
111
|
+
export function renderRuns(runs) {
|
|
112
|
+
let body = '';
|
|
113
|
+
let open = [];
|
|
114
|
+
for (const run of runs) {
|
|
115
|
+
const shared = sharedMarks(open, run.marks);
|
|
116
|
+
for (let index = open.length - 1; index >= shared; index--) {
|
|
117
|
+
body += markClose(open[index]);
|
|
118
|
+
}
|
|
119
|
+
for (let index = shared; index < run.marks.length; index++) {
|
|
120
|
+
body += markOpen(run.marks[index]);
|
|
121
|
+
}
|
|
122
|
+
body += run.text;
|
|
123
|
+
open = run.marks;
|
|
124
|
+
}
|
|
125
|
+
for (let index = open.length - 1; index >= 0; index--) {
|
|
126
|
+
body += markClose(open[index]);
|
|
127
|
+
}
|
|
128
|
+
return body;
|
|
129
|
+
}
|
|
130
|
+
/** Visible characters of a run list: one per Unicode code point. */
|
|
131
|
+
export function visibleLength(runs) {
|
|
132
|
+
let length = 0;
|
|
133
|
+
for (const run of runs)
|
|
134
|
+
for (const _ of run.text)
|
|
135
|
+
length += 1;
|
|
136
|
+
return length;
|
|
137
|
+
}
|
|
138
|
+
/** Canonical identity of a whole mark stack, for joining runs that render identically. */
|
|
139
|
+
function stackKey(marks) {
|
|
140
|
+
return marks.map(markKey).join('\u0000');
|
|
141
|
+
}
|
|
142
|
+
/** Fold an atom list back into runs, joining neighbours that share their whole stack. */
|
|
143
|
+
function runsOf(atoms) {
|
|
144
|
+
const runs = [];
|
|
145
|
+
let key = '';
|
|
146
|
+
for (const atom of atoms) {
|
|
147
|
+
const atomKey = stackKey(atom.marks);
|
|
148
|
+
const last = runs[runs.length - 1];
|
|
149
|
+
if (last !== undefined && atomKey === key) {
|
|
150
|
+
last.text += atom.char;
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
runs.push({ text: atom.char, marks: atom.marks });
|
|
154
|
+
key = atomKey;
|
|
155
|
+
}
|
|
156
|
+
return runs;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Split a run list into chunks of at most `limit` visible characters.
|
|
160
|
+
*
|
|
161
|
+
* The cut prefers the last line break of the window, then the last space, then a hard cut; every chunk closes the
|
|
162
|
+
* marks it opened, so each message parses on its own. No visible character is ever dropped.
|
|
163
|
+
*
|
|
164
|
+
* @param runs - the whole message body.
|
|
165
|
+
* @param limit - visible characters per chunk.
|
|
166
|
+
* @returns the chunks, in order.
|
|
167
|
+
*/
|
|
168
|
+
export function splitRuns(runs, limit) {
|
|
169
|
+
if (visibleLength(runs) <= limit)
|
|
170
|
+
return [[...runs]];
|
|
171
|
+
const atoms = [];
|
|
172
|
+
for (const run of runs) {
|
|
173
|
+
for (const char of run.text)
|
|
174
|
+
atoms.push({ char, marks: run.marks });
|
|
175
|
+
}
|
|
176
|
+
const chunks = [];
|
|
177
|
+
let start = 0;
|
|
178
|
+
while (start < atoms.length) {
|
|
179
|
+
if (atoms.length - start <= limit) {
|
|
180
|
+
chunks.push(runsOf(atoms.slice(start)));
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
const window = start + limit;
|
|
184
|
+
let cut = window;
|
|
185
|
+
for (let index = window - 1; index >= start; index--) {
|
|
186
|
+
if (atoms[index].char === '\n') {
|
|
187
|
+
cut = index + 1;
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (cut === window) {
|
|
192
|
+
for (let index = window - 1; index >= start; index--) {
|
|
193
|
+
if (atoms[index].char === ' ') {
|
|
194
|
+
cut = index + 1;
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
chunks.push(runsOf(atoms.slice(start, cut)));
|
|
200
|
+
start = cut;
|
|
201
|
+
}
|
|
202
|
+
return chunks;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Fold the rendered node stream into platform messages.
|
|
206
|
+
*
|
|
207
|
+
* Inline nodes share one body; a media element flushes the body and becomes a message of its own, as the upstream
|
|
208
|
+
* encoder does. A paragraph break adds one newline and never starts a message with one, and the ends of every message
|
|
209
|
+
* are trimmed.
|
|
210
|
+
*
|
|
211
|
+
* @param nodes - rendered nodes in document order.
|
|
212
|
+
* @returns one draft per platform message; a single empty text draft when the content renders nothing.
|
|
213
|
+
*/
|
|
214
|
+
export function assembleDraft(nodes) {
|
|
215
|
+
const drafts = [];
|
|
216
|
+
let runs = [];
|
|
217
|
+
/** The runs without the whitespace around the message, which no mark wraps. */
|
|
218
|
+
const trimmed = (input) => {
|
|
219
|
+
const copy = input.map((run) => ({ text: run.text, marks: run.marks }));
|
|
220
|
+
while (copy.length > 0) {
|
|
221
|
+
const first = copy[0];
|
|
222
|
+
const text = first.text.replace(/^\s+/, '');
|
|
223
|
+
if (text !== '') {
|
|
224
|
+
first.text = text;
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
copy.shift();
|
|
228
|
+
}
|
|
229
|
+
while (copy.length > 0) {
|
|
230
|
+
const last = copy[copy.length - 1];
|
|
231
|
+
const text = last.text.replace(/\s+$/, '');
|
|
232
|
+
if (text !== '') {
|
|
233
|
+
last.text = text;
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
copy.pop();
|
|
237
|
+
}
|
|
238
|
+
return copy;
|
|
239
|
+
};
|
|
240
|
+
const flushText = () => {
|
|
241
|
+
if (runs.length === 0)
|
|
242
|
+
return;
|
|
243
|
+
for (const chunk of splitRuns(runs, SLACK_LIMITS.text)) {
|
|
244
|
+
const trimmedRuns = trimmed(chunk);
|
|
245
|
+
if (trimmedRuns.length === 0)
|
|
246
|
+
continue;
|
|
247
|
+
drafts.push({ type: 'text', text: renderRuns(trimmedRuns) });
|
|
248
|
+
}
|
|
249
|
+
runs = [];
|
|
250
|
+
};
|
|
251
|
+
const append = (run) => {
|
|
252
|
+
const last = runs[runs.length - 1];
|
|
253
|
+
if (last !== undefined && stackKey(last.marks) === stackKey(run.marks)) {
|
|
254
|
+
last.text += run.text;
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
runs.push({ text: run.text, marks: run.marks });
|
|
258
|
+
};
|
|
259
|
+
const lineBreak = () => {
|
|
260
|
+
const last = runs[runs.length - 1];
|
|
261
|
+
if (last === undefined)
|
|
262
|
+
return;
|
|
263
|
+
if (last.text.endsWith('\n'))
|
|
264
|
+
return;
|
|
265
|
+
// The break sits outside every mark: a marked run never swallows the newline of the next paragraph, which matters
|
|
266
|
+
// most for a code fence, whose closing marker would otherwise move past the break.
|
|
267
|
+
append({ text: '\n', marks: [] });
|
|
268
|
+
};
|
|
269
|
+
for (const node of nodes) {
|
|
270
|
+
switch (node.type) {
|
|
271
|
+
case 'text':
|
|
272
|
+
append(node.run);
|
|
273
|
+
break;
|
|
274
|
+
case 'break':
|
|
275
|
+
lineBreak();
|
|
276
|
+
break;
|
|
277
|
+
case 'media':
|
|
278
|
+
flushText();
|
|
279
|
+
drafts.push({ type: 'file', ref: node.ref, name: node.name });
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
flushText();
|
|
284
|
+
if (drafts.length === 0)
|
|
285
|
+
drafts.push({ type: 'text', text: '' });
|
|
286
|
+
return drafts;
|
|
287
|
+
}
|
|
288
|
+
/** The file name of an outbound attachment: the declared name, else the last path segment of the source. */
|
|
289
|
+
export function fileName(name, src) {
|
|
290
|
+
if (name !== undefined && name !== '')
|
|
291
|
+
return name;
|
|
292
|
+
try {
|
|
293
|
+
const path = new URL(src).pathname;
|
|
294
|
+
const segment = path.slice(path.lastIndexOf('/') + 1);
|
|
295
|
+
if (segment !== '')
|
|
296
|
+
return decodeURIComponent(segment);
|
|
297
|
+
}
|
|
298
|
+
catch (error) {
|
|
299
|
+
// Not a URL: the source itself is the best name available.
|
|
300
|
+
error;
|
|
301
|
+
if (src !== '' && !src.includes('/'))
|
|
302
|
+
return src;
|
|
303
|
+
}
|
|
304
|
+
return 'file';
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* The attachment node of one media element.
|
|
308
|
+
* @param el - one of `img`, `audio`, `video`, `file`.
|
|
309
|
+
* @param ctx - render context of the mode.
|
|
310
|
+
* @returns the node to publish after the body it was found in.
|
|
311
|
+
*/
|
|
312
|
+
export function mediaNode(el, ctx) {
|
|
313
|
+
const parent = ctx.ancestors[ctx.ancestors.length - 1];
|
|
314
|
+
if (parent !== undefined && isPhrasingContainer(parent.type)) {
|
|
315
|
+
ctx.report.moved.push({
|
|
316
|
+
tag: el.type,
|
|
317
|
+
reason: 'slack-media-split',
|
|
318
|
+
path: ctx.stableId(el),
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
switch (el.type) {
|
|
322
|
+
case 'img':
|
|
323
|
+
return {
|
|
324
|
+
type: 'media',
|
|
325
|
+
ref: ctx.resource('image', el.attrs.src, {}),
|
|
326
|
+
name: fileName(undefined, el.attrs.src),
|
|
327
|
+
};
|
|
328
|
+
case 'audio':
|
|
329
|
+
return {
|
|
330
|
+
type: 'media',
|
|
331
|
+
ref: ctx.resource('audio', el.attrs.src, el.attrs.name === undefined ? {} : { name: el.attrs.name }),
|
|
332
|
+
name: fileName(el.attrs.name, el.attrs.src),
|
|
333
|
+
};
|
|
334
|
+
case 'video':
|
|
335
|
+
return {
|
|
336
|
+
type: 'media',
|
|
337
|
+
ref: ctx.resource('video', el.attrs.src, el.attrs.name === undefined ? {} : { name: el.attrs.name }),
|
|
338
|
+
name: fileName(el.attrs.name, el.attrs.src),
|
|
339
|
+
};
|
|
340
|
+
case 'file':
|
|
341
|
+
return {
|
|
342
|
+
type: 'media',
|
|
343
|
+
ref: ctx.resource('file', el.attrs.src, el.attrs.name === undefined ? {} : { name: el.attrs.name }),
|
|
344
|
+
name: fileName(el.attrs.name, el.attrs.src),
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
/** The resource key `prepare` resolved for one attachment. */
|
|
349
|
+
function resolvedKey(prepared, ref) {
|
|
350
|
+
const resolved = prepared.resolved.get(ref);
|
|
351
|
+
if (resolved === undefined) {
|
|
352
|
+
throw new Error('slack: the attachment was not prepared before serialize');
|
|
353
|
+
}
|
|
354
|
+
return resolved.key;
|
|
355
|
+
}
|
|
356
|
+
/** `thread_ts` of an inbound referrer, when the target asks to follow it. */
|
|
357
|
+
function referrerThreadTs(referrer) {
|
|
358
|
+
if (typeof referrer !== 'object' || referrer === null)
|
|
359
|
+
return undefined;
|
|
360
|
+
const threadTs = referrer.threadTs;
|
|
361
|
+
return typeof threadTs === 'string' && threadTs !== '' ? threadTs : undefined;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* The thread one part answers: an explicit thread, the referrer's thread, or — for the first part only — the quote.
|
|
365
|
+
*
|
|
366
|
+
* Slack's "reply to a message" is a thread reply, so a `<quote>` becomes `thread_ts`. Only the first part carries it,
|
|
367
|
+
* because the later parts of a split message would otherwise start threads of their own.
|
|
368
|
+
*
|
|
369
|
+
* @param ctx - serialize context.
|
|
370
|
+
* @returns the thread timestamp, when this part goes into a thread.
|
|
371
|
+
*/
|
|
372
|
+
export function threadTsOf(ctx) {
|
|
373
|
+
if (typeof ctx.target.thread === 'string')
|
|
374
|
+
return ctx.target.thread;
|
|
375
|
+
if (ctx.target.thread === true)
|
|
376
|
+
return referrerThreadTs(ctx.target.referrer);
|
|
377
|
+
return ctx.index === 0 ? ctx.quote : undefined;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Build the exact request data of one draft.
|
|
381
|
+
*
|
|
382
|
+
* @param prepared - the draft with its resources resolved.
|
|
383
|
+
* @param ctx - serialize context (channel, thread, part index).
|
|
384
|
+
* @param replyBroadcast - `replyBroadcast` of the profile row.
|
|
385
|
+
* @returns the request data of one platform message or file message.
|
|
386
|
+
*/
|
|
387
|
+
export function serializeDraft(prepared, ctx, replyBroadcast) {
|
|
388
|
+
const { draft } = prepared;
|
|
389
|
+
const channel = ctx.target.chat.id;
|
|
390
|
+
const threadTs = threadTsOf(ctx);
|
|
391
|
+
if (draft.type === 'file') {
|
|
392
|
+
return {
|
|
393
|
+
kind: 'file',
|
|
394
|
+
channel,
|
|
395
|
+
fileId: resolvedKey(prepared, draft.ref),
|
|
396
|
+
name: draft.name,
|
|
397
|
+
...(threadTs === undefined ? {} : { threadTs }),
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
return {
|
|
401
|
+
kind: 'message',
|
|
402
|
+
channel,
|
|
403
|
+
// Slack accepts a zero-width joiner and shows no empty bubble; `assemble` only produces this when nothing rendered.
|
|
404
|
+
text: draft.text === '' ? '\u2060' : draft.text,
|
|
405
|
+
...(threadTs === undefined ? {} : { threadTs }),
|
|
406
|
+
...(threadTs !== undefined && replyBroadcast
|
|
407
|
+
? { replyBroadcast: true }
|
|
408
|
+
: {}),
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/modes/shared.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AASH,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAGjE,8FAA8F;AAC9F,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,IAAI,EAAE,KAAK,EAAW,CAAA;AAuDpD,8BAA8B;AAC9B,MAAM,CAAC,MAAM,KAAK,GAAc,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;AAEjD;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAA2B;IAC9D,IAAI,KAAK,GAAG,CAAC,CAAA;IACb,OAAO,KAAK,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,CAAE,CAAC,IAAI,KAAK,OAAO;QAAE,KAAK,IAAI,CAAC,CAAA;IACzE,OAAO,KAAK,CAA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,IAAI,EAAE;YAC1B,CAAC,CAAC,EAAE,CAAC;KACR,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `mrkdwn` escaping rules of the upstream adapter and the inbound parser of the same syntax.
|
|
3
|
+
*
|
|
4
|
+
* Slack's message text is a small markup language, not plain text: `*bold*`, `_italic_`, `~strike~`, `` `code` ``,
|
|
5
|
+
* `<@U…>` mentions, `<#C…>` channel links, `<url|label>` links and `:emoji:` names. Outbound, every literal character
|
|
6
|
+
* that would otherwise be read as markup is escaped with a zero-width space; inbound, the same markers are parsed back
|
|
7
|
+
* into the element vocabulary.
|
|
8
|
+
*/
|
|
9
|
+
import type { Element } from '@deepseek-ai/cordis-plugin-im-core';
|
|
10
|
+
/**
|
|
11
|
+
* Escape text so Slack renders it literally.
|
|
12
|
+
*
|
|
13
|
+
* Four rules, identical to the upstream adapter's: a markup character gets a zero-width space; `@everyone`/`@here`
|
|
14
|
+
* are broken up so they cannot notify; a leading `>` cannot start a quoted block; and `<…>` cannot become a link or a
|
|
15
|
+
* mention. The result keeps every visible character and adds only invisible ones.
|
|
16
|
+
*
|
|
17
|
+
* @param text - the text of a `text` element.
|
|
18
|
+
* @returns the text to append to the message body.
|
|
19
|
+
*/
|
|
20
|
+
export declare function escape(text: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Undo {@link escape}: restore the markup characters, the notification words and a leading `>`.
|
|
23
|
+
*
|
|
24
|
+
* Slack hands back the text of a message as its author typed it, so a zero-width space only appears when the text was
|
|
25
|
+
* written by an adapter of this family; parsing it back is what keeps a relayed message identical.
|
|
26
|
+
*
|
|
27
|
+
* @param text - text of one rich-text run.
|
|
28
|
+
* @returns the text as it was written.
|
|
29
|
+
*/
|
|
30
|
+
export declare function unescape(text: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* Parse Slack message text into the element vocabulary.
|
|
33
|
+
*
|
|
34
|
+
* Used for the `text` field of a message (when it carries no usable `blocks`), for the `text` of a `section` block,
|
|
35
|
+
* and for a `rich_text_quote`/`rich_text_preformatted` body.
|
|
36
|
+
*
|
|
37
|
+
* @param text - Slack message text.
|
|
38
|
+
* @returns the content nodes; empty when the text is empty.
|
|
39
|
+
*/
|
|
40
|
+
export declare function parseMrkdwn(text: string): Element[];
|
|
41
|
+
//# sourceMappingURL=mrkdwn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mrkdwn.d.ts","sourceRoot":"","sources":["../../src/mrkdwn.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAA;AAOjE;;;;;;;;;GASG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO3C;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM7C;AA0ED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,EAAE,CAWnD"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `mrkdwn` escaping rules of the upstream adapter and the inbound parser of the same syntax.
|
|
3
|
+
*
|
|
4
|
+
* Slack's message text is a small markup language, not plain text: `*bold*`, `_italic_`, `~strike~`, `` `code` ``,
|
|
5
|
+
* `<@U…>` mentions, `<#C…>` channel links, `<url|label>` links and `:emoji:` names. Outbound, every literal character
|
|
6
|
+
* that would otherwise be read as markup is escaped with a zero-width space; inbound, the same markers are parsed back
|
|
7
|
+
* into the element vocabulary.
|
|
8
|
+
*/
|
|
9
|
+
import { h } from '@deepseek-ai/cordis-plugin-im-core';
|
|
10
|
+
/** Zero-width space put in front of a markup character; it is invisible and keeps the character literal. */
|
|
11
|
+
const MARK_ESCAPE = '\u200B';
|
|
12
|
+
/** Hair space put in front of a leading `>`; a quoted block is started by `>` at the beginning of a line. */
|
|
13
|
+
const QUOTE_ESCAPE = '\u200A';
|
|
14
|
+
/**
|
|
15
|
+
* Escape text so Slack renders it literally.
|
|
16
|
+
*
|
|
17
|
+
* Four rules, identical to the upstream adapter's: a markup character gets a zero-width space; `@everyone`/`@here`
|
|
18
|
+
* are broken up so they cannot notify; a leading `>` cannot start a quoted block; and `<…>` cannot become a link or a
|
|
19
|
+
* mention. The result keeps every visible character and adds only invisible ones.
|
|
20
|
+
*
|
|
21
|
+
* @param text - the text of a `text` element.
|
|
22
|
+
* @returns the text to append to the message body.
|
|
23
|
+
*/
|
|
24
|
+
export function escape(text) {
|
|
25
|
+
return text
|
|
26
|
+
.replace(/(?<!\u200B)[*_~`]/g, `${MARK_ESCAPE}$&`)
|
|
27
|
+
.replace(/@everyone/g, () => `@${MARK_ESCAPE}everyone`)
|
|
28
|
+
.replace(/@here/g, () => `@${MARK_ESCAPE}here`)
|
|
29
|
+
.replace(/(?<!\u200B)^>/g, `${QUOTE_ESCAPE}>`)
|
|
30
|
+
.replace(/<(.*?)>/g, '<$1>');
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Undo {@link escape}: restore the markup characters, the notification words and a leading `>`.
|
|
34
|
+
*
|
|
35
|
+
* Slack hands back the text of a message as its author typed it, so a zero-width space only appears when the text was
|
|
36
|
+
* written by an adapter of this family; parsing it back is what keeps a relayed message identical.
|
|
37
|
+
*
|
|
38
|
+
* @param text - text of one rich-text run.
|
|
39
|
+
* @returns the text as it was written.
|
|
40
|
+
*/
|
|
41
|
+
export function unescape(text) {
|
|
42
|
+
return text
|
|
43
|
+
.replace(/\u200B([*_~`])/g, '$1')
|
|
44
|
+
.replace(new RegExp(`@${MARK_ESCAPE}everyone`, 'g'), () => '@everyone')
|
|
45
|
+
.replace(new RegExp(`@${MARK_ESCAPE}here`, 'g'), () => '@here')
|
|
46
|
+
.replace(new RegExp(`^${QUOTE_ESCAPE}>`), '>');
|
|
47
|
+
}
|
|
48
|
+
/** A Slack control sequence between angle brackets, e.g. `<@U123>` or `<https://example.com|label>`. */
|
|
49
|
+
const CONTROL = /(<[^<>]*>)/;
|
|
50
|
+
/** An emoji name between colons, e.g. `:tada:` or `:+1:`. */
|
|
51
|
+
const EMOJI = /(:[a-zA-Z0-9_+-]+:)/;
|
|
52
|
+
/** The label of a mention or channel link, when Slack included one (`<@U123|alice>`). */
|
|
53
|
+
function labelOf(raw, prefixLength) {
|
|
54
|
+
const body = raw.slice(prefixLength, -1);
|
|
55
|
+
const separator = body.indexOf('|');
|
|
56
|
+
if (separator < 0)
|
|
57
|
+
return { id: body };
|
|
58
|
+
return {
|
|
59
|
+
id: body.slice(0, separator),
|
|
60
|
+
...(body.slice(separator + 1) === ''
|
|
61
|
+
? {}
|
|
62
|
+
: { name: body.slice(separator + 1) }),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/** Turn one `<…>` control sequence into elements; an unrecognized one stays as its literal text. */
|
|
66
|
+
function controlElement(raw) {
|
|
67
|
+
const body = raw.slice(1, -1);
|
|
68
|
+
if (body.startsWith('@')) {
|
|
69
|
+
const { id, name } = labelOf(raw, 2);
|
|
70
|
+
return [
|
|
71
|
+
h('at', { type: 'user', id, ...(name === undefined ? {} : { name }) }),
|
|
72
|
+
];
|
|
73
|
+
}
|
|
74
|
+
if (body.startsWith('#')) {
|
|
75
|
+
const { id, name } = labelOf(raw, 2);
|
|
76
|
+
return [h('channel', { id, ...(name === undefined ? {} : { name }) })];
|
|
77
|
+
}
|
|
78
|
+
if (body.startsWith('!')) {
|
|
79
|
+
const range = body.slice(1);
|
|
80
|
+
if (range === 'here')
|
|
81
|
+
return [h('at', { type: 'here' })];
|
|
82
|
+
if (range === 'channel' || range === 'everyone') {
|
|
83
|
+
return [h('at', { type: 'all' })];
|
|
84
|
+
}
|
|
85
|
+
return [h.text(raw)];
|
|
86
|
+
}
|
|
87
|
+
const separator = body.indexOf('|');
|
|
88
|
+
if (separator > 0) {
|
|
89
|
+
const href = body.slice(0, separator);
|
|
90
|
+
const label = body.slice(separator + 1);
|
|
91
|
+
return [h('a', { href }, label === '' ? href : label)];
|
|
92
|
+
}
|
|
93
|
+
if (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(body)) {
|
|
94
|
+
return [h('a', { href: body }, body)];
|
|
95
|
+
}
|
|
96
|
+
// A subteam mention, an unresolved id or something Slack added later: keeping it as text loses no content.
|
|
97
|
+
return [h.text(raw)];
|
|
98
|
+
}
|
|
99
|
+
/** Split one plain run on emoji names, keeping the text between them. */
|
|
100
|
+
function emojiElements(text) {
|
|
101
|
+
const parts = text.split(EMOJI);
|
|
102
|
+
const elements = [];
|
|
103
|
+
for (const part of parts) {
|
|
104
|
+
if (part === '')
|
|
105
|
+
continue;
|
|
106
|
+
if (part.length > 2 && part.startsWith(':') && part.endsWith(':')) {
|
|
107
|
+
const name = part.slice(1, -1);
|
|
108
|
+
elements.push(h('emoji', { id: name, name }));
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
elements.push(h.text(unescape(part)));
|
|
112
|
+
}
|
|
113
|
+
return elements;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Parse Slack message text into the element vocabulary.
|
|
117
|
+
*
|
|
118
|
+
* Used for the `text` field of a message (when it carries no usable `blocks`), for the `text` of a `section` block,
|
|
119
|
+
* and for a `rich_text_quote`/`rich_text_preformatted` body.
|
|
120
|
+
*
|
|
121
|
+
* @param text - Slack message text.
|
|
122
|
+
* @returns the content nodes; empty when the text is empty.
|
|
123
|
+
*/
|
|
124
|
+
export function parseMrkdwn(text) {
|
|
125
|
+
const elements = [];
|
|
126
|
+
for (const part of text.split(CONTROL)) {
|
|
127
|
+
if (part === '')
|
|
128
|
+
continue;
|
|
129
|
+
if (part.startsWith('<') && part.endsWith('>') && part.length > 2) {
|
|
130
|
+
elements.push(...controlElement(part));
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
elements.push(...emojiElements(part));
|
|
134
|
+
}
|
|
135
|
+
return elements;
|
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