import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
import { PluginsContainer } from "./PluginsContainer";
import { renderPlugins, renderPlugin } from "./app/index";
var plugins = new PluginsContainer();

var registerPlugins = function registerPlugins() {
  plugins.register.apply(plugins, arguments);
};

var registerCustoms = function registerCustoms(args, type) {
  if (plugins.currentType && plugins.currentType === type) {// 不需要注册
  } else {
    if (plugins.currentType) {
      // 先卸载
      unregisterCustomPlugins();
    } // 注册


    plugins.currentType = type;
    plugins.registerCustom.apply(plugins, _toConsumableArray(args));
  }
};

var getPlugins = function getPlugins(type) {
  if (!type) {
    return plugins.all();
  }

  return plugins.byType(type);
};

var getPlugin = function getPlugin(name) {
  return plugins.byName(name);
};

var unregisterPlugin = function unregisterPlugin(name) {
  return plugins.unregister(name);
};

var unregisterCustomPlugins = function unregisterCustomPlugins() {
  if (plugins.customPluginNames.length > 0) {
    plugins.customPluginNames.forEach(function (name) {
      unregisterPlugin(name);
    });
    plugins.customPluginNames = [];
  }
};

export { PluginsContainer, plugins, registerPlugins, registerCustoms, getPlugins, getPlugin, unregisterPlugin, unregisterCustomPlugins, renderPlugins, renderPlugin };
//# sourceMappingURL=index.js.map