@devexpress/dx-react-core
Advanced tools
Comparing version
/** | ||
* Bundle of @devexpress/dx-react-core | ||
* Generated: 2017-08-07 | ||
* Version: 1.0.0-alpha.7 | ||
* Generated: 2017-08-21 | ||
* Version: 1.0.0-alpha.8 | ||
* License: https://js.devexpress.com/Licensing | ||
@@ -10,51 +10,5 @@ */ | ||
import PropTypes from 'prop-types'; | ||
import { EventEmitter, PluginHost } from '@devexpress/dx-core'; | ||
import { EventEmitter, PluginHost, argumentsShallowEqual, shallowEqual } from '@devexpress/dx-core'; | ||
import { findDOMNode } from 'react-dom'; | ||
function shallowEqual(objA, objB) { | ||
if (objA === objB) { | ||
return true; | ||
} | ||
var keysA = Object.keys(objA); | ||
var keysB = Object.keys(objB); | ||
if (keysA.length !== keysB.length) { | ||
return false; | ||
} | ||
// Test for A's keys different from B. | ||
var hasOwn = Object.prototype.hasOwnProperty; | ||
for (var i = 0; i < keysA.length; i += 1) { | ||
if (!hasOwn.call(objB, keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) { | ||
return false; | ||
} | ||
var valA = objA[keysA[i]]; | ||
var valB = objB[keysA[i]]; | ||
if (valA !== valB) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
function argumentsShallowEqual(prev, next) { | ||
if (prev === null || next === null || prev.length !== next.length) { | ||
return false; | ||
} | ||
var length = prev.length; | ||
for (var i = 0; i < length; i += 1) { | ||
if (prev[i] !== next[i]) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
var getAction = function getAction(pluginHost, actionName) { | ||
@@ -236,18 +190,2 @@ var actions = pluginHost.collect(actionName + "Action").reverse(); | ||
function getterMemoize(func) { | ||
var lastArg = null; | ||
var lastResult = null; | ||
return function () { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
if (lastArg === null || !argumentsShallowEqual(lastArg, args)) { | ||
lastResult = func.apply(undefined, args); | ||
} | ||
lastArg = args; | ||
return lastResult; | ||
}; | ||
} | ||
var UPDATE_CONNECTION = 'updateConnection'; | ||
@@ -269,8 +207,9 @@ | ||
var pluginHost = this.context.pluginHost; | ||
var _props = this.props, | ||
name = _props.name, | ||
pureComputed = _props.pureComputed; | ||
var name = this.props.name; | ||
var pureComputedMemoized = getterMemoize(pureComputed); | ||
var lastComputed = void 0; | ||
var lastGetterDependencies = {}; | ||
var lastResult = void 0; | ||
this.plugin = defineProperty({ | ||
@@ -291,20 +230,44 @@ position: function position() { | ||
}(function (original) { | ||
var _props2 = _this2.props, | ||
value = _props2.value, | ||
connectArgs = _props2.connectArgs; | ||
var _props = _this2.props, | ||
value = _props.value, | ||
computed = _props.computed; | ||
if (value !== undefined) return value; | ||
var args = []; | ||
if (connectArgs) { | ||
var getter = function getter(getterName) { | ||
if (getterName === name) return original; | ||
var getGetterValue = function getGetterValue(getterName) { | ||
return getterName === name ? original : pluginHost.get(getterName + 'Getter', _this2.plugin); | ||
}; | ||
return pluginHost.get(getterName + 'Getter', _this2.plugin); | ||
}; | ||
args = connectArgs(getter, function (actionName) { | ||
return getAction(pluginHost, actionName); | ||
var currentGetterDependencies = Object.keys(lastGetterDependencies).reduce(function (acc, getterName) { | ||
return Object.assign(acc, defineProperty({}, getterName, getGetterValue(getterName))); | ||
}, {}); | ||
if (computed === lastComputed && shallowEqual(lastGetterDependencies, currentGetterDependencies)) { | ||
return lastResult; | ||
} | ||
lastComputed = computed; | ||
lastGetterDependencies = {}; | ||
var getters = pluginHost.knownKeys('Getter').reduce(function (acc, getterName) { | ||
Object.defineProperty(acc, getterName, { | ||
get: function get$$1() { | ||
var result = getGetterValue(getterName); | ||
lastGetterDependencies[getterName] = result; | ||
return result; | ||
} | ||
}); | ||
} | ||
return pureComputedMemoized.apply(undefined, toConsumableArray(args)); | ||
return acc; | ||
}, {}); | ||
var actions = pluginHost.knownKeys('Action').reduce(function (acc, actionName) { | ||
Object.defineProperty(acc, actionName, { | ||
get: function get$$1() { | ||
return getAction(pluginHost, actionName); | ||
} | ||
}); | ||
return acc; | ||
}, {}); | ||
lastResult = computed(getters, actions); | ||
return lastResult; | ||
})); | ||
@@ -343,4 +306,3 @@ | ||
value: PropTypes.any, // eslint-disable-line react/forbid-prop-types | ||
pureComputed: PropTypes.func, | ||
connectArgs: PropTypes.func | ||
computed: PropTypes.func | ||
}; | ||
@@ -350,4 +312,3 @@ | ||
value: undefined, | ||
pureComputed: null, | ||
connectArgs: null, | ||
computed: null, | ||
position: null | ||
@@ -902,2 +863,7 @@ }; | ||
}, { | ||
key: 'componentWillUpdate', | ||
value: function componentWillUpdate() { | ||
this.context.pluginHost.ensureDependencies(); | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
@@ -904,0 +870,0 @@ value: function componentWillUnmount() { |
/** | ||
* Bundle of @devexpress/dx-react-core | ||
* Generated: 2017-08-07 | ||
* Version: 1.0.0-alpha.7 | ||
* Generated: 2017-08-21 | ||
* Version: 1.0.0-alpha.8 | ||
* License: https://js.devexpress.com/Licensing | ||
@@ -17,48 +17,2 @@ */ | ||
function shallowEqual(objA, objB) { | ||
if (objA === objB) { | ||
return true; | ||
} | ||
var keysA = Object.keys(objA); | ||
var keysB = Object.keys(objB); | ||
if (keysA.length !== keysB.length) { | ||
return false; | ||
} | ||
// Test for A's keys different from B. | ||
var hasOwn = Object.prototype.hasOwnProperty; | ||
for (var i = 0; i < keysA.length; i += 1) { | ||
if (!hasOwn.call(objB, keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) { | ||
return false; | ||
} | ||
var valA = objA[keysA[i]]; | ||
var valB = objB[keysA[i]]; | ||
if (valA !== valB) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
function argumentsShallowEqual(prev, next) { | ||
if (prev === null || next === null || prev.length !== next.length) { | ||
return false; | ||
} | ||
var length = prev.length; | ||
for (var i = 0; i < length; i += 1) { | ||
if (prev[i] !== next[i]) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
var getAction = function getAction(pluginHost, actionName) { | ||
@@ -240,18 +194,2 @@ var actions = pluginHost.collect(actionName + "Action").reverse(); | ||
function getterMemoize(func) { | ||
var lastArg = null; | ||
var lastResult = null; | ||
return function () { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
if (lastArg === null || !argumentsShallowEqual(lastArg, args)) { | ||
lastResult = func.apply(undefined, args); | ||
} | ||
lastArg = args; | ||
return lastResult; | ||
}; | ||
} | ||
var UPDATE_CONNECTION = 'updateConnection'; | ||
@@ -273,8 +211,9 @@ | ||
var pluginHost = this.context.pluginHost; | ||
var _props = this.props, | ||
name = _props.name, | ||
pureComputed = _props.pureComputed; | ||
var name = this.props.name; | ||
var pureComputedMemoized = getterMemoize(pureComputed); | ||
var lastComputed = void 0; | ||
var lastGetterDependencies = {}; | ||
var lastResult = void 0; | ||
this.plugin = defineProperty({ | ||
@@ -295,20 +234,44 @@ position: function position() { | ||
}(function (original) { | ||
var _props2 = _this2.props, | ||
value = _props2.value, | ||
connectArgs = _props2.connectArgs; | ||
var _props = _this2.props, | ||
value = _props.value, | ||
computed = _props.computed; | ||
if (value !== undefined) return value; | ||
var args = []; | ||
if (connectArgs) { | ||
var getter = function getter(getterName) { | ||
if (getterName === name) return original; | ||
var getGetterValue = function getGetterValue(getterName) { | ||
return getterName === name ? original : pluginHost.get(getterName + 'Getter', _this2.plugin); | ||
}; | ||
return pluginHost.get(getterName + 'Getter', _this2.plugin); | ||
}; | ||
args = connectArgs(getter, function (actionName) { | ||
return getAction(pluginHost, actionName); | ||
var currentGetterDependencies = Object.keys(lastGetterDependencies).reduce(function (acc, getterName) { | ||
return Object.assign(acc, defineProperty({}, getterName, getGetterValue(getterName))); | ||
}, {}); | ||
if (computed === lastComputed && _devexpress_dxCore.shallowEqual(lastGetterDependencies, currentGetterDependencies)) { | ||
return lastResult; | ||
} | ||
lastComputed = computed; | ||
lastGetterDependencies = {}; | ||
var getters = pluginHost.knownKeys('Getter').reduce(function (acc, getterName) { | ||
Object.defineProperty(acc, getterName, { | ||
get: function get$$1() { | ||
var result = getGetterValue(getterName); | ||
lastGetterDependencies[getterName] = result; | ||
return result; | ||
} | ||
}); | ||
} | ||
return pureComputedMemoized.apply(undefined, toConsumableArray(args)); | ||
return acc; | ||
}, {}); | ||
var actions = pluginHost.knownKeys('Action').reduce(function (acc, actionName) { | ||
Object.defineProperty(acc, actionName, { | ||
get: function get$$1() { | ||
return getAction(pluginHost, actionName); | ||
} | ||
}); | ||
return acc; | ||
}, {}); | ||
lastResult = computed(getters, actions); | ||
return lastResult; | ||
})); | ||
@@ -347,4 +310,3 @@ | ||
value: PropTypes.any, // eslint-disable-line react/forbid-prop-types | ||
pureComputed: PropTypes.func, | ||
connectArgs: PropTypes.func | ||
computed: PropTypes.func | ||
}; | ||
@@ -354,4 +316,3 @@ | ||
value: undefined, | ||
pureComputed: null, | ||
connectArgs: null, | ||
computed: null, | ||
position: null | ||
@@ -613,3 +574,3 @@ }; | ||
value: function shouldComponentUpdate(nextProps, nextState) { | ||
return !shallowEqual(this.props.params, nextProps.params) || !shallowEqual(this.state.props, nextState.props) || this.props.content !== nextProps.content; | ||
return !_devexpress_dxCore.shallowEqual(this.props.params, nextProps.params) || !_devexpress_dxCore.shallowEqual(this.state.props, nextState.props) || this.props.content !== nextProps.content; | ||
} | ||
@@ -733,3 +694,3 @@ }, { | ||
value: function shouldComponentUpdate(nextProps) { | ||
return !shallowEqual(this.props.params, nextProps.params); | ||
return !_devexpress_dxCore.shallowEqual(this.props.params, nextProps.params); | ||
} | ||
@@ -908,2 +869,7 @@ }, { | ||
}, { | ||
key: 'componentWillUpdate', | ||
value: function componentWillUpdate() { | ||
this.context.pluginHost.ensureDependencies(); | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
@@ -953,3 +919,3 @@ value: function componentWillUnmount() { | ||
var args = watch(); | ||
if (lastArg === null || !argumentsShallowEqual(lastArg, args)) { | ||
if (lastArg === null || !_devexpress_dxCore.argumentsShallowEqual(lastArg, args)) { | ||
onChange(args); | ||
@@ -956,0 +922,0 @@ } |
{ | ||
"name": "@devexpress/dx-react-core", | ||
"version": "1.0.0-alpha.7", | ||
"version": "1.0.0-alpha.8", | ||
"description": "Core library for DevExtreme React Components", | ||
@@ -52,3 +52,3 @@ "author": { | ||
"devDependencies": { | ||
"@devexpress/dx-testing": "1.0.0-alpha.7", | ||
"@devexpress/dx-testing": "1.0.0-alpha.8", | ||
"babel-cli": "^6.24.1", | ||
@@ -83,3 +83,3 @@ "babel-core": "^6.25.0", | ||
"dependencies": { | ||
"@devexpress/dx-core": "1.0.0-alpha.7", | ||
"@devexpress/dx-core": "1.0.0-alpha.8", | ||
"prop-types": "^15.5.8" | ||
@@ -86,0 +86,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
181812
-1.16%2506
-2.03%+ Added
- Removed