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AM,EAAY,EAAM,MACxC,EAAW,KAAK,EAAM,KAAM,GAE9B,KAAK,KAAK,OAAQ,EACpB,MAEc,IAAZ,GACF,EAAO,KAAK,GAAW,EAAQ,OAAS,EAAQ,OAAS,WAAW,GAExE,CAEA,SAAS,eAAe,GAOtB,OANI,EAAM,cAAgB,SAAW,EAAM,SAAW,EAAM,QAC1D,EAAQ,OAAO,OAAO,CAAC,EAAG,MAAM,KAAK,EAAO,CAAC,UAAW,SAAU,CAChE,IAAK,GAAG,OAAO,EAAM,KAAO,GAAI,MAAM,KAAK,EAAO,CAAC,UAAW,aAI3D,IAAI,KAAK,EAClB,CA9DA,WAAW,OAAS,SAAS,EAAO,GAClC,OAAO,IAAI,WAAW,GAAU,OAAO,EACzC,EA+DA,WAAW,KAAO,aAClB,WAAW,MAAQ,MACnB,WAAW,QAAU,QACrB,WAAW,KAAO,KAClB,OAAO,QAAU","file":"/npm/bit-bundler@11.0.2/src/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/bit-bundler@11.0.2/src/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","\"use strict\";\n\nvar File = require(\"src-dest\");\nvar types = require(\"dis-isa\");\nvar utils = require(\"belty\");\nvar EventEmitter = require(\"events\");\nvar Stream = require(\"stream\");\nvar es = require(\"event-stream\");\nvar loaderFactory = require(\"./loader/factory\");\nvar bundlerFactory = require(\"./bundler/factory\");\nvar Bundle = require(\"./bundle\");\nvar Context = require(\"./context\");\nvar bundleWriter = require(\"./bundle/writer\");\nvar watch = require(\"./watch\");\nvar loggerFactory = require(\"./logger\");\nvar buildstats = require(\"../loggers/buildstats\");\n\nvar logger = loggerFactory.create(\"bundler/build\");\nvar id = 0;\n\nclass Bitbundler extends EventEmitter {\n  constructor(options) {\n    super();\n\n    this.options = Object.assign({}, options);\n    configureNotifications(this, this.options.notifications);\n    configureLogger(this, this.options.log, loggerFactory);\n\n    this.context = null;\n    this.loader = loaderFactory(this.options);\n    this.bundler = bundlerFactory(this.options);\n  }\n\n  bundle(files) {\n    logger.log(\"build-init\");\n\n    const file = configureFiles(files);\n    const generateEntryId = (src) => (types.isString(src) ? src : (src.id || src.path || \"@anonymous-\" + id++));\n    const entries = file.src.map(generateEntryId);\n    this.context = new Context().setBundle(new Bundle(\"main\", { dest: file.dest, entries: entries }, true));\n\n    return this.update(file).then((context) => {\n      if (this.options.watch) {\n        watch(this, this.options.watch);\n      }\n\n      if (this.options.multiprocess) {\n        if (this.options.watch) {\n          this.loader.pool.size(1);          \n        }\n        else {\n          this.loader.pool.stop();          \n        }\n      }\n\n      return context;\n    });\n  }\n\n  update(files) {\n    logger.log(\"build-start\");\n\n    return this\n      .buildBundles(files)\n      .then((context) => {\n        logger.log(\"build-writing\");\n        return bundleWriter()(context);\n      })\n      .then((context) => {\n        context.visitBundles((bundle) => logger.log(\"bundle\", bundle));\n        logger.log(\"build-success\", context);\n        logger.log(\"build-end\");\n        this.context = context;\n        return context;\n      })\n      .catch((err) => {\n        if (err) {\n          process.stderr.write((err && err.stack ? err.stack : err) + \"\\n\");\n        }\n\n        if (this.options.multiprocess) {\n          this.loader.pool.stop();\n        }\n\n        logger.error(\"build-failure\", err);\n        logger.log(\"build-end\");\n        throw err;\n      });\n  }\n\n  getLogger(name) {\n    return loggerFactory.create(name);\n  }\n\n  buildBundles(files) {\n    const file = configureFiles(files);\n    const context = this.context;\n    const loader = this.loader;\n    const bundler = this.bundler;\n\n    // Clear up cached items that need to be reprocessed\n    file.src\n      .filter(filePath => types.isString(filePath) && loader.hasModule(filePath))\n      .map(filePath => loader.getModule(filePath))\n      .forEach(mod => loader.deleteModule(mod));\n\n    return loader\n      .fetch(file.src)\n      .then(() => {\n        const cache = loader.getCache();\n        const mainBundle = context.getBundles(\"main\");\n        const moduleIds = Object.keys(cache);\n\n        const updatedContext = context\n          .setBundle(mainBundle.setModules(moduleIds))\n          .setCache(cache);\n\n        return bundler.bundle(updatedContext);\n      });\n  }\n}\n\nBitbundler.bundle = function(files, settings) {\n  return new Bitbundler(settings).bundle(files);\n};\n\nfunction configureNotifications(bitbundler, notifications) {\n  if (!notifications) {\n    return;\n  }\n\n  [].concat(notifications).forEach((notification) => {\n    if (types.isFunction(notification)) {\n      notification = notification(bitbundler) || {};\n    }\n\n    Object.keys(notification).forEach((notificationName) => {\n      [].concat(notification[notificationName]).forEach((cb) => {\n        bitbundler.on(notificationName, cb);\n      });\n    });\n  });\n}\n\nfunction configureLogger(bitbundler, options, loggerFactory) {\n  if (options === true) {\n    options = {\n      level: \"info\"\n    };\n  }\n  else if (types.isString(options)) {\n    options = {\n      level: options\n    };\n  }\n  else if (options instanceof Stream) {\n    options = {\n      stream: options\n    };\n  }\n\n  const logger = loggerFactory\n    .enableAll()\n    .pipe(es.through(function(chunk) {\n      chunk.name === \"bundler/build\" ?\n        bitbundler.emit.apply(bitbundler, chunk.data) :\n        bitbundler.emit(chunk.name, chunk);\n\n      this.emit(\"data\", chunk);\n    }));\n\n  if (options !== false) {\n    logger.pipe(options && options.stream ? options.stream : buildstats(options));\n  }\n}\n\nfunction configureFiles(files) {\n  if (files.constructor === Object && (files.content || files.path)) {\n    files = Object.assign({}, utils.omit(files, [\"content\", \"path\"]), {\n      src: [].concat(files.src || [], utils.pick(files, [\"content\", \"path\"]))\n    });\n  }\n\n  return new File(files);\n}\n\n\nBitbundler.dest = bundleWriter;\nBitbundler.watch = watch;\nBitbundler.Context = Context;\nBitbundler.File = File;\nmodule.exports = Bitbundler;\n"]}