deictic 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/API.md +136 -30
  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/index.d.ts +116 -7
  30. package/dist/shared/index.d.ts.map +1 -1
  31. package/dist/shared/index2.d.ts +9 -19
  32. package/dist/shared/index2.d.ts.map +1 -1
  33. package/dist/shared/index7.d.ts +103 -26
  34. package/dist/shared/index7.d.ts.map +1 -1
  35. package/dist/shared/index9.d.ts +1 -1
  36. package/dist/shared/integration.d.ts +1 -1
  37. package/dist/shared/packages.js +1 -1
  38. package/dist/shared/recording.js +31 -3
  39. package/dist/shared/recording.js.map +1 -1
  40. package/dist/shared/src.js.map +1 -1
  41. package/dist/shared/task.js +44 -29
  42. package/dist/shared/task.js.map +1 -1
  43. package/dist/shared/tasks.js +232 -62
  44. package/dist/shared/tasks.js.map +1 -1
  45. package/dist/shared/vb.js +1 -1
  46. package/dist/shared/voice2.js +6 -4
  47. package/dist/shared/voice2.js.map +1 -1
  48. package/dist/shared/watch.js +14 -14
  49. package/dist/shared/watch.js.map +1 -1
  50. package/dist/tasks/client.d.ts +2 -2
  51. package/dist/tasks/client.d.ts.map +1 -1
  52. package/dist/tasks/client.js +1829 -741
  53. package/dist/tasks/client.js.map +1 -1
  54. package/dist/tasks/index.d.ts +2 -2
  55. package/dist/voice/client.d.ts.map +1 -1
  56. package/dist/voice/client.js +154 -57
  57. package/dist/voice/client.js.map +1 -1
  58. package/package.json +1 -1
  59. package/skills/deictic/SKILL.md +22 -28
  60. package/src/cli/recording.ts +34 -3
  61. package/src/cli/task.ts +59 -30
  62. package/src/cli/voice.ts +9 -4
  63. package/src/cli/watch.ts +14 -13
  64. package/src/client/away.ts +3 -1
  65. package/src/client/component.ts +98 -0
  66. package/src/client/dom.ts +70 -0
  67. package/src/client/drawer.ts +258 -0
  68. package/src/client/index.ts +220 -128
  69. package/src/client/lightbox.ts +8 -8
  70. package/src/client/lighting.ts +279 -0
  71. package/src/client/style.ts +263 -44
  72. package/src/client/tools.ts +279 -0
  73. package/src/client/tooltip.ts +25 -5
  74. package/src/client/tray.ts +48 -0
  75. package/src/index.ts +113 -6
  76. package/src/plugins/annotations/client.ts +103 -129
  77. package/src/plugins/annotations/draw.ts +68 -72
  78. package/src/plugins/annotations/index.ts +12 -19
  79. package/src/plugins/recordings/client.ts +89 -167
  80. package/src/plugins/screenshots/client.ts +53 -2
  81. package/src/plugins/tasks/client.ts +219 -748
  82. package/src/plugins/tasks/composer.ts +797 -0
  83. package/src/plugins/tasks/drawer.ts +516 -0
  84. package/src/plugins/tasks/index.ts +360 -82
  85. package/src/plugins/tasks/pins.ts +275 -0
  86. package/src/plugins/tasks/store.ts +132 -0
  87. package/src/plugins/voice/client.ts +96 -5
  88. package/skills/deictic/references/recordings.md +0 -13
  89. package/skills/deictic/references/tasks.md +0 -22
  90. package/skills/deictic/references/watch.md +0 -17
@@ -1,33 +1,29 @@
1
1
  /**
2
- * Drawing with the pointer, wherever marks go: the page in annotate mode, or a picture in the editor.
3
- * Each says where an event is in its marks' coordinates; this is the toolbar and the gestures.
2
+ * Drawing on the page with the pointer: the tools, as the tool panel has them, and the gestures.
3
+ *
4
+ * The tools say nothing in words: each is an icon whose tooltip is its name and its key (`aria-keyshortcuts`, which
5
+ * the panel hears and the overlay's tooltip draws as keycaps). While one is picked it has the page (`hold`): the
6
+ * surface takes the pointer, so drawing never clicks the page, until the panel gives the page back.
4
7
  */
8
+ import { MOD, toolButton } from '#src/client/dom.ts';
9
+ import type { ToolPanel } from '#src/index.ts';
10
+
5
11
  import type { Point, Shape } from './index.ts';
6
12
  import { FONT, guess, type Measure } from './svg.ts';
7
13
 
8
- export const TOOLS_STYLE = `
9
- .annotations-tools { display: flex; flex-wrap: wrap; gap: 4px; }
10
- .annotations-tools .icon { display: inline-flex; align-items: center; justify-content: center; padding: 3px 5px; }
11
- .annotations-tools .icon svg { width: 16px; height: 16px; }
12
- .annotations-tools .gap { width: 1px; align-self: stretch; margin: 2px 4px; background: var(--deictic-line); }
13
- .annotations-tools button[aria-pressed='true'] { background: var(--deictic-accent); border-color: var(--deictic-accent); color: var(--deictic-on-accent); }
14
- .annotations-tools .end { margin-left: auto; }
15
- .annotations-hint { margin: 6px 0 0; font-size: 12px; color: var(--deictic-muted); }
14
+ const STYLE = `
15
+ .annotations-tools .gap { width: 1px; align-self: stretch; margin: 2px; background: rgb(255 255 255 / 0.12); }
16
+ .tool-panel.vertical .annotations-tools .gap { width: auto; height: 1px; }
16
17
  `;
17
18
 
18
- type Tool = 'pointer' | 'box' | 'arrow' | 'pen' | 'note';
19
+ type Tool = 'box' | 'arrow' | 'pen' | 'note';
19
20
  const TOOLS: Tool[] = ['box', 'arrow', 'pen', 'note'];
20
- const NAMES: Record<Tool, string> = {
21
- pointer: 'Use the page',
22
- box: 'Draw a box',
23
- arrow: 'Draw an arrow',
24
- pen: 'Draw freehand',
25
- note: 'Add a note',
26
- };
21
+ const NAMES: Record<Tool, string> = { box: 'Box', arrow: 'Arrow', pen: 'Pen', note: 'Note' };
22
+ /** The key that picks each, alone. */
23
+ const KEYS: Record<Tool, string> = { box: 'M', arrow: 'A', pen: 'B', note: 'N' };
27
24
 
28
25
  /** Each icon's strokes, on a 24-pixel grid: drawn here, so the page half needs nothing to show them. */
29
26
  const ICONS = {
30
- pointer: '<path d="M5 3l14 7-6 2-2 6z"/>',
31
27
  box: '<rect x="4" y="4" width="16" height="16" rx="2"/>',
32
28
  arrow: '<path d="M6 18 18 6M9 6h9v9"/>',
33
29
  pen: '<path d="M4 20l1-4L16 5a2.1 2.1 0 0 1 3 3L8 19z"/>',
@@ -36,15 +32,6 @@ const ICONS = {
36
32
  clear: '<path d="M4 7h16M10 11v6M14 11v6M6 7l1 13h10l1-13M9 7V4h6v3"/>',
37
33
  } as const;
38
34
 
39
- /** A button that shows an icon, with its name as its tooltip and for a screen reader. */
40
- export function iconButton(icon: keyof typeof ICONS, name: string, run: () => void): HTMLButtonElement {
41
- const el = button('', name, run);
42
- el.className = 'icon';
43
- el.setAttribute('aria-label', name);
44
- el.innerHTML = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${ICONS[icon]}</svg>`;
45
- return el;
46
- }
47
-
48
35
  /** Text's width as the marks draw it, by a canvas's measure, which the guess stands in for without one. */
49
36
  export function measurer(): Measure {
50
37
  const ctx = document.createElement('canvas').getContext('2d');
@@ -53,14 +40,8 @@ export function measurer(): Measure {
53
40
  return (text) => ctx.measureText(text).width;
54
41
  }
55
42
 
56
- export function button(label: string, title: string, run: () => void): HTMLButtonElement {
57
- const el = Object.assign(document.createElement('button'), { type: 'button', textContent: label, title });
58
- el.addEventListener('click', run);
59
- return el;
60
- }
61
-
62
43
  export interface DrawingOptions {
63
- /** What takes the pointer to draw on. */
44
+ /** What takes the pointer to draw on, while a tool is picked. */
64
45
  surface: HTMLElement;
65
46
  /** Where an event is, in the coordinates the marks are kept in. */
66
47
  at: (e: PointerEvent) => Point;
@@ -69,49 +50,53 @@ export interface DrawingOptions {
69
50
  add: (shape: Shape) => void;
70
51
  removeLast: () => void;
71
52
  clear: () => void;
72
- /**
73
- * Where the page stays usable between marks (a recording's toolbar): a pointer tool comes first and is
74
- * picked to start with, and this hears whether a drawing tool is picked, to let the surface take the
75
- * pointer only then.
76
- */
77
- drawing?: (on: boolean) => void;
53
+ /** The tool panel's `hold`: a picked tool has the page until the panel gives it back. */
54
+ hold: ToolPanel['hold'];
78
55
  }
79
56
 
80
- /**
81
- * Draws on `surface` with the tool picked: answers the toolbar (the tools, then removing the last mark or all), for the
82
- * caller to add its own buttons to, and a hint for the tool.
83
- */
84
- export function drawing({ surface, at, preview, add, removeLast, clear, drawing: on }: DrawingOptions) {
57
+ export interface Drawing {
58
+ /** The tools, as a group for the tool panel: the tools, then removing the last mark or all. */
59
+ group: HTMLElement;
60
+ /** Picks the tool used last, the box first: what a button elsewhere starts drawing with. */
61
+ draw: () => void;
62
+ }
63
+
64
+ /** Draws on `surface` with the tool picked. */
65
+ export function drawing({ surface, at, preview, add, removeLast, clear, hold }: DrawingOptions): Drawing {
85
66
  const tools = document.createElement('div');
86
- tools.className = 'annotations-tools';
87
- const hint = document.createElement('p');
88
- hint.className = 'annotations-hint';
67
+ tools.className = 'tool-group annotations-tools';
89
68
 
90
- let tool: Tool = on === undefined ? 'box' : 'pointer';
91
- const picks = (on === undefined ? TOOLS : (['pointer', ...TOOLS] as Tool[])).map((t) => ({
92
- t,
93
- el: iconButton(t, NAMES[t], () => pick(t)),
94
- }));
69
+ // None until one is picked: the page is the page's.
70
+ let tool: Tool | undefined;
71
+ let last: Tool = 'box';
72
+ let release: (() => void) | undefined;
73
+ const picks = TOOLS.map((t) => ({ t, el: toolButton(ICONS[t], NAMES[t], KEYS[t], () => pick(t)) }));
74
+ const show = () => {
75
+ for (const p of picks) p.el.setAttribute('aria-pressed', String(p.t === tool));
76
+ surface.style.pointerEvents = tool === undefined ? 'none' : 'auto';
77
+ };
95
78
  const pick = (t: Tool) => {
96
79
  tool = t;
97
- for (const p of picks) p.el.setAttribute('aria-pressed', String(p.t === t));
98
- on?.(t !== 'pointer');
99
- hint.textContent =
100
- t === 'pointer'
101
- ? 'Use the page; pick a tool to draw.'
102
- : t === 'note'
103
- ? 'Click where the note goes, type it, Enter to place it.'
104
- : 'Drag to draw.';
80
+ last = t;
81
+ // The page's, once: another of these tools takes over from the one that had it.
82
+ release ??= hold(() => {
83
+ tool = undefined;
84
+ release = undefined;
85
+ show();
86
+ });
87
+ show();
105
88
  };
106
89
  const gap = document.createElement('span');
107
90
  gap.className = 'gap';
108
91
  tools.append(
92
+ Object.assign(document.createElement('style'), { textContent: STYLE }),
109
93
  ...picks.map((p) => p.el),
110
94
  gap,
111
- iconButton('undo', 'Remove the last mark', removeLast),
112
- iconButton('clear', 'Remove every mark', clear),
95
+ toolButton(ICONS.undo, 'Undo', `${MOD}+Z`, removeLast),
96
+ // With Shift: it takes every mark, and nothing brings them back.
97
+ toolButton(ICONS.clear, 'Clear', 'Shift+Backspace', clear),
113
98
  );
114
- pick(tool);
99
+ show();
115
100
 
116
101
  surface.style.cursor = 'crosshair';
117
102
  const shapeFrom = (from: Point, to: Point, points: Point[]): Shape | undefined => {
@@ -148,22 +133,33 @@ export function drawing({ surface, at, preview, add, removeLast, clear, drawing:
148
133
  surface.addEventListener('pointerup', up, { once: true });
149
134
  });
150
135
 
151
- /** A field where the note goes: Enter places what's typed, leaving it empty or blurring it places nothing. */
136
+ /** A field where the note goes: Enter places what's typed, as does leaving it; Esc, or nothing typed, places nothing. */
152
137
  const note = (point: Point, e: PointerEvent) => {
153
- const field = Object.assign(document.createElement('input'), { placeholder: 'Note, then Enter' });
138
+ const field = Object.assign(document.createElement('input'), { placeholder: 'Note', ariaLabel: 'Note' });
139
+ // Esc is the field's while it's there, not the popup's.
140
+ field.dataset['deicticModal'] = '';
154
141
  // Its own colours: on the page, outside the popup, it would take the page's text colour on deictic's dark field.
155
142
  field.style.cssText = `position:fixed;left:${e.clientX}px;top:${e.clientY}px;width:220px;pointer-events:auto;cursor:text;color:var(--deictic-fg);background:var(--deictic-bg);border-color:var(--deictic-accent)`;
156
143
  surface.append(field);
157
- const place = () => {
144
+ // Once: taking the field away blurs it, while it's still there to be asked.
145
+ let over = false;
146
+ const end = (placed: boolean) => {
147
+ if (over) return;
148
+ over = true;
158
149
  const text = field.value.trim();
159
150
  field.remove();
160
- if (text !== '') add({ kind: 'note', at: point, text });
151
+ if (placed && text !== '') add({ kind: 'note', at: point, text });
161
152
  };
162
- field.addEventListener('keydown', (k) => k.key === 'Enter' && place());
163
- field.addEventListener('blur', () => field.isConnected && place());
153
+ field.addEventListener('keydown', (k) => {
154
+ if (k.key === 'Enter') end(true);
155
+ if (k.key !== 'Escape') return;
156
+ k.stopPropagation();
157
+ end(false);
158
+ });
159
+ field.addEventListener('blur', () => end(true));
164
160
  // Now, not a frame later: the pointerdown's default is prevented, so no mousedown takes focus back.
165
161
  field.focus();
166
162
  };
167
163
 
168
- return { tools, hint };
164
+ return { group: tools, draw: () => pick(last) };
169
165
  }
@@ -1,13 +1,13 @@
1
1
  /**
2
- * `deictic/annotations`: mark up the page itself. Its tab is annotate
3
- * mode over the page: boxes, arrows, a pen and notes, drawn where the page is, so they stay with
4
- * it as it scrolls. They're kept for the tab's session, per page, until cleared.
2
+ * `deictic/annotations`: mark up the page itself. Its tools are in the tool panel: boxes, arrows, a pen and notes,
3
+ * drawn where the page is, so they stay with it as it scrolls. They're kept for the tab's session, per page, until
4
+ * they're cleared or a task takes them.
5
5
  *
6
6
  * They're data other plugins build on, through `use('annotations')` in the page: screenshots draw them
7
7
  * over the page (`svg(area)`), tasks repeat their notes, and a recording can keep each change as it
8
8
  * happens (`subscribe`). Nothing of it runs on the server.
9
9
  */
10
- import { definePlugin, type Shortcut } from '#src/index.ts';
10
+ import { definePlugin } from '#src/index.ts';
11
11
 
12
12
  /** A point in page coordinates: CSS pixels from the document's top left, so it stays put as the page scrolls. */
13
13
  export interface Point {
@@ -55,24 +55,20 @@ export interface Annotations {
55
55
  */
56
56
  svg(area: Area): string | undefined;
57
57
  /**
58
- * Opens a picture (a screenshot, most often) over everything, with the toolbar, to draw on: answers the
59
- * marks, in the picture's CSS pixels, on Save, and nothing on Cancel, Esc or `signal`. It starts from
60
- * `marks`, to edit them again. They're the picture's alone, not the page's.
58
+ * Starts drawing on the page, as the tool panel's own tools do, with the one used last (the box, first): for
59
+ * another plugin's button. The page is the marks' until the tool panel gives it back (its pointer, or Esc).
60
+ */
61
+ draw(): void;
62
+ /**
63
+ * Opens `picture` over everything, to draw on with the same tools: the marks on Save, in the picture's CSS
64
+ * pixels, or nothing on Cancel, Esc or `signal`. Start it with `marks`, to change them. They're the picture's
65
+ * alone, not the page's.
61
66
  */
62
67
  edit(picture: Picture, marks?: readonly Annotation[], options?: { signal?: AbortSignal }): Promise<Annotation[] | undefined>;
63
68
  /** The picture with the marks drawn over it, as a PNG at the picture's own resolution. */
64
69
  flatten(picture: Picture, marks: readonly Annotation[]): Promise<Blob>;
65
- /**
66
- * Annotate mode's tools, for another plugin's UI to show (a recording's toolbar): a pointer tool, picked
67
- * to start with, leaves the page usable; while a drawing tool is picked, the page is drawn on. What's
68
- * drawn is its own `marks`, not the page's: shown while it's open, kept by nothing, gone on `close`.
69
- */
70
- tools(): { element: HTMLElement; marks: MarkSet; close: () => void };
71
70
  }
72
71
 
73
- /** A set of marks on the page: the page's own, kept for the session, or a toolbar's, kept by nothing. */
74
- export type MarkSet = Pick<Annotations, 'list' | 'add' | 'remove' | 'clear' | 'subscribe' | 'svg'>;
75
-
76
72
  /** An image to draw on: where it loads from (the page's origin, so a canvas may read it), and its size in CSS pixels, which marks on it are in. */
77
73
  export interface Picture {
78
74
  url: string;
@@ -87,8 +83,6 @@ declare module 'deictic' {
87
83
  }
88
84
 
89
85
  export interface AnnotationsOptions {
90
- /** What opens its tab directly, beside deictic's own shortcut, which opens any: none by default. */
91
- shortcut?: Shortcut;
92
86
  /** The colour marks are drawn in: a red that deictic's own green isn't. */
93
87
  color?: string;
94
88
  }
@@ -97,7 +91,6 @@ export function annotations(options: AnnotationsOptions = {}) {
97
91
  return definePlugin({
98
92
  name: 'annotations',
99
93
  client: 'deictic/annotations/client',
100
- shortcut: options.shortcut,
101
94
  clientOptions: { color: options.color ?? '#ef4444' },
102
95
  });
103
96
  }