screw-bugs 0.1.2 → 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.
- package/README.md +1 -1
- package/dist/build-info.json +3 -3
- package/dist/core/engine.d.ts +4 -1
- package/dist/core/engine.js +9 -1
- package/dist/report/html.d.ts +1 -1
- package/dist/report/html.js +3 -2
- package/dist/report/icons.d.ts +1 -0
- package/dist/report/icons.js +3 -3
- package/dist/report/index.d.ts +1 -1
- package/dist/report/index.js +1 -1
- package/dist/report/markup.d.ts +1 -14
- package/dist/report/markup.js +5 -60
- package/dist/report/menu-bar.d.ts +60 -0
- package/dist/report/menu-bar.js +153 -0
- package/dist/report/player.d.ts +3 -3
- package/dist/report/player.js +8 -8
- package/dist/report/sign-in.d.ts +1 -1
- package/dist/report/sign-in.js +13 -65
- package/dist/report/styles.js +9 -33
- package/dist/report/walkthrough.d.ts +1 -1
- package/dist/report/walkthrough.js +3 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -83,7 +83,7 @@ Set up screw-bugs (local browser QA for coding agents, over MCP) in this project
|
|
|
83
83
|
|
|
84
84
|
## Requirements
|
|
85
85
|
|
|
86
|
-
Node.js 22.
|
|
86
|
+
Node.js 22.19 or newer, and Google Chrome or Microsoft Edge (or Playwright's Chromium). Check with:
|
|
87
87
|
|
|
88
88
|
```sh
|
|
89
89
|
npx screw-bugs@latest doctor
|
package/dist/build-info.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"id": "2026-11-
|
|
3
|
-
"builtAt": "2026-11-
|
|
4
|
-
"commit": "
|
|
2
|
+
"id": "2026-11-13T00:59:51.438Z-4af8fe21",
|
|
3
|
+
"builtAt": "2026-11-13T00:59:51.438Z",
|
|
4
|
+
"commit": "ec971e4c0742db6553f710b938697b5eeaa1131c"
|
|
5
5
|
}
|
package/dist/core/engine.d.ts
CHANGED
|
@@ -50,7 +50,10 @@ declare const Engine_base: Context.ServiceClass<Engine, "screw-bugs/Engine", {
|
|
|
50
50
|
* whether the run may get one (never an interrupted run).
|
|
51
51
|
*/
|
|
52
52
|
readonly writeWalkthrough: (jobId: JobId) => Effect.Effect<string, RunNotFound | StorageFailed>;
|
|
53
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* The report bundle of a run as it is now, with the agent's write-up if it gave one, naming
|
|
55
|
+
* its `walkthrough.html` when the run folder has one beside its own `report.html`.
|
|
56
|
+
*/
|
|
54
57
|
readonly bundle: (jobId: JobId) => Effect.Effect<ReportBundle, RunNotFound | StorageFailed>;
|
|
55
58
|
/**
|
|
56
59
|
* Checks an agent's findings against an ended run (`checkFindings`), saves them as
|
package/dist/core/engine.js
CHANGED
|
@@ -475,7 +475,15 @@ export class Engine extends Context.Service()('screw-bugs/Engine') {
|
|
|
475
475
|
}),
|
|
476
476
|
bundle: (jobId) => Effect.gen(function* () {
|
|
477
477
|
const job = yield* storage.readJob(jobId);
|
|
478
|
-
|
|
478
|
+
const { bundle } = yield* assemble(job, yield* status(jobId));
|
|
479
|
+
// Names the walkthrough as the written report does, when the run has one: a share
|
|
480
|
+
// built from this bundle shows it only then. Only beside the run's own report: a
|
|
481
|
+
// walkthrough left by a run that died before writing it belongs to no report.
|
|
482
|
+
const walkthrough = yield* storage.probe(jobId, runFiles.walkthrough, 0);
|
|
483
|
+
const report = yield* storage.probe(jobId, runFiles.html, 0);
|
|
484
|
+
return walkthrough === undefined || report === undefined
|
|
485
|
+
? bundle
|
|
486
|
+
: { ...bundle, files: { ...bundle.files, walkthrough: runFiles.walkthrough } };
|
|
479
487
|
}),
|
|
480
488
|
submitFindings: (jobId, findings) => Effect.gen(function* () {
|
|
481
489
|
const job = yield* storage.readJob(jobId);
|
package/dist/report/html.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { type RenderOptions } from './assets.js';
|
|
|
19
19
|
* failed. Without script: the video has its own controls, timecodes open the video at their time
|
|
20
20
|
* and screenshots open the image.
|
|
21
21
|
*/
|
|
22
|
-
export declare const REPORT_SCRIPT = "(()=>{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\nconst badImg=i=>{const f=i.closest('figure');if(!f||f.classList.contains('broken'))return;f.classList.add('broken');f.querySelectorAll('.unloaded').forEach(u=>u.removeAttribute('aria-hidden'))};\nconst scan=()=>d.querySelectorAll('figure img').forEach(i=>{if(i.complete&&i.naturalWidth===0)badImg(i)});\nd.addEventListener('error',e=>{const t=e.target;if(t instanceof Element&&t.matches('figure img'))badImg(t)},true);\naddEventListener('load',scan);\nd.addEventListener('DOMContentLoaded',()=>{\n chrome();scan();\n const cards=[...d.querySelectorAll('.case[data-i]')],segs=[...d.querySelectorAll('.seg[data-case]')];\n const np=d.getElementById('rp-now'),loopB=d.getElementById('rp-loop'),dlg=d.getElementById('viewer');\n const N=cards.length,dash=String.fromCharCode(8211);let cur=null,loop=true,lock=0,lastT=0,P=null,sr=0;\n const timed=c=>!!c&&c.dataset.t0!==undefined;\n const span=c=>[Number(c.dataset.t0),Number(c.dataset.t1)];\n const shown=()=>cards.filter(c=>!c.hidden);\n const line=()=>{const b=topEdge();if(matchMedia('(max-width: 900px)').matches){const s=d.querySelector('.rp-left');return s?s.getBoundingClientRect().bottom+24:b+120}return Math.round(b+(innerHeight-b)*0.3)};\n const playable=c=>timed(c)&&!!P&&P.has(c.dataset.s);\n const chip=c=>{if(!playable(c)||P.down()!==null)return '';const s=span(c);return (loop?'Looping ':'Playing ')+clock(s[0])+dash+clock(s[1])};\n const paintNow=()=>{\n if(!np||!cur)return;\n np.querySelector('.np-st').replaceChildren(cur.querySelector('.case-head .st').cloneNode(true));\n np.querySelector('.np-n').textContent=cur.dataset.i+' / '+N;\n np.querySelector('.np-title').textContent=cur.querySelector('.case-go').textContent;\n np.querySelector('.np-status').textContent=cur.dataset.label+': ';\n const ch=np.querySelector('.np-chip'),t=chip(cur);ch.querySelector('span').textContent=t||'No video';ch.classList.toggle('none',!t);\n };\n const toCard=c=>{lock=Date.now()+700;const y=c.getBoundingClientRect().top+scrollY-line()+2;scrollTo({top:Math.max(0,y),behavior:still()?'auto':'smooth'})};\n const setCurrent=(c,seek,scroll)=>{\n if(!c)return;\n if(c!==cur){if(cur){cur.classList.remove('on');cur.removeAttribute('aria-current')}cur=c;c.classList.add('on');c.setAttribute('aria-current','true');segs.forEach(x=>x.classList.toggle('on',x.dataset.case===c.dataset.id));paintNow()}\n if(seek&&P){if(playable(c)){const a=span(c)[0];lastT=a;P.load(c.dataset.s,a,P.playing())}else P.none()}\n if(scroll)toCard(c);\n };\n const caseAt=(s,t)=>{let f=null;for(const c of shown()){if(timed(c)&&c.dataset.s===s){const x=span(c);if(t>=x[0]&&t<x[1])f=c}}return f};\n const onScroll=()=>{\n if(Date.now()<lock)return;const vis=shown();if(!vis.length)return;\n const L=line();let pick=vis[0];for(const c of vis){if(c.getBoundingClientRect().top<=L)pick=c}\n const last=vis[vis.length-1];if(innerHeight+scrollY>=r.scrollHeight-2&&last.getBoundingClientRect().bottom<=innerHeight)pick=last;\n if(pick!==cur)setCurrent(pick,true,false);\n };\n const stk=d.querySelector('.rp-sticky'),head=d.querySelector('.rp-head');\n const fit=()=>{if(stk)stk.style.setProperty('--rp-top',Math.round(stk.getBoundingClientRect().top)+'px')};\n fit();addEventListener('resize',fit);addEventListener('load',fit);\n if(head&&window.ResizeObserver)new ResizeObserver(fit).observe(head);\n addEventListener('scroll',()=>{if(!sr)sr=requestAnimationFrame(()=>{sr=0;fit();onScroll()})},{passive:true});\n if(d.getElementById('rp-video'))P=player('rp',{\n broken:paintNow,fine:paintNow,\n tick:t=>{\n if(!cur||P.down()!==null||P.v.seeking)return;const s=P.cur();\n if(loop){if(timed(cur)&&cur.dataset.s===s){const x=span(cur);if(!P.v.paused&&t>=x[1]-0.03&&lastT<x[1]){lastT=x[0];P.v.currentTime=x[0];return}}}\n else{const c=caseAt(s,t);if(c&&c!==cur)setCurrent(c,false,true)}\n lastT=t;\n },\n seek:t=>{lastT=t;const c=caseAt(P.cur(),t);if(c&&c!==cur)setCurrent(c,false,true)},\n ended:()=>{\n if(!cur)return false;\n if(loop&&timed(cur)&&cur.dataset.s===P.cur()){P.load(P.cur(),span(cur)[0],true);return true}\n if(!loop){const later=shown().find(c=>timed(c)&&Number(c.dataset.s)>Number(P.cur())&&P.has(c.dataset.s));if(later){setCurrent(later,false,true);P.load(later.dataset.s,span(later)[0],true);return true}}\n return false;\n },\n });\n if(loopB)loopB.addEventListener('click',()=>{loop=!loop;loopB.setAttribute('aria-pressed',String(loop));paintNow()});\n const filter=f=>{\n d.querySelectorAll('[data-filter]').forEach(x=>x.setAttribute('aria-pressed',String(x.dataset.filter===f)));\n cards.forEach(c=>{c.hidden=!(f==='all'||c.dataset.status===f)});\n segs.forEach(x=>{const c=cards.find(k=>k.dataset.id===x.dataset.case);x.classList.toggle('off',!!c&&c.hidden)});\n if(cur&&cur.hidden)setCurrent(shown()[0],true,false);\n };\n d.querySelectorAll('[data-filter]').forEach(b=>b.addEventListener('click',()=>filter(b.dataset.filter)));\n d.querySelectorAll('.filters').forEach(f=>f.classList.add('live'));\n let vCase=null,vIdx=0,opener=null;\n const q=s=>dlg.querySelector(s);\n const list=c=>{const t=c&&c.querySelector('template.shots');return t?[...t.content.children]:[]};\n const showShot=()=>{\n const l=list(vCase),f=l[vIdx];if(!f)return;\n q('.v-body').replaceChildren(f.cloneNode(true));\n q('.v-st').replaceChildren(vCase.querySelector('.case-head .st').cloneNode(true));\n q('.v-title').textContent=vCase.querySelector('.case-go').textContent;\n q('.v-what').textContent=f.dataset.cap+(l.length>1?' ('+(vIdx+1)+' of '+l.length+')':'');\n q('.v-prev').disabled=vIdx===0;q('.v-next').disabled=vIdx>=l.length-1;scan();\n };\n if(dlg){\n q('.v-prev').addEventListener('click',()=>{if(vIdx>0){vIdx--;showShot()}});\n q('.v-next').addEventListener('click',()=>{if(vIdx<list(vCase).length-1){vIdx++;showShot()}});\n q('.v-close').addEventListener('click',()=>dlg.close());\n dlg.addEventListener('click',e=>{if(e.target===dlg)dlg.close()});\n dlg.addEventListener('keydown',e=>{if(e.key==='ArrowLeft'){e.preventDefault();q('.v-prev').click()}else if(e.key==='ArrowRight'){e.preventDefault();q('.v-next').click()}});\n dlg.addEventListener('close',()=>{q('.v-body').replaceChildren();if(opener&&opener.isConnected)opener.focus()});\n }\n d.addEventListener('click',e=>{\n const t=e.target;if(!(t instanceof Element))return;\n const tc=t.closest('a.tc[data-t]');\n if(tc){if(!P||!P.has(tc.dataset.s))return;e.preventDefault();const s=tc.dataset.s,at=Number(tc.dataset.t),c=caseAt(s,at)||tc.closest('.case')||(dlg&&dlg.open?vCase:null);if(dlg&&dlg.open)dlg.close();if(c)setCurrent(c,false,!tc.closest('.case'));lastT=at;P.load(s,at,P.playing());return}\n const go=t.closest('a[href^=\"#case-\"]');\n if(go){const c=d.getElementById(go.getAttribute('href').slice(1));if(!c||!c.matches('.case[data-i]'))return;e.preventDefault();if(c.hidden)filter('all');toCard(c);setCurrent(c,true,false);return}\n const shot=t.closest('[data-shot]');\n if(shot&&dlg&&dlg.showModal){e.preventDefault();opener=shot;vCase=shot.closest('.case');vIdx=Number(shot.dataset.shot)||0;showShot();dlg.showModal();q('.v-close').focus();return}\n const c=t.closest('.case[data-i]');\n if(!c||t.closest('a,summary,details,input,label')||(t.closest('button')&&!t.closest('.case-go')))return;\n toCard(c);setCurrent(c,true,false);\n });\n const first=cards.find(c=>timed(c)&&(!P||P.has(c.dataset.s)))||cards[0];\n if(first){setCurrent(first,false,false);if(timed(first))lastT=span(first)[0]}\n});\n})();";
|
|
22
|
+
export declare const REPORT_SCRIPT = "(()=>{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\nconst badImg=i=>{const f=i.closest('figure');if(!f||f.classList.contains('broken'))return;f.classList.add('broken');f.querySelectorAll('.unloaded').forEach(u=>u.removeAttribute('aria-hidden'))};\nconst scan=()=>d.querySelectorAll('figure img').forEach(i=>{if(i.complete&&i.naturalWidth===0)badImg(i)});\nd.addEventListener('error',e=>{const t=e.target;if(t instanceof Element&&t.matches('figure img'))badImg(t)},true);\naddEventListener('load',scan);\nd.addEventListener('DOMContentLoaded',()=>{\n chrome();scan();\n const cards=[...d.querySelectorAll('.case[data-i]')],segs=[...d.querySelectorAll('.seg[data-case]')];\n const np=d.getElementById('rp-now'),loopB=d.getElementById('rp-loop'),dlg=d.getElementById('viewer');\n const N=cards.length,dash=String.fromCharCode(8211);let cur=null,loop=true,lock=0,lastT=0,P=null,sr=0;\n const timed=c=>!!c&&c.dataset.t0!==undefined;\n const span=c=>[Number(c.dataset.t0),Number(c.dataset.t1)];\n const shown=()=>cards.filter(c=>!c.hidden);\n const line=()=>{const b=topEdge();if(matchMedia('(max-width: 900px)').matches){const s=d.querySelector('.rp-left');return s?s.getBoundingClientRect().bottom+24:b+120}return Math.round(b+(innerHeight-b)*0.3)};\n const playable=c=>timed(c)&&!!P&&P.has(c.dataset.s);\n const chip=c=>{if(!playable(c)||P.down()!==null)return '';const s=span(c);return (loop?'Looping ':'Playing ')+clock(s[0])+dash+clock(s[1])};\n const paintNow=()=>{\n if(!np||!cur)return;\n np.querySelector('.np-st').replaceChildren(cur.querySelector('.case-head .st').cloneNode(true));\n np.querySelector('.np-n').textContent=cur.dataset.i+' / '+N;\n np.querySelector('.np-title').textContent=cur.querySelector('.case-go').textContent;\n np.querySelector('.np-status').textContent=cur.dataset.label+': ';\n const ch=np.querySelector('.np-chip'),t=chip(cur);ch.querySelector('span').textContent=t||'No video';ch.classList.toggle('none',!t);\n };\n const toCard=c=>{lock=Date.now()+700;const y=c.getBoundingClientRect().top+scrollY-line()+2;scrollTo({top:Math.max(0,y),behavior:still()?'auto':'smooth'})};\n const setCurrent=(c,seek,scroll)=>{\n if(!c)return;\n if(c!==cur){if(cur){cur.classList.remove('on');cur.removeAttribute('aria-current')}cur=c;c.classList.add('on');c.setAttribute('aria-current','true');segs.forEach(x=>x.classList.toggle('on',x.dataset.case===c.dataset.id));paintNow()}\n if(seek&&P){if(playable(c)){const a=span(c)[0];lastT=a;P.load(c.dataset.s,a,P.playing())}else P.none()}\n if(scroll)toCard(c);\n };\n const caseAt=(s,t)=>{let f=null;for(const c of shown()){if(timed(c)&&c.dataset.s===s){const x=span(c);if(t>=x[0]&&t<x[1])f=c}}return f};\n const onScroll=()=>{\n if(Date.now()<lock)return;const vis=shown();if(!vis.length)return;\n const L=line();let pick=vis[0];for(const c of vis){if(c.getBoundingClientRect().top<=L)pick=c}\n const last=vis[vis.length-1];if(innerHeight+scrollY>=r.scrollHeight-2&&last.getBoundingClientRect().bottom<=innerHeight)pick=last;\n if(pick!==cur)setCurrent(pick,true,false);\n };\n const stk=d.querySelector('.rp-sticky'),head=d.querySelector('.rp-head');\n const fit=()=>{if(stk)stk.style.setProperty('--rp-top',Math.round(stk.getBoundingClientRect().top)+'px')};\n fit();addEventListener('resize',fit);addEventListener('load',fit);\n if(head&&window.ResizeObserver)new ResizeObserver(fit).observe(head);\n addEventListener('scroll',()=>{if(!sr)sr=requestAnimationFrame(()=>{sr=0;fit();onScroll()})},{passive:true});\n if(d.getElementById('rp-video'))P=player('rp',{\n broken:paintNow,fine:paintNow,\n tick:t=>{\n if(!cur||P.down()!==null||P.v.seeking)return;const s=P.cur();\n if(loop){if(timed(cur)&&cur.dataset.s===s){const x=span(cur);if(!P.v.paused&&t>=x[1]-0.03&&lastT<x[1]){lastT=x[0];P.v.currentTime=x[0];return}}}\n else{const c=caseAt(s,t);if(c&&c!==cur)setCurrent(c,false,true)}\n lastT=t;\n },\n seek:t=>{lastT=t;const c=caseAt(P.cur(),t);if(c&&c!==cur)setCurrent(c,false,true)},\n ended:()=>{\n if(!cur)return false;\n if(loop&&timed(cur)&&cur.dataset.s===P.cur()){P.load(P.cur(),span(cur)[0],true);return true}\n if(!loop){const later=shown().find(c=>timed(c)&&Number(c.dataset.s)>Number(P.cur())&&P.has(c.dataset.s));if(later){setCurrent(later,false,true);P.load(later.dataset.s,span(later)[0],true);return true}}\n return false;\n },\n });\n if(loopB)loopB.addEventListener('click',()=>{loop=!loop;loopB.setAttribute('aria-pressed',String(loop));paintNow()});\n const filter=f=>{\n d.querySelectorAll('[data-filter]').forEach(x=>x.setAttribute('aria-pressed',String(x.dataset.filter===f)));\n cards.forEach(c=>{c.hidden=!(f==='all'||c.dataset.status===f)});\n segs.forEach(x=>{const c=cards.find(k=>k.dataset.id===x.dataset.case);x.classList.toggle('off',!!c&&c.hidden)});\n if(cur&&cur.hidden)setCurrent(shown()[0],true,false);\n };\n d.querySelectorAll('[data-filter]').forEach(b=>b.addEventListener('click',()=>filter(b.dataset.filter)));\n d.querySelectorAll('.filters').forEach(f=>f.classList.add('live'));\n let vCase=null,vIdx=0,opener=null;\n const q=s=>dlg.querySelector(s);\n const list=c=>{const t=c&&c.querySelector('template.shots');return t?[...t.content.children]:[]};\n const showShot=()=>{\n const l=list(vCase),f=l[vIdx];if(!f)return;\n q('.v-body').replaceChildren(f.cloneNode(true));\n q('.v-st').replaceChildren(vCase.querySelector('.case-head .st').cloneNode(true));\n q('.v-title').textContent=vCase.querySelector('.case-go').textContent;\n q('.v-what').textContent=f.dataset.cap+(l.length>1?' ('+(vIdx+1)+' of '+l.length+')':'');\n q('.v-prev').disabled=vIdx===0;q('.v-next').disabled=vIdx>=l.length-1;scan();\n };\n if(dlg){\n q('.v-prev').addEventListener('click',()=>{if(vIdx>0){vIdx--;showShot()}});\n q('.v-next').addEventListener('click',()=>{if(vIdx<list(vCase).length-1){vIdx++;showShot()}});\n q('.v-close').addEventListener('click',()=>dlg.close());\n dlg.addEventListener('click',e=>{if(e.target===dlg)dlg.close()});\n dlg.addEventListener('keydown',e=>{if(e.key==='ArrowLeft'){e.preventDefault();q('.v-prev').click()}else if(e.key==='ArrowRight'){e.preventDefault();q('.v-next').click()}});\n dlg.addEventListener('close',()=>{q('.v-body').replaceChildren();if(opener&&opener.isConnected)opener.focus()});\n }\n d.addEventListener('click',e=>{\n const t=e.target;if(!(t instanceof Element))return;\n const tc=t.closest('a.tc[data-t]');\n if(tc){if(!P||!P.has(tc.dataset.s))return;e.preventDefault();const s=tc.dataset.s,at=Number(tc.dataset.t),c=caseAt(s,at)||tc.closest('.case')||(dlg&&dlg.open?vCase:null);if(dlg&&dlg.open)dlg.close();if(c)setCurrent(c,false,!tc.closest('.case'));lastT=at;P.load(s,at,P.playing());return}\n const go=t.closest('a[href^=\"#case-\"]');\n if(go){const c=d.getElementById(go.getAttribute('href').slice(1));if(!c||!c.matches('.case[data-i]'))return;e.preventDefault();if(c.hidden)filter('all');toCard(c);setCurrent(c,true,false);return}\n const shot=t.closest('[data-shot]');\n if(shot&&dlg&&dlg.showModal){e.preventDefault();opener=shot;vCase=shot.closest('.case');vIdx=Number(shot.dataset.shot)||0;showShot();dlg.showModal();q('.v-close').focus();return}\n const c=t.closest('.case[data-i]');\n if(!c||t.closest('a,summary,details,input,label')||(t.closest('button')&&!t.closest('.case-go')))return;\n toCard(c);setCurrent(c,true,false);\n });\n const first=cards.find(c=>timed(c)&&(!P||P.has(c.dataset.s)))||cards[0];\n if(first){setCurrent(first,false,false);if(timed(first))lastT=span(first)[0]}\n});\n})();";
|
|
23
23
|
/**
|
|
24
24
|
* Images and video load from the run folder by relative path (`'self'`, and `file:` for a report
|
|
25
25
|
* opened from disk); styles are inline, but for Google Fonts' stylesheet, whose fonts come from
|
package/dist/report/html.js
CHANGED
|
@@ -2,9 +2,10 @@ import { Layer } from 'effect';
|
|
|
2
2
|
import { ReportRenderer, SESSION_NOTE } from '../core/index.js';
|
|
3
3
|
import { isWebUrl, runFiles } from '../schema/index.js';
|
|
4
4
|
import { assetsOf, contentPolicy } from './assets.js';
|
|
5
|
-
import { favicon, generatorMeta, html, icon, Markup, promptBlock, safeRelative, statusIcon, textParts,
|
|
5
|
+
import { favicon, generatorMeta, html, icon, Markup, promptBlock, safeRelative, statusIcon, textParts, webFonts, } from './markup.js';
|
|
6
6
|
import { controlsBlock, PLAYER_JS, playableSessions, playerWindow, shapeStyle, share, toggleButton, } from './player.js';
|
|
7
7
|
import { CHROME_LOGO } from './logos.js';
|
|
8
|
+
import { topBar } from './menu-bar.js';
|
|
8
9
|
import { cspHash } from './sha256.js';
|
|
9
10
|
import { cardShot, viewerShot } from './shots.js';
|
|
10
11
|
import { styles } from './styles.js';
|
|
@@ -805,7 +806,7 @@ export const renderHtmlReport = (bundle, options) => {
|
|
|
805
806
|
<body>
|
|
806
807
|
${scriptTag}
|
|
807
808
|
<div class="${`rp device-${bundle.device.kind}`}" style="${shapeStyle(bundle)}">
|
|
808
|
-
${topBar(bundle.startedAt, bundle.jobId, walkthrough ?
|
|
809
|
+
${topBar(bundle.startedAt, bundle.jobId, walkthrough ? { href: walkthrough, name: 'Walkthrough', icon: 'play' } : undefined)}
|
|
809
810
|
<header class="rp-head">
|
|
810
811
|
<h1>${reportHeading(bundle)}</h1>
|
|
811
812
|
<ul class="meta" aria-label="Run">
|
package/dist/report/icons.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export declare const ICONS: {
|
|
|
10
10
|
readonly 'chevrons-up-down': '<path d="m7 15 5 5 5-5"/><path d="m7 9 5-5 5 5"/>';
|
|
11
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"/>';
|
|
12
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"/>';
|
|
13
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"/>';
|
|
14
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"/>';
|
|
15
16
|
readonly minus: '<path d="M5 12h14"/>';
|
package/dist/report/icons.js
CHANGED
|
@@ -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,
|
|
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
|
*
|
|
@@ -57,6 +56,7 @@ export const ICONS = {
|
|
|
57
56
|
'chevrons-up-down': '<path d="m7 15 5 5 5-5"/><path d="m7 9 5-5 5 5"/>',
|
|
58
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"/>',
|
|
59
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"/>',
|
|
60
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"/>',
|
|
61
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"/>',
|
|
62
62
|
minus: '<path d="M5 12h14"/>',
|
package/dist/report/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from './html.js';
|
|
2
2
|
export * from './pr-summary.js';
|
|
3
|
-
export { SHARE_START_PATH } from './
|
|
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';
|
package/dist/report/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from './html.js';
|
|
2
2
|
export * from './pr-summary.js';
|
|
3
|
-
export { SHARE_START_PATH } from './
|
|
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';
|
package/dist/report/markup.d.ts
CHANGED
|
@@ -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,19 +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
|
-
/** The bug of each theme (`bugMark`), for the
|
|
40
|
+
/** The bug of each theme (`bugMark`), for the menu bar (`menu-bar.ts`). */
|
|
43
41
|
export declare const brandMark: Markup;
|
|
44
|
-
/**
|
|
45
|
-
* Where a page's Share button starts sharing its run on screw-bugs Cloud: a route of the local
|
|
46
|
-
* report server (`src/cli/share.ts`), by absolute path, so it is the server the page came from.
|
|
47
|
-
*/
|
|
48
|
-
export declare const SHARE_START_PATH = "/.screw-bugs/share/start";
|
|
49
|
-
/**
|
|
50
|
-
* The top row of both pages: the brand (a link to the website), when the run started, and links (the other page, the
|
|
51
|
-
* project's GitHub) with the Share button (see `shareButton`) and the theme switch. When the run started is in UTC, saying so, until the
|
|
52
|
-
* page's script puts it in the reader's own time (see `PLAYER_JS`).
|
|
53
|
-
*/
|
|
54
|
-
export declare const topBar: (startedAt: string, jobId: string, links: ReadonlyArray<Markup>) => Markup;
|
|
55
42
|
/**
|
|
56
43
|
* What the user asked, in quotes, clamped to two lines; the page's script offers the rest in place
|
|
57
44
|
* when it does not fit. Nothing when the job recorded no request.
|
package/dist/report/markup.js
CHANGED
|
@@ -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 {
|
|
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
|
|
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
|
|
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'>" +
|
|
@@ -78,7 +77,7 @@ export const favicon = html `<link
|
|
|
78
77
|
/>`;
|
|
79
78
|
/**
|
|
80
79
|
* Geist and Geist Mono from Google Fonts, in exactly the weights the pages use (Geist 400,
|
|
81
|
-
* 500, 600 for the
|
|
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
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';
|
|
@@ -87,25 +86,6 @@ export const webFonts = html `<link rel="preconnect" href="https://fonts.googlea
|
|
|
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,43 +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
|
-
/** The bug of each theme (`bugMark`), for the
|
|
123
|
+
/** The bug of each theme (`bugMark`), for the menu bar (`menu-bar.ts`). */
|
|
144
124
|
export const brandMark = html `${bugMark(BUG_GIF_ON_LIGHT, BUG_DARK, 'light')}${bugMark(BUG_GIF_ON_DARK, BUG_LIME, 'dark')}`;
|
|
145
|
-
/**
|
|
146
|
-
* Where a page's Share button starts sharing its run on screw-bugs Cloud: a route of the local
|
|
147
|
-
* report server (`src/cli/share.ts`), by absolute path, so it is the server the page came from.
|
|
148
|
-
*/
|
|
149
|
-
export const SHARE_START_PATH = '/.screw-bugs/share/start';
|
|
150
|
-
/**
|
|
151
|
-
* The Share button: a link to the report server's start of a share. Hidden until the page's script
|
|
152
|
-
* finds it was served by the local report server (`http:` on 127.0.0.1 or localhost): opened from
|
|
153
|
-
* disk or on a host such as screw-bugs Cloud, there is no server to share it.
|
|
154
|
-
*/
|
|
155
|
-
const shareButton = (jobId) => html `<a
|
|
156
|
-
class="share-btn"
|
|
157
|
-
href="${`${SHARE_START_PATH}?run=${encodeURIComponent(jobId)}`}"
|
|
158
|
-
title="Share this report on screw-bugs Cloud: a link anyone can open for 7 days"
|
|
159
|
-
hidden
|
|
160
|
-
>${icon('share', { size: 14, strokeWidth: 2.25 })}<span>Share</span></a
|
|
161
|
-
>`;
|
|
162
|
-
/**
|
|
163
|
-
* The top row of both pages: the brand (a link to the website), when the run started, and links (the other page, the
|
|
164
|
-
* project's GitHub) with the Share button (see `shareButton`) and the theme switch. When the run started is in UTC, saying so, until the
|
|
165
|
-
* page's script puts it in the reader's own time (see `PLAYER_JS`).
|
|
166
|
-
*/
|
|
167
|
-
export const topBar = (startedAt, jobId, links) => html `<header class="top">
|
|
168
|
-
<a class="brand" href="${SITE_URL}" rel="noopener noreferrer"
|
|
169
|
-
>${brandMark}<span class="brand-name">screwbugs.dev</span></a
|
|
170
|
-
>
|
|
171
|
-
<time class="when" datetime="${startedAt}">${formatDate(startedAt)}</time>
|
|
172
|
-
<nav class="links" aria-label="Links">
|
|
173
|
-
${links.map((link) => html `${link}<span class="sep" data-orientation="vertical" aria-hidden="true"></span>`)}
|
|
174
|
-
<a class="gh" href="${REPO_URL}" rel="noopener noreferrer"
|
|
175
|
-
>${new Markup(GITHUB_MARK)}GitHub</a
|
|
176
|
-
>
|
|
177
|
-
${shareButton(jobId)} ${themeSwitch}
|
|
178
|
-
</nav>
|
|
179
|
-
</header>`;
|
|
180
125
|
/**
|
|
181
126
|
* What the user asked, in quotes, clamped to two lines; the page's script offers the rest in place
|
|
182
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
|
+
`;
|
package/dist/report/player.d.ts
CHANGED
|
@@ -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
|
|
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('.
|
|
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";
|
package/dist/report/player.js
CHANGED
|
@@ -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
|
|
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('.
|
|
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
|
-
|
|
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
|
-
|
|
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};
|
package/dist/report/sign-in.d.ts
CHANGED
|
@@ -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();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
|
package/dist/report/sign-in.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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
|
|
247
|
-
//
|
|
248
|
-
|
|
249
|
-
|
|
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
|
|
390
|
-
|
|
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
|
-
|
|
513
|
-
|
|
514
|
-
|
|
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">
|
package/dist/report/styles.js
CHANGED
|
@@ -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
|
|
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
|
-
/*
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
.
|
|
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
|
-
.
|
|
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
|
`;
|
|
@@ -40,7 +40,7 @@ export declare const GLIDE_S = 0.6;
|
|
|
40
40
|
* and there is no ripple. A "Cursor" switch turns it off, remembered like the theme. Nothing is
|
|
41
41
|
* added to the page under test or to the video.
|
|
42
42
|
*/
|
|
43
|
-
export declare const WALKTHROUGH_SCRIPT = "(()=>{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\nd.addEventListener('DOMContentLoaded',()=>{\n chrome();\n const stg=d.querySelector('.wt-stage');let fr=0;\n const fit=()=>{fr=0;if(!stg)return;const t=stg.getBoundingClientRect().top;stg.style.setProperty('--wt-top',Math.round(t)+'px');stg.style.setProperty('--wt-y',Math.round(t+scrollY)+'px')};\n const refit=()=>{if(!fr)fr=requestAnimationFrame(fit)};\n fit();addEventListener('resize',refit);addEventListener('load',refit);addEventListener('scroll',refit,{passive:true});d.addEventListener('fullscreenchange',refit);\n if(window.ResizeObserver)new ResizeObserver(refit).observe(d.body);\n const v=d.getElementById('wt-video');if(!v)return;\n const w=d.querySelector('.wt'),panel=d.getElementById('wt-script'),box=d.getElementById('wt-box'),cap=d.getElementById('wt-cap');\n const say=a=>{const x=a&&a.querySelector('.wt-text');cap.replaceChildren(...(x?[...x.childNodes].filter(n=>!(n instanceof Element&&n.classList.contains('wt-state'))).map(n=>n.cloneNode(true)):[]));cap.hidden=!x};\n const steps=[...d.querySelectorAll('.wt-step[data-t]')];\n const idle=[...d.querySelectorAll('.idle[data-a]')].map(e=>({s:e.closest('.track').dataset.s,a:Number(e.dataset.a),b:Number(e.dataset.b)}));\n const skipB=d.getElementById('wt-skip'),expB=d.getElementById('wt-expand');\n let on=null,skip=!!skipB&&skipB.getAttribute('aria-pressed')==='true',P=null;\n w.classList.add('live');\n const hide=()=>{box.hidden=true};\n const geo=()=>{const vw=v.videoWidth,vh=v.videoHeight,cw=v.clientWidth,ch=v.clientHeight;if(!vw||!vh||!cw||!ch)return null;const s=Math.min(cw/vw,ch/vh);return{x:v.offsetLeft+(cw-vw*s)/2,y:v.offsetTop+(ch-vh*s)/2,w:vw*s,h:vh*s}};\n const put=(e,x,y,bw,bh)=>{e.style.left=x+'px';e.style.top=y+'px';if(bw!==undefined){e.style.width=bw+'px';e.style.height=bh+'px'}};\n const draw=(t,g)=>{if(P.down()!==null||!g||!on||!on.dataset.box||t<Number(on.dataset.b0)||t>Number(on.dataset.b1))return hide();const b=on.dataset.box.split(' ').map(Number);put(box,g.x+b[0]*g.w,g.y+b[1]*g.h,b[2]*g.w,b[3]*g.h);box.querySelector('span').textContent=on.dataset.label||'';box.hidden=false};\n const C=d.getElementById('wt-cursor'),R=d.getElementById('wt-ripple'),G=d.getElementById('wt-ring'),L=d.getElementById('wt-act'),T=d.getElementById('wt-cursor-on'),ck='screw-bugs-cursor';\n const nums=x=>x?x.split(' ').map(Number):null;\n const acts=[...d.querySelectorAll('.wt-step[data-act][data-s]')].map(e=>({s:e.dataset.s,at:e.dataset.at?Number(e.dataset.at):NaN,t0:Number(e.dataset.t),t1:Number(e.dataset.a1),b0:Number(e.dataset.b0),b1:Number(e.dataset.b1),k:e.dataset.act,p:nums(e.dataset.pt),b:nums(e.dataset.tb),l:e.dataset.al||''})).sort((a,b)=>(a.at>=0?a.at:a.t0)-(b.at>=0?b.at:b.t0));\n let fon=true;try{fon=localStorage.getItem(ck)!=='off'}catch(e){}\n const fx=(t,g)=>{\n C.hidden=R.hidden=G.hidden=L.hidden=true;box.querySelector('span').hidden=false;\n if(!fon||P.down()!==null||!g)return;\n const m=still(),mine=acts.filter(a=>a.s===P.cur()),ptr=mine.filter(a=>a.p),xy=p=>[g.x+p[0]*g.w,g.y+p[1]*g.h];\n let i=-1;ptr.forEach((a,j)=>{if(a.at<=t)i=j});\n const a=ptr[i],n=ptr[i+1];let c=a?a.p:null;\n if(n&&a){const gw=Math.min(0.6,n.at-a.at),q=gw>0?(t-n.at+gw)/gw:1;if(q>=0){const e=q<.5?4*q*q*q:1-Math.pow(2-2*q,3)/2;c=!m&&q<1?[a.p[0]+(n.p[0]-a.p[0])*e,a.p[1]+(n.p[1]-a.p[1])*e]:n.p}}\n if(c){const xy0=xy(c);put(C,xy0[0]-3,xy0[1]-2);C.hidden=false}\n if(a&&!m&&t-a.at<.6){const q=(t-a.at)/.6,xy1=xy(a.p);put(R,xy1[0],xy1[1]);R.style.transform='translate(-50%,-50%) scale('+(.35+q*1.3)+')';R.style.opacity=String(1-q);R.hidden=false}\n let f=null,l=null,u=null;\n for(const x of mine){if(x.k==='fill'&&x.b&&t>=x.b0&&t<=x.b1)f=x;if(x.k==='fill'||!(x.at>=0)?t>=x.t0&&t<=x.t1:t>=x.at&&t<=x.at+1.5)l=x;else if(!u&&x.p&&x.at>t&&x.at-t<=0.6)u=x}\n l=l||u;\n if(f){const xy2=xy(f.b);put(G,xy2[0],xy2[1],f.b[2]*g.w,f.b[3]*g.h);G.hidden=false;box.hidden=true}\n if(l&&l.l){L.textContent=l.l;L.hidden=false;let x=g.x+10,y=g.y+10;if(l.p){const q=xy(l.p);x=q[0]+14;y=q[1]+20}else if(l.b){const q=xy(l.b);x=q[0];y=q[1]+l.b[3]*g.h+10}if(y+L.offsetHeight>g.y+g.h-4)y=l.b?g.y+l.b[1]*g.h-L.offsetHeight-10:g.y+g.h-L.offsetHeight-4;put(L,Math.max(g.x+4,Math.min(x,g.x+g.w-L.offsetWidth-4)),Math.max(g.y+4,y))}\n box.querySelector('span').hidden=!L.hidden;\n };\n const stage=d.querySelector('.wt-stage');\n const cover=()=>{let y=topEdge();if(stage&&getComputedStyle(stage).position==='sticky')y=Math.max(y,stage.getBoundingClientRect().bottom+16);return y};\n const anchor=a=>{const hid=Math.max(0,cover()-panel.getBoundingClientRect().top);panel.scrollTo({top:Math.max(0,a.offsetTop-6-hid),behavior:still()?'auto':'smooth'})};\n const tick=t=>{\n const cur=P.cur();\n if(skip&&!v.paused&&!v.seeking){const gap=idle.find(x=>x.s===cur&&t>=x.a&&t<x.b-0.05);if(gap){v.currentTime=gap.b;return}}\n let a=null;for(const s of steps){if(s.dataset.s===cur&&Number(s.dataset.t)<=t+0.02)a=s}\n if(a!==on){if(on){on.classList.remove('on');on.removeAttribute('aria-current');on.closest('.wt-case').classList.remove('on')}on=a;say(a);if(a){a.classList.add('on');a.setAttribute('aria-current','step');a.closest('.wt-case').classList.add('on');anchor(a)}}\n const g=geo();draw(t,g);fx(t,g);\n };\n P=player('wt',{tick,full:w,expand:true,inPage:()=>matchMedia('(min-width: 901px)').matches,broken:()=>{hide();fx(0,null);w.classList.remove('live')},fine:()=>{w.classList.add('live')}});\n if(T&&acts.length){T.checked=fon;T.closest('label').hidden=false;T.addEventListener('change',()=>{fon=T.checked;try{localStorage.setItem(ck,fon?'on':'off')}catch(e){}P.update()})}\n if(skipB)skipB.addEventListener('click',()=>{skip=!skip;skipB.setAttribute('aria-pressed',String(skip))});\n if(expB)expB.addEventListener('click',()=>{const x=w.classList.toggle('expanded');expB.setAttribute('aria-expanded',String(x));expB.querySelector('span').textContent=x?'Collapse':'Expand';P.update();if(on)anchor(on)});\n d.addEventListener('click',e=>{\n const t=e.target;if(!(t instanceof Element))return;\n const a=t.closest('a[data-t][data-s],.wt-step[data-t][data-s]');if(!a||!P.has(a.dataset.s))return;\n e.preventDefault();const fig=v.closest('.player');\n if(fig.getBoundingClientRect().bottom<topEdge())fig.scrollIntoView({block:'start',behavior:still()?'auto':'smooth'});\n P.load(a.dataset.s,Number(a.dataset.t),P.playing());\n });\n P.update();\n});\n})();";
|
|
43
|
+
export declare const WALKTHROUGH_SCRIPT = "(()=>{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\nd.addEventListener('DOMContentLoaded',()=>{\n chrome();\n const stg=d.querySelector('.wt-stage');let fr=0;\n const fit=()=>{fr=0;if(!stg)return;const t=stg.getBoundingClientRect().top;stg.style.setProperty('--wt-top',Math.round(t)+'px');stg.style.setProperty('--wt-y',Math.round(t+scrollY)+'px')};\n const refit=()=>{if(!fr)fr=requestAnimationFrame(fit)};\n fit();addEventListener('resize',refit);addEventListener('load',refit);addEventListener('scroll',refit,{passive:true});d.addEventListener('fullscreenchange',refit);\n if(window.ResizeObserver)new ResizeObserver(refit).observe(d.body);\n const v=d.getElementById('wt-video');if(!v)return;\n const w=d.querySelector('.wt'),panel=d.getElementById('wt-script'),box=d.getElementById('wt-box'),cap=d.getElementById('wt-cap');\n const say=a=>{const x=a&&a.querySelector('.wt-text');cap.replaceChildren(...(x?[...x.childNodes].filter(n=>!(n instanceof Element&&n.classList.contains('wt-state'))).map(n=>n.cloneNode(true)):[]));cap.hidden=!x};\n const steps=[...d.querySelectorAll('.wt-step[data-t]')];\n const idle=[...d.querySelectorAll('.idle[data-a]')].map(e=>({s:e.closest('.track').dataset.s,a:Number(e.dataset.a),b:Number(e.dataset.b)}));\n const skipB=d.getElementById('wt-skip'),expB=d.getElementById('wt-expand');\n let on=null,skip=!!skipB&&skipB.getAttribute('aria-pressed')==='true',P=null;\n w.classList.add('live');\n const hide=()=>{box.hidden=true};\n const geo=()=>{const vw=v.videoWidth,vh=v.videoHeight,cw=v.clientWidth,ch=v.clientHeight;if(!vw||!vh||!cw||!ch)return null;const s=Math.min(cw/vw,ch/vh);return{x:v.offsetLeft+(cw-vw*s)/2,y:v.offsetTop+(ch-vh*s)/2,w:vw*s,h:vh*s}};\n const put=(e,x,y,bw,bh)=>{e.style.left=x+'px';e.style.top=y+'px';if(bw!==undefined){e.style.width=bw+'px';e.style.height=bh+'px'}};\n const draw=(t,g)=>{if(P.down()!==null||!g||!on||!on.dataset.box||t<Number(on.dataset.b0)||t>Number(on.dataset.b1))return hide();const b=on.dataset.box.split(' ').map(Number);put(box,g.x+b[0]*g.w,g.y+b[1]*g.h,b[2]*g.w,b[3]*g.h);box.querySelector('span').textContent=on.dataset.label||'';box.hidden=false};\n const C=d.getElementById('wt-cursor'),R=d.getElementById('wt-ripple'),G=d.getElementById('wt-ring'),L=d.getElementById('wt-act'),T=d.getElementById('wt-cursor-on'),ck='screw-bugs-cursor';\n const nums=x=>x?x.split(' ').map(Number):null;\n const acts=[...d.querySelectorAll('.wt-step[data-act][data-s]')].map(e=>({s:e.dataset.s,at:e.dataset.at?Number(e.dataset.at):NaN,t0:Number(e.dataset.t),t1:Number(e.dataset.a1),b0:Number(e.dataset.b0),b1:Number(e.dataset.b1),k:e.dataset.act,p:nums(e.dataset.pt),b:nums(e.dataset.tb),l:e.dataset.al||''})).sort((a,b)=>(a.at>=0?a.at:a.t0)-(b.at>=0?b.at:b.t0));\n let fon=true;try{fon=localStorage.getItem(ck)!=='off'}catch(e){}\n const fx=(t,g)=>{\n C.hidden=R.hidden=G.hidden=L.hidden=true;box.querySelector('span').hidden=false;\n if(!fon||P.down()!==null||!g)return;\n const m=still(),mine=acts.filter(a=>a.s===P.cur()),ptr=mine.filter(a=>a.p),xy=p=>[g.x+p[0]*g.w,g.y+p[1]*g.h];\n let i=-1;ptr.forEach((a,j)=>{if(a.at<=t)i=j});\n const a=ptr[i],n=ptr[i+1];let c=a?a.p:null;\n if(n&&a){const gw=Math.min(0.6,n.at-a.at),q=gw>0?(t-n.at+gw)/gw:1;if(q>=0){const e=q<.5?4*q*q*q:1-Math.pow(2-2*q,3)/2;c=!m&&q<1?[a.p[0]+(n.p[0]-a.p[0])*e,a.p[1]+(n.p[1]-a.p[1])*e]:n.p}}\n if(c){const xy0=xy(c);put(C,xy0[0]-3,xy0[1]-2);C.hidden=false}\n if(a&&!m&&t-a.at<.6){const q=(t-a.at)/.6,xy1=xy(a.p);put(R,xy1[0],xy1[1]);R.style.transform='translate(-50%,-50%) scale('+(.35+q*1.3)+')';R.style.opacity=String(1-q);R.hidden=false}\n let f=null,l=null,u=null;\n for(const x of mine){if(x.k==='fill'&&x.b&&t>=x.b0&&t<=x.b1)f=x;if(x.k==='fill'||!(x.at>=0)?t>=x.t0&&t<=x.t1:t>=x.at&&t<=x.at+1.5)l=x;else if(!u&&x.p&&x.at>t&&x.at-t<=0.6)u=x}\n l=l||u;\n if(f){const xy2=xy(f.b);put(G,xy2[0],xy2[1],f.b[2]*g.w,f.b[3]*g.h);G.hidden=false;box.hidden=true}\n if(l&&l.l){L.textContent=l.l;L.hidden=false;let x=g.x+10,y=g.y+10;if(l.p){const q=xy(l.p);x=q[0]+14;y=q[1]+20}else if(l.b){const q=xy(l.b);x=q[0];y=q[1]+l.b[3]*g.h+10}if(y+L.offsetHeight>g.y+g.h-4)y=l.b?g.y+l.b[1]*g.h-L.offsetHeight-10:g.y+g.h-L.offsetHeight-4;put(L,Math.max(g.x+4,Math.min(x,g.x+g.w-L.offsetWidth-4)),Math.max(g.y+4,y))}\n box.querySelector('span').hidden=!L.hidden;\n };\n const stage=d.querySelector('.wt-stage');\n const cover=()=>{let y=topEdge();if(stage&&getComputedStyle(stage).position==='sticky')y=Math.max(y,stage.getBoundingClientRect().bottom+16);return y};\n const anchor=a=>{const hid=Math.max(0,cover()-panel.getBoundingClientRect().top);panel.scrollTo({top:Math.max(0,a.offsetTop-6-hid),behavior:still()?'auto':'smooth'})};\n const tick=t=>{\n const cur=P.cur();\n if(skip&&!v.paused&&!v.seeking){const gap=idle.find(x=>x.s===cur&&t>=x.a&&t<x.b-0.05);if(gap){v.currentTime=gap.b;return}}\n let a=null;for(const s of steps){if(s.dataset.s===cur&&Number(s.dataset.t)<=t+0.02)a=s}\n if(a!==on){if(on){on.classList.remove('on');on.removeAttribute('aria-current');on.closest('.wt-case').classList.remove('on')}on=a;say(a);if(a){a.classList.add('on');a.setAttribute('aria-current','step');a.closest('.wt-case').classList.add('on');anchor(a)}}\n const g=geo();draw(t,g);fx(t,g);\n };\n P=player('wt',{tick,full:w,expand:true,inPage:()=>matchMedia('(min-width: 901px)').matches,broken:()=>{hide();fx(0,null);w.classList.remove('live')},fine:()=>{w.classList.add('live')}});\n if(T&&acts.length){T.checked=fon;T.closest('label').hidden=false;T.addEventListener('change',()=>{fon=T.checked;try{localStorage.setItem(ck,fon?'on':'off')}catch(e){}P.update()})}\n if(skipB)skipB.addEventListener('click',()=>{skip=!skip;skipB.setAttribute('aria-pressed',String(skip))});\n if(expB)expB.addEventListener('click',()=>{const x=w.classList.toggle('expanded');expB.setAttribute('aria-expanded',String(x));expB.querySelector('span').textContent=x?'Collapse':'Expand';P.update();if(on)anchor(on)});\n d.addEventListener('click',e=>{\n const t=e.target;if(!(t instanceof Element))return;\n const a=t.closest('a[data-t][data-s],.wt-step[data-t][data-s]');if(!a||!P.has(a.dataset.s))return;\n e.preventDefault();const fig=v.closest('.player');\n if(fig.getBoundingClientRect().bottom<topEdge())fig.scrollIntoView({block:'start',behavior:still()?'auto':'smooth'});\n P.load(a.dataset.s,Number(a.dataset.t),P.playing());\n });\n P.update();\n});\n})();";
|
|
44
44
|
/**
|
|
45
45
|
* As the report's: the video by relative path, one script by hash, and from the network only
|
|
46
46
|
* Google Fonts' stylesheet and its fonts.
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { clampBox } from '../core/index.js';
|
|
2
2
|
import { runFiles, } from '../schema/index.js';
|
|
3
|
-
import { favicon, generatorMeta, html, icon, Markup, promptBlock, safeRelative, statusIcon, statusTag, textParts,
|
|
3
|
+
import { favicon, generatorMeta, html, icon, Markup, promptBlock, safeRelative, statusIcon, statusTag, textParts, webFonts, } from './markup.js';
|
|
4
4
|
import { controlsBlock, PLAYER_JS, playableSessions, playerWindow, shapeStyle, share, toggleButton, } from './player.js';
|
|
5
5
|
import { assetsOf, contentPolicy } from './assets.js';
|
|
6
|
+
import { topBar } from './menu-bar.js';
|
|
6
7
|
import { cspHash } from './sha256.js';
|
|
7
8
|
import { styles } from './styles.js';
|
|
8
9
|
import { caseViews, formatTimecode, fragmentSeconds, idleStretches, stepParts, stepText, statusLabel, urlAt, urlTimeline, } from './view.js';
|
|
@@ -644,7 +645,7 @@ export const renderWalkthrough = (bundle, options) => {
|
|
|
644
645
|
<body>
|
|
645
646
|
${scriptTag}
|
|
646
647
|
<div class="${`wt device-${bundle.device.kind}`}" style="${shapeStyle(bundle)}">
|
|
647
|
-
${topBar(bundle.startedAt, bundle.jobId,
|
|
648
|
+
${topBar(bundle.startedAt, bundle.jobId, { href: report, name: 'Full report', icon: 'file-text' })}
|
|
648
649
|
${promptBlock(spec.instructions)}
|
|
649
650
|
${ledger.error
|
|
650
651
|
? html `<div class="alert" role="note">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "screw-bugs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Local browser QA for coding agents (MCP), people and CI.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"browser",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"vitest": "5.0.5"
|
|
70
70
|
},
|
|
71
71
|
"engines": {
|
|
72
|
-
"node": ">=22.
|
|
72
|
+
"node": ">=22.19.0"
|
|
73
73
|
},
|
|
74
74
|
"packageManager": "pnpm@12.9.1"
|
|
75
75
|
}
|