Files
site-portfolio/diag.mjs
T

31 lines
1.6 KiB
JavaScript

import puppeteer from 'puppeteer';
const b = await puppeteer.launch({ args:['--no-sandbox','--disable-setuid-sandbox','--use-gl=angle','--enable-unsafe-swiftshader','--ignore-gpu-blocklist'] });
const p = await b.newPage();
const errs=[]; p.on('console',m=>{ if(m.type()==='error'||m.type()==='warning') errs.push(m.type()+': '+m.text()); });
p.on('pageerror',e=>errs.push('PAGEERR: '+e.message));
p.on('requestfailed',r=>errs.push('REQFAIL: '+r.url()+' '+r.failure()?.errorText));
await p.goto('http://10.200.201.3:4175/_lab/neu-card.html',{waitUntil:'load',timeout:60000});
await new Promise(r=>setTimeout(r,1500));
const diag = await p.evaluate(()=>{
const sec=document.querySelector('#sec-shader');
const demo=document.querySelector('[data-shader-demo]');
const canvas=document.querySelector('#sec-shader canvas');
const sw=document.querySelectorAll('[data-shader-switch]').length;
return {
secExists: !!sec,
secH: sec?Math.round(sec.getBoundingClientRect().height):0,
demoExists: !!demo,
demoH: demo?Math.round(demo.getBoundingClientRect().height):0,
canvasCount: document.querySelectorAll('#sec-shader canvas').length,
swCount: sw,
swVisible: sw?getComputedStyle(document.querySelector('[data-shader-switch]')).display:'n/a',
};
});
// проверим доступен ли модуль
const modOk = await p.evaluate(async()=>{
try { const m = await import('/vendor/paper-shaders/index.js'); return 'OK keys:'+Object.keys(m).length; }
catch(e){ return 'IMPORT ERR: '+e.message; }
});
console.log(JSON.stringify({diag, modOk, errs: errs.slice(0,10)}, null, 1));
await b.close();