1// Local native-preview observations. Never uploaded or enabled for ordinary runs. 2export function createPreviewEvidence(send) { 3 let current=null, generation=0, painted=false, active=false; 4 const emit=(kind,extra={})=>current && send({type:'aesel-preview',content:{...current,kind,...extra}}); 5 return { 6 async begin(source,identity) { 7 emit('invalidated'); 8 const turn=++generation;current=null;painted=false;active=false; 9 if(typeof source!=='string'||!identity||typeof identity.sessionID!=='string'|| 10 identity.sessionID.length>200||!Number.isSafeInteger(identity.revision)|| 11 !Number.isSafeInteger(identity.requestID))return null; 12 const digest=await crypto.subtle.digest('SHA-256',new TextEncoder().encode(source)); 13 if(turn!==generation)return null; 14 current={sessionID:identity.sessionID,revision:identity.revision,requestID:identity.requestID, 15 sourceHash:Array.from(new Uint8Array(digest),n=>n.toString(16).padStart(2,'0')).join('')}; 16 emit('loading');return current; 17 }, 18 activate(identity) { if(current && current===identity){active=true;emit('loaded');} }, 19 paint() { if(current&&active)painted=true; }, 20 frame() { return active&&painted?current:null; }, 21 record(level,message) { emit('console',{event:{level,message:String(message).slice(0,2000),at:Date.now()}}); }, 22 }; 23}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.