-
-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Goal
Add wa-sqlite (SQLite WASM) support so Peerbit can use a SQLite-backed indexer in the browser (ideally persisted via OPFS), without relying solely on @sqlite.org/sqlite-wasm.
Why
We want a browser-capable SQLite backend for indexing (documents/programs) with:
- good performance vs pure in-memory indices
- persistence (OPFS when available)
- better bundler/runtime ergonomics (Vite/etc)
- a path that works even when
SharedArrayBuffer/ cross-origin isolation is not available
Today @peerbit/indexer-sqlite3 already has a browser path via @sqlite.org/sqlite-wasm, but it comes with heavier initialization and constraints. Adding wa-sqlite gives us another implementation option and a fallback for environments where sqlite.org's OPFS/SAH pool approach is problematic.
Scope
A. New backend option
Either:
- add a new package (suggested):
@peerbit/indexer-wa-sqlite, or - add a selectable engine inside
@peerbit/indexer-sqlite3(e.g.{ engine: 'sqlite.org' | 'wa-sqlite' }).
B. Storage/VFS options
- OPFS VFS (preferred when available)
- fallback VFS (memory or IDB) when OPFS is unavailable or locked
C. Worker model
- run SQLite in a Worker (similar to current proxy/worker model) to keep UI responsive
- expose a minimal proxy that implements
@peerbit/indexer-interface
D. Tooling
- ensure wasm + worker assets work with the site build (Vite) and CI
Deliverables
- Browser demo/test that creates an index, writes rows, queries, and persists across reload (when OPFS is enabled)
- Basic perf sanity check vs current wasm backend (optional)
Acceptance criteria
peerbit-orgcan use a SQLite-backed indexer in the browser without crashing and without special runtime assumptions.- Indexer can be configured in apps (Document store / Peerbit.create indexer hook) to pick the wa-sqlite backend.
- Tests cover the basic read/write/query flow in a browser runtime.
Related
documents: Allow for SQLLite WASM backend #275 (documents: allow a SQLite WASM backend)- OPFS persistance with multiple tabs, prevent lock issues #304 (OPFS persistence across multiple tabs / lock issues)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request