// Walks every slide and every click step of dist/index.html with network blocked, in both themes, // at 1280x720 and 1920x1080, and fails on: console errors, any network request, missing fonts, // content outside the dome-safe box, clipped text, overlapping text, missing notes, em/en dashes. // Also checks the T toggle, ?theme=, the speaker view, and saves screenshots: // //NN-.png final state of each slide at 1920x1080 // /steps//NN--.png every step at 1280x720 (with --steps) // Usage: node scripts/verify.mjs dist/index.html verify-shots [--steps] import { chromium } from 'playwright' import { mkdirSync, rmSync } from 'node:fs' import { resolve, join } from 'node:path' import { pathToFileURL } from 'node:url' const [file = 'dist/index.html', out = 'verify-shots'] = process.argv.slice(2).filter((a) => !a.startsWith('--')) const allSteps = process.argv.includes('--steps') const url = pathToFileURL(resolve(file)).href const SAFE = { left: 200, right: 1720, top: 100, bottom: 990 } // canvas px (1920x1080) const MIN_FONT = 26 const browser = await chromium.launch({ executablePath: process.env.CHROMIUM_PATH || undefined }) const problems = [] const fail = (msg) => problems.push(msg) async function open(viewport, query, colorScheme = 'dark') { const context = await browser.newContext({ viewport, deviceScaleFactor: 1, colorScheme }) await context.route('**/*', (route) => { const u = route.request().url() if (u.startsWith('file:') || u.startsWith('data:')) return route.continue() fail(`network request: ${u}`) return route.abort() }) const page = await context.newPage() page.on('console', (m) => { if (m.type() === 'error') fail(`console error (${query}): ${m.text()}`) }) page.on('pageerror', (e) => fail(`page error (${query}): ${e.message}`)) await page.goto(`${url}?${query}`) await page.waitForFunction(() => window.__deck?.isReady()) await page.evaluate(() => document.fonts.ready) return { context, page } } // Measures the current state of the current slide. const measure = () => { const section = window.__deck.getCurrentSlide() const box = section.getBoundingClientRect() const scale = box.width / 1920 const toCanvas = (r) => ({ l: (r.left - box.left) / scale, t: (r.top - box.top) / scale, r: (r.right - box.left) / scale, b: (r.bottom - box.top) / scale }) const shown = (el) => { for (let e = el; e && e !== section.parentElement; e = e.parentElement) { const cs = getComputedStyle(e) if (cs.display === 'none' || cs.visibility === 'hidden' || Number(cs.opacity) < 0.05) return false } return true } const issues = [] const texts = [] // WCAG contrast: resolve any CSS color (oklch, color-mix) to sRGB through a canvas. const cv = document.createElement('canvas').getContext('2d', { willReadFrequently: true }) const rgba = (c) => { cv.clearRect(0, 0, 1, 1); cv.fillStyle = '#000'; cv.fillStyle = c; cv.fillRect(0, 0, 1, 1); return [...cv.getImageData(0, 0, 1, 1).data] } const lum = ([r, g, b]) => [r, g, b].map((v) => { v /= 255; return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4 }).reduce((s, v, i) => s + v * [0.2126, 0.7152, 0.0722][i], 0) const page = rgba(getComputedStyle(document.documentElement).getPropertyValue('--page')) const bgOf = (el) => { for (let e = el; e && e !== document.documentElement; e = e.parentElement) { const c = rgba(getComputedStyle(e).backgroundColor) if (c[3] > 200) return c } return page } window.__minContrast ??= 99 for (const el of section.querySelectorAll('*')) { if (el.closest('aside.notes') || el.matches('style, script, .step-marker')) continue const hasText = [...el.childNodes].some((n) => n.nodeType === 3 && n.textContent.trim()) const isMedia = el.matches('img, svg, canvas') if (!hasText && !isMedia) continue // Texture (the title crowd canvas, slide 12's agent tracks) may bleed to the edges by design; it carries no content. if (el.closest('.texture')) continue if (el.closest('svg') && el.tagName.toLowerCase() !== 'svg' && el.tagName.toLowerCase() !== 'text') continue if (!shown(el)) continue const rect = el.getBoundingClientRect() if (rect.width < 2 || rect.height < 2) continue const c = toCanvas(rect) const label = (el.textContent.trim() || el.getAttribute('alt') || el.className?.baseVal || el.className || el.tagName).toString().slice(0, 40) if (c.l < 200 - 1 || c.r > 1720 + 1 || c.t < 100 - 1 || c.b > 990 + 1) issues.push(`outside safe box: "${label}" [${c.l.toFixed(0)},${c.t.toFixed(0)} to ${c.r.toFixed(0)},${c.b.toFixed(0)}]`) if (hasText) { const fs = parseFloat(getComputedStyle(el).fontSize) if (fs < 26) issues.push(`small text ${fs}px: "${label}"`) { const fg = rgba(getComputedStyle(el).color) const bg = bgOf(el) const [a, b] = [lum(fg), lum(bg)].sort((x, y) => y - x) const ratio = (a + 0.05) / (b + 0.05) if (!el.closest('[data-chrome]')) window.__minContrast = Math.min(window.__minContrast, ratio) // [data-chrome]: faithful app chrome copied from the original screenshots (date labels, input placeholder), exempt from the contrast floor. if (ratio < 4.5 && !el.closest('[data-chrome]')) issues.push(`low contrast ${ratio.toFixed(2)}:1: "${label}"`) } if (el.scrollWidth > el.clientWidth + 2 && getComputedStyle(el).overflow !== 'visible') issues.push(`clipped text: "${label}"`) // Text must sit inside every clipping ancestor. for (let a = el.parentElement; a && a !== section; a = a.parentElement) { const ov = getComputedStyle(a).overflow if (ov === 'visible') continue const ar = toCanvas(a.getBoundingClientRect()) if (c.l < ar.l - 1 || c.r > ar.r + 1 || c.t < ar.t - 1 || c.b > ar.b + 1) issues.push(`text cut off by ${a.className || a.tagName}: "${label}"`) break } // Rotated boxes over-report overlap; skip text inside a rotated ancestor. let rotated = false for (let a = el; a && a !== section; a = a.parentElement) if (getComputedStyle(a).rotate !== 'none' && getComputedStyle(a).rotate !== '0deg') rotated = true // Inline text that wraps has one box per line; compare those, not their union. // Hidden text: whatever is on top at the text's centre must be the text itself (or its own box). { const r0 = el.getClientRects()[0] if (r0 && getComputedStyle(el).pointerEvents !== 'none') { const top = document.elementFromPoint(r0.left + r0.width / 2, r0.top + r0.height / 2) if (top && !(top === el || el.contains(top) || top.contains(el))) issues.push(`text hidden under ${top.className?.baseVal ?? top.className ?? top.tagName}: "${label}"`) } } if (!rotated) texts.push({ el, c, label, boxes: [...el.getClientRects()].filter((r) => r.width > 1 && r.height > 1).map(toCanvas) }) } } for (let i = 0; i < texts.length; i++) { for (let j = i + 1; j < texts.length; j++) { const a = texts[i], b = texts[j] if (a.el.contains(b.el) || b.el.contains(a.el)) continue const hit = a.boxes.some((p) => b.boxes.some((q) => Math.min(p.r, q.r) - Math.max(p.l, q.l) > 3 && Math.min(p.b, q.b) - Math.max(p.t, q.t) > 3)) if (hit) issues.push(`overlap: "${a.label}" and "${b.label}"`) } } const text = section.innerText if (/[–—]/.test(text + section.querySelector('aside.notes')?.textContent)) issues.push('em or en dash') const notes = section.querySelector('aside.notes')?.textContent.trim() if (!notes) issues.push('no speaker notes') return { id: section.id, step: Number(section.dataset.step ?? 0), steps: Number(section.dataset.steps ?? 0), issues } } const themes = ['dark', 'light'] const viewports = [{ width: 1280, height: 720 }, { width: 1920, height: 1080 }] rmSync(out, { recursive: true, force: true }) let slideTotal = 0 let beatTotal = 0 for (const theme of themes) { mkdirSync(join(out, theme), { recursive: true }) if (allSteps) mkdirSync(join(out, 'steps', theme), { recursive: true }) for (const viewport of viewports) { const { context, page } = await open(viewport, `theme=${theme}&static`) if ((await page.evaluate(() => document.documentElement.dataset.theme)) !== theme) fail(`?theme=${theme} not applied`) const fontsOk = await page.evaluate(() => document.fonts.check('700 60px "Bricolage Grotesque"') && document.fonts.check('600 44px "Wix Madefor Text"')) if (!fontsOk) fail('embedded fonts not loaded') let index = 0 let beats = 0 const seen = new Set() while (true) { const demoOk = await page.waitForFunction(() => window.__demoSettled(), null, { timeout: 15000 }).then(() => true, () => false) const m = await page.evaluate(measure) if (!demoOk) fail(`${theme} ${viewport.width}x${viewport.height} ${m.id} step ${m.step}: phone demo did not settle`) beats++ for (const issue of m.issues) fail(`${theme} ${viewport.width}x${viewport.height} ${m.id} step ${m.step}: ${issue}`) for (const issue of await page.evaluate(() => { const section = window.__deck.getCurrentSlide() const step = Number(section.dataset.step ?? 0) const nums = (s) => (s.match(/-?\d*\.?\d+/g) ?? []).map(Number) return [...section.querySelectorAll('path[data-morph]')].flatMap((el) => { const want = nums(step >= Number(el.dataset.morph) ? el.dataset.to : el.dataset.from) const got = nums(el.getAttribute('d')) return got.length === want.length && got.every((v, i) => Math.abs(v - want[i]) < 0.01) ? [] : [`path morph not at its end state for beat ${step}`] }) })) fail(`${theme} ${viewport.width}x${viewport.height} ${m.id} step ${m.step}: ${issue}`) if (allSteps && viewport.width === 1280) await page.screenshot({ path: join(out, 'steps', theme, `${String(index + 1).padStart(2, '0')}-${m.id}-${m.step}.png`) }) if (m.step === m.steps) { seen.add(m.id) index++ if (viewport.width === 1920) await page.screenshot({ path: join(out, theme, `${String(index).padStart(2, '0')}-${m.id}.png`) }) } if (await page.evaluate(() => window.__deck.isLastSlide() && !window.__deck.availableFragments().next)) break await page.evaluate(() => window.__deck.next()) await page.waitForTimeout(40) } const minC = await page.evaluate(() => window.__minContrast) console.log(`${theme} ${viewport.width}x${viewport.height}: lowest text contrast ${minC.toFixed(2)}:1`) slideTotal = seen.size beatTotal = beats await context.close() } } // Motion on, T toggle, speaker view. { const { context, page } = await open({ width: 1280, height: 720 }, '') const theme = () => page.evaluate(() => document.documentElement.dataset.theme) // Default follows the OS, live. if ((await theme()) !== 'dark') fail('with a dark OS the deck is not dark') await page.emulateMedia({ colorScheme: 'light' }) await page.waitForTimeout(100) if ((await theme()) !== 'light') fail('the deck did not follow the OS switching to light') await page.emulateMedia({ colorScheme: 'dark' }) await page.waitForTimeout(100) if ((await theme()) !== 'dark') fail('the deck did not follow the OS switching back to dark') await page.keyboard.press('t') if ((await theme()) !== 'light') fail('T did not switch to light') await page.emulateMedia({ colorScheme: 'light' }) await page.emulateMedia({ colorScheme: 'dark' }) await page.waitForTimeout(100) if ((await theme()) !== 'light') fail('a T pick did not stick when the OS changed') await page.keyboard.press('t') if ((await theme()) !== 'dark') fail('T did not switch back to dark') { const lightOs = await open({ width: 1280, height: 720 }, '', 'light') if ((await lightOs.page.evaluate(() => document.documentElement.dataset.theme)) !== 'light') fail('with a light OS the deck is not light') await lightOs.page.evaluate(() => localStorage.setItem('invisible-sw-deck-theme', 'dark')) await lightOs.page.goto(lightOs.page.url().split('?')[0] + '?theme=system') await lightOs.page.waitForFunction(() => window.__deck?.isReady()) if ((await lightOs.page.evaluate(() => [document.documentElement.dataset.theme, localStorage.getItem('invisible-sw-deck-theme')].join())) !== 'light,') fail('?theme=system did not clear the saved pick') await lightOs.context.close() } // Going backward: every slide, entered from the next one with Prev, must appear in its final // state at once (no entry animation or transitions running, widgets settled), and the slide // being left must rewind its entry animation. { const total = await page.evaluate(() => window.__deck.getTotalSlides()) let checked = 0 for (let h = 0; h < total - 1; h++) { await page.evaluate((h) => window.__deck.slide(h + 1, 0, -1), h) await page.waitForTimeout(1600) await page.evaluate(() => window.__deck.prev()) await page.waitForTimeout(90) const r = await page.evaluate(() => { const s = window.__deck.getCurrentSlide() const left = s.nextElementSibling const running = s.getAnimations({ subtree: true }).filter((a) => a.playState === 'running' && a.effect?.getTiming().iterations !== Infinity) const morph = s.querySelector('path[data-morph]') const nums = (x) => (x.match(/-?\d*\.?\d+/g) ?? []).map(Number) const morphEnd = !morph || nums(morph.getAttribute('d')).every((v, i) => Math.abs(v - nums(morph.dataset.to)[i]) < 0.01) const leftHasM = !!left?.querySelector('[data-m]') return { id: s.id, step: Number(s.dataset.step ?? 0), steps: Number(s.dataset.steps ?? 0), running: running.map((a) => a.animationName ?? a.transitionProperty ?? a.constructor.name).slice(0, 4), entry: s.classList.contains('m-go'), morphEnd, rewinding: !leftHasM || left.classList.contains('m-rev'), } }) if (r.step !== r.steps) fail(`back into ${r.id}: landed on beat ${r.step}, not the last beat ${r.steps}`) if (r.running.length) fail(`back into ${r.id}: animations still running on arrival: ${r.running.join(', ')}`) if (r.entry) fail(`back into ${r.id}: the entry animation replayed`) if (!r.morphEnd) fail(`back into ${r.id}: the curve morph replayed`) if (!r.rewinding) fail(`leaving the slide after ${r.id} backward did not rewind its entry`) checked++ } console.log(`backward navigation: ${checked} slides arrive settled; leaving slides rewind`) } // Reflow audit: with motion on, no text may move in layout (offset box, which ignores // transforms) while a slide enters or while a beat plays, and text already on screen must not // shift when a beat adds or removes siblings. Motion must be transforms and opacity only. { const snap = () => page.evaluate(() => { const section = window.__deck.getCurrentSlide() const out = [] for (const el of section.querySelectorAll('*')) { if (!(el instanceof HTMLElement) || el.closest('aside.notes') || el.matches('style, script, .step-marker')) continue if (![...el.childNodes].some((n) => n.nodeType === 3 && n.textContent.trim())) continue let x = 0, y = 0 // Sum offsets up to the section, adding each intermediate offsetParent's border (Chrome makes // a transformed element the offsetParent mid-animation, so borders must be counted). for (let e = el; e && e !== section; e = e.offsetParent) { x += e.offsetLeft y += e.offsetTop if (e.offsetParent && e.offsetParent !== section) { x += e.offsetParent.clientLeft; y += e.offsetParent.clientTop } } out.push({ t: el.textContent.trim().slice(0, 30), box: [x, y, el.offsetWidth, el.offsetHeight] }) } return { id: section.id, step: Number(section.dataset.step ?? 0), out } }) const diff = (a, b, what) => { a.out.forEach((e, i) => { const f = b.out[i] if (!f || f.t !== e.t) return if (e.box[2] === 0 || f.box[2] === 0) return const d = Math.max(...e.box.map((v, k) => Math.abs(v - f.box[k]))) if (d > 1) fail(`reflow jump on ${b.id} ${what}: "${e.t}" moved ${d}px (${e.box.join(',')} -> ${f.box.join(',')})`) }) } const total = await page.evaluate(() => window.__deck.getTotalSlides()) let jumpsChecked = 0 for (let h = 0; h < total; h++) { await page.evaluate((h) => window.__deck.slide(h, 0, -1), h) await page.waitForTimeout(40) const first = await snap() await page.waitForTimeout(3000) let settled = await snap() diff(first, settled, 'entering') jumpsChecked++ const steps = await page.evaluate(() => Number(window.__deck.getCurrentSlide().dataset.steps ?? 0)) for (let k = 1; k <= steps; k++) { await page.evaluate(() => window.__deck.next()) await page.waitForTimeout(40) const early = await snap() await page.waitForTimeout(2000) const late = await snap() diff(settled, early, `beat ${k} start`) diff(early, late, `beat ${k}`) settled = late jumpsChecked++ } } console.log(`reflow audit: ${jumpsChecked} slide entries and beats checked`) } await page.evaluate(() => window.__deck.slide(0)) // Walk with motion on to catch runtime errors in animations. for (let i = 0; i < 80; i++) { await page.keyboard.press('ArrowRight') await page.waitForTimeout(30) } await page.evaluate(() => window.__deck.slide(0)) const [popup] = await Promise.all([context.waitForEvent('page'), page.keyboard.press('s')]) await popup.waitForLoadState() await popup.waitForTimeout(1500) const notesText = await popup.evaluate(() => document.querySelector('.speaker-controls-notes')?.textContent ?? '') if (!/Victoria/.test(notesText)) fail(`speaker view does not show the title notes: ${notesText.slice(0, 80)}`) await context.close() } // PWA: serve the built app the way Kody mounts it (mount stripped), let the service worker // install, then cut the network and make sure the deck (and the speaker view) still load. { const { createServer } = await import('node:http') const router = (await import(new URL('../app/router.ts', import.meta.url).href)).default const mount = '/invisible-software-talk' let hostile = null // 'portal' | '403': what the network serves instead of the deck const server = createServer(async (req, res) => { const url = new URL(req.url, 'http://localhost') if (hostile === 'portal') { res.writeHead(200, { 'content-type': 'text/html' }); return res.end('Venue Wi-Fi

Accept the terms to continue

') } if (hostile === '403') { res.writeHead(403, { 'content-type': 'text/plain' }); return res.end('Forbidden') } if (url.pathname !== mount && !url.pathname.startsWith(`${mount}/`)) { res.writeHead(404); return res.end() } url.pathname = url.pathname.slice(mount.length) || '/' const response = await router.fetch(new Request(url, { method: req.method })) res.writeHead(response.status, Object.fromEntries(response.headers)) res.end(Buffer.from(await response.arrayBuffer())) }) await new Promise((done) => server.listen(0, done)) const origin = `http://localhost:${server.address().port}` // Hashed files are immutable; the page and the worker are revalidated. { const html = await (await fetch(`${origin}${mount}/`)).text() const one = html.match(/c\/img\/[\w.-]+\.[0-9a-f]{8}\.\w+/)?.[0] const head = one && (await fetch(`${origin}${mount}/${one}`)) if (!head?.ok || !/immutable/.test(head.headers.get('cache-control') ?? '')) fail(`hashed asset ${one} is not served immutable`) if (/data:image\/(?:png|jpeg|webp)|data:font\//.test(html.replace(/