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,13 +1,64 @@
1
1
  import { relative } from "node:path";
2
+ import "./marks.js";
2
3
  import { a as clock, l as fail, t as ME } from "./board.js";
3
4
  import { r as loadRecording } from "./find.js";
4
5
  // src/cli/recording.ts
5
6
  /**
6
7
  * `deictic recording`: a recording as a timeline: the page, each click and field typed in (with the element's place
7
8
  * in the source), scrolls, resizes, each change to the marks (what was drawn, where, and the notes' text), the voice
8
- * clips, the page's console and its requests where the project records them, and the end. Or the part of it asked
9
- * for: `--only`, `--problems`, `--from`, `--to`, `--around`, `--grep`, and `--full` for all of each line.
9
+ * clips, the page's console and its requests where the project records them, React's commits where the recording had
10
+ * them on, and the end. Or the part of it asked
11
+ * for: `--only`, `--problems`, `--from`, `--to`, `--around`, `--grep`, `--all`, and `--full` for all of each line.
12
+ *
13
+ * Asked for nothing, it's what the person did and what went wrong: the page's requests, its console's lines and
14
+ * React's commits, which a dev server makes hundreds of, are left out where they're not a problem, and counted at
15
+ * the end with what lists them. An agent asks for them where the task needs them. `--json` has every line.
10
16
  */
17
+ /**
18
+ * The kinds left out of a timeline asked for nothing in particular, where a line of them isn't a problem: a dev
19
+ * server's page makes hundreds of requests (its modules, its hot updates), logs what its tools do, and commits
20
+ * React each frame it animates. Counted, with what lists them.
21
+ */
22
+ const QUIET = [
23
+ {
24
+ kind: "request",
25
+ noun: "request"
26
+ },
27
+ {
28
+ kind: "console",
29
+ noun: "console line"
30
+ },
31
+ {
32
+ kind: "react",
33
+ noun: "React line"
34
+ }
35
+ ];
36
+ /** A commit past this took longer than a frame: a problem, as it's what makes a page stutter. */
37
+ const FRAME = 16;
38
+ const ms = (n) => `${n < 10 ? n.toFixed(1) : round(n)}ms`;
39
+ /** A React commit entry, as a line: how long, why it ran, and what rendered, the slowest first. */
40
+ function commitLine(c) {
41
+ const components = c.components ?? [];
42
+ const many = (c.commits ?? 1) > 1;
43
+ const head = [
44
+ c.priority,
45
+ many ? `${c.commits} commits${c.over === void 0 ? "" : ` over ${(c.over / 1e3).toFixed(1)}s`}` : void 0,
46
+ c.slowest === void 0 ? void 0 : `slowest ${ms(c.slowest)}`
47
+ ].filter(Boolean).join(", ");
48
+ const slow = c.slowest ?? c.ms;
49
+ const named = components.map((r) => `${r.name}${(r.count ?? 1) > 1 ? ` ×${r.count}` : ""}${r.selfMs === void 0 ? "" : ` ${ms(r.selfMs)}`} (${r.why})`);
50
+ const rest = c.more === void 0 ? "" : named.length === 0 ? `${c.more} components` : `, and ${c.more} more`;
51
+ return {
52
+ text: `${c.ms === void 0 ? "commit" : ms(c.ms)}${head === "" ? "" : ` (${head})`}: ${named.join(", ")}${rest}`,
53
+ details: components.map((r) => [
54
+ `${r.name}${(r.count ?? 1) > 1 ? ` ×${r.count}` : ""}`,
55
+ r.at,
56
+ r.ms === void 0 ? void 0 : `${ms(r.ms)} with what it rendered`,
57
+ r.why
58
+ ].filter(Boolean).join(" · ")),
59
+ ...slow !== void 0 && slow > FRAME ? { problem: true } : {}
60
+ };
61
+ }
11
62
  const round = Math.round;
12
63
  /** The marks, as data where the recording has it. */
13
64
  function shapeOf({ shape }) {
@@ -185,6 +236,10 @@ function timelineOf(events, voice) {
185
236
  ...payload.isInitial === true ? { before: "made as the page loaded, before this moment" } : {}
186
237
  });
187
238
  }
239
+ if (e.type === 5 && d.tag === "deictic.react") {
240
+ if (payload.on !== void 0) push(t, "react", payload.on ? "commits recorded from here" : "commits no longer recorded");
241
+ else push(t, "react", "", commitLine(payload));
242
+ }
188
243
  if (e.type === 5 && d.tag === "deictic.end") push(t, "end", "recording stopped");
189
244
  if (e.type !== 3) continue;
190
245
  if (d.source === 0) {
@@ -272,7 +327,22 @@ async function run(named, values) {
272
327
  const only = (values.only ?? []).flatMap((list) => list.split(",")).filter(Boolean);
273
328
  const grep = values.grep?.toLowerCase();
274
329
  const isKind = (kind, asked) => kind === asked || kind.startsWith(`${asked}.`) || kind.endsWith(`-${asked}`);
330
+ const whole = values.all === true || only.length > 0 || from !== void 0 || to !== void 0 || grep !== void 0;
331
+ const left = /* @__PURE__ */ new Map();
332
+ const listed = (e) => {
333
+ if (whole || e.problem === true) return true;
334
+ const quiet = QUIET.find((q) => isKind(e.kind, q.kind));
335
+ if (quiet === void 0) return true;
336
+ const held = left.get(quiet.kind) ?? {
337
+ count: 0,
338
+ noun: quiet.noun
339
+ };
340
+ held.count++;
341
+ left.set(quiet.kind, held);
342
+ return false;
343
+ };
275
344
  const shown = timeline.filter((e) => (only.length === 0 || only.some((asked) => isKind(e.kind, asked))) && (values.problems !== true || e.problem === true) && (from === void 0 || e.t >= from) && (to === void 0 || e.t <= to) && (grep === void 0 || `${e.kind} ${e.text}`.toLowerCase().includes(grep)));
345
+ const listing = values.json === true ? shown : shown.filter(listed);
276
346
  const colorScheme = kept.colorScheme ?? "light";
277
347
  const startedAt = new Date(kept.startedAt ?? events[0].timestamp).toISOString();
278
348
  if (values.json) {
@@ -297,12 +367,14 @@ async function run(named, values) {
297
367
  console.log(`viewport ${kept.viewport.width}×${kept.viewport.height}, ${colorScheme}, started ${startedAt}`);
298
368
  if (replay !== void 0) console.log(`replays at ${replay} (add ?t=<seconds> to open it paused there)`);
299
369
  if (shown.length < timeline.length) console.log(`${shown.length} of its ${timeline.length} lines, as asked`);
370
+ else if (listing.length < shown.length) console.log(`${listing.length} of its ${timeline.length} lines: what the person did, and what went wrong`);
300
371
  console.log();
301
372
  const short = shortener(kept.page);
302
373
  const under = (line) => console.log(`${" ".repeat(22)}${short(line)}`);
303
- for (const e of shown) {
374
+ for (const e of listing) {
304
375
  console.log(`${e.at.padStart(6)} ${e.kind.padEnd(13)} ${short(e.text)}`);
305
376
  if (e.trace && (values.full === true || e.problem === true)) for (const line of values.full ? e.trace : e.trace.slice(0, 5)) under(`at ${line}`);
377
+ if (values.full === true) for (const line of e.details ?? []) under(line);
306
378
  if (values.full !== true || e.request === void 0) continue;
307
379
  const r = e.request;
308
380
  if (e.before !== void 0) under(e.before);
@@ -311,6 +383,11 @@ async function run(named, values) {
311
383
  if (r.responseBody !== void 0) under(`response body ${r.responseBody}`);
312
384
  }
313
385
  if (shown.length === 0) console.log(timeline.length === 0 ? "Nothing in it." : "No line of it is what was asked for.");
386
+ if (left.size > 0) {
387
+ const counted = [...left.entries()].map(([kind, { count, noun }]) => `${count} ${noun}${count === 1 ? "" : "s"} (--only ${kind})`);
388
+ console.log(`
389
+ Not listed: ${counted.join(", ")}; --all lists every line, --around <seconds> every line of a moment.`);
390
+ }
314
391
  const problems = timeline.filter((e) => e.problem === true).length;
315
392
  if (problems === 0 || shown.length < timeline.length) return;
316
393
  const ref = task?.id ?? id;
@@ -1 +1 @@
1
- {"version":3,"file":"recording.js","names":[],"sources":["../../src/cli/recording.ts"],"sourcesContent":["/**\n * `deictic recording`: a recording as a timeline: the page, each click and field typed in (with the element's place\n * in the source), scrolls, resizes, each change to the marks (what was drawn, where, and the notes' text), the voice\n * clips, the page's console and its requests where the project records them, and the end. Or the part of it asked\n * for: `--only`, `--problems`, `--from`, `--to`, `--around`, `--grep`, and `--full` for all of each line.\n */\nimport { relative } from 'node:path';\n\nimport type { Shape } from '#src/plugins/annotations/index.ts';\n\nimport { clock, fail, ME } from './board.ts';\nimport { loadRecording } from './find.ts';\n\n/** A node of rrweb's snapshot. */\ninterface SnapNode {\n id: number;\n type: number;\n tagName?: string;\n textContent?: string;\n attributes?: Record<string, string>;\n childNodes?: SnapNode[];\n}\n\ninterface Known extends Omit<SnapNode, 'childNodes'> {\n parent: number | undefined;\n kids: number[];\n}\n\n/** A request rrweb's network plugin kept. */\ninterface Request {\n name: string;\n method?: string;\n initiatorType?: string;\n status?: number;\n duration?: number;\n requestHeaders?: Record<string, string>;\n responseHeaders?: Record<string, string>;\n requestBody?: string;\n responseBody?: string;\n}\n\n/** What rrweb's events carry that the timeline reads: each kind has some of it. */\ninterface Data {\n href?: string;\n width?: number;\n height?: number;\n node?: SnapNode;\n tag?: string;\n plugin?: string;\n payload?: {\n annotations?: Annotation[];\n svg?: string;\n href?: string;\n level?: string;\n payload?: string[];\n trace?: string[];\n requests?: Request[];\n isInitial?: boolean;\n };\n source?: number;\n type?: number;\n id?: number;\n x?: number;\n y?: number;\n adds?: { node: SnapNode; parentId: number }[];\n attributes?: { id: number; attributes: Record<string, string> }[];\n texts?: { id: number; value: string }[];\n isChecked?: boolean;\n text?: string;\n}\n\ninterface Event {\n type: number;\n timestamp: number;\n data: Data;\n}\n\ninterface Annotation {\n id?: string;\n shape: Shape;\n}\n\ninterface Line {\n t: number;\n at: string;\n kind: string;\n text: string;\n problem?: boolean;\n trace?: string[];\n request?: Request;\n before?: string;\n marks?: Shape[];\n node?: number;\n}\n\ntype Point = { x: number; y: number };\n\nconst round = Math.round;\n\n/** The marks, as data where the recording has it. */\nfunction shapeOf({ shape }: Annotation): string {\n const bounds = (points: Point[]) => {\n const xs = points.map((p) => p.x);\n const ys = points.map((p) => p.y);\n return `(${round(Math.min(...xs))},${round(Math.min(...ys))})–(${round(Math.max(...xs))},${round(Math.max(...ys))})`;\n };\n if (shape.kind === 'box') return `box ${bounds([shape, { x: shape.x + shape.width, y: shape.y + shape.height }])}`;\n if (shape.kind === 'arrow')\n return `arrow from (${round(shape.from.x)},${round(shape.from.y)}) to (${round(shape.to.x)},${round(shape.to.y)})`;\n if (shape.kind === 'pen') return `pen stroke over ${bounds(shape.points)}`;\n return `note at (${round(shape.at.x)},${round(shape.at.y)}): ${JSON.stringify(shape.text)}`;\n}\n\nconst pairs = (s: string): Point[] => [...s.matchAll(/(-?[\\d.]+)[ ,](-?[\\d.]+)/g)].map((m) => ({ x: Number(m[1]), y: Number(m[2]) }));\n\n/** The marks read off the SVG, for a recording older than the marks as data. */\nfunction shapesInSvg(svg: string): Annotation[] {\n const out: Annotation[] = [];\n const unescape = (t: string) => t.replaceAll('&lt;', '<').replaceAll('&gt;', '>').replaceAll('&quot;', '\"').replaceAll('&amp;', '&');\n for (const [, tag, attrs = '', inner = ''] of svg.matchAll(/<(rect|path|polyline|text)\\b([^>]*)>(?:(.*?)<\\/text>)?/g)) {\n const num = (name: string) => Number(new RegExp(`\\\\b${name}=\"(-?[\\\\d.]+)\"`).exec(attrs)?.[1]);\n if (tag === 'rect' && attrs.includes('fill=\"none\"'))\n out.push({ shape: { kind: 'box', x: num('x'), y: num('y'), width: num('width'), height: num('height') } });\n if (tag === 'path') {\n const [from, to] = pairs(/d=\"([^\"]*)\"/.exec(attrs)?.[1] ?? '');\n if (from !== undefined && to !== undefined) out.push({ shape: { kind: 'arrow', from, to } });\n }\n if (tag === 'polyline') out.push({ shape: { kind: 'pen', points: pairs(/points=\"([^\"]*)\"/.exec(attrs)?.[1] ?? '') } });\n if (tag === 'text') {\n const lines = [...inner.matchAll(/<tspan[^>]*>(.*?)<\\/tspan>/g)].map((l) => unescape(l[1] ?? ''));\n const xy = /x=\"(-?[\\d.]+)\" y=\"(-?[\\d.]+)\"/.exec(inner);\n out.push({ shape: { kind: 'note', at: { x: Number(xy?.[1] ?? 0), y: Number(xy?.[2] ?? 0) }, text: lines.join('\\n') } });\n }\n }\n return out;\n}\n\n/** The page's nodes by rrweb's IDs, from the full snapshot and each mutation: enough to name an element. */\nclass Nodes {\n #nodes = new Map<number, Known>();\n\n clear(): void {\n this.#nodes.clear();\n }\n\n add(node: SnapNode, parent: number | undefined): void {\n const { childNodes = [], ...rest } = node;\n this.#nodes.set(node.id, { ...rest, parent, kids: childNodes.map((c) => c.id) });\n for (const c of childNodes) this.add(c, node.id);\n }\n\n get(id: number): Known | undefined {\n return this.#nodes.get(id);\n }\n\n text(id: number, max = 60): string {\n let out = '';\n const walk = (n: number) => {\n const node = this.#nodes.get(n);\n if (node === undefined || out.length > max) return;\n if (node.type === 3) out += node.textContent ?? '';\n for (const k of node.kids) walk(k);\n };\n walk(id);\n const text = out.replace(/\\s+/g, ' ').trim();\n return text.length > max ? `${text.slice(0, max)}…` : text;\n }\n\n /** `<button> \"Save\" at src/App.tsx:9:7`: the element, its text, and the nearest place deictic marked. */\n describe(id: number | undefined): string {\n const node = id === undefined ? undefined : this.#nodes.get(id);\n if (id === undefined || node === undefined) return `node ${id}`;\n if (node.type === 0) return 'the page';\n let at: string | undefined;\n for (\n let n: Known | undefined = node;\n n !== undefined && at === undefined;\n n = n.parent === undefined ? undefined : this.#nodes.get(n.parent)\n )\n at = n.attributes?.['data-deictic'];\n const tag = node.tagName === undefined ? 'text' : `<${node.tagName}>`;\n const text = this.text(id);\n return `${tag}${text ? ` \"${text}\"` : ''}${at === undefined ? '' : ` at ${at}`}`;\n }\n}\n\n/** The page's console's arguments, each as JSON: a string without its quotes. */\nconst plain = (arg: string) => {\n try {\n const value: unknown = JSON.parse(arg);\n return typeof value === 'string' ? value : arg;\n } catch {\n return arg;\n }\n};\n\n/** Every line of the recording, in time. */\nfunction timelineOf(events: Event[], voice: { id: string; at: number; duration: number }[]): Line[] {\n const t0 = events[0]!.timestamp;\n const timeline: Line[] = [];\n const nodes = new Nodes();\n const push = (t: number, kind: string, text: string, extra: Partial<Line> = {}) =>\n timeline.push({ t, at: clock(t), kind, text, ...extra });\n let marks: Annotation[] = [];\n let scroll: { t: number; id: number | undefined; x: number; y: number } | undefined;\n let typing: { t: number; id: number | undefined; value: string } | undefined;\n const flushScroll = () => {\n if (scroll) push(scroll.t, 'scroll', `${nodes.describe(scroll.id)} to (${scroll.x},${scroll.y})`);\n scroll = undefined;\n };\n const flushTyping = () => {\n if (typing) push(typing.t, 'input', `${nodes.describe(typing.id)}: ${typing.value}`);\n typing = undefined;\n };\n\n for (const e of events) {\n const t = e.timestamp - t0;\n const d = e.data;\n const payload = d.payload ?? {};\n if (e.type === 4) push(t, 'page', `${d.href} at ${d.width}×${d.height}`);\n if (e.type === 2 && d.node !== undefined) {\n nodes.clear();\n nodes.add(d.node, undefined);\n }\n if (e.type === 5 && d.tag === 'deictic.annotations') {\n const now = payload.annotations ?? shapesInSvg(payload.svg ?? '');\n const key = (a: Annotation) => a.id ?? JSON.stringify(a.shape);\n const before = new Set(marks.map(key));\n const after = new Set(now.map(key));\n const added = now.filter((a) => !before.has(key(a)));\n const removed = marks.filter((a) => !after.has(key(a)));\n if (added.length > 0 || removed.length > 0) {\n // All of them cleared (a task added, the page left) is said as that: each was said as it was drawn.\n const gone = now.length === 0 && removed.length > 1 ? [`− all ${removed.length} marks`] : removed.map((a) => `− ${shapeOf(a)}`);\n const text = [...added.map((a) => `+ ${shapeOf(a)}`), ...gone].join('; ');\n push(t, 'marks', text, { marks: now.map((a) => a.shape) });\n }\n marks = now;\n }\n // The address changed with no load: a route of the app's.\n if (e.type === 5 && d.tag === 'deictic.page') push(t, 'page', `${payload.href} (a route change, no load)`);\n // The page's console, and errors nothing caught (rrweb's console plugin), and where it was logged from, which goes\n // under a warning or an error.\n if (e.type === 6 && d.plugin === 'rrweb/console@1') {\n const level = payload.level ?? 'log';\n push(t, `console.${level}`, (payload.payload ?? []).map(plain).join(' '), {\n trace: payload.trace ?? [],\n ...(['error', 'assert', 'warn'].includes(level) ? { problem: true } : {}),\n });\n }\n // The page's requests (rrweb's network plugin), masked as they were kept: each as it ended. One the browser\n // reported of itself has no method; headers and bodies, where kept, are in `--json`.\n if (e.type === 6 && d.plugin === 'rrweb/network@1') {\n for (const r of payload.requests ?? []) {\n const took = r.duration !== undefined && Number.isFinite(r.duration) ? ` in ${round(r.duration)} ms` : '';\n const status = r.status === undefined || r.status === 0 ? 'no status (failed, blocked, or another origin’s)' : r.status;\n push(t, 'request', `${r.method ?? r.initiatorType ?? ''} ${r.name} → ${status}${took}`.trim(), {\n request: r,\n ...((r.status ?? 0) >= 400 ? { problem: true } : {}),\n ...(payload.isInitial === true ? { before: 'made as the page loaded, before this moment' } : {}),\n });\n }\n }\n if (e.type === 5 && d.tag === 'deictic.end') push(t, 'end', 'recording stopped');\n if (e.type !== 3) continue;\n if (d.source === 0) {\n for (const a of d.adds ?? []) nodes.add(a.node, a.parentId);\n for (const a of d.attributes ?? []) {\n const node = nodes.get(a.id);\n if (node) node.attributes = { ...node.attributes, ...a.attributes };\n }\n for (const x of d.texts ?? []) {\n const node = nodes.get(x.id);\n if (node) node.textContent = x.value;\n }\n }\n if (d.source === 2 && (d.type === 2 || d.type === 3 || d.type === 4)) {\n flushScroll();\n flushTyping();\n const what = { 2: 'click', 3: 'right-click', 4: 'double-click' }[d.type];\n // A click a key made (Enter on a button) has no position.\n const where = d.x === 0 && d.y === 0 ? ' by keyboard' : ` at (${round(d.x ?? 0)},${round(d.y ?? 0)}) in the viewport`;\n push(t, what, `${nodes.describe(d.id)}${where}`, { node: d.id });\n }\n if (d.source === 3) {\n if (scroll && scroll.id !== d.id) flushScroll();\n scroll = { t: scroll?.t ?? t, id: d.id, x: round(d.x ?? 0), y: round(d.y ?? 0) };\n }\n if (d.source === 4) push(t, 'resize', `viewport ${d.width}×${d.height}`);\n if (d.source === 5) {\n if (typing && typing.id !== d.id) flushTyping();\n const value = d.isChecked !== undefined && d.text === undefined ? String(d.isChecked) : JSON.stringify(d.text);\n typing = { t: typing?.t ?? t, id: d.id, value };\n }\n }\n flushScroll();\n flushTyping();\n for (const c of voice) push(c.at, 'voice', `clip ${c.id}, ${clock(c.duration)} long, until ${clock(c.at + c.duration)}`);\n return timeline.sort((a, b) => a.t - b.t);\n}\n\n/**\n * The page's own URLs as paths, in a line of text: `http://localhost:5180/src/App.tsx?t=1712:9:7` is `/src/App.tsx:9:7`,\n * and a file Vite serves from outside its root (`/@fs/S:/…/dist/client.js`) is that file's path from here. The header\n * says the origin once; `--json` keeps every URL whole.\n */\nfunction shortener(page: string): (text: string) => string {\n let origin: string;\n try {\n origin = new URL(page).origin;\n } catch {\n return (text) => text;\n }\n const quoted = origin.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n // A Windows path has a drive's colon in it, which a line and column also follow.\n const fs = new RegExp(`${quoted}/@fs/([A-Za-z]:)?([^\\\\s?:)]+)`, 'g');\n const own = new RegExp(`${quoted}(?=/)`, 'g');\n return (text) =>\n text\n .replace(fs, (_, drive: string | undefined, rest: string) =>\n relative(process.cwd(), drive ? `${drive}${rest}` : `/${rest}`).replaceAll('\\\\', '/'),\n )\n .replace(own, '')\n // A bundler's cache-busting query, between a module's path and its line.\n .replace(/(\\.[cm]?[jt]sx?)\\?[tv]=[\\w.-]+/g, '$1');\n}\n\nexport interface Options {\n nth: string;\n json?: boolean;\n only?: string[];\n problems?: boolean;\n from?: string;\n to?: string;\n around?: string;\n grep?: string;\n full?: boolean;\n}\n\nexport async function run(named: string, values: Options): Promise<void> {\n const { kept, id, replay, task } = await loadRecording(named, Number(values.nth));\n const events = kept.events as Event[];\n if (!Array.isArray(events) || events.length === 0) fail(`Recording ${id} has no events.`);\n const timeline = timelineOf(events, kept.voice ?? []);\n\n // The part asked for. Seconds, as the replay's `?t=` and `frame --at` take them.\n const seconds = (name: 'from' | 'to' | 'around') => {\n const given = values[name];\n if (given === undefined) return undefined;\n const value = Number(given);\n if (!Number.isFinite(value)) fail(`--${name} takes seconds from the recording's start, as 12 or 4.5: not ${given}`);\n return value * 1000;\n };\n const around = seconds('around');\n const from = seconds('from') ?? (around === undefined ? undefined : around - 3000);\n const to = seconds('to') ?? (around === undefined ? undefined : around + 3000);\n const only = (values.only ?? []).flatMap((list) => list.split(',')).filter(Boolean);\n const grep = values.grep?.toLowerCase();\n // `console` is every level's lines, `click` a right or a double one too.\n const isKind = (kind: string, asked: string) => kind === asked || kind.startsWith(`${asked}.`) || kind.endsWith(`-${asked}`);\n const shown = timeline.filter(\n (e) =>\n (only.length === 0 || only.some((asked) => isKind(e.kind, asked))) &&\n (values.problems !== true || e.problem === true) &&\n (from === undefined || e.t >= from) &&\n (to === undefined || e.t <= to) &&\n (grep === undefined || `${e.kind} ${e.text}`.toLowerCase().includes(grep)),\n );\n\n const colorScheme = kept.colorScheme ?? 'light';\n const startedAt = new Date(kept.startedAt ?? events[0]!.timestamp).toISOString();\n if (values.json) {\n const head = { id, page: kept.page, viewport: kept.viewport, colorScheme, startedAt, duration: kept.duration, replay, task: task?.id };\n console.log(JSON.stringify({ ...head, lines: timeline.length, timeline: shown }, null, 2));\n return;\n }\n console.log(`Recording ${id}${task ? ` on task #${task.id}` : ''}: ${clock(kept.duration)} of ${kept.page}`);\n console.log(`viewport ${kept.viewport.width}×${kept.viewport.height}, ${colorScheme}, started ${startedAt}`);\n if (replay !== undefined) console.log(`replays at ${replay} (add ?t=<seconds> to open it paused there)`);\n if (shown.length < timeline.length) console.log(`${shown.length} of its ${timeline.length} lines, as asked`);\n console.log();\n const short = shortener(kept.page);\n const under = (line: string) => console.log(`${' '.repeat(22)}${short(line)}`);\n for (const e of shown) {\n console.log(`${e.at.padStart(6)} ${e.kind.padEnd(13)} ${short(e.text)}`);\n // Where a warning or an error came from, its nearest few places: all of them, and every line's, with `--full`.\n if (e.trace && (values.full === true || e.problem === true))\n for (const line of values.full ? e.trace : e.trace.slice(0, 5)) under(`at ${line}`);\n if (values.full !== true || e.request === undefined) continue;\n const r = e.request;\n if (e.before !== undefined) under(e.before);\n for (const [title, held] of [\n ['request headers', r.requestHeaders],\n ['response headers', r.responseHeaders],\n ] as const)\n for (const [name, value] of Object.entries(held ?? {})) under(`${title} ${name}: ${value}`);\n if (r.requestBody !== undefined) under(`request body ${r.requestBody}`);\n if (r.responseBody !== undefined) under(`response body ${r.responseBody}`);\n }\n if (shown.length === 0) console.log(timeline.length === 0 ? 'Nothing in it.' : 'No line of it is what was asked for.');\n // Where something went wrong, how to get to it: what led up to it, and what the page looked like.\n const problems = timeline.filter((e) => e.problem === true).length;\n if (problems === 0 || shown.length < timeline.length) return;\n const ref = task?.id ?? id;\n console.log(\n `\\n${problems} problem${problems === 1 ? '' : 's'}: --problems lists them, --around <seconds> shows what led to one, and ${ME} frame ${ref} --at <seconds> the page then.`,\n );\n}\n"],"mappings":";;;;;;;;;;AAiGA,MAAM,QAAQ,KAAK;;AAGnB,SAAS,QAAQ,EAAE,SAA6B;CAC9C,MAAM,UAAU,WAAoB;EAClC,MAAM,KAAK,OAAO,KAAK,MAAM,EAAE,CAAC;EAChC,MAAM,KAAK,OAAO,KAAK,MAAM,EAAE,CAAC;EAChC,OAAO,IAAI,MAAM,KAAK,IAAI,GAAG,EAAE,CAAC,EAAE,GAAG,MAAM,KAAK,IAAI,GAAG,EAAE,CAAC,EAAE,KAAK,MAAM,KAAK,IAAI,GAAG,EAAE,CAAC,EAAE,GAAG,MAAM,KAAK,IAAI,GAAG,EAAE,CAAC,EAAE;CACpH;CACA,IAAI,MAAM,SAAS,OAAO,OAAO,OAAO,OAAO,CAAC,OAAO;EAAE,GAAG,MAAM,IAAI,MAAM;EAAO,GAAG,MAAM,IAAI,MAAM;CAAO,CAAC,CAAC;CAC/G,IAAI,MAAM,SAAS,SACjB,OAAO,eAAe,MAAM,MAAM,KAAK,CAAC,EAAE,GAAG,MAAM,MAAM,KAAK,CAAC,EAAE,QAAQ,MAAM,MAAM,GAAG,CAAC,EAAE,GAAG,MAAM,MA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AAC,GAAG,MAAM,GAAG,MAAM,IAAI,KAAK,IAAI,OAAO;EAC7F,IAAI,EAAE,gBAAgB,KAAA,GAAW,MAAM,iBAAiB,EAAE,aAAa;EACvE,IAAI,EAAE,iBAAiB,KAAA,GAAW,MAAM,kBAAkB,EAAE,cAAc;CAC5E;CACA,IAAI,MAAM,WAAW,GAAG,QAAQ,IAAI,SAAS,WAAW,IAAI,mBAAmB,sCAAsC;CAErH,MAAM,WAAW,SAAS,QAAQ,MAAM,EAAE,YAAY,IAAI,CAAC,CAAC;CAC5D,IAAI,aAAa,KAAK,MAAM,SAAS,SAAS,QAAQ;CACtD,MAAM,MAAM,MAAM,MAAM;CACxB,QAAQ,IACN,KAAK,SAAS,UAAU,aAAa,IAAI,KAAK,IAAI,yEAAyE,GAAG,SAAS,IAAI,+BAC7I;AACF"}
1
+ {"version":3,"file":"recording.js","names":[],"sources":["../../src/cli/recording.ts"],"sourcesContent":["/**\n * `deictic recording`: a recording as a timeline: the page, each click and field typed in (with the element's place\n * in the source), scrolls, resizes, each change to the marks (what was drawn, where, and the notes' text), the voice\n * clips, the page's console and its requests where the project records them, React's commits where the recording had\n * them on, and the end. Or the part of it asked\n * for: `--only`, `--problems`, `--from`, `--to`, `--around`, `--grep`, `--all`, and `--full` for all of each line.\n *\n * Asked for nothing, it's what the person did and what went wrong: the page's requests, its console's lines and\n * React's commits, which a dev server makes hundreds of, are left out where they're not a problem, and counted at\n * the end with what lists them. An agent asks for them where the task needs them. `--json` has every line.\n */\nimport { relative } from 'node:path';\n\nimport type { Shape } from '#src/plugins/annotations/index.ts';\nimport type { Commit } from '#src/plugins/react/index.ts';\nimport { REACT } from '#src/plugins/recordings/marks.ts';\n\nimport { clock, fail, ME } from './board.ts';\nimport { loadRecording } from './find.ts';\n\n/** A node of rrweb's snapshot. */\ninterface SnapNode {\n id: number;\n type: number;\n tagName?: string;\n textContent?: string;\n attributes?: Record<string, string>;\n childNodes?: SnapNode[];\n}\n\ninterface Known extends Omit<SnapNode, 'childNodes'> {\n parent: number | undefined;\n kids: number[];\n}\n\n/** A request rrweb's network plugin kept. */\ninterface Request {\n name: string;\n method?: string;\n initiatorType?: string;\n status?: number;\n duration?: number;\n requestHeaders?: Record<string, string>;\n responseHeaders?: Record<string, string>;\n requestBody?: string;\n responseBody?: string;\n}\n\n/** What rrweb's events carry that the timeline reads: each kind has some of it. */\ninterface Data {\n href?: string;\n width?: number;\n height?: number;\n node?: SnapNode;\n tag?: string;\n plugin?: string;\n payload?: {\n annotations?: Annotation[];\n svg?: string;\n href?: string;\n level?: string;\n payload?: string[];\n trace?: string[];\n requests?: Request[];\n isInitial?: boolean;\n } & Partial<Commit> & { on?: boolean };\n source?: number;\n type?: number;\n id?: number;\n x?: number;\n y?: number;\n adds?: { node: SnapNode; parentId: number }[];\n attributes?: { id: number; attributes: Record<string, string> }[];\n texts?: { id: number; value: string }[];\n isChecked?: boolean;\n text?: string;\n}\n\ninterface Event {\n type: number;\n timestamp: number;\n data: Data;\n}\n\ninterface Annotation {\n id?: string;\n shape: Shape;\n}\n\ninterface Line {\n t: number;\n at: string;\n kind: string;\n text: string;\n problem?: boolean;\n trace?: string[];\n request?: Request;\n before?: string;\n marks?: Shape[];\n node?: number;\n /** A React commit entry's components, one line each: under it with `--full`. */\n details?: string[];\n}\n\n/**\n * The kinds left out of a timeline asked for nothing in particular, where a line of them isn't a problem: a dev\n * server's page makes hundreds of requests (its modules, its hot updates), logs what its tools do, and commits\n * React each frame it animates. Counted, with what lists them.\n */\nconst QUIET = [\n { kind: 'request', noun: 'request' },\n { kind: 'console', noun: 'console line' },\n { kind: 'react', noun: 'React line' },\n];\n\n/** A commit past this took longer than a frame: a problem, as it's what makes a page stutter. */\nconst FRAME = 16;\n\nconst ms = (n: number) => `${n < 10 ? n.toFixed(1) : round(n)}ms`;\n\n/** A React commit entry, as a line: how long, why it ran, and what rendered, the slowest first. */\nfunction commitLine(c: Partial<Commit>): Pick<Line, 'text' | 'details' | 'problem'> {\n const components = c.components ?? [];\n const many = (c.commits ?? 1) > 1;\n const head = [\n c.priority,\n many ? `${c.commits} commits${c.over === undefined ? '' : ` over ${(c.over / 1000).toFixed(1)}s`}` : undefined,\n c.slowest === undefined ? undefined : `slowest ${ms(c.slowest)}`,\n ]\n .filter(Boolean)\n .join(', ');\n // One slow commit is what makes a page stutter, not many quick ones.\n const slow = c.slowest ?? c.ms;\n const named = components.map(\n (r) => `${r.name}${(r.count ?? 1) > 1 ? ` ×${r.count}` : ''}${r.selfMs === undefined ? '' : ` ${ms(r.selfMs)}`} (${r.why})`,\n );\n const rest = c.more === undefined ? '' : named.length === 0 ? `${c.more} components` : `, and ${c.more} more`;\n return {\n text: `${c.ms === undefined ? 'commit' : ms(c.ms)}${head === '' ? '' : ` (${head})`}: ${named.join(', ')}${rest}`,\n details: components.map((r) =>\n [\n `${r.name}${(r.count ?? 1) > 1 ? ` ×${r.count}` : ''}`,\n r.at,\n r.ms === undefined ? undefined : `${ms(r.ms)} with what it rendered`,\n r.why,\n ]\n .filter(Boolean)\n .join(' · '),\n ),\n ...(slow !== undefined && slow > FRAME ? { problem: true } : {}),\n };\n}\n\ntype Point = { x: number; y: number };\n\nconst round = Math.round;\n\n/** The marks, as data where the recording has it. */\nfunction shapeOf({ shape }: Annotation): string {\n const bounds = (points: Point[]) => {\n const xs = points.map((p) => p.x);\n const ys = points.map((p) => p.y);\n return `(${round(Math.min(...xs))},${round(Math.min(...ys))})–(${round(Math.max(...xs))},${round(Math.max(...ys))})`;\n };\n if (shape.kind === 'box') return `box ${bounds([shape, { x: shape.x + shape.width, y: shape.y + shape.height }])}`;\n if (shape.kind === 'arrow')\n return `arrow from (${round(shape.from.x)},${round(shape.from.y)}) to (${round(shape.to.x)},${round(shape.to.y)})`;\n if (shape.kind === 'pen') return `pen stroke over ${bounds(shape.points)}`;\n return `note at (${round(shape.at.x)},${round(shape.at.y)}): ${JSON.stringify(shape.text)}`;\n}\n\nconst pairs = (s: string): Point[] => [...s.matchAll(/(-?[\\d.]+)[ ,](-?[\\d.]+)/g)].map((m) => ({ x: Number(m[1]), y: Number(m[2]) }));\n\n/** The marks read off the SVG, for a recording older than the marks as data. */\nfunction shapesInSvg(svg: string): Annotation[] {\n const out: Annotation[] = [];\n const unescape = (t: string) => t.replaceAll('&lt;', '<').replaceAll('&gt;', '>').replaceAll('&quot;', '\"').replaceAll('&amp;', '&');\n for (const [, tag, attrs = '', inner = ''] of svg.matchAll(/<(rect|path|polyline|text)\\b([^>]*)>(?:(.*?)<\\/text>)?/g)) {\n const num = (name: string) => Number(new RegExp(`\\\\b${name}=\"(-?[\\\\d.]+)\"`).exec(attrs)?.[1]);\n if (tag === 'rect' && attrs.includes('fill=\"none\"'))\n out.push({ shape: { kind: 'box', x: num('x'), y: num('y'), width: num('width'), height: num('height') } });\n if (tag === 'path') {\n const [from, to] = pairs(/d=\"([^\"]*)\"/.exec(attrs)?.[1] ?? '');\n if (from !== undefined && to !== undefined) out.push({ shape: { kind: 'arrow', from, to } });\n }\n if (tag === 'polyline') out.push({ shape: { kind: 'pen', points: pairs(/points=\"([^\"]*)\"/.exec(attrs)?.[1] ?? '') } });\n if (tag === 'text') {\n const lines = [...inner.matchAll(/<tspan[^>]*>(.*?)<\\/tspan>/g)].map((l) => unescape(l[1] ?? ''));\n const xy = /x=\"(-?[\\d.]+)\" y=\"(-?[\\d.]+)\"/.exec(inner);\n out.push({ shape: { kind: 'note', at: { x: Number(xy?.[1] ?? 0), y: Number(xy?.[2] ?? 0) }, text: lines.join('\\n') } });\n }\n }\n return out;\n}\n\n/** The page's nodes by rrweb's IDs, from the full snapshot and each mutation: enough to name an element. */\nclass Nodes {\n #nodes = new Map<number, Known>();\n\n clear(): void {\n this.#nodes.clear();\n }\n\n add(node: SnapNode, parent: number | undefined): void {\n const { childNodes = [], ...rest } = node;\n this.#nodes.set(node.id, { ...rest, parent, kids: childNodes.map((c) => c.id) });\n for (const c of childNodes) this.add(c, node.id);\n }\n\n get(id: number): Known | undefined {\n return this.#nodes.get(id);\n }\n\n text(id: number, max = 60): string {\n let out = '';\n const walk = (n: number) => {\n const node = this.#nodes.get(n);\n if (node === undefined || out.length > max) return;\n if (node.type === 3) out += node.textContent ?? '';\n for (const k of node.kids) walk(k);\n };\n walk(id);\n const text = out.replace(/\\s+/g, ' ').trim();\n return text.length > max ? `${text.slice(0, max)}…` : text;\n }\n\n /** `<button> \"Save\" at src/App.tsx:9:7`: the element, its text, and the nearest place deictic marked. */\n describe(id: number | undefined): string {\n const node = id === undefined ? undefined : this.#nodes.get(id);\n if (id === undefined || node === undefined) return `node ${id}`;\n if (node.type === 0) return 'the page';\n let at: string | undefined;\n for (\n let n: Known | undefined = node;\n n !== undefined && at === undefined;\n n = n.parent === undefined ? undefined : this.#nodes.get(n.parent)\n )\n at = n.attributes?.['data-deictic'];\n const tag = node.tagName === undefined ? 'text' : `<${node.tagName}>`;\n const text = this.text(id);\n return `${tag}${text ? ` \"${text}\"` : ''}${at === undefined ? '' : ` at ${at}`}`;\n }\n}\n\n/** The page's console's arguments, each as JSON: a string without its quotes. */\nconst plain = (arg: string) => {\n try {\n const value: unknown = JSON.parse(arg);\n return typeof value === 'string' ? value : arg;\n } catch {\n return arg;\n }\n};\n\n/** Every line of the recording, in time. */\nfunction timelineOf(events: Event[], voice: { id: string; at: number; duration: number }[]): Line[] {\n const t0 = events[0]!.timestamp;\n const timeline: Line[] = [];\n const nodes = new Nodes();\n const push = (t: number, kind: string, text: string, extra: Partial<Line> = {}) =>\n timeline.push({ t, at: clock(t), kind, text, ...extra });\n let marks: Annotation[] = [];\n let scroll: { t: number; id: number | undefined; x: number; y: number } | undefined;\n let typing: { t: number; id: number | undefined; value: string } | undefined;\n const flushScroll = () => {\n if (scroll) push(scroll.t, 'scroll', `${nodes.describe(scroll.id)} to (${scroll.x},${scroll.y})`);\n scroll = undefined;\n };\n const flushTyping = () => {\n if (typing) push(typing.t, 'input', `${nodes.describe(typing.id)}: ${typing.value}`);\n typing = undefined;\n };\n\n for (const e of events) {\n const t = e.timestamp - t0;\n const d = e.data;\n const payload = d.payload ?? {};\n if (e.type === 4) push(t, 'page', `${d.href} at ${d.width}×${d.height}`);\n if (e.type === 2 && d.node !== undefined) {\n nodes.clear();\n nodes.add(d.node, undefined);\n }\n if (e.type === 5 && d.tag === 'deictic.annotations') {\n const now = payload.annotations ?? shapesInSvg(payload.svg ?? '');\n const key = (a: Annotation) => a.id ?? JSON.stringify(a.shape);\n const before = new Set(marks.map(key));\n const after = new Set(now.map(key));\n const added = now.filter((a) => !before.has(key(a)));\n const removed = marks.filter((a) => !after.has(key(a)));\n if (added.length > 0 || removed.length > 0) {\n // All of them cleared (a task added, the page left) is said as that: each was said as it was drawn.\n const gone = now.length === 0 && removed.length > 1 ? [`− all ${removed.length} marks`] : removed.map((a) => `− ${shapeOf(a)}`);\n const text = [...added.map((a) => `+ ${shapeOf(a)}`), ...gone].join('; ');\n push(t, 'marks', text, { marks: now.map((a) => a.shape) });\n }\n marks = now;\n }\n // The address changed with no load: a route of the app's.\n if (e.type === 5 && d.tag === 'deictic.page') push(t, 'page', `${payload.href} (a route change, no load)`);\n // The page's console, and errors nothing caught (rrweb's console plugin), and where it was logged from, which goes\n // under a warning or an error.\n if (e.type === 6 && d.plugin === 'rrweb/console@1') {\n const level = payload.level ?? 'log';\n push(t, `console.${level}`, (payload.payload ?? []).map(plain).join(' '), {\n trace: payload.trace ?? [],\n ...(['error', 'assert', 'warn'].includes(level) ? { problem: true } : {}),\n });\n }\n // The page's requests (rrweb's network plugin), masked as they were kept: each as it ended. One the browser\n // reported of itself has no method; headers and bodies, where kept, are in `--json`.\n if (e.type === 6 && d.plugin === 'rrweb/network@1') {\n for (const r of payload.requests ?? []) {\n const took = r.duration !== undefined && Number.isFinite(r.duration) ? ` in ${round(r.duration)} ms` : '';\n const status = r.status === undefined || r.status === 0 ? 'no status (failed, blocked, or another origin’s)' : r.status;\n push(t, 'request', `${r.method ?? r.initiatorType ?? ''} ${r.name} → ${status}${took}`.trim(), {\n request: r,\n ...((r.status ?? 0) >= 400 ? { problem: true } : {}),\n ...(payload.isInitial === true ? { before: 'made as the page loaded, before this moment' } : {}),\n });\n }\n }\n if (e.type === 5 && d.tag === REACT) {\n if (payload.on !== undefined) push(t, 'react', payload.on ? 'commits recorded from here' : 'commits no longer recorded');\n else push(t, 'react', '', commitLine(payload));\n }\n if (e.type === 5 && d.tag === 'deictic.end') push(t, 'end', 'recording stopped');\n if (e.type !== 3) continue;\n if (d.source === 0) {\n for (const a of d.adds ?? []) nodes.add(a.node, a.parentId);\n for (const a of d.attributes ?? []) {\n const node = nodes.get(a.id);\n if (node) node.attributes = { ...node.attributes, ...a.attributes };\n }\n for (const x of d.texts ?? []) {\n const node = nodes.get(x.id);\n if (node) node.textContent = x.value;\n }\n }\n if (d.source === 2 && (d.type === 2 || d.type === 3 || d.type === 4)) {\n flushScroll();\n flushTyping();\n const what = { 2: 'click', 3: 'right-click', 4: 'double-click' }[d.type];\n // A click a key made (Enter on a button) has no position.\n const where = d.x === 0 && d.y === 0 ? ' by keyboard' : ` at (${round(d.x ?? 0)},${round(d.y ?? 0)}) in the viewport`;\n push(t, what, `${nodes.describe(d.id)}${where}`, { node: d.id });\n }\n if (d.source === 3) {\n if (scroll && scroll.id !== d.id) flushScroll();\n scroll = { t: scroll?.t ?? t, id: d.id, x: round(d.x ?? 0), y: round(d.y ?? 0) };\n }\n if (d.source === 4) push(t, 'resize', `viewport ${d.width}×${d.height}`);\n if (d.source === 5) {\n if (typing && typing.id !== d.id) flushTyping();\n const value = d.isChecked !== undefined && d.text === undefined ? String(d.isChecked) : JSON.stringify(d.text);\n typing = { t: typing?.t ?? t, id: d.id, value };\n }\n }\n flushScroll();\n flushTyping();\n for (const c of voice) push(c.at, 'voice', `clip ${c.id}, ${clock(c.duration)} long, until ${clock(c.at + c.duration)}`);\n return timeline.sort((a, b) => a.t - b.t);\n}\n\n/**\n * The page's own URLs as paths, in a line of text: `http://localhost:5180/src/App.tsx?t=1712:9:7` is `/src/App.tsx:9:7`,\n * and a file Vite serves from outside its root (`/@fs/S:/…/dist/client.js`) is that file's path from here. The header\n * says the origin once; `--json` keeps every URL whole.\n */\nfunction shortener(page: string): (text: string) => string {\n let origin: string;\n try {\n origin = new URL(page).origin;\n } catch {\n return (text) => text;\n }\n const quoted = origin.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n // A Windows path has a drive's colon in it, which a line and column also follow.\n const fs = new RegExp(`${quoted}/@fs/([A-Za-z]:)?([^\\\\s?:)]+)`, 'g');\n const own = new RegExp(`${quoted}(?=/)`, 'g');\n return (text) =>\n text\n .replace(fs, (_, drive: string | undefined, rest: string) =>\n relative(process.cwd(), drive ? `${drive}${rest}` : `/${rest}`).replaceAll('\\\\', '/'),\n )\n .replace(own, '')\n // A bundler's cache-busting query, between a module's path and its line.\n .replace(/(\\.[cm]?[jt]sx?)\\?[tv]=[\\w.-]+/g, '$1');\n}\n\nexport interface Options {\n nth: string;\n json?: boolean;\n all?: boolean;\n only?: string[];\n problems?: boolean;\n from?: string;\n to?: string;\n around?: string;\n grep?: string;\n full?: boolean;\n}\n\nexport async function run(named: string, values: Options): Promise<void> {\n const { kept, id, replay, task } = await loadRecording(named, Number(values.nth));\n const events = kept.events as Event[];\n if (!Array.isArray(events) || events.length === 0) fail(`Recording ${id} has no events.`);\n const timeline = timelineOf(events, kept.voice ?? []);\n\n // The part asked for. Seconds, as the replay's `?t=` and `frame --at` take them.\n const seconds = (name: 'from' | 'to' | 'around') => {\n const given = values[name];\n if (given === undefined) return undefined;\n const value = Number(given);\n if (!Number.isFinite(value)) fail(`--${name} takes seconds from the recording's start, as 12 or 4.5: not ${given}`);\n return value * 1000;\n };\n const around = seconds('around');\n const from = seconds('from') ?? (around === undefined ? undefined : around - 3000);\n const to = seconds('to') ?? (around === undefined ? undefined : around + 3000);\n const only = (values.only ?? []).flatMap((list) => list.split(',')).filter(Boolean);\n const grep = values.grep?.toLowerCase();\n // `console` is every level's lines, `click` a right or a double one too.\n const isKind = (kind: string, asked: string) => kind === asked || kind.startsWith(`${asked}.`) || kind.endsWith(`-${asked}`);\n // Asked for nothing in particular: what the person did and what went wrong, the rest counted. A slice of time, a\n // word or kinds asked for are every line of it.\n const whole = values.all === true || only.length > 0 || from !== undefined || to !== undefined || grep !== undefined;\n const left = new Map<string, { count: number; noun: string }>();\n const listed = (e: Line) => {\n if (whole || e.problem === true) return true;\n const quiet = QUIET.find((q) => isKind(e.kind, q.kind));\n if (quiet === undefined) return true;\n const held = left.get(quiet.kind) ?? { count: 0, noun: quiet.noun };\n held.count++;\n left.set(quiet.kind, held);\n return false;\n };\n const shown = timeline.filter(\n (e) =>\n (only.length === 0 || only.some((asked) => isKind(e.kind, asked))) &&\n (values.problems !== true || e.problem === true) &&\n (from === undefined || e.t >= from) &&\n (to === undefined || e.t <= to) &&\n (grep === undefined || `${e.kind} ${e.text}`.toLowerCase().includes(grep)),\n );\n // Not in `--json`, which is for a script, and has every line it was asked for.\n const listing = values.json === true ? shown : shown.filter(listed);\n\n const colorScheme = kept.colorScheme ?? 'light';\n const startedAt = new Date(kept.startedAt ?? events[0]!.timestamp).toISOString();\n if (values.json) {\n const head = { id, page: kept.page, viewport: kept.viewport, colorScheme, startedAt, duration: kept.duration, replay, task: task?.id };\n console.log(JSON.stringify({ ...head, lines: timeline.length, timeline: shown }, null, 2));\n return;\n }\n console.log(`Recording ${id}${task ? ` on task #${task.id}` : ''}: ${clock(kept.duration)} of ${kept.page}`);\n console.log(`viewport ${kept.viewport.width}×${kept.viewport.height}, ${colorScheme}, started ${startedAt}`);\n if (replay !== undefined) console.log(`replays at ${replay} (add ?t=<seconds> to open it paused there)`);\n if (shown.length < timeline.length) console.log(`${shown.length} of its ${timeline.length} lines, as asked`);\n else if (listing.length < shown.length)\n console.log(`${listing.length} of its ${timeline.length} lines: what the person did, and what went wrong`);\n console.log();\n const short = shortener(kept.page);\n const under = (line: string) => console.log(`${' '.repeat(22)}${short(line)}`);\n for (const e of listing) {\n console.log(`${e.at.padStart(6)} ${e.kind.padEnd(13)} ${short(e.text)}`);\n // Where a warning or an error came from, its nearest few places: all of them, and every line's, with `--full`.\n if (e.trace && (values.full === true || e.problem === true))\n for (const line of values.full ? e.trace : e.trace.slice(0, 5)) under(`at ${line}`);\n if (values.full === true) for (const line of e.details ?? []) under(line);\n if (values.full !== true || e.request === undefined) continue;\n const r = e.request;\n if (e.before !== undefined) under(e.before);\n for (const [title, held] of [\n ['request headers', r.requestHeaders],\n ['response headers', r.responseHeaders],\n ] as const)\n for (const [name, value] of Object.entries(held ?? {})) under(`${title} ${name}: ${value}`);\n if (r.requestBody !== undefined) under(`request body ${r.requestBody}`);\n if (r.responseBody !== undefined) under(`response body ${r.responseBody}`);\n }\n if (shown.length === 0) console.log(timeline.length === 0 ? 'Nothing in it.' : 'No line of it is what was asked for.');\n if (left.size > 0) {\n const counted = [...left.entries()].map(([kind, { count, noun }]) => `${count} ${noun}${count === 1 ? '' : 's'} (--only ${kind})`);\n console.log(`\nNot listed: ${counted.join(', ')}; --all lists every line, --around <seconds> every line of a moment.`);\n }\n // Where something went wrong, how to get to it: what led up to it, and what the page looked like.\n const problems = timeline.filter((e) => e.problem === true).length;\n if (problems === 0 || shown.length < timeline.length) return;\n const ref = task?.id ?? id;\n console.log(\n `\\n${problems} problem${problems === 1 ? '' : 's'}: --problems lists them, --around <seconds> shows what led to one, and ${ME} frame ${ref} --at <seconds> the page then.`,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA6GA,MAAM,QAAQ;CACZ;EAAE,MAAM;EAAW,MAAM;CAAU;CACnC;EAAE,MAAM;EAAW,MAAM;CAAe;CACxC;EAAE,MAAM;EAAS,MAAM;CAAa;AACtC;;AAGA,MAAM,QAAQ;AAEd,MAAM,MAAM,MAAc,GAAG,IAAI,KAAK,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,EAAE;;AAG9D,SAAS,WAAW,GAAgE;CAClF,MAAM,aAAa,EAAE,cAAc,CAAC;CACpC,MAAM,Q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AAM,IAAI,EAAE;EACZ,IAAI,EAAE,WAAW,KAAA,GAAW,MAAM,EAAE,MAAM;EAC1C,KAAK,MAAM,CAAC,OAAO,SAAS,CAC1B,CAAC,mBAAmB,EAAE,cAAc,GACpC,CAAC,oBAAoB,EAAE,eAAe,CACxC,GACE,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,QAAQ,CAAC,CAAC,GAAG,MAAM,GAAG,MAAM,IAAI,KAAK,IAAI,OAAO;EAC7F,IAAI,EAAE,gBAAgB,KAAA,GAAW,MAAM,iBAAiB,EAAE,aAAa;EACvE,IAAI,EAAE,iBAAiB,KAAA,GAAW,MAAM,kBAAkB,EAAE,cAAc;CAC5E;CACA,IAAI,MAAM,WAAW,GAAG,QAAQ,IAAI,SAAS,WAAW,IAAI,mBAAmB,sCAAsC;CACrH,IAAI,KAAK,OAAO,GAAG;EACjB,MAAM,UAAU,CAAC,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,YAAY,GAAG,MAAM,GAAG,OAAO,UAAU,IAAI,KAAK,IAAI,WAAW,KAAK,EAAE;EACjI,QAAQ,IAAI;cACF,QAAQ,KAAK,IAAI,EAAE,qEAAqE;CACpG;CAEA,MAAM,WAAW,SAAS,QAAQ,MAAM,EAAE,YAAY,IAAI,CAAC,CAAC;CAC5D,IAAI,aAAa,KAAK,MAAM,SAAS,SAAS,QAAQ;CACtD,MAAM,MAAM,MAAM,MAAM;CACxB,QAAQ,IACN,KAAK,SAAS,UAAU,aAAa,IAAI,KAAK,IAAI,yEAAyE,GAAG,SAAS,IAAI,+BAC7I;AACF"}
@@ -3,7 +3,7 @@ import { createRequire } from "node:module";
3
3
  import { dirname, join, resolve } from "node:path";
4
4
  import { r as definePlugin } from "./src.js";
5
5
  import { t as keptIn } from "./kept.js";
6
- import { n as MARKS } from "./marks.js";
6
+ import { i as REACT, n as MARKS } from "./marks.js";
7
7
  // src/plugins/recordings/replay.ts
8
8
  /**
9
9
  * The replay page, `replay/<id>`: rrweb's own player (`rrweb-player`), its timeline, speeds, skipping idle
@@ -70,7 +70,10 @@ const replayPage = ({ player = "..", source } = {}) => `<!doctype html>
70
70
  #log .text { min-width: 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
71
71
  #log li.open .text { display: block; white-space: pre-wrap; }
72
72
  #log pre { margin: 0; padding: 2px 8px 8px calc(8px + 6ch + 8px); color: #a1a1aa; font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; }
73
- #log.no-console li.console, #log.no-network li.network, #log.only-bad li:not(.bad) { display: none; }
73
+ #log.no-console li.console, #log.no-network li.network, #log.no-react li.react, #log.only-bad li:not(.bad) { display: none; }
74
+ #log li.react .label { color: #58c4dc; }
75
+ #log li.react.warn .label { color: #fbbf24; }
76
+ #main .rr-player .rr-progress .slow-mark { position: absolute; top: -3px; width: 3px; height: 10px; margin-left: -1px; border-radius: 1px; background: #fbbf24; pointer-events: none; }
74
77
  #main .rr-player .rr-progress .bad-mark { position: absolute; top: -3px; width: 3px; height: 10px; margin-left: -1px; border-radius: 1px; background: #f87171; pointer-events: none; }
75
78
  body.embed #main .rr-player { box-shadow: none; border-radius: 0; }
76
79
  #marks { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 3; }
@@ -106,6 +109,7 @@ const replayPage = ({ player = "..", source } = {}) => `<!doctype html>
106
109
  <div class="filters">
107
110
  <button type="button" data-hides="no-console" aria-pressed="true">Console</button>
108
111
  <button type="button" data-hides="no-network" aria-pressed="true">Network</button>
112
+ <button type="button" data-hides="no-react" aria-pressed="true" hidden title="React's commits: what rendered, how long it took, and why">React</button>
109
113
  <button type="button" data-shows="only-bad" aria-pressed="false" title="Errors, and requests that failed">Problems</button>
110
114
  </div>
111
115
  <ol></ol>
@@ -144,6 +148,27 @@ const replayPage = ({ player = "..", source } = {}) => `<!doctype html>
144
148
  const origin = (() => { try { return new URL(kept.page).origin; } catch { return ''; } })();
145
149
  const fields = (title, held) => (held && Object.keys(held).length > 0 ? [title, ...Object.entries(held).map(([k, v]) => ' ' + k + ': ' + v)] : []);
146
150
  const rows = [];
151
+ // React's commits, where the recording had them on: a row an entry, slow ones (past a frame) marked.
152
+ const ms = (n) => (n === undefined ? '' : (n < 10 ? n.toFixed(1) : Math.round(n)) + ' ms');
153
+ for (const e of events) {
154
+ if (e.type !== 5 || bare || e.data.tag !== ${JSON.stringify(REACT)}) continue;
155
+ const at = e.timestamp - t0;
156
+ const c = e.data.payload;
157
+ if (c.on !== undefined) {
158
+ rows.push({ at, kind: 'react', label: 'React', text: c.on ? 'commits recorded from here' : 'commits no longer recorded', more: [] });
159
+ continue;
160
+ }
161
+ const named = (c.components ?? []).map((r) => r.name + (r.count > 1 ? ' ×' + r.count : '') + ' (' + r.why + ')');
162
+ const text = (named.length > 0 ? named.slice(0, 3).join(', ') : (c.more ?? 0) + ' components') + (named.length > 3 || (c.more && named.length > 0) ? ', …' : '');
163
+ const more = [
164
+ [c.commits > 1 ? c.commits + ' commits' + (c.over === undefined ? '' : ' over ' + (c.over / 1000).toFixed(1) + ' s') : '1 commit', c.priority, ms(c.ms), c.slowest === undefined ? '' : 'slowest ' + ms(c.slowest)].filter(Boolean).join(' · '),
165
+ ...(c.components ?? []).map((r) => [r.name + (r.count > 1 ? ' ×' + r.count : ''), r.at, ms(r.ms), r.selfMs === undefined ? '' : ms(r.selfMs) + ' own', r.why].filter(Boolean).join(' · ')),
166
+ ...(c.more ? ['and ' + c.more + ' more'] : []),
167
+ ];
168
+ // One slow commit is what makes a page stutter, not many quick ones.
169
+ const slow = (c.slowest ?? c.ms) > 16;
170
+ rows.push({ at, kind: 'react', label: c.ms === undefined ? 'React' : ms(c.ms), warn: slow, slow, text: (c.over === undefined ? '' : c.commits + ' commits: ') + text, more });
171
+ }
147
172
  for (const e of events) {
148
173
  if (e.type !== 6 || bare) continue;
149
174
  const at = e.timestamp - t0;
@@ -169,8 +194,10 @@ const replayPage = ({ player = "..", source } = {}) => `<!doctype html>
169
194
  }
170
195
  }
171
196
  }
197
+ rows.sort((a, b) => a.at - b.at);
172
198
  const logged = rows.length > 0;
173
199
  const log = document.getElementById('log');
200
+ if (rows.some((r) => r.kind === 'react')) log.querySelector('[data-hides="no-react"]').hidden = false;
174
201
  if (logged) document.body.classList.add('logged');
175
202
  // The panel's room, where the window is wide enough to show it (as the stylesheet has it).
176
203
  const side = () => (logged && innerWidth >= 900 ? 340 : 0);
@@ -231,6 +258,7 @@ const replayPage = ({ player = "..", source } = {}) => `<!doctype html>
231
258
  row.el.append(go, more);
232
259
  list.append(row.el);
233
260
  // An error, or a request that failed, is a mark on the timeline too.
261
+ if (row.slow && bar) bar.append(Object.assign(cell('i', 'slow-mark', ''), { title: row.label + ': ' + row.text.slice(0, 200), style: 'left:' + (total > 0 ? (row.at / total) * 100 : 0) + '%' }));
234
262
  if (row.bad && bar) bar.append(Object.assign(cell('i', 'bad-mark', ''), { title: row.text.slice(0, 200), style: 'left:' + (total > 0 ? (row.at / total) * 100 : 0) + '%' }));
235
263
  }
236
264
  for (const button of log.querySelectorAll('.filters button')) {
@@ -1 +1 @@
1
- {"version":3,"file":"recordings.js","names":[],"sources":["../../src/plugins/recordings/replay.ts","../../src/plugins/recordings/index.ts"],"sourcesContent":["/**\n * The replay page, `replay/<id>`: rrweb's own player (`rrweb-player`), its timeline, speeds, skipping idle\n * stretches and fullscreen, sized to the window, with what it doesn't do drawn over it:\n *\n * - The page shows in the colour scheme it was recorded in, whatever the viewer's: the replay's iframe\n * answers `prefers-color-scheme` as the viewer's browser does, so the recorded CSS's queries are rewritten\n * before it's replayed, the recorded scheme's to always match and the other's never.\n * - The marks drawn while recording come as custom events, an SVG in page coordinates each; they're drawn\n * over the replay in the player's own scaled wrapper, moved with its scroll, rather than into its document,\n * which the replayer rebuilds. Each is a marker on the timeline.\n * - The voice clips play in step, at the player's speed. A recording with voice starts paused, as a browser\n * plays sound only after a click.\n * - What the page logged and asked for (rrweb's console and network plugins' events, which its player doesn't\n * show) is a list beside the replay, where the window has the room: the row the replay is at is lit, a click on\n * one goes to its moment and shows the rest of it, and each error and failed request is a mark on the timeline.\n * - A recorded canvas is replayed (`UNSAFE_replayCanvas`, which lets the replay's frame run rrweb's own script\n * to draw it), for a recording that has one.\n *\n * `?t=<seconds>` opens it paused there, and `&bare` without the controls at the recorded size, 1:1, for a\n * screenshot; `?embed` is it filling a frame, with no header of its own (the lightbox's); `body[data-ready]` says\n * it's in place.\n *\n * The plugin's routes serve it, the player and what it plays. A page with no server behind it (a `standalone` build)\n * publishes it as a file instead, `replayPage(sources)`: which recording is `?id=`, and a script of its own says\n * where one is.\n */\nimport { MARKS } from './marks.ts';\n\n/** Where the replay page finds what the plugin's routes would serve it, for a page published as a file. */\nexport interface ReplaySources {\n /** The folder `player.js` and `player.css` are in (`rrweb-player`'s `rrweb-player.umd.min.cjs` and `style.css`), from the page: `..`, the routes', by default. */\n player?: string;\n /**\n * A script, from the page, that sets `globalThis.deicticReplay` before the page asks: `recording(id)` answers the\n * recording (a `Kept`) and `clip(id)` a voice clip's URL, either as a promise. The routes by default.\n */\n source?: string;\n}\n\n/** The replay page's HTML: the routes' as it is, or one for a page published as a file. */\nexport const replayPage = ({ player = '..', source }: ReplaySources = {}) => `<!doctype html>\n<html lang=\"en\">\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<title>Recording · deictic</title>\n<link rel=\"stylesheet\" href=\"${player}/player.css\">\n<style>\n :root { color-scheme: dark; --accent: #12b358; }\n body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: #18181b; color: #fafafa; font: 13px/1.4 system-ui, sans-serif; }\n header { display: flex; gap: 10px; align-items: center; padding: 10px 16px; border-bottom: 1px solid #3f3f46; }\n header a { color: #a1a1aa; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n #stage { flex: 1; display: flex; min-height: 0; }\n main { flex: 1; min-width: 0; display: flex; justify-content: center; align-items: flex-start; padding: 16px; }\n body.bare header { display: none; }\n body.bare main { padding: 0; }\n body.embed header { display: none; }\n body.embed main { padding: 0; }\n /* What the page logged and asked for, beside the replay: the window's height, its list scrolling in it. */\n #log { display: none; flex: none; width: 340px; flex-direction: column; border-left: 1px solid #3f3f46; background: #1f1f23; }\n body.logged { height: 100vh; }\n body.logged #log { display: flex; }\n @media (max-width: 899px) { body.logged #log { display: none; } }\n #log .filters { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid #3f3f46; }\n #log .filters button { padding: 3px 8px; border: 1px solid #3f3f46; border-radius: 6px; background: none; color: #a1a1aa; font: inherit; font-size: 12px; cursor: pointer; }\n #log .filters button[aria-pressed='true'] { color: #fafafa; background: #3f3f46; }\n #log ol { flex: 1; min-height: 0; overflow: auto; margin: 0; padding: 0; list-style: none; font: 12px/1.45 ui-monospace, monospace; }\n #log li { border-bottom: 1px solid #2e2e33; border-left: 2px solid transparent; }\n #log li.ahead { opacity: 0.45; }\n #log li.now { border-left-color: var(--accent); background: #27272a; }\n #log li.warn .label { color: #fbbf24; }\n #log li.bad .label, #log li.bad .text { color: #f87171; }\n #log li > button { display: flex; gap: 8px; align-items: baseline; width: 100%; padding: 5px 8px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }\n #log li > button:hover { background: #2e2e33; }\n #log time { flex: none; color: #71717a; }\n #log .label { flex: none; min-width: 4ch; color: #a1a1aa; }\n #log .text { min-width: 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }\n #log li.open .text { display: block; white-space: pre-wrap; }\n #log pre { margin: 0; padding: 2px 8px 8px calc(8px + 6ch + 8px); color: #a1a1aa; font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; }\n #log.no-console li.console, #log.no-network li.network, #log.only-bad li:not(.bad) { display: none; }\n #main .rr-player .rr-progress .bad-mark { position: absolute; top: -3px; width: 3px; height: 10px; margin-left: -1px; border-radius: 1px; background: #f87171; pointer-events: none; }\n body.embed #main .rr-player { box-shadow: none; border-radius: 0; }\n #marks { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 3; }\n #marks svg { position: absolute; left: 0; top: 0; overflow: visible; }\n .problem { color: #f87171; padding: 16px; }\n /* rrweb-player, in the dark of the rest of deictic. Its rules repeat Svelte's scoping class, so these start\n from #main, which outweighs any number of classes. */\n #main .rr-player { background: #27272a; box-shadow: 0 12px 32px rgb(0 0 0 / 0.5); border-radius: 8px; overflow: hidden; }\n body.bare #main .rr-player { box-shadow: none; border-radius: 0; }\n #main .rr-player .rr-player__frame { background: #fff; }\n #main .rr-player .rr-controller { background: #18181b; border-top: 1px solid #3f3f46; border-radius: 0; }\n #main .rr-player .rr-timeline__time { color: #a1a1aa; font: 12px ui-monospace, monospace; }\n #main .rr-player .rr-progress { background: #3f3f46; border-color: #18181b; }\n #main .rr-player .rr-progress__step { background: color-mix(in srgb, var(--accent) 45%, transparent); }\n #main .rr-player .rr-progress__handler { background: var(--accent); }\n #main .rr-player .rr-controller__btns button { color: #e4e4e7; }\n #main .rr-player .rr-controller__btns button:disabled { color: #52525b; }\n #main .rr-player .rr-controller__btns button svg { fill: currentColor; }\n #main .rr-player .rr-controller__btns button.active { color: #04130b; background: var(--accent); }\n #main .rr-player .rr-controller__btns button:active { background: color-mix(in srgb, var(--accent) 60%, transparent); }\n #main .rr-player .switch .label { color: #e4e4e7; }\n #main .rr-player .switch.disabled .label { color: #52525b; }\n #main .rr-player .switch label:before { background: #52525b; }\n #main .rr-player .switch input:checked + label:before { background: var(--accent); }\n</style>\n<header>\n <strong>Recording</strong>\n <a id=\"page\" target=\"_blank\" rel=\"noreferrer\"></a>\n</header>\n<div id=\"stage\">\n <main id=\"main\"></main>\n <aside id=\"log\" aria-label=\"Console and network\">\n <div class=\"filters\">\n <button type=\"button\" data-hides=\"no-console\" aria-pressed=\"true\">Console</button>\n <button type=\"button\" data-hides=\"no-network\" aria-pressed=\"true\">Network</button>\n <button type=\"button\" data-shows=\"only-bad\" aria-pressed=\"false\" title=\"Errors, and requests that failed\">Problems</button>\n </div>\n <ol></ol>\n </aside>\n</div>\n<script src=\"${player}/player.js\"></script>${\n source === undefined\n ? ''\n : `\n<script src=\"${source}\"></script>`\n}\n<script>\n const params = new URLSearchParams(location.search);\n const bare = params.has('bare');\n const embed = params.has('embed');\n if (bare) document.body.classList.add('bare');\n if (embed) document.body.classList.add('embed');\n const id = params.get('id') ?? location.pathname.split('/').at(-1);\n // The plugin's routes, unless the page was given a source of its own (\\`replayPage\\`).\n const from = globalThis.deicticReplay ?? {\n recording: (id) => fetch('../recording/' + id).then((r) => (r.ok ? r.json() : r.text().then((t) => Promise.reject(new Error(t))))),\n clip: (id) => '../../voice/clip/' + id,\n };\n Promise.resolve(from.recording(id)).then(async (kept) => {\n const scheme = kept.colorScheme ?? 'light';\n const events = JSON.parse(\n JSON.stringify(kept.events).replace(/\\\\(\\\\s*prefers-color-scheme\\\\s*:\\\\s*(light|dark)\\\\s*\\\\)/g, (_, s) =>\n s === scheme ? '(min-width: 0px)' : '(max-width: 0px) and (min-width: 1px)',\n ),\n );\n page.textContent = kept.page;\n page.href = kept.page;\n\n // What the page logged and asked for, where the recording has it (rrweb's console and network plugins' events):\n // a row each, in their order, beside the replay. Not in a bare one, which is the page alone.\n const t0 = events[0].timestamp;\n const clock = (ms) => { const s = Math.max(0, ms) / 1000; return Math.floor(s / 60) + ':' + (s % 60).toFixed(1).padStart(4, '0'); };\n // An argument is kept as JSON: a string reads better without its quotes.\n const plain = (arg) => { try { const v = JSON.parse(arg); return typeof v === 'string' ? v : arg; } catch { return arg; } };\n const origin = (() => { try { return new URL(kept.page).origin; } catch { return ''; } })();\n const fields = (title, held) => (held && Object.keys(held).length > 0 ? [title, ...Object.entries(held).map(([k, v]) => ' ' + k + ': ' + v)] : []);\n const rows = [];\n for (const e of events) {\n if (e.type !== 6 || bare) continue;\n const at = e.timestamp - t0;\n if (e.data.plugin === 'rrweb/console@1') {\n const { level, payload = [], trace = [] } = e.data.payload;\n rows.push({ at, kind: 'console', label: level, bad: level === 'error' || level === 'assert', warn: level === 'warn', text: payload.map(plain).join(' '), more: trace.map((l) => 'at ' + l) });\n }\n if (e.data.plugin === 'rrweb/network@1') {\n for (const r of e.data.payload.requests ?? []) {\n // The page's own origin goes without saying.\n let name = r.name;\n try { const u = new URL(r.name); if (u.origin === origin) name = u.pathname + u.search + u.hash; } catch {}\n const more = [\n r.name,\n [r.initiatorType, Number.isFinite(r.duration) ? Math.round(r.duration) + ' ms' : '', e.data.payload.isInitial ? 'as the page loaded' : ''].filter(Boolean).join(' · '),\n ...fields('Request headers', r.requestHeaders),\n ...(r.requestBody ? ['Request body', ' ' + r.requestBody] : []),\n ...fields('Response headers', r.responseHeaders),\n ...(r.responseBody ? ['Response body', ' ' + r.responseBody] : []),\n ];\n // No status is one the browser won't say (another origin's), not one that failed.\n rows.push({ at, kind: 'network', label: r.status ? String(r.status) : '···', bad: r.status >= 400, text: (r.method ? r.method + ' ' : '') + name, more });\n }\n }\n }\n const logged = rows.length > 0;\n const log = document.getElementById('log');\n if (logged) document.body.classList.add('logged');\n // The panel's room, where the window is wide enough to show it (as the stylesheet has it).\n const side = () => (logged && innerWidth >= 900 ? 340 : 0);\n\n // A recording with the mic starts paused: a browser plays sound only after a click, which Play is.\n const clips = await Promise.all((kept.voice ?? []).map(async (c) => ({ ...c, audio: Object.assign(new Audio(await from.clip(c.id)), { preload: 'auto' }) })));\n const t = Number.parseFloat(params.get('t') ?? '');\n // The player's frame, at most the window's room, the controls (80px) under it; 1:1 when bare.\n const size = () => bare\n ? { width: kept.viewport.width, height: kept.viewport.height }\n : embed\n ? { width: innerWidth - side(), height: innerHeight - 80 }\n : { width: Math.min(kept.viewport.width, innerWidth - 32 - side()), height: Math.min(kept.viewport.height, innerHeight - 90 - 80 - 16) };\n const Player = rrwebPlayer.default ?? rrwebPlayer.Player ?? rrwebPlayer;\n const player = new Player({\n target: main,\n props: {\n events,\n ...size(),\n autoPlay: !Number.isFinite(t) && clips.length === 0,\n showController: !bare,\n speedOption: [1, 2, 4, 8],\n tags: { ${JSON.stringify(MARKS)}: '#12b358' },\n inactiveColor: '#3f3f46',\n mouseTail: false,\n // A recorded canvas is drawn by rrweb's own script in the replay's frame, which then must run scripts\n // (the page's own were never recorded): only for a recording that has one.\n ...(events.some((e) => e.type === 3 && e.data.source === 9) ? { UNSAFE_replayCanvas: true } : {}),\n },\n });\n addEventListener('resize', () => { player.$set(size()); player.triggerResize(); });\n const replayer = player.getReplayer();\n const total = player.getMetaData().totalTime;\n\n // The marks as they were at this point: the latest custom event's, in the player's scaled wrapper, moved with the replay's scroll.\n const marks = Object.assign(document.createElement('div'), { id: 'marks' });\n replayer.wrapper.append(marks);\n replayer.on('custom-event', (e) => { if (e.data.tag === ${JSON.stringify(MARKS)}) marks.innerHTML = e.data.payload.svg; });\n\n let playing = false;\n player.addEventListener('ui-update-player-state', (e) => { playing = e.payload === 'playing'; });\n\n // The rows: a click goes to its moment, and shows the rest of it (where a line was logged from, a request's\n // headers and bodies). All set as text: it's the recorded page's, not ours.\n const list = log.querySelector('ol');\n const bar = main.querySelector('.rr-progress');\n for (const row of rows) {\n const cell = (tag, name, text) => Object.assign(document.createElement(tag), { className: name, textContent: text });\n const go = Object.assign(document.createElement('button'), { type: 'button' });\n go.append(cell('time', '', clock(row.at)), cell('span', 'label', row.label), cell('span', 'text', row.text));\n const more = Object.assign(cell('pre', '', row.more.join('\\\\n')), { hidden: true });\n row.el = Object.assign(document.createElement('li'), { className: row.kind + (row.bad ? ' bad' : row.warn ? ' warn' : '') });\n go.addEventListener('click', () => {\n player.goto(Math.min(row.at, total), playing);\n more.hidden = !more.hidden || row.more.length === 0;\n row.el.classList.toggle('open', !more.hidden);\n });\n row.el.append(go, more);\n list.append(row.el);\n // An error, or a request that failed, is a mark on the timeline too.\n if (row.bad && bar) bar.append(Object.assign(cell('i', 'bad-mark', ''), { title: row.text.slice(0, 200), style: 'left:' + (total > 0 ? (row.at / total) * 100 : 0) + '%' }));\n }\n for (const button of log.querySelectorAll('.filters button')) {\n button.addEventListener('click', () => {\n const on = button.getAttribute('aria-pressed') !== 'true';\n button.setAttribute('aria-pressed', String(on));\n if (button.dataset.hides) log.classList.toggle(button.dataset.hides, !on);\n if (button.dataset.shows) log.classList.toggle(button.dataset.shows, on);\n });\n }\n // The row the replay is at: the last whose moment has come, lit, the ones to come faint, kept in sight unless\n // the list is being read.\n let lit;\n const light = (now) => {\n let i = -1;\n while (i + 1 < rows.length && rows[i + 1].at <= now) i++;\n if (i === lit) return;\n lit = i;\n rows.forEach((row, k) => { row.el.classList.toggle('ahead', k > i); row.el.classList.toggle('now', k === i); });\n if (i >= 0 && !log.matches(':hover')) rows[i].el.scrollIntoView({ block: 'nearest' });\n };\n const follow = () => {\n const win = replayer.iframe.contentWindow;\n if (win) marks.style.transform = 'translate(' + -win.scrollX + 'px,' + -win.scrollY + 'px)';\n const now = Math.min(replayer.getCurrentTime(), total);\n light(now);\n const speed = replayer.config.speed ?? 1;\n // Each clip plays while the replay is inside it, at its speed, kept within a few frames of the replay's time.\n for (const c of clips) {\n const into = now - c.at;\n if (!playing || into < 0 || into >= c.duration) { if (!c.audio.paused) c.audio.pause(); continue; }\n if (c.audio.playbackRate !== speed) c.audio.playbackRate = speed;\n if (Math.abs(c.audio.currentTime * 1000 - into) > 250 * speed) c.audio.currentTime = into / 1000;\n if (c.audio.paused) c.audio.play().catch(() => {});\n }\n requestAnimationFrame(follow);\n };\n follow();\n\n if (Number.isFinite(t)) player.goto(Math.min(Math.max(0, t * 1000), total), false);\n document.body.dataset.ready = '';\n }).catch((e) => { document.querySelector('main').innerHTML = '<p class=\"problem\"></p>'; document.querySelector('.problem').textContent = e.message; });\n</script>\n</html>\n`;\n","/**\n * `deictic/recordings`: records the page with rrweb, for other plugins to attach (tasks does). No tab of\n * its own: `use('recordings').record()` shows a toolbar on the page (drag it to any edge) with annotate\n * mode's tools, where that plugin is loaded, a mic where the voice plugin is, and Stop and Discard. What's drawn while recording is in the\n * recording too, as custom events the replay draws.\n *\n * Recordings are kept under `.deictic/recordings`, the latest `keep`, as JSON: rrweb's\n * events, with the page, its viewport and how long it ran. `replay/<id>` plays one back in the browser.\n *\n * The page sends one as it goes (`begin`, then `part/<id>` each second or so, then `end/<id>` or `discard/<id>`),\n * not whole at the end, so it outlasts the page: after a reload, or a link to another page of the site, the next\n * page carries on with the same recording, which then holds each page in turn.\n */\nimport { appendFileSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, join, resolve } from 'node:path';\n\nimport type { record } from 'rrweb';\n\nimport { definePlugin } from '#src/index.ts';\nimport type { Masking, ResolvedMasking } from '#src/plugins/screenshots/index.ts';\nimport { keptIn } from '#src/tools/kept.ts';\n\nimport { replayPage } from './replay.ts';\n\nexport { MARKS } from './marks.ts';\nexport { replayPage, type ReplaySources } from './replay.ts';\n\n/** A recording as the page knows it: its ID, where it plays back, and how long it ran, in milliseconds. */\nexport interface Recording {\n id: string;\n url: string;\n duration: number;\n /** What the mic took while it was on, where the voice plugin is loaded. */\n voice?: VoiceClip[];\n}\n\n/** A stretch of the mic in a recording: the voice plugin's clip, and when it starts in the recording, in milliseconds. */\nexport interface VoiceClip {\n id: string;\n at: number;\n duration: number;\n}\n\n/** The page's half, for other plugins' page halves. */\nexport interface Recorder {\n /**\n * Records the page, with the toolbar, until Stop: answers the recording, kept by the dev server, or\n * nothing when it's discarded. Rejects while another is going, or when it couldn't be kept. A page load\n * doesn't end it: the next page of the site carries on, and `going` there answers what this would have.\n */\n record(): Promise<Recording | undefined>;\n /** Whether one is going. */\n recording(): boolean;\n /** The one going, as `record` answers it: also one a page before this started, carried on here. */\n going(): Promise<Recording | undefined> | undefined;\n}\n\n/** A plugin of rrweb's own, as its `record` takes them: what puts more than the page in a recording. */\nexport type RecordPlugin = NonNullable<NonNullable<Parameters<typeof record>[0]>['plugins']>[number];\n\n/**\n * What a plugin that adds to recordings answers in the page, under its name (`logs` and `network` do): the\n * recorder asks each it knows for its rrweb plugin as a recording starts, so nothing listens before, or after it stops.\n */\nexport interface Recorded {\n /** `sinceLoad`: the recording was going as this page loaded, so what the page did before now is its too. */\n plugin(from: { sinceLoad: boolean }): Promise<RecordPlugin>;\n}\n\n/** The server's half, for other plugins' server halves. */\nexport interface Recordings {\n /** A recording's JSON, or nothing for one not kept (any more). */\n read(id: string): { data: Uint8Array<ArrayBuffer>; name: string; type: 'application/json' } | undefined;\n}\n\n/** What a recording says as it begins: all of a `Kept` that's known then. */\nexport type Meta = Omit<Kept, 'events' | 'duration' | 'voice'>;\n\n/** What's kept: rrweb's events and what they can't say. */\nexport interface Kept {\n /** The page it started on. One that went on to others has each in its events, as rrweb's own: a `Meta`, then a snapshot. */\n page: string;\n viewport: { width: number; height: number };\n /**\n * The colour scheme the page was in, which rrweb doesn't record: the replay shows it in the same, or a\n * page styled by `prefers-color-scheme` would take the replay's.\n */\n colorScheme?: 'light' | 'dark';\n startedAt: number;\n duration: number;\n events: unknown[];\n /** The mic's clips, played along with the replay. */\n voice?: VoiceClip[];\n}\n\ndeclare module 'deictic' {\n interface ServerApis {\n recordings: Recordings;\n }\n interface ClientApis {\n recordings: Recorder;\n }\n}\n\nexport interface RecordingsOptions extends Masking {\n /** How many recordings to keep, the latest: 20 by default. */\n keep?: number;\n /** Where they're kept, from the project's root: `.deictic/recordings` by default. */\n dir?: string;\n /**\n * What a `<canvas>` draws (a chart, a map, WebGL), which is no part of the page's markup: a picture of each\n * canvas that changed, `fps` times a second, 2 by default. `false` for none, and a canvas replays blank.\n */\n canvas?: boolean | { fps?: number };\n}\n\nconst ID = /^[a-z0-9]+-[a-z0-9]+$/;\n/** What one recording may weigh: minutes of a busy page are a few MB. */\nconst MAX = 50 * 1024 * 1024;\n/** How long a recording nobody ended keeps its parts, in milliseconds. */\nconst STALE = 24 * 60 * 60 * 1000;\n\n/** rrweb's player (`rrweb-player`), served to the replay page: its build for a script tag, and its styles. */\nconst player = (file: string) => {\n try {\n return join(dirname(createRequire(import.meta.url).resolve('rrweb-player')), file);\n } catch {\n // Not installed: `file` answers what to add.\n return '';\n }\n};\n\nexport function recordings(options: RecordingsOptions = {}) {\n const keep = options.keep ?? 20;\n let dir = '';\n let taken = 0;\n const pathOf = (id: string) => join(dir, `${id}.json`);\n const read: Recordings['read'] = (id) => {\n if (!ID.test(id) || !existsSync(pathOf(id))) return undefined;\n return { data: new Uint8Array(readFileSync(pathOf(id))), name: `recording-${id}.json`, type: 'application/json' };\n };\n const partOf = (id: string) => join(dir, `${id}.part`);\n /** The recording going on that a request names, as its last segment: its ID, or the answer that there's none. */\n const going = (req: Request): string | Response => {\n const id = new URL(req.url).pathname.split('/').at(-1) ?? '';\n if (ID.test(id) && existsSync(partOf(id))) return id;\n return Response.json({ problem: `no recording ${id} is going any more: record again` }, { status: 404 });\n };\n const json = async <T>(req: Request): Promise<T | undefined> => {\n try {\n return (await req.json()) as T;\n } catch {\n return undefined;\n }\n };\n /** A recording begun: its ID, and the file its parts are added to, which starts with what `Kept` says besides the events. */\n const begin = (meta: Meta) => {\n // Sorts by when it was made, which is what pruning keeps by: the count orders two in one millisecond.\n const id = `${Date.now().toString(36).padStart(9, '0')}${(taken++ % 1296).toString(36).padStart(2, '0')}-${crypto.randomUUID().slice(0, 8)}`;\n mkdirSync(dir, { recursive: true });\n // One nobody ended, as its tab was closed: gone a day on.\n for (const f of readdirSync(dir)) if (f.endsWith('.part') && Date.now() - statSync(join(dir, f)).mtimeMs > STALE) rmSync(join(dir, f));\n\n writeFileSync(partOf(id), `${JSON.stringify(meta)}\\n`);\n return id;\n };\n /** The parts as one recording, in their order whatever order they came in: a page's last may overtake the one before. */\n const end = (id: string, last: Pick<Kept, 'duration' | 'voice'>): boolean => {\n const [meta, ...lines] = readFileSync(partOf(id), 'utf8').trimEnd().split('\\n');\n const parts = lines.map((line) => JSON.parse(line) as { seq: number; events: unknown[] });\n const events = parts.toSorted((a, b) => a.seq - b.seq).flatMap((part) => part.events);\n rmSync(partOf(id));\n if (events.length === 0) return false;\n const kept: Kept = { ...(JSON.parse(meta!) as Meta), ...last, events };\n writeFileSync(pathOf(id), JSON.stringify(kept));\n const all = readdirSync(dir)\n .filter((f) => f.endsWith('.json'))\n .toSorted();\n for (const old of all.slice(0, Math.max(0, all.length - keep))) rmSync(join(dir, old));\n return true;\n };\n const file = (path: string, type: string) => {\n if (!existsSync(path)) return new Response('rrweb-player is missing: add it to your devDependencies', { status: 404 });\n return new Response(readFileSync(path), { headers: { 'content-type': type } });\n };\n\n return definePlugin<never, never, never, Recordings>({\n name: 'recordings',\n client: 'deictic/recordings/client',\n packages: ['rrweb', 'rrweb-player'],\n clientOptions: {\n masking: {\n blockClass: options.blockClass ?? 'rr-block',\n blockSelector: options.blockSelector,\n maskTextClass: options.maskTextClass ?? 'rr-mask',\n maskTextSelector: options.maskTextSelector,\n maskAllInputs: options.maskAllInputs ?? false,\n } satisfies ResolvedMasking,\n canvas: options.canvas === false ? false : { fps: (options.canvas === true ? undefined : options.canvas?.fps) ?? 2 },\n },\n setup: ({ root }) => {\n dir = options.dir === undefined ? keptIn(root, 'recordings') : resolve(root, options.dir);\n return { read };\n },\n routes: {\n // A recording starts: the page, its viewport and when. Its events come in parts, as they happen, so a page\n // load in the middle loses none of them, and the next page carries on under the same ID.\n begin: async (req) => {\n const meta = await json<Partial<Meta>>(req);\n if (meta?.viewport === undefined || typeof meta.page !== 'string' || typeof meta.startedAt !== 'number')\n return Response.json({ problem: 'send the page, its viewport and when it started, as JSON' }, { status: 400 });\n const { page, viewport, colorScheme, startedAt } = meta;\n return Response.json({ id: begin({ page, viewport, ...(colorScheme === undefined ? {} : { colorScheme }), startedAt }) });\n },\n // `part/<id>?seq=<n>`: more of its events, a JSON array, and their place among the parts.\n part: async (req) => {\n const id = going(req);\n if (typeof id !== 'string') return id;\n const seq = Number(new URL(req.url).searchParams.get('seq') ?? 'none');\n const events = await json<unknown>(req);\n if (!Array.isArray(events) || !Number.isInteger(seq))\n return Response.json({ problem: 'send the events as a JSON array, and `seq`, their place' }, { status: 400 });\n const line = `${JSON.stringify({ seq, events })}\\n`;\n if (statSync(partOf(id)).size + line.length > MAX)\n return Response.json({ problem: `a recording may weigh ${MAX / 1024 / 1024} MB at most: stop this one` }, { status: 413 });\n appendFileSync(partOf(id), line);\n return Response.json({ id });\n },\n // `end/<id>`: it's over, and kept: how long it ran, and the mic's clips.\n end: async (req) => {\n const id = going(req);\n if (typeof id !== 'string') return id;\n const last = await json<Partial<Kept>>(req);\n if (typeof last?.duration !== 'number') return Response.json({ problem: 'send how long it ran, as JSON' }, { status: 400 });\n if (!end(id, { duration: last.duration, ...(last.voice === undefined ? {} : { voice: last.voice }) }))\n return Response.json({ problem: 'the recording has no events: record for a moment longer' }, { status: 400 });\n return Response.json({ id });\n },\n // `discard/<id>`: it's over, and not kept.\n discard: (req) => {\n const id = going(req);\n if (typeof id !== 'string') return id;\n rmSync(partOf(id));\n return Response.json({ id });\n },\n // `recording/<id>`: the JSON, for the replay page.\n recording: (req) => {\n const found = read(new URL(req.url).pathname.split('/').at(-1) ?? '');\n if (found === undefined) return new Response('no such recording, or not kept any more', { status: 404 });\n return new Response(found.data, { headers: { 'content-type': found.type, 'cache-control': 'no-store' } });\n },\n // `replay/<id>`: a page that plays it back.\n replay: () => new Response(replayPage(), { headers: { 'content-type': 'text/html; charset=utf-8' } }),\n 'player.js': () => file(player('rrweb-player.umd.min.cjs'), 'text/javascript'),\n 'player.css': () => file(player('style.css'), 'text/css'),\n },\n });\n}\n\nexport default recordings;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAa,cAAc,EAAE,SAAS,MAAM,WAA0B,CAAC,MAAM;;;;;+BAK9C,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA0EvB,OAAO,wBACpB,WAAW,KAA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;GAC7B;GAEA,UAAU,QAAQ;IAChB,MAAM,KAAK,MAAM,GAAG;IACpB,IAAI,OAAO,OAAO,UAAU,OAAO;IACnC,OAAO,OAAO,EAAE,CAAC;IACjB,OAAO,SAAS,KAAK,EAAE,GAAG,CAAC;GAC7B;GAEA,YAAY,QAAQ;IAClB,MAAM,QAAQ,KAAK,IAAI,IAAI,IAAI,GAAG,CAAC,CAAC,SAAS,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE;IACpE,IAAI,UAAU,KAAA,GAAW,OAAO,IAAI,SAAS,2CAA2C,EAAE,QAAQ,IAAI,CAAC;IACvG,OAAO,IAAI,SAAS,MAAM,MAAM,EAAE,SAAS;KAAE,gBAAgB,MAAM;KAAM,iBAAiB;IAAW,EAAE,CAAC;GAC1G;GAEA,cAAc,IAAI,SAAS,WAAW,GAAG,EAAE,SAAS,EAAE,gBAAgB,2BAA2B,EAAE,CAAC;GACpG,mBAAmB,KAAK,OAAO,0BAA0B,GAAG,iBAAiB;GAC7E,oBAAoB,KAAK,OAAO,WAAW,GAAG,UAAU;EAC1D;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"recordings.js","names":[],"sources":["../../src/plugins/recordings/replay.ts","../../src/plugins/recordings/index.ts"],"sourcesContent":["/**\n * The replay page, `replay/<id>`: rrweb's own player (`rrweb-player`), its timeline, speeds, skipping idle\n * stretches and fullscreen, sized to the window, with what it doesn't do drawn over it:\n *\n * - The page shows in the colour scheme it was recorded in, whatever the viewer's: the replay's iframe\n * answers `prefers-color-scheme` as the viewer's browser does, so the recorded CSS's queries are rewritten\n * before it's replayed, the recorded scheme's to always match and the other's never.\n * - The marks drawn while recording come as custom events, an SVG in page coordinates each; they're drawn\n * over the replay in the player's own scaled wrapper, moved with its scroll, rather than into its document,\n * which the replayer rebuilds. Each is a marker on the timeline.\n * - The voice clips play in step, at the player's speed. A recording with voice starts paused, as a browser\n * plays sound only after a click.\n * - What the page logged and asked for (rrweb's console and network plugins' events, which its player doesn't\n * show) is a list beside the replay, where the window has the room: the row the replay is at is lit, a click on\n * one goes to its moment and shows the rest of it, and each error and failed request is a mark on the timeline.\n * - A recorded canvas is replayed (`UNSAFE_replayCanvas`, which lets the replay's frame run rrweb's own script\n * to draw it), for a recording that has one.\n *\n * `?t=<seconds>` opens it paused there, and `&bare` without the controls at the recorded size, 1:1, for a\n * screenshot; `?embed` is it filling a frame, with no header of its own (the lightbox's); `body[data-ready]` says\n * it's in place.\n *\n * The plugin's routes serve it, the player and what it plays. A page with no server behind it (a `standalone` build)\n * publishes it as a file instead, `replayPage(sources)`: which recording is `?id=`, and a script of its own says\n * where one is.\n */\nimport { MARKS, REACT } from './marks.ts';\n\n/** Where the replay page finds what the plugin's routes would serve it, for a page published as a file. */\nexport interface ReplaySources {\n /** The folder `player.js` and `player.css` are in (`rrweb-player`'s `rrweb-player.umd.min.cjs` and `style.css`), from the page: `..`, the routes', by default. */\n player?: string;\n /**\n * A script, from the page, that sets `globalThis.deicticReplay` before the page asks: `recording(id)` answers the\n * recording (a `Kept`) and `clip(id)` a voice clip's URL, either as a promise. The routes by default.\n */\n source?: string;\n}\n\n/** The replay page's HTML: the routes' as it is, or one for a page published as a file. */\nexport const replayPage = ({ player = '..', source }: ReplaySources = {}) => `<!doctype html>\n<html lang=\"en\">\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<title>Recording · deictic</title>\n<link rel=\"stylesheet\" href=\"${player}/player.css\">\n<style>\n :root { color-scheme: dark; --accent: #12b358; }\n body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: #18181b; color: #fafafa; font: 13px/1.4 system-ui, sans-serif; }\n header { display: flex; gap: 10px; align-items: center; padding: 10px 16px; border-bottom: 1px solid #3f3f46; }\n header a { color: #a1a1aa; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n #stage { flex: 1; display: flex; min-height: 0; }\n main { flex: 1; min-width: 0; display: flex; justify-content: center; align-items: flex-start; padding: 16px; }\n body.bare header { display: none; }\n body.bare main { padding: 0; }\n body.embed header { display: none; }\n body.embed main { padding: 0; }\n /* What the page logged and asked for, beside the replay: the window's height, its list scrolling in it. */\n #log { display: none; flex: none; width: 340px; flex-direction: column; border-left: 1px solid #3f3f46; background: #1f1f23; }\n body.logged { height: 100vh; }\n body.logged #log { display: flex; }\n @media (max-width: 899px) { body.logged #log { display: none; } }\n #log .filters { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid #3f3f46; }\n #log .filters button { padding: 3px 8px; border: 1px solid #3f3f46; border-radius: 6px; background: none; color: #a1a1aa; font: inherit; font-size: 12px; cursor: pointer; }\n #log .filters button[aria-pressed='true'] { color: #fafafa; background: #3f3f46; }\n #log ol { flex: 1; min-height: 0; overflow: auto; margin: 0; padding: 0; list-style: none; font: 12px/1.45 ui-monospace, monospace; }\n #log li { border-bottom: 1px solid #2e2e33; border-left: 2px solid transparent; }\n #log li.ahead { opacity: 0.45; }\n #log li.now { border-left-color: var(--accent); background: #27272a; }\n #log li.warn .label { color: #fbbf24; }\n #log li.bad .label, #log li.bad .text { color: #f87171; }\n #log li > button { display: flex; gap: 8px; align-items: baseline; width: 100%; padding: 5px 8px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }\n #log li > button:hover { background: #2e2e33; }\n #log time { flex: none; color: #71717a; }\n #log .label { flex: none; min-width: 4ch; color: #a1a1aa; }\n #log .text { min-width: 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }\n #log li.open .text { display: block; white-space: pre-wrap; }\n #log pre { margin: 0; padding: 2px 8px 8px calc(8px + 6ch + 8px); color: #a1a1aa; font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; }\n #log.no-console li.console, #log.no-network li.network, #log.no-react li.react, #log.only-bad li:not(.bad) { display: none; }\n #log li.react .label { color: #58c4dc; }\n #log li.react.warn .label { color: #fbbf24; }\n #main .rr-player .rr-progress .slow-mark { position: absolute; top: -3px; width: 3px; height: 10px; margin-left: -1px; border-radius: 1px; background: #fbbf24; pointer-events: none; }\n #main .rr-player .rr-progress .bad-mark { position: absolute; top: -3px; width: 3px; height: 10px; margin-left: -1px; border-radius: 1px; background: #f87171; pointer-events: none; }\n body.embed #main .rr-player { box-shadow: none; border-radius: 0; }\n #marks { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 3; }\n #marks svg { position: absolute; left: 0; top: 0; overflow: visible; }\n .problem { color: #f87171; padding: 16px; }\n /* rrweb-player, in the dark of the rest of deictic. Its rules repeat Svelte's scoping class, so these start\n from #main, which outweighs any number of classes. */\n #main .rr-player { background: #27272a; box-shadow: 0 12px 32px rgb(0 0 0 / 0.5); border-radius: 8px; overflow: hidden; }\n body.bare #main .rr-player { box-shadow: none; border-radius: 0; }\n #main .rr-player .rr-player__frame { background: #fff; }\n #main .rr-player .rr-controller { background: #18181b; border-top: 1px solid #3f3f46; border-radius: 0; }\n #main .rr-player .rr-timeline__time { color: #a1a1aa; font: 12px ui-monospace, monospace; }\n #main .rr-player .rr-progress { background: #3f3f46; border-color: #18181b; }\n #main .rr-player .rr-progress__step { background: color-mix(in srgb, var(--accent) 45%, transparent); }\n #main .rr-player .rr-progress__handler { background: var(--accent); }\n #main .rr-player .rr-controller__btns button { color: #e4e4e7; }\n #main .rr-player .rr-controller__btns button:disabled { color: #52525b; }\n #main .rr-player .rr-controller__btns button svg { fill: currentColor; }\n #main .rr-player .rr-controller__btns button.active { color: #04130b; background: var(--accent); }\n #main .rr-player .rr-controller__btns button:active { background: color-mix(in srgb, var(--accent) 60%, transparent); }\n #main .rr-player .switch .label { color: #e4e4e7; }\n #main .rr-player .switch.disabled .label { color: #52525b; }\n #main .rr-player .switch label:before { background: #52525b; }\n #main .rr-player .switch input:checked + label:before { background: var(--accent); }\n</style>\n<header>\n <strong>Recording</strong>\n <a id=\"page\" target=\"_blank\" rel=\"noreferrer\"></a>\n</header>\n<div id=\"stage\">\n <main id=\"main\"></main>\n <aside id=\"log\" aria-label=\"Console and network\">\n <div class=\"filters\">\n <button type=\"button\" data-hides=\"no-console\" aria-pressed=\"true\">Console</button>\n <button type=\"button\" data-hides=\"no-network\" aria-pressed=\"true\">Network</button>\n <button type=\"button\" data-hides=\"no-react\" aria-pressed=\"true\" hidden title=\"React's commits: what rendered, how long it took, and why\">React</button>\n <button type=\"button\" data-shows=\"only-bad\" aria-pressed=\"false\" title=\"Errors, and requests that failed\">Problems</button>\n </div>\n <ol></ol>\n </aside>\n</div>\n<script src=\"${player}/player.js\"></script>${\n source === undefined\n ? ''\n : `\n<script src=\"${source}\"></script>`\n}\n<script>\n const params = new URLSearchParams(location.search);\n const bare = params.has('bare');\n const embed = params.has('embed');\n if (bare) document.body.classList.add('bare');\n if (embed) document.body.classList.add('embed');\n const id = params.get('id') ?? location.pathname.split('/').at(-1);\n // The plugin's routes, unless the page was given a source of its own (\\`replayPage\\`).\n const from = globalThis.deicticReplay ?? {\n recording: (id) => fetch('../recording/' + id).then((r) => (r.ok ? r.json() : r.text().then((t) => Promise.reject(new Error(t))))),\n clip: (id) => '../../voice/clip/' + id,\n };\n Promise.resolve(from.recording(id)).then(async (kept) => {\n const scheme = kept.colorScheme ?? 'light';\n const events = JSON.parse(\n JSON.stringify(kept.events).replace(/\\\\(\\\\s*prefers-color-scheme\\\\s*:\\\\s*(light|dark)\\\\s*\\\\)/g, (_, s) =>\n s === scheme ? '(min-width: 0px)' : '(max-width: 0px) and (min-width: 1px)',\n ),\n );\n page.textContent = kept.page;\n page.href = kept.page;\n\n // What the page logged and asked for, where the recording has it (rrweb's console and network plugins' events):\n // a row each, in their order, beside the replay. Not in a bare one, which is the page alone.\n const t0 = events[0].timestamp;\n const clock = (ms) => { const s = Math.max(0, ms) / 1000; return Math.floor(s / 60) + ':' + (s % 60).toFixed(1).padStart(4, '0'); };\n // An argument is kept as JSON: a string reads better without its quotes.\n const plain = (arg) => { try { const v = JSON.parse(arg); return typeof v === 'string' ? v : arg; } catch { return arg; } };\n const origin = (() => { try { return new URL(kept.page).origin; } catch { return ''; } })();\n const fields = (title, held) => (held && Object.keys(held).length > 0 ? [title, ...Object.entries(held).map(([k, v]) => ' ' + k + ': ' + v)] : []);\n const rows = [];\n // React's commits, where the recording had them on: a row an entry, slow ones (past a frame) marked.\n const ms = (n) => (n === undefined ? '' : (n < 10 ? n.toFixed(1) : Math.round(n)) + ' ms');\n for (const e of events) {\n if (e.type !== 5 || bare || e.data.tag !== ${JSON.stringify(REACT)}) continue;\n const at = e.timestamp - t0;\n const c = e.data.payload;\n if (c.on !== undefined) {\n rows.push({ at, kind: 'react', label: 'React', text: c.on ? 'commits recorded from here' : 'commits no longer recorded', more: [] });\n continue;\n }\n const named = (c.components ?? []).map((r) => r.name + (r.count > 1 ? ' ×' + r.count : '') + ' (' + r.why + ')');\n const text = (named.length > 0 ? named.slice(0, 3).join(', ') : (c.more ?? 0) + ' components') + (named.length > 3 || (c.more && named.length > 0) ? ', …' : '');\n const more = [\n [c.commits > 1 ? c.commits + ' commits' + (c.over === undefined ? '' : ' over ' + (c.over / 1000).toFixed(1) + ' s') : '1 commit', c.priority, ms(c.ms), c.slowest === undefined ? '' : 'slowest ' + ms(c.slowest)].filter(Boolean).join(' · '),\n ...(c.components ?? []).map((r) => [r.name + (r.count > 1 ? ' ×' + r.count : ''), r.at, ms(r.ms), r.selfMs === undefined ? '' : ms(r.selfMs) + ' own', r.why].filter(Boolean).join(' · ')),\n ...(c.more ? ['and ' + c.more + ' more'] : []),\n ];\n // One slow commit is what makes a page stutter, not many quick ones.\n const slow = (c.slowest ?? c.ms) > 16;\n rows.push({ at, kind: 'react', label: c.ms === undefined ? 'React' : ms(c.ms), warn: slow, slow, text: (c.over === undefined ? '' : c.commits + ' commits: ') + text, more });\n }\n for (const e of events) {\n if (e.type !== 6 || bare) continue;\n const at = e.timestamp - t0;\n if (e.data.plugin === 'rrweb/console@1') {\n const { level, payload = [], trace = [] } = e.data.payload;\n rows.push({ at, kind: 'console', label: level, bad: level === 'error' || level === 'assert', warn: level === 'warn', text: payload.map(plain).join(' '), more: trace.map((l) => 'at ' + l) });\n }\n if (e.data.plugin === 'rrweb/network@1') {\n for (const r of e.data.payload.requests ?? []) {\n // The page's own origin goes without saying.\n let name = r.name;\n try { const u = new URL(r.name); if (u.origin === origin) name = u.pathname + u.search + u.hash; } catch {}\n const more = [\n r.name,\n [r.initiatorType, Number.isFinite(r.duration) ? Math.round(r.duration) + ' ms' : '', e.data.payload.isInitial ? 'as the page loaded' : ''].filter(Boolean).join(' · '),\n ...fields('Request headers', r.requestHeaders),\n ...(r.requestBody ? ['Request body', ' ' + r.requestBody] : []),\n ...fields('Response headers', r.responseHeaders),\n ...(r.responseBody ? ['Response body', ' ' + r.responseBody] : []),\n ];\n // No status is one the browser won't say (another origin's), not one that failed.\n rows.push({ at, kind: 'network', label: r.status ? String(r.status) : '···', bad: r.status >= 400, text: (r.method ? r.method + ' ' : '') + name, more });\n }\n }\n }\n rows.sort((a, b) => a.at - b.at);\n const logged = rows.length > 0;\n const log = document.getElementById('log');\n if (rows.some((r) => r.kind === 'react')) log.querySelector('[data-hides=\"no-react\"]').hidden = false;\n if (logged) document.body.classList.add('logged');\n // The panel's room, where the window is wide enough to show it (as the stylesheet has it).\n const side = () => (logged && innerWidth >= 900 ? 340 : 0);\n\n // A recording with the mic starts paused: a browser plays sound only after a click, which Play is.\n const clips = await Promise.all((kept.voice ?? []).map(async (c) => ({ ...c, audio: Object.assign(new Audio(await from.clip(c.id)), { preload: 'auto' }) })));\n const t = Number.parseFloat(params.get('t') ?? '');\n // The player's frame, at most the window's room, the controls (80px) under it; 1:1 when bare.\n const size = () => bare\n ? { width: kept.viewport.width, height: kept.viewport.height }\n : embed\n ? { width: innerWidth - side(), height: innerHeight - 80 }\n : { width: Math.min(kept.viewport.width, innerWidth - 32 - side()), height: Math.min(kept.viewport.height, innerHeight - 90 - 80 - 16) };\n const Player = rrwebPlayer.default ?? rrwebPlayer.Player ?? rrwebPlayer;\n const player = new Player({\n target: main,\n props: {\n events,\n ...size(),\n autoPlay: !Number.isFinite(t) && clips.length === 0,\n showController: !bare,\n speedOption: [1, 2, 4, 8],\n tags: { ${JSON.stringify(MARKS)}: '#12b358' },\n inactiveColor: '#3f3f46',\n mouseTail: false,\n // A recorded canvas is drawn by rrweb's own script in the replay's frame, which then must run scripts\n // (the page's own were never recorded): only for a recording that has one.\n ...(events.some((e) => e.type === 3 && e.data.source === 9) ? { UNSAFE_replayCanvas: true } : {}),\n },\n });\n addEventListener('resize', () => { player.$set(size()); player.triggerResize(); });\n const replayer = player.getReplayer();\n const total = player.getMetaData().totalTime;\n\n // The marks as they were at this point: the latest custom event's, in the player's scaled wrapper, moved with the replay's scroll.\n const marks = Object.assign(document.createElement('div'), { id: 'marks' });\n replayer.wrapper.append(marks);\n replayer.on('custom-event', (e) => { if (e.data.tag === ${JSON.stringify(MARKS)}) marks.innerHTML = e.data.payload.svg; });\n\n let playing = false;\n player.addEventListener('ui-update-player-state', (e) => { playing = e.payload === 'playing'; });\n\n // The rows: a click goes to its moment, and shows the rest of it (where a line was logged from, a request's\n // headers and bodies). All set as text: it's the recorded page's, not ours.\n const list = log.querySelector('ol');\n const bar = main.querySelector('.rr-progress');\n for (const row of rows) {\n const cell = (tag, name, text) => Object.assign(document.createElement(tag), { className: name, textContent: text });\n const go = Object.assign(document.createElement('button'), { type: 'button' });\n go.append(cell('time', '', clock(row.at)), cell('span', 'label', row.label), cell('span', 'text', row.text));\n const more = Object.assign(cell('pre', '', row.more.join('\\\\n')), { hidden: true });\n row.el = Object.assign(document.createElement('li'), { className: row.kind + (row.bad ? ' bad' : row.warn ? ' warn' : '') });\n go.addEventListener('click', () => {\n player.goto(Math.min(row.at, total), playing);\n more.hidden = !more.hidden || row.more.length === 0;\n row.el.classList.toggle('open', !more.hidden);\n });\n row.el.append(go, more);\n list.append(row.el);\n // An error, or a request that failed, is a mark on the timeline too.\n if (row.slow && bar) bar.append(Object.assign(cell('i', 'slow-mark', ''), { title: row.label + ': ' + row.text.slice(0, 200), style: 'left:' + (total > 0 ? (row.at / total) * 100 : 0) + '%' }));\n if (row.bad && bar) bar.append(Object.assign(cell('i', 'bad-mark', ''), { title: row.text.slice(0, 200), style: 'left:' + (total > 0 ? (row.at / total) * 100 : 0) + '%' }));\n }\n for (const button of log.querySelectorAll('.filters button')) {\n button.addEventListener('click', () => {\n const on = button.getAttribute('aria-pressed') !== 'true';\n button.setAttribute('aria-pressed', String(on));\n if (button.dataset.hides) log.classList.toggle(button.dataset.hides, !on);\n if (button.dataset.shows) log.classList.toggle(button.dataset.shows, on);\n });\n }\n // The row the replay is at: the last whose moment has come, lit, the ones to come faint, kept in sight unless\n // the list is being read.\n let lit;\n const light = (now) => {\n let i = -1;\n while (i + 1 < rows.length && rows[i + 1].at <= now) i++;\n if (i === lit) return;\n lit = i;\n rows.forEach((row, k) => { row.el.classList.toggle('ahead', k > i); row.el.classList.toggle('now', k === i); });\n if (i >= 0 && !log.matches(':hover')) rows[i].el.scrollIntoView({ block: 'nearest' });\n };\n const follow = () => {\n const win = replayer.iframe.contentWindow;\n if (win) marks.style.transform = 'translate(' + -win.scrollX + 'px,' + -win.scrollY + 'px)';\n const now = Math.min(replayer.getCurrentTime(), total);\n light(now);\n const speed = replayer.config.speed ?? 1;\n // Each clip plays while the replay is inside it, at its speed, kept within a few frames of the replay's time.\n for (const c of clips) {\n const into = now - c.at;\n if (!playing || into < 0 || into >= c.duration) { if (!c.audio.paused) c.audio.pause(); continue; }\n if (c.audio.playbackRate !== speed) c.audio.playbackRate = speed;\n if (Math.abs(c.audio.currentTime * 1000 - into) > 250 * speed) c.audio.currentTime = into / 1000;\n if (c.audio.paused) c.audio.play().catch(() => {});\n }\n requestAnimationFrame(follow);\n };\n follow();\n\n if (Number.isFinite(t)) player.goto(Math.min(Math.max(0, t * 1000), total), false);\n document.body.dataset.ready = '';\n }).catch((e) => { document.querySelector('main').innerHTML = '<p class=\"problem\"></p>'; document.querySelector('.problem').textContent = e.message; });\n</script>\n</html>\n`;\n","/**\n * `deictic/recordings`: records the page with rrweb, for other plugins to attach (tasks does). No tab of\n * its own: `use('recordings').record()` shows a toolbar on the page (drag it to any edge) with annotate\n * mode's tools, where that plugin is loaded, a mic where the voice plugin is, and Stop and Discard. What's drawn while recording is in the\n * recording too, as custom events the replay draws.\n *\n * Recordings are kept under `.deictic/recordings`, the latest `keep`, as JSON: rrweb's\n * events, with the page, its viewport and how long it ran. `replay/<id>` plays one back in the browser.\n *\n * The page sends one as it goes (`begin`, then `part/<id>` each second or so, then `end/<id>` or `discard/<id>`),\n * not whole at the end, so it outlasts the page: after a reload, or a link to another page of the site, the next\n * page carries on with the same recording, which then holds each page in turn.\n */\nimport { appendFileSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, join, resolve } from 'node:path';\n\nimport type { record } from 'rrweb';\n\nimport { definePlugin } from '#src/index.ts';\nimport type { Masking, ResolvedMasking } from '#src/plugins/screenshots/index.ts';\nimport { keptIn } from '#src/tools/kept.ts';\n\nimport { replayPage } from './replay.ts';\n\nexport { MARKS } from './marks.ts';\nexport { replayPage, type ReplaySources } from './replay.ts';\n\n/** A recording as the page knows it: its ID, where it plays back, and how long it ran, in milliseconds. */\nexport interface Recording {\n id: string;\n url: string;\n duration: number;\n /** What the mic took while it was on, where the voice plugin is loaded. */\n voice?: VoiceClip[];\n}\n\n/** A stretch of the mic in a recording: the voice plugin's clip, and when it starts in the recording, in milliseconds. */\nexport interface VoiceClip {\n id: string;\n at: number;\n duration: number;\n}\n\n/** The page's half, for other plugins' page halves. */\nexport interface Recorder {\n /**\n * Records the page, with the toolbar, until Stop: answers the recording, kept by the dev server, or\n * nothing when it's discarded. Rejects while another is going, or when it couldn't be kept. A page load\n * doesn't end it: the next page of the site carries on, and `going` there answers what this would have.\n */\n record(): Promise<Recording | undefined>;\n /** Whether one is going. */\n recording(): boolean;\n /** The one going, as `record` answers it: also one a page before this started, carried on here. */\n going(): Promise<Recording | undefined> | undefined;\n}\n\n/** A plugin of rrweb's own, as its `record` takes them: what puts more than the page in a recording. */\nexport type RecordPlugin = NonNullable<NonNullable<Parameters<typeof record>[0]>['plugins']>[number];\n\n/**\n * What a plugin that adds to recordings answers in the page, under its name (`logs` and `network` do): the\n * recorder asks each it knows for its rrweb plugin as a recording starts, so nothing listens before, or after it stops.\n */\nexport interface Recorded {\n /** `sinceLoad`: the recording was going as this page loaded, so what the page did before now is its too. */\n plugin(from: { sinceLoad: boolean }): Promise<RecordPlugin>;\n}\n\n/** The server's half, for other plugins' server halves. */\nexport interface Recordings {\n /** A recording's JSON, or nothing for one not kept (any more). */\n read(id: string): { data: Uint8Array<ArrayBuffer>; name: string; type: 'application/json' } | undefined;\n}\n\n/** What a recording says as it begins: all of a `Kept` that's known then. */\nexport type Meta = Omit<Kept, 'events' | 'duration' | 'voice'>;\n\n/** What's kept: rrweb's events and what they can't say. */\nexport interface Kept {\n /** The page it started on. One that went on to others has each in its events, as rrweb's own: a `Meta`, then a snapshot. */\n page: string;\n viewport: { width: number; height: number };\n /**\n * The colour scheme the page was in, which rrweb doesn't record: the replay shows it in the same, or a\n * page styled by `prefers-color-scheme` would take the replay's.\n */\n colorScheme?: 'light' | 'dark';\n startedAt: number;\n duration: number;\n events: unknown[];\n /** The mic's clips, played along with the replay. */\n voice?: VoiceClip[];\n}\n\ndeclare module 'deictic' {\n interface ServerApis {\n recordings: Recordings;\n }\n interface ClientApis {\n recordings: Recorder;\n }\n}\n\nexport interface RecordingsOptions extends Masking {\n /** How many recordings to keep, the latest: 20 by default. */\n keep?: number;\n /** Where they're kept, from the project's root: `.deictic/recordings` by default. */\n dir?: string;\n /**\n * What a `<canvas>` draws (a chart, a map, WebGL), which is no part of the page's markup: a picture of each\n * canvas that changed, `fps` times a second, 2 by default. `false` for none, and a canvas replays blank.\n */\n canvas?: boolean | { fps?: number };\n}\n\nconst ID = /^[a-z0-9]+-[a-z0-9]+$/;\n/** What one recording may weigh: minutes of a busy page are a few MB. */\nconst MAX = 50 * 1024 * 1024;\n/** How long a recording nobody ended keeps its parts, in milliseconds. */\nconst STALE = 24 * 60 * 60 * 1000;\n\n/** rrweb's player (`rrweb-player`), served to the replay page: its build for a script tag, and its styles. */\nconst player = (file: string) => {\n try {\n return join(dirname(createRequire(import.meta.url).resolve('rrweb-player')), file);\n } catch {\n // Not installed: `file` answers what to add.\n return '';\n }\n};\n\nexport function recordings(options: RecordingsOptions = {}) {\n const keep = options.keep ?? 20;\n let dir = '';\n let taken = 0;\n const pathOf = (id: string) => join(dir, `${id}.json`);\n const read: Recordings['read'] = (id) => {\n if (!ID.test(id) || !existsSync(pathOf(id))) return undefined;\n return { data: new Uint8Array(readFileSync(pathOf(id))), name: `recording-${id}.json`, type: 'application/json' };\n };\n const partOf = (id: string) => join(dir, `${id}.part`);\n /** The recording going on that a request names, as its last segment: its ID, or the answer that there's none. */\n const going = (req: Request): string | Response => {\n const id = new URL(req.url).pathname.split('/').at(-1) ?? '';\n if (ID.test(id) && existsSync(partOf(id))) return id;\n return Response.json({ problem: `no recording ${id} is going any more: record again` }, { status: 404 });\n };\n const json = async <T>(req: Request): Promise<T | undefined> => {\n try {\n return (await req.json()) as T;\n } catch {\n return undefined;\n }\n };\n /** A recording begun: its ID, and the file its parts are added to, which starts with what `Kept` says besides the events. */\n const begin = (meta: Meta) => {\n // Sorts by when it was made, which is what pruning keeps by: the count orders two in one millisecond.\n const id = `${Date.now().toString(36).padStart(9, '0')}${(taken++ % 1296).toString(36).padStart(2, '0')}-${crypto.randomUUID().slice(0, 8)}`;\n mkdirSync(dir, { recursive: true });\n // One nobody ended, as its tab was closed: gone a day on.\n for (const f of readdirSync(dir)) if (f.endsWith('.part') && Date.now() - statSync(join(dir, f)).mtimeMs > STALE) rmSync(join(dir, f));\n\n writeFileSync(partOf(id), `${JSON.stringify(meta)}\\n`);\n return id;\n };\n /** The parts as one recording, in their order whatever order they came in: a page's last may overtake the one before. */\n const end = (id: string, last: Pick<Kept, 'duration' | 'voice'>): boolean => {\n const [meta, ...lines] = readFileSync(partOf(id), 'utf8').trimEnd().split('\\n');\n const parts = lines.map((line) => JSON.parse(line) as { seq: number; events: unknown[] });\n const events = parts.toSorted((a, b) => a.seq - b.seq).flatMap((part) => part.events);\n rmSync(partOf(id));\n if (events.length === 0) return false;\n const kept: Kept = { ...(JSON.parse(meta!) as Meta), ...last, events };\n writeFileSync(pathOf(id), JSON.stringify(kept));\n const all = readdirSync(dir)\n .filter((f) => f.endsWith('.json'))\n .toSorted();\n for (const old of all.slice(0, Math.max(0, all.length - keep))) rmSync(join(dir, old));\n return true;\n };\n const file = (path: string, type: string) => {\n if (!existsSync(path)) return new Response('rrweb-player is missing: add it to your devDependencies', { status: 404 });\n return new Response(readFileSync(path), { headers: { 'content-type': type } });\n };\n\n return definePlugin<never, never, never, Recordings>({\n name: 'recordings',\n client: 'deictic/recordings/client',\n packages: ['rrweb', 'rrweb-player'],\n clientOptions: {\n masking: {\n blockClass: options.blockClass ?? 'rr-block',\n blockSelector: options.blockSelector,\n maskTextClass: options.maskTextClass ?? 'rr-mask',\n maskTextSelector: options.maskTextSelector,\n maskAllInputs: options.maskAllInputs ?? false,\n } satisfies ResolvedMasking,\n canvas: options.canvas === false ? false : { fps: (options.canvas === true ? undefined : options.canvas?.fps) ?? 2 },\n },\n setup: ({ root }) => {\n dir = options.dir === undefined ? keptIn(root, 'recordings') : resolve(root, options.dir);\n return { read };\n },\n routes: {\n // A recording starts: the page, its viewport and when. Its events come in parts, as they happen, so a page\n // load in the middle loses none of them, and the next page carries on under the same ID.\n begin: async (req) => {\n const meta = await json<Partial<Meta>>(req);\n if (meta?.viewport === undefined || typeof meta.page !== 'string' || typeof meta.startedAt !== 'number')\n return Response.json({ problem: 'send the page, its viewport and when it started, as JSON' }, { status: 400 });\n const { page, viewport, colorScheme, startedAt } = meta;\n return Response.json({ id: begin({ page, viewport, ...(colorScheme === undefined ? {} : { colorScheme }), startedAt }) });\n },\n // `part/<id>?seq=<n>`: more of its events, a JSON array, and their place among the parts.\n part: async (req) => {\n const id = going(req);\n if (typeof id !== 'string') return id;\n const seq = Number(new URL(req.url).searchParams.get('seq') ?? 'none');\n const events = await json<unknown>(req);\n if (!Array.isArray(events) || !Number.isInteger(seq))\n return Response.json({ problem: 'send the events as a JSON array, and `seq`, their place' }, { status: 400 });\n const line = `${JSON.stringify({ seq, events })}\\n`;\n if (statSync(partOf(id)).size + line.length > MAX)\n return Response.json({ problem: `a recording may weigh ${MAX / 1024 / 1024} MB at most: stop this one` }, { status: 413 });\n appendFileSync(partOf(id), line);\n return Response.json({ id });\n },\n // `end/<id>`: it's over, and kept: how long it ran, and the mic's clips.\n end: async (req) => {\n const id = going(req);\n if (typeof id !== 'string') return id;\n const last = await json<Partial<Kept>>(req);\n if (typeof last?.duration !== 'number') return Response.json({ problem: 'send how long it ran, as JSON' }, { status: 400 });\n if (!end(id, { duration: last.duration, ...(last.voice === undefined ? {} : { voice: last.voice }) }))\n return Response.json({ problem: 'the recording has no events: record for a moment longer' }, { status: 400 });\n return Response.json({ id });\n },\n // `discard/<id>`: it's over, and not kept.\n discard: (req) => {\n const id = going(req);\n if (typeof id !== 'string') return id;\n rmSync(partOf(id));\n return Response.json({ id });\n },\n // `recording/<id>`: the JSON, for the replay page.\n recording: (req) => {\n const found = read(new URL(req.url).pathname.split('/').at(-1) ?? '');\n if (found === undefined) return new Response('no such recording, or not kept any more', { status: 404 });\n return new Response(found.data, { headers: { 'content-type': found.type, 'cache-control': 'no-store' } });\n },\n // `replay/<id>`: a page that plays it back.\n replay: () => new Response(replayPage(), { headers: { 'content-type': 'text/html; charset=utf-8' } }),\n 'player.js': () => file(player('rrweb-player.umd.min.cjs'), 'text/javascript'),\n 'player.css': () => file(player('style.css'), 'text/css'),\n },\n });\n}\n\nexport default recordings;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAa,cAAc,EAAE,SAAS,MAAM,WA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