screw-bugs 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +906 -2
- package/bin/screw-bugs.js +29 -0
- package/dist/browser-playwright/annotate.d.ts +9 -0
- package/dist/browser-playwright/annotate.js +86 -0
- package/dist/browser-playwright/capture.d.ts +232 -0
- package/dist/browser-playwright/capture.js +1049 -0
- package/dist/browser-playwright/frames.d.ts +77 -0
- package/dist/browser-playwright/frames.js +191 -0
- package/dist/browser-playwright/index.d.ts +2 -0
- package/dist/browser-playwright/index.js +2 -0
- package/dist/browser-playwright/input.d.ts +44 -0
- package/dist/browser-playwright/input.js +116 -0
- package/dist/browser-playwright/launch.d.ts +21 -0
- package/dist/browser-playwright/launch.js +86 -0
- package/dist/browser-playwright/page.d.ts +387 -0
- package/dist/browser-playwright/page.js +1930 -0
- package/dist/build-info.json +5 -0
- package/dist/cli/app.d.ts +19 -0
- package/dist/cli/app.js +70 -0
- package/dist/cli/build-info.d.ts +52 -0
- package/dist/cli/build-info.js +82 -0
- package/dist/cli/commands.d.ts +14 -0
- package/dist/cli/commands.js +308 -0
- package/dist/cli/config.d.ts +16 -0
- package/dist/cli/config.js +71 -0
- package/dist/cli/doctor.d.ts +19 -0
- package/dist/cli/doctor.js +113 -0
- package/dist/cli/environment.d.ts +20 -0
- package/dist/cli/environment.js +34 -0
- package/dist/cli/exit-codes.d.ts +29 -0
- package/dist/cli/exit-codes.js +28 -0
- package/dist/cli/failure.d.ts +20 -0
- package/dist/cli/failure.js +15 -0
- package/dist/cli/index.d.ts +6 -0
- package/dist/cli/index.js +6 -0
- package/dist/cli/install-method.d.ts +96 -0
- package/dist/cli/install-method.js +148 -0
- package/dist/cli/main.d.ts +1 -0
- package/dist/cli/main.js +10 -0
- package/dist/cli/mcp.d.ts +30 -0
- package/dist/cli/mcp.js +309 -0
- package/dist/cli/node-version.d.ts +3 -0
- package/dist/cli/node-version.js +22 -0
- package/dist/cli/operations.d.ts +127 -0
- package/dist/cli/operations.js +337 -0
- package/dist/cli/package-info.d.ts +22 -0
- package/dist/cli/package-info.js +25 -0
- package/dist/cli/report-server.d.ts +170 -0
- package/dist/cli/report-server.js +387 -0
- package/dist/cli/signals.d.ts +37 -0
- package/dist/cli/signals.js +61 -0
- package/dist/cli/stamp-build.d.ts +1 -0
- package/dist/cli/stamp-build.js +9 -0
- package/dist/cli/update-check.d.ts +140 -0
- package/dist/cli/update-check.js +316 -0
- package/dist/cli/uploads.d.ts +16 -0
- package/dist/cli/uploads.js +80 -0
- package/dist/core/css.d.ts +95 -0
- package/dist/core/css.js +436 -0
- package/dist/core/engine.d.ts +65 -0
- package/dist/core/engine.js +436 -0
- package/dist/core/errors.d.ts +66 -0
- package/dist/core/errors.js +30 -0
- package/dist/core/evidence.d.ts +14 -0
- package/dist/core/evidence.js +127 -0
- package/dist/core/index.d.ts +12 -0
- package/dist/core/index.js +12 -0
- package/dist/core/labels.d.ts +47 -0
- package/dist/core/labels.js +199 -0
- package/dist/core/liveness.d.ts +45 -0
- package/dist/core/liveness.js +64 -0
- package/dist/core/marks.d.ts +63 -0
- package/dist/core/marks.js +410 -0
- package/dist/core/services.d.ts +444 -0
- package/dist/core/services.js +22 -0
- package/dist/core/steps.d.ts +96 -0
- package/dist/core/steps.js +656 -0
- package/dist/core/uploads.d.ts +49 -0
- package/dist/core/uploads.js +133 -0
- package/dist/core/video.d.ts +16 -0
- package/dist/core/video.js +101 -0
- package/dist/core/viewport.d.ts +28 -0
- package/dist/core/viewport.js +50 -0
- package/dist/report/html.d.ts +37 -0
- package/dist/report/html.js +762 -0
- package/dist/report/index.d.ts +5 -0
- package/dist/report/index.js +5 -0
- package/dist/report/markup.d.ts +27 -0
- package/dist/report/markup.js +75 -0
- package/dist/report/pr-summary.d.ts +11 -0
- package/dist/report/pr-summary.js +110 -0
- package/dist/report/sha256.d.ts +9 -0
- package/dist/report/sha256.js +97 -0
- package/dist/report/styles.d.ts +1 -0
- package/dist/report/styles.js +328 -0
- package/dist/report/view.d.ts +141 -0
- package/dist/report/view.js +368 -0
- package/dist/report/walkthrough.d.ts +75 -0
- package/dist/report/walkthrough.js +458 -0
- package/dist/schema/config.d.ts +7 -0
- package/dist/schema/config.js +6 -0
- package/dist/schema/doctor.d.ts +46 -0
- package/dist/schema/doctor.js +23 -0
- package/dist/schema/evidence.d.ts +994 -0
- package/dist/schema/evidence.js +521 -0
- package/dist/schema/findings.d.ts +159 -0
- package/dist/schema/findings.js +80 -0
- package/dist/schema/index.d.ts +7 -0
- package/dist/schema/index.js +7 -0
- package/dist/schema/job.d.ts +1724 -0
- package/dist/schema/job.js +505 -0
- package/dist/schema/ledger.d.ts +951 -0
- package/dist/schema/ledger.js +193 -0
- package/dist/schema/status.d.ts +7 -0
- package/dist/schema/status.js +11 -0
- package/dist/store-local/accounts.d.ts +7 -0
- package/dist/store-local/accounts.js +9 -0
- package/dist/store-local/index.d.ts +3 -0
- package/dist/store-local/index.js +3 -0
- package/dist/store-local/paths.d.ts +10 -0
- package/dist/store-local/paths.js +17 -0
- package/dist/store-local/storage.d.ts +20 -0
- package/dist/store-local/storage.js +170 -0
- package/package.json +73 -4
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
import { clampBox } from '../core/index.js';
|
|
2
|
+
import { runFiles, } from '../schema/index.js';
|
|
3
|
+
import { badge, html, icon, Markup, safeRelative, textParts, themeSwitch } from './markup.js';
|
|
4
|
+
import { cspHash } from './sha256.js';
|
|
5
|
+
import { styles } from './styles.js';
|
|
6
|
+
import { caseViews, stepText, formatTime, formatTimecode, fragmentSeconds, stepParts, } from './view.js';
|
|
7
|
+
/*
|
|
8
|
+
* The walkthrough: one player for the run's video, and below it the script, every step of every
|
|
9
|
+
* case in run order with its timecode. The step playing now is shown in full contrast and the
|
|
10
|
+
* script keeps it in view; any timecode seeks the player there (switching to its session's video)
|
|
11
|
+
* and plays. Cases that did not pass say why at the step that decided them, in the report's words.
|
|
12
|
+
* Like the report it loads nothing from the network and links the video by relative path.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* How long around the moment a step's element was measured its box is drawn over the video, in
|
|
16
|
+
* ms: a little before (the element was already there while the step waited on it) and after.
|
|
17
|
+
* Outside this the page may have moved on, so no box is drawn.
|
|
18
|
+
*/
|
|
19
|
+
export const BOX_BEFORE_MS = 700;
|
|
20
|
+
export const BOX_AFTER_MS = 1200;
|
|
21
|
+
/** Seconds the cursor takes, at most, to glide to the next point the mouse pressed. */
|
|
22
|
+
export const GLIDE_S = 0.6;
|
|
23
|
+
/**
|
|
24
|
+
* The page's one script, allowed by its hash in the Content Security Policy. It sets the theme as
|
|
25
|
+
* the report does. With a player, it marks the step playing now (the last step of the video's
|
|
26
|
+
* session whose time is at or before the player's), keeps it in view in the script (without
|
|
27
|
+
* motion when the reader prefers less), draws the box of the element it acted on over the video
|
|
28
|
+
* while that was measured, makes timecodes seek (and switch session videos) instead of opening
|
|
29
|
+
* the file, and goes on to the next session's video when one ends. A session video that does not
|
|
30
|
+
* load is remembered as broken on its own: the note takes the player's place, naming that file,
|
|
31
|
+
* while timecodes of the other sessions still load and play theirs (and bring the player back);
|
|
32
|
+
* moving on skips broken ones. Without script, timecodes open the video file at their time, and
|
|
33
|
+
* every step reads in full contrast.
|
|
34
|
+
*
|
|
35
|
+
* Over the video it also draws, from each step's recorded action (`stepAction`) and only for the
|
|
36
|
+
* session playing, what the mouse and keyboard did: a cursor that shows from the first point the
|
|
37
|
+
* mouse pressed, glides to each next one (eased, over at most `GLIDE_S` before it) and rests there, a ripple where and when it
|
|
38
|
+
* pressed, a ring in place of the step's box around a field typed into (when that box shows: a
|
|
39
|
+
* fill records no time or element of its own), and a short
|
|
40
|
+
* label of the action (the latest one that happened, else the one the cursor is gliding to; the
|
|
41
|
+
* box's own label gives way to it; one whose time was not recorded is labelled while its step
|
|
42
|
+
* plays, and has no cursor or ripple). All of
|
|
43
|
+
* it follows the player's time, so seeking or pausing shows the state at that moment. With less
|
|
44
|
+
* motion preferred, the cursor jumps instead of gliding and there is no ripple. A "Show cursor"
|
|
45
|
+
* switch turns it off, remembered like the theme. Nothing is added to the page under test or to
|
|
46
|
+
* the video.
|
|
47
|
+
*/
|
|
48
|
+
export const WALKTHROUGH_SCRIPT = `(()=>{const d=document,r=d.documentElement,k='screw-bugs-theme';const set=m=>{r.dataset.theme=m;d.querySelectorAll('[data-theme-set]').forEach(b=>b.setAttribute('aria-pressed',String(b.dataset.themeSet===m)))};let m='system';try{m=localStorage.getItem(k)||m}catch(e){}r.dataset.theme=m;const still=()=>matchMedia('(prefers-reduced-motion: reduce)').matches;d.addEventListener('DOMContentLoaded',()=>{set(r.dataset.theme);const th=d.getElementById('theme');if(th)th.hidden=false;d.addEventListener('click',e=>{const b=e.target.closest('[data-theme-set]');if(!b)return;set(b.dataset.themeSet);try{localStorage.setItem(k,b.dataset.themeSet)}catch(e){}});const v=d.getElementById('wt-video');if(!v)return;const w=d.querySelector('.wt'),fig=v.closest('.wt-player'),panel=d.getElementById('wt-script'),box=d.getElementById('wt-box'),note=d.getElementById('wt-unloaded');const srcs=new Map([...d.querySelectorAll('[data-session-src]')].map(e=>[e.dataset.session,e.dataset.sessionSrc]));const order=[...srcs.keys()];const steps=[...d.querySelectorAll('.wt-step[data-t]')];const dead=new Set();let cur=v.dataset.session,on=null,down=null,ask=0,auto=false;w.classList.add('live');const hide=()=>{box.hidden=true};const show=s=>{down=s;v.pause();hide();update();w.classList.remove('live');fig.classList.add('broken');if(note){note.hidden=false;const a=note.querySelector('a');if(a){a.href=srcs.get(s);a.textContent=srcs.get(s)}}};const fine=()=>{if(down===null)return;down=null;fig.classList.remove('broken');w.classList.add('live');if(note)note.hidden=true};const next=s=>order.slice(order.indexOf(s)+1).find(n=>!dead.has(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}};const put=(e,x,y,w,h)=>{e.style.left=x+'px';e.style.top=y+'px';if(w!==undefined){e.style.width=w+'px';e.style.height=h+'px'}};const draw=(t,g)=>{if(down!==null||!g||!on||!on.dataset.box||t<Number(on.dataset.b0)||t>Number(on.dataset.b1))return hide();const [x,y,bw,bh]=on.dataset.box.split(' ').map(Number);put(box,g.x+x*g.w,g.y+y*g.h,bw*g.w,bh*g.h);box.querySelector('span').textContent=on.dataset.label||'';box.hidden=false};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';const nums=x=>x?x.split(' ').map(Number):null;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));let fon=true;try{fon=localStorage.getItem(ck)!=='off'}catch(e){}const fx=(t,g)=>{C.hidden=R.hidden=G.hidden=L.hidden=true;box.querySelector('span').hidden=false;if(!fon||down!==null||!g)return;const m=still(),mine=acts.filter(a=>a.s===cur),ptr=mine.filter(a=>a.p),xy=p=>[g.x+p[0]*g.w,g.y+p[1]*g.h];let i=-1;ptr.forEach((a,j)=>{if(a.at<=t)i=j});const a=ptr[i],n=ptr[i+1];let c=a?a.p:null;if(n&&a){const w=Math.min(${GLIDE_S},a?n.at-a.at:${GLIDE_S}),q=w>0?(t-n.at+w)/w: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}}if(c){const [x,y]=xy(c);put(C,x-3,y-2);C.hidden=false}if(a&&!m&&t-a.at<.6){const q=(t-a.at)/.6,[x,y]=xy(a.p);put(R,x,y);R.style.transform='translate(-50%,-50%) scale('+(.35+q*1.3)+')';R.style.opacity=String(1-q);R.hidden=false}let f=null,l=null,u=null;for(const a of mine){if(a.k==='fill'&&a.b&&t>=a.b0&&t<=a.b1)f=a;if(a.k==='fill'||!(a.at>=0)?t>=a.t0&&t<=a.t1:t>=a.at&&t<=a.at+1.5)l=a;else if(!u&&a.p&&a.at>t&&a.at-t<=${GLIDE_S})u=a}l=l||u;if(f){const [x,y]=xy(f.b);put(G,x,y,f.b[2]*g.w,f.b[3]*g.h);G.hidden=false;box.hidden=true}if(l&&l.l){L.textContent=l.l;L.hidden=false;let x=g.x+10,y=g.y+10;if(l.p){[x,y]=xy(l.p);x+=14;y+=20}else if(l.b){[x,y]=xy(l.b);y+=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))}box.querySelector('span').hidden=!L.hidden};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){}update()})}const update=()=>{const t=v.currentTime;let a=null;for(const s of steps){if(s.dataset.s===cur&&Number(s.dataset.t)<=t+0.02)a=s}if(a!==on){if(on){on.classList.remove('on');on.removeAttribute('aria-current');on.closest('.wt-case').classList.remove('on')}on=a;if(a){a.classList.add('on');a.setAttribute('aria-current','step');a.closest('.wt-case').classList.add('on');const p=panel.getBoundingClientRect(),q=a.getBoundingClientRect();if(q.top<p.top||q.bottom>p.bottom)panel.scrollBy({top:q.top-p.top-p.height/3,behavior:still()?'auto':'smooth'})}}const g=geo();draw(t,g);fx(t,g)};let raf=0;const tick=()=>{update();raf=v.paused?0:requestAnimationFrame(tick)};['timeupdate','seeked','loadedmetadata','pause'].forEach(n=>v.addEventListener(n,update));v.addEventListener('play',()=>{if(!raf)raf=requestAnimationFrame(tick)});addEventListener('resize',update);const load=(s,t,play,a=false)=>{const my=++ask;auto=a;if(dead.has(s))return show(s);if(s!==cur||!v.currentSrc||v.error){cur=s;v.dataset.session=s;v.src=srcs.get(s);v.load()}const go=()=>{if(my!==ask)return;auto=false;fine();v.currentTime=t;update();if(play)v.play().catch(()=>{})};if(v.readyState>0)go();else v.addEventListener('loadedmetadata',go,{once:true})};const bad=()=>{if(!v.error)return;dead.add(cur);const n=auto?next(cur):undefined;if(n!==undefined)return load(n,0,true,true);auto=false;show(cur)};v.addEventListener('error',bad);if(v.error)bad();v.addEventListener('ended',()=>{const n=next(cur);if(n!==undefined)load(n,0,true,true)});d.addEventListener('click',e=>{const a=e.target.closest('a[data-t]');if(!a||!srcs.has(a.dataset.s))return;e.preventDefault();if(fig.getBoundingClientRect().bottom<0)fig.scrollIntoView({block:'start',behavior:still()?'auto':'smooth'});load(a.dataset.s,Number(a.dataset.t),true)})})})();`;
|
|
49
|
+
const scriptTag = new Markup(`<script>${WALKTHROUGH_SCRIPT}</script>`);
|
|
50
|
+
/** As the report's: nothing from the network, the video by relative path, one script by hash. */
|
|
51
|
+
export const WALKTHROUGH_CSP = "default-src 'none'; img-src 'self' file: data:; media-src 'self' file:; " +
|
|
52
|
+
`style-src 'unsafe-inline'; script-src ${cspHash(WALKTHROUGH_SCRIPT)}; base-uri 'none'; form-action 'none'`;
|
|
53
|
+
const walkthroughStyles = `
|
|
54
|
+
.wt-top { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; margin: 18px 0 0; }
|
|
55
|
+
.wt-top h1 { margin: 0; font-size: 24px; letter-spacing: -0.01em; }
|
|
56
|
+
.wt-report { font-weight: 600; }
|
|
57
|
+
.wt-problems { margin: 18px 0 0; padding: 12px 16px; border: 1px solid var(--rule-2); border-radius: 4px; background: var(--paper); }
|
|
58
|
+
.wt-problems h2 { margin: 0 0 8px; }
|
|
59
|
+
.wt-problems ul { list-style: none; margin: 0; padding: 0; }
|
|
60
|
+
.wt-problems li { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 10px; align-items: baseline; padding: 6px 0; border-top: 1px solid var(--rule); }
|
|
61
|
+
.wt-problems li:first-child { border-top: 0; }
|
|
62
|
+
.wt-problems .why { overflow-wrap: anywhere; }
|
|
63
|
+
.wt-player { margin: 20px 0 0; }
|
|
64
|
+
.wt-screen { position: relative; }
|
|
65
|
+
.wt-screen video { display: block; width: 100%; max-height: 48vh; aspect-ratio: auto 16 / 10; background: var(--player); border-radius: 6px; }
|
|
66
|
+
.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; }
|
|
67
|
+
.wt-box[hidden] { display: none; }
|
|
68
|
+
.wt-box span { position: absolute; left: -2px; top: 100%; margin-top: 9px; font: 600 11px/1.4 var(--sans); color: #fff; background: var(--mark-step); padding: 1px 6px; border-radius: 3px; white-space: nowrap; }
|
|
69
|
+
.wt-cursor, .wt-ripple, .wt-ring, .wt-act { position: absolute; pointer-events: none; }
|
|
70
|
+
.wt-cursor { width: 22px; height: 22px; z-index: 4; filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, .5)); }
|
|
71
|
+
.wt-cursor svg { display: block; }
|
|
72
|
+
.wt-ripple { width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--mark-step); background: rgba(47, 111, 214, .22); z-index: 3; }
|
|
73
|
+
.wt-ring { border-radius: 4px; box-shadow: 0 0 0 3px var(--mark-step), 0 0 0 7px rgba(47, 111, 214, .28); z-index: 2; }
|
|
74
|
+
.wt-act { z-index: 5; max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 12px/1.45 var(--sans); color: #fff; background: rgba(17, 17, 17, .88); padding: 3px 8px; border-radius: 4px; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
|
|
75
|
+
.wt-cursor[hidden], .wt-ripple[hidden], .wt-ring[hidden], .wt-act[hidden] { display: none; }
|
|
76
|
+
.wt-controls { display: flex; justify-content: flex-end; margin: 6px 0 0; font-size: 13px; color: var(--ink-2); }
|
|
77
|
+
.wt-controls label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
|
|
78
|
+
.wt-controls label[hidden] { display: none; }
|
|
79
|
+
.wt-player.broken .wt-controls { display: none; }
|
|
80
|
+
.wt-player .unloaded { margin: 0; padding: 28px 20px; border: 1px dashed var(--rule-2); border-radius: 6px; background: var(--paper); text-align: center; overflow-wrap: anywhere; }
|
|
81
|
+
.wt-player.broken .wt-screen { display: none; }
|
|
82
|
+
.wt-novideo { margin: 20px 0 0; padding: 12px 16px; border: 1px dashed var(--rule-2); border-radius: 4px; background: var(--paper); }
|
|
83
|
+
.wt-script { list-style: none; margin: 14px 0 0; padding: 0 4px 0 0; max-height: 48vh; overflow-y: auto; border-top: 1px solid var(--ink); }
|
|
84
|
+
.wt-case { padding: 14px 0 10px; border-bottom: 1px solid var(--rule); }
|
|
85
|
+
.wt-case-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0 0 8px; font-size: 15px; }
|
|
86
|
+
.wt-case-head h2 { margin: 0; font-size: 15.5px; }
|
|
87
|
+
.wt-case-head .case-n { font: 500 12px var(--mono); color: var(--ink-3); }
|
|
88
|
+
.wt-case-note { margin: 0 0 8px; font-size: 13px; color: var(--ink-3); }
|
|
89
|
+
.wt-steps { list-style: none; margin: 0; padding: 0; }
|
|
90
|
+
.wt-step { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 12px; align-items: baseline; padding: 5px 0; color: var(--ink); }
|
|
91
|
+
.wt-pill { justify-self: start; display: inline-block; min-width: 58px; text-align: center; font: 600 12.5px/1.5 var(--mono); padding: 1px 8px; border-radius: 999px; background: var(--ink); color: var(--bg); text-decoration: none; }
|
|
92
|
+
a.wt-pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
|
93
|
+
.wt-pill.off { background: transparent; color: var(--ink-3); border: 1px dashed var(--rule-2); }
|
|
94
|
+
.wt-text { overflow-wrap: anywhere; }
|
|
95
|
+
.wt-text code { padding: 1px 5px; border-radius: 3px; background: var(--paper); }
|
|
96
|
+
.wt-state { font-size: 12px; color: var(--ink-3); margin-left: 6px; }
|
|
97
|
+
.wt-why { grid-column: 2; margin: 4px 0 2px; padding: 8px 12px; border-radius: 4px; background: var(--c-bg); color: var(--ink); box-shadow: inset 3px 0 0 var(--c); overflow-wrap: anywhere; white-space: pre-wrap; }
|
|
98
|
+
.wt-why .badge { margin-right: 6px; }
|
|
99
|
+
.wt.live .wt-step { color: var(--ink-3); }
|
|
100
|
+
.wt.live .wt-step .wt-pill:not(.off) { background: var(--rule); color: var(--ink-3); }
|
|
101
|
+
.wt.live .wt-step.on { color: var(--ink); }
|
|
102
|
+
.wt.live .wt-step.on .wt-pill:not(.off) { background: var(--ink); color: var(--bg); }
|
|
103
|
+
.wt.live .wt-step .wt-why { color: var(--ink); }
|
|
104
|
+
.wt.live .wt-case-head .case-n { color: var(--ink-3); }
|
|
105
|
+
.wt.live .wt-case.on .wt-case-head .case-n { color: var(--ink); font-weight: 700; }
|
|
106
|
+
@media (max-width: 680px) { .wt-step { grid-template-columns: 64px minmax(0, 1fr); gap: 8px; } }
|
|
107
|
+
`;
|
|
108
|
+
const playableSessions = (bundle) => (bundle.ledger.sessions ?? []).flatMap((session) => {
|
|
109
|
+
const src = safeRelative(session.video);
|
|
110
|
+
return src === undefined ? [] : [{ number: session.number, src }];
|
|
111
|
+
});
|
|
112
|
+
const sessionOf = (entry) => entry.session ?? 1;
|
|
113
|
+
/** A timecode pill: a link that seeks the player (or opens the video at that time without it). */
|
|
114
|
+
const pill = (sessions, session, ms, label) => {
|
|
115
|
+
if (ms === undefined)
|
|
116
|
+
return html `<span class="wt-pill off" aria-hidden="true">–</span>`;
|
|
117
|
+
const text = formatTimecode(ms);
|
|
118
|
+
const src = sessions.get(session);
|
|
119
|
+
if (src === undefined)
|
|
120
|
+
return html `<span class="wt-pill off">${text}</span>`;
|
|
121
|
+
const t = fragmentSeconds(ms);
|
|
122
|
+
return html `<a
|
|
123
|
+
class="wt-pill"
|
|
124
|
+
href="${`${src}#t=${t}`}"
|
|
125
|
+
data-s="${String(session)}"
|
|
126
|
+
data-t="${t}"
|
|
127
|
+
aria-label="${`Play from ${text}: ${label}`}"
|
|
128
|
+
>${text}</a
|
|
129
|
+
>`;
|
|
130
|
+
};
|
|
131
|
+
/** The mouse pointer drawn over the video; its tip is at (3, 2) of its 22 × 22 box. */
|
|
132
|
+
const cursorSvg = html `<div class="wt-cursor" id="wt-cursor" hidden>
|
|
133
|
+
<svg width="22" height="22" viewBox="0 0 22 22" aria-hidden="true">
|
|
134
|
+
<path
|
|
135
|
+
d="M3 2 L3 18.5 L7.2 14.6 L10 20.6 L12.9 19.3 L10.2 13.4 L16 13.4 Z"
|
|
136
|
+
fill="#fff"
|
|
137
|
+
stroke="#111"
|
|
138
|
+
stroke-width="1.4"
|
|
139
|
+
stroke-linejoin="round"
|
|
140
|
+
/>
|
|
141
|
+
</svg>
|
|
142
|
+
</div>`;
|
|
143
|
+
const fraction = (n) => String(Math.round(Math.max(0, Math.min(1, n)) * 10_000) / 10_000);
|
|
144
|
+
/**
|
|
145
|
+
* Where the element a step acted on was in the video, as shares of the frame, and when to draw
|
|
146
|
+
* it. Only from the viewport screenshot taken at the step (which is what the video shows), and
|
|
147
|
+
* only when its element was measured on it, and when (`targetAtMs`): the element Playwright
|
|
148
|
+
* acted on, located the same way. Never for a full-page screenshot, which the video does not show.
|
|
149
|
+
*/
|
|
150
|
+
export const stepBox = (entry, step) => {
|
|
151
|
+
const timing = step.timing;
|
|
152
|
+
if (timing === undefined)
|
|
153
|
+
return undefined;
|
|
154
|
+
const shot = (entry.shots ?? []).findLast((s) => s.kind === 'step' &&
|
|
155
|
+
s.step === step.index &&
|
|
156
|
+
!s.fullPage &&
|
|
157
|
+
s.target !== undefined &&
|
|
158
|
+
s.targetAtMs !== undefined &&
|
|
159
|
+
s.width > 0 &&
|
|
160
|
+
s.height > 0);
|
|
161
|
+
if (shot === undefined || shot.target === undefined || shot.targetAtMs === undefined)
|
|
162
|
+
return undefined;
|
|
163
|
+
const on = clampBox(shot.target, shot.width, shot.height);
|
|
164
|
+
if (on === undefined)
|
|
165
|
+
return undefined;
|
|
166
|
+
// When the box was measured, not when the image was taken: reading the page's frames and
|
|
167
|
+
// taking the image come after, and can take seconds. Older runs did not record it: no box.
|
|
168
|
+
const at = shot.targetAtMs;
|
|
169
|
+
const from = Math.max(timing.startMs, at - BOX_BEFORE_MS);
|
|
170
|
+
const to = Math.max(at, Math.min(timing.endMs, at + BOX_AFTER_MS));
|
|
171
|
+
return {
|
|
172
|
+
box: [on.x / shot.width, on.y / shot.height, on.width / shot.width, on.height / shot.height]
|
|
173
|
+
.map(fraction)
|
|
174
|
+
.join(' '),
|
|
175
|
+
from,
|
|
176
|
+
to,
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
/** An action's label over the video is cut to this many characters. */
|
|
180
|
+
export const ACTION_LABEL_MAX = 48;
|
|
181
|
+
const cut = (text, max) => text.length <= max ? text : `${text.slice(0, max - 1).trimEnd()}…`;
|
|
182
|
+
/**
|
|
183
|
+
* What a step did, in a few words for over the video, such as `Click "Save"`, `Type "Ada"` or
|
|
184
|
+
* `Press Enter`: the step's own wording (`stepParts`), with only the element's name or the value.
|
|
185
|
+
*/
|
|
186
|
+
export const actionLabel = (step) => {
|
|
187
|
+
const parts = stepParts(step);
|
|
188
|
+
const named = parts.filter((p) => p.kind !== 'text');
|
|
189
|
+
const quoted = (i) => {
|
|
190
|
+
const part = named.at(i);
|
|
191
|
+
if (part === undefined)
|
|
192
|
+
return undefined;
|
|
193
|
+
return part.kind === 'value' ? `"${cut(part.text, ACTION_LABEL_MAX - 8)}"` : part.text;
|
|
194
|
+
};
|
|
195
|
+
const words = (() => {
|
|
196
|
+
switch (step.action) {
|
|
197
|
+
case 'click':
|
|
198
|
+
return quoted(0) === undefined ? undefined : `Click ${quoted(0)}`;
|
|
199
|
+
case 'fill':
|
|
200
|
+
return step.value === ''
|
|
201
|
+
? quoted(0) === undefined
|
|
202
|
+
? undefined
|
|
203
|
+
: `Clear ${quoted(0)}`
|
|
204
|
+
: `Type ${quoted(-1)}`;
|
|
205
|
+
case 'upload':
|
|
206
|
+
return `Upload ${quoted(0)}`;
|
|
207
|
+
case 'press':
|
|
208
|
+
return `Press ${step.key}`;
|
|
209
|
+
case 'reload':
|
|
210
|
+
return 'Reload';
|
|
211
|
+
default:
|
|
212
|
+
return undefined;
|
|
213
|
+
}
|
|
214
|
+
})();
|
|
215
|
+
return cut(words ?? stepText(step), ACTION_LABEL_MAX);
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* An action drawn over the video, as data on its step for the page's script: when it happened
|
|
219
|
+
* (`at`), and as shares of the viewport (which is what the video shows) where the mouse pressed
|
|
220
|
+
* (`pt`, `x y`) and the element (`tb`, `x y width height`). An action whose input was not seen
|
|
221
|
+
* has no time, and so no point: its label shows while its step plays. Nothing from older runs,
|
|
222
|
+
* which did not record actions.
|
|
223
|
+
*/
|
|
224
|
+
export const stepAction = (action) => {
|
|
225
|
+
if (action === undefined)
|
|
226
|
+
return undefined;
|
|
227
|
+
const view = action.viewport;
|
|
228
|
+
const sized = view !== undefined && view.width > 0 && view.height > 0;
|
|
229
|
+
const point = sized && action.point !== undefined
|
|
230
|
+
? `${fraction(action.point.x / view.width)} ${fraction(action.point.y / view.height)}`
|
|
231
|
+
: undefined;
|
|
232
|
+
const on = sized && action.target !== undefined
|
|
233
|
+
? clampBox(action.target, view.width, view.height)
|
|
234
|
+
: undefined;
|
|
235
|
+
const target = on === undefined || !sized
|
|
236
|
+
? undefined
|
|
237
|
+
: [on.x / view.width, on.y / view.height, on.width / view.width, on.height / view.height]
|
|
238
|
+
.map(fraction)
|
|
239
|
+
.join(' ');
|
|
240
|
+
// A point is drawn only at the time it was pressed.
|
|
241
|
+
if (action.atMs === undefined)
|
|
242
|
+
return target !== undefined ? { tb: target } : {};
|
|
243
|
+
return {
|
|
244
|
+
at: fragmentSeconds(action.atMs),
|
|
245
|
+
...(point !== undefined ? { pt: point } : {}),
|
|
246
|
+
...(target !== undefined ? { tb: target } : {}),
|
|
247
|
+
};
|
|
248
|
+
};
|
|
249
|
+
const stepLabel = (step) => (step.index === 0 ? 'Opening page' : `Step ${step.index}`);
|
|
250
|
+
const notRun = { 'not-run': 'not run', unknown: '', done: '', decided: '' };
|
|
251
|
+
const stepRow = (view, step, sessions) => {
|
|
252
|
+
const { entry } = view;
|
|
253
|
+
const session = sessionOf(entry);
|
|
254
|
+
const parts = stepParts(step.step);
|
|
255
|
+
const plain = parts.map((p) => p.text).join('');
|
|
256
|
+
const ms = step.timing?.startMs;
|
|
257
|
+
const timed = ms !== undefined && sessions.has(session);
|
|
258
|
+
const box = timed ? stepBox(entry, step) : undefined;
|
|
259
|
+
const acted = timed ? stepAction(step.timing?.action) : undefined;
|
|
260
|
+
// A fill records no element of its own (its input is not watched): its ring is the step's box,
|
|
261
|
+
// drawn when that is, from the screenshot taken at the step.
|
|
262
|
+
const action = acted !== undefined && acted.tb === undefined && step.timing?.action?.kind === 'fill' && box
|
|
263
|
+
? { ...acted, tb: box.box }
|
|
264
|
+
: acted;
|
|
265
|
+
const decided = step.state === 'decided';
|
|
266
|
+
return html `<li
|
|
267
|
+
class="wt-step st-${step.state}${decided ? ` s-${entry.status}` : ''}"
|
|
268
|
+
id="${`wt-${entry.id}-${step.index}`}"
|
|
269
|
+
${timed ? html ` data-s="${String(session)}" data-t="${fragmentSeconds(ms)}"` : ''}
|
|
270
|
+
${box
|
|
271
|
+
? html ` data-box="${box.box}" data-b0="${fragmentSeconds(box.from)}"
|
|
272
|
+
data-b1="${fragmentSeconds(box.to)}" data-label="${stepLabel(step)}"`
|
|
273
|
+
: ''}
|
|
274
|
+
${action && step.timing
|
|
275
|
+
? html ` data-act="${step.timing.action?.kind ?? ''}"${action.at ? html ` data-at="${action.at}"` : ''}
|
|
276
|
+
data-a1="${fragmentSeconds(step.timing.endMs)}" data-al="${actionLabel(step.step)}"
|
|
277
|
+
${action.pt ? html ` data-pt="${action.pt}"` : ''}${action.tb ? html ` data-tb="${action.tb}"` : ''}`
|
|
278
|
+
: ''}
|
|
279
|
+
>
|
|
280
|
+
${pill(sessions, session, ms, plain)}
|
|
281
|
+
<span class="wt-text"
|
|
282
|
+
>${textParts(parts)}${step.implicit
|
|
283
|
+
? html ` <span class="wt-state">(added: every case starts at the job URL)</span>`
|
|
284
|
+
: ''}${notRun[step.state] ? html ` <span class="wt-state">(${notRun[step.state]})</span>` : ''}</span
|
|
285
|
+
>
|
|
286
|
+
${decided && entry.reason ? html `<p class="wt-why">${badge(entry.status)}${entry.reason}</p>` : ''}
|
|
287
|
+
</li>`;
|
|
288
|
+
};
|
|
289
|
+
const caseBlock = (view, position, sessions) => {
|
|
290
|
+
const { entry } = view;
|
|
291
|
+
const session = sessionOf(entry);
|
|
292
|
+
const decidedShown = view.steps.some((s) => s.state === 'decided');
|
|
293
|
+
const why = entry.reason && !decidedShown
|
|
294
|
+
? html `<p class="wt-why wt-case-why s-${entry.status}">
|
|
295
|
+
${badge(entry.status)}${entry.reason}
|
|
296
|
+
</p>`
|
|
297
|
+
: '';
|
|
298
|
+
const timedButNoVideo = view.steps.some((s) => s.timing !== undefined) && !sessions.has(session)
|
|
299
|
+
? html `<p class="wt-case-note">
|
|
300
|
+
Session ${session} has no video, so these times cannot be played.
|
|
301
|
+
</p>`
|
|
302
|
+
: '';
|
|
303
|
+
return html `<li class="wt-case s-${entry.status}" id="${`wt-${entry.id}`}">
|
|
304
|
+
<div class="wt-case-head">
|
|
305
|
+
<span class="case-n">${String(position).padStart(2, '0')}</span>
|
|
306
|
+
<h2>${entry.title}</h2>
|
|
307
|
+
${badge(entry.status)} ${pill(sessions, session, entry.startMs, `case ${entry.title}`)}
|
|
308
|
+
</div>
|
|
309
|
+
${timedButNoVideo}${why}
|
|
310
|
+
${view.steps.length > 0
|
|
311
|
+
? html `<ol class="wt-steps">
|
|
312
|
+
${view.steps.map((step) => stepRow(view, step, sessions))}
|
|
313
|
+
</ol>`
|
|
314
|
+
: html `<p class="wt-case-note">No steps recorded for this case.</p>`}
|
|
315
|
+
</li>`;
|
|
316
|
+
};
|
|
317
|
+
/** Cases that did not pass, each with a link to where it was decided. */
|
|
318
|
+
const problemsBlock = (views, sessions) => {
|
|
319
|
+
const failing = views.filter((v) => v.entry.status !== 'passed');
|
|
320
|
+
if (failing.length === 0)
|
|
321
|
+
return '';
|
|
322
|
+
return html `<section class="wt-problems" aria-labelledby="wt-problems-title">
|
|
323
|
+
<h2 id="wt-problems-title" class="label">Did not pass</h2>
|
|
324
|
+
<ul>
|
|
325
|
+
${failing.map((view) => {
|
|
326
|
+
const { entry } = view;
|
|
327
|
+
const decided = view.steps.find((s) => s.state === 'decided');
|
|
328
|
+
const ms = decided?.timing?.startMs ?? entry.startMs;
|
|
329
|
+
const at = ms !== undefined && sessions.has(sessionOf(entry))
|
|
330
|
+
? pill(sessions, sessionOf(entry), ms, `where case ${entry.title} was decided`)
|
|
331
|
+
: html `<a class="wt-pill off" href="${`#wt-${entry.id}`}"
|
|
332
|
+
>${ms !== undefined ? formatTimecode(ms) : 'see'}</a
|
|
333
|
+
>`;
|
|
334
|
+
return html `<li class="s-${entry.status}">
|
|
335
|
+
${at}${badge(entry.status)}<span class="why"
|
|
336
|
+
><a href="${`#wt-${entry.id}`}">${entry.title}</a>${entry.reason ? html `: ${entry.reason}` : ''}</span
|
|
337
|
+
>
|
|
338
|
+
</li>`;
|
|
339
|
+
})}
|
|
340
|
+
</ul>
|
|
341
|
+
</section>`;
|
|
342
|
+
};
|
|
343
|
+
/**
|
|
344
|
+
* The run's walkthrough as a self-contained page, written next to its `report.html`: inline CSS,
|
|
345
|
+
* one inline script, no fonts or network. Code decides everything on it; nothing from the agent's
|
|
346
|
+
* write-up is shown. Every piece of text from the job or the page is escaped.
|
|
347
|
+
*/
|
|
348
|
+
export const renderWalkthrough = (bundle) => {
|
|
349
|
+
const { spec, ledger } = bundle;
|
|
350
|
+
const views = caseViews(bundle);
|
|
351
|
+
const playable = playableSessions(bundle);
|
|
352
|
+
const sessions = new Map(playable.map((p) => [p.number, p.src]));
|
|
353
|
+
const first = playable.find((p) => ledger.cases.some((c) => sessionOf(c) === p.number && c.startMs !== undefined)) ?? playable[0];
|
|
354
|
+
const timed = ledger.cases.some((c) => (c.steps ?? []).length > 0);
|
|
355
|
+
const host = URL.canParse(spec.url) ? new URL(spec.url).host : spec.url;
|
|
356
|
+
const report = safeRelative(bundle.files.html) ?? runFiles.html;
|
|
357
|
+
const passed = ledger.cases.filter((c) => c.status === 'passed').length;
|
|
358
|
+
const missingVideo = (ledger.sessions ?? []).filter((s) => s.videoProblem || !s.video);
|
|
359
|
+
const player = first === undefined
|
|
360
|
+
? html `<p class="wt-novideo" role="note">
|
|
361
|
+
<strong>This run has no video</strong>, so the times below cannot be played. The steps and
|
|
362
|
+
results are still listed.
|
|
363
|
+
</p>`
|
|
364
|
+
: html `<figure class="wt-player">
|
|
365
|
+
<div class="wt-screen">
|
|
366
|
+
<video
|
|
367
|
+
id="wt-video"
|
|
368
|
+
controls
|
|
369
|
+
preload="metadata"
|
|
370
|
+
playsinline
|
|
371
|
+
data-session="${String(first.number)}"
|
|
372
|
+
src="${first.src}"
|
|
373
|
+
></video>
|
|
374
|
+
<div class="wt-box" id="wt-box" hidden><span></span></div>
|
|
375
|
+
<div class="wt-ring" id="wt-ring" hidden></div>
|
|
376
|
+
<div class="wt-ripple" id="wt-ripple" hidden></div>
|
|
377
|
+
${cursorSvg}
|
|
378
|
+
<span class="wt-act" id="wt-act" hidden></span>
|
|
379
|
+
</div>
|
|
380
|
+
<div class="wt-controls">
|
|
381
|
+
<label id="wt-cursor-toggle" hidden
|
|
382
|
+
><input type="checkbox" id="wt-cursor-on" checked /> Show cursor</label
|
|
383
|
+
>
|
|
384
|
+
</div>
|
|
385
|
+
<p class="unloaded" id="wt-unloaded" hidden>
|
|
386
|
+
<strong>Video didn't load:</strong> <a href="${first.src}">${first.src}</a>. Open this
|
|
387
|
+
page from its run folder in a browser, or open the file directly.
|
|
388
|
+
</p>
|
|
389
|
+
<ul hidden>
|
|
390
|
+
${playable.map((p) => html `<li data-session="${String(p.number)}" data-session-src="${p.src}">
|
|
391
|
+
${p.src}
|
|
392
|
+
</li>`)}
|
|
393
|
+
</ul>
|
|
394
|
+
${playable.length > 1
|
|
395
|
+
? html `<figcaption class="note">
|
|
396
|
+
${playable.length} session videos; the player moves on to the next when one ends.
|
|
397
|
+
</figcaption>`
|
|
398
|
+
: ''}
|
|
399
|
+
</figure>`;
|
|
400
|
+
const page = html `<!doctype html>
|
|
401
|
+
<html lang="en">
|
|
402
|
+
<head>
|
|
403
|
+
<meta charset="utf-8" />
|
|
404
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
405
|
+
<meta name="color-scheme" content="light dark" />
|
|
406
|
+
<meta http-equiv="Content-Security-Policy" content="${WALKTHROUGH_CSP}" />
|
|
407
|
+
<title>${`Walkthrough · screw-bugs ${bundle.jobId}`}</title>
|
|
408
|
+
<style>
|
|
409
|
+
${new Markup(styles + walkthroughStyles)}
|
|
410
|
+
</style>
|
|
411
|
+
</head>
|
|
412
|
+
<body>
|
|
413
|
+
${scriptTag}
|
|
414
|
+
<div class="${`page wt device-${bundle.device.kind}`}">
|
|
415
|
+
<header class="masthead">
|
|
416
|
+
<span class="brand">screw-bugs <span class="brand-sub">walkthrough</span></span>
|
|
417
|
+
<span class="job"><code>${bundle.jobId}</code></span>
|
|
418
|
+
<a class="wt-report" href="${report}">Full report</a>
|
|
419
|
+
${themeSwitch}
|
|
420
|
+
</header>
|
|
421
|
+
<div class="wt-top">
|
|
422
|
+
<h1>
|
|
423
|
+
${`${passed} of ${ledger.cases.length} ${ledger.cases.length === 1 ? 'case' : 'cases'} passed`}
|
|
424
|
+
</h1>
|
|
425
|
+
<p class="kicker">${host} · ${bundle.device.label} · ${formatTime(bundle.startedAt)}</p>
|
|
426
|
+
</div>
|
|
427
|
+
${ledger.error
|
|
428
|
+
? html `<div class="alert" role="note">
|
|
429
|
+
<strong>The run stopped early.</strong> ${ledger.error}
|
|
430
|
+
</div>`
|
|
431
|
+
: ''}
|
|
432
|
+
${problemsBlock(views, sessions)} ${player}
|
|
433
|
+
${first !== undefined && !timed
|
|
434
|
+
? html `<p class="wt-novideo" role="note">
|
|
435
|
+
This run recorded no step times, so the steps below cannot be played from here.
|
|
436
|
+
</p>`
|
|
437
|
+
: ''}
|
|
438
|
+
${first !== undefined && missingVideo.length > 0
|
|
439
|
+
? html `<p class="wt-case-note">
|
|
440
|
+
${missingVideo.map((s) => html `Session ${s.number}: video missing or
|
|
441
|
+
incomplete${s.videoProblem ? `: ${s.videoProblem}` : '.'} `)}
|
|
442
|
+
</p>`
|
|
443
|
+
: ''}
|
|
444
|
+
<h2 class="label" id="wt-script-title">Script ${icon('chip')} decided by code</h2>
|
|
445
|
+
<ol class="wt-script" id="wt-script" aria-labelledby="wt-script-title">
|
|
446
|
+
${views.map((view, i) => caseBlock(view, i + 1, sessions))}
|
|
447
|
+
</ol>
|
|
448
|
+
<p class="foot">
|
|
449
|
+
Statuses decided by code in a real browser. Boxes over the video mark the element a step
|
|
450
|
+
acted on, measured as it ran; none is drawn where it was not measured. The cursor,
|
|
451
|
+
clicks and labels over it are drawn here from where each action was recorded; they are
|
|
452
|
+
not in the video itself.
|
|
453
|
+
</p>
|
|
454
|
+
</div>
|
|
455
|
+
</body>
|
|
456
|
+
</html> `;
|
|
457
|
+
return page.value;
|
|
458
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
|
+
/** Project config, committed as `screw-bugs.json` at the project root. */
|
|
3
|
+
export declare const ProjectConfig: Schema.Struct<{
|
|
4
|
+
readonly version: Schema.Literal<1>;
|
|
5
|
+
readonly baseUrl: Schema.optionalKey<Schema.NonEmptyString>;
|
|
6
|
+
}>;
|
|
7
|
+
export type ProjectConfig = typeof ProjectConfig.Type;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
|
+
export declare const DoctorCheckId: Schema.Literals<readonly ["node", "browser", "video", "disk", "update"]>;
|
|
3
|
+
export type DoctorCheckId = typeof DoctorCheckId.Type;
|
|
4
|
+
/** How to fix a failed check. Doctor only suggests; it never runs the command itself. */
|
|
5
|
+
export declare const DoctorFix: Schema.Struct<{
|
|
6
|
+
/** What to do, in plain language. */
|
|
7
|
+
readonly action: Schema.String;
|
|
8
|
+
/** The command to run, when there is one. */
|
|
9
|
+
readonly command: Schema.optionalKey<Schema.String>;
|
|
10
|
+
readonly why: Schema.String;
|
|
11
|
+
}>;
|
|
12
|
+
export type DoctorFix = typeof DoctorFix.Type;
|
|
13
|
+
export declare const DoctorCheck: Schema.Struct<{
|
|
14
|
+
readonly id: Schema.Literals<readonly ["node", "browser", "video", "disk", "update"]>;
|
|
15
|
+
readonly ok: Schema.Boolean;
|
|
16
|
+
readonly detail: Schema.String;
|
|
17
|
+
readonly fix: Schema.optionalKey<Schema.Struct<{
|
|
18
|
+
/** What to do, in plain language. */
|
|
19
|
+
readonly action: Schema.String;
|
|
20
|
+
/** The command to run, when there is one. */
|
|
21
|
+
readonly command: Schema.optionalKey<Schema.String>;
|
|
22
|
+
readonly why: Schema.String;
|
|
23
|
+
}>>;
|
|
24
|
+
/** A failed warning does not make the report fail: screw-bugs still runs, with less. */
|
|
25
|
+
readonly severity: Schema.optionalKey<Schema.Literal<"warning">>;
|
|
26
|
+
}>;
|
|
27
|
+
export type DoctorCheck = typeof DoctorCheck.Type;
|
|
28
|
+
export declare const DoctorReport: Schema.Struct<{
|
|
29
|
+
/** True when every check is ok or only a warning. */
|
|
30
|
+
readonly ok: Schema.Boolean;
|
|
31
|
+
readonly checks: Schema.$Array<Schema.Struct<{
|
|
32
|
+
readonly id: Schema.Literals<readonly ["node", "browser", "video", "disk", "update"]>;
|
|
33
|
+
readonly ok: Schema.Boolean;
|
|
34
|
+
readonly detail: Schema.String;
|
|
35
|
+
readonly fix: Schema.optionalKey<Schema.Struct<{
|
|
36
|
+
/** What to do, in plain language. */
|
|
37
|
+
readonly action: Schema.String;
|
|
38
|
+
/** The command to run, when there is one. */
|
|
39
|
+
readonly command: Schema.optionalKey<Schema.String>;
|
|
40
|
+
readonly why: Schema.String;
|
|
41
|
+
}>>;
|
|
42
|
+
/** A failed warning does not make the report fail: screw-bugs still runs, with less. */
|
|
43
|
+
readonly severity: Schema.optionalKey<Schema.Literal<"warning">>;
|
|
44
|
+
}>>;
|
|
45
|
+
}>;
|
|
46
|
+
export type DoctorReport = typeof DoctorReport.Type;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
|
+
export const DoctorCheckId = Schema.Literals(['node', 'browser', 'video', 'disk', 'update']);
|
|
3
|
+
/** How to fix a failed check. Doctor only suggests; it never runs the command itself. */
|
|
4
|
+
export const DoctorFix = Schema.Struct({
|
|
5
|
+
/** What to do, in plain language. */
|
|
6
|
+
action: Schema.String,
|
|
7
|
+
/** The command to run, when there is one. */
|
|
8
|
+
command: Schema.optionalKey(Schema.String),
|
|
9
|
+
why: Schema.String,
|
|
10
|
+
});
|
|
11
|
+
export const DoctorCheck = Schema.Struct({
|
|
12
|
+
id: DoctorCheckId,
|
|
13
|
+
ok: Schema.Boolean,
|
|
14
|
+
detail: Schema.String,
|
|
15
|
+
fix: Schema.optionalKey(DoctorFix),
|
|
16
|
+
/** A failed warning does not make the report fail: screw-bugs still runs, with less. */
|
|
17
|
+
severity: Schema.optionalKey(Schema.Literal('warning')),
|
|
18
|
+
});
|
|
19
|
+
export const DoctorReport = Schema.Struct({
|
|
20
|
+
/** True when every check is ok or only a warning. */
|
|
21
|
+
ok: Schema.Boolean,
|
|
22
|
+
checks: Schema.Array(DoctorCheck),
|
|
23
|
+
});
|