/*! * Copyright (c) 2026 Interop Alliance. All rights reserved. */ /** * The storage manager: the one remaining process-wide pointer, to the ACTIVE * {@link StorageContext}, plus the app-facing facades over it. Entity stores * are created at module level, before any session exists, so their verbs * cannot hold a context of their own; they reach the live session through * {@link requireStore} / {@link requireRemoteStore} / {@link stampLww} here, * which resolve to whichever context is active. Keeping the facade free of * store imports (no cycle) also lets the session store own the init/hydrate * ordering. * * Activation is deliberate about the two-providers case: a context with a * replica attached is live, and a live context is never replaced -- a second * session attaching a replica of its own throws instead of silently taking the * facades over. A context without a replica (created but not booted, or torn * down) is inert and is replaced without complaint, which is what a React * dev-mode double `useState` initializer or a test's sequence of stores needs. */ import type { LwwFields } from '@interop/was-sync'; import type { LocalStore } from './localStore.js'; import type { StorageContext } from './storageContext.js'; import type { WasRemoteStore } from './wasRemoteStore.js'; /** * Makes `context` the active one (called by the session store at creation, so * the facades resolve before any replica opens, again right before it opens a * replica, and by {@link StorageContext.attachStore}). Idempotent for the * context already active; throws while a DIFFERENT context still has a replica * attached. * * @param context {StorageContext} * @returns {void} */ export declare function activateStorageContext(context: StorageContext): void; /** * Releases the active pointer if `context` holds it (called by * `StorageContext.detachStore`, so every path that detaches a replica -- * `destroy`, logout, clear-data, the connected activation's fallback to * `local` -- releases it and re-claims on re-attach); a no-op for any other * context. Until the next claim the facades throw rather than resolve a * retired session. * * @param context {StorageContext} * @returns {void} */ export declare function deactivateStorageContext(context: StorageContext): void; /** * Whether a storage context is active. * * @returns {boolean} */ export declare function hasStorageContext(): boolean; /** * The active storage context, or throws if no session store has been created. * * @returns {StorageContext} */ export declare function requireStorageContext(): StorageContext; /** * The active session's opened replica, or throws if none is open. * * @returns {LocalStore} */ export declare function requireStore(): LocalStore; /** * Whether the active session has a replica open. * * @returns {boolean} */ export declare function hasStore(): boolean; /** * The active session's remote store, or throws while no wallet-connected * session is active. * * @returns {WasRemoteStore} */ export declare function requireRemoteStore(): WasRemoteStore; /** * Whether the active session has a remote store available. * * @returns {boolean} */ export declare function hasRemoteStore(): boolean; /** * The active session's writer id, or throws if no session store exists yet. * Deliberately never falls back to `getWriterId`: that would resolve under the * DEFAULT key prefix, so an app with a custom `storageKeyPrefix` would silently * stamp a second writer id. * * @returns {string} */ export declare function requireWriterId(): string; /** * Stamps a payload with fresh last-write-wins fields under the active session * (see {@link StorageContext.stampLww}); the entity-store write verbs call it * on every write, and an app writing through `LocalStore` directly does too. * * @param payload {object} * @returns {object} the payload with the LWW fields set */ export declare function stampLww(payload: T): T & LwwFields; //# sourceMappingURL=storageManager.d.ts.map