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.
Files changed (103) hide show
  1. package/API.md +150 -37
  2. package/README.md +4 -3
  3. package/dist/annotations/client.d.ts +1 -1
  4. package/dist/annotations/client.d.ts.map +1 -1
  5. package/dist/annotations/client.js +161 -176
  6. package/dist/annotations/client.js.map +1 -1
  7. package/dist/annotations/index.d.ts +2 -11
  8. package/dist/client/index.d.ts +7 -6
  9. package/dist/client/index.d.ts.map +1 -1
  10. package/dist/client/index.js +1007 -192
  11. package/dist/client/index.js.map +1 -1
  12. package/dist/index.d.ts +2 -2
  13. package/dist/recommended/index.d.ts +2 -2
  14. package/dist/recordings/client.d.ts.map +1 -1
  15. package/dist/recordings/client.js +82 -153
  16. package/dist/recordings/client.js.map +1 -1
  17. package/dist/screenshots/client.d.ts.map +1 -1
  18. package/dist/shared/annotations.js +3 -4
  19. package/dist/shared/annotations.js.map +1 -1
  20. package/dist/shared/board.js +1 -1
  21. package/dist/shared/client.js +45 -2
  22. package/dist/shared/client.js.map +1 -1
  23. package/dist/shared/component.js +62 -0
  24. package/dist/shared/component.js.map +1 -0
  25. package/dist/shared/dom.js +79 -0
  26. package/dist/shared/dom.js.map +1 -0
  27. package/dist/shared/drawer.js +217 -0
  28. package/dist/shared/drawer.js.map +1 -0
  29. package/dist/shared/endpoints.js +34 -8
  30. package/dist/shared/endpoints.js.map +1 -1
  31. package/dist/shared/find.js +2 -1
  32. package/dist/shared/find.js.map +1 -1
  33. package/dist/shared/index.d.ts +124 -11
  34. package/dist/shared/index.d.ts.map +1 -1
  35. package/dist/shared/index2.d.ts +9 -19
  36. package/dist/shared/index2.d.ts.map +1 -1
  37. package/dist/shared/index7.d.ts +105 -26
  38. package/dist/shared/index7.d.ts.map +1 -1
  39. package/dist/shared/index9.d.ts +1 -1
  40. package/dist/shared/init.js +12 -10
  41. package/dist/shared/init.js.map +1 -1
  42. package/dist/shared/integration.d.ts +1 -1
  43. package/dist/shared/packages.js +1 -1
  44. package/dist/shared/recording.js +31 -3
  45. package/dist/shared/recording.js.map +1 -1
  46. package/dist/shared/src.js.map +1 -1
  47. package/dist/shared/task.js +72 -21
  48. package/dist/shared/task.js.map +1 -1
  49. package/dist/shared/tasks.js +330 -166
  50. package/dist/shared/tasks.js.map +1 -1
  51. package/dist/shared/vb.js +1 -1
  52. package/dist/shared/voice2.js +6 -4
  53. package/dist/shared/voice2.js.map +1 -1
  54. package/dist/shared/watch.js +14 -14
  55. package/dist/shared/watch.js.map +1 -1
  56. package/dist/tailwind/index.js +6 -2
  57. package/dist/tailwind/index.js.map +1 -1
  58. package/dist/tasks/client.d.ts +2 -2
  59. package/dist/tasks/client.d.ts.map +1 -1
  60. package/dist/tasks/client.js +1829 -742
  61. package/dist/tasks/client.js.map +1 -1
  62. package/dist/tasks/index.d.ts +2 -2
  63. package/dist/voice/client.d.ts.map +1 -1
  64. package/dist/voice/client.js +154 -57
  65. package/dist/voice/client.js.map +1 -1
  66. package/package.json +1 -1
  67. package/skills/deictic/SKILL.md +22 -28
  68. package/src/cli/find.ts +3 -1
  69. package/src/cli/init.ts +13 -11
  70. package/src/cli/recording.ts +34 -3
  71. package/src/cli/task.ts +94 -23
  72. package/src/cli/voice.ts +9 -4
  73. package/src/cli/watch.ts +14 -13
  74. package/src/client/away.ts +3 -1
  75. package/src/client/component.ts +98 -0
  76. package/src/client/dom.ts +70 -0
  77. package/src/client/drawer.ts +258 -0
  78. package/src/client/index.ts +220 -128
  79. package/src/client/lightbox.ts +8 -8
  80. package/src/client/lighting.ts +279 -0
  81. package/src/client/style.ts +263 -44
  82. package/src/client/tools.ts +279 -0
  83. package/src/client/tooltip.ts +25 -5
  84. package/src/client/tray.ts +48 -0
  85. package/src/index.ts +121 -10
  86. package/src/plugins/annotations/client.ts +103 -129
  87. package/src/plugins/annotations/draw.ts +68 -72
  88. package/src/plugins/annotations/index.ts +12 -19
  89. package/src/plugins/recordings/client.ts +89 -167
  90. package/src/plugins/screenshots/client.ts +53 -2
  91. package/src/plugins/tailwind/index.ts +6 -2
  92. package/src/plugins/tasks/client.ts +219 -749
  93. package/src/plugins/tasks/composer.ts +797 -0
  94. package/src/plugins/tasks/drawer.ts +516 -0
  95. package/src/plugins/tasks/index.ts +459 -192
  96. package/src/plugins/tasks/pins.ts +275 -0
  97. package/src/plugins/tasks/store.ts +132 -0
  98. package/src/plugins/voice/client.ts +96 -5
  99. package/src/tools/endpoints.ts +18 -7
  100. package/src/tools/source.ts +25 -5
  101. package/skills/deictic/references/recordings.md +0 -13
  102. package/skills/deictic/references/tasks.md +0 -21
  103. package/skills/deictic/references/watch.md +0 -17
@@ -1 +1 @@
1
- {"version":3,"file":"endpoints.js","names":[],"sources":["../../src/tools/source.ts","../../src/tools/history.ts","../../src/tools/endpoints.ts"],"sourcesContent":["/**\n * The source a server half reads: a target's file, parsed, and the opening tag the page's attribute\n * points at. Files are only ever read and written under the project's root, outside `node_modules`.\n */\nimport { readFileSync } from 'node:fs';\nimport { isAbsolute, relative, resolve, sep } from 'node:path';\n\nimport { Refusal, type Source, type Target, type TextEdit } from '#src/index.ts';\n\nimport { ASTRO, parseAstro, type Parsed } from './astro.ts';\nimport { isHost, lineStarts, offsetOf, openingsIn, parse } from './locate.ts';\n\n/** A file from the project's root, as an absolute path; refused anywhere the page has no business writing. */\nexport function resolveFile(root: string, file: string): string {\n const path = resolve(root, file);\n const from = relative(root, path);\n // `relative` gives an absolute path for another drive.\n if (from === '' || from.startsWith('..') || isAbsolute(from) || from.split(sep).includes('node_modules'))\n throw new Refusal(`${file} is not a file of this project's own`);\n return path;\n}\n\nexport function readSource(root: string, file: string): string {\n try {\n return readFileSync(resolveFile(root, file), 'utf8');\n } catch (e) {\n if (e instanceof Refusal) throw e;\n throw new Refusal(`can't read ${file}: has it moved since the page loaded?`, { cause: e });\n }\n}\n\n/** The target's file and element, as they are on disk now. */\nexport function sourceAt(root: string, target: Target): Source {\n const { file, line, column } = target.loc;\n const code = readSource(root, file);\n const offset = offsetOf(lineStarts(code), line, column);\n const { program, elements } = ASTRO.test(file) ? astro(root, file, code) : jsx(file, code);\n const element = elements.find((el) => el.start === offset && isHost(el));\n if (element === undefined || (element.name.type === 'JSXIdentifier' && element.name.name !== target.tag))\n throw new Refusal(`no <${target.tag}> at ${file}:${line}:${column} any more: the file changed since the page loaded, so reload it`);\n return { file, code, program, element, read: (other) => readSource(root, other) };\n}\n\nfunction jsx(file: string, code: string): Parsed {\n const { program, errors } = parse(file, code);\n if (errors.length > 0) throw new Refusal(`${file} doesn't parse: fix it first (${errors[0]!.message})`);\n return { program, elements: openingsIn(program) };\n}\n\nfunction astro(root: string, file: string, code: string): Parsed {\n const parsed = parseAstro(root, code);\n if ('problem' in parsed) throw new Refusal(`${file} can't be read: ${parsed.problem}`);\n return parsed;\n}\n\n/** Each file's text after its edits, which must not overlap. */\nexport function applyEdits(source: Source, edits: TextEdit[]): Map<string, string> {\n const byFile = Map.groupBy(edits, (e) => e.file ?? source.file);\n const out = new Map<string, string>();\n for (const [file, list] of byFile) {\n const sorted = list.toSorted((a, b) => b.start - a.start);\n let code = file === source.file ? source.code : source.read(file);\n let floor = Infinity;\n for (const edit of sorted) {\n if (edit.end > floor) throw new Error(`deictic: edits to ${file} overlap at ${edit.end}`);\n code = code.slice(0, edit.start) + edit.text + code.slice(edit.end);\n floor = edit.start;\n }\n out.set(file, code);\n }\n return out;\n}\n","/**\n * Every change deictic made, to undo and redo. A change to files holds each file's whole text\n * before and after: source files are small, and the texts make undo exact without a diff to go stale.\n * A change a plugin made itself (`Done`) holds the plugin's name and its record, and undoing it is the\n * plugin's `undo`.\n *\n * Each change has a scope, the plugin and the element it was made on, and the popup undoes and redoes\n * within its own: the latest change of this tab on this element, not the latest of all. So a change\n * is taken back out of order, with later ones to the same file still in it. Then only the lines the\n * change wrote go back to what they were, where they're still in the file as it wrote them, once.\n *\n * Anything else is refused, not merged: a file whose lines were edited since has the editor's own undo\n * for it; and a redo likewise. A plugin's undo refuses on its own terms. Kept under `.deictic`, so it\n * outlives a restart of the dev server and stays out of git.\n */\nimport { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';\nimport { dirname } from 'node:path';\n\nimport { Refusal, type ServerPlugin } from '#src/index.ts';\n\nimport { keptIn } from './kept.ts';\nimport { resolveFile } from './source.ts';\n\nexport interface FileChange {\n file: string;\n /** The text before, or nothing for a file the change made. */\n before: string | null;\n after: string;\n}\n\n/** Whose a change is: the plugin whose tab made it, and the element it was open on, as `file:line:column`. */\nexport interface Scope {\n plugin: string;\n target: string;\n}\n\ninterface Base {\n id: number;\n at: string;\n label: string;\n /** None on a change made without one, which only an undo of the whole history reaches. */\n scope?: Scope;\n}\n\nexport type Change = Base & ({ files: FileChange[] } | { plugin: string; record: unknown });\n\n/** A change as the page lists it. `files` is empty for one a plugin made itself. */\nexport interface Summary {\n id: number;\n at: string;\n label: string;\n files: string[];\n}\n\nexport interface HistoryOptions {\n /** Whose `undo` and `redo` take back the changes they made themselves. */\n plugins?: ServerPlugin[];\n store?: string;\n}\n\nconst LIMIT = 200;\n\n/** Whether a change is in a scope: any is in none. */\nconst within = (scope: Scope | undefined) => (c: Change) =>\n scope === undefined || (c.scope?.plugin === scope.plugin && c.scope.target === scope.target);\n\nconst summary = (c: Change): Summary => ({ id: c.id, at: c.at, label: c.label, files: 'files' in c ? c.files.map((f) => f.file) : [] });\n\nexport class History {\n #done: Change[] = [];\n #undone: Change[] = [];\n readonly #root: string;\n readonly #store: string;\n readonly #plugins: Map<string, ServerPlugin>;\n\n constructor(root: string, { plugins = [], store = keptIn(root, 'history.json') }: HistoryOptions = {}) {\n this.#root = root;\n this.#store = store;\n this.#plugins = new Map(plugins.map((p) => [p.name, p]));\n if (!existsSync(store)) return;\n try {\n ({ done: this.#done, undone: this.#undone } = JSON.parse(readFileSync(store, 'utf8')) as { done: Change[]; undone: Change[] });\n } catch {\n // A history that doesn't read is one we start over, not one to stop the dev server for.\n }\n }\n\n /** Writes each file's new text and records it as one change. A redo after it, in its scope, is gone, as in any editor. */\n commit(label: string, texts: Map<string, string>, scope?: Scope): Summary {\n const files: FileChange[] = [];\n for (const [file, after] of texts) {\n const path = resolveFile(this.#root, file);\n const before = existsSync(path) ? readFileSync(path, 'utf8') : null;\n if (before !== after) files.push({ file, before, after });\n }\n if (files.length === 0) throw new Refusal('nothing to change: the source already says that');\n for (const f of files) write(resolveFile(this.#root, f.file), f.after);\n return this.#push({ label, files }, scope);\n }\n\n /** Records a change `plugin` made itself, with what its `undo` needs. */\n record(label: string, plugin: string, record: unknown, scope?: Scope): Summary {\n return this.#push({ label, plugin, record }, scope);\n }\n\n /** Takes back the latest change, of a scope where one is given. */\n async undo(scope?: Scope): Promise<Summary> {\n const change = this.#done.findLast(within(scope));\n if (change === undefined) throw new Refusal(scope === undefined ? 'nothing to undo' : 'nothing to undo here');\n if ('files' in change) this.#put(change, 'after', 'before');\n else change.record = (await this.#pluginOf(change, 'undo').undo!(change.record)) ?? change.record;\n this.#done = this.#done.filter((c) => c !== change);\n this.#undone.push(change);\n this.#save();\n return summary(change);\n }\n\n /** Makes the change last undone again, of a scope where one is given. */\n async redo(scope?: Scope): Promise<Summary> {\n const change = this.#undone.findLast(within(scope));\n if (change === undefined) throw new Refusal(scope === undefined ? 'nothing to redo' : 'nothing to redo here');\n if ('files' in change) this.#put(change, 'before', 'after');\n else change.record = await this.#pluginOf(change, 'redo').redo!(change.record);\n this.#undone = this.#undone.filter((c) => c !== change);\n this.#done.push(change);\n this.#save();\n return summary(change);\n }\n\n list(scope?: Scope): { done: Summary[]; undone: Summary[] } {\n return { done: this.#done.filter(within(scope)).map(summary), undone: this.#undone.filter(within(scope)).map(summary) };\n }\n\n #push(change: Omit<Base, 'id' | 'at'> & ({ files: FileChange[] } | { plugin: string; record: unknown }), scope?: Scope): Summary {\n const id = Math.max(0, ...[...this.#done, ...this.#undone].map((c) => c.id)) + 1;\n const made = { id, at: new Date().toISOString(), ...change, ...(scope === undefined ? {} : { scope }) };\n this.#done = [...this.#done, made].slice(-LIMIT);\n // What was undone in this scope can't be redone over the new change; another scope's still can.\n this.#undone = this.#undone.filter((c) => !within(scope)(c));\n this.#save();\n return summary(made);\n }\n\n #pluginOf(change: { label: string; plugin: string }, step: 'undo' | 'redo'): ServerPlugin {\n const plugin = this.#plugins.get(change.plugin);\n if (plugin?.[step] === undefined) {\n throw new Refusal(\n `can't ${step} \"${change.label}\": the ${change.plugin} plugin that made it isn't loaded, so add it back to \\`plugins\\``,\n );\n }\n return plugin;\n }\n\n /**\n * Puts each file's `to` text back, once every one of them still reads as its `from`, or still has the\n * lines that differ as `from` has them: then those lines alone change, and the rest stays as it is now.\n */\n #put(change: Base & { files: FileChange[] }, from: 'before' | 'after', to: 'before' | 'after'): void {\n const paths = change.files.map((f) => resolveFile(this.#root, f.file));\n const texts = change.files.map((f, i) => {\n const now = existsSync(paths[i]!) ? readFileSync(paths[i]!, 'utf8') : null;\n if (now === f[from]) return f[to];\n const text = now === null || f[from] === null || f[to] === null ? undefined : swapped(now, f[from], f[to]);\n if (text === undefined) {\n throw new Refusal(\n `${f.file} changed since \"${change.label}\" ${from === 'after' ? 'was made' : 'was undone'}: use the editor's undo there`,\n );\n }\n return text;\n });\n texts.forEach((text, i) => {\n if (text === null) rmSync(paths[i]!);\n else write(paths[i]!, text);\n });\n }\n\n #save(): void {\n write(this.#store, JSON.stringify({ done: this.#done, undone: this.#undone }));\n }\n}\n\n/**\n * `now` with the lines that differ between `from` and `to` put as `to` has them, where `now` has them as\n * `from` does, in one place only. Nothing where it doesn't (they were edited, or there are two of them), or\n * where `from` has no such lines to find (the change only removed some).\n */\nfunction swapped(now: string, from: string, to: string): string | undefined {\n const [a, b, lines] = [from.split('\\n'), to.split('\\n'), now.split('\\n')];\n let head = 0;\n while (head < a.length && head < b.length && a[head] === b[head]) head++;\n let tail = 0;\n while (tail < a.length - head && tail < b.length - head && a.at(-1 - tail) === b.at(-1 - tail)) tail++;\n const theirs = a.slice(head, a.length - tail);\n if (theirs.length === 0) return undefined;\n const found = lines.flatMap((_, i) => (theirs.every((line, j) => lines[i + j] === line) ? [i] : []));\n if (found.length !== 1) return undefined;\n return [...lines.slice(0, found[0]), ...b.slice(head, b.length - tail), ...lines.slice(found[0]! + theirs.length)].join('\\n');\n}\n\nfunction write(path: string, text: string): void {\n mkdirSync(dirname(path), { recursive: true });\n writeFileSync(path, text);\n}\n","/**\n * The dev server's half of deictic, under `/__deictic/`: `read` and `apply` an op through a\n * plugin, `undo`, `redo` and `history`, and `open`, which opens a place in the editor. Written over\n * `Request` and `Response`, so each integration mounts them its own way (Vite as middleware), and\n * served from the page's own origin, so no token travels to the page. `undo`, `redo` and `history` are a\n * plugin's on an element where the request names them (as the popup does: its tab, its element), and\n * the whole history's where it doesn't.\n *\n * Everything but `open` and `history` writes or may, so only the page itself may send it: a POST of\n * JSON from the same origin, which a form or a script on another site can't send without asking first.\n *\n * Each plugin's own `routes` are under `plugins/<name>/`. A `GET` there reaches the plugin as it\n * comes; anything else only from the page's own origin, in whatever type it sends (an image, say).\n * Nothing is answered before every plugin's `setup` has run.\n */\nimport type { IncomingMessage, ServerResponse } from 'node:http';\n\nimport { type Loc, Refusal, type ServerPlugin, type Target } from '#src/index.ts';\n\nimport { History, type Scope } from './history.ts';\nimport { missingMessage } from './packages.ts';\nimport { setUp } from './plugins.ts';\nimport { applyEdits, resolveFile, sourceAt } from './source.ts';\n\nexport interface EndpointOptions {\n root: string;\n plugins: ServerPlugin[];\n /** The path the endpoints sit under, ending in `/`: `/` by default. */\n base?: string;\n /** Opens a place in the editor: a redirect to the dev server's own launcher. */\n open: (path: string, loc: Loc) => Response | Promise<Response>;\n history?: History;\n}\n\ninterface Body {\n plugin: string;\n target: Target;\n op?: unknown;\n}\n\nconst scopeOf = (plugin: string, { file, line, column }: Loc): Scope => ({ plugin, target: `${file}:${line}:${column}` });\n/** The scope an undo or a redo names, or none for the whole history. */\nconst scopeIn = ({ plugin, target }: Partial<Body>) =>\n plugin === undefined || target === undefined ? undefined : scopeOf(plugin, target.loc);\n\n/** Answers deictic's requests, and nothing for any other path. */\nexport function endpoints({ root, plugins, base = '/', open, history = new History(root, { plugins }) }: EndpointOptions) {\n const byName = new Map(plugins.map((p) => [p.name, p]));\n const prefix = `${base}__deictic/`;\n // Started now, awaited by every request: a plugin's API is there before anything asks for it.\n const ready = setUp(root, plugins);\n const gone = missingMessage(root, plugins);\n if (gone !== undefined) console.warn(gone);\n\n const pluginOf = (name: string) => {\n const plugin = byName.get(name);\n if (plugin === undefined) throw new Refusal(`no plugin \"${name}\" on the server: is it in the bundler plugin's \\`plugins\\`?`);\n return plugin;\n };\n\n const routes: Record<string, (body: Body) => Promise<unknown>> = {\n read: async ({ plugin, target }) => ({ model: await readOf(pluginOf(plugin), target) }),\n apply: async ({ plugin: name, target, op }) => {\n const plugin = pluginOf(name);\n if (plugin.apply === undefined) throw new Refusal(`${name} changes nothing from its panel: it has no \\`apply\\``);\n const source = sourceAt(root, target);\n const before = await readOf(plugin, target);\n const { file, line } = target.loc;\n const label = `${name} ${file}:${line}: ${plugin.describe?.(op, before) ?? 'edit'}`;\n const result = await plugin.apply(source, target, op);\n const scope = scopeOf(name, target.loc);\n const change = Array.isArray(result)\n ? history.commit(label, applyEdits(source, result), scope)\n : history.record(label, name, result.done, scope);\n return { model: await readOf(plugin, target), change };\n },\n undo: async (body) => ({ change: await history.undo(scopeIn(body)) }),\n redo: async (body) => ({ change: await history.redo(scopeIn(body)) }),\n };\n // A plugin without `read` has no model, and no need for its element to be where the page says.\n const readOf = (plugin: ServerPlugin, target: Target) => (plugin.read === undefined ? null : plugin.read(sourceAt(root, target), target));\n // One write at a time: a plugin's change may wait on the network, and an undo sent meanwhile must\n // take back that change, not the one before it.\n let queue: Promise<unknown> = Promise.resolve();\n const serially = <T>(run: () => Promise<T>): Promise<T> => {\n const next = queue.then(run, run);\n queue = next.catch(() => {});\n return next;\n };\n\n return async (req: Request): Promise<Response | undefined> => {\n const url = new URL(req.url);\n if (!url.pathname.startsWith(prefix)) return undefined;\n const route = url.pathname.slice(prefix.length);\n const origin = req.headers.get('origin');\n const sameOrigin = origin !== null && new URL(origin).host === url.host;\n try {\n const context = await ready;\n if (route.startsWith('plugins/')) {\n const [name = '', first = ''] = route.slice('plugins/'.length).split('/');\n const handle = byName.get(name)?.routes?.[first];\n if (handle === undefined) return new Response(`no endpoint ${url.pathname}`, { status: 404 });\n if (req.method !== 'GET' && req.method !== 'HEAD' && !sameOrigin)\n return Response.json({ problem: `only the page itself may ${req.method} to ${name}` }, { status: 403 });\n return await handle(req, context);\n }\n const loc = {\n file: url.searchParams.get('file') ?? '',\n line: Number(url.searchParams.get('line')),\n column: Number(url.searchParams.get('column')),\n };\n if (route === 'history') {\n const plugin = url.searchParams.get('plugin');\n return Response.json(history.list(plugin === null ? undefined : scopeOf(plugin, loc)));\n }\n if (route === 'open') return await open(resolveFile(root, loc.file), loc);\n const handler = routes[route];\n if (handler === undefined) return new Response(`no endpoint ${url.pathname}`, { status: 404 });\n if (req.method !== 'POST' || !sameOrigin || req.headers.get('content-type')?.startsWith('application/json') !== true)\n return Response.json({ problem: 'edits come from the page, as JSON' }, { status: 403 });\n const body = (await req.json()) as Body;\n return Response.json(await (route === 'read' ? handler(body) : serially(() => handler(body))));\n } catch (e) {\n if (e instanceof Refusal) return Response.json({ problem: e.message }, { status: 422 });\n return Response.json({ problem: e instanceof Error ? (e.stack ?? e.message) : String(e) }, { status: 500 });\n }\n };\n}\n\n/** A redirect within the page's origin, to a launcher the dev server answers itself. */\nexport const redirect = (path: string) => new Response(null, { status: 307, headers: { Location: path } });\n\n/**\n * The endpoints as Node middleware, for Vite's server. The request's host is the one the page was\n * served from: a proxy's `x-forwarded-host` before its own.\n */\nexport function nodeMiddleware(\n handle: (req: Request) => Promise<Response | undefined>,\n): (req: IncomingMessage, res: ServerResponse, next: () => void) => void {\n return (req, res, next) => {\n // Before reading the body, which a request for anything else leaves to whoever answers it.\n if (req.url?.includes('/__deictic/') !== true) return next();\n const forwarded = req.headers['x-forwarded-host'];\n const host = (Array.isArray(forwarded) ? forwarded[0] : forwarded) ?? req.headers.host ?? 'localhost';\n const headers = new Headers();\n for (const [name, value] of Object.entries(req.headers))\n for (const v of Array.isArray(value) ? value : value === undefined ? [] : [value]) headers.append(name, v);\n\n const chunks: Buffer[] = [];\n req.on('data', (chunk: Buffer) => chunks.push(chunk));\n req.on('end', () => {\n const body = req.method === 'GET' || req.method === 'HEAD' ? undefined : Buffer.concat(chunks);\n handle(new Request(`http://${host}${req.url}`, { method: req.method, headers, body }))\n .then(async (response) => {\n if (response === undefined) return next();\n res.statusCode = response.status;\n response.headers.forEach((value, name) => res.setHeader(name, value));\n res.end(Buffer.from(await response.arrayBuffer()));\n })\n .catch((e: unknown) => {\n res.statusCode = 500;\n res.end(e instanceof Error ? e.message : String(e));\n });\n });\n };\n}\n"],"mappings":";;;;;;;;;;;;AAaA,SAAgB,YAAY,MAAc,MAAsB;CAC9D,MAAM,OAAO,QAAQ,MAAM,IAAI;CAC/B,MAAM,OAAO,SAAS,MAAM,IAAI;CAEhC,IAAI,SAAS,MAAM,KAAK,WAAW,IAAI,KAAK,WAAW,IAAI,KAAK,KAAK,MAAM,GAAG,CAAC,CAAC,SAAS,cAAc,GACrG,MAAM,IAAI,QAAQ,GAAG,KAAK,qCAAqC;CACjE,OAAO;AACT;AAEA,SAAgB,WAAW,MAAc,MAAsB;CAC7D,IAAI;EACF,OAAO,aAAa,YAAY,MAAM,IAAI,GAAG,MAAM;CACrD,SAAS,GAAG;EACV,IAAI,aAAa,SAAS,MAAM;EAChC,MAAM,IAAI,QAAQ,cAAc,KAAK,wCAAwC,EAAE,OAAO,EAAE,CAAC;CAC3F;AACF;;AAGA,SAAgB,SAAS,MAAc,QAAwB;CAC7D,MAAM,EAAE,MAAM,MAAM,WAAW,OAAO;CACtC,MAAM,OAAO,WAAW,MAAM,IAAI;CAClC,MAAM,SAAS,SAAS,WAAW,IAAI,GAAG,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a,SAAS;IAC1B,SAAS,QAAQ,SAAS,OAAO,SAAS,IAAI,UAAU,MAAM,KAAK,CAAC;IACpE,IAAI,IAAI,OAAO,KAAK,MAAM,SAAS,YAAY,CAAC,CAAC;GACnD,CAAC,CAAC,CACD,OAAO,MAAe;IACrB,IAAI,aAAa;IACjB,IAAI,IAAI,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC,CAAC;GACpD,CAAC;EACL,CAAC;CACH;AACF"}
1
+ {"version":3,"file":"endpoints.js","names":[],"sources":["../../src/tools/source.ts","../../src/tools/history.ts","../../src/tools/endpoints.ts"],"sourcesContent":["/**\n * The source a server half reads: a target's file, parsed, and the opening tag the page's attribute\n * points at. Files are only ever read and written under the project's root, outside `node_modules`.\n */\nimport { readFileSync } from 'node:fs';\nimport { isAbsolute, relative, resolve, sep } from 'node:path';\n\nimport { Refusal, type Source, type Target, type TextEdit } from '#src/index.ts';\n\nimport { ASTRO, parseAstro, type Parsed } from './astro.ts';\nimport { isHost, lineStarts, offsetOf, openingsIn, parse } from './locate.ts';\n\n/** A file from the project's root, as an absolute path; refused anywhere the page has no business writing. */\nexport function resolveFile(root: string, file: string): string {\n const path = resolve(root, file);\n const from = relative(root, path);\n // `relative` gives an absolute path for another drive.\n if (from === '' || from.startsWith('..') || isAbsolute(from) || from.split(sep).includes('node_modules'))\n throw new Refusal(`${file} is not a file of this project's own`);\n return path;\n}\n\nexport function readSource(root: string, file: string): string {\n try {\n return readFileSync(resolveFile(root, file), 'utf8');\n } catch (e) {\n if (e instanceof Refusal) throw e;\n throw new Refusal(`can't read ${file}: has it moved since the page loaded?`, { cause: e });\n }\n}\n\n/**\n * The target's file and element, as they are on disk now. The element is the one the page's mark names, or else the\n * only one of its tag on that line: the page may count columns in code a plugin before deictic's changed.\n */\nexport function sourceAt(root: string, target: Target): Source {\n const { file, line, column } = target.loc;\n const code = readSource(root, file);\n const lines = lineStarts(code);\n const offset = offsetOf(lines, line, column);\n const { program, elements } = ASTRO.test(file) ? astro(root, file, code) : jsx(file, code);\n const tagged = elements.filter((el) => isHost(el) && el.name.type === 'JSXIdentifier' && el.name.name === target.tag);\n const start = lines[line - 1];\n const onLine = start === undefined ? [] : tagged.filter((el) => el.start >= start && el.start < (lines[line] ?? Infinity));\n const element = tagged.find((el) => el.start === offset) ?? (onLine.length === 1 ? onLine[0] : undefined);\n if (element === undefined) throw new Refusal(notThere(target, code, lines, onLine.length));\n return { file, code, program, element, read: (other) => readSource(root, other) };\n}\n\n/** Why the page's element isn't in the file, from what the file has there: it may not have changed at all. */\nfunction notThere({ loc: { file, line, column }, tag }: Target, code: string, lines: number[], onLine: number): string {\n const start = lines[line - 1];\n const found =\n start === undefined\n ? `${file} has no line ${line}`\n : onLine === 0\n ? `line ${line} of ${file} has no <${tag}>: it reads \\`${clip(code.slice(start, (lines[line] ?? code.length + 1) - 1).trim())}\\``\n : `line ${line} of ${file} has ${onLine} <${tag}>s, none at column ${column}`;\n return `${found}. The page isn't running the file as it is: reload it, and if it says this again, a plugin before deictic's changes the file, so put deictic first`;\n}\n\nconst clip = (text: string) => (text.length > 80 ? `${text.slice(0, 79)}…` : text);\n\nfunction jsx(file: string, code: string): Parsed {\n const { program, errors } = parse(file, code);\n if (errors.length > 0) throw new Refusal(`${file} doesn't parse: fix it first (${errors[0]!.message})`);\n return { program, elements: openingsIn(program) };\n}\n\nfunction astro(root: string, file: string, code: string): Parsed {\n const parsed = parseAstro(root, code);\n if ('problem' in parsed) throw new Refusal(`${file} can't be read: ${parsed.problem}`);\n return parsed;\n}\n\n/** Each file's text after its edits, which must not overlap. */\nexport function applyEdits(source: Source, edits: TextEdit[]): Map<string, string> {\n const byFile = Map.groupBy(edits, (e) => e.file ?? source.file);\n const out = new Map<string, string>();\n for (const [file, list] of byFile) {\n const sorted = list.toSorted((a, b) => b.start - a.start);\n let code = file === source.file ? source.code : source.read(file);\n let floor = Infinity;\n for (const edit of sorted) {\n if (edit.end > floor) throw new Error(`deictic: edits to ${file} overlap at ${edit.end}`);\n code = code.slice(0, edit.start) + edit.text + code.slice(edit.end);\n floor = edit.start;\n }\n out.set(file, code);\n }\n return out;\n}\n","/**\n * Every change deictic made, to undo and redo. A change to files holds each file's whole text\n * before and after: source files are small, and the texts make undo exact without a diff to go stale.\n * A change a plugin made itself (`Done`) holds the plugin's name and its record, and undoing it is the\n * plugin's `undo`.\n *\n * Each change has a scope, the plugin and the element it was made on, and the popup undoes and redoes\n * within its own: the latest change of this tab on this element, not the latest of all. So a change\n * is taken back out of order, with later ones to the same file still in it. Then only the lines the\n * change wrote go back to what they were, where they're still in the file as it wrote them, once.\n *\n * Anything else is refused, not merged: a file whose lines were edited since has the editor's own undo\n * for it; and a redo likewise. A plugin's undo refuses on its own terms. Kept under `.deictic`, so it\n * outlives a restart of the dev server and stays out of git.\n */\nimport { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';\nimport { dirname } from 'node:path';\n\nimport { Refusal, type ServerPlugin } from '#src/index.ts';\n\nimport { keptIn } from './kept.ts';\nimport { resolveFile } from './source.ts';\n\nexport interface FileChange {\n file: string;\n /** The text before, or nothing for a file the change made. */\n before: string | null;\n after: string;\n}\n\n/** Whose a change is: the plugin whose tab made it, and the element it was open on, as `file:line:column`. */\nexport interface Scope {\n plugin: string;\n target: string;\n}\n\ninterface Base {\n id: number;\n at: string;\n label: string;\n /** None on a change made without one, which only an undo of the whole history reaches. */\n scope?: Scope;\n}\n\nexport type Change = Base & ({ files: FileChange[] } | { plugin: string; record: unknown });\n\n/** A change as the page lists it. `files` is empty for one a plugin made itself. */\nexport interface Summary {\n id: number;\n at: string;\n label: string;\n files: string[];\n}\n\nexport interface HistoryOptions {\n /** Whose `undo` and `redo` take back the changes they made themselves. */\n plugins?: ServerPlugin[];\n store?: string;\n}\n\nconst LIMIT = 200;\n\n/** Whether a change is in a scope: any is in none. */\nconst within = (scope: Scope | undefined) => (c: Change) =>\n scope === undefined || (c.scope?.plugin === scope.plugin && c.scope.target === scope.target);\n\nconst summary = (c: Change): Summary => ({ id: c.id, at: c.at, label: c.label, files: 'files' in c ? c.files.map((f) => f.file) : [] });\n\nexport class History {\n #done: Change[] = [];\n #undone: Change[] = [];\n readonly #root: string;\n readonly #store: string;\n readonly #plugins: Map<string, ServerPlugin>;\n\n constructor(root: string, { plugins = [], store = keptIn(root, 'history.json') }: HistoryOptions = {}) {\n this.#root = root;\n this.#store = store;\n this.#plugins = new Map(plugins.map((p) => [p.name, p]));\n if (!existsSync(store)) return;\n try {\n ({ done: this.#done, undone: this.#undone } = JSON.parse(readFileSync(store, 'utf8')) as { done: Change[]; undone: Change[] });\n } catch {\n // A history that doesn't read is one we start over, not one to stop the dev server for.\n }\n }\n\n /** Writes each file's new text and records it as one change. A redo after it, in its scope, is gone, as in any editor. */\n commit(label: string, texts: Map<string, string>, scope?: Scope): Summary {\n const files: FileChange[] = [];\n for (const [file, after] of texts) {\n const path = resolveFile(this.#root, file);\n const before = existsSync(path) ? readFileSync(path, 'utf8') : null;\n if (before !== after) files.push({ file, before, after });\n }\n if (files.length === 0) throw new Refusal('nothing to change: the source already says that');\n for (const f of files) write(resolveFile(this.#root, f.file), f.after);\n return this.#push({ label, files }, scope);\n }\n\n /** Records a change `plugin` made itself, with what its `undo` needs. */\n record(label: string, plugin: string, record: unknown, scope?: Scope): Summary {\n return this.#push({ label, plugin, record }, scope);\n }\n\n /** Takes back the latest change, of a scope where one is given. */\n async undo(scope?: Scope): Promise<Summary> {\n const change = this.#done.findLast(within(scope));\n if (change === undefined) throw new Refusal(scope === undefined ? 'nothing to undo' : 'nothing to undo here');\n if ('files' in change) this.#put(change, 'after', 'before');\n else change.record = (await this.#pluginOf(change, 'undo').undo!(change.record)) ?? change.record;\n this.#done = this.#done.filter((c) => c !== change);\n this.#undone.push(change);\n this.#save();\n return summary(change);\n }\n\n /** Makes the change last undone again, of a scope where one is given. */\n async redo(scope?: Scope): Promise<Summary> {\n const change = this.#undone.findLast(within(scope));\n if (change === undefined) throw new Refusal(scope === undefined ? 'nothing to redo' : 'nothing to redo here');\n if ('files' in change) this.#put(change, 'before', 'after');\n else change.record = await this.#pluginOf(change, 'redo').redo!(change.record);\n this.#undone = this.#undone.filter((c) => c !== change);\n this.#done.push(change);\n this.#save();\n return summary(change);\n }\n\n list(scope?: Scope): { done: Summary[]; undone: Summary[] } {\n return { done: this.#done.filter(within(scope)).map(summary), undone: this.#undone.filter(within(scope)).map(summary) };\n }\n\n #push(change: Omit<Base, 'id' | 'at'> & ({ files: FileChange[] } | { plugin: string; record: unknown }), scope?: Scope): Summary {\n const id = Math.max(0, ...[...this.#done, ...this.#undone].map((c) => c.id)) + 1;\n const made = { id, at: new Date().toISOString(), ...change, ...(scope === undefined ? {} : { scope }) };\n this.#done = [...this.#done, made].slice(-LIMIT);\n // What was undone in this scope can't be redone over the new change; another scope's still can.\n this.#undone = this.#undone.filter((c) => !within(scope)(c));\n this.#save();\n return summary(made);\n }\n\n #pluginOf(change: { label: string; plugin: string }, step: 'undo' | 'redo'): ServerPlugin {\n const plugin = this.#plugins.get(change.plugin);\n if (plugin?.[step] === undefined) {\n throw new Refusal(\n `can't ${step} \"${change.label}\": the ${change.plugin} plugin that made it isn't loaded, so add it back to \\`plugins\\``,\n );\n }\n return plugin;\n }\n\n /**\n * Puts each file's `to` text back, once every one of them still reads as its `from`, or still has the\n * lines that differ as `from` has them: then those lines alone change, and the rest stays as it is now.\n */\n #put(change: Base & { files: FileChange[] }, from: 'before' | 'after', to: 'before' | 'after'): void {\n const paths = change.files.map((f) => resolveFile(this.#root, f.file));\n const texts = change.files.map((f, i) => {\n const now = existsSync(paths[i]!) ? readFileSync(paths[i]!, 'utf8') : null;\n if (now === f[from]) return f[to];\n const text = now === null || f[from] === null || f[to] === null ? undefined : swapped(now, f[from], f[to]);\n if (text === undefined) {\n throw new Refusal(\n `${f.file} changed since \"${change.label}\" ${from === 'after' ? 'was made' : 'was undone'}: use the editor's undo there`,\n );\n }\n return text;\n });\n texts.forEach((text, i) => {\n if (text === null) rmSync(paths[i]!);\n else write(paths[i]!, text);\n });\n }\n\n #save(): void {\n write(this.#store, JSON.stringify({ done: this.#done, undone: this.#undone }));\n }\n}\n\n/**\n * `now` with the lines that differ between `from` and `to` put as `to` has them, where `now` has them as\n * `from` does, in one place only. Nothing where it doesn't (they were edited, or there are two of them), or\n * where `from` has no such lines to find (the change only removed some).\n */\nfunction swapped(now: string, from: string, to: string): string | undefined {\n const [a, b, lines] = [from.split('\\n'), to.split('\\n'), now.split('\\n')];\n let head = 0;\n while (head < a.length && head < b.length && a[head] === b[head]) head++;\n let tail = 0;\n while (tail < a.length - head && tail < b.length - head && a.at(-1 - tail) === b.at(-1 - tail)) tail++;\n const theirs = a.slice(head, a.length - tail);\n if (theirs.length === 0) return undefined;\n const found = lines.flatMap((_, i) => (theirs.every((line, j) => lines[i + j] === line) ? [i] : []));\n if (found.length !== 1) return undefined;\n return [...lines.slice(0, found[0]), ...b.slice(head, b.length - tail), ...lines.slice(found[0]! + theirs.length)].join('\\n');\n}\n\nfunction write(path: string, text: string): void {\n mkdirSync(dirname(path), { recursive: true });\n writeFileSync(path, text);\n}\n","/**\n * The dev server's half of deictic, under `/__deictic/`: `read` and `apply` an op through a\n * plugin, `undo`, `redo` and `history`, and `open`, which opens a place in the editor. Written over\n * `Request` and `Response`, so each integration mounts them its own way (Vite as middleware), and\n * served from the page's own origin, so no token travels to the page. `undo`, `redo` and `history` are a\n * plugin's on an element where the request names them (as the popup does: its tab, its element), and\n * the whole history's where it doesn't.\n *\n * Everything but `open` and `history` writes or may, so only the page itself may send it: a POST of\n * JSON from the same origin, which a form or a script on another site can't send without asking first.\n *\n * Each plugin's own `routes` are under `plugins/<name>/`. A `GET` there reaches the plugin as it\n * comes; anything else only from the page's own origin, in whatever type it sends (an image, say).\n * Nothing is answered before every plugin's `setup` has run.\n */\nimport type { IncomingMessage, ServerResponse } from 'node:http';\n\nimport { type Loc, Refusal, type ServerPlugin, type Source, type Target } from '#src/index.ts';\n\nimport { History, type Scope } from './history.ts';\nimport { missingMessage } from './packages.ts';\nimport { setUp } from './plugins.ts';\nimport { applyEdits, resolveFile, sourceAt } from './source.ts';\n\nexport interface EndpointOptions {\n root: string;\n plugins: ServerPlugin[];\n /** The path the endpoints sit under, ending in `/`: `/` by default. */\n base?: string;\n /** Opens a place in the editor: a redirect to the dev server's own launcher. */\n open: (path: string, loc: Loc) => Response | Promise<Response>;\n history?: History;\n}\n\ninterface Body {\n plugin: string;\n target: Target;\n op?: unknown;\n}\n\nconst scopeOf = (plugin: string, { file, line, column }: Loc): Scope => ({ plugin, target: `${file}:${line}:${column}` });\n/** The scope an undo or a redo names, or none for the whole history. */\nconst scopeIn = ({ plugin, target }: Partial<Body>) =>\n plugin === undefined || target === undefined ? undefined : scopeOf(plugin, target.loc);\n\n/** Answers deictic's requests, and nothing for any other path. */\nexport function endpoints({ root, plugins, base = '/', open, history = new History(root, { plugins }) }: EndpointOptions) {\n const byName = new Map(plugins.map((p) => [p.name, p]));\n const prefix = `${base}__deictic/`;\n // Started now, awaited by every request: a plugin's API is there before anything asks for it.\n const ready = setUp(root, plugins);\n const gone = missingMessage(root, plugins);\n if (gone !== undefined) console.warn(gone);\n\n const pluginOf = (name: string) => {\n const plugin = byName.get(name);\n if (plugin === undefined) throw new Refusal(`no plugin \"${name}\" on the server: is it in the bundler plugin's \\`plugins\\`?`);\n return plugin;\n };\n\n const routes: Record<string, (body: Body) => Promise<unknown>> = {\n read: async ({ plugin, target }) => ({ model: await readOf(pluginOf(plugin), target) }),\n apply: async ({ plugin: name, target, op }) => {\n const plugin = pluginOf(name);\n if (plugin.apply === undefined) throw new Refusal(`${name} changes nothing from its panel: it has no \\`apply\\``);\n const source = sourceOf(target);\n const before = await readOf(plugin, target, source);\n const { file, line } = target.loc;\n const label = `${name} ${file}:${line}: ${plugin.describe?.(op, before) ?? 'edit'}`;\n const result = await plugin.apply(source, target, op);\n const scope = scopeOf(name, target.loc);\n if (!Array.isArray(result)) return { change: history.record(label, name, result.done, scope), model: await readOf(plugin, target) };\n // Edits to a file whose element isn't found would go who knows where: refused, as only they need it.\n if (source instanceof Refusal) throw source;\n const change = history.commit(label, applyEdits(source, result), scope);\n return { model: await readOf(plugin, target), change };\n },\n undo: async (body) => ({ change: await history.undo(scopeIn(body)) }),\n redo: async (body) => ({ change: await history.redo(scopeIn(body)) }),\n };\n // The source or why it can't be had, for the plugin to decide: only an edit to the file needs it, not a task.\n const sourceOf = (target: Target): Source | Refusal => {\n try {\n return sourceAt(root, target);\n } catch (e) {\n if (e instanceof Refusal) return e;\n throw e;\n }\n };\n // A plugin without `read` has no model, and no need for its element to be where the page says.\n const readOf = (plugin: ServerPlugin, target: Target, source?: Source | Refusal) =>\n plugin.read === undefined ? null : plugin.read(source ?? sourceOf(target), target);\n // One write at a time: a plugin's change may wait on the network, and an undo sent meanwhile must\n // take back that change, not the one before it.\n let queue: Promise<unknown> = Promise.resolve();\n const serially = <T>(run: () => Promise<T>): Promise<T> => {\n const next = queue.then(run, run);\n queue = next.catch(() => {});\n return next;\n };\n\n return async (req: Request): Promise<Response | undefined> => {\n const url = new URL(req.url);\n if (!url.pathname.startsWith(prefix)) return undefined;\n const route = url.pathname.slice(prefix.length);\n const origin = req.headers.get('origin');\n const sameOrigin = origin !== null && new URL(origin).host === url.host;\n try {\n const context = await ready;\n if (route.startsWith('plugins/')) {\n const [name = '', first = ''] = route.slice('plugins/'.length).split('/');\n const handle = byName.get(name)?.routes?.[first];\n if (handle === undefined) return new Response(`no endpoint ${url.pathname}`, { status: 404 });\n if (req.method !== 'GET' && req.method !== 'HEAD' && !sameOrigin)\n return Response.json({ problem: `only the page itself may ${req.method} to ${name}` }, { status: 403 });\n return await handle(req, context);\n }\n const loc = {\n file: url.searchParams.get('file') ?? '',\n line: Number(url.searchParams.get('line')),\n column: Number(url.searchParams.get('column')),\n };\n if (route === 'history') {\n const plugin = url.searchParams.get('plugin');\n return Response.json(history.list(plugin === null ? undefined : scopeOf(plugin, loc)));\n }\n if (route === 'open') return await open(resolveFile(root, loc.file), loc);\n const handler = routes[route];\n if (handler === undefined) return new Response(`no endpoint ${url.pathname}`, { status: 404 });\n if (req.method !== 'POST' || !sameOrigin || req.headers.get('content-type')?.startsWith('application/json') !== true)\n return Response.json({ problem: 'edits come from the page, as JSON' }, { status: 403 });\n const body = (await req.json()) as Body;\n return Response.json(await (route === 'read' ? handler(body) : serially(() => handler(body))));\n } catch (e) {\n if (e instanceof Refusal) return Response.json({ problem: e.message }, { status: 422 });\n return Response.json({ problem: e instanceof Error ? (e.stack ?? e.message) : String(e) }, { status: 500 });\n }\n };\n}\n\n/** A redirect within the page's origin, to a launcher the dev server answers itself. */\nexport const redirect = (path: string) => new Response(null, { status: 307, headers: { Location: path } });\n\n/**\n * The endpoints as Node middleware, for Vite's server. The request's host is the one the page was\n * served from: a proxy's `x-forwarded-host` before its own.\n */\nexport function nodeMiddleware(\n handle: (req: Request) => Promise<Response | undefined>,\n): (req: IncomingMessage, res: ServerResponse, next: () => void) => void {\n return (req, res, next) => {\n // Before reading the body, which a request for anything else leaves to whoever answers it.\n if (req.url?.includes('/__deictic/') !== true) return next();\n const forwarded = req.headers['x-forwarded-host'];\n const host = (Array.isArray(forwarded) ? forwarded[0] : forwarded) ?? req.headers.host ?? 'localhost';\n const headers = new Headers();\n for (const [name, value] of Object.entries(req.headers))\n for (const v of Array.isArray(value) ? value : value === undefined ? [] : [value]) headers.append(name, v);\n\n const chunks: Buffer[] = [];\n req.on('data', (chunk: Buffer) => chunks.push(chunk));\n req.on('end', () => {\n const body = req.method === 'GET' || req.method === 'HEAD' ? undefined : Buffer.concat(chunks);\n handle(new Request(`http://${host}${req.url}`, { method: req.method, headers, body }))\n .then(async (response) => {\n if (response === undefined) return next();\n res.statusCode = response.status;\n response.headers.forEach((value, name) => res.setHeader(name, value));\n res.end(Buffer.from(await response.arrayBuffer()));\n })\n .catch((e: unknown) => {\n res.statusCode = 500;\n res.end(e instanceof Error ? e.message : String(e));\n });\n });\n };\n}\n"],"mappings":";;;;;;;;;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AAO,MAAM,CAAC;EAE3G,MAAM,SAAmB,CAAC;EAC1B,IAAI,GAAG,SAAS,UAAkB,OAAO,KAAK,KAAK,CAAC;EACpD,IAAI,GAAG,aAAa;GAClB,MAAM,OAAO,IAAI,WAAW,SAAS,IAAI,WAAW,SAAS,KAAA,IAAY,OAAO,OAAO,MAAM;GAC7F,OAAO,IAAI,QAAQ,UAAU,OAAO,IAAI,OAAO;IAAE,QAAQ,IAAI;IAAQ;IAAS;GAAK,CAAC,CAAC,CAAC,CACnF,KAAK,OAAO,aAAa;IACxB,IAAI,aAAa,KAAA,GAAW,OAAO,KAAK;IACxC,IAAI,aAAa,SAAS;IAC1B,SAAS,QAAQ,SAAS,OAAO,SAAS,IAAI,UAAU,MAAM,KAAK,CAAC;IACpE,IAAI,IAAI,OAAO,KAAK,MAAM,SAAS,YAAY,CAAC,CAAC;GACnD,CAAC,CAAC,CACD,OAAO,MAAe;IACrB,IAAI,aAAa;IACjB,IAAI,IAAI,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC,CAAC;GACpD,CAAC;EACL,CAAC;CACH;AACF"}
@@ -33,7 +33,8 @@ async function loadRecording(ref, nth = 1) {
33
33
  const file = files[nth - 1];
34
34
  if (file === void 0) fail(`Task #${root.id} has ${files.length} recording(s), not a ${nth}th.`);
35
35
  const id = file.name.slice(10, -5);
36
- const replay = new RegExp(`https?://\\S+/replay/${id}`).exec(root.text)?.[0];
36
+ const where = (text) => new RegExp(`https?://\\S+/replay/${id}`).exec(text)?.[0];
37
+ const replay = Object.values(root.labels).map(where).find(Boolean) ?? where(root.text);
37
38
  return {
38
39
  kept: parsed(fetched(root, file.name)),
39
40
  id,
@@ -1 +1 @@
1
- {"version":3,"file":"find.js","names":[],"sources":["../../src/cli/find.ts"],"sourcesContent":["/**\n * Finding what a task carries: a recording or a voice clip, by a task's ID, a recording's ID, a replay URL or a path,\n * kept under a `.deictic/` near here or downloaded from the board. And the tools outside deictic some commands run\n * (ffmpeg, the project's Playwright).\n */\nimport { spawnSync } from 'node:child_process';\nimport { existsSync, mkdtempSync, readdirSync, readFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { tmpdir } from 'node:os';\nimport { join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nimport type { Kept } from '#src/plugins/recordings/index.ts';\n\nimport { deicticDirs, download, fail, type Message, task } from './board.ts';\n\nconst TASK = /^#?\\d+$/;\n\nexport interface Found {\n kept: Kept;\n id: string;\n /** Where it replays, where that's known. */\n replay?: string;\n /** The task it's attached to, where it was found by one. */\n task?: Message;\n}\n\nconst parsed = (path: string) => JSON.parse(readFileSync(path, 'utf8')) as Kept;\n\n/** An attachment of a task, written to a temporary folder: its path. */\nfunction fetched(root: Message, name: string): string {\n const file = root.attachments.find((a) => a.name === name);\n if (file === undefined) fail(`Task #${root.id} has no ${name}.`);\n const path = join(mkdtempSync(join(tmpdir(), 'deictic-')), file.name);\n download(file, path);\n return path;\n}\n\n/**\n * A recording, with where it came from. `ref` is a task's ID (its first recording, or the `nth`), a replay or\n * recording URL, a recording's ID kept under a `.deictic/`, or a path.\n */\nexport async function loadRecording(ref: string | undefined, nth = 1): Promise<Found> {\n if (ref === undefined) fail('Name a recording: a task (68), a replay URL, a recording ID or a JSON file.');\n if (TASK.test(ref)) {\n const root = task(ref);\n const files = root.attachments.filter((a) => /^recording-.*\\.json$/.test(a.name));\n const file = files[nth - 1];\n if (file === undefined) fail(`Task #${root.id} has ${files.length} recording(s), not a ${nth}th.`);\n const id = file.name.slice('recording-'.length, -'.json'.length);\n const replay = new RegExp(`https?://\\\\S+/replay/${id}`).exec(root.text)?.[0];\n return { kept: parsed(fetched(root, file.name)), id, replay, task: root };\n }\n if (/^https?:/.test(ref)) {\n const url = new URL(ref);\n const id = url.pathname.split('/').at(-1) ?? '';\n const json = new URL(url.pathname.replace(/\\/(replay|recording)\\/[^/]+$/, `/recording/${id}`), url);\n const res = await fetch(json);\n if (!res.ok) fail(`${json.href}: ${res.status} ${await res.text()}`);\n return { kept: (await res.json()) as Kept, id, replay: new URL(json.pathname.replace(/\\/recording\\//, '/replay/'), url).href };\n }\n if (existsSync(ref)) return { kept: parsed(ref), id: ref.replace(/^.*[\\\\/]|\\.json$/g, '') };\n for (const dir of deicticDirs()) {\n const path = join(dir, 'recordings', `${ref}.json`);\n if (existsSync(path)) return { kept: parsed(path), id: ref };\n }\n return fail(`No recording ${ref} in ${deicticDirs().join(', ') || 'any .deictic/ near here'}: name its task or replay URL instead.`);\n}\n\n/** A voice clip kept under a `.deictic/` near here, by its ID. */\nfunction keptClip(id: string): string | undefined {\n for (const dir of deicticDirs()) {\n const voice = join(dir, 'voice');\n const name = existsSync(voice) ? readdirSync(voice).find((f) => f.startsWith(`${id}.`)) : undefined;\n if (name !== undefined) return join(voice, name);\n }\n return undefined;\n}\n\n/** A voice clip's audio as a file: kept under a `.deictic/`, or downloaded from `from`. */\nfunction voiceFile(id: string, from?: Message): string {\n const kept = keptClip(id);\n if (kept !== undefined) return kept;\n const file = from?.attachments.find((a) => a.name.startsWith(`voice-${id}.`));\n if (from === undefined || file === undefined) fail(`No voice clip ${id} here${from ? ` or on task #${from.id}` : ''}.`);\n return fetched(from, file.name);\n}\n\nexport interface Clip {\n id: string;\n file: string;\n /** Where it starts in its recording, or 0 for a voice note on its own. */\n at: number;\n recording?: string;\n}\n\n/**\n * The voice clips `ref` names: a task (every recording's clips and its voice notes), a recording as `loadRecording`\n * takes one, or a clip's ID.\n */\nexport async function voiceClips(ref: string | undefined): Promise<Clip[]> {\n if (ref === undefined) fail('Name a task, a recording or a voice clip.');\n const clips: Clip[] = [];\n if (TASK.test(ref)) {\n const root = task(ref);\n const recordings = root.attachments.filter((a) => /^recording-.*\\.json$/.test(a.name));\n const inRecordings = new Set<string>();\n for (let n = 1; n <= recordings.length; n++) {\n const { kept, id } = await loadRecording(ref, n);\n for (const c of kept.voice ?? []) {\n inRecordings.add(c.id);\n clips.push({ id: c.id, file: voiceFile(c.id, root), at: c.at, recording: id });\n }\n }\n for (const a of root.attachments) {\n const id = /^voice-(.+)\\.\\w+$/.exec(a.name)?.[1];\n if (id !== undefined && !inRecordings.has(id)) clips.push({ id, file: voiceFile(id, root), at: 0 });\n }\n } else if (!/^https?:/.test(ref) && !existsSync(ref) && keptClip(ref) !== undefined) {\n clips.push({ id: ref, file: voiceFile(ref), at: 0 });\n } else {\n const { kept, id } = await loadRecording(ref);\n for (const c of kept.voice ?? []) clips.push({ id: c.id, file: voiceFile(c.id), at: c.at, recording: id });\n }\n if (clips.length === 0) fail(`No voice on ${ref}.`);\n return clips;\n}\n\n/** Runs ffmpeg, which reads what MediaRecorder makes, and answers its log (stderr) and what it wrote to stdout. */\nexport function ffmpeg(args: string[]): { stdout: Buffer; log: string } {\n const run = spawnSync('ffmpeg', ['-hide_banner', '-nostats', ...args], { maxBuffer: 1 << 30 });\n if (run.error) fail('Needs ffmpeg on the PATH (https://ffmpeg.org/download.html).');\n return { stdout: run.stdout, log: run.stderr.toString('utf8') };\n}\n\n/** The project's own copy of a package deictic doesn't bring (Playwright, either of its names), from here. */\nexport async function fromProject<T>(...names: string[]): Promise<T> {\n const project = createRequire(join(process.cwd(), 'package.json'));\n for (const name of names) {\n try {\n return (await import(pathToFileURL(project.resolve(name)).href)) as T;\n } catch {\n // Not this one: the next name.\n }\n }\n return fail(`Needs ${names.join(' or ')} in the project: npm install -D ${names[0]}`);\n}\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAM,OAAO;AAWb,MAAM,UAAU,SAAiB,KAAK,MAAM,aAAa,MAAM,MAAM,CAAC;;AAGtE,SAAS,QAAQ,MAAe,MAAsB;CACpD,MAAM,OAAO,KAAK,YAAY,MAAM,MAAM,EAAE,SAAS,IAAI;CACzD,IAAI,SAAS,KAAA,GAAW,KAAK,SAAS,KAAK,GAAG,UAAU,KAAK,EAAE;CAC/D,MAAM,OAAO,KAAK,YAAY,KAAK,OAAO,GAAG,UAAU,CAAC,GAAG,KAAK,IAAI;CACpE,SAAS,MAAM,IAAI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,MAAM,UAAU,cAAc,KAAK,QAAQ,IAAI,GAAG,cAAc,CAAC;CACjE,KAAK,MAAM,QAAQ,OACjB,IAAI;EACF,OAAQ,MAAM,OAAO,cAAc,QAAQ,QAAQ,IAAI,CAAC,CAAC,CAAC;CAC5D,QAAQ,CAER;CAEF,OAAO,KAAK,SAAS,MAAM,KAAK,MAAM,EAAE,kCAAkC,MAAM,IAAI;AACtF"}
1
+ {"version":3,"file":"find.js","names":[],"sources":["../../src/cli/find.ts"],"sourcesContent":["/**\n * Finding what a task carries: a recording or a voice clip, by a task's ID, a recording's ID, a replay URL or a path,\n * kept under a `.deictic/` near here or downloaded from the board. And the tools outside deictic some commands run\n * (ffmpeg, the project's Playwright).\n */\nimport { spawnSync } from 'node:child_process';\nimport { existsSync, mkdtempSync, readdirSync, readFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { tmpdir } from 'node:os';\nimport { join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nimport type { Kept } from '#src/plugins/recordings/index.ts';\n\nimport { deicticDirs, download, fail, type Message, task } from './board.ts';\n\nconst TASK = /^#?\\d+$/;\n\nexport interface Found {\n kept: Kept;\n id: string;\n /** Where it replays, where that's known. */\n replay?: string;\n /** The task it's attached to, where it was found by one. */\n task?: Message;\n}\n\nconst parsed = (path: string) => JSON.parse(readFileSync(path, 'utf8')) as Kept;\n\n/** An attachment of a task, written to a temporary folder: its path. */\nfunction fetched(root: Message, name: string): string {\n const file = root.attachments.find((a) => a.name === name);\n if (file === undefined) fail(`Task #${root.id} has no ${name}.`);\n const path = join(mkdtempSync(join(tmpdir(), 'deictic-')), file.name);\n download(file, path);\n return path;\n}\n\n/**\n * A recording, with where it came from. `ref` is a task's ID (its first recording, or the `nth`), a replay or\n * recording URL, a recording's ID kept under a `.deictic/`, or a path.\n */\nexport async function loadRecording(ref: string | undefined, nth = 1): Promise<Found> {\n if (ref === undefined) fail('Name a recording: a task (68), a replay URL, a recording ID or a JSON file.');\n if (TASK.test(ref)) {\n const root = task(ref);\n const files = root.attachments.filter((a) => /^recording-.*\\.json$/.test(a.name));\n const file = files[nth - 1];\n if (file === undefined) fail(`Task #${root.id} has ${files.length} recording(s), not a ${nth}th.`);\n const id = file.name.slice('recording-'.length, -'.json'.length);\n // Its `deictic.recording.N.replay` label, or in the text of a task added before that was a label.\n const where = (text: string) => new RegExp(`https?://\\\\S+/replay/${id}`).exec(text)?.[0];\n const replay = Object.values(root.labels).map(where).find(Boolean) ?? where(root.text);\n return { kept: parsed(fetched(root, file.name)), id, replay, task: root };\n }\n if (/^https?:/.test(ref)) {\n const url = new URL(ref);\n const id = url.pathname.split('/').at(-1) ?? '';\n const json = new URL(url.pathname.replace(/\\/(replay|recording)\\/[^/]+$/, `/recording/${id}`), url);\n const res = await fetch(json);\n if (!res.ok) fail(`${json.href}: ${res.status} ${await res.text()}`);\n return { kept: (await res.json()) as Kept, id, replay: new URL(json.pathname.replace(/\\/recording\\//, '/replay/'), url).href };\n }\n if (existsSync(ref)) return { kept: parsed(ref), id: ref.replace(/^.*[\\\\/]|\\.json$/g, '') };\n for (const dir of deicticDirs()) {\n const path = join(dir, 'recordings', `${ref}.json`);\n if (existsSync(path)) return { kept: parsed(path), id: ref };\n }\n return fail(`No recording ${ref} in ${deicticDirs().join(', ') || 'any .deictic/ near here'}: name its task or replay URL instead.`);\n}\n\n/** A voice clip kept under a `.deictic/` near here, by its ID. */\nfunction keptClip(id: string): string | undefined {\n for (const dir of deicticDirs()) {\n const voice = join(dir, 'voice');\n const name = existsSync(voice) ? readdirSync(voice).find((f) => f.startsWith(`${id}.`)) : undefined;\n if (name !== undefined) return join(voice, name);\n }\n return undefined;\n}\n\n/** A voice clip's audio as a file: kept under a `.deictic/`, or downloaded from `from`. */\nfunction voiceFile(id: string, from?: Message): string {\n const kept = keptClip(id);\n if (kept !== undefined) return kept;\n const file = from?.attachments.find((a) => a.name.startsWith(`voice-${id}.`));\n if (from === undefined || file === undefined) fail(`No voice clip ${id} here${from ? ` or on task #${from.id}` : ''}.`);\n return fetched(from, file.name);\n}\n\nexport interface Clip {\n id: string;\n file: string;\n /** Where it starts in its recording, or 0 for a voice note on its own. */\n at: number;\n recording?: string;\n}\n\n/**\n * The voice clips `ref` names: a task (every recording's clips and its voice notes), a recording as `loadRecording`\n * takes one, or a clip's ID.\n */\nexport async function voiceClips(ref: string | undefined): Promise<Clip[]> {\n if (ref === undefined) fail('Name a task, a recording or a voice clip.');\n const clips: Clip[] = [];\n if (TASK.test(ref)) {\n const root = task(ref);\n const recordings = root.attachments.filter((a) => /^recording-.*\\.json$/.test(a.name));\n const inRecordings = new Set<string>();\n for (let n = 1; n <= recordings.length; n++) {\n const { kept, id } = await loadRecording(ref, n);\n for (const c of kept.voice ?? []) {\n inRecordings.add(c.id);\n clips.push({ id: c.id, file: voiceFile(c.id, root), at: c.at, recording: id });\n }\n }\n for (const a of root.attachments) {\n const id = /^voice-(.+)\\.\\w+$/.exec(a.name)?.[1];\n if (id !== undefined && !inRecordings.has(id)) clips.push({ id, file: voiceFile(id, root), at: 0 });\n }\n } else if (!/^https?:/.test(ref) && !existsSync(ref) && keptClip(ref) !== undefined) {\n clips.push({ id: ref, file: voiceFile(ref), at: 0 });\n } else {\n const { kept, id } = await loadRecording(ref);\n for (const c of kept.voice ?? []) clips.push({ id: c.id, file: voiceFile(c.id), at: c.at, recording: id });\n }\n if (clips.length === 0) fail(`No voice on ${ref}.`);\n return clips;\n}\n\n/** Runs ffmpeg, which reads what MediaRecorder makes, and answers its log (stderr) and what it wrote to stdout. */\nexport function ffmpeg(args: string[]): { stdout: Buffer; log: string } {\n const run = spawnSync('ffmpeg', ['-hide_banner', '-nostats', ...args], { maxBuffer: 1 << 30 });\n if (run.error) fail('Needs ffmpeg on the PATH (https://ffmpeg.org/download.html).');\n return { stdout: run.stdout, log: run.stderr.toString('utf8') };\n}\n\n/** The project's own copy of a package deictic doesn't bring (Playwright, either of its names), from here. */\nexport async function fromProject<T>(...names: string[]): Promise<T> {\n const project = createRequire(join(process.cwd(), 'package.json'));\n for (const name of names) {\n try {\n return (await import(pathToFileURL(project.resolve(name)).href)) as T;\n } catch {\n // Not this one: the next name.\n }\n }\n return fail(`Needs ${names.join(' or ')} in the project: npm install -D ${names[0]}`);\n}\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAM,OAAO;AAWb,MAAM,UAAU,SAAiB,KAAK,MAAM,aAAa,MAAM,MAAM,CAAC;;AAGtE,SAAS,QAAQ,MAAe,MAAsB;CACpD,MAAM,OAAO,KAAK,YAAY,MAAM,MAAM,EAAE,SAAS,IAAI;CACzD,IAAI,SAAS,KAAA,GAAW,KAAK,SAAS,KAAK,GAAG,UAAU,KAAK,EAAE;CAC/D,MAAM,OAAO,KAAK,YAAY,KAAK,OAAO,GAAG,UAAU,CAAC,GAAG,KAAK,IAAI;CACpE,SAAS,MAAM,IAAI;CACnB,OAAO;AACT;;;;;AAMA,eAAsB,cAAc,KAAyB,MAAM,GAAmB;CACpF,IAAI,QAAQ,KAAA,GAAW,KAAK,6EAA6E;CACzG,IAAI,KAAK,KAAK,GAAG,GAAG;EAClB,MAAM,OAAO,KAAK,GAAG;EACrB,MAAM,QAAQ,KAAK,YAAY,QAAQ,MAAM,uBAAuB,KAAK,EAAE,IAAI,CAAC;EAChF,MAAM,OAAO,MAAM,MAAM;EACzB,IAAI,SAAS,KAAA,GAAW,KAAK,SAAS,KAAK,GAAG,OAAO,MAAM,OAAO,uBAAuB,IAAI,IAAI;EACjG,MAAM,KAAK,KAAK,KAAK,MAAM,IAAqB,EAAe;EAE/D,MAAM,SAAS,SAAiB,IAAI,OAAO,wBAAwB,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,GAAG;EACtF,MAAM,SAAS,OAAO,OAAO,KAAK,MAAM,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,OAAO,KAAK,MAAM,KAAK,IAAI;EACrF,OAAO;GAAE,MAAM,OAAO,QAAQ,MAAM,KAAK,IAAI,CAAC;GAAG;GAA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AA,GACxE,MAAM,KAAK;EAAE,IAAI;EAAK,MAAM,UAAU,GAAG;EAAG,IAAI;CAAE,CAAC;MAC9C;EACL,MAAM,EAAE,MAAM,OAAO,MAAM,cAAc,GAAG;EAC5C,KAAK,MAAM,KAAK,KAAK,SAAS,CAAC,GAAG,MAAM,KAAK;GAAE,IAAI,EAAE;GAAI,MAAM,UAAU,EAAE,EAAE;GAAG,IAAI,EAAE;GAAI,WAAW;EAAG,CAAC;CAC3G;CACA,IAAI,MAAM,WAAW,GAAG,KAAK,eAAe,IAAI,EAAE;CAClD,OAAO;AACT;;AAGA,SAAgB,OAAO,MAAiD;CACtE,MAAM,MAAM,UAAU,UAAU;EAAC;EAAgB;EAAY,GAAG;CAAI,GAAG,EAAE,WAAW,KAAK,GAAG,CAAC;CAC7F,IAAI,IAAI,OAAO,KAAK,8DAA8D;CAClF,OAAO;EAAE,QAAQ,IAAI;EAAQ,KAAK,IAAI,OAAO,SAAS,MAAM;CAAE;AAChE;;AAGA,eAAsB,YAAe,GAAG,OAA6B;CACnE,MAAM,UAAU,cAAc,KAAK,QAAQ,IAAI,GAAG,cAAc,CAAC;CACjE,KAAK,MAAM,QAAQ,OACjB,IAAI;EACF,OAAQ,MAAM,OAAO,cAAc,QAAQ,QAAQ,IAAI,CAAC,CAAC,CAAC;CAC5D,QAAQ,CAER;CAEF,OAAO,KAAK,SAAS,MAAM,KAAK,MAAM,EAAE,kCAAkC,MAAM,IAAI;AACtF"}
@@ -108,10 +108,14 @@ interface ServerPlugin<Model = unknown, Op = unknown, Record = unknown, Api = un
108
108
  routes?: {
109
109
  [route: string]: Route;
110
110
  };
111
- /** The model its panel shows for an element. Without it, the panel gets none. */
112
- read?(source: Source, target: Target): Maybe<Model>;
113
- /** Text edits for deictic to write, or a change the plugin made itself. */
114
- apply?(source: Source, target: Target, op: Op): Maybe<TextEdit[] | Done<Record>>;
111
+ /**
112
+ * The model its panel shows for an element. Without it, the panel gets none. `source` is a `Refusal` where the
113
+ * 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
114
+ * the plugin needs the source, or go on without it, as a task does.
115
+ */
116
+ read?(source: Source | Refusal, target: Target): Maybe<Model>;
117
+ /** Text edits for deictic to write, which it refuses without the source, or a change the plugin made itself. */
118
+ apply?(source: Source | Refusal, target: Target, op: Op): Maybe<TextEdit[] | Done<Record>>;
115
119
  /**
116
120
  * Takes back a change `apply` made itself, or throws a `Refusal` saying why it can't any more. It may
117
121
  * answer what the next redo needs, where that differs (what it put back has a new ID).
@@ -123,6 +127,92 @@ interface ServerPlugin<Model = unknown, Op = unknown, Record = unknown, Api = un
123
127
  describe?(op: Op, before: Model): string;
124
128
  }
125
129
  declare const definePlugin: <Model, Op, Record = unknown, Api = unknown>(plugin: ServerPlugin<Model, Op, Record, Api>) => ServerPlugin<Model, Op, Record, Api>;
130
+ /** Where something is in an element, in CSS pixels from its top left. */
131
+ interface Point {
132
+ x: number;
133
+ y: number;
134
+ }
135
+ /** 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). */
136
+ interface Spot {
137
+ element: Element;
138
+ at: Point;
139
+ }
140
+ /**
141
+ * The tool panel: a bar docked to an edge of the window, which shows while a shortcut's keys are held and stays
142
+ * while it's in use. A plugin adds its tools to it from its page half's `setup`.
143
+ */
144
+ interface ToolPanel {
145
+ /**
146
+ * Adds a plugin's controls, as one group, in the order plugins are loaded. Groups of one `section` sit together,
147
+ * with no line between them, after the groups of none: the screenshots', recordings', voice's and tasks' are
148
+ * `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`
149
+ * (`B`, `Control+Z`) is the key the panel hears for it, alone or with the keys held to point, and what its tooltip
150
+ * shows.
151
+ */
152
+ add: (group: HTMLElement, options?: {
153
+ last?: boolean;
154
+ section?: string;
155
+ }) => void;
156
+ /**
157
+ * Takes the page for a tool that works on it (drawing, picking a point): the tool that had it lets go first, and
158
+ * the panel stays shown. `left` is called when another takes it, or Esc or the pointer tool gives the page back.
159
+ * Answers what lets go of it, for the tool to call when it's done on its own.
160
+ */
161
+ hold: (left: () => void) => () => void;
162
+ /** Keeps the panel shown while something goes on that its controls end (a recording). Answers what ends that. */
163
+ keep: () => () => void;
164
+ /**
165
+ * Takes the page until a point of it is pressed, lighting what's under the pointer as pointing does: answers the
166
+ * spot, the marked element there or the nearest to it, or nothing where the page was given back first.
167
+ */
168
+ pick: () => Promise<Spot | undefined>;
169
+ }
170
+ /**
171
+ * The drawer: on the window's side, where what the plugins have for the page lands, a section each. It
172
+ * shows while a shortcut's keys are held and a section has something, and stays while it's in use.
173
+ */
174
+ interface Drawer {
175
+ /**
176
+ * Adds a section, in the order added, or before the others with `first`. A section that has nothing to show sets
177
+ * its own `hidden`: the drawer stays away while every one is. Folded away, the drawer counts what the sections
178
+ * have: each says how many things it lists in `data-count`, and how many are unread in `data-unread`.
179
+ */
180
+ add: (section: HTMLElement, options?: {
181
+ first?: boolean;
182
+ }) => void;
183
+ /**
184
+ * Opens one item in the drawer, in the sections' place, under `title` and a way back. The drawer stays while it's
185
+ * open. `closed` is called when it's left, by the way back, Esc, or another item opening. Answers what closes it.
186
+ */
187
+ show: (view: HTMLElement, options?: {
188
+ title?: string;
189
+ closed?: () => void;
190
+ }) => () => void;
191
+ /** Keeps the drawer up while something goes on in it; answers what lets it go. */
192
+ keep: () => () => void;
193
+ }
194
+ /** Something a plugin made on the page that nothing has taken yet: a shot, a recording, a voice clip. */
195
+ interface TrayItem {
196
+ /** The plugin that made it. */
197
+ plugin: string;
198
+ /** Its ID, as that plugin has it. */
199
+ id: string;
200
+ /** What that plugin says of it, as JSON: the screenshots plugin's `Shot`, a `Recording`, a `Clip`. */
201
+ value: unknown;
202
+ }
203
+ /**
204
+ * What plugins made on the page from the tool panel, until something takes it: a task attaches what's there and
205
+ * removes it. Kept for the tab's session, so it's there on the tab's next page too.
206
+ */
207
+ interface Tray {
208
+ /** What's kept, oldest first: all of it, or one plugin's. */
209
+ list: (plugin?: string) => TrayItem[];
210
+ add: (plugin: string, id: string, value: unknown) => void;
211
+ /** Takes one out, or all of a plugin's. */
212
+ remove: (plugin: string, id?: string) => void;
213
+ /** Hears every change from now on; answers what stops it. */
214
+ subscribe: (listener: () => void) => () => void;
215
+ }
126
216
  interface ClientContext {
127
217
  /** The dev server's base URL, ending in `/`. */
128
218
  base: string;
@@ -135,11 +225,24 @@ interface ClientContext {
135
225
  /** Asks one of this plugin's own routes, from the page: `request('shots', { method: 'POST', body: blob })`. */
136
226
  request: (route: string, init?: RequestInit) => Promise<Response>;
137
227
  /**
138
- * Opens the popup on an element at a plugin's tab, as its shortcut would: after a recording, say. An
139
- * element rendered again since stands in for one no longer on the page. False when there's no such tab
140
- * or no such element any more. Not from `setup`, which runs before the popup can open.
228
+ * Opens the popup on an element at a plugin's tab, as its shortcut would, or with `at` on a spot in it: the
229
+ * popup is then beside the spot, which is what's lit, and the tab's context has it. An element rendered again
230
+ * since stands in for one no longer on the page. False when there's no such tab or no such element any more, and
231
+ * while the open popup holds something unsaved, whose button then shakes. Not as `setup` runs, which is before the
232
+ * popup can open.
233
+ */
234
+ open: (plugin: string, element: Element, at?: Point) => boolean;
235
+ /** The tool panel, to add this plugin's tools to. */
236
+ tools: ToolPanel;
237
+ /** What was made from the tool panel and not taken yet. */
238
+ tray: Tray;
239
+ /** The drawer, to add this plugin's section to. */
240
+ drawer: Drawer;
241
+ /**
242
+ * Lights an element on the page as pointing at it does, for something of the overlay's own that stands for it (a
243
+ * task's row in the drawer, while the pointer is on it); none puts the light back as it was.
141
244
  */
142
- open: (plugin: string, element: Element) => boolean;
245
+ light: (element?: Element) => void;
143
246
  /**
144
247
  * Shows `items` in the lightbox over everything, at `at` (the first by default), stepping between them with
145
248
  * ← and →. With `from`, it grows out of that element (the chip clicked) and shrinks back into it on close.
@@ -187,12 +290,17 @@ interface PanelContext<Model, Op> extends ClientContext {
187
290
  * dependency's, or in an open shadow root, as the popup's own on a page that shows it (`popupIn`).
188
291
  */
189
292
  pointed?: Element;
293
+ /** The spot in `element` the popup was opened on, where it was (the tool panel's task tool), not the element as a whole. */
294
+ at?: Point;
190
295
  /** Every element on the page from the same place in the source, the clicked one among them: the rows of a list. */
191
296
  elements: Element[];
192
297
  target: Target;
193
298
  model: Model;
194
- /** Applies an op on disk, and reads the model again. Rejects with the server's reason, which the panel also shows. */
195
- apply(op: Op): Promise<Model>;
299
+ /**
300
+ * Applies an op on disk, and reads the model again. Rejects with the server's reason, which the panel also shows.
301
+ * On another element with `on`, whose model is then the one answered: for an op that's about that one.
302
+ */
303
+ apply(op: Op, on?: Target): Promise<Model>;
196
304
  close: () => void;
197
305
  /**
198
306
  * Says there's something here that leaving would lose (words typed, a change tried on the page), and the button
@@ -235,9 +343,14 @@ interface ClientPlugin<Model = unknown, Op = unknown, Api = unknown> {
235
343
  * done the popup opens at this tab with `resumed`, on the element where this page has it and without where not.
236
344
  */
237
345
  resume?(context: ClientContext): Promise<unknown> | undefined;
346
+ /**
347
+ * What it shows on the page while a shortcut's keys are held, and the page is dimmed to point on: the tasks
348
+ * plugin pins each task where its element is. Answers what takes it away.
349
+ */
350
+ pointing?(context: ClientContext): () => void;
238
351
  /** Draws into `panel`, inside deictic's shadow root. Returns what to undo on the page when the panel closes. */
239
352
  mount?: (panel: HTMLElement, context: PanelContext<Model, Op>) => (() => void) | void;
240
353
  }
241
354
  declare const defineClientPlugin: <Model, Op, Api = unknown>(plugin: ClientPlugin<Model, Op, Api>) => ClientPlugin<Model, Op, Api>;
242
- export { Modifier as C, definePlugin as S, Source as _, Done as a, TextEdit as b, LightboxOptions as c, Refusal as d, Resumed as f, ServerPlugin as g, ServerContext as h, ClientPlugin as i, Loc as l, ServerApis as m, ClientApis as n, LightboxAction as o, Route as p, ClientContext as r, LightboxItem as s, ApiOf as t, PanelContext as u, Standalone as v, Shortcut as w, defineClientPlugin as x, Target as y };
355
+ export { Shortcut as A, TextEdit as C, defineClientPlugin as D, TrayItem as E, definePlugin as O, Target as S, Tray as T, ServerContext as _, Done as a, Spot as b, LightboxItem as c, PanelContext as d, Point as f, ServerApis as g, Route as h, ClientPlugin as i, Modifier as k, LightboxOptions as l, Resumed as m, ClientApis as n, Drawer as o, Refusal as p, ClientContext as r, LightboxAction as s, ApiOf as t, Loc as u, ServerPlugin as v, ToolPanel as w, Standalone as x, Source as y };
243
356
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/shortcut.ts","../../src/index.ts"],"mappings":";;;;;;;;;;KAUY;UAEK;;EAEf,YAAY;;EAEZ;;;UCYe;EACf;EACA;EACA;;;UAIe;EACf,KAAK;EACL;;;UAIe;EACf;EACA;EACA;EACA;;;UAIe;;EAEf;EACA;;EAEA,SAAS;;EAET,SAAS;;EAET,KAAK;;;;;;;KAQK,cAAc,SAAS,YAAY,WAAW,QAAQ;;cAGrD,gBAAgB;EAClB;;;;;;UAOM,KAAK;EACpB,MAAM;;KAGH,MAAM,KAAK,IAAI,QAAQ;;;;;UAOX;;UAIA;;KAGL,MAAM,MAAM,uBAAuB,mBAAmB,OAAO,KAAK;UAE7D;;EAEf;;;;;EAKA,MAAM,qBAAqB,MAAM,SAAS,MAAM,YAAY;;;;;;KAOlD,SAAS,SAAS,SAAS,SAAS,kBAAkB,MAAM;UAEvD,aAAa,iBAAiB,cAAc,kBAAkB;;EAE7E;;EAEA;;EAEA;;EAEA,WAAW;;EAEX;;;;;EAKA;;EAEA,OAAO,SAAS,gBAAgB,MAAM;;EAEtC;KAAY,gBAAgB;;;EAE5B,MAAM,QAAQ,QAAQ,QAAQ,SAAS,MAAM;;EAE7C,OAAO,QAAQ,QAAQ,QAAQ,QAAQ,IAAI,KAAK,MAAM,aAAa,KAAK;;;;;EAKxE,MAAM,QAAQ,SAAS,aAAa;;EAEpC,MAAM,QAAQ,SAAS,MAAM;;EAE7B,UAAU,IAAI,IAAI,QAAQ;;cAGf,eAAgB,OAAO,IAAI,kBAAkB,eAAa,QAC7D,aAAa,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AAS,KAAK;;EAE9C,OAAO;;EAEP,MAAM;;EAEN,QAAQ;;;;;EAKR,QAAQ,UAAU;;;;;EAKlB,WAAW,OAAO,gBAAgB,UAAU;IAAsB;;;;KAIxD;;EAEV;;EAEA,UAAU;;EACL;EAAe;;EAAkB;EAAc;;EAAkB;EAAe;;UAEtE;EACf;EACA;EACA;;UAGe;;EAEf;;EAEA,OAAO;;UAGQ,aAAa,OAAO,YAAY;;;;;;EAM/C,SAAS;;;;;EAKT,UAAU;;EAEV,KAAK;;EAEL,UAAU;EACV,QAAQ;EACR,OAAO;;;;;EAKP,MAAM,IAAI,IAAI,KAAK,SAAS,QAAQ;EACpC;;;;;;EAMA,UAAU,QAAQ;;;;;;;;;EASlB,OAAO,GAAG,gBAAgB,YAAY,QAAQ;;EAE9C,UAAU;;;UAIK;EACf;EACA;;EAEA;;UAGe,aAAa,iBAAiB,cAAc;;EAE3D;;EAEA;;;;;EAKA,OAAO,SAAS,gBAAgB;;;;;;EAMhC,QAAQ,SAAS,gBAAgB;;;;;EAKjC,UAAU,SAAS;;EAEnB,SAAS,OAAO,aAAa,SAAS,aAAa,OAAO;;cAG/C,qBAAsB,OAAO,IAAI,eAAa,QAAU,aAAa,OAAO,IAAI,SAAO,aAAa,OAAO,IAAI"}
@@ -1,4 +1,3 @@
1
- import { w as Shortcut } from "./index.js";
2
1
  /** A point in page coordinates: CSS pixels from the document's top left, so it stays put as the page scrolls. */
3
2
  interface Point {
4
3
  x: number;
@@ -57,28 +56,21 @@ interface Annotations {
57
56
  */
58
57
  svg(area: Area): string | undefined;
59
58
  /**
60
- * Opens a picture (a screenshot, most often) over everything, with the toolbar, to draw on: answers the
61
- * marks, in the picture's CSS pixels, on Save, and nothing on Cancel, Esc or `signal`. It starts from
62
- * `marks`, to edit them again. They're the picture's alone, not the page's.
59
+ * Starts drawing on the page, as the tool panel's own tools do, with the one used last (the box, first): for
60
+ * another plugin's button. The page is the marks' until the tool panel gives it back (its pointer, or Esc).
61
+ */
62
+ draw(): void;
63
+ /**
64
+ * Opens `picture` over everything, to draw on with the same tools: the marks on Save, in the picture's CSS
65
+ * pixels, or nothing on Cancel, Esc or `signal`. Start it with `marks`, to change them. They're the picture's
66
+ * alone, not the page's.
63
67
  */
64
68
  edit(picture: Picture, marks?: readonly Annotation[], options?: {
65
69
  signal?: AbortSignal;
66
70
  }): Promise<Annotation[] | undefined>;
67
71
  /** The picture with the marks drawn over it, as a PNG at the picture's own resolution. */
68
72
  flatten(picture: Picture, marks: readonly Annotation[]): Promise<Blob>;
69
- /**
70
- * Annotate mode's tools, for another plugin's UI to show (a recording's toolbar): a pointer tool, picked
71
- * to start with, leaves the page usable; while a drawing tool is picked, the page is drawn on. What's
72
- * drawn is its own `marks`, not the page's: shown while it's open, kept by nothing, gone on `close`.
73
- */
74
- tools(): {
75
- element: HTMLElement;
76
- marks: MarkSet;
77
- close: () => void;
78
- };
79
73
  }
80
- /** A set of marks on the page: the page's own, kept for the session, or a toolbar's, kept by nothing. */
81
- type MarkSet = Pick<Annotations, 'list' | 'add' | 'remove' | 'clear' | 'subscribe' | 'svg'>;
82
74
  /** An image to draw on: where it loads from (the page's origin, so a canvas may read it), and its size in CSS pixels, which marks on it are in. */
83
75
  interface Picture {
84
76
  url: string;
@@ -91,11 +83,9 @@ declare module 'deictic' {
91
83
  }
92
84
  }
93
85
  interface AnnotationsOptions {
94
- /** What opens its tab directly, beside deictic's own shortcut, which opens any: none by default. */
95
- shortcut?: Shortcut;
96
86
  /** The colour marks are drawn in: a red that deictic's own green isn't. */
97
87
  color?: string;
98
88
  }
99
89
  declare function annotations(options?: AnnotationsOptions): import("deictic").ServerPlugin<unknown, unknown, unknown, unknown>;
100
- export { Area as a, Point as c, AnnotationsOptions as i, Shape as l, AnnotationEvent as n, MarkSet as o, Annotations as r, Picture as s, Annotation as t, annotations as u };
90
+ export { Area as a, Shape as c, AnnotationsOptions as i, annotations as l, AnnotationEvent as n, Picture as o, Annotations as r, Point as s, Annotation as t };
101
91
  //# sourceMappingURL=index2.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index2.d.ts","names":[],"sources":["../../src/plugins/annotations/index.ts"],"mappings":";;UAYiB;EACf;EACA;;;UAIe;EACf;EACA;EACA;EACA;;KAGU;EACL;IAAgB;EACjB;EAAe,MAAM;EAAO,IAAI;;EAChC;EAAa,QAAQ;;EACrB;EAAc,IAAI;EAAO;;UAEd;EACf;EACA;EACA,OAAO;;EAEP;;;KAIU;EAAoB;EAAa,YAAY;;EAAiB;EAAgB;;EAAiB;;;UAG1F;;EAEf,QAAQ;EACR,IAAI,OAAO,OAAO,iBAAiB;EACnC,OAAO;EACP;;EAEA,UAAU,WAAW,OAAO;;;;;EAK5B,IAAI,MAAM;;;;;;EAMV,KAAK,SAAS,SAAS,iBAAiB,cAAc;IAAY,SAAS;MAAgB,QAAQ;;EAEnG,QAAQ,SAAS,SAAS,gBAAgB,eAAe,QAAQ;;;;;;EAMjE;IAAW,SAAS;IAAa,OAAO;IAAS;;;;KAIvC,UAAU,KAAK;;UAGV;EACf;EACA;EACA;;;YAIU;IACR,aAAa;;;UAIA;;EAEf,WAAW;;EAEX;;iBAGc,YAAY,UAAS,uCAAuB"}
1
+ {"version":3,"file":"index2.d.ts","names":[],"sources":["../../src/plugins/annotations/index.ts"],"mappings":";UAYiB;EACf;EACA;;;UAIe;EACf;EACA;EACA;EACA;;KAGU;EACL;IAAgB;EACjB;EAAe,MAAM;EAAO,IAAI;;EAChC;EAAa,QAAQ;;EACrB;EAAc,IAAI;EAAO;;UAEd;EACf;EACA;EACA,OAAO;;EAEP;;;KAIU;EAAoB;EAAa,YAAY;;EAAiB;EAAgB;;EAAiB;;;UAG1F;;EAEf,QAAQ;EACR,IAAI,OAAO,OAAO,iBAAiB;EACnC,OAAO;EACP;;EAEA,UAAU,WAAW,OAAO;;;;;EAK5B,IAAI,MAAM;;;;;EAKV;;;;;;EAMA,KAAK,SAAS,SAAS,iBAAiB,cAAc;IAAY,SAAS;MAAgB,QAAQ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