export type Serializer = { parse(value: string): T; stringify(value: T): string; }; export type Adapter = { clear?(): void; getItem(key: string): string | null; removeItem(key: string): void; setItem(key: string, value: string): void; setItem(key: string, value: string, config?: SetConfig): void; }; export type AsyncAdapter = { clear?(): Promise; getItem(key: string): Promise; removeItem(key: string): Promise; setItem(key: string, value: string): Promise; setItem(key: string, value: string, config?: SetConfig): Promise; }; export type StorageConfig = { prefix?: string; serializer?: Serializer; adapter?: Adapter; }; export type AsyncStorageConfig = { prefix?: string; serializer?: Serializer; adapter: AsyncAdapter; }; export type DefineResponse = { get(): T | null; set(value: unknown, config?: SetConfig): boolean; remove(): void; }; export type AsyncDefineResponse = { get(): Promise; set(value: unknown, config?: SetConfig): Promise; remove(): Promise; }; /** * Abstract base class for browser storage implementations. * @template SetConfig - Optional configuration type for the setItem method. */ export declare abstract class AbstractBrowserStorage { abstract adapter: Adapter | AsyncAdapter; abstract prefix: string; abstract serializer: Serializer; protected toStore(value: unknown): string; protected fromStore(item: unknown): T | null; } /** * Synchronous browser storage class. * @template SetConfig - Optional configuration type for the setItem method. */ export declare class BrowserStorage extends AbstractBrowserStorage { readonly adapter: Adapter; readonly prefix: string; readonly serializer: Serializer; constructor(config?: StorageConfig); clear(): void; get(key: string): T | null; set(key: string, value?: unknown, config?: SetConfig): boolean; remove(key: string): void; defineGroup>(group: GenericRecord): Record>; define(key: string, defaultConfig?: SetConfig): DefineResponse; } /** * Asynchronous browser storage class with in memory cached storage. * @template SetConfig - Optional configuration object for the setItem method. */ export declare class AsyncBrowserStorage extends AbstractBrowserStorage { readonly adapter: AsyncAdapter; readonly cachedAdapter: MemoryStorageAdapter; readonly prefix: string; readonly serializer: Serializer; constructor(config: AsyncStorageConfig); syncCache(): Promise; getCache(key: string): string | null; setCache(key: string, value?: string): void; removeCache(key: string): void; clear(): Promise; get(key: string): Promise; set(key: string, value?: unknown, config?: SetConfig): Promise; remove(key: string): Promise; defineGroup>(group: GenericRecord): Record>; define(key: string, defaultConfig?: SetConfig): AsyncDefineResponse; } /** * Local storage class that extends BrowserStorage. * Uses localStorage if available, otherwise falls back to in-memory storage. */ export declare class LocalStorage extends BrowserStorage { constructor(config?: Omit); } /** * Session storage class that extends BrowserStorage. * Uses sessionStorage if available, otherwise falls back to in-memory storage. */ export declare class SessionStorage extends BrowserStorage { constructor(config?: Omit); } /** In-memory storage adapter implementing the Adapter interface. */ export declare class MemoryStorageAdapter implements Adapter { private storage; entries(): IterableIterator<[string, string]>; clear(): void; getItem(key: string): string | null; removeItem(key: string): void; setItem(key: string, value: string): void; }