import Logger from "./logger.js"; import CombinedStorage from "./storages/combined-storage.js"; import StoreStatus from "./store-status.js"; import { IConstructableStore, IGroupedStores, IManagerOptions, IManagerParams, IPersistOptions, IStoreParams, IStorePersisted, TAnyStore, TInitStore, TStoreDefinition, TStores } from "./types.js"; /** * Mobx stores manager */ declare class Manager { /** * Manger instance */ protected static instance: Manager; /** * Created stores */ protected readonly stores: Map>; /** * Relations between stores */ protected readonly storesRelations: Map; parentId: string | null; componentName?: string | undefined; }>; /** * Save persisted stores identities */ protected static readonly persistedStores: Set; /** * Initial stores state (local storage, custom etc.) */ protected readonly initState: Record; /** * Storage for persisted stores */ readonly storage?: CombinedStorage; /** * Additional store's constructor params */ protected readonly storesParams: IManagerParams['storesParams']; /** * Manager options */ readonly options: IManagerOptions; /** * Suspense stores relations * @see withStores */ protected suspenseRelations: Map>; /** * Mobx manager logger */ protected readonly logger: Logger; /** * @constructor */ /** * @constructor */ constructor({ initState, storesParams, storage, options, logger }?: IManagerParams); /** * Init store manager */ /** * Init store manager */ init(): Promise; /** * Get manager instance */ /** * Get manager instance */ static get(): Manager; /** * Get all stores */ /** * Get all stores */ getStores(): Manager['stores']; /** * Get stores relations */ /** * Get stores relations */ getStoresRelations(): Manager['storesRelations']; /** * Get suspense relations with stores */ /** * Get suspense relations with stores */ getSuspenseRelations(): Manager['suspenseRelations']; /** * Get persisted stores ids */ /** * Get persisted stores ids */ static getPersistedStoresIds(): Set; /** * Push initial state dynamically * E.g. when stream html */ pushInitState: (storesState?: Record) => void; /** * Get store identity */ /** * Get store identity */ protected getStoreId(store: IConstructableStore | TInitStore, params?: IStoreParams): string; /** * Get exist store */ /** * Get exist store */ getStore(store: IConstructableStore, params?: IStoreParams): T | undefined; /** * Lookup store */ /** * Lookup store */ protected lookupStore(id: string, params: IStoreParams): TInitStore | undefined; /** * Get bigger context from two */ /** * Get bigger context from two */ protected getBiggerContext(ctx1?: string, ctx2?: string): string | undefined; /** * Create new store instance */ /** * Create new store instance */ protected createStore(store: IConstructableStore, params: Omit, 'key'>): T; /** * Create stores for component * * NOTE: use only inside withStores wrapper */ /** * Create stores for component * * NOTE: use only inside withStores wrapper */ createStores(map: [string, TStoreDefinition][], parentId: string, contextId: string, suspenseId: string, componentName: string, componentProps?: Record): IGroupedStores; /** * Create empty relation context */ /** * Create empty relation context */ protected createRelationContext(contextId: string, parentId?: string, componentName?: string): void; /** * Delete relation context id */ /** * Delete relation context id */ protected removeRelationContext(contextId: string): void; /** * Append callback to store destroy lifecycle */ /** * Append callback to store destroy lifecycle */ protected appendDestroyCallback(store: TStores[string], callback?: () => void): void; /** * Prepare store before usage */ /** * Prepare store before usage */ protected prepareStore(store: TStores[string]): void; /** * Remove store */ /** * Remove store */ protected removeStore(store: TStores[string]): void; /** * Mount stores to component * * NOTE: use only inside withStores wrapper */ /** * Mount stores to component * * NOTE: use only inside withStores wrapper */ mountStores(contextId: string, { globalStores, relativeStores }: Partial): () => void; /** * Destroy manager stores and detach internal relations */ /** * Destroy manager stores and detach internal relations */ destroy(): void; /** * Change the stores status to touched */ /** * Change the stores status to touched */ touchedStores(stores: TStores): void; /** * Change store status */ /** * Change store status */ protected setStoreStatus(store: TStores[string], status: StoreStatus): void; /** * Get store state */ /** * Get store state */ getStoreState(store: TAnyStore, withNotExported?: boolean): Record; /** * Get store's state */ /** * Get store's state */ toJSON(ids?: string[], isIncludeExported?: boolean): Record; /** * Save persisted store state to provided storage */ /** * Save persisted store state to provided storage */ savePersistedStore(store: IStorePersisted): Promise; /** * Get observable store props (fields) */ /** * Get observable store props (fields) */ static getObservableProps(store: TAnyStore, withNotExported?: boolean): Record; /** * Persist store */ /** * Persist store */ static persistStore(store: IConstructableStore, id: string, options?: IPersistOptions): IConstructableStore; } export { Manager as default };