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.
Files changed (103) hide show
  1. package/API.md +150 -37
  2. package/README.md +4 -3
  3. package/dist/annotations/client.d.ts +1 -1
  4. package/dist/annotations/client.d.ts.map +1 -1
  5. package/dist/annotations/client.js +161 -176
  6. package/dist/annotations/client.js.map +1 -1
  7. package/dist/annotations/index.d.ts +2 -11
  8. package/dist/client/index.d.ts +7 -6
  9. package/dist/client/index.d.ts.map +1 -1
  10. package/dist/client/index.js +1007 -192
  11. package/dist/client/index.js.map +1 -1
  12. package/dist/index.d.ts +2 -2
  13. package/dist/recommended/index.d.ts +2 -2
  14. package/dist/recordings/client.d.ts.map +1 -1
  15. package/dist/recordings/client.js +82 -153
  16. package/dist/recordings/client.js.map +1 -1
  17. package/dist/screenshots/client.d.ts.map +1 -1
  18. package/dist/shared/annotations.js +3 -4
  19. package/dist/shared/annotations.js.map +1 -1
  20. package/dist/shared/board.js +1 -1
  21. package/dist/shared/client.js +45 -2
  22. package/dist/shared/client.js.map +1 -1
  23. package/dist/shared/component.js +62 -0
  24. package/dist/shared/component.js.map +1 -0
  25. package/dist/shared/dom.js +79 -0
  26. package/dist/shared/dom.js.map +1 -0
  27. package/dist/shared/drawer.js +217 -0
  28. package/dist/shared/drawer.js.map +1 -0
  29. package/dist/shared/endpoints.js +34 -8
  30. package/dist/shared/endpoints.js.map +1 -1
  31. package/dist/shared/find.js +2 -1
  32. package/dist/shared/find.js.map +1 -1
  33. package/dist/shared/index.d.ts +124 -11
  34. package/dist/shared/index.d.ts.map +1 -1
  35. package/dist/shared/index2.d.ts +9 -19
  36. package/dist/shared/index2.d.ts.map +1 -1
  37. package/dist/shared/index7.d.ts +105 -26
  38. package/dist/shared/index7.d.ts.map +1 -1
  39. package/dist/shared/index9.d.ts +1 -1
  40. package/dist/shared/init.js +12 -10
  41. package/dist/shared/init.js.map +1 -1
  42. package/dist/shared/integration.d.ts +1 -1
  43. package/dist/shared/packages.js +1 -1
  44. package/dist/shared/recording.js +31 -3
  45. package/dist/shared/recording.js.map +1 -1
  46. package/dist/shared/src.js.map +1 -1
  47. package/dist/shared/task.js +72 -21
  48. package/dist/shared/task.js.map +1 -1
  49. package/dist/shared/tasks.js +330 -166
  50. package/dist/shared/tasks.js.map +1 -1
  51. package/dist/shared/vb.js +1 -1
  52. package/dist/shared/voice2.js +6 -4
  53. package/dist/shared/voice2.js.map +1 -1
  54. package/dist/shared/watch.js +14 -14
  55. package/dist/shared/watch.js.map +1 -1
  56. package/dist/tailwind/index.js +6 -2
  57. package/dist/tailwind/index.js.map +1 -1
  58. package/dist/tasks/client.d.ts +2 -2
  59. package/dist/tasks/client.d.ts.map +1 -1
  60. package/dist/tasks/client.js +1829 -742
  61. package/dist/tasks/client.js.map +1 -1
  62. package/dist/tasks/index.d.ts +2 -2
  63. package/dist/voice/client.d.ts.map +1 -1
  64. package/dist/voice/client.js +154 -57
  65. package/dist/voice/client.js.map +1 -1
  66. package/package.json +1 -1
  67. package/skills/deictic/SKILL.md +22 -28
  68. package/src/cli/find.ts +3 -1
  69. package/src/cli/init.ts +13 -11
  70. package/src/cli/recording.ts +34 -3
  71. package/src/cli/task.ts +94 -23
  72. package/src/cli/voice.ts +9 -4
  73. package/src/cli/watch.ts +14 -13
  74. package/src/client/away.ts +3 -1
  75. package/src/client/component.ts +98 -0
  76. package/src/client/dom.ts +70 -0
  77. package/src/client/drawer.ts +258 -0
  78. package/src/client/index.ts +220 -128
  79. package/src/client/lightbox.ts +8 -8
  80. package/src/client/lighting.ts +279 -0
  81. package/src/client/style.ts +263 -44
  82. package/src/client/tools.ts +279 -0
  83. package/src/client/tooltip.ts +25 -5
  84. package/src/client/tray.ts +48 -0
  85. package/src/index.ts +121 -10
  86. package/src/plugins/annotations/client.ts +103 -129
  87. package/src/plugins/annotations/draw.ts +68 -72
  88. package/src/plugins/annotations/index.ts +12 -19
  89. package/src/plugins/recordings/client.ts +89 -167
  90. package/src/plugins/screenshots/client.ts +53 -2
  91. package/src/plugins/tailwind/index.ts +6 -2
  92. package/src/plugins/tasks/client.ts +219 -749
  93. package/src/plugins/tasks/composer.ts +797 -0
  94. package/src/plugins/tasks/drawer.ts +516 -0
  95. package/src/plugins/tasks/index.ts +459 -192
  96. package/src/plugins/tasks/pins.ts +275 -0
  97. package/src/plugins/tasks/store.ts +132 -0
  98. package/src/plugins/voice/client.ts +96 -5
  99. package/src/tools/endpoints.ts +18 -7
  100. package/src/tools/source.ts +25 -5
  101. package/skills/deictic/references/recordings.md +0 -13
  102. package/skills/deictic/references/tasks.md +0 -21
  103. package/skills/deictic/references/watch.md +0 -17
@@ -0,0 +1,258 @@
1
+ /**
2
+ * The drawer: on the window's side, where what the plugins have for the page lands, a section each (the
3
+ * tasks still to do, the shots and recordings no task has taken). It shows while a shortcut's keys are held, as the
4
+ * tool panel does, and only while a section has something in it; it stays while the pointer is on it, while something
5
+ * goes on in it (`keep`), and while one of its items is open.
6
+ *
7
+ * An item opens in the drawer itself (`show`): its view takes the sections' place, with a way back. Esc is the view's
8
+ * while the focus is in the drawer, or no popup is open to have it first.
9
+ *
10
+ * It folds away to a pill, by the button in its corner, and stays so (`localStorage`) until the pill is pressed or an
11
+ * item opens in it. The pill counts what the sections have (`data-count`), or what's unread there (`data-unread`).
12
+ */
13
+ import type { ClientContext, Drawer, TrayItem } from '#src/index.ts';
14
+
15
+ import { div } from './dom.ts';
16
+
17
+ /** How long the drawer outlasts the keys, in milliseconds: time to get the pointer to it. */
18
+ const LINGER = 600;
19
+ /** Where whether it's folded is kept. */
20
+ const FOLDED = 'deictic:drawer';
21
+ const FOLD =
22
+ '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14"/></svg>';
23
+ const TRAY =
24
+ '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 13l2.5-8h11l2.5 8v6H4zM4 13h5l1 2h4l1-2h5"/></svg>';
25
+ const BACK =
26
+ '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M15 6l-6 6 6 6"/></svg>';
27
+
28
+ /** A play mark, for a row that plays something: drawn, as a system's own differs from one to the next. */
29
+ export function playMark(): HTMLElement {
30
+ const mark = document.createElement('span');
31
+ mark.innerHTML = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M7 4v16l13-8z" fill="currentColor"/></svg>';
32
+ return mark;
33
+ }
34
+
35
+ export interface OwnDrawer extends Drawer {
36
+ /** Whether a shortcut's keys are held: the drawer shows while they are. */
37
+ point: (on: boolean) => void;
38
+ }
39
+
40
+ export interface DrawerOptions {
41
+ /** Whether the tool panel is on the window's right: the drawer is then on its left, out from under it. */
42
+ crowded: () => boolean;
43
+ }
44
+
45
+ export function drawerIn(root: ShadowRoot, { crowded }: DrawerOptions): OwnDrawer {
46
+ const drawer = div('drawer');
47
+ drawer.setAttribute('role', 'complementary');
48
+ drawer.setAttribute('aria-label', 'deictic drawer');
49
+ const sections = div('drawer-sections');
50
+ const viewing = div('drawer-view');
51
+ viewing.hidden = true;
52
+ const fold = Object.assign(document.createElement('button'), {
53
+ type: 'button',
54
+ className: 'icon drawer-fold',
55
+ title: 'Fold the drawer away',
56
+ innerHTML: FOLD,
57
+ });
58
+ const pill = Object.assign(document.createElement('button'), {
59
+ type: 'button',
60
+ className: 'drawer-pill',
61
+ title: 'Open the drawer',
62
+ innerHTML: TRAY,
63
+ });
64
+ const count = document.createElement('span');
65
+ pill.append(count);
66
+ drawer.append(fold, pill, sections, viewing);
67
+ root.append(drawer);
68
+
69
+ let folded = false;
70
+ try {
71
+ folded = localStorage.getItem(FOLDED) === 'folded';
72
+ } catch {
73
+ // Storage can be off: open, then.
74
+ }
75
+ const foldTo = (on: boolean) => {
76
+ folded = on;
77
+ drawer.classList.toggle('folded', on);
78
+ try {
79
+ localStorage.setItem(FOLDED, on ? 'folded' : 'open');
80
+ } catch {
81
+ // Not kept past the page, then.
82
+ }
83
+ };
84
+ drawer.classList.toggle('folded', folded);
85
+ fold.addEventListener('click', () => foldTo(true));
86
+ pill.addEventListener('click', () => foldTo(false));
87
+ /** What the pill says: how much the sections shown have, or how much of it is unread, in the overlay's green. */
88
+ const counted = () => {
89
+ const shown = [...sections.children].filter((section) => !section.hasAttribute('hidden')) as HTMLElement[];
90
+ // A section that says nothing, or something that isn't a number, counts none.
91
+ const sum = (key: 'count' | 'unread') =>
92
+ shown.reduce((n, section) => {
93
+ const said = Number(section.dataset[key] ?? 0);
94
+ return n + (Number.isFinite(said) ? said : 0);
95
+ }, 0);
96
+ const unread = sum('unread');
97
+ count.textContent = String(unread > 0 ? unread : sum('count'));
98
+ pill.classList.toggle('news', unread > 0);
99
+ pill.title = unread > 0 ? `Open the drawer: ${unread} unread` : 'Open the drawer';
100
+ };
101
+
102
+ let pointing = false;
103
+ let over = false;
104
+ let keeps = 0;
105
+ // What closes the item that's open, where one is.
106
+ let leave: (() => void) | undefined;
107
+ let leaving: ReturnType<typeof setTimeout> | undefined;
108
+ const shown = () => drawer.classList.contains('shown');
109
+ // A section with nothing to show hides itself: the drawer has nothing then, and stays away.
110
+ const empty = () => leave === undefined && ![...sections.children].some((section) => !section.hasAttribute('hidden'));
111
+ const show = () => {
112
+ clearTimeout(leaving);
113
+ leaving = undefined;
114
+ const on = !empty() && (pointing || over || keeps > 0 || leave !== undefined || drawer.contains(root.activeElement));
115
+ if (on === shown()) return;
116
+ // Emptied, it goes at once, not shrunk to its corner's button for a while: nothing is left to get the pointer to.
117
+ if (!on && empty()) {
118
+ drawer.classList.add('emptied');
119
+ drawer.classList.remove('shown');
120
+ return;
121
+ }
122
+ drawer.classList.remove('emptied');
123
+ if (!on) {
124
+ // Not at once: the keys are let go on the way to it.
125
+ leaving = setTimeout(() => drawer.classList.remove('shown'), LINGER);
126
+ return;
127
+ }
128
+ drawer.classList.toggle('left', crowded());
129
+ drawer.classList.add('shown');
130
+ };
131
+ drawer.addEventListener('pointerenter', () => {
132
+ over = true;
133
+ show();
134
+ });
135
+ drawer.addEventListener('pointerleave', () => {
136
+ over = false;
137
+ show();
138
+ });
139
+ drawer.addEventListener('focusout', () => queueMicrotask(show));
140
+ // A section fills as its plugin reads what it has: the drawer is there once one does.
141
+ new MutationObserver(() => {
142
+ counted();
143
+ show();
144
+ }).observe(sections, { subtree: true, attributes: true, attributeFilter: ['hidden', 'data-count', 'data-unread'] });
145
+
146
+ const close = () => {
147
+ const closed = leave;
148
+ if (closed === undefined) return;
149
+ leave = undefined;
150
+ viewing.replaceChildren();
151
+ viewing.hidden = true;
152
+ sections.hidden = false;
153
+ closed();
154
+ show();
155
+ };
156
+ // Before the popup's own Esc, which is added as a popup opens: the item's while it's typed in, or with no popup.
157
+ window.addEventListener(
158
+ 'keydown',
159
+ (e) => {
160
+ if (e.key !== 'Escape' || leave === undefined || root.querySelector('[data-deictic-modal]') !== null) return;
161
+ if (!drawer.contains(root.activeElement) && root.querySelector('.panel') !== null) return;
162
+ e.preventDefault();
163
+ e.stopImmediatePropagation();
164
+ close();
165
+ },
166
+ true,
167
+ );
168
+
169
+ return {
170
+ add: (section, options) => {
171
+ section.classList.add('drawer-section');
172
+ if (options?.first === true) sections.prepend(section);
173
+ else sections.append(section);
174
+ counted();
175
+ show();
176
+ },
177
+ show: (view, { title = '', closed = () => {} } = {}) => {
178
+ close();
179
+ const back = Object.assign(document.createElement('button'), {
180
+ type: 'button',
181
+ className: 'icon',
182
+ title: 'Back to the list',
183
+ innerHTML: BACK,
184
+ });
185
+ back.setAttribute('aria-keyshortcuts', 'Escape');
186
+ back.addEventListener('click', close);
187
+ const head = div('drawer-head');
188
+ head.append(back, Object.assign(document.createElement('span'), { className: 'drawer-title', textContent: title }));
189
+ viewing.replaceChildren(head, view);
190
+ sections.hidden = true;
191
+ viewing.hidden = false;
192
+ leave = closed;
193
+ // Something asked to be seen: folded away, it couldn't be.
194
+ if (folded) foldTo(false);
195
+ show();
196
+ return () => {
197
+ if (leave === closed) close();
198
+ };
199
+ },
200
+ keep: () => {
201
+ keeps++;
202
+ show();
203
+ let kept = true;
204
+ return () => {
205
+ if (!kept) return;
206
+ kept = false;
207
+ keeps--;
208
+ show();
209
+ };
210
+ },
211
+ point: (on) => {
212
+ pointing = on;
213
+ show();
214
+ },
215
+ };
216
+ }
217
+
218
+ /**
219
+ * A section of what a plugin's tools made and no task has taken, from the tray: a heading and a row each, which
220
+ * opens it; its × takes it out of the tray. Away while there are none.
221
+ */
222
+ export function trayed(
223
+ { tray }: Pick<ClientContext, 'tray'>,
224
+ plugin: string,
225
+ title: string,
226
+ row: (item: TrayItem, index: number, all: TrayItem[]) => { label: (string | Node)[]; open: (from: HTMLElement) => void },
227
+ ): HTMLElement {
228
+ const section = document.createElement('section');
229
+ const heading = Object.assign(document.createElement('h3'), { textContent: title });
230
+ const list = div('drawer-rows');
231
+ section.append(heading, list);
232
+ const draw = () => {
233
+ const items = tray.list(plugin);
234
+ section.hidden = items.length === 0;
235
+ section.dataset.count = String(items.length);
236
+ list.replaceChildren(
237
+ ...items.map((item, i) => {
238
+ const { label, open } = row(item, i, items);
239
+ const opener = Object.assign(document.createElement('button'), { type: 'button', className: 'drawer-open' });
240
+ opener.append(...label);
241
+ opener.addEventListener('click', () => open(el));
242
+ const remover = Object.assign(document.createElement('button'), {
243
+ type: 'button',
244
+ className: 'icon',
245
+ textContent: '×',
246
+ title: 'Remove',
247
+ });
248
+ remover.addEventListener('click', () => tray.remove(plugin, item.id));
249
+ const el = div('drawer-row');
250
+ el.append(opener, remover);
251
+ return el;
252
+ }),
253
+ );
254
+ };
255
+ tray.subscribe(draw);
256
+ draw();
257
+ return section;
258
+ }