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,uDAKA,KAAK,eAAL,QAAiC,CAC/B,QAAS,WAAA,QAAQ,QAAQ,OAGV,KAAK,QACpB,KAAK,QAAQ,GAAM,iBAEtB,G,0BAEG,GACF,OAAI,KAAK,eAAe,GACf,KAAK,eAAe,GAAM,QAE5B,WAAA,QAAQ,QAAQ,KACxB,G,0BAEG,GACF,QAAI,KAAK,eAAe,EAIzB,G,gCAGC,IAAM,EAAO,GACb,IAAK,IAAI,KAAc,KAAK,QAC1B,EAAK,GAAc,KAAK,QAAQ,GAAY,UAE9C,MAAO,CACL,QAAS,EACT,OAAQ,KAAK,OAEhB,K,KAGH,OAAO,QAAU","file":"/npm/flat-ioc@1.1.1/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/flat-ioc@1.1.1/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import Plugin from './plugin';\nimport printTables from './print-tables';\n\nimport Promise from 'bluebird';\nimport winston from 'winston';\n\nconst CONTAINER_DEFAULT_CONFIG = {\n  interactive: true,\n  loggingLevel: 'info'\n};\n\nclass Container {\n  constructor(root, configFilePath, configs) {\n    configs = {\n      ...CONTAINER_DEFAULT_CONFIG,\n      ...configs\n    };\n    const logger = new winston.Logger({\n      transports: [\n        new winston.transports.Console({\n          timestamp: () => new Date().toLocaleString(),\n          level: configs.loggingLevel\n        })\n      ]\n    });\n    logger.cli();\n    this.logger = logger;\n    this.root = root;\n    this.plugins = {};\n    this.errors = [];\n    this.publicServices = {};\n    const pluginPaths = root.require(configFilePath);\n    this.loadPluginConfigs(pluginPaths);\n\n    if (configs.interactive) {\n      this.enableKeyPress();\n    }\n  }\n\n  reportError(service, error) {\n    this.errors.push({\n      serviceName: service.name,\n      status: service.status,\n      error\n    });\n  }\n\n  enableKeyPress() {\n    process.stdin.on('data', () => printTables(this));\n  }\n\n  getLogger() {\n    return this.logger;\n  }\n\n  registerService(name, service) {\n    this.publicServices[name] = service;\n  }\n\n  loadPluginConfigs(pluginPaths) {\n    pluginPaths.map(path => {\n      let config = this.root.require(path);\n      if (config.default) {\n        // ES6 export default\n        config = config.default;\n      }\n      if (!config || !config.name) {\n        return;\n      }\n      this.logger.info(\n        'flat-ioc',\n        `\\tLoading plugin ${config.name} @path ${path}`\n      );\n      this.plugins[config.name] = new Plugin(this, path, config);\n    });\n\n    this.logger.info(\n      'flat-ioc',\n      `\\tDone loading plugins. Trying to resolve services.`\n    );\n\n    this.publicServices['context'] = {\n      promise: Promise.resolve(this)\n    };\n\n    for (let name in this.plugins) {\n      this.plugins[name].resolveServices();\n    }\n  }\n\n  get(name) {\n    if (this.publicServices[name]) {\n      return this.publicServices[name].promise;\n    }\n    return Promise.resolve(null);\n  }\n\n  has(name) {\n    if (this.publicServices[name]) {\n      return true;\n    }\n    return false;\n  }\n\n  getInfo() {\n    const info = {};\n    for (let pluginName in this.plugins) {\n      info[pluginName] = this.plugins[pluginName].getInfo();\n    }\n    return {\n      plugins: info,\n      errors: this.errors\n    };\n  }\n}\n\nmodule.exports = Container;\n"]}