screw-bugs 0.1.3 → 0.1.5
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/dist/build-info.json +3 -3
- package/dist/report/assets.js +1 -1
- package/dist/report/html.d.ts +4 -3
- package/dist/report/html.js +14 -11
- package/dist/report/markup.d.ts +4 -0
- package/dist/report/markup.js +29 -10
- package/dist/report/menu-bar.d.ts +3 -3
- package/dist/report/menu-bar.js +6 -2
- package/dist/report/player.d.ts +1 -1
- package/dist/report/sign-in.d.ts +1 -1
- package/dist/report/walkthrough.d.ts +1 -1
- package/dist/report/walkthrough.js +1 -1
- package/package.json +1 -1
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-13T12:03:13.596Z-d6d3a62c",
|
|
3
|
+
"builtAt": "2026-11-13T12:03:13.596Z",
|
|
4
|
+
"commit": "45611aa254ba70af92c771220ed33924bef8b395"
|
|
5
5
|
}
|
package/dist/report/assets.js
CHANGED
|
@@ -8,7 +8,7 @@ import { Schema } from 'effect';
|
|
|
8
8
|
* plus the file's path, and the page's Content Security Policy lets images and media, and nothing
|
|
9
9
|
* else, load from its origin.
|
|
10
10
|
*
|
|
11
|
-
* Links from one page to the other (the report's "Walkthrough", the walkthrough's "
|
|
11
|
+
* Links from one page to the other (the report's "Walkthrough", the walkthrough's "Report")
|
|
12
12
|
* stay relative: they are pages, not files to load, and a host serves them side by side under its
|
|
13
13
|
* own policy, never from the file origin, which should not serve HTML that runs as a page.
|
|
14
14
|
*/
|
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('.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})();";
|
|
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(),f=document.getElementById('favicon'),h=f&&f.dataset[T[i]];if(h)f.href=h;b.setAttribute('aria-label',N[T[i]]+'. Switch to '+N[T[(i+1)%3]].toLowerCase());b.title=N[T[i]]};\n show();\n b.addEventListener('click',()=>{const m=T[(at()+1)%3];r.dataset.theme=m;if(key)try{localStorage.setItem(key,m)}catch(e){}show()});\n};\nconst chrome=()=>{\n d.querySelectorAll('.menubar .theme').forEach(b=>{themeCycle(b,K);b.hidden=false});\n if(location.protocol==='http:'&&(location.hostname==='127.0.0.1'||location.hostname==='localhost'))d.querySelectorAll('a.share-btn').forEach(a=>{a.hidden=false});\n d.querySelectorAll('time.when[datetime]').forEach(e=>{\n const t=new Date(e.getAttribute('datetime'));if(isNaN(t.getTime()))return;const p={};\n try{new Intl.DateTimeFormat('en-US',{month:'short',day:'numeric',year:'numeric',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(t).forEach(x=>{p[x.type]=x.value});\n const y=d.createElement('span');y.className='year';y.textContent=', '+p.year;\n e.replaceChildren(p.month+' '+p.day,y,' '+String.fromCharCode(183)+' '+p.hour+':'+p.minute);\n e.title=new Intl.DateTimeFormat('en-US',{dateStyle:'full',timeStyle:'long'}).format(t)}catch(x){}\n });\n d.querySelectorAll('.prompt').forEach(p=>{\n const t=p.querySelector('.prompt-text'),b=p.querySelector('.prompt-more');if(!t||!b)return;\n const fits=()=>{if(!p.classList.contains('open'))b.hidden=t.scrollHeight<=t.clientHeight+1};\n fits();if(window.ResizeObserver)new ResizeObserver(fits).observe(t);if(d.fonts&&d.fonts.ready)d.fonts.ready.then(fits);\n b.addEventListener('click',()=>{const o=p.classList.toggle('open');b.textContent=o?'Show less':'Show full prompt';b.setAttribute('aria-expanded',String(o));fits()});\n });\n};\nconst bare=u=>{const i=u.indexOf('://');return i<0?u:u.slice(i+3)};\nconst player=(p,o)=>{\n const v=d.getElementById(p+'-video'),fig=v.closest('.player'),note=d.getElementById(p+'-unloaded'),c=d.getElementById(p+'-controls'),url=d.getElementById(p+'-url');\n const srcs=new Map([...fig.querySelectorAll('[data-session-src]')].map(e=>[e.dataset.session,e.dataset.sessionSrc]));\n const order=[...srcs.keys()];\n const urls=[...fig.querySelectorAll('[data-url]')].map(e=>({s:e.dataset.s,t:Number(e.dataset.at),u:e.dataset.url}));\n const dead=new Set(),empty=d.getElementById(p+'-none');let cur=v.dataset.session,down=null,held=false,ask=0,auto=false,rate=1,raf=0,drag=false;\n const play=c.querySelector('.play'),now=c.querySelector('.now'),total=c.querySelector('.total'),bar=c.querySelector('.scrub'),head=c.querySelector('.head'),tracks=[...c.querySelectorAll('.track')];\n v.removeAttribute('controls');c.hidden=false;\n const big=d.getElementById(p+'-start');\n if(big){big.hidden=false;big.addEventListener('click',()=>{grow();v.play().catch(()=>{})});v.addEventListener('play',()=>big.remove(),{once:true})}\n const track=()=>tracks.find(t=>t.dataset.s===cur);\n const len=()=>{const t=track(),n=t?Number(t.dataset.total):0;return n>0?n:(isFinite(v.duration)?v.duration:0)};\n const paint=()=>{\n const L=len(),t=v.currentTime,f=L?Math.min(1,t/L):0,k=track();\n tracks.forEach(x=>{x.hidden=x!==k});head.style.left=(f*100)+'%';\n const done=k&&k.querySelector('.done');if(done)done.style.width=(f*100)+'%';\n now.textContent=clock(t);total.textContent=clock(L);\n bar.setAttribute('aria-valuemax',String(Math.round(L)));bar.setAttribute('aria-valuenow',String(Math.round(t)));bar.setAttribute('aria-valuetext',clock(t)+' of '+clock(L));\n play.classList.toggle('playing',!v.paused);play.setAttribute('aria-label',v.paused?'Play':'Pause');\n if(url){let u='';if(down!=='')for(const x of urls){if(x.s===cur&&x.t<=t+0.02)u=x.u}url.textContent=bare(u);url.parentElement.title=u}\n };\n const update=()=>{paint();if(o.tick)o.tick(v.currentTime)};\n const frame=()=>{update();raf=v.paused?0:requestAnimationFrame(frame)};\n const show=s=>{if(down===null)held=!v.paused;down=s;v.pause();fig.classList.add('broken');c.hidden=true;if(empty)empty.hidden=true;if(note){note.hidden=false;const a=note.querySelector('a');if(a){a.href=srcs.get(s);a.textContent=srcs.get(s)}}if(o.broken)o.broken()};\n const fine=()=>{if(down===null)return;down=null;fig.classList.remove('broken');c.hidden=false;if(note)note.hidden=true;if(empty)empty.hidden=true;if(o.fine)o.fine()};\n const none=()=>{if(down===null)held=!v.paused;++ask;auto=false;down='';v.pause();fig.classList.add('broken');c.hidden=true;if(note)note.hidden=true;if(empty)empty.hidden=false;paint();if(o.broken)o.broken()};\n const playing=()=>down===null?!v.paused:held;\n const next=s=>order.slice(order.indexOf(s)+1).find(n=>!dead.has(n));\n const load=(s,t,go,a)=>{\n const my=++ask;auto=!!a;if(dead.has(s))return show(s);\n if(s!==cur||!v.currentSrc||v.error){cur=s;v.dataset.session=s;v.src=srcs.get(s);v.load()}\n const done=()=>{if(my!==ask)return;auto=false;fine();v.playbackRate=rate;v.currentTime=t;update();if(go)v.play().catch(()=>{})};\n if(v.readyState>0)done();else v.addEventListener('loadedmetadata',done,{once:true});\n };\n const bad=()=>{if(!v.error)return;dead.add(cur);if(down==='')return;const n=auto?next(cur):undefined;if(n!==undefined)return load(n,0,true,true);auto=false;show(cur)};\n ['timeupdate','seeked','loadedmetadata','pause','play','durationchange'].forEach(n=>v.addEventListener(n,update));\n v.addEventListener('play',()=>{if(!raf)raf=requestAnimationFrame(frame)});\n addEventListener('resize',update);\n v.addEventListener('error',bad);if(v.error)queueMicrotask(bad);\n v.addEventListener('ended',()=>{if(o.ended&&o.ended())return;const n=next(cur);if(n!==undefined)load(n,0,true,true)});\n play.addEventListener('click',()=>{if(v.paused)v.play().catch(()=>{});else v.pause()});\n v.addEventListener('click',()=>{if(down!==null)return;if(grow())v.play().catch(()=>{});else play.click()});\n c.querySelectorAll('[data-rate]').forEach(b=>b.addEventListener('click',()=>{rate=Number(b.dataset.rate);v.playbackRate=rate;v.defaultPlaybackRate=rate;c.querySelectorAll('[data-rate]').forEach(x=>x.setAttribute('aria-pressed',String(x===b)))}));\n const seek=t=>{const L=len();t=Math.max(0,L?Math.min(L,t):t);v.currentTime=t;if(o.seek)o.seek(t);update()};\n const at=e=>{const b=bar.getBoundingClientRect();return Math.max(0,Math.min(1,(e.clientX-b.left)/b.width))*len()};\n bar.addEventListener('pointerdown',e=>{if(e.button>0||down!==null)return;drag=true;bar.setPointerCapture(e.pointerId);seek(at(e))});\n bar.addEventListener('pointermove',e=>{if(drag)seek(at(e))});\n ['pointerup','pointercancel'].forEach(n=>bar.addEventListener(n,()=>{drag=false}));\n bar.addEventListener('keydown',e=>{\n const k=e.key,t=v.currentTime,by={ArrowLeft:-1,ArrowDown:-1,ArrowRight:1,ArrowUp:1,PageDown:-10,PageUp:10}[k];\n const to=by!==undefined?t+by:k==='Home'?0:k==='End'?len():null;if(to===null)return;e.preventDefault();seek(to);\n });\n const full=c.querySelector('.full'),screen=o.full||fig.querySelector('.screen');\n const api=!!(d.fullscreenEnabled&&screen.requestFullscreen),inPage=()=>!!o.inPage&&(o.inPage()||!api);\n const mark=()=>{const f=d.fullscreenElement===screen||screen.classList.contains('focus');full.classList.toggle('out',f);full.setAttribute('aria-label',f?'Exit fullscreen':'Fullscreen');update()};\n let back=0;const focus=on=>{if(on)back=scrollY;screen.classList.toggle('focus',on);scrollTo({top:on?0:back,behavior:'auto'});mark()};\n const grow=()=>{if(!o.expand||!o.inPage||!o.inPage()||d.fullscreenElement||screen.classList.contains('focus'))return false;focus(true);return true};\n if(!api&&!o.inPage)full.hidden=true;\n else{full.addEventListener('click',()=>{const f=screen.classList.contains('focus');if(d.fullscreenElement){d.exitFullscreen().catch(()=>{});if(f)focus(false)}else if(f)focus(false);else if(inPage())focus(true);else screen.requestFullscreen().catch(()=>{})});\n d.addEventListener('fullscreenchange',mark);\n d.addEventListener('keydown',e=>{if(e.key==='Escape'&&!e.defaultPrevented&&screen.classList.contains('focus')&&!d.querySelector('dialog[open]')){e.preventDefault();focus(false)}})}\n d.addEventListener('keydown',e=>{if(e.key!==' '||down!==null||e.defaultPrevented||d.querySelector('dialog[open]')||e.target.closest('button,a,input,textarea,select,summary,[role=slider]'))return;e.preventDefault();play.click()});\n return {v,load,none,playing,update,len,cur:()=>cur,down:()=>down,has:s=>srcs.has(s)};\n};\n\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
|
|
@@ -34,8 +34,9 @@ export declare const reportCsp: (assetOrigin?: string) => string;
|
|
|
34
34
|
* A self-contained HTML report: inline CSS, one inline script, and from the network only Geist
|
|
35
35
|
* and Geist Mono from Google Fonts (system fonts offline). Screenshots and the video are linked by
|
|
36
36
|
* paths relative to the run folder, so the page works from disk and after the folder is zipped or
|
|
37
|
-
* moved; or, with `options.assetBaseUrl`, under that URL (see `RenderOptions`)
|
|
38
|
-
* the
|
|
37
|
+
* moved; or, with `options.assetBaseUrl`, under that URL (see `RenderOptions`), and then without
|
|
38
|
+
* the details' raw data row (a host keeps no JSON files). With no options the page is exactly the
|
|
39
|
+
* local one. Code lays out every part and decides every status; the
|
|
39
40
|
* agent's write-up, when it submitted one, fills fixed slots and is labelled as its own. Every
|
|
40
41
|
* piece of text from the job, the page or the agent is escaped.
|
|
41
42
|
*/
|
package/dist/report/html.js
CHANGED
|
@@ -721,11 +721,18 @@ const versionDetail = (bundle) => {
|
|
|
721
721
|
? run
|
|
722
722
|
: html `${run} <span class="note">· report built with ${built}</span>`;
|
|
723
723
|
};
|
|
724
|
-
/**
|
|
725
|
-
|
|
724
|
+
/**
|
|
725
|
+
* The run's details, all from the run: what it checks, where, when, and its raw files. The raw
|
|
726
|
+
* files are left out when `hosted` (an asset base URL): a host stores the screenshots and videos,
|
|
727
|
+
* never the run's JSON files, so links to them would only fail.
|
|
728
|
+
*/
|
|
729
|
+
const runDetails = (bundle, assets, hosted) => {
|
|
726
730
|
const { spec, ledger, summary } = bundle;
|
|
727
731
|
const duration = durationOf(bundle.startedAt, bundle.finishedAt);
|
|
728
732
|
const findings = assets.url(runFiles.findings);
|
|
733
|
+
const rawData = detail('Raw data', html `<a class="file" href="${assets.url(bundle.files.ledger)}">${bundle.files.ledger}</a> ·
|
|
734
|
+
<a class="file" href="${assets.url(runFiles.job)}">${runFiles.job}</a> ·
|
|
735
|
+
<a class="file" href="${assets.url(runFiles.evidence)}">${runFiles.evidence}</a>${bundle.findings ? html ` · <a class="file" href="${findings}">${runFiles.findings}</a>` : ''}`);
|
|
729
736
|
return html `<section class="details" aria-labelledby="details-title">
|
|
730
737
|
<h2 id="details-title">Run details</h2>
|
|
731
738
|
<dl>
|
|
@@ -740,12 +747,7 @@ const runDetails = (bundle, assets) => {
|
|
|
740
747
|
: html `<span class="note">not yet</span>`)}
|
|
741
748
|
${detail('Duration', duration ?? html `<span class="note">n/a</span>`)}
|
|
742
749
|
${detail('Video', videoSummary(bundle, assets))}
|
|
743
|
-
${detail('screw-bugs', versionDetail(bundle))}
|
|
744
|
-
${detail('Raw data', html `<a class="file" href="${assets.url(bundle.files.ledger)}">${bundle.files.ledger}</a> ·
|
|
745
|
-
<a class="file" href="${assets.url(runFiles.job)}">${runFiles.job}</a> ·
|
|
746
|
-
<a class="file" href="${assets.url(runFiles.evidence)}">${runFiles.evidence}</a>${bundle.findings
|
|
747
|
-
? html ` · <a class="file" href="${findings}">${runFiles.findings}</a>`
|
|
748
|
-
: ''}`)}
|
|
750
|
+
${detail('screw-bugs', versionDetail(bundle))} ${hosted ? '' : rawData}
|
|
749
751
|
</dl>
|
|
750
752
|
${ledger.sessions && ledger.sessions.length > 0 ? html `<p>${SESSION_NOTE}</p>` : ''}
|
|
751
753
|
</section>`;
|
|
@@ -770,8 +772,9 @@ const viewerDialog = html `<dialog class="viewer" id="viewer" aria-labelledby="v
|
|
|
770
772
|
* A self-contained HTML report: inline CSS, one inline script, and from the network only Geist
|
|
771
773
|
* and Geist Mono from Google Fonts (system fonts offline). Screenshots and the video are linked by
|
|
772
774
|
* paths relative to the run folder, so the page works from disk and after the folder is zipped or
|
|
773
|
-
* moved; or, with `options.assetBaseUrl`, under that URL (see `RenderOptions`)
|
|
774
|
-
* the
|
|
775
|
+
* moved; or, with `options.assetBaseUrl`, under that URL (see `RenderOptions`), and then without
|
|
776
|
+
* the details' raw data row (a host keeps no JSON files). With no options the page is exactly the
|
|
777
|
+
* local one. Code lays out every part and decides every status; the
|
|
775
778
|
* agent's write-up, when it submitted one, fills fixed slots and is labelled as its own. Every
|
|
776
779
|
* piece of text from the job, the page or the agent is escaped.
|
|
777
780
|
*/
|
|
@@ -847,7 +850,7 @@ export const renderHtmlReport = (bundle, options) => {
|
|
|
847
850
|
</ol>
|
|
848
851
|
</section>`
|
|
849
852
|
: ''}
|
|
850
|
-
${runDetails(bundle, assets)}
|
|
853
|
+
${runDetails(bundle, assets, options?.assetBaseUrl !== undefined)}
|
|
851
854
|
<footer class="foot">
|
|
852
855
|
<p>
|
|
853
856
|
Statuses decided by code in a real browser; write-up by the agent.
|
package/dist/report/markup.d.ts
CHANGED
|
@@ -25,6 +25,10 @@ export declare const textParts: (parts: ReadonlyArray<TextPart>) => Markup[];
|
|
|
25
25
|
* bundle does not know it.
|
|
26
26
|
*/
|
|
27
27
|
export declare const generatorMeta: ({ generator }: ReportBundle) => "" | Markup;
|
|
28
|
+
/**
|
|
29
|
+
* The pages' favicon: the system's colors at first, and each theme's in `data-*`, which the theme
|
|
30
|
+
* button's script (`THEME_BUTTON_JS`) puts in `href` as the reader switches.
|
|
31
|
+
*/
|
|
28
32
|
export declare const favicon: Markup;
|
|
29
33
|
export declare const webFonts: Markup;
|
|
30
34
|
/** A Lucide icon (see `icons.ts`) as markup for the page templates. */
|
package/dist/report/markup.js
CHANGED
|
@@ -48,17 +48,28 @@ export const textParts = (parts) => parts.map((part) => part.kind === 'text'
|
|
|
48
48
|
? html `<q class="value">${part.text}</q>`
|
|
49
49
|
: html `<code>${part.text}</code>`);
|
|
50
50
|
/**
|
|
51
|
-
* The
|
|
52
|
-
*
|
|
53
|
-
* `prefers-color-scheme
|
|
54
|
-
* page stays one file; the CSP allows `data:` images.
|
|
51
|
+
* The report icon, as the design's light and dark favicons draw it: a pixel page with a folded
|
|
52
|
+
* corner, its outline dark, or lime on dark, on nothing. `faviconSvg(style)` colors it: `light`,
|
|
53
|
+
* `dark`, or `system`, which follows `prefers-color-scheme` (the browser's, not the page's theme
|
|
54
|
+
* button). Inline, so the page stays one file; the CSP allows `data:` images. `assets/icon.svg` is
|
|
55
|
+
* the same drawing, as a file for tools that look for a project icon (T3 Code).
|
|
55
56
|
*/
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
const LIME = '#96F011';
|
|
58
|
+
const INK = '#1D1D1D';
|
|
59
|
+
const ICON_PATH = 'M94 2H464V57H94zM409 2H464V464H409zM48 48H103V464H48zM103 57H149V103H103zM103 409H149V455H103z' +
|
|
60
|
+
'M363 409H409V455H363zM94 455H418V510H94zM279 57H334V187H279zM279 132H409V187H279z';
|
|
61
|
+
const faviconSvg = (style) => "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'>" +
|
|
62
|
+
`<style>${style}</style>` +
|
|
63
|
+
`<path d='${ICON_PATH}'/>` +
|
|
61
64
|
'</svg>';
|
|
65
|
+
const LIGHT_STYLE = `path{fill:${INK}}`;
|
|
66
|
+
const DARK_STYLE = `path{fill:${LIME}}`;
|
|
67
|
+
const iconUrl = (style) => `data:image/svg+xml,${faviconSvg(style).replaceAll('#', '%23')}`;
|
|
68
|
+
const FAVICON = {
|
|
69
|
+
light: iconUrl(LIGHT_STYLE),
|
|
70
|
+
dark: iconUrl(DARK_STYLE),
|
|
71
|
+
system: iconUrl(`${LIGHT_STYLE}@media (prefers-color-scheme:dark){${DARK_STYLE}}`),
|
|
72
|
+
};
|
|
62
73
|
/**
|
|
63
74
|
* `<meta name="generator">` with the screw-bugs version that built the page's bundle, so whoever
|
|
64
75
|
* serves or shares the page can tell which version made it without the bundle; nothing when the
|
|
@@ -70,10 +81,18 @@ export const generatorMeta = ({ generator }) => {
|
|
|
70
81
|
const content = `${generator.name} ${generator.version}`;
|
|
71
82
|
return html `<meta name="generator" content="${content}" />`;
|
|
72
83
|
};
|
|
84
|
+
/**
|
|
85
|
+
* The pages' favicon: the system's colors at first, and each theme's in `data-*`, which the theme
|
|
86
|
+
* button's script (`THEME_BUTTON_JS`) puts in `href` as the reader switches.
|
|
87
|
+
*/
|
|
73
88
|
export const favicon = html `<link
|
|
74
89
|
rel="icon"
|
|
75
90
|
type="image/svg+xml"
|
|
76
|
-
href="${
|
|
91
|
+
href="${FAVICON.system}"
|
|
92
|
+
id="favicon"
|
|
93
|
+
data-light="${FAVICON.light}"
|
|
94
|
+
data-dark="${FAVICON.dark}"
|
|
95
|
+
data-system="${FAVICON.system}"
|
|
77
96
|
/>`;
|
|
78
97
|
/**
|
|
79
98
|
* Geist and Geist Mono from Google Fonts, in exactly the weights the pages use (Geist 400,
|
|
@@ -23,9 +23,9 @@ export declare const themeButton: (hidden: boolean) => Markup;
|
|
|
23
23
|
/**
|
|
24
24
|
* The script of the theme button (`themeButton`): `themeCycle(button, key)` names the theme it
|
|
25
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.
|
|
26
|
+
* allows (none: not kept). The favicon (`#favicon`, where the page has its own) follows it. Plain ES2020, without backslashes, for the pages' scripts to include.
|
|
27
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};";
|
|
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(),f=document.getElementById('favicon'),h=f&&f.dataset[T[i]];if(h)f.href=h;b.setAttribute('aria-label',N[T[i]]+'. Switch to '+N[T[(i+1)%3]].toLowerCase());b.title=N[T[i]]};\n show();\n b.addEventListener('click',()=>{const m=T[(at()+1)%3];r.dataset.theme=m;if(key)try{localStorage.setItem(key,m)}catch(e){}show()});\n};";
|
|
29
29
|
/** The project on GitHub, by its mark; `owner/name` beside it from `from` px wide. */
|
|
30
30
|
export declare const githubLink: (from: 640 | 1280) => Markup;
|
|
31
31
|
/** A link to another page of the run (report ↔ walkthrough), by its icon and name. */
|
|
@@ -57,4 +57,4 @@ export declare const topBar: (startedAt: string, jobId: string, other: {
|
|
|
57
57
|
* between the ends; on a phone (below 640 px) the right capsule keeps only icons and the middle one
|
|
58
58
|
* only the date's shortest form (see `topBar`), so the bar stays one row down to 360 px.
|
|
59
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";
|
|
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 /* Icon-only links get the theme button's 32 px cell, a target a finger can hit, with the\n capsule's padding and gaps taken in by as much, so it stays as wide. */\n .menubar.with-mid .ends { gap: 0; padding-left: 4px; }\n .menubar.with-mid .ends a:not(.share-btn) { justify-content: center; width: 32px; height: 32px; border-radius: 999px; }\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";
|
package/dist/report/menu-bar.js
CHANGED
|
@@ -47,12 +47,12 @@ export const themeButton = (hidden) => html `<button
|
|
|
47
47
|
/**
|
|
48
48
|
* The script of the theme button (`themeButton`): `themeCycle(button, key)` names the theme it
|
|
49
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.
|
|
50
|
+
* allows (none: not kept). The favicon (`#favicon`, where the page has its own) follows it. Plain ES2020, without backslashes, for the pages' scripts to include.
|
|
51
51
|
*/
|
|
52
52
|
export const THEME_BUTTON_JS = `const themeCycle=(b,key)=>{
|
|
53
53
|
const r=document.documentElement,T=['light','dark','system'],N={light:'Light theme',dark:'Dark theme',system:'Theme from system'};
|
|
54
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]]};
|
|
55
|
+
const show=()=>{const i=at(),f=document.getElementById('favicon'),h=f&&f.dataset[T[i]];if(h)f.href=h;b.setAttribute('aria-label',N[T[i]]+'. Switch to '+N[T[(i+1)%3]].toLowerCase());b.title=N[T[i]]};
|
|
56
56
|
show();
|
|
57
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
58
|
};`;
|
|
@@ -139,6 +139,10 @@ export const menuBarStyles = /* css */ `
|
|
|
139
139
|
.menubar.with-mid .brand { padding: 0 8px; }
|
|
140
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
141
|
.menubar.with-mid .share-btn { width: 32px; padding: 0; }
|
|
142
|
+
/* Icon-only links get the theme button's 32 px cell, a target a finger can hit, with the
|
|
143
|
+
capsule's padding and gaps taken in by as much, so it stays as wide. */
|
|
144
|
+
.menubar.with-mid .ends { gap: 0; padding-left: 4px; }
|
|
145
|
+
.menubar.with-mid .ends a:not(.share-btn) { justify-content: center; width: 32px; height: 32px; border-radius: 999px; }
|
|
142
146
|
.menubar .when .year { display: none; }
|
|
143
147
|
}
|
|
144
148
|
/* The reports' bar is sticky over a dense page: it keeps the page's background behind it, so no
|
package/dist/report/player.d.ts
CHANGED
|
@@ -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('.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";
|
|
86
|
+
export declare const PLAYER_JS = "const d=document,r=d.documentElement,K='screw-bugs-theme';\nconst still=()=>matchMedia('(prefers-reduced-motion: reduce)').matches;\nconst topEdge=()=>{const b=d.querySelector('.menubar');return b?Math.max(0,b.getBoundingClientRect().bottom):0};\nconst pad=n=>String(n).padStart(2,'0');\nconst clock=s=>{s=Math.max(0,Math.floor(s||0));const h=Math.floor(s/3600),m=Math.floor(s%3600/60);return(h?h+':'+pad(m):String(m))+':'+pad(s%60)};\nlet theme='system';try{theme=localStorage.getItem(K)||theme}catch(e){}r.dataset.theme=theme;\nconst themeCycle=(b,key)=>{\n const r=document.documentElement,T=['light','dark','system'],N={light:'Light theme',dark:'Dark theme',system:'Theme from system'};\n const at=()=>{const i=T.indexOf(r.dataset.theme);return i<0?2:i};\n const show=()=>{const i=at(),f=document.getElementById('favicon'),h=f&&f.dataset[T[i]];if(h)f.href=h;b.setAttribute('aria-label',N[T[i]]+'. Switch to '+N[T[(i+1)%3]].toLowerCase());b.title=N[T[i]]};\n show();\n b.addEventListener('click',()=>{const m=T[(at()+1)%3];r.dataset.theme=m;if(key)try{localStorage.setItem(key,m)}catch(e){}show()});\n};\nconst chrome=()=>{\n d.querySelectorAll('.menubar .theme').forEach(b=>{themeCycle(b,K);b.hidden=false});\n if(location.protocol==='http:'&&(location.hostname==='127.0.0.1'||location.hostname==='localhost'))d.querySelectorAll('a.share-btn').forEach(a=>{a.hidden=false});\n d.querySelectorAll('time.when[datetime]').forEach(e=>{\n const t=new Date(e.getAttribute('datetime'));if(isNaN(t.getTime()))return;const p={};\n try{new Intl.DateTimeFormat('en-US',{month:'short',day:'numeric',year:'numeric',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(t).forEach(x=>{p[x.type]=x.value});\n const y=d.createElement('span');y.className='year';y.textContent=', '+p.year;\n e.replaceChildren(p.month+' '+p.day,y,' '+String.fromCharCode(183)+' '+p.hour+':'+p.minute);\n e.title=new Intl.DateTimeFormat('en-US',{dateStyle:'full',timeStyle:'long'}).format(t)}catch(x){}\n });\n d.querySelectorAll('.prompt').forEach(p=>{\n const t=p.querySelector('.prompt-text'),b=p.querySelector('.prompt-more');if(!t||!b)return;\n const fits=()=>{if(!p.classList.contains('open'))b.hidden=t.scrollHeight<=t.clientHeight+1};\n fits();if(window.ResizeObserver)new ResizeObserver(fits).observe(t);if(d.fonts&&d.fonts.ready)d.fonts.ready.then(fits);\n b.addEventListener('click',()=>{const o=p.classList.toggle('open');b.textContent=o?'Show less':'Show full prompt';b.setAttribute('aria-expanded',String(o));fits()});\n });\n};\nconst bare=u=>{const i=u.indexOf('://');return i<0?u:u.slice(i+3)};\nconst player=(p,o)=>{\n const v=d.getElementById(p+'-video'),fig=v.closest('.player'),note=d.getElementById(p+'-unloaded'),c=d.getElementById(p+'-controls'),url=d.getElementById(p+'-url');\n const srcs=new Map([...fig.querySelectorAll('[data-session-src]')].map(e=>[e.dataset.session,e.dataset.sessionSrc]));\n const order=[...srcs.keys()];\n const urls=[...fig.querySelectorAll('[data-url]')].map(e=>({s:e.dataset.s,t:Number(e.dataset.at),u:e.dataset.url}));\n const dead=new Set(),empty=d.getElementById(p+'-none');let cur=v.dataset.session,down=null,held=false,ask=0,auto=false,rate=1,raf=0,drag=false;\n const play=c.querySelector('.play'),now=c.querySelector('.now'),total=c.querySelector('.total'),bar=c.querySelector('.scrub'),head=c.querySelector('.head'),tracks=[...c.querySelectorAll('.track')];\n v.removeAttribute('controls');c.hidden=false;\n const big=d.getElementById(p+'-start');\n if(big){big.hidden=false;big.addEventListener('click',()=>{grow();v.play().catch(()=>{})});v.addEventListener('play',()=>big.remove(),{once:true})}\n const track=()=>tracks.find(t=>t.dataset.s===cur);\n const len=()=>{const t=track(),n=t?Number(t.dataset.total):0;return n>0?n:(isFinite(v.duration)?v.duration:0)};\n const paint=()=>{\n const L=len(),t=v.currentTime,f=L?Math.min(1,t/L):0,k=track();\n tracks.forEach(x=>{x.hidden=x!==k});head.style.left=(f*100)+'%';\n const done=k&&k.querySelector('.done');if(done)done.style.width=(f*100)+'%';\n now.textContent=clock(t);total.textContent=clock(L);\n bar.setAttribute('aria-valuemax',String(Math.round(L)));bar.setAttribute('aria-valuenow',String(Math.round(t)));bar.setAttribute('aria-valuetext',clock(t)+' of '+clock(L));\n play.classList.toggle('playing',!v.paused);play.setAttribute('aria-label',v.paused?'Play':'Pause');\n if(url){let u='';if(down!=='')for(const x of urls){if(x.s===cur&&x.t<=t+0.02)u=x.u}url.textContent=bare(u);url.parentElement.title=u}\n };\n const update=()=>{paint();if(o.tick)o.tick(v.currentTime)};\n const frame=()=>{update();raf=v.paused?0:requestAnimationFrame(frame)};\n const show=s=>{if(down===null)held=!v.paused;down=s;v.pause();fig.classList.add('broken');c.hidden=true;if(empty)empty.hidden=true;if(note){note.hidden=false;const a=note.querySelector('a');if(a){a.href=srcs.get(s);a.textContent=srcs.get(s)}}if(o.broken)o.broken()};\n const fine=()=>{if(down===null)return;down=null;fig.classList.remove('broken');c.hidden=false;if(note)note.hidden=true;if(empty)empty.hidden=true;if(o.fine)o.fine()};\n const none=()=>{if(down===null)held=!v.paused;++ask;auto=false;down='';v.pause();fig.classList.add('broken');c.hidden=true;if(note)note.hidden=true;if(empty)empty.hidden=false;paint();if(o.broken)o.broken()};\n const playing=()=>down===null?!v.paused:held;\n const next=s=>order.slice(order.indexOf(s)+1).find(n=>!dead.has(n));\n const load=(s,t,go,a)=>{\n const my=++ask;auto=!!a;if(dead.has(s))return show(s);\n if(s!==cur||!v.currentSrc||v.error){cur=s;v.dataset.session=s;v.src=srcs.get(s);v.load()}\n const done=()=>{if(my!==ask)return;auto=false;fine();v.playbackRate=rate;v.currentTime=t;update();if(go)v.play().catch(()=>{})};\n if(v.readyState>0)done();else v.addEventListener('loadedmetadata',done,{once:true});\n };\n const bad=()=>{if(!v.error)return;dead.add(cur);if(down==='')return;const n=auto?next(cur):undefined;if(n!==undefined)return load(n,0,true,true);auto=false;show(cur)};\n ['timeupdate','seeked','loadedmetadata','pause','play','durationchange'].forEach(n=>v.addEventListener(n,update));\n v.addEventListener('play',()=>{if(!raf)raf=requestAnimationFrame(frame)});\n addEventListener('resize',update);\n v.addEventListener('error',bad);if(v.error)queueMicrotask(bad);\n v.addEventListener('ended',()=>{if(o.ended&&o.ended())return;const n=next(cur);if(n!==undefined)load(n,0,true,true)});\n play.addEventListener('click',()=>{if(v.paused)v.play().catch(()=>{});else v.pause()});\n v.addEventListener('click',()=>{if(down!==null)return;if(grow())v.play().catch(()=>{});else play.click()});\n c.querySelectorAll('[data-rate]').forEach(b=>b.addEventListener('click',()=>{rate=Number(b.dataset.rate);v.playbackRate=rate;v.defaultPlaybackRate=rate;c.querySelectorAll('[data-rate]').forEach(x=>x.setAttribute('aria-pressed',String(x===b)))}));\n const seek=t=>{const L=len();t=Math.max(0,L?Math.min(L,t):t);v.currentTime=t;if(o.seek)o.seek(t);update()};\n const at=e=>{const b=bar.getBoundingClientRect();return Math.max(0,Math.min(1,(e.clientX-b.left)/b.width))*len()};\n bar.addEventListener('pointerdown',e=>{if(e.button>0||down!==null)return;drag=true;bar.setPointerCapture(e.pointerId);seek(at(e))});\n bar.addEventListener('pointermove',e=>{if(drag)seek(at(e))});\n ['pointerup','pointercancel'].forEach(n=>bar.addEventListener(n,()=>{drag=false}));\n bar.addEventListener('keydown',e=>{\n const k=e.key,t=v.currentTime,by={ArrowLeft:-1,ArrowDown:-1,ArrowRight:1,ArrowUp:1,PageDown:-10,PageUp:10}[k];\n const to=by!==undefined?t+by:k==='Home'?0:k==='End'?len():null;if(to===null)return;e.preventDefault();seek(to);\n });\n const full=c.querySelector('.full'),screen=o.full||fig.querySelector('.screen');\n const api=!!(d.fullscreenEnabled&&screen.requestFullscreen),inPage=()=>!!o.inPage&&(o.inPage()||!api);\n const mark=()=>{const f=d.fullscreenElement===screen||screen.classList.contains('focus');full.classList.toggle('out',f);full.setAttribute('aria-label',f?'Exit fullscreen':'Fullscreen');update()};\n let back=0;const focus=on=>{if(on)back=scrollY;screen.classList.toggle('focus',on);scrollTo({top:on?0:back,behavior:'auto'});mark()};\n const grow=()=>{if(!o.expand||!o.inPage||!o.inPage()||d.fullscreenElement||screen.classList.contains('focus'))return false;focus(true);return true};\n if(!api&&!o.inPage)full.hidden=true;\n else{full.addEventListener('click',()=>{const f=screen.classList.contains('focus');if(d.fullscreenElement){d.exitFullscreen().catch(()=>{});if(f)focus(false)}else if(f)focus(false);else if(inPage())focus(true);else screen.requestFullscreen().catch(()=>{})});\n d.addEventListener('fullscreenchange',mark);\n d.addEventListener('keydown',e=>{if(e.key==='Escape'&&!e.defaultPrevented&&screen.classList.contains('focus')&&!d.querySelector('dialog[open]')){e.preventDefault();focus(false)}})}\n d.addEventListener('keydown',e=>{if(e.key!==' '||down!==null||e.defaultPrevented||d.querySelector('dialog[open]')||e.target.closest('button,a,input,textarea,select,summary,[role=slider]'))return;e.preventDefault();play.click()});\n return {v,load,none,playing,update,len,cur:()=>cur,down:()=>down,has:s=>srcs.has(s)};\n};\n";
|
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\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})();";
|
|
19
|
+
export declare const SIGN_IN_SCRIPT = "(() => {\n 'use strict';\n const RIVE = 'https://cdn.jsdelivr.net/npm/@rive-app/canvas-lite@2.48.0/', RIVE_JS_SRI = 'sha384-KKLeoe6TCJ0x8AYfmSeeOfpT6u1rpxnG6clu8dKuLNqMImJV40kWrCVhTU7lmcNg', ANIMATION = 'https://static.screwbugs.dev/animations/auth-required.riv';\n // The animation's state while the bug waits by the lock (its `kick` trigger works only then),\n // and how long after the kick the bug has run off, when the browser shows (at most\n // `KICK_WAIT_MAX` after the person started, however long the bug took to reach the lock).\n const WAITING = 'Wait (idle)', KICK_MS = 2300, KICK_WAIT_MAX = 6000;\n const base = location.pathname.replace(/\\/+$/, '');\n const $ = (id) => document.getElementById(id);\n const img = $('screen'), stage = $('stage'), kb = $('keys'), addr = $('addr'), note = $('note');\n let seq = 0, fw = 1280, fh = 800, over = false, saving = false;\n const sleep = (ms) => new Promise((r) => setTimeout(r, ms));\n\n const end = (text) => {\n over = true;\n document.body.classList.add('over');\n note.textContent = text;\n $('ended').textContent = text;\n };\n const GONE = 'This sign-in has ended (it closes after 15 minutes without use), so nothing was saved. Ask your coding agent to start its job again for a new link.';\n\n const queue = [];\n // Inputs per request: under the server's limit (100, and 256 KB with text of up to 2000).\n const BATCH = 50;\n let sending = false;\n // Whether an input may not have reached the browser: Save then asks to check the page first.\n let lost = false;\n const flush = async () => {\n if (sending || over || queue.length === 0) return;\n sending = true;\n const batch = queue.splice(0, BATCH);\n try {\n const r = await fetch(base + '/input', {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify(batch),\n });\n if (r.status === 410) end('This sign-in has ended. You can close this tab.');\n else if (!r.ok) lost = true;\n } catch {\n // It may or may not have been played; sending it again could type twice.\n lost = true;\n await sleep(500);\n }\n if (lost && !over) note.textContent = 'Some input may not have reached the browser; check the page shows what you expect.';\n sending = false;\n flush();\n };\n const send = (input) => {\n // Nothing more goes in once Save was pressed: the session is what the inputs before it made.\n if (saving || over) return;\n const last = queue[queue.length - 1];\n if (input.type === 'mouse' && input.kind === 'move' && last && last.type === 'mouse' && last.kind === 'move') queue[queue.length - 1] = input;\n else queue.push(input);\n flush();\n };\n\n const frames = async () => {\n let failures = 0;\n while (!over) {\n try {\n const r = await fetch(base + '/frame?after=' + seq, { cache: 'no-store' });\n failures = 0;\n if (r.status === 410) return end('This sign-in has ended. You can close this tab.');\n if (r.status === 200) {\n const f = await r.json();\n seq = f.seq; fw = f.width; fh = f.height;\n img.src = 'data:image/jpeg;base64,' + f.jpeg;\n addr.textContent = f.url;\n } else if (r.status !== 204) await sleep(1000);\n } catch {\n // Its server is gone (it ended, or the agent's process stopped): say so rather than wait.\n if (++failures >= 3) return end(GONE);\n await sleep(1000);\n }\n }\n };\n\n let sized;\n const resize = () => {\n clearTimeout(sized);\n sized = setTimeout(() => send({ type: 'viewport', width: Math.round(stage.clientWidth), height: Math.round(stage.clientHeight) }), 250);\n };\n addEventListener('resize', resize);\n\n const at = (e) => {\n const r = img.getBoundingClientRect();\n return {\n x: Math.round(((e.clientX - r.left) * fw) / Math.max(1, r.width)),\n y: Math.round(((e.clientY - r.top) * fh) / Math.max(1, r.height)),\n };\n };\n const button = (b) => (b === 1 ? 'middle' : b === 2 ? 'right' : 'left');\n let touch;\n img.addEventListener('contextmenu', (e) => e.preventDefault());\n img.addEventListener('pointerdown', (e) => {\n e.preventDefault();\n kb.focus({ preventScroll: true });\n img.setPointerCapture(e.pointerId);\n const p = at(e);\n if (e.pointerType === 'mouse') send({ type: 'mouse', kind: 'down', ...p, button: button(e.button), clickCount: Math.min(3, Math.max(1, e.detail || 1)) });\n else touch = { x: e.clientX, y: e.clientY, moved: false };\n });\n img.addEventListener('pointermove', (e) => {\n const p = at(e);\n if (e.pointerType === 'mouse') return send({ type: 'mouse', kind: 'move', ...p });\n if (!touch) return;\n const dx = e.clientX - touch.x, dy = e.clientY - touch.y;\n if (!touch.moved && Math.hypot(dx, dy) < 8) return;\n touch.moved = true;\n const scale = fw / Math.max(1, img.getBoundingClientRect().width);\n send({ type: 'wheel', ...p, dx: Math.round(-dx * scale), dy: Math.round(-dy * scale) });\n touch.x = e.clientX; touch.y = e.clientY;\n });\n img.addEventListener('pointerup', (e) => {\n const p = at(e);\n if (e.pointerType === 'mouse') return send({ type: 'mouse', kind: 'up', ...p, button: button(e.button), clickCount: Math.min(3, Math.max(1, e.detail || 1)) });\n if (touch && !touch.moved) {\n send({ type: 'mouse', kind: 'move', ...p });\n send({ type: 'mouse', kind: 'down', ...p, button: 'left', clickCount: 1 });\n send({ type: 'mouse', kind: 'up', ...p, button: 'left', clickCount: 1 });\n }\n touch = undefined;\n });\n img.addEventListener('pointercancel', () => { touch = undefined; });\n img.addEventListener('wheel', (e) => {\n e.preventDefault();\n const unit = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? fh : 1;\n send({ type: 'wheel', ...at(e), dx: Math.round(e.deltaX * unit), dy: Math.round(e.deltaY * unit) });\n }, { passive: false });\n\n const ignored = new Set(['Shift', 'Control', 'Alt', 'Meta', 'CapsLock', 'Unidentified', 'Dead', 'Process', 'Compose']);\n let composing = false;\n kb.addEventListener('compositionstart', () => { composing = true; });\n kb.addEventListener('compositionend', () => { composing = false; typed(); });\n kb.addEventListener('keydown', (e) => {\n if (e.isComposing || e.keyCode === 229 || ignored.has(e.key)) return;\n // A character typed with AltGr (an @ on many European keyboards, where it also reports Ctrl\n // and Alt) or with Option on a Mac is text, not a shortcut: the box gets it as input.\n const altGraph = e.getModifierState && e.getModifierState('AltGraph');\n if (e.key.length === 1 && (altGraph || (e.altKey && !e.ctrlKey && !e.metaKey))) return;\n const command = e.ctrlKey || e.metaKey || e.altKey;\n // Pasting goes in as text, from the paste itself.\n if (command && e.key.toLowerCase() === 'v') return;\n if (e.key.length === 1 && !command) return;\n e.preventDefault();\n const modifiers = [e.altKey && 'Alt', e.ctrlKey && 'Control', e.metaKey && 'Meta', e.shiftKey && 'Shift'].filter(Boolean);\n send({ type: 'key', key: e.key, modifiers });\n });\n // The box always holds one invisible character, so a phone keyboard's Backspace (often only\n // keyCode 229 or 'Unidentified' on keydown) has something to delete, which shows below.\n const MARK = '\u200B';\n const reset = () => {\n kb.value = MARK;\n kb.setSelectionRange(1, 1);\n };\n const typed = () => {\n if (composing) return;\n const value = kb.value;\n const text = value.split(MARK).join('');\n if (!value.includes(MARK) && !text) send({ type: 'key', key: 'Backspace', modifiers: [] });\n if (text) send({ type: 'text', text: text.slice(0, 2000) });\n reset();\n };\n kb.addEventListener('beforeinput', (e) => {\n // Deleting, as keyboards that send no key for it say it: played as the key itself.\n const key = e.inputType === 'deleteContentBackward' ? 'Backspace' : e.inputType === 'deleteContentForward' ? 'Delete' : undefined;\n if (key === undefined || !e.cancelable) return;\n e.preventDefault();\n send({ type: 'key', key, modifiers: [] });\n });\n kb.addEventListener('input', typed);\n kb.addEventListener('focus', reset);\n reset();\n\n $('back').addEventListener('click', () => send({ type: 'nav', kind: 'back' }));\n $('reload').addEventListener('click', () => send({ type: 'nav', kind: 'reload' }));\n const post = async (route) => {\n const r = await fetch(base + '/' + route, { method: 'POST', headers: { 'content-type': 'application/json' }, body: '{}' });\n return r;\n };\n /** Until every input already given has been played (or the sign-in ended). */\n const drained = async () => {\n while (!over && (sending || queue.length > 0)) await sleep(50);\n };\n $('save').addEventListener('click', async () => {\n if (saving || over) return;\n saving = true;\n document.body.classList.add('saving');\n note.textContent = 'Saving\u2026';\n try {\n await drained();\n if (over) return;\n if (lost) {\n lost = false;\n saving = false;\n document.body.classList.remove('saving');\n note.textContent = 'Some input did not reach the browser, so nothing was saved yet. Check the page shows you signed in, then press Save sign-in again.';\n return;\n }\n const r = await post('save');\n if (r.ok) return end('Saved. You can close this tab; your coding agent can start the run again.');\n if (r.status === 410) return end('This sign-in has ended. You can close this tab.');\n note.textContent = 'Could not save: ' + (await r.text());\n } catch {\n note.textContent = 'Could not reach screw-bugs to save. Try again.';\n }\n saving = false;\n document.body.classList.remove('saving');\n });\n $('cancel').addEventListener('click', async () => {\n try { await post('cancel'); } catch {}\n end('Cancelled. Nothing was saved. You can close this tab.');\n });\n\n // The theme: light, dark or the system's, in turn, as on screw-bugs Cloud's menu bar (the\n // reports' tokens follow `data-theme`). Not kept: each sign-in is a new origin.\n const themeCycle=(b,key)=>{\n const r=document.documentElement,T=['light','dark','system'],N={light:'Light theme',dark:'Dark theme',system:'Theme from system'};\n const at=()=>{const i=T.indexOf(r.dataset.theme);return i<0?2:i};\n const show=()=>{const i=at(),f=document.getElementById('favicon'),h=f&&f.dataset[T[i]];if(h)f.href=h;b.setAttribute('aria-label',N[T[i]]+'. Switch to '+N[T[(i+1)%3]].toLowerCase());b.title=N[T[i]]};\n show();\n b.addEventListener('click',()=>{const m=T[(at()+1)%3];r.dataset.theme=m;if(key)try{localStorage.setItem(key,m)}catch(e){}show()});\n};\n themeCycle(document.querySelector('.menubar .theme'));\n\n // The animation: the bug waits by a lock, and kicks it open when the person starts. It plays\n // with Rive's runtime from its CDN (taken only with the hash it was published with) and the file\n // from screw-bugs' CDN. Without either, or where the person prefers less motion, the page is the\n // same without it.\n const art = $('art');\n // `instance` from when it is made, `rive` once its file loaded; `stopped` once the art is gone\n // for good (it failed, or the person started), so nothing that loads later plays.\n let instance, rive, observer, stopped = false, waiting = false, onWaiting;\n const noArt = () => {\n stopped = true;\n if (art) art.hidden = true;\n if (observer) observer.disconnect();\n try {\n if (instance) instance.cleanup();\n } catch {}\n instance = rive = observer = undefined;\n };\n if (art && !matchMedia('(prefers-reduced-motion: reduce)').matches) {\n const runtime = document.createElement('script');\n runtime.src = RIVE + 'rive.js';\n runtime.integrity = RIVE_JS_SRI;\n runtime.crossOrigin = 'anonymous';\n runtime.onerror = noArt;\n runtime.onload = () => {\n if (stopped) return;\n try {\n const R = window.rive;\n // The runtime is pinned, so the state changes it still gives are what this relies on.\n R.Rive.suppressDeprecationWarnings = ['state-change-events'];\n R.RuntimeLoader.setWasmUrl(RIVE + 'rive.wasm');\n R.RuntimeLoader.setWasmFallbackUrl(RIVE + 'rive_fallback.wasm');\n const canvas = art.querySelector('canvas');\n const r = new R.Rive({\n src: ANIMATION,\n canvas,\n autoplay: true,\n stateMachine: 'Main',\n // Binds the file's view model, whose `kick` trigger starts the kick.\n autoBind: true,\n layout: new R.Layout({ fit: R.Fit.Contain, alignment: R.Alignment.Center }),\n onLoad: () => {\n if (stopped) return;\n r.resizeDrawingSurfaceToCanvas();\n rive = r;\n },\n onLoadError: noArt,\n onStateChange: (e) => {\n for (const name of [].concat(e.data || [])) {\n if (name === WAITING) waiting = true;\n else if (name === 'Arrive' || name === 'Kick') waiting = false;\n }\n if (waiting && onWaiting) onWaiting();\n },\n });\n instance = r;\n observer = new ResizeObserver(() => rive && rive.resizeDrawingSurfaceToCanvas());\n observer.observe(canvas);\n } catch {\n noArt();\n }\n };\n document.head.appendChild(runtime);\n } else noArt();\n /** Plays the kick (once the bug waits by the lock), resolving when the bug has run off. */\n const kick = () =>\n new Promise((done) => {\n if (!rive) return done();\n const cap = setTimeout(done, KICK_WAIT_MAX);\n onWaiting = () => {\n onWaiting = undefined;\n try {\n rive.viewModelInstance.trigger('kick').trigger();\n } catch {\n clearTimeout(cap);\n return done();\n }\n setTimeout(() => {\n clearTimeout(cap);\n done();\n }, KICK_MS);\n };\n if (waiting) onWaiting();\n });\n\n // The explainer comes first; the browser shows (and its frames start) once the person starts.\n let starting = false;\n $('start').addEventListener('click', async () => {\n if (starting || over) return;\n starting = true;\n $('start').setAttribute('aria-disabled', 'true');\n // Reading this takes no requests, so the sign-in may have ended meanwhile.\n try {\n const r = await fetch(base + '/status', { cache: 'no-store' });\n if (!r.ok) return end(GONE);\n } catch {\n return end(GONE);\n }\n await kick();\n noArt();\n if (over) return;\n document.body.classList.remove('intro');\n resize();\n frames();\n });\n})();";
|
|
20
20
|
/**
|
|
21
21
|
* The live view's Content-Security-Policy: its own script, frames and icons as data URLs, its own
|
|
22
22
|
* routes, Google Fonts as the reports load them (`webFonts`), Rive's runtime from its exact folder
|
|
@@ -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('.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})();";
|
|
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(),f=document.getElementById('favicon'),h=f&&f.dataset[T[i]];if(h)f.href=h;b.setAttribute('aria-label',N[T[i]]+'. Switch to '+N[T[(i+1)%3]].toLowerCase());b.title=N[T[i]]};\n show();\n b.addEventListener('click',()=>{const m=T[(at()+1)%3];r.dataset.theme=m;if(key)try{localStorage.setItem(key,m)}catch(e){}show()});\n};\nconst chrome=()=>{\n d.querySelectorAll('.menubar .theme').forEach(b=>{themeCycle(b,K);b.hidden=false});\n if(location.protocol==='http:'&&(location.hostname==='127.0.0.1'||location.hostname==='localhost'))d.querySelectorAll('a.share-btn').forEach(a=>{a.hidden=false});\n d.querySelectorAll('time.when[datetime]').forEach(e=>{\n const t=new Date(e.getAttribute('datetime'));if(isNaN(t.getTime()))return;const p={};\n try{new Intl.DateTimeFormat('en-US',{month:'short',day:'numeric',year:'numeric',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(t).forEach(x=>{p[x.type]=x.value});\n const y=d.createElement('span');y.className='year';y.textContent=', '+p.year;\n e.replaceChildren(p.month+' '+p.day,y,' '+String.fromCharCode(183)+' '+p.hour+':'+p.minute);\n e.title=new Intl.DateTimeFormat('en-US',{dateStyle:'full',timeStyle:'long'}).format(t)}catch(x){}\n });\n d.querySelectorAll('.prompt').forEach(p=>{\n const t=p.querySelector('.prompt-text'),b=p.querySelector('.prompt-more');if(!t||!b)return;\n const fits=()=>{if(!p.classList.contains('open'))b.hidden=t.scrollHeight<=t.clientHeight+1};\n fits();if(window.ResizeObserver)new ResizeObserver(fits).observe(t);if(d.fonts&&d.fonts.ready)d.fonts.ready.then(fits);\n b.addEventListener('click',()=>{const o=p.classList.toggle('open');b.textContent=o?'Show less':'Show full prompt';b.setAttribute('aria-expanded',String(o));fits()});\n });\n};\nconst bare=u=>{const i=u.indexOf('://');return i<0?u:u.slice(i+3)};\nconst player=(p,o)=>{\n const v=d.getElementById(p+'-video'),fig=v.closest('.player'),note=d.getElementById(p+'-unloaded'),c=d.getElementById(p+'-controls'),url=d.getElementById(p+'-url');\n const srcs=new Map([...fig.querySelectorAll('[data-session-src]')].map(e=>[e.dataset.session,e.dataset.sessionSrc]));\n const order=[...srcs.keys()];\n const urls=[...fig.querySelectorAll('[data-url]')].map(e=>({s:e.dataset.s,t:Number(e.dataset.at),u:e.dataset.url}));\n const dead=new Set(),empty=d.getElementById(p+'-none');let cur=v.dataset.session,down=null,held=false,ask=0,auto=false,rate=1,raf=0,drag=false;\n const play=c.querySelector('.play'),now=c.querySelector('.now'),total=c.querySelector('.total'),bar=c.querySelector('.scrub'),head=c.querySelector('.head'),tracks=[...c.querySelectorAll('.track')];\n v.removeAttribute('controls');c.hidden=false;\n const big=d.getElementById(p+'-start');\n if(big){big.hidden=false;big.addEventListener('click',()=>{grow();v.play().catch(()=>{})});v.addEventListener('play',()=>big.remove(),{once:true})}\n const track=()=>tracks.find(t=>t.dataset.s===cur);\n const len=()=>{const t=track(),n=t?Number(t.dataset.total):0;return n>0?n:(isFinite(v.duration)?v.duration:0)};\n const paint=()=>{\n const L=len(),t=v.currentTime,f=L?Math.min(1,t/L):0,k=track();\n tracks.forEach(x=>{x.hidden=x!==k});head.style.left=(f*100)+'%';\n const done=k&&k.querySelector('.done');if(done)done.style.width=(f*100)+'%';\n now.textContent=clock(t);total.textContent=clock(L);\n bar.setAttribute('aria-valuemax',String(Math.round(L)));bar.setAttribute('aria-valuenow',String(Math.round(t)));bar.setAttribute('aria-valuetext',clock(t)+' of '+clock(L));\n play.classList.toggle('playing',!v.paused);play.setAttribute('aria-label',v.paused?'Play':'Pause');\n if(url){let u='';if(down!=='')for(const x of urls){if(x.s===cur&&x.t<=t+0.02)u=x.u}url.textContent=bare(u);url.parentElement.title=u}\n };\n const update=()=>{paint();if(o.tick)o.tick(v.currentTime)};\n const frame=()=>{update();raf=v.paused?0:requestAnimationFrame(frame)};\n const show=s=>{if(down===null)held=!v.paused;down=s;v.pause();fig.classList.add('broken');c.hidden=true;if(empty)empty.hidden=true;if(note){note.hidden=false;const a=note.querySelector('a');if(a){a.href=srcs.get(s);a.textContent=srcs.get(s)}}if(o.broken)o.broken()};\n const fine=()=>{if(down===null)return;down=null;fig.classList.remove('broken');c.hidden=false;if(note)note.hidden=true;if(empty)empty.hidden=true;if(o.fine)o.fine()};\n const none=()=>{if(down===null)held=!v.paused;++ask;auto=false;down='';v.pause();fig.classList.add('broken');c.hidden=true;if(note)note.hidden=true;if(empty)empty.hidden=false;paint();if(o.broken)o.broken()};\n const playing=()=>down===null?!v.paused:held;\n const next=s=>order.slice(order.indexOf(s)+1).find(n=>!dead.has(n));\n const load=(s,t,go,a)=>{\n const my=++ask;auto=!!a;if(dead.has(s))return show(s);\n if(s!==cur||!v.currentSrc||v.error){cur=s;v.dataset.session=s;v.src=srcs.get(s);v.load()}\n const done=()=>{if(my!==ask)return;auto=false;fine();v.playbackRate=rate;v.currentTime=t;update();if(go)v.play().catch(()=>{})};\n if(v.readyState>0)done();else v.addEventListener('loadedmetadata',done,{once:true});\n };\n const bad=()=>{if(!v.error)return;dead.add(cur);if(down==='')return;const n=auto?next(cur):undefined;if(n!==undefined)return load(n,0,true,true);auto=false;show(cur)};\n ['timeupdate','seeked','loadedmetadata','pause','play','durationchange'].forEach(n=>v.addEventListener(n,update));\n v.addEventListener('play',()=>{if(!raf)raf=requestAnimationFrame(frame)});\n addEventListener('resize',update);\n v.addEventListener('error',bad);if(v.error)queueMicrotask(bad);\n v.addEventListener('ended',()=>{if(o.ended&&o.ended())return;const n=next(cur);if(n!==undefined)load(n,0,true,true)});\n play.addEventListener('click',()=>{if(v.paused)v.play().catch(()=>{});else v.pause()});\n v.addEventListener('click',()=>{if(down!==null)return;if(grow())v.play().catch(()=>{});else play.click()});\n c.querySelectorAll('[data-rate]').forEach(b=>b.addEventListener('click',()=>{rate=Number(b.dataset.rate);v.playbackRate=rate;v.defaultPlaybackRate=rate;c.querySelectorAll('[data-rate]').forEach(x=>x.setAttribute('aria-pressed',String(x===b)))}));\n const seek=t=>{const L=len();t=Math.max(0,L?Math.min(L,t):t);v.currentTime=t;if(o.seek)o.seek(t);update()};\n const at=e=>{const b=bar.getBoundingClientRect();return Math.max(0,Math.min(1,(e.clientX-b.left)/b.width))*len()};\n bar.addEventListener('pointerdown',e=>{if(e.button>0||down!==null)return;drag=true;bar.setPointerCapture(e.pointerId);seek(at(e))});\n bar.addEventListener('pointermove',e=>{if(drag)seek(at(e))});\n ['pointerup','pointercancel'].forEach(n=>bar.addEventListener(n,()=>{drag=false}));\n bar.addEventListener('keydown',e=>{\n const k=e.key,t=v.currentTime,by={ArrowLeft:-1,ArrowDown:-1,ArrowRight:1,ArrowUp:1,PageDown:-10,PageUp:10}[k];\n const to=by!==undefined?t+by:k==='Home'?0:k==='End'?len():null;if(to===null)return;e.preventDefault();seek(to);\n });\n const full=c.querySelector('.full'),screen=o.full||fig.querySelector('.screen');\n const api=!!(d.fullscreenEnabled&&screen.requestFullscreen),inPage=()=>!!o.inPage&&(o.inPage()||!api);\n const mark=()=>{const f=d.fullscreenElement===screen||screen.classList.contains('focus');full.classList.toggle('out',f);full.setAttribute('aria-label',f?'Exit fullscreen':'Fullscreen');update()};\n let back=0;const focus=on=>{if(on)back=scrollY;screen.classList.toggle('focus',on);scrollTo({top:on?0:back,behavior:'auto'});mark()};\n const grow=()=>{if(!o.expand||!o.inPage||!o.inPage()||d.fullscreenElement||screen.classList.contains('focus'))return false;focus(true);return true};\n if(!api&&!o.inPage)full.hidden=true;\n else{full.addEventListener('click',()=>{const f=screen.classList.contains('focus');if(d.fullscreenElement){d.exitFullscreen().catch(()=>{});if(f)focus(false)}else if(f)focus(false);else if(inPage())focus(true);else screen.requestFullscreen().catch(()=>{})});\n d.addEventListener('fullscreenchange',mark);\n d.addEventListener('keydown',e=>{if(e.key==='Escape'&&!e.defaultPrevented&&screen.classList.contains('focus')&&!d.querySelector('dialog[open]')){e.preventDefault();focus(false)}})}\n d.addEventListener('keydown',e=>{if(e.key!==' '||down!==null||e.defaultPrevented||d.querySelector('dialog[open]')||e.target.closest('button,a,input,textarea,select,summary,[role=slider]'))return;e.preventDefault();play.click()});\n return {v,load,none,playing,update,len,cur:()=>cur,down:()=>down,has:s=>srcs.has(s)};\n};\n\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.
|
|
@@ -645,7 +645,7 @@ export const renderWalkthrough = (bundle, options) => {
|
|
|
645
645
|
<body>
|
|
646
646
|
${scriptTag}
|
|
647
647
|
<div class="${`wt device-${bundle.device.kind}`}" style="${shapeStyle(bundle)}">
|
|
648
|
-
${topBar(bundle.startedAt, bundle.jobId, { href: report, name: '
|
|
648
|
+
${topBar(bundle.startedAt, bundle.jobId, { href: report, name: 'Report', icon: 'file-text' })}
|
|
649
649
|
${promptBlock(spec.instructions)}
|
|
650
650
|
${ledger.error
|
|
651
651
|
? html `<div class="alert" role="note">
|