screw-bugs 0.1.2 → 0.1.4

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.
@@ -0,0 +1,157 @@
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). 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
+ `;
@@ -61,8 +61,8 @@ 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:
@@ -83,4 +83,4 @@ export declare const share: (ms: number, of: number | undefined) => string;
83
83
  * hooks use. The big play button over the video shows from the start until the video first plays
84
84
  * (by whatever control), and never after. Plain ES2020; no backslashes, so it reads the same in the TypeScript source.
85
85
  */
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('.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',()=>{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";
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(),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:'&&(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,8 +152,8 @@ 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:
@@ -175,22 +176,21 @@ export const share = (ms, of) => of === undefined || of <= 0
175
176
  */
176
177
  export const PLAYER_JS = `const d=document,r=d.documentElement,K='screw-bugs-theme';
177
178
  const still=()=>matchMedia('(prefers-reduced-motion: reduce)').matches;
178
- 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};
179
180
  const pad=n=>String(n).padStart(2,'0');
180
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)};
181
- const setTheme=m=>{r.dataset.theme=m;d.querySelectorAll('[data-theme-set]').forEach(b=>b.setAttribute('aria-pressed',String(b.dataset.themeSet===m)))};
182
182
  let theme='system';try{theme=localStorage.getItem(K)||theme}catch(e){}r.dataset.theme=theme;
183
+ ${THEME_BUTTON_JS}
183
184
  const chrome=()=>{
184
- setTheme(r.dataset.theme);
185
- d.querySelectorAll('.theme').forEach(t=>{t.hidden=false});
185
+ d.querySelectorAll('.menubar .theme').forEach(b=>{themeCycle(b,K);b.hidden=false});
186
186
  if(location.protocol==='http:'&&(location.hostname==='127.0.0.1'||location.hostname==='localhost'))d.querySelectorAll('a.share-btn').forEach(a=>{a.hidden=false});
187
187
  d.querySelectorAll('time.when[datetime]').forEach(e=>{
188
188
  const t=new Date(e.getAttribute('datetime'));if(isNaN(t.getTime()))return;const p={};
189
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});
190
- 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);
191
192
  e.title=new Intl.DateTimeFormat('en-US',{dateStyle:'full',timeStyle:'long'}).format(t)}catch(x){}
192
193
  });
193
- 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){}});
194
194
  d.querySelectorAll('.prompt').forEach(p=>{
195
195
  const t=p.querySelector('.prompt-text'),b=p.querySelector('.prompt-more');if(!t||!b)return;
196
196
  const fits=()=>{if(!p.classList.contains('open'))b.hidden=t.scrollHeight<=t.clientHeight+1};
@@ -16,7 +16,7 @@ export declare const SIGN_IN_ANIMATION = "https://static.screwbugs.dev/animation
16
16
  * hash is fixed. Frames come by long polling `frame?after=<seq>`; inputs go out in order, one
17
17
  * request at a time, mouse moves merged. `410` from any route means the sign-in ended.
18
18
  */
19
- export declare const SIGN_IN_SCRIPT = "(() => {\n 'use strict';\n const RIVE = 'https://cdn.jsdelivr.net/npm/@rive-app/canvas-lite@2.48.0/', RIVE_JS_SRI = 'sha384-KKLeoe6TCJ0x8AYfmSeeOfpT6u1rpxnG6clu8dKuLNqMImJV40kWrCVhTU7lmcNg', ANIMATION = 'https://static.screwbugs.dev/animations/auth-required.riv';\n // The animation's state while the bug waits by the lock (its `kick` trigger works only then),\n // and how long after the kick the bug has run off, when the browser shows (at most\n // `KICK_WAIT_MAX` after the person started, however long the bug took to reach the lock).\n const WAITING = 'Wait (idle)', KICK_MS = 2300, KICK_WAIT_MAX = 6000;\n const base = location.pathname.replace(/\\/+$/, '');\n const $ = (id) => document.getElementById(id);\n const img = $('screen'), stage = $('stage'), kb = $('keys'), addr = $('addr'), note = $('note');\n let seq = 0, fw = 1280, fh = 800, over = false, saving = false;\n const sleep = (ms) => new Promise((r) => setTimeout(r, ms));\n\n const end = (text) => {\n over = true;\n document.body.classList.add('over');\n note.textContent = text;\n $('ended').textContent = text;\n };\n const GONE = 'This sign-in has ended (it closes after 15 minutes without use), so nothing was saved. Ask your coding agent to start its job again for a new link.';\n\n const queue = [];\n // Inputs per request: under the server's limit (100, and 256 KB with text of up to 2000).\n const BATCH = 50;\n let sending = false;\n // Whether an input may not have reached the browser: Save then asks to check the page first.\n let lost = false;\n const flush = async () => {\n if (sending || over || queue.length === 0) return;\n sending = true;\n const batch = queue.splice(0, BATCH);\n try {\n const r = await fetch(base + '/input', {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify(batch),\n });\n if (r.status === 410) end('This sign-in has ended. You can close this tab.');\n else if (!r.ok) lost = true;\n } catch {\n // It may or may not have been played; sending it again could type twice.\n lost = true;\n await sleep(500);\n }\n if (lost && !over) note.textContent = 'Some input may not have reached the browser; check the page shows what you expect.';\n sending = false;\n flush();\n };\n const send = (input) => {\n // Nothing more goes in once Save was pressed: the session is what the inputs before it made.\n if (saving || over) return;\n const last = queue[queue.length - 1];\n if (input.type === 'mouse' && input.kind === 'move' && last && last.type === 'mouse' && last.kind === 'move') queue[queue.length - 1] = input;\n else queue.push(input);\n flush();\n };\n\n const frames = async () => {\n let failures = 0;\n while (!over) {\n try {\n const r = await fetch(base + '/frame?after=' + seq, { cache: 'no-store' });\n failures = 0;\n if (r.status === 410) return end('This sign-in has ended. You can close this tab.');\n if (r.status === 200) {\n const f = await r.json();\n seq = f.seq; fw = f.width; fh = f.height;\n img.src = 'data:image/jpeg;base64,' + f.jpeg;\n addr.textContent = f.url;\n } else if (r.status !== 204) await sleep(1000);\n } catch {\n // Its server is gone (it ended, or the agent's process stopped): say so rather than wait.\n if (++failures >= 3) return end(GONE);\n await sleep(1000);\n }\n }\n };\n\n let sized;\n const resize = () => {\n clearTimeout(sized);\n sized = setTimeout(() => send({ type: 'viewport', width: Math.round(stage.clientWidth), height: Math.round(stage.clientHeight) }), 250);\n };\n addEventListener('resize', resize);\n\n const at = (e) => {\n const r = img.getBoundingClientRect();\n return {\n x: Math.round(((e.clientX - r.left) * fw) / Math.max(1, r.width)),\n y: Math.round(((e.clientY - r.top) * fh) / Math.max(1, r.height)),\n };\n };\n const button = (b) => (b === 1 ? 'middle' : b === 2 ? 'right' : 'left');\n let touch;\n img.addEventListener('contextmenu', (e) => e.preventDefault());\n img.addEventListener('pointerdown', (e) => {\n e.preventDefault();\n kb.focus({ preventScroll: true });\n img.setPointerCapture(e.pointerId);\n const p = at(e);\n if (e.pointerType === 'mouse') send({ type: 'mouse', kind: 'down', ...p, button: button(e.button), clickCount: Math.min(3, Math.max(1, e.detail || 1)) });\n else touch = { x: e.clientX, y: e.clientY, moved: false };\n });\n img.addEventListener('pointermove', (e) => {\n const p = at(e);\n if (e.pointerType === 'mouse') return send({ type: 'mouse', kind: 'move', ...p });\n if (!touch) return;\n const dx = e.clientX - touch.x, dy = e.clientY - touch.y;\n if (!touch.moved && Math.hypot(dx, dy) < 8) return;\n touch.moved = true;\n const scale = fw / Math.max(1, img.getBoundingClientRect().width);\n send({ type: 'wheel', ...p, dx: Math.round(-dx * scale), dy: Math.round(-dy * scale) });\n touch.x = e.clientX; touch.y = e.clientY;\n });\n img.addEventListener('pointerup', (e) => {\n const p = at(e);\n if (e.pointerType === 'mouse') return send({ type: 'mouse', kind: 'up', ...p, button: button(e.button), clickCount: Math.min(3, Math.max(1, e.detail || 1)) });\n if (touch && !touch.moved) {\n send({ type: 'mouse', kind: 'move', ...p });\n send({ type: 'mouse', kind: 'down', ...p, button: 'left', clickCount: 1 });\n send({ type: 'mouse', kind: 'up', ...p, button: 'left', clickCount: 1 });\n }\n touch = undefined;\n });\n img.addEventListener('pointercancel', () => { touch = undefined; });\n img.addEventListener('wheel', (e) => {\n e.preventDefault();\n const unit = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? fh : 1;\n send({ type: 'wheel', ...at(e), dx: Math.round(e.deltaX * unit), dy: Math.round(e.deltaY * unit) });\n }, { passive: false });\n\n const ignored = new Set(['Shift', 'Control', 'Alt', 'Meta', 'CapsLock', 'Unidentified', 'Dead', 'Process', 'Compose']);\n let composing = false;\n kb.addEventListener('compositionstart', () => { composing = true; });\n kb.addEventListener('compositionend', () => { composing = false; typed(); });\n kb.addEventListener('keydown', (e) => {\n if (e.isComposing || e.keyCode === 229 || ignored.has(e.key)) return;\n // A character typed with AltGr (an @ on many European keyboards, where it also reports Ctrl\n // and Alt) or with Option on a Mac is text, not a shortcut: the box gets it as input.\n const altGraph = e.getModifierState && e.getModifierState('AltGraph');\n if (e.key.length === 1 && (altGraph || (e.altKey && !e.ctrlKey && !e.metaKey))) return;\n const command = e.ctrlKey || e.metaKey || e.altKey;\n // Pasting goes in as text, from the paste itself.\n if (command && e.key.toLowerCase() === 'v') return;\n if (e.key.length === 1 && !command) return;\n e.preventDefault();\n const modifiers = [e.altKey && 'Alt', e.ctrlKey && 'Control', e.metaKey && 'Meta', e.shiftKey && 'Shift'].filter(Boolean);\n send({ type: 'key', key: e.key, modifiers });\n });\n // The box always holds one invisible character, so a phone keyboard's Backspace (often only\n // keyCode 229 or 'Unidentified' on keydown) has something to delete, which shows below.\n const MARK = '\u200B';\n const reset = () => {\n kb.value = MARK;\n kb.setSelectionRange(1, 1);\n };\n const typed = () => {\n if (composing) return;\n const value = kb.value;\n const text = value.split(MARK).join('');\n if (!value.includes(MARK) && !text) send({ type: 'key', key: 'Backspace', modifiers: [] });\n if (text) send({ type: 'text', text: text.slice(0, 2000) });\n reset();\n };\n kb.addEventListener('beforeinput', (e) => {\n // Deleting, as keyboards that send no key for it say it: played as the key itself.\n const key = e.inputType === 'deleteContentBackward' ? 'Backspace' : e.inputType === 'deleteContentForward' ? 'Delete' : undefined;\n if (key === undefined || !e.cancelable) return;\n e.preventDefault();\n send({ type: 'key', key, modifiers: [] });\n });\n kb.addEventListener('input', typed);\n kb.addEventListener('focus', reset);\n reset();\n\n $('back').addEventListener('click', () => send({ type: 'nav', kind: 'back' }));\n $('reload').addEventListener('click', () => send({ type: 'nav', kind: 'reload' }));\n const post = async (route) => {\n const r = await fetch(base + '/' + route, { method: 'POST', headers: { 'content-type': 'application/json' }, body: '{}' });\n return r;\n };\n /** Until every input already given has been played (or the sign-in ended). */\n const drained = async () => {\n while (!over && (sending || queue.length > 0)) await sleep(50);\n };\n $('save').addEventListener('click', async () => {\n if (saving || over) return;\n saving = true;\n document.body.classList.add('saving');\n note.textContent = 'Saving\u2026';\n try {\n await drained();\n if (over) return;\n if (lost) {\n lost = false;\n saving = false;\n document.body.classList.remove('saving');\n note.textContent = 'Some input did not reach the browser, so nothing was saved yet. Check the page shows you signed in, then press Save sign-in again.';\n return;\n }\n const r = await post('save');\n if (r.ok) return end('Saved. You can close this tab; your coding agent can start the run again.');\n if (r.status === 410) return end('This sign-in has ended. You can close this tab.');\n note.textContent = 'Could not save: ' + (await r.text());\n } catch {\n note.textContent = 'Could not reach screw-bugs to save. Try again.';\n }\n saving = false;\n document.body.classList.remove('saving');\n });\n $('cancel').addEventListener('click', async () => {\n try { await post('cancel'); } catch {}\n end('Cancelled. Nothing was saved. You can close this tab.');\n });\n\n // The theme: light, dark or the system's, in turn, as on screw-bugs Cloud's menu bar; the button\n // shows the current one (the reports' tokens follow `data-theme`).\n const root = document.documentElement, themes = ['light', 'dark', 'system'];\n const names = { light: 'Light theme', dark: 'Dark theme', system: 'Theme from system' };\n $('theme').addEventListener('click', (e) => {\n const now = themes.indexOf(root.dataset.theme || 'system');\n const theme = themes[(now + 1) % themes.length], after = themes[(now + 2) % themes.length];\n root.dataset.theme = theme;\n e.currentTarget.setAttribute('aria-label', names[theme] + '. Switch to ' + names[after].toLowerCase());\n e.currentTarget.title = names[theme];\n });\n\n // The animation: the bug waits by a lock, and kicks it open when the person starts. It plays\n // with Rive's runtime from its CDN (taken only with the hash it was published with) and the file\n // from screw-bugs' CDN. Without either, or where the person prefers less motion, the page is the\n // same without it.\n const art = $('art');\n // `instance` from when it is made, `rive` once its file loaded; `stopped` once the art is gone\n // for good (it failed, or the person started), so nothing that loads later plays.\n let instance, rive, observer, stopped = false, waiting = false, onWaiting;\n const noArt = () => {\n stopped = true;\n if (art) art.hidden = true;\n if (observer) observer.disconnect();\n try {\n if (instance) instance.cleanup();\n } catch {}\n instance = rive = observer = undefined;\n };\n if (art && !matchMedia('(prefers-reduced-motion: reduce)').matches) {\n const runtime = document.createElement('script');\n runtime.src = RIVE + 'rive.js';\n runtime.integrity = RIVE_JS_SRI;\n runtime.crossOrigin = 'anonymous';\n runtime.onerror = noArt;\n runtime.onload = () => {\n if (stopped) return;\n try {\n const R = window.rive;\n // The runtime is pinned, so the state changes it still gives are what this relies on.\n R.Rive.suppressDeprecationWarnings = ['state-change-events'];\n R.RuntimeLoader.setWasmUrl(RIVE + 'rive.wasm');\n R.RuntimeLoader.setWasmFallbackUrl(RIVE + 'rive_fallback.wasm');\n const canvas = art.querySelector('canvas');\n const r = new R.Rive({\n src: ANIMATION,\n canvas,\n autoplay: true,\n stateMachine: 'Main',\n // Binds the file's view model, whose `kick` trigger starts the kick.\n autoBind: true,\n layout: new R.Layout({ fit: R.Fit.Contain, alignment: R.Alignment.Center }),\n onLoad: () => {\n if (stopped) return;\n r.resizeDrawingSurfaceToCanvas();\n rive = r;\n },\n onLoadError: noArt,\n onStateChange: (e) => {\n for (const name of [].concat(e.data || [])) {\n if (name === WAITING) waiting = true;\n else if (name === 'Arrive' || name === 'Kick') waiting = false;\n }\n if (waiting && onWaiting) onWaiting();\n },\n });\n instance = r;\n observer = new ResizeObserver(() => rive && rive.resizeDrawingSurfaceToCanvas());\n observer.observe(canvas);\n } catch {\n noArt();\n }\n };\n document.head.appendChild(runtime);\n } else noArt();\n /** Plays the kick (once the bug waits by the lock), resolving when the bug has run off. */\n const kick = () =>\n new Promise((done) => {\n if (!rive) return done();\n const cap = setTimeout(done, KICK_WAIT_MAX);\n onWaiting = () => {\n onWaiting = undefined;\n try {\n rive.viewModelInstance.trigger('kick').trigger();\n } catch {\n clearTimeout(cap);\n return done();\n }\n setTimeout(() => {\n clearTimeout(cap);\n done();\n }, KICK_MS);\n };\n if (waiting) onWaiting();\n });\n\n // The explainer comes first; the browser shows (and its frames start) once the person starts.\n let starting = false;\n $('start').addEventListener('click', async () => {\n if (starting || over) return;\n starting = true;\n $('start').setAttribute('aria-disabled', 'true');\n // Reading this takes no requests, so the sign-in may have ended meanwhile.\n try {\n const r = await fetch(base + '/status', { cache: 'no-store' });\n if (!r.ok) return end(GONE);\n } catch {\n return end(GONE);\n }\n await kick();\n noArt();\n if (over) return;\n document.body.classList.remove('intro');\n resize();\n frames();\n });\n})();";
19
+ export declare const SIGN_IN_SCRIPT = "(() => {\n 'use strict';\n const RIVE = 'https://cdn.jsdelivr.net/npm/@rive-app/canvas-lite@2.48.0/', RIVE_JS_SRI = 'sha384-KKLeoe6TCJ0x8AYfmSeeOfpT6u1rpxnG6clu8dKuLNqMImJV40kWrCVhTU7lmcNg', ANIMATION = 'https://static.screwbugs.dev/animations/auth-required.riv';\n // The animation's state while the bug waits by the lock (its `kick` trigger works only then),\n // and how long after the kick the bug has run off, when the browser shows (at most\n // `KICK_WAIT_MAX` after the person started, however long the bug took to reach the lock).\n const WAITING = 'Wait (idle)', KICK_MS = 2300, KICK_WAIT_MAX = 6000;\n const base = location.pathname.replace(/\\/+$/, '');\n const $ = (id) => document.getElementById(id);\n const img = $('screen'), stage = $('stage'), kb = $('keys'), addr = $('addr'), note = $('note');\n let seq = 0, fw = 1280, fh = 800, over = false, saving = false;\n const sleep = (ms) => new Promise((r) => setTimeout(r, ms));\n\n const end = (text) => {\n over = true;\n document.body.classList.add('over');\n note.textContent = text;\n $('ended').textContent = text;\n };\n const GONE = 'This sign-in has ended (it closes after 15 minutes without use), so nothing was saved. Ask your coding agent to start its job again for a new link.';\n\n const queue = [];\n // Inputs per request: under the server's limit (100, and 256 KB with text of up to 2000).\n const BATCH = 50;\n let sending = false;\n // Whether an input may not have reached the browser: Save then asks to check the page first.\n let lost = false;\n const flush = async () => {\n if (sending || over || queue.length === 0) return;\n sending = true;\n const batch = queue.splice(0, BATCH);\n try {\n const r = await fetch(base + '/input', {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify(batch),\n });\n if (r.status === 410) end('This sign-in has ended. You can close this tab.');\n else if (!r.ok) lost = true;\n } catch {\n // It may or may not have been played; sending it again could type twice.\n lost = true;\n await sleep(500);\n }\n if (lost && !over) note.textContent = 'Some input may not have reached the browser; check the page shows what you expect.';\n sending = false;\n flush();\n };\n const send = (input) => {\n // Nothing more goes in once Save was pressed: the session is what the inputs before it made.\n if (saving || over) return;\n const last = queue[queue.length - 1];\n if (input.type === 'mouse' && input.kind === 'move' && last && last.type === 'mouse' && last.kind === 'move') queue[queue.length - 1] = input;\n else queue.push(input);\n flush();\n };\n\n const frames = async () => {\n let failures = 0;\n while (!over) {\n try {\n const r = await fetch(base + '/frame?after=' + seq, { cache: 'no-store' });\n failures = 0;\n if (r.status === 410) return end('This sign-in has ended. You can close this tab.');\n if (r.status === 200) {\n const f = await r.json();\n seq = f.seq; fw = f.width; fh = f.height;\n img.src = 'data:image/jpeg;base64,' + f.jpeg;\n addr.textContent = f.url;\n } else if (r.status !== 204) await sleep(1000);\n } catch {\n // Its server is gone (it ended, or the agent's process stopped): say so rather than wait.\n if (++failures >= 3) return end(GONE);\n await sleep(1000);\n }\n }\n };\n\n let sized;\n const resize = () => {\n clearTimeout(sized);\n sized = setTimeout(() => send({ type: 'viewport', width: Math.round(stage.clientWidth), height: Math.round(stage.clientHeight) }), 250);\n };\n addEventListener('resize', resize);\n\n const at = (e) => {\n const r = img.getBoundingClientRect();\n return {\n x: Math.round(((e.clientX - r.left) * fw) / Math.max(1, r.width)),\n y: Math.round(((e.clientY - r.top) * fh) / Math.max(1, r.height)),\n };\n };\n const button = (b) => (b === 1 ? 'middle' : b === 2 ? 'right' : 'left');\n let touch;\n img.addEventListener('contextmenu', (e) => e.preventDefault());\n img.addEventListener('pointerdown', (e) => {\n e.preventDefault();\n kb.focus({ preventScroll: true });\n img.setPointerCapture(e.pointerId);\n const p = at(e);\n if (e.pointerType === 'mouse') send({ type: 'mouse', kind: 'down', ...p, button: button(e.button), clickCount: Math.min(3, Math.max(1, e.detail || 1)) });\n else touch = { x: e.clientX, y: e.clientY, moved: false };\n });\n img.addEventListener('pointermove', (e) => {\n const p = at(e);\n if (e.pointerType === 'mouse') return send({ type: 'mouse', kind: 'move', ...p });\n if (!touch) return;\n const dx = e.clientX - touch.x, dy = e.clientY - touch.y;\n if (!touch.moved && Math.hypot(dx, dy) < 8) return;\n touch.moved = true;\n const scale = fw / Math.max(1, img.getBoundingClientRect().width);\n send({ type: 'wheel', ...p, dx: Math.round(-dx * scale), dy: Math.round(-dy * scale) });\n touch.x = e.clientX; touch.y = e.clientY;\n });\n img.addEventListener('pointerup', (e) => {\n const p = at(e);\n if (e.pointerType === 'mouse') return send({ type: 'mouse', kind: 'up', ...p, button: button(e.button), clickCount: Math.min(3, Math.max(1, e.detail || 1)) });\n if (touch && !touch.moved) {\n send({ type: 'mouse', kind: 'move', ...p });\n send({ type: 'mouse', kind: 'down', ...p, button: 'left', clickCount: 1 });\n send({ type: 'mouse', kind: 'up', ...p, button: 'left', clickCount: 1 });\n }\n touch = undefined;\n });\n img.addEventListener('pointercancel', () => { touch = undefined; });\n img.addEventListener('wheel', (e) => {\n e.preventDefault();\n const unit = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? fh : 1;\n send({ type: 'wheel', ...at(e), dx: Math.round(e.deltaX * unit), dy: Math.round(e.deltaY * unit) });\n }, { passive: false });\n\n const ignored = new Set(['Shift', 'Control', 'Alt', 'Meta', 'CapsLock', 'Unidentified', 'Dead', 'Process', 'Compose']);\n let composing = false;\n kb.addEventListener('compositionstart', () => { composing = true; });\n kb.addEventListener('compositionend', () => { composing = false; typed(); });\n kb.addEventListener('keydown', (e) => {\n if (e.isComposing || e.keyCode === 229 || ignored.has(e.key)) return;\n // A character typed with AltGr (an @ on many European keyboards, where it also reports Ctrl\n // and Alt) or with Option on a Mac is text, not a shortcut: the box gets it as input.\n const altGraph = e.getModifierState && e.getModifierState('AltGraph');\n if (e.key.length === 1 && (altGraph || (e.altKey && !e.ctrlKey && !e.metaKey))) return;\n const command = e.ctrlKey || e.metaKey || e.altKey;\n // Pasting goes in as text, from the paste itself.\n if (command && e.key.toLowerCase() === 'v') return;\n if (e.key.length === 1 && !command) return;\n e.preventDefault();\n const modifiers = [e.altKey && 'Alt', e.ctrlKey && 'Control', e.metaKey && 'Meta', e.shiftKey && 'Shift'].filter(Boolean);\n send({ type: 'key', key: e.key, modifiers });\n });\n // The box always holds one invisible character, so a phone keyboard's Backspace (often only\n // keyCode 229 or 'Unidentified' on keydown) has something to delete, which shows below.\n const MARK = '\u200B';\n const reset = () => {\n kb.value = MARK;\n kb.setSelectionRange(1, 1);\n };\n const typed = () => {\n if (composing) return;\n const value = kb.value;\n const text = value.split(MARK).join('');\n if (!value.includes(MARK) && !text) send({ type: 'key', key: 'Backspace', modifiers: [] });\n if (text) send({ type: 'text', text: text.slice(0, 2000) });\n reset();\n };\n kb.addEventListener('beforeinput', (e) => {\n // Deleting, as keyboards that send no key for it say it: played as the key itself.\n const key = e.inputType === 'deleteContentBackward' ? 'Backspace' : e.inputType === 'deleteContentForward' ? 'Delete' : undefined;\n if (key === undefined || !e.cancelable) return;\n e.preventDefault();\n send({ type: 'key', key, modifiers: [] });\n });\n kb.addEventListener('input', typed);\n kb.addEventListener('focus', reset);\n reset();\n\n $('back').addEventListener('click', () => send({ type: 'nav', kind: 'back' }));\n $('reload').addEventListener('click', () => send({ type: 'nav', kind: 'reload' }));\n const post = async (route) => {\n const r = await fetch(base + '/' + route, { method: 'POST', headers: { 'content-type': 'application/json' }, body: '{}' });\n return r;\n };\n /** Until every input already given has been played (or the sign-in ended). */\n const drained = async () => {\n while (!over && (sending || queue.length > 0)) await sleep(50);\n };\n $('save').addEventListener('click', async () => {\n if (saving || over) return;\n saving = true;\n document.body.classList.add('saving');\n note.textContent = 'Saving\u2026';\n try {\n await drained();\n if (over) return;\n if (lost) {\n lost = false;\n saving = false;\n document.body.classList.remove('saving');\n note.textContent = 'Some input did not reach the browser, so nothing was saved yet. Check the page shows you signed in, then press Save sign-in again.';\n return;\n }\n const r = await post('save');\n if (r.ok) return end('Saved. You can close this tab; your coding agent can start the run again.');\n if (r.status === 410) return end('This sign-in has ended. You can close this tab.');\n note.textContent = 'Could not save: ' + (await r.text());\n } catch {\n note.textContent = 'Could not reach screw-bugs to save. Try again.';\n }\n saving = false;\n document.body.classList.remove('saving');\n });\n $('cancel').addEventListener('click', async () => {\n try { await post('cancel'); } catch {}\n end('Cancelled. Nothing was saved. You can close this tab.');\n });\n\n // The theme: light, dark or the system's, in turn, as on screw-bugs Cloud's menu bar (the\n // reports' tokens follow `data-theme`). Not kept: each sign-in is a new origin.\n const themeCycle=(b,key)=>{\n const r=document.documentElement,T=['light','dark','system'],N={light:'Light theme',dark:'Dark theme',system:'Theme from system'};\n const at=()=>{const i=T.indexOf(r.dataset.theme);return i<0?2:i};\n const show=()=>{const i=at(),f=document.getElementById('favicon'),h=f&&f.dataset[T[i]];if(h)f.href=h;b.setAttribute('aria-label',N[T[i]]+'. Switch to '+N[T[(i+1)%3]].toLowerCase());b.title=N[T[i]]};\n show();\n b.addEventListener('click',()=>{const m=T[(at()+1)%3];r.dataset.theme=m;if(key)try{localStorage.setItem(key,m)}catch(e){}show()});\n};\n themeCycle(document.querySelector('.menubar .theme'));\n\n // The animation: the bug waits by a lock, and kicks it open when the person starts. It plays\n // with Rive's runtime from its CDN (taken only with the hash it was published with) and the file\n // from screw-bugs' CDN. Without either, or where the person prefers less motion, the page is the\n // same without it.\n const art = $('art');\n // `instance` from when it is made, `rive` once its file loaded; `stopped` once the art is gone\n // for good (it failed, or the person started), so nothing that loads later plays.\n let instance, rive, observer, stopped = false, waiting = false, onWaiting;\n const noArt = () => {\n stopped = true;\n if (art) art.hidden = true;\n if (observer) observer.disconnect();\n try {\n if (instance) instance.cleanup();\n } catch {}\n instance = rive = observer = undefined;\n };\n if (art && !matchMedia('(prefers-reduced-motion: reduce)').matches) {\n const runtime = document.createElement('script');\n runtime.src = RIVE + 'rive.js';\n runtime.integrity = RIVE_JS_SRI;\n runtime.crossOrigin = 'anonymous';\n runtime.onerror = noArt;\n runtime.onload = () => {\n if (stopped) return;\n try {\n const R = window.rive;\n // The runtime is pinned, so the state changes it still gives are what this relies on.\n R.Rive.suppressDeprecationWarnings = ['state-change-events'];\n R.RuntimeLoader.setWasmUrl(RIVE + 'rive.wasm');\n R.RuntimeLoader.setWasmFallbackUrl(RIVE + 'rive_fallback.wasm');\n const canvas = art.querySelector('canvas');\n const r = new R.Rive({\n src: ANIMATION,\n canvas,\n autoplay: true,\n stateMachine: 'Main',\n // Binds the file's view model, whose `kick` trigger starts the kick.\n autoBind: true,\n layout: new R.Layout({ fit: R.Fit.Contain, alignment: R.Alignment.Center }),\n onLoad: () => {\n if (stopped) return;\n r.resizeDrawingSurfaceToCanvas();\n rive = r;\n },\n onLoadError: noArt,\n onStateChange: (e) => {\n for (const name of [].concat(e.data || [])) {\n if (name === WAITING) waiting = true;\n else if (name === 'Arrive' || name === 'Kick') waiting = false;\n }\n if (waiting && onWaiting) onWaiting();\n },\n });\n instance = r;\n observer = new ResizeObserver(() => rive && rive.resizeDrawingSurfaceToCanvas());\n observer.observe(canvas);\n } catch {\n noArt();\n }\n };\n document.head.appendChild(runtime);\n } else noArt();\n /** Plays the kick (once the bug waits by the lock), resolving when the bug has run off. */\n const kick = () =>\n new Promise((done) => {\n if (!rive) return done();\n const cap = setTimeout(done, KICK_WAIT_MAX);\n onWaiting = () => {\n onWaiting = undefined;\n try {\n rive.viewModelInstance.trigger('kick').trigger();\n } catch {\n clearTimeout(cap);\n return done();\n }\n setTimeout(() => {\n clearTimeout(cap);\n done();\n }, KICK_MS);\n };\n if (waiting) onWaiting();\n });\n\n // The explainer comes first; the browser shows (and its frames start) once the person starts.\n let starting = false;\n $('start').addEventListener('click', async () => {\n if (starting || over) return;\n starting = true;\n $('start').setAttribute('aria-disabled', 'true');\n // Reading this takes no requests, so the sign-in may have ended meanwhile.\n try {\n const r = await fetch(base + '/status', { cache: 'no-store' });\n if (!r.ok) return end(GONE);\n } catch {\n return end(GONE);\n }\n await kick();\n noArt();\n if (over) return;\n document.body.classList.remove('intro');\n resize();\n frames();\n });\n})();";
20
20
  /**
21
21
  * The live view's Content-Security-Policy: its own script, frames and icons as data URLs, its own
22
22
  * routes, Google Fonts as the reports load them (`webFonts`), Rive's runtime from its exact folder
@@ -1,5 +1,5 @@
1
- import { brandMark, favicon, html, icon as icon_, Markup, REPO_URL, SITE_URL, webFonts, } from './markup.js';
2
- import { GITHUB_MARK } from './logos.js';
1
+ import { favicon, html, icon as icon_, Markup, webFonts } from './markup.js';
2
+ import { githubLink, menuBar, THEME_BUTTON_JS, themeButton } from './menu-bar.js';
3
3
  import { styles } from './styles.js';
4
4
  import { cspHash } from './sha256.js';
5
5
  /*
@@ -243,17 +243,10 @@ export const SIGN_IN_SCRIPT = /* js */ `(() => {
243
243
  end('Cancelled. Nothing was saved. You can close this tab.');
244
244
  });
245
245
 
246
- // The theme: light, dark or the system's, in turn, as on screw-bugs Cloud's menu bar; the button
247
- // shows the current one (the reports' tokens follow \`data-theme\`).
248
- const root = document.documentElement, themes = ['light', 'dark', 'system'];
249
- const names = { light: 'Light theme', dark: 'Dark theme', system: 'Theme from system' };
250
- $('theme').addEventListener('click', (e) => {
251
- const now = themes.indexOf(root.dataset.theme || 'system');
252
- const theme = themes[(now + 1) % themes.length], after = themes[(now + 2) % themes.length];
253
- root.dataset.theme = theme;
254
- e.currentTarget.setAttribute('aria-label', names[theme] + '. Switch to ' + names[after].toLowerCase());
255
- e.currentTarget.title = names[theme];
256
- });
246
+ // The theme: light, dark or the system's, in turn, as on screw-bugs Cloud's menu bar (the
247
+ // reports' tokens follow \`data-theme\`). Not kept: each sign-in is a new origin.
248
+ ${THEME_BUTTON_JS}
249
+ themeCycle(document.querySelector('.menubar .theme'));
257
250
 
258
251
  // The animation: the bug waits by a lock, and kicks it open when the person starts. It plays
259
252
  // with Rive's runtime from its CDN (taken only with the hash it was published with) and the file
@@ -376,7 +369,7 @@ export const SIGN_IN_CSP = "default-src 'none'; img-src data:; font-src https://
376
369
  const signInStyles = /* css */ `
377
370
  html, body { height: 100%; }
378
371
  body { display: flex; flex-direction: column; background: var(--bg); }
379
- .top { grid-template-columns: 1fr auto 1fr; padding: 0 24px; }
372
+ .top { position: sticky; top: 0; z-index: 10; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; height: 56px; padding: 0 24px; background: var(--bg); font: var(--t-mono); color: var(--header); }
380
373
  .top .what { justify-self: center; white-space: nowrap; }
381
374
  .pill { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 16px; border: 0; border-radius: 999px; font: var(--t-control); cursor: pointer; }
382
375
  .pill.primary { background: var(--accent); color: var(--on-accent); font-weight: 500; }
@@ -386,30 +379,8 @@ body { display: flex; flex-direction: column; background: var(--bg); }
386
379
  .app-icon { display: grid; place-items: center; flex: none; overflow: hidden; border-radius: 6px; background: var(--subtle); color: var(--muted); font: var(--t-small-strong); text-transform: uppercase; }
387
380
  .app-icon img { width: 100%; height: 100%; object-fit: contain; }
388
381
 
389
- /* The explainer: the animation beside a card that says what is about to happen. */
390
- /* The menu bar of screw-bugs Cloud's landing page, without Sign in: see-through, its two ends in
391
- frosted capsules, in the landing's own colors (\`--l-*\`, which differ a little from the reports'). */
392
- .intro-only.top { --l-text: #303030; --l-muted: #636363; --l-icon: #000000; }
393
- @media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .intro-only.top { --l-text: #eceeec; --l-muted: #afb5ad; --l-icon: #eceeec; } }
394
- :root[data-theme="dark"] .intro-only.top { --l-text: #eceeec; --l-muted: #afb5ad; --l-icon: #eceeec; }
395
- .intro-only.top { display: flex; justify-content: space-between; gap: 8px; height: 56px; padding: 0 12px; background: transparent; font: 600 13px/16px var(--sans); letter-spacing: -0.03em; color: var(--l-text); }
396
- .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); }
397
- .intro-only .brand { gap: 8px; padding: 0 16px 0 12px; white-space: nowrap; }
398
- .intro-only .brand:hover { color: inherit; }
399
- .intro-only .bug { width: 24px; height: 24px; }
400
- .intro-only .ends { flex: none; gap: 6px; padding: 4px 4px 4px 12px; }
401
- .intro-only .gh { 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; }
402
- .intro-only .gh:hover { color: var(--l-muted); }
403
- .intro-only .gh .logo { width: 16px; height: 16px; }
404
- .intro-only .gh .logo path { fill: var(--l-icon); }
405
- .intro-only .gh .repo { display: none; }
406
- @media (min-width: 400px) { .intro-only .ends { gap: 8px; } }
407
- @media (min-width: 640px) { .intro-only .gh .repo { display: inline; } }
408
- @media (min-width: 768px) { .intro-only.top { height: 72px; padding: 0 32px; } .intro-only .ends { gap: 12px; } }
409
- #theme { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 999px; background: none; color: var(--l-text); cursor: pointer; }
410
- #theme:hover { background: color-mix(in srgb, var(--l-text) 8%, transparent); }
411
- #theme .t-light, #theme .t-dark, :root[data-theme="light"] #theme .t-system, :root[data-theme="dark"] #theme .t-system { display: none; }
412
- :root[data-theme="light"] #theme .t-light, :root[data-theme="dark"] #theme .t-dark { display: block; }
382
+ /* The explainer: the menu bar (\`menu-bar.ts\`), and the animation beside a card that says what is
383
+ about to happen. */
413
384
  #intro { display: none; }
414
385
  .intro #intro { display: flex; flex: 1; align-items: center; justify-content: center; gap: 40px; padding: 24px 24px 88px; overflow: auto; }
415
386
  .intro .live { display: none !important; }
@@ -475,8 +446,6 @@ body:not(.intro) .intro-only { display: none; }
475
446
  #note { padding: 0 16px 8px; }
476
447
  }
477
448
  `;
478
- /** The project on GitHub, as the menu bar names it: `owner/name`. */
479
- const REPO = REPO_URL.replace('https://github.com/', '');
480
449
  /** Exactly the script its hash allows: no whitespace around it. */
481
450
  const scriptTag = new Markup(`<script>${SIGN_IN_SCRIPT}</script>`);
482
451
  /** The app's icon, or the first letter of its host where it has none. */
@@ -509,31 +478,10 @@ export const renderSignInPage = (account) => {
509
478
  </style>
510
479
  </head>
511
480
  <body class="intro">
512
- <header class="top intro-only">
513
- <a class="brand capsule" href="${SITE_URL}" target="_blank" rel="noopener noreferrer"
514
- >${brandMark}screw bugs</a
515
- >
516
- <nav class="ends capsule" aria-label="Links">
517
- <a
518
- class="gh"
519
- href="${REPO_URL}"
520
- target="_blank"
521
- rel="noopener noreferrer"
522
- aria-label="${`${REPO} on GitHub`}"
523
- >${new Markup(GITHUB_MARK)}<span class="repo">${REPO}</span></a
524
- >
525
- <button
526
- id="theme"
527
- type="button"
528
- aria-label="Theme from system. Switch to light theme"
529
- title="Theme from system"
530
- >
531
- <span class="t-system">${icon_('monitor', { size: 16 })}</span
532
- ><span class="t-light">${icon_('sun', { size: 16 })}</span
533
- ><span class="t-dark">${icon_('moon', { size: 16 })}</span>
534
- </button>
535
- </nav>
536
- </header>
481
+ ${menuBar({
482
+ className: 'intro-only',
483
+ ends: html `${githubLink(640)}${themeButton(false)}`,
484
+ })}
537
485
  <main id="intro">
538
486
  <div id="art" class="art" aria-hidden="true"><canvas></canvas></div>
539
487
  <section class="card" aria-labelledby="intro-title">
@@ -1,9 +1,10 @@
1
+ import { menuBarStyles } from './menu-bar.js';
1
2
  import { CROP_WIDE } from './view.js';
2
3
  /*
3
4
  * The styles both pages share: the report and the walkthrough. Colors are tokens with a light and
4
5
  * a dark set (greys are Radix Olive, the accent is screw-bugs' lime), plus shadcn/ui's `--input`
5
6
  * (a switch's track when off) and `--ring` (the focus ring) mapped onto them: the system's choice by
6
- * default (`prefers-color-scheme`), or the reader's from the theme switch (`data-theme` on the
7
+ * default (`prefers-color-scheme`), or the reader's from the theme button (`data-theme` on the
7
8
  * root, set by the page's script). Lime is only ever a fill behind dark text. Recordings,
8
9
  * screenshots and the marks drawn over them keep their colors in both themes.
9
10
  *
@@ -88,37 +89,17 @@ q.value { quotes: "\\201C" "\\201D"; }
88
89
  .label { margin: 0 0 10px; font: var(--t-small-strong); color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
89
90
  h1, h2, h3, h4 { text-wrap: balance; }
90
91
 
91
- /* Header: brand, when, links; the theme switch. It stays on top while the page scrolls, \`--bar\`
92
- high: whatever else sticks goes under it. */
93
- .top { position: sticky; top: 0; z-index: 10; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; height: var(--bar); padding: 0 32px; background: var(--bg); font: var(--t-mono); color: var(--header); }
94
- .brand { display: inline-flex; align-items: center; gap: 8px; justify-self: start; color: inherit; text-decoration: none; }
95
- .brand:hover { color: var(--muted); }
96
- .brand:hover .brand-name { text-decoration: underline; }
97
- /* The bug, the one of the page's theme, at 1.5 px per cell of its 15-cell grid: 3 device pixels
98
- per cell on a 2x screen, so it is exact there, and its cells stay hard-edged (pixelated) on any.
99
- About the height of the wordmark's two lines of capitals. */
100
- .bug { display: block; flex: none; width: 22.5px; height: 22.5px; }
92
+ /* The menu bar (\`menu-bar.ts\`). It stays on top while the page scrolls, \`--bar\` high (as it is):
93
+ whatever else sticks goes under it. */
94
+ ${menuBarStyles}
95
+ /* The bug of the page's theme, and brand logos (logos.ts), in their own colors. */
96
+ .bug { display: block; flex: none; width: 24px; height: 24px; }
101
97
  .bug img { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
102
- /* Brand logos (logos.ts): in their own colors, left of the words that name them. */
103
98
  .logo { display: block; flex: none; }
104
99
  .bug-dark, .gh-dark { display: none; }
105
100
  @media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) :is(.bug-light, .gh-light) { display: none; } :root:not([data-theme="light"]) :is(.bug-dark, .gh-dark) { display: block; } }
106
101
  :root[data-theme="dark"] :is(.bug-light, .gh-light) { display: none; }
107
102
  :root[data-theme="dark"] :is(.bug-dark, .gh-dark) { display: block; }
108
- .links a.gh { display: inline-flex; align-items: center; gap: 6px; }
109
- .when { justify-self: center; white-space: nowrap; }
110
- .links { justify-self: end; display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
111
- .links a { color: inherit; text-decoration: none; }
112
- .links a:hover { color: var(--muted); text-decoration: underline; }
113
- .links .sep { width: 1px; height: 12px; background: currentColor; opacity: .7; }
114
- /* A toggle group, like the player's speed buttons, smaller. */
115
- .share-btn { display: inline-flex; align-items: center; gap: 6px; height: 28px; margin-left: 4px; padding: 0 12px; border-radius: 999px; background: var(--accent); color: var(--on-accent) !important; font: var(--t-control); text-decoration: none !important; }
116
- .share-btn:hover { filter: brightness(.95); }
117
- .share-btn[hidden] { display: none; }
118
- .theme { display: inline-flex; margin-left: 4px; padding: 2px; border-radius: 999px; background: var(--subtle); }
119
- .theme button { display: grid; place-items: center; width: 28px; height: 24px; padding: 0; border: 0; border-radius: 999px; background: none; color: var(--muted); cursor: pointer; }
120
- .theme button:hover { color: var(--text); background: var(--subtle-hover); }
121
- .theme button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
122
103
 
123
104
  /* What was asked, in quotes, clamped; "read full prompt" opens it in place. */
124
105
  .prompt { margin: 0 auto; max-width: 46em; text-align: center; font: var(--t-prompt); color: var(--muted); }
@@ -269,13 +250,8 @@ label.toggle input { appearance: none; margin: 0; cursor: pointer; }
269
250
  @container fig (width < ${CROP_WIDE.frame}px) { :is(.shot, .crop) .v-wide { display: none; } }
270
251
  @container fig (width >= ${CROP_WIDE.frame}px) { :is(.shot, .crop) .v-narrow { display: none; } }
271
252
 
253
+ @media (min-width: 768px) { :root { --bar: 72px; } }
272
254
  @media (max-width: 680px) {
273
- /* Two rows: the brand and when; the links and the theme switch. */
274
- :root { --bar: 76px; }
275
- .top { grid-template-columns: 1fr auto; gap: 2px 12px; align-content: center; padding: 0 16px; }
276
- .when { justify-self: end; }
277
- .links { grid-column: 1 / -1; justify-self: stretch; justify-content: flex-start; }
278
- .links .theme { margin-left: auto; }
279
255
  .speed button { min-width: 36px; }
280
256
  }
281
257
  @media (max-width: 900px) {
@@ -284,7 +260,7 @@ label.toggle input { appearance: none; margin: 0; cursor: pointer; }
284
260
  }
285
261
  @media print {
286
262
  html { background: #fff; }
287
- .theme, .mk-switch, .controls { display: none; }
263
+ .mk-switch, .controls { display: none; }
288
264
  }
289
265
  @media (prefers-reduced-motion: reduce) { *, *::before, *::after, ::backdrop { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }
290
266
  `;