OPFS (Origin Private File System) storage adapter for Lix.
Provides persistent storage in the browser using the Origin Private File System API. Data persists across browser sessions and page refreshes.
Features auto-saving functionality when integrated with the hooks system.
new OpfsStorage(
args
):OpfsStorage
Creates a new OpfsStorage instance.
string
Path/name of the file to store in OPFS
OpfsStorage
close():
Promise
<void
>
Closes the database connection.
Performs a final save to OPFS before closing.
Promise
<void
>
connect(
args
):void
Called after the Lix instance is fully initialized. Sets up observers for persisting state changes.
void
export():
Promise
<Blob
>
Exports the current database state as a blob.
Promise
<Blob
>
getPersistedState():
Promise
<undefined
| {activeAccounts?
:Pick
<{id
:LixGenerated
<string
>;name
:string
; },"id"
|"name"
>[]; }>
Returns any persisted state that should be restored.
Promise
<undefined
| { activeAccounts?
: Pick
<{ id
: LixGenerated
<string
>; name
: string
; }, "id"
| "name"
>[]; }>
LixStorageAdapter
.getPersistedState
import(
blob
):Promise
<void
>
Imports data from a blob, replacing the current database content.
Also saves the imported data to OPFS.
Blob
Promise
<void
>
open():
Promise
<SqliteWasmDatabase
>
Opens a database with OPFS persistence.
Loads existing data from OPFS if available, otherwise creates a new lix. Returns the same database instance on subsequent calls.
Promise
<SqliteWasmDatabase
>
static
clean():Promise
<void
>
Cleans the entire OPFS by removing all files. Useful for debugging and testing.
TODO refactor to only delete opfs adapter related files after https://github.com/opral/lix-sdk/issues/332 is implemented.
Promise
<void
>
This will delete ALL files in OPFS, not just Lix files!