fix(system): allow wrapping components both from presets and plugins (#9919)
Refs #7232
This commit is contained in:
@@ -70,13 +70,6 @@ const defaultOptions = Object.freeze({
|
||||
// Plugins; ( loaded after presets )
|
||||
plugins: [],
|
||||
|
||||
pluginsOptions: {
|
||||
// Behavior during plugin registration. Can be :
|
||||
// - legacy (default) : the current behavior for backward compatibility – last plugin takes precedence over the others
|
||||
// - chain : chain wrapComponents when targeting the same core component
|
||||
pluginLoadType: "legacy",
|
||||
},
|
||||
|
||||
initialState: {},
|
||||
|
||||
// Inline Plugin
|
||||
|
||||
@@ -37,7 +37,6 @@ const systemFactorization = (options) => {
|
||||
configs: options.configs,
|
||||
},
|
||||
plugins: options.presets,
|
||||
pluginsOptions: options.pluginsOptions,
|
||||
state,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,11 +55,6 @@ const mappings = {
|
||||
typeCaster: arrayTypeCaster,
|
||||
defaultValue: defaultOptions.plugins,
|
||||
},
|
||||
pluginsOptions: {
|
||||
typeCaster: objectTypeCaster,
|
||||
pluginsOptions: defaultOptions.pluginsOptions,
|
||||
},
|
||||
"pluginsOptions.pluginsLoadType": { typeCaster: stringTypeCaster },
|
||||
presets: {
|
||||
typeCaster: arrayTypeCaster,
|
||||
defaultValue: defaultOptions.presets,
|
||||
|
||||
@@ -35,7 +35,6 @@ export default class Store {
|
||||
deepExtend(this, {
|
||||
state: {},
|
||||
plugins: [],
|
||||
pluginsOptions: {},
|
||||
system: {
|
||||
configs: {},
|
||||
fn: {},
|
||||
@@ -64,7 +63,7 @@ export default class Store {
|
||||
}
|
||||
|
||||
register(plugins, rebuild=true) {
|
||||
var pluginSystem = combinePlugins(plugins, this.getSystem(), this.pluginsOptions)
|
||||
var pluginSystem = combinePlugins(plugins, this.getSystem())
|
||||
systemExtend(this.system, pluginSystem)
|
||||
if(rebuild) {
|
||||
this.buildSystem()
|
||||
@@ -311,21 +310,19 @@ export default class Store {
|
||||
|
||||
}
|
||||
|
||||
function combinePlugins(plugins, toolbox, pluginOptions) {
|
||||
function combinePlugins(plugins, toolbox) {
|
||||
if(isObject(plugins) && !isArray(plugins)) {
|
||||
return merge({}, plugins)
|
||||
}
|
||||
|
||||
if(isFunc(plugins)) {
|
||||
return combinePlugins(plugins(toolbox), toolbox, pluginOptions)
|
||||
return combinePlugins(plugins(toolbox), toolbox)
|
||||
}
|
||||
|
||||
if(isArray(plugins)) {
|
||||
const dest = pluginOptions.pluginLoadType === "chain" ? toolbox.getComponents() : {}
|
||||
|
||||
return plugins
|
||||
.map(plugin => combinePlugins(plugin, toolbox, pluginOptions))
|
||||
.reduce(systemExtend, dest)
|
||||
.map(plugin => combinePlugins(plugin, toolbox))
|
||||
.reduce(systemExtend, { components: { ...toolbox.getComponents() } })
|
||||
}
|
||||
|
||||
return {}
|
||||
|
||||
Reference in New Issue
Block a user