import { ConfigurableWindow } from '../_configurable.js'; import { StorageLike } from '../ssr-handlers.js'; import { Awaitable, ConfigurableEventFilter, RemovableSignal } from '@solidjs-use/shared'; import { Accessor } from 'solid-js'; interface Serializer { read: (raw: string) => T; write: (value: T) => string; } interface SerializerAsync { read: (raw: string) => Awaitable; write: (value: T) => Awaitable; } declare const StorageSerializers: Record<'boolean' | 'object' | 'number' | 'any' | 'string' | 'map' | 'set' | 'date', Serializer>; declare const customStorageEventName = "vueuse-storage"; interface StorageEventLike { storageArea: StorageLike | null; key: StorageEvent['key']; oldValue: StorageEvent['oldValue']; newValue: StorageEvent['newValue']; } interface UseStorageOptions extends ConfigurableEventFilter, ConfigurableWindow { /** * Watch for deep changes * * @default true */ deep?: boolean; /** * Listen to storage changes, useful for multiple tabs application * * @default true */ listenToStorageChanges?: boolean; /** * Write the default value to the storage when it does not exist * * @default true */ writeDefaults?: boolean; /** * Merge the default value with the value read from the storage. * * When setting it to true, it will perform a **shallow merge** for objects. * You can pass a function to perform custom merge (e.g. deep merge), for example: * * @default false */ mergeDefaults?: boolean | ((storageValue: T, defaults: T) => T); /** * Custom data serialization */ serializer?: Serializer; /** * On error callback * * Default log error to `console.error` */ onError?: (error: unknown) => void; } declare function useStorage(key: string, defaults: Accessor, storage?: StorageLike, options?: UseStorageOptions): Accessor; declare function useStorage(key: string, defaults: string, storage?: StorageLike, options?: UseStorageOptions): RemovableSignal; declare function useStorage(key: string, defaults: Accessor, storage?: StorageLike, options?: UseStorageOptions): Accessor; declare function useStorage(key: string, defaults: boolean, storage?: StorageLike, options?: UseStorageOptions): RemovableSignal; declare function useStorage(key: string, defaults: Accessor, storage?: StorageLike, options?: UseStorageOptions): Accessor; declare function useStorage(key: string, defaults: number, storage?: StorageLike, options?: UseStorageOptions): RemovableSignal; declare function useStorage(key: string, defaults: Accessor, storage?: StorageLike, options?: UseStorageOptions): Accessor; declare function useStorage(key: string, defaults: T, storage?: StorageLike, options?: UseStorageOptions): RemovableSignal; declare function useStorage(key: string, defaults: Accessor, storage?: StorageLike, options?: UseStorageOptions): Accessor; declare function useStorage(key: string, defaults: null, storage?: StorageLike, options?: UseStorageOptions): RemovableSignal; export { Serializer, SerializerAsync, StorageEventLike, StorageSerializers, UseStorageOptions, customStorageEventName, useStorage };