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
|
@@ -1,33 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Drawing
|
|
3
|
-
*
|
|
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
|
-
|
|
9
|
-
.annotations-tools {
|
|
10
|
-
.annotations-tools .
|
|
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 = '
|
|
19
|
+
type Tool = 'box' | 'arrow' | 'pen' | 'note';
|
|
19
20
|
const TOOLS: Tool[] = ['box', 'arrow', 'pen', 'note'];
|
|
20
|
-
const NAMES: Record<Tool, string> = {
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
*/
|
|
84
|
-
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
-
|
|
112
|
-
|
|
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
|
-
|
|
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
|
|
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,
|
|
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
|
-
|
|
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) =>
|
|
163
|
-
|
|
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,
|
|
164
|
+
return { group: tools, draw: () => pick(last) };
|
|
169
165
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `deictic/annotations`: mark up the page itself. Its
|
|
3
|
-
*
|
|
4
|
-
*
|
|
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
|
|
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
|
-
*
|
|
59
|
-
*
|
|
60
|
-
|
|
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
|
}
|