storage
Declare storage.maxBytes. Binary objects are private to the plugin and local to the device, persisting across View and app restarts. read returns null for an absent key. Writes are subject to the declared quota and host limits. Lite API 3.11 adds opt-in storage.atomic: true for readVersioned and compareAndWrite. These compare and replace current object bytes atomically across owner windows; conflicts do not write. Re-read and replay the specific edit, not a stale full snapshot.
Usage guide: services. API index.
Signatures, parameters and return types are generated from the SDK. Optional members are not available in every host and context.
PluginStorage
Section titled “PluginStorage”PluginStorage.list
Section titled “PluginStorage.list”Supported hosts: Lite
List stored objects, optionally filtered by key prefix.
list(prefix?: string): Promise<Array<{ key: string; size: number;}>>;| Parameter | Type | Required |
|---|---|---|
prefix |
string |
No |
Returns: Promise<Array<{ key: string; size: number; }>>.
PluginStorage.read
Section titled “PluginStorage.read”Supported hosts: Lite
Read object bytes, or null for an absent key.
read(key: string): Promise<Uint8Array | null>;| Parameter | Type | Required |
|---|---|---|
key |
string |
Yes |
Returns: Promise<Uint8Array | null>.
PluginStorage.write
Section titled “PluginStorage.write”Supported hosts: Lite
Write an object within the plugin’s storage quota.
write(key: string, value: Uint8Array): Promise<void>;| Parameter | Type | Required |
|---|---|---|
key |
string |
Yes |
value |
Uint8Array |
Yes |
Returns: Promise<void>.
PluginStorage.delete
Section titled “PluginStorage.delete”Supported hosts: Lite
Delete a private stored object.
delete(key: string): Promise<void>;| Parameter | Type | Required |
|---|---|---|
key |
string |
Yes |
Returns: Promise<void>.
PluginStorage.readVersioned
Section titled “PluginStorage.readVersioned”Supported hosts: Lite
Lite API 3.11; requires storage.atomic: true. Read bytes and their opaque current-bytes token together. Both are null for an absent key; an empty stored object has a non-null token. Tokens are stable for identical bytes, not monotonic revision numbers.
readVersioned?(key: string): Promise<StorageSnapshot>;| Parameter | Type | Required |
|---|---|---|
key |
string |
Yes |
Returns: Promise<StorageSnapshot>.
PluginStorage.compareAndWrite
Section titled “PluginStorage.compareAndWrite”Supported hosts: Lite
Lite API 3.11; requires storage.atomic: true. Compare expectedVersion with the current token and replace bytes in one host operation. A conflict returns applied: false and the current token without writing. Reread and replay the specific edit before retrying. The 4 MiB object limit and declared plugin quota still apply.
compareAndWrite?(key: string, expectedVersion: string | null, data: Uint8Array): Promise<StorageWriteResult>;| Parameter | Type | Required |
|---|---|---|
key |
string |
Yes |
expectedVersion |
string | null |
Yes |
data |
Uint8Array |
Yes |
Returns: Promise<StorageWriteResult>.
Related types: StorageSnapshot, StorageWriteResult.
StorageSnapshot
Section titled “StorageSnapshot”StorageSnapshot.data
Section titled “StorageSnapshot.data”Supported hosts: Lite
data: Uint8Array | null;StorageSnapshot.version
Section titled “StorageSnapshot.version”Supported hosts: Lite
version: string | null;StorageWriteResult
Section titled “StorageWriteResult”StorageWriteResult.applied
Section titled “StorageWriteResult.applied”Supported hosts: Lite
applied: boolean;StorageWriteResult.version
Section titled “StorageWriteResult.version”Supported hosts: Lite
version: string | null;