// 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'; import { cleanAiProps } from '../src/sitesmith/clean-ai-response'; /** Round 6: the background URL the editor really stores for an AI hero placeholder (apply-time cleaner). */ (window as any).cleanedBgImage = (url: string) => cleanAiProps({ bgImage: url }, 'BackgroundSection').bgImage; (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 t0 = performance.now(); const r = await captureHtml(html, { settleMs: 200, injectFontAwesome: false }); const ms = Math.round(performance.now() - t0); 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, strips: r.strips, cropped: r.cropped, pageHeight: r.pageHeight, bytes: r.blob.size, ms, samples: points.map(([x, y]) => Array.from(ctx.getImageData(x, y, 1, 1).data.slice(0, 3))) }; };