deictic 0.1.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 -104
- package/dist/annotations/index.d.ts +1 -1
- package/dist/astro.d.ts +1 -1
- package/dist/bun.d.ts +1 -1
- package/dist/bun.js +2 -2
- package/dist/client/index.d.ts +4 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +130 -16
- package/dist/client/index.js.map +1 -1
- package/dist/index.d.ts +21 -218
- package/dist/index.js.map +1 -1
- package/dist/loader.js +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/next.d.ts +1 -1
- package/dist/next.js +2 -2
- package/dist/recommended/index.d.ts +15 -5
- package/dist/recommended/index.d.ts.map +1 -1
- package/dist/recommended/index.js +10 -3
- 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 +177 -48
- package/dist/recordings/client.js.map +1 -1
- package/dist/recordings/index.d.ts +2 -2
- package/dist/recordings/index.js +3 -3
- package/dist/screenshots/client.d.ts +7 -1
- package/dist/screenshots/client.d.ts.map +1 -1
- package/dist/screenshots/client.js +36 -4
- package/dist/screenshots/client.js.map +1 -1
- package/dist/screenshots/dom.d.ts +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.d.ts +1 -1
- package/dist/screenshots/index.js +2 -2
- package/dist/screenshots/index.js.map +1 -1
- package/dist/screenshots/rrweb.d.ts +2 -2
- package/dist/screenshots/rrweb.js +5 -1
- package/dist/screenshots/rrweb.js.map +1 -1
- package/dist/{endpoints.js → shared/endpoints.js} +1 -1
- package/dist/shared/endpoints.js.map +1 -0
- package/dist/shared/index.d.ts +238 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/{index3.d.ts → shared/index2.d.ts} +3 -1
- package/dist/shared/index2.d.ts.map +1 -0
- package/dist/shared/index3.d.ts +112 -0
- package/dist/shared/index3.d.ts.map +1 -0
- package/dist/shared/index4.d.ts +64 -0
- package/dist/shared/index4.d.ts.map +1 -0
- package/dist/shared/index5.d.ts +220 -0
- package/dist/shared/index5.d.ts.map +1 -0
- package/dist/{index5.d.ts → shared/index6.d.ts} +2 -2
- package/dist/shared/index6.d.ts.map +1 -0
- package/dist/{integration.d.ts → shared/integration.d.ts} +4 -3
- package/dist/shared/integration.d.ts.map +1 -0
- package/dist/{integration.js → shared/integration.js} +5 -3
- package/dist/shared/integration.js.map +1 -0
- package/dist/{kept.js → shared/kept.js} +2 -2
- package/dist/shared/kept.js.map +1 -0
- package/dist/{marks.js → shared/marks.js} +6 -1
- package/dist/shared/marks.js.map +1 -0
- package/dist/shared/mask.js +107 -0
- package/dist/shared/mask.js.map +1 -0
- package/dist/{playwright.js → shared/playwright.js} +19 -4
- package/dist/shared/playwright.js.map +1 -0
- package/dist/shared/recordings.js +437 -0
- package/dist/shared/recordings.js.map +1 -0
- package/dist/shared/shortcut.js.map +1 -0
- package/dist/shared/tasks.js +632 -0
- package/dist/shared/tasks.js.map +1 -0
- package/dist/shared/waveform.js.map +1 -0
- 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 +272 -57
- package/dist/tasks/client.js.map +1 -1
- package/dist/tasks/index.d.ts +2 -159
- package/dist/tasks/index.js +1 -348
- package/dist/vite.d.ts +11 -12
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +21 -4
- package/dist/vite.js.map +1 -1
- package/dist/voice/client.d.ts.map +1 -1
- package/dist/voice/client.js +36 -15
- 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 +13 -3
- package/dist/voice/index.js.map +1 -1
- package/dist/webpack.d.ts +1 -1
- package/dist/webpack.js +2 -2
- package/package.json +41 -2
- package/skills/deictic/SKILL.md +20 -14
- package/skills/deictic/references/install.md +32 -10
- 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 +88 -4
- 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 +60 -16
- package/src/client/style.ts +1 -0
- package/src/index.ts +21 -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 +220 -40
- package/src/plugins/recordings/index.ts +111 -25
- package/src/plugins/recordings/marks.ts +6 -0
- package/src/plugins/recordings/replay.ts +159 -10
- package/src/plugins/screenshots/client.ts +38 -2
- 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 +207 -47
- package/src/plugins/tasks/local.ts +170 -0
- package/src/plugins/tasks/watchers.ts +36 -0
- package/src/plugins/voice/client.ts +33 -10
- package/src/plugins/voice/index.ts +21 -4
- package/src/tools/integration.ts +5 -3
- package/src/tools/kept.ts +2 -2
- package/src/vite.ts +23 -4
- package/dist/endpoints.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index2.d.ts +0 -23
- package/dist/index3.d.ts.map +0 -1
- package/dist/index4.d.ts +0 -74
- package/dist/index4.d.ts.map +0 -1
- package/dist/index5.d.ts.map +0 -1
- package/dist/integration.d.ts.map +0 -1
- package/dist/integration.js.map +0 -1
- package/dist/kept.js.map +0 -1
- package/dist/marks.js.map +0 -1
- package/dist/playwright.js.map +0 -1
- package/dist/recordings.js +0 -235
- package/dist/recordings.js.map +0 -1
- package/dist/shortcut.js.map +0 -1
- package/dist/tasks/index.d.ts.map +0 -1
- package/dist/tasks/index.js.map +0 -1
- package/dist/waveform.js.map +0 -1
- /package/dist/{shortcut.js → shared/shortcut.js} +0 -0
- /package/dist/{waveform.js → shared/waveform.js} +0 -0
|
@@ -10,29 +10,74 @@
|
|
|
10
10
|
* which the replayer rebuilds. Each is a marker on the timeline.
|
|
11
11
|
* - The voice clips play in step, at the player's speed. A recording with voice starts paused, as a browser
|
|
12
12
|
* plays sound only after a click.
|
|
13
|
+
* - What the page logged and asked for (rrweb's console and network plugins' events, which its player doesn't
|
|
14
|
+
* show) is a list beside the replay, where the window has the room: the row the replay is at is lit, a click on
|
|
15
|
+
* one goes to its moment and shows the rest of it, and each error and failed request is a mark on the timeline.
|
|
16
|
+
* - A recorded canvas is replayed (`UNSAFE_replayCanvas`, which lets the replay's frame run rrweb's own script
|
|
17
|
+
* to draw it), for a recording that has one.
|
|
13
18
|
*
|
|
14
19
|
* `?t=<seconds>` opens it paused there, and `&bare` without the controls at the recorded size, 1:1, for a
|
|
15
20
|
* screenshot; `?embed` is it filling a frame, with no header of its own (the lightbox's); `body[data-ready]` says
|
|
16
21
|
* it's in place.
|
|
22
|
+
*
|
|
23
|
+
* The plugin's routes serve it, the player and what it plays. A page with no server behind it (a `standalone` build)
|
|
24
|
+
* publishes it as a file instead, `replayPage(sources)`: which recording is `?id=`, and a script of its own says
|
|
25
|
+
* where one is.
|
|
17
26
|
*/
|
|
18
27
|
import { MARKS } from './marks.ts';
|
|
19
28
|
|
|
20
|
-
|
|
29
|
+
/** Where the replay page finds what the plugin's routes would serve it, for a page published as a file. */
|
|
30
|
+
export interface ReplaySources {
|
|
31
|
+
/** The folder `player.js` and `player.css` are in (`rrweb-player`'s `rrweb-player.umd.min.cjs` and `style.css`), from the page: `..`, the routes', by default. */
|
|
32
|
+
player?: string;
|
|
33
|
+
/**
|
|
34
|
+
* A script, from the page, that sets `globalThis.deicticReplay` before the page asks: `recording(id)` answers the
|
|
35
|
+
* recording (a `Kept`) and `clip(id)` a voice clip's URL, either as a promise. The routes by default.
|
|
36
|
+
*/
|
|
37
|
+
source?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** The replay page's HTML: the routes' as it is, or one for a page published as a file. */
|
|
41
|
+
export const replayPage = ({ player = '..', source }: ReplaySources = {}) => `<!doctype html>
|
|
21
42
|
<html lang="en">
|
|
22
43
|
<meta charset="utf-8">
|
|
23
44
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
24
45
|
<title>Recording · deictic</title>
|
|
25
|
-
<link rel="stylesheet" href="
|
|
46
|
+
<link rel="stylesheet" href="${player}/player.css">
|
|
26
47
|
<style>
|
|
27
48
|
:root { color-scheme: dark; --accent: #12b358; }
|
|
28
49
|
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: #18181b; color: #fafafa; font: 13px/1.4 system-ui, sans-serif; }
|
|
29
50
|
header { display: flex; gap: 10px; align-items: center; padding: 10px 16px; border-bottom: 1px solid #3f3f46; }
|
|
30
51
|
header a { color: #a1a1aa; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
31
|
-
|
|
52
|
+
#stage { flex: 1; display: flex; min-height: 0; }
|
|
53
|
+
main { flex: 1; min-width: 0; display: flex; justify-content: center; align-items: flex-start; padding: 16px; }
|
|
32
54
|
body.bare header { display: none; }
|
|
33
55
|
body.bare main { padding: 0; }
|
|
34
56
|
body.embed header { display: none; }
|
|
35
57
|
body.embed main { padding: 0; }
|
|
58
|
+
/* What the page logged and asked for, beside the replay: the window's height, its list scrolling in it. */
|
|
59
|
+
#log { display: none; flex: none; width: 340px; flex-direction: column; border-left: 1px solid #3f3f46; background: #1f1f23; }
|
|
60
|
+
body.logged { height: 100vh; }
|
|
61
|
+
body.logged #log { display: flex; }
|
|
62
|
+
@media (max-width: 899px) { body.logged #log { display: none; } }
|
|
63
|
+
#log .filters { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid #3f3f46; }
|
|
64
|
+
#log .filters button { padding: 3px 8px; border: 1px solid #3f3f46; border-radius: 6px; background: none; color: #a1a1aa; font: inherit; font-size: 12px; cursor: pointer; }
|
|
65
|
+
#log .filters button[aria-pressed='true'] { color: #fafafa; background: #3f3f46; }
|
|
66
|
+
#log ol { flex: 1; min-height: 0; overflow: auto; margin: 0; padding: 0; list-style: none; font: 12px/1.45 ui-monospace, monospace; }
|
|
67
|
+
#log li { border-bottom: 1px solid #2e2e33; border-left: 2px solid transparent; }
|
|
68
|
+
#log li.ahead { opacity: 0.45; }
|
|
69
|
+
#log li.now { border-left-color: var(--accent); background: #27272a; }
|
|
70
|
+
#log li.warn .label { color: #fbbf24; }
|
|
71
|
+
#log li.bad .label, #log li.bad .text { color: #f87171; }
|
|
72
|
+
#log li > button { display: flex; gap: 8px; align-items: baseline; width: 100%; padding: 5px 8px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
|
|
73
|
+
#log li > button:hover { background: #2e2e33; }
|
|
74
|
+
#log time { flex: none; color: #71717a; }
|
|
75
|
+
#log .label { flex: none; min-width: 4ch; color: #a1a1aa; }
|
|
76
|
+
#log .text { min-width: 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
|
|
77
|
+
#log li.open .text { display: block; white-space: pre-wrap; }
|
|
78
|
+
#log pre { margin: 0; padding: 2px 8px 8px calc(8px + 6ch + 8px); color: #a1a1aa; font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
79
|
+
#log.no-console li.console, #log.no-network li.network, #log.only-bad li:not(.bad) { display: none; }
|
|
80
|
+
#main .rr-player .rr-progress .bad-mark { position: absolute; top: -3px; width: 3px; height: 10px; margin-left: -1px; border-radius: 1px; background: #f87171; pointer-events: none; }
|
|
36
81
|
body.embed #main .rr-player { box-shadow: none; border-radius: 0; }
|
|
37
82
|
#marks { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 3; }
|
|
38
83
|
#marks svg { position: absolute; left: 0; top: 0; overflow: visible; }
|
|
@@ -61,16 +106,36 @@ export const REPLAY = `<!doctype html>
|
|
|
61
106
|
<strong>Recording</strong>
|
|
62
107
|
<a id="page" target="_blank" rel="noreferrer"></a>
|
|
63
108
|
</header>
|
|
64
|
-
<
|
|
65
|
-
<
|
|
109
|
+
<div id="stage">
|
|
110
|
+
<main id="main"></main>
|
|
111
|
+
<aside id="log" aria-label="Console and network">
|
|
112
|
+
<div class="filters">
|
|
113
|
+
<button type="button" data-hides="no-console" aria-pressed="true">Console</button>
|
|
114
|
+
<button type="button" data-hides="no-network" aria-pressed="true">Network</button>
|
|
115
|
+
<button type="button" data-shows="only-bad" aria-pressed="false" title="Errors, and requests that failed">Problems</button>
|
|
116
|
+
</div>
|
|
117
|
+
<ol></ol>
|
|
118
|
+
</aside>
|
|
119
|
+
</div>
|
|
120
|
+
<script src="${player}/player.js"></script>${
|
|
121
|
+
source === undefined
|
|
122
|
+
? ''
|
|
123
|
+
: `
|
|
124
|
+
<script src="${source}"></script>`
|
|
125
|
+
}
|
|
66
126
|
<script>
|
|
67
127
|
const params = new URLSearchParams(location.search);
|
|
68
128
|
const bare = params.has('bare');
|
|
69
129
|
const embed = params.has('embed');
|
|
70
130
|
if (bare) document.body.classList.add('bare');
|
|
71
131
|
if (embed) document.body.classList.add('embed');
|
|
72
|
-
const id = location.pathname.split('/').at(-1);
|
|
73
|
-
|
|
132
|
+
const id = params.get('id') ?? location.pathname.split('/').at(-1);
|
|
133
|
+
// The plugin's routes, unless the page was given a source of its own (\`replayPage\`).
|
|
134
|
+
const from = globalThis.deicticReplay ?? {
|
|
135
|
+
recording: (id) => fetch('../recording/' + id).then((r) => (r.ok ? r.json() : r.text().then((t) => Promise.reject(new Error(t))))),
|
|
136
|
+
clip: (id) => '../../voice/clip/' + id,
|
|
137
|
+
};
|
|
138
|
+
Promise.resolve(from.recording(id)).then(async (kept) => {
|
|
74
139
|
const scheme = kept.colorScheme ?? 'light';
|
|
75
140
|
const events = JSON.parse(
|
|
76
141
|
JSON.stringify(kept.events).replace(/\\(\\s*prefers-color-scheme\\s*:\\s*(light|dark)\\s*\\)/g, (_, s) =>
|
|
@@ -80,15 +145,55 @@ export const REPLAY = `<!doctype html>
|
|
|
80
145
|
page.textContent = kept.page;
|
|
81
146
|
page.href = kept.page;
|
|
82
147
|
|
|
148
|
+
// What the page logged and asked for, where the recording has it (rrweb's console and network plugins' events):
|
|
149
|
+
// a row each, in their order, beside the replay. Not in a bare one, which is the page alone.
|
|
150
|
+
const t0 = events[0].timestamp;
|
|
151
|
+
const clock = (ms) => { const s = Math.max(0, ms) / 1000; return Math.floor(s / 60) + ':' + (s % 60).toFixed(1).padStart(4, '0'); };
|
|
152
|
+
// An argument is kept as JSON: a string reads better without its quotes.
|
|
153
|
+
const plain = (arg) => { try { const v = JSON.parse(arg); return typeof v === 'string' ? v : arg; } catch { return arg; } };
|
|
154
|
+
const origin = (() => { try { return new URL(kept.page).origin; } catch { return ''; } })();
|
|
155
|
+
const fields = (title, held) => (held && Object.keys(held).length > 0 ? [title, ...Object.entries(held).map(([k, v]) => ' ' + k + ': ' + v)] : []);
|
|
156
|
+
const rows = [];
|
|
157
|
+
for (const e of events) {
|
|
158
|
+
if (e.type !== 6 || bare) continue;
|
|
159
|
+
const at = e.timestamp - t0;
|
|
160
|
+
if (e.data.plugin === 'rrweb/console@1') {
|
|
161
|
+
const { level, payload = [], trace = [] } = e.data.payload;
|
|
162
|
+
rows.push({ at, kind: 'console', label: level, bad: level === 'error' || level === 'assert', warn: level === 'warn', text: payload.map(plain).join(' '), more: trace.map((l) => 'at ' + l) });
|
|
163
|
+
}
|
|
164
|
+
if (e.data.plugin === 'rrweb/network@1') {
|
|
165
|
+
for (const r of e.data.payload.requests ?? []) {
|
|
166
|
+
// The page's own origin goes without saying.
|
|
167
|
+
let name = r.name;
|
|
168
|
+
try { const u = new URL(r.name); if (u.origin === origin) name = u.pathname + u.search + u.hash; } catch {}
|
|
169
|
+
const more = [
|
|
170
|
+
r.name,
|
|
171
|
+
[r.initiatorType, Number.isFinite(r.duration) ? Math.round(r.duration) + ' ms' : '', e.data.payload.isInitial ? 'as the page loaded' : ''].filter(Boolean).join(' · '),
|
|
172
|
+
...fields('Request headers', r.requestHeaders),
|
|
173
|
+
...(r.requestBody ? ['Request body', ' ' + r.requestBody] : []),
|
|
174
|
+
...fields('Response headers', r.responseHeaders),
|
|
175
|
+
...(r.responseBody ? ['Response body', ' ' + r.responseBody] : []),
|
|
176
|
+
];
|
|
177
|
+
// No status is one the browser won't say (another origin's), not one that failed.
|
|
178
|
+
rows.push({ at, kind: 'network', label: r.status ? String(r.status) : '···', bad: r.status >= 400, text: (r.method ? r.method + ' ' : '') + name, more });
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
const logged = rows.length > 0;
|
|
183
|
+
const log = document.getElementById('log');
|
|
184
|
+
if (logged) document.body.classList.add('logged');
|
|
185
|
+
// The panel's room, where the window is wide enough to show it (as the stylesheet has it).
|
|
186
|
+
const side = () => (logged && innerWidth >= 900 ? 340 : 0);
|
|
187
|
+
|
|
83
188
|
// A recording with the mic starts paused: a browser plays sound only after a click, which Play is.
|
|
84
|
-
const clips = (kept.voice ?? []).map((c) => ({ ...c, audio: Object.assign(new Audio(
|
|
189
|
+
const clips = await Promise.all((kept.voice ?? []).map(async (c) => ({ ...c, audio: Object.assign(new Audio(await from.clip(c.id)), { preload: 'auto' }) })));
|
|
85
190
|
const t = Number.parseFloat(params.get('t') ?? '');
|
|
86
191
|
// The player's frame, at most the window's room, the controls (80px) under it; 1:1 when bare.
|
|
87
192
|
const size = () => bare
|
|
88
193
|
? { width: kept.viewport.width, height: kept.viewport.height }
|
|
89
194
|
: embed
|
|
90
|
-
? { width: innerWidth, height: innerHeight - 80 }
|
|
91
|
-
: { width: Math.min(kept.viewport.width, innerWidth - 32), height: Math.min(kept.viewport.height, innerHeight - 90 - 80 - 16) };
|
|
195
|
+
? { width: innerWidth - side(), height: innerHeight - 80 }
|
|
196
|
+
: { width: Math.min(kept.viewport.width, innerWidth - 32 - side()), height: Math.min(kept.viewport.height, innerHeight - 90 - 80 - 16) };
|
|
92
197
|
const Player = rrwebPlayer.default ?? rrwebPlayer.Player ?? rrwebPlayer;
|
|
93
198
|
const player = new Player({
|
|
94
199
|
target: main,
|
|
@@ -101,6 +206,9 @@ export const REPLAY = `<!doctype html>
|
|
|
101
206
|
tags: { ${JSON.stringify(MARKS)}: '#12b358' },
|
|
102
207
|
inactiveColor: '#3f3f46',
|
|
103
208
|
mouseTail: false,
|
|
209
|
+
// A recorded canvas is drawn by rrweb's own script in the replay's frame, which then must run scripts
|
|
210
|
+
// (the page's own were never recorded): only for a recording that has one.
|
|
211
|
+
...(events.some((e) => e.type === 3 && e.data.source === 9) ? { UNSAFE_replayCanvas: true } : {}),
|
|
104
212
|
},
|
|
105
213
|
});
|
|
106
214
|
addEventListener('resize', () => { player.$set(size()); player.triggerResize(); });
|
|
@@ -114,10 +222,51 @@ export const REPLAY = `<!doctype html>
|
|
|
114
222
|
|
|
115
223
|
let playing = false;
|
|
116
224
|
player.addEventListener('ui-update-player-state', (e) => { playing = e.payload === 'playing'; });
|
|
225
|
+
|
|
226
|
+
// The rows: a click goes to its moment, and shows the rest of it (where a line was logged from, a request's
|
|
227
|
+
// headers and bodies). All set as text: it's the recorded page's, not ours.
|
|
228
|
+
const list = log.querySelector('ol');
|
|
229
|
+
const bar = main.querySelector('.rr-progress');
|
|
230
|
+
for (const row of rows) {
|
|
231
|
+
const cell = (tag, name, text) => Object.assign(document.createElement(tag), { className: name, textContent: text });
|
|
232
|
+
const go = Object.assign(document.createElement('button'), { type: 'button' });
|
|
233
|
+
go.append(cell('time', '', clock(row.at)), cell('span', 'label', row.label), cell('span', 'text', row.text));
|
|
234
|
+
const more = Object.assign(cell('pre', '', row.more.join('\\n')), { hidden: true });
|
|
235
|
+
row.el = Object.assign(document.createElement('li'), { className: row.kind + (row.bad ? ' bad' : row.warn ? ' warn' : '') });
|
|
236
|
+
go.addEventListener('click', () => {
|
|
237
|
+
player.goto(Math.min(row.at, total), playing);
|
|
238
|
+
more.hidden = !more.hidden || row.more.length === 0;
|
|
239
|
+
row.el.classList.toggle('open', !more.hidden);
|
|
240
|
+
});
|
|
241
|
+
row.el.append(go, more);
|
|
242
|
+
list.append(row.el);
|
|
243
|
+
// An error, or a request that failed, is a mark on the timeline too.
|
|
244
|
+
if (row.bad && bar) bar.append(Object.assign(cell('i', 'bad-mark', ''), { title: row.text.slice(0, 200), style: 'left:' + (total > 0 ? (row.at / total) * 100 : 0) + '%' }));
|
|
245
|
+
}
|
|
246
|
+
for (const button of log.querySelectorAll('.filters button')) {
|
|
247
|
+
button.addEventListener('click', () => {
|
|
248
|
+
const on = button.getAttribute('aria-pressed') !== 'true';
|
|
249
|
+
button.setAttribute('aria-pressed', String(on));
|
|
250
|
+
if (button.dataset.hides) log.classList.toggle(button.dataset.hides, !on);
|
|
251
|
+
if (button.dataset.shows) log.classList.toggle(button.dataset.shows, on);
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
// The row the replay is at: the last whose moment has come, lit, the ones to come faint, kept in sight unless
|
|
255
|
+
// the list is being read.
|
|
256
|
+
let lit;
|
|
257
|
+
const light = (now) => {
|
|
258
|
+
let i = -1;
|
|
259
|
+
while (i + 1 < rows.length && rows[i + 1].at <= now) i++;
|
|
260
|
+
if (i === lit) return;
|
|
261
|
+
lit = i;
|
|
262
|
+
rows.forEach((row, k) => { row.el.classList.toggle('ahead', k > i); row.el.classList.toggle('now', k === i); });
|
|
263
|
+
if (i >= 0 && !log.matches(':hover')) rows[i].el.scrollIntoView({ block: 'nearest' });
|
|
264
|
+
};
|
|
117
265
|
const follow = () => {
|
|
118
266
|
const win = replayer.iframe.contentWindow;
|
|
119
267
|
if (win) marks.style.transform = 'translate(' + -win.scrollX + 'px,' + -win.scrollY + 'px)';
|
|
120
268
|
const now = Math.min(replayer.getCurrentTime(), total);
|
|
269
|
+
light(now);
|
|
121
270
|
const speed = replayer.config.speed ?? 1;
|
|
122
271
|
// Each clip plays while the replay is inside it, at its speed, kept within a few frames of the replay's time.
|
|
123
272
|
for (const c of clips) {
|
|
@@ -33,6 +33,36 @@ export function boxOf(element: Element, area: NonNullable<CaptureOptions['area']
|
|
|
33
33
|
return area === 'element' ? { x: 0, y: 0, width, height } : { x, y, width, height };
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
const BLANK = '#d4d4d8';
|
|
37
|
+
|
|
38
|
+
const selector = (className: string, extra: string | undefined) => [`.${CSS.escape(className)}`, ...(extra ? [extra] : [])].join(', ');
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Hides in a copy of the page's what rrweb would: blocked elements become a blank box their size (the copy keeps each
|
|
42
|
+
* element's size as its styles), masked text keeps its spaces but shows `*`, and so do passwords' values,
|
|
43
|
+
* or every field's.
|
|
44
|
+
*/
|
|
45
|
+
export function mask(copy: Node, m: ResolvedMasking): void {
|
|
46
|
+
if (!(copy instanceof Element)) return;
|
|
47
|
+
const all = (sel: string) => [...(copy.matches(sel) ? [copy] : []), ...copy.querySelectorAll(sel)];
|
|
48
|
+
const stars = (text: string) => text.replace(/\S/g, '*');
|
|
49
|
+
for (const el of all(selector(m.blockClass, m.blockSelector))) {
|
|
50
|
+
el.replaceChildren();
|
|
51
|
+
if (el instanceof HTMLElement || el instanceof SVGElement) el.style.background = BLANK;
|
|
52
|
+
}
|
|
53
|
+
for (const el of all(selector(m.maskTextClass, m.maskTextSelector))) {
|
|
54
|
+
const walker = document.createTreeWalker(el, NodeFilter.SHOW_TEXT);
|
|
55
|
+
for (let text = walker.nextNode(); text !== null; text = walker.nextNode()) text.textContent = stars(text.textContent ?? '');
|
|
56
|
+
}
|
|
57
|
+
for (const field of all('input, textarea')) {
|
|
58
|
+
if (!(field instanceof HTMLInputElement || field instanceof HTMLTextAreaElement)) continue;
|
|
59
|
+
if (!m.maskAllInputs && !(field instanceof HTMLInputElement && field.type === 'password')) continue;
|
|
60
|
+
field.value = stars(field.value);
|
|
61
|
+
field.setAttribute('value', field.value);
|
|
62
|
+
if (field instanceof HTMLTextAreaElement) field.textContent = field.value;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
36
66
|
export function screenshotsClient(capture: PageCapture) {
|
|
37
67
|
return defineClientPlugin<never, never, Capture>({
|
|
38
68
|
name: 'screenshots',
|
|
@@ -45,9 +75,10 @@ export function screenshotsClient(capture: PageCapture) {
|
|
|
45
75
|
};
|
|
46
76
|
const add = async (body: Blob | string, type: string, { box, size }: Pick<Shot, 'box' | 'size'>): Promise<Shot> => {
|
|
47
77
|
const res = await request('add', { method: 'POST', headers: { 'content-type': type }, body });
|
|
48
|
-
|
|
78
|
+
// `url`: where the shot is, said by what keeps it with no server to serve it from (a `standalone` build).
|
|
79
|
+
const { id, url, problem } = (await res.json()) as { id?: string; url?: string; problem?: string };
|
|
49
80
|
if (id === undefined) throw new Error(`screenshots: ${problem ?? res.statusText}`);
|
|
50
|
-
return { id, url: `${base}__deictic/plugins/screenshots/shot/${id}`, box, size };
|
|
81
|
+
return { id, url: url ?? `${base}__deictic/plugins/screenshots/shot/${id}`, box, size };
|
|
51
82
|
};
|
|
52
83
|
return {
|
|
53
84
|
capture: async (element, { area = 'viewport' } = {}) => {
|
|
@@ -57,6 +88,11 @@ export function screenshotsClient(capture: PageCapture) {
|
|
|
57
88
|
return add(body, type, { box, size });
|
|
58
89
|
},
|
|
59
90
|
upload: (png, of) => add(png, 'image/png', of),
|
|
91
|
+
masked: (element) => {
|
|
92
|
+
const copy = element.cloneNode(true) as Element;
|
|
93
|
+
mask(copy, masking);
|
|
94
|
+
return copy;
|
|
95
|
+
},
|
|
60
96
|
};
|
|
61
97
|
},
|
|
62
98
|
});
|
|
@@ -3,38 +3,7 @@
|
|
|
3
3
|
* (imported on the first shot), so it needs no server, but text may lay out a little differently than
|
|
4
4
|
* the page's. Masking changes only the copy that's drawn, never the page.
|
|
5
5
|
*/
|
|
6
|
-
import { boxOf, notOurs, screenshotsClient } from './client.ts';
|
|
7
|
-
import type { ResolvedMasking } from './index.ts';
|
|
8
|
-
|
|
9
|
-
const BLANK = '#d4d4d8';
|
|
10
|
-
|
|
11
|
-
const selector = (className: string, extra: string | undefined) => [`.${CSS.escape(className)}`, ...(extra ? [extra] : [])].join(', ');
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Hides in the copy what rrweb would: blocked elements become a blank box their size (the copy keeps each
|
|
15
|
-
* element's size as its styles), masked text keeps its spaces but shows `*`, and so do passwords' values,
|
|
16
|
-
* or every field's.
|
|
17
|
-
*/
|
|
18
|
-
function mask(copy: Node, m: ResolvedMasking): void {
|
|
19
|
-
if (!(copy instanceof Element)) return;
|
|
20
|
-
const all = (sel: string) => [...(copy.matches(sel) ? [copy] : []), ...copy.querySelectorAll(sel)];
|
|
21
|
-
const stars = (text: string) => text.replace(/\S/g, '*');
|
|
22
|
-
for (const el of all(selector(m.blockClass, m.blockSelector))) {
|
|
23
|
-
el.replaceChildren();
|
|
24
|
-
if (el instanceof HTMLElement || el instanceof SVGElement) el.style.background = BLANK;
|
|
25
|
-
}
|
|
26
|
-
for (const el of all(selector(m.maskTextClass, m.maskTextSelector))) {
|
|
27
|
-
const walker = document.createTreeWalker(el, NodeFilter.SHOW_TEXT);
|
|
28
|
-
for (let text = walker.nextNode(); text !== null; text = walker.nextNode()) text.textContent = stars(text.textContent ?? '');
|
|
29
|
-
}
|
|
30
|
-
for (const field of all('input, textarea')) {
|
|
31
|
-
if (!(field instanceof HTMLInputElement || field instanceof HTMLTextAreaElement)) continue;
|
|
32
|
-
if (!m.maskAllInputs && !(field instanceof HTMLInputElement && field.type === 'password')) continue;
|
|
33
|
-
field.value = stars(field.value);
|
|
34
|
-
field.setAttribute('value', field.value);
|
|
35
|
-
if (field instanceof HTMLTextAreaElement) field.textContent = field.value;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
6
|
+
import { boxOf, mask, notOurs, screenshotsClient } from './client.ts';
|
|
38
7
|
|
|
39
8
|
/** Draws an SVG over the whole canvas, which is the area it was made for at the canvas's scale. */
|
|
40
9
|
async function drawOver(canvas: HTMLCanvasElement, svg: string | undefined): Promise<HTMLCanvasElement> {
|
|
@@ -46,6 +46,8 @@ export interface Capture {
|
|
|
46
46
|
capture(element: Element, options?: CaptureOptions): Promise<Shot>;
|
|
47
47
|
/** Keeps a PNG made of a shot (the same one with marks drawn over it, say) as a shot of its own. */
|
|
48
48
|
upload(png: Blob, of: Pick<Shot, 'box' | 'size'>): Promise<Shot>;
|
|
49
|
+
/** A copy of an element with what a shot hides hidden in it too: for a plugin that sends its HTML somewhere. */
|
|
50
|
+
masked(element: Element): Element;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
/** The server's half, for other plugins' server halves. */
|
|
@@ -6,6 +6,11 @@
|
|
|
6
6
|
* The snapshot is rebuilt into a sandboxed iframe filling a blank page on the page's own origin, which
|
|
7
7
|
* Playwright answers itself, so nothing asks the dev server for it: rrweb has made the snapshot's URLs
|
|
8
8
|
* whole, and its stylesheets' fonts and images load from the dev server as the page's did.
|
|
9
|
+
*
|
|
10
|
+
* The browser is as big as the page's window, scrollbars and all, and shows its own: a media query asks the
|
|
11
|
+
* window's width, and the page is laid out in what the scrollbar leaves. At the width without it, a window
|
|
12
|
+
* right on a breakpoint (1024 wide, 1009 to lay out in) would render as the narrower layout. The shot is then
|
|
13
|
+
* cut to the part the page is in.
|
|
9
14
|
*/
|
|
10
15
|
import { createRequire } from 'node:module';
|
|
11
16
|
|
|
@@ -22,6 +27,8 @@ export interface Snapshot {
|
|
|
22
27
|
snapshot: SnapshotNode;
|
|
23
28
|
url: string;
|
|
24
29
|
viewport: { width: number; height: number };
|
|
30
|
+
/** The window's size, scrollbars included, where it has any: what the page's media queries ask. */
|
|
31
|
+
window?: { width: number; height: number };
|
|
25
32
|
scroll: { x: number; y: number };
|
|
26
33
|
scale: number;
|
|
27
34
|
/** The part of the viewport to keep, for a shot of an element alone. */
|
|
@@ -46,15 +53,18 @@ export function browserOf(options: BrowserOptions): Promise<Browser> {
|
|
|
46
53
|
return launched;
|
|
47
54
|
}
|
|
48
55
|
|
|
56
|
+
/** Playwright hides a headless browser's scrollbars, and with them the room they take in the page. */
|
|
57
|
+
const SCROLLBARS = { ignoreDefaultArgs: ['--hide-scrollbars'] };
|
|
58
|
+
|
|
49
59
|
async function launch({ executablePath, channel }: BrowserOptions): Promise<Browser> {
|
|
50
60
|
const { chromium } = await import('playwright-core').catch((e: unknown) => {
|
|
51
61
|
throw new Error('the rrweb() renderer needs playwright-core: add it to your devDependencies', { cause: e });
|
|
52
62
|
});
|
|
53
|
-
if (executablePath !== undefined || channel !== undefined) return chromium.launch({ executablePath, channel });
|
|
63
|
+
if (executablePath !== undefined || channel !== undefined) return chromium.launch({ executablePath, channel, ...SCROLLBARS });
|
|
54
64
|
const tried: string[] = [];
|
|
55
65
|
for (const attempt of [{}, { channel: 'chrome' }, { channel: 'msedge' }]) {
|
|
56
66
|
try {
|
|
57
|
-
return await chromium.launch(attempt);
|
|
67
|
+
return await chromium.launch({ ...attempt, ...SCROLLBARS });
|
|
58
68
|
} catch (e) {
|
|
59
69
|
tried.push(
|
|
60
70
|
`${'channel' in attempt ? attempt.channel : "Playwright's Chromium"}: ${(e instanceof Error ? e.message : String(e)).split('\n', 1)[0]}`,
|
|
@@ -74,7 +84,7 @@ export async function render(input: unknown, options: BrowserOptions): Promise<U
|
|
|
74
84
|
if (typeof shot?.url !== 'string' || typeof shot.snapshot !== 'object' || typeof shot.viewport?.width !== 'number')
|
|
75
85
|
throw new Error('screenshots: that is not a snapshot the rrweb() renderer took');
|
|
76
86
|
const browser = await browserOf(options);
|
|
77
|
-
const context = await browser.newContext({ viewport: shot.viewport, deviceScaleFactor: shot.scale });
|
|
87
|
+
const context = await browser.newContext({ viewport: shot.window ?? shot.viewport, deviceScaleFactor: shot.scale });
|
|
78
88
|
try {
|
|
79
89
|
const page = await context.newPage();
|
|
80
90
|
const host = new URL('/__deictic/plugins/screenshots/host', shot.url).href;
|
|
@@ -102,7 +112,8 @@ export async function render(input: unknown, options: BrowserOptions): Promise<U
|
|
|
102
112
|
marks.innerHTML = overlay;
|
|
103
113
|
document.body.append(marks);
|
|
104
114
|
}, shot);
|
|
105
|
-
|
|
115
|
+
// Without the scrollbars: a shot is what the page is drawn in, which is what an element's box is from.
|
|
116
|
+
const clip = clamp(shot.clip ?? { x: 0, y: 0, ...shot.viewport }, shot.viewport);
|
|
106
117
|
return new Uint8Array(await page.screenshot({ type: 'png', ...(clip === undefined ? {} : { clip }) }));
|
|
107
118
|
} finally {
|
|
108
119
|
await context.close();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The `rrweb()` renderer's page half: a snapshot of the page's DOM with `rrweb-snapshot` (imported on the
|
|
3
3
|
* first shot), masked as rrweb masks, without deictic's overlay, sent with what the server's browser needs
|
|
4
|
-
* to show it as the page does: the viewport, where it's scrolled to, the pixel density, the page's URL.
|
|
4
|
+
* 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.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { boxOf, screenshotsClient } from './client.ts';
|
|
@@ -35,6 +35,7 @@ export default screenshotsClient(async (element, { area, masking, overlay }) =>
|
|
|
35
35
|
snapshot: withoutOurs(taken),
|
|
36
36
|
url: location.href,
|
|
37
37
|
viewport,
|
|
38
|
+
window: { width: innerWidth, height: innerHeight },
|
|
38
39
|
...(marks === undefined ? {} : { overlay: marks }),
|
|
39
40
|
scroll: { x: scrollX, y: scrollY },
|
|
40
41
|
scale: Math.min(devicePixelRatio, 2),
|