import { FrameworkReadableState, FrameworkState, GeneralFn, GeneralState } from '@alova/shared'; import type { AlovaGenerics, EffectRequestParams, ReferingObject, StatesExport, StatesHook } from 'alova'; import { ExportedComputed, ExportedState } from './general'; type ActualStateTranslator> = StateProxy extends FrameworkState ? ExportedState : ExportedComputed; type CompletedExposingProvider> = { [K in keyof O]: O[K] extends FrameworkReadableState ? ActualStateTranslator : K extends `on${infer eventUnused}` ? (...args: Parameters) => CompletedExposingProvider : O[K]; }; /** * create simple and unified, framework-independent states creators and handlers. * @param statesHook states hook from `promiseStatesHook` function of alova * @param referingObject refering object exported from `promiseStatesHook` function * @returns simple and unified states creators and handlers */ // eslint-disable-next-line export declare function statesHookHelper( statesHook: StatesHook>, referingObject?: ReferingObject ): { create: (initialValue: Data, key: Key) => FrameworkState; computed: ( getter: () => Data, depList: (GeneralState | FrameworkReadableState)[], key: Key ) => FrameworkReadableState; effectRequest: (effectRequestParams: EffectRequestParams) => void; ref: (initialValue: Data) => { current: Data; }; memorize: (fn: Callback) => Callback; watch: (source: (GeneralState | FrameworkReadableState)[], callback: () => void) => void; onMounted: (callback: () => void) => void; onUnmounted: (callback: () => void) => void; /** * refering object that sharing some value with this object. */ __referingObj: ReferingObject; /** * expose provider for specified use hook. * @param object object that contains state proxy, framework state, operating function and event binder. * @returns provider component. */ exposeProvider: >( object: O ) => CompletedExposingProvider< AG, O & { __referingObj: ReferingObject; update: (newStates: { [K in keyof O]?: any }) => void; __proxyState: (key: K) => any; } >; /** * transform state proxies to object. * @param states proxy array of framework states * @param filterKey filter key of state proxy * @returns an object that contains the states of target form */ objectify: [], Key extends 's' | 'v' | 'e' | undefined = undefined>( states: S, filterKey?: Key ) => { [K in S[number]['k']]: Key extends undefined ? Extract< S[number], { k: K; } > : Extract< S[number], { k: K; } >[NonNullable]; }; transformState2Proxy: (state: GeneralState, key: Key) => FrameworkState; };