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

50 lines
3.5 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Look at pages without a visible browser: scroll each page like a person at desktop (1470×900) and phone (375×812),
// letting motion settle, and save one JPEG per screen to shots/<page>/d-01.jpg … p-01.jpg. Fails on console errors.
// Usage: node scripts/shot.mjs /about /pricing ... [--desk-only|--phone-only] [--max=10] (dev server on :4180)
import fs from 'node:fs';
import puppeteer from 'puppeteer-core';
import { lock } from './lock.ts';
import { why } from './why.ts';
const args = process.argv.slice(2);
const paths = args.filter((a) => a.startsWith('/'));
const max = +(args.find((a) => a.startsWith('--max=')) || '--max=10').slice(6);
const modes = [!args.includes('--phone-only') && 'd', !args.includes('--desk-only') && 'p'].filter(Boolean);
if (!paths.length) { console.log('usage: node scripts/shot.mjs /path ... [--desk-only|--phone-only] [--max=10]'); process.exit(2); }
await lock();
const b = await puppeteer.launch({ executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', headless: true });
let bad = 0;
for (const p of paths) {
const dir = 'shots/' + (p.replace(/^\/|\/$/g, '').replace(/\//g, '_') || 'home');
fs.rmSync(dir, { recursive: true, force: true }); fs.mkdirSync(dir, { recursive: true });
for (const m of modes) {
const page = await b.newPage();
if (m === 'd') await page.setViewport({ width: 1470, height: 900 });
else await page.emulate({ viewport: { width: 375, height: 812, deviceScaleFactor: 1, isMobile: true, hasTouch: true }, userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Mobile/15E148 Safari/604.1' });
const errs: string[] = [];
page.on('pageerror', (e) => errs.push(e.message.slice(0, 160)));
page.on('console', (x) => x.type() === 'error' && !/favicon|Failed to load resource/.test(x.text()) && errs.push(x.text().slice(0, 160)));
try {
await page.goto('http://localhost:4180' + p.replace(/\/?$/, '/'), { waitUntil: 'networkidle2', timeout: 120000 });
await page.evaluate(() => { localStorage.setItem('hz-consent', JSON.stringify({ necessary: true })); document.querySelectorAll<HTMLElement>('[role=dialog]').forEach((d) => /cookie/i.test(d.innerText) && d.remove()); });
await new Promise((r) => setTimeout(r, 1800));
const H = await page.evaluate(() => document.documentElement.scrollHeight), V = m === 'd' ? 900 : 812;
const step = Math.max(V * 0.9, (H - V) / Math.max(1, max - 1));
let n = 0;
for (let y = 0; n < max; y += step) {
// glide there in small steps so scroll-linked and in-view motion fires as it would for a person
await page.evaluate(async (to) => { const from = scrollY; for (let k = 1; k <= 8; k++) { scrollTo(0, from + ((to - from) * k) / 8); await new Promise((r) => setTimeout(r, 40)); } }, Math.min(y, H - V));
await new Promise((r) => setTimeout(r, 1100));
await page.screenshot({ path: `${dir}/${m}-${String(++n).padStart(2, '0')}.jpg`, type: 'jpeg', quality: 62 });
if (y >= H - V) break;
}
const sw = await page.evaluate(() => document.documentElement.scrollWidth - innerWidth);
if (errs.length || sw > 0) bad++;
console.log(`${p} ${m === 'd' ? 'desktop' : 'phone'}: ${n} shots, height ${H}${sw > 0 ? ' SIDEWAYS SCROLL +' + sw : ''}${errs.length ? ' errors: ' + errs.slice(0, 2).join(' | ') : ''} -> ${dir}`);
} catch (e) { bad++; console.log(`${p} ${m}: FAILED ${why(e, 120)}`); }
finally { await page.close(); }
}
}
await b.close();
process.exit(bad ? 1 : 0);