screw-bugs 0.1.8 → 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/browser-playwright/launch.js +27 -10
- package/dist/browser-playwright/page.d.ts +48 -26
- package/dist/browser-playwright/page.js +86 -89
- package/dist/browser-playwright/recorder.d.ts +154 -0
- package/dist/browser-playwright/recorder.js +382 -0
- 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 -554
- 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 -574
- 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 -47
- package/dist/core/video.js +0 -233
- 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/menu-bar.js
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import { GITHUB_MARK } from './logos.js';
|
|
2
|
-
import { brandMark, html, icon, Markup, REPO_URL, SITE_URL } from './markup.js';
|
|
3
|
-
import { formatDate } from './view.js';
|
|
4
|
-
/*
|
|
5
|
-
* The menu bar of every page (the report, the walkthrough and the sign-in page's explainer): the
|
|
6
|
-
* menu bar of screw-bugs Cloud's landing page, without its Sign in button. It is see-through, with
|
|
7
|
-
* its ends in frosted capsules: the brand on the left; the links and the theme button on the right,
|
|
8
|
-
* where the reports also put their Share button, in the place of Cloud's Sign in. A page may put
|
|
9
|
-
* something in a third capsule in the middle (the reports: when the run started).
|
|
10
|
-
*/
|
|
11
|
-
/** The project on GitHub, as the menu bar names it: `owner/name`. */
|
|
12
|
-
export const REPO = REPO_URL.replace('https://github.com/', '');
|
|
13
|
-
/**
|
|
14
|
-
* Where a page's Share button starts sharing its run on screw-bugs Cloud: a route of the local
|
|
15
|
-
* report server (`src/cli/share.ts`), by absolute path, so it is the server the page came from.
|
|
16
|
-
*/
|
|
17
|
-
export const SHARE_START_PATH = '/.screw-bugs/share/start';
|
|
18
|
-
/**
|
|
19
|
-
* The Share button, in the place of Cloud's Sign in button: a link to the report server's start of
|
|
20
|
-
* a share. Hidden until the page's script finds it was served over `http:`, as the local report
|
|
21
|
-
* server serves it (on 127.0.0.1, or a tailnet address with `SCREW_BUGS_REPORT_HOST`): opened from
|
|
22
|
-
* disk or on a host such as screw-bugs Cloud (`https:`), there is no server to share it.
|
|
23
|
-
*/
|
|
24
|
-
export const shareButton = (jobId) => html `<a
|
|
25
|
-
class="share-btn"
|
|
26
|
-
href="${`${SHARE_START_PATH}?run=${encodeURIComponent(jobId)}`}"
|
|
27
|
-
title="Share this report on Screw Bugs Cloud: a link anyone can open for 7 days"
|
|
28
|
-
hidden
|
|
29
|
-
>${icon('share', { size: 16 })}<span class="share-word">Share</span></a
|
|
30
|
-
>`;
|
|
31
|
-
/**
|
|
32
|
-
* The theme button: light, dark or the system's, in turn, as on Cloud's menu bar; it shows the
|
|
33
|
-
* current one (`THEME_BUTTON_JS` names it and switches). `hidden` until a script shows it, where a
|
|
34
|
-
* page's script may not run.
|
|
35
|
-
*/
|
|
36
|
-
export const themeButton = (hidden) => html `<button
|
|
37
|
-
class="theme"
|
|
38
|
-
type="button"
|
|
39
|
-
aria-label="Theme from system. Switch to light theme"
|
|
40
|
-
title="Theme from system"
|
|
41
|
-
${hidden ? new Markup('hidden') : ''}
|
|
42
|
-
>
|
|
43
|
-
<span class="t-system">${icon('monitor', { size: 16 })}</span
|
|
44
|
-
><span class="t-light">${icon('sun', { size: 16 })}</span
|
|
45
|
-
><span class="t-dark">${icon('moon', { size: 16 })}</span>
|
|
46
|
-
</button>`;
|
|
47
|
-
/**
|
|
48
|
-
* The script of the theme button (`themeButton`): `themeCycle(button, key)` names the theme it
|
|
49
|
-
* shows and, on a click, moves to the next one, kept under `key` in `localStorage` where the browser
|
|
50
|
-
* allows (none: not kept). The favicon (`#favicon`, where the page has its own) follows it. Plain ES2020, without backslashes, for the pages' scripts to include.
|
|
51
|
-
*/
|
|
52
|
-
export const THEME_BUTTON_JS = `const themeCycle=(b,key)=>{
|
|
53
|
-
const r=document.documentElement,T=['light','dark','system'],N={light:'Light theme',dark:'Dark theme',system:'Theme from system'};
|
|
54
|
-
const at=()=>{const i=T.indexOf(r.dataset.theme);return i<0?2:i};
|
|
55
|
-
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]]};
|
|
56
|
-
show();
|
|
57
|
-
b.addEventListener('click',()=>{const m=T[(at()+1)%3];r.dataset.theme=m;if(key)try{localStorage.setItem(key,m)}catch(e){}show()});
|
|
58
|
-
};`;
|
|
59
|
-
/**
|
|
60
|
-
* A link in the right capsule: an icon (`.logo` or Lucide's), then its words, underlined in the
|
|
61
|
-
* mono face, as Cloud's GitHub link. The words show from `from` px wide; below, the icon alone,
|
|
62
|
-
* named by `aria-label`.
|
|
63
|
-
*/
|
|
64
|
-
const endLink = (href, mark, words, from, extra) => html `<a
|
|
65
|
-
class="${extra.className}"
|
|
66
|
-
href="${href}"
|
|
67
|
-
${extra.external ? new Markup('target="_blank" rel="noopener noreferrer"') : ''}
|
|
68
|
-
aria-label="${extra.label ?? words}"
|
|
69
|
-
>${mark}<span class="${`words from-${from}`}">${words}</span></a
|
|
70
|
-
>`;
|
|
71
|
-
/** The project on GitHub, by its mark; `owner/name` beside it from `from` px wide. */
|
|
72
|
-
export const githubLink = (from) => endLink(REPO_URL, new Markup(GITHUB_MARK), REPO, from, {
|
|
73
|
-
className: 'gh',
|
|
74
|
-
label: `${REPO} on GitHub`,
|
|
75
|
-
external: true,
|
|
76
|
-
});
|
|
77
|
-
/** A link to another page of the run (report ↔ walkthrough), by its icon and name. */
|
|
78
|
-
export const pageLink = (href, name, mark, from) => endLink(href, icon(mark, { size: 16 }), name, from, { className: 'page' });
|
|
79
|
-
/**
|
|
80
|
-
* The bar: the brand (a link to the website), the middle capsule when there is one, and the right
|
|
81
|
-
* capsule (`ends`). `className` adds the page's own classes to the header.
|
|
82
|
-
*/
|
|
83
|
-
export const menuBar = (options) => html `<header class="${`menubar ${options.className ?? ''}`.trim()}">
|
|
84
|
-
<a class="brand capsule" href="${SITE_URL}" target="_blank" rel="noopener noreferrer"
|
|
85
|
-
>${brandMark}<span class="brand-name">screw bugs</span></a
|
|
86
|
-
>
|
|
87
|
-
${options.middle ? html `<div class="mid capsule">${options.middle}</div>` : ''}
|
|
88
|
-
<nav class="ends capsule" aria-label="Links">${options.ends}</nav>
|
|
89
|
-
</header>`;
|
|
90
|
-
/** `Nov 4, 2026 · 23:50 UTC` with its year in a span, which a phone leaves out. */
|
|
91
|
-
const yearApart = (date) => {
|
|
92
|
-
const parts = /^(.+?)(, \d{4})( .*)$/.exec(date);
|
|
93
|
-
return parts ? html `${parts[1]}<span class="year">${parts[2]}</span>${parts[3]}` : date;
|
|
94
|
-
};
|
|
95
|
-
/**
|
|
96
|
-
* The reports' bar (the report's and the walkthrough's): when the run started in the middle, in UTC
|
|
97
|
-
* and saying so until the page's script puts it in the reader's own time (see `PLAYER_JS`); on the
|
|
98
|
-
* right the other page of the run (`other`, when there is one), the project's GitHub, the theme
|
|
99
|
-
* button and the Share button (see `shareButton`). The theme button and Share wait for the script.
|
|
100
|
-
*/
|
|
101
|
-
export const topBar = (startedAt, jobId, other) => menuBar({
|
|
102
|
-
className: 'with-mid solid',
|
|
103
|
-
middle: html `<time class="when" datetime="${startedAt}"
|
|
104
|
-
>${yearApart(formatDate(startedAt))}</time
|
|
105
|
-
>`,
|
|
106
|
-
ends: html `${other ? pageLink(other.href, other.name, other.icon, 640) : ''}${githubLink(1280)}${themeButton(true)}${shareButton(jobId)}`,
|
|
107
|
-
});
|
|
108
|
-
/**
|
|
109
|
-
* The bar's styles, in the landing's own colors (`--l-*`, which differ a little from the reports'),
|
|
110
|
-
* its sizes and breakpoints: 56 px tall, 72 px from 768 px wide; capsules 40 px tall, the page's
|
|
111
|
-
* background at 70 % over a 12 px blur. The three capsules sit in a grid, the middle one centered
|
|
112
|
-
* between the ends; on a phone (below 640 px) the right capsule keeps only icons and the middle one
|
|
113
|
-
* only the date's shortest form (see `topBar`), so the bar stays one row down to 360 px.
|
|
114
|
-
*/
|
|
115
|
-
export const menuBarStyles = /* css */ `
|
|
116
|
-
.menubar { --l-text: #303030; --l-muted: #636363; --l-icon: #000000; }
|
|
117
|
-
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .menubar { --l-text: #eceeec; --l-muted: #afb5ad; --l-icon: #eceeec; } }
|
|
118
|
-
:root[data-theme="dark"] .menubar { --l-text: #eceeec; --l-muted: #afb5ad; --l-icon: #eceeec; }
|
|
119
|
-
.menubar { position: sticky; top: 0; z-index: 10; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; height: 56px; padding: 0 12px; background: transparent; font: 600 13px/16px var(--sans); letter-spacing: -0.03em; color: var(--l-text); }
|
|
120
|
-
.capsule { display: flex; align-items: center; height: 40px; box-sizing: border-box; border-radius: 999px; background: color-mix(in srgb, var(--bg) 70%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
|
|
121
|
-
.menubar .brand { grid-column: 1; justify-self: start; gap: 8px; padding: 0 16px 0 12px; white-space: nowrap; color: inherit; text-decoration: none; }
|
|
122
|
-
.menubar .mid { grid-column: 2; min-width: 0; padding: 0 16px; font: 400 12px/16px var(--mono); letter-spacing: -0.038em; white-space: nowrap; }
|
|
123
|
-
.menubar .ends { grid-column: 3; justify-self: end; flex: none; gap: 6px; padding: 4px 4px 4px 12px; }
|
|
124
|
-
.menubar .ends a:not(.share-btn) { display: inline-flex; align-items: center; gap: 6px; font: 400 12px/16px var(--mono); letter-spacing: -0.038em; color: inherit; text-decoration: underline; text-underline-offset: 2px; white-space: nowrap; }
|
|
125
|
-
.menubar .ends a:not(.share-btn):hover { color: var(--l-muted); }
|
|
126
|
-
.menubar .ends .logo, .menubar .ends .icon { width: 16px; height: 16px; }
|
|
127
|
-
.menubar .ends .page .icon { color: var(--l-icon); }
|
|
128
|
-
.menubar .gh .logo path { fill: var(--l-icon); }
|
|
129
|
-
.menubar .from-640, .menubar .from-1280 { display: none; }
|
|
130
|
-
.menubar .theme { display: grid; place-items: center; flex: none; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 999px; background: none; color: var(--l-text); cursor: pointer; }
|
|
131
|
-
.menubar .theme:hover { background: color-mix(in srgb, var(--l-text) 8%, transparent); }
|
|
132
|
-
.menubar .theme .t-light, .menubar .theme .t-dark, :root[data-theme="light"] .menubar .theme .t-system, :root[data-theme="dark"] .menubar .theme .t-system { display: none; }
|
|
133
|
-
:root[data-theme="light"] .menubar .theme .t-light, :root[data-theme="dark"] .menubar .theme .t-dark { display: block; }
|
|
134
|
-
.menubar .share-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none; height: 32px; padding: 0 16px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font: 500 14px/20px var(--sans); letter-spacing: -0.02em; text-decoration: none; white-space: nowrap; }
|
|
135
|
-
.menubar .share-btn:hover { filter: brightness(.95); }
|
|
136
|
-
/* Three capsules on a phone: the brand by its bug alone, the date without its year, Share by its
|
|
137
|
-
icon (each still named for screen readers). */
|
|
138
|
-
@media (max-width: 639px) {
|
|
139
|
-
.menubar.with-mid .brand { padding: 0 8px; }
|
|
140
|
-
.menubar.with-mid :is(.brand-name, .share-word) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
|
141
|
-
.menubar.with-mid .share-btn { width: 32px; padding: 0; }
|
|
142
|
-
/* Icon-only links get the theme button's 32 px cell, a target a finger can hit, with the
|
|
143
|
-
capsule's padding and gaps taken in by as much, so it stays as wide. */
|
|
144
|
-
.menubar.with-mid .ends { gap: 0; padding-left: 4px; }
|
|
145
|
-
.menubar.with-mid .ends a:not(.share-btn) { justify-content: center; width: 32px; height: 32px; border-radius: 999px; }
|
|
146
|
-
.menubar .when .year { display: none; }
|
|
147
|
-
}
|
|
148
|
-
/* The reports' bar is sticky over a dense page: it keeps the page's background behind it, so no
|
|
149
|
-
text runs between the capsules (the sign-in page's, over a page that does not scroll under it,
|
|
150
|
-
stays see-through). */
|
|
151
|
-
.menubar.solid { background: var(--bg); }
|
|
152
|
-
@media (min-width: 400px) { .menubar .ends { gap: 8px; } }
|
|
153
|
-
@media (min-width: 640px) { .menubar .from-640 { display: inline; } .menubar .share-btn { padding: 0 20px; } }
|
|
154
|
-
@media (min-width: 768px) { .menubar { height: 72px; padding: 0 32px; } .menubar .ends { gap: 12px; } .menubar .share-btn { padding: 0 28px; } }
|
|
155
|
-
@media (min-width: 1280px) { .menubar .from-1280 { display: inline; } }
|
|
156
|
-
@media print { .menubar .theme, .menubar .share-btn { display: none; } }
|
|
157
|
-
`;
|
package/dist/report/player.d.ts
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import type { ReportBundle } from '../schema/index.js';
|
|
2
|
-
import type { Assets } from './assets.js';
|
|
3
|
-
import { type Value } from './markup.js';
|
|
4
|
-
import { type UrlPoint } from './view.js';
|
|
5
|
-
/** A session whose video can be played here: its number and its URL (its relative path locally). */
|
|
6
|
-
export interface Playable {
|
|
7
|
-
readonly number: number;
|
|
8
|
-
readonly src: string;
|
|
9
|
-
}
|
|
10
|
-
export declare const playableSessions: (bundle: ReportBundle, assets: Assets) => ReadonlyArray<Playable>;
|
|
11
|
-
/**
|
|
12
|
-
* The shape of the recording, width / height, as the run measured its viewport: from a viewport
|
|
13
|
-
* screenshot, else from an action's viewport. Undefined when the run recorded neither; the player
|
|
14
|
-
* then uses the device's usual shape and letterboxes what differs.
|
|
15
|
-
*/
|
|
16
|
-
export declare const recordingShape: (bundle: ReportBundle) => number | undefined;
|
|
17
|
-
/** The recording's shape, width / height, or the device's usual one when the run has none. */
|
|
18
|
-
export declare const shapeOf: (bundle: ReportBundle) => number;
|
|
19
|
-
/** The recording's shape as CSS custom properties: `--ar` for `aspect-ratio`, `--arw` a number. */
|
|
20
|
-
export declare const shapeStyle: (bundle: ReportBundle) => string;
|
|
21
|
-
/**
|
|
22
|
-
* The prompt the "Copy a prompt for your coding agent" button under a video that does not load
|
|
23
|
-
* copies, for the person to paste into their own coding agent. The page's script fills in what
|
|
24
|
-
* only the browser knows: `{video}` (the file that failed, relative to the run folder), `{page}`
|
|
25
|
-
* (the page's address), `{browser}` (its user agent) and `{error}` (what the video element said).
|
|
26
|
-
*/
|
|
27
|
-
export declare const videoFixPrompt: (jobId: string) => string;
|
|
28
|
-
/**
|
|
29
|
-
* The player: the window with its URL field and the video (with a big play button over it, which
|
|
30
|
-
* the script shows until the video first plays, by any control, and never again), the note for a video that does not
|
|
31
|
-
* load, the session videos for the script to switch between, and every recorded address for the
|
|
32
|
-
* URL field to follow. `prefix` names its parts (`<prefix>-video`, `<prefix>-unloaded`, …).
|
|
33
|
-
*/
|
|
34
|
-
export declare const playerWindow: (options: {
|
|
35
|
-
readonly prefix: string;
|
|
36
|
-
readonly sessions: ReadonlyArray<Playable>;
|
|
37
|
-
readonly first: Playable;
|
|
38
|
-
/** Seconds into the first video to show at first. */
|
|
39
|
-
readonly startMs: number;
|
|
40
|
-
readonly urls: ReadonlyArray<UrlPoint>;
|
|
41
|
-
readonly initialUrl: string | undefined;
|
|
42
|
-
/** Drawn over the video (the walkthrough's boxes and cursor). */
|
|
43
|
-
readonly overlay?: Value;
|
|
44
|
-
/** In the window, after the screen (the walkthrough's caption). */
|
|
45
|
-
readonly below?: Value;
|
|
46
|
-
/** What the player says in the video's place while what is chosen has no video (`none`). */
|
|
47
|
-
readonly none?: Value;
|
|
48
|
-
/**
|
|
49
|
-
* The prompt (`videoFixPrompt`) the note for a video that does not load offers to copy; none on a
|
|
50
|
-
* page hosted elsewhere, whose reader has no run folder to fix.
|
|
51
|
-
*/
|
|
52
|
-
readonly fixPrompt?: string;
|
|
53
|
-
readonly extraClass?: string;
|
|
54
|
-
}) => import("./markup.js").Markup;
|
|
55
|
-
/** A switch: a button whose state is `aria-pressed`. */
|
|
56
|
-
export declare const toggleButton: (id: string, label: Value, on: boolean) => import("./markup.js").Markup;
|
|
57
|
-
/**
|
|
58
|
-
* The two lines of controls: time, scrubber, length; then play, speed, the page's toggles and
|
|
59
|
-
* fullscreen. One track per session, with what the page marks on it (`marks`, laid out in shares
|
|
60
|
-
* of the session's length); the script shows the one playing. Hidden until the script runs.
|
|
61
|
-
*/
|
|
62
|
-
export declare const controlsBlock: (options: {
|
|
63
|
-
readonly prefix: string;
|
|
64
|
-
readonly bundle: ReportBundle;
|
|
65
|
-
readonly sessions: ReadonlyArray<Playable>;
|
|
66
|
-
readonly marks: (session: number, lengthMs: number | undefined) => Value;
|
|
67
|
-
/** Whether a track shows how far the video has played (the walkthrough's). */
|
|
68
|
-
readonly progress: boolean;
|
|
69
|
-
readonly toggles: Value;
|
|
70
|
-
readonly label: string;
|
|
71
|
-
}) => import("./markup.js").Markup;
|
|
72
|
-
/** A share of a track, as a CSS percentage. */
|
|
73
|
-
export declare const share: (ms: number, of: number | undefined) => string;
|
|
74
|
-
/**
|
|
75
|
-
* The script both pages start with: the theme (set before anything is painted, kept where the
|
|
76
|
-
* browser allows, and the menu bar's theme button, `THEME_BUTTON_JS`), the Share button (shown only on a page served over `http:`, as the local report server serves
|
|
77
|
-
* it), where the sticky menu bar ends (`topEdge`), when the run started in the reader's
|
|
78
|
-
* own time zone (`Nov 4, 2026 · 23:50`, with the full date and zone as its title), the prompt's
|
|
79
|
-
* "Show full prompt" (offered only when it does not fit, measured again whenever the prompt's box
|
|
80
|
-
* changes size and once the page's fonts have loaded; while open it stays, as "Show less"), and `player(prefix, hooks)`, which takes over the video:
|
|
81
|
-
* custom controls, speed, a scrubber that seeks by pointer and by keys, fullscreen (of the video, or
|
|
82
|
-
* of the element `full` names; where `inPage()` says so, or the browser has no fullscreen, that
|
|
83
|
-
* element gets the class `focus` instead, the page laying itself out as fullscreen would without
|
|
84
|
-
* taking the browser's screen, and Escape leaves it; its button turns into "Exit fullscreen"
|
|
85
|
-
* while it is), the space bar, a click on the video (plays or pauses it, as the play button does;
|
|
86
|
-
* with `expand`, where `o.inPage()` says so (not merely for want of fullscreen), a click on the
|
|
87
|
-
* video or its big play button first lays it out that way and plays),
|
|
88
|
-
* the URL field (the last address recorded by the time shown), session videos (switched with
|
|
89
|
-
* `load`, moving on to the next session when one ends) and a video that does not load (its note
|
|
90
|
-
* takes the player's place, naming the file, while other sessions still play; its button copies
|
|
91
|
-
* `videoFixPrompt` filled in with the file, the page's address, the browser and the error that file's video gave,
|
|
92
|
-
* through the Clipboard API where the page is a secure context, else by selecting it in a text box
|
|
93
|
-
* it shows, which also stays for the reader to copy by hand when the browser would not, until the note shows
|
|
94
|
-
* for another file; a copy still pending then says nothing). `none` stops the
|
|
95
|
-
* player for something chosen that has no video: the video pauses and the `-none` note takes its
|
|
96
|
-
* place until the next `load`. While either note shows, `playing` says whether the video was
|
|
97
|
-
* playing before, so what is chosen next plays on. A video that failed before the script ran is
|
|
98
|
-
* handled as one that fails later, once `player` has returned and the page has the handle its
|
|
99
|
-
* hooks use. The big play button over the video shows from the start until the video first plays
|
|
100
|
-
* (by whatever control), and never after. Plain ES2020; no backslashes, so it reads the same in the TypeScript source.
|
|
101
|
-
*/
|
|
102
|
-
export declare const PLAYER_JS = "const d=document,r=d.documentElement,K='screw-bugs-theme';\nconst still=()=>matchMedia('(prefers-reduced-motion: reduce)').matches;\nconst topEdge=()=>{const b=d.querySelector('.menubar');return b?Math.max(0,b.getBoundingClientRect().bottom):0};\nconst pad=n=>String(n).padStart(2,'0');\nconst clock=s=>{s=Math.max(0,Math.floor(s||0));const h=Math.floor(s/3600),m=Math.floor(s%3600/60);return(h?h+':'+pad(m):String(m))+':'+pad(s%60)};\nlet theme='system';try{theme=localStorage.getItem(K)||theme}catch(e){}r.dataset.theme=theme;\nconst 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};\nconst chrome=()=>{\n d.querySelectorAll('.menubar .theme').forEach(b=>{themeCycle(b,K);b.hidden=false});\n if(location.protocol==='http:')d.querySelectorAll('a.share-btn').forEach(a=>{a.hidden=false});\n d.querySelectorAll('time.when[datetime]').forEach(e=>{\n const t=new Date(e.getAttribute('datetime'));if(isNaN(t.getTime()))return;const p={};\n try{new Intl.DateTimeFormat('en-US',{month:'short',day:'numeric',year:'numeric',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(t).forEach(x=>{p[x.type]=x.value});\n const y=d.createElement('span');y.className='year';y.textContent=', '+p.year;\n e.replaceChildren(p.month+' '+p.day,y,' '+String.fromCharCode(183)+' '+p.hour+':'+p.minute);\n e.title=new Intl.DateTimeFormat('en-US',{dateStyle:'full',timeStyle:'long'}).format(t)}catch(x){}\n });\n d.querySelectorAll('.prompt').forEach(p=>{\n const t=p.querySelector('.prompt-text'),b=p.querySelector('.prompt-more');if(!t||!b)return;\n const fits=()=>{if(!p.classList.contains('open'))b.hidden=t.scrollHeight<=t.clientHeight+1};\n fits();if(window.ResizeObserver)new ResizeObserver(fits).observe(t);if(d.fonts&&d.fonts.ready)d.fonts.ready.then(fits);\n b.addEventListener('click',()=>{const o=p.classList.toggle('open');b.textContent=o?'Show less':'Show full prompt';b.setAttribute('aria-expanded',String(o));fits()});\n });\n};\nconst bare=u=>{const i=u.indexOf('://');return i<0?u:u.slice(i+3)};\nconst player=(p,o)=>{\n const v=d.getElementById(p+'-video'),fig=v.closest('.player'),note=d.getElementById(p+'-unloaded'),c=d.getElementById(p+'-controls'),url=d.getElementById(p+'-url');\n const srcs=new Map([...fig.querySelectorAll('[data-session-src]')].map(e=>[e.dataset.session,e.dataset.sessionSrc]));\n const order=[...srcs.keys()];\n const urls=[...fig.querySelectorAll('[data-url]')].map(e=>({s:e.dataset.s,t:Number(e.dataset.at),u:e.dataset.url}));\n const dead=new Set(),errs=new Map(),empty=d.getElementById(p+'-none');let shown=0,cur=v.dataset.session,down=null,held=false,ask=0,auto=false,rate=1,raf=0,drag=false;\n const play=c.querySelector('.play'),now=c.querySelector('.now'),total=c.querySelector('.total'),bar=c.querySelector('.scrub'),head=c.querySelector('.head'),tracks=[...c.querySelectorAll('.track')];\n v.removeAttribute('controls');c.hidden=false;\n const big=d.getElementById(p+'-start');\n if(big){big.hidden=false;big.addEventListener('click',()=>{grow();v.play().catch(()=>{})});v.addEventListener('play',()=>big.remove(),{once:true})}\n const track=()=>tracks.find(t=>t.dataset.s===cur);\n const len=()=>{const t=track(),n=t?Number(t.dataset.total):0;return n>0?n:(isFinite(v.duration)?v.duration:0)};\n const paint=()=>{\n const L=len(),t=v.currentTime,f=L?Math.min(1,t/L):0,k=track();\n tracks.forEach(x=>{x.hidden=x!==k});head.style.left=(f*100)+'%';\n const done=k&&k.querySelector('.done');if(done)done.style.width=(f*100)+'%';\n now.textContent=clock(t);total.textContent=clock(L);\n bar.setAttribute('aria-valuemax',String(Math.round(L)));bar.setAttribute('aria-valuenow',String(Math.round(t)));bar.setAttribute('aria-valuetext',clock(t)+' of '+clock(L));\n play.classList.toggle('playing',!v.paused);play.setAttribute('aria-label',v.paused?'Play':'Pause');\n if(url){let u='';if(down!=='')for(const x of urls){if(x.s===cur&&x.t<=t+0.02)u=x.u}url.textContent=bare(u);url.parentElement.title=u}\n };\n const update=()=>{paint();if(o.tick)o.tick(v.currentTime)};\n const frame=()=>{update();raf=v.paused?0:requestAnimationFrame(frame)};\n const show=s=>{if(down===null)held=!v.paused;down=s;v.pause();fig.classList.add('broken');c.hidden=true;if(empty)empty.hidden=true;if(note){++shown;note.hidden=false;const a=note.querySelector('a');if(a){a.href=srcs.get(s);a.textContent=srcs.get(s)}const ft=note.querySelector('.fix-text'),fd=note.querySelector('.fix-done');if(ft){ft.hidden=true;ft.value=''}if(fd)fd.textContent=''}if(o.broken)o.broken()};\n const fine=()=>{if(down===null)return;down=null;fig.classList.remove('broken');c.hidden=false;if(note)note.hidden=true;if(empty)empty.hidden=true;if(o.fine)o.fine()};\n const none=()=>{if(down===null)held=!v.paused;++ask;auto=false;down='';v.pause();fig.classList.add('broken');c.hidden=true;if(note)note.hidden=true;if(empty)empty.hidden=false;paint();if(o.broken)o.broken()};\n const playing=()=>down===null?!v.paused:held;\n const next=s=>order.slice(order.indexOf(s)+1).find(n=>!dead.has(n));\n const load=(s,t,go,a)=>{\n const my=++ask;auto=!!a;if(dead.has(s))return show(s);\n if(s!==cur||!v.currentSrc||v.error){cur=s;v.dataset.session=s;v.src=srcs.get(s);v.load()}\n const done=()=>{if(my!==ask)return;auto=false;fine();v.playbackRate=rate;v.currentTime=t;update();if(go)v.play().catch(()=>{})};\n if(v.readyState>0)done();else v.addEventListener('loadedmetadata',done,{once:true});\n };\n const bad=()=>{const e=v.error;if(!e)return;dead.add(cur);errs.set(cur,'error code '+e.code+(e.message?': '+e.message:''));if(down==='')return;const n=auto?next(cur):undefined;if(n!==undefined)return load(n,0,true,true);auto=false;show(cur)};\n ['timeupdate','seeked','loadedmetadata','pause','play','durationchange'].forEach(n=>v.addEventListener(n,update));\n v.addEventListener('play',()=>{if(!raf)raf=requestAnimationFrame(frame)});\n addEventListener('resize',update);\n v.addEventListener('error',bad);if(v.error)queueMicrotask(bad);\n const fix=d.getElementById(p+'-fix');\n if(fix){const box=fix.parentElement,ta=box.querySelector('.fix-text'),said=box.querySelector('.fix-done');\n fix.addEventListener('click',()=>{\n let t=ta.dataset.template||'';\n [['video',down?srcs.get(down)||'':''],['page',location.href],['browser',navigator.userAgent],['error',errs.get(down)||'nothing']].forEach(([k,x])=>{t=t.split('{'+k+'}').join(x)});\n const g=shown;ta.value=t;const ok=()=>{if(g!==shown)return;said.textContent='Copied. Paste it into your coding agent.'};\n const by=()=>{if(g!==shown)return;ta.hidden=false;ta.focus();ta.setSelectionRange(0,t.length);ta.scrollTop=0;let c=false;try{c=d.execCommand('copy')}catch(x){}if(c)ok();else said.textContent='Copy the prompt below.'};\n if(navigator.clipboard&&window.isSecureContext)navigator.clipboard.writeText(t).then(ok,by);else by();\n })}\n v.addEventListener('ended',()=>{if(o.ended&&o.ended())return;const n=next(cur);if(n!==undefined)load(n,0,true,true)});\n play.addEventListener('click',()=>{if(v.paused)v.play().catch(()=>{});else v.pause()});\n v.addEventListener('click',()=>{if(down!==null)return;if(grow())v.play().catch(()=>{});else play.click()});\n c.querySelectorAll('[data-rate]').forEach(b=>b.addEventListener('click',()=>{rate=Number(b.dataset.rate);v.playbackRate=rate;v.defaultPlaybackRate=rate;c.querySelectorAll('[data-rate]').forEach(x=>x.setAttribute('aria-pressed',String(x===b)))}));\n const seek=t=>{const L=len();t=Math.max(0,L?Math.min(L,t):t);v.currentTime=t;if(o.seek)o.seek(t);update()};\n const at=e=>{const b=bar.getBoundingClientRect();return Math.max(0,Math.min(1,(e.clientX-b.left)/b.width))*len()};\n bar.addEventListener('pointerdown',e=>{if(e.button>0||down!==null)return;drag=true;bar.setPointerCapture(e.pointerId);seek(at(e))});\n bar.addEventListener('pointermove',e=>{if(drag)seek(at(e))});\n ['pointerup','pointercancel'].forEach(n=>bar.addEventListener(n,()=>{drag=false}));\n bar.addEventListener('keydown',e=>{\n const k=e.key,t=v.currentTime,by={ArrowLeft:-1,ArrowDown:-1,ArrowRight:1,ArrowUp:1,PageDown:-10,PageUp:10}[k];\n const to=by!==undefined?t+by:k==='Home'?0:k==='End'?len():null;if(to===null)return;e.preventDefault();seek(to);\n });\n const full=c.querySelector('.full'),screen=o.full||fig.querySelector('.screen');\n const api=!!(d.fullscreenEnabled&&screen.requestFullscreen),inPage=()=>!!o.inPage&&(o.inPage()||!api);\n const mark=()=>{const f=d.fullscreenElement===screen||screen.classList.contains('focus');full.classList.toggle('out',f);full.setAttribute('aria-label',f?'Exit fullscreen':'Fullscreen');update()};\n let back=0;const focus=on=>{if(on)back=scrollY;screen.classList.toggle('focus',on);scrollTo({top:on?0:back,behavior:'auto'});mark()};\n const grow=()=>{if(!o.expand||!o.inPage||!o.inPage()||d.fullscreenElement||screen.classList.contains('focus'))return false;focus(true);return true};\n if(!api&&!o.inPage)full.hidden=true;\n else{full.addEventListener('click',()=>{const f=screen.classList.contains('focus');if(d.fullscreenElement){d.exitFullscreen().catch(()=>{});if(f)focus(false)}else if(f)focus(false);else if(inPage())focus(true);else screen.requestFullscreen().catch(()=>{})});\n d.addEventListener('fullscreenchange',mark);\n d.addEventListener('keydown',e=>{if(e.key==='Escape'&&!e.defaultPrevented&&screen.classList.contains('focus')&&!d.querySelector('dialog[open]')){e.preventDefault();focus(false)}})}\n d.addEventListener('keydown',e=>{if(e.key!==' '||down!==null||e.defaultPrevented||d.querySelector('dialog[open]')||e.target.closest('button,a,input,textarea,select,summary,[role=slider]'))return;e.preventDefault();play.click()});\n return {v,load,none,playing,update,len,cur:()=>cur,down:()=>down,has:s=>srcs.has(s)};\n};\n";
|
package/dist/report/player.js
DELETED
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
import { html, icon, safeRelative } from './markup.js';
|
|
2
|
-
import { THEME_BUTTON_JS } from './menu-bar.js';
|
|
3
|
-
import { displayUrl, formatClock, fragmentSeconds, sessionLength } from './view.js';
|
|
4
|
-
export const playableSessions = (bundle, assets) => (bundle.ledger.sessions ?? []).flatMap((session) => {
|
|
5
|
-
const path = safeRelative(session.video);
|
|
6
|
-
return path === undefined ? [] : [{ number: session.number, src: assets.url(path) }];
|
|
7
|
-
});
|
|
8
|
-
/**
|
|
9
|
-
* The shape of the recording, width / height, as the run measured its viewport: from a viewport
|
|
10
|
-
* screenshot, else from an action's viewport. Undefined when the run recorded neither; the player
|
|
11
|
-
* then uses the device's usual shape and letterboxes what differs.
|
|
12
|
-
*/
|
|
13
|
-
export const recordingShape = (bundle) => {
|
|
14
|
-
for (const entry of bundle.ledger.cases) {
|
|
15
|
-
const shot = (entry.shots ?? []).find((s) => !s.fullPage && s.width > 0 && s.height > 0);
|
|
16
|
-
if (shot !== undefined)
|
|
17
|
-
return shot.width / shot.height;
|
|
18
|
-
const view = (entry.steps ?? []).find((s) => (s.action?.viewport?.width ?? 0) > 0 && (s.action?.viewport?.height ?? 0) > 0)?.action?.viewport;
|
|
19
|
-
if (view !== undefined)
|
|
20
|
-
return view.width / view.height;
|
|
21
|
-
}
|
|
22
|
-
return undefined;
|
|
23
|
-
};
|
|
24
|
-
/** The recording's shape, width / height, or the device's usual one when the run has none. */
|
|
25
|
-
export const shapeOf = (bundle) => Math.round((recordingShape(bundle) ?? (bundle.device.kind === 'mobile' ? 9 / 19.5 : 16 / 10)) * 10_000) / 10_000;
|
|
26
|
-
/** The recording's shape as CSS custom properties: `--ar` for `aspect-ratio`, `--arw` a number. */
|
|
27
|
-
export const shapeStyle = (bundle) => `--ar:${shapeOf(bundle)} / 1;--arw:${shapeOf(bundle)}`;
|
|
28
|
-
/**
|
|
29
|
-
* The prompt the "Copy a prompt for your coding agent" button under a video that does not load
|
|
30
|
-
* copies, for the person to paste into their own coding agent. The page's script fills in what
|
|
31
|
-
* only the browser knows: `{video}` (the file that failed, relative to the run folder), `{page}`
|
|
32
|
-
* (the page's address), `{browser}` (its user agent) and `{error}` (what the video element said).
|
|
33
|
-
*/
|
|
34
|
-
export const videoFixPrompt = (jobId) => [
|
|
35
|
-
`The screw-bugs video of run ${jobId} does not play in my browser. Please find out why and help me watch it.`,
|
|
36
|
-
'',
|
|
37
|
-
`- Video: .screw-bugs/runs/${jobId}/{video}`,
|
|
38
|
-
'- Page I opened: {page}',
|
|
39
|
-
'- Browser: {browser}',
|
|
40
|
-
'- What the browser said: {error}',
|
|
41
|
-
'',
|
|
42
|
-
'Check, in this order:',
|
|
43
|
-
"1. Does the video file exist, and is it more than a few KB? If it is missing or empty, run `npx screw-bugs doctor`, fix what it reports (Playwright's ffmpeg records the video), then run the job again.",
|
|
44
|
-
'2. Can this browser play WebM (VP8)? Safari on iPhone and iPad often cannot. If so, tell me which browser to open it in.',
|
|
45
|
-
`3. Was the page opened as a file, or from a server that does not serve the video? Run \`npx screw-bugs report ${jobId}\` and give me the report URL it prints; that server serves the video. It listens on 127.0.0.1 only, so if I am on another device, tell me how to reach it.`,
|
|
46
|
-
'',
|
|
47
|
-
'Do not change or delete anything in the run folder.',
|
|
48
|
-
].join('\n');
|
|
49
|
-
/** What the URL field says at `ms`: the address without its scheme. */
|
|
50
|
-
const urlText = (url) => (url === undefined ? '' : displayUrl(url, 120));
|
|
51
|
-
/**
|
|
52
|
-
* The player: the window with its URL field and the video (with a big play button over it, which
|
|
53
|
-
* the script shows until the video first plays, by any control, and never again), the note for a video that does not
|
|
54
|
-
* load, the session videos for the script to switch between, and every recorded address for the
|
|
55
|
-
* URL field to follow. `prefix` names its parts (`<prefix>-video`, `<prefix>-unloaded`, …).
|
|
56
|
-
*/
|
|
57
|
-
export const playerWindow = (options) => {
|
|
58
|
-
const { prefix, sessions, first, startMs, urls, initialUrl, overlay } = options;
|
|
59
|
-
return html `<figure class="${`player ${options.extraClass ?? ''}`.trim()}">
|
|
60
|
-
<div class="window">
|
|
61
|
-
<div class="toolbar">
|
|
62
|
-
<span class="dots" aria-hidden="true"><i></i><i></i><i></i></span>
|
|
63
|
-
<span class="url" title="${initialUrl ?? ''}"
|
|
64
|
-
><span class="sr">Address: </span
|
|
65
|
-
><span id="${`${prefix}-url`}">${urlText(initialUrl)}</span></span
|
|
66
|
-
>
|
|
67
|
-
</div>
|
|
68
|
-
<div class="screen">
|
|
69
|
-
<video
|
|
70
|
-
id="${`${prefix}-video`}"
|
|
71
|
-
controls
|
|
72
|
-
muted
|
|
73
|
-
preload="metadata"
|
|
74
|
-
playsinline
|
|
75
|
-
data-session="${String(first.number)}"
|
|
76
|
-
src="${`${first.src}#t=${fragmentSeconds(startMs)}`}"
|
|
77
|
-
></video>
|
|
78
|
-
${overlay}
|
|
79
|
-
<button
|
|
80
|
-
type="button"
|
|
81
|
-
class="big-play"
|
|
82
|
-
id="${`${prefix}-start`}"
|
|
83
|
-
aria-label="Play video"
|
|
84
|
-
hidden
|
|
85
|
-
>
|
|
86
|
-
<span>${icon('play', { size: 34, filled: true })}</span>
|
|
87
|
-
</button>
|
|
88
|
-
</div>
|
|
89
|
-
<p class="unloaded-video" id="${`${prefix}-unloaded`}" hidden>
|
|
90
|
-
<strong>Video didn't load:</strong> <a href="${first.src}">${first.src}</a>. Open this page
|
|
91
|
-
from its run folder in a browser, or open the file
|
|
92
|
-
directly.${options.fixPrompt === undefined
|
|
93
|
-
? ''
|
|
94
|
-
: html `<span class="fix-video"
|
|
95
|
-
><button type="button" class="fix-copy" id="${`${prefix}-fix`}">
|
|
96
|
-
Copy a prompt for your coding agent</button
|
|
97
|
-
><span class="fix-done" role="status"></span
|
|
98
|
-
><textarea
|
|
99
|
-
class="fix-text"
|
|
100
|
-
readonly
|
|
101
|
-
rows="8"
|
|
102
|
-
aria-label="Prompt for your coding agent"
|
|
103
|
-
data-template="${options.fixPrompt}"
|
|
104
|
-
hidden
|
|
105
|
-
></textarea>
|
|
106
|
-
</span>`}
|
|
107
|
-
</p>
|
|
108
|
-
${options.none === undefined
|
|
109
|
-
? ''
|
|
110
|
-
: html `<p class="unloaded-video" id="${`${prefix}-none`}" hidden>${options.none}</p>`}
|
|
111
|
-
${options.below ?? ''}
|
|
112
|
-
</div>
|
|
113
|
-
<ul hidden>
|
|
114
|
-
${sessions.map((p) => html `<li data-session="${String(p.number)}" data-session-src="${p.src}">${p.src}</li>`)}
|
|
115
|
-
</ul>
|
|
116
|
-
<ul hidden>
|
|
117
|
-
${urls.map((u) => html `<li
|
|
118
|
-
data-s="${String(u.session)}"
|
|
119
|
-
data-at="${fragmentSeconds(u.ms)}"
|
|
120
|
-
data-url="${u.url}"
|
|
121
|
-
></li>`)}
|
|
122
|
-
</ul>
|
|
123
|
-
</figure>`;
|
|
124
|
-
};
|
|
125
|
-
/* Lucide's play and pause, filled, like the design's; one shows at a time (`.playing`). */
|
|
126
|
-
const playIcons = html `${icon('play', { size: 16, filled: true, className: 'i-play' })}${icon('pause', { size: 16, filled: true, className: 'i-pause' })}`;
|
|
127
|
-
/* Enter and leave fullscreen; one shows at a time (`.out` while fullscreen). */
|
|
128
|
-
const fullIcon = html `${icon('maximize', { size: 18, strokeWidth: 2.25, className: 'i-full' })}${icon('minimize', { size: 18, strokeWidth: 2.25, className: 'i-out' })}`;
|
|
129
|
-
/** A switch: a button whose state is `aria-pressed`. */
|
|
130
|
-
export const toggleButton = (id, label, on) => html `<button type="button" class="toggle" id="${id}" aria-pressed="${String(on)}">
|
|
131
|
-
<span class="knob" aria-hidden="true"></span><span>${label}</span>
|
|
132
|
-
</button>`;
|
|
133
|
-
/**
|
|
134
|
-
* The two lines of controls: time, scrubber, length; then play, speed, the page's toggles and
|
|
135
|
-
* fullscreen. One track per session, with what the page marks on it (`marks`, laid out in shares
|
|
136
|
-
* of the session's length); the script shows the one playing. Hidden until the script runs.
|
|
137
|
-
*/
|
|
138
|
-
export const controlsBlock = (options) => {
|
|
139
|
-
const { prefix, bundle, sessions, marks, progress, toggles } = options;
|
|
140
|
-
const first = sessions[0];
|
|
141
|
-
const firstLength = first === undefined ? undefined : sessionLength(bundle, first.number);
|
|
142
|
-
return html `<div class="controls" id="${`${prefix}-controls`}" hidden>
|
|
143
|
-
<div class="line1">
|
|
144
|
-
<span class="now">0:00</span>
|
|
145
|
-
<div
|
|
146
|
-
class="scrub"
|
|
147
|
-
role="slider"
|
|
148
|
-
tabindex="0"
|
|
149
|
-
aria-label="${options.label}"
|
|
150
|
-
aria-valuemin="0"
|
|
151
|
-
aria-valuemax="${String(Math.round((firstLength ?? 0) / 1000))}"
|
|
152
|
-
aria-valuenow="0"
|
|
153
|
-
>
|
|
154
|
-
${sessions.map((p) => {
|
|
155
|
-
const length = sessionLength(bundle, p.number);
|
|
156
|
-
return html `<div
|
|
157
|
-
class="track"
|
|
158
|
-
data-s="${String(p.number)}"
|
|
159
|
-
data-total="${length === undefined ? '0' : fragmentSeconds(length)}"
|
|
160
|
-
${p === first ? '' : html ` hidden`}
|
|
161
|
-
>
|
|
162
|
-
${marks(p.number, length)}${progress ? html `<span class="done"></span>` : ''}
|
|
163
|
-
</div>`;
|
|
164
|
-
})}
|
|
165
|
-
<span class="head"></span>
|
|
166
|
-
</div>
|
|
167
|
-
<span class="total">${firstLength === undefined ? '0:00' : formatClock(firstLength)}</span>
|
|
168
|
-
</div>
|
|
169
|
-
<div class="line2">
|
|
170
|
-
<button type="button" class="play" aria-label="Play">${playIcons}</button>
|
|
171
|
-
<div class="speed" role="group" aria-label="Playback speed">
|
|
172
|
-
${[0.5, 1, 2, 4].map((rate) => html `<button
|
|
173
|
-
type="button"
|
|
174
|
-
data-rate="${String(rate)}"
|
|
175
|
-
aria-pressed="${String(rate === 1)}"
|
|
176
|
-
>
|
|
177
|
-
${rate}x
|
|
178
|
-
</button>`)}
|
|
179
|
-
</div>
|
|
180
|
-
${toggles}
|
|
181
|
-
<button type="button" class="full" aria-label="Fullscreen">${fullIcon}</button>
|
|
182
|
-
</div>
|
|
183
|
-
</div>`;
|
|
184
|
-
};
|
|
185
|
-
/** A share of a track, as a CSS percentage. */
|
|
186
|
-
export const share = (ms, of) => of === undefined || of <= 0
|
|
187
|
-
? '0%'
|
|
188
|
-
: `${Math.round(Math.max(0, Math.min(1, ms / of)) * 1e6) / 1e4}%`;
|
|
189
|
-
/**
|
|
190
|
-
* The script both pages start with: the theme (set before anything is painted, kept where the
|
|
191
|
-
* browser allows, and the menu bar's theme button, `THEME_BUTTON_JS`), the Share button (shown only on a page served over `http:`, as the local report server serves
|
|
192
|
-
* it), where the sticky menu bar ends (`topEdge`), when the run started in the reader's
|
|
193
|
-
* own time zone (`Nov 4, 2026 · 23:50`, with the full date and zone as its title), the prompt's
|
|
194
|
-
* "Show full prompt" (offered only when it does not fit, measured again whenever the prompt's box
|
|
195
|
-
* changes size and once the page's fonts have loaded; while open it stays, as "Show less"), and `player(prefix, hooks)`, which takes over the video:
|
|
196
|
-
* custom controls, speed, a scrubber that seeks by pointer and by keys, fullscreen (of the video, or
|
|
197
|
-
* of the element `full` names; where `inPage()` says so, or the browser has no fullscreen, that
|
|
198
|
-
* element gets the class `focus` instead, the page laying itself out as fullscreen would without
|
|
199
|
-
* taking the browser's screen, and Escape leaves it; its button turns into "Exit fullscreen"
|
|
200
|
-
* while it is), the space bar, a click on the video (plays or pauses it, as the play button does;
|
|
201
|
-
* with `expand`, where `o.inPage()` says so (not merely for want of fullscreen), a click on the
|
|
202
|
-
* video or its big play button first lays it out that way and plays),
|
|
203
|
-
* the URL field (the last address recorded by the time shown), session videos (switched with
|
|
204
|
-
* `load`, moving on to the next session when one ends) and a video that does not load (its note
|
|
205
|
-
* takes the player's place, naming the file, while other sessions still play; its button copies
|
|
206
|
-
* `videoFixPrompt` filled in with the file, the page's address, the browser and the error that file's video gave,
|
|
207
|
-
* through the Clipboard API where the page is a secure context, else by selecting it in a text box
|
|
208
|
-
* it shows, which also stays for the reader to copy by hand when the browser would not, until the note shows
|
|
209
|
-
* for another file; a copy still pending then says nothing). `none` stops the
|
|
210
|
-
* player for something chosen that has no video: the video pauses and the `-none` note takes its
|
|
211
|
-
* place until the next `load`. While either note shows, `playing` says whether the video was
|
|
212
|
-
* playing before, so what is chosen next plays on. A video that failed before the script ran is
|
|
213
|
-
* handled as one that fails later, once `player` has returned and the page has the handle its
|
|
214
|
-
* hooks use. The big play button over the video shows from the start until the video first plays
|
|
215
|
-
* (by whatever control), and never after. Plain ES2020; no backslashes, so it reads the same in the TypeScript source.
|
|
216
|
-
*/
|
|
217
|
-
export const PLAYER_JS = `const d=document,r=d.documentElement,K='screw-bugs-theme';
|
|
218
|
-
const still=()=>matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
219
|
-
const topEdge=()=>{const b=d.querySelector('.menubar');return b?Math.max(0,b.getBoundingClientRect().bottom):0};
|
|
220
|
-
const pad=n=>String(n).padStart(2,'0');
|
|
221
|
-
const clock=s=>{s=Math.max(0,Math.floor(s||0));const h=Math.floor(s/3600),m=Math.floor(s%3600/60);return(h?h+':'+pad(m):String(m))+':'+pad(s%60)};
|
|
222
|
-
let theme='system';try{theme=localStorage.getItem(K)||theme}catch(e){}r.dataset.theme=theme;
|
|
223
|
-
${THEME_BUTTON_JS}
|
|
224
|
-
const chrome=()=>{
|
|
225
|
-
d.querySelectorAll('.menubar .theme').forEach(b=>{themeCycle(b,K);b.hidden=false});
|
|
226
|
-
if(location.protocol==='http:')d.querySelectorAll('a.share-btn').forEach(a=>{a.hidden=false});
|
|
227
|
-
d.querySelectorAll('time.when[datetime]').forEach(e=>{
|
|
228
|
-
const t=new Date(e.getAttribute('datetime'));if(isNaN(t.getTime()))return;const p={};
|
|
229
|
-
try{new Intl.DateTimeFormat('en-US',{month:'short',day:'numeric',year:'numeric',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(t).forEach(x=>{p[x.type]=x.value});
|
|
230
|
-
const y=d.createElement('span');y.className='year';y.textContent=', '+p.year;
|
|
231
|
-
e.replaceChildren(p.month+' '+p.day,y,' '+String.fromCharCode(183)+' '+p.hour+':'+p.minute);
|
|
232
|
-
e.title=new Intl.DateTimeFormat('en-US',{dateStyle:'full',timeStyle:'long'}).format(t)}catch(x){}
|
|
233
|
-
});
|
|
234
|
-
d.querySelectorAll('.prompt').forEach(p=>{
|
|
235
|
-
const t=p.querySelector('.prompt-text'),b=p.querySelector('.prompt-more');if(!t||!b)return;
|
|
236
|
-
const fits=()=>{if(!p.classList.contains('open'))b.hidden=t.scrollHeight<=t.clientHeight+1};
|
|
237
|
-
fits();if(window.ResizeObserver)new ResizeObserver(fits).observe(t);if(d.fonts&&d.fonts.ready)d.fonts.ready.then(fits);
|
|
238
|
-
b.addEventListener('click',()=>{const o=p.classList.toggle('open');b.textContent=o?'Show less':'Show full prompt';b.setAttribute('aria-expanded',String(o));fits()});
|
|
239
|
-
});
|
|
240
|
-
};
|
|
241
|
-
const bare=u=>{const i=u.indexOf('://');return i<0?u:u.slice(i+3)};
|
|
242
|
-
const player=(p,o)=>{
|
|
243
|
-
const v=d.getElementById(p+'-video'),fig=v.closest('.player'),note=d.getElementById(p+'-unloaded'),c=d.getElementById(p+'-controls'),url=d.getElementById(p+'-url');
|
|
244
|
-
const srcs=new Map([...fig.querySelectorAll('[data-session-src]')].map(e=>[e.dataset.session,e.dataset.sessionSrc]));
|
|
245
|
-
const order=[...srcs.keys()];
|
|
246
|
-
const urls=[...fig.querySelectorAll('[data-url]')].map(e=>({s:e.dataset.s,t:Number(e.dataset.at),u:e.dataset.url}));
|
|
247
|
-
const dead=new Set(),errs=new Map(),empty=d.getElementById(p+'-none');let shown=0,cur=v.dataset.session,down=null,held=false,ask=0,auto=false,rate=1,raf=0,drag=false;
|
|
248
|
-
const play=c.querySelector('.play'),now=c.querySelector('.now'),total=c.querySelector('.total'),bar=c.querySelector('.scrub'),head=c.querySelector('.head'),tracks=[...c.querySelectorAll('.track')];
|
|
249
|
-
v.removeAttribute('controls');c.hidden=false;
|
|
250
|
-
const big=d.getElementById(p+'-start');
|
|
251
|
-
if(big){big.hidden=false;big.addEventListener('click',()=>{grow();v.play().catch(()=>{})});v.addEventListener('play',()=>big.remove(),{once:true})}
|
|
252
|
-
const track=()=>tracks.find(t=>t.dataset.s===cur);
|
|
253
|
-
const len=()=>{const t=track(),n=t?Number(t.dataset.total):0;return n>0?n:(isFinite(v.duration)?v.duration:0)};
|
|
254
|
-
const paint=()=>{
|
|
255
|
-
const L=len(),t=v.currentTime,f=L?Math.min(1,t/L):0,k=track();
|
|
256
|
-
tracks.forEach(x=>{x.hidden=x!==k});head.style.left=(f*100)+'%';
|
|
257
|
-
const done=k&&k.querySelector('.done');if(done)done.style.width=(f*100)+'%';
|
|
258
|
-
now.textContent=clock(t);total.textContent=clock(L);
|
|
259
|
-
bar.setAttribute('aria-valuemax',String(Math.round(L)));bar.setAttribute('aria-valuenow',String(Math.round(t)));bar.setAttribute('aria-valuetext',clock(t)+' of '+clock(L));
|
|
260
|
-
play.classList.toggle('playing',!v.paused);play.setAttribute('aria-label',v.paused?'Play':'Pause');
|
|
261
|
-
if(url){let u='';if(down!=='')for(const x of urls){if(x.s===cur&&x.t<=t+0.02)u=x.u}url.textContent=bare(u);url.parentElement.title=u}
|
|
262
|
-
};
|
|
263
|
-
const update=()=>{paint();if(o.tick)o.tick(v.currentTime)};
|
|
264
|
-
const frame=()=>{update();raf=v.paused?0:requestAnimationFrame(frame)};
|
|
265
|
-
const show=s=>{if(down===null)held=!v.paused;down=s;v.pause();fig.classList.add('broken');c.hidden=true;if(empty)empty.hidden=true;if(note){++shown;note.hidden=false;const a=note.querySelector('a');if(a){a.href=srcs.get(s);a.textContent=srcs.get(s)}const ft=note.querySelector('.fix-text'),fd=note.querySelector('.fix-done');if(ft){ft.hidden=true;ft.value=''}if(fd)fd.textContent=''}if(o.broken)o.broken()};
|
|
266
|
-
const fine=()=>{if(down===null)return;down=null;fig.classList.remove('broken');c.hidden=false;if(note)note.hidden=true;if(empty)empty.hidden=true;if(o.fine)o.fine()};
|
|
267
|
-
const none=()=>{if(down===null)held=!v.paused;++ask;auto=false;down='';v.pause();fig.classList.add('broken');c.hidden=true;if(note)note.hidden=true;if(empty)empty.hidden=false;paint();if(o.broken)o.broken()};
|
|
268
|
-
const playing=()=>down===null?!v.paused:held;
|
|
269
|
-
const next=s=>order.slice(order.indexOf(s)+1).find(n=>!dead.has(n));
|
|
270
|
-
const load=(s,t,go,a)=>{
|
|
271
|
-
const my=++ask;auto=!!a;if(dead.has(s))return show(s);
|
|
272
|
-
if(s!==cur||!v.currentSrc||v.error){cur=s;v.dataset.session=s;v.src=srcs.get(s);v.load()}
|
|
273
|
-
const done=()=>{if(my!==ask)return;auto=false;fine();v.playbackRate=rate;v.currentTime=t;update();if(go)v.play().catch(()=>{})};
|
|
274
|
-
if(v.readyState>0)done();else v.addEventListener('loadedmetadata',done,{once:true});
|
|
275
|
-
};
|
|
276
|
-
const bad=()=>{const e=v.error;if(!e)return;dead.add(cur);errs.set(cur,'error code '+e.code+(e.message?': '+e.message:''));if(down==='')return;const n=auto?next(cur):undefined;if(n!==undefined)return load(n,0,true,true);auto=false;show(cur)};
|
|
277
|
-
['timeupdate','seeked','loadedmetadata','pause','play','durationchange'].forEach(n=>v.addEventListener(n,update));
|
|
278
|
-
v.addEventListener('play',()=>{if(!raf)raf=requestAnimationFrame(frame)});
|
|
279
|
-
addEventListener('resize',update);
|
|
280
|
-
v.addEventListener('error',bad);if(v.error)queueMicrotask(bad);
|
|
281
|
-
const fix=d.getElementById(p+'-fix');
|
|
282
|
-
if(fix){const box=fix.parentElement,ta=box.querySelector('.fix-text'),said=box.querySelector('.fix-done');
|
|
283
|
-
fix.addEventListener('click',()=>{
|
|
284
|
-
let t=ta.dataset.template||'';
|
|
285
|
-
[['video',down?srcs.get(down)||'':''],['page',location.href],['browser',navigator.userAgent],['error',errs.get(down)||'nothing']].forEach(([k,x])=>{t=t.split('{'+k+'}').join(x)});
|
|
286
|
-
const g=shown;ta.value=t;const ok=()=>{if(g!==shown)return;said.textContent='Copied. Paste it into your coding agent.'};
|
|
287
|
-
const by=()=>{if(g!==shown)return;ta.hidden=false;ta.focus();ta.setSelectionRange(0,t.length);ta.scrollTop=0;let c=false;try{c=d.execCommand('copy')}catch(x){}if(c)ok();else said.textContent='Copy the prompt below.'};
|
|
288
|
-
if(navigator.clipboard&&window.isSecureContext)navigator.clipboard.writeText(t).then(ok,by);else by();
|
|
289
|
-
})}
|
|
290
|
-
v.addEventListener('ended',()=>{if(o.ended&&o.ended())return;const n=next(cur);if(n!==undefined)load(n,0,true,true)});
|
|
291
|
-
play.addEventListener('click',()=>{if(v.paused)v.play().catch(()=>{});else v.pause()});
|
|
292
|
-
v.addEventListener('click',()=>{if(down!==null)return;if(grow())v.play().catch(()=>{});else play.click()});
|
|
293
|
-
c.querySelectorAll('[data-rate]').forEach(b=>b.addEventListener('click',()=>{rate=Number(b.dataset.rate);v.playbackRate=rate;v.defaultPlaybackRate=rate;c.querySelectorAll('[data-rate]').forEach(x=>x.setAttribute('aria-pressed',String(x===b)))}));
|
|
294
|
-
const seek=t=>{const L=len();t=Math.max(0,L?Math.min(L,t):t);v.currentTime=t;if(o.seek)o.seek(t);update()};
|
|
295
|
-
const at=e=>{const b=bar.getBoundingClientRect();return Math.max(0,Math.min(1,(e.clientX-b.left)/b.width))*len()};
|
|
296
|
-
bar.addEventListener('pointerdown',e=>{if(e.button>0||down!==null)return;drag=true;bar.setPointerCapture(e.pointerId);seek(at(e))});
|
|
297
|
-
bar.addEventListener('pointermove',e=>{if(drag)seek(at(e))});
|
|
298
|
-
['pointerup','pointercancel'].forEach(n=>bar.addEventListener(n,()=>{drag=false}));
|
|
299
|
-
bar.addEventListener('keydown',e=>{
|
|
300
|
-
const k=e.key,t=v.currentTime,by={ArrowLeft:-1,ArrowDown:-1,ArrowRight:1,ArrowUp:1,PageDown:-10,PageUp:10}[k];
|
|
301
|
-
const to=by!==undefined?t+by:k==='Home'?0:k==='End'?len():null;if(to===null)return;e.preventDefault();seek(to);
|
|
302
|
-
});
|
|
303
|
-
const full=c.querySelector('.full'),screen=o.full||fig.querySelector('.screen');
|
|
304
|
-
const api=!!(d.fullscreenEnabled&&screen.requestFullscreen),inPage=()=>!!o.inPage&&(o.inPage()||!api);
|
|
305
|
-
const mark=()=>{const f=d.fullscreenElement===screen||screen.classList.contains('focus');full.classList.toggle('out',f);full.setAttribute('aria-label',f?'Exit fullscreen':'Fullscreen');update()};
|
|
306
|
-
let back=0;const focus=on=>{if(on)back=scrollY;screen.classList.toggle('focus',on);scrollTo({top:on?0:back,behavior:'auto'});mark()};
|
|
307
|
-
const grow=()=>{if(!o.expand||!o.inPage||!o.inPage()||d.fullscreenElement||screen.classList.contains('focus'))return false;focus(true);return true};
|
|
308
|
-
if(!api&&!o.inPage)full.hidden=true;
|
|
309
|
-
else{full.addEventListener('click',()=>{const f=screen.classList.contains('focus');if(d.fullscreenElement){d.exitFullscreen().catch(()=>{});if(f)focus(false)}else if(f)focus(false);else if(inPage())focus(true);else screen.requestFullscreen().catch(()=>{})});
|
|
310
|
-
d.addEventListener('fullscreenchange',mark);
|
|
311
|
-
d.addEventListener('keydown',e=>{if(e.key==='Escape'&&!e.defaultPrevented&&screen.classList.contains('focus')&&!d.querySelector('dialog[open]')){e.preventDefault();focus(false)}})}
|
|
312
|
-
d.addEventListener('keydown',e=>{if(e.key!==' '||down!==null||e.defaultPrevented||d.querySelector('dialog[open]')||e.target.closest('button,a,input,textarea,select,summary,[role=slider]'))return;e.preventDefault();play.click()});
|
|
313
|
-
return {v,load,none,playing,update,len,cur:()=>cur,down:()=>down,has:s=>srcs.has(s)};
|
|
314
|
-
};
|
|
315
|
-
`;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type ReportBundle } from '../schema/index.js';
|
|
2
|
-
/**
|
|
3
|
-
* A short GitHub-flavored Markdown summary of a run, to paste into (or post on) a pull request:
|
|
4
|
-
* the headline (the agent's, when it wrote one up, else the code's verdict), the counts, what to
|
|
5
|
-
* fix, the cases that did not pass with where their failure is in the video, the video and the
|
|
6
|
-
* screenshots with the agent's highlights drawn in, and where the full report is. Paths are
|
|
7
|
-
* relative to the project root; `reportPath` defaults to the report's.
|
|
8
|
-
*/
|
|
9
|
-
export declare const renderPrSummary: (bundle: ReportBundle, options?: {
|
|
10
|
-
readonly reportPath?: string;
|
|
11
|
-
}) => string;
|