import superjson from 'superjson'; /** * @class HyperStorage * @classdesc A lightweight wrapper for localStorage/sessionStorage * with efficient caching and type-preserving serialization. * * @source https://github.com/Khoeckman/HyperStorage */ declare class HyperStorage { #private; /** Version of the library, injected via Rollup replace plugin. */ static readonly version: string; static readonly superjson: typeof superjson; /** Key name under which the data is stored. */ readonly itemName: string; /** Default value used when the key does not exist in storage. */ readonly defaultValue: T; /** The underlying storage backend (defaults to `window.localStorage`). */ readonly storage: Storage; /** * Creates a new HyperStorage instance. * * @param {string} itemName - The key name under which the data will be stored. * @param {T} [defaultValue] - Default value assigned to the key if it does not exist yet. * @param {Object} [options={}] - Optional configuration parameters. * @param {(value: T) => string} [options.encodeFn] - Optional function to encode stored values. * @param {(value: string) => string} [options.decodeFn] - Optional function to decode stored values. * @param {Storage} [options.storage=window.localStorage] - Optional custom storage backend. * * @throws {TypeError} If `itemName` is not a string. * @throws {TypeError} If `encodeFn` or `decodeFn` are defined but not functions. * @throws {TypeError} If `storage` does not implement the standard Storage API. */ constructor(itemName: string, defaultValue: T, options?: { encodeFn?: (value: T) => string; decodeFn?: (value: string) => T; storage?: Storage; }); /** * Sets the current value in storage. * Automatically caches, stringifies and encodes the value. */ set value(value: T); /** * Gets the current cached value. */ get value(): T; /** * Allows using the value setter with property assignment or a callback. */ set(key: K, value: T[K]): T; set(callback: (value: T) => T): T; /** * Synchronizes the cached value of this wrapper with the value in storage. * * This is only necessary if the stored value may have been modified without using the setter of this class. * Using this function is not type safe. */ sync(decodeFn?: (value: string) => T): unknown; /** * Resets the stored value to its configured default. * * Updates both the underlying storage and the internal cache. */ reset(): T; /** * Checks whether the current value matches the configured default value. * * Uses reference comparison for objects and strict equality for primitives. */ isDefault(): boolean; } export default HyperStorage;