@buoy-gg/mcp 7.0.49 → 7.0.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/camera-YKUHGME2.mjs +1 -0
- package/dist/chunk-EKM5ZZKU.mjs +139 -0
- package/dist/chunk-RYFN5J56.mjs +5 -0
- package/dist/chunk-ZP243U3K.mjs +367 -0
- package/dist/cli.js +212 -135
- package/dist/cli.mjs +8 -8
- package/dist/index.d.mts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +203 -126
- package/dist/index.mjs +1 -1
- package/dist/webBench-K5MAFWO3.mjs +1 -0
- package/package.json +3 -3
- package/skill/buoy-optimize/SKILL.md +35 -5
- package/dist/chunk-2PTJT2QF.mjs +0 -64
- package/dist/chunk-MLEZPZP3.mjs +0 -369
- package/dist/webBench-LKAOZXHK.mjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{cliPath as e,describeDevices as i,describeDiagnosis as r,describeInputs as s,proRequired as t,readEntitlement as c,run as d}from"./chunk-RYFN5J56.mjs";export{e as cliPath,i as describeDevices,r as describeDiagnosis,s as describeInputs,t as proRequired,c as readEntitlement,d as run};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import{createRequire as Ke}from"module";import{execFileSync as be}from"child_process";import{join as ue}from"path";import{closeSync as $e,linkSync as Se,mkdirSync as Qe,openSync as ke,readFileSync as Ve,renameSync as Xe,statSync as ve,unlinkSync as X,writeFileSync as Te,writeSync as Ye}from"fs";import{tmpdir as Ze}from"os";import{pathToFileURL as et}from"url";var tt=`(() => {
|
|
2
|
+
const supported = (t) => {
|
|
3
|
+
try { return (PerformanceObserver.supportedEntryTypes || []).includes(t); } catch { return false; }
|
|
4
|
+
};
|
|
5
|
+
const frames = [], longTasks = [], loaf = [], shifts = [], events = [], observers = [];
|
|
6
|
+
const watch = (type, cb, extra) => {
|
|
7
|
+
if (!supported(type)) return false;
|
|
8
|
+
const o = new PerformanceObserver((l) => l.getEntries().forEach(cb));
|
|
9
|
+
o.observe(Object.assign({ type, buffered: false }, extra || {}));
|
|
10
|
+
observers.push([o, cb]);
|
|
11
|
+
return true;
|
|
12
|
+
};
|
|
13
|
+
const hasLong = watch("longtask", (e) => longTasks.push({ start: e.startTime, end: e.startTime + e.duration }));
|
|
14
|
+
const hasLoaf = watch("long-animation-frame", (e) => loaf.push({
|
|
15
|
+
startTime: e.startTime,
|
|
16
|
+
duration: e.duration,
|
|
17
|
+
blockingDuration: e.blockingDuration || 0,
|
|
18
|
+
styleAndLayoutStart: e.styleAndLayoutStart || 0,
|
|
19
|
+
scripts: (e.scripts || []).map((s) => {
|
|
20
|
+
const file = s.sourceURL ? s.sourceURL.split("?")[0].split("/").pop() : "";
|
|
21
|
+
const where = s.sourceFunctionName ? s.sourceFunctionName + (file ? " @ " + file : "") : file;
|
|
22
|
+
// Invokers like "FrameRequestCallback" say how a script ran, not which
|
|
23
|
+
// one; add the function and file when the browser gives them.
|
|
24
|
+
const name = s.invoker ? (where ? s.invoker + " \u2192 " + where : s.invoker) : where || "(anonymous)";
|
|
25
|
+
return { duration: s.duration, name, forced: s.forcedStyleAndLayoutDuration || 0 };
|
|
26
|
+
}),
|
|
27
|
+
}));
|
|
28
|
+
// 16 ms is Event Timing's smallest threshold; the default (104) hides most taps.
|
|
29
|
+
const hasEvents = watch("event", (e) => {
|
|
30
|
+
if (e.interactionId) events.push({
|
|
31
|
+
name: e.name, startTime: e.startTime, duration: e.duration,
|
|
32
|
+
processingStart: e.processingStart, processingEnd: e.processingEnd, interactionId: e.interactionId,
|
|
33
|
+
});
|
|
34
|
+
}, { durationThreshold: 16 });
|
|
35
|
+
// Click proof: which step selectors each real click landed inside, read
|
|
36
|
+
// at the moment of the click (capture phase, before the page's handlers).
|
|
37
|
+
const clickTargets = Array.isArray(window.__buoyBenchClickTargets) ? window.__buoyBenchClickTargets : [];
|
|
38
|
+
const clicks = [], keys = [];
|
|
39
|
+
// Only real (trusted) input counts as proof; a click the page fakes in
|
|
40
|
+
// script doesn't. Input after the run's end doesn't count either.
|
|
41
|
+
const onClick = (e) => {
|
|
42
|
+
if (!e.isTrusted || ended) return;
|
|
43
|
+
const t = e.target;
|
|
44
|
+
const hit = clickTargets.filter((sel) => { try { return t && t.closest && t.closest(sel); } catch { return false; } });
|
|
45
|
+
clicks.push({ t: performance.now(), hit });
|
|
46
|
+
};
|
|
47
|
+
const onKey = (e) => {
|
|
48
|
+
if (!e.isTrusted || ended) return;
|
|
49
|
+
keys.push({ t: performance.now(), key: e.key, ctrl: e.ctrlKey, shift: e.shiftKey, alt: e.altKey, meta: e.metaKey });
|
|
50
|
+
};
|
|
51
|
+
// Expect steps, judged inside end() so no page work can slip in between
|
|
52
|
+
// the end of the run and the check.
|
|
53
|
+
const expects = Array.isArray(window.__buoyBenchExpects) ? window.__buoyBenchExpects : [];
|
|
54
|
+
let expectResults = null;
|
|
55
|
+
document.addEventListener("click", onClick, true);
|
|
56
|
+
document.addEventListener("keydown", onKey, true);
|
|
57
|
+
const hasShift = watch("layout-shift", (e) => shifts.push({ startTime: e.startTime, value: e.value, hadRecentInput: e.hadRecentInput }));
|
|
58
|
+
let hidden = document.visibilityState === "hidden";
|
|
59
|
+
const onVis = () => { if (document.visibilityState === "hidden") hidden = true; };
|
|
60
|
+
document.addEventListener("visibilitychange", onVis);
|
|
61
|
+
// Latched: a resize or zoom that's undone before stop still changed the work.
|
|
62
|
+
let resized = false;
|
|
63
|
+
const onResize = () => { resized = true; };
|
|
64
|
+
window.addEventListener("resize", onResize);
|
|
65
|
+
// A pixel-ratio change (moving to another screen) may not fire resize.
|
|
66
|
+
let dprQuery = null;
|
|
67
|
+
try {
|
|
68
|
+
dprQuery = matchMedia("(resolution: " + window.devicePixelRatio + "dppx)");
|
|
69
|
+
dprQuery.addEventListener("change", onResize);
|
|
70
|
+
} catch {}
|
|
71
|
+
let raf = 0;
|
|
72
|
+
const tick = (t) => { frames.push(t); raf = requestAnimationFrame(tick); };
|
|
73
|
+
raf = requestAnimationFrame(tick);
|
|
74
|
+
const start = performance.now();
|
|
75
|
+
// Trace markers: the driver counts Chrome's frames between these two.
|
|
76
|
+
try { performance.mark("__buoy_bench_start"); } catch {}
|
|
77
|
+
const domStart = document.getElementsByTagName("*").length;
|
|
78
|
+
let ended = 0;
|
|
79
|
+
window.__buoyBench = {
|
|
80
|
+
// Two steps so the driver can read Chrome's counters between them:
|
|
81
|
+
// end() freezes the end time at once; collect() then waits up to two
|
|
82
|
+
// frames (capped at 300 ms) so an input's entry, which only arrives after
|
|
83
|
+
// its paint, isn't lost. Entries after the end are filtered out later.
|
|
84
|
+
end: () => {
|
|
85
|
+
if (ended) return ended;
|
|
86
|
+
ended = performance.now();
|
|
87
|
+
try { performance.mark("__buoy_bench_end"); } catch {}
|
|
88
|
+
cancelAnimationFrame(raf);
|
|
89
|
+
expectResults = expects.map((x) => {
|
|
90
|
+
const n = document.querySelector(x.selector);
|
|
91
|
+
const full = n ? (n.textContent || "") : null;
|
|
92
|
+
// Match against the full text here; only a short snippet goes back.
|
|
93
|
+
return { selector: x.selector, text: x.text == null ? null : x.text, found: !!n, matched: full != null && (x.text == null || full.includes(x.text)), content: full == null ? null : full.slice(0, 200) };
|
|
94
|
+
});
|
|
95
|
+
return ended;
|
|
96
|
+
},
|
|
97
|
+
collect: () => new Promise((resolve) => {
|
|
98
|
+
const end = window.__buoyBench.end();
|
|
99
|
+
let done = false;
|
|
100
|
+
const finish = () => {
|
|
101
|
+
if (done) return;
|
|
102
|
+
done = true;
|
|
103
|
+
document.removeEventListener("visibilitychange", onVis);
|
|
104
|
+
window.removeEventListener("resize", onResize);
|
|
105
|
+
document.removeEventListener("click", onClick, true);
|
|
106
|
+
document.removeEventListener("keydown", onKey, true);
|
|
107
|
+
try { dprQuery && dprQuery.removeEventListener("change", onResize); } catch {}
|
|
108
|
+
for (const [o, cb] of observers) { o.takeRecords().forEach(cb); o.disconnect(); }
|
|
109
|
+
resolve({
|
|
110
|
+
start, end, frames,
|
|
111
|
+
longTasks: hasLong ? longTasks : null,
|
|
112
|
+
loaf: hasLoaf ? loaf : null,
|
|
113
|
+
shifts: hasShift ? shifts : null,
|
|
114
|
+
events: hasEvents ? events : null,
|
|
115
|
+
clicks,
|
|
116
|
+
keys,
|
|
117
|
+
expectResults,
|
|
118
|
+
domStart,
|
|
119
|
+
domEnd: document.getElementsByTagName("*").length,
|
|
120
|
+
hidden,
|
|
121
|
+
resized,
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
requestAnimationFrame(() => requestAnimationFrame(finish));
|
|
125
|
+
setTimeout(finish, 300);
|
|
126
|
+
}),
|
|
127
|
+
};
|
|
128
|
+
return true;
|
|
129
|
+
})()`;var nt=`(() => (window.__buoyBench ? window.__buoyBench.end() : null))()`;var st=`(() => (window.__buoyBench ? window.__buoyBench.collect() : null))()`;var rt=`new Promise((resolve) => {
|
|
130
|
+
let n = 0, t0 = 0;
|
|
131
|
+
const tick = (t) => {
|
|
132
|
+
if (!t0) t0 = t;
|
|
133
|
+
n++;
|
|
134
|
+
if (t - t0 >= 1000) resolve(((n - 1) / (t - t0)) * 1000);
|
|
135
|
+
else requestAnimationFrame(tick);
|
|
136
|
+
};
|
|
137
|
+
requestAnimationFrame(tick);
|
|
138
|
+
})`;function xe(e,o,t=[]){const r=e.median;const s=[];const n=[];const i=(f,l,u)=>{if(l==null)return;if(u==null)n.push(f);else if(u>l)s.push(`${f} ${u} > ${l}`)};i("droppedPct",o.droppedPct,e.droppedMin!=null?r?.droppedPct:null);const a=e.runs.filter(f=>!f.failed&&f.fps!=null);const c=t.some(f=>"click"in f||"press"in f||"type"in f);const p=a.map(f=>f.interactions==null||!f.inputCaptureComplete?null:f.worstInteractionMs??16);i("inputMs",o.inputMs,c&&p.length&&p.every(f=>f!=null)?Math.max(...p):null);const h=a.map(f=>Math.max(f.frameGapMaxMs??0,f.edgeSilenceMs??0));i("freezeMs",o.freezeMs,h.length?Math.max(...h):null);i("mainThreadPct",o.mainThreadPct,r?.mainThreadPct);i("jsHeapMb",o.jsHeapMb,r?.heapMb);return{meets:Boolean(r)&&s.length===0&&n.length===0,over:s,unknown:n}}var v=e=>Math.round(e*10)/10;function Ee(e,o){if(e.length===0)return null;const t=[...e].sort((s,n)=>s-n);const r=Math.ceil(o/100*t.length)-1;return t[Math.min(t.length-1,Math.max(0,r))]}var at=[30,60,75,90,120,144,165,240];function Pe(e){for(const o of at)if(Math.abs(e-o)/o<=.08)return o;return Math.max(1,Math.round(e))}function de(e,o){let t=o>>>0;const r=()=>{t=t+1831565813>>>0;let n=t;n=Math.imul(n^n>>>15,n|1);n^=n+Math.imul(n^n>>>7,n|61);return((n^n>>>14)>>>0)/4294967296};const s=[...e];for(let n=s.length-1;n>0;n--){const i=Math.floor(r()*(n+1));[s[n],s[i]]=[s[i],s[n]]}return s}function Re(e,o,t){const r=new URL(e);const s=o.path??t;if(s)r.pathname=s.startsWith("/")?s:`${r.pathname.replace(/\/$/,"")}/${s}`;for(const[n,i]of Object.entries(o.params??{}))r.searchParams.set(n,i);return r.toString()}var ot=["STATE_PRESENTED_ALL","STATE_PRESENTED_PARTIAL","STATE_DROPPED"];function _e(e){const o=u=>e.find(g=>g.name===u&&g.ts!=null);const t=o("__buoy_bench_start");const r=o("__buoy_bench_end");if(!t||!r||r.ts<=t.ts)return null;if(t.pid!==r.pid)return null;const s=t.pid;const n={STATE_PRESENTED_ALL:0,STATE_PRESENTED_PARTIAL:1,STATE_DROPPED:2};const i=new Map;for(const u of e){if(u.name!=="PipelineReporter"||u.ph!=="b")continue;if(s!=null&&u.pid!==s)continue;if(u.ts==null||u.ts<t.ts||u.ts>r.ts)continue;const g=u.args?.frame_reporter;if(!g||g.frame_sequence==null)continue;const x=g.state;if(!ot.includes(x))continue;const E=`${g.layer_tree_host_id??""}:${g.frame_source??""}:${g.frame_sequence}`;const $=Boolean(g.affects_smoothness)&&x!=="STATE_PRESENTED_ALL";const R=i.get(E);if(!R)i.set(E,{state:x,fault:$});else{if(n[x]>n[R.state])R.state=x;R.fault=R.fault||$}}let a=0;let c=0;let p=0;let h=0;for(const u of i.values()){if(u.state==="STATE_PRESENTED_ALL")a++;else if(u.state==="STATE_PRESENTED_PARTIAL")c++;else p++;if(u.fault)h++}const f=a+c+p;if(f===0)return null;const l=(r.ts-t.ts)/1e6;return{full:a,partial:c,dropped:p,faults:h,shownFps:v((a+c)/l),droppedPct:v(h/f*100)}}function Ce(e,o){const t=e.split("+");const r=t[t.length-1];const s=new Set(t.slice(0,-1).map(a=>a.toLowerCase()));if(o.key!==r)return false;const n=r.toLowerCase();const i={ctrl:s.has("control")||n==="control",alt:s.has("alt")||n==="alt",meta:s.has("meta")||s.has("command")||n==="meta",shift:s.has("shift")||n==="shift"};if(Boolean(o.ctrl)!==i.ctrl||Boolean(o.alt)!==i.alt||Boolean(o.meta)!==i.meta)return false;if(!i.shift&&o.shift&&r.length!==1)return false;if(i.shift&&!o.shift)return false;return true}function Ae(e){const o=[];for(const t of e){const r=t.startTime+t.duration;const s=o.find(i=>i.interactionId===t.interactionId&&Math.abs(i.startTime+i.duration-r)<=8);if(!s){o.push({...t});continue}const n=s.startTime+s.duration;s.startTime=Math.min(s.startTime,t.startTime);s.processingStart=Math.min(s.processingStart,t.processingStart);s.processingEnd=Math.max(s.processingEnd,t.processingEnd);s.duration=Math.max(n,r)-s.startTime;if(t.processingEnd-t.processingStart>0)s.name=t.name}return o}function Le(e,o){const{start:t,end:r}=e;const s=Math.max(1,r-t);const n=[];for(let y=1;y<e.frames.length;y++)n.push(e.frames[y]-e.frames[y-1]);const i=1e3/o;const a=Ee(n,95);let c=null;if(e.longTasks){let y=0;for(const T of e.longTasks){const H=Math.min(T.end,r)-Math.max(T.start,t);if(H>0)y+=H}c=v(Math.min(100,y/s*100))}let p=null;let h=null;let f=null;let l=[];let u=0;if(e.loaf){let y=0;let T=0;let H=0;const te=new Map;for(const S of e.loaf){if(S.startTime>=t&&S.startTime<=r&&S.startTime+S.duration>r)u++;if(S.startTime<t||S.startTime+S.duration>r)continue;y+=S.blockingDuration;if(S.styleAndLayoutStart>S.startTime)T+=Math.max(0,S.startTime+S.duration-S.styleAndLayoutStart);for(const d of S.scripts){H+=d.forced;const M=te.get(d.name)??{ms:0,count:0};M.ms+=d.duration;M.count++;te.set(d.name,M)}}p=v(y);h=v(T);f=v(H);l=[...te.entries()].map(([S,d])=>({name:S,ms:v(d.ms),count:d.count})).sort((S,d)=>d.ms-S.ms).slice(0,5)}let g=null;if(e.shifts){let y=0;for(const T of e.shifts)if(!T.hadRecentInput&&T.startTime>=t&&T.startTime<=r)y+=T.value;g=Math.round(y*1e3)/1e3}let x=null;let E=null;if(e.events){const y=Ae(e.events.filter(T=>T.startTime>=t&&T.startTime<=r));x=new Set(y.map(T=>T.interactionId)).size;for(const T of y)if(!E||T.duration>E.duration)E=T}const $=E;const R=e.frames;const I=[...(e.clicks??[]).map(y=>y.t),...(e.keys??[]).map(y=>y.t)];const ee=I.length?Math.max(...I):null;const re=ee==null||R.filter(y=>y>ee).length>=2;const L=R.length===0?s:Math.max(0,R[0]-t,r-R[R.length-1]);return{edgeSilenceMs:v(L),frameGapCount:n.length,inputCaptureComplete:re,resized:Boolean(e.resized),interactions:x,worstInteractionMs:$?v($.duration):null,worstInputDelayMs:$?v(Math.max(0,$.processingStart-$.startTime)):null,worstProcessingMs:$?v(Math.max(0,$.processingEnd-$.processingStart)):null,worstPresentationMs:$?v(Math.max(0,$.startTime+$.duration-$.processingEnd)):null,fps:v(e.frames.length/s*1e3),frameGapP95Ms:a==null?null:v(a),frameGapMaxMs:n.length?v(Math.max(...n)):null,longFrames:n.filter(y=>y>i*1.5).length,longTaskPct:c,loafBlockingMs:p,styleLayoutMs:h,forcedLayoutMs:f,topScripts:l,loafCutOff:u,layoutShift:g,domNodesStart:e.domStart,domNodesEnd:e.domEnd}}function Fe(e,o,t){const r=a=>a in e&&a in o?o[a]-e[a]:null;const s=a=>{const c=r(a);return c==null?null:v(c*1e3)};const n=s("TaskDuration");const i=s("Timestamp")??t;return{mainThreadPct:n==null?null:v(n/Math.max(1,i)*100),scriptMs:s("ScriptDuration"),styleMs:s("RecalcStyleDuration"),layoutMs:s("LayoutDuration"),layoutCount:r("LayoutCount"),styleCount:r("RecalcStyleCount"),heapMb:"JSHeapUsedSize"in o?v(o.JSHeapUsedSize/(1024*1024)):null}}function Ne(e,o){const t=[];if(e.droppedPct!=null&&e.droppedPct>=5)t.push(`${e.droppedPct}% of frames dropped or partial`);if(e.fps!=null&&e.fps<o*.95)t.push("Low main-thread frame rate");if(e.frameGapCount&&e.longFrames/e.frameGapCount>=.02)t.push("Frequent long frames");const r=Math.max(e.frameGapMaxMs??0,e.edgeSilenceMs??0);if(r>=100)t.push(`Freeze of ${Math.round(r)} ms`);if(e.mainThreadPct!=null&&e.mainThreadPct>=80)t.push("Main thread near full");if(e.longTaskPct!=null&&e.longTaskPct>=20)t.push("Long tasks block the main thread");if(e.forcedLayoutMs!=null&&e.forcedLayoutMs>=50)t.push(`Forced layout in scripts (${Math.round(e.forcedLayoutMs)} ms)`);if(e.layoutShift!=null&&e.layoutShift>=.1)t.push(`Layout shifts (${e.layoutShift})`);if(e.worstInteractionMs!=null&&e.worstInteractionMs>=200){t.push(`Slow response to input (${Math.round(e.worstInteractionMs)} ms)`)}return t}function fe(e,o){const t=e.filter(c=>!c.failed&&c.fps!=null);const r=[...t].sort((c,p)=>(c.fps??0)-(p.fps??0));const s=t.filter(c=>c.droppedPct!=null).length;const n=t.length>0&&s===t.length;const i=n?[...t].sort((c,p)=>c.droppedPct-p.droppedPct):r;const a=i.length?i[Math.floor((i.length-1)/2)]:null;return{caseName:e[0]?.caseName??"",cpu:e[0]?.cpu??1,validRuns:t.length,plannedRuns:e.length,isBaseline:false,deltaDroppedPct:null,tracedRuns:s,...(()=>{const c=n?t.map(h=>h.droppedPct):[];const p=t.map(h=>h.worstInteractionMs).filter(h=>h!=null);return{droppedMin:c.length?Math.min(...c):null,droppedMax:c.length?Math.max(...c):null,inputMin:p.length?Math.min(...p):null,inputMax:p.length?Math.max(...p):null}})(),runs:e,median:a,fpsMin:r.length?r[0].fps:null,fpsMax:r.length?r[r.length-1].fps:null,flags:a?Ne(n?a:{...a,droppedPct:null},o):[]}}var De="Playwright isn't installed in this project. Install it, then run again:\n npm i -D playwright && npx playwright install chromium";async function it(e){const o=Ke(ue(e,"noop.js"));for(const t of["playwright","playwright-core"]){let r;try{r=o.resolve(t)}catch{continue}const s=await import(et(r).href);const n=s.chromium??s.default?.chromium;if(n)return n}throw new Error(`${De}
|
|
139
|
+
(Searched from ${e}. Pass projectRoot to look elsewhere.)`)}async function Y(e,o,t){let r;const s=new Promise(n=>{r=setTimeout(()=>n("timeout"),o)});try{const n=await Promise.race([e,s]);if(n==="timeout"){e.catch(()=>{});return await t()}return n}finally{clearTimeout(r)}}function lt(e){try{return be("git",["rev-parse","HEAD"],{cwd:e,stdio:["ignore","pipe","ignore"],timeout:3e3}).toString().trim()}catch{return null}}function ct(e){try{const o=be("git",["status","--porcelain"],{cwd:e,stdio:["ignore","pipe","ignore"],timeout:5e3});return o.toString().trim().length>0}catch{return null}}async function K(e,o){if(!e)return true;return Y(e.close().then(()=>true,()=>false),o,async()=>false)}function Be(e){if(!e.cases?.length)throw new Error("Give at least one case.");const o=new Set;for(const i of e.cases){if(!i.name?.trim())throw new Error("Every case needs a name.");if(o.has(i.name))throw new Error(`Two cases are named "${i.name}". Give each case its own name.`);o.add(i.name)}const t=(i,a,c,p)=>{if(i==null)return;if(!Number.isInteger(i)||i<c||i>p)throw new Error(`${a} must be a whole number from ${c} to ${p}.`)};const r=(i,a,c)=>{if(i==null)return;if(!Number.isFinite(i)||i<c)throw new Error(`${a} must be a number of at least ${c}.`)};const s=(i,a,c,p)=>{if(i==null)return;if(!Number.isFinite(i)||i<c||i>p)throw new Error(`${a} must be from ${c} to ${p}.`)};t(e.runsPerCase,"runsPerCase",1,10);s(e.durationMs,"durationMs",500,12e4);s(e.settleMs,"settleMs",0,6e4);s(e.refreshHz,"refreshHz",1,500);const n=e.cpuSlowdown??[];for(const i of n)s(i,"each cpuSlowdown rate",1,20);if(new Set(n).size!==n.length)throw new Error("cpuSlowdown has the same rate twice.");if(e.viewport){t(e.viewport.width,"viewport.width",200,8e3);t(e.viewport.height,"viewport.height",200,8e3);s(e.viewport.deviceScaleFactor,"viewport.deviceScaleFactor",.5,4)}t(e.extraRoundsWhenClose,"extraRoundsWhenClose",0,10);s(e.maxBatchMs,"maxBatchMs",1e4,6*60*6e4);for(const[i,a]of Object.entries(e.budgets??{}))s(a,`budgets.${i}`,0,1e9);for(const i of e.steps??[]){if("wait"in i)s(i.wait,"a wait step",0,6e4);if("scroll"in i)s(i.scroll,"a scroll step",-1e5,1e5)}new URL(e.url)}function se(e){return e.replace(/\u001b\[[0-9;]*m/g,"").split("\n")[0].trim().slice(0,160)}var ut=["disabled-by-default-devtools.timeline.frame","blink.user_timing"];var dt=["devtools.timeline","disabled-by-default-devtools.timeline","disabled-by-default-devtools.timeline.frame","blink.user_timing","loading","latencyInfo","v8.execute"];var he=15e7;var pe=e=>new Promise(o=>setTimeout(o,e));async function Ie(e,o){const t=new Map;for(const r of o){if("expect"in r)continue;const s="click"in r?r.click:"type"in r?r.type.selector:null;if(!s||t.has(s))continue;const n=await e.$(s);const i=n?await n.boundingBox():null;if(!i)throw new Error(`step target ${s} isn't on the page (or isn't visible)`);t.set(s,{x:i.x+i.width/2,y:i.y+i.height/2})}return t}async function ft(e,o,t){for(const r of o){if("click"in r){const s=t.get(r.click);await e.mouse.click(s.x,s.y)}else if("press"in r)await e.keyboard.press(r.press);else if("type"in r){const s=t.get(r.type.selector);await e.mouse.click(s.x,s.y);await e.keyboard.type(r.type.text)}else if("scroll"in r)await e.mouse.wheel(0,r.scroll);else if("wait"in r)await pe(r.wait)}}function ze(e,o,t=[]){const r=[...o].sort((h,f)=>h.t-f.t);const s=[...t].sort((h,f)=>h.t-f.t);let n=0;let i=0;let a=-Infinity;const c=h=>{while(n<r.length){const f=r[n++];if(f.t>=a&&f.hit.includes(h)){a=f.t;return true}}return false};const p=h=>{while(i<s.length){const f=s[i++];if(f.t>=a&&Ce(h,f)){a=f.t;return true}}return false};for(const[h,f]of e.entries()){if("click"in f&&!c(f.click)){return`step ${h+1} (click ${f.click}) has no real click on its target, in order (moved, covered, or ignored)`}if("type"in f){if(!c(f.type.selector))return`step ${h+1} (type into ${f.type.selector}) has no real click on its target`;for(const l of f.type.text){if(!p(l))return`step ${h+1} (type "${f.type.text}") didn't deliver the key "${l}"`}}if("press"in f&&!p(f.press))return`step ${h+1} (press ${f.press}) didn't deliver that key`}return null}async function ht(e,o){for(const t of o){if(!("expect"in t))continue;const{selector:r,text:s}=t.expect;const n=await e.evaluate(`(() => { const n = document.querySelector(${JSON.stringify(r)}); if (!n) return false; ${s==null?"return true;":`return (n.textContent || "").includes(${JSON.stringify(s)});`} })()`);if(n)return s==null?r:`${r} contains "${s}"`}return null}async function pt(e,o){for(const[t,r]of o){const s=await e.$(t);const n=s?await s.boundingBox():null;if(!n)return`step target ${t} was gone after the run`;const i=n.x+n.width/2;const a=n.y+n.height/2;if(Math.abs(i-r.x)>4||Math.abs(a-r.y)>4){return`step target ${t} moved during the run, so a click may have missed it`}}return null}function Oe(e){for(const o of e){if(!o.found)return`expected ${o.selector} at the end of the run, but it isn't there`;const t=o.matched??(o.text==null||(o.content??"").includes(o.text));if(!t){return`expected ${o.selector} to contain "${o.text}" at the end of the run, got "${(o.content??"").slice(0,60)}"`}}return null}async function je(e){const{metrics:o}=await e.send("Performance.getMetrics");return Object.fromEntries(o.map(t=>[t.name,t.value]))}async function mt(e,o=()=>{}){Be(e);const t=Ge();const r={browserLeftRunning:false};try{return await wt(e,o,r)}finally{t(r.browserLeftRunning)}}var Z=ue(Ze(),"buoy-web-bench.lock");var me=false;function Ge(){if(me){throw new Error("A web benchmark is already running in this process (or left a stuck browser). Wait, or restart the MCP server.")}const e=`${process.pid}:${Date.now()}:${Math.random().toString(36).slice(2)}`;const o=JSON.stringify({pid:process.pid,token:e,startedAt:new Date().toISOString()});const t=()=>{const n=`${Z}.${e.replace(/[^\w]/g,"")}.tmp`;try{Te(n,o);Se(n,Z);return true}catch{return false}finally{try{X(n)}catch{}}};const r=()=>{try{return JSON.parse(Ve(Z,"utf8"))}catch{return null}};const s=n=>{if(!n)return false;try{process.kill(n,0);return true}catch{return false}};if(!t()){const n=r();if(!n)throw new Error("Another web benchmark is starting. Wait for it to finish.");if(s(n.pid)){throw new Error(`Another web benchmark is running (pid ${n.pid}, since ${n.startedAt}). Two at once would skew both; wait for it to finish.`)}const i=`${Z}.cleanup`;let a=null;try{if(Date.now()-ve(i).mtimeMs>3e4){const c=`${i}.${e.replace(/[^\w]/g,"")}.old`;Xe(i,c);if(Date.now()-ve(c).mtimeMs>3e4)X(c);else{try{Se(c,i)}catch{}X(c)}}}catch{}try{a=ke(i,"wx")}catch{throw new Error("Another web benchmark is clearing an old lock. Try again in a moment.")}try{const c=r();if(c?.token===n.token)X(Z);if(!t())throw new Error("Another web benchmark just started. Wait for it to finish.")}finally{$e(a);try{X(i)}catch{}}}me=true;return(n=false)=>{if(n)return;me=false;if(r()?.token===e){try{X(Z)}catch{}}}}async function wt(e,o,t){const r=e.runsPerCase??3;const s=Math.max(500,e.durationMs??5e3);const n=Math.max(0,e.settleMs??1e3);const i=e.frameTrace!==false;const a=(e.cpuSlowdown?.length?e.cpuSlowdown:[1]).map(d=>Math.max(1,d));let c=e.refreshHz??60;const p={width:e.viewport?.width??1280,height:e.viewport?.height??800,deviceScaleFactor:e.viewport?.deviceScaleFactor??1};const h=[];const f=[];if(r<2)h.push("runsPerCase=1 gives no spread; use 3 or more before choosing.");const l=await it(e.projectRoot??process.cwd());const u=await l.launch({headless:!e.headed});const g=[];const x=[];const E=Date.now();const $=new Date(E).toISOString();const R=e.maxBatchMs??30*6e4;let I=false;let ee=false;const re={commit:lt(e.projectRoot??process.cwd()),dirty:ct(e.projectRoot??process.cwd())};try{const d={viewport:{width:p.width,height:p.height},deviceScaleFactor:p.deviceScaleFactor};const M=await Y(u.newContext(d),3e4,async()=>{t.browserLeftRunning=true;throw new Error("Chromium didn't open a page in 30 s. Restart the MCP server and try again.")});const _=3e4+15e3+n+s+6e4;const Q=async(b,m,k,C)=>{const A={};return Y(F(A,b,m,k,C),_,async()=>{A.cancelled=true;if(!A.ctx)I=true;else if(!await K(A.ctx,1e4))I=true;return{...U(b.name,m,k),failed:`run took over ${Math.round(_/1e3)} s (the page may be stuck in a loop)`}})};const U=(b,m,k)=>({caseName:b,cpu:m,round:k,fps:null,frameGapP95Ms:null,frameGapMaxMs:null,longFrames:0,longTaskPct:null,loafBlockingMs:null,styleLayoutMs:null,forcedLayoutMs:null,topScripts:[],layoutShift:null,domNodesStart:null,domNodesEnd:null,mainThreadPct:null,scriptMs:null,styleMs:null,layoutMs:null,layoutCount:null,styleCount:null,heapMb:null,pageErrors:[]});const F=async(b,m,k,C,A)=>{const q=await u.newContext(d);b.ctx=q;if(b.cancelled){await K(q,1e4);throw new Error("run was cancelled during setup")}const w=await q.newPage();const z=[];w.on("pageerror",P=>z.push(String(P?.message??P)));const N={...U(m.name,k,C),pageErrors:z};try{const P=await q.newCDPSession(w);await P.send("Performance.enable",{timeDomain:"timeTicks"});if(k>1)await P.send("Emulation.setCPUThrottlingRate",{rate:k});const ae=await w.goto(Re(e.url,m,e.path),{waitUntil:"load",timeout:3e4});if(ae&&ae.status()>=400)return{...N,failed:`HTTP ${ae.status()}`};if(e.readySelector)await w.waitForSelector(e.readySelector,{state:"attached",timeout:15e3});await pe(n);const ge=A||i;if(ge){await P.send("Tracing.start",{transferMode:"ReturnAsStream",categories:(A?dt:ut).join(",")})}const oe=e.steps?.length?await Ie(w,e.steps):new Map;if(e.steps?.length){const J=await ht(w,e.steps);if(J)return{...N,failed:`expect ${J} already held before the steps, so it can't prove they worked`};const W=[...oe.keys()];const j=e.steps.flatMap(V=>"expect"in V?[V.expect]:[]);await w.evaluate(`window.__buoyBenchClickTargets = ${JSON.stringify(W)}; window.__buoyBenchExpects = ${JSON.stringify(j)}; true`)}const ie=await je(P);await w.evaluate(tt);const ye=Date.now();if(e.steps?.length)await ft(w,e.steps,oe);const Me=s-(Date.now()-ye);if(Me>0)await pe(Me);await w.evaluate(nt);const le=await je(P);const Je=Date.now()-ye;const O=await w.evaluate(st);let D=null;if(ge){const J=new Promise(B=>P.on("Tracing.tracingComplete",ne=>B(ne.stream)));await P.send("Tracing.end");const W=await J;const j=A?ke(A,"w"):null;const V=[];let ce=0;try{for(;;){const B=await P.send("IO.read",{handle:W});const ne=B.base64Encoded?Buffer.from(B.data,"base64").toString("utf8"):B.data;ce+=ne.length;if(j!=null)Ye(j,ne);if(ce<=he)V.push(ne);else V.length=0;if(B.eof)break}}finally{await P.send("IO.close",{handle:W}).catch(()=>{});if(j!=null)$e(j)}if(A)f.push(A);if(ce>he){h.push(`Trace for ${m.name} was over ${Math.round(he/1e6)} MB, so its frames weren't counted. A page that busy shows its problem in the table already.`)}else{try{const B=JSON.parse(V.join(""));D=_e(Array.isArray(B)?B:B.traceEvents??[])}catch{D=null}}}if(!O)return{...N,failed:"probe returned nothing (page navigated away?)"};if(O.hidden)return{...N,failed:"page was hidden during the run"};if(O.resized)return{...N,failed:"the window size or zoom changed during the run"};if(z.length&&!e.allowPageErrors){return{...N,failed:`page error: ${se(z[0])}`}}if(e.steps?.length){const J=ze(e.steps,O.clicks??[],O.keys??[]);if(J)return{...N,failed:J};const W=Oe(O.expectResults??[]);if(W)return{...N,failed:W};const j=await pt(w,oe);if(j)return{...N,failed:j}}const We="Timestamp"in ie&&"Timestamp"in le?v((le.Timestamp-ie.Timestamp)*1e3):null;return{...N,...Le(O,c),...Fe(ie,le,Je),probeSpanMs:v(O.end-O.start),cdpSpanMs:We,shownFps:D?.shownFps??null,droppedFrames:D?.faults??null,frameCounts:D?{full:D.full,partial:D.partial,dropped:D.dropped,faults:D.faults}:null,droppedPct:D?.droppedPct??null}}catch(P){return{...N,failed:se(P?.message??String(P))}}finally{await K(w,5e3);if(!await K(q,1e4))I=true}};if(e.refreshHz==null){const b=await Y(M.newPage(),15e3,async()=>{throw new Error("Chromium didn't open the calibration page in 15 s.")});try{await Y(b.goto("about:blank"),15e3,async()=>null);const m=await Y(b.evaluate(rt),5e3,async()=>{throw new Error("idle rate check timed out")});c=Pe(m);o(`idle frame rate ${m.toFixed(1)} \u2192 ${c} Hz`)}catch{h.push("Couldn't measure the idle frame rate; frame budgets assume 60 Hz.")}finally{await K(b,5e3)}}o("warmup load");await Q(e.cases[0],1,-1);const G=async(b,m,k,C)=>{if(I){g.push({...U(b.name,m,k),failed:"an earlier run left the browser stuck; batch stopped"});return}if(Date.now()-E>R){g.push({...U(b.name,m,k),failed:"batch time limit reached; run skipped"});return}o(C);x.push({cpu:m,round:k,caseName:b.name});g.push(await Q(b,m,k))};for(const b of a){for(let m=0;m<r;m++){const k=de(e.cases,2654435769^m*7919+b);for(const C of k)await G(C,b,m,`cpu ${b}x \xB7 round ${m+1}/${r} \xB7 ${C.name}`)}for(let m=0;m<(e.extraRoundsWhenClose??0);m++){const k=e.cases.map(w=>fe(g.filter(z=>z.cpu===b&&z.caseName===w.name),c));for(const w of k)w.control=e.cases.find(z=>z.name===w.caseName)?.control===true;const C=new Set([...we(k).flat(),...k.filter(w=>!w.control&&w.validRuns<2&&w.plannedRuns>0).map(w=>w.caseName)]);if(C.size===0)break;const A=r+m;const q=de(e.cases.filter(w=>C.has(w.name)),20973^A*7919+b);for(const w of q)await G(w,b,A,`cpu ${b}x \xB7 extra round ${m+1} (close call) \xB7 ${w.name}`)}}if(e.traceDir){Qe(e.traceDir,{recursive:true});for(const[b,m]of e.cases.entries()){const k=ue(e.traceDir,`${String(b+1).padStart(2,"0")}-${m.name.replace(/[^\w.-]+/g,"_")}.json`);if(I||Date.now()-E>R){h.push(`Trace run for ${m.name} skipped (batch time limit or a stuck browser).`);continue}o(`trace \xB7 ${m.name}`);const C=await Q(m,a[0],-1,k);if(C.failed)h.push(`Trace run for ${m.name} failed: ${C.failed}`)}}await K(M,1e4)}finally{const d=await K(u,15e3);t.browserLeftRunning=!d;if(!d){ee=true;h.push("Chromium didn't close in 15 s and may still be running. The benchmark lock stays held; restart the MCP server before the next batch.")}}const L=[];for(const d of a){for(const M of e.cases){L.push(fe(g.filter(_=>_.cpu===d&&_.caseName===M.name),c))}}for(const d of L)d.control=e.cases.find(M=>M.name===d.caseName)?.control===true;for(const d of a){const M=L.filter(F=>F.cpu===d);const _=M.find(F=>!F.control);if(!_)continue;_.isBaseline=true;const Q=F=>F.droppedMin!=null?F.median?.droppedPct??null:null;const U=Q(_);for(const F of M.filter(G=>G!==_&&!G.control)){const G=Q(F);F.deltaDroppedPct=U!=null&&G!=null?v(G-U):null}}if(e.allowPageErrors&&g.some(d=>d.pageErrors.length)){h.push("Some runs threw page errors (kept because allowPageErrors is on).")}if(I)h.push("A browser context wouldn't close, so the batch stopped early. Restart and run again.");if(e.budgets)for(const d of L)d.budget=xe(d,e.budgets,e.steps??[]);const y=L.filter(d=>d.median).length;const T=L.every(d=>d.validRuns===d.plannedRuns);const H=y===0?"failed":y<L.length||!T?"partial":"ok";const te=L.filter(d=>d.median&&d.validRuns>0&&d.validRuns<d.plannedRuns);for(const d of te){const M=Array.from(new Set(d.runs.filter(_=>_.failed).map(_=>_.failed)));h.push(`${d.caseName} (CPU ${d.cpu}x): ${d.plannedRuns-d.validRuns} of ${d.plannedRuns} runs failed: ${M.join("; ")}`)}for(const d of L){const M=d.median;if(M?.probeSpanMs&&M.cdpSpanMs&&Math.abs(M.cdpSpanMs-M.probeSpanMs)/M.probeSpanMs>.15){h.push(`${d.caseName} (CPU ${d.cpu}x): Chrome's counters cover ${Math.round(M.cdpSpanMs)} ms but frames cover ${Math.round(M.probeSpanMs)} ms, so its cost columns include extra time.`)}if(M?.probeSpanMs!=null&&M.probeSpanMs<s*.8){h.push(`${d.caseName} (CPU ${d.cpu}x) recorded ${Math.round(M.probeSpanMs)} ms, not the ${s} ms asked for.`)}}const S={status:H,hasSteps:Boolean(e.steps?.length),browserLeftRunning:ee,replay:{startedAt:$,...re,runOrder:x},url:e.url,browser:`Chromium ${u.version()}${e.headed?"":" (headless)"}`,viewport:p,refreshHz:c,durationMs:s,runsPerCase:r,results:L,traces:f,warnings:h};if(e.outFile){try{Te(e.outFile,JSON.stringify({options:e,result:S},null,2))}catch(d){S.warnings.push(`Couldn't write outFile ${e.outFile}: ${se(d?.message??String(d))}`)}}return S}var He=1.5;var Ue=2;function we(e){const o=e.filter(n=>!n.control&&n.median&&n.validRuns>1);const t=o.filter(n=>n.droppedMin!=null);const r=[];if(t.length>=2&&t.length===o.length){const n=[...t].sort((i,a)=>i.median.droppedPct-a.median.droppedPct);for(let i=1;i<n.length;i++){const[a,c]=[n[i-1],n[i]];const p=c.median.droppedPct-a.median.droppedPct<=He;if(c.droppedMin<=a.droppedMax||p)r.push([a.caseName,c.caseName])}return r}if(t.length>0)return r;const s=o.filter(n=>n.median.fps!=null).sort((n,i)=>i.median.fps-n.median.fps);for(let n=1;n<s.length;n++){const[i,a]=[s[n-1],s[n]];const c=i.median.fps-a.median.fps<=Ue;if((a.fpsMax??0)>=(i.fpsMin??0)||c)r.push([i.caseName,a.caseName])}return r}function qe(e){const o=e.filter(a=>!a.control&&a.median);const t=[];const r=o.filter(a=>a.validRuns<2);if(r.length)t.push(`**Too few runs to rank:** ${r.map(a=>a.caseName).join(", ")} (need 2 or more valid runs).`);const s=o.filter(a=>a.validRuns>1);const n=s.filter(a=>a.droppedMin!=null);if(n.length>0&&n.length<s.length){t.push(`**Not enough traced runs to compare smoothness:** ${s.filter(a=>!n.includes(a)).map(a=>`${a.caseName} (${a.tracedRuns}/${a.validRuns} traced)`).join(", ")}.`);return t.join("\n")}const i=new Map(s.map(a=>[a.caseName,a]));for(const[a,c]of we(e)){const p=i.get(a);const h=i.get(c);t.push(n.length?`**Too close to call:** ${a} (${p.droppedMin}\u2013${p.droppedMax}% dropped) and ${c} (${h.droppedMin}\u2013${h.droppedMax}%) overlap or sit within ${He} pp. No clear winner between them; more runs may separate them.`:`**Too close to call:** ${a} and ${c} overlap or sit within ${Ue} FPS. No clear winner between them; more runs may separate them.`)}return t.length?t.join("\n"):null}function gt(e){const o=(a,c=1)=>a==null?"\u2014":a.toFixed(c);const t=[];t.push(`### Web benchmark \xB7 ${e.url}`);t.push(`${e.browser} \xB7 ${e.viewport.width}\xD7${e.viewport.height} @${e.viewport.deviceScaleFactor}x \xB7 ${e.runsPerCase} runs${e.results.some(a=>a.plannedRuns>e.runsPerCase)?" (more for close calls)":""} \xD7 ${e.durationMs/1e3}s per case, fresh browser context each run, case order shuffled each round.`);const r=e.results.map(a=>a.median?.probeSpanMs).filter(a=>a!=null);const s=e.results.map(a=>a.median?.cdpSpanMs).filter(a=>a!=null);const n=a=>`${(Math.min(...a)/1e3).toFixed(2)}\u2013${(Math.max(...a)/1e3).toFixed(2)} s`;if(r.length){t.push(`Recorded: frames over ${n(r)}${s.length?`; cost columns (Chrome's counters) over ${n(s)}`:""}, not the requested time.`)}if(e.replay?.dirty)t.push(`Note: the project had uncommitted changes, so commit ${e.replay.commit?.slice(0,10)??"?"} alone doesn't describe the code that ran.`);t.push("");t.push(`**How to read this.** Dropped % is the smoothness number: frames Chrome dropped or only partly produced that it says hurt smoothness, as a share of the frames it wanted, from its own verdicts in a trace. Rank on it first, and only across variants doing the same work. Shown FPS counts frames Chrome produced (headless Chrome displays nothing), so an animation that changes less often needs fewer; don't compare it across variants that update at different rates. Main-thread FPS and frame gaps come from requestAnimationFrame. Main thread % is Chrome's task time for the run. Desktop numbers, even with CPU slowdown, don't stand in for a real phone's GPU, memory or heat.`);const i=Array.from(new Set(e.results.map(a=>a.cpu)));for(const a of i){t.push("");t.push(a===1?`#### No CPU slowdown`:`#### CPU slowed ${a}x`);t.push("");t.push(`| Case | Runs | Shown FPS | Dropped % | Main-thread FPS (range) | p95 gap ms | Worst gap ms | Main thread % | Script ms | Style ms | Layout ms | Layouts | DOM nodes | JS heap MB | Flags |`);t.push(`|------|-----:|----------:|----------:|------------------------:|-----------:|-------------:|--------------:|----------:|---------:|----------:|--------:|----------:|--------:|-------|`);for(const l of e.results.filter(u=>u.cpu===a)){const u=l.median;if(!u){const E=l.runs.find($=>$.failed)?.failed??"no valid runs";t.push(`| ${l.caseName} | 0/${l.plannedRuns} | \u2014 | \u2014 | \u2014 | \u2014 | \u2014 | \u2014 | \u2014 | \u2014 | \u2014 | \u2014 | \u2014 | \u2014 | \u274C FAILED (${E}) |`);continue}const g=l.fpsMin!=null&&l.fpsMax!=null&&l.validRuns>1?` (${o(l.fpsMin)}\u2013${o(l.fpsMax)})`:"";const x=l.flags.length?`\u26A0\uFE0F ${l.flags.join("; ")}`:"no flags";t.push(`| ${l.isBaseline?`${l.caseName} (baseline)`:l.control?`${l.caseName} (control)`:l.caseName} | ${l.validRuns}/${l.plannedRuns} | ${o(u.shownFps)} | ${l.droppedMin==null&&l.tracedRuns>0?`\u2014 (${l.tracedRuns}/${l.validRuns} traced)`:o(l.droppedMin==null?null:u.droppedPct)}${l.droppedMin!=null&&l.validRuns>1?` [${l.droppedMin}\u2013${l.droppedMax}]`:""}${l.deltaDroppedPct!=null?` (${l.deltaDroppedPct>0?"+":""}${l.deltaDroppedPct} pp)`:""} | ${o(u.fps)}${g} | ${o(u.frameGapP95Ms)} | ${o(u.frameGapMaxMs)} | ${o(u.mainThreadPct)} | ${o(u.scriptMs,0)} | ${o(u.styleMs,0)} | ${o(u.layoutMs,0)} | ${o(u.layoutCount,0)} | ${o(u.domNodesEnd,0)} | ${o(u.heapMb)} | ${x} |`)}const c=qe(e.results.filter(l=>l.cpu===a));if(c){t.push("");t.push(c)}const p=e.results.filter(l=>l.cpu===a&&l.budget);if(p.length){t.push("");t.push(`Budget:`);for(const l of p){const u=l.budget;const g=[...u.over,...u.unknown.map(E=>`${E} not measured`)].join("; ");const x=l.control?`${l.caseName} (control)`:l.caseName;t.push(`- **${x}**: ${u.meets?"meets every limit":`misses (${g||"no result"})`}`)}}const h=e.results.filter(l=>l.cpu===a&&l.median?.interactions!=null&&(e.hasSteps||l.median.interactions>0)).map(l=>{const u=l.median;const g=l.inputMin!=null&&l.inputMax!=null?` \xB7 slowest across all runs ${l.inputMax} ms (range ${l.inputMin}\u2013${l.inputMax})`:"";const x=l.runs.filter($=>!$.failed&&$.fps!=null&&$.inputCaptureComplete===false).length;const E=x?` \xB7 \u26A0\uFE0F timing incomplete in ${x} run(s): the last input's paint came after the run ended, so its time is unknown (leave more time after the last step)`:"";if(!u.interactions)return`- **${l.caseName}**: middle run had no input entry (inputs under 16 ms aren't reported)${g}${E}`;return`- **${l.caseName}**: middle run: ${u.interactions} reported (16 ms or more), slowest ${u.worstInteractionMs} ms (waiting ${u.worstInputDelayMs} \xB7 handlers ${u.worstProcessingMs} \xB7 to paint ${u.worstPresentationMs})${g}${E}`});if(h.length){t.push("");t.push(`Input response (scripted steps, Event Timing). Inputs under 16 ms aren't reported. Under 200 ms is good.`);t.push(...h)}const f=e.results.filter(l=>l.cpu===a&&l.median&&l.median.topScripts.length).map(l=>`- **${l.caseName}**: ${l.median.topScripts.slice(0,3).map(u=>`${u.name} ${u.ms} ms`).join(", ")}`);if(f.length){t.push("");t.push(`Scripts in slow frames (Long Animation Frames; frames that ran past the end of a run are left out):`);t.push(...f)}}if(e.traces.length){t.push("");t.push(`Chrome traces (open in DevTools \u2192 Performance \u2192 Load profile): ${e.traces.join(", ")}`)}if(e.warnings.length){t.push("");t.push(...e.warnings.map(a=>`\u26A0\uFE0F ${a}`))}return t.join("\n")}export{xe as checkBudgets,Ee as percentile,Pe as snapRefreshRate,de as shuffled,Re as caseUrl,_e as summarizeFrameTrace,Ce as keyMatches,Ae as mergeInteractions,Le as summarizeProbe,Fe as cdpDeltas,Ne as webBenchFlags,fe as aggregateCase,De as PLAYWRIGHT_MISSING,Be as validateWebBenchOptions,se as oneLine,Ie as locateStepTargets,ze as missedInput,Oe as expectFailureFrom,mt as runWebBench,Ge as takeHostLock,we as tiedPairs,qe as closeCall,gt as formatWebBenchMarkdown};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{execFile as p}from"child_process";import{promisify as d}from"util";import{existsSync as l,readFileSync as h}from"fs";import u from"os";import i from"path";var m=d(p);function f(){const n=process.env.BUOY_SIMCAM_DIR;const e=[...n?[i.join(n,"buoycam")]:[],"/Applications/Buoy.app/Contents/Resources/simcam/buoycam",i.join(u.homedir(),"Applications/Buoy.app/Contents/Resources/simcam/buoycam")];let t=__dirname;for(let o=0;o<8;o++){e.push(i.join(t,"apps/desktop/resources/simcam/buoycam"));const a=i.dirname(t);if(a===t)break;t=a}return e}var s=null;function c(){if(s)return s;s=f().find(n=>l(n))??null;return s}async function y(n){const e=c();if(!e){return{ok:false,error:"The simulator camera components were not found. They ship with the Buoy desktop app \u2014 install it, or set BUOY_SIMCAM_DIR to the directory holding `buoycam`."}}try{const{stdout:t}=await m(e,[...n,"--json"],{timeout:3e4});return{ok:true,data:JSON.parse(t)}}catch(t){const o=t.stdout??"";try{return{ok:false,data:JSON.parse(o)}}catch{return{ok:false,error:t.message||"the simulator camera CLI failed"}}}}function g(n){const e=n.filter(r=>r.level==="fail");const t=n.filter(r=>r.level==="warn");if(e.length===0&&t.length===0){return"The simulator camera is healthy \u2014 every check passed."}const o=[];for(const r of[...e,...t]){o.push(`- **${r.name}** (${r.level}): ${r.detail}`);if(r.fix)o.push(` ${r.fix}`)}const a=e.length>0?`${e.length} problem${e.length===1?"":"s"} found.`:`No hard failures, but ${t.length} thing${t.length===1?"":"s"} worth knowing.`;return[a,"",...o].join("\n")}function b(n,e){if(n.length===0){return"No booted simulators.\n\n_Boot one first \u2014 `xcrun simctl boot <udid>`, or open Simulator.app. The camera attaches to a simulator, so nothing else here works until one is running._"}const t=[n.length===1?"1 booted simulator:":`${n.length} booted simulators:`,...n.map(o=>`- **${o.name}** (${o.runtime}) \u2014 \`${o.udid}\``)];if(n.length>1&&e===null){t.push("","_More than one is booted, so pass `udid` to list a specific one's apps \u2014 and to every other camera tool that takes one._");return t.join("\n")}if(e===null){t.push("","_Could not read the installed apps._");return t.join("\n")}if(e.length===0){t.push("","No apps installed on it.");return t.join("\n")}t.push("",`${e.length} installed app${e.length===1?"":"s"}:`,...e.map(o=>`- ${o.name} \u2014 \`${o.bundleId}\``),"","_Pass one of these bundle ids to `camera_launch` to relaunch it with the camera attached._");return t.join("\n")}function _(n,e){const t=[];t.push(n.length?'**Mac cameras** (for `kind: "camera"`):':"**Mac cameras**: none found.");if(n.length){t.push(...n.map(o=>`- ${o.name} \u2014 \`${o.uniqueId}\``))}else{t.push("_If this Mac has a webcam, Buoy has not been granted Camera permission (System Settings \u2192 Privacy & Security \u2192 Camera)._")}t.push("");t.push(e.length?'**Capturable windows** (for `kind: "screen"`, `value: "window:<id>"`):':"**Capturable windows**: none found.");if(e.length){t.push(...e.map(o=>`- ${o.app}${o.title?` \u2014 ${o.title}`:""} \u2014 \`window:${o.id}\``))}else{t.push("_Screen Recording permission is almost certainly missing (System Settings \u2192 Privacy & Security \u2192 Screen & System Audio Recording)._")}return t.join("\n")}function $(){const n=process.env.BUOY_ENTITLEMENT_FILE;if(n)return[n];return[i.join(u.homedir(),"Library/Application Support/Buoy/entitlement.json"),i.join(u.homedir(),"Library/Application Support/buoy-desktop/entitlement.json")]}function k(){for(const n of $()){try{if(!l(n))continue;const e=JSON.parse(h(n,"utf8"));return{tier:e.tier==="pro"||e.tier==="free"?e.tier:"locked",isPro:e.isPro===true&&e.hasDesktopAccess===true&&typeof e.validUntil==="number"&&Number.isFinite(e.validUntil)&&Date.now()<e.validUntil&&typeof e.proValidUntil==="number"&&Number.isFinite(e.proValidUntil)&&Date.now()<e.proValidUntil}}catch{}}return{tier:"locked",isPro:false}}function S(n){return`\`${n}\` is a Buoy Pro feature.
|
|
2
|
+
|
|
3
|
+
The simulator camera itself is free \u2014 the Mac camera, image, video, test-pattern and QR sources all work in the Buoy desktop panel with a Free account. Pro adds the screen region, the non-QR symbologies (PDF417, Aztec, DataMatrix, Code 128), and driving any of it from an agent.
|
|
4
|
+
|
|
5
|
+
_Tell the user to enter a licence in Buoy Desktop, or see https://buoy.gg/pricing. Don't try to work around it \u2014 use the desktop panel by hand instead._`}export{c as cliPath,y as run,g as describeDiagnosis,b as describeDevices,_ as describeInputs,k as readEntitlement,S as proRequired};
|