deictic 0.8.1 → 0.10.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 +81 -17
- package/README.md +1 -1
- package/dist/annotations/client.js +1 -1
- package/dist/bun.d.ts.map +1 -1
- package/dist/bun.js +26 -8
- package/dist/bun.js.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/client/index.d.ts +13 -13
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +19 -7
- package/dist/client/index.js.map +1 -1
- package/dist/next.d.ts.map +1 -1
- package/dist/next.js +45 -25
- package/dist/next.js.map +1 -1
- package/dist/react/client.d.ts +19 -0
- package/dist/react/client.d.ts.map +1 -0
- package/dist/react/client.js +504 -0
- package/dist/react/client.js.map +1 -0
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.js +1 -0
- package/dist/recommended/index.d.ts +15 -7
- package/dist/recommended/index.d.ts.map +1 -1
- package/dist/recommended/index.js +1 -1
- package/dist/recordings/client.d.ts.map +1 -1
- package/dist/recordings/client.js +48 -5
- package/dist/recordings/client.js.map +1 -1
- package/dist/screenshots/client.d.ts +9 -1
- package/dist/screenshots/client.d.ts.map +1 -1
- package/dist/screenshots/rrweb.d.ts +0 -6
- package/dist/screenshots/rrweb.d.ts.map +1 -1
- package/dist/screenshots/rrweb.js +46 -12
- package/dist/screenshots/rrweb.js.map +1 -1
- package/dist/shared/board.js +1 -1
- package/dist/shared/client.js +44 -2
- package/dist/shared/client.js.map +1 -1
- package/dist/shared/dom.js +7 -1
- package/dist/shared/dom.js.map +1 -1
- package/dist/shared/drawer.js +1 -1
- package/dist/shared/endpoints.js +15 -4
- package/dist/shared/endpoints.js.map +1 -1
- package/dist/shared/index.d.ts +11 -0
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index10.d.ts +70 -0
- package/dist/shared/index10.d.ts.map +1 -0
- package/dist/shared/index3.d.ts +11 -0
- package/dist/shared/index3.d.ts.map +1 -1
- package/dist/shared/index7.d.ts +92 -312
- package/dist/shared/index7.d.ts.map +1 -1
- package/dist/shared/index8.d.ts +324 -47
- package/dist/shared/index8.d.ts.map +1 -1
- package/dist/shared/index9.d.ts +45 -63
- package/dist/shared/index9.d.ts.map +1 -1
- package/dist/shared/init.js +15 -11
- package/dist/shared/init.js.map +1 -1
- package/dist/shared/integration.d.ts +6 -0
- package/dist/shared/integration.d.ts.map +1 -1
- package/dist/shared/integration.js +28 -1
- package/dist/shared/integration.js.map +1 -1
- package/dist/shared/marks.js +7 -1
- package/dist/shared/marks.js.map +1 -1
- package/dist/shared/package.js +3 -1
- package/dist/shared/packages.js +1 -1
- package/dist/shared/playwright.js +39 -1
- package/dist/shared/playwright.js.map +1 -1
- package/dist/shared/react.js +25 -0
- package/dist/shared/react.js.map +1 -0
- package/dist/shared/recommended.js +6 -3
- package/dist/shared/recommended.js.map +1 -1
- package/dist/shared/recording.js +80 -3
- package/dist/shared/recording.js.map +1 -1
- package/dist/shared/recordings.js +30 -2
- package/dist/shared/recordings.js.map +1 -1
- package/dist/shared/screenshots.js.map +1 -1
- package/dist/shared/src.js.map +1 -1
- package/dist/shared/task.js +1 -0
- package/dist/shared/task.js.map +1 -1
- package/dist/shared/tasks.js +11 -0
- package/dist/shared/tasks.js.map +1 -1
- package/dist/shared/vite.d.ts +1 -1
- package/dist/shared/vite.d.ts.map +1 -1
- package/dist/shared/vite.js +28 -10
- package/dist/shared/vite.js.map +1 -1
- package/dist/tailwind/client.d.ts +1 -1
- package/dist/tailwind/index.d.ts +1 -1
- package/dist/tasks/client.d.ts +1 -1
- package/dist/tasks/client.js +45 -19
- package/dist/tasks/client.js.map +1 -1
- package/dist/tasks/index.d.ts +1 -1
- package/dist/voice/client.d.ts +1 -1
- package/dist/voice/client.js +1 -1
- package/dist/voice/index.d.ts +1 -1
- package/dist/webpack.d.ts +4 -0
- package/dist/webpack.d.ts.map +1 -1
- package/dist/webpack.js +37 -15
- package/dist/webpack.js.map +1 -1
- package/package.json +25 -1
- package/src/bun.ts +32 -8
- package/src/cli/bun.ts +2 -2
- package/src/cli/init.ts +14 -9
- package/src/cli/recording.ts +90 -4
- package/src/cli/task.ts +4 -0
- package/src/cli.ts +13 -6
- package/src/client/dom.ts +14 -0
- package/src/client/index.ts +25 -14
- package/src/index.ts +11 -0
- package/src/next.ts +34 -15
- package/src/plugins/react/client.ts +162 -0
- package/src/plugins/react/index.ts +130 -0
- package/src/plugins/react/renders.ts +219 -0
- package/src/plugins/react/serialize.ts +139 -0
- package/src/plugins/react/timeline.ts +143 -0
- package/src/plugins/recommended/index.ts +17 -5
- package/src/plugins/recordings/client.ts +64 -4
- package/src/plugins/recordings/marks.ts +7 -0
- package/src/plugins/recordings/replay.ts +30 -2
- package/src/plugins/screenshots/client.ts +42 -2
- package/src/plugins/screenshots/index.ts +11 -0
- package/src/plugins/screenshots/playwright.ts +65 -1
- package/src/plugins/screenshots/rrweb.ts +55 -28
- package/src/plugins/screenshots/states.ts +26 -0
- package/src/plugins/tasks/client.ts +41 -6
- package/src/plugins/tasks/composer.ts +24 -7
- package/src/plugins/tasks/index.ts +16 -2
- package/src/tools/integration.ts +33 -0
- package/src/tools/source.ts +14 -2
- package/src/vite.ts +31 -10
- package/src/webpack.ts +48 -16
package/dist/tasks/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as local, S as LocalOptions, _ as TasksOptions, a as Kept, b as tasks, c as Model, d as Placed, f as Removed, g as TaskBoard, h as TaskAdded, i as Edited, l as Op, m as Task, n as Answer, o as Listed, p as Reply, r as Attached, s as Marks, t as Added, u as Place, v as Thread, x as LocalBoard, y as Which } from "../shared/
|
|
1
|
+
import { C as local, S as LocalOptions, _ as TasksOptions, a as Kept, b as tasks, c as Model, d as Placed, f as Removed, g as TaskBoard, h as TaskAdded, i as Edited, l as Op, m as Task, n as Answer, o as Listed, p as Reply, r as Attached, s as Marks, t as Added, u as Place, v as Thread, x as LocalBoard, y as Which } from "../shared/index8.js";
|
|
2
2
|
export { Added, Answer, Attached, Edited, Kept, Listed, type LocalBoard, type LocalOptions, Marks, Model, Op, Place, Placed, Removed, Reply, Task, TaskAdded, TaskBoard, TasksOptions, Thread, Which, tasks as default, tasks, local };
|
package/dist/voice/client.d.ts
CHANGED
package/dist/voice/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { f as toolButton } from "../shared/dom.js";
|
|
2
2
|
import { n as playMark, r as trayed } from "../shared/drawer.js";
|
|
3
3
|
import { n as liveWaveform } from "../shared/waveform.js";
|
|
4
4
|
import { n as defineClientPlugin } from "../shared/src.js";
|
package/dist/voice/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as VoiceOptions, i as Voice, n as Clips, o as voice, r as Take, t as Clip } from "../shared/
|
|
1
|
+
import { a as VoiceOptions, i as Voice, n as Clips, o as voice, r as Take, t as Clip } from "../shared/index9.js";
|
|
2
2
|
export { Clip, Clips, Take, Voice, VoiceOptions, voice as default, voice };
|
package/dist/webpack.d.ts
CHANGED
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
* webpack-dev-server and Rspack's both read), and a place opens with `launch-editor`, as webpack has no
|
|
10
10
|
* launcher of its own. Where the dev server is started by hand, or by Rsbuild, `middleware` is the
|
|
11
11
|
* endpoints to mount there.
|
|
12
|
+
*
|
|
13
|
+
* A compiler may be given deictic more than once: the app's, and one a package applied with its own plugin
|
|
14
|
+
* (`defaults`). The first applied adds the rule and the middleware, and every one writes the client again with all
|
|
15
|
+
* of their options merged (`merge`), so the last applied writes it whole before the compiler runs.
|
|
12
16
|
*/
|
|
13
17
|
import { IncomingMessage, ServerResponse } from "node:http";
|
|
14
18
|
import { t as DeicticOptions } from "./shared/integration.js";
|
package/dist/webpack.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpack.d.ts","names":[],"sources":["../src/webpack.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"webpack.d.ts","names":[],"sources":["../src/webpack.ts"],"mappings":";;;;;;;;;;;;;;;;;;iBAwBiB,8BAA8B;;EAE7C;;EAEA;;KAGG,cAAc,KAAK,iBAAiB,KAAK,gBAAgB;KACzD;EAAiB;EAAc,YAAY;IAAe;;UAGrD;EACR;EACA;IACE;IACA;IACA;MAAU;;IACV;MAAc,oBAAoB,aAAa,aAAa,oBAAoB;QAAgB;;;qBAkBvF;;EAMX,YAAY,UAAS;;MAajB,cAAc;EAuBlB,MAAM,UAAU;;;qBAmCL,UAAO,UAAa,0BAAqB"}
|
package/dist/webpack.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as nodeMiddleware, t as endpoints } from "./shared/endpoints.js";
|
|
2
|
-
import {
|
|
2
|
+
import { c as writeClient, g as JSX, o as merge, s as prepare, t as beside } from "./shared/integration.js";
|
|
3
3
|
// src/tools/editor.ts
|
|
4
4
|
async function openInEditor(path, { line, column }) {
|
|
5
5
|
const launcher = await import("launch-editor").catch(() => void 0);
|
|
@@ -17,34 +17,56 @@ async function openInEditor(path, { line, column }) {
|
|
|
17
17
|
const loaderPath = beside(import.meta.url, "loader");
|
|
18
18
|
/** Whether a target runs in a browser: webpack's default does, as do `web` and `browserslist`; Node's and Electron's main don't. */
|
|
19
19
|
const forBrowser = (target) => target === void 0 || [target].flat().some((t) => t !== false && !/^(async-)?node|^electron-main|^electron-preload/.test(t));
|
|
20
|
+
const appliedTo = /* @__PURE__ */ new WeakMap();
|
|
20
21
|
var DeicticPlugin = class {
|
|
21
22
|
#options;
|
|
22
|
-
#
|
|
23
|
-
#shortcut;
|
|
23
|
+
#applied;
|
|
24
24
|
#middleware;
|
|
25
25
|
#root = "";
|
|
26
26
|
constructor(options = {}) {
|
|
27
27
|
this.#options = options;
|
|
28
|
-
|
|
28
|
+
prepare(options);
|
|
29
|
+
}
|
|
30
|
+
/** The options of every deictic the compiler was given, merged. */
|
|
31
|
+
#merged() {
|
|
32
|
+
const given = this.#applied?.given ?? [this.#options];
|
|
33
|
+
return given.length === 1 ? given[0] : merge(given);
|
|
29
34
|
}
|
|
30
35
|
/** The endpoints as Node middleware, once the plugin is applied: for a dev server started by hand. */
|
|
31
36
|
get middleware() {
|
|
37
|
+
const applied = this.#applied;
|
|
38
|
+
if (applied === void 0) throw new Error("deictic: give the plugin to the compiler before mounting its middleware");
|
|
39
|
+
if (applied.first !== this) return applied.first.middleware;
|
|
32
40
|
if (this.#middleware !== void 0) return this.#middleware;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
let handle;
|
|
42
|
+
return this.#middleware = (req, res, next) => {
|
|
43
|
+
if (handle === void 0) {
|
|
44
|
+
const merged = this.#merged();
|
|
45
|
+
handle = nodeMiddleware(endpoints({
|
|
46
|
+
root: this.#root,
|
|
47
|
+
plugins: prepare(merged).plugins,
|
|
48
|
+
base: merged.base ?? "/",
|
|
49
|
+
open: (path, loc) => openInEditor(path, loc)
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
handle(req, res, next);
|
|
53
|
+
};
|
|
42
54
|
}
|
|
43
55
|
apply(compiler) {
|
|
44
56
|
if (compiler.options.mode !== "development") return;
|
|
45
|
-
|
|
57
|
+
let applied = appliedTo.get(compiler);
|
|
58
|
+
if (applied === void 0) appliedTo.set(compiler, applied = {
|
|
59
|
+
given: [],
|
|
60
|
+
first: this
|
|
61
|
+
});
|
|
62
|
+
applied.given.push(this.#options);
|
|
63
|
+
this.#applied = applied;
|
|
64
|
+
const merged = this.#merged();
|
|
65
|
+
const { plugins, shortcut } = prepare(merged);
|
|
66
|
+
this.#root = merged.root ?? compiler.context;
|
|
46
67
|
const browser = forBrowser(compiler.options.target);
|
|
47
|
-
const client = browser ? writeClient(this.#root,
|
|
68
|
+
const client = browser ? writeClient(this.#root, plugins, merged.base ?? "/", shortcut) : void 0;
|
|
69
|
+
if (applied.first !== this) return;
|
|
48
70
|
const options = {
|
|
49
71
|
root: this.#root,
|
|
50
72
|
...client === void 0 ? {} : { client }
|
package/dist/webpack.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpack.js","names":[],"sources":["../src/tools/editor.ts","../src/webpack.ts"],"sourcesContent":["/**\n * Opens a place in the editor, for a dev server without a launcher of its own (webpack's, Rspack's):\n * `launch-editor`, which Vite's own launcher uses, finds the editor that's running or the one `EDITOR`\n * names. An optional peer, imported when first asked.\n */\n\nimport type { Loc } from '#src/index.ts';\n\nexport async function openInEditor(path: string, { line, column }: Loc): Promise<Response> {\n const launcher = await import('launch-editor').catch(() => undefined);\n if (launcher === undefined)\n return new Response('deictic opens files with launch-editor here: add it to your devDependencies', { status: 501 });\n return new Promise((done) => {\n let failed = false;\n launcher.default(`${path}:${line}:${column}`, (_, message) => {\n failed = true;\n done(new Response(`${message ?? \"the editor didn't open\"}: set EDITOR to your editor's command`, { status: 500 }));\n });\n // launch-editor reports a failure as it happens, and nothing on success.\n setTimeout(() => failed || done(new Response(null, { status: 204 })), 50);\n });\n}\n","/**\n * `deictic/webpack`: deictic in webpack's dev server, or Rspack's (`@rspack/core` takes the same\n * plugin). Nothing runs out of development mode.\n *\n * A loader (`loader.ts`) runs `pre` on the project's JSX modules, marking each host element with its\n * place in the source as written, and in a build for the browser appending the import of the client\n * module, which webpack has no virtual module for, so it's written to `.deictic/client.js`. The\n * endpoints go in front of the dev server's own middleware (`devServer.setupMiddlewares`, which\n * webpack-dev-server and Rspack's both read), and a place opens with `launch-editor`, as webpack has no\n * launcher of its own. Where the dev server is started by hand, or by Rsbuild, `middleware` is the\n * endpoints to mount there.\n
|
|
1
|
+
{"version":3,"file":"webpack.js","names":[],"sources":["../src/tools/editor.ts","../src/webpack.ts"],"sourcesContent":["/**\n * Opens a place in the editor, for a dev server without a launcher of its own (webpack's, Rspack's):\n * `launch-editor`, which Vite's own launcher uses, finds the editor that's running or the one `EDITOR`\n * names. An optional peer, imported when first asked.\n */\n\nimport type { Loc } from '#src/index.ts';\n\nexport async function openInEditor(path: string, { line, column }: Loc): Promise<Response> {\n const launcher = await import('launch-editor').catch(() => undefined);\n if (launcher === undefined)\n return new Response('deictic opens files with launch-editor here: add it to your devDependencies', { status: 501 });\n return new Promise((done) => {\n let failed = false;\n launcher.default(`${path}:${line}:${column}`, (_, message) => {\n failed = true;\n done(new Response(`${message ?? \"the editor didn't open\"}: set EDITOR to your editor's command`, { status: 500 }));\n });\n // launch-editor reports a failure as it happens, and nothing on success.\n setTimeout(() => failed || done(new Response(null, { status: 204 })), 50);\n });\n}\n","/**\n * `deictic/webpack`: deictic in webpack's dev server, or Rspack's (`@rspack/core` takes the same\n * plugin). Nothing runs out of development mode.\n *\n * A loader (`loader.ts`) runs `pre` on the project's JSX modules, marking each host element with its\n * place in the source as written, and in a build for the browser appending the import of the client\n * module, which webpack has no virtual module for, so it's written to `.deictic/client.js`. The\n * endpoints go in front of the dev server's own middleware (`devServer.setupMiddlewares`, which\n * webpack-dev-server and Rspack's both read), and a place opens with `launch-editor`, as webpack has no\n * launcher of its own. Where the dev server is started by hand, or by Rsbuild, `middleware` is the\n * endpoints to mount there.\n *\n * A compiler may be given deictic more than once: the app's, and one a package applied with its own plugin\n * (`defaults`). The first applied adds the rule and the middleware, and every one writes the client again with all\n * of their options merged (`merge`), so the last applied writes it whole before the compiler runs.\n */\nimport type { IncomingMessage, ServerResponse } from 'node:http';\n\nimport type { LoaderOptions } from './loader.ts';\nimport { openInEditor } from './tools/editor.ts';\nimport { endpoints, nodeMiddleware } from './tools/endpoints.ts';\nimport { beside, type DeicticOptions, merge, prepare, writeClient } from './tools/integration.ts';\nimport { JSX } from './tools/locate.ts';\n\nexport interface DeicticWebpackOptions extends DeicticOptions {\n /** The project's root, which marks and edits are from: the compiler's `context` by default. */\n root?: string;\n /** The path the page is served under, ending in `/`: `/` by default. */\n base?: string;\n}\n\ntype Middleware = (req: IncomingMessage, res: ServerResponse, next: () => void) => void;\ntype Middlewares = ({ name: string; middleware: Middleware } | Middleware)[];\n\n/** What the plugin reads and sets of a webpack or Rspack compiler. */\ninterface Compiler {\n context: string;\n options: {\n mode?: string;\n target?: string | string[] | false;\n module: { rules: unknown[] };\n devServer?: { setupMiddlewares?: (middlewares: Middlewares, server: unknown) => Middlewares } & Record<string, unknown>;\n };\n}\n\nconst loaderPath = beside(import.meta.url, 'loader');\n\n/** Whether a target runs in a browser: webpack's default does, as do `web` and `browserslist`; Node's and Electron's main don't. */\nconst forBrowser = (target: Compiler['options']['target']) =>\n target === undefined || [target].flat().some((t) => t !== false && !/^(async-)?node|^electron-main|^electron-preload/.test(t));\n\n/** Every deictic one compiler was given, and the first of them, which serves the endpoints. */\ninterface Applied {\n given: DeicticWebpackOptions[];\n first: DeicticPlugin;\n}\n\nconst appliedTo = new WeakMap<Compiler, Applied>();\n\nexport class DeicticPlugin {\n readonly #options: DeicticWebpackOptions;\n #applied: Applied | undefined;\n #middleware: Middleware | undefined;\n #root = '';\n\n constructor(options: DeicticWebpackOptions = {}) {\n this.#options = options;\n // Now, so a wrong set of plugins stops the dev server as it starts, rather than the page.\n prepare(options);\n }\n\n /** The options of every deictic the compiler was given, merged. */\n #merged(): DeicticWebpackOptions {\n const given = this.#applied?.given ?? [this.#options];\n return given.length === 1 ? given[0]! : merge(given);\n }\n\n /** The endpoints as Node middleware, once the plugin is applied: for a dev server started by hand. */\n get middleware(): Middleware {\n const applied = this.#applied;\n if (applied === undefined) throw new Error('deictic: give the plugin to the compiler before mounting its middleware');\n if (applied.first !== this) return applied.first.middleware;\n if (this.#middleware !== undefined) return this.#middleware;\n let handle: Middleware | undefined;\n // Made at the first request, once every deictic of the compiler has been applied.\n return (this.#middleware = (req, res, next) => {\n if (handle === undefined) {\n const merged = this.#merged();\n handle = nodeMiddleware(\n endpoints({\n root: this.#root,\n plugins: prepare(merged).plugins,\n base: merged.base ?? '/',\n open: (path, loc) => openInEditor(path, loc),\n }),\n );\n }\n handle(req, res, next);\n });\n }\n\n apply(compiler: Compiler): void {\n // Development only: a build without a mode is webpack's production one.\n if (compiler.options.mode !== 'development') return;\n let applied = appliedTo.get(compiler);\n if (applied === undefined) appliedTo.set(compiler, (applied = { given: [], first: this }));\n applied.given.push(this.#options);\n this.#applied = applied;\n const merged = this.#merged();\n const { plugins, shortcut } = prepare(merged);\n this.#root = merged.root ?? compiler.context;\n const browser = forBrowser(compiler.options.target);\n const client = browser ? writeClient(this.#root, plugins, merged.base ?? '/', shortcut) : undefined;\n if (applied.first !== this) return;\n const options: LoaderOptions = { root: this.#root, ...(client === undefined ? {} : { client }) };\n // First, and `pre`, so it sees the source as written whatever the app's own rules do.\n compiler.options.module.rules.unshift({\n test: JSX,\n exclude: /[\\\\/]node_modules[\\\\/]/,\n enforce: 'pre',\n use: [{ loader: loaderPath, options }],\n });\n if (!browser) return;\n\n const devServer = (compiler.options.devServer ??= {});\n const theirs = devServer.setupMiddlewares;\n devServer.setupMiddlewares = (middlewares, server) => {\n const all = theirs === undefined ? middlewares : theirs(middlewares, server);\n // In front of the dev server's own, which would answer `/__deictic/` with the page or a 404.\n all.unshift({ name: 'deictic', middleware: this.middleware });\n return all;\n };\n }\n}\n\n/** The plugin, as a function: `plugins: [deictic({ plugins: [tailwind()] })]`. */\nexport const deictic = (options: DeicticWebpackOptions = {}) => new DeicticPlugin(options);\n\nexport default deictic;\n"],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "deictic",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Point at an element in your running app and leave a task about it for your agent.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"annotations",
|
|
@@ -204,6 +204,20 @@
|
|
|
204
204
|
"default": "./dist/network/client.js"
|
|
205
205
|
}
|
|
206
206
|
},
|
|
207
|
+
"./react": {
|
|
208
|
+
"deictic@dev": "./src/plugins/react/index.ts",
|
|
209
|
+
"default": {
|
|
210
|
+
"types": "./dist/react/index.d.ts",
|
|
211
|
+
"default": "./dist/react/index.js"
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
"./react/client": {
|
|
215
|
+
"deictic@dev": "./src/plugins/react/client.ts",
|
|
216
|
+
"default": {
|
|
217
|
+
"types": "./dist/react/client.d.ts",
|
|
218
|
+
"default": "./dist/react/client.js"
|
|
219
|
+
}
|
|
220
|
+
},
|
|
207
221
|
"./recommended": {
|
|
208
222
|
"deictic@dev": "./src/plugins/recommended/index.ts",
|
|
209
223
|
"default": {
|
|
@@ -267,11 +281,13 @@
|
|
|
267
281
|
"@rrweb/rrweb-plugin-network-record": "2.2.2",
|
|
268
282
|
"@rspack/core": "2.3.3",
|
|
269
283
|
"@types/bun": "^1.4.5",
|
|
284
|
+
"@types/react": "^19.3.0",
|
|
270
285
|
"@vercel/board": "^0.54.0",
|
|
271
286
|
"@vitejs/plugin-react": "^6.3.0",
|
|
272
287
|
"astro": "^7.4.13",
|
|
273
288
|
"babel-loader": "^10.1.1",
|
|
274
289
|
"babel-plugin-react-compiler": "^1.0.0",
|
|
290
|
+
"bippy": "0.7.3",
|
|
275
291
|
"launch-editor": "2.14.2",
|
|
276
292
|
"modern-screenshot": "^4.7.0",
|
|
277
293
|
"next": "^16.4.6",
|
|
@@ -296,10 +312,12 @@
|
|
|
296
312
|
"@rspack/core": ">=1",
|
|
297
313
|
"@vercel/board": ">=0.53.0",
|
|
298
314
|
"astro": ">=5",
|
|
315
|
+
"bippy": "^0.7.3",
|
|
299
316
|
"launch-editor": "^2.9.0",
|
|
300
317
|
"modern-screenshot": "^4.7.0",
|
|
301
318
|
"next": ">=16",
|
|
302
319
|
"playwright-core": "^1.50.0",
|
|
320
|
+
"react": ">=18",
|
|
303
321
|
"rrweb": "^2.2.2",
|
|
304
322
|
"rrweb-player": "^2.2.2",
|
|
305
323
|
"rrweb-snapshot": "^2.2.2",
|
|
@@ -322,6 +340,9 @@
|
|
|
322
340
|
"astro": {
|
|
323
341
|
"optional": true
|
|
324
342
|
},
|
|
343
|
+
"bippy": {
|
|
344
|
+
"optional": true
|
|
345
|
+
},
|
|
325
346
|
"launch-editor": {
|
|
326
347
|
"optional": true
|
|
327
348
|
},
|
|
@@ -334,6 +355,9 @@
|
|
|
334
355
|
"playwright-core": {
|
|
335
356
|
"optional": true
|
|
336
357
|
},
|
|
358
|
+
"react": {
|
|
359
|
+
"optional": true
|
|
360
|
+
},
|
|
337
361
|
"rrweb": {
|
|
338
362
|
"optional": true
|
|
339
363
|
},
|
package/src/bun.ts
CHANGED
|
@@ -15,13 +15,18 @@
|
|
|
15
15
|
* // server.ts
|
|
16
16
|
* import tools from './deictic.ts';
|
|
17
17
|
* Bun.serve({ routes: { ...tools.routes, '/*': index }, development: true });
|
|
18
|
+
*
|
|
19
|
+
* bunfig may name deictic more than once: the app's, and a package's that adds its own plugin (`defaults`), as
|
|
20
|
+
* prosebook's does. Each made in the process for a root is kept (`made`), the first set up marks the modules, and
|
|
21
|
+
* the client and the endpoints, made when first needed, load all of their options merged (`merge`); any of them
|
|
22
|
+
* has the routes.
|
|
18
23
|
*/
|
|
19
24
|
import { resolve } from 'node:path';
|
|
20
25
|
|
|
21
26
|
import type { BunPlugin } from 'bun';
|
|
22
27
|
|
|
23
28
|
import { endpoints } from './tools/endpoints.ts';
|
|
24
|
-
import { type DeicticOptions, importOf, mark, prepare, writeClient } from './tools/integration.ts';
|
|
29
|
+
import { type DeicticOptions, importOf, mark, merge, prepare, writeClient } from './tools/integration.ts';
|
|
25
30
|
import { JSX } from './tools/locate.ts';
|
|
26
31
|
|
|
27
32
|
export interface DeicticBunOptions extends DeicticOptions {
|
|
@@ -34,15 +39,28 @@ export type DeicticBunPlugin = BunPlugin & {
|
|
|
34
39
|
routes: Record<string, (req: Request) => Promise<Response>>;
|
|
35
40
|
};
|
|
36
41
|
|
|
42
|
+
/** Every deictic made in the process, by its root: what it was given, whether one set up its marking, and its endpoints. */
|
|
43
|
+
interface Made {
|
|
44
|
+
given: DeicticBunOptions[];
|
|
45
|
+
marking: boolean;
|
|
46
|
+
handle?: (req: Request) => Promise<Response | undefined>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const made = new Map<string, Made>();
|
|
50
|
+
|
|
37
51
|
export function deictic(options: DeicticBunOptions = {}): DeicticBunPlugin {
|
|
38
52
|
// Now, so a wrong set of plugins stops the dev server as it starts, rather than the page.
|
|
39
|
-
|
|
53
|
+
prepare(options);
|
|
40
54
|
const root = resolve(options.root ?? process.cwd());
|
|
41
|
-
let
|
|
55
|
+
let all = made.get(root);
|
|
56
|
+
if (all === undefined) made.set(root, (all = { given: [], marking: false }));
|
|
57
|
+
all.given.push(options);
|
|
58
|
+
const shared = all;
|
|
59
|
+
const merged = () => prepare(shared.given.length === 1 ? shared.given[0]! : merge(shared.given));
|
|
42
60
|
const route = async (req: Request) => {
|
|
43
|
-
handle ??= endpoints({
|
|
61
|
+
shared.handle ??= endpoints({
|
|
44
62
|
root,
|
|
45
|
-
plugins,
|
|
63
|
+
plugins: merged().plugins,
|
|
46
64
|
open: (path, { line, column }) => {
|
|
47
65
|
try {
|
|
48
66
|
Bun.openInEditor(path, { line, column });
|
|
@@ -54,7 +72,7 @@ export function deictic(options: DeicticBunOptions = {}): DeicticBunPlugin {
|
|
|
54
72
|
}
|
|
55
73
|
},
|
|
56
74
|
});
|
|
57
|
-
return (await handle(req)) ?? new Response(null, { status: 404 });
|
|
75
|
+
return (await shared.handle(req)) ?? new Response(null, { status: 404 });
|
|
58
76
|
};
|
|
59
77
|
|
|
60
78
|
return {
|
|
@@ -62,14 +80,20 @@ export function deictic(options: DeicticBunOptions = {}): DeicticBunPlugin {
|
|
|
62
80
|
routes: { '/__deictic/*': route },
|
|
63
81
|
setup(build) {
|
|
64
82
|
// A build names its entry points; the dev server's bundler doesn't.
|
|
65
|
-
if ('entrypoints' in build.config) return;
|
|
66
|
-
|
|
83
|
+
if ('entrypoints' in build.config || shared.marking) return;
|
|
84
|
+
shared.marking = true;
|
|
85
|
+
let client: string | undefined;
|
|
67
86
|
// Bun names the side it loads a module for (undocumented, and not in Bun's types); the dev server's is the browser's.
|
|
68
87
|
const forBrowser = (args: object) => !('side' in args) || args.side === 'client';
|
|
69
88
|
build.onLoad({ filter: JSX }, async (args) => {
|
|
70
89
|
// A dependency's is left to Bun, unread.
|
|
71
90
|
if (/[\\/]node_modules[\\/]/.test(args.path)) return undefined;
|
|
72
91
|
const code = await Bun.file(args.path).text();
|
|
92
|
+
// Written as the first module loads, once bunfig's every deictic has been made.
|
|
93
|
+
if (client === undefined) {
|
|
94
|
+
const { plugins, shortcut } = merged();
|
|
95
|
+
client = writeClient(root, plugins, '/', shortcut);
|
|
96
|
+
}
|
|
73
97
|
const marked = mark(code, args.path, root, forBrowser(args) ? importOf(client, args.path) : '');
|
|
74
98
|
if (marked === undefined) return undefined;
|
|
75
99
|
return { contents: marked.code, loader: args.path.endsWith('tsx') ? 'tsx' : 'jsx' };
|
package/src/cli/bun.ts
CHANGED
|
@@ -16,11 +16,11 @@ import { addFirst, addImports, eolOf } from './edit.ts';
|
|
|
16
16
|
export const MODULE = 'deictic.plugin.ts';
|
|
17
17
|
|
|
18
18
|
export const PLUGIN = `import { deictic } from 'deictic/bun';
|
|
19
|
-
import {
|
|
19
|
+
import { deicticRecommended } from 'deictic/recommended';
|
|
20
20
|
|
|
21
21
|
// One module for both: bunfig.toml names it as the dev server's bundler plugin, and the server spreads its routes,
|
|
22
22
|
// deictic's endpoints, into its own.
|
|
23
|
-
export default deictic({ plugins:
|
|
23
|
+
export default deictic({ plugins: deicticRecommended() });
|
|
24
24
|
`;
|
|
25
25
|
|
|
26
26
|
const SOURCE = /\.[cm]?[jt]sx?$/;
|
package/src/cli/init.ts
CHANGED
|
@@ -12,9 +12,9 @@ import { createInterface } from 'node:readline/promises';
|
|
|
12
12
|
import MagicString from 'magic-string';
|
|
13
13
|
import { type Expression, type ObjectExpression, parseSync, type Program } from 'oxc-parser';
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import { deicticRecommended } from '#src/plugins/recommended/index.ts';
|
|
16
16
|
|
|
17
|
-
import { installCommand, packageManager, readJson, runnerOf } from '#src/tools/packages.ts';
|
|
17
|
+
import { installCommand, installed, packageManager, readJson, runnerOf } from '#src/tools/packages.ts';
|
|
18
18
|
|
|
19
19
|
import { fail } from './board.ts';
|
|
20
20
|
import { addToBunfig, addToServer, BY_HAND, MODULE, PLUGIN, serverOf } from './bun.ts';
|
|
@@ -37,7 +37,7 @@ interface Setup {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
const extensions = (base: string) => ['ts', 'mts', 'js', 'mjs', 'cts', 'cjs'].map((e) => `${base}.${e}`);
|
|
40
|
-
const PLUGINS = '{ plugins:
|
|
40
|
+
const PLUGINS = '{ plugins: deicticRecommended() }';
|
|
41
41
|
|
|
42
42
|
const SETUPS: Record<Exclude<Bundler, 'bun'>, Setup> = {
|
|
43
43
|
next: {
|
|
@@ -109,9 +109,14 @@ export function bundlerOf(root: string): Bundler | undefined {
|
|
|
109
109
|
return undefined;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
/**
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
/**
|
|
113
|
+
* What the recommended setup imports, for the bundler and the project: launch-editor opens files under webpack, which
|
|
114
|
+
* has no launcher, and React's state is read only where it has React.
|
|
115
|
+
*/
|
|
116
|
+
export function packagesFor(bundler: Bundler | undefined, root: string): string[] {
|
|
117
|
+
// Named in package.json and not installed yet, in a fresh checkout, or installed from a workspace's.
|
|
118
|
+
const react = dependenciesOf(root).has('react') || installed(root, 'react');
|
|
119
|
+
const plugins = deicticRecommended({ react: react ? {} : false }).flatMap((p) => p.packages ?? []);
|
|
115
120
|
return ['deictic', ...plugins, ...(bundler === 'webpack' || bundler === 'rspack' ? ['launch-editor'] : [])];
|
|
116
121
|
}
|
|
117
122
|
|
|
@@ -197,7 +202,7 @@ export function addToConfig(bundler: Exclude<Bundler, 'bun'>, file: string, code
|
|
|
197
202
|
}
|
|
198
203
|
|
|
199
204
|
const lines: [string, string][] = [
|
|
200
|
-
['{
|
|
205
|
+
['{ deicticRecommended }', 'deictic/recommended'],
|
|
201
206
|
[`{ ${setup.name} }`, setup.from],
|
|
202
207
|
];
|
|
203
208
|
addImports(out, program, code, lines, exported.commonjs);
|
|
@@ -259,7 +264,7 @@ export async function init(options: InitOptions): Promise<void> {
|
|
|
259
264
|
const bundler = bundlerOf(root);
|
|
260
265
|
const has = dependenciesOf(root);
|
|
261
266
|
|
|
262
|
-
const wanted = packagesFor(bundler).filter((p) => !has.has(p));
|
|
267
|
+
const wanted = packagesFor(bundler, root).filter((p) => !has.has(p));
|
|
263
268
|
const command = installCommand(manager, wanted, root);
|
|
264
269
|
if (wanted.length === 0) {
|
|
265
270
|
log('deictic: its packages are installed');
|
|
@@ -298,7 +303,7 @@ function configure(root: string, bundler: Bundler | undefined, dryRun: boolean,
|
|
|
298
303
|
}
|
|
299
304
|
const setup = SETUPS[bundler];
|
|
300
305
|
const file = setup.files.map((f) => join(root, f)).find((f) => existsSync(f));
|
|
301
|
-
const imports = `import {
|
|
306
|
+
const imports = `import { deicticRecommended } from 'deictic/recommended';\nimport { ${setup.name} } from '${setup.from}';`;
|
|
302
307
|
if (file === undefined) {
|
|
303
308
|
log(`deictic: no ${setup.files[0]} here: add deictic to your ${bundler} config:\n\n${imports}\n${setup.snippet}\n`);
|
|
304
309
|
return;
|
package/src/cli/recording.ts
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `deictic recording`: a recording as a timeline: the page, each click and field typed in (with the element's place
|
|
3
3
|
* in the source), scrolls, resizes, each change to the marks (what was drawn, where, and the notes' text), the voice
|
|
4
|
-
* clips, the page's console and its requests where the project records them,
|
|
5
|
-
*
|
|
4
|
+
* clips, the page's console and its requests where the project records them, React's commits where the recording had
|
|
5
|
+
* them on, and the end. Or the part of it asked
|
|
6
|
+
* for: `--only`, `--problems`, `--from`, `--to`, `--around`, `--grep`, `--all`, and `--full` for all of each line.
|
|
7
|
+
*
|
|
8
|
+
* Asked for nothing, it's what the person did and what went wrong: the page's requests, its console's lines and
|
|
9
|
+
* React's commits, which a dev server makes hundreds of, are left out where they're not a problem, and counted at
|
|
10
|
+
* the end with what lists them. An agent asks for them where the task needs them. `--json` has every line.
|
|
6
11
|
*/
|
|
7
12
|
import { relative } from 'node:path';
|
|
8
13
|
|
|
9
14
|
import type { Shape } from '#src/plugins/annotations/index.ts';
|
|
15
|
+
import type { Commit } from '#src/plugins/react/index.ts';
|
|
16
|
+
import { REACT } from '#src/plugins/recordings/marks.ts';
|
|
10
17
|
|
|
11
18
|
import { clock, fail, ME } from './board.ts';
|
|
12
19
|
import { loadRecording } from './find.ts';
|
|
@@ -56,7 +63,7 @@ interface Data {
|
|
|
56
63
|
trace?: string[];
|
|
57
64
|
requests?: Request[];
|
|
58
65
|
isInitial?: boolean;
|
|
59
|
-
};
|
|
66
|
+
} & Partial<Commit> & { on?: boolean };
|
|
60
67
|
source?: number;
|
|
61
68
|
type?: number;
|
|
62
69
|
id?: number;
|
|
@@ -91,6 +98,57 @@ interface Line {
|
|
|
91
98
|
before?: string;
|
|
92
99
|
marks?: Shape[];
|
|
93
100
|
node?: number;
|
|
101
|
+
/** A React commit entry's components, one line each: under it with `--full`. */
|
|
102
|
+
details?: string[];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The kinds left out of a timeline asked for nothing in particular, where a line of them isn't a problem: a dev
|
|
107
|
+
* server's page makes hundreds of requests (its modules, its hot updates), logs what its tools do, and commits
|
|
108
|
+
* React each frame it animates. Counted, with what lists them.
|
|
109
|
+
*/
|
|
110
|
+
const QUIET = [
|
|
111
|
+
{ kind: 'request', noun: 'request' },
|
|
112
|
+
{ kind: 'console', noun: 'console line' },
|
|
113
|
+
{ kind: 'react', noun: 'React line' },
|
|
114
|
+
];
|
|
115
|
+
|
|
116
|
+
/** A commit past this took longer than a frame: a problem, as it's what makes a page stutter. */
|
|
117
|
+
const FRAME = 16;
|
|
118
|
+
|
|
119
|
+
const ms = (n: number) => `${n < 10 ? n.toFixed(1) : round(n)}ms`;
|
|
120
|
+
|
|
121
|
+
/** A React commit entry, as a line: how long, why it ran, and what rendered, the slowest first. */
|
|
122
|
+
function commitLine(c: Partial<Commit>): Pick<Line, 'text' | 'details' | 'problem'> {
|
|
123
|
+
const components = c.components ?? [];
|
|
124
|
+
const many = (c.commits ?? 1) > 1;
|
|
125
|
+
const head = [
|
|
126
|
+
c.priority,
|
|
127
|
+
many ? `${c.commits} commits${c.over === undefined ? '' : ` over ${(c.over / 1000).toFixed(1)}s`}` : undefined,
|
|
128
|
+
c.slowest === undefined ? undefined : `slowest ${ms(c.slowest)}`,
|
|
129
|
+
]
|
|
130
|
+
.filter(Boolean)
|
|
131
|
+
.join(', ');
|
|
132
|
+
// One slow commit is what makes a page stutter, not many quick ones.
|
|
133
|
+
const slow = c.slowest ?? c.ms;
|
|
134
|
+
const named = components.map(
|
|
135
|
+
(r) => `${r.name}${(r.count ?? 1) > 1 ? ` ×${r.count}` : ''}${r.selfMs === undefined ? '' : ` ${ms(r.selfMs)}`} (${r.why})`,
|
|
136
|
+
);
|
|
137
|
+
const rest = c.more === undefined ? '' : named.length === 0 ? `${c.more} components` : `, and ${c.more} more`;
|
|
138
|
+
return {
|
|
139
|
+
text: `${c.ms === undefined ? 'commit' : ms(c.ms)}${head === '' ? '' : ` (${head})`}: ${named.join(', ')}${rest}`,
|
|
140
|
+
details: components.map((r) =>
|
|
141
|
+
[
|
|
142
|
+
`${r.name}${(r.count ?? 1) > 1 ? ` ×${r.count}` : ''}`,
|
|
143
|
+
r.at,
|
|
144
|
+
r.ms === undefined ? undefined : `${ms(r.ms)} with what it rendered`,
|
|
145
|
+
r.why,
|
|
146
|
+
]
|
|
147
|
+
.filter(Boolean)
|
|
148
|
+
.join(' · '),
|
|
149
|
+
),
|
|
150
|
+
...(slow !== undefined && slow > FRAME ? { problem: true } : {}),
|
|
151
|
+
};
|
|
94
152
|
}
|
|
95
153
|
|
|
96
154
|
type Point = { x: number; y: number };
|
|
@@ -261,6 +319,10 @@ function timelineOf(events: Event[], voice: { id: string; at: number; duration:
|
|
|
261
319
|
});
|
|
262
320
|
}
|
|
263
321
|
}
|
|
322
|
+
if (e.type === 5 && d.tag === REACT) {
|
|
323
|
+
if (payload.on !== undefined) push(t, 'react', payload.on ? 'commits recorded from here' : 'commits no longer recorded');
|
|
324
|
+
else push(t, 'react', '', commitLine(payload));
|
|
325
|
+
}
|
|
264
326
|
if (e.type === 5 && d.tag === 'deictic.end') push(t, 'end', 'recording stopped');
|
|
265
327
|
if (e.type !== 3) continue;
|
|
266
328
|
if (d.source === 0) {
|
|
@@ -328,6 +390,7 @@ function shortener(page: string): (text: string) => string {
|
|
|
328
390
|
export interface Options {
|
|
329
391
|
nth: string;
|
|
330
392
|
json?: boolean;
|
|
393
|
+
all?: boolean;
|
|
331
394
|
only?: string[];
|
|
332
395
|
problems?: boolean;
|
|
333
396
|
from?: string;
|
|
@@ -358,6 +421,19 @@ export async function run(named: string, values: Options): Promise<void> {
|
|
|
358
421
|
const grep = values.grep?.toLowerCase();
|
|
359
422
|
// `console` is every level's lines, `click` a right or a double one too.
|
|
360
423
|
const isKind = (kind: string, asked: string) => kind === asked || kind.startsWith(`${asked}.`) || kind.endsWith(`-${asked}`);
|
|
424
|
+
// Asked for nothing in particular: what the person did and what went wrong, the rest counted. A slice of time, a
|
|
425
|
+
// word or kinds asked for are every line of it.
|
|
426
|
+
const whole = values.all === true || only.length > 0 || from !== undefined || to !== undefined || grep !== undefined;
|
|
427
|
+
const left = new Map<string, { count: number; noun: string }>();
|
|
428
|
+
const listed = (e: Line) => {
|
|
429
|
+
if (whole || e.problem === true) return true;
|
|
430
|
+
const quiet = QUIET.find((q) => isKind(e.kind, q.kind));
|
|
431
|
+
if (quiet === undefined) return true;
|
|
432
|
+
const held = left.get(quiet.kind) ?? { count: 0, noun: quiet.noun };
|
|
433
|
+
held.count++;
|
|
434
|
+
left.set(quiet.kind, held);
|
|
435
|
+
return false;
|
|
436
|
+
};
|
|
361
437
|
const shown = timeline.filter(
|
|
362
438
|
(e) =>
|
|
363
439
|
(only.length === 0 || only.some((asked) => isKind(e.kind, asked))) &&
|
|
@@ -366,6 +442,8 @@ export async function run(named: string, values: Options): Promise<void> {
|
|
|
366
442
|
(to === undefined || e.t <= to) &&
|
|
367
443
|
(grep === undefined || `${e.kind} ${e.text}`.toLowerCase().includes(grep)),
|
|
368
444
|
);
|
|
445
|
+
// Not in `--json`, which is for a script, and has every line it was asked for.
|
|
446
|
+
const listing = values.json === true ? shown : shown.filter(listed);
|
|
369
447
|
|
|
370
448
|
const colorScheme = kept.colorScheme ?? 'light';
|
|
371
449
|
const startedAt = new Date(kept.startedAt ?? events[0]!.timestamp).toISOString();
|
|
@@ -378,14 +456,17 @@ export async function run(named: string, values: Options): Promise<void> {
|
|
|
378
456
|
console.log(`viewport ${kept.viewport.width}×${kept.viewport.height}, ${colorScheme}, started ${startedAt}`);
|
|
379
457
|
if (replay !== undefined) console.log(`replays at ${replay} (add ?t=<seconds> to open it paused there)`);
|
|
380
458
|
if (shown.length < timeline.length) console.log(`${shown.length} of its ${timeline.length} lines, as asked`);
|
|
459
|
+
else if (listing.length < shown.length)
|
|
460
|
+
console.log(`${listing.length} of its ${timeline.length} lines: what the person did, and what went wrong`);
|
|
381
461
|
console.log();
|
|
382
462
|
const short = shortener(kept.page);
|
|
383
463
|
const under = (line: string) => console.log(`${' '.repeat(22)}${short(line)}`);
|
|
384
|
-
for (const e of
|
|
464
|
+
for (const e of listing) {
|
|
385
465
|
console.log(`${e.at.padStart(6)} ${e.kind.padEnd(13)} ${short(e.text)}`);
|
|
386
466
|
// Where a warning or an error came from, its nearest few places: all of them, and every line's, with `--full`.
|
|
387
467
|
if (e.trace && (values.full === true || e.problem === true))
|
|
388
468
|
for (const line of values.full ? e.trace : e.trace.slice(0, 5)) under(`at ${line}`);
|
|
469
|
+
if (values.full === true) for (const line of e.details ?? []) under(line);
|
|
389
470
|
if (values.full !== true || e.request === undefined) continue;
|
|
390
471
|
const r = e.request;
|
|
391
472
|
if (e.before !== undefined) under(e.before);
|
|
@@ -398,6 +479,11 @@ export async function run(named: string, values: Options): Promise<void> {
|
|
|
398
479
|
if (r.responseBody !== undefined) under(`response body ${r.responseBody}`);
|
|
399
480
|
}
|
|
400
481
|
if (shown.length === 0) console.log(timeline.length === 0 ? 'Nothing in it.' : 'No line of it is what was asked for.');
|
|
482
|
+
if (left.size > 0) {
|
|
483
|
+
const counted = [...left.entries()].map(([kind, { count, noun }]) => `${count} ${noun}${count === 1 ? '' : 's'} (--only ${kind})`);
|
|
484
|
+
console.log(`
|
|
485
|
+
Not listed: ${counted.join(', ')}; --all lists every line, --around <seconds> every line of a moment.`);
|
|
486
|
+
}
|
|
401
487
|
// Where something went wrong, how to get to it: what led up to it, and what the page looked like.
|
|
402
488
|
const problems = timeline.filter((e) => e.problem === true).length;
|
|
403
489
|
if (problems === 0 || shown.length < timeline.length) return;
|
package/src/cli/task.ts
CHANGED
|
@@ -183,6 +183,10 @@ function attachments(message: Message, out: string | undefined, indent: string,
|
|
|
183
183
|
if (task === undefined) console.log(`${indent} ${ME} voice ${/^voice-(.+)\.\w+$/.exec(a.name)?.[1] ?? a.id} (speech)`);
|
|
184
184
|
} else if (a.name === 'element.html') {
|
|
185
185
|
console.log(`${indent}${a.name} (${kb}), the element's HTML as it rendered, if you need it${saved}`);
|
|
186
|
+
} else if (/^react(\.\d+)?\.json$/.test(a.name)) {
|
|
187
|
+
console.log(
|
|
188
|
+
`${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}`,
|
|
189
|
+
);
|
|
186
190
|
} else {
|
|
187
191
|
console.log(`${indent}${a.name} (${kb})${saved}`);
|
|
188
192
|
}
|
package/src/cli.ts
CHANGED
|
@@ -85,16 +85,23 @@ program
|
|
|
85
85
|
|
|
86
86
|
program
|
|
87
87
|
.command('recording')
|
|
88
|
-
.description(
|
|
88
|
+
.description(
|
|
89
|
+
"a recording as a timeline: what the person did and what went wrong, with a count of the page's other requests, console lines and React commits; or the part of it asked for",
|
|
90
|
+
)
|
|
89
91
|
.argument('<recording>', RECORDING)
|
|
90
92
|
.option('--nth <n>', "a task's nth recording", '1')
|
|
91
|
-
.option(
|
|
92
|
-
|
|
93
|
+
.option(
|
|
94
|
+
'--only <kinds>',
|
|
95
|
+
'these kinds of line: console, request, react, page, click, input, scroll, resize, marks, voice (repeatable)',
|
|
96
|
+
all,
|
|
97
|
+
)
|
|
98
|
+
.option('--all', 'every line: every request, console line and React commit too')
|
|
99
|
+
.option('--problems', 'errors, warnings, requests that failed and React commits slower than a frame')
|
|
93
100
|
.option('--from <seconds>', 'from this far in')
|
|
94
101
|
.option('--to <seconds>', 'to this far in')
|
|
95
|
-
.option('--around <seconds>', 'the 3 seconds either side of this')
|
|
96
|
-
.option('--grep <text>', 'lines with this in them, in any case')
|
|
97
|
-
.option('--full', "all of each line: where it was logged from, a request's headers and bodies")
|
|
102
|
+
.option('--around <seconds>', 'every line of the 3 seconds either side of this')
|
|
103
|
+
.option('--grep <text>', 'lines with this in them, in any case, of every line')
|
|
104
|
+
.option('--full', "all of each line: where it was logged from, a request's headers and bodies, a React commit's components")
|
|
98
105
|
.option('--json', 'as JSON')
|
|
99
106
|
.action(async (ref: string, options) => (await import('./cli/recording.ts')).run(ref, options));
|
|
100
107
|
|
package/src/client/dom.ts
CHANGED
|
@@ -68,3 +68,17 @@ export function controlFor(within: ParentNode, e: KeyboardEvent, loose = false):
|
|
|
68
68
|
|
|
69
69
|
/** The key held with a letter for a command, as the platform has it, by the name `aria-keyshortcuts` gives it. */
|
|
70
70
|
export const MOD = typeof navigator !== 'undefined' && /Mac|iP(?:hone|ad)/.test(navigator.platform) ? 'Meta' : 'Control';
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* What the page hears on `window` as the popup opens over it on an element (its `detail` a `PopupOpened`) and as
|
|
74
|
+
* it closes: for a page that moves on its own to hold still meanwhile, as deictic's site does. Not for one pinned.
|
|
75
|
+
*/
|
|
76
|
+
export const POPUP_OPENED = 'deictic:open';
|
|
77
|
+
export const POPUP_CLOSED = 'deictic:close';
|
|
78
|
+
|
|
79
|
+
export interface PopupOpened {
|
|
80
|
+
/** The element it's open on. */
|
|
81
|
+
element: Element;
|
|
82
|
+
/** The plugin whose tab it opened at. */
|
|
83
|
+
tab: string;
|
|
84
|
+
}
|