@dura/types
Advanced tools
+55
-6
@@ -1,2 +0,21 @@ | ||
| import type { StoreEnhancer, Middleware, Store as ReduxStore } from "redux"; | ||
| import type { StoreEnhancer, Middleware, Store as ReduxStore } from 'redux'; | ||
| export interface Loading { | ||
| status: boolean; | ||
| error: Error; | ||
| } | ||
| export interface DebounceSettings { | ||
| /** 需要延迟的毫秒数 */ | ||
| wait: number; | ||
| /** 是否立即执行 */ | ||
| iife?: boolean; | ||
| } | ||
| export interface ThrottleSettings { | ||
| /** 需要延迟的毫秒数 */ | ||
| wait: number; | ||
| /** 是否立即执行 */ | ||
| iife?: boolean; | ||
| } | ||
| export interface LoadingSettings { | ||
| customizeId: string | number; | ||
| } | ||
| export interface ConfiguraOptions { | ||
@@ -12,7 +31,21 @@ enhancers?: StoreEnhancer[]; | ||
| export interface Effect { | ||
| (action: any): Promise<void>; | ||
| (action: Action): Promise<void>; | ||
| } | ||
| export interface Reducer<S = JsonObject> { | ||
| (state: S, action: any): void | S; | ||
| (state: S, action: Action): void | S; | ||
| } | ||
| export interface LoadingMeta { | ||
| loading: boolean | LoadingSettings; | ||
| } | ||
| export interface DebounceMeta { | ||
| debounce: number | DebounceSettings; | ||
| } | ||
| export interface ThrottleMeta { | ||
| throttle: number | ThrottleSettings; | ||
| } | ||
| export declare type Meta = LoadingMeta | DebounceMeta | ThrottleMeta; | ||
| export declare type Action<P = any> = { | ||
| payload: P; | ||
| meta?: Meta; | ||
| }; | ||
| export declare type EffectsMapOfStoreSlice = JsonObject<Effect>; | ||
@@ -28,2 +61,4 @@ export declare type ReducersMapOfStoreSlice<S> = JsonObject<Reducer<S>>; | ||
| effects?: E; | ||
| watchs?: any; | ||
| computed?: any; | ||
| } | ||
@@ -38,10 +73,24 @@ export declare type ExtractStateByStoreUnion<T> = T extends StoreSlice<infer N, infer S, infer R, infer E> ? { | ||
| [K in N]: { | ||
| [RK in keyof R]: R[RK] extends (state: infer FS, action?: infer A) => any ? (action?: A) => void | FS : never; | ||
| [RK in keyof R]: R[RK] extends (state: infer FS, action: Action<infer A>) => any ? (payload?: A) => void : never; | ||
| }; | ||
| } : never; | ||
| export interface WrapTypesEffect<T> { | ||
| (payload?: T, meta?: LoadingMeta): void; | ||
| (payload?: T, meta?: DebounceMeta): void; | ||
| (payload?: T, meta?: ThrottleMeta): void; | ||
| } | ||
| export declare type ExtractActionByEffect<T> = T extends StoreSlice<infer N, infer S, infer R, infer E> ? { | ||
| [K in N]: { | ||
| [EK in keyof E]: E[EK] extends (action?: infer A) => any ? (action?: A) => void : never; | ||
| [EK in keyof E]: E[EK] extends (action?: Action<infer A>) => any ? WrapTypesEffect<A> : never; | ||
| }; | ||
| } : never; | ||
| export declare type ExtractLoadingTypes<T> = T extends StoreSlice<infer N, infer S, infer R, infer E> ? { | ||
| [K in N]: { | ||
| [EK in keyof E]: E[EK] extends (action?: Action<infer A>) => any ? { | ||
| status: boolean; | ||
| error: Error; | ||
| customize: JsonObject<Loading>; | ||
| } : never; | ||
| }; | ||
| } : never; | ||
| export declare type UnionToIntersection<T> = (T extends any ? (param: T) => any : never) extends (param: infer P) => any ? P : never; | ||
@@ -52,3 +101,3 @@ export interface UseStoreSliceFn<GS, GA> { | ||
| export interface UnUseStoreSliceFn<GS, GA> { | ||
| <N extends string, S extends JsonObject, R extends ReducersMapOfStoreSlice<S>, E extends EffectsMapOfStoreSlice, STORES extends StoreSlice<N, S, R, E>[]>(...stores: STORES): CreateStoreReturn<Omit<GS, STORES[number]["namespace"]>, Omit<GA, STORES[number]["namespace"]>>; | ||
| <N extends string, S extends JsonObject, R extends ReducersMapOfStoreSlice<S>, E extends EffectsMapOfStoreSlice, STORES extends StoreSlice<N, S, R, E>[]>(...stores: STORES): CreateStoreReturn<Omit<GS, STORES[number]['namespace']>, Omit<GA, STORES[number]['namespace']>>; | ||
| } | ||
@@ -55,0 +104,0 @@ export interface RefreshStoreFn<S, A> { |
+0
-1
| //# sourceMappingURL=index.js.map |
+2
-2
| { | ||
| "name": "@dura/types", | ||
| "version": "4.0.0-alpha.11", | ||
| "version": "4.0.0-alpha.12", | ||
| "description": "", | ||
@@ -17,3 +17,3 @@ "main": "./lib/index.js", | ||
| }, | ||
| "gitHead": "01810f0b17df01ef3b90a060513af86503b1cfbf" | ||
| "gitHead": "4fa93399faf2836bff41afed994922b0988208ea" | ||
| } |
+74
-9
@@ -1,3 +0,26 @@ | ||
| import type { StoreEnhancer, Middleware, Store as ReduxStore } from "redux"; | ||
| import type { StoreEnhancer, Middleware, Store as ReduxStore } from 'redux'; | ||
| export interface Loading { | ||
| status: boolean; | ||
| error: Error; | ||
| } | ||
| export interface DebounceSettings { | ||
| /** 需要延迟的毫秒数 */ | ||
| wait: number; | ||
| /** 是否立即执行 */ | ||
| iife?: boolean; | ||
| } | ||
| export interface ThrottleSettings { | ||
| /** 需要延迟的毫秒数 */ | ||
| wait: number; | ||
| /** 是否立即执行 */ | ||
| iife?: boolean; | ||
| } | ||
| export interface LoadingSettings { | ||
| customizeId: string | number; | ||
| } | ||
| export interface ConfiguraOptions { | ||
@@ -15,9 +38,28 @@ enhancers?: StoreEnhancer[]; | ||
| export interface Effect { | ||
| (action: any): Promise<void>; | ||
| (action: Action): Promise<void>; | ||
| } | ||
| export interface Reducer<S = JsonObject> { | ||
| (state: S, action: any): void | S; | ||
| (state: S, action: Action): void | S; | ||
| } | ||
| export interface LoadingMeta { | ||
| loading: boolean | LoadingSettings; | ||
| } | ||
| export interface DebounceMeta { | ||
| debounce: number | DebounceSettings; | ||
| } | ||
| export interface ThrottleMeta { | ||
| throttle: number | ThrottleSettings; | ||
| } | ||
| export type Meta = LoadingMeta | DebounceMeta | ThrottleMeta; | ||
| export type Action<P = any> = { | ||
| payload: P; | ||
| meta?: Meta; | ||
| }; | ||
| export type EffectsMapOfStoreSlice = JsonObject<Effect>; | ||
@@ -48,2 +90,4 @@ | ||
| effects?: E; | ||
| watchs?: any; | ||
| computed?: any; | ||
| } | ||
@@ -77,5 +121,5 @@ | ||
| state: infer FS, | ||
| action?: infer A | ||
| action: Action<infer A>, | ||
| ) => any | ||
| ? (action?: A) => void | FS | ||
| ? (payload?: A) => void | ||
| : never; | ||
@@ -86,2 +130,8 @@ }; | ||
| export interface WrapTypesEffect<T> { | ||
| (payload?: T, meta?: LoadingMeta): void; | ||
| (payload?: T, meta?: DebounceMeta): void; | ||
| (payload?: T, meta?: ThrottleMeta): void; | ||
| } | ||
| export type ExtractActionByEffect<T> = T extends StoreSlice< | ||
@@ -95,4 +145,4 @@ infer N, | ||
| [K in N]: { | ||
| [EK in keyof E]: E[EK] extends (action?: infer A) => any | ||
| ? (action?: A) => void | ||
| [EK in keyof E]: E[EK] extends (action?: Action<infer A>) => any | ||
| ? WrapTypesEffect<A> | ||
| : never; | ||
@@ -103,2 +153,17 @@ }; | ||
| export type ExtractLoadingTypes<T> = T extends StoreSlice< | ||
| infer N, | ||
| infer S, | ||
| infer R, | ||
| infer E | ||
| > | ||
| ? { | ||
| [K in N]: { | ||
| [EK in keyof E]: E[EK] extends (action?: Action<infer A>) => any | ||
| ? { status: boolean; error: Error; customize: JsonObject<Loading> } | ||
| : never; | ||
| }; | ||
| } | ||
| : never; | ||
| export type UnionToIntersection<T> = ( | ||
@@ -134,4 +199,4 @@ T extends any ? (param: T) => any : never | ||
| ): CreateStoreReturn< | ||
| Omit<GS, STORES[number]["namespace"]>, | ||
| Omit<GA, STORES[number]["namespace"]> | ||
| Omit<GS, STORES[number]['namespace']>, | ||
| Omit<GA, STORES[number]['namespace']> | ||
| >; | ||
@@ -138,0 +203,0 @@ } |
11204
31.32%310
49.04%