state-decorator 6.2.1 → 6.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"middlewares.js","sources":["../node_modules/@babel/runtime/helpers/defineProperty.js","../node_modules/@babel/runtime/helpers/typeof.js","../node_modules/fast-deep-equal/index.js","../node_modules/@babel/runtime/helpers/arrayLikeToArray.js","../node_modules/@babel/runtime/helpers/arrayWithoutHoles.js","../node_modules/@babel/runtime/helpers/iterableToArray.js","../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js","../node_modules/@babel/runtime/helpers/nonIterableSpread.js","../node_modules/@babel/runtime/helpers/toConsumableArray.js","../src/types.ts","../node_modules/@babel/runtime/helpers/arrayWithHoles.js","../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js","../node_modules/@babel/runtime/helpers/nonIterableRest.js","../node_modules/@babel/runtime/helpers/slicedToArray.js","../node_modules/@babel/runtime/helpers/asyncToGenerator.js","../node_modules/regenerator-runtime/runtime.js","../src/impl.ts","../src/shallow.ts","../src/middlewares.ts"],"sourcesContent":["function _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n}\n\nmodule.exports = _defineProperty;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","function _typeof(obj) {\n \"@babel/helpers - typeof\";\n\n if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n module.exports = _typeof = function _typeof(obj) {\n return typeof obj;\n };\n\n module.exports[\"default\"] = module.exports, module.exports.__esModule = true;\n } else {\n module.exports = _typeof = function _typeof(obj) {\n return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n };\n\n module.exports[\"default\"] = module.exports, module.exports.__esModule = true;\n }\n\n return _typeof(obj);\n}\n\nmodule.exports = _typeof;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","'use strict';\n\nvar isArray = Array.isArray;\nvar keyList = Object.keys;\nvar hasProp = Object.prototype.hasOwnProperty;\n\nmodule.exports = function equal(a, b) {\n if (a === b) return true;\n\n if (a && b && typeof a == 'object' && typeof b == 'object') {\n var arrA = isArray(a)\n , arrB = isArray(b)\n , i\n , length\n , key;\n\n if (arrA && arrB) {\n length = a.length;\n if (length != b.length) return false;\n for (i = length; i-- !== 0;)\n if (!equal(a[i], b[i])) return false;\n return true;\n }\n\n if (arrA != arrB) return false;\n\n var dateA = a instanceof Date\n , dateB = b instanceof Date;\n if (dateA != dateB) return false;\n if (dateA && dateB) return a.getTime() == b.getTime();\n\n var regexpA = a instanceof RegExp\n , regexpB = b instanceof RegExp;\n if (regexpA != regexpB) return false;\n if (regexpA && regexpB) return a.toString() == b.toString();\n\n var keys = keyList(a);\n length = keys.length;\n\n if (length !== keyList(b).length)\n return false;\n\n for (i = length; i-- !== 0;)\n if (!hasProp.call(b, keys[i])) return false;\n\n for (i = length; i-- !== 0;) {\n key = keys[i];\n if (!equal(a[key], b[key])) return false;\n }\n\n return true;\n }\n\n return a!==a && b!==b;\n};\n","function _arrayLikeToArray(arr, len) {\n if (len == null || len > arr.length) len = arr.length;\n\n for (var i = 0, arr2 = new Array(len); i < len; i++) {\n arr2[i] = arr[i];\n }\n\n return arr2;\n}\n\nmodule.exports = _arrayLikeToArray;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","var arrayLikeToArray = require(\"./arrayLikeToArray.js\");\n\nfunction _arrayWithoutHoles(arr) {\n if (Array.isArray(arr)) return arrayLikeToArray(arr);\n}\n\nmodule.exports = _arrayWithoutHoles;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","function _iterableToArray(iter) {\n if (typeof Symbol !== \"undefined\" && Symbol.iterator in Object(iter)) return Array.from(iter);\n}\n\nmodule.exports = _iterableToArray;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","var arrayLikeToArray = require(\"./arrayLikeToArray.js\");\n\nfunction _unsupportedIterableToArray(o, minLen) {\n if (!o) return;\n if (typeof o === \"string\") return arrayLikeToArray(o, minLen);\n var n = Object.prototype.toString.call(o).slice(8, -1);\n if (n === \"Object\" && o.constructor) n = o.constructor.name;\n if (n === \"Map\" || n === \"Set\") return Array.from(o);\n if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen);\n}\n\nmodule.exports = _unsupportedIterableToArray;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","function _nonIterableSpread() {\n throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\n\nmodule.exports = _nonIterableSpread;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","var arrayWithoutHoles = require(\"./arrayWithoutHoles.js\");\n\nvar iterableToArray = require(\"./iterableToArray.js\");\n\nvar unsupportedIterableToArray = require(\"./unsupportedIterableToArray.js\");\n\nvar nonIterableSpread = require(\"./nonIterableSpread.js\");\n\nfunction _toConsumableArray(arr) {\n return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread();\n}\n\nmodule.exports = _toConsumableArray;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","/*\n * Copyright 2019 Globalsport SAS\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\nexport type PromiseResult<Type> = Type extends Promise<infer X> ? X : null;\n\nexport type NotifyFunc = (msg: string) => void;\n\nexport type PromiseIdMap = { [promiseId: string]: boolean };\n\nexport type LoadingMap<A> = { [pId in keyof A]?: boolean };\nexport type LoadingParallelMap<A> = { [P in keyof A]?: PromiseIdMap };\nexport type InternalLoadingMap<A> = LoadingParallelMap<A>;\n\nexport type LoadingProps<A> = {\n loading: boolean;\n loadingMap: LoadingMap<A>;\n loadingParallelMap: LoadingParallelMap<A>;\n};\n\n// https://github.com/Microsoft/TypeScript/issues/15300\nexport interface DecoratedActions {\n [name: string]: (...args: any[]) => Promise<any> | void;\n}\n\n/**\n * The State decorator can manage only one asynchronous action of same name at a time.\n * This enum is enumertaing all the policies in such case.\n */\nexport enum ConflictPolicy {\n /**\n * Reject the promise.\n */\n REJECT = 'reject',\n\n /**\n * Return a resolved promise with no result.\n */\n IGNORE = 'ignore',\n\n /**\n * Execute only the last call that conflicts after the one ongoing.\n */\n KEEP_LAST = 'keepLast',\n\n /**\n * Execute all calls one after another.\n */\n KEEP_ALL = 'keepAll',\n\n /**\n * Execute all calls one after another.\n * @see getPromiseId\n */\n PARALLEL = 'parallel',\n\n /**\n * Reuse the ongoing promise if any and if possible (same arguments). Only for GET requests!\n */\n REUSE = 'reuse',\n}\n\nexport type PromiseProvider<S, DS, F extends (...args: any[]) => any, A, P> = (\n ctx: GetPromiseInvocationContext<S, DS, F, P, A>\n) => ReturnType<F> | null;\n\n/**\n * Simple form of a synchronous action.\n */\nexport type SimpleSyncAction<S, F extends (...args: any[]) => any, P, DS, FxRes = S> = (\n ctx: InvocationContext<S, DS, F, P>\n) => FxRes | null;\n\nexport type SyncAction<S, F extends (...args: any[]) => any, A, P, DS, FxRes = S> = {\n /**\n * The action to execute.\n */\n effects: (ctx: EffectsInvocationContext<S, DS, F, P>) => FxRes | null;\n\n /**\n * Debounces the action if this parameter is defined.\n */\n debounceTimeout?: number;\n\n /**\n * Debounces the action side effects if this parameter is defined.\n */\n debounceSideEffectsTimeout?: number;\n\n /**\n * Action to call when the action is done. Used to trigger other actions (even asynchronous),\n */\n sideEffects?: (ctx: SideEffectsInvocationContext<S, DS, F, P, A>) => void;\n};\n\n/**\n * Try to abort an action, if the action is <code>abortable</code>.\n * @param actionName The action name\n * @param promiseId If the action conflict type is <code>ConflictType.PARALLEL</code>, the identifier of the promise.\n * @returns <code>true</code> if the action is abortable and an action is ongoing, <code>false</code> otherwise.\n */\nexport type AbortActionCallback<A> = (actionName: keyof A, promiseId?: string) => boolean;\n\nexport type GetErrorMessage<S, DS, F extends (...args: any[]) => any, P> = (\n ctx: ErrorMessageInvocationContext<S, DS, F, P>\n) => string;\n\nexport type ContextState<S> = {\n state: S;\n s: S;\n};\n\nexport type ContextDerivedStateState<DS> = {\n derived: DS;\n ds: DS;\n};\n\nexport type ContextBase<S, P> = ContextState<S> & {\n props: P;\n p: P;\n};\n\nexport type ContextWithDerived<S, DS, P> = ContextBase<S, P> & ContextDerivedStateState<DS>;\n\nexport type InvocationContextActions<A> = {\n actions: A;\n a: A;\n};\n\nexport type WarningNotifyFunc = {\n notifyWarning?: NotifyFunc;\n};\n\nexport type InvocationContext<S, DS, F extends (...args: any[]) => any, P> = ContextWithDerived<S, DS, P> & {\n args: Parameters<F>;\n promiseId: string;\n};\n\nexport type EffectsInvocationContext<S, DS, F extends (...args: any[]) => any, P> = InvocationContext<S, DS, F, P> & {\n result: PromiseResult<ReturnType<F>>;\n res: PromiseResult<ReturnType<F>>;\n};\n\nexport type GetPromiseInvocationContext<S, DS, F extends (...args: any[]) => any, P, A> = InvocationContextActions<A> &\n InvocationContext<S, DS, F, P> & {\n abortSignal: AbortSignal;\n };\n\nexport type ErrorEffectsInvocationContext<S, DS, F extends (...args: any[]) => any, P> = InvocationContext<\n S,\n DS,\n F,\n P\n> & {\n error: Error;\n err: Error;\n};\n\nexport type SuccessMessageInvocationContext<S, DS, F extends (...args: any[]) => any, P> = EffectsInvocationContext<\n S,\n DS,\n F,\n P\n>;\nexport type ErrorMessageInvocationContext<S, DS, F extends (...args: any[]) => any, P> = ErrorEffectsInvocationContext<\n S,\n DS,\n F,\n P\n>;\n\nexport type SideEffectsInvocationContext<S, DS, F extends (...args: any[]) => any, P, A> = EffectsInvocationContext<\n S,\n DS,\n F,\n P\n> &\n InvocationContextActions<A> &\n WarningNotifyFunc;\n\nexport type ErrorSideEffectsInvocationContext<\n S,\n DS,\n F extends (...args: any[]) => any,\n P,\n A\n> = ErrorEffectsInvocationContext<S, DS, F, P> & InvocationContextActions<A> & WarningNotifyFunc;\n\nexport type OnMountInvocationContext<S, A, P> = ContextBase<S, P> & InvocationContextActions<A>;\n\nexport type EffectsType = 'preEffects' | 'effects' | 'errorEffects' | 'optimisticEffects' | null;\n\nexport type MiddlewareActionContext<S, A, P> = {\n name: keyof A;\n type: EffectsType;\n isAsync: boolean;\n context: InvocationContext<S, any, any, P>;\n};\n\nexport type MiddlewareStoreContext<S, A extends DecoratedActions, P> = {\n actions: StoreActions<S, A, P, any, any>;\n state: S;\n setState: (s: S) => void;\n options: StoreOptions<S, A, P, any>;\n};\n\nexport type MiddlewareFactory<S, A extends DecoratedActions, P> = () => Middleware<S, A, P>;\n\n/**\n * A state change middleware.\n * Allow to listen and change a state change on the fly.\n */\nexport type Middleware<S, A extends DecoratedActions, P> = {\n /**\n * Initializes the middleware. Called when the store is initializing.\n */\n init: (storeContext: MiddlewareStoreContext<S, A, P>) => void;\n\n /**\n * Invoked on a state change has occurred and returns a new state or <code>null</code> if unchanged.\n */\n effects: (\n actionContext: MiddlewareActionContext<S, A, P>,\n oldState: S,\n newState: S,\n loading: boolean\n ) => null | {\n state: S;\n loading: boolean;\n };\n\n /**\n * Destroys the middleware. Called when the store is being destroyed.\n */\n destroy: () => void;\n};\n\nexport type AsyncActionBase<S, F extends (...args: any[]) => any, A, P, DS, FxRes = S> = {\n /**\n * This action can be aborted. An abortSignal will be injected to the <code>promise</code> / <code>promiseGet</code>.\n */\n abortable?: boolean;\n\n /**\n * A function that provides the success message to pass to the notifySuccess function passed as property to the StateDecorator.\n */\n getSuccessMessage?: (ctx: SuccessMessageInvocationContext<S, DS, F, P>) => string;\n\n /**\n * A function that provides the error message to pass to the notifyError function passed as property to the StateDecorator.\n */\n getErrorMessage?: GetErrorMessage<S, DS, F, P>;\n\n /**\n * If set, called with the result of the promise to update the current state.\n */\n effects?: (ctx: EffectsInvocationContext<S, DS, F, P>) => FxRes | null;\n\n /**\n * If set, called with the error of the promise to update the current state.\n */\n errorEffects?: (ctx: ErrorEffectsInvocationContext<S, DS, F, P>) => FxRes | null;\n\n /**\n * Whether reject the promise instead of handling it.\n */\n rejectPromiseOnError?: boolean;\n\n /**\n * Handle side effects when the request succeeded.\n * @param result The result of the request\n * @param newData The data after the reducer is applied\n * @param args The argument during the call of the request function\n * @param props The props passed to the state decorator\n * @param actions The actions available\n * @param notifyWarning If specified, a notify function to indicate that the action is a semi success (use successMessage / getSuccessMessage otherwise).\n */\n sideEffects?: (ctx: SideEffectsInvocationContext<S, DS, F, P, A>) => void;\n\n /**\n * Handle side effects when the request failed.\n * @param error The error of the request\n * @param args The argument during the call of the request function\n * @param props The props passed to the state decorator\n * @param actions The actions available\n * @param notifyWarning If specified, a notify function to indicate that the action is a semi failure (use errorMessage / getErrorMessage otherwise).\n */\n errorSideEffects?: (ctx: ErrorSideEffectsInvocationContext<S, DS, F, P, A>) => void;\n\n /**\n * Retrieve the state to set as current data before the promise is resolved.\n * If the there's no reducer, this data will be used after the promise is done.\n */\n preEffects?: (ctx: InvocationContext<S, DS, F, P>) => FxRes | null;\n\n /**\n * Retrieve the state to set as current data before the promise is resolved.\n * If the there's no reducer, this data will be used after the promise is done.\n */\n optimisticEffects?: (ctx: InvocationContext<S, DS, F, P>) => FxRes | null;\n\n /**\n * Policy to apply when a call to an asynchronous action is done but a previous call is still not resolved.\n */\n conflictPolicy?: ConflictPolicy;\n\n /**\n * Get an identifier for an action call. Used only when conflictPolicy is ConflictPolicy.PARALLEL.\n * This information will be available in loadingMap. loadingMap[actionName] will be an array of promise identifiers.\n */\n getPromiseId?: (...args: Parameters<F>) => string;\n\n /**\n * Number of retries in case of error (failed to fetch).\n * Do not use this if you are creating objects...\n * Default value is 0 (no retry).\n */\n retryCount?: number;\n\n /**\n * Seed of delay between each retry in milliseconds.\n * The applied delay is retryDelaySeed * retry count.\n * Default value is 1000 (1 second).\n */\n retryDelaySeed?: number;\n\n /**\n * Function to test if the error will trigger an action retry or will fail directly.\n */\n isTriggerRetryError?: (e: Error) => boolean;\n};\n\nexport type AsyncActionPromise<S, F extends (...args: any[]) => any, A, P, DS = {}, FxRes = S> = AsyncActionBase<\n S,\n F,\n A,\n P,\n DS,\n FxRes\n> & {\n /**\n * The request, returns a promise\n */\n getPromise: PromiseProvider<S, DS, F, A, P>;\n};\n\nexport type AsyncActionPromiseGet<S, F extends (...args: any[]) => any, A, P, DS, FxRes = S> = AsyncActionBase<\n S,\n F,\n A,\n P,\n DS,\n FxRes\n> & {\n /**\n * The request, returns a promise that is a GET request.\n * A shortcut to set:\n * - retryCount: 3\n * - conflictPolicy: ConflictPolicy.REUSE\n */\n getGetPromise: PromiseProvider<S, DS, F, A, P>;\n};\n\nexport type AsyncAction<S, F extends (...args: any[]) => any, A, P, DS = {}, FxRes = S> =\n | AsyncActionPromise<S, F, A, P, DS, FxRes>\n | AsyncActionPromiseGet<S, F, A, P, DS, FxRes>;\n\nexport type StoreAction<S, F extends (...args: any[]) => any, A, P, DS = {}, FxRes = S> =\n | AsyncAction<S, F, A, P, DS, FxRes>\n | SimpleSyncAction<S, F, P, DS, FxRes>\n | SyncAction<S, F, A, P, DS, FxRes>;\n\n/**\n * S: The type of the state\n * A: The type of the actions to pass to the children (used to check keys only).\n */\nexport type StoreActions<S, A extends DecoratedActions, P = {}, DS = {}, FxRes = S> = {\n [Prop in keyof A]: StoreAction<S, A[Prop], A, P, DS, FxRes>;\n};\n\nexport type OnPropsChangeEffectsContext<S, DS, P> = ContextWithDerived<S, DS, P> & {\n indices: number[];\n index: number;\n isInit: boolean;\n};\n\nexport type OnPropsChangeSideEffectsContext<S, P, A, DS = {}> = OnPropsChangeEffectsContext<S, DS, P> & {\n actions: A;\n a: A;\n};\n\ntype DerivedStateOption<S, P, DS> = {\n [k in keyof DS]: {\n getDeps: (ctx: ContextBase<S, P>) => any[];\n get: (ctx: ContextBase<S, P>) => DS[k];\n };\n};\n\nexport type OnPropsChangeOptions<S, DS, A, P> = {\n onMount?: boolean;\n getDeps: (p: P) => any[];\n effects?: (ctx: OnPropsChangeEffectsContext<S, DS, P>) => S;\n sideEffects?: (ctx: OnPropsChangeSideEffectsContext<S, P, A>) => void;\n};\n\nexport type StoreOptions<S, A, P = {}, DS = {}> = {\n /**\n * The state decorator name. Use in debug traces to identify the useStateDecorator instance.\n */\n name?: string;\n\n /**\n * List of action names that are marked as loading at initial time.\n * If you must start your initial actions in a useSideEffect, a render is done before\n * first actions can be trigerred, some actions can be marked as loading at initial time.\n */\n initialActionsMarkedLoading?: (keyof A)[];\n\n /**\n * One or several configurations of inbound properties change managements.\n */\n onPropsChange?: OnPropsChangeOptions<S, DS, A, P> | OnPropsChangeOptions<S, DS, A, P>[];\n\n /**\n * The callback function called if an asynchronous function succeeded and a success messsage is defined.\n */\n notifySuccess?: NotifyFunc;\n\n /**\n * The callback function called if an asynchronous function fails and an error messsage is defined.\n */\n notifyError?: NotifyFunc;\n\n /**\n * The callback function injected in onDone and onFail of asynchronous functions to notify a semi success / failed request.\n */\n notifyWarning?: NotifyFunc;\n\n /**\n * Initial actions.\n */\n onMount?: (ctx: OnMountInvocationContext<S, A, P>) => void;\n\n /**\n * Callback on store destruction.\n */\n onUnmount?: (ctx: OnMountInvocationContext<S, A, P>) => Promise<any> | void;\n\n /**\n * Compute derived state\n */\n derivedState?: DerivedStateOption<S, P, DS>;\n};\n","function _arrayWithHoles(arr) {\n if (Array.isArray(arr)) return arr;\n}\n\nmodule.exports = _arrayWithHoles;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","function _iterableToArrayLimit(arr, i) {\n if (typeof Symbol === \"undefined\" || !(Symbol.iterator in Object(arr))) return;\n var _arr = [];\n var _n = true;\n var _d = false;\n var _e = undefined;\n\n try {\n for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {\n _arr.push(_s.value);\n\n if (i && _arr.length === i) break;\n }\n } catch (err) {\n _d = true;\n _e = err;\n } finally {\n try {\n if (!_n && _i[\"return\"] != null) _i[\"return\"]();\n } finally {\n if (_d) throw _e;\n }\n }\n\n return _arr;\n}\n\nmodule.exports = _iterableToArrayLimit;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","function _nonIterableRest() {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\n\nmodule.exports = _nonIterableRest;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","var arrayWithHoles = require(\"./arrayWithHoles.js\");\n\nvar iterableToArrayLimit = require(\"./iterableToArrayLimit.js\");\n\nvar unsupportedIterableToArray = require(\"./unsupportedIterableToArray.js\");\n\nvar nonIterableRest = require(\"./nonIterableRest.js\");\n\nfunction _slicedToArray(arr, i) {\n return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest();\n}\n\nmodule.exports = _slicedToArray;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {\n try {\n var info = gen[key](arg);\n var value = info.value;\n } catch (error) {\n reject(error);\n return;\n }\n\n if (info.done) {\n resolve(value);\n } else {\n Promise.resolve(value).then(_next, _throw);\n }\n}\n\nfunction _asyncToGenerator(fn) {\n return function () {\n var self = this,\n args = arguments;\n return new Promise(function (resolve, reject) {\n var gen = fn.apply(self, args);\n\n function _next(value) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value);\n }\n\n function _throw(err) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err);\n }\n\n _next(undefined);\n });\n };\n}\n\nmodule.exports = _asyncToGenerator;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","/**\n * Copyright (c) 2014-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nvar runtime = (function (exports) {\n \"use strict\";\n\n var Op = Object.prototype;\n var hasOwn = Op.hasOwnProperty;\n var undefined; // More compressible than void 0.\n var $Symbol = typeof Symbol === \"function\" ? Symbol : {};\n var iteratorSymbol = $Symbol.iterator || \"@@iterator\";\n var asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\";\n var toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\";\n\n function define(obj, key, value) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n return obj[key];\n }\n try {\n // IE 8 has a broken Object.defineProperty that only works on DOM objects.\n define({}, \"\");\n } catch (err) {\n define = function(obj, key, value) {\n return obj[key] = value;\n };\n }\n\n function wrap(innerFn, outerFn, self, tryLocsList) {\n // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.\n var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;\n var generator = Object.create(protoGenerator.prototype);\n var context = new Context(tryLocsList || []);\n\n // The ._invoke method unifies the implementations of the .next,\n // .throw, and .return methods.\n generator._invoke = makeInvokeMethod(innerFn, self, context);\n\n return generator;\n }\n exports.wrap = wrap;\n\n // Try/catch helper to minimize deoptimizations. Returns a completion\n // record like context.tryEntries[i].completion. This interface could\n // have been (and was previously) designed to take a closure to be\n // invoked without arguments, but in all the cases we care about we\n // already have an existing method we want to call, so there's no need\n // to create a new function object. We can even get away with assuming\n // the method takes exactly one argument, since that happens to be true\n // in every case, so we don't have to touch the arguments object. The\n // only additional allocation required is the completion record, which\n // has a stable shape and so hopefully should be cheap to allocate.\n function tryCatch(fn, obj, arg) {\n try {\n return { type: \"normal\", arg: fn.call(obj, arg) };\n } catch (err) {\n return { type: \"throw\", arg: err };\n }\n }\n\n var GenStateSuspendedStart = \"suspendedStart\";\n var GenStateSuspendedYield = \"suspendedYield\";\n var GenStateExecuting = \"executing\";\n var GenStateCompleted = \"completed\";\n\n // Returning this object from the innerFn has the same effect as\n // breaking out of the dispatch switch statement.\n var ContinueSentinel = {};\n\n // Dummy constructor functions that we use as the .constructor and\n // .constructor.prototype properties for functions that return Generator\n // objects. For full spec compliance, you may wish to configure your\n // minifier not to mangle the names of these two functions.\n function Generator() {}\n function GeneratorFunction() {}\n function GeneratorFunctionPrototype() {}\n\n // This is a polyfill for %IteratorPrototype% for environments that\n // don't natively support it.\n var IteratorPrototype = {};\n IteratorPrototype[iteratorSymbol] = function () {\n return this;\n };\n\n var getProto = Object.getPrototypeOf;\n var NativeIteratorPrototype = getProto && getProto(getProto(values([])));\n if (NativeIteratorPrototype &&\n NativeIteratorPrototype !== Op &&\n hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {\n // This environment has a native %IteratorPrototype%; use it instead\n // of the polyfill.\n IteratorPrototype = NativeIteratorPrototype;\n }\n\n var Gp = GeneratorFunctionPrototype.prototype =\n Generator.prototype = Object.create(IteratorPrototype);\n GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;\n GeneratorFunctionPrototype.constructor = GeneratorFunction;\n GeneratorFunction.displayName = define(\n GeneratorFunctionPrototype,\n toStringTagSymbol,\n \"GeneratorFunction\"\n );\n\n // Helper for defining the .next, .throw, and .return methods of the\n // Iterator interface in terms of a single ._invoke method.\n function defineIteratorMethods(prototype) {\n [\"next\", \"throw\", \"return\"].forEach(function(method) {\n define(prototype, method, function(arg) {\n return this._invoke(method, arg);\n });\n });\n }\n\n exports.isGeneratorFunction = function(genFun) {\n var ctor = typeof genFun === \"function\" && genFun.constructor;\n return ctor\n ? ctor === GeneratorFunction ||\n // For the native GeneratorFunction constructor, the best we can\n // do is to check its .name property.\n (ctor.displayName || ctor.name) === \"GeneratorFunction\"\n : false;\n };\n\n exports.mark = function(genFun) {\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);\n } else {\n genFun.__proto__ = GeneratorFunctionPrototype;\n define(genFun, toStringTagSymbol, \"GeneratorFunction\");\n }\n genFun.prototype = Object.create(Gp);\n return genFun;\n };\n\n // Within the body of any async function, `await x` is transformed to\n // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test\n // `hasOwn.call(value, \"__await\")` to determine if the yielded value is\n // meant to be awaited.\n exports.awrap = function(arg) {\n return { __await: arg };\n };\n\n function AsyncIterator(generator, PromiseImpl) {\n function invoke(method, arg, resolve, reject) {\n var record = tryCatch(generator[method], generator, arg);\n if (record.type === \"throw\") {\n reject(record.arg);\n } else {\n var result = record.arg;\n var value = result.value;\n if (value &&\n typeof value === \"object\" &&\n hasOwn.call(value, \"__await\")) {\n return PromiseImpl.resolve(value.__await).then(function(value) {\n invoke(\"next\", value, resolve, reject);\n }, function(err) {\n invoke(\"throw\", err, resolve, reject);\n });\n }\n\n return PromiseImpl.resolve(value).then(function(unwrapped) {\n // When a yielded Promise is resolved, its final value becomes\n // the .value of the Promise<{value,done}> result for the\n // current iteration.\n result.value = unwrapped;\n resolve(result);\n }, function(error) {\n // If a rejected Promise was yielded, throw the rejection back\n // into the async generator function so it can be handled there.\n return invoke(\"throw\", error, resolve, reject);\n });\n }\n }\n\n var previousPromise;\n\n function enqueue(method, arg) {\n function callInvokeWithMethodAndArg() {\n return new PromiseImpl(function(resolve, reject) {\n invoke(method, arg, resolve, reject);\n });\n }\n\n return previousPromise =\n // If enqueue has been called before, then we want to wait until\n // all previous Promises have been resolved before calling invoke,\n // so that results are always delivered in the correct order. If\n // enqueue has not been called before, then it is important to\n // call invoke immediately, without waiting on a callback to fire,\n // so that the async generator function has the opportunity to do\n // any necessary setup in a predictable way. This predictability\n // is why the Promise constructor synchronously invokes its\n // executor callback, and why async functions synchronously\n // execute code before the first await. Since we implement simple\n // async functions in terms of async generators, it is especially\n // important to get this right, even though it requires care.\n previousPromise ? previousPromise.then(\n callInvokeWithMethodAndArg,\n // Avoid propagating failures to Promises returned by later\n // invocations of the iterator.\n callInvokeWithMethodAndArg\n ) : callInvokeWithMethodAndArg();\n }\n\n // Define the unified helper method that is used to implement .next,\n // .throw, and .return (see defineIteratorMethods).\n this._invoke = enqueue;\n }\n\n defineIteratorMethods(AsyncIterator.prototype);\n AsyncIterator.prototype[asyncIteratorSymbol] = function () {\n return this;\n };\n exports.AsyncIterator = AsyncIterator;\n\n // Note that simple async functions are implemented on top of\n // AsyncIterator objects; they just return a Promise for the value of\n // the final result produced by the iterator.\n exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {\n if (PromiseImpl === void 0) PromiseImpl = Promise;\n\n var iter = new AsyncIterator(\n wrap(innerFn, outerFn, self, tryLocsList),\n PromiseImpl\n );\n\n return exports.isGeneratorFunction(outerFn)\n ? iter // If outerFn is a generator, return the full iterator.\n : iter.next().then(function(result) {\n return result.done ? result.value : iter.next();\n });\n };\n\n function makeInvokeMethod(innerFn, self, context) {\n var state = GenStateSuspendedStart;\n\n return function invoke(method, arg) {\n if (state === GenStateExecuting) {\n throw new Error(\"Generator is already running\");\n }\n\n if (state === GenStateCompleted) {\n if (method === \"throw\") {\n throw arg;\n }\n\n // Be forgiving, per 25.3.3.3.3 of the spec:\n // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume\n return doneResult();\n }\n\n context.method = method;\n context.arg = arg;\n\n while (true) {\n var delegate = context.delegate;\n if (delegate) {\n var delegateResult = maybeInvokeDelegate(delegate, context);\n if (delegateResult) {\n if (delegateResult === ContinueSentinel) continue;\n return delegateResult;\n }\n }\n\n if (context.method === \"next\") {\n // Setting context._sent for legacy support of Babel's\n // function.sent implementation.\n context.sent = context._sent = context.arg;\n\n } else if (context.method === \"throw\") {\n if (state === GenStateSuspendedStart) {\n state = GenStateCompleted;\n throw context.arg;\n }\n\n context.dispatchException(context.arg);\n\n } else if (context.method === \"return\") {\n context.abrupt(\"return\", context.arg);\n }\n\n state = GenStateExecuting;\n\n var record = tryCatch(innerFn, self, context);\n if (record.type === \"normal\") {\n // If an exception is thrown from innerFn, we leave state ===\n // GenStateExecuting and loop back for another invocation.\n state = context.done\n ? GenStateCompleted\n : GenStateSuspendedYield;\n\n if (record.arg === ContinueSentinel) {\n continue;\n }\n\n return {\n value: record.arg,\n done: context.done\n };\n\n } else if (record.type === \"throw\") {\n state = GenStateCompleted;\n // Dispatch the exception by looping back around to the\n // context.dispatchException(context.arg) call above.\n context.method = \"throw\";\n context.arg = record.arg;\n }\n }\n };\n }\n\n // Call delegate.iterator[context.method](context.arg) and handle the\n // result, either by returning a { value, done } result from the\n // delegate iterator, or by modifying context.method and context.arg,\n // setting context.delegate to null, and returning the ContinueSentinel.\n function maybeInvokeDelegate(delegate, context) {\n var method = delegate.iterator[context.method];\n if (method === undefined) {\n // A .throw or .return when the delegate iterator has no .throw\n // method always terminates the yield* loop.\n context.delegate = null;\n\n if (context.method === \"throw\") {\n // Note: [\"return\"] must be used for ES3 parsing compatibility.\n if (delegate.iterator[\"return\"]) {\n // If the delegate iterator has a return method, give it a\n // chance to clean up.\n context.method = \"return\";\n context.arg = undefined;\n maybeInvokeDelegate(delegate, context);\n\n if (context.method === \"throw\") {\n // If maybeInvokeDelegate(context) changed context.method from\n // \"return\" to \"throw\", let that override the TypeError below.\n return ContinueSentinel;\n }\n }\n\n context.method = \"throw\";\n context.arg = new TypeError(\n \"The iterator does not provide a 'throw' method\");\n }\n\n return ContinueSentinel;\n }\n\n var record = tryCatch(method, delegate.iterator, context.arg);\n\n if (record.type === \"throw\") {\n context.method = \"throw\";\n context.arg = record.arg;\n context.delegate = null;\n return ContinueSentinel;\n }\n\n var info = record.arg;\n\n if (! info) {\n context.method = \"throw\";\n context.arg = new TypeError(\"iterator result is not an object\");\n context.delegate = null;\n return ContinueSentinel;\n }\n\n if (info.done) {\n // Assign the result of the finished delegate to the temporary\n // variable specified by delegate.resultName (see delegateYield).\n context[delegate.resultName] = info.value;\n\n // Resume execution at the desired location (see delegateYield).\n context.next = delegate.nextLoc;\n\n // If context.method was \"throw\" but the delegate handled the\n // exception, let the outer generator proceed normally. If\n // context.method was \"next\", forget context.arg since it has been\n // \"consumed\" by the delegate iterator. If context.method was\n // \"return\", allow the original .return call to continue in the\n // outer generator.\n if (context.method !== \"return\") {\n context.method = \"next\";\n context.arg = undefined;\n }\n\n } else {\n // Re-yield the result returned by the delegate method.\n return info;\n }\n\n // The delegate iterator is finished, so forget it and continue with\n // the outer generator.\n context.delegate = null;\n return ContinueSentinel;\n }\n\n // Define Generator.prototype.{next,throw,return} in terms of the\n // unified ._invoke helper method.\n defineIteratorMethods(Gp);\n\n define(Gp, toStringTagSymbol, \"Generator\");\n\n // A Generator should always return itself as the iterator object when the\n // @@iterator function is called on it. Some browsers' implementations of the\n // iterator prototype chain incorrectly implement this, causing the Generator\n // object to not be returned from this call. This ensures that doesn't happen.\n // See https://github.com/facebook/regenerator/issues/274 for more details.\n Gp[iteratorSymbol] = function() {\n return this;\n };\n\n Gp.toString = function() {\n return \"[object Generator]\";\n };\n\n function pushTryEntry(locs) {\n var entry = { tryLoc: locs[0] };\n\n if (1 in locs) {\n entry.catchLoc = locs[1];\n }\n\n if (2 in locs) {\n entry.finallyLoc = locs[2];\n entry.afterLoc = locs[3];\n }\n\n this.tryEntries.push(entry);\n }\n\n function resetTryEntry(entry) {\n var record = entry.completion || {};\n record.type = \"normal\";\n delete record.arg;\n entry.completion = record;\n }\n\n function Context(tryLocsList) {\n // The root entry object (effectively a try statement without a catch\n // or a finally block) gives us a place to store values thrown from\n // locations where there is no enclosing try statement.\n this.tryEntries = [{ tryLoc: \"root\" }];\n tryLocsList.forEach(pushTryEntry, this);\n this.reset(true);\n }\n\n exports.keys = function(object) {\n var keys = [];\n for (var key in object) {\n keys.push(key);\n }\n keys.reverse();\n\n // Rather than returning an object with a next method, we keep\n // things simple and return the next function itself.\n return function next() {\n while (keys.length) {\n var key = keys.pop();\n if (key in object) {\n next.value = key;\n next.done = false;\n return next;\n }\n }\n\n // To avoid creating an additional object, we just hang the .value\n // and .done properties off the next function object itself. This\n // also ensures that the minifier will not anonymize the function.\n next.done = true;\n return next;\n };\n };\n\n function values(iterable) {\n if (iterable) {\n var iteratorMethod = iterable[iteratorSymbol];\n if (iteratorMethod) {\n return iteratorMethod.call(iterable);\n }\n\n if (typeof iterable.next === \"function\") {\n return iterable;\n }\n\n if (!isNaN(iterable.length)) {\n var i = -1, next = function next() {\n while (++i < iterable.length) {\n if (hasOwn.call(iterable, i)) {\n next.value = iterable[i];\n next.done = false;\n return next;\n }\n }\n\n next.value = undefined;\n next.done = true;\n\n return next;\n };\n\n return next.next = next;\n }\n }\n\n // Return an iterator with no values.\n return { next: doneResult };\n }\n exports.values = values;\n\n function doneResult() {\n return { value: undefined, done: true };\n }\n\n Context.prototype = {\n constructor: Context,\n\n reset: function(skipTempReset) {\n this.prev = 0;\n this.next = 0;\n // Resetting context._sent for legacy support of Babel's\n // function.sent implementation.\n this.sent = this._sent = undefined;\n this.done = false;\n this.delegate = null;\n\n this.method = \"next\";\n this.arg = undefined;\n\n this.tryEntries.forEach(resetTryEntry);\n\n if (!skipTempReset) {\n for (var name in this) {\n // Not sure about the optimal order of these conditions:\n if (name.charAt(0) === \"t\" &&\n hasOwn.call(this, name) &&\n !isNaN(+name.slice(1))) {\n this[name] = undefined;\n }\n }\n }\n },\n\n stop: function() {\n this.done = true;\n\n var rootEntry = this.tryEntries[0];\n var rootRecord = rootEntry.completion;\n if (rootRecord.type === \"throw\") {\n throw rootRecord.arg;\n }\n\n return this.rval;\n },\n\n dispatchException: function(exception) {\n if (this.done) {\n throw exception;\n }\n\n var context = this;\n function handle(loc, caught) {\n record.type = \"throw\";\n record.arg = exception;\n context.next = loc;\n\n if (caught) {\n // If the dispatched exception was caught by a catch block,\n // then let that catch block handle the exception normally.\n context.method = \"next\";\n context.arg = undefined;\n }\n\n return !! caught;\n }\n\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n var record = entry.completion;\n\n if (entry.tryLoc === \"root\") {\n // Exception thrown outside of any try block that could handle\n // it, so set the completion value of the entire function to\n // throw the exception.\n return handle(\"end\");\n }\n\n if (entry.tryLoc <= this.prev) {\n var hasCatch = hasOwn.call(entry, \"catchLoc\");\n var hasFinally = hasOwn.call(entry, \"finallyLoc\");\n\n if (hasCatch && hasFinally) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n } else if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else if (hasCatch) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n }\n\n } else if (hasFinally) {\n if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else {\n throw new Error(\"try statement without catch or finally\");\n }\n }\n }\n },\n\n abrupt: function(type, arg) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc <= this.prev &&\n hasOwn.call(entry, \"finallyLoc\") &&\n this.prev < entry.finallyLoc) {\n var finallyEntry = entry;\n break;\n }\n }\n\n if (finallyEntry &&\n (type === \"break\" ||\n type === \"continue\") &&\n finallyEntry.tryLoc <= arg &&\n arg <= finallyEntry.finallyLoc) {\n // Ignore the finally entry if control is not jumping to a\n // location outside the try/catch block.\n finallyEntry = null;\n }\n\n var record = finallyEntry ? finallyEntry.completion : {};\n record.type = type;\n record.arg = arg;\n\n if (finallyEntry) {\n this.method = \"next\";\n this.next = finallyEntry.finallyLoc;\n return ContinueSentinel;\n }\n\n return this.complete(record);\n },\n\n complete: function(record, afterLoc) {\n if (record.type === \"throw\") {\n throw record.arg;\n }\n\n if (record.type === \"break\" ||\n record.type === \"continue\") {\n this.next = record.arg;\n } else if (record.type === \"return\") {\n this.rval = this.arg = record.arg;\n this.method = \"return\";\n this.next = \"end\";\n } else if (record.type === \"normal\" && afterLoc) {\n this.next = afterLoc;\n }\n\n return ContinueSentinel;\n },\n\n finish: function(finallyLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.finallyLoc === finallyLoc) {\n this.complete(entry.completion, entry.afterLoc);\n resetTryEntry(entry);\n return ContinueSentinel;\n }\n }\n },\n\n \"catch\": function(tryLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc === tryLoc) {\n var record = entry.completion;\n if (record.type === \"throw\") {\n var thrown = record.arg;\n resetTryEntry(entry);\n }\n return thrown;\n }\n }\n\n // The context.catch method must only be called with a location\n // argument that corresponds to a known catch block.\n throw new Error(\"illegal catch attempt\");\n },\n\n delegateYield: function(iterable, resultName, nextLoc) {\n this.delegate = {\n iterator: values(iterable),\n resultName: resultName,\n nextLoc: nextLoc\n };\n\n if (this.method === \"next\") {\n // Deliberately forget the last sent value so that we don't\n // accidentally pass it on to the delegate.\n this.arg = undefined;\n }\n\n return ContinueSentinel;\n }\n };\n\n // Regardless of whether this script is executing as a CommonJS module\n // or not, return the runtime object so that we can declare the variable\n // regeneratorRuntime in the outer scope, which allows this module to be\n // injected easily by `bin/regenerator --include-runtime script.js`.\n return exports;\n\n}(\n // If this script is executing as a CommonJS module, use module.exports\n // as the regeneratorRuntime namespace. Otherwise create a new empty\n // object. Either way, the resulting object will be used to initialize\n // the regeneratorRuntime variable at the top of this file.\n typeof module === \"object\" ? module.exports : {}\n));\n\ntry {\n regeneratorRuntime = runtime;\n} catch (accidentalStrictMode) {\n // This module should not be running in strict mode, so the above\n // assignment should always work unless something is misconfigured. Just\n // in case runtime.js accidentally runs in strict mode, we can escape\n // strict mode using a global Function call. This could conceivably fail\n // if a Content Security Policy forbids using Function, but in that case\n // the proper solution is to fix the accidental strict mode problem. If\n // you've misconfigured your bundler to force strict mode and applied a\n // CSP to forbid Function, and you're not willing to fix either of those\n // problems, please detail your unique predicament in a GitHub issue.\n Function(\"r\", \"regeneratorRuntime = r\")(runtime);\n}\n","/*\n * Copyright 2019 Globalsport SAS\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport shallow from './shallow';\nimport {\n AsyncAction,\n SimpleSyncAction,\n SyncAction,\n StoreAction,\n AsyncActionPromise,\n ConflictPolicy,\n AsyncActionPromiseGet,\n PromiseProvider,\n GetPromiseInvocationContext,\n DecoratedActions,\n InternalLoadingMap,\n StoreOptions,\n PromiseResult,\n InvocationContext,\n EffectsInvocationContext,\n InvocationContextActions,\n WarningNotifyFunc,\n ErrorEffectsInvocationContext,\n OnMountInvocationContext,\n OnPropsChangeEffectsContext,\n ContextState,\n Middleware,\n MiddlewareFactory,\n OnPropsChangeOptions,\n ContextWithDerived,\n} from './types';\n\nexport type SetStateFunc<S, A, P> = (\n newState: S,\n newLoadingMap: InternalLoadingMap<A>,\n actionName: keyof A | 'onPropsChange',\n actionType: 'preEffects' | 'effects' | 'errorEffects' | null, // FIXME\n isAsync: boolean,\n actionCtx: any,\n propsChanged: boolean,\n isInit?: boolean\n) => void;\n\n/** @internal */\nexport type PromiseMap<A> = {\n [name in keyof A]?: {\n [promiseId: string]: {\n promise: Promise<any>;\n refArgs: any[];\n abortController: AbortController;\n };\n };\n};\n\n/** @internal */\nexport type FutureActions = {\n args: any[];\n resolve: (...args: any[]) => void;\n reject: (...args: any[]) => void;\n timestamp?: number;\n};\n\n/** @internal */\nexport type ConflictActionsMap<A> = {\n [name in keyof A]?: FutureActions[];\n};\n\n/** @internal */\nexport type AsyncActionExecContext<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P> = {\n actionName: keyof A;\n action: AsyncActionPromise<S, F, A, P, DS>;\n stateRef: Ref<S>;\n derivedStateRef: Ref<DerivedState<DS>>;\n propsRef: Ref<P>;\n loadingMapRef: Ref<InternalLoadingMap<A>>;\n promisesRef: Ref<PromiseMap<A>>;\n conflictActionsRef: Ref<ConflictActionsMap<A>>;\n actionsRef: Ref<A>;\n initializedRef: Ref<boolean>;\n options: StoreOptions<S, A, P, any>;\n setState: SetStateFunc<S, A, P>;\n};\n\n/** @internal */\nexport type TimeoutMap<A> = {\n [name in keyof A]?: any;\n};\n\nexport type NotifyFunc = (msg: string) => void;\nexport type CloneFunction = <C>(obj: C) => C;\nexport type ComparatorFunction = <C>(obj1: C, Obj2: C) => boolean;\nexport type RetryOnErrorFunction = (error: any) => boolean;\nexport type AsyncErrorHandler = (\n error: any,\n isHandled: boolean,\n state: any,\n props: any,\n actionName: string,\n args: any[]\n) => void;\n\ntype DerivedStateMap<DS> = {\n [name in keyof DS]?: any[];\n};\n\n/** @internal */\nexport type DerivedState<DS> = {\n state: DS;\n deps: DerivedStateMap<DS>;\n};\n\n// =============================\n//\n// GLOBAL CONFIG\n//\n// =============================\n\n/**\n * Global configuration, shared with all stores.\n */\nexport type GlobalConfig = {\n /**\n * Clone function.\n * Used to clone state and props when managing optimistic reducer and conflicting actions.\n * Default implementation is a very basic algorithm using JSON.stringify. To clone complex stats,\n * use a custom implementation like lodash/cloneDeep.\n * @default JSON.stringify\n */\n clone: CloneFunction;\n\n /**\n * Compare to objets and returns if they are equal.\n * Used to comparent previous and current state slice.\n * @default shallow\n */\n comparator: ComparatorFunction;\n\n /**\n * Global callback function to handle asychronous actions rejected promise.\n */\n asyncErrorHandler: AsyncErrorHandler;\n\n /**\n * Tests if the error will trigger a retry of the action or will fail directly.\n * Default implementation is returning true for TypeError instances only.\n * @see AsynchActionBase#retryCount\n */\n retryOnErrorFunction: RetryOnErrorFunction;\n\n /**\n * Global notification function that will called when an asynchronous action succeeded,\n * if and only if, an error message is specified for this action using\n * <code>getErrorMessage</code>.\n * If another function is set in the options, the function from the options will be used.\n */\n notifySuccess: NotifyFunc;\n\n /**\n * Global notification function that will called when an asynchronous action fails,\n * if and only if, an error message is specified for this action using\n * <code>getErrorMessage</code>.\n * If another function is set in the options, the function from the options will be used.\n */\n notifyError: NotifyFunc;\n\n /**\n * Global notification function that will injected in onDone and onFail of an asynchronous actions and onActionDone of a synchronous function,\n * If another function is set in the options, the function from the options will be used.\n */\n notifyWarning: NotifyFunc;\n\n /**\n * A default error message provider.\n * Used to return generic messages on generic HTTP errors\n */\n getErrorMessage: (error: Error) => string;\n\n /**\n * Default middlewares. Store middleware array will be concatenated with this one.\n * By default contains only the optimistic middleware.\n */\n defaultMiddlewares: MiddlewareFactory<any, any, any>[];\n};\n\n/** @internal */\nexport const globalConfig: GlobalConfig = {\n clone: defaultCloneFunc,\n comparator: shallow,\n asyncErrorHandler: () => {},\n retryOnErrorFunction: (error: Error) => error instanceof TypeError,\n notifySuccess: undefined,\n notifyError: undefined,\n notifyWarning: undefined,\n getErrorMessage: undefined,\n defaultMiddlewares: [],\n};\n\nexport function setGlobalConfig(overrideConfig: Partial<GlobalConfig>) {\n const keys = Object.keys(overrideConfig) as (keyof GlobalConfig)[];\n keys.forEach((k) => {\n if (overrideConfig[k] != null) {\n globalConfig[k] = overrideConfig[k] as any;\n }\n });\n}\n\nfunction defaultCloneFunc(src: any) {\n return JSON.parse(JSON.stringify(src));\n}\n\nfunction clone(obj: any) {\n try {\n return globalConfig.clone(obj);\n } catch (e) {\n const msg =\n 'StateDecorator: Cannot clone object. Call setCloneFunction with another implementation like lodash/cloneDeep.';\n if (process.env.NODE_ENV === 'development') {\n console.error(msg);\n console.error(e.toString());\n }\n throw new Error(msg);\n }\n}\n\n// ----------------------------\n//\n// TYPE GUARDS\n//\n// -----------------------------\n\n/**\n * Type guard function to test if an action is a asynchronous action.\n */\nexport function isAsyncAction<S, DS, F extends (...args: any[]) => any, A, P, FxRes = S>(\n action: StoreAction<S, F, A, P, DS, FxRes>\n): action is AsyncAction<S, F, A, P, DS, FxRes> {\n return (\n !(action instanceof Function) && (action.hasOwnProperty('getPromise') || action.hasOwnProperty('getGetPromise'))\n );\n}\n\n/**\n * Type guard function to test if an action is a synchronous action.\n */\nexport function isSimpleSyncAction<S, F extends (...args: any[]) => any, A, P, DS = {}, FxRes = S>(\n action: StoreAction<S, F, A, P, DS, FxRes>\n): action is SimpleSyncAction<S, F, P, DS, FxRes> {\n return typeof action === 'function';\n}\n\n/**\n * Type guard function to test if an action is a synchronous action.\n */\nexport function isSyncAction<S, F extends (...args: any[]) => any, A, P, DS = {}, FxRes = S>(\n action: StoreAction<S, F, A, P, DS, FxRes>\n): action is SyncAction<S, F, A, P, DS, FxRes> {\n return (\n typeof action !== 'function' && !action.hasOwnProperty('getPromise') && !action.hasOwnProperty('getGetPromise')\n );\n}\n\nexport function isAsyncGetPromiseAction<S, DS, F extends (...args: any[]) => any, A, P, FxRes = S>(\n action: StoreAction<S, F, A, P, DS, FxRes>\n): action is AsyncActionPromise<S, F, A, P, DS, FxRes> {\n return typeof action !== 'function' && action.hasOwnProperty('getPromise') && !action.hasOwnProperty('getGetPromise');\n}\n\nexport function isAsyncGetPromiseGetAction<S, DS, F extends (...args: any[]) => any, A, P, FxRes = S>(\n action: StoreAction<S, F, A, P, DS, FxRes>\n): action is AsyncActionPromiseGet<S, F, A, P, DS, FxRes> {\n return typeof action !== 'function' && !action.hasOwnProperty('getPromise') && action.hasOwnProperty('getGetPromise');\n}\n\n/** @internal */\nexport function computeAsyncActionInput<S, DS, F extends (...args: any[]) => any, A, P, FxRes = S>(\n action: AsyncAction<S, F, A, P, DS, FxRes>\n): AsyncActionPromise<S, F, A, P, DS, FxRes> {\n if (isAsyncGetPromiseGetAction(action)) {\n return {\n ...(action as any),\n getPromise: action.getGetPromise,\n retryCount: 3,\n conflictPolicy: ConflictPolicy.REUSE,\n };\n }\n return action;\n}\n\n/** @internal */\nexport function buildLoadingMap<A>(\n source: InternalLoadingMap<A>,\n actionName: keyof A,\n promiseId: string,\n loading: boolean\n): InternalLoadingMap<A> {\n if (loading) {\n return {\n ...source,\n [actionName]: { ...(source[actionName] || {}), [promiseId]: loading },\n };\n }\n const res = {\n ...source,\n [actionName]: { ...source[actionName], [promiseId]: false },\n };\n return res;\n}\n\n/** @internal */\nexport function retryPromiseDecorator<S, DS, F extends (...args: any[]) => Promise<any>, A, P>(\n promiseProvider: PromiseProvider<S, DS, F, A, P>,\n maxCalls = 1,\n delay = 1000,\n isRetryError: (e: Error) => boolean = () => true\n): PromiseProvider<S, DS, F, A, P> {\n if (maxCalls === 1) {\n return promiseProvider;\n }\n return (ctx: GetPromiseInvocationContext<S, DS, F, P, A>): ReturnType<F> => {\n async function call(callCount: number, p: Promise<any>): Promise<any> {\n if (p === null) {\n return null;\n }\n\n return p.catch((e) => {\n if (isRetryError(e)) {\n if (callCount === maxCalls) {\n return Promise.reject(e);\n }\n return new Promise((resolve, reject) => {\n setTimeout(() => {\n const p = promiseProvider(ctx);\n call(callCount + 1, p)\n .then(resolve)\n .catch(reject);\n }, delay * callCount);\n });\n }\n return Promise.reject(e);\n });\n }\n\n const initialPromise = promiseProvider(ctx);\n if (initialPromise === null) {\n return null;\n }\n\n return call(1, initialPromise) as ReturnType<F>;\n };\n}\n\nexport type Ref<P> = {\n current: P;\n};\n\n/** @internal */\nexport function createRef<U>(init: U = null): Ref<U> {\n return {\n current: init,\n };\n}\n\n// =============================\n//\n// ACTION DECORATORS\n//\n// =============================\n/** @internal */\nexport function buildInvocationContextBase<S, DS, P>(\n stateRef: Ref<S>,\n derivedStateRef: Ref<DerivedState<DS>>,\n propsRef: Ref<P>\n): ContextWithDerived<S, DS, P> {\n return {\n state: stateRef.current,\n s: stateRef.current,\n ds: derivedStateRef?.current?.state,\n derived: derivedStateRef?.current?.state,\n props: propsRef.current,\n p: propsRef.current,\n };\n}\n\n/** @internal */\nexport function buildOnMountInvocationContext<S, DS, A, P>(\n stateRef: Ref<S>,\n derivedStateRef: Ref<DerivedState<DS>>,\n propsRef: Ref<P>,\n actionsRef: Ref<A>\n): OnMountInvocationContext<S, A, P> {\n return addContextActions(buildInvocationContextBase(stateRef, derivedStateRef, propsRef), actionsRef);\n}\n\n/** @internal */\nexport function buildOnPropChangeEffects<S, DS, P>(\n stateRef: Ref<S>,\n derivedStateRef: Ref<DerivedState<DS>>,\n propsRef: Ref<P>,\n indices: number[],\n index: number,\n isInit: boolean\n): OnPropsChangeEffectsContext<S, DS, P> {\n const res = buildInvocationContextBase(stateRef, derivedStateRef, propsRef) as OnPropsChangeEffectsContext<S, DS, P>;\n res.indices = indices;\n res.index = index;\n res.isInit = isInit;\n return res;\n}\n\n/** @internal */\nfunction buildInvocationContext<S, DS, F extends (...args: any[]) => any, P>(\n stateRef: Ref<S>,\n derivedStateRef: Ref<DerivedState<DS>>,\n propsRef: Ref<P>,\n args: Parameters<F>,\n promiseId?: string\n): InvocationContext<S, DS, F, P> {\n const res = buildInvocationContextBase(stateRef, derivedStateRef, propsRef) as InvocationContext<S, DS, F, P>;\n res.args = args;\n if (promiseId) {\n res.promiseId = promiseId;\n }\n\n return res;\n}\n\n/** @internal */\nfunction buildEffectsInvocationContext<S, DS, F extends (...args: any[]) => any, P>(\n stateRef: Ref<S>,\n derivedStateRef: Ref<DerivedState<DS>>,\n propsRef: Ref<P>,\n args: Parameters<F>,\n result: PromiseResult<ReturnType<F>>,\n promiseId?: string\n): EffectsInvocationContext<S, DS, F, P> {\n const res = buildInvocationContext(stateRef, derivedStateRef, propsRef, args, promiseId) as EffectsInvocationContext<\n S,\n DS,\n F,\n P\n >;\n res.result = result;\n res.res = result;\n return res;\n}\n\n/** @internal */\nfunction buildErrorEffectsInvocationContext<S, DS, F extends (...args: any[]) => any, P>(\n stateRef: Ref<S>,\n derivedStateRef: Ref<DerivedState<DS>>,\n propsRef: Ref<P>,\n args: Parameters<F>,\n error: Error,\n promiseId?: string\n): ErrorEffectsInvocationContext<S, DS, F, P> {\n const res = buildInvocationContext(\n stateRef,\n derivedStateRef,\n propsRef,\n args,\n promiseId\n ) as ErrorEffectsInvocationContext<S, DS, F, P>;\n res.error = error;\n res.err = error;\n return res;\n}\n\n/** @internal */\nfunction buildPromiseActionContext<S, DS, F extends (...args: any[]) => any, P, A>(\n stateRef: Ref<S>,\n derivedStateRef: Ref<DerivedState<DS>>,\n propsRef: Ref<P>,\n args: Parameters<F>,\n actionsRef: Ref<A>,\n abortSignal: AbortSignal,\n promiseId?: string\n): GetPromiseInvocationContext<S, DS, F, P, A> {\n const res = addContextActions(\n buildInvocationContext(stateRef, derivedStateRef, propsRef, args, promiseId),\n actionsRef\n ) as GetPromiseInvocationContext<S, DS, F, P, A>;\n res.abortSignal = abortSignal;\n return res;\n}\n\n/** @internal */\nexport function addStateToContext<T, S>(ctx: T, stateRef: Ref<S>): T & ContextState<S> {\n const newCtx = ctx as T & ContextState<S>;\n\n newCtx.state = stateRef.current;\n newCtx.s = stateRef.current;\n return newCtx;\n}\n\n/** @internal */\nexport function addContextActions<T, A>(ctx: T, actionsRef: Ref<A>): T & InvocationContextActions<A> {\n const newCtx = ctx as T & InvocationContextActions<A>;\n\n newCtx.actions = actionsRef.current;\n newCtx.a = actionsRef.current;\n return newCtx;\n}\n\n/** @internal */\nfunction addSideEffectsContext<S, T extends { s: S; state: S }, A>(\n ctx: T,\n stateRef: Ref<S>,\n actionsRef: Ref<A>,\n notifyWarning: NotifyFunc\n): T & InvocationContextActions<A> & WarningNotifyFunc {\n const res = addContextActions(ctx, actionsRef) as T & InvocationContextActions<A> & WarningNotifyFunc;\n addStateToContext(ctx, stateRef);\n res.notifyWarning = notifyWarning;\n return res;\n}\n\nfunction notInitWarning<A>(actionName: keyof A) {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n `[state-decorator] ${actionName} action was called while store is not initialized or destroyed, this is probably a leak`\n );\n }\n}\n\n/** @internal */\nexport function decorateSimpleSyncAction<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P>(\n actionName: keyof A,\n action: SimpleSyncAction<S, F, P, DS>,\n stateRef: Ref<S>,\n derivedStateRef: Ref<DerivedState<DS>>,\n propsRef: Ref<P>,\n initializedRef: Ref<boolean>,\n setState: SetStateFunc<S, A, P>\n) {\n return (...args: Parameters<F>) => {\n // store was destroyed\n if (!initializedRef.current) {\n notInitWarning(actionName);\n return;\n }\n\n const ctx = buildInvocationContext(stateRef, derivedStateRef, propsRef, args);\n const newState = action(ctx);\n setState(newState, null, actionName, 'effects', false, ctx, false);\n };\n}\n\n/** @internal */\nfunction executeSyncActionImpl<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P>(\n actionName: keyof A,\n action: SyncAction<S, F, A, P, DS>,\n stateRef: Ref<S>,\n derivedStateRef: Ref<DerivedState<DS>>,\n propsRef: Ref<P>,\n actionsRef: Ref<A>,\n timeoutMap: Ref<TimeoutMap<A>>,\n options: StoreOptions<S, A, P, any>,\n setState: SetStateFunc<S, A, P>,\n args: Parameters<F>\n) {\n const ctx = buildEffectsInvocationContext(stateRef, derivedStateRef, propsRef, args, undefined);\n const newState = action.effects(ctx);\n setState(newState, undefined, actionName, 'effects', false, ctx, false);\n\n if (newState !== null) {\n if (action.debounceSideEffectsTimeout > 0) {\n const timeout = timeoutMap.current[actionName];\n\n if (timeout) {\n clearTimeout(timeout);\n }\n\n timeoutMap.current[actionName] = setTimeout(() => {\n action.sideEffects(addSideEffectsContext(ctx, stateRef, actionsRef, options.notifyWarning));\n delete timeoutMap.current[actionName];\n }, action.debounceSideEffectsTimeout);\n } else if (action.sideEffects) {\n action.sideEffects(addSideEffectsContext(ctx, stateRef, actionsRef, options.notifyWarning));\n }\n }\n}\n\n/** @internal */\nexport function decorateSyncAction<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P>(\n actionName: keyof A,\n action: SyncAction<S, F, A, P, DS>,\n stateRef: Ref<S>,\n derivedStateRef: Ref<DerivedState<DS>>,\n propsRef: Ref<P>,\n actionsRef: Ref<A>,\n initializedRef: Ref<boolean>,\n timeoutMap: Ref<TimeoutMap<A>>,\n options: StoreOptions<S, A, P, any>,\n setState: SetStateFunc<S, A, P>\n) {\n return (...args: Parameters<F>) => {\n // store was destroyed\n if (!initializedRef.current) {\n notInitWarning(actionName);\n return;\n }\n\n if (action.debounceTimeout) {\n const timeout = timeoutMap.current[actionName];\n\n if (timeout) {\n clearTimeout(timeout);\n }\n\n timeoutMap.current[actionName] = setTimeout(() => {\n delete timeoutMap.current[actionName];\n executeSyncActionImpl(\n actionName,\n action,\n stateRef,\n derivedStateRef,\n propsRef,\n actionsRef,\n timeoutMap,\n options,\n setState,\n args\n );\n }, action.debounceTimeout);\n } else {\n executeSyncActionImpl(\n actionName,\n action,\n stateRef,\n derivedStateRef,\n propsRef,\n actionsRef,\n timeoutMap,\n options,\n setState,\n args\n );\n }\n };\n}\n\nfunction processPromiseSuccess<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P>(\n context: AsyncActionExecContext<S, DS, F, A, P>,\n promiseId: string,\n promiseResult: PromiseResult<F>,\n args: Parameters<F>\n) {\n const {\n action,\n stateRef,\n derivedStateRef,\n propsRef,\n promisesRef,\n actionsRef,\n loadingMapRef,\n conflictActionsRef,\n actionName,\n options,\n setState,\n } = context;\n\n // store was destroyed\n if (!context.initializedRef.current) {\n return void 0;\n }\n\n let newState = null;\n\n const ctx = buildEffectsInvocationContext(stateRef, derivedStateRef, propsRef, args, promiseResult, promiseId);\n\n if (action.effects) {\n newState = action.effects(ctx);\n }\n\n setState(\n newState,\n buildLoadingMap(loadingMapRef.current, actionName, promiseId, false),\n actionName,\n 'effects',\n true,\n ctx,\n false\n );\n\n const notifySuccess = options.notifySuccess || globalConfig.notifySuccess;\n\n if (notifySuccess) {\n let msg: string;\n\n if (action.getSuccessMessage) {\n msg = action.getSuccessMessage(ctx);\n }\n\n if (msg) {\n notifySuccess(msg);\n }\n }\n\n delete promisesRef.current[actionName][promiseId];\n\n if (action.sideEffects) {\n action.sideEffects(addSideEffectsContext(ctx, stateRef, actionsRef, globalConfig.notifyWarning));\n }\n\n processNextConflictAction(actionName, actionsRef.current, conflictActionsRef.current);\n\n return promiseResult;\n}\n\nfunction processPromiseFailed<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P>(\n context: AsyncActionExecContext<S, DS, F, A, P>,\n promiseId: string,\n error: Error,\n args: Parameters<F>\n) {\n const {\n action,\n stateRef,\n derivedStateRef,\n propsRef,\n actionsRef,\n loadingMapRef,\n promisesRef,\n conflictActionsRef,\n actionName,\n options,\n setState,\n } = context;\n\n // store was killed;\n if (!context.initializedRef.current) {\n return void 0;\n }\n\n let newState = null;\n\n const ctx = buildErrorEffectsInvocationContext(stateRef, derivedStateRef, propsRef, args, error, promiseId);\n\n if (action.errorEffects) {\n newState = action.errorEffects(ctx);\n }\n\n setState(\n newState,\n buildLoadingMap(loadingMapRef.current, actionName, promiseId, false),\n actionName,\n 'errorEffects',\n true,\n ctx,\n false\n );\n\n let errorHandled = false;\n\n if (newState != null || action.errorSideEffects) {\n errorHandled = true;\n }\n\n const notifyError = options.notifyError || globalConfig.notifyError;\n\n if (notifyError) {\n let msg: string;\n\n if (action.getErrorMessage) {\n msg = action.getErrorMessage(ctx);\n }\n\n // do not trigger a default error message if the error is already managed by error effects\n if (!msg && !errorHandled && globalConfig.getErrorMessage) {\n msg = globalConfig.getErrorMessage(error);\n }\n\n if (msg) {\n errorHandled = true;\n notifyError(msg);\n }\n }\n\n globalConfig.asyncErrorHandler(\n error,\n errorHandled || action.rejectPromiseOnError,\n stateRef.current,\n propsRef.current,\n actionName as string,\n args\n );\n\n delete promisesRef.current[actionName][promiseId];\n\n if (action.errorSideEffects) {\n action.errorSideEffects(addSideEffectsContext(ctx, stateRef, actionsRef, globalConfig.notifyWarning));\n }\n\n processNextConflictAction(actionName, actionsRef.current, conflictActionsRef.current);\n\n const result = !errorHandled || action.rejectPromiseOnError ? Promise.reject(error) : Promise.resolve();\n\n return result;\n}\n\n/** @internal */\nexport function decorateAsyncAction<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P>(\n context: AsyncActionExecContext<S, DS, F, A, P>\n) {\n const {\n action,\n stateRef,\n derivedStateRef,\n propsRef,\n actionsRef,\n promisesRef,\n loadingMapRef,\n initializedRef,\n conflictActionsRef,\n actionName,\n setState,\n } = context;\n\n return (...args: Parameters<F>): Promise<any> => {\n if (!initializedRef.current) {\n notInitWarning(actionName);\n return null;\n }\n\n const promises = promisesRef.current;\n\n const { conflictPolicy = ConflictPolicy.KEEP_ALL } = action;\n const isParallel = conflictPolicy === ConflictPolicy.PARALLEL;\n\n let promiseId: string = null;\n if (isParallel) {\n if (!action.getPromiseId) {\n throw new Error(\n 'If conflict policy is set to ConflictPolicy.PARALLEL, getPromiseId must be set and return a string.'\n );\n }\n promiseId = action.getPromiseId(...args);\n } else {\n promiseId = DEFAULT_PROMISE_ID;\n }\n\n if (!isParallel && promises[actionName]?.[promiseId]) {\n return handleConflictingAction(promises, conflictActionsRef.current, actionName, conflictPolicy, args);\n }\n\n let newState = null;\n let hasChanged = false;\n\n const ctx = buildInvocationContext(stateRef, derivedStateRef, propsRef, args, promiseId);\n if (action.preEffects) {\n newState = action.preEffects(ctx);\n\n // apply internal state change for calls to other actions in the getPromise\n if (newState) {\n hasChanged = true;\n stateRef.current = newState;\n }\n }\n\n const { abortable, retryCount, retryDelaySeed, isTriggerRetryError } = action;\n\n const abortController = abortable && window.AbortController ? new AbortController() : null;\n\n const promiseProvider = retryPromiseDecorator(\n action.getPromise,\n retryCount ? 1 + retryCount : 1,\n retryDelaySeed,\n isTriggerRetryError || globalConfig.retryOnErrorFunction\n );\n\n const p = promiseProvider(\n buildPromiseActionContext(stateRef, derivedStateRef, propsRef, args, actionsRef, abortController?.signal)\n )\n ?.then((promiseResult: PromiseResult<F>) => processPromiseSuccess(context, promiseId, promiseResult, args))\n .catch((error: any) => processPromiseFailed(context, promiseId, error, args));\n\n if (p != null) {\n promises[actionName] = {\n ...(promises[actionName] || {}),\n [promiseId || DEFAULT_PROMISE_ID]: {\n abortController,\n promise: p,\n refArgs: conflictPolicy === ConflictPolicy.REUSE && args.length > 0 ? [...args] : [],\n },\n };\n }\n\n setState(\n p == null && !hasChanged ? undefined : stateRef.current,\n p == null ? undefined : buildLoadingMap(loadingMapRef.current, actionName, promiseId, true),\n actionName,\n 'preEffects',\n true,\n ctx,\n false\n );\n\n return p;\n };\n}\n\n/** @internal */\nexport function isLoadingImpl<A, K extends keyof A>(loadingMap: InternalLoadingMap<A>, ...props: (K | [K, string])[]) {\n return props.some((propIn) => {\n let actionName: keyof A = null;\n let promiseId = DEFAULT_PROMISE_ID;\n\n if (Array.isArray(propIn)) {\n [actionName, promiseId = DEFAULT_PROMISE_ID] = propIn;\n } else {\n actionName = propIn;\n }\n\n const res = loadingMap[actionName];\n\n if (res == null) {\n return false;\n }\n\n if (res[promiseId] != null) {\n return res[promiseId];\n }\n\n return false;\n });\n}\n\n// ------------------------------\n//\n// Conflict management\n//\n// ------------------------------\n\nexport const DEFAULT_PROMISE_ID = '__def__';\n\n/** @internal */\nexport function areSameArgs(args1: any[], args2: any[]): boolean {\n if (args1.length !== args2.length) {\n return false;\n }\n return args1.findIndex((value, index) => args2[index] !== value) === -1;\n}\n\n/**\n * Handles a conflicting action depending on the action conflict policy.\n */\n/** @internal */\nfunction handleConflictingAction<A>(\n promises: PromiseMap<A>,\n conflictActions: ConflictActionsMap<A>,\n actionName: keyof A,\n conflictPolicy: ConflictPolicy,\n args: any[]\n) {\n let policy = conflictPolicy;\n if (policy === ConflictPolicy.REUSE) {\n // use default because action cannot be parallel\n if (areSameArgs(promises[actionName][DEFAULT_PROMISE_ID].refArgs, args)) {\n return promises[actionName][DEFAULT_PROMISE_ID].promise;\n } // else\n policy = ConflictPolicy.KEEP_ALL;\n }\n\n return new Promise((resolve, reject) => {\n const futureAction = {\n resolve,\n reject,\n args: clone(args),\n timestamp: Date.now(),\n };\n\n switch (policy) {\n case ConflictPolicy.IGNORE:\n resolve(void 0);\n break;\n case ConflictPolicy.REJECT:\n reject(new Error(`An asynchronous action ${actionName} is already ongoing.`));\n break;\n case ConflictPolicy.KEEP_LAST: {\n conflictActions[actionName] = [futureAction];\n break;\n }\n case ConflictPolicy.KEEP_ALL: {\n let stack = conflictActions[actionName];\n if (!stack) {\n conflictActions[actionName] = stack = [];\n }\n stack.push(futureAction);\n\n break;\n }\n case ConflictPolicy.PARALLEL:\n case ConflictPolicy.REUSE:\n // no-op\n break;\n default:\n // will trigger a compilation error if one of the enum values is not processed.\n const exhaustiveCheck: never = policy;\n exhaustiveCheck;\n break;\n }\n });\n}\n\n/**\n * Processes next conflicting action (see ConflictPolicy) in the queue.\n */\nfunction processNextConflictAction<A>(actionName: keyof A, actions: A, conflictActions: ConflictActionsMap<A>) {\n const futureActions = conflictActions[actionName];\n\n if (futureActions && futureActions.length > 0) {\n const futureAction = conflictActions[actionName].shift();\n\n if (futureAction) {\n const p = (actions[actionName] as any)(...futureAction.args) as Promise<any>;\n if (p == null) {\n processNextConflictAction(actionName, actions, conflictActions);\n } else {\n p.then((res) => {\n if (res === null) {\n // promise was aborted\n processNextConflictAction(actionName, actions, conflictActions);\n }\n futureAction.resolve(res);\n }).catch((e) => futureAction.reject(e));\n } // else aborted\n }\n }\n}\n\n/** @internal */\nexport function computeDerivedValues<S, A, P, DS>(\n s: Ref<S>,\n p: Ref<P>,\n derivedStateRef: Ref<DerivedState<DS>>,\n options: StoreOptions<S, A, P, DS>\n): boolean {\n if (options?.derivedState == null) {\n return false;\n }\n\n let hasChanged = false;\n const compare = globalConfig.comparator;\n\n const depsMap = derivedStateRef.current.deps;\n const ctx = buildInvocationContextBase(s, null, p);\n\n const keys = Object.keys(options.derivedState) as (keyof DS)[];\n\n derivedStateRef.current.state = keys.reduce((acc, propName) => {\n let compute = false;\n\n const previousDeps = depsMap[propName];\n const deps = options.derivedState[propName].getDeps(ctx);\n if (previousDeps == null) {\n compute = true;\n } else {\n compute =\n deps.find((dep, index) => (previousDeps.length < index ? true : !compare(previousDeps[index], dep))) != null;\n }\n\n hasChanged = hasChanged || compute;\n\n // update cache of previous deps\n depsMap[propName] = deps;\n\n if (compute) {\n acc[propName] = options.derivedState[propName].get(ctx);\n } else {\n acc[propName] = derivedStateRef.current.state[propName];\n }\n\n return acc;\n }, {} as DS);\n\n return hasChanged;\n}\n\n// --------------------------------------\n//\n// Props change\n//\n// --------------------------------------\n\n/** @internal */\nexport function onPropChange<S, P, A, DS>(\n stateRef: Ref<S>,\n derivedStateRef: Ref<DerivedState<DS>>,\n propsRef: Ref<P>,\n oldProps: P,\n actionsRef: Ref<A>,\n options: StoreOptions<S, A, P, DS>,\n setState: SetStateFunc<S, A, P>,\n isInit: boolean\n) {\n const hasDerivedState = options?.derivedState != null;\n\n if (options.onPropsChange == null) {\n if (options?.derivedState != null) {\n // derived values must be updated from props\n setState(undefined, undefined, 'onPropsChange', 'effects', false, null, true);\n }\n return;\n }\n\n let onPropsChanges: OnPropsChangeOptions<S, DS, A, P>[];\n\n if (Array.isArray(options.onPropsChange)) {\n onPropsChanges = options.onPropsChange;\n } else {\n onPropsChanges = [options.onPropsChange];\n }\n\n let stateChanged = false;\n\n const newStateRef = createRef(stateRef.current);\n const sideEffects: { index: number; indices: any[]; ctx: OnPropsChangeEffectsContext<S, DS, P> }[] = [];\n\n const compare = globalConfig.comparator;\n\n onPropsChanges.forEach((propsChange, index) => {\n const getDeps = propsChange.getDeps;\n if (getDeps) {\n let propChanged = false;\n\n const indices: number[] = [];\n\n if (isInit) {\n if (propsChange.onMount) {\n propChanged = true;\n } else {\n // skip this onPropsChange\n return;\n }\n } else {\n const oldValues = getDeps(oldProps);\n const newValues = getDeps(propsRef.current);\n\n if (oldValues.length !== newValues.length) {\n console.warn('options.onPropsChange.getDeps returned array must be stable (same length)');\n propChanged = true;\n } else {\n oldValues.forEach((v, i) => {\n if (!compare(v, newValues[i])) {\n propChanged = true;\n indices.push(i);\n }\n });\n }\n }\n\n if (propChanged) {\n const ctx = buildOnPropChangeEffects(newStateRef, derivedStateRef, propsRef, indices, index, isInit);\n const newState = propsChange.effects?.(ctx) ?? null;\n\n if (newState != null) {\n stateChanged = true;\n newStateRef.current = newState;\n setState(newStateRef.current, undefined, 'onPropsChange', 'effects', false, ctx, true, isInit);\n }\n\n if (propsChange.sideEffects) {\n sideEffects.push({ index, indices, ctx });\n }\n }\n }\n });\n\n if (!stateChanged && hasDerivedState) {\n // derived values must be updated from props\n setState(undefined, undefined, 'onPropsChange', 'effects', false, null, true);\n }\n\n if (sideEffects.length > 0) {\n sideEffects.forEach((sideEffectInfo) => {\n const onPropChange = onPropsChanges[sideEffectInfo.index];\n onPropChange.sideEffects({\n ...addStateToContext(addContextActions(sideEffectInfo.ctx, actionsRef), newStateRef),\n indices: sideEffectInfo.indices,\n });\n });\n }\n}\n\n// ------------------\n//\n// Middlewares\n//\n// ------------------\n\n/** @internal */\nexport function runMiddlewares<S, A extends DecoratedActions, P>(\n middlewares: Middleware<S, A, P>[],\n oldState: S,\n newState: S,\n loading: boolean,\n actionName: keyof A,\n actionType: 'preEffects' | 'effects' | 'errorEffects' | null,\n isAsync: boolean,\n actionCtx: any\n): {\n newState: S;\n newLoading: boolean;\n} {\n // onPropChange to compute derived state but not state change\n if (actionName === 'onPropsChange' && newState === undefined) {\n return {\n newState: null,\n newLoading: false,\n };\n }\n\n if (middlewares && middlewares.length > 0) {\n const res = middlewares.reduce(\n (acc, middleware) => {\n const res = middleware.effects(\n {\n isAsync,\n name: actionName,\n type: actionType,\n context: actionCtx,\n },\n acc.oldState,\n acc.newState,\n loading\n );\n\n return {\n newState: res?.state || acc.newState,\n oldState: res?.state ? acc.newState : acc.oldState,\n loading: res?.loading == null ? acc.loading : res.loading,\n };\n },\n {\n oldState,\n newState,\n loading,\n }\n );\n\n return {\n newLoading: res.loading,\n newState: res.newState,\n };\n }\n return {\n newState,\n newLoading: loading,\n };\n}\n","/*\n * Copyright 2019 Globalsport SAS\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n// @ts-nocheck\n// SOURCE https://github.com/pmndrs/zustand/blob/master/src/shallow.ts\n\ntype Obj = Record<string | number | symbol, unknown>;\n\nexport default function shallow<T extends any, U extends any>(objA: T, objB: U) {\n if (Object.is(objA, objB)) {\n return true;\n }\n if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {\n return false;\n }\n const keysA = Object.keys(objA as object);\n if (keysA.length !== Object.keys(objB as object).length) {\n return false;\n }\n for (let i = 0; i < keysA.length; i++) {\n if (\n !Object.prototype.hasOwnProperty.call(objB, keysA[i]) ||\n !Object.is((objA as Obj)[keysA[i]], (objB as Obj)[keysA[i]])\n ) {\n return false;\n }\n }\n return true;\n}\n","import type {\n AsyncAction,\n DecoratedActions,\n EffectsType,\n Middleware,\n MiddlewareFactory,\n MiddlewareStoreContext,\n} from './types';\nimport isEqual from 'fast-deep-equal';\nimport { CloneFunction, globalConfig, isSimpleSyncAction } from './impl';\n\nfunction getNoopMiddleware<S, A extends DecoratedActions, P>(): Middleware<S, A, P> {\n const middleware: Middleware<S, A, P> = {\n init: () => {},\n destroy: null,\n effects: () => null,\n };\n\n return middleware;\n}\n\nexport function logEffects<S, A extends DecoratedActions, P>(\n log: (...msg: any[]) => void = console.log\n): MiddlewareFactory<S, A, P> {\n const f = () => {\n const logger = log;\n let storeName = '';\n\n const middleware: Middleware<S, A, P> = {\n init: (storeContext) => {\n if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {\n storeName = storeContext.options?.name ? `[${storeContext.options?.name}]` : '';\n const newState = storeContext.state;\n logger(storeName, 'initialState', newState);\n }\n },\n destroy: null,\n effects: (action, oldState, newState, loading: boolean) => {\n if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {\n logger(\n storeName,\n action.name,\n action.type,\n newState === null ? 'no effect' : newState,\n action.isAsync\n ? action.type === 'preEffects' && !loading\n ? 'Promise cancelled'\n : `loading: ${loading}`\n : ''\n );\n }\n return null;\n },\n };\n return middleware;\n };\n\n return f;\n}\n\nexport type Logger = {\n log: (...args: any[]) => void;\n group: (...args: any[]) => void;\n groupCollapsed: (...args: any[]) => void;\n groupEnd: (...args: any[]) => void;\n};\n\nexport function logDetailedEffects<S, A extends DecoratedActions, P>(\n logger: Logger = console\n): MiddlewareFactory<S, A, P> {\n return () => {\n let storeName = '';\n\n const console = logger;\n\n if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {\n const computeDiffPropValue = (oldValue: any, newValue: any) => {\n let res: any;\n if (newValue !== oldValue) {\n const type = oldValue != null ? typeof oldValue : typeof newValue;\n if (type === 'number' || type === 'string' || type === 'boolean') {\n res = `${oldValue} => ${newValue === '' ? '\"\"' : newValue}`;\n } else if ((oldValue && oldValue.length) || (newValue && newValue.length)) {\n if (oldValue == null) {\n res = `was ${oldValue}, now contains ${newValue.length} element(s)`;\n } else if (newValue == null) {\n res = `contained ${oldValue.length} element(s), now is ${newValue}`;\n } else if (oldValue.length === 0) {\n res = `was empty, now contains ${newValue.length} elements`;\n } else if (newValue.length === 0) {\n res = `contained ${oldValue.length} elements, now is empty`;\n } else {\n let addedValues = newValue.filter((a: any) => !oldValue.find((b: any) => isEqual(a, b)));\n let removedValues = oldValue.filter((a: any) => !newValue.find((b: any) => isEqual(a, b)));\n\n if (addedValues.length > 10) {\n addedValues = `${addedValues.length} element(s) added`;\n }\n if (removedValues.length > 10) {\n removedValues = `${removedValues.length} element(s) removed`;\n }\n res = {\n added: addedValues,\n removed: removedValues,\n };\n }\n } else {\n res = newValue;\n }\n }\n return res;\n };\n\n const buildDiff = <S>(oldState: S, newState: S) => {\n const res: Record<string, any> = {};\n\n if (process.env.NODE_ENV === 'development') {\n if (oldState) {\n const keys = Object.keys(oldState) as (keyof S)[];\n keys.forEach((k) => {\n if (newState.hasOwnProperty(k)) {\n const oldValue = oldState[k];\n const newValue = newState[k];\n const diff = computeDiffPropValue(oldValue, newValue);\n if (diff) {\n res[k as any] = diff;\n }\n } else {\n res[k as any] = 'was deleted';\n }\n });\n }\n\n const keys = Object.keys(newState) as (keyof S)[];\n keys.forEach((k) => {\n if (oldState == null || !oldState.hasOwnProperty(k)) {\n const newValue = newState[k];\n\n res[k as any] = computeDiffPropValue(undefined, newValue);\n }\n });\n }\n\n return res;\n };\n\n const getStr = (v: any) => {\n if (typeof v === 'string') {\n return `\"${v}\"`;\n }\n return v;\n };\n\n const middleware: Middleware<S, A, P> = {\n init: (storeContext) => {\n storeName = storeContext.options?.name ? `[${storeContext.options?.name}]` : '';\n const newState = storeContext.state;\n logger.group(storeName, 'initialState');\n const keys = Object.keys(newState) as (keyof S)[];\n keys.forEach((prop) => void console.log(prop, ':', getStr(newState[prop])));\n logger.groupEnd();\n },\n destroy: null,\n effects: (action, oldState, newState, loading) => {\n const args: any[] = action.context?.args;\n\n const params: string[] = [storeName, action.name.toString()];\n\n if (action.isAsync) {\n if (action.type === 'preEffects') {\n params.push(loading ? 'START' : 'CANCELLED');\n } else if (action.type === 'effects') {\n params.push('DONE');\n } else {\n params.push('FAILED');\n }\n }\n\n if (newState == null && (!args || Object.keys(args).length === 0)) {\n console.log(...params);\n } else {\n console.group(...params);\n }\n\n if (args && Object.keys(args).length > 0) {\n console.group('Arguments');\n args.forEach((arg) => void console.log(arg, ':', getStr(arg)));\n console.groupEnd();\n }\n\n if (newState != null) {\n console.groupCollapsed('Before');\n if (oldState == null) {\n console.log('was null');\n } else {\n const keys = Object.keys(oldState) as (keyof S)[];\n keys.forEach((prop) => void console.log(prop, ':', getStr(oldState[prop])));\n }\n console.groupEnd();\n\n console.groupCollapsed('After');\n if (newState == null) {\n console.log('was null');\n } else {\n const keys = Object.keys(newState) as (keyof S)[];\n keys.forEach((prop) => void console.log(prop, ':', getStr(newState[prop])));\n }\n console.groupEnd();\n\n if (newState != null) {\n console.group('Diff');\n const diff = buildDiff(oldState, newState);\n Object.keys(diff).forEach((prop) => console.log(prop, ':', diff[prop]));\n console.groupEnd();\n }\n }\n //\n console.groupEnd();\n\n return null;\n },\n };\n return middleware;\n }\n\n const middleware = getNoopMiddleware<S, A, P>();\n return middleware;\n };\n}\n\n// ------------------------------\n//\n// Optimistic\n//\n// ------------------------------\n\ntype ActionHistory<S, A> = {\n actionName: keyof A;\n promiseId: string;\n effectType: EffectsType;\n ctx: any;\n // FIXME CTX ?\n beforeEffectState: S;\n};\n\ntype OptimisticActionsMap = {\n [name: string]: any;\n};\n\ntype OptimisticData<S, A> = {\n /** History of effects */\n history: ActionHistory<S, A>[];\n /** Map of ongoing optimistic actions */\n optimisticActions: OptimisticActionsMap;\n /** Whether or not record all effects */\n shouldRecordHistory: boolean;\n};\n\nexport function optimisticActions<S, A extends DecoratedActions, P>(\n cloneFunc?: CloneFunction\n): MiddlewareFactory<S, A, P> {\n function getMiddleWare() {\n let storeContext: MiddlewareStoreContext<S, A, P> = null;\n\n const optimisticData: OptimisticData<S, A> = {\n history: null,\n optimisticActions: {},\n shouldRecordHistory: false,\n };\n\n const clone = (obj: any) => {\n const f = cloneFunc || globalConfig.clone;\n return f(obj);\n };\n\n const getActionId = (name: keyof A, promiseId: string) => {\n return `${name}_${promiseId}`;\n };\n\n /**\n * Adds an action to the action history (only when at least one optimistic action is ongoing).\n * @param actionName The action name\n * @param reducer The reducer name\n * @param args The arguments of the action (will be cloned)\n * @param beforeState state before the optimistic action\n */\n function pushActionToHistory(actionName: keyof A, effectType: EffectsType, ctx: any, beforeState: S = null): void {\n const { shouldRecordHistory } = optimisticData;\n const { history } = optimisticData;\n\n if (shouldRecordHistory) {\n if (history === null) {\n optimisticData.history = [];\n }\n\n const clonedCtx = clone(ctx);\n delete clonedCtx.state;\n delete clonedCtx.s;\n delete clonedCtx.abortSignal;\n // error clone issue\n clonedCtx.error = ctx.err;\n clonedCtx.err = ctx.err;\n\n const newEntry: ActionHistory<S, A> = {\n effectType,\n actionName,\n promiseId: ctx.promiseId,\n // fixme remove actions etc etc\n ctx: clonedCtx,\n beforeEffectState: beforeState ? clone(beforeState) : null,\n };\n\n optimisticData.history.push(newEntry);\n }\n }\n\n /**\n * Undo the optimistic action.\n * Strategy:\n * - Get the state before the optimistic reducer\n * - Replay all actions that occured after the optimistic action.\n * @param actionName The action name.\n */\n function undoOptimisticAction(actionName: keyof A, promiseId: string) {\n const { history } = optimisticData;\n\n // find the optimistic action in the history\n const index = history.findIndex(\n (a) => a.effectType === 'optimisticEffects' && a.actionName === actionName && a.promiseId === promiseId\n );\n\n // find the state at the time of the optimistic action.\n let state = history[index].beforeEffectState;\n\n // +1 to skip undo action\n for (let i = index + 1; i < history.length; i++) {\n const action = history[i];\n\n // This is an optimistic action, update restore state\n if (action.beforeEffectState) {\n action.beforeEffectState = state;\n }\n\n const ctx = {\n ...action.ctx,\n state,\n s: state,\n };\n\n if (action.actionName === 'onPropsChange') {\n const onPropsChanges = Array.isArray(storeContext.options.onPropsChange)\n ? storeContext.options.onPropsChange\n : [storeContext.options.onPropsChange];\n state = (onPropsChanges[ctx.index].effects as any)(ctx);\n } else if (isSimpleSyncAction(storeContext.actions[action.actionName])) {\n state = (storeContext.actions[action.actionName] as any)(ctx);\n } else {\n state = (storeContext.actions[action.actionName] as any)[action.effectType](ctx);\n }\n }\n\n // clean up\n cleanHistoryAfterOptimistAction(actionName, promiseId, index);\n\n return state;\n }\n\n function cleanHistoryAfterOptimistAction(\n actionName: keyof A,\n promiseId: string,\n indexInHistory: number = undefined\n ): void {\n const { optimisticActions, history } = optimisticData;\n\n const actionId = getActionId(actionName, promiseId);\n\n delete optimisticActions[actionId];\n\n const optiStateKeys = Object.keys(optimisticActions) as (keyof A)[];\n\n if (optiStateKeys.length === 0) {\n optimisticData.history = null;\n optimisticData.shouldRecordHistory = false;\n } else {\n const index =\n indexInHistory === undefined\n ? history.findIndex((a) => getActionId(a.actionName, a.promiseId) === actionId)\n : indexInHistory;\n\n if (index === 0) {\n // this was the first optimist action, so find the next one\n const nextOptimisticIndex = history.slice(1).findIndex((a) => a.beforeEffectState != null) + 1;\n\n // forget actions before the first optimist action in the history\n history.splice(0, nextOptimisticIndex);\n } else if (indexInHistory === undefined) {\n // success use case.\n // this was not the first optimist action, but can forget the saved state.\n // it becomes an asynchronous action.\n history[index].beforeEffectState = null;\n }\n }\n }\n\n // FIXME test destroy + init\n const middleware: Middleware<S, A, P> = {\n init(ctx) {\n storeContext = ctx;\n },\n destroy() {\n storeContext = null;\n optimisticData.history = null;\n optimisticData.optimisticActions = {};\n optimisticData.shouldRecordHistory = false;\n },\n effects({ name, type, context, isAsync }, oldState, newState, loading) {\n // add effect to the history if needed\n\n if (\n (newState != null && isSimpleSyncAction(storeContext.actions[name])) ||\n name === 'onPropsChange' ||\n (storeContext.actions[name] as any)[type] != null\n ) {\n pushActionToHistory(name, type, context, null);\n }\n\n if (isAsync) {\n // can cast\n const action = (storeContext.actions[name] as any) as AsyncAction<S, any, any, A, P>;\n\n // promise is sent and action is optimistic\n if (loading && action.optimisticEffects != null && type === 'preEffects') {\n optimisticData.shouldRecordHistory = true;\n optimisticData.optimisticActions[getActionId(name, context.promiseId)] = true;\n const state = newState || oldState;\n pushActionToHistory(name, 'optimisticEffects', context, state);\n return {\n loading: false,\n state: action.optimisticEffects({\n ...(context as any),\n state,\n s: state,\n }),\n };\n }\n // The promise was successful\n if (action.optimisticEffects != null && type === 'effects') {\n cleanHistoryAfterOptimistAction(name, context.promiseId);\n return {\n loading,\n state: newState,\n };\n }\n\n // The promise failed\n if (action.optimisticEffects != null && type === 'errorEffects') {\n const state = undoOptimisticAction(name, context.promiseId);\n return {\n state,\n loading,\n };\n }\n }\n\n // else no-op\n return null;\n },\n };\n return middleware;\n }\n return getMiddleWare;\n}\n\nexport function devtools<S, A extends DecoratedActions, P>(): MiddlewareFactory<S, A, P> {\n const getMiddleware = () => {\n let extension: any;\n try {\n extension = (window as any).__REDUX_DEVTOOLS_EXTENSION__ || (window as any).top.__REDUX_DEVTOOLS_EXTENSION__;\n } catch {}\n\n if (!extension) {\n return getNoopMiddleware<S, A, P>();\n }\n\n let devtools: any;\n let unsubscribe: () => void;\n\n const middleware: Middleware<S, A, P> = {\n init(storeContext) {\n devtools = extension.connect({ name: storeContext.options?.name ?? 'StateDecorator' });\n devtools.init(storeContext.state);\n let savedState: S = null;\n const initialState: S = storeContext.state;\n\n unsubscribe = devtools.subscribe((message: any) => {\n if (message.type === 'DISPATCH' && message.state && message.payload?.type !== 'ROLLBACK') {\n const newState = JSON.parse(message.state);\n storeContext.setState(newState);\n } else if (message.payload?.type === 'COMMIT') {\n savedState = storeContext.state;\n } else if (message.payload?.type === 'ROLLBACK') {\n if (savedState != null) {\n storeContext.setState(savedState);\n }\n } else if (message.payload?.type === 'RESET') {\n storeContext.setState(initialState);\n }\n });\n },\n\n effects(ctx, oldState, newState) {\n if (newState != null) {\n const cleanCtx: any = {\n ...ctx.context,\n };\n\n delete cleanCtx.a;\n delete cleanCtx.s;\n delete cleanCtx.p;\n delete cleanCtx.res;\n delete cleanCtx.err;\n delete cleanCtx.ds;\n\n devtools.send(\n {\n type: `${ctx.name} ${ctx.type}`,\n args: cleanCtx.args,\n context: cleanCtx,\n },\n newState\n );\n }\n\n return null; // no op on state\n },\n\n destroy() {\n unsubscribe();\n devtools = null;\n },\n };\n\n return middleware;\n };\n\n return getMiddleware;\n}\n"],"names":["module","obj","key","value","Object","defineProperty","enumerable","configurable","writable","exports","_typeof","Symbol","iterator","constructor","prototype","isArray","Array","keyList","keys","hasProp","hasOwnProperty","equal","a","b","i","length","arrA","arrB","dateA","Date","dateB","getTime","regexpA","RegExp","regexpB","toString","call","arr","len","arr2","arrayLikeToArray","iter","from","o","minLen","n","slice","name","test","TypeError","arrayWithoutHoles","iterableToArray","unsupportedIterableToArray","nonIterableSpread","ConflictPolicy","_arr","_n","_d","_e","undefined","_s","_i","next","done","push","err","arrayWithHoles","iterableToArrayLimit","nonIterableRest","asyncGeneratorStep","gen","resolve","reject","_next","_throw","arg","info","error","Promise","then","fn","self","this","args","arguments","apply","runtime","Op","hasOwn","$Symbol","iteratorSymbol","asyncIteratorSymbol","asyncIterator","toStringTagSymbol","toStringTag","define","wrap","innerFn","outerFn","tryLocsList","protoGenerator","Generator","generator","create","context","Context","_invoke","state","GenStateSuspendedStart","method","GenStateExecuting","Error","GenStateCompleted","doneResult","delegate","delegateResult","maybeInvokeDelegate","ContinueSentinel","sent","_sent","dispatchException","abrupt","record","tryCatch","type","GenStateSuspendedYield","makeInvokeMethod","GeneratorFunction","GeneratorFunctionPrototype","IteratorPrototype","getProto","getPrototypeOf","NativeIteratorPrototype","values","Gp","defineIteratorMethods","forEach","AsyncIterator","PromiseImpl","invoke","result","__await","unwrapped","previousPromise","callInvokeWithMethodAndArg","resultName","nextLoc","pushTryEntry","locs","entry","tryLoc","catchLoc","finallyLoc","afterLoc","tryEntries","resetTryEntry","completion","reset","iterable","iteratorMethod","isNaN","displayName","isGeneratorFunction","genFun","ctor","mark","setPrototypeOf","__proto__","awrap","async","object","reverse","pop","skipTempReset","prev","charAt","stop","rootRecord","rval","exception","handle","loc","caught","hasCatch","hasFinally","finallyEntry","complete","finish","catch","thrown","delegateYield","regeneratorRuntime","accidentalStrictMode","Function","globalConfig","clone","src","JSON","parse","stringify","comparator","objA","objB","is","keysA","asyncErrorHandler","retryOnErrorFunction","notifySuccess","notifyError","notifyWarning","getErrorMessage","defaultMiddlewares","isSimpleSyncAction","action","extension","devtools","unsubscribe","window","__REDUX_DEVTOOLS_EXTENSION__","top","init","storeContext","connect","options","_storeContext$options6","savedState","initialState","subscribe","message","payload","newState","setState","effects","ctx","oldState","cleanCtx","s","p","res","ds","send","destroy","logger","console","storeName","process","env","NODE_ENV","computeDiffPropValue","oldValue","newValue","addedValues","filter","find","isEqual","removedValues","added","removed","getStr","v","_storeContext$options4","group","prop","log","groupEnd","loading","_action$context","params","isAsync","groupCollapsed","diff","k","buildDiff","f","_storeContext$options2","cloneFunc","optimisticData","history","optimisticActions","shouldRecordHistory","getActionId","promiseId","pushActionToHistory","actionName","effectType","beforeState","clonedCtx","abortSignal","newEntry","beforeEffectState","cleanHistoryAfterOptimistAction","indexInHistory","actionId","optiStateKeys","index","findIndex","nextOptimisticIndex","splice","actions","optimisticEffects","onPropsChange","und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AAmBS,EAAa6E,QAAQrF,EAAOsE,aAC/C9D,EAAa6E,QAAQrF,EAAOsE,YAAoBlD,GAEhDZ,EAAa6E,QAAQrF,EAAOsE,YAAoBtE,EAAOuE,YAAYnD,UAKhFyD,EAAgCP,EAAYF,EAAWa,GAEhD3L,EA4FakM,CAAqB9P,EAAMyD,EAAQiL,WAG/ChB,QAAAA,UAMC"}
1
+ {"version":3,"file":"middlewares.js","sources":["../node_modules/@babel/runtime/helpers/defineProperty.js","../node_modules/@babel/runtime/helpers/typeof.js","../node_modules/fast-deep-equal/index.js","../node_modules/@babel/runtime/helpers/arrayLikeToArray.js","../node_modules/@babel/runtime/helpers/arrayWithoutHoles.js","../node_modules/@babel/runtime/helpers/iterableToArray.js","../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js","../node_modules/@babel/runtime/helpers/nonIterableSpread.js","../node_modules/@babel/runtime/helpers/toConsumableArray.js","../src/types.ts","../node_modules/@babel/runtime/helpers/arrayWithHoles.js","../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js","../node_modules/@babel/runtime/helpers/nonIterableRest.js","../node_modules/@babel/runtime/helpers/slicedToArray.js","../node_modules/@babel/runtime/helpers/asyncToGenerator.js","../node_modules/regenerator-runtime/runtime.js","../src/impl.ts","../src/shallow.ts","../src/middlewares.ts"],"sourcesContent":["function _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n}\n\nmodule.exports = _defineProperty;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","function _typeof(obj) {\n \"@babel/helpers - typeof\";\n\n if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n module.exports = _typeof = function _typeof(obj) {\n return typeof obj;\n };\n\n module.exports[\"default\"] = module.exports, module.exports.__esModule = true;\n } else {\n module.exports = _typeof = function _typeof(obj) {\n return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n };\n\n module.exports[\"default\"] = module.exports, module.exports.__esModule = true;\n }\n\n return _typeof(obj);\n}\n\nmodule.exports = _typeof;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","'use strict';\n\nvar isArray = Array.isArray;\nvar keyList = Object.keys;\nvar hasProp = Object.prototype.hasOwnProperty;\n\nmodule.exports = function equal(a, b) {\n if (a === b) return true;\n\n if (a && b && typeof a == 'object' && typeof b == 'object') {\n var arrA = isArray(a)\n , arrB = isArray(b)\n , i\n , length\n , key;\n\n if (arrA && arrB) {\n length = a.length;\n if (length != b.length) return false;\n for (i = length; i-- !== 0;)\n if (!equal(a[i], b[i])) return false;\n return true;\n }\n\n if (arrA != arrB) return false;\n\n var dateA = a instanceof Date\n , dateB = b instanceof Date;\n if (dateA != dateB) return false;\n if (dateA && dateB) return a.getTime() == b.getTime();\n\n var regexpA = a instanceof RegExp\n , regexpB = b instanceof RegExp;\n if (regexpA != regexpB) return false;\n if (regexpA && regexpB) return a.toString() == b.toString();\n\n var keys = keyList(a);\n length = keys.length;\n\n if (length !== keyList(b).length)\n return false;\n\n for (i = length; i-- !== 0;)\n if (!hasProp.call(b, keys[i])) return false;\n\n for (i = length; i-- !== 0;) {\n key = keys[i];\n if (!equal(a[key], b[key])) return false;\n }\n\n return true;\n }\n\n return a!==a && b!==b;\n};\n","function _arrayLikeToArray(arr, len) {\n if (len == null || len > arr.length) len = arr.length;\n\n for (var i = 0, arr2 = new Array(len); i < len; i++) {\n arr2[i] = arr[i];\n }\n\n return arr2;\n}\n\nmodule.exports = _arrayLikeToArray;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","var arrayLikeToArray = require(\"./arrayLikeToArray.js\");\n\nfunction _arrayWithoutHoles(arr) {\n if (Array.isArray(arr)) return arrayLikeToArray(arr);\n}\n\nmodule.exports = _arrayWithoutHoles;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","function _iterableToArray(iter) {\n if (typeof Symbol !== \"undefined\" && Symbol.iterator in Object(iter)) return Array.from(iter);\n}\n\nmodule.exports = _iterableToArray;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","var arrayLikeToArray = require(\"./arrayLikeToArray.js\");\n\nfunction _unsupportedIterableToArray(o, minLen) {\n if (!o) return;\n if (typeof o === \"string\") return arrayLikeToArray(o, minLen);\n var n = Object.prototype.toString.call(o).slice(8, -1);\n if (n === \"Object\" && o.constructor) n = o.constructor.name;\n if (n === \"Map\" || n === \"Set\") return Array.from(o);\n if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen);\n}\n\nmodule.exports = _unsupportedIterableToArray;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","function _nonIterableSpread() {\n throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\n\nmodule.exports = _nonIterableSpread;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","var arrayWithoutHoles = require(\"./arrayWithoutHoles.js\");\n\nvar iterableToArray = require(\"./iterableToArray.js\");\n\nvar unsupportedIterableToArray = require(\"./unsupportedIterableToArray.js\");\n\nvar nonIterableSpread = require(\"./nonIterableSpread.js\");\n\nfunction _toConsumableArray(arr) {\n return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread();\n}\n\nmodule.exports = _toConsumableArray;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","/*\n * Copyright 2019 Globalsport SAS\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\nexport type PromiseResult<Type> = Type extends Promise<infer X> ? X : null;\n\nexport type NotifyFunc = (msg: string) => void;\n\nexport type PromiseIdMap = { [promiseId: string]: boolean };\n\nexport type LoadingMap<A> = { [pId in keyof A]?: boolean };\nexport type LoadingParallelMap<A> = { [P in keyof A]?: PromiseIdMap };\nexport type InternalLoadingMap<A> = LoadingParallelMap<A>;\n\nexport type LoadingProps<A> = {\n loading: boolean;\n loadingMap: LoadingMap<A>;\n loadingParallelMap: LoadingParallelMap<A>;\n};\n\n// https://github.com/Microsoft/TypeScript/issues/15300\nexport interface DecoratedActions {\n [name: string]: (...args: any[]) => Promise<any> | void;\n}\n\n/**\n * The State decorator can manage only one asynchronous action of same name at a time.\n * This enum is enumertaing all the policies in such case.\n */\nexport enum ConflictPolicy {\n /**\n * Reject the promise.\n */\n REJECT = 'reject',\n\n /**\n * Return a resolved promise with no result.\n */\n IGNORE = 'ignore',\n\n /**\n * Execute only the last call that conflicts after the one ongoing.\n */\n KEEP_LAST = 'keepLast',\n\n /**\n * Execute all calls one after another.\n */\n KEEP_ALL = 'keepAll',\n\n /**\n * Execute all calls one after another.\n * @see getPromiseId\n */\n PARALLEL = 'parallel',\n\n /**\n * Reuse the ongoing promise if any and if possible (same arguments). Only for GET requests!\n */\n REUSE = 'reuse',\n}\n\nexport type PromiseProvider<S, DS, F extends (...args: any[]) => any, A, P> = (\n ctx: GetPromiseInvocationContext<S, DS, F, P, A>\n) => ReturnType<F> | null;\n\n/**\n * Simple form of a synchronous action.\n */\nexport type SimpleSyncAction<S, F extends (...args: any[]) => any, P, DS, FxRes = S> = (\n ctx: InvocationContext<S, DS, F, P>\n) => FxRes | null;\n\nexport type SyncAction<S, F extends (...args: any[]) => any, A, P, DS, FxRes = S> = {\n /**\n * Function that update the state when the action is called.\n */\n effects?: (ctx: EffectsInvocationContext<S, DS, F, P>) => FxRes | null;\n\n /**\n * Debounces the action if this parameter is defined.\n */\n debounceTimeout?: number;\n\n /**\n * Debounces the action side effects if this parameter is defined.\n */\n debounceSideEffectsTimeout?: number;\n\n /**\n * Function that calls side effects, ie. effects that are not changing the state directly.\n */\n sideEffects?: (ctx: SideEffectsInvocationContext<S, DS, F, P, A>) => void;\n};\n\n/**\n * Try to abort an action, if the action is <code>abortable</code>.\n * @param actionName The action name\n * @param promiseId If the action conflict type is <code>ConflictType.PARALLEL</code>, the identifier of the promise.\n * @returns <code>true</code> if the action is abortable and an action is ongoing, <code>false</code> otherwise.\n */\nexport type AbortActionCallback<A> = (actionName: keyof A, promiseId?: string) => boolean;\n\nexport type GetErrorMessage<S, DS, F extends (...args: any[]) => any, P> = (\n ctx: ErrorMessageInvocationContext<S, DS, F, P>\n) => string;\n\nexport type ContextState<S> = {\n state: S;\n s: S;\n};\n\nexport type ContextDerivedStateState<DS> = {\n derived: DS;\n ds: DS;\n};\n\nexport type ContextBase<S, P> = ContextState<S> & {\n props: P;\n p: P;\n};\n\nexport type ContextWithDerived<S, DS, P> = ContextBase<S, P> & ContextDerivedStateState<DS>;\n\nexport type InvocationContextActions<A> = {\n actions: A;\n a: A;\n};\n\nexport type WarningNotifyFunc = {\n notifyWarning?: NotifyFunc;\n};\n\nexport type InvocationContext<S, DS, F extends (...args: any[]) => any, P> = ContextWithDerived<S, DS, P> & {\n args: Parameters<F>;\n promiseId: string;\n};\n\nexport type EffectsInvocationContext<S, DS, F extends (...args: any[]) => any, P> = InvocationContext<S, DS, F, P> & {\n result: PromiseResult<ReturnType<F>>;\n res: PromiseResult<ReturnType<F>>;\n};\n\nexport type GetPromiseInvocationContext<S, DS, F extends (...args: any[]) => any, P, A> = InvocationContextActions<A> &\n InvocationContext<S, DS, F, P> & {\n abortSignal: AbortSignal;\n };\n\nexport type ErrorEffectsInvocationContext<S, DS, F extends (...args: any[]) => any, P> = InvocationContext<\n S,\n DS,\n F,\n P\n> & {\n error: Error;\n err: Error;\n};\n\nexport type SuccessMessageInvocationContext<S, DS, F extends (...args: any[]) => any, P> = EffectsInvocationContext<\n S,\n DS,\n F,\n P\n>;\nexport type ErrorMessageInvocationContext<S, DS, F extends (...args: any[]) => any, P> = ErrorEffectsInvocationContext<\n S,\n DS,\n F,\n P\n>;\n\nexport type SideEffectsInvocationContext<S, DS, F extends (...args: any[]) => any, P, A> = EffectsInvocationContext<\n S,\n DS,\n F,\n P\n> &\n InvocationContextActions<A> &\n WarningNotifyFunc;\n\nexport type ErrorSideEffectsInvocationContext<\n S,\n DS,\n F extends (...args: any[]) => any,\n P,\n A\n> = ErrorEffectsInvocationContext<S, DS, F, P> & InvocationContextActions<A> & WarningNotifyFunc;\n\nexport type OnMountInvocationContext<S, A, P> = ContextBase<S, P> & InvocationContextActions<A>;\n\nexport type EffectsType = 'preEffects' | 'effects' | 'errorEffects' | 'optimisticEffects' | null;\n\nexport type MiddlewareActionContext<S, A, P> = {\n name: keyof A;\n type: EffectsType;\n isAsync: boolean;\n context: InvocationContext<S, any, any, P>;\n};\n\nexport type MiddlewareStoreContext<S, A extends DecoratedActions, P> = {\n actions: StoreActions<S, A, P, any, any>;\n state: S;\n setState: (s: S) => void;\n options: StoreOptions<S, A, P, any>;\n};\n\nexport type MiddlewareFactory<S, A extends DecoratedActions, P> = () => Middleware<S, A, P>;\n\n/**\n * A state change middleware.\n * Allow to listen and change a state change on the fly.\n */\nexport type Middleware<S, A extends DecoratedActions, P> = {\n /**\n * Initializes the middleware. Called when the store is initializing.\n */\n init: (storeContext: MiddlewareStoreContext<S, A, P>) => void;\n\n /**\n * Invoked on a state change has occurred and returns a new state or <code>null</code> if unchanged.\n */\n effects: (\n actionContext: MiddlewareActionContext<S, A, P>,\n oldState: S,\n newState: S,\n loading: boolean\n ) => null | {\n state: S;\n loading: boolean;\n };\n\n /**\n * Destroys the middleware. Called when the store is being destroyed.\n */\n destroy: () => void;\n};\n\nexport type AsyncActionBase<S, F extends (...args: any[]) => any, A, P, DS, FxRes = S> = {\n /**\n * This action can be aborted. An abortSignal will be injected to the <code>promise</code> / <code>promiseGet</code>.\n */\n abortable?: boolean;\n\n /**\n * A function that provides the success message to pass to the notifySuccess function passed as property to the StateDecorator.\n */\n getSuccessMessage?: (ctx: SuccessMessageInvocationContext<S, DS, F, P>) => string;\n\n /**\n * A function that provides the error message to pass to the notifyError function passed as property to the StateDecorator.\n */\n getErrorMessage?: GetErrorMessage<S, DS, F, P>;\n\n /**\n * If set, called with the result of the promise to update the current state.\n */\n effects?: (ctx: EffectsInvocationContext<S, DS, F, P>) => FxRes | null;\n\n /**\n * If set, called with the error of the promise to update the current state.\n */\n errorEffects?: (ctx: ErrorEffectsInvocationContext<S, DS, F, P>) => FxRes | null;\n\n /**\n * Whether reject the promise instead of handling it.\n */\n rejectPromiseOnError?: boolean;\n\n /**\n * Handle side effects when the request succeeded.\n * @param result The result of the request\n * @param newData The data after the reducer is applied\n * @param args The argument during the call of the request function\n * @param props The props passed to the state decorator\n * @param actions The actions available\n * @param notifyWarning If specified, a notify function to indicate that the action is a semi success (use successMessage / getSuccessMessage otherwise).\n */\n sideEffects?: (ctx: SideEffectsInvocationContext<S, DS, F, P, A>) => void;\n\n /**\n * Handle side effects when the request failed.\n * @param error The error of the request\n * @param args The argument during the call of the request function\n * @param props The props passed to the state decorator\n * @param actions The actions available\n * @param notifyWarning If specified, a notify function to indicate that the action is a semi failure (use errorMessage / getErrorMessage otherwise).\n */\n errorSideEffects?: (ctx: ErrorSideEffectsInvocationContext<S, DS, F, P, A>) => void;\n\n /**\n * Retrieve the state to set as current data before the promise is resolved.\n * If the there's no reducer, this data will be used after the promise is done.\n */\n preEffects?: (ctx: InvocationContext<S, DS, F, P>) => FxRes | null;\n\n /**\n * Retrieve the state to set as current data before the promise is resolved.\n * If the there's no reducer, this data will be used after the promise is done.\n */\n optimisticEffects?: (ctx: InvocationContext<S, DS, F, P>) => FxRes | null;\n\n /**\n * Policy to apply when a call to an asynchronous action is done but a previous call is still not resolved.\n */\n conflictPolicy?: ConflictPolicy;\n\n /**\n * Get an identifier for an action call. Used only when conflictPolicy is ConflictPolicy.PARALLEL.\n * This information will be available in loadingMap. loadingMap[actionName] will be an array of promise identifiers.\n */\n getPromiseId?: (...args: Parameters<F>) => string;\n\n /**\n * Number of retries in case of error (failed to fetch).\n * Do not use this if you are creating objects...\n * Default value is 0 (no retry).\n */\n retryCount?: number;\n\n /**\n * Seed of delay between each retry in milliseconds.\n * The applied delay is retryDelaySeed * retry count.\n * Default value is 1000 (1 second).\n */\n retryDelaySeed?: number;\n\n /**\n * Function to test if the error will trigger an action retry or will fail directly.\n */\n isTriggerRetryError?: (e: Error) => boolean;\n};\n\nexport type AsyncActionPromise<S, F extends (...args: any[]) => any, A, P, DS = {}, FxRes = S> = AsyncActionBase<\n S,\n F,\n A,\n P,\n DS,\n FxRes\n> & {\n /**\n * The request, returns a promise\n */\n getPromise: PromiseProvider<S, DS, F, A, P>;\n};\n\nexport type AsyncActionPromiseGet<S, F extends (...args: any[]) => any, A, P, DS, FxRes = S> = AsyncActionBase<\n S,\n F,\n A,\n P,\n DS,\n FxRes\n> & {\n /**\n * The request, returns a promise that is a GET request.\n * A shortcut to set:\n * - retryCount: 3\n * - conflictPolicy: ConflictPolicy.REUSE\n */\n getGetPromise: PromiseProvider<S, DS, F, A, P>;\n};\n\nexport type AsyncAction<S, F extends (...args: any[]) => any, A, P, DS = {}, FxRes = S> =\n | AsyncActionPromise<S, F, A, P, DS, FxRes>\n | AsyncActionPromiseGet<S, F, A, P, DS, FxRes>;\n\nexport type StoreAction<S, F extends (...args: any[]) => any, A, P, DS = {}, FxRes = S> =\n | AsyncAction<S, F, A, P, DS, FxRes>\n | SimpleSyncAction<S, F, P, DS, FxRes>\n | SyncAction<S, F, A, P, DS, FxRes>;\n\n/**\n * S: The type of the state\n * A: The type of the actions to pass to the children (used to check keys only).\n */\nexport type StoreActions<S, A extends DecoratedActions, P = {}, DS = {}, FxRes = S> = {\n [Prop in keyof A]: StoreAction<S, A[Prop], A, P, DS, FxRes>;\n};\n\nexport type OnPropsChangeEffectsContext<S, DS, P> = ContextWithDerived<S, DS, P> & {\n indices: number[];\n index: number;\n isInit: boolean;\n};\n\nexport type OnPropsChangeSideEffectsContext<S, P, A, DS = {}> = OnPropsChangeEffectsContext<S, DS, P> & {\n actions: A;\n a: A;\n};\n\ntype DerivedStateOption<S, P, DS> = {\n [k in keyof DS]: {\n getDeps: (ctx: ContextBase<S, P>) => any[];\n get: (ctx: ContextBase<S, P>) => DS[k];\n };\n};\n\nexport type OnPropsChangeOptions<S, DS, A, P> = {\n onMount?: boolean;\n getDeps: (p: P) => any[];\n effects?: (ctx: OnPropsChangeEffectsContext<S, DS, P>) => S;\n sideEffects?: (ctx: OnPropsChangeSideEffectsContext<S, P, A>) => void;\n};\n\nexport type StoreOptions<S, A, P = {}, DS = {}> = {\n /**\n * The state decorator name. Use in debug traces to identify the useStateDecorator instance.\n */\n name?: string;\n\n /**\n * List of action names that are marked as loading at initial time.\n * If you must start your initial actions in a useSideEffect, a render is done before\n * first actions can be trigerred, some actions can be marked as loading at initial time.\n */\n initialActionsMarkedLoading?: (keyof A)[];\n\n /**\n * One or several configurations of inbound properties change managements.\n */\n onPropsChange?: OnPropsChangeOptions<S, DS, A, P> | OnPropsChangeOptions<S, DS, A, P>[];\n\n /**\n * The callback function called if an asynchronous function succeeded and a success messsage is defined.\n */\n notifySuccess?: NotifyFunc;\n\n /**\n * The callback function called if an asynchronous function fails and an error messsage is defined.\n */\n notifyError?: NotifyFunc;\n\n /**\n * The callback function injected in onDone and onFail of asynchronous functions to notify a semi success / failed request.\n */\n notifyWarning?: NotifyFunc;\n\n /**\n * Initial actions.\n */\n onMount?: (ctx: OnMountInvocationContext<S, A, P>) => void;\n\n /**\n * Callback on store destruction.\n */\n onUnmount?: (ctx: OnMountInvocationContext<S, A, P>) => Promise<any> | void;\n\n /**\n * Compute derived state\n */\n derivedState?: DerivedStateOption<S, P, DS>;\n};\n","function _arrayWithHoles(arr) {\n if (Array.isArray(arr)) return arr;\n}\n\nmodule.exports = _arrayWithHoles;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","function _iterableToArrayLimit(arr, i) {\n if (typeof Symbol === \"undefined\" || !(Symbol.iterator in Object(arr))) return;\n var _arr = [];\n var _n = true;\n var _d = false;\n var _e = undefined;\n\n try {\n for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {\n _arr.push(_s.value);\n\n if (i && _arr.length === i) break;\n }\n } catch (err) {\n _d = true;\n _e = err;\n } finally {\n try {\n if (!_n && _i[\"return\"] != null) _i[\"return\"]();\n } finally {\n if (_d) throw _e;\n }\n }\n\n return _arr;\n}\n\nmodule.exports = _iterableToArrayLimit;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","function _nonIterableRest() {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\n\nmodule.exports = _nonIterableRest;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","var arrayWithHoles = require(\"./arrayWithHoles.js\");\n\nvar iterableToArrayLimit = require(\"./iterableToArrayLimit.js\");\n\nvar unsupportedIterableToArray = require(\"./unsupportedIterableToArray.js\");\n\nvar nonIterableRest = require(\"./nonIterableRest.js\");\n\nfunction _slicedToArray(arr, i) {\n return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest();\n}\n\nmodule.exports = _slicedToArray;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {\n try {\n var info = gen[key](arg);\n var value = info.value;\n } catch (error) {\n reject(error);\n return;\n }\n\n if (info.done) {\n resolve(value);\n } else {\n Promise.resolve(value).then(_next, _throw);\n }\n}\n\nfunction _asyncToGenerator(fn) {\n return function () {\n var self = this,\n args = arguments;\n return new Promise(function (resolve, reject) {\n var gen = fn.apply(self, args);\n\n function _next(value) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value);\n }\n\n function _throw(err) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err);\n }\n\n _next(undefined);\n });\n };\n}\n\nmodule.exports = _asyncToGenerator;\nmodule.exports[\"default\"] = module.exports, module.exports.__esModule = true;","/**\n * Copyright (c) 2014-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nvar runtime = (function (exports) {\n \"use strict\";\n\n var Op = Object.prototype;\n var hasOwn = Op.hasOwnProperty;\n var undefined; // More compressible than void 0.\n var $Symbol = typeof Symbol === \"function\" ? Symbol : {};\n var iteratorSymbol = $Symbol.iterator || \"@@iterator\";\n var asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\";\n var toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\";\n\n function define(obj, key, value) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n return obj[key];\n }\n try {\n // IE 8 has a broken Object.defineProperty that only works on DOM objects.\n define({}, \"\");\n } catch (err) {\n define = function(obj, key, value) {\n return obj[key] = value;\n };\n }\n\n function wrap(innerFn, outerFn, self, tryLocsList) {\n // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.\n var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;\n var generator = Object.create(protoGenerator.prototype);\n var context = new Context(tryLocsList || []);\n\n // The ._invoke method unifies the implementations of the .next,\n // .throw, and .return methods.\n generator._invoke = makeInvokeMethod(innerFn, self, context);\n\n return generator;\n }\n exports.wrap = wrap;\n\n // Try/catch helper to minimize deoptimizations. Returns a completion\n // record like context.tryEntries[i].completion. This interface could\n // have been (and was previously) designed to take a closure to be\n // invoked without arguments, but in all the cases we care about we\n // already have an existing method we want to call, so there's no need\n // to create a new function object. We can even get away with assuming\n // the method takes exactly one argument, since that happens to be true\n // in every case, so we don't have to touch the arguments object. The\n // only additional allocation required is the completion record, which\n // has a stable shape and so hopefully should be cheap to allocate.\n function tryCatch(fn, obj, arg) {\n try {\n return { type: \"normal\", arg: fn.call(obj, arg) };\n } catch (err) {\n return { type: \"throw\", arg: err };\n }\n }\n\n var GenStateSuspendedStart = \"suspendedStart\";\n var GenStateSuspendedYield = \"suspendedYield\";\n var GenStateExecuting = \"executing\";\n var GenStateCompleted = \"completed\";\n\n // Returning this object from the innerFn has the same effect as\n // breaking out of the dispatch switch statement.\n var ContinueSentinel = {};\n\n // Dummy constructor functions that we use as the .constructor and\n // .constructor.prototype properties for functions that return Generator\n // objects. For full spec compliance, you may wish to configure your\n // minifier not to mangle the names of these two functions.\n function Generator() {}\n function GeneratorFunction() {}\n function GeneratorFunctionPrototype() {}\n\n // This is a polyfill for %IteratorPrototype% for environments that\n // don't natively support it.\n var IteratorPrototype = {};\n IteratorPrototype[iteratorSymbol] = function () {\n return this;\n };\n\n var getProto = Object.getPrototypeOf;\n var NativeIteratorPrototype = getProto && getProto(getProto(values([])));\n if (NativeIteratorPrototype &&\n NativeIteratorPrototype !== Op &&\n hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {\n // This environment has a native %IteratorPrototype%; use it instead\n // of the polyfill.\n IteratorPrototype = NativeIteratorPrototype;\n }\n\n var Gp = GeneratorFunctionPrototype.prototype =\n Generator.prototype = Object.create(IteratorPrototype);\n GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;\n GeneratorFunctionPrototype.constructor = GeneratorFunction;\n GeneratorFunction.displayName = define(\n GeneratorFunctionPrototype,\n toStringTagSymbol,\n \"GeneratorFunction\"\n );\n\n // Helper for defining the .next, .throw, and .return methods of the\n // Iterator interface in terms of a single ._invoke method.\n function defineIteratorMethods(prototype) {\n [\"next\", \"throw\", \"return\"].forEach(function(method) {\n define(prototype, method, function(arg) {\n return this._invoke(method, arg);\n });\n });\n }\n\n exports.isGeneratorFunction = function(genFun) {\n var ctor = typeof genFun === \"function\" && genFun.constructor;\n return ctor\n ? ctor === GeneratorFunction ||\n // For the native GeneratorFunction constructor, the best we can\n // do is to check its .name property.\n (ctor.displayName || ctor.name) === \"GeneratorFunction\"\n : false;\n };\n\n exports.mark = function(genFun) {\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);\n } else {\n genFun.__proto__ = GeneratorFunctionPrototype;\n define(genFun, toStringTagSymbol, \"GeneratorFunction\");\n }\n genFun.prototype = Object.create(Gp);\n return genFun;\n };\n\n // Within the body of any async function, `await x` is transformed to\n // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test\n // `hasOwn.call(value, \"__await\")` to determine if the yielded value is\n // meant to be awaited.\n exports.awrap = function(arg) {\n return { __await: arg };\n };\n\n function AsyncIterator(generator, PromiseImpl) {\n function invoke(method, arg, resolve, reject) {\n var record = tryCatch(generator[method], generator, arg);\n if (record.type === \"throw\") {\n reject(record.arg);\n } else {\n var result = record.arg;\n var value = result.value;\n if (value &&\n typeof value === \"object\" &&\n hasOwn.call(value, \"__await\")) {\n return PromiseImpl.resolve(value.__await).then(function(value) {\n invoke(\"next\", value, resolve, reject);\n }, function(err) {\n invoke(\"throw\", err, resolve, reject);\n });\n }\n\n return PromiseImpl.resolve(value).then(function(unwrapped) {\n // When a yielded Promise is resolved, its final value becomes\n // the .value of the Promise<{value,done}> result for the\n // current iteration.\n result.value = unwrapped;\n resolve(result);\n }, function(error) {\n // If a rejected Promise was yielded, throw the rejection back\n // into the async generator function so it can be handled there.\n return invoke(\"throw\", error, resolve, reject);\n });\n }\n }\n\n var previousPromise;\n\n function enqueue(method, arg) {\n function callInvokeWithMethodAndArg() {\n return new PromiseImpl(function(resolve, reject) {\n invoke(method, arg, resolve, reject);\n });\n }\n\n return previousPromise =\n // If enqueue has been called before, then we want to wait until\n // all previous Promises have been resolved before calling invoke,\n // so that results are always delivered in the correct order. If\n // enqueue has not been called before, then it is important to\n // call invoke immediately, without waiting on a callback to fire,\n // so that the async generator function has the opportunity to do\n // any necessary setup in a predictable way. This predictability\n // is why the Promise constructor synchronously invokes its\n // executor callback, and why async functions synchronously\n // execute code before the first await. Since we implement simple\n // async functions in terms of async generators, it is especially\n // important to get this right, even though it requires care.\n previousPromise ? previousPromise.then(\n callInvokeWithMethodAndArg,\n // Avoid propagating failures to Promises returned by later\n // invocations of the iterator.\n callInvokeWithMethodAndArg\n ) : callInvokeWithMethodAndArg();\n }\n\n // Define the unified helper method that is used to implement .next,\n // .throw, and .return (see defineIteratorMethods).\n this._invoke = enqueue;\n }\n\n defineIteratorMethods(AsyncIterator.prototype);\n AsyncIterator.prototype[asyncIteratorSymbol] = function () {\n return this;\n };\n exports.AsyncIterator = AsyncIterator;\n\n // Note that simple async functions are implemented on top of\n // AsyncIterator objects; they just return a Promise for the value of\n // the final result produced by the iterator.\n exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {\n if (PromiseImpl === void 0) PromiseImpl = Promise;\n\n var iter = new AsyncIterator(\n wrap(innerFn, outerFn, self, tryLocsList),\n PromiseImpl\n );\n\n return exports.isGeneratorFunction(outerFn)\n ? iter // If outerFn is a generator, return the full iterator.\n : iter.next().then(function(result) {\n return result.done ? result.value : iter.next();\n });\n };\n\n function makeInvokeMethod(innerFn, self, context) {\n var state = GenStateSuspendedStart;\n\n return function invoke(method, arg) {\n if (state === GenStateExecuting) {\n throw new Error(\"Generator is already running\");\n }\n\n if (state === GenStateCompleted) {\n if (method === \"throw\") {\n throw arg;\n }\n\n // Be forgiving, per 25.3.3.3.3 of the spec:\n // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume\n return doneResult();\n }\n\n context.method = method;\n context.arg = arg;\n\n while (true) {\n var delegate = context.delegate;\n if (delegate) {\n var delegateResult = maybeInvokeDelegate(delegate, context);\n if (delegateResult) {\n if (delegateResult === ContinueSentinel) continue;\n return delegateResult;\n }\n }\n\n if (context.method === \"next\") {\n // Setting context._sent for legacy support of Babel's\n // function.sent implementation.\n context.sent = context._sent = context.arg;\n\n } else if (context.method === \"throw\") {\n if (state === GenStateSuspendedStart) {\n state = GenStateCompleted;\n throw context.arg;\n }\n\n context.dispatchException(context.arg);\n\n } else if (context.method === \"return\") {\n context.abrupt(\"return\", context.arg);\n }\n\n state = GenStateExecuting;\n\n var record = tryCatch(innerFn, self, context);\n if (record.type === \"normal\") {\n // If an exception is thrown from innerFn, we leave state ===\n // GenStateExecuting and loop back for another invocation.\n state = context.done\n ? GenStateCompleted\n : GenStateSuspendedYield;\n\n if (record.arg === ContinueSentinel) {\n continue;\n }\n\n return {\n value: record.arg,\n done: context.done\n };\n\n } else if (record.type === \"throw\") {\n state = GenStateCompleted;\n // Dispatch the exception by looping back around to the\n // context.dispatchException(context.arg) call above.\n context.method = \"throw\";\n context.arg = record.arg;\n }\n }\n };\n }\n\n // Call delegate.iterator[context.method](context.arg) and handle the\n // result, either by returning a { value, done } result from the\n // delegate iterator, or by modifying context.method and context.arg,\n // setting context.delegate to null, and returning the ContinueSentinel.\n function maybeInvokeDelegate(delegate, context) {\n var method = delegate.iterator[context.method];\n if (method === undefined) {\n // A .throw or .return when the delegate iterator has no .throw\n // method always terminates the yield* loop.\n context.delegate = null;\n\n if (context.method === \"throw\") {\n // Note: [\"return\"] must be used for ES3 parsing compatibility.\n if (delegate.iterator[\"return\"]) {\n // If the delegate iterator has a return method, give it a\n // chance to clean up.\n context.method = \"return\";\n context.arg = undefined;\n maybeInvokeDelegate(delegate, context);\n\n if (context.method === \"throw\") {\n // If maybeInvokeDelegate(context) changed context.method from\n // \"return\" to \"throw\", let that override the TypeError below.\n return ContinueSentinel;\n }\n }\n\n context.method = \"throw\";\n context.arg = new TypeError(\n \"The iterator does not provide a 'throw' method\");\n }\n\n return ContinueSentinel;\n }\n\n var record = tryCatch(method, delegate.iterator, context.arg);\n\n if (record.type === \"throw\") {\n context.method = \"throw\";\n context.arg = record.arg;\n context.delegate = null;\n return ContinueSentinel;\n }\n\n var info = record.arg;\n\n if (! info) {\n context.method = \"throw\";\n context.arg = new TypeError(\"iterator result is not an object\");\n context.delegate = null;\n return ContinueSentinel;\n }\n\n if (info.done) {\n // Assign the result of the finished delegate to the temporary\n // variable specified by delegate.resultName (see delegateYield).\n context[delegate.resultName] = info.value;\n\n // Resume execution at the desired location (see delegateYield).\n context.next = delegate.nextLoc;\n\n // If context.method was \"throw\" but the delegate handled the\n // exception, let the outer generator proceed normally. If\n // context.method was \"next\", forget context.arg since it has been\n // \"consumed\" by the delegate iterator. If context.method was\n // \"return\", allow the original .return call to continue in the\n // outer generator.\n if (context.method !== \"return\") {\n context.method = \"next\";\n context.arg = undefined;\n }\n\n } else {\n // Re-yield the result returned by the delegate method.\n return info;\n }\n\n // The delegate iterator is finished, so forget it and continue with\n // the outer generator.\n context.delegate = null;\n return ContinueSentinel;\n }\n\n // Define Generator.prototype.{next,throw,return} in terms of the\n // unified ._invoke helper method.\n defineIteratorMethods(Gp);\n\n define(Gp, toStringTagSymbol, \"Generator\");\n\n // A Generator should always return itself as the iterator object when the\n // @@iterator function is called on it. Some browsers' implementations of the\n // iterator prototype chain incorrectly implement this, causing the Generator\n // object to not be returned from this call. This ensures that doesn't happen.\n // See https://github.com/facebook/regenerator/issues/274 for more details.\n Gp[iteratorSymbol] = function() {\n return this;\n };\n\n Gp.toString = function() {\n return \"[object Generator]\";\n };\n\n function pushTryEntry(locs) {\n var entry = { tryLoc: locs[0] };\n\n if (1 in locs) {\n entry.catchLoc = locs[1];\n }\n\n if (2 in locs) {\n entry.finallyLoc = locs[2];\n entry.afterLoc = locs[3];\n }\n\n this.tryEntries.push(entry);\n }\n\n function resetTryEntry(entry) {\n var record = entry.completion || {};\n record.type = \"normal\";\n delete record.arg;\n entry.completion = record;\n }\n\n function Context(tryLocsList) {\n // The root entry object (effectively a try statement without a catch\n // or a finally block) gives us a place to store values thrown from\n // locations where there is no enclosing try statement.\n this.tryEntries = [{ tryLoc: \"root\" }];\n tryLocsList.forEach(pushTryEntry, this);\n this.reset(true);\n }\n\n exports.keys = function(object) {\n var keys = [];\n for (var key in object) {\n keys.push(key);\n }\n keys.reverse();\n\n // Rather than returning an object with a next method, we keep\n // things simple and return the next function itself.\n return function next() {\n while (keys.length) {\n var key = keys.pop();\n if (key in object) {\n next.value = key;\n next.done = false;\n return next;\n }\n }\n\n // To avoid creating an additional object, we just hang the .value\n // and .done properties off the next function object itself. This\n // also ensures that the minifier will not anonymize the function.\n next.done = true;\n return next;\n };\n };\n\n function values(iterable) {\n if (iterable) {\n var iteratorMethod = iterable[iteratorSymbol];\n if (iteratorMethod) {\n return iteratorMethod.call(iterable);\n }\n\n if (typeof iterable.next === \"function\") {\n return iterable;\n }\n\n if (!isNaN(iterable.length)) {\n var i = -1, next = function next() {\n while (++i < iterable.length) {\n if (hasOwn.call(iterable, i)) {\n next.value = iterable[i];\n next.done = false;\n return next;\n }\n }\n\n next.value = undefined;\n next.done = true;\n\n return next;\n };\n\n return next.next = next;\n }\n }\n\n // Return an iterator with no values.\n return { next: doneResult };\n }\n exports.values = values;\n\n function doneResult() {\n return { value: undefined, done: true };\n }\n\n Context.prototype = {\n constructor: Context,\n\n reset: function(skipTempReset) {\n this.prev = 0;\n this.next = 0;\n // Resetting context._sent for legacy support of Babel's\n // function.sent implementation.\n this.sent = this._sent = undefined;\n this.done = false;\n this.delegate = null;\n\n this.method = \"next\";\n this.arg = undefined;\n\n this.tryEntries.forEach(resetTryEntry);\n\n if (!skipTempReset) {\n for (var name in this) {\n // Not sure about the optimal order of these conditions:\n if (name.charAt(0) === \"t\" &&\n hasOwn.call(this, name) &&\n !isNaN(+name.slice(1))) {\n this[name] = undefined;\n }\n }\n }\n },\n\n stop: function() {\n this.done = true;\n\n var rootEntry = this.tryEntries[0];\n var rootRecord = rootEntry.completion;\n if (rootRecord.type === \"throw\") {\n throw rootRecord.arg;\n }\n\n return this.rval;\n },\n\n dispatchException: function(exception) {\n if (this.done) {\n throw exception;\n }\n\n var context = this;\n function handle(loc, caught) {\n record.type = \"throw\";\n record.arg = exception;\n context.next = loc;\n\n if (caught) {\n // If the dispatched exception was caught by a catch block,\n // then let that catch block handle the exception normally.\n context.method = \"next\";\n context.arg = undefined;\n }\n\n return !! caught;\n }\n\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n var record = entry.completion;\n\n if (entry.tryLoc === \"root\") {\n // Exception thrown outside of any try block that could handle\n // it, so set the completion value of the entire function to\n // throw the exception.\n return handle(\"end\");\n }\n\n if (entry.tryLoc <= this.prev) {\n var hasCatch = hasOwn.call(entry, \"catchLoc\");\n var hasFinally = hasOwn.call(entry, \"finallyLoc\");\n\n if (hasCatch && hasFinally) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n } else if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else if (hasCatch) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n }\n\n } else if (hasFinally) {\n if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else {\n throw new Error(\"try statement without catch or finally\");\n }\n }\n }\n },\n\n abrupt: function(type, arg) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc <= this.prev &&\n hasOwn.call(entry, \"finallyLoc\") &&\n this.prev < entry.finallyLoc) {\n var finallyEntry = entry;\n break;\n }\n }\n\n if (finallyEntry &&\n (type === \"break\" ||\n type === \"continue\") &&\n finallyEntry.tryLoc <= arg &&\n arg <= finallyEntry.finallyLoc) {\n // Ignore the finally entry if control is not jumping to a\n // location outside the try/catch block.\n finallyEntry = null;\n }\n\n var record = finallyEntry ? finallyEntry.completion : {};\n record.type = type;\n record.arg = arg;\n\n if (finallyEntry) {\n this.method = \"next\";\n this.next = finallyEntry.finallyLoc;\n return ContinueSentinel;\n }\n\n return this.complete(record);\n },\n\n complete: function(record, afterLoc) {\n if (record.type === \"throw\") {\n throw record.arg;\n }\n\n if (record.type === \"break\" ||\n record.type === \"continue\") {\n this.next = record.arg;\n } else if (record.type === \"return\") {\n this.rval = this.arg = record.arg;\n this.method = \"return\";\n this.next = \"end\";\n } else if (record.type === \"normal\" && afterLoc) {\n this.next = afterLoc;\n }\n\n return ContinueSentinel;\n },\n\n finish: function(finallyLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.finallyLoc === finallyLoc) {\n this.complete(entry.completion, entry.afterLoc);\n resetTryEntry(entry);\n return ContinueSentinel;\n }\n }\n },\n\n \"catch\": function(tryLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc === tryLoc) {\n var record = entry.completion;\n if (record.type === \"throw\") {\n var thrown = record.arg;\n resetTryEntry(entry);\n }\n return thrown;\n }\n }\n\n // The context.catch method must only be called with a location\n // argument that corresponds to a known catch block.\n throw new Error(\"illegal catch attempt\");\n },\n\n delegateYield: function(iterable, resultName, nextLoc) {\n this.delegate = {\n iterator: values(iterable),\n resultName: resultName,\n nextLoc: nextLoc\n };\n\n if (this.method === \"next\") {\n // Deliberately forget the last sent value so that we don't\n // accidentally pass it on to the delegate.\n this.arg = undefined;\n }\n\n return ContinueSentinel;\n }\n };\n\n // Regardless of whether this script is executing as a CommonJS module\n // or not, return the runtime object so that we can declare the variable\n // regeneratorRuntime in the outer scope, which allows this module to be\n // injected easily by `bin/regenerator --include-runtime script.js`.\n return exports;\n\n}(\n // If this script is executing as a CommonJS module, use module.exports\n // as the regeneratorRuntime namespace. Otherwise create a new empty\n // object. Either way, the resulting object will be used to initialize\n // the regeneratorRuntime variable at the top of this file.\n typeof module === \"object\" ? module.exports : {}\n));\n\ntry {\n regeneratorRuntime = runtime;\n} catch (accidentalStrictMode) {\n // This module should not be running in strict mode, so the above\n // assignment should always work unless something is misconfigured. Just\n // in case runtime.js accidentally runs in strict mode, we can escape\n // strict mode using a global Function call. This could conceivably fail\n // if a Content Security Policy forbids using Function, but in that case\n // the proper solution is to fix the accidental strict mode problem. If\n // you've misconfigured your bundler to force strict mode and applied a\n // CSP to forbid Function, and you're not willing to fix either of those\n // problems, please detail your unique predicament in a GitHub issue.\n Function(\"r\", \"regeneratorRuntime = r\")(runtime);\n}\n","/*\n * Copyright 2019 Globalsport SAS\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport shallow from './shallow';\nimport {\n AsyncAction,\n SimpleSyncAction,\n SyncAction,\n StoreAction,\n AsyncActionPromise,\n ConflictPolicy,\n AsyncActionPromiseGet,\n PromiseProvider,\n GetPromiseInvocationContext,\n DecoratedActions,\n InternalLoadingMap,\n StoreOptions,\n PromiseResult,\n InvocationContext,\n EffectsInvocationContext,\n InvocationContextActions,\n WarningNotifyFunc,\n ErrorEffectsInvocationContext,\n OnMountInvocationContext,\n OnPropsChangeEffectsContext,\n ContextState,\n Middleware,\n MiddlewareFactory,\n OnPropsChangeOptions,\n ContextWithDerived,\n} from './types';\n\nexport type SetStateFunc<S, A, P> = (\n newState: S,\n newLoadingMap: InternalLoadingMap<A>,\n actionName: keyof A | 'onPropsChange',\n actionType: 'preEffects' | 'effects' | 'errorEffects' | null, // FIXME\n isAsync: boolean,\n actionCtx: any,\n propsChanged: boolean,\n isInit?: boolean\n) => void;\n\n/** @internal */\nexport type PromiseMap<A> = {\n [name in keyof A]?: {\n [promiseId: string]: {\n promise: Promise<any>;\n refArgs: any[];\n abortController: AbortController;\n };\n };\n};\n\n/** @internal */\nexport type FutureActions = {\n args: any[];\n resolve: (...args: any[]) => void;\n reject: (...args: any[]) => void;\n timestamp?: number;\n};\n\n/** @internal */\nexport type ConflictActionsMap<A> = {\n [name in keyof A]?: FutureActions[];\n};\n\n/** @internal */\nexport type AsyncActionExecContext<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P> = {\n actionName: keyof A;\n action: AsyncActionPromise<S, F, A, P, DS>;\n stateRef: Ref<S>;\n derivedStateRef: Ref<DerivedState<DS>>;\n propsRef: Ref<P>;\n loadingMapRef: Ref<InternalLoadingMap<A>>;\n promisesRef: Ref<PromiseMap<A>>;\n conflictActionsRef: Ref<ConflictActionsMap<A>>;\n actionsRef: Ref<A>;\n initializedRef: Ref<boolean>;\n options: StoreOptions<S, A, P, any>;\n setState: SetStateFunc<S, A, P>;\n};\n\n/** @internal */\nexport type TimeoutMap<A> = {\n [name in keyof A]?: any;\n};\n\nexport type NotifyFunc = (msg: string) => void;\nexport type CloneFunction = <C>(obj: C) => C;\nexport type ComparatorFunction = <C>(obj1: C, Obj2: C) => boolean;\nexport type RetryOnErrorFunction = (error: any) => boolean;\nexport type AsyncErrorHandler = (\n error: any,\n isHandled: boolean,\n state: any,\n props: any,\n actionName: string,\n args: any[]\n) => void;\n\ntype DerivedStateMap<DS> = {\n [name in keyof DS]?: any[];\n};\n\n/** @internal */\nexport type DerivedState<DS> = {\n state: DS;\n deps: DerivedStateMap<DS>;\n};\n\n// =============================\n//\n// GLOBAL CONFIG\n//\n// =============================\n\n/**\n * Global configuration, shared with all stores.\n */\nexport type GlobalConfig = {\n /**\n * Clone function.\n * Used to clone state and props when managing optimistic reducer and conflicting actions.\n * Default implementation is a very basic algorithm using JSON.stringify. To clone complex stats,\n * use a custom implementation like lodash/cloneDeep.\n * @default JSON.stringify\n */\n clone: CloneFunction;\n\n /**\n * Compare to objets and returns if they are equal.\n * Used to comparent previous and current state slice.\n * @default shallow\n */\n comparator: ComparatorFunction;\n\n /**\n * Global callback function to handle asychronous actions rejected promise.\n */\n asyncErrorHandler: AsyncErrorHandler;\n\n /**\n * Tests if the error will trigger a retry of the action or will fail directly.\n * Default implementation is returning true for TypeError instances only.\n * @see AsynchActionBase#retryCount\n */\n retryOnErrorFunction: RetryOnErrorFunction;\n\n /**\n * Global notification function that will called when an asynchronous action succeeded,\n * if and only if, an error message is specified for this action using\n * <code>getErrorMessage</code>.\n * If another function is set in the options, the function from the options will be used.\n */\n notifySuccess: NotifyFunc;\n\n /**\n * Global notification function that will called when an asynchronous action fails,\n * if and only if, an error message is specified for this action using\n * <code>getErrorMessage</code>.\n * If another function is set in the options, the function from the options will be used.\n */\n notifyError: NotifyFunc;\n\n /**\n * Global notification function that will injected in onDone and onFail of an asynchronous actions and onActionDone of a synchronous function,\n * If another function is set in the options, the function from the options will be used.\n */\n notifyWarning: NotifyFunc;\n\n /**\n * A default error message provider.\n * Used to return generic messages on generic HTTP errors\n */\n getErrorMessage: (error: Error) => string;\n\n /**\n * Default middlewares. Store middleware array will be concatenated with this one.\n * By default contains only the optimistic middleware.\n */\n defaultMiddlewares: MiddlewareFactory<any, any, any>[];\n};\n\n/** @internal */\nexport const globalConfig: GlobalConfig = {\n clone: defaultCloneFunc,\n comparator: shallow,\n asyncErrorHandler: () => {},\n retryOnErrorFunction: (error: Error) => error instanceof TypeError,\n notifySuccess: undefined,\n notifyError: undefined,\n notifyWarning: undefined,\n getErrorMessage: undefined,\n defaultMiddlewares: [],\n};\n\nexport function setGlobalConfig(overrideConfig: Partial<GlobalConfig>) {\n const keys = Object.keys(overrideConfig) as (keyof GlobalConfig)[];\n keys.forEach((k) => {\n if (overrideConfig[k] != null) {\n globalConfig[k] = overrideConfig[k] as any;\n }\n });\n}\n\nfunction defaultCloneFunc(src: any) {\n return JSON.parse(JSON.stringify(src));\n}\n\nfunction clone(obj: any) {\n try {\n return globalConfig.clone(obj);\n } catch (e) {\n const msg =\n 'StateDecorator: Cannot clone object. Call setCloneFunction with another implementation like lodash/cloneDeep.';\n if (process.env.NODE_ENV === 'development') {\n console.error(msg);\n console.error(e.toString());\n }\n throw new Error(msg);\n }\n}\n\n// ----------------------------\n//\n// TYPE GUARDS\n//\n// -----------------------------\n\n/**\n * Type guard function to test if an action is a asynchronous action.\n */\nexport function isAsyncAction<S, DS, F extends (...args: any[]) => any, A, P, FxRes = S>(\n action: StoreAction<S, F, A, P, DS, FxRes>\n): action is AsyncAction<S, F, A, P, DS, FxRes> {\n return (\n !(action instanceof Function) && (action.hasOwnProperty('getPromise') || action.hasOwnProperty('getGetPromise'))\n );\n}\n\n/**\n * Type guard function to test if an action is a synchronous action.\n */\nexport function isSimpleSyncAction<S, F extends (...args: any[]) => any, A, P, DS = {}, FxRes = S>(\n action: StoreAction<S, F, A, P, DS, FxRes>\n): action is SimpleSyncAction<S, F, P, DS, FxRes> {\n return typeof action === 'function';\n}\n\n/**\n * Type guard function to test if an action is a synchronous action.\n */\nexport function isSyncAction<S, F extends (...args: any[]) => any, A, P, DS = {}, FxRes = S>(\n action: StoreAction<S, F, A, P, DS, FxRes>\n): action is SyncAction<S, F, A, P, DS, FxRes> {\n return (\n typeof action !== 'function' && !action.hasOwnProperty('getPromise') && !action.hasOwnProperty('getGetPromise')\n );\n}\n\nexport function isAsyncGetPromiseAction<S, DS, F extends (...args: any[]) => any, A, P, FxRes = S>(\n action: StoreAction<S, F, A, P, DS, FxRes>\n): action is AsyncActionPromise<S, F, A, P, DS, FxRes> {\n return typeof action !== 'function' && action.hasOwnProperty('getPromise') && !action.hasOwnProperty('getGetPromise');\n}\n\nexport function isAsyncGetPromiseGetAction<S, DS, F extends (...args: any[]) => any, A, P, FxRes = S>(\n action: StoreAction<S, F, A, P, DS, FxRes>\n): action is AsyncActionPromiseGet<S, F, A, P, DS, FxRes> {\n return typeof action !== 'function' && !action.hasOwnProperty('getPromise') && action.hasOwnProperty('getGetPromise');\n}\n\n/** @internal */\nexport function computeAsyncActionInput<S, DS, F extends (...args: any[]) => any, A, P, FxRes = S>(\n action: AsyncAction<S, F, A, P, DS, FxRes>\n): AsyncActionPromise<S, F, A, P, DS, FxRes> {\n if (isAsyncGetPromiseGetAction(action)) {\n return {\n ...(action as any),\n getPromise: action.getGetPromise,\n retryCount: 3,\n conflictPolicy: ConflictPolicy.REUSE,\n };\n }\n return action;\n}\n\n/** @internal */\nexport function buildLoadingMap<A>(\n source: InternalLoadingMap<A>,\n actionName: keyof A,\n promiseId: string,\n loading: boolean\n): InternalLoadingMap<A> {\n if (loading) {\n return {\n ...source,\n [actionName]: { ...(source[actionName] || {}), [promiseId]: loading },\n };\n }\n const res = {\n ...source,\n [actionName]: { ...source[actionName], [promiseId]: false },\n };\n return res;\n}\n\n/** @internal */\nexport function retryPromiseDecorator<S, DS, F extends (...args: any[]) => Promise<any>, A, P>(\n promiseProvider: PromiseProvider<S, DS, F, A, P>,\n maxCalls = 1,\n delay = 1000,\n isRetryError: (e: Error) => boolean = () => true\n): PromiseProvider<S, DS, F, A, P> {\n if (maxCalls === 1) {\n return promiseProvider;\n }\n return (ctx: GetPromiseInvocationContext<S, DS, F, P, A>): ReturnType<F> => {\n async function call(callCount: number, p: Promise<any>): Promise<any> {\n if (p === null) {\n return null;\n }\n\n return p.catch((e) => {\n if (isRetryError(e)) {\n if (callCount === maxCalls) {\n return Promise.reject(e);\n }\n return new Promise((resolve, reject) => {\n setTimeout(() => {\n const p = promiseProvider(ctx);\n call(callCount + 1, p)\n .then(resolve)\n .catch(reject);\n }, delay * callCount);\n });\n }\n return Promise.reject(e);\n });\n }\n\n const initialPromise = promiseProvider(ctx);\n if (initialPromise === null) {\n return null;\n }\n\n return call(1, initialPromise) as ReturnType<F>;\n };\n}\n\nexport type Ref<P> = {\n current: P;\n};\n\n/** @internal */\nexport function createRef<U>(init: U = null): Ref<U> {\n return {\n current: init,\n };\n}\n\n// =============================\n//\n// ACTION DECORATORS\n//\n// =============================\n/** @internal */\nexport function buildInvocationContextBase<S, DS, P>(\n stateRef: Ref<S>,\n derivedStateRef: Ref<DerivedState<DS>>,\n propsRef: Ref<P>\n): ContextWithDerived<S, DS, P> {\n return {\n state: stateRef.current,\n s: stateRef.current,\n ds: derivedStateRef?.current?.state,\n derived: derivedStateRef?.current?.state,\n props: propsRef.current,\n p: propsRef.current,\n };\n}\n\n/** @internal */\nexport function buildOnMountInvocationContext<S, DS, A, P>(\n stateRef: Ref<S>,\n derivedStateRef: Ref<DerivedState<DS>>,\n propsRef: Ref<P>,\n actionsRef: Ref<A>\n): OnMountInvocationContext<S, A, P> {\n return addContextActions(buildInvocationContextBase(stateRef, derivedStateRef, propsRef), actionsRef);\n}\n\n/** @internal */\nexport function buildOnPropChangeEffects<S, DS, P>(\n stateRef: Ref<S>,\n derivedStateRef: Ref<DerivedState<DS>>,\n propsRef: Ref<P>,\n indices: number[],\n index: number,\n isInit: boolean\n): OnPropsChangeEffectsContext<S, DS, P> {\n const res = buildInvocationContextBase(stateRef, derivedStateRef, propsRef) as OnPropsChangeEffectsContext<S, DS, P>;\n res.indices = indices;\n res.index = index;\n res.isInit = isInit;\n return res;\n}\n\n/** @internal */\nfunction buildInvocationContext<S, DS, F extends (...args: any[]) => any, P>(\n stateRef: Ref<S>,\n derivedStateRef: Ref<DerivedState<DS>>,\n propsRef: Ref<P>,\n args: Parameters<F>,\n promiseId?: string\n): InvocationContext<S, DS, F, P> {\n const res = buildInvocationContextBase(stateRef, derivedStateRef, propsRef) as InvocationContext<S, DS, F, P>;\n res.args = args;\n if (promiseId) {\n res.promiseId = promiseId;\n }\n\n return res;\n}\n\n/** @internal */\nfunction buildEffectsInvocationContext<S, DS, F extends (...args: any[]) => any, P>(\n stateRef: Ref<S>,\n derivedStateRef: Ref<DerivedState<DS>>,\n propsRef: Ref<P>,\n args: Parameters<F>,\n result: PromiseResult<ReturnType<F>>,\n promiseId?: string\n): EffectsInvocationContext<S, DS, F, P> {\n const res = buildInvocationContext(stateRef, derivedStateRef, propsRef, args, promiseId) as EffectsInvocationContext<\n S,\n DS,\n F,\n P\n >;\n res.result = result;\n res.res = result;\n return res;\n}\n\n/** @internal */\nfunction buildErrorEffectsInvocationContext<S, DS, F extends (...args: any[]) => any, P>(\n stateRef: Ref<S>,\n derivedStateRef: Ref<DerivedState<DS>>,\n propsRef: Ref<P>,\n args: Parameters<F>,\n error: Error,\n promiseId?: string\n): ErrorEffectsInvocationContext<S, DS, F, P> {\n const res = buildInvocationContext(\n stateRef,\n derivedStateRef,\n propsRef,\n args,\n promiseId\n ) as ErrorEffectsInvocationContext<S, DS, F, P>;\n res.error = error;\n res.err = error;\n return res;\n}\n\n/** @internal */\nfunction buildPromiseActionContext<S, DS, F extends (...args: any[]) => any, P, A>(\n stateRef: Ref<S>,\n derivedStateRef: Ref<DerivedState<DS>>,\n propsRef: Ref<P>,\n args: Parameters<F>,\n actionsRef: Ref<A>,\n abortSignal: AbortSignal,\n promiseId?: string\n): GetPromiseInvocationContext<S, DS, F, P, A> {\n const res = addContextActions(\n buildInvocationContext(stateRef, derivedStateRef, propsRef, args, promiseId),\n actionsRef\n ) as GetPromiseInvocationContext<S, DS, F, P, A>;\n res.abortSignal = abortSignal;\n return res;\n}\n\n/** @internal */\nexport function addStateToContext<T, S>(ctx: T, stateRef: Ref<S>): T & ContextState<S> {\n const newCtx = ctx as T & ContextState<S>;\n\n newCtx.state = stateRef.current;\n newCtx.s = stateRef.current;\n return newCtx;\n}\n\n/** @internal */\nexport function addContextActions<T, A>(ctx: T, actionsRef: Ref<A>): T & InvocationContextActions<A> {\n const newCtx = ctx as T & InvocationContextActions<A>;\n\n newCtx.actions = actionsRef.current;\n newCtx.a = actionsRef.current;\n return newCtx;\n}\n\n/** @internal */\nfunction addSideEffectsContext<S, T extends { s: S; state: S }, A>(\n ctx: T,\n stateRef: Ref<S>,\n actionsRef: Ref<A>,\n notifyWarning: NotifyFunc\n): T & InvocationContextActions<A> & WarningNotifyFunc {\n const res = addContextActions(ctx, actionsRef) as T & InvocationContextActions<A> & WarningNotifyFunc;\n addStateToContext(ctx, stateRef);\n res.notifyWarning = notifyWarning;\n return res;\n}\n\nfunction notInitWarning<A>(actionName: keyof A) {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n `[state-decorator] ${actionName} action was called while store is not initialized or destroyed, this is probably a leak`\n );\n }\n}\n\n/** @internal */\nexport function decorateSimpleSyncAction<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P>(\n actionName: keyof A,\n action: SimpleSyncAction<S, F, P, DS>,\n stateRef: Ref<S>,\n derivedStateRef: Ref<DerivedState<DS>>,\n propsRef: Ref<P>,\n initializedRef: Ref<boolean>,\n setState: SetStateFunc<S, A, P>\n) {\n return (...args: Parameters<F>) => {\n // store was destroyed\n if (!initializedRef.current) {\n notInitWarning(actionName);\n return;\n }\n\n const ctx = buildInvocationContext(stateRef, derivedStateRef, propsRef, args);\n const newState = action(ctx);\n setState(newState, null, actionName, 'effects', false, ctx, false);\n };\n}\n\n/** @internal */\nfunction executeSyncActionImpl<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P>(\n actionName: keyof A,\n action: SyncAction<S, F, A, P, DS>,\n stateRef: Ref<S>,\n derivedStateRef: Ref<DerivedState<DS>>,\n propsRef: Ref<P>,\n actionsRef: Ref<A>,\n timeoutMap: Ref<TimeoutMap<A>>,\n options: StoreOptions<S, A, P, any>,\n setState: SetStateFunc<S, A, P>,\n args: Parameters<F>\n) {\n const ctx = buildEffectsInvocationContext(stateRef, derivedStateRef, propsRef, args, undefined);\n\n let actionDropped = false;\n if (action.effects != null) {\n const newState: S = action.effects(ctx);\n if (newState === null) {\n actionDropped = true;\n } else {\n setState(newState, undefined, actionName, 'effects', false, ctx, false);\n }\n }\n\n if (!actionDropped) {\n if (action.debounceSideEffectsTimeout > 0) {\n const timeout = timeoutMap.current[actionName];\n\n if (timeout) {\n clearTimeout(timeout);\n }\n\n timeoutMap.current[actionName] = setTimeout(() => {\n action.sideEffects(addSideEffectsContext(ctx, stateRef, actionsRef, options.notifyWarning));\n delete timeoutMap.current[actionName];\n }, action.debounceSideEffectsTimeout);\n } else if (action.sideEffects) {\n action.sideEffects(addSideEffectsContext(ctx, stateRef, actionsRef, options.notifyWarning));\n }\n }\n}\n\n/** @internal */\nexport function decorateSyncAction<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P>(\n actionName: keyof A,\n action: SyncAction<S, F, A, P, DS>,\n stateRef: Ref<S>,\n derivedStateRef: Ref<DerivedState<DS>>,\n propsRef: Ref<P>,\n actionsRef: Ref<A>,\n initializedRef: Ref<boolean>,\n timeoutMap: Ref<TimeoutMap<A>>,\n options: StoreOptions<S, A, P, any>,\n setState: SetStateFunc<S, A, P>\n) {\n return (...args: Parameters<F>) => {\n // store was destroyed\n if (!initializedRef.current) {\n notInitWarning(actionName);\n return;\n }\n\n if (action.debounceTimeout) {\n const timeout = timeoutMap.current[actionName];\n\n if (timeout) {\n clearTimeout(timeout);\n }\n\n timeoutMap.current[actionName] = setTimeout(() => {\n delete timeoutMap.current[actionName];\n executeSyncActionImpl(\n actionName,\n action,\n stateRef,\n derivedStateRef,\n propsRef,\n actionsRef,\n timeoutMap,\n options,\n setState,\n args\n );\n }, action.debounceTimeout);\n } else {\n executeSyncActionImpl(\n actionName,\n action,\n stateRef,\n derivedStateRef,\n propsRef,\n actionsRef,\n timeoutMap,\n options,\n setState,\n args\n );\n }\n };\n}\n\nfunction processPromiseSuccess<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P>(\n context: AsyncActionExecContext<S, DS, F, A, P>,\n promiseId: string,\n promiseResult: PromiseResult<F>,\n args: Parameters<F>\n) {\n const {\n action,\n stateRef,\n derivedStateRef,\n propsRef,\n promisesRef,\n actionsRef,\n loadingMapRef,\n conflictActionsRef,\n actionName,\n options,\n setState,\n } = context;\n\n // store was destroyed\n if (!context.initializedRef.current) {\n return void 0;\n }\n\n let newState = null;\n\n const ctx = buildEffectsInvocationContext(stateRef, derivedStateRef, propsRef, args, promiseResult, promiseId);\n\n if (action.effects) {\n newState = action.effects(ctx);\n }\n\n setState(\n newState,\n buildLoadingMap(loadingMapRef.current, actionName, promiseId, false),\n actionName,\n 'effects',\n true,\n ctx,\n false\n );\n\n const notifySuccess = options.notifySuccess || globalConfig.notifySuccess;\n\n if (notifySuccess) {\n let msg: string;\n\n if (action.getSuccessMessage) {\n msg = action.getSuccessMessage(ctx);\n }\n\n if (msg) {\n notifySuccess(msg);\n }\n }\n\n delete promisesRef.current[actionName][promiseId];\n\n if (action.sideEffects) {\n action.sideEffects(addSideEffectsContext(ctx, stateRef, actionsRef, globalConfig.notifyWarning));\n }\n\n processNextConflictAction(actionName, actionsRef.current, conflictActionsRef.current);\n\n return promiseResult;\n}\n\nfunction processPromiseFailed<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P>(\n context: AsyncActionExecContext<S, DS, F, A, P>,\n promiseId: string,\n error: Error,\n args: Parameters<F>\n) {\n const {\n action,\n stateRef,\n derivedStateRef,\n propsRef,\n actionsRef,\n loadingMapRef,\n promisesRef,\n conflictActionsRef,\n actionName,\n options,\n setState,\n } = context;\n\n // store was killed;\n if (!context.initializedRef.current) {\n return void 0;\n }\n\n let newState = null;\n\n const ctx = buildErrorEffectsInvocationContext(stateRef, derivedStateRef, propsRef, args, error, promiseId);\n\n if (action.errorEffects) {\n newState = action.errorEffects(ctx);\n }\n\n setState(\n newState,\n buildLoadingMap(loadingMapRef.current, actionName, promiseId, false),\n actionName,\n 'errorEffects',\n true,\n ctx,\n false\n );\n\n let errorHandled = false;\n\n if (newState != null || action.errorSideEffects) {\n errorHandled = true;\n }\n\n const notifyError = options.notifyError || globalConfig.notifyError;\n\n if (notifyError) {\n let msg: string;\n\n if (action.getErrorMessage) {\n msg = action.getErrorMessage(ctx);\n }\n\n // do not trigger a default error message if the error is already managed by error effects\n if (!msg && !errorHandled && globalConfig.getErrorMessage) {\n msg = globalConfig.getErrorMessage(error);\n }\n\n if (msg) {\n errorHandled = true;\n notifyError(msg);\n }\n }\n\n globalConfig.asyncErrorHandler(\n error,\n errorHandled || action.rejectPromiseOnError,\n stateRef.current,\n propsRef.current,\n actionName as string,\n args\n );\n\n delete promisesRef.current[actionName][promiseId];\n\n if (action.errorSideEffects) {\n action.errorSideEffects(addSideEffectsContext(ctx, stateRef, actionsRef, globalConfig.notifyWarning));\n }\n\n processNextConflictAction(actionName, actionsRef.current, conflictActionsRef.current);\n\n const result = !errorHandled || action.rejectPromiseOnError ? Promise.reject(error) : Promise.resolve();\n\n return result;\n}\n\n/** @internal */\nexport function decorateAsyncAction<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P>(\n context: AsyncActionExecContext<S, DS, F, A, P>\n) {\n const {\n action,\n stateRef,\n derivedStateRef,\n propsRef,\n actionsRef,\n promisesRef,\n loadingMapRef,\n initializedRef,\n conflictActionsRef,\n actionName,\n setState,\n } = context;\n\n return (...args: Parameters<F>): Promise<any> => {\n if (!initializedRef.current) {\n notInitWarning(actionName);\n return null;\n }\n\n const promises = promisesRef.current;\n\n const { conflictPolicy = ConflictPolicy.KEEP_ALL } = action;\n const isParallel = conflictPolicy === ConflictPolicy.PARALLEL;\n\n let promiseId: string = null;\n if (isParallel) {\n if (!action.getPromiseId) {\n throw new Error(\n 'If conflict policy is set to ConflictPolicy.PARALLEL, getPromiseId must be set and return a string.'\n );\n }\n promiseId = action.getPromiseId(...args);\n } else {\n promiseId = DEFAULT_PROMISE_ID;\n }\n\n if (!isParallel && promises[actionName]?.[promiseId]) {\n return handleConflictingAction(promises, conflictActionsRef.current, actionName, conflictPolicy, args);\n }\n\n let newState = null;\n let hasChanged = false;\n\n const ctx = buildInvocationContext(stateRef, derivedStateRef, propsRef, args, promiseId);\n if (action.preEffects) {\n newState = action.preEffects(ctx);\n\n // apply internal state change for calls to other actions in the getPromise\n if (newState) {\n hasChanged = true;\n stateRef.current = newState;\n }\n }\n\n const { abortable, retryCount, retryDelaySeed, isTriggerRetryError } = action;\n\n const abortController = abortable && window.AbortController ? new AbortController() : null;\n\n const promiseProvider = retryPromiseDecorator(\n action.getPromise,\n retryCount ? 1 + retryCount : 1,\n retryDelaySeed,\n isTriggerRetryError || globalConfig.retryOnErrorFunction\n );\n\n const p = promiseProvider(\n buildPromiseActionContext(stateRef, derivedStateRef, propsRef, args, actionsRef, abortController?.signal)\n )\n ?.then((promiseResult: PromiseResult<F>) => processPromiseSuccess(context, promiseId, promiseResult, args))\n .catch((error: any) => processPromiseFailed(context, promiseId, error, args));\n\n if (p != null) {\n promises[actionName] = {\n ...(promises[actionName] || {}),\n [promiseId || DEFAULT_PROMISE_ID]: {\n abortController,\n promise: p,\n refArgs: conflictPolicy === ConflictPolicy.REUSE && args.length > 0 ? [...args] : [],\n },\n };\n }\n\n setState(\n p == null && !hasChanged ? undefined : stateRef.current,\n p == null ? undefined : buildLoadingMap(loadingMapRef.current, actionName, promiseId, true),\n actionName,\n 'preEffects',\n true,\n ctx,\n false\n );\n\n return p;\n };\n}\n\n/** @internal */\nexport function isLoadingImpl<A, K extends keyof A>(loadingMap: InternalLoadingMap<A>, ...props: (K | [K, string])[]) {\n return props.some((propIn) => {\n let actionName: keyof A = null;\n let promiseId = DEFAULT_PROMISE_ID;\n\n if (Array.isArray(propIn)) {\n [actionName, promiseId = DEFAULT_PROMISE_ID] = propIn;\n } else {\n actionName = propIn;\n }\n\n const res = loadingMap[actionName];\n\n if (res == null) {\n return false;\n }\n\n if (res[promiseId] != null) {\n return res[promiseId];\n }\n\n return false;\n });\n}\n\n// ------------------------------\n//\n// Conflict management\n//\n// ------------------------------\n\nexport const DEFAULT_PROMISE_ID = '__def__';\n\n/** @internal */\nexport function areSameArgs(args1: any[], args2: any[]): boolean {\n if (args1.length !== args2.length) {\n return false;\n }\n return args1.findIndex((value, index) => args2[index] !== value) === -1;\n}\n\n/**\n * Handles a conflicting action depending on the action conflict policy.\n */\n/** @internal */\nfunction handleConflictingAction<A>(\n promises: PromiseMap<A>,\n conflictActions: ConflictActionsMap<A>,\n actionName: keyof A,\n conflictPolicy: ConflictPolicy,\n args: any[]\n) {\n let policy = conflictPolicy;\n if (policy === ConflictPolicy.REUSE) {\n // use default because action cannot be parallel\n if (areSameArgs(promises[actionName][DEFAULT_PROMISE_ID].refArgs, args)) {\n return promises[actionName][DEFAULT_PROMISE_ID].promise;\n } // else\n policy = ConflictPolicy.KEEP_ALL;\n }\n\n return new Promise((resolve, reject) => {\n const futureAction = {\n resolve,\n reject,\n args: clone(args),\n timestamp: Date.now(),\n };\n\n switch (policy) {\n case ConflictPolicy.IGNORE:\n resolve(void 0);\n break;\n case ConflictPolicy.REJECT:\n reject(new Error(`An asynchronous action ${actionName} is already ongoing.`));\n break;\n case ConflictPolicy.KEEP_LAST: {\n conflictActions[actionName] = [futureAction];\n break;\n }\n case ConflictPolicy.KEEP_ALL: {\n let stack = conflictActions[actionName];\n if (!stack) {\n conflictActions[actionName] = stack = [];\n }\n stack.push(futureAction);\n\n break;\n }\n case ConflictPolicy.PARALLEL:\n case ConflictPolicy.REUSE:\n // no-op\n break;\n default:\n // will trigger a compilation error if one of the enum values is not processed.\n const exhaustiveCheck: never = policy;\n exhaustiveCheck;\n break;\n }\n });\n}\n\n/**\n * Processes next conflicting action (see ConflictPolicy) in the queue.\n */\nfunction processNextConflictAction<A>(actionName: keyof A, actions: A, conflictActions: ConflictActionsMap<A>) {\n const futureActions = conflictActions[actionName];\n\n if (futureActions && futureActions.length > 0) {\n const futureAction = conflictActions[actionName].shift();\n\n if (futureAction) {\n const p = (actions[actionName] as any)(...futureAction.args) as Promise<any>;\n if (p == null) {\n processNextConflictAction(actionName, actions, conflictActions);\n } else {\n p.then((res) => {\n if (res === null) {\n // promise was aborted\n processNextConflictAction(actionName, actions, conflictActions);\n }\n futureAction.resolve(res);\n }).catch((e) => futureAction.reject(e));\n } // else aborted\n }\n }\n}\n\n/** @internal */\nexport function computeDerivedValues<S, A, P, DS>(\n s: Ref<S>,\n p: Ref<P>,\n derivedStateRef: Ref<DerivedState<DS>>,\n options: StoreOptions<S, A, P, DS>\n): boolean {\n if (options?.derivedState == null) {\n return false;\n }\n\n let hasChanged = false;\n const compare = globalConfig.comparator;\n\n const depsMap = derivedStateRef.current.deps;\n const ctx = buildInvocationContextBase(s, null, p);\n\n const keys = Object.keys(options.derivedState) as (keyof DS)[];\n\n derivedStateRef.current.state = keys.reduce((acc, propName) => {\n let compute = false;\n\n const previousDeps = depsMap[propName];\n const deps = options.derivedState[propName].getDeps(ctx);\n if (previousDeps == null) {\n compute = true;\n } else {\n compute =\n deps.find((dep, index) => (previousDeps.length < index ? true : !compare(previousDeps[index], dep))) != null;\n }\n\n hasChanged = hasChanged || compute;\n\n // update cache of previous deps\n depsMap[propName] = deps;\n\n if (compute) {\n acc[propName] = options.derivedState[propName].get(ctx);\n } else {\n acc[propName] = derivedStateRef.current.state[propName];\n }\n\n return acc;\n }, {} as DS);\n\n return hasChanged;\n}\n\n// --------------------------------------\n//\n// Props change\n//\n// --------------------------------------\n\n/** @internal */\nexport function onPropChange<S, P, A, DS>(\n stateRef: Ref<S>,\n derivedStateRef: Ref<DerivedState<DS>>,\n propsRef: Ref<P>,\n oldProps: P,\n actionsRef: Ref<A>,\n options: StoreOptions<S, A, P, DS>,\n setState: SetStateFunc<S, A, P>,\n isInit: boolean\n) {\n const hasDerivedState = options?.derivedState != null;\n\n if (options.onPropsChange == null) {\n if (options?.derivedState != null) {\n // derived values must be updated from props\n setState(undefined, undefined, 'onPropsChange', 'effects', false, null, true);\n }\n return;\n }\n\n let onPropsChanges: OnPropsChangeOptions<S, DS, A, P>[];\n\n if (Array.isArray(options.onPropsChange)) {\n onPropsChanges = options.onPropsChange;\n } else {\n onPropsChanges = [options.onPropsChange];\n }\n\n let stateChanged = false;\n\n const newStateRef = createRef(stateRef.current);\n const sideEffects: { index: number; indices: any[]; ctx: OnPropsChangeEffectsContext<S, DS, P> }[] = [];\n\n const compare = globalConfig.comparator;\n\n onPropsChanges.forEach((propsChange, index) => {\n const getDeps = propsChange.getDeps;\n if (getDeps) {\n let propChanged = false;\n\n const indices: number[] = [];\n\n if (isInit) {\n if (propsChange.onMount) {\n propChanged = true;\n } else {\n // skip this onPropsChange\n return;\n }\n } else {\n const oldValues = getDeps(oldProps);\n const newValues = getDeps(propsRef.current);\n\n if (oldValues.length !== newValues.length) {\n console.warn('options.onPropsChange.getDeps returned array must be stable (same length)');\n propChanged = true;\n } else {\n oldValues.forEach((v, i) => {\n if (!compare(v, newValues[i])) {\n propChanged = true;\n indices.push(i);\n }\n });\n }\n }\n\n if (propChanged) {\n const ctx = buildOnPropChangeEffects(newStateRef, derivedStateRef, propsRef, indices, index, isInit);\n const newState = propsChange.effects?.(ctx) ?? null;\n\n if (newState != null) {\n stateChanged = true;\n newStateRef.current = newState;\n setState(newStateRef.current, undefined, 'onPropsChange', 'effects', false, ctx, true, isInit);\n }\n\n if (propsChange.sideEffects) {\n sideEffects.push({ index, indices, ctx });\n }\n }\n }\n });\n\n if (!stateChanged && hasDerivedState) {\n // derived values must be updated from props\n setState(undefined, undefined, 'onPropsChange', 'effects', false, null, true);\n }\n\n if (sideEffects.length > 0) {\n sideEffects.forEach((sideEffectInfo) => {\n const onPropChange = onPropsChanges[sideEffectInfo.index];\n onPropChange.sideEffects({\n ...addStateToContext(addContextActions(sideEffectInfo.ctx, actionsRef), newStateRef),\n indices: sideEffectInfo.indices,\n });\n });\n }\n}\n\n// ------------------\n//\n// Middlewares\n//\n// ------------------\n\n/** @internal */\nexport function runMiddlewares<S, A extends DecoratedActions, P>(\n middlewares: Middleware<S, A, P>[],\n oldState: S,\n newState: S,\n loading: boolean,\n actionName: keyof A,\n actionType: 'preEffects' | 'effects' | 'errorEffects' | null,\n isAsync: boolean,\n actionCtx: any\n): {\n newState: S;\n newLoading: boolean;\n} {\n // onPropChange to compute derived state but not state change\n if (actionName === 'onPropsChange' && newState === undefined) {\n return {\n newState: null,\n newLoading: false,\n };\n }\n\n if (middlewares && middlewares.length > 0) {\n const res = middlewares.reduce(\n (acc, middleware) => {\n const res = middleware.effects(\n {\n isAsync,\n name: actionName,\n type: actionType,\n context: actionCtx,\n },\n acc.oldState,\n acc.newState,\n loading\n );\n\n return {\n newState: res?.state || acc.newState,\n oldState: res?.state ? acc.newState : acc.oldState,\n loading: res?.loading == null ? acc.loading : res.loading,\n };\n },\n {\n oldState,\n newState,\n loading,\n }\n );\n\n return {\n newLoading: res.loading,\n newState: res.newState,\n };\n }\n return {\n newState,\n newLoading: loading,\n };\n}\n","/*\n * Copyright 2019 Globalsport SAS\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n// @ts-nocheck\n// SOURCE https://github.com/pmndrs/zustand/blob/master/src/shallow.ts\n\ntype Obj = Record<string | number | symbol, unknown>;\n\nexport default function shallow<T extends any, U extends any>(objA: T, objB: U) {\n if (Object.is(objA, objB)) {\n return true;\n }\n if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {\n return false;\n }\n const keysA = Object.keys(objA as object);\n if (keysA.length !== Object.keys(objB as object).length) {\n return false;\n }\n for (let i = 0; i < keysA.length; i++) {\n if (\n !Object.prototype.hasOwnProperty.call(objB, keysA[i]) ||\n !Object.is((objA as Obj)[keysA[i]], (objB as Obj)[keysA[i]])\n ) {\n return false;\n }\n }\n return true;\n}\n","import type {\n AsyncAction,\n DecoratedActions,\n EffectsType,\n Middleware,\n MiddlewareFactory,\n MiddlewareStoreContext,\n} from './types';\nimport isEqual from 'fast-deep-equal';\nimport { CloneFunction, globalConfig, isSimpleSyncAction } from './impl';\n\nfunction getNoopMiddleware<S, A extends DecoratedActions, P>(): Middleware<S, A, P> {\n const middleware: Middleware<S, A, P> = {\n init: () => {},\n destroy: null,\n effects: () => null,\n };\n\n return middleware;\n}\n\nexport function logEffects<S, A extends DecoratedActions, P>(\n log: (...msg: any[]) => void = console.log\n): MiddlewareFactory<S, A, P> {\n const f = () => {\n const logger = log;\n let storeName = '';\n\n const middleware: Middleware<S, A, P> = {\n init: (storeContext) => {\n if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {\n storeName = storeContext.options?.name ? `[${storeContext.options?.name}]` : '';\n const newState = storeContext.state;\n logger(storeName, 'initialState', newState);\n }\n },\n destroy: null,\n effects: (action, oldState, newState, loading: boolean) => {\n if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {\n logger(\n storeName,\n action.name,\n action.type,\n newState === null ? 'no effect' : newState,\n action.isAsync\n ? action.type === 'preEffects' && !loading\n ? 'Promise cancelled'\n : `loading: ${loading}`\n : ''\n );\n }\n return null;\n },\n };\n return middleware;\n };\n\n return f;\n}\n\nexport type Logger = {\n log: (...args: any[]) => void;\n group: (...args: any[]) => void;\n groupCollapsed: (...args: any[]) => void;\n groupEnd: (...args: any[]) => void;\n};\n\nexport function logDetailedEffects<S, A extends DecoratedActions, P>(\n logger: Logger = console\n): MiddlewareFactory<S, A, P> {\n return () => {\n let storeName = '';\n\n const console = logger;\n\n if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {\n const computeDiffPropValue = (oldValue: any, newValue: any) => {\n let res: any;\n if (newValue !== oldValue) {\n const type = oldValue != null ? typeof oldValue : typeof newValue;\n if (type === 'number' || type === 'string' || type === 'boolean') {\n res = `${oldValue} => ${newValue === '' ? '\"\"' : newValue}`;\n } else if ((oldValue && oldValue.length) || (newValue && newValue.length)) {\n if (oldValue == null) {\n res = `was ${oldValue}, now contains ${newValue.length} element(s)`;\n } else if (newValue == null) {\n res = `contained ${oldValue.length} element(s), now is ${newValue}`;\n } else if (oldValue.length === 0) {\n res = `was empty, now contains ${newValue.length} elements`;\n } else if (newValue.length === 0) {\n res = `contained ${oldValue.length} elements, now is empty`;\n } else {\n let addedValues = newValue.filter((a: any) => !oldValue.find((b: any) => isEqual(a, b)));\n let removedValues = oldValue.filter((a: any) => !newValue.find((b: any) => isEqual(a, b)));\n\n if (addedValues.length > 10) {\n addedValues = `${addedValues.length} element(s) added`;\n }\n if (removedValues.length > 10) {\n removedValues = `${removedValues.length} element(s) removed`;\n }\n res = {\n added: addedValues,\n removed: removedValues,\n };\n }\n } else {\n res = newValue;\n }\n }\n return res;\n };\n\n const buildDiff = <S>(oldState: S, newState: S) => {\n const res: Record<string, any> = {};\n\n if (process.env.NODE_ENV === 'development') {\n if (oldState) {\n const keys = Object.keys(oldState) as (keyof S)[];\n keys.forEach((k) => {\n if (newState.hasOwnProperty(k)) {\n const oldValue = oldState[k];\n const newValue = newState[k];\n const diff = computeDiffPropValue(oldValue, newValue);\n if (diff) {\n res[k as any] = diff;\n }\n } else {\n res[k as any] = 'was deleted';\n }\n });\n }\n\n const keys = Object.keys(newState) as (keyof S)[];\n keys.forEach((k) => {\n if (oldState == null || !oldState.hasOwnProperty(k)) {\n const newValue = newState[k];\n\n res[k as any] = computeDiffPropValue(undefined, newValue);\n }\n });\n }\n\n return res;\n };\n\n const getStr = (v: any) => {\n if (typeof v === 'string') {\n return `\"${v}\"`;\n }\n return v;\n };\n\n const middleware: Middleware<S, A, P> = {\n init: (storeContext) => {\n storeName = storeContext.options?.name ? `[${storeContext.options?.name}]` : '';\n const newState = storeContext.state;\n logger.group(storeName, 'initialState');\n const keys = Object.keys(newState) as (keyof S)[];\n keys.forEach((prop) => void console.log(prop, ':', getStr(newState[prop])));\n logger.groupEnd();\n },\n destroy: null,\n effects: (action, oldState, newState, loading) => {\n const args: any[] = action.context?.args;\n\n const params: string[] = [storeName, action.name.toString()];\n\n if (action.isAsync) {\n if (action.type === 'preEffects') {\n params.push(loading ? 'START' : 'CANCELLED');\n } else if (action.type === 'effects') {\n params.push('DONE');\n } else {\n params.push('FAILED');\n }\n }\n\n if (newState == null && (!args || Object.keys(args).length === 0)) {\n console.log(...params);\n } else {\n console.group(...params);\n }\n\n if (args && Object.keys(args).length > 0) {\n console.group('Arguments');\n args.forEach((arg) => void console.log(arg, ':', getStr(arg)));\n console.groupEnd();\n }\n\n if (newState != null) {\n console.groupCollapsed('Before');\n if (oldState == null) {\n console.log('was null');\n } else {\n const keys = Object.keys(oldState) as (keyof S)[];\n keys.forEach((prop) => void console.log(prop, ':', getStr(oldState[prop])));\n }\n console.groupEnd();\n\n console.groupCollapsed('After');\n if (newState == null) {\n console.log('was null');\n } else {\n const keys = Object.keys(newState) as (keyof S)[];\n keys.forEach((prop) => void console.log(prop, ':', getStr(newState[prop])));\n }\n console.groupEnd();\n\n if (newState != null) {\n console.group('Diff');\n const diff = buildDiff(oldState, newState);\n Object.keys(diff).forEach((prop) => console.log(prop, ':', diff[prop]));\n console.groupEnd();\n }\n }\n //\n console.groupEnd();\n\n return null;\n },\n };\n return middleware;\n }\n\n const middleware = getNoopMiddleware<S, A, P>();\n return middleware;\n };\n}\n\n// ------------------------------\n//\n// Optimistic\n//\n// ------------------------------\n\ntype ActionHistory<S, A> = {\n actionName: keyof A;\n promiseId: string;\n effectType: EffectsType;\n ctx: any;\n // FIXME CTX ?\n beforeEffectState: S;\n};\n\ntype OptimisticActionsMap = {\n [name: string]: any;\n};\n\ntype OptimisticData<S, A> = {\n /** History of effects */\n history: ActionHistory<S, A>[];\n /** Map of ongoing optimistic actions */\n optimisticActions: OptimisticActionsMap;\n /** Whether or not record all effects */\n shouldRecordHistory: boolean;\n};\n\nexport function optimisticActions<S, A extends DecoratedActions, P>(\n cloneFunc?: CloneFunction\n): MiddlewareFactory<S, A, P> {\n function getMiddleWare() {\n let storeContext: MiddlewareStoreContext<S, A, P> = null;\n\n const optimisticData: OptimisticData<S, A> = {\n history: null,\n optimisticActions: {},\n shouldRecordHistory: false,\n };\n\n const clone = (obj: any) => {\n const f = cloneFunc || globalConfig.clone;\n return f(obj);\n };\n\n const getActionId = (name: keyof A, promiseId: string) => {\n return `${name}_${promiseId}`;\n };\n\n /**\n * Adds an action to the action history (only when at least one optimistic action is ongoing).\n * @param actionName The action name\n * @param reducer The reducer name\n * @param args The arguments of the action (will be cloned)\n * @param beforeState state before the optimistic action\n */\n function pushActionToHistory(actionName: keyof A, effectType: EffectsType, ctx: any, beforeState: S = null): void {\n const { shouldRecordHistory } = optimisticData;\n const { history } = optimisticData;\n\n if (shouldRecordHistory) {\n if (history === null) {\n optimisticData.history = [];\n }\n\n const clonedCtx = clone(ctx);\n delete clonedCtx.state;\n delete clonedCtx.s;\n delete clonedCtx.abortSignal;\n // error clone issue\n clonedCtx.error = ctx.err;\n clonedCtx.err = ctx.err;\n\n const newEntry: ActionHistory<S, A> = {\n effectType,\n actionName,\n promiseId: ctx.promiseId,\n // fixme remove actions etc etc\n ctx: clonedCtx,\n beforeEffectState: beforeState ? clone(beforeState) : null,\n };\n\n optimisticData.history.push(newEntry);\n }\n }\n\n /**\n * Undo the optimistic action.\n * Strategy:\n * - Get the state before the optimistic reducer\n * - Replay all actions that occured after the optimistic action.\n * @param actionName The action name.\n */\n function undoOptimisticAction(actionName: keyof A, promiseId: string) {\n const { history } = optimisticData;\n\n // find the optimistic action in the history\n const index = history.findIndex(\n (a) => a.effectType === 'optimisticEffects' && a.actionName === actionName && a.promiseId === promiseId\n );\n\n // find the state at the time of the optimistic action.\n let state = history[index].beforeEffectState;\n\n // +1 to skip undo action\n for (let i = index + 1; i < history.length; i++) {\n const action = history[i];\n\n // This is an optimistic action, update restore state\n if (action.beforeEffectState) {\n action.beforeEffectState = state;\n }\n\n const ctx = {\n ...action.ctx,\n state,\n s: state,\n };\n\n if (action.actionName === 'onPropsChange') {\n const onPropsChanges = Array.isArray(storeContext.options.onPropsChange)\n ? storeContext.options.onPropsChange\n : [storeContext.options.onPropsChange];\n state = (onPropsChanges[ctx.index].effects as any)(ctx);\n } else if (isSimpleSyncAction(storeContext.actions[action.actionName])) {\n state = (storeContext.actions[action.actionName] as any)(ctx);\n } else {\n state = (storeContext.actions[action.actionName] as any)[action.effectType](ctx);\n }\n }\n\n // clean up\n cleanHistoryAfterOptimistAction(actionName, promiseId, index);\n\n return state;\n }\n\n function cleanHistoryAfterOptimistAction(\n actionName: keyof A,\n promiseId: string,\n indexInHistory: number = undefined\n ): void {\n const { optimisticActions, history } = optimisticData;\n\n const actionId = getActionId(actionName, promiseId);\n\n delete optimisticActions[actionId];\n\n const optiStateKeys = Object.keys(optimisticActions) as (keyof A)[];\n\n if (optiStateKeys.length === 0) {\n optimisticData.history = null;\n optimisticData.shouldRecordHistory = false;\n } else {\n const index =\n indexInHistory === undefined\n ? history.findIndex((a) => getActionId(a.actionName, a.promiseId) === actionId)\n : indexInHistory;\n\n if (index === 0) {\n // this was the first optimist action, so find the next one\n const nextOptimisticIndex = history.slice(1).findIndex((a) => a.beforeEffectState != null) + 1;\n\n // forget actions before the first optimist action in the history\n history.splice(0, nextOptimisticIndex);\n } else if (indexInHistory === undefined) {\n // success use case.\n // this was not the first optimist action, but can forget the saved state.\n // it becomes an asynchronous action.\n history[index].beforeEffectState = null;\n }\n }\n }\n\n // FIXME test destroy + init\n const middleware: Middleware<S, A, P> = {\n init(ctx) {\n storeContext = ctx;\n },\n destroy() {\n storeContext = null;\n optimisticData.history = null;\n optimisticData.optimisticActions = {};\n optimisticData.shouldRecordHistory = false;\n },\n effects({ name, type, context, isAsync }, oldState, newState, loading) {\n // add effect to the history if needed\n\n if (\n (newState != null && isSimpleSyncAction(storeContext.actions[name])) ||\n name === 'onPropsChange' ||\n (storeContext.actions[name] as any)[type] != null\n ) {\n pushActionToHistory(name, type, context, null);\n }\n\n if (isAsync) {\n // can cast\n const action = (storeContext.actions[name] as any) as AsyncAction<S, any, any, A, P>;\n\n // promise is sent and action is optimistic\n if (loading && action.optimisticEffects != null && type === 'preEffects') {\n optimisticData.shouldRecordHistory = true;\n optimisticData.optimisticActions[getActionId(name, context.promiseId)] = true;\n const state = newState || oldState;\n pushActionToHistory(name, 'optimisticEffects', context, state);\n return {\n loading: false,\n state: action.optimisticEffects({\n ...(context as any),\n state,\n s: state,\n }),\n };\n }\n // The promise was successful\n if (action.optimisticEffects != null && type === 'effects') {\n cleanHistoryAfterOptimistAction(name, context.promiseId);\n return {\n loading,\n state: newState,\n };\n }\n\n // The promise failed\n if (action.optimisticEffects != null && type === 'errorEffects') {\n const state = undoOptimisticAction(name, context.promiseId);\n return {\n state,\n loading,\n };\n }\n }\n\n // else no-op\n return null;\n },\n };\n return middleware;\n }\n return getMiddleWare;\n}\n\nexport function devtools<S, A extends DecoratedActions, P>(): MiddlewareFactory<S, A, P> {\n const getMiddleware = () => {\n let extension: any;\n try {\n extension = (window as any).__REDUX_DEVTOOLS_EXTENSION__ || (window as any).top.__REDUX_DEVTOOLS_EXTENSION__;\n } catch {}\n\n if (!extension) {\n return getNoopMiddleware<S, A, P>();\n }\n\n let devtools: any;\n let unsubscribe: () => void;\n\n const middleware: Middleware<S, A, P> = {\n init(storeContext) {\n devtools = extension.connect({ name: storeContext.options?.name ?? 'StateDecorator' });\n devtools.init(storeContext.state);\n let savedState: S = null;\n const initialState: S = storeContext.state;\n\n unsubscribe = devtools.subscribe((message: any) => {\n if (message.type === 'DISPATCH' && message.state && message.payload?.type !== 'ROLLBACK') {\n const newState = JSON.parse(message.state);\n storeContext.setState(newState);\n } else if (message.payload?.type === 'COMMIT') {\n savedState = storeContext.state;\n } else if (message.payload?.type === 'ROLLBACK') {\n if (savedState != null) {\n storeContext.setState(savedState);\n }\n } else if (message.payload?.type === 'RESET') {\n storeContext.setState(initialState);\n }\n });\n },\n\n effects(ctx, oldState, newState) {\n if (newState != null) {\n const cleanCtx: any = {\n ...ctx.context,\n };\n\n delete cleanCtx.a;\n delete cleanCtx.s;\n delete cleanCtx.p;\n delete cleanCtx.res;\n delete cleanCtx.err;\n delete cleanCtx.ds;\n\n devtools.send(\n {\n type: `${ctx.name} ${ctx.type}`,\n args: cleanCtx.args,\n context: cleanCtx,\n },\n newState\n );\n }\n\n return null; // no op on state\n },\n\n destroy() {\n unsubscribe();\n devtools = null;\n },\n };\n\n return middleware;\n };\n\n return getMiddleware;\n}\n"],"names":["module","obj","key","value","Object","defineProperty","enumerable","configurable","writable","exports","_typeof","Symbol","iterator","constructor","prototype","isArray","Array","keyList","keys","hasProp","hasOwnProperty","equal","a","b","i","length","arrA","arrB","dateA","Date","dateB","getTime","regexpA","RegExp","regexpB","toString","call","arr","len","arr2","arrayLikeToArray","iter","from","o","minLen","n","slice","name","test","TypeError","arrayWithoutHoles","iterableToArray","unsupportedIterableToArray","nonIterableSpread","ConflictPolicy","_arr","_n","_d","_e","undefined","_s","_i","next","done","push","err","arrayWithHoles","iterableToArrayLimit","nonIterableRest","asyncGeneratorStep","gen","resolve","reject","_next","_throw","arg","info","error","Promise","then","fn","self","this","args","arguments","apply","runtime","Op","hasOwn","$Symbol","iteratorSymbol","asyncIteratorSymbol","asyncIterator","toStringTagSymbol","toStringTag","define","wrap","innerFn","outerFn","tryLocsList","protoGenerator","Generator","generator","create","context","Context","_invoke","state","GenStateSuspendedStart","method","GenStateExecuting","Error","GenStateCompleted","doneResult","delegate","delegateResult","maybeInvokeDelegate","ContinueSentinel","sent","_sent","dispatchException","abrupt","record","tryCatch","type","GenStateSuspendedYield","makeInvokeMethod","GeneratorFunction","GeneratorFunctionPrototype","IteratorPrototype","getProto","getPrototypeOf","NativeIteratorPrototype","values","Gp","defineIteratorMethods","forEach","AsyncIterator","PromiseImpl","invoke","result","__await","unwrapped","previousPromise","callInvokeWithMethodAndArg","resultName","nextLoc","pushTryEntry","locs","entry","tryLoc","catchLoc","finallyLoc","afterLoc","tryEntries","resetTryEntry","completion","reset","iterable","iteratorMethod","isNaN","displayName","isGeneratorFunction","genFun","ctor","mark","setPrototypeOf","__proto__","awrap","async","object","reverse","pop","skipTempReset","prev","charAt","stop","rootRecord","rval","exception","handle","loc","caught","hasCatch","hasFinally","finallyEntry","complete","finish","catch","thrown","delegateYield","regeneratorRuntime","accidentalStrictMode","Function","globalConfig","clone","src","JSON","parse","stringify","comparator","objA","objB","is","keysA","asyncErrorHandler","retryOnErrorFunction","notifySuccess","notifyError","notifyWarning","getErrorMessage","defaultMiddlewares","isSimpleSyncAction","action","extension","devtools","unsubscribe","window","__REDUX_DEVTOOLS_EXTENSION__","top","init","storeContext","connect","options","_storeContext$options6","savedState","initialState","subscribe","message","payload","newState","setState","effects","ctx","oldState","cleanCtx","s","p","res","ds","send","destroy","logger","console","storeName","process","env","NODE_ENV","computeDiffPropValue","oldValue","newValue","addedValues","filter","find","isEqual","removedValues","added","removed","getStr","v","_storeContext$options4","group","prop","log","groupEnd","loading","_action$context","params","isAsync","groupCollapsed","diff","k","buildDiff","f","_storeContext$options2","cloneFunc","optimisticData","history","optimisticActions","shouldRecordHistory","getActionId","promiseId","pushActionToHistory","actionName","effectType","beforeState","clonedCtx","abortSignal","newEntry","beforeEffectState","cleanHistoryAfterOptimistAction","indexInHistory","actionId","optiStateKeys","index","findIndex","nextOptimisticIndex","splice","actions","optimisticEffects","onPropsChange","undoOptimisticAction"],"mappings":"gQAeAA,UAfA,SAAyBC,EAAKC,EAAKC,GAYjC,OAXID,KAAOD,EACTG,OAAOC,eAAeJ,EAAKC,EAAK,CAC9BC,MAAOA,EACPG,YAAY,EACZC,cAAc,EACdC,UAAU,IAGZP,EAAIC,GAAOC,EAGNF,GAITD,EAAOS,QAAiB,QAAIT,EAAOS,QAAST,sBAA4B,yBChBxE,SAASU,EAAQT,GAiBf,MAdsB,mBAAXU,QAAoD,iBAApBA,OAAOC,UAChDZ,UAAiBU,EAAU,SAAiBT,GAC1C,cAAcA,GAGhBD,EAAOS,QAAiB,QAAIT,EAAOS,QAAST,sBAA4B,IAExEA,UAAiBU,EAAU,SAAiBT,GAC1C,OAAOA,GAAyB,mBAAXU,QAAyBV,EAAIY,cAAgBF,QAAUV,IAAQU,OAAOG,UAAY,gBAAkBb,GAG3HD,EAAOS,QAAiB,QAAIT,EAAOS,QAAST,sBAA4B,GAGnEU,EAAQT,GAGjBD,UAAiBU,EACjBV,EAAOS,QAAiB,QAAIT,EAAOS,QAAST,sBAA4B,MCnBpEe,EAAUC,MAAMD,QAChBE,EAAUb,OAAOc,KACjBC,EAAUf,OAAOU,UAAUM,iBAEd,SAASC,EAAMC,EAAGC,GACjC,GAAID,IAAMC,EAAG,OAAO,EAEpB,GAAID,GAAKC,GAAiB,iBAALD,GAA6B,iBAALC,EAAe,CAC1D,IAEIC,EACAC,EACAvB,EAJAwB,EAAOX,EAAQO,GACfK,EAAOZ,EAAQQ,GAKnB,GAAIG,GAAQC,EAAM,CAEhB,IADAF,EAASH,EAAEG,SACGF,EAAEE,OAAQ,OAAO,EAC/B,IAAKD,EAAIC,EAAgB,G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