UNPKG

5.53 kB JavaScript View Raw
1var e=function(e){var t,n=e.Symbol;return"function"==typeof n?n.observable?t=n.observable:(t=n("observable"),n.observable=t):t="@@observable",t}("undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof module?module:Function("return this")());const t=()=>Math.random().toString(36).substring(7).split("").join("."),n={INIT:`@@redux/INIT${t()}`,REPLACE:`@@redux/REPLACE${t()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${t()}`};function o(t,r,i){if("function"==typeof r&&"function"==typeof i||"function"==typeof i&&"function"==typeof arguments[3])throw Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function.");if("function"==typeof r&&void 0===i&&(i=r,r=void 0),void 0!==i){if("function"!=typeof i)throw Error("Expected the enhancer to be a function.");return i(o)(t,r)}if("function"!=typeof t)throw Error("Expected the reducer to be a function.");let u=t,s=r,c=[],a=c,f=!1;function d(){a===c&&(a=c.slice())}function l(){if(f)throw Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return s}function h(e){if("function"!=typeof e)throw Error("Expected the listener to be a function.");if(f)throw Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api-reference/store#subscribelistener for more details.");let t=!0;return d(),a.push(e),function(){if(!t)return;if(f)throw Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api-reference/store#subscribelistener for more details.");t=!1,d();const n=a.indexOf(e);a.splice(n,1),c=null}}function p(e){if(!function(e){if("object"!=typeof e||null===e)return!1;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}(e))throw Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===e.type)throw Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(f)throw Error("Reducers may not dispatch actions.");try{f=!0,s=u(s,e)}finally{f=!1}const t=c=a;for(let e=0;t.length>e;e++){(0,t[e])()}return e}return p({type:n.INIT}),{dispatch:p,subscribe:h,getState:l,replaceReducer:function(e){if("function"!=typeof e)throw Error("Expected the nextReducer to be a function.");u=e,p({type:n.REPLACE})},[e]:function(){const t=h;return{subscribe(e){if("object"!=typeof e||null===e)throw new TypeError("Expected the observer to be an object.");function n(){e.next&&e.next(l())}return n(),{unsubscribe:t(n)}},[e](){return this}}}}}function r(e,t){const n=t&&t.type;return`Given ${n&&`action "${n+""}"`||"an action"}, reducer "${e}" returned undefined. `+"To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined."}function i(e){const t=Object.keys(e),o={};for(let n=0;t.length>n;n++){const r=t[n];"function"==typeof e[r]&&(o[r]=e[r])}const i=Object.keys(o);let u;try{!function(e){Object.keys(e).forEach(t=>{const o=e[t];if(void 0===o(void 0,{type:n.INIT}))throw Error(`Reducer "${t}" returned undefined during initialization. `+"If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.");if(void 0===o(void 0,{type:n.PROBE_UNKNOWN_ACTION()}))throw Error(`Reducer "${t}" returned undefined when probed with a random type. `+`Don't try to handle ${n.INIT} or other actions in "redux/*" `+"namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.")})}(o)}catch(e){u=e}return function(e={},t){if(u)throw u;let n=!1;const s={};for(let u=0;i.length>u;u++){const c=i[u],a=e[c],f=(0,o[c])(a,t);if(void 0===f){const e=r(c,t);throw Error(e)}s[c]=f,n=n||f!==a}return(n=n||i.length!==Object.keys(e).length)?s:e}}function u(e,t){return function(){return t(e.apply(this,arguments))}}function s(e,t){if("function"==typeof e)return u(e,t);if("object"!=typeof e||null===e)throw Error(`bindActionCreators expected an object or a function, instead received ${null===e?"null":typeof e}. `+'Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');const n={};for(const o in e){const r=e[o];"function"==typeof r&&(n[o]=u(r,t))}return n}function c(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce((e,t)=>(...n)=>e(t(...n)))}function a(...e){return t=>(...n)=>{const o=t(...n);let r=()=>{throw Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const i={getState:o.getState,dispatch:(...e)=>r(...e)},u=e.map(e=>e(i));return r=c(...u)(o.dispatch),{...o,dispatch:r}}}export{n as __DO_NOT_USE__ActionTypes,a as applyMiddleware,s as bindActionCreators,i as combineReducers,c as compose,o as createStore};