Skip to content

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.

Source

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; }>>.

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 &#124; null>.

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>.

Supported hosts: Lite

Delete a private stored object.

delete(key: string): Promise<void>;
Parameter Type Required
key string Yes

Returns: Promise<void>.

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>.

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 &#124; null Yes
data Uint8Array Yes

Returns: Promise<StorageWriteResult>.

Related types: StorageSnapshot, StorageWriteResult.

Source

Supported hosts: Lite

data: Uint8Array | null;

Supported hosts: Lite

version: string | null;

Source

Supported hosts: Lite

applied: boolean;

Supported hosts: Lite

version: string | null;