You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

2 lines
12 KiB

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("preact"),require("redux")):"function"==typeof define&&define.amd?define(["preact","redux"],e):t.preactRedux=e(t.preact,t.Redux)}(this,function(t,e){function n(){}function r(){z||(z=!0)}function o(){var t=[],e=[];return{clear:function(){e=et,t=et},notify:function(){for(var n=t=e,r=0;r<n.length;r++)n[r]()},get:function(){return e},subscribe:function(n){var r=!0;return e===t&&(e=t.slice()),e.push(n),function(){r&&t!==et&&(r=!1,e===t&&(e=t.slice()),e.splice(e.indexOf(n),1))}}}}function i(){}function s(t,e){var n={run:function(r){try{var o=t(e.getState(),r);(o!==n.props||n.error)&&(n.shouldComponentUpdate=!0,n.props=o,n.error=null)}catch(t){n.shouldComponentUpdate=!0,n.error=t}}};return n}function u(e){var n,r,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},u=o.getDisplayName,p=void 0===u?function(t){return"ConnectAdvanced("+t+")"}:u,c=o.methodName,a=void 0===c?"connectAdvanced":c,d=o.renderCountProp,f=void 0===d?void 0:d,l=o.shouldHandleStateChanges,h=void 0===l||l,b=o.storeKey,y=void 0===b?"store":b,v=o.withRef,m=void 0!==v&&v,P=k(o,["getDisplayName","methodName","renderCountProp","shouldHandleStateChanges","storeKey","withRef"]),O=y+"Subscription",S=ot++,g=(n={},n[y]=H,n[O]=F,n),w=(r={},r[O]=F,r);return function(n){JSON.stringify(n);var r=n.displayName||n.name||"Component",o=p(r),u=_({},P,{getDisplayName:p,methodName:a,renderCountProp:f,shouldHandleStateChanges:h,storeKey:y,withRef:m,displayName:o,wrappedComponentName:r,WrappedComponent:n}),c=function(r){function o(t,e){var n=J(this,r.call(this,t,e));return n.version=S,n.state={},n.renderCount=0,n.store=t[y]||e[y],n.propsMode=!!t[y],n.setWrappedInstance=n.setWrappedInstance.bind(n),n.initSelector(),n.initSubscription(),n}return K(o,r),o.prototype.getChildContext=function(){var t,e=this.propsMode?null:this.subscription;return t={},t[O]=e||this.context[O],t},o.prototype.componentDidMount=function(){h&&(this.subscription.trySubscribe(),this.selector.run(this.props),this.selector.shouldComponentUpdate&&this.forceUpdate())},o.prototype.componentWillReceiveProps=function(t){this.selector.run(t)},o.prototype.shouldComponentUpdate=function(){return this.selector.shouldComponentUpdate},o.prototype.componentWillUnmount=function(){this.subscription&&this.subscription.tryUnsubscribe(),this.subscription=null,this.notifyNestedSubs=i,this.store=null,this.selector.run=i,this.selector.shouldComponentUpdate=!1},o.prototype.getWrappedInstance=function(){return this.wrappedInstance},o.prototype.setWrappedInstance=function(t){this.wrappedInstance=t},o.prototype.initSelector=function(){this.selector=s(e(this.store.dispatch,u),this.store),this.selector.run(this.props)},o.prototype.initSubscription=function(){if(h){this.subscription=new rt(this.store,(this.propsMode?this.props:this.context)[O],this.onStateChange.bind(this)),this.notifyNestedSubs=this.subscription.notifyNestedSubs.bind(this.subscription)}},o.prototype.onStateChange=function(){this.selector.run(this.props),this.selector.shouldComponentUpdate?(this.componentDidUpdate=this.notifyNestedSubsOnComponentDidUpdate,this.setState(it)):this.notifyNestedSubs()},o.prototype.notifyNestedSubsOnComponentDidUpdate=function(){this.componentDidUpdate=void 0,this.notifyNestedSubs()},o.prototype.isSubscribed=function(){return!!this.subscription&&this.subscription.isSubscribed()},o.prototype.addExtraProps=function(t){if(!(m||f||this.propsMode&&this.subscription))return t;var e=_({},t);return m&&(e.ref=this.setWrappedInstance),f&&(e[f]=this.renderCount++),this.propsMode&&this.subscription&&(e[O]=this.subscription),e},o.prototype.render=function(){var e=this.selector;if(e.shouldComponentUpdate=!1,e.error)throw e.error;return t.h(n,this.addExtraProps(e.props))},o}(t.Component);return c.WrappedComponent=n,c.displayName=o,c.childContextTypes=w,c.contextTypes=g,c.prototype.componentWillUpdate=function(){var t=this;if(this.version!==S){this.version=S,this.initSelector();var e=[];this.subscription&&(e=this.subscription.listeners.get(),this.subscription.tryUnsubscribe()),this.initSubscription(),h&&(this.subscription.trySubscribe(),e.forEach(function(e){return t.subscription.listeners.subscribe(e)}))}},tt(c,n)}}function p(t,e){return t===e?0!==t||0!==e||1/t==1/e:t!==t&&e!==e}function c(t,e){if(p(t,e))return!0;if("object"!==(void 0===t?"undefined":A(t))||null===t||"object"!==(void 0===e?"undefined":A(e))||null===e)return!1;var n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(var r=0;r<n.length;r++)if(!st.call(e,n[r])||!p(t[n[r]],e[n[r]]))return!1;return!0}function a(t){var e=ft.call(t,ht),n=t[ht];try{t[ht]=void 0;var r=!0}catch(t){}var o=lt.call(t);return r&&(e?t[ht]=n:delete t[ht]),o}function d(t){return yt.call(t)}function f(t){return null==t?void 0===t?mt:vt:Pt&&Pt in Object(t)?a(t):d(t)}function l(t){return null!=t&&"object"==(void 0===t?"undefined":A(t))}function h(t){if(!l(t)||f(t)!=St)return!1;var e=Ot(t);if(null===e)return!0;var n=jt.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&Ct.call(n)==Nt}function b(t){h(t)}function y(t){return function(e,n){function r(){return o}var o=t(e,n);return r.dependsOnOwnProps=!1,r}}function v(t){return null!==t.dependsOnOwnProps&&void 0!==t.dependsOnOwnProps?!!t.dependsOnOwnProps:1!==t.length}function m(t,e){return function(n,r){var o=r.displayName,i=function(t,e){return i.dependsOnOwnProps?i.mapToProps(t,e):i.mapToProps(t)};return i.dependsOnOwnProps=!0,i.mapToProps=function(n,r){i.mapToProps=t,i.dependsOnOwnProps=v(t);var s=i(n,r);return"function"==typeof s&&(i.mapToProps=s,i.dependsOnOwnProps=v(s),s=i(n,r)),b(s,o,e),s},i}}function P(t){return"function"==typeof t?m(t,"mapDispatchToProps"):void 0}function O(t){return t?void 0:y(function(t){return{dispatch:t}})}function S(t){return t&&"object"===(void 0===t?"undefined":A(t))?y(function(n){return e.bindActionCreators(t,n)}):void 0}function g(t){return"function"==typeof t?m(t,"mapStateToProps"):void 0}function w(t){return t?void 0:y(function(){return{}})}function C(t,e,n){return _({},n,t,e)}function j(t){return function(e,n){var r=n.displayName,o=n.pure,i=n.areMergedPropsEqual,s=!1,u=void 0;return function(e,n,p){var c=t(e,n,p);return s?o&&i(c,u)||(u=c):(s=!0,u=c,b(u,r,"mergeProps")),u}}}function N(t){return"function"==typeof t?j(t):void 0}function T(t){return t?void 0:function(){return C}}function q(t,e,n){if(!t)throw Error("Unexpected value for "+e+" in "+n+".");"mapStateToProps"!==e&&"mapDispatchToProps"!==e||t.hasOwnProperty("dependsOnOwnProps")}function E(t,e,n,r){q(t,"mapStateToProps",r),q(e,"mapDispatchToProps",r),q(n,"mergeProps",r)}function x(t,e,n,r){return function(o,i){return n(t(o,i),e(r,i),i)}}function U(t,e,n,r,o){function i(o,i){return h=o,b=i,y=t(h,b),v=e(r,b),m=n(y,v,b),l=!0,m}function s(){return y=t(h,b),e.dependsOnOwnProps&&(v=e(r,b)),m=n(y,v,b)}function u(){return t.dependsOnOwnProps&&(y=t(h,b)),e.dependsOnOwnProps&&(v=e(r,b)),m=n(y,v,b)}function p(){var e=t(h,b),r=!f(e,y);return y=e,r&&(m=n(y,v,b)),m}function c(t,e){var n=!d(e,b),r=!a(t,h);return h=t,b=e,n&&r?s():n?u():r?p():m}var a=o.areStatesEqual,d=o.areOwnPropsEqual,f=o.areStatePropsEqual,l=!1,h=void 0,b=void 0,y=void 0,v=void 0,m=void 0;return function(t,e){return l?c(t,e):i(t,e)}}function D(t,e){var n=e.initMapStateToProps,r=e.initMapDispatchToProps,o=e.initMergeProps,i=k(e,["initMapStateToProps","initMapDispatchToProps","initMergeProps"]),s=n(t,i),u=r(t,i),p=o(t,i);return E(s,u,p,i.displayName),(i.pure?U:x)(s,u,p,t,i)}function M(t,e,n){for(var r=e.length-1;r>=0;r--){var o=e[r](t);if(o)return o}return function(e,r){throw Error("Invalid value of type "+(void 0===t?"undefined":A(t))+" for "+n+" argument when connecting component "+r.wrappedComponentName+".")}}function R(t,e){return t===e}var W={only:function(t){return t&&t[0]||null}};n.isRequired=n;var I={element:n,func:n,shape:function(){return n},instanceOf:function(){return n}},F=I.shape({trySubscribe:I.func.isRequired,tryUnsubscribe:I.func.isRequired,notifyNestedSubs:I.func.isRequired,isSubscribed:I.func.isRequired}),H=I.shape({subscribe:I.func.isRequired,dispatch:I.func.isRequired,getState:I.func.isRequired}),A="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},K=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},k=function(t,e){var n={};for(var r in t)e.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return n},J=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},z=!1,B=function(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"store",o=arguments[1],i=o||n+"Subscription",s=function(t){function e(e,r){var o=J(this,t.call(this,e,r));return o[n]=e.store,o}return K(e,t),e.prototype.getChildContext=function(){var t;return t={},t[n]=this[n],t[i]=null,t},e.prototype.render=function(){return W.only(this.props.children)},e}(t.Component);return s.prototype.componentWillReceiveProps=function(t){this[n]!==t.store&&r()},s.childContextTypes=(e={},e[n]=H.isRequired,e[i]=F,e),s}(),G={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},L={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},Q=Object.defineProperty,V=Object.getOwnPropertyNames,X=Object.getOwnPropertySymbols,Y=Object.getOwnPropertyDescriptor,Z=Object.getPrototypeOf,$=Z&&Z(Object),tt=function t(e,n,r){if("string"!=typeof n){if($){var o=Z(n);o&&o!==$&&t(e,o,r)}var i=V(n);X&&(i=i.concat(X(n)));for(var s=0;s<i.length;++s){var u=i[s];if(!(G[u]||L[u]||r&&r[u])){var p=Y(n,u);try{Q(e,u,p)}catch(t){}}}return e}return e},et=null,nt={notify:function(){}},rt=function(){function t(t,e,n){this.store=t,this.parentSub=e,this.onStateChange=n,this.unsubscribe=null,this.listeners=nt}return t.prototype.addNestedSub=function(t){return this.trySubscribe(),this.listeners.subscribe(t)},t.prototype.notifyNestedSubs=function(){this.listeners.notify()},t.prototype.isSubscribed=function(){return!!this.unsubscribe},t.prototype.trySubscribe=function(){this.unsubscribe||(this.unsubscribe=this.parentSub?this.parentSub.addNestedSub(this.onStateChange):this.store.subscribe(this.onStateChange),this.listeners=o())},t.prototype.tryUnsubscribe=function(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null,this.listeners.clear(),this.listeners=nt)},t}(),ot=0,it={},st=Object.prototype.hasOwnProperty,ut="object"==("undefined"==typeof global?"undefined":A(global))&&global&&global.Object===Object&&global,pt="object"==("undefined"==typeof self?"undefined":A(self))&&self&&self.Object===Object&&self,ct=ut||pt||Function("return this")(),at=ct.Symbol,dt=Object.prototype,ft=dt.hasOwnProperty,lt=dt.toString,ht=at?at.toStringTag:void 0,bt=Object.prototype,yt=bt.toString,vt="[object Null]",mt="[object Undefined]",Pt=at?at.toStringTag:void 0,Ot=function(t,e){return function(n){return t(e(n))}}(Object.getPrototypeOf,Object),St="[object Object]",gt=Function.prototype,wt=Object.prototype,Ct=gt.toString,jt=wt.hasOwnProperty,Nt=Ct.call(Object),Tt=[P,O,S],qt=[g,w],Et=[N,T];return{Provider:B,connect:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.connectHOC,n=void 0===e?u:e,r=t.mapStateToPropsFactories,o=void 0===r?qt:r,i=t.mapDispatchToPropsFactories,s=void 0===i?Tt:i,p=t.mergePropsFactories,a=void 0===p?Et:p,d=t.selectorFactory,f=void 0===d?D:d;return function(t,e,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},u=i.pure,p=void 0===u||u,d=i.areStatesEqual,l=void 0===d?R:d,h=i.areOwnPropsEqual,b=void 0===h?c:h,y=i.areStatePropsEqual,v=void 0===y?c:y,m=i.areMergedPropsEqual,P=void 0===m?c:m,O=k(i,["pure","areStatesEqual","areOwnPropsEqual","areStatePropsEqual","areMergedPropsEqual"]),S=M(t,o,"mapStateToProps"),g=M(e,s,"mapDispatchToProps"),w=M(r,a,"mergeProps");return n(f,_({methodName:"connect",getDisplayName:function(t){return"Connect("+t+")"},shouldHandleStateChanges:!!t,initMapStateToProps:S,initMapDispatchToProps:g,initMergeProps:w,pure:p,areStatesEqual:l,areOwnPropsEqual:b,areStatePropsEqual:v,areMergedPropsEqual:P},O))}}(),connectAdvanced:u}});
//# sourceMappingURL=preact-redux.min.js.map