/**
* Renders the PWA icons (docs/07 §11) from the favicon design with headless Chrome.
* bun scripts/pwa-icons.ts → apps/web/public/icons/*.png
* "any" icons keep the favicon's rounded corners; maskable/apple icons are full-bleed
* (the OS applies its own mask) with the board inside the 40% safe circle.
*/
import { chromium } from 'playwright-core';
import { mkdirSync, readFileSync } from 'node:fs';
import { join } from 'node:path';
const PUBLIC = join(import.meta.dir, '../apps/web/public');
const OUT = join(PUBLIC, 'icons');
mkdirSync(OUT, { recursive: true });
const rounded = readFileSync(join(PUBLIC, 'favicon.svg'), 'utf8');
// Same board as the favicon, shrunk to 80% so every stroke stays inside the safe circle.
const fullBleed = ``;
const ICONS: [file: string, size: number, svg: string][] = [
['icon-192.png', 192, rounded],
['icon-512.png', 512, rounded],
['icon-maskable-512.png', 512, fullBleed],
['apple-touch-icon.png', 180, fullBleed],
];
const browser = await chromium.launch({ executablePath: process.env.CHROME ?? '/usr/bin/google-chrome', headless: true });
const page = await browser.newPage();
for (const [file, size, svg] of ICONS) {
await page.setViewportSize({ width: size, height: size });
await page.setContent(`${svg}`);
await page.screenshot({ path: join(OUT, file), omitBackground: true });
console.log(`✓ ${file}`);
}
await browser.close();