#!/usr/bin/env bun // Screenshots of every desktop screen in light and dark, from the Vite dev server in fixture mode (no Tauri, no store // accounts), plus a few interaction checks (command palette, toast progress, keyboard focus). Dev tool only. // cd apps/desktop && VITE_FIXTURES=1 bunx vite --port 1431 & // bun scripts/screens.ts --base http://127.0.0.1:1431 --out [--only portfolio,app:health] [--themes light,dark] // Uses playwright (root devDependency) with the installed Google Chrome (channel "chrome"). import { mkdirSync } from 'node:fs'; import { join } from 'node:path'; import { chromium, type Page } from 'playwright'; const arg = (k: string, d: string) => { const i = process.argv.indexOf(`--${k}`); return i >= 0 ? process.argv[i + 1] ?? d : d; }; const base = arg('base', 'http://127.0.0.1:1431'); const out = arg('out', join(import.meta.dir, '..', '.screens')); const only = arg('only', '').split(',').filter(Boolean); const themes = arg('themes', 'light,dark').split(','); const lang = arg('lang', 'en'); const suffix = arg('suffix', ''); export const SCREENS: [string, string][] = [ ['portfolio', 'portfolio'], ['releases', 'app:releases'], ['releases-2', 'app:releases:2'], ['catalog', 'app:catalog'], ['listings', 'app:listings'], ['health', 'app:health'], ['reviews', 'app:reviews'], ['testflight', 'app:testflight'], ['checks', 'app:checks'], ['apps', 'apps'], ['accounts', 'accounts'], ['dependencies', 'dependencies'], ['settings', 'settings'], ['palette', 'palette'], ['welcome-1', 'welcome:1'], ['welcome-2', 'welcome:2'], ['welcome-3', 'welcome:3'], ['welcome-4', 'welcome:4'], ['welcome-5', 'welcome:5'], ]; async function settle(page: Page) { await page.waitForLoadState('networkidle'); await page.waitForTimeout(900); } mkdirSync(out, { recursive: true }); const browser = await chromium.launch({ channel: 'chrome', headless: true }); const files: string[] = []; for (const theme of themes) { const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 }, deviceScaleFactor: 1, colorScheme: theme === 'dark' ? 'dark' : 'light', reducedMotion: 'reduce' }); const page = await ctx.newPage(); const errors: string[] = []; page.on('pageerror', e => errors.push(String(e))); page.on('console', m => { if (m.type() === 'error') errors.push(m.text()); }); for (const [name, start] of SCREENS) { if (only.length && !only.includes(name)) continue; await page.goto(`${base}/?start=${encodeURIComponent(start)}&theme=${theme}&lang=${lang}`); await settle(page); const f = join(out, `d2-${name}${suffix}-${theme}${lang === 'en' ? '' : `-${lang}`}.png`); await page.screenshot({ path: f }); files.push(f); } if (!only.length || only.includes('toast')) { // a background job: Read the stores, caught mid-way with its progress toast await page.goto(`${base}/?start=portfolio&theme=${theme}&lang=${lang}`); await settle(page); await page.getByRole('button', { name: /Read the stores|Mağazaları oku/ }).first().click(); await page.waitForTimeout(900); const f = join(out, `d2-toast${suffix}-${theme}${lang === 'en' ? '' : `-${lang}`}.png`); await page.screenshot({ path: f }); files.push(f); } if (errors.length) console.error(`${theme}: page errors:\n ${[...new Set(errors)].join('\n ')}`); await ctx.close(); } await browser.close(); console.log(files.join('\n'));