Files
Harvey_Team_Page/design/halo-audit-2026-11-10/lib/probe-clip.cjs
T
FastD 9e7b1e3430 Serve planet and mascots from src/assets
- Move served planet (animated webp, posters, 300 frames) and team mascots into src/assets/
- Use relative paths (assets/...) that work in file://, on the dev server and with docroot=src
- Screenshot pipeline writes to src/assets/projects
- Halo audit: report and measurements, ticker ring fix, shadow rules in DESIGN.md and spec.md
2026-11-10 18:42:12 +03:00

31 lines
1.9 KiB
JavaScript

const { chromium } = require('playwright-core');
const png = require('./png.cjs');
(async () => {
const b = await chromium.launch({ executablePath: 'C:/Users/deeen/AppData/Local/ms-playwright/chromium_headless_shell-1223/chrome-headless-shell-win64/chrome-headless-shell.exe' });
const c = await b.newContext({ viewport: { width: 1440, height: 900 }, deviceScaleFactor: 1, reducedMotion: 'reduce' });
const p = await c.newPage();
await p.goto('http://127.0.0.1:8791/src/index.html', { waitUntil: 'load' });
await p.waitForTimeout(800);
const sel = process.argv[2] || '.case-card';
const loc = p.locator(sel).first();
await loc.evaluate(el => el.scrollIntoView({ block: 'center', inline: 'center', behavior: 'instant' }));
await p.waitForTimeout(400);
const box = await loc.evaluate(el => { const r = el.getBoundingClientRect(); return { x: r.x, y: r.y, w: r.width, h: r.height, sy: scrollY, sx: scrollX, vw: innerWidth, vh: innerHeight }; });
console.log('box', box);
const m = Math.floor(Math.min(40, box.y, box.vh - (box.y + box.h), box.x, box.vw - (box.x + box.w)));
console.log('m', m);
const variants = {
page: { x: Math.round(box.x + box.sx - m), y: Math.round(box.y + box.sy - m), width: Math.round(box.w + 2 * m), height: Math.round(box.h + 2 * m) },
view: { x: Math.round(box.x - m), y: Math.round(box.y - m), width: Math.round(box.w + 2 * m), height: Math.round(box.h + 2 * m) }
};
for (const [k, clip] of Object.entries(variants)) {
try {
const buf = await p.screenshot({ clip, animations: 'disabled' });
const img = png.decode(buf);
require('fs').writeFileSync('G:/Project/Haevey_Monster_Team_Page/design/halo-audit-2026-11-10/out/debug-' + k + '.png', buf);
console.log(k, 'OK', img.width + 'x' + img.height, 'center px', png.px(img, img.width >> 1, img.height >> 1), 'corner px', png.px(img, 1, 1));
} catch (e) { console.log(k, 'FAIL', e.message.split('\n')[0]); }
}
await b.close();
})();