state-decorator 6.8.0 → 6.10.0
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 +90 -25
- package/dist/impl.d.ts +195 -0
- package/dist/impl.js +2 -0
- package/dist/impl.js.map +1 -0
- package/dist/index.d.ts +168 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/middlewares.d.ts +26 -0
- package/dist/middlewares.js +2 -0
- package/dist/middlewares.js.map +1 -0
- package/dist/shallow.d.ts +15 -0
- package/dist/test.d.ts +134 -0
- package/dist/test.js +2 -0
- package/dist/test.js.map +1 -0
- package/dist/types.d.ts +352 -0
- package/dist/v5.d.ts +58 -0
- package/dist/v5.js +2 -0
- package/dist/v5.js.map +1 -0
- package/dist/v5_test.d.ts +70 -0
- package/dist/v5_test.js +2 -0
- package/dist/v5_test.js.map +1 -0
- package/dist/v5_types.d.ts +227 -0
- package/es/impl.d.ts +195 -0
- package/es/impl.js +2 -0
- package/es/impl.js.map +1 -0
- package/es/index.d.ts +168 -0
- package/es/index.js +2 -0
- package/es/index.js.map +1 -0
- package/es/middlewares.d.ts +26 -0
- package/es/middlewares.js +2 -0
- package/es/middlewares.js.map +1 -0
- package/es/shallow.d.ts +15 -0
- package/es/test.d.ts +134 -0
- package/es/test.js +2 -0
- package/es/test.js.map +1 -0
- package/es/types.d.ts +352 -0
- package/es/v5.d.ts +58 -0
- package/es/v5.js +2 -0
- package/es/v5.js.map +1 -0
- package/es/v5_test.d.ts +70 -0
- package/es/v5_test.js +2 -0
- package/es/v5_test.js.map +1 -0
- package/es/v5_types.d.ts +227 -0
- package/impl.d.ts +107 -3
- package/impl.js +1 -1
- package/impl.js.map +1 -1
- package/index.d.ts +14 -0
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/middlewares.d.ts +14 -0
- package/middlewares.js +1 -1
- package/middlewares.js.map +1 -1
- package/package.json +3 -4
- package/shallow.d.ts +14 -0
- package/test.d.ts +17 -0
- package/test.js +1 -1
- package/test.js.map +1 -1
- package/types.d.ts +20 -0
- package/v5.d.ts +14 -0
- package/v5.js +1 -1
- package/v5.js.map +1 -1
- package/v5_test.d.ts +14 -0
- package/v5_test.js +1 -1
- package/v5_test.js.map +1 -1
- package/v5_types.d.ts +14 -0
- package/impl.es.js +0 -2
- package/impl.es.js.map +0 -1
- package/index.es.js +0 -2
- package/index.es.js.map +0 -1
- package/middlewares.es.js +0 -2
- package/middlewares.es.js.map +0 -1
- package/test.es.js +0 -2
- package/test.es.js.map +0 -1
- package/v5.es.js +0 -2
- package/v5.es.js.map +0 -1
- package/v5_test.es.js +0 -2
- package/v5_test.es.js.map +0 -1
package/es/index.d.ts
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
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
|
+
import { setGlobalConfig, GlobalConfig, ParallelActionError } from './impl';
|
|
16
|
+
import { DecoratedActions, StoreActions, AsyncAction, SyncAction, SimpleSyncAction, LoadingMap, ErrorMap, LoadingParallelMap, ErrorParallelMap, StoreOptions, AsyncActionPromise, InvocationContext, GetPromiseInvocationContext, EffectsInvocationContext, InvocationContextActions, WarningNotifyFunc, ErrorEffectsInvocationContext, OnMountInvocationContext, ContextBase, OnPropsChangeEffectsContext, ContextState, ConflictPolicy, Middleware, AbortActionCallback, MiddlewareFactory, LoadingProps } from './types';
|
|
17
|
+
export { DecoratedActions, StoreActions, LoadingMap, ErrorMap, LoadingParallelMap, ErrorParallelMap, ParallelActionError, StoreOptions, AsyncActionPromise as AsynchActionPromise, InvocationContext, GetPromiseInvocationContext, EffectsInvocationContext, InvocationContextActions, WarningNotifyFunc, ErrorEffectsInvocationContext, OnMountInvocationContext, ContextBase, OnPropsChangeEffectsContext, SyncAction, AsyncAction, SimpleSyncAction, ContextState, ConflictPolicy, GlobalConfig, Middleware, setGlobalConfig, LoadingProps, AbortActionCallback, };
|
|
18
|
+
export declare type IsLoadingFunc<A> = (...props: (keyof A | [keyof A, string])[]) => boolean;
|
|
19
|
+
declare type StateListenerUnregister = () => void;
|
|
20
|
+
export declare type StoreApi<S, A extends DecoratedActions, P, DS = {}> = {
|
|
21
|
+
/**
|
|
22
|
+
* The current store state (with derived state if any).
|
|
23
|
+
*/
|
|
24
|
+
readonly state: S & DS;
|
|
25
|
+
/**
|
|
26
|
+
* The store decorator (ie. ready to use) actions.
|
|
27
|
+
*/
|
|
28
|
+
readonly actions: A;
|
|
29
|
+
/**
|
|
30
|
+
* A boolean that indicates that at least one asynchronous action is loading.
|
|
31
|
+
*/
|
|
32
|
+
readonly loading: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* A map of loading actions map (computed on property access)
|
|
35
|
+
*/
|
|
36
|
+
readonly loadingMap: LoadingMap<A>;
|
|
37
|
+
/**
|
|
38
|
+
* A map of loading actions map (computed on property access)
|
|
39
|
+
*/
|
|
40
|
+
readonly errorMap: ErrorMap<A>;
|
|
41
|
+
/**
|
|
42
|
+
* A map of parallel loading actions map (computed on property access)
|
|
43
|
+
*/
|
|
44
|
+
readonly loadingParallelMap: LoadingParallelMap<A>;
|
|
45
|
+
/**
|
|
46
|
+
* A map of parallel actions error map (computed on property access)
|
|
47
|
+
*/
|
|
48
|
+
readonly errorParallelMap: ErrorParallelMap<A>;
|
|
49
|
+
/**
|
|
50
|
+
* Initializes the store with the specified props
|
|
51
|
+
*/
|
|
52
|
+
init: (p: P) => void;
|
|
53
|
+
/**
|
|
54
|
+
* Update the store with the specified props
|
|
55
|
+
*/
|
|
56
|
+
setProps: (p: P) => void;
|
|
57
|
+
/**
|
|
58
|
+
* Destroy the store
|
|
59
|
+
*/
|
|
60
|
+
destroy: () => void;
|
|
61
|
+
/**
|
|
62
|
+
* Abort an asynchronous action marked as abortable.
|
|
63
|
+
*/
|
|
64
|
+
abortAction: (actionName: keyof A, promiseId?: string) => boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Add a store state change listener
|
|
67
|
+
*/
|
|
68
|
+
addStateListener: (listener: StateListener<S, DS, A>) => StateListenerUnregister;
|
|
69
|
+
/**
|
|
70
|
+
* A function that takes a list of action names or a tuple of [action name, promiseId] and returns <code>true</code> if any action is loading.
|
|
71
|
+
*/
|
|
72
|
+
isLoading: IsLoadingFunc<A>;
|
|
73
|
+
getConfig: () => {
|
|
74
|
+
getInitialState: (p: P) => S;
|
|
75
|
+
options: StoreOptions<S, A, P, DS>;
|
|
76
|
+
actions: StoreActions<S, A, P, DS>;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
export declare type StateListenerContext<S, DS, A extends DecoratedActions> = S & DS & A & Pick<StoreApi<S, A, any, DS>, 'loading' | 'loadingMap' | 'errorMap' | 'isLoading' | 'abortAction'>;
|
|
80
|
+
export declare type StateListener<S, DS, A extends DecoratedActions> = (ctx: StateListenerContext<S, DS, A>) => void;
|
|
81
|
+
/**
|
|
82
|
+
* Create a new store.
|
|
83
|
+
* @param getInitialState The state initialization function (using props)
|
|
84
|
+
* @param actionsImpl The actions implementation (pure functions only).
|
|
85
|
+
* @param options Options to configure the store
|
|
86
|
+
* @returns a store.
|
|
87
|
+
*/
|
|
88
|
+
export declare function createStore<S, A extends DecoratedActions, P, DS = {}>(getInitialState: (p: P) => S, actionsImpl: StoreActions<S, A, P, DS>, options?: StoreOptions<S, A, P, DS>, storeMiddlewares?: MiddlewareFactory<S, A, P>[]): StoreApi<S, A, P, DS>;
|
|
89
|
+
/**
|
|
90
|
+
* A react hook to get a state slice. Will be refresh if, and only if, one property of the slice has changed
|
|
91
|
+
* @param store The store to listen to.
|
|
92
|
+
* @param slicerFunc A function that returns a state slice
|
|
93
|
+
* @param comparator An optional function to compare if slice property has changed (shallow test by default)
|
|
94
|
+
* @returns The state slice.
|
|
95
|
+
*/
|
|
96
|
+
export declare function useStoreSlice<S, A extends DecoratedActions, P, DS, SLICE>(store: StoreApi<S, A, P, DS>, slicerFunc: (ctx: StateListenerContext<S, DS, A>) => SLICE): SLICE;
|
|
97
|
+
export declare function useStoreSlice<S, A extends DecoratedActions, P, DS, K extends keyof StateListenerContext<S, DS, A>>(store: StoreApi<S, A, P, DS>, properties: K[]): Pick<StateListenerContext<S, DS, A>, K>;
|
|
98
|
+
/**
|
|
99
|
+
* Binds the store to this component.
|
|
100
|
+
* Store will be destroyed when component is unmouted.
|
|
101
|
+
* Props passed to actions will come from this components.
|
|
102
|
+
* If store is configured to react of props changes, it will used passed props.
|
|
103
|
+
* A store must be bound to only one React component.
|
|
104
|
+
* This component will be refreshed for every change in the store.
|
|
105
|
+
*
|
|
106
|
+
* @param store The store to listen to.
|
|
107
|
+
* @param props The parent component props
|
|
108
|
+
* @returns The state, actions and isLoading function.
|
|
109
|
+
*/
|
|
110
|
+
export declare function useStore<S, A extends DecoratedActions, P, DS = {}>(store: StoreApi<S, A, P, DS>, props?: P): {
|
|
111
|
+
state: S & DS;
|
|
112
|
+
actions: A;
|
|
113
|
+
loading: boolean;
|
|
114
|
+
isLoading: IsLoadingFunc<A>;
|
|
115
|
+
abortAction: (actionName: keyof A, promiseId?: string) => boolean;
|
|
116
|
+
loadingMap: LoadingMap<A>;
|
|
117
|
+
errorMap: ErrorMap<A>;
|
|
118
|
+
loadingParallelMap: LoadingParallelMap<A>;
|
|
119
|
+
errorParallelMap: ErrorParallelMap<A>;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Binds the store to this component.
|
|
123
|
+
* Store will be destroyed when component is unmouted.
|
|
124
|
+
* Props passed to actions will come from this components.
|
|
125
|
+
* If store is configured to react of props changes, it will used passed props.
|
|
126
|
+
* A store must be bound to only one React component.
|
|
127
|
+
*
|
|
128
|
+
* This component will NOT be refreshed for any change in the store.
|
|
129
|
+
*
|
|
130
|
+
* @param store The store to listen to.
|
|
131
|
+
* @param props The parent component props
|
|
132
|
+
*/
|
|
133
|
+
export declare function useBindStore<S, A extends DecoratedActions, P, DS = {}>(store: StoreApi<S, A, P, DS>, props?: P): StoreApi<S, A, P, DS>;
|
|
134
|
+
/**
|
|
135
|
+
* Creates and manages a local store.
|
|
136
|
+
* @param getInitialState Function to compute initial state from props.
|
|
137
|
+
* @param actionImpl Actions implementation.
|
|
138
|
+
* @param props Owner component props to update state or react on prop changes
|
|
139
|
+
* @param options The store options.
|
|
140
|
+
* @returns The state, actions and isLoading function.
|
|
141
|
+
*/
|
|
142
|
+
export declare function useLocalStore<S, A extends DecoratedActions, P, DS = {}>(getInitialState: (p: P) => S, actionImpl: StoreActions<S, A, P, DS>, props?: P, options?: StoreOptions<S, A, P, DS>, middlewares?: MiddlewareFactory<S, A, P>[]): {
|
|
143
|
+
state: S & DS;
|
|
144
|
+
actions: A;
|
|
145
|
+
loading: boolean;
|
|
146
|
+
isLoading: IsLoadingFunc<A>;
|
|
147
|
+
abortAction: (actionName: keyof A, promiseId?: string) => boolean;
|
|
148
|
+
loadingMap: LoadingMap<A>;
|
|
149
|
+
errorMap: ErrorMap<A>;
|
|
150
|
+
loadingParallelMap: LoadingParallelMap<A>;
|
|
151
|
+
errorParallelMap: ErrorParallelMap<A>;
|
|
152
|
+
};
|
|
153
|
+
export default useLocalStore;
|
|
154
|
+
/**
|
|
155
|
+
* Creates a new object by picking properties to the object passed a first parameter
|
|
156
|
+
* @param obj Object to pick properties from
|
|
157
|
+
* @param props Property names
|
|
158
|
+
* @returns a new object containing only picked properties
|
|
159
|
+
*/
|
|
160
|
+
export declare function pick<T, K extends keyof T>(obj: T, props: K[]): Pick<T, K>;
|
|
161
|
+
/**
|
|
162
|
+
* Returns a function that creates a new object by picking properties to the object passed as first parameter.
|
|
163
|
+
* To be used in conjunction of <code>useStoreSlice</code> like in example:
|
|
164
|
+
* const s = useStoreSlice(myStore, slice('list', 'addItem'));
|
|
165
|
+
* @param props Property names
|
|
166
|
+
* @returns a function to pick property from an passed object.
|
|
167
|
+
*/
|
|
168
|
+
export declare function slice<T, K extends keyof T>(...props: K[]): (obj: T) => Pick<T, K>;
|
package/es/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{useReducer as r,useMemo as n,useRef as t,useLayoutEffect as e,useEffect as u}from"react";import{createRef as o,isSimpleSyncAction as c,decorateSimpleSyncAction as i,isAsyncAction as a,decorateAsyncAction as l,computeAsyncActionInput as f,isSyncAction as s,decorateSyncAction as d,globalConfig as p,onPropChange as v,DEFAULT_PROMISE_ID as g,computeDerivedValues as M,buildOnMountInvocationContext as y,isLoadingImpl as b,runMiddlewares as L,buildLoadingMap as h,buildErrorMap as A}from"./impl";export{ParallelActionError,setGlobalConfig}from"./impl";var E,O=function(){return(O=Object.assign||function(r){for(var n,t=1,e=arguments.length;t<e;t++)for(var u in n=arguments[t])Object.prototype.hasOwnProperty.call(n,u)&&(r[u]=n[u]);return r}).apply(this,arguments)};function P(r,n,t){if(t||2===arguments.length)for(var e,u=0,o=n.length;u<o;u++)!e&&u in n||(e||(e=Array.prototype.slice.call(n,0,u)),e[u]=n[u]);return r.concat(e||Array.prototype.slice.call(n))}function m(r,n,t,e){void 0===t&&(t={}),void 0===e&&(e=null);var u=o(),E=o(),m=o(),j=o(),k=o(),R=o(),S=o(),w=o(),C=o(),I=o(!1),x=o([]),T={},G=0;function K(r,n){var t=O(O({},r),n),e=O(O(O({},t),j.current),{isLoading:F,abortAction:J,loading:q(),loadingMap:B(),errorMap:D()});Object.keys(T).forEach((function(r){T[r](e)}))}function N(r){u.current=r,M(u,m,E,t),K(u.current,E.current.state)}function U(o){var c;if(!I.current){m.current=o,I.current=!0,u.current=r(o);var i=new Set(null==t?void 0:t.initialActionsMarkedLoading);R.current=Object.keys(n).reduce((function(r,n){var t;return r[n]=i.has(n)?((t={})[g]=!0,t):{},r}),{}),S.current=Object.keys(n).reduce((function(r,n){return r[n]={},r}),{}),k.current={},w.current={},C.current={},E.current={state:null,deps:{}},x.current=[];var a={options:t,get state(){return u.current},actions:n,setState:N},l=function(r){var n,t=r();x.current.push(t),null===(n=t.init)||void 0===n||n.call(t,a)};null===(c=p.defaultMiddlewares)||void 0===c||c.forEach(l),null==e||e.forEach(l),M(u,m,E,t),v(u,E,m,null,j,t,_,!0),(null==t?void 0:t.onMount)&&t.onMount(y(u,E,m,j)),K(u.current,E.current.state)}}function _(r,n,e,o,c,i,a,l){void 0===a&&(a=!1),void 0===l&&(l=!1);var f=!1;if(I.current){var s=n,d=!!c&&b(s||R.current,[e,null==i?void 0:i.promiseId]),p=L(x.current,u.current,r,d,e,o,c,i),v=p.newState,y=p.newLoading;if(null!=v&&(f=!0,u.current=v),d!==y&&(s=h(s,e,(null==i?void 0:i.promiseId)||g,y),0===Object.keys(s).length&&(s=void 0)),null!=s&&(f=!0,R.current=s),f)M(u,m,E,t),l||K(v||u.current,E.current.state);else if(a){M(u,m,E,t)&&!l&&K(v||u.current,E.current.state)}}}var z=Object.keys(n);function F(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return b.apply(void 0,P([R.current],r,!1))}function J(r,n){var t,e;void 0===n&&(n=g);var u=null===(e=null===(t=w.current[r])||void 0===t?void 0:t[n])||void 0===e?void 0:e.abortController,o=!1;return u&&(u.abort(),o=!0),o}function q(){if(I.current){var r=R.current;return null!=Object.keys(r).find((function(n){var t=r[n];return Object.keys(t).find((function(r){return!!t[r]}))}))}return null}function B(){if(I.current){var r=R.current;return Object.keys(r).reduce((function(n,t){var e=r[t];return n[t]=null!=Object.keys(e).find((function(r){return!!e[r]})),n}),{})}return null}function D(){return I.current?A(S.current):null}return j.current=z.reduce((function(r,e){var o=n[e];return c(o)?r[e]=i(e,o,u,E,m,I,_):a(o)?r[e]=l({actionName:e,stateRef:u,derivedStateRef:E,propsRef:m,loadingMapRef:R,errorMapRef:S,actionsRef:j,promisesRef:w,conflictActionsRef:C,initializedRef:I,options:t,setState:_,action:f(o)}):s(o)&&(r[e]=d(e,o,u,E,m,j,I,k,t,_)),r}),{}),{getConfig:function(){return{getInitialState:r,options:t,actions:n}},setProps:function(r){var n=m.current;m.current=r,I.current?v(u,E,m,n,j,t,_,!1):U(r)},addStateListener:function(r){var n="".concat(G++);return T[n]=r,function(){delete T[n]}},init:U,destroy:function(){var r;I.current&&(null===(r=null==t?void 0:t.onUnmount)||void 0===r||r.call(t,y(u,E,m,j)),m.current=null,u.current=null,R.current=null,S.current=null,w.current=null,C.current=null,E.current=null,Object.keys(k.current).forEach((function(r){clearTimeout(k.current[r])})),k.current=null,T={},I.current=!1,x.current.forEach((function(r){var n;null===(n=r.destroy)||void 0===n||n.call(r)})),x.current=[])},isLoading:F,abortAction:J,get actions(){return j.current},get state(){return I.current?O(O({},u.current),E.current.state):null},get loading(){return q()},get loadingMap(){return B()},get errorMap(){return D()},get loadingParallelMap(){return I.current?R.current:null},get errorParallelMap(){return I.current?S.current:null}}}function j(u,o){var c=r((function(r){return r>100?0:r+1}),0)[1],i=n((function(){return o instanceof Function?o:function(r){return w(r,o)}}),[o]),a=t(null);if(null===a.current){var l=u.state;a.current=i(O(O(O({},l),u.actions),{actions:u.actions,loading:u.loading,isLoading:u.isLoading,abortAction:u.abortAction,loadingMap:u.loadingMap,errorMap:u.errorMap}))}return e((function(){return u.addStateListener((function(r){var n,t=i(r),e=a.current,u=p.comparator;n=null==e||!u(t,e),a.current=t,n&&c()}))}),[]),a.current}function k(n,o){void 0===o&&(o=null);var c=r((function(r){return r>100?0:r+1}),0)[1],i=t(n);return n.setProps(o),e((function(){return i.current.addStateListener((function(){c()}))}),[]),u((function(){return function(){return n.destroy()}}),[]),{state:n.state,actions:n.actions,loading:n.loading,isLoading:n.isLoading,abortAction:n.abortAction,loadingMap:n.loadingMap,errorMap:n.errorMap,loadingParallelMap:n.loadingParallelMap,errorParallelMap:n.errorParallelMap}}function R(r,n){return void 0===n&&(n=null),t(r),r.setProps(n),u((function(){return function(){return r.destroy()}}),[]),r}function S(r,n,e,u,o){var c=t();return null==c.current&&(c.current=m(r,n,u,o)),k(c.current,e)}function w(r,n){return n.reduce((function(n,t){return r.hasOwnProperty(t)&&(n[t]=r[t]),n}),{})}function C(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return function(n){return w(n,r)}}!function(r){r.REJECT="reject",r.IGNORE="ignore",r.KEEP_LAST="keepLast",r.KEEP_ALL="keepAll",r.PARALLEL="parallel",r.REUSE="reuse"}(E||(E={}));export default S;export{E as ConflictPolicy,m as createStore,w as pick,C as slice,R as useBindStore,S as useLocalStore,k as useStore,j as useStoreSlice};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
package/es/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.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":["__assign","Object","assign","t","s","i","n","arguments","length","p","prototype","hasOwnProperty","call","apply","this","__spreadArray","to","from","pack","ar","l","Array","slice","concat"],"mappings":"4iBA+BO,MAAIA,EAAW,WAQlB,OAPAA,EAAWC,OAAOC,QAAU,SAAkBC,GAC1C,IAAK,IAAIC,EAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAE5C,IAAK,IAAII,KADTL,EAAIG,UAAUF,GACOJ,OAAOS,UAAUC,eAAeC,KAAKR,EAAGK,KAAIN,EAAEM,GAAKL,EAAEK,IAE9E,OAAON,IAEKU,MAAMC,KAAMP,YA6HzB,SAASQ,EAAcC,EAAIC,EAAMC,GACpC,GAAIA,GAA6B,IAArBX,UAAUC,OAAc,IAAK,IAA4BW,EAAxBd,EAAI,EAAGe,EAAIH,EAAKT,OAAYH,EAAIe,EAAGf,KACxEc,GAAQd,KAAKY,IACRE,IAAIA,EAAKE,MAAMX,UAAUY,MAAMV,KAAKK,EAAM,EAAGZ,IAClDc,EAAGd,GAAKY,EAAKZ,IAGrB,OAAOW,EAAGO,OAAOJ,GAAME,MAAMX,UAAUY,MAAMV,KAAKK"}
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
import type { DecoratedActions, MiddlewareFactory } from './types';
|
|
16
|
+
import { CloneFunction } from './impl';
|
|
17
|
+
export declare function logEffects<S, A extends DecoratedActions, P>(log?: (...msg: any[]) => void): MiddlewareFactory<S, A, P>;
|
|
18
|
+
export declare type Logger = {
|
|
19
|
+
log: (...args: any[]) => void;
|
|
20
|
+
group: (...args: any[]) => void;
|
|
21
|
+
groupCollapsed: (...args: any[]) => void;
|
|
22
|
+
groupEnd: (...args: any[]) => void;
|
|
23
|
+
};
|
|
24
|
+
export declare function logDetailedEffects<S, A extends DecoratedActions, P>(logger?: Logger): MiddlewareFactory<S, A, P>;
|
|
25
|
+
export declare function optimisticActions<S, A extends DecoratedActions, P>(cloneFunc?: CloneFunction): MiddlewareFactory<S, A, P>;
|
|
26
|
+
export declare function devtools<S, A extends DecoratedActions, P>(): MiddlewareFactory<S, A, P>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{isSimpleSyncAction as e,globalConfig as t}from"./impl";var n=function(){return(n=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)},o=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var o,r,i;if(Array.isArray(t)){if((o=t.length)!=n.length)return!1;for(r=o;0!=r--;)if(!e(t[r],n[r]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((o=(i=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(r=o;0!=r--;)if(!Object.prototype.hasOwnProperty.call(n,i[r]))return!1;for(r=o;0!=r--;){var c=i[r];if(!e(t[c],n[c]))return!1}return!0}return t!=t&&n!=n};function r(e){void 0===e&&(e=console.log);return function(){var t=e,n="";return{init:function(e){var o,r;if("development"===process.env.NODE_ENV||"test"===process.env.NODE_ENV){n=(null===(o=e.options)||void 0===o?void 0:o.name)?"[".concat(null===(r=e.options)||void 0===r?void 0:r.name,"]"):"";var i=e.state;t(n,"initialState",i)}},destroy:null,effects:function(e,o,r,i){return"development"!==process.env.NODE_ENV&&"test"!==process.env.NODE_ENV||t(n,e.name,e.type,null===r?"no effect":r,e.isAsync?"preEffects"!==e.type||i?"loading: ".concat(i):"Promise cancelled":""),null}}}}function i(e){return void 0===e&&(e=console),function(){var t="",n=e;if("development"===process.env.NODE_ENV||"test"===process.env.NODE_ENV){var r=function(e,t){var n;if(t!==e){var r=null!=e?typeof e:typeof t;if("number"===r||"string"===r||"boolean"===r)n="".concat(e," => ").concat(""===t?'""':t);else if(e&&e.length||t&&t.length)if(null==e)n="was ".concat(e,", now contains ").concat(t.length," element(s)");else if(null==t)n="contained ".concat(e.length," element(s), now is ").concat(t);else if(0===e.length)n="was empty, now contains ".concat(t.length," elements");else if(0===t.length)n="contained ".concat(e.length," elements, now is empty");else{var i=t.filter((function(t){return!e.find((function(e){return o(t,e)}))})),c=e.filter((function(e){return!t.find((function(t){return o(e,t)}))}));i.length>10&&(i="".concat(i.length," element(s) added")),c.length>10&&(c="".concat(c.length," element(s) removed")),n={added:i,removed:c}}else n=t}return n},i=function(e){return"string"==typeof e?'"'.concat(e,'"'):e};return{init:function(o){var r,c;t=(null===(r=o.options)||void 0===r?void 0:r.name)?"[".concat(null===(c=o.options)||void 0===c?void 0:c.name,"]"):"";var l=o.state;e.group(t,"initialState"),Object.keys(l).forEach((function(e){n.log(e,":",i(l[e]))})),e.groupEnd()},destroy:null,effects:function(e,o,c,l){var s,f=null===(s=e.context)||void 0===s?void 0:s.args,a=[t,e.name.toString()];if(e.isAsync&&("preEffects"===e.type?a.push(l?"START":"CANCELLED"):"effects"===e.type?a.push("DONE"):a.push("FAILED")),null!=c||f&&0!==Object.keys(f).length?n.group.apply(n,a):n.log.apply(n,a),f&&Object.keys(f).length>0&&(n.group("Arguments"),f.forEach((function(e){n.log(e,":",i(e))})),n.groupEnd()),null!=c){if(n.groupCollapsed("Before"),null==o)n.log("was null");else Object.keys(o).forEach((function(e){n.log(e,":",i(o[e]))}));if(n.groupEnd(),n.groupCollapsed("After"),null==c)n.log("was null");else Object.keys(c).forEach((function(e){n.log(e,":",i(c[e]))}));if(n.groupEnd(),null!=c){n.group("Diff");var u=function(e,t){var n={};"development"===process.env.NODE_ENV&&(e&&Object.keys(e).forEach((function(o){if(t.hasOwnProperty(o)){var i=e[o],c=t[o],l=r(i,c);l&&(n[o]=l)}else n[o]="was deleted"})),Object.keys(t).forEach((function(o){if(null==e||!e.hasOwnProperty(o)){var i=t[o];n[o]=r(void 0,i)}})));return n}(o,c);Object.keys(u).forEach((function(e){return n.log(e,":",u[e])})),n.groupEnd()}}return n.groupEnd(),null}}}return{init:function(){},destroy:null,effects:function(){return null}}}}function c(o){return function(){var r=null,i={history:null,optimisticActions:{},shouldRecordHistory:!1},c=function(e){return(o||t.clone)(e)},l=function(e,t){return"".concat(e,"_").concat(t)};function s(e,t,n,o){void 0===o&&(o=null);var r=i.shouldRecordHistory,l=i.history;if(r){null===l&&(i.history=[]);var s=c(n);delete s.state,delete s.s,delete s.abortSignal,s.error=n.err,s.err=n.err;var f={effectType:t,actionName:e,promiseId:n.promiseId,ctx:s,beforeEffectState:o?c(o):null};i.history.push(f)}}function f(e,t,n){void 0===n&&(n=void 0);var o=i.optimisticActions,r=i.history,c=l(e,t);if(delete o[c],0===Object.keys(o).length)i.history=null,i.shouldRecordHistory=!1;else{var s=void 0===n?r.findIndex((function(e){return l(e.actionName,e.promiseId)===c})):n;if(0===s){var f=r.slice(1).findIndex((function(e){return null!=e.beforeEffectState}))+1;r.splice(0,f)}else void 0===n&&(r[s].beforeEffectState=null)}}return{init:function(e){r=e},destroy:function(){r=null,i.history=null,i.optimisticActions={},i.shouldRecordHistory=!1},effects:function(t,o,c,a){var u=t.name,p=t.type,d=t.context,v=t.isAsync;if((null!=c&&e(r.actions[u])||"onPropsChange"===u||null!=r.actions[u][p])&&s(u,p,d,null),v){var y,g=r.actions[u];if(a&&null!=g.optimisticEffects&&"preEffects"===p)return i.shouldRecordHistory=!0,i.optimisticActions[l(u,d.promiseId)]=!0,s(u,"optimisticEffects",d,y=c||o),{loading:!1,state:g.optimisticEffects(n(n({},d),{state:y,s:y}))};if(null!=g.optimisticEffects&&"effects"===p)return f(u,d.promiseId),{loading:a,state:c};if(null!=g.optimisticEffects&&"errorEffects"===p)return{state:y=function(t,o){for(var c=i.history,l=c.findIndex((function(e){return"optimisticEffects"===e.effectType&&e.actionName===t&&e.promiseId===o})),s=c[l].beforeEffectState,a=l+1;a<c.length;a++){var u=c[a];u.beforeEffectState&&(u.beforeEffectState=s);var p=n(n({},u.ctx),{state:s,s:s});s="onPropsChange"===u.actionName?(Array.isArray(r.options.onPropsChange)?r.options.onPropsChange:[r.options.onPropsChange])[p.index].effects(p):e(r.actions[u.actionName])?r.actions[u.actionName](p):r.actions[u.actionName][u.effectType](p)}return f(t,o,l),s}(u,d.promiseId),loading:a}}return null}}}}function l(){return function(){var e,t,o;try{e=window.__REDUX_DEVTOOLS_EXTENSION__||window.top.__REDUX_DEVTOOLS_EXTENSION__}catch(e){}return e?{init:function(n){var r,i;(t=e.connect({name:null!==(i=null===(r=n.options)||void 0===r?void 0:r.name)&&void 0!==i?i:"StateDecorator"})).init(n.state);var c=null,l=n.state;o=t.subscribe((function(e){var t,o,r,i;if("DISPATCH"===e.type&&e.state&&"ROLLBACK"!==(null===(t=e.payload)||void 0===t?void 0:t.type)){var s=JSON.parse(e.state);n.setState(s)}else"COMMIT"===(null===(o=e.payload)||void 0===o?void 0:o.type)?c=n.state:"ROLLBACK"===(null===(r=e.payload)||void 0===r?void 0:r.type)?null!=c&&n.setState(c):"RESET"===(null===(i=e.payload)||void 0===i?void 0:i.type)&&n.setState(l)}))},effects:function(e,o,r){if(null!=r){var i=n({},e.context);delete i.a,delete i.s,delete i.p,delete i.res,delete i.err,delete i.ds,t.send({type:"".concat(e.name," ").concat(e.type),args:i.args,context:i},r)}return null},destroy:function(){o(),t=null}}:{init:function(){},destroy:null,effects:function(){return null}}}}export{l as devtools,i as logDetailedEffects,r as logEffects,c as optimisticActions};
|
|
2
|
+
//# sourceMappingURL=middlewares.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middlewares.js","sources":["../../node_modules/tslib/tslib.es6.js","../../node_modules/fast-deep-equal/index.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","'use strict';\n\n// do not edit .js files directly - edit src/index.jst\n\n\n\nmodule.exports = function equal(a, b) {\n if (a === b) return true;\n\n if (a && b && typeof a == 'object' && typeof b == 'object') {\n if (a.constructor !== b.constructor) return false;\n\n var length, i, keys;\n if (Array.isArray(a)) {\n length = a.length;\n if (length != b.length) return false;\n for (i = length; i-- !== 0;)\n if (!equal(a[i], b[i])) return false;\n return true;\n }\n\n\n\n if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;\n if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();\n if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();\n\n keys = Object.keys(a);\n length = keys.length;\n if (length !== Object.keys(b).length) return false;\n\n for (i = length; i-- !== 0;)\n if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;\n\n for (i = length; i-- !== 0;) {\n var key = keys[i];\n\n if (!equal(a[key], b[key])) return false;\n }\n\n return true;\n }\n\n // true if both NaN, false otherwise\n return a!==a && b!==b;\n};\n"],"names":["__assign","Object","assign","t","s","i","n","arguments","length","p","prototype","hasOwnProperty","call","apply","this","equal","a","b","constructor","keys","Array","isArray","RegExp","source","flags","valueOf","toString","key"],"mappings":"8DA+BO,IAAIA,EAAW,WAQlB,OAPAA,EAAWC,OAAOC,QAAU,SAAkBC,GAC1C,IAAK,IAAIC,EAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAE5C,IAAK,IAAII,KADTL,EAAIG,UAAUF,GACOJ,OAAOS,UAAUC,eAAeC,KAAKR,EAAGK,KAAIN,EAAEM,GAAKL,EAAEK,IAE9E,OAAON,IAEKU,MAAMC,KAAMP,cCjCf,SAASQ,EAAMC,EAAGC,GACjC,GAAID,IAAMC,EAAG,OAAO,EAEpB,GAAID,GAAKC,GAAiB,iBAALD,GAA6B,iBAALC,EAAe,CAC1D,GAAID,EAAEE,cAAgBD,EAAEC,YAAa,OAAO,EAE5C,IAAIV,EAAQH,EAAGc,EACf,GAAIC,MAAMC,QAAQL,GAAI,CAEpB,IADAR,EAASQ,EAAER,SACGS,EAAET,OAAQ,OAAO,EAC/B,IAAKH,EAAIG,EAAgB,GAARH,KACf,IAAKU,EAAMC,EAAEX,GAAIY,EAAEZ,IAAK,OAAO,EACjC,OAAO,EAKT,GAAIW,EAAEE,cAAgBI,OAAQ,OAAON,EAAEO,SAAWN,EAAEM,QAAUP,EAAEQ,QAAUP,EAAEO,MAC5E,GAAIR,EAAES,UAAYxB,OAAOS,UAAUe,QAAS,OAAOT,EAAES,YAAcR,EAAEQ,UACrE,GAAIT,EAAEU,WAAazB,OAAOS,UAAUgB,SAAU,OAAOV,EAAEU,aAAeT,EAAES,WAIxE,IADAlB,GADAW,EAAOlB,OAAOkB,KAAKH,IACLR,UACCP,OAAOkB,KAAKF,GAAGT,OAAQ,OAAO,EAE7C,IAAKH,EAAIG,EAAgB,GAARH,KACf,IAAKJ,OAAOS,UAAUC,eAAeC,KAAKK,EAAGE,EAAKd,IAAK,OAAO,EAEhE,IAAKA,EAAIG,EAAgB,GAARH,KAAY,CAC3B,IAAIsB,EAAMR,EAAKd,GAEf,IAAKU,EAAMC,EAAEW,GAAMV,EAAEU,IAAO,OAAO,EAGrC,OAAO,EAIT,OAAOX,GAAIA,GAAKC,GAAIA"}
|
package/es/shallow.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
export default function shallow<T extends any, U extends any>(objA: T, objB: U): boolean;
|
package/es/test.d.ts
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
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
|
+
import { ErrorMap, StoreActions, StoreApi, StoreOptions } from '.';
|
|
16
|
+
import { DerivedState, SetStateFunc, Ref } from './impl';
|
|
17
|
+
import { DecoratedActions } from './types';
|
|
18
|
+
declare type MockActions<A, MockAction> = {
|
|
19
|
+
[k in keyof A]: MockAction;
|
|
20
|
+
};
|
|
21
|
+
declare type MockResult<S, A extends DecoratedActions, P, DS> = {
|
|
22
|
+
readonly prevState: S & DS;
|
|
23
|
+
readonly state: S & DS;
|
|
24
|
+
readonly props: P;
|
|
25
|
+
readonly actions: MockActions<A, any>;
|
|
26
|
+
readonly errorMap: ErrorMap<A>;
|
|
27
|
+
};
|
|
28
|
+
declare type MockActionImpl<A> = Partial<Record<keyof A, (...args: any[]) => any>>;
|
|
29
|
+
declare type MockResultWithTest<S, A extends DecoratedActions, P, DS> = MockResult<S, A, P, DS> & {
|
|
30
|
+
/**
|
|
31
|
+
* Execute function passed as parameter to test state/props/actions called.
|
|
32
|
+
*/
|
|
33
|
+
test: (f: (res: MockResult<S, A, P, DS>) => void) => void;
|
|
34
|
+
};
|
|
35
|
+
declare type MockStoreAction<S, A extends DecoratedActions, F extends (...args: any[]) => any, P, DS> = {
|
|
36
|
+
/**
|
|
37
|
+
* Creates a new store action with specified state.
|
|
38
|
+
*/
|
|
39
|
+
setState: (state: S) => MockStoreAction<S, A, F, P, DS>;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a new store action with specified props.
|
|
42
|
+
*/
|
|
43
|
+
setProps: (props: P) => MockStoreAction<S, A, F, P, DS>;
|
|
44
|
+
/**
|
|
45
|
+
* Creates a new store action using store state overriden by specified state.
|
|
46
|
+
*/
|
|
47
|
+
setPartialState: (state: Partial<S>) => MockStoreAction<S, A, F, P, DS>;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a new store action using store props overriden by specified props.
|
|
50
|
+
*/
|
|
51
|
+
setPartialProps: (props: Partial<P>) => MockStoreAction<S, A, F, P, DS>;
|
|
52
|
+
/**
|
|
53
|
+
* Set implementations to some actions to test side effects.
|
|
54
|
+
*/
|
|
55
|
+
setMockActions: (implementation: MockActionImpl<A>) => MockStoreAction<S, A, F, P, DS>;
|
|
56
|
+
/**
|
|
57
|
+
* If action is asynchronous, mock the getPromise call to be resolved with specified object.
|
|
58
|
+
*/
|
|
59
|
+
promiseResolves: (res: any) => MockStoreAction<S, A, F, P, DS>;
|
|
60
|
+
/**
|
|
61
|
+
* If action is asynchronous, mock the getPromise call to be rejected with specified error.
|
|
62
|
+
*/
|
|
63
|
+
promiseRejects: (err: Error) => MockStoreAction<S, A, F, P, DS>;
|
|
64
|
+
/**
|
|
65
|
+
* Executes passed function to test state and/or props
|
|
66
|
+
*/
|
|
67
|
+
test: (f: (state: S & DS, props: P) => void) => MockStoreAction<S, A, F, P, DS>;
|
|
68
|
+
/**
|
|
69
|
+
* Calls the action with specified parameters.
|
|
70
|
+
* @returns a promise with state/props/actions to assert
|
|
71
|
+
*/
|
|
72
|
+
call: (...args: Parameters<F>) => Promise<MockResult<S, A, P, DS>>;
|
|
73
|
+
};
|
|
74
|
+
declare type MockStore<S, A extends DecoratedActions, P, DS> = {
|
|
75
|
+
/**
|
|
76
|
+
* Creates a new store with specified state.
|
|
77
|
+
*/
|
|
78
|
+
setState: (state: S) => MockStore<S, A, P, DS>;
|
|
79
|
+
/**
|
|
80
|
+
* Creates a new store with specified props.
|
|
81
|
+
*/
|
|
82
|
+
setProps: (props: P) => MockStore<S, A, P, DS>;
|
|
83
|
+
/**
|
|
84
|
+
* Creates a new store using store state overriden by specified state.
|
|
85
|
+
*/
|
|
86
|
+
setPartialState: (state: Partial<S>) => MockStore<S, A, P, DS>;
|
|
87
|
+
/**
|
|
88
|
+
* Creates a new store using store props overriden by specified props.
|
|
89
|
+
*/
|
|
90
|
+
setPartialProps: (props: Partial<P>) => MockStore<S, A, P, DS>;
|
|
91
|
+
/**
|
|
92
|
+
* Set implementations to some actions to test side effects.
|
|
93
|
+
*/
|
|
94
|
+
setMockActions: (implementation: MockActionImpl<A>) => MockStore<S, A, P, DS>;
|
|
95
|
+
/**
|
|
96
|
+
* Executes passed function to test state and/or props
|
|
97
|
+
*/
|
|
98
|
+
test: (f: (state: S & DS, props: P) => void) => MockStore<S, A, P, DS>;
|
|
99
|
+
/**
|
|
100
|
+
* Test options.onMount
|
|
101
|
+
* @deprecated Use init() instead
|
|
102
|
+
*/
|
|
103
|
+
onMount: (props: Partial<P>) => MockResultWithTest<S, A, P, DS>;
|
|
104
|
+
/**
|
|
105
|
+
* Test state and side effect actions after inbound props have changed.
|
|
106
|
+
*/
|
|
107
|
+
onPropsChange: (props: Partial<P>, init?: boolean) => MockResultWithTest<S, A, P, DS>;
|
|
108
|
+
/**
|
|
109
|
+
* Test store at initialization time:
|
|
110
|
+
* - options.onPropsChange with onMount set to true
|
|
111
|
+
* - options.onMount
|
|
112
|
+
*/
|
|
113
|
+
onInit: (props?: Partial<P>) => MockResultWithTest<S, A, P, DS>;
|
|
114
|
+
/** @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
|
+
getAction: <K extends keyof A>(name: K) => MockStoreAction<S, A, A[K], P, DS>;
|
|
117
|
+
};
|
|
118
|
+
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
|
+
/**
|
|
121
|
+
* Set the mock factory. Each mock action will be created using this factory.
|
|
122
|
+
* @param factory the mock factory
|
|
123
|
+
*/
|
|
124
|
+
export declare function setMockFactory(factory: (impl?: (...args: any[]) => any) => any): void;
|
|
125
|
+
export declare class ActionError<S = any, P = any, A = any> extends Error {
|
|
126
|
+
sourceError: Error;
|
|
127
|
+
prevState: S;
|
|
128
|
+
state: S;
|
|
129
|
+
props: P;
|
|
130
|
+
actions: MockActions<A, any>;
|
|
131
|
+
constructor(sourceError: Error, prevState: S, state: S, props: P, actions: MockActions<A, any>);
|
|
132
|
+
}
|
|
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>;
|
|
134
|
+
export {};
|
package/es/test.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createRef as t,computeDerivedValues as r,onPropChange as n,buildOnMountInvocationContext as e,isSimpleSyncAction as o,decorateSimpleSyncAction as i,isSyncAction as u,decorateSyncAction as c,isAsyncAction as s,computeAsyncActionInput as a,decorateAsyncAction as l,buildErrorMap as f}from"./impl";var p=function(t,r){return(p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])})(t,r)};var v=function(){return(v=Object.assign||function(t){for(var r,n=1,e=arguments.length;n<e;n++)for(var o in r=arguments[n])Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o]);return t}).apply(this,arguments)};function d(t,r){void 0===r&&(r={});var n=t.getConfig();return m(n.getInitialState,n.actions,r,n.options)}function m(o,i,u,c,s){void 0===u&&(u={}),void 0===c&&(c={});var a=t(),l=t(u);function f(t,r,n){return m(null!=t?t:a.current,i,null!=r?r:l.current,c,null!=n?n:s)}function p(n,e){void 0===n&&(n=void 0),void 0===e&&(e=void 0);var o=t({state:null,deps:{}});return r(n||a,e||l,o,c),v(v({},(null==n?void 0:n.current)||a.current),o.current.state||{})}return a.current="function"==typeof o?o(u):o,{test:function(t){return t(p(),l.current),this},setMockActions:function(t){return f(void 0,void 0,t)},onMount:function(t){return void 0===t&&(t={}),this.onInit(t)},setState:function(t){return f(t,void 0)},setProps:function(t){return f(void 0,t)},setPartialState:function(t){return f(v(v({},a.current),t),void 0)},setPartialProps:function(t){return f(void 0,v(v({},l.current),t))},onPropsChange:function(r,n){void 0===n&&(n=!1);var e=t(a.current),o=t(v(v({},l.current),r)),u=t({state:null,deps:{}}),c=P(i,s),f=this.onPropsChangeImpl(e,o,u,c,(function(t,r,n,o,i){null!=t&&(e.current=t)}),n);return v(v({},f),{test:function(t){t(f)}})},onPropsChangeImpl:function(t,e,o,i,u,s){return r(a,l,o,c),n(t,o,e,l.current,i,c,u,s),{prevState:p(a,l),state:p(t,e),props:e.current,actions:i.current,errorMap:{}}},onInit:function(r){void 0===r&&(r={});var n="function"==typeof o?o(u):o,a=t(n),f=t(v(v({},l.current),r)),d=t({state:null,deps:{}}),m=P(i,s);this.onPropsChangeImpl(a,f,d,m,(function(t,r,n,e,o){null!=t&&(a.current=t)}),!0),(null==c?void 0:c.onMount)&&c.onMount(e(a,d,f,m));var h={prevState:null,state:p(a,f),props:f.current,actions:m.current,errorMap:{}};return v(v({},h),{test:function(t){t(h)}})},getAction:function(t){return S(a.current,t,i,l.current,null,c,void 0)}}}function P(r,n){var e=Object.keys(r);return t(e.reduce((function(t,r){return t[r]=h(null==n?void 0:n[r]),t}),{}))}var h=function(t){return jest.fn(t)};function y(t){h=t}var g=function(t){function r(n,e,o,i,u){var c=t.call(this,n.message)||this;return Object.setPrototypeOf(c,r.prototype),c.sourceError=n,c.prevState=e,c.props=i,c.state=o,c.actions=u,Error.captureStackTrace&&Error.captureStackTrace(c,r),c}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}p(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}(r,t),r}(Error);function S(n,e,p,d,m,h,y){var j=t(n),O=t(d),R=m;function M(t,r,n,o){return void 0===o&&(o=y),S(null!=t?t:j.current,e,p,null!=r?r:O.current,null!=n?n:R,h,o)}function b(n,e){void 0===n&&(n=void 0),void 0===e&&(e=void 0);var o=t({state:null,deps:{}});return r(null!=n?n:j,null!=e?e:O,o,h),v(v({},(null==n?void 0:n.current)||j.current),o.current.state||{})}return{setMockActions:function(t){return M(void 0,void 0,void 0,t)},setState:function(t){return M(t,void 0,void 0)},setProps:function(t){return M(void 0,t,void 0)},setPartialState:function(t){return M(v(v({},j.current),t),void 0,void 0)},setPartialProps:function(t){return M(void 0,v(v({},O.current),t),void 0)},promiseResolves:function(t){return M(void 0,void 0,Promise.resolve(t))},promiseRejects:function(t){return M(void 0,void 0,Promise.reject(t))},test:function(t){return t(b(),O.current),this},call:function(){for(var n=[],d=0;d<arguments.length;d++)n[d]=arguments[d];var m=t(v({},j.current)),S=t({state:null,deps:{}});r(m,O,S,h);var M=P(p,y),E=t({}),_=t({}),w=function(t){null!=t&&(m.current=t)},C=p[e],I=null;if(o(C))i(e,C,m,S,O,t(!0),w).apply(void 0,n),I=Promise.resolve();else if(u(C))c(e,v(v({},C),{debounceSideEffectsTimeout:0,debounceTimeout:0}),m,S,O,M,t(!0),null,h,w).apply(void 0,n),I=Promise.resolve();else if(s(C)){var k=t({}),A=t({}),T=t(!0),x=v({},a(C));R&&(x.getPromise=function(){return R}),x.optimisticEffects&&(x.effects=x.optimisticEffects,delete x.optimisticEffects),I=l({actionName:e,derivedStateRef:S,propsRef:O,loadingMapRef:E,errorMapRef:_,promisesRef:k,conflictActionsRef:A,initializedRef:T,options:h,setState:w,stateRef:m,actionsRef:M,action:x}).apply(void 0,n)}return(null!=I?I:Promise.resolve()).then((function(){return E.current={},{prevState:b(j),state:b(m),props:O.current,errorMap:f(_.current),actions:M.current}})).catch((function(t){return Promise.reject(new g(t,b(j),b(m),O.current,M.current))}))}}}export{g as ActionError,d as createMockFromStore,m as createMockStore,S as createMockStoreAction,y as setMockFactory};
|
|
2
|
+
//# sourceMappingURL=test.js.map
|
package/es/test.js.map
ADDED
|
@@ -0,0 +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":"8SAgBA,IAAIA,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,yoEAhBzB,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"}
|