Skip to content

feat: SQLite OPFS driver for browser - #10

Draft
brainkim wants to merge 1 commit into
mainfrom
sqlite-opfs
Draft

feat: SQLite OPFS driver for browser#10
brainkim wants to merge 1 commit into
mainfrom
sqlite-opfs

Conversation

@brainkim

Copy link
Copy Markdown
Member

Summary

Adds @b9g/zen/sqlite-opfs entrypoint - a SQLite driver for browsers using OPFS persistence.

Usage

// worker.ts
import { createSQLiteOPFSDriver } from "@b9g/zen/sqlite-opfs";
import { Database } from "@b9g/zen";

const driver = await createSQLiteOPFSDriver("myapp.db");
const db = new Database(driver);
await db.open(1);

Technical Details

  • Uses @sqlite.org/sqlite-wasm with opfs-sahpool VFS
  • No COOP/COEP headers required
  • Fastest OPFS performance (3-4x faster than alternatives)
  • Must run in Web Worker
  • Single connection (no multi-tab, but that's fine for most use cases)

Status

Draft - Pending browser tests via libuild multiplatform test runner.

The driver code mirrors the tested sqlite.ts driver, but the WASM integration needs real browser testing before merging.

Test plan

  • libuild multiplatform test runner available
  • Add Playwright/browser tests
  • Manual testing via playground

🤖 Generated with Claude Code

Adds @b9g/zen/sqlite-opfs entrypoint using @sqlite.org/sqlite-wasm
with opfs-sahpool VFS for persistent browser storage.

- No COOP/COEP headers required
- Must run in Web Worker
- Fastest OPFS performance (3-4x faster than alternatives)

Note: Untested pending libuild multiplatform test runner.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@brainkim

Copy link
Copy Markdown
Member Author

Blocked by bikeshaving/libuild#3

brainkim added a commit that referenced this pull request Aug 12, 2026
We were pinned at ^0.1.21, so the whole 0.2 line never came in — including
`libuild test`, the multiplatform runner (`--platform bun node chromium
firefox webkit`) that PR #10 has been waiting on since December.

Verified on 0.2.17:
- `libuild build` — unchanged, same 5 entries, same ESM output, no config
- `libuild test test --platform bun` — 594 passed, 0 failed

0.2.16 was not usable for browser tests here, and its failure mode was the
dangerous one: in an ESM package it reported `0 passed, 0 failed` and exited
0. The dispatcher's top-level await deferred every test file's body past the
runner's start, so it ran with nothing registered and called that success.
Wiring browser tests into CI on 0.2.16 would have merged a suite that
silently ran nothing. 0.2.17 fixes it.

Browser platforms additionally need `playwright` (an optional peer dep);
adding it belongs with the work that uses it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Sxss5Fa7yjQr3on4VArnuk
brainkim added a commit that referenced this pull request Aug 12, 2026
We were pinned at ^0.1.21, so the whole 0.2 line never came in — including
`libuild test`, the multiplatform runner (`--platform bun node chromium
firefox webkit`) that PR #10 has been waiting on since December.

Verified on 0.2.17:
- `libuild build` — unchanged, same 5 entries, same ESM output, no config
- `libuild test test --platform bun` — 594 passed, 0 failed

0.2.16 was not usable for browser tests here, and its failure mode was the
dangerous one: in an ESM package it reported `0 passed, 0 failed` and exited
0. The dispatcher's top-level await deferred every test file's body past the
runner's start, so it ran with nothing registered and called that success.
Wiring browser tests into CI on 0.2.16 would have merged a suite that
silently ran nothing. 0.2.17 fixes it.

Browser platforms additionally need `playwright` (an optional peer dep);
adding it belongs with the work that uses it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Sxss5Fa7yjQr3on4VArnuk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant