Class: OpfsSahEnvironment

OPFS SAH‑pool environment implemented with a Dedicated Worker.

Spawns a Worker and forwards calls via a minimal RPC while keeping the environment async surface. Use one instance per logical database key.

Example

// Static helper: clear all OPFS data for this origin (destructive)
await OpfsSahEnvironment.clear()

Implements

Constructors

Constructor

new OpfsSahEnvironment(opts?: { key?: string; }): OpfsSahEnvironment

Parameters

ParameterType
opts?{ key?: string; }
opts.key?string

Returns

OpfsSahEnvironment

Methods

call()

call(name: string, payload?: unknown): Promise<unknown>

Invoke a named engine function inside the worker engine.

Parameters

ParameterType
namestring
payload?unknown

Returns

Promise<unknown>

Implementation of

LixEnvironment.call


close()

close(): Promise<void>

Returns

Promise<void>

Implementation of

LixEnvironment.close


create()

create(createOpts: { blob: ArrayBuffer; }): Promise<void>

Parameters

ParameterType
createOpts{ blob: ArrayBuffer; }
createOpts.blobArrayBuffer

Returns

Promise<void>

Implementation of

LixEnvironment.create


exists()

exists(): Promise<boolean>

Returns

Promise<boolean>

Implementation of

LixEnvironment.exists


export()

export(): Promise<ArrayBuffer>

Export the SQLite database image as raw bytes.

Worker returns one of two shapes for performance:

  • Fast path: { blob: ArrayBuffer } (zero‑copy transfer)
  • Fallback: { buffer, offset, length } (single copy on host)

Returns

Promise<ArrayBuffer>

Implementation of

LixEnvironment.export


open()

open(initOpts: { boot: { args: BootArgs; }; emit: (ev: EngineEvent) => void; }): Promise<{ engine?: LixEngine; }>

Parameters

ParameterType
initOpts{ boot: { args: BootArgs; }; emit: (ev: EngineEvent) => void; }
initOpts.boot{ args: BootArgs; }
initOpts.boot.argsBootArgs
initOpts.emit(ev: EngineEvent) => void

Returns

Promise<{ engine?: LixEngine; }>

Implementation of

LixEnvironment.open


spawnActor()

spawnActor(opts: SpawnActorOptions): Promise<EnvironmentActorHandle>

Parameters

ParameterType
optsSpawnActorOptions

Returns

Promise<EnvironmentActorHandle>

Implementation of

LixEnvironment.spawnActor


clear()

static clear(): Promise<void>

Cleans the entire OPFS by removing all files. Useful for debugging and testing.

WARNING! This will delete ALL files in OPFS, not just Lix files!

Returns

Promise<void>