deictic 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API.md +150 -37
- package/README.md +4 -3
- package/dist/annotations/client.d.ts +1 -1
- package/dist/annotations/client.d.ts.map +1 -1
- package/dist/annotations/client.js +161 -176
- package/dist/annotations/client.js.map +1 -1
- package/dist/annotations/index.d.ts +2 -11
- package/dist/client/index.d.ts +7 -6
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1007 -192
- package/dist/client/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/recommended/index.d.ts +2 -2
- package/dist/recordings/client.d.ts.map +1 -1
- package/dist/recordings/client.js +82 -153
- package/dist/recordings/client.js.map +1 -1
- package/dist/screenshots/client.d.ts.map +1 -1
- package/dist/shared/annotations.js +3 -4
- package/dist/shared/annotations.js.map +1 -1
- package/dist/shared/board.js +1 -1
- package/dist/shared/client.js +45 -2
- package/dist/shared/client.js.map +1 -1
- package/dist/shared/component.js +62 -0
- package/dist/shared/component.js.map +1 -0
- package/dist/shared/dom.js +79 -0
- package/dist/shared/dom.js.map +1 -0
- package/dist/shared/drawer.js +217 -0
- package/dist/shared/drawer.js.map +1 -0
- package/dist/shared/endpoints.js +34 -8
- package/dist/shared/endpoints.js.map +1 -1
- package/dist/shared/find.js +2 -1
- package/dist/shared/find.js.map +1 -1
- package/dist/shared/index.d.ts +124 -11
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index2.d.ts +9 -19
- package/dist/shared/index2.d.ts.map +1 -1
- package/dist/shared/index7.d.ts +105 -26
- package/dist/shared/index7.d.ts.map +1 -1
- package/dist/shared/index9.d.ts +1 -1
- package/dist/shared/init.js +12 -10
- package/dist/shared/init.js.map +1 -1
- package/dist/shared/integration.d.ts +1 -1
- package/dist/shared/packages.js +1 -1
- package/dist/shared/recording.js +31 -3
- package/dist/shared/recording.js.map +1 -1
- package/dist/shared/src.js.map +1 -1
- package/dist/shared/task.js +72 -21
- package/dist/shared/task.js.map +1 -1
- package/dist/shared/tasks.js +330 -166
- package/dist/shared/tasks.js.map +1 -1
- package/dist/shared/vb.js +1 -1
- package/dist/shared/voice2.js +6 -4
- package/dist/shared/voice2.js.map +1 -1
- package/dist/shared/watch.js +14 -14
- package/dist/shared/watch.js.map +1 -1
- package/dist/tailwind/index.js +6 -2
- package/dist/tailwind/index.js.map +1 -1
- package/dist/tasks/client.d.ts +2 -2
- package/dist/tasks/client.d.ts.map +1 -1
- package/dist/tasks/client.js +1829 -742
- package/dist/tasks/client.js.map +1 -1
- package/dist/tasks/index.d.ts +2 -2
- package/dist/voice/client.d.ts.map +1 -1
- package/dist/voice/client.js +154 -57
- package/dist/voice/client.js.map +1 -1
- package/package.json +1 -1
- package/skills/deictic/SKILL.md +22 -28
- package/src/cli/find.ts +3 -1
- package/src/cli/init.ts +13 -11
- package/src/cli/recording.ts +34 -3
- package/src/cli/task.ts +94 -23
- package/src/cli/voice.ts +9 -4
- package/src/cli/watch.ts +14 -13
- package/src/client/away.ts +3 -1
- package/src/client/component.ts +98 -0
- package/src/client/dom.ts +70 -0
- package/src/client/drawer.ts +258 -0
- package/src/client/index.ts +220 -128
- package/src/client/lightbox.ts +8 -8
- package/src/client/lighting.ts +279 -0
- package/src/client/style.ts +263 -44
- package/src/client/tools.ts +279 -0
- package/src/client/tooltip.ts +25 -5
- package/src/client/tray.ts +48 -0
- package/src/index.ts +121 -10
- package/src/plugins/annotations/client.ts +103 -129
- package/src/plugins/annotations/draw.ts +68 -72
- package/src/plugins/annotations/index.ts +12 -19
- package/src/plugins/recordings/client.ts +89 -167
- package/src/plugins/screenshots/client.ts +53 -2
- package/src/plugins/tailwind/index.ts +6 -2
- package/src/plugins/tasks/client.ts +219 -749
- package/src/plugins/tasks/composer.ts +797 -0
- package/src/plugins/tasks/drawer.ts +516 -0
- package/src/plugins/tasks/index.ts +459 -192
- package/src/plugins/tasks/pins.ts +275 -0
- package/src/plugins/tasks/store.ts +132 -0
- package/src/plugins/voice/client.ts +96 -5
- package/src/tools/endpoints.ts +18 -7
- package/src/tools/source.ts +25 -5
- package/skills/deictic/references/recordings.md +0 -13
- package/skills/deictic/references/tasks.md +0 -21
- package/skills/deictic/references/watch.md +0 -17
|
@@ -1 +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 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('<', '<').replaceAll('>', '>').replaceAll('"', '\"').replaceAll('&', '&');\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 const text = [...added.map((a) => `+ ${shapeOf(a)}`), ...removed.map((a) => `− ${shapeOf(a)}`)].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\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 under = (line: string) => console.log(`${' '.repeat(22)}${line}`);\n for (const e of shown) {\n console.log(`${e.at.padStart(6)} ${e.kind.padEnd(13)} ${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'}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AAoB,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;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, 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('<', '<').replaceAll('>', '>').replaceAll('"', '\"').replaceAll('&', '&');\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 ${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SAAS,IAAI,+BAC7I;AACF"}
|
package/dist/shared/src.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"src.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["/**\n * `deictic`: what a plugin is. Every plugin is optional: deictic itself is the glue (the\n * transform that ties elements to source, the dev server's endpoints, the history, shortcuts and the\n * overlay's panel), and each plugin adds what it does on top.\n *\n * A plugin has two halves, each optional that meet over the dev server's endpoints (`tools/endpoints.ts`). The\n * server half runs beside the bundler and is the only one that reads source: it turns the element\n * under the pointer into a model its panel can show, and an op from that panel into text edits. It\n * never writes files; deictic does, so every plugin's changes land in one history and undo the\n * same way. A change that isn't to a file (a task added to a board) the plugin makes itself and\n * answers with what it did (`Done`): the history keeps that beside the files' changes and hands it\n * back to the plugin's own `undo` and `redo`.\n * The client half is a module the page loads, named by the server half's `client`, which draws the\n * panel and previews an op on the page before it is applied.\n *\n * A plugin may have no panel at all, only an API for others (screenshots, a recording) and routes of\n * its own on the dev server. Each half's `setup` answers its API, and `use(name)` reaches another\n * plugin's, on the same side; `needs` names the plugins it can't do without.\n *\n * Both halves import from here, so the parser is imported for its types only: the browser must not load it.\n */\nimport type { JSXOpeningElement, Program } from 'oxc-parser';\n\nimport type { Shortcut } from './shortcut.ts';\n\nexport type { Modifier, Shortcut } from './shortcut.ts';\n\n/** A place in the source: the file from the project's root, with `/`, and the line and column, from 1. */\nexport interface Loc {\n file: string;\n line: number;\n column: number;\n}\n\n/** An element the pointer picked: where its opening tag starts, and the tag, which the server checks is still there. */\nexport interface Target {\n loc: Loc;\n tag: string;\n}\n\n/** Text in a file to replace, by UTF-16 offsets. `file` is the target's unless named, from the project's root. */\nexport interface TextEdit {\n file?: string;\n start: number;\n end: number;\n text: string;\n}\n\n/** What a server half reads: the target's file, parsed, and its element. */\nexport interface Source {\n /** The target's file, from the project's root. */\n file: string;\n code: string;\n /** The file's module; for an `.astro` component, its frontmatter's. */\n program: Program;\n /** The target's opening tag. */\n element: JSXOpeningElement;\n /** Another file under the project's root, for plugins whose edits go elsewhere (a locale's messages). */\n read(file: string): string;\n}\n\n/**\n * What answers the overlay's requests in a page with no dev server behind it (`deictic/vite`'s `standalone`): the\n * default export of a module of the page's. A request is one the endpoints would get, under `<base>__deictic/`;\n * the answer is theirs too (`{ model }`, `{ model, change }`, `{ problem }` with a status that isn't ok).\n */\nexport type Standalone = (request: Request) => Response | Promise<Response>;\n\n/** An op a plugin won't make. The message says why and what to do instead; the panel shows it. */\nexport class Refusal extends Error {\n override name = 'Refusal';\n}\n\n/**\n * A change the plugin made itself, not to a file: what its `undo` and `redo` need to take it back and\n * make it again. JSON, since the history keeps it on disk across restarts of the dev server.\n */\nexport interface Done<Record = unknown> {\n done: Record;\n}\n\ntype Maybe<T> = T | Promise<T>;\n\n/**\n * Each plugin's API to the others on the server, by name. A plugin adds its own, so `use` knows its type:\n * `declare module 'deictic' { interface ServerApis { screenshots: Screenshots } }`.\n */\n// oxlint-disable-next-line typescript/no-empty-interface -- filled by declaration merging\nexport interface ServerApis {}\n\n/** The same, in the page: `declare module 'deictic' { interface ClientApis { screenshots: Capture } }`. */\n// oxlint-disable-next-line typescript/no-empty-interface -- filled by declaration merging\nexport interface ClientApis {}\n\n/** A plugin's API, by its name: what its package declared, or `unknown` for one that declared none. */\nexport type ApiOf<Apis, Name extends string> = Name extends keyof Apis ? Apis[Name] : unknown;\n\nexport interface ServerContext {\n /** The project's root, as an absolute path. */\n root: string;\n /**\n * Another plugin's API, as its `setup` answered it, or nothing when it isn't loaded. One the plugin\n * `needs` always is; any other may not be, so check.\n */\n use: <Name extends string>(name: Name) => ApiOf<ServerApis, Name> | undefined;\n}\n\n/**\n * A route of the plugin's own, at `/__deictic/plugins/<name>/<route>`, and below it. A `GET` must\n * change nothing: anything else reaches it only from the page itself, which deictic checks.\n */\nexport type Route = (request: Request, context: ServerContext) => Maybe<Response>;\n\nexport interface ServerPlugin<Model = unknown, Op = unknown, Record = unknown, Api = unknown> {\n /** Ties the halves together; also the label of its changes in the history, and its routes' path. Lowercase, with `-`. */\n name: string;\n /** The module the page loads for this plugin's half there, which default-exports its `ClientPlugin`. */\n client?: string;\n /** What the page half gets as `context.options`: the user's options it needs there, as JSON. */\n clientOptions?: unknown;\n /** What opens its panel: its own default, which its options let the user change. A plugin with no panel has none. */\n shortcut?: Shortcut;\n /** The plugins it can't do without, by name: the dev server won't start without them. */\n needs?: string[];\n /**\n * The packages it imports that the project installs itself (optional peers), by name: as the dev server starts,\n * it says how to install any that's missing, rather than failing when first used.\n */\n packages?: string[];\n /** Runs once, as the dev server starts and before it answers anything. Answers the plugin's API to the others. */\n setup?(context: ServerContext): Maybe<Api>;\n /** Routes of its own, by their first segment under `/__deictic/plugins/<name>/`. */\n routes?: { [route: string]: Route };\n /** The model its panel shows for an element. Without it, the panel gets none. */\n read?(source: Source, target: Target): Maybe<Model>;\n /** Text edits for deictic to write, or a change the plugin made itself. */\n apply?(source: Source, target: Target, op: Op): Maybe<TextEdit[] | Done<Record>>;\n /**\n * Takes back a change `apply` made itself, or throws a `Refusal` saying why it can't any more. It may\n * answer what the next redo needs, where that differs (what it put back has a new ID).\n */\n undo?(record: Record): Maybe<void | Record>;\n /** Makes it again after an undo, and answers what the next undo needs, which may differ (a new ID). */\n redo?(record: Record): Maybe<Record>;\n /** Says what an op does, for the history: `className: px-2 → px-4`. */\n describe?(op: Op, before: Model): string;\n}\n\nexport const definePlugin = <Model, Op, Record = unknown, Api = unknown>(\n plugin: ServerPlugin<Model, Op, Record, Api>,\n): ServerPlugin<Model, Op, Record, Api> => plugin;\n\nexport interface ClientContext {\n /** The dev server's base URL, ending in `/`. */\n base: string;\n /** deictic's shadow root, to draw in: neither the page's styles nor the overlay's cross over. */\n root: ShadowRoot;\n /** The server half's `clientOptions`, or nothing. */\n options: unknown;\n /** Another plugin's API in the page, as its `setup` answered it, or nothing when it isn't loaded. */\n use: <Name extends string>(name: Name) => ApiOf<ClientApis, Name> | undefined;\n /** Asks one of this plugin's own routes, from the page: `request('shots', { method: 'POST', body: blob })`. */\n request: (route: string, init?: RequestInit) => Promise<Response>;\n /**\n * Opens the popup on an element at a plugin's tab, as its shortcut would: after a recording, say. An\n * element rendered again since stands in for one no longer on the page. False when there's no such tab\n * or no such element any more. Not from `setup`, which runs before the popup can open.\n */\n open: (plugin: string, element: Element) => boolean;\n /**\n * Shows `items` in the lightbox over everything, at `at` (the first by default), stepping between them with\n * ← and →. With `from`, it grows out of that element (the chip clicked) and shrinks back into it on close.\n */\n lightbox: (items: LightboxItem[], options?: LightboxOptions) => { close: () => void };\n}\n\n/** What the lightbox shows: a picture, a page in a frame (a recording's replay), or a sound with its waveform. */\nexport type LightboxItem = {\n /** Its name, over it. */\n title: string;\n /** Buttons beside the name: each closes the lightbox and runs. */\n actions?: LightboxAction[];\n} & ({ kind: 'image'; url: string } | { kind: 'page'; url: string } | { kind: 'audio'; url: string });\n\nexport interface LightboxAction {\n label: string;\n title?: string;\n run: () => void;\n}\n\nexport interface LightboxOptions {\n /** The item it opens at. */\n at?: number;\n /** The element it grows out of, and goes back into. */\n from?: Element;\n}\n\nexport interface PanelContext<Model, Op> extends ClientContext {\n /**\n * The element clicked: the one the source marked, under the pointer or around what is. Back from `away`\n * it may be off the page (`isConnected` is false), where the page moved on without it: the element as it\n * was left, or after a page load an empty one of its tag and mark. `elements` is then empty.\n */\n element: Element;\n /**\n * What was under the pointer, where it isn't `element` but inside it: markup nothing marked, as a\n * dependency's, or in an open shadow root, as the popup's own on a page that shows it (`popupIn`).\n */\n pointed?: Element;\n /** Every element on the page from the same place in the source, the clicked one among them: the rows of a list. */\n elements: Element[];\n target: Target;\n model: Model;\n /** Applies an op on disk, and reads the model again. Rejects with the server's reason, which the panel also shows. */\n apply(op: Op): Promise<Model>;\n close: () => void;\n /**\n * Says there's something here that leaving would lose (words typed, a change tried on the page), and the button\n * that keeps it: a click outside the popup then shakes that button, where it would have closed the popup.\n * `undefined` once there's nothing to lose. Forgotten as the panel unmounts.\n */\n unsaved: (action: HTMLElement | undefined) => void;\n /**\n * Leaves the popup to do something on the page, then comes back: closes it, runs `task` (a recording, a\n * pick of another element), and opens it again at this tab on this element. The next mount gets\n * `resumed`: the `state` kept now (what was typed, what's attached), and what `task` answered, or why\n * it failed. The state stays in the page, as it is: no need for JSON. It's also kept for the tab's next\n * page, as a structured clone, where it can be one: after a page load, the plugin's `resume` says whether\n * the task carries on, and the popup comes back there.\n */\n away: <T>(state: unknown, task: () => Promise<T>) => void;\n /** Set when this mount is the panel coming back from `away`. */\n resumed?: Resumed;\n}\n\n/** What a panel coming back from `away` gets: the state it kept, and the task's result or problem. */\nexport interface Resumed {\n state: unknown;\n result?: unknown;\n /** Why the task failed: its error's message. */\n problem?: string;\n}\n\nexport interface ClientPlugin<Model = unknown, Op = unknown, Api = unknown> {\n /** The server half's `name`. */\n name: string;\n /** Shown over the element while its shortcut's keys are held, and atop the panel. */\n label?: string;\n /**\n * Runs once, as the page starts, before any panel opens (a recording starts here). Answers the\n * plugin's API to the others in the page, at once: one that needs time keeps its promises inside it.\n */\n setup?(context: ClientContext): Api;\n /**\n * Asked as a page starts where the page before it left this plugin's panel `away`: the task it left for,\n * where that carries on in this page (a recording does), or nothing where it ended with the page. When it's\n * done the popup opens at this tab with `resumed`, on the element where this page has it and without where not.\n */\n resume?(context: ClientContext): Promise<unknown> | undefined;\n /** Draws into `panel`, inside deictic's shadow root. Returns what to undo on the page when the panel closes. */\n mount?: (panel: HTMLElement, context: PanelContext<Model, Op>) => (() => void) | void;\n}\n\nexport const defineClientPlugin = <Model, Op, Api = unknown>(plugin: ClientPlugin<Model, Op, Api>): ClientPlugin<Model, Op, Api> => plugin;\n"],"mappings":";;AAqEA,IAAa,UAAb,cAA6B,MAAM;CACxB,OAAO;AAClB;AA6EA,MAAa,gBACX,WACyC;AAiH3C,MAAa,sBAAgD,WAAuE"}
|
|
1
|
+
{"version":3,"file":"src.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["/**\n * `deictic`: what a plugin is. Every plugin is optional: deictic itself is the glue (the\n * transform that ties elements to source, the dev server's endpoints, the history, shortcuts and the\n * overlay's panel), and each plugin adds what it does on top.\n *\n * A plugin has two halves, each optional that meet over the dev server's endpoints (`tools/endpoints.ts`). The\n * server half runs beside the bundler and is the only one that reads source: it turns the element\n * under the pointer into a model its panel can show, and an op from that panel into text edits. It\n * never writes files; deictic does, so every plugin's changes land in one history and undo the\n * same way. A change that isn't to a file (a task added to a board) the plugin makes itself and\n * answers with what it did (`Done`): the history keeps that beside the files' changes and hands it\n * back to the plugin's own `undo` and `redo`.\n * The client half is a module the page loads, named by the server half's `client`, which draws the\n * panel and previews an op on the page before it is applied.\n *\n * A plugin may have no panel at all, only an API for others (screenshots, a recording) and routes of\n * its own on the dev server. Each half's `setup` answers its API, and `use(name)` reaches another\n * plugin's, on the same side; `needs` names the plugins it can't do without.\n *\n * Both halves import from here, so the parser is imported for its types only: the browser must not load it.\n */\nimport type { JSXOpeningElement, Program } from 'oxc-parser';\n\nimport type { Shortcut } from './shortcut.ts';\n\nexport type { Modifier, Shortcut } from './shortcut.ts';\n\n/** A place in the source: the file from the project's root, with `/`, and the line and column, from 1. */\nexport interface Loc {\n file: string;\n line: number;\n column: number;\n}\n\n/** An element the pointer picked: where its opening tag starts, and the tag, which the server checks is still there. */\nexport interface Target {\n loc: Loc;\n tag: string;\n}\n\n/** Text in a file to replace, by UTF-16 offsets. `file` is the target's unless named, from the project's root. */\nexport interface TextEdit {\n file?: string;\n start: number;\n end: number;\n text: string;\n}\n\n/** What a server half reads: the target's file, parsed, and its element. */\nexport interface Source {\n /** The target's file, from the project's root. */\n file: string;\n code: string;\n /** The file's module; for an `.astro` component, its frontmatter's. */\n program: Program;\n /** The target's opening tag. */\n element: JSXOpeningElement;\n /** Another file under the project's root, for plugins whose edits go elsewhere (a locale's messages). */\n read(file: string): string;\n}\n\n/**\n * What answers the overlay's requests in a page with no dev server behind it (`deictic/vite`'s `standalone`): the\n * default export of a module of the page's. A request is one the endpoints would get, under `<base>__deictic/`;\n * the answer is theirs too (`{ model }`, `{ model, change }`, `{ problem }` with a status that isn't ok).\n */\nexport type Standalone = (request: Request) => Response | Promise<Response>;\n\n/** An op a plugin won't make. The message says why and what to do instead; the panel shows it. */\nexport class Refusal extends Error {\n override name = 'Refusal';\n}\n\n/**\n * A change the plugin made itself, not to a file: what its `undo` and `redo` need to take it back and\n * make it again. JSON, since the history keeps it on disk across restarts of the dev server.\n */\nexport interface Done<Record = unknown> {\n done: Record;\n}\n\ntype Maybe<T> = T | Promise<T>;\n\n/**\n * Each plugin's API to the others on the server, by name. A plugin adds its own, so `use` knows its type:\n * `declare module 'deictic' { interface ServerApis { screenshots: Screenshots } }`.\n */\n// oxlint-disable-next-line typescript/no-empty-interface -- filled by declaration merging\nexport interface ServerApis {}\n\n/** The same, in the page: `declare module 'deictic' { interface ClientApis { screenshots: Capture } }`. */\n// oxlint-disable-next-line typescript/no-empty-interface -- filled by declaration merging\nexport interface ClientApis {}\n\n/** A plugin's API, by its name: what its package declared, or `unknown` for one that declared none. */\nexport type ApiOf<Apis, Name extends string> = Name extends keyof Apis ? Apis[Name] : unknown;\n\nexport interface ServerContext {\n /** The project's root, as an absolute path. */\n root: string;\n /**\n * Another plugin's API, as its `setup` answered it, or nothing when it isn't loaded. One the plugin\n * `needs` always is; any other may not be, so check.\n */\n use: <Name extends string>(name: Name) => ApiOf<ServerApis, Name> | undefined;\n}\n\n/**\n * A route of the plugin's own, at `/__deictic/plugins/<name>/<route>`, and below it. A `GET` must\n * change nothing: anything else reaches it only from the page itself, which deictic checks.\n */\nexport type Route = (request: Request, context: ServerContext) => Maybe<Response>;\n\nexport interface ServerPlugin<Model = unknown, Op = unknown, Record = unknown, Api = unknown> {\n /** Ties the halves together; also the label of its changes in the history, and its routes' path. Lowercase, with `-`. */\n name: string;\n /** The module the page loads for this plugin's half there, which default-exports its `ClientPlugin`. */\n client?: string;\n /** What the page half gets as `context.options`: the user's options it needs there, as JSON. */\n clientOptions?: unknown;\n /** What opens its panel: its own default, which its options let the user change. A plugin with no panel has none. */\n shortcut?: Shortcut;\n /** The plugins it can't do without, by name: the dev server won't start without them. */\n needs?: string[];\n /**\n * The packages it imports that the project installs itself (optional peers), by name: as the dev server starts,\n * it says how to install any that's missing, rather than failing when first used.\n */\n packages?: string[];\n /** Runs once, as the dev server starts and before it answers anything. Answers the plugin's API to the others. */\n setup?(context: ServerContext): Maybe<Api>;\n /** Routes of its own, by their first segment under `/__deictic/plugins/<name>/`. */\n routes?: { [route: string]: Route };\n /**\n * The model its panel shows for an element. Without it, the panel gets none. `source` is a `Refusal` where the\n * element isn't to be found in its file (it doesn't parse, or the page runs other code than it has): throw it where\n * the plugin needs the source, or go on without it, as a task does.\n */\n read?(source: Source | Refusal, target: Target): Maybe<Model>;\n /** Text edits for deictic to write, which it refuses without the source, or a change the plugin made itself. */\n apply?(source: Source | Refusal, target: Target, op: Op): Maybe<TextEdit[] | Done<Record>>;\n /**\n * Takes back a change `apply` made itself, or throws a `Refusal` saying why it can't any more. It may\n * answer what the next redo needs, where that differs (what it put back has a new ID).\n */\n undo?(record: Record): Maybe<void | Record>;\n /** Makes it again after an undo, and answers what the next undo needs, which may differ (a new ID). */\n redo?(record: Record): Maybe<Record>;\n /** Says what an op does, for the history: `className: px-2 → px-4`. */\n describe?(op: Op, before: Model): string;\n}\n\nexport const definePlugin = <Model, Op, Record = unknown, Api = unknown>(\n plugin: ServerPlugin<Model, Op, Record, Api>,\n): ServerPlugin<Model, Op, Record, Api> => plugin;\n\n/** Where something is in an element, in CSS pixels from its top left. */\nexport interface Point {\n x: number;\n y: number;\n}\n\n/** A spot on the page: a marked element, and a point in it (or beside it, for the nearest to a point no marked element is under). */\nexport interface Spot {\n element: Element;\n at: Point;\n}\n\n/**\n * The tool panel: a bar docked to an edge of the window, which shows while a shortcut's keys are held and stays\n * while it's in use. A plugin adds its tools to it from its page half's `setup`.\n */\nexport interface ToolPanel {\n /**\n * Adds a plugin's controls, as one group, in the order plugins are loaded. Groups of one `section` sit together,\n * with no line between them, after the groups of none: the screenshots', recordings', voice's and tasks' are\n * `capture`. `last` puts a group at the end of its section, or after all the others for one of none. Each control is a button named by its `title`; its `aria-keyshortcuts`\n * (`B`, `Control+Z`) is the key the panel hears for it, alone or with the keys held to point, and what its tooltip\n * shows.\n */\n add: (group: HTMLElement, options?: { last?: boolean; section?: string }) => void;\n /**\n * Takes the page for a tool that works on it (drawing, picking a point): the tool that had it lets go first, and\n * the panel stays shown. `left` is called when another takes it, or Esc or the pointer tool gives the page back.\n * Answers what lets go of it, for the tool to call when it's done on its own.\n */\n hold: (left: () => void) => () => void;\n /** Keeps the panel shown while something goes on that its controls end (a recording). Answers what ends that. */\n keep: () => () => void;\n /**\n * Takes the page until a point of it is pressed, lighting what's under the pointer as pointing does: answers the\n * spot, the marked element there or the nearest to it, or nothing where the page was given back first.\n */\n pick: () => Promise<Spot | undefined>;\n}\n\n/**\n * The drawer: on the window's side, where what the plugins have for the page lands, a section each. It\n * shows while a shortcut's keys are held and a section has something, and stays while it's in use.\n */\nexport interface Drawer {\n /**\n * Adds a section, in the order added, or before the others with `first`. A section that has nothing to show sets\n * its own `hidden`: the drawer stays away while every one is. Folded away, the drawer counts what the sections\n * have: each says how many things it lists in `data-count`, and how many are unread in `data-unread`.\n */\n add: (section: HTMLElement, options?: { first?: boolean }) => void;\n /**\n * Opens one item in the drawer, in the sections' place, under `title` and a way back. The drawer stays while it's\n * open. `closed` is called when it's left, by the way back, Esc, or another item opening. Answers what closes it.\n */\n show: (view: HTMLElement, options?: { title?: string; closed?: () => void }) => () => void;\n /** Keeps the drawer up while something goes on in it; answers what lets it go. */\n keep: () => () => void;\n}\n\n/** Something a plugin made on the page that nothing has taken yet: a shot, a recording, a voice clip. */\nexport interface TrayItem {\n /** The plugin that made it. */\n plugin: string;\n /** Its ID, as that plugin has it. */\n id: string;\n /** What that plugin says of it, as JSON: the screenshots plugin's `Shot`, a `Recording`, a `Clip`. */\n value: unknown;\n}\n\n/**\n * What plugins made on the page from the tool panel, until something takes it: a task attaches what's there and\n * removes it. Kept for the tab's session, so it's there on the tab's next page too.\n */\nexport interface Tray {\n /** What's kept, oldest first: all of it, or one plugin's. */\n list: (plugin?: string) => TrayItem[];\n add: (plugin: string, id: string, value: unknown) => void;\n /** Takes one out, or all of a plugin's. */\n remove: (plugin: string, id?: string) => void;\n /** Hears every change from now on; answers what stops it. */\n subscribe: (listener: () => void) => () => void;\n}\n\nexport interface ClientContext {\n /** The dev server's base URL, ending in `/`. */\n base: string;\n /** deictic's shadow root, to draw in: neither the page's styles nor the overlay's cross over. */\n root: ShadowRoot;\n /** The server half's `clientOptions`, or nothing. */\n options: unknown;\n /** Another plugin's API in the page, as its `setup` answered it, or nothing when it isn't loaded. */\n use: <Name extends string>(name: Name) => ApiOf<ClientApis, Name> | undefined;\n /** Asks one of this plugin's own routes, from the page: `request('shots', { method: 'POST', body: blob })`. */\n request: (route: string, init?: RequestInit) => Promise<Response>;\n /**\n * Opens the popup on an element at a plugin's tab, as its shortcut would, or with `at` on a spot in it: the\n * popup is then beside the spot, which is what's lit, and the tab's context has it. An element rendered again\n * since stands in for one no longer on the page. False when there's no such tab or no such element any more, and\n * while the open popup holds something unsaved, whose button then shakes. Not as `setup` runs, which is before the\n * popup can open.\n */\n open: (plugin: string, element: Element, at?: Point) => boolean;\n /** The tool panel, to add this plugin's tools to. */\n tools: ToolPanel;\n /** What was made from the tool panel and not taken yet. */\n tray: Tray;\n /** The drawer, to add this plugin's section to. */\n drawer: Drawer;\n /**\n * Lights an element on the page as pointing at it does, for something of the overlay's own that stands for it (a\n * task's row in the drawer, while the pointer is on it); none puts the light back as it was.\n */\n light: (element?: Element) => void;\n /**\n * Shows `items` in the lightbox over everything, at `at` (the first by default), stepping between them with\n * ← and →. With `from`, it grows out of that element (the chip clicked) and shrinks back into it on close.\n */\n lightbox: (items: LightboxItem[], options?: LightboxOptions) => { close: () => void };\n}\n\n/** What the lightbox shows: a picture, a page in a frame (a recording's replay), or a sound with its waveform. */\nexport type LightboxItem = {\n /** Its name, over it. */\n title: string;\n /** Buttons beside the name: each closes the lightbox and runs. */\n actions?: LightboxAction[];\n} & ({ kind: 'image'; url: string } | { kind: 'page'; url: string } | { kind: 'audio'; url: string });\n\nexport interface LightboxAction {\n label: string;\n title?: string;\n run: () => void;\n}\n\nexport interface LightboxOptions {\n /** The item it opens at. */\n at?: number;\n /** The element it grows out of, and goes back into. */\n from?: Element;\n}\n\nexport interface PanelContext<Model, Op> extends ClientContext {\n /**\n * The element clicked: the one the source marked, under the pointer or around what is. Back from `away`\n * it may be off the page (`isConnected` is false), where the page moved on without it: the element as it\n * was left, or after a page load an empty one of its tag and mark. `elements` is then empty.\n */\n element: Element;\n /**\n * What was under the pointer, where it isn't `element` but inside it: markup nothing marked, as a\n * dependency's, or in an open shadow root, as the popup's own on a page that shows it (`popupIn`).\n */\n pointed?: Element;\n /** The spot in `element` the popup was opened on, where it was (the tool panel's task tool), not the element as a whole. */\n at?: Point;\n /** Every element on the page from the same place in the source, the clicked one among them: the rows of a list. */\n elements: Element[];\n target: Target;\n model: Model;\n /**\n * Applies an op on disk, and reads the model again. Rejects with the server's reason, which the panel also shows.\n * On another element with `on`, whose model is then the one answered: for an op that's about that one.\n */\n apply(op: Op, on?: Target): Promise<Model>;\n close: () => void;\n /**\n * Says there's something here that leaving would lose (words typed, a change tried on the page), and the button\n * that keeps it: a click outside the popup then shakes that button, where it would have closed the popup.\n * `undefined` once there's nothing to lose. Forgotten as the panel unmounts.\n */\n unsaved: (action: HTMLElement | undefined) => void;\n /**\n * Leaves the popup to do something on the page, then comes back: closes it, runs `task` (a recording, a\n * pick of another element), and opens it again at this tab on this element. The next mount gets\n * `resumed`: the `state` kept now (what was typed, what's attached), and what `task` answered, or why\n * it failed. The state stays in the page, as it is: no need for JSON. It's also kept for the tab's next\n * page, as a structured clone, where it can be one: after a page load, the plugin's `resume` says whether\n * the task carries on, and the popup comes back there.\n */\n away: <T>(state: unknown, task: () => Promise<T>) => void;\n /** Set when this mount is the panel coming back from `away`. */\n resumed?: Resumed;\n}\n\n/** What a panel coming back from `away` gets: the state it kept, and the task's result or problem. */\nexport interface Resumed {\n state: unknown;\n result?: unknown;\n /** Why the task failed: its error's message. */\n problem?: string;\n}\n\nexport interface ClientPlugin<Model = unknown, Op = unknown, Api = unknown> {\n /** The server half's `name`. */\n name: string;\n /** Shown over the element while its shortcut's keys are held, and atop the panel. */\n label?: string;\n /**\n * Runs once, as the page starts, before any panel opens (a recording starts here). Answers the\n * plugin's API to the others in the page, at once: one that needs time keeps its promises inside it.\n */\n setup?(context: ClientContext): Api;\n /**\n * Asked as a page starts where the page before it left this plugin's panel `away`: the task it left for,\n * where that carries on in this page (a recording does), or nothing where it ended with the page. When it's\n * done the popup opens at this tab with `resumed`, on the element where this page has it and without where not.\n */\n resume?(context: ClientContext): Promise<unknown> | undefined;\n /**\n * What it shows on the page while a shortcut's keys are held, and the page is dimmed to point on: the tasks\n * plugin pins each task where its element is. Answers what takes it away.\n */\n pointing?(context: ClientContext): () => void;\n /** Draws into `panel`, inside deictic's shadow root. Returns what to undo on the page when the panel closes. */\n mount?: (panel: HTMLElement, context: PanelContext<Model, Op>) => (() => void) | void;\n}\n\nexport const defineClientPlugin = <Model, Op, Api = unknown>(plugin: ClientPlugin<Model, Op, Api>): ClientPlugin<Model, Op, Api> => plugin;\n"],"mappings":";;AAqEA,IAAa,UAAb,cAA6B,MAAM;CACxB,OAAO;AAClB;AAiFA,MAAa,gBACX,WACyC;AA4N3C,MAAa,sBAAgD,WAAuE"}
|
package/dist/shared/task.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync } from "node:fs";
|
|
2
|
-
import { dirname, join, resolve } from "node:path";
|
|
3
|
-
import {
|
|
2
|
+
import { dirname, join, relative, resolve } from "node:path";
|
|
3
|
+
import { m as vbJson, o as deicticDirs, s as download, t as ME, u as read } from "./board.js";
|
|
4
4
|
// src/cli/task.ts
|
|
5
5
|
/**
|
|
6
6
|
* `deictic task`: a task, briefly: what was asked, where (and whether that place has moved in the source since), the
|
|
@@ -23,25 +23,70 @@ function run(id, values) {
|
|
|
23
23
|
const facts = [
|
|
24
24
|
["deictic.project", (v) => `Project ${v}`],
|
|
25
25
|
["deictic.at", (v) => `${v} <${label("deictic.tag") ?? "?"}>`],
|
|
26
|
+
["deictic.source", (v) => `Source: ${at?.replace(/:\d+$/, "") ?? "?"} ← ${v} (a shared component's change is usually at the next)`],
|
|
26
27
|
["deictic.url", (v) => v],
|
|
27
28
|
["deictic.viewport", (v) => `Viewport ${v}`],
|
|
28
29
|
["deictic.count", (v) => v === "1" ? void 0 : `${v} elements on the page come from that line`],
|
|
29
|
-
["deictic.
|
|
30
|
+
["deictic.point", (v) => `About the spot at x,y ${v} in that element (CSS px from its top left): a screenshot taken as the task was added has it circled`],
|
|
31
|
+
["deictic.position", (v) => `In the screenshot at x,y ${v}, ${label("deictic.size") ?? "?"} (CSS px)`]
|
|
30
32
|
];
|
|
31
33
|
for (const [key, say] of facts) {
|
|
32
34
|
const value = label(key);
|
|
33
35
|
const line = value === void 0 ? void 0 : say(value);
|
|
34
36
|
if (line !== void 0) console.log(line);
|
|
35
37
|
}
|
|
38
|
+
if (at === void 0) console.log("About the page as a whole: no element was attached, so find it from the words, the page's URL and the screenshot");
|
|
39
|
+
for (const line of drawn(root)) console.log(line);
|
|
36
40
|
const told = (pointed ? where.slice(0, pointed.index) : where).trim();
|
|
37
41
|
if (told !== "") console.log(told);
|
|
38
42
|
if (pointed) console.log(`\nPointed at, inside it: ${pointed[1]}\n ${pointed[2]}`);
|
|
43
|
+
const path = label("deictic.pointed");
|
|
44
|
+
if (path !== void 0) {
|
|
45
|
+
const file = root.attachments.some((a) => a.name === "pointed.html") ? "pointed.html" : "element.html";
|
|
46
|
+
console.log(`\nPointed at, inside it: ${path} (its HTML is in ${file}): what they mean, though no line marks it; find it by its classes`);
|
|
47
|
+
}
|
|
39
48
|
if (at !== void 0) placeOf(at, label("deictic.line"));
|
|
40
|
-
|
|
49
|
+
const out = values.out === void 0 ? void 0 : resolve(values.out);
|
|
50
|
+
if (root.attachments.length > 0) console.log("\nAttached:");
|
|
51
|
+
attachments(root, out, " ", String(root.id));
|
|
41
52
|
if (replies.length > 0) console.log("\nReplies:");
|
|
42
|
-
for (const r of replies)
|
|
53
|
+
for (const r of replies) {
|
|
54
|
+
console.log(` ${r.author?.handle ?? r.by.actor}: ${r.text}`);
|
|
55
|
+
for (const line of drawn(r)) console.log(` ${line}`);
|
|
56
|
+
attachments(r, out, " ");
|
|
57
|
+
}
|
|
58
|
+
if (out === void 0 && [root, ...replies].some((m) => m.attachments.length > 0)) console.log(`\nTo download what's attached: ${ME} task ${root.id} --out <dir>`);
|
|
43
59
|
others(root);
|
|
44
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* What the attached files don't say, from the numbered labels: where the element is in each shot and the notes on it, the
|
|
63
|
+
* notes drawn on the page, and what wasn't kept any more. Where a recording replays, `recording` says.
|
|
64
|
+
*/
|
|
65
|
+
function drawn({ labels, attachments }) {
|
|
66
|
+
const numbered = (prefix) => {
|
|
67
|
+
const out = [];
|
|
68
|
+
for (let n = 1; labels[`${prefix}.${n}`] !== void 0; n++) out.push(labels[`${prefix}.${n}`]);
|
|
69
|
+
return out;
|
|
70
|
+
};
|
|
71
|
+
const notes = (prefix) => numbered(`${prefix}.note`).map((note) => JSON.stringify(note));
|
|
72
|
+
const lines = [];
|
|
73
|
+
for (const [i, { name }] of attachments.filter((a) => a.type === "image/png").entries()) {
|
|
74
|
+
const shot = `deictic.screenshot.${i + 1}`;
|
|
75
|
+
const position = labels[`${shot}.position`];
|
|
76
|
+
if (position === void 0) continue;
|
|
77
|
+
const said = notes(shot);
|
|
78
|
+
lines.push(`${name}: the element at x,y ${position}, ${labels[`${shot}.size`] ?? "?"} (CSS px)${said.length === 0 ? "" : `; notes drawn on it: ${said.join(", ")}`}`);
|
|
79
|
+
}
|
|
80
|
+
for (const [i, other] of numbered("deictic.also").entries()) {
|
|
81
|
+
const html = attachments.some((a) => a.name === `element.${i + 2}.html`) ? ` (its HTML is in element.${i + 2}.html)` : "";
|
|
82
|
+
lines.push(`Also about ${other}${html}`);
|
|
83
|
+
}
|
|
84
|
+
const onPage = notes("deictic");
|
|
85
|
+
if (onPage.length > 0) lines.push(`Notes drawn on the page: ${onPage.join(", ")}`);
|
|
86
|
+
const dropped = numbered("deictic.dropped");
|
|
87
|
+
if (dropped.length > 0) lines.push(`Not attached, as it wasn't kept any more: ${dropped.join(", ")}`);
|
|
88
|
+
return lines;
|
|
89
|
+
}
|
|
45
90
|
/** The place as the task saw it, against the file now: the element's opening tag may have moved or changed. */
|
|
46
91
|
function placeOf(at, first) {
|
|
47
92
|
const file = at.replace(/:\d+:\d+$/, "");
|
|
@@ -53,33 +98,39 @@ function placeOf(at, first) {
|
|
|
53
98
|
return;
|
|
54
99
|
}
|
|
55
100
|
const lines = readFileSync(path, "utf8").split("\n");
|
|
101
|
+
const shown = relative(process.cwd(), path) || path;
|
|
56
102
|
const now = lines[line - 1]?.trim();
|
|
57
103
|
if (first === void 0 || now?.includes(first.slice(0, 40))) {
|
|
58
|
-
console.log(`\nFile: ${
|
|
104
|
+
console.log(`\nFile: ${shown}:${line}, as the task saw it.`);
|
|
59
105
|
return;
|
|
60
106
|
}
|
|
61
107
|
const moved = lines.findIndex((l) => l.includes(first.slice(0, 40)));
|
|
62
|
-
console.log(moved >= 0 ? `\nFile: moved to ${
|
|
108
|
+
console.log(moved >= 0 ? `\nFile: moved to ${shown}:${moved + 1} (the task says line ${line}).` : `\nFile: ${shown}:${line} no longer reads as the task saw it; it was:\n ${first}`);
|
|
63
109
|
}
|
|
64
|
-
/**
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
110
|
+
/**
|
|
111
|
+
* A message's files, with the command to read a recording or voice clip by, downloaded to `out` where it's given. The
|
|
112
|
+
* task's own are read by its ID (all its voice clips at once); a reply's recording by where it replays, and its voice
|
|
113
|
+
* note by the clip's ID.
|
|
114
|
+
*/
|
|
115
|
+
function attachments(message, out, indent, task) {
|
|
116
|
+
if (out !== void 0 && message.attachments.length > 0) mkdirSync(out, { recursive: true });
|
|
117
|
+
const recordings = message.attachments.filter((a) => a.name.startsWith("recording-"));
|
|
118
|
+
for (const a of message.attachments) {
|
|
69
119
|
const kb = `${Math.round(a.size / 1024)} KB`;
|
|
70
120
|
if (out !== void 0) download(a, join(out, a.name));
|
|
71
|
-
const saved = out === void 0 ? "" : ` → ${join(out, a.name)}`;
|
|
72
|
-
const get = saved || `: ${ME} vb download ${a.id} ${a.name}`;
|
|
121
|
+
const saved = out === void 0 ? "" : ` → ${relative(process.cwd(), join(out, a.name))}`;
|
|
73
122
|
if (a.name.startsWith("recording-")) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
console.log(
|
|
123
|
+
const n = recordings.indexOf(a) + 1;
|
|
124
|
+
const ref = task === void 0 ? message.labels[`deictic.recording.${n}.replay`] : `${task}${n > 1 ? ` --nth ${n}` : ""}`;
|
|
125
|
+
console.log(`${indent}${a.name} (${kb})${saved}`);
|
|
126
|
+
if (ref !== void 0) console.log(`${indent} ${ME} recording ${ref} (timeline), ${ME} frame ${ref} (frames)`);
|
|
77
127
|
} else if (a.name.startsWith("voice-")) {
|
|
78
|
-
console.log(
|
|
79
|
-
console.log(
|
|
80
|
-
} else if (a.name === "element.html") console.log(
|
|
81
|
-
else console.log(
|
|
128
|
+
console.log(`${indent}${a.name} (${kb}), a voice clip${saved}`);
|
|
129
|
+
if (task === void 0) console.log(`${indent} ${ME} voice ${/^voice-(.+)\.\w+$/.exec(a.name)?.[1] ?? a.id} (speech)`);
|
|
130
|
+
} else if (a.name === "element.html") console.log(`${indent}${a.name} (${kb}), the element's HTML as it rendered, if you need it${saved}`);
|
|
131
|
+
else console.log(`${indent}${a.name} (${kb})${saved}`);
|
|
82
132
|
}
|
|
133
|
+
if (task !== void 0 && message.attachments.some((a) => a.name.startsWith("voice-"))) console.log(`${indent}${ME} voice ${task} (speech in every clip), ${ME} transcribe ${task} (the words)`);
|
|
83
134
|
}
|
|
84
135
|
/** The other open tasks about the same page, of the same project: left a minute apart, they're often one change. */
|
|
85
136
|
function others(root) {
|
package/dist/shared/task.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task.js","names":[],"sources":["../../src/cli/task.ts"],"sourcesContent":["/**\n * `deictic task`: a task, briefly: what was asked, where (and whether that place has moved in the source since), the\n * page, what's attached with the command to look at each, the replies, and the other open tasks about the same page.\n */\nimport { existsSync, mkdirSync, readFileSync } from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\n\nimport { deicticDirs, download, ME, type Message, read, vbJson } from './board.ts';\n\n/** An actor by the profile its ID ends in (`…+claude`), or the ID of one that writes as itself. */\nconst nameOf = (actor: string) => (actor.includes('+') ? actor.slice(actor.lastIndexOf('+') + 1) : actor);\n\nexport function run(id: string, values: { out?: string }): void {\n const { message: root, replies } = read(id);\n const [asked = '', where = ''] = root.text.split(/\\n---\\n/);\n const label = (key: string) => root.labels[key];\n const at = label('deictic.at');\n\n // Who asked, said as that: the line's state is beside it, and a board's record names no one for a task's end.\n console.log(`#${root.id} ${root.task?.state ?? 'not a task'}, asked by ${root.author?.handle ?? root.by.actor}, ${root.createdAt}`);\n const claim = root.task?.claim;\n if (claim) console.log(`Claimed by ${nameOf(claim.actor)} until ${claim.until}`);\n // A task not over yet has them, as null.\n if (root.task?.result != null) console.log(`Result: ${root.task.result}`);\n if (root.task?.reason != null) console.log(`Reason: ${root.task.reason}`);\n console.log(`\\nAsked:\\n${asked.trim()}\\n`);\n // The part inside the element that was pointed at, where nothing marked it: what the person means.\n const pointed = /\\nPointed at, inside it: `([^`]*)`\\n`{3,}\\w*\\n([\\s\\S]*?)\\n`{3,}/.exec(where);\n // Where, from the labels: the place, the page, and the viewport to look at it in.\n const facts: [string, (v: string) => string | undefined][] = [\n ['deictic.project', (v) => `Project ${v}`],\n ['deictic.at', (v) => `${v} <${label('deictic.tag') ?? '?'}>`],\n ['deictic.url', (v) => v],\n ['deictic.viewport', (v) => `Viewport ${v}`],\n ['deictic.count', (v) => (v === '1' ? undefined : `${v} elements on the page come from that line`)],\n ['deictic.position', (v) => `In the screenshot at x,y ${v}, ${label('deictic.size') ?? '?'} (CSS pixels from its top left)`],\n ];\n for (const [key, say] of facts) {\n const value = label(key);\n const line = value === undefined ? undefined : say(value);\n if (line !== undefined) console.log(line);\n }\n // What no label holds: what's attached and drawn on it.\n const told = (pointed ? where.slice(0, pointed.index) : where).trim();\n if (told !== '') console.log(told);\n if (pointed) console.log(`\\nPointed at, inside it: ${pointed[1]}\\n ${pointed[2]}`);\n\n if (at !== undefined) placeOf(at, label('deictic.line'));\n attachments(root, values.out === undefined ? undefined : resolve(values.out));\n\n if (replies.length > 0) console.log('\\nReplies:');\n for (const r of replies) console.log(` ${r.author?.handle ?? r.by.actor}: ${r.text}`);\n others(root);\n}\n\n/** The place as the task saw it, against the file now: the element's opening tag may have moved or changed. */\nfunction placeOf(at: string, first: string | undefined): void {\n const file = at.replace(/:\\d+:\\d+$/, '');\n const line = Number(at.split(':').at(-2));\n // Marks are from the dev server's root: here, above, or a folder with a .deictic/ of its own.\n const roots = [process.cwd(), ...deicticDirs().map(dirname)];\n const path = roots.map((r) => resolve(r, file)).find((p) => existsSync(p));\n if (path === undefined) {\n console.log(`\\n${file} isn't under ${roots.join(' or ')}: find the dev server's root.`);\n return;\n }\n const lines = readFileSync(path, 'utf8').split('\\n');\n // The tag's first line may follow other code on its line: `const App = () => <h1>`.\n const now = lines[line - 1]?.trim();\n if (first === undefined || now?.includes(first.slice(0, 40))) {\n console.log(`\\nFile: ${path}:${line}, as the task saw it.`);\n return;\n }\n const moved = lines.findIndex((l) => l.includes(first.slice(0, 40)));\n console.log(\n moved >= 0\n ? `\\nFile: moved to ${path}:${moved + 1} (the task says line ${line}).`\n : `\\nFile: ${path}:${line} no longer reads as the task saw it; it was:\\n ${first}`,\n );\n}\n\n/** What's attached, with the command to look at each, downloaded to `out` where it's given. */\nfunction attachments(root: Message, out: string | undefined): void {\n if (root.attachments.length > 0) console.log('\\nAttached:');\n if (out !== undefined) mkdirSync(out, { recursive: true });\n for (const a of root.attachments) {\n const kb = `${Math.round(a.size / 1024)} KB`;\n if (out !== undefined) download(a, join(out, a.name));\n const saved = out === undefined ? '' : ` → ${join(out, a.name)}`;\n // To a file's path: the CLI writes what it's given, and refuses a folder.\n const get = saved || `: ${ME} vb download ${a.id} ${a.name}`;\n if (a.name.startsWith('recording-')) {\n console.log(` ${a.name} (${kb})${saved}`);\n console.log(` timeline: ${ME} recording ${root.id}`);\n console.log(` frames: ${ME} frame ${root.id}`);\n } else if (a.name.startsWith('voice-')) {\n console.log(` ${a.name} (${kb}), a voice clip${saved}`);\n console.log(` speech: ${ME} voice ${root.id}`);\n } else if (a.name === 'element.html') {\n console.log(` ${a.name} (${kb}), the element's HTML as it rendered, if you need it${get}`);\n } else {\n console.log(` ${a.name} (${a.type}, ${kb})${get}`);\n }\n }\n}\n\n/** The other open tasks about the same page, of the same project: left a minute apart, they're often one change. */\nfunction others(root: Message): void {\n const page = root.labels['deictic.page'];\n if (page === undefined) return;\n const project = root.labels['deictic.project'];\n const labels = [`deictic.page=${page}`, ...(project === undefined ? [] : [`deictic.project=${project}`])];\n const { tasks } = vbJson<{ tasks: { message: Message }[] }>(['tasks', root.channel, ...labels.flatMap((l) => ['--label', l])]);\n const rest = tasks.map((t) => t.message).filter((m) => m.id !== root.id);\n if (rest.length === 0) return;\n console.log(\n `\\n${rest.length} other open task${rest.length === 1 ? '' : 's'} on ${page}: read them before you start, they may be one change.`,\n );\n for (const m of rest) {\n const title = (m.text.split(/\\n---\\n/)[0] ?? '').split('\\n')[0]?.slice(0, 100);\n console.log(` #${m.id} ${m.task?.state ?? ''}, ${m.labels['deictic.at'] ?? '?'}: ${title}`);\n }\n}\n"],"mappings":";;;;;;;;;AAUA,MAAM,UAAU,UA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KAAK;OAE1F,QAAQ,IAAI,KAAK,EAAE,KAAK,IAAI,EAAE,KAAK,IAAI,GAAG,GAAG,KAAK;CAEtD;AACF;;AAGA,SAAS,OAAO,MAAqB;CACnC,MAAM,OAAO,KAAK,OAAO;CACzB,IAAI,SAAS,KAAA,GAAW;CACxB,MAAM,UAAU,KAAK,OAAO;CAC5B,MAAM,SAAS,CAAC,gBAAgB,QAAQ,GAAI,YAAY,KAAA,IAAY,CAAC,IAAI,CAAC,mBAAmB,SAAS,CAAE;CACxG,MAAM,EAAE,UAAU,OAA0C;EAAC;EAAS,KAAK;EAAS,GAAG,OAAO,SAAS,MAAM,CAAC,WAAW,CAAC,CAAC;CAAC,CAAC;CAC7H,MAAM,OAAO,MAAM,KAAK,MAAM,EAAE,OAAO,CAAC,CAAC,QAAQ,MAAM,EAAE,OAAO,KAAK,EAAE;CACvE,IAAI,KAAK,WAAW,GAAG;CACvB,QAAQ,IACN,KAAK,KAAK,OAAO,kBAAkB,KAAK,WAAW,IAAI,KAAK,IAAI,MAAM,KAAK,sDAC7E;CACA,KAAK,MAAM,KAAK,MAAM;EACpB,MAAM,SAAS,EAAE,KAAK,MAAM,SAAS,CAAC,CAAC,MAAM,GAAA,CAAI,MAAM,IAAI,CAAC,CAAC,EAAE,EAAE,MAAM,GAAG,GAAG;EAC7E,QAAQ,IAAI,MAAM,EAAE,GAAG,GAAG,EAAE,MAAM,SAAS,GAAG,IAAI,EAAE,OAAO,iBAAiB,IAAI,IAAI,OAAO;CAC7F;AACF"}
|
|
1
|
+
{"version":3,"file":"task.js","names":[],"sources":["../../src/cli/task.ts"],"sourcesContent":["/**\n * `deictic task`: a task, briefly: what was asked, where (and whether that place has moved in the source since), the\n * page, what's attached with the command to look at each, the replies, and the other open tasks about the same page.\n */\nimport { existsSync, mkdirSync, readFileSync } from 'node:fs';\nimport { dirname, join, relative, resolve } from 'node:path';\n\nimport { deicticDirs, download, ME, type Message, read, vbJson } from './board.ts';\n\n/** An actor by the profile its ID ends in (`…+claude`), or the ID of one that writes as itself. */\nconst nameOf = (actor: string) => (actor.includes('+') ? actor.slice(actor.lastIndexOf('+') + 1) : actor);\n\nexport function run(id: string, values: { out?: string }): void {\n const { message: root, replies } = read(id);\n const [asked = '', where = ''] = root.text.split(/\\n---\\n/);\n const label = (key: string) => root.labels[key];\n const at = label('deictic.at');\n\n // Who asked, said as that: the line's state is beside it, and a board's record names no one for a task's end.\n console.log(`#${root.id} ${root.task?.state ?? 'not a task'}, asked by ${root.author?.handle ?? root.by.actor}, ${root.createdAt}`);\n const claim = root.task?.claim;\n if (claim) console.log(`Claimed by ${nameOf(claim.actor)} until ${claim.until}`);\n // A task not over yet has them, as null.\n if (root.task?.result != null) console.log(`Result: ${root.task.result}`);\n if (root.task?.reason != null) console.log(`Reason: ${root.task.reason}`);\n console.log(`\\nAsked:\\n${asked.trim()}\\n`);\n // The part inside the element that was pointed at, where nothing marked it: what the person means.\n const pointed = /\\nPointed at, inside it: `([^`]*)`\\n`{3,}\\w*\\n([\\s\\S]*?)\\n`{3,}/.exec(where);\n // Where, from the labels: the place, the page, and the viewport to look at it in.\n const facts: [string, (v: string) => string | undefined][] = [\n ['deictic.project', (v) => `Project ${v}`],\n ['deictic.at', (v) => `${v} <${label('deictic.tag') ?? '?'}>`],\n // From its own line out: before the label, tasks said it in their text, which is printed below as it is.\n // The first is often a shared component (`ui/label.tsx`), which the task isn't about changing everywhere.\n ['deictic.source', (v) => `Source: ${at?.replace(/:\\d+$/, '') ?? '?'} ← ${v} (a shared component's change is usually at the next)`],\n ['deictic.url', (v) => v],\n ['deictic.viewport', (v) => `Viewport ${v}`],\n ['deictic.count', (v) => (v === '1' ? undefined : `${v} elements on the page come from that line`)],\n [\n 'deictic.point',\n // Circled only in a shot taken as the task went, which no label tells from one drawn on before.\n (v) =>\n `About the spot at x,y ${v} in that element (CSS px from its top left): a screenshot taken as the task was added has it circled`,\n ],\n // A task added before shots were numbered had its one shot's place here.\n ['deictic.position', (v) => `In the screenshot at x,y ${v}, ${label('deictic.size') ?? '?'} (CSS px)`],\n ];\n for (const [key, say] of facts) {\n const value = label(key);\n const line = value === undefined ? undefined : say(value);\n if (line !== undefined) console.log(line);\n }\n if (at === undefined)\n console.log(\"About the page as a whole: no element was attached, so find it from the words, the page's URL and the screenshot\");\n for (const line of drawn(root)) console.log(line);\n // A task added before these were labels says them after its words.\n const told = (pointed ? where.slice(0, pointed.index) : where).trim();\n if (told !== '') console.log(told);\n if (pointed) console.log(`\\nPointed at, inside it: ${pointed[1]}\\n ${pointed[2]}`);\n const path = label('deictic.pointed');\n if (path !== undefined) {\n const file = root.attachments.some((a) => a.name === 'pointed.html') ? 'pointed.html' : 'element.html';\n // Markup no line marks, a dependency's.\n console.log(\n `\\nPointed at, inside it: ${path} (its HTML is in ${file}): what they mean, though no line marks it; find it by its classes`,\n );\n }\n\n if (at !== undefined) placeOf(at, label('deictic.line'));\n const out = values.out === undefined ? undefined : resolve(values.out);\n if (root.attachments.length > 0) console.log('\\nAttached:');\n attachments(root, out, ' ', String(root.id));\n\n if (replies.length > 0) console.log('\\nReplies:');\n for (const r of replies) {\n console.log(` ${r.author?.handle ?? r.by.actor}: ${r.text}`);\n // A reply may attach what a task does: shots, a recording, a voice note.\n for (const line of drawn(r)) console.log(` ${line}`);\n attachments(r, out, ' ');\n }\n // Said once, not as a command per file: most tasks need their shots, and `--out` gets everything at once.\n if (out === undefined && [root, ...replies].some((m) => m.attachments.length > 0))\n console.log(`\\nTo download what's attached: ${ME} task ${root.id} --out <dir>`);\n others(root);\n}\n\n/**\n * What the attached files don't say, from the numbered labels: where the element is in each shot and the notes on it, the\n * notes drawn on the page, and what wasn't kept any more. Where a recording replays, `recording` says.\n */\nfunction drawn({ labels, attachments }: Message): string[] {\n const numbered = (prefix: string) => {\n const out: string[] = [];\n for (let n = 1; labels[`${prefix}.${n}`] !== undefined; n++) out.push(labels[`${prefix}.${n}`]!);\n return out;\n };\n const notes = (prefix: string) => numbered(`${prefix}.note`).map((note) => JSON.stringify(note));\n const lines: string[] = [];\n // `deictic.screenshot.N` is the Nth PNG attached, `deictic.recording.N` the Nth recording.\n for (const [i, { name }] of attachments.filter((a) => a.type === 'image/png').entries()) {\n const shot = `deictic.screenshot.${i + 1}`;\n const position = labels[`${shot}.position`];\n if (position === undefined) continue;\n const said = notes(shot);\n lines.push(\n `${name}: the element at x,y ${position}, ${labels[`${shot}.size`] ?? '?'} (CSS px)${said.length === 0 ? '' : `; notes drawn on it: ${said.join(', ')}`}`,\n );\n }\n // The others it's about, after the one it names first: the Nth element's HTML is `element.N.html`.\n for (const [i, other] of numbered('deictic.also').entries()) {\n const html = attachments.some((a) => a.name === `element.${i + 2}.html`) ? ` (its HTML is in element.${i + 2}.html)` : '';\n lines.push(`Also about ${other}${html}`);\n }\n const onPage = notes('deictic');\n if (onPage.length > 0) lines.push(`Notes drawn on the page: ${onPage.join(', ')}`);\n const dropped = numbered('deictic.dropped');\n if (dropped.length > 0) lines.push(`Not attached, as it wasn't kept any more: ${dropped.join(', ')}`);\n return lines;\n}\n\n/** The place as the task saw it, against the file now: the element's opening tag may have moved or changed. */\nfunction placeOf(at: string, first: string | undefined): void {\n const file = at.replace(/:\\d+:\\d+$/, '');\n const line = Number(at.split(':').at(-2));\n // Marks are from the dev server's root: here, above, or a folder with a .deictic/ of its own.\n const roots = [process.cwd(), ...deicticDirs().map(dirname)];\n const path = roots.map((r) => resolve(r, file)).find((p) => existsSync(p));\n if (path === undefined) {\n console.log(`\\n${file} isn't under ${roots.join(' or ')}: find the dev server's root.`);\n return;\n }\n const lines = readFileSync(path, 'utf8').split('\\n');\n const shown = relative(process.cwd(), path) || path;\n // The tag's first line may follow other code on its line: `const App = () => <h1>`.\n const now = lines[line - 1]?.trim();\n if (first === undefined || now?.includes(first.slice(0, 40))) {\n console.log(`\\nFile: ${shown}:${line}, as the task saw it.`);\n return;\n }\n const moved = lines.findIndex((l) => l.includes(first.slice(0, 40)));\n console.log(\n moved >= 0\n ? `\\nFile: moved to ${shown}:${moved + 1} (the task says line ${line}).`\n : `\\nFile: ${shown}:${line} no longer reads as the task saw it; it was:\\n ${first}`,\n );\n}\n\n/**\n * A message's files, with the command to read a recording or voice clip by, downloaded to `out` where it's given. The\n * task's own are read by its ID (all its voice clips at once); a reply's recording by where it replays, and its voice\n * note by the clip's ID.\n */\nfunction attachments(message: Message, out: string | undefined, indent: string, task?: string): void {\n if (out !== undefined && message.attachments.length > 0) mkdirSync(out, { recursive: true });\n const recordings = message.attachments.filter((a) => a.name.startsWith('recording-'));\n for (const a of message.attachments) {\n const kb = `${Math.round(a.size / 1024)} KB`;\n if (out !== undefined) download(a, join(out, a.name));\n const saved = out === undefined ? '' : ` → ${relative(process.cwd(), join(out, a.name))}`;\n if (a.name.startsWith('recording-')) {\n const n = recordings.indexOf(a) + 1;\n const ref = task === undefined ? message.labels[`deictic.recording.${n}.replay`] : `${task}${n > 1 ? ` --nth ${n}` : ''}`;\n console.log(`${indent}${a.name} (${kb})${saved}`);\n if (ref !== undefined) console.log(`${indent} ${ME} recording ${ref} (timeline), ${ME} frame ${ref} (frames)`);\n } else if (a.name.startsWith('voice-')) {\n console.log(`${indent}${a.name} (${kb}), a voice clip${saved}`);\n if (task === undefined) console.log(`${indent} ${ME} voice ${/^voice-(.+)\\.\\w+$/.exec(a.name)?.[1] ?? a.id} (speech)`);\n } else if (a.name === 'element.html') {\n console.log(`${indent}${a.name} (${kb}), the element's HTML as it rendered, if you need it${saved}`);\n } else {\n console.log(`${indent}${a.name} (${kb})${saved}`);\n }\n }\n if (task !== undefined && message.attachments.some((a) => a.name.startsWith('voice-')))\n console.log(`${indent}${ME} voice ${task} (speech in every clip), ${ME} transcribe ${task} (the words)`);\n}\n\n/** The other open tasks about the same page, of the same project: left a minute apart, they're often one change. */\nfunction others(root: Message): void {\n const page = root.labels['deictic.page'];\n if (page === undefined) return;\n const project = root.labels['deictic.project'];\n const labels = [`deictic.page=${page}`, ...(project === undefined ? [] : [`deictic.project=${project}`])];\n const { tasks } = vbJson<{ tasks: { message: Message }[] }>(['tasks', root.channel, ...labels.flatMap((l) => ['--label', l])]);\n const rest = tasks.map((t) => t.message).filter((m) => m.id !== root.id);\n if (rest.length === 0) return;\n console.log(\n `\\n${rest.length} other open task${rest.length === 1 ? '' : 's'} on ${page}: read them before you start, they may be one change.`,\n );\n for (const m of rest) {\n const title = (m.text.split(/\\n---\\n/)[0] ?? '').split('\\n')[0]?.slice(0, 100);\n console.log(` #${m.id} ${m.task?.state ?? ''}, ${m.labels['deictic.at'] ?? '?'}: ${title}`);\n }\n}\n"],"mappings":";;;;;;;;;AAUA,MAAM,UAAU,UAAmB,MAAM,SAAS,GAAG,IAAI,MAAM,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI;AAEnG,SAAgB,IAAI,IAAY,QAAgC;CAC9D,MAAM,EAAE,SAAS,MAAM,YAAY,KAAK,EAAE;CAC1C,MAAM,CAAC,QAAQ,IAAI,QAAQ,MAAM,KAAK,KAAK,MAAM,SAAS;CAC1D,MAAM,SAAS,QAAgB,KAAK,OAAO;CAC3C,MAAM,KAAK,MAAM,YAAY;CAG7B,QAAQ,IAAI,IAAI,KAAK,GAAG,GAAG,KAAK,MAAM,SAAS,aAAa,aAAa,KAAK,QAAQ,UAAU,KAAK,GAAG,MAAM,IAAI,KAAK,WAAW;CAClI,MAAM,QAAQ,KAAK,MAAM;CACzB,IAAI,OAAO,QAAQ,IAAI,cAAc,OAAO,MAAM,KAAK,EAAE,SAAS,MAAM,OAAO;CAE/E,IAAI,KAAK,MAAM,UAAU,MAAM,QAAQ,IAAI,WAAW,KAAK,KAAK,QAAQ;CACxE,IAAI,KAAK,MAAM,UAAU,MAAM,QAAQ,IAAI,WAAW,KAAK,KAAK,QAAQ;CACxE,QAAQ,IAAI,aAAa,MAAM,KAAK,EAAE,GAAG;CAEzC,MAAM,UAAU,kEAAkE,KAAK,KAAK;CAE5F,MAAM,QAAuD;EAC3D,CAAC,oBAAoB,MAAM,WAAW,GAAG;EACzC,C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