src/holds the TypeScript library. Key files includesrc/main.ts(public API),src/worker.ts(SQLite WASM worker),src/worker-bridge.ts, and shared logic undersrc/utils/andsrc/types/.src/jswasm/contains the vendored SQLite WASM assets and typings.- Tests: unit tests live next to code as
*.unit.test.ts(example:src/utils/mutex/mutex.unit.test.ts); E2E tests live intests/e2e/*.e2e.test.ts. docs/contains the VitePress site anddocs/public/assets.samples/includes runnable HTML examples.scripts/has build helpers.specs/stores design notes.dist/andcoverage/are build/test outputs.
npm installinstalls dependencies.npm run buildbuilds the library todist/(minified).npm run build:watchbuilds in watch mode for local development.npm run testruns build, lint, unit, and E2E suites.npm run test:unitruns Vitest unit tests with coverage incoverage/.npm run test:e2eruns the Vitest E2E suite viavitest.e2e.config.ts.npm run lintruns ESLint, TypeScript typecheck, and Prettier.npm run formatformats with Prettier.npm run docs:devstarts the docs site;npm run docs:buildbuilds it.npm run httpserves the repo locally on port 8399 (useful for OPFS/worker testing).
- TypeScript (ESM). Indentation is 2 spaces, no tabs, keep lines readable.
- Follow ESLint rules in
eslint.config.ts(no unused vars unless prefixed_, noany). - Format with Prettier via
npm run format. - Test filenames:
*.unit.test.tsfor unit,*.e2e.test.tsfor E2E. - Keep public API changes isolated to
src/main.tsand update types insrc/types/.
- Unit tests run under Vitest using
vitest.unit.config.ts. - E2E tests run with Vitest browser config (
vitest.e2e.config.ts); install Playwright browsers if prompted. - Cover both worker and main-thread behavior when touching concurrency or transaction logic.
- Commit messages follow a Conventional Commit style in history (examples:
feat(build): ...,perf(build): ...,docs: ...). Version bumps useversion: x.y.z. - PRs should include a clear description, linked issues (if any), and the test commands run. Add screenshots for docs or UI changes.
- SharedArrayBuffer requires COOP/COEP headers:
Cross-Origin-Opener-Policy: same-originandCross-Origin-Embedder-Policy: require-corp. Ensure your local server sends them when testing OPFS/WASM.