mirror of
https://github.com/hanzoai/site.git
synced 2026-11-20 21:14:28 +00:00
* 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
48 lines
3.1 KiB
TypeScript
48 lines
3.1 KiB
TypeScript
// Phone check: open pages at 375×812 as a touch phone, scroll through, and fail on sideways scroll, elements wider than the
|
||
// screen, console errors, or a page that does not load. Screenshots go to /tmp/hz-phone/<path>.png for review.
|
||
// Usage: node scripts/phone.mjs /enterprise /about ... (dev server on :4180)
|
||
import fs from 'node:fs';
|
||
import puppeteer from 'puppeteer-core';
|
||
import { lock } from './lock.ts';
|
||
import { why } from './why.ts';
|
||
await lock();
|
||
|
||
const paths = process.argv.slice(2);
|
||
if (!paths.length) { console.log('usage: node scripts/phone.mjs /path ...'); process.exit(2); }
|
||
fs.mkdirSync('/tmp/hz-phone', { recursive: true });
|
||
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 page = await b.newPage();
|
||
await page.emulate({ viewport: { width: 375, height: 812, deviceScaleFactor: 2, 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', (m) => m.type() === 'error' && !/favicon|Failed to load resource/.test(m.text()) && errs.push(m.text().slice(0, 160)));
|
||
try {
|
||
await page.goto('http://localhost:4180' + p.replace(/\/?$/, '/'), { waitUntil: 'networkidle2', timeout: 120000 });
|
||
const H = await page.evaluate(() => document.documentElement.scrollHeight);
|
||
for (let y = 0; y < H; y += 700) { await page.evaluate((y) => window.scrollTo(0, y), y); await new Promise((r) => setTimeout(r, 120)); }
|
||
await new Promise((r) => setTimeout(r, 400));
|
||
const r = await page.evaluate(() => {
|
||
const W = innerWidth;
|
||
const wide = [...document.querySelectorAll('main *')].filter((e) => {
|
||
const b = e.getBoundingClientRect();
|
||
if (!b.width || getComputedStyle(e).position === 'fixed') return false;
|
||
let a = e.parentElement; // overflow inside a scroller (rails, tables) is fine
|
||
while (a && a !== document.body) { const s = getComputedStyle(a); if (/(auto|scroll|hidden|clip)/.test(s.overflowX)) return false; a = a.parentElement; }
|
||
return b.right > W + 1 || b.left < -1;
|
||
}).slice(0, 5).map((e) => (e.className && e.className.toString().split(' ').slice(0, 2).join('.')) || e.tagName);
|
||
return { sw: document.documentElement.scrollWidth, W, wide };
|
||
});
|
||
await page.evaluate(() => window.scrollTo(0, 0));
|
||
await page.screenshot({ path: '/tmp/hz-phone/' + (p.replace(/\//g, '_') || '_home') + '.png', fullPage: false });
|
||
const ok = r.sw <= r.W && !r.wide.length && !errs.length;
|
||
if (!ok) bad++;
|
||
console.log(`${p}: ${ok ? 'OK' : 'PROBLEM'} width ${r.sw}/${r.W}${r.wide.length ? ' too wide: ' + r.wide.join(', ') : ''}${errs.length ? ' errors: ' + errs.slice(0, 3).join(' | ') : ''}`);
|
||
} catch (e) {
|
||
bad++; console.log(`${p}: FAILED ${why(e, 120)}`);
|
||
} finally { await page.close(); }
|
||
}
|
||
await b.close();
|
||
process.exit(bad ? 1 : 0);
|