/**
* Проба дебага спрайта: включаем просмотр кадра героя (KeyP) и снимаем скриншот.
* Запуск: node tools/skin-probe.mjs [url] [скриншот]
*/
import puppeteer from 'puppeteer-core';
const url = process.argv[2] ?? 'http://localhost:5201/';
const shot = process.argv[3] ?? '/tmp/skin_check.png';
const browser = await puppeteer.launch({
executablePath: '/usr/bin/chromium', headless: true,
args: ['--no-sandbox', '--enable-unsafe-swiftshader', '--use-angle=swiftshader',
'--autoplay-policy=no-user-gesture-required', '--window-size=960,540']
});
const page = await browser.newPage();
await page.setViewport({ width: 960, height: 540 });
page.on('pageerror', (e) => console.log(`[ошибка] ${e.message}`));
const booted = new Promise((r) => page.on('console', (m) => { if (m.text().includes('[location]')) r(); }));
await page.goto(url, { waitUntil: 'networkidle2', timeout: 20000 });
await new Promise((r) => setTimeout(r, 2000));
await page.mouse.click(480, 283);
await booted;
await new Promise((r) => setTimeout(r, 1500));
await page.keyboard.press('KeyP');
await new Promise((r) => setTimeout(r, 500));
await page.screenshot({ path: shot });
console.log(`Скриншот: ${shot}`);
await browser.close();