screw-bugs 0.1.1 → 0.1.3

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.
Files changed (57) hide show
  1. package/README.md +70 -20
  2. package/dist/browser-playwright/launch.js +3 -1
  3. package/dist/browser-playwright/page.d.ts +3 -11
  4. package/dist/browser-playwright/page.js +17 -1
  5. package/dist/browser-playwright/sign-in.d.ts +77 -0
  6. package/dist/browser-playwright/sign-in.js +217 -0
  7. package/dist/build-info.json +3 -3
  8. package/dist/cli/app.js +4 -1
  9. package/dist/cli/commands.js +68 -3
  10. package/dist/cli/exit-codes.d.ts +6 -0
  11. package/dist/cli/exit-codes.js +6 -0
  12. package/dist/cli/mcp.js +17 -3
  13. package/dist/cli/operations.d.ts +31 -3
  14. package/dist/cli/operations.js +95 -3
  15. package/dist/cli/sign-in.d.ts +79 -0
  16. package/dist/cli/sign-in.js +305 -0
  17. package/dist/core/accounts.d.ts +40 -0
  18. package/dist/core/accounts.js +95 -0
  19. package/dist/core/engine.d.ts +8 -4
  20. package/dist/core/engine.js +39 -9
  21. package/dist/core/errors.d.ts +19 -0
  22. package/dist/core/errors.js +6 -0
  23. package/dist/core/index.d.ts +1 -0
  24. package/dist/core/index.js +1 -0
  25. package/dist/core/services.d.ts +77 -8
  26. package/dist/core/services.js +4 -1
  27. package/dist/report/bug.d.ts +2 -2
  28. package/dist/report/bug.js +5 -4
  29. package/dist/report/html.d.ts +1 -1
  30. package/dist/report/html.js +3 -2
  31. package/dist/report/icons.d.ts +2 -0
  32. package/dist/report/icons.js +4 -3
  33. package/dist/report/index.d.ts +2 -1
  34. package/dist/report/index.js +2 -1
  35. package/dist/report/markup.d.ts +2 -13
  36. package/dist/report/markup.js +8 -62
  37. package/dist/report/menu-bar.d.ts +60 -0
  38. package/dist/report/menu-bar.js +153 -0
  39. package/dist/report/player.d.ts +9 -4
  40. package/dist/report/player.js +24 -13
  41. package/dist/report/sign-in.d.ts +41 -0
  42. package/dist/report/sign-in.js +539 -0
  43. package/dist/report/styles.js +10 -34
  44. package/dist/report/walkthrough.d.ts +3 -2
  45. package/dist/report/walkthrough.js +50 -40
  46. package/dist/schema/accounts.d.ts +137 -0
  47. package/dist/schema/accounts.js +112 -0
  48. package/dist/schema/index.d.ts +1 -0
  49. package/dist/schema/index.js +1 -0
  50. package/dist/schema/job.d.ts +27 -6
  51. package/dist/schema/job.js +12 -2
  52. package/dist/schema/ledger.d.ts +5 -1
  53. package/dist/store-local/accounts.d.ts +8 -4
  54. package/dist/store-local/accounts.js +82 -7
  55. package/dist/store-local/paths.d.ts +4 -1
  56. package/dist/store-local/paths.js +4 -1
  57. package/package.json +2 -2
@@ -2,6 +2,7 @@
2
2
  export declare const LUCIDE_SOURCE = "lucide-static@1.70.0";
3
3
  /** Each icon's inner elements, on Lucide's 24 × 24 grid, exactly as Lucide ships them. */
4
4
  export declare const ICONS: {
5
+ readonly 'arrow-right': '<path d="M5 12h14"/><path d="m12 5 7 7-7 7"/>';
5
6
  readonly check: '<path d="M20 6 9 17l-5-5"/>';
6
7
  readonly 'chevron-left': '<path d="m15 18-6-6 6-6"/>';
7
8
  readonly 'chevron-right': '<path d="m9 18 6-6-6-6"/>';
@@ -9,6 +10,7 @@ export declare const ICONS: {
9
10
  readonly 'chevrons-up-down': '<path d="m7 15 5 5 5-5"/><path d="m7 9 5-5 5 5"/>';
10
11
  readonly 'circle-question-mark': '<circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><path d="M12 17h.01"/>';
11
12
  readonly maximize: '<path d="M8 3H5a2 2 0 0 0-2 2v3"/><path d="M21 8V5a2 2 0 0 0-2-2h-3"/><path d="M3 16v3a2 2 0 0 0 2 2h3"/><path d="M16 21h3a2 2 0 0 0 2-2v-3"/>';
13
+ readonly 'file-text': '<path d="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"/><path d="M14 2v5a1 1 0 0 0 1 1h5"/><path d="M10 9H8"/><path d="M16 13H8"/><path d="M16 17H8"/>';
12
14
  readonly keyboard: '<path d="M10 8h.01"/><path d="M12 12h.01"/><path d="M14 8h.01"/><path d="M16 12h.01"/><path d="M18 8h.01"/><path d="M6 8h.01"/><path d="M7 16h10"/><path d="M8 12h.01"/><rect width="20" height="16" x="2" y="4" rx="2"/>';
13
15
  readonly minimize: '<path d="M8 3v3a2 2 0 0 1-2 2H3"/><path d="M21 8h-3a2 2 0 0 1-2-2V3"/><path d="M3 16h3a2 2 0 0 1 2 2v3"/><path d="M16 21v-3a2 2 0 0 1 2-2h3"/>';
14
16
  readonly minus: '<path d="M5 12h14"/>';
@@ -19,9 +19,8 @@
19
19
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20
20
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21
21
  *
22
- * Of these, check, chevron-left, chevron-right, maximize, minus, monitor, moon, share, smartphone and
23
- * x
24
- * are derived from the Feather project, under its MIT License:
22
+ * Of these, check, chevron-left, chevron-right, file-text, maximize, minus, monitor, moon, share,
23
+ * smartphone and x are derived from the Feather project, under its MIT License:
25
24
  *
26
25
  * The MIT License (MIT) (for the icons listed above)
27
26
  *
@@ -49,6 +48,7 @@
49
48
  export const LUCIDE_SOURCE = 'lucide-static@1.70.0';
50
49
  /** Each icon's inner elements, on Lucide's 24 × 24 grid, exactly as Lucide ships them. */
51
50
  export const ICONS = {
51
+ 'arrow-right': '<path d="M5 12h14"/><path d="m12 5 7 7-7 7"/>',
52
52
  check: '<path d="M20 6 9 17l-5-5"/>',
53
53
  'chevron-left': '<path d="m15 18-6-6 6-6"/>',
54
54
  'chevron-right': '<path d="m9 18 6-6-6-6"/>',
@@ -56,6 +56,7 @@ export const ICONS = {
56
56
  'chevrons-up-down': '<path d="m7 15 5 5 5-5"/><path d="m7 9 5-5 5 5"/>',
57
57
  'circle-question-mark': '<circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><path d="M12 17h.01"/>',
58
58
  maximize: '<path d="M8 3H5a2 2 0 0 0-2 2v3"/><path d="M21 8V5a2 2 0 0 0-2-2h-3"/><path d="M3 16v3a2 2 0 0 0 2 2h3"/><path d="M16 21h3a2 2 0 0 0 2-2v-3"/>',
59
+ 'file-text': '<path d="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"/><path d="M14 2v5a1 1 0 0 0 1 1h5"/><path d="M10 9H8"/><path d="M16 13H8"/><path d="M16 17H8"/>',
59
60
  keyboard: '<path d="M10 8h.01"/><path d="M12 12h.01"/><path d="M14 8h.01"/><path d="M16 12h.01"/><path d="M18 8h.01"/><path d="M6 8h.01"/><path d="M7 16h10"/><path d="M8 12h.01"/><rect width="20" height="16" x="2" y="4" rx="2"/>',
60
61
  minimize: '<path d="M8 3v3a2 2 0 0 1-2 2H3"/><path d="M21 8h-3a2 2 0 0 1-2-2V3"/><path d="M3 16h3a2 2 0 0 1 2 2v3"/><path d="M16 21v-3a2 2 0 0 1 2-2h3"/>',
61
62
  minus: '<path d="M5 12h14"/>',
@@ -1,7 +1,8 @@
1
1
  export * from './html.js';
2
2
  export * from './pr-summary.js';
3
- export { SHARE_START_PATH } from './markup.js';
3
+ export { SHARE_START_PATH } from './menu-bar.js';
4
4
  export { stepText } from './view.js';
5
5
  export { hex, hmacSha256, sha256 } from './sha256.js';
6
6
  export { renderWalkthrough, WALKTHROUGH_CSP, WALKTHROUGH_SCRIPT, walkthroughCsp, } from './walkthrough.js';
7
7
  export { AssetBaseUrl, type RenderOptions } from './assets.js';
8
+ export { renderSignInPage, SIGN_IN_CSP, SIGN_IN_SCRIPT } from './sign-in.js';
@@ -1,7 +1,8 @@
1
1
  export * from './html.js';
2
2
  export * from './pr-summary.js';
3
- export { SHARE_START_PATH } from './markup.js';
3
+ export { SHARE_START_PATH } from './menu-bar.js';
4
4
  export { stepText } from './view.js';
5
5
  export { hex, hmacSha256, sha256 } from './sha256.js';
6
6
  export { renderWalkthrough, WALKTHROUGH_CSP, WALKTHROUGH_SCRIPT, walkthroughCsp, } from './walkthrough.js';
7
7
  export { AssetBaseUrl } from './assets.js';
8
+ export { renderSignInPage, SIGN_IN_CSP, SIGN_IN_SCRIPT } from './sign-in.js';
@@ -29,8 +29,6 @@ export declare const favicon: Markup;
29
29
  export declare const webFonts: Markup;
30
30
  /** A Lucide icon (see `icons.ts`) as markup for the page templates. */
31
31
  export declare const icon: (name: IconName, options?: IconOptions) => Markup;
32
- /** Light, dark, or the system's: icons with their names; hidden until the page's script runs. */
33
- export declare const themeSwitch: Markup;
34
32
  /** screw-bugs' website, which the brand links to. */
35
33
  export declare const SITE_URL = "https://screwbugs.dev";
36
34
  /** The project's home, from `package.json`'s `repository`. */
@@ -39,17 +37,8 @@ export declare const REPO_URL = "https://github.com/uxstudioteam/screw-bugs";
39
37
  export declare const statusIcon: (status: CaseStatus) => Markup;
40
38
  /** A status as an icon and its words, such as ✕ Failed. */
41
39
  export declare const statusTag: (status: CaseStatus) => Markup;
42
- /**
43
- * Where a page's Share button starts sharing its run on screw-bugs Cloud: a route of the local
44
- * report server (`src/cli/share.ts`), by absolute path, so it is the server the page came from.
45
- */
46
- export declare const SHARE_START_PATH = "/.screw-bugs/share/start";
47
- /**
48
- * The top row of both pages: the brand (a link to the website), when the run started, and links (the other page, the
49
- * project's GitHub) with the Share button (see `shareButton`) and the theme switch. When the run started is in UTC, saying so, until the
50
- * page's script puts it in the reader's own time (see `PLAYER_JS`).
51
- */
52
- export declare const topBar: (startedAt: string, jobId: string, links: ReadonlyArray<Markup>) => Markup;
40
+ /** The bug of each theme (`bugMark`), for the menu bar (`menu-bar.ts`). */
41
+ export declare const brandMark: Markup;
53
42
  /**
54
43
  * What the user asked, in quotes, clamped to two lines; the page's script offers the rest in place
55
44
  * when it does not fit. Nothing when the job recorded no request.
@@ -1,10 +1,9 @@
1
1
  import { BUG_DARK, BUG_GIF_ON_DARK, BUG_GIF_ON_LIGHT, BUG_LIME, bugStill } from './bug.js';
2
2
  import { iconSvg } from './icons.js';
3
- import { GITHUB_MARK } from './logos.js';
4
- import { formatDate, statusLabel } from './view.js';
3
+ import { statusLabel } from './view.js';
5
4
  /*
6
5
  * The pieces both HTML pages (the report and the walkthrough) are built from: escaped templates,
7
- * safe relative links, status icons, the top bar with the theme switch, and the prompt.
6
+ * safe relative links, status icons, the brand's bug, and the prompt (the top bar: `menu-bar.ts`).
8
7
  */
9
8
  /** Markup that is already safe. Everything else that goes into the page is escaped. */
10
9
  export class Markup {
@@ -51,7 +50,7 @@ export const textParts = (parts) => parts.map((part) => part.kind === 'text'
51
50
  /**
52
51
  * The screw-bugs bug on its 15 × 15 pixel grid, as the design's light and dark favicons draw it:
53
52
  * a dark bug on lime, or lime on dark where the browser is in dark mode (an SVG favicon follows
54
- * `prefers-color-scheme`, which is the tab strip's, not the page's theme switch). Inline, so the
53
+ * `prefers-color-scheme`, which is the tab strip's, not the page's theme button). Inline, so the
55
54
  * page stays one file; the CSP allows `data:` images.
56
55
  */
57
56
  const FAVICON_SVG = "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 15'>" +
@@ -77,35 +76,16 @@ export const favicon = html `<link
77
76
  href="${`data:image/svg+xml,${FAVICON_SVG.replaceAll('#', '%23')}`}"
78
77
  />`;
79
78
  /**
80
- * Geist and Geist Mono from Google Fonts, in exactly the weights the type scale uses (Geist 400,
81
- * 500 and 700; Geist Mono 400 and 500). Offline, or where Google cannot be reached, the pages use
79
+ * Geist and Geist Mono from Google Fonts, in exactly the weights the pages use (Geist 400,
80
+ * 500, 600 for the menu bar (`menu-bar.ts`), and 700; Geist Mono 400 and 500). Offline, or where Google cannot be reached, the pages use
82
81
  * the system fonts after them in `--sans` and `--mono`. The CSPs allow these two hosts only.
83
82
  */
84
- const GOOGLE_FONTS_CSS = 'https://fonts.googleapis.com/css2?family=Geist:wght@400;500;700&family=Geist+Mono:wght@400;500&display=swap';
83
+ const GOOGLE_FONTS_CSS = 'https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500&display=swap';
85
84
  export const webFonts = html `<link rel="preconnect" href="https://fonts.googleapis.com" />
86
85
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
87
86
  <link rel="stylesheet" href="${GOOGLE_FONTS_CSS}" />`;
88
87
  /** A Lucide icon (see `icons.ts`) as markup for the page templates. */
89
88
  export const icon = (name, options) => new Markup(iconSvg(name, options));
90
- const themeButton = (theme, name, icon, pressed) => html `<button
91
- type="button"
92
- data-theme-set="${theme}"
93
- aria-pressed="${String(pressed)}"
94
- aria-label="${name}"
95
- title="${name}"
96
- >
97
- ${icon}
98
- </button>`;
99
- /** Light, dark, or the system's: icons with their names; hidden until the page's script runs. */
100
- export const themeSwitch = html `<div
101
- class="theme"
102
- id="theme"
103
- role="group"
104
- aria-label="Color theme"
105
- hidden
106
- >
107
- ${themeButton('light', 'Light theme', icon('sun', { size: 14 }), false)}${themeButton('dark', 'Dark theme', icon('moon', { size: 14 }), false)}${themeButton('system', 'Theme from system', icon('monitor', { size: 14 }), true)}
108
- </div>`;
109
89
  /** screw-bugs' website, which the brand links to. */
110
90
  export const SITE_URL = 'https://screwbugs.dev';
111
91
  /** The project's home, from `package.json`'s `repository`. */
@@ -140,42 +120,8 @@ const bugMark = (gif, color, theme) => html `<picture class="${`bug bug-${theme}
140
120
  ><source media="(prefers-reduced-motion: reduce)" srcset="${bugStill(color)}" />
141
121
  <img src="${gif}" alt=""
142
122
  /></picture>`;
143
- const brandMark = html `${bugMark(BUG_GIF_ON_LIGHT, BUG_DARK, 'light')}${bugMark(BUG_GIF_ON_DARK, BUG_LIME, 'dark')}`;
144
- /**
145
- * Where a page's Share button starts sharing its run on screw-bugs Cloud: a route of the local
146
- * report server (`src/cli/share.ts`), by absolute path, so it is the server the page came from.
147
- */
148
- export const SHARE_START_PATH = '/.screw-bugs/share/start';
149
- /**
150
- * The Share button: a link to the report server's start of a share. Hidden until the page's script
151
- * finds it was served by the local report server (`http:` on 127.0.0.1 or localhost): opened from
152
- * disk or on a host such as screw-bugs Cloud, there is no server to share it.
153
- */
154
- const shareButton = (jobId) => html `<a
155
- class="share-btn"
156
- href="${`${SHARE_START_PATH}?run=${encodeURIComponent(jobId)}`}"
157
- title="Share this report on screw-bugs Cloud: a link anyone can open for 7 days"
158
- hidden
159
- >${icon('share', { size: 14, strokeWidth: 2.25 })}<span>Share</span></a
160
- >`;
161
- /**
162
- * The top row of both pages: the brand (a link to the website), when the run started, and links (the other page, the
163
- * project's GitHub) with the Share button (see `shareButton`) and the theme switch. When the run started is in UTC, saying so, until the
164
- * page's script puts it in the reader's own time (see `PLAYER_JS`).
165
- */
166
- export const topBar = (startedAt, jobId, links) => html `<header class="top">
167
- <a class="brand" href="${SITE_URL}" rel="noopener noreferrer"
168
- >${brandMark}<span class="brand-name">screwbugs.dev</span></a
169
- >
170
- <time class="when" datetime="${startedAt}">${formatDate(startedAt)}</time>
171
- <nav class="links" aria-label="Links">
172
- ${links.map((link) => html `${link}<span class="sep" data-orientation="vertical" aria-hidden="true"></span>`)}
173
- <a class="gh" href="${REPO_URL}" rel="noopener noreferrer"
174
- >${new Markup(GITHUB_MARK)}GitHub</a
175
- >
176
- ${shareButton(jobId)} ${themeSwitch}
177
- </nav>
178
- </header>`;
123
+ /** The bug of each theme (`bugMark`), for the menu bar (`menu-bar.ts`). */
124
+ export const brandMark = html `${bugMark(BUG_GIF_ON_LIGHT, BUG_DARK, 'light')}${bugMark(BUG_GIF_ON_DARK, BUG_LIME, 'dark')}`;
179
125
  /**
180
126
  * What the user asked, in quotes, clamped to two lines; the page's script offers the rest in place
181
127
  * when it does not fit. Nothing when the job recorded no request.
@@ -0,0 +1,60 @@
1
+ import type { IconName } from './icons.js';
2
+ import { Markup } from './markup.js';
3
+ /** The project on GitHub, as the menu bar names it: `owner/name`. */
4
+ export declare const REPO: string;
5
+ /**
6
+ * Where a page's Share button starts sharing its run on screw-bugs Cloud: a route of the local
7
+ * report server (`src/cli/share.ts`), by absolute path, so it is the server the page came from.
8
+ */
9
+ export declare const SHARE_START_PATH = "/.screw-bugs/share/start";
10
+ /**
11
+ * The Share button, in the place of Cloud's Sign in button: a link to the report server's start of
12
+ * a share. Hidden until the page's script finds it was served by the local report server (`http:`
13
+ * on 127.0.0.1 or localhost): opened from disk or on a host such as screw-bugs Cloud, there is no
14
+ * server to share it.
15
+ */
16
+ export declare const shareButton: (jobId: string) => Markup;
17
+ /**
18
+ * The theme button: light, dark or the system's, in turn, as on Cloud's menu bar; it shows the
19
+ * current one (`THEME_BUTTON_JS` names it and switches). `hidden` until a script shows it, where a
20
+ * page's script may not run.
21
+ */
22
+ export declare const themeButton: (hidden: boolean) => Markup;
23
+ /**
24
+ * The script of the theme button (`themeButton`): `themeCycle(button, key)` names the theme it
25
+ * shows and, on a click, moves to the next one, kept under `key` in `localStorage` where the browser
26
+ * allows (none: not kept). Plain ES2020, without backslashes, for the pages' scripts to include.
27
+ */
28
+ export declare const THEME_BUTTON_JS = "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();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};";
29
+ /** The project on GitHub, by its mark; `owner/name` beside it from `from` px wide. */
30
+ export declare const githubLink: (from: 640 | 1280) => Markup;
31
+ /** A link to another page of the run (report ↔ walkthrough), by its icon and name. */
32
+ export declare const pageLink: (href: string, name: string, mark: IconName, from: 640 | 1280) => Markup;
33
+ /**
34
+ * The bar: the brand (a link to the website), the middle capsule when there is one, and the right
35
+ * capsule (`ends`). `className` adds the page's own classes to the header.
36
+ */
37
+ export declare const menuBar: (options: {
38
+ readonly middle?: Markup;
39
+ readonly ends: Markup;
40
+ readonly className?: string;
41
+ }) => Markup;
42
+ /**
43
+ * The reports' bar (the report's and the walkthrough's): when the run started in the middle, in UTC
44
+ * and saying so until the page's script puts it in the reader's own time (see `PLAYER_JS`); on the
45
+ * right the other page of the run (`other`, when there is one), the project's GitHub, the theme
46
+ * button and the Share button (see `shareButton`). The theme button and Share wait for the script.
47
+ */
48
+ export declare const topBar: (startedAt: string, jobId: string, other: {
49
+ readonly href: string;
50
+ readonly name: string;
51
+ readonly icon: IconName;
52
+ } | undefined) => Markup;
53
+ /**
54
+ * The bar's styles, in the landing's own colors (`--l-*`, which differ a little from the reports'),
55
+ * its sizes and breakpoints: 56 px tall, 72 px from 768 px wide; capsules 40 px tall, the page's
56
+ * background at 70 % over a 12 px blur. The three capsules sit in a grid, the middle one centered
57
+ * between the ends; on a phone (below 640 px) the right capsule keeps only icons and the middle one
58
+ * only the date's shortest form (see `topBar`), so the bar stays one row down to 360 px.
59
+ */
60
+ export declare const menuBarStyles = "\n.menubar { --l-text: #303030; --l-muted: #636363; --l-icon: #000000; }\n@media (prefers-color-scheme: dark) { :root:not([data-theme=\"light\"]) .menubar { --l-text: #eceeec; --l-muted: #afb5ad; --l-icon: #eceeec; } }\n:root[data-theme=\"dark\"] .menubar { --l-text: #eceeec; --l-muted: #afb5ad; --l-icon: #eceeec; }\n.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); }\n.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); }\n.menubar .brand { grid-column: 1; justify-self: start; gap: 8px; padding: 0 16px 0 12px; white-space: nowrap; color: inherit; text-decoration: none; }\n.menubar .mid { grid-column: 2; min-width: 0; padding: 0 16px; font: 400 12px/16px var(--mono); letter-spacing: -0.038em; white-space: nowrap; }\n.menubar .ends { grid-column: 3; justify-self: end; flex: none; gap: 6px; padding: 4px 4px 4px 12px; }\n.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; }\n.menubar .ends a:not(.share-btn):hover { color: var(--l-muted); }\n.menubar .ends .logo, .menubar .ends .icon { width: 16px; height: 16px; }\n.menubar .ends .page .icon { color: var(--l-icon); }\n.menubar .gh .logo path { fill: var(--l-icon); }\n.menubar .from-640, .menubar .from-1280 { display: none; }\n.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; }\n.menubar .theme:hover { background: color-mix(in srgb, var(--l-text) 8%, transparent); }\n.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; }\n:root[data-theme=\"light\"] .menubar .theme .t-light, :root[data-theme=\"dark\"] .menubar .theme .t-dark { display: block; }\n.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; }\n.menubar .share-btn:hover { filter: brightness(.95); }\n/* Three capsules on a phone: the brand by its bug alone, the date without its year, Share by its\n icon (each still named for screen readers). */\n@media (max-width: 639px) {\n .menubar.with-mid .brand { padding: 0 8px; }\n .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; }\n .menubar.with-mid .share-btn { width: 32px; padding: 0; }\n .menubar .when .year { display: none; }\n}\n/* The reports' bar is sticky over a dense page: it keeps the page's background behind it, so no\n text runs between the capsules (the sign-in page's, over a page that does not scroll under it,\n stays see-through). */\n.menubar.solid { background: var(--bg); }\n@media (min-width: 400px) { .menubar .ends { gap: 8px; } }\n@media (min-width: 640px) { .menubar .from-640 { display: inline; } .menubar .share-btn { padding: 0 20px; } }\n@media (min-width: 768px) { .menubar { height: 72px; padding: 0 32px; } .menubar .ends { gap: 12px; } .menubar .share-btn { padding: 0 28px; } }\n@media (min-width: 1280px) { .menubar .from-1280 { display: inline; } }\n@media print { .menubar .theme, .menubar .share-btn { display: none; } }\n";
@@ -0,0 +1,153 @@
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 by the local report server (`http:`
21
+ * on 127.0.0.1 or localhost): opened from disk or on a host such as screw-bugs Cloud, there is no
22
+ * 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). 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();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
+ .menubar .when .year { display: none; }
143
+ }
144
+ /* The reports' bar is sticky over a dense page: it keeps the page's background behind it, so no
145
+ text runs between the capsules (the sign-in page's, over a page that does not scroll under it,
146
+ stays see-through). */
147
+ .menubar.solid { background: var(--bg); }
148
+ @media (min-width: 400px) { .menubar .ends { gap: 8px; } }
149
+ @media (min-width: 640px) { .menubar .from-640 { display: inline; } .menubar .share-btn { padding: 0 20px; } }
150
+ @media (min-width: 768px) { .menubar { height: 72px; padding: 0 32px; } .menubar .ends { gap: 12px; } .menubar .share-btn { padding: 0 28px; } }
151
+ @media (min-width: 1280px) { .menubar .from-1280 { display: inline; } }
152
+ @media print { .menubar .theme, .menubar .share-btn { display: none; } }
153
+ `;
@@ -61,13 +61,18 @@ export declare const controlsBlock: (options: {
61
61
  export declare const share: (ms: number, of: number | undefined) => string;
62
62
  /**
63
63
  * The script both pages start with: the theme (set before anything is painted, kept where the
64
- * browser allows), the Share button (shown only on a page the local report server served: `http:`
65
- * on 127.0.0.1 or localhost), where the sticky top bar ends (`topEdge`), when the run started in the reader's
64
+ * browser allows, and the menu bar's theme button, `THEME_BUTTON_JS`), the Share button (shown only on a page the local report server served: `http:`
65
+ * on 127.0.0.1 or localhost), where the sticky menu bar ends (`topEdge`), when the run started in the reader's
66
66
  * own time zone (`Nov 4, 2026 · 23:50`, with the full date and zone as its title), the prompt's
67
67
  * "Show full prompt" (offered only when it does not fit, measured again whenever the prompt's box
68
68
  * 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:
69
69
  * custom controls, speed, a scrubber that seeks by pointer and by keys, fullscreen (of the video, or
70
- * of the element `full` names; its button turns into "Exit fullscreen" while it is), the space bar,
70
+ * of the element `full` names; where `inPage()` says so, or the browser has no fullscreen, that
71
+ * element gets the class `focus` instead, the page laying itself out as fullscreen would without
72
+ * taking the browser's screen, and Escape leaves it; its button turns into "Exit fullscreen"
73
+ * while it is), the space bar, a click on the video (plays or pauses it, as the play button does;
74
+ * with `expand`, where `o.inPage()` says so (not merely for want of fullscreen), a click on the
75
+ * video or its big play button first lays it out that way and plays),
71
76
  * the URL field (the last address recorded by the time shown), session videos (switched with
72
77
  * `load`, moving on to the next session when one ends) and a video that does not load (its note
73
78
  * takes the player's place, naming the file, while other sessions still play). `none` stops the
@@ -78,4 +83,4 @@ export declare const share: (ms: number, of: number | undefined) => string;
78
83
  * hooks use. The big play button over the video shows from the start until the video first plays
79
84
  * (by whatever control), and never after. Plain ES2020; no backslashes, so it reads the same in the TypeScript source.
80
85
  */
81
- 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('.top');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)};\nconst setTheme=m=>{r.dataset.theme=m;d.querySelectorAll('[data-theme-set]').forEach(b=>b.setAttribute('aria-pressed',String(b.dataset.themeSet===m)))};\nlet theme='system';try{theme=localStorage.getItem(K)||theme}catch(e){}r.dataset.theme=theme;\nconst chrome=()=>{\n setTheme(r.dataset.theme);\n d.querySelectorAll('.theme').forEach(t=>{t.hidden=false});\n if(location.protocol==='http:'&&(location.hostname==='127.0.0.1'||location.hostname==='localhost'))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 e.textContent=p.month+' '+p.day+', '+p.year+' '+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.addEventListener('click',e=>{const b=e.target.closest('[data-theme-set]');if(!b)return;setTheme(b.dataset.themeSet);try{localStorage.setItem(K,b.dataset.themeSet)}catch(x){}});\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(),empty=d.getElementById(p+'-none');let 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',()=>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){note.hidden=false;const a=note.querySelector('a');if(a){a.href=srcs.get(s);a.textContent=srcs.get(s)}}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=()=>{if(!v.error)return;dead.add(cur);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 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 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 if(!d.fullscreenEnabled||!screen.requestFullscreen)full.hidden=true;\n else{full.addEventListener('click',()=>{if(d.fullscreenElement)d.exitFullscreen().catch(()=>{});else screen.requestFullscreen().catch(()=>{})});\n d.addEventListener('fullscreenchange',()=>{const f=d.fullscreenElement===screen;full.classList.toggle('out',f);full.setAttribute('aria-label',f?'Exit fullscreen':'Fullscreen');update()})}\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";
86
+ 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();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:'&&(location.hostname==='127.0.0.1'||location.hostname==='localhost'))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(),empty=d.getElementById(p+'-none');let 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){note.hidden=false;const a=note.querySelector('a');if(a){a.href=srcs.get(s);a.textContent=srcs.get(s)}}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=()=>{if(!v.error)return;dead.add(cur);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 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";
@@ -1,4 +1,5 @@
1
1
  import { html, icon, safeRelative } from './markup.js';
2
+ import { THEME_BUTTON_JS } from './menu-bar.js';
2
3
  import { displayUrl, formatClock, fragmentSeconds, sessionLength } from './view.js';
3
4
  export const playableSessions = (bundle, assets) => (bundle.ledger.sessions ?? []).flatMap((session) => {
4
5
  const path = safeRelative(session.video);
@@ -151,13 +152,18 @@ export const share = (ms, of) => of === undefined || of <= 0
151
152
  : `${Math.round(Math.max(0, Math.min(1, ms / of)) * 1e6) / 1e4}%`;
152
153
  /**
153
154
  * The script both pages start with: the theme (set before anything is painted, kept where the
154
- * browser allows), the Share button (shown only on a page the local report server served: `http:`
155
- * on 127.0.0.1 or localhost), where the sticky top bar ends (`topEdge`), when the run started in the reader's
155
+ * browser allows, and the menu bar's theme button, `THEME_BUTTON_JS`), the Share button (shown only on a page the local report server served: `http:`
156
+ * on 127.0.0.1 or localhost), where the sticky menu bar ends (`topEdge`), when the run started in the reader's
156
157
  * own time zone (`Nov 4, 2026 · 23:50`, with the full date and zone as its title), the prompt's
157
158
  * "Show full prompt" (offered only when it does not fit, measured again whenever the prompt's box
158
159
  * 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:
159
160
  * custom controls, speed, a scrubber that seeks by pointer and by keys, fullscreen (of the video, or
160
- * of the element `full` names; its button turns into "Exit fullscreen" while it is), the space bar,
161
+ * of the element `full` names; where `inPage()` says so, or the browser has no fullscreen, that
162
+ * element gets the class `focus` instead, the page laying itself out as fullscreen would without
163
+ * taking the browser's screen, and Escape leaves it; its button turns into "Exit fullscreen"
164
+ * while it is), the space bar, a click on the video (plays or pauses it, as the play button does;
165
+ * with `expand`, where `o.inPage()` says so (not merely for want of fullscreen), a click on the
166
+ * video or its big play button first lays it out that way and plays),
161
167
  * the URL field (the last address recorded by the time shown), session videos (switched with
162
168
  * `load`, moving on to the next session when one ends) and a video that does not load (its note
163
169
  * takes the player's place, naming the file, while other sessions still play). `none` stops the
@@ -170,22 +176,21 @@ export const share = (ms, of) => of === undefined || of <= 0
170
176
  */
171
177
  export const PLAYER_JS = `const d=document,r=d.documentElement,K='screw-bugs-theme';
172
178
  const still=()=>matchMedia('(prefers-reduced-motion: reduce)').matches;
173
- const topEdge=()=>{const b=d.querySelector('.top');return b?Math.max(0,b.getBoundingClientRect().bottom):0};
179
+ const topEdge=()=>{const b=d.querySelector('.menubar');return b?Math.max(0,b.getBoundingClientRect().bottom):0};
174
180
  const pad=n=>String(n).padStart(2,'0');
175
181
  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)};
176
- const setTheme=m=>{r.dataset.theme=m;d.querySelectorAll('[data-theme-set]').forEach(b=>b.setAttribute('aria-pressed',String(b.dataset.themeSet===m)))};
177
182
  let theme='system';try{theme=localStorage.getItem(K)||theme}catch(e){}r.dataset.theme=theme;
183
+ ${THEME_BUTTON_JS}
178
184
  const chrome=()=>{
179
- setTheme(r.dataset.theme);
180
- d.querySelectorAll('.theme').forEach(t=>{t.hidden=false});
185
+ d.querySelectorAll('.menubar .theme').forEach(b=>{themeCycle(b,K);b.hidden=false});
181
186
  if(location.protocol==='http:'&&(location.hostname==='127.0.0.1'||location.hostname==='localhost'))d.querySelectorAll('a.share-btn').forEach(a=>{a.hidden=false});
182
187
  d.querySelectorAll('time.when[datetime]').forEach(e=>{
183
188
  const t=new Date(e.getAttribute('datetime'));if(isNaN(t.getTime()))return;const p={};
184
189
  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});
185
- e.textContent=p.month+' '+p.day+', '+p.year+' '+String.fromCharCode(183)+' '+p.hour+':'+p.minute;
190
+ const y=d.createElement('span');y.className='year';y.textContent=', '+p.year;
191
+ e.replaceChildren(p.month+' '+p.day,y,' '+String.fromCharCode(183)+' '+p.hour+':'+p.minute);
186
192
  e.title=new Intl.DateTimeFormat('en-US',{dateStyle:'full',timeStyle:'long'}).format(t)}catch(x){}
187
193
  });
188
- d.addEventListener('click',e=>{const b=e.target.closest('[data-theme-set]');if(!b)return;setTheme(b.dataset.themeSet);try{localStorage.setItem(K,b.dataset.themeSet)}catch(x){}});
189
194
  d.querySelectorAll('.prompt').forEach(p=>{
190
195
  const t=p.querySelector('.prompt-text'),b=p.querySelector('.prompt-more');if(!t||!b)return;
191
196
  const fits=()=>{if(!p.classList.contains('open'))b.hidden=t.scrollHeight<=t.clientHeight+1};
@@ -203,7 +208,7 @@ const player=(p,o)=>{
203
208
  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')];
204
209
  v.removeAttribute('controls');c.hidden=false;
205
210
  const big=d.getElementById(p+'-start');
206
- if(big){big.hidden=false;big.addEventListener('click',()=>v.play().catch(()=>{}));v.addEventListener('play',()=>big.remove(),{once:true})}
211
+ if(big){big.hidden=false;big.addEventListener('click',()=>{grow();v.play().catch(()=>{})});v.addEventListener('play',()=>big.remove(),{once:true})}
207
212
  const track=()=>tracks.find(t=>t.dataset.s===cur);
208
213
  const len=()=>{const t=track(),n=t?Number(t.dataset.total):0;return n>0?n:(isFinite(v.duration)?v.duration:0)};
209
214
  const paint=()=>{
@@ -235,6 +240,7 @@ const player=(p,o)=>{
235
240
  v.addEventListener('error',bad);if(v.error)queueMicrotask(bad);
236
241
  v.addEventListener('ended',()=>{if(o.ended&&o.ended())return;const n=next(cur);if(n!==undefined)load(n,0,true,true)});
237
242
  play.addEventListener('click',()=>{if(v.paused)v.play().catch(()=>{});else v.pause()});
243
+ v.addEventListener('click',()=>{if(down!==null)return;if(grow())v.play().catch(()=>{});else play.click()});
238
244
  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)))}));
239
245
  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()};
240
246
  const at=e=>{const b=bar.getBoundingClientRect();return Math.max(0,Math.min(1,(e.clientX-b.left)/b.width))*len()};
@@ -246,9 +252,14 @@ const player=(p,o)=>{
246
252
  const to=by!==undefined?t+by:k==='Home'?0:k==='End'?len():null;if(to===null)return;e.preventDefault();seek(to);
247
253
  });
248
254
  const full=c.querySelector('.full'),screen=o.full||fig.querySelector('.screen');
249
- if(!d.fullscreenEnabled||!screen.requestFullscreen)full.hidden=true;
250
- else{full.addEventListener('click',()=>{if(d.fullscreenElement)d.exitFullscreen().catch(()=>{});else screen.requestFullscreen().catch(()=>{})});
251
- d.addEventListener('fullscreenchange',()=>{const f=d.fullscreenElement===screen;full.classList.toggle('out',f);full.setAttribute('aria-label',f?'Exit fullscreen':'Fullscreen');update()})}
255
+ const api=!!(d.fullscreenEnabled&&screen.requestFullscreen),inPage=()=>!!o.inPage&&(o.inPage()||!api);
256
+ 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()};
257
+ let back=0;const focus=on=>{if(on)back=scrollY;screen.classList.toggle('focus',on);scrollTo({top:on?0:back,behavior:'auto'});mark()};
258
+ const grow=()=>{if(!o.expand||!o.inPage||!o.inPage()||d.fullscreenElement||screen.classList.contains('focus'))return false;focus(true);return true};
259
+ if(!api&&!o.inPage)full.hidden=true;
260
+ 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(()=>{})});
261
+ d.addEventListener('fullscreenchange',mark);
262
+ d.addEventListener('keydown',e=>{if(e.key==='Escape'&&!e.defaultPrevented&&screen.classList.contains('focus')&&!d.querySelector('dialog[open]')){e.preventDefault();focus(false)}})}
252
263
  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()});
253
264
  return {v,load,none,playing,update,len,cur:()=>cur,down:()=>down,has:s=>srcs.has(s)};
254
265
  };