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.
// Static helper: clear all OPFS data for this origin (destructive)
await OpfsSahEnvironment.clear()new OpfsSahEnvironment(
opts?: {key?:string; }):OpfsSahEnvironment
| Parameter | Type |
|---|---|
opts? | { key?: string; } |
opts.key? | string |
OpfsSahEnvironment
call(
name:string,args?:unknown):Promise<unknown>
Invoke a named engine function inside the worker engine.
| Parameter | Type |
|---|---|
name | string |
args? | unknown |
Promise<unknown>
LixEnvironment.call
close():
Promise<void>
Promise<void>
create(
createOpts: {blob:ArrayBuffer; }):Promise<void>
| Parameter | Type |
|---|---|
createOpts | { blob: ArrayBuffer; } |
createOpts.blob | ArrayBuffer |
Promise<void>
exists():
Promise<boolean>
Promise<boolean>
export():
Promise<ArrayBuffer>
Export the SQLite database image as raw bytes.
Worker returns one of two shapes for performance:
{ blob: ArrayBuffer } (zero‑copy transfer){ buffer, offset, length } (single copy on host)Promise<ArrayBuffer>
open(
initOpts: {boot: {args:BootArgs; };emit: (ev:EngineEvent) =>void; }):Promise<{engine?:LixEngine; }>
| Parameter | Type |
|---|---|
initOpts | { boot: { args: BootArgs; }; emit: (ev: EngineEvent) => void; } |
initOpts.boot | { args: BootArgs; } |
initOpts.boot.args | BootArgs |
initOpts.emit | (ev: EngineEvent) => void |
Promise<{ engine?: LixEngine; }>
spawnActor(
opts:SpawnActorOptions):Promise<EnvironmentActorHandle>
Spawn a dedicated worker-based actor.
Messages emitted by the worker before any subscribers attach are buffered and replayed to the first subscriber so initialization events are never lost.
const actor = await env.spawnActor({ entryModule, name: "echo" });
const unsubscribe = actor.subscribe((message) => console.log(message));
actor.post({ type: "ping" });| Parameter | Type |
|---|---|
opts | SpawnActorOptions |
Promise<EnvironmentActorHandle>
staticclear():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!
Promise<void>