/** * Canvas liveness from screenshots: a run counts as alive when consecutive * captures keep differing. PNG bytes are hashed directly; no image decoder is * needed (tools/web/lib/image-stats.mjs covers pixel verdicts when a tool needs * them). */ export function bufferHash(buffer) { if (!buffer) return null; let hash = 7; for (let index = 0; index < buffer.length; index += 1) hash = (hash * 31 + buffer[index]) >>> 0; return hash; } export async function snapshot(page) { try { return await page.screenshot(); } catch { return null; } }