Skip to content

OpfsWorker.ts

Runs the worker side of the browser SQLite WASM client that stores data in OPFS.

This module opens @effect/wa-sqlite with the OPFS access-handle VFS, then listens on a MessagePort-compatible port for the protocol used by SqliteClient. It sends a ready message, executes SQL messages, imports and exports database bytes, forwards update-hook notifications, and closes when requested. It is meant to run in a dedicated worker or a SharedWorker.

Since v4.0.0



Runs the SQLite OPFS worker loop, opening the configured database, posting a ready message, handling query/import/export/update-hook messages, and closing when a close message is received.

Signature

declare const run: (options: OpfsWorkerConfig) => Effect.Effect<void, SqlError>

Source

Since v4.0.0

Configuration for the SQLite OPFS worker, including the message port used for the client protocol and the OPFS database name to open.

Signature

export interface OpfsWorkerConfig {
readonly port: EventTarget & Pick<MessagePort, "postMessage" | "close">
readonly dbName: string
}

Source

Since v4.0.0