@bhoomash/syncraft-storage
v0.1.0
Published
Pluggable local storage abstractions and IndexedDB persistence for Syncraft
Maintainers
Readme
@bhoomash/syncraft-storage
Pluggable durable storage adapters with browser IndexedDB and in-memory backends for Syncraft.
Installation
npm install @bhoomash/syncraft-storageFeatures
- 💾 IndexedDB Storage Adapter: Full durable offline storage for operations, pending queues, snapshots, and replica metadata.
- ⚡ In-Memory Storage Adapter: Fast zero-dependency memory store with causal ordering for Node.js, unit tests, and ephemeral sessions.
- 🔄 Pending Offline Queue: Caches unacknowledged local mutations and guarantees orderly queue flushing upon reconnecting.
- 🔒 Room Isolation: Separates stored operations and pending mutations by room ID.
Quick Start
import { IndexedDBAdapter, MemoryStorageAdapter } from '@bhoomash/syncraft-storage';
// Browser IndexedDB persistence
const idbStorage = new IndexedDBAdapter({
dbName: 'my-app-db',
dbVersion: 1
});
// Or fast in-memory persistence (for tests / Node servers)
const memStorage = new MemoryStorageAdapter();
// Save operation
await memStorage.saveOperation({
operationId: 'node-1-1-abc',
nodeId: 'node-1',
logicalClock: 1,
operationType: 'SET',
path: 'title',
value: 'Offline First'
}, 'my-room');
// Query operations
const ops = await memStorage.getOperations('my-room');License
MIT © Bhoomash
