wxt-zustand
Version:
High-performance Zustand state management for WXT web extensions with seamless cross-tab synchronization and sub-10ms React re-renders
35 lines • 1.76 kB
TypeScript
import type { StoreApi } from 'zustand';
import type { StoreConfiguration } from '../types';
import { connectAndFetchInitialState as _connectAndFetchInitialState } from './connect';
import { setupBidirectionalSync as _setupBidirectionalSync } from './sync';
/**
* Returns the cached readiness promise for a given store and name, if any.
*/
export declare function getStoreReadiness<S>(storeName: string, store: StoreApi<S>): Promise<void> | undefined;
/**
* Caches a readiness promise for a given store and name.
*/
export declare function setStoreReadiness<S>(storeName: string, store: StoreApi<S>, readiness: Promise<void>): void;
/**
* Cleanup cached readiness data.
* - When storeName is provided, remove only that entry.
* - Otherwise, remove the entire record for the StoreApi.
*/
export declare function cleanupStoreReadiness<S>(store: StoreApi<S>, storeName?: string): void;
/**
* For diagnostics/tests only: expose internal state length.
*/
export declare function __readinessSizeFor<S>(store: StoreApi<S>): number;
export declare function __setReadyImplementations(impl: {
connectAndFetchInitialState?: typeof _connectAndFetchInitialState;
setupBidirectionalSync?: typeof _setupBidirectionalSync;
}): void;
export declare function __resetReadyImplementations(): void;
/**
* Orchestrate frontend readiness for a WXT Zustand store.
* - Uses WXT-native primitives for optimal performance and compatibility.
* - Ensures single initialization per (store instance + name) via readiness cache.
* - Applies initial state, then sets up bidirectional sync.
*/
export declare function wxtZustandStoreReady<S>(storeName: string, store: StoreApi<S>, config?: StoreConfiguration<S>): Promise<StoreApi<S>>;
//# sourceMappingURL=ready.d.ts.map