deictic 0.2.0 → 0.3.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 +303 -0
- package/README.md +56 -127
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +117 -7
- package/dist/client/index.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/logs/client.d.ts +4 -0
- package/dist/logs/client.d.ts.map +1 -0
- package/dist/logs/client.js +16 -0
- package/dist/logs/client.js.map +1 -0
- package/dist/logs/index.d.ts +18 -0
- package/dist/logs/index.d.ts.map +1 -0
- package/dist/logs/index.js +21 -0
- package/dist/logs/index.js.map +1 -0
- package/dist/network/client.d.ts +4 -0
- package/dist/network/client.d.ts.map +1 -0
- package/dist/network/client.js +29 -0
- package/dist/network/client.js.map +1 -0
- package/dist/network/index.d.ts +2 -0
- package/dist/network/index.js +39 -0
- package/dist/network/index.js.map +1 -0
- package/dist/recommended/index.d.ts +13 -3
- package/dist/recommended/index.d.ts.map +1 -1
- package/dist/recommended/index.js +8 -1
- package/dist/recommended/index.js.map +1 -1
- package/dist/recordings/client.d.ts +1 -1
- package/dist/recordings/client.d.ts.map +1 -1
- package/dist/recordings/client.js +175 -46
- package/dist/recordings/client.js.map +1 -1
- package/dist/recordings/index.d.ts +2 -2
- package/dist/screenshots/client.d.ts +6 -0
- package/dist/screenshots/client.d.ts.map +1 -1
- package/dist/screenshots/client.js +34 -2
- package/dist/screenshots/client.js.map +1 -1
- package/dist/screenshots/dom.d.ts.map +1 -1
- package/dist/screenshots/dom.js +1 -28
- package/dist/screenshots/dom.js.map +1 -1
- package/dist/screenshots/index.js.map +1 -1
- package/dist/screenshots/rrweb.d.ts +1 -1
- package/dist/screenshots/rrweb.js +5 -1
- package/dist/screenshots/rrweb.js.map +1 -1
- package/dist/shared/index.d.ts +14 -2
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index2.d.ts +2 -0
- package/dist/shared/index2.d.ts.map +1 -1
- package/dist/shared/index3.d.ts +29 -3
- package/dist/shared/index3.d.ts.map +1 -1
- package/dist/shared/index4.d.ts +52 -172
- package/dist/shared/index4.d.ts.map +1 -1
- package/dist/shared/index5.d.ts +208 -58
- package/dist/shared/index5.d.ts.map +1 -1
- package/dist/shared/index6.d.ts +70 -0
- package/dist/shared/index6.d.ts.map +1 -0
- package/dist/shared/marks.js +6 -1
- package/dist/shared/marks.js.map +1 -1
- package/dist/shared/mask.js +107 -0
- package/dist/shared/mask.js.map +1 -0
- package/dist/shared/playwright.js +19 -4
- package/dist/shared/playwright.js.map +1 -1
- package/dist/shared/recordings.js +219 -28
- package/dist/shared/recordings.js.map +1 -1
- package/dist/shared/tasks.js +145 -34
- 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.d.ts.map +1 -1
- package/dist/tasks/client.js +271 -56
- package/dist/tasks/client.js.map +1 -1
- package/dist/tasks/index.d.ts +2 -2
- package/dist/voice/client.d.ts.map +1 -1
- package/dist/voice/client.js +35 -14
- package/dist/voice/client.js.map +1 -1
- package/dist/voice/index.d.ts +6 -1
- package/dist/voice/index.d.ts.map +1 -1
- package/dist/voice/index.js +12 -2
- package/dist/voice/index.js.map +1 -1
- package/package.json +41 -2
- package/skills/deictic/SKILL.md +20 -14
- package/skills/deictic/references/install.md +18 -11
- package/skills/deictic/references/recordings.md +29 -0
- package/skills/deictic/references/tasks.md +49 -21
- package/skills/deictic/references/watch.md +38 -11
- package/skills/deictic/scripts/lib.mjs +69 -3
- package/skills/deictic/scripts/recording.mjs +84 -4
- package/skills/deictic/scripts/task.mjs +36 -7
- package/skills/deictic/scripts/vb.mjs +12 -0
- package/skills/deictic/scripts/watch.mjs +74 -10
- package/src/client/away.ts +105 -0
- package/src/client/index.ts +40 -9
- package/src/client/style.ts +1 -0
- package/src/index.ts +14 -2
- package/src/plugins/logs/client.ts +18 -0
- package/src/plugins/logs/index.ts +55 -0
- package/src/plugins/network/client.ts +30 -0
- package/src/plugins/network/index.ts +69 -0
- package/src/plugins/network/mask.ts +133 -0
- package/src/plugins/recommended/index.ts +14 -1
- package/src/plugins/recordings/client.ts +219 -40
- package/src/plugins/recordings/index.ts +108 -23
- package/src/plugins/recordings/marks.ts +6 -0
- package/src/plugins/recordings/replay.ts +127 -4
- package/src/plugins/screenshots/client.ts +35 -0
- package/src/plugins/screenshots/dom.ts +1 -32
- package/src/plugins/screenshots/index.ts +2 -0
- package/src/plugins/screenshots/playwright.ts +15 -4
- package/src/plugins/screenshots/rrweb.ts +2 -1
- package/src/plugins/tasks/client.ts +273 -41
- package/src/plugins/tasks/index.ts +155 -39
- package/src/plugins/tasks/watchers.ts +36 -0
- package/src/plugins/voice/client.ts +33 -11
- package/src/plugins/voice/index.ts +21 -4
package/dist/shared/index5.d.ts
CHANGED
|
@@ -1,70 +1,220 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { Board } from "@vercel/board";
|
|
2
|
+
import { w as Shortcut, y as Target } from "./index.js";
|
|
3
|
+
import { t as Box } from "./index2.js";
|
|
4
|
+
interface LocalOptions {
|
|
5
|
+
/**
|
|
6
|
+
* 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
|
|
7
|
+
* the only one tried: taken, the board doesn't start.
|
|
8
|
+
*/
|
|
9
|
+
port?: number;
|
|
10
|
+
/** Where its log is kept, from the project's root: `.deictic/board` by default. */
|
|
11
|
+
dir?: string;
|
|
12
|
+
/** `false` for no pages of the board's own (its inspector): the panel then links its tasks nowhere. */
|
|
13
|
+
inspect?: boolean;
|
|
14
|
+
/** More arguments for `vb serve`, as it takes them: `['--tailscale', 'box.tailnet.ts.net']`. */
|
|
15
|
+
args?: string[];
|
|
13
16
|
}
|
|
14
|
-
/**
|
|
15
|
-
interface
|
|
16
|
-
|
|
17
|
-
label: string;
|
|
18
|
-
/** Whether the kind is a colour's, shown as swatches. */
|
|
19
|
-
colors: boolean;
|
|
20
|
-
items: ClassInfo[];
|
|
21
|
-
/** A custom value goes between these: `md:text-[` and `]`. None for a kind that takes no value (`flex`). */
|
|
22
|
-
custom?: {
|
|
23
|
-
before: string;
|
|
24
|
-
after: string;
|
|
25
|
-
value?: string;
|
|
26
|
-
};
|
|
17
|
+
/** What `local()` answers, for the tasks plugin's `board` option. */
|
|
18
|
+
interface LocalBoard {
|
|
19
|
+
local: LocalOptions;
|
|
27
20
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
21
|
+
/**
|
|
22
|
+
* The project's own board on this machine, as the tasks plugin's `board`: what it uses anyway with no
|
|
23
|
+
* `BOARD_URL`, here whatever the environment says, and with options.
|
|
24
|
+
*/
|
|
25
|
+
declare const local: (options?: LocalOptions) => LocalBoard;
|
|
26
|
+
/** What the plugin uses of a board: `board()` from `@vercel/board` is one. */
|
|
27
|
+
type TaskBoard = Pick<Board, 'tasks' | 'thread' | 'discovery' | 'upload' | 'edit' | 'actors'>;
|
|
28
|
+
interface TasksOptions {
|
|
29
|
+
/**
|
|
30
|
+
* The board, as `@vercel/board`'s `board()` answers it. By default the one `BOARD_URL` names, and with none,
|
|
31
|
+
* one of the project's own on this machine: `vb serve`, started with the dev server and stopped with it, at
|
|
32
|
+
* `http://127.0.0.1:4100/api/board` (or the port `.deictic/board.json` says, where that one's taken), its log
|
|
33
|
+
* in `.deictic/board`. For your team's board, through `vercel login`, pass `board()`. `local()`, from here, is
|
|
34
|
+
* that board of the project's own whatever `BOARD_URL` says, with its port, its folder and the rest as options.
|
|
35
|
+
*/
|
|
36
|
+
board?: TaskBoard | LocalBoard;
|
|
37
|
+
/** The channel tasks go to: `deictic` by default. */
|
|
38
|
+
channel?: string;
|
|
39
|
+
/**
|
|
40
|
+
* The project the tasks are about, as the `deictic.project` label, to tell them apart on a board several
|
|
41
|
+
* projects share: by default the `name` in the root's `package.json`, and no label where it has none.
|
|
42
|
+
*/
|
|
43
|
+
project?: string;
|
|
44
|
+
/** Labels every task gets besides deictic's own, for whoever works them to filter by (`vb tail --label`). None by default. */
|
|
45
|
+
labels?: Record<string, string>;
|
|
46
|
+
/**
|
|
47
|
+
* Where the panel links the channel to, for a person to see its tasks, and with `task`, where it links
|
|
48
|
+
* that task's ID to. By default the board's own pages when it's one `vb serve` runs on this machine
|
|
49
|
+
* (`http://127.0.0.1:4100/c/deictic`, and `?thread=<id>` on it), and none for another board, whose pages
|
|
50
|
+
* deictic can't know.
|
|
51
|
+
*/
|
|
52
|
+
link?: (channel: string, task?: string) => string | undefined;
|
|
33
53
|
/**
|
|
34
|
-
*
|
|
35
|
-
* the
|
|
54
|
+
* Whether a task has the element's HTML as it rendered attached, as `element.html`, masked as a screenshot is
|
|
55
|
+
* (the screenshots plugin's masking, where it's loaded): what was on the page, for whoever can't open it as the
|
|
56
|
+
* person did. True by default: the Task tab has a box for it, ticked, to untick for a task that should go
|
|
57
|
+
* without. `false` takes the box away, where a page shows what the board shouldn't hold.
|
|
36
58
|
*/
|
|
37
|
-
|
|
59
|
+
html?: boolean;
|
|
38
60
|
/** What opens its tab directly, beside deictic's own shortcut, which opens any: none by default. */
|
|
39
61
|
shortcut?: Shortcut;
|
|
40
62
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
63
|
+
interface Task {
|
|
64
|
+
id: string;
|
|
65
|
+
/** The first line of what was typed. */
|
|
66
|
+
title: string;
|
|
67
|
+
/** What was typed, whole: what an edit changes. */
|
|
68
|
+
text: string;
|
|
69
|
+
state: string;
|
|
70
|
+
/** Whether it can still be edited or deleted: no one has claimed it. */
|
|
71
|
+
open: boolean;
|
|
72
|
+
/** Its page on the board, when there's one to link to. */
|
|
73
|
+
link?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Where it was added, where that isn't the element's place: for one of `tasks`, where the element was before
|
|
76
|
+
* it moved; for one of `elsewhere`, the element it's about.
|
|
77
|
+
*/
|
|
78
|
+
at?: Place;
|
|
79
|
+
}
|
|
80
|
+
/** A place in the element's file: a line and a column, from 1, and the tag there as the task saw it. */
|
|
81
|
+
interface Place {
|
|
82
|
+
line: number;
|
|
83
|
+
column: number;
|
|
84
|
+
tag: string;
|
|
85
|
+
}
|
|
86
|
+
interface Model {
|
|
87
|
+
channel: string;
|
|
88
|
+
/** The channel's page, when there's one to link to. */
|
|
89
|
+
link?: string;
|
|
90
|
+
/** Tasks about this element, oldest first, canceled ones left out: also those added before it moved. */
|
|
91
|
+
tasks: Task[];
|
|
92
|
+
/** Tasks about the file's other elements, by line, canceled ones left out: each with its `at`. */
|
|
93
|
+
elsewhere: Task[];
|
|
94
|
+
/**
|
|
95
|
+
* Who watches the channel, by name (`claude`): the agents whose watch (the skill's `watch.mjs`) is running in
|
|
96
|
+
* this project, as a board can't say, and those holding a claim on one of the channel's tasks, which it can.
|
|
97
|
+
* Empty where none is and the board is this machine's own;
|
|
98
|
+
* left out where none is and the board is another, which an agent may watch from elsewhere.
|
|
99
|
+
*/
|
|
100
|
+
watching?: string[];
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* What the Task tab asks for: a new task (an `Op`), other words for one it lists (`edit` is its ID), or
|
|
104
|
+
* that one deleted (`remove` is its ID), which cancels it on the board.
|
|
105
|
+
*/
|
|
106
|
+
type Change = Op | {
|
|
107
|
+
edit: string;
|
|
108
|
+
text: string;
|
|
46
109
|
} | {
|
|
47
|
-
|
|
48
|
-
source: string;
|
|
110
|
+
remove: string;
|
|
49
111
|
};
|
|
50
|
-
/**
|
|
51
|
-
interface Extra {
|
|
52
|
-
/** The argument, or the part of it these classes come from, as written. */
|
|
53
|
-
source: string;
|
|
54
|
-
/** The classes, where the source spells them out: there, or in a `const` of the file it names. */
|
|
55
|
-
classes?: string;
|
|
56
|
-
/** What must hold for them to be added, as written: `active === 'h3'`. None where they always are. */
|
|
57
|
-
when?: string;
|
|
58
|
-
/** Set where the classes are a string in this file, which an op with `at` can write. */
|
|
59
|
-
editable?: true;
|
|
60
|
-
/** The `const` the string is in, where it isn't the argument itself: other elements may use it too. */
|
|
61
|
-
shared?: string;
|
|
62
|
-
}
|
|
112
|
+
/** A new task: what the page knows and the source doesn't. */
|
|
63
113
|
interface Op {
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
|
|
114
|
+
text: string;
|
|
115
|
+
/** The page's URL. */
|
|
116
|
+
page: string;
|
|
117
|
+
viewport: {
|
|
118
|
+
width: number;
|
|
119
|
+
height: number;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* What was under the pointer inside the element, where nothing marked it (a dependency's markup, or a
|
|
123
|
+
* shadow root's): its path from the element, and its HTML, cut short.
|
|
124
|
+
*/
|
|
125
|
+
pointed?: {
|
|
126
|
+
path: string;
|
|
127
|
+
html: string;
|
|
128
|
+
};
|
|
129
|
+
/** How many elements on the page come from the same place in the source. */
|
|
130
|
+
count: number;
|
|
131
|
+
/**
|
|
132
|
+
* The source it rendered through, after its own place, nearest first, each a `file:line`: where the file
|
|
133
|
+
* before it is used. A shared component's line says nothing of which use of it this is, and these do.
|
|
134
|
+
*/
|
|
135
|
+
chain?: string[];
|
|
136
|
+
/** The element's HTML as it rendered, to attach: cut short, and masked where the screenshots plugin is loaded. */
|
|
137
|
+
html?: string;
|
|
138
|
+
/**
|
|
139
|
+
* Shots the screenshots plugin took of it, to attach, where that plugin is loaded: each with where the
|
|
140
|
+
* element is in it, whether it's `outlined` there (dashes drawn around it, in the PNG), and the marks drawn
|
|
141
|
+
* on it in the panel, where there are any.
|
|
142
|
+
*/
|
|
143
|
+
screenshots?: {
|
|
144
|
+
id: string;
|
|
145
|
+
box: Box;
|
|
146
|
+
outlined?: boolean;
|
|
147
|
+
marks?: Marks;
|
|
148
|
+
}[];
|
|
149
|
+
/**
|
|
150
|
+
* Recordings the recordings plugin made, to attach, where that plugin is loaded: how long each ran,
|
|
151
|
+
* where it plays back, and the voice plugin's clips of the mic in it, attached too.
|
|
152
|
+
*/
|
|
153
|
+
recordings?: {
|
|
154
|
+
id: string;
|
|
155
|
+
duration: number;
|
|
156
|
+
replay: string;
|
|
157
|
+
voice?: string[];
|
|
158
|
+
}[];
|
|
159
|
+
/** Voice notes the voice plugin kept, to attach, where that plugin is loaded, and how long each runs. */
|
|
160
|
+
voice?: {
|
|
161
|
+
id: string;
|
|
162
|
+
duration: number;
|
|
163
|
+
}[];
|
|
164
|
+
/** The page's annotations, where that plugin is loaded and there are any: how many, and their notes' text. */
|
|
165
|
+
annotations?: Marks;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* A task the Task tab just added, as the page hears of it: the `detail` of a `deictic:task` event on `window`, for a
|
|
169
|
+
* page that shows its own tasks (deictic's playground lists them as a board does).
|
|
170
|
+
*/
|
|
171
|
+
interface TaskAdded {
|
|
172
|
+
id: string;
|
|
173
|
+
/** The first line of what was typed. */
|
|
174
|
+
title: string;
|
|
175
|
+
state: string;
|
|
176
|
+
channel: string;
|
|
177
|
+
/** The element: its file, line and column, and its tag. */
|
|
178
|
+
target: Target;
|
|
179
|
+
/** The page's URL. */
|
|
180
|
+
page: string;
|
|
181
|
+
/** How many of each were attached; `marks` counts those drawn on shots and on the page. */
|
|
182
|
+
attached: {
|
|
183
|
+
screenshots: number;
|
|
184
|
+
recordings: number;
|
|
185
|
+
voice: number;
|
|
186
|
+
marks: number;
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
/** Marks, as a task tells of them: how many, and what the notes among them say. */
|
|
190
|
+
interface Marks {
|
|
191
|
+
count: number;
|
|
192
|
+
notes: string[];
|
|
193
|
+
}
|
|
194
|
+
interface Added {
|
|
195
|
+
channel: string;
|
|
196
|
+
id: string;
|
|
197
|
+
text: string;
|
|
198
|
+
labels: Record<string, string>;
|
|
199
|
+
/** What's attached, by the board's IDs: kept, so a redo attaches the same without uploading it again. */
|
|
200
|
+
attachments?: string[];
|
|
201
|
+
}
|
|
202
|
+
/** A task's words changed: its message's whole text before and after. */
|
|
203
|
+
interface Edited {
|
|
204
|
+
kind: 'edited';
|
|
205
|
+
id: string;
|
|
206
|
+
before: string;
|
|
207
|
+
after: string;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* A task deleted in the panel: canceled on the board, for good, as a board has it. So it's kept whole, and
|
|
211
|
+
* an undo adds it again, as a new task whose ID the record then has.
|
|
212
|
+
*/
|
|
213
|
+
interface Removed extends Added {
|
|
214
|
+
kind: 'removed';
|
|
67
215
|
}
|
|
68
|
-
|
|
69
|
-
|
|
216
|
+
/** What the history keeps of a change: a task added has no `kind`, as it had none before there were others. */
|
|
217
|
+
type Kept = Added | Edited | Removed;
|
|
218
|
+
declare function tasks(options?: TasksOptions): import("deictic").ServerPlugin<Model, Change, Kept, unknown>;
|
|
219
|
+
export { local as _, Marks as a, Place as c, TaskAdded as d, TaskBoard as f, LocalOptions as g, LocalBoard as h, Kept as i, Removed as l, tasks as m, Change as n, Model as o, TasksOptions as p, Edited as r, Op as s, Added as t, Task as u };
|
|
70
220
|
//# sourceMappingURL=index5.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index5.d.ts","names":[],"sources":["../../src/plugins/
|
|
1
|
+
{"version":3,"file":"index5.d.ts","names":[],"sources":["../../src/plugins/tasks/local.ts","../../src/plugins/tasks/index.ts"],"mappings":";;;UAkBiB;;;;;EAKf;;EAEA;;EAEA;;EAEA;;;UAIe;EACf,OAAO;;;;;;cAOI,QAAK,UAAa,iBAAoB;;KCTvC,YAAY,KAAK;UAEZ;;;;;;;;EAQf,QAAQ,YAAY;;EAEpB;;;;;EAKA;;EAEA,SAAS;;;;;;;EAOT,QAAQ,iBAAiB;;;;;;;EAOzB;;EAEA,WAAW;;UAGI;EACf;;EAEA;;EAEA;EACA;;EAEA;;EAEA;;;;;EAKA,KAAK;;;UAIU;EACf;EACA;EACA;;UAGe;EACf;;EAEA;;EAEA,OAAO;;EAEP,WAAW;;;;;;;EAOX;;;;;;KAOU,SAAS;EAAO;EAAc;;EAAmB;;;UAG5C;EACf;;EAEA;EACA;IAAY;IAAe;;;;;;EAK3B;IAAY;IAAc;;;EAE1B;;;;;EAKA;;EAEA;;;;;;EAMA;IAAgB;IAAY,KAAK;IAAK;IAAoB,QAAQ;;;;;;EAKlE;IAAe;IAAY;IAAkB;IAAgB;;;EAE7D;IAAU;IAAY;;;EAEtB,cAAc;;;;;;UAOC;EACf;;EAEA;EACA;EACA;;EAEA,QAAQ;;EAER;;EAEA;IAAY;IAAqB;IAAoB;IAAe;;;;UAIrD;EACf;EACA;;UAGe;EACf;EACA;EACA;EACA,QAAQ;;EAER;;;UAIe;EACf;EACA;EACA;EACA;;;;;;UAOe,gBAAgB;EAC/B;;;KAIU,OAAO,QAAQ,SAAS;iBAQpB,MAAM,UAAS,iCAAiB,aAAA,OAAA,QAAA"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { w as Shortcut } from "./index.js";
|
|
2
|
+
/** A class as the panel shows it. */
|
|
3
|
+
interface ClassInfo {
|
|
4
|
+
name: string;
|
|
5
|
+
/** Whether Tailwind makes anything of it: a class of the project's own isn't known. */
|
|
6
|
+
known: boolean;
|
|
7
|
+
/** The colour it sets, as CSS. */
|
|
8
|
+
color?: string;
|
|
9
|
+
/** What it sets its main property to, theme values resolved: `0.875rem`. */
|
|
10
|
+
value?: string;
|
|
11
|
+
/** A variant to go on typing after (`hover:`), not a class. */
|
|
12
|
+
variant?: true;
|
|
13
|
+
}
|
|
14
|
+
/** The classes of one kind, and how to write one with a value of the user's own. */
|
|
15
|
+
interface Alternatives {
|
|
16
|
+
/** The property the kind sets: `font-size`. */
|
|
17
|
+
label: string;
|
|
18
|
+
/** Whether the kind is a colour's, shown as swatches. */
|
|
19
|
+
colors: boolean;
|
|
20
|
+
items: ClassInfo[];
|
|
21
|
+
/** A custom value goes between these: `md:text-[` and `]`. None for a kind that takes no value (`flex`). */
|
|
22
|
+
custom?: {
|
|
23
|
+
before: string;
|
|
24
|
+
after: string;
|
|
25
|
+
value?: string;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
interface TailwindOptions {
|
|
29
|
+
/** Calls whose first argument is a class list: `cn`, `clsx`, `cx`, `twMerge`, `classNames` by default. */
|
|
30
|
+
helpers?: string[];
|
|
31
|
+
/** The attribute an element without one gets: `className`, or `class` for Solid and Preact. */
|
|
32
|
+
attribute?: 'className' | 'class';
|
|
33
|
+
/**
|
|
34
|
+
* The stylesheet that imports Tailwind and holds the theme, from the project's root: `src/index.css`. What
|
|
35
|
+
* the panel completes and shows comes from it. Tailwind's default theme without one.
|
|
36
|
+
*/
|
|
37
|
+
css?: string;
|
|
38
|
+
/** What opens its tab directly, beside deictic's own shortcut, which opens any: none by default. */
|
|
39
|
+
shortcut?: Shortcut;
|
|
40
|
+
}
|
|
41
|
+
type Model = {
|
|
42
|
+
editable: true;
|
|
43
|
+
classes: string;
|
|
44
|
+
/** The helper's other arguments, which add classes at runtime, each read as far as the source says. */
|
|
45
|
+
others?: Extra[];
|
|
46
|
+
} | {
|
|
47
|
+
editable: false;
|
|
48
|
+
source: string;
|
|
49
|
+
};
|
|
50
|
+
/** Classes a helper's argument adds: `active && 'ring'` is `ring` when `active`. */
|
|
51
|
+
interface Extra {
|
|
52
|
+
/** The argument, or the part of it these classes come from, as written. */
|
|
53
|
+
source: string;
|
|
54
|
+
/** The classes, where the source spells them out: there, or in a `const` of the file it names. */
|
|
55
|
+
classes?: string;
|
|
56
|
+
/** What must hold for them to be added, as written: `active === 'h3'`. None where they always are. */
|
|
57
|
+
when?: string;
|
|
58
|
+
/** Set where the classes are a string in this file, which an op with `at` can write. */
|
|
59
|
+
editable?: true;
|
|
60
|
+
/** The `const` the string is in, where it isn't the argument itself: other elements may use it too. */
|
|
61
|
+
shared?: string;
|
|
62
|
+
}
|
|
63
|
+
interface Op {
|
|
64
|
+
classes: string;
|
|
65
|
+
/** Which of the model's `others` the classes are for, by its place there. The element's own list without. */
|
|
66
|
+
at?: number;
|
|
67
|
+
}
|
|
68
|
+
declare function tailwind(options?: TailwindOptions): import("deictic").ServerPlugin<Model, Op, unknown, unknown>;
|
|
69
|
+
export { tailwind as a, TailwindOptions as i, Model as n, Alternatives as o, Op as r, ClassInfo as s, Extra as t };
|
|
70
|
+
//# sourceMappingURL=index6.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index6.d.ts","names":[],"sources":["../../src/plugins/tailwind/catalog.ts","../../src/plugins/tailwind/index.ts"],"mappings":";;UAeiB;EACf;;EAEA;;EAEA;;EAEA;;EAEA;;;UAIe;;EAEf;;EAEA;EACA,OAAO;;EAEP;IAAW;IAAgB;IAAe;;;UCf3B;;EAEf;;EAEA;;;;;EAKA;;EAEA,WAAW;;KAGD;EAEN;EACA;;EAEA,SAAS;;EAET;EAAiB;;;UAGN;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;UAGe;EACf;;EAEA;;iBASc,SAAS,UAAS,oCAAoB,aAAA,OAAA"}
|
package/dist/shared/marks.js
CHANGED
|
@@ -5,10 +5,15 @@
|
|
|
5
5
|
*/
|
|
6
6
|
const MARKS = "deictic.annotations";
|
|
7
7
|
/**
|
|
8
|
+
* The custom event for the page's address changing with no load, as a router does it (`href`, the new one): rrweb
|
|
9
|
+
* records what the route drew, not that the address changed. A page that loads has rrweb's own `Meta` instead.
|
|
10
|
+
*/
|
|
11
|
+
const PAGE = "deictic.page";
|
|
12
|
+
/**
|
|
8
13
|
* The custom event a recording ends with: rrweb's timeline lasts as long as its events, so without it a
|
|
9
14
|
* recording of a still page (a voice-over, say) would replay as a moment, and its voice never play.
|
|
10
15
|
*/
|
|
11
16
|
const END = "deictic.end";
|
|
12
|
-
export { MARKS as n, END as t };
|
|
17
|
+
export { MARKS as n, PAGE as r, END as t };
|
|
13
18
|
|
|
14
19
|
//# sourceMappingURL=marks.js.map
|
package/dist/shared/marks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marks.js","names":[],"sources":["../../src/plugins/recordings/marks.ts"],"sourcesContent":["/**\n * The custom event's tag the marks go in: the page's annotations, as an SVG in page coordinates (`svg`),\n * and as the annotations themselves (`annotations`, absent from recordings made before it was added).\n */\nexport const MARKS = 'deictic.annotations';\n\n/**\n * The custom event a recording ends with: rrweb's timeline lasts as long as its events, so without it a\n * recording of a still page (a voice-over, say) would replay as a moment, and its voice never play.\n */\nexport const END = 'deictic.end';\n"],"mappings":";;;;;AAIA,MAAa,QAAQ;;;;;AAMrB,MAAa,MAAM"}
|
|
1
|
+
{"version":3,"file":"marks.js","names":[],"sources":["../../src/plugins/recordings/marks.ts"],"sourcesContent":["/**\n * The custom event's tag the marks go in: the page's annotations, as an SVG in page coordinates (`svg`),\n * and as the annotations themselves (`annotations`, absent from recordings made before it was added).\n */\nexport const MARKS = 'deictic.annotations';\n\n/**\n * The custom event for the page's address changing with no load, as a router does it (`href`, the new one): rrweb\n * records what the route drew, not that the address changed. A page that loads has rrweb's own `Meta` instead.\n */\nexport const PAGE = 'deictic.page';\n\n/**\n * The custom event a recording ends with: rrweb's timeline lasts as long as its events, so without it a\n * recording of a still page (a voice-over, say) would replay as a moment, and its voice never play.\n */\nexport const END = 'deictic.end';\n"],"mappings":";;;;;AAIA,MAAa,QAAQ;;;;;AAMrB,MAAa,OAAO;;;;;AAMpB,MAAa,MAAM"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// src/plugins/network/mask.ts
|
|
2
|
+
/** What a blanked value reads as. */
|
|
3
|
+
const MASKED = "***";
|
|
4
|
+
/** What's kept of a body at most, in characters. */
|
|
5
|
+
const BODY = 1e4;
|
|
6
|
+
/** A name with one of these in it holds a secret, in any case: `access_token`, `X-Api-Key`, `Set-Cookie`. */
|
|
7
|
+
const PARTS = [
|
|
8
|
+
"token",
|
|
9
|
+
"secret",
|
|
10
|
+
"passw",
|
|
11
|
+
"pwd",
|
|
12
|
+
"auth",
|
|
13
|
+
"cookie",
|
|
14
|
+
"session",
|
|
15
|
+
"credential",
|
|
16
|
+
"signature",
|
|
17
|
+
"apikey",
|
|
18
|
+
"api-key",
|
|
19
|
+
"api_key",
|
|
20
|
+
"jwt",
|
|
21
|
+
"otp",
|
|
22
|
+
"cvv",
|
|
23
|
+
"cvc",
|
|
24
|
+
"ssn",
|
|
25
|
+
"cardnumber",
|
|
26
|
+
"card_number"
|
|
27
|
+
];
|
|
28
|
+
/** And these whole names, too short to look for inside others: `code` is OAuth's, on its way back. */
|
|
29
|
+
const NAMES = /* @__PURE__ */ new Set([
|
|
30
|
+
"key",
|
|
31
|
+
"pass",
|
|
32
|
+
"code",
|
|
33
|
+
"pin",
|
|
34
|
+
"sig",
|
|
35
|
+
"sid"
|
|
36
|
+
]);
|
|
37
|
+
/** deictic's own requests: a recording sends itself as it goes, which would be a request to record each second. */
|
|
38
|
+
const OURS = "/__deictic/";
|
|
39
|
+
const sensitive = (name, more = []) => {
|
|
40
|
+
const lower = name.toLowerCase();
|
|
41
|
+
return NAMES.has(lower) || PARTS.some((part) => lower.includes(part)) || more.some((part) => lower.includes(part.toLowerCase()));
|
|
42
|
+
};
|
|
43
|
+
function maskParams(params, more) {
|
|
44
|
+
let changed = false;
|
|
45
|
+
for (const name of new Set(params.keys())) {
|
|
46
|
+
if (!sensitive(name, more)) continue;
|
|
47
|
+
params.set(name, "***");
|
|
48
|
+
changed = true;
|
|
49
|
+
}
|
|
50
|
+
return changed;
|
|
51
|
+
}
|
|
52
|
+
/** The URL without a name and password before its host, and with its secrets blanked: the query's, and a fragment's that reads as one. */
|
|
53
|
+
function maskUrl(url, more = []) {
|
|
54
|
+
let parsed;
|
|
55
|
+
try {
|
|
56
|
+
parsed = new URL(url);
|
|
57
|
+
} catch {
|
|
58
|
+
return url;
|
|
59
|
+
}
|
|
60
|
+
let changed = parsed.username !== "" || parsed.password !== "";
|
|
61
|
+
parsed.username = parsed.password = "";
|
|
62
|
+
if (maskParams(parsed.searchParams, more)) changed = true;
|
|
63
|
+
if (parsed.hash.includes("=")) {
|
|
64
|
+
const fragment = new URLSearchParams(parsed.hash.slice(1));
|
|
65
|
+
if (maskParams(fragment, more)) {
|
|
66
|
+
parsed.hash = fragment.toString();
|
|
67
|
+
changed = true;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return changed ? parsed.href.replaceAll(encodeURIComponent("***"), "***") : url;
|
|
71
|
+
}
|
|
72
|
+
function maskHeaders(headers, more = []) {
|
|
73
|
+
return Object.fromEntries(Object.entries(headers).map(([name, value]) => [name, sensitive(name, more) ? "***" : value]));
|
|
74
|
+
}
|
|
75
|
+
function maskJson(value, more) {
|
|
76
|
+
if (Array.isArray(value)) return value.map((item) => maskJson(item, more));
|
|
77
|
+
if (typeof value !== "object" || value === null) return value;
|
|
78
|
+
return Object.fromEntries(Object.entries(value).map(([name, inner]) => [name, sensitive(name, more) ? "***" : maskJson(inner, more)]));
|
|
79
|
+
}
|
|
80
|
+
/** A body with its secrets blanked where it's JSON or a form's fields, cut where it's long: other text has no names to go by. */
|
|
81
|
+
function maskBody(body, more = []) {
|
|
82
|
+
const cut = (text) => text.length > BODY ? `${text.slice(0, BODY)}… (${text.length} characters)` : text;
|
|
83
|
+
const text = body.trim();
|
|
84
|
+
if (text.startsWith("{") || text.startsWith("[")) try {
|
|
85
|
+
return cut(JSON.stringify(maskJson(JSON.parse(text), more)));
|
|
86
|
+
} catch {}
|
|
87
|
+
if (/^[^\s=&]+=[^\s&]*(&[^\s=&]+=[^\s&]*)*$/.test(text)) {
|
|
88
|
+
const fields = new URLSearchParams(text);
|
|
89
|
+
if (maskParams(fields, more)) return cut(fields.toString().replaceAll(encodeURIComponent("***"), "***"));
|
|
90
|
+
}
|
|
91
|
+
return cut(body);
|
|
92
|
+
}
|
|
93
|
+
/** The request as it's kept, or nothing for one left out. */
|
|
94
|
+
function maskRequest(request, { mask, ignore }) {
|
|
95
|
+
if (request.name.includes(OURS) || ignore.some((part) => request.name.includes(part))) return void 0;
|
|
96
|
+
return {
|
|
97
|
+
...request,
|
|
98
|
+
name: maskUrl(request.name, mask),
|
|
99
|
+
...request.requestHeaders ? { requestHeaders: maskHeaders(request.requestHeaders, mask) } : {},
|
|
100
|
+
...request.responseHeaders ? { responseHeaders: maskHeaders(request.responseHeaders, mask) } : {},
|
|
101
|
+
...typeof request.requestBody === "string" ? { requestBody: maskBody(request.requestBody, mask) } : {},
|
|
102
|
+
...typeof request.responseBody === "string" ? { responseBody: maskBody(request.responseBody, mask) } : {}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
export { maskUrl as a, maskRequest as i, maskBody as n, sensitive as o, maskHeaders as r, MASKED as t };
|
|
106
|
+
|
|
107
|
+
//# sourceMappingURL=mask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mask.js","names":[],"sources":["../../src/plugins/network/mask.ts"],"sourcesContent":["/**\n * What a request is kept as: with what it carries that's a secret blanked, wherever a name says so. The\n * names are all there is to go by, so a secret under a name that says nothing (a token in a path, a password in\n * prose) isn't found: bodies and headers are kept only where asked for, and `ignore` leaves a request out whole.\n */\n\n/** A request as rrweb's network plugin has it: all this reads of one, and changes. */\nexport interface Request {\n name: string;\n requestHeaders?: Record<string, string>;\n responseHeaders?: Record<string, string>;\n requestBody?: string | null;\n responseBody?: string | null;\n}\n\nexport interface Masking {\n /** More names whose values are blanked, as these are: a part of the name, in any case. */\n mask: string[];\n /** Requests left out: a part of the URL. */\n ignore: string[];\n}\n\n/** What a blanked value reads as. */\nexport const MASKED = '***';\n/** What's kept of a body at most, in characters. */\nconst BODY = 10_000;\n\n/** A name with one of these in it holds a secret, in any case: `access_token`, `X-Api-Key`, `Set-Cookie`. */\nconst PARTS = [\n 'token',\n 'secret',\n 'passw',\n 'pwd',\n 'auth',\n 'cookie',\n 'session',\n 'credential',\n 'signature',\n 'apikey',\n 'api-key',\n 'api_key',\n 'jwt',\n 'otp',\n 'cvv',\n 'cvc',\n 'ssn',\n 'cardnumber',\n 'card_number',\n];\n/** And these whole names, too short to look for inside others: `code` is OAuth's, on its way back. */\nconst NAMES = new Set(['key', 'pass', 'code', 'pin', 'sig', 'sid']);\n/** deictic's own requests: a recording sends itself as it goes, which would be a request to record each second. */\nconst OURS = '/__deictic/';\n\nexport const sensitive = (name: string, more: readonly string[] = []): boolean => {\n const lower = name.toLowerCase();\n return NAMES.has(lower) || PARTS.some((part) => lower.includes(part)) || more.some((part) => lower.includes(part.toLowerCase()));\n};\n\nfunction maskParams(params: URLSearchParams, more: readonly string[]): boolean {\n let changed = false;\n for (const name of new Set(params.keys())) {\n if (!sensitive(name, more)) continue;\n params.set(name, MASKED);\n changed = true;\n }\n return changed;\n}\n\n/** The URL without a name and password before its host, and with its secrets blanked: the query's, and a fragment's that reads as one. */\nexport function maskUrl(url: string, more: readonly string[] = []): string {\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n // Not one this can read: kept as it is, as there's no telling its parts.\n return url;\n }\n let changed = parsed.username !== '' || parsed.password !== '';\n parsed.username = parsed.password = '';\n if (maskParams(parsed.searchParams, more)) changed = true;\n if (parsed.hash.includes('=')) {\n const fragment = new URLSearchParams(parsed.hash.slice(1));\n if (maskParams(fragment, more)) {\n parsed.hash = fragment.toString();\n changed = true;\n }\n }\n // As it was written where nothing changed: a parsed URL spells some things its own way.\n return changed ? parsed.href.replaceAll(encodeURIComponent(MASKED), MASKED) : url;\n}\n\nexport function maskHeaders(headers: Record<string, string>, more: readonly string[] = []): Record<string, string> {\n return Object.fromEntries(Object.entries(headers).map(([name, value]) => [name, sensitive(name, more) ? MASKED : value]));\n}\n\nfunction maskJson(value: unknown, more: readonly string[]): unknown {\n if (Array.isArray(value)) return value.map((item) => maskJson(item, more));\n if (typeof value !== 'object' || value === null) return value;\n return Object.fromEntries(Object.entries(value).map(([name, inner]) => [name, sensitive(name, more) ? MASKED : maskJson(inner, more)]));\n}\n\n/** A body with its secrets blanked where it's JSON or a form's fields, cut where it's long: other text has no names to go by. */\nexport function maskBody(body: string, more: readonly string[] = []): string {\n const cut = (text: string) => (text.length > BODY ? `${text.slice(0, BODY)}… (${text.length} characters)` : text);\n const text = body.trim();\n if (text.startsWith('{') || text.startsWith('[')) {\n try {\n return cut(JSON.stringify(maskJson(JSON.parse(text), more)));\n } catch {\n // Not JSON after all.\n }\n }\n // A form's fields: `name=value&…`, with nothing a sentence would have.\n if (/^[^\\s=&]+=[^\\s&]*(&[^\\s=&]+=[^\\s&]*)*$/.test(text)) {\n const fields = new URLSearchParams(text);\n if (maskParams(fields, more)) return cut(fields.toString().replaceAll(encodeURIComponent(MASKED), MASKED));\n }\n return cut(body);\n}\n\n/** The request as it's kept, or nothing for one left out. */\nexport function maskRequest<R extends Request>(request: R, { mask, ignore }: Masking): R | undefined {\n if (request.name.includes(OURS) || ignore.some((part) => request.name.includes(part))) return undefined;\n return {\n ...request,\n name: maskUrl(request.name, mask),\n ...(request.requestHeaders ? { requestHeaders: maskHeaders(request.requestHeaders, mask) } : {}),\n ...(request.responseHeaders ? { responseHeaders: maskHeaders(request.responseHeaders, mask) } : {}),\n ...(typeof request.requestBody === 'string' ? { requestBody: maskBody(request.requestBody, mask) } : {}),\n ...(typeof request.responseBody === 'string' ? { responseBody: maskBody(request.responseBody, mask) } : {}),\n };\n}\n"],"mappings":";;AAuBA,MAAa,SAAS;;AAEtB,MAAM,OAAO;;AAGb,MAAM,QAAQ;CACZ;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAEA,MAAM,wBAAQ,IAAI,IAAI;CAAC;CAAO;CAAQ;CAAQ;CAAO;CAAO;AAAK,CAAC;;AAElE,MAAM,OAAO;AAEb,MAAa,aAAa,MAAc,OAA0B,CAAC,MAAe;CAChF,MAAM,QAA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aAAa,IAAI,EAAE,IAAI,CAAC;EACtG,GAAI,OAAO,QAAQ,iBAAiB,WAAW,EAAE,cAAc,SAAS,QAAQ,cAAc,IAAI,EAAE,IAAI,CAAC;CAC3G;AACF"}
|
|
@@ -8,6 +8,11 @@ import { createRequire } from "node:module";
|
|
|
8
8
|
* The snapshot is rebuilt into a sandboxed iframe filling a blank page on the page's own origin, which
|
|
9
9
|
* Playwright answers itself, so nothing asks the dev server for it: rrweb has made the snapshot's URLs
|
|
10
10
|
* whole, and its stylesheets' fonts and images load from the dev server as the page's did.
|
|
11
|
+
*
|
|
12
|
+
* The browser is as big as the page's window, scrollbars and all, and shows its own: a media query asks the
|
|
13
|
+
* window's width, and the page is laid out in what the scrollbar leaves. At the width without it, a window
|
|
14
|
+
* right on a breakpoint (1024 wide, 1009 to lay out in) would render as the narrower layout. The shot is then
|
|
15
|
+
* cut to the part the page is in.
|
|
11
16
|
*/
|
|
12
17
|
const HOST = "<!doctype html><html><body style=\"margin:0\"></body></html>";
|
|
13
18
|
const browsers = /* @__PURE__ */ new Map();
|
|
@@ -21,13 +26,16 @@ function browserOf(options) {
|
|
|
21
26
|
launched.catch(() => browsers.delete(key));
|
|
22
27
|
return launched;
|
|
23
28
|
}
|
|
29
|
+
/** Playwright hides a headless browser's scrollbars, and with them the room they take in the page. */
|
|
30
|
+
const SCROLLBARS = { ignoreDefaultArgs: ["--hide-scrollbars"] };
|
|
24
31
|
async function launch({ executablePath, channel }) {
|
|
25
32
|
const { chromium } = await import("playwright-core").catch((e) => {
|
|
26
33
|
throw new Error("the rrweb() renderer needs playwright-core: add it to your devDependencies", { cause: e });
|
|
27
34
|
});
|
|
28
35
|
if (executablePath !== void 0 || channel !== void 0) return chromium.launch({
|
|
29
36
|
executablePath,
|
|
30
|
-
channel
|
|
37
|
+
channel,
|
|
38
|
+
...SCROLLBARS
|
|
31
39
|
});
|
|
32
40
|
const tried = [];
|
|
33
41
|
for (const attempt of [
|
|
@@ -35,7 +43,10 @@ async function launch({ executablePath, channel }) {
|
|
|
35
43
|
{ channel: "chrome" },
|
|
36
44
|
{ channel: "msedge" }
|
|
37
45
|
]) try {
|
|
38
|
-
return await chromium.launch(
|
|
46
|
+
return await chromium.launch({
|
|
47
|
+
...attempt,
|
|
48
|
+
...SCROLLBARS
|
|
49
|
+
});
|
|
39
50
|
} catch (e) {
|
|
40
51
|
tried.push(`${"channel" in attempt ? attempt.channel : "Playwright's Chromium"}: ${(e instanceof Error ? e.message : String(e)).split("\n", 1)[0]}`);
|
|
41
52
|
}
|
|
@@ -47,7 +58,7 @@ async function render(input, options) {
|
|
|
47
58
|
const shot = input;
|
|
48
59
|
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");
|
|
49
60
|
const context = await (await browserOf(options)).newContext({
|
|
50
|
-
viewport: shot.viewport,
|
|
61
|
+
viewport: shot.window ?? shot.viewport,
|
|
51
62
|
deviceScaleFactor: shot.scale
|
|
52
63
|
});
|
|
53
64
|
try {
|
|
@@ -78,7 +89,11 @@ async function render(input, options) {
|
|
|
78
89
|
marks.innerHTML = overlay;
|
|
79
90
|
document.body.append(marks);
|
|
80
91
|
}, shot);
|
|
81
|
-
const clip =
|
|
92
|
+
const clip = clamp(shot.clip ?? {
|
|
93
|
+
x: 0,
|
|
94
|
+
y: 0,
|
|
95
|
+
...shot.viewport
|
|
96
|
+
}, shot.viewport);
|
|
82
97
|
return new Uint8Array(await page.screenshot({
|
|
83
98
|
type: "png",
|
|
84
99
|
...clip === void 0 ? {} : { clip }
|
|
@@ -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 */\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 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\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 });\n const tried: string[] = [];\n for (const attempt of [{}, { channel: 'chrome' }, { channel: 'msedge' }]) {\n try {\n return await chromium.launch(attempt);\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.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 const clip = shot.clip
|
|
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,EA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