From 75dce7bc59ef6c02aa0d0dfa1711125aa40e58a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Tue, 14 Apr 2026 19:48:21 +0200 Subject: [PATCH] fix: format contrast-report.mjs + fix TS window casts in validate --- packages/cli/src/commands/validate.ts | 6 ++--- .../scripts/contrast-report.mjs | 26 ++++++++++--------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/packages/cli/src/commands/validate.ts b/packages/cli/src/commands/validate.ts index c021db83aa..4cfb607805 100644 --- a/packages/cli/src/commands/validate.ts +++ b/packages/cli/src/commands/validate.ts @@ -48,7 +48,7 @@ async function seekTo(page: import("puppeteer-core").Page, time: number): Promis window.__hf.seek(t); return; } - const timelines = (window as Record).__timelines as + const timelines = (window as unknown as Record).__timelines as | Record void }> | undefined; if (timelines) { @@ -74,8 +74,8 @@ async function runContrastAudit(page: import("puppeteer-core").Page): Promise - typeof (window as Record).__contrastAudit === "function" - ? ((window as Record).__contrastAudit as Function)(b64, time) + typeof (window as unknown as Record).__contrastAudit === "function" + ? ((window as unknown as Record).__contrastAudit as Function)(b64, time) : [], screenshot, t, diff --git a/skills/hyperframes-contrast/scripts/contrast-report.mjs b/skills/hyperframes-contrast/scripts/contrast-report.mjs index a7b170129c..121500e417 100644 --- a/skills/hyperframes-contrast/scripts/contrast-report.mjs +++ b/skills/hyperframes-contrast/scripts/contrast-report.mjs @@ -59,8 +59,9 @@ await initializeSession(session); try { const duration = await getCompositionDuration(session); - const times = Array.from({ length: SAMPLES }, (_, i) => - +(((i + 0.5) / SAMPLES) * duration).toFixed(3), + const times = Array.from( + { length: SAMPLES }, + (_, i) => +(((i + 0.5) / SAMPLES) * duration).toFixed(3), ); const allEntries = []; @@ -85,10 +86,7 @@ try { summary: summarize(allEntries), }; - await writeFile( - resolve(OUT_DIR, "contrast-report.json"), - JSON.stringify(report, null, 2), - ); + await writeFile(resolve(OUT_DIR, "contrast-report.json"), JSON.stringify(report, null, 2)); await writeOverlaySprite(overlayFrames, resolve(OUT_DIR, "contrast-overlay.png")); printSummary(report); @@ -122,7 +120,9 @@ async function probeTextElements(session, _t) { let el; while ((el = walker.nextNode())) { // must have direct text - const direct = [...el.childNodes].some((n) => n.nodeType === 3 && n.textContent.trim().length); + const direct = [...el.childNodes].some( + (n) => n.nodeType === 3 && n.textContent.trim().length, + ); if (!direct) continue; const cs = getComputedStyle(el); if (cs.visibility === "hidden" || cs.display === "none") continue; @@ -175,14 +175,18 @@ async function annotateFrame(pngBuf, elements) { function sampleRingMedian(raw, width, height, channels, bbox) { // 4-px ring immediately outside the element bbox. Median of each channel. - const r = [], g = [], b = []; + const r = [], + g = [], + b = []; const x0 = Math.max(0, Math.floor(bbox.x) - 4); const x1 = Math.min(width - 1, Math.ceil(bbox.x + bbox.w) + 4); const y0 = Math.max(0, Math.floor(bbox.y) - 4); const y1 = Math.min(height - 1, Math.ceil(bbox.y + bbox.h) + 4); const pushPixel = (x, y) => { const i = (y * width + x) * channels; - r.push(raw[i]); g.push(raw[i + 1]); b.push(raw[i + 2]); + r.push(raw[i]); + g.push(raw[i + 1]); + b.push(raw[i + 2]); }; for (let x = x0; x <= x1; x++) { pushPixel(x, y0); @@ -301,9 +305,7 @@ function printSummary({ summary, entries }) { if (failAA) { console.log("\nFailures:"); for (const e of entries.filter((x) => !x.wcagAA)) { - console.log( - ` t=${e.time}s ${e.selector.padEnd(24)} ${e.ratio.toFixed(2)}:1 "${e.text}"`, - ); + console.log(` t=${e.time}s ${e.selector.padEnd(24)} ${e.ratio.toFixed(2)}:1 "${e.text}"`); } } }