UNPKG

13.8 kBJavaScriptView Raw
1!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("redux")):"function"==typeof define&&define.amd?define(["exports","react","redux"],t):t(e.ReactRedux={},e.React,e.Redux)}(this,function(e,g,n){"use strict";function O(e,t){e.prototype=Object.create(t.prototype),(e.prototype.constructor=e).__proto__=t}function t(e,t){return e(t={exports:{}},t.exports),t.exports}function r(e){return function(){return e}}var o=function(){};o.thatReturns=r,o.thatReturnsFalse=r(!1),o.thatReturnsTrue=r(!0),o.thatReturnsNull=r(null),o.thatReturnsThis=function(){return this},o.thatReturnsArgument=function(e){return e};var i=o;var s=function(e,t,n,r,o,i,s,u){if(!e){var a;if(void 0===t)a=Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,r,o,i,s,u],p=0;(a=Error(t.replace(/%s/g,function(){return c[p++]}))).name="Invariant Violation"}throw a.framesToPop=1,a}},u=t(function(e){e.exports=function(){function e(e,t,n,r,o,i){"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"!==i&&s(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}var n={array:e.isRequired=e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return n.checkPropTypes=i,n.PropTypes=n}()}),C=u.shape({trySubscribe:u.func.isRequired,tryUnsubscribe:u.func.isRequired,notifyNestedSubs:u.func.isRequired,isSubscribed:u.func.isRequired}),w=u.shape({subscribe:u.func.isRequired,dispatch:u.func.isRequired,getState:u.func.isRequired});function a(o){var e;void 0===o&&(o="store");var n=o+"Subscription",t=function(r){O(t,r);var e=t.prototype;function t(e,t){var n;return(n=r.call(this,e,t)||this)[o]=e.store,n}return e.getChildContext=function(){var e;return(e={})[o]=this[o],e[n]=null,e},e.render=function(){return g.Children.only(this.props.children)},t}(g.Component);return t.propTypes={store:w.isRequired,children:u.element.isRequired},t.childContextTypes=((e={})[o]=w.isRequired,e[n]=C,e),t}var c=a();function T(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function x(){return(x=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function E(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)t.indexOf(n=i[r])<0&&(o[n]=e[n]);return o}var p,f=t(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var n="function"==typeof Symbol&&Symbol.for,r=n?Symbol.for("react.element"):60103,o=n?Symbol.for("react.portal"):60106,i=n?Symbol.for("react.fragment"):60107,s=n?Symbol.for("react.strict_mode"):60108,u=n?Symbol.for("react.profiler"):60114,a=n?Symbol.for("react.provider"):60109,c=n?Symbol.for("react.context"):60110,p=n?Symbol.for("react.concurrent_mode"):60111,f=n?Symbol.for("react.forward_ref"):60112,d=n?Symbol.for("react.suspense"):60113,l=n?Symbol.for("react.memo"):60115,h=n?Symbol.for("react.lazy"):60116;function y(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case r:switch(e=e.type){case p:case i:case u:case s:return e;default:switch(e=e&&e.$$typeof){case c:case f:case a:return e;default:return t}}case o:return t}}}function b(e){return y(e)===p}t.typeOf=y,t.AsyncMode=p,t.ConcurrentMode=p,t.ContextConsumer=c,t.ContextProvider=a,t.Element=r,t.ForwardRef=f,t.Fragment=i,t.Profiler=u,t.Portal=o,t.StrictMode=s,t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===i||e===p||e===u||e===s||e===d||"object"==typeof e&&null!==e&&(e.$$typeof===h||e.$$typeof===l||e.$$typeof===a||e.$$typeof===c||e.$$typeof===f)},t.isAsyncMode=function(e){return b(e)},t.isConcurrentMode=b,t.isContextConsumer=function(e){return y(e)===c},t.isContextProvider=function(e){return y(e)===a},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===r},t.isForwardRef=function(e){return y(e)===f},t.isFragment=function(e){return y(e)===i},t.isProfiler=function(e){return y(e)===u},t.isPortal=function(e){return y(e)===o},t.isStrictMode=function(e){return y(e)===s}});(p=f)&&p.__esModule&&Object.prototype.hasOwnProperty.call(p,"default");var d,l=t(function(e){e.exports=f}),R=l.isValidElementType;function h(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var y={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},b={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},v=h({},l.ForwardRef,(h(d={},"$$typeof",!0),h(d,"render",!0),d)),m=Object.defineProperty,P=Object.getOwnPropertyNames,S=Object.getOwnPropertySymbols,M=Object.getOwnPropertyDescriptor,q=Object.getPrototypeOf,N=Object.prototype;var j=function e(t,n,r){if("string"==typeof n)return t;if(N){var o=q(n);o&&o!==N&&e(t,o,r)}var i=P(n);S&&(i=i.concat(S(n)));for(var s=v[t.$$typeof]||y,u=v[n.$$typeof]||y,a=0;a<i.length;++a){var c=i[a];if(!(b[c]||r&&r[c]||u&&u[c]||s&&s[c])){var p=M(n,c);try{m(t,c,p)}catch(e){}}}return t},$=function(e,t,n,r,o,i,s,u){if(!e){var a;if(void 0===t)a=Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,r,o,i,s,u],p=0;(a=Error(t.replace(/%s/g,function(){return c[p++]}))).name="Invariant Violation"}throw a.framesToPop=1,a}},_={notify:function(){}};var D=function(){function e(e,t,n){this.store=e,this.parentSub=t,this.onStateChange=n,this.unsubscribe=null,this.listeners=_}var t=e.prototype;return t.addNestedSub=function(e){return this.trySubscribe(),this.listeners.subscribe(e)},t.notifyNestedSubs=function(){this.listeners.notify()},t.isSubscribed=function(){return!!this.unsubscribe},t.trySubscribe=function(){var n,r;this.unsubscribe||(this.unsubscribe=this.parentSub?this.parentSub.addNestedSub(this.onStateChange):this.store.subscribe(this.onStateChange),this.listeners=(n=[],r=[],{clear:function(){n=r=null},notify:function(){for(var e=n=r,t=0;t<e.length;t++)e[t]()},get:function(){return r},subscribe:function(e){var t=!0;return r===n&&(r=n.slice()),r.push(e),function(){t&&null!==n&&(t=!1,r===n&&(r=n.slice()),r.splice(r.indexOf(e),1))}}}))},t.tryUnsubscribe=function(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null,this.listeners.clear(),this.listeners=_)},e}(),U=0,I={};function F(){}function W(s,e){var t,n;void 0===e&&(e={});var r=e.getDisplayName,u=void 0===r?function(e){return"ConnectAdvanced("+e+")"}:r,o=e.methodName,a=void 0===o?"connectAdvanced":o,i=e.renderCountProp,c=void 0===i?void 0:i,p=e.shouldHandleStateChanges,f=void 0===p||p,d=e.storeKey,l=void 0===d?"store":d,h=e.withRef,y=void 0!==h&&h,b=E(e,["getDisplayName","methodName","renderCountProp","shouldHandleStateChanges","storeKey","withRef"]),v=l+"Subscription",m=U++,P=((t={})[l]=w,t[v]=C,t),S=((n={})[v]=C,n);return function(n){$(R(n),"You must pass a component to the function returned by "+a+". Instead received "+JSON.stringify(n));var e=n.displayName||n.name||"Component",o=u(e),i=x({},b,{getDisplayName:u,methodName:a,renderCountProp:c,shouldHandleStateChanges:f,storeKey:l,withRef:y,displayName:o,wrappedComponentName:e,WrappedComponent:n}),t=function(r){function e(e,t){var n;return(n=r.call(this,e,t)||this).version=m,n.state={},n.renderCount=0,n.store=e[l]||t[l],n.propsMode=!!e[l],n.setWrappedInstance=n.setWrappedInstance.bind(T(T(n))),$(n.store,'Could not find "'+l+'" in either the context or props of "'+o+'". Either wrap the root component in a <Provider>, or explicitly pass "'+l+'" as a prop to "'+o+'".'),n.initSelector(),n.initSubscription(),n}O(e,r);var t=e.prototype;return t.getChildContext=function(){var e;return(e={})[v]=(this.propsMode?null:this.subscription)||this.context[v],e},t.componentDidMount=function(){f&&(this.subscription.trySubscribe(),this.selector.run(this.props),this.selector.shouldComponentUpdate&&this.forceUpdate())},t.componentWillReceiveProps=function(e){this.selector.run(e)},t.shouldComponentUpdate=function(){return this.selector.shouldComponentUpdate},t.componentWillUnmount=function(){this.subscription&&this.subscription.tryUnsubscribe(),this.subscription=null,this.notifyNestedSubs=F,this.store=null,this.selector.run=F,this.selector.shouldComponentUpdate=!1},t.getWrappedInstance=function(){return $(y,"To access the wrapped instance, you need to specify { withRef: true } in the options argument of the "+a+"() call."),this.wrappedInstance},t.setWrappedInstance=function(e){this.wrappedInstance=e},t.initSelector=function(){var n,r,o,e=s(this.store.dispatch,i);this.selector=(n=e,r=this.store,o={run:function(e){try{var t=n(r.getState(),e);(t!==o.props||o.error)&&(o.shouldComponentUpdate=!0,o.props=t,o.error=null)}catch(e){o.shouldComponentUpdate=!0,o.error=e}}}),this.selector.run(this.props)},t.initSubscription=function(){f&&(this.subscription=new D(this.store,(this.propsMode?this.props:this.context)[v],this.onStateChange.bind(this)),this.notifyNestedSubs=this.subscription.notifyNestedSubs.bind(this.subscription))},t.onStateChange=function(){this.selector.run(this.props),this.selector.shouldComponentUpdate?(this.componentDidUpdate=this.notifyNestedSubsOnComponentDidUpdate,this.setState(I)):this.notifyNestedSubs()},t.notifyNestedSubsOnComponentDidUpdate=function(){this.componentDidUpdate=void 0,this.notifyNestedSubs()},t.isSubscribed=function(){return!!this.subscription&&this.subscription.isSubscribed()},t.addExtraProps=function(e){if(!(y||c||this.propsMode&&this.subscription))return e;var t=x({},e);return y&&(t.ref=this.setWrappedInstance),c&&(t[c]=this.renderCount++),this.propsMode&&this.subscription&&(t[v]=this.subscription),t},t.render=function(){var e=this.selector;if(e.shouldComponentUpdate=!1,e.error)throw e.error;return g.createElement(n,this.addExtraProps(e.props))},e}(g.Component);return t.WrappedComponent=n,t.displayName=o,t.childContextTypes=S,t.contextTypes=P,t.propTypes=P,j(t,n)}}var A=Object.prototype.hasOwnProperty;function k(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function H(e,t){if(k(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(var r=0;r<n.length;r++)if(!A.call(t,n[r])||!k(e[n[r]],t[n[r]]))return!1;return!0}function V(o){return function(e,t){var n=o(e,t);function r(){return n}return r.dependsOnOwnProps=!1,r}}function K(e){return null!=e.dependsOnOwnProps?!!e.dependsOnOwnProps:1!==e.length}function L(o,e){return function(e,t){var r=function(e,t){return r.dependsOnOwnProps?r.mapToProps(e,t):r.mapToProps(e)};return r.dependsOnOwnProps=!0,r.mapToProps=function(e,t){r.mapToProps=o,r.dependsOnOwnProps=K(o);var n=r(e,t);return"function"==typeof n&&(r.mapToProps=n,r.dependsOnOwnProps=K(n),n=r(e,t)),n},r}}function Y(e,t,n){return x({},n,e,t)}function z(n,r,o,i){return function(e,t){return o(n(e,t),r(i,t),t)}}function B(s,u,a,c,e){var p,f,d,l,h,y=e.areStatesEqual,b=e.areOwnPropsEqual,v=e.areStatePropsEqual,n=!1;function r(e,t){var n,r,o=!b(t,f),i=!y(e,p);return p=e,f=t,o&&i?(d=s(p,f),u.dependsOnOwnProps&&(l=u(c,f)),h=a(d,l,f)):o?(s.dependsOnOwnProps&&(d=s(p,f)),u.dependsOnOwnProps&&(l=u(c,f)),h=a(d,l,f)):(i&&(n=s(p,f),r=!v(n,d),d=n,r&&(h=a(d,l,f))),h)}return function(e,t){return n?r(e,t):(d=s(p=e,f=t),l=u(c,f),h=a(d,l,f),n=!0,h)}}function J(e,t){var n=t.initMapStateToProps,r=t.initMapDispatchToProps,o=t.initMergeProps,i=E(t,["initMapStateToProps","initMapDispatchToProps","initMergeProps"]),s=n(e,i),u=r(e,i),a=o(e,i);return(i.pure?B:z)(s,u,a,e,i)}function G(n,e,r){for(var t=e.length-1;0<=t;t--){var o=e[t](n);if(o)return o}return function(e,t){throw Error("Invalid value of type "+typeof n+" for "+r+" argument when connecting component "+t.wrappedComponentName+".")}}function Q(e,t){return e===t}var X,Z,ee,te,ne,re,oe,ie,se,ue,ae,ce,pe=(te=void 0===(ee=(Z=void 0===X?{}:X).connectHOC)?W:ee,re=void 0===(ne=Z.mapStateToPropsFactories)?[function(e){return"function"==typeof e?L(e):void 0},function(e){return e?void 0:V(function(){return{}})}]:ne,ie=void 0===(oe=Z.mapDispatchToPropsFactories)?[function(e){return"function"==typeof e?L(e):void 0},function(e){return e?void 0:V(function(e){return{dispatch:e}})},function(t){return t&&"object"==typeof t?V(function(e){return n.bindActionCreators(t,e)}):void 0}]:oe,ue=void 0===(se=Z.mergePropsFactories)?[function(e){return"function"==typeof e?(a=e,function(e,t){var o,i=t.pure,s=t.areMergedPropsEqual,u=!1;return function(e,t,n){var r=a(e,t,n);return u?i&&s(r,o)||(o=r):(u=!0,o=r),o}}):void 0;var a},function(e){return e?void 0:function(){return Y}}]:se,ce=void 0===(ae=Z.selectorFactory)?J:ae,function(e,t,n,r){void 0===r&&(r={});var o=r.pure,i=void 0===o||o,s=r.areStatesEqual,u=void 0===s?Q:s,a=r.areOwnPropsEqual,c=void 0===a?H:a,p=r.areStatePropsEqual,f=void 0===p?H:p,d=r.areMergedPropsEqual,l=void 0===d?H:d,h=E(r,["pure","areStatesEqual","areOwnPropsEqual","areStatePropsEqual","areMergedPropsEqual"]),y=G(e,re,"mapStateToProps"),b=G(t,ie,"mapDispatchToProps"),v=G(n,ue,"mergeProps");return te(ce,x({methodName:"connect",getDisplayName:function(e){return"Connect("+e+")"},shouldHandleStateChanges:!!e,initMapStateToProps:y,initMapDispatchToProps:b,initMergeProps:v,pure:i,areStatesEqual:u,areOwnPropsEqual:c,areStatePropsEqual:f,areMergedPropsEqual:l},h))});e.Provider=c,e.createProvider=a,e.connectAdvanced=W,e.connect=pe,Object.defineProperty(e,"__esModule",{value:!0})});