@remax/framework-shared
Version:
使用真正的 React 构建跨平台小程序
67 lines (66 loc) • 2.66 kB
JavaScript
var PluginDriver = /** @class */ (function () {
function PluginDriver(plugins) {
this.plugins = plugins;
}
PluginDriver.prototype.onAppConfig = function (config) {
return this.plugins.reduce(function (acc, plugin) {
if (typeof plugin.onAppConfig === 'function') {
acc = plugin.onAppConfig({ config: acc });
}
return acc;
}, config);
};
PluginDriver.prototype.onPageConfig = function (_a) {
var config = _a.config, page = _a.page;
return this.plugins.reduce(function (acc, plugin) {
if (typeof plugin.onPageConfig === 'function') {
acc = plugin.onPageConfig({ config: acc, page: page });
}
return acc;
}, config);
};
PluginDriver.prototype.onAppComponent = function (component) {
return this.plugins.reduce(function (acc, plugin) {
if (typeof plugin.onAppComponent === 'function') {
acc = plugin.onAppComponent({ component: acc });
}
return acc;
}, component);
};
PluginDriver.prototype.onPageComponent = function (_a) {
var component = _a.component, page = _a.page;
return this.plugins.reduce(function (acc, plugin) {
if (typeof plugin.onPageComponent === 'function') {
acc = plugin.onPageComponent({ component: acc, page: page });
}
return acc;
}, component);
};
PluginDriver.prototype.onMiniComponent = function (_a) {
var component = _a.component, context = _a.context;
return this.plugins.reduce(function (acc, plugin) {
if (typeof plugin.onMiniComponent === 'function') {
acc = plugin.onMiniComponent({ component: acc, context: context });
}
return acc;
}, component);
};
PluginDriver.prototype.onCreateHostComponent = function (component) {
return this.plugins.reduce(function (acc, plugin) {
if (typeof plugin.onCreateHostComponent === 'function') {
acc = plugin.onCreateHostComponent({ component: acc });
}
return acc;
}, component);
};
PluginDriver.prototype.onCreateHostComponentElement = function (element) {
return this.plugins.reduce(function (acc, plugin) {
if (typeof plugin.onCreateHostComponentElement === 'function') {
acc = plugin.onCreateHostComponentElement({ element: acc });
}
return acc;
}, element);
};
return PluginDriver;
}());
export default PluginDriver;