redux-starter-kit
Advanced tools
Comparing version 0.6.3 to 0.7.0
import { Reducer, ReducersMapObject, Middleware, Action, AnyAction, StoreEnhancer, Store, DeepPartial } from 'redux'; | ||
import { EnhancerOptions } from 'redux-devtools-extension'; | ||
import { ThunkDispatch, ThunkMiddleware } from 'redux-thunk'; | ||
import { EnhancerOptions as DevToolsOptions } from 'redux-devtools-extension'; | ||
import { ThunkDispatch } from 'redux-thunk'; | ||
export declare type ConfigureEnhancersCallback = (defaultEnhancers: StoreEnhancer[]) => StoreEnhancer[]; | ||
/** | ||
* Returns any array containing the default middleware installed by | ||
* `configureStore()`. Useful if you want to configure your store with a custom | ||
* `middleware` array but still keep the default set. | ||
* | ||
* @return The default middleware used by `configureStore()`. | ||
*/ | ||
export declare function getDefaultMiddleware<S = any, A extends Action = AnyAction>(): [ThunkMiddleware<S, A>, ...Middleware<{}, S>[]]; | ||
/** | ||
* Options for `configureStore()`. | ||
@@ -29,7 +22,8 @@ */ | ||
* | ||
* Additional configuration can be done by passing enhancer options | ||
* Additional configuration can be done by passing Redux DevTools options | ||
*/ | ||
devTools?: boolean | EnhancerOptions; | ||
devTools?: boolean | DevToolsOptions; | ||
/** | ||
* The initial state. You may optionally specify it to hydrate the state | ||
* The initial state, same as Redux's createStore. | ||
* You may optionally specify it to hydrate the state | ||
* from the server in universal apps, or to restore a previously serialized | ||
@@ -42,6 +36,10 @@ * user session. If you use `combineReducers()` to produce the root reducer | ||
/** | ||
* The store enhancers to apply. See Redux's `createStore()`. If you only | ||
* need to add middleware, you can use the `middleware` parameter instaead. | ||
* The store enhancers to apply. See Redux's `createStore()`. | ||
* All enhancers will be included before the DevTools Extension enhancer. | ||
* If you need to customize the order of enhancers, supply a callback | ||
* function that will receive the original array (ie, `[applyMiddleware]`), | ||
* and should return a new array (such as `[applyMiddleware, offline]`). | ||
* If you only need to add middleware, you can use the `middleware` parameter instaead. | ||
*/ | ||
enhancers?: StoreEnhancer[]; | ||
enhancers?: StoreEnhancer[] | ConfigureEnhancersCallback; | ||
} | ||
@@ -48,0 +46,0 @@ /** |
@@ -8,9 +8,5 @@ import { Action } from 'redux'; | ||
* @template T the type used for the action type. | ||
* @template M The type of the action's meta (optional) | ||
*/ | ||
export declare type PayloadAction<P = any, T extends string = string, M = void> = Action<T> & { | ||
payload: P; | ||
} & ([M] extends [void] ? {} : { | ||
meta: M; | ||
}); | ||
export declare type Diff<T, U> = T extends U ? never : T; | ||
export declare type PayloadAction<P = any, T extends string = string, M = void> = WithOptionalMeta<M, WithPayload<P, Action<T>>>; | ||
export declare type PrepareAction<P> = ((...args: any[]) => { | ||
@@ -22,17 +18,13 @@ payload: P; | ||
}); | ||
export declare type ActionCreatorWithPreparedPayload<PA extends PrepareAction<any> | void, T extends string = string> = WithTypeProperty<T, PA extends PrepareAction<infer P> ? (...args: Parameters<PA>) => PayloadAction<P, T, MetaOrVoid<PA>> : void>; | ||
export declare type ActionCreatorWithOptionalPayload<P, T extends string = string> = WithTypeProperty<T, { | ||
(payload?: undefined): PayloadAction<undefined, T>; | ||
<PT extends Diff<P, undefined>>(payload?: PT): PayloadAction<PT, T>; | ||
}>; | ||
export declare type ActionCreatorWithoutPayload<T extends string = string> = WithTypeProperty<T, () => PayloadAction<undefined, T>>; | ||
export declare type ActionCreatorWithPayload<P, T extends string = string> = WithTypeProperty<T, <PT extends P>(payload: PT) => PayloadAction<PT, T>>; | ||
/** | ||
* An action creator that produces actions with a `payload` attribute. | ||
*/ | ||
export declare type PayloadActionCreator<P = any, T extends string = string, PA extends PrepareAction<P> | void = void> = { | ||
type: T; | ||
} & (PA extends (...args: any[]) => any ? (ReturnType<PA> extends { | ||
meta: infer M; | ||
} ? (...args: Parameters<PA>) => PayloadAction<P, T, M> : (...args: Parameters<PA>) => PayloadAction<P, T>) : ([undefined] extends [P] ? { | ||
(payload?: undefined): PayloadAction<undefined, T>; | ||
<PT extends Diff<P, undefined>>(payload?: PT): PayloadAction<PT, T>; | ||
} : [void] extends [P] ? { | ||
(): PayloadAction<undefined, T>; | ||
} : { | ||
<PT extends P>(payload: PT): PayloadAction<PT, T>; | ||
})); | ||
export declare type PayloadActionCreator<P = any, T extends string = string, PA extends PrepareAction<P> | void = void> = IfPrepareActionMethodProvided<PA, ActionCreatorWithPreparedPayload<PA, T>, IfMaybeUndefined<P, ActionCreatorWithOptionalPayload<P, T>, IfVoid<P, ActionCreatorWithoutPayload<T>, ActionCreatorWithPayload<P, T>>>>; | ||
/** | ||
@@ -46,2 +38,4 @@ * A utility function to create an action creator for the given action type | ||
* @param type The action type to use for created actions. | ||
* @param prepare (optional) a method that takes any number of arguments and returns { payload } or { payload, meta }. | ||
* If this is given, the resulting action creator will pass it's arguments to this method to calculate payload & meta. | ||
*/ | ||
@@ -59,1 +53,18 @@ export declare function createAction<P = any, T extends string = string>(type: T): PayloadActionCreator<P, T>; | ||
export declare function getType<T extends string>(actionCreator: PayloadActionCreator<any, T>): T; | ||
declare type Diff<T, U> = T extends U ? never : T; | ||
declare type WithPayload<P, T> = T & { | ||
payload: P; | ||
}; | ||
declare type WithOptionalMeta<M, T> = T & ([M] extends [void] ? {} : { | ||
meta: M; | ||
}); | ||
declare type WithTypeProperty<T, MergeIn> = { | ||
type: T; | ||
} & MergeIn; | ||
declare type IfPrepareActionMethodProvided<PA extends PrepareAction<any> | void, True, False> = PA extends (...args: any[]) => any ? True : False; | ||
declare type MetaOrVoid<PA extends PrepareAction<any>> = ReturnType<PA> extends { | ||
meta: infer M; | ||
} ? M : void; | ||
declare type IfMaybeUndefined<P, True, False> = [undefined] extends [P] ? True : False; | ||
declare type IfVoid<P, True, False> = [void] extends [P] ? True : False; | ||
export {}; |
import { Reducer } from 'redux'; | ||
import { PayloadAction, PayloadActionCreator, PrepareAction } from './createAction'; | ||
import { PayloadAction, PayloadActionCreator, PrepareAction, ActionCreatorWithoutPayload, ActionCreatorWithPreparedPayload } from './createAction'; | ||
import { CaseReducers, CaseReducer } from './createReducer'; | ||
@@ -10,3 +10,3 @@ /** | ||
export declare type SliceActionCreator<P> = PayloadActionCreator<P>; | ||
export interface Slice<S = any, AC extends { | ||
export interface Slice<State = any, ActionCreators extends { | ||
[key: string]: any; | ||
@@ -23,3 +23,3 @@ } = { | ||
*/ | ||
reducer: Reducer<S>; | ||
reducer: Reducer<State>; | ||
/** | ||
@@ -29,12 +29,3 @@ * Action creators for the types of actions that are handled by the slice | ||
*/ | ||
actions: AC; | ||
/** | ||
* Selectors for the slice reducer state. `createSlice()` inserts a single | ||
* selector that returns the entire slice state and whose name is | ||
* automatically derived from the slice name (e.g., `getCounter` for a slice | ||
* named `counter`). | ||
*/ | ||
selectors: { | ||
[key: string]: (state: any) => S; | ||
}; | ||
actions: ActionCreators; | ||
} | ||
@@ -44,6 +35,5 @@ /** | ||
*/ | ||
export interface CreateSliceOptions<S = any, CR extends SliceCaseReducers<S, any> = SliceCaseReducers<S, any>> { | ||
export interface CreateSliceOptions<State = any, CR extends SliceCaseReducers<State, any> = SliceCaseReducers<State, any>> { | ||
/** | ||
* The slice's name. Used to namespace the generated action types and to | ||
* name the selector for retrieving the reducer's state. | ||
* The slice's name. Used to namespace the generated action types. | ||
*/ | ||
@@ -54,3 +44,3 @@ slice?: string; | ||
*/ | ||
initialState: S; | ||
initialState: State; | ||
/** | ||
@@ -67,16 +57,22 @@ * A mapping from action types to action-type-specific *case reducer* | ||
*/ | ||
extraReducers?: CaseReducers<S, any>; | ||
extraReducers?: CaseReducers<State, any>; | ||
} | ||
declare type PayloadActions<T extends keyof any = string> = Record<T, PayloadAction>; | ||
declare type EnhancedCaseReducer<S, A extends PayloadAction> = { | ||
reducer: CaseReducer<S, A>; | ||
prepare: PrepareAction<A['payload']>; | ||
declare type PayloadActions<Types extends keyof any = string> = Record<Types, PayloadAction>; | ||
declare type EnhancedCaseReducer<State, Action extends PayloadAction> = { | ||
reducer: CaseReducer<State, Action>; | ||
prepare: PrepareAction<Action['payload']>; | ||
}; | ||
declare type SliceCaseReducers<S, PA extends PayloadActions> = { | ||
[T in keyof PA]: CaseReducer<S, PA[T]> | EnhancedCaseReducer<S, PA[T]>; | ||
declare type SliceCaseReducers<State, PA extends PayloadActions> = { | ||
[ActionType in keyof PA]: CaseReducer<State, PA[ActionType]> | EnhancedCaseReducer<State, PA[ActionType]>; | ||
}; | ||
declare type CaseReducerActions<CR extends SliceCaseReducers<any, any>> = { | ||
[T in keyof CR]: CR[T] extends (state: any) => any ? PayloadActionCreator<void> : (CR[T] extends (state: any, action: PayloadAction<infer P>) => any ? PayloadActionCreator<P> : CR[T] extends { | ||
prepare: PrepareAction<infer P>; | ||
} ? PayloadActionCreator<P, string, CR[T]['prepare']> : PayloadActionCreator<void>); | ||
declare type IfIsReducerFunctionWithoutAction<R, True, False = never> = R extends (state: any) => any ? True : False; | ||
declare type IfIsEnhancedReducer<R, True, False = never> = R extends { | ||
prepare: Function; | ||
} ? True : False; | ||
declare type PayloadForReducer<R> = R extends (state: any, action: PayloadAction<infer P>) => any ? P : void; | ||
declare type PrepareActionForReducer<R> = R extends { | ||
prepare: infer Prepare; | ||
} ? Prepare : never; | ||
declare type CaseReducerActions<CaseReducers extends SliceCaseReducers<any, any>> = { | ||
[Type in keyof CaseReducers]: IfIsEnhancedReducer<CaseReducers[Type], ActionCreatorWithPreparedPayload<PrepareActionForReducer<CaseReducers[Type]>>, IfIsReducerFunctionWithoutAction<CaseReducers[Type], ActionCreatorWithoutPayload, PayloadActionCreator<PayloadForReducer<CaseReducers[Type]>>>>; | ||
}; | ||
@@ -95,6 +91,9 @@ declare type NoInfer<T> = [T][T extends any ? 0 : never]; | ||
}; | ||
declare type RestrictEnhancedReducersToMatchReducerAndPrepare<S, CR extends SliceCaseReducers<S, any>> = { | ||
reducers: SliceCaseReducersCheck<S, NoInfer<CR>>; | ||
}; | ||
/** | ||
* A function that accepts an initial state, an object full of reducer | ||
* functions, and optionally a "slice name", and automatically generates | ||
* action creators, action types, and selectors that correspond to the | ||
* action creators and action types that correspond to the | ||
* reducers and state. | ||
@@ -104,5 +103,3 @@ * | ||
*/ | ||
export declare function createSlice<S, CR extends SliceCaseReducers<S, any>>(options: CreateSliceOptions<S, CR> & { | ||
reducers: SliceCaseReducersCheck<S, NoInfer<CR>>; | ||
}): Slice<S, CaseReducerActions<CR>>; | ||
export declare function createSlice<State, CaseReducers extends SliceCaseReducers<State, any>>(options: CreateSliceOptions<State, CaseReducers> & RestrictEnhancedReducersToMatchReducerAndPrepare<State, CaseReducers>): Slice<State, CaseReducerActions<CaseReducers>>; | ||
export {}; |
export { combineReducers, compose } from 'redux'; | ||
export { default as createNextState } from 'immer'; | ||
export { default as createSelector } from 'selectorator'; | ||
export { createSelector } from 'reselect'; | ||
export * from './configureStore'; | ||
@@ -9,1 +9,2 @@ export * from './createAction'; | ||
export * from './serializableStateInvariantMiddleware'; | ||
export * from './getDefaultMiddleware'; |
@@ -9,5 +9,5 @@ 'use strict'; | ||
var createNextState = _interopDefault(require('immer')); | ||
var selectorator = _interopDefault(require('selectorator')); | ||
var reselect = require('reselect'); | ||
var reduxDevtoolsExtension = require('redux-devtools-extension'); | ||
var thunk = _interopDefault(require('redux-thunk')); | ||
var thunkMiddleware = _interopDefault(require('redux-thunk')); | ||
@@ -228,6 +228,12 @@ function _typeof(obj) { | ||
isSerializable = _options$isSerializab === void 0 ? isPlain : _options$isSerializab, | ||
getEntries = options.getEntries; | ||
getEntries = options.getEntries, | ||
_options$ignoredActio = options.ignoredActions, | ||
ignoredActions = _options$ignoredActio === void 0 ? [] : _options$ignoredActio; | ||
return function (storeAPI) { | ||
return function (next) { | ||
return function (action) { | ||
if (ignoredActions.length && ignoredActions.indexOf(action.type) !== -1) { | ||
return next(action); | ||
} | ||
var foundActionNonSerializableValue = findNonSerializableValue(action, [], isSerializable, getEntries); | ||
@@ -257,3 +263,6 @@ | ||
var IS_PRODUCTION = process.env.NODE_ENV === 'production'; | ||
function isBoolean(x) { | ||
return typeof x === 'boolean'; | ||
} | ||
/** | ||
@@ -266,14 +275,45 @@ * Returns any array containing the default middleware installed by | ||
*/ | ||
function getDefaultMiddleware() { | ||
var middlewareArray = [thunk]; | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var _options$thunk = options.thunk, | ||
thunk = _options$thunk === void 0 ? true : _options$thunk, | ||
_options$immutableChe = options.immutableCheck, | ||
immutableCheck = _options$immutableChe === void 0 ? true : _options$immutableChe, | ||
_options$serializable = options.serializableCheck, | ||
serializableCheck = _options$serializable === void 0 ? true : _options$serializable; | ||
var middlewareArray = []; | ||
if (thunk) { | ||
if (isBoolean(thunk)) { | ||
middlewareArray.push(thunkMiddleware); | ||
} else { | ||
middlewareArray.push(thunkMiddleware.withExtraArgument(thunk.extraArgument)); | ||
} | ||
} | ||
if (process.env.NODE_ENV !== 'production') { | ||
/* START_REMOVE_UMD */ | ||
var createImmutableStateInvariantMiddleware = require('redux-immutable-state-invariant')["default"]; | ||
if (immutableCheck) { | ||
var createImmutableStateInvariantMiddleware = require('redux-immutable-state-invariant')["default"]; | ||
middlewareArray.unshift(createImmutableStateInvariantMiddleware()); | ||
var immutableOptions = {}; | ||
if (!isBoolean(immutableCheck)) { | ||
immutableOptions = immutableCheck; | ||
} | ||
middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions)); | ||
} | ||
/* STOP_REMOVE_UMD */ | ||
middlewareArray.push(createSerializableStateInvariantMiddleware()); | ||
if (serializableCheck) { | ||
var serializableOptions = {}; | ||
if (!isBoolean(serializableCheck)) { | ||
serializableOptions = serializableCheck; | ||
} | ||
middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions)); | ||
} | ||
} | ||
@@ -283,6 +323,5 @@ | ||
} | ||
/** | ||
* Options for `configureStore()`. | ||
*/ | ||
var IS_PRODUCTION = process.env.NODE_ENV === 'production'; | ||
/** | ||
@@ -305,3 +344,3 @@ * A friendly abstraction over the standard Redux `createStore()` function. | ||
_ref$enhancers = _ref.enhancers, | ||
enhancers = _ref$enhancers === void 0 ? [] : _ref$enhancers; | ||
enhancers = _ref$enhancers === void 0 ? undefined : _ref$enhancers; | ||
@@ -328,3 +367,10 @@ var rootReducer; | ||
var storeEnhancers = [middlewareEnhancer].concat(_toConsumableArray(enhancers)); | ||
var storeEnhancers = [middlewareEnhancer]; | ||
if (Array.isArray(enhancers)) { | ||
storeEnhancers = [middlewareEnhancer].concat(_toConsumableArray(enhancers)); | ||
} else if (typeof enhancers === 'function') { | ||
storeEnhancers = enhancers(storeEnhancers); | ||
} | ||
var composedEnhancer = finalCompose.apply(void 0, _toConsumableArray(storeEnhancers)); | ||
@@ -340,2 +386,3 @@ return redux.createStore(rootReducer, preloadedState, composedEnhancer); | ||
* @template T the type used for the action type. | ||
* @template M The type of the action's meta (optional) | ||
*/ | ||
@@ -355,2 +402,4 @@ | ||
* @param type The action type to use for created actions. | ||
* @param prepare (optional) a method that takes any number of arguments and returns { payload } or { payload, meta }. | ||
* If this is given, the resulting action creator will pass it's arguments to this method to calculate payload & meta. | ||
*/ | ||
@@ -400,3 +449,3 @@ function createAction(type, prepareAction) { | ||
return "".concat(actionCreator); | ||
} | ||
} // helper types for more readable typings | ||
@@ -433,27 +482,2 @@ /** | ||
function createSliceSelector(slice) { | ||
if (!slice) { | ||
return function (state) { | ||
return state; | ||
}; | ||
} | ||
return function (state) { | ||
return state[slice]; | ||
}; | ||
} | ||
function createSelectorName(slice) { | ||
if (!slice) { | ||
return 'getState'; | ||
} | ||
return camelize("get ".concat(slice)); | ||
} | ||
function camelize(str) { | ||
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function (letter, index) { | ||
return index === 0 ? letter.toLowerCase() : letter.toUpperCase(); | ||
}).replace(/\s+/g, '').replace(/[-_]/g, ''); | ||
} | ||
/** | ||
@@ -471,3 +495,3 @@ * An action creator atttached to a slice. | ||
* functions, and optionally a "slice name", and automatically generates | ||
* action creators, action types, and selectors that correspond to the | ||
* action creators and action types that correspond to the | ||
* reducers and state. | ||
@@ -479,2 +503,3 @@ * | ||
// internal definition is a little less restrictive | ||
function createSlice(options) { | ||
@@ -499,10 +524,6 @@ var _options$slice = options.slice, | ||
}, {}); | ||
var selectors = _defineProperty({}, createSelectorName(slice), createSliceSelector(slice)); | ||
return { | ||
slice: slice, | ||
reducer: reducer, | ||
actions: actionMap, | ||
selectors: selectors | ||
actions: actionMap | ||
}; | ||
@@ -524,3 +545,8 @@ } | ||
exports.createNextState = createNextState; | ||
exports.createSelector = selectorator; | ||
Object.defineProperty(exports, 'createSelector', { | ||
enumerable: true, | ||
get: function () { | ||
return reselect.createSelector; | ||
} | ||
}); | ||
exports.configureStore = configureStore; | ||
@@ -527,0 +553,0 @@ exports.createAction = createAction; |
@@ -5,5 +5,5 @@ import { combineReducers, applyMiddleware, createStore, compose } from 'redux'; | ||
export { default as createNextState } from 'immer'; | ||
export { default as createSelector } from 'selectorator'; | ||
export { createSelector } from 'reselect'; | ||
import { composeWithDevTools } from 'redux-devtools-extension'; | ||
import thunk from 'redux-thunk'; | ||
import thunkMiddleware from 'redux-thunk'; | ||
@@ -224,6 +224,12 @@ function _typeof(obj) { | ||
isSerializable = _options$isSerializab === void 0 ? isPlain : _options$isSerializab, | ||
getEntries = options.getEntries; | ||
getEntries = options.getEntries, | ||
_options$ignoredActio = options.ignoredActions, | ||
ignoredActions = _options$ignoredActio === void 0 ? [] : _options$ignoredActio; | ||
return function (storeAPI) { | ||
return function (next) { | ||
return function (action) { | ||
if (ignoredActions.length && ignoredActions.indexOf(action.type) !== -1) { | ||
return next(action); | ||
} | ||
var foundActionNonSerializableValue = findNonSerializableValue(action, [], isSerializable, getEntries); | ||
@@ -253,3 +259,6 @@ | ||
var IS_PRODUCTION = process.env.NODE_ENV === 'production'; | ||
function isBoolean(x) { | ||
return typeof x === 'boolean'; | ||
} | ||
/** | ||
@@ -262,14 +271,45 @@ * Returns any array containing the default middleware installed by | ||
*/ | ||
function getDefaultMiddleware() { | ||
var middlewareArray = [thunk]; | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var _options$thunk = options.thunk, | ||
thunk = _options$thunk === void 0 ? true : _options$thunk, | ||
_options$immutableChe = options.immutableCheck, | ||
immutableCheck = _options$immutableChe === void 0 ? true : _options$immutableChe, | ||
_options$serializable = options.serializableCheck, | ||
serializableCheck = _options$serializable === void 0 ? true : _options$serializable; | ||
var middlewareArray = []; | ||
if (thunk) { | ||
if (isBoolean(thunk)) { | ||
middlewareArray.push(thunkMiddleware); | ||
} else { | ||
middlewareArray.push(thunkMiddleware.withExtraArgument(thunk.extraArgument)); | ||
} | ||
} | ||
if (process.env.NODE_ENV !== 'production') { | ||
/* START_REMOVE_UMD */ | ||
var createImmutableStateInvariantMiddleware = require('redux-immutable-state-invariant')["default"]; | ||
if (immutableCheck) { | ||
var createImmutableStateInvariantMiddleware = require('redux-immutable-state-invariant')["default"]; | ||
middlewareArray.unshift(createImmutableStateInvariantMiddleware()); | ||
var immutableOptions = {}; | ||
if (!isBoolean(immutableCheck)) { | ||
immutableOptions = immutableCheck; | ||
} | ||
middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions)); | ||
} | ||
/* STOP_REMOVE_UMD */ | ||
middlewareArray.push(createSerializableStateInvariantMiddleware()); | ||
if (serializableCheck) { | ||
var serializableOptions = {}; | ||
if (!isBoolean(serializableCheck)) { | ||
serializableOptions = serializableCheck; | ||
} | ||
middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions)); | ||
} | ||
} | ||
@@ -279,6 +319,5 @@ | ||
} | ||
/** | ||
* Options for `configureStore()`. | ||
*/ | ||
var IS_PRODUCTION = process.env.NODE_ENV === 'production'; | ||
/** | ||
@@ -301,3 +340,3 @@ * A friendly abstraction over the standard Redux `createStore()` function. | ||
_ref$enhancers = _ref.enhancers, | ||
enhancers = _ref$enhancers === void 0 ? [] : _ref$enhancers; | ||
enhancers = _ref$enhancers === void 0 ? undefined : _ref$enhancers; | ||
@@ -324,3 +363,10 @@ var rootReducer; | ||
var storeEnhancers = [middlewareEnhancer].concat(_toConsumableArray(enhancers)); | ||
var storeEnhancers = [middlewareEnhancer]; | ||
if (Array.isArray(enhancers)) { | ||
storeEnhancers = [middlewareEnhancer].concat(_toConsumableArray(enhancers)); | ||
} else if (typeof enhancers === 'function') { | ||
storeEnhancers = enhancers(storeEnhancers); | ||
} | ||
var composedEnhancer = finalCompose.apply(void 0, _toConsumableArray(storeEnhancers)); | ||
@@ -336,2 +382,3 @@ return createStore(rootReducer, preloadedState, composedEnhancer); | ||
* @template T the type used for the action type. | ||
* @template M The type of the action's meta (optional) | ||
*/ | ||
@@ -351,2 +398,4 @@ | ||
* @param type The action type to use for created actions. | ||
* @param prepare (optional) a method that takes any number of arguments and returns { payload } or { payload, meta }. | ||
* If this is given, the resulting action creator will pass it's arguments to this method to calculate payload & meta. | ||
*/ | ||
@@ -396,3 +445,3 @@ function createAction(type, prepareAction) { | ||
return "".concat(actionCreator); | ||
} | ||
} // helper types for more readable typings | ||
@@ -429,27 +478,2 @@ /** | ||
function createSliceSelector(slice) { | ||
if (!slice) { | ||
return function (state) { | ||
return state; | ||
}; | ||
} | ||
return function (state) { | ||
return state[slice]; | ||
}; | ||
} | ||
function createSelectorName(slice) { | ||
if (!slice) { | ||
return 'getState'; | ||
} | ||
return camelize("get ".concat(slice)); | ||
} | ||
function camelize(str) { | ||
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function (letter, index) { | ||
return index === 0 ? letter.toLowerCase() : letter.toUpperCase(); | ||
}).replace(/\s+/g, '').replace(/[-_]/g, ''); | ||
} | ||
/** | ||
@@ -467,3 +491,3 @@ * An action creator atttached to a slice. | ||
* functions, and optionally a "slice name", and automatically generates | ||
* action creators, action types, and selectors that correspond to the | ||
* action creators and action types that correspond to the | ||
* reducers and state. | ||
@@ -475,2 +499,3 @@ * | ||
// internal definition is a little less restrictive | ||
function createSlice(options) { | ||
@@ -495,10 +520,6 @@ var _options$slice = options.slice, | ||
}, {}); | ||
var selectors = _defineProperty({}, createSelectorName(slice), createSliceSelector(slice)); | ||
return { | ||
slice: slice, | ||
reducer: reducer, | ||
actions: actionMap, | ||
selectors: selectors | ||
actions: actionMap | ||
}; | ||
@@ -505,0 +526,0 @@ } |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).RSK={})}(this,function(e){"use strict";var t=function(e){var t,r=e.Symbol;return"function"==typeof r?r.observable?t=r.observable:(t=r("observable"),r.observable=t):t="@@observable",t}("undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof module?module:Function("return this")()),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 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 Error("Expected the enhancer to be a function.");return i(o)(e,r)}if("function"!=typeof e)throw 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 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 y(e){if("function"!=typeof e)throw Error("Expected the listener to be a function.");if(l)throw 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 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 h(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 Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===e.type)throw Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(l)throw Error("Reducers may not dispatch actions.");try{l=!0,c=u(c,e)}finally{l=!1}for(var t=f=s,r=0;t.length>r;r++){(0,t[r])()}return e}return h({type:n.INIT}),(a={dispatch:h,subscribe:y,getState:d,replaceReducer:function(e){if("function"!=typeof e)throw Error("Expected the nextReducer to be a function.");u=e,h({type:n.REPLACE})}})[t]=function(){var e,r=y;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 "'+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;t.length>o;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 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 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;c.length>a;a++){var f=c[a],s=e[f],l=(0,r[f])(s,t);if(void 0===l){var p=i(f,t);throw 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;arguments.length>t;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=Array(e),r=0;e>r;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=Array(e),r=0;e>r;r++)t[r]=arguments[r];return function(e){return function(){var r=e.apply(void 0,arguments),n=function(){throw 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=Object.freeze({createStore:o,combineReducers:a,bindActionCreators:function(e,t){if("function"==typeof e)return u(e,t);if("object"!=typeof e||null===e)throw 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;r.length>o;o++){var i=r[o],a=e[i];"function"==typeof a&&(n[i]=u(a,t))}return n},applyMiddleware:l,compose:s,__DO_NOT_USE__ActionTypes:n}),y="undefined"!=typeof Symbol?Symbol("immer-nothing"):((p={})["immer-nothing"]=!0,p),h="undefined"!=typeof Symbol?Symbol.for("immer-draftable"):"__$immer_draftable",v="undefined"!=typeof Symbol?Symbol.for("immer-state"):"__$immer_state";function b(e){return!!e&&!!e[v]}function g(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[h]||!!e.constructor[h])}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 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 j(e,t){if(Array.isArray(e))for(var r=0;e.length>r;r++)t(r,e[r],e);else w(e).forEach(function(r){return t(r,e[r],e)})}function E(e,t){return Object.getOwnPropertyDescriptor(e,t).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}var S=function(e){this.drafts=[],this.parent=e,this.canAutoFreeze=!0,this.patches=null};function x(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(x),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 _={};function z(e,t){var r=Array.isArray(e),n=N(e);j(n,function(t){!function(e,t,r){var n=_[t];n?n.enumerable=r:_[t]=n={configurable:!0,enumerable:r,get:function(){return function(e,t){C(e);var r=T(I(e),t);if(e.finalizing)return r;if(r===T(e.base,t)&&g(r))return R(e),e.copy[t]=z(r,e);return r}(this[v],t)},set:function(e){!function(e,t,r){if(C(e),e.assigned[t]=!0,!e.modified){if(A(r,T(I(e),t)))return;D(e),R(e)}e.copy[t]=r}(this[v],t,e)}};Object.defineProperty(e,t,n)}(n,t,r||E(e,t))});var o=t?t.scope:S.current;return Object.defineProperty(n,v,{value:{scope:o,modified:!1,finalizing:!1,finalized:!1,assigned:{},parent:t,base:e,draft:n,copy:null,revoke:k,revoked:!1},enumerable:!1,writable:!0}),o.drafts.push(n),n}function k(){this.revoked=!0}function I(e){return e.copy||e.base}function T(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 D(e){e.modified||(e.modified=!0,e.parent&&D(e.parent))}function R(e){e.copy||(e.copy=N(e.base))}function N(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 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(I(e)))}function F(e){for(var t=e.length-1;t>=0;t--){var r=e[t][v];r.modified||(Array.isArray(r.base)?U(r)&&D(r):M(r)&&D(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 U(e){var t=e.draft;if(t.length!==e.base.length)return!0;var r=Object.getOwnPropertyDescriptor(t,t.length-1);return!(!r||r.get)}var L=Object.freeze({willFinalize:function(e,t,r){e.drafts.forEach(function(e){e[v].finalizing=!0}),r?b(t)&&t[v].scope===e&&F(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(U(r)){if(D(r),i.length=!0,n.length>o.length)for(var a=o.length;n.length>a;a++)i[a]=!1;else for(var u=n.length;o.length>u;u++)i[u]=!0;for(var c=0;o.length>c;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,D(r))}),Object.keys(n).forEach(function(e){void 0!==o[e]||P(o,e)||(i[e]=!1,D(r))})}}}(e.drafts[0]),F(e.drafts))},createProxy:z});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],X):Proxy.revocable(n,W),i=o.revoke,a=o.proxy;return n.draft=a,n.revoke=i,r.drafts.push(a),a}var W={get:function(e,t){if(t===v)return e;var r=e.drafts;if(!e.modified&&P(r,t))return r[t];var n=$(e)[t];if(e.finalized||!g(n))return n;if(e.modified){if(n!==V(e.base,t))return n;r=e.copy}return r[t]=K(n,e)},has:function(e,t){return t in $(e)},ownKeys:function(e){return Reflect.ownKeys($(e))},set:function(e,t,r){if(!e.modified){var n=V(e.base,t),o=r?A(n,r)||r===e.drafts[t]:A(n,r)&&t in e.base;if(o)return!0;q(e)}return e.assigned[t]=!0,e.copy[t]=r,!0},deleteProperty:function(e,t){(void 0!==V(e.base,t)||t in e.base)&&(e.assigned[t]=!1,q(e));e.copy&&delete e.copy[t];return!0},getOwnPropertyDescriptor:function(e,t){var r=$(e),n=Reflect.getOwnPropertyDescriptor(r,t);n&&(n.writable=!0,n.configurable=!Array.isArray(r)||"length"!==t);return n},defineProperty:function(){throw Error("Object.defineProperty() cannot be used on an Immer draft")},getPrototypeOf:function(e){return Object.getPrototypeOf(e.base)},setPrototypeOf:function(){throw Error("Object.setPrototypeOf() cannot be used on an Immer draft")}},X={};function $(e){return e.copy||e.base}function V(e,t){var r=e[v],n=Reflect.getOwnPropertyDescriptor(r?$(r):e,t);return n&&n.value}function q(e){e.modified||(e.modified=!0,e.copy=m(O(e.base),e.drafts),e.drafts=null,e.parent&&q(e.parent))}j(W,function(e,t){X[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),X.deleteProperty=function(e,t){if(isNaN(parseInt(t)))throw Error("Immer only supports deleting array indices");return W.deleteProperty.call(this,e[0],t)},X.set=function(e,t,r){if("length"!==t&&isNaN(parseInt(t)))throw Error("Immer only supports setting array indices and the 'length' property");return W.set.call(this,e[0],t,r)};var Y=Object.freeze({willFinalize:function(){},createProxy:K});function B(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;a.length>u.length&&(a=(o=[u,a])[0],u=o[1],r=(i=[n,r])[0],n=i[1]);var f=u.length-a.length,s=0;for(;a[s]===u[s]&&a.length>s;)++s;var l=a.length;for(;l>s&&a[l-1]===u[l+f-1];)--l;for(var p=s;l>p;++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 y=l!=a.length,h=r.length,v=l+f-1;v>=l;--v){var b=t.concat([v]);r[h+v-l]={op:"add",path:b,value:u[v]},y&&n.push({op:"remove",path:b})}y||n.push({op:"replace",path:t.concat(["length"]),value:a.length})}(e,t,r,n):function(e,t,r,n){var o=e.base,i=e.copy;j(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)}function G(e,t){for(var r=0;t.length>r;r++){var n=t[r],o=n.path;if(0===o.length&&"replace"===n.op)e=n.value;else{for(var i=e,a=0;o.length-1>a;a++)if(!(i=i[o[a]])||"object"!=typeof i)throw Error("Cannot apply patch, path doesn't resolve: "+o.join("/"));var u=o[o.length-1];switch(n.op){case"replace":i[u]=n.value;break;case"add":Array.isArray(i)?i.splice(u,0,n.value):i[u]=n.value;break;case"remove":Array.isArray(i)?i.splice(u,1):delete i[u];break;default:throw Error("Unsupported patch operation: "+n.op)}}}return e}var H={useProxies:"undefined"!=typeof Proxy&&"undefined"!=typeof Reflect,autoFreeze:!1,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;return t=e,function(e){void 0===e&&(e=i);for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return o.produce(e,function(e){return t.call.apply(t,[e,e].concat(r))})}}if("function"!=typeof t)throw Error("The first or second argument to `produce` must be a function");if(void 0!==r&&"function"!=typeof r)throw Error("The third argument to `produce` must be a function or undefined");if(g(e)){var a=S.enter(),u=this.createProxy(e),c=!0;try{n=t.call(u,u),c=!1}finally{c?a.revoke():a.leave()}return n instanceof Promise?n.then(function(e){return a.usePatches(r),o.processResult(e,a)},function(e){throw a.revoke(),e}):(a.usePatches(r),this.processResult(n,a))}return void 0===(n=t(e))?e:n!==y?n:void 0},J.prototype.createDraft=function(e){if(!g(e))throw 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 Error("First argument to `finishDraft` must be a draft returned by `createDraft`");if(r.finalized)throw 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?Y:L)},J.prototype.applyPatches=function(e,t){return b(e)?G(e,t):this.produce(e,function(e){return G(e,t)})},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(),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)),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!==y?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 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;j(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&&B(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)||E(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)&&j(c,a)}s&&n.onAssign&&n.onAssign(o,u,c)};return j(e,a),e};var Z=new J,Q=Z.produce,ee=(Z.setAutoFreeze.bind(Z),Z.setUseProxies.bind(Z),Z.applyPatches.bind(Z),Z.createDraft.bind(Z),Z.finishDraft.bind(Z),{clear:function(){ee.results={},ee.size=0},results:{},size:0}),te=/"[^"]+"|`[^`]+`|'[^']+'|[^.[\]]+/g,re=/^\d+$/i,ne=/^"[^"]+"|`[^`]+`|'[^']+'$/,oe=function(e,t){for(var r=e.length,n=[],o=0;r>o;o++)n[o]=t(e[o]);return n},ie=function(e){var t=function(e){return ne.test(e)}(e)?e.slice(1,e.length-1):e;return function(e){return!(!e||!e.length)&&re.test(e)}(t)?+t:t},ae=Array.isArray,ue=function(e){if("string"==typeof e)return function(e){return ee.results[e]?ee.results[e]:(ee.size>500&&ee.clear(),ee.results[e]=e?oe(e.match(te),ie):[e],ee.size++,ee.results[e])}(e);if(ae(e))return oe(e,ie);var t=ie(e);return["number"==typeof t?t:""+t]},ce=function e(t,r){if(1===t.length)return r?r[t[0]]:void 0;var n=t.shift();return r&&r.hasOwnProperty(n)?e(t,r[n]):void 0},fe=function(e,t){var r=void 0!==t;return function(){var n=arguments[0>e?arguments.length+e:e];return r?ce(ue(t),n):n}},se=fe(0),le="function"==typeof Map,pe="function"==typeof Set,de="function"==typeof WeakSet,ye=Object.keys,he=function(e,t){return e&&"object"==typeof e&&t.add(e)},ve=function(e,t,r,n){for(var o,i=0;e.length>i;i++)if(r((o=e[i])[0],t[0],n)&&r(o[1],t[1],n))return!0;return!1},be=function(e,t,r,n){for(var o=0;e.length>o;o++)if(r(e[o],t,n))return!0;return!1},ge=function(e,t){return e===t||e!=e&&t!=t},me=function(e){return e.constructor===Object},we=function(e){return"function"==typeof e.then},Oe=function(e){return!(!e.$$typeof||!e._store)},je=function(e){return function(t){var r=e||t;return function(e,t,n){void 0===n&&(n=de?new WeakSet:Object.create({_values:[],add:function(e){this._values.push(e)},has:function(e){return!!~this._values.indexOf(e)}}));var o=n.has(e),i=n.has(t);return o||i?o&&i:(he(e,n),he(t,n),r(e,t,n))}}},Ee=function(e){var t=[];return e.forEach(function(e,r){return t.push([r,e])}),t},Pe=function(e){var t=[];return e.forEach(function(e){return t.push(e)}),t},Ae=function(e,t,r,n){if(e.length!==t.length)return!1;for(var o=0;e.length>o;o++)if(!r(e[o],t[o],n))return!1;return!0},Se=function(e,t,r,n){var o=Ee(e),i=Ee(t);if(o.length!==i.length)return!1;for(var a=0;o.length>a;a++)if(!ve(i,o[a],r,n)||!ve(o,i[a],r,n))return!1;return!0},xe=function(e,t,r,n){var o,i=ye(e),a=ye(t);if(i.length!==a.length)return!1;for(var u=0;i.length>u;u++){if(!be(a,o=i[u],ge))return!1;if(("_owner"!==o||!Oe(e)||!Oe(t))&&!r(e[o],t[o],n))return!1}return!0},_e=function(e,t){return e.source===t.source&&e.global===t.global&&e.ignoreCase===t.ignoreCase&&e.multiline===t.multiline&&e.unicode===t.unicode&&e.sticky===t.sticky&&e.lastIndex===t.lastIndex},ze=function(e,t,r,n){var o=Pe(e),i=Pe(t);if(o.length!==i.length)return!1;for(var a=0;o.length>a;a++)if(!be(i,o[a],r,n)||!be(o,i[a],r,n))return!1;return!0},ke=Array.isArray,Ie=function(e){var t="function"==typeof e?e(r):r;function r(e,r,n){if(ge(e,r))return!0;var o=typeof e;if(o!==typeof r||"object"!==o||!e||!r)return!1;if(me(e)&&me(r))return xe(e,r,t,n);var i=ke(e),a=ke(r);if(i||a)return i===a&&Ae(e,r,t,n);var u=e instanceof Date,c=r instanceof Date;if(u||c)return u===c&&ge(e.getTime(),r.getTime());var f=e instanceof RegExp,s=r instanceof RegExp;if(f||s)return f===s&&_e(e,r);if(we(e)||we(r))return e===r;if(le){var l=e instanceof Map,p=r instanceof Map;if(l||p)return l===p&&Se(e,r,t,n)}if(pe){var d=e instanceof Set,y=r instanceof Set;if(d||y)return d===y&&ze(e,r,t,n)}return xe(e,r,t,n)}return r},Te=(Ie(je()),Ie(je(ge)),Ie());Ie(function(){return ge});function De(e,t){return e===t}function Re(e,t,r){if(null===t||null===r||t.length!==r.length)return!1;for(var n=t.length,o=0;n>o;o++)if(!e(t[o],r[o]))return!1;return!0}function Ne(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:De,r=null,n=null;return function(){return Re(t,r,arguments)||(n=e.apply(null,arguments)),r=arguments,n}}function Ce(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 Error("Selector creators expect all input-selectors to be functions, instead received the following types: ["+r+"]")}return t}function Fe(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;t>n;n++)r[n-1]=arguments[n];return function(){for(var t=arguments.length,n=Array(t),o=0;t>o;o++)n[o]=arguments[o];var i=0,a=n.pop(),u=Ce(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;t>r;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}}Fe(Ne);var Me="function"==typeof Symbol?Symbol("curriable placeholder"):60881,Ue=function(e,t,r){return function(){var n,o=r.length,i=arguments,a=i.length,u=[],c=0,f=t;if(o)for(var s=0;o>s;s++)u[s]=n=r[s]===Me&&a>c?i[c++]:r[s],n!==Me&&--f;if(a>c)for(;a>c;c++)u[u.length]=n=i[c],n!==Me&&t>c&&--f;return f>0?Ue(e,t,u):e.apply(this,u)}},Le=function(e,t){void 0===t&&(t=e.length);var r=Ue(e,t,[]);return r.arity=t,r.fn=e,r};Le.__=Me;Le.uncurry=function(e){return e.fn};var Ke=Object,We=Ke.create,Xe=Ke.getOwnPropertySymbols,$e=Ke.getPrototypeOf,Ve=Ke.keys,qe=Ke.propertyIsEnumerable,Ye=Ke.prototype.toString,Be=Function.prototype.toString,Ge=Array.isArray,He="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("react.element"):60103,Je=function(e,t,r){for(var n=r,o=0;e.length>o;o++)n=t(n,e[o]);return n},Ze=function(e){var t=Xe(e);return t.length?Ve(e).concat(Je(t,function(t,r){return qe.call(e,r)&&t.push(r),t},[])):Ve(e)},Qe="function"==typeof Ke.assign?Ke.assign:function(e,t){return t?Je(Ze(t),function(e,r){return e[r]=t[r],e},Object(e)):e},et=function(e){return We(e.__proto__||$e(e))},tt=function(e){if(!e||"object"!=typeof e||e.$$typeof===He)return!1;var t=Ye.call(e);return"[object Date]"!==t&&"[object RegExp]"!==t},rt=function(e){return null==e||Ge(e)&&!e.length},nt=function(e){return"function"==typeof e&&!!~Be.call(e).indexOf("[native code]")},ot=function(e,t,r){return"function"==typeof e?e.apply(t,r):void 0},it=function(e){return Ge(e)?[]:{}},at=function(e){return e.constructor===Ke?Qe({},e):Ge(e)?function(e){for(var t=new e.constructor,r=0;e.length>r;r++)t[r]=e[r];return t}(e):nt(e.constructor)?{}:Qe(et(e),e)},ut=function(e,t){return e===t||e!=e&&t!=t},ct=function(e,t){return tt(e)?at(e):"number"==typeof t?[]:{}},ft=function(e,t){return void 0===e?t:e},st=function(e){return Ge(e)?e:ue(e)},lt=function(e,t,r,n){var o=e[n],i=n+1;return i===e.length?r(t,o):t[o]=lt(e,ct(t[o],e[i]),r,i),t},pt=function(e,t,r){var n=st(e),o=ct(t,n[0]);return 1===n.length?(r(o,n[0]),o):lt(n,o,r,0)},dt=function(e,t,r){var n,o=Ge(e);if(o!==Ge(t)||!tt(e))return tt(n=t)?at(n):n;if(o)return e.concat(t);var i=e.constructor===Ke||nt(e.constructor)?{}:et(e);return Je(Ze(t),function(n,o){return n[o]=r&&tt(t[o])?dt(e[o],t[o],r):t[o],n},Qe(i,e))},yt=function(e,t,r){var n=st(e);if(1===n.length)return t?ft(t[n[0]],r):r;for(var o=t,i=n[0],a=0;n.length-1>a;a++){if(!o||!o[i])return r;o=o[i],i=n[a+1]}return o?ft(o[i],r):r},ht=function(e,t,r){var n=rt(e),o=n?t:r?r(yt(e,t)):yt(e,t);return Ge(o)?Ge(e)?e.concat([o.length]):(n?"":e)+"["+o.length+"]":e},vt=function(e,t){if(e.length){for(var r=e.length,n=t;r-1>n;)e[n]=e[n+1],++n;--e.length}},bt=function(){throw new TypeError('handler passed is not of type "function".')},gt=Array.isArray,mt=Array.prototype.slice,wt=function(e){return e?function(e,t,r,n,o){void 0===o&&(o=n),"function"!=typeof e&&bt();var i=mt.call(arguments,5);if(rt(t))return ot(e.apply(void 0,[n].concat(i)),o,r);var a=yt(t,n);if(void 0!==a){var u=e.apply(void 0,[a].concat(i));return ot(u,o,r)}}:function(e,t,r,n){void 0===n&&(n=r);var o=rt(e)?r:yt(e,r);return ot(o,n,t)}},Ot=function(e){return e?function(e,t,r){"function"!=typeof e&&bt();var n=mt.call(arguments,4);if(rt(t))return e.apply(void 0,[r].concat(n));var o=yt(t,r);return void 0===o?o:e.apply(void 0,[o].concat(n))}:function(e,t){return rt(e)?t:yt(e,t)}},jt=function(e){return e?function(e,t,r,n){"function"!=typeof e&&bt();var o=mt.call(arguments,4);if(rt(r))return e.apply(void 0,[n].concat(o));var i=yt(r,n);return void 0===i?t:e.apply(void 0,[i].concat(o))}:function(e,t,r){return rt(t)?r:yt(t,r,e)}},Et=function(e){return e?function(e,t,r){"function"!=typeof e&&bt();var n=mt.call(arguments,3);if(rt(t))return!!e.apply(void 0,[r].concat(n));var o=yt(t,r);return void 0!==o&&!!e.apply(void 0,[o].concat(n))}:function(e,t){return rt(e)?null!=t:void 0!==yt(e,t)}},Pt=function(e){return e?function(e,t,r,n){"function"!=typeof e&&bt();var o=mt.call(arguments,4);return rt(t)?ut(e.apply(void 0,[n].concat(o)),r):ut(e.apply(void 0,[yt(t,n)].concat(o)),r)}:function(e,t,r){return rt(e)?ut(r,t):ut(yt(e,r),t)}},At=function(e,t){return e?function(e,r,n){"function"!=typeof e&&bt();var o=mt.call(arguments,3);if(!tt(n))return e.apply(void 0,[n].concat(o));if(rt(r)){var i=e.apply(void 0,[n].concat(o));return i?dt(n,i,t):n}var a=!1,u=pt(r,n,function(r,n){var i=e.apply(void 0,[r[n]].concat(o));i&&(r[n]=dt(r[n],i,t),a=!0)});return a?u:n}:function(e,r,n){return tt(n)?rt(e)?dt(n,r,!0):pt(e,n,function(e,n){e[n]=dt(e[n],r,t)}):r}},St=function(e){var t=Pt(e);return function(){return!t.apply(this,arguments)}},xt=function(e){return e?function(e,t,r){"function"!=typeof e&&bt();var n=mt.call(arguments,3);if(rt(t)){var o=it(r);return e.apply(void 0,[o].concat(n))?o:r}var i=yt(t,r);return void 0!==i&&e.apply(void 0,[i].concat(n))?pt(t,r,function(e,t){gt(e)?vt(e,t):delete e[t]}):r}:function(e,t){return rt(e)?it(t):void 0!==yt(e,t)?pt(e,t,function(e,t){gt(e)?vt(e,t):delete e[t]}):t}},_t=function(e){return e?function(e,t,r){"function"!=typeof e&&bt();var n=mt.call(arguments,3);return rt(t)?e.apply(void 0,[r].concat(n)):pt(t,r,function(t,r){t[r]=e.apply(void 0,[t[r]].concat(n))})}:function(e,t,r){return rt(e)?t:pt(e,r,function(e,r){e[r]=t})}},zt=function(e){var t=_t(e);return e?function(e,r,n){return t.apply(this,[e,ht(r,n,e),n].concat(mt.call(arguments,3)))}:function(e,r,n){return t(ht(e,n),r,n)}},kt=(Le(zt(!1),3),Le(zt(!0),3),Le(At(!1,!1),3),Le(At(!0,!1),3),Le(wt(!1),3),Le(wt(!0),4),Le(Ot(!1),2)),It=(Le(jt(!1),3),Le(Ot(!0),3),Le(jt(!0),4),Le(Et(!1),2),Le(Et(!0),3),Le(Pt(!1),3),Le(Pt(!0),4),Le(At(!1,!0),3),Le(At(!0,!0),3),Le(St(!1),3),Le(St(!0),4),Le(xt(!1),2),Le(xt(!0),3),Le(_t(!1),3),Le(_t(!0),3),"You have not provided any values for paths, so no values can be retrieved from state."),Tt="First parameter passed must be either an array or a plain object. If you are creating a standard selector, pass an array of either properties on the state to retrieve, or custom selector functions. If creating a structured selector, pass a plain object with source and destination properties, where source is an array of properties or custom selector functions, and destination is an array of property names to assign the values from source to.",Dt=Object.prototype.hasOwnProperty,Rt=function(e){var t=typeof e;if(function(e,t){return"function"===t}(0,t))return e;if(function(e,t){return"string"===t||"number"===t||Array.isArray(e)}(e,t))return function(t){return kt(e,t)};if(function(e,t){return!!e&&"object"===t}(e,t)){if(Dt.call(e,"path")&&Dt.call(e,"argIndex")){var r=fe(e.argIndex);return function(){return kt(e.path,r.apply(null,arguments))}}throw new ReferenceError('When providing an object path, you must provide the following properties:\n * path: the path to retrieve, e.g. "foo.bar"\n * argIndx: the index of the argument to retrieve the path from')}throw new TypeError('Path provided is of invalid type. It can be any one of the following values:\n * Dot-bracket notation, e.g. "foo.bar" or "bar[0].baz"\n * Number index, e.g. 0\n * Object {path, argIndex}, e.g. {path: "foo.bar", argIndex: 1}\n * Selector function')},Nt=function(e){var t,r=e.deepEqual,n=e.isEqual,o=e.memoizerParams;return(t=Fe).call.apply(t,[null,e.memoizer||Ne,void 0!==r&&r?Te:void 0===n?ge:n].concat(void 0===o?[]:o))},Ct=function(e,t,r){return t(e.map(Rt),r)},Ft=function(e,t){var r,n=Object.keys(e);return t(n.map(function(t){return Rt(e[t])}),(r=n,function(){for(var e=[],t=0;arguments.length>t;t++)e[t]=arguments[t];return r.reduce(function(t,r,n){return t[r]=e[n],t},{})}))};function Mt(e){return(Mt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Ut(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Lt(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=[],n=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}return r}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function Kt(e){return function(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);e.length>t;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var Wt,Xt=function(e,t){return e(t={exports:{}},t.exports),t.exports}(function(e,t){var r=d.compose;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}}});(Wt=Xt)&&Wt.__esModule&&Object.prototype.hasOwnProperty.call(Wt,"default");var $t=Xt.composeWithDevTools;function Vt(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 qt=Vt();function Yt(e){if("object"!==Mt(e)||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function Bt(e){return null==e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||Array.isArray(e)||Yt(e)}qt.withExtraArgument=Vt;var Gt="A non-serializable value was detected in the state, in the path: `%s`. Value: %o\nTake a look at the reducer(s) handling this action type: %s.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)",Ht="A non-serializable value was detected in an action, in the path: `%s`. Value: %o\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)";function Jt(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Bt,o=arguments.length>3?arguments[3]:void 0;if(!n(e))return{keyPath:r.join(".")||"<root>",value:e};if("object"!==Mt(e)||null===e)return!1;var i=null!=o?o(e):Object.entries(e),a=!0,u=!1,c=void 0;try{for(var f,s=i[Symbol.iterator]();!(a=(f=s.next()).done);a=!0){var l=Lt(f.value,2),p=l[1],d=r.concat(l[0]);if(!n(p))return{keyPath:d.join("."),value:p};if("object"===Mt(p)&&(t=Jt(p,d,n,o)))return t}}catch(e){u=!0,c=e}finally{try{a||null==s.return||s.return()}finally{if(u)throw c}}return!1}var Zt=!0;function Qt(){return[qt]}function er(e,t){function r(){if(t){var r=t.apply(void 0,arguments);if(!r)throw Error("prepareAction did not return an object");return"meta"in r?{type:e,payload:r.payload,meta:r.meta}:{type:e,payload:r.payload}}return{type:e,payload:arguments.length>0?arguments[0]:void 0}}return r.toString=function(){return"".concat(e)},r.type=e,r}function tr(e,t){return function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e,n=arguments.length>1?arguments[1]:void 0;return Q(r,function(e){var r=t[n.type];return r?r(e,n):void 0})}}function rr(e,t){return e?"".concat(e,"/").concat(t):t}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?Qt():u,f=r.devTools,p=void 0===f||f,d=r.preloadedState,y=void 0===d?void 0:d,h=r.enhancers,v=void 0===h?[]:h;if("function"==typeof i)t=i;else{if(!Yt(i))throw Error("Reducer argument must be a function or an object of functions that can be passed to combineReducers");t=a(i)}var b=l.apply(void 0,Kt(c)),g=s;p&&(g=$t(function(e){for(var t=1;arguments.length>t;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){Ut(e,t,r[t])})}return e}({trace:!Zt},"object"===Mt(p)&&p)));var m=[b].concat(Kt(v));return o(t,y,g.apply(void 0,Kt(m)))},e.createAction=er,e.createNextState=Q,e.createReducer=tr,e.createSelector=function(e,t,r){void 0===t&&(t=se),void 0===r&&(r={});var n=Nt(r);if(Array.isArray(e)){if(!e.length)throw new ReferenceError(It);return Ct(e,n,t)}if(e&&null!==e&&"object"==typeof e)return Ft(e,n);throw new TypeError(Tt)},e.createSerializableStateInvariantMiddleware=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.isSerializable,r=void 0===t?Bt:t,n=e.getEntries;return function(e){return function(t){return function(o){var i=Jt(o,[],r,n);i&&console.error(Ht,i.keyPath,i.value,o);var a=t(o),u=Jt(e.getState(),[],r,n);return u&&console.error(Gt,u.keyPath,u.value,o.type),a}}}},e.createSlice=function(e){var t=e.slice,r=void 0===t?"":t,n=e.initialState,o=e.reducers||{},i=e.extraReducers||{},a=Object.keys(o),u=tr(n,a.reduce(function(e,t){var n=o[t];return e[rr(r,t)]="function"==typeof n?n:n.reducer,e},i)),c=a.reduce(function(e,t){var n=o[t],i=rr(r,t);return e[t]="function"==typeof n?er(i):er(i,n.prepare),e},{}),f=Ut({},function(e){return e?"get ".concat(e).replace(/(?:^\w|[A-Z]|\b\w)/g,function(e,t){return 0===t?e.toLowerCase():e.toUpperCase()}).replace(/\s+/g,"").replace(/[-_]/g,""):"getState"}(r),function(e){return e?function(t){return t[e]}:function(e){return e}}(r));return{slice:r,reducer:u,actions:c,selectors:f}},e.findNonSerializableValue=Jt,e.getDefaultMiddleware=Qt,e.getType=function(e){return"".concat(e)},e.isPlain=Bt,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).RSK={})}(this,function(e){"use strict";var t=function(e){var t,r=e.Symbol;return"function"==typeof r?r.observable?t=r.observable:(t=r("observable"),r.observable=t):t="@@observable",t}("undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof module?module:Function("return this")()),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 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 Error("Expected the enhancer to be a function.");return i(o)(e,r)}if("function"!=typeof e)throw 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 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 y(e){if("function"!=typeof e)throw Error("Expected the listener to be a function.");if(l)throw 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 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 h(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 Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===e.type)throw Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(l)throw Error("Reducers may not dispatch actions.");try{l=!0,c=u(c,e)}finally{l=!1}for(var t=f=s,r=0;t.length>r;r++){(0,t[r])()}return e}return h({type:n.INIT}),(a={dispatch:h,subscribe:y,getState:d,replaceReducer:function(e){if("function"!=typeof e)throw Error("Expected the nextReducer to be a function.");u=e,h({type:n.REPLACE})}})[t]=function(){var e,r=y;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 "'+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;t.length>o;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 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 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;c.length>a;a++){var f=c[a],s=e[f],l=(0,r[f])(s,t);if(void 0===l){var p=i(f,t);throw 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;arguments.length>t;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=Array(e),r=0;e>r;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=Array(e),r=0;e>r;r++)t[r]=arguments[r];return function(e){return function(){var r=e.apply(void 0,arguments),n=function(){throw 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=Object.freeze({createStore:o,combineReducers:a,bindActionCreators:function(e,t){if("function"==typeof e)return u(e,t);if("object"!=typeof e||null===e)throw 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;r.length>o;o++){var i=r[o],a=e[i];"function"==typeof a&&(n[i]=u(a,t))}return n},applyMiddleware:l,compose:s,__DO_NOT_USE__ActionTypes:n}),y="undefined"!=typeof Symbol?Symbol("immer-nothing"):((p={})["immer-nothing"]=!0,p),h="undefined"!=typeof Symbol?Symbol.for("immer-draftable"):"__$immer_draftable",v="undefined"!=typeof Symbol?Symbol.for("immer-state"):"__$immer_state";function b(e){return!!e&&!!e[v]}function g(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[h]||!!e.constructor[h])}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 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 j(e,t){if(Array.isArray(e))for(var r=0;e.length>r;r++)t(r,e[r],e);else w(e).forEach(function(r){return t(r,e[r],e)})}function E(e,t){return Object.getOwnPropertyDescriptor(e,t).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}var S=function(e){this.drafts=[],this.parent=e,this.canAutoFreeze=!0,this.patches=null};function x(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(x),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 _={};function z(e,t){var r=Array.isArray(e),n=R(e);j(n,function(t){!function(e,t,r){var n=_[t];n?n.enumerable=r:_[t]=n={configurable:!0,enumerable:r,get:function(){return function(e,t){C(e);var r=D(T(e),t);if(e.finalizing)return r;if(r===D(e.base,t)&&g(r))return N(e),e.copy[t]=z(r,e);return r}(this[v],t)},set:function(e){!function(e,t,r){if(C(e),e.assigned[t]=!0,!e.modified){if(A(r,D(T(e),t)))return;I(e),N(e)}e.copy[t]=r}(this[v],t,e)}};Object.defineProperty(e,t,n)}(n,t,r||E(e,t))});var o=t?t.scope:S.current;return Object.defineProperty(n,v,{value:{scope:o,modified:!1,finalizing:!1,finalized:!1,assigned:{},parent:t,base:e,draft:n,copy:null,revoke:k,revoked:!1},enumerable:!1,writable:!0}),o.drafts.push(n),n}function k(){this.revoked=!0}function T(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 N(e){e.copy||(e.copy=R(e.base))}function R(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 Error("Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+JSON.stringify(T(e)))}function F(e){for(var t=e.length-1;t>=0;t--){var r=e[t][v];r.modified||(Array.isArray(r.base)?M(r)&&I(r):U(r)&&I(r))}}function U(e){for(var t=e.base,r=e.draft,n=Object.keys(r),o=n.length-1;o>=0;o--){var i=n[o],a=t[i];if(void 0===a&&!P(t,i))return!0;var u=r[i],c=u&&u[v];if(c?c.base!==a:!A(u,a))return!0}return n.length!==Object.keys(t).length}function M(e){var t=e.draft;if(t.length!==e.base.length)return!0;var r=Object.getOwnPropertyDescriptor(t,t.length-1);return!(!r||r.get)}var L=Object.freeze({willFinalize:function(e,t,r){e.drafts.forEach(function(e){e[v].finalizing=!0}),r?b(t)&&t[v].scope===e&&F(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(M(r)){if(I(r),i.length=!0,n.length>o.length)for(var a=o.length;n.length>a;a++)i[a]=!1;else for(var u=n.length;o.length>u;u++)i[u]=!0;for(var c=0;o.length>c;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]),F(e.drafts))},createProxy:z});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=W(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 W(e)},ownKeys:function(e){return Reflect.ownKeys(W(e))},set:function(e,t,r){if(!e.modified){var n=B(e.base,t),o=r?A(n,r)||r===e.drafts[t]:A(n,r)&&t in e.base;if(o)return!0;Y(e)}return e.assigned[t]=!0,e.copy[t]=r,!0},deleteProperty:function(e,t){(void 0!==B(e.base,t)||t in e.base)&&(e.assigned[t]=!1,Y(e));e.copy&&delete e.copy[t];return!0},getOwnPropertyDescriptor:function(e,t){var r=W(e),n=Reflect.getOwnPropertyDescriptor(r,t);n&&(n.writable=!0,n.configurable=!Array.isArray(r)||"length"!==t);return n},defineProperty:function(){throw Error("Object.defineProperty() cannot be used on an Immer draft")},getPrototypeOf:function(e){return Object.getPrototypeOf(e.base)},setPrototypeOf:function(){throw Error("Object.setPrototypeOf() cannot be used on an Immer draft")}},V={};function W(e){return e.copy||e.base}function B(e,t){var r=e[v],n=Reflect.getOwnPropertyDescriptor(r?W(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))}j(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 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 Error("Immer only supports setting array indices and the 'length' property");return X.set.call(this,e[0],t,r)};var q=Object.freeze({willFinalize:function(){},createProxy:K});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;a.length>u.length&&(a=(o=[u,a])[0],u=o[1],r=(i=[n,r])[0],n=i[1]);var f=u.length-a.length,s=0;for(;a[s]===u[s]&&a.length>s;)++s;var l=a.length;for(;l>s&&a[l-1]===u[l+f-1];)--l;for(var p=s;l>p;++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 y=l!=a.length,h=r.length,v=l+f-1;v>=l;--v){var b=t.concat([v]);r[h+v-l]={op:"add",path:b,value:u[v]},y&&n.push({op:"remove",path:b})}y||n.push({op:"replace",path:t.concat(["length"]),value:a.length})}(e,t,r,n):function(e,t,r,n){var o=e.base,i=e.copy;j(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)}function G(e,t){for(var r=0;t.length>r;r++){var n=t[r],o=n.path;if(0===o.length&&"replace"===n.op)e=n.value;else{for(var i=e,a=0;o.length-1>a;a++)if(!(i=i[o[a]])||"object"!=typeof i)throw Error("Cannot apply patch, path doesn't resolve: "+o.join("/"));var u=o[o.length-1];switch(n.op){case"replace":i[u]=n.value;break;case"add":Array.isArray(i)?i.splice(u,0,n.value):i[u]=n.value;break;case"remove":Array.isArray(i)?i.splice(u,1):delete i[u];break;default:throw Error("Unsupported patch operation: "+n.op)}}}return e}var H={useProxies:"undefined"!=typeof Proxy&&"undefined"!=typeof Reflect,autoFreeze:!1,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;return t=e,function(e){void 0===e&&(e=i);for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return o.produce(e,function(e){return t.call.apply(t,[e,e].concat(r))})}}if("function"!=typeof t)throw Error("The first or second argument to `produce` must be a function");if(void 0!==r&&"function"!=typeof r)throw Error("The third argument to `produce` must be a function or undefined");if(g(e)){var a=S.enter(),u=this.createProxy(e),c=!0;try{n=t.call(u,u),c=!1}finally{c?a.revoke():a.leave()}return n instanceof Promise?n.then(function(e){return a.usePatches(r),o.processResult(e,a)},function(e){throw a.revoke(),e}):(a.usePatches(r),this.processResult(n,a))}return void 0===(n=t(e))?e:n!==y?n:void 0},J.prototype.createDraft=function(e){if(!g(e))throw 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 Error("First argument to `finishDraft` must be a draft returned by `createDraft`");if(r.finalized)throw 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?q:L)},J.prototype.applyPatches=function(e,t){return b(e)?G(e,t):this.produce(e,function(e){return G(e,t)})},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(),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)),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!==y?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 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;j(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&&$(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)||E(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)&&j(c,a)}s&&n.onAssign&&n.onAssign(o,u,c)};return j(e,a),e};var Q=new J,Z=Q.produce;Q.setAutoFreeze.bind(Q),Q.setUseProxies.bind(Q),Q.applyPatches.bind(Q),Q.createDraft.bind(Q),Q.finishDraft.bind(Q);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;n>o;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 Error("Selector creators expect all input-selectors to be functions, instead received the following types: ["+r+"]")}return t}var ne=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;t>n;n++)r[n-1]=arguments[n];return function(){for(var t=arguments.length,n=Array(t),o=0;t>o;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;t>r;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(e){return(oe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ie(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ae(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=[],n=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}return r}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function ue(e){return function(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);e.length>t;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var ce,fe=function(e,t){return e(t={exports:{}},t.exports),t.exports}(function(e,t){var r=d.compose;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}}});(ce=fe)&&ce.__esModule&&Object.prototype.hasOwnProperty.call(ce,"default");var se=fe.composeWithDevTools;function le(e){if("object"!==oe(e)||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function pe(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 de=pe();function ye(e){return null==e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||Array.isArray(e)||le(e)}de.withExtraArgument=pe;var he="A non-serializable value was detected in the state, in the path: `%s`. Value: %o\nTake a look at the reducer(s) handling this action type: %s.\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)",ve="A non-serializable value was detected in an action, in the path: `%s`. Value: %o\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)";function be(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ye,o=arguments.length>3?arguments[3]:void 0;if(!n(e))return{keyPath:r.join(".")||"<root>",value:e};if("object"!==oe(e)||null===e)return!1;var i=null!=o?o(e):Object.entries(e),a=!0,u=!1,c=void 0;try{for(var f,s=i[Symbol.iterator]();!(a=(f=s.next()).done);a=!0){var l=ae(f.value,2),p=l[1],d=r.concat(l[0]);if(!n(p))return{keyPath:d.join("."),value:p};if("object"===oe(p)&&(t=be(p,d,n,o)))return t}}catch(e){u=!0,c=e}finally{try{a||null==s.return||s.return()}finally{if(u)throw c}}return!1}function ge(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.thunk,r=void 0===t||t,n=[];return r&&(!function(e){return"boolean"==typeof e}(r)?n.push(de.withExtraArgument(r.extraArgument)):n.push(de)),n}var me=!0;function we(e,t){function r(){if(t){var r=t.apply(void 0,arguments);if(!r)throw Error("prepareAction did not return an object");return"meta"in r?{type:e,payload:r.payload,meta:r.meta}:{type:e,payload:r.payload}}return{type:e,payload:arguments.length>0?arguments[0]:void 0}}return r.toString=function(){return"".concat(e)},r.type=e,r}function Oe(e,t){return function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e,n=arguments.length>1?arguments[1]:void 0;return Z(r,function(e){var r=t[n.type];return r?r(e,n):void 0})}}function je(e,t){return e?"".concat(e,"/").concat(t):t}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?ge():u,f=r.devTools,p=void 0===f||f,d=r.preloadedState,y=void 0===d?void 0:d,h=r.enhancers,v=void 0===h?void 0:h;if("function"==typeof i)t=i;else{if(!le(i))throw Error("Reducer argument must be a function or an object of functions that can be passed to combineReducers");t=a(i)}var b=l.apply(void 0,ue(c)),g=s;p&&(g=se(function(e){for(var t=1;arguments.length>t;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){ie(e,t,r[t])})}return e}({trace:!me},"object"===oe(p)&&p)));var m=[b];return Array.isArray(v)?m=[b].concat(ue(v)):"function"==typeof v&&(m=v(m)),o(t,y,g.apply(void 0,ue(m)))},e.createAction=we,e.createNextState=Z,e.createReducer=Oe,e.createSelector=ne,e.createSerializableStateInvariantMiddleware=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.isSerializable,r=void 0===t?ye: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=be(o,[],r,n);a&&console.error(ve,a.keyPath,a.value,o);var u=t(o),c=be(e.getState(),[],r,n);return c&&console.error(he,c.keyPath,c.value,o.type),u}}}},e.createSlice=function(e){var t=e.slice,r=void 0===t?"":t,n=e.initialState,o=e.reducers||{},i=e.extraReducers||{},a=Object.keys(o),u=Oe(n,a.reduce(function(e,t){var n=o[t];return e[je(r,t)]="function"==typeof n?n:n.reducer,e},i)),c=a.reduce(function(e,t){var n=o[t],i=je(r,t);return e[t]="function"==typeof n?we(i):we(i,n.prepare),e},{});return{slice:r,reducer:u,actions:c}},e.findNonSerializableValue=be,e.getDefaultMiddleware=ge,e.getType=function(e){return"".concat(e)},e.isPlain=ye,Object.defineProperty(e,"__esModule",{value:!0})}); |
@@ -31,2 +31,6 @@ import { Middleware } from 'redux'; | ||
getEntries?: (value: any) => [string, any][]; | ||
/** | ||
* An array of action types to ignore when checking for serializability, Defaults to [] | ||
*/ | ||
ignoredActions?: string[]; | ||
} | ||
@@ -33,0 +37,0 @@ /** |
export { Action, ActionCreator, AnyAction, Middleware, Reducer, Store, StoreEnhancer, combineReducers, compose } from 'redux'; | ||
export { default as createNextState } from 'immer'; | ||
export { default as createSelector } from 'selectorator'; | ||
export { createSelector } from 'reselect'; | ||
export * from '.'; |
{ | ||
"name": "redux-starter-kit", | ||
"version": "0.6.3", | ||
"version": "0.7.0", | ||
"description": "A simple set of tools to make using Redux easier", | ||
@@ -18,3 +18,3 @@ "repository": "https://github.com/reduxjs/redux-starter-kit", | ||
"@types/node": "^10.14.4", | ||
"@types/redux-immutable-state-invariant": "^2.1.0", | ||
"@types/redux-immutable-state-invariant": "^2.1.1", | ||
"@typescript-eslint/parser": "^1.6.0", | ||
@@ -29,3 +29,3 @@ "babel-eslint": "^10.0.1", | ||
"jest": "^24.7.1", | ||
"prettier": "^1.17.0", | ||
"prettier": "^1.18.2", | ||
"react": "^16.8.6", | ||
@@ -48,3 +48,3 @@ "rollup": "^1.9.0", | ||
"lint": "eslint \"src/**/*.ts\"", | ||
"prepare": "npm run tsc && npm run lint && npm test && npm run build", | ||
"prepare": "npm run tsc && npm run lint && npm run format:check && npm test && npm run build", | ||
"test": "jest", | ||
@@ -63,3 +63,3 @@ "tsc": "tsc" | ||
"redux-thunk": "^2.2.0", | ||
"selectorator": "^4.0.3" | ||
"reselect": "^4.0.0" | ||
}, | ||
@@ -66,0 +66,0 @@ "jest": { |
@@ -1,27 +0,6 @@ | ||
import { configureStore, getDefaultMiddleware } from './configureStore' | ||
import { configureStore } from './configureStore' | ||
import * as redux from 'redux' | ||
import * as devtools from 'redux-devtools-extension' | ||
import { StoreEnhancer, StoreEnhancerStoreCreator } from 'redux' | ||
import thunk from 'redux-thunk' | ||
describe('getDefaultMiddleware', () => { | ||
const ORIGINAL_NODE_ENV = process.env.NODE_ENV | ||
afterEach(() => { | ||
process.env.NODE_ENV = ORIGINAL_NODE_ENV | ||
}) | ||
it('returns an array with only redux-thunk in production', () => { | ||
process.env.NODE_ENV = 'production' | ||
expect(getDefaultMiddleware()).toEqual([thunk]) | ||
}) | ||
it('returns an array with additional middleware in development', () => { | ||
const middleware = getDefaultMiddleware() | ||
expect(middleware).toContain(thunk) | ||
expect(middleware.length).toBeGreaterThan(1) | ||
}) | ||
}) | ||
describe('configureStore', () => { | ||
@@ -169,3 +148,26 @@ jest.spyOn(redux, 'applyMiddleware') | ||
}) | ||
it('accepts a callback for customizing enhancers', () => { | ||
let dummyEnhancerCalled = false | ||
const dummyEnhancer: StoreEnhancer = ( | ||
createStore: StoreEnhancerStoreCreator | ||
) => (reducer, ...args: any[]) => { | ||
dummyEnhancerCalled = true | ||
return createStore(reducer, ...args) | ||
} | ||
const reducer = () => ({}) | ||
const store = configureStore({ | ||
reducer, | ||
enhancers: defaultEnhancers => { | ||
return [...defaultEnhancers, dummyEnhancer] | ||
} | ||
}) | ||
expect(dummyEnhancerCalled).toBe(true) | ||
}) | ||
}) | ||
}) |
@@ -15,39 +15,17 @@ import { | ||
} from 'redux' | ||
import { composeWithDevTools, EnhancerOptions } from 'redux-devtools-extension' | ||
import thunk, { ThunkDispatch, ThunkMiddleware } from 'redux-thunk' | ||
import { | ||
composeWithDevTools, | ||
EnhancerOptions as DevToolsOptions | ||
} from 'redux-devtools-extension' | ||
import { ThunkDispatch } from 'redux-thunk' | ||
// UMD-DEV-ONLY: import createImmutableStateInvariantMiddleware from 'redux-immutable-state-invariant' | ||
import { createSerializableStateInvariantMiddleware } from './serializableStateInvariantMiddleware' | ||
import isPlainObject from './isPlainObject' | ||
import { getDefaultMiddleware } from './getDefaultMiddleware' | ||
const IS_PRODUCTION = process.env.NODE_ENV === 'production' | ||
/** | ||
* Returns any array containing the default middleware installed by | ||
* `configureStore()`. Useful if you want to configure your store with a custom | ||
* `middleware` array but still keep the default set. | ||
* | ||
* @return The default middleware used by `configureStore()`. | ||
*/ | ||
export function getDefaultMiddleware<S = any, A extends Action = AnyAction>(): [ | ||
ThunkMiddleware<S, A>, | ||
...Middleware<{}, S>[] | ||
] { | ||
let middlewareArray: [ThunkMiddleware<S, A>, ...Middleware<{}, S>[]] = [thunk] | ||
export type ConfigureEnhancersCallback = ( | ||
defaultEnhancers: StoreEnhancer[] | ||
) => StoreEnhancer[] | ||
if (process.env.NODE_ENV !== 'production') { | ||
/* START_REMOVE_UMD */ | ||
const createImmutableStateInvariantMiddleware = require('redux-immutable-state-invariant') | ||
.default | ||
middlewareArray.unshift(createImmutableStateInvariantMiddleware()) | ||
/* STOP_REMOVE_UMD */ | ||
middlewareArray.push(createSerializableStateInvariantMiddleware()) | ||
} | ||
return middlewareArray | ||
} | ||
/** | ||
@@ -72,8 +50,9 @@ * Options for `configureStore()`. | ||
* | ||
* Additional configuration can be done by passing enhancer options | ||
* Additional configuration can be done by passing Redux DevTools options | ||
*/ | ||
devTools?: boolean | EnhancerOptions | ||
devTools?: boolean | DevToolsOptions | ||
/** | ||
* The initial state. You may optionally specify it to hydrate the state | ||
* The initial state, same as Redux's createStore. | ||
* You may optionally specify it to hydrate the state | ||
* from the server in universal apps, or to restore a previously serialized | ||
@@ -91,6 +70,10 @@ * user session. If you use `combineReducers()` to produce the root reducer | ||
/** | ||
* The store enhancers to apply. See Redux's `createStore()`. If you only | ||
* need to add middleware, you can use the `middleware` parameter instaead. | ||
* The store enhancers to apply. See Redux's `createStore()`. | ||
* All enhancers will be included before the DevTools Extension enhancer. | ||
* If you need to customize the order of enhancers, supply a callback | ||
* function that will receive the original array (ie, `[applyMiddleware]`), | ||
* and should return a new array (such as `[applyMiddleware, offline]`). | ||
* If you only need to add middleware, you can use the `middleware` parameter instaead. | ||
*/ | ||
enhancers?: StoreEnhancer[] | ||
enhancers?: StoreEnhancer[] | ConfigureEnhancersCallback | ||
} | ||
@@ -121,3 +104,3 @@ | ||
preloadedState = undefined, | ||
enhancers = [] | ||
enhancers = undefined | ||
} = options || {} | ||
@@ -149,4 +132,10 @@ | ||
const storeEnhancers = [middlewareEnhancer, ...enhancers] | ||
let storeEnhancers: StoreEnhancer[] = [middlewareEnhancer] | ||
if (Array.isArray(enhancers)) { | ||
storeEnhancers = [middlewareEnhancer, ...enhancers] | ||
} else if (typeof enhancers === 'function') { | ||
storeEnhancers = enhancers(storeEnhancers) | ||
} | ||
const composedEnhancer = finalCompose(...storeEnhancers) as StoreEnhancer | ||
@@ -153,0 +142,0 @@ |
@@ -9,2 +9,3 @@ import { Action } from 'redux' | ||
* @template T the type used for the action type. | ||
* @template M The type of the action's meta (optional) | ||
*/ | ||
@@ -15,8 +16,4 @@ export type PayloadAction< | ||
M = void | ||
> = Action<T> & { | ||
payload: P | ||
} & ([M] extends [void] ? {} : { meta: M }) | ||
> = WithOptionalMeta<M, WithPayload<P, Action<T>>> | ||
export type Diff<T, U> = T extends U ? never : T | ||
export type PrepareAction<P> = | ||
@@ -26,2 +23,32 @@ | ((...args: any[]) => { payload: P }) | ||
export type ActionCreatorWithPreparedPayload< | ||
PA extends PrepareAction<any> | void, | ||
T extends string = string | ||
> = WithTypeProperty< | ||
T, | ||
PA extends PrepareAction<infer P> | ||
? (...args: Parameters<PA>) => PayloadAction<P, T, MetaOrVoid<PA>> | ||
: void | ||
> | ||
export type ActionCreatorWithOptionalPayload< | ||
P, | ||
T extends string = string | ||
> = WithTypeProperty< | ||
T, | ||
{ | ||
(payload?: undefined): PayloadAction<undefined, T> | ||
<PT extends Diff<P, undefined>>(payload?: PT): PayloadAction<PT, T> | ||
} | ||
> | ||
export type ActionCreatorWithoutPayload< | ||
T extends string = string | ||
> = WithTypeProperty<T, () => PayloadAction<undefined, T>> | ||
export type ActionCreatorWithPayload< | ||
P, | ||
T extends string = string | ||
> = WithTypeProperty<T, <PT extends P>(payload: PT) => PayloadAction<PT, T>> | ||
/** | ||
@@ -34,25 +61,18 @@ * An action creator that produces actions with a `payload` attribute. | ||
PA extends PrepareAction<P> | void = void | ||
> = { | ||
type: T | ||
} & (PA extends (...args: any[]) => any | ||
? (ReturnType<PA> extends { meta: infer M } | ||
? (...args: Parameters<PA>) => PayloadAction<P, T, M> | ||
: (...args: Parameters<PA>) => PayloadAction<P, T>) | ||
: (/* | ||
* The `P` generic is wrapped with a single-element tuple to prevent the | ||
* conditional from being checked distributively, thus preserving unions | ||
* of contra-variant types. | ||
*/ | ||
[undefined] extends [P] | ||
? { | ||
(payload?: undefined): PayloadAction<undefined, T> | ||
<PT extends Diff<P, undefined>>(payload?: PT): PayloadAction<PT, T> | ||
} | ||
: [void] extends [P] | ||
? { | ||
(): PayloadAction<undefined, T> | ||
} | ||
: { | ||
<PT extends P>(payload: PT): PayloadAction<PT, T> | ||
})) | ||
> = IfPrepareActionMethodProvided< | ||
PA, | ||
ActionCreatorWithPreparedPayload<PA, T>, | ||
// else | ||
IfMaybeUndefined< | ||
P, | ||
ActionCreatorWithOptionalPayload<P, T>, | ||
// else | ||
IfVoid< | ||
P, | ||
ActionCreatorWithoutPayload<T>, | ||
// else | ||
ActionCreatorWithPayload<P, T> | ||
> | ||
> | ||
> | ||
@@ -67,2 +87,4 @@ /** | ||
* @param type The action type to use for created actions. | ||
* @param prepare (optional) a method that takes any number of arguments and returns { payload } or { payload, meta }. | ||
* If this is given, the resulting action creator will pass it's arguments to this method to calculate payload & meta. | ||
*/ | ||
@@ -116,1 +138,29 @@ | ||
} | ||
// helper types for more readable typings | ||
type Diff<T, U> = T extends U ? never : T | ||
type WithPayload<P, T> = T & { payload: P } | ||
type WithOptionalMeta<M, T> = T & ([M] extends [void] ? {} : { meta: M }) | ||
type WithTypeProperty<T, MergeIn> = { | ||
type: T | ||
} & MergeIn | ||
type IfPrepareActionMethodProvided< | ||
PA extends PrepareAction<any> | void, | ||
True, | ||
False | ||
> = PA extends (...args: any[]) => any ? True : False | ||
type MetaOrVoid<PA extends PrepareAction<any>> = ReturnType<PA> extends { | ||
meta: infer M | ||
} | ||
? M | ||
: void | ||
type IfMaybeUndefined<P, True, False> = [undefined] extends [P] ? True : False | ||
type IfVoid<P, True, False> = [void] extends [P] ? True : False |
@@ -6,3 +6,3 @@ import { createSlice } from './createSlice' | ||
describe('when slice is empty', () => { | ||
const { actions, reducer, selectors } = createSlice({ | ||
const { actions, reducer } = createSlice({ | ||
reducers: { | ||
@@ -47,16 +47,6 @@ increment: state => state + 1, | ||
}) | ||
describe('when using selectors', () => { | ||
it('should create selector with correct name', () => { | ||
expect(selectors.hasOwnProperty('getState')).toBe(true) | ||
}) | ||
it('should return the slice state data', () => { | ||
expect(selectors.getState(2)).toEqual(2) | ||
}) | ||
}) | ||
}) | ||
describe('when passing slice', () => { | ||
const { actions, reducer, selectors } = createSlice({ | ||
const { actions, reducer } = createSlice({ | ||
reducers: { | ||
@@ -83,10 +73,2 @@ increment: state => state + 1 | ||
}) | ||
it('should create selector with correct name', () => { | ||
expect(selectors.hasOwnProperty('getCool')).toBe(true) | ||
}) | ||
it('should return the slice state data', () => { | ||
expect(selectors.getCool({ cool: 2 })).toEqual(2) | ||
}) | ||
}) | ||
@@ -93,0 +75,0 @@ |
@@ -6,6 +6,7 @@ import { Reducer } from 'redux' | ||
PayloadActionCreator, | ||
PrepareAction | ||
PrepareAction, | ||
ActionCreatorWithoutPayload, | ||
ActionCreatorWithPreparedPayload | ||
} from './createAction' | ||
import { createReducer, CaseReducers, CaseReducer } from './createReducer' | ||
import { createSliceSelector, createSelectorName } from './sliceSelector' | ||
@@ -20,4 +21,4 @@ /** | ||
export interface Slice< | ||
S = any, | ||
AC extends { [key: string]: any } = { [key: string]: any } | ||
State = any, | ||
ActionCreators extends { [key: string]: any } = { [key: string]: any } | ||
> { | ||
@@ -32,3 +33,3 @@ /** | ||
*/ | ||
reducer: Reducer<S> | ||
reducer: Reducer<State> | ||
@@ -39,11 +40,3 @@ /** | ||
*/ | ||
actions: AC | ||
/** | ||
* Selectors for the slice reducer state. `createSlice()` inserts a single | ||
* selector that returns the entire slice state and whose name is | ||
* automatically derived from the slice name (e.g., `getCounter` for a slice | ||
* named `counter`). | ||
*/ | ||
selectors: { [key: string]: (state: any) => S } | ||
actions: ActionCreators | ||
} | ||
@@ -55,8 +48,7 @@ | ||
export interface CreateSliceOptions< | ||
S = any, | ||
CR extends SliceCaseReducers<S, any> = SliceCaseReducers<S, any> | ||
State = any, | ||
CR extends SliceCaseReducers<State, any> = SliceCaseReducers<State, any> | ||
> { | ||
/** | ||
* The slice's name. Used to namespace the generated action types and to | ||
* name the selector for retrieving the reducer's state. | ||
* The slice's name. Used to namespace the generated action types. | ||
*/ | ||
@@ -68,3 +60,3 @@ slice?: string | ||
*/ | ||
initialState: S | ||
initialState: State | ||
@@ -83,37 +75,75 @@ /** | ||
*/ | ||
extraReducers?: CaseReducers<S, any> | ||
extraReducers?: CaseReducers<State, any> | ||
} | ||
type PayloadActions<T extends keyof any = string> = Record<T, PayloadAction> | ||
type PayloadActions<Types extends keyof any = string> = Record< | ||
Types, | ||
PayloadAction | ||
> | ||
type EnhancedCaseReducer<S, A extends PayloadAction> = { | ||
reducer: CaseReducer<S, A> | ||
prepare: PrepareAction<A['payload']> | ||
type EnhancedCaseReducer<State, Action extends PayloadAction> = { | ||
reducer: CaseReducer<State, Action> | ||
prepare: PrepareAction<Action['payload']> | ||
} | ||
type SliceCaseReducers<S, PA extends PayloadActions> = { | ||
[T in keyof PA]: CaseReducer<S, PA[T]> | EnhancedCaseReducer<S, PA[T]> | ||
type SliceCaseReducers<State, PA extends PayloadActions> = { | ||
[ActionType in keyof PA]: | ||
| CaseReducer<State, PA[ActionType]> | ||
| EnhancedCaseReducer<State, PA[ActionType]> | ||
} | ||
type CaseReducerActions<CR extends SliceCaseReducers<any, any>> = { | ||
[T in keyof CR]: CR[T] extends (state: any) => any | ||
? PayloadActionCreator<void> | ||
: (CR[T] extends (state: any, action: PayloadAction<infer P>) => any | ||
? PayloadActionCreator<P> | ||
: CR[T] extends { prepare: PrepareAction<infer P> } | ||
? PayloadActionCreator<P, string, CR[T]['prepare']> | ||
: PayloadActionCreator<void>) | ||
type IfIsReducerFunctionWithoutAction<R, True, False = never> = R extends ( | ||
state: any | ||
) => any | ||
? True | ||
: False | ||
type IfIsEnhancedReducer<R, True, False = never> = R extends { | ||
prepare: Function | ||
} | ||
? True | ||
: False | ||
type NoInfer<T> = [T][T extends any ? 0 : never]; | ||
type SliceCaseReducersCheck<S, ACR> = { | ||
[P in keyof ACR] : ACR[P] extends { | ||
reducer(s:S, action?: { payload: infer O }): any | ||
} ? { | ||
prepare(...a:never[]): { payload: O } | ||
} : { | ||
type PayloadForReducer<R> = R extends ( | ||
state: any, | ||
action: PayloadAction<infer P> | ||
) => any | ||
? P | ||
: void | ||
type PrepareActionForReducer<R> = R extends { prepare: infer Prepare } | ||
? Prepare | ||
: never | ||
} | ||
type CaseReducerActions<CaseReducers extends SliceCaseReducers<any, any>> = { | ||
[Type in keyof CaseReducers]: IfIsEnhancedReducer< | ||
CaseReducers[Type], | ||
ActionCreatorWithPreparedPayload< | ||
PrepareActionForReducer<CaseReducers[Type]> | ||
>, | ||
// else | ||
IfIsReducerFunctionWithoutAction< | ||
CaseReducers[Type], | ||
ActionCreatorWithoutPayload, | ||
// else | ||
PayloadActionCreator<PayloadForReducer<CaseReducers[Type]>> | ||
> | ||
> | ||
} | ||
type NoInfer<T> = [T][T extends any ? 0 : never] | ||
type SliceCaseReducersCheck<S, ACR> = { | ||
[P in keyof ACR]: ACR[P] extends { | ||
reducer(s: S, action?: { payload: infer O }): any | ||
} | ||
? { | ||
prepare(...a: never[]): { payload: O } | ||
} | ||
: {} | ||
} | ||
type RestrictEnhancedReducersToMatchReducerAndPrepare< | ||
S, | ||
CR extends SliceCaseReducers<S, any> | ||
> = { reducers: SliceCaseReducersCheck<S, NoInfer<CR>> } | ||
function getType(slice: string, actionKey: string): string { | ||
@@ -126,3 +156,3 @@ return slice ? `${slice}/${actionKey}` : actionKey | ||
* functions, and optionally a "slice name", and automatically generates | ||
* action creators, action types, and selectors that correspond to the | ||
* action creators and action types that correspond to the | ||
* reducers and state. | ||
@@ -132,8 +162,17 @@ * | ||
*/ | ||
export function createSlice<S, CR extends SliceCaseReducers<S, any>>( | ||
options: CreateSliceOptions<S, CR> & { reducers: SliceCaseReducersCheck<S, NoInfer<CR>> } | ||
): Slice<S, CaseReducerActions<CR>> | ||
export function createSlice<S, CR extends SliceCaseReducers<S, any>>( | ||
options: CreateSliceOptions<S, CR> | ||
): Slice<S, CaseReducerActions<CR>> { | ||
export function createSlice< | ||
State, | ||
CaseReducers extends SliceCaseReducers<State, any> | ||
>( | ||
options: CreateSliceOptions<State, CaseReducers> & | ||
RestrictEnhancedReducersToMatchReducerAndPrepare<State, CaseReducers> | ||
): Slice<State, CaseReducerActions<CaseReducers>> | ||
// internal definition is a little less restrictive | ||
export function createSlice< | ||
State, | ||
CaseReducers extends SliceCaseReducers<State, any> | ||
>( | ||
options: CreateSliceOptions<State, CaseReducers> | ||
): Slice<State, CaseReducerActions<CaseReducers>> { | ||
const { slice = '', initialState } = options | ||
@@ -168,12 +207,7 @@ const reducers = options.reducers || {} | ||
const selectors = { | ||
[createSelectorName(slice)]: createSliceSelector(slice) | ||
} | ||
return { | ||
slice, | ||
reducer, | ||
actions: actionMap, | ||
selectors | ||
actions: actionMap | ||
} | ||
} |
export { combineReducers, compose } from 'redux' | ||
export { default as createNextState } from 'immer' | ||
export { default as createSelector } from 'selectorator' | ||
export { createSelector } from 'reselect' | ||
@@ -10,1 +10,2 @@ export * from './configureStore' | ||
export * from './serializableStateInvariantMiddleware' | ||
export * from './getDefaultMiddleware' |
@@ -7,3 +7,3 @@ import { Reducer } from 'redux' | ||
findNonSerializableValue, | ||
isPlain, | ||
isPlain | ||
} from './serializableStateInvariantMiddleware' | ||
@@ -165,31 +165,29 @@ | ||
describe('consumer tolerated structures', () => { | ||
const nonSerializableValue = new Map(); | ||
const nonSerializableValue = new Map() | ||
const nestedSerializableObjectWithBadValue = { | ||
isSerializable: true, | ||
entries: (): [string, any][] => | ||
[ | ||
['good-string', 'Good!'], | ||
['good-number', 1337], | ||
['bad-map-instance', nonSerializableValue], | ||
], | ||
}; | ||
const serializableObject = { | ||
isSerializable: true, | ||
entries: (): [string, any][] => | ||
[ | ||
['first', 1], | ||
['second', 'B!'], | ||
['third', nestedSerializableObjectWithBadValue] | ||
], | ||
}; | ||
isSerializable: true, | ||
entries: (): [string, any][] => [ | ||
['good-string', 'Good!'], | ||
['good-number', 1337], | ||
['bad-map-instance', nonSerializableValue] | ||
] | ||
} | ||
const serializableObject = { | ||
isSerializable: true, | ||
entries: (): [string, any][] => [ | ||
['first', 1], | ||
['second', 'B!'], | ||
['third', nestedSerializableObjectWithBadValue] | ||
] | ||
} | ||
it('Should log an error when a non-serializable value is nested in state', () => { | ||
const ACTION_TYPE = 'TEST_ACTION' | ||
const initialState = { | ||
a: 0 | ||
} | ||
const reducer: Reducer = (state = initialState, action) => { | ||
@@ -206,6 +204,6 @@ switch (action.type) { | ||
} | ||
// use default options | ||
const serializableStateInvariantMiddleware = createSerializableStateInvariantMiddleware() | ||
const store = configureStore({ | ||
@@ -217,8 +215,7 @@ reducer: { | ||
}) | ||
store.dispatch({ type: ACTION_TYPE }) | ||
expect(console.error).toHaveBeenCalled() | ||
const [ | ||
@@ -230,3 +227,3 @@ message, | ||
] = (console.error as jest.Mock).mock.calls[0] | ||
// since default options are used, the `entries` function in `serializableObject` will cause the error | ||
@@ -236,3 +233,3 @@ expect(message).toContain('detected in the state, in the path: `%s`') | ||
expect(value).toBe(serializableObject.entries) | ||
expect(actionType).toBe(ACTION_TYPE) | ||
expect(actionType).toBe(ACTION_TYPE) | ||
}) | ||
@@ -242,10 +239,12 @@ | ||
const ACTION_TYPE = 'TEST_ACTION' | ||
const initialState = { | ||
a: 0 | ||
} | ||
const isSerializable = (val: any): boolean => val.isSerializable || isPlain(val); | ||
const getEntries = (val: any): [string, any][] => val.isSerializable ? val.entries() : Object.entries(val); | ||
const isSerializable = (val: any): boolean => | ||
val.isSerializable || isPlain(val) | ||
const getEntries = (val: any): [string, any][] => | ||
val.isSerializable ? val.entries() : Object.entries(val) | ||
const reducer: Reducer = (state = initialState, action) => { | ||
@@ -262,5 +261,7 @@ switch (action.type) { | ||
} | ||
const serializableStateInvariantMiddleware = createSerializableStateInvariantMiddleware({ isSerializable, getEntries }) | ||
const serializableStateInvariantMiddleware = createSerializableStateInvariantMiddleware( | ||
{ isSerializable, getEntries } | ||
) | ||
const store = configureStore({ | ||
@@ -272,7 +273,7 @@ reducer: { | ||
}) | ||
store.dispatch({ type: ACTION_TYPE }) | ||
expect(console.error).toHaveBeenCalled() | ||
const [ | ||
@@ -284,3 +285,3 @@ message, | ||
] = (console.error as jest.Mock).mock.calls[0] | ||
// error reported is from a nested class instance, rather than the `entries` function `serializableObject` | ||
@@ -290,5 +291,6 @@ expect(message).toContain('detected in the state, in the path: `%s`') | ||
expect(value).toBe(nonSerializableValue) | ||
expect(actionType).toBe(ACTION_TYPE) | ||
}) | ||
}); | ||
expect(actionType).toBe(ACTION_TYPE) | ||
}) | ||
}) | ||
it('Should use the supplied isSerializable function to determine serializability', () => { | ||
@@ -315,5 +317,7 @@ const ACTION_TYPE = 'TEST_ACTION' | ||
const serializableStateInvariantMiddleware = createSerializableStateInvariantMiddleware({ | ||
isSerializable: (value: any) => true | ||
}) | ||
const serializableStateInvariantMiddleware = createSerializableStateInvariantMiddleware( | ||
{ | ||
isSerializable: () => true | ||
} | ||
) | ||
@@ -333,2 +337,31 @@ const store = configureStore({ | ||
}) | ||
it('should not check serializability for ignored action types', () => { | ||
let numTimesCalled = 0 | ||
const serializableStateMiddleware = createSerializableStateInvariantMiddleware( | ||
{ | ||
isSerializable: () => { | ||
numTimesCalled++ | ||
return true | ||
}, | ||
ignoredActions: ['IGNORE_ME'] | ||
} | ||
) | ||
const store = configureStore({ | ||
reducer: () => ({}), | ||
middleware: [serializableStateMiddleware] | ||
}) | ||
expect(numTimesCalled).toBe(0) | ||
store.dispatch({ type: 'IGNORE_ME' }) | ||
expect(numTimesCalled).toBe(0) | ||
store.dispatch({ type: 'ANY_OTHER_ACTION' }) | ||
expect(numTimesCalled).toBeGreaterThan(0) | ||
}) | ||
}) |
@@ -59,3 +59,3 @@ import isPlainObject from './isPlainObject' | ||
const entries = getEntries != null ? getEntries(value) : Object.entries(value); | ||
const entries = getEntries != null ? getEntries(value) : Object.entries(value) | ||
@@ -98,3 +98,3 @@ for (const [property, nestedValue] of entries) { | ||
*/ | ||
isSerializable?: (value: any) => boolean, | ||
isSerializable?: (value: any) => boolean | ||
/** | ||
@@ -105,3 +105,8 @@ * The function that will be used to retrieve entries from each | ||
*/ | ||
getEntries?: (value: any) => [string, any][], | ||
getEntries?: (value: any) => [string, any][] | ||
/** | ||
* An array of action types to ignore when checking for serializability, Defaults to [] | ||
*/ | ||
ignoredActions?: string[] | ||
} | ||
@@ -119,5 +124,9 @@ | ||
): Middleware { | ||
const { isSerializable = isPlain, getEntries } = options | ||
const { isSerializable = isPlain, getEntries, ignoredActions = [] } = options | ||
return storeAPI => next => action => { | ||
if (ignoredActions.length && ignoredActions.indexOf(action.type) !== -1) { | ||
return next(action) | ||
} | ||
const foundActionNonSerializableValue = findNonSerializableValue( | ||
@@ -127,3 +136,3 @@ action, | ||
isSerializable, | ||
getEntries, | ||
getEntries | ||
) | ||
@@ -145,4 +154,4 @@ | ||
isSerializable, | ||
getEntries, | ||
) | ||
getEntries | ||
) | ||
@@ -149,0 +158,0 @@ if (foundStateNonSerializableValue) { |
@@ -13,4 +13,4 @@ export { | ||
export { default as createNextState } from 'immer' | ||
export { default as createSelector } from 'selectorator' | ||
export { createSelector } from 'reselect' | ||
export * from '.' |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
217393
5026
+ Addedreselect@^4.0.0
- Removedselectorator@^4.0.3
- Removedcurriable@1.3.0(transitive)
- Removedfast-equals@1.6.3(transitive)
- Removedidentitate@1.0.1(transitive)
- Removedpathington@1.1.7(transitive)
- Removedselectorator@4.0.3(transitive)
- Removedunchanged@2.2.1(transitive)