deictic 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API.md +26 -17
- package/README.md +6 -26
- package/dist/annotations/client.d.ts +1 -1
- package/dist/annotations/client.js +1 -1
- package/dist/annotations/index.d.ts +2 -101
- package/dist/annotations/index.js +1 -22
- package/dist/astro.d.ts +1 -1
- package/dist/astro.js +1 -1
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +37 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.js +1 -10
- package/dist/logs/client.d.ts +1 -1
- package/dist/logs/client.js +1 -1
- package/dist/logs/index.d.ts +2 -18
- package/dist/logs/index.js +1 -21
- package/dist/network/client.d.ts +1 -1
- package/dist/network/client.js +1 -1
- package/dist/network/index.d.ts +1 -1
- package/dist/network/index.js +1 -37
- package/dist/recommended/index.d.ts +7 -7
- package/dist/recommended/index.js +1 -26
- package/dist/recordings/client.d.ts +1 -1
- package/dist/recordings/client.js +1 -1
- package/dist/recordings/index.d.ts +1 -1
- package/dist/screenshots/client.d.ts +1 -1
- package/dist/screenshots/client.js +1 -108
- package/dist/screenshots/dom.d.ts +1 -1
- package/dist/screenshots/dom.js +1 -1
- package/dist/screenshots/index.d.ts +1 -1
- package/dist/screenshots/index.js +1 -103
- package/dist/screenshots/rrweb.d.ts +1 -1
- package/dist/screenshots/rrweb.js +1 -1
- package/dist/shared/annotations.js +22 -0
- package/dist/shared/annotations.js.map +1 -0
- package/dist/shared/board.js +190 -0
- package/dist/shared/board.js.map +1 -0
- package/dist/shared/client.js +108 -0
- package/dist/shared/endpoints.js +4 -1
- package/dist/shared/endpoints.js.map +1 -1
- package/dist/shared/find.js +156 -0
- package/dist/shared/find.js.map +1 -0
- package/dist/shared/frame.js +75 -0
- package/dist/shared/frame.js.map +1 -0
- package/dist/shared/index.d.ts +5 -0
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index2.d.ts +85 -88
- package/dist/shared/index2.d.ts.map +1 -1
- package/dist/shared/index3.d.ts +83 -89
- package/dist/shared/index3.d.ts.map +1 -1
- package/dist/shared/index4.d.ts +98 -50
- package/dist/shared/index4.d.ts.map +1 -1
- package/dist/shared/index5.d.ts +13 -219
- package/dist/shared/index5.d.ts.map +1 -1
- package/dist/shared/index6.d.ts +55 -61
- package/dist/shared/index6.d.ts.map +1 -1
- package/dist/shared/index7.d.ts +224 -0
- package/dist/shared/index7.d.ts.map +1 -0
- package/dist/shared/index8.d.ts +52 -0
- package/dist/shared/index8.d.ts.map +1 -0
- package/dist/shared/index9.d.ts +70 -0
- package/dist/shared/index9.d.ts.map +1 -0
- package/dist/shared/init.js +472 -0
- package/dist/shared/init.js.map +1 -0
- package/dist/shared/local.js +165 -0
- package/dist/shared/local.js.map +1 -0
- package/dist/shared/logs.js +22 -0
- package/dist/shared/logs.js.map +1 -0
- package/dist/shared/network.js +39 -0
- package/dist/shared/network.js.map +1 -0
- package/dist/shared/packages.js +125 -0
- package/dist/shared/packages.js.map +1 -0
- package/dist/shared/recommended.js +26 -0
- package/dist/shared/recommended.js.map +1 -0
- package/dist/shared/recording.js +316 -0
- package/dist/shared/recording.js.map +1 -0
- package/dist/shared/recordings.js +2 -1
- package/dist/shared/recordings.js.map +1 -1
- package/dist/shared/screenshots.js +108 -0
- package/dist/shared/screenshots.js.map +1 -0
- package/dist/shared/src.js +10 -0
- package/dist/shared/src.js.map +1 -0
- package/dist/shared/task.js +108 -0
- package/dist/shared/task.js.map +1 -0
- package/dist/shared/tasks.js +7 -180
- package/dist/shared/tasks.js.map +1 -1
- package/dist/shared/transcribe.js +128 -0
- package/dist/shared/transcribe.js.map +1 -0
- package/dist/shared/vb.js +13 -0
- package/dist/shared/vb.js.map +1 -0
- package/dist/shared/vite.d.ts +16 -0
- package/dist/shared/vite.d.ts.map +1 -0
- package/dist/shared/vite.js +61 -0
- package/dist/shared/vite.js.map +1 -0
- package/dist/shared/voice.js +84 -0
- package/dist/{voice/index.js.map → shared/voice.js.map} +1 -1
- package/dist/shared/voice2.js +90 -0
- package/dist/shared/voice2.js.map +1 -0
- package/dist/shared/watch.js +209 -0
- package/dist/shared/watch.js.map +1 -0
- package/dist/shared/watchers.js +62 -0
- package/dist/shared/watchers.js.map +1 -0
- package/dist/tailwind/client.d.ts +1 -1
- package/dist/tailwind/client.js +1 -1
- package/dist/tailwind/index.d.ts +1 -1
- package/dist/tailwind/index.js +1 -1
- package/dist/tasks/client.d.ts +1 -1
- package/dist/tasks/client.js +1 -1
- package/dist/tasks/index.d.ts +1 -1
- package/dist/tasks/index.js +3 -1
- package/dist/vite.d.ts +2 -15
- package/dist/vite.js +2 -60
- package/dist/voice/client.d.ts +1 -1
- package/dist/voice/client.js +1 -1
- package/dist/voice/index.d.ts +2 -52
- package/dist/voice/index.js +1 -84
- package/package.json +6 -9
- package/skills/deictic/SKILL.md +27 -42
- package/skills/deictic/references/recordings.md +9 -108
- package/skills/deictic/references/tasks.md +21 -112
- package/skills/deictic/references/watch.md +13 -68
- package/src/cli/board.ts +204 -0
- package/src/cli/bun.ts +133 -0
- package/src/cli/edit.ts +56 -0
- package/src/cli/find.ts +147 -0
- package/src/cli/frame.ts +90 -0
- package/src/cli/init.ts +388 -0
- package/src/cli/recording.ts +383 -0
- package/src/cli/task.ts +126 -0
- package/src/cli/transcribe.ts +129 -0
- package/src/cli/vb.ts +11 -0
- package/src/cli/voice.ts +59 -0
- package/src/cli/watch.ts +221 -0
- package/src/cli.ts +37 -0
- package/src/index.ts +5 -0
- package/src/plugins/logs/index.ts +1 -0
- package/src/plugins/network/index.ts +1 -0
- package/src/plugins/recordings/index.ts +1 -0
- package/src/plugins/screenshots/index.ts +5 -1
- package/src/plugins/tasks/index.ts +3 -2
- package/src/plugins/tasks/local.ts +19 -6
- package/src/plugins/tasks/watchers.ts +41 -6
- package/src/tools/endpoints.ts +3 -0
- package/src/tools/packages.ts +107 -0
- package/dist/annotations/index.d.ts.map +0 -1
- package/dist/annotations/index.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/logs/index.d.ts.map +0 -1
- package/dist/logs/index.js.map +0 -1
- package/dist/network/index.js.map +0 -1
- package/dist/recommended/index.js.map +0 -1
- package/dist/screenshots/index.js.map +0 -1
- package/dist/vite.d.ts.map +0 -1
- package/dist/vite.js.map +0 -1
- package/dist/voice/index.d.ts.map +0 -1
- package/skills/deictic/references/install.md +0 -103
- package/skills/deictic/scripts/frame.mjs +0 -62
- package/skills/deictic/scripts/lib.mjs +0 -283
- package/skills/deictic/scripts/recording.mjs +0 -266
- package/skills/deictic/scripts/task.mjs +0 -120
- package/skills/deictic/scripts/transcribe.mjs +0 -93
- package/skills/deictic/scripts/vb.mjs +0 -12
- package/skills/deictic/scripts/voice.mjs +0 -50
- package/skills/deictic/scripts/watch.mjs +0 -152
- /package/dist/{screenshots → shared}/client.js.map +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/plugins/annotations/index.ts"],"mappings":";;;;;;;;;;;iBAYiB;EACf;EACA;;;iBAIe;EACf;EACA;EACA;EACA;;YAGU;EACL;IAAgB;EACjB;EAAe,MAAM;EAAO,IAAI;;EAChC;EAAa,QAAQ;;EACrB;EAAc,IAAI;EAAO;;iBAEd;EACf;EACA;EACA,OAAO;;EAEP;;;YAIU;EAAoB;EAAa,YAAY;;EAAiB;EAAgB;;EAAiB;;;iBAG1F;;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;;;;YAIvC,UAAU,KAAK;;iBAGV;EACf;EACA;EACA;;;YAIU;IACR,aAAa;;;iBAIA;;EAEf,WAAW;;EAEX;;wBAGc,YAAY,UAAS,uCAAuB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/plugins/annotations/index.ts"],"sourcesContent":["/**\n * `deictic/annotations`: mark up the page itself. Its tab is annotate\n * mode over the page: boxes, arrows, a pen and notes, drawn where the page is, so they stay with\n * it as it scrolls. They're kept for the tab's session, per page, until cleared.\n *\n * They're data other plugins build on, through `use('annotations')` in the page: screenshots draw them\n * over the page (`svg(area)`), tasks repeat their notes, and a recording can keep each change as it\n * happens (`subscribe`). Nothing of it runs on the server.\n */\nimport { definePlugin, type Shortcut } from '#src/index.ts';\n\n/** A point in page coordinates: CSS pixels from the document's top left, so it stays put as the page scrolls. */\nexport interface Point {\n x: number;\n y: number;\n}\n\n/** A rectangle: in page coordinates for a shape, in viewport coordinates for an area to draw. */\nexport interface Area {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport type Shape =\n | ({ kind: 'box' } & Area)\n | { kind: 'arrow'; from: Point; to: Point }\n | { kind: 'pen'; points: Point[] }\n | { kind: 'note'; at: Point; text: string };\n\nexport interface Annotation {\n id: string;\n color: string;\n shape: Shape;\n /** When it was made, as `Date.now()`. */\n at: number;\n}\n\n/** A change, as `subscribe` hears it: what a recording keeps, to show the marks as they were made. */\nexport type AnnotationEvent = { type: 'add'; annotation: Annotation } | { type: 'remove'; id: string } | { type: 'clear' };\n\n/** The page's half, for other plugins' page halves. */\nexport interface Annotations {\n /** Every annotation on this page, oldest first. */\n list(): Annotation[];\n add(shape: Shape, color?: string): Annotation;\n remove(id: string): void;\n clear(): void;\n /** Hears every change from now on; answers what stops it. */\n subscribe(listener: (event: AnnotationEvent) => void): () => void;\n /**\n * The annotations over a part of the viewport, in viewport CSS pixels, as an SVG that size: what a\n * screenshot of that area draws over it. Nothing when there are none.\n */\n svg(area: Area): string | undefined;\n /**\n * Opens a picture (a screenshot, most often) over everything, with the toolbar, to draw on: answers the\n * marks, in the picture's CSS pixels, on Save, and nothing on Cancel, Esc or `signal`. It starts from\n * `marks`, to edit them again. They're the picture's alone, not the page's.\n */\n edit(picture: Picture, marks?: readonly Annotation[], options?: { signal?: AbortSignal }): Promise<Annotation[] | undefined>;\n /** The picture with the marks drawn over it, as a PNG at the picture's own resolution. */\n flatten(picture: Picture, marks: readonly Annotation[]): Promise<Blob>;\n /**\n * Annotate mode's tools, for another plugin's UI to show (a recording's toolbar): a pointer tool, picked\n * to start with, leaves the page usable; while a drawing tool is picked, the page is drawn on. What's\n * drawn is its own `marks`, not the page's: shown while it's open, kept by nothing, gone on `close`.\n */\n tools(): { element: HTMLElement; marks: MarkSet; close: () => void };\n}\n\n/** A set of marks on the page: the page's own, kept for the session, or a toolbar's, kept by nothing. */\nexport type MarkSet = Pick<Annotations, 'list' | 'add' | 'remove' | 'clear' | 'subscribe' | 'svg'>;\n\n/** 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. */\nexport interface Picture {\n url: string;\n width: number;\n height: number;\n}\n\ndeclare module 'deictic' {\n interface ClientApis {\n annotations: Annotations;\n }\n}\n\nexport interface AnnotationsOptions {\n /** What opens its tab directly, beside deictic's own shortcut, which opens any: none by default. */\n shortcut?: Shortcut;\n /** The colour marks are drawn in: a red that deictic's own green isn't. */\n color?: string;\n}\n\nexport function annotations(options: AnnotationsOptions = {}) {\n return definePlugin({\n name: 'annotations',\n client: 'deictic/annotations/client',\n shortcut: options.shortcut,\n clientOptions: { color: options.color ?? '#ef4444' },\n });\n}\n\nexport default annotations;\n"],"mappings":";;;;;;;;;;;AA+FA,SAAgB,YAAY,UAA8B,CAAC,GAAG;CAC5D,OAAO,aAAa;EAClB,MAAM;EACN,QAAQ;EACR,UAAU,QAAQ;EAClB,eAAe,EAAE,OAAO,QAAQ,SAAS,UAAU;CACrD,CAAC;AACH"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * `deictic`: what a plugin is. Every plugin is optional: deictic itself is the glue (the\n * transform that ties elements to source, the dev server's endpoints, the history, shortcuts and the\n * overlay's panel), and each plugin adds what it does on top.\n *\n * A plugin has two halves, each optional that meet over the dev server's endpoints (`tools/endpoints.ts`). The\n * server half runs beside the bundler and is the only one that reads source: it turns the element\n * under the pointer into a model its panel can show, and an op from that panel into text edits. It\n * never writes files; deictic does, so every plugin's changes land in one history and undo the\n * same way. A change that isn't to a file (a task added to a board) the plugin makes itself and\n * answers with what it did (`Done`): the history keeps that beside the files' changes and hands it\n * back to the plugin's own `undo` and `redo`.\n * The client half is a module the page loads, named by the server half's `client`, which draws the\n * panel and previews an op on the page before it is applied.\n *\n * A plugin may have no panel at all, only an API for others (screenshots, a recording) and routes of\n * its own on the dev server. Each half's `setup` answers its API, and `use(name)` reaches another\n * plugin's, on the same side; `needs` names the plugins it can't do without.\n *\n * Both halves import from here, so the parser is imported for its types only: the browser must not load it.\n */\nimport type { JSXOpeningElement, Program } from 'oxc-parser';\n\nimport type { Shortcut } from './shortcut.ts';\n\nexport type { Modifier, Shortcut } from './shortcut.ts';\n\n/** A place in the source: the file from the project's root, with `/`, and the line and column, from 1. */\nexport interface Loc {\n file: string;\n line: number;\n column: number;\n}\n\n/** An element the pointer picked: where its opening tag starts, and the tag, which the server checks is still there. */\nexport interface Target {\n loc: Loc;\n tag: string;\n}\n\n/** Text in a file to replace, by UTF-16 offsets. `file` is the target's unless named, from the project's root. */\nexport interface TextEdit {\n file?: string;\n start: number;\n end: number;\n text: string;\n}\n\n/** What a server half reads: the target's file, parsed, and its element. */\nexport interface Source {\n /** The target's file, from the project's root. */\n file: string;\n code: string;\n /** The file's module; for an `.astro` component, its frontmatter's. */\n program: Program;\n /** The target's opening tag. */\n element: JSXOpeningElement;\n /** Another file under the project's root, for plugins whose edits go elsewhere (a locale's messages). */\n read(file: string): string;\n}\n\n/**\n * What answers the overlay's requests in a page with no dev server behind it (`deictic/vite`'s `standalone`): the\n * default export of a module of the page's. A request is one the endpoints would get, under `<base>__deictic/`;\n * the answer is theirs too (`{ model }`, `{ model, change }`, `{ problem }` with a status that isn't ok).\n */\nexport type Standalone = (request: Request) => Response | Promise<Response>;\n\n/** An op a plugin won't make. The message says why and what to do instead; the panel shows it. */\nexport class Refusal extends Error {\n override name = 'Refusal';\n}\n\n/**\n * A change the plugin made itself, not to a file: what its `undo` and `redo` need to take it back and\n * make it again. JSON, since the history keeps it on disk across restarts of the dev server.\n */\nexport interface Done<Record = unknown> {\n done: Record;\n}\n\ntype Maybe<T> = T | Promise<T>;\n\n/**\n * Each plugin's API to the others on the server, by name. A plugin adds its own, so `use` knows its type:\n * `declare module 'deictic' { interface ServerApis { screenshots: Screenshots } }`.\n */\n// oxlint-disable-next-line typescript/no-empty-interface -- filled by declaration merging\nexport interface ServerApis {}\n\n/** The same, in the page: `declare module 'deictic' { interface ClientApis { screenshots: Capture } }`. */\n// oxlint-disable-next-line typescript/no-empty-interface -- filled by declaration merging\nexport interface ClientApis {}\n\n/** A plugin's API, by its name: what its package declared, or `unknown` for one that declared none. */\nexport type ApiOf<Apis, Name extends string> = Name extends keyof Apis ? Apis[Name] : unknown;\n\nexport interface ServerContext {\n /** The project's root, as an absolute path. */\n root: string;\n /**\n * Another plugin's API, as its `setup` answered it, or nothing when it isn't loaded. One the plugin\n * `needs` always is; any other may not be, so check.\n */\n use: <Name extends string>(name: Name) => ApiOf<ServerApis, Name> | undefined;\n}\n\n/**\n * A route of the plugin's own, at `/__deictic/plugins/<name>/<route>`, and below it. A `GET` must\n * change nothing: anything else reaches it only from the page itself, which deictic checks.\n */\nexport type Route = (request: Request, context: ServerContext) => Maybe<Response>;\n\nexport interface ServerPlugin<Model = unknown, Op = unknown, Record = unknown, Api = unknown> {\n /** Ties the halves together; also the label of its changes in the history, and its routes' path. Lowercase, with `-`. */\n name: string;\n /** The module the page loads for this plugin's half there, which default-exports its `ClientPlugin`. */\n client?: string;\n /** What the page half gets as `context.options`: the user's options it needs there, as JSON. */\n clientOptions?: unknown;\n /** What opens its panel: its own default, which its options let the user change. A plugin with no panel has none. */\n shortcut?: Shortcut;\n /** The plugins it can't do without, by name: the dev server won't start without them. */\n needs?: string[];\n /** Runs once, as the dev server starts and before it answers anything. Answers the plugin's API to the others. */\n setup?(context: ServerContext): Maybe<Api>;\n /** Routes of its own, by their first segment under `/__deictic/plugins/<name>/`. */\n routes?: { [route: string]: Route };\n /** The model its panel shows for an element. Without it, the panel gets none. */\n read?(source: Source, target: Target): Maybe<Model>;\n /** Text edits for deictic to write, or a change the plugin made itself. */\n apply?(source: Source, target: Target, op: Op): Maybe<TextEdit[] | Done<Record>>;\n /**\n * Takes back a change `apply` made itself, or throws a `Refusal` saying why it can't any more. It may\n * answer what the next redo needs, where that differs (what it put back has a new ID).\n */\n undo?(record: Record): Maybe<void | Record>;\n /** Makes it again after an undo, and answers what the next undo needs, which may differ (a new ID). */\n redo?(record: Record): Maybe<Record>;\n /** Says what an op does, for the history: `className: px-2 → px-4`. */\n describe?(op: Op, before: Model): string;\n}\n\nexport const definePlugin = <Model, Op, Record = unknown, Api = unknown>(\n plugin: ServerPlugin<Model, Op, Record, Api>,\n): ServerPlugin<Model, Op, Record, Api> => plugin;\n\nexport interface ClientContext {\n /** The dev server's base URL, ending in `/`. */\n base: string;\n /** deictic's shadow root, to draw in: neither the page's styles nor the overlay's cross over. */\n root: ShadowRoot;\n /** The server half's `clientOptions`, or nothing. */\n options: unknown;\n /** Another plugin's API in the page, as its `setup` answered it, or nothing when it isn't loaded. */\n use: <Name extends string>(name: Name) => ApiOf<ClientApis, Name> | undefined;\n /** Asks one of this plugin's own routes, from the page: `request('shots', { method: 'POST', body: blob })`. */\n request: (route: string, init?: RequestInit) => Promise<Response>;\n /**\n * Opens the popup on an element at a plugin's tab, as its shortcut would: after a recording, say. An\n * element rendered again since stands in for one no longer on the page. False when there's no such tab\n * or no such element any more. Not from `setup`, which runs before the popup can open.\n */\n open: (plugin: string, element: Element) => boolean;\n /**\n * Shows `items` in the lightbox over everything, at `at` (the first by default), stepping between them with\n * ← and →. With `from`, it grows out of that element (the chip clicked) and shrinks back into it on close.\n */\n lightbox: (items: LightboxItem[], options?: LightboxOptions) => { close: () => void };\n}\n\n/** What the lightbox shows: a picture, a page in a frame (a recording's replay), or a sound with its waveform. */\nexport type LightboxItem = {\n /** Its name, over it. */\n title: string;\n /** Buttons beside the name: each closes the lightbox and runs. */\n actions?: LightboxAction[];\n} & ({ kind: 'image'; url: string } | { kind: 'page'; url: string } | { kind: 'audio'; url: string });\n\nexport interface LightboxAction {\n label: string;\n title?: string;\n run: () => void;\n}\n\nexport interface LightboxOptions {\n /** The item it opens at. */\n at?: number;\n /** The element it grows out of, and goes back into. */\n from?: Element;\n}\n\nexport interface PanelContext<Model, Op> extends ClientContext {\n /**\n * The element clicked: the one the source marked, under the pointer or around what is. Back from `away`\n * it may be off the page (`isConnected` is false), where the page moved on without it: the element as it\n * was left, or after a page load an empty one of its tag and mark. `elements` is then empty.\n */\n element: Element;\n /**\n * What was under the pointer, where it isn't `element` but inside it: markup nothing marked, as a\n * dependency's, or in an open shadow root, as the popup's own on a page that shows it (`popupIn`).\n */\n pointed?: Element;\n /** Every element on the page from the same place in the source, the clicked one among them: the rows of a list. */\n elements: Element[];\n target: Target;\n model: Model;\n /** Applies an op on disk, and reads the model again. Rejects with the server's reason, which the panel also shows. */\n apply(op: Op): Promise<Model>;\n close: () => void;\n /**\n * Says there's something here that leaving would lose (words typed, a change tried on the page), and the button\n * that keeps it: a click outside the popup then shakes that button, where it would have closed the popup.\n * `undefined` once there's nothing to lose. Forgotten as the panel unmounts.\n */\n unsaved: (action: HTMLElement | undefined) => void;\n /**\n * Leaves the popup to do something on the page, then comes back: closes it, runs `task` (a recording, a\n * pick of another element), and opens it again at this tab on this element. The next mount gets\n * `resumed`: the `state` kept now (what was typed, what's attached), and what `task` answered, or why\n * it failed. The state stays in the page, as it is: no need for JSON. It's also kept for the tab's next\n * page, as a structured clone, where it can be one: after a page load, the plugin's `resume` says whether\n * the task carries on, and the popup comes back there.\n */\n away: <T>(state: unknown, task: () => Promise<T>) => void;\n /** Set when this mount is the panel coming back from `away`. */\n resumed?: Resumed;\n}\n\n/** What a panel coming back from `away` gets: the state it kept, and the task's result or problem. */\nexport interface Resumed {\n state: unknown;\n result?: unknown;\n /** Why the task failed: its error's message. */\n problem?: string;\n}\n\nexport interface ClientPlugin<Model = unknown, Op = unknown, Api = unknown> {\n /** The server half's `name`. */\n name: string;\n /** Shown over the element while its shortcut's keys are held, and atop the panel. */\n label?: string;\n /**\n * Runs once, as the page starts, before any panel opens (a recording starts here). Answers the\n * plugin's API to the others in the page, at once: one that needs time keeps its promises inside it.\n */\n setup?(context: ClientContext): Api;\n /**\n * Asked as a page starts where the page before it left this plugin's panel `away`: the task it left for,\n * where that carries on in this page (a recording does), or nothing where it ended with the page. When it's\n * done the popup opens at this tab with `resumed`, on the element where this page has it and without where not.\n */\n resume?(context: ClientContext): Promise<unknown> | undefined;\n /** Draws into `panel`, inside deictic's shadow root. Returns what to undo on the page when the panel closes. */\n mount?: (panel: HTMLElement, context: PanelContext<Model, Op>) => (() => void) | void;\n}\n\nexport const defineClientPlugin = <Model, Op, Api = unknown>(plugin: ClientPlugin<Model, Op, Api>): ClientPlugin<Model, Op, Api> => plugin;\n"],"mappings":";;AAqEA,IAAa,UAAb,cAA6B,MAAM;CACxB,OAAO;AAClB;AAwEA,MAAa,gBACX,WACyC;AAiH3C,MAAa,sBAAgD,WAAuE"}
|
package/dist/logs/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/plugins/logs/index.ts"],"mappings":";;YAaY;iBAmBK;;;;;EAKf,SAAS;;;YAIC;IACR,MAAM;;;wBAIM,KAAK,UAAS,gCAAgB"}
|
package/dist/logs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/plugins/logs/index.ts"],"sourcesContent":["/**\n * `deictic/logs`: what the page logs while it's recorded, and the errors nothing caught, in the recording, each at\n * its moment. No tab, and nothing of its own: it hands the recordings plugin rrweb's console plugin\n * (`@rrweb/rrweb-plugin-console-record`, an optional peer), whose events are rrweb's (`rrweb/console@1`).\n *\n * A wrapped console names the wrapper, not the caller, as each line's source in the browser's tools. rrweb wraps it\n * as a recording starts and puts it back as it stops, so it's the page's own the rest of the time. Leave the plugin\n * out and it never is.\n */\nimport { definePlugin } from '#src/index.ts';\nimport type { Recorded } from '#src/plugins/recordings/index.ts';\n\n/** What of the console is kept: its methods, by name. */\nexport type Level =\n | 'assert'\n | 'count'\n | 'countReset'\n | 'debug'\n | 'dir'\n | 'dirxml'\n | 'error'\n | 'group'\n | 'groupCollapsed'\n | 'info'\n | 'log'\n | 'table'\n | 'time'\n | 'timeEnd'\n | 'timeLog'\n | 'trace'\n | 'warn';\n\nexport interface LogsOptions {\n /**\n * The console's methods kept, `['warn', 'error']` for the least: every one that says something by default. Errors\n * nothing caught, and rejections nothing handled, come with `error`.\n */\n levels?: Level[];\n}\n\ndeclare module 'deictic' {\n interface ClientApis {\n logs: Recorded;\n }\n}\n\nexport function logs(options: LogsOptions = {}) {\n return definePlugin<never, never>({\n name: 'logs',\n client: 'deictic/logs/client',\n clientOptions: { levels: options.levels },\n });\n}\n\nexport default logs;\n"],"mappings":";;;;;;;;;;;AA8CA,SAAgB,KAAK,UAAuB,CAAC,GAAG;CAC9C,OAAO,aAA2B;EAChC,MAAM;EACN,QAAQ;EACR,eAAe,EAAE,QAAQ,QAAQ,OAAO;CAC1C,CAAC;AACH"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/plugins/network/index.ts"],"sourcesContent":["/**\n * `deictic/network`: the requests the page makes while it's recorded, in the recording, each as it ends. No tab,\n * and nothing of its own: it hands the recordings plugin rrweb's network plugin\n * (`@rrweb/rrweb-plugin-network-record`, an optional peer), whose events are rrweb's (`rrweb/network@1`).\n *\n * By default a request is its URL, its status and its timing, which the browser reports of itself\n * (`PerformanceObserver`): nothing of the page's is wrapped, and no method is known. `headers` and `body` add those\n * and the method, for which rrweb wraps `fetch` and `XMLHttpRequest` while a recording is going, and only then.\n *\n * Everything kept is masked first (`mask.ts`): a secret in a URL's query, a header or a body's field is blanked by\n * its name, and deictic's own requests are left out.\n */\nimport { definePlugin } from '#src/index.ts';\nimport type { Recorded } from '#src/plugins/recordings/index.ts';\n\nexport { MASKED, maskBody, maskHeaders, maskRequest, maskUrl, sensitive } from './mask.ts';\n\nexport interface NetworkOptions {\n /**\n * What made the requests kept, as the browser names it (a resource's `initiatorType`): `['fetch',\n * 'xmlhttprequest']` by default, the page's own calls. `'img'`, `'script'`, `'css'` and the like add what it loads.\n */\n initiators?: string[];\n /** Keeps each request's and response's headers, the secret ones blanked (`Authorization`, `Cookie`, …): not by default. */\n headers?: boolean;\n /**\n * Keeps each request's and response's body, cut at 10,000 characters, secrets blanked by name where it's JSON or a\n * form's fields: not by default. `true` is JSON, text and forms; a list names the content types, by a part of each.\n */\n body?: boolean | string[];\n /** More names whose values are blanked, in a query, a header or a body: a part of the name, in any case (`['email']`). */\n mask?: string[];\n /** Requests left out whole: a part of the URL (`['/analytics', 'sentry.io']`). */\n ignore?: string[];\n}\n\n/** The options as the page half gets them. */\nexport interface Resolved {\n initiators: string[];\n headers: boolean;\n body: false | string[];\n mask: string[];\n ignore: string[];\n}\n\ndeclare module 'deictic' {\n interface ClientApis {\n network: Recorded;\n }\n}\n\n/** The bodies kept with `body: true`: what reads as text. */\nconst TEXT = ['application/json', '+json', 'text/', 'application/x-www-form-urlencoded', 'application/xml'];\n\nexport function network(options: NetworkOptions = {}) {\n return definePlugin<never, never>({\n name: 'network',\n client: 'deictic/network/client',\n clientOptions: {\n initiators: options.initiators ?? ['fetch', 'xmlhttprequest'],\n headers: options.headers ?? false,\n body: options.body === true ? TEXT : (options.body ?? false),\n mask: options.mask ?? [],\n ignore: options.ignore ?? [],\n } satisfies Resolved,\n });\n}\n\nexport default network;\n"],"mappings":";;;;;;;;;;;;;;;;AAoDA,MAAM,OAAO;CAAC;CAAoB;CAAS;CAAS;CAAqC;AAAiB;AAE1G,SAAgB,QAAQ,UAA0B,CAAC,GAAG;CACpD,OAAO,aAA2B;EAChC,MAAM;EACN,QAAQ;EACR,eAAe;GACb,YAAY,QAAQ,cAAc,CAAC,SAAS,gBAAgB;GAC5D,SAAS,QAAQ,WAAW;GAC5B,MAAM,QAAQ,SAAS,OAAO,OAAQ,QAAQ,QAAQ;GACtD,MAAM,QAAQ,QAAQ,CAAC;GACvB,QAAQ,QAAQ,UAAU,CAAC;EAC7B;CACF,CAAC;AACH"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/plugins/recommended/index.ts"],"sourcesContent":["/**\n * `deictic/recommended`: the plugins for describing a change rather than making it. Alt-click an element, say what\n * should change, attach a screenshot to draw on, a screen recording or your voice, and it goes to a Vercel Board.\n * A recording has the page's console and its requests in it too.\n *\n * Only the server halves, as every factory is: each names its page half, which the integration imports. A plugin\n * outside the preset (Tailwind, your own) goes beside it: `plugins: [...recommended(), tailwind()]`.\n */\nimport type { ServerPlugin } from '#src/index.ts';\nimport { annotations, type AnnotationsOptions } from '#src/plugins/annotations/index.ts';\nimport { logs, type LogsOptions } from '#src/plugins/logs/index.ts';\nimport { network, type NetworkOptions } from '#src/plugins/network/index.ts';\nimport { recordings, type RecordingsOptions } from '#src/plugins/recordings/index.ts';\nimport { screenshots, type ScreenshotsOptions } from '#src/plugins/screenshots/index.ts';\nimport { tasks, type TasksOptions } from '#src/plugins/tasks/index.ts';\nimport { voice, type VoiceOptions } from '#src/plugins/voice/index.ts';\n\n/** Each plugin's options, by its name, or `false` to leave it out. */\nexport interface RecommendedOptions {\n tasks?: TasksOptions | false;\n screenshots?: ScreenshotsOptions | false;\n annotations?: AnnotationsOptions | false;\n recordings?: RecordingsOptions | false;\n voice?: VoiceOptions | false;\n /** The console's lines in a recording. */\n logs?: LogsOptions | false;\n /** The page's requests in a recording, masked. */\n network?: NetworkOptions | false;\n}\n\n/**\n * Tasks, screenshots, annotations, recordings and voice, in that order, the order of their tabs, then what a\n * recording has besides the page: logs and network.\n */\nexport function recommended(options: RecommendedOptions = {}): ServerPlugin[] {\n const plugins: ServerPlugin[] = [];\n if (options.tasks !== false) plugins.push(tasks(options.tasks));\n if (options.screenshots !== false) plugins.push(screenshots(options.screenshots));\n if (options.annotations !== false) plugins.push(annotations(options.annotations));\n if (options.recordings !== false) plugins.push(recordings(options.recordings));\n if (options.voice !== false) plugins.push(voice(options.voice));\n // Nothing without recordings to be in.\n if (options.recordings !== false && options.logs !== false) plugins.push(logs(options.logs));\n if (options.recordings !== false && options.network !== false) plugins.push(network(options.network));\n return plugins;\n}\n\nexport default recommended;\n"],"mappings":";;;;;;;;;;;;AAkCA,SAAgB,YAAY,UAA8B,CAAC,GAAmB;CAC5E,MAAM,UAA0B,CAAC;CACjC,IAAI,QAAQ,UAAU,OAAO,QAAQ,KAAK,MAAM,QAAQ,KAAK,CAAC;CAC9D,IAAI,QAAQ,gBAAgB,OAAO,QAAQ,KAAK,YAAY,QAAQ,WAAW,CAAC;CAChF,IAAI,QAAQ,gBAAgB,OAAO,QAAQ,KAAK,YAAY,QAAQ,WAAW,CAAC;CAChF,IAAI,QAAQ,eAAe,OAAO,QAAQ,KAAK,WAAW,QAAQ,UAAU,CAAC;CAC7E,IAAI,QAAQ,UAAU,OAAO,QAAQ,KAAK,MAAM,QAAQ,KAAK,CAAC;CAE9D,IAAI,QAAQ,eAAe,SAAS,QAAQ,SAAS,OAAO,QAAQ,KAAK,KAAK,QAAQ,IAAI,CAAC;CAC3F,IAAI,QAAQ,eAAe,SAAS,QAAQ,YAAY,OAAO,QAAQ,KAAK,QAAQ,QAAQ,OAAO,CAAC;CACpG,OAAO;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/plugins/screenshots/index.ts"],"sourcesContent":["/**\n * `deictic/screenshots`: a plugin with no panel, for others to build on. In the page,\n * `use('screenshots').capture(element)` takes what the viewport shows (or the element alone), with\n * nothing of deictic's in it, and says where the element is; on the server, `use('screenshots').read(id)`\n * hands the PNG to another plugin, which the tasks plugin attaches to a task.\n *\n * How a shot is made is its renderer's: `rrweb()` by default, which snapshots the page's DOM and renders it\n * in a browser beside the dev server, so text lays out as the page's does; or `dom()`, which draws the page\n * in the page itself, for a target with no server to render on. A renderer is a page module and, where it\n * renders elsewhere, a `render` here (`Renderer`): another may take pixels from screen sharing or devtools.\n *\n * Shots are kept under `.deictic/screenshots`, the latest `keep` of them, so they outlive a\n * restart of the dev server and stay out of git.\n */\nimport { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\n\nimport { definePlugin } from '#src/index.ts';\nimport { keptIn } from '#src/tools/kept.ts';\n\n/** A rectangle in CSS pixels, from the shot's top left. */\nexport interface Box {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/** A shot as the page knows it: its ID, where the dev server serves its PNG, and where the element is in it. */\nexport interface Shot {\n id: string;\n url: string;\n /** The element, in the shot: nothing marks it there, as nothing of deictic's is drawn. */\n box: Box;\n /** The shot's size in CSS pixels; its PNG may have more, on a high-density screen. */\n size: { width: number; height: number };\n}\n\nexport interface CaptureOptions {\n /** `viewport`, what the page shows, by default; or `element`, the element alone. */\n area?: 'viewport' | 'element';\n}\n\n/** The page's half, for other plugins' page halves. */\nexport interface Capture {\n capture(element: Element, options?: CaptureOptions): Promise<Shot>;\n /** Keeps a PNG made of a shot (the same one with marks drawn over it, say) as a shot of its own. */\n upload(png: Blob, of: Pick<Shot, 'box' | 'size'>): Promise<Shot>;\n /** A copy of an element with what a shot hides hidden in it too: for a plugin that sends its HTML somewhere. */\n masked(element: Element): Element;\n}\n\n/** The server's half, for other plugins' server halves. */\nexport interface Screenshots {\n /** A shot's PNG, or nothing for one not kept (any more). */\n read(id: string): { data: Uint8Array<ArrayBuffer>; name: string; type: 'image/png' } | undefined;\n}\n\ndeclare module 'deictic' {\n interface ServerApis {\n screenshots: Screenshots;\n }\n interface ClientApis {\n screenshots: Capture;\n }\n}\n\n/**\n * What a shot hides, as rrweb names it and by its defaults, so one marking in the app hides the same\n * things from a screenshot as from an rrweb recording or snapshot.\n */\nexport interface Masking {\n /** Elements drawn as a blank box their size: `rr-block` by default. */\n blockClass?: string;\n blockSelector?: string;\n /** Elements whose text is drawn as `*`: `rr-mask` by default. */\n maskTextClass?: string;\n maskTextSelector?: string;\n /** Every field's value as `*`, not only passwords': false by default. */\n maskAllInputs?: boolean;\n}\n\n/** Masking with its defaults, as a renderer's page half gets it. */\nexport type ResolvedMasking = Required<Pick<Masking, 'blockClass' | 'maskTextClass' | 'maskAllInputs'>> & Masking;\n\n/**\n * How shots are made. `client` is the page module that captures, default-exporting `screenshotsClient(…)`\n * from `deictic/screenshots/client`. A page half that sends a PNG needs nothing here; one that sends\n * something else, as JSON (a DOM snapshot), needs `render` to make the PNG of it.\n */\nexport interface Renderer {\n client: string;\n /** What the page half gets, besides the masking. */\n clientOptions?: unknown;\n /** The PNG, or with it the element's `box` in it, where it's not where the page said (the page was drawn again elsewhere). */\n render?(input: unknown): Promise<Uint8Array | { png: Uint8Array; box?: Box }>;\n}\n\n/** Where `rrweb()` finds a browser: any Chromium renders the snapshot as the page's own would. */\nexport interface BrowserOptions {\n /** A Chromium-based browser's executable. */\n executablePath?: string;\n /** An installed browser by Playwright's name: `chrome`, `msedge`. By default Playwright's own Chromium, then Chrome, then Edge. */\n channel?: string;\n}\n\n/** Draws the page in the page, from its DOM (`modern-screenshot`): no server needed, but text may lay out a little differently. */\nexport const dom = (): Renderer => ({ client: 'deictic/screenshots/dom' });\n\n/**\n * Snapshots the page's DOM in the page (`rrweb-snapshot`, masking as rrweb does) and renders it in a\n * browser beside the dev server (`playwright-core`), so text lays out as the page's does.\n */\nexport const rrweb = (options: BrowserOptions = {}): Renderer => ({\n client: 'deictic/screenshots/rrweb',\n // Loaded on the first shot, so a project rendering in the page needn't install Playwright.\n render: async (input) => (await import('./playwright.ts')).render(input, options),\n});\n\nexport interface ScreenshotsOptions extends Masking {\n /** How shots are made: `rrweb()` by default, or `dom()` where there's no server to render on. */\n renderer?: Renderer;\n /** How many shots to keep, the latest: 100 by default. */\n keep?: number;\n /** Where they're kept, from the project's root: `.deictic/screenshots` by default. */\n dir?: string;\n}\n\nconst ID = /^[a-z0-9]+-[a-z0-9]+$/;\n/** What one PNG, or one snapshot to render, may weigh: a viewport at twice its pixels is a few MB. */\nconst MAX = 20 * 1024 * 1024;\n\nexport function screenshots(options: ScreenshotsOptions = {}) {\n const renderer = options.renderer ?? rrweb();\n const keep = options.keep ?? 100;\n let dir = '';\n let taken = 0;\n const pathOf = (id: string) => join(dir, `${id}.png`);\n const read: Screenshots['read'] = (id) => {\n if (!ID.test(id) || !existsSync(pathOf(id))) return undefined;\n return { data: new Uint8Array(readFileSync(pathOf(id))), name: `${id}.png`, type: 'image/png' };\n };\n const keepShot = (data: Uint8Array) => {\n // Sorts by when it was taken, which is what pruning keeps by: the count orders two in one millisecond.\n const id = `${Date.now().toString(36).padStart(9, '0')}${(taken++ % 1296).toString(36).padStart(2, '0')}-${crypto.randomUUID().slice(0, 8)}`;\n mkdirSync(dir, { recursive: true });\n writeFileSync(pathOf(id), data);\n const kept = readdirSync(dir)\n .filter((f) => f.endsWith('.png'))\n .toSorted();\n for (const old of kept.slice(0, Math.max(0, kept.length - keep))) rmSync(join(dir, old));\n return id;\n };\n\n return definePlugin<never, never, never, Screenshots>({\n name: 'screenshots',\n client: renderer.client,\n clientOptions: {\n masking: {\n blockClass: options.blockClass ?? 'rr-block',\n blockSelector: options.blockSelector,\n maskTextClass: options.maskTextClass ?? 'rr-mask',\n maskTextSelector: options.maskTextSelector,\n maskAllInputs: options.maskAllInputs ?? false,\n } satisfies ResolvedMasking,\n renderer: renderer.clientOptions,\n },\n setup: ({ root }) => {\n dir = options.dir === undefined ? keptIn(root, 'screenshots') : resolve(root, options.dir);\n return { read };\n },\n routes: {\n // A PNG the page made, or what the renderer makes one of.\n add: async (req) => {\n const type = req.headers.get('content-type') ?? '';\n const body = new Uint8Array(await req.arrayBuffer());\n if (body.byteLength > MAX) return Response.json({ problem: `a shot may weigh ${MAX / 1024 / 1024} MB at most` }, { status: 413 });\n if (type === 'image/png') return Response.json({ id: keepShot(body) });\n if (renderer.render === undefined || !type.startsWith('application/json'))\n return Response.json({ problem: 'send the shot as image/png' }, { status: 415 });\n try {\n const made = await renderer.render(JSON.parse(new TextDecoder().decode(body)));\n if (made instanceof Uint8Array) return Response.json({ id: keepShot(made) });\n return Response.json({ id: keepShot(made.png), ...(made.box === undefined ? {} : { box: made.box }) });\n } catch (e) {\n return Response.json({ problem: e instanceof Error ? e.message : String(e) }, { status: 500 });\n }\n },\n // `shot/<id>`: the PNG, for a panel to show.\n shot: (req) => {\n const shot = read(new URL(req.url).pathname.split('/').at(-1) ?? '');\n if (shot === undefined) return new Response('no such shot, or not kept any more', { status: 404 });\n return new Response(shot.data, { headers: { 'content-type': shot.type, 'cache-control': 'no-store' } });\n },\n },\n });\n}\n\nexport default screenshots;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2GA,MAAa,aAAuB,EAAE,QAAQ,0BAA0B;;;;;AAMxE,MAAa,SAAS,UAA0B,CAAC,OAAiB;CAChE,QAAQ;CAER,QAAQ,OAAO,WAAW,MAAM,OAAO,2BAAA,CAAoB,OAAO,OAAO,OAAO;AAClF;AAWA,MAAM,KAAK;;AAEX,MAAM,MAAM;AAEZ,SAAgB,YAAY,UAA8B,CAAC,GAAG;CAC5D,MAAM,WAAW,QAAQ,YAAY,MAAM;CAC3C,MAAM,OAAO,QAAQ,QAAQ;CAC7B,IAAI,MAAM;CACV,IAAI,QAAQ;CACZ,MAAM,UAAU,OAAe,KAAK,KAAK,GAAG,GAAG,KAAK;CACpD,MAAM,QAA6B,OAAO;EACxC,IAAI,CAAC,GAAG,KAAK,EAAE,KAAK,CAAC,WAAW,OAAO,EAAE,CAAC,GAAG,OAAO,KAAA;EACpD,OAAO;GAAE,MAAM,IAAI,WAAW,aAAa,OAAO,EAAE,CAAC,CAAC;GAAG,MAAM,GAAG,GAAG;GAAO,MAAM;EAAY;CAChG;CACA,MAAM,YAAY,SAAqB;EAErC,MAAM,KAAK,GAAG,KAAK,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,KAAK,UAAU,KAAA,CAAM,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,EAAE,GAAG,OAAO,WAAW,CAAC,CAAC,MAAM,GAAG,CAAC;EACzI,UAAU,KAAK,EAAE,WAAW,KAAK,CAAC;EAClC,cAAc,OAAO,EAAE,GAAG,IAAI;EAC9B,MAAM,OAAO,YAAY,GAAG,CAAC,CAC1B,QAAQ,MAAM,EAAE,SAAS,MAAM,CAAC,CAAC,CACjC,SAAS;EACZ,KAAK,MAAM,OAAO,KAAK,MAAM,GAAG,KAAK,IAAI,GAAG,KAAK,SAAS,IAAI,CAAC,GAAG,OAAO,KAAK,KAAK,GAAG,CAAC;EACvF,OAAO;CACT;CAEA,OAAO,aAA+C;EACpD,MAAM;EACN,QAAQ,SAAS;EACjB,eAAe;GACb,SAAS;IACP,YAAY,QAAQ,cAAc;IAClC,eAAe,QAAQ;IACvB,eAAe,QAAQ,iBAAiB;IACxC,kBAAkB,QAAQ;IAC1B,eAAe,QAAQ,iBAAiB;GAC1C;GACA,UAAU,SAAS;EACrB;EACA,QAAQ,EAAE,WAAW;GACnB,MAAM,QAAQ,QAAQ,KAAA,IAAY,OAAO,MAAM,aAAa,IAAI,QAAQ,MAAM,QAAQ,GAAG;GACzF,OAAO,EAAE,KAAK;EAChB;EACA,QAAQ;GAEN,KAAK,OAAO,QAAQ;IAClB,MAAM,OAAO,IAAI,QAAQ,IAAI,cAAc,KAAK;IAChD,MAAM,OAAO,IAAI,WAAW,MAAM,IAAI,YAAY,CAAC;IACnD,IAAI,KAAK,aAAa,KAAK,OAAO,SAAS,KAAK,EAAE,SAAS,oBAAoB,MAAM,OAAO,KAAK,aAAa,GAAG,EAAE,QAAQ,IAAI,CAAC;IAChI,IAAI,SAAS,aAAa,OAAO,SAAS,KAAK,EAAE,IAAI,SAAS,IAAI,EAAE,CAAC;IACrE,IAAI,SAAS,WAAW,KAAA,KAAa,CAAC,KAAK,WAAW,kBAAkB,GACtE,OAAO,SAAS,KAAK,EAAE,SAAS,6BAA6B,GAAG,EAAE,QAAQ,IAAI,CAAC;IACjF,IAAI;KACF,MAAM,OAAO,MAAM,SAAS,OAAO,KAAK,MAAM,IAAI,YAAY,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC;KAC7E,IAAI,gBAAgB,YAAY,OAAO,SAAS,KAAK,EAAE,IAAI,SAAS,IAAI,EAAE,CAAC;KAC3E,OAAO,SAAS,KAAK;MAAE,IAAI,SAAS,KAAK,GAAG;MAAG,GAAI,KAAK,QAAQ,KAAA,IAAY,CAAC,IAAI,EAAE,KAAK,KAAK,IAAI;KAAG,CAAC;IACvG,SAAS,GAAG;KACV,OAAO,SAAS,KAAK,EAAE,SAAS,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC,EAAE,GAAG,EAAE,QAAQ,IAAI,CAAC;IAC/F;GACF;GAEA,OAAO,QAAQ;IACb,MAAM,OAAO,KAAK,IAAI,IAAI,IAAI,GAAG,CAAC,CAAC,SAAS,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE;IACnE,IAAI,SAAS,KAAA,GAAW,OAAO,IAAI,SAAS,sCAAsC,EAAE,QAAQ,IAAI,CAAC;IACjG,OAAO,IAAI,SAAS,KAAK,MAAM,EAAE,SAAS;KAAE,gBAAgB,KAAK;KAAM,iBAAiB;IAAW,EAAE,CAAC;GACxG;EACF;CACF,CAAC;AACH"}
|
package/dist/vite.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vite.d.ts","names":[],"sources":["../src/vite.ts"],"mappings":";;iBAmBiB,oBAAoB;;;;;;;EAOnC;;;qBAIW;wBAGG,QAAQ,UAAS,cAAmB"}
|
package/dist/vite.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vite.js","names":[],"sources":["../src/vite.ts"],"sourcesContent":["/**\n * `deictic/vite`: deictic in Vite's dev server. Nothing runs in a build, unless `standalone` asks for it.\n *\n * Its transform runs `pre`, so each JSX module's host elements are marked with their place in the\n * source as written (`tools/locate.ts`). In the browser each marked module also imports the client\n * module, which starts the overlay with every plugin's panel: imports run first and only once, so no\n * line moves and frameworks that render their own HTML get it too. The endpoints are middleware on\n * Vite's server, and a place opens through Vite's own `/__open-in-editor`, so the editor is whichever\n * Vite already launches. A write reaches the page through Vite's usual update for the file.\n */\nimport { resolve } from 'node:path';\n\nimport type { Plugin } from 'vite';\n\nimport { endpoints, nodeMiddleware, redirect } from './tools/endpoints.ts';\nimport { clientModule, type DeicticOptions, mark, markAstro, prepare } from './tools/integration.ts';\n\nexport { clientModule, type DeicticOptions };\n\nexport interface ViteOptions extends DeicticOptions {\n /**\n * deictic in a build too, for a page that shows it with no dev server behind it (a deployed demo): a module of\n * the page's, from the root, whose default export answers the overlay's requests there (a `Standalone`, from\n * `deictic`). The build's elements are marked and the overlay is in its bundle. The dev server answers as ever.\n * Without it, the default, nothing of deictic is in a build.\n */\n standalone?: string;\n}\n\n/** The client module's ID, which a page can import itself where nothing it bundles is JSX (Astro's pages). */\nexport const CLIENT = 'virtual:deictic/client';\nconst CLIENT_ID = '\\0deictic/client';\n\nexport function deictic(options: ViteOptions = {}): Plugin {\n const { plugins, shortcut } = prepare(options);\n let root = '';\n let base = '/';\n let building = false;\n return {\n name: 'deictic',\n enforce: 'pre',\n apply: (_, { command }) => command === 'serve' || options.standalone !== undefined,\n // The client is the app's to bundle as it changes, not a dependency to prebundle once.\n config: () => ({ optimizeDeps: { exclude: ['deictic'] } }),\n configResolved(config) {\n root = config.root;\n base = config.base;\n building = config.command === 'build';\n },\n configureServer(server) {\n const handle = endpoints({\n root,\n plugins,\n base,\n open: (path, { line, column }) => redirect(`${base}__open-in-editor?${new URLSearchParams({ file: `${path}:${line}:${column}` })}`),\n });\n server.middlewares.use(nodeMiddleware(handle));\n },\n resolveId: (id) => (id === CLIENT ? CLIENT_ID : undefined),\n load(id) {\n if (id !== CLIENT_ID) return undefined;\n // Only a build's page asks the module: the dev server is there to answer.\n const server = building && options.standalone !== undefined ? resolve(root, options.standalone).replaceAll('\\\\', '/') : undefined;\n return clientModule(plugins, base, shortcut, server);\n },\n transform: {\n // First of all, not only first of the `pre` plugins: the React Compiler (`react({ compiler: true })`) is\n // `pre` too and compiles the JSX away, so after it there'd be no element to mark, wherever deictic is listed.\n order: 'pre',\n handler(code, id) {\n const [path = ''] = id.split('?');\n // An `.astro` component itself, not the styles and scripts Astro loads from it by a query.\n if (path.endsWith('.astro')) return id === path ? markAstro(code, path, root) : undefined;\n const browser = this.environment.config.consumer === 'client';\n return mark(code, path, root, browser ? `\\nimport ${JSON.stringify(CLIENT)};\\n` : '');\n },\n },\n };\n}\n\nexport default deictic;\n"],"mappings":";;;;;;;;;;;;;;;AA8BA,MAAa,SAAS;AACtB,MAAM,YAAY;AAElB,SAAgB,QAAQ,UAAuB,CAAC,GAAW;CACzD,MAAM,EAAE,SAAS,aAAa,QAAQ,OAAO;CAC7C,IAAI,OAAO;CACX,IAAI,OAAO;CACX,IAAI,WAAW;CACf,OAAO;EACL,MAAM;EACN,SAAS;EACT,QAAQ,GAAG,EAAE,cAAc,YAAY,WAAW,QAAQ,eAAe,KAAA;EAEzE,eAAe,EAAE,cAAc,EAAE,SAAS,CAAC,SAAS,EAAE,EAAE;EACxD,eAAe,QAAQ;GACrB,OAAO,OAAO;GACd,OAAO,OAAO;GACd,WAAW,OAAO,YAAY;EAChC;EACA,gBAAgB,QAAQ;GACtB,MAAM,SAAS,UAAU;IACvB;IACA;IACA;IACA,OAAO,MAAM,EAAE,MAAM,aAAa,SAAS,GAAG,KAAK,mBAAmB,IAAI,gBAAgB,EAAE,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,SAAS,CAAC,GAAG;GACpI,CAAC;GACD,OAAO,YAAY,IAAI,eAAe,MAAM,CAAC;EAC/C;EACA,YAAY,OAAQ,OAAA,2BAAgB,YAAY,KAAA;EAChD,KAAK,IAAI;GACP,IAAI,OAAO,WAAW,OAAO,KAAA;GAE7B,MAAM,SAAS,YAAY,QAAQ,eAAe,KAAA,IAAY,QAAQ,MAAM,QAAQ,UAAU,CAAC,CAAC,WAAW,MAAM,GAAG,IAAI,KAAA;GACxH,OAAO,aAAa,SAAS,MAAM,UAAU,MAAM;EACrD;EACA,WAAW;GAGT,OAAO;GACP,QAAQ,MAAM,IAAI;IAChB,MAAM,CAAC,OAAO,MAAM,GAAG,MAAM,GAAG;IAEhC,IAAI,KAAK,SAAS,QAAQ,GAAG,OAAO,OAAO,OAAO,UAAU,MAAM,MAAM,IAAI,IAAI,KAAA;IAChF,MAAM,UAAU,KAAK,YAAY,OAAO,aAAa;IACrD,OAAO,KAAK,MAAM,MAAM,MAAM,UAAU,YAAY,KAAK,UAAU,MAAM,EAAE,OAAO,EAAE;GACtF;EACF;CACF;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/plugins/voice/index.ts"],"mappings":";iBAciB;EACf;EACA;EACA;EACA;;;iBAIe;;EAEf;;EAEA,QAAQ;;;;;EAKR,SAAS,KAAK;EACd,QAAQ,QAAQ;EAChB;;;iBAIe;;EAEf,SAAS,QAAQ;;;iBAIF;;EAEf,KAAK;IAAe,MAAM,WAAW;IAAc;IAAc;;;;YAIvD;IACR,OAAO;;YAEC;IACR,OAAO;;;iBAIM;;EAEf;;EAEA;;wBASc,MAAM,UAAS,iCAAiB,kCAAA"}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
# Setting deictic up
|
|
2
|
-
|
|
3
|
-
Only when the project doesn't have it yet, or the person asks. Check first: a `deictic` dependency and its plugin
|
|
4
|
-
in the bundler config. The package's `API.md` has the setup; each plugin's options are its factory's types.
|
|
5
|
-
|
|
6
|
-
## The package and the bundler
|
|
7
|
-
|
|
8
|
-
Install with the project's package manager (`npm install -D`, `bun add -d`, `pnpm add -D`, `yarn add -D`), the
|
|
9
|
-
plugins' dependencies with it (below), and add it to the bundler; each runs in the dev server only and takes the
|
|
10
|
-
same options:
|
|
11
|
-
|
|
12
|
-
| Bundler | Config |
|
|
13
|
-
| ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------- |
|
|
14
|
-
| Vite (and frameworks on it) | `plugins: [deictic({ plugins })]`, `deictic` from `deictic/vite` |
|
|
15
|
-
| Next.js (`next dev`, either bundler) | `export default withDeictic(nextConfig, { plugins })`, from `deictic/next` |
|
|
16
|
-
| webpack 5, Rspack | `plugins: [new DeicticPlugin({ plugins })]`, from `deictic/webpack`; `launch-editor` to open files |
|
|
17
|
-
| Bun (`Bun.serve` with HTML imports) | `deictic/bun`: a plugin module named in `bunfig.toml`'s `[serve.static] plugins`, its `routes` spread into `Bun.serve` |
|
|
18
|
-
| Astro | `integrations: [deictic({ plugins })]`, from `deictic/astro`; `.astro` components are marked with Astro 7 or later |
|
|
19
|
-
|
|
20
|
-
React Native isn't supported. With no plugins deictic loads nothing; `.deictic/` (kept data) ignores itself in git.
|
|
21
|
-
|
|
22
|
-
## Which plugins: ask first
|
|
23
|
-
|
|
24
|
-
Before installing anything, ask the person in one message whether they want the recommended setup, and name the
|
|
25
|
-
other options so they can add or drop some:
|
|
26
|
-
|
|
27
|
-
> I'd set deictic up for tasks: Alt-click an element, describe the change, and attach a screenshot (which you can
|
|
28
|
-
> draw on), a screen recording, or your voice; it goes to a Vercel Board for me to work. That's the tasks,
|
|
29
|
-
> screenshots, annotations, recordings and voice plugins (a recording keeps the page's console and its requests too,
|
|
30
|
-
> secrets masked), plus `@vercel/board`, `rrweb`, `rrweb-player`, `rrweb-snapshot`, rrweb's console and network plugins
|
|
31
|
-
> and `playwright-core` as dev dependencies. Also available: Tailwind (edit an element's classes in place, no task
|
|
32
|
-
> needed), screenshots drawn in the page instead of a headless browser (`dom()`, for a page with no server to
|
|
33
|
-
> render on), a channel or labels for the tasks, and a shortcut other than Alt. Go with the recommended setup?
|
|
34
|
-
|
|
35
|
-
On yes, the recommended setup:
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
npm install -D deictic @vercel/board rrweb rrweb-player rrweb-snapshot playwright-core \
|
|
39
|
-
@rrweb/rrweb-plugin-console-record @rrweb/rrweb-plugin-network-record
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
```ts
|
|
43
|
-
import { recommended } from 'deictic/recommended';
|
|
44
|
-
|
|
45
|
-
deictic({ plugins: recommended() });
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Screenshots render in a Chromium: Playwright's (`npx playwright install chromium`), else Chrome or Edge if installed.
|
|
49
|
-
|
|
50
|
-
To fit what they choose instead: a plugin's options go under its name, `false` leaves one out
|
|
51
|
-
(`recommended({ tasks: { channel: 'ui' }, voice: false })`), and one outside the preset goes beside it
|
|
52
|
-
(`[...recommended(), tailwind()]`, `tailwind` from `deictic/tailwind`). Every plugin:
|
|
53
|
-
|
|
54
|
-
| Plugin | What it adds | Install too |
|
|
55
|
-
| --------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
|
|
56
|
-
| `tasks()` | The Task tab; `{ channel, project, labels }` route and name them (`deictic` by default) | `@vercel/board` |
|
|
57
|
-
| `screenshots()` | A shot of the page attached to a task; `{ renderer: dom() }` in-page | `rrweb-snapshot`, `playwright-core` (`modern-screenshot` for `dom()`) |
|
|
58
|
-
| `annotations()` | Marks on the page, on shots (Annotate) and in recordings | |
|
|
59
|
-
| `recordings()` | Record beside Attach: a screen recording attached to a task | `rrweb`, `rrweb-player` (its replay) |
|
|
60
|
-
| `voice()` | The mic, in recordings and as voice notes in a task | |
|
|
61
|
-
| `logs()` | The console's lines and uncaught errors in a recording; `{ levels }` | `@rrweb/rrweb-plugin-console-record` |
|
|
62
|
-
| `network()` | The page's requests in a recording, masked; `{ headers, body, mask, ignore }` | `@rrweb/rrweb-plugin-network-record` |
|
|
63
|
-
| `tailwind()` | Edit an element's classes in place; `{ css: 'src/index.css' }` names the theme's sheet | |
|
|
64
|
-
|
|
65
|
-
`deictic({ shortcut })` changes Alt-click, or `false` for none. The plugins' order is the tabs' order: keep theirs.
|
|
66
|
-
|
|
67
|
-
A build has nothing of deictic. Only for a deployed demo with no dev server, `deictic/vite` takes
|
|
68
|
-
`standalone: 'src/standalone.ts'`: deictic is then in the build, and that module's default export (a `Standalone`,
|
|
69
|
-
from `deictic`: `(request: Request) => Response`) answers in the page what the dev server would under `/__deictic/`
|
|
70
|
-
(`read` → `{ model }`, `apply` → `{ model, change: { label } }`, `undo`, `redo`, `history`, each plugin's routes).
|
|
71
|
-
What keeps a shot (`add`), a voice clip (`add`, then `more/<id>`, the last with `?last`) or a recording (`begin`,
|
|
72
|
-
`part/<id>?seq=<n>`, then `end/<id>` or `discard/<id>`) may name the `url` it's kept at. For a recording that's a
|
|
73
|
-
replay page the build publishes: `replayPage({ player, source })` from `deictic/recordings` is its HTML.
|
|
74
|
-
|
|
75
|
-
## The board
|
|
76
|
-
|
|
77
|
-
Tasks go to a Vercel Board. With nothing set, the dev server starts one on this machine and stops it as it stops:
|
|
78
|
-
`http://127.0.0.1:4100/api/board` (another port where that one's taken), its log in `.deictic/board`. It prints the
|
|
79
|
-
URL as it starts and keeps it in `.deictic/board.json`:
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
export BOARD_PROFILE=claude # your name: what you post is yours, not the person's
|
|
83
|
-
node <skill>/scripts/vb.mjs whoami # krtgo/claude, and the board's URL
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
`vb.mjs` is the project's own `vb` (in `node_modules/.bin`, so rarely on the PATH), and like the other scripts here
|
|
87
|
-
it reads that file when `BOARD_URL` isn't set. A `vb` you run yourself needs the variable:
|
|
88
|
-
`export BOARD_URL=$(node -p "require('./.deictic/board.json').url")`. The board is there only while the dev server
|
|
89
|
-
runs.
|
|
90
|
-
|
|
91
|
-
For another board, set `BOARD_URL` for the dev server and for `vb` alike. For the team's, through `vercel login`,
|
|
92
|
-
with no `BOARD_URL`: `tasks({ board: board() })` in the bundler config (`board` from `@vercel/board`), or
|
|
93
|
-
`recommended({ tasks: { board: board() } })`. `board: local({ port, dir, inspect, args })`, with `local` from
|
|
94
|
-
`deictic/tasks`, is the board on this machine with those options (its port, its folder from the root, `false` for
|
|
95
|
-
none of its pages, more of `vb serve`'s arguments), and whatever `BOARD_URL` says.
|
|
96
|
-
|
|
97
|
-
## This skill
|
|
98
|
-
|
|
99
|
-
```bash
|
|
100
|
-
npx skills add gkurt/deictic # or ./node_modules/deictic, the installed package's; -a <agent> to pick agents, -g for global
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
Then restart the agent if it only reads skills as it starts.
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Screenshots of a recording at moments of it, as its replay page shows them (marks and pointer included),
|
|
3
|
-
// at the recorded viewport's size. By default: just after each change to the marks, and the end.
|
|
4
|
-
// Usage: frame.mjs <task | replay URL | recording ID | file> [--at 4.2 ...] [--every 2] [--out dir] [--base url]
|
|
5
|
-
// Needs the dev server running (it serves the replay) and Playwright (playwright-core or playwright) in the project.
|
|
6
|
-
import { mkdirSync } from 'node:fs';
|
|
7
|
-
import { tmpdir } from 'node:os';
|
|
8
|
-
import { join, resolve } from 'node:path';
|
|
9
|
-
|
|
10
|
-
import { clock, fail, fromProject, loadRecording, parseArgs } from './lib.mjs';
|
|
11
|
-
|
|
12
|
-
const { options, rest } = parseArgs(process.argv.slice(2));
|
|
13
|
-
const { kept, id, replay } = await loadRecording(rest[0], Number(options.nth?.[0] ?? 1));
|
|
14
|
-
const base = options.base?.[0];
|
|
15
|
-
// The replay is served by the dev server that recorded it, under deictic's routes.
|
|
16
|
-
const page = base
|
|
17
|
-
? `${base.replace(/\/$/, '')}/__deictic/plugins/recordings/replay/${id}`
|
|
18
|
-
: (replay ?? `${new URL(kept.page).origin}/__deictic/plugins/recordings/replay/${id}`);
|
|
19
|
-
|
|
20
|
-
const t0 = kept.events[0].timestamp;
|
|
21
|
-
let times = (options.at ?? []).map(Number);
|
|
22
|
-
if (options.every) for (let t = 0; t <= kept.duration / 1000; t += Number(options.every[0])) times.push(t);
|
|
23
|
-
if (times.length === 0) {
|
|
24
|
-
// Just after each change to the marks, so it's drawn, then the end.
|
|
25
|
-
const marks = kept.events.filter((e) => e.type === 5 && e.data.tag === 'deictic.annotations' && (e.data.payload.svg ?? '') !== '');
|
|
26
|
-
times = [...marks.map((e) => (e.timestamp - t0 + 50) / 1000), kept.duration / 1000];
|
|
27
|
-
}
|
|
28
|
-
times = [...new Set(times.map((t) => Math.min(Math.max(0, t), kept.duration / 1000)))].sort((a, b) => a - b);
|
|
29
|
-
if (times.some((t) => !Number.isFinite(t))) fail('--at and --every take seconds: --at 4.2');
|
|
30
|
-
|
|
31
|
-
const out = resolve(options.out?.[0] ?? join(tmpdir(), 'deictic-frames', id));
|
|
32
|
-
mkdirSync(out, { recursive: true });
|
|
33
|
-
|
|
34
|
-
const { chromium } = await fromProject('playwright-core', 'playwright');
|
|
35
|
-
let browser;
|
|
36
|
-
for (const channel of [undefined, 'chrome', 'msedge']) {
|
|
37
|
-
try {
|
|
38
|
-
browser = await chromium.launch(channel ? { channel } : {});
|
|
39
|
-
break;
|
|
40
|
-
} catch {}
|
|
41
|
-
}
|
|
42
|
-
if (browser === undefined) fail('No Chromium to launch: npx playwright install chromium, or install Chrome or Edge.');
|
|
43
|
-
try {
|
|
44
|
-
// `bare`: the replay alone, at the recorded size, so a window that size shows it 1:1.
|
|
45
|
-
const view = await browser.newPage({ viewport: kept.viewport });
|
|
46
|
-
for (const t of times) {
|
|
47
|
-
const url = new URL(page);
|
|
48
|
-
url.searchParams.set('t', t.toFixed(2));
|
|
49
|
-
url.searchParams.set('bare', '');
|
|
50
|
-
const res = await view.goto(url.href);
|
|
51
|
-
if (!res?.ok()) fail(`${url.href}: ${res?.status()}. Is the dev server running? Pass --base with its URL.`);
|
|
52
|
-
await view.waitForSelector('body[data-ready]', { timeout: 15_000 });
|
|
53
|
-
// The replayed page's images and fonts.
|
|
54
|
-
await view.waitForLoadState('networkidle').catch(() => {});
|
|
55
|
-
await view.waitForTimeout(200);
|
|
56
|
-
const path = join(out, `${String(Math.round(t * 1000)).padStart(6, '0')}.png`);
|
|
57
|
-
await view.screenshot({ path });
|
|
58
|
-
console.log(`${clock(t * 1000).padStart(6)} ${path}`);
|
|
59
|
-
}
|
|
60
|
-
} finally {
|
|
61
|
-
await browser.close();
|
|
62
|
-
}
|
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
// What the scripts share: the board's CLI, the project's `.deictic/` folders, and finding a recording or a
|
|
2
|
-
// voice clip by a task's ID, a recording's ID, a replay URL or a path. Node 20 or Bun; no dependencies.
|
|
3
|
-
import { spawnSync } from 'node:child_process';
|
|
4
|
-
import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
5
|
-
import { tmpdir } from 'node:os';
|
|
6
|
-
import { delimiter, dirname, join, resolve } from 'node:path';
|
|
7
|
-
import { pathToFileURL } from 'node:url';
|
|
8
|
-
|
|
9
|
-
/** `--name value` and `--flag` options, and the arguments around them. */
|
|
10
|
-
export function parseArgs(argv, flags = []) {
|
|
11
|
-
const options = {};
|
|
12
|
-
const rest = [];
|
|
13
|
-
for (let i = 0; i < argv.length; i++) {
|
|
14
|
-
const a = argv[i];
|
|
15
|
-
if (!a.startsWith('--')) rest.push(a);
|
|
16
|
-
else if (flags.includes(a.slice(2))) options[a.slice(2)] = true;
|
|
17
|
-
else (options[a.slice(2)] ??= []).push(argv[++i]);
|
|
18
|
-
}
|
|
19
|
-
return { options, rest };
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function fail(message) {
|
|
23
|
-
console.error(message);
|
|
24
|
-
process.exit(1);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** `1:02.5`, from milliseconds. */
|
|
28
|
-
export function clock(ms) {
|
|
29
|
-
const s = Math.max(0, ms) / 1000;
|
|
30
|
-
return `${Math.floor(s / 60)}:${(s % 60).toFixed(1).padStart(4, '0')}`;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/** This directory and each above it. */
|
|
34
|
-
function* upFrom(dir = process.cwd()) {
|
|
35
|
-
for (let at = resolve(dir); ; at = dirname(at)) {
|
|
36
|
-
yield at;
|
|
37
|
-
if (dirname(at) === at) return;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** Every `.deictic/` near here: in this directory or above, or in a folder of it (a site/, an app/). */
|
|
42
|
-
export function deicticDirs() {
|
|
43
|
-
const found = [...upFrom()].map((d) => join(d, '.deictic')).filter((p) => existsSync(p));
|
|
44
|
-
const walk = (dir, depth) => {
|
|
45
|
-
if (depth === 0) return;
|
|
46
|
-
for (const e of readdirSync(dir, { withFileTypes: true })) {
|
|
47
|
-
if (!e.isDirectory() || e.name === 'node_modules' || (e.name.startsWith('.') && e.name !== '.deictic')) continue;
|
|
48
|
-
const path = join(dir, e.name);
|
|
49
|
-
if (e.name === '.deictic') found.push(path);
|
|
50
|
-
else walk(path, depth - 1);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
walk(process.cwd(), 3);
|
|
54
|
-
return [...new Set(found)];
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* The board's URL: `BOARD_URL`, or with none, the board the dev server started for the project, which
|
|
59
|
-
* `.deictic/board.json` names. Nothing where there's neither: `vb` then finds the team's board.
|
|
60
|
-
*/
|
|
61
|
-
export function boardUrl() {
|
|
62
|
-
if (process.env.BOARD_URL) return process.env.BOARD_URL;
|
|
63
|
-
for (const dir of deicticDirs()) {
|
|
64
|
-
try {
|
|
65
|
-
const { url } = JSON.parse(readFileSync(join(dir, 'board.json'), 'utf8'));
|
|
66
|
-
if (typeof url === 'string') return url;
|
|
67
|
-
} catch {
|
|
68
|
-
// No board of this project's own: the next one's, or the team's.
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return undefined;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/** How often a watch says it's still there, and so how soon the page knows of one that was killed (three missed). */
|
|
75
|
-
const BEAT = 20_000;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Tells the project's dev server that `name` watches `channel`, which a board can't say: a file under
|
|
79
|
-
* `.deictic/watchers`, written again every `BEAT`, that the Task tab reads. In the `.deictic/` whose board this
|
|
80
|
-
* is, or in each one near here where the board is the environment's. Answers what takes it back.
|
|
81
|
-
*/
|
|
82
|
-
export function watching(channel, name) {
|
|
83
|
-
const url = boardUrl();
|
|
84
|
-
const dirs = deicticDirs();
|
|
85
|
-
const boardIn = (dir) => {
|
|
86
|
-
try {
|
|
87
|
-
return JSON.parse(readFileSync(join(dir, 'board.json'), 'utf8')).url;
|
|
88
|
-
} catch {
|
|
89
|
-
return undefined;
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
const own = dirs.filter((dir) => boardIn(dir) === url);
|
|
93
|
-
const files = (own.length > 0 ? own : dirs).map((dir) => join(dir, 'watchers', `${process.pid}.json`));
|
|
94
|
-
const beat = () => {
|
|
95
|
-
for (const file of files) {
|
|
96
|
-
try {
|
|
97
|
-
mkdirSync(dirname(file), { recursive: true });
|
|
98
|
-
writeFileSync(file, `${JSON.stringify({ name, channel, pid: process.pid, at: Date.now() })}\n`);
|
|
99
|
-
} catch {
|
|
100
|
-
// A folder that can't be written to: the watch goes on, unseen.
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
beat();
|
|
105
|
-
const timer = setInterval(beat, BEAT);
|
|
106
|
-
return () => {
|
|
107
|
-
clearInterval(timer);
|
|
108
|
-
for (const file of files) rmSync(file, { force: true });
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/** `30m`, `45s`, `1h` or a bare number of seconds, as milliseconds. */
|
|
113
|
-
export function duration(text) {
|
|
114
|
-
const [, n, unit = 's'] = /^(\d+(?:\.\d+)?)([smh])?$/.exec(text) ?? [];
|
|
115
|
-
if (n === undefined) fail(`"${text}" isn't a duration: 30m, 45s, 1h, or seconds as a number.`);
|
|
116
|
-
return Number(n) * { s: 1000, m: 60_000, h: 3_600_000 }[unit];
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/** The project's own `@vercel/board` CLI, as a script: from here, above, or beside a `.deictic/` near here. */
|
|
120
|
-
function vbScript() {
|
|
121
|
-
for (const dir of new Set([...upFrom(), ...deicticDirs().map(dirname)])) {
|
|
122
|
-
const pkg = join(dir, 'node_modules', '@vercel', 'board', 'package.json');
|
|
123
|
-
if (!existsSync(pkg)) continue;
|
|
124
|
-
const { bin } = JSON.parse(readFileSync(pkg, 'utf8'));
|
|
125
|
-
const entry = typeof bin === 'string' ? bin : bin?.vb;
|
|
126
|
-
if (typeof entry === 'string') return join(dirname(pkg), entry);
|
|
127
|
-
}
|
|
128
|
-
return undefined;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* How to run the board's CLI, with the environment's board or the project's own, as `spawn`'s command,
|
|
133
|
-
* arguments and options: the project's `@vercel/board`, run by this runtime, so it needn't be on the PATH and
|
|
134
|
-
* no shell reads the arguments; with none installed, `vb` from the PATH.
|
|
135
|
-
*/
|
|
136
|
-
export function vbCommand(args) {
|
|
137
|
-
const bins = [...upFrom()].map((d) => join(d, 'node_modules', '.bin'));
|
|
138
|
-
const url = boardUrl();
|
|
139
|
-
const env = { ...process.env, ...(url === undefined ? {} : { BOARD_URL: url }), PATH: [...bins, process.env.PATH].join(delimiter) };
|
|
140
|
-
const script = vbScript();
|
|
141
|
-
if (script !== undefined) return [process.execPath, [script, ...args], { env }];
|
|
142
|
-
// npm's shims on Windows are .cmd files, which only a shell runs; the arguments here are IDs and names.
|
|
143
|
-
if (process.platform === 'win32') return [`vb ${args.map((a) => `"${a}"`).join(' ')}`, [], { env, shell: true }];
|
|
144
|
-
return ['vb', args, { env }];
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/** Runs the board's CLI and answers what it printed: parsed with `json`, bytes for a download to stdout. */
|
|
148
|
-
export function vb(args, { json = false } = {}) {
|
|
149
|
-
const [command, argv, options] = vbCommand(json ? [...args, '--json'] : args);
|
|
150
|
-
const run = spawnSync(command, argv, {
|
|
151
|
-
...options,
|
|
152
|
-
encoding: json || args[0] !== 'download' ? 'utf8' : 'buffer',
|
|
153
|
-
maxBuffer: 1 << 28,
|
|
154
|
-
});
|
|
155
|
-
if (run.error) fail(`vb: ${run.error.message}. Install @vercel/board in the project, or put vb on the PATH.`);
|
|
156
|
-
if (run.status !== 0) fail(`vb ${args.join(' ')}: ${String(run.stderr).trim() || `exit ${run.status}`}`);
|
|
157
|
-
return json ? JSON.parse(run.stdout) : run.stdout;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/** Whether the board answers now, as whoever the CLI writes as: asked of one that may be starting again. */
|
|
161
|
-
export function answers() {
|
|
162
|
-
const [command, argv, options] = vbCommand(['whoami', '--json']);
|
|
163
|
-
return spawnSync(command, argv, { ...options, encoding: 'utf8' }).status === 0;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Who the CLI writes as: `{ actor, handle, profile }`. `profile` is the name `BOARD_PROFILE` (or `--as`) gave, and
|
|
168
|
-
* `null` without one: then what's written is the person's own, as the board sees it.
|
|
169
|
-
*/
|
|
170
|
-
export const whoami = () => vb(['whoami'], { json: true });
|
|
171
|
-
|
|
172
|
-
/** A task's root message, by its ID (`68` or `#68`). */
|
|
173
|
-
export const task = (id) => vb(['read', String(id).replace(/^#/, '')], { json: true }).message;
|
|
174
|
-
|
|
175
|
-
/** An attachment's bytes. */
|
|
176
|
-
export const download = (attachment) => vb(['download', attachment.id, '-']);
|
|
177
|
-
|
|
178
|
-
const TASK = /^#?\d+$/;
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* A recording, with where it came from: `{ kept, id, replay?, task? }`. `ref` is a task's ID (its first
|
|
182
|
-
* recording, or the `nth`), a replay or recording URL, a recording's ID kept under a `.deictic/`, or a path.
|
|
183
|
-
*/
|
|
184
|
-
export async function loadRecording(ref, nth = 1) {
|
|
185
|
-
if (ref === undefined) fail('Name a recording: a task (68), a replay URL, a recording ID or a JSON file.');
|
|
186
|
-
if (TASK.test(ref)) {
|
|
187
|
-
const root = task(ref);
|
|
188
|
-
const files = root.attachments.filter((a) => /^recording-.*\.json$/.test(a.name));
|
|
189
|
-
const file = files[nth - 1];
|
|
190
|
-
if (file === undefined) fail(`Task #${root.id} has ${files.length} recording(s), not a ${nth}th.`);
|
|
191
|
-
const kept = JSON.parse(download(file).toString('utf8'));
|
|
192
|
-
const id = file.name.slice('recording-'.length, -'.json'.length);
|
|
193
|
-
const replay = root.text.match(new RegExp(`https?://\\S+/replay/${id}`))?.[0];
|
|
194
|
-
return { kept, id, replay, task: root };
|
|
195
|
-
}
|
|
196
|
-
if (/^https?:/.test(ref)) {
|
|
197
|
-
const url = new URL(ref);
|
|
198
|
-
const id = url.pathname.split('/').at(-1);
|
|
199
|
-
const json = new URL(url.pathname.replace(/\/(replay|recording)\/[^/]+$/, `/recording/${id}`), url);
|
|
200
|
-
const res = await fetch(json);
|
|
201
|
-
if (!res.ok) fail(`${json}: ${res.status} ${await res.text()}`);
|
|
202
|
-
return { kept: await res.json(), id, replay: new URL(json.pathname.replace(/\/recording\//, '/replay/'), url).href };
|
|
203
|
-
}
|
|
204
|
-
if (existsSync(ref)) return { kept: JSON.parse(readFileSync(ref, 'utf8')), id: ref.replace(/^.*[\\/]|\.json$/g, '') };
|
|
205
|
-
for (const dir of deicticDirs()) {
|
|
206
|
-
const path = join(dir, 'recordings', `${ref}.json`);
|
|
207
|
-
if (existsSync(path)) return { kept: JSON.parse(readFileSync(path, 'utf8')), id: ref };
|
|
208
|
-
}
|
|
209
|
-
fail(`No recording ${ref} in ${deicticDirs().join(', ') || 'any .deictic/ near here'}: name its task or replay URL instead.`);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/** A voice clip's audio as a file: kept under a `.deictic/`, or downloaded from `fromTask` to a temporary folder. */
|
|
213
|
-
export function voiceFile(id, fromTask) {
|
|
214
|
-
for (const dir of deicticDirs()) {
|
|
215
|
-
const voice = join(dir, 'voice');
|
|
216
|
-
const name = existsSync(voice) ? readdirSync(voice).find((f) => f.startsWith(`${id}.`)) : undefined;
|
|
217
|
-
if (name !== undefined) return join(voice, name);
|
|
218
|
-
}
|
|
219
|
-
const file = fromTask?.attachments.find((a) => a.name.startsWith(`voice-${id}.`));
|
|
220
|
-
if (file === undefined) fail(`No voice clip ${id} here${fromTask ? ` or on task #${fromTask.id}` : ''}.`);
|
|
221
|
-
const path = join(mkdtempSync(join(tmpdir(), 'deictic-voice-')), file.name);
|
|
222
|
-
// The CLI writes an attachment to a path of our choosing.
|
|
223
|
-
vb(['download', file.id, path]);
|
|
224
|
-
return path;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* The voice clips `ref` names, each `{ id, file, at, recording? }`: `at` is where it starts in its recording (0
|
|
229
|
-
* for a voice note on its own). `ref` is a task (every recording's clips and its voice notes), a recording as
|
|
230
|
-
* `loadRecording` takes one, or a clip's ID.
|
|
231
|
-
*/
|
|
232
|
-
export async function voiceClips(ref) {
|
|
233
|
-
if (ref === undefined) fail('Name a task, a recording or a voice clip.');
|
|
234
|
-
const clips = [];
|
|
235
|
-
if (TASK.test(ref)) {
|
|
236
|
-
const root = task(ref);
|
|
237
|
-
const recordings = root.attachments.filter((a) => /^recording-.*\.json$/.test(a.name));
|
|
238
|
-
const inRecordings = new Set();
|
|
239
|
-
for (let n = 1; n <= recordings.length; n++) {
|
|
240
|
-
const { kept, id } = await loadRecording(ref, n);
|
|
241
|
-
for (const c of kept.voice ?? []) {
|
|
242
|
-
inRecordings.add(c.id);
|
|
243
|
-
clips.push({ id: c.id, file: voiceFile(c.id, root), at: c.at, recording: id });
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
for (const a of root.attachments) {
|
|
247
|
-
const id = a.name.match(/^voice-(.+)\.\w+$/)?.[1];
|
|
248
|
-
if (id !== undefined && !inRecordings.has(id)) clips.push({ id, file: voiceFile(id, root), at: 0 });
|
|
249
|
-
}
|
|
250
|
-
} else if (!/^https?:/.test(ref) && !existsSync(ref) && isClip(ref)) {
|
|
251
|
-
clips.push({ id: ref, file: voiceFile(ref), at: 0 });
|
|
252
|
-
} else {
|
|
253
|
-
const { kept, id } = await loadRecording(ref);
|
|
254
|
-
for (const c of kept.voice ?? []) clips.push({ id: c.id, file: voiceFile(c.id), at: c.at, recording: id });
|
|
255
|
-
}
|
|
256
|
-
if (clips.length === 0) fail(`No voice on ${ref}.`);
|
|
257
|
-
return clips;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
const isClip = (id) =>
|
|
261
|
-
deicticDirs().some((d) => existsSync(join(d, 'voice')) && readdirSync(join(d, 'voice')).some((f) => f.startsWith(`${id}.`)));
|
|
262
|
-
|
|
263
|
-
/** Runs ffmpeg, which reads what MediaRecorder makes; its log is on stderr. */
|
|
264
|
-
export function ffmpeg(args, encoding = 'utf8') {
|
|
265
|
-
const run = spawnSync('ffmpeg', ['-hide_banner', '-nostats', ...args], { encoding, maxBuffer: 1 << 30 });
|
|
266
|
-
if (run.error) fail('Needs ffmpeg on the PATH (https://ffmpeg.org/download.html).');
|
|
267
|
-
return run;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
/** The project's own copy of a package, where a script needs one it doesn't bundle (Playwright). */
|
|
271
|
-
export async function fromProject(...names) {
|
|
272
|
-
for (const dir of upFrom()) {
|
|
273
|
-
for (const name of names) {
|
|
274
|
-
const pkg = join(dir, 'node_modules', name, 'package.json');
|
|
275
|
-
if (!existsSync(pkg)) continue;
|
|
276
|
-
const { exports, main } = JSON.parse(readFileSync(pkg, 'utf8'));
|
|
277
|
-
const entry = exports?.['.']?.import ?? exports?.['.']?.default ?? main ?? 'index.js';
|
|
278
|
-
const path = join(dirname(pkg), typeof entry === 'string' ? entry : (entry.default ?? 'index.js'));
|
|
279
|
-
return import(pathToFileURL(path).href);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
return fail(`Needs ${names.join(' or ')} in the project: npm install -D ${names[0]}`);
|
|
283
|
-
}
|