state-decorator 7.0.0-beta.9-dev → 7.0.0-rc1

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 (56) hide show
  1. package/README.md +42 -11
  2. package/development.d.ts +24 -0
  3. package/development.js +2 -0
  4. package/development.js.map +1 -0
  5. package/es/development.d.ts +24 -0
  6. package/es/development.js +2 -0
  7. package/es/development.js.map +1 -0
  8. package/es/graph.d.ts +8 -0
  9. package/es/helpers.js +1 -162
  10. package/es/helpers.js.map +1 -1
  11. package/es/impl.d.ts +20 -18
  12. package/es/impl.js +1 -963
  13. package/es/impl.js.map +1 -1
  14. package/es/index.d.ts +6 -9
  15. package/es/index.js +1 -1013
  16. package/es/index.js.map +1 -1
  17. package/es/middlewares.d.ts +0 -9
  18. package/es/middlewares.js +1 -519
  19. package/es/middlewares.js.map +1 -1
  20. package/es/test.d.ts +7 -7
  21. package/es/test.js +1 -349
  22. package/es/test.js.map +1 -1
  23. package/es/types.d.ts +70 -58
  24. package/es/v5.js +1 -301
  25. package/es/v5.js.map +1 -1
  26. package/es/v5_test.js +1 -392
  27. package/es/v5_test.js.map +1 -1
  28. package/es/v5_types.d.ts +15 -15
  29. package/es/v6.d.ts +5 -2
  30. package/es/v6.js +1 -96
  31. package/es/v6.js.map +1 -1
  32. package/graph.d.ts +8 -0
  33. package/helpers.js +1 -174
  34. package/helpers.js.map +1 -1
  35. package/impl.d.ts +20 -18
  36. package/impl.js +1 -996
  37. package/impl.js.map +1 -1
  38. package/index.d.ts +6 -9
  39. package/index.js +1 -1044
  40. package/index.js.map +1 -1
  41. package/middlewares.d.ts +0 -9
  42. package/middlewares.js +1 -526
  43. package/middlewares.js.map +1 -1
  44. package/package.json +1 -1
  45. package/test.d.ts +7 -7
  46. package/test.js +1 -358
  47. package/test.js.map +1 -1
  48. package/types.d.ts +70 -58
  49. package/v5.js +1 -322
  50. package/v5.js.map +1 -1
  51. package/v5_test.js +1 -416
  52. package/v5_test.js.map +1 -1
  53. package/v5_types.d.ts +15 -15
  54. package/v6.d.ts +5 -2
  55. package/v6.js +1 -120
  56. package/v6.js.map +1 -1
package/es/impl.d.ts CHANGED
@@ -13,10 +13,10 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
13
  PERFORMANCE OF THIS SOFTWARE.
14
14
  ***************************************************************************** */
15
15
  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
16
+ export type SetStateFunc<S, A> = (newState: S, newLoadingMap: InternalLoadingMap<A>, actionName: keyof A | 'onPropsChange', actionType: 'preEffects' | 'effects' | 'errorEffects' | null, // FIXME
17
17
  isAsync: boolean, actionCtx: any, propsChanged: boolean, isInit?: boolean) => void;
18
18
  /** @internal */
19
- export declare type PromiseMap<A> = {
19
+ export type PromiseMap<A> = {
20
20
  [name in keyof A]?: {
21
21
  [promiseId: string]: {
22
22
  promise: Promise<any>;
@@ -26,18 +26,18 @@ export declare type PromiseMap<A> = {
26
26
  };
27
27
  };
28
28
  /** @internal */
29
- export declare type FutureActions = {
29
+ export type FutureActions = {
30
30
  args: any[];
31
31
  resolve: (...args: any[]) => void;
32
32
  reject: (...args: any[]) => void;
33
33
  timestamp?: number;
34
34
  };
35
35
  /** @internal */
36
- export declare type ConflictActionsMap<A> = {
36
+ export type ConflictActionsMap<A> = {
37
37
  [name in keyof A]?: FutureActions[];
38
38
  };
39
39
  /** @internal */
40
- export declare type AsyncActionExecContext<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P> = {
40
+ export type AsyncActionExecContext<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P> = {
41
41
  actionName: keyof A;
42
42
  action: AsyncActionPromise<S, F, A, P, DS>;
43
43
  stateRef: Ref<S>;
@@ -54,19 +54,19 @@ export declare type AsyncActionExecContext<S, DS, F extends (...args: any[]) =>
54
54
  clearError: ClearErrorFunc<A>;
55
55
  };
56
56
  /** @internal */
57
- export declare type TimeoutMap<A> = {
57
+ export type TimeoutMap<A> = {
58
58
  [name in keyof A]?: any;
59
59
  };
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> = {
60
+ export type NotifyFunc = (msg: string) => void;
61
+ export type CloneFunction = <C>(obj: C) => C;
62
+ export type ComparatorFunction = <C>(obj1: C, Obj2: C) => boolean;
63
+ export type RetryOnErrorFunction = (error: any) => boolean;
64
+ export type AsyncErrorHandler = (error: any, isHandled: boolean, state: any, props: any, actionName: string, args: any[]) => void;
65
+ type DerivedStateMap<DS> = {
66
66
  [name in keyof DS]?: any[];
67
67
  };
68
68
  /** @internal */
69
- export declare type DerivedState<DS> = {
69
+ export type DerivedState<DS> = {
70
70
  state: DS;
71
71
  deps: DerivedStateMap<DS>;
72
72
  };
@@ -84,7 +84,7 @@ export declare class EffectError extends Error {
84
84
  /**
85
85
  * Global configuration, shared with all stores.
86
86
  */
87
- export declare type GlobalConfig = {
87
+ export type GlobalConfig = {
88
88
  /**
89
89
  * Clone function.
90
90
  * Used to clone state and props when managing optimistic reducer and conflicting actions.
@@ -169,7 +169,7 @@ export declare class ParallelActionError extends Error {
169
169
  export declare function buildErrorMap<A>(map: ErrorParallelMap<A>): ErrorMap<A>;
170
170
  /** @internal */
171
171
  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> = {
172
+ export type Ref<P> = {
173
173
  current: P;
174
174
  };
175
175
  /** @internal */
@@ -181,13 +181,13 @@ export declare function buildOnMountInvocationContext<S, DS, A, P>(stateRef: Ref
181
181
  /** @internal */
182
182
  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
183
  /** @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>;
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: (p: P) => S): OnPropsChangeEffectsContext<S, DS, P>;
185
185
  /** @internal */
186
186
  export declare function addStateToContext<T, S>(ctx: T, stateRef: Ref<S>): T & ContextState<S>;
187
187
  /** @internal */
188
188
  export declare function addContextActions<T, A>(ctx: T, actionsRef: Ref<A>): T & InvocationContextActions<A>;
189
189
  /** @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;
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>, options: StoreOptions<S, A, P, DS>, setState: SetStateFunc<S, A>): (...args: Parameters<F>) => void;
191
191
  /** @internal */
192
192
  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
193
  /** @internal */
@@ -200,7 +200,9 @@ export declare function areSameArgs(args1: any[], args2: any[]): boolean;
200
200
  /** @internal */
201
201
  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
202
  /** @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;
203
+ export declare function fixDerivedDeps<S, A, P, DS>(options: StoreOptions<S, A, P, DS>): void;
204
+ /** @internal */
205
+ 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
206
  /** @internal */
205
207
  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
208
  newState: S;