Socket
Socket
Sign inDemoInstall

@reduxjs/toolkit

Package Overview
Dependencies
Maintainers
4
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@reduxjs/toolkit - npm Package Compare versions

Comparing version 1.0.4 to 1.1.0

src/mapBuilders.ts

131

dist/index.d.ts

@@ -1,6 +0,85 @@

import { Middleware, Reducer, ReducersMapObject, Action, AnyAction, StoreEnhancer, Store, DeepPartial } from "redux";
import { Action, AnyAction, Reducer, Middleware, ReducersMapObject, StoreEnhancer, Store, DeepPartial } from "redux";
import { Draft } from "immer";
import { EnhancerOptions as DevToolsOptions } from "redux-devtools-extension";
import { ThunkDispatch } from "redux-thunk";
import { Draft } from "immer";
interface TypedActionCreator<Type extends string> {
(...args: any[]): Action<Type>;
type: Type;
}
/**
* A builder for an action <-> reducer map.
*/
interface ActionReducerMapBuilder<State> {
/**
* Add a case reducer for actions created by this action creator.
* @param actionCreator
* @param reducer
*/
addCase<ActionCreator extends TypedActionCreator<string>>(actionCreator: ActionCreator, reducer: CaseReducer<State, ReturnType<ActionCreator>>): ActionReducerMapBuilder<State>;
/**
* Add a case reducer for actions with the specified type.
* @param type
* @param reducer
*/
addCase<Type extends string, A extends Action<Type>>(type: Type, reducer: CaseReducer<State, A>): ActionReducerMapBuilder<State>;
}
/**
* Defines a mapping from action types to corresponding action object shapes.
*/
declare type Actions<T extends keyof any = string> = Record<T, Action>;
/**
* An *case reducer* is a reducer function for a specific action type. Case
* reducers can be composed to full reducers using `createReducer()`.
*
* Unlike a normal Redux reducer, a case reducer is never called with an
* `undefined` state to determine the initial state. Instead, the initial
* state is explicitly specified as an argument to `createReducer()`.
*
* In addition, a case reducer can choose to mutate the passed-in `state`
* value directly instead of returning a new state. This does not actually
* cause the store state to be mutated directly; instead, thanks to
* [immer](https://github.com/mweststrate/immer), the mutations are
* translated to copy operations that result in a new state.
*/
declare type CaseReducer<S = any, A extends Action = AnyAction> = (state: Draft<S>, action: A) => S | void;
/**
* A mapping from action types to case reducers for `createReducer()`.
*/
declare type CaseReducers<S, AS extends Actions> = {
[T in keyof AS]: AS[T] extends Action ? CaseReducer<S, AS[T]> : void;
};
/**
* A utility function that allows defining a reducer as a mapping from action
* type to *case reducer* functions that handle these action types. The
* reducer's initial state is passed as the first argument.
*
* The body of every case reducer is implicitly wrapped with a call to
* `produce()` from the [immer](https://github.com/mweststrate/immer) library.
* This means that rather than returning a new state object, you can also
* mutate the passed-in state object directly; these mutations will then be
* automatically and efficiently translated into copies, giving you both
* convenience and immutability.
*
* @param initialState The initial state to be returned by the reducer.
* @param actionsMap A mapping from action types to action-type-specific
* case reducers.
*/
declare function createReducer<S, CR extends CaseReducers<S, any> = CaseReducers<S, any>>(initialState: S, actionsMap: CR): Reducer<S>;
/**
* A utility function that allows defining a reducer as a mapping from action
* type to *case reducer* functions that handle these action types. The
* reducer's initial state is passed as the first argument.
*
* The body of every case reducer is implicitly wrapped with a call to
* `produce()` from the [immer](https://github.com/mweststrate/immer) library.
* This means that rather than returning a new state object, you can also
* mutate the passed-in state object directly; these mutations will then be
* automatically and efficiently translated into copies, giving you both
* convenience and immutability.
* @param initialState The initial state to be returned by the reducer.
* @param builderCallback A callback that receives a *builder* object to define
* case reducers via calls to `builder.addCase(actionCreatorOrType, reducer)`.
*/
declare function createReducer<S>(initialState: S, builderCallback: (builder: ActionReducerMapBuilder<S>) => void): Reducer<S>;
/**
* Returns true if the passed value is "plain", i.e. a value that is either

@@ -214,44 +293,2 @@ * directly JSON-serializable (boolean, number, string, array, plain object)

/**
* Defines a mapping from action types to corresponding action object shapes.
*/
declare type Actions<T extends keyof any = string> = Record<T, Action>;
/**
* An *case reducer* is a reducer function for a speficic action type. Case
* reducers can be composed to full reducers using `createReducer()`.
*
* Unlike a normal Redux reducer, a case reducer is never called with an
* `undefined` state to determine the initial state. Instead, the initial
* state is explicitly specified as an argument to `createReducer()`.
*
* In addition, a case reducer can choose to mutate the passed-in `state`
* value directly instead of returning a new state. This does not actually
* cause the store state to be mutated directly; instead, thanks to
* [immer](https://github.com/mweststrate/immer), the mutations are
* translated to copy operations that result in a new state.
*/
declare type CaseReducer<S = any, A extends Action = AnyAction> = (state: Draft<S>, action: A) => S | void;
/**
* A mapping from action types to case reducers for `createReducer()`.
*/
declare type CaseReducers<S, AS extends Actions> = {
[T in keyof AS]: AS[T] extends Action ? CaseReducer<S, AS[T]> : void;
};
/**
* A utility function that allows defining a reducer as a mapping from action
* type to *case reducer* functions that handle these action types. The
* reducer's initial state is passed as the first argument.
*
* The body of every case reducer is implicitly wrapped with a call to
* `produce()` from the [immer](https://github.com/mweststrate/immer) library.
* This means that rather than returning a new state object, you can also
* mutate the passed-in state object directly; these mutations will then be
* automatically and efficiently translated into copies, giving you both
* convenience and immutability.
*
* @param initialState The initial state to be returned by the reducer.
* @param actionsMap A mapping from action types to action-type-specific
* case redeucers.
*/
declare function createReducer<S, CR extends CaseReducers<S, any> = CaseReducers<S, any>>(initialState: S, actionsMap: CR): Reducer<S>;
/**
* An action creator atttached to a slice.

@@ -302,4 +339,6 @@ *

* as the keys, and action creators will _not_ be generated.
* Alternatively, a callback that receives a *builder* object to define
* case reducers via calls to `builder.addCase(actionCreatorOrType, reducer)`.
*/
extraReducers?: CaseReducers<NoInfer<State>, any>;
extraReducers?: CaseReducers<NoInfer<State>, any> | ((builder: ActionReducerMapBuilder<NoInfer<State>>) => void);
}

@@ -358,2 +397,2 @@ declare type PayloadActions<Types extends keyof any = string> = Record<Types, PayloadAction>;

export { createSelector } from "reselect";
export { ConfigureEnhancersCallback, ConfigureStoreOptions, EnhancedStore, configureStore, PayloadAction, PrepareAction, ActionCreatorWithPreparedPayload, ActionCreatorWithOptionalPayload, ActionCreatorWithoutPayload, ActionCreatorWithPayload, PayloadActionCreator, createAction, getType, Actions, CaseReducer, CaseReducers, createReducer, SliceActionCreator, Slice, CreateSliceOptions, createSlice, isPlain, findNonSerializableValue, SerializableStateInvariantMiddlewareOptions, createSerializableStateInvariantMiddleware, getDefaultMiddleware };
export { ConfigureEnhancersCallback, ConfigureStoreOptions, EnhancedStore, configureStore, PayloadAction, PrepareAction, ActionCreatorWithPreparedPayload, ActionCreatorWithOptionalPayload, ActionCreatorWithoutPayload, ActionCreatorWithPayload, PayloadActionCreator, createAction, getType, Actions, CaseReducer, CaseReducers, createReducer, SliceActionCreator, Slice, CreateSliceOptions, createSlice, isPlain, findNonSerializableValue, SerializableStateInvariantMiddlewareOptions, createSerializableStateInvariantMiddleware, getDefaultMiddleware, ActionReducerMapBuilder };

@@ -5,4 +5,4 @@ 'use strict';

var createNextState = _interopDefault(require('immer'));
var redux = require('redux');
var createNextState = _interopDefault(require('immer'));
var reselect = require('reselect');

@@ -12,2 +12,37 @@ var reduxDevtoolsExtension = require('redux-devtools-extension');

function createReducer(initialState, mapOrBuilderCallback) {
var actionsMap = typeof mapOrBuilderCallback === 'function' ? executeReducerBuilderCallback(mapOrBuilderCallback) : mapOrBuilderCallback;
return function (state, action) {
if (state === void 0) {
state = initialState;
}
// @ts-ignore createNextState() produces an Immutable<Draft<S>> rather
// than an Immutable<S>, and TypeScript cannot find out how to reconcile
// these two types.
return createNextState(state, function (draft) {
var caseReducer = actionsMap[action.type];
return caseReducer ? caseReducer(draft, action) : undefined;
});
};
}
function executeReducerBuilderCallback(builderCallback) {
var actionsMap = {};
var builder = {
addCase: function addCase(typeOrActionCreator, reducer) {
var type = typeof typeOrActionCreator === 'string' ? typeOrActionCreator : typeOrActionCreator.type;
if (type in actionsMap) {
throw new Error('addCase cannot be called with two reducers for the same action type');
}
actionsMap[type] = reducer;
return builder;
}
};
builderCallback(builder);
return actionsMap;
}
function _extends() {

@@ -61,8 +96,2 @@ _extends = Object.assign || function (target) {

}
var NON_SERIALIZABLE_STATE_MESSAGE =
/*#__PURE__*/
['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');
var NON_SERIALIZABLE_ACTION_MESSAGE =
/*#__PURE__*/
['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 findNonSerializableValue(value, path, isSerializable, getEntries) {

@@ -158,3 +187,3 @@ if (path === void 0) {

value = foundActionNonSerializableValue.value;
console.error(NON_SERIALIZABLE_ACTION_MESSAGE, keyPath, value, action);
console.error("A non-serializable value was detected in an action, in the path: `" + keyPath + "`. Value:", value, '\nTake a look at the logic that dispatched this action: ', action, '\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)');
}

@@ -169,3 +198,3 @@

_value = foundStateNonSerializableValue.value;
console.error(NON_SERIALIZABLE_STATE_MESSAGE, _keyPath, _value, action.type);
console.error("A non-serializable value was detected in the state, in the path: `" + _keyPath + "`. Value:", _value, "\nTake a look at the reducer(s) handling this action type: " + action.type + ".\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)");
}

@@ -348,35 +377,2 @@

/**
* A utility function that allows defining a reducer as a mapping from action
* type to *case reducer* functions that handle these action types. The
* reducer's initial state is passed as the first argument.
*
* The body of every case reducer is implicitly wrapped with a call to
* `produce()` from the [immer](https://github.com/mweststrate/immer) library.
* This means that rather than returning a new state object, you can also
* mutate the passed-in state object directly; these mutations will then be
* automatically and efficiently translated into copies, giving you both
* convenience and immutability.
*
* @param initialState The initial state to be returned by the reducer.
* @param actionsMap A mapping from action types to action-type-specific
* case redeucers.
*/
function createReducer(initialState, actionsMap) {
return function (state, action) {
if (state === void 0) {
state = initialState;
}
// @ts-ignore createNextState() produces an Immutable<Draft<S>> rather
// than an Immutable<S>, and TypeScript cannot find out how to reconcile
// these two types.
return createNextState(state, function (draft) {
var caseReducer = actionsMap[action.type];
return caseReducer ? caseReducer(draft, action) : undefined;
});
};
}
function getType$1(slice, actionKey) {

@@ -396,3 +392,3 @@ return slice + "/" + actionKey;

var reducers = options.reducers || {};
var extraReducers = options.extraReducers || {};
var extraReducers = typeof options.extraReducers === 'undefined' ? {} : typeof options.extraReducers === 'function' ? executeReducerBuilderCallback(options.extraReducers) : options.extraReducers;
var reducerNames = Object.keys(reducers);

@@ -399,0 +395,0 @@ var sliceCaseReducersByName = {};

@@ -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 f(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],d=t.concat(s[0]);if(!r(l))return{keyPath:d.join("."),value:l};if("object"==typeof l&&(n=f(l,d,r,o)))return n}return!1}function d(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 p(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 v(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.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 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?d():s,f=o.devTools,p=void 0===f||f,v=o.preloadedState,y=void 0===v?void 0:v,h=o.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,l),m=t.compose;p&&(m=n.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=p,exports.createReducer=v,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=f(n,[],r,o);i&&console.error(l,i.keyPath,i.value,n);var u=t(n),c=f(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?p(i,n):p(i)}));var l=v(r,i({},n,{},c));return{name:t,reducer:l,actions:s,caseReducers:u}},exports.findNonSerializableValue=f,exports.getDefaultMiddleware=d,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 t=e(require("immer")),r=require("redux"),n=require("reselect"),o=require("redux-devtools-extension"),a=e(require("redux-thunk"));function i(e,r){var n="function"==typeof r?u(r):r;return function(r,o){return void 0===r&&(r=e),t(r,(function(e){var t=n[o.type];return t?t(e,o):void 0}))}}function u(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 c(){return(c=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 s(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 f(e){return null==e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||Array.isArray(e)||s(e)}function d(e,t,r,n){var o;if(void 0===t&&(t=[]),void 0===r&&(r=f),!r(e))return{keyPath:t.join(".")||"<root>",value:e};if("object"!=typeof e||null===e)return!1;var a=null!=n?n(e):Object.entries(e),i=Array.isArray(a),u=0;for(a=i?a:a[Symbol.iterator]();;){var c;if(i){if(u>=a.length)break;c=a[u++]}else{if((u=a.next()).done)break;c=u.value}var s=c[1],l=t.concat(c[0]);if(!r(s))return{keyPath:l.join("."),value:s};if("object"==typeof s&&(o=d(s,l,r,n)))return o}return!1}function l(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 p(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 c({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}Object.keys(r).forEach((function(e){"default"!==e&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return r[e]}})})),exports.createNextState=t,Object.defineProperty(exports,"createSelector",{enumerable:!0,get:function(){return n.createSelector}}),exports.configureStore=function(e){var t,n=e||{},a=n.reducer,i=void 0===a?void 0:a,u=n.middleware,f=void 0===u?l():u,d=n.devTools,p=void 0===d||d,y=n.preloadedState,v=void 0===y?void 0:y,h=n.enhancers,b=void 0===h?void 0:h;if("function"==typeof i)t=i;else{if(!s(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=r.combineReducers(i)}var g=r.applyMiddleware.apply(void 0,f),m=r.compose;p&&(m=o.composeWithDevTools(c({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 r.createStore(t,v,j)},exports.createAction=p,exports.createReducer=i,exports.createSerializableStateInvariantMiddleware=function(e){void 0===e&&(e={});var t=e.isSerializable,r=void 0===t?f:t,n=e.getEntries,o=e.ignoredActions,a=void 0===o?[]:o;return function(e){return function(t){return function(o){if(a.length&&-1!==a.indexOf(o.type))return t(o);var i=d(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 u=t(o),c=d(e.getState(),[],r,n);return c&&console.error("A non-serializable value was detected in the state, in the path: `"+c.keyPath+"`. Value:",c.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)"),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 n=e.reducers||{},o=void 0===e.extraReducers?{}:"function"==typeof e.extraReducers?u(e.extraReducers):e.extraReducers,a=Object.keys(n),s={},f={},d={};a.forEach((function(e){var r,o,a=n[e],i=t+"/"+e;"function"==typeof a?r=a:(r=a.reducer,o=a.prepare),s[e]=r,f[i]=r,d[e]=o?p(i,o):p(i)}));var l=i(r,c({},o,{},f));return{name:t,reducer:l,actions:d,caseReducers:s}},exports.findNonSerializableValue=d,exports.getDefaultMiddleware=l,exports.getType=function(e){return""+e},exports.isPlain=f;
//# sourceMappingURL=redux-toolkit.cjs.production.min.js.map

@@ -0,5 +1,5 @@

import createNextState from 'immer';
export { default as createNextState } from 'immer';
import { combineReducers, applyMiddleware, createStore, compose } from 'redux';
export * from 'redux';
import createNextState from 'immer';
export { default as createNextState } from 'immer';
export { createSelector } from 'reselect';

@@ -9,2 +9,37 @@ import { composeWithDevTools } from 'redux-devtools-extension';

function createReducer(initialState, mapOrBuilderCallback) {
var actionsMap = typeof mapOrBuilderCallback === 'function' ? executeReducerBuilderCallback(mapOrBuilderCallback) : mapOrBuilderCallback;
return function (state, action) {
if (state === void 0) {
state = initialState;
}
// @ts-ignore createNextState() produces an Immutable<Draft<S>> rather
// than an Immutable<S>, and TypeScript cannot find out how to reconcile
// these two types.
return createNextState(state, function (draft) {
var caseReducer = actionsMap[action.type];
return caseReducer ? caseReducer(draft, action) : undefined;
});
};
}
function executeReducerBuilderCallback(builderCallback) {
var actionsMap = {};
var builder = {
addCase: function addCase(typeOrActionCreator, reducer) {
var type = typeof typeOrActionCreator === 'string' ? typeOrActionCreator : typeOrActionCreator.type;
if (type in actionsMap) {
throw new Error('addCase cannot be called with two reducers for the same action type');
}
actionsMap[type] = reducer;
return builder;
}
};
builderCallback(builder);
return actionsMap;
}
function _extends() {

@@ -58,8 +93,2 @@ _extends = Object.assign || function (target) {

}
var NON_SERIALIZABLE_STATE_MESSAGE =
/*#__PURE__*/
['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');
var NON_SERIALIZABLE_ACTION_MESSAGE =
/*#__PURE__*/
['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 findNonSerializableValue(value, path, isSerializable, getEntries) {

@@ -155,3 +184,3 @@ if (path === void 0) {

value = foundActionNonSerializableValue.value;
console.error(NON_SERIALIZABLE_ACTION_MESSAGE, keyPath, value, action);
console.error("A non-serializable value was detected in an action, in the path: `" + keyPath + "`. Value:", value, '\nTake a look at the logic that dispatched this action: ', action, '\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)');
}

@@ -166,3 +195,3 @@

_value = foundStateNonSerializableValue.value;
console.error(NON_SERIALIZABLE_STATE_MESSAGE, _keyPath, _value, action.type);
console.error("A non-serializable value was detected in the state, in the path: `" + _keyPath + "`. Value:", _value, "\nTake a look at the reducer(s) handling this action type: " + action.type + ".\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)");
}

@@ -345,35 +374,2 @@

/**
* A utility function that allows defining a reducer as a mapping from action
* type to *case reducer* functions that handle these action types. The
* reducer's initial state is passed as the first argument.
*
* The body of every case reducer is implicitly wrapped with a call to
* `produce()` from the [immer](https://github.com/mweststrate/immer) library.
* This means that rather than returning a new state object, you can also
* mutate the passed-in state object directly; these mutations will then be
* automatically and efficiently translated into copies, giving you both
* convenience and immutability.
*
* @param initialState The initial state to be returned by the reducer.
* @param actionsMap A mapping from action types to action-type-specific
* case redeucers.
*/
function createReducer(initialState, actionsMap) {
return function (state, action) {
if (state === void 0) {
state = initialState;
}
// @ts-ignore createNextState() produces an Immutable<Draft<S>> rather
// than an Immutable<S>, and TypeScript cannot find out how to reconcile
// these two types.
return createNextState(state, function (draft) {
var caseReducer = actionsMap[action.type];
return caseReducer ? caseReducer(draft, action) : undefined;
});
};
}
function getType$1(slice, actionKey) {

@@ -393,3 +389,3 @@ return slice + "/" + actionKey;

var reducers = options.reducers || {};
var extraReducers = options.extraReducers || {};
var extraReducers = typeof options.extraReducers === 'undefined' ? {} : typeof options.extraReducers === 'function' ? executeReducerBuilderCallback(options.extraReducers) : options.extraReducers;
var reducerNames = Object.keys(reducers);

@@ -396,0 +392,0 @@ var sliceCaseReducersByName = {};

@@ -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).RTK={})}(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){return function(){return t(e.apply(this,arguments))}}function c(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function f(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){c(e,t,r[t])}))}return e}function s(){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 l(){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 f({},r,{dispatch:n=s.apply(void 0,i)(r.dispatch)})}}}var p,d=s,h="undefined"!=typeof Symbol?Symbol("immer-nothing"):((p={})["immer-nothing"]=!0,p),y="undefined"!=typeof Symbol&&Symbol.for?Symbol.for("immer-draftable"):"__$immer_draftable",v="undefined"!=typeof Symbol&&Symbol.for?Symbol.for("immer-state"):"__$immer_state";function b(e){return!!e&&!!e[v]}function g(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[y]||!!e.constructor[y])}var m=Object.assign||function(e,t){for(var r in t)P(t,r)&&(e[r]=t[r]);return e},w="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames;function O(e,t){if(void 0===t&&(t=!1),Array.isArray(e))return e.slice();var r=Object.create(Object.getPrototypeOf(e));return w(e).forEach((function(n){if(n!==v){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 E(e,t){if(Array.isArray(e))for(var r=0;r<e.length;r++)t(r,e[r],e);else w(e).forEach((function(r){return t(r,e[r],e)}))}function j(e,t){var r=Object.getOwnPropertyDescriptor(e,t);return!!r&&r.enumerable}function P(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function A(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function z(e){if(!g(e))return e;if(Array.isArray(e))return e.map(z);var t=Object.create(Object.getPrototypeOf(e));for(var r in e)t[r]=z(e[r]);return t}function x(e){if(g(e)&&!b(e)&&!Object.isFrozen(e))if(Object.freeze(e),Array.isArray(e))e.forEach(x);else for(var t in e)x(e[t])}var S=function(e){this.drafts=[],this.parent=e,this.canAutoFreeze=!0,this.patches=null};function _(e){e[v].revoke()}S.prototype.usePatches=function(e){e&&(this.patches=[],this.inversePatches=[],this.patchListener=e)},S.prototype.revoke=function(){this.leave(),this.drafts.forEach(_),this.drafts=null},S.prototype.leave=function(){this===S.current&&(S.current=this.parent)},S.current=null,S.enter=function(){return this.current=new S(this.current)};var k={};function T(){this.revoked=!0}function N(e){return e.copy||e.base}function D(e,t){var r=e[v];if(r&&!r.finalizing){r.finalizing=!0;var n=e[t];return r.finalizing=!1,n}return e[t]}function I(e){e.modified||(e.modified=!0,e.parent&&I(e.parent))}function R(e){e.copy||(e.copy=F(e.base))}function F(e){var t=e&&e[v];if(t){t.finalizing=!0;var r=O(t.draft,!0);return t.finalizing=!1,r}return O(e)}function C(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(N(e)))}function U(e){for(var t=e.length-1;t>=0;t--){var r=e[t][v];r.modified||(Array.isArray(r.base)?L(r)&&I(r):M(r)&&I(r))}}function M(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[v];if(c?c.base!==a:!A(u,a))return!0}return n.length!==Object.keys(t).length}function L(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 W=Object.freeze({willFinalize:function(e,t,r){e.drafts.forEach((function(e){e[v].finalizing=!0})),r?b(t)&&t[v].scope===e&&U(e.drafts):(e.patches&&function e(t){if(t&&"object"==typeof t){var r=t[v];if(r){var n=r.base,o=r.draft,i=r.assigned;if(Array.isArray(t)){if(L(r)){if(I(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,I(r))})),Object.keys(n).forEach((function(e){void 0!==o[e]||P(o,e)||(i[e]=!1,I(r))}))}}}(e.drafts[0]),U(e.drafts))},createProxy:function e(t,r){var n=Array.isArray(t),o=F(t);E(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){C(t);var n=D(N(t),r);return t.finalizing?n:n===D(t.base,r)&&g(n)?(R(t),t.copy[r]=e(n,t)):n}(this[v],r)},set:function(e){!function(e,t,r){if(C(e),e.assigned[t]=!0,!e.modified){if(A(r,D(N(e),t)))return;I(e),R(e)}e.copy[t]=r}(this[v],r,e)}},Object.defineProperty(t,r,o)}(o,r,n||j(t,r))}));var i=r?r.scope:S.current;return Object.defineProperty(o,v,{value:{scope:i,modified:!1,finalizing:!1,finalized:!1,assigned:{},parent:r,base:t,draft:o,copy:null,revoke:T,revoked:!1},enumerable:!1,writable:!0}),i.drafts.push(o),o}});function K(e,t){var r=t?t.scope:S.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],V):Proxy.revocable(n,X),i=o.revoke,a=o.proxy;return n.draft=a,n.revoke=i,r.drafts.push(a),a}var X={get:function(e,t){if(t===v)return e;var r=e.drafts;if(!e.modified&&P(r,t))return r[t];var n=q(e)[t];if(e.finalized||!g(n))return n;if(e.modified){if(n!==B(e.base,t))return n;r=e.copy}return r[t]=K(n,e)},has:function(e,t){return t in q(e)},ownKeys:function(e){return Reflect.ownKeys(q(e))},set:function(e,t,r){if(!e.modified){var n=B(e.base,t);if(r?A(n,r)||r===e.drafts[t]:A(n,r)&&t in e.base)return!0;Y(e)}return e.assigned[t]=!0,e.copy[t]=r,!0},deleteProperty:function(e,t){return void 0!==B(e.base,t)||t in e.base?(e.assigned[t]=!1,Y(e)):e.assigned[t]&&delete e.assigned[t],e.copy&&delete e.copy[t],!0},getOwnPropertyDescriptor:function(e,t){var r=q(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")}},V={};function q(e){return e.copy||e.base}function B(e,t){var r=e[v],n=Reflect.getOwnPropertyDescriptor(r?q(r):e,t);return n&&n.value}function Y(e){e.modified||(e.modified=!0,e.copy=m(O(e.base),e.drafts),e.drafts=null,e.parent&&Y(e.parent))}E(X,(function(e,t){V[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),V.deleteProperty=function(e,t){if(isNaN(parseInt(t)))throw new Error("Immer only supports deleting array indices");return X.deleteProperty.call(this,e[0],t)},V.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 X.set.call(this,e[0],t,r)};var $=Object.freeze({willFinalize:function(){},createProxy:K}),G=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=z(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},H={useProxies:"undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,autoFreeze:"undefined"==typeof process&&"verifyMinified"===function(){}.name,onAssign:null,onDelete:null,onCopy:null},J=function(e){m(this,H,e),this.setUseProxies(this.useProxies),this.produce=this.produce.bind(this)};J.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(g(e)){var u=S.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))!==h)return void 0===n&&(n=e),this.maybeFreeze(n,!0),n},J.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]},J.prototype.createDraft=function(e){if(!g(e))throw new Error("First argument to `createDraft` must be a plain object, an array, or an immerable object");var t=S.enter(),r=this.createProxy(e);return r[v].isManual=!0,t.leave(),r},J.prototype.finishDraft=function(e,t){var r=e&&e[v];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)},J.prototype.setAutoFreeze=function(e){this.autoFreeze=e},J.prototype.setUseProxies=function(e){this.useProxies=e,m(this,e?$:W)},J.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 b(e)?G(e,t):this.produce(e,(function(e){return G(e,t.slice(r+1))}))},J.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[v].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.");g(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[v].base}))}else e=this.finalize(r,[],t);return t.revoke(),t.patches&&t.patchListener(t.patches,t.inversePatches),e!==h?e:void 0},J.prototype.finalize=function(e,t,r){var n=this,o=e[v];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;E(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;E(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},J.prototype.finalizeTree=function(e,t,r){var n=this,o=e[v];o&&(this.useProxies||(o.copy=O(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(b(c)){var l=s&&i&&!o.assigned[u]?t.concat(u):null;if(b(c=n.finalize(c,l,r))&&(r.canAutoFreeze=!1),Array.isArray(f)||j(f,u)?f[u]=c:Object.defineProperty(f,u,{value:c}),s&&c===o.base[u])return}else{if(s&&A(c,o.base[u]))return;g(c)&&!Object.isFrozen(c)&&(E(c,a),n.maybeFreeze(c))}s&&n.onAssign&&n.onAssign(o,u,c)};return E(e,a),e},J.prototype.maybeFreeze=function(e,t){void 0===t&&(t=!1),this.autoFreeze&&!b(e)&&(t?x(e):Object.freeze(e))};var Q=new J,Z=Q.produce;function ee(e,t){return e===t}function te(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 re(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}Q.produceWithPatches.bind(Q),Q.setAutoFreeze.bind(Q),Q.setUseProxies.bind(Q),Q.applyPatches.bind(Q),Q.createDraft.bind(Q),Q.finishDraft.bind(Q);var ne=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=re(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]:ee,r=null,n=null;return function(){return te(t,r,arguments)||(n=e.apply(null,arguments)),r=arguments,n}}));function oe(){return(oe=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 ie,ae=function(e,t){return function(e,t){var r=d;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}();(ie=ae)&&ie.__esModule&&Object.prototype.hasOwnProperty.call(ie,"default");var ue=ae.composeWithDevTools;function ce(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 fe(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 se=fe();function le(e){return null==e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||Array.isArray(e)||ce(e)}se.withExtraArgument=fe;var pe=["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"),de=["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 he(e,t,r,n){var o;if(void 0===t&&(t=[]),void 0===r&&(r=le),!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=he(f,s,r,n)))return o}return!1}function ye(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(se):n.push(se.withExtraArgument(r.extraArgument))),n}function ve(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 oe({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 be(e,t){return function(r,n){return void 0===r&&(r=e),Z(r,(function(e){var r=t[n.type];return r?r(e,n):void 0}))}}e.__DO_NOT_USE__ActionTypes=n,e.applyMiddleware=l,e.bindActionCreators=function(e,t){if("function"==typeof e)return u(e,t);if("object"!=typeof e||null===e)throw new Error("bindActionCreators expected an object or a function, instead received "+(null===e?"null":typeof e)+'. Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');for(var r=Object.keys(e),n={},o=0;o<r.length;o++){var i=r[o],a=e[i];"function"==typeof a&&(n[i]=u(a,t))}return n},e.combineReducers=a,e.compose=s,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?ye():u,f=r.devTools,p=void 0===f||f,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(!ce(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=l.apply(void 0,c),g=s;p&&(g=ue(oe({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=ve,e.createNextState=Z,e.createReducer=be,e.createSelector=ne,e.createSerializableStateInvariantMiddleware=function(e){void 0===e&&(e={});var t=e.isSerializable,r=void 0===t?le: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=he(o,[],r,n);a&&console.error(de,a.keyPath,a.value,o);var u=t(o),c=he(e.getState(),[],r,n);return c&&console.error(pe,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?ve(f,o):ve(f)}));var f=be(r,oe({},o,{},u));return{name:t,reducer:f,actions:c,caseReducers:a}},e.createStore=o,e.findNonSerializableValue=he,e.getDefaultMiddleware=ye,e.getType=function(e){return""+e},e.isPlain=le}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).RTK={})}(this,(function(e){"use strict";var t,r="undefined"!=typeof Symbol?Symbol("immer-nothing"):((t={})["immer-nothing"]=!0,t),n="undefined"!=typeof Symbol&&Symbol.for?Symbol.for("immer-draftable"):"__$immer_draftable",o="undefined"!=typeof Symbol&&Symbol.for?Symbol.for("immer-state"):"__$immer_state";function i(e){return!!e&&!!e[o]}function a(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[n]||!!e.constructor[n])}var u=Object.assign||function(e,t){for(var r in t)p(t,r)&&(e[r]=t[r]);return e},c="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames;function f(e,t){if(void 0===t&&(t=!1),Array.isArray(e))return e.slice();var r=Object.create(Object.getPrototypeOf(e));return c(e).forEach((function(n){if(n!==o){var i=Object.getOwnPropertyDescriptor(e,n),a=i.value;if(i.get){if(!t)throw new Error("Immer drafts cannot have computed properties");a=i.get.call(e)}i.enumerable?r[n]=a:Object.defineProperty(r,n,{value:a,writable:!0,configurable:!0})}})),r}function s(e,t){if(Array.isArray(e))for(var r=0;r<e.length;r++)t(r,e[r],e);else c(e).forEach((function(r){return t(r,e[r],e)}))}function l(e,t){var r=Object.getOwnPropertyDescriptor(e,t);return!!r&&r.enumerable}function p(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function d(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function h(e){if(!a(e))return e;if(Array.isArray(e))return e.map(h);var t=Object.create(Object.getPrototypeOf(e));for(var r in e)t[r]=h(e[r]);return t}function y(e){if(a(e)&&!i(e)&&!Object.isFrozen(e))if(Object.freeze(e),Array.isArray(e))e.forEach(y);else for(var t in e)y(e[t])}var v=function(e){this.drafts=[],this.parent=e,this.canAutoFreeze=!0,this.patches=null};function b(e){e[o].revoke()}v.prototype.usePatches=function(e){e&&(this.patches=[],this.inversePatches=[],this.patchListener=e)},v.prototype.revoke=function(){this.leave(),this.drafts.forEach(b),this.drafts=null},v.prototype.leave=function(){this===v.current&&(v.current=this.parent)},v.current=null,v.enter=function(){return this.current=new v(this.current)};var g={};function w(){this.revoked=!0}function m(e){return e.copy||e.base}function O(e,t){var r=e[o];if(r&&!r.finalizing){r.finalizing=!0;var n=e[t];return r.finalizing=!1,n}return e[t]}function E(e){e.modified||(e.modified=!0,e.parent&&E(e.parent))}function P(e){e.copy||(e.copy=j(e.base))}function j(e){var t=e&&e[o];if(t){t.finalizing=!0;var r=f(t.draft,!0);return t.finalizing=!1,r}return f(e)}function A(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(m(e)))}function x(e){for(var t=e.length-1;t>=0;t--){var r=e[t][o];r.modified||(Array.isArray(r.base)?S(r)&&E(r):z(r)&&E(r))}}function z(e){for(var t=e.base,r=e.draft,n=Object.keys(r),i=n.length-1;i>=0;i--){var a=n[i],u=t[a];if(void 0===u&&!p(t,a))return!0;var c=r[a],f=c&&c[o];if(f?f.base!==u:!d(c,u))return!0}return n.length!==Object.keys(t).length}function S(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 _=Object.freeze({willFinalize:function(e,t,r){e.drafts.forEach((function(e){e[o].finalizing=!0})),r?i(t)&&t[o].scope===e&&x(e.drafts):(e.patches&&function e(t){if(t&&"object"==typeof t){var r=t[o];if(r){var n=r.base,i=r.draft,a=r.assigned;if(Array.isArray(t)){if(S(r)){if(E(r),a.length=!0,i.length<n.length)for(var u=i.length;u<n.length;u++)a[u]=!1;else for(var c=n.length;c<i.length;c++)a[c]=!0;for(var f=0;f<i.length;f++)void 0===a[f]&&e(i[f])}}else Object.keys(i).forEach((function(t){void 0!==n[t]||p(n,t)?a[t]||e(i[t]):(a[t]=!0,E(r))})),Object.keys(n).forEach((function(e){void 0!==i[e]||p(i,e)||(a[e]=!1,E(r))}))}}}(e.drafts[0]),x(e.drafts))},createProxy:function e(t,r){var n=Array.isArray(t),i=j(t);s(i,(function(r){!function(t,r,n){var i=g[r];i?i.enumerable=n:g[r]=i={configurable:!0,enumerable:n,get:function(){return function(t,r){A(t);var n=O(m(t),r);return t.finalizing?n:n===O(t.base,r)&&a(n)?(P(t),t.copy[r]=e(n,t)):n}(this[o],r)},set:function(e){!function(e,t,r){if(A(e),e.assigned[t]=!0,!e.modified){if(d(r,O(m(e),t)))return;E(e),P(e)}e.copy[t]=r}(this[o],r,e)}},Object.defineProperty(t,r,i)}(i,r,n||l(t,r))}));var u=r?r.scope:v.current;return Object.defineProperty(i,o,{value:{scope:u,modified:!1,finalizing:!1,finalized:!1,assigned:{},parent:r,base:t,draft:i,copy:null,revoke:w,revoked:!1},enumerable:!1,writable:!0}),u.drafts.push(i),i}});function k(e,t){var r=t?t.scope:v.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],R):Proxy.revocable(n,T),i=o.revoke,a=o.proxy;return n.draft=a,n.revoke=i,r.drafts.push(a),a}var T={get:function(e,t){if(t===o)return e;var r=e.drafts;if(!e.modified&&p(r,t))return r[t];var n=N(e)[t];if(e.finalized||!a(n))return n;if(e.modified){if(n!==D(e.base,t))return n;r=e.copy}return r[t]=k(n,e)},has:function(e,t){return t in N(e)},ownKeys:function(e){return Reflect.ownKeys(N(e))},set:function(e,t,r){if(!e.modified){var n=D(e.base,t);if(r?d(n,r)||r===e.drafts[t]:d(n,r)&&t in e.base)return!0;I(e)}return e.assigned[t]=!0,e.copy[t]=r,!0},deleteProperty:function(e,t){return void 0!==D(e.base,t)||t in e.base?(e.assigned[t]=!1,I(e)):e.assigned[t]&&delete e.assigned[t],e.copy&&delete e.copy[t],!0},getOwnPropertyDescriptor:function(e,t){var r=N(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")}},R={};function N(e){return e.copy||e.base}function D(e,t){var r=e[o],n=Reflect.getOwnPropertyDescriptor(r?N(r):e,t);return n&&n.value}function I(e){e.modified||(e.modified=!0,e.copy=u(f(e.base),e.drafts),e.drafts=null,e.parent&&I(e.parent))}s(T,(function(e,t){R[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),R.deleteProperty=function(e,t){if(isNaN(parseInt(t)))throw new Error("Immer only supports deleting array indices");return T.deleteProperty.call(this,e[0],t)},R.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 T.set.call(this,e[0],t,r)};var F=Object.freeze({willFinalize:function(){},createProxy:k}),C=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=h(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},U={useProxies:"undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,autoFreeze:"undefined"==typeof process&&"verifyMinified"===function(){}.name,onAssign:null,onDelete:null,onCopy:null},M=function(e){u(this,U,e),this.setUseProxies(this.useProxies),this.produce=this.produce.bind(this)};M.prototype.produce=function(e,t,n){var o,i=this;if("function"==typeof e&&"function"!=typeof t){var u=t;t=e;var c=this;return function(e){var r=this;void 0===e&&(e=u);for(var n=[],o=arguments.length-1;o-- >0;)n[o]=arguments[o+1];return c.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!==n&&"function"!=typeof n)throw new Error("The third argument to `produce` must be a function or undefined");if(a(e)){var f=v.enter(),s=this.createProxy(e),l=!0;try{o=t(s),l=!1}finally{l?f.revoke():f.leave()}return o instanceof Promise?o.then((function(e){return f.usePatches(n),i.processResult(e,f)}),(function(e){throw f.revoke(),e})):(f.usePatches(n),this.processResult(o,f))}if((o=t(e))!==r)return void 0===o&&(o=e),this.maybeFreeze(o,!0),o},M.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]},M.prototype.createDraft=function(e){if(!a(e))throw new Error("First argument to `createDraft` must be a plain object, an array, or an immerable object");var t=v.enter(),r=this.createProxy(e);return r[o].isManual=!0,t.leave(),r},M.prototype.finishDraft=function(e,t){var r=e&&e[o];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)},M.prototype.setAutoFreeze=function(e){this.autoFreeze=e},M.prototype.setUseProxies=function(e){this.useProxies=e,u(this,e?F:_)},M.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 i(e)?C(e,t):this.produce(e,(function(e){return C(e,t.slice(r+1))}))},M.prototype.processResult=function(e,t){var n=t.drafts[0],i=void 0!==e&&e!==n;if(this.willFinalize(t,e,i),i){if(n[o].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.");a(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:n[o].base}))}else e=this.finalize(n,[],t);return t.revoke(),t.patches&&t.patchListener(t.patches,t.inversePatches),e!==r?e:void 0},M.prototype.finalize=function(e,t,r){var n=this,i=e[o];if(!i)return Object.isFrozen(e)?e:this.finalizeTree(e,null,r);if(i.scope!==r)return e;if(!i.modified)return this.maybeFreeze(i.base,!0),i.base;if(!i.finalized){if(i.finalized=!0,this.finalizeTree(i.draft,t,r),this.onDelete)if(this.useProxies){var a=i.assigned;for(var u in a)a[u]||this.onDelete(i,u)}else{var c=i.copy;s(i.base,(function(e){p(c,e)||n.onDelete(i,e)}))}this.onCopy&&this.onCopy(i),this.autoFreeze&&r.canAutoFreeze&&Object.freeze(i.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;s(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)}(i,t,r.patches,r.inversePatches)}return i.copy},M.prototype.finalizeTree=function(e,t,r){var n=this,u=e[o];u&&(this.useProxies||(u.copy=f(u.draft,!0)),e=u.copy);var c=!!t&&!!r.patches,p=function(o,f,h){if(f===h)throw Error("Immer forbids circular references");var y=!!u&&h===e;if(i(f)){var v=y&&c&&!u.assigned[o]?t.concat(o):null;if(i(f=n.finalize(f,v,r))&&(r.canAutoFreeze=!1),Array.isArray(h)||l(h,o)?h[o]=f:Object.defineProperty(h,o,{value:f}),y&&f===u.base[o])return}else{if(y&&d(f,u.base[o]))return;a(f)&&!Object.isFrozen(f)&&(s(f,p),n.maybeFreeze(f))}y&&n.onAssign&&n.onAssign(u,o,f)};return s(e,p),e},M.prototype.maybeFreeze=function(e,t){void 0===t&&(t=!1),this.autoFreeze&&!i(e)&&(t?y(e):Object.freeze(e))};var L=new M,W=L.produce;function K(e,t){var r="function"==typeof t?X(t):t;return function(t,n){return void 0===t&&(t=e),W(t,(function(e){var t=r[n.type];return t?t(e,n):void 0}))}}function X(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}L.produceWithPatches.bind(L),L.setAutoFreeze.bind(L),L.setUseProxies.bind(L),L.applyPatches.bind(L),L.createDraft.bind(L),L.finishDraft.bind(L);var V=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}(),q=function(){return Math.random().toString(36).substring(7).split("").join(".")},B={INIT:"@@redux/INIT"+q(),REPLACE:"@@redux/REPLACE"+q(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+q()}};function Y(e,t,r){var n;if("function"==typeof t&&"function"==typeof r||"function"==typeof r&&"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 t&&void 0===r&&(r=t,t=void 0),void 0!==r){if("function"!=typeof r)throw new Error("Expected the enhancer to be a function.");return r(Y)(e,t)}if("function"!=typeof e)throw new Error("Expected the reducer to be a function.");var o=e,i=t,a=[],u=a,c=!1;function f(){u===a&&(u=a.slice())}function s(){if(c)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 i}function l(e){if("function"!=typeof e)throw new Error("Expected the listener to be a function.");if(c)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 f(),u.push(e),function(){if(t){if(c)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,f();var r=u.indexOf(e);u.splice(r,1)}}}function p(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(c)throw new Error("Reducers may not dispatch actions.");try{c=!0,i=o(i,e)}finally{c=!1}for(var t=a=u,r=0;r<t.length;r++)(0,t[r])();return e}return p({type:B.INIT}),(n={dispatch:p,subscribe:l,getState:s,replaceReducer:function(e){if("function"!=typeof e)throw new Error("Expected the nextReducer to be a function.");o=e,p({type:B.REPLACE})}})[V]=function(){var e,t=l;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new TypeError("Expected the observer to be an object.");function r(){e.next&&e.next(s())}return r(),{unsubscribe:t(r)}}})[V]=function(){return this},e},n}function $(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 G(e){for(var t=Object.keys(e),r={},n=0;n<t.length;n++){var o=t[n];"function"==typeof e[o]&&(r[o]=e[o])}var i,a=Object.keys(r);try{!function(e){Object.keys(e).forEach((function(t){var r=e[t];if(void 0===r(void 0,{type:B.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:B.PROBE_UNKNOWN_ACTION()}))throw new Error('Reducer "'+t+"\" returned undefined when probed with a random type. Don't try to handle "+B.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){i=e}return function(e,t){if(void 0===e&&(e={}),i)throw i;for(var n=!1,o={},u=0;u<a.length;u++){var c=a[u],f=e[c],s=(0,r[c])(f,t);if(void 0===s){var l=$(c,t);throw new Error(l)}o[c]=s,n=n||s!==f}return n?o:e}}function H(e,t){return function(){return t(e.apply(this,arguments))}}function J(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Q(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){J(e,t,r[t])}))}return e}function Z(){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 ee(){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 Q({},r,{dispatch:n=Z.apply(void 0,i)(r.dispatch)})}}}var te=Z;function re(e,t){return e===t}function ne(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 oe(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}var ie=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=oe(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]:re,r=null,n=null;return function(){return ne(t,r,arguments)||(n=e.apply(null,arguments)),r=arguments,n}}));function ae(){return(ae=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 ue,ce=function(e,t){return function(e,t){var r=te;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}();(ue=ce)&&ue.__esModule&&Object.prototype.hasOwnProperty.call(ue,"default");var fe=ce.composeWithDevTools;function se(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 le(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 pe=le();function de(e){return null==e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||Array.isArray(e)||se(e)}function he(e,t,r,n){var o;if(void 0===t&&(t=[]),void 0===r&&(r=de),!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=he(f,s,r,n)))return o}return!1}function ye(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(pe):n.push(pe.withExtraArgument(r.extraArgument))),n}function ve(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 ae({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}pe.withExtraArgument=le,e.__DO_NOT_USE__ActionTypes=B,e.applyMiddleware=ee,e.bindActionCreators=function(e,t){if("function"==typeof e)return H(e,t);if("object"!=typeof e||null===e)throw new Error("bindActionCreators expected an object or a function, instead received "+(null===e?"null":typeof e)+'. Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');for(var r=Object.keys(e),n={},o=0;o<r.length;o++){var i=r[o],a=e[i];"function"==typeof a&&(n[i]=H(a,t))}return n},e.combineReducers=G,e.compose=Z,e.configureStore=function(e){var t,r=e||{},n=r.reducer,o=void 0===n?void 0:n,i=r.middleware,a=void 0===i?ye():i,u=r.devTools,c=void 0===u||u,f=r.preloadedState,s=void 0===f?void 0:f,l=r.enhancers,p=void 0===l?void 0:l;if("function"==typeof o)t=o;else{if(!se(o))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=G(o)}var d=ee.apply(void 0,a),h=Z;c&&(h=fe(ae({trace:!1},"object"==typeof c&&c)));var y=[d];return Array.isArray(p)?y=[d].concat(p):"function"==typeof p&&(y=p(y)),Y(t,s,h.apply(void 0,y))},e.createAction=ve,e.createNextState=W,e.createReducer=K,e.createSelector=ie,e.createSerializableStateInvariantMiddleware=function(e){void 0===e&&(e={});var t=e.isSerializable,r=void 0===t?de: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=he(o,[],r,n);a&&console.error("A non-serializable value was detected in an action, in the path: `"+a.keyPath+"`. Value:",a.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 u=t(o),c=he(e.getState(),[],r,n);return c&&console.error("A non-serializable value was detected in the state, in the path: `"+c.keyPath+"`. Value:",c.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)"),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=void 0===e.extraReducers?{}:"function"==typeof e.extraReducers?X(e.extraReducers):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?ve(f,o):ve(f)}));var f=K(r,ae({},o,{},u));return{name:t,reducer:f,actions:c,caseReducers:a}},e.createStore=Y,e.findNonSerializableValue=he,e.getDefaultMiddleware=ye,e.getType=function(e){return""+e},e.isPlain=de}));
//# sourceMappingURL=redux-toolkit.umd.min.js.map
{
"name": "@reduxjs/toolkit",
"version": "1.0.4",
"version": "1.1.0",
"description": "The official, opinionated, batteries-included toolset for efficient Redux development",

@@ -5,0 +5,0 @@ "repository": "https://github.com/reduxjs/redux-toolkit",

# Redux Toolkit
[![build status](https://img.shields.io/travis/reduxjs/toolkit/master.svg?style=flat-square)](https://travis-ci.org/reduxjs/redux-toolkit)
[![build status](https://img.shields.io/travis/reduxjs/redux-toolkit/master.svg?style=flat-square)](https://travis-ci.org/reduxjs/redux-toolkit)
[![npm version](https://img.shields.io/npm/v/@reduxjs/toolkit.svg?style=flat-square)](https://www.npmjs.com/package/@reduxjs/toolkit)
[![npm downloads](https://img.shields.io/npm/dm/@reduxjs/toolkit.svg?style=flat-square)](https://www.npmjs.com/package/@reduxjs/toolkit) (RTK)
[![npm downloads](https://img.shields.io/npm/dm/redux-starter-kit.svg?style=flat-square)](https://www.npmjs.com/package/redux-starter-kit) (RSK)
[![npm downloads](https://img.shields.io/npm/dm/@reduxjs/toolkit.svg?style=flat-square&label=RTK+downloads)](https://www.npmjs.com/package/@reduxjs/toolkit)
[![npm downloads](https://img.shields.io/npm/dm/redux-starter-kit.svg?style=flat-square&label=RSK+downloads)](https://www.npmjs.com/package/redux-starter-kit)

@@ -8,0 +8,0 @@ **The official, opinionated, batteries-included toolset for efficient Redux development**

import { createReducer, CaseReducer } from './createReducer'
import { PayloadAction } from './createAction'
import { PayloadAction, createAction } from './createAction'
import { Reducer } from 'redux'

@@ -77,2 +77,69 @@

})
describe('alternative builder callback for actionMap', () => {
const increment = createAction<number, 'increment'>('increment')
const decrement = createAction<number, 'decrement'>('decrement')
test('can be used with ActionCreators', () => {
const reducer = createReducer(0, builder =>
builder
.addCase(increment, (state, action) => state + action.payload)
.addCase(decrement, (state, action) => state - action.payload)
)
expect(reducer(0, increment(5))).toBe(5)
expect(reducer(5, decrement(5))).toBe(0)
})
test('can be used with string types', () => {
const reducer = createReducer(0, builder =>
builder
.addCase(
'increment',
(state, action: { type: 'increment'; payload: number }) =>
state + action.payload
)
.addCase(
'decrement',
(state, action: { type: 'decrement'; payload: number }) =>
state - action.payload
)
)
expect(reducer(0, increment(5))).toBe(5)
expect(reducer(5, decrement(5))).toBe(0)
})
test('can be used with ActionCreators and string types combined', () => {
const reducer = createReducer(0, builder =>
builder
.addCase(increment, (state, action) => state + action.payload)
.addCase(
'decrement',
(state, action: { type: 'decrement'; payload: number }) =>
state - action.payload
)
)
expect(reducer(0, increment(5))).toBe(5)
expect(reducer(5, decrement(5))).toBe(0)
})
test('will throw if the same type is used twice', () => {
expect(() =>
createReducer(0, builder =>
builder
.addCase(increment, (state, action) => state + action.payload)
.addCase(increment, (state, action) => state + action.payload)
.addCase(decrement, (state, action) => state - action.payload)
)
).toThrowErrorMatchingInlineSnapshot(
`"addCase cannot be called with two reducers for the same action type"`
)
expect(() =>
createReducer(0, builder =>
builder
.addCase(increment, (state, action) => state + action.payload)
.addCase('increment', state => state + 1)
.addCase(decrement, (state, action) => state - action.payload)
)
).toThrowErrorMatchingInlineSnapshot(
`"addCase cannot be called with two reducers for the same action type"`
)
})
})
})

@@ -79,0 +146,0 @@

import createNextState, { Draft } from 'immer'
import { AnyAction, Action, Reducer } from 'redux'
import {
executeReducerBuilderCallback,
ActionReducerMapBuilder
} from './mapBuilders'

@@ -10,3 +14,3 @@ /**

/**
* An *case reducer* is a reducer function for a speficic action type. Case
* An *case reducer* is a reducer function for a specific action type. Case
* reducers can be composed to full reducers using `createReducer()`.

@@ -50,3 +54,3 @@ *

* @param actionsMap A mapping from action types to action-type-specific
* case redeucers.
* case reducers.
*/

@@ -56,3 +60,34 @@ export function createReducer<

CR extends CaseReducers<S, any> = CaseReducers<S, any>
>(initialState: S, actionsMap: CR): Reducer<S> {
>(initialState: S, actionsMap: CR): Reducer<S>
/**
* A utility function that allows defining a reducer as a mapping from action
* type to *case reducer* functions that handle these action types. The
* reducer's initial state is passed as the first argument.
*
* The body of every case reducer is implicitly wrapped with a call to
* `produce()` from the [immer](https://github.com/mweststrate/immer) library.
* This means that rather than returning a new state object, you can also
* mutate the passed-in state object directly; these mutations will then be
* automatically and efficiently translated into copies, giving you both
* convenience and immutability.
* @param initialState The initial state to be returned by the reducer.
* @param builderCallback A callback that receives a *builder* object to define
* case reducers via calls to `builder.addCase(actionCreatorOrType, reducer)`.
*/
export function createReducer<S>(
initialState: S,
builderCallback: (builder: ActionReducerMapBuilder<S>) => void
): Reducer<S>
export function createReducer<S>(
initialState: S,
mapOrBuilderCallback:
| CaseReducers<S, any>
| ((builder: ActionReducerMapBuilder<S>) => void)
): Reducer<S> {
let actionsMap =
typeof mapOrBuilderCallback === 'function'
? executeReducerBuilderCallback(mapOrBuilderCallback)
: mapOrBuilderCallback
return function(state = initialState, action): S {

@@ -59,0 +94,0 @@ // @ts-ignore createNextState() produces an Immutable<Draft<S>> rather

@@ -108,2 +108,53 @@ import { createSlice } from './createSlice'

})
describe('alternative builder callback for extraReducers', () => {
const increment = createAction<number, 'increment'>('increment')
test('can be used with actionCreators', () => {
const slice = createSlice({
name: 'counter',
initialState: 0,
reducers: {},
extraReducers: builder =>
builder.addCase(
increment,
(state, action) => state + action.payload
)
})
expect(slice.reducer(0, increment(5))).toBe(5)
})
test('can be used with string action types', () => {
const slice = createSlice({
name: 'counter',
initialState: 0,
reducers: {},
extraReducers: builder =>
builder.addCase(
'increment',
(state, action: { type: 'increment'; payload: number }) =>
state + action.payload
)
})
expect(slice.reducer(0, increment(5))).toBe(5)
})
test('prevents the same action type from being specified twice', () => {
expect(() =>
createSlice({
name: 'counter',
initialState: 0,
reducers: {},
extraReducers: builder =>
builder
.addCase('increment', state => state + 1)
.addCase('increment', state => state + 1)
})
).toThrowErrorMatchingInlineSnapshot(
`"addCase cannot be called with two reducers for the same action type"`
)
})
// for further tests, see the test of createReducer that goes way more into depth on this
})
})

@@ -110,0 +161,0 @@

@@ -11,2 +11,6 @@ import { Reducer } from 'redux'

import { createReducer, CaseReducers, CaseReducer } from './createReducer'
import {
ActionReducerMapBuilder,
executeReducerBuilderCallback
} from './mapBuilders'

@@ -76,4 +80,8 @@ /**

* as the keys, and action creators will _not_ be generated.
* Alternatively, a callback that receives a *builder* object to define
* case reducers via calls to `builder.addCase(actionCreatorOrType, reducer)`.
*/
extraReducers?: CaseReducers<NoInfer<State>, any>
extraReducers?:
| CaseReducers<NoInfer<State>, any>
| ((builder: ActionReducerMapBuilder<NoInfer<State>>) => void)
}

@@ -206,3 +214,9 @@

const reducers = options.reducers || {}
const extraReducers = options.extraReducers || {}
const extraReducers =
typeof options.extraReducers === 'undefined'
? {}
: typeof options.extraReducers === 'function'
? executeReducerBuilderCallback(options.extraReducers)
: options.extraReducers
const reducerNames = Object.keys(reducers)

@@ -209,0 +223,0 @@

@@ -11,1 +11,2 @@ export * from 'redux'

export * from './getDefaultMiddleware'
export { ActionReducerMapBuilder } from './mapBuilders'
import { Reducer } from 'redux'
import { Console } from 'console'
import { Writable } from 'stream'
import { configureStore } from './configureStore'

@@ -82,6 +84,31 @@

describe('serializableStateInvariantMiddleware', () => {
let log = ''
const originalConsole = window.console
beforeEach(() => {
console.error = jest.fn()
log = ''
const writable = new Writable({
write(chunk, encoding, callback) {
log += chunk
callback()
}
})
const mockConsole = new Console({
stdout: writable,
stderr: writable
})
Object.defineProperty(window, 'console', {
value: mockConsole
})
})
afterEach(() => {
Object.defineProperty(window, 'console', {
value: originalConsole
})
})
it('Should log an error when a non-serializable action is dispatched', () => {

@@ -102,15 +129,8 @@ const reducer: Reducer = (state = 0, _action) => state + 1

expect(console.error).toHaveBeenCalled()
const [
message,
keyPath,
value,
action
] = (console.error as jest.Mock).mock.calls[0]
expect(message).toContain('detected in an action, in the path: `%s`')
expect(keyPath).toBe('type')
expect(value).toBe(type)
expect(action).toBe(dispatchedAction)
expect(log).toMatchInlineSnapshot(`
"A non-serializable value was detected in an action, in the path: \`type\`. Value: Symbol(SOME_CONSTANT)
Take a look at the logic that dispatched this action: { type: Symbol(SOME_CONSTANT) }
(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)
"
`)
})

@@ -150,15 +170,8 @@

expect(console.error).toHaveBeenCalled()
const [
message,
keyPath,
value,
actionType
] = (console.error as jest.Mock).mock.calls[0]
expect(message).toContain('detected in the state, in the path: `%s`')
expect(keyPath).toBe('testSlice.a')
expect(value).toBe(badValue)
expect(actionType).toBe(ACTION_TYPE)
expect(log).toMatchInlineSnapshot(`
"A non-serializable value was detected in the state, in the path: \`testSlice.a\`. Value: Map {}
Take a look at the reducer(s) handling this action type: TEST_ACTION.
(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)
"
`)
})

@@ -218,16 +231,9 @@

expect(console.error).toHaveBeenCalled()
const [
message,
keyPath,
value,
actionType
] = (console.error as jest.Mock).mock.calls[0]
// since default options are used, the `entries` function in `serializableObject` will cause the error
expect(message).toContain('detected in the state, in the path: `%s`')
expect(keyPath).toBe('testSlice.a.entries')
expect(value).toBe(serializableObject.entries)
expect(actionType).toBe(ACTION_TYPE)
expect(log).toMatchInlineSnapshot(`
"A non-serializable value was detected in the state, in the path: \`testSlice.a.entries\`. Value: [Function: entries]
Take a look at the reducer(s) handling this action type: TEST_ACTION.
(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)
"
`)
})

@@ -272,16 +278,9 @@

expect(console.error).toHaveBeenCalled()
const [
message,
keyPath,
value,
actionType
] = (console.error as jest.Mock).mock.calls[0]
// error reported is from a nested class instance, rather than the `entries` function `serializableObject`
expect(message).toContain('detected in the state, in the path: `%s`')
expect(keyPath).toBe('testSlice.a.third.bad-map-instance')
expect(value).toBe(nonSerializableValue)
expect(actionType).toBe(ACTION_TYPE)
expect(log).toMatchInlineSnapshot(`
"A non-serializable value was detected in the state, in the path: \`testSlice.a.third.bad-map-instance\`. Value: Map {}
Take a look at the reducer(s) handling this action type: TEST_ACTION.
(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)
"
`)
})

@@ -328,3 +327,3 @@ })

// no error logging is expected:
expect(console.error).not.toHaveBeenCalled()
expect(log).toBe('')
})

@@ -331,0 +330,0 @@

@@ -23,14 +23,2 @@ import isPlainObject from './isPlainObject'

const NON_SERIALIZABLE_STATE_MESSAGE = [
'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')
const NON_SERIALIZABLE_ACTION_MESSAGE = [
'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')
interface NonSerializableValue {

@@ -139,3 +127,9 @@ keyPath: string

console.error(NON_SERIALIZABLE_ACTION_MESSAGE, keyPath, value, action)
console.error(
`A non-serializable value was detected in an action, in the path: \`${keyPath}\`. Value:`,
value,
'\nTake a look at the logic that dispatched this action: ',
action,
'\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)'
)
}

@@ -157,3 +151,9 @@

console.error(NON_SERIALIZABLE_STATE_MESSAGE, keyPath, value, action.type)
console.error(
`A non-serializable value was detected in the state, in the path: \`${keyPath}\`. Value:`,
value,
`
Take a look at the reducer(s) handling this action type: ${action.type}.
(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`
)
}

@@ -160,0 +160,0 @@

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc