state-decorator 7.0.0-beta.0 → 7.0.0-beta.10-dev

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 (65) hide show
  1. package/README.md +384 -192
  2. package/es/helpers.d.ts +66 -0
  3. package/es/helpers.js +163 -0
  4. package/{dist/v5_test.js.map → es/helpers.js.map} +1 -1
  5. package/es/impl.d.ts +19 -5
  6. package/es/impl.js +963 -1
  7. package/es/impl.js.map +1 -1
  8. package/es/index.d.ts +34 -36
  9. package/es/index.js +1013 -1
  10. package/es/index.js.map +1 -1
  11. package/es/middlewares.js +519 -1
  12. package/es/middlewares.js.map +1 -1
  13. package/es/test.d.ts +6 -4
  14. package/es/test.js +349 -1
  15. package/es/test.js.map +1 -1
  16. package/es/types.d.ts +32 -3
  17. package/es/v5.js +301 -1
  18. package/es/v5.js.map +1 -1
  19. package/es/v5_test.js +392 -1
  20. package/es/v5_test.js.map +1 -1
  21. package/es/v6.d.ts +18 -0
  22. package/es/v6.js +98 -0
  23. package/es/v6.js.map +1 -0
  24. package/helpers.d.ts +66 -0
  25. package/helpers.js +175 -0
  26. package/{dist/test.js.map → helpers.js.map} +1 -1
  27. package/impl.d.ts +19 -5
  28. package/impl.js +996 -1
  29. package/impl.js.map +1 -1
  30. package/index.d.ts +34 -36
  31. package/index.js +1044 -1
  32. package/index.js.map +1 -1
  33. package/middlewares.js +526 -1
  34. package/middlewares.js.map +1 -1
  35. package/package.json +5 -4
  36. package/test.d.ts +6 -4
  37. package/test.js +358 -1
  38. package/test.js.map +1 -1
  39. package/types.d.ts +32 -3
  40. package/v5.js +322 -1
  41. package/v5.js.map +1 -1
  42. package/v5_test.js +416 -1
  43. package/v5_test.js.map +1 -1
  44. package/v6.d.ts +18 -0
  45. package/v6.js +123 -0
  46. package/v6.js.map +1 -0
  47. package/dist/impl.d.ts +0 -195
  48. package/dist/impl.js +0 -2
  49. package/dist/impl.js.map +0 -1
  50. package/dist/index.d.ts +0 -168
  51. package/dist/index.js +0 -2
  52. package/dist/index.js.map +0 -1
  53. package/dist/middlewares.d.ts +0 -26
  54. package/dist/middlewares.js +0 -2
  55. package/dist/middlewares.js.map +0 -1
  56. package/dist/shallow.d.ts +0 -15
  57. package/dist/test.d.ts +0 -134
  58. package/dist/test.js +0 -2
  59. package/dist/types.d.ts +0 -352
  60. package/dist/v5.d.ts +0 -58
  61. package/dist/v5.js +0 -2
  62. package/dist/v5.js.map +0 -1
  63. package/dist/v5_test.d.ts +0 -70
  64. package/dist/v5_test.js +0 -2
  65. package/dist/v5_types.d.ts +0 -227
package/test.d.ts CHANGED
@@ -14,7 +14,7 @@ PERFORMANCE OF THIS SOFTWARE.
14
14
  ***************************************************************************** */
15
15
  import { ErrorMap, StoreActions, StoreApi, StoreOptions } from '.';
16
16
  import { DerivedState, SetStateFunc, Ref } from './impl';
17
- import { DecoratedActions } from './types';
17
+ import { DecoratedActions, StoreConfig } from './types';
18
18
  declare type MockActions<A, MockAction> = {
19
19
  [k in keyof A]: MockAction;
20
20
  };
@@ -72,6 +72,7 @@ declare type MockStoreAction<S, A extends DecoratedActions, F extends (...args:
72
72
  call: (...args: Parameters<F>) => Promise<MockResult<S, A, P, DS>>;
73
73
  };
74
74
  declare type MockStore<S, A extends DecoratedActions, P, DS> = {
75
+ getInitialState: (p: P) => S;
75
76
  /**
76
77
  * Creates a new store with specified state.
77
78
  */
@@ -112,11 +113,12 @@ declare type MockStore<S, A extends DecoratedActions, P, DS> = {
112
113
  */
113
114
  onInit: (props?: Partial<P>) => MockResultWithTest<S, A, P, DS>;
114
115
  /** @internal */
115
- onPropsChangeImpl: (newStateRef: Ref<S>, newPropsRef: Ref<P>, newDerivedStateRef: Ref<DerivedState<DS>>, newActionsRef: Ref<StoreActions<S, A, P, DS, S>>, setState: SetStateFunc<S, A>, init?: boolean) => MockResult<S, A, P, DS>;
116
+ onPropsChangeImpl: (newStateRef: Ref<S>, newPropsRef: Ref<P>, newDerivedStateRef: Ref<DerivedState<DS>>, newActionsRef: Ref<StoreActions<S, A, P, DS, S>>, setState: SetStateFunc<S, A>, init?: boolean, deferred?: boolean) => MockResult<S, A, P, DS>;
116
117
  getAction: <K extends keyof A>(name: K) => MockStoreAction<S, A, A[K], P, DS>;
117
118
  };
118
119
  export declare function createMockFromStore<S, A extends DecoratedActions, P, DS>(store: StoreApi<S, A, P, DS>, props?: P): MockStore<S, A, P, DS>;
119
- export declare function createMockStore<S, A extends DecoratedActions, P = {}, DS = {}>(initialState: S | ((p: P) => S), actions: StoreActions<S, A, P, DS>, props?: P, options?: StoreOptions<S, A, P, DS>, mockActions?: MockActionImpl<A>): MockStore<S, A, P, DS>;
120
+ export declare function createMockStore<S, A extends DecoratedActions, P, DS>(config: StoreConfig<S, A, P, DS>, props?: P): MockStore<S, A, P, DS>;
121
+ export declare function createMockStoreV6<S, A extends DecoratedActions, P = {}, DS = {}>(initialState: S | ((p: P) => S), actions: StoreActions<S, A, P, DS>, props?: P, options?: StoreOptions<S, A, P, DS>, mockActions?: MockActionImpl<A>): MockStore<S, A, P, DS>;
120
122
  /**
121
123
  * Set the mock factory. Each mock action will be created using this factory.
122
124
  * @param factory the mock factory
@@ -130,5 +132,5 @@ export declare class ActionError<S = any, P = any, A = any> extends Error {
130
132
  actions: MockActions<A, any>;
131
133
  constructor(sourceError: Error, prevState: S, state: S, props: P, actions: MockActions<A, any>);
132
134
  }
133
- export declare function createMockStoreAction<S, A extends DecoratedActions, F extends (...args: any[]) => any, P, DS>(state: S, actionName: keyof A, actions: StoreActions<S, A, P, DS, S>, props: P, promiseRes: Promise<F> | Error, options: StoreOptions<S, A, P, DS>, mockActions: Partial<Record<keyof A, (...args: any[]) => any>>): MockStoreAction<S, A, F, P, DS>;
135
+ export declare function createMockStoreAction<S, A extends DecoratedActions, F extends (...args: any[]) => any, P, DS>(state: S, actionName: keyof A, actions: StoreActions<S, A, P, DS>, props: P, promiseRes: Promise<F> | Error, options: StoreOptions<S, A, P, DS>, mockActions: Partial<Record<keyof A, (...args: any[]) => any>>): MockStoreAction<S, A, F, P, DS>;
134
136
  export {};
package/test.js CHANGED
@@ -1,2 +1,359 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("./impl"),e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,r)};var r=function(){return(r=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function n(e,c,i,a,s){void 0===i&&(i={}),void 0===a&&(a={});var f=t.createRef(),l=t.createRef(i);function p(t,e,r){return n(null!=t?t:f.current,c,null!=e?e:l.current,a,null!=r?r:s)}function v(e,n){void 0===e&&(e=void 0),void 0===n&&(n=void 0);var o=t.createRef({state:null,deps:{}});return t.computeDerivedValues(e||f,n||l,o,a),r(r({},(null==e?void 0:e.current)||f.current),o.current.state||{})}return f.current="function"==typeof e?e(i):e,{test:function(t){return t(v(),l.current),this},setMockActions:function(t){return p(void 0,void 0,t)},onMount:function(t){return void 0===t&&(t={}),this.onInit(t)},setState:function(t){return p(t,void 0)},setProps:function(t){return p(void 0,t)},setPartialState:function(t){return p(r(r({},f.current),t),void 0)},setPartialProps:function(t){return p(void 0,r(r({},l.current),t))},onPropsChange:function(e,n){void 0===n&&(n=!1);var i=t.createRef(f.current),u=t.createRef(r(r({},l.current),e)),a=t.createRef({state:null,deps:{}}),p=o(c,s),v=this.onPropsChangeImpl(i,u,a,p,(function(t,e,r,n,o){null!=t&&(i.current=t)}),n);return r(r({},v),{test:function(t){t(v)}})},onPropsChangeImpl:function(e,r,n,o,c,i){return t.computeDerivedValues(f,l,n,a),t.onPropChange(e,n,r,l.current,o,a,c,i),{prevState:v(f,l),state:v(e,r),props:r.current,actions:o.current,errorMap:{}}},onInit:function(n){void 0===n&&(n={});var u="function"==typeof e?e(i):e,f=t.createRef(u),p=t.createRef(r(r({},l.current),n)),d=t.createRef({state:null,deps:{}}),R=o(c,s);this.onPropsChangeImpl(f,p,d,R,(function(t,e,r,n,o){null!=t&&(f.current=t)}),!0),(null==a?void 0:a.onMount)&&a.onMount(t.buildOnMountInvocationContext(f,d,p,R));var m={prevState:null,state:v(f,p),props:p.current,actions:R.current,errorMap:{}};return r(r({},m),{test:function(t){t(m)}})},getAction:function(t){return u(f.current,t,c,l.current,null,a,void 0)}}}function o(e,r){var n=Object.keys(e);return t.createRef(n.reduce((function(t,e){return t[e]=c(null==r?void 0:r[e]),t}),{}))}var c=function(t){return jest.fn(t)};var i=function(t){function r(e,n,o,c,i){var u=t.call(this,e.message)||this;return Object.setPrototypeOf(u,r.prototype),u.sourceError=e,u.prevState=n,u.props=c,u.state=o,u.actions=i,Error.captureStackTrace&&Error.captureStackTrace(u,r),u}return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}(r,t),r}(Error);function u(e,n,c,a,s,f,l){var p=t.createRef(e),v=t.createRef(a),d=s;function R(t,e,r,o){return void 0===o&&(o=l),u(null!=t?t:p.current,n,c,null!=e?e:v.current,null!=r?r:d,f,o)}function m(e,n){void 0===e&&(e=void 0),void 0===n&&(n=void 0);var o=t.createRef({state:null,deps:{}});return t.computeDerivedValues(null!=e?e:p,null!=n?n:v,o,f),r(r({},(null==e?void 0:e.current)||p.current),o.current.state||{})}return{setMockActions:function(t){return R(void 0,void 0,void 0,t)},setState:function(t){return R(t,void 0,void 0)},setProps:function(t){return R(void 0,t,void 0)},setPartialState:function(t){return R(r(r({},p.current),t),void 0,void 0)},setPartialProps:function(t){return R(void 0,r(r({},v.current),t),void 0)},promiseResolves:function(t){return R(void 0,void 0,Promise.resolve(t))},promiseRejects:function(t){return R(void 0,void 0,Promise.reject(t))},test:function(t){return t(m(),v.current),this},call:function(){for(var e=[],u=0;u<arguments.length;u++)e[u]=arguments[u];var a=t.createRef(r({},p.current)),s=t.createRef({state:null,deps:{}});t.computeDerivedValues(a,v,s,f);var R=o(c,l),y=t.createRef({}),P=t.createRef({}),S=function(t){null!=t&&(a.current=t)},h=c[n],A=null;if(t.isSimpleSyncAction(h))t.decorateSimpleSyncAction(n,h,a,s,v,t.createRef(!0),S).apply(void 0,e),A=Promise.resolve();else if(t.isSyncAction(h))t.decorateSyncAction(n,r(r({},h),{debounceSideEffectsTimeout:0,debounceTimeout:0}),a,s,v,R,t.createRef(!0),null,f,S).apply(void 0,e),A=Promise.resolve();else if(t.isAsyncAction(h)){var M=t.createRef({}),g=t.createRef({}),O=t.createRef(!0),b=r({},t.computeAsyncActionInput(h));d&&(b.getPromise=function(){return d}),b.optimisticEffects&&(b.effects=b.optimisticEffects,delete b.optimisticEffects),A=t.decorateAsyncAction({actionName:n,derivedStateRef:s,propsRef:v,loadingMapRef:y,errorMapRef:P,promisesRef:M,conflictActionsRef:g,initializedRef:O,options:f,setState:S,stateRef:a,actionsRef:R,action:b}).apply(void 0,e)}return(null!=A?A:Promise.resolve()).then((function(){return y.current={},{prevState:m(p),state:m(a),props:v.current,errorMap:t.buildErrorMap(P.current),actions:R.current}})).catch((function(t){return Promise.reject(new i(t,m(p),m(a),v.current,R.current))}))}}}exports.ActionError=i,exports.createMockFromStore=function(t,e){void 0===e&&(e={});var r=t.getConfig();return n(r.getInitialState,r.actions,e,r.options)},exports.createMockStore=n,exports.createMockStoreAction=u,exports.setMockFactory=function(t){c=t};
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var impl = require('./impl');
6
+
7
+ /*! *****************************************************************************
8
+ Copyright (c) Microsoft Corporation.
9
+
10
+ Permission to use, copy, modify, and/or distribute this software for any
11
+ purpose with or without fee is hereby granted.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19
+ PERFORMANCE OF THIS SOFTWARE.
20
+ ***************************************************************************** */
21
+ /* global Reflect, Promise */
22
+
23
+ var extendStatics = function(d, b) {
24
+ extendStatics = Object.setPrototypeOf ||
25
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
26
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
27
+ return extendStatics(d, b);
28
+ };
29
+
30
+ function __extends(d, b) {
31
+ if (typeof b !== "function" && b !== null)
32
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
33
+ extendStatics(d, b);
34
+ function __() { this.constructor = d; }
35
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
36
+ }
37
+
38
+ var __assign = function() {
39
+ __assign = Object.assign || function __assign(t) {
40
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
41
+ s = arguments[i];
42
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
43
+ }
44
+ return t;
45
+ };
46
+ return __assign.apply(this, arguments);
47
+ };
48
+
49
+ function __rest(s, e) {
50
+ var t = {};
51
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
52
+ t[p] = s[p];
53
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
54
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
55
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
56
+ t[p[i]] = s[p[i]];
57
+ }
58
+ return t;
59
+ }
60
+
61
+ /*! *****************************************************************************
62
+ Copyright (c) GlobalSport SAS.
63
+
64
+ Permission to use, copy, modify, and/or distribute this software for any
65
+ purpose with or without fee is hereby granted.
66
+
67
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
68
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
69
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
70
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
71
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
72
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
73
+ PERFORMANCE OF THIS SOFTWARE.
74
+ ***************************************************************************** */
75
+ function createMockFromStore(store, props) {
76
+ if (props === void 0) { props = {}; }
77
+ var cfg = store.getConfig();
78
+ return createMockStore(cfg, props);
79
+ }
80
+ function createMockStore(config, props) {
81
+ if (props === void 0) { props = {}; }
82
+ var getInitialState = config.getInitialState, actions = config.actions, options = __rest(config, ["getInitialState", "actions"]);
83
+ return createMockStoreV6(getInitialState, actions, props, options);
84
+ }
85
+ function createMockStoreV6(initialState, actions, props, options, mockActions) {
86
+ if (props === void 0) { props = {}; }
87
+ if (options === void 0) { options = {}; }
88
+ var stateRef = impl.createRef();
89
+ var propsRef = impl.createRef(props);
90
+ if (typeof initialState === 'function') {
91
+ stateRef.current = initialState(props);
92
+ }
93
+ else {
94
+ stateRef.current = initialState;
95
+ }
96
+ function cloneStore(newState, newProps, newMockActions) {
97
+ return createMockStoreV6(newState !== null && newState !== void 0 ? newState : stateRef.current, actions, newProps !== null && newProps !== void 0 ? newProps : propsRef.current, options, newMockActions !== null && newMockActions !== void 0 ? newMockActions : mockActions);
98
+ }
99
+ function getState(newStateRef, newPropsRef) {
100
+ if (newStateRef === void 0) { newStateRef = undefined; }
101
+ if (newPropsRef === void 0) { newPropsRef = undefined; }
102
+ var derivedStateRef = impl.createRef({ state: null, deps: {} });
103
+ impl.computeDerivedValues(newStateRef || stateRef, newPropsRef || propsRef, derivedStateRef, options);
104
+ return __assign(__assign({}, ((newStateRef === null || newStateRef === void 0 ? void 0 : newStateRef.current) || stateRef.current)), (derivedStateRef.current.state || {}));
105
+ }
106
+ return {
107
+ getInitialState: function (p) {
108
+ if (typeof initialState === 'function') {
109
+ return initialState(p);
110
+ }
111
+ return initialState;
112
+ },
113
+ test: function (f) {
114
+ f(getState(), propsRef.current);
115
+ return this;
116
+ },
117
+ setMockActions: function (mockActions) {
118
+ return cloneStore(undefined, undefined, mockActions);
119
+ },
120
+ onMount: function (propsIn) {
121
+ if (propsIn === void 0) { propsIn = {}; }
122
+ return this.onInit(propsIn);
123
+ },
124
+ setState: function (s) {
125
+ return cloneStore(s, undefined);
126
+ },
127
+ setProps: function (p) {
128
+ return cloneStore(undefined, p);
129
+ },
130
+ setPartialState: function (s) {
131
+ return cloneStore(__assign(__assign({}, stateRef.current), s), undefined);
132
+ },
133
+ setPartialProps: function (p) {
134
+ return cloneStore(undefined, __assign(__assign({}, propsRef.current), p));
135
+ },
136
+ onPropsChange: function (newProps, init) {
137
+ if (init === void 0) { init = false; }
138
+ var newStateRef = impl.createRef(stateRef.current);
139
+ var newPropsRef = impl.createRef(__assign(__assign({}, propsRef.current), newProps));
140
+ var derivedStateRef = impl.createRef({ state: null, deps: {} });
141
+ var actionsRef = getActionsRef(actions, mockActions);
142
+ var setState = function (newStateIn, _newLoadingMap, _actionName, _actionType, _isAsync) {
143
+ if (newStateIn != null) {
144
+ newStateRef.current = newStateIn;
145
+ }
146
+ };
147
+ var res = this.onPropsChangeImpl(newStateRef, newPropsRef, derivedStateRef, actionsRef, setState, init, false);
148
+ return __assign(__assign({}, res), { test: function (testFunc) {
149
+ testFunc(res);
150
+ } });
151
+ },
152
+ onPropsChangeImpl: function (newStateRef, newPropsRef, newDerivedStateRef, actionsRef, setState, init, isDeferred) {
153
+ impl.computeDerivedValues(stateRef, propsRef, newDerivedStateRef, options);
154
+ impl.onPropChange(newStateRef, newDerivedStateRef, newPropsRef, propsRef.current, actionsRef, options, typeof initialState === 'function' ? initialState : function () { return initialState; }, setState, init, isDeferred);
155
+ return {
156
+ prevState: getState(stateRef, propsRef),
157
+ state: getState(newStateRef, newPropsRef),
158
+ props: newPropsRef.current,
159
+ actions: actionsRef.current,
160
+ errorMap: {},
161
+ };
162
+ },
163
+ onInit: function (newProps) {
164
+ if (newProps === void 0) { newProps = {}; }
165
+ // reset initial state
166
+ var state = typeof initialState === 'function' ? initialState(props) : initialState;
167
+ var newStateRef = impl.createRef(state);
168
+ var newPropsRef = impl.createRef(__assign(__assign({}, propsRef.current), newProps));
169
+ var derivedStateRef = impl.createRef({ state: null, deps: {} });
170
+ var actionsRef = getActionsRef(actions, mockActions);
171
+ var setState = function (newStateIn, _newLoadingMap, _actionName, _actionType, _isAsync) {
172
+ if (newStateIn != null) {
173
+ newStateRef.current = newStateIn;
174
+ }
175
+ };
176
+ // sync
177
+ this.onPropsChangeImpl(newStateRef, newPropsRef, derivedStateRef, actionsRef, setState, true, false);
178
+ if (options === null || options === void 0 ? void 0 : options.onMount) {
179
+ options.onMount(impl.buildOnMountInvocationContext(newStateRef, derivedStateRef, newPropsRef, actionsRef));
180
+ }
181
+ // deferred
182
+ this.onPropsChangeImpl(newStateRef, newPropsRef, derivedStateRef, actionsRef, setState, true, true);
183
+ if (options === null || options === void 0 ? void 0 : options.onMountDeferred) {
184
+ options.onMountDeferred(impl.buildOnMountInvocationContext(newStateRef, derivedStateRef, newPropsRef, actionsRef));
185
+ }
186
+ var res = {
187
+ prevState: null,
188
+ state: getState(newStateRef, newPropsRef),
189
+ props: newPropsRef.current,
190
+ actions: actionsRef.current,
191
+ errorMap: {},
192
+ };
193
+ return __assign(__assign({}, res), { test: function (testFunc) {
194
+ testFunc(res);
195
+ } });
196
+ },
197
+ getAction: function (actionName) {
198
+ return createMockStoreAction(stateRef.current, actionName, actions, propsRef.current, null, options, undefined);
199
+ },
200
+ };
201
+ }
202
+ function getActionsRef(actions, impl$1) {
203
+ var keys = Object.keys(actions);
204
+ return impl.createRef(keys.reduce(function (acc, actionName) {
205
+ acc[actionName] = mockFactory(impl$1 === null || impl$1 === void 0 ? void 0 : impl$1[actionName]);
206
+ return acc;
207
+ }, {}));
208
+ }
209
+ function createMockAction(impl) {
210
+ return jest.fn(impl);
211
+ }
212
+ var mockFactory = createMockAction;
213
+ /**
214
+ * Set the mock factory. Each mock action will be created using this factory.
215
+ * @param factory the mock factory
216
+ */
217
+ function setMockFactory(factory) {
218
+ mockFactory = factory;
219
+ }
220
+ var ActionError = /** @class */ (function (_super) {
221
+ __extends(ActionError, _super);
222
+ function ActionError(sourceError, prevState, state, props, actions) {
223
+ var _this = _super.call(this, sourceError.message) || this;
224
+ Object.setPrototypeOf(_this, ActionError.prototype);
225
+ _this.sourceError = sourceError;
226
+ _this.prevState = prevState;
227
+ _this.props = props;
228
+ _this.state = state;
229
+ _this.actions = actions;
230
+ if (Error.captureStackTrace) {
231
+ Error.captureStackTrace(_this, ActionError);
232
+ }
233
+ return _this;
234
+ }
235
+ return ActionError;
236
+ }(Error));
237
+ function createMockStoreAction(state, actionName, actions, props, promiseRes, options, mockActions) {
238
+ var stateRef = impl.createRef(state);
239
+ var propsRef = impl.createRef(props);
240
+ var promiseResult = promiseRes;
241
+ function cloneStoreAction(newState, newProps, promiseRes, newMockActions) {
242
+ if (newMockActions === void 0) { newMockActions = mockActions; }
243
+ return createMockStoreAction(newState !== null && newState !== void 0 ? newState : stateRef.current, actionName, actions, newProps !== null && newProps !== void 0 ? newProps : propsRef.current, promiseRes !== null && promiseRes !== void 0 ? promiseRes : promiseResult, options, newMockActions);
244
+ }
245
+ function getState(newStateRef, newPropsRef) {
246
+ if (newStateRef === void 0) { newStateRef = undefined; }
247
+ if (newPropsRef === void 0) { newPropsRef = undefined; }
248
+ var derivedStateRef = impl.createRef({ state: null, deps: {} });
249
+ impl.computeDerivedValues(newStateRef !== null && newStateRef !== void 0 ? newStateRef : stateRef, newPropsRef !== null && newPropsRef !== void 0 ? newPropsRef : propsRef, derivedStateRef, options);
250
+ return __assign(__assign({}, ((newStateRef === null || newStateRef === void 0 ? void 0 : newStateRef.current) || stateRef.current)), (derivedStateRef.current.state || {}));
251
+ }
252
+ return {
253
+ setMockActions: function (mockActions) {
254
+ return cloneStoreAction(undefined, undefined, undefined, mockActions);
255
+ },
256
+ setState: function (s) {
257
+ return cloneStoreAction(s, undefined, undefined);
258
+ },
259
+ setProps: function (p) {
260
+ return cloneStoreAction(undefined, p, undefined);
261
+ },
262
+ setPartialState: function (s) {
263
+ return cloneStoreAction(__assign(__assign({}, stateRef.current), s), undefined, undefined);
264
+ },
265
+ setPartialProps: function (p) {
266
+ return cloneStoreAction(undefined, __assign(__assign({}, propsRef.current), p), undefined);
267
+ },
268
+ promiseResolves: function (res) {
269
+ return cloneStoreAction(undefined, undefined, Promise.resolve(res));
270
+ },
271
+ promiseRejects: function (err) {
272
+ return cloneStoreAction(undefined, undefined, Promise.reject(err));
273
+ },
274
+ test: function (f) {
275
+ f(getState(), propsRef.current);
276
+ return this;
277
+ },
278
+ call: function () {
279
+ var args = [];
280
+ for (var _i = 0; _i < arguments.length; _i++) {
281
+ args[_i] = arguments[_i];
282
+ }
283
+ var newStateRef = impl.createRef(__assign({}, stateRef.current));
284
+ var derivedStateRef = impl.createRef({ state: null, deps: {} });
285
+ impl.computeDerivedValues(newStateRef, propsRef, derivedStateRef, options);
286
+ // create mock action to test side effects
287
+ var actionsRef = getActionsRef(actions, mockActions);
288
+ var loadingParallelMapRef = impl.createRef({});
289
+ var errorMapRef = impl.createRef({});
290
+ var setState = function (newStateIn /* newLoadingMap, actionName, actionType, isAsync, ctx */) {
291
+ if (newStateIn != null) {
292
+ newStateRef.current = newStateIn;
293
+ }
294
+ };
295
+ var action = actions[actionName];
296
+ var promise = null;
297
+ if (impl.isSimpleSyncAction(action)) {
298
+ impl.decorateSimpleSyncAction(actionName, action, newStateRef, derivedStateRef, propsRef, impl.createRef(true), setState).apply(void 0, args);
299
+ promise = Promise.resolve();
300
+ }
301
+ else if (impl.isSyncAction(action)) {
302
+ impl.decorateSyncAction(actionName, __assign(__assign({}, action), { debounceSideEffectsTimeout: 0, debounceTimeout: 0 }), newStateRef, derivedStateRef, propsRef, actionsRef, impl.createRef(true), null, options, setState, function (_) { }).apply(void 0, args);
303
+ promise = Promise.resolve();
304
+ }
305
+ else if (impl.isAsyncAction(action)) {
306
+ var promisesRef = impl.createRef({});
307
+ var conflictActionsRef = impl.createRef({});
308
+ var initializedRef = impl.createRef(true);
309
+ var impl$1 = __assign({}, impl.computeAsyncActionInput(action));
310
+ if (promiseResult) {
311
+ impl$1.getPromise = function () { return promiseResult; };
312
+ }
313
+ // simulate optimistic actions
314
+ if (impl$1.optimisticEffects) {
315
+ impl$1.effects = impl$1.optimisticEffects;
316
+ delete impl$1.optimisticEffects;
317
+ }
318
+ promise = impl.decorateAsyncAction({
319
+ actionName: actionName,
320
+ derivedStateRef: derivedStateRef,
321
+ propsRef: propsRef,
322
+ loadingParallelMapRef: loadingParallelMapRef,
323
+ errorMapRef: errorMapRef,
324
+ promisesRef: promisesRef,
325
+ conflictActionsRef: conflictActionsRef,
326
+ initializedRef: initializedRef,
327
+ options: options,
328
+ setState: setState,
329
+ stateRef: newStateRef,
330
+ actionsRef: actionsRef,
331
+ action: impl$1,
332
+ clearError: function (_) { },
333
+ }).apply(void 0, args);
334
+ }
335
+ return (promise !== null && promise !== void 0 ? promise : Promise.resolve())
336
+ .then(function () {
337
+ loadingParallelMapRef.current = {};
338
+ return {
339
+ prevState: getState(stateRef),
340
+ state: getState(newStateRef),
341
+ props: propsRef.current,
342
+ errorMap: impl.buildErrorMap(errorMapRef.current),
343
+ actions: actionsRef.current,
344
+ };
345
+ })
346
+ .catch(function (e) {
347
+ return Promise.reject(new ActionError(e, getState(stateRef), getState(newStateRef), propsRef.current, actionsRef.current));
348
+ });
349
+ },
350
+ };
351
+ }
352
+
353
+ exports.ActionError = ActionError;
354
+ exports.createMockFromStore = createMockFromStore;
355
+ exports.createMockStore = createMockStore;
356
+ exports.createMockStoreAction = createMockStoreAction;
357
+ exports.createMockStoreV6 = createMockStoreV6;
358
+ exports.setMockFactory = setMockFactory;
2
359
  //# sourceMappingURL=test.js.map
package/test.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"test.js","sources":["../node_modules/tslib/tslib.es6.js"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n"],"names":["extendStatics","d","b","Object","setPrototypeOf","__proto__","Array","p","prototype","hasOwnProperty","call","__assign","assign","t","s","i","n","arguments","length","apply","this","TypeError","String","__","constructor","create"],"mappings":"4FAgBIA,EAAgB,SAASC,EAAGC,GAI5B,OAHAF,EAAgBG,OAAOC,gBAClB,CAAEC,UAAW,cAAgBC,OAAS,SAAUL,EAAGC,GAAKD,EAAEI,UAAYH,IACvE,SAAUD,EAAGC,GAAK,IAAK,IAAIK,KAAKL,EAAOC,OAAOK,UAAUC,eAAeC,KAAKR,EAAGK,KAAIN,EAAEM,GAAKL,EAAEK,MAC3EN,EAAGC,IAWrB,IAAIS,EAAW,WAQlB,OAPAA,EAAWR,OAAOS,QAAU,SAAkBC,GAC1C,IAAK,IAAIC,EAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAE5C,IAAK,IAAIR,KADTO,EAAIG,UAAUF,GACOZ,OAAOK,UAAUC,eAAeC,KAAKI,EAAGP,KAAIM,EAAEN,GAAKO,EAAEP,IAE9E,OAAOM,IAEKM,MAAMC,KAAMH,usEAhBzB,SAAmBhB,EAAGC,GACzB,GAAiB,mBAANA,GAA0B,OAANA,EAC3B,MAAM,IAAImB,UAAU,uBAAyBC,OAAOpB,GAAK,iCAE7D,SAASqB,IAAOH,KAAKI,YAAcvB,EADnCD,EAAcC,EAAGC,GAEjBD,EAAEO,UAAkB,OAANN,EAAaC,OAAOsB,OAAOvB,IAAMqB,EAAGf,UAAYN,EAAEM,UAAW,IAAIe"}
1
+ {"version":3,"file":"test.js","sources":["../node_modules/tslib/tslib.es6.js"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n"],"names":[],"mappings":"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"}
package/types.d.ts CHANGED
@@ -29,6 +29,7 @@ export declare type LoadingProps<A> = {
29
29
  loadingMap: LoadingMap<A>;
30
30
  loadingParallelMap: LoadingParallelMap<A>;
31
31
  };
32
+ export declare type LoadingMapProps<A> = Pick<LoadingProps<A>, 'loadingMap'>;
32
33
  export declare type PromiseIdErrorMap = {
33
34
  [promiseId: string]: Error;
34
35
  };
@@ -38,6 +39,9 @@ export declare type ErrorMap<A> = {
38
39
  export declare type ErrorParallelMap<A> = {
39
40
  [P in keyof A]?: PromiseIdErrorMap;
40
41
  };
42
+ export declare type ErrorProps<A> = {
43
+ errorMap: ErrorMap<A>;
44
+ };
41
45
  export interface DecoratedActions {
42
46
  [name: string]: (...args: any[]) => Promise<any> | void;
43
47
  }
@@ -102,7 +106,7 @@ export declare type SyncAction<S, F extends (...args: any[]) => any, A, P, DS, F
102
106
  * @returns <code>true</code> if the action is abortable and an action is ongoing, <code>false</code> otherwise.
103
107
  */
104
108
  export declare type AbortActionCallback<A> = (actionName: keyof A, promiseId?: string) => boolean;
105
- export declare type GetErrorMessage<S, DS, F extends (...args: any[]) => any, P> = (ctx: ErrorMessageInvocationContext<S, DS, F, P>) => string;
109
+ export declare type GetErrorMessage<S, DS, F extends (...args: any[]) => any, P> = (ctx: ErrorMessageInvocationContext<S, DS, F, P>) => string | null;
106
110
  export declare type ContextState<S> = {
107
111
  state: S;
108
112
  s: S;
@@ -140,9 +144,17 @@ export declare type ErrorEffectsInvocationContext<S, DS, F extends (...args: any
140
144
  };
141
145
  export declare type SuccessMessageInvocationContext<S, DS, F extends (...args: any[]) => any, P> = EffectsInvocationContext<S, DS, F, P>;
142
146
  export declare type ErrorMessageInvocationContext<S, DS, F extends (...args: any[]) => any, P> = ErrorEffectsInvocationContext<S, DS, F, P>;
143
- export declare type SideEffectsInvocationContext<S, DS, F extends (...args: any[]) => any, P, A> = EffectsInvocationContext<S, DS, F, P> & InvocationContextActions<A> & WarningNotifyFunc;
147
+ export declare type ClearErrorFunc<A> = (actionName: keyof A, promiseId?: string) => void;
148
+ export declare type ClearError<A> = {
149
+ clearError: ClearErrorFunc<A>;
150
+ };
151
+ export declare type SideEffectsInvocationContext<S, DS, F extends (...args: any[]) => any, P, A> = EffectsInvocationContext<S, DS, F, P> & InvocationContextActions<A> & WarningNotifyFunc & ClearError<A>;
144
152
  export declare type ErrorSideEffectsInvocationContext<S, DS, F extends (...args: any[]) => any, P, A> = ErrorEffectsInvocationContext<S, DS, F, P> & InvocationContextActions<A> & WarningNotifyFunc;
145
153
  export declare type OnMountInvocationContext<S, A, P> = ContextBase<S, P> & InvocationContextActions<A>;
154
+ export declare type AbortedActions<A> = Partial<Record<keyof A, string[]>>;
155
+ export declare type OnUnMountInvocationContext<S, A, P> = ContextBase<S, P> & {
156
+ abortedActions: AbortedActions<A>;
157
+ };
146
158
  export declare type EffectsType = 'preEffects' | 'effects' | 'errorEffects' | 'optimisticEffects' | null;
147
159
  export declare type MiddlewareActionContext<S, A, P> = {
148
160
  name: keyof A;
@@ -292,6 +304,7 @@ export declare type OnPropsChangeEffectsContext<S, DS, P> = ContextWithDerived<S
292
304
  indices: number[];
293
305
  index: number;
294
306
  isInit: boolean;
307
+ getInitialState: (p: P) => S;
295
308
  };
296
309
  export declare type OnPropsChangeSideEffectsContext<S, P, A, DS = {}> = OnPropsChangeEffectsContext<S, DS, P> & {
297
310
  actions: A;
@@ -305,6 +318,7 @@ declare type DerivedStateOption<S, P, DS> = {
305
318
  };
306
319
  export declare type OnPropsChangeOptions<S, DS, A, P> = {
307
320
  onMount?: boolean;
321
+ onMountDeferred?: boolean;
308
322
  getDeps: (p: P) => any[];
309
323
  effects?: (ctx: OnPropsChangeEffectsContext<S, DS, P>) => Partial<S>;
310
324
  sideEffects?: (ctx: OnPropsChangeSideEffectsContext<S, P, A>) => void;
@@ -314,6 +328,11 @@ export declare type StoreOptions<S, A, P = {}, DS = {}> = {
314
328
  * The state decorator name. Use in debug traces to identify the useStateDecorator instance.
315
329
  */
316
330
  name?: string;
331
+ /**
332
+ * Indicates that all asynchronous actions errors are managed externally.
333
+ * Same as setting isErrorManaged to true for all actions.
334
+ */
335
+ isErrorManaged?: boolean;
317
336
  /**
318
337
  * List of action names that are marked as loading at initial time.
319
338
  * If you must start your initial actions in a useSideEffect, a render is done before
@@ -340,13 +359,23 @@ export declare type StoreOptions<S, A, P = {}, DS = {}> = {
340
359
  * Initial actions.
341
360
  */
342
361
  onMount?: (ctx: OnMountInvocationContext<S, A, P>) => void;
362
+ /**
363
+ * Initial actions executed after initial render.
364
+ *
365
+ */
366
+ onMountDeferred?: (ctx: OnMountInvocationContext<S, A, P>) => void;
343
367
  /**
344
368
  * Callback on store destruction.
345
369
  */
346
- onUnmount?: (ctx: OnMountInvocationContext<S, A, P>) => Promise<any> | void;
370
+ onUnmount?: (ctx: OnUnMountInvocationContext<S, A, P>) => Promise<any> | void;
347
371
  /**
348
372
  * Compute derived state
349
373
  */
350
374
  derivedState?: DerivedStateOption<S, P, DS>;
351
375
  };
376
+ export declare type StoreConfig<S, A extends DecoratedActions, P = {}, DS = {}> = {
377
+ getInitialState: S | ((p: P) => S);
378
+ actions: StoreActions<S, A, P, DS>;
379
+ middlewares?: MiddlewareFactory<S, A, P>[];
380
+ } & StoreOptions<S, A, P, DS>;
352
381
  export {};