{"version":3,"file":"module.mjs","names":[],"sources":["../../src/nitro/module.ts"],"sourcesContent":["import { dirname, resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport type { Nitro } from 'nitropack'\nimport type { NitroModuleOptions } from '../nitro'\n\nexport type { NitroModuleOptions }\n\nconst _dir = dirname(fileURLToPath(import.meta.url))\n\nexport default function mxllog(options?: NitroModuleOptions) {\n  return {\n    name: '@safaricom-mxl/log',\n    setup(nitro: Nitro) {\n      // Push the plugin (no extension — Nitro's bundler resolves it)\n      nitro.options.plugins = nitro.options.plugins || []\n      nitro.options.plugins.push(resolve(_dir, 'plugin'))\n\n      // Set error handler only if not already configured by user\n      if (!nitro.options.errorHandler) {\n        nitro.options.errorHandler = resolve(_dir, 'errorHandler')\n      }\n\n      // explicitly tell nitro to bundle mxllog's files to correctly resolve nitro dependencies\n      // in nitro v2 we can only disable externals globally\n\n      nitro.options.noExternals = true\n\n      // Inject config into runtimeConfig — works in production where the\n      // plugin is bundled through Nitro's builder and the virtual\n      // runtime-config module resolves correctly.\n      nitro.options.runtimeConfig = nitro.options.runtimeConfig || {}\n      nitro.options.runtimeConfig.mxllog = options || {}\n\n      // In dev mode, Nitro loads plugins externally (not bundled), so the\n      // virtual runtime-config module is unreachable and useRuntimeConfig()\n      // returns a stub without our values. process.env is inherited by the\n      // Worker Threads that run the dev server, making it a reliable bridge.\n      // The plugin reads: useRuntimeConfig().mxllog ?? process.env.__EVLOG_CONFIG\n      process.env.__EVLOG_CONFIG = JSON.stringify(options || {})\n    },\n  }\n}\n\nexport { useLogger } from '../runtime/server/useLogger'\n"],"mappings":";;;;AAOA,MAAM,OAAO,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AAEpD,SAAwB,OAAO,SAA8B;AAC3D,QAAO;EACL,MAAM;EACN,MAAM,OAAc;AAElB,SAAM,QAAQ,UAAU,MAAM,QAAQ,WAAW,EAAE;AACnD,SAAM,QAAQ,QAAQ,KAAK,QAAQ,MAAM,SAAS,CAAC;AAGnD,OAAI,CAAC,MAAM,QAAQ,aACjB,OAAM,QAAQ,eAAe,QAAQ,MAAM,eAAe;AAM5D,SAAM,QAAQ,cAAc;AAK5B,SAAM,QAAQ,gBAAgB,MAAM,QAAQ,iBAAiB,EAAE;AAC/D,SAAM,QAAQ,cAAc,SAAS,WAAW,EAAE;AAOlD,WAAQ,IAAI,iBAAiB,KAAK,UAAU,WAAW,EAAE,CAAC;;EAE7D"}