Files
Website-Nov26/scripts/capturas.mjs
T
Collina SystemsandClaude Fable 5.1 c72ddb73e7 feat(demo): fase 3, componente ChatDemo como isla y guiones en JSON
- Colección demos con esquema zod: guion, chips, respuestas, pasos con PDF,
  reglas de clasificación (regex validadas) y fallback
- ChatDemo: arranca al entrar en pantalla y se pausa al salir, respeta
  prefers-reduced-motion, escala al ancho disponible, Pausar/Reiniciar y
  entrada libre; visor de PDF dentro del teléfono; fuentes del sitio
- Estilos globales anidados bajo .chatdemo para los nodos creados por JS
- Las fichas con demo tipo chat incrustan el guion correspondiente
- Script de capturas acepta ESPERA_MS para fotografiar el chat en marcha

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-04 12:29:40 -06:00

39 lines
2.0 KiB
JavaScript

// Capturas de pantalla y comprobación de scroll horizontal sobre dist/ (astro preview).
// Uso: node scripts/capturas.mjs <raíz> <carpeta-salida> "/,/proyectos"
import { chromium } from 'playwright';
import { spawn } from 'node:child_process';
import { setTimeout as sleep } from 'node:timers/promises';
import { mkdirSync } from 'node:fs';
const raiz = process.argv[2];
const salida = process.argv[3];
const rutas = (process.argv[4] || '/').split(',');
mkdirSync(salida, { recursive: true });
const srv = spawn('npx', ['astro', 'preview', '--port', '4321'], { cwd: raiz, stdio: 'ignore' });
await sleep(2500);
const browser = await chromium.launch();
try {
for (const ruta of rutas) {
for (const [ancho, alto] of [[320, 700], [360, 780], [768, 900], [1280, 900], [1920, 1000]]) {
for (const esquema of ['light', 'dark']) {
const ctx = await browser.newContext({ viewport: { width: ancho, height: alto }, colorScheme: esquema, deviceScaleFactor: 1 });
const page = await ctx.newPage();
const errores = [];
page.on('console', (m) => { if (m.type() === 'error') errores.push(m.text()); });
page.on('requestfailed', (r) => errores.push('request failed: ' + r.url()));
await page.goto('http://localhost:4321' + ruta, { waitUntil: 'networkidle' });
if (process.env.ESPERA_MS) await sleep(Number(process.env.ESPERA_MS));
const sw = await page.evaluate(() => [document.documentElement.scrollWidth, document.documentElement.clientWidth]);
const nombre = ruta.replace(/\//g, '_').replace(/^_$/, 'inicio').replace(/^_/, '');
if ([360, 1280].includes(ancho)) await page.screenshot({ path: `${salida}/${nombre}-${ancho}-${esquema}.png`, fullPage: true });
console.log(`${ruta} ${ancho}px ${esquema}: scrollWidth=${sw[0]} clientWidth=${sw[1]} ${sw[0] > sw[1] ? 'SCROLL HORIZONTAL' : 'ok'} ${errores.length ? 'ERRORES: ' + errores.join(' | ') : ''}`);
await ctx.close();
}
}
}
} finally {
await browser.close();
srv.kill();
}