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

62 lines
4.5 KiB
TypeScript

// Learn where each of Hanzo's forms sends its data, WITHOUT sending anything: every non-GET request is blocked in the
// browser before it leaves, and only its address, method and field names are recorded. Test values only.
// Usage: node scripts/forms.mjs /contact-sales /newsletter ... -> content/forms.json
import fs from 'node:fs';
import puppeteer from 'puppeteer-core';
import { lock } from './lock.ts';
import { why } from './why.ts';
await lock();
interface Send { url: string; method: string; type: string; fields: string[]; body: string }
interface Field { name: string; type: string; required: boolean; label: string; options?: string[] }
interface FormInfo { fields: Field[]; sends: Send[] }
type Control = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
const paths = process.argv.slice(2);
const out: Record<string, FormInfo[]> = fs.existsSync('content/forms.json') ? JSON.parse(fs.readFileSync('content/forms.json', 'utf8')) : {};
const b = await puppeteer.launch({ executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', headless: true });
for (const p of paths) {
const page = await b.newPage();
await page.setViewport({ width: 1470, height: 900 });
await page.setRequestInterception(true);
const seen: Send[] = [];
page.on('request', (r) => {
if (r.method() !== 'GET' && r.method() !== 'OPTIONS' && r.method() !== 'HEAD') {
let body = r.postData() || '';
let fields: string[] = [];
try { fields = Object.keys(JSON.parse(body)); } catch { fields = [...new URLSearchParams(body).keys()]; }
if (!/google|analytics|posthog|segment|sentry|vitals|collect|insights|telemetry/i.test(r.url())) seen.push({ url: r.url(), method: r.method(), type: r.headers()['content-type'] || '', fields, body: body.slice(0, 600) }); // test values only
r.abort(); // never let a form submission reach Hanzo
} else r.continue();
});
try {
await page.goto('https://hanzo.ai' + p, { waitUntil: 'networkidle2', timeout: 45000 });
await page.evaluate(() => document.querySelectorAll<HTMLElement>('[role=dialog]').forEach((d) => /cookies/i.test(d.innerText) && d.remove()));
const forms = await page.$$('main form');
const info: FormInfo[] = [];
for (const f of forms) {
const fields = await f.evaluate((form) => ([...form.elements] as Control[]).filter((e) => e.name || e.id).map((e) => ({ name: e.name || e.id, type: e.type || e.tagName.toLowerCase(), required: e.required, label: (e.labels && e.labels[0] ? e.labels[0].innerText : e.getAttribute('aria-label') || ('placeholder' in e ? e.placeholder : '') || '').trim().slice(0, 60), options: e instanceof HTMLSelectElement ? [...e.options].map((o) => o.value) : undefined })));
await f.evaluate((form) => {
for (const e of [...form.elements] as Control[]) {
if (!e.name || e.name === 'website') continue; // leave the honeypot empty
if (e instanceof HTMLSelectElement) { e.value = e.options[e.options.length - 1].value; e.dispatchEvent(new Event('change', { bubbles: true })); }
else if (e instanceof HTMLInputElement && e.type === 'checkbox') { if (!e.checked) e.click(); }
else if (e.type === 'email') { const s = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')!.set!; s.call(e, '[email protected]'); e.dispatchEvent(new Event('input', { bubbles: true })); }
else if (e.type === 'tel') { const s = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')!.set!; s.call(e, '+15555550123'); e.dispatchEvent(new Event('input', { bubbles: true })); }
else if (/text|url|search|textarea/.test(e.type) || e.tagName === 'TEXTAREA') { const proto = e.tagName === 'TEXTAREA' ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype; Object.getOwnPropertyDescriptor(proto, 'value')!.set!.call(e, 'Test'); e.dispatchEvent(new Event('input', { bubbles: true })); }
}
});
const before = seen.length;
await f.evaluate((form) => { const s = form.querySelector<HTMLButtonElement>('button[type=submit], button:not([type])'); if (s) s.click(); else form.requestSubmit(); });
await new Promise((r) => setTimeout(r, 2500));
info.push({ fields, sends: seen.slice(before) });
}
out[p] = info;
console.log(p, JSON.stringify(info.map((x) => x.sends.map((s) => s.method + ' ' + s.url + ' [' + s.fields.join(',') + ']'))));
} catch (e) {
console.log(p, 'FAILED', why(e, 100));
} finally { await page.close(); }
}
await b.close();
fs.writeFileSync('content/forms.json', JSON.stringify(out, null, 1));