deictic 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API.md +71 -17
- package/README.md +1 -1
- package/dist/annotations/client.js +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 +11 -7
- package/dist/client/index.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 +1 -1
- package/dist/shared/index.d.ts +6 -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/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/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/package.json +25 -1
- 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 +21 -14
- package/src/index.ts +6 -0
- 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
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `deictic/recommended`: the plugins for describing a change rather than making it. Alt-click an element, say what
|
|
3
3
|
* should change, attach a screenshot to draw on, a screen recording or your voice, and it goes to a Vercel Board.
|
|
4
|
-
* A recording has the page's console and its requests in it too
|
|
4
|
+
* A recording has the page's console and its requests in it too, and in a React project a task has the props and
|
|
5
|
+
* state of the components that wrote its element.
|
|
5
6
|
*
|
|
6
7
|
* Only the server halves, as every factory is: each names its page half, which the integration imports. A plugin
|
|
7
|
-
* outside the preset (Tailwind, your own) goes beside it: `plugins: [...
|
|
8
|
+
* outside the preset (Tailwind, your own) goes beside it: `plugins: [...deicticRecommended(), tailwind()]`. Named for
|
|
9
|
+
* deictic, as a config imports other presets called `recommended`.
|
|
8
10
|
*/
|
|
9
11
|
import { y as ServerPlugin } from "../shared/index.js";
|
|
10
12
|
import { i as AnnotationsOptions } from "../shared/index2.js";
|
|
11
13
|
import { n as LogsOptions } from "../shared/index5.js";
|
|
12
14
|
import { t as NetworkOptions } from "../shared/index6.js";
|
|
15
|
+
import { i as ReactOptions } from "../shared/index7.js";
|
|
13
16
|
import { c as RecordingsOptions } from "../shared/index4.js";
|
|
14
17
|
import { l as ScreenshotsOptions } from "../shared/index3.js";
|
|
15
|
-
import { _ as TasksOptions } from "../shared/
|
|
16
|
-
import { a as VoiceOptions } from "../shared/
|
|
18
|
+
import { _ as TasksOptions } from "../shared/index8.js";
|
|
19
|
+
import { a as VoiceOptions } from "../shared/index9.js";
|
|
17
20
|
/** Each plugin's options, by its name, or `false` to leave it out. */
|
|
18
21
|
export interface RecommendedOptions {
|
|
19
22
|
tasks?: TasksOptions | false;
|
|
@@ -25,11 +28,16 @@ export interface RecommendedOptions {
|
|
|
25
28
|
logs?: LogsOptions | false;
|
|
26
29
|
/** The page's requests in a recording, masked. */
|
|
27
30
|
network?: NetworkOptions | false;
|
|
31
|
+
/**
|
|
32
|
+
* The props, state and hooks of the components that wrote a task's element: where the project has React (found from
|
|
33
|
+
* the working directory, where the dev server starts), unless it's `false`.
|
|
34
|
+
*/
|
|
35
|
+
react?: ReactOptions | false;
|
|
28
36
|
}
|
|
29
37
|
/**
|
|
30
38
|
* Tasks, screenshots, annotations, recordings and voice, in that order, the order of their tabs, then what a
|
|
31
|
-
* recording has besides the page: logs and network.
|
|
39
|
+
* recording has besides the page: logs and network, and React's state where the project has React.
|
|
32
40
|
*/
|
|
33
|
-
export declare function
|
|
34
|
-
export {
|
|
41
|
+
export declare function deicticRecommended(options?: RecommendedOptions): ServerPlugin[];
|
|
42
|
+
export { deicticRecommended as default };
|
|
35
43
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/plugins/recommended/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/plugins/recommended/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;iBAsBiB;EACf,QAAQ;EACR,cAAc;EACd,cAAc;EACd,aAAa;EACb,QAAQ;;EAER,OAAO;;EAEP,UAAU;;;;;EAKV,QAAQ;;;;;;wBAOM,mBAAmB,UAAS,qBAA0B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as default, t as
|
|
1
|
+
export { t as default, t as deicticRecommended } from "../shared/recommended.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","names":[],"sources":["../../src/plugins/recordings/client.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"client.d.ts","names":[],"sources":["../../src/plugins/recordings/client.ts"],"mappings":";cAiHA,4B"}
|
|
@@ -1,8 +1,8 @@
|
|
|
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";
|
|
5
|
-
import { n as MARKS, r as PAGE, t as END } from "../shared/marks.js";
|
|
5
|
+
import { i as REACT, n as MARKS, r as PAGE, t as END } from "../shared/marks.js";
|
|
6
6
|
// src/plugins/recordings/ours.ts
|
|
7
7
|
/** rrweb's numbers: an incremental snapshot, and the sources whose data is a list of pointer positions. */
|
|
8
8
|
const INCREMENTAL = 3;
|
|
@@ -73,12 +73,27 @@ function dropOurs(hostId, pageId) {
|
|
|
73
73
|
* the time running, and turns the mic back on where it was.
|
|
74
74
|
*
|
|
75
75
|
* Nothing of deictic's is recorded: the overlay is blocked, as rrweb blocks. The marks are, as custom
|
|
76
|
-
* events: the page's annotations, as SVGs in page coordinates, at the start and at each change.
|
|
76
|
+
* events: the page's annotations, as SVGs in page coordinates, at the start and at each change. So are React's
|
|
77
|
+
* commits, where the react plugin is loaded, while its button is on (P): off by default, and as it was last left.
|
|
77
78
|
*/
|
|
78
79
|
/** Where the recording going on is kept, for the tab's next page to carry on with. */
|
|
79
80
|
const GOING = "deictic:recording";
|
|
80
81
|
/** How often the events are sent, in milliseconds. */
|
|
81
82
|
const EVERY = 1e3;
|
|
83
|
+
/** Whether the last recording had React's commits going in when it ended, for the next to start as it was left. */
|
|
84
|
+
const REACT_ON = "deictic:recording:react";
|
|
85
|
+
const reactWanted = () => {
|
|
86
|
+
try {
|
|
87
|
+
return localStorage.getItem(REACT_ON) === "true";
|
|
88
|
+
} catch {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
const wantReact = (on) => {
|
|
93
|
+
try {
|
|
94
|
+
localStorage.setItem(REACT_ON, String(on));
|
|
95
|
+
} catch {}
|
|
96
|
+
};
|
|
82
97
|
function carried() {
|
|
83
98
|
try {
|
|
84
99
|
return JSON.parse(sessionStorage.getItem(GOING) ?? "null") ?? void 0;
|
|
@@ -103,6 +118,7 @@ const STYLE = `
|
|
|
103
118
|
.tool-panel.vertical .recorder .live { flex-direction: column; gap: 2px; padding: 4px 0; }
|
|
104
119
|
.recorder .dot { width: 8px; height: 8px; border-radius: 50%; background: #ef4444; animation: deictic-blink 1.2s infinite; }
|
|
105
120
|
.recorder .mic[aria-pressed='true'], .recorder .mic[aria-pressed='true']:hover { background: #ef4444; color: #fff; }
|
|
121
|
+
.recorder .react[aria-pressed='true'], .recorder .react[aria-pressed='true']:hover { background: #087ea4; color: #fff; }
|
|
106
122
|
.recorder .wave { width: 44px; height: 18px; }
|
|
107
123
|
.tool-panel.vertical .recorder .wave { width: 28px; }
|
|
108
124
|
@keyframes deictic-blink { 50% { opacity: 0.3; } }
|
|
@@ -112,6 +128,8 @@ const RECORD = "<circle cx=\"12\" cy=\"12\" r=\"8\"/><circle cx=\"12\" cy=\"12\"
|
|
|
112
128
|
const STOP = "<rect x=\"6\" y=\"6\" width=\"12\" height=\"12\" rx=\"1\" fill=\"currentColor\"/>";
|
|
113
129
|
const DISCARD = "<path d=\"M6 6l12 12M18 6 6 18\"/>";
|
|
114
130
|
const MIC = "<rect x=\"9\" y=\"3\" width=\"6\" height=\"11\" rx=\"3\"/><path d=\"M5 11a7 7 0 0 0 14 0M12 18v3\"/>";
|
|
131
|
+
/** An atom, as React's own mark is drawn. */
|
|
132
|
+
const ATOM = "<circle cx=\"12\" cy=\"12\" r=\"1.6\" fill=\"currentColor\"/><ellipse cx=\"12\" cy=\"12\" rx=\"10\" ry=\"4\"/><ellipse cx=\"12\" cy=\"12\" rx=\"10\" ry=\"4\" transform=\"rotate(60 12 12)\"/><ellipse cx=\"12\" cy=\"12\" rx=\"10\" ry=\"4\" transform=\"rotate(120 12 12)\"/>";
|
|
115
133
|
const clock = (ms) => {
|
|
116
134
|
const s = Math.floor(ms / 1e3);
|
|
117
135
|
return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`;
|
|
@@ -243,6 +261,8 @@ var client_default = defineClientPlugin({
|
|
|
243
261
|
mark();
|
|
244
262
|
const voice = use("voice");
|
|
245
263
|
let take;
|
|
264
|
+
const commits = use("react")?.commits;
|
|
265
|
+
let unreact;
|
|
246
266
|
/** What the next page carries on from, kept as it changes: a page that's going has no time to say it then. */
|
|
247
267
|
let over = false;
|
|
248
268
|
const save = () => over || carry({
|
|
@@ -250,7 +270,8 @@ var client_default = defineClientPlugin({
|
|
|
250
270
|
startedAt,
|
|
251
271
|
seq,
|
|
252
272
|
clips,
|
|
253
|
-
mic: take !== void 0
|
|
273
|
+
mic: take !== void 0,
|
|
274
|
+
react: unreact !== void 0
|
|
254
275
|
});
|
|
255
276
|
const unsubscribe = marks?.subscribe(mark);
|
|
256
277
|
let sending = Promise.resolve();
|
|
@@ -333,6 +354,26 @@ var client_default = defineClientPlugin({
|
|
|
333
354
|
mic?.classList.add("mic");
|
|
334
355
|
mic?.setAttribute("aria-pressed", "false");
|
|
335
356
|
if (from?.mic === true) toggle();
|
|
357
|
+
const react = commits === void 0 ? void 0 : toolButton(ATOM, "Record React's commits: what rendered, how long it took, and why", "P", () => reactOn(unreact === void 0));
|
|
358
|
+
react?.classList.add("react");
|
|
359
|
+
const reactOn = (on) => {
|
|
360
|
+
if (commits === void 0 || react === void 0 || on === (unreact !== void 0)) return;
|
|
361
|
+
if (on) {
|
|
362
|
+
rrweb.record.addCustomEvent(REACT, { on: true });
|
|
363
|
+
unreact = commits((commit) => rrweb.record.addCustomEvent(REACT, commit));
|
|
364
|
+
} else {
|
|
365
|
+
unreact?.();
|
|
366
|
+
unreact = void 0;
|
|
367
|
+
rrweb.record.addCustomEvent(REACT, { on: false });
|
|
368
|
+
}
|
|
369
|
+
react.setAttribute("aria-pressed", String(on));
|
|
370
|
+
react.title = on ? "Stop recording React's commits" : "Record React's commits: what rendered, how long it took, and why";
|
|
371
|
+
react.setAttribute("aria-label", react.title);
|
|
372
|
+
wantReact(on);
|
|
373
|
+
save();
|
|
374
|
+
};
|
|
375
|
+
react?.setAttribute("aria-pressed", "false");
|
|
376
|
+
if (from?.react ?? reactWanted()) reactOn(true);
|
|
336
377
|
const leave = () => {
|
|
337
378
|
const spoken = take?.soFar();
|
|
338
379
|
if (take !== void 0 && spoken !== void 0) clips.push({
|
|
@@ -348,6 +389,8 @@ var client_default = defineClientPlugin({
|
|
|
348
389
|
};
|
|
349
390
|
addEventListener("pagehide", leave);
|
|
350
391
|
const end = async (kept) => {
|
|
392
|
+
unreact?.();
|
|
393
|
+
unreact = void 0;
|
|
351
394
|
rrweb.record.addCustomEvent(END, {});
|
|
352
395
|
stopRecording?.();
|
|
353
396
|
unsubscribe?.();
|
|
@@ -385,7 +428,7 @@ var client_default = defineClientPlugin({
|
|
|
385
428
|
};
|
|
386
429
|
const stop = toolButton(STOP, "Stop", "R", () => void end(true));
|
|
387
430
|
const discard = toolButton(DISCARD, "Discard", "Shift+R", () => void end(false));
|
|
388
|
-
going.replaceChildren(live, ...mic ? [mic, wave] : [], stop, discard);
|
|
431
|
+
going.replaceChildren(live, ...mic ? [mic, wave] : [], ...react ? [react] : [], stop, discard);
|
|
389
432
|
const unkeep = tools.keep();
|
|
390
433
|
start.hidden = true;
|
|
391
434
|
going.hidden = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":[],"sources":["../../src/plugins/recordings/ours.ts","../../src/plugins/recordings/client.ts"],"sourcesContent":["/**\n * Keeps deictic's own UI out of a recording. Blocking the overlay keeps it out of the first snapshot,\n * but rrweb watches a blocked host's shadow root all the same, so what's added there later (the toolbar,\n * a note's field) comes as mutations. This drops them, and clicks and input on those nodes, by the IDs\n * rrweb gave them: the host's, and every node added under one of ours.\n *\n * The pointer's moves over them stay, on the page's root instead: the replay moves its cursor only over a\n * node it has, and while a drawing tool is picked the pointer is over ours the whole time.\n */\n\n/** The parts of rrweb's events this reads; the rest passes as it is. */\ninterface Event {\n type: number;\n data?: unknown;\n}\n\ninterface Mutation {\n source: 0;\n adds: { parentId: number; node: { id: number } }[];\n removes: { parentId: number; id: number }[];\n texts: { id: number }[];\n attributes: { id: number }[];\n}\n\n/** rrweb's numbers: an incremental snapshot, and the sources whose data is a list of pointer positions. */\nconst INCREMENTAL = 3;\nconst MUTATION = 0;\nconst POSITIONS = new Set([1, 6, 12]);\n\n/** A filter for `emit`: the event without our nodes, or nothing when nothing else is left in it. */\nexport function dropOurs<E extends Event>(hostId: () => number, pageId: () => number): (event: E) => E | undefined {\n const ours = new Set<number>();\n return (event) => {\n if (ours.size === 0) {\n const id = hostId();\n if (id > 0) ours.add(id);\n }\n if (event.type !== INCREMENTAL || typeof event.data !== 'object' || event.data === null) return event;\n const data = event.data as { source: number; id?: number; positions?: { id: number }[] };\n\n if (data.source === MUTATION) {\n const m = data as Mutation;\n // Added parents and children come in any order: claim until nothing more is ours.\n for (let grew = true; grew;) {\n grew = false;\n for (const add of m.adds) {\n if (ours.has(add.parentId) && !ours.has(add.node.id)) {\n ours.add(add.node.id);\n grew = true;\n }\n }\n }\n const kept: Mutation = {\n ...m,\n adds: m.adds.filter((a) => !ours.has(a.node.id)),\n removes: m.removes.filter((r) => !ours.has(r.id) && !ours.has(r.parentId)),\n texts: m.texts.filter((t) => !ours.has(t.id)),\n attributes: m.attributes.filter((a) => !ours.has(a.id)),\n };\n const left = kept.adds.length + kept.removes.length + kept.texts.length + kept.attributes.length;\n return left === 0 ? undefined : { ...event, data: kept };\n }\n if (POSITIONS.has(data.source) && Array.isArray(data.positions)) {\n const page = pageId();\n const positions = data.positions.map((p) => (ours.has(p.id) ? { ...p, id: page } : p));\n return { ...event, data: { ...data, positions } };\n }\n return data.id !== undefined && ours.has(data.id) ? undefined : event;\n };\n}\n","/**\n * The recordings plugin's page half. Its tool in the tool panel is Record: `record()` starts rrweb (imported\n * then), and while one is going the panel stays, with the time, the mic where the voice plugin is loaded, and\n * Stop and Discard in Record's place. A recording that's stopped goes in the tray, for the next task.\n *\n * The events go to the server as they happen (`begin`, a `part` each second, `end` on Stop), and what the next\n * page needs to carry on is kept in the tab's session storage: a reload, or a link to another page of the site,\n * leaves the recording going. The page that loads starts rrweb again under the same ID, which makes it a\n * recording of several pages as rrweb has them (a `Meta` and a snapshot for each), puts its controls back with\n * the time running, and turns the mic back on where it was.\n *\n * Nothing of deictic's is recorded: the overlay is blocked, as rrweb blocks. The marks are, as custom\n * events: the page's annotations, as SVGs in page coordinates, at the start and at each change.\n */\nimport { toolButton } from '#src/client/dom.ts';\nimport { playMark, trayed } from '#src/client/drawer.ts';\nimport { liveWaveform } from '#src/client/waveform.ts';\nimport { defineClientPlugin } from '#src/index.ts';\nimport type { ResolvedMasking } from '#src/plugins/screenshots/index.ts';\n\nimport type { Take } from '#src/plugins/voice/index.ts';\n\nimport type { Kept, Meta, Recorder, Recording, RecordPlugin, VoiceClip } from './index.ts';\nimport { END, MARKS, PAGE } from './marks.ts';\nimport { dropOurs } from './ours.ts';\n\n/** Where the recording going on is kept, for the tab's next page to carry on with. */\nconst GOING = 'deictic:recording';\n/** How often the events are sent, in milliseconds. */\nconst EVERY = 1000;\n\n/** A recording going on, as the next page needs it. */\ninterface Carried {\n id: string;\n startedAt: number;\n /** The next part's place among the parts. */\n seq: number;\n /** The mic's clips so far, and whether it was on. */\n clips: VoiceClip[];\n mic: boolean;\n}\n\nfunction carried(): Carried | undefined {\n try {\n return (JSON.parse(sessionStorage.getItem(GOING) ?? 'null') as Carried | null) ?? undefined;\n } catch {\n // Storage can be off: nothing carries over, then.\n return undefined;\n }\n}\n\nfunction carry(going: Carried | undefined): void {\n try {\n if (going === undefined) sessionStorage.removeItem(GOING);\n else sessionStorage.setItem(GOING, JSON.stringify(going));\n } catch {\n // Not kept, then: a page load ends the recording.\n }\n}\n\nconst STYLE = `\n.recorder .going { display: flex; align-items: center; gap: 4px; }\n/* Away while nothing records: laid out empty, it would still count in the group's gap. */\n.recorder .going[hidden] { display: none; }\n/* While one goes, its controls are its section's alone: the other tools that capture (a shot, the mic, a task) wait. */\n.tool-panel:has(.recorder.going) .tool-group[data-section='capture']:not(.recorder) { display: none; }\n.tool-panel.vertical .recorder .going { flex-direction: column; }\n.recorder .live { display: inline-flex; align-items: center; gap: 6px; padding: 0 4px; font: 12px ui-monospace, monospace; }\n.tool-panel.vertical .recorder .live { flex-direction: column; gap: 2px; padding: 4px 0; }\n.recorder .dot { width: 8px; height: 8px; border-radius: 50%; background: #ef4444; animation: deictic-blink 1.2s infinite; }\n.recorder .mic[aria-pressed='true'], .recorder .mic[aria-pressed='true']:hover { background: #ef4444; color: #fff; }\n.recorder .wave { width: 44px; height: 18px; }\n.tool-panel.vertical .recorder .wave { width: 28px; }\n@keyframes deictic-blink { 50% { opacity: 0.3; } }\n`;\n\n/** Each icon's strokes, on a 24-pixel grid. */\nconst RECORD = '<circle cx=\"12\" cy=\"12\" r=\"8\"/><circle cx=\"12\" cy=\"12\" r=\"3\" fill=\"currentColor\"/>';\nconst STOP = '<rect x=\"6\" y=\"6\" width=\"12\" height=\"12\" rx=\"1\" fill=\"currentColor\"/>';\nconst DISCARD = '<path d=\"M6 6l12 12M18 6 6 18\"/>';\nconst MIC = '<rect x=\"9\" y=\"3\" width=\"6\" height=\"11\" rx=\"3\"/><path d=\"M5 11a7 7 0 0 0 14 0M12 18v3\"/>';\n\nconst clock = (ms: number) => {\n const s = Math.floor(ms / 1000);\n return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, '0')}`;\n};\n\nexport default defineClientPlugin<never, never, Recorder>({\n name: 'recordings',\n setup: ({ base, root, options, use, request, report, tools, tray, drawer, lightbox }) => {\n const { masking, canvas } = options as { masking: ResolvedMasking; canvas?: false | { fps: number } };\n let running: Promise<Recording | undefined> | undefined;\n\n // In the tool panel: Record, and in its place while one is going, what `record` puts there.\n const group = Object.assign(document.createElement('div'), { className: 'tool-group recorder' });\n const going = Object.assign(document.createElement('div'), { className: 'going', hidden: true });\n const start = toolButton(RECORD, 'Record', 'R', () => {\n run().catch((e: unknown) => {\n // Said where it was asked for: its tooltip, which a missing package's fix fits in.\n start.classList.add('problem');\n start.title = e instanceof Error ? e.message : String(e);\n });\n });\n group.append(Object.assign(document.createElement('style'), { textContent: STYLE }), start, going);\n // Beside the other tools that capture the page: a shot, a recording, the mic.\n tools.add(group, { section: 'capture' });\n // In the drawer until a task takes them: each plays back in the lightbox.\n drawer.add(\n trayed({ tray }, 'recordings', 'Recordings', (item, i, all) => {\n const { url, duration, voice } = item.value as Recording;\n const name = `${all.length === 1 ? 'Recording' : `Recording ${i + 1}`} ${clock(duration)}`;\n return {\n label: [playMark(), `${name}${voice === undefined ? '' : ' · voice'}`],\n // The replay filling the frame, without a header of its own: the lightbox names it.\n open: (from) => lightbox([{ kind: 'page', url: `${url}${url.includes('?') ? '&' : '?'}embed`, title: name }], { from }),\n };\n }),\n );\n\n const post = async (route: string, body: unknown, keepalive = false) => {\n const res = await request(route, {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify(body),\n ...(keepalive ? { keepalive } : {}),\n });\n // `url`: where it replays, said by what keeps it with no server to serve it from (a `standalone` build).\n const answer = (await res.json()) as { id?: string; url?: string; problem?: string };\n if (answer.id === undefined) throw new Error(`recordings: ${answer.problem ?? res.statusText}`);\n return { id: answer.id, url: answer.url };\n };\n\n /** Records until Stop or Discard: a new recording, or `from`, one a page before this started. */\n const record = async (from?: Carried): Promise<Recording | undefined> => {\n const startedAt = from?.startedAt ?? Date.now();\n const begin = async (): Promise<string> => {\n const viewport = { width: document.documentElement.clientWidth, height: document.documentElement.clientHeight };\n const colorScheme = matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';\n return (await post('begin', { page: location.href, viewport, colorScheme, startedAt } satisfies Meta)).id;\n };\n // What else goes in the recording, where its plugin is loaded: the console's lines and the page's requests, each\n // rrweb's own plugin, which listens from when rrweb starts until it stops. One that can't be had (its package\n // isn't installed) is said, and the recording goes on without.\n const extra = (name: 'logs' | 'network'): Promise<RecordPlugin | undefined> | undefined =>\n use(name)\n // A page that carries a recording on made requests before this: those of its load are the recording's too.\n ?.plugin({ sinceLoad: from !== undefined })\n .catch((e: unknown) => {\n const why = e instanceof Error ? e.message : String(e);\n report({\n key: `page:recordings:${name}:${why.split('\\n', 1)[0]!.slice(0, 200)}`,\n kind: 'setup',\n message: `recordings go without ${name}, as it couldn't be loaded: install what it needs (\\`deictic init\\` does), then load the page again: ${why}`,\n ...(e instanceof Error && e.stack !== undefined ? { details: e.stack } : {}),\n });\n return undefined;\n });\n const [rrweb, id, ...extras] = await Promise.all([\n import('rrweb').catch((e: unknown) => {\n throw new Error('recordings need rrweb: add it to your devDependencies', { cause: e });\n }),\n from?.id ?? begin(),\n extra('logs'),\n extra('network'),\n ]);\n const clips: VoiceClip[] = from?.clips ?? [];\n // What the server doesn't have yet, and the place of the next part sent.\n let unsent: { type: number; data?: unknown }[] = [];\n let seq = from?.seq ?? 0;\n const host = root.host;\n const keep = dropOurs<(typeof unsent)[number]>(\n () => rrweb.record.mirror.getId(host),\n () => rrweb.record.mirror.getId(document.documentElement),\n );\n // The page's address changing with no load (a router's `pushState`, Back within the app, a hash), which rrweb\n // doesn't record: a custom event, so the recording says where each stretch happened. Nothing tells of\n // `pushState`, so it's read as each event comes, and as the clock ticks for a route that draws nothing.\n let href = location.href;\n const moved = () => {\n if (location.href === href) return;\n href = location.href;\n rrweb.record.addCustomEvent(PAGE, { href });\n };\n const stopRecording = rrweb.record({\n emit: (event) => {\n // Before what the new route drew, which is what comes next.\n moved();\n const kept = keep(event);\n if (kept !== undefined) unsent.push(kept);\n },\n plugins: extras.filter((plugin) => plugin !== undefined),\n blockClass: masking.blockClass,\n // deictic's own UI, the overlay: a blocked element is kept as an empty box its size, and it has none.\n blockSelector: ['deictic-overlay', ...(masking.blockSelector ? [masking.blockSelector] : [])].join(', '),\n maskTextClass: masking.maskTextClass,\n ...(masking.maskTextSelector ? { maskTextSelector: masking.maskTextSelector } : {}),\n maskAllInputs: masking.maskAllInputs,\n maskInputOptions: { password: true },\n inlineStylesheet: true,\n // A canvas as pictures of it, a few a second and only when it changed: rrweb's other way keeps every call\n // drawn on it, for which it wraps each drawing method of every canvas.\n ...(canvas === false || canvas === undefined\n ? {}\n : { recordCanvas: true, sampling: { canvas: canvas.fps }, dataURLOptions: { type: 'image/webp', quality: 0.6 } }),\n });\n\n // The marks, now and at each change: an SVG whose view is the page from its top left, at 1:1.\n const marks = use('annotations');\n const mark = () => {\n const area = { x: -scrollX, y: -scrollY, width: 1, height: 1 };\n rrweb.record.addCustomEvent(MARKS, {\n svg: marks?.svg(area) ?? '',\n // The same marks as data, in page coordinates, for whatever reads the recording but doesn't draw it.\n annotations: marks?.list() ?? [],\n });\n };\n mark();\n\n // The mic, where the voice plugin is loaded: each stretch it's on is a clip, at its time in the recording.\n const voice = use('voice');\n let take: Take | undefined;\n /** What the next page carries on from, kept as it changes: a page that's going has no time to say it then. */\n let over = false;\n const save = () =>\n // Not once it's ended, as its last events go: the next page would carry on with one that's over.\n over || carry({ id, startedAt, seq, clips, mic: take !== undefined });\n const unsubscribe = marks?.subscribe(mark);\n\n // One part at a time, each with its place. A part that didn't arrive goes again with the next, before it.\n let sending: Promise<void> = Promise.resolve();\n const flush = () => {\n const next = sending\n .catch(() => {})\n .then(async () => {\n if (unsent.length === 0) return;\n const part = unsent;\n unsent = [];\n const at = seq++;\n save();\n try {\n await post(`part/${id}?seq=${at}`, part);\n } catch (e) {\n unsent = [...part, ...unsent];\n throw e;\n }\n });\n sending = next;\n return next;\n };\n // A problem is heard at Stop, where it matters: a part that fails meanwhile goes again a second on.\n const flushing = setInterval(() => void flush().catch(() => {}), EVERY);\n save();\n\n return new Promise((done, fail) => {\n const live = Object.assign(document.createElement('span'), { className: 'live' });\n const dot = Object.assign(document.createElement('span'), { className: 'dot' });\n const time = document.createElement('span');\n live.append(dot, time);\n\n // The mic's live waveform beside it while it's on, so it's plain it hears.\n const wave = Object.assign(document.createElement('canvas'), { className: 'wave', hidden: true });\n let stopWave: (() => void) | undefined;\n const unwave = () => {\n stopWave?.();\n stopWave = undefined;\n wave.hidden = true;\n };\n // What the mic is doing (asking for it, keeping a take): the next toggle, and the end, wait for it.\n let busy: Promise<void> = Promise.resolve();\n const micOff = async () => {\n const ending = take;\n take = undefined;\n unwave();\n if (ending === undefined) return;\n try {\n const clip = await ending.stop();\n clips.push({ id: clip.id, at: ending.started - startedAt, duration: clip.duration });\n } catch (e) {\n // The recording is worth keeping without it.\n console.warn('deictic: the voice clip was not kept', e);\n }\n };\n const mic = voice === undefined ? undefined : toolButton(MIC, 'Turn the mic on', 'K', () => toggle());\n const toggle = () => {\n busy = busy.then(async () => {\n if (voice === undefined || mic === undefined) return;\n if (take !== undefined) {\n await micOff();\n } else {\n try {\n take = await voice.start();\n mic.classList.remove('problem');\n wave.hidden = false;\n stopWave = liveWaveform(wave, take.stream, { played: '#ef4444', rest: '#52525b' });\n } catch (e) {\n mic.classList.add('problem');\n mic.title = e instanceof Error ? e.message : String(e);\n return;\n }\n }\n const on = take !== undefined;\n mic.setAttribute('aria-pressed', String(on));\n mic.title = on ? 'Turn the mic off' : 'Turn the mic on';\n mic.setAttribute('aria-label', mic.title);\n save();\n });\n };\n mic?.classList.add('mic');\n mic?.setAttribute('aria-pressed', 'false');\n // On, as the page before left it: a browser that was let use the mic gives it again without asking.\n if (from?.mic === true) toggle();\n\n // The page is going, for another or for good, with no time to wait for anything: what's sent of the mic's\n // take is its clip, the next page is told where things stand, and the last events go as the page does.\n const leave = () => {\n const spoken = take?.soFar();\n if (take !== undefined && spoken !== undefined)\n clips.push({ id: spoken.id, at: take.started - startedAt, duration: spoken.duration });\n const part = unsent;\n unsent = [];\n const at = seq++;\n save();\n // Not behind `sending`, which a page that's going never gets to: the server orders the parts by their place.\n // A browser sends 64 KB at most for a page that's gone, so a last second busier than that is lost.\n if (part.length > 0) void post(`part/${id}?seq=${at}`, part, true).catch(() => {});\n };\n addEventListener('pagehide', leave);\n\n const end = async (kept: boolean) => {\n rrweb.record.addCustomEvent(END, {});\n stopRecording?.();\n unsubscribe?.();\n clearInterval(flushing);\n clearInterval(ticking);\n removeEventListener('pagehide', leave);\n idle();\n over = true;\n carry(undefined);\n await busy;\n if (!kept) {\n unwave();\n take?.cancel();\n void post(`discard/${id}`, {}).catch(() => {});\n return done(undefined);\n }\n await micOff();\n const duration = Date.now() - startedAt;\n const voiced = clips.length > 0 ? { voice: clips } : {};\n try {\n await flush();\n const { url } = await post(`end/${id}`, { duration, ...voiced } satisfies Pick<Kept, 'duration' | 'voice'>);\n done({ id, url: url ?? `${base}__deictic/plugins/recordings/replay/${id}`, duration, ...voiced });\n } catch (e) {\n fail(e);\n }\n };\n // Record's key again: it's Stop while one is going.\n const stop = toolButton(STOP, 'Stop', 'R', () => void end(true));\n const discard = toolButton(DISCARD, 'Discard', 'Shift+R', () => void end(false));\n going.replaceChildren(live, ...(mic ? [mic, wave] : []), stop, discard);\n // The panel stays while it goes: its controls are what ends it.\n const unkeep = tools.keep();\n start.hidden = true;\n going.hidden = false;\n group.classList.add('going');\n const idle = () => {\n unkeep();\n going.replaceChildren();\n going.hidden = true;\n start.hidden = false;\n group.classList.remove('going');\n };\n\n const tick = () => {\n moved();\n time.textContent = clock(Date.now() - startedAt);\n };\n tick();\n const ticking = setInterval(tick, 250);\n });\n };\n\n const run = (from?: Carried) => {\n start.disabled = true;\n start.classList.remove('problem');\n start.title = 'Record';\n const mine = record(from).finally(() => {\n if (running === mine) running = undefined;\n start.disabled = false;\n });\n running = mine;\n // One that's stopped and kept is the next task's, whoever started it.\n mine.then(\n (recording) => recording !== undefined && tray.add('recordings', recording.id, recording),\n () => {},\n );\n return mine;\n };\n // One the page before this left going: carried on at once, whoever asks for it later (`going`), or no one.\n const left = carried();\n if (left !== undefined) {\n run(left).catch((e: unknown) => {\n // Not for the page after this to try again.\n carry(undefined);\n console.warn('deictic: the recording did not carry on, or was not kept', e);\n });\n }\n // A page shown again as it was left (Back, out of the browser's cache) knows nothing of what happened since:\n // loaded afresh, it carries on like any other.\n window.addEventListener('pageshow', (e) => {\n if (e.persisted && (running !== undefined || carried() !== undefined)) location.reload();\n });\n\n return {\n recording: () => running !== undefined,\n going: () => running,\n record: async () => {\n if (running !== undefined) throw new Error('recordings: one is going already: stop it first');\n return run();\n },\n };\n },\n});\n"],"mappings":";;;;;;;AAyBA,MAAM,cAAc;AACpB,MAAM,WAAW;AACjB,MAAM,4BAAY,IAAI,IAAI;CAAC;CAAG;CAAG;AAAE,CAAC;;AAGpC,SAAgB,SAA0B,QAAsB,QAAmD;CACjH,MAAM,uBAAO,IAAI,IAAY;CAC7B,QAAQ,UAAU;EAChB,IAAI,KAAK,SAAS,GAAG;GACnB,MAAM,KAAK,OAAO;GAClB,IAAI,KAAK,GAAG,KAAK,IAAI,EAAE;EACzB;EACA,IAAI,MAAM,SAAS,eAAe,OAAO,MAAM,SAAS,YAAY,MAAM,SAAS,MAAM,OAAO;EAChG,MAAM,OAAO,MAAM;EAEnB,IAAI,KAAK,WAAW,UAAU;GAC5B,MAAM,IAAI;GAEV,KAAK,IAAI,OAAO,MAAM,OAAO;IAC3B,OAAO;IACP,KAAK,MAAM,OAAO,EAAE,MAClB,IAAI,KAAK,IAAI,IAAI,QAAQ,KAAK,CAAC,KAAK,IAAI,IAAI,KAAK,EAAE,GAAG;KACpD,KAAK,IAAI,IAAI,KAAK,EAAE;KACpB,OAAO;IACT;GAEJ;GACA,MAAM,OAAiB;IACrB,GAAG;IACH,MAAM,EAAE,KAAK,QAAQ,MAAM,CAAC,KAAK,IAAI,EAAE,KAAK,EAAE,CAAC;IAC/C,SAAS,EAAE,QAAQ,QAAQ,MAAM,CAAC,KAAK,IAAI,EAAE,EAAE,KAAK,CAAC,KAAK,IAAI,EAAE,QAAQ,CAAC;IACzE,OAAO,EAAE,MAAM,QAAQ,MAAM,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC;IAC5C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AAS,MAAM,KAAK;IAC1B,MAAM,SAAS;IACf,MAAM,SAAS;IACf,MAAM,UAAU,IAAI,OAAO;IAC3B,MAAM,aAAa;KACjB,OAAO;KACP,MAAM,gBAAgB;KACtB,MAAM,SAAS;KACf,MAAM,SAAS;KACf,MAAM,UAAU,OAAO,OAAO;IAChC;IAEA,MAAM,aAAa;KACjB,MAAM;KACN,KAAK,cAAc,MAAM,KAAK,IAAI,IAAI,SAAS;IACjD;IACA,KAAK;IACL,MAAM,UAAU,YAAY,MAAM,GAAG;GACvC,CAAC;EACH;EAEA,MAAM,OAAO,SAAmB;GAC9B,MAAM,WAAW;GACjB,MAAM,UAAU,OAAO,SAAS;GAChC,MAAM,QAAQ;GACd,MAAM,OAAO,OAAO,IAAI,CAAC,CAAC,cAAc;IACtC,IAAI,YAAY,MAAM,UAAU,KAAA;IAChC,MAAM,WAAW;GACnB,CAAC;GACD,UAAU;GAEV,KAAK,MACF,cAAc,cAAc,KAAA,KAAa,KAAK,IAAI,cAAc,UAAU,IAAI,SAAS,SAClF,CAAC,CACT;GACA,OAAO;EACT;EAEA,MAAM,OAAO,QAAQ;EACrB,IAAI,SAAS,KAAA,GACX,IAAI,IAAI,CAAC,CAAC,OAAO,MAAe;GAE9B,MAAM,KAAA,CAAS;GACf,QAAQ,KAAK,4DAA4D,CAAC;EAC5E,CAAC;EAIH,OAAO,iBAAiB,aAAa,MAAM;GACzC,IAAI,EAAE,cAAc,YAAY,KAAA,KAAa,QAAQ,MAAM,KAAA,IAAY,SAAS,OAAO;EACzF,CAAC;EAED,OAAO;GACL,iBAAiB,YAAY,KAAA;GAC7B,aAAa;GACb,QAAQ,YAAY;IAClB,IAAI,YAAY,KAAA,GAAW,MAAM,IAAI,MAAM,iDAAiD;IAC5F,OAAO,IAAI;GACb;EACF;CACF;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"client.js","names":[],"sources":["../../src/plugins/recordings/ours.ts","../../src/plugins/recordings/client.ts"],"sourcesContent":["/**\n * Keeps deictic's own UI out of a recording. Blocking the overlay keeps it out of the first snapshot,\n * but rrweb watches a blocked host's shadow root all the same, so what's added there later (the toolbar,\n * a note's field) comes as mutations. This drops them, and clicks and input on those nodes, by the IDs\n * rrweb gave them: the host's, and every node added under one of ours.\n *\n * The pointer's moves over them stay, on the page's root instead: the replay moves its cursor only over a\n * node it has, and while a drawing tool is picked the pointer is over ours the whole time.\n */\n\n/** The parts of rrweb's events this reads; the rest passes as it is. */\ninterface Event {\n type: number;\n data?: unknown;\n}\n\ninterface Mutation {\n source: 0;\n adds: { parentId: number; node: { id: number } }[];\n removes: { parentId: number; id: number }[];\n texts: { id: number }[];\n attributes: { id: number }[];\n}\n\n/** rrweb's numbers: an incremental snapshot, and the sources whose data is a list of pointer positions. */\nconst INCREMENTAL = 3;\nconst MUTATION = 0;\nconst POSITIONS = new Set([1, 6, 12]);\n\n/** A filter for `emit`: the event without our nodes, or nothing when nothing else is left in it. */\nexport function dropOurs<E extends Event>(hostId: () => number, pageId: () => number): (event: E) => E | undefined {\n const ours = new Set<number>();\n return (event) => {\n if (ours.size === 0) {\n const id = hostId();\n if (id > 0) ours.add(id);\n }\n if (event.type !== INCREMENTAL || typeof event.data !== 'object' || event.data === null) return event;\n const data = event.data as { source: number; id?: number; positions?: { id: number }[] };\n\n if (data.source === MUTATION) {\n const m = data as Mutation;\n // Added parents and children come in any order: claim until nothing more is ours.\n for (let grew = true; grew;) {\n grew = false;\n for (const add of m.adds) {\n if (ours.has(add.parentId) && !ours.has(add.node.id)) {\n ours.add(add.node.id);\n grew = true;\n }\n }\n }\n const kept: Mutation = {\n ...m,\n adds: m.adds.filter((a) => !ours.has(a.node.id)),\n removes: m.removes.filter((r) => !ours.has(r.id) && !ours.has(r.parentId)),\n texts: m.texts.filter((t) => !ours.has(t.id)),\n attributes: m.attributes.filter((a) => !ours.has(a.id)),\n };\n const left = kept.adds.length + kept.removes.length + kept.texts.length + kept.attributes.length;\n return left === 0 ? undefined : { ...event, data: kept };\n }\n if (POSITIONS.has(data.source) && Array.isArray(data.positions)) {\n const page = pageId();\n const positions = data.positions.map((p) => (ours.has(p.id) ? { ...p, id: page } : p));\n return { ...event, data: { ...data, positions } };\n }\n return data.id !== undefined && ours.has(data.id) ? undefined : event;\n };\n}\n","/**\n * The recordings plugin's page half. Its tool in the tool panel is Record: `record()` starts rrweb (imported\n * then), and while one is going the panel stays, with the time, the mic where the voice plugin is loaded, and\n * Stop and Discard in Record's place. A recording that's stopped goes in the tray, for the next task.\n *\n * The events go to the server as they happen (`begin`, a `part` each second, `end` on Stop), and what the next\n * page needs to carry on is kept in the tab's session storage: a reload, or a link to another page of the site,\n * leaves the recording going. The page that loads starts rrweb again under the same ID, which makes it a\n * recording of several pages as rrweb has them (a `Meta` and a snapshot for each), puts its controls back with\n * the time running, and turns the mic back on where it was.\n *\n * Nothing of deictic's is recorded: the overlay is blocked, as rrweb blocks. The marks are, as custom\n * events: the page's annotations, as SVGs in page coordinates, at the start and at each change. So are React's\n * commits, where the react plugin is loaded, while its button is on (P): off by default, and as it was last left.\n */\nimport { toolButton } from '#src/client/dom.ts';\nimport { playMark, trayed } from '#src/client/drawer.ts';\nimport { liveWaveform } from '#src/client/waveform.ts';\nimport { defineClientPlugin } from '#src/index.ts';\nimport type { ResolvedMasking } from '#src/plugins/screenshots/index.ts';\n\nimport type { Take } from '#src/plugins/voice/index.ts';\n\nimport type { Kept, Meta, Recorder, Recording, RecordPlugin, VoiceClip } from './index.ts';\nimport { END, MARKS, PAGE, REACT } from './marks.ts';\nimport { dropOurs } from './ours.ts';\n\n/** Where the recording going on is kept, for the tab's next page to carry on with. */\nconst GOING = 'deictic:recording';\n/** How often the events are sent, in milliseconds. */\nconst EVERY = 1000;\n\n/** A recording going on, as the next page needs it. */\ninterface Carried {\n id: string;\n startedAt: number;\n /** The next part's place among the parts. */\n seq: number;\n /** The mic's clips so far, and whether it was on. */\n clips: VoiceClip[];\n mic: boolean;\n /** Whether React's commits were going in. */\n react?: boolean;\n}\n\n/** Whether the last recording had React's commits going in when it ended, for the next to start as it was left. */\nconst REACT_ON = 'deictic:recording:react';\n\nconst reactWanted = () => {\n try {\n return localStorage.getItem(REACT_ON) === 'true';\n } catch {\n return false;\n }\n};\n\nconst wantReact = (on: boolean) => {\n try {\n localStorage.setItem(REACT_ON, String(on));\n } catch {\n // Not remembered, then: the next recording starts without.\n }\n};\n\nfunction carried(): Carried | undefined {\n try {\n return (JSON.parse(sessionStorage.getItem(GOING) ?? 'null') as Carried | null) ?? undefined;\n } catch {\n // Storage can be off: nothing carries over, then.\n return undefined;\n }\n}\n\nfunction carry(going: Carried | undefined): void {\n try {\n if (going === undefined) sessionStorage.removeItem(GOING);\n else sessionStorage.setItem(GOING, JSON.stringify(going));\n } catch {\n // Not kept, then: a page load ends the recording.\n }\n}\n\nconst STYLE = `\n.recorder .going { display: flex; align-items: center; gap: 4px; }\n/* Away while nothing records: laid out empty, it would still count in the group's gap. */\n.recorder .going[hidden] { display: none; }\n/* While one goes, its controls are its section's alone: the other tools that capture (a shot, the mic, a task) wait. */\n.tool-panel:has(.recorder.going) .tool-group[data-section='capture']:not(.recorder) { display: none; }\n.tool-panel.vertical .recorder .going { flex-direction: column; }\n.recorder .live { display: inline-flex; align-items: center; gap: 6px; padding: 0 4px; font: 12px ui-monospace, monospace; }\n.tool-panel.vertical .recorder .live { flex-direction: column; gap: 2px; padding: 4px 0; }\n.recorder .dot { width: 8px; height: 8px; border-radius: 50%; background: #ef4444; animation: deictic-blink 1.2s infinite; }\n.recorder .mic[aria-pressed='true'], .recorder .mic[aria-pressed='true']:hover { background: #ef4444; color: #fff; }\n.recorder .react[aria-pressed='true'], .recorder .react[aria-pressed='true']:hover { background: #087ea4; color: #fff; }\n.recorder .wave { width: 44px; height: 18px; }\n.tool-panel.vertical .recorder .wave { width: 28px; }\n@keyframes deictic-blink { 50% { opacity: 0.3; } }\n`;\n\n/** Each icon's strokes, on a 24-pixel grid. */\nconst RECORD = '<circle cx=\"12\" cy=\"12\" r=\"8\"/><circle cx=\"12\" cy=\"12\" r=\"3\" fill=\"currentColor\"/>';\nconst STOP = '<rect x=\"6\" y=\"6\" width=\"12\" height=\"12\" rx=\"1\" fill=\"currentColor\"/>';\nconst DISCARD = '<path d=\"M6 6l12 12M18 6 6 18\"/>';\nconst MIC = '<rect x=\"9\" y=\"3\" width=\"6\" height=\"11\" rx=\"3\"/><path d=\"M5 11a7 7 0 0 0 14 0M12 18v3\"/>';\n/** An atom, as React's own mark is drawn. */\nconst ATOM =\n '<circle cx=\"12\" cy=\"12\" r=\"1.6\" fill=\"currentColor\"/><ellipse cx=\"12\" cy=\"12\" rx=\"10\" ry=\"4\"/><ellipse cx=\"12\" cy=\"12\" rx=\"10\" ry=\"4\" transform=\"rotate(60 12 12)\"/><ellipse cx=\"12\" cy=\"12\" rx=\"10\" ry=\"4\" transform=\"rotate(120 12 12)\"/>';\n\nconst clock = (ms: number) => {\n const s = Math.floor(ms / 1000);\n return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, '0')}`;\n};\n\nexport default defineClientPlugin<never, never, Recorder>({\n name: 'recordings',\n setup: ({ base, root, options, use, request, report, tools, tray, drawer, lightbox }) => {\n const { masking, canvas } = options as { masking: ResolvedMasking; canvas?: false | { fps: number } };\n let running: Promise<Recording | undefined> | undefined;\n\n // In the tool panel: Record, and in its place while one is going, what `record` puts there.\n const group = Object.assign(document.createElement('div'), { className: 'tool-group recorder' });\n const going = Object.assign(document.createElement('div'), { className: 'going', hidden: true });\n const start = toolButton(RECORD, 'Record', 'R', () => {\n run().catch((e: unknown) => {\n // Said where it was asked for: its tooltip, which a missing package's fix fits in.\n start.classList.add('problem');\n start.title = e instanceof Error ? e.message : String(e);\n });\n });\n group.append(Object.assign(document.createElement('style'), { textContent: STYLE }), start, going);\n // Beside the other tools that capture the page: a shot, a recording, the mic.\n tools.add(group, { section: 'capture' });\n // In the drawer until a task takes them: each plays back in the lightbox.\n drawer.add(\n trayed({ tray }, 'recordings', 'Recordings', (item, i, all) => {\n const { url, duration, voice } = item.value as Recording;\n const name = `${all.length === 1 ? 'Recording' : `Recording ${i + 1}`} ${clock(duration)}`;\n return {\n label: [playMark(), `${name}${voice === undefined ? '' : ' · voice'}`],\n // The replay filling the frame, without a header of its own: the lightbox names it.\n open: (from) => lightbox([{ kind: 'page', url: `${url}${url.includes('?') ? '&' : '?'}embed`, title: name }], { from }),\n };\n }),\n );\n\n const post = async (route: string, body: unknown, keepalive = false) => {\n const res = await request(route, {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify(body),\n ...(keepalive ? { keepalive } : {}),\n });\n // `url`: where it replays, said by what keeps it with no server to serve it from (a `standalone` build).\n const answer = (await res.json()) as { id?: string; url?: string; problem?: string };\n if (answer.id === undefined) throw new Error(`recordings: ${answer.problem ?? res.statusText}`);\n return { id: answer.id, url: answer.url };\n };\n\n /** Records until Stop or Discard: a new recording, or `from`, one a page before this started. */\n const record = async (from?: Carried): Promise<Recording | undefined> => {\n const startedAt = from?.startedAt ?? Date.now();\n const begin = async (): Promise<string> => {\n const viewport = { width: document.documentElement.clientWidth, height: document.documentElement.clientHeight };\n const colorScheme = matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';\n return (await post('begin', { page: location.href, viewport, colorScheme, startedAt } satisfies Meta)).id;\n };\n // What else goes in the recording, where its plugin is loaded: the console's lines and the page's requests, each\n // rrweb's own plugin, which listens from when rrweb starts until it stops. One that can't be had (its package\n // isn't installed) is said, and the recording goes on without.\n const extra = (name: 'logs' | 'network'): Promise<RecordPlugin | undefined> | undefined =>\n use(name)\n // A page that carries a recording on made requests before this: those of its load are the recording's too.\n ?.plugin({ sinceLoad: from !== undefined })\n .catch((e: unknown) => {\n const why = e instanceof Error ? e.message : String(e);\n report({\n key: `page:recordings:${name}:${why.split('\\n', 1)[0]!.slice(0, 200)}`,\n kind: 'setup',\n message: `recordings go without ${name}, as it couldn't be loaded: install what it needs (\\`deictic init\\` does), then load the page again: ${why}`,\n ...(e instanceof Error && e.stack !== undefined ? { details: e.stack } : {}),\n });\n return undefined;\n });\n const [rrweb, id, ...extras] = await Promise.all([\n import('rrweb').catch((e: unknown) => {\n throw new Error('recordings need rrweb: add it to your devDependencies', { cause: e });\n }),\n from?.id ?? begin(),\n extra('logs'),\n extra('network'),\n ]);\n const clips: VoiceClip[] = from?.clips ?? [];\n // What the server doesn't have yet, and the place of the next part sent.\n let unsent: { type: number; data?: unknown }[] = [];\n let seq = from?.seq ?? 0;\n const host = root.host;\n const keep = dropOurs<(typeof unsent)[number]>(\n () => rrweb.record.mirror.getId(host),\n () => rrweb.record.mirror.getId(document.documentElement),\n );\n // The page's address changing with no load (a router's `pushState`, Back within the app, a hash), which rrweb\n // doesn't record: a custom event, so the recording says where each stretch happened. Nothing tells of\n // `pushState`, so it's read as each event comes, and as the clock ticks for a route that draws nothing.\n let href = location.href;\n const moved = () => {\n if (location.href === href) return;\n href = location.href;\n rrweb.record.addCustomEvent(PAGE, { href });\n };\n const stopRecording = rrweb.record({\n emit: (event) => {\n // Before what the new route drew, which is what comes next.\n moved();\n const kept = keep(event);\n if (kept !== undefined) unsent.push(kept);\n },\n plugins: extras.filter((plugin) => plugin !== undefined),\n blockClass: masking.blockClass,\n // deictic's own UI, the overlay: a blocked element is kept as an empty box its size, and it has none.\n blockSelector: ['deictic-overlay', ...(masking.blockSelector ? [masking.blockSelector] : [])].join(', '),\n maskTextClass: masking.maskTextClass,\n ...(masking.maskTextSelector ? { maskTextSelector: masking.maskTextSelector } : {}),\n maskAllInputs: masking.maskAllInputs,\n maskInputOptions: { password: true },\n inlineStylesheet: true,\n // A canvas as pictures of it, a few a second and only when it changed: rrweb's other way keeps every call\n // drawn on it, for which it wraps each drawing method of every canvas.\n ...(canvas === false || canvas === undefined\n ? {}\n : { recordCanvas: true, sampling: { canvas: canvas.fps }, dataURLOptions: { type: 'image/webp', quality: 0.6 } }),\n });\n\n // The marks, now and at each change: an SVG whose view is the page from its top left, at 1:1.\n const marks = use('annotations');\n const mark = () => {\n const area = { x: -scrollX, y: -scrollY, width: 1, height: 1 };\n rrweb.record.addCustomEvent(MARKS, {\n svg: marks?.svg(area) ?? '',\n // The same marks as data, in page coordinates, for whatever reads the recording but doesn't draw it.\n annotations: marks?.list() ?? [],\n });\n };\n mark();\n\n // The mic, where the voice plugin is loaded: each stretch it's on is a clip, at its time in the recording.\n const voice = use('voice');\n let take: Take | undefined;\n // React's commits, where the react plugin counts them: what stops them going in while they do.\n const commits = use('react')?.commits;\n let unreact: (() => void) | undefined;\n /** What the next page carries on from, kept as it changes: a page that's going has no time to say it then. */\n let over = false;\n const save = () =>\n // Not once it's ended, as its last events go: the next page would carry on with one that's over.\n over || carry({ id, startedAt, seq, clips, mic: take !== undefined, react: unreact !== undefined });\n const unsubscribe = marks?.subscribe(mark);\n\n // One part at a time, each with its place. A part that didn't arrive goes again with the next, before it.\n let sending: Promise<void> = Promise.resolve();\n const flush = () => {\n const next = sending\n .catch(() => {})\n .then(async () => {\n if (unsent.length === 0) return;\n const part = unsent;\n unsent = [];\n const at = seq++;\n save();\n try {\n await post(`part/${id}?seq=${at}`, part);\n } catch (e) {\n unsent = [...part, ...unsent];\n throw e;\n }\n });\n sending = next;\n return next;\n };\n // A problem is heard at Stop, where it matters: a part that fails meanwhile goes again a second on.\n const flushing = setInterval(() => void flush().catch(() => {}), EVERY);\n save();\n\n return new Promise((done, fail) => {\n const live = Object.assign(document.createElement('span'), { className: 'live' });\n const dot = Object.assign(document.createElement('span'), { className: 'dot' });\n const time = document.createElement('span');\n live.append(dot, time);\n\n // The mic's live waveform beside it while it's on, so it's plain it hears.\n const wave = Object.assign(document.createElement('canvas'), { className: 'wave', hidden: true });\n let stopWave: (() => void) | undefined;\n const unwave = () => {\n stopWave?.();\n stopWave = undefined;\n wave.hidden = true;\n };\n // What the mic is doing (asking for it, keeping a take): the next toggle, and the end, wait for it.\n let busy: Promise<void> = Promise.resolve();\n const micOff = async () => {\n const ending = take;\n take = undefined;\n unwave();\n if (ending === undefined) return;\n try {\n const clip = await ending.stop();\n clips.push({ id: clip.id, at: ending.started - startedAt, duration: clip.duration });\n } catch (e) {\n // The recording is worth keeping without it.\n console.warn('deictic: the voice clip was not kept', e);\n }\n };\n const mic = voice === undefined ? undefined : toolButton(MIC, 'Turn the mic on', 'K', () => toggle());\n const toggle = () => {\n busy = busy.then(async () => {\n if (voice === undefined || mic === undefined) return;\n if (take !== undefined) {\n await micOff();\n } else {\n try {\n take = await voice.start();\n mic.classList.remove('problem');\n wave.hidden = false;\n stopWave = liveWaveform(wave, take.stream, { played: '#ef4444', rest: '#52525b' });\n } catch (e) {\n mic.classList.add('problem');\n mic.title = e instanceof Error ? e.message : String(e);\n return;\n }\n }\n const on = take !== undefined;\n mic.setAttribute('aria-pressed', String(on));\n mic.title = on ? 'Turn the mic off' : 'Turn the mic on';\n mic.setAttribute('aria-label', mic.title);\n save();\n });\n };\n mic?.classList.add('mic');\n mic?.setAttribute('aria-pressed', 'false');\n // On, as the page before left it: a browser that was let use the mic gives it again without asking.\n if (from?.mic === true) toggle();\n\n const react =\n commits === undefined\n ? undefined\n : toolButton(ATOM, \"Record React's commits: what rendered, how long it took, and why\", 'P', () =>\n reactOn(unreact === undefined),\n );\n react?.classList.add('react');\n const reactOn = (on: boolean) => {\n if (commits === undefined || react === undefined || on === (unreact !== undefined)) return;\n if (on) {\n rrweb.record.addCustomEvent(REACT, { on: true });\n unreact = commits((commit) => rrweb.record.addCustomEvent(REACT, commit));\n } else {\n // What's waiting goes first, then where it stops.\n unreact?.();\n unreact = undefined;\n rrweb.record.addCustomEvent(REACT, { on: false });\n }\n react.setAttribute('aria-pressed', String(on));\n react.title = on ? \"Stop recording React's commits\" : \"Record React's commits: what rendered, how long it took, and why\";\n react.setAttribute('aria-label', react.title);\n wantReact(on);\n save();\n };\n react?.setAttribute('aria-pressed', 'false');\n // As the page before left it, or a new one as the last was left.\n if (from?.react ?? reactWanted()) reactOn(true);\n\n // The page is going, for another or for good, with no time to wait for anything: what's sent of the mic's\n // take is its clip, the next page is told where things stand, and the last events go as the page does.\n const leave = () => {\n const spoken = take?.soFar();\n if (take !== undefined && spoken !== undefined)\n clips.push({ id: spoken.id, at: take.started - startedAt, duration: spoken.duration });\n const part = unsent;\n unsent = [];\n const at = seq++;\n save();\n // Not behind `sending`, which a page that's going never gets to: the server orders the parts by their place.\n // A browser sends 64 KB at most for a page that's gone, so a last second busier than that is lost.\n if (part.length > 0) void post(`part/${id}?seq=${at}`, part, true).catch(() => {});\n };\n addEventListener('pagehide', leave);\n\n const end = async (kept: boolean) => {\n // What's waiting of React's commits goes in before the end, and the next recording starts as this one ends.\n unreact?.();\n unreact = undefined;\n rrweb.record.addCustomEvent(END, {});\n stopRecording?.();\n unsubscribe?.();\n clearInterval(flushing);\n clearInterval(ticking);\n removeEventListener('pagehide', leave);\n idle();\n over = true;\n carry(undefined);\n await busy;\n if (!kept) {\n unwave();\n take?.cancel();\n void post(`discard/${id}`, {}).catch(() => {});\n return done(undefined);\n }\n await micOff();\n const duration = Date.now() - startedAt;\n const voiced = clips.length > 0 ? { voice: clips } : {};\n try {\n await flush();\n const { url } = await post(`end/${id}`, { duration, ...voiced } satisfies Pick<Kept, 'duration' | 'voice'>);\n done({ id, url: url ?? `${base}__deictic/plugins/recordings/replay/${id}`, duration, ...voiced });\n } catch (e) {\n fail(e);\n }\n };\n // Record's key again: it's Stop while one is going.\n const stop = toolButton(STOP, 'Stop', 'R', () => void end(true));\n const discard = toolButton(DISCARD, 'Discard', 'Shift+R', () => void end(false));\n going.replaceChildren(live, ...(mic ? [mic, wave] : []), ...(react ? [react] : []), stop, discard);\n // The panel stays while it goes: its controls are what ends it.\n const unkeep = tools.keep();\n start.hidden = true;\n going.hidden = false;\n group.classList.add('going');\n const idle = () => {\n unkeep();\n going.replaceChildren();\n going.hidden = true;\n start.hidden = false;\n group.classList.remove('going');\n };\n\n const tick = () => {\n moved();\n time.textContent = clock(Date.now() - startedAt);\n };\n tick();\n const ticking = setInterval(tick, 250);\n });\n };\n\n const run = (from?: Carried) => {\n start.disabled = true;\n start.classList.remove('problem');\n start.title = 'Record';\n const mine = record(from).finally(() => {\n if (running === mine) running = undefined;\n start.disabled = false;\n });\n running = mine;\n // One that's stopped and kept is the next task's, whoever started it.\n mine.then(\n (recording) => recording !== undefined && tray.add('recordings', recording.id, recording),\n () => {},\n );\n return mine;\n };\n // One the page before this left going: carried on at once, whoever asks for it later (`going`), or no one.\n const left = carried();\n if (left !== undefined) {\n run(left).catch((e: unknown) => {\n // Not for the page after this to try again.\n carry(undefined);\n console.warn('deictic: the recording did not carry on, or was not kept', e);\n });\n }\n // A page shown again as it was left (Back, out of the browser's cache) knows nothing of what happened since:\n // loaded afresh, it carries on like any other.\n window.addEventListener('pageshow', (e) => {\n if (e.persisted && (running !== undefined || carried() !== undefined)) location.reload();\n });\n\n return {\n recording: () => running !== undefined,\n going: () => running,\n record: async () => {\n if (running !== undefined) throw new Error('recordings: one is going already: stop it first');\n return run();\n },\n };\n },\n});\n"],"mappings":";;;;;;;AAyBA,MAAM,cAAc;AACpB,MAAM,WAAW;AACjB,MAAM,4BAAY,IAAI,IAAI;CAAC;CAAG;CAAG;AAAE,CAAC;;AAGpC,SAAgB,SAA0B,QAAsB,QAAmD;CACjH,MAAM,uBAAO,IAAI,IAAY;CAC7B,QAAQ,UAAU;EAChB,IAAI,KAAK,SAAS,GAAG;GACnB,MAAM,KAAK,OAAO;GAClB,IAAI,KAAK,GAAG,KAAK,IAAI,EAAE;EACzB;EACA,IAAI,MAAM,SAAS,eAAe,OAAO,MAAM,SAAS,YAAY,MAAM,SAAS,MAAM,OAAO;EAChG,MAAM,OAAO,MAAM;EAEnB,IAAI,KAAK,WAAW,UAAU;GAC5B,MAAM,IAAI;GAEV,KAAK,IAAI,OAAO,MAAM,OAAO;IAC3B,OAAO;IACP,KAAK,MAAM,OAAO,EAAE,MAClB,IAAI,KAAK,IAAI,IAAI,QAAQ,KAAK,CAAC,KAAK,IAAI,IAAI,KAAK,EAAE,GAA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A;GAC7B,aAAa;GACb,QAAQ,YAAY;IAClB,IAAI,YAAY,KAAA,GAAW,MAAM,IAAI,MAAM,iDAAiD;IAC5F,OAAO,IAAI;GACb;EACF;CACF;AACF,CAAC"}
|
|
@@ -15,6 +15,14 @@ export type PageCapture = (element: Element, options: {
|
|
|
15
15
|
type: string;
|
|
16
16
|
box: Box;
|
|
17
17
|
}>;
|
|
18
|
+
/**
|
|
19
|
+
* What a renderer that can take the page at once makes of it, synchronously: as `PageCapture` answers, or nothing
|
|
20
|
+
* where it isn't ready (what it imports hasn't loaded). `prepare` loads it, once the page has started.
|
|
21
|
+
*/
|
|
22
|
+
export interface PageFreeze {
|
|
23
|
+
freeze: (element: Element, options: Parameters<PageCapture>[1]) => Awaited<ReturnType<PageCapture>> | undefined;
|
|
24
|
+
prepare: () => void;
|
|
25
|
+
}
|
|
18
26
|
/** Leaves out deictic's own UI: the overlay with its hover outline and any open panel. */
|
|
19
27
|
export declare const notOurs: (node: Node) => boolean;
|
|
20
28
|
/** The element's box, in CSS pixels from the viewport's top left, or from its own for a shot of it alone. */
|
|
@@ -25,5 +33,5 @@ export declare function boxOf(element: Element, area: NonNullable<CaptureOptions
|
|
|
25
33
|
* or every field's.
|
|
26
34
|
*/
|
|
27
35
|
export declare function mask(copy: Node, m: ResolvedMasking): void;
|
|
28
|
-
export declare function screenshotsClient(capture: PageCapture): import("deictic").ClientPlugin<never, never, Capture>;
|
|
36
|
+
export declare function screenshotsClient(capture: PageCapture, freezer?: PageFreeze): import("deictic").ClientPlugin<never, never, Capture>;
|
|
29
37
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","names":[],"sources":["../../src/plugins/screenshots/client.ts"],"mappings":";;;;;;;YAqBY,eACV,SAAS,SACT;EACE,MAAM,YAAY;EAClB,SAAS;EACT;EACA,UAAU,MAAM;MAEf;EAAU,MAAM;EAAe;EAAc,KAAK;;;
|
|
1
|
+
{"version":3,"file":"client.d.ts","names":[],"sources":["../../src/plugins/screenshots/client.ts"],"mappings":";;;;;;;YAqBY,eACV,SAAS,SACT;EACE,MAAM,YAAY;EAClB,SAAS;EACT;EACA,UAAU,MAAM;MAEf;EAAU,MAAM;EAAe;EAAc,KAAK;;;;;;iBAMtC;EACf,SAAS,SAAS,SAAS,SAAS,WAAW,oBAAoB,QAAQ,WAAW;EACtF;;;qBAIW,UAAO,MAAU;;wBAGd,MAAM,SAAS,SAAS,MAAM,YAAY,0BAA0B;;;;;;wBAkBpE,KAAK,MAAM,MAAM,GAAG;wBAqBpB,kBAAkB,SAAS,aAAa,UAAU,+BAAU,2BAAA"}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import { r as Capture } from "../shared/index3.js";
|
|
2
|
-
/**
|
|
3
|
-
* The `rrweb()` renderer's page half: a snapshot of the page's DOM with `rrweb-snapshot` (imported on the
|
|
4
|
-
* first shot), masked as rrweb masks, without deictic's overlay, sent with what the server's browser needs
|
|
5
|
-
* to show it as the page does: the viewport and the window around it, where it's scrolled to, the pixel density, the page's URL.
|
|
6
|
-
* And which node of the snapshot the element is, so the server says where it is in what it drew.
|
|
7
|
-
*/
|
|
8
2
|
declare const _default: import("deictic").ClientPlugin<never, never, Capture>;
|
|
9
3
|
export { _default as default };
|
|
10
4
|
//# sourceMappingURL=rrweb.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rrweb.d.ts","names":["_$__index_ts0.Capture"],"sources":["../../src/plugins/screenshots/rrweb.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"rrweb.d.ts","names":["_$__index_ts0.Capture"],"sources":["../../src/plugins/screenshots/rrweb.ts"],"mappings":";cA2FA,4B,2BAAAA"}
|
|
@@ -1,12 +1,31 @@
|
|
|
1
1
|
import { n as keepWebGLDrawing, t as CANVAS_SIZE } from "../shared/canvas.js";
|
|
2
2
|
import { i as screenshotsClient, t as boxOf } from "../shared/client.js";
|
|
3
|
+
// src/plugins/screenshots/states.ts
|
|
4
|
+
/** Which nodes match each state now, by the snapshot's IDs (`id`), through open shadow roots, deictic's overlay left out. */
|
|
5
|
+
function statesOf(id, root = document) {
|
|
6
|
+
const pseudo = {
|
|
7
|
+
hover: ":hover",
|
|
8
|
+
focus: ":focus",
|
|
9
|
+
focusVisible: ":focus-visible",
|
|
10
|
+
focusWithin: ":focus-within"
|
|
11
|
+
};
|
|
12
|
+
const states = {};
|
|
13
|
+
for (const [name, selector] of Object.entries(pseudo)) {
|
|
14
|
+
const ids = [];
|
|
15
|
+
const within = (inside) => {
|
|
16
|
+
for (const el of inside.querySelectorAll(selector)) {
|
|
17
|
+
if (el.localName === "deictic-overlay") continue;
|
|
18
|
+
const known = id(el);
|
|
19
|
+
if (known !== -1) ids.push(known);
|
|
20
|
+
if (el.shadowRoot !== null) within(el.shadowRoot);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
within(root);
|
|
24
|
+
if (ids.length > 0) states[name] = ids;
|
|
25
|
+
}
|
|
26
|
+
return states;
|
|
27
|
+
}
|
|
3
28
|
// src/plugins/screenshots/rrweb.ts
|
|
4
|
-
/**
|
|
5
|
-
* The `rrweb()` renderer's page half: a snapshot of the page's DOM with `rrweb-snapshot` (imported on the
|
|
6
|
-
* first shot), masked as rrweb masks, without deictic's overlay, sent with what the server's browser needs
|
|
7
|
-
* to show it as the page does: the viewport and the window around it, where it's scrolled to, the pixel density, the page's URL.
|
|
8
|
-
* And which node of the snapshot the element is, so the server says where it is in what it drew.
|
|
9
|
-
*/
|
|
10
29
|
keepWebGLDrawing();
|
|
11
30
|
/** The snapshot without deictic's overlay, which rrweb has no option to leave out. */
|
|
12
31
|
function withoutOurs(node) {
|
|
@@ -17,12 +36,17 @@ function withoutOurs(node) {
|
|
|
17
36
|
childNodes
|
|
18
37
|
};
|
|
19
38
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
39
|
+
let loading;
|
|
40
|
+
let loaded;
|
|
41
|
+
const load = () => loading ??= import("rrweb-snapshot").then((module) => loaded = module, (e) => {
|
|
42
|
+
loading = void 0;
|
|
43
|
+
throw new Error("the rrweb() renderer needs rrweb-snapshot: add it to your devDependencies", { cause: e });
|
|
44
|
+
});
|
|
45
|
+
/** The page now, at once: what the server renders. */
|
|
46
|
+
function take(rrweb, element, { area, masking, overlay }) {
|
|
47
|
+
const { snapshot, createMirror } = rrweb;
|
|
24
48
|
const mirror = createMirror();
|
|
25
|
-
const taken =
|
|
49
|
+
const taken = snapshot(document, {
|
|
26
50
|
mirror,
|
|
27
51
|
inlineStylesheet: true,
|
|
28
52
|
recordCanvas: true,
|
|
@@ -31,7 +55,7 @@ var rrweb_default = screenshotsClient(async (element, { area, masking, overlay }
|
|
|
31
55
|
maskTextClass: masking.maskTextClass,
|
|
32
56
|
maskTextSelector: masking.maskTextSelector ?? null,
|
|
33
57
|
maskAllInputs: masking.maskAllInputs
|
|
34
|
-
})
|
|
58
|
+
});
|
|
35
59
|
if (taken === null) throw new Error("screenshots: rrweb took no snapshot of this page");
|
|
36
60
|
for (const canvas of document.querySelectorAll("canvas")) {
|
|
37
61
|
const node = mirror.getMeta(canvas);
|
|
@@ -49,6 +73,7 @@ var rrweb_default = screenshotsClient(async (element, { area, masking, overlay }
|
|
|
49
73
|
y: 0,
|
|
50
74
|
...viewport
|
|
51
75
|
});
|
|
76
|
+
const states = statesOf((el) => mirror.getId(el));
|
|
52
77
|
const body = {
|
|
53
78
|
snapshot: withoutOurs(taken),
|
|
54
79
|
...mirror.getId(element) === -1 ? {} : { element: mirror.getId(element) },
|
|
@@ -59,6 +84,7 @@ var rrweb_default = screenshotsClient(async (element, { area, masking, overlay }
|
|
|
59
84
|
height: innerHeight
|
|
60
85
|
},
|
|
61
86
|
...marks === void 0 ? {} : { overlay: marks },
|
|
87
|
+
...Object.keys(states).length === 0 ? {} : { states },
|
|
62
88
|
scroll: {
|
|
63
89
|
x: scrollX,
|
|
64
90
|
y: scrollY
|
|
@@ -71,6 +97,14 @@ var rrweb_default = screenshotsClient(async (element, { area, masking, overlay }
|
|
|
71
97
|
type: "application/json",
|
|
72
98
|
box
|
|
73
99
|
};
|
|
100
|
+
}
|
|
101
|
+
var rrweb_default = screenshotsClient(async (element, options) => {
|
|
102
|
+
const rrweb = await load();
|
|
103
|
+
await new Promise((done) => requestAnimationFrame(done));
|
|
104
|
+
return take(rrweb, element, options);
|
|
105
|
+
}, {
|
|
106
|
+
freeze: (element, options) => loaded === void 0 ? void 0 : take(loaded, element, options),
|
|
107
|
+
prepare: () => void load().catch(() => {})
|
|
74
108
|
});
|
|
75
109
|
export { rrweb_default as default };
|
|
76
110
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rrweb.js","names":[],"sources":["../../src/plugins/screenshots/rrweb.ts"],"sourcesContent":["/**\n * The `rrweb()` renderer's page half: a snapshot of the page's DOM with `rrweb-snapshot` (imported
|
|
1
|
+
{"version":3,"file":"rrweb.js","names":[],"sources":["../../src/plugins/screenshots/states.ts","../../src/plugins/screenshots/rrweb.ts"],"sourcesContent":["/**\n * What a copy of the DOM loses: which elements are hovered and focused. The `rrweb()` renderer reads it as it takes\n * the page, and its server half gives the rebuilt page those states again (`playwright.ts`). Self-contained, with\n * nothing from outside it, so a test can run this very function in a browser.\n */\nimport type { States } from './playwright.ts';\n\n/** Which nodes match each state now, by the snapshot's IDs (`id`), through open shadow roots, deictic's overlay left out. */\nexport function statesOf(id: (el: Element) => number, root: Document = document): States {\n const pseudo = { hover: ':hover', focus: ':focus', focusVisible: ':focus-visible', focusWithin: ':focus-within' } as const;\n const states: States = {};\n for (const [name, selector] of Object.entries(pseudo) as [keyof States, string][]) {\n const ids: number[] = [];\n const within = (inside: Document | ShadowRoot) => {\n for (const el of inside.querySelectorAll(selector)) {\n if (el.localName === 'deictic-overlay') continue;\n const known = id(el);\n if (known !== -1) ids.push(known);\n if (el.shadowRoot !== null) within(el.shadowRoot);\n }\n };\n within(root);\n if (ids.length > 0) states[name] = ids;\n }\n return states;\n}\n","/**\n * The `rrweb()` renderer's page half: a snapshot of the page's DOM with `rrweb-snapshot` (imported as the page\n * starts), masked as rrweb masks, without deictic's overlay, sent with what the server's browser needs\n * to show it as the page does: the viewport and the window around it, where it's scrolled to, the pixel density, the page's URL.\n * And which node of the snapshot the element is, so the server says where it is in what it drew, and which match\n * `:hover` and `:focus` and the like, which a copy of the DOM has no state for and the server gives them again.\n *\n * It takes the page at once, so a press can freeze it (`PageFreeze`): rrweb-snapshot is imported once the page has\n * started, while the browser is idle, and a press before it has loaded is taken as the task goes, as without.\n */\nimport type * as RrwebSnapshot from 'rrweb-snapshot';\n\nimport { CANVAS_SIZE, keepWebGLDrawing } from './canvas.ts';\nimport { boxOf, type PageCapture, type PageFreeze, screenshotsClient } from './client.ts';\nimport type { Snapshot, SnapshotNode } from './playwright.ts';\nimport { statesOf } from './states.ts';\n\ntype Rrweb = typeof RrwebSnapshot;\n\n// As the page loads, before the page makes its canvases.\nkeepWebGLDrawing();\n\n/** The snapshot without deictic's overlay, which rrweb has no option to leave out. */\nfunction withoutOurs(node: SnapshotNode): SnapshotNode {\n if (!('childNodes' in node)) return node;\n const childNodes = node.childNodes.filter((c: SnapshotNode) => !('tagName' in c && c.tagName === 'deictic-overlay')).map(withoutOurs);\n return { ...node, childNodes };\n}\n\nlet loading: Promise<Rrweb> | undefined;\nlet loaded: Rrweb | undefined;\nconst load = () =>\n (loading ??= import('rrweb-snapshot').then(\n (module) => (loaded = module),\n (e: unknown) => {\n loading = undefined;\n throw new Error('the rrweb() renderer needs rrweb-snapshot: add it to your devDependencies', { cause: e });\n },\n ));\n\n/** The page now, at once: what the server renders. */\nfunction take(rrweb: Rrweb, element: Element, { area, masking, overlay }: Parameters<PageCapture>[1]) {\n const { snapshot, createMirror } = rrweb;\n const mirror = createMirror();\n const taken = snapshot(document, {\n mirror,\n inlineStylesheet: true,\n // A canvas as a picture of what it shows, which the server draws on the canvas it rebuilds.\n recordCanvas: true,\n blockClass: masking.blockClass,\n blockSelector: masking.blockSelector ?? null,\n maskTextClass: masking.maskTextClass,\n maskTextSelector: masking.maskTextSelector ?? null,\n maskAllInputs: masking.maskAllInputs,\n });\n if (taken === null) throw new Error('screenshots: rrweb took no snapshot of this page');\n // Each canvas's size as the page lays it out, and whether in a line, as which the server shows the canvas's picture.\n for (const canvas of document.querySelectorAll('canvas')) {\n const node = mirror.getMeta(canvas);\n if (node === null || !('attributes' in node) || typeof node.attributes.rr_dataURL !== 'string') continue;\n const inline = getComputedStyle(canvas).display === 'inline';\n node.attributes[CANVAS_SIZE] = `${canvas.offsetWidth}x${canvas.offsetHeight}${inline ? ' inline' : ''}`;\n }\n const box = boxOf(element, area);\n const viewport = { width: document.documentElement.clientWidth, height: document.documentElement.clientHeight };\n // Over the viewport, which the server renders before cutting out an element's part.\n const marks = overlay({ x: 0, y: 0, ...viewport });\n const states = statesOf((el) => mirror.getId(el));\n const body: Snapshot = {\n snapshot: withoutOurs(taken),\n ...(mirror.getId(element) === -1 ? {} : { element: mirror.getId(element) }),\n url: location.href,\n viewport,\n window: { width: innerWidth, height: innerHeight },\n ...(marks === undefined ? {} : { overlay: marks }),\n ...(Object.keys(states).length === 0 ? {} : { states }),\n scroll: { x: scrollX, y: scrollY },\n scale: Math.min(devicePixelRatio, 2),\n // A shot of the element alone is the part of the viewport it fills.\n ...(area === 'element' ? { clip: element.getBoundingClientRect().toJSON() as Snapshot['clip'] } : {}),\n };\n return { body: JSON.stringify(body), type: 'application/json', box };\n}\n\nconst freezer: PageFreeze = {\n // Not in a frame: a press is now, before the page's own handlers change it. A WebGL canvas shows what it drew,\n // as `keepWebGLDrawing` has it keep its buffer.\n freeze: (element, options) => (loaded === undefined ? undefined : take(loaded, element, options)),\n prepare: () => void load().catch(() => {}),\n};\n\nexport default screenshotsClient(async (element, options) => {\n const rrweb = await load();\n // In a frame, after the page drew in it: a WebGL canvas reads back blank once its frame is shown, unless the page\n // keeps its drawing buffer, and the page's own callbacks for the frame were asked for before this one.\n await new Promise((done) => requestAnimationFrame(done));\n return take(rrweb, element, options);\n}, freezer);\n"],"mappings":";;;;AAQA,SAAgB,SAAS,IAA6B,OAAiB,UAAkB;CACvF,MAAM,SAAS;EAAE,OAAO;EAAU,OAAO;EAAU,cAAc;EAAkB,aAAa;CAAgB;CAChH,MAAM,SAAiB,CAAC;CACxB,KAAK,MAAM,CAAC,MAAM,aAAa,OAAO,QAAQ,MAAM,GAA+B;EACjF,MAAM,MAAgB,CAAC;EACvB,MAAM,UAAU,WAAkC;GAChD,KAAK,MAAM,MAAM,OAAO,iBAAiB,QAAQ,GAAG;IAClD,IAAI,GAAG,cAAc,mBAAmB;IACxC,MAAM,QAAQ,GAAG,EAAE;IACnB,IAAI,UAAU,IAAI,IAAI,KAAK,KAAK;IAChC,IAAI,GAAG,eAAe,MAAM,OAAO,GAAG,UAAU;GAClD;EACF;EACA,OAAO,IAAI;EACX,IAAI,IAAI,SAAS,GAAG,OAAO,QAAQ;CACrC;CACA,OAAO;AACT;;ACLA,iBAAiB;;AAGjB,SAAS,YAAY,MAAkC;CACrD,IAAI,EAAE,gBAAgB,OAAO,OAAO;CACpC,MAAM,aAAa,KAAK,WAAW,QAAQ,MAAoB,EAAE,aAAa,KAAK,EAAE,YAAY,kBAAkB,CAAC,CAAC,IAAI,WAAW;CACpI,OAAO;EAAE,GAAG;EAAM;CAAW;AAC/B;AAEA,IAAI;AACJ,IAAI;AACJ,MAAM,aACH,YAAY,OAAO,iBAAiB,CAAC,MACnC,WAAY,SAAS,SACrB,MAAe;CACd,UAAU,KAAA;CACV,MAAM,IAAI,MAAM,6EAA6E,EAAE,OAAO,EAAE,CAAC;AAC3G,CACF;;AAGF,SAAS,KAAK,OAAc,SAAkB,EAAE,MAAM,SAAS,WAAuC;CACpG,MAAM,EAAE,UAAU,iBAAiB;CACnC,MAAM,SAAS,aAAa;CAC5B,MAAM,QAAQ,SAAS,UAAU;EAC/B;EACA,kBAAkB;EAElB,cAAc;EACd,YAAY,QA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EAAE,MAAM,KAAK,UAAU,IAAI;EAAG,MAAM;EAAoB;CAAI;AACrE;AASA,IAAA,gBAAe,kBAAkB,OAAO,SAAS,YAAY;CAC3D,MAAM,QAAQ,MAAM,KAAK;CAGzB,MAAM,IAAI,SAAS,SAAS,sBAAsB,IAAI,CAAC;CACvD,OAAO,KAAK,OAAO,SAAS,OAAO;AACrC,GAAG;CAVD,SAAS,SAAS,YAAa,WAAW,KAAA,IAAY,KAAA,IAAY,KAAK,QAAQ,SAAS,OAAO;CAC/F,eAAe,KAAK,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC;AASxC,CAAO"}
|
package/dist/shared/board.js
CHANGED
|
@@ -2,7 +2,7 @@ import { spawnSync } from "node:child_process";
|
|
|
2
2
|
import { existsSync, readdirSync } from "node:fs";
|
|
3
3
|
import { dirname, join, resolve } from "node:path";
|
|
4
4
|
import { a as vbScript, i as runningAt } from "./local.js";
|
|
5
|
-
import {
|
|
5
|
+
import { a as packageManager, t as execOf } from "./packages.js";
|
|
6
6
|
// src/cli/board.ts
|
|
7
7
|
/**
|
|
8
8
|
* What the agent's commands share: the board's CLI (`vb`, the project's `@vercel/board`) on the board the dev server
|
package/dist/shared/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { f as toolButton, i as POPUP_OPENED, r as POPUP_CLOSED } from "./dom.js";
|
|
2
2
|
import { r as trayed } from "./drawer.js";
|
|
3
3
|
import { n as defineClientPlugin } from "./src.js";
|
|
4
4
|
// src/plugins/screenshots/client.ts
|
|
@@ -28,6 +28,8 @@ function boxOf(element, area) {
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
const BLANK = "#d4d4d8";
|
|
31
|
+
/** How long after its press a popup may first ask for the shot it froze, in milliseconds: later, it's another's. */
|
|
32
|
+
const ASKED = 6e4;
|
|
31
33
|
/** A camera, on a 24-pixel grid. */
|
|
32
34
|
const CAMERA = "<path d=\"M4 8h3l2-3h6l2 3h3v11H4z\"/><circle cx=\"12\" cy=\"13\" r=\"3.5\"/>";
|
|
33
35
|
const selector = (className, extra) => [`.${CSS.escape(className)}`, ...extra ? [extra] : []].join(", ");
|
|
@@ -56,11 +58,16 @@ function mask(copy, m) {
|
|
|
56
58
|
if (field instanceof HTMLTextAreaElement) field.textContent = field.value;
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
|
-
function screenshotsClient(capture) {
|
|
61
|
+
function screenshotsClient(capture, freezer) {
|
|
60
62
|
return defineClientPlugin({
|
|
61
63
|
name: "screenshots",
|
|
64
|
+
...freezer === void 0 ? {} : { pressed: ({ use }, element) => use("screenshots")?.freeze(element) },
|
|
62
65
|
setup: ({ base, request, options, use, tools, tray, drawer, lightbox }) => {
|
|
63
66
|
const { masking, renderer } = options;
|
|
67
|
+
if (freezer !== void 0) {
|
|
68
|
+
if (typeof requestIdleCallback === "function") requestIdleCallback(freezer.prepare, { timeout: 5e3 });
|
|
69
|
+
else setTimeout(freezer.prepare, 1e3);
|
|
70
|
+
}
|
|
64
71
|
const overlay = (area) => {
|
|
65
72
|
return use("annotations")?.svg(area);
|
|
66
73
|
};
|
|
@@ -79,7 +86,42 @@ function screenshotsClient(capture) {
|
|
|
79
86
|
size
|
|
80
87
|
};
|
|
81
88
|
};
|
|
89
|
+
let last;
|
|
90
|
+
window.addEventListener(POPUP_CLOSED, () => last = void 0);
|
|
91
|
+
window.addEventListener(POPUP_OPENED, (e) => {
|
|
92
|
+
if (last !== void 0 && e.detail.element !== last.element) last = void 0;
|
|
93
|
+
});
|
|
82
94
|
const api = {
|
|
95
|
+
freeze: (element) => {
|
|
96
|
+
const { clientWidth: width, clientHeight: height } = document.documentElement;
|
|
97
|
+
const made = freezer?.freeze(element, {
|
|
98
|
+
area: "viewport",
|
|
99
|
+
masking,
|
|
100
|
+
renderer,
|
|
101
|
+
overlay
|
|
102
|
+
});
|
|
103
|
+
last = made === void 0 ? void 0 : {
|
|
104
|
+
element,
|
|
105
|
+
at: performance.now(),
|
|
106
|
+
made,
|
|
107
|
+
size: {
|
|
108
|
+
width,
|
|
109
|
+
height
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
},
|
|
113
|
+
frozen: (element) => {
|
|
114
|
+
if (last?.element !== element || last.shot === void 0 && performance.now() - last.at > ASKED) return void 0;
|
|
115
|
+
const { made, size } = last;
|
|
116
|
+
if (last.shot === void 0) {
|
|
117
|
+
last.shot = add(made.body, made.type, {
|
|
118
|
+
box: made.box,
|
|
119
|
+
size
|
|
120
|
+
});
|
|
121
|
+
last.shot.catch(() => {});
|
|
122
|
+
}
|
|
123
|
+
return last.shot;
|
|
124
|
+
},
|
|
83
125
|
capture: async (element, { area = "viewport" } = {}) => {
|
|
84
126
|
const { body, type, box } = await capture(element, {
|
|
85
127
|
area,
|