screw-bugs 0.1.9 → 0.1.10
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/README.md +49 -34
- package/dist/browser-playwright/capture.js +1 -1
- package/dist/build-info.json +3 -3
- package/dist/cli/app.js +6 -2
- package/dist/cli/commands.js +4 -3
- package/dist/cli/doctor.d.ts +17 -2
- package/dist/cli/doctor.js +62 -4
- package/dist/cli/mcp.js +2 -2
- package/dist/cli/report-server.d.ts +19 -10
- package/dist/cli/report-server.js +43 -18
- package/dist/cli/share.js +2 -2
- package/dist/cli/sign-in.d.ts +9 -3
- package/dist/cli/sign-in.js +12 -9
- package/dist/cli/tailnet.d.ts +57 -0
- package/dist/cli/tailnet.js +82 -0
- package/dist/core/index.d.ts +1 -14
- package/dist/core/index.js +3 -14
- package/dist/report/index.d.ts +1 -10
- package/dist/report/index.js +3 -10
- package/dist/schema/index.d.ts +1 -9
- package/dist/schema/index.js +3 -9
- package/package.json +14 -14
- package/dist/core/accounts.d.ts +0 -40
- package/dist/core/accounts.js +0 -95
- package/dist/core/css.d.ts +0 -95
- package/dist/core/css.js +0 -436
- package/dist/core/engine.d.ts +0 -75
- package/dist/core/engine.js +0 -560
- package/dist/core/errors.d.ts +0 -85
- package/dist/core/errors.js +0 -36
- package/dist/core/evidence.d.ts +0 -14
- package/dist/core/evidence.js +0 -131
- package/dist/core/labels.d.ts +0 -47
- package/dist/core/labels.js +0 -199
- package/dist/core/liveness.d.ts +0 -45
- package/dist/core/liveness.js +0 -66
- package/dist/core/marks.d.ts +0 -63
- package/dist/core/marks.js +0 -410
- package/dist/core/services.d.ts +0 -579
- package/dist/core/services.js +0 -25
- package/dist/core/share.d.ts +0 -68
- package/dist/core/share.js +0 -318
- package/dist/core/steps.d.ts +0 -106
- package/dist/core/steps.js +0 -722
- package/dist/core/uploads.d.ts +0 -49
- package/dist/core/uploads.js +0 -133
- package/dist/core/video.d.ts +0 -53
- package/dist/core/video.js +0 -241
- package/dist/core/viewport.d.ts +0 -28
- package/dist/core/viewport.js +0 -50
- package/dist/report/assets.d.ts +0 -34
- package/dist/report/assets.js +0 -105
- package/dist/report/bug.d.ts +0 -11
- package/dist/report/bug.js +0 -20
- package/dist/report/html.d.ts +0 -47
- package/dist/report/html.js +0 -923
- package/dist/report/icons.d.ts +0 -51
- package/dist/report/icons.js +0 -93
- package/dist/report/live.d.ts +0 -7
- package/dist/report/live.js +0 -135
- package/dist/report/logos.d.ts +0 -4
- package/dist/report/logos.js +0 -19
- package/dist/report/markup.d.ts +0 -50
- package/dist/report/markup.js +0 -156
- package/dist/report/menu-bar.d.ts +0 -60
- package/dist/report/menu-bar.js +0 -157
- package/dist/report/player.d.ts +0 -102
- package/dist/report/player.js +0 -315
- package/dist/report/pr-summary.d.ts +0 -11
- package/dist/report/pr-summary.js +0 -119
- package/dist/report/sha256.d.ts +0 -9
- package/dist/report/sha256.js +0 -97
- package/dist/report/share-page.d.ts +0 -48
- package/dist/report/share-page.js +0 -291
- package/dist/report/shots.d.ts +0 -59
- package/dist/report/shots.js +0 -280
- package/dist/report/sign-in.d.ts +0 -41
- package/dist/report/sign-in.js +0 -568
- package/dist/report/styles.d.ts +0 -3
- package/dist/report/styles.js +0 -274
- package/dist/report/view.d.ts +0 -296
- package/dist/report/view.js +0 -702
- package/dist/report/walkthrough.d.ts +0 -93
- package/dist/report/walkthrough.js +0 -716
- package/dist/schema/accounts.d.ts +0 -137
- package/dist/schema/accounts.js +0 -121
- package/dist/schema/config.d.ts +0 -7
- package/dist/schema/config.js +0 -6
- package/dist/schema/doctor.d.ts +0 -46
- package/dist/schema/doctor.js +0 -30
- package/dist/schema/evidence.d.ts +0 -1115
- package/dist/schema/evidence.js +0 -565
- package/dist/schema/findings.d.ts +0 -161
- package/dist/schema/findings.js +0 -82
- package/dist/schema/job.d.ts +0 -1905
- package/dist/schema/job.js +0 -577
- package/dist/schema/ledger.d.ts +0 -1124
- package/dist/schema/ledger.js +0 -285
- package/dist/schema/share.d.ts +0 -55
- package/dist/schema/share.js +0 -64
- package/dist/schema/status.d.ts +0 -7
- package/dist/schema/status.js +0 -11
package/dist/report/sign-in.js
DELETED
|
@@ -1,568 +0,0 @@
|
|
|
1
|
-
import { favicon, html, icon as icon_, Markup, webFonts } from './markup.js';
|
|
2
|
-
import { githubLink, menuBar, THEME_BUTTON_JS, themeButton } from './menu-bar.js';
|
|
3
|
-
import { styles } from './styles.js';
|
|
4
|
-
import { cspHash } from './sha256.js';
|
|
5
|
-
/*
|
|
6
|
-
* The live view: a page a person opens (in any browser that reaches the sign-in server, a phone
|
|
7
|
-
* on the tailnet included) to drive the headless browser screw-bugs signs in with. It shows the
|
|
8
|
-
* browser's frames and sends the person's pointer, wheel, keys and text back. Plain browser code:
|
|
9
|
-
* the script is a fixed string, allowed by its hash alone; the page's values come as data
|
|
10
|
-
* attributes. Nothing typed is kept by the page or the server; only the session is saved, when
|
|
11
|
-
* the person presses Save.
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* Rive's web runtime (its canvas renderer without text and audio, which the animation does not
|
|
15
|
-
* use), on jsDelivr at an exact version: the script, taken only with `RIVE_JS_SRI`, and its
|
|
16
|
-
* WebAssembly, which the script fetches.
|
|
17
|
-
*/
|
|
18
|
-
export const RIVE_RUNTIME = 'https://cdn.jsdelivr.net/npm/@rive-app/canvas-lite@2.48.0/';
|
|
19
|
-
/** The runtime script's Subresource Integrity hash: any other script at that URL is refused. */
|
|
20
|
-
export const RIVE_JS_SRI = 'sha384-KKLeoe6TCJ0x8AYfmSeeOfpT6u1rpxnG6clu8dKuLNqMImJV40kWrCVhTU7lmcNg';
|
|
21
|
-
/**
|
|
22
|
-
* The animation the page plays (the bug kicks a lock open when the person starts), on screw-bugs'
|
|
23
|
-
* CDN, which allows any page to fetch it. The page is the same without it when it cannot load.
|
|
24
|
-
*/
|
|
25
|
-
export const SIGN_IN_ANIMATION = 'https://static.screwbugs.dev/animations/auth-required.riv';
|
|
26
|
-
/**
|
|
27
|
-
* The script of the live view, with no values of its own (they are data attributes), so its
|
|
28
|
-
* hash is fixed. Frames come by long polling `frame?after=<seq>`; inputs go out in order, one
|
|
29
|
-
* request at a time, mouse moves merged. `410` from any route means the sign-in ended.
|
|
30
|
-
*/
|
|
31
|
-
export const SIGN_IN_SCRIPT = /* js */ `(() => {
|
|
32
|
-
'use strict';
|
|
33
|
-
const RIVE = '${RIVE_RUNTIME}', RIVE_JS_SRI = '${RIVE_JS_SRI}', ANIMATION = '${SIGN_IN_ANIMATION}';
|
|
34
|
-
// The animation's state while the bug waits by the lock (its \`kick\` trigger works only then),
|
|
35
|
-
// and how long after the kick the bug has run off, when the browser shows (at most
|
|
36
|
-
// \`KICK_WAIT_MAX\` after the person started, however long the bug took to reach the lock).
|
|
37
|
-
const WAITING = 'Wait (idle)', KICK_MS = 2300, KICK_WAIT_MAX = 6000;
|
|
38
|
-
const base = location.pathname.replace(/\\/+$/, '');
|
|
39
|
-
const $ = (id) => document.getElementById(id);
|
|
40
|
-
const img = $('screen'), stage = $('stage'), kb = $('keys'), addr = $('addr'), note = $('note');
|
|
41
|
-
let seq = 0, fw = 1280, fh = 800, over = false, saving = false;
|
|
42
|
-
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
43
|
-
|
|
44
|
-
const end = (text) => {
|
|
45
|
-
over = true;
|
|
46
|
-
document.body.classList.add('over');
|
|
47
|
-
note.textContent = text;
|
|
48
|
-
$('ended').textContent = text;
|
|
49
|
-
};
|
|
50
|
-
const GONE = 'This sign-in has ended (it closes after 15 minutes without use), so nothing was saved. Ask your coding agent to start its job again for a new link.';
|
|
51
|
-
|
|
52
|
-
const queue = [];
|
|
53
|
-
// Inputs per request: under the server's limit (100, and 256 KB with text of up to 2000).
|
|
54
|
-
const BATCH = 50;
|
|
55
|
-
let sending = false;
|
|
56
|
-
// Whether an input may not have reached the browser: Save then asks to check the page first.
|
|
57
|
-
let lost = false;
|
|
58
|
-
const flush = async () => {
|
|
59
|
-
if (sending || over || queue.length === 0) return;
|
|
60
|
-
sending = true;
|
|
61
|
-
const batch = queue.splice(0, BATCH);
|
|
62
|
-
try {
|
|
63
|
-
const r = await fetch(base + '/input', {
|
|
64
|
-
method: 'POST',
|
|
65
|
-
headers: { 'content-type': 'application/json' },
|
|
66
|
-
body: JSON.stringify(batch),
|
|
67
|
-
});
|
|
68
|
-
if (r.status === 410) end('This sign-in has ended. You can close this tab.');
|
|
69
|
-
else if (!r.ok) lost = true;
|
|
70
|
-
} catch {
|
|
71
|
-
// It may or may not have been played; sending it again could type twice.
|
|
72
|
-
lost = true;
|
|
73
|
-
await sleep(500);
|
|
74
|
-
}
|
|
75
|
-
if (lost && !over) note.textContent = 'Some input may not have reached the browser; check the page shows what you expect.';
|
|
76
|
-
sending = false;
|
|
77
|
-
flush();
|
|
78
|
-
};
|
|
79
|
-
const send = (input) => {
|
|
80
|
-
// Nothing more goes in once Save was pressed: the session is what the inputs before it made.
|
|
81
|
-
if (saving || over) return;
|
|
82
|
-
const last = queue[queue.length - 1];
|
|
83
|
-
if (input.type === 'mouse' && input.kind === 'move' && last && last.type === 'mouse' && last.kind === 'move') queue[queue.length - 1] = input;
|
|
84
|
-
else queue.push(input);
|
|
85
|
-
flush();
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const frames = async () => {
|
|
89
|
-
let failures = 0;
|
|
90
|
-
while (!over) {
|
|
91
|
-
try {
|
|
92
|
-
const r = await fetch(base + '/frame?after=' + seq, { cache: 'no-store' });
|
|
93
|
-
failures = 0;
|
|
94
|
-
if (r.status === 410) return end('This sign-in has ended. You can close this tab.');
|
|
95
|
-
if (r.status === 200) {
|
|
96
|
-
const f = await r.json();
|
|
97
|
-
seq = f.seq; fw = f.width; fh = f.height;
|
|
98
|
-
img.src = 'data:image/jpeg;base64,' + f.jpeg;
|
|
99
|
-
addr.textContent = f.url;
|
|
100
|
-
} else if (r.status !== 204) await sleep(1000);
|
|
101
|
-
} catch {
|
|
102
|
-
// Its server is gone (it ended, or the agent's process stopped): say so rather than wait.
|
|
103
|
-
if (++failures >= 3) return end(GONE);
|
|
104
|
-
await sleep(1000);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
let sized;
|
|
110
|
-
const resize = () => {
|
|
111
|
-
clearTimeout(sized);
|
|
112
|
-
sized = setTimeout(() => send({ type: 'viewport', width: Math.round(stage.clientWidth), height: Math.round(stage.clientHeight) }), 250);
|
|
113
|
-
};
|
|
114
|
-
addEventListener('resize', resize);
|
|
115
|
-
|
|
116
|
-
const at = (e) => {
|
|
117
|
-
const r = img.getBoundingClientRect();
|
|
118
|
-
return {
|
|
119
|
-
x: Math.round(((e.clientX - r.left) * fw) / Math.max(1, r.width)),
|
|
120
|
-
y: Math.round(((e.clientY - r.top) * fh) / Math.max(1, r.height)),
|
|
121
|
-
};
|
|
122
|
-
};
|
|
123
|
-
const button = (b) => (b === 1 ? 'middle' : b === 2 ? 'right' : 'left');
|
|
124
|
-
let touch;
|
|
125
|
-
img.addEventListener('contextmenu', (e) => e.preventDefault());
|
|
126
|
-
img.addEventListener('pointerdown', (e) => {
|
|
127
|
-
e.preventDefault();
|
|
128
|
-
kb.focus({ preventScroll: true });
|
|
129
|
-
img.setPointerCapture(e.pointerId);
|
|
130
|
-
const p = at(e);
|
|
131
|
-
if (e.pointerType === 'mouse') send({ type: 'mouse', kind: 'down', ...p, button: button(e.button), clickCount: Math.min(3, Math.max(1, e.detail || 1)) });
|
|
132
|
-
else touch = { x: e.clientX, y: e.clientY, moved: false };
|
|
133
|
-
});
|
|
134
|
-
img.addEventListener('pointermove', (e) => {
|
|
135
|
-
const p = at(e);
|
|
136
|
-
if (e.pointerType === 'mouse') return send({ type: 'mouse', kind: 'move', ...p });
|
|
137
|
-
if (!touch) return;
|
|
138
|
-
const dx = e.clientX - touch.x, dy = e.clientY - touch.y;
|
|
139
|
-
if (!touch.moved && Math.hypot(dx, dy) < 8) return;
|
|
140
|
-
touch.moved = true;
|
|
141
|
-
const scale = fw / Math.max(1, img.getBoundingClientRect().width);
|
|
142
|
-
send({ type: 'wheel', ...p, dx: Math.round(-dx * scale), dy: Math.round(-dy * scale) });
|
|
143
|
-
touch.x = e.clientX; touch.y = e.clientY;
|
|
144
|
-
});
|
|
145
|
-
img.addEventListener('pointerup', (e) => {
|
|
146
|
-
const p = at(e);
|
|
147
|
-
if (e.pointerType === 'mouse') return send({ type: 'mouse', kind: 'up', ...p, button: button(e.button), clickCount: Math.min(3, Math.max(1, e.detail || 1)) });
|
|
148
|
-
if (touch && !touch.moved) {
|
|
149
|
-
send({ type: 'mouse', kind: 'move', ...p });
|
|
150
|
-
send({ type: 'mouse', kind: 'down', ...p, button: 'left', clickCount: 1 });
|
|
151
|
-
send({ type: 'mouse', kind: 'up', ...p, button: 'left', clickCount: 1 });
|
|
152
|
-
}
|
|
153
|
-
touch = undefined;
|
|
154
|
-
});
|
|
155
|
-
img.addEventListener('pointercancel', () => { touch = undefined; });
|
|
156
|
-
img.addEventListener('wheel', (e) => {
|
|
157
|
-
e.preventDefault();
|
|
158
|
-
const unit = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? fh : 1;
|
|
159
|
-
send({ type: 'wheel', ...at(e), dx: Math.round(e.deltaX * unit), dy: Math.round(e.deltaY * unit) });
|
|
160
|
-
}, { passive: false });
|
|
161
|
-
|
|
162
|
-
const ignored = new Set(['Shift', 'Control', 'Alt', 'Meta', 'CapsLock', 'Unidentified', 'Dead', 'Process', 'Compose']);
|
|
163
|
-
let composing = false;
|
|
164
|
-
kb.addEventListener('compositionstart', () => { composing = true; });
|
|
165
|
-
kb.addEventListener('compositionend', () => { composing = false; typed(); });
|
|
166
|
-
kb.addEventListener('keydown', (e) => {
|
|
167
|
-
if (e.isComposing || e.keyCode === 229 || ignored.has(e.key)) return;
|
|
168
|
-
// A character typed with AltGr (an @ on many European keyboards, where it also reports Ctrl
|
|
169
|
-
// and Alt) or with Option on a Mac is text, not a shortcut: the box gets it as input.
|
|
170
|
-
const altGraph = e.getModifierState && e.getModifierState('AltGraph');
|
|
171
|
-
if (e.key.length === 1 && (altGraph || (e.altKey && !e.ctrlKey && !e.metaKey))) return;
|
|
172
|
-
const command = e.ctrlKey || e.metaKey || e.altKey;
|
|
173
|
-
// Pasting goes in as text, from the paste itself.
|
|
174
|
-
if (command && e.key.toLowerCase() === 'v') return;
|
|
175
|
-
if (e.key.length === 1 && !command) return;
|
|
176
|
-
e.preventDefault();
|
|
177
|
-
const modifiers = [e.altKey && 'Alt', e.ctrlKey && 'Control', e.metaKey && 'Meta', e.shiftKey && 'Shift'].filter(Boolean);
|
|
178
|
-
send({ type: 'key', key: e.key, modifiers });
|
|
179
|
-
});
|
|
180
|
-
// The box always holds one invisible character, so a phone keyboard's Backspace (often only
|
|
181
|
-
// keyCode 229 or 'Unidentified' on keydown) has something to delete, which shows below.
|
|
182
|
-
const MARK = '\u200b';
|
|
183
|
-
const reset = () => {
|
|
184
|
-
kb.value = MARK;
|
|
185
|
-
kb.setSelectionRange(1, 1);
|
|
186
|
-
};
|
|
187
|
-
const typed = () => {
|
|
188
|
-
if (composing) return;
|
|
189
|
-
const value = kb.value;
|
|
190
|
-
const text = value.split(MARK).join('');
|
|
191
|
-
if (!value.includes(MARK) && !text) send({ type: 'key', key: 'Backspace', modifiers: [] });
|
|
192
|
-
if (text) send({ type: 'text', text: text.slice(0, 2000) });
|
|
193
|
-
reset();
|
|
194
|
-
};
|
|
195
|
-
kb.addEventListener('beforeinput', (e) => {
|
|
196
|
-
// Deleting, as keyboards that send no key for it say it: played as the key itself.
|
|
197
|
-
const key = e.inputType === 'deleteContentBackward' ? 'Backspace' : e.inputType === 'deleteContentForward' ? 'Delete' : undefined;
|
|
198
|
-
if (key === undefined || !e.cancelable) return;
|
|
199
|
-
e.preventDefault();
|
|
200
|
-
send({ type: 'key', key, modifiers: [] });
|
|
201
|
-
});
|
|
202
|
-
kb.addEventListener('input', typed);
|
|
203
|
-
kb.addEventListener('focus', reset);
|
|
204
|
-
reset();
|
|
205
|
-
|
|
206
|
-
$('back').addEventListener('click', () => send({ type: 'nav', kind: 'back' }));
|
|
207
|
-
$('reload').addEventListener('click', () => send({ type: 'nav', kind: 'reload' }));
|
|
208
|
-
const post = async (route) => {
|
|
209
|
-
const r = await fetch(base + '/' + route, { method: 'POST', headers: { 'content-type': 'application/json' }, body: '{}' });
|
|
210
|
-
return r;
|
|
211
|
-
};
|
|
212
|
-
/** Until every input already given has been played (or the sign-in ended). */
|
|
213
|
-
const drained = async () => {
|
|
214
|
-
while (!over && (sending || queue.length > 0)) await sleep(50);
|
|
215
|
-
};
|
|
216
|
-
$('save').addEventListener('click', async () => {
|
|
217
|
-
if (saving || over) return;
|
|
218
|
-
saving = true;
|
|
219
|
-
document.body.classList.add('saving');
|
|
220
|
-
note.textContent = 'Saving…';
|
|
221
|
-
try {
|
|
222
|
-
await drained();
|
|
223
|
-
if (over) return;
|
|
224
|
-
if (lost) {
|
|
225
|
-
lost = false;
|
|
226
|
-
saving = false;
|
|
227
|
-
document.body.classList.remove('saving');
|
|
228
|
-
note.textContent = 'Some input did not reach the browser, so nothing was saved yet. Check the page shows you signed in, then press Save sign-in again.';
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
const r = await post('save');
|
|
232
|
-
if (r.ok) return end('Saved. You can close this tab; your coding agent can start the run again.');
|
|
233
|
-
if (r.status === 410) return end('This sign-in has ended. You can close this tab.');
|
|
234
|
-
note.textContent = 'Could not save: ' + (await r.text());
|
|
235
|
-
} catch {
|
|
236
|
-
note.textContent = 'Could not reach screw-bugs to save. Try again.';
|
|
237
|
-
}
|
|
238
|
-
saving = false;
|
|
239
|
-
document.body.classList.remove('saving');
|
|
240
|
-
});
|
|
241
|
-
$('cancel').addEventListener('click', async () => {
|
|
242
|
-
try { await post('cancel'); } catch {}
|
|
243
|
-
end('Cancelled. Nothing was saved. You can close this tab.');
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
// The theme: light, dark or the system's, in turn, as on screw-bugs Cloud's menu bar (the
|
|
247
|
-
// reports' tokens follow \`data-theme\`). Not kept: each sign-in is a new origin.
|
|
248
|
-
${THEME_BUTTON_JS}
|
|
249
|
-
themeCycle(document.querySelector('.menubar .theme'));
|
|
250
|
-
|
|
251
|
-
// The animation: the bug waits by a lock, and kicks it open when the person starts. It plays
|
|
252
|
-
// with Rive's runtime from its CDN (taken only with the hash it was published with) and the file
|
|
253
|
-
// from screw-bugs' CDN. Without either, or where the person prefers less motion, the page is the
|
|
254
|
-
// same without it.
|
|
255
|
-
const art = $('art');
|
|
256
|
-
// \`instance\` from when it is made, \`rive\` once its file loaded; \`stopped\` once the art is gone
|
|
257
|
-
// for good (it failed, or the person started), so nothing that loads later plays.
|
|
258
|
-
let instance, rive, observer, stopped = false, waiting = false, onWaiting;
|
|
259
|
-
const noArt = () => {
|
|
260
|
-
stopped = true;
|
|
261
|
-
if (art) art.hidden = true;
|
|
262
|
-
if (observer) observer.disconnect();
|
|
263
|
-
try {
|
|
264
|
-
if (instance) instance.cleanup();
|
|
265
|
-
} catch {}
|
|
266
|
-
instance = rive = observer = undefined;
|
|
267
|
-
};
|
|
268
|
-
if (art && !matchMedia('(prefers-reduced-motion: reduce)').matches) {
|
|
269
|
-
const runtime = document.createElement('script');
|
|
270
|
-
runtime.src = RIVE + 'rive.js';
|
|
271
|
-
runtime.integrity = RIVE_JS_SRI;
|
|
272
|
-
runtime.crossOrigin = 'anonymous';
|
|
273
|
-
runtime.onerror = noArt;
|
|
274
|
-
runtime.onload = () => {
|
|
275
|
-
if (stopped) return;
|
|
276
|
-
try {
|
|
277
|
-
const R = window.rive;
|
|
278
|
-
// The runtime is pinned, so the state changes it still gives are what this relies on.
|
|
279
|
-
R.Rive.suppressDeprecationWarnings = ['state-change-events'];
|
|
280
|
-
R.RuntimeLoader.setWasmUrl(RIVE + 'rive.wasm');
|
|
281
|
-
R.RuntimeLoader.setWasmFallbackUrl(RIVE + 'rive_fallback.wasm');
|
|
282
|
-
const canvas = art.querySelector('canvas');
|
|
283
|
-
const r = new R.Rive({
|
|
284
|
-
src: ANIMATION,
|
|
285
|
-
canvas,
|
|
286
|
-
autoplay: true,
|
|
287
|
-
stateMachine: 'Main',
|
|
288
|
-
// Binds the file's view model, whose \`kick\` trigger starts the kick.
|
|
289
|
-
autoBind: true,
|
|
290
|
-
layout: new R.Layout({ fit: R.Fit.Contain, alignment: R.Alignment.Center }),
|
|
291
|
-
onLoad: () => {
|
|
292
|
-
if (stopped) return;
|
|
293
|
-
r.resizeDrawingSurfaceToCanvas();
|
|
294
|
-
rive = r;
|
|
295
|
-
},
|
|
296
|
-
onLoadError: noArt,
|
|
297
|
-
onStateChange: (e) => {
|
|
298
|
-
for (const name of [].concat(e.data || [])) {
|
|
299
|
-
if (name === WAITING) waiting = true;
|
|
300
|
-
else if (name === 'Arrive' || name === 'Kick') waiting = false;
|
|
301
|
-
}
|
|
302
|
-
if (waiting && onWaiting) onWaiting();
|
|
303
|
-
},
|
|
304
|
-
});
|
|
305
|
-
instance = r;
|
|
306
|
-
observer = new ResizeObserver(() => rive && rive.resizeDrawingSurfaceToCanvas());
|
|
307
|
-
observer.observe(canvas);
|
|
308
|
-
} catch {
|
|
309
|
-
noArt();
|
|
310
|
-
}
|
|
311
|
-
};
|
|
312
|
-
document.head.appendChild(runtime);
|
|
313
|
-
} else noArt();
|
|
314
|
-
/** Plays the kick (once the bug waits by the lock), resolving when the bug has run off. */
|
|
315
|
-
const kick = () =>
|
|
316
|
-
new Promise((done) => {
|
|
317
|
-
if (!rive) return done();
|
|
318
|
-
const cap = setTimeout(done, KICK_WAIT_MAX);
|
|
319
|
-
onWaiting = () => {
|
|
320
|
-
onWaiting = undefined;
|
|
321
|
-
try {
|
|
322
|
-
rive.viewModelInstance.trigger('kick').trigger();
|
|
323
|
-
} catch {
|
|
324
|
-
clearTimeout(cap);
|
|
325
|
-
return done();
|
|
326
|
-
}
|
|
327
|
-
setTimeout(() => {
|
|
328
|
-
clearTimeout(cap);
|
|
329
|
-
done();
|
|
330
|
-
}, KICK_MS);
|
|
331
|
-
};
|
|
332
|
-
if (waiting) onWaiting();
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
// The explainer comes first; the browser shows (and its frames start) once the person starts.
|
|
336
|
-
// Start shows a spinner and takes no more clicks from the click until the browser shows; a
|
|
337
|
-
// failed check gives it back.
|
|
338
|
-
const start = $('start'), startError = $('start-error');
|
|
339
|
-
let starting = false;
|
|
340
|
-
const busy = (on) => {
|
|
341
|
-
starting = on;
|
|
342
|
-
start.disabled = on;
|
|
343
|
-
start.classList.toggle('loading', on);
|
|
344
|
-
if (on) start.setAttribute('aria-busy', 'true');
|
|
345
|
-
else start.removeAttribute('aria-busy');
|
|
346
|
-
};
|
|
347
|
-
start.addEventListener('click', async () => {
|
|
348
|
-
if (starting || over) return;
|
|
349
|
-
busy(true);
|
|
350
|
-
startError.textContent = '';
|
|
351
|
-
// Reading this takes no requests, so the sign-in may have ended meanwhile.
|
|
352
|
-
try {
|
|
353
|
-
const r = await fetch(base + '/status', { cache: 'no-store' });
|
|
354
|
-
if (!r.ok) {
|
|
355
|
-
busy(false);
|
|
356
|
-
return end(GONE);
|
|
357
|
-
}
|
|
358
|
-
} catch {
|
|
359
|
-
// Not reached at all: screw-bugs may have stopped, or the network dropped for a moment.
|
|
360
|
-
busy(false);
|
|
361
|
-
startError.textContent = 'Could not reach screw-bugs. Check that your coding agent is still running, then try again.';
|
|
362
|
-
return;
|
|
363
|
-
}
|
|
364
|
-
await kick();
|
|
365
|
-
noArt();
|
|
366
|
-
if (over) return;
|
|
367
|
-
document.body.classList.remove('intro');
|
|
368
|
-
resize();
|
|
369
|
-
frames();
|
|
370
|
-
});
|
|
371
|
-
})();`;
|
|
372
|
-
/**
|
|
373
|
-
* The live view's Content-Security-Policy: its own script, frames and icons as data URLs, its own
|
|
374
|
-
* routes, Google Fonts as the reports load them (`webFonts`), Rive's runtime from its exact folder
|
|
375
|
-
* on jsDelivr (its script and WebAssembly, which needs `wasm-unsafe-eval` to run) and the
|
|
376
|
-
* animation it plays (`SIGN_IN_ANIMATION`).
|
|
377
|
-
*/
|
|
378
|
-
export const SIGN_IN_CSP = "default-src 'none'; img-src data:; font-src https://fonts.gstatic.com; " +
|
|
379
|
-
"style-src 'unsafe-inline' https://fonts.googleapis.com; " +
|
|
380
|
-
`script-src ${cspHash(SIGN_IN_SCRIPT)} ${RIVE_RUNTIME}rive.js 'wasm-unsafe-eval'; ` +
|
|
381
|
-
`connect-src 'self' ${RIVE_RUNTIME} ${SIGN_IN_ANIMATION}; base-uri 'none'; ` +
|
|
382
|
-
// Framing it is refused by the server's `X-Frame-Options`; a meta policy cannot say that.
|
|
383
|
-
"form-action 'none'";
|
|
384
|
-
/** The sign-in page's own styles, on the reports' tokens and type scale (`styles`). */
|
|
385
|
-
const signInStyles = /* css */ `
|
|
386
|
-
html, body { height: 100%; }
|
|
387
|
-
body { display: flex; flex-direction: column; background: var(--bg); }
|
|
388
|
-
.top { position: sticky; top: 0; z-index: 10; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; height: 56px; padding: 0 24px; background: var(--bg); font: var(--t-mono); color: var(--header); }
|
|
389
|
-
.top .what { justify-self: center; white-space: nowrap; }
|
|
390
|
-
.pill { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 16px; border: 0; border-radius: 999px; font: var(--t-control); cursor: pointer; }
|
|
391
|
-
.pill.primary { background: var(--accent); color: var(--on-accent); font-weight: 500; }
|
|
392
|
-
.pill.primary:hover { filter: brightness(.95); }
|
|
393
|
-
.pill.quiet { background: var(--subtle); color: var(--text); }
|
|
394
|
-
.pill.quiet:hover { background: var(--subtle-hover); }
|
|
395
|
-
.app-icon { display: grid; place-items: center; flex: none; overflow: hidden; border-radius: 6px; background: var(--subtle); color: var(--muted); font: var(--t-small-strong); text-transform: uppercase; }
|
|
396
|
-
.app-icon img { width: 100%; height: 100%; object-fit: contain; }
|
|
397
|
-
|
|
398
|
-
/* The explainer: the menu bar (\`menu-bar.ts\`), and the animation beside a card that says what is
|
|
399
|
-
about to happen. */
|
|
400
|
-
#intro { display: none; }
|
|
401
|
-
.intro #intro { display: flex; flex: 1; align-items: center; justify-content: center; gap: 40px; padding: 24px 24px 88px; overflow: auto; }
|
|
402
|
-
.intro .live { display: none !important; }
|
|
403
|
-
.art { flex: none; width: 400px; aspect-ratio: 600 / 386; }
|
|
404
|
-
.art canvas { display: block; width: 100%; height: 100%; }
|
|
405
|
-
.card { flex: none; box-sizing: border-box; width: 378px; max-width: 100%; padding: 44px 64px 40px; border: 1px solid var(--border); border-radius: 28px; background: var(--panel); }
|
|
406
|
-
.card h1 { margin: 0 0 28px; font: 700 24px/30px var(--sans); letter-spacing: -0.7px; text-align: center; }
|
|
407
|
-
.card p { margin: 0 0 21px; font: var(--t-body-lg); color: var(--muted); }
|
|
408
|
-
.card .app { margin: 52px 0 0; text-align: center; }
|
|
409
|
-
.card .app-line { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; }
|
|
410
|
-
.card .app-icon { width: 22px; height: 22px; }
|
|
411
|
-
.card .app-line strong { min-width: 0; font: var(--t-heading-sm); color: var(--text); overflow-wrap: anywhere; }
|
|
412
|
-
.card .app-title { margin: 6px 0 0; font: var(--t-small); color: var(--muted); overflow-wrap: anywhere; }
|
|
413
|
-
.card .go { display: flex; justify-content: center; margin-top: 36px; }
|
|
414
|
-
#start { height: 40px; padding: 0 20px 0 24px; gap: 10px; font: var(--t-body-lg); font-weight: 500; }
|
|
415
|
-
#start:disabled { cursor: default; filter: none; }
|
|
416
|
-
/* While it starts, a spinner in place of the arrow. It keeps turning (slower) where the person
|
|
417
|
-
prefers less motion: it says something is happening, which a still ring does not. */
|
|
418
|
-
#start .spin { display: none; box-sizing: border-box; width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: start-spin 700ms linear infinite; }
|
|
419
|
-
#start.loading .spin { display: block; }
|
|
420
|
-
#start.loading svg { display: none; }
|
|
421
|
-
@keyframes start-spin { to { transform: rotate(360deg); } }
|
|
422
|
-
@media (prefers-reduced-motion: reduce) { #start .spin { animation: start-spin 1400ms linear infinite !important; } }
|
|
423
|
-
#start-error { margin: 16px 0 0; font: var(--t-small); color: var(--muted); text-align: center; }
|
|
424
|
-
#start-error:empty { display: none; }
|
|
425
|
-
#ended { display: none; margin: 36px 0 0; font: var(--t-body); color: var(--text); text-align: center; }
|
|
426
|
-
.intro.over .card .go, .intro.over #start-error { display: none; }
|
|
427
|
-
.intro.over #ended { display: block; }
|
|
428
|
-
body:not(.intro) .intro-only { display: none; }
|
|
429
|
-
/* The card's entrance, once per page: it rises in, then what it says follows in reading order.
|
|
430
|
-
Opacity and transform only, from the styles' resting state (so without animations the card is
|
|
431
|
-
simply there); a CSS animation, so it stays smooth while Rive's runtime loads. The reports'
|
|
432
|
-
reduced-motion rule turns it off. */
|
|
433
|
-
.card { --ease-out: cubic-bezier(0.23, 1, 0.32, 1); animation: card-in 300ms var(--ease-out) both; }
|
|
434
|
-
.card > * { animation: card-part-in 250ms var(--ease-out) both; }
|
|
435
|
-
.card > :nth-child(1) { animation-delay: 80ms; }
|
|
436
|
-
.card > :nth-child(2) { animation-delay: 120ms; }
|
|
437
|
-
.card > :nth-child(3) { animation-delay: 160ms; }
|
|
438
|
-
.card > :nth-child(4) { animation-delay: 200ms; }
|
|
439
|
-
.card > :nth-child(5) { animation-delay: 240ms; }
|
|
440
|
-
@keyframes card-in { from { opacity: 0; transform: translateY(12px) scale(0.97); } }
|
|
441
|
-
@keyframes card-part-in { from { opacity: 0; transform: translateY(8px); } }
|
|
442
|
-
/* The bug kicks the lock in place of a still: where the person prefers less motion, none. */
|
|
443
|
-
@media (prefers-reduced-motion: reduce) { .art { display: none; } }
|
|
444
|
-
|
|
445
|
-
/* The live view: the browser, its controls and Save. */
|
|
446
|
-
.live.top .who { display: inline-flex; align-items: center; gap: 10px; min-width: 0; justify-self: start; font: var(--t-body); color: var(--text); }
|
|
447
|
-
.live.top .who .app-icon { width: 24px; height: 24px; }
|
|
448
|
-
.live.top .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
449
|
-
.live.top .who .about { color: var(--muted); }
|
|
450
|
-
.live.top .acts { justify-self: end; display: inline-flex; gap: 8px; }
|
|
451
|
-
#note { padding: 0 24px 10px; font: var(--t-small); color: var(--muted); text-align: center; }
|
|
452
|
-
.bar { display: flex; gap: 6px; align-items: center; margin: 0 24px 12px; padding: 4px; border-radius: 999px; background: var(--subtle); min-width: 0; }
|
|
453
|
-
.bar button { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 999px; background: none; color: var(--muted); cursor: pointer; }
|
|
454
|
-
.bar button:hover { color: var(--text); background: var(--subtle-hover); }
|
|
455
|
-
#addr { flex: 1; min-width: 0; padding-right: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: var(--t-mono); color: var(--muted); }
|
|
456
|
-
#stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: flex-start; justify-content: center; background: var(--bg-2); border-top: 1px solid var(--border); overflow: hidden; }
|
|
457
|
-
#screen { max-width: 100%; max-height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; cursor: default; }
|
|
458
|
-
#keys { position: absolute; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; resize: none; }
|
|
459
|
-
.over #stage, .over .bar, .over #save, .over #cancel { opacity: .4; pointer-events: none; }
|
|
460
|
-
.saving #stage, .saving .bar, .saving #save { opacity: .6; pointer-events: none; }
|
|
461
|
-
@media (max-width: 860px) {
|
|
462
|
-
.intro #intro { flex-direction: column; justify-content: flex-start; gap: 24px; padding: 8px 24px 40px; }
|
|
463
|
-
.art { width: min(240px, 100%); }
|
|
464
|
-
}
|
|
465
|
-
@media (max-width: 640px) {
|
|
466
|
-
.top { padding: 0 24px; }
|
|
467
|
-
.top .what, .live.top .who .about { display: none; }
|
|
468
|
-
.live.top { grid-template-columns: 1fr auto; }
|
|
469
|
-
.card { width: 100%; padding: 44px 46px 40px; }
|
|
470
|
-
.bar { margin: 0 16px 10px; }
|
|
471
|
-
#note { padding: 0 16px 8px; }
|
|
472
|
-
}
|
|
473
|
-
`;
|
|
474
|
-
/** Exactly the script its hash allows: no whitespace around it. */
|
|
475
|
-
const scriptTag = new Markup(`<script>${SIGN_IN_SCRIPT}</script>`);
|
|
476
|
-
/** The app's icon, or the first letter of its host where it has none. */
|
|
477
|
-
const appIcon = (icon, host) => icon
|
|
478
|
-
? html `<span class="app-icon"><img src="${icon}" alt="" /></span>`
|
|
479
|
-
: html `<span class="app-icon" aria-hidden="true">${host.charAt(0)}</span>`;
|
|
480
|
-
/**
|
|
481
|
-
* The live view for signing in to the account `label`, which `about` describes, at the app that
|
|
482
|
-
* `site` names (its title and icon as the sign-in browser read them; its host alone without).
|
|
483
|
-
* First a card that says what happens, beside the animation (`SIGN_IN_ANIMATION`), then the
|
|
484
|
-
* browser.
|
|
485
|
-
*/
|
|
486
|
-
export const renderSignInPage = (account) => {
|
|
487
|
-
const title = account.site?.title;
|
|
488
|
-
// Only an image data URL: anything else is never put in the page.
|
|
489
|
-
const icon = /^data:image\/[a-z0-9.+-]+;base64,[A-Za-z0-9+/=]+$/.test(account.site?.icon ?? '')
|
|
490
|
-
? account.site?.icon
|
|
491
|
-
: undefined;
|
|
492
|
-
const host = URL.parse(account.origin)?.host ?? account.origin;
|
|
493
|
-
return `<!doctype html>\n${html `<html lang="en">
|
|
494
|
-
<head>
|
|
495
|
-
<meta charset="utf-8" />
|
|
496
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
497
|
-
<meta name="referrer" content="no-referrer" />
|
|
498
|
-
<meta http-equiv="Content-Security-Policy" content="${SIGN_IN_CSP}" />
|
|
499
|
-
<title>${`Sign in to ${host} as ${account.label} · screw-bugs`}</title>
|
|
500
|
-
${icon ? html `<link rel="icon" href="${icon}" />` : favicon} ${webFonts}
|
|
501
|
-
<style>
|
|
502
|
-
${new Markup(styles + signInStyles)}
|
|
503
|
-
</style>
|
|
504
|
-
</head>
|
|
505
|
-
<body class="intro">
|
|
506
|
-
${menuBar({
|
|
507
|
-
className: 'intro-only',
|
|
508
|
-
ends: html `${githubLink(640)}${themeButton(false)}`,
|
|
509
|
-
})}
|
|
510
|
-
<main id="intro">
|
|
511
|
-
<div id="art" class="art" aria-hidden="true"><canvas></canvas></div>
|
|
512
|
-
<section class="card" aria-labelledby="intro-title">
|
|
513
|
-
<h1 id="intro-title">Sign-in required</h1>
|
|
514
|
-
<p>This website requires you to sign in with an existing user.</p>
|
|
515
|
-
<p>
|
|
516
|
-
Your session will be saved only to your machine, so next time you won't have to log in
|
|
517
|
-
(until the session expires).
|
|
518
|
-
</p>
|
|
519
|
-
<div class="app">
|
|
520
|
-
<span class="app-line">${appIcon(icon, host)}<strong>${host}</strong></span>
|
|
521
|
-
${title === undefined ? '' : html `<p class="app-title">${title}</p>`}
|
|
522
|
-
</div>
|
|
523
|
-
<div class="go">
|
|
524
|
-
<button id="start" type="button" class="pill primary">
|
|
525
|
-
Sign in with a test user ${icon_('arrow-right', { size: 18 })}<span
|
|
526
|
-
class="spin"
|
|
527
|
-
aria-hidden="true"
|
|
528
|
-
></span>
|
|
529
|
-
</button>
|
|
530
|
-
</div>
|
|
531
|
-
<p id="start-error" role="alert"></p>
|
|
532
|
-
<p id="ended" role="status"></p>
|
|
533
|
-
</section>
|
|
534
|
-
</main>
|
|
535
|
-
<header class="top live">
|
|
536
|
-
<span class="who"
|
|
537
|
-
>${appIcon(icon, host)}<span>${`Sign in as ${account.label}`}</span>${account.about ? html `<span class="about">${account.about}</span>` : ''}</span
|
|
538
|
-
>
|
|
539
|
-
<span class="what">${host}</span>
|
|
540
|
-
<span class="acts">
|
|
541
|
-
<button id="cancel" type="button" class="pill quiet">Cancel</button>
|
|
542
|
-
<button id="save" type="button" class="pill primary">Save sign-in</button>
|
|
543
|
-
</span>
|
|
544
|
-
</header>
|
|
545
|
-
<div id="note" class="live">Sign in below, then press Save sign-in.</div>
|
|
546
|
-
<div class="bar live">
|
|
547
|
-
<button id="back" type="button" aria-label="Back">
|
|
548
|
-
${icon_('chevron-left', { size: 16 })}
|
|
549
|
-
</button>
|
|
550
|
-
<button id="reload" type="button" aria-label="Reload">
|
|
551
|
-
${icon_('refresh-cw', { size: 14 })}
|
|
552
|
-
</button>
|
|
553
|
-
<span id="addr"></span>
|
|
554
|
-
</div>
|
|
555
|
-
<div id="stage" class="live">
|
|
556
|
-
<img id="screen" alt="The browser screw-bugs signs in with" draggable="false" />
|
|
557
|
-
<textarea
|
|
558
|
-
id="keys"
|
|
559
|
-
aria-label="Keyboard input"
|
|
560
|
-
autocapitalize="off"
|
|
561
|
-
autocomplete="off"
|
|
562
|
-
spellcheck="false"
|
|
563
|
-
></textarea>
|
|
564
|
-
</div>
|
|
565
|
-
${scriptTag}
|
|
566
|
-
</body>
|
|
567
|
-
</html>`}`;
|
|
568
|
-
};
|
package/dist/report/styles.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare const light = "\n --bg: #ffffff; --bg-2: #f9f9f9; --panel: #fcfdfc; --subtle: #eff1ef;\n --border: #d7dad7; --border-strong: #b9bcb8;\n --muted: #60655f; --header: #9a9e98; --text: #1d211c;\n --accent: #94f20d; --on-accent: #1d211c; --accent-subtle: #eef6d6; --accent-border: #abc978;\n --fail: #e54d2e; --fail-text: #d13415; --pass: #8d8d8d;\n --link: #1d211c;\n --input: var(--border-strong); --ring: var(--header);\n --shadow: 0 16px 40px -4px rgba(29, 33, 28, .14), 0 2px 6px rgba(29, 33, 28, .08);\n --scrim: rgba(29, 33, 28, .55);\n --caption: #d7dad7; --caption-border: #b9bcb8; --video-edge: #111210;\n color-scheme: light;\n";
|
|
2
|
-
export declare const dark = "\n --bg: #111210; --bg-2: #181917; --panel: #181917; --subtle: #212220;\n --border: #383a36; --border-strong: #5c625b;\n --muted: #afb5ad; --header: #5c625b; --text: #eceeec;\n --accent: #94f20d; --on-accent: #1d211c; --accent-subtle: #1f2917; --accent-border: #496231;\n --fail: #e54d2e; --fail-text: #ff977d; --pass: #8d8d8d;\n --link: #eceeec;\n --input: var(--border-strong); --ring: var(--muted);\n --shadow: 0 20px 48px -4px rgba(0, 0, 0, .6), 0 2px 6px rgba(0, 0, 0, .4);\n --scrim: rgba(0, 0, 0, .7);\n --caption: #181917; --caption-border: #383a36; --video-edge: #383a36;\n color-scheme: dark;\n";
|
|
3
|
-
export declare const styles: string;
|