// Bundled by scripts/e2e-capture-fidelity.mjs and run in real Firefox + Chromium. import { captureHtml } from '../src/utils/self-review-capture'; import { sanitizeCaptureHtml } from '../src/utils/sanitize-capture-html'; (window as any).sanitizeCaptureHtml = sanitizeCaptureHtml; /** Capture through the real path, then decode the JPEG and return RGB samples at the given points. */ (window as any).captureAndSample = async (html: string, points: Array<[number, number]>) => { const r = await captureHtml(html, { settleMs: 200, injectFontAwesome: false }); if (!r.ok) return { ok: false, reason: r.reason }; const url = URL.createObjectURL(r.blob); const img = new Image(); await new Promise((res, rej) => { img.onload = () => res(); img.onerror = () => rej(new Error('decode')); img.src = url; }); const c = document.createElement('canvas'); c.width = img.naturalWidth; c.height = img.naturalHeight; const ctx = c.getContext('2d')!; ctx.drawImage(img, 0, 0); URL.revokeObjectURL(url); return { ok: true, w: c.width, h: c.height, samples: points.map(([x, y]) => Array.from(ctx.getImageData(x, y, 1, 1).data.slice(0, 3))) }; };