API reference › @evolu/web › createWasmSqliteDriver
function createWasmSqliteDriver(deps: WasmSqliteDriverDeps): CreateSqliteDriver;
Defined in: packages/web/src/Sqlite.ts:101
Creates the CreateSqliteDriver of Evolu for the web.
A database is the file /evolu1.db in a pool of OPFS sync access handles in
the directory .<name>, in the format of SQLite's opfs-sahpool, and Evolu's
codec, in C, encrypts it in the encrypted mode. So the databases
@evolu/web 3 created with @evolu/sqlite-wasm 2.2.4 open unchanged, an
encrypted one with the key 2.2.4 derived from the encryption key, which is
never rekeyed. 2.2.4 derived it because of a bug in SQLite3 Multiple Ciphers:
it took the encryption key, passed in SQLCipher's notation for a raw key, as
a passphrase (https://github.com/utelle/SQLite3MultipleCiphers/issues/218),
as deriveLegacySqliteKey of @evolu/sqlite-wasm describes. A new
encrypted database is encrypted with the encryption key itself, so
@evolu/web 3.4.1 and earlier cannot open it. A database in the memory
mode uses no OPFS.
An encrypted database is opened in exclusive locking mode: its connection takes the file's lock at the open and holds it until it closes, so SQLite keeps its page cache between transactions without rereading page 1. Its rollback journal stays between transactions, truncated to 0 bytes after each commit, until a connection that wrote closes.
In WebKit on macOS, such as Safari, whose file system ignores case by default, names that differ only in case share the directory, and both can hold it at once, so make database names differ in more than case.
The pool is opened once, so the driver throws while another context holds a file of it. A DbWorker waits for the files with createWaitForDatabaseRelease first.
The SqliteDriver contract has no error channel, so every error, such
as a query's SqliteError, is thrown as the cause of an Error whose
message is SQLite's message, or the error's type for an error without one.