screw-bugs 0.1.9 → 0.1.11
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 +100 -54
- 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 +7 -4
- 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
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { judgedLedger, } from '../schema/index.js';
|
|
2
|
-
import { checksNote, countsOf, fixesOf, formatTimecode, notTestedCount, severityLabel, statuses, statusLabel, videoOf, } from './view.js';
|
|
3
|
-
const mark = {
|
|
4
|
-
passed: '✅',
|
|
5
|
-
failed: '❌',
|
|
6
|
-
blocked: '⚠️',
|
|
7
|
-
not_verified: '➖',
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Free text as inert Markdown on one line: no tables broken by `|`, no HTML, links, emphasis or
|
|
11
|
-
* headings from page-derived or user-written text.
|
|
12
|
-
*/
|
|
13
|
-
const inline = (text) => text
|
|
14
|
-
.replace(/\s+/g, ' ')
|
|
15
|
-
.trim()
|
|
16
|
-
.replace(/[\\`*_[\]<>|#~!]/g, (ch) => `\\${ch}`)
|
|
17
|
-
.replaceAll('&', '&');
|
|
18
|
-
/** A path as inline code; backticks cannot occur in run paths, but are dropped to be sure. */
|
|
19
|
-
const code = (path) => `\`${path.replaceAll('`', '')}\``;
|
|
20
|
-
/**
|
|
21
|
-
* A short GitHub-flavored Markdown summary of a run, to paste into (or post on) a pull request:
|
|
22
|
-
* the headline (the agent's, when it wrote one up, else the code's verdict), the counts, what to
|
|
23
|
-
* fix, the cases that did not pass with where their failure is in the video, the video and the
|
|
24
|
-
* screenshots with the agent's highlights drawn in, and where the full report is. Paths are
|
|
25
|
-
* relative to the project root; `reportPath` defaults to the report's.
|
|
26
|
-
*/
|
|
27
|
-
export const renderPrSummary = (bundle, options = {}) => {
|
|
28
|
-
const { findings } = bundle;
|
|
29
|
-
// Statuses as results show them: a case the agent's findings mark failed counts as failed.
|
|
30
|
-
const ledger = judgedLedger(bundle.ledger, findings);
|
|
31
|
-
const byAgent = ledger.cases.filter((c) => c.agentFailed !== undefined).length;
|
|
32
|
-
const counts = countsOf(ledger.cases);
|
|
33
|
-
const total = ledger.cases.length;
|
|
34
|
-
const ended = ledger.state === 'finished' || ledger.state === 'errored';
|
|
35
|
-
const allPassed = ledger.state === 'finished' && counts.passed === total;
|
|
36
|
-
const mood = !ended ? '🕒' : allPassed ? mark.passed : mark.failed;
|
|
37
|
-
const gaps = notTestedCount(bundle);
|
|
38
|
-
const verdict = !ended
|
|
39
|
-
? `still running, ${counts.passed} of ${total} passed so far`
|
|
40
|
-
: allPassed && gaps === undefined
|
|
41
|
-
? `${total === 1 ? 'the case' : `all ${total} cases`} passed`
|
|
42
|
-
: `${counts.passed} of ${total} ${total === 1 ? 'case' : 'cases'} passed${gaps ? ` · ${gaps}` : ''}`;
|
|
43
|
-
const notTested = findings?.notTested ?? [];
|
|
44
|
-
const headline = findings ? inline(findings.headline) : verdict;
|
|
45
|
-
const notPassing = ledger.cases.filter((c) => c.status !== 'passed');
|
|
46
|
-
const runDir = `.screw-bugs/runs/${bundle.jobId}`;
|
|
47
|
-
const reportPath = options.reportPath ?? `${runDir}/${bundle.files.html ?? 'report.html'}`;
|
|
48
|
-
const sessions = ledger.sessions ?? [];
|
|
49
|
-
const fixes = fixesOf(bundle);
|
|
50
|
-
const annotated = Object.entries(bundle.annotated ?? {});
|
|
51
|
-
const caseOfShot = new Map(ledger.cases.flatMap((c) => (c.shots ?? []).map((shot) => [shot.id, c.id])));
|
|
52
|
-
/** Where a case was decided in its session's video. */
|
|
53
|
-
const at = (c) => {
|
|
54
|
-
const video = videoOf(bundle, c);
|
|
55
|
-
if (video?.path === undefined)
|
|
56
|
-
return '—';
|
|
57
|
-
const decided = c.steps?.find((s) => s.index === c.step)?.startMs ?? c.startMs;
|
|
58
|
-
return decided === undefined ? '—' : formatTimecode(decided);
|
|
59
|
-
};
|
|
60
|
-
return [
|
|
61
|
-
`### ${mood} screw-bugs: ${headline}`,
|
|
62
|
-
'',
|
|
63
|
-
...(findings
|
|
64
|
-
? [
|
|
65
|
-
`**${byAgent > 0 ? 'Code and agent decided' : 'Code decided'}:** ${verdict}${byAgent > 0 ? ` (${byAgent} marked failed by the agent's review)` : ''}. _The ${notTested.length > 0 ? 'headline, fixes and what was not tested' : 'headline and fixes'} are the agent's write-up._`,
|
|
66
|
-
'',
|
|
67
|
-
]
|
|
68
|
-
: []),
|
|
69
|
-
`${inline(bundle.summary.text)}${bundle.summary.derived ? ' _(summarized from case titles)_' : ''}`,
|
|
70
|
-
'',
|
|
71
|
-
statuses.map((s) => `${mark[s]} ${counts[s]} ${statusLabel[s].toLowerCase()}`).join(' · '),
|
|
72
|
-
...(ledger.error ? ['', `**The run stopped early:** ${inline(ledger.error)}`] : []),
|
|
73
|
-
...(notTested.length > 0
|
|
74
|
-
? [
|
|
75
|
-
'',
|
|
76
|
-
"#### Not tested _(agent's write-up)_",
|
|
77
|
-
'',
|
|
78
|
-
...notTested.map((item) => `- **${inline(item.what)}:** ${inline(item.why)}`),
|
|
79
|
-
]
|
|
80
|
-
: []),
|
|
81
|
-
...(fixes.length > 0
|
|
82
|
-
? [
|
|
83
|
-
'',
|
|
84
|
-
'#### What to fix',
|
|
85
|
-
'',
|
|
86
|
-
...fixes.map((fix, i) => `${i + 1}. **${severityLabel[fix.severity]}: ${inline(fix.title)}** ${inline(fix.why)} ` +
|
|
87
|
-
`(${fix.caseIds.map((id) => code(id)).join(', ')})`),
|
|
88
|
-
]
|
|
89
|
-
: []),
|
|
90
|
-
...(notPassing.length > 0
|
|
91
|
-
? [
|
|
92
|
-
'',
|
|
93
|
-
'| Case | Status | Reason | Video at |',
|
|
94
|
-
'| --- | --- | --- | --- |',
|
|
95
|
-
...notPassing.map((c) => `| ${inline(c.title)} | ${mark[c.status]} ${statusLabel[c.status]} | ${c.agentFailed !== undefined
|
|
96
|
-
? `Agent's verdict: ${inline(c.agentFailed)} (${checksNote(c.checkStatus)})` +
|
|
97
|
-
(c.reason ? `; ${inline(c.reason)}` : '')
|
|
98
|
-
: c.reason
|
|
99
|
-
? inline(c.reason)
|
|
100
|
-
: '—'} | ${at(c)} |`),
|
|
101
|
-
]
|
|
102
|
-
: []),
|
|
103
|
-
'',
|
|
104
|
-
...sessions.map((session) => session.video !== undefined && session.videoProblem === undefined
|
|
105
|
-
? `Video: ${code(`${runDir}/${session.video}`)}`
|
|
106
|
-
: `Video missing or incomplete${session.video ? ` (${code(`${runDir}/${session.video}`)})` : ''}: ${inline(session.videoProblem ?? 'the video file was not saved.')}`),
|
|
107
|
-
...(sessions.length > 0 ? [''] : []),
|
|
108
|
-
...(annotated.length > 0
|
|
109
|
-
? [
|
|
110
|
-
'Screenshots with highlights drawn in:',
|
|
111
|
-
...annotated.map(([id, path]) => `- ${code(`${runDir}/${path}`)} (case ${code(caseOfShot.get(id) ?? '?')})`),
|
|
112
|
-
'',
|
|
113
|
-
]
|
|
114
|
-
: []),
|
|
115
|
-
`Target: ${inline(bundle.spec.url)} (${inline(bundle.device.label)}) · Job \`${bundle.jobId}\``,
|
|
116
|
-
`Full report with video, steps and screenshots: ${code(reportPath)}`,
|
|
117
|
-
'',
|
|
118
|
-
].join('\n');
|
|
119
|
-
};
|
package/dist/report/sha256.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/** The SHA-256 digest of `bytes`. */
|
|
2
|
-
export declare const sha256: (bytes: Uint8Array) => Uint8Array;
|
|
3
|
-
/** HMAC-SHA256 (RFC 2104) of `message` under `key`. */
|
|
4
|
-
export declare const hmacSha256: (key: Uint8Array, message: Uint8Array) => Uint8Array;
|
|
5
|
-
/** Bytes as lowercase hex. */
|
|
6
|
-
export declare const hex: (bytes: Uint8Array) => string;
|
|
7
|
-
export declare const base64: (bytes: Uint8Array) => string;
|
|
8
|
-
/** A CSP source that allows exactly this inline script: `'sha256-…'`. */
|
|
9
|
-
export declare const cspHash: (script: string) => string;
|
package/dist/report/sha256.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* SHA-256 (and HMAC-SHA256) in plain code, for the hash of the report's one inline script in its
|
|
3
|
-
* Content Security Policy, and the report server's identity proof. The report module stays free
|
|
4
|
-
* of Node, and the renderer is synchronous, so neither `node:crypto` nor Web Crypto (which is
|
|
5
|
-
* async) fits.
|
|
6
|
-
*/
|
|
7
|
-
const K = Uint32Array.from([
|
|
8
|
-
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
9
|
-
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
10
|
-
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
11
|
-
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
12
|
-
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
13
|
-
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
14
|
-
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
15
|
-
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
|
|
16
|
-
]);
|
|
17
|
-
const rotr = (x, n) => (x >>> n) | (x << (32 - n));
|
|
18
|
-
/** The SHA-256 digest of `bytes`. */
|
|
19
|
-
export const sha256 = (bytes) => {
|
|
20
|
-
const length = bytes.length;
|
|
21
|
-
const padded = new Uint8Array(Math.ceil((length + 9) / 64) * 64);
|
|
22
|
-
padded.set(bytes);
|
|
23
|
-
padded[length] = 0x80;
|
|
24
|
-
const view = new DataView(padded.buffer);
|
|
25
|
-
view.setUint32(padded.length - 8, Math.floor((length * 8) / 2 ** 32));
|
|
26
|
-
view.setUint32(padded.length - 4, (length * 8) >>> 0);
|
|
27
|
-
const h = Uint32Array.from([
|
|
28
|
-
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
|
|
29
|
-
]);
|
|
30
|
-
const w = new Uint32Array(64);
|
|
31
|
-
for (let block = 0; block < padded.length; block += 64) {
|
|
32
|
-
for (let i = 0; i < 16; i++)
|
|
33
|
-
w[i] = view.getUint32(block + i * 4);
|
|
34
|
-
for (let i = 16; i < 64; i++) {
|
|
35
|
-
const a = w[i - 15];
|
|
36
|
-
const b = w[i - 2];
|
|
37
|
-
const s0 = rotr(a, 7) ^ rotr(a, 18) ^ (a >>> 3);
|
|
38
|
-
const s1 = rotr(b, 17) ^ rotr(b, 19) ^ (b >>> 10);
|
|
39
|
-
w[i] = (w[i - 16] + s0 + w[i - 7] + s1) >>> 0;
|
|
40
|
-
}
|
|
41
|
-
let [a, b, c, d, e, f, g, hh] = h;
|
|
42
|
-
for (let i = 0; i < 64; i++) {
|
|
43
|
-
const t1 = (hh + (rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25)) + ((e & f) ^ (~e & g)) + K[i] + w[i]) >>>
|
|
44
|
-
0;
|
|
45
|
-
const t2 = ((rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22)) + ((a & b) ^ (a & c) ^ (b & c))) >>> 0;
|
|
46
|
-
hh = g;
|
|
47
|
-
g = f;
|
|
48
|
-
f = e;
|
|
49
|
-
e = (d + t1) >>> 0;
|
|
50
|
-
d = c;
|
|
51
|
-
c = b;
|
|
52
|
-
b = a;
|
|
53
|
-
a = (t1 + t2) >>> 0;
|
|
54
|
-
}
|
|
55
|
-
h[0] = (h[0] + a) >>> 0;
|
|
56
|
-
h[1] = (h[1] + b) >>> 0;
|
|
57
|
-
h[2] = (h[2] + c) >>> 0;
|
|
58
|
-
h[3] = (h[3] + d) >>> 0;
|
|
59
|
-
h[4] = (h[4] + e) >>> 0;
|
|
60
|
-
h[5] = (h[5] + f) >>> 0;
|
|
61
|
-
h[6] = (h[6] + g) >>> 0;
|
|
62
|
-
h[7] = (h[7] + hh) >>> 0;
|
|
63
|
-
}
|
|
64
|
-
const out = new Uint8Array(32);
|
|
65
|
-
const outView = new DataView(out.buffer);
|
|
66
|
-
h.forEach((word, i) => outView.setUint32(i * 4, word));
|
|
67
|
-
return out;
|
|
68
|
-
};
|
|
69
|
-
/** HMAC-SHA256 (RFC 2104) of `message` under `key`. */
|
|
70
|
-
export const hmacSha256 = (key, message) => {
|
|
71
|
-
const block = new Uint8Array(64);
|
|
72
|
-
block.set(key.length > 64 ? sha256(key) : key);
|
|
73
|
-
const pad = (byte) => block.map((b) => b ^ byte);
|
|
74
|
-
const inner = new Uint8Array(64 + message.length);
|
|
75
|
-
inner.set(pad(0x36));
|
|
76
|
-
inner.set(message, 64);
|
|
77
|
-
const outer = new Uint8Array(64 + 32);
|
|
78
|
-
outer.set(pad(0x5c));
|
|
79
|
-
outer.set(sha256(inner), 64);
|
|
80
|
-
return sha256(outer);
|
|
81
|
-
};
|
|
82
|
-
/** Bytes as lowercase hex. */
|
|
83
|
-
export const hex = (bytes) => Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
|
|
84
|
-
const BASE64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
85
|
-
export const base64 = (bytes) => {
|
|
86
|
-
let out = '';
|
|
87
|
-
for (let i = 0; i < bytes.length; i += 3) {
|
|
88
|
-
const [a = 0, b = 0, c = 0] = [bytes[i], bytes[i + 1], bytes[i + 2]];
|
|
89
|
-
const n = (a << 16) | (b << 8) | c;
|
|
90
|
-
out += BASE64[(n >> 18) & 63] + BASE64[(n >> 12) & 63];
|
|
91
|
-
out += i + 1 < bytes.length ? BASE64[(n >> 6) & 63] : '=';
|
|
92
|
-
out += i + 2 < bytes.length ? BASE64[n & 63] : '=';
|
|
93
|
-
}
|
|
94
|
-
return out;
|
|
95
|
-
};
|
|
96
|
-
/** A CSP source that allows exactly this inline script: `'sha256-…'`. */
|
|
97
|
-
export const cspHash = (script) => `'sha256-${base64(sha256(new TextEncoder().encode(script)))}'`;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/** The quality the upload's page encodes screenshots with (0 to 1). */
|
|
2
|
-
export declare const SHARE_WEBP_QUALITY = 0.8;
|
|
3
|
-
/** How often the upload's page asks how the share is going, in milliseconds. */
|
|
4
|
-
export declare const SHARE_POLL_MS = 500;
|
|
5
|
-
/** Plain ES2020, without backslashes. */
|
|
6
|
-
export declare const SHARE_PAGE_SCRIPT = "(() => {\n const d = document, r = d.documentElement, K = 'screw-bugs-theme';\n let theme = 'system'; try { theme = localStorage.getItem(K) || theme; } catch (e) {} r.dataset.theme = theme;\n const themeCycle=(b,key)=>{\n const r=document.documentElement,T=['light','dark','system'],N={light:'Light theme',dark:'Dark theme',system:'Theme from system'};\n const at=()=>{const i=T.indexOf(r.dataset.theme);return i<0?2:i};\n const show=()=>{const i=at(),f=document.getElementById('favicon'),h=f&&f.dataset[T[i]];if(h)f.href=h;b.setAttribute('aria-label',N[T[i]]+'. Switch to '+N[T[(i+1)%3]].toLowerCase());b.title=N[T[i]]};\n show();\n b.addEventListener('click',()=>{const m=T[(at()+1)%3];r.dataset.theme=m;if(key)try{localStorage.setItem(key,m)}catch(e){}show()});\n};\n const t = d.querySelector('.menubar .theme'); if (t) { themeCycle(t, K); t.hidden = false; }\n const c = d.getElementById('copy');\n if (c) {\n const label = c.querySelector('.copy-label'), was = label.textContent;\n let timer;\n c.hidden = false;\n c.addEventListener('click', async () => {\n const code = c.dataset.code;\n let ok = false;\n try { await navigator.clipboard.writeText(code); ok = true; } catch (e) {}\n if (!ok) {\n const a = d.createElement('textarea');\n a.value = code; a.setAttribute('readonly', ''); a.style.position = 'fixed'; a.style.opacity = '0';\n d.body.append(a); a.select();\n try { ok = d.execCommand('copy'); } catch (e) {}\n a.remove();\n }\n label.textContent = ok ? 'Copied' : 'Select the code to copy it';\n c.classList.toggle('copied', ok);\n clearTimeout(timer);\n timer = setTimeout(() => { label.textContent = was; c.classList.remove('copied'); }, 2000);\n });\n }\n const b = d.body.dataset;\n if (b.refresh) setTimeout(() => location.reload(), Number(b.refresh) * 1000);\n if (b.wait) {\n const tick = async () => {\n try {\n const res = await fetch(location.href, { redirect: 'manual', cache: 'no-store' });\n if (res.type === 'opaqueredirect' || res.status !== 200) return location.reload();\n // The page's own phase, read from its body (the text also holds this script).\n const next = new DOMParser().parseFromString(await res.text(), 'text/html').body;\n if (next.dataset.phase !== 'pairing') return location.reload();\n } catch (e) {}\n setTimeout(tick, Number(b.wait) * 1000);\n };\n setTimeout(tick, Number(b.wait) * 1000);\n }\n if (b.phase === 'following') {\n const ask = (route, path) =>\n route + '?state=' + encodeURIComponent(b.state) +\n (path === undefined ? '' : '&path=' + encodeURIComponent(path));\n const text = d.getElementById('text'), bar = d.getElementById('bar');\n const shot = d.getElementById('shot'), name = d.getElementById('name');\n let shown;\n const show = (path) => {\n if (path === shown) return;\n shown = path;\n name.textContent = path === undefined ? '' : path;\n if (path !== undefined && /[.](png|jpe?g|webp)$/i.test(path)) {\n shot.src = '/' + encodeURIComponent(b.run) + '/' + path.split('/').map(encodeURIComponent).join('/');\n shot.hidden = false;\n } else {\n shot.hidden = true;\n shot.removeAttribute('src');\n }\n };\n const say = (sentence, done, total) => {\n text.textContent = sentence;\n if (total > 0) { bar.max = total; bar.value = done; } else bar.removeAttribute('value');\n };\n const webp = async (blob) => {\n const bitmap = await createImageBitmap(blob);\n try {\n if (typeof OffscreenCanvas === 'function') {\n const canvas = new OffscreenCanvas(bitmap.width, bitmap.height);\n canvas.getContext('2d', { alpha: false }).drawImage(bitmap, 0, 0);\n return await canvas.convertToBlob({ type: 'image/webp', quality: 0.8 });\n }\n const canvas = d.createElement('canvas');\n canvas.width = bitmap.width;\n canvas.height = bitmap.height;\n canvas.getContext('2d', { alpha: false }).drawImage(bitmap, 0, 0);\n return await new Promise((done) => canvas.toBlob(done, 'image/webp', 0.8));\n } finally {\n bitmap.close();\n }\n };\n // Each screenshot once, one at a time; anything that goes wrong hands back nothing, and the\n // original goes up instead. A 410 means the server stopped waiting.\n let encoding = false;\n const encode = async (files) => {\n encoding = true;\n for (const file of files) {\n show(file.path);\n let made = null;\n try {\n const source = await fetch(ask(b.source, file.path), { cache: 'no-store' });\n if (source.ok) {\n const blob = await webp(await source.blob());\n if (blob && blob.type === 'image/webp' && blob.size < file.size) made = blob;\n }\n } catch (e) {}\n let answer;\n try {\n answer = await fetch(ask(b.encoded, file.path), {\n method: 'POST',\n headers: { 'content-type': 'image/webp' },\n body: made || new Blob([]),\n });\n } catch (e) {\n return;\n }\n if (answer.status === 410) return;\n }\n };\n const poll = async () => {\n let status;\n try {\n const answer = await fetch(ask(b.status), { cache: 'no-store' });\n if (answer.status !== 200) return location.reload();\n status = await answer.json();\n } catch (e) {\n return setTimeout(poll, 500 * 4);\n }\n if (status.phase === 'preparing') {\n say('Making the screenshots smaller: ' + status.settled + ' of ' + status.files.length + '.', status.settled, status.files.length);\n if (!encoding) encode(status.files);\n } else if (status.phase === 'uploading') {\n say(\n status.total === 0\n ? 'Uploading the report\u2026'\n : 'Uploading screenshots and videos: ' + status.done + ' of ' + status.total + '.',\n status.done,\n status.total,\n );\n show(status.current[status.current.length - 1]);\n } else return location.reload();\n setTimeout(poll, 500);\n };\n poll();\n }\n})();";
|
|
7
|
-
/**
|
|
8
|
-
* The pages' policy: their own styles and script, the fonts, nothing else; never in a frame. A
|
|
9
|
-
* page with a form may post it to this server, then follow its redirect to `formTo` (Cloud).
|
|
10
|
-
*/
|
|
11
|
-
export declare const sharePageCsp: (formTo?: string) => string;
|
|
12
|
-
export interface SharePage {
|
|
13
|
-
readonly title: string;
|
|
14
|
-
/** Plain text under the title. */
|
|
15
|
-
readonly text: string;
|
|
16
|
-
/** A failure: the title in the failure color. */
|
|
17
|
-
readonly failed?: boolean;
|
|
18
|
-
/** A pairing code to show large, with a Copy button; the page then waits for it to be used. */
|
|
19
|
-
readonly code?: string;
|
|
20
|
-
/** How often the code's page asks whether it moved on, in seconds. */
|
|
21
|
-
readonly wait?: number;
|
|
22
|
-
/** A link to open in a new tab, as the main button. */
|
|
23
|
-
readonly link?: {
|
|
24
|
-
readonly href: string;
|
|
25
|
-
readonly text: string;
|
|
26
|
-
};
|
|
27
|
-
/** A button that posts to `action` on this server, as the main button. */
|
|
28
|
-
readonly form?: {
|
|
29
|
-
readonly action: string;
|
|
30
|
-
readonly label: string;
|
|
31
|
-
};
|
|
32
|
-
/** The report to go back to. */
|
|
33
|
-
readonly back?: string;
|
|
34
|
-
/** Reload after this many seconds (without script, for the upload's page). */
|
|
35
|
-
readonly refresh?: number;
|
|
36
|
-
/** The upload's page: it follows the share `state` of the run `run` live, at `routes`. */
|
|
37
|
-
readonly follow?: {
|
|
38
|
-
readonly state: string;
|
|
39
|
-
readonly run: string;
|
|
40
|
-
readonly routes: {
|
|
41
|
-
readonly status: string;
|
|
42
|
-
readonly source: string;
|
|
43
|
-
readonly encoded: string;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
/** A page of the Share button's routes (see the top of this file). */
|
|
48
|
-
export declare const renderSharePage: (page: SharePage) => string;
|
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
import { favicon, html, icon, Markup, webFonts } from './markup.js';
|
|
2
|
-
import { githubLink, menuBar, THEME_BUTTON_JS, themeButton } from './menu-bar.js';
|
|
3
|
-
import { cspHash } from './sha256.js';
|
|
4
|
-
import { styles } from './styles.js';
|
|
5
|
-
/*
|
|
6
|
-
* The pages of the Share button's routes on the local report server (`src/cli/share.ts`): asking
|
|
7
|
-
* before a share, the pairing code to type on Screw Bugs Cloud, the upload's progress, and what
|
|
8
|
-
* went wrong. In the reports' look: their menu bar, tokens and type, one card in the middle.
|
|
9
|
-
*
|
|
10
|
-
* Their one script (`SHARE_PAGE_SCRIPT`, allowed by its hash) keeps the theme the reports keep,
|
|
11
|
-
* copies the pairing code (`navigator.clipboard`, which an `http:` tailnet address does not have,
|
|
12
|
-
* else a selected text area), and moves the page on: a page with `data-refresh` reloads after that
|
|
13
|
-
* many seconds; the pairing code's page (`data-phase="pairing"`) asks for itself again every
|
|
14
|
-
* `data-wait` seconds and reloads only once it is no longer the code (so a copy or a selection is
|
|
15
|
-
* not lost every few seconds). Without the script, a meta refresh does both.
|
|
16
|
-
*
|
|
17
|
-
* The upload's page (`data-phase="following"`) follows the share live instead: it asks how it is
|
|
18
|
-
* going (`status`, as JSON) and shows the screenshot going up right now. While the server prepares
|
|
19
|
-
* the share, it makes the screenshots smaller: it fetches each one (`source`), encodes it as WebP
|
|
20
|
-
* at its own size and hands it back (`encoded`), or hands back nothing when it cannot (an empty
|
|
21
|
-
* body: a browser without a WebP encoder, such as Safari, or one that fails). The upload never
|
|
22
|
-
* needs the page; it goes on with the original files when the page is closed or has no script.
|
|
23
|
-
*/
|
|
24
|
-
/** The quality the upload's page encodes screenshots with (0 to 1). */
|
|
25
|
-
export const SHARE_WEBP_QUALITY = 0.8;
|
|
26
|
-
/** How often the upload's page asks how the share is going, in milliseconds. */
|
|
27
|
-
export const SHARE_POLL_MS = 500;
|
|
28
|
-
/** Plain ES2020, without backslashes. */
|
|
29
|
-
export const SHARE_PAGE_SCRIPT = `(() => {
|
|
30
|
-
const d = document, r = d.documentElement, K = 'screw-bugs-theme';
|
|
31
|
-
let theme = 'system'; try { theme = localStorage.getItem(K) || theme; } catch (e) {} r.dataset.theme = theme;
|
|
32
|
-
${THEME_BUTTON_JS}
|
|
33
|
-
const t = d.querySelector('.menubar .theme'); if (t) { themeCycle(t, K); t.hidden = false; }
|
|
34
|
-
const c = d.getElementById('copy');
|
|
35
|
-
if (c) {
|
|
36
|
-
const label = c.querySelector('.copy-label'), was = label.textContent;
|
|
37
|
-
let timer;
|
|
38
|
-
c.hidden = false;
|
|
39
|
-
c.addEventListener('click', async () => {
|
|
40
|
-
const code = c.dataset.code;
|
|
41
|
-
let ok = false;
|
|
42
|
-
try { await navigator.clipboard.writeText(code); ok = true; } catch (e) {}
|
|
43
|
-
if (!ok) {
|
|
44
|
-
const a = d.createElement('textarea');
|
|
45
|
-
a.value = code; a.setAttribute('readonly', ''); a.style.position = 'fixed'; a.style.opacity = '0';
|
|
46
|
-
d.body.append(a); a.select();
|
|
47
|
-
try { ok = d.execCommand('copy'); } catch (e) {}
|
|
48
|
-
a.remove();
|
|
49
|
-
}
|
|
50
|
-
label.textContent = ok ? 'Copied' : 'Select the code to copy it';
|
|
51
|
-
c.classList.toggle('copied', ok);
|
|
52
|
-
clearTimeout(timer);
|
|
53
|
-
timer = setTimeout(() => { label.textContent = was; c.classList.remove('copied'); }, 2000);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
const b = d.body.dataset;
|
|
57
|
-
if (b.refresh) setTimeout(() => location.reload(), Number(b.refresh) * 1000);
|
|
58
|
-
if (b.wait) {
|
|
59
|
-
const tick = async () => {
|
|
60
|
-
try {
|
|
61
|
-
const res = await fetch(location.href, { redirect: 'manual', cache: 'no-store' });
|
|
62
|
-
if (res.type === 'opaqueredirect' || res.status !== 200) return location.reload();
|
|
63
|
-
// The page's own phase, read from its body (the text also holds this script).
|
|
64
|
-
const next = new DOMParser().parseFromString(await res.text(), 'text/html').body;
|
|
65
|
-
if (next.dataset.phase !== 'pairing') return location.reload();
|
|
66
|
-
} catch (e) {}
|
|
67
|
-
setTimeout(tick, Number(b.wait) * 1000);
|
|
68
|
-
};
|
|
69
|
-
setTimeout(tick, Number(b.wait) * 1000);
|
|
70
|
-
}
|
|
71
|
-
if (b.phase === 'following') {
|
|
72
|
-
const ask = (route, path) =>
|
|
73
|
-
route + '?state=' + encodeURIComponent(b.state) +
|
|
74
|
-
(path === undefined ? '' : '&path=' + encodeURIComponent(path));
|
|
75
|
-
const text = d.getElementById('text'), bar = d.getElementById('bar');
|
|
76
|
-
const shot = d.getElementById('shot'), name = d.getElementById('name');
|
|
77
|
-
let shown;
|
|
78
|
-
const show = (path) => {
|
|
79
|
-
if (path === shown) return;
|
|
80
|
-
shown = path;
|
|
81
|
-
name.textContent = path === undefined ? '' : path;
|
|
82
|
-
if (path !== undefined && /[.](png|jpe?g|webp)$/i.test(path)) {
|
|
83
|
-
shot.src = '/' + encodeURIComponent(b.run) + '/' + path.split('/').map(encodeURIComponent).join('/');
|
|
84
|
-
shot.hidden = false;
|
|
85
|
-
} else {
|
|
86
|
-
shot.hidden = true;
|
|
87
|
-
shot.removeAttribute('src');
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
const say = (sentence, done, total) => {
|
|
91
|
-
text.textContent = sentence;
|
|
92
|
-
if (total > 0) { bar.max = total; bar.value = done; } else bar.removeAttribute('value');
|
|
93
|
-
};
|
|
94
|
-
const webp = async (blob) => {
|
|
95
|
-
const bitmap = await createImageBitmap(blob);
|
|
96
|
-
try {
|
|
97
|
-
if (typeof OffscreenCanvas === 'function') {
|
|
98
|
-
const canvas = new OffscreenCanvas(bitmap.width, bitmap.height);
|
|
99
|
-
canvas.getContext('2d', { alpha: false }).drawImage(bitmap, 0, 0);
|
|
100
|
-
return await canvas.convertToBlob({ type: 'image/webp', quality: ${SHARE_WEBP_QUALITY} });
|
|
101
|
-
}
|
|
102
|
-
const canvas = d.createElement('canvas');
|
|
103
|
-
canvas.width = bitmap.width;
|
|
104
|
-
canvas.height = bitmap.height;
|
|
105
|
-
canvas.getContext('2d', { alpha: false }).drawImage(bitmap, 0, 0);
|
|
106
|
-
return await new Promise((done) => canvas.toBlob(done, 'image/webp', ${SHARE_WEBP_QUALITY}));
|
|
107
|
-
} finally {
|
|
108
|
-
bitmap.close();
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
// Each screenshot once, one at a time; anything that goes wrong hands back nothing, and the
|
|
112
|
-
// original goes up instead. A 410 means the server stopped waiting.
|
|
113
|
-
let encoding = false;
|
|
114
|
-
const encode = async (files) => {
|
|
115
|
-
encoding = true;
|
|
116
|
-
for (const file of files) {
|
|
117
|
-
show(file.path);
|
|
118
|
-
let made = null;
|
|
119
|
-
try {
|
|
120
|
-
const source = await fetch(ask(b.source, file.path), { cache: 'no-store' });
|
|
121
|
-
if (source.ok) {
|
|
122
|
-
const blob = await webp(await source.blob());
|
|
123
|
-
if (blob && blob.type === 'image/webp' && blob.size < file.size) made = blob;
|
|
124
|
-
}
|
|
125
|
-
} catch (e) {}
|
|
126
|
-
let answer;
|
|
127
|
-
try {
|
|
128
|
-
answer = await fetch(ask(b.encoded, file.path), {
|
|
129
|
-
method: 'POST',
|
|
130
|
-
headers: { 'content-type': 'image/webp' },
|
|
131
|
-
body: made || new Blob([]),
|
|
132
|
-
});
|
|
133
|
-
} catch (e) {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
if (answer.status === 410) return;
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
const poll = async () => {
|
|
140
|
-
let status;
|
|
141
|
-
try {
|
|
142
|
-
const answer = await fetch(ask(b.status), { cache: 'no-store' });
|
|
143
|
-
if (answer.status !== 200) return location.reload();
|
|
144
|
-
status = await answer.json();
|
|
145
|
-
} catch (e) {
|
|
146
|
-
return setTimeout(poll, ${SHARE_POLL_MS} * 4);
|
|
147
|
-
}
|
|
148
|
-
if (status.phase === 'preparing') {
|
|
149
|
-
say('Making the screenshots smaller: ' + status.settled + ' of ' + status.files.length + '.', status.settled, status.files.length);
|
|
150
|
-
if (!encoding) encode(status.files);
|
|
151
|
-
} else if (status.phase === 'uploading') {
|
|
152
|
-
say(
|
|
153
|
-
status.total === 0
|
|
154
|
-
? 'Uploading the report…'
|
|
155
|
-
: 'Uploading screenshots and videos: ' + status.done + ' of ' + status.total + '.',
|
|
156
|
-
status.done,
|
|
157
|
-
status.total,
|
|
158
|
-
);
|
|
159
|
-
show(status.current[status.current.length - 1]);
|
|
160
|
-
} else return location.reload();
|
|
161
|
-
setTimeout(poll, ${SHARE_POLL_MS});
|
|
162
|
-
};
|
|
163
|
-
poll();
|
|
164
|
-
}
|
|
165
|
-
})();`;
|
|
166
|
-
/**
|
|
167
|
-
* The pages' policy: their own styles and script, the fonts, nothing else; never in a frame. A
|
|
168
|
-
* page with a form may post it to this server, then follow its redirect to `formTo` (Cloud).
|
|
169
|
-
*/
|
|
170
|
-
export const sharePageCsp = (formTo) => "default-src 'none'; img-src 'self' data:; font-src https://fonts.gstatic.com; " +
|
|
171
|
-
"style-src 'unsafe-inline' https://fonts.googleapis.com; " +
|
|
172
|
-
`script-src ${cspHash(SHARE_PAGE_SCRIPT)}; connect-src 'self'; base-uri 'none'; ` +
|
|
173
|
-
"frame-ancestors 'none'; " +
|
|
174
|
-
(formTo === undefined ? "form-action 'none'" : `form-action 'self' ${formTo}`);
|
|
175
|
-
const sharePageStyles = /* css */ `
|
|
176
|
-
html, body { height: 100%; }
|
|
177
|
-
body { display: flex; flex-direction: column; margin: 0; background: var(--bg); color: var(--text); font: var(--t-body); }
|
|
178
|
-
main { display: flex; flex: 1; align-items: center; justify-content: center; padding: 24px 16px 88px; }
|
|
179
|
-
.card { box-sizing: border-box; width: 420px; max-width: 100%; padding: 40px 40px 32px; border: 1px solid var(--border); border-radius: 28px; background: var(--panel); text-align: center; }
|
|
180
|
-
.card h1 { margin: 0 0 16px; font: 700 24px/30px var(--sans); letter-spacing: -0.7px; }
|
|
181
|
-
.card p { margin: 0 0 16px; font: var(--t-body-lg); color: var(--muted); }
|
|
182
|
-
.card.failed h1 { color: var(--fail-text); }
|
|
183
|
-
.code { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; margin: 28px 0; }
|
|
184
|
-
.code output { font: 500 32px/40px var(--mono); letter-spacing: 0.08em; color: var(--text); white-space: nowrap; user-select: all; }
|
|
185
|
-
@media (max-width: 479px) { .card { padding: 32px 20px 24px; } }
|
|
186
|
-
.acts { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin-top: 28px; }
|
|
187
|
-
.acts form { margin: 0; }
|
|
188
|
-
.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); text-decoration: none; cursor: pointer; }
|
|
189
|
-
.pill.primary { background: var(--accent); color: var(--on-accent); font-weight: 500; }
|
|
190
|
-
.pill.primary:hover { filter: brightness(.95); }
|
|
191
|
-
.pill.quiet { background: var(--subtle); color: var(--text); }
|
|
192
|
-
.pill.quiet:hover { background: var(--subtle-hover); }
|
|
193
|
-
.pill.copied { background: var(--accent-subtle); }
|
|
194
|
-
.pill .i-copy, .pill .i-check { display: inline-flex; }
|
|
195
|
-
.pill .i-check, .pill.copied .i-copy { display: none; }
|
|
196
|
-
.pill.copied .i-check { display: inline-flex; }
|
|
197
|
-
.pill .icon { width: 16px; height: 16px; }
|
|
198
|
-
.pill:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
|
|
199
|
-
.follow progress { display: block; width: 100%; height: 6px; margin: 4px 0 20px; accent-color: var(--accent); }
|
|
200
|
-
.follow figure { margin: 0; }
|
|
201
|
-
.follow img { display: block; width: 100%; max-height: 40vh; object-fit: contain; object-position: center top; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); }
|
|
202
|
-
.follow figcaption { margin-top: 8px; font: 12px/16px var(--mono); color: var(--muted); overflow-wrap: anywhere; }
|
|
203
|
-
`;
|
|
204
|
-
/** A page of the Share button's routes (see the top of this file). */
|
|
205
|
-
export const renderSharePage = (page) => {
|
|
206
|
-
const again = page.code === undefined ? page.refresh : page.wait;
|
|
207
|
-
return `<!doctype html>\n${html `<html lang="en">
|
|
208
|
-
<head>
|
|
209
|
-
<meta charset="utf-8" />
|
|
210
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
211
|
-
${again === undefined
|
|
212
|
-
? ''
|
|
213
|
-
: html `<noscript><meta http-equiv="refresh" content="${String(again)}" /></noscript>`}
|
|
214
|
-
<title>${`${page.title} · screw-bugs`}</title>
|
|
215
|
-
${favicon} ${webFonts}
|
|
216
|
-
<style>
|
|
217
|
-
${new Markup(styles + sharePageStyles)}
|
|
218
|
-
</style>
|
|
219
|
-
</head>
|
|
220
|
-
<body
|
|
221
|
-
${page.code === undefined ? '' : new Markup('data-phase="pairing"')}
|
|
222
|
-
${page.follow === undefined
|
|
223
|
-
? ''
|
|
224
|
-
: html `data-phase="following" data-state="${page.follow.state}"
|
|
225
|
-
data-run="${page.follow.run}" data-status="${page.follow.routes.status}"
|
|
226
|
-
data-source="${page.follow.routes.source}" data-encoded="${page.follow.routes.encoded}"`}
|
|
227
|
-
${page.code === undefined || page.wait === undefined
|
|
228
|
-
? ''
|
|
229
|
-
: new Markup(`data-wait="${page.wait}"`)}
|
|
230
|
-
${page.code === undefined && page.follow === undefined && page.refresh !== undefined
|
|
231
|
-
? new Markup(`data-refresh="${page.refresh}"`)
|
|
232
|
-
: ''}
|
|
233
|
-
>
|
|
234
|
-
${menuBar({ ends: html `${githubLink(640)}${themeButton(true)}` })}
|
|
235
|
-
<main>
|
|
236
|
-
<section
|
|
237
|
-
class="${['card', page.failed ? 'failed' : '', page.follow ? 'follow' : ''].filter(Boolean).join(' ')}"
|
|
238
|
-
aria-labelledby="title"
|
|
239
|
-
>
|
|
240
|
-
<h1 id="title">${page.title}</h1>
|
|
241
|
-
<p id="text" aria-live="polite">${page.text}</p>
|
|
242
|
-
${page.follow === undefined
|
|
243
|
-
? ''
|
|
244
|
-
: html `<progress id="bar" aria-label="Upload progress"></progress>
|
|
245
|
-
<figure>
|
|
246
|
-
<img id="shot" alt="The screenshot going up now" hidden />
|
|
247
|
-
<figcaption id="name"></figcaption>
|
|
248
|
-
</figure>`}
|
|
249
|
-
${page.code === undefined
|
|
250
|
-
? ''
|
|
251
|
-
: html `<div class="code">
|
|
252
|
-
<output aria-label="Pairing code">${page.code}</output>
|
|
253
|
-
<button
|
|
254
|
-
id="copy"
|
|
255
|
-
type="button"
|
|
256
|
-
class="pill quiet"
|
|
257
|
-
data-code="${page.code}"
|
|
258
|
-
hidden
|
|
259
|
-
>
|
|
260
|
-
<span class="i-copy">${icon('copy', { size: 16 })}</span
|
|
261
|
-
><span class="i-check">${icon('check', { size: 16 })}</span
|
|
262
|
-
><span class="copy-label">Copy</span>
|
|
263
|
-
</button>
|
|
264
|
-
</div>`}
|
|
265
|
-
${page.link === undefined && page.form === undefined && page.back === undefined
|
|
266
|
-
? ''
|
|
267
|
-
: html `<div class="acts">
|
|
268
|
-
${page.form === undefined
|
|
269
|
-
? ''
|
|
270
|
-
: html `<form method="post" action="${page.form.action}">
|
|
271
|
-
<button type="submit" class="pill primary">${page.form.label}</button>
|
|
272
|
-
</form>`}
|
|
273
|
-
${page.link === undefined
|
|
274
|
-
? ''
|
|
275
|
-
: html `<a
|
|
276
|
-
class="pill primary"
|
|
277
|
-
href="${page.link.href}"
|
|
278
|
-
target="_blank"
|
|
279
|
-
rel="noopener noreferrer"
|
|
280
|
-
>${page.link.text}${icon('external-link', { size: 16 })}</a
|
|
281
|
-
>`}
|
|
282
|
-
${page.back === undefined
|
|
283
|
-
? ''
|
|
284
|
-
: html `<a class="pill quiet" href="${page.back}">Back to the report</a>`}
|
|
285
|
-
</div>`}
|
|
286
|
-
</section>
|
|
287
|
-
</main>
|
|
288
|
-
${new Markup(`<script>${SHARE_PAGE_SCRIPT}</script>`)}
|
|
289
|
-
</body>
|
|
290
|
-
</html>`}`;
|
|
291
|
-
};
|
package/dist/report/shots.d.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { Box } from '../schema/index.js';
|
|
2
|
-
import type { Assets } from './assets.js';
|
|
3
|
-
import { Markup } from './markup.js';
|
|
4
|
-
import { type CaseShot, type CaseView } from './view.js';
|
|
5
|
-
/** A box to draw: one of the agent's highlights, or the element a step acted on. */
|
|
6
|
-
export interface Overlay {
|
|
7
|
-
readonly kind: 'red' | 'green' | 'step';
|
|
8
|
-
readonly box: Box;
|
|
9
|
-
/** Where its element's text and images are inside it, when known: a crop keeps them in. */
|
|
10
|
-
readonly content?: Box | undefined;
|
|
11
|
-
readonly label: string;
|
|
12
|
-
}
|
|
13
|
-
export declare const markWord: {
|
|
14
|
-
readonly red: 'Problem';
|
|
15
|
-
readonly green: 'As expected';
|
|
16
|
-
};
|
|
17
|
-
/** Where to open a report whose screenshots or video cannot load. */
|
|
18
|
-
export declare const OPEN_FROM_RUN_FOLDER = "Open this report from its run folder in a browser";
|
|
19
|
-
/**
|
|
20
|
-
* The frames a screenshot is shown in: zoomed in on its boxes (whole when it has none, they take
|
|
21
|
-
* most of it, or `whole` is asked for), with the boxes drawn over the untouched image, linking to
|
|
22
|
-
* `link`. One frame, or one for wide and one for narrow figures when their crops differ.
|
|
23
|
-
*/
|
|
24
|
-
export declare const framesOf: (options: {
|
|
25
|
-
readonly src: string;
|
|
26
|
-
/** The image's path in the run folder, as the page says it when the image cannot load. */
|
|
27
|
-
readonly file: string;
|
|
28
|
-
readonly link: string;
|
|
29
|
-
/** Opens the image itself in a new tab, not a place in the report. */
|
|
30
|
-
readonly external: boolean;
|
|
31
|
-
readonly size: {
|
|
32
|
-
readonly width: number;
|
|
33
|
-
readonly height: number;
|
|
34
|
-
} | undefined;
|
|
35
|
-
readonly items: ReadonlyArray<Overlay>;
|
|
36
|
-
readonly elements: ReadonlyArray<Box>;
|
|
37
|
-
readonly alt: (zoomed: boolean) => string;
|
|
38
|
-
/** Show the whole image, never a crop. */
|
|
39
|
-
readonly whole?: boolean;
|
|
40
|
-
/** More attributes for each frame's link, such as what the page's script opens with it. */
|
|
41
|
-
readonly attrs?: Markup;
|
|
42
|
-
}) => {
|
|
43
|
-
frames: Markup[];
|
|
44
|
-
zoomed: Markup[];
|
|
45
|
-
};
|
|
46
|
-
/** What a shot is called in the viewer: `Actual`, `Expected`, or the step it was taken at. */
|
|
47
|
-
export declare const shotCaption: (shot: CaseShot) => string;
|
|
48
|
-
/**
|
|
49
|
-
* A screenshot in a case card: a frame zoomed in on its marks (whole when it has none) that opens
|
|
50
|
-
* the screenshot viewer at it (`n`, its place in the case), or the image itself without script.
|
|
51
|
-
* `large` ones (Actual, Expected) carry their label under them.
|
|
52
|
-
*/
|
|
53
|
-
export declare const cardShot: (view: CaseView, shot: CaseShot, n: number, large: boolean, assets: Assets) => Markup;
|
|
54
|
-
/**
|
|
55
|
-
* A screenshot as the viewer shows it: the whole image with its marks (a checkbox shows and hides
|
|
56
|
-
* them, with no script), its name, ID and when it was taken (`time`, a link that plays the video
|
|
57
|
-
* from there), the file, and the legend of its marks.
|
|
58
|
-
*/
|
|
59
|
-
export declare const viewerShot: (shot: CaseShot, time: Markup | string, assets: Assets) => Markup;
|