jetstream v2 in zig stream.waow.tech
Something went wrong. Try again.
1234567891011121314151617181920212223242526import {parseStorageReport} from './storage-parser.js';const bytes=value=>{const units=['B','KB','MB','GB','TB'];const index=Math.min(4,Math.floor(Math.log10(Math.max(1,value))/3));return `${new Intl.NumberFormat('en',{maximumFractionDigits:index===4?2:1}).format(value/1000**index)} ${units[index]}`;};export function renderStorage(input){ const panel=document.querySelector('#storage'); if(!input)return; try{ const report=parseStorageReport(input); if(report.probes.length!==3||report.segmentCount<3||report.sealedFileBytes<=0)throw Error('Invalid storage report'); for(const p of report.probes){ const values=[p.fileBytes,p.compressedFrameBytes,p.uncompressedBlockBytes,p.framingBytes,p.headerBytes,p.footerBytes,p.mixedNamespaceFrameBytes]; if(values.some(n=>!Number.isSafeInteger(n)||n<0)||p.uncompressedBlockBytes===0||p.compressedFrameBytes===0||p.mixedNamespaceFrameBytes>p.compressedFrameBytes||p.fileBytes!==p.compressedFrameBytes+p.framingBytes+p.headerBytes+p.footerBytes)throw Error('Storage accounting mismatch'); } panel.hidden=false; panel.innerHTML=`<summary>Space behind the spheres <span>${bytes(report.sealedFileBytes)}</span></summary><div class="storage-content"><h2>${bytes(report.sealedFileBytes)} of saved history</h2><p>Across ${report.segmentCount.toLocaleString()} completed files. This measures those files, not all storage used by Stream.</p><h3>What compression saves</h3><p>We inspected three files. Choose one to see how it’s stored.</p><label for="storage-file">File to inspect</label><select id="storage-file"><option value="0">First file</option><option value="1">Middle file</option><option value="2" selected>Last file measured</option></select><div id="storage-comparison" aria-live="polite"></div><p class="storage-source">Measured ${new Date(report.measuredAt).toLocaleString()}. These three files do not establish averages for the whole archive. Sizes use decimal units.</p></div>`; const draw=()=>{ const p=report.probes[Number(document.querySelector('#storage-file').value)]; const overhead=p.footerBytes+p.framingBytes+p.headerBytes; const max=Math.max(p.uncompressedBlockBytes,p.fileBytes); const shared=p.mixedNamespaceFrameBytes/p.compressedFrameBytes; const sharedText=shared>.999?'More than 99.9%':`${(shared*100).toFixed(1)}%`; document.querySelector('#storage-comparison').innerHTML=`<div class="storage-row"><span>Data before compression</span><strong>${bytes(p.uncompressedBlockBytes)}</strong></div><div class="storage-track" aria-hidden="true"><i class="storage-before" style="width:${p.uncompressedBlockBytes/max*100}%"></i></div><div class="storage-row"><span>Stored file</span><strong>${bytes(p.fileBytes)}</strong></div><div class="storage-track" aria-hidden="true"><i class="storage-packed" style="width:${p.compressedFrameBytes/max*100}%"></i><i class="storage-index" style="width:${overhead/max*100}%"></i></div><p class="storage-key"><span>● Compressed data ${bytes(p.compressedFrameBytes)}</span><span>● Indexes and framing ${bytes(overhead)}</span></p><h3>Different sources share the same space</h3><p><strong>${sharedText}</strong> of this file’s compressed data is in blocks shared by multiple sources. These are groups of records compressed together.</p><p>That’s why the number of events alone can’t tell us how much disk space each source uses.</p><details><summary>Measurement details</summary><p>File ${p.index+1} of ${report.segmentCount}; ${p.blocks.toLocaleString()} blocks; ${p.collections.toLocaleString()} collection-index entries.</p><p>The full file size includes compressed frames, their length prefixes, the header, and the footer. The first bar measures uncompressed block bodies only. Shared means more than one namespace (or account-level marker) occurs in a block; shared bytes are counted once.</p><p>Only headers and indexes were fetched. Record bodies and media were not downloaded. No per-source byte estimates or claims about reclaimable space are made.</p></details>`; }; document.querySelector('#storage-file').addEventListener('change',draw);draw(); }catch{panel.hidden=false;panel.innerHTML='<summary>Storage measurements unavailable</summary><p>The saved report could not be validated. The sphere map is still available.</p>';}}