hex/site/scripts/generate-poster.ts
Kit Langton 9d1fe53433 Site: replace the chattering teeth with the Shout hero
The hero is now the Bean-head show from the hex-words prototype: an idle head and an
option keycap until the visitor presses it, then a voiced demo of messages, OpenCode
prompts and fixes, a Super Saiyan power-up and a Tommy-gun inbox wipe.

- WebGPU with a Canvas 2D fallback; the engine chunk loads on idle or keycap intent,
  audio and its manifest only after the press. Poster still first, no layout shift.
- Pauses when hidden or off screen, 30 fps idle, DPR cap, thinner on phones (the head
  slides right so OpenCode fits), reduced motion stays calm.
- Real avatars for Dax, Jay and Frank; generated portraits for invented senders; real
  OpenCode, Hex, Scrawl, Effect, owner and brand icons (Simple Icons, Lucide).
- Polish: badge-sized resolve check (was a 200 px ring), messages reply bubble sized
  with the right font, dizzy words below the head, head perks on the key press,
  master gain -1 dB so the pre-limiter mix no longer clips.
- Open Graph card is now the app icon, name and one line.
2026-10-20 15:12:37 -07:00

29 lines
1.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.

// Renders the idle-head poster (public/shout-idle.webp) that the page shows before the show's
// renderer loads. Needs a capture build, which exposes the engine's frame stepper:
//
// VITE_SHOUT_CAPTURE=1 bunx vite --port 5531
// HEX_SITE_URL=http://127.0.0.1:5531 bun run generate:poster
//
// Requires cwebp (brew install webp).
import { chromium } from "playwright"
import { fileURLToPath } from "node:url"
const site = process.env.HEX_SITE_URL ?? "http://127.0.0.1:5531"
const png = fileURLToPath(new URL("../node_modules/.cache/shout-idle.png", import.meta.url))
const webp = fileURLToPath(new URL("../public/shout-idle.webp", import.meta.url))
const browser = await chromium.launch({ headless: true, args: ["--enable-unsafe-webgpu", "--use-angle=metal", "--mute-audio"] })
try {
// The largest head box (20rem), at 2×.
const page = await browser.newPage({ viewport: { width: 1440, height: 1100 }, deviceScaleFactor: 2 })
await page.goto(`${site}/?capture`)
await page.waitForFunction(() => document.querySelector("main")?.dataset.phase === "live" && "__shout" in window)
await page.addStyleTag({ content: ".header, .show, .hero { visibility: hidden !important }" })
const box = await page.locator(".show__head").boundingBox()
if (!box) throw new Error("no .show__head")
await page.screenshot({ path: png, clip: box })
} finally {
await browser.close()
}
const webpResult = Bun.spawnSync(["cwebp", "-quiet", "-q", "86", png, "-o", webp], { stdio: ["ignore", "inherit", "inherit"] })
if (webpResult.exitCode !== 0) throw new Error("cwebp failed")