screw-bugs 0.1.9 → 0.1.11
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 +100 -54
- package/dist/browser-playwright/capture.js +1 -1
- package/dist/build-info.json +3 -3
- package/dist/cli/app.js +6 -2
- package/dist/cli/commands.js +4 -3
- package/dist/cli/doctor.d.ts +17 -2
- package/dist/cli/doctor.js +62 -4
- package/dist/cli/mcp.js +7 -4
- package/dist/cli/report-server.d.ts +19 -10
- package/dist/cli/report-server.js +43 -18
- package/dist/cli/share.js +2 -2
- package/dist/cli/sign-in.d.ts +9 -3
- package/dist/cli/sign-in.js +12 -9
- package/dist/cli/tailnet.d.ts +57 -0
- package/dist/cli/tailnet.js +82 -0
- package/dist/core/index.d.ts +1 -14
- package/dist/core/index.js +3 -14
- package/dist/report/index.d.ts +1 -10
- package/dist/report/index.js +3 -10
- package/dist/schema/index.d.ts +1 -9
- package/dist/schema/index.js +3 -9
- package/package.json +14 -14
- package/dist/core/accounts.d.ts +0 -40
- package/dist/core/accounts.js +0 -95
- package/dist/core/css.d.ts +0 -95
- package/dist/core/css.js +0 -436
- package/dist/core/engine.d.ts +0 -75
- package/dist/core/engine.js +0 -560
- package/dist/core/errors.d.ts +0 -85
- package/dist/core/errors.js +0 -36
- package/dist/core/evidence.d.ts +0 -14
- package/dist/core/evidence.js +0 -131
- package/dist/core/labels.d.ts +0 -47
- package/dist/core/labels.js +0 -199
- package/dist/core/liveness.d.ts +0 -45
- package/dist/core/liveness.js +0 -66
- package/dist/core/marks.d.ts +0 -63
- package/dist/core/marks.js +0 -410
- package/dist/core/services.d.ts +0 -579
- package/dist/core/services.js +0 -25
- package/dist/core/share.d.ts +0 -68
- package/dist/core/share.js +0 -318
- package/dist/core/steps.d.ts +0 -106
- package/dist/core/steps.js +0 -722
- package/dist/core/uploads.d.ts +0 -49
- package/dist/core/uploads.js +0 -133
- package/dist/core/video.d.ts +0 -53
- package/dist/core/video.js +0 -241
- package/dist/core/viewport.d.ts +0 -28
- package/dist/core/viewport.js +0 -50
- package/dist/report/assets.d.ts +0 -34
- package/dist/report/assets.js +0 -105
- package/dist/report/bug.d.ts +0 -11
- package/dist/report/bug.js +0 -20
- package/dist/report/html.d.ts +0 -47
- package/dist/report/html.js +0 -923
- package/dist/report/icons.d.ts +0 -51
- package/dist/report/icons.js +0 -93
- package/dist/report/live.d.ts +0 -7
- package/dist/report/live.js +0 -135
- package/dist/report/logos.d.ts +0 -4
- package/dist/report/logos.js +0 -19
- package/dist/report/markup.d.ts +0 -50
- package/dist/report/markup.js +0 -156
- package/dist/report/menu-bar.d.ts +0 -60
- package/dist/report/menu-bar.js +0 -157
- package/dist/report/player.d.ts +0 -102
- package/dist/report/player.js +0 -315
- package/dist/report/pr-summary.d.ts +0 -11
- package/dist/report/pr-summary.js +0 -119
- package/dist/report/sha256.d.ts +0 -9
- package/dist/report/sha256.js +0 -97
- package/dist/report/share-page.d.ts +0 -48
- package/dist/report/share-page.js +0 -291
- package/dist/report/shots.d.ts +0 -59
- package/dist/report/shots.js +0 -280
- package/dist/report/sign-in.d.ts +0 -41
- package/dist/report/sign-in.js +0 -568
- package/dist/report/styles.d.ts +0 -3
- package/dist/report/styles.js +0 -274
- package/dist/report/view.d.ts +0 -296
- package/dist/report/view.js +0 -702
- package/dist/report/walkthrough.d.ts +0 -93
- package/dist/report/walkthrough.js +0 -716
- package/dist/schema/accounts.d.ts +0 -137
- package/dist/schema/accounts.js +0 -121
- package/dist/schema/config.d.ts +0 -7
- package/dist/schema/config.js +0 -6
- package/dist/schema/doctor.d.ts +0 -46
- package/dist/schema/doctor.js +0 -30
- package/dist/schema/evidence.d.ts +0 -1115
- package/dist/schema/evidence.js +0 -565
- package/dist/schema/findings.d.ts +0 -161
- package/dist/schema/findings.js +0 -82
- package/dist/schema/job.d.ts +0 -1905
- package/dist/schema/job.js +0 -577
- package/dist/schema/ledger.d.ts +0 -1124
- package/dist/schema/ledger.js +0 -285
- package/dist/schema/share.d.ts +0 -55
- package/dist/schema/share.js +0 -64
- package/dist/schema/status.d.ts +0 -7
- package/dist/schema/status.js +0 -11
|
@@ -1,716 +0,0 @@
|
|
|
1
|
-
import { clampBox } from '../core/index.js';
|
|
2
|
-
import { runFiles, } from '../schema/index.js';
|
|
3
|
-
import { favicon, generatorMeta, html, icon, Markup, promptBlock, safeRelative, statusIcon, statusTag, textParts, webFonts, } from './markup.js';
|
|
4
|
-
import { controlsBlock, PLAYER_JS, playableSessions, playerWindow, shapeStyle, share, toggleButton, videoFixPrompt, } from './player.js';
|
|
5
|
-
import { assetsOf, contentPolicy } from './assets.js';
|
|
6
|
-
import { topBar } from './menu-bar.js';
|
|
7
|
-
import { cspHash } from './sha256.js';
|
|
8
|
-
import { styles } from './styles.js';
|
|
9
|
-
import { caseViews, checksNote, formatTimecode, fragmentSeconds, idleStretches, stepParts, stepText, statusLabel, urlAt, urlTimeline, } from './view.js';
|
|
10
|
-
/*
|
|
11
|
-
* The walkthrough: one player for the run's video, and under it (beside it, for a run on a phone)
|
|
12
|
-
* the script: every step of every case in run order with its timecode. The step playing now is the
|
|
13
|
-
* script's top row, highlighted; any timecode or row seeks the player there (switching to its
|
|
14
|
-
* session's video), playing on if it was playing and staying paused if not. Cases that did not pass say why at the step that decided them, in
|
|
15
|
-
* the report's words. Like the report it loads only its fonts from the network (Google Fonts) and
|
|
16
|
-
* links the video by relative path.
|
|
17
|
-
*/
|
|
18
|
-
/**
|
|
19
|
-
* How long around the moment a step's element was measured its box is drawn over the video, in
|
|
20
|
-
* ms: a little before (the element was already there while the step waited on it) and after.
|
|
21
|
-
* Outside this the page may have moved on, so no box is drawn.
|
|
22
|
-
*/
|
|
23
|
-
export const BOX_BEFORE_MS = 700;
|
|
24
|
-
export const BOX_AFTER_MS = 1200;
|
|
25
|
-
/** Seconds the cursor takes, at most, to glide to the next point the mouse pressed. */
|
|
26
|
-
export const GLIDE_S = 0.6;
|
|
27
|
-
/**
|
|
28
|
-
* The page's one script, allowed by its hash in the Content Security Policy. On top of the shared
|
|
29
|
-
* player (see `PLAYER_JS`), it tells the stage where it starts (`--wt-y` on the page, `--wt-top`
|
|
30
|
-
* in the view) as the page scrolls or changes size, so the player and its controls fit on screen
|
|
31
|
-
* together; it marks the step playing now (the last step of the video's session
|
|
32
|
-
* whose time is at or before the player's) and makes it the script's top row (without motion when
|
|
33
|
-
* the reader prefers less; the top row that shows, below the top bar and, on a narrow screen, the
|
|
34
|
-
* pinned player and its fade, when the page has scrolled the script under them), draws the box of the element it acted on over the video while that was
|
|
35
|
-
* measured, makes timecodes and rows seek (and switch session videos) instead of opening the file,
|
|
36
|
-
* and, with "Skip inactive" on (remembered like the theme), jumps over the stretches where
|
|
37
|
-
* nothing happened (`idleStretches`) while it plays.
|
|
38
|
-
* "Expand" shows the whole script and makes the video smaller. Fullscreen takes the whole page
|
|
39
|
-
* (`.wt`), not only the video; on a wide screen (a desktop) it never takes the browser's screen,
|
|
40
|
-
* 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
|
|
41
|
-
* the step playing now as a caption under it, and the controls; the prompt and the script are left
|
|
42
|
-
* out. A session video that does not load
|
|
43
|
-
* is remembered as broken on its own (see `PLAYER_JS`). Without script, timecodes open the video
|
|
44
|
-
* file at their time, and every step reads in full contrast.
|
|
45
|
-
*
|
|
46
|
-
* Over the video it also draws, from each step's recorded action (`stepAction`) and only for the
|
|
47
|
-
* session playing, what the mouse and keyboard did: a cursor that shows from the first point the
|
|
48
|
-
* mouse pressed, glides to each next one (eased, over at most `GLIDE_S` before it) and rests
|
|
49
|
-
* there, a ripple where and when it pressed, a ring in place of the step's box around a field
|
|
50
|
-
* typed into (when that box shows: a fill records no time or element of its own), and a short
|
|
51
|
-
* label of the action (the latest one that happened, else the one the cursor is gliding to; the
|
|
52
|
-
* box's own label gives way to it; one whose time was not recorded is labelled while its step
|
|
53
|
-
* plays, and has no cursor or ripple). A hover moves the mouse but records no point (see
|
|
54
|
-
* `StepAction.atMs`), so from when its step starts (any hover step that ran, also one that failed
|
|
55
|
-
* or was blocked, which may have moved the mouse all the same; its row's `data-hv`) the cursor is
|
|
56
|
-
* hidden until the next point the mouse pressed, rather than shown where the mouse no longer is. All of it follows the player's time, so seeking or pausing
|
|
57
|
-
* shows the state at that moment. With less motion preferred, the cursor jumps instead of gliding
|
|
58
|
-
* and there is no ripple. A "Cursor" switch turns it off, remembered like the theme. Nothing is
|
|
59
|
-
* added to the page under test or to the video.
|
|
60
|
-
*/
|
|
61
|
-
export const WALKTHROUGH_SCRIPT = `(()=>{${PLAYER_JS}
|
|
62
|
-
d.addEventListener('DOMContentLoaded',()=>{
|
|
63
|
-
chrome();
|
|
64
|
-
const stg=d.querySelector('.wt-stage');let fr=0;
|
|
65
|
-
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')};
|
|
66
|
-
const refit=()=>{if(!fr)fr=requestAnimationFrame(fit)};
|
|
67
|
-
fit();addEventListener('resize',refit);addEventListener('load',refit);addEventListener('scroll',refit,{passive:true});d.addEventListener('fullscreenchange',refit);
|
|
68
|
-
if(window.ResizeObserver)new ResizeObserver(refit).observe(d.body);
|
|
69
|
-
const v=d.getElementById('wt-video');if(!v)return;
|
|
70
|
-
const w=d.querySelector('.wt'),panel=d.getElementById('wt-script'),box=d.getElementById('wt-box'),cap=d.getElementById('wt-cap');
|
|
71
|
-
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};
|
|
72
|
-
const steps=[...d.querySelectorAll('.wt-step[data-t]')];
|
|
73
|
-
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)}));
|
|
74
|
-
const skipB=d.getElementById('wt-skip'),expB=d.getElementById('wt-expand');
|
|
75
|
-
let on=null,skip=!!skipB,P=null;const sk='screw-bugs-skip';try{skip=skip&&localStorage.getItem(sk)!=='off'}catch(e){}if(skipB)skipB.setAttribute('aria-pressed',String(skip));
|
|
76
|
-
w.classList.add('live');
|
|
77
|
-
const hide=()=>{box.hidden=true};
|
|
78
|
-
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}};
|
|
79
|
-
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'}};
|
|
80
|
-
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};
|
|
81
|
-
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';
|
|
82
|
-
const nums=x=>x?x.split(' ').map(Number):null;
|
|
83
|
-
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));
|
|
84
|
-
const hv=[...d.querySelectorAll('.wt-step[data-hv][data-s]')].map(e=>({s:e.dataset.s,t0:Number(e.dataset.t)}));
|
|
85
|
-
let fon=true;try{fon=localStorage.getItem(ck)!=='off'}catch(e){}
|
|
86
|
-
const fx=(t,g)=>{
|
|
87
|
-
C.hidden=R.hidden=G.hidden=L.hidden=true;box.querySelector('span').hidden=false;
|
|
88
|
-
if(!fon||P.down()!==null||!g)return;
|
|
89
|
-
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];
|
|
90
|
-
let i=-1;ptr.forEach((a,j)=>{if(a.at<=t)i=j});
|
|
91
|
-
const a=ptr[i],n=ptr[i+1];let c=a?a.p:null;
|
|
92
|
-
if(n&&a){const gw=Math.min(${GLIDE_S},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}}
|
|
93
|
-
if(a&&hv.some(x=>x.s===P.cur()&&x.t0>a.at&&x.t0<=t))c=null;
|
|
94
|
-
if(c){const xy0=xy(c);put(C,xy0[0]-3,xy0[1]-2);C.hidden=false}
|
|
95
|
-
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}
|
|
96
|
-
let f=null,l=null,u=null;
|
|
97
|
-
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<=${GLIDE_S})u=x}
|
|
98
|
-
l=l||u;
|
|
99
|
-
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}
|
|
100
|
-
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))}
|
|
101
|
-
box.querySelector('span').hidden=!L.hidden;
|
|
102
|
-
};
|
|
103
|
-
const stage=d.querySelector('.wt-stage');
|
|
104
|
-
const cover=()=>{let y=topEdge();if(stage&&getComputedStyle(stage).position==='sticky')y=Math.max(y,stage.getBoundingClientRect().bottom+16);return y};
|
|
105
|
-
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'})};
|
|
106
|
-
const tick=t=>{
|
|
107
|
-
const cur=P.cur();
|
|
108
|
-
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}}
|
|
109
|
-
let a=null;for(const s of steps){if(s.dataset.s===cur&&Number(s.dataset.t)<=t+0.02)a=s}
|
|
110
|
-
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)}}
|
|
111
|
-
const g=geo();draw(t,g);fx(t,g);
|
|
112
|
-
};
|
|
113
|
-
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')}});
|
|
114
|
-
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()})}
|
|
115
|
-
if(skipB)skipB.addEventListener('click',()=>{skip=!skip;skipB.setAttribute('aria-pressed',String(skip));try{localStorage.setItem(sk,skip?'on':'off')}catch(e){}});
|
|
116
|
-
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)});
|
|
117
|
-
d.addEventListener('click',e=>{
|
|
118
|
-
const t=e.target;if(!(t instanceof Element))return;
|
|
119
|
-
const a=t.closest('a[data-t][data-s],.wt-step[data-t][data-s]');if(!a||!P.has(a.dataset.s))return;
|
|
120
|
-
e.preventDefault();const fig=v.closest('.player');
|
|
121
|
-
if(fig.getBoundingClientRect().bottom<topEdge())fig.scrollIntoView({block:'start',behavior:still()?'auto':'smooth'});
|
|
122
|
-
P.load(a.dataset.s,Number(a.dataset.t),P.playing());
|
|
123
|
-
});
|
|
124
|
-
P.update();
|
|
125
|
-
});
|
|
126
|
-
})();`;
|
|
127
|
-
const scriptTag = new Markup(`<script>${WALKTHROUGH_SCRIPT}</script>`);
|
|
128
|
-
/**
|
|
129
|
-
* As the report's: the video by relative path, one script by hash, and from the network only
|
|
130
|
-
* Google Fonts' stylesheet and its fonts.
|
|
131
|
-
*/
|
|
132
|
-
export const WALKTHROUGH_CSP = contentPolicy(cspHash(WALKTHROUGH_SCRIPT));
|
|
133
|
-
/** The walkthrough's policy when its files load from `assetOrigin` (see `RenderOptions`). */
|
|
134
|
-
export const walkthroughCsp = (assetOrigin) => contentPolicy(cspHash(WALKTHROUGH_SCRIPT), assetOrigin);
|
|
135
|
-
const walkthroughStyles = /* css */ `
|
|
136
|
-
.wt { max-width: 1440px; margin: 0 auto; padding-bottom: 56px; }
|
|
137
|
-
.wt > .prompt { margin-top: 8px; padding: 0 32px; }
|
|
138
|
-
.wt .alert { max-width: 760px; margin: 18px auto 0; padding: 12px 16px; border: 1px solid var(--fail); border-radius: 12px; background: var(--bg-2); overflow-wrap: anywhere; }
|
|
139
|
-
.wt .alert strong { color: var(--fail-text); }
|
|
140
|
-
.wt-main { display: grid; justify-items: center; gap: 28px; padding: 22px 32px 0; }
|
|
141
|
-
/* The player and its controls fit on screen together below where the stage starts (\`--wt-y\` on
|
|
142
|
-
the page, set by the page's script; pinned on a phone, \`--wt-top\` in the view), as the
|
|
143
|
-
report's player does (see its \`.rp-sticky\`): the player shrinks to what is left, its window
|
|
144
|
-
at the recording's shape. \`--win-cap\` is the widest the window may be, \`--player-cap\` the
|
|
145
|
-
tallest the player may be. */
|
|
146
|
-
.wt-stage { --fit-top: var(--wt-y, 160px); --fit-gap: 20px; --win-cap: 100cqw; width: min(932px, 100%); display: flex; flex-direction: column; max-height: calc(100dvh - var(--fit-top) - var(--fit-gap)); container-type: inline-size; }
|
|
147
|
-
.wt-stage > * { flex: none; }
|
|
148
|
-
.wt-stage > .player { flex: 0 1 auto; min-height: 0; height: calc((var(--win-cap) - var(--win-w)) / var(--arw, 1.6) + var(--win-h) + var(--player-pad, 0px)); max-height: var(--player-cap, none); container-type: size; }
|
|
149
|
-
.wt-stage > .player.broken { height: auto; container-type: normal; }
|
|
150
|
-
.wt-stage .window { width: min(var(--win-cap), calc((100cqh - var(--win-h)) * var(--arw, 1.6) + var(--win-w))); margin: 0 auto; }
|
|
151
|
-
.wt-stage .controls { width: min(810px, 100%); }
|
|
152
|
-
.device-mobile .wt-stage { --win-cap: min(360px, 100cqw); width: min(540px, 100%); }
|
|
153
|
-
.wt.expanded:not(:fullscreen, .focus) .wt-stage { --win-cap: min(640px, 100cqw, calc((50vh - 160px) * var(--arw, 1.6))); }
|
|
154
|
-
.device-mobile.wt.expanded:not(:fullscreen, .focus) .wt-stage { --win-cap: min(260px, 100cqw, calc((60vh - 200px) * var(--arw, .46) + var(--win-w))); }
|
|
155
|
-
.wt-notes { margin: 12px 0 0; padding: 0; list-style: none; font: var(--t-control); color: var(--muted); text-align: center; }
|
|
156
|
-
.wt-notes li { margin: 4px 0; overflow-wrap: anywhere; }
|
|
157
|
-
.wt-panel { width: min(708px, 100%); border: 1px solid var(--border); border-radius: 12px; background: var(--panel); padding: 12px 16px 0; }
|
|
158
|
-
.wt-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0 10px; }
|
|
159
|
-
.wt-panel-head h2 { margin: 0; font: var(--t-small); color: var(--muted); }
|
|
160
|
-
.wt-expand { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; border: 0; border-radius: 999px; background: var(--subtle); font: var(--t-control); color: var(--text); cursor: pointer; }
|
|
161
|
-
.wt-expand:hover { background: var(--subtle-hover); }
|
|
162
|
-
.wt-expand[aria-expanded="true"] .i-expand, .wt-expand:not([aria-expanded="true"]) .i-collapse { display: none; }
|
|
163
|
-
.wt-script { position: relative; list-style: none; margin: 0; padding: 0 0 8px; }
|
|
164
|
-
.wt.live .wt-script { max-height: 300px; overflow-y: auto; overscroll-behavior: contain; }
|
|
165
|
-
.wt:not(.live) .wt-expand { display: none; }
|
|
166
|
-
/* The script fades out at the bottom, and at the top once rows have scrolled away above (\`--wt-fade\`
|
|
167
|
-
grows with the first 32 px scrolled, where the browser has scroll-driven animations; elsewhere the
|
|
168
|
-
top stays a plain edge). The fade only follows the scroll, so it stays with less motion too. */
|
|
169
|
-
@property --wt-fade { syntax: "<length>"; inherits: false; initial-value: 0px; }
|
|
170
|
-
@keyframes wt-fade { to { --wt-fade: 32px; } }
|
|
171
|
-
.wt.live .wt-script { -webkit-mask-image: linear-gradient(to bottom, transparent, #000 var(--wt-fade), #000 62%, transparent); mask-image: linear-gradient(to bottom, transparent, #000 var(--wt-fade), #000 62%, transparent); }
|
|
172
|
-
@supports (animation-timeline: scroll()) {
|
|
173
|
-
.wt.live .wt-script { animation: wt-fade linear both; animation-timeline: scroll(self); animation-range: 0 32px; }
|
|
174
|
-
@media (prefers-reduced-motion: reduce) { .wt.live .wt-script { animation-name: wt-fade !important; animation-duration: auto !important; animation-fill-mode: both !important; animation-timeline: scroll(self) !important; animation-range: 0 32px !important; } }
|
|
175
|
-
}
|
|
176
|
-
.wt.live .wt-script::after { content: ""; display: block; height: 240px; }
|
|
177
|
-
.wt.expanded .wt-script { max-height: none; -webkit-mask-image: none; mask-image: none; }
|
|
178
|
-
.wt.expanded .wt-script::after { display: none; }
|
|
179
|
-
.wt-case { padding: 0; }
|
|
180
|
-
.wt-case-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0 2px; padding: 0 16px; font: var(--t-small); color: var(--muted); }
|
|
181
|
-
.wt-case:first-child .wt-case-head { margin-top: 0; }
|
|
182
|
-
.wt-case-head h3 { margin: 0; font: var(--t-small-strong); color: var(--muted); }
|
|
183
|
-
.wt-case-head .st { width: 16px; height: 16px; }
|
|
184
|
-
.wt-case-head .st svg { width: 11px; height: 11px; }
|
|
185
|
-
.case-n { font: var(--t-mono); }
|
|
186
|
-
.wt-case-note { margin: 2px 16px 6px; font: var(--t-small); color: var(--muted); }
|
|
187
|
-
.wt-steps { list-style: none; margin: 0; padding: 0; }
|
|
188
|
-
.wt-step { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 16px; align-items: center; min-height: 56px; padding: 8px 16px; border-radius: 10px; font: var(--t-body-lg); color: var(--text); }
|
|
189
|
-
.wt.live .wt-step { color: var(--muted); cursor: pointer; }
|
|
190
|
-
.wt.live .wt-step.on { background: var(--accent-subtle); color: var(--text); font: 500 18px/24px var(--sans); min-height: 60px; }
|
|
191
|
-
.wt-pill { justify-self: start; display: inline-block; min-width: 72px; text-align: center; font: var(--t-mono); padding: 6px 10px; border-radius: 999px; background: var(--subtle); color: var(--text); text-decoration: none; }
|
|
192
|
-
.wt.live .wt-pill { color: var(--muted); }
|
|
193
|
-
.wt.live .wt-step.on .wt-pill { background: var(--accent); color: var(--on-accent); font: var(--t-mono-strong); }
|
|
194
|
-
a.wt-pill:hover { background: var(--accent); color: var(--on-accent); }
|
|
195
|
-
.wt-pill.off { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--border); }
|
|
196
|
-
.wt-text { overflow-wrap: anywhere; }
|
|
197
|
-
.wt-text code { font-size: .85em; padding: 1px 5px; border-radius: 4px; background: var(--subtle); }
|
|
198
|
-
.wt-state { font: var(--t-small); color: var(--muted); margin-left: 6px; }
|
|
199
|
-
.wt-why { grid-column: 2; margin: 0; padding: 8px 12px; border-radius: 10px; background: var(--bg-2); color: var(--st); font: var(--t-control); overflow-wrap: anywhere; white-space: pre-wrap; display: flex; gap: 8px; align-items: flex-start; }
|
|
200
|
-
.wt-case-why { margin: 4px 16px 8px; }
|
|
201
|
-
.wt-why .tag { display: inline-flex; gap: 6px; align-items: center; flex: none; }
|
|
202
|
-
.wt-why .st { width: 18px; height: 18px; }
|
|
203
|
-
.wt-problems { width: min(708px, 100%); }
|
|
204
|
-
.wt-problems h2 { margin: 0 0 8px; font: var(--t-heading-sm); }
|
|
205
|
-
.wt-problems ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
|
|
206
|
-
.wt-problems li { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 10px; align-items: center; font: var(--t-body); }
|
|
207
|
-
.wt-problems .wt-pill { min-width: 64px; padding: 4px 8px; }
|
|
208
|
-
.wt-problems .why { overflow-wrap: anywhere; color: var(--muted); }
|
|
209
|
-
.wt-problems .why a { color: var(--text); }
|
|
210
|
-
|
|
211
|
-
/* What is drawn over the video: the step's box, the cursor, ripples, typing rings, labels. */
|
|
212
|
-
.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; }
|
|
213
|
-
.wt-box span { position: absolute; left: -2px; top: 100%; margin-top: 9px; font: 500 11px/1.4 var(--sans); color: #fff; background: var(--mark-step); padding: 1px 6px; border-radius: 3px; white-space: nowrap; }
|
|
214
|
-
.wt-cursor, .wt-ripple, .wt-ring, .wt-act { position: absolute; pointer-events: none; }
|
|
215
|
-
.wt-cursor { width: 22px; height: 22px; z-index: 4; filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, .5)); }
|
|
216
|
-
.wt-cursor svg { display: block; }
|
|
217
|
-
.wt-ripple { width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--mark-step); background: rgba(47, 111, 214, .22); z-index: 3; }
|
|
218
|
-
.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; }
|
|
219
|
-
.wt-act { z-index: 5; max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 500 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); }
|
|
220
|
-
|
|
221
|
-
/* The scrubber: a thin track, how far it has played in the text's color, and a round head. */
|
|
222
|
-
.wt .track { inset: 12px 0; border-radius: 2px; }
|
|
223
|
-
.wt .done, .wt .idle { border-radius: 2px; }
|
|
224
|
-
.wt .head { top: 7px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--bg); box-shadow: inset 0 0 0 2px var(--text); }
|
|
225
|
-
|
|
226
|
-
/* A run on a desktop, on a wide screen: the player and its controls on the left, the script
|
|
227
|
-
beside them, as tall as they are (\`contain: size\`: the script scrolls in it, never makes it taller).
|
|
228
|
-
Expanded, the script is below in full, as on a narrow screen. With room to spare, more air
|
|
229
|
-
around the prompt. */
|
|
230
|
-
@media (min-width: 1100px) {
|
|
231
|
-
.wt:not(.device-mobile):not(.expanded) .wt-main { grid-template-columns: minmax(0, 804px) minmax(0, 418px); justify-content: center; align-items: start; gap: 56px; }
|
|
232
|
-
.wt:not(.device-mobile):not(.expanded) .wt-stage { width: 100%; }
|
|
233
|
-
.wt:not(.device-mobile):not(.expanded) .wt-problems { grid-column: 1 / -1; justify-self: center; }
|
|
234
|
-
.wt.live:not(.device-mobile):not(.expanded) .wt-panel { justify-self: stretch; align-self: stretch; width: auto; contain: size; display: flex; flex-direction: column; }
|
|
235
|
-
.wt.live:not(.device-mobile):not(.expanded) .wt-script { flex: 1 1 auto; min-height: 0; max-height: none; }
|
|
236
|
-
}
|
|
237
|
-
@media (min-width: 1100px) and (min-height: 860px) {
|
|
238
|
-
.wt > .prompt { margin-top: 64px; }
|
|
239
|
-
.wt-main { padding-top: 80px; }
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/* Fullscreen is the whole page: the top bar, the video in a dark card as big as fits, its address
|
|
243
|
-
over it and the step playing now as a caption across its foot, then the controls. The prompt,
|
|
244
|
-
the script and the notes stay out; the caption takes the place of the label by the cursor. On a
|
|
245
|
-
wide screen it is \`.focus\`: the same layout in the browser's window, never its whole screen. */
|
|
246
|
-
.wt-cap { display: none; }
|
|
247
|
-
.wt:fullscreen { overflow: auto; }
|
|
248
|
-
.wt:is(:fullscreen, .focus) { padding-bottom: 0; background: var(--bg); }
|
|
249
|
-
.wt:is(:fullscreen, .focus) > .prompt, .wt:is(:fullscreen, .focus) :is(.alert, .wt-panel, .wt-problems, .wt-notes, .wt-act) { display: none !important; }
|
|
250
|
-
.wt:is(:fullscreen, .focus) .wt-main { display: block; padding: 0 24px; }
|
|
251
|
-
.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; }
|
|
252
|
-
.wt:is(:fullscreen, .focus) .wt-stage::after { display: none; }
|
|
253
|
-
.wt:is(:fullscreen, .focus) .wt-stage .player { padding: 0; background: none; }
|
|
254
|
-
.wt:is(:fullscreen, .focus) .window { padding: 0 0 58px; border-radius: 12px; border-color: var(--video-edge); background: var(--video); box-shadow: none; }
|
|
255
|
-
.wt:is(:fullscreen, .focus) .screen { border-radius: 0; }
|
|
256
|
-
.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; }
|
|
257
|
-
.wt:is(:fullscreen, .focus) .dots { display: none; }
|
|
258
|
-
.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); }
|
|
259
|
-
.wt:is(:fullscreen, .focus) .url:has(span:empty) { visibility: hidden; }
|
|
260
|
-
.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; }
|
|
261
|
-
.wt:is(:fullscreen, .focus) .wt-cap code { font-size: .85em; }
|
|
262
|
-
.wt-ico { display: none; }
|
|
263
|
-
.wt:is(:fullscreen, .focus) .wt-cap .wt-ico { display: inline-block; margin-right: 10px; vertical-align: -4px; color: var(--muted); }
|
|
264
|
-
.wt:is(:fullscreen, .focus) .wt-cap .wt-ico svg { display: block; }
|
|
265
|
-
.wt:is(:fullscreen, .focus) .player.broken .wt-cap { display: none; }
|
|
266
|
-
.wt:is(:fullscreen, .focus) .wt-stage .controls { width: min(810px, 100%); }
|
|
267
|
-
@media (max-width: 900px) {
|
|
268
|
-
.wt:is(:fullscreen, .focus) .wt-main { padding: 0 12px; }
|
|
269
|
-
.wt:is(:fullscreen, .focus) .wt-cap:not([hidden]) { bottom: 14px; padding: 8px 16px; font: var(--t-body); }
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
/* A run on a phone, on a wide screen: the phone and its controls on the left, the script beside. */
|
|
273
|
-
@media (min-width: 901px) {
|
|
274
|
-
.device-mobile .wt-main { grid-template-columns: minmax(0, 540px) minmax(0, 516px); justify-content: center; align-items: center; gap: 64px; }
|
|
275
|
-
.device-mobile .wt-problems { grid-column: 1 / -1; }
|
|
276
|
-
}
|
|
277
|
-
/* Phones: one column, the player pinned under the top bar while the script scrolls under it. */
|
|
278
|
-
@media (max-width: 900px) {
|
|
279
|
-
.wt > .prompt { padding: 0 16px; }
|
|
280
|
-
.wt > .prompt .prompt-text { -webkit-line-clamp: 1; line-clamp: 1; }
|
|
281
|
-
.wt-main { padding: 12px 12px 0; gap: 16px; }
|
|
282
|
-
.wt-stage { --fit-top: max(var(--wt-top, 0px), var(--bar)); --fit-gap: 0px; position: sticky; top: var(--bar); z-index: 2; width: 100%; padding: 8px 0 10px; background: var(--bg); }
|
|
283
|
-
.wt-stage::after { content: ""; position: absolute; top: 100%; left: 0; right: 0; height: 16px; background: linear-gradient(var(--bg), transparent); pointer-events: none; }
|
|
284
|
-
.wt-stage .window { box-shadow: none; }
|
|
285
|
-
.device-mobile .wt-stage { width: 100%; }
|
|
286
|
-
.device-mobile .wt-stage { --win-cap: min(224px, 100cqw); --player-pad: 20px; --player-cap: calc(44vh - 60px + var(--win-h) + var(--player-pad)); }
|
|
287
|
-
.device-mobile .wt-stage .player { padding: 10px 0; border-radius: 14px; background: var(--subtle); }
|
|
288
|
-
.device-mobile .wt-stage .window { box-shadow: var(--shadow); }
|
|
289
|
-
.wt.expanded:not(:fullscreen, .focus) .wt-stage { --win-cap: 100cqw; --player-cap: calc(96px + var(--win-h)); }
|
|
290
|
-
.device-mobile.wt.expanded:not(:fullscreen, .focus) .wt-stage { --win-cap: 120px; --player-cap: none; }
|
|
291
|
-
.wt-stage .controls { gap: 8px; margin-top: 10px; }
|
|
292
|
-
.wt-panel { padding: 10px 8px 0; }
|
|
293
|
-
.wt-step { grid-template-columns: 64px minmax(0, 1fr); gap: 10px; min-height: 46px; padding: 6px 8px; font: var(--t-body); }
|
|
294
|
-
.wt.live .wt-step.on { font: var(--t-heading-sm); }
|
|
295
|
-
.wt-pill { min-width: 58px; padding: 6px; }
|
|
296
|
-
.play, .full { width: 44px; height: 44px; }
|
|
297
|
-
.speed button { height: 38px; }
|
|
298
|
-
.wt.live .wt-script { max-height: 48vh; }
|
|
299
|
-
}
|
|
300
|
-
`;
|
|
301
|
-
const sessionOf = (entry) => entry.session ?? 1;
|
|
302
|
-
/** A timecode pill: a link that seeks the player (or opens the video at that time without it). */
|
|
303
|
-
const pill = (sessions, session, ms, label) => {
|
|
304
|
-
if (ms === undefined)
|
|
305
|
-
return html `<span class="wt-pill off" aria-hidden="true">–</span>`;
|
|
306
|
-
const text = formatTimecode(ms);
|
|
307
|
-
const src = sessions.get(session);
|
|
308
|
-
if (src === undefined)
|
|
309
|
-
return html `<span class="wt-pill off">${text}</span>`;
|
|
310
|
-
const t = fragmentSeconds(ms);
|
|
311
|
-
return html `<a
|
|
312
|
-
class="wt-pill"
|
|
313
|
-
href="${`${src}#t=${t}`}"
|
|
314
|
-
data-s="${String(session)}"
|
|
315
|
-
data-t="${t}"
|
|
316
|
-
aria-label="${`Play from ${text}: ${label}`}"
|
|
317
|
-
>${text}</a
|
|
318
|
-
>`;
|
|
319
|
-
};
|
|
320
|
-
/** The mouse pointer drawn over the video; its tip is at (3, 2) of its 22 × 22 box. */
|
|
321
|
-
const cursorSvg = html `<div class="wt-cursor" id="wt-cursor" hidden>
|
|
322
|
-
<svg width="22" height="22" viewBox="0 0 22 22" aria-hidden="true">
|
|
323
|
-
<path
|
|
324
|
-
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"
|
|
325
|
-
fill="#fff"
|
|
326
|
-
stroke="#111"
|
|
327
|
-
stroke-width="1.4"
|
|
328
|
-
stroke-linejoin="round"
|
|
329
|
-
/>
|
|
330
|
-
</svg>
|
|
331
|
-
</div>`;
|
|
332
|
-
const fraction = (n) => String(Math.round(Math.max(0, Math.min(1, n)) * 10_000) / 10_000);
|
|
333
|
-
/**
|
|
334
|
-
* Where the element a step acted on was in the video, as shares of the frame, and when to draw
|
|
335
|
-
* it. Only from the viewport screenshot taken at the step (which is what the video shows), and
|
|
336
|
-
* only when its element was measured on it, and when (`targetAtMs`): the element Playwright
|
|
337
|
-
* acted on, located the same way. Never for a full-page screenshot, which the video does not show.
|
|
338
|
-
*/
|
|
339
|
-
export const stepBox = (entry, step) => {
|
|
340
|
-
const timing = step.timing;
|
|
341
|
-
if (timing === undefined)
|
|
342
|
-
return undefined;
|
|
343
|
-
const shot = (entry.shots ?? []).findLast((s) => s.kind === 'step' &&
|
|
344
|
-
s.step === step.index &&
|
|
345
|
-
!s.fullPage &&
|
|
346
|
-
s.target !== undefined &&
|
|
347
|
-
s.targetAtMs !== undefined &&
|
|
348
|
-
s.width > 0 &&
|
|
349
|
-
s.height > 0);
|
|
350
|
-
if (shot === undefined || shot.target === undefined || shot.targetAtMs === undefined)
|
|
351
|
-
return undefined;
|
|
352
|
-
const on = clampBox(shot.target, shot.width, shot.height);
|
|
353
|
-
if (on === undefined)
|
|
354
|
-
return undefined;
|
|
355
|
-
// When the box was measured, not when the image was taken: reading the page's frames and
|
|
356
|
-
// taking the image come after, and can take seconds. Older runs did not record it: no box.
|
|
357
|
-
const at = shot.targetAtMs;
|
|
358
|
-
const from = Math.max(timing.startMs, at - BOX_BEFORE_MS);
|
|
359
|
-
const to = Math.max(at, Math.min(timing.endMs, at + BOX_AFTER_MS));
|
|
360
|
-
return {
|
|
361
|
-
box: [on.x / shot.width, on.y / shot.height, on.width / shot.width, on.height / shot.height]
|
|
362
|
-
.map(fraction)
|
|
363
|
-
.join(' '),
|
|
364
|
-
from,
|
|
365
|
-
to,
|
|
366
|
-
};
|
|
367
|
-
};
|
|
368
|
-
/** An action's label over the video is cut to this many characters. */
|
|
369
|
-
export const ACTION_LABEL_MAX = 48;
|
|
370
|
-
const cut = (text, max) => text.length <= max ? text : `${text.slice(0, max - 1).trimEnd()}…`;
|
|
371
|
-
/**
|
|
372
|
-
* What a step did, in a few words for over the video, such as `Click "Save"`, `Type "Ada"` or
|
|
373
|
-
* `Press Enter`: the step's own wording (`stepParts`), with only the element's name or the value.
|
|
374
|
-
*/
|
|
375
|
-
export const actionLabel = (step) => {
|
|
376
|
-
const parts = stepParts(step);
|
|
377
|
-
const named = parts.filter((p) => p.kind !== 'text');
|
|
378
|
-
const quoted = (i) => {
|
|
379
|
-
const part = named.at(i);
|
|
380
|
-
if (part === undefined)
|
|
381
|
-
return undefined;
|
|
382
|
-
return part.kind === 'value' ? `"${cut(part.text, ACTION_LABEL_MAX - 8)}"` : part.text;
|
|
383
|
-
};
|
|
384
|
-
const words = (() => {
|
|
385
|
-
switch (step.action) {
|
|
386
|
-
case 'click':
|
|
387
|
-
return quoted(0) === undefined ? undefined : `Click ${quoted(0)}`;
|
|
388
|
-
case 'hover':
|
|
389
|
-
return quoted(0) === undefined ? undefined : `Hover ${quoted(0)}`;
|
|
390
|
-
case 'fill':
|
|
391
|
-
return step.value === ''
|
|
392
|
-
? quoted(0) === undefined
|
|
393
|
-
? undefined
|
|
394
|
-
: `Clear ${quoted(0)}`
|
|
395
|
-
: `Type ${quoted(-1)}`;
|
|
396
|
-
case 'upload':
|
|
397
|
-
return `Upload ${quoted(0)}`;
|
|
398
|
-
case 'press':
|
|
399
|
-
return `Press ${step.key}`;
|
|
400
|
-
case 'reload':
|
|
401
|
-
return 'Reload';
|
|
402
|
-
default:
|
|
403
|
-
return undefined;
|
|
404
|
-
}
|
|
405
|
-
})();
|
|
406
|
-
return cut(words ?? stepText(step), ACTION_LABEL_MAX);
|
|
407
|
-
};
|
|
408
|
-
/**
|
|
409
|
-
* An action drawn over the video, as data on its step for the page's script: when it happened
|
|
410
|
-
* (`at`), and as shares of the viewport (which is what the video shows) where the mouse pressed
|
|
411
|
-
* (`pt`, `x y`) and the element (`tb`, `x y width height`). An action whose input was not seen
|
|
412
|
-
* has no time, and so no point: its label shows while its step plays. Nothing from older runs,
|
|
413
|
-
* which did not record actions.
|
|
414
|
-
*/
|
|
415
|
-
export const stepAction = (action) => {
|
|
416
|
-
if (action === undefined)
|
|
417
|
-
return undefined;
|
|
418
|
-
const view = action.viewport;
|
|
419
|
-
const sized = view !== undefined && view.width > 0 && view.height > 0;
|
|
420
|
-
const point = sized && action.point !== undefined
|
|
421
|
-
? `${fraction(action.point.x / view.width)} ${fraction(action.point.y / view.height)}`
|
|
422
|
-
: undefined;
|
|
423
|
-
const on = sized && action.target !== undefined
|
|
424
|
-
? clampBox(action.target, view.width, view.height)
|
|
425
|
-
: undefined;
|
|
426
|
-
const target = on === undefined || !sized
|
|
427
|
-
? undefined
|
|
428
|
-
: [on.x / view.width, on.y / view.height, on.width / view.width, on.height / view.height]
|
|
429
|
-
.map(fraction)
|
|
430
|
-
.join(' ');
|
|
431
|
-
// A point is drawn only at the time it was pressed.
|
|
432
|
-
if (action.atMs === undefined)
|
|
433
|
-
return target !== undefined ? { tb: target } : {};
|
|
434
|
-
return {
|
|
435
|
-
at: fragmentSeconds(action.atMs),
|
|
436
|
-
...(point !== undefined ? { pt: point } : {}),
|
|
437
|
-
...(target !== undefined ? { tb: target } : {}),
|
|
438
|
-
};
|
|
439
|
-
};
|
|
440
|
-
const stepLabel = (step) => (step.index === 0 ? 'Opening page' : `Step ${step.index}`);
|
|
441
|
-
const notRun = { 'not-run': 'not run', unknown: '', done: '', decided: '' };
|
|
442
|
-
/** Why the code gave a case its status (`status`: the code's, not one the agent gave). */
|
|
443
|
-
const why = (entry, status, extraClass = '') => html `<p class="${`wt-why s-${status}${extraClass}`}">
|
|
444
|
-
${statusTag(status)}<span>${entry.reason}</span>
|
|
445
|
-
</p>`;
|
|
446
|
-
/** The agent's verdict on a case its findings mark failed, beside the code's result. */
|
|
447
|
-
const agentWhy = (view) => html `<p class="wt-why s-failed wt-case-why">
|
|
448
|
-
${statusTag('failed')}<span
|
|
449
|
-
>Agent's verdict: ${view.agentFailed ?? ''}
|
|
450
|
-
<span class="wt-checked">(${checksNote(view.checkStatus)})</span></span
|
|
451
|
-
>
|
|
452
|
-
</p>`;
|
|
453
|
-
/**
|
|
454
|
-
* The input a step gives the page, as an icon by its words in the fullscreen caption: a left
|
|
455
|
-
* click, a pointer moved over something, typing, a key or the mouse wheel. Steps that only look
|
|
456
|
-
* or wait have none.
|
|
457
|
-
*/
|
|
458
|
-
const stepIcon = {
|
|
459
|
-
click: 'mouse-left',
|
|
460
|
-
hover: 'mouse-pointer-2',
|
|
461
|
-
fill: 'text-cursor',
|
|
462
|
-
press: 'keyboard',
|
|
463
|
-
scroll: 'mouse',
|
|
464
|
-
};
|
|
465
|
-
const stepRow = (view, step, sessions) => {
|
|
466
|
-
const { entry } = view;
|
|
467
|
-
const session = sessionOf(entry);
|
|
468
|
-
const parts = stepParts(step.step);
|
|
469
|
-
const plain = parts.map((p) => p.text).join('');
|
|
470
|
-
const ms = step.timing?.startMs;
|
|
471
|
-
const timed = ms !== undefined && sessions.has(session);
|
|
472
|
-
const box = timed ? stepBox(entry, step) : undefined;
|
|
473
|
-
const acted = timed ? stepAction(step.timing?.action) : undefined;
|
|
474
|
-
// A fill or a hover records no element of its own (its input is not watched): its ring (a
|
|
475
|
-
// fill's) and its label are placed by the step's box, when there is one, from the screenshot
|
|
476
|
-
// taken at the step.
|
|
477
|
-
const unwatched = step.timing?.action?.kind === 'fill' || step.timing?.action?.kind === 'hover';
|
|
478
|
-
const action = acted !== undefined && acted.tb === undefined && unwatched && box
|
|
479
|
-
? { ...acted, tb: box.box }
|
|
480
|
-
: acted;
|
|
481
|
-
const decided = step.state === 'decided';
|
|
482
|
-
const kind = stepIcon[step.step.action];
|
|
483
|
-
return html `<li
|
|
484
|
-
class="wt-step st-${step.state}${decided ? ` s-${view.checkStatus}` : ''}"
|
|
485
|
-
id="${`wt-${entry.id}-${step.index}`}"
|
|
486
|
-
${timed ? html ` data-s="${String(session)}" data-t="${fragmentSeconds(ms)}"` : ''}
|
|
487
|
-
${timed && step.step.action === 'hover' ? html ` data-hv` : ''}
|
|
488
|
-
${box
|
|
489
|
-
? html ` data-box="${box.box}" data-b0="${fragmentSeconds(box.from)}"
|
|
490
|
-
data-b1="${fragmentSeconds(box.to)}" data-label="${stepLabel(step)}"`
|
|
491
|
-
: ''}
|
|
492
|
-
${action && step.timing
|
|
493
|
-
? html ` data-act="${step.timing.action?.kind ?? ''}"${action.at ? html ` data-at="${action.at}"` : ''}
|
|
494
|
-
data-a1="${fragmentSeconds(step.timing.endMs)}" data-al="${actionLabel(step.step)}"
|
|
495
|
-
${action.pt ? html ` data-pt="${action.pt}"` : ''}${action.tb ? html ` data-tb="${action.tb}"` : ''}`
|
|
496
|
-
: ''}
|
|
497
|
-
>
|
|
498
|
-
${pill(sessions, session, ms, plain)}
|
|
499
|
-
<span class="wt-text"
|
|
500
|
-
>${kind ? html `<span class="wt-ico">${icon(kind, { size: 20 })}</span>` : ''}${textParts(parts)}${step.implicit
|
|
501
|
-
? html ` <span class="wt-state">(added: every case starts at the job URL)</span>`
|
|
502
|
-
: ''}${notRun[step.state] ? html ` <span class="wt-state">(${notRun[step.state]})</span>` : ''}</span
|
|
503
|
-
>
|
|
504
|
-
${decided && entry.reason ? why(entry, view.checkStatus) : ''}
|
|
505
|
-
</li>`;
|
|
506
|
-
};
|
|
507
|
-
/** Steps that only check the page, left out of the walkthrough's script, even one that decided its case. */
|
|
508
|
-
const checks = new Set([
|
|
509
|
-
'expectText',
|
|
510
|
-
'expectNoText',
|
|
511
|
-
'expectUrl',
|
|
512
|
-
'expectLink',
|
|
513
|
-
]);
|
|
514
|
-
/**
|
|
515
|
-
* The steps the walkthrough lists: what the run did. A case a check decided says why under its
|
|
516
|
-
* title instead, and in the cases that did not pass.
|
|
517
|
-
*/
|
|
518
|
-
const scriptSteps = (view) => view.steps.filter((s) => !checks.has(s.step.action));
|
|
519
|
-
const caseBlock = (view, position, sessions) => {
|
|
520
|
-
const { entry } = view;
|
|
521
|
-
const session = sessionOf(entry);
|
|
522
|
-
const steps = scriptSteps(view);
|
|
523
|
-
const decidedShown = steps.some((s) => s.state === 'decided');
|
|
524
|
-
const timedButNoVideo = view.steps.some((s) => s.timing !== undefined) && !sessions.has(session)
|
|
525
|
-
? html `<p class="wt-case-note">
|
|
526
|
-
Session ${session} has no video, so these times cannot be played.
|
|
527
|
-
</p>`
|
|
528
|
-
: '';
|
|
529
|
-
return html `<li class="wt-case s-${entry.status}" id="${`wt-${entry.id}`}">
|
|
530
|
-
<div class="wt-case-head">
|
|
531
|
-
<span class="case-n">${String(position).padStart(2, '0')}</span>
|
|
532
|
-
${statusIcon(entry.status)}
|
|
533
|
-
<h3>${entry.title}</h3>
|
|
534
|
-
<span class="${entry.status === 'passed' ? 'sr' : 'st-label'}"
|
|
535
|
-
>${statusLabel[entry.status]}</span
|
|
536
|
-
>
|
|
537
|
-
</div>
|
|
538
|
-
${timedButNoVideo}${view.agentFailed !== undefined ? agentWhy(view) : ''}${entry.reason && !decidedShown ? why(entry, view.checkStatus, ' wt-case-why') : ''}
|
|
539
|
-
${steps.length > 0
|
|
540
|
-
? html `<ol class="wt-steps">
|
|
541
|
-
${steps.map((step) => stepRow(view, step, sessions))}
|
|
542
|
-
</ol>`
|
|
543
|
-
: html `<p class="wt-case-note">No steps recorded for this case.</p>`}
|
|
544
|
-
</li>`;
|
|
545
|
-
};
|
|
546
|
-
/** Cases that did not pass, each with a link to where it was decided. */
|
|
547
|
-
const problemsBlock = (views, sessions) => {
|
|
548
|
-
const failing = views.filter((v) => v.entry.status !== 'passed');
|
|
549
|
-
if (failing.length === 0)
|
|
550
|
-
return '';
|
|
551
|
-
return html `<section class="wt-problems" aria-labelledby="wt-problems-title">
|
|
552
|
-
<h2 id="wt-problems-title">Did not pass</h2>
|
|
553
|
-
<ul>
|
|
554
|
-
${failing.map((view) => {
|
|
555
|
-
const { entry } = view;
|
|
556
|
-
const decided = view.steps.find((s) => s.state === 'decided');
|
|
557
|
-
const ms = decided?.timing?.startMs ?? entry.startMs;
|
|
558
|
-
const at = ms !== undefined && sessions.has(sessionOf(entry))
|
|
559
|
-
? pill(sessions, sessionOf(entry), ms, `where case ${entry.title} was decided`)
|
|
560
|
-
: html `<a class="wt-pill off" href="${`#wt-${entry.id}`}"
|
|
561
|
-
>${ms !== undefined ? formatTimecode(ms) : 'see'}</a
|
|
562
|
-
>`;
|
|
563
|
-
return html `<li class="s-${entry.status}">
|
|
564
|
-
${at}${statusTag(entry.status)}<span class="why"
|
|
565
|
-
><a href="${`#wt-${entry.id}`}">${entry.title}</a>${view.agentFailed !== undefined
|
|
566
|
-
? html `: agent's verdict: ${view.agentFailed} (${checksNote(view.checkStatus)})`
|
|
567
|
-
: entry.reason
|
|
568
|
-
? html `: ${entry.reason}`
|
|
569
|
-
: ''}</span
|
|
570
|
-
>
|
|
571
|
-
</li>`;
|
|
572
|
-
})}
|
|
573
|
-
</ul>
|
|
574
|
-
</section>`;
|
|
575
|
-
};
|
|
576
|
-
/* Expand shows chevrons apart; Collapse, together (by `aria-expanded`). */
|
|
577
|
-
const expandIcon = html `${icon('chevrons-up-down', { size: 13, className: 'i-expand' })}${icon('chevrons-down-up', { size: 13, className: 'i-collapse' })}`;
|
|
578
|
-
/**
|
|
579
|
-
* The run's walkthrough as a self-contained page, written next to its `report.html`: inline CSS,
|
|
580
|
-
* one inline script, and from the network only Geist and Geist Mono from Google Fonts (system
|
|
581
|
-
* fonts offline). The video loads by relative path, or under `options.assetBaseUrl` (see
|
|
582
|
-
* `RenderOptions`); with no options the page is exactly the local one. Code decides everything
|
|
583
|
-
* on it, except that a case the agent's findings mark failed shows as failed, with the agent's
|
|
584
|
-
* verdict labelled as its own; nothing else from the write-up is shown. Every piece of text from the job or the page is escaped.
|
|
585
|
-
*/
|
|
586
|
-
export const renderWalkthrough = (bundle, options) => {
|
|
587
|
-
const { spec, ledger } = bundle;
|
|
588
|
-
const assets = assetsOf(options);
|
|
589
|
-
const views = caseViews(bundle);
|
|
590
|
-
const playable = playableSessions(bundle, assets);
|
|
591
|
-
const sessions = new Map(playable.map((p) => [p.number, p.src]));
|
|
592
|
-
const firstCase = ledger.cases.find((c) => sessions.has(sessionOf(c)) && c.startMs !== undefined);
|
|
593
|
-
const first = playable.find((p) => p.number === (firstCase && sessionOf(firstCase))) ?? playable[0];
|
|
594
|
-
const timed = ledger.cases.some((c) => (c.steps ?? []).length > 0);
|
|
595
|
-
// A page, not a file to load: relative even with an asset base URL (see `assets.ts`).
|
|
596
|
-
const report = safeRelative(bundle.files.html) ?? runFiles.html;
|
|
597
|
-
const missingVideo = (ledger.sessions ?? []).filter((s) => s.videoProblem || !s.video);
|
|
598
|
-
const actions = views.reduce((n, v) => n + scriptSteps(v).length, 0);
|
|
599
|
-
const urls = urlTimeline(bundle, views);
|
|
600
|
-
const idle = idleStretches(bundle);
|
|
601
|
-
const overlay = html `<div class="wt-box" id="wt-box" hidden><span></span></div>
|
|
602
|
-
<div class="wt-ring" id="wt-ring" hidden></div>
|
|
603
|
-
<div class="wt-ripple" id="wt-ripple" hidden></div>
|
|
604
|
-
${cursorSvg}
|
|
605
|
-
<span class="wt-act" id="wt-act" hidden></span>`;
|
|
606
|
-
// The step playing now, under the video in fullscreen; the page's script copies its words in.
|
|
607
|
-
const caption = html `<p class="wt-cap" id="wt-cap" hidden></p>`;
|
|
608
|
-
const notes = html `${first !== undefined && !timed
|
|
609
|
-
? html `<li>This run recorded no step times, so the steps cannot be played from here.</li>`
|
|
610
|
-
: ''}${first !== undefined
|
|
611
|
-
? missingVideo.map((s) => html `<li>
|
|
612
|
-
Session ${s.number}: video missing or
|
|
613
|
-
incomplete${s.videoProblem ? `: ${s.videoProblem}` : '.'}
|
|
614
|
-
</li>`)
|
|
615
|
-
: ''}${playable.length > 1
|
|
616
|
-
? html `<li>
|
|
617
|
-
${playable.length} session videos; the player moves on to the next when one ends.
|
|
618
|
-
</li>`
|
|
619
|
-
: ''}`;
|
|
620
|
-
const stage = first === undefined
|
|
621
|
-
? html `<p class="novideo" role="note">
|
|
622
|
-
<strong>This run has no video</strong>, so the times below cannot be played. The steps and
|
|
623
|
-
results are still listed.
|
|
624
|
-
</p>`
|
|
625
|
-
: html `${playerWindow({
|
|
626
|
-
prefix: 'wt',
|
|
627
|
-
sessions: playable,
|
|
628
|
-
first,
|
|
629
|
-
startMs: 0,
|
|
630
|
-
urls,
|
|
631
|
-
initialUrl: urlAt(urls, first.number, 0),
|
|
632
|
-
overlay,
|
|
633
|
-
below: caption,
|
|
634
|
-
extraClass: 'wt-player',
|
|
635
|
-
...(options?.assetBaseUrl === undefined
|
|
636
|
-
? { fixPrompt: videoFixPrompt(bundle.jobId) }
|
|
637
|
-
: {}),
|
|
638
|
-
})}
|
|
639
|
-
${controlsBlock({
|
|
640
|
-
prefix: 'wt',
|
|
641
|
-
bundle,
|
|
642
|
-
sessions: playable,
|
|
643
|
-
progress: true,
|
|
644
|
-
label: 'Seek in the recording',
|
|
645
|
-
marks: (session, length) => idle
|
|
646
|
-
.filter((g) => g.session === session)
|
|
647
|
-
.map((g) => html `<span
|
|
648
|
-
class="idle"
|
|
649
|
-
data-a="${fragmentSeconds(g.fromMs)}"
|
|
650
|
-
data-b="${fragmentSeconds(g.toMs)}"
|
|
651
|
-
style="${`left:${share(g.fromMs, length)};width:${share(g.toMs - g.fromMs, length)}`}"
|
|
652
|
-
></span>`),
|
|
653
|
-
toggles: html `${idle.length > 0 ? toggleButton('wt-skip', html `Skip<span class="wide"> inactive</span>`, true) : ''}<label
|
|
654
|
-
class="toggle"
|
|
655
|
-
id="wt-cursor-toggle"
|
|
656
|
-
hidden
|
|
657
|
-
><input type="checkbox" id="wt-cursor-on" checked /> Cursor</label
|
|
658
|
-
>`,
|
|
659
|
-
})}`;
|
|
660
|
-
const page = html `<!doctype html>
|
|
661
|
-
<html lang="en">
|
|
662
|
-
<head>
|
|
663
|
-
<meta charset="utf-8" />
|
|
664
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
665
|
-
<meta name="color-scheme" content="light dark" />
|
|
666
|
-
${generatorMeta(bundle)}
|
|
667
|
-
<meta http-equiv="Content-Security-Policy" content="${walkthroughCsp(assets.origin)}" />
|
|
668
|
-
${favicon} ${webFonts}
|
|
669
|
-
<title>${`Walkthrough · screw-bugs ${bundle.jobId}`}</title>
|
|
670
|
-
<style>
|
|
671
|
-
${new Markup(styles + walkthroughStyles)}
|
|
672
|
-
</style>
|
|
673
|
-
</head>
|
|
674
|
-
<body>
|
|
675
|
-
${scriptTag}
|
|
676
|
-
<div class="${`wt device-${bundle.device.kind}`}" style="${shapeStyle(bundle)}">
|
|
677
|
-
${topBar(bundle.startedAt, bundle.jobId, { href: report, name: 'Report', icon: 'file-text' })}
|
|
678
|
-
${promptBlock(spec.instructions)}
|
|
679
|
-
${ledger.error
|
|
680
|
-
? html `<div class="alert" role="note">
|
|
681
|
-
<strong>The run stopped early.</strong> ${ledger.error}
|
|
682
|
-
</div>`
|
|
683
|
-
: ''}
|
|
684
|
-
<main class="wt-main">
|
|
685
|
-
<div class="wt-stage">
|
|
686
|
-
${stage}
|
|
687
|
-
<ul class="wt-notes">
|
|
688
|
-
${notes}
|
|
689
|
-
</ul>
|
|
690
|
-
</div>
|
|
691
|
-
<section class="wt-panel" aria-labelledby="wt-script-title">
|
|
692
|
-
<div class="wt-panel-head">
|
|
693
|
-
<h2 id="wt-script-title">
|
|
694
|
-
Script · ${actions} ${actions === 1 ? 'action' : 'actions'}
|
|
695
|
-
</h2>
|
|
696
|
-
<button
|
|
697
|
-
type="button"
|
|
698
|
-
class="wt-expand"
|
|
699
|
-
id="wt-expand"
|
|
700
|
-
aria-expanded="false"
|
|
701
|
-
aria-controls="wt-script"
|
|
702
|
-
>
|
|
703
|
-
${expandIcon}<span>Expand</span>
|
|
704
|
-
</button>
|
|
705
|
-
</div>
|
|
706
|
-
<ol class="wt-script" id="wt-script">
|
|
707
|
-
${views.map((view, i) => caseBlock(view, i + 1, sessions))}
|
|
708
|
-
</ol>
|
|
709
|
-
</section>
|
|
710
|
-
${problemsBlock(views, sessions)}
|
|
711
|
-
</main>
|
|
712
|
-
</div>
|
|
713
|
-
</body>
|
|
714
|
-
</html> `;
|
|
715
|
-
return page.value;
|
|
716
|
-
};
|