/** Проба: печатает информацию о текущей текстуре спрайта героя из браузера. */
import puppeteer from 'puppeteer-core';
const url = process.argv[2] ?? 'http://localhost:5201/';
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));
const info = await page.evaluate(() => {
const g = window.__game;
const scene = g.scenes?.current ?? g.sceneManager?.current;
const player = scene?.player;
if (!player) return { error: 'нет scene.player: ' + Object.keys(scene ?? {}) };
const tex = player.currentTexture;
const src = tex.source;
return {
width: tex.width, height: tex.height,
frame: tex.frame, trim: tex.trim,
srcWidth: src.width, srcHeight: src.height,
label: tex.label ?? null,
textureDatas: tex.textureCacheIds ?? null
};
});
console.log(JSON.stringify(info, null, 2));
await browser.close();