// Screenshots the wayBetter panel through the dev harness (/?panel, mocked native commands). // Needs the Vite dev server on 127.0.0.1:1433. Usage: node scripts/panel-screenshots.mjs 'name|width|query|action|height'... import { chromium } from 'playwright'; const [, , out, ...shots] = process.argv; const browser = await chromium.launch(); for (const spec of shots) { const [name, width, query = '', action = '', height = '900'] = spec.split('|'); const page = await browser.newPage({ viewport: { width: Number(width), height: Number(height) }, deviceScaleFactor: 2, colorScheme: 'dark' }); const errors = []; page.on('pageerror', e => errors.push(e.message)); page.on('console', m => { if (m.type() === 'error') errors.push(m.text()); }); await page.goto(`http://127.0.0.1:1433/?panel${query ? '&' + query : ''}`); await page.waitForTimeout(900); if (action) await eval(`(async () => { ${action} })()`); await page.waitForTimeout(400); await page.screenshot({ path: `${out}/${name}.png`, fullPage: false }); console.log(name, errors.length ? 'ERRORS: ' + errors.join(' | ') : 'ok'); await page.close(); } await browser.close();