redux-starter-kit
Version:
A simple set of tools to make using Redux easier
3 lines (2 loc) • 4.43 kB
JavaScript
;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;
//# sourceMappingURL=redux-starter-kit.cjs.production.min.js.map