redux-starter-kit
Advanced tools
Comparing version 0.9.1 to 1.0.0
@@ -139,4 +139,5 @@ import { Middleware, Reducer, ReducersMapObject, Action, AnyAction, StoreEnhancer, Store, DeepPartial } from "redux"; | ||
* @template M The type of the action's meta (optional) | ||
* @template E The type of the action's error (optional) | ||
*/ | ||
declare type PayloadAction<P = void, T extends string = string, M = void> = WithOptionalMeta<M, WithPayload<P, Action<T>>>; | ||
declare type PayloadAction<P = void, T extends string = string, M = void, E = void> = WithOptional<M, E, WithPayload<P, Action<T>>>; | ||
declare type PrepareAction<P> = ((...args: any[]) => { | ||
@@ -147,4 +148,8 @@ payload: P; | ||
meta: any; | ||
}) | ((...args: any[]) => { | ||
payload: P; | ||
meta: any; | ||
error: any; | ||
}); | ||
declare type ActionCreatorWithPreparedPayload<PA extends PrepareAction<any> | void, T extends string = string> = WithTypeProperty<T, PA extends PrepareAction<infer P> ? (...args: Parameters<PA>) => PayloadAction<P, T, MetaOrVoid<PA>> : void>; | ||
declare type ActionCreatorWithPreparedPayload<PA extends PrepareAction<any> | void, T extends string = string> = WithTypeProperty<T, PA extends PrepareAction<infer P> ? (...args: Parameters<PA>) => PayloadAction<P, T, MetaOrVoid<PA>, ErrorOrVoid<PA>> : void>; | ||
declare type ActionCreatorWithOptionalPayload<P, T extends string = string> = WithTypeProperty<T, { | ||
@@ -186,4 +191,6 @@ (payload?: undefined): PayloadAction<undefined, T>; | ||
}; | ||
declare type WithOptionalMeta<M, T> = T & ([M] extends [void] ? {} : { | ||
declare type WithOptional<M, E, T> = T & ([M] extends [void] ? {} : { | ||
meta: M; | ||
}) & ([E] extends [void] ? {} : { | ||
error: E; | ||
}); | ||
@@ -197,2 +204,5 @@ declare type WithTypeProperty<T, MergeIn> = { | ||
} ? M : void; | ||
declare type ErrorOrVoid<PA extends PrepareAction<any>> = ReturnType<PA> extends { | ||
error: infer E; | ||
} ? E : void; | ||
declare type IfMaybeUndefined<P, True, False> = [undefined] extends [P] ? True : False; | ||
@@ -199,0 +209,0 @@ declare type IfVoid<P, True, False> = [void] extends [P] ? True : False; |
@@ -302,10 +302,10 @@ 'use strict'; | ||
return 'meta' in prepared ? { | ||
return _extends({ | ||
type: type, | ||
payload: prepared.payload, | ||
payload: prepared.payload | ||
}, 'meta' in prepared && { | ||
meta: prepared.meta | ||
} : { | ||
type: type, | ||
payload: prepared.payload | ||
}; | ||
}, {}, 'error' in prepared && { | ||
error: prepared.error | ||
}); | ||
} | ||
@@ -312,0 +312,0 @@ |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=require("redux"),r=e(require("immer")),o=require("reselect"),n=require("redux-devtools-extension"),a=e(require("redux-thunk"));function i(){return(i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e}).apply(this,arguments)}function u(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function c(e){return null==e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||Array.isArray(e)||u(e)}var s=["A non-serializable value was detected in the state, in the path: `%s`. Value: %o","Take a look at the reducer(s) handling this action type: %s.","(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)"].join("\n"),l=["A non-serializable value was detected in an action, in the path: `%s`. Value: %o","Take a look at the logic that dispatched this action: %o.","(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)"].join("\n");function d(e,t,r,o){var n;if(void 0===t&&(t=[]),void 0===r&&(r=c),!r(e))return{keyPath:t.join(".")||"<root>",value:e};if("object"!=typeof e||null===e)return!1;var a=null!=o?o(e):Object.entries(e),i=Array.isArray(a),u=0;for(a=i?a:a[Symbol.iterator]();;){var s;if(i){if(u>=a.length)break;s=a[u++]}else{if((u=a.next()).done)break;s=u.value}var l=s[1],p=t.concat(s[0]);if(!r(l))return{keyPath:p.join("."),value:l};if("object"==typeof l&&(n=d(l,p,r,o)))return n}return!1}function p(e){void 0===e&&(e={});var t=e.thunk,r=void 0===t||t,o=[];return r&&o.push("boolean"==typeof r?a:a.withExtraArgument(r.extraArgument)),o}function f(e,t){function r(){if(t){var r=t.apply(void 0,arguments);if(!r)throw new Error("prepareAction did not return an object");return"meta"in r?{type:e,payload:r.payload,meta:r.meta}:{type:e,payload:r.payload}}return{type:e,payload:arguments.length<=0?void 0:arguments[0]}}return r.toString=function(){return""+e},r.type=e,r}function y(e,t){return function(o,n){return void 0===o&&(o=e),r(o,(function(e){var r=t[n.type];return r?r(e,n):void 0}))}}Object.defineProperty(exports,"combineReducers",{enumerable:!0,get:function(){return t.combineReducers}}),Object.defineProperty(exports,"compose",{enumerable:!0,get:function(){return t.compose}}),exports.createNextState=r,Object.defineProperty(exports,"createSelector",{enumerable:!0,get:function(){return o.createSelector}}),exports.configureStore=function(e){var r,o=e||{},a=o.reducer,c=void 0===a?void 0:a,s=o.middleware,l=void 0===s?p():s,d=o.devTools,f=void 0===d||d,y=o.preloadedState,v=void 0===y?void 0:y,b=o.enhancers,h=void 0===b?void 0:b;if("function"==typeof c)r=c;else{if(!u(c))throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');r=t.combineReducers(c)}var m=t.applyMiddleware.apply(void 0,l),g=t.compose;f&&(g=n.composeWithDevTools(i({trace:!1},"object"==typeof f&&f)));var x=[m];Array.isArray(h)?x=[m].concat(h):"function"==typeof h&&(x=h(x));var j=g.apply(void 0,x);return t.createStore(r,v,j)},exports.createAction=f,exports.createReducer=y,exports.createSerializableStateInvariantMiddleware=function(e){void 0===e&&(e={});var t=e.isSerializable,r=void 0===t?c:t,o=e.getEntries,n=e.ignoredActions,a=void 0===n?[]:n;return function(e){return function(t){return function(n){if(a.length&&-1!==a.indexOf(n.type))return t(n);var i=d(n,[],r,o);i&&console.error(l,i.keyPath,i.value,n);var u=t(n),c=d(e.getState(),[],r,o);return c&&console.error(s,c.keyPath,c.value,n.type),u}}}},exports.createSlice=function(e){var t=e.name,r=e.initialState;if(!t)throw new Error("`name` is a required option for createSlice");var o=e.reducers||{},n=e.extraReducers||{},a=Object.keys(o),u={},c={},s={};a.forEach((function(e){var r,n,a=o[e],i=t+"/"+e;"function"==typeof a?r=a:(r=a.reducer,n=a.prepare),u[e]=r,c[i]=r,s[e]=n?f(i,n):f(i)}));var l=y(r,i({},n,{},c));return{name:t,reducer:l,actions:s,caseReducers:u}},exports.findNonSerializableValue=d,exports.getDefaultMiddleware=p,exports.getType=function(e){return""+e},exports.isPlain=c; | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var r=require("redux"),t=e(require("immer")),o=require("reselect"),n=require("redux-devtools-extension"),a=e(require("redux-thunk"));function i(){return(i=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e}).apply(this,arguments)}function u(e){if("object"!=typeof e||null===e)return!1;for(var r=e;null!==Object.getPrototypeOf(r);)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(e)===r}function c(e){return null==e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||Array.isArray(e)||u(e)}var s=["A non-serializable value was detected in the state, in the path: `%s`. Value: %o","Take a look at the reducer(s) handling this action type: %s.","(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)"].join("\n"),l=["A non-serializable value was detected in an action, in the path: `%s`. Value: %o","Take a look at the logic that dispatched this action: %o.","(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)"].join("\n");function d(e,r,t,o){var n;if(void 0===r&&(r=[]),void 0===t&&(t=c),!t(e))return{keyPath:r.join(".")||"<root>",value:e};if("object"!=typeof e||null===e)return!1;var a=null!=o?o(e):Object.entries(e),i=Array.isArray(a),u=0;for(a=i?a:a[Symbol.iterator]();;){var s;if(i){if(u>=a.length)break;s=a[u++]}else{if((u=a.next()).done)break;s=u.value}var l=s[1],f=r.concat(s[0]);if(!t(l))return{keyPath:f.join("."),value:l};if("object"==typeof l&&(n=d(l,f,t,o)))return n}return!1}function f(e){void 0===e&&(e={});var r=e.thunk,t=void 0===r||r,o=[];return t&&o.push("boolean"==typeof t?a:a.withExtraArgument(t.extraArgument)),o}function p(e,r){function t(){if(r){var t=r.apply(void 0,arguments);if(!t)throw new Error("prepareAction did not return an object");return i({type:e,payload:t.payload},"meta"in t&&{meta:t.meta},{},"error"in t&&{error:t.error})}return{type:e,payload:arguments.length<=0?void 0:arguments[0]}}return t.toString=function(){return""+e},t.type=e,t}function v(e,r){return function(o,n){return void 0===o&&(o=e),t(o,(function(e){var t=r[n.type];return t?t(e,n):void 0}))}}Object.defineProperty(exports,"combineReducers",{enumerable:!0,get:function(){return r.combineReducers}}),Object.defineProperty(exports,"compose",{enumerable:!0,get:function(){return r.compose}}),exports.createNextState=t,Object.defineProperty(exports,"createSelector",{enumerable:!0,get:function(){return o.createSelector}}),exports.configureStore=function(e){var t,o=e||{},a=o.reducer,c=void 0===a?void 0:a,s=o.middleware,l=void 0===s?f():s,d=o.devTools,p=void 0===d||d,v=o.preloadedState,y=void 0===v?void 0:v,b=o.enhancers,h=void 0===b?void 0:b;if("function"==typeof c)t=c;else{if(!u(c))throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');t=r.combineReducers(c)}var m=r.applyMiddleware.apply(void 0,l),g=r.compose;p&&(g=n.composeWithDevTools(i({trace:!1},"object"==typeof p&&p)));var x=[m];Array.isArray(h)?x=[m].concat(h):"function"==typeof h&&(x=h(x));var j=g.apply(void 0,x);return r.createStore(t,y,j)},exports.createAction=p,exports.createReducer=v,exports.createSerializableStateInvariantMiddleware=function(e){void 0===e&&(e={});var r=e.isSerializable,t=void 0===r?c:r,o=e.getEntries,n=e.ignoredActions,a=void 0===n?[]:n;return function(e){return function(r){return function(n){if(a.length&&-1!==a.indexOf(n.type))return r(n);var i=d(n,[],t,o);i&&console.error(l,i.keyPath,i.value,n);var u=r(n),c=d(e.getState(),[],t,o);return c&&console.error(s,c.keyPath,c.value,n.type),u}}}},exports.createSlice=function(e){var r=e.name,t=e.initialState;if(!r)throw new Error("`name` is a required option for createSlice");var o=e.reducers||{},n=e.extraReducers||{},a=Object.keys(o),u={},c={},s={};a.forEach((function(e){var t,n,a=o[e],i=r+"/"+e;"function"==typeof a?t=a:(t=a.reducer,n=a.prepare),u[e]=t,c[i]=t,s[e]=n?p(i,n):p(i)}));var l=v(t,i({},n,{},c));return{name:r,reducer:l,actions:s,caseReducers:u}},exports.findNonSerializableValue=d,exports.getDefaultMiddleware=f,exports.getType=function(e){return""+e},exports.isPlain=c; | ||
//# sourceMappingURL=redux-starter-kit.cjs.production.min.js.map |
@@ -300,10 +300,10 @@ import { combineReducers, applyMiddleware, createStore, compose } from 'redux'; | ||
return 'meta' in prepared ? { | ||
return _extends({ | ||
type: type, | ||
payload: prepared.payload, | ||
payload: prepared.payload | ||
}, 'meta' in prepared && { | ||
meta: prepared.meta | ||
} : { | ||
type: type, | ||
payload: prepared.payload | ||
}; | ||
}, {}, 'error' in prepared && { | ||
error: prepared.error | ||
}); | ||
} | ||
@@ -310,0 +310,0 @@ |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).RSK={})}(this,(function(e){"use strict";var t=function(e){var t,r=("undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof module?module:Function("return this")()).Symbol;return"function"==typeof r?r.observable?t=r.observable:(t=r("observable"),r.observable=t):t="@@observable",t}(),r=function(){return Math.random().toString(36).substring(7).split("").join(".")},n={INIT:"@@redux/INIT"+r(),REPLACE:"@@redux/REPLACE"+r(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+r()}};function o(e,r,i){var a;if("function"==typeof r&&"function"==typeof i||"function"==typeof i&&"function"==typeof arguments[3])throw new Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function");if("function"==typeof r&&void 0===i&&(i=r,r=void 0),void 0!==i){if("function"!=typeof i)throw new Error("Expected the enhancer to be a function.");return i(o)(e,r)}if("function"!=typeof e)throw new Error("Expected the reducer to be a function.");var u=e,c=r,f=[],s=f,l=!1;function p(){s===f&&(s=f.slice())}function d(){if(l)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return c}function h(e){if("function"!=typeof e)throw new Error("Expected the listener to be a function.");if(l)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api-reference/store#subscribe(listener) for more details.");var t=!0;return p(),s.push(e),function(){if(t){if(l)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api-reference/store#subscribe(listener) for more details.");t=!1,p();var r=s.indexOf(e);s.splice(r,1)}}}function y(e){if(!function(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}(e))throw new Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===e.type)throw new Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(l)throw new Error("Reducers may not dispatch actions.");try{l=!0,c=u(c,e)}finally{l=!1}for(var t=f=s,r=0;r<t.length;r++)(0,t[r])();return e}return y({type:n.INIT}),(a={dispatch:y,subscribe:h,getState:d,replaceReducer:function(e){if("function"!=typeof e)throw new Error("Expected the nextReducer to be a function.");u=e,y({type:n.REPLACE})}})[t]=function(){var e,r=h;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new TypeError("Expected the observer to be an object.");function t(){e.next&&e.next(d())}return t(),{unsubscribe:r(t)}}})[t]=function(){return this},e},a}function i(e,t){var r=t&&t.type;return"Given "+(r&&'action "'+String(r)+'"'||"an action")+', reducer "'+e+'" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.'}function a(e){for(var t=Object.keys(e),r={},o=0;o<t.length;o++){var a=t[o];"function"==typeof e[a]&&(r[a]=e[a])}var u,c=Object.keys(r);try{!function(e){Object.keys(e).forEach((function(t){var r=e[t];if(void 0===r(void 0,{type:n.INIT}))throw new Error('Reducer "'+t+"\" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.");if(void 0===r(void 0,{type:n.PROBE_UNKNOWN_ACTION()}))throw new Error('Reducer "'+t+"\" returned undefined when probed with a random type. Don't try to handle "+n.INIT+' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.')}))}(r)}catch(e){u=e}return function(e,t){if(void 0===e&&(e={}),u)throw u;for(var n=!1,o={},a=0;a<c.length;a++){var f=c[a],s=e[f],l=(0,r[f])(s,t);if(void 0===l){var p=i(f,t);throw new Error(p)}o[f]=l,n=n||l!==s}return n?o:e}}function u(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function c(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){u(e,t,r[t])}))}return e}function f(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return 0===t.length?function(e){return e}:1===t.length?t[0]:t.reduce((function(e,t){return function(){return e(t.apply(void 0,arguments))}}))}function s(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e){return function(){var r=e.apply(void 0,arguments),n=function(){throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},o={getState:r.getState,dispatch:function(){return n.apply(void 0,arguments)}},i=t.map((function(e){return e(o)}));return c({},r,{dispatch:n=f.apply(void 0,i)(r.dispatch)})}}}var l,p=f,d="undefined"!=typeof Symbol?Symbol("immer-nothing"):((l={})["immer-nothing"]=!0,l),h="undefined"!=typeof Symbol&&Symbol.for?Symbol.for("immer-draftable"):"__$immer_draftable",y="undefined"!=typeof Symbol&&Symbol.for?Symbol.for("immer-state"):"__$immer_state";function v(e){return!!e&&!!e[y]}function b(e){return!!e&&(function(e){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e))return!0;var t=Object.getPrototypeOf(e);return!t||t===Object.prototype}(e)||!!e[h]||!!e.constructor[h])}var g=Object.assign||function(e,t){for(var r in t)P(t,r)&&(e[r]=t[r]);return e},m="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames;function w(e,t){if(void 0===t&&(t=!1),Array.isArray(e))return e.slice();var r=Object.create(Object.getPrototypeOf(e));return m(e).forEach((function(n){if(n!==y){var o=Object.getOwnPropertyDescriptor(e,n),i=o.value;if(o.get){if(!t)throw new Error("Immer drafts cannot have computed properties");i=o.get.call(e)}o.enumerable?r[n]=i:Object.defineProperty(r,n,{value:i,writable:!0,configurable:!0})}})),r}function O(e,t){if(Array.isArray(e))for(var r=0;r<e.length;r++)t(r,e[r],e);else m(e).forEach((function(r){return t(r,e[r],e)}))}function E(e,t){var r=Object.getOwnPropertyDescriptor(e,t);return!!r&&r.enumerable}function P(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function j(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function A(e){if(!b(e))return e;if(Array.isArray(e))return e.map(A);var t=Object.create(Object.getPrototypeOf(e));for(var r in e)t[r]=A(e[r]);return t}function z(e){if(b(e)&&!v(e)&&!Object.isFrozen(e))if(Object.freeze(e),Array.isArray(e))e.forEach(z);else for(var t in e)z(e[t])}var x=function(e){this.drafts=[],this.parent=e,this.canAutoFreeze=!0,this.patches=null};function S(e){e[y].revoke()}x.prototype.usePatches=function(e){e&&(this.patches=[],this.inversePatches=[],this.patchListener=e)},x.prototype.revoke=function(){this.leave(),this.drafts.forEach(S),this.drafts=null},x.prototype.leave=function(){this===x.current&&(x.current=this.parent)},x.current=null,x.enter=function(){return this.current=new x(this.current)};var k={};function _(){this.revoked=!0}function T(e){return e.copy||e.base}function I(e,t){var r=e[y];if(r&&!r.finalizing){r.finalizing=!0;var n=e[t];return r.finalizing=!1,n}return e[t]}function N(e){e.modified||(e.modified=!0,e.parent&&N(e.parent))}function R(e){e.copy||(e.copy=D(e.base))}function D(e){var t=e&&e[y];if(t){t.finalizing=!0;var r=w(t.draft,!0);return t.finalizing=!1,r}return w(e)}function F(e){if(!0===e.revoked)throw new Error("Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+JSON.stringify(T(e)))}function C(e){for(var t=e.length-1;t>=0;t--){var r=e[t][y];r.modified||(Array.isArray(r.base)?M(r)&&N(r):U(r)&&N(r))}}function U(e){for(var t=e.base,r=e.draft,n=Object.keys(r),o=n.length-1;o>=0;o--){var i=n[o],a=t[i];if(void 0===a&&!P(t,i))return!0;var u=r[i],c=u&&u[y];if(c?c.base!==a:!j(u,a))return!0}return n.length!==Object.keys(t).length}function M(e){var t=e.draft;if(t.length!==e.base.length)return!0;var r=Object.getOwnPropertyDescriptor(t,t.length-1);return!(!r||r.get)}var L=Object.freeze({willFinalize:function(e,t,r){e.drafts.forEach((function(e){e[y].finalizing=!0})),r?v(t)&&t[y].scope===e&&C(e.drafts):(e.patches&&function e(t){if(t&&"object"==typeof t){var r=t[y];if(r){var n=r.base,o=r.draft,i=r.assigned;if(Array.isArray(t)){if(M(r)){if(N(r),i.length=!0,o.length<n.length)for(var a=o.length;a<n.length;a++)i[a]=!1;else for(var u=n.length;u<o.length;u++)i[u]=!0;for(var c=0;c<o.length;c++)void 0===i[c]&&e(o[c])}}else Object.keys(o).forEach((function(t){void 0!==n[t]||P(n,t)?i[t]||e(o[t]):(i[t]=!0,N(r))})),Object.keys(n).forEach((function(e){void 0!==o[e]||P(o,e)||(i[e]=!1,N(r))}))}}}(e.drafts[0]),C(e.drafts))},createProxy:function e(t,r){var n=Array.isArray(t),o=D(t);O(o,(function(r){!function(t,r,n){var o=k[r];o?o.enumerable=n:k[r]=o={configurable:!0,enumerable:n,get:function(){return function(t,r){F(t);var n=I(T(t),r);return t.finalizing?n:n===I(t.base,r)&&b(n)?(R(t),t.copy[r]=e(n,t)):n}(this[y],r)},set:function(e){!function(e,t,r){if(F(e),e.assigned[t]=!0,!e.modified){if(j(r,I(T(e),t)))return;N(e),R(e)}e.copy[t]=r}(this[y],r,e)}},Object.defineProperty(t,r,o)}(o,r,n||E(t,r))}));var i=r?r.scope:x.current;return Object.defineProperty(o,y,{value:{scope:i,modified:!1,finalizing:!1,finalized:!1,assigned:{},parent:r,base:t,draft:o,copy:null,revoke:_,revoked:!1},enumerable:!1,writable:!0}),i.drafts.push(o),o}});function W(e,t){var r=t?t.scope:x.current,n={scope:r,modified:!1,finalized:!1,assigned:{},parent:t,base:e,draft:null,drafts:{},copy:null,revoke:null},o=Array.isArray(e)?Proxy.revocable([n],X):Proxy.revocable(n,K),i=o.revoke,a=o.proxy;return n.draft=a,n.revoke=i,r.drafts.push(a),a}var K={get:function(e,t){if(t===y)return e;var r=e.drafts;if(!e.modified&&P(r,t))return r[t];var n=V(e)[t];if(e.finalized||!b(n))return n;if(e.modified){if(n!==q(e.base,t))return n;r=e.copy}return r[t]=W(n,e)},has:function(e,t){return t in V(e)},ownKeys:function(e){return Reflect.ownKeys(V(e))},set:function(e,t,r){if(!e.modified){var n=q(e.base,t);if(r?j(n,r)||r===e.drafts[t]:j(n,r)&&t in e.base)return!0;B(e)}return e.assigned[t]=!0,e.copy[t]=r,!0},deleteProperty:function(e,t){return void 0!==q(e.base,t)||t in e.base?(e.assigned[t]=!1,B(e)):e.assigned[t]&&delete e.assigned[t],e.copy&&delete e.copy[t],!0},getOwnPropertyDescriptor:function(e,t){var r=V(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&(n.writable=!0,n.configurable=!Array.isArray(r)||"length"!==t),n},defineProperty:function(){throw new Error("Object.defineProperty() cannot be used on an Immer draft")},getPrototypeOf:function(e){return Object.getPrototypeOf(e.base)},setPrototypeOf:function(){throw new Error("Object.setPrototypeOf() cannot be used on an Immer draft")}},X={};function V(e){return e.copy||e.base}function q(e,t){var r=e[y],n=Reflect.getOwnPropertyDescriptor(r?V(r):e,t);return n&&n.value}function B(e){e.modified||(e.modified=!0,e.copy=g(w(e.base),e.drafts),e.drafts=null,e.parent&&B(e.parent))}O(K,(function(e,t){X[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),X.deleteProperty=function(e,t){if(isNaN(parseInt(t)))throw new Error("Immer only supports deleting array indices");return K.deleteProperty.call(this,e[0],t)},X.set=function(e,t,r){if("length"!==t&&isNaN(parseInt(t)))throw new Error("Immer only supports setting array indices and the 'length' property");return K.set.call(this,e[0],t,r)};var Y=Object.freeze({willFinalize:function(){},createProxy:W}),$=function(e,t){for(var r=0,n=t;r<n.length;r+=1){var o=n[r],i=o.path,a=o.op,u=A(o.value);if(!i.length)throw new Error("Illegal state");for(var c=e,f=0;f<i.length-1;f++)if(!(c=c[i[f]])||"object"!=typeof c)throw new Error("Cannot apply patch, path doesn't resolve: "+i.join("/"));var s=i[i.length-1];switch(a){case"replace":c[s]=u;break;case"add":Array.isArray(c)?c.splice(s,0,u):c[s]=u;break;case"remove":Array.isArray(c)?c.splice(s,1):delete c[s];break;default:throw new Error("Unsupported patch operation: "+a)}}return e},G={useProxies:"undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,autoFreeze:"undefined"==typeof process&&"verifyMinified"===function(){}.name,onAssign:null,onDelete:null,onCopy:null},H=function(e){g(this,G,e),this.setUseProxies(this.useProxies),this.produce=this.produce.bind(this)};H.prototype.produce=function(e,t,r){var n,o=this;if("function"==typeof e&&"function"!=typeof t){var i=t;t=e;var a=this;return function(e){var r=this;void 0===e&&(e=i);for(var n=[],o=arguments.length-1;o-- >0;)n[o]=arguments[o+1];return a.produce(e,(function(e){return t.call.apply(t,[r,e].concat(n))}))}}if("function"!=typeof t)throw new Error("The first or second argument to `produce` must be a function");if(void 0!==r&&"function"!=typeof r)throw new Error("The third argument to `produce` must be a function or undefined");if(b(e)){var u=x.enter(),c=this.createProxy(e),f=!0;try{n=t(c),f=!1}finally{f?u.revoke():u.leave()}return n instanceof Promise?n.then((function(e){return u.usePatches(r),o.processResult(e,u)}),(function(e){throw u.revoke(),e})):(u.usePatches(r),this.processResult(n,u))}if((n=t(e))!==d)return void 0===n&&(n=e),this.maybeFreeze(n,!0),n},H.prototype.produceWithPatches=function(e,t,r){var n,o,i=this;if("function"==typeof e)return function(t){for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return i.produceWithPatches(t,(function(t){return e.apply(void 0,[t].concat(r))}))};if(r)throw new Error("A patch listener cannot be passed to produceWithPatches");return[this.produce(e,t,(function(e,t){n=e,o=t})),n,o]},H.prototype.createDraft=function(e){if(!b(e))throw new Error("First argument to `createDraft` must be a plain object, an array, or an immerable object");var t=x.enter(),r=this.createProxy(e);return r[y].isManual=!0,t.leave(),r},H.prototype.finishDraft=function(e,t){var r=e&&e[y];if(!r||!r.isManual)throw new Error("First argument to `finishDraft` must be a draft returned by `createDraft`");if(r.finalized)throw new Error("The given draft is already finalized");var n=r.scope;return n.usePatches(t),this.processResult(void 0,n)},H.prototype.setAutoFreeze=function(e){this.autoFreeze=e},H.prototype.setUseProxies=function(e){this.useProxies=e,g(this,e?Y:L)},H.prototype.applyPatches=function(e,t){var r;for(r=t.length-1;r>=0;r--){var n=t[r];if(0===n.path.length&&"replace"===n.op){e=n.value;break}}return v(e)?$(e,t):this.produce(e,(function(e){return $(e,t.slice(r+1))}))},H.prototype.processResult=function(e,t){var r=t.drafts[0],n=void 0!==e&&e!==r;if(this.willFinalize(t,e,n),n){if(r[y].modified)throw t.revoke(),new Error("An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.");b(e)&&(e=this.finalize(e,null,t),this.maybeFreeze(e)),t.patches&&(t.patches.push({op:"replace",path:[],value:e}),t.inversePatches.push({op:"replace",path:[],value:r[y].base}))}else e=this.finalize(r,[],t);return t.revoke(),t.patches&&t.patchListener(t.patches,t.inversePatches),e!==d?e:void 0},H.prototype.finalize=function(e,t,r){var n=this,o=e[y];if(!o)return Object.isFrozen(e)?e:this.finalizeTree(e,null,r);if(o.scope!==r)return e;if(!o.modified)return this.maybeFreeze(o.base,!0),o.base;if(!o.finalized){if(o.finalized=!0,this.finalizeTree(o.draft,t,r),this.onDelete)if(this.useProxies){var i=o.assigned;for(var a in i)i[a]||this.onDelete(o,a)}else{var u=o.copy;O(o.base,(function(e){P(u,e)||n.onDelete(o,e)}))}this.onCopy&&this.onCopy(o),this.autoFreeze&&r.canAutoFreeze&&Object.freeze(o.copy),t&&r.patches&&function(e,t,r,n){Array.isArray(e.base)?function(e,t,r,n){var o,i,a=e.base,u=e.copy,c=e.assigned;u.length<a.length&&(a=(o=[u,a])[0],u=o[1],r=(i=[n,r])[0],n=i[1]);for(var f=u.length-a.length,s=0;a[s]===u[s]&&s<a.length;)++s;for(var l=a.length;l>s&&a[l-1]===u[l+f-1];)--l;for(var p=s;p<l;++p)if(c[p]&&u[p]!==a[p]){var d=t.concat([p]);r.push({op:"replace",path:d,value:u[p]}),n.push({op:"replace",path:d,value:a[p]})}for(var h=r.length,y=l+f-1;y>=l;--y){var v=t.concat([y]);r[h+y-l]={op:"add",path:v,value:u[y]},n.push({op:"remove",path:v})}}(e,t,r,n):function(e,t,r,n){var o=e.base,i=e.copy;O(e.assigned,(function(e,a){var u=o[e],c=i[e],f=a?e in o?"replace":"add":"remove";if(u!==c||"replace"!==f){var s=t.concat(e);r.push("remove"===f?{op:f,path:s}:{op:f,path:s,value:c}),n.push("add"===f?{op:"remove",path:s}:"remove"===f?{op:"add",path:s,value:u}:{op:"replace",path:s,value:u})}}))}(e,t,r,n)}(o,t,r.patches,r.inversePatches)}return o.copy},H.prototype.finalizeTree=function(e,t,r){var n=this,o=e[y];o&&(this.useProxies||(o.copy=w(o.draft,!0)),e=o.copy);var i=!!t&&!!r.patches,a=function(u,c,f){if(c===f)throw Error("Immer forbids circular references");var s=!!o&&f===e;if(v(c)){var l=s&&i&&!o.assigned[u]?t.concat(u):null;if(v(c=n.finalize(c,l,r))&&(r.canAutoFreeze=!1),Array.isArray(f)||E(f,u)?f[u]=c:Object.defineProperty(f,u,{value:c}),s&&c===o.base[u])return}else{if(s&&j(c,o.base[u]))return;b(c)&&!Object.isFrozen(c)&&(O(c,a),n.maybeFreeze(c))}s&&n.onAssign&&n.onAssign(o,u,c)};return O(e,a),e},H.prototype.maybeFreeze=function(e,t){void 0===t&&(t=!1),this.autoFreeze&&!v(e)&&(t?z(e):Object.freeze(e))};var J=new H,Q=J.produce;function Z(e,t){return e===t}function ee(e,t,r){if(null===t||null===r||t.length!==r.length)return!1;for(var n=t.length,o=0;o<n;o++)if(!e(t[o],r[o]))return!1;return!0}function te(e){var t=Array.isArray(e[0])?e[0]:e;if(!t.every((function(e){return"function"==typeof e}))){var r=t.map((function(e){return typeof e})).join(", ");throw new Error("Selector creators expect all input-selectors to be functions, instead received the following types: ["+r+"]")}return t}J.produceWithPatches.bind(J),J.setAutoFreeze.bind(J),J.setUseProxies.bind(J),J.applyPatches.bind(J),J.createDraft.bind(J),J.finishDraft.bind(J);var re=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return function(){for(var t=arguments.length,n=Array(t),o=0;o<t;o++)n[o]=arguments[o];var i=0,a=n.pop(),u=te(n),c=e.apply(void 0,[function(){return i++,a.apply(null,arguments)}].concat(r)),f=e((function(){for(var e=[],t=u.length,r=0;r<t;r++)e.push(u[r].apply(null,arguments));return c.apply(null,e)}));return f.resultFunc=a,f.dependencies=u,f.recomputations=function(){return i},f.resetRecomputations=function(){return i=0},f}}((function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Z,r=null,n=null;return function(){return ee(t,r,arguments)||(n=e.apply(null,arguments)),r=arguments,n}}));function ne(){return(ne=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var oe,ie=function(e,t){return function(e,t){var r=p;t.__esModule=!0,t.composeWithDevTools="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?r:r.apply(null,arguments)},t.devToolsEnhancer="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__?window.__REDUX_DEVTOOLS_EXTENSION__:function(){return function(e){return e}}}(t={exports:{}},t.exports),t.exports}();(oe=ie)&&oe.__esModule&&Object.prototype.hasOwnProperty.call(oe,"default");var ae=ie.composeWithDevTools;function ue(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function ce(e){return function(t){var r=t.dispatch,n=t.getState;return function(t){return function(o){return"function"==typeof o?o(r,n,e):t(o)}}}}var fe=ce();function se(e){return null==e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||Array.isArray(e)||ue(e)}fe.withExtraArgument=ce;var le=["A non-serializable value was detected in the state, in the path: `%s`. Value: %o","Take a look at the reducer(s) handling this action type: %s.","(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)"].join("\n"),pe=["A non-serializable value was detected in an action, in the path: `%s`. Value: %o","Take a look at the logic that dispatched this action: %o.","(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)"].join("\n");function de(e,t,r,n){var o;if(void 0===t&&(t=[]),void 0===r&&(r=se),!r(e))return{keyPath:t.join(".")||"<root>",value:e};if("object"!=typeof e||null===e)return!1;var i=null!=n?n(e):Object.entries(e),a=Array.isArray(i),u=0;for(i=a?i:i[Symbol.iterator]();;){var c;if(a){if(u>=i.length)break;c=i[u++]}else{if((u=i.next()).done)break;c=u.value}var f=c[1],s=t.concat(c[0]);if(!r(f))return{keyPath:s.join("."),value:f};if("object"==typeof f&&(o=de(f,s,r,n)))return o}return!1}function he(e){void 0===e&&(e={});var t=e.thunk,r=void 0===t||t,n=[];return r&&(function(e){return"boolean"==typeof e}(r)?n.push(fe):n.push(fe.withExtraArgument(r.extraArgument))),n}function ye(e,t){function r(){if(t){var r=t.apply(void 0,arguments);if(!r)throw new Error("prepareAction did not return an object");return"meta"in r?{type:e,payload:r.payload,meta:r.meta}:{type:e,payload:r.payload}}return{type:e,payload:arguments.length<=0?void 0:arguments[0]}}return r.toString=function(){return""+e},r.type=e,r}function ve(e,t){return function(r,n){return void 0===r&&(r=e),Q(r,(function(e){var r=t[n.type];return r?r(e,n):void 0}))}}e.combineReducers=a,e.compose=f,e.configureStore=function(e){var t,r=e||{},n=r.reducer,i=void 0===n?void 0:n,u=r.middleware,c=void 0===u?he():u,l=r.devTools,p=void 0===l||l,d=r.preloadedState,h=void 0===d?void 0:d,y=r.enhancers,v=void 0===y?void 0:y;if("function"==typeof i)t=i;else{if(!ue(i))throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');t=a(i)}var b=s.apply(void 0,c),g=f;p&&(g=ae(ne({trace:!1},"object"==typeof p&&p)));var m=[b];return Array.isArray(v)?m=[b].concat(v):"function"==typeof v&&(m=v(m)),o(t,h,g.apply(void 0,m))},e.createAction=ye,e.createNextState=Q,e.createReducer=ve,e.createSelector=re,e.createSerializableStateInvariantMiddleware=function(e){void 0===e&&(e={});var t=e.isSerializable,r=void 0===t?se:t,n=e.getEntries,o=e.ignoredActions,i=void 0===o?[]:o;return function(e){return function(t){return function(o){if(i.length&&-1!==i.indexOf(o.type))return t(o);var a=de(o,[],r,n);a&&console.error(pe,a.keyPath,a.value,o);var u=t(o),c=de(e.getState(),[],r,n);return c&&console.error(le,c.keyPath,c.value,o.type),u}}}},e.createSlice=function(e){var t=e.name,r=e.initialState;if(!t)throw new Error("`name` is a required option for createSlice");var n=e.reducers||{},o=e.extraReducers||{},i=Object.keys(n),a={},u={},c={};i.forEach((function(e){var r,o,i=n[e],f=t+"/"+e;"function"==typeof i?r=i:(r=i.reducer,o=i.prepare),a[e]=r,u[f]=r,c[e]=o?ye(f,o):ye(f)}));var f=ve(r,ne({},o,{},u));return{name:t,reducer:f,actions:c,caseReducers:a}},e.findNonSerializableValue=de,e.getDefaultMiddleware=he,e.getType=function(e){return""+e},e.isPlain=se})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).RSK={})}(this,(function(e){"use strict";var t=function(e){var t,r=("undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof module?module:Function("return this")()).Symbol;return"function"==typeof r?r.observable?t=r.observable:(t=r("observable"),r.observable=t):t="@@observable",t}(),r=function(){return Math.random().toString(36).substring(7).split("").join(".")},n={INIT:"@@redux/INIT"+r(),REPLACE:"@@redux/REPLACE"+r(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+r()}};function o(e,r,i){var a;if("function"==typeof r&&"function"==typeof i||"function"==typeof i&&"function"==typeof arguments[3])throw new Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function");if("function"==typeof r&&void 0===i&&(i=r,r=void 0),void 0!==i){if("function"!=typeof i)throw new Error("Expected the enhancer to be a function.");return i(o)(e,r)}if("function"!=typeof e)throw new Error("Expected the reducer to be a function.");var u=e,c=r,f=[],s=f,l=!1;function p(){s===f&&(s=f.slice())}function d(){if(l)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return c}function h(e){if("function"!=typeof e)throw new Error("Expected the listener to be a function.");if(l)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api-reference/store#subscribe(listener) for more details.");var t=!0;return p(),s.push(e),function(){if(t){if(l)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api-reference/store#subscribe(listener) for more details.");t=!1,p();var r=s.indexOf(e);s.splice(r,1)}}}function y(e){if(!function(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}(e))throw new Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===e.type)throw new Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(l)throw new Error("Reducers may not dispatch actions.");try{l=!0,c=u(c,e)}finally{l=!1}for(var t=f=s,r=0;r<t.length;r++)(0,t[r])();return e}return y({type:n.INIT}),(a={dispatch:y,subscribe:h,getState:d,replaceReducer:function(e){if("function"!=typeof e)throw new Error("Expected the nextReducer to be a function.");u=e,y({type:n.REPLACE})}})[t]=function(){var e,r=h;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new TypeError("Expected the observer to be an object.");function t(){e.next&&e.next(d())}return t(),{unsubscribe:r(t)}}})[t]=function(){return this},e},a}function i(e,t){var r=t&&t.type;return"Given "+(r&&'action "'+String(r)+'"'||"an action")+', reducer "'+e+'" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.'}function a(e){for(var t=Object.keys(e),r={},o=0;o<t.length;o++){var a=t[o];"function"==typeof e[a]&&(r[a]=e[a])}var u,c=Object.keys(r);try{!function(e){Object.keys(e).forEach((function(t){var r=e[t];if(void 0===r(void 0,{type:n.INIT}))throw new Error('Reducer "'+t+"\" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.");if(void 0===r(void 0,{type:n.PROBE_UNKNOWN_ACTION()}))throw new Error('Reducer "'+t+"\" returned undefined when probed with a random type. Don't try to handle "+n.INIT+' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.')}))}(r)}catch(e){u=e}return function(e,t){if(void 0===e&&(e={}),u)throw u;for(var n=!1,o={},a=0;a<c.length;a++){var f=c[a],s=e[f],l=(0,r[f])(s,t);if(void 0===l){var p=i(f,t);throw new Error(p)}o[f]=l,n=n||l!==s}return n?o:e}}function u(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function c(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){u(e,t,r[t])}))}return e}function f(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return 0===t.length?function(e){return e}:1===t.length?t[0]:t.reduce((function(e,t){return function(){return e(t.apply(void 0,arguments))}}))}function s(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e){return function(){var r=e.apply(void 0,arguments),n=function(){throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},o={getState:r.getState,dispatch:function(){return n.apply(void 0,arguments)}},i=t.map((function(e){return e(o)}));return c({},r,{dispatch:n=f.apply(void 0,i)(r.dispatch)})}}}var l,p=f,d="undefined"!=typeof Symbol?Symbol("immer-nothing"):((l={})["immer-nothing"]=!0,l),h="undefined"!=typeof Symbol&&Symbol.for?Symbol.for("immer-draftable"):"__$immer_draftable",y="undefined"!=typeof Symbol&&Symbol.for?Symbol.for("immer-state"):"__$immer_state";function v(e){return!!e&&!!e[y]}function b(e){return!!e&&(function(e){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e))return!0;var t=Object.getPrototypeOf(e);return!t||t===Object.prototype}(e)||!!e[h]||!!e.constructor[h])}var g=Object.assign||function(e,t){for(var r in t)P(t,r)&&(e[r]=t[r]);return e},m="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames;function w(e,t){if(void 0===t&&(t=!1),Array.isArray(e))return e.slice();var r=Object.create(Object.getPrototypeOf(e));return m(e).forEach((function(n){if(n!==y){var o=Object.getOwnPropertyDescriptor(e,n),i=o.value;if(o.get){if(!t)throw new Error("Immer drafts cannot have computed properties");i=o.get.call(e)}o.enumerable?r[n]=i:Object.defineProperty(r,n,{value:i,writable:!0,configurable:!0})}})),r}function O(e,t){if(Array.isArray(e))for(var r=0;r<e.length;r++)t(r,e[r],e);else m(e).forEach((function(r){return t(r,e[r],e)}))}function E(e,t){var r=Object.getOwnPropertyDescriptor(e,t);return!!r&&r.enumerable}function P(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function j(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function A(e){if(!b(e))return e;if(Array.isArray(e))return e.map(A);var t=Object.create(Object.getPrototypeOf(e));for(var r in e)t[r]=A(e[r]);return t}function z(e){if(b(e)&&!v(e)&&!Object.isFrozen(e))if(Object.freeze(e),Array.isArray(e))e.forEach(z);else for(var t in e)z(e[t])}var x=function(e){this.drafts=[],this.parent=e,this.canAutoFreeze=!0,this.patches=null};function S(e){e[y].revoke()}x.prototype.usePatches=function(e){e&&(this.patches=[],this.inversePatches=[],this.patchListener=e)},x.prototype.revoke=function(){this.leave(),this.drafts.forEach(S),this.drafts=null},x.prototype.leave=function(){this===x.current&&(x.current=this.parent)},x.current=null,x.enter=function(){return this.current=new x(this.current)};var k={};function _(){this.revoked=!0}function T(e){return e.copy||e.base}function I(e,t){var r=e[y];if(r&&!r.finalizing){r.finalizing=!0;var n=e[t];return r.finalizing=!1,n}return e[t]}function N(e){e.modified||(e.modified=!0,e.parent&&N(e.parent))}function R(e){e.copy||(e.copy=D(e.base))}function D(e){var t=e&&e[y];if(t){t.finalizing=!0;var r=w(t.draft,!0);return t.finalizing=!1,r}return w(e)}function F(e){if(!0===e.revoked)throw new Error("Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+JSON.stringify(T(e)))}function C(e){for(var t=e.length-1;t>=0;t--){var r=e[t][y];r.modified||(Array.isArray(r.base)?M(r)&&N(r):U(r)&&N(r))}}function U(e){for(var t=e.base,r=e.draft,n=Object.keys(r),o=n.length-1;o>=0;o--){var i=n[o],a=t[i];if(void 0===a&&!P(t,i))return!0;var u=r[i],c=u&&u[y];if(c?c.base!==a:!j(u,a))return!0}return n.length!==Object.keys(t).length}function M(e){var t=e.draft;if(t.length!==e.base.length)return!0;var r=Object.getOwnPropertyDescriptor(t,t.length-1);return!(!r||r.get)}var L=Object.freeze({willFinalize:function(e,t,r){e.drafts.forEach((function(e){e[y].finalizing=!0})),r?v(t)&&t[y].scope===e&&C(e.drafts):(e.patches&&function e(t){if(t&&"object"==typeof t){var r=t[y];if(r){var n=r.base,o=r.draft,i=r.assigned;if(Array.isArray(t)){if(M(r)){if(N(r),i.length=!0,o.length<n.length)for(var a=o.length;a<n.length;a++)i[a]=!1;else for(var u=n.length;u<o.length;u++)i[u]=!0;for(var c=0;c<o.length;c++)void 0===i[c]&&e(o[c])}}else Object.keys(o).forEach((function(t){void 0!==n[t]||P(n,t)?i[t]||e(o[t]):(i[t]=!0,N(r))})),Object.keys(n).forEach((function(e){void 0!==o[e]||P(o,e)||(i[e]=!1,N(r))}))}}}(e.drafts[0]),C(e.drafts))},createProxy:function e(t,r){var n=Array.isArray(t),o=D(t);O(o,(function(r){!function(t,r,n){var o=k[r];o?o.enumerable=n:k[r]=o={configurable:!0,enumerable:n,get:function(){return function(t,r){F(t);var n=I(T(t),r);return t.finalizing?n:n===I(t.base,r)&&b(n)?(R(t),t.copy[r]=e(n,t)):n}(this[y],r)},set:function(e){!function(e,t,r){if(F(e),e.assigned[t]=!0,!e.modified){if(j(r,I(T(e),t)))return;N(e),R(e)}e.copy[t]=r}(this[y],r,e)}},Object.defineProperty(t,r,o)}(o,r,n||E(t,r))}));var i=r?r.scope:x.current;return Object.defineProperty(o,y,{value:{scope:i,modified:!1,finalizing:!1,finalized:!1,assigned:{},parent:r,base:t,draft:o,copy:null,revoke:_,revoked:!1},enumerable:!1,writable:!0}),i.drafts.push(o),o}});function W(e,t){var r=t?t.scope:x.current,n={scope:r,modified:!1,finalized:!1,assigned:{},parent:t,base:e,draft:null,drafts:{},copy:null,revoke:null},o=Array.isArray(e)?Proxy.revocable([n],X):Proxy.revocable(n,K),i=o.revoke,a=o.proxy;return n.draft=a,n.revoke=i,r.drafts.push(a),a}var K={get:function(e,t){if(t===y)return e;var r=e.drafts;if(!e.modified&&P(r,t))return r[t];var n=V(e)[t];if(e.finalized||!b(n))return n;if(e.modified){if(n!==q(e.base,t))return n;r=e.copy}return r[t]=W(n,e)},has:function(e,t){return t in V(e)},ownKeys:function(e){return Reflect.ownKeys(V(e))},set:function(e,t,r){if(!e.modified){var n=q(e.base,t);if(r?j(n,r)||r===e.drafts[t]:j(n,r)&&t in e.base)return!0;B(e)}return e.assigned[t]=!0,e.copy[t]=r,!0},deleteProperty:function(e,t){return void 0!==q(e.base,t)||t in e.base?(e.assigned[t]=!1,B(e)):e.assigned[t]&&delete e.assigned[t],e.copy&&delete e.copy[t],!0},getOwnPropertyDescriptor:function(e,t){var r=V(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&(n.writable=!0,n.configurable=!Array.isArray(r)||"length"!==t),n},defineProperty:function(){throw new Error("Object.defineProperty() cannot be used on an Immer draft")},getPrototypeOf:function(e){return Object.getPrototypeOf(e.base)},setPrototypeOf:function(){throw new Error("Object.setPrototypeOf() cannot be used on an Immer draft")}},X={};function V(e){return e.copy||e.base}function q(e,t){var r=e[y],n=Reflect.getOwnPropertyDescriptor(r?V(r):e,t);return n&&n.value}function B(e){e.modified||(e.modified=!0,e.copy=g(w(e.base),e.drafts),e.drafts=null,e.parent&&B(e.parent))}O(K,(function(e,t){X[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),X.deleteProperty=function(e,t){if(isNaN(parseInt(t)))throw new Error("Immer only supports deleting array indices");return K.deleteProperty.call(this,e[0],t)},X.set=function(e,t,r){if("length"!==t&&isNaN(parseInt(t)))throw new Error("Immer only supports setting array indices and the 'length' property");return K.set.call(this,e[0],t,r)};var Y=Object.freeze({willFinalize:function(){},createProxy:W}),$=function(e,t){for(var r=0,n=t;r<n.length;r+=1){var o=n[r],i=o.path,a=o.op,u=A(o.value);if(!i.length)throw new Error("Illegal state");for(var c=e,f=0;f<i.length-1;f++)if(!(c=c[i[f]])||"object"!=typeof c)throw new Error("Cannot apply patch, path doesn't resolve: "+i.join("/"));var s=i[i.length-1];switch(a){case"replace":c[s]=u;break;case"add":Array.isArray(c)?c.splice(s,0,u):c[s]=u;break;case"remove":Array.isArray(c)?c.splice(s,1):delete c[s];break;default:throw new Error("Unsupported patch operation: "+a)}}return e},G={useProxies:"undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,autoFreeze:"undefined"==typeof process&&"verifyMinified"===function(){}.name,onAssign:null,onDelete:null,onCopy:null},H=function(e){g(this,G,e),this.setUseProxies(this.useProxies),this.produce=this.produce.bind(this)};H.prototype.produce=function(e,t,r){var n,o=this;if("function"==typeof e&&"function"!=typeof t){var i=t;t=e;var a=this;return function(e){var r=this;void 0===e&&(e=i);for(var n=[],o=arguments.length-1;o-- >0;)n[o]=arguments[o+1];return a.produce(e,(function(e){return t.call.apply(t,[r,e].concat(n))}))}}if("function"!=typeof t)throw new Error("The first or second argument to `produce` must be a function");if(void 0!==r&&"function"!=typeof r)throw new Error("The third argument to `produce` must be a function or undefined");if(b(e)){var u=x.enter(),c=this.createProxy(e),f=!0;try{n=t(c),f=!1}finally{f?u.revoke():u.leave()}return n instanceof Promise?n.then((function(e){return u.usePatches(r),o.processResult(e,u)}),(function(e){throw u.revoke(),e})):(u.usePatches(r),this.processResult(n,u))}if((n=t(e))!==d)return void 0===n&&(n=e),this.maybeFreeze(n,!0),n},H.prototype.produceWithPatches=function(e,t,r){var n,o,i=this;if("function"==typeof e)return function(t){for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return i.produceWithPatches(t,(function(t){return e.apply(void 0,[t].concat(r))}))};if(r)throw new Error("A patch listener cannot be passed to produceWithPatches");return[this.produce(e,t,(function(e,t){n=e,o=t})),n,o]},H.prototype.createDraft=function(e){if(!b(e))throw new Error("First argument to `createDraft` must be a plain object, an array, or an immerable object");var t=x.enter(),r=this.createProxy(e);return r[y].isManual=!0,t.leave(),r},H.prototype.finishDraft=function(e,t){var r=e&&e[y];if(!r||!r.isManual)throw new Error("First argument to `finishDraft` must be a draft returned by `createDraft`");if(r.finalized)throw new Error("The given draft is already finalized");var n=r.scope;return n.usePatches(t),this.processResult(void 0,n)},H.prototype.setAutoFreeze=function(e){this.autoFreeze=e},H.prototype.setUseProxies=function(e){this.useProxies=e,g(this,e?Y:L)},H.prototype.applyPatches=function(e,t){var r;for(r=t.length-1;r>=0;r--){var n=t[r];if(0===n.path.length&&"replace"===n.op){e=n.value;break}}return v(e)?$(e,t):this.produce(e,(function(e){return $(e,t.slice(r+1))}))},H.prototype.processResult=function(e,t){var r=t.drafts[0],n=void 0!==e&&e!==r;if(this.willFinalize(t,e,n),n){if(r[y].modified)throw t.revoke(),new Error("An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.");b(e)&&(e=this.finalize(e,null,t),this.maybeFreeze(e)),t.patches&&(t.patches.push({op:"replace",path:[],value:e}),t.inversePatches.push({op:"replace",path:[],value:r[y].base}))}else e=this.finalize(r,[],t);return t.revoke(),t.patches&&t.patchListener(t.patches,t.inversePatches),e!==d?e:void 0},H.prototype.finalize=function(e,t,r){var n=this,o=e[y];if(!o)return Object.isFrozen(e)?e:this.finalizeTree(e,null,r);if(o.scope!==r)return e;if(!o.modified)return this.maybeFreeze(o.base,!0),o.base;if(!o.finalized){if(o.finalized=!0,this.finalizeTree(o.draft,t,r),this.onDelete)if(this.useProxies){var i=o.assigned;for(var a in i)i[a]||this.onDelete(o,a)}else{var u=o.copy;O(o.base,(function(e){P(u,e)||n.onDelete(o,e)}))}this.onCopy&&this.onCopy(o),this.autoFreeze&&r.canAutoFreeze&&Object.freeze(o.copy),t&&r.patches&&function(e,t,r,n){Array.isArray(e.base)?function(e,t,r,n){var o,i,a=e.base,u=e.copy,c=e.assigned;u.length<a.length&&(a=(o=[u,a])[0],u=o[1],r=(i=[n,r])[0],n=i[1]);for(var f=u.length-a.length,s=0;a[s]===u[s]&&s<a.length;)++s;for(var l=a.length;l>s&&a[l-1]===u[l+f-1];)--l;for(var p=s;p<l;++p)if(c[p]&&u[p]!==a[p]){var d=t.concat([p]);r.push({op:"replace",path:d,value:u[p]}),n.push({op:"replace",path:d,value:a[p]})}for(var h=r.length,y=l+f-1;y>=l;--y){var v=t.concat([y]);r[h+y-l]={op:"add",path:v,value:u[y]},n.push({op:"remove",path:v})}}(e,t,r,n):function(e,t,r,n){var o=e.base,i=e.copy;O(e.assigned,(function(e,a){var u=o[e],c=i[e],f=a?e in o?"replace":"add":"remove";if(u!==c||"replace"!==f){var s=t.concat(e);r.push("remove"===f?{op:f,path:s}:{op:f,path:s,value:c}),n.push("add"===f?{op:"remove",path:s}:"remove"===f?{op:"add",path:s,value:u}:{op:"replace",path:s,value:u})}}))}(e,t,r,n)}(o,t,r.patches,r.inversePatches)}return o.copy},H.prototype.finalizeTree=function(e,t,r){var n=this,o=e[y];o&&(this.useProxies||(o.copy=w(o.draft,!0)),e=o.copy);var i=!!t&&!!r.patches,a=function(u,c,f){if(c===f)throw Error("Immer forbids circular references");var s=!!o&&f===e;if(v(c)){var l=s&&i&&!o.assigned[u]?t.concat(u):null;if(v(c=n.finalize(c,l,r))&&(r.canAutoFreeze=!1),Array.isArray(f)||E(f,u)?f[u]=c:Object.defineProperty(f,u,{value:c}),s&&c===o.base[u])return}else{if(s&&j(c,o.base[u]))return;b(c)&&!Object.isFrozen(c)&&(O(c,a),n.maybeFreeze(c))}s&&n.onAssign&&n.onAssign(o,u,c)};return O(e,a),e},H.prototype.maybeFreeze=function(e,t){void 0===t&&(t=!1),this.autoFreeze&&!v(e)&&(t?z(e):Object.freeze(e))};var J=new H,Q=J.produce;function Z(e,t){return e===t}function ee(e,t,r){if(null===t||null===r||t.length!==r.length)return!1;for(var n=t.length,o=0;o<n;o++)if(!e(t[o],r[o]))return!1;return!0}function te(e){var t=Array.isArray(e[0])?e[0]:e;if(!t.every((function(e){return"function"==typeof e}))){var r=t.map((function(e){return typeof e})).join(", ");throw new Error("Selector creators expect all input-selectors to be functions, instead received the following types: ["+r+"]")}return t}J.produceWithPatches.bind(J),J.setAutoFreeze.bind(J),J.setUseProxies.bind(J),J.applyPatches.bind(J),J.createDraft.bind(J),J.finishDraft.bind(J);var re=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return function(){for(var t=arguments.length,n=Array(t),o=0;o<t;o++)n[o]=arguments[o];var i=0,a=n.pop(),u=te(n),c=e.apply(void 0,[function(){return i++,a.apply(null,arguments)}].concat(r)),f=e((function(){for(var e=[],t=u.length,r=0;r<t;r++)e.push(u[r].apply(null,arguments));return c.apply(null,e)}));return f.resultFunc=a,f.dependencies=u,f.recomputations=function(){return i},f.resetRecomputations=function(){return i=0},f}}((function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Z,r=null,n=null;return function(){return ee(t,r,arguments)||(n=e.apply(null,arguments)),r=arguments,n}}));function ne(){return(ne=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var oe,ie=function(e,t){return function(e,t){var r=p;t.__esModule=!0,t.composeWithDevTools="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?r:r.apply(null,arguments)},t.devToolsEnhancer="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__?window.__REDUX_DEVTOOLS_EXTENSION__:function(){return function(e){return e}}}(t={exports:{}},t.exports),t.exports}();(oe=ie)&&oe.__esModule&&Object.prototype.hasOwnProperty.call(oe,"default");var ae=ie.composeWithDevTools;function ue(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function ce(e){return function(t){var r=t.dispatch,n=t.getState;return function(t){return function(o){return"function"==typeof o?o(r,n,e):t(o)}}}}var fe=ce();function se(e){return null==e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||Array.isArray(e)||ue(e)}fe.withExtraArgument=ce;var le=["A non-serializable value was detected in the state, in the path: `%s`. Value: %o","Take a look at the reducer(s) handling this action type: %s.","(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)"].join("\n"),pe=["A non-serializable value was detected in an action, in the path: `%s`. Value: %o","Take a look at the logic that dispatched this action: %o.","(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)"].join("\n");function de(e,t,r,n){var o;if(void 0===t&&(t=[]),void 0===r&&(r=se),!r(e))return{keyPath:t.join(".")||"<root>",value:e};if("object"!=typeof e||null===e)return!1;var i=null!=n?n(e):Object.entries(e),a=Array.isArray(i),u=0;for(i=a?i:i[Symbol.iterator]();;){var c;if(a){if(u>=i.length)break;c=i[u++]}else{if((u=i.next()).done)break;c=u.value}var f=c[1],s=t.concat(c[0]);if(!r(f))return{keyPath:s.join("."),value:f};if("object"==typeof f&&(o=de(f,s,r,n)))return o}return!1}function he(e){void 0===e&&(e={});var t=e.thunk,r=void 0===t||t,n=[];return r&&(function(e){return"boolean"==typeof e}(r)?n.push(fe):n.push(fe.withExtraArgument(r.extraArgument))),n}function ye(e,t){function r(){if(t){var r=t.apply(void 0,arguments);if(!r)throw new Error("prepareAction did not return an object");return ne({type:e,payload:r.payload},"meta"in r&&{meta:r.meta},{},"error"in r&&{error:r.error})}return{type:e,payload:arguments.length<=0?void 0:arguments[0]}}return r.toString=function(){return""+e},r.type=e,r}function ve(e,t){return function(r,n){return void 0===r&&(r=e),Q(r,(function(e){var r=t[n.type];return r?r(e,n):void 0}))}}e.combineReducers=a,e.compose=f,e.configureStore=function(e){var t,r=e||{},n=r.reducer,i=void 0===n?void 0:n,u=r.middleware,c=void 0===u?he():u,l=r.devTools,p=void 0===l||l,d=r.preloadedState,h=void 0===d?void 0:d,y=r.enhancers,v=void 0===y?void 0:y;if("function"==typeof i)t=i;else{if(!ue(i))throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');t=a(i)}var b=s.apply(void 0,c),g=f;p&&(g=ae(ne({trace:!1},"object"==typeof p&&p)));var m=[b];return Array.isArray(v)?m=[b].concat(v):"function"==typeof v&&(m=v(m)),o(t,h,g.apply(void 0,m))},e.createAction=ye,e.createNextState=Q,e.createReducer=ve,e.createSelector=re,e.createSerializableStateInvariantMiddleware=function(e){void 0===e&&(e={});var t=e.isSerializable,r=void 0===t?se:t,n=e.getEntries,o=e.ignoredActions,i=void 0===o?[]:o;return function(e){return function(t){return function(o){if(i.length&&-1!==i.indexOf(o.type))return t(o);var a=de(o,[],r,n);a&&console.error(pe,a.keyPath,a.value,o);var u=t(o),c=de(e.getState(),[],r,n);return c&&console.error(le,c.keyPath,c.value,o.type),u}}}},e.createSlice=function(e){var t=e.name,r=e.initialState;if(!t)throw new Error("`name` is a required option for createSlice");var n=e.reducers||{},o=e.extraReducers||{},i=Object.keys(n),a={},u={},c={};i.forEach((function(e){var r,o,i=n[e],f=t+"/"+e;"function"==typeof i?r=i:(r=i.reducer,o=i.prepare),a[e]=r,u[f]=r,c[e]=o?ye(f,o):ye(f)}));var f=ve(r,ne({},o,{},u));return{name:t,reducer:f,actions:c,caseReducers:a}},e.findNonSerializableValue=de,e.getDefaultMiddleware=he,e.getType=function(e){return""+e},e.isPlain=se})); | ||
//# sourceMappingURL=redux-starter-kit.umd.min.js.map |
{ | ||
"name": "redux-starter-kit", | ||
"version": "0.9.1", | ||
"version": "1.0.0", | ||
"description": "A simple set of tools to make using Redux easier", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/reduxjs/redux-starter-kit", |
@@ -51,2 +51,46 @@ import { createAction, getType } from './createAction' | ||
describe('when passing a prepareAction method returning a payload and error', () => { | ||
it('should use the payload returned from the prepareAction method', () => { | ||
const actionCreator = createAction('A_TYPE', (a: number) => ({ | ||
payload: a * 2, | ||
error: true | ||
})) | ||
expect(actionCreator(5).payload).toBe(10) | ||
}) | ||
it('should use the error returned from the prepareAction method', () => { | ||
const actionCreator = createAction('A_TYPE', (a: number) => ({ | ||
payload: a * 2, | ||
error: true | ||
})) | ||
expect(actionCreator(10).error).toBe(true) | ||
}) | ||
}) | ||
describe('when passing a prepareAction method returning a payload, meta and error', () => { | ||
it('should use the payload returned from the prepareAction method', () => { | ||
const actionCreator = createAction('A_TYPE', (a: number) => ({ | ||
payload: a * 2, | ||
meta: a / 2, | ||
error: true | ||
})) | ||
expect(actionCreator(5).payload).toBe(10) | ||
}) | ||
it('should use the error returned from the prepareAction method', () => { | ||
const actionCreator = createAction('A_TYPE', (a: number) => ({ | ||
payload: a * 2, | ||
meta: a / 2, | ||
error: true | ||
})) | ||
expect(actionCreator(10).error).toBe(true) | ||
}) | ||
it('should use the meta returned from the prepareAction method', () => { | ||
const actionCreator = createAction('A_TYPE', (a: number) => ({ | ||
payload: a * 2, | ||
meta: a / 2, | ||
error: true | ||
})) | ||
expect(actionCreator(10).meta).toBe(5) | ||
}) | ||
}) | ||
describe('when passing a prepareAction that accepts multiple arguments', () => { | ||
@@ -53,0 +97,0 @@ it('should pass all arguments of the resulting actionCreator to prepareAction', () => { |
@@ -11,2 +11,3 @@ import { Action } from 'redux' | ||
* @template M The type of the action's meta (optional) | ||
* @template E The type of the action's error (optional) | ||
*/ | ||
@@ -16,4 +17,5 @@ export type PayloadAction< | ||
T extends string = string, | ||
M = void | ||
> = WithOptionalMeta<M, WithPayload<P, Action<T>>> | ||
M = void, | ||
E = void | ||
> = WithOptional<M, E, WithPayload<P, Action<T>>> | ||
@@ -23,2 +25,3 @@ export type PrepareAction<P> = | ||
| ((...args: any[]) => { payload: P; meta: any }) | ||
| ((...args: any[]) => { payload: P; meta: any; error: any }) | ||
@@ -31,3 +34,5 @@ export type ActionCreatorWithPreparedPayload< | ||
PA extends PrepareAction<infer P> | ||
? (...args: Parameters<PA>) => PayloadAction<P, T, MetaOrVoid<PA>> | ||
? ( | ||
...args: Parameters<PA> | ||
) => PayloadAction<P, T, MetaOrVoid<PA>, ErrorOrVoid<PA>> | ||
: void | ||
@@ -120,5 +125,9 @@ > | ||
} | ||
return 'meta' in prepared | ||
? { type, payload: prepared.payload, meta: prepared.meta } | ||
: { type, payload: prepared.payload } | ||
return { | ||
type, | ||
payload: prepared.payload, | ||
...('meta' in prepared && { meta: prepared.meta }), | ||
...('error' in prepared && { error: prepared.error }) | ||
} | ||
} | ||
@@ -155,3 +164,5 @@ return { type, payload: args[0] } | ||
type WithOptionalMeta<M, T> = T & ([M] extends [void] ? {} : { meta: M }) | ||
type WithOptional<M, E, T> = T & | ||
([M] extends [void] ? {} : { meta: M }) & | ||
([E] extends [void] ? {} : { error: E }) | ||
@@ -174,4 +185,10 @@ type WithTypeProperty<T, MergeIn> = { | ||
type ErrorOrVoid<PA extends PrepareAction<any>> = ReturnType<PA> extends { | ||
error: infer E | ||
} | ||
? E | ||
: void | ||
type IfMaybeUndefined<P, True, False> = [undefined] extends [P] ? True : False | ||
type IfVoid<P, True, False> = [void] extends [P] ? True : False |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
592219
5050
2