deictic 0.1.0 → 0.3.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 +303 -0
- package/README.md +56 -104
- package/dist/annotations/index.d.ts +1 -1
- package/dist/astro.d.ts +1 -1
- package/dist/bun.d.ts +1 -1
- package/dist/bun.js +2 -2
- package/dist/client/index.d.ts +4 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +130 -16
- package/dist/client/index.js.map +1 -1
- package/dist/index.d.ts +21 -218
- package/dist/index.js.map +1 -1
- package/dist/loader.js +1 -1
- package/dist/logs/client.d.ts +4 -0
- package/dist/logs/client.d.ts.map +1 -0
- package/dist/logs/client.js +16 -0
- package/dist/logs/client.js.map +1 -0
- package/dist/logs/index.d.ts +18 -0
- package/dist/logs/index.d.ts.map +1 -0
- package/dist/logs/index.js +21 -0
- package/dist/logs/index.js.map +1 -0
- package/dist/network/client.d.ts +4 -0
- package/dist/network/client.d.ts.map +1 -0
- package/dist/network/client.js +29 -0
- package/dist/network/client.js.map +1 -0
- package/dist/network/index.d.ts +2 -0
- package/dist/network/index.js +39 -0
- package/dist/network/index.js.map +1 -0
- package/dist/next.d.ts +1 -1
- package/dist/next.js +2 -2
- package/dist/recommended/index.d.ts +15 -5
- package/dist/recommended/index.d.ts.map +1 -1
- package/dist/recommended/index.js +10 -3
- package/dist/recommended/index.js.map +1 -1
- package/dist/recordings/client.d.ts +1 -1
- package/dist/recordings/client.d.ts.map +1 -1
- package/dist/recordings/client.js +177 -48
- package/dist/recordings/client.js.map +1 -1
- package/dist/recordings/index.d.ts +2 -2
- package/dist/recordings/index.js +3 -3
- package/dist/screenshots/client.d.ts +7 -1
- package/dist/screenshots/client.d.ts.map +1 -1
- package/dist/screenshots/client.js +36 -4
- package/dist/screenshots/client.js.map +1 -1
- package/dist/screenshots/dom.d.ts +1 -1
- package/dist/screenshots/dom.d.ts.map +1 -1
- package/dist/screenshots/dom.js +1 -28
- package/dist/screenshots/dom.js.map +1 -1
- package/dist/screenshots/index.d.ts +1 -1
- package/dist/screenshots/index.js +2 -2
- package/dist/screenshots/index.js.map +1 -1
- package/dist/screenshots/rrweb.d.ts +2 -2
- package/dist/screenshots/rrweb.js +5 -1
- package/dist/screenshots/rrweb.js.map +1 -1
- package/dist/{endpoints.js → shared/endpoints.js} +1 -1
- package/dist/shared/endpoints.js.map +1 -0
- package/dist/shared/index.d.ts +238 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/{index3.d.ts → shared/index2.d.ts} +3 -1
- package/dist/shared/index2.d.ts.map +1 -0
- package/dist/shared/index3.d.ts +112 -0
- package/dist/shared/index3.d.ts.map +1 -0
- package/dist/shared/index4.d.ts +64 -0
- package/dist/shared/index4.d.ts.map +1 -0
- package/dist/shared/index5.d.ts +220 -0
- package/dist/shared/index5.d.ts.map +1 -0
- package/dist/{index5.d.ts → shared/index6.d.ts} +2 -2
- package/dist/shared/index6.d.ts.map +1 -0
- package/dist/{integration.d.ts → shared/integration.d.ts} +4 -3
- package/dist/shared/integration.d.ts.map +1 -0
- package/dist/{integration.js → shared/integration.js} +5 -3
- package/dist/shared/integration.js.map +1 -0
- package/dist/{kept.js → shared/kept.js} +2 -2
- package/dist/shared/kept.js.map +1 -0
- package/dist/{marks.js → shared/marks.js} +6 -1
- package/dist/shared/marks.js.map +1 -0
- package/dist/shared/mask.js +107 -0
- package/dist/shared/mask.js.map +1 -0
- package/dist/{playwright.js → shared/playwright.js} +19 -4
- package/dist/shared/playwright.js.map +1 -0
- package/dist/shared/recordings.js +437 -0
- package/dist/shared/recordings.js.map +1 -0
- package/dist/shared/shortcut.js.map +1 -0
- package/dist/shared/tasks.js +632 -0
- package/dist/shared/tasks.js.map +1 -0
- package/dist/shared/waveform.js.map +1 -0
- package/dist/tailwind/client.d.ts +1 -1
- package/dist/tailwind/index.d.ts +1 -1
- package/dist/tasks/client.d.ts +1 -1
- package/dist/tasks/client.d.ts.map +1 -1
- package/dist/tasks/client.js +272 -57
- package/dist/tasks/client.js.map +1 -1
- package/dist/tasks/index.d.ts +2 -159
- package/dist/tasks/index.js +1 -348
- package/dist/vite.d.ts +11 -12
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +21 -4
- package/dist/vite.js.map +1 -1
- package/dist/voice/client.d.ts.map +1 -1
- package/dist/voice/client.js +36 -15
- package/dist/voice/client.js.map +1 -1
- package/dist/voice/index.d.ts +6 -1
- package/dist/voice/index.d.ts.map +1 -1
- package/dist/voice/index.js +13 -3
- package/dist/voice/index.js.map +1 -1
- package/dist/webpack.d.ts +1 -1
- package/dist/webpack.js +2 -2
- package/package.json +41 -2
- package/skills/deictic/SKILL.md +20 -14
- package/skills/deictic/references/install.md +32 -10
- package/skills/deictic/references/recordings.md +29 -0
- package/skills/deictic/references/tasks.md +49 -21
- package/skills/deictic/references/watch.md +38 -11
- package/skills/deictic/scripts/lib.mjs +88 -4
- package/skills/deictic/scripts/recording.mjs +84 -4
- package/skills/deictic/scripts/task.mjs +36 -7
- package/skills/deictic/scripts/vb.mjs +12 -0
- package/skills/deictic/scripts/watch.mjs +74 -10
- package/src/client/away.ts +105 -0
- package/src/client/index.ts +60 -16
- package/src/client/style.ts +1 -0
- package/src/index.ts +21 -2
- package/src/plugins/logs/client.ts +18 -0
- package/src/plugins/logs/index.ts +55 -0
- package/src/plugins/network/client.ts +30 -0
- package/src/plugins/network/index.ts +69 -0
- package/src/plugins/network/mask.ts +133 -0
- package/src/plugins/recommended/index.ts +14 -1
- package/src/plugins/recordings/client.ts +220 -40
- package/src/plugins/recordings/index.ts +111 -25
- package/src/plugins/recordings/marks.ts +6 -0
- package/src/plugins/recordings/replay.ts +159 -10
- package/src/plugins/screenshots/client.ts +38 -2
- package/src/plugins/screenshots/dom.ts +1 -32
- package/src/plugins/screenshots/index.ts +2 -0
- package/src/plugins/screenshots/playwright.ts +15 -4
- package/src/plugins/screenshots/rrweb.ts +2 -1
- package/src/plugins/tasks/client.ts +273 -41
- package/src/plugins/tasks/index.ts +207 -47
- package/src/plugins/tasks/local.ts +170 -0
- package/src/plugins/tasks/watchers.ts +36 -0
- package/src/plugins/voice/client.ts +33 -10
- package/src/plugins/voice/index.ts +21 -4
- package/src/tools/integration.ts +5 -3
- package/src/tools/kept.ts +2 -2
- package/src/vite.ts +23 -4
- package/dist/endpoints.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index2.d.ts +0 -23
- package/dist/index3.d.ts.map +0 -1
- package/dist/index4.d.ts +0 -74
- package/dist/index4.d.ts.map +0 -1
- package/dist/index5.d.ts.map +0 -1
- package/dist/integration.d.ts.map +0 -1
- package/dist/integration.js.map +0 -1
- package/dist/kept.js.map +0 -1
- package/dist/marks.js.map +0 -1
- package/dist/playwright.js.map +0 -1
- package/dist/recordings.js +0 -235
- package/dist/recordings.js.map +0 -1
- package/dist/shortcut.js.map +0 -1
- package/dist/tasks/index.d.ts.map +0 -1
- package/dist/tasks/index.js.map +0 -1
- package/dist/waveform.js.map +0 -1
- /package/dist/{shortcut.js → shared/shortcut.js} +0 -0
- /package/dist/{waveform.js → shared/waveform.js} +0 -0
|
@@ -2,15 +2,22 @@
|
|
|
2
2
|
* The tasks panel: the tasks already about this element and their state, and a field to add one. Each
|
|
3
3
|
* task's ID opens it on the board, where the board has a page; one no one has claimed yet can be edited
|
|
4
4
|
* in place (its words) or deleted (canceled on the board), both changes the popup's undo takes back.
|
|
5
|
+
* Beside the channel it says who watches it (`Model.watching`), or that no agent does.
|
|
5
6
|
* Ctrl+Enter or Add sends it with the page's URL, the viewport and the element as it rendered, which
|
|
6
|
-
* the source can't tell
|
|
7
|
+
* the source can't tell: the chain of source it rendered through, its HTML (a file attached), and where the
|
|
8
|
+
* annotations plugin is loaded, what's marked on the page.
|
|
7
9
|
*
|
|
8
|
-
* Where the screenshots plugin is loaded, a shot of the page goes with it, unless that's unticked
|
|
10
|
+
* Where the screenshots plugin is loaded, a shot of the page goes with it, unless that's unticked, the element
|
|
11
|
+
* outlined in it as the task goes: nothing else says which of two rows alike was meant (a shot drawn on is
|
|
12
|
+
* left as it was drawn). With
|
|
9
13
|
* the annotations plugin too, Annotate takes the shot now and opens it to draw on: saved, it's a chip
|
|
10
14
|
* under the field, which opens it again to change the marks, and Add another takes one more. Any chip
|
|
11
15
|
* (a recording's too) takes the box's place; removing the last brings it back unticked, so a task goes
|
|
12
16
|
* without a shot unless asked again.
|
|
13
17
|
*
|
|
18
|
+
* The element's HTML as it rendered goes with it too, as a file, unless its box is unticked (or the server
|
|
19
|
+
* half's `html` option is off, and then there's no box).
|
|
20
|
+
*
|
|
14
21
|
* Where the recordings plugin is loaded, Record leaves the popup (`away`) to record the page, keeping
|
|
15
22
|
* what's typed and attached, and comes back with the recording as a chip too, which plays it back.
|
|
16
23
|
* Where the voice plugin is, Voice records the mic here in the panel: stopped, it's a chip that plays it.
|
|
@@ -27,23 +34,51 @@ import type { Clip, Take } from '#src/plugins/voice/index.ts';
|
|
|
27
34
|
import type { Change, Marks, Model, Op, Task, TaskAdded } from './index.ts';
|
|
28
35
|
|
|
29
36
|
const STYLE = `
|
|
30
|
-
|
|
31
|
-
.tasks
|
|
32
|
-
|
|
33
|
-
.tasks
|
|
34
|
-
|
|
35
|
-
.tasks
|
|
37
|
+
/* The column is no wider than the panel: an \`auto\` one grows to a long title, which then never truncates. */
|
|
38
|
+
.tasks { list-style: none; margin: 0 0 8px; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
|
|
39
|
+
/* Five rows, and the rest scrolled to: the field stays where it is however many there are. */
|
|
40
|
+
.tasks { max-height: 112px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--deictic-line) transparent; }
|
|
41
|
+
/* A task's words being changed need the room. */
|
|
42
|
+
.tasks:has(.editing) { max-height: none; }
|
|
43
|
+
.tasks li { position: relative; display: flex; gap: 6px; align-items: baseline; }
|
|
44
|
+
.tasks .title { flex: 1; min-width: 0; padding: 0; border: 0; border-radius: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
45
|
+
/* Clicked, a task reads whole, as it was typed. */
|
|
46
|
+
.tasks li.whole .title { white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
47
|
+
/* The state is a dot, named by its tooltip: a ring while no one has it, filled once someone does or it's over. */
|
|
48
|
+
.tasks .state { flex: none; align-self: center; box-sizing: border-box; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--deictic-muted); }
|
|
49
|
+
/* Room for Edit and Delete, which would lie over the first line's end. */
|
|
50
|
+
.tasks li.whole:has(.acts) .title { padding-right: 40px; }
|
|
51
|
+
.tasks li.whole .state { align-self: baseline; }
|
|
52
|
+
.tasks .state.waiting { border-style: dotted; }
|
|
53
|
+
.tasks .state.claimed { border-color: #60a5fa; background: #60a5fa; }
|
|
54
|
+
.tasks .state.blocked { border-color: #fbbf24; background: #fbbf24; }
|
|
55
|
+
.tasks .state.completed { border-color: #4ade80; background: #4ade80; }
|
|
56
|
+
.tasks .state.failed { border-color: var(--deictic-problem); background: var(--deictic-problem); }
|
|
36
57
|
.tasks a { color: inherit; text-decoration: none; }
|
|
37
58
|
.tasks a:hover { text-decoration: underline; }
|
|
38
|
-
|
|
59
|
+
/* Over the row's end, and only while the row is pointed at or focused in: the title keeps the width. */
|
|
60
|
+
.tasks .acts { position: absolute; inset: 0 0 auto auto; min-height: 18px; display: none; align-items: center; padding-left: 14px; background: linear-gradient(to right, transparent, var(--deictic-bg) 12px); }
|
|
61
|
+
.tasks li:hover .acts, .tasks li:focus-within .acts { display: flex; }
|
|
62
|
+
.tasks .act { display: inline-flex; padding: 2px; border: 0; color: var(--deictic-muted); }
|
|
39
63
|
.tasks .act:hover { color: var(--deictic-fg); }
|
|
40
64
|
.tasks .act svg { width: 12px; height: 12px; }
|
|
65
|
+
.tasks .place { flex: none; padding: 0; border: 0; font: 11px ui-monospace, monospace; color: var(--deictic-muted); }
|
|
66
|
+
.tasks button.place:hover { color: var(--deictic-fg); text-decoration: underline; }
|
|
67
|
+
.more { margin: 0 0 8px; }
|
|
68
|
+
.more[hidden] { display: none; }
|
|
69
|
+
.more summary { cursor: pointer; font-size: 12px; color: var(--deictic-muted); }
|
|
70
|
+
.more summary:hover { color: var(--deictic-fg); }
|
|
71
|
+
.more .tasks { margin: 4px 0 0; }
|
|
41
72
|
.tasks li.editing { display: grid; }
|
|
42
73
|
.tasks li.editing .row { margin-top: 0; }
|
|
43
74
|
.tasks li.editing .actions { display: flex; gap: 6px; }
|
|
44
75
|
textarea { min-height: 64px; resize: vertical; font: 13px/1.4 system-ui, sans-serif; }
|
|
45
76
|
.row { display: flex; gap: 6px; margin-top: 8px; justify-content: space-between; align-items: center; }
|
|
46
|
-
|
|
77
|
+
/* Cut short before it pushes Add out: a channel's name and its watchers' may be long. */
|
|
78
|
+
.hint { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--deictic-muted); font-size: 12px; }
|
|
79
|
+
/* A dot as a task's state is: a ring while no one watches, green while someone does. */
|
|
80
|
+
.watch::before { content: ''; display: inline-block; box-sizing: border-box; width: 7px; height: 7px; margin-right: 4px; border-radius: 50%; border: 1.5px solid var(--deictic-muted); }
|
|
81
|
+
.watch.on::before { border-color: #4ade80; background: #4ade80; }
|
|
47
82
|
.hint a { color: inherit; }
|
|
48
83
|
.hint a:hover { color: var(--deictic-fg); }
|
|
49
84
|
.shot { display: flex; gap: 6px; align-items: center; margin-top: 6px; font-size: 12px; color: var(--deictic-muted); }
|
|
@@ -70,6 +105,8 @@ const ICON = (path: string) =>
|
|
|
70
105
|
`<svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="${path}"/></svg>`;
|
|
71
106
|
const EDIT = ICON('M4 20h4L19 9l-4-4L4 16z');
|
|
72
107
|
const DELETE = ICON('M4 7h16M10 7V4h4v3M6 7l1 13h10l1-13');
|
|
108
|
+
/** The states of a task that's over, as a board names them: nothing more happens to it. */
|
|
109
|
+
const OVER = new Set(['completed', 'failed']);
|
|
73
110
|
const PLAY = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M7 4v16l13-8z" fill="currentColor"/></svg>';
|
|
74
111
|
|
|
75
112
|
/** Marks as a task tells of them: how many, and what the notes say. */
|
|
@@ -99,11 +136,20 @@ interface Chip extends Drawn {
|
|
|
99
136
|
interface Kept {
|
|
100
137
|
text: string;
|
|
101
138
|
attach: boolean;
|
|
139
|
+
html: boolean;
|
|
102
140
|
drawn: Drawn[];
|
|
103
141
|
recordings: Recording[];
|
|
104
142
|
voices: Clip[];
|
|
143
|
+
/** What the page said of the element as the panel left, for a task added where the page no longer has it. */
|
|
144
|
+
facts: Facts;
|
|
105
145
|
}
|
|
106
146
|
|
|
147
|
+
/** What a task says that only the page with the element on it knows. */
|
|
148
|
+
type Facts = Pick<Op, 'page' | 'viewport' | 'pointed' | 'count' | 'chain'> & {
|
|
149
|
+
/** The element's HTML, as it would be attached. */
|
|
150
|
+
html: string;
|
|
151
|
+
};
|
|
152
|
+
|
|
107
153
|
const clock = (ms: number) => {
|
|
108
154
|
const s = Math.round(ms / 1000);
|
|
109
155
|
return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, '0')}`;
|
|
@@ -137,6 +183,74 @@ function pathTo(inner: Element, outer: Element): string {
|
|
|
137
183
|
return steps.join(' > ');
|
|
138
184
|
}
|
|
139
185
|
|
|
186
|
+
const parentOf = (el: Element): Element | undefined => {
|
|
187
|
+
if (el.parentElement !== null) return el.parentElement;
|
|
188
|
+
const root = el.getRootNode();
|
|
189
|
+
return root instanceof ShadowRoot ? root.host : undefined;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
/** How many places a chain names after the element's own. */
|
|
193
|
+
const CHAIN = 5;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* The source `el` rendered through, after its own file, nearest first, each a `file:line`: a shared component's
|
|
197
|
+
* own line is the same wherever it's used, and what uses it is the next file out (or a component between them,
|
|
198
|
+
* which is why there are several). Read off the marks around it, the only trace of source the page has: each
|
|
199
|
+
* place is the nearest element the next file wrote, which is where, in that file, the one before is used.
|
|
200
|
+
*/
|
|
201
|
+
function chainOf(el: Element, file: string): NonNullable<Op['chain']> {
|
|
202
|
+
const found: NonNullable<Op['chain']> = [];
|
|
203
|
+
let last = file;
|
|
204
|
+
for (let at = parentOf(el); at !== undefined && found.length < CHAIN; at = parentOf(at)) {
|
|
205
|
+
const mark = at.getAttribute('data-deictic');
|
|
206
|
+
if (mark === null) continue;
|
|
207
|
+
const from = mark.replace(/:\d+:\d+$/, '');
|
|
208
|
+
if (from === last) continue;
|
|
209
|
+
last = from;
|
|
210
|
+
found.push(mark.replace(/:\d+$/, ''));
|
|
211
|
+
}
|
|
212
|
+
return found;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** What's sent of the element's HTML at most, in characters: the server attaches it as a file. */
|
|
216
|
+
const HTML = 100_000;
|
|
217
|
+
|
|
218
|
+
/** The overlay's own green, as its outline of the element while the popup is open. */
|
|
219
|
+
const OUTLINE = '#12b358';
|
|
220
|
+
/** CSS pixels between the element and its outline, so the dashes are on nothing of the element's. */
|
|
221
|
+
const ROOM = 3;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* A shot's PNG with the element outlined in it: dashes around its box, white under them so they show on any
|
|
225
|
+
* page. The shot may have more pixels than its size in CSS ones, which the box is in.
|
|
226
|
+
*/
|
|
227
|
+
async function outlined(png: Blob | string, { box, size }: Pick<Shot, 'box' | 'size'>): Promise<Blob> {
|
|
228
|
+
const url = typeof png === 'string' ? png : URL.createObjectURL(png);
|
|
229
|
+
try {
|
|
230
|
+
const image = new Image();
|
|
231
|
+
image.src = url;
|
|
232
|
+
await image.decode();
|
|
233
|
+
const canvas = element('canvas', { width: image.naturalWidth, height: image.naturalHeight });
|
|
234
|
+
const ctx = canvas.getContext('2d');
|
|
235
|
+
if (ctx === null) throw new Error("tasks: this browser won't draw to a canvas");
|
|
236
|
+
ctx.drawImage(image, 0, 0);
|
|
237
|
+
const k = image.naturalWidth / size.width;
|
|
238
|
+
const rect = [(box.x - ROOM) * k, (box.y - ROOM) * k, (box.width + 2 * ROOM) * k, (box.height + 2 * ROOM) * k] as const;
|
|
239
|
+
ctx.lineWidth = 4 * k;
|
|
240
|
+
ctx.strokeStyle = '#fff';
|
|
241
|
+
ctx.strokeRect(...rect);
|
|
242
|
+
ctx.lineWidth = 2 * k;
|
|
243
|
+
ctx.strokeStyle = OUTLINE;
|
|
244
|
+
ctx.setLineDash([6 * k, 4 * k]);
|
|
245
|
+
ctx.strokeRect(...rect);
|
|
246
|
+
return await new Promise<Blob>((done, fail) =>
|
|
247
|
+
canvas.toBlob((blob) => (blob === null ? fail(new Error('tasks: the screenshot drew nothing')) : done(blob)), 'image/png'),
|
|
248
|
+
);
|
|
249
|
+
} finally {
|
|
250
|
+
if (typeof png !== 'string') URL.revokeObjectURL(url);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
140
254
|
function element<K extends keyof HTMLElementTagNameMap>(tag: K, props: Partial<HTMLElementTagNameMap[K]> = {}): HTMLElementTagNameMap[K] {
|
|
141
255
|
return Object.assign(document.createElement(tag), props);
|
|
142
256
|
}
|
|
@@ -169,6 +283,8 @@ function announce(model: Model, op: Op, target: Target): void {
|
|
|
169
283
|
export default defineClientPlugin<Model, Change>({
|
|
170
284
|
name: 'tasks',
|
|
171
285
|
label: 'Task',
|
|
286
|
+
// All the panel leaves for is a recording, which a page load doesn't end.
|
|
287
|
+
resume: ({ use }) => use('recordings')?.going(),
|
|
172
288
|
mount: (panel, context) => {
|
|
173
289
|
const style = element('style', { textContent: STYLE });
|
|
174
290
|
const list = element('ul', { className: 'tasks' });
|
|
@@ -177,17 +293,31 @@ export default defineClientPlugin<Model, Change>({
|
|
|
177
293
|
const hint = element('span', { className: 'hint' });
|
|
178
294
|
const row = element('div', { className: 'row' });
|
|
179
295
|
row.append(hint, add);
|
|
180
|
-
panel.
|
|
296
|
+
// The file's other tasks, folded away: the panel is about this element. It stays as it's left while the panel is up.
|
|
297
|
+
const fold = element('details', { className: 'more' });
|
|
298
|
+
const count = element('summary');
|
|
299
|
+
const others = element('ul', { className: 'tasks' });
|
|
300
|
+
fold.append(count, others);
|
|
301
|
+
// The element's tasks that are over, folded away too: what's still to do is what's read first.
|
|
302
|
+
const closed = element('details', { className: 'more' });
|
|
303
|
+
const closedCount = element('summary');
|
|
304
|
+
const ended = element('ul', { className: 'tasks' });
|
|
305
|
+
closed.append(closedCount, ended);
|
|
306
|
+
panel.append(style, list, closed, fold, text);
|
|
181
307
|
|
|
182
308
|
const shots = context.use('screenshots');
|
|
309
|
+
// Back from a recording that went on to a page without the element: there's nothing here to take a shot of.
|
|
310
|
+
const here = context.element.isConnected;
|
|
183
311
|
const notes = context.use('annotations');
|
|
184
312
|
const recorder = context.use('recordings');
|
|
185
313
|
const voice = context.use('voice');
|
|
314
|
+
// The server half's `html` option, which takes the box away; a page half with no options (a `standalone` server's) has it.
|
|
315
|
+
const sendsHtml = (context.options as { html?: boolean } | undefined)?.html !== false;
|
|
186
316
|
// Closes an open editor with the panel.
|
|
187
317
|
const aborts = new AbortController();
|
|
188
318
|
|
|
189
319
|
const attach = element('input', { type: 'checkbox', checked: true });
|
|
190
|
-
const toggle = element('label', { hidden: shots === undefined });
|
|
320
|
+
const toggle = element('label', { hidden: shots === undefined || !here });
|
|
191
321
|
toggle.append(attach, 'Attach a screenshot');
|
|
192
322
|
const annotate = element('button', { type: 'button', textContent: 'Annotate', title: 'Take the screenshot now and draw on it' });
|
|
193
323
|
const record = element('button', {
|
|
@@ -197,13 +327,20 @@ export default defineClientPlugin<Model, Change>({
|
|
|
197
327
|
});
|
|
198
328
|
const speak = element('button', { type: 'button', textContent: 'Voice', title: 'Record your voice, here' });
|
|
199
329
|
const actions = element('span', { className: 'actions' });
|
|
200
|
-
actions.append(...(shots !== undefined && notes !== undefined ? [annotate] : []));
|
|
330
|
+
actions.append(...(shots !== undefined && notes !== undefined && here ? [annotate] : []));
|
|
201
331
|
const shot = element('div', { className: 'shot' });
|
|
202
332
|
shot.append(toggle, actions);
|
|
203
333
|
const chipsEl = element('div', { className: 'chips' });
|
|
204
334
|
const another = element('button', { type: 'button', textContent: 'Add another', title: 'Take another screenshot and draw on it' });
|
|
205
335
|
const problem = element('div', { className: 'shot-problem' });
|
|
206
336
|
if (shots !== undefined || recorder !== undefined || voice !== undefined) panel.append(shot, chipsEl, problem);
|
|
337
|
+
// Its own line: the screenshot's gives way to the chips, and this is asked whatever else is attached.
|
|
338
|
+
const withHtml = element('input', { type: 'checkbox', checked: true });
|
|
339
|
+
const htmlToggle = element('label', { title: 'The element as the page has it now, as a file: element.html' });
|
|
340
|
+
htmlToggle.append(withHtml, 'Attach HTML snapshot');
|
|
341
|
+
const htmlRow = element('div', { className: 'shot' });
|
|
342
|
+
htmlRow.append(htmlToggle);
|
|
343
|
+
if (sendsHtml) panel.append(htmlRow);
|
|
207
344
|
panel.append(row);
|
|
208
345
|
|
|
209
346
|
let chips: Chip[] = [];
|
|
@@ -289,7 +426,7 @@ export default defineClientPlugin<Model, Change>({
|
|
|
289
426
|
},
|
|
290
427
|
);
|
|
291
428
|
}),
|
|
292
|
-
...(attached && shots !== undefined && notes !== undefined ? [another] : []),
|
|
429
|
+
...(attached && shots !== undefined && notes !== undefined && here ? [another] : []),
|
|
293
430
|
...(attached ? more() : []),
|
|
294
431
|
);
|
|
295
432
|
able();
|
|
@@ -353,7 +490,7 @@ export default defineClientPlugin<Model, Change>({
|
|
|
353
490
|
// A take going on is kept first, as a chip, to come back to with the rest.
|
|
354
491
|
void speakOff().then(() => {
|
|
355
492
|
const drawn = chips.map(({ url: _, ...d }) => d);
|
|
356
|
-
const kept: Kept = { text: text.value, attach: attach.checked, drawn, recordings, voices };
|
|
493
|
+
const kept: Kept = { text: text.value, attach: attach.checked, html: withHtml.checked, drawn, recordings, voices, facts: facts() };
|
|
357
494
|
context.away(kept, () => recorder.record());
|
|
358
495
|
});
|
|
359
496
|
});
|
|
@@ -410,6 +547,8 @@ export default defineClientPlugin<Model, Change>({
|
|
|
410
547
|
|
|
411
548
|
// The task whose words are open to change, by ID, and the tasks as last read.
|
|
412
549
|
let editing: string | undefined;
|
|
550
|
+
// The tasks shown whole, by ID: kept over a change, which draws the list again.
|
|
551
|
+
const whole = new Set<string>();
|
|
413
552
|
// The Save of a listed task whose words were changed and not kept yet.
|
|
414
553
|
let edited: HTMLElement | undefined;
|
|
415
554
|
/** Tells the popup what leaving now would lose: a listed task's changed words, or a new one's, typed, attached or being spoken. */
|
|
@@ -470,27 +609,92 @@ export default defineClientPlugin<Model, Change>({
|
|
|
470
609
|
shown = model;
|
|
471
610
|
// A task being changed is drawn again with its words as they were.
|
|
472
611
|
edited = undefined;
|
|
473
|
-
const { channel, link, tasks } = model;
|
|
612
|
+
const { channel, link, tasks, elsewhere, watching } = model;
|
|
474
613
|
const name =
|
|
475
614
|
link === undefined
|
|
476
615
|
? element('span')
|
|
477
616
|
: element('a', { href: link, target: '_blank', rel: 'noreferrer', title: 'Open the channel on the board' });
|
|
478
617
|
name.textContent = `#${channel}`;
|
|
479
618
|
hint.replaceChildren('to ', name);
|
|
619
|
+
// Whether a task added now is taken up: who watches the channel, or that no one does, where that's known.
|
|
620
|
+
if (watching !== undefined) {
|
|
621
|
+
const names = new Intl.ListFormat('en', { type: 'conjunction' }).format(watching);
|
|
622
|
+
const on = watching.length > 0;
|
|
623
|
+
const who = element('span', {
|
|
624
|
+
className: on ? 'watch on' : 'watch',
|
|
625
|
+
textContent: on ? `${names} watching` : 'no agent watching',
|
|
626
|
+
title: on
|
|
627
|
+
? `${names} ${watching.length === 1 ? 'is' : 'are'} watching #${channel}, and take${watching.length === 1 ? 's' : ''} each task as it's added`
|
|
628
|
+
: `A task waits on the board until an agent watches #${channel}: ask yours to watch deictic's tasks`,
|
|
629
|
+
});
|
|
630
|
+
hint.append(' · ', who);
|
|
631
|
+
}
|
|
632
|
+
/** A task's row: its state, its ID, a link where it has a page, its title, and where it's from when that's said. */
|
|
633
|
+
const rowOf = (t: Task, from?: HTMLElement) => {
|
|
634
|
+
const item = element('li');
|
|
635
|
+
const state = element('span', { className: `state ${t.state}`, title: t.state });
|
|
636
|
+
state.role = 'img';
|
|
637
|
+
const id = element('code', { textContent: `#${t.id}` });
|
|
638
|
+
const title = element('button', { type: 'button', className: 'title' });
|
|
639
|
+
// In place, not by drawing the list again: that would take a task's words being changed with it.
|
|
640
|
+
const show = () => {
|
|
641
|
+
const all = whole.has(t.id);
|
|
642
|
+
item.classList.toggle('whole', all);
|
|
643
|
+
title.textContent = all ? t.text : t.title;
|
|
644
|
+
title.title = all ? 'Show its first line only' : 'Show all of it';
|
|
645
|
+
title.ariaExpanded = String(all);
|
|
646
|
+
};
|
|
647
|
+
title.addEventListener('click', () => {
|
|
648
|
+
if (!whole.delete(t.id)) whole.add(t.id);
|
|
649
|
+
show();
|
|
650
|
+
});
|
|
651
|
+
show();
|
|
652
|
+
const to =
|
|
653
|
+
t.link === undefined
|
|
654
|
+
? id
|
|
655
|
+
: element('a', { href: t.link, target: '_blank', rel: 'noreferrer', title: 'Open the task on the board' });
|
|
656
|
+
if (to !== id) to.append(id);
|
|
657
|
+
item.append(state, to, title, ...(from === undefined ? [] : [from]));
|
|
658
|
+
return item;
|
|
659
|
+
};
|
|
660
|
+
const { file } = context.target.loc;
|
|
661
|
+
fold.hidden = elsewhere.length === 0;
|
|
662
|
+
count.textContent = `${elsewhere.length} elsewhere in ${file.split('/').at(-1)}`;
|
|
663
|
+
others.replaceChildren(
|
|
664
|
+
...elsewhere.map((t) => {
|
|
665
|
+
if (t.at === undefined) return rowOf(t);
|
|
666
|
+
const { line, column, tag } = t.at;
|
|
667
|
+
const name = `<${tag}> :${line}`;
|
|
668
|
+
// Only an element the page shows now has a popup to open: its place is from the task, which may be old.
|
|
669
|
+
const there = document.querySelector(`[data-deictic="${CSS.escape(`${file}:${line}:${column}`)}"]`);
|
|
670
|
+
if (there === null)
|
|
671
|
+
return rowOf(t, element('span', { className: 'place', textContent: name, title: `Line ${line}, not on this page now` }));
|
|
672
|
+
|
|
673
|
+
const go = element('button', { type: 'button', className: 'place', textContent: name, title: `Open the tasks of line ${line}` });
|
|
674
|
+
go.addEventListener('click', () => void context.open('tasks', there));
|
|
675
|
+
return rowOf(t, go);
|
|
676
|
+
}),
|
|
677
|
+
);
|
|
678
|
+
const over = tasks.filter((t) => OVER.has(t.state));
|
|
679
|
+
closed.hidden = over.length === 0;
|
|
680
|
+
closedCount.textContent = `${over.length} closed`;
|
|
681
|
+
ended.replaceChildren(...over.map((t) => rowOf(t)));
|
|
682
|
+
const live = tasks.filter((t) => !OVER.has(t.state));
|
|
683
|
+
// The latest is the last, which a list longer than its room would keep out of sight: as it opens, and after one is added.
|
|
684
|
+
const grew = live.length > list.childElementCount;
|
|
480
685
|
list.replaceChildren(
|
|
481
|
-
...
|
|
686
|
+
...live.map((t) => {
|
|
482
687
|
if (t.id === editing && t.open) return editor(t);
|
|
483
|
-
const item =
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
}
|
|
688
|
+
const item = rowOf(
|
|
689
|
+
t,
|
|
690
|
+
t.at === undefined
|
|
691
|
+
? undefined
|
|
692
|
+
: element('span', {
|
|
693
|
+
className: 'place',
|
|
694
|
+
textContent: `was :${t.at.line}`,
|
|
695
|
+
title: `Added when this was on line ${t.at.line}: it has moved since`,
|
|
696
|
+
}),
|
|
697
|
+
);
|
|
494
698
|
if (!t.open) return item;
|
|
495
699
|
const edit = element('button', { type: 'button', className: 'act', innerHTML: EDIT, title: 'Edit the task' });
|
|
496
700
|
edit.addEventListener('click', () => {
|
|
@@ -502,15 +706,43 @@ export default defineClientPlugin<Model, Change>({
|
|
|
502
706
|
remove.disabled = true;
|
|
503
707
|
void change({ remove: t.id });
|
|
504
708
|
});
|
|
505
|
-
|
|
709
|
+
const acts = element('span', { className: 'acts' });
|
|
710
|
+
acts.append(edit, remove);
|
|
711
|
+
item.append(acts);
|
|
506
712
|
return item;
|
|
507
713
|
}),
|
|
508
714
|
);
|
|
715
|
+
if (grew) list.scrollTop = list.scrollHeight;
|
|
509
716
|
able();
|
|
510
717
|
mark();
|
|
511
718
|
};
|
|
512
719
|
|
|
513
|
-
|
|
720
|
+
const back = context.resumed;
|
|
721
|
+
/**
|
|
722
|
+
* What the page says of the element: read now, while the page has it, and as the panel left it where the
|
|
723
|
+
* page has moved on without it (a recording that went on to another), which is the page the task is about.
|
|
724
|
+
*/
|
|
725
|
+
const facts = (): Facts => {
|
|
726
|
+
const { element: el, elements } = context;
|
|
727
|
+
if (!here && back !== undefined) return (back.state as Kept).facts;
|
|
728
|
+
const chain = chainOf(el, context.target.loc.file);
|
|
729
|
+
return {
|
|
730
|
+
page: location.href,
|
|
731
|
+
viewport: { width: innerWidth, height: innerHeight },
|
|
732
|
+
...(context.pointed === undefined
|
|
733
|
+
? {}
|
|
734
|
+
: { pointed: { path: pathTo(context.pointed, el), html: context.pointed.outerHTML.slice(0, 4000) } }),
|
|
735
|
+
count: elements.length,
|
|
736
|
+
...(chain.length === 0 ? {} : { chain }),
|
|
737
|
+
html: (shots?.masked(el) ?? el).outerHTML.slice(0, HTML),
|
|
738
|
+
};
|
|
739
|
+
};
|
|
740
|
+
|
|
741
|
+
/**
|
|
742
|
+
* The shots to attach: each chip's PNG, kept as a shot, as the person drew it, or a shot taken now where the
|
|
743
|
+
* box is ticked. Only that one has the element outlined in it (or is as it was taken, where that can't be
|
|
744
|
+
* drawn): nothing else in it says what it's about, while a shot someone annotated says what they marked.
|
|
745
|
+
*/
|
|
514
746
|
const screenshotsOf = async (): Promise<Op['screenshots']> => {
|
|
515
747
|
if (shots === undefined) return undefined;
|
|
516
748
|
if (chips.length > 0) {
|
|
@@ -524,10 +756,14 @@ export default defineClientPlugin<Model, Change>({
|
|
|
524
756
|
);
|
|
525
757
|
}
|
|
526
758
|
// With a recording attached the box is away, so no shot is asked for.
|
|
527
|
-
if (!attach.checked || recordings.length > 0) return undefined;
|
|
759
|
+
if (!attach.checked || recordings.length > 0 || !here) return undefined;
|
|
528
760
|
add.textContent = 'Capturing…';
|
|
529
|
-
const
|
|
530
|
-
|
|
761
|
+
const taken = await shots.capture(context.element);
|
|
762
|
+
try {
|
|
763
|
+
return [{ id: (await shots.upload(await outlined(taken.url, taken), taken)).id, box: taken.box, outlined: true }];
|
|
764
|
+
} catch {
|
|
765
|
+
return [{ id: taken.id, box: taken.box }];
|
|
766
|
+
}
|
|
531
767
|
};
|
|
532
768
|
|
|
533
769
|
const send = async () => {
|
|
@@ -550,16 +786,12 @@ export default defineClientPlugin<Model, Change>({
|
|
|
550
786
|
return;
|
|
551
787
|
}
|
|
552
788
|
add.textContent = 'Add task';
|
|
553
|
-
const { element: el, elements } = context;
|
|
554
789
|
try {
|
|
790
|
+
const { html, ...said } = facts();
|
|
555
791
|
const op: Op = {
|
|
556
792
|
text: text.value,
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
...(context.pointed === undefined
|
|
560
|
-
? {}
|
|
561
|
-
: { pointed: { path: pathTo(context.pointed, el), html: context.pointed.outerHTML.slice(0, 4000) } }),
|
|
562
|
-
count: elements.length,
|
|
793
|
+
...said,
|
|
794
|
+
...(sendsHtml && withHtml.checked ? { html } : {}),
|
|
563
795
|
...(screenshots === undefined ? {} : { screenshots }),
|
|
564
796
|
...(recordings.length === 0
|
|
565
797
|
? {}
|
|
@@ -587,11 +819,11 @@ export default defineClientPlugin<Model, Change>({
|
|
|
587
819
|
};
|
|
588
820
|
|
|
589
821
|
// Back from recording: what was kept, and the recording, or why there's none.
|
|
590
|
-
const back = context.resumed;
|
|
591
822
|
if (back !== undefined) {
|
|
592
823
|
const kept = back.state as Kept;
|
|
593
824
|
text.value = kept.text;
|
|
594
825
|
attach.checked = kept.attach;
|
|
826
|
+
withHtml.checked = kept.html;
|
|
595
827
|
chips = kept.drawn.map(toChip);
|
|
596
828
|
recordings = [...kept.recordings, ...(back.result === undefined ? [] : [back.result as Recording])];
|
|
597
829
|
voices = kept.voices;
|