state-decorator 7.0.0-beta.9-dev → 7.0.0-rc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -24
- package/development.d.ts +10 -0
- package/development.js +2 -0
- package/development.js.map +1 -0
- package/graph.d.ts +8 -0
- package/helpers.js +1 -174
- package/helpers.js.map +1 -1
- package/impl.d.ts +20 -32
- package/impl.js +1 -996
- package/impl.js.map +1 -1
- package/index.d.ts +10 -11
- package/index.js +1 -1044
- package/index.js.map +1 -1
- package/middlewares.d.ts +0 -23
- package/middlewares.js +1 -526
- package/middlewares.js.map +1 -1
- package/package.json +2 -2
- package/shallow.d.ts +0 -14
- package/test.d.ts +7 -21
- package/test.js +1 -358
- package/test.js.map +1 -1
- package/types.d.ts +73 -72
- package/v5.d.ts +5 -18
- package/v5.js +1 -322
- package/v5.js.map +1 -1
- package/v5_test.d.ts +4 -17
- package/v5_test.js +1 -416
- package/v5_test.js.map +1 -1
- package/v5_types.d.ts +15 -29
- package/v6.d.ts +7 -3
- package/v6.js +1 -120
- package/v6.js.map +1 -1
- package/es/helpers.d.ts +0 -66
- package/es/helpers.js +0 -163
- package/es/helpers.js.map +0 -1
- package/es/impl.d.ts +0 -209
- package/es/impl.js +0 -964
- package/es/impl.js.map +0 -1
- package/es/index.d.ts +0 -164
- package/es/index.js +0 -1014
- package/es/index.js.map +0 -1
- package/es/middlewares.d.ts +0 -26
- package/es/middlewares.js +0 -520
- package/es/middlewares.js.map +0 -1
- package/es/shallow.d.ts +0 -15
- package/es/test.d.ts +0 -136
- package/es/test.js +0 -350
- package/es/test.js.map +0 -1
- package/es/types.d.ts +0 -381
- package/es/v5.d.ts +0 -58
- package/es/v5.js +0 -302
- package/es/v5.js.map +0 -1
- package/es/v5_test.d.ts +0 -70
- package/es/v5_test.js +0 -393
- package/es/v5_test.js.map +0 -1
- package/es/v5_types.d.ts +0 -227
- package/es/v6.d.ts +0 -17
- package/es/v6.js +0 -97
- package/es/v6.js.map +0 -1
package/impl.d.ts
CHANGED
|
@@ -1,22 +1,8 @@
|
|
|
1
|
-
/*! *****************************************************************************
|
|
2
|
-
Copyright (c) GlobalSport SAS.
|
|
3
|
-
|
|
4
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
-
purpose with or without fee is hereby granted.
|
|
6
|
-
|
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
-
***************************************************************************** */
|
|
15
1
|
import { AsyncAction, SimpleSyncAction, SyncAction, StoreAction, AsyncActionPromise, AsyncActionPromiseGet, PromiseProvider, DecoratedActions, InternalLoadingMap, StoreOptions, InvocationContextActions, OnMountInvocationContext, OnPropsChangeEffectsContext, ContextState, Middleware, MiddlewareFactory, ContextWithDerived, PromiseIdErrorMap, ErrorMap, ErrorParallelMap, OnUnMountInvocationContext, AbortedActions, ClearErrorFunc } from './types';
|
|
16
|
-
export
|
|
2
|
+
export type SetStateFunc<S, A> = (newState: S, newLoadingMap: InternalLoadingMap<A>, actionName: keyof A | 'onPropsChange', actionType: 'preEffects' | 'effects' | 'errorEffects' | null, // FIXME
|
|
17
3
|
isAsync: boolean, actionCtx: any, propsChanged: boolean, isInit?: boolean) => void;
|
|
18
4
|
/** @internal */
|
|
19
|
-
export
|
|
5
|
+
export type PromiseMap<A> = {
|
|
20
6
|
[name in keyof A]?: {
|
|
21
7
|
[promiseId: string]: {
|
|
22
8
|
promise: Promise<any>;
|
|
@@ -26,18 +12,18 @@ export declare type PromiseMap<A> = {
|
|
|
26
12
|
};
|
|
27
13
|
};
|
|
28
14
|
/** @internal */
|
|
29
|
-
export
|
|
15
|
+
export type FutureActions = {
|
|
30
16
|
args: any[];
|
|
31
17
|
resolve: (...args: any[]) => void;
|
|
32
18
|
reject: (...args: any[]) => void;
|
|
33
19
|
timestamp?: number;
|
|
34
20
|
};
|
|
35
21
|
/** @internal */
|
|
36
|
-
export
|
|
22
|
+
export type ConflictActionsMap<A> = {
|
|
37
23
|
[name in keyof A]?: FutureActions[];
|
|
38
24
|
};
|
|
39
25
|
/** @internal */
|
|
40
|
-
export
|
|
26
|
+
export type AsyncActionExecContext<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P> = {
|
|
41
27
|
actionName: keyof A;
|
|
42
28
|
action: AsyncActionPromise<S, F, A, P, DS>;
|
|
43
29
|
stateRef: Ref<S>;
|
|
@@ -54,19 +40,19 @@ export declare type AsyncActionExecContext<S, DS, F extends (...args: any[]) =>
|
|
|
54
40
|
clearError: ClearErrorFunc<A>;
|
|
55
41
|
};
|
|
56
42
|
/** @internal */
|
|
57
|
-
export
|
|
43
|
+
export type TimeoutMap<A> = {
|
|
58
44
|
[name in keyof A]?: any;
|
|
59
45
|
};
|
|
60
|
-
export
|
|
61
|
-
export
|
|
62
|
-
export
|
|
63
|
-
export
|
|
64
|
-
export
|
|
65
|
-
|
|
46
|
+
export type NotifyFunc = (msg: string) => void;
|
|
47
|
+
export type CloneFunction = <C>(obj: C) => C;
|
|
48
|
+
export type ComparatorFunction = <C>(obj1: C, Obj2: C) => boolean;
|
|
49
|
+
export type RetryOnErrorFunction = (error: any) => boolean;
|
|
50
|
+
export type AsyncErrorHandler = (error: any, isHandled: boolean, state: any, props: any, actionName: string, args: any[]) => void;
|
|
51
|
+
type DerivedStateMap<DS> = {
|
|
66
52
|
[name in keyof DS]?: any[];
|
|
67
53
|
};
|
|
68
54
|
/** @internal */
|
|
69
|
-
export
|
|
55
|
+
export type DerivedState<DS> = {
|
|
70
56
|
state: DS;
|
|
71
57
|
deps: DerivedStateMap<DS>;
|
|
72
58
|
};
|
|
@@ -84,7 +70,7 @@ export declare class EffectError extends Error {
|
|
|
84
70
|
/**
|
|
85
71
|
* Global configuration, shared with all stores.
|
|
86
72
|
*/
|
|
87
|
-
export
|
|
73
|
+
export type GlobalConfig = {
|
|
88
74
|
/**
|
|
89
75
|
* Clone function.
|
|
90
76
|
* Used to clone state and props when managing optimistic reducer and conflicting actions.
|
|
@@ -169,7 +155,7 @@ export declare class ParallelActionError extends Error {
|
|
|
169
155
|
export declare function buildErrorMap<A>(map: ErrorParallelMap<A>): ErrorMap<A>;
|
|
170
156
|
/** @internal */
|
|
171
157
|
export declare function retryPromiseDecorator<S, DS, F extends (...args: any[]) => Promise<any>, A, P>(promiseProvider: PromiseProvider<S, DS, F, A, P>, maxCalls?: number, delay?: number, isRetryError?: (e: Error) => boolean): PromiseProvider<S, DS, F, A, P>;
|
|
172
|
-
export
|
|
158
|
+
export type Ref<P> = {
|
|
173
159
|
current: P;
|
|
174
160
|
};
|
|
175
161
|
/** @internal */
|
|
@@ -181,13 +167,13 @@ export declare function buildOnMountInvocationContext<S, DS, A, P>(stateRef: Ref
|
|
|
181
167
|
/** @internal */
|
|
182
168
|
export declare function buildOnUnMountInvocationContext<S, DS, A, P>(stateRef: Ref<S>, derivedStateRef: Ref<DerivedState<DS>>, propsRef: Ref<P>, abortedActions: AbortedActions<A>): OnUnMountInvocationContext<S, A, P>;
|
|
183
169
|
/** @internal */
|
|
184
|
-
export declare function buildOnPropChangeEffects<S, DS, P>(stateRef: Ref<S>, derivedStateRef: Ref<DerivedState<DS>>, propsRef: Ref<P>, indices: number[], index: number, isInit: boolean, getInitialState:
|
|
170
|
+
export declare function buildOnPropChangeEffects<S, DS, P>(stateRef: Ref<S>, derivedStateRef: Ref<DerivedState<DS>>, propsRef: Ref<P>, indices: number[], index: number, isInit: boolean, getInitialState: (p: P) => S): OnPropsChangeEffectsContext<S, DS, P>;
|
|
185
171
|
/** @internal */
|
|
186
172
|
export declare function addStateToContext<T, S>(ctx: T, stateRef: Ref<S>): T & ContextState<S>;
|
|
187
173
|
/** @internal */
|
|
188
174
|
export declare function addContextActions<T, A>(ctx: T, actionsRef: Ref<A>): T & InvocationContextActions<A>;
|
|
189
175
|
/** @internal */
|
|
190
|
-
export declare function decorateSimpleSyncAction<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P>(actionName: keyof A, action: SimpleSyncAction<S, F, P, DS>, stateRef: Ref<S>, derivedStateRef: Ref<DerivedState<DS>>, propsRef: Ref<P>, initializedRef: Ref<boolean>, setState: SetStateFunc<S, A>): (...args: Parameters<F>) => void;
|
|
176
|
+
export declare function decorateSimpleSyncAction<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P>(actionName: keyof A, action: SimpleSyncAction<S, F, P, DS>, stateRef: Ref<S>, derivedStateRef: Ref<DerivedState<DS>>, propsRef: Ref<P>, initializedRef: Ref<boolean>, options: StoreOptions<S, A, P, DS>, setState: SetStateFunc<S, A>): (...args: Parameters<F>) => void;
|
|
191
177
|
/** @internal */
|
|
192
178
|
export declare function decorateSyncAction<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P>(actionName: keyof A, action: SyncAction<S, F, A, P, DS>, stateRef: Ref<S>, derivedStateRef: Ref<DerivedState<DS>>, propsRef: Ref<P>, actionsRef: Ref<A>, initializedRef: Ref<boolean>, timeoutMap: Ref<TimeoutMap<A>>, options: StoreOptions<S, A, P, any>, setState: SetStateFunc<S, A>, clearError: ClearErrorFunc<A>): (...args: Parameters<F>) => void;
|
|
193
179
|
/** @internal */
|
|
@@ -200,7 +186,9 @@ export declare function areSameArgs(args1: any[], args2: any[]): boolean;
|
|
|
200
186
|
/** @internal */
|
|
201
187
|
export declare function computeDerivedValues<S, A, P, DS>(s: Ref<S>, p: Ref<P>, derivedStateRef: Ref<DerivedState<DS>>, options: StoreOptions<S, A, P, DS>): boolean;
|
|
202
188
|
/** @internal */
|
|
203
|
-
export declare function
|
|
189
|
+
export declare function fixDerivedDeps<S, A, P, DS>(options: StoreOptions<S, A, P, DS>): void;
|
|
190
|
+
/** @internal */
|
|
191
|
+
export declare function onPropChange<S, P, A, DS>(stateRef: Ref<S>, derivedStateRef: Ref<DerivedState<DS>>, propsRef: Ref<P>, oldProps: P, actionsRef: Ref<A>, options: StoreOptions<S, A, P, DS>, getInitialState: (p: P) => S, setState: SetStateFunc<S, A>, isInit: boolean, isDeferred: boolean): void;
|
|
204
192
|
/** @internal */
|
|
205
193
|
export declare function runMiddlewares<S, A extends DecoratedActions, P>(middlewares: Middleware<S, A, P>[], oldState: S, newState: S, loading: boolean, actionName: keyof A, actionType: 'preEffects' | 'effects' | 'errorEffects' | null, isAsync: boolean, actionCtx: any): {
|
|
206
194
|
newState: S;
|