deictic 0.6.0 → 0.7.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/API.md +136 -30
- package/README.md +4 -3
- package/dist/annotations/client.d.ts +1 -1
- package/dist/annotations/client.d.ts.map +1 -1
- package/dist/annotations/client.js +161 -176
- package/dist/annotations/client.js.map +1 -1
- package/dist/annotations/index.d.ts +2 -11
- package/dist/client/index.d.ts +7 -6
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1007 -192
- package/dist/client/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/recommended/index.d.ts +2 -2
- package/dist/recordings/client.d.ts.map +1 -1
- package/dist/recordings/client.js +82 -153
- package/dist/recordings/client.js.map +1 -1
- package/dist/screenshots/client.d.ts.map +1 -1
- package/dist/shared/annotations.js +3 -4
- package/dist/shared/annotations.js.map +1 -1
- package/dist/shared/board.js +1 -1
- package/dist/shared/client.js +45 -2
- package/dist/shared/client.js.map +1 -1
- package/dist/shared/component.js +62 -0
- package/dist/shared/component.js.map +1 -0
- package/dist/shared/dom.js +79 -0
- package/dist/shared/dom.js.map +1 -0
- package/dist/shared/drawer.js +217 -0
- package/dist/shared/drawer.js.map +1 -0
- package/dist/shared/index.d.ts +116 -7
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index2.d.ts +9 -19
- package/dist/shared/index2.d.ts.map +1 -1
- package/dist/shared/index7.d.ts +103 -26
- package/dist/shared/index7.d.ts.map +1 -1
- package/dist/shared/index9.d.ts +1 -1
- package/dist/shared/integration.d.ts +1 -1
- package/dist/shared/packages.js +1 -1
- package/dist/shared/recording.js +31 -3
- package/dist/shared/recording.js.map +1 -1
- package/dist/shared/src.js.map +1 -1
- package/dist/shared/task.js +44 -29
- package/dist/shared/task.js.map +1 -1
- package/dist/shared/tasks.js +232 -62
- package/dist/shared/tasks.js.map +1 -1
- package/dist/shared/vb.js +1 -1
- package/dist/shared/voice2.js +6 -4
- package/dist/shared/voice2.js.map +1 -1
- package/dist/shared/watch.js +14 -14
- package/dist/shared/watch.js.map +1 -1
- package/dist/tasks/client.d.ts +2 -2
- package/dist/tasks/client.d.ts.map +1 -1
- package/dist/tasks/client.js +1829 -741
- package/dist/tasks/client.js.map +1 -1
- package/dist/tasks/index.d.ts +2 -2
- package/dist/voice/client.d.ts.map +1 -1
- package/dist/voice/client.js +154 -57
- package/dist/voice/client.js.map +1 -1
- package/package.json +1 -1
- package/skills/deictic/SKILL.md +22 -28
- package/src/cli/recording.ts +34 -3
- package/src/cli/task.ts +59 -30
- package/src/cli/voice.ts +9 -4
- package/src/cli/watch.ts +14 -13
- package/src/client/away.ts +3 -1
- package/src/client/component.ts +98 -0
- package/src/client/dom.ts +70 -0
- package/src/client/drawer.ts +258 -0
- package/src/client/index.ts +220 -128
- package/src/client/lightbox.ts +8 -8
- package/src/client/lighting.ts +279 -0
- package/src/client/style.ts +263 -44
- package/src/client/tools.ts +279 -0
- package/src/client/tooltip.ts +25 -5
- package/src/client/tray.ts +48 -0
- package/src/index.ts +113 -6
- package/src/plugins/annotations/client.ts +103 -129
- package/src/plugins/annotations/draw.ts +68 -72
- package/src/plugins/annotations/index.ts +12 -19
- package/src/plugins/recordings/client.ts +89 -167
- package/src/plugins/screenshots/client.ts +53 -2
- package/src/plugins/tasks/client.ts +219 -748
- package/src/plugins/tasks/composer.ts +797 -0
- package/src/plugins/tasks/drawer.ts +516 -0
- package/src/plugins/tasks/index.ts +360 -82
- package/src/plugins/tasks/pins.ts +275 -0
- package/src/plugins/tasks/store.ts +132 -0
- package/src/plugins/voice/client.ts +96 -5
- package/skills/deictic/references/recordings.md +0 -13
- package/skills/deictic/references/tasks.md +0 -22
- package/skills/deictic/references/watch.md +0 -17
package/dist/shared/tasks.js
CHANGED
|
@@ -18,8 +18,14 @@ import { n as watchersOf } from "./watchers.js";
|
|
|
18
18
|
* place is no longer the element's is still its own where the tag and the line it saw (`deictic.line`) are
|
|
19
19
|
* the element's, and that line is in the file once: the element has moved, as lines above it changed.
|
|
20
20
|
*/
|
|
21
|
+
/** How many of the latest finished tasks the drawer lists: what an agent said as it ended one is there to read. */
|
|
22
|
+
const OVER = 10;
|
|
23
|
+
/** How many tasks a page is asked about at most: past that it has more pins than anyone reads. */
|
|
24
|
+
const PINNED = 500;
|
|
21
25
|
const AT = "deictic.at";
|
|
22
26
|
const FILE = "deictic.file";
|
|
27
|
+
/** `x,y`: the spot in the element a task is about, in CSS pixels from the element's top left. */
|
|
28
|
+
const POINT = "deictic.point";
|
|
23
29
|
/** What parts what was typed from the rest of a task's text. */
|
|
24
30
|
const REST = "\n---\n";
|
|
25
31
|
const OPEN = /* @__PURE__ */ new Set([
|
|
@@ -65,9 +71,11 @@ function tasks(options = {}) {
|
|
|
65
71
|
* One of this channel's tasks about an element, while it's still open: the page names it by ID, so
|
|
66
72
|
* nothing else on the board is its to change, nor a task someone has taken up.
|
|
67
73
|
*/
|
|
74
|
+
/** One of deictic's: it has a place, or the page it's about where no element was attached. */
|
|
75
|
+
const ours = (message) => message.labels[AT] !== void 0 || message.labels["deictic.page"] !== void 0;
|
|
68
76
|
const openTask = async (team, id, verb) => {
|
|
69
77
|
const { message } = await team.thread(id);
|
|
70
|
-
if (message.channel !== channel || message
|
|
78
|
+
if (message.channel !== channel || !ours(message)) throw new Refusal(`#${id} isn't a task of deictic's in #${channel}: reload the page for the ones that are`);
|
|
71
79
|
const { task } = message;
|
|
72
80
|
if (task !== void 0 && !OPEN.has(task.state)) throw new Refusal(`task ${id} is ${task.state}${task.claim ? ` by ${task.claim.actor}` : ""} now: ${verb} it on the board if you still mean to`);
|
|
73
81
|
return message;
|
|
@@ -98,6 +106,130 @@ function tasks(options = {}) {
|
|
|
98
106
|
id: task.id
|
|
99
107
|
};
|
|
100
108
|
};
|
|
109
|
+
/** A board's task as the panel lists it: its words, its state, who has it, and its page there. */
|
|
110
|
+
const taskOf = (message, actors, page) => {
|
|
111
|
+
const state = message.task?.state ?? "ready";
|
|
112
|
+
const by = actors.get(message.task?.claim?.actor ?? "")?.name;
|
|
113
|
+
const text = message.text.split(REST, 1)[0];
|
|
114
|
+
const to = taskLink(page, message.id);
|
|
115
|
+
const missing = Object.entries(message.labels).flatMap(([key, value]) => /^deictic\.dropped\.\d+$/.test(key) ? [value] : []);
|
|
116
|
+
const dropped = missing.length === 0 ? void 0 : listOf(missing);
|
|
117
|
+
const [, x, y] = /^(-?\d+),(-?\d+)$/.exec(message.labels[POINT] ?? "") ?? [];
|
|
118
|
+
const point = x === void 0 || y === void 0 ? void 0 : {
|
|
119
|
+
x: Number(x),
|
|
120
|
+
y: Number(y)
|
|
121
|
+
};
|
|
122
|
+
return {
|
|
123
|
+
id: message.id,
|
|
124
|
+
title: text.split("\n", 1)[0],
|
|
125
|
+
text,
|
|
126
|
+
state,
|
|
127
|
+
...by === void 0 ? {} : { by },
|
|
128
|
+
open: OPEN.has(state),
|
|
129
|
+
...to === void 0 ? {} : { link: to },
|
|
130
|
+
...dropped === void 0 ? {} : { dropped },
|
|
131
|
+
...point === void 0 ? {} : { point }
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
const listedOf = ({ message, replies, last }, actors, page) => {
|
|
135
|
+
const { task, labels } = message;
|
|
136
|
+
const said = task?.blocked?.reason ?? task?.result ?? task?.reason ?? void 0;
|
|
137
|
+
return {
|
|
138
|
+
...taskOf(message, actors, page),
|
|
139
|
+
...labels[AT] === void 0 ? {} : { place: labels[AT] },
|
|
140
|
+
...labels["deictic.tag"] === void 0 ? {} : { tag: labels["deictic.tag"] },
|
|
141
|
+
...labels["deictic.page"] === void 0 ? {} : { page: labels["deictic.page"] },
|
|
142
|
+
replies,
|
|
143
|
+
...last === null ? {} : { last: last.id },
|
|
144
|
+
...said === void 0 || said === "" ? {} : { said: clip(said, 2e3) }
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* The channel's tasks, for the page: those still to do, oldest first, a page of the board's at a time and no more
|
|
149
|
+
* than `PINNED`, then the `OVER` that last ended, the latest first.
|
|
150
|
+
*/
|
|
151
|
+
const listed = async () => {
|
|
152
|
+
const team = await boardOf();
|
|
153
|
+
const open = [];
|
|
154
|
+
for (let after; open.length < PINNED;) {
|
|
155
|
+
const { tasks, cursor } = await team.tasks.list({
|
|
156
|
+
channel,
|
|
157
|
+
...after === void 0 ? {} : { after }
|
|
158
|
+
});
|
|
159
|
+
open.push(...tasks);
|
|
160
|
+
if (tasks.length === 0 || cursor === after) break;
|
|
161
|
+
after = cursor;
|
|
162
|
+
}
|
|
163
|
+
const ended = await Promise.all(["completed", "failed"].map((state) => team.threads({
|
|
164
|
+
channel,
|
|
165
|
+
label: { "board.task": state },
|
|
166
|
+
limit: OVER
|
|
167
|
+
})));
|
|
168
|
+
const when = ({ message, last }) => (last ?? message).createdAt;
|
|
169
|
+
const over = ended.flatMap(({ threads }) => threads).sort((a, b) => when(b).localeCompare(when(a))).slice(0, OVER);
|
|
170
|
+
const about = [...open, ...over].filter(({ message }) => ours(message));
|
|
171
|
+
const [actors, page] = await Promise.all([actorsOf(team, about.flatMap(({ message }) => message.task?.claim?.actor ?? [])), linkOf()]);
|
|
172
|
+
return about.map((summary) => listedOf(summary, actors, page));
|
|
173
|
+
};
|
|
174
|
+
const replyOf = (message) => ({
|
|
175
|
+
id: message.id,
|
|
176
|
+
by: message.author?.name ?? message.by.actor,
|
|
177
|
+
kind: message.author?.kind ?? "unknown",
|
|
178
|
+
text: message.text,
|
|
179
|
+
at: message.createdAt,
|
|
180
|
+
files: filesOf(message)
|
|
181
|
+
});
|
|
182
|
+
/** A task of ours with its thread, the newest replies a board answers at once. */
|
|
183
|
+
const threadOf = async (id) => {
|
|
184
|
+
const team = await boardOf();
|
|
185
|
+
const { message, replies } = await team.thread(id);
|
|
186
|
+
if (message.channel !== channel || !ours(message)) throw new Refusal(`#${id} isn't a task of deictic's in #${channel}: reload the page for the ones that are`);
|
|
187
|
+
const said = replies.filter((reply) => !reply.deleted);
|
|
188
|
+
const [actors, page] = await Promise.all([actorsOf(team, message.task?.claim ? [message.task.claim.actor] : []), linkOf()]);
|
|
189
|
+
return {
|
|
190
|
+
task: listedOf({
|
|
191
|
+
message,
|
|
192
|
+
replies: said.length,
|
|
193
|
+
last: said.at(-1) ?? null
|
|
194
|
+
}, actors, page),
|
|
195
|
+
files: filesOf(message),
|
|
196
|
+
replies: said.map(replyOf)
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
/** The task a route's request names, as its last segment, and what it sent. */
|
|
200
|
+
const named = async (req) => {
|
|
201
|
+
const id = decodeURIComponent(new URL(req.url).pathname.split("/").at(-1) ?? "");
|
|
202
|
+
const sent = req.method === "POST" ? await req.json().catch(() => ({})) : {};
|
|
203
|
+
const body = typeof sent === "object" && sent !== null ? sent : {};
|
|
204
|
+
return {
|
|
205
|
+
id,
|
|
206
|
+
text: typeof body.text === "string" ? body.text : "",
|
|
207
|
+
body
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* A file of a task's, `file/<task>/<file>`: one attached to the task or to a reply in its thread, and to nothing
|
|
212
|
+
* else on the board. An image or a sound is served as it is; anything else as its text, escaped, in a page of the
|
|
213
|
+
* lightbox's dark colours, so an element's HTML is read there, never run, on the dev server's origin.
|
|
214
|
+
*/
|
|
215
|
+
const fileOf = async (req) => {
|
|
216
|
+
const [task = "", file = ""] = (new URL(req.url).pathname.split("/file/")[1] ?? "").split("/").map(decodeURIComponent);
|
|
217
|
+
const team = await boardOf();
|
|
218
|
+
const { message, replies } = await team.thread(task);
|
|
219
|
+
if (message.channel !== channel || !ours(message)) throw new Refusal(`#${task} isn't a task of deictic's in #${channel}: reload the page for the ones that are`);
|
|
220
|
+
const found = [message, ...replies].flatMap((m) => m.attachments).find((a) => a.id === file);
|
|
221
|
+
if (found === void 0) throw new Refusal(`task ${task} has no file ${file}: reload the page for what it has`);
|
|
222
|
+
const res = await team.download(found.id);
|
|
223
|
+
const media = /^(image|audio|video)\//.test(found.type);
|
|
224
|
+
const body = media ? res.body : textPage(found.name, await res.text());
|
|
225
|
+
return new Response(body, { headers: {
|
|
226
|
+
"content-type": media ? found.type : "text/html; charset=utf-8",
|
|
227
|
+
"content-disposition": `inline; filename="${found.name.replaceAll("\"", "")}"`,
|
|
228
|
+
"x-content-type-options": "nosniff",
|
|
229
|
+
"content-security-policy": "sandbox; default-src 'none'; style-src 'unsafe-inline'; img-src 'self' blob:; media-src 'self' blob:",
|
|
230
|
+
"cache-control": "private, max-age=86400, immutable"
|
|
231
|
+
} });
|
|
232
|
+
};
|
|
101
233
|
let context;
|
|
102
234
|
let project = options.project;
|
|
103
235
|
/**
|
|
@@ -136,6 +268,14 @@ function tasks(options = {}) {
|
|
|
136
268
|
name: "pointed.html",
|
|
137
269
|
type: "text/html"
|
|
138
270
|
});
|
|
271
|
+
for (const [i, other] of (op.also ?? []).entries()) {
|
|
272
|
+
if (typeof other.html !== "string" || other.html === "") continue;
|
|
273
|
+
files.push({
|
|
274
|
+
data: new TextEncoder().encode(other.html.slice(0, HTML)),
|
|
275
|
+
name: `element.${i + 2}.html`,
|
|
276
|
+
type: "text/html"
|
|
277
|
+
});
|
|
278
|
+
}
|
|
139
279
|
return {
|
|
140
280
|
op: {
|
|
141
281
|
...op,
|
|
@@ -165,6 +305,54 @@ function tasks(options = {}) {
|
|
|
165
305
|
project ??= nameOf(given.root);
|
|
166
306
|
boardOf().catch(() => {});
|
|
167
307
|
},
|
|
308
|
+
routes: {
|
|
309
|
+
page: async () => {
|
|
310
|
+
const [tasks, link] = await Promise.all([asked(listed), linkOf()]);
|
|
311
|
+
return Response.json({
|
|
312
|
+
channel,
|
|
313
|
+
...link === void 0 ? {} : { link },
|
|
314
|
+
tasks
|
|
315
|
+
});
|
|
316
|
+
},
|
|
317
|
+
thread: async (req) => Response.json(await asked(async () => threadOf((await named(req)).id))),
|
|
318
|
+
file: (req) => asked(() => fileOf(req)),
|
|
319
|
+
reply: (req) => asked(async () => {
|
|
320
|
+
const { id, text, body } = await named(req);
|
|
321
|
+
const answer = {
|
|
322
|
+
text,
|
|
323
|
+
...Array.isArray(body.screenshots) ? { screenshots: body.screenshots } : {},
|
|
324
|
+
...Array.isArray(body.recordings) ? { recordings: body.recordings } : {},
|
|
325
|
+
...Array.isArray(body.voice) ? { voice: body.voice } : {},
|
|
326
|
+
...body.annotations === void 0 ? {} : { annotations: body.annotations }
|
|
327
|
+
};
|
|
328
|
+
if (wordsOf(answer) === "") throw new Refusal("say something first");
|
|
329
|
+
await threadOf(id);
|
|
330
|
+
const { op: kept, files, dropped } = keptOf(answer);
|
|
331
|
+
const verb = dropped.length === 1 ? "isn't" : "aren't";
|
|
332
|
+
if (wordsOf(kept) === "") throw new Refusal(`${listOf(dropped)} ${verb} kept any more: attach again, or say something`);
|
|
333
|
+
const labels = attachedLabels(kept, dropped);
|
|
334
|
+
const attachments = await upload(files);
|
|
335
|
+
await (await boardOf()).reply(id, {
|
|
336
|
+
text: clip(wordsOf(kept), 1e4),
|
|
337
|
+
...Object.keys(labels).length === 0 ? {} : { labels },
|
|
338
|
+
...attachments === void 0 ? {} : { attachments }
|
|
339
|
+
});
|
|
340
|
+
return Response.json(await threadOf(id));
|
|
341
|
+
}),
|
|
342
|
+
edit: (req) => asked(async () => {
|
|
343
|
+
const { id, text } = await named(req);
|
|
344
|
+
if (text.trim() === "") throw new Refusal("say what should change first");
|
|
345
|
+
const before = (await openTask(await boardOf(), id, "edit")).text;
|
|
346
|
+
const rest = before.includes(REST) ? before.slice(before.indexOf(REST)) : "";
|
|
347
|
+
await rewrite(id, before, clip(text.trim(), 1e4 - rest.length) + rest);
|
|
348
|
+
return Response.json(await threadOf(id));
|
|
349
|
+
}),
|
|
350
|
+
remove: (req) => asked(async () => {
|
|
351
|
+
const { id } = await named(req);
|
|
352
|
+
await cancel(id, "deleted in deictic");
|
|
353
|
+
return Response.json({});
|
|
354
|
+
})
|
|
355
|
+
},
|
|
168
356
|
read: (source, target) => asked(async () => {
|
|
169
357
|
const team = await boardOf();
|
|
170
358
|
const labelled = (label) => team.tasks.list({
|
|
@@ -184,39 +372,19 @@ function tasks(options = {}) {
|
|
|
184
372
|
const listed = new Set(inFile.tasks.map(({ message }) => message.id));
|
|
185
373
|
const line = source instanceof Refusal ? void 0 : onceIn(source);
|
|
186
374
|
const tasks = [];
|
|
187
|
-
const elsewhere = [];
|
|
188
375
|
const about = [...here.tasks.filter((t) => !listed.has(t.message.id)), ...inFile.tasks];
|
|
189
376
|
const actorOf = ({ task }) => task?.claim?.actor;
|
|
190
377
|
const claims = held.tasks.flatMap(({ message }) => message.task?.claim ?? []);
|
|
191
378
|
const actors = await actorsOf(team, [...about.flatMap(({ message }) => actorOf(message) ?? []), ...claims.map((c) => c.actor)]);
|
|
192
379
|
for (const { message } of about) {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
const by = actors.get(actorOf(message) ?? "")?.name;
|
|
196
|
-
const text = message.text.split(REST, 1)[0];
|
|
197
|
-
const to = taskLink(page, message.id);
|
|
198
|
-
const missing = Object.entries(message.labels).flatMap(([key, value]) => /^deictic\.dropped\.\d+$/.test(key) ? [value] : []);
|
|
199
|
-
const dropped = missing.length === 0 ? void 0 : listOf(missing);
|
|
200
|
-
const task = {
|
|
201
|
-
id: message.id,
|
|
202
|
-
title: text.split("\n", 1)[0],
|
|
203
|
-
text,
|
|
204
|
-
state,
|
|
205
|
-
...by === void 0 ? {} : { by },
|
|
206
|
-
open: OPEN.has(state),
|
|
207
|
-
...to === void 0 ? {} : { link: to },
|
|
208
|
-
...dropped === void 0 ? {} : { dropped }
|
|
209
|
-
};
|
|
380
|
+
if (message.task?.state === "canceled") continue;
|
|
381
|
+
const task = taskOf(message, actors, page);
|
|
210
382
|
const at = placeIn(message.labels);
|
|
211
383
|
if (at === void 0 || message.labels[AT] === atOf(target)) tasks.push(task);
|
|
212
384
|
else if (line !== void 0 && at.tag === target.tag && message.labels["deictic.line"] === line) tasks.push({
|
|
213
385
|
...task,
|
|
214
386
|
at
|
|
215
387
|
});
|
|
216
|
-
else elsewhere.push({
|
|
217
|
-
...task,
|
|
218
|
-
at
|
|
219
|
-
});
|
|
220
388
|
}
|
|
221
389
|
const working = agentsOf(actors, claims);
|
|
222
390
|
const watching = [.../* @__PURE__ */ new Set([...watchersOf(root ?? process.cwd(), channel), ...working])].sort();
|
|
@@ -225,37 +393,11 @@ function tasks(options = {}) {
|
|
|
225
393
|
channel,
|
|
226
394
|
...page === void 0 ? {} : { link: page },
|
|
227
395
|
...watching.length > 0 || ours ? { watching } : {},
|
|
228
|
-
tasks
|
|
229
|
-
elsewhere: elsewhere.sort((a, b) => a.at.line === b.at.line ? a.at.column - b.at.column : a.at.line - b.at.line)
|
|
396
|
+
tasks
|
|
230
397
|
};
|
|
231
398
|
}),
|
|
232
399
|
apply: (source, target, op) => {
|
|
233
|
-
if ("
|
|
234
|
-
const message = await cancel(op.remove, "deleted in deictic");
|
|
235
|
-
const labels = Object.fromEntries(Object.entries(message.labels).filter(([key]) => !key.startsWith("board.")));
|
|
236
|
-
const attachments = message.attachments.map((a) => a.id);
|
|
237
|
-
return { done: {
|
|
238
|
-
kind: "removed",
|
|
239
|
-
channel,
|
|
240
|
-
id: op.remove,
|
|
241
|
-
text: message.text,
|
|
242
|
-
labels,
|
|
243
|
-
...attachments.length === 0 ? {} : { attachments }
|
|
244
|
-
} };
|
|
245
|
-
});
|
|
246
|
-
if (op.text.trim() === "" && ("edit" in op || shown(op) === void 0)) throw new Refusal("say what should change first");
|
|
247
|
-
if ("edit" in op) return asked(async () => {
|
|
248
|
-
const before = (await openTask(await boardOf(), op.edit, "edit")).text;
|
|
249
|
-
const rest = before.includes(REST) ? before.slice(before.indexOf(REST)) : "";
|
|
250
|
-
const after = clip(op.text.trim(), 1e4 - rest.length) + rest;
|
|
251
|
-
await rewrite(op.edit, before, after);
|
|
252
|
-
return { done: {
|
|
253
|
-
kind: "edited",
|
|
254
|
-
id: op.edit,
|
|
255
|
-
before,
|
|
256
|
-
after
|
|
257
|
-
} };
|
|
258
|
-
});
|
|
400
|
+
if (op.text.trim() === "" && shown(op) === void 0) throw new Refusal("say what should change first");
|
|
259
401
|
const { op: kept, files, dropped } = keptOf(op);
|
|
260
402
|
const verb = dropped.length === 1 ? "isn't" : "aren't";
|
|
261
403
|
if (wordsOf(kept) === "") throw new Refusal(`${listOf(dropped)} ${verb} kept any more: attach again, or say what should change`);
|
|
@@ -303,12 +445,7 @@ function tasks(options = {}) {
|
|
|
303
445
|
await cancel(record.id, "deleted in deictic");
|
|
304
446
|
return record;
|
|
305
447
|
}),
|
|
306
|
-
describe: (op
|
|
307
|
-
const named = (id) => `task "${clip(before.tasks.find((t) => t.id === id)?.title ?? `#${id}`, 60)}"`;
|
|
308
|
-
if ("remove" in op) return `delete ${named(op.remove)}`;
|
|
309
|
-
if ("edit" in op) return `edit ${named(op.edit)}`;
|
|
310
|
-
return `task "${clip(wordsOf(op).split("\n", 1)[0], 60)}"`;
|
|
311
|
-
}
|
|
448
|
+
describe: (op) => `task "${clip(wordsOf(op).split("\n", 1)[0], 60)}"`
|
|
312
449
|
});
|
|
313
450
|
}
|
|
314
451
|
/**
|
|
@@ -325,9 +462,35 @@ async function localPage(team, channel) {
|
|
|
325
462
|
return `${url.origin}${url.pathname.slice(0, -10)}/c/${channel.split("/").map(encodeURIComponent).join("/")}`;
|
|
326
463
|
}
|
|
327
464
|
/**
|
|
465
|
+
* A file's text as a page to read it in: escaped, so nothing in it runs or loads, in the lightbox's colours, as the
|
|
466
|
+
* browser's own text page is black on nothing and the lightbox is dark under it.
|
|
467
|
+
*/
|
|
468
|
+
function textPage(name, text) {
|
|
469
|
+
const escape = (raw) => raw.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
470
|
+
return `<!doctype html><meta charset="utf-8"><title>${escape(name)}</title><style>:root{color-scheme:dark}body{margin:0;padding:16px;font:12px/1.5 ui-monospace,monospace;color:#e4e4e7;background:#18181b;white-space:pre-wrap;overflow-wrap:anywhere}</style><body>${escape(text)}`;
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* A message's files, as the drawer shows them: each recording with where it replays, which its
|
|
474
|
+
* `deictic.recording.N.replay` label says, the Nth being the Nth recording attached.
|
|
475
|
+
*/
|
|
476
|
+
function filesOf({ attachments, labels }) {
|
|
477
|
+
const recordings = attachments.filter((a) => a.name.startsWith("recording-"));
|
|
478
|
+
return attachments.map(({ id, name, type, size }) => {
|
|
479
|
+
const n = recordings.findIndex((r) => r.id === id);
|
|
480
|
+
const replay = n === -1 ? void 0 : labels[`deictic.recording.${n + 1}.replay`];
|
|
481
|
+
return {
|
|
482
|
+
id,
|
|
483
|
+
name,
|
|
484
|
+
type,
|
|
485
|
+
size,
|
|
486
|
+
...replay === void 0 ? {} : { replay }
|
|
487
|
+
};
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
328
491
|
* What the attached files don't say, as labels numbered from 1, so each value is short and none is read out of the
|
|
329
492
|
* text. `deictic.screenshot.N` is the Nth PNG attached: its `.position` and `.size` where the element is in it (CSS
|
|
330
|
-
* pixels from its top left), `.note.M` a note drawn on it. `deictic.recording.N.replay` is where the Nth recording
|
|
493
|
+
* pixels from its top left), for one taken of the element, `.note.M` a note drawn on it. `deictic.recording.N.replay` is where the Nth recording
|
|
331
494
|
* plays back; `deictic.note.M` a note drawn on the page; `deictic.dropped.N` what wasn't kept any more;
|
|
332
495
|
* `deictic.pointed` the path to what was pointed at inside the element. A note past a label is cut.
|
|
333
496
|
*/
|
|
@@ -338,12 +501,14 @@ function attachedLabels(op, dropped) {
|
|
|
338
501
|
};
|
|
339
502
|
for (const [i, { box, marks }] of (op.screenshots ?? []).entries()) {
|
|
340
503
|
const n = `screenshot.${i + 1}`;
|
|
504
|
+
for (const [j, note] of (marks?.notes ?? []).entries()) set(`${n}.note.${j + 1}`, note);
|
|
505
|
+
if (box === void 0) continue;
|
|
341
506
|
const [x, y, width, height] = boxOf(box);
|
|
342
507
|
set(`${n}.position`, `${x},${y}`);
|
|
343
508
|
set(`${n}.size`, `${width}x${height}`);
|
|
344
|
-
for (const [j, note] of (marks?.notes ?? []).entries()) set(`${n}.note.${j + 1}`, note);
|
|
345
509
|
}
|
|
346
510
|
for (const [j, note] of (op.annotations?.notes ?? []).entries()) set(`note.${j + 1}`, note);
|
|
511
|
+
for (const [i, { at, tag }] of (op.also ?? []).entries()) set(`also.${i + 1}`, `${at} <${tag}>`);
|
|
347
512
|
for (const [i, { replay }] of (op.recordings ?? []).entries()) if (replay.length <= LABEL) set(`recording.${i + 1}.replay`, replay);
|
|
348
513
|
for (const [i, kind] of dropped.entries()) set(`dropped.${i + 1}`, kind);
|
|
349
514
|
if (op.pointed !== void 0) set("pointed", op.pointed.path);
|
|
@@ -388,15 +553,20 @@ function nameOf(root) {
|
|
|
388
553
|
* `deictic.url` is the page's whole URL, where a label holds it; `deictic.page` is its path.
|
|
389
554
|
*/
|
|
390
555
|
function labelsOf(source, target, op) {
|
|
556
|
+
const page = {
|
|
557
|
+
"deictic.page": clip(new URL(op.page).pathname, LABEL),
|
|
558
|
+
...op.page.length <= LABEL ? { "deictic.url": op.page } : {},
|
|
559
|
+
"deictic.viewport": `${op.viewport.width}x${op.viewport.height}`
|
|
560
|
+
};
|
|
561
|
+
if (op.detached === true) return page;
|
|
391
562
|
return {
|
|
392
563
|
[AT]: atOf(target),
|
|
393
564
|
[FILE]: clip(target.loc.file, LABEL),
|
|
394
565
|
"deictic.tag": target.tag,
|
|
395
566
|
...source instanceof Refusal ? {} : { "deictic.line": clip(lineOf(source), LABEL) },
|
|
396
|
-
|
|
397
|
-
...op.page.length <= LABEL ? { "deictic.url": op.page } : {},
|
|
398
|
-
"deictic.viewport": `${op.viewport.width}x${op.viewport.height}`,
|
|
567
|
+
...page,
|
|
399
568
|
"deictic.count": String(op.count),
|
|
569
|
+
...op.point === void 0 ? {} : { [POINT]: `${Math.round(op.point.x)},${Math.round(op.point.y)}` },
|
|
400
570
|
...sourceOf(op.chain ?? [])
|
|
401
571
|
};
|
|
402
572
|
}
|