Files
huncode 12562baeb5
Build and deploy / deploy (push) Successful in 2m39s
Implement ProgCode identity and real shared reading UI kit
2026-10-27 15:19:49 +03:00

15 lines
2.3 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
async page => {
await page.unrouteAll({behavior:'wait'});
const events=[];page.on('response',r=>{if(r.url().includes('favicon.ico'))events.push({url:r.url(),status:r.status(),type:r.headers()['content-type']});});page.on('requestfailed',r=>events.push({failed:r.url(),error:r.failure()}));
if(page.url()!=='http://127.0.0.1:52007/ui-kit/') throw Error('Expected own loaded origin');
const result=await page.evaluate(async()=>{
const url=location.origin+'/brand/favicon.ico';const res=await fetch(url);const b=new Uint8Array(await res.arrayBuffer());const v=new DataView(b.buffer);const hash=Array.from(new Uint8Array(await crypto.subtle.digest('SHA-256',b))).map(x=>x.toString(16).padStart(2,'0')).join('');
const decode=async(src)=>{const im=new Image();im.src=src;try{await im.decode();return {ok:true,width:im.naturalWidth,height:im.naturalHeight,image:im};}catch(e){return{ok:false,error:String(e)}}};
const bare=await decode(url);const frames=[];const row=document.createElement('section');row.style='position:fixed;z-index:999999;top:0;left:0;background:white;color:black;padding:30px;display:flex;gap:40px;align-items:center';row.setAttribute('aria-label','ICO native frame diagnostics');
for(let i=0;i<v.getUint16(4,true);i++){
const o=6+i*16,len=v.getUint32(o+8,true),start=v.getUint32(o+12,true);const one=new Uint8Array(22+len);one.set(b.slice(0,6));new DataView(one.buffer).setUint16(4,1,true);one.set(b.slice(o,o+16),6);new DataView(one.buffer).setUint32(18,22,true);one.set(b.slice(start,start+len),22);
const obj=URL.createObjectURL(new Blob([one],{type:'image/x-icon'}));const d=await decode(obj);const cell=document.createElement('div');cell.textContent=`${b[o]} × ${b[o+1]} `;if(d.image)cell.append(d.image);row.append(cell);frames.push({entryWidth:b[o],entryHeight:b[o+1],dibHeader:v.getUint32(start,true),ok:d.ok,width:d.width,height:d.height,error:d.error});
}document.body.append(row);return{location:location.href,source:(await(await fetch('/build-identity.json')).json()).sourceHash,url,sha256:hash,bytes:b.length,status:res.status,mime:res.headers.get('content-type'),bare:{ok:bare.ok,width:bare.width,height:bare.height,error:bare.error},frames};
});await page.screenshot({path:'/Users/gavrilovdev/tmp/progcode.ru/docs/design-system/candidates/7b11bf22fd24/ico-native-recovery.png'});return {...result,events};
}