state-decorator 7.0.0-rc4 → 7.0.0-rc6

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 (3) hide show
  1. package/es/test.js +1 -1
  2. package/package.json +1 -1
  3. package/test.js +1 -1
package/es/test.js CHANGED
@@ -1,2 +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])},p(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},v.apply(this,arguments)};function d(t,r){return void 0===r&&(r={}),P(t.getConfig(),r)}function P(t,r){void 0===r&&(r={});var n=t.actions,e=function(t,r){var n={};for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&r.indexOf(e)<0&&(n[e]=t[e]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(e=Object.getOwnPropertySymbols(t);o<e.length;o++)r.indexOf(e[o])<0&&Object.prototype.propertyIsEnumerable.call(t,e[o])&&(n[e[o]]=t[e[o]])}return n}(t,["actions"]);return m(t.getInitialState||function(){return t.initialState},n,r,e)}function m(o,i,u,c,s){void 0===u&&(u={}),void 0===c&&(c={});var a=t(o(u)),l=t(u);function f(t,r,n){return m((function(){return 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{getInitialState: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=y(i,s),f=this.onPropsChangeImpl(e,o,u,c,(function(t,r,n,o,i){null!=t&&(e.current=t)}),n,!1);return v(v({},f),{test:function(t){t(f)}})},onPropsChangeImpl:function(t,e,i,u,s,f,v){return r(a,l,i,c),n(t,i,e,l.current,u,c,o,s,f,v),{prevState:p(a,l),state:p(t,e),props:e.current,actions:u.current,errorMap:{}}},onInit:function(r){void 0===r&&(r={});var n=o(u),a=t(n),f=t(v(v({},l.current),r)),d=t({state:null,deps:{}}),P=y(i,s),m=function(t,r,n,e,o){null!=t&&(a.current=t)};this.onPropsChangeImpl(a,f,d,P,m,!0,!1),(null==c?void 0:c.onMount)&&c.onMount(e(a,d,f,P)),this.onPropsChangeImpl(a,f,d,P,m,!0,!0),(null==c?void 0:c.onMountDeferred)&&c.onMountDeferred(e(a,d,f,P));var h={prevState:null,state:p(a,f),props:f.current,actions:P.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 y(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 g(t){h=t}var O=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,P,m,h){var g=t(n),b=t(d),j=P;function M(t,r,n,o){return void 0===o&&(o=h),S(null!=t?t:g.current,e,p,null!=r?r:b.current,null!=n?n:j,m,o)}function E(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:g,null!=e?e:b,o,m),v(v({},(null==n?void 0:n.current)||g.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({},g.current),t),void 0,void 0)},setPartialProps:function(t){return M(void 0,v(v({},b.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(E(),b.current),this},call:function(){for(var n=[],d=0;d<arguments.length;d++)n[d]=arguments[d];var P=t(v({},g.current)),S=t({state:null,deps:{}});r(P,b,S,m);var M=y(p,h),R=t({}),w=t({}),I=function(t){null!=t&&(P.current=t)},_=p[e],C=null;if(o(_))i(e,_,P,S,b,t(!0),m,I).apply(void 0,n),C=Promise.resolve();else if(u(_))c(e,v(v({},_),{debounceSideEffectsTimeout:0,debounceTimeout:0}),P,S,b,M,t(!0),null,m,I,(function(t){})).apply(void 0,n),C=Promise.resolve();else if(s(_)){var k=t({}),A=t({}),T=t(!0),x=v({},a(_));j&&(x.getPromise=function(){return j}),x.optimisticEffects&&(x.effects=x.optimisticEffects,delete x.optimisticEffects),C=l({actionName:e,derivedStateRef:S,propsRef:b,loadingParallelMapRef:R,errorMapRef:w,promisesRef:k,conflictActionsRef:A,initializedRef:T,options:m,setState:I,stateRef:P,actionsRef:M,action:x,clearError:function(t){}}).apply(void 0,n)}return(null!=C?C:Promise.resolve()).then((function(){return R.current={},{prevState:E(g),state:E(P),props:b.current,errorMap:f(w.current),actions:M.current}})).catch((function(t){return Promise.reject(new O(t,E(g),E(P),b.current,M.current))}))}}}export{O as ActionError,d as createMockFromStore,P as createMockStore,S as createMockStoreAction,m as createMockStoreV6,g as setMockFactory};
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])},p(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},v.apply(this,arguments)};function d(t,r){return void 0===r&&(r={}),m(t.getConfig(),r)}function m(t,r){void 0===r&&(r={});var n=t.actions,e=function(t,r){var n={};for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&r.indexOf(e)<0&&(n[e]=t[e]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(e=Object.getOwnPropertySymbols(t);o<e.length;o++)r.indexOf(e[o])<0&&Object.prototype.propertyIsEnumerable.call(t,e[o])&&(n[e[o]]=t[e[o]])}return n}(t,["actions"]);return P(t.getInitialState||function(){return t.initialState},n,r,e)}function P(o,i,u,c,s){void 0===u&&(u={}),void 0===c&&(c={});var a=t(o(u)),l=t(u);function f(t,r,n){return P((function(){return 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{getInitialState: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=y(i,s),f=this.onPropsChangeImpl(e,o,u,c,(function(t,r,n,o,i){null!=t&&(e.current=t)}),n,!1);return v(v({},f),{test:function(t){t(f)}})},onPropsChangeImpl:function(t,e,i,u,s,f,v){return r(a,l,i,c),n(t,i,e,l.current,u,c,o,s,f,v),{prevState:p(a,l),state:p(t,e),props:e.current,actions:u.current,errorMap:{}}},onInit:function(r){void 0===r&&(r={});var n=o(u),a=t(n),f=t(v(v({},l.current),r)),d=t({state:null,deps:{}}),m=y(i,s),P=function(t,r,n,e,o){null!=t&&(a.current=t)};this.onPropsChangeImpl(a,f,d,m,P,!0,!1),(null==c?void 0:c.onMount)&&c.onMount(e(a,d,f,m)),this.onPropsChangeImpl(a,f,d,m,P,!0,!0),(null==c?void 0:c.onMountDeferred)&&c.onMountDeferred(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 y(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 g(t){h=t}var O=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,P,h){var g=t(n),b=t(d),j=m;function E(t,r,n,o){return void 0===o&&(o=h),S(null!=t?t:g.current,e,p,null!=r?r:b.current,null!=n?n:j,P,o)}function M(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:g,null!=e?e:b,o,P),v(v({},(null==n?void 0:n.current)||g.current),o.current.state||{})}return{setMockActions:function(t){return E(void 0,void 0,void 0,t)},setState:function(t){return E(t,void 0,void 0)},setProps:function(t){return E(void 0,t,void 0)},setPartialState:function(t){return E(v(v({},g.current),t),void 0,void 0)},setPartialProps:function(t){return E(void 0,v(v({},b.current),t),void 0)},promiseResolves:function(t){return E(void 0,void 0,Promise.resolve(t))},promiseRejects:function(t){return E(void 0,void 0,Promise.reject(t))},test:function(t){return t(M(),b.current),this},call:function(){for(var n=[],d=0;d<arguments.length;d++)n[d]=arguments[d];var m=t(v({},g.current)),S=t({state:null,deps:{}});r(m,b,S,P);var E=y(p,h),R=t({}),w=t({}),I=function(t){null!=t&&(m.current=t)},_=p[e],C=null;if(o(_))i(e,_,m,S,b,t(!0),P,I).apply(void 0,n),C=Promise.resolve();else if(u(_))c(e,v(v({},_),{debounceSideEffectsTimeout:0,debounceTimeout:0}),m,S,b,E,t(!0),null,P,I,(function(t){})).apply(void 0,n),C=Promise.resolve();else if(s(_)){var k=t({}),A=t({}),T=t(!0),x=v({},a(_));if(j&&(x.getPromise=function(){return j}),x.optimisticEffects){if(x.effects){var D=x.optimisticEffects,z=x.effects;x.effects=function(t){var r=D(t);return r=v(v({},t.state),r),v(v({},r),z(v(v({},t),{state:r,s:r})))}}else x.effects=x.optimisticEffects;delete x.optimisticEffects}C=l({actionName:e,derivedStateRef:S,propsRef:b,loadingParallelMapRef:R,errorMapRef:w,promisesRef:k,conflictActionsRef:A,initializedRef:T,options:P,setState:I,stateRef:m,actionsRef:E,action:x,clearError:function(t){}}).apply(void 0,n)}return(null!=C?C:Promise.resolve()).then((function(){return R.current={},{prevState:M(g),state:M(m),props:b.current,errorMap:f(w.current),actions:E.current}})).catch((function(t){return Promise.reject(new O(t,M(g),M(m),b.current,E.current))}))}}}export{O as ActionError,d as createMockFromStore,m as createMockStore,S as createMockStoreAction,P as createMockStoreV6,g as setMockFactory};
2
2
  //# sourceMappingURL=test.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "state-decorator",
3
- "version": "7.0.0-rc4",
3
+ "version": "7.0.0-rc6",
4
4
  "description": "React state management library",
5
5
  "main": "index.js",
6
6
  "module": "es/index.js",
package/test.js CHANGED
@@ -1,2 +1,2 @@
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])},e(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},r.apply(this,arguments)};function n(t,e){void 0===e&&(e={});var r=t.actions,n=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}(t,["actions"]);return o(t.getInitialState||function(){return t.initialState},r,e,n)}function o(e,n,i,u,s){void 0===i&&(i={}),void 0===u&&(u={});var l=t.createRef(e(i)),f=t.createRef(i);function p(t,e,r){return o((function(){return null!=t?t:l.current}),n,null!=e?e:f.current,u,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||l,n||f,o,u),r(r({},(null==e?void 0:e.current)||l.current),o.current.state||{})}return{getInitialState:e,test:function(t){return t(v(),f.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({},l.current),t),void 0)},setPartialProps:function(t){return p(void 0,r(r({},f.current),t))},onPropsChange:function(e,o){void 0===o&&(o=!1);var i=t.createRef(l.current),u=t.createRef(r(r({},f.current),e)),a=t.createRef({state:null,deps:{}}),p=c(n,s),v=this.onPropsChangeImpl(i,u,a,p,(function(t,e,r,n,o){null!=t&&(i.current=t)}),o,!1);return r(r({},v),{test:function(t){t(v)}})},onPropsChangeImpl:function(r,n,o,c,i,a,s){return t.computeDerivedValues(l,f,o,u),t.onPropChange(r,o,n,f.current,c,u,e,i,a,s),{prevState:v(l,f),state:v(r,n),props:n.current,actions:c.current,errorMap:{}}},onInit:function(o){void 0===o&&(o={});var a=e(i),l=t.createRef(a),p=t.createRef(r(r({},f.current),o)),d=t.createRef({state:null,deps:{}}),y=c(n,s),m=function(t,e,r,n,o){null!=t&&(l.current=t)};this.onPropsChangeImpl(l,p,d,y,m,!0,!1),(null==u?void 0:u.onMount)&&u.onMount(t.buildOnMountInvocationContext(l,d,p,y)),this.onPropsChangeImpl(l,p,d,y,m,!0,!0),(null==u?void 0:u.onMountDeferred)&&u.onMountDeferred(t.buildOnMountInvocationContext(l,d,p,y));var R={prevState:null,state:v(l,p),props:p.current,actions:y.current,errorMap:{}};return r(r({},R),{test:function(t){t(R)}})},getAction:function(t){return a(l.current,t,n,f.current,null,u,void 0)}}}function c(e,r){var n=Object.keys(e);return t.createRef(n.reduce((function(t,e){return t[e]=i(null==r?void 0:r[e]),t}),{}))}var i=function(t){return jest.fn(t)};var u=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 a(e,n,o,i,s,l,f){var p=t.createRef(e),v=t.createRef(i),d=s;function y(t,e,r,c){return void 0===c&&(c=f),a(null!=t?t:p.current,n,o,null!=e?e:v.current,null!=r?r:d,l,c)}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,l),r(r({},(null==e?void 0:e.current)||p.current),o.current.state||{})}return{setMockActions:function(t){return y(void 0,void 0,void 0,t)},setState:function(t){return y(t,void 0,void 0)},setProps:function(t){return y(void 0,t,void 0)},setPartialState:function(t){return y(r(r({},p.current),t),void 0,void 0)},setPartialProps:function(t){return y(void 0,r(r({},v.current),t),void 0)},promiseResolves:function(t){return y(void 0,void 0,Promise.resolve(t))},promiseRejects:function(t){return y(void 0,void 0,Promise.reject(t))},test:function(t){return t(m(),v.current),this},call:function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var a=t.createRef(r({},p.current)),s=t.createRef({state:null,deps:{}});t.computeDerivedValues(a,v,s,l);var y=c(o,f),R=t.createRef({}),P=t.createRef({}),S=function(t){null!=t&&(a.current=t)},h=o[n],O=null;if(t.isSimpleSyncAction(h))t.decorateSimpleSyncAction(n,h,a,s,v,t.createRef(!0),l,S).apply(void 0,e),O=Promise.resolve();else if(t.isSyncAction(h))t.decorateSyncAction(n,r(r({},h),{debounceSideEffectsTimeout:0,debounceTimeout:0}),a,s,v,y,t.createRef(!0),null,l,S,(function(t){})).apply(void 0,e),O=Promise.resolve();else if(t.isAsyncAction(h)){var g=t.createRef({}),M=t.createRef({}),b=t.createRef(!0),A=r({},t.computeAsyncActionInput(h));d&&(A.getPromise=function(){return d}),A.optimisticEffects&&(A.effects=A.optimisticEffects,delete A.optimisticEffects),O=t.decorateAsyncAction({actionName:n,derivedStateRef:s,propsRef:v,loadingParallelMapRef:R,errorMapRef:P,promisesRef:g,conflictActionsRef:M,initializedRef:b,options:l,setState:S,stateRef:a,actionsRef:y,action:A,clearError:function(t){}}).apply(void 0,e)}return(null!=O?O:Promise.resolve()).then((function(){return R.current={},{prevState:m(p),state:m(a),props:v.current,errorMap:t.buildErrorMap(P.current),actions:y.current}})).catch((function(t){return Promise.reject(new u(t,m(p),m(a),v.current,y.current))}))}}}exports.ActionError=u,exports.createMockFromStore=function(t,e){return void 0===e&&(e={}),n(t.getConfig(),e)},exports.createMockStore=n,exports.createMockStoreAction=a,exports.createMockStoreV6=o,exports.setMockFactory=function(t){i=t};
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])},e(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},r.apply(this,arguments)};function n(t,e){void 0===e&&(e={});var r=t.actions,n=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}(t,["actions"]);return o(t.getInitialState||function(){return t.initialState},r,e,n)}function o(e,n,i,u,s){void 0===i&&(i={}),void 0===u&&(u={});var f=t.createRef(e(i)),l=t.createRef(i);function p(t,e,r){return o((function(){return null!=t?t:f.current}),n,null!=e?e:l.current,u,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,u),r(r({},(null==e?void 0:e.current)||f.current),o.current.state||{})}return{getInitialState: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,o){void 0===o&&(o=!1);var i=t.createRef(f.current),u=t.createRef(r(r({},l.current),e)),a=t.createRef({state:null,deps:{}}),p=c(n,s),v=this.onPropsChangeImpl(i,u,a,p,(function(t,e,r,n,o){null!=t&&(i.current=t)}),o,!1);return r(r({},v),{test:function(t){t(v)}})},onPropsChangeImpl:function(r,n,o,c,i,a,s){return t.computeDerivedValues(f,l,o,u),t.onPropChange(r,o,n,l.current,c,u,e,i,a,s),{prevState:v(f,l),state:v(r,n),props:n.current,actions:c.current,errorMap:{}}},onInit:function(o){void 0===o&&(o={});var a=e(i),f=t.createRef(a),p=t.createRef(r(r({},l.current),o)),d=t.createRef({state:null,deps:{}}),y=c(n,s),m=function(t,e,r,n,o){null!=t&&(f.current=t)};this.onPropsChangeImpl(f,p,d,y,m,!0,!1),(null==u?void 0:u.onMount)&&u.onMount(t.buildOnMountInvocationContext(f,d,p,y)),this.onPropsChangeImpl(f,p,d,y,m,!0,!0),(null==u?void 0:u.onMountDeferred)&&u.onMountDeferred(t.buildOnMountInvocationContext(f,d,p,y));var R={prevState:null,state:v(f,p),props:p.current,actions:y.current,errorMap:{}};return r(r({},R),{test:function(t){t(R)}})},getAction:function(t){return a(f.current,t,n,l.current,null,u,void 0)}}}function c(e,r){var n=Object.keys(e);return t.createRef(n.reduce((function(t,e){return t[e]=i(null==r?void 0:r[e]),t}),{}))}var i=function(t){return jest.fn(t)};var u=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 a(e,n,o,i,s,f,l){var p=t.createRef(e),v=t.createRef(i),d=s;function y(t,e,r,c){return void 0===c&&(c=l),a(null!=t?t:p.current,n,o,null!=e?e:v.current,null!=r?r:d,f,c)}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 y(void 0,void 0,void 0,t)},setState:function(t){return y(t,void 0,void 0)},setProps:function(t){return y(void 0,t,void 0)},setPartialState:function(t){return y(r(r({},p.current),t),void 0,void 0)},setPartialProps:function(t){return y(void 0,r(r({},v.current),t),void 0)},promiseResolves:function(t){return y(void 0,void 0,Promise.resolve(t))},promiseRejects:function(t){return y(void 0,void 0,Promise.reject(t))},test:function(t){return t(m(),v.current),this},call:function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var a=t.createRef(r({},p.current)),s=t.createRef({state:null,deps:{}});t.computeDerivedValues(a,v,s,f);var y=c(o,l),R=t.createRef({}),P=t.createRef({}),S=function(t){null!=t&&(a.current=t)},h=o[n],O=null;if(t.isSimpleSyncAction(h))t.decorateSimpleSyncAction(n,h,a,s,v,t.createRef(!0),f,S).apply(void 0,e),O=Promise.resolve();else if(t.isSyncAction(h))t.decorateSyncAction(n,r(r({},h),{debounceSideEffectsTimeout:0,debounceTimeout:0}),a,s,v,y,t.createRef(!0),null,f,S,(function(t){})).apply(void 0,e),O=Promise.resolve();else if(t.isAsyncAction(h)){var g=t.createRef({}),M=t.createRef({}),b=t.createRef(!0),A=r({},t.computeAsyncActionInput(h));if(d&&(A.getPromise=function(){return d}),A.optimisticEffects){if(A.effects){var j=A.optimisticEffects,E=A.effects;A.effects=function(t){var e=j(t);return e=r(r({},t.state),e),r(r({},e),E(r(r({},t),{state:e,s:e})))}}else A.effects=A.optimisticEffects;delete A.optimisticEffects}O=t.decorateAsyncAction({actionName:n,derivedStateRef:s,propsRef:v,loadingParallelMapRef:R,errorMapRef:P,promisesRef:g,conflictActionsRef:M,initializedRef:b,options:f,setState:S,stateRef:a,actionsRef:y,action:A,clearError:function(t){}}).apply(void 0,e)}return(null!=O?O:Promise.resolve()).then((function(){return R.current={},{prevState:m(p),state:m(a),props:v.current,errorMap:t.buildErrorMap(P.current),actions:y.current}})).catch((function(t){return Promise.reject(new u(t,m(p),m(a),v.current,y.current))}))}}}exports.ActionError=u,exports.createMockFromStore=function(t,e){return void 0===e&&(e={}),n(t.getConfig(),e)},exports.createMockStore=n,exports.createMockStoreAction=a,exports.createMockStoreV6=o,exports.setMockFactory=function(t){i=t};
2
2
  //# sourceMappingURL=test.js.map