screw-bugs 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -20
- package/dist/browser-playwright/launch.js +3 -1
- package/dist/browser-playwright/page.d.ts +3 -11
- package/dist/browser-playwright/page.js +17 -1
- package/dist/browser-playwright/sign-in.d.ts +77 -0
- package/dist/browser-playwright/sign-in.js +217 -0
- package/dist/build-info.json +3 -3
- package/dist/cli/app.js +4 -1
- package/dist/cli/commands.js +68 -3
- package/dist/cli/exit-codes.d.ts +6 -0
- package/dist/cli/exit-codes.js +6 -0
- package/dist/cli/mcp.js +17 -3
- package/dist/cli/operations.d.ts +31 -3
- package/dist/cli/operations.js +95 -3
- package/dist/cli/sign-in.d.ts +79 -0
- package/dist/cli/sign-in.js +305 -0
- package/dist/core/accounts.d.ts +40 -0
- package/dist/core/accounts.js +95 -0
- package/dist/core/engine.d.ts +8 -4
- package/dist/core/engine.js +39 -9
- package/dist/core/errors.d.ts +19 -0
- package/dist/core/errors.js +6 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +1 -0
- package/dist/core/services.d.ts +77 -8
- package/dist/core/services.js +4 -1
- package/dist/report/bug.d.ts +2 -2
- package/dist/report/bug.js +5 -4
- package/dist/report/html.d.ts +1 -1
- package/dist/report/html.js +3 -2
- package/dist/report/icons.d.ts +2 -0
- package/dist/report/icons.js +4 -3
- package/dist/report/index.d.ts +2 -1
- package/dist/report/index.js +2 -1
- package/dist/report/markup.d.ts +2 -13
- package/dist/report/markup.js +8 -62
- package/dist/report/menu-bar.d.ts +60 -0
- package/dist/report/menu-bar.js +153 -0
- package/dist/report/player.d.ts +9 -4
- package/dist/report/player.js +24 -13
- package/dist/report/sign-in.d.ts +41 -0
- package/dist/report/sign-in.js +539 -0
- package/dist/report/styles.js +10 -34
- package/dist/report/walkthrough.d.ts +3 -2
- package/dist/report/walkthrough.js +50 -40
- package/dist/schema/accounts.d.ts +137 -0
- package/dist/schema/accounts.js +112 -0
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/index.js +1 -0
- package/dist/schema/job.d.ts +27 -6
- package/dist/schema/job.js +12 -2
- package/dist/schema/ledger.d.ts +5 -1
- package/dist/store-local/accounts.d.ts +8 -4
- package/dist/store-local/accounts.js +82 -7
- package/dist/store-local/paths.d.ts +4 -1
- package/dist/store-local/paths.js +4 -1
- package/package.json +2 -2
package/dist/report/styles.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { menuBarStyles } from './menu-bar.js';
|
|
1
2
|
import { CROP_WIDE } from './view.js';
|
|
2
3
|
/*
|
|
3
4
|
* The styles both pages share: the report and the walkthrough. Colors are tokens with a light and
|
|
4
5
|
* a dark set (greys are Radix Olive, the accent is screw-bugs' lime), plus shadcn/ui's `--input`
|
|
5
6
|
* (a switch's track when off) and `--ring` (the focus ring) mapped onto them: the system's choice by
|
|
6
|
-
* default (`prefers-color-scheme`), or the reader's from the theme
|
|
7
|
+
* default (`prefers-color-scheme`), or the reader's from the theme button (`data-theme` on the
|
|
7
8
|
* root, set by the page's script). Lime is only ever a fill behind dark text. Recordings,
|
|
8
9
|
* screenshots and the marks drawn over them keep their colors in both themes.
|
|
9
10
|
*
|
|
@@ -88,37 +89,17 @@ q.value { quotes: "\\201C" "\\201D"; }
|
|
|
88
89
|
.label { margin: 0 0 10px; font: var(--t-small-strong); color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
|
|
89
90
|
h1, h2, h3, h4 { text-wrap: balance; }
|
|
90
91
|
|
|
91
|
-
/*
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
.
|
|
96
|
-
.brand:hover .brand-name { text-decoration: underline; }
|
|
97
|
-
/* The bug, the one of the page's theme, at 1.5 px per cell of its 15-cell grid: 3 device pixels
|
|
98
|
-
per cell on a 2x screen, so it is exact there, and its cells stay hard-edged (pixelated) on any.
|
|
99
|
-
About the height of the wordmark's two lines of capitals. */
|
|
100
|
-
.bug { display: block; flex: none; width: 22.5px; height: 22.5px; }
|
|
92
|
+
/* The menu bar (\`menu-bar.ts\`). It stays on top while the page scrolls, \`--bar\` high (as it is):
|
|
93
|
+
whatever else sticks goes under it. */
|
|
94
|
+
${menuBarStyles}
|
|
95
|
+
/* The bug of the page's theme, and brand logos (logos.ts), in their own colors. */
|
|
96
|
+
.bug { display: block; flex: none; width: 24px; height: 24px; }
|
|
101
97
|
.bug img { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
|
|
102
|
-
/* Brand logos (logos.ts): in their own colors, left of the words that name them. */
|
|
103
98
|
.logo { display: block; flex: none; }
|
|
104
99
|
.bug-dark, .gh-dark { display: none; }
|
|
105
100
|
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) :is(.bug-light, .gh-light) { display: none; } :root:not([data-theme="light"]) :is(.bug-dark, .gh-dark) { display: block; } }
|
|
106
101
|
:root[data-theme="dark"] :is(.bug-light, .gh-light) { display: none; }
|
|
107
102
|
:root[data-theme="dark"] :is(.bug-dark, .gh-dark) { display: block; }
|
|
108
|
-
.links a.gh { display: inline-flex; align-items: center; gap: 6px; }
|
|
109
|
-
.when { justify-self: center; white-space: nowrap; }
|
|
110
|
-
.links { justify-self: end; display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
|
|
111
|
-
.links a { color: inherit; text-decoration: none; }
|
|
112
|
-
.links a:hover { color: var(--muted); text-decoration: underline; }
|
|
113
|
-
.links .sep { width: 1px; height: 12px; background: currentColor; opacity: .7; }
|
|
114
|
-
/* A toggle group, like the player's speed buttons, smaller. */
|
|
115
|
-
.share-btn { display: inline-flex; align-items: center; gap: 6px; height: 28px; margin-left: 4px; padding: 0 12px; border-radius: 999px; background: var(--accent); color: var(--on-accent) !important; font: var(--t-control); text-decoration: none !important; }
|
|
116
|
-
.share-btn:hover { filter: brightness(.95); }
|
|
117
|
-
.share-btn[hidden] { display: none; }
|
|
118
|
-
.theme { display: inline-flex; margin-left: 4px; padding: 2px; border-radius: 999px; background: var(--subtle); }
|
|
119
|
-
.theme button { display: grid; place-items: center; width: 28px; height: 24px; padding: 0; border: 0; border-radius: 999px; background: none; color: var(--muted); cursor: pointer; }
|
|
120
|
-
.theme button:hover { color: var(--text); background: var(--subtle-hover); }
|
|
121
|
-
.theme button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
|
|
122
103
|
|
|
123
104
|
/* What was asked, in quotes, clamped; "read full prompt" opens it in place. */
|
|
124
105
|
.prompt { margin: 0 auto; max-width: 46em; text-align: center; font: var(--t-prompt); color: var(--muted); }
|
|
@@ -151,7 +132,7 @@ figure { margin: 0; }
|
|
|
151
132
|
.url span { overflow: hidden; text-overflow: ellipsis; }
|
|
152
133
|
.url:empty::before, .url span:empty::before { content: "\\00a0"; }
|
|
153
134
|
.screen { position: relative; aspect-ratio: var(--ar, 16 / 10); background: var(--video); }
|
|
154
|
-
.screen video { display: block; width: 100%; height: 100%; object-fit: contain; background: var(--video); }
|
|
135
|
+
.screen video { display: block; width: 100%; height: 100%; object-fit: contain; background: var(--video); cursor: pointer; }
|
|
155
136
|
.device-mobile .window { border-radius: 28px; padding: 8px 8px 10px; background: var(--subtle); }
|
|
156
137
|
.device-mobile .toolbar { height: 38px; border: 0; padding: 0; margin-bottom: 8px; }
|
|
157
138
|
.device-mobile .dots { display: none; }
|
|
@@ -269,13 +250,8 @@ label.toggle input { appearance: none; margin: 0; cursor: pointer; }
|
|
|
269
250
|
@container fig (width < ${CROP_WIDE.frame}px) { :is(.shot, .crop) .v-wide { display: none; } }
|
|
270
251
|
@container fig (width >= ${CROP_WIDE.frame}px) { :is(.shot, .crop) .v-narrow { display: none; } }
|
|
271
252
|
|
|
253
|
+
@media (min-width: 768px) { :root { --bar: 72px; } }
|
|
272
254
|
@media (max-width: 680px) {
|
|
273
|
-
/* Two rows: the brand and when; the links and the theme switch. */
|
|
274
|
-
:root { --bar: 76px; }
|
|
275
|
-
.top { grid-template-columns: 1fr auto; gap: 2px 12px; align-content: center; padding: 0 16px; }
|
|
276
|
-
.when { justify-self: end; }
|
|
277
|
-
.links { grid-column: 1 / -1; justify-self: stretch; justify-content: flex-start; }
|
|
278
|
-
.links .theme { margin-left: auto; }
|
|
279
255
|
.speed button { min-width: 36px; }
|
|
280
256
|
}
|
|
281
257
|
@media (max-width: 900px) {
|
|
@@ -284,7 +260,7 @@ label.toggle input { appearance: none; margin: 0; cursor: pointer; }
|
|
|
284
260
|
}
|
|
285
261
|
@media print {
|
|
286
262
|
html { background: #fff; }
|
|
287
|
-
.
|
|
263
|
+
.mk-switch, .controls { display: none; }
|
|
288
264
|
}
|
|
289
265
|
@media (prefers-reduced-motion: reduce) { *, *::before, *::after, ::backdrop { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }
|
|
290
266
|
`;
|
|
@@ -21,7 +21,8 @@ export declare const GLIDE_S = 0.6;
|
|
|
21
21
|
* measured, makes timecodes and rows seek (and switch session videos) instead of opening the file,
|
|
22
22
|
* and, with "Skip inactive" on, jumps over the stretches where no step ran while it plays.
|
|
23
23
|
* "Expand" shows the whole script and makes the video smaller. Fullscreen takes the whole page
|
|
24
|
-
* (`.wt`), not only the video
|
|
24
|
+
* (`.wt`), not only the video; on a wide screen (a desktop) it never takes the browser's screen,
|
|
25
|
+
* only lays the page out again (`.focus`, see `PLAYER_JS`): the top bar, the video as big as fits with its address over it and
|
|
25
26
|
* the step playing now as a caption under it, and the controls; the prompt and the script are left
|
|
26
27
|
* out. A session video that does not load
|
|
27
28
|
* is remembered as broken on its own (see `PLAYER_JS`). Without script, timecodes open the video
|
|
@@ -39,7 +40,7 @@ export declare const GLIDE_S = 0.6;
|
|
|
39
40
|
* and there is no ripple. A "Cursor" switch turns it off, remembered like the theme. Nothing is
|
|
40
41
|
* added to the page under test or to the video.
|
|
41
42
|
*/
|
|
42
|
-
export declare const WALKTHROUGH_SCRIPT = "(()=>{const d=document,r=d.documentElement,K='screw-bugs-theme';\nconst still=()=>matchMedia('(prefers-reduced-motion: reduce)').matches;\nconst topEdge=()=>{const b=d.querySelector('.top');return b?Math.max(0,b.getBoundingClientRect().bottom):0};\nconst pad=n=>String(n).padStart(2,'0');\nconst clock=s=>{s=Math.max(0,Math.floor(s||0));const h=Math.floor(s/3600),m=Math.floor(s%3600/60);return(h?h+':'+pad(m):String(m))+':'+pad(s%60)};\nconst setTheme=m=>{r.dataset.theme=m;d.querySelectorAll('[data-theme-set]').forEach(b=>b.setAttribute('aria-pressed',String(b.dataset.themeSet===m)))};\nlet theme='system';try{theme=localStorage.getItem(K)||theme}catch(e){}r.dataset.theme=theme;\nconst chrome=()=>{\n setTheme(r.dataset.theme);\n d.querySelectorAll('.theme').forEach(t=>{t.hidden=false});\n if(location.protocol==='http:'&&(location.hostname==='127.0.0.1'||location.hostname==='localhost'))d.querySelectorAll('a.share-btn').forEach(a=>{a.hidden=false});\n d.querySelectorAll('time.when[datetime]').forEach(e=>{\n const t=new Date(e.getAttribute('datetime'));if(isNaN(t.getTime()))return;const p={};\n try{new Intl.DateTimeFormat('en-US',{month:'short',day:'numeric',year:'numeric',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(t).forEach(x=>{p[x.type]=x.value});\n e.textContent=p.month+' '+p.day+', '+p.year+' '+String.fromCharCode(183)+' '+p.hour+':'+p.minute;\n e.title=new Intl.DateTimeFormat('en-US',{dateStyle:'full',timeStyle:'long'}).format(t)}catch(x){}\n });\n d.addEventListener('click',e=>{const b=e.target.closest('[data-theme-set]');if(!b)return;setTheme(b.dataset.themeSet);try{localStorage.setItem(K,b.dataset.themeSet)}catch(x){}});\n d.querySelectorAll('.prompt').forEach(p=>{\n const t=p.querySelector('.prompt-text'),b=p.querySelector('.prompt-more');if(!t||!b)return;\n const fits=()=>{if(!p.classList.contains('open'))b.hidden=t.scrollHeight<=t.clientHeight+1};\n fits();if(window.ResizeObserver)new ResizeObserver(fits).observe(t);if(d.fonts&&d.fonts.ready)d.fonts.ready.then(fits);\n b.addEventListener('click',()=>{const o=p.classList.toggle('open');b.textContent=o?'Show less':'Show full prompt';b.setAttribute('aria-expanded',String(o));fits()});\n });\n};\nconst bare=u=>{const i=u.indexOf('://');return i<0?u:u.slice(i+3)};\nconst player=(p,o)=>{\n const v=d.getElementById(p+'-video'),fig=v.closest('.player'),note=d.getElementById(p+'-unloaded'),c=d.getElementById(p+'-controls'),url=d.getElementById(p+'-url');\n const srcs=new Map([...fig.querySelectorAll('[data-session-src]')].map(e=>[e.dataset.session,e.dataset.sessionSrc]));\n const order=[...srcs.keys()];\n const urls=[...fig.querySelectorAll('[data-url]')].map(e=>({s:e.dataset.s,t:Number(e.dataset.at),u:e.dataset.url}));\n const dead=new Set(),empty=d.getElementById(p+'-none');let cur=v.dataset.session,down=null,held=false,ask=0,auto=false,rate=1,raf=0,drag=false;\n const play=c.querySelector('.play'),now=c.querySelector('.now'),total=c.querySelector('.total'),bar=c.querySelector('.scrub'),head=c.querySelector('.head'),tracks=[...c.querySelectorAll('.track')];\n v.removeAttribute('controls');c.hidden=false;\n const big=d.getElementById(p+'-start');\n if(big){big.hidden=false;big.addEventListener('click',()=>v.play().catch(()=>{}));v.addEventListener('play',()=>big.remove(),{once:true})}\n const track=()=>tracks.find(t=>t.dataset.s===cur);\n const len=()=>{const t=track(),n=t?Number(t.dataset.total):0;return n>0?n:(isFinite(v.duration)?v.duration:0)};\n const paint=()=>{\n const L=len(),t=v.currentTime,f=L?Math.min(1,t/L):0,k=track();\n tracks.forEach(x=>{x.hidden=x!==k});head.style.left=(f*100)+'%';\n const done=k&&k.querySelector('.done');if(done)done.style.width=(f*100)+'%';\n now.textContent=clock(t);total.textContent=clock(L);\n bar.setAttribute('aria-valuemax',String(Math.round(L)));bar.setAttribute('aria-valuenow',String(Math.round(t)));bar.setAttribute('aria-valuetext',clock(t)+' of '+clock(L));\n play.classList.toggle('playing',!v.paused);play.setAttribute('aria-label',v.paused?'Play':'Pause');\n if(url){let u='';if(down!=='')for(const x of urls){if(x.s===cur&&x.t<=t+0.02)u=x.u}url.textContent=bare(u);url.parentElement.title=u}\n };\n const update=()=>{paint();if(o.tick)o.tick(v.currentTime)};\n const frame=()=>{update();raf=v.paused?0:requestAnimationFrame(frame)};\n const show=s=>{if(down===null)held=!v.paused;down=s;v.pause();fig.classList.add('broken');c.hidden=true;if(empty)empty.hidden=true;if(note){note.hidden=false;const a=note.querySelector('a');if(a){a.href=srcs.get(s);a.textContent=srcs.get(s)}}if(o.broken)o.broken()};\n const fine=()=>{if(down===null)return;down=null;fig.classList.remove('broken');c.hidden=false;if(note)note.hidden=true;if(empty)empty.hidden=true;if(o.fine)o.fine()};\n const none=()=>{if(down===null)held=!v.paused;++ask;auto=false;down='';v.pause();fig.classList.add('broken');c.hidden=true;if(note)note.hidden=true;if(empty)empty.hidden=false;paint();if(o.broken)o.broken()};\n const playing=()=>down===null?!v.paused:held;\n const next=s=>order.slice(order.indexOf(s)+1).find(n=>!dead.has(n));\n const load=(s,t,go,a)=>{\n const my=++ask;auto=!!a;if(dead.has(s))return show(s);\n if(s!==cur||!v.currentSrc||v.error){cur=s;v.dataset.session=s;v.src=srcs.get(s);v.load()}\n const done=()=>{if(my!==ask)return;auto=false;fine();v.playbackRate=rate;v.currentTime=t;update();if(go)v.play().catch(()=>{})};\n if(v.readyState>0)done();else v.addEventListener('loadedmetadata',done,{once:true});\n };\n const bad=()=>{if(!v.error)return;dead.add(cur);if(down==='')return;const n=auto?next(cur):undefined;if(n!==undefined)return load(n,0,true,true);auto=false;show(cur)};\n ['timeupdate','seeked','loadedmetadata','pause','play','durationchange'].forEach(n=>v.addEventListener(n,update));\n v.addEventListener('play',()=>{if(!raf)raf=requestAnimationFrame(frame)});\n addEventListener('resize',update);\n v.addEventListener('error',bad);if(v.error)queueMicrotask(bad);\n v.addEventListener('ended',()=>{if(o.ended&&o.ended())return;const n=next(cur);if(n!==undefined)load(n,0,true,true)});\n play.addEventListener('click',()=>{if(v.paused)v.play().catch(()=>{});else v.pause()});\n c.querySelectorAll('[data-rate]').forEach(b=>b.addEventListener('click',()=>{rate=Number(b.dataset.rate);v.playbackRate=rate;v.defaultPlaybackRate=rate;c.querySelectorAll('[data-rate]').forEach(x=>x.setAttribute('aria-pressed',String(x===b)))}));\n const seek=t=>{const L=len();t=Math.max(0,L?Math.min(L,t):t);v.currentTime=t;if(o.seek)o.seek(t);update()};\n const at=e=>{const b=bar.getBoundingClientRect();return Math.max(0,Math.min(1,(e.clientX-b.left)/b.width))*len()};\n bar.addEventListener('pointerdown',e=>{if(e.button>0||down!==null)return;drag=true;bar.setPointerCapture(e.pointerId);seek(at(e))});\n bar.addEventListener('pointermove',e=>{if(drag)seek(at(e))});\n ['pointerup','pointercancel'].forEach(n=>bar.addEventListener(n,()=>{drag=false}));\n bar.addEventListener('keydown',e=>{\n const k=e.key,t=v.currentTime,by={ArrowLeft:-1,ArrowDown:-1,ArrowRight:1,ArrowUp:1,PageDown:-10,PageUp:10}[k];\n const to=by!==undefined?t+by:k==='Home'?0:k==='End'?len():null;if(to===null)return;e.preventDefault();seek(to);\n });\n const full=c.querySelector('.full'),screen=o.full||fig.querySelector('.screen');\n if(!d.fullscreenEnabled||!screen.requestFullscreen)full.hidden=true;\n else{full.addEventListener('click',()=>{if(d.fullscreenElement)d.exitFullscreen().catch(()=>{});else screen.requestFullscreen().catch(()=>{})});\n d.addEventListener('fullscreenchange',()=>{const f=d.fullscreenElement===screen;full.classList.toggle('out',f);full.setAttribute('aria-label',f?'Exit fullscreen':'Fullscreen');update()})}\n d.addEventListener('keydown',e=>{if(e.key!==' '||down!==null||e.defaultPrevented||d.querySelector('dialog[open]')||e.target.closest('button,a,input,textarea,select,summary,[role=slider]'))return;e.preventDefault();play.click()});\n return {v,load,none,playing,update,len,cur:()=>cur,down:()=>down,has:s=>srcs.has(s)};\n};\n\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,broken:()=>{hide();fx(0,null);w.classList.remove('live')},fine:()=>{w.classList.add('live')}});\n if(T&&acts.length){T.checked=fon;T.closest('label').hidden=false;T.addEventListener('change',()=>{fon=T.checked;try{localStorage.setItem(ck,fon?'on':'off')}catch(e){}P.update()})}\n if(skipB)skipB.addEventListener('click',()=>{skip=!skip;skipB.setAttribute('aria-pressed',String(skip))});\n if(expB)expB.addEventListener('click',()=>{const x=w.classList.toggle('expanded');expB.setAttribute('aria-expanded',String(x));expB.querySelector('span').textContent=x?'Collapse':'Expand';P.update();if(on)anchor(on)});\n d.addEventListener('click',e=>{\n const t=e.target;if(!(t instanceof Element))return;\n const a=t.closest('a[data-t][data-s],.wt-step[data-t][data-s]');if(!a||!P.has(a.dataset.s))return;\n e.preventDefault();const fig=v.closest('.player');\n if(fig.getBoundingClientRect().bottom<topEdge())fig.scrollIntoView({block:'start',behavior:still()?'auto':'smooth'});\n P.load(a.dataset.s,Number(a.dataset.t),P.playing());\n });\n P.update();\n});\n})();";
|
|
43
|
+
export declare const WALKTHROUGH_SCRIPT = "(()=>{const d=document,r=d.documentElement,K='screw-bugs-theme';\nconst still=()=>matchMedia('(prefers-reduced-motion: reduce)').matches;\nconst topEdge=()=>{const b=d.querySelector('.menubar');return b?Math.max(0,b.getBoundingClientRect().bottom):0};\nconst pad=n=>String(n).padStart(2,'0');\nconst clock=s=>{s=Math.max(0,Math.floor(s||0));const h=Math.floor(s/3600),m=Math.floor(s%3600/60);return(h?h+':'+pad(m):String(m))+':'+pad(s%60)};\nlet theme='system';try{theme=localStorage.getItem(K)||theme}catch(e){}r.dataset.theme=theme;\nconst themeCycle=(b,key)=>{\n const r=document.documentElement,T=['light','dark','system'],N={light:'Light theme',dark:'Dark theme',system:'Theme from system'};\n const at=()=>{const i=T.indexOf(r.dataset.theme);return i<0?2:i};\n const show=()=>{const i=at();b.setAttribute('aria-label',N[T[i]]+'. Switch to '+N[T[(i+1)%3]].toLowerCase());b.title=N[T[i]]};\n show();\n b.addEventListener('click',()=>{const m=T[(at()+1)%3];r.dataset.theme=m;if(key)try{localStorage.setItem(key,m)}catch(e){}show()});\n};\nconst chrome=()=>{\n d.querySelectorAll('.menubar .theme').forEach(b=>{themeCycle(b,K);b.hidden=false});\n if(location.protocol==='http:'&&(location.hostname==='127.0.0.1'||location.hostname==='localhost'))d.querySelectorAll('a.share-btn').forEach(a=>{a.hidden=false});\n d.querySelectorAll('time.when[datetime]').forEach(e=>{\n const t=new Date(e.getAttribute('datetime'));if(isNaN(t.getTime()))return;const p={};\n try{new Intl.DateTimeFormat('en-US',{month:'short',day:'numeric',year:'numeric',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(t).forEach(x=>{p[x.type]=x.value});\n const y=d.createElement('span');y.className='year';y.textContent=', '+p.year;\n e.replaceChildren(p.month+' '+p.day,y,' '+String.fromCharCode(183)+' '+p.hour+':'+p.minute);\n e.title=new Intl.DateTimeFormat('en-US',{dateStyle:'full',timeStyle:'long'}).format(t)}catch(x){}\n });\n d.querySelectorAll('.prompt').forEach(p=>{\n const t=p.querySelector('.prompt-text'),b=p.querySelector('.prompt-more');if(!t||!b)return;\n const fits=()=>{if(!p.classList.contains('open'))b.hidden=t.scrollHeight<=t.clientHeight+1};\n fits();if(window.ResizeObserver)new ResizeObserver(fits).observe(t);if(d.fonts&&d.fonts.ready)d.fonts.ready.then(fits);\n b.addEventListener('click',()=>{const o=p.classList.toggle('open');b.textContent=o?'Show less':'Show full prompt';b.setAttribute('aria-expanded',String(o));fits()});\n });\n};\nconst bare=u=>{const i=u.indexOf('://');return i<0?u:u.slice(i+3)};\nconst player=(p,o)=>{\n const v=d.getElementById(p+'-video'),fig=v.closest('.player'),note=d.getElementById(p+'-unloaded'),c=d.getElementById(p+'-controls'),url=d.getElementById(p+'-url');\n const srcs=new Map([...fig.querySelectorAll('[data-session-src]')].map(e=>[e.dataset.session,e.dataset.sessionSrc]));\n const order=[...srcs.keys()];\n const urls=[...fig.querySelectorAll('[data-url]')].map(e=>({s:e.dataset.s,t:Number(e.dataset.at),u:e.dataset.url}));\n const dead=new Set(),empty=d.getElementById(p+'-none');let cur=v.dataset.session,down=null,held=false,ask=0,auto=false,rate=1,raf=0,drag=false;\n const play=c.querySelector('.play'),now=c.querySelector('.now'),total=c.querySelector('.total'),bar=c.querySelector('.scrub'),head=c.querySelector('.head'),tracks=[...c.querySelectorAll('.track')];\n v.removeAttribute('controls');c.hidden=false;\n const big=d.getElementById(p+'-start');\n if(big){big.hidden=false;big.addEventListener('click',()=>{grow();v.play().catch(()=>{})});v.addEventListener('play',()=>big.remove(),{once:true})}\n const track=()=>tracks.find(t=>t.dataset.s===cur);\n const len=()=>{const t=track(),n=t?Number(t.dataset.total):0;return n>0?n:(isFinite(v.duration)?v.duration:0)};\n const paint=()=>{\n const L=len(),t=v.currentTime,f=L?Math.min(1,t/L):0,k=track();\n tracks.forEach(x=>{x.hidden=x!==k});head.style.left=(f*100)+'%';\n const done=k&&k.querySelector('.done');if(done)done.style.width=(f*100)+'%';\n now.textContent=clock(t);total.textContent=clock(L);\n bar.setAttribute('aria-valuemax',String(Math.round(L)));bar.setAttribute('aria-valuenow',String(Math.round(t)));bar.setAttribute('aria-valuetext',clock(t)+' of '+clock(L));\n play.classList.toggle('playing',!v.paused);play.setAttribute('aria-label',v.paused?'Play':'Pause');\n if(url){let u='';if(down!=='')for(const x of urls){if(x.s===cur&&x.t<=t+0.02)u=x.u}url.textContent=bare(u);url.parentElement.title=u}\n };\n const update=()=>{paint();if(o.tick)o.tick(v.currentTime)};\n const frame=()=>{update();raf=v.paused?0:requestAnimationFrame(frame)};\n const show=s=>{if(down===null)held=!v.paused;down=s;v.pause();fig.classList.add('broken');c.hidden=true;if(empty)empty.hidden=true;if(note){note.hidden=false;const a=note.querySelector('a');if(a){a.href=srcs.get(s);a.textContent=srcs.get(s)}}if(o.broken)o.broken()};\n const fine=()=>{if(down===null)return;down=null;fig.classList.remove('broken');c.hidden=false;if(note)note.hidden=true;if(empty)empty.hidden=true;if(o.fine)o.fine()};\n const none=()=>{if(down===null)held=!v.paused;++ask;auto=false;down='';v.pause();fig.classList.add('broken');c.hidden=true;if(note)note.hidden=true;if(empty)empty.hidden=false;paint();if(o.broken)o.broken()};\n const playing=()=>down===null?!v.paused:held;\n const next=s=>order.slice(order.indexOf(s)+1).find(n=>!dead.has(n));\n const load=(s,t,go,a)=>{\n const my=++ask;auto=!!a;if(dead.has(s))return show(s);\n if(s!==cur||!v.currentSrc||v.error){cur=s;v.dataset.session=s;v.src=srcs.get(s);v.load()}\n const done=()=>{if(my!==ask)return;auto=false;fine();v.playbackRate=rate;v.currentTime=t;update();if(go)v.play().catch(()=>{})};\n if(v.readyState>0)done();else v.addEventListener('loadedmetadata',done,{once:true});\n };\n const bad=()=>{if(!v.error)return;dead.add(cur);if(down==='')return;const n=auto?next(cur):undefined;if(n!==undefined)return load(n,0,true,true);auto=false;show(cur)};\n ['timeupdate','seeked','loadedmetadata','pause','play','durationchange'].forEach(n=>v.addEventListener(n,update));\n v.addEventListener('play',()=>{if(!raf)raf=requestAnimationFrame(frame)});\n addEventListener('resize',update);\n v.addEventListener('error',bad);if(v.error)queueMicrotask(bad);\n v.addEventListener('ended',()=>{if(o.ended&&o.ended())return;const n=next(cur);if(n!==undefined)load(n,0,true,true)});\n play.addEventListener('click',()=>{if(v.paused)v.play().catch(()=>{});else v.pause()});\n v.addEventListener('click',()=>{if(down!==null)return;if(grow())v.play().catch(()=>{});else play.click()});\n c.querySelectorAll('[data-rate]').forEach(b=>b.addEventListener('click',()=>{rate=Number(b.dataset.rate);v.playbackRate=rate;v.defaultPlaybackRate=rate;c.querySelectorAll('[data-rate]').forEach(x=>x.setAttribute('aria-pressed',String(x===b)))}));\n const seek=t=>{const L=len();t=Math.max(0,L?Math.min(L,t):t);v.currentTime=t;if(o.seek)o.seek(t);update()};\n const at=e=>{const b=bar.getBoundingClientRect();return Math.max(0,Math.min(1,(e.clientX-b.left)/b.width))*len()};\n bar.addEventListener('pointerdown',e=>{if(e.button>0||down!==null)return;drag=true;bar.setPointerCapture(e.pointerId);seek(at(e))});\n bar.addEventListener('pointermove',e=>{if(drag)seek(at(e))});\n ['pointerup','pointercancel'].forEach(n=>bar.addEventListener(n,()=>{drag=false}));\n bar.addEventListener('keydown',e=>{\n const k=e.key,t=v.currentTime,by={ArrowLeft:-1,ArrowDown:-1,ArrowRight:1,ArrowUp:1,PageDown:-10,PageUp:10}[k];\n const to=by!==undefined?t+by:k==='Home'?0:k==='End'?len():null;if(to===null)return;e.preventDefault();seek(to);\n });\n const full=c.querySelector('.full'),screen=o.full||fig.querySelector('.screen');\n const api=!!(d.fullscreenEnabled&&screen.requestFullscreen),inPage=()=>!!o.inPage&&(o.inPage()||!api);\n const mark=()=>{const f=d.fullscreenElement===screen||screen.classList.contains('focus');full.classList.toggle('out',f);full.setAttribute('aria-label',f?'Exit fullscreen':'Fullscreen');update()};\n let back=0;const focus=on=>{if(on)back=scrollY;screen.classList.toggle('focus',on);scrollTo({top:on?0:back,behavior:'auto'});mark()};\n const grow=()=>{if(!o.expand||!o.inPage||!o.inPage()||d.fullscreenElement||screen.classList.contains('focus'))return false;focus(true);return true};\n if(!api&&!o.inPage)full.hidden=true;\n else{full.addEventListener('click',()=>{const f=screen.classList.contains('focus');if(d.fullscreenElement){d.exitFullscreen().catch(()=>{});if(f)focus(false)}else if(f)focus(false);else if(inPage())focus(true);else screen.requestFullscreen().catch(()=>{})});\n d.addEventListener('fullscreenchange',mark);\n d.addEventListener('keydown',e=>{if(e.key==='Escape'&&!e.defaultPrevented&&screen.classList.contains('focus')&&!d.querySelector('dialog[open]')){e.preventDefault();focus(false)}})}\n d.addEventListener('keydown',e=>{if(e.key!==' '||down!==null||e.defaultPrevented||d.querySelector('dialog[open]')||e.target.closest('button,a,input,textarea,select,summary,[role=slider]'))return;e.preventDefault();play.click()});\n return {v,load,none,playing,update,len,cur:()=>cur,down:()=>down,has:s=>srcs.has(s)};\n};\n\nd.addEventListener('DOMContentLoaded',()=>{\n chrome();\n const stg=d.querySelector('.wt-stage');let fr=0;\n const fit=()=>{fr=0;if(!stg)return;const t=stg.getBoundingClientRect().top;stg.style.setProperty('--wt-top',Math.round(t)+'px');stg.style.setProperty('--wt-y',Math.round(t+scrollY)+'px')};\n const refit=()=>{if(!fr)fr=requestAnimationFrame(fit)};\n fit();addEventListener('resize',refit);addEventListener('load',refit);addEventListener('scroll',refit,{passive:true});d.addEventListener('fullscreenchange',refit);\n if(window.ResizeObserver)new ResizeObserver(refit).observe(d.body);\n const v=d.getElementById('wt-video');if(!v)return;\n const w=d.querySelector('.wt'),panel=d.getElementById('wt-script'),box=d.getElementById('wt-box'),cap=d.getElementById('wt-cap');\n const say=a=>{const x=a&&a.querySelector('.wt-text');cap.replaceChildren(...(x?[...x.childNodes].filter(n=>!(n instanceof Element&&n.classList.contains('wt-state'))).map(n=>n.cloneNode(true)):[]));cap.hidden=!x};\n const steps=[...d.querySelectorAll('.wt-step[data-t]')];\n const idle=[...d.querySelectorAll('.idle[data-a]')].map(e=>({s:e.closest('.track').dataset.s,a:Number(e.dataset.a),b:Number(e.dataset.b)}));\n const skipB=d.getElementById('wt-skip'),expB=d.getElementById('wt-expand');\n let on=null,skip=!!skipB&&skipB.getAttribute('aria-pressed')==='true',P=null;\n w.classList.add('live');\n const hide=()=>{box.hidden=true};\n const geo=()=>{const vw=v.videoWidth,vh=v.videoHeight,cw=v.clientWidth,ch=v.clientHeight;if(!vw||!vh||!cw||!ch)return null;const s=Math.min(cw/vw,ch/vh);return{x:v.offsetLeft+(cw-vw*s)/2,y:v.offsetTop+(ch-vh*s)/2,w:vw*s,h:vh*s}};\n const put=(e,x,y,bw,bh)=>{e.style.left=x+'px';e.style.top=y+'px';if(bw!==undefined){e.style.width=bw+'px';e.style.height=bh+'px'}};\n const draw=(t,g)=>{if(P.down()!==null||!g||!on||!on.dataset.box||t<Number(on.dataset.b0)||t>Number(on.dataset.b1))return hide();const b=on.dataset.box.split(' ').map(Number);put(box,g.x+b[0]*g.w,g.y+b[1]*g.h,b[2]*g.w,b[3]*g.h);box.querySelector('span').textContent=on.dataset.label||'';box.hidden=false};\n const C=d.getElementById('wt-cursor'),R=d.getElementById('wt-ripple'),G=d.getElementById('wt-ring'),L=d.getElementById('wt-act'),T=d.getElementById('wt-cursor-on'),ck='screw-bugs-cursor';\n const nums=x=>x?x.split(' ').map(Number):null;\n const acts=[...d.querySelectorAll('.wt-step[data-act][data-s]')].map(e=>({s:e.dataset.s,at:e.dataset.at?Number(e.dataset.at):NaN,t0:Number(e.dataset.t),t1:Number(e.dataset.a1),b0:Number(e.dataset.b0),b1:Number(e.dataset.b1),k:e.dataset.act,p:nums(e.dataset.pt),b:nums(e.dataset.tb),l:e.dataset.al||''})).sort((a,b)=>(a.at>=0?a.at:a.t0)-(b.at>=0?b.at:b.t0));\n let fon=true;try{fon=localStorage.getItem(ck)!=='off'}catch(e){}\n const fx=(t,g)=>{\n C.hidden=R.hidden=G.hidden=L.hidden=true;box.querySelector('span').hidden=false;\n if(!fon||P.down()!==null||!g)return;\n const m=still(),mine=acts.filter(a=>a.s===P.cur()),ptr=mine.filter(a=>a.p),xy=p=>[g.x+p[0]*g.w,g.y+p[1]*g.h];\n let i=-1;ptr.forEach((a,j)=>{if(a.at<=t)i=j});\n const a=ptr[i],n=ptr[i+1];let c=a?a.p:null;\n if(n&&a){const gw=Math.min(0.6,n.at-a.at),q=gw>0?(t-n.at+gw)/gw:1;if(q>=0){const e=q<.5?4*q*q*q:1-Math.pow(2-2*q,3)/2;c=!m&&q<1?[a.p[0]+(n.p[0]-a.p[0])*e,a.p[1]+(n.p[1]-a.p[1])*e]:n.p}}\n if(c){const xy0=xy(c);put(C,xy0[0]-3,xy0[1]-2);C.hidden=false}\n if(a&&!m&&t-a.at<.6){const q=(t-a.at)/.6,xy1=xy(a.p);put(R,xy1[0],xy1[1]);R.style.transform='translate(-50%,-50%) scale('+(.35+q*1.3)+')';R.style.opacity=String(1-q);R.hidden=false}\n let f=null,l=null,u=null;\n for(const x of mine){if(x.k==='fill'&&x.b&&t>=x.b0&&t<=x.b1)f=x;if(x.k==='fill'||!(x.at>=0)?t>=x.t0&&t<=x.t1:t>=x.at&&t<=x.at+1.5)l=x;else if(!u&&x.p&&x.at>t&&x.at-t<=0.6)u=x}\n l=l||u;\n if(f){const xy2=xy(f.b);put(G,xy2[0],xy2[1],f.b[2]*g.w,f.b[3]*g.h);G.hidden=false;box.hidden=true}\n if(l&&l.l){L.textContent=l.l;L.hidden=false;let x=g.x+10,y=g.y+10;if(l.p){const q=xy(l.p);x=q[0]+14;y=q[1]+20}else if(l.b){const q=xy(l.b);x=q[0];y=q[1]+l.b[3]*g.h+10}if(y+L.offsetHeight>g.y+g.h-4)y=l.b?g.y+l.b[1]*g.h-L.offsetHeight-10:g.y+g.h-L.offsetHeight-4;put(L,Math.max(g.x+4,Math.min(x,g.x+g.w-L.offsetWidth-4)),Math.max(g.y+4,y))}\n box.querySelector('span').hidden=!L.hidden;\n };\n const stage=d.querySelector('.wt-stage');\n const cover=()=>{let y=topEdge();if(stage&&getComputedStyle(stage).position==='sticky')y=Math.max(y,stage.getBoundingClientRect().bottom+16);return y};\n const anchor=a=>{const hid=Math.max(0,cover()-panel.getBoundingClientRect().top);panel.scrollTo({top:Math.max(0,a.offsetTop-6-hid),behavior:still()?'auto':'smooth'})};\n const tick=t=>{\n const cur=P.cur();\n if(skip&&!v.paused&&!v.seeking){const gap=idle.find(x=>x.s===cur&&t>=x.a&&t<x.b-0.05);if(gap){v.currentTime=gap.b;return}}\n let a=null;for(const s of steps){if(s.dataset.s===cur&&Number(s.dataset.t)<=t+0.02)a=s}\n if(a!==on){if(on){on.classList.remove('on');on.removeAttribute('aria-current');on.closest('.wt-case').classList.remove('on')}on=a;say(a);if(a){a.classList.add('on');a.setAttribute('aria-current','step');a.closest('.wt-case').classList.add('on');anchor(a)}}\n const g=geo();draw(t,g);fx(t,g);\n };\n P=player('wt',{tick,full:w,expand:true,inPage:()=>matchMedia('(min-width: 901px)').matches,broken:()=>{hide();fx(0,null);w.classList.remove('live')},fine:()=>{w.classList.add('live')}});\n if(T&&acts.length){T.checked=fon;T.closest('label').hidden=false;T.addEventListener('change',()=>{fon=T.checked;try{localStorage.setItem(ck,fon?'on':'off')}catch(e){}P.update()})}\n if(skipB)skipB.addEventListener('click',()=>{skip=!skip;skipB.setAttribute('aria-pressed',String(skip))});\n if(expB)expB.addEventListener('click',()=>{const x=w.classList.toggle('expanded');expB.setAttribute('aria-expanded',String(x));expB.querySelector('span').textContent=x?'Collapse':'Expand';P.update();if(on)anchor(on)});\n d.addEventListener('click',e=>{\n const t=e.target;if(!(t instanceof Element))return;\n const a=t.closest('a[data-t][data-s],.wt-step[data-t][data-s]');if(!a||!P.has(a.dataset.s))return;\n e.preventDefault();const fig=v.closest('.player');\n if(fig.getBoundingClientRect().bottom<topEdge())fig.scrollIntoView({block:'start',behavior:still()?'auto':'smooth'});\n P.load(a.dataset.s,Number(a.dataset.t),P.playing());\n });\n P.update();\n});\n})();";
|
|
43
44
|
/**
|
|
44
45
|
* As the report's: the video by relative path, one script by hash, and from the network only
|
|
45
46
|
* Google Fonts' stylesheet and its fonts.
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { clampBox } from '../core/index.js';
|
|
2
2
|
import { runFiles, } from '../schema/index.js';
|
|
3
|
-
import { favicon, generatorMeta, html, icon, Markup, promptBlock, safeRelative, statusIcon, statusTag, textParts,
|
|
3
|
+
import { favicon, generatorMeta, html, icon, Markup, promptBlock, safeRelative, statusIcon, statusTag, textParts, webFonts, } from './markup.js';
|
|
4
4
|
import { controlsBlock, PLAYER_JS, playableSessions, playerWindow, shapeStyle, share, toggleButton, } from './player.js';
|
|
5
5
|
import { assetsOf, contentPolicy } from './assets.js';
|
|
6
|
+
import { topBar } from './menu-bar.js';
|
|
6
7
|
import { cspHash } from './sha256.js';
|
|
7
8
|
import { styles } from './styles.js';
|
|
8
9
|
import { caseViews, formatTimecode, fragmentSeconds, idleStretches, stepParts, stepText, statusLabel, urlAt, urlTimeline, } from './view.js';
|
|
@@ -34,7 +35,8 @@ export const GLIDE_S = 0.6;
|
|
|
34
35
|
* measured, makes timecodes and rows seek (and switch session videos) instead of opening the file,
|
|
35
36
|
* and, with "Skip inactive" on, jumps over the stretches where no step ran while it plays.
|
|
36
37
|
* "Expand" shows the whole script and makes the video smaller. Fullscreen takes the whole page
|
|
37
|
-
* (`.wt`), not only the video
|
|
38
|
+
* (`.wt`), not only the video; on a wide screen (a desktop) it never takes the browser's screen,
|
|
39
|
+
* only lays the page out again (`.focus`, see `PLAYER_JS`): the top bar, the video as big as fits with its address over it and
|
|
38
40
|
* the step playing now as a caption under it, and the controls; the prompt and the script are left
|
|
39
41
|
* out. A session video that does not load
|
|
40
42
|
* is remembered as broken on its own (see `PLAYER_JS`). Without script, timecodes open the video
|
|
@@ -102,7 +104,7 @@ d.addEventListener('DOMContentLoaded',()=>{
|
|
|
102
104
|
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)}}
|
|
103
105
|
const g=geo();draw(t,g);fx(t,g);
|
|
104
106
|
};
|
|
105
|
-
P=player('wt',{tick,full:w,broken:()=>{hide();fx(0,null);w.classList.remove('live')},fine:()=>{w.classList.add('live')}});
|
|
107
|
+
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')}});
|
|
106
108
|
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()})}
|
|
107
109
|
if(skipB)skipB.addEventListener('click',()=>{skip=!skip;skipB.setAttribute('aria-pressed',String(skip))});
|
|
108
110
|
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)});
|
|
@@ -142,8 +144,8 @@ const walkthroughStyles = /* css */ `
|
|
|
142
144
|
.wt-stage .window { width: min(var(--win-cap), calc((100cqh - var(--win-h)) * var(--arw, 1.6) + var(--win-w))); margin: 0 auto; }
|
|
143
145
|
.wt-stage .controls { width: min(810px, 100%); }
|
|
144
146
|
.device-mobile .wt-stage { --win-cap: min(360px, 100cqw); width: min(540px, 100%); }
|
|
145
|
-
.wt.expanded:not(:fullscreen) .wt-stage { --win-cap: min(640px, 100cqw, calc((50vh - 160px) * var(--arw, 1.6))); }
|
|
146
|
-
.device-mobile.wt.expanded:not(:fullscreen) .wt-stage { --win-cap: min(260px, 100cqw, calc((60vh - 200px) * var(--arw, .46) + var(--win-w))); }
|
|
147
|
+
.wt.expanded:not(:fullscreen, .focus) .wt-stage { --win-cap: min(640px, 100cqw, calc((50vh - 160px) * var(--arw, 1.6))); }
|
|
148
|
+
.device-mobile.wt.expanded:not(:fullscreen, .focus) .wt-stage { --win-cap: min(260px, 100cqw, calc((60vh - 200px) * var(--arw, .46) + var(--win-w))); }
|
|
147
149
|
.wt-notes { margin: 12px 0 0; padding: 0; list-style: none; font: var(--t-control); color: var(--muted); text-align: center; }
|
|
148
150
|
.wt-notes li { margin: 4px 0; overflow-wrap: anywhere; }
|
|
149
151
|
.wt-panel { width: min(708px, 100%); border: 1px solid var(--border); border-radius: 12px; background: var(--panel); padding: 12px 16px 0; }
|
|
@@ -199,7 +201,6 @@ a.wt-pill:hover { background: var(--accent); color: var(--on-accent); }
|
|
|
199
201
|
.wt-problems .wt-pill { min-width: 64px; padding: 4px 8px; }
|
|
200
202
|
.wt-problems .why { overflow-wrap: anywhere; color: var(--muted); }
|
|
201
203
|
.wt-problems .why a { color: var(--text); }
|
|
202
|
-
.wt .foot { width: min(708px, 100%); margin: 28px auto 0; padding: 0 16px; font: var(--t-small); color: var(--muted); }
|
|
203
204
|
|
|
204
205
|
/* What is drawn over the video: the step's box, the cursor, ripples, typing rings, labels. */
|
|
205
206
|
.wt-box { position: absolute; outline: 3px solid var(--mark-step); outline-offset: 3px; border-radius: 2px; box-shadow: 0 0 0 3px rgba(255, 255, 255, .85); pointer-events: none; }
|
|
@@ -234,30 +235,32 @@ a.wt-pill:hover { background: var(--accent); color: var(--on-accent); }
|
|
|
234
235
|
|
|
235
236
|
/* Fullscreen is the whole page: the top bar, the video in a dark card as big as fits, its address
|
|
236
237
|
over it and the step playing now as a caption across its foot, then the controls. The prompt,
|
|
237
|
-
the script and the notes stay out; the caption takes the place of the label by the cursor.
|
|
238
|
+
the script and the notes stay out; the caption takes the place of the label by the cursor. On a
|
|
239
|
+
wide screen it is \`.focus\`: the same layout in the browser's window, never its whole screen. */
|
|
238
240
|
.wt-cap { display: none; }
|
|
239
|
-
.wt:fullscreen { overflow: auto;
|
|
240
|
-
.wt:
|
|
241
|
-
.wt:fullscreen .wt-
|
|
242
|
-
.wt:fullscreen .wt-
|
|
243
|
-
.wt:fullscreen .wt-stage
|
|
244
|
-
.wt:fullscreen .wt-stage
|
|
245
|
-
.wt:fullscreen .
|
|
246
|
-
.wt:fullscreen .
|
|
247
|
-
.wt:fullscreen .
|
|
248
|
-
.wt:fullscreen .
|
|
249
|
-
.wt:fullscreen .
|
|
250
|
-
.wt:fullscreen .url:
|
|
251
|
-
.wt:
|
|
252
|
-
.wt:fullscreen .wt-cap
|
|
241
|
+
.wt:fullscreen { overflow: auto; }
|
|
242
|
+
.wt:is(:fullscreen, .focus) { padding-bottom: 0; background: var(--bg); }
|
|
243
|
+
.wt:is(:fullscreen, .focus) > .prompt, .wt:is(:fullscreen, .focus) :is(.alert, .wt-panel, .wt-problems, .wt-notes, .wt-act) { display: none !important; }
|
|
244
|
+
.wt:is(:fullscreen, .focus) .wt-main { display: block; padding: 0 24px; }
|
|
245
|
+
.wt:is(:fullscreen, .focus) .wt-stage { --fit-top: var(--wt-top, var(--bar)); --fit-gap: 20px; --win-cap: 100cqw; --win-h: 60px; --win-w: 2px; --player-pad: 0px; --player-cap: none; position: static; width: 100%; padding: 0; background: none; }
|
|
246
|
+
.wt:is(:fullscreen, .focus) .wt-stage::after { display: none; }
|
|
247
|
+
.wt:is(:fullscreen, .focus) .wt-stage .player { padding: 0; background: none; }
|
|
248
|
+
.wt:is(:fullscreen, .focus) .window { padding: 0 0 58px; border-radius: 12px; border-color: var(--video-edge); background: var(--video); box-shadow: none; }
|
|
249
|
+
.wt:is(:fullscreen, .focus) .screen { border-radius: 0; }
|
|
250
|
+
.wt:is(:fullscreen, .focus) .toolbar { position: absolute; top: 10px; left: 0; right: 0; z-index: 7; height: auto; margin: 0; padding: 0 12px; justify-content: center; border: 0; background: none; pointer-events: none; }
|
|
251
|
+
.wt:is(:fullscreen, .focus) .dots { display: none; }
|
|
252
|
+
.wt:is(:fullscreen, .focus) .url { position: static; transform: none; width: auto; max-width: min(420px, 70%); height: 24px; padding: 0 14px; border-radius: 999px; background: var(--subtle); }
|
|
253
|
+
.wt:is(:fullscreen, .focus) .url:has(span:empty) { visibility: hidden; }
|
|
254
|
+
.wt:is(:fullscreen, .focus) .wt-cap:not([hidden]) { display: block; position: absolute; left: 50%; bottom: 22px; z-index: 7; transform: translateX(-50%); max-width: min(720px, calc(100% - 32px)); margin: 0; padding: 12px 40px; border: 1px solid var(--caption-border); border-radius: 8px; background: var(--caption); color: var(--text); font: 400 18px/26px var(--sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
|
|
255
|
+
.wt:is(:fullscreen, .focus) .wt-cap code { font-size: .85em; }
|
|
253
256
|
.wt-ico { display: none; }
|
|
254
|
-
.wt:fullscreen .wt-cap .wt-ico { display: inline-block; margin-right: 10px; vertical-align: -4px; color: var(--muted); }
|
|
255
|
-
.wt:fullscreen .wt-cap .wt-ico svg { display: block; }
|
|
256
|
-
.wt:fullscreen .player.broken .wt-cap { display: none; }
|
|
257
|
-
.wt:fullscreen .wt-stage .controls { width: min(810px, 100%); }
|
|
257
|
+
.wt:is(:fullscreen, .focus) .wt-cap .wt-ico { display: inline-block; margin-right: 10px; vertical-align: -4px; color: var(--muted); }
|
|
258
|
+
.wt:is(:fullscreen, .focus) .wt-cap .wt-ico svg { display: block; }
|
|
259
|
+
.wt:is(:fullscreen, .focus) .player.broken .wt-cap { display: none; }
|
|
260
|
+
.wt:is(:fullscreen, .focus) .wt-stage .controls { width: min(810px, 100%); }
|
|
258
261
|
@media (max-width: 900px) {
|
|
259
|
-
.wt:fullscreen .wt-main { padding: 0 12px; }
|
|
260
|
-
.wt:fullscreen .wt-cap:not([hidden]) { bottom: 14px; padding: 8px 16px; font: var(--t-body); }
|
|
262
|
+
.wt:is(:fullscreen, .focus) .wt-main { padding: 0 12px; }
|
|
263
|
+
.wt:is(:fullscreen, .focus) .wt-cap:not([hidden]) { bottom: 14px; padding: 8px 16px; font: var(--t-body); }
|
|
261
264
|
}
|
|
262
265
|
|
|
263
266
|
/* A run on a phone, on a wide screen: the phone and its controls on the left, the script beside. */
|
|
@@ -277,8 +280,8 @@ a.wt-pill:hover { background: var(--accent); color: var(--on-accent); }
|
|
|
277
280
|
.device-mobile .wt-stage { --win-cap: min(224px, 100cqw); --player-pad: 20px; --player-cap: calc(44vh - 60px + var(--win-h) + var(--player-pad)); }
|
|
278
281
|
.device-mobile .wt-stage .player { padding: 10px 0; border-radius: 14px; background: var(--subtle); }
|
|
279
282
|
.device-mobile .wt-stage .window { box-shadow: var(--shadow); }
|
|
280
|
-
.wt.expanded:not(:fullscreen) .wt-stage { --win-cap: 100cqw; --player-cap: calc(96px + var(--win-h)); }
|
|
281
|
-
.device-mobile.wt.expanded:not(:fullscreen) .wt-stage { --win-cap: 120px; --player-cap: none; }
|
|
283
|
+
.wt.expanded:not(:fullscreen, .focus) .wt-stage { --win-cap: 100cqw; --player-cap: calc(96px + var(--win-h)); }
|
|
284
|
+
.device-mobile.wt.expanded:not(:fullscreen, .focus) .wt-stage { --win-cap: 120px; --player-cap: none; }
|
|
282
285
|
.wt-stage .controls { gap: 8px; margin-top: 10px; }
|
|
283
286
|
.wt-panel { padding: 10px 8px 0; }
|
|
284
287
|
.wt-step { grid-template-columns: 64px minmax(0, 1fr); gap: 10px; min-height: 46px; padding: 6px 8px; font: var(--t-body); }
|
|
@@ -480,10 +483,23 @@ const stepRow = (view, step, sessions) => {
|
|
|
480
483
|
${decided && entry.reason ? why(entry) : ''}
|
|
481
484
|
</li>`;
|
|
482
485
|
};
|
|
486
|
+
/** Steps that only check the page, left out of the walkthrough's script, even one that decided its case. */
|
|
487
|
+
const checks = new Set([
|
|
488
|
+
'expectText',
|
|
489
|
+
'expectNoText',
|
|
490
|
+
'expectUrl',
|
|
491
|
+
'expectLink',
|
|
492
|
+
]);
|
|
493
|
+
/**
|
|
494
|
+
* The steps the walkthrough lists: what the run did. A case a check decided says why under its
|
|
495
|
+
* title instead, and in the cases that did not pass.
|
|
496
|
+
*/
|
|
497
|
+
const scriptSteps = (view) => view.steps.filter((s) => !checks.has(s.step.action));
|
|
483
498
|
const caseBlock = (view, position, sessions) => {
|
|
484
499
|
const { entry } = view;
|
|
485
500
|
const session = sessionOf(entry);
|
|
486
|
-
const
|
|
501
|
+
const steps = scriptSteps(view);
|
|
502
|
+
const decidedShown = steps.some((s) => s.state === 'decided');
|
|
487
503
|
const timedButNoVideo = view.steps.some((s) => s.timing !== undefined) && !sessions.has(session)
|
|
488
504
|
? html `<p class="wt-case-note">
|
|
489
505
|
Session ${session} has no video, so these times cannot be played.
|
|
@@ -499,9 +515,9 @@ const caseBlock = (view, position, sessions) => {
|
|
|
499
515
|
>
|
|
500
516
|
</div>
|
|
501
517
|
${timedButNoVideo}${entry.reason && !decidedShown ? why(entry, ' wt-case-why') : ''}
|
|
502
|
-
${
|
|
518
|
+
${steps.length > 0
|
|
503
519
|
? html `<ol class="wt-steps">
|
|
504
|
-
${
|
|
520
|
+
${steps.map((step) => stepRow(view, step, sessions))}
|
|
505
521
|
</ol>`
|
|
506
522
|
: html `<p class="wt-case-note">No steps recorded for this case.</p>`}
|
|
507
523
|
</li>`;
|
|
@@ -553,7 +569,7 @@ export const renderWalkthrough = (bundle, options) => {
|
|
|
553
569
|
// A page, not a file to load: relative even with an asset base URL (see `assets.ts`).
|
|
554
570
|
const report = safeRelative(bundle.files.html) ?? runFiles.html;
|
|
555
571
|
const missingVideo = (ledger.sessions ?? []).filter((s) => s.videoProblem || !s.video);
|
|
556
|
-
const actions = views.reduce((n, v) => n + v.
|
|
572
|
+
const actions = views.reduce((n, v) => n + scriptSteps(v).length, 0);
|
|
557
573
|
const urls = urlTimeline(bundle, views);
|
|
558
574
|
const idle = idleStretches(bundle);
|
|
559
575
|
const overlay = html `<div class="wt-box" id="wt-box" hidden><span></span></div>
|
|
@@ -629,7 +645,7 @@ export const renderWalkthrough = (bundle, options) => {
|
|
|
629
645
|
<body>
|
|
630
646
|
${scriptTag}
|
|
631
647
|
<div class="${`wt device-${bundle.device.kind}`}" style="${shapeStyle(bundle)}">
|
|
632
|
-
${topBar(bundle.startedAt, bundle.jobId,
|
|
648
|
+
${topBar(bundle.startedAt, bundle.jobId, { href: report, name: 'Full report', icon: 'file-text' })}
|
|
633
649
|
${promptBlock(spec.instructions)}
|
|
634
650
|
${ledger.error
|
|
635
651
|
? html `<div class="alert" role="note">
|
|
@@ -664,12 +680,6 @@ export const renderWalkthrough = (bundle, options) => {
|
|
|
664
680
|
</section>
|
|
665
681
|
${problemsBlock(views, sessions)}
|
|
666
682
|
</main>
|
|
667
|
-
<p class="foot">
|
|
668
|
-
Statuses decided by code in a real browser. Boxes over the video mark the element a step
|
|
669
|
-
acted on, measured as it ran; none is drawn where it was not measured. The cursor,
|
|
670
|
-
clicks and labels over it are drawn here from where each action was recorded; they are
|
|
671
|
-
not in the video itself.
|
|
672
|
-
</p>
|
|
673
683
|
</div>
|
|
674
684
|
</body>
|
|
675
685
|
</html> `;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
|
+
/** At most this long, the `about` of an account (one line). */
|
|
3
|
+
export declare const ACCOUNT_ABOUT_MAX = 200;
|
|
4
|
+
/** A label such as `trial-user`: lower-case letters, digits and dashes, also a file name. */
|
|
5
|
+
export declare const AccountLabel: Schema.String;
|
|
6
|
+
/** What kind of user an account is, for the agent picking one: one line. */
|
|
7
|
+
export declare const AccountAbout: Schema.String;
|
|
8
|
+
/** A job's account: its label, or the label with what it is and whether to sign in again. */
|
|
9
|
+
export declare const JobAccount: Schema.Union<readonly [Schema.String, Schema.Struct<{
|
|
10
|
+
readonly label: Schema.String;
|
|
11
|
+
readonly about: Schema.optionalKey<Schema.String>;
|
|
12
|
+
readonly renew: Schema.optionalKey<Schema.Boolean>;
|
|
13
|
+
}>]>;
|
|
14
|
+
export type JobAccount = typeof JobAccount.Type;
|
|
15
|
+
/** The label of a job's account. */
|
|
16
|
+
export declare const accountLabel: (account: JobAccount) => string;
|
|
17
|
+
/** The `about` a job gave its account, if any. */
|
|
18
|
+
export declare const accountAboutOf: (account: JobAccount) => string | undefined;
|
|
19
|
+
/** One saved account in `accounts.json`. Never a secret: the session is a file of its own. */
|
|
20
|
+
export declare const AccountEntry: Schema.Struct<{
|
|
21
|
+
readonly label: Schema.String;
|
|
22
|
+
readonly about: Schema.optionalKey<Schema.String>;
|
|
23
|
+
/** The origin it was signed in on, such as `http://localhost:3000`; runs elsewhere sign in again. */
|
|
24
|
+
readonly origin: Schema.String;
|
|
25
|
+
/** When the session was saved, as an ISO time. */
|
|
26
|
+
readonly savedAt: Schema.String;
|
|
27
|
+
}>;
|
|
28
|
+
export type AccountEntry = typeof AccountEntry.Type;
|
|
29
|
+
/** `.screw-bugs/accounts.json`: the saved accounts, for agents to pick from. */
|
|
30
|
+
export declare const AccountsFile: Schema.Struct<{
|
|
31
|
+
readonly version: Schema.Literal<1>;
|
|
32
|
+
readonly accounts: Schema.$Array<Schema.Struct<{
|
|
33
|
+
readonly label: Schema.String;
|
|
34
|
+
readonly about: Schema.optionalKey<Schema.String>;
|
|
35
|
+
/** The origin it was signed in on, such as `http://localhost:3000`; runs elsewhere sign in again. */
|
|
36
|
+
readonly origin: Schema.String;
|
|
37
|
+
/** When the session was saved, as an ISO time. */
|
|
38
|
+
readonly savedAt: Schema.String;
|
|
39
|
+
}>>;
|
|
40
|
+
}>;
|
|
41
|
+
export type AccountsFile = typeof AccountsFile.Type;
|
|
42
|
+
/**
|
|
43
|
+
* The parts of a saved session (Playwright's storage state) read to tell whether it may still
|
|
44
|
+
* work. Everything else in the file is only for the browser.
|
|
45
|
+
*/
|
|
46
|
+
export declare const SavedSession: Schema.Struct<{
|
|
47
|
+
/**
|
|
48
|
+
* Where and when this session was signed in, written in the same file (one atomic rename) so a
|
|
49
|
+
* run never pairs a session with another one's origin; `accounts.json` only lists it.
|
|
50
|
+
*/
|
|
51
|
+
readonly account: Schema.Struct<{
|
|
52
|
+
readonly label: Schema.String;
|
|
53
|
+
readonly origin: Schema.String;
|
|
54
|
+
readonly savedAt: Schema.String;
|
|
55
|
+
}>;
|
|
56
|
+
readonly cookies: Schema.$Array<Schema.Struct<{
|
|
57
|
+
readonly name: Schema.String;
|
|
58
|
+
readonly domain: Schema.String;
|
|
59
|
+
/** Seconds since the epoch; -1 for a cookie that lasts as long as the browser. */
|
|
60
|
+
readonly expires: Schema.Number;
|
|
61
|
+
}>>;
|
|
62
|
+
readonly origins: Schema.$Array<Schema.Struct<{
|
|
63
|
+
readonly origin: Schema.String;
|
|
64
|
+
}>>;
|
|
65
|
+
}>;
|
|
66
|
+
export type SavedSession = typeof SavedSession.Type;
|
|
67
|
+
/** Why a job's account needs a person to sign in before it can run. */
|
|
68
|
+
export type SignInWhy = {
|
|
69
|
+
readonly _tag: 'none';
|
|
70
|
+
} | {
|
|
71
|
+
readonly _tag: 'origin';
|
|
72
|
+
readonly saved: string;
|
|
73
|
+
} | {
|
|
74
|
+
readonly _tag: 'expired';
|
|
75
|
+
} | {
|
|
76
|
+
readonly _tag: 'renew';
|
|
77
|
+
};
|
|
78
|
+
export declare const SignInInput: Schema.Union<readonly [Schema.Struct<{
|
|
79
|
+
readonly type: Schema.Literal<"mouse">;
|
|
80
|
+
readonly kind: Schema.Literals<readonly ["move", "down", "up"]>;
|
|
81
|
+
readonly x: Schema.Number;
|
|
82
|
+
readonly y: Schema.Number;
|
|
83
|
+
readonly button: Schema.optionalKey<Schema.Literals<readonly ["left", "middle", "right"]>>;
|
|
84
|
+
readonly clickCount: Schema.optionalKey<Schema.Int>;
|
|
85
|
+
}>, Schema.Struct<{
|
|
86
|
+
readonly type: Schema.Literal<"wheel">;
|
|
87
|
+
readonly x: Schema.Number;
|
|
88
|
+
readonly y: Schema.Number;
|
|
89
|
+
readonly dx: Schema.Number;
|
|
90
|
+
readonly dy: Schema.Number;
|
|
91
|
+
}>, Schema.Struct<{
|
|
92
|
+
readonly type: Schema.Literal<"key">;
|
|
93
|
+
/** A `KeyboardEvent.key`, such as `Enter`, `ArrowLeft` or `a`. */
|
|
94
|
+
readonly key: Schema.String;
|
|
95
|
+
readonly modifiers: Schema.optionalKey<Schema.$Array<Schema.Literals<readonly ["Alt", "Control", "Meta", "Shift"]>>>;
|
|
96
|
+
}>, Schema.Struct<{
|
|
97
|
+
readonly type: Schema.Literal<"text">;
|
|
98
|
+
readonly text: Schema.String;
|
|
99
|
+
}>, Schema.Struct<{
|
|
100
|
+
readonly type: Schema.Literal<"nav">;
|
|
101
|
+
readonly kind: Schema.Literals<readonly ["back", "forward", "reload"]>;
|
|
102
|
+
}>, Schema.Struct<{
|
|
103
|
+
readonly type: Schema.Literal<"viewport">;
|
|
104
|
+
readonly width: Schema.Int;
|
|
105
|
+
readonly height: Schema.Int;
|
|
106
|
+
}>]>;
|
|
107
|
+
export type SignInInput = typeof SignInInput.Type;
|
|
108
|
+
/** What the live view posts: a few inputs at a time. */
|
|
109
|
+
export declare const SignInInputs: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
110
|
+
readonly type: Schema.Literal<"mouse">;
|
|
111
|
+
readonly kind: Schema.Literals<readonly ["move", "down", "up"]>;
|
|
112
|
+
readonly x: Schema.Number;
|
|
113
|
+
readonly y: Schema.Number;
|
|
114
|
+
readonly button: Schema.optionalKey<Schema.Literals<readonly ["left", "middle", "right"]>>;
|
|
115
|
+
readonly clickCount: Schema.optionalKey<Schema.Int>;
|
|
116
|
+
}>, Schema.Struct<{
|
|
117
|
+
readonly type: Schema.Literal<"wheel">;
|
|
118
|
+
readonly x: Schema.Number;
|
|
119
|
+
readonly y: Schema.Number;
|
|
120
|
+
readonly dx: Schema.Number;
|
|
121
|
+
readonly dy: Schema.Number;
|
|
122
|
+
}>, Schema.Struct<{
|
|
123
|
+
readonly type: Schema.Literal<"key">;
|
|
124
|
+
/** A `KeyboardEvent.key`, such as `Enter`, `ArrowLeft` or `a`. */
|
|
125
|
+
readonly key: Schema.String;
|
|
126
|
+
readonly modifiers: Schema.optionalKey<Schema.$Array<Schema.Literals<readonly ["Alt", "Control", "Meta", "Shift"]>>>;
|
|
127
|
+
}>, Schema.Struct<{
|
|
128
|
+
readonly type: Schema.Literal<"text">;
|
|
129
|
+
readonly text: Schema.String;
|
|
130
|
+
}>, Schema.Struct<{
|
|
131
|
+
readonly type: Schema.Literal<"nav">;
|
|
132
|
+
readonly kind: Schema.Literals<readonly ["back", "forward", "reload"]>;
|
|
133
|
+
}>, Schema.Struct<{
|
|
134
|
+
readonly type: Schema.Literal<"viewport">;
|
|
135
|
+
readonly width: Schema.Int;
|
|
136
|
+
readonly height: Schema.Int;
|
|
137
|
+
}>]>>;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
|
+
/*
|
|
3
|
+
* Test accounts: sessions a person signed in to once, which runs start from. The agent picks an
|
|
4
|
+
* account by label for what its cases need (`about` says what kind of user it is); a person signs
|
|
5
|
+
* in to it in the live view, where what they type goes to that browser only: never logged, recorded
|
|
6
|
+
* or saved. Only the session is kept.
|
|
7
|
+
*/
|
|
8
|
+
/** At most this long, the `about` of an account (one line). */
|
|
9
|
+
export const ACCOUNT_ABOUT_MAX = 200;
|
|
10
|
+
/** A label such as `trial-user`: lower-case letters, digits and dashes, also a file name. */
|
|
11
|
+
export const AccountLabel = Schema.String.check(Schema.isPattern(/^[a-z0-9][a-z0-9-]{0,39}$/, {
|
|
12
|
+
message: 'Use 1-40 lower-case letters, digits or dashes, starting with a letter or digit',
|
|
13
|
+
})).annotate({ description: 'Label of a test account, such as trial-user.' });
|
|
14
|
+
/** What kind of user an account is, for the agent picking one: one line. */
|
|
15
|
+
export const AccountAbout = Schema.String.check(Schema.makeFilter((text) => !text.trim()
|
|
16
|
+
? 'Must not be blank'
|
|
17
|
+
: text.length > ACCOUNT_ABOUT_MAX
|
|
18
|
+
? `At most ${ACCOUNT_ABOUT_MAX} characters`
|
|
19
|
+
: /[\r\n]/.test(text)
|
|
20
|
+
? 'Must be one line'
|
|
21
|
+
: undefined)).annotate({
|
|
22
|
+
description: 'What kind of user this is, such as "On a 14-day trial, no card on file".',
|
|
23
|
+
});
|
|
24
|
+
/** A job's account: its label, or the label with what it is and whether to sign in again. */
|
|
25
|
+
export const JobAccount = Schema.Union([
|
|
26
|
+
AccountLabel,
|
|
27
|
+
Schema.Struct({
|
|
28
|
+
label: AccountLabel,
|
|
29
|
+
about: Schema.optionalKey(AccountAbout),
|
|
30
|
+
renew: Schema.optionalKey(Schema.Boolean.annotate({
|
|
31
|
+
description: 'Ask the user to sign in to it again (its saved session no longer works), unless that ' +
|
|
32
|
+
'happened in the last 10 minutes.',
|
|
33
|
+
})),
|
|
34
|
+
}),
|
|
35
|
+
]);
|
|
36
|
+
/** The label of a job's account. */
|
|
37
|
+
export const accountLabel = (account) => typeof account === 'string' ? account : account.label;
|
|
38
|
+
/** The `about` a job gave its account, if any. */
|
|
39
|
+
export const accountAboutOf = (account) => typeof account === 'string' ? undefined : account.about;
|
|
40
|
+
/** One saved account in `accounts.json`. Never a secret: the session is a file of its own. */
|
|
41
|
+
export const AccountEntry = Schema.Struct({
|
|
42
|
+
label: AccountLabel,
|
|
43
|
+
about: Schema.optionalKey(Schema.String),
|
|
44
|
+
/** The origin it was signed in on, such as `http://localhost:3000`; runs elsewhere sign in again. */
|
|
45
|
+
origin: Schema.String,
|
|
46
|
+
/** When the session was saved, as an ISO time. */
|
|
47
|
+
savedAt: Schema.String,
|
|
48
|
+
});
|
|
49
|
+
/** `.screw-bugs/accounts.json`: the saved accounts, for agents to pick from. */
|
|
50
|
+
export const AccountsFile = Schema.Struct({
|
|
51
|
+
version: Schema.Literal(1),
|
|
52
|
+
accounts: Schema.Array(AccountEntry),
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* The parts of a saved session (Playwright's storage state) read to tell whether it may still
|
|
56
|
+
* work. Everything else in the file is only for the browser.
|
|
57
|
+
*/
|
|
58
|
+
export const SavedSession = Schema.Struct({
|
|
59
|
+
/**
|
|
60
|
+
* Where and when this session was signed in, written in the same file (one atomic rename) so a
|
|
61
|
+
* run never pairs a session with another one's origin; `accounts.json` only lists it.
|
|
62
|
+
*/
|
|
63
|
+
account: Schema.Struct({ label: Schema.String, origin: Schema.String, savedAt: Schema.String }),
|
|
64
|
+
cookies: Schema.Array(Schema.Struct({
|
|
65
|
+
name: Schema.String,
|
|
66
|
+
domain: Schema.String,
|
|
67
|
+
/** Seconds since the epoch; -1 for a cookie that lasts as long as the browser. */
|
|
68
|
+
expires: Schema.Number,
|
|
69
|
+
})),
|
|
70
|
+
origins: Schema.Array(Schema.Struct({ origin: Schema.String })),
|
|
71
|
+
});
|
|
72
|
+
/** One input the live view sends for the person signing in, in viewport CSS pixels. */
|
|
73
|
+
const Coordinate = Schema.Number.check(Schema.isBetween({ minimum: -10_000, maximum: 10_000 }));
|
|
74
|
+
const Modifiers = Schema.Array(Schema.Literals(['Alt', 'Control', 'Meta', 'Shift'])).check(Schema.isMaxLength(4));
|
|
75
|
+
export const SignInInput = Schema.Union([
|
|
76
|
+
Schema.Struct({
|
|
77
|
+
type: Schema.Literal('mouse'),
|
|
78
|
+
kind: Schema.Literals(['move', 'down', 'up']),
|
|
79
|
+
x: Coordinate,
|
|
80
|
+
y: Coordinate,
|
|
81
|
+
button: Schema.optionalKey(Schema.Literals(['left', 'middle', 'right'])),
|
|
82
|
+
clickCount: Schema.optionalKey(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 3 }))),
|
|
83
|
+
}),
|
|
84
|
+
Schema.Struct({
|
|
85
|
+
type: Schema.Literal('wheel'),
|
|
86
|
+
x: Coordinate,
|
|
87
|
+
y: Coordinate,
|
|
88
|
+
dx: Coordinate,
|
|
89
|
+
dy: Coordinate,
|
|
90
|
+
}),
|
|
91
|
+
Schema.Struct({
|
|
92
|
+
type: Schema.Literal('key'),
|
|
93
|
+
/** A `KeyboardEvent.key`, such as `Enter`, `ArrowLeft` or `a`. */
|
|
94
|
+
key: Schema.String.check(Schema.isPattern(/^(?:[A-Za-z0-9]{1,20}|[^\s]|\s)$/u)),
|
|
95
|
+
modifiers: Schema.optionalKey(Modifiers),
|
|
96
|
+
}),
|
|
97
|
+
Schema.Struct({
|
|
98
|
+
type: Schema.Literal('text'),
|
|
99
|
+
text: Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(2_000)),
|
|
100
|
+
}),
|
|
101
|
+
Schema.Struct({
|
|
102
|
+
type: Schema.Literal('nav'),
|
|
103
|
+
kind: Schema.Literals(['back', 'forward', 'reload']),
|
|
104
|
+
}),
|
|
105
|
+
Schema.Struct({
|
|
106
|
+
type: Schema.Literal('viewport'),
|
|
107
|
+
width: Schema.Int,
|
|
108
|
+
height: Schema.Int,
|
|
109
|
+
}),
|
|
110
|
+
]);
|
|
111
|
+
/** What the live view posts: a few inputs at a time. */
|
|
112
|
+
export const SignInInputs = Schema.Array(SignInInput).check(Schema.isMaxLength(100));
|
package/dist/schema/index.d.ts
CHANGED
package/dist/schema/index.js
CHANGED