preact-redux
Advanced tools
Comparing version
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('preact'), require('redux')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'preact', 'redux'], factory) : | ||
(factory((global.preactRedux = global.preactRedux || {}),global.preact,global.redux)); | ||
}(this, (function (exports,preact,redux) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('preact'), require('redux')) : | ||
typeof define === 'function' && define.amd ? define(['preact', 'redux'], factory) : | ||
(global.preactRedux = factory(global.preact,global.redux)); | ||
}(this, (function (preact,redux) { | ||
@@ -175,188 +175,135 @@ var Children = { | ||
function interopDefault(ex) { | ||
return ex && typeof ex === 'object' && 'default' in ex ? ex['default'] : ex; | ||
/** | ||
* Creates a unary function that invokes `func` with its argument transformed. | ||
* | ||
* @private | ||
* @param {Function} func The function to wrap. | ||
* @param {Function} transform The argument transform. | ||
* @returns {Function} Returns the new function. | ||
*/ | ||
function overArg(func, transform) { | ||
return function (arg) { | ||
return func(transform(arg)); | ||
}; | ||
} | ||
function createCommonjsModule(fn, module) { | ||
return module = { exports: {} }, fn(module, module.exports), module.exports; | ||
} | ||
/** Built-in value references. */ | ||
var getPrototype = overArg(Object.getPrototypeOf, Object); | ||
var _overArg = createCommonjsModule(function (module) { | ||
/** | ||
* Creates a unary function that invokes `func` with its argument transformed. | ||
* | ||
* @private | ||
* @param {Function} func The function to wrap. | ||
* @param {Function} transform The argument transform. | ||
* @returns {Function} Returns the new function. | ||
*/ | ||
function overArg(func, transform) { | ||
return function (arg) { | ||
return func(transform(arg)); | ||
}; | ||
/** | ||
* Checks if `value` is a host object in IE < 9. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a host object, else `false`. | ||
*/ | ||
function isHostObject(value) { | ||
// Many host objects are `Object` objects that can coerce to strings | ||
// despite having improperly defined `toString` methods. | ||
var result = false; | ||
if (value != null && typeof value.toString != 'function') { | ||
try { | ||
result = !!(value + ''); | ||
} catch (e) {} | ||
} | ||
return result; | ||
} | ||
module.exports = overArg; | ||
}); | ||
/** | ||
* Checks if `value` is object-like. A value is object-like if it's not `null` | ||
* and has a `typeof` result of "object". | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 4.0.0 | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is object-like, else `false`. | ||
* @example | ||
* | ||
* _.isObjectLike({}); | ||
* // => true | ||
* | ||
* _.isObjectLike([1, 2, 3]); | ||
* // => true | ||
* | ||
* _.isObjectLike(_.noop); | ||
* // => false | ||
* | ||
* _.isObjectLike(null); | ||
* // => false | ||
*/ | ||
function isObjectLike(value) { | ||
return !!value && typeof value == 'object'; | ||
} | ||
var _overArg$1 = interopDefault(_overArg); | ||
/** `Object#toString` result references. */ | ||
var objectTag = '[object Object]'; | ||
var require$$0 = Object.freeze({ | ||
default: _overArg$1 | ||
}); | ||
/** Used for built-in method references. */ | ||
var funcProto = Function.prototype; | ||
var objectProto = Object.prototype; | ||
/** Used to resolve the decompiled source of functions. */ | ||
var funcToString = funcProto.toString; | ||
var _getPrototype = createCommonjsModule(function (module) { | ||
var overArg = interopDefault(require$$0); | ||
/** Used to check objects for own properties. */ | ||
var hasOwnProperty = objectProto.hasOwnProperty; | ||
/** Built-in value references. */ | ||
var getPrototype = overArg(Object.getPrototypeOf, Object); | ||
/** Used to infer the `Object` constructor. */ | ||
var objectCtorString = funcToString.call(Object); | ||
module.exports = getPrototype; | ||
}); | ||
/** | ||
* Used to resolve the | ||
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) | ||
* of values. | ||
*/ | ||
var objectToString = objectProto.toString; | ||
var _getPrototype$1 = interopDefault(_getPrototype); | ||
var require$$2 = Object.freeze({ | ||
default: _getPrototype$1 | ||
}); | ||
var _isHostObject = createCommonjsModule(function (module) { | ||
/** | ||
* Checks if `value` is a host object in IE < 9. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a host object, else `false`. | ||
*/ | ||
function isHostObject(value) { | ||
// Many host objects are `Object` objects that can coerce to strings | ||
// despite having improperly defined `toString` methods. | ||
var result = false; | ||
if (value != null && typeof value.toString != 'function') { | ||
try { | ||
result = !!(value + ''); | ||
} catch (e) {} | ||
/** | ||
* Checks if `value` is a plain object, that is, an object created by the | ||
* `Object` constructor or one with a `[[Prototype]]` of `null`. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 0.8.0 | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a plain object, else `false`. | ||
* @example | ||
* | ||
* function Foo() { | ||
* this.a = 1; | ||
* } | ||
* | ||
* _.isPlainObject(new Foo); | ||
* // => false | ||
* | ||
* _.isPlainObject([1, 2, 3]); | ||
* // => false | ||
* | ||
* _.isPlainObject({ 'x': 0, 'y': 0 }); | ||
* // => true | ||
* | ||
* _.isPlainObject(Object.create(null)); | ||
* // => true | ||
*/ | ||
function isPlainObject(value) { | ||
if (!isObjectLike(value) || objectToString.call(value) != objectTag || isHostObject(value)) { | ||
return false; | ||
} | ||
return result; | ||
} | ||
module.exports = isHostObject; | ||
}); | ||
var _isHostObject$1 = interopDefault(_isHostObject); | ||
var require$$1 = Object.freeze({ | ||
default: _isHostObject$1 | ||
}); | ||
var isObjectLike = createCommonjsModule(function (module) { | ||
/** | ||
* Checks if `value` is object-like. A value is object-like if it's not `null` | ||
* and has a `typeof` result of "object". | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 4.0.0 | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is object-like, else `false`. | ||
* @example | ||
* | ||
* _.isObjectLike({}); | ||
* // => true | ||
* | ||
* _.isObjectLike([1, 2, 3]); | ||
* // => true | ||
* | ||
* _.isObjectLike(_.noop); | ||
* // => false | ||
* | ||
* _.isObjectLike(null); | ||
* // => false | ||
*/ | ||
function isObjectLike(value) { | ||
return !!value && typeof value == 'object'; | ||
} | ||
module.exports = isObjectLike; | ||
}); | ||
var isObjectLike$1 = interopDefault(isObjectLike); | ||
var require$$0$1 = Object.freeze({ | ||
default: isObjectLike$1 | ||
}); | ||
var isPlainObject = createCommonjsModule(function (module) { | ||
var getPrototype = interopDefault(require$$2), | ||
isHostObject = interopDefault(require$$1), | ||
isObjectLike = interopDefault(require$$0$1); | ||
/** `Object#toString` result references. */ | ||
var objectTag = '[object Object]'; | ||
/** Used for built-in method references. */ | ||
var funcProto = Function.prototype, | ||
objectProto = Object.prototype; | ||
/** Used to resolve the decompiled source of functions. */ | ||
var funcToString = funcProto.toString; | ||
/** Used to check objects for own properties. */ | ||
var hasOwnProperty = objectProto.hasOwnProperty; | ||
/** Used to infer the `Object` constructor. */ | ||
var objectCtorString = funcToString.call(Object); | ||
/** | ||
* Used to resolve the | ||
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) | ||
* of values. | ||
*/ | ||
var objectToString = objectProto.toString; | ||
/** | ||
* Checks if `value` is a plain object, that is, an object created by the | ||
* `Object` constructor or one with a `[[Prototype]]` of `null`. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 0.8.0 | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a plain object, else `false`. | ||
* @example | ||
* | ||
* function Foo() { | ||
* this.a = 1; | ||
* } | ||
* | ||
* _.isPlainObject(new Foo); | ||
* // => false | ||
* | ||
* _.isPlainObject([1, 2, 3]); | ||
* // => false | ||
* | ||
* _.isPlainObject({ 'x': 0, 'y': 0 }); | ||
* // => true | ||
* | ||
* _.isPlainObject(Object.create(null)); | ||
* // => true | ||
*/ | ||
function isPlainObject(value) { | ||
if (!isObjectLike(value) || objectToString.call(value) != objectTag || isHostObject(value)) { | ||
return false; | ||
} | ||
var proto = getPrototype(value); | ||
if (proto === null) { | ||
return true; | ||
} | ||
var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; | ||
return typeof Ctor == 'function' && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString; | ||
var proto = getPrototype(value); | ||
if (proto === null) { | ||
return true; | ||
} | ||
var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; | ||
return typeof Ctor == 'function' && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString; | ||
} | ||
module.exports = isPlainObject; | ||
}); | ||
function interopDefault(ex) { | ||
return ex && typeof ex === 'object' && 'default' in ex ? ex['default'] : ex; | ||
} | ||
var isPlainObject$1 = interopDefault(isPlainObject); | ||
function createCommonjsModule(fn, module) { | ||
return module = { exports: {} }, fn(module, module.exports), module.exports; | ||
} | ||
@@ -476,3 +423,3 @@ var index = createCommonjsModule(function (module) { | ||
function checkStateShape(props, methodName) { | ||
if (!isPlainObject$1(props)) { | ||
if (!isPlainObject(props)) { | ||
warning(methodName + '() in ' + connectDisplayName + ' must return a plain object. ' + ('Instead received ' + props + '.')); | ||
@@ -768,8 +715,12 @@ } | ||
exports.Provider = Provider; | ||
exports.connect = connect; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var lib = { | ||
Provider: Provider, | ||
connect: connect | ||
}; | ||
return lib; | ||
}))); | ||
//# sourceMappingURL=preact-redux.js.map |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("preact"),require("redux")):"function"==typeof define&&define.amd?define(["exports","preact","redux"],e):e(t.preactRedux=t.preactRedux||{},t.preact,t.redux)}(this,function(t,e,r){function n(){}function o(t,e){if(t===e)return!0;var r=Object.keys(t);if(r.length!==Object.keys(e).length)return!1;for(var n=Object.prototype.hasOwnProperty,o=0;o<r.length;o++)if(!n.call(e,r[o])||t[r[o]]!==e[r[o]])return!1;return!0}function s(t){return function(e){return r.bindActionCreators(t,e)}}function i(t){return t&&"object"==typeof t&&"default"in t?t.default:t}function p(t,e){return e={exports:{}},t(e,e.exports),e.exports}function a(t){return t.displayName||t.name||"Component"}function u(t,e){try{return t.apply(e)}catch(t){return z.value=t,z}}function c(t,r,n){var i=arguments.length<=3||void 0===arguments[3]?{}:arguments[3],p=!!t,c=t||E,h=void 0;h="function"==typeof r?r:r?s(r):q;var f=n||F,b=i.pure,g=void 0===b||b,v=i.withRef,S=void 0!==v&&v,O=g&&f!==F,m=B++;return function(t){function r(t,e,r){return f(t,e,r)}var n="Connect("+a(t)+")",s=function(n){function s(t,e){var r=y(this,n.call(this,t,e));return r.version=m,r.store=t.store||e.store,r.state={storeState:r.store.getState()},r.clearCache(),r}return P(s,n),s.prototype.shouldComponentUpdate=function(){return!g||this.haveOwnPropsChanged||this.hasStoreStateChanged},s.prototype.computeStateProps=function(t,e){if(!this.finalMapStateToProps)return this.configureFinalMapState(t,e);var r=t.getState();return this.doStatePropsDependOnOwnProps?this.finalMapStateToProps(r,e):this.finalMapStateToProps(r)},s.prototype.configureFinalMapState=function(t,e){var r=c(t.getState(),e),n="function"==typeof r;return this.finalMapStateToProps=n?r:c,this.doStatePropsDependOnOwnProps=1!==this.finalMapStateToProps.length,n?this.computeStateProps(t,e):r},s.prototype.computeDispatchProps=function(t,e){if(!this.finalMapDispatchToProps)return this.configureFinalMapDispatch(t,e);var r=t.dispatch;return this.doDispatchPropsDependOnOwnProps?this.finalMapDispatchToProps(r,e):this.finalMapDispatchToProps(r)},s.prototype.configureFinalMapDispatch=function(t,e){var r=h(t.dispatch,e),n="function"==typeof r;return this.finalMapDispatchToProps=n?r:h,this.doDispatchPropsDependOnOwnProps=1!==this.finalMapDispatchToProps.length,n?this.computeDispatchProps(t,e):r},s.prototype.updateStatePropsIfNeeded=function(){var t=this.computeStateProps(this.store,this.props);return(!this.stateProps||!o(t,this.stateProps))&&(this.stateProps=t,!0)},s.prototype.updateDispatchPropsIfNeeded=function(){var t=this.computeDispatchProps(this.store,this.props);return(!this.dispatchProps||!o(t,this.dispatchProps))&&(this.dispatchProps=t,!0)},s.prototype.updateMergedPropsIfNeeded=function(){var t=r(this.stateProps,this.dispatchProps,this.props);return!(this.mergedProps&&O&&o(t,this.mergedProps))&&(this.mergedProps=t,!0)},s.prototype.isSubscribed=function(){return"function"==typeof this.unsubscribe},s.prototype.trySubscribe=function(){p&&!this.unsubscribe&&(this.unsubscribe=this.store.subscribe(this.handleChange.bind(this)),this.handleChange())},s.prototype.tryUnsubscribe=function(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null)},s.prototype.componentDidMount=function(){this.trySubscribe()},s.prototype.componentWillReceiveProps=function(t){g&&o(t,this.props)||(this.haveOwnPropsChanged=!0)},s.prototype.componentWillUnmount=function(){this.tryUnsubscribe(),this.clearCache()},s.prototype.clearCache=function(){this.dispatchProps=null,this.stateProps=null,this.mergedProps=null,this.haveOwnPropsChanged=!0,this.hasStoreStateChanged=!0,this.haveStatePropsBeenPrecalculated=!1,this.statePropsPrecalculationError=null,this.renderedElement=null,this.finalMapDispatchToProps=null,this.finalMapStateToProps=null},s.prototype.handleChange=function(){if(this.unsubscribe){var t=this.store.getState(),e=this.state.storeState;if(!g||e!==t){if(g&&!this.doStatePropsDependOnOwnProps){var r=u(this.updateStatePropsIfNeeded,this);if(!r)return;r===z&&(this.statePropsPrecalculationError=z.value),this.haveStatePropsBeenPrecalculated=!0}this.hasStoreStateChanged=!0,this.setState({storeState:t})}}},s.prototype.getWrappedInstance=function(){return this.refs.wrappedInstance},s.prototype.render=function(){var r=this.haveOwnPropsChanged,n=this.hasStoreStateChanged,o=this.haveStatePropsBeenPrecalculated,s=this.statePropsPrecalculationError,i=this.renderedElement;if(this.haveOwnPropsChanged=!1,this.hasStoreStateChanged=!1,this.haveStatePropsBeenPrecalculated=!1,this.statePropsPrecalculationError=null,s)throw s;var p=!0,a=!0;g&&i&&(p=n||r&&this.doStatePropsDependOnOwnProps,a=r&&this.doDispatchPropsDependOnOwnProps);var u=!1,c=!1;o?u=!0:p&&(u=this.updateStatePropsIfNeeded()),a&&(c=this.updateDispatchPropsIfNeeded());var h=!0;return h=!!(u||c||r)&&this.updateMergedPropsIfNeeded(),!h&&i?i:this.renderedElement=S?e.h(t,d({},this.mergedProps,{ref:"wrappedInstance"})):e.h(t,this.mergedProps)},s}(e.Component);return s.displayName=n,s.WrappedComponent=t,s.contextTypes={store:l},R(s,t)}}var h={only:function(t){return t&&t[0]||null}};n.isRequired=n;var f={element:n,func:n,shape:function(){return n}},l=f.shape({subscribe:f.func.isRequired,dispatch:f.func.isRequired,getState:f.func.isRequired}),d=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},P=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)},y=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},b=function(t){function e(e,r){var n=y(this,t.call(this,e,r));return n.store=e.store,n}return P(e,t),e.prototype.getChildContext=function(){return{store:this.store}},e.prototype.render=function(){return h.only(this.props.children)},e}(e.Component);b.childContextTypes={store:l.isRequired};var g=p(function(t){function e(t,e){return function(r){return t(e(r))}}t.exports=e}),v=i(g),S=Object.freeze({default:v}),O=p(function(t){t.exports=i(S)(Object.getPrototypeOf,Object)}),m=i(O),w=Object.freeze({default:m}),C=p(function(t){function e(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}t.exports=e}),j=i(C),D=Object.freeze({default:j}),x=p(function(t){function e(t){return!!t&&"object"==typeof t}t.exports=e}),M=i(x),T=Object.freeze({default:M}),N=p(function(t){function e(t){if(!o(t)||f.call(t)!=s||n(t))return!1;var e=r(t);if(null===e)return!0;var i=c.call(e,"constructor")&&e.constructor;return"function"==typeof i&&i instanceof i&&u.call(i)==h}var r=i(w),n=i(D),o=i(T),s="[object Object]",p=Function.prototype,a=Object.prototype,u=p.toString,c=a.hasOwnProperty,h=u.call(Object),f=a.toString;t.exports=e}),I=(i(N),p(function(t){"use strict";var e={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},r={name:!0,length:!0,prototype:!0,caller:!0,arguments:!0,arity:!0},n="function"==typeof Object.getOwnPropertySymbols;t.exports=function(t,o,s){if("string"!=typeof o){var i=Object.getOwnPropertyNames(o);n&&(i=i.concat(Object.getOwnPropertySymbols(o)));for(var p=0;p<i.length;++p)if(!(e[i[p]]||r[i[p]]||s&&s[i[p]]))try{t[i[p]]=o[i[p]]}catch(t){}}return t}})),R=i(I),E=function(){return{}},q=function(t){return{dispatch:t}},F=function(t,e,r){return d({},r,t,e)},z={value:null},B=0;t.Provider=b,t.connect=c}); | ||
!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 r(){}function n(t,e){if(t===e)return!0;var r=Object.keys(t);if(r.length!==Object.keys(e).length)return!1;for(var n=Object.prototype.hasOwnProperty,o=0;o<r.length;o++)if(!n.call(e,r[o])||t[r[o]]!==e[r[o]])return!1;return!0}function o(t){return function(r){return e.bindActionCreators(t,r)}}function s(t,e){return function(r){return t(e(r))}}function i(t){return t&&"object"==typeof t&&"default"in t?t.default:t}function p(t,e){return e={exports:{}},t(e,e.exports),e.exports}function a(t){return t.displayName||t.name||"Component"}function u(t,e){try{return t.apply(e)}catch(t){return D.value=t,D}}function c(e,r,s){var i=arguments.length<=3||void 0===arguments[3]?{}:arguments[3],p=!!e,c=e||m,h=void 0;h="function"==typeof r?r:r?o(r):C;var f=s||w,b=i.pure,g=void 0===b||b,v=i.withRef,S=void 0!==v&&v,j=g&&f!==w,T=M++;return function(e){function r(t,e,r){return f(t,e,r)}var o="Connect("+a(e)+")",s=function(o){function s(t,e){var r=y(this,o.call(this,t,e));return r.version=T,r.store=t.store||e.store,r.state={storeState:r.store.getState()},r.clearCache(),r}return P(s,o),s.prototype.shouldComponentUpdate=function(){return!g||this.haveOwnPropsChanged||this.hasStoreStateChanged},s.prototype.computeStateProps=function(t,e){if(!this.finalMapStateToProps)return this.configureFinalMapState(t,e);var r=t.getState();return this.doStatePropsDependOnOwnProps?this.finalMapStateToProps(r,e):this.finalMapStateToProps(r)},s.prototype.configureFinalMapState=function(t,e){var r=c(t.getState(),e),n="function"==typeof r;return this.finalMapStateToProps=n?r:c,this.doStatePropsDependOnOwnProps=1!==this.finalMapStateToProps.length,n?this.computeStateProps(t,e):r},s.prototype.computeDispatchProps=function(t,e){if(!this.finalMapDispatchToProps)return this.configureFinalMapDispatch(t,e);var r=t.dispatch;return this.doDispatchPropsDependOnOwnProps?this.finalMapDispatchToProps(r,e):this.finalMapDispatchToProps(r)},s.prototype.configureFinalMapDispatch=function(t,e){var r=h(t.dispatch,e),n="function"==typeof r;return this.finalMapDispatchToProps=n?r:h,this.doDispatchPropsDependOnOwnProps=1!==this.finalMapDispatchToProps.length,n?this.computeDispatchProps(t,e):r},s.prototype.updateStatePropsIfNeeded=function(){var t=this.computeStateProps(this.store,this.props);return(!this.stateProps||!n(t,this.stateProps))&&(this.stateProps=t,!0)},s.prototype.updateDispatchPropsIfNeeded=function(){var t=this.computeDispatchProps(this.store,this.props);return(!this.dispatchProps||!n(t,this.dispatchProps))&&(this.dispatchProps=t,!0)},s.prototype.updateMergedPropsIfNeeded=function(){var t=r(this.stateProps,this.dispatchProps,this.props);return!(this.mergedProps&&j&&n(t,this.mergedProps))&&(this.mergedProps=t,!0)},s.prototype.isSubscribed=function(){return"function"==typeof this.unsubscribe},s.prototype.trySubscribe=function(){p&&!this.unsubscribe&&(this.unsubscribe=this.store.subscribe(this.handleChange.bind(this)),this.handleChange())},s.prototype.tryUnsubscribe=function(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null)},s.prototype.componentDidMount=function(){this.trySubscribe()},s.prototype.componentWillReceiveProps=function(t){g&&n(t,this.props)||(this.haveOwnPropsChanged=!0)},s.prototype.componentWillUnmount=function(){this.tryUnsubscribe(),this.clearCache()},s.prototype.clearCache=function(){this.dispatchProps=null,this.stateProps=null,this.mergedProps=null,this.haveOwnPropsChanged=!0,this.hasStoreStateChanged=!0,this.haveStatePropsBeenPrecalculated=!1,this.statePropsPrecalculationError=null,this.renderedElement=null,this.finalMapDispatchToProps=null,this.finalMapStateToProps=null},s.prototype.handleChange=function(){if(this.unsubscribe){var t=this.store.getState(),e=this.state.storeState;if(!g||e!==t){if(g&&!this.doStatePropsDependOnOwnProps){var r=u(this.updateStatePropsIfNeeded,this);if(!r)return;r===D&&(this.statePropsPrecalculationError=D.value),this.haveStatePropsBeenPrecalculated=!0}this.hasStoreStateChanged=!0,this.setState({storeState:t})}}},s.prototype.getWrappedInstance=function(){return this.refs.wrappedInstance},s.prototype.render=function(){var r=this.haveOwnPropsChanged,n=this.hasStoreStateChanged,o=this.haveStatePropsBeenPrecalculated,s=this.statePropsPrecalculationError,i=this.renderedElement;if(this.haveOwnPropsChanged=!1,this.hasStoreStateChanged=!1,this.haveStatePropsBeenPrecalculated=!1,this.statePropsPrecalculationError=null,s)throw s;var p=!0,a=!0;g&&i&&(p=n||r&&this.doStatePropsDependOnOwnProps,a=r&&this.doDispatchPropsDependOnOwnProps);var u=!1,c=!1;o?u=!0:p&&(u=this.updateStatePropsIfNeeded()),a&&(c=this.updateDispatchPropsIfNeeded());var h=!0;return h=!!(u||c||r)&&this.updateMergedPropsIfNeeded(),!h&&i?i:this.renderedElement=S?t.h(e,d({},this.mergedProps,{ref:"wrappedInstance"})):t.h(e,this.mergedProps)},s}(t.Component);return s.displayName=o,s.WrappedComponent=e,s.contextTypes={store:l},O(s,e)}}var h={only:function(t){return t&&t[0]||null}};r.isRequired=r;var f={element:r,func:r,shape:function(){return r}},l=f.shape({subscribe:f.func.isRequired,dispatch:f.func.isRequired,getState:f.func.isRequired}),d=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},P=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)},y=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},b=function(t){function e(e,r){var n=y(this,t.call(this,e,r));return n.store=e.store,n}return P(e,t),e.prototype.getChildContext=function(){return{store:this.store}},e.prototype.render=function(){return h.only(this.props.children)},e}(t.Component);b.childContextTypes={store:l.isRequired};var g=(s(Object.getPrototypeOf,Object),Function.prototype),v=(Object.prototype,g.toString),S=(v.call(Object),p(function(t){"use strict";var e={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},r={name:!0,length:!0,prototype:!0,caller:!0,arguments:!0,arity:!0},n="function"==typeof Object.getOwnPropertySymbols;t.exports=function(t,o,s){if("string"!=typeof o){var i=Object.getOwnPropertyNames(o);n&&(i=i.concat(Object.getOwnPropertySymbols(o)));for(var p=0;p<i.length;++p)if(!(e[i[p]]||r[i[p]]||s&&s[i[p]]))try{t[i[p]]=o[i[p]]}catch(t){}}return t}})),O=i(S),m=function(){return{}},C=function(t){return{dispatch:t}},w=function(t,e,r){return d({},r,t,e)},D={value:null},M=0;return{Provider:b,connect:c}}); | ||
//# sourceMappingURL=preact-redux.min.js.map |
{ | ||
"name": "preact-redux", | ||
"amdName": "preactRedux", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Wraps react-redux up for Preact, without preact-compat", | ||
@@ -41,12 +41,13 @@ "main": "dist/preact-redux.js", | ||
"devDependencies": { | ||
"babel-cli": "^6.9.0", | ||
"babel-core": "^6.9.1", | ||
"babel-cli": "^6.14.0", | ||
"babel-core": "^6.14.0", | ||
"babel-eslint": "^6.0.4", | ||
"babel-loader": "^6.2.4", | ||
"babel-loader": "^6.2.5", | ||
"babel-plugin-transform-class-properties": "^6.9.1", | ||
"babel-plugin-transform-es2015-classes": "^6.9.0", | ||
"babel-plugin-transform-es2015-classes": "^6.14.0", | ||
"babel-plugin-transform-node-env-inline": "^6.8.0", | ||
"babel-plugin-transform-object-assign": "^6.8.0", | ||
"babel-plugin-transform-react-jsx": "^6.8.0", | ||
"babel-plugin-transform-react-remove-prop-types": "^0.2.7", | ||
"babel-preset-es2015": "^6.9.0", | ||
"babel-preset-es2015": "^6.14.0", | ||
"babel-preset-es2015-minimal": "^2.0.0", | ||
@@ -57,7 +58,7 @@ "babel-preset-es2015-minimal-rollup": "^2.0.0", | ||
"chai": "^3.5.0", | ||
"diff": "^2.2.3", | ||
"eslint": "^2.11.1", | ||
"eslint-plugin-react": "^5.1.1", | ||
"diff": "^3.0.0", | ||
"eslint": "^3.3.1", | ||
"eslint-plugin-react": "^6.1.2", | ||
"gzip-size-cli": "^1.0.0", | ||
"karma": "^0.13.22", | ||
"karma": "^1.2.0", | ||
"karma-chai-sinon": "^0.1.5", | ||
@@ -70,6 +71,6 @@ "karma-mocha": "^1.0.1", | ||
"mkdirp": "^0.5.1", | ||
"mocha": "^2.5.0", | ||
"npm-run-all": "^2.0.0", | ||
"mocha": "^3.0.2", | ||
"npm-run-all": "^3.0.0", | ||
"phantomjs-prebuilt": "^2.1.7", | ||
"preact": "^5.6.0", | ||
"preact": "^5.7.0", | ||
"pretty-bytes-cli": "^1.0.0", | ||
@@ -79,12 +80,15 @@ "react-redux": "^4.4.5", | ||
"rimraf": "^2.5.1", | ||
"rollup": "^0.34.9", | ||
"rollup": "^0.34.10", | ||
"rollup-plugin-alias": "^1.2.0", | ||
"rollup-plugin-babel": "^2.4.0", | ||
"rollup-plugin-commonjs": "^3.3.1", | ||
"rollup-plugin-es3": "^1.0.3", | ||
"rollup-plugin-memory": "^2.0.0", | ||
"rollup-plugin-node-resolve": "^2.0.0", | ||
"rollup-plugin-replace": "^1.1.1", | ||
"sinon": "^1.17.4", | ||
"sinon-chai": "^2.8.0", | ||
"uglify-js": "^2.6.1", | ||
"webpack": "^1.13.1" | ||
"uglify-js": "^2.7.3", | ||
"webpack": "^1.13.2" | ||
} | ||
} |
import fs from 'fs'; | ||
import memory from 'rollup-plugin-memory'; | ||
import alias from 'rollup-plugin-alias'; | ||
import commonjs from 'rollup-plugin-commonjs'; | ||
import nodeResolve from 'rollup-plugin-node-resolve'; | ||
import replace from 'rollup-plugin-replace'; | ||
import babel from 'rollup-plugin-babel'; | ||
import es3 from 'rollup-plugin-es3'; | ||
@@ -15,6 +18,20 @@ var babelRc = JSON.parse(fs.readFileSync('.babelrc','utf8')); | ||
export default { | ||
exports: 'named', | ||
exports: 'default', | ||
external: external, | ||
useStrict: false, | ||
plugins: [ | ||
memory({ | ||
path: 'src/index', | ||
contents: "import * as lib from './index'; export default lib;" | ||
}), | ||
{ | ||
// This insane thing transforms Lodash CommonJS modules to ESModules. Doing so shaves 500b (20%) off the library size. | ||
load: function(id) { | ||
if (id.match(/\blodash\b/)) { | ||
return fs.readFileSync(id, 'utf8') | ||
.replace(/\b(?:var\s+)?([\w$]+)\s*=\s*require\((['"])(.*?)\2\)\s*[,;]/g, 'import $1 from $2$3$2;') | ||
.replace(/\bmodule\.exports\s*=\s*/, 'export default '); | ||
} | ||
} | ||
}, | ||
alias({ | ||
@@ -39,4 +56,8 @@ 'react-redux': 'node_modules/react-redux/src/index.js', | ||
plugins: babelRc.plugins | ||
}) | ||
}), | ||
replace({ | ||
'process.env.NODE_ENV': JSON.stringify('production') | ||
}), | ||
es3() | ||
] | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
40049
-59.82%48
9.09%801
-1.84%