import type { Changes as BaseChanges, Immutable as AutoImmutable, Value } from '@webkrafters/auto-immutable'; import { FULL_STATE_SELECTOR } from './constants'; import { createEagleEye, Channel } from './main'; export type { BaseType, ClearCommand, Immutable as AutoImmutable, KeyType, MoveCommand, PushCommand, ReplaceCommand, SetCommand, SpliceCommand, TagCommand, TagType, UpdateStats, UpdatePayload, UpdatePayloadArray } from '@webkrafters/auto-immutable'; export type State = Value; export type ShutdownMonitor = (reason: ShutdownReason) => void; export type Listener = (changes: Changes, changedPathsTokens: Readonly>>, netChanges: Readonly, mayHaveChangesAt: (pathTokens: Array) => boolean) => void; export interface ContextInfra { prehooks?: Prehooks; storage?: IStorage; } export interface RawProviderProps extends ContextInfra { value?: T; } export interface ProviderProps extends ContextInfra { value?: AutoImmutable; } export type Text = string | number; export type FullStateSelector = typeof FULL_STATE_SELECTOR; export type ObjectSelector = Record; export type ArraySelector = Array; export type SelectorMap = ObjectSelector | ArraySelector | undefined | null; type Replace

= P extends `${infer K}${S}${infer PP}` ? `${K}${R}${Replace}` : P; type DotizedPath

= Replace, '[', '.'>, '..', '.'>, '...', '.'>; type DrillType, P extends string, W extends State> = P extends `${infer K}.${infer R}` ? T[K] extends {} ? DrillType : any : P extends FullStateSelector ? W : T[P]; type ExtricateTypeFrom = DrillType, T>; export type Data = S extends undefined | null ? {} : S extends ObjectSelector ? { [K in keyof S]: S[K] extends string ? ExtricateTypeFrom : S[K] extends keyof T ? T[S[K]] : any; } : S extends Array ? U extends FullStateSelector ? Record : Record : Record; export type Changes = BaseChanges; interface StorageGetter { (key: null): T; (key: string): T; } interface StorageDeleteFn { (key: null): void; (key: string): void; } interface StorageSetter { (key: null, data: T): void; (key: string, data: T): void; } export interface IStorage { clone: (data: T) => T; getItem: StorageGetter; removeItem: StorageDeleteFn; setItem: StorageSetter; } export interface CurrentStorage extends IStorage { isKeyRequired?: boolean; } export interface Prehooks { resetState?: (resetData: Partial, state: { current: T; original: T; }) => boolean; setState?: (newChanges: Changes) => boolean; } export type Unsubscribe = (...args: Array) => void; export declare const enum Phase { UN_OPENED = -1, CLOSED = 0, OPENED = 1, CLOSING = 2 } export declare const enum ShutdownReason { CACHE = "CACHE DATA SHUTDOWN", CONTEXT = "CONTEXT-WIDE SHUTDOWN", LOCAL = "CURRENT STORE INITIATED SHUTDOWN" } export interface IStore { resetState: (propertyPaths?: Array) => void; setState: (changes: Changes) => void; } export interface Store extends IStore { data: Data; } export interface StoreRef extends IStore { getState: (propertyPaths?: Array) => T; subscribe: { (eventType: "closing", listener: ShutdownMonitor): Unsubscribe; (eventType: "data-updated", listener: Listener): Unsubscribe; }; } export interface StoreInternal extends StoreRef { close: () => void; closed: boolean; } export interface BaseStream { (selectorMap?: S): Channel; } export interface Stream extends BaseStream { (selectorMap?: S): Store; } export { CLEAR_TAG, DELETE_TAG, FULL_STATE_SELECTOR, MOVE_TAG, NULL_SELECTOR, PUSH_TAG, REPLACE_TAG, SET_TAG, SPLICE_TAG, Tag, } from './constants'; export { Channel, createEagleEye, EagleEyeContext } from './main'; export default createEagleEye;