Files
skills/plugins/document-navigator/docs/persistence/storage/storage-browser-indexeddb
admin 9bf56a806b Move docs/ package mirror into document-navigator plugin
Relocate the ~6k-file docs tree from the repo root into
plugins/document-navigator/docs/ so the plugin is self-contained and
portable. docs/superpowers/ (specs and plans) stays at the repo root.

Moved via cp+rm rather than git mv because directory rename() fails with
EPERM on this WSL /mnt DrvFs mount; git rename-detection pairs the
identical-content files at commit time.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-30 01:10:00 +01:00
..

@suaveplan/storage-browser-indexeddb - Browser IndexedDB AbstractStorage adapter for @suaveplan/storage: structured-clone key-value storage via globalThis.indexedDB, AbortSignal everywhere, strict key sanitisation, TTL via expiresAt index, metadata storage, partial reads, DOMException → typed IndexedDbError mapping, full OTel surface.

Browser-tier AbstractStorage adapter backed by the W3C IndexedDB API (globalThis.indexedDB). Provides persistent, origin-scoped key-value storage for browser consumers — vault snapshots, drive chunk caches, in-app i18n catalogues, password manager records — with full AbstractStorage conformance, TTL via an expiresAt index, AbortSignal threading, strict key sanitisation, Zod-validated options, structured IndexedDbError boundary, DOMException → typed-code mapping, and a complete OpenTelemetry surface.

Documentation tree

Install

bun add @suaveplan/storage-browser-indexeddb

Quick start

import {
 createIndexedDbStorage,
 isIndexedDbAvailable,
} from "@suaveplan/storage-browser-indexeddb";

if (!isIndexedDbAvailable()) {
 throw new Error("This browser does not support IndexedDB");
}

const storage = createIndexedDbStorage({ dbName: "myapp" });
await storage.set("user/42", new TextEncoder().encode("hello"));
const back = await storage.get("user/42");

Factory integration

import { registerIndexedDbProvider } from "@suaveplan/storage-browser-indexeddb/registry";
import { createStorage } from "@suaveplan/storage/factory";

registerIndexedDbProvider();
const storage = createStorage({ type: "indexeddb", config: { dbName: "myapp" } });

The package does NOT self-register at module-evaluation time — call registerIndexedDbProvider() explicitly so sideEffects: false bundlers can tree-shake the factory path when not used.

Capabilities

Capability Value Notes
partialReads true Via Uint8Array.subarray(...) on the in-memory copy of the stored row.
partialWrites false IndexedDB has no random-access put; setPartial uses the AbstractStorage read-modify-write fallback.
nativeStreams false IndexedDB has no native streaming surface; createReadStream / createWriteStream use the buffered fallback.
atomicWrites true Each objectStore.put is a single-transaction commit.
contentAddressable false Keys are caller-supplied strings.

Modules

License

MIT.