deictic 0.8.0 → 0.9.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 (112) hide show
  1. package/API.md +73 -18
  2. package/README.md +1 -1
  3. package/dist/annotations/client.js +1 -1
  4. package/dist/cli.js +1 -1
  5. package/dist/cli.js.map +1 -1
  6. package/dist/client/index.d.ts +13 -13
  7. package/dist/client/index.d.ts.map +1 -1
  8. package/dist/client/index.js +11 -7
  9. package/dist/client/index.js.map +1 -1
  10. package/dist/react/client.d.ts +19 -0
  11. package/dist/react/client.d.ts.map +1 -0
  12. package/dist/react/client.js +504 -0
  13. package/dist/react/client.js.map +1 -0
  14. package/dist/react/index.d.ts +2 -0
  15. package/dist/react/index.js +1 -0
  16. package/dist/recommended/index.d.ts +15 -7
  17. package/dist/recommended/index.d.ts.map +1 -1
  18. package/dist/recommended/index.js +1 -1
  19. package/dist/recordings/client.d.ts.map +1 -1
  20. package/dist/recordings/client.js +48 -5
  21. package/dist/recordings/client.js.map +1 -1
  22. package/dist/screenshots/client.d.ts +9 -1
  23. package/dist/screenshots/client.d.ts.map +1 -1
  24. package/dist/screenshots/rrweb.d.ts +0 -6
  25. package/dist/screenshots/rrweb.d.ts.map +1 -1
  26. package/dist/screenshots/rrweb.js +53 -10
  27. package/dist/screenshots/rrweb.js.map +1 -1
  28. package/dist/shared/board.js +1 -1
  29. package/dist/shared/canvas.js +30 -0
  30. package/dist/shared/canvas.js.map +1 -0
  31. package/dist/shared/client.js +44 -2
  32. package/dist/shared/client.js.map +1 -1
  33. package/dist/shared/dom.js +7 -1
  34. package/dist/shared/dom.js.map +1 -1
  35. package/dist/shared/drawer.js +1 -1
  36. package/dist/shared/endpoints.js +1 -1
  37. package/dist/shared/find.js +6 -1
  38. package/dist/shared/find.js.map +1 -1
  39. package/dist/shared/frame.js +5 -2
  40. package/dist/shared/frame.js.map +1 -1
  41. package/dist/shared/index.d.ts +6 -0
  42. package/dist/shared/index.d.ts.map +1 -1
  43. package/dist/shared/index10.d.ts +70 -0
  44. package/dist/shared/index10.d.ts.map +1 -0
  45. package/dist/shared/index3.d.ts +11 -0
  46. package/dist/shared/index3.d.ts.map +1 -1
  47. package/dist/shared/index7.d.ts +92 -312
  48. package/dist/shared/index7.d.ts.map +1 -1
  49. package/dist/shared/index8.d.ts +324 -47
  50. package/dist/shared/index8.d.ts.map +1 -1
  51. package/dist/shared/index9.d.ts +45 -63
  52. package/dist/shared/index9.d.ts.map +1 -1
  53. package/dist/shared/init.js +15 -11
  54. package/dist/shared/init.js.map +1 -1
  55. package/dist/shared/marks.js +7 -1
  56. package/dist/shared/marks.js.map +1 -1
  57. package/dist/shared/package.js +3 -1
  58. package/dist/shared/packages.js +1 -1
  59. package/dist/shared/playwright.js +59 -3
  60. package/dist/shared/playwright.js.map +1 -1
  61. package/dist/shared/react.js +25 -0
  62. package/dist/shared/react.js.map +1 -0
  63. package/dist/shared/recommended.js +6 -3
  64. package/dist/shared/recommended.js.map +1 -1
  65. package/dist/shared/recording.js +80 -3
  66. package/dist/shared/recording.js.map +1 -1
  67. package/dist/shared/recordings.js +30 -2
  68. package/dist/shared/recordings.js.map +1 -1
  69. package/dist/shared/screenshots.js.map +1 -1
  70. package/dist/shared/src.js.map +1 -1
  71. package/dist/shared/task.js +1 -0
  72. package/dist/shared/task.js.map +1 -1
  73. package/dist/shared/tasks.js +11 -0
  74. package/dist/shared/tasks.js.map +1 -1
  75. package/dist/tailwind/client.d.ts +1 -1
  76. package/dist/tailwind/index.d.ts +1 -1
  77. package/dist/tasks/client.d.ts +1 -1
  78. package/dist/tasks/client.js +45 -19
  79. package/dist/tasks/client.js.map +1 -1
  80. package/dist/tasks/index.d.ts +1 -1
  81. package/dist/voice/client.d.ts +1 -1
  82. package/dist/voice/client.js +1 -1
  83. package/dist/voice/index.d.ts +1 -1
  84. package/package.json +25 -1
  85. package/src/cli/bun.ts +2 -2
  86. package/src/cli/find.ts +5 -1
  87. package/src/cli/frame.ts +6 -3
  88. package/src/cli/init.ts +14 -9
  89. package/src/cli/recording.ts +90 -4
  90. package/src/cli/task.ts +4 -0
  91. package/src/cli.ts +13 -6
  92. package/src/client/dom.ts +14 -0
  93. package/src/client/index.ts +21 -14
  94. package/src/index.ts +6 -0
  95. package/src/plugins/react/client.ts +162 -0
  96. package/src/plugins/react/index.ts +130 -0
  97. package/src/plugins/react/renders.ts +219 -0
  98. package/src/plugins/react/serialize.ts +139 -0
  99. package/src/plugins/react/timeline.ts +143 -0
  100. package/src/plugins/recommended/index.ts +17 -5
  101. package/src/plugins/recordings/client.ts +64 -4
  102. package/src/plugins/recordings/marks.ts +7 -0
  103. package/src/plugins/recordings/replay.ts +30 -2
  104. package/src/plugins/screenshots/canvas.ts +27 -0
  105. package/src/plugins/screenshots/client.ts +42 -2
  106. package/src/plugins/screenshots/index.ts +11 -0
  107. package/src/plugins/screenshots/playwright.ts +90 -4
  108. package/src/plugins/screenshots/rrweb.ts +57 -9
  109. package/src/plugins/screenshots/states.ts +26 -0
  110. package/src/plugins/tasks/client.ts +41 -6
  111. package/src/plugins/tasks/composer.ts +24 -7
  112. package/src/plugins/tasks/index.ts +16 -2
@@ -1,2 +1,2 @@
1
- import { C as local, S as LocalOptions, _ as TasksOptions, a as Kept, b as tasks, c as Model, d as Placed, f as Removed, g as TaskBoard, h as TaskAdded, i as Edited, l as Op, m as Task, n as Answer, o as Listed, p as Reply, r as Attached, s as Marks, t as Added, u as Place, v as Thread, x as LocalBoard, y as Which } from "../shared/index7.js";
1
+ import { C as local, S as LocalOptions, _ as TasksOptions, a as Kept, b as tasks, c as Model, d as Placed, f as Removed, g as TaskBoard, h as TaskAdded, i as Edited, l as Op, m as Task, n as Answer, o as Listed, p as Reply, r as Attached, s as Marks, t as Added, u as Place, v as Thread, x as LocalBoard, y as Which } from "../shared/index8.js";
2
2
  export { Added, Answer, Attached, Edited, Kept, Listed, type LocalBoard, type LocalOptions, Marks, Model, Op, Place, Placed, Removed, Reply, Task, TaskAdded, TaskBoard, TasksOptions, Thread, Which, tasks as default, tasks, local };
@@ -1,4 +1,4 @@
1
- import { i as Voice } from "../shared/index8.js";
1
+ import { i as Voice } from "../shared/index9.js";
2
2
  declare const _default: import("deictic").ClientPlugin<never, never, Voice>;
3
3
  export { _default as default };
4
4
  //# sourceMappingURL=client.d.ts.map
@@ -1,4 +1,4 @@
1
- import { u as toolButton } from "../shared/dom.js";
1
+ import { f as toolButton } from "../shared/dom.js";
2
2
  import { n as playMark, r as trayed } from "../shared/drawer.js";
3
3
  import { n as liveWaveform } from "../shared/waveform.js";
4
4
  import { n as defineClientPlugin } from "../shared/src.js";
@@ -1,2 +1,2 @@
1
- import { a as VoiceOptions, i as Voice, n as Clips, o as voice, r as Take, t as Clip } from "../shared/index8.js";
1
+ import { a as VoiceOptions, i as Voice, n as Clips, o as voice, r as Take, t as Clip } from "../shared/index9.js";
2
2
  export { Clip, Clips, Take, Voice, VoiceOptions, voice as default, voice };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deictic",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Point at an element in your running app and leave a task about it for your agent.",
5
5
  "keywords": [
6
6
  "annotations",
@@ -204,6 +204,20 @@
204
204
  "default": "./dist/network/client.js"
205
205
  }
206
206
  },
207
+ "./react": {
208
+ "deictic@dev": "./src/plugins/react/index.ts",
209
+ "default": {
210
+ "types": "./dist/react/index.d.ts",
211
+ "default": "./dist/react/index.js"
212
+ }
213
+ },
214
+ "./react/client": {
215
+ "deictic@dev": "./src/plugins/react/client.ts",
216
+ "default": {
217
+ "types": "./dist/react/client.d.ts",
218
+ "default": "./dist/react/client.js"
219
+ }
220
+ },
207
221
  "./recommended": {
208
222
  "deictic@dev": "./src/plugins/recommended/index.ts",
209
223
  "default": {
@@ -267,11 +281,13 @@
267
281
  "@rrweb/rrweb-plugin-network-record": "2.2.2",
268
282
  "@rspack/core": "2.3.3",
269
283
  "@types/bun": "^1.4.5",
284
+ "@types/react": "^19.3.0",
270
285
  "@vercel/board": "^0.54.0",
271
286
  "@vitejs/plugin-react": "^6.3.0",
272
287
  "astro": "^7.4.13",
273
288
  "babel-loader": "^10.1.1",
274
289
  "babel-plugin-react-compiler": "^1.0.0",
290
+ "bippy": "0.7.3",
275
291
  "launch-editor": "2.14.2",
276
292
  "modern-screenshot": "^4.7.0",
277
293
  "next": "^16.4.6",
@@ -296,10 +312,12 @@
296
312
  "@rspack/core": ">=1",
297
313
  "@vercel/board": ">=0.53.0",
298
314
  "astro": ">=5",
315
+ "bippy": "^0.7.3",
299
316
  "launch-editor": "^2.9.0",
300
317
  "modern-screenshot": "^4.7.0",
301
318
  "next": ">=16",
302
319
  "playwright-core": "^1.50.0",
320
+ "react": ">=18",
303
321
  "rrweb": "^2.2.2",
304
322
  "rrweb-player": "^2.2.2",
305
323
  "rrweb-snapshot": "^2.2.2",
@@ -322,6 +340,9 @@
322
340
  "astro": {
323
341
  "optional": true
324
342
  },
343
+ "bippy": {
344
+ "optional": true
345
+ },
325
346
  "launch-editor": {
326
347
  "optional": true
327
348
  },
@@ -334,6 +355,9 @@
334
355
  "playwright-core": {
335
356
  "optional": true
336
357
  },
358
+ "react": {
359
+ "optional": true
360
+ },
337
361
  "rrweb": {
338
362
  "optional": true
339
363
  },
package/src/cli/bun.ts CHANGED
@@ -16,11 +16,11 @@ import { addFirst, addImports, eolOf } from './edit.ts';
16
16
  export const MODULE = 'deictic.plugin.ts';
17
17
 
18
18
  export const PLUGIN = `import { deictic } from 'deictic/bun';
19
- import { recommended } from 'deictic/recommended';
19
+ import { deicticRecommended } from 'deictic/recommended';
20
20
 
21
21
  // One module for both: bunfig.toml names it as the dev server's bundler plugin, and the server spreads its routes,
22
22
  // deictic's endpoints, into its own.
23
- export default deictic({ plugins: recommended() });
23
+ export default deictic({ plugins: deicticRecommended() });
24
24
  `;
25
25
 
26
26
  const SOURCE = /\.[cm]?[jt]sx?$/;
package/src/cli/find.ts CHANGED
@@ -140,7 +140,11 @@ export async function fromProject<T>(...names: string[]): Promise<T> {
140
140
  const project = createRequire(join(process.cwd(), 'package.json'));
141
141
  for (const name of names) {
142
142
  try {
143
- return (await import(pathToFileURL(project.resolve(name)).href)) as T;
143
+ const module = (await import(pathToFileURL(project.resolve(name)).href)) as Record<string, unknown>;
144
+ // A CommonJS package whose exports Node can't name, as playwright-core's `module.exports = require(…)`, has
145
+ // them on `default` alone.
146
+ const exported = module.default;
147
+ return (typeof exported === 'object' && exported !== null ? { ...exported, ...module } : module) as T;
144
148
  } catch {
145
149
  // Not this one: the next name.
146
150
  }
package/src/cli/frame.ts CHANGED
@@ -44,15 +44,18 @@ export async function run(ref: string, values: { nth: string; at?: string[]; eve
44
44
 
45
45
  const playwright = await fromProject<{ chromium: typeof chromium }>('playwright-core', 'playwright');
46
46
  let browser: Browser | undefined;
47
+ // Why each browser didn't launch, said where none did.
48
+ const tried: string[] = [];
47
49
  for (const channel of [undefined, 'chrome', 'msedge']) {
48
50
  try {
49
51
  browser = await playwright.chromium.launch(channel === undefined ? {} : { channel });
50
52
  break;
51
- } catch {
52
- // Not this one: the next.
53
+ } catch (e) {
54
+ tried.push(`${channel ?? "Playwright's Chromium"}: ${(e instanceof Error ? e.message : String(e)).split('\n', 1)[0]}`);
53
55
  }
54
56
  }
55
- if (browser === undefined) fail('No Chromium to launch: npx playwright install chromium, or install Chrome or Edge.');
57
+ if (browser === undefined)
58
+ fail(`No Chromium to launch (${tried.join('; ')}): npx playwright install chromium, or install Chrome or Edge.`);
56
59
  try {
57
60
  // `bare`: the replay alone, at the recorded size, so a window that size shows it 1:1.
58
61
  const view = await browser.newPage({ viewport: kept.viewport });
package/src/cli/init.ts CHANGED
@@ -12,9 +12,9 @@ import { createInterface } from 'node:readline/promises';
12
12
  import MagicString from 'magic-string';
13
13
  import { type Expression, type ObjectExpression, parseSync, type Program } from 'oxc-parser';
14
14
 
15
- import { recommended } from '#src/plugins/recommended/index.ts';
15
+ import { deicticRecommended } from '#src/plugins/recommended/index.ts';
16
16
 
17
- import { installCommand, packageManager, readJson, runnerOf } from '#src/tools/packages.ts';
17
+ import { installCommand, installed, packageManager, readJson, runnerOf } from '#src/tools/packages.ts';
18
18
 
19
19
  import { fail } from './board.ts';
20
20
  import { addToBunfig, addToServer, BY_HAND, MODULE, PLUGIN, serverOf } from './bun.ts';
@@ -37,7 +37,7 @@ interface Setup {
37
37
  }
38
38
 
39
39
  const extensions = (base: string) => ['ts', 'mts', 'js', 'mjs', 'cts', 'cjs'].map((e) => `${base}.${e}`);
40
- const PLUGINS = '{ plugins: recommended() }';
40
+ const PLUGINS = '{ plugins: deicticRecommended() }';
41
41
 
42
42
  const SETUPS: Record<Exclude<Bundler, 'bun'>, Setup> = {
43
43
  next: {
@@ -109,9 +109,14 @@ export function bundlerOf(root: string): Bundler | undefined {
109
109
  return undefined;
110
110
  }
111
111
 
112
- /** What the recommended setup imports, for the bundler: launch-editor opens files under webpack, which has no launcher. */
113
- export function packagesFor(bundler: Bundler | undefined): string[] {
114
- const plugins = recommended().flatMap((p) => p.packages ?? []);
112
+ /**
113
+ * What the recommended setup imports, for the bundler and the project: launch-editor opens files under webpack, which
114
+ * has no launcher, and React's state is read only where it has React.
115
+ */
116
+ export function packagesFor(bundler: Bundler | undefined, root: string): string[] {
117
+ // Named in package.json and not installed yet, in a fresh checkout, or installed from a workspace's.
118
+ const react = dependenciesOf(root).has('react') || installed(root, 'react');
119
+ const plugins = deicticRecommended({ react: react ? {} : false }).flatMap((p) => p.packages ?? []);
115
120
  return ['deictic', ...plugins, ...(bundler === 'webpack' || bundler === 'rspack' ? ['launch-editor'] : [])];
116
121
  }
117
122
 
@@ -197,7 +202,7 @@ export function addToConfig(bundler: Exclude<Bundler, 'bun'>, file: string, code
197
202
  }
198
203
 
199
204
  const lines: [string, string][] = [
200
- ['{ recommended }', 'deictic/recommended'],
205
+ ['{ deicticRecommended }', 'deictic/recommended'],
201
206
  [`{ ${setup.name} }`, setup.from],
202
207
  ];
203
208
  addImports(out, program, code, lines, exported.commonjs);
@@ -259,7 +264,7 @@ export async function init(options: InitOptions): Promise<void> {
259
264
  const bundler = bundlerOf(root);
260
265
  const has = dependenciesOf(root);
261
266
 
262
- const wanted = packagesFor(bundler).filter((p) => !has.has(p));
267
+ const wanted = packagesFor(bundler, root).filter((p) => !has.has(p));
263
268
  const command = installCommand(manager, wanted, root);
264
269
  if (wanted.length === 0) {
265
270
  log('deictic: its packages are installed');
@@ -298,7 +303,7 @@ function configure(root: string, bundler: Bundler | undefined, dryRun: boolean,
298
303
  }
299
304
  const setup = SETUPS[bundler];
300
305
  const file = setup.files.map((f) => join(root, f)).find((f) => existsSync(f));
301
- const imports = `import { recommended } from 'deictic/recommended';\nimport { ${setup.name} } from '${setup.from}';`;
306
+ const imports = `import { deicticRecommended } from 'deictic/recommended';\nimport { ${setup.name} } from '${setup.from}';`;
302
307
  if (file === undefined) {
303
308
  log(`deictic: no ${setup.files[0]} here: add deictic to your ${bundler} config:\n\n${imports}\n${setup.snippet}\n`);
304
309
  return;
@@ -1,12 +1,19 @@
1
1
  /**
2
2
  * `deictic recording`: a recording as a timeline: the page, each click and field typed in (with the element's place
3
3
  * in the source), scrolls, resizes, each change to the marks (what was drawn, where, and the notes' text), the voice
4
- * clips, the page's console and its requests where the project records them, and the end. Or the part of it asked
5
- * for: `--only`, `--problems`, `--from`, `--to`, `--around`, `--grep`, and `--full` for all of each line.
4
+ * clips, the page's console and its requests where the project records them, React's commits where the recording had
5
+ * them on, and the end. Or the part of it asked
6
+ * for: `--only`, `--problems`, `--from`, `--to`, `--around`, `--grep`, `--all`, and `--full` for all of each line.
7
+ *
8
+ * Asked for nothing, it's what the person did and what went wrong: the page's requests, its console's lines and
9
+ * React's commits, which a dev server makes hundreds of, are left out where they're not a problem, and counted at
10
+ * the end with what lists them. An agent asks for them where the task needs them. `--json` has every line.
6
11
  */
7
12
  import { relative } from 'node:path';
8
13
 
9
14
  import type { Shape } from '#src/plugins/annotations/index.ts';
15
+ import type { Commit } from '#src/plugins/react/index.ts';
16
+ import { REACT } from '#src/plugins/recordings/marks.ts';
10
17
 
11
18
  import { clock, fail, ME } from './board.ts';
12
19
  import { loadRecording } from './find.ts';
@@ -56,7 +63,7 @@ interface Data {
56
63
  trace?: string[];
57
64
  requests?: Request[];
58
65
  isInitial?: boolean;
59
- };
66
+ } & Partial<Commit> & { on?: boolean };
60
67
  source?: number;
61
68
  type?: number;
62
69
  id?: number;
@@ -91,6 +98,57 @@ interface Line {
91
98
  before?: string;
92
99
  marks?: Shape[];
93
100
  node?: number;
101
+ /** A React commit entry's components, one line each: under it with `--full`. */
102
+ details?: string[];
103
+ }
104
+
105
+ /**
106
+ * The kinds left out of a timeline asked for nothing in particular, where a line of them isn't a problem: a dev
107
+ * server's page makes hundreds of requests (its modules, its hot updates), logs what its tools do, and commits
108
+ * React each frame it animates. Counted, with what lists them.
109
+ */
110
+ const QUIET = [
111
+ { kind: 'request', noun: 'request' },
112
+ { kind: 'console', noun: 'console line' },
113
+ { kind: 'react', noun: 'React line' },
114
+ ];
115
+
116
+ /** A commit past this took longer than a frame: a problem, as it's what makes a page stutter. */
117
+ const FRAME = 16;
118
+
119
+ const ms = (n: number) => `${n < 10 ? n.toFixed(1) : round(n)}ms`;
120
+
121
+ /** A React commit entry, as a line: how long, why it ran, and what rendered, the slowest first. */
122
+ function commitLine(c: Partial<Commit>): Pick<Line, 'text' | 'details' | 'problem'> {
123
+ const components = c.components ?? [];
124
+ const many = (c.commits ?? 1) > 1;
125
+ const head = [
126
+ c.priority,
127
+ many ? `${c.commits} commits${c.over === undefined ? '' : ` over ${(c.over / 1000).toFixed(1)}s`}` : undefined,
128
+ c.slowest === undefined ? undefined : `slowest ${ms(c.slowest)}`,
129
+ ]
130
+ .filter(Boolean)
131
+ .join(', ');
132
+ // One slow commit is what makes a page stutter, not many quick ones.
133
+ const slow = c.slowest ?? c.ms;
134
+ const named = components.map(
135
+ (r) => `${r.name}${(r.count ?? 1) > 1 ? ` ×${r.count}` : ''}${r.selfMs === undefined ? '' : ` ${ms(r.selfMs)}`} (${r.why})`,
136
+ );
137
+ const rest = c.more === undefined ? '' : named.length === 0 ? `${c.more} components` : `, and ${c.more} more`;
138
+ return {
139
+ text: `${c.ms === undefined ? 'commit' : ms(c.ms)}${head === '' ? '' : ` (${head})`}: ${named.join(', ')}${rest}`,
140
+ details: components.map((r) =>
141
+ [
142
+ `${r.name}${(r.count ?? 1) > 1 ? ` ×${r.count}` : ''}`,
143
+ r.at,
144
+ r.ms === undefined ? undefined : `${ms(r.ms)} with what it rendered`,
145
+ r.why,
146
+ ]
147
+ .filter(Boolean)
148
+ .join(' · '),
149
+ ),
150
+ ...(slow !== undefined && slow > FRAME ? { problem: true } : {}),
151
+ };
94
152
  }
95
153
 
96
154
  type Point = { x: number; y: number };
@@ -261,6 +319,10 @@ function timelineOf(events: Event[], voice: { id: string; at: number; duration:
261
319
  });
262
320
  }
263
321
  }
322
+ if (e.type === 5 && d.tag === REACT) {
323
+ if (payload.on !== undefined) push(t, 'react', payload.on ? 'commits recorded from here' : 'commits no longer recorded');
324
+ else push(t, 'react', '', commitLine(payload));
325
+ }
264
326
  if (e.type === 5 && d.tag === 'deictic.end') push(t, 'end', 'recording stopped');
265
327
  if (e.type !== 3) continue;
266
328
  if (d.source === 0) {
@@ -328,6 +390,7 @@ function shortener(page: string): (text: string) => string {
328
390
  export interface Options {
329
391
  nth: string;
330
392
  json?: boolean;
393
+ all?: boolean;
331
394
  only?: string[];
332
395
  problems?: boolean;
333
396
  from?: string;
@@ -358,6 +421,19 @@ export async function run(named: string, values: Options): Promise<void> {
358
421
  const grep = values.grep?.toLowerCase();
359
422
  // `console` is every level's lines, `click` a right or a double one too.
360
423
  const isKind = (kind: string, asked: string) => kind === asked || kind.startsWith(`${asked}.`) || kind.endsWith(`-${asked}`);
424
+ // Asked for nothing in particular: what the person did and what went wrong, the rest counted. A slice of time, a
425
+ // word or kinds asked for are every line of it.
426
+ const whole = values.all === true || only.length > 0 || from !== undefined || to !== undefined || grep !== undefined;
427
+ const left = new Map<string, { count: number; noun: string }>();
428
+ const listed = (e: Line) => {
429
+ if (whole || e.problem === true) return true;
430
+ const quiet = QUIET.find((q) => isKind(e.kind, q.kind));
431
+ if (quiet === undefined) return true;
432
+ const held = left.get(quiet.kind) ?? { count: 0, noun: quiet.noun };
433
+ held.count++;
434
+ left.set(quiet.kind, held);
435
+ return false;
436
+ };
361
437
  const shown = timeline.filter(
362
438
  (e) =>
363
439
  (only.length === 0 || only.some((asked) => isKind(e.kind, asked))) &&
@@ -366,6 +442,8 @@ export async function run(named: string, values: Options): Promise<void> {
366
442
  (to === undefined || e.t <= to) &&
367
443
  (grep === undefined || `${e.kind} ${e.text}`.toLowerCase().includes(grep)),
368
444
  );
445
+ // Not in `--json`, which is for a script, and has every line it was asked for.
446
+ const listing = values.json === true ? shown : shown.filter(listed);
369
447
 
370
448
  const colorScheme = kept.colorScheme ?? 'light';
371
449
  const startedAt = new Date(kept.startedAt ?? events[0]!.timestamp).toISOString();
@@ -378,14 +456,17 @@ export async function run(named: string, values: Options): Promise<void> {
378
456
  console.log(`viewport ${kept.viewport.width}×${kept.viewport.height}, ${colorScheme}, started ${startedAt}`);
379
457
  if (replay !== undefined) console.log(`replays at ${replay} (add ?t=<seconds> to open it paused there)`);
380
458
  if (shown.length < timeline.length) console.log(`${shown.length} of its ${timeline.length} lines, as asked`);
459
+ else if (listing.length < shown.length)
460
+ console.log(`${listing.length} of its ${timeline.length} lines: what the person did, and what went wrong`);
381
461
  console.log();
382
462
  const short = shortener(kept.page);
383
463
  const under = (line: string) => console.log(`${' '.repeat(22)}${short(line)}`);
384
- for (const e of shown) {
464
+ for (const e of listing) {
385
465
  console.log(`${e.at.padStart(6)} ${e.kind.padEnd(13)} ${short(e.text)}`);
386
466
  // Where a warning or an error came from, its nearest few places: all of them, and every line's, with `--full`.
387
467
  if (e.trace && (values.full === true || e.problem === true))
388
468
  for (const line of values.full ? e.trace : e.trace.slice(0, 5)) under(`at ${line}`);
469
+ if (values.full === true) for (const line of e.details ?? []) under(line);
389
470
  if (values.full !== true || e.request === undefined) continue;
390
471
  const r = e.request;
391
472
  if (e.before !== undefined) under(e.before);
@@ -398,6 +479,11 @@ export async function run(named: string, values: Options): Promise<void> {
398
479
  if (r.responseBody !== undefined) under(`response body ${r.responseBody}`);
399
480
  }
400
481
  if (shown.length === 0) console.log(timeline.length === 0 ? 'Nothing in it.' : 'No line of it is what was asked for.');
482
+ if (left.size > 0) {
483
+ const counted = [...left.entries()].map(([kind, { count, noun }]) => `${count} ${noun}${count === 1 ? '' : 's'} (--only ${kind})`);
484
+ console.log(`
485
+ Not listed: ${counted.join(', ')}; --all lists every line, --around <seconds> every line of a moment.`);
486
+ }
401
487
  // Where something went wrong, how to get to it: what led up to it, and what the page looked like.
402
488
  const problems = timeline.filter((e) => e.problem === true).length;
403
489
  if (problems === 0 || shown.length < timeline.length) return;
package/src/cli/task.ts CHANGED
@@ -183,6 +183,10 @@ function attachments(message: Message, out: string | undefined, indent: string,
183
183
  if (task === undefined) console.log(`${indent} ${ME} voice ${/^voice-(.+)\.\w+$/.exec(a.name)?.[1] ?? a.id} (speech)`);
184
184
  } else if (a.name === 'element.html') {
185
185
  console.log(`${indent}${a.name} (${kb}), the element's HTML as it rendered, if you need it${saved}`);
186
+ } else if (/^react(\.\d+)?\.json$/.test(a.name)) {
187
+ console.log(
188
+ `${indent}${a.name} (${kb}), the props, state and hooks of the components that wrote it, as React's DevTools has them, if the change depends on them${saved}`,
189
+ );
186
190
  } else {
187
191
  console.log(`${indent}${a.name} (${kb})${saved}`);
188
192
  }
package/src/cli.ts CHANGED
@@ -85,16 +85,23 @@ program
85
85
 
86
86
  program
87
87
  .command('recording')
88
- .description('a recording as a timeline, or the part of it asked for')
88
+ .description(
89
+ "a recording as a timeline: what the person did and what went wrong, with a count of the page's other requests, console lines and React commits; or the part of it asked for",
90
+ )
89
91
  .argument('<recording>', RECORDING)
90
92
  .option('--nth <n>', "a task's nth recording", '1')
91
- .option('--only <kinds>', 'these kinds of line: console, request, page, click, input, scroll, resize, marks, voice (repeatable)', all)
92
- .option('--problems', 'errors, warnings and requests that failed')
93
+ .option(
94
+ '--only <kinds>',
95
+ 'these kinds of line: console, request, react, page, click, input, scroll, resize, marks, voice (repeatable)',
96
+ all,
97
+ )
98
+ .option('--all', 'every line: every request, console line and React commit too')
99
+ .option('--problems', 'errors, warnings, requests that failed and React commits slower than a frame')
93
100
  .option('--from <seconds>', 'from this far in')
94
101
  .option('--to <seconds>', 'to this far in')
95
- .option('--around <seconds>', 'the 3 seconds either side of this')
96
- .option('--grep <text>', 'lines with this in them, in any case')
97
- .option('--full', "all of each line: where it was logged from, a request's headers and bodies")
102
+ .option('--around <seconds>', 'every line of the 3 seconds either side of this')
103
+ .option('--grep <text>', 'lines with this in them, in any case, of every line')
104
+ .option('--full', "all of each line: where it was logged from, a request's headers and bodies, a React commit's components")
98
105
  .option('--json', 'as JSON')
99
106
  .action(async (ref: string, options) => (await import('./cli/recording.ts')).run(ref, options));
100
107
 
package/src/client/dom.ts CHANGED
@@ -68,3 +68,17 @@ export function controlFor(within: ParentNode, e: KeyboardEvent, loose = false):
68
68
 
69
69
  /** The key held with a letter for a command, as the platform has it, by the name `aria-keyshortcuts` gives it. */
70
70
  export const MOD = typeof navigator !== 'undefined' && /Mac|iP(?:hone|ad)/.test(navigator.platform) ? 'Meta' : 'Control';
71
+
72
+ /**
73
+ * What the page hears on `window` as the popup opens over it on an element (its `detail` a `PopupOpened`) and as
74
+ * it closes: for a page that moves on its own to hold still meanwhile, as deictic's site does. Not for one pinned.
75
+ */
76
+ export const POPUP_OPENED = 'deictic:open';
77
+ export const POPUP_CLOSED = 'deictic:close';
78
+
79
+ export interface PopupOpened {
80
+ /** The element it's open on. */
81
+ element: Element;
82
+ /** The plugin whose tab it opened at. */
83
+ tab: string;
84
+ }
@@ -24,7 +24,7 @@ import { gestureOf, type Shortcut } from '#src/shortcut.ts';
24
24
 
25
25
  import { dropAway, keepAway, keptAway } from './away.ts';
26
26
  import { named, tell } from './component.ts';
27
- import { ATTRIBUTE, div, nameOf, reduced, sameAs, targetOf } from './dom.ts';
27
+ import { ATTRIBUTE, div, nameOf, POPUP_CLOSED, POPUP_OPENED, type PopupOpened, reduced, sameAs, targetOf } from './dom.ts';
28
28
  import { drawerIn } from './drawer.ts';
29
29
  import { openLightbox } from './lightbox.ts';
30
30
  import { CLEAR, type Lighting, spotlight, spotOf } from './lighting.ts';
@@ -98,19 +98,8 @@ interface Started {
98
98
 
99
99
  let started: Started | undefined;
100
100
 
101
- /**
102
- * What the page hears on `window` as the popup opens over it on an element (its `detail` a `PopupOpened`) and as
103
- * it closes: for a page that moves on its own to hold still meanwhile, as deictic's site does. Not for one pinned.
104
- */
105
- export const POPUP_OPENED = 'deictic:open';
106
- export const POPUP_CLOSED = 'deictic:close';
107
-
108
- export interface PopupOpened {
109
- /** The element it's open on. */
110
- element: Element;
111
- /** The plugin whose tab it opened at. */
112
- tab: string;
113
- }
101
+ // The events the page hears as the popup opens and closes: kept beside the mark, where a plugin's page half reads them.
102
+ export { POPUP_CLOSED, POPUP_OPENED, type PopupOpened } from './dom.ts';
114
103
 
115
104
  /**
116
105
  * Opens the popup over the page on `element`, as deictic's own shortcut does: at `tab` (a plugin's name), or at the
@@ -430,6 +419,24 @@ export function start({ base, shortcut: own, plugins: given, server }: StartOpti
430
419
  );
431
420
  let press = {};
432
421
  let opened: object | undefined;
422
+ // The page as it is under the press, for whoever keeps it (`pressed`): before the page's own handlers, which may
423
+ // close what was open, and before the popup takes the pointer and the focus.
424
+ window.addEventListener(
425
+ 'pointerdown',
426
+ (e) => {
427
+ if (e.composedPath().includes(host) || pressedBy(e) === undefined) return;
428
+ const hit = hitAt(e.clientX, e.clientY);
429
+ if (hit === undefined) return;
430
+ for (const { plugin } of given) {
431
+ try {
432
+ plugin.pressed?.(contextOf(plugin.name), hit.el);
433
+ } catch (e) {
434
+ report(failed(plugin.name, 'keep what the page showed as it was pressed', e));
435
+ }
436
+ }
437
+ },
438
+ true,
439
+ );
433
440
  // Alt-click on a link would otherwise download it, and on a field focus it.
434
441
  window.addEventListener(
435
442
  'mousedown',
package/src/index.ts CHANGED
@@ -401,6 +401,12 @@ export interface ClientPlugin<Model = unknown, Op = unknown, Api = unknown> {
401
401
  * plugin pins each task where its element is. Answers what takes it away.
402
402
  */
403
403
  pointing?(context: ClientContext): () => void;
404
+ /**
405
+ * A shortcut's press on a marked element, before the page hears it and before the popup opens: the page as the
406
+ * person saw it, a tooltip still open under the pointer, a menu still focused. Called as the press goes down, so
407
+ * it must be quick; the screenshots plugin keeps what a shot needs here, and renders it later.
408
+ */
409
+ pressed?(context: ClientContext, element: Element): void;
404
410
  /** Draws into `panel`, inside deictic's shadow root. Returns what to undo on the page when the panel closes. */
405
411
  mount?: (panel: HTMLElement, context: PanelContext<Model, Op>) => (() => void) | void;
406
412
  }