Files
zeekayandGitHub ea43c5a975 Type lib, scripts, v2, home and app under strict (#8)
* Type scripts under strict

Playwright's API the checks use is declared in host.ts (the package is
the app repo's); caught errors read through why(). tabs-tree.test waits
for the typed tabsTree.

Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk

* Type the shared components under strict

Window globals (__lenis, __hzHold, google) and the two react-dom calls
are declared in components/*.d.ts, since @types/react-dom is not a
dependency and the lockfile is frozen.

Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk

* Type components/v2 under strict

Props, state, refs and DOM events in the 93 v2 files. A2Motion's easing
tuples are as const. Two real bugs: x-archimedes/MaskLines imported a
NoJs that does not exist, and x-hypatia/PinChapters returned the element
from a ref callback, which React 19 reads as a cleanup. AppSheet no
longer sets aria-label to a JSX label.

Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk

* Type components/home under strict

The race, cost and frontier figures, the plan cards, the repository card
and the product stories take Run, Models and Plan types from lib.

Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk

* Type the hero devices and the app routes under strict

HeroScene and its parts describe hero-scenes.json; the [slug] pages take
params as a Promise, and metadata and viewport carry Next's types.

Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk

* Give the integrations previews their Preview type

Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk

* Use the bench Card type for the closing cards

Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk
2026-11-14 01:34:34 -08:00

53 lines
3.4 KiB
TypeScript

// Morph navigation check: click real links and expect a view transition (open for big cards, turn for small links),
// a new page, and the page at the top. Films each click (shots/morph/NN.webm, sheets at 10 frames a second).
// Usage: node scripts/morph.mjs (dev server on :4180)
import fs from 'node:fs';
import { execFileSync } from 'node:child_process';
import puppeteer from 'puppeteer-core';
import { lock } from './lock.ts';
import { why } from './why.ts';
declare global {
interface Window { __vt: string[] }
}
const CASES = [
['/legal/', '.xlg-card[href*="/legal/"]', 'open'],
['/enterprise/', 'main a[href="/contact-sales"], main a[href="/contact-sales/"]', 'any'],
['/about/', 'main a[href^="/"]:not([href="/"])', 'any'],
];
await lock();
fs.mkdirSync('shots/morph', { recursive: true });
const b = await puppeteer.launch({ executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', headless: true, protocolTimeout: 240000 });
let bad = 0, n = 0;
for (const [from, sel, want] of CASES) {
const page = await b.newPage();
await page.setViewport({ width: 1470, height: 900 });
await page.evaluateOnNewDocument(() => { try { localStorage.setItem('hz-consent', '{"necessary":true}'); } catch {} window.__vt = []; const o = document.startViewTransition?.bind(document); if (o) document.startViewTransition = (f) => { window.__vt.push(document.documentElement.dataset.morph || '?'); return o(f); }; });
try {
await page.goto('http://localhost:4180' + from, { waitUntil: 'networkidle2', timeout: 120000 });
const el = await page.$(sel);
if (!el) { console.log(`${from}: no link matches ${sel}`); bad++; continue; }
await el.evaluate((e) => e.scrollIntoView({ block: 'center' }));
await new Promise((r) => setTimeout(r, 900));
const to = await el.evaluate((e) => new URL((e as HTMLAnchorElement).href).pathname);
const file = `shots/morph/${String(++n).padStart(2, '0')}`;
// screenshots force a frame each time, so they catch the transition itself (a screencast can miss it)
const ys = [];
const click = el.click();
for (let k = 0; k < 16; k++) { await page.screenshot({ path: `${file}-f${String(k).padStart(2, '0')}.jpg`, type: 'jpeg', quality: 55 }); ys.push(await page.evaluate(() => Math.round(scrollY))); await new Promise((r) => setTimeout(r, 70)); }
await click;
await page.waitForFunction((t) => location.pathname.replace(/\/$/, '') === t.replace(/\/$/, ''), { timeout: 20000 }, to);
await new Promise((r) => setTimeout(r, 1600));
const r = await page.evaluate(() => ({ vt: window.__vt, y: Math.round(scrollY) }));
// a client-side transition keeps window state; a full reload would have wiped __vt
const ok = (want === 'any' ? !!r.vt[0] : r.vt[0] === want) && r.y < 5;
if (!ok) bad++;
execFileSync('ffmpeg', ['-loglevel', 'error', '-y', '-framerate', '10', '-i', `${file}-f%02d.jpg`, '-vf', 'scale=368:-1,tile=4x4', '-frames:v', '1', '-q:v', '5', `${file}-sheet.jpg`]);
for (const f of fs.readdirSync('shots/morph').filter((x) => x.startsWith(file.split('/').pop() + '-f'))) fs.unlinkSync('shots/morph/' + f);
console.log(`${from} -> ${to}: ${ok ? 'OK' : 'PROBLEM'} transition ${r.vt.join(',') || 'none'} (want ${want}), landed at y=${r.y}, scroll during: ${ys.join(' ')} sheet ${file}-sheet.jpg`);
} catch (e) { bad++; console.log(`${from}: FAILED ${why(e, 140)}`); }
finally { await page.close(); }
}
await b.close();
process.exit(bad ? 1 : 0);