import {ComputedRef, DeepReadonly, EffectScope, Reactive, Ref, UnwrapRef} from '@vue/reactivity' import {Domain, Store, Event, Effect, Scope} from 'effector' type GateConfig = { name?: string defaultState?: T domain?: Domain sid?: string } type Gate = { open: Event close: Event status: Store state: Store set: Event } type ExtractStore>> = { [Key in keyof T]: T[Key] extends Store ? Reactive : never } export interface UseVModel { (vm: Store): Ref >>(vm: T, scope?: EffectScope): ExtractStore } export function useStoreMap( config: { store: Store keys?: () => Keys fn: (state: State, keys: Keys) => Result updateFilter?: (update: Result, current: Result) => boolean defaultValue?: Result }, scope?: Scope, ): ComputedRef export function useVModel(vm: Store, scope?: EffectScope): Ref> export function useVModel>>( vm: T, scope?: EffectScope ): ExtractStore export function useStore(store: Store): DeepReadonly> export function createGate(config?: GateConfig): Gate export function useGate( GateComponent: Gate, cb?: () => Props, ): void export function useUnit( store: Store, opts?: {forceScope?: boolean}, ): DeepReadonly> export function useUnit( event: Event, opts?: {forceScope?: boolean}, ): () => void export function useUnit( event: Event, opts?: {forceScope?: boolean}, ): (payload: T) => T export function useUnit( fx: Effect, opts?: {forceScope?: boolean}, ): () => Promise export function useUnit( fx: Effect, opts?: {forceScope?: boolean}, ): (payload: T) => Promise export function useUnit< List extends (Event | Effect | Store)[], >( list: [...List], opts?: {forceScope?: boolean}, ): { [Key in keyof List]: List[Key] extends Event ? Equal extends true ? () => void : (payload: T) => T : List[Key] extends Effect ? Equal extends true ? () => Promise : (payload: P) => Promise : List[Key] extends Store ? DeepReadonly> : never } export function useUnit< Shape extends Record | Effect | Store>, >( shape: Shape | {'@@unitShape': () => Shape}, opts?: {forceScope?: boolean}, ): { [Key in keyof Shape]: Shape[Key] extends Event ? Equal extends true ? () => void : (payload: T) => T : Shape[Key] extends Effect ? Equal extends true ? () => Promise : (payload: P) => Promise : Shape[Key] extends Store ? DeepReadonly> : never } type Equal = (() => T extends X ? 1 : 2) extends () => T extends Y ? 1 : 2 ? true : false