@reduxjs/toolkit
Version:
The official, opinionated, batteries-included toolset for efficient Redux development
3 lines (2 loc) • 4.85 kB
JavaScript
;function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=require("redux"),r=e(require("immer")),n=require("reselect"),o=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 n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}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)}function s(e,t,r,n,o){var a;if(void 0===t&&(t=[]),void 0===r&&(r=c),void 0===o&&(o=[]),!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),u=o.length>0,d=i,f=Array.isArray(d),l=0;for(d=f?d:d[Symbol.iterator]();;){var p;if(f){if(l>=d.length)break;p=d[l++]}else{if((l=d.next()).done)break;p=l.value}var v=p[1],y=t.concat(p[0]);if(!(u&&o.indexOf(y.join("."))>=0)){if(!r(v))return{keyPath:y.join("."),value:v};if("object"==typeof v&&(a=s(v,y,r,n,o)))return a}}return!1}function d(e){void 0===e&&(e={});var t=e.thunk,r=void 0===t||t,n=[];return r&&n.push("boolean"==typeof r?a:a.withExtraArgument(r.extraArgument)),n}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 i({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.match=function(t){return t.type===e},r}function l(e){var t={},r={addCase:function(e,n){var o="string"==typeof e?e:e.type;if(o in t)throw new Error("addCase cannot be called with two reducers for the same action type");return t[o]=n,r}};return e(r),t}function p(e,t){var n="function"==typeof t?l(t):t;return function(t,o){return void 0===t&&(t=e),r(t,(function(e){var t=n[o.type];return t?t(e,o):void 0}))}}require("redux-immutable-state-invariant"),Object.keys(t).forEach((function(e){"default"!==e&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),exports.createNextState=r,Object.defineProperty(exports,"createSelector",{enumerable:!0,get:function(){return n.createSelector}}),exports.configureStore=function(e){var r,n=e||{},a=n.reducer,c=void 0===a?void 0:a,s=n.middleware,f=void 0===s?d():s,l=n.devTools,p=void 0===l||l,v=n.preloadedState,y=void 0===v?void 0:v,h=n.enhancers,b=void 0===h?void 0:h;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 g=t.applyMiddleware.apply(void 0,f),m=t.compose;p&&(m=o.composeWithDevTools(i({trace:!1},"object"==typeof p&&p)));var x=[g];Array.isArray(b)?x=[g].concat(b):"function"==typeof b&&(x=b(x));var j=m.apply(void 0,x);return t.createStore(r,y,j)},exports.createAction=f,exports.createReducer=p,exports.createSerializableStateInvariantMiddleware=function(e){void 0===e&&(e={});var t=e.isSerializable,r=void 0===t?c:t,n=e.getEntries,o=e.ignoredActions,a=void 0===o?[]:o,i=e.ignoredPaths,u=void 0===i?[]:i;return function(e){return function(t){return function(o){if(a.length&&-1!==a.indexOf(o.type))return t(o);var i=s(o,[],r,n);i&&console.error("A non-serializable value was detected in an action, in the path: `"+i.keyPath+"`. Value:",i.value,"\nTake a look at the logic that dispatched this action: ",o,"\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)");var c=t(o),d=s(e.getState(),[],r,n,u);return d&&console.error("A non-serializable value was detected in the state, in the path: `"+d.keyPath+"`. Value:",d.value,"\nTake a look at the reducer(s) handling this action type: "+o.type+".\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)"),c}}}},exports.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=void 0===e.extraReducers?{}:"function"==typeof e.extraReducers?l(e.extraReducers):e.extraReducers,a=Object.keys(n),u={},c={},s={};a.forEach((function(e){var r,o,a=n[e],i=t+"/"+e;"reducer"in a?(r=a.reducer,o=a.prepare):r=a,u[e]=r,c[i]=r,s[e]=o?f(i,o):f(i)}));var d=p(r,i({},o,{},c));return{name:t,reducer:d,actions:s,caseReducers:u}},exports.findNonSerializableValue=s,exports.getDefaultMiddleware=d,exports.getType=function(e){return""+e},exports.isPlain=c;
//# sourceMappingURL=redux-toolkit.cjs.production.min.js.map