@devexpress/dx-core
Advanced tools
Comparing version 1.0.0-alpha.6 to 1.0.0-alpha.7
/** | ||
* Bundle of @devexpress/dx-core | ||
* Generated: 2017-07-24 | ||
* Version: 1.0.0-alpha.6 | ||
* Generated: 2017-08-07 | ||
* Version: 1.0.0-alpha.7 | ||
* License: https://js.devexpress.com/Licensing | ||
*/ | ||
var sortPlugins = function sortPlugins(plugins) { | ||
var result = plugins.slice(); | ||
result.sort(function (a, b) { | ||
var aPosition = a.position(); | ||
var bPosition = b.position(); | ||
for (var i = 0; i < Math.min(aPosition.length, bPosition.length); i += 1) { | ||
if (aPosition[i] < bPosition[i]) return -1; | ||
if (aPosition[i] > bPosition[i]) return 1; | ||
} | ||
return aPosition.length - bPosition.length; | ||
var compare = function compare(a, b) { | ||
var aPosition = a.position(); | ||
var bPosition = b.position(); | ||
for (var i = 0; i < Math.min(aPosition.length, bPosition.length); i += 1) { | ||
if (aPosition[i] < bPosition[i]) return -1; | ||
if (aPosition[i] > bPosition[i]) return 1; | ||
} | ||
return aPosition.length - bPosition.length; | ||
}; | ||
var insertPlugin = function insertPlugin(array, newItem) { | ||
var result = array.slice(); | ||
var targetIndex = array.findIndex(function (item) { | ||
return compare(newItem, item) < 0; | ||
}); | ||
result.splice(targetIndex < 0 ? array.length : targetIndex, 0, newItem); | ||
return result; | ||
@@ -46,2 +51,56 @@ }; | ||
var toConsumableArray = function (arr) { | ||
if (Array.isArray(arr)) { | ||
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} else { | ||
return Array.from(arr); | ||
} | ||
}; | ||
var getDependencyError = function getDependencyError(pluginName, dependencyName) { | ||
return new Error('The \'' + pluginName + '\' plugin requires \'' + dependencyName + '\' to be defined before it.'); | ||
}; | ||
var PluginHost = function () { | ||
@@ -57,5 +116,29 @@ function PluginHost() { | ||
createClass(PluginHost, [{ | ||
key: 'ensureDependencies', | ||
value: function ensureDependencies() { | ||
var defined = new Set(); | ||
var unresolved = this.plugins.slice().reverse().reduce(function (acc, plugin) { | ||
if (!plugin.pluginName) return acc; | ||
defined.add(plugin.pluginName); | ||
return [].concat(toConsumableArray(acc.filter(function (item) { | ||
return item.dependencyName !== plugin.pluginName; | ||
})), toConsumableArray(plugin.dependencies.filter(function (dependency) { | ||
return !dependency.optional || defined.has(dependency.pluginName); | ||
}).map(function (dependency) { | ||
return { | ||
pluginName: plugin.pluginName, | ||
dependencyName: dependency.pluginName | ||
}; | ||
}))); | ||
}, [])[0]; | ||
if (unresolved) { | ||
throw getDependencyError(unresolved.pluginName, unresolved.dependencyName); | ||
} | ||
} | ||
}, { | ||
key: 'registerPlugin', | ||
value: function registerPlugin(plugin) { | ||
this.plugins.push(plugin); | ||
this.plugins = insertPlugin(this.plugins, plugin); | ||
this.cleanPluginsCache(); | ||
@@ -72,3 +155,3 @@ } | ||
value: function cleanPluginsCache() { | ||
this.unordered = true; | ||
this.validationRequired = true; | ||
this.gettersCache = {}; | ||
@@ -81,6 +164,7 @@ } | ||
if (this.unordered) { | ||
this.plugins = sortPlugins(this.plugins); | ||
this.unordered = false; | ||
if (this.validationRequired) { | ||
this.ensureDependencies(); | ||
this.validationRequired = false; | ||
} | ||
if (!this.gettersCache[key]) { | ||
@@ -87,0 +171,0 @@ this.gettersCache[key] = this.plugins.map(function (plugin) { |
/** | ||
* Bundle of @devexpress/dx-core | ||
* Generated: 2017-07-24 | ||
* Version: 1.0.0-alpha.6 | ||
* Generated: 2017-08-07 | ||
* Version: 1.0.0-alpha.7 | ||
* License: https://js.devexpress.com/Licensing | ||
@@ -14,13 +14,18 @@ */ | ||
var sortPlugins = function sortPlugins(plugins) { | ||
var result = plugins.slice(); | ||
result.sort(function (a, b) { | ||
var aPosition = a.position(); | ||
var bPosition = b.position(); | ||
for (var i = 0; i < Math.min(aPosition.length, bPosition.length); i += 1) { | ||
if (aPosition[i] < bPosition[i]) return -1; | ||
if (aPosition[i] > bPosition[i]) return 1; | ||
} | ||
return aPosition.length - bPosition.length; | ||
var compare = function compare(a, b) { | ||
var aPosition = a.position(); | ||
var bPosition = b.position(); | ||
for (var i = 0; i < Math.min(aPosition.length, bPosition.length); i += 1) { | ||
if (aPosition[i] < bPosition[i]) return -1; | ||
if (aPosition[i] > bPosition[i]) return 1; | ||
} | ||
return aPosition.length - bPosition.length; | ||
}; | ||
var insertPlugin = function insertPlugin(array, newItem) { | ||
var result = array.slice(); | ||
var targetIndex = array.findIndex(function (item) { | ||
return compare(newItem, item) < 0; | ||
}); | ||
result.splice(targetIndex < 0 ? array.length : targetIndex, 0, newItem); | ||
return result; | ||
@@ -53,2 +58,56 @@ }; | ||
var toConsumableArray = function (arr) { | ||
if (Array.isArray(arr)) { | ||
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} else { | ||
return Array.from(arr); | ||
} | ||
}; | ||
var getDependencyError = function getDependencyError(pluginName, dependencyName) { | ||
return new Error('The \'' + pluginName + '\' plugin requires \'' + dependencyName + '\' to be defined before it.'); | ||
}; | ||
var PluginHost = function () { | ||
@@ -64,5 +123,29 @@ function PluginHost() { | ||
createClass(PluginHost, [{ | ||
key: 'ensureDependencies', | ||
value: function ensureDependencies() { | ||
var defined = new Set(); | ||
var unresolved = this.plugins.slice().reverse().reduce(function (acc, plugin) { | ||
if (!plugin.pluginName) return acc; | ||
defined.add(plugin.pluginName); | ||
return [].concat(toConsumableArray(acc.filter(function (item) { | ||
return item.dependencyName !== plugin.pluginName; | ||
})), toConsumableArray(plugin.dependencies.filter(function (dependency) { | ||
return !dependency.optional || defined.has(dependency.pluginName); | ||
}).map(function (dependency) { | ||
return { | ||
pluginName: plugin.pluginName, | ||
dependencyName: dependency.pluginName | ||
}; | ||
}))); | ||
}, [])[0]; | ||
if (unresolved) { | ||
throw getDependencyError(unresolved.pluginName, unresolved.dependencyName); | ||
} | ||
} | ||
}, { | ||
key: 'registerPlugin', | ||
value: function registerPlugin(plugin) { | ||
this.plugins.push(plugin); | ||
this.plugins = insertPlugin(this.plugins, plugin); | ||
this.cleanPluginsCache(); | ||
@@ -79,3 +162,3 @@ } | ||
value: function cleanPluginsCache() { | ||
this.unordered = true; | ||
this.validationRequired = true; | ||
this.gettersCache = {}; | ||
@@ -88,6 +171,7 @@ } | ||
if (this.unordered) { | ||
this.plugins = sortPlugins(this.plugins); | ||
this.unordered = false; | ||
if (this.validationRequired) { | ||
this.ensureDependencies(); | ||
this.validationRequired = false; | ||
} | ||
if (!this.gettersCache[key]) { | ||
@@ -94,0 +178,0 @@ this.gettersCache[key] = this.plugins.map(function (plugin) { |
{ | ||
"name": "@devexpress/dx-core", | ||
"version": "1.0.0-alpha.6", | ||
"version": "1.0.0-alpha.7", | ||
"description": "Core library for DevExtreme Reactive Components", | ||
@@ -5,0 +5,0 @@ "author": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38901
472