// @ts-nocheck import React, { Component, ReactNode, ComponentClass, FC } from 'react'; /** * concent types.d.ts file v2.21.10 */ declare const mvoid = '$$concent_void_module_624313307'; type CC_CLASS = '$$CcClass'; type CC_HOOK = '$$CcHook'; type CC_FRAGMENT = '$$CcFrag'; type CC_CUSTOMIZE = '$$CcCust'; type CC_OB = '$$CcOb'; export type MODULE_GLOBAL = '$$global'; export type MODULE_DEFAULT = '$$default'; type MODULE_CC = '$$cc'; export type MODULE_VOID = typeof mvoid; type CcCst = { MODULE_GLOBAL: MODULE_GLOBAL; MODULE_DEFAULT: MODULE_DEFAULT; MODULE_CC: MODULE_CC; MODULE_VOID: MODULE_VOID; MODULE_CC_ROUTER: '$$CONCENT_ROUTER'; AUTO_VAL: Symbol, CC_CLASS: CC_CLASS; CC_HOOK: CC_HOOK; CC_FRAGMENT: CC_FRAGMENT; CC_OB: CC_OB; CC_CUSTOMIZE: CC_CUSTOMIZE; CC_PREFIX: '$$Cc'; CC_DISPATCHER: '$$Dispatcher'; CCSYNC_KEY: typeof Symbol; SIG_FN_START: 10; SIG_FN_END: 11; SIG_FN_QUIT: 12; SIG_FN_ERR: 13; SIG_MODULE_CONFIGURED: 14; SIG_STATE_CHANGED: 15; SIG_ASYNC_COMPUTED_START: 30, SIG_ASYNC_COMPUTED_END: 31, SIG_ASYNC_COMPUTED_ERR: 32, SIG_ASYNC_COMPUTED_BATCH_START: 33, SIG_ASYNC_COMPUTED_BATCH_END: 34, RENDER_NO_OP: 1; RENDER_BY_KEY: 2; RENDER_BY_STATE: 3; FOR_CUR_MOD: 1; FOR_ANOTHER_MOD: 2; // EFFECT_AVAILABLE: 1; // EFFECT_STOPPED: 0; DISPATCH: 'dispatch'; SET_STATE: 'setState'; SET_MODULE_STATE: 'setModuleState'; FORCE_UPDATE: 'forceUpdate'; INVOKE: 'invoke'; SYNC: 'sync'; CATE_MODULE: 'module'; CATE_REF: 'ref'; FN_CU: 'computed'; FN_WATCH: 'watch'; } export type CalledBy = CcCst['DISPATCH'] | CcCst['SET_STATE'] | CcCst['SET_MODULE_STATE'] | CcCst['FORCE_UPDATE'] | CcCst['INVOKE'] | CcCst['SYNC']; export type SigFn = CcCst['SIG_FN_START'] | CcCst['SIG_FN_END'] | CcCst['SIG_FN_QUIT'] | CcCst['SIG_FN_ERR']; export type SigModuleConfigured = CcCst['SIG_MODULE_CONFIGURED']; export type SigStateChanged = CcCst['SIG_STATE_CHANGED']; // export interface IAnyObj { [key: string]: any }; type ValueRange = string | number | boolean | symbol | object | null | undefined; type StrKeys = Exclude; /** * 注意: * IState 能约束 plain json object, 而 IAnyObj 不可以 * const o1: IState = [1]; // error * const o2: IAnyObj = [1]; // ok */ export interface IState { [key: string]: ValueRange; } export interface IAnyObj { [key: string]: any } export interface IAnyFn { (...args: any): any; } export interface IAnyFnPromise { (...args: any): any | Promise; } export interface IAnyFnReturnObj { (...args: any): IAnyObj; } export interface IAnyFnInObj { [key: string]: IAnyFn } export interface IAnyClass { new(...args: any[]): any; } export interface ToggleBoolFn { (...args: any): any; } export interface SyncValueToStateFn { (...args: any): any; } // let user export syncer new type when user define private state export type Syncer = FullState extends IAnyObj ? { [key in keyof FullState]: SyncValueToStateFn } : {}; // let user export syncerOfBool new type when user define private state export type SyncerOfBool = FullState extends IAnyObj ? { [key in GetBoolKeys]: ToggleBoolFn } : {}; export type ComputedFn = ( newState: S, oldState: S, fnCtx: FnCtx, ) => any; export interface IComputedFnDesc { fn: Fn; sort?: number; compare?: boolean; depKeys?: DepKeys; retKeyDep?: boolean; } export interface IReducerFn { // let configure works well, set actionCtx generic type any (payload: any, moduleState: S, actionCtx: IActionCtx): any | Promise; } // !!!use infer export type ArrItemsType = T extends (any[] | readonly any[]) ? ( T extends Array ? E : never ) : any; export type ComputedValType = { readonly [K in keyof T]: T[K] extends IAnyFn ? GetPromiseT : (T[K] extends IComputedFnDesc ? GetPromiseT : never); } // for heping refComputed to infer type export type ComputedValTypeForFn = { readonly [K in keyof ReturnType]: ReturnType[K] extends IAnyFn ? GetPromiseT[K]> : (ReturnType[K] extends IComputedFnDesc ? GetPromiseT[K]['fn']> : never); } export type SetupFn = (ctx: ICtxBase) => IAnyObj | void; export type SettingsType = Fn extends SetupFn ? (ReturnType extends IAnyObj ? ReturnType : {}) : {}; /** * inspired by * https://github.com/pirix-gh/ts-toolbelt/blob/master/src/List/Tail.ts */ type C2List = ReadonlyArray; type Tail = ((...t: L) => any) extends ((head: any, ...tail: infer LTail) => any) ? LTail : never type GetRestItemsType> = Exclude; // when set bindCtxToMethod as true, user should use SettingsCType to infer ctx.settings type export type SettingsCType = ReturnType extends IAnyObj ? ( { [key in keyof ReturnType]: ( ReturnType[key] extends IAnyFn ? (...p: GetRestItemsType[key]>>>) => ReturnType[key]> : ReturnType[key] ) } ) : {} export type StateType = S extends IAnyFn ? ReturnType : S; type RenderKey = string | number | Array | null; export interface IDispatchOptions { /** * force update module state no matter state changed or not, bydefaut is false */ force?: boolean; silent?: boolean; lazy?: boolean; renderKey?: RenderKey; /** * delay broadcast state to other refs */ delay?: number; } /** * 自于 mrc.{xxxx} 调用返回的对象类型 */ export interface ReducerCallerParams { module: string, fnName: string, payload: any, renderKey: any, delay: any, } /** * 允许用户定义 xxx(payload: number| null, state: State) 时, 可以 mr.xxx() 不传参数 ts 不报错 */ type ReducerMethod = T[K] extends (arg0: infer T, ...args: any[]) => infer R ? ( undefined extends T ? (payload?: T, renderKeyOrOptions?: RenderKey | IDispatchOptions, delay?: number) => R : (payload: T, renderKeyOrOptions?: RenderKey | IDispatchOptions, delay?: number) => R ) : unknown; /** * 推导模块里来得mrc 调用的单个reducer方法的类型 */ type ReducerCallerMethod = T[K] extends IAnyFn ? ( payload: Parameters[0] extends undefined ? void : Parameters[0], renderKeyOrOptions?: RenderKey | IDispatchOptions, delay?: number, ) => ReducerCallerParams : unknown; // ) => ReducerCallerParams[0] extends undefined ? void : Parameters[0]> : unknown; export type ReducerType = Rd extends IAnyObj ? ( Rd['setState'] extends Function ? { readonly [K in keyof Rd]: ReducerMethod } : ( { readonly [K in keyof Rd]: ReducerMethod; } & { setState:

= {}>(payload: P, renderKeyOrOptions?: RenderKey | IDispatchOptions, delay?: number) => Promise

} )) : {}; type ReducerMethodOfDef = RdFn extends IAnyFn ? ( payload: any, moduleState: S, actionCtx: IActionCtxBase, ) => any : unknown; export type ReducerTypeOfDef = Rd extends IAnyObj ? ( { readonly [K in keyof Rd]: Rd[K] extends ReducerMethodOfDef ? ReducerMethodOfDef : never } ) : {}; /** * 推导模块caller类型的reducer方法集合类型 * 即 ctx.mrc 类型 */ export type ReducerCallerType = T extends IAnyObj ? ( T['setState'] extends Function ? { readonly [K in keyof T]: ReducerCallerMethod } : ( { readonly [K in keyof T]: ReducerCallerMethod } & { setState:

(payload: P, renderKeyOrOptions?: RenderKey | IDispatchOptions, delay?: number) => { module: string, fnName: 'setState', payload: P, renderKey: any, delay: any, } } )) : {}; // attention here omit Ghosts[number] export type ReducerGhostType = Ghosts extends readonly string[] ? { [key in Ghosts[number]]: Omit } : {}; export interface EvMapBase { [key: string]: any[]; } /** watch all keys changed */ export type TStar = '*'; /** collect key change automatically */ export type TAuto = '-'; export type DepKeys = Array | TStar | TAuto; type DepKeyCollector = (state: State) => any; export type DepKeysOfWatch = DepKeyCollector | Array | TStar | TAuto; // type EvSyncReturn = (event: React.ChangeEvent) => void; type OnCallBack = (...args: EventCbArgs) => void; type GetComputedFn = ( newState: any, oldState: any, fnCtx: FnCtx, ) => T; interface IDict { [customizedKey: string]: any; // [customizedKey2: number]: any; } interface IDictWithT { [customizedKey: string]: T; // [customizedKey2: number]: any; } export interface IRootBase extends IDict { [mvoid]: any $$global: any; $$default: any; [customizedModuleKey: string]: any; } type PropKey = string | number | symbol; type FnState = IAnyFnReturnObj | IAnyObj; // export function dodo(a: TA, b: TB): void; type MyPick = Pick; type Super = T extends infer U ? U : object; /** * * @param eventName * @param cb * suggest use conditional type to maitain EventCbArgsType * // or type EventCbArgsType type ET = EventName extends 'foo' ? [string, number] : EventName extends 'bar' ? [string, boolean] : []; */ declare function refCtxOn(eventName: string, cb: OnCallBack): void; declare function refCtxOn(eventDesc: [string, string?], cb: OnCallBack): void; declare function refCtxOn(eventDesc: { name: string, identity?: string }, cb: OnCallBack): void; // this way is better!!! declare function refCtxOn(eventName: EvName, cb: OnCallBack): void; declare function refCtxOn(eventDesc: [string, string?], cb: OnCallBack): void; declare function refCtxOn(eventDesc: { name: string, identity?: string }, cb: OnCallBack): void; type EventDesc = { name: string, identity?: string, canPerform?: (ctx: ICtxBase) => boolean, module?: string, ccClassKey?: string, ccUniqueKey?: string }; declare function refCtxEmit(eventName: string, ...args: EventCbArgs): void; declare function refCtxEmit(eventDesc: [string, string?], ...args: EventCbArgs): void; declare function refCtxEmit(eventDesc: EventDesc, ...args: EventCbArgs): void; // this way is better!!! declare function refCtxEmit(eventName: string, ...args: EvMap[EvName]): void; declare function refCtxEmit(eventDesc: [string, string?], ...args: EvMap[EvName]): void; declare function refCtxEmit(eventDesc: EventDesc, ...args: EvMap[EvName]): void; export interface OffOptions { module?: string; ccClassKey?: string; ccUniqueKey?: string; } declare function refCtxOff(eventName: string, offOptions?: OffOptions): void; declare function refCtxOff(eventDesc: [string, string?], offOptions?: OffOptions): void; declare function refCtxOff(eventDesc: { name: string, identity?: string }, offOptions?: OffOptions): void; // 用户定义 function xx():any 时,Promise 会推导T为unknown,所以加一个类型强转 export type GetPromiseT any> = F extends (...args: any) => Promise ? (T extends unknown ? any : T) : ReturnType; /** * * @param type * @param payload * @param renderKey * @param delay * if first arg type is string, user should manually make sure fnName an fn is mapped correctly, if you don not want to do so, you can write code like below * * function aaa(){}; function bbb(){}; type reducerFnType = FnName extends 'aaa' ? typeof aaa : FnName extends 'bbb' ? typeof bbb : null; type PayloadType = (Parameters>)[0]; type reducerFnResultType = ReturnType>; */ type RenderKeyOrOpts = RenderKey | IDispatchOptions; declare function refCtxDispatch (type: string, payload?: (Parameters)[0], renderKey?: RenderKeyOrOpts, delay?: number): Promise>; declare function refCtxDispatch (type: RdFn, payload?: (Parameters)[0], renderKey?: RenderKeyOrOpts, delay?: number): Promise>; declare function refCtxDispatch (type: { module?: string, fn: RdFn, cb?: (state: FullState) => void }, payload?: (Parameters)[0], renderKey?: RenderKeyOrOpts, delay?: number): Promise>; declare function refCtxDispatch (type: { module?: string, type: string, cb?: (state: FullState) => void }, payload?: (Parameters)[0], renderKey?: RenderKeyOrOpts, delay?: number): Promise>; declare function refCtxDispatch (type: [string, RdFn], payload?: (Parameters)[0], renderKey?: RenderKeyOrOpts, delay?: number): Promise>; declare function refCtxInvoke (fn: UserFn, payload?: (Parameters)[0], renderKey?: RenderKeyOrOpts, delay?: number): Promise>; declare function refCtxInvoke (fn: UserFn, payload?: (Parameters)[0], renderKey?: RenderKeyOrOpts, delay?: number): Promise>; declare function refCtxInvoke (fn: { module: string, fn: UserFn }, payload?: (Parameters)[0], renderKey?: RenderKeyOrOpts, delay?: number): Promise>; declare function refCtxForceUpdate(cb?: (newFullState: FullState) => void, renderKey?: RenderKeyOrOpts, delay?: number): void; declare function refCtxGetConnectWatchedKeys(): { [key: string]: string[] }; declare function refCtxGetConnectWatchedKeys(module: string): string[]; declare function reducerSetState(state: Partial, cb?: (newFullState: FullState) => void, renderKey?: RenderKeyOrOpts, delay?: number): Promise; type ComputeCb = (newState: FullState, oldState: FullState, fnCtx: _IFnCtx) => any; export type MultiComputed = { [retKey: string]: ComputeCb | { fn: ComputeCb, depKeys?: DepKeys, compare?: boolean, sort?: number, retKeyDep?: boolean, } }; export type MultiComputedFn = (ctx: ICtxBase) => MultiComputed; interface ComputedCbOptions { depKeys?: DepKeys, compare?: boolean, sort?: number, retKeyDep?: boolean } /** * ctx.comptued overloading * define how to compute refComputed */ interface RefCtxComputed { >(multiComputed: T): ComputedValType; >(multiFn: T): ComputedValTypeForFn; > (retKey: Key, fn: Fn, depKeysOrOpts?: DepKeys | ComputedCbOptions): ComputedValType<{ [key in Key]: Fn }>; > (retKey: Key, fnDesc: { fn: Fn } & ComputedCbOptions): ComputedValType<{ [key in Key]: Fn }>; } /** * 不支持 computedModule 传递参数形如 (ctx)=> cuDesc */ interface RefCtxComputedModule { , M extends keyof RootState>(moduleName: M, multiComputed: T): ComputedValType; // , M extends keyof RootState>(moduleName: M, multiFn: T): ComputedValTypeForFn; , M extends keyof RootState> (moduleName: M, retKey: Key, fn: Fn, depKeysOrOpts?: DepKeys | ComputedCbOptions): ComputedValType<{ [key in Key]: Fn }>; , M extends keyof RootState> (moduleName: M, retKey: Key, fnDesc: { fn: Fn } & ComputedCbOptions): ComputedValType<{ [key in Key]: Fn }>; } interface WatchCbOptions { depKeys?: DepKeysOfWatch; /** defalut is true */ compare?: boolean; /** defalut is false */ immediate?: boolean; sort?: number; /** retKeyDep: default is true, when key is same as state key, it will be a dep */ retKeyDep?: boolean; } type WatchCb = (newState: FullState, oldState: FullState, fnCtx: _IFnCtx) => void; type MultiWatch = { [fnKey: string]: WatchCb | { fn: WatchCb, depKeys?: DepKeys, compare?: boolean, immediate?: boolean, retKeyDep?: boolean, } }; export type MultiWatchFn = (ctx: ICtxBase) => MultiWatch; interface RefCtxWatch { /** * ```js * ctx.watch({ * key1Changed: { * fn:(n, o, f){ * const { key1 } = n; // dep collected; * if(f.isFirstCall)return; * // logic * }, * immediate: true, * } * }); * ``` */ >(multiWatch: T): void; >(multiWatchFn: T): void; >(fnKey: Key, fn: Fn, depKeysOrOpts?: DepKeysOfWatch | WatchCbOptions): void; >(fnKey: Key, fnDesc: { fn: Fn } & WatchCbOptions): void; } /** * 不支持 watchModule 传递参数形如 (ctx)=> watchDesc * ```ts * ctx.watchModule('foo', { * key1Change: ({key1})=>console.log(`key1 changed`), * key2Change: { * fn: ({key1})=>console.log(`key1 changed`), * immediate: true, * }, * }); * ``` */ interface RefCtxWatchModule { , M extends keyof RootState>(moduleName: M, multiWatch: T): void; // , M extends keyof RootState>(moduleName: M, multiWatchFn: T): void; , M extends keyof RootState> (moduleName: M, fn: Fn, depKeysOrOpts?: DepKeysOfWatch | WatchCbOptions): void; , M extends keyof RootState> (moduleName: M, fnDesc: { fn: Fn } & WatchCbOptions): void; } type ClearEffect = IAnyFnPromise | IAnyFn | void; type EffectDepKeys = string[] | null; type EffectDepPropKeys = string[] | null; interface DepKeysOptions { depKeys?: EffectDepKeys; /** compare is false by default */ compare?: boolean; /** immediate is true by default */ immediate?: boolean; } interface PropDepKeysOptions { depKeys?: EffectDepPropKeys; /** immediate is true by default */ immediate?: boolean; } // compare default is false, 表示针对object类型的值需不需要比较 // immediate default is true declare function refCtxEffect (cb: (refCtx: RefCtx, isFirstCall: boolean) => ClearEffect, depKeys?: EffectDepKeys, compare?: boolean, immediate?: boolean): void; declare function refCtxEffect (cb: (refCtx: RefCtx, isFirstCall: boolean) => ClearEffect, depKeysOpt?: DepKeysOptions): void; declare function refCtxEffectProps (cb: (refCtx: RefCtx, isFirstCall: boolean) => ClearEffect, depPropKeys?: EffectDepPropKeys, immediate?: boolean): void; declare function refCtxEffectProps (cb: (refCtx: RefCtx, isFirstCall: boolean) => ClearEffect, depPropKeysOpt?: PropDepKeysOptions): void; interface SyncCb { ( value: any, keyPath: string, syncContext: { event: React.BaseSyntheticEvent, module: string, moduleState: object, fullKeyPath: string, state: object, refCtx: object } ): IAnyObj | boolean; // if module state is not equal full state, you need pass generic type FullState ( value: Val, keyPath: string, syncContext: { event: React.BaseSyntheticEvent, module: string, moduleState: ModuleState, fullKeyPath: string, state: FullState, refCtx: RefCtx } ): any; } declare function asCb ( value: any, keyPath: string, syncContext: { event: React.BaseSyntheticEvent, module: string, moduleState: object, fullKeyPath: string, state: object, refCtx: object } ): any; // if module state is not equal full state, you need pass generic type FullState declare function asCb ( value: Val, keyPath: string, syncContext: { event: React.BaseSyntheticEvent, module: string, moduleState: ModuleState, fullKeyPath: string, state: RefState, refCtx: RefCtx } ): any; interface RefCtxSync { (string: string, value?: SyncCb | any, renderKey?: RenderKeyOrOpts, delay?: string): IAnyFn; (...args: any[]): any; // 支持dom直接绑sync时ts语法正确 } ////////////////////////////////////////// // exposed interface ////////////////////////////////////////// /** * use this interface to match ctx type that component only defined belong-module * * concent will build ctx for every instance * get ctx in class : this.ctx * get ctx in function : const ctx = useConcent('foo'); */ export interface ICtxBase { // module: '$$default'; readonly module: PropKey; readonly allModules: string[]; /** component type */ readonly type: CC_CLASS | CC_HOOK; /** component instance type */ readonly insType: CC_FRAGMENT | CC_OB | CC_CUSTOMIZE; readonly ccKey: string; readonly ccClassKey: string; readonly ccUniqueKey: string; readonly initTime: number; readonly renderCount: number; readonly watchedKeys: string[] | TStar | TAuto; readonly privStateKeys: string[]; readonly connect: { [key: string]: string[] | TStar | TAuto }; // ref can rewrite these 4 props by ccOption readonly persistStoredKeys: boolean; readonly storedKeys: string[]; readonly renderKey: string | number; readonly tag: string; readonly mapped: any; readonly stateKeys: string[]; readonly extra: any; readonly staticExtra: any; readonly state: any; readonly unProxyState: any; readonly prevState: any; readonly props: any; readonly prevProps: any; readonly moduleState: any; readonly globalState: any; readonly connectedState: any; readonly refComputed: any; readonly moduleComputed: any; readonly globalComputed: any; readonly connectedComputed: any; readonly moduleReducer: any; readonly globalReducer: any; readonly connectedReducer: any; readonly reducer: any; readonly mr: any; // alias of moduleReducer readonly mrc: any; // alias of moduleReducerCaller readonly mrg: any; // alias of moduleReducerGhost readonly gr: any; // alias of globalReducer readonly cr: any; // alias of connectedReducer readonly r: any; // alias of reducer readonly computed: RefCtxComputed; readonly computedModule: RefCtxComputedModule; readonly watch: RefCtxWatch; readonly watchModule: RefCtxWatchModule; readonly effect: typeof refCtxEffect; readonly effectProps: typeof refCtxEffectProps; readonly execute: (filters: RefFilters, handler: IAnyFnPromise) => void; readonly on: typeof refCtxOn; readonly emit: typeof refCtxEmit; readonly off: typeof refCtxOff; readonly dispatch: typeof refCtxDispatch; readonly dispatchLazy: typeof refCtxDispatch; readonly dispatchSilent: typeof refCtxDispatch; readonly lazyDispatch: typeof refCtxDispatch; readonly silentDispatch: typeof refCtxDispatch; readonly getWatchedKeys: () => string[]; readonly getConnectWatchedKeys: typeof refCtxGetConnectWatchedKeys; readonly invoke: typeof refCtxInvoke; readonly invokeLazy: typeof refCtxInvoke; readonly invokeSilent: typeof refCtxInvoke; readonly lazyInvoke: typeof refCtxInvoke; readonly silentInvoke: typeof refCtxInvoke; readonly reactSetState: ( state: ((prevState: Readonly, props: Readonly

) => (Pick | S | null)) | (Pick | S | null), callback?: () => void ) => void; readonly reactForceUpdate: (callback?: () => void) => void; readonly initState: RefCtxInitState; readonly setState: RefCtxSetState; readonly refs: { [key: string]: { current: any } }; /** * get target ref from ctx.refs */ readonly getRef: (refName: string) => { current: T } | undefined; /** * can work for both class and function */ readonly useRef: (refName: string) => ((reactRef: T) => void); readonly forceUpdate: typeof refCtxForceUpdate; readonly setGlobalState: RefCtxSetState; readonly setModuleState: RefCtxSetModuleState; readonly sync: RefCtxSync; readonly syncer: any; readonly syncerOfBool: any; /** alias of syncerOfBool */ readonly sybo: any; readonly syncBool: (string: string, value?: SyncCb | boolean, renderKey?: RenderKey, delay?: string) => IAnyFn; readonly syncInt: (string: string, value?: SyncCb | number, renderKey?: RenderKey, delay?: string) => IAnyFn; readonly syncAs: (string: string, value?: typeof asCb | any, renderKey?: RenderKey, delay?: string) => any; readonly set: (string: string, value: any, renderKey?: RenderKey, delay?: string) => void; readonly setBool: (string: string, renderKey?: RenderKey, delay?: string) => void; readonly settings: IAnyObj; } interface ICtxBaseP extends ICtxBase { props: Props; } // 第二位泛型参数默认值设为 any,是为了使用 services/concent useSetup 时类型校验通过 type RefCtxInitState = (state: PrivState | (() => PrivState)) => Extract extends never // you must make sure that there is no common keys between privState and moduleState ? { state: PrivState & ModuleState, computed: RefCtxComputed, watch: RefCtxWatch, setState: RefCtxSetState, sync: RefCtxSync, syncer: Syncer, syncerOfBool: SyncerOfBool, sybo: SyncerOfBool, ccUniqueKey: string; initTime: number; renderCount: number; globalState: GlobalState; setGlobalState: RefCtxSetState; } : never; // 该类型用于辅助用户外部某些地方直接求出 ins 类型 export type RefCtxIns = Extract extends never // you must make sure that there is no common keys between privState and moduleState ? { state: PrivState & ModuleState, computed: RefCtxComputed, watch: RefCtxWatch, setState: RefCtxSetState, sync: RefCtxSync, syncer: Syncer, syncerOfBool: SyncerOfBool, sybo: SyncerOfBool, ccUniqueKey: string; initTime: number; renderCount: number; globalState: GlobalState; setGlobalState: RefCtxSetState; } : never; type DecideFullState = T2['__no_anyobj_passed__'] extends '_nap_' ? T1 : T2; /** * ctx.setState overloading */ interface RefCtxSetState { ( state: Partial>, cb?: (newFullState: DecideFullState) => void | null, renderKey?: RenderKeyOrOpts, delay?: number, ): void; ( updater: (prevFullState: DecideFullState, props: any) => Partial>, renderKey?: RenderKeyOrOpts, delay?: number, ): void; } interface RefCtxSetModuleState { >( moduleName: M, state: Partial, cb?: (newFullState: RootState[M]) => void | null, renderKey?: RenderKeyOrOpts, delay?: number, ): void; >( moduleName: M, updater: (prevFullState: RootState[M], props: any) => Partial, renderKey?: RenderKeyOrOpts, delay?: number, ): void; } /** * the difference between IRefCtx and ICtx is that * IRefCtx doesn't need to know RootModule */ export interface IRefCtx< Props extends IAnyObj = {}, PrivState extends IAnyObj = {}, ModuleState extends IAnyObj = {}, ModuleReducer extends IAnyObj = {}, ModuleReducerCaller extends IAnyObj = {}, ModuleReducerGhost extends IAnyObj = {}, ModuleComputed extends IAnyObj = {}, Settings extends IAnyObj = {}, RefComputed extends IAnyObj = {}, Mapped extends IAnyObj = {}, // when connect other modules ConnectedState extends IAnyObj = {}, ConnectedReducer extends IAnyObj = {}, ConnectedComputed extends IAnyObj = {}, ExtraTypes extends [IAnyObj, any] | [IAnyObj] = [IAnyObj, any], > extends ICtxBase { readonly props: Props; readonly prevProps: Props; readonly state: PrivState & ModuleState; readonly unProxyState: PrivState & ModuleState; readonly extra: ExtraTypes[0]; readonly staticExtra: ExtraTypes[1] extends undefined ? any : ExtraTypes[1]; readonly prevState: PrivState & ModuleState; readonly moduleState: ModuleState; readonly moduleComputed: ModuleComputed; readonly moduleReducer: ModuleReducer; readonly mr: ModuleReducer;// alias of moduleReducer readonly mrc: ModuleReducerCaller;// alias of moduleReducerCaller readonly mrg: ModuleReducerGhost;// alias of moduleReducerGhost readonly settings: Settings; readonly mapped: Mapped; readonly refComputed: RefComputed; // when connect other modules readonly connectedState: ConnectedState; readonly connectedReducer: ConnectedReducer; readonly cr: ConnectedReducer;// alias of connectedReducer readonly connectedComputed: ConnectedComputed; readonly computed: RefCtxComputed; readonly computedModule: RefCtxComputedModule; readonly watch: RefCtxWatch; readonly watchModule: RefCtxWatchModule; readonly initState: RefCtxInitState; readonly setState: RefCtxSetState; readonly setModuleState: RefCtxSetModuleState; readonly syncer: Syncer; readonly syncerOfBool: { [key in keyof PickBool]: IAnyFn }; /** alias of syncerOfBool */ readonly sybo: { [key in keyof PickBool]: IAnyFn }; } export interface IRefCtxWithRoot< RootInfo extends IAnyObj = {}, Props extends IAnyObj = {}, PrivState extends IAnyObj = {}, ModuleState extends IAnyObj = {}, ModuleReducer extends IAnyObj = {}, ModuleReducerCaller extends IAnyObj = {}, ModuleReducerGhost extends IAnyObj = {}, ModuleComputed extends IAnyObj = {}, Settings extends IAnyObj = {}, RefComputed extends IAnyObj = {}, Mapped extends IAnyObj = {}, // when connect other modules ConnectedState extends IAnyObj = {}, ConnectedReducer extends IAnyObj = {}, ConnectedComputed extends IAnyObj = {}, ExtraType extends [IAnyObj, any] | [IAnyObj] = [IAnyObj, any], > extends IRefCtx< Props, PrivState, ModuleState, ModuleReducer, ModuleReducerCaller, ModuleReducerGhost, ModuleComputed, Settings, RefComputed, Mapped, ConnectedState, ConnectedReducer, ConnectedComputed, ExtraType > { readonly globalState: GetSubType, MODULE_GLOBAL>; readonly globalComputed: ComputedValType, MODULE_GLOBAL>>; readonly watchModule: RefCtxWatchModule>; } export interface ModuleDesc { // recommend define state as () => S, then it can been cloned anytime state: S | (() => S); reducer?: { [key: string]: IReducerFn }; computed?: { [key: string]: ComputedFn | IComputedFnDesc> }; ghosts?: readonly string[]; watch?: { [key: string]: WatchFn | WatchFnDesc> }; } interface RootModule { [key: string]: ModuleDesc; } type GetSubType = K extends keyof T ? T[K] : {}; type GetSubArrType = K extends keyof T ? T[K] : []; type GetSubRdType = ReducerType, GetSubType>; type GetSubRdCallerType = ReducerCallerType>; type GetSubRdGhostType = ReducerGhostType, GetSubRdType>; type GetSubCuType = ComputedValType>; type GetConnState = { [key in Conn]: StateType } & (IncludeModelKey extends true ? {} : { [key in MODULE_GLOBAL]: {} }); type GetConnReducer = { [key in Conn]: ReducerType, Mods[key]['reducer']> } & (IncludeModelKey extends true ? {} : { [key in MODULE_GLOBAL]: {} }); type GetConnComputed = { [key in Conn]: ComputedValType } & (IncludeModelKey extends true ? {} : { [key in MODULE_GLOBAL]: {} }); export interface IRefCtxM< RootInfo extends IAnyObj, Props extends IAnyObj, M extends ModuleDesc, Se = {}, RefCu = {}, Extra = {} > extends IRefCtxWithRoot< RootInfo, Props, {}, StateType, GetSubRdType, GetSubRdCallerType, GetSubRdGhostType, GetSubCuType, Se, RefCu, {}, {}, {}, {}, [Extra] > { } export interface IRefCtxMS< RootInfo extends IAnyObj, Props extends IAnyObj, M extends ModuleDesc, St extends IAnyObj = {}, Se = {}, RefCu = {}, Extra = {} > extends IRefCtxWithRoot< RootInfo, Props, St, StateType, GetSubRdType, GetSubRdCallerType, GetSubRdGhostType, GetSubCuType, Se, RefCu, {}, {}, {}, {}, [Extra] > { } export interface IRefCtxS< RootInfo extends IAnyObj, Props extends IAnyObj, St extends IAnyObj = {}, Se = {}, RefCu = {}, Extra = {} > extends IRefCtxWithRoot { } export interface IRefCtxMConn< RootInfo extends IAnyObj, Props extends IAnyObj, M extends ModuleDesc, Mods extends RootModule, Conn extends keyof Mods, Se = {}, RefCu = {}, Extra = {} > extends IRefCtxWithRoot< RootInfo, Props, {}, StateType, GetSubRdType, GetSubRdCallerType, GetSubRdGhostType, GetSubCuType, Se, RefCu, {}, GetConnState, GetConnReducer, GetConnComputed, [Extra] > { } export interface IRefCtxMSConn< RootInfo extends IAnyObj, Props extends IAnyObj, M extends ModuleDesc, St extends IAnyObj, Mods extends RootModule, Conn extends keyof Mods, Se = {}, RefCu = {}, Extra = {}, > extends IRefCtxWithRoot< RootInfo, Props, St, StateType, GetSubRdType, GetSubRdCallerType, GetSubRdGhostType, GetSubCuType, Se, RefCu, {}, GetConnState, GetConnReducer, GetConnComputed, [Extra] > { } export interface IRefCtxConn< RootInfo extends IAnyObj, Props extends IAnyObj, Mods extends RootModule, Conn extends keyof Mods, Se = {}, RefCu = {}, Extra = {}, > extends IRefCtxWithRoot< RootInfo, Props, {}, {}, {}, {}, Se, RefCu, {}, GetConnState, GetConnReducer, GetConnComputed, [Extra] > { } // !!! only extract boolean value type's keys type GetBoolKeys = { [K in keyof T]: T[K] extends boolean ? K : never }[keyof T]; type PickBool = Pick>; /** * ================================= * ICtx series start! because ICtx has strict type check, so start with RootState RootReducer RootComputed generic type * ================================= */ export interface ICtx < RootState extends IRootBase = IRootBase, RootReducer extends { [key in keyof RootState]?: any } = IRootBase, RootReducerCaller extends { [key in keyof RootState]?: any } = IRootBase, RootReducerGhost extends { [key in keyof RootState]?: any } = IRootBase, RootCu extends { [key in keyof RootState]?: any } = IRootBase, Props = {}, PrivState = {}, ModuleName extends keyof RootState = MODULE_DEFAULT, // ConnectedModules extends keyof IRootBase = MODULE_VOID, // !!! 配合下面的问题注释掉 ConnectedModules extends keyof RootState = MODULE_VOID, Settings extends IAnyObj = {}, RefComputed extends IAnyObj = {}, Mapped extends IAnyObj = {}, ExtraType extends [any, any] | [any] = [any, any], > extends ICtxBase { readonly props: Props; readonly prevProps: Props; readonly globalState: RootState[MODULE_GLOBAL]; readonly globalComputed: RootCu[MODULE_GLOBAL]; readonly extra: ExtraType[0]; readonly staticExtra: ExtraType[1] extends undefined ? any : ExtraType[1]; readonly computed: RefCtxComputed; readonly computedModule: RefCtxComputedModule; readonly watch: RefCtxWatch; readonly watchModule: RefCtxWatchModule; readonly initState: RefCtxInitState; readonly setState: RefCtxSetState; readonly setModuleState: RefCtxSetModuleState; readonly setGlobalState: RefCtxSetState; readonly syncer: Syncer; readonly syncerOfBool: { [key in keyof PickBool]: IAnyFn }; /** alias of syncerOfBool */ readonly sybo: { [key in keyof PickBool]: IAnyFn }; readonly state: PrivState & RootState[ModuleName]; readonly unProxyState: PrivState & RootState[ModuleName]; readonly prevState: PrivState & RootState[ModuleName]; readonly moduleState: RootState[ModuleName]; readonly reducer: RootReducer; readonly r: RootReducer; readonly globalReducer: RootReducer[MODULE_GLOBAL]; readonly gr: RootReducer[MODULE_GLOBAL]; readonly moduleReducer: ModuleName extends keyof RootReducer ? ( RootReducer[ModuleName]['setState'] extends Function ? RootReducer[ModuleName] : RootReducer[ModuleName] & { setState: typeof reducerSetState } ) : {}; // alias of moduleReducer readonly mr: ModuleName extends keyof RootReducer ? RootReducer[ModuleName] : {}; // alias of moduleReducerCaller readonly mrc: ModuleName extends keyof RootReducerCaller ? RootReducerCaller[ModuleName] : {}; readonly mrg: ModuleName extends keyof RootReducerGhost ? ( { [K in keyof ArrItemsType]: RootReducer[ModuleName] } ) : {}; readonly moduleComputed: ModuleName extends keyof RootCu ? RootCu[ModuleName] : {}; readonly settings: Settings; /** for user get computed value in ui */ readonly refComputed: RefComputed; readonly mapped: Mapped; // overwrite connectedState , connectedComputed readonly connectedState: Pick; readonly connectedReducer: Pick; readonly cr: Pick;// alias of connectedReducer readonly connectedComputed: Pick; // !!! 目前这样写有问题,例如连接是foo,bar, // 外面推导出的是 Pick | Pick // 而不是 Pick // connectedReducer: ConnectedModules extends keyof RootReducer ? Pick : {}; // connectedComputed: ConnectedModules extends keyof RootCu ? Pick : {}; } export interface ICtxCommon< Props = {}, PrivState extends IAnyObj = {}, Settings extends IAnyObj = {}, RefComputed extends IAnyObj = {}, RootState extends IRootBase = IRootBase, Extra extends [any, any] | [any] = [any, any], > extends ICtx< RootState, {}, {}, {}, {}, Props, PrivState, MODULE_DEFAULT, MODULE_VOID, Settings, RefComputed, {}, Extra > { } // this kind of ctx must belong to $$default module // it has no default type as it has not been exposed to user! export interface ICtxDefault < RootState extends IRootBase = IRootBase, RootReducer extends { [key in keyof RootState]?: any } = IRootBase, RootReducerCaller extends { [key in keyof RootState]?: any } = IRootBase, RootReducerGhost extends { [key in keyof RootState]?: any } = IRootBase, RootCu extends { [key in keyof RootState]?: any } = IRootBase, Props = {}, PrivState extends IAnyObj = {}, ModuleName extends Required = MODULE_DEFAULT, ConnectedModules extends keyof RootState = MODULE_VOID, Settings extends IAnyObj = {}, RefComputed extends IAnyObj = {}, Mapped extends IAnyObj = {}, Extra extends [any, any] | [any] = [any, any], > extends ICtx < RootState, RootReducer, RootReducerCaller, RootReducerGhost, RootCu, Props, PrivState, ModuleName, ConnectedModules, Settings, RefComputed, Mapped, Extra > { // __key_as_hint_your_ctx_is_not_default__: 'your component is belong to $$default module by default, but you give a type Ctx which not belong to $$default module', } type GetFnCtxCommit = >(partialState: PS) => void; type GetFnCtxCommitCu = >(partialComputed: PC) => void; // to constrain IFnCtx interface series shape interface _IFnCtx { // 方便 ctx.computed({....}) 定义计算描述体时,可以正确赋值fnCtx类型 retKey: string; callInfo: ICallInfo, /** * is cb been called first time */ isFirstCall: boolean; setted: string[]; changed: string[]; stateModule: string; refModule: string; oldState: FullState; committedState: IAnyObj; deltaCommittedState: IAnyObj; cuVal: Computed; refCtx: ICtxBase; setInitialVal: (initialVal: any) => void; commit: GetFnCtxCommit; commitCu: GetFnCtxCommitCu; /** * 总是优化考虑使用 dispatch 替代 dispatchImmediate,确保执行的目标函数里拿到的 moduleState 是落地后的结果 */ dispatch: typeof refCtxDispatch; dispatchImmediate: typeof refCtxDispatch; } export interface IFnCtxBase extends _IFnCtx { refCtx: ICtxBase; } // M, means need module associate generic type export interface IFnCtx extends IFnCtxBase { commit: GetFnCtxCommit;// for module computed or watch definition, FullState equivalent ModuleState, Computed equivalent ModuleComputed commitCu: GetFnCtxCommitCu; committedState: Partial; cuVal: Computed; oldState: FullState; refCtx: RefCtx; // __forCheckRefCtxAndCu__?: RefCtx['moduleComputed'] extends {} ? ( // Computed extends {} ? true : never // ) : ( // Computed extends RefCtx['moduleComputed'] ? true : never // ); } declare class ConcentComponent

extends Component { ctx: ICtxBase; constructor(props: Readonly

); constructor(props: P, context?: any); } interface IRegBase

{ module?: PropKey; props?: P; state?: IAnyFnReturnObj | IAnyObj; extra?: any, // assign to ctx.extra in every render period for useConcent , but only time for register staticExtra?: any, // assign to ctx.staticExtra only one time for useConcent and register both watchedKeys?: string[] | TStar | TAuto; storedKeys?: string[]; connect?: any; tag?: string; persistStoredKeys?: boolean; lite?: 1 | 2 | 3 | 4; layoutEffect?: boolean; // work for useConcent only isPropsProxy?: boolean; // work for register only, default false bindCtxToMethod?: boolean; // default false renderKeyClasses?: string[]; compareProps?: boolean; // default true setup?: (refCtx: EnsureEmptySettings) => IAnyObj | void; cuDesc?: MultiComputed | MultiComputedFn | null; // render?: (ctxOrMapped: any) => ReactNode; // work for useConcent, registerHookComp, registerDumb only } // 不把render写在IRegBase里,会导致registerHookComp接口里的联合类型render函数类型失效 // 所以这里单独为CcFrag单独写一个接口 interface IRegBaseFrag

extends IRegBase { render?: (ctxOrMapped: any) => ReactNode; // work for useConcent, registerHookComp, registerDumb only } interface IRegBaseSt

extends IRegBase { state: FnState; // state required } // 加readonly 修饰是为了支持声明connect时用 as const后缀 // @see https://codesandbox.io/s/concent-guide-ts-zrxd5?file=/src/pages/CtxMConn/index.tsx type ConnectSpec = (keyof RootState)[] | readonly (keyof RootState)[] | // !!! currently I do not know how to pass ${moduleName} to evaluate target type in object value // something like (keyof RootState[moduleName] )[] but it is wrong writing { [moduleName in (keyof RootState)]?: TStar | TAuto | string[] }; type TargetKeysInFn = Exclude, (number | symbol)>; type TargetKeysInObj = Exclude; // setup 里的 ctx.settings 在初次拿到时是一个空map,此处需要用Omit剔除掉透传的settings来确保类型安全 type EnsureEmptySettings = Omit & { settings: {} }; export interface RegisterOptions< P extends IAnyObj, RootState extends IRootBase, ModuleName extends keyof RootState, PrivState extends FnState, ICtx extends ICtxBase = ICtxBase > extends IRegBase { module?: ModuleName, state?: PrivState, watchedKeys?: (Extract)[] | TStar | TAuto; storedKeys?: PrivState extends IAnyFn ? (TargetKeysInFn)[] : (TargetKeysInObj)[] connect?: ConnectSpec, setup?: (refCtx: EnsureEmptySettings) => IAnyObj | void; } // only state required interface RegisterOptionsSt< P extends IAnyObj, RootState extends IRootBase, ModuleName extends keyof RootState, PrivState extends FnState, ICtx extends ICtxBase = ICtxBase > extends RegisterOptions { state: PrivState; } // only module required interface RegisterOptionsMo< P extends IAnyObj, RootState extends IRootBase, ModuleName extends keyof RootState, PrivState extends FnState, ICtx extends ICtxBase = ICtxBase > extends RegisterOptions { module: ModuleName, } // both module、state required interface RegisterOptionsMoSt< P extends IAnyObj, RootState extends IRootBase, ModuleName extends keyof RootState, PrivState extends FnState, ICtx extends ICtxBase = ICtxBase > extends RegisterOptions { module: ModuleName, state: PrivState; } type WatchFn = (newState: S, oldState: S, fnCtx: F) => void; // declare function watchFn(oldVal: any, newVal: any, fnCtx: IFnCtx): void; type WatchFnDesc = { fn: Fn, compare?: boolean,// default is runtimeVar.watchCompare immediate?: boolean,// default is runtimeVar.watchImmediate depKeys?: DepKeysOfWatch,// default is '-' retKeyDep?: boolean,// default is true } type TypeDesc = { module?: string; type: string; cb?: Function; }; declare function init(moduleState: T): Partial; declare function init(moduleState: T): Promise>; /** default is true */ export type TriggerOnce = boolean | void; export type ModuleTemplate = { state: S | (() => S); reducer?: ModuleReducerDef; ghosts?: string[] | readonly string[]; computed?: ModuleComputedDef; watch?: ModuleWatchDef; lifecycle?: ModuleLifeCycleDef; } // for legacy export type ModuleConfig = ModuleTemplate; export interface ConfOptions { /** 慎用此选项 */ allowDup: boolean; } // returned by createModule api export type RegisteredModule = { /** concent will also keep a symbol('__regModule__') for prevent user creating a fake RegisteredModule */ __regModule__: string; } & ModuleConfig; export interface StoreConfig { [moduleName: string]: ModuleConfig; } export type MidCtx = { calledBy: CalledBy, type: string, payload: any, renderKey: Array[], delay: number, ccKey: string, ccUniqueKey: string, committedState: object, sharedState: object | null, refModule: string, module: string, fnName: string, modState: (key: string, value: any) => void, }; export type SigFnData = { sig: SigFn, payload: { isSourceCall: boolean, calledBy: CalledBy, module: string, chainId: number, fn: Function, /** * 可以等同于方法名 */ type: string, } }; export type SigModuleConfiguredData = { sig: SigModuleConfigured, payload: string,//配置了新模块 }; export type SigStateChangedData = { sig: SigStateChanged, payload: { calledBy: CalledBy, type: string, payload: any, committedState: IAnyObj, sharedState: IAnyObj | null, module: string, ccUniqueKey: string, stateSnapshot: IAnyObj, renderKey: Array[], } }; export interface PluginOn { (sig: SigFn | SigFn[], callback: (data: SigFnData) => void): void; (sig: SigModuleConfigured, callback: (data: SigModuleConfiguredData) => void): void; (sig: SigStateChanged, callback: (data: SigStateChangedData) => void): void; (sig: string | string[], callback: (data: { sig: string, payload: any }) => void): void; } type PluginName = string; export interface Plugin { install: (on: PluginOn) => { name: PluginName }; } export interface RunOptions { middlewares?: ((midCtx: MidCtx, next: Function) => void)[]; plugins?: Plugin[]; // default is false isHot?: boolean; // default is false isStrict?: boolean; /** * default: false * let concent.setState and react.setState stay the same * * 2.19.5 新增,是否忽略掉提交的 state 里第一层为 undefined 的值 * true: { a: 1, b: undefined } ---> { a: 1 } * false: { a: 1, b: undefined } ---> { a: 1, b: undefined } * 2.17.5之前都是忽略的,导致问题 https://github.com/concentjs/concent/issues/68 * 为了和 react.setState 的行为一致,默认设置为不忽略 * * 考虑到在 2.17.5 版本之前,用户的程序提交状态当包含有 undefined 值时,concent 会自动忽略掉, * 但当用户升级到最新版本后,默认不忽略的策略可能会导致出现 bug( 使用时未检测 undefined ), * 为了平滑升级,用户可设置 ignoreUndefined 为 true,让 concent 保持和之前一样的状态过滤策略 */ ignoreUndefined?: boolean; /** * default is false * 是否转发 reducer 错误到 errorHandler 里, * 强烈不建议用户配置 unsafe_moveReducerErrToErrorHandler 为 true,否则reducer错误会被静默掉 * 保留这个参数是为了让老版本的concent工程能够正常工作, */ unsafe_moveReducerErrToErrorHandler?: boolean; log?: boolean; // if print error message with console.error or not, default is true logVersion?: boolean; // if print concent version or not, default is true act?: IAnyFn; // should pass act avoid warning if in test mode, see https://reactjs.org/docs/test-utils.html#act errorHandler?: (err: Error) => void; /** * this kind of error will not lead to app crash, but should let developer know it */ warningHandler?: (err: Error) => void; bindCtxToMethod?: boolean; // default is false /** * default is true * it means no matter state changed or not, if a ref call setState or mr.{method} * it will always been rendered */ alwaysRenderCaller?: boolean; computedCompare?: boolean; // default is false, trigger computed if set watchCompare?: boolean; // default is false, trigger watch if set watchImmediate?: boolean; // default is false reComputed?: boolean; // default is true extractModuleChangedState?: boolean; // default is true extractRefChangedState?: boolean; // default is false /** * default is false * when extractRefChangedState is true, objectValueCompare will effect * -------------------------------------------------------------------- * when objectValueCompare is false, concent treat object value as new value when user set it * * const { obj } = ctx.state; * obj.foo = 'new'; * ctx.setState({obj}); // trigger re-render * * // but if you set objectValueCompare true, you need write immutable style code to trigger re-render * ctx.setState({obj}); // no trigger re-render * ctx.setState({obj:{...obj}}); // trigger re-render */ objectValueCompare?: boolean; nonObjectValueCompare?: boolean; // default is true localStorage?: Record; // localStorage lib, in browser it will be window.localStorage by default, in rn, user should pass one /** * currently an async cu fun will be computed to below template in babel: * function asyncFn(_x, _x2, _x3) { * return _asyncFn.apply(this, arguments); * } * so if you want your async cu fn work well after compiled, you must specify async-cu-keys */ asyncCuKeys?: string[], /** * pass immer or limu */ immutLib?: any, } export interface ICallInfo { renderKey: Array[]; delay: number; fnName: string; type: string; calledBy: CalledBy; keys: string[]; keyPath: string; } export interface IActionCtxBase { callInfo: ICallInfo; callerModule: string; module: PropKey; committedStateMap: IAnyObj, committedState: IAnyObj, invoke: typeof refCtxInvoke; lazyInvoke: typeof refCtxInvoke; dispatch: typeof refCtxDispatch; lazyDispatch: typeof refCtxDispatch; rootState: IAnyObj; globalState: any; moduleState: IAnyObj; moduleComputed: IAnyObj; setState: (obj: any, renderKey?: RenderKey, delay?: number) => Promise; refCtx: IAnyObj; refState: RefState; } // constraint RefCtx must be an implement of ICtxBase export interface IActionCtx< RootState extends IRootBase = IRootBase, RootCu extends IRootBase = IRootBase, ModuleName extends keyof RootState = MODULE_VOID, RefCtx extends ICtxBase = ICtxBase, FullState extends IAnyObj = RootState[ModuleName] > extends IActionCtxBase { module: ModuleName; moduleState: RootState[ModuleName]; moduleComputed: ModuleName extends keyof RootCu ? RootCu[ModuleName] : {}; rootState: RootState; globalState: RootState[MODULE_GLOBAL]; setState: >(obj: T, renderKey?: RenderKey, delay?: number) => Promise; refCtx: RefCtx; } // 适用于标记属于default模块的invokeFn的第三位ac参数 export interface IActionCtxDe< RefState extends IAnyObj = IAnyObj > extends IActionCtxBase { setState: >(obj: T, renderKey?: RenderKey, delay?: number) => Promise; refState: RefState; } // 直接传入模块描述体来推导 actionCtx 类型 export interface IActionCtxMod< RootInfo extends IAnyObj, Mod extends ModuleDesc, RefCtx extends ICtxBase = ICtxBase, > extends IActionCtxBase { moduleState: StateType; moduleComputed: GetSubCuType; rootState: GetSubType; globalState: GetSubType, MODULE_GLOBAL>; setState: >>(obj: T, renderKey?: RenderKey, delay?: number) => Promise; refCtx: RefCtx; } // IModActionCtx仅为了兼容旧的类型声明,(推荐优先考虑 IActionCtxMod,这样 IActionCtx 前缀能够形成统一词语前缀) export type IModActionCtx< RootInfo extends IAnyObj, Mod extends ModuleDesc, RefCtx extends ICtxBase = ICtxBase, > = IActionCtxMod; ////////////////////////////////////////// // exposed top api ////////////////////////////////////////// /** * * @param clearAll default false * @param warningErrForClearAll */ export function clearContextIfHot(clearAll?: boolean, warningErrForClearAll?: string): void; export function run(storeConfig?: StoreConfig | null, runOptions?: RunOptions): void; // register 用于class组件注册,因只有setup在class组件的reg参数里是有意义的,而setup在类组件里使用场景不多 // 所以setup的ctx参数类型不再有泛型方法列表里传入,由用户自己标记,如果不标记则默认为ICtxBase,以便减少register函数的泛型列表长度 export function register( registerOptions: string, ccClassKey?: string, ): (ReactComp: IAnyClass) => IAnyClass; export function register< Props extends IAnyObj, RootState extends IRootBase = IRootBase, ModuleName extends keyof RootState = MODULE_DEFAULT, PrivState extends FnState | NoPrivState = NoPrivState >( registerOptions: PrivState extends NoPrivState ? (ModuleName extends MODULE_DEFAULT ? RegisterOptions : RegisterOptionsMo) : (ModuleName extends MODULE_DEFAULT ? RegisterOptionsSt> : RegisterOptionsMoSt>), ccClassKey?: string, ): (ReactComp: IAnyClass) => IAnyClass; export function connect< Props extends IAnyObj = {}, RootState extends IRootBase = IRootBase, >( connectSpec: ConnectSpec, ccClassKey?: string, ): (ReactComp: typeof Component) => ComponentClass; export type NoMap = 'NoMap'; // no mapProps passed type NoPrivState = 'NoPrivState'; type TMap = IAnyObj | NoMap; export function registerHookComp( registerOptions?: string, ccClassKey?: string, ): (renderFn: (props: RefCtx) => ReactNode) => FC; // ********* registerOptions 【包含】render时,直接返回组件 ********* /** ====== 无指定所属模块,仅自定义自己的管理状态时 ======*/ export function registerHookComp< Props extends IAnyObj, RefCtx extends ICtxDefault = ICtxDefault, T extends TMap = NoMap, PrivState extends FnState | NoPrivState = NoPrivState >( // 用IRegBaseSt来约束只有state无module传入 registerOptions: (PrivState extends NoPrivState ? IRegBase : IRegBaseSt>) & (T extends NoMap ? {} : { mapProps: (refCtx: RefCtx) => T; }) & { render: (props: T extends NoMap ? RefCtx : T) => ReactNode }, ccClassKey?: string, ): FC; export function registerHookComp< Props extends IAnyObj, RefCtx extends ICtxBase, T extends TMap, RootState extends IRootBase, ModuleName extends keyof RootState, PrivState extends FnState | NoPrivState = NoPrivState >( registerOptions: // 约束state,module是否必需传入 (PrivState extends NoPrivState ? (ModuleName extends MODULE_DEFAULT ? RegisterOptions : RegisterOptionsMo) : (ModuleName extends MODULE_DEFAULT ? RegisterOptionsSt, RefCtx> : RegisterOptionsMoSt, RefCtx>) ) & (T extends NoMap ? {} : { mapProps: (refCtx: RefCtx) => T; }) & { render: (props: T extends NoMap ? RefCtx : T) => ReactNode }, ccClassKey?: string, ): FC; // ----------------------------------------------------------------------------------------------------------------------------------------- // ********* registerOptions 【不包含】render时,返回一个接收render函数作为参数的函数,由函数返回组件 ********* /** ====== 无指定所属模块,仅自定义自己的自己管理状态时 ======*/ export function registerHookComp< Props extends IAnyObj, RefCtx extends ICtxDefault = ICtxDefault, // RefCtx约束为ICtxDefault T extends TMap = NoMap, PrivState extends FnState | NoPrivState = NoPrivState >( // 用IRegBaseSt来约束只有state无module传入 registerOptions: (PrivState extends NoPrivState ? IRegBase : IRegBaseSt>) & (T extends NoMap ? {} : { mapProps: (refCtx: RefCtx) => T; }), ccClassKey?: string, ): (render: (props: T extends NoMap ? RefCtx : T) => ReactNode) => FC;//有mapProp时,render函数的参数类型就是mapProps返回类型 export function registerHookComp< Props extends IAnyObj, RefCtx extends ICtxBase, T extends TMap, RootState extends IRootBase, ModuleName extends keyof RootState, PrivState extends FnState | NoPrivState = NoPrivState >( registerOptions: // 约束state,module是否必需传入 (PrivState extends NoPrivState ? (ModuleName extends MODULE_DEFAULT ? RegisterOptions : RegisterOptionsMo) : (ModuleName extends MODULE_DEFAULT ? RegisterOptionsSt, RefCtx> : RegisterOptionsMoSt, RefCtx>) ) & (T extends NoMap ? {} : { mapProps: (refCtx: RefCtx) => T; }), ccClassKey?: string, ): (render: (props: T extends NoMap ? RefCtx : T) => ReactNode) => FC; // 除了返回组件是ClassComponent,registerDumb效果和registerHookComp一样 export function registerDumb( registerOptions?: string, ccClassKey?: string, ): (renderFn: (props: RefCtx) => ReactNode) => ComponentClass; // ********* registerOptions 【包含】render时,直接返回组件 ********* /** ====== 无指定所属模块,仅自定义自己的自己管理状态时 ======*/ export function registerDumb< Props extends IAnyObj, RefCtx extends ICtxDefault = ICtxDefault, // RefCtx约束为ICtxDefault T extends TMap = NoMap, PrivState extends FnState | NoPrivState = NoPrivState >( // 用IRegBaseSt来约束只有state无module传入 registerOptions: (PrivState extends NoPrivState ? IRegBase : IRegBaseSt>) & (T extends NoMap ? {} : { mapProps: (refCtx: RefCtx) => T; }) & { render: (props: T extends NoMap ? RefCtx : T) => ReactNode }, ccClassKey?: string, ): ComponentClass; export function registerDumb< Props extends IAnyObj, RefCtx extends ICtxBase, T extends TMap, RootState extends IRootBase, ModuleName extends keyof RootState, PrivState extends FnState | NoPrivState = NoPrivState >( registerOptions: // 约束state,module是否必需传入 (PrivState extends NoPrivState ? (ModuleName extends MODULE_DEFAULT ? RegisterOptions : RegisterOptionsMo) : (ModuleName extends MODULE_DEFAULT ? RegisterOptionsSt, RefCtx> : RegisterOptionsMoSt, RefCtx>) ) & (T extends NoMap ? {} : { mapProps: (refCtx: RefCtx) => T; }) & { render: (props: T extends NoMap ? RefCtx : T) => ReactNode }, ccClassKey?: string, ): ComponentClass; // ----------------------------------------------------------------------------------------------------------------------------------------- // ********* registerOptions 【不包含】render时,返回一个接收render函数作为参数的函数,由函数返回组件 ********* /** ====== 无指定所属模块,仅自定义自己的自己管理状态时 ======*/ export function registerDumb< Props extends IAnyObj, RefCtx extends ICtxDefault = ICtxDefault, // RefCtx约束为ICtxDefault T extends TMap = NoMap, PrivState extends FnState | NoPrivState = NoPrivState >( // 用IRegBaseSt来约束只有state无module传入 registerOptions: (PrivState extends NoPrivState ? IRegBase : IRegBaseSt>) & (T extends NoMap ? {} : { mapProps: (refCtx: RefCtx) => T; }), ccClassKey?: string, ): (render: (props: T extends NoMap ? RefCtx : T) => ReactNode) => ComponentClass;//有mapProp时,render函数的参数类型就是mapProps返回类型 export function registerDumb< Props extends IAnyObj, RefCtx extends ICtxBase, T extends TMap, RootState extends IRootBase, ModuleName extends keyof RootState, PrivState extends FnState | NoPrivState = NoPrivState >( registerOptions: // 约束state,module是否必需传入 (PrivState extends NoPrivState ? (ModuleName extends MODULE_DEFAULT ? RegisterOptions : RegisterOptionsMo) : (ModuleName extends MODULE_DEFAULT ? RegisterOptionsSt, RefCtx> : RegisterOptionsMoSt, RefCtx>) ) & (T extends NoMap ? {} : { mapProps: (refCtx: RefCtx) => T; }), ccClassKey?: string, ): (render: (props: T extends NoMap ? RefCtx : T) => ReactNode) => ComponentClass; export function connectDumb( connectSpec: ConnectSpec, ccClassKey: string, ): (render: (props: RefCtx) => ReactNode) => ComponentClass; // user decide RefCtx type is which one of RefCtx series, default is ICtxBase export function useConcent>( registerOptions?: string, ccClassKey?: string, ): RefCtx; export function useConcent< Props extends IAnyObj, RefCtx extends ICtxBase, T extends IAnyObj | NoMap = NoMap, PrivState extends FnState | NoPrivState = NoPrivState >( registerOptions: (PrivState extends NoPrivState ? IRegBase : IRegBaseSt>) & (T extends NoMap ? {} : { mapProps: (refCtx: RefCtx) => T }), ccClassKey?: string, ): RefCtx; export function useConcent< Props extends IAnyObj, RefCtx extends ICtxBase, T extends IAnyObj | NoMap, RootState extends IRootBase, ModuleName extends keyof RootState, PrivState extends FnState | NoPrivState = NoPrivState >( registerOptions: // 约束state,module是否必需传入 (PrivState extends NoPrivState ? (ModuleName extends MODULE_DEFAULT ? RegisterOptions : RegisterOptionsMo) : (ModuleName extends MODULE_DEFAULT ? RegisterOptionsSt, RefCtx> : RegisterOptionsMoSt, RefCtx>) // 下面写法是不对的,需要如上使用Exclude排除掉 // (ModuleName extends MODULE_DEFAULT ? RegisterOptionsSt : RegisterOptionsMoSt) ) & (T extends NoMap ? {} : { mapProps: (refCtx: RefCtx) => T }), ccClassKey?: string, ): RefCtx; /** * 配置模块到concent模块池,区别于 run 接口集中式的配置,configureModule可以在 run 之前或之后新增模块到concent模块池 * @param moduleName * @param moduleConfig */ declare function configureModule(moduleName: string, moduleConfig: ModuleConfig): void; declare function configureModule(storeConfig: StoreConfig, confOptions?: ConfOptions): void; /** 用于辅助 defineModule 方法推导出类型 */ interface ModuleConfigDef< S extends IAnyObj = IAnyObj, Rd extends ModuleReducerDef = ModuleReducerDef, Cu extends ModuleComputedDef = ModuleComputedDef, Wa extends ModuleWatchDef = ModuleWatchDef, Li extends ModuleLifeCycleDef = ModuleLifeCycleDef, Go extends string[] = string[] > { state: S | (() => S); reducer?: Rd; computed?: Cu; watch?: Wa; lifecycle?: Li; ghosts?: Go; } export type ModuleReducerDef = { [key: string]: IReducerFn }; export type ModuleComputedDef = { [key: string]: ComputedFn | IComputedFnDesc> }; export type ModuleWatchDef = { [retKey: string]: WatchFn | WatchFnDesc> }; export type ModuleLifeCycleDef = { initState?: typeof init; // legency for ModuleConfig.init initStateDone?: (dispatch: IDispatch, moduleState: S) => any; // legency for ModuleConfig.initPost // insteand of initState and initStateDone, using bellow methods is better way // because you can put the logic to reducer loaded?: (dispatch: IDispatch, moduleState: S) => void; // return triggerOnce, default is true, // that means mounted will only been called one time if match the condition mounted?: (dispatch: IDispatch, moduleState: S) => TriggerOnce; willUnmount?: (dispatch: IDispatch, moduleState: S) => TriggerOnce; }; /** * 定义模块配置,此函数仅用于辅助单文件定义model时,方便向对象体注入类型 * defineModule 返回的对象依然需要交给run函数执行后才能够被使用 * * ```js * import { defineModule } from 'concent'; * const modelDef = defineModule({ * state: { a:1, b:2 }; * reducer: { * // 此处 moduleState actionCtx 将获得类型 * xxAction(payload, moduleState, actionCtx){} * } * computed: { * // 此处 newState oldState fnCtx 将获得类型 * xxAction(newState, oldState, fnCtx){} * } * watch: { * // 此处 newState oldState fnCtx 将获得类型 * xxChanged(newState, oldState, fnCtx){} * } * lifecycle: { * willUnmount(dispatch, moduleState){} * }; // lifecycle 下的所有方法获得类型 * ghosts: []; // 将被约束为 reducer keys * }); * ``` * @param moduleConfig * @return moduleDef */ export declare function defineModule< // 此处不约束 S 为 IState,否则会导致调用 defineModule 传入真正的state泛型类型时 ts报错 Type 'YourRealState' does not satisfy the constraint 'IState' S extends IAnyObj = any, Rd extends ModuleReducerDef = ModuleReducerDef, Cu extends ModuleComputedDef = ModuleComputedDef, Wa extends ModuleWatchDef = ModuleWatchDef, Li extends ModuleLifeCycleDef = ModuleLifeCycleDef, Go extends Array> = Array, > (moduleConfig: ModuleConfigDef): { state: S; reducer: 'reducer' extends keyof ModuleConfigDef ? Rd : {}; /** * alias of reducer,方便书写 dispatch 调用 * * @example * ```js * const m = defineModule({ * state: { a:1, b:2 }; * reducer: { * xxAction(payload, moduleState, ac){ * // 等同于 ac.dispatch(m.reducer.anotherAction); * await ac.dispatch(m.r.anotherAction); * }, * anotherAction(payload, moduleState, ac){ * ac.dispatch(m.r.); * }, * } * }); *``` */ r: 'reducer' extends keyof ModuleConfigDef ? Rd : {}; computed: 'computed' extends keyof ModuleConfigDef ? Cu : {}; watch: 'watch' extends keyof ModuleConfigDef ? Wa : {}; lifecycle: 'lifecycle' extends keyof ModuleConfigDef ? Li : {}; ghosts: 'ghosts' extends keyof ModuleConfigDef ? Go : []; }; export const configure: typeof configureModule; export function cloneModule(newModule: string, existingModule: string, overwriteModuleConfig?: ModuleConfig): void; export function setState(moduleName: keyof RootState, state: Partial, renderKey?: RenderKey, delay?: number): void; export function setGlobalState(state: Partial): void; export function getGlobalState(): RootState['$$global']; // 放弃这种写法,拆为下面两个,方便外界调用时可直接通过泛型参数数量来确定返回类型 // export function getState = undefined> // (moduleName?: M): M extends undefined ? RootState : RootState[M]; export function getState | Empty = undefined> (moduleName: M): (M extends StrKeys ? RootState[M] : RootState); /** * 适用于不需要感知 RootState 类型,直接返回用户的定义模块状态的场景 * @param moduleName */ export function getState(moduleName: string): State; export function getState(): RootState; export function getComputed>(moduleName: M): RootCu[M]; /** * 适用于不需要感知 RootCu 类型,直接返回用户的定义模块计算结果的场景 * @param moduleName */ export function getComputed(moduleName: string): Cu; /** * 不传递模块名,直接返回整个 RootCu */ export function getComputed(): RootCu; /** * for printing cu object in console as plain json object */ export function debugComputed(moduleName?: string): T; export function getGlobalComputed(): T; export function set(keyPath: string, value: any, renderKey?: RenderKey, delay?: number): void; // only work for top api cc.dispatch interface IDispatchExtra { ccClassKey?: string; ccKey?: string; throwError?: boolean; refModule?: string; } type GetDispatchRetType = T extends IAnyFn ? GetPromiseT : any; type GetDispatchPayloadType = T extends IAnyFn ? Parameters[0] : any; declare function ccDispatch>( type: T, payload?: P, renderKey?: RenderKey | IDispatchOptions, delay?: number, extra?: IDispatchExtra ): Promise>; export type IDispatch = typeof ccDispatch; export declare const dispatch: IDispatch; export declare const emit: typeof refCtxEmit; export declare const off: typeof refCtxOff; export function execute(ccClassKey: string, ...args: any): void; export function executeAll(...args: any): void; export function appendState(moduleName: string, state: IAnyObj): void; type DefOptions = { depKeys?: DepKeys, compare?: boolean, lazy?: boolean, sort?: number, retKeyDep?: boolean }; export function defComputedVal(ret: CuRet): IComputedFnDesc>; export function defComputed (fn: (newState: V, oldState: V, fnCtx: F) => CuRet, defOptions?: DepKeys | DefOptions): IComputedFnDesc>; export function defComputed (fn: (newState: IAnyObj, oldState: IAnyObj, fnCtx: IFnCtxBase) => CuRet, defOptions?: DepKeys | DefOptions): IComputedFnDesc>; type DefLazyOptions = { depKeys?: DepKeys, compare?: boolean, sort?: number, retKeyDep?: boolean }; export function defLazyComputed (fn: (newState: V, oldState: V, fnCtx: F) => CuRet, defOptions?: DepKeys | DefLazyOptions): IComputedFnDesc>; export function defLazyComputed (fn: (newState: IAnyObj, oldState: IAnyObj, fnCtx: IFnCtxBase) => CuRet, defOptions?: DepKeys | DefLazyOptions): IComputedFnDesc>; /** * 给单个fn 函数排序,推荐使用 setComputedSorts 排序,更方便更直观 * @param fn * @param sort */ export function setFnSort(fn: any, sort: number): void; /** * 给 computed 排序,默认保证 sortFnKeys 在尾部执行 (options.ensureAtLast=true) */ export function setComputedSorts(computed: any, sortFnKeys: string[], options?: { ensureAtLast?: boolean }): void; export function defWatch (fn: (newState: V, oldState: V, fnCtx: F) => void | boolean, defOptions?: DepKeysOfWatch | WatchCbOptions): WatchFnDesc; export declare const cst: CcCst; export class CcFragment

extends Component<{ register: IRegBaseFrag, ccKey?: string, ccClassKey?: string, ccOption?: { storedKeys?: string[], renderKey?: string | number, persistStoredKeys?: boolean, tag?: string } }, any> { } /** * [state, computed, reducers] * reducers:{ mr: IAnyFnInObj, cr: IAnyFnInObj, r: IAnyFnInObj } */ type ObRenderFn = (obTuple: [IAnyObj, IAnyObj, { mr: IAnyFnInObj, cr: IAnyFnInObj, r: IAnyFnInObj }]) => React.ReactNode; export function Ob(props: { classKey?: string, module?: string, connect?: string | string[], render: ObRenderFn, children?: ObRenderFn }): React.FC; /** * user specify detail type when use * * import {reducer} from 'concent'; * import { RootReducer } from 'types'; * * const typedReducer = reducer as RootReducer; */ export declare const reducer: IAnyFnInObj; export interface RefFilters { /** * find refs that mountStatus is belong (NOT_MOUNT, MOUNTED) or (MOUNTED) * default is false, means only find out MOUNTED refs */ includeNotMount?: boolean; tag?: string; ccClassKey?: string; moduleName?: string; } type ccClassKey = string; export function getRefs(filters?: RefFilters | ccClassKey): { ctx: Ctx }[]; export function getRef(filters?: RefFilters | ccClassKey): ({ ctx: Ctx } | undefined); /** * * @param newModuleName * @param existingModuleName * @param overwriteModuleConfig overwriteModuleConfig will been merged to existingModuleConfig */ export function cloneModule(newModuleName: string, existingModuleName: string, overwriteModuleConfig?: ModuleConfig): void; export type Empty = void | null | undefined; export type MouseEv = React.MouseEvent; export type VoidPayload = Empty | MouseEv; interface FnPayload { /** * 【重载1】如果 fn 的第一位参数不是 VoidPayload,则会进入 unknown 逻辑导致类型推导出错 * 以便让用户必须传递具体的 payload 参数,让ts进入其他重载,便有机会检查 传递的payload类型是否符合定义的payload类型 */ (fn: F): Parameters[0] extends VoidPayload ? [F] : unknown; /** * 【重载2】 */ [0]>(fn: F, payload: P): [F, P]; [0]>(fn: F, payload: P, renderKey: RenderKeyOrOpts): [F, P, RenderKeyOrOpts]; [0]>(fn: F, payload: P, renderKey: RenderKeyOrOpts, delay: number): [F, P, RenderKeyOrOpts, number]; } /** * 辅助检查 fn 类型和 payload 类型是否相匹配 */ export const fnPayload: FnPayload; ////////////////////////////////////////////////// // type helper ////////////////////////////////////////////////// export type IncludeModelKey = ModelKey extends keyof Models ? true : false; export type GetRootState }> = { [key in keyof Models]: StateType } & { [cst.MODULE_VOID]: {} } & (IncludeModelKey extends true ? {} : { [cst.MODULE_DEFAULT]: {} }) & (IncludeModelKey extends true ? {} : { [cst.MODULE_GLOBAL]: {} }); export type GetRootReducer }> = { [key in keyof Models]: 'reducer' extends keyof Models[key] ? (Models[key]['reducer'] extends IAnyObj ? ReducerType, Models[key]['reducer']> : {}) : {}; } & { [cst.MODULE_VOID]: {} } & (IncludeModelKey extends true ? {} : { [cst.MODULE_DEFAULT]: {} }) & (IncludeModelKey extends true ? {} : { [cst.MODULE_GLOBAL]: {} }); export type GetRootReducerCaller }> = { [key in keyof Models]: 'reducer' extends keyof Models[key] ? (Models[key]['reducer'] extends IAnyObj ? ReducerCallerType : {}) : {}; } & { [cst.MODULE_VOID]: {} } & (IncludeModelKey extends true ? {} : { [cst.MODULE_DEFAULT]: {} }) & (IncludeModelKey extends true ? {} : { [cst.MODULE_GLOBAL]: {} }); export type GetRootReducerGhost }, RootReducer extends { [K in keyof Models]: any }> = { [key in keyof Models]: 'ghosts' extends keyof Models[key] ? (Models[key]['ghosts'] extends string[] ? { [ghostKey in ArrItemsType]: RootReducer[key] } : {}) : {}; } & { [cst.MODULE_VOID]: {} } & (IncludeModelKey extends true ? {} : { [cst.MODULE_DEFAULT]: {} }) & (IncludeModelKey extends true ? {} : { [cst.MODULE_GLOBAL]: {} }); export type GetRootComputed }> = { [key in keyof Models]: 'computed' extends keyof Models[key] ? (Models[key]['computed'] extends IAnyObj ? ComputedValType : {}) : {}; } & { [cst.MODULE_VOID]: {} } & (IncludeModelKey extends true ? {} : { [cst.MODULE_DEFAULT]: {} }) & (IncludeModelKey extends true ? {} : { [cst.MODULE_GLOBAL]: {} }); type AnyOrEmpty = any | void | undefined | null; export type CallTargetParams = ReducerCallerParams | [reducerFn: IAnyFn] | [reducerFn: IAnyFn, payload: AnyOrEmpty] | [reducerFn: IAnyFn, payload: AnyOrEmpty, renderKeyOrOpts: RenderKeyOrOpts] | [reducerFn: IAnyFn, payload: AnyOrEmpty, renderKeyOrOpts: RenderKeyOrOpts, delay: number]; export declare function bindCcToMcc(key: string): void; export declare function bindCcToWindow(custPrefix: string): void; declare type DefaultExport = { bindCcToMcc: typeof bindCcToMcc, bindCcToWindow: typeof bindCcToWindow, ccContext: any, clearContextIfHot: typeof clearContextIfHot, run: typeof run, register: typeof register, connect: typeof connect, registerDumb: typeof registerDumb, connectDumb: typeof connectDumb, registerHookComp: typeof registerHookComp, useConcent: typeof useConcent, configure: typeof configureModule, defineModule: typeof defineModule, cloneModule: typeof cloneModule, set: typeof set, setState: typeof setState, setGlobalState: typeof setGlobalState, getState: typeof getState, getGlobalState: typeof getGlobalState, getComputed: typeof getComputed, debugComputed: typeof debugComputed, getGlobalComputed: typeof getGlobalComputed, getRefs: typeof getRefs, getRef: typeof getRef, dispatch: typeof dispatch, reducer: typeof reducer, emit: typeof refCtxEmit, off: typeof refCtxOff, execute: typeof execute, executeAll: typeof executeAll, appendState: typeof appendState, defComputed: typeof defComputed, defLazyComputed: typeof defLazyComputed, defComputedVal: typeof defComputedVal, defWatch: typeof defWatch, fnPayload: FnPayload, cst: typeof cst, CcFragment: typeof CcFragment, Ob: typeof Ob, } declare let defaultExport: DefaultExport; export default defaultExport; export as namespace cc;