deictic 0.1.0 → 0.2.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 (107) hide show
  1. package/README.md +26 -3
  2. package/dist/annotations/index.d.ts +1 -1
  3. package/dist/astro.d.ts +1 -1
  4. package/dist/bun.d.ts +1 -1
  5. package/dist/bun.js +2 -2
  6. package/dist/client/index.d.ts +4 -2
  7. package/dist/client/index.d.ts.map +1 -1
  8. package/dist/client/index.js +13 -9
  9. package/dist/client/index.js.map +1 -1
  10. package/dist/index.d.ts +21 -218
  11. package/dist/index.js.map +1 -1
  12. package/dist/loader.js +1 -1
  13. package/dist/next.d.ts +1 -1
  14. package/dist/next.js +2 -2
  15. package/dist/recommended/index.d.ts +4 -4
  16. package/dist/recommended/index.js +2 -2
  17. package/dist/recordings/client.d.ts +1 -1
  18. package/dist/recordings/client.js +4 -4
  19. package/dist/recordings/client.js.map +1 -1
  20. package/dist/recordings/index.d.ts +2 -2
  21. package/dist/recordings/index.js +3 -3
  22. package/dist/screenshots/client.d.ts +1 -1
  23. package/dist/screenshots/client.js +2 -2
  24. package/dist/screenshots/client.js.map +1 -1
  25. package/dist/screenshots/dom.d.ts +1 -1
  26. package/dist/screenshots/index.d.ts +1 -1
  27. package/dist/screenshots/index.js +2 -2
  28. package/dist/screenshots/index.js.map +1 -1
  29. package/dist/screenshots/rrweb.d.ts +1 -1
  30. package/dist/{endpoints.js → shared/endpoints.js} +1 -1
  31. package/dist/shared/endpoints.js.map +1 -0
  32. package/dist/shared/index.d.ts +226 -0
  33. package/dist/shared/index.d.ts.map +1 -0
  34. package/dist/{index3.d.ts → shared/index2.d.ts} +1 -1
  35. package/dist/shared/index2.d.ts.map +1 -0
  36. package/dist/{index4.d.ts → shared/index3.d.ts} +15 -3
  37. package/dist/shared/index3.d.ts.map +1 -0
  38. package/dist/shared/index4.d.ts +184 -0
  39. package/dist/shared/index4.d.ts.map +1 -0
  40. package/dist/{index5.d.ts → shared/index5.d.ts} +1 -1
  41. package/dist/shared/index5.d.ts.map +1 -0
  42. package/dist/{integration.d.ts → shared/integration.d.ts} +4 -3
  43. package/dist/shared/integration.d.ts.map +1 -0
  44. package/dist/{integration.js → shared/integration.js} +5 -3
  45. package/dist/shared/integration.js.map +1 -0
  46. package/dist/{kept.js → shared/kept.js} +2 -2
  47. package/dist/shared/kept.js.map +1 -0
  48. package/dist/shared/marks.js.map +1 -0
  49. package/dist/shared/playwright.js.map +1 -0
  50. package/dist/{recordings.js → shared/recordings.js} +20 -9
  51. package/dist/shared/recordings.js.map +1 -0
  52. package/dist/shared/shortcut.js.map +1 -0
  53. package/dist/shared/tasks.js +521 -0
  54. package/dist/shared/tasks.js.map +1 -0
  55. package/dist/shared/waveform.js.map +1 -0
  56. package/dist/tailwind/client.d.ts +1 -1
  57. package/dist/tailwind/index.d.ts +1 -1
  58. package/dist/tasks/client.d.ts +1 -1
  59. package/dist/tasks/client.js +1 -1
  60. package/dist/tasks/index.d.ts +2 -159
  61. package/dist/tasks/index.js +1 -348
  62. package/dist/vite.d.ts +11 -12
  63. package/dist/vite.d.ts.map +1 -1
  64. package/dist/vite.js +21 -4
  65. package/dist/vite.js.map +1 -1
  66. package/dist/voice/client.js +2 -2
  67. package/dist/voice/client.js.map +1 -1
  68. package/dist/voice/index.js +1 -1
  69. package/dist/webpack.d.ts +1 -1
  70. package/dist/webpack.js +2 -2
  71. package/package.json +1 -1
  72. package/skills/deictic/SKILL.md +1 -1
  73. package/skills/deictic/references/install.md +20 -5
  74. package/skills/deictic/scripts/lib.mjs +21 -3
  75. package/skills/deictic/scripts/watch.mjs +2 -2
  76. package/src/client/index.ts +20 -7
  77. package/src/index.ts +7 -0
  78. package/src/plugins/recordings/client.ts +3 -2
  79. package/src/plugins/recordings/index.ts +3 -2
  80. package/src/plugins/recordings/replay.ts +32 -6
  81. package/src/plugins/screenshots/client.ts +3 -2
  82. package/src/plugins/tasks/index.ts +52 -8
  83. package/src/plugins/tasks/local.ts +170 -0
  84. package/src/plugins/voice/client.ts +3 -2
  85. package/src/tools/integration.ts +5 -3
  86. package/src/tools/kept.ts +2 -2
  87. package/src/vite.ts +23 -4
  88. package/dist/endpoints.js.map +0 -1
  89. package/dist/index.d.ts.map +0 -1
  90. package/dist/index2.d.ts +0 -23
  91. package/dist/index3.d.ts.map +0 -1
  92. package/dist/index4.d.ts.map +0 -1
  93. package/dist/index5.d.ts.map +0 -1
  94. package/dist/integration.d.ts.map +0 -1
  95. package/dist/integration.js.map +0 -1
  96. package/dist/kept.js.map +0 -1
  97. package/dist/marks.js.map +0 -1
  98. package/dist/playwright.js.map +0 -1
  99. package/dist/recordings.js.map +0 -1
  100. package/dist/shortcut.js.map +0 -1
  101. package/dist/tasks/index.d.ts.map +0 -1
  102. package/dist/tasks/index.js.map +0 -1
  103. package/dist/waveform.js.map +0 -1
  104. /package/dist/{marks.js → shared/marks.js} +0 -0
  105. /package/dist/{playwright.js → shared/playwright.js} +0 -0
  106. /package/dist/{shortcut.js → shared/shortcut.js} +0 -0
  107. /package/dist/{waveform.js → shared/waveform.js} +0 -0
@@ -1,4 +1,4 @@
1
- import { Change, Model } from "./index.js";
1
+ import { n as Change, o as Model } from "../shared/index4.js";
2
2
  /** The event the page hears of each added task by, on `window`: its `detail` is a `TaskAdded`. */
3
3
  export declare const TASK_ADDED = "deictic:task";
4
4
  declare const _default: import("deictic").ClientPlugin<Model, Change, unknown>;
@@ -1,4 +1,4 @@
1
- import { n as liveWaveform } from "../waveform.js";
1
+ import { n as liveWaveform } from "../shared/waveform.js";
2
2
  import { defineClientPlugin } from "../index.js";
3
3
  // src/plugins/tasks/client.ts
4
4
  /**
@@ -1,159 +1,2 @@
1
- import { Board } from "@vercel/board";
2
- import { C as Shortcut, v as Target } from "../index.js";
3
- import { t as Box } from "../index3.js";
4
- /** What the plugin uses of a board: `board()` from `@vercel/board` is one. */
5
- export type TaskBoard = Pick<Board, 'tasks' | 'thread' | 'discovery' | 'upload' | 'edit'>;
6
- export interface TasksOptions {
7
- /**
8
- * The board, as `@vercel/board`'s `board()` answers it: by default the one `BOARD_URL` names (`npx vb serve`
9
- * runs one on this machine), or your team's default board, through `vercel login`.
10
- */
11
- board?: TaskBoard;
12
- /** The channel tasks go to: `deictic` by default. */
13
- channel?: string;
14
- /**
15
- * The project the tasks are about, as the `deictic.project` label, to tell them apart on a board several
16
- * projects share: by default the `name` in the root's `package.json`, and no label where it has none.
17
- */
18
- project?: string;
19
- /** Labels every task gets besides deictic's own, for whoever works them to filter by (`vb tail --label`). None by default. */
20
- labels?: Record<string, string>;
21
- /**
22
- * Where the panel links the channel to, for a person to see its tasks, and with `task`, where it links
23
- * that task's ID to. By default the board's own pages when it's one `vb serve` runs on this machine
24
- * (`http://127.0.0.1:4100/c/deictic`, and `?thread=<id>` on it), and none for another board, whose pages
25
- * deictic can't know.
26
- */
27
- link?: (channel: string, task?: string) => string | undefined;
28
- /** What opens its tab directly, beside deictic's own shortcut, which opens any: none by default. */
29
- shortcut?: Shortcut;
30
- }
31
- export interface Task {
32
- id: string;
33
- /** The first line of what was typed. */
34
- title: string;
35
- /** What was typed, whole: what an edit changes. */
36
- text: string;
37
- state: string;
38
- /** Whether it can still be edited or deleted: no one has claimed it. */
39
- open: boolean;
40
- /** Its page on the board, when there's one to link to. */
41
- link?: string;
42
- }
43
- export interface Model {
44
- channel: string;
45
- /** The channel's page, when there's one to link to. */
46
- link?: string;
47
- /** Tasks about this element, oldest first, canceled ones left out. */
48
- tasks: Task[];
49
- }
50
- /**
51
- * What the Task tab asks for: a new task (an `Op`), other words for one it lists (`edit` is its ID), or
52
- * that one deleted (`remove` is its ID), which cancels it on the board.
53
- */
54
- export type Change = Op | {
55
- edit: string;
56
- text: string;
57
- } | {
58
- remove: string;
59
- };
60
- /** A new task: what the page knows and the source doesn't. */
61
- export interface Op {
62
- text: string;
63
- /** The page's URL. */
64
- page: string;
65
- viewport: {
66
- width: number;
67
- height: number;
68
- };
69
- /**
70
- * What was under the pointer inside the element, where nothing marked it (a dependency's markup, or a
71
- * shadow root's): its path from the element, and its HTML, cut short.
72
- */
73
- pointed?: {
74
- path: string;
75
- html: string;
76
- };
77
- /** How many elements on the page come from the same place in the source. */
78
- count: number;
79
- /**
80
- * Shots the screenshots plugin took of it, to attach, where that plugin is loaded: each with where the
81
- * element is in it, and the marks drawn on it in the panel, where there are any.
82
- */
83
- screenshots?: {
84
- id: string;
85
- box: Box;
86
- marks?: Marks;
87
- }[];
88
- /**
89
- * Recordings the recordings plugin made, to attach, where that plugin is loaded: how long each ran,
90
- * where it plays back, and the voice plugin's clips of the mic in it, attached too.
91
- */
92
- recordings?: {
93
- id: string;
94
- duration: number;
95
- replay: string;
96
- voice?: string[];
97
- }[];
98
- /** Voice notes the voice plugin kept, to attach, where that plugin is loaded, and how long each runs. */
99
- voice?: {
100
- id: string;
101
- duration: number;
102
- }[];
103
- /** The page's annotations, where that plugin is loaded and there are any: how many, and their notes' text. */
104
- annotations?: Marks;
105
- }
106
- /**
107
- * A task the Task tab just added, as the page hears of it: the `detail` of a `deictic:task` event on `window`, for a
108
- * page that shows its own tasks (deictic's playground lists them as a board does).
109
- */
110
- export interface TaskAdded {
111
- id: string;
112
- /** The first line of what was typed. */
113
- title: string;
114
- state: string;
115
- channel: string;
116
- /** The element: its file, line and column, and its tag. */
117
- target: Target;
118
- /** The page's URL. */
119
- page: string;
120
- /** How many of each were attached; `marks` counts those drawn on shots and on the page. */
121
- attached: {
122
- screenshots: number;
123
- recordings: number;
124
- voice: number;
125
- marks: number;
126
- };
127
- }
128
- /** Marks, as a task tells of them: how many, and what the notes among them say. */
129
- export interface Marks {
130
- count: number;
131
- notes: string[];
132
- }
133
- export interface Added {
134
- channel: string;
135
- id: string;
136
- text: string;
137
- labels: Record<string, string>;
138
- /** What's attached, by the board's IDs: kept, so a redo attaches the same without uploading it again. */
139
- attachments?: string[];
140
- }
141
- /** A task's words changed: its message's whole text before and after. */
142
- export interface Edited {
143
- kind: 'edited';
144
- id: string;
145
- before: string;
146
- after: string;
147
- }
148
- /**
149
- * A task deleted in the panel: canceled on the board, for good, as a board has it. So it's kept whole, and
150
- * an undo adds it again, as a new task whose ID the record then has.
151
- */
152
- export interface Removed extends Added {
153
- kind: 'removed';
154
- }
155
- /** What the history keeps of a change: a task added has no `kind`, as it had none before there were others. */
156
- export type Kept = Added | Edited | Removed;
157
- export declare function tasks(options?: TasksOptions): import("deictic").ServerPlugin<Model, Change, Kept, unknown>;
158
- export { tasks as default };
159
- //# sourceMappingURL=index.d.ts.map
1
+ import { a as Marks, c as Removed, d as TaskBoard, f as TasksOptions, g as local, h as LocalOptions, i as Kept, l as Task, m as LocalBoard, n as Change, o as Model, p as tasks, r as Edited, s as Op, t as Added, u as TaskAdded } from "../shared/index4.js";
2
+ export { Added, Change, Edited, Kept, type LocalBoard, type LocalOptions, Marks, Model, Op, Removed, Task, TaskAdded, TaskBoard, TasksOptions, tasks as default, tasks, local };
@@ -1,348 +1 @@
1
- import { readFileSync } from "node:fs";
2
- import { join } from "node:path";
3
- import { Refusal, definePlugin } from "../index.js";
4
- // src/plugins/tasks/index.ts
5
- /**
6
- * `deictic/tasks`: open its tab on an element to add a task about it to a Vercel Board
7
- * (`@vercel/board`). The task says what to change, in the words typed, and where: the element's file,
8
- * line and tag, the page and the project, all as labels beside the short facts (viewport, how many, where
9
- * it is in the shot). Whatever works the board's tasks (a person, or an agent of theirs claiming them) takes it
10
- * from there; deictic only adds them.
11
- *
12
- * Adding one is a change like any other: undo cancels the task, while no one has claimed it, and redo
13
- * adds it again, as a new task. Each task carries `deictic.at=<file:line:column>`, so the panel
14
- * lists the ones about the element clicked, until its line moves.
15
- */
16
- const AT = "deictic.at";
17
- /** What parts what was typed from the rest of a task's text. */
18
- const REST = "\n---\n";
19
- const OPEN = /* @__PURE__ */ new Set([
20
- "waiting",
21
- "ready",
22
- "blocked"
23
- ]);
24
- function tasks(options = {}) {
25
- const channel = options.channel ?? "deictic";
26
- let team;
27
- const boardOf = () => team ??= options.board ? Promise.resolve(options.board) : import("@vercel/board").then((m) => m.board());
28
- let link;
29
- const linkOf = () => link ??= (options.link ? Promise.resolve(options.link(channel)) : boardOf().then((b) => localPage(b, channel))).catch(() => {
30
- link = void 0;
31
- });
32
- /** A task's page: what `link` says, or its thread on the channel's own page on this machine. */
33
- const taskLink = (page, id) => options.link ? options.link(channel, id) : page === void 0 ? void 0 : `${page}?thread=${encodeURIComponent(id)}`;
34
- /**
35
- * One of this channel's tasks about an element, while it's still open: the page names it by ID, so
36
- * nothing else on the board is its to change, nor a task someone has taken up.
37
- */
38
- const openTask = async (team, id, verb) => {
39
- const { message } = await team.thread(id);
40
- if (message.channel !== channel || message.labels[AT] === void 0) throw new Refusal(`#${id} isn't a task of deictic's in #${channel}: reload the page for the ones that are`);
41
- const { task } = message;
42
- if (task !== void 0 && !OPEN.has(task.state)) throw new Refusal(`task ${id} is ${task.state}${task.claim ? ` by ${task.claim.actor}` : ""} now: ${verb} it on the board if you still mean to`);
43
- return message;
44
- };
45
- /** Cancels an open task of ours, and answers it as it was. */
46
- const cancel = async (id, reason) => {
47
- const team = await boardOf();
48
- const message = await openTask(team, id, "cancel");
49
- await team.tasks.cancel(id, reason);
50
- return message;
51
- };
52
- /** Puts a task's text from one to the other, unless it reads as neither any more. */
53
- const rewrite = async (id, from, to) => {
54
- const team = await boardOf();
55
- const message = await openTask(team, id, "edit");
56
- if (message.text === to) return;
57
- if (message.text !== from) throw new Refusal(`task ${id} has been edited since: change it on the board`);
58
- await team.edit(id, to, { revision: message.revision });
59
- };
60
- const create = async (record) => {
61
- const { task } = await (await boardOf()).tasks.create(record.channel, {
62
- text: record.text,
63
- labels: record.labels,
64
- ...record.attachments === void 0 ? {} : { attachments: record.attachments }
65
- });
66
- return {
67
- ...record,
68
- id: task.id
69
- };
70
- };
71
- let context;
72
- let project = options.project;
73
- /** The screenshots and recordings to attach, uploaded to the board, or nothing when there are none. */
74
- const attach = async (op) => {
75
- const files = [
76
- ...(op.screenshots ?? []).map(({ id }) => {
77
- const shot = context?.use("screenshots")?.read(id);
78
- if (shot === void 0) throw new Refusal(`screenshot ${id} isn't kept any more: take it again`);
79
- return shot;
80
- }),
81
- ...(op.recordings ?? []).map(({ id }) => {
82
- const recording = context?.use("recordings")?.read(id);
83
- if (recording === void 0) throw new Refusal(`recording ${id} isn't kept any more: record it again`);
84
- return recording;
85
- }),
86
- ...[...(op.recordings ?? []).flatMap((r) => r.voice ?? []), ...(op.voice ?? []).map((v) => v.id)].map((id) => {
87
- const clip = context?.use("voice")?.read(id);
88
- if (clip === void 0) throw new Refusal(`voice clip ${id} isn't kept any more: record it again`);
89
- return clip;
90
- })
91
- ];
92
- if (files.length === 0) return void 0;
93
- const team = await boardOf();
94
- return Promise.all(files.map(async (file) => (await team.upload(file)).id));
95
- };
96
- return definePlugin({
97
- name: "tasks",
98
- client: "deictic/tasks/client",
99
- shortcut: options.shortcut,
100
- setup: (given) => {
101
- context = given;
102
- project ??= nameOf(given.root);
103
- },
104
- read: (_source, target) => asked(async () => {
105
- const [{ tasks: found }, page] = await Promise.all([(await boardOf()).tasks.list({
106
- channel,
107
- label: { [AT]: atOf(target) },
108
- state: "all"
109
- }), linkOf()]);
110
- return {
111
- channel,
112
- ...page === void 0 ? {} : { link: page },
113
- tasks: found.map(({ message }) => {
114
- const text = message.text.split(REST, 1)[0];
115
- const state = message.task?.state ?? "ready";
116
- const to = taskLink(page, message.id);
117
- return {
118
- id: message.id,
119
- title: text.split("\n", 1)[0],
120
- text,
121
- state,
122
- open: OPEN.has(state),
123
- ...to === void 0 ? {} : { link: to }
124
- };
125
- }).filter((t) => t.state !== "canceled")
126
- };
127
- }),
128
- apply: (source, target, op) => {
129
- if ("remove" in op) return asked(async () => {
130
- const message = await cancel(op.remove, "deleted in deictic");
131
- const labels = Object.fromEntries(Object.entries(message.labels).filter(([key]) => !key.startsWith("board.")));
132
- const attachments = message.attachments.map((a) => a.id);
133
- return { done: {
134
- kind: "removed",
135
- channel,
136
- id: op.remove,
137
- text: message.text,
138
- labels,
139
- ...attachments.length === 0 ? {} : { attachments }
140
- } };
141
- });
142
- if (op.text.trim() === "" && ("edit" in op || shown(op) === void 0)) throw new Refusal("say what should change first");
143
- if ("edit" in op) return asked(async () => {
144
- const before = (await openTask(await boardOf(), op.edit, "edit")).text;
145
- const rest = before.includes(REST) ? before.slice(before.indexOf(REST)) : "";
146
- const after = clip(op.text.trim(), 1e4 - rest.length) + rest;
147
- await rewrite(op.edit, before, after);
148
- return { done: {
149
- kind: "edited",
150
- id: op.edit,
151
- before,
152
- after
153
- } };
154
- });
155
- const labels = {
156
- ...options.labels,
157
- ...project === void 0 ? {} : { "deictic.project": clip(project, LABEL) },
158
- ...labelsOf(source, target, op)
159
- };
160
- return asked(async () => {
161
- const attachments = await attach(op);
162
- return { done: await create({
163
- channel,
164
- text: textOf(op),
165
- labels,
166
- ...attachments === void 0 ? {} : { attachments }
167
- }) };
168
- });
169
- },
170
- undo: (record) => asked(async () => {
171
- if (!("kind" in record)) {
172
- await cancel(record.id, "undone in deictic");
173
- return;
174
- }
175
- if (record.kind === "edited") {
176
- await rewrite(record.id, record.after, record.before);
177
- return;
178
- }
179
- const { kind, id: _, ...task } = record;
180
- return {
181
- kind,
182
- ...await create(task)
183
- };
184
- }),
185
- redo: (record) => asked(async () => {
186
- if (!("kind" in record)) {
187
- const { id: _, ...added } = record;
188
- return create(added);
189
- }
190
- if (record.kind === "edited") {
191
- await rewrite(record.id, record.before, record.after);
192
- return record;
193
- }
194
- await cancel(record.id, "deleted in deictic");
195
- return record;
196
- }),
197
- describe: (op, before) => {
198
- const named = (id) => `task "${clip(before.tasks.find((t) => t.id === id)?.title ?? `#${id}`, 60)}"`;
199
- if ("remove" in op) return `delete ${named(op.remove)}`;
200
- if ("edit" in op) return `edit ${named(op.edit)}`;
201
- return `task "${clip(wordsOf(op).split("\n", 1)[0], 60)}"`;
202
- }
203
- });
204
- }
205
- /**
206
- * The channel's page on a board `vb serve` runs on this machine, which serves its pages beside its API:
207
- * `/api/board` there, `/c/<channel>` beside it. Nothing for any other board.
208
- */
209
- async function localPage(team, channel) {
210
- const url = new URL((await team.discovery()).url);
211
- if (![
212
- "127.0.0.1",
213
- "localhost",
214
- "[::1]"
215
- ].includes(url.hostname) || !url.pathname.endsWith("/api/board")) return void 0;
216
- return `${url.origin}${url.pathname.slice(0, -10)}/c/${channel.split("/").map(encodeURIComponent).join("/")}`;
217
- }
218
- const plural = (count, word) => `${count} ${word}${count === 1 ? "" : "s"}`;
219
- const said = (notes) => notes.length === 0 ? "" : `; the notes say: ${notes.map((n) => JSON.stringify(n)).join(", ")}`;
220
- /** What was marked on the page: how many marks, and what the notes say. */
221
- function annotated({ count, notes }, shots, recordings) {
222
- const where = [...shots === 0 ? [] : [shots === 1 ? "the screenshot" : "the screenshots"], ...recordings === 0 ? [] : [recordings === 1 ? "the recording" : "the recordings"]];
223
- const drawn = where.length === 0 ? "" : `, drawn in ${where.join(" and ")}`;
224
- return `${plural(count, "mark")} on the page${drawn}${said(notes)}`;
225
- }
226
- /** How long each recording ran, and where it plays back, while the dev server keeps it. */
227
- function recordingsOf(recordings) {
228
- return recordings.map(({ duration, replay, voice }, i) => {
229
- const name = recordings.length === 1 ? "A recording" : `Recording ${i + 1}`;
230
- const spoken = voice === void 0 || voice.length === 0 ? "" : `, with the voice (${voice.map((id) => `voice-${id}`).join(", ")})`;
231
- return `${name}, ${clock(duration)} long, attached as rrweb events${spoken}; it replays at ${replay}`;
232
- });
233
- }
234
- /** How long each voice note runs, and the attachment it's in. */
235
- function voicesOf(voice) {
236
- return voice.map(({ id, duration }, i) => {
237
- return `${voice.length === 1 ? "A voice note" : `Voice note ${i + 1}`}, ${clock(duration)} long, attached as voice-${id}`;
238
- });
239
- }
240
- const clock = (ms) => {
241
- const s = Math.round(ms / 1e3);
242
- return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`;
243
- };
244
- /**
245
- * What was drawn on each shot, and with several, where the element is in each: nothing marks it there. One
246
- * shot's place is the `deictic.position` and `deictic.size` labels, so a shot with no marks has no line.
247
- */
248
- function shotsOf(shots) {
249
- const [only] = shots;
250
- if (shots.length === 1 && only !== void 0) {
251
- const { marks } = only;
252
- return marks === void 0 || marks.count === 0 ? [] : [`The screenshot has ${plural(marks.count, "mark")} drawn on it${said(marks.notes)}`];
253
- }
254
- return shots.map(({ box, marks }, i) => {
255
- const drawn = marks === void 0 || marks.count === 0 ? "" : `, with ${plural(marks.count, "mark")} drawn on it${said(marks.notes)}`;
256
- const [x, y, width, height] = boxOf(box);
257
- return `In screenshot ${i + 1} at x ${x}, y ${y}, ${width}×${height}${drawn}`;
258
- });
259
- }
260
- /** A box as `x,y,width,height`, in whole CSS pixels from the shot's top left. */
261
- const boxOf = ({ x, y, width, height }) => [
262
- x,
263
- y,
264
- width,
265
- height
266
- ].map(Math.round);
267
- /** A label's value: a board holds 256 characters. */
268
- const LABEL = 256;
269
- /** The project's name: the `name` in the root's `package.json`, or nothing where it has none. */
270
- function nameOf(root) {
271
- try {
272
- const { name } = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
273
- return typeof name === "string" && name !== "" ? name : void 0;
274
- } catch {
275
- return;
276
- }
277
- }
278
- /**
279
- * The facts about the element, as labels: short values a script reads without parsing the text, and a watch
280
- * filters by. `deictic.line` is the opening tag's first line as the task saw it, to tell later that it moved.
281
- * `deictic.url` is the page's whole URL, where a label holds it: `textOf` says a longer one.
282
- */
283
- function labelsOf({ code, element }, target, op) {
284
- const [shot] = op.screenshots ?? [];
285
- return {
286
- [AT]: atOf(target),
287
- "deictic.tag": target.tag,
288
- "deictic.line": clip(code.slice(element.start, element.end).split("\n", 1)[0].trim(), LABEL),
289
- "deictic.page": clip(new URL(op.page).pathname, LABEL),
290
- ...op.page.length <= LABEL ? { "deictic.url": op.page } : {},
291
- "deictic.viewport": `${op.viewport.width}x${op.viewport.height}`,
292
- "deictic.count": String(op.count),
293
- ...op.screenshots?.length === 1 && shot !== void 0 ? placeOf(shot.box) : {}
294
- };
295
- }
296
- /** Where the element is in the one shot, from its top left, and how big: `87,387` and `138x32`, as the viewport is written. */
297
- function placeOf(box) {
298
- const [x, y, width, height] = boxOf(box);
299
- return {
300
- "deictic.position": `${x},${y}`,
301
- "deictic.size": `${width}x${height}`
302
- };
303
- }
304
- const atOf = ({ loc }) => `${loc.file}:${loc.line}:${loc.column}`;
305
- /**
306
- * The task's text: what was typed, and after a `---` only what no label holds: what's attached and drawn, what
307
- * was pointed at inside the element, and a URL too long for one. A board holds 10,000 characters.
308
- */
309
- function textOf(op) {
310
- const more = [
311
- ...op.page.length <= LABEL ? [] : [op.page],
312
- ...shotsOf(op.screenshots ?? []),
313
- ...recordingsOf(op.recordings ?? []),
314
- ...voicesOf(op.voice ?? []),
315
- ...op.annotations === void 0 ? [] : [annotated(op.annotations, op.screenshots?.length ?? 0, op.recordings?.length ?? 0)],
316
- ...op.pointed === void 0 ? [] : [`Pointed at, inside it: \`${op.pointed.path}\``, fence(op.pointed.html, "html")]
317
- ];
318
- const tail = more.length === 0 ? "" : REST + more.join("\n");
319
- return clip(wordsOf(op), 1e4 - tail.length) + tail;
320
- }
321
- /** The task's words: what was typed, or where nothing was, a line that sends the reader to what's attached. */
322
- const wordsOf = (op) => op.text.trim() === "" ? shown(op) ?? "" : op.text.trim();
323
- /** `See the recording and the voice note`: what stands for the words of a task sent with none, where something is attached. */
324
- function shown(op) {
325
- const named = (count, word) => count === void 0 || count === 0 ? [] : [`the ${word}${count === 1 ? "" : "s"}`];
326
- const attached = [
327
- ...named(op.screenshots?.length, "screenshot"),
328
- ...named(op.recordings?.length, "recording"),
329
- ...named(op.voice?.length, "voice note")
330
- ];
331
- return attached.length === 0 ? void 0 : `See ${new Intl.ListFormat("en", { type: "conjunction" }).format(attached)}`;
332
- }
333
- const fence = (text, lang) => `\`\`\`\`${lang}\n${clip(text, 1500)}\n\`\`\`\``;
334
- const clip = (text, max) => text.length <= max ? text : `${text.slice(0, max - 1)}…`;
335
- /** The board's answer, or a `Refusal` saying what to do when there's no board to ask or it said no. */
336
- async function asked(ask) {
337
- try {
338
- return await ask();
339
- } catch (e) {
340
- if (e instanceof Refusal) throw e;
341
- const { code, message, hint } = e;
342
- if (typeof code === "string") throw new Refusal(`the board says: ${message}${hint === void 0 ? "" : ` (${hint})`}`, { cause: e });
343
- throw new Refusal(`can't reach the board (${message ?? String(e)}): run \`npx vb serve\` and set BOARD_URL for the dev server, or \`vercel login\``, { cause: e });
344
- }
345
- }
346
- export { tasks as default, tasks };
347
-
348
- //# sourceMappingURL=index.js.map
1
+ export { t as default, t as tasks, n as local } from "../shared/tasks.js";
package/dist/vite.d.ts CHANGED
@@ -1,17 +1,16 @@
1
- /**
2
- * `deictic/vite`: deictic in Vite's dev server. Nothing runs in a build.
3
- *
4
- * Its transform runs `pre`, so each JSX module's host elements are marked with their place in the
5
- * source as written (`tools/locate.ts`). In the browser each marked module also imports the client
6
- * module, which starts the overlay with every plugin's panel: imports run first and only once, so no
7
- * line moves and frameworks that render their own HTML get it too. The endpoints are middleware on
8
- * Vite's server, and a place opens through Vite's own `/__open-in-editor`, so the editor is whichever
9
- * Vite already launches. A write reaches the page through Vite's usual update for the file.
10
- */
11
1
  import { Plugin } from "vite";
12
- import { n as clientModule, t as DeicticOptions } from "./integration.js";
2
+ import { n as clientModule, t as DeicticOptions } from "./shared/integration.js";
3
+ export interface ViteOptions extends DeicticOptions {
4
+ /**
5
+ * deictic in a build too, for a page that shows it with no dev server behind it (a deployed demo): a module of
6
+ * the page's, from the root, whose default export answers the overlay's requests there (a `Standalone`, from
7
+ * `deictic`). The build's elements are marked and the overlay is in its bundle. The dev server answers as ever.
8
+ * Without it, the default, nothing of deictic is in a build.
9
+ */
10
+ standalone?: string;
11
+ }
13
12
  /** The client module's ID, which a page can import itself where nothing it bundles is JSX (Astro's pages). */
14
13
  export declare const CLIENT = "virtual:deictic/client";
15
- export declare function deictic(options?: DeicticOptions): Plugin;
14
+ export declare function deictic(options?: ViteOptions): Plugin;
16
15
  export { type DeicticOptions, clientModule, deictic as default };
17
16
  //# sourceMappingURL=vite.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vite.d.ts","names":[],"sources":["../src/vite.ts"],"mappings":";;;;;;;;;;;;;qBAkBa;wBAGG,QAAQ,UAAS,iBAAsB"}
1
+ {"version":3,"file":"vite.d.ts","names":[],"sources":["../src/vite.ts"],"mappings":";;iBAmBiB,oBAAoB;;;;;;;EAOnC;;;qBAIW;wBAGG,QAAQ,UAAS,cAAmB"}
package/dist/vite.js CHANGED
@@ -1,6 +1,17 @@
1
- import { n as nodeMiddleware, r as redirect, t as endpoints } from "./endpoints.js";
2
- import { a as markAstro, i as mark, n as clientModule, o as prepare } from "./integration.js";
1
+ import { resolve } from "node:path";
2
+ import { n as nodeMiddleware, r as redirect, t as endpoints } from "./shared/endpoints.js";
3
+ import { a as markAstro, i as mark, n as clientModule, o as prepare } from "./shared/integration.js";
3
4
  // src/vite.ts
5
+ /**
6
+ * `deictic/vite`: deictic in Vite's dev server. Nothing runs in a build, unless `standalone` asks for it.
7
+ *
8
+ * Its transform runs `pre`, so each JSX module's host elements are marked with their place in the
9
+ * source as written (`tools/locate.ts`). In the browser each marked module also imports the client
10
+ * module, which starts the overlay with every plugin's panel: imports run first and only once, so no
11
+ * line moves and frameworks that render their own HTML get it too. The endpoints are middleware on
12
+ * Vite's server, and a place opens through Vite's own `/__open-in-editor`, so the editor is whichever
13
+ * Vite already launches. A write reaches the page through Vite's usual update for the file.
14
+ */
4
15
  /** The client module's ID, which a page can import itself where nothing it bundles is JSX (Astro's pages). */
5
16
  const CLIENT = "virtual:deictic/client";
6
17
  const CLIENT_ID = "\0deictic/client";
@@ -8,14 +19,16 @@ function deictic(options = {}) {
8
19
  const { plugins, shortcut } = prepare(options);
9
20
  let root = "";
10
21
  let base = "/";
22
+ let building = false;
11
23
  return {
12
24
  name: "deictic",
13
25
  enforce: "pre",
14
- apply: "serve",
26
+ apply: (_, { command }) => command === "serve" || options.standalone !== void 0,
15
27
  config: () => ({ optimizeDeps: { exclude: ["deictic"] } }),
16
28
  configResolved(config) {
17
29
  root = config.root;
18
30
  base = config.base;
31
+ building = config.command === "build";
19
32
  },
20
33
  configureServer(server) {
21
34
  const handle = endpoints({
@@ -27,7 +40,11 @@ function deictic(options = {}) {
27
40
  server.middlewares.use(nodeMiddleware(handle));
28
41
  },
29
42
  resolveId: (id) => id === "virtual:deictic/client" ? CLIENT_ID : void 0,
30
- load: (id) => id === CLIENT_ID ? clientModule(plugins, base, shortcut) : void 0,
43
+ load(id) {
44
+ if (id !== CLIENT_ID) return void 0;
45
+ const server = building && options.standalone !== void 0 ? resolve(root, options.standalone).replaceAll("\\", "/") : void 0;
46
+ return clientModule(plugins, base, shortcut, server);
47
+ },
31
48
  transform: {
32
49
  order: "pre",
33
50
  handler(code, id) {
package/dist/vite.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vite.js","names":[],"sources":["../src/vite.ts"],"sourcesContent":["/**\n * `deictic/vite`: deictic in Vite's dev server. Nothing runs in a build.\n *\n * Its transform runs `pre`, so each JSX module's host elements are marked with their place in the\n * source as written (`tools/locate.ts`). In the browser each marked module also imports the client\n * module, which starts the overlay with every plugin's panel: imports run first and only once, so no\n * line moves and frameworks that render their own HTML get it too. The endpoints are middleware on\n * Vite's server, and a place opens through Vite's own `/__open-in-editor`, so the editor is whichever\n * Vite already launches. A write reaches the page through Vite's usual update for the file.\n */\nimport type { Plugin } from 'vite';\n\nimport { endpoints, nodeMiddleware, redirect } from './tools/endpoints.ts';\nimport { clientModule, type DeicticOptions, mark, markAstro, prepare } from './tools/integration.ts';\n\nexport { clientModule, type DeicticOptions };\n\n/** The client module's ID, which a page can import itself where nothing it bundles is JSX (Astro's pages). */\nexport const CLIENT = 'virtual:deictic/client';\nconst CLIENT_ID = '\\0deictic/client';\n\nexport function deictic(options: DeicticOptions = {}): Plugin {\n const { plugins, shortcut } = prepare(options);\n let root = '';\n let base = '/';\n return {\n name: 'deictic',\n enforce: 'pre',\n apply: 'serve',\n // The client is the app's to bundle as it changes, not a dependency to prebundle once.\n config: () => ({ optimizeDeps: { exclude: ['deictic'] } }),\n configResolved(config) {\n root = config.root;\n base = config.base;\n },\n configureServer(server) {\n const handle = endpoints({\n root,\n plugins,\n base,\n open: (path, { line, column }) => redirect(`${base}__open-in-editor?${new URLSearchParams({ file: `${path}:${line}:${column}` })}`),\n });\n server.middlewares.use(nodeMiddleware(handle));\n },\n resolveId: (id) => (id === CLIENT ? CLIENT_ID : undefined),\n load: (id) => (id === CLIENT_ID ? clientModule(plugins, base, shortcut) : undefined),\n transform: {\n // First of all, not only first of the `pre` plugins: the React Compiler (`react({ compiler: true })`) is\n // `pre` too and compiles the JSX away, so after it there'd be no element to mark, wherever deictic is listed.\n order: 'pre',\n handler(code, id) {\n const [path = ''] = id.split('?');\n // An `.astro` component itself, not the styles and scripts Astro loads from it by a query.\n if (path.endsWith('.astro')) return id === path ? markAstro(code, path, root) : undefined;\n const browser = this.environment.config.consumer === 'client';\n return mark(code, path, root, browser ? `\\nimport ${JSON.stringify(CLIENT)};\\n` : '');\n },\n },\n };\n}\n\nexport default deictic;\n"],"mappings":";;;;AAkBA,MAAa,SAAS;AACtB,MAAM,YAAY;AAElB,SAAgB,QAAQ,UAA0B,CAAC,GAAW;CAC5D,MAAM,EAAE,SAAS,aAAa,QAAQ,OAAO;CAC7C,IAAI,OAAO;CACX,IAAI,OAAO;CACX,OAAO;EACL,MAAM;EACN,SAAS;EACT,OAAO;EAEP,eAAe,EAAE,cAAc,EAAE,SAAS,CAAC,SAAS,EAAE,EAAE;EACxD,eAAe,QAAQ;GACrB,OAAO,OAAO;GACd,OAAO,OAAO;EAChB;EACA,gBAAgB,QAAQ;GACtB,MAAM,SAAS,UAAU;IACvB;IACA;IACA;IACA,OAAO,MAAM,EAAE,MAAM,aAAa,SAAS,GAAG,KAAK,mBAAmB,IAAI,gBAAgB,EAAE,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,SAAS,CAAC,GAAG;GACpI,CAAC;GACD,OAAO,YAAY,IAAI,eAAe,MAAM,CAAC;EAC/C;EACA,YAAY,OAAQ,OAAA,2BAAgB,YAAY,KAAA;EAChD,OAAO,OAAQ,OAAO,YAAY,aAAa,SAAS,MAAM,QAAQ,IAAI,KAAA;EAC1E,WAAW;GAGT,OAAO;GACP,QAAQ,MAAM,IAAI;IAChB,MAAM,CAAC,OAAO,MAAM,GAAG,MAAM,GAAG;IAEhC,IAAI,KAAK,SAAS,QAAQ,GAAG,OAAO,OAAO,OAAO,UAAU,MAAM,MAAM,IAAI,IAAI,KAAA;IAChF,MAAM,UAAU,KAAK,YAAY,OAAO,aAAa;IACrD,OAAO,KAAK,MAAM,MAAM,MAAM,UAAU,YAAY,KAAK,UAAU,MAAM,EAAE,OAAO,EAAE;GACtF;EACF;CACF;AACF"}
1
+ {"version":3,"file":"vite.js","names":[],"sources":["../src/vite.ts"],"sourcesContent":["/**\n * `deictic/vite`: deictic in Vite's dev server. Nothing runs in a build, unless `standalone` asks for it.\n *\n * Its transform runs `pre`, so each JSX module's host elements are marked with their place in the\n * source as written (`tools/locate.ts`). In the browser each marked module also imports the client\n * module, which starts the overlay with every plugin's panel: imports run first and only once, so no\n * line moves and frameworks that render their own HTML get it too. The endpoints are middleware on\n * Vite's server, and a place opens through Vite's own `/__open-in-editor`, so the editor is whichever\n * Vite already launches. A write reaches the page through Vite's usual update for the file.\n */\nimport { resolve } from 'node:path';\n\nimport type { Plugin } from 'vite';\n\nimport { endpoints, nodeMiddleware, redirect } from './tools/endpoints.ts';\nimport { clientModule, type DeicticOptions, mark, markAstro, prepare } from './tools/integration.ts';\n\nexport { clientModule, type DeicticOptions };\n\nexport interface ViteOptions extends DeicticOptions {\n /**\n * deictic in a build too, for a page that shows it with no dev server behind it (a deployed demo): a module of\n * the page's, from the root, whose default export answers the overlay's requests there (a `Standalone`, from\n * `deictic`). The build's elements are marked and the overlay is in its bundle. The dev server answers as ever.\n * Without it, the default, nothing of deictic is in a build.\n */\n standalone?: string;\n}\n\n/** The client module's ID, which a page can import itself where nothing it bundles is JSX (Astro's pages). */\nexport const CLIENT = 'virtual:deictic/client';\nconst CLIENT_ID = '\\0deictic/client';\n\nexport function deictic(options: ViteOptions = {}): Plugin {\n const { plugins, shortcut } = prepare(options);\n let root = '';\n let base = '/';\n let building = false;\n return {\n name: 'deictic',\n enforce: 'pre',\n apply: (_, { command }) => command === 'serve' || options.standalone !== undefined,\n // The client is the app's to bundle as it changes, not a dependency to prebundle once.\n config: () => ({ optimizeDeps: { exclude: ['deictic'] } }),\n configResolved(config) {\n root = config.root;\n base = config.base;\n building = config.command === 'build';\n },\n configureServer(server) {\n const handle = endpoints({\n root,\n plugins,\n base,\n open: (path, { line, column }) => redirect(`${base}__open-in-editor?${new URLSearchParams({ file: `${path}:${line}:${column}` })}`),\n });\n server.middlewares.use(nodeMiddleware(handle));\n },\n resolveId: (id) => (id === CLIENT ? CLIENT_ID : undefined),\n load(id) {\n if (id !== CLIENT_ID) return undefined;\n // Only a build's page asks the module: the dev server is there to answer.\n const server = building && options.standalone !== undefined ? resolve(root, options.standalone).replaceAll('\\\\', '/') : undefined;\n return clientModule(plugins, base, shortcut, server);\n },\n transform: {\n // First of all, not only first of the `pre` plugins: the React Compiler (`react({ compiler: true })`) is\n // `pre` too and compiles the JSX away, so after it there'd be no element to mark, wherever deictic is listed.\n order: 'pre',\n handler(code, id) {\n const [path = ''] = id.split('?');\n // An `.astro` component itself, not the styles and scripts Astro loads from it by a query.\n if (path.endsWith('.astro')) return id === path ? markAstro(code, path, root) : undefined;\n const browser = this.environment.config.consumer === 'client';\n return mark(code, path, root, browser ? `\\nimport ${JSON.stringify(CLIENT)};\\n` : '');\n },\n },\n };\n}\n\nexport default deictic;\n"],"mappings":";;;;;;;;;;;;;;;AA8BA,MAAa,SAAS;AACtB,MAAM,YAAY;AAElB,SAAgB,QAAQ,UAAuB,CAAC,GAAW;CACzD,MAAM,EAAE,SAAS,aAAa,QAAQ,OAAO;CAC7C,IAAI,OAAO;CACX,IAAI,OAAO;CACX,IAAI,WAAW;CACf,OAAO;EACL,MAAM;EACN,SAAS;EACT,QAAQ,GAAG,EAAE,cAAc,YAAY,WAAW,QAAQ,eAAe,KAAA;EAEzE,eAAe,EAAE,cAAc,EAAE,SAAS,CAAC,SAAS,EAAE,EAAE;EACxD,eAAe,QAAQ;GACrB,OAAO,OAAO;GACd,OAAO,OAAO;GACd,WAAW,OAAO,YAAY;EAChC;EACA,gBAAgB,QAAQ;GACtB,MAAM,SAAS,UAAU;IACvB;IACA;IACA;IACA,OAAO,MAAM,EAAE,MAAM,aAAa,SAAS,GAAG,KAAK,mBAAmB,IAAI,gBAAgB,EAAE,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,SAAS,CAAC,GAAG;GACpI,CAAC;GACD,OAAO,YAAY,IAAI,eAAe,MAAM,CAAC;EAC/C;EACA,YAAY,OAAQ,OAAA,2BAAgB,YAAY,KAAA;EAChD,KAAK,IAAI;GACP,IAAI,OAAO,WAAW,OAAO,KAAA;GAE7B,MAAM,SAAS,YAAY,QAAQ,eAAe,KAAA,IAAY,QAAQ,MAAM,QAAQ,UAAU,CAAC,CAAC,WAAW,MAAM,GAAG,IAAI,KAAA;GACxH,OAAO,aAAa,SAAS,MAAM,UAAU,MAAM;EACrD;EACA,WAAW;GAGT,OAAO;GACP,QAAQ,MAAM,IAAI;IAChB,MAAM,CAAC,OAAO,MAAM,GAAG,MAAM,GAAG;IAEhC,IAAI,KAAK,SAAS,QAAQ,GAAG,OAAO,OAAO,OAAO,UAAU,MAAM,MAAM,IAAI,IAAI,KAAA;IAChF,MAAM,UAAU,KAAK,YAAY,OAAO,aAAa;IACrD,OAAO,KAAK,MAAM,MAAM,MAAM,UAAU,YAAY,KAAK,UAAU,MAAM,EAAE,OAAO,EAAE;GACtF;EACF;CACF;AACF"}
@@ -49,11 +49,11 @@ var client_default = defineClientPlugin({
49
49
  headers: { "content-type": type },
50
50
  body: new Blob(chunks, { type })
51
51
  });
52
- const { id, problem } = await res.json();
52
+ const { id, url, problem } = await res.json();
53
53
  if (id === void 0) throw new Error(`voice: ${problem ?? res.statusText}`);
54
54
  return {
55
55
  id,
56
- url: `${base}__deictic/plugins/voice/clip/${id}`,
56
+ url: url ?? `${base}__deictic/plugins/voice/clip/${id}`,
57
57
  duration,
58
58
  type
59
59
  };