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.
Files changed (59) hide show
  1. package/README.md +55 -24
  2. package/development.d.ts +10 -0
  3. package/development.js +2 -0
  4. package/development.js.map +1 -0
  5. package/graph.d.ts +8 -0
  6. package/helpers.js +1 -174
  7. package/helpers.js.map +1 -1
  8. package/impl.d.ts +20 -32
  9. package/impl.js +1 -996
  10. package/impl.js.map +1 -1
  11. package/index.d.ts +10 -11
  12. package/index.js +1 -1044
  13. package/index.js.map +1 -1
  14. package/middlewares.d.ts +0 -23
  15. package/middlewares.js +1 -526
  16. package/middlewares.js.map +1 -1
  17. package/package.json +2 -2
  18. package/shallow.d.ts +0 -14
  19. package/test.d.ts +7 -21
  20. package/test.js +1 -358
  21. package/test.js.map +1 -1
  22. package/types.d.ts +73 -72
  23. package/v5.d.ts +5 -18
  24. package/v5.js +1 -322
  25. package/v5.js.map +1 -1
  26. package/v5_test.d.ts +4 -17
  27. package/v5_test.js +1 -416
  28. package/v5_test.js.map +1 -1
  29. package/v5_types.d.ts +15 -29
  30. package/v6.d.ts +7 -3
  31. package/v6.js +1 -120
  32. package/v6.js.map +1 -1
  33. package/es/helpers.d.ts +0 -66
  34. package/es/helpers.js +0 -163
  35. package/es/helpers.js.map +0 -1
  36. package/es/impl.d.ts +0 -209
  37. package/es/impl.js +0 -964
  38. package/es/impl.js.map +0 -1
  39. package/es/index.d.ts +0 -164
  40. package/es/index.js +0 -1014
  41. package/es/index.js.map +0 -1
  42. package/es/middlewares.d.ts +0 -26
  43. package/es/middlewares.js +0 -520
  44. package/es/middlewares.js.map +0 -1
  45. package/es/shallow.d.ts +0 -15
  46. package/es/test.d.ts +0 -136
  47. package/es/test.js +0 -350
  48. package/es/test.js.map +0 -1
  49. package/es/types.d.ts +0 -381
  50. package/es/v5.d.ts +0 -58
  51. package/es/v5.js +0 -302
  52. package/es/v5.js.map +0 -1
  53. package/es/v5_test.d.ts +0 -70
  54. package/es/v5_test.js +0 -393
  55. package/es/v5_test.js.map +0 -1
  56. package/es/v5_types.d.ts +0 -227
  57. package/es/v6.d.ts +0 -17
  58. package/es/v6.js +0 -97
  59. 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 declare type SetStateFunc<S, A> = (newState: S, newLoadingMap: InternalLoadingMap<A>, actionName: keyof A | 'onPropsChange', actionType: 'preEffects' | 'effects' | 'errorEffects' | null, // FIXME
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 declare type PromiseMap<A> = {
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 declare type FutureActions = {
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 declare type ConflictActionsMap<A> = {
22
+ export type ConflictActionsMap<A> = {
37
23
  [name in keyof A]?: FutureActions[];
38
24
  };
39
25
  /** @internal */
40
- export declare type AsyncActionExecContext<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P> = {
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 declare type TimeoutMap<A> = {
43
+ export type TimeoutMap<A> = {
58
44
  [name in keyof A]?: any;
59
45
  };
60
- export declare type NotifyFunc = (msg: string) => void;
61
- export declare type CloneFunction = <C>(obj: C) => C;
62
- export declare type ComparatorFunction = <C>(obj1: C, Obj2: C) => boolean;
63
- export declare type RetryOnErrorFunction = (error: any) => boolean;
64
- export declare type AsyncErrorHandler = (error: any, isHandled: boolean, state: any, props: any, actionName: string, args: any[]) => void;
65
- declare type DerivedStateMap<DS> = {
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 declare type DerivedState<DS> = {
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 declare type GlobalConfig = {
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 declare type Ref<P> = {
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: S | ((p: P) => S)): OnPropsChangeEffectsContext<S, DS, P>;
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 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: S | ((p: P) => S), setState: SetStateFunc<S, A>, isInit: boolean, isDeferred: boolean): void;
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;