deictic 0.3.0 → 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 +31 -19
- 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 -98
- package/dist/screenshots/rrweb.d.ts +2 -1
- package/dist/screenshots/rrweb.d.ts.map +1 -1
- package/dist/screenshots/rrweb.js +6 -2
- package/dist/screenshots/rrweb.js.map +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/{screenshots → shared}/client.js.map +1 -1
- 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 -84
- 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 -215
- 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/playwright.js +36 -9
- package/dist/shared/playwright.js.map +1 -1
- 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 +33 -191
- 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.d.ts.map +1 -1
- package/dist/tasks/client.js +45 -8
- package/dist/tasks/client.js.map +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 -107
- package/skills/deictic/references/watch.md +13 -66
- 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/client.ts +3 -2
- package/src/plugins/screenshots/index.ts +10 -3
- package/src/plugins/screenshots/playwright.ts +34 -7
- package/src/plugins/screenshots/rrweb.ts +5 -1
- package/src/plugins/tasks/client.ts +62 -7
- package/src/plugins/tasks/index.ts +41 -20
- 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 -277
- package/skills/deictic/scripts/recording.mjs +0 -266
- package/skills/deictic/scripts/task.mjs +0 -113
- 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 -115
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import { createServer } from "node:net";
|
|
5
|
+
import { dirname, join, resolve } from "node:path";
|
|
6
|
+
import { t as keptIn } from "./kept.js";
|
|
7
|
+
// src/plugins/tasks/local.ts
|
|
8
|
+
/**
|
|
9
|
+
* The board tasks go to when nothing names one: `vb serve`, `@vercel/board`'s own, started with the dev server
|
|
10
|
+
* and stopped with it, its log in `.deictic/board`. So Alt-click adds a task with nothing else to run, and
|
|
11
|
+
* whoever works the tasks reaches the same board at the URL `.deictic/board.json` holds.
|
|
12
|
+
*/
|
|
13
|
+
/** `vb serve`'s own default, so `http://127.0.0.1:4100/api/board` is the board wherever it's free. */
|
|
14
|
+
const PORT = 4100;
|
|
15
|
+
/** How long a board may take to answer after it's started, or to be gone after it's stopped. */
|
|
16
|
+
const PATIENCE = 2e4;
|
|
17
|
+
/**
|
|
18
|
+
* The project's own board on this machine, as the tasks plugin's `board`: what it uses anyway with no
|
|
19
|
+
* `BOARD_URL`, here whatever the environment says, and with options.
|
|
20
|
+
*/
|
|
21
|
+
const local = (options = {}) => ({ local: options });
|
|
22
|
+
/**
|
|
23
|
+
* The project's own board, started unless it's running: a dev server that restarts in its process (Vite, when
|
|
24
|
+
* its config changes) asks again, and so does a second dev server of the same project, and two boards mustn't
|
|
25
|
+
* write one log. One running with other options is stopped first, for the same reason.
|
|
26
|
+
*/
|
|
27
|
+
async function localBoard(root, options = {}) {
|
|
28
|
+
const file = keptIn(root, "board.json");
|
|
29
|
+
const dir = options.dir === void 0 ? keptIn(root, "board") : resolve(root, options.dir);
|
|
30
|
+
const flags = [...options.inspect === false ? ["--no-inspect"] : [], ...options.args ?? []];
|
|
31
|
+
const as = JSON.stringify([
|
|
32
|
+
options.port ?? null,
|
|
33
|
+
dir,
|
|
34
|
+
flags
|
|
35
|
+
]);
|
|
36
|
+
const running = runningAt(file);
|
|
37
|
+
if (running !== void 0 && alive(running.pid) && await answers(running.url)) {
|
|
38
|
+
if (running.as === as) return {
|
|
39
|
+
url: running.url,
|
|
40
|
+
fresh: false,
|
|
41
|
+
dir,
|
|
42
|
+
stop: () => {}
|
|
43
|
+
};
|
|
44
|
+
process.kill(running.pid);
|
|
45
|
+
await gone(running.url);
|
|
46
|
+
}
|
|
47
|
+
const port = options.port ?? await free(PORT);
|
|
48
|
+
const url = `http://127.0.0.1:${port}/api/board`;
|
|
49
|
+
const script = vbScript();
|
|
50
|
+
if (script === void 0) throw new Error("@vercel/board is missing: add it to your devDependencies");
|
|
51
|
+
const child = spawn(process.execPath, [
|
|
52
|
+
script,
|
|
53
|
+
"serve",
|
|
54
|
+
"--port",
|
|
55
|
+
String(port),
|
|
56
|
+
"--no-open",
|
|
57
|
+
"--dir",
|
|
58
|
+
dir,
|
|
59
|
+
...flags
|
|
60
|
+
], { stdio: [
|
|
61
|
+
"ignore",
|
|
62
|
+
"ignore",
|
|
63
|
+
"pipe"
|
|
64
|
+
] });
|
|
65
|
+
let said = "";
|
|
66
|
+
child.stderr.on("data", (chunk) => said += chunk.toString());
|
|
67
|
+
const stop = () => void child.kill();
|
|
68
|
+
process.once("exit", stop);
|
|
69
|
+
try {
|
|
70
|
+
await started(child, url);
|
|
71
|
+
} catch (e) {
|
|
72
|
+
stop();
|
|
73
|
+
const fix = options.port === void 0 ? "set BOARD_URL to a board of your own" : `is port ${port} taken? name another, or none`;
|
|
74
|
+
throw new Error(`the board didn't start (${said.trim() || e.message}): ${fix}`, { cause: e });
|
|
75
|
+
}
|
|
76
|
+
writeFileSync(file, `${JSON.stringify({
|
|
77
|
+
url,
|
|
78
|
+
pid: child.pid,
|
|
79
|
+
as
|
|
80
|
+
}, null, 2)}\n`);
|
|
81
|
+
child.unref();
|
|
82
|
+
child.stderr.unref?.();
|
|
83
|
+
return {
|
|
84
|
+
url,
|
|
85
|
+
fresh: true,
|
|
86
|
+
dir,
|
|
87
|
+
stop
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* `vb`'s script in the project's `@vercel/board`, by its `bin`, to run with this process's own runtime: no shim, no
|
|
92
|
+
* shell. Nothing where it isn't installed.
|
|
93
|
+
*/
|
|
94
|
+
function vbScript() {
|
|
95
|
+
try {
|
|
96
|
+
const manifest = createRequire(import.meta.url).resolve("@vercel/board/package.json");
|
|
97
|
+
const { bin } = JSON.parse(readFileSync(manifest, "utf8"));
|
|
98
|
+
const entry = typeof bin === "string" ? bin : bin?.vb;
|
|
99
|
+
return entry === void 0 ? void 0 : join(dirname(manifest), entry);
|
|
100
|
+
} catch {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/** What a `.deictic/board.json` says, where it says it. */
|
|
105
|
+
function runningAt(file) {
|
|
106
|
+
try {
|
|
107
|
+
const { url, pid, as } = JSON.parse(readFileSync(file, "utf8"));
|
|
108
|
+
return typeof url === "string" && typeof pid === "number" ? {
|
|
109
|
+
url,
|
|
110
|
+
pid,
|
|
111
|
+
as: as ?? ""
|
|
112
|
+
} : void 0;
|
|
113
|
+
} catch {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function alive(pid) {
|
|
118
|
+
try {
|
|
119
|
+
process.kill(pid, 0);
|
|
120
|
+
return true;
|
|
121
|
+
} catch {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/** Whether a board answers there: its discovery, which names its own URL. */
|
|
126
|
+
async function answers(url) {
|
|
127
|
+
try {
|
|
128
|
+
const res = await fetch(url, { signal: AbortSignal.timeout(2e3) });
|
|
129
|
+
return res.ok && (await res.json()).url === url;
|
|
130
|
+
} catch {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/** `wanted` where nothing listens on it (another project's board may), or else a port the system picks. */
|
|
135
|
+
async function free(wanted) {
|
|
136
|
+
const listen = (port) => new Promise((done, failed) => {
|
|
137
|
+
const server = createServer();
|
|
138
|
+
server.once("error", failed);
|
|
139
|
+
server.listen(port, "127.0.0.1", () => {
|
|
140
|
+
const { port: got } = server.address();
|
|
141
|
+
server.close(() => done(got));
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
return listen(wanted).catch(() => listen(0));
|
|
145
|
+
}
|
|
146
|
+
const nap = () => new Promise((wake) => setTimeout(wake, 100));
|
|
147
|
+
/** Waits for the board to answer, or for its process to end without having. */
|
|
148
|
+
async function started(child, url) {
|
|
149
|
+
let ended;
|
|
150
|
+
child.once("error", (e) => ended = e.message);
|
|
151
|
+
child.once("exit", (code) => ended ??= `exit ${code}`);
|
|
152
|
+
for (const until = Date.now() + PATIENCE; Date.now() < until; await nap()) {
|
|
153
|
+
if (ended !== void 0) throw new Error(ended);
|
|
154
|
+
if (await answers(url)) return;
|
|
155
|
+
}
|
|
156
|
+
throw new Error(`no answer at ${url} after ${PATIENCE / 1e3}s`);
|
|
157
|
+
}
|
|
158
|
+
/** Waits for a stopped board to let go of its port and its log. */
|
|
159
|
+
async function gone(url) {
|
|
160
|
+
for (const until = Date.now() + PATIENCE; Date.now() < until; await nap()) if (!await answers(url)) return;
|
|
161
|
+
throw new Error(`the board at ${url} is still running: stop it, then restart the dev server`);
|
|
162
|
+
}
|
|
163
|
+
export { vbScript as i, localBoard as n, runningAt as r, local as t };
|
|
164
|
+
|
|
165
|
+
//# sourceMappingURL=local.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local.js","names":[],"sources":["../../src/plugins/tasks/local.ts"],"sourcesContent":["/**\n * The board tasks go to when nothing names one: `vb serve`, `@vercel/board`'s own, started with the dev server\n * and stopped with it, its log in `.deictic/board`. So Alt-click adds a task with nothing else to run, and\n * whoever works the tasks reaches the same board at the URL `.deictic/board.json` holds.\n */\nimport { type ChildProcess, spawn } from 'node:child_process';\nimport { readFileSync, writeFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { createServer } from 'node:net';\nimport { dirname, join, resolve } from 'node:path';\n\nimport { keptIn } from '#src/tools/kept.ts';\n\n/** `vb serve`'s own default, so `http://127.0.0.1:4100/api/board` is the board wherever it's free. */\nconst PORT = 4100;\n/** How long a board may take to answer after it's started, or to be gone after it's stopped. */\nconst PATIENCE = 20_000;\n\nexport interface LocalOptions {\n /**\n * The port it listens on, on 127.0.0.1. By default 4100, or a free one where that's taken. One named here is\n * the only one tried: taken, the board doesn't start.\n */\n port?: number;\n /** Where its log is kept, from the project's root: `.deictic/board` by default. */\n dir?: string;\n /** `false` for no pages of the board's own (its inspector): the panel then links its tasks nowhere. */\n inspect?: boolean;\n /** More arguments for `vb serve`, as it takes them: `['--tailscale', 'box.tailnet.ts.net']`. */\n args?: string[];\n}\n\n/** What `local()` answers, for the tasks plugin's `board` option. */\nexport interface LocalBoard {\n local: LocalOptions;\n}\n\n/**\n * The project's own board on this machine, as the tasks plugin's `board`: what it uses anyway with no\n * `BOARD_URL`, here whatever the environment says, and with options.\n */\nexport const local = (options: LocalOptions = {}): LocalBoard => ({ local: options });\n\n/** What `.deictic/board.json` holds: the board the dev server started, for whoever works its tasks. */\nexport interface Running {\n url: string;\n pid: number;\n /** The options it was started with, as one string to compare: other ones need another board. */\n as: string;\n}\n\nexport interface Local {\n url: string;\n /** Whether this call started it, rather than found it running. */\n fresh: boolean;\n /** Where its log is. */\n dir: string;\n /** Stops the board, where this call started it: one found running is left to what started it. */\n stop: () => void;\n}\n\n/**\n * The project's own board, started unless it's running: a dev server that restarts in its process (Vite, when\n * its config changes) asks again, and so does a second dev server of the same project, and two boards mustn't\n * write one log. One running with other options is stopped first, for the same reason.\n */\nexport async function localBoard(root: string, options: LocalOptions = {}): Promise<Local> {\n const file = keptIn(root, 'board.json');\n const dir = options.dir === undefined ? keptIn(root, 'board') : resolve(root, options.dir);\n const flags = [...(options.inspect === false ? ['--no-inspect'] : []), ...(options.args ?? [])];\n const as = JSON.stringify([options.port ?? null, dir, flags]);\n\n const running = runningAt(file);\n if (running !== undefined && alive(running.pid) && (await answers(running.url))) {\n if (running.as === as) return { url: running.url, fresh: false, dir, stop: () => {} };\n process.kill(running.pid);\n await gone(running.url);\n }\n\n const port = options.port ?? (await free(PORT));\n const url = `http://127.0.0.1:${port}/api/board`;\n const script = vbScript();\n if (script === undefined) throw new Error('@vercel/board is missing: add it to your devDependencies');\n const child = spawn(process.execPath, [script, 'serve', '--port', String(port), '--no-open', '--dir', dir, ...flags], {\n stdio: ['ignore', 'ignore', 'pipe'],\n });\n let said = '';\n child.stderr.on('data', (chunk: Buffer) => (said += chunk.toString()));\n const stop = () => void child.kill();\n process.once('exit', stop);\n\n try {\n await started(child, url);\n } catch (e) {\n stop();\n const fix = options.port === undefined ? 'set BOARD_URL to a board of your own' : `is port ${port} taken? name another, or none`;\n throw new Error(`the board didn't start (${said.trim() || (e as Error).message}): ${fix}`, { cause: e });\n }\n writeFileSync(file, `${JSON.stringify({ url, pid: child.pid, as }, null, 2)}\\n`);\n // The board ends with this process, and mustn't be what keeps it from ending.\n child.unref();\n (child.stderr as { unref?: () => void }).unref?.();\n return { url, fresh: true, dir, stop };\n}\n\n/**\n * `vb`'s script in the project's `@vercel/board`, by its `bin`, to run with this process's own runtime: no shim, no\n * shell. Nothing where it isn't installed.\n */\nexport function vbScript(): string | undefined {\n try {\n const manifest = createRequire(import.meta.url).resolve('@vercel/board/package.json');\n const { bin } = JSON.parse(readFileSync(manifest, 'utf8')) as { bin?: string | { vb?: string } };\n const entry = typeof bin === 'string' ? bin : bin?.vb;\n return entry === undefined ? undefined : join(dirname(manifest), entry);\n } catch {\n return undefined;\n }\n}\n\n/** What a `.deictic/board.json` says, where it says it. */\nexport function runningAt(file: string): Running | undefined {\n try {\n const { url, pid, as } = JSON.parse(readFileSync(file, 'utf8')) as Partial<Running>;\n return typeof url === 'string' && typeof pid === 'number' ? { url, pid, as: as ?? '' } : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction alive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return true;\n } catch {\n return false;\n }\n}\n\n/** Whether a board answers there: its discovery, which names its own URL. */\nasync function answers(url: string): Promise<boolean> {\n try {\n const res = await fetch(url, { signal: AbortSignal.timeout(2000) });\n return res.ok && ((await res.json()) as { url?: unknown }).url === url;\n } catch {\n return false;\n }\n}\n\n/** `wanted` where nothing listens on it (another project's board may), or else a port the system picks. */\nasync function free(wanted: number): Promise<number> {\n const listen = (port: number) =>\n new Promise<number>((done, failed) => {\n const server = createServer();\n server.once('error', failed);\n server.listen(port, '127.0.0.1', () => {\n const { port: got } = server.address() as { port: number };\n server.close(() => done(got));\n });\n });\n return listen(wanted).catch(() => listen(0));\n}\n\nconst nap = () => new Promise((wake) => setTimeout(wake, 100));\n\n/** Waits for the board to answer, or for its process to end without having. */\nasync function started(child: ChildProcess, url: string): Promise<void> {\n let ended: string | undefined;\n child.once('error', (e) => (ended = e.message));\n child.once('exit', (code) => (ended ??= `exit ${code}`));\n for (const until = Date.now() + PATIENCE; Date.now() < until; await nap()) {\n if (ended !== undefined) throw new Error(ended);\n if (await answers(url)) return;\n }\n throw new Error(`no answer at ${url} after ${PATIENCE / 1000}s`);\n}\n\n/** Waits for a stopped board to let go of its port and its log. */\nasync function gone(url: string): Promise<void> {\n for (const until = Date.now() + PATIENCE; Date.now() < until; await nap()) if (!(await answers(url))) return;\n\n throw new Error(`the board at ${url} is still running: stop it, then restart the dev server`);\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAM,OAAO;;AAEb,MAAM,WAAW;;;;;AAyBjB,MAAa,SAAS,UAAwB,CAAC,OAAmB,EAAE,OAAO,QAAQ;;;;;;AAyBnF,eAAsB,WAAW,MAAc,UAAwB,CAAC,GAAmB;CACzF,MAAM,OAAO,OAAO,MAAM,YAAY;CACtC,MAAM,MAAM,QAAQ,QAAQ,KAAA,IAAY,OAAO,MAAM,OAAO,IAAI,QAAQ,MAAM,QAAQ,GAAG;CACzF,MAAM,QAAQ,CAAC,GAAI,QAAQ,YAAY,QAAQ,CAAC,cAAc,IAAI,CAAC,GAAI,GAAI,QAAQ,QAAQ,CAAC,CAAE;CAC9F,MAAM,KAAK,KAAK,UAAU;EAAC,QAAQ,QAAQ;EAAM;EAAK;CAAK,CAAC;CAE5D,MAAM,UAAU,UAAU,IAAI;CAC9B,IAAI,YAAY,KAAA,KAAa,MAAM,QAAQ,GAAG,KAAM,MAAM,QAAQ,QAAQ,GAAG,GAAI;EAC/E,IAAI,QAAQ,OAAO,IAAI,OAAO;GAAE,KAAK,QAAQ;GAAK,OAAO;GAAO;GAAK,YAAY,CAAC;EAAE;EACpF,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,IAAI,IAAI,OAAO,MAAM,IAAI,GAAG;EACzE,IAAI,UAAU,KAAA,GAAW,MAAM,IAAI,MAAM,KAAK;EAC9C,IAAI,MAAM,QAAQ,GAAG,GAAG;CAC1B;CACA,MAAM,IAAI,MAAM,gBAAgB,IAAI,SAAS,WAAW,IAAK,EAAE;AACjE;;AAGA,eAAe,KAAK,KAA4B;CAC9C,KAAK,MAAM,QAAQ,KAAK,IAAI,IAAI,UAAU,KAAK,IAAI,IAAI,OAAO,MAAM,IAAI,GAAG,IAAI,CAAE,MAAM,QAAQ,GAAG,GAAI;CAEtG,MAAM,IAAI,MAAM,gBAAgB,IAAI,wDAAwD;AAC9F"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { r as definePlugin } from "./src.js";
|
|
2
|
+
// src/plugins/logs/index.ts
|
|
3
|
+
/**
|
|
4
|
+
* `deictic/logs`: what the page logs while it's recorded, and the errors nothing caught, in the recording, each at
|
|
5
|
+
* its moment. No tab, and nothing of its own: it hands the recordings plugin rrweb's console plugin
|
|
6
|
+
* (`@rrweb/rrweb-plugin-console-record`, an optional peer), whose events are rrweb's (`rrweb/console@1`).
|
|
7
|
+
*
|
|
8
|
+
* A wrapped console names the wrapper, not the caller, as each line's source in the browser's tools. rrweb wraps it
|
|
9
|
+
* 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
|
|
10
|
+
* out and it never is.
|
|
11
|
+
*/
|
|
12
|
+
function logs(options = {}) {
|
|
13
|
+
return definePlugin({
|
|
14
|
+
name: "logs",
|
|
15
|
+
client: "deictic/logs/client",
|
|
16
|
+
packages: ["@rrweb/rrweb-plugin-console-record"],
|
|
17
|
+
clientOptions: { levels: options.levels }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export { logs as t };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=logs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs.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 packages: ['@rrweb/rrweb-plugin-console-record'],\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,UAAU,CAAC,oCAAoC;EAC/C,eAAe,EAAE,QAAQ,QAAQ,OAAO;CAC1C,CAAC;AACH"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { r as definePlugin } from "./src.js";
|
|
2
|
+
// src/plugins/network/index.ts
|
|
3
|
+
/**
|
|
4
|
+
* `deictic/network`: the requests the page makes while it's recorded, in the recording, each as it ends. No tab,
|
|
5
|
+
* and nothing of its own: it hands the recordings plugin rrweb's network plugin
|
|
6
|
+
* (`@rrweb/rrweb-plugin-network-record`, an optional peer), whose events are rrweb's (`rrweb/network@1`).
|
|
7
|
+
*
|
|
8
|
+
* By default a request is its URL, its status and its timing, which the browser reports of itself
|
|
9
|
+
* (`PerformanceObserver`): nothing of the page's is wrapped, and no method is known. `headers` and `body` add those
|
|
10
|
+
* and the method, for which rrweb wraps `fetch` and `XMLHttpRequest` while a recording is going, and only then.
|
|
11
|
+
*
|
|
12
|
+
* Everything kept is masked first (`mask.ts`): a secret in a URL's query, a header or a body's field is blanked by
|
|
13
|
+
* its name, and deictic's own requests are left out.
|
|
14
|
+
*/
|
|
15
|
+
/** The bodies kept with `body: true`: what reads as text. */
|
|
16
|
+
const TEXT = [
|
|
17
|
+
"application/json",
|
|
18
|
+
"+json",
|
|
19
|
+
"text/",
|
|
20
|
+
"application/x-www-form-urlencoded",
|
|
21
|
+
"application/xml"
|
|
22
|
+
];
|
|
23
|
+
function network(options = {}) {
|
|
24
|
+
return definePlugin({
|
|
25
|
+
name: "network",
|
|
26
|
+
client: "deictic/network/client",
|
|
27
|
+
packages: ["@rrweb/rrweb-plugin-network-record"],
|
|
28
|
+
clientOptions: {
|
|
29
|
+
initiators: options.initiators ?? ["fetch", "xmlhttprequest"],
|
|
30
|
+
headers: options.headers ?? false,
|
|
31
|
+
body: options.body === true ? TEXT : options.body ?? false,
|
|
32
|
+
mask: options.mask ?? [],
|
|
33
|
+
ignore: options.ignore ?? []
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
export { network as t };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=network.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network.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 packages: ['@rrweb/rrweb-plugin-network-record'],\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,UAAU,CAAC,oCAAoC;EAC/C,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"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
// package.json
|
|
5
|
+
var name = "deictic";
|
|
6
|
+
var version = "0.4.0";
|
|
7
|
+
var peerDependencies = {
|
|
8
|
+
"@rrweb/rrweb-plugin-console-record": "^2.2.2",
|
|
9
|
+
"@rrweb/rrweb-plugin-network-record": "^2.2.2",
|
|
10
|
+
"@rspack/core": ">=1",
|
|
11
|
+
"@vercel/board": ">=0.53.0",
|
|
12
|
+
"astro": ">=5",
|
|
13
|
+
"launch-editor": "^2.9.0",
|
|
14
|
+
"modern-screenshot": "^4.7.0",
|
|
15
|
+
"next": ">=16",
|
|
16
|
+
"playwright-core": "^1.50.0",
|
|
17
|
+
"rrweb": "^2.2.2",
|
|
18
|
+
"rrweb-player": "^2.2.2",
|
|
19
|
+
"rrweb-snapshot": "^2.2.2",
|
|
20
|
+
"vite": ">=6",
|
|
21
|
+
"webpack": ">=5"
|
|
22
|
+
};
|
|
23
|
+
// src/tools/packages.ts
|
|
24
|
+
/**
|
|
25
|
+
* The packages plugins import that the project installs itself (`ServerPlugin.packages`: deictic's optional peers,
|
|
26
|
+
* or a plugin's own), and how to install them with the project's package manager. A missing one is said as the dev
|
|
27
|
+
* server starts, with the command that installs it, not on the first shot or recording, where it would fail.
|
|
28
|
+
*/
|
|
29
|
+
/** Each package manager's lockfiles, in the order they're looked for in a folder. */
|
|
30
|
+
const LOCKS = [
|
|
31
|
+
["bun.lock", "bun"],
|
|
32
|
+
["bun.lockb", "bun"],
|
|
33
|
+
["pnpm-lock.yaml", "pnpm"],
|
|
34
|
+
["yarn.lock", "yarn"],
|
|
35
|
+
["package-lock.json", "npm"]
|
|
36
|
+
];
|
|
37
|
+
const MANAGERS = [
|
|
38
|
+
"npm",
|
|
39
|
+
"pnpm",
|
|
40
|
+
"yarn",
|
|
41
|
+
"bun"
|
|
42
|
+
];
|
|
43
|
+
/**
|
|
44
|
+
* The project's package manager: its `packageManager` field, or the lockfile nearest the root (a workspace's is
|
|
45
|
+
* above it), or the one running this (`npm_config_user_agent`), or npm. The lockfile wins over what runs this,
|
|
46
|
+
* as `npx deictic init` runs under npm in a project of any manager's.
|
|
47
|
+
*/
|
|
48
|
+
function packageManager(root, agent = process.env.npm_config_user_agent) {
|
|
49
|
+
for (let dir = root;; dir = dirname(dir)) {
|
|
50
|
+
const field = fieldOf(dir);
|
|
51
|
+
if (field !== void 0) return field;
|
|
52
|
+
const lock = LOCKS.find(([file]) => existsSync(join(dir, file)));
|
|
53
|
+
if (lock !== void 0) return lock[1];
|
|
54
|
+
if (dirname(dir) === dir) break;
|
|
55
|
+
}
|
|
56
|
+
const running = agent?.split("/")[0];
|
|
57
|
+
return MANAGERS.find((m) => m === running) ?? "npm";
|
|
58
|
+
}
|
|
59
|
+
/** A package.json's `packageManager` (`pnpm@9.1.0`), by its manager's name. */
|
|
60
|
+
function fieldOf(dir) {
|
|
61
|
+
const field = readJson(join(dir, "package.json"))?.packageManager;
|
|
62
|
+
const name = typeof field === "string" ? field.split("@")[0] : void 0;
|
|
63
|
+
return MANAGERS.find((m) => m === name);
|
|
64
|
+
}
|
|
65
|
+
function readJson(path) {
|
|
66
|
+
try {
|
|
67
|
+
return JSON.parse(readFileSync(path, "utf8"));
|
|
68
|
+
} catch {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* A package as the install command names it: with deictic's range for it where it's one of deictic's peers (rrweb's
|
|
74
|
+
* packages must agree), or deictic's own version for deictic. Quoted, as `>` and `^` are a shell's.
|
|
75
|
+
*/
|
|
76
|
+
function specOf(name$1) {
|
|
77
|
+
const range = name$1 === name ? `^${version}` : peerDependencies[name$1];
|
|
78
|
+
return range === void 0 ? name$1 : `"${name$1}@${range}"`;
|
|
79
|
+
}
|
|
80
|
+
/** The command that adds `names` to the project's dev dependencies. A pnpm workspace's root takes them only with `-w`. */
|
|
81
|
+
function installCommand(manager, names, root) {
|
|
82
|
+
return [{
|
|
83
|
+
npm: "npm install -D",
|
|
84
|
+
pnpm: existsSync(join(root, "pnpm-workspace.yaml")) ? "pnpm add -D -w" : "pnpm add -D",
|
|
85
|
+
yarn: "yarn add -D",
|
|
86
|
+
bun: "bun add -d"
|
|
87
|
+
}[manager], ...names.map(specOf)].join(" ");
|
|
88
|
+
}
|
|
89
|
+
/** What runs a package's CLI without installing it, for the manager: `npx`, `bunx`. */
|
|
90
|
+
const runnerOf = (manager) => ({
|
|
91
|
+
npm: "npx",
|
|
92
|
+
pnpm: "pnpm dlx",
|
|
93
|
+
yarn: "npx",
|
|
94
|
+
bun: "bunx"
|
|
95
|
+
})[manager];
|
|
96
|
+
/** Whether the project can import `name`: it's found from the root, as the bundler and deictic's own imports find it. */
|
|
97
|
+
function installed(root, name) {
|
|
98
|
+
try {
|
|
99
|
+
createRequire(join(root, "package.json")).resolve(`${name}/package.json`);
|
|
100
|
+
return true;
|
|
101
|
+
} catch (e) {
|
|
102
|
+
return e.code !== "MODULE_NOT_FOUND";
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/** Each plugin with the packages it imports that the project hasn't installed, where it has any. */
|
|
106
|
+
function missing(root, plugins) {
|
|
107
|
+
return plugins.flatMap(({ name, packages = [] }) => {
|
|
108
|
+
const gone = packages.filter((p) => !installed(root, p));
|
|
109
|
+
return gone.length === 0 ? [] : [{
|
|
110
|
+
plugin: name,
|
|
111
|
+
packages: gone
|
|
112
|
+
}];
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/** What to say as the dev server starts when plugins' packages are missing: which, and the command that installs them. */
|
|
116
|
+
function missingMessage(root, plugins) {
|
|
117
|
+
const gone = missing(root, plugins);
|
|
118
|
+
if (gone.length === 0) return void 0;
|
|
119
|
+
const names = [...new Set(gone.flatMap((g) => g.packages))];
|
|
120
|
+
const which = gone.map((g) => g.plugin);
|
|
121
|
+
return `deictic: install what ${which.length === 1 ? which[0] : `${which.slice(0, -1).join(", ")} and ${which.at(-1)}`} ${which.length === 1 ? "needs" : "need"}: ${installCommand(packageManager(root), names, root)}`;
|
|
122
|
+
}
|
|
123
|
+
export { runnerOf as a, readJson as i, missingMessage as n, packageManager as r, installCommand as t };
|
|
124
|
+
|
|
125
|
+
//# sourceMappingURL=packages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packages.js","names":["name","manifest.name","manifest.version","manifest.peerDependencies"],"sources":["../../package.json","../../src/tools/packages.ts"],"sourcesContent":["","/**\n * The packages plugins import that the project installs itself (`ServerPlugin.packages`: deictic's optional peers,\n * or a plugin's own), and how to install them with the project's package manager. A missing one is said as the dev\n * server starts, with the command that installs it, not on the first shot or recording, where it would fail.\n */\nimport { existsSync, readFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, join } from 'node:path';\n\nimport manifest from '#package.json' with { type: 'json' };\nimport type { ServerPlugin } from '#src/index.ts';\n\nexport type PackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun';\n\n/** Each package manager's lockfiles, in the order they're looked for in a folder. */\nconst LOCKS: [string, PackageManager][] = [\n ['bun.lock', 'bun'],\n ['bun.lockb', 'bun'],\n ['pnpm-lock.yaml', 'pnpm'],\n ['yarn.lock', 'yarn'],\n ['package-lock.json', 'npm'],\n];\nconst MANAGERS: PackageManager[] = ['npm', 'pnpm', 'yarn', 'bun'];\n\n/**\n * The project's package manager: its `packageManager` field, or the lockfile nearest the root (a workspace's is\n * above it), or the one running this (`npm_config_user_agent`), or npm. The lockfile wins over what runs this,\n * as `npx deictic init` runs under npm in a project of any manager's.\n */\nexport function packageManager(root: string, agent = process.env.npm_config_user_agent): PackageManager {\n for (let dir = root; ; dir = dirname(dir)) {\n const field = fieldOf(dir);\n if (field !== undefined) return field;\n const lock = LOCKS.find(([file]) => existsSync(join(dir, file)));\n if (lock !== undefined) return lock[1];\n if (dirname(dir) === dir) break;\n }\n const running = agent?.split('/')[0];\n return MANAGERS.find((m) => m === running) ?? 'npm';\n}\n\n/** A package.json's `packageManager` (`pnpm@9.1.0`), by its manager's name. */\nfunction fieldOf(dir: string): PackageManager | undefined {\n const field = readJson(join(dir, 'package.json'))?.packageManager;\n const name = typeof field === 'string' ? field.split('@')[0] : undefined;\n return MANAGERS.find((m) => m === name);\n}\n\nexport function readJson(path: string): Record<string, unknown> | undefined {\n try {\n return JSON.parse(readFileSync(path, 'utf8')) as Record<string, unknown>;\n } catch {\n return undefined;\n }\n}\n\n/**\n * A package as the install command names it: with deictic's range for it where it's one of deictic's peers (rrweb's\n * packages must agree), or deictic's own version for deictic. Quoted, as `>` and `^` are a shell's.\n */\nexport function specOf(name: string): string {\n const range = name === manifest.name ? `^${manifest.version}` : (manifest.peerDependencies as Record<string, string>)[name];\n return range === undefined ? name : `\"${name}@${range}\"`;\n}\n\n/** The command that adds `names` to the project's dev dependencies. A pnpm workspace's root takes them only with `-w`. */\nexport function installCommand(manager: PackageManager, names: readonly string[], root: string): string {\n const add = {\n npm: 'npm install -D',\n pnpm: existsSync(join(root, 'pnpm-workspace.yaml')) ? 'pnpm add -D -w' : 'pnpm add -D',\n yarn: 'yarn add -D',\n bun: 'bun add -d',\n }[manager];\n return [add, ...names.map(specOf)].join(' ');\n}\n\n/** What runs a package's CLI without installing it, for the manager: `npx`, `bunx`. */\nexport const runnerOf = (manager: PackageManager) => ({ npm: 'npx', pnpm: 'pnpm dlx', yarn: 'npx', bun: 'bunx' })[manager];\n\n/** Whether the project can import `name`: it's found from the root, as the bundler and deictic's own imports find it. */\nexport function installed(root: string, name: string): boolean {\n try {\n createRequire(join(root, 'package.json')).resolve(`${name}/package.json`);\n return true;\n } catch (e) {\n // There, but its `exports` don't name its package.json: only \"not found\" means it's missing.\n return (e as { code?: string }).code !== 'MODULE_NOT_FOUND';\n }\n}\n\n/** Each plugin with the packages it imports that the project hasn't installed, where it has any. */\nexport function missing(root: string, plugins: readonly ServerPlugin[]): { plugin: string; packages: string[] }[] {\n return plugins.flatMap(({ name, packages = [] }) => {\n const gone = packages.filter((p) => !installed(root, p));\n return gone.length === 0 ? [] : [{ plugin: name, packages: gone }];\n });\n}\n\n/** What to say as the dev server starts when plugins' packages are missing: which, and the command that installs them. */\nexport function missingMessage(root: string, plugins: readonly ServerPlugin[]): string | undefined {\n const gone = missing(root, plugins);\n if (gone.length === 0) return undefined;\n const names = [...new Set(gone.flatMap((g) => g.packages))];\n const which = gone.map((g) => g.plugin);\n const who = which.length === 1 ? which[0] : `${which.slice(0, -1).join(', ')} and ${which.at(-1)}`;\n return `deictic: install what ${who} ${which.length === 1 ? 'needs' : 'need'}: ${installCommand(packageManager(root), names, root)}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACeA,MAAM,QAAoC;CACxC,CAAC,YAAY,KAAK;CAClB,CAAC,aAAa,KAAK;CACnB,CAAC,kBAAkB,MAAM;CACzB,CAAC,aAAa,MAAM;CACpB,CAAC,qBAAqB,KAAK;AAC7B;AACA,MAAM,WAA6B;CAAC;CAAO;CAAQ;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MAAM;CAAY,MAAM;CAAO,KAAK;AAAO,EAAA,CAAG;;AAGlH,SAAgB,UAAU,MAAc,MAAuB;CAC7D,IAAI;EACF,cAAc,KAAK,MAAM,cAAc,CAAC,CAAC,CAAC,QAAQ,GAAG,KAAK,cAAc;EACxE,OAAO;CACT,SAAS,GAAG;EAEV,OAAQ,EAAwB,SAAS;CAC3C;AACF;;AAGA,SAAgB,QAAQ,MAAc,SAA4E;CAChH,OAAO,QAAQ,SAAS,EAAE,MAAM,WAAW,CAAC,QAAQ;EAClD,MAAM,OAAO,SAAS,QAAQ,MAAM,CAAC,UAAU,MAAM,CAAC,CAAC;EACvD,OAAO,KAAK,WAAW,IAAI,CAAC,IAAI,CAAC;GAAE,QAAQ;GAAM,UAAU;EAAK,CAAC;CACnE,CAAC;AACH;;AAGA,SAAgB,eAAe,MAAc,SAAsD;CACjG,MAAM,OAAO,QAAQ,MAAM,OAAO;CAClC,IAAI,KAAK,WAAW,GAAG,OAAO,KAAA;CAC9B,MAAM,QAAQ,CAAC,GAAG,IAAI,IAAI,KAAK,SAAS,MAAM,EAAE,QAAQ,CAAC,CAAC;CAC1D,MAAM,QAAQ,KAAK,KAAK,MAAM,EAAE,MAAM;CAEtC,OAAO,yBADK,MAAM,WAAW,IAAI,MAAM,KAAK,GAAG,MAAM,MAAM,GAAG,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE,OAAO,MAAM,GAAG,EAAE,IAC3D,GAAG,MAAM,WAAW,IAAI,UAAU,OAAO,IAAI,eAAe,eAAe,IAAI,GAAG,OAAO,IAAI;AACnI"}
|
|
@@ -54,6 +54,11 @@ async function launch({ executablePath, channel }) {
|
|
|
54
54
|
}
|
|
55
55
|
/** The rrweb-snapshot bundle that defines `rrwebSnapshot` in a page: its CommonJS entry is that bundle. */
|
|
56
56
|
const bundle = () => createRequire(import.meta.url).resolve("rrweb-snapshot");
|
|
57
|
+
/**
|
|
58
|
+
* The PNG, and where the element is in it. That's measured in the rebuilt page, not taken from the live one: the
|
|
59
|
+
* two can lay out a few pixels apart (a font that loaded differently, a panel's own scroll), and an outline drawn
|
|
60
|
+
* at the live page's box would then cross the element.
|
|
61
|
+
*/
|
|
57
62
|
async function render(input, options) {
|
|
58
63
|
const shot = input;
|
|
59
64
|
if (typeof shot?.url !== "string" || typeof shot.snapshot !== "object" || typeof shot.viewport?.width !== "number") throw new Error("screenshots: that is not a snapshot the rrweb() renderer took");
|
|
@@ -70,12 +75,13 @@ async function render(input, options) {
|
|
|
70
75
|
}));
|
|
71
76
|
await page.goto(host);
|
|
72
77
|
await page.addScriptTag({ path: bundle() });
|
|
73
|
-
await page.evaluate(async ({ snapshot, scroll, overlay }) => {
|
|
78
|
+
const found = await page.evaluate(async ({ snapshot, scroll, overlay, element }) => {
|
|
74
79
|
const { rebuildIntoSandboxedIframe, createCache, createMirror } = globalThis.rrwebSnapshot;
|
|
80
|
+
const mirror = createMirror();
|
|
75
81
|
const { iframe } = rebuildIntoSandboxedIframe(snapshot, {
|
|
76
82
|
root: document.body,
|
|
77
83
|
cache: createCache(),
|
|
78
|
-
mirror
|
|
84
|
+
mirror,
|
|
79
85
|
iframeAttributes: { style: "border:0;position:fixed;inset:0;width:100vw;height:100vh" }
|
|
80
86
|
});
|
|
81
87
|
const doc = iframe.contentDocument;
|
|
@@ -83,21 +89,42 @@ async function render(input, options) {
|
|
|
83
89
|
await doc.fonts.ready;
|
|
84
90
|
await Promise.all([...doc.images].map((img) => img.decode().catch(() => {})));
|
|
85
91
|
iframe.contentWindow?.scrollTo(scroll.x, scroll.y);
|
|
86
|
-
|
|
92
|
+
const isElement = (node) => node?.nodeType === 1;
|
|
93
|
+
for (const id of mirror.getIds()) {
|
|
94
|
+
const node = mirror.getNode(id);
|
|
95
|
+
const meta = node === null ? null : mirror.getMeta(node);
|
|
96
|
+
if (!isElement(node) || meta === null || !("attributes" in meta)) continue;
|
|
97
|
+
const { rr_scrollTop: top, rr_scrollLeft: left } = meta.attributes;
|
|
98
|
+
if (typeof top === "number") node.scrollTop = top;
|
|
99
|
+
if (typeof left === "number") node.scrollLeft = left;
|
|
100
|
+
}
|
|
101
|
+
const node = element === void 0 ? null : mirror.getNode(element);
|
|
102
|
+
const rect = isElement(node) ? node.getBoundingClientRect() : void 0;
|
|
103
|
+
const box = rect === void 0 ? void 0 : {
|
|
104
|
+
x: rect.x,
|
|
105
|
+
y: rect.y,
|
|
106
|
+
width: rect.width,
|
|
107
|
+
height: rect.height
|
|
108
|
+
};
|
|
109
|
+
if (overlay === void 0) return box;
|
|
87
110
|
const marks = document.createElement("div");
|
|
88
111
|
marks.style.cssText = "position:fixed;inset:0;z-index:1;pointer-events:none";
|
|
89
112
|
marks.innerHTML = overlay;
|
|
90
113
|
document.body.append(marks);
|
|
114
|
+
return box;
|
|
91
115
|
}, shot);
|
|
92
|
-
const clip = clamp(shot.clip
|
|
116
|
+
const clip = clamp(shot.clip === void 0 ? {
|
|
93
117
|
x: 0,
|
|
94
118
|
y: 0,
|
|
95
119
|
...shot.viewport
|
|
96
|
-
}, shot.viewport);
|
|
97
|
-
return
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
120
|
+
} : found ?? shot.clip, shot.viewport);
|
|
121
|
+
return {
|
|
122
|
+
png: new Uint8Array(await page.screenshot({
|
|
123
|
+
type: "png",
|
|
124
|
+
...clip === void 0 ? {} : { clip }
|
|
125
|
+
})),
|
|
126
|
+
...found === void 0 || shot.clip !== void 0 ? {} : { box: found }
|
|
127
|
+
};
|
|
101
128
|
} finally {
|
|
102
129
|
await context.close();
|
|
103
130
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playwright.js","names":[],"sources":["../../src/plugins/screenshots/playwright.ts"],"sourcesContent":["/**\n * The `rrweb()` renderer's server half: rebuilds a page's snapshot in a browser beside the dev server and\n * screenshots it at the page's viewport, scroll and pixel density, so text lays out as the page's does. The\n * browser is launched on the first shot and kept for the next; Playwright closes it with the process.\n *\n * The snapshot is rebuilt into a sandboxed iframe filling a blank page on the page's own origin, which\n * Playwright answers itself, so nothing asks the dev server for it: rrweb has made the snapshot's URLs\n * whole, and its stylesheets' fonts and images load from the dev server as the page's did.\n *\n * The browser is as big as the page's window, scrollbars and all, and shows its own: a media query asks the\n * window's width, and the page is laid out in what the scrollbar leaves. At the width without it, a window\n * right on a breakpoint (1024 wide, 1009 to lay out in) would render as the narrower layout. The shot is then\n * cut to the part the page is in.\n */\nimport { createRequire } from 'node:module';\n\nimport type { Browser } from 'playwright-core';\nimport type * as Rrweb from 'rrweb-snapshot';\n\nimport type { Box, BrowserOptions } from './index.ts';\n\n/** What the page sends: its snapshot and what's needed to show it as the page does. */\n/** A node of an rrweb snapshot, as `snapshot()` answers it. */\nexport type SnapshotNode = NonNullable<ReturnType<typeof Rrweb.snapshot>>;\n\nexport interface Snapshot {\n snapshot: SnapshotNode;\n url: string;\n viewport: { width: number; height: number };\n /** The window's size, scrollbars included, where it has any: what the page's media queries ask. */\n window?: { width: number; height: number };\n scroll: { x: number; y: number };\n scale: number;\n /** The part of the viewport to keep, for a shot of an element alone. */\n clip?: Box;\n /** An SVG the viewport's size, drawn over the page: the annotations, where there are any. */\n overlay?: string;\n}\n\nconst HOST = '<!doctype html><html><body style=\"margin:0\"></body></html>';\n\nconst browsers = new Map<string, Promise<Browser>>();\n\n/** A browser by the options, launched once: the one named, or Playwright's own Chromium, then Chrome, then Edge. */\nexport function browserOf(options: BrowserOptions): Promise<Browser> {\n const key = JSON.stringify(options);\n const known = browsers.get(key);\n if (known !== undefined) return known;\n const launched = launch(options);\n browsers.set(key, launched);\n // A launch that failed is tried again on the next shot, after the user installs what it said to.\n launched.catch(() => browsers.delete(key));\n return launched;\n}\n\n/** Playwright hides a headless browser's scrollbars, and with them the room they take in the page. */\nconst SCROLLBARS = { ignoreDefaultArgs: ['--hide-scrollbars'] };\n\nasync function launch({ executablePath, channel }: BrowserOptions): Promise<Browser> {\n const { chromium } = await import('playwright-core').catch((e: unknown) => {\n throw new Error('the rrweb() renderer needs playwright-core: add it to your devDependencies', { cause: e });\n });\n if (executablePath !== undefined || channel !== undefined) return chromium.launch({ executablePath, channel, ...SCROLLBARS });\n const tried: string[] = [];\n for (const attempt of [{}, { channel: 'chrome' }, { channel: 'msedge' }]) {\n try {\n return await chromium.launch({ ...attempt, ...SCROLLBARS });\n } catch (e) {\n tried.push(\n `${'channel' in attempt ? attempt.channel : \"Playwright's Chromium\"}: ${(e instanceof Error ? e.message : String(e)).split('\\n', 1)[0]}`,\n );\n }\n }\n throw new Error(\n `the rrweb() renderer found no browser to render in (${tried.join('; ')}): run \\`npx playwright install chromium\\`, or pass rrweb({ executablePath })`,\n );\n}\n\n/** The rrweb-snapshot bundle that defines `rrwebSnapshot` in a page: its CommonJS entry is that bundle. */\nconst bundle = () => createRequire(import.meta.url).resolve('rrweb-snapshot');\n\nexport async function render(input: unknown, options: BrowserOptions): Promise<Uint8Array> {\n const shot = input as Snapshot;\n if (typeof shot?.url !== 'string' || typeof shot.snapshot !== 'object' || typeof shot.viewport?.width !== 'number')\n throw new Error('screenshots: that is not a snapshot the rrweb() renderer took');\n const browser = await browserOf(options);\n const context = await browser.newContext({ viewport: shot.window ?? shot.viewport, deviceScaleFactor: shot.scale });\n try {\n const page = await context.newPage();\n const host = new URL('/__deictic/plugins/screenshots/host', shot.url).href;\n await page.route(host, (route) => route.fulfill({ contentType: 'text/html', body: HOST }));\n await page.goto(host);\n await page.addScriptTag({ path: bundle() });\n await page.evaluate(async ({ snapshot, scroll, overlay }) => {\n const { rebuildIntoSandboxedIframe, createCache, createMirror } = (globalThis as unknown as { rrwebSnapshot: typeof Rrweb })\n .rrwebSnapshot;\n const { iframe } = rebuildIntoSandboxedIframe(snapshot, {\n root: document.body,\n cache: createCache(),\n mirror: createMirror(),\n iframeAttributes: { style: 'border:0;position:fixed;inset:0;width:100vw;height:100vh' },\n });\n const doc = iframe.contentDocument;\n if (doc === null) throw new Error('screenshots: the snapshot was rebuilt where it cannot be read');\n await doc.fonts.ready;\n await Promise.all([...doc.images].map((img) => img.decode().catch(() => {})));\n iframe.contentWindow?.scrollTo(scroll.x, scroll.y);\n if (overlay === undefined) return;\n // Over the page and its scroll: the SVG is the viewport's, already where it scrolled to.\n const marks = document.createElement('div');\n marks.style.cssText = 'position:fixed;inset:0;z-index:1;pointer-events:none';\n marks.innerHTML = overlay;\n document.body.append(marks);\n }, shot);\n // Without the scrollbars: a shot is what the page is drawn in, which is what an element's box is from.\n const clip = clamp(shot.clip ?? { x: 0, y: 0, ...shot.viewport }, shot.viewport);\n return new Uint8Array(await page.screenshot({ type: 'png', ...(clip === undefined ? {} : { clip }) }));\n } finally {\n await context.close();\n }\n}\n\n/** A box kept within the viewport: an element partly scrolled out of it shows only the part that's in. */\nfunction clamp(box: Box, viewport: { width: number; height: number }): Box | undefined {\n const x = Math.max(0, box.x);\n const y = Math.max(0, box.y);\n const width = Math.min(viewport.width, box.x + box.width) - x;\n const height = Math.min(viewport.height, box.y + box.height) - y;\n return width > 0 && height > 0 ? { x, y, width, height } : undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAuCA,MAAM,OAAO;AAEb,MAAM,2BAAW,IAAI,IAA8B;;AAGnD,SAAgB,UAAU,SAA2C;CACnE,MAAM,MAAM,KAAK,UAAU,OAAO;CAClC,MAAM,QAAQ,SAAS,IAAI,GAAG;CAC9B,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,MAAM,WAAW,OAAO,OAAO;CAC/B,SAAS,IAAI,KAAK,QAAQ;CAE1B,SAAS,YAAY,SAAS,OAAO,GAAG,CAAC;CACzC,OAAO;AACT;;AAGA,MAAM,aAAa,EAAE,mBAAmB,CAAC,mBAAmB,EAAE;AAE9D,eAAe,OAAO,EAAE,gBAAgB,WAA6C;CACnF,MAAM,EAAE,aAAa,MAAM,OAAO,kBAAkB,CAAC,OAAO,MAAe;EACzE,MAAM,IAAI,MAAM,8EAA8E,EAAE,OAAO,EAAE,CAAC;CAC5G,CAAC;CACD,IAAI,mBAAmB,KAAA,K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IAAI,KAAA;AAC7D"}
|
|
1
|
+
{"version":3,"file":"playwright.js","names":[],"sources":["../../src/plugins/screenshots/playwright.ts"],"sourcesContent":["/**\n * The `rrweb()` renderer's server half: rebuilds a page's snapshot in a browser beside the dev server and\n * screenshots it at the page's viewport, scroll and pixel density, so text lays out as the page's does. The\n * browser is launched on the first shot and kept for the next; Playwright closes it with the process.\n *\n * The snapshot is rebuilt into a sandboxed iframe filling a blank page on the page's own origin, which\n * Playwright answers itself, so nothing asks the dev server for it: rrweb has made the snapshot's URLs\n * whole, and its stylesheets' fonts and images load from the dev server as the page's did.\n *\n * The browser is as big as the page's window, scrollbars and all, and shows its own: a media query asks the\n * window's width, and the page is laid out in what the scrollbar leaves. At the width without it, a window\n * right on a breakpoint (1024 wide, 1009 to lay out in) would render as the narrower layout. The shot is then\n * cut to the part the page is in.\n */\nimport { createRequire } from 'node:module';\n\nimport type { Browser } from 'playwright-core';\nimport type * as Rrweb from 'rrweb-snapshot';\n\nimport type { Box, BrowserOptions } from './index.ts';\n\n/** What the page sends: its snapshot and what's needed to show it as the page does. */\n/** A node of an rrweb snapshot, as `snapshot()` answers it. */\nexport type SnapshotNode = NonNullable<ReturnType<typeof Rrweb.snapshot>>;\n\nexport interface Snapshot {\n snapshot: SnapshotNode;\n url: string;\n viewport: { width: number; height: number };\n /** The window's size, scrollbars included, where it has any: what the page's media queries ask. */\n window?: { width: number; height: number };\n scroll: { x: number; y: number };\n scale: number;\n /** The element the shot is of, as the snapshot numbers its nodes: found again in the rebuilt page, for where it is there. */\n element?: number;\n /** The part of the viewport to keep, for a shot of an element alone: where the element was in the page. */\n clip?: Box;\n /** An SVG the viewport's size, drawn over the page: the annotations, where there are any. */\n overlay?: string;\n}\n\nconst HOST = '<!doctype html><html><body style=\"margin:0\"></body></html>';\n\nconst browsers = new Map<string, Promise<Browser>>();\n\n/** A browser by the options, launched once: the one named, or Playwright's own Chromium, then Chrome, then Edge. */\nexport function browserOf(options: BrowserOptions): Promise<Browser> {\n const key = JSON.stringify(options);\n const known = browsers.get(key);\n if (known !== undefined) return known;\n const launched = launch(options);\n browsers.set(key, launched);\n // A launch that failed is tried again on the next shot, after the user installs what it said to.\n launched.catch(() => browsers.delete(key));\n return launched;\n}\n\n/** Playwright hides a headless browser's scrollbars, and with them the room they take in the page. */\nconst SCROLLBARS = { ignoreDefaultArgs: ['--hide-scrollbars'] };\n\nasync function launch({ executablePath, channel }: BrowserOptions): Promise<Browser> {\n const { chromium } = await import('playwright-core').catch((e: unknown) => {\n throw new Error('the rrweb() renderer needs playwright-core: add it to your devDependencies', { cause: e });\n });\n if (executablePath !== undefined || channel !== undefined) return chromium.launch({ executablePath, channel, ...SCROLLBARS });\n const tried: string[] = [];\n for (const attempt of [{}, { channel: 'chrome' }, { channel: 'msedge' }]) {\n try {\n return await chromium.launch({ ...attempt, ...SCROLLBARS });\n } catch (e) {\n tried.push(\n `${'channel' in attempt ? attempt.channel : \"Playwright's Chromium\"}: ${(e instanceof Error ? e.message : String(e)).split('\\n', 1)[0]}`,\n );\n }\n }\n throw new Error(\n `the rrweb() renderer found no browser to render in (${tried.join('; ')}): run \\`npx playwright install chromium\\`, or pass rrweb({ executablePath })`,\n );\n}\n\n/** The rrweb-snapshot bundle that defines `rrwebSnapshot` in a page: its CommonJS entry is that bundle. */\nconst bundle = () => createRequire(import.meta.url).resolve('rrweb-snapshot');\n\n/**\n * The PNG, and where the element is in it. That's measured in the rebuilt page, not taken from the live one: the\n * two can lay out a few pixels apart (a font that loaded differently, a panel's own scroll), and an outline drawn\n * at the live page's box would then cross the element.\n */\nexport async function render(input: unknown, options: BrowserOptions): Promise<{ png: Uint8Array; box?: Box }> {\n const shot = input as Snapshot;\n if (typeof shot?.url !== 'string' || typeof shot.snapshot !== 'object' || typeof shot.viewport?.width !== 'number')\n throw new Error('screenshots: that is not a snapshot the rrweb() renderer took');\n const browser = await browserOf(options);\n const context = await browser.newContext({ viewport: shot.window ?? shot.viewport, deviceScaleFactor: shot.scale });\n try {\n const page = await context.newPage();\n const host = new URL('/__deictic/plugins/screenshots/host', shot.url).href;\n await page.route(host, (route) => route.fulfill({ contentType: 'text/html', body: HOST }));\n await page.goto(host);\n await page.addScriptTag({ path: bundle() });\n const found = await page.evaluate(async ({ snapshot, scroll, overlay, element }) => {\n const { rebuildIntoSandboxedIframe, createCache, createMirror } = (globalThis as unknown as { rrwebSnapshot: typeof Rrweb })\n .rrwebSnapshot;\n const mirror = createMirror();\n const { iframe } = rebuildIntoSandboxedIframe(snapshot, {\n root: document.body,\n cache: createCache(),\n mirror,\n iframeAttributes: { style: 'border:0;position:fixed;inset:0;width:100vw;height:100vh' },\n });\n const doc = iframe.contentDocument;\n if (doc === null) throw new Error('screenshots: the snapshot was rebuilt where it cannot be read');\n await doc.fonts.ready;\n await Promise.all([...doc.images].map((img) => img.decode().catch(() => {})));\n iframe.contentWindow?.scrollTo(scroll.x, scroll.y);\n // rrweb scrolled each element as it built it, before the fonts and images gave its content its height:\n // one that couldn't scroll that far yet is scrolled again now.\n // By its kind: the iframe's elements aren't instances of this page's `Element`.\n const isElement = (node: Node | null): node is Element => node?.nodeType === 1;\n for (const id of mirror.getIds()) {\n const node = mirror.getNode(id);\n const meta = node === null ? null : mirror.getMeta(node);\n if (!isElement(node) || meta === null || !('attributes' in meta)) continue;\n const { rr_scrollTop: top, rr_scrollLeft: left } = meta.attributes;\n if (typeof top === 'number') node.scrollTop = top;\n if (typeof left === 'number') node.scrollLeft = left;\n }\n const node = element === undefined ? null : mirror.getNode(element);\n // The iframe fills the page from its top left, so a box in it is one in the shot.\n const rect = isElement(node) ? node.getBoundingClientRect() : undefined;\n const box = rect === undefined ? undefined : { x: rect.x, y: rect.y, width: rect.width, height: rect.height };\n if (overlay === undefined) return box;\n // Over the page and its scroll: the SVG is the viewport's, already where it scrolled to.\n const marks = document.createElement('div');\n marks.style.cssText = 'position:fixed;inset:0;z-index:1;pointer-events:none';\n marks.innerHTML = overlay;\n document.body.append(marks);\n return box;\n }, shot);\n // Without the scrollbars: a shot is what the page is drawn in, which is what an element's box is from.\n // A shot of the element alone is cut where the element is here.\n const clip = clamp(shot.clip === undefined ? { x: 0, y: 0, ...shot.viewport } : (found ?? shot.clip), shot.viewport);\n const png = new Uint8Array(await page.screenshot({ type: 'png', ...(clip === undefined ? {} : { clip }) }));\n return { png, ...(found === undefined || shot.clip !== undefined ? {} : { box: found }) };\n } finally {\n await context.close();\n }\n}\n\n/** A box kept within the viewport: an element partly scrolled out of it shows only the part that's in. */\nfunction clamp(box: Box, viewport: { width: number; height: number }): Box | undefined {\n const x = Math.max(0, box.x);\n const y = Math.max(0, box.y);\n const width = Math.min(viewport.width, box.x + box.width) - x;\n const height = Math.min(viewport.height, box.y + box.height) - y;\n return width > 0 && height > 0 ? { x, y, width, height } : undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAyCA,MAAM,OAAO;AAEb,MAAM,2BAAW,IAAI,IAA8B;;AAGnD,SAAgB,UAAU,SAA2C;CACnE,MAAM,MAAM,KAAK,UAAU,OAAO;CAClC,MAAM,QAAQ,SAAS,IAAI,GAAG;CAC9B,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,MAAM,WAAW,OAAO,OAAO;CAC/B,SAAS,IAAI,KAAK,QAAQ;CAE1B,SAAS,YAAY,SAAS,OAAO,GAAG,CAAC;CACzC,OAAO;AACT;;AAGA,MAAM,aAAa,EAAE,mBAAmB,CAAC,mBAAmB,EAAE;AAE9D,eAAe,OAAO,EAAE,gBAAgB,WAA6C;CACnF,MAAM,EAAE,aAAa,MAAM,OAAO,kBAAkB,CAAC,OAAO,MAAe;EACzE,MAAM,IAAI,MAAM,8EAA8E,EAAE,OAAO,EAAE,CAAC;CAC5G,CAAC;CACD,IAAI,mBAAmB,KAAA,KAAa,YAAY,KAAA,GAAW,OAAO,SAAS,OAAO;EAAE;EAAgB;EAAS,GAAG;CAAW,CAAC;CAC5H,MAAM,QAAkB,CAAC;CACzB,KAAK,MAAM,WAAW;EAAC,CAAC;EAAG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G,KAAK;EAAS,IAAK,SAAS,KAAK,MAAO,KAAK,QAAQ;EAEnH,OAAO;GAAE,KAAA,IADO,WAAW,MAAM,KAAK,WAAW;IAAE,MAAM;IAAO,GAAI,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,KAAK;GAAG,CAAC,CAC9F;GAAG,GAAI,UAAU,KAAA,KAAa,KAAK,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,KAAK,MAAM;EAAG;CAC1F,UAAU;EACR,MAAM,QAAQ,MAAM;CACtB;AACF;;AAGA,SAAS,MAAM,KAAU,UAA8D;CACrF,MAAM,IAAI,KAAK,IAAI,GAAG,IAAI,CAAC;CAC3B,MAAM,IAAI,KAAK,IAAI,GAAG,IAAI,CAAC;CAC3B,MAAM,QAAQ,KAAK,IAAI,SAAS,OAAO,IAAI,IAAI,IAAI,KAAK,IAAI;CAC5D,MAAM,SAAS,KAAK,IAAI,SAAS,QAAQ,IAAI,IAAI,IAAI,MAAM,IAAI;CAC/D,OAAO,QAAQ,KAAK,SAAS,IAAI;EAAE;EAAG;EAAG;EAAO;CAAO,IAAI,KAAA;AAC7D"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { t as annotations } from "./annotations.js";
|
|
2
|
+
import { t as logs } from "./logs.js";
|
|
3
|
+
import { t as network } from "./network.js";
|
|
4
|
+
import { t as recordings } from "./recordings.js";
|
|
5
|
+
import { r as screenshots } from "./screenshots.js";
|
|
6
|
+
import { t as tasks } from "./tasks.js";
|
|
7
|
+
import { t as voice } from "./voice.js";
|
|
8
|
+
// src/plugins/recommended/index.ts
|
|
9
|
+
/**
|
|
10
|
+
* Tasks, screenshots, annotations, recordings and voice, in that order, the order of their tabs, then what a
|
|
11
|
+
* recording has besides the page: logs and network.
|
|
12
|
+
*/
|
|
13
|
+
function recommended(options = {}) {
|
|
14
|
+
const plugins = [];
|
|
15
|
+
if (options.tasks !== false) plugins.push(tasks(options.tasks));
|
|
16
|
+
if (options.screenshots !== false) plugins.push(screenshots(options.screenshots));
|
|
17
|
+
if (options.annotations !== false) plugins.push(annotations(options.annotations));
|
|
18
|
+
if (options.recordings !== false) plugins.push(recordings(options.recordings));
|
|
19
|
+
if (options.voice !== false) plugins.push(voice(options.voice));
|
|
20
|
+
if (options.recordings !== false && options.logs !== false) plugins.push(logs(options.logs));
|
|
21
|
+
if (options.recordings !== false && options.network !== false) plugins.push(network(options.network));
|
|
22
|
+
return plugins;
|
|
23
|
+
}
|
|
24
|
+
export { recommended as t };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=recommended.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recommended.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"}
|