/** * Storage origin-usage adapter (spec §02 → Storage Monitor; docs/architecture/02 §6). * * The ONLY module that touches the Storage Manager API. We read `usage` — the bytes * actually stored for the origin, which is reliable — and deliberately ignore * `quota`, a padded, browser-decided approximation that is not a real free-space * figure (web.dev → storage-for-the-web). Snippet/dataset bytes are measured in the * component from our own stores; this just supplies the whole-origin total so the * "App" remainder can be derived. Returns undefined when the API is absent or the * call rejects; never throws. */ export async function readOriginUsage(): Promise { const storage = typeof navigator !== 'undefined' ? navigator.storage : undefined; if (!storage || typeof storage.estimate !== 'function') return undefined; try { const { usage } = await storage.estimate(); return typeof usage === 'number' ? usage : undefined; } catch { return undefined; } }