LocalCDN-Firefox-Chrome-Brave/resources/redux/5.0.1/redux.min.jsm

1 line
10 KiB
JavaScript

function formatProdErrorMessage(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var $$observable=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),symbol_observable_default=$$observable,randomString=()=>Math.random().toString(36).substring(7).split("").join("."),ActionTypes={INIT:"@@redux/INIT"+randomString(),REPLACE:"@@redux/REPLACE"+randomString(),PROBE_UNKNOWN_ACTION:()=>"@@redux/PROBE_UNKNOWN_ACTION"+randomString()},actionTypes_default=ActionTypes;function isPlainObject(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||null===Object.getPrototypeOf(e)}function miniKindOf(e){if(void 0===e)return"undefined";if(null===e)return"null";var t=typeof e;switch(t){case"boolean":case"string":case"number":case"symbol":case"function":return t}if(Array.isArray(e))return"array";if(isDate(e))return"date";if(isError(e))return"error";var r=ctorName(e);switch(r){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return r}return Object.prototype.toString.call(e).slice(8,-1).toLowerCase().replace(/\s/g,"")}function ctorName(e){return"function"==typeof e.constructor?e.constructor.name:null}function isError(e){return e instanceof Error||"string"==typeof e.message&&e.constructor&&"number"==typeof e.constructor.stackTraceLimit}function isDate(e){return e instanceof Date||"function"==typeof e.toDateString&&"function"==typeof e.getDate&&"function"==typeof e.setDate}function kindOf(e){let t=typeof e;return t="production"!==process.env.NODE_ENV?miniKindOf(e):t}function createStore(e,t,r){if("function"!=typeof e)throw new Error("production"===process.env.NODE_ENV?formatProdErrorMessage(2):`Expected the root reducer to be a function. Instead, received: '${kindOf(e)}'`);if("function"==typeof t&&"function"==typeof r||"function"==typeof r&&"function"==typeof arguments[3])throw new Error("production"===process.env.NODE_ENV?formatProdErrorMessage(0):"It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.");if("function"==typeof t&&void 0===r&&(r=t,t=void 0),void 0!==r){if("function"!=typeof r)throw new Error("production"===process.env.NODE_ENV?formatProdErrorMessage(1):`Expected the enhancer to be a function. Instead, received: '${kindOf(r)}'`);return r(createStore)(e,t)}let o=e,n=t,i=new Map,s=i,a=0,c=!1;function u(){s===i&&(s=new Map,i.forEach((e,t)=>{s.set(t,e)}))}function d(){if(c)throw new Error("production"===process.env.NODE_ENV?formatProdErrorMessage(3):"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 n}function f(e){if("function"!=typeof e)throw new Error("production"===process.env.NODE_ENV?formatProdErrorMessage(4):`Expected the listener to be a function. Instead, received: '${kindOf(e)}'`);if(c)throw new Error("production"===process.env.NODE_ENV?formatProdErrorMessage(5):"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/store#subscribelistener for more details.");let t=!0;u();const r=a++;return s.set(r,e),function(){if(t){if(c)throw new Error("production"===process.env.NODE_ENV?formatProdErrorMessage(6):"You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");t=!1,u(),s.delete(r),i=null}}}function p(e){if(!isPlainObject(e))throw new Error("production"===process.env.NODE_ENV?formatProdErrorMessage(7):`Actions must be plain objects. Instead, the actual type was: '${kindOf(e)}'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.`);if(void 0===e.type)throw new Error("production"===process.env.NODE_ENV?formatProdErrorMessage(8):'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');if("string"!=typeof e.type)throw new Error("production"===process.env.NODE_ENV?formatProdErrorMessage(17):`Action "type" property must be a string. Instead, the actual type was: '${kindOf(e.type)}'. Value was: '${e.type}' (stringified)`);if(c)throw new Error("production"===process.env.NODE_ENV?formatProdErrorMessage(9):"Reducers may not dispatch actions.");try{c=!0,n=o(n,e)}finally{c=!1}const t=i=s;return t.forEach(e=>{e()}),e}return p({type:actionTypes_default.INIT}),{dispatch:p,subscribe:f,getState:d,replaceReducer:function(e){if("function"!=typeof e)throw new Error("production"===process.env.NODE_ENV?formatProdErrorMessage(10):"Expected the nextReducer to be a function. Instead, received: '"+kindOf(e));o=e,p({type:actionTypes_default.REPLACE})},[symbol_observable_default]:function(){const r=f;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error("production"===process.env.NODE_ENV?formatProdErrorMessage(11):`Expected the observer to be an object. Instead, received: '${kindOf(t)}'`);function e(){const e=t;e.next&&e.next(d())}return e(),{unsubscribe:r(e)}},[symbol_observable_default](){return this}}}}}function legacy_createStore(e,t,r){return createStore(e,t,r)}function warning(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}}function getUnexpectedStateShapeWarningMessage(e,t,r,o){const n=Object.keys(t);var i=r&&r.type===actionTypes_default.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(0===n.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!isPlainObject(e))return`The ${i} has unexpected type of "${kindOf(e)}". Expected argument to be an object with the following keys: "${n.join('", "')}"`;const s=Object.keys(e).filter(e=>!t.hasOwnProperty(e)&&!o[e]);return s.forEach(e=>{o[e]=!0}),(!r||r.type!==actionTypes_default.REPLACE)&&0<s.length?`Unexpected ${1<s.length?"keys":"key"} "${s.join('", "')}" found in ${i}. Expected to find one of the known reducer keys instead: "${n.join('", "')}". Unexpected keys will be ignored.`:void 0}function assertReducerShape(r){Object.keys(r).forEach(e=>{const t=r[e];if(void 0===t(void 0,{type:actionTypes_default.INIT}))throw new Error("production"===process.env.NODE_ENV?formatProdErrorMessage(12):`The slice reducer for key "${e}" 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===t(void 0,{type:actionTypes_default.PROBE_UNKNOWN_ACTION()}))throw new Error("production"===process.env.NODE_ENV?formatProdErrorMessage(13):`The slice reducer for key "${e}" returned undefined when probed with a random type. Don't try to handle '${actionTypes_default.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.`)})}function combineReducers(t){var r=Object.keys(t);const d={};for(let e=0;e<r.length;e++){var o=r[e];"production"!==process.env.NODE_ENV&&void 0===t[o]&&warning(`No reducer provided for key "${o}"`),"function"==typeof t[o]&&(d[o]=t[o])}const f=Object.keys(d);let p;"production"!==process.env.NODE_ENV&&(p={});let l;try{assertReducerShape(d)}catch(e){l=e}return function(t={},r){if(l)throw l;var e;"production"!==process.env.NODE_ENV&&(e=getUnexpectedStateShapeWarningMessage(t,d,r,p))&&warning(e);let o=!1;const n={};for(let e=0;e<f.length;e++){var i=f[e];const u=d[i];var s,a=t[i],c=u(a,r);if(void 0===c)throw s=r&&r.type,new Error("production"===process.env.NODE_ENV?formatProdErrorMessage(14):`When called with an action of type ${s?`"${String(s)}"`:"(unknown type)"}, the slice reducer for key "${i}" 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.`);n[i]=c,o=o||c!==a}return(o=o||f.length!==Object.keys(t).length)?n:t}}function bindActionCreator(t,r){return function(...e){return r(t.apply(this,e))}}function bindActionCreators(e,t){if("function"==typeof e)return bindActionCreator(e,t);if("object"!=typeof e||null===e)throw new Error("production"===process.env.NODE_ENV?formatProdErrorMessage(16):`bindActionCreators expected an object or a function, but instead received: '${kindOf(e)}'. Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?`);const r={};for(const n in e){var o=e[n];"function"==typeof o&&(r[n]=bindActionCreator(o,t))}return r}function compose(...e){return 0===e.length?e=>e:1===e.length?e[0]:e.reduce((t,r)=>(...e)=>t(r(...e)))}function applyMiddleware(...i){return n=>(e,t)=>{e=n(e,t);let r=()=>{throw new Error("production"===process.env.NODE_ENV?formatProdErrorMessage(15):"Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const o={getState:e.getState,dispatch:(e,...t)=>r(e,...t)};t=i.map(e=>e(o));return r=compose(...t)(e.dispatch),{...e,dispatch:r}}}function isAction(e){return isPlainObject(e)&&"type"in e&&"string"==typeof e.type}export{actionTypes_default as __DO_NOT_USE__ActionTypes,applyMiddleware,bindActionCreators,combineReducers,compose,createStore,isAction,isPlainObject,legacy_createStore};