import type { Patch } from 'mutative'; import { stateKey, storeKey, subscriptionsKey, identifierKey, bootstrappedKey, usm, strictKey, enablePatchesKey, } from './constant'; export interface Config { enablePatches?: boolean; hook?(store: Store, action: Action): Action; } export interface StoreOptions { modules: any[]; strict?: boolean; } export interface Store> { dispatch(action: Action): void; getState(): T; subscribe(listener: Subscription): Unsubscribe; } export interface Service = Record> { name?: string; readonly [identifierKey]: string; readonly [strictKey]: boolean; readonly [enablePatchesKey]: boolean; readonly [bootstrappedKey]: boolean; readonly [stateKey]: T; readonly [storeKey]: Store; readonly [subscriptionsKey]: Subscription[]; [K: string]: any; } export type Subscription = () => void; export type Unsubscribe = () => void; export interface PropertyDescriptor extends TypedPropertyDescriptor { initializer(): T; } export interface Action> { type: string; method: string | symbol; params: any[]; _state: T; _usm: typeof usm; _patches?: Patch[]; _inversePatches?: Patch[]; } export type Subscribe = (module: any, listener: () => void) => Unsubscribe; export type Watch =

( module: any, selector: () => P extends true ? readonly [...T] | [...T] : T, watcher: (newValue: T, oldValue: T) => void, options?: { multiple?: P; isEqual?: (x: unknown, y: unknown) => boolean; } ) => Unsubscribe;