UNPKG

@stainless-code/persist

Version:

Hydration-aware persistence middleware for reactive stores (storage × codec seams, TanStack Store adapters, React hydration hook)

24 lines (23 loc) 1 kB
import { c as PersistStorage, d as StorageCodec, t as CreateStorageOptions, u as StateStorage } from "./persist-core-BTPBGNGX.mjs"; //#region src/persist-seroval.d.ts /** Same options as `createStorage` (`clearCorruptOnFailure`). */ type SerovalStorageOptions = CreateStorageOptions; /** * Seroval codec — round-trips `Set` / `Map` / `Date`. The `toJSON` / * `fromJSON` envelope keeps the payload JSON-serializable. */ declare const serovalCodec: <S>() => StorageCodec<S>; /** * Build a seroval-encoded `PersistStorage` (round-trips `Set`/`Map`/`Date`). * * @example * ```ts * // any string-keyed Storage works: localStorage, sessionStorage, custom * const storage = createSerovalStorage<Prefs>(() => localStorage, { * clearCorruptOnFailure: true, * }); * ``` */ declare function createSerovalStorage<S>(getStorage: () => StateStorage, options?: SerovalStorageOptions): PersistStorage<S> | undefined; //#endregion export { SerovalStorageOptions, createSerovalStorage, serovalCodec };