deictic 0.5.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 +150 -37
- 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/endpoints.js +34 -8
- package/dist/shared/endpoints.js.map +1 -1
- package/dist/shared/find.js +2 -1
- package/dist/shared/find.js.map +1 -1
- package/dist/shared/index.d.ts +124 -11
- 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 +105 -26
- package/dist/shared/index7.d.ts.map +1 -1
- package/dist/shared/index9.d.ts +1 -1
- package/dist/shared/init.js +12 -10
- package/dist/shared/init.js.map +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 +72 -21
- package/dist/shared/task.js.map +1 -1
- package/dist/shared/tasks.js +330 -166
- 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/tailwind/index.js +6 -2
- package/dist/tailwind/index.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 -742
- 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/find.ts +3 -1
- package/src/cli/init.ts +13 -11
- package/src/cli/recording.ts +34 -3
- package/src/cli/task.ts +94 -23
- 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 +121 -10
- 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/tailwind/index.ts +6 -2
- package/src/plugins/tasks/client.ts +219 -749
- package/src/plugins/tasks/composer.ts +797 -0
- package/src/plugins/tasks/drawer.ts +516 -0
- package/src/plugins/tasks/index.ts +459 -192
- 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/src/tools/endpoints.ts +18 -7
- package/src/tools/source.ts +25 -5
- package/skills/deictic/references/recordings.md +0 -13
- package/skills/deictic/references/tasks.md +0 -21
- package/skills/deictic/references/watch.md +0 -17
package/dist/tasks/client.js
CHANGED
|
@@ -1,103 +1,99 @@
|
|
|
1
|
-
import { n as
|
|
1
|
+
import { a as tell, i as ownerOf, n as fiberOf, r as named, t as componentOf } from "../shared/component.js";
|
|
2
|
+
import { c as sameAs, i as div, l as targetOf, o as place, s as reduced, t as ATTRIBUTE, u as toolButton } from "../shared/dom.js";
|
|
2
3
|
import { n as defineClientPlugin } from "../shared/src.js";
|
|
3
|
-
|
|
4
|
+
import { n as liveWaveform } from "../shared/waveform.js";
|
|
5
|
+
// src/plugins/tasks/composer.ts
|
|
4
6
|
/**
|
|
5
|
-
* The
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* The composer: a field as a chat has, shared by the Task tab (a new task) and a task's thread in the drawer (a
|
|
8
|
+
* reply). What's attached is chips over the words, and under them the buttons that attach, each an icon named by its
|
|
9
|
+
* tooltip, and the arrow that sends. Enter sends, and Shift+Enter starts a new line.
|
|
10
|
+
*
|
|
11
|
+
* Two buttons are on or off. With the screenshots plugin, a shot of the page goes as it's sent, the elements
|
|
12
|
+
* outlined in it (or the spot circled): nothing else says which of two rows alike was meant. And, for a task, the
|
|
13
|
+
* element's HTML as it rendered, as a file. The rest make something: Draw takes a shot and opens it to draw on, in the
|
|
14
|
+
* annotations plugin's editor; Record is the caller's (the Task tab leaves the popup to record the page); Voice
|
|
15
|
+
* records the mic here, its time and waveform beside it.
|
|
12
16
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* left as it was drawn). With
|
|
16
|
-
* the annotations plugin too, Annotate takes the shot now and opens it to draw on: saved, it's a chip
|
|
17
|
-
* under the field, which opens it again to change the marks, and Add another takes one more. Any chip
|
|
18
|
-
* (a recording's too) takes the box's place; removing the last brings it back unticked, so a task goes
|
|
19
|
-
* without a shot unless asked again.
|
|
17
|
+
* A task's elements are chips too: the one the popup is on to begin with, and any other the element button's next
|
|
18
|
+
* press on the page picks. A reply has none.
|
|
20
19
|
*
|
|
21
|
-
*
|
|
22
|
-
* half's `html` option is off, and then there's no box).
|
|
20
|
+
* A picture pasted in, or dropped on it, is a screenshot of its own, in the tray, to draw on as one drawn here is.
|
|
23
21
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
22
|
+
* What they make, and what the tool panel's tools made since (the tray), is this one's to attach. Each is a chip,
|
|
23
|
+
* which opens it; removing one takes it out of the tray. Once it's sent, they're gone from the tray, and the page's
|
|
24
|
+
* marks with them.
|
|
27
25
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
.
|
|
33
|
-
|
|
34
|
-
.
|
|
35
|
-
.
|
|
36
|
-
.
|
|
37
|
-
|
|
38
|
-
.
|
|
39
|
-
|
|
40
|
-
.
|
|
41
|
-
|
|
42
|
-
.
|
|
43
|
-
.
|
|
44
|
-
.
|
|
45
|
-
.
|
|
46
|
-
.
|
|
47
|
-
.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
.
|
|
51
|
-
|
|
52
|
-
.
|
|
53
|
-
.
|
|
54
|
-
.
|
|
55
|
-
.tasks .act:hover { color: var(--deictic-fg); }
|
|
56
|
-
.tasks .act svg { width: 12px; height: 12px; }
|
|
57
|
-
.tasks .place { flex: none; padding: 0; border: 0; font: 11px ui-monospace, monospace; color: var(--deictic-muted); }
|
|
58
|
-
.tasks button.place:hover { color: var(--deictic-fg); text-decoration: underline; }
|
|
59
|
-
.more { margin: 0 0 8px; }
|
|
60
|
-
.more[hidden] { display: none; }
|
|
61
|
-
.more summary { cursor: pointer; font-size: 12px; color: var(--deictic-muted); }
|
|
62
|
-
.more summary:hover { color: var(--deictic-fg); }
|
|
63
|
-
.more .tasks { margin: 4px 0 0; }
|
|
64
|
-
.tasks li.editing { display: grid; }
|
|
65
|
-
.tasks li.editing .row { margin-top: 0; }
|
|
66
|
-
.tasks li.editing .actions { display: flex; gap: 6px; }
|
|
67
|
-
textarea { min-height: 64px; resize: vertical; font: 13px/1.4 system-ui, sans-serif; }
|
|
68
|
-
.row { display: flex; gap: 6px; margin-top: 8px; justify-content: space-between; align-items: center; }
|
|
69
|
-
/* Cut short before it pushes Add out: a channel's name and its watchers' may be long. */
|
|
70
|
-
.hint { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--deictic-muted); font-size: 12px; }
|
|
71
|
-
/* A dot as a task's state is: a ring while no one watches, green while someone does. */
|
|
72
|
-
.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); }
|
|
73
|
-
.watch.on::before { border-color: #4ade80; background: #4ade80; }
|
|
74
|
-
.hint a { color: inherit; }
|
|
75
|
-
.hint a:hover { color: var(--deictic-fg); }
|
|
76
|
-
.shot { display: flex; gap: 6px; align-items: center; margin-top: 6px; font-size: 12px; color: var(--deictic-muted); }
|
|
77
|
-
.shot label { display: flex; gap: 6px; align-items: center; }
|
|
78
|
-
.shot input { width: auto; margin: 0; }
|
|
79
|
-
.shot .actions { display: flex; gap: 6px; margin-left: auto; }
|
|
80
|
-
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; font-size: 12px; }
|
|
81
|
-
.chip { display: inline-flex; align-items: center; border: 1px solid var(--deictic-line); border-radius: 6px; }
|
|
82
|
-
.chip button { border: 0; }
|
|
83
|
-
.chip .open { display: inline-flex; align-items: center; gap: 6px; padding: 2px 4px 2px 2px; }
|
|
84
|
-
.chip img { display: block; height: 28px; border-radius: 4px; }
|
|
85
|
-
.chip .play { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 4px; background: var(--deictic-line); }
|
|
26
|
+
/** Scoped to the composer: the drawer and the Task tab share the overlay's root, and a field of theirs is their own. */
|
|
27
|
+
const COMPOSER_STYLE = `
|
|
28
|
+
/* One box for what's attached, the words and the buttons, lit as a field is while it's typed in. */
|
|
29
|
+
.composer { border: 1px solid var(--deictic-line); border-radius: 12px; background: rgb(0 0 0 / 0.35); }
|
|
30
|
+
.composer:focus-within, .composer.dropping { border-color: var(--deictic-accent); box-shadow: 0 0 0 1px var(--deictic-accent); }
|
|
31
|
+
.composer textarea { display: block; box-sizing: border-box; width: 100%; min-height: 0; padding: 10px 12px 4px; border: 0; resize: none; background: none; font: 13px/1.45 system-ui, sans-serif; }
|
|
32
|
+
.composer textarea:focus { outline: none; }
|
|
33
|
+
.composer .chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0; padding: 8px 8px 0; font-size: 12px; }
|
|
34
|
+
.composer .attach { display: flex; align-items: center; gap: 2px; padding: 4px 6px 6px; }
|
|
35
|
+
.composer .attach button.icon { width: 28px; height: 28px; border-radius: 8px; }
|
|
36
|
+
.composer .attach button.icon svg { width: 16px; height: 16px; }
|
|
37
|
+
.composer .attach button[aria-pressed='true'] { color: var(--deictic-accent); background: rgb(18 179 88 / 0.14); }
|
|
38
|
+
.composer .attach .gap { width: 1px; height: 16px; margin: 0 4px; background: var(--deictic-line); }
|
|
39
|
+
.composer .attach .mic[aria-pressed='true'], .composer .attach .mic[aria-pressed='true']:hover { color: #fff; background: #ef4444; }
|
|
40
|
+
.composer .hearing { display: inline-flex; align-items: center; gap: 6px; padding-left: 4px; font: 12px ui-monospace, monospace; color: var(--deictic-muted); }
|
|
41
|
+
.composer .hearing canvas { width: 56px; height: 18px; }
|
|
42
|
+
.composer .doing { margin-left: auto; padding-right: 6px; font-size: 12px; color: var(--deictic-muted); }
|
|
43
|
+
.composer .attach button.send { border-radius: 50%; color: var(--deictic-on-accent); }
|
|
44
|
+
.composer .attach button.send:hover:not(:disabled) { color: var(--deictic-on-accent); background: var(--deictic-accent); filter: brightness(1.1); }
|
|
45
|
+
.composer [hidden] { display: none; }
|
|
46
|
+
/* Every chip one height, and a picture's thumbnail one size whatever its shape or whether it has loaded yet: nothing
|
|
47
|
+
moves as one is attached, or as its picture comes. */
|
|
48
|
+
.chip { box-sizing: border-box; display: inline-flex; align-items: center; height: 30px; border: 1px solid var(--deictic-line); border-radius: 6px; }
|
|
49
|
+
.chip button { height: 100%; border: 0; }
|
|
50
|
+
.chip .open { display: inline-flex; align-items: center; gap: 6px; padding: 0 4px 0 2px; }
|
|
51
|
+
.chip img { display: block; width: 36px; height: 24px; object-fit: cover; border-radius: 4px; background: var(--deictic-line); }
|
|
52
|
+
.chip .play { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 4px; background: var(--deictic-line); }
|
|
86
53
|
.chip .play svg { width: 12px; height: 12px; }
|
|
54
|
+
.chip .play.drawn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
|
|
87
55
|
.chip .remove { padding: 0 6px; color: var(--deictic-muted); }
|
|
88
56
|
.chip .remove:hover { color: var(--deictic-fg); }
|
|
89
|
-
|
|
90
|
-
.
|
|
91
|
-
.
|
|
92
|
-
.shot-problem
|
|
93
|
-
.
|
|
57
|
+
/* An element the task is about: named as the caption names it, in the overlay's own green. */
|
|
58
|
+
.chip.about .open { padding: 0 4px 0 8px; font: 12px ui-monospace, monospace; color: var(--deictic-accent); }
|
|
59
|
+
.chip.about .open span { color: var(--deictic-muted); }
|
|
60
|
+
.compose .shot-problem { margin-top: 4px; font-size: 12px; color: var(--deictic-problem); }
|
|
61
|
+
.compose .shot-problem:empty { display: none; }
|
|
62
|
+
.compose .shot-note { margin-top: 4px; font-size: 12px; color: var(--deictic-muted); }
|
|
63
|
+
.compose .shot-note:empty { display: none; }
|
|
94
64
|
`;
|
|
95
|
-
const ICON = (path) => `<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>`;
|
|
96
|
-
const EDIT = ICON("M4 20h4L19 9l-4-4L4 16z");
|
|
97
|
-
const DELETE = ICON("M4 7h16M10 7V4h4v3M6 7l1 13h10l1-13");
|
|
98
|
-
/** The states of a task that's over, as a board names them: nothing more happens to it. */
|
|
99
|
-
const OVER = /* @__PURE__ */ new Set(["completed", "failed"]);
|
|
100
65
|
const PLAY = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M7 4v16l13-8z\" fill=\"currentColor\"/></svg>";
|
|
66
|
+
/** The composer's buttons, each its strokes on a 24-pixel grid. */
|
|
67
|
+
const CAMERA = "<path d=\"M4 8h3l2-3h6l2 3h3v11H4z\"/><circle cx=\"12\" cy=\"13\" r=\"3.5\"/>";
|
|
68
|
+
const CODE = "<path d=\"M8 7l-5 5 5 5M16 7l5 5-5 5M13.5 5l-3 14\"/>";
|
|
69
|
+
const PEN = "<path d=\"M4 20l1-4L16 5a2.1 2.1 0 0 1 3 3L8 19z\"/>";
|
|
70
|
+
const RECORD = "<circle cx=\"12\" cy=\"12\" r=\"8\"/><circle cx=\"12\" cy=\"12\" r=\"3\" fill=\"currentColor\"/>";
|
|
71
|
+
const MIC = "<rect x=\"9\" y=\"3\" width=\"6\" height=\"11\" rx=\"3\"/><path d=\"M5 11a7 7 0 0 0 14 0M12 18v3\"/>";
|
|
72
|
+
const SEND = "<path d=\"M12 19V5M6 11l6-6 6 6\"/>";
|
|
73
|
+
const TARGET = "<circle cx=\"12\" cy=\"12\" r=\"7\"/><path d=\"M12 2v4M12 18v4M2 12h4M18 12h4\"/>";
|
|
74
|
+
/** How tall the field grows with what's typed, in pixels, before it scrolls. */
|
|
75
|
+
const GROWN = 200;
|
|
76
|
+
/** The overlay's own green, as its ring on the element while the popup is open. */
|
|
77
|
+
const OUTLINE = "#12b358";
|
|
78
|
+
/** CSS pixels between the element and its outline, so the dashes are on nothing of the element's. */
|
|
79
|
+
const ROOM = 3;
|
|
80
|
+
/** How far around a spot its circle is drawn in a shot, in CSS pixels. */
|
|
81
|
+
const SPOT = 16;
|
|
82
|
+
/** The tray's kinds a composer attaches. */
|
|
83
|
+
const KINDS = [
|
|
84
|
+
"screenshots",
|
|
85
|
+
"recordings",
|
|
86
|
+
"voice"
|
|
87
|
+
];
|
|
88
|
+
function element(tag, props = {}) {
|
|
89
|
+
return Object.assign(document.createElement(tag), props);
|
|
90
|
+
}
|
|
91
|
+
const atOf = ({ loc }) => `${loc.file}:${loc.line}:${loc.column}`;
|
|
92
|
+
const clock = (ms) => {
|
|
93
|
+
const s = Math.round(ms / 1e3);
|
|
94
|
+
return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`;
|
|
95
|
+
};
|
|
96
|
+
const messageOf = (e) => e instanceof Error ? e.message : String(e);
|
|
101
97
|
/** Marks as a task tells of them: how many, and what the notes say. */
|
|
102
98
|
function marksOf(list) {
|
|
103
99
|
return {
|
|
@@ -105,16 +101,1569 @@ function marksOf(list) {
|
|
|
105
101
|
notes: list.flatMap(({ shape }) => shape.kind === "note" ? [shape.text] : [])
|
|
106
102
|
};
|
|
107
103
|
}
|
|
108
|
-
/** The page's annotations
|
|
104
|
+
/** The page's annotations, where there are any. */
|
|
109
105
|
function annotationsOf(marks) {
|
|
110
106
|
const list = marks?.list() ?? [];
|
|
111
|
-
return list.length === 0 ?
|
|
107
|
+
return list.length === 0 ? void 0 : marksOf(list);
|
|
108
|
+
}
|
|
109
|
+
const onPage = (a) => a?.el?.isConnected === true ? a.el : void 0;
|
|
110
|
+
/** What's attached, as a task's op or a reply sends it: each shot, each recording with where it replays, each voice note, the marks. */
|
|
111
|
+
function attachedOf({ screenshots, recordings, voices, annotations }) {
|
|
112
|
+
return {
|
|
113
|
+
...screenshots === void 0 ? {} : { screenshots: screenshots.map(({ url: _, ...shot }) => shot) },
|
|
114
|
+
...recordings.length === 0 ? {} : { recordings: recordings.map(({ id, duration, url, voice: clips }) => ({
|
|
115
|
+
id,
|
|
116
|
+
duration,
|
|
117
|
+
replay: new URL(url, location.href).href,
|
|
118
|
+
...clips === void 0 ? {} : { voice: clips.map((c) => c.id) }
|
|
119
|
+
})) },
|
|
120
|
+
...voices.length === 0 ? {} : { voice: voices.map(({ id, duration }) => ({
|
|
121
|
+
id,
|
|
122
|
+
duration
|
|
123
|
+
})) },
|
|
124
|
+
...annotations === void 0 ? {} : { annotations }
|
|
125
|
+
};
|
|
112
126
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
127
|
+
/**
|
|
128
|
+
* A shot's PNG with what the task is about outlined in it: dashes around each box, with nothing between them, and a
|
|
129
|
+
* circle around `spot`. The shot may have more pixels than its size in CSS ones, which the boxes are in.
|
|
130
|
+
*/
|
|
131
|
+
async function outlined(png, size, boxes, spot) {
|
|
132
|
+
const image = new Image();
|
|
133
|
+
image.src = png;
|
|
134
|
+
await image.decode();
|
|
135
|
+
const canvas = element("canvas", {
|
|
136
|
+
width: image.naturalWidth,
|
|
137
|
+
height: image.naturalHeight
|
|
138
|
+
});
|
|
139
|
+
const ctx = canvas.getContext("2d");
|
|
140
|
+
if (ctx === null) throw new Error("tasks: this browser won't draw to a canvas");
|
|
141
|
+
ctx.drawImage(image, 0, 0);
|
|
142
|
+
const k = image.naturalWidth / size.width;
|
|
143
|
+
ctx.lineWidth = 2 * k;
|
|
144
|
+
ctx.strokeStyle = OUTLINE;
|
|
145
|
+
ctx.setLineDash([6 * k, 4 * k]);
|
|
146
|
+
for (const box of boxes) ctx.strokeRect((box.x - ROOM) * k, (box.y - ROOM) * k, (box.width + 6) * k, (box.height + 6) * k);
|
|
147
|
+
if (spot !== void 0) {
|
|
148
|
+
ctx.beginPath();
|
|
149
|
+
ctx.arc(spot.x * k, spot.y * k, SPOT * k, 0, 2 * Math.PI);
|
|
150
|
+
ctx.stroke();
|
|
151
|
+
}
|
|
152
|
+
return await new Promise((done, fail) => canvas.toBlob((blob) => blob === null ? fail(/* @__PURE__ */ new Error("tasks: the screenshot drew nothing")) : done(blob), "image/png"));
|
|
153
|
+
}
|
|
154
|
+
/** A picture as a PNG, and its size: the screenshots plugin keeps PNGs, and a pasted one may be a JPEG or a GIF. */
|
|
155
|
+
async function pngOf(picture) {
|
|
156
|
+
const url = URL.createObjectURL(picture);
|
|
157
|
+
try {
|
|
158
|
+
const image = new Image();
|
|
159
|
+
image.src = url;
|
|
160
|
+
await image.decode();
|
|
161
|
+
const { naturalWidth: width, naturalHeight: height } = image;
|
|
162
|
+
if (picture.type === "image/png") return {
|
|
163
|
+
png: picture,
|
|
164
|
+
width,
|
|
165
|
+
height
|
|
166
|
+
};
|
|
167
|
+
const canvas = element("canvas", {
|
|
168
|
+
width,
|
|
169
|
+
height
|
|
170
|
+
});
|
|
171
|
+
const ctx = canvas.getContext("2d");
|
|
172
|
+
if (ctx === null) throw new Error("tasks: this browser won't draw to a canvas");
|
|
173
|
+
ctx.drawImage(image, 0, 0);
|
|
174
|
+
return {
|
|
175
|
+
png: await new Promise((done, fail) => canvas.toBlob((blob) => blob === null ? fail(/* @__PURE__ */ new Error("tasks: the picture drew nothing")) : done(blob), "image/png")),
|
|
176
|
+
width,
|
|
177
|
+
height
|
|
178
|
+
};
|
|
179
|
+
} finally {
|
|
180
|
+
URL.revokeObjectURL(url);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function composerIn(context, options) {
|
|
184
|
+
const shots = context.use("screenshots");
|
|
185
|
+
const notes = context.use("annotations");
|
|
186
|
+
const recorder = context.use("recordings");
|
|
187
|
+
const voice = context.use("voice");
|
|
188
|
+
const { tray } = context;
|
|
189
|
+
const here = options.here ?? true;
|
|
190
|
+
const withElements = options.about !== void 0;
|
|
191
|
+
let about = options.about?.() ?? [];
|
|
192
|
+
let wanted;
|
|
193
|
+
const shooting = () => shots !== void 0 && here && (wanted ?? (options.shoot === true && attachedCount() === 0));
|
|
194
|
+
let withHtml = true;
|
|
195
|
+
const text = element("textarea", {
|
|
196
|
+
placeholder: options.placeholder,
|
|
197
|
+
rows: 1
|
|
198
|
+
});
|
|
199
|
+
const chipsEl = element("div", { className: "chips" });
|
|
200
|
+
const camera = toolButton(CAMERA, `Attach a screenshot, taken as it's sent`, void 0, () => {
|
|
201
|
+
wanted = !shooting();
|
|
202
|
+
showChips();
|
|
203
|
+
});
|
|
204
|
+
camera.hidden = shots === void 0 || !here;
|
|
205
|
+
const code = toolButton(CODE, "Attach an HTML snapshot: the element as the page has it now, as a file", void 0, () => {
|
|
206
|
+
withHtml = !withHtml;
|
|
207
|
+
showChips();
|
|
208
|
+
});
|
|
209
|
+
code.hidden = !withElements || options.html === false;
|
|
210
|
+
const picker = toolButton(TARGET, "Attach another element: press it on the page", void 0, () => void pick());
|
|
211
|
+
picker.setAttribute("aria-pressed", "false");
|
|
212
|
+
picker.hidden = !withElements || !options.over;
|
|
213
|
+
const pen = toolButton(PEN, "Draw on a screenshot", void 0, () => void draw());
|
|
214
|
+
pen.hidden = shots === void 0 || notes === void 0 || !here;
|
|
215
|
+
const record = toolButton(RECORD, "Record the page", void 0, () => {
|
|
216
|
+
if (!sending) options.record?.();
|
|
217
|
+
});
|
|
218
|
+
record.hidden = recorder === void 0 || options.record === void 0;
|
|
219
|
+
const mic = toolButton(MIC, "Record your voice", void 0, () => void (take === void 0 ? speakOn() : speakOff()));
|
|
220
|
+
mic.classList.add("mic");
|
|
221
|
+
mic.hidden = voice === void 0;
|
|
222
|
+
const gap = element("span", {
|
|
223
|
+
className: "gap",
|
|
224
|
+
hidden: camera.hidden && code.hidden || picker.hidden && pen.hidden && record.hidden && mic.hidden
|
|
225
|
+
});
|
|
226
|
+
const time = element("span");
|
|
227
|
+
const wave = element("canvas");
|
|
228
|
+
const hearing = element("span", {
|
|
229
|
+
className: "hearing",
|
|
230
|
+
hidden: true
|
|
231
|
+
});
|
|
232
|
+
hearing.append(time, wave);
|
|
233
|
+
const doing = element("span", { className: "doing" });
|
|
234
|
+
const send = toolButton(SEND, options.sendLabel, "Enter", () => void sendIt());
|
|
235
|
+
send.classList.add("send", "primary");
|
|
236
|
+
const attach = element("div", { className: "attach" });
|
|
237
|
+
attach.append(camera, code, gap, picker, pen, record, mic, hearing, doing, send);
|
|
238
|
+
const box = element("div", { className: "composer" });
|
|
239
|
+
box.append(chipsEl, text, attach);
|
|
240
|
+
const problem = element("div", { className: "shot-problem" });
|
|
241
|
+
const note = element("div", { className: "shot-note" });
|
|
242
|
+
const el = element("div", { className: "compose" });
|
|
243
|
+
el.append(box, problem, note);
|
|
244
|
+
const grow = () => {
|
|
245
|
+
text.style.height = "auto";
|
|
246
|
+
text.style.height = `${Math.min(text.scrollHeight, GROWN)}px`;
|
|
247
|
+
};
|
|
248
|
+
const inTray = (plugin) => tray.list(plugin).map((item) => item.value);
|
|
249
|
+
const taken = () => ({
|
|
250
|
+
pictures: inTray("screenshots"),
|
|
251
|
+
recordings: inTray("recordings"),
|
|
252
|
+
voices: inTray("voice")
|
|
253
|
+
});
|
|
254
|
+
const attachedCount = () => KINDS.reduce((n, plugin) => n + tray.list(plugin).length, 0);
|
|
255
|
+
let sending = false;
|
|
256
|
+
let take;
|
|
257
|
+
const able = () => send.disabled = sending || text.value.trim() === "" && attachedCount() === 0 && take === void 0;
|
|
258
|
+
const changed = () => options.changed?.();
|
|
259
|
+
const chip = (content, title, at, remove, drop) => {
|
|
260
|
+
const opener = element("button", {
|
|
261
|
+
type: "button",
|
|
262
|
+
className: "open",
|
|
263
|
+
title
|
|
264
|
+
});
|
|
265
|
+
opener.append(...content);
|
|
266
|
+
opener.addEventListener("click", () => context.lightbox(viewed(), {
|
|
267
|
+
at,
|
|
268
|
+
from: it
|
|
269
|
+
}));
|
|
270
|
+
const remover = element("button", {
|
|
271
|
+
type: "button",
|
|
272
|
+
className: "remove",
|
|
273
|
+
textContent: "×",
|
|
274
|
+
title: remove
|
|
275
|
+
});
|
|
276
|
+
remover.addEventListener("click", drop);
|
|
277
|
+
const it = element("span", { className: "chip" });
|
|
278
|
+
it.append(opener, remover);
|
|
279
|
+
return it;
|
|
280
|
+
};
|
|
281
|
+
const numbered = (name, i, of) => of === 1 ? name : `${name} ${i + 1}`;
|
|
282
|
+
/** What's attached, as the lightbox shows it, in the chips' order. */
|
|
283
|
+
const viewed = () => {
|
|
284
|
+
const { pictures, recordings, voices } = taken();
|
|
285
|
+
return [
|
|
286
|
+
...pictures.map((s, i) => ({
|
|
287
|
+
kind: "image",
|
|
288
|
+
url: s.url,
|
|
289
|
+
title: numbered("Screenshot", i, pictures.length),
|
|
290
|
+
...s.drawn === void 0 ? {} : { actions: [s.drawn.marks.length === 0 ? {
|
|
291
|
+
label: "Draw on it",
|
|
292
|
+
title: "Draw boxes, arrows and notes on it",
|
|
293
|
+
run: () => void draw(s)
|
|
294
|
+
} : {
|
|
295
|
+
label: "Change marks",
|
|
296
|
+
title: "Draw on it again",
|
|
297
|
+
run: () => void draw(s)
|
|
298
|
+
}] }
|
|
299
|
+
})),
|
|
300
|
+
...recordings.map((r, i) => ({
|
|
301
|
+
kind: "page",
|
|
302
|
+
url: `${r.url}${r.url.includes("?") ? "&" : "?"}embed`,
|
|
303
|
+
title: `${numbered("Recording", i, recordings.length)} · ${clock(r.duration)}`,
|
|
304
|
+
actions: [{
|
|
305
|
+
label: "New tab",
|
|
306
|
+
title: "Play it back in a tab of its own",
|
|
307
|
+
run: () => void window.open(r.url, "_blank", "noopener")
|
|
308
|
+
}]
|
|
309
|
+
})),
|
|
310
|
+
...voices.map((v, i) => ({
|
|
311
|
+
kind: "audio",
|
|
312
|
+
url: v.url,
|
|
313
|
+
title: `${numbered("Voice", i, voices.length)} · ${clock(v.duration)}`
|
|
314
|
+
}))
|
|
315
|
+
];
|
|
316
|
+
};
|
|
317
|
+
/** Takes one out of the tray. A shot that was the last thing attached leaves none asked for: taking it out said so. */
|
|
318
|
+
const drop = (plugin, id) => () => {
|
|
319
|
+
tray.remove(plugin, id);
|
|
320
|
+
if (plugin === "screenshots" && attachedCount() === 0) wanted = false;
|
|
321
|
+
showChips();
|
|
322
|
+
};
|
|
323
|
+
/** An element the task is about: named as the caption names it, with its place for a tip. Its chip shows it, and its × leaves it out. */
|
|
324
|
+
const aboutChip = (a) => {
|
|
325
|
+
const it = onPage(a);
|
|
326
|
+
const { file, line } = a.target.loc;
|
|
327
|
+
const { component, sole, tag } = it === void 0 ? {
|
|
328
|
+
component: void 0,
|
|
329
|
+
sole: false,
|
|
330
|
+
tag: a.target.tag
|
|
331
|
+
} : named(it);
|
|
332
|
+
const opener = element("button", {
|
|
333
|
+
type: "button",
|
|
334
|
+
className: "open",
|
|
335
|
+
title: `${file}:${line}`
|
|
336
|
+
});
|
|
337
|
+
opener.append(`<${component ?? tag}>`, ...component === void 0 || sole ? [] : [element("span", { textContent: ` <${tag}>` })]);
|
|
338
|
+
opener.addEventListener("click", () => it?.scrollIntoView({
|
|
339
|
+
block: "nearest",
|
|
340
|
+
behavior: "smooth"
|
|
341
|
+
}));
|
|
342
|
+
const remover = element("button", {
|
|
343
|
+
type: "button",
|
|
344
|
+
className: "remove",
|
|
345
|
+
textContent: "×",
|
|
346
|
+
title: `Leave ${it === void 0 ? `<${tag}>` : tell(named(it))} out`
|
|
347
|
+
});
|
|
348
|
+
remover.addEventListener("click", () => {
|
|
349
|
+
about = about.filter((x) => x !== a);
|
|
350
|
+
showChips();
|
|
351
|
+
});
|
|
352
|
+
const chipEl = element("span", { className: "chip about" });
|
|
353
|
+
chipEl.append(opener, remover);
|
|
354
|
+
return chipEl;
|
|
355
|
+
};
|
|
356
|
+
/** What's drawn on the page, which goes with it: its chip draws more, and its × clears it. */
|
|
357
|
+
const marksChip = (marked) => {
|
|
358
|
+
const opener = element("button", {
|
|
359
|
+
type: "button",
|
|
360
|
+
className: "open",
|
|
361
|
+
title: "Draw more on the page"
|
|
362
|
+
});
|
|
363
|
+
const icon = element("span", {
|
|
364
|
+
className: "play drawn",
|
|
365
|
+
innerHTML: `<svg viewBox="0 0 24 24" aria-hidden="true">${PEN}</svg>`
|
|
366
|
+
});
|
|
367
|
+
opener.append(icon, `${marked} mark${marked === 1 ? "" : "s"}`);
|
|
368
|
+
opener.addEventListener("click", () => notes?.draw());
|
|
369
|
+
const remover = element("button", {
|
|
370
|
+
type: "button",
|
|
371
|
+
className: "remove",
|
|
372
|
+
textContent: "×",
|
|
373
|
+
title: "Clear the marks"
|
|
374
|
+
});
|
|
375
|
+
remover.addEventListener("click", () => notes?.clear());
|
|
376
|
+
const it = element("span", { className: "chip" });
|
|
377
|
+
it.append(opener, remover);
|
|
378
|
+
return it;
|
|
379
|
+
};
|
|
380
|
+
const showChips = () => {
|
|
381
|
+
const { pictures, recordings, voices } = taken();
|
|
382
|
+
const marked = notes?.list().length ?? 0;
|
|
383
|
+
camera.setAttribute("aria-pressed", String(shooting()));
|
|
384
|
+
code.setAttribute("aria-pressed", String(withHtml));
|
|
385
|
+
chipsEl.hidden = about.length === 0 && attachedCount() === 0 && marked === 0;
|
|
386
|
+
chipsEl.replaceChildren(...about.map(aboutChip), ...pictures.map((s, i) => {
|
|
387
|
+
const name = numbered("Screenshot", i, pictures.length);
|
|
388
|
+
const thumb = element("img", {
|
|
389
|
+
src: s.url,
|
|
390
|
+
alt: ""
|
|
391
|
+
});
|
|
392
|
+
return chip([thumb, name], `Open ${name.toLowerCase()}`, i, `Remove ${name.toLowerCase()}`, drop("screenshots", s.id));
|
|
393
|
+
}), ...recordings.map((r, i) => {
|
|
394
|
+
const name = numbered("Recording", i, recordings.length);
|
|
395
|
+
const play = element("span", {
|
|
396
|
+
className: "play",
|
|
397
|
+
innerHTML: PLAY
|
|
398
|
+
});
|
|
399
|
+
return chip([play, `${name} ${clock(r.duration)}${r.voice === void 0 ? "" : " · voice"}`], `Play ${name.toLowerCase()} back`, pictures.length + i, `Remove ${name.toLowerCase()}`, drop("recordings", r.id));
|
|
400
|
+
}), ...voices.map((v, i) => {
|
|
401
|
+
const name = numbered("Voice", i, voices.length);
|
|
402
|
+
const play = element("span", {
|
|
403
|
+
className: "play",
|
|
404
|
+
innerHTML: PLAY
|
|
405
|
+
});
|
|
406
|
+
return chip([play, `${name} ${clock(v.duration)}`], `Play ${name.toLowerCase()}`, pictures.length + recordings.length + i, `Remove ${name.toLowerCase()}`, drop("voice", v.id));
|
|
407
|
+
}), ...marked === 0 ? [] : [marksChip(marked)]);
|
|
408
|
+
able();
|
|
409
|
+
};
|
|
410
|
+
const unsubscribe = [tray.subscribe(showChips), notes?.subscribe(showChips)];
|
|
411
|
+
let picking = false;
|
|
412
|
+
const pick = async () => {
|
|
413
|
+
if (picking) return;
|
|
414
|
+
picking = true;
|
|
415
|
+
picker.setAttribute("aria-pressed", "true");
|
|
416
|
+
const spot = await context.tools.pick();
|
|
417
|
+
picking = false;
|
|
418
|
+
picker.setAttribute("aria-pressed", "false");
|
|
419
|
+
const target = spot === void 0 ? void 0 : targetOf(spot.element);
|
|
420
|
+
if (spot === void 0 || target === void 0) return;
|
|
421
|
+
const r = spot.element.getBoundingClientRect();
|
|
422
|
+
if (spot.at.x < 0 || spot.at.y < 0 || spot.at.x > r.width || spot.at.y > r.height) return;
|
|
423
|
+
if (about.some((a) => a.el === spot.element)) return;
|
|
424
|
+
about = [...about, {
|
|
425
|
+
target,
|
|
426
|
+
own: false,
|
|
427
|
+
el: spot.element
|
|
428
|
+
}];
|
|
429
|
+
showChips();
|
|
430
|
+
};
|
|
431
|
+
const outlines = withElements && options.over ? element("div") : void 0;
|
|
432
|
+
if (outlines !== void 0) context.root.append(outlines);
|
|
433
|
+
let following = 0;
|
|
434
|
+
const follow = () => {
|
|
435
|
+
following = requestAnimationFrame(follow);
|
|
436
|
+
if (outlines === void 0) return;
|
|
437
|
+
const others = about.flatMap((a) => a.own || onPage(a) === void 0 ? [] : [onPage(a)]);
|
|
438
|
+
while (outlines.childElementCount > others.length) outlines.lastElementChild.remove();
|
|
439
|
+
while (outlines.childElementCount < others.length) outlines.append(element("div", { className: "task-about" }));
|
|
440
|
+
for (const [i, it] of others.entries()) place(outlines.children[i], it.getBoundingClientRect());
|
|
441
|
+
};
|
|
442
|
+
if (outlines !== void 0) follow();
|
|
443
|
+
const firstAt = () => about[0] === void 0 ? "" : atOf(about[0].target);
|
|
444
|
+
const aborts = new AbortController();
|
|
445
|
+
let drawing = false;
|
|
446
|
+
const draw = async (old) => {
|
|
447
|
+
if (shots === void 0 || notes === void 0 || drawing || sending) return;
|
|
448
|
+
drawing = true;
|
|
449
|
+
problem.textContent = "";
|
|
450
|
+
try {
|
|
451
|
+
if (old === void 0) doing.textContent = "Capturing…";
|
|
452
|
+
const shot = old?.drawn?.shot ?? await shots.capture(onPage(about[0]) ?? document.documentElement);
|
|
453
|
+
doing.textContent = "";
|
|
454
|
+
const picture = {
|
|
455
|
+
url: shot.url,
|
|
456
|
+
...shot.size
|
|
457
|
+
};
|
|
458
|
+
const marks = await notes.edit(picture, old?.drawn?.marks ?? [], { signal: aborts.signal });
|
|
459
|
+
if (marks === void 0) return;
|
|
460
|
+
doing.textContent = "Saving…";
|
|
461
|
+
const kept = await shots.upload(await notes.flatten(picture, marks), shot);
|
|
462
|
+
if (old !== void 0) tray.remove("screenshots", old.id);
|
|
463
|
+
const pictured = {
|
|
464
|
+
...kept,
|
|
465
|
+
drawn: {
|
|
466
|
+
shot,
|
|
467
|
+
marks,
|
|
468
|
+
about: old?.drawn?.about ?? firstAt()
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
tray.add("screenshots", kept.id, pictured);
|
|
472
|
+
} catch (e) {
|
|
473
|
+
problem.textContent = messageOf(e);
|
|
474
|
+
} finally {
|
|
475
|
+
doing.textContent = "";
|
|
476
|
+
drawing = false;
|
|
477
|
+
text.focus();
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
/**
|
|
481
|
+
* Pictures pasted in or dropped on it: each kept as a shot of its own (a PNG, as the screenshots plugin keeps them)
|
|
482
|
+
* and put in the tray, so it's a chip as any other is, to draw on. Anything else is said, not attached.
|
|
483
|
+
*/
|
|
484
|
+
const paste = async (files) => {
|
|
485
|
+
const pictures = files.filter((file) => file.type.startsWith("image/"));
|
|
486
|
+
const others = files.length - pictures.length;
|
|
487
|
+
problem.textContent = "";
|
|
488
|
+
if (pictures.length > 0 && shots === void 0) problem.textContent = "Attaching a picture needs the screenshots plugin: add it to deictic";
|
|
489
|
+
else if (others > 0) problem.textContent = `Only pictures can be attached here: ${others === 1 ? "that file was" : `${others} files were`} left out`;
|
|
490
|
+
if (shots === void 0 || pictures.length === 0) return;
|
|
491
|
+
doing.textContent = "Attaching…";
|
|
492
|
+
try {
|
|
493
|
+
for (const picture of pictures) {
|
|
494
|
+
const { png, width, height } = await pngOf(picture);
|
|
495
|
+
const size = {
|
|
496
|
+
width,
|
|
497
|
+
height
|
|
498
|
+
};
|
|
499
|
+
const kept = await shots.upload(png, {
|
|
500
|
+
box: {
|
|
501
|
+
x: 0,
|
|
502
|
+
y: 0,
|
|
503
|
+
...size
|
|
504
|
+
},
|
|
505
|
+
size
|
|
506
|
+
});
|
|
507
|
+
const pictured = {
|
|
508
|
+
...kept,
|
|
509
|
+
drawn: {
|
|
510
|
+
shot: kept,
|
|
511
|
+
marks: [],
|
|
512
|
+
about: ""
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
tray.add("screenshots", kept.id, pictured);
|
|
516
|
+
}
|
|
517
|
+
} catch (e) {
|
|
518
|
+
problem.textContent = messageOf(e);
|
|
519
|
+
} finally {
|
|
520
|
+
doing.textContent = "";
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
box.addEventListener("paste", (e) => {
|
|
524
|
+
const files = [...e.clipboardData?.files ?? []];
|
|
525
|
+
if (files.length === 0) return;
|
|
526
|
+
e.preventDefault();
|
|
527
|
+
paste(files);
|
|
528
|
+
});
|
|
529
|
+
box.addEventListener("dragover", (e) => {
|
|
530
|
+
if (!e.dataTransfer?.types.includes("Files")) return;
|
|
531
|
+
e.preventDefault();
|
|
532
|
+
box.classList.add("dropping");
|
|
533
|
+
});
|
|
534
|
+
box.addEventListener("dragleave", () => box.classList.remove("dropping"));
|
|
535
|
+
box.addEventListener("drop", (e) => {
|
|
536
|
+
box.classList.remove("dropping");
|
|
537
|
+
const files = [...e.dataTransfer?.files ?? []];
|
|
538
|
+
if (files.length === 0) return;
|
|
539
|
+
e.preventDefault();
|
|
540
|
+
paste(files);
|
|
541
|
+
});
|
|
542
|
+
let ticking;
|
|
543
|
+
let stopWave;
|
|
544
|
+
const speakOn = async () => {
|
|
545
|
+
if (voice === void 0) return;
|
|
546
|
+
problem.textContent = "";
|
|
547
|
+
mic.disabled = true;
|
|
548
|
+
try {
|
|
549
|
+
take = await voice.start();
|
|
550
|
+
} catch (e) {
|
|
551
|
+
problem.textContent = messageOf(e);
|
|
552
|
+
return;
|
|
553
|
+
} finally {
|
|
554
|
+
mic.disabled = false;
|
|
555
|
+
}
|
|
556
|
+
const { started, stream } = take;
|
|
557
|
+
stopWave = liveWaveform(wave, stream, {
|
|
558
|
+
played: "#ef4444",
|
|
559
|
+
rest: "#52525b"
|
|
560
|
+
});
|
|
561
|
+
const tick = () => time.textContent = clock(Date.now() - started);
|
|
562
|
+
tick();
|
|
563
|
+
ticking = setInterval(tick, 250);
|
|
564
|
+
hearing.hidden = false;
|
|
565
|
+
mic.setAttribute("aria-pressed", "true");
|
|
566
|
+
mic.title = "Stop, and attach it";
|
|
567
|
+
able();
|
|
568
|
+
changed();
|
|
569
|
+
};
|
|
570
|
+
const speakOff = async () => {
|
|
571
|
+
const ending = take;
|
|
572
|
+
if (ending === void 0) return;
|
|
573
|
+
take = void 0;
|
|
574
|
+
clearInterval(ticking);
|
|
575
|
+
stopWave?.();
|
|
576
|
+
stopWave = void 0;
|
|
577
|
+
hearing.hidden = true;
|
|
578
|
+
mic.setAttribute("aria-pressed", "false");
|
|
579
|
+
mic.title = "Record your voice";
|
|
580
|
+
try {
|
|
581
|
+
const clip = await ending.stop();
|
|
582
|
+
tray.add("voice", clip.id, clip);
|
|
583
|
+
} catch (e) {
|
|
584
|
+
problem.textContent = messageOf(e);
|
|
585
|
+
}
|
|
586
|
+
able();
|
|
587
|
+
changed();
|
|
588
|
+
};
|
|
589
|
+
/**
|
|
590
|
+
* The shots to attach: one taken now, where that's on, and those in the tray, each the window as it was taken.
|
|
591
|
+
* Only the first has the elements outlined in it, and its spot circled (or is as it was taken, where that can't be
|
|
592
|
+
* drawn), so it's first: nothing else in a shot says what it's about.
|
|
593
|
+
*/
|
|
594
|
+
const screenshotsOf = async () => {
|
|
595
|
+
if (shots === void 0) return void 0;
|
|
596
|
+
const kept = taken().pictures.map(({ id, url, drawn }) => ({
|
|
597
|
+
id,
|
|
598
|
+
url,
|
|
599
|
+
...drawn !== void 0 && drawn.about !== "" && drawn.about === firstAt() ? { box: drawn.shot.box } : {},
|
|
600
|
+
...drawn === void 0 || drawn.marks.length === 0 ? {} : { marks: marksOf(drawn.marks) }
|
|
601
|
+
}));
|
|
602
|
+
if (!shooting()) return kept.length === 0 ? void 0 : kept;
|
|
603
|
+
doing.textContent = "Capturing…";
|
|
604
|
+
const first = onPage(about[0]);
|
|
605
|
+
const of = first ?? document.documentElement;
|
|
606
|
+
const now = await shots.capture(of);
|
|
607
|
+
const where = first === void 0 ? {} : { box: now.box };
|
|
608
|
+
const live = of.getBoundingClientRect();
|
|
609
|
+
const boxes = about.flatMap((a) => {
|
|
610
|
+
const it = onPage(a);
|
|
611
|
+
if (it === void 0) return [];
|
|
612
|
+
if (it === first) return a.own && options.at !== void 0 ? [] : [now.box];
|
|
613
|
+
const r = it.getBoundingClientRect();
|
|
614
|
+
return [{
|
|
615
|
+
x: r.left + now.box.x - live.left,
|
|
616
|
+
y: r.top + now.box.y - live.top,
|
|
617
|
+
width: r.width,
|
|
618
|
+
height: r.height
|
|
619
|
+
}];
|
|
620
|
+
});
|
|
621
|
+
const spot = first !== void 0 && about[0]?.own === true ? options.at : void 0;
|
|
622
|
+
const circled = spot === void 0 ? void 0 : {
|
|
623
|
+
x: now.box.x + spot.x,
|
|
624
|
+
y: now.box.y + spot.y
|
|
625
|
+
};
|
|
626
|
+
if (boxes.length === 0 && circled === void 0) return [{
|
|
627
|
+
id: now.id,
|
|
628
|
+
url: now.url
|
|
629
|
+
}, ...kept];
|
|
630
|
+
try {
|
|
631
|
+
const { id, url } = await shots.upload(await outlined(now.url, now.size, boxes, circled), now);
|
|
632
|
+
return [{
|
|
633
|
+
id,
|
|
634
|
+
url,
|
|
635
|
+
...where,
|
|
636
|
+
outlined: true
|
|
637
|
+
}, ...kept];
|
|
638
|
+
} catch {
|
|
639
|
+
return [{
|
|
640
|
+
id: now.id,
|
|
641
|
+
url: now.url,
|
|
642
|
+
...where
|
|
643
|
+
}, ...kept];
|
|
644
|
+
}
|
|
645
|
+
};
|
|
646
|
+
const sendIt = async () => {
|
|
647
|
+
if (sending) return;
|
|
648
|
+
sending = true;
|
|
649
|
+
await speakOff();
|
|
650
|
+
if (text.value.trim() === "" && attachedCount() === 0) {
|
|
651
|
+
sending = false;
|
|
652
|
+
able();
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
able();
|
|
656
|
+
problem.textContent = "";
|
|
657
|
+
note.textContent = "";
|
|
658
|
+
let screenshots;
|
|
659
|
+
try {
|
|
660
|
+
screenshots = await screenshotsOf();
|
|
661
|
+
} catch (e) {
|
|
662
|
+
problem.textContent = messageOf(e);
|
|
663
|
+
doing.textContent = "";
|
|
664
|
+
sending = false;
|
|
665
|
+
able();
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
doing.textContent = "";
|
|
669
|
+
const { recordings, voices } = taken();
|
|
670
|
+
const annotations = annotationsOf(notes);
|
|
671
|
+
let done = false;
|
|
672
|
+
try {
|
|
673
|
+
done = await options.submit({
|
|
674
|
+
text: text.value,
|
|
675
|
+
about,
|
|
676
|
+
html: withHtml,
|
|
677
|
+
...screenshots === void 0 ? {} : { screenshots },
|
|
678
|
+
recordings,
|
|
679
|
+
voices,
|
|
680
|
+
...annotations === void 0 ? {} : { annotations }
|
|
681
|
+
});
|
|
682
|
+
} catch (e) {
|
|
683
|
+
problem.textContent = messageOf(e);
|
|
684
|
+
}
|
|
685
|
+
if (done) {
|
|
686
|
+
text.value = "";
|
|
687
|
+
grow();
|
|
688
|
+
for (const plugin of KINDS) tray.remove(plugin);
|
|
689
|
+
notes?.clear();
|
|
690
|
+
wanted = void 0;
|
|
691
|
+
about = options.about?.() ?? [];
|
|
692
|
+
showChips();
|
|
693
|
+
changed();
|
|
694
|
+
}
|
|
695
|
+
sending = false;
|
|
696
|
+
able();
|
|
697
|
+
};
|
|
698
|
+
text.addEventListener("input", () => {
|
|
699
|
+
grow();
|
|
700
|
+
able();
|
|
701
|
+
changed();
|
|
702
|
+
});
|
|
703
|
+
text.addEventListener("keydown", (e) => {
|
|
704
|
+
if (e.key !== "Enter" || e.shiftKey || e.isComposing) return;
|
|
705
|
+
e.preventDefault();
|
|
706
|
+
sendIt();
|
|
707
|
+
});
|
|
708
|
+
showChips();
|
|
709
|
+
requestAnimationFrame(grow);
|
|
710
|
+
return {
|
|
711
|
+
el,
|
|
712
|
+
send,
|
|
713
|
+
problem,
|
|
714
|
+
note,
|
|
715
|
+
pending: () => text.value.trim() !== "" || take !== void 0,
|
|
716
|
+
draft: () => ({
|
|
717
|
+
text: text.value,
|
|
718
|
+
...wanted === void 0 ? {} : { shot: wanted },
|
|
719
|
+
html: withHtml,
|
|
720
|
+
about
|
|
721
|
+
}),
|
|
722
|
+
restore: (draft) => {
|
|
723
|
+
if (draft.text !== void 0) text.value = draft.text;
|
|
724
|
+
if (draft.shot !== void 0) wanted = draft.shot;
|
|
725
|
+
if (draft.html !== void 0) withHtml = draft.html;
|
|
726
|
+
if (draft.about !== void 0) about = draft.about;
|
|
727
|
+
showChips();
|
|
728
|
+
grow();
|
|
729
|
+
},
|
|
730
|
+
stopTake: speakOff,
|
|
731
|
+
focus: () => text.focus(),
|
|
732
|
+
destroy: () => {
|
|
733
|
+
for (const stop of unsubscribe) stop?.();
|
|
734
|
+
aborts.abort();
|
|
735
|
+
cancelAnimationFrame(following);
|
|
736
|
+
outlines?.remove();
|
|
737
|
+
speakOff();
|
|
738
|
+
}
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
// src/plugins/tasks/store.ts
|
|
742
|
+
/** How long the tasks read last are shown as they are, in ms: the keys are held again and again, and each is no reason to ask the board. */
|
|
743
|
+
const FRESH = 4e3;
|
|
744
|
+
/** Where what's been read is kept: each task's ID, and how its thread stood when it was last opened. */
|
|
745
|
+
const SEEN = "deictic:tasks:seen";
|
|
746
|
+
/** Where the finished tasks put away are kept: each one's ID, and how its thread stood then. */
|
|
747
|
+
const ARCHIVED = "deictic:tasks:archived";
|
|
748
|
+
/** The states of a finished task, as a board names them: nothing more happens to it. */
|
|
749
|
+
const OVER = /* @__PURE__ */ new Set(["completed", "failed"]);
|
|
750
|
+
/** The states whose coming is news in itself, whoever said nothing as it came. */
|
|
751
|
+
const NEWS = /* @__PURE__ */ new Set([
|
|
752
|
+
"blocked",
|
|
753
|
+
"completed",
|
|
754
|
+
"failed"
|
|
755
|
+
]);
|
|
756
|
+
/** How a task's thread stands: its newest reply, and its state where that's news. */
|
|
757
|
+
const markOf = (task) => `${task.last ?? ""}|${NEWS.has(task.state) ? task.state : ""}`;
|
|
758
|
+
/** What's kept under `key` (what's been read, what's put away), or nothing where this browser has kept none yet. */
|
|
759
|
+
function kept(key = SEEN) {
|
|
760
|
+
try {
|
|
761
|
+
const seen = JSON.parse(localStorage.getItem(key) ?? "null");
|
|
762
|
+
return typeof seen === "object" && seen !== null ? seen : void 0;
|
|
763
|
+
} catch {
|
|
764
|
+
return;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
const made$2 = /* @__PURE__ */ new WeakMap();
|
|
768
|
+
/** The tasks of the overlay `context` is of: one store, whoever asks. */
|
|
769
|
+
function storeOf(context) {
|
|
770
|
+
const known = made$2.get(context.root);
|
|
771
|
+
if (known !== void 0) return known;
|
|
772
|
+
let tasks = [];
|
|
773
|
+
let channel;
|
|
774
|
+
let read = 0;
|
|
775
|
+
let asked = 0;
|
|
776
|
+
let seen = kept();
|
|
777
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
778
|
+
const tell = () => {
|
|
779
|
+
for (const listener of listeners) listener();
|
|
780
|
+
};
|
|
781
|
+
let away = kept(ARCHIVED) ?? {};
|
|
782
|
+
const keep = (key = SEEN, value = seen) => {
|
|
783
|
+
try {
|
|
784
|
+
localStorage.setItem(key, JSON.stringify(value));
|
|
785
|
+
} catch {}
|
|
786
|
+
};
|
|
787
|
+
const store = {
|
|
788
|
+
tasks: () => tasks,
|
|
789
|
+
channel: () => channel,
|
|
790
|
+
load: (again = false) => {
|
|
791
|
+
if (!again && Date.now() - read < FRESH) return;
|
|
792
|
+
const ask = ++asked;
|
|
793
|
+
read = Date.now();
|
|
794
|
+
context.request("page").then(async (res) => {
|
|
795
|
+
if (!res.ok || ask !== asked) return;
|
|
796
|
+
const answer = await res.json();
|
|
797
|
+
({tasks} = answer);
|
|
798
|
+
if (seen === void 0) {
|
|
799
|
+
seen = Object.fromEntries(tasks.map((task) => [task.id, markOf(task)]));
|
|
800
|
+
keep();
|
|
801
|
+
}
|
|
802
|
+
if (answer.channel !== void 0) channel = {
|
|
803
|
+
name: answer.channel,
|
|
804
|
+
...answer.link === void 0 ? {} : { link: answer.link }
|
|
805
|
+
};
|
|
806
|
+
tell();
|
|
807
|
+
}).catch(() => {});
|
|
808
|
+
},
|
|
809
|
+
subscribe: (listener) => {
|
|
810
|
+
listeners.add(listener);
|
|
811
|
+
return () => listeners.delete(listener);
|
|
812
|
+
},
|
|
813
|
+
unread: (task) => seen !== void 0 && markOf(task) !== "|" && seen[task.id] !== markOf(task),
|
|
814
|
+
read: (task) => seen?.[task.id]?.split("|", 1)[0] || void 0,
|
|
815
|
+
seen: (task) => {
|
|
816
|
+
if (seen?.[task.id] === markOf(task)) return;
|
|
817
|
+
seen = {
|
|
818
|
+
...seen,
|
|
819
|
+
...kept(),
|
|
820
|
+
[task.id]: markOf(task)
|
|
821
|
+
};
|
|
822
|
+
keep();
|
|
823
|
+
tell();
|
|
824
|
+
},
|
|
825
|
+
archived: (task) => OVER.has(task.state) && away[task.id] === markOf(task),
|
|
826
|
+
archive: (finished) => {
|
|
827
|
+
const marks = Object.fromEntries(finished.filter((task) => OVER.has(task.state)).map((task) => [task.id, markOf(task)]));
|
|
828
|
+
const listed = new Set(tasks.map((task) => task.id));
|
|
829
|
+
away = Object.fromEntries(Object.entries({
|
|
830
|
+
...away,
|
|
831
|
+
...kept(ARCHIVED),
|
|
832
|
+
...marks
|
|
833
|
+
}).filter(([id]) => listed.has(id)));
|
|
834
|
+
keep(ARCHIVED, away);
|
|
835
|
+
seen = {
|
|
836
|
+
...seen,
|
|
837
|
+
...kept(),
|
|
838
|
+
...marks
|
|
839
|
+
};
|
|
840
|
+
keep();
|
|
841
|
+
tell();
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
made$2.set(context.root, store);
|
|
845
|
+
return store;
|
|
846
|
+
}
|
|
847
|
+
// src/plugins/tasks/drawer.ts
|
|
848
|
+
/**
|
|
849
|
+
* The tasks' section of the drawer: the channel's tasks still to do, each with its state, and the latest finished
|
|
850
|
+
* folded under them, those put away (archived) left out. One with something unread (a reply since it was last opened
|
|
851
|
+
* here, or an end no one looked at) says so, and a row the pointer is on lights its element on the page. A task opens
|
|
852
|
+
* in the drawer: its words, to change while no one has it, what it has attached, its thread, read as it's opened and
|
|
853
|
+
* again every few seconds, a composer to answer in (as the Task tab's, with what a reply can attach), and Delete,
|
|
854
|
+
* which cancels it on the board.
|
|
855
|
+
*/
|
|
856
|
+
const STYLE$2 = `
|
|
857
|
+
.tasks-drawer h3 .unread { padding: 0 6px; border-radius: 8px; font-weight: 700; letter-spacing: 0; color: var(--deictic-on-accent); background: var(--deictic-accent); }
|
|
858
|
+
.tasks-drawer h3 a { margin-left: auto; font-weight: 400; letter-spacing: 0; text-transform: none; color: inherit; }
|
|
859
|
+
.tasks-drawer h3 a:hover { color: var(--deictic-fg); }
|
|
860
|
+
.task-row { display: grid; grid-template: 'state title mark' auto 'state meta mark' auto / auto minmax(0, 1fr) auto; gap: 1px 8px; align-items: center;
|
|
861
|
+
width: 100%; padding: 6px 8px; border: 1px solid rgb(255 255 255 / 0.08); border-radius: 8px; text-align: left; font-size: 12px; background: rgb(255 255 255 / 0.04); }
|
|
862
|
+
.task-row:hover { border-color: rgb(255 255 255 / 0.16); background: rgb(255 255 255 / 0.06); }
|
|
863
|
+
.task-row .title { grid-area: title; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
864
|
+
.task-row .meta { grid-area: meta; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: var(--deictic-muted); }
|
|
865
|
+
.task-row.unread .title { font-weight: 600; }
|
|
866
|
+
/* What's unread is a dot of the overlay's own green, where a read one has nothing. */
|
|
867
|
+
.task-row .mark { grid-area: mark; width: 7px; height: 7px; border-radius: 50%; }
|
|
868
|
+
.task-row.unread .mark { background: var(--deictic-accent); box-shadow: 0 0 8px var(--deictic-accent); }
|
|
869
|
+
/* The state is a dot, as a board's is: a ring while no one has it, filled once someone does or it's finished. */
|
|
870
|
+
.task-state { grid-area: state; flex: none; box-sizing: border-box; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--deictic-muted); }
|
|
871
|
+
.task-state.waiting { border-style: dotted; }
|
|
872
|
+
.task-state.claimed { border-color: #60a5fa; background: #60a5fa; }
|
|
873
|
+
.task-state.blocked { border-color: #fbbf24; background: #fbbf24; }
|
|
874
|
+
.task-state.completed { border-color: #4ade80; background: #4ade80; }
|
|
875
|
+
.task-state.failed { border-color: var(--deictic-problem); background: var(--deictic-problem); }
|
|
876
|
+
.tasks-drawer details { margin-top: 6px; }
|
|
877
|
+
.tasks-drawer summary { cursor: pointer; font-size: 12px; color: var(--deictic-muted); }
|
|
878
|
+
.tasks-drawer summary:hover { color: var(--deictic-fg); }
|
|
879
|
+
.tasks-drawer details .drawer-rows { margin-top: 6px; }
|
|
880
|
+
.tasks-drawer .put-away { justify-self: end; }
|
|
881
|
+
.tasks-drawer .act, .task-view .act { padding: 1px 6px; border: 0; font-size: 12px; color: var(--deictic-muted); }
|
|
882
|
+
.tasks-drawer .act:hover, .task-view .act:hover { color: var(--deictic-fg); }
|
|
883
|
+
.task-view { display: flex; flex-direction: column; gap: 8px; min-height: 0; font-size: 12px; }
|
|
884
|
+
.task-view .stands { display: flex; align-items: center; gap: 6px; color: var(--deictic-muted); }
|
|
885
|
+
.task-view .stands .says { flex: 1; }
|
|
886
|
+
.task-view .stands a { color: inherit; }
|
|
887
|
+
.task-view .stands a:hover { color: var(--deictic-fg); }
|
|
888
|
+
.task-view .act.sure { color: var(--deictic-problem); }
|
|
889
|
+
.task-view .where { align-self: start; max-width: 100%; padding: 0; border: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 11px ui-monospace, monospace; color: var(--deictic-accent); }
|
|
890
|
+
.task-view .where span { color: var(--deictic-muted); }
|
|
891
|
+
.task-view .words { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.45; }
|
|
892
|
+
.task-view .said { padding: 4px 8px; border-left: 2px solid var(--deictic-line); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--deictic-muted); }
|
|
893
|
+
.task-view .editing textarea { display: block; box-sizing: border-box; width: 100%; min-height: 56px; resize: vertical; font: 13px/1.45 system-ui, sans-serif; }
|
|
894
|
+
.task-view .buttons { display: flex; justify-content: end; gap: 6px; margin-top: 6px; }
|
|
895
|
+
/* What a task or a reply has attached: a chip each, which opens all of them in the lightbox. */
|
|
896
|
+
.task-files { display: flex; flex-wrap: wrap; gap: 4px; }
|
|
897
|
+
.task-files:empty { display: none; }
|
|
898
|
+
/* One height, and a thumbnail one size, as the composer's chips: nothing moves as the pictures load. */
|
|
899
|
+
.task-files button { box-sizing: border-box; display: inline-flex; align-items: center; gap: 6px; max-width: 100%; height: 26px; padding: 0 6px 0 2px; border: 1px solid var(--deictic-line); border-radius: 6px; font-size: 11px; }
|
|
900
|
+
.task-files button span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
901
|
+
.task-files img { flex: none; display: block; width: 30px; height: 20px; object-fit: cover; border-radius: 4px; background: var(--deictic-line); }
|
|
902
|
+
.task-files .play { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 4px; background: var(--deictic-line); }
|
|
903
|
+
.task-files .play svg { width: 10px; height: 10px; }
|
|
904
|
+
.task-thread { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; margin: 0; padding: 8px 0 0; border-top: 1px solid rgb(255 255 255 / 0.08); list-style: none; }
|
|
905
|
+
.task-thread:empty { display: none; }
|
|
906
|
+
.task-thread li { display: grid; gap: 4px; padding: 6px 8px; border: 1px solid rgb(255 255 255 / 0.08); border-radius: 8px; background: rgb(255 255 255 / 0.04); }
|
|
907
|
+
.task-thread li.new { border-color: color-mix(in srgb, var(--deictic-accent) 55%, transparent); }
|
|
908
|
+
.task-thread .by { display: flex; gap: 6px; align-items: baseline; font-size: 11px; color: var(--deictic-muted); }
|
|
909
|
+
.task-thread .by b { font-weight: 600; color: var(--deictic-fg); }
|
|
910
|
+
.task-thread .by i { margin-left: auto; font-style: normal; }
|
|
911
|
+
.task-thread .text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
|
|
912
|
+
.task-view .problem { color: var(--deictic-problem); }
|
|
913
|
+
.task-view .problem:empty { display: none; }
|
|
914
|
+
/* On the page, around an element a task is about: the open task's, and each one attached in the Task tab. */
|
|
915
|
+
.task-about { position: fixed; z-index: 2147483646; box-sizing: border-box; pointer-events: none; border: 1.5px dashed var(--deictic-accent); border-radius: 6px; }
|
|
916
|
+
.task-about[hidden] { display: none; }
|
|
917
|
+
${COMPOSER_STYLE}`;
|
|
918
|
+
/** How often an open task's thread is read again, in ms: an agent answers while it's looked at. */
|
|
919
|
+
const AGAIN = 5e3;
|
|
920
|
+
/** How long Delete waits to be pressed again, in ms, before it's only Delete once more. */
|
|
921
|
+
const SURE = 3e3;
|
|
922
|
+
/** Where what's typed in a reply is kept while its task isn't open: for the tab, over page loads. */
|
|
923
|
+
const DRAFTS = "deictic:tasks:drafts";
|
|
924
|
+
const FILE = "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><path d=\"M6 3h8l4 4v14H6zM14 3v4h4\"/></svg>";
|
|
925
|
+
/** `now`, `5m`, `2h`, `3d`: how long ago, as short as a thread's margin. */
|
|
926
|
+
function ago(at) {
|
|
927
|
+
const minutes = Math.round((Date.now() - Date.parse(at)) / 6e4);
|
|
928
|
+
if (!(minutes >= 1)) return "now";
|
|
929
|
+
if (minutes < 60) return `${minutes}m`;
|
|
930
|
+
return minutes < 1440 ? `${Math.round(minutes / 60)}h` : `${Math.round(minutes / 1440)}d`;
|
|
931
|
+
}
|
|
932
|
+
/** What's typed in each task's reply, by its ID. */
|
|
933
|
+
function drafts() {
|
|
934
|
+
try {
|
|
935
|
+
const kept = JSON.parse(sessionStorage.getItem(DRAFTS) ?? "{}");
|
|
936
|
+
return typeof kept === "object" && kept !== null ? kept : {};
|
|
937
|
+
} catch {
|
|
938
|
+
return {};
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
function keepDraft(id, text) {
|
|
942
|
+
const { [id]: _, ...rest } = drafts();
|
|
943
|
+
try {
|
|
944
|
+
sessionStorage.setItem(DRAFTS, JSON.stringify(text.trim() === "" ? rest : {
|
|
945
|
+
...rest,
|
|
946
|
+
[id]: text
|
|
947
|
+
}));
|
|
948
|
+
} catch {}
|
|
949
|
+
}
|
|
950
|
+
/** A board's file as a person names it: what it is, not what deictic called it. */
|
|
951
|
+
function nameOf(file, i, all) {
|
|
952
|
+
const alike = all.filter((other) => kindOf(other) === kindOf(file));
|
|
953
|
+
const n = alike.length === 1 ? "" : ` ${alike.indexOf(file) + 1}`;
|
|
954
|
+
const kind = kindOf(file);
|
|
955
|
+
if (kind === "image") return `Screenshot${n}`;
|
|
956
|
+
if (kind === "recording") return `Recording${n}`;
|
|
957
|
+
if (kind === "audio") return `Voice note${n}`;
|
|
958
|
+
if (/^element(\.\d+)?\.html$/.test(file.name)) return `HTML${n}`;
|
|
959
|
+
return file.name || `File ${i + 1}`;
|
|
960
|
+
}
|
|
961
|
+
const kindOf = ({ type, name }) => type.startsWith("image/") ? "image" : name.startsWith("recording-") ? "recording" : type.startsWith("audio/") ? "audio" : "file";
|
|
962
|
+
const made$1 = /* @__PURE__ */ new WeakMap();
|
|
963
|
+
/** The tasks' section in the drawer of the overlay `context` is of: added the first time it's asked for. */
|
|
964
|
+
function drawerOf(context) {
|
|
965
|
+
const known = made$1.get(context.root);
|
|
966
|
+
if (known !== void 0) return known;
|
|
967
|
+
const store = storeOf(context);
|
|
968
|
+
const section = element("section", {
|
|
969
|
+
className: "tasks-drawer",
|
|
970
|
+
hidden: true
|
|
971
|
+
});
|
|
972
|
+
const heading = element("h3");
|
|
973
|
+
const rows = element("div", { className: "drawer-rows" });
|
|
974
|
+
const finished = element("details");
|
|
975
|
+
const finishedCount = element("summary");
|
|
976
|
+
const finishedRows = element("div", { className: "drawer-rows" });
|
|
977
|
+
const putAway = element("button", {
|
|
978
|
+
type: "button",
|
|
979
|
+
className: "act put-away",
|
|
980
|
+
textContent: "Archive all",
|
|
981
|
+
title: "Put the finished tasks away: one comes back when something happens to it"
|
|
982
|
+
});
|
|
983
|
+
putAway.addEventListener("click", () => store.archive(store.tasks().filter((task) => OVER.has(task.state))));
|
|
984
|
+
finishedRows.append(putAway);
|
|
985
|
+
finished.append(finishedCount, finishedRows);
|
|
986
|
+
section.append(element("style", { textContent: STYLE$2 }), heading, rows, finished);
|
|
987
|
+
const elementOf = (task) => task.place === void 0 ? null : document.querySelector(`[${ATTRIBUTE}="${CSS.escape(task.place)}"]`);
|
|
988
|
+
/** What a task is about, as the caption says an element: by its component where the page has it, else its tag. */
|
|
989
|
+
const about = (task) => {
|
|
990
|
+
if (task.place === void 0) return "the page";
|
|
991
|
+
const el = elementOf(task);
|
|
992
|
+
if (el !== null) return tell(named(el));
|
|
993
|
+
const on = task.page === void 0 || task.page === location.pathname ? "" : ` on ${task.page}`;
|
|
994
|
+
return `${task.tag === void 0 ? "an element" : `<${task.tag}>`}${on}`;
|
|
995
|
+
};
|
|
996
|
+
/** Lights a task's element on the page while the pointer is on what stands for it here. */
|
|
997
|
+
const lights = (on, task) => {
|
|
998
|
+
on.addEventListener("pointerenter", () => context.light(elementOf(task()) ?? void 0));
|
|
999
|
+
on.addEventListener("pointerleave", () => context.light());
|
|
1000
|
+
};
|
|
1001
|
+
const rowOf = (task) => {
|
|
1002
|
+
const row = element("button", {
|
|
1003
|
+
type: "button",
|
|
1004
|
+
className: `task-row${store.unread(task) ? " unread" : ""}`
|
|
1005
|
+
});
|
|
1006
|
+
const says = task.by === void 0 ? task.state : `${task.state} by ${task.by}`;
|
|
1007
|
+
const replies = task.replies === 0 ? "" : ` · ${task.replies} ${task.replies === 1 ? "reply" : "replies"}`;
|
|
1008
|
+
row.append(element("span", {
|
|
1009
|
+
className: `task-state ${task.state}`,
|
|
1010
|
+
ariaHidden: "true"
|
|
1011
|
+
}), element("span", {
|
|
1012
|
+
className: "title",
|
|
1013
|
+
textContent: task.title
|
|
1014
|
+
}), element("span", {
|
|
1015
|
+
className: "meta",
|
|
1016
|
+
textContent: `${says} · ${about(task)}${replies}`
|
|
1017
|
+
}), element("span", {
|
|
1018
|
+
className: "mark",
|
|
1019
|
+
...store.unread(task) ? { title: "Unread" } : {}
|
|
1020
|
+
}));
|
|
1021
|
+
lights(row, () => task);
|
|
1022
|
+
row.addEventListener("click", () => {
|
|
1023
|
+
context.light();
|
|
1024
|
+
view(task);
|
|
1025
|
+
});
|
|
1026
|
+
return row;
|
|
1027
|
+
};
|
|
1028
|
+
const draw = () => {
|
|
1029
|
+
const tasks = store.tasks().filter((task) => !store.archived(task));
|
|
1030
|
+
const live = tasks.filter((task) => !OVER.has(task.state));
|
|
1031
|
+
const ended = tasks.filter((task) => OVER.has(task.state));
|
|
1032
|
+
section.hidden = tasks.length === 0;
|
|
1033
|
+
const unread = tasks.filter(store.unread).length;
|
|
1034
|
+
section.dataset.count = String(live.length);
|
|
1035
|
+
section.dataset.unread = String(unread);
|
|
1036
|
+
const channel = store.channel();
|
|
1037
|
+
heading.replaceChildren("Tasks", ...unread === 0 ? [] : [element("span", {
|
|
1038
|
+
className: "unread",
|
|
1039
|
+
textContent: String(unread),
|
|
1040
|
+
title: `${unread} unread`
|
|
1041
|
+
})], ...channel?.link === void 0 ? [] : [element("a", {
|
|
1042
|
+
href: channel.link,
|
|
1043
|
+
target: "_blank",
|
|
1044
|
+
rel: "noreferrer",
|
|
1045
|
+
textContent: `#${channel.name}`,
|
|
1046
|
+
title: "Open the channel on the board"
|
|
1047
|
+
})]);
|
|
1048
|
+
rows.replaceChildren(...live.map(rowOf));
|
|
1049
|
+
finished.hidden = ended.length === 0;
|
|
1050
|
+
const news = ended.filter(store.unread).length;
|
|
1051
|
+
finishedCount.textContent = `${ended.length} finished${news === 0 ? "" : `, ${news} unread`}`;
|
|
1052
|
+
finishedRows.replaceChildren(...ended.map(rowOf), putAway);
|
|
1053
|
+
};
|
|
1054
|
+
store.subscribe(draw);
|
|
1055
|
+
context.drawer.add(section, { first: true });
|
|
1056
|
+
const ask = async (route, body) => {
|
|
1057
|
+
const res = await context.request(route, body === void 0 ? void 0 : {
|
|
1058
|
+
method: "POST",
|
|
1059
|
+
headers: { "content-type": "application/json" },
|
|
1060
|
+
body: JSON.stringify(body)
|
|
1061
|
+
});
|
|
1062
|
+
const answer = await res.json();
|
|
1063
|
+
if (!res.ok) throw new Error(answer.problem ?? `the dev server answered ${res.status}`);
|
|
1064
|
+
return answer;
|
|
1065
|
+
};
|
|
1066
|
+
/** A message's files as chips, each opening them all in the lightbox at itself. */
|
|
1067
|
+
const filesOf = (task, files) => {
|
|
1068
|
+
const list = element("div", { className: "task-files" });
|
|
1069
|
+
const urlOf = (file) => file.url ?? `${context.base}__deictic/plugins/tasks/file/${encodeURIComponent(task)}/${encodeURIComponent(file.id)}`;
|
|
1070
|
+
const items = files.map((file, i) => {
|
|
1071
|
+
const title = nameOf(file, i, files);
|
|
1072
|
+
const kind = kindOf(file);
|
|
1073
|
+
if (kind === "image") return {
|
|
1074
|
+
kind: "image",
|
|
1075
|
+
url: urlOf(file),
|
|
1076
|
+
title
|
|
1077
|
+
};
|
|
1078
|
+
if (kind === "audio") return {
|
|
1079
|
+
kind: "audio",
|
|
1080
|
+
url: urlOf(file),
|
|
1081
|
+
title
|
|
1082
|
+
};
|
|
1083
|
+
const replay = kind === "recording" ? file.replay : void 0;
|
|
1084
|
+
const url = replay === void 0 ? urlOf(file) : `${replay}${replay.includes("?") ? "&" : "?"}embed`;
|
|
1085
|
+
const open = replay ?? urlOf(file);
|
|
1086
|
+
return {
|
|
1087
|
+
kind: "page",
|
|
1088
|
+
url,
|
|
1089
|
+
title,
|
|
1090
|
+
actions: [{
|
|
1091
|
+
label: "New tab",
|
|
1092
|
+
title: "Open it in a tab of its own",
|
|
1093
|
+
run: () => void window.open(open, "_blank", "noopener")
|
|
1094
|
+
}]
|
|
1095
|
+
};
|
|
1096
|
+
});
|
|
1097
|
+
list.append(...files.map((file, i) => {
|
|
1098
|
+
const name = nameOf(file, i, files);
|
|
1099
|
+
const chip = element("button", {
|
|
1100
|
+
type: "button",
|
|
1101
|
+
title: `Open ${/^[A-Z]{2}/.test(name) ? name : `${name[0].toLowerCase()}${name.slice(1)}`}`
|
|
1102
|
+
});
|
|
1103
|
+
const kind = kindOf(file);
|
|
1104
|
+
const icon = kind === "image" ? element("img", {
|
|
1105
|
+
src: urlOf(file),
|
|
1106
|
+
alt: "",
|
|
1107
|
+
loading: "lazy"
|
|
1108
|
+
}) : element("span", {
|
|
1109
|
+
className: "play",
|
|
1110
|
+
innerHTML: kind === "file" ? FILE : PLAY
|
|
1111
|
+
});
|
|
1112
|
+
chip.append(icon, element("span", { textContent: name }));
|
|
1113
|
+
chip.addEventListener("click", () => context.lightbox(items, {
|
|
1114
|
+
at: i,
|
|
1115
|
+
from: chip
|
|
1116
|
+
}));
|
|
1117
|
+
return chip;
|
|
1118
|
+
}));
|
|
1119
|
+
return list;
|
|
1120
|
+
};
|
|
1121
|
+
/** A task, open in the drawer: its words, what's attached, its thread, and what changes them. */
|
|
1122
|
+
function view(first) {
|
|
1123
|
+
let task = first;
|
|
1124
|
+
let editing = false;
|
|
1125
|
+
const readTo = store.read(first);
|
|
1126
|
+
const fresh = store.unread(first);
|
|
1127
|
+
const mine = /* @__PURE__ */ new Set();
|
|
1128
|
+
const recorder = context.use("recordings");
|
|
1129
|
+
const el = element("div", { className: "task-view" });
|
|
1130
|
+
const stands = element("div", { className: "stands" });
|
|
1131
|
+
const where = element("button", {
|
|
1132
|
+
type: "button",
|
|
1133
|
+
className: "where"
|
|
1134
|
+
});
|
|
1135
|
+
const words = element("div");
|
|
1136
|
+
const files = element("div");
|
|
1137
|
+
const said = element("div", { className: "said" });
|
|
1138
|
+
const thread = element("ol", { className: "task-thread" });
|
|
1139
|
+
const problem = element("div", { className: "problem" });
|
|
1140
|
+
lights(where, () => task);
|
|
1141
|
+
const composer = composerIn(context, {
|
|
1142
|
+
placeholder: "Reply…",
|
|
1143
|
+
sendLabel: "Reply",
|
|
1144
|
+
over: true,
|
|
1145
|
+
record: () => {
|
|
1146
|
+
if (recorder === void 0) return;
|
|
1147
|
+
if (recorder.recording()) {
|
|
1148
|
+
composer.problem.textContent = "A recording is going already: stop it in the tool panel, and it's attached here";
|
|
1149
|
+
return;
|
|
1150
|
+
}
|
|
1151
|
+
close();
|
|
1152
|
+
recorder.record();
|
|
1153
|
+
},
|
|
1154
|
+
submit: async (gathered) => {
|
|
1155
|
+
const answer = {
|
|
1156
|
+
text: gathered.text,
|
|
1157
|
+
...attachedOf(gathered)
|
|
1158
|
+
};
|
|
1159
|
+
const after = await ask(`reply/${encodeURIComponent(task.id)}`, answer);
|
|
1160
|
+
const last = after.replies.at(-1);
|
|
1161
|
+
if (last !== void 0) mine.add(last.id);
|
|
1162
|
+
shown(after);
|
|
1163
|
+
keepDraft(task.id, "");
|
|
1164
|
+
store.load(true);
|
|
1165
|
+
return true;
|
|
1166
|
+
}
|
|
1167
|
+
});
|
|
1168
|
+
composer.restore({ text: drafts()[first.id] ?? "" });
|
|
1169
|
+
el.append(stands, where, words, files, said, thread, composer.el, problem);
|
|
1170
|
+
const outline = element("div", {
|
|
1171
|
+
className: "task-about",
|
|
1172
|
+
hidden: true
|
|
1173
|
+
});
|
|
1174
|
+
context.root.append(outline);
|
|
1175
|
+
let following = requestAnimationFrame(function follow() {
|
|
1176
|
+
following = requestAnimationFrame(follow);
|
|
1177
|
+
const it = elementOf(task);
|
|
1178
|
+
outline.hidden = it === null;
|
|
1179
|
+
if (it !== null) place(outline, it.getBoundingClientRect());
|
|
1180
|
+
});
|
|
1181
|
+
where.addEventListener("click", () => elementOf(task)?.scrollIntoView({
|
|
1182
|
+
block: "center",
|
|
1183
|
+
behavior: "smooth"
|
|
1184
|
+
}));
|
|
1185
|
+
const failed = (e) => problem.textContent = messageOf(e);
|
|
1186
|
+
let removing;
|
|
1187
|
+
const drawTask = () => {
|
|
1188
|
+
const state = element("span", {
|
|
1189
|
+
className: `task-state ${task.state}`,
|
|
1190
|
+
ariaHidden: "true"
|
|
1191
|
+
});
|
|
1192
|
+
const says = element("span", {
|
|
1193
|
+
className: "says",
|
|
1194
|
+
textContent: task.by === void 0 ? task.state : `${task.state} by ${task.by}`
|
|
1195
|
+
});
|
|
1196
|
+
const to = task.link === void 0 ? [] : [element("a", {
|
|
1197
|
+
href: task.link,
|
|
1198
|
+
target: "_blank",
|
|
1199
|
+
rel: "noreferrer",
|
|
1200
|
+
textContent: "on the board",
|
|
1201
|
+
title: "Open the task on the board"
|
|
1202
|
+
})];
|
|
1203
|
+
const edit = element("button", {
|
|
1204
|
+
type: "button",
|
|
1205
|
+
className: "act",
|
|
1206
|
+
textContent: "Edit",
|
|
1207
|
+
title: "Change its words"
|
|
1208
|
+
});
|
|
1209
|
+
edit.addEventListener("click", () => {
|
|
1210
|
+
editing = true;
|
|
1211
|
+
drawWords();
|
|
1212
|
+
});
|
|
1213
|
+
const remove = element("button", {
|
|
1214
|
+
type: "button",
|
|
1215
|
+
className: "act",
|
|
1216
|
+
textContent: "Delete",
|
|
1217
|
+
title: "Cancel it on the board"
|
|
1218
|
+
});
|
|
1219
|
+
remove.addEventListener("click", () => {
|
|
1220
|
+
if (!remove.classList.contains("sure")) {
|
|
1221
|
+
remove.classList.add("sure");
|
|
1222
|
+
remove.textContent = "Delete?";
|
|
1223
|
+
removing = setTimeout(() => {
|
|
1224
|
+
remove.classList.remove("sure");
|
|
1225
|
+
remove.textContent = "Delete";
|
|
1226
|
+
}, SURE);
|
|
1227
|
+
return;
|
|
1228
|
+
}
|
|
1229
|
+
remove.disabled = true;
|
|
1230
|
+
ask(`remove/${encodeURIComponent(task.id)}`, {}).then(() => {
|
|
1231
|
+
store.load(true);
|
|
1232
|
+
close();
|
|
1233
|
+
}, failed);
|
|
1234
|
+
});
|
|
1235
|
+
const archive = element("button", {
|
|
1236
|
+
type: "button",
|
|
1237
|
+
className: "act",
|
|
1238
|
+
textContent: "Archive",
|
|
1239
|
+
title: "Put it away: it comes back when something happens to it"
|
|
1240
|
+
});
|
|
1241
|
+
archive.addEventListener("click", () => {
|
|
1242
|
+
store.archive([task]);
|
|
1243
|
+
close();
|
|
1244
|
+
});
|
|
1245
|
+
stands.replaceChildren(state, says, ...to, ...task.open ? [edit, remove] : [], ...OVER.has(task.state) ? [archive] : []);
|
|
1246
|
+
const at = task.place?.replace(/:\d+$/, "");
|
|
1247
|
+
where.replaceChildren(about(task), ...at === void 0 ? [] : [element("span", { textContent: ` ${at}` })]);
|
|
1248
|
+
where.disabled = elementOf(task) === null;
|
|
1249
|
+
where.title = task.place === void 0 ? "No element was attached" : where.disabled ? "Not on this page now" : "Show it on the page";
|
|
1250
|
+
said.hidden = task.said === void 0;
|
|
1251
|
+
said.textContent = task.said ?? "";
|
|
1252
|
+
};
|
|
1253
|
+
const drawWords = () => {
|
|
1254
|
+
if (!editing) {
|
|
1255
|
+
words.className = "words";
|
|
1256
|
+
words.replaceChildren(task.text);
|
|
1257
|
+
return;
|
|
1258
|
+
}
|
|
1259
|
+
const text = element("textarea", { value: task.text });
|
|
1260
|
+
const save = element("button", {
|
|
1261
|
+
type: "button",
|
|
1262
|
+
className: "primary",
|
|
1263
|
+
textContent: "Save"
|
|
1264
|
+
});
|
|
1265
|
+
const leave = element("button", {
|
|
1266
|
+
type: "button",
|
|
1267
|
+
textContent: "Cancel"
|
|
1268
|
+
});
|
|
1269
|
+
const buttons = element("div", { className: "buttons" });
|
|
1270
|
+
buttons.append(leave, save);
|
|
1271
|
+
const done = () => {
|
|
1272
|
+
editing = false;
|
|
1273
|
+
drawWords();
|
|
1274
|
+
};
|
|
1275
|
+
const keep = () => {
|
|
1276
|
+
if (text.value.trim() === "") return;
|
|
1277
|
+
if (text.value.trim() === task.text) return done();
|
|
1278
|
+
save.disabled = true;
|
|
1279
|
+
ask(`edit/${encodeURIComponent(task.id)}`, { text: text.value }).then((answer) => {
|
|
1280
|
+
editing = false;
|
|
1281
|
+
shown(answer);
|
|
1282
|
+
store.load(true);
|
|
1283
|
+
}, (e) => {
|
|
1284
|
+
save.disabled = false;
|
|
1285
|
+
failed(e);
|
|
1286
|
+
});
|
|
1287
|
+
};
|
|
1288
|
+
text.addEventListener("keydown", (e) => {
|
|
1289
|
+
if (e.key === "Escape") {
|
|
1290
|
+
e.stopPropagation();
|
|
1291
|
+
done();
|
|
1292
|
+
}
|
|
1293
|
+
if (e.key !== "Enter" || e.shiftKey || e.isComposing) return;
|
|
1294
|
+
e.preventDefault();
|
|
1295
|
+
keep();
|
|
1296
|
+
});
|
|
1297
|
+
save.addEventListener("click", keep);
|
|
1298
|
+
leave.addEventListener("click", done);
|
|
1299
|
+
words.className = "editing";
|
|
1300
|
+
words.replaceChildren(text, buttons);
|
|
1301
|
+
text.focus();
|
|
1302
|
+
};
|
|
1303
|
+
let drawn = "";
|
|
1304
|
+
/** The task and its thread as just read: drawn, and read by whoever is looking. */
|
|
1305
|
+
const shown = (answer) => {
|
|
1306
|
+
task = answer.task;
|
|
1307
|
+
problem.textContent = "";
|
|
1308
|
+
drawTask();
|
|
1309
|
+
if (!editing) drawWords();
|
|
1310
|
+
const now = JSON.stringify([
|
|
1311
|
+
answer.files.map((f) => f.id),
|
|
1312
|
+
answer.replies.map((r) => [
|
|
1313
|
+
r.id,
|
|
1314
|
+
r.text,
|
|
1315
|
+
r.files.length
|
|
1316
|
+
]),
|
|
1317
|
+
[...mine]
|
|
1318
|
+
]);
|
|
1319
|
+
if (now !== drawn) {
|
|
1320
|
+
drawn = now;
|
|
1321
|
+
files.replaceChildren(filesOf(task.id, answer.files));
|
|
1322
|
+
const from = readTo === void 0 ? -1 : answer.replies.findIndex((r) => r.id === readTo);
|
|
1323
|
+
const grew = answer.replies.length !== thread.childElementCount;
|
|
1324
|
+
thread.replaceChildren(...answer.replies.map((r, i) => {
|
|
1325
|
+
const item = element("li", { className: fresh && i > from && !mine.has(r.id) ? "new" : "" });
|
|
1326
|
+
const by = element("div", { className: "by" });
|
|
1327
|
+
by.append(element("b", { textContent: r.by }), ...r.kind === "person" ? [] : ["agent"], element("i", {
|
|
1328
|
+
textContent: ago(r.at),
|
|
1329
|
+
title: new Date(r.at).toLocaleString()
|
|
1330
|
+
}));
|
|
1331
|
+
item.append(by, element("div", {
|
|
1332
|
+
className: "text",
|
|
1333
|
+
textContent: r.text
|
|
1334
|
+
}), filesOf(task.id, r.files));
|
|
1335
|
+
return item;
|
|
1336
|
+
}));
|
|
1337
|
+
if (grew) thread.lastElementChild?.scrollIntoView({ block: "nearest" });
|
|
1338
|
+
}
|
|
1339
|
+
store.seen(task);
|
|
1340
|
+
};
|
|
1341
|
+
const load = () => ask(`thread/${encodeURIComponent(task.id)}`).then(shown, failed);
|
|
1342
|
+
drawTask();
|
|
1343
|
+
drawWords();
|
|
1344
|
+
load();
|
|
1345
|
+
const again = setInterval(() => void load(), AGAIN);
|
|
1346
|
+
const close = context.drawer.show(el, {
|
|
1347
|
+
title: `#${task.id}`,
|
|
1348
|
+
closed: () => {
|
|
1349
|
+
keepDraft(task.id, composer.draft().text);
|
|
1350
|
+
composer.destroy();
|
|
1351
|
+
context.light();
|
|
1352
|
+
clearInterval(again);
|
|
1353
|
+
clearTimeout(removing);
|
|
1354
|
+
cancelAnimationFrame(following);
|
|
1355
|
+
outline.remove();
|
|
1356
|
+
}
|
|
1357
|
+
});
|
|
1358
|
+
}
|
|
1359
|
+
/** Several tasks of one place, to pick from. */
|
|
1360
|
+
const pick = (tasks) => {
|
|
1361
|
+
const el = element("div", { className: "drawer-rows" });
|
|
1362
|
+
el.append(...tasks.map(rowOf));
|
|
1363
|
+
context.drawer.show(el, {
|
|
1364
|
+
title: `${tasks.length} tasks on ${about(tasks[0])}`,
|
|
1365
|
+
closed: () => context.light()
|
|
1366
|
+
});
|
|
1367
|
+
};
|
|
1368
|
+
const drawer = { open: (tasks) => {
|
|
1369
|
+
if (tasks.length === 1) view(tasks[0]);
|
|
1370
|
+
else if (tasks.length > 1) pick(tasks);
|
|
1371
|
+
} };
|
|
1372
|
+
made$1.set(context.root, drawer);
|
|
1373
|
+
return drawer;
|
|
1374
|
+
}
|
|
1375
|
+
// src/plugins/tasks/pins.ts
|
|
1376
|
+
/**
|
|
1377
|
+
* The page's tasks, each pinned where its element is: what's shown of them on the page itself, beside the Task
|
|
1378
|
+
* tab's list of one element's. A pin is the element's outline, faint, and a badge on its corner with how many
|
|
1379
|
+
* tasks are still to do there, in the colour of the furthest along, and a dot where one has something unread. They
|
|
1380
|
+
* show while a shortcut's keys are held and while the Task tab is open: a pin under the pointer reads its tasks, and
|
|
1381
|
+
* a click opens them in the drawer.
|
|
1382
|
+
*
|
|
1383
|
+
* In a layer of the overlay's root, which the tab's own styles don't reach once it's closed: so its styles are its own.
|
|
1384
|
+
*/
|
|
1385
|
+
const STYLE$1 = `
|
|
1386
|
+
/* No box of its own, which its pins would stack in: each is under the popup, and the one pointed at over it, with its card. */
|
|
1387
|
+
.pins { display: contents; font: 12px/1.4 system-ui, sans-serif; color: var(--deictic-fg); }
|
|
1388
|
+
.pin { --pin: var(--deictic-accent); position: fixed; z-index: 2147483646; box-sizing: border-box; pointer-events: none; border: 1px solid color-mix(in srgb, var(--pin) 45%, transparent); border-radius: 6px; transition: border-color 0.15s, box-shadow 0.15s; }
|
|
1389
|
+
.pin.claimed { --pin: #60a5fa; }
|
|
1390
|
+
.pin.blocked { --pin: #fbbf24; }
|
|
1391
|
+
.pin[hidden] { display: none; }
|
|
1392
|
+
.pin.spot, .pin.spot:has(.pin-badge:hover, .pin-badge:focus-visible) { border: 0; box-shadow: none; }
|
|
1393
|
+
.pin:has(.pin-badge:hover, .pin-badge:focus-visible) { z-index: 2147483647; border-color: var(--pin); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pin) 18%, transparent), 0 0 28px color-mix(in srgb, var(--pin) 45%, transparent); }
|
|
1394
|
+
/* A drop, its point on the element's corner. */
|
|
1395
|
+
.pin-badge {
|
|
1396
|
+
position: absolute;
|
|
1397
|
+
display: flex;
|
|
1398
|
+
align-items: center;
|
|
1399
|
+
justify-content: center;
|
|
1400
|
+
box-sizing: border-box;
|
|
1401
|
+
min-width: 22px;
|
|
1402
|
+
height: 22px;
|
|
1403
|
+
padding: 0 6px;
|
|
1404
|
+
border: 0;
|
|
1405
|
+
border-radius: 11px 11px 11px 3px;
|
|
1406
|
+
font: 700 12px/22px system-ui, sans-serif;
|
|
1407
|
+
font-variant-numeric: tabular-nums;
|
|
1408
|
+
color: #09090b;
|
|
1409
|
+
background: var(--pin);
|
|
1410
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--pin) 22%, transparent), 0 0 18px color-mix(in srgb, var(--pin) 60%, transparent), 0 4px 12px rgb(0 0 0 / 0.4);
|
|
1411
|
+
pointer-events: auto;
|
|
1412
|
+
cursor: pointer;
|
|
1413
|
+
}
|
|
1414
|
+
.pin-badge:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
|
|
1415
|
+
/* Something unread there: a dot on the badge's corner. */
|
|
1416
|
+
.pin.unread .pin-badge::after { content: ''; position: absolute; top: -3px; right: -3px; width: 8px; height: 8px; border: 2px solid #09090b; border-radius: 50%; background: #fff; }
|
|
1417
|
+
.pin-card {
|
|
1418
|
+
position: absolute;
|
|
1419
|
+
left: 0;
|
|
1420
|
+
top: calc(100% + 8px);
|
|
1421
|
+
display: none;
|
|
1422
|
+
flex-direction: column;
|
|
1423
|
+
gap: 4px;
|
|
1424
|
+
width: max-content;
|
|
1425
|
+
max-width: 300px;
|
|
1426
|
+
padding: 8px 10px;
|
|
1427
|
+
border: 1px solid rgb(255 255 255 / 0.12);
|
|
1428
|
+
border-radius: 10px;
|
|
1429
|
+
font: 12px/1.4 system-ui, sans-serif;
|
|
1430
|
+
text-align: left;
|
|
1431
|
+
color: var(--deictic-fg);
|
|
1432
|
+
background: rgb(24 24 27 / 0.9);
|
|
1433
|
+
backdrop-filter: blur(16px) saturate(1.6);
|
|
1434
|
+
box-shadow: 0 12px 32px rgb(0 0 0 / 0.45);
|
|
1435
|
+
cursor: pointer;
|
|
1436
|
+
}
|
|
1437
|
+
.pin.left .pin-card { left: auto; right: 0; }
|
|
1438
|
+
.pin.up .pin-card { top: auto; bottom: calc(100% + 8px); }
|
|
1439
|
+
.pin-badge:hover .pin-card, .pin-badge:focus-visible .pin-card { display: flex; }
|
|
1440
|
+
.pin-where { font: 11px ui-monospace, monospace; color: var(--deictic-muted); }
|
|
1441
|
+
.pin-where b { color: var(--pin); }
|
|
1442
|
+
.pin-task { display: flex; gap: 6px; align-items: baseline; min-width: 0; }
|
|
1443
|
+
.pin-task span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1444
|
+
.pin-task i { flex: none; align-self: center; box-sizing: border-box; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--deictic-muted); }
|
|
1445
|
+
.pin-task i.claimed { border-color: #60a5fa; background: #60a5fa; }
|
|
1446
|
+
.pin-task i.blocked { border-color: #fbbf24; background: #fbbf24; }
|
|
1447
|
+
.pin-task i.waiting { border-style: dotted; }
|
|
1448
|
+
.pin-task em { flex: none; font-style: normal; color: var(--deictic-muted); }
|
|
1449
|
+
.pin-more { color: var(--deictic-muted); }
|
|
1450
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
1451
|
+
.pin { animation: deictic-pin-area 0.3s ease-out backwards; }
|
|
1452
|
+
.pin-badge { animation: deictic-pin 0.34s cubic-bezier(0.2, 0.9, 0.25, 1.4) backwards; animation-delay: inherit; transform-origin: 0 100%; }
|
|
1453
|
+
}
|
|
1454
|
+
@keyframes deictic-pin-area {
|
|
1455
|
+
from { opacity: 0; }
|
|
1456
|
+
}
|
|
1457
|
+
@keyframes deictic-pin {
|
|
1458
|
+
from { opacity: 0; scale: 0.2; }
|
|
1459
|
+
}
|
|
1460
|
+
`;
|
|
1461
|
+
/** How long the pins outlast what showed them, in ms: the popup opens a moment after the pointing that led to it ends. */
|
|
1462
|
+
const LINGER = 200;
|
|
1463
|
+
/** A badge's size, and how far out of the element's corner it sits, in pixels. */
|
|
1464
|
+
const BADGE = 22;
|
|
1465
|
+
const OUT = 10;
|
|
1466
|
+
const EDGE = 4;
|
|
1467
|
+
/** The tasks a pin's card names, before it only counts them. */
|
|
1468
|
+
const NAMED = 4;
|
|
1469
|
+
/** The states by how far along, the furthest first: a pin is the colour of its furthest. */
|
|
1470
|
+
const ALONG = [
|
|
1471
|
+
"blocked",
|
|
1472
|
+
"claimed",
|
|
1473
|
+
"ready",
|
|
1474
|
+
"waiting"
|
|
1475
|
+
];
|
|
1476
|
+
const made = /* @__PURE__ */ new WeakMap();
|
|
1477
|
+
/** The pins of the overlay `context` is of: one set, whoever shows it. */
|
|
1478
|
+
function pinsIn(context) {
|
|
1479
|
+
const kept = made.get(context.root);
|
|
1480
|
+
if (kept !== void 0) return kept;
|
|
1481
|
+
const store = storeOf(context);
|
|
1482
|
+
let glances = 0;
|
|
1483
|
+
let layer;
|
|
1484
|
+
let frame = 0;
|
|
1485
|
+
let leaving;
|
|
1486
|
+
const pins = /* @__PURE__ */ new Map();
|
|
1487
|
+
let frames = 0;
|
|
1488
|
+
const elementAt = (at) => document.querySelector(`[data-deictic="${CSS.escape(at)}"]`);
|
|
1489
|
+
const pinOf = (at, el, spot) => {
|
|
1490
|
+
const box = div("pin");
|
|
1491
|
+
const badge = Object.assign(document.createElement("button"), {
|
|
1492
|
+
type: "button",
|
|
1493
|
+
className: "pin-badge"
|
|
1494
|
+
});
|
|
1495
|
+
const count = document.createElement("span");
|
|
1496
|
+
const card = Object.assign(document.createElement("span"), { className: "pin-card" });
|
|
1497
|
+
badge.append(count, card);
|
|
1498
|
+
box.append(badge);
|
|
1499
|
+
if (!reduced()) box.style.animationDelay = `${Math.min(pins.size, 12) * 30}ms`;
|
|
1500
|
+
const pin = {
|
|
1501
|
+
place: at,
|
|
1502
|
+
...spot === void 0 ? {} : { at: spot },
|
|
1503
|
+
el,
|
|
1504
|
+
box,
|
|
1505
|
+
badge,
|
|
1506
|
+
count,
|
|
1507
|
+
card,
|
|
1508
|
+
tasks: []
|
|
1509
|
+
};
|
|
1510
|
+
badge.addEventListener("click", () => drawerOf(context).open(pin.tasks));
|
|
1511
|
+
return pin;
|
|
1512
|
+
};
|
|
1513
|
+
/** A pin as its tasks are now: how many, the colour of the furthest along, and its card. */
|
|
1514
|
+
const fill = (pin, list) => {
|
|
1515
|
+
const state = ALONG.find((s) => list.some((t) => t.state === s)) ?? "ready";
|
|
1516
|
+
pin.tasks = list;
|
|
1517
|
+
pin.box.className = `pin ${state}${pin.at === void 0 ? "" : " spot"}${list.some(store.unread) ? " unread" : ""}`;
|
|
1518
|
+
pin.count.textContent = String(list.length);
|
|
1519
|
+
const [, file = "", line = ""] = /^(.*):(\d+):\d+$/.exec(pin.place) ?? [];
|
|
1520
|
+
const tag = tell(named(pin.el));
|
|
1521
|
+
pin.badge.setAttribute("aria-label", `${list.length} ${list.length === 1 ? "task" : "tasks"} on ${tag}, line ${line}: open`);
|
|
1522
|
+
const where = Object.assign(document.createElement("span"), { className: "pin-where" });
|
|
1523
|
+
where.append(Object.assign(document.createElement("b"), { textContent: tag }), ` ${file.split("/").at(-1)}:${line}`);
|
|
1524
|
+
const rows = list.slice(0, NAMED).map((t) => {
|
|
1525
|
+
const row = Object.assign(document.createElement("span"), { className: "pin-task" });
|
|
1526
|
+
const dot = Object.assign(document.createElement("i"), { className: t.state });
|
|
1527
|
+
const by = t.by === void 0 ? [] : [Object.assign(document.createElement("em"), { textContent: t.by })];
|
|
1528
|
+
row.append(dot, Object.assign(document.createElement("span"), { textContent: t.title }), ...by);
|
|
1529
|
+
return row;
|
|
1530
|
+
});
|
|
1531
|
+
const rest = list.length - rows.length;
|
|
1532
|
+
const more = rest === 0 ? [] : [Object.assign(document.createElement("span"), {
|
|
1533
|
+
className: "pin-more",
|
|
1534
|
+
textContent: `+${rest} more`
|
|
1535
|
+
})];
|
|
1536
|
+
pin.card.replaceChildren(where, ...rows, ...more);
|
|
1537
|
+
};
|
|
1538
|
+
/** The pins as the tasks read last have them: one per place with an element on the page, for those still to do. */
|
|
1539
|
+
const draw = () => {
|
|
1540
|
+
if (layer === void 0) return;
|
|
1541
|
+
const tasks = store.tasks().filter((t) => t.place !== void 0 && !OVER.has(t.state));
|
|
1542
|
+
const keyOf = (t) => t.point === void 0 ? t.place : `${t.place}@${t.point.x},${t.point.y}`;
|
|
1543
|
+
const byPlace = /* @__PURE__ */ new Map();
|
|
1544
|
+
for (const t of tasks) byPlace.set(keyOf(t), [...byPlace.get(keyOf(t)) ?? [], t]);
|
|
1545
|
+
for (const [at, pin] of pins) {
|
|
1546
|
+
if (byPlace.has(at)) continue;
|
|
1547
|
+
pin.box.remove();
|
|
1548
|
+
pins.delete(at);
|
|
1549
|
+
}
|
|
1550
|
+
for (const [at, list] of byPlace) {
|
|
1551
|
+
let pin = pins.get(at);
|
|
1552
|
+
if (pin === void 0) {
|
|
1553
|
+
const [{ place: where, point }] = list;
|
|
1554
|
+
const el = elementAt(where);
|
|
1555
|
+
if (el === null) continue;
|
|
1556
|
+
pin = pinOf(where, el, point);
|
|
1557
|
+
pins.set(at, pin);
|
|
1558
|
+
layer.append(pin.box);
|
|
1559
|
+
}
|
|
1560
|
+
fill(pin, list);
|
|
1561
|
+
}
|
|
1562
|
+
follow();
|
|
1563
|
+
};
|
|
1564
|
+
/** Each pin over its element as the page has it now: read each frame, as nothing tells of an element moving. */
|
|
1565
|
+
const follow = () => {
|
|
1566
|
+
const width = document.documentElement.clientWidth;
|
|
1567
|
+
const height = document.documentElement.clientHeight;
|
|
1568
|
+
const look = frames++ % 20 === 0;
|
|
1569
|
+
for (const pin of pins.values()) {
|
|
1570
|
+
if (!pin.el.isConnected && look) pin.el = elementAt(pin.place) ?? pin.el;
|
|
1571
|
+
const whole = pin.el.getBoundingClientRect();
|
|
1572
|
+
const r = pin.at === void 0 ? whole : new DOMRect(whole.left + pin.at.x, whole.top + pin.at.y, 0, 0);
|
|
1573
|
+
const seen = pin.el.isConnected && whole.width > 0 && whole.height > 0 && r.bottom > 0 && r.top < height && r.right > 0 && r.left < width;
|
|
1574
|
+
pin.box.hidden = !seen;
|
|
1575
|
+
if (!seen) continue;
|
|
1576
|
+
place(pin.box, r);
|
|
1577
|
+
const out = pin.at === void 0 ? OUT : 0;
|
|
1578
|
+
const x = Math.max(EDGE, Math.min(r.right - out, width - EDGE - pin.badge.offsetWidth));
|
|
1579
|
+
const y = Math.max(EDGE, Math.min(r.top - BADGE + out, height - EDGE - BADGE));
|
|
1580
|
+
const edge = pin.at === void 0 ? 1 : 0;
|
|
1581
|
+
Object.assign(pin.badge.style, {
|
|
1582
|
+
left: `${x - r.left - edge}px`,
|
|
1583
|
+
top: `${y - r.top - edge}px`
|
|
1584
|
+
});
|
|
1585
|
+
pin.box.classList.toggle("left", x > width / 2);
|
|
1586
|
+
pin.box.classList.toggle("up", y > height / 2);
|
|
1587
|
+
}
|
|
1588
|
+
};
|
|
1589
|
+
store.subscribe(draw);
|
|
1590
|
+
const sync = () => {
|
|
1591
|
+
clearTimeout(leaving);
|
|
1592
|
+
if (glances === 0) {
|
|
1593
|
+
leaving = setTimeout(() => {
|
|
1594
|
+
cancelAnimationFrame(frame);
|
|
1595
|
+
layer?.remove();
|
|
1596
|
+
layer = void 0;
|
|
1597
|
+
pins.clear();
|
|
1598
|
+
}, LINGER);
|
|
1599
|
+
return;
|
|
1600
|
+
}
|
|
1601
|
+
if (layer === void 0) {
|
|
1602
|
+
layer = div("pins");
|
|
1603
|
+
layer.append(Object.assign(document.createElement("style"), { textContent: STYLE$1 }));
|
|
1604
|
+
frame = requestAnimationFrame(function each() {
|
|
1605
|
+
frame = requestAnimationFrame(each);
|
|
1606
|
+
follow();
|
|
1607
|
+
});
|
|
1608
|
+
}
|
|
1609
|
+
context.root.append(layer);
|
|
1610
|
+
draw();
|
|
1611
|
+
store.load();
|
|
1612
|
+
};
|
|
1613
|
+
const shown = { glance: () => {
|
|
1614
|
+
glances++;
|
|
1615
|
+
sync();
|
|
1616
|
+
return () => {
|
|
1617
|
+
glances--;
|
|
1618
|
+
sync();
|
|
1619
|
+
};
|
|
1620
|
+
} };
|
|
1621
|
+
made.set(context.root, shown);
|
|
1622
|
+
return shown;
|
|
1623
|
+
}
|
|
1624
|
+
// src/plugins/tasks/client.ts
|
|
1625
|
+
/**
|
|
1626
|
+
* The Task tab: a composer to add a task about the element with (`composer.ts`). The tasks there already are the
|
|
1627
|
+
* drawer's to list and open (`drawer.ts`), and the pins' to show on the page. Beside the channel it says who watches
|
|
1628
|
+
* it (`Model.watching`), or that no agent does.
|
|
1629
|
+
* Enter or the arrow sends it with the page's URL, the viewport and the element as it rendered, which the source
|
|
1630
|
+
* can't tell: the chain of source it rendered through, its HTML (a file attached), and where the annotations plugin
|
|
1631
|
+
* is loaded, what's marked on the page. Record leaves the popup (`away`) to record the page, and comes back with
|
|
1632
|
+
* what was typed when it's stopped, wherever the page is by then.
|
|
1633
|
+
*
|
|
1634
|
+
* Its tool in the panel adds a task about a spot: picked, the next press on the page opens this tab on that point,
|
|
1635
|
+
* in the marked element under it or the nearest to it.
|
|
1636
|
+
*/
|
|
1637
|
+
const STYLE = `
|
|
1638
|
+
.compose { flex: none; }
|
|
1639
|
+
.row { display: flex; gap: 6px; margin-top: 8px; justify-content: space-between; align-items: center; }
|
|
1640
|
+
/* Cut short: a channel's name and its watchers' may be long. */
|
|
1641
|
+
.hint { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--deictic-muted); font-size: 12px; }
|
|
1642
|
+
/* A dot as a task's state is: a ring while no one watches, green while someone does. */
|
|
1643
|
+
.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); }
|
|
1644
|
+
.watch.on::before { border-color: #4ade80; background: #4ade80; }
|
|
1645
|
+
.hint a { color: inherit; }
|
|
1646
|
+
.hint a:hover { color: var(--deictic-fg); }
|
|
1647
|
+
${COMPOSER_STYLE}`;
|
|
1648
|
+
const TOOL_STYLE = `
|
|
1649
|
+
.task-tool button { position: relative; }
|
|
1650
|
+
.task-tool .count {
|
|
1651
|
+
position: absolute;
|
|
1652
|
+
top: -5px;
|
|
1653
|
+
right: -5px;
|
|
1654
|
+
box-sizing: border-box;
|
|
1655
|
+
min-width: 15px;
|
|
1656
|
+
height: 15px;
|
|
1657
|
+
padding: 0 4px;
|
|
1658
|
+
border-radius: 8px;
|
|
1659
|
+
font: 700 10px/15px system-ui, sans-serif;
|
|
1660
|
+
color: var(--deictic-on-accent);
|
|
1661
|
+
background: var(--deictic-accent);
|
|
1662
|
+
}
|
|
1663
|
+
.task-tool button[aria-pressed='true'] .count { color: var(--deictic-fg); background: #09090b; }
|
|
1664
|
+
`;
|
|
1665
|
+
/** A note with a plus: a task to add. */
|
|
1666
|
+
const TASK = "<path d=\"M4 5h16v11H9l-5 4zM12 8v5M9.5 10.5h5\"/>";
|
|
118
1667
|
/**
|
|
119
1668
|
* `#shadow-root > div.panel > div.head > button.tab:nth-of-type(2)`: where `inner` is inside `outer`, through
|
|
120
1669
|
* shadow roots, by tag, classes and, among siblings alike, place, for whoever finds it in the code.
|
|
@@ -145,22 +1694,6 @@ const parentOf = (el) => {
|
|
|
145
1694
|
};
|
|
146
1695
|
/** How many places a chain names after the element's own: who uses it, and who uses that. Further out is the app's shell. */
|
|
147
1696
|
const CHAIN = 3;
|
|
148
|
-
/** React's fiber of an element it rendered, which it keeps on the element under a key of its own. */
|
|
149
|
-
const fiberOf = (el) => {
|
|
150
|
-
const key = Object.keys(el).find((k) => k.startsWith("__reactFiber$"));
|
|
151
|
-
return key === void 0 ? void 0 : el[key];
|
|
152
|
-
};
|
|
153
|
-
const ownerOf = (of) => of?._debugOwner ?? of?.owner ?? void 0;
|
|
154
|
-
/** A component's name, through `memo` and `forwardRef`, or nothing for one written without. */
|
|
155
|
-
function componentOf(owner) {
|
|
156
|
-
if (typeof owner.name === "string") return owner.name === "" ? void 0 : owner.name;
|
|
157
|
-
let type = owner.type;
|
|
158
|
-
for (let depth = 0; depth < 4 && type !== null && type !== void 0; depth++) {
|
|
159
|
-
const name = type.displayName ?? type.name;
|
|
160
|
-
if (typeof name === "string" && name !== "") return name;
|
|
161
|
-
type = type.render ?? type.type;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
1697
|
/**
|
|
165
1698
|
* The source `el` rendered through, after its own place, nearest first: a shared component's own line is the same
|
|
166
1699
|
* wherever it's used, and the change is most often in what uses it, or in what uses that.
|
|
@@ -203,56 +1736,12 @@ function chainOf(el, file) {
|
|
|
203
1736
|
}
|
|
204
1737
|
/** What's sent of the element's HTML at most, in characters: the server attaches it as a file. */
|
|
205
1738
|
const HTML = 1e5;
|
|
206
|
-
/** The overlay's own green, as its outline of the element while the popup is open. */
|
|
207
|
-
const OUTLINE = "#12b358";
|
|
208
|
-
/** CSS pixels between the element and its outline, so the dashes are on nothing of the element's. */
|
|
209
|
-
const ROOM = 3;
|
|
210
|
-
/**
|
|
211
|
-
* A shot's PNG with the element outlined in it: dashes around its box, white under them so they show on any
|
|
212
|
-
* page. The shot may have more pixels than its size in CSS ones, which the box is in.
|
|
213
|
-
*/
|
|
214
|
-
async function outlined(png, { box, size }) {
|
|
215
|
-
const url = typeof png === "string" ? png : URL.createObjectURL(png);
|
|
216
|
-
try {
|
|
217
|
-
const image = new Image();
|
|
218
|
-
image.src = url;
|
|
219
|
-
await image.decode();
|
|
220
|
-
const canvas = element("canvas", {
|
|
221
|
-
width: image.naturalWidth,
|
|
222
|
-
height: image.naturalHeight
|
|
223
|
-
});
|
|
224
|
-
const ctx = canvas.getContext("2d");
|
|
225
|
-
if (ctx === null) throw new Error("tasks: this browser won't draw to a canvas");
|
|
226
|
-
ctx.drawImage(image, 0, 0);
|
|
227
|
-
const k = image.naturalWidth / size.width;
|
|
228
|
-
const rect = [
|
|
229
|
-
(box.x - ROOM) * k,
|
|
230
|
-
(box.y - ROOM) * k,
|
|
231
|
-
(box.width + 6) * k,
|
|
232
|
-
(box.height + 6) * k
|
|
233
|
-
];
|
|
234
|
-
ctx.lineWidth = 4 * k;
|
|
235
|
-
ctx.strokeStyle = "#fff";
|
|
236
|
-
ctx.strokeRect(...rect);
|
|
237
|
-
ctx.lineWidth = 2 * k;
|
|
238
|
-
ctx.strokeStyle = OUTLINE;
|
|
239
|
-
ctx.setLineDash([6 * k, 4 * k]);
|
|
240
|
-
ctx.strokeRect(...rect);
|
|
241
|
-
return await new Promise((done, fail) => canvas.toBlob((blob) => blob === null ? fail(/* @__PURE__ */ new Error("tasks: the screenshot drew nothing")) : done(blob), "image/png"));
|
|
242
|
-
} finally {
|
|
243
|
-
if (typeof png !== "string") URL.revokeObjectURL(url);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
function element(tag, props = {}) {
|
|
247
|
-
return Object.assign(document.createElement(tag), props);
|
|
248
|
-
}
|
|
249
1739
|
/** The event the page hears of each added task by, on `window`: its `detail` is a `TaskAdded`. */
|
|
250
1740
|
const TASK_ADDED = "deictic:task";
|
|
251
1741
|
/** Tells the page of a task just added: the newest of the element's tasks, as the board answered them. */
|
|
252
|
-
function announce(model, op, target) {
|
|
1742
|
+
function announce(model, op, target, shots) {
|
|
253
1743
|
const task = model.tasks.at(-1);
|
|
254
1744
|
if (task === void 0) return;
|
|
255
|
-
const marks = (op.annotations?.count ?? 0) + (op.screenshots ?? []).reduce((n, shot) => n + (shot.marks?.count ?? 0), 0);
|
|
256
1745
|
const detail = {
|
|
257
1746
|
id: task.id,
|
|
258
1747
|
title: task.title,
|
|
@@ -264,628 +1753,226 @@ function announce(model, op, target) {
|
|
|
264
1753
|
screenshots: op.screenshots?.length ?? 0,
|
|
265
1754
|
recordings: op.recordings?.length ?? 0,
|
|
266
1755
|
voice: op.voice?.length ?? 0,
|
|
267
|
-
marks
|
|
268
|
-
}
|
|
1756
|
+
marks: (op.annotations?.count ?? 0) + (op.screenshots ?? []).reduce((n, shot) => n + (shot.marks?.count ?? 0), 0)
|
|
1757
|
+
},
|
|
1758
|
+
screenshots: shots
|
|
269
1759
|
};
|
|
270
1760
|
window.dispatchEvent(new CustomEvent(TASK_ADDED, { detail }));
|
|
271
1761
|
}
|
|
272
1762
|
var client_default = defineClientPlugin({
|
|
273
1763
|
name: "tasks",
|
|
274
1764
|
label: "Task",
|
|
1765
|
+
setup: (context) => {
|
|
1766
|
+
const { tools, tray } = context;
|
|
1767
|
+
drawerOf(context);
|
|
1768
|
+
const group = element("div", { className: "tool-group task-tool" });
|
|
1769
|
+
let picking = false;
|
|
1770
|
+
const button = toolButton(TASK, "Task", "T", () => {
|
|
1771
|
+
if (picking) return;
|
|
1772
|
+
picking = true;
|
|
1773
|
+
button.setAttribute("aria-pressed", "true");
|
|
1774
|
+
tools.pick().then((spot) => {
|
|
1775
|
+
picking = false;
|
|
1776
|
+
button.setAttribute("aria-pressed", "false");
|
|
1777
|
+
if (spot !== void 0) context.open("tasks", spot.element, spot.at);
|
|
1778
|
+
});
|
|
1779
|
+
});
|
|
1780
|
+
button.setAttribute("aria-pressed", "false");
|
|
1781
|
+
const count = element("span", { className: "count" });
|
|
1782
|
+
const counted = () => {
|
|
1783
|
+
const held = tray.list().length;
|
|
1784
|
+
count.textContent = String(held);
|
|
1785
|
+
count.hidden = held === 0;
|
|
1786
|
+
};
|
|
1787
|
+
tray.subscribe(counted);
|
|
1788
|
+
counted();
|
|
1789
|
+
button.append(count);
|
|
1790
|
+
group.append(element("style", { textContent: TOOL_STYLE }), button);
|
|
1791
|
+
tools.add(group, {
|
|
1792
|
+
section: "capture",
|
|
1793
|
+
last: true
|
|
1794
|
+
});
|
|
1795
|
+
},
|
|
275
1796
|
resume: ({ use }) => use("recordings")?.going(),
|
|
1797
|
+
pointing: (context) => pinsIn(context).glance(),
|
|
276
1798
|
mount: (panel, context) => {
|
|
277
1799
|
const style = element("style", { textContent: STYLE });
|
|
278
|
-
const list = element("ul", { className: "tasks" });
|
|
279
|
-
const text = element("textarea", { placeholder: "What should change here?" });
|
|
280
|
-
const add = element("button", {
|
|
281
|
-
type: "button",
|
|
282
|
-
className: "primary",
|
|
283
|
-
textContent: "Add task"
|
|
284
|
-
});
|
|
285
1800
|
const hint = element("span", { className: "hint" });
|
|
286
1801
|
const row = element("div", { className: "row" });
|
|
287
|
-
row.append(hint
|
|
288
|
-
const
|
|
289
|
-
const
|
|
290
|
-
const others = element("ul", { className: "tasks" });
|
|
291
|
-
fold.append(count, others);
|
|
292
|
-
const closed = element("details", { className: "more" });
|
|
293
|
-
const closedCount = element("summary");
|
|
294
|
-
const ended = element("ul", { className: "tasks" });
|
|
295
|
-
closed.append(closedCount, ended);
|
|
296
|
-
panel.append(style, list, closed, fold, text);
|
|
1802
|
+
row.append(hint);
|
|
1803
|
+
const over = panel.getRootNode() === context.root;
|
|
1804
|
+
const unpin = over ? pinsIn(context).glance() : void 0;
|
|
297
1805
|
const shots = context.use("screenshots");
|
|
298
|
-
const here = context.element.isConnected;
|
|
299
|
-
const notes = context.use("annotations");
|
|
300
1806
|
const recorder = context.use("recordings");
|
|
301
|
-
const
|
|
1807
|
+
const back = context.resumed;
|
|
302
1808
|
const sendsHtml = context.options?.html !== false;
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
actions.append(...shots !== void 0 && notes !== void 0 && here ? [annotate] : []);
|
|
327
|
-
const shot = element("div", { className: "shot" });
|
|
328
|
-
shot.append(toggle, actions);
|
|
329
|
-
const chipsEl = element("div", { className: "chips" });
|
|
330
|
-
const another = element("button", {
|
|
331
|
-
type: "button",
|
|
332
|
-
textContent: "Add another",
|
|
333
|
-
title: "Take another screenshot and draw on it"
|
|
334
|
-
});
|
|
335
|
-
const problem = element("div", { className: "shot-problem" });
|
|
336
|
-
if (shots !== void 0 || recorder !== void 0 || voice !== void 0) panel.append(shot, chipsEl, problem);
|
|
337
|
-
const withHtml = element("input", {
|
|
338
|
-
type: "checkbox",
|
|
339
|
-
checked: true
|
|
340
|
-
});
|
|
341
|
-
const htmlToggle = element("label", { title: "The element as the page has it now, as a file: element.html" });
|
|
342
|
-
htmlToggle.append(withHtml, "Attach HTML snapshot");
|
|
343
|
-
const htmlRow = element("div", { className: "shot" });
|
|
344
|
-
htmlRow.append(htmlToggle);
|
|
345
|
-
if (sendsHtml) panel.append(htmlRow);
|
|
346
|
-
panel.append(row);
|
|
347
|
-
let chips = [];
|
|
348
|
-
let recordings = [];
|
|
349
|
-
let voices = [];
|
|
350
|
-
let busy = false;
|
|
351
|
-
const attachedCount = () => chips.length + recordings.length + voices.length;
|
|
352
|
-
let sending = false;
|
|
353
|
-
const able = () => add.disabled = sending || text.value.trim() === "" && attachedCount() === 0;
|
|
354
|
-
const more = () => [...recorder !== void 0 ? [record] : [], ...voice !== void 0 ? [speak] : []];
|
|
355
|
-
const chip = (content, title, at, remove, drop) => {
|
|
356
|
-
const opener = element("button", {
|
|
357
|
-
type: "button",
|
|
358
|
-
className: "open",
|
|
359
|
-
title
|
|
360
|
-
});
|
|
361
|
-
opener.append(...content);
|
|
362
|
-
opener.addEventListener("click", () => context.lightbox(viewed(), {
|
|
363
|
-
at,
|
|
364
|
-
from: el
|
|
365
|
-
}));
|
|
366
|
-
const remover = element("button", {
|
|
367
|
-
type: "button",
|
|
368
|
-
className: "remove",
|
|
369
|
-
textContent: "×",
|
|
370
|
-
title: remove
|
|
371
|
-
});
|
|
372
|
-
remover.addEventListener("click", drop);
|
|
373
|
-
const el = element("span", { className: "chip" });
|
|
374
|
-
el.append(opener, remover);
|
|
375
|
-
return el;
|
|
376
|
-
};
|
|
377
|
-
const shotName = (i) => `Screenshot ${i + 1}`;
|
|
378
|
-
const recordingName = (i) => recordings.length === 1 ? "Recording" : `Recording ${i + 1}`;
|
|
379
|
-
const voiceName = (i) => voices.length === 1 ? "Voice" : `Voice ${i + 1}`;
|
|
380
|
-
/** What's attached, as the lightbox shows it, in the chips' order. */
|
|
381
|
-
const viewed = () => [
|
|
382
|
-
...chips.map((c, i) => ({
|
|
383
|
-
kind: "image",
|
|
384
|
-
url: c.url,
|
|
385
|
-
title: shotName(i),
|
|
386
|
-
actions: [{
|
|
387
|
-
label: "Change marks",
|
|
388
|
-
title: "Draw on it again",
|
|
389
|
-
run: () => void draw(c)
|
|
390
|
-
}]
|
|
391
|
-
})),
|
|
392
|
-
...recordings.map((r, i) => ({
|
|
393
|
-
kind: "page",
|
|
394
|
-
url: `${r.url}${r.url.includes("?") ? "&" : "?"}embed`,
|
|
395
|
-
title: `${recordingName(i)} · ${clock(r.duration)}`,
|
|
396
|
-
actions: [{
|
|
397
|
-
label: "New tab",
|
|
398
|
-
title: "Play it back in a tab of its own",
|
|
399
|
-
run: () => void window.open(r.url, "_blank", "noopener")
|
|
400
|
-
}]
|
|
401
|
-
})),
|
|
402
|
-
...voices.map((v, i) => ({
|
|
403
|
-
kind: "audio",
|
|
404
|
-
url: v.url,
|
|
405
|
-
title: `${voiceName(i)} · ${clock(v.duration)}`
|
|
406
|
-
}))
|
|
407
|
-
];
|
|
408
|
-
const showChips = () => {
|
|
409
|
-
const attached = attachedCount() > 0;
|
|
410
|
-
shot.hidden = attached;
|
|
411
|
-
chipsEl.hidden = !attached;
|
|
412
|
-
if (!busy) another.textContent = chips.length > 0 ? "Add another" : "Annotate";
|
|
413
|
-
if (!attached) actions.append(...more());
|
|
414
|
-
chipsEl.replaceChildren(...chips.map((c, i) => {
|
|
415
|
-
const thumb = element("img", {
|
|
416
|
-
src: c.url,
|
|
417
|
-
alt: ""
|
|
418
|
-
});
|
|
419
|
-
return chip([thumb, shotName(i)], `Open ${shotName(i).toLowerCase()}`, i, `Remove ${shotName(i).toLowerCase()}`, () => dropShot(c));
|
|
420
|
-
}), ...recordings.map((r, i) => {
|
|
421
|
-
const play = element("span", {
|
|
422
|
-
className: "play",
|
|
423
|
-
innerHTML: PLAY
|
|
424
|
-
});
|
|
425
|
-
return chip([play, `${recordingName(i)} ${clock(r.duration)}${r.voice === void 0 ? "" : " · voice"}`], `Play ${recordingName(i).toLowerCase()} back`, chips.length + i, `Remove ${recordingName(i).toLowerCase()}`, () => {
|
|
426
|
-
recordings = recordings.filter((x) => x !== r);
|
|
427
|
-
dropped();
|
|
428
|
-
});
|
|
429
|
-
}), ...voices.map((v, i) => {
|
|
430
|
-
const play = element("span", {
|
|
431
|
-
className: "play",
|
|
432
|
-
innerHTML: PLAY
|
|
433
|
-
});
|
|
434
|
-
return chip([play, `${voiceName(i)} ${clock(v.duration)}`], `Play ${voiceName(i).toLowerCase()}`, chips.length + recordings.length + i, `Remove ${voiceName(i).toLowerCase()}`, () => {
|
|
435
|
-
voices = voices.filter((x) => x !== v);
|
|
436
|
-
dropped();
|
|
437
|
-
});
|
|
438
|
-
}), ...attached && shots !== void 0 && notes !== void 0 && here ? [another] : [], ...attached ? more() : []);
|
|
439
|
-
able();
|
|
440
|
-
mark();
|
|
441
|
-
};
|
|
442
|
-
const dropShot = (c) => {
|
|
443
|
-
URL.revokeObjectURL(c.url);
|
|
444
|
-
chips = chips.filter((x) => x !== c);
|
|
445
|
-
dropped();
|
|
446
|
-
};
|
|
447
|
-
const dropped = () => {
|
|
448
|
-
if (attachedCount() === 0) attach.checked = false;
|
|
449
|
-
showChips();
|
|
450
|
-
};
|
|
451
|
-
const toChip = (drawn) => ({
|
|
452
|
-
...drawn,
|
|
453
|
-
url: URL.createObjectURL(drawn.png)
|
|
454
|
-
});
|
|
455
|
-
const reset = () => {
|
|
456
|
-
for (const c of chips) URL.revokeObjectURL(c.url);
|
|
457
|
-
chips = [];
|
|
458
|
-
recordings = [];
|
|
459
|
-
voices = [];
|
|
460
|
-
attach.checked = true;
|
|
461
|
-
showChips();
|
|
462
|
-
};
|
|
463
|
-
/** Takes a shot and opens it to draw on, or opens a chip's again: saved, it's a chip. */
|
|
464
|
-
const draw = async (old) => {
|
|
465
|
-
if (shots === void 0 || notes === void 0 || busy) return;
|
|
466
|
-
busy = true;
|
|
467
|
-
const was = {
|
|
468
|
-
annotate: annotate.textContent,
|
|
469
|
-
another: another.textContent
|
|
1809
|
+
const own = () => [{
|
|
1810
|
+
target: context.target,
|
|
1811
|
+
own: true,
|
|
1812
|
+
el: context.element
|
|
1813
|
+
}];
|
|
1814
|
+
/**
|
|
1815
|
+
* What the page says of an element: read now, while the page has it, and as the panel left it where the page
|
|
1816
|
+
* has moved on without it (a recording that went on to another), which is the page the task is about.
|
|
1817
|
+
*/
|
|
1818
|
+
const seenOf = (a) => {
|
|
1819
|
+
const el = onPage(a);
|
|
1820
|
+
if (el === void 0) return a.seen;
|
|
1821
|
+
const chain = chainOf(el, a.target.loc.file);
|
|
1822
|
+
const { pointed, at } = context;
|
|
1823
|
+
return {
|
|
1824
|
+
...a.own && at !== void 0 ? { point: at } : {},
|
|
1825
|
+
...a.own && pointed !== void 0 ? { pointed: {
|
|
1826
|
+
path: pathTo(pointed, el),
|
|
1827
|
+
html: pointed.outerHTML.slice(0, 4e3)
|
|
1828
|
+
} } : {},
|
|
1829
|
+
count: sameAs(el).length,
|
|
1830
|
+
...chain.length === 0 ? {} : { chain },
|
|
1831
|
+
html: (shots?.masked(el) ?? el).outerHTML.slice(0, HTML)
|
|
470
1832
|
};
|
|
471
|
-
annotate.textContent = another.textContent = old === void 0 ? "Capturing…" : was.another;
|
|
472
|
-
problem.textContent = "";
|
|
473
|
-
try {
|
|
474
|
-
const taken = old?.shot ?? await shots.capture(context.element);
|
|
475
|
-
annotate.textContent = was.annotate;
|
|
476
|
-
another.textContent = was.another;
|
|
477
|
-
const picture = {
|
|
478
|
-
url: taken.url,
|
|
479
|
-
...taken.size
|
|
480
|
-
};
|
|
481
|
-
const marks = await notes.edit(picture, old?.marks ?? [], { signal: aborts.signal });
|
|
482
|
-
if (marks === void 0) return;
|
|
483
|
-
const next = toChip({
|
|
484
|
-
shot: taken,
|
|
485
|
-
marks,
|
|
486
|
-
png: await notes.flatten(picture, marks)
|
|
487
|
-
});
|
|
488
|
-
if (old === void 0) chips = [...chips, next];
|
|
489
|
-
else {
|
|
490
|
-
URL.revokeObjectURL(old.url);
|
|
491
|
-
chips = chips.map((c) => c === old ? next : c);
|
|
492
|
-
}
|
|
493
|
-
showChips();
|
|
494
|
-
} catch (e) {
|
|
495
|
-
problem.textContent = messageOf(e);
|
|
496
|
-
} finally {
|
|
497
|
-
annotate.textContent = was.annotate;
|
|
498
|
-
another.textContent = was.another;
|
|
499
|
-
busy = false;
|
|
500
|
-
showChips();
|
|
501
|
-
}
|
|
502
1833
|
};
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
text: text.value,
|
|
511
|
-
attach: attach.checked,
|
|
512
|
-
html: withHtml.checked,
|
|
513
|
-
drawn,
|
|
514
|
-
recordings,
|
|
515
|
-
voices,
|
|
516
|
-
facts: facts()
|
|
1834
|
+
/** The page the task is about: this one, or the one the panel left where none of its elements is on this one. */
|
|
1835
|
+
const wherever = (about) => {
|
|
1836
|
+
if (back !== void 0 && about.length > 0 && !about.some((a) => onPage(a) !== void 0)) {
|
|
1837
|
+
const { page, viewport } = back.state;
|
|
1838
|
+
return {
|
|
1839
|
+
page,
|
|
1840
|
+
viewport
|
|
517
1841
|
};
|
|
518
|
-
context.away(kept, () => recorder.record());
|
|
519
|
-
});
|
|
520
|
-
});
|
|
521
|
-
let take;
|
|
522
|
-
let ticking;
|
|
523
|
-
let stopWave;
|
|
524
|
-
const speakOn = async () => {
|
|
525
|
-
if (voice === void 0) return;
|
|
526
|
-
problem.textContent = "";
|
|
527
|
-
speak.disabled = true;
|
|
528
|
-
try {
|
|
529
|
-
take = await voice.start();
|
|
530
|
-
} catch (e) {
|
|
531
|
-
problem.textContent = messageOf(e);
|
|
532
|
-
return;
|
|
533
|
-
} finally {
|
|
534
|
-
speak.disabled = false;
|
|
535
1842
|
}
|
|
536
|
-
const started = take.started;
|
|
537
|
-
const time = element("span", { className: "time" });
|
|
538
|
-
const wave = element("canvas", { className: "wave" });
|
|
539
|
-
speak.replaceChildren("● ", time, wave, "Stop");
|
|
540
|
-
stopWave = liveWaveform(wave, take.stream, {
|
|
541
|
-
played: "#fff",
|
|
542
|
-
rest: "rgb(255 255 255 / 0.4)"
|
|
543
|
-
});
|
|
544
|
-
const tick = () => time.textContent = clock(Date.now() - started);
|
|
545
|
-
speak.classList.add("voice-on");
|
|
546
|
-
speak.title = "Stop, and attach it";
|
|
547
|
-
tick();
|
|
548
|
-
ticking = setInterval(tick, 250);
|
|
549
|
-
mark();
|
|
550
|
-
};
|
|
551
|
-
const speakOff = async () => {
|
|
552
|
-
const ending = take;
|
|
553
|
-
if (ending === void 0) return;
|
|
554
|
-
take = void 0;
|
|
555
|
-
clearInterval(ticking);
|
|
556
|
-
stopWave?.();
|
|
557
|
-
stopWave = void 0;
|
|
558
|
-
speak.classList.remove("voice-on");
|
|
559
|
-
speak.textContent = "Saving…";
|
|
560
|
-
try {
|
|
561
|
-
voices = [...voices, await ending.stop()];
|
|
562
|
-
} catch (e) {
|
|
563
|
-
problem.textContent = messageOf(e);
|
|
564
|
-
} finally {
|
|
565
|
-
speak.textContent = "Voice";
|
|
566
|
-
speak.title = "Record your voice, here";
|
|
567
|
-
showChips();
|
|
568
|
-
}
|
|
569
|
-
};
|
|
570
|
-
speak.addEventListener("click", () => void (take === void 0 ? speakOn() : speakOff()));
|
|
571
|
-
let editing;
|
|
572
|
-
const whole = /* @__PURE__ */ new Set();
|
|
573
|
-
let edited;
|
|
574
|
-
/** Tells the popup what leaving now would lose: a listed task's changed words, or a new one's, typed, attached or being spoken. */
|
|
575
|
-
const mark = () => context.unsaved(edited ?? (text.value.trim() !== "" || attachedCount() > 0 || take !== void 0 ? add : void 0));
|
|
576
|
-
let shown = context.model;
|
|
577
|
-
/** Asks for a change to a listed task and shows the tasks as they are after; the panel's status says why not. */
|
|
578
|
-
const change = async (op) => {
|
|
579
|
-
try {
|
|
580
|
-
editing = void 0;
|
|
581
|
-
render(await context.apply(op));
|
|
582
|
-
} catch {
|
|
583
|
-
render(shown);
|
|
584
|
-
}
|
|
585
|
-
};
|
|
586
|
-
/** A task's words in a field of their own: Save or Ctrl+Enter keeps them, Cancel or Esc leaves them. */
|
|
587
|
-
const editor = (t) => {
|
|
588
|
-
const item = element("li", { className: "editing" });
|
|
589
|
-
item.dataset["deicticModal"] = "";
|
|
590
|
-
const field = element("textarea", { value: t.text });
|
|
591
|
-
const save = element("button", {
|
|
592
|
-
type: "button",
|
|
593
|
-
className: "primary",
|
|
594
|
-
textContent: "Save"
|
|
595
|
-
});
|
|
596
|
-
const leave = element("button", {
|
|
597
|
-
type: "button",
|
|
598
|
-
textContent: "Cancel"
|
|
599
|
-
});
|
|
600
|
-
const buttons = element("div", { className: "row" });
|
|
601
|
-
const right = element("span", { className: "actions" });
|
|
602
|
-
right.append(leave, save);
|
|
603
|
-
buttons.append(element("code", { textContent: `#${t.id}` }), right);
|
|
604
|
-
item.append(field, buttons);
|
|
605
|
-
const done = () => {
|
|
606
|
-
editing = void 0;
|
|
607
|
-
render(shown);
|
|
608
|
-
};
|
|
609
|
-
const keep = () => {
|
|
610
|
-
if (field.value.trim() === "") return;
|
|
611
|
-
if (field.value.trim() === t.text) return done();
|
|
612
|
-
save.disabled = true;
|
|
613
|
-
change({
|
|
614
|
-
edit: t.id,
|
|
615
|
-
text: field.value
|
|
616
|
-
});
|
|
617
|
-
};
|
|
618
|
-
field.addEventListener("input", () => {
|
|
619
|
-
save.disabled = field.value.trim() === "";
|
|
620
|
-
edited = field.value.trim() === t.text ? void 0 : save;
|
|
621
|
-
mark();
|
|
622
|
-
});
|
|
623
|
-
field.addEventListener("keydown", (e) => {
|
|
624
|
-
if (e.key === "Escape") {
|
|
625
|
-
e.stopPropagation();
|
|
626
|
-
done();
|
|
627
|
-
}
|
|
628
|
-
if (e.key !== "Enter" || !(e.ctrlKey || e.metaKey)) return;
|
|
629
|
-
e.preventDefault();
|
|
630
|
-
keep();
|
|
631
|
-
});
|
|
632
|
-
save.addEventListener("click", keep);
|
|
633
|
-
leave.addEventListener("click", done);
|
|
634
|
-
queueMicrotask(() => field.focus());
|
|
635
|
-
return item;
|
|
636
|
-
};
|
|
637
|
-
const render = (model) => {
|
|
638
|
-
shown = model;
|
|
639
|
-
edited = void 0;
|
|
640
|
-
const { channel, link, tasks, elsewhere, watching } = model;
|
|
641
|
-
const name = link === void 0 ? element("span") : element("a", {
|
|
642
|
-
href: link,
|
|
643
|
-
target: "_blank",
|
|
644
|
-
rel: "noreferrer",
|
|
645
|
-
title: "Open the channel on the board"
|
|
646
|
-
});
|
|
647
|
-
name.textContent = `#${channel}`;
|
|
648
|
-
hint.replaceChildren("to ", name);
|
|
649
|
-
if (watching !== void 0) {
|
|
650
|
-
const names = new Intl.ListFormat("en", { type: "conjunction" }).format(watching);
|
|
651
|
-
const on = watching.length > 0;
|
|
652
|
-
const who = element("span", {
|
|
653
|
-
className: on ? "watch on" : "watch",
|
|
654
|
-
textContent: on ? `${names} watching` : "no agent watching",
|
|
655
|
-
title: on ? `${names} ${watching.length === 1 ? "is" : "are"} watching #${channel}, and take${watching.length === 1 ? "s" : ""} each task as it's added` : `A task waits on the board until an agent watches #${channel}: ask yours to watch deictic's tasks`
|
|
656
|
-
});
|
|
657
|
-
hint.append(" · ", who);
|
|
658
|
-
}
|
|
659
|
-
/** 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. */
|
|
660
|
-
const rowOf = (t, from) => {
|
|
661
|
-
const item = element("li");
|
|
662
|
-
const state = element("span", {
|
|
663
|
-
className: `state ${t.state}`,
|
|
664
|
-
title: t.by === void 0 ? t.state : `${t.state} by ${t.by}`
|
|
665
|
-
});
|
|
666
|
-
state.role = "img";
|
|
667
|
-
const id = element("code", { textContent: `#${t.id}` });
|
|
668
|
-
const title = element("button", {
|
|
669
|
-
type: "button",
|
|
670
|
-
className: "title"
|
|
671
|
-
});
|
|
672
|
-
const show = () => {
|
|
673
|
-
const all = whole.has(t.id);
|
|
674
|
-
item.classList.toggle("whole", all);
|
|
675
|
-
title.textContent = all ? t.text : t.title;
|
|
676
|
-
title.title = all ? "Show its first line only" : "Show all of it";
|
|
677
|
-
title.ariaExpanded = String(all);
|
|
678
|
-
};
|
|
679
|
-
title.addEventListener("click", () => {
|
|
680
|
-
if (!whole.delete(t.id)) whole.add(t.id);
|
|
681
|
-
show();
|
|
682
|
-
});
|
|
683
|
-
show();
|
|
684
|
-
const to = t.link === void 0 ? id : element("a", {
|
|
685
|
-
href: t.link,
|
|
686
|
-
target: "_blank",
|
|
687
|
-
rel: "noreferrer",
|
|
688
|
-
title: "Open the task on the board"
|
|
689
|
-
});
|
|
690
|
-
if (to !== id) to.append(id);
|
|
691
|
-
item.append(state, to, title, ...from === void 0 ? [] : [from]);
|
|
692
|
-
return item;
|
|
693
|
-
};
|
|
694
|
-
const { file } = context.target.loc;
|
|
695
|
-
fold.hidden = elsewhere.length === 0;
|
|
696
|
-
count.textContent = `${elsewhere.length} elsewhere in ${file.split("/").at(-1)}`;
|
|
697
|
-
others.replaceChildren(...elsewhere.map((t) => {
|
|
698
|
-
if (t.at === void 0) return rowOf(t);
|
|
699
|
-
const { line, column, tag } = t.at;
|
|
700
|
-
const name = `<${tag}> :${line}`;
|
|
701
|
-
const there = document.querySelector(`[data-deictic="${CSS.escape(`${file}:${line}:${column}`)}"]`);
|
|
702
|
-
if (there === null) return rowOf(t, element("span", {
|
|
703
|
-
className: "place",
|
|
704
|
-
textContent: name,
|
|
705
|
-
title: `Line ${line}, not on this page now`
|
|
706
|
-
}));
|
|
707
|
-
const go = element("button", {
|
|
708
|
-
type: "button",
|
|
709
|
-
className: "place",
|
|
710
|
-
textContent: name,
|
|
711
|
-
title: `Open the tasks of line ${line}`
|
|
712
|
-
});
|
|
713
|
-
go.addEventListener("click", () => void context.open("tasks", there));
|
|
714
|
-
return rowOf(t, go);
|
|
715
|
-
}));
|
|
716
|
-
const over = tasks.filter((t) => OVER.has(t.state));
|
|
717
|
-
closed.hidden = over.length === 0;
|
|
718
|
-
closedCount.textContent = `${over.length} closed`;
|
|
719
|
-
ended.replaceChildren(...over.map((t) => rowOf(t)));
|
|
720
|
-
const live = tasks.filter((t) => !OVER.has(t.state));
|
|
721
|
-
const grew = live.length > list.childElementCount;
|
|
722
|
-
list.replaceChildren(...live.map((t) => {
|
|
723
|
-
if (t.id === editing && t.open) return editor(t);
|
|
724
|
-
const item = rowOf(t, t.at === void 0 ? void 0 : element("span", {
|
|
725
|
-
className: "place",
|
|
726
|
-
textContent: `was :${t.at.line}`,
|
|
727
|
-
title: `Added when this was on line ${t.at.line}: it has moved since`
|
|
728
|
-
}));
|
|
729
|
-
if (!t.open) return item;
|
|
730
|
-
const edit = element("button", {
|
|
731
|
-
type: "button",
|
|
732
|
-
className: "act",
|
|
733
|
-
innerHTML: EDIT,
|
|
734
|
-
title: "Edit the task"
|
|
735
|
-
});
|
|
736
|
-
edit.addEventListener("click", () => {
|
|
737
|
-
editing = t.id;
|
|
738
|
-
render(shown);
|
|
739
|
-
});
|
|
740
|
-
const remove = element("button", {
|
|
741
|
-
type: "button",
|
|
742
|
-
className: "act",
|
|
743
|
-
innerHTML: DELETE,
|
|
744
|
-
title: "Delete the task"
|
|
745
|
-
});
|
|
746
|
-
remove.addEventListener("click", () => {
|
|
747
|
-
remove.disabled = true;
|
|
748
|
-
change({ remove: t.id });
|
|
749
|
-
});
|
|
750
|
-
const acts = element("span", { className: "acts" });
|
|
751
|
-
acts.append(edit, remove);
|
|
752
|
-
item.append(acts);
|
|
753
|
-
return item;
|
|
754
|
-
}));
|
|
755
|
-
if (grew) list.scrollTop = list.scrollHeight;
|
|
756
|
-
able();
|
|
757
|
-
mark();
|
|
758
|
-
};
|
|
759
|
-
const back = context.resumed;
|
|
760
|
-
/**
|
|
761
|
-
* What the page says of the element: read now, while the page has it, and as the panel left it where the
|
|
762
|
-
* page has moved on without it (a recording that went on to another), which is the page the task is about.
|
|
763
|
-
*/
|
|
764
|
-
const facts = () => {
|
|
765
|
-
const { element: el, elements } = context;
|
|
766
|
-
if (!here && back !== void 0) return back.state.facts;
|
|
767
|
-
const chain = chainOf(el, context.target.loc.file);
|
|
768
1843
|
return {
|
|
769
1844
|
page: location.href,
|
|
770
1845
|
viewport: {
|
|
771
1846
|
width: innerWidth,
|
|
772
1847
|
height: innerHeight
|
|
773
|
-
}
|
|
774
|
-
...context.pointed === void 0 ? {} : { pointed: {
|
|
775
|
-
path: pathTo(context.pointed, el),
|
|
776
|
-
html: context.pointed.outerHTML.slice(0, 4e3)
|
|
777
|
-
} },
|
|
778
|
-
count: elements.length,
|
|
779
|
-
...chain.length === 0 ? {} : { chain },
|
|
780
|
-
html: (shots?.masked(el) ?? el).outerHTML.slice(0, HTML)
|
|
1848
|
+
}
|
|
781
1849
|
};
|
|
782
1850
|
};
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
const screenshotsOf = async () => {
|
|
789
|
-
if (shots === void 0) return void 0;
|
|
790
|
-
if (chips.length > 0) {
|
|
791
|
-
add.textContent = "Uploading…";
|
|
792
|
-
return Promise.all(chips.map(async ({ shot: taken, marks, png }) => ({
|
|
793
|
-
id: (await shots.upload(png, taken)).id,
|
|
794
|
-
box: taken.box,
|
|
795
|
-
...marks.length === 0 ? {} : { marks: marksOf(marks) }
|
|
796
|
-
})));
|
|
797
|
-
}
|
|
798
|
-
if (!attach.checked || recordings.length > 0 || !here) return void 0;
|
|
799
|
-
add.textContent = "Capturing…";
|
|
800
|
-
const taken = await shots.capture(context.element);
|
|
801
|
-
try {
|
|
802
|
-
return [{
|
|
803
|
-
id: (await shots.upload(await outlined(taken.url, taken), taken)).id,
|
|
804
|
-
box: taken.box,
|
|
805
|
-
outlined: true
|
|
806
|
-
}];
|
|
807
|
-
} catch {
|
|
808
|
-
return [{
|
|
809
|
-
id: taken.id,
|
|
810
|
-
box: taken.box
|
|
811
|
-
}];
|
|
812
|
-
}
|
|
813
|
-
};
|
|
814
|
-
const send = async () => {
|
|
815
|
-
if (busy || sending) return;
|
|
816
|
-
await speakOff();
|
|
817
|
-
if (able()) return;
|
|
818
|
-
sending = true;
|
|
819
|
-
able();
|
|
820
|
-
problem.textContent = "";
|
|
821
|
-
let screenshots;
|
|
822
|
-
try {
|
|
823
|
-
screenshots = await screenshotsOf();
|
|
824
|
-
} catch (e) {
|
|
825
|
-
problem.textContent = messageOf(e);
|
|
826
|
-
add.textContent = "Add task";
|
|
827
|
-
sending = false;
|
|
828
|
-
able();
|
|
1851
|
+
const leave = async () => {
|
|
1852
|
+
if (recorder === void 0) return;
|
|
1853
|
+
composer.problem.textContent = "";
|
|
1854
|
+
if (recorder.recording()) {
|
|
1855
|
+
composer.problem.textContent = "A recording is going already: stop it in the tool panel, and it's attached here";
|
|
829
1856
|
return;
|
|
830
1857
|
}
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
1858
|
+
await composer.stopTake();
|
|
1859
|
+
const { text, shot, html, about } = composer.draft();
|
|
1860
|
+
const kept = {
|
|
1861
|
+
text,
|
|
1862
|
+
...shot === void 0 ? {} : { shot },
|
|
1863
|
+
html,
|
|
1864
|
+
...wherever(about),
|
|
1865
|
+
about: about.flatMap(({ target, own: mine, ...a }) => {
|
|
1866
|
+
const seen = seenOf({
|
|
1867
|
+
target,
|
|
1868
|
+
own: mine,
|
|
1869
|
+
...a
|
|
1870
|
+
});
|
|
1871
|
+
return seen === void 0 ? [] : [{
|
|
1872
|
+
target,
|
|
1873
|
+
own: mine,
|
|
1874
|
+
seen
|
|
1875
|
+
}];
|
|
1876
|
+
})
|
|
1877
|
+
};
|
|
1878
|
+
context.away(kept, () => recorder.record());
|
|
1879
|
+
};
|
|
1880
|
+
const composer = composerIn(context, {
|
|
1881
|
+
placeholder: "What should change here?",
|
|
1882
|
+
sendLabel: "Add task",
|
|
1883
|
+
about: own,
|
|
1884
|
+
html: sendsHtml,
|
|
1885
|
+
...context.at === void 0 ? {} : { at: context.at },
|
|
1886
|
+
shoot: true,
|
|
1887
|
+
here: context.element.isConnected,
|
|
1888
|
+
over,
|
|
1889
|
+
record: () => void leave(),
|
|
1890
|
+
changed: () => mark(),
|
|
1891
|
+
submit: async (gathered) => {
|
|
1892
|
+
const { text, about, html: withHtml, screenshots } = gathered;
|
|
1893
|
+
const [first, ...rest] = about;
|
|
1894
|
+
const { html, ...said } = (first === void 0 ? void 0 : seenOf(first)) ?? {
|
|
1895
|
+
html: void 0,
|
|
1896
|
+
count: 0
|
|
1897
|
+
};
|
|
1898
|
+
const htmlOf = (of) => sendsHtml && withHtml && of !== void 0 ? { html: of } : {};
|
|
834
1899
|
const op = {
|
|
835
|
-
text
|
|
1900
|
+
text,
|
|
1901
|
+
...wherever(about),
|
|
836
1902
|
...said,
|
|
837
|
-
...
|
|
838
|
-
...
|
|
839
|
-
...
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
...clips === void 0 ? {} : { voice: clips.map((c) => c.id) }
|
|
844
|
-
})) },
|
|
845
|
-
...voices.length === 0 ? {} : { voice: voices.map(({ id, duration }) => ({
|
|
846
|
-
id,
|
|
847
|
-
duration
|
|
1903
|
+
...first === void 0 ? { detached: true } : {},
|
|
1904
|
+
...htmlOf(html),
|
|
1905
|
+
...rest.length === 0 ? {} : { also: rest.map((a) => ({
|
|
1906
|
+
at: atOf(a.target),
|
|
1907
|
+
tag: a.target.tag,
|
|
1908
|
+
...htmlOf(seenOf(a)?.html)
|
|
848
1909
|
})) },
|
|
849
|
-
...
|
|
1910
|
+
...attachedOf(gathered)
|
|
850
1911
|
};
|
|
851
|
-
const
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
1912
|
+
const on = first?.target ?? context.target;
|
|
1913
|
+
let model;
|
|
1914
|
+
try {
|
|
1915
|
+
model = await context.apply(op, on);
|
|
1916
|
+
} catch {
|
|
1917
|
+
return false;
|
|
1918
|
+
}
|
|
1919
|
+
storeOf(context).load(true);
|
|
1920
|
+
announce(model, op, on, (screenshots ?? []).map((shot) => shot.url));
|
|
1921
|
+
const added = model.tasks.at(-1);
|
|
1922
|
+
composer.note.textContent = first === void 0 ? "Added, about the page: it is in the drawer" : `Added${added === void 0 ? "" : ` #${added.id}`}: it is in the drawer`;
|
|
1923
|
+
if (added?.dropped !== void 0) composer.problem.textContent = `Sent without ${added.dropped}: it wasn't kept any more`;
|
|
1924
|
+
return true;
|
|
1925
|
+
}
|
|
1926
|
+
});
|
|
1927
|
+
panel.append(style, composer.el);
|
|
1928
|
+
composer.el.append(row);
|
|
1929
|
+
/** Tells the popup what leaving now would lose: the words of a new task, or a take. What's attached is the tray's, and stays. */
|
|
1930
|
+
const mark = () => context.unsaved(composer.pending() ? composer.send : void 0);
|
|
1931
|
+
/** Where a task goes, and whether it's taken up: the channel, and who watches it, or that no one does, where that's known. */
|
|
1932
|
+
const render = ({ channel, link, watching }) => {
|
|
1933
|
+
const name = link === void 0 ? element("span") : element("a", {
|
|
1934
|
+
href: link,
|
|
1935
|
+
target: "_blank",
|
|
1936
|
+
rel: "noreferrer",
|
|
1937
|
+
title: "Open the channel on the board"
|
|
1938
|
+
});
|
|
1939
|
+
name.textContent = `#${channel}`;
|
|
1940
|
+
hint.replaceChildren("to ", name);
|
|
1941
|
+
if (watching === void 0) return;
|
|
1942
|
+
const names = new Intl.ListFormat("en", { type: "conjunction" }).format(watching);
|
|
1943
|
+
const on = watching.length > 0;
|
|
1944
|
+
const who = element("span", {
|
|
1945
|
+
className: on ? "watch on" : "watch",
|
|
1946
|
+
textContent: on ? `${names} watching` : "no agent watching",
|
|
1947
|
+
title: on ? `${names} ${watching.length === 1 ? "is" : "are"} watching #${channel}, and take${watching.length === 1 ? "s" : ""} each task as it's added` : `A task waits on the board until an agent watches #${channel}: ask yours to watch deictic's tasks`
|
|
1948
|
+
});
|
|
1949
|
+
hint.append(" · ", who);
|
|
859
1950
|
};
|
|
860
1951
|
if (back !== void 0) {
|
|
861
1952
|
const kept = back.state;
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
1953
|
+
const about = kept.about.map(({ target, own: mine, seen }) => {
|
|
1954
|
+
const el = mine ? context.element : document.querySelector(`[data-deictic="${CSS.escape(atOf(target))}"]`) ?? void 0;
|
|
1955
|
+
return {
|
|
1956
|
+
target,
|
|
1957
|
+
own: mine,
|
|
1958
|
+
seen,
|
|
1959
|
+
...el === void 0 ? {} : { el }
|
|
1960
|
+
};
|
|
1961
|
+
});
|
|
1962
|
+
const draft = {
|
|
1963
|
+
text: kept.text,
|
|
1964
|
+
html: kept.html,
|
|
1965
|
+
about,
|
|
1966
|
+
...kept.shot === void 0 ? {} : { shot: kept.shot }
|
|
1967
|
+
};
|
|
1968
|
+
composer.restore(draft);
|
|
1969
|
+
if (back.problem !== void 0) composer.problem.textContent = back.problem;
|
|
869
1970
|
}
|
|
870
|
-
text.addEventListener("input", () => {
|
|
871
|
-
able();
|
|
872
|
-
mark();
|
|
873
|
-
});
|
|
874
|
-
text.addEventListener("keydown", (e) => {
|
|
875
|
-
if (e.key !== "Enter" || !(e.ctrlKey || e.metaKey)) return;
|
|
876
|
-
e.preventDefault();
|
|
877
|
-
send();
|
|
878
|
-
});
|
|
879
|
-
add.addEventListener("click", () => void send());
|
|
880
|
-
showChips();
|
|
881
1971
|
render(context.model);
|
|
882
|
-
|
|
1972
|
+
composer.focus();
|
|
883
1973
|
return () => {
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
clearInterval(ticking);
|
|
887
|
-
stopWave?.();
|
|
888
|
-
for (const c of chips) URL.revokeObjectURL(c.url);
|
|
1974
|
+
unpin?.();
|
|
1975
|
+
composer.destroy();
|
|
889
1976
|
};
|
|
890
1977
|
}
|
|
891
1978
|
});
|