deictic 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/API.md +71 -17
  2. package/README.md +1 -1
  3. package/dist/annotations/client.js +1 -1
  4. package/dist/cli.js +1 -1
  5. package/dist/cli.js.map +1 -1
  6. package/dist/client/index.d.ts +13 -13
  7. package/dist/client/index.d.ts.map +1 -1
  8. package/dist/client/index.js +11 -7
  9. package/dist/client/index.js.map +1 -1
  10. package/dist/react/client.d.ts +19 -0
  11. package/dist/react/client.d.ts.map +1 -0
  12. package/dist/react/client.js +504 -0
  13. package/dist/react/client.js.map +1 -0
  14. package/dist/react/index.d.ts +2 -0
  15. package/dist/react/index.js +1 -0
  16. package/dist/recommended/index.d.ts +15 -7
  17. package/dist/recommended/index.d.ts.map +1 -1
  18. package/dist/recommended/index.js +1 -1
  19. package/dist/recordings/client.d.ts.map +1 -1
  20. package/dist/recordings/client.js +48 -5
  21. package/dist/recordings/client.js.map +1 -1
  22. package/dist/screenshots/client.d.ts +9 -1
  23. package/dist/screenshots/client.d.ts.map +1 -1
  24. package/dist/screenshots/rrweb.d.ts +0 -6
  25. package/dist/screenshots/rrweb.d.ts.map +1 -1
  26. package/dist/screenshots/rrweb.js +46 -12
  27. package/dist/screenshots/rrweb.js.map +1 -1
  28. package/dist/shared/board.js +1 -1
  29. package/dist/shared/client.js +44 -2
  30. package/dist/shared/client.js.map +1 -1
  31. package/dist/shared/dom.js +7 -1
  32. package/dist/shared/dom.js.map +1 -1
  33. package/dist/shared/drawer.js +1 -1
  34. package/dist/shared/endpoints.js +1 -1
  35. package/dist/shared/index.d.ts +6 -0
  36. package/dist/shared/index.d.ts.map +1 -1
  37. package/dist/shared/index10.d.ts +70 -0
  38. package/dist/shared/index10.d.ts.map +1 -0
  39. package/dist/shared/index3.d.ts +11 -0
  40. package/dist/shared/index3.d.ts.map +1 -1
  41. package/dist/shared/index7.d.ts +92 -312
  42. package/dist/shared/index7.d.ts.map +1 -1
  43. package/dist/shared/index8.d.ts +324 -47
  44. package/dist/shared/index8.d.ts.map +1 -1
  45. package/dist/shared/index9.d.ts +45 -63
  46. package/dist/shared/index9.d.ts.map +1 -1
  47. package/dist/shared/init.js +15 -11
  48. package/dist/shared/init.js.map +1 -1
  49. package/dist/shared/marks.js +7 -1
  50. package/dist/shared/marks.js.map +1 -1
  51. package/dist/shared/package.js +3 -1
  52. package/dist/shared/packages.js +1 -1
  53. package/dist/shared/playwright.js +39 -1
  54. package/dist/shared/playwright.js.map +1 -1
  55. package/dist/shared/react.js +25 -0
  56. package/dist/shared/react.js.map +1 -0
  57. package/dist/shared/recommended.js +6 -3
  58. package/dist/shared/recommended.js.map +1 -1
  59. package/dist/shared/recording.js +80 -3
  60. package/dist/shared/recording.js.map +1 -1
  61. package/dist/shared/recordings.js +30 -2
  62. package/dist/shared/recordings.js.map +1 -1
  63. package/dist/shared/screenshots.js.map +1 -1
  64. package/dist/shared/src.js.map +1 -1
  65. package/dist/shared/task.js +1 -0
  66. package/dist/shared/task.js.map +1 -1
  67. package/dist/shared/tasks.js +11 -0
  68. package/dist/shared/tasks.js.map +1 -1
  69. package/dist/tailwind/client.d.ts +1 -1
  70. package/dist/tailwind/index.d.ts +1 -1
  71. package/dist/tasks/client.d.ts +1 -1
  72. package/dist/tasks/client.js +45 -19
  73. package/dist/tasks/client.js.map +1 -1
  74. package/dist/tasks/index.d.ts +1 -1
  75. package/dist/voice/client.d.ts +1 -1
  76. package/dist/voice/client.js +1 -1
  77. package/dist/voice/index.d.ts +1 -1
  78. package/package.json +25 -1
  79. package/src/cli/bun.ts +2 -2
  80. package/src/cli/init.ts +14 -9
  81. package/src/cli/recording.ts +90 -4
  82. package/src/cli/task.ts +4 -0
  83. package/src/cli.ts +13 -6
  84. package/src/client/dom.ts +14 -0
  85. package/src/client/index.ts +21 -14
  86. package/src/index.ts +6 -0
  87. package/src/plugins/react/client.ts +162 -0
  88. package/src/plugins/react/index.ts +130 -0
  89. package/src/plugins/react/renders.ts +219 -0
  90. package/src/plugins/react/serialize.ts +139 -0
  91. package/src/plugins/react/timeline.ts +143 -0
  92. package/src/plugins/recommended/index.ts +17 -5
  93. package/src/plugins/recordings/client.ts +64 -4
  94. package/src/plugins/recordings/marks.ts +7 -0
  95. package/src/plugins/recordings/replay.ts +30 -2
  96. package/src/plugins/screenshots/client.ts +42 -2
  97. package/src/plugins/screenshots/index.ts +11 -0
  98. package/src/plugins/screenshots/playwright.ts +65 -1
  99. package/src/plugins/screenshots/rrweb.ts +55 -28
  100. package/src/plugins/screenshots/states.ts +26 -0
  101. package/src/plugins/tasks/client.ts +41 -6
  102. package/src/plugins/tasks/composer.ts +24 -7
  103. package/src/plugins/tasks/index.ts +16 -2
@@ -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 * Something of deictic's that went wrong, which nothing a person did in the page caused: a package the project\n * hasn't installed, a plugin that failed. The dev server says it, and hands it to each plugin with a `problem`\n * (tasks posts it to the board, for an agent to fix).\n */\nexport interface Problem {\n /**\n * What tells it apart, and the same problem again from a new one: `packages:rrweb`, `setup:tailwind`. Never a\n * time or an ID, so a problem that comes back is known.\n */\n key: string;\n /**\n * `setup`: the project's to fix, as `message` says (install a package, configure a plugin). `bug`: deictic's own, or\n * a plugin's, to report where it's made, not to patch where it's installed.\n */\n kind: 'setup' | 'bug';\n /** What went wrong, and the fix where there is one, as any problem message says it. */\n message: string;\n /** What more there is to look into: a stack. */\n details?: string;\n /** The plugin it's about, where it's one's: none for deictic's own. */\n plugin?: string;\n}\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 (or its `setup` failed,\n * which is reported). One the plugin `needs` always is loaded; any other may not be, so check.\n */\n use: <Name extends string>(name: Name) => ApiOf<ServerApis, Name> | undefined;\n /** Says a problem of the plugin's own, as deictic says its own: in the dev server's output, and to each plugin's `problem`. */\n report: (problem: Problem) => void;\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 * Hears each problem deictic or a plugin reports, on the server or in the page, after every `setup` has run: once\n * per `key` while the dev server runs. Its own failure is only said, never reported again.\n */\n problem?(problem: Problem): Maybe<void>;\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 /** Says a problem of the plugin's own to the dev server, as the server half's `report` does: its `plugin` is this one. */\n report: (problem: Problem) => void;\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;AAgHA,MAAa,gBACX,WACyC;AA8N3C,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 * Something of deictic's that went wrong, which nothing a person did in the page caused: a package the project\n * hasn't installed, a plugin that failed. The dev server says it, and hands it to each plugin with a `problem`\n * (tasks posts it to the board, for an agent to fix).\n */\nexport interface Problem {\n /**\n * What tells it apart, and the same problem again from a new one: `packages:rrweb`, `setup:tailwind`. Never a\n * time or an ID, so a problem that comes back is known.\n */\n key: string;\n /**\n * `setup`: the project's to fix, as `message` says (install a package, configure a plugin). `bug`: deictic's own, or\n * a plugin's, to report where it's made, not to patch where it's installed.\n */\n kind: 'setup' | 'bug';\n /** What went wrong, and the fix where there is one, as any problem message says it. */\n message: string;\n /** What more there is to look into: a stack. */\n details?: string;\n /** The plugin it's about, where it's one's: none for deictic's own. */\n plugin?: string;\n}\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 (or its `setup` failed,\n * which is reported). One the plugin `needs` always is loaded; any other may not be, so check.\n */\n use: <Name extends string>(name: Name) => ApiOf<ServerApis, Name> | undefined;\n /** Says a problem of the plugin's own, as deictic says its own: in the dev server's output, and to each plugin's `problem`. */\n report: (problem: Problem) => void;\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 * Hears each problem deictic or a plugin reports, on the server or in the page, after every `setup` has run: once\n * per `key` while the dev server runs. Its own failure is only said, never reported again.\n */\n problem?(problem: Problem): Maybe<void>;\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 /** Says a problem of the plugin's own to the dev server, as the server half's `report` does: its `plugin` is this one. */\n report: (problem: Problem) => void;\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 /**\n * A shortcut's press on a marked element, before the page hears it and before the popup opens: the page as the\n * person saw it, a tooltip still open under the pointer, a menu still focused. Called as the press goes down, so\n * it must be quick; the screenshots plugin keeps what a shot needs here, and renders it later.\n */\n pressed?(context: ClientContext, element: Element): 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;AAgHA,MAAa,gBACX,WACyC;AAoO3C,MAAa,sBAAgD,WAAuE"}
@@ -137,6 +137,7 @@ function attachments(message, out, indent, task) {
137
137
  console.log(`${indent}${a.name} (${kb}), a voice clip${saved}`);
138
138
  if (task === void 0) console.log(`${indent} ${ME} voice ${/^voice-(.+)\.\w+$/.exec(a.name)?.[1] ?? a.id} (speech)`);
139
139
  } else if (a.name === "element.html") console.log(`${indent}${a.name} (${kb}), the element's HTML as it rendered, if you need it${saved}`);
140
+ else if (/^react(\.\d+)?\.json$/.test(a.name)) console.log(`${indent}${a.name} (${kb}), the props, state and hooks of the components that wrote it, as React's DevTools has them, if the change depends on them${saved}`);
140
141
  else console.log(`${indent}${a.name} (${kb})${saved}`);
141
142
  }
142
143
  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)`);
@@ -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, 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 [\n 'deictic.count',\n (v) => {\n if (v === '1') return undefined;\n const nth = label('deictic.nth');\n const text = label('deictic.text');\n const which = nth === undefined ? '' : `: it's number ${nth}${text === undefined ? '' : `, saying \"${text}\"`}`;\n return `${v} elements on the page come from that line${which}`;\n },\n ],\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 const problem = label('deictic.problem.kind');\n if (problem !== undefined) {\n const plugin = label('deictic.problem.plugin');\n console.log(\n `A problem deictic ${label('deictic.version') ?? ''} reported${plugin === undefined ? '' : ` in its ${plugin} plugin`}, not a person's ask`,\n );\n } else 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 }\n for (const line of drawn(root)) console.log(line);\n // A task added before these were labels says them after its words; a problem, its details.\n const told = (pointed ? where.slice(0, pointed.index) : where).trim();\n if (told !== '') console.log(problem === undefined ? told : `Details:\\n${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,MA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K,WAAW,QAAQ,CAAC,GACnF,QAAQ,IAAI,GAAG,SAAS,GAAG,SAAS,KAAK,2BAA2B,GAAG,cAAc,KAAK,aAAa;AAC3G;;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 [\n 'deictic.count',\n (v) => {\n if (v === '1') return undefined;\n const nth = label('deictic.nth');\n const text = label('deictic.text');\n const which = nth === undefined ? '' : `: it's number ${nth}${text === undefined ? '' : `, saying \"${text}\"`}`;\n return `${v} elements on the page come from that line${which}`;\n },\n ],\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 const problem = label('deictic.problem.kind');\n if (problem !== undefined) {\n const plugin = label('deictic.problem.plugin');\n console.log(\n `A problem deictic ${label('deictic.version') ?? ''} reported${plugin === undefined ? '' : ` in its ${plugin} plugin`}, not a person's ask`,\n );\n } else 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 }\n for (const line of drawn(root)) console.log(line);\n // A task added before these were labels says them after its words; a problem, its details.\n const told = (pointed ? where.slice(0, pointed.index) : where).trim();\n if (told !== '') console.log(problem === undefined ? told : `Details:\\n${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 if (/^react(\\.\\d+)?\\.json$/.test(a.name)) {\n console.log(\n `${indent}${a.name} (${kb}), the props, state and hooks of the components that wrote it, as React's DevTools has them, if the change depends on them${saved}`,\n );\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,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,4HAA4H,OACxJ;OAEA,QAAQ,IAAI,GAAG,SAAS,EAAE,KAAK,IAAI,GAAG,GAAG,OAAO;CAEpD;CACA,IAAI,SAAS,KAAA,KAAa,QAAQ,YAAY,MAAM,MAAM,EAAE,KAAK,WAAW,QAAQ,CAAC,GACnF,QAAQ,IAAI,GAAG,SAAS,GAAG,SAAS,KAAK,2BAA2B,GAAG,cAAc,KAAK,aAAa;AAC3G;;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"}
@@ -283,7 +283,16 @@ function tasks(options = {}) {
283
283
  name: "pointed.html",
284
284
  type: "text/html"
285
285
  });
286
+ const json = (of, name) => {
287
+ if (typeof of === "string" && of !== "") files.push({
288
+ data: new TextEncoder().encode(of.slice(0, REACT)),
289
+ name,
290
+ type: "application/json"
291
+ });
292
+ };
293
+ json(op.react, "react.json");
286
294
  for (const [i, other] of (op.also ?? []).entries()) {
295
+ json(other.react, `react.${i + 2}.json`);
287
296
  if (typeof other.html !== "string" || other.html === "") continue;
288
297
  files.push({
289
298
  data: new TextEncoder().encode(other.html.slice(0, HTML)),
@@ -582,6 +591,8 @@ const boxOf = ({ x, y, width, height }) => [
582
591
  ].map(Math.round);
583
592
  /** What `element.html` holds of an element at most, in characters: a table's rows, not a whole page. */
584
593
  const HTML = 1e5;
594
+ /** What `react.json` holds at most, in characters: the page half cuts it to less. */
595
+ const REACT = 25e4;
585
596
  /** A label's value: a board holds 256 characters. */
586
597
  const LABEL = 256;
587
598
  /** The project's name: the `name` in the root's `package.json`, or nothing where it has none. */