commandkit 1.2.0-dev.20250823015335 → 1.2.0-dev.20250825125304

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/ActionRow-CmTHbo2t.js.map +1 -1
  2. package/dist/CommandKitEventsChannel-Bgw0XCOl.js.map +1 -1
  3. package/dist/CommandsRouter-tMAivEfv.js.map +1 -1
  4. package/dist/CompilerPlugin-CjoZAAR8.js.map +1 -1
  5. package/dist/{DefaultLogger-Cy55-uPl.d.ts → DefaultLogger-XCOl5nLd.d.ts} +19 -12
  6. package/dist/EventInterceptor-CQ4PBpBJ.js.map +1 -1
  7. package/dist/EventWorkerContext-CSlD9rbx.js.map +1 -1
  8. package/dist/EventsRouter-C_J0M3uO.js.map +1 -1
  9. package/dist/ILogger-BW8GM-YZ.d.ts +64 -0
  10. package/dist/{Logger-iSjA-DWN.d.ts → Logger-DyfkPk7u.d.ts} +2 -2
  11. package/dist/MessageCommandParser-B_BEQ3p8.js.map +1 -1
  12. package/dist/PluginCommon-Di1xIa8d.js.map +1 -1
  13. package/dist/RuntimePlugin-CBgBLXTG.js.map +1 -1
  14. package/dist/analytics/analytics-engine.js +1 -1
  15. package/dist/analytics/utils.js +1 -1
  16. package/dist/app/commands/AppCommandRunner.js +1 -1
  17. package/dist/app/commands/Context.js +1 -1
  18. package/dist/app/handlers/AppCommandHandler.js +1 -1
  19. package/dist/app/handlers/AppEventsHandler.js +1 -1
  20. package/dist/app/index.js +1 -1
  21. package/dist/app/middlewares/permissions.js +1 -1
  22. package/dist/app/register/CommandRegistrar.js +1 -1
  23. package/dist/app-process-CjMovpoZ.js.map +1 -1
  24. package/dist/{build-BmDzPe4V.js → build-CoJqJ17n.js} +2 -2
  25. package/dist/{build-BmDzPe4V.js.map → build-CoJqJ17n.js.map} +1 -1
  26. package/dist/cli/build.js +2 -2
  27. package/dist/cli/development.js +2 -2
  28. package/dist/cli/development.js.map +1 -1
  29. package/dist/cli/generators.js.map +1 -1
  30. package/dist/cli/information.js +1 -1
  31. package/dist/cli/information.js.map +1 -1
  32. package/dist/cli/init.js +2 -2
  33. package/dist/cli/production.js +2 -2
  34. package/dist/cli/production.js.map +1 -1
  35. package/dist/{commandkit-C0BuNRSN.js → commandkit-CYJ8d2gj.js} +53 -49
  36. package/dist/commandkit-CYJ8d2gj.js.map +1 -0
  37. package/dist/commandkit.js +1 -1
  38. package/dist/common-DNADUU3_.js.map +1 -1
  39. package/dist/common-vnMIelAE.js.map +1 -1
  40. package/dist/components/index.js +1 -1
  41. package/dist/components/v1/button/Button.js +1 -1
  42. package/dist/components/v1/button/ButtonKit.js +1 -1
  43. package/dist/components/v1/modal/Modal.js +1 -1
  44. package/dist/components/v1/modal/ModalKit.js +1 -1
  45. package/dist/components/v1/select-menu/ChannelSelectMenuKit.js +1 -1
  46. package/dist/components/v1/select-menu/MentionableSelectMenuKit.js +1 -1
  47. package/dist/components/v1/select-menu/RoleSelectMenuKit.js +1 -1
  48. package/dist/components/v1/select-menu/SelectMenu.js +1 -1
  49. package/dist/components/v1/select-menu/StringSelectMenuKit.js +1 -1
  50. package/dist/components/v1/select-menu/UserSelectMenuKit.js +1 -1
  51. package/dist/config/config.js +1 -1
  52. package/dist/config/default.js +1 -1
  53. package/dist/config/loader.js +1 -1
  54. package/dist/constants-4oxxvaJA.js.map +1 -1
  55. package/dist/constants-B5_Ta7PR.js.map +1 -1
  56. package/dist/constants-CUND8XkG.js.map +1 -1
  57. package/dist/container-z621KfH5.js.map +1 -1
  58. package/dist/context/async-context.js +1 -1
  59. package/dist/context/environment.js +1 -1
  60. package/dist/dotprops-C_4L7RPD.js.map +1 -1
  61. package/dist/element-Bak9llw_.js.map +1 -1
  62. package/dist/env-_68PRRoA.js.map +1 -1
  63. package/dist/error-codes-C-ViHyu-.js.map +1 -1
  64. package/dist/{feature-flags-BZMExGfA.js → feature-flags-Co2WUAIe.js} +2 -2
  65. package/dist/{feature-flags-BZMExGfA.js.map → feature-flags-Co2WUAIe.js.map} +1 -1
  66. package/dist/file-DVZC0QXI.js.map +1 -1
  67. package/dist/flags/FlagProvider.js.map +1 -1
  68. package/dist/flags/feature-flags.js +2 -2
  69. package/dist/helpers-BUlN3lIz.js.map +1 -1
  70. package/dist/index.d.ts +3 -3
  71. package/dist/index.js +11 -6
  72. package/dist/index.js.map +1 -0
  73. package/dist/{init-D20FhDjn.js → init-CEuxl8qP.js} +2 -2
  74. package/dist/{init-D20FhDjn.js.map → init-CEuxl8qP.js.map} +1 -1
  75. package/dist/kv/kv.js.map +1 -1
  76. package/dist/logger/DefaultLogger.d.ts +2 -2
  77. package/dist/logger/DefaultLogger.js +1 -1
  78. package/dist/logger/ILogger.d.ts +1 -1
  79. package/dist/logger/Logger.d.ts +2 -2
  80. package/dist/logger/Logger.js +1 -1
  81. package/dist/logger/NoopLogger.d.ts +41 -11
  82. package/dist/logger/NoopLogger.js +5 -25
  83. package/dist/logger/NoopLogger.js.map +1 -1
  84. package/dist/media-gallery-CIKypjbJ.js.map +1 -1
  85. package/dist/plugins/index.js +1 -1
  86. package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.js +1 -1
  87. package/dist/plugins/plugin-runtime/CompilerPluginRuntime.js +1 -1
  88. package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.js +1 -1
  89. package/dist/plugins/plugin-runtime/builtin/MacroPlugin.js +1 -1
  90. package/dist/resolve-file-url-DHTQj2mU.js.map +1 -1
  91. package/dist/section-CuYr0Inu.js.map +1 -1
  92. package/dist/separator-DLdWBjSN.js.map +1 -1
  93. package/dist/serde-CHySNpFr.js.map +1 -1
  94. package/dist/signals-DHdYrd-n.js.map +1 -1
  95. package/dist/store-CiqLHedg.js.map +1 -1
  96. package/dist/text-display--p2-BoUa.js.map +1 -1
  97. package/dist/type-checker-1Iu1jJcy.js.map +1 -1
  98. package/dist/types-package-DrnIdWLg.js.map +1 -1
  99. package/dist/utils/dev-hooks.js +1 -1
  100. package/dist/utils/useful-stuff/async-queue.js.map +1 -1
  101. package/dist/utils/useful-stuff/mutex.js.map +1 -1
  102. package/dist/utils/useful-stuff/ratelimiter.js.map +1 -1
  103. package/dist/utils/useful-stuff/semaphore.js.map +1 -1
  104. package/dist/utils/utilities.js +1 -1
  105. package/dist/utils/warn-unstable.js.map +1 -1
  106. package/dist/utils-BnXM4eKk.js.map +1 -1
  107. package/dist/utils-DCSnVAZ6.js.map +1 -1
  108. package/dist/{version-DDiOJ2Yv.js → version-B_bKw4jL.js} +2 -2
  109. package/dist/{version-DDiOJ2Yv.js.map → version-B_bKw4jL.js.map} +1 -1
  110. package/dist/version.js +1 -1
  111. package/package.json +2 -2
  112. package/dist/ILogger-DBGON5wx.d.ts +0 -34
  113. package/dist/commandkit-C0BuNRSN.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"init-D20FhDjn.js","names":[],"sources":["../src/cli/init.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { mkdir } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { generateTypesPackage } from '../utils/types-package';\nimport { loadConfigFile } from '../config/loader';\nimport {\n CompilerPlugin,\n CompilerPluginRuntime,\n isCompilerPlugin,\n} from '../plugins';\nimport { panic } from './common';\nimport { COMMANDKIT_CWD } from '../utils/constants';\n\n/**\n * Creates a command line interface for CommandKit.\n * @param argv The arguments passed to the CLI.\n * @param options The options passed to the CLI.\n */\nexport async function bootstrapCommandkitCLI(\n argv: string[],\n options?: import('commander').ParseOptions | undefined,\n) {\n process.title = 'CommandKit CLI';\n\n // imports are lazily loaded when the cli is used, instead of loading it with the lib itself\n const { Command } = await import('commander');\n const { bootstrapDevelopmentServer } = await import('./development');\n const { bootstrapProductionServer, createProductionBuild } = await import(\n './production'\n );\n const { generateCommand, generateEvent } = await import('./generators');\n const { version } = await import('../version');\n const { showInformation } = await import('./information');\n const { setCLIEnv } = await import('./env');\n\n const program = new Command('commandkit');\n\n program\n .command('dev')\n .version(version)\n .description('Start your bot in development mode.')\n .option(\n '-c, --config [path]',\n 'Path to your commandkit config file.',\n './commandkit.js',\n )\n .action(() => {\n const options = program.opts();\n bootstrapDevelopmentServer(options.config);\n });\n\n program\n .command('info')\n .description(\n 'Show information about the system which can be used to report bugs.',\n )\n .action(async () => {\n await showInformation();\n });\n\n program\n .command('start')\n .description(\n 'Start your bot in production mode after running the build command.',\n )\n .option('-c, --config [path]', 'Path to your commandkit config file.')\n .action(() => {\n const options = program.opts();\n bootstrapProductionServer(options.config);\n });\n\n program\n .command('build')\n .description('Build your project for production usage.')\n .option('-c, --config [path]', 'Path to your commandkit config file.')\n .action(() => {\n setCLIEnv();\n const options = program.opts();\n return createProductionBuild(options.config);\n });\n\n program\n .command('create')\n .description(\n 'Create new files using built-in templates or custom plugin templates',\n )\n .argument(\n '<template>',\n 'The template to use (e.g. command, event, or custom plugin template)',\n )\n .argument('[args...]', 'Additional arguments for the template')\n .action(async (template, args) => {\n setCLIEnv();\n\n // Handle custom plugin templates\n const { plugins } = await loadConfigFile();\n const runtime = new CompilerPluginRuntime(\n plugins.filter((p) => isCompilerPlugin(p)) as CompilerPlugin[],\n );\n\n try {\n await runtime.init();\n const templateHandler = runtime.getTemplate(template);\n\n if (!templateHandler) {\n // Handle built-in templates\n if (template === 'command') {\n const [name] = args;\n if (!name) {\n panic('Command name is required');\n }\n await generateCommand(name);\n return;\n }\n\n if (template === 'event') {\n const [name] = args;\n if (!name) {\n panic('Event name is required');\n }\n await generateEvent(name);\n return;\n }\n\n const valid = Array.from(\n new Set([\n 'command',\n 'event',\n ...Array.from(runtime.getTemplates().keys()),\n ]),\n ).map((t) => `\"${t}\"`);\n\n panic(\n `Template \"${template}\" not found. Available templates: ${valid.join(', ')}`,\n );\n }\n\n await templateHandler(args);\n } catch (e: any) {\n panic(`Failed to execute template \"${template}\": ${e?.message || e}`);\n } finally {\n await runtime.destroy();\n }\n });\n\n const types = join(COMMANDKIT_CWD, 'node_modules', 'commandkit-types');\n\n if (!existsSync(types)) {\n await mkdir(types, { recursive: true }).catch(() => {});\n await generateTypesPackage(true).catch(() => {});\n }\n\n await program.parseAsync(argv, options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,eAAsB,uBACtB,MACA,SACA;AACE,SAAQ,QAAQ;CAGhB,MAAM,EAAE,SAAS,GAAG,MAAM,OAAO;CACjC,MAAM,EAAE,4BAA4B,GAAG,2CAAM;CAC7C,MAAM,EAAE,2BAA2B,uBAAuB,GAAG,2CAAM;CAGnE,MAAM,EAAE,iBAAiB,eAAe,GAAG,2CAAM;CACjD,MAAM,EAAE,SAAS,GAAG,2CAAM;CAC1B,MAAM,EAAE,iBAAiB,GAAG,2CAAM;CAClC,MAAM,EAAE,WAAW,GAAG,2CAAM;CAE5B,MAAM,UAAU,IAAI,QAAQ;AAE5B,SACA,QAAQ,OACR,QAAQ,SACR,YAAY,uCACZ,OACE,uBACA,wCACA,mBAEF,aAAa;EACX,MAAM,YAAU,QAAQ;AACxB,6BAA2B,UAAQ;CACpC;AAED,SACA,QAAQ,QACR,YACE,uEAEF,OAAO,YAAY;AACjB,QAAM;CACP;AAED,SACA,QAAQ,SACR,YACE,sEAEF,OAAO,uBAAuB,wCAC9B,aAAa;EACX,MAAM,YAAU,QAAQ;AACxB,4BAA0B,UAAQ;CACnC;AAED,SACA,QAAQ,SACR,YAAY,4CACZ,OAAO,uBAAuB,wCAC9B,aAAa;AACX;EACA,MAAM,YAAU,QAAQ;AACxB,SAAO,sBAAsB,UAAQ;CACtC;AAED,SACA,QAAQ,UACR,YACE,wEAEF,SACE,cACA,wEAEF,SAAS,aAAa,yCACtB,OAAO,OAAO,UAAU,SAAS;AAC/B;EAGA,MAAM,EAAE,SAAS,GAAG,MAAM;EAC1B,MAAM,UAAU,IAAI,yCAClB,QAAQ,QAAQ,MAAM,wCAAiB;AAGzC,MAAI;AACF,SAAM,QAAQ;GACd,MAAM,kBAAkB,QAAQ,YAAY;AAE5C,OAAI,CAAC,iBAAiB;AAEpB,QAAI,aAAa,WAAW;KAC1B,MAAM,CAAC,KAAK,GAAG;AACf,SAAI,CAAC,KACH,sBAAM;AAER,WAAM,gBAAgB;AACtB;IACD;AAED,QAAI,aAAa,SAAS;KACxB,MAAM,CAAC,KAAK,GAAG;AACf,SAAI,CAAC,KACH,sBAAM;AAER,WAAM,cAAc;AACpB;IACD;IAED,MAAM,QAAQ,MAAM,KAClB,IAAI,IAAI;KACR;KACA;KACA,GAAG,MAAM,KAAK,QAAQ,eAAe;KAAQ,GAE7C,KAAK,MAAM,IAAI,EAAE;AAEnB,yBACE,aAAa,SAAS,oCAAoC,MAAM,KAAK;GAExE;AAED,SAAM,gBAAgB;EACvB,SAAQ,GAAQ;AACf,wBAAM,+BAA+B,SAAS,4CAAK,EAAG,YAAW;EAClE,UAAS;AACR,SAAM,QAAQ;EACf;CACF;CAED,MAAM,4BAAa,kCAAgB,gBAAgB;AAEnD,KAAI,yBAAY,QAAQ;AACtB,oCAAY,OAAO,EAAE,WAAW,MAAM,EAAE,YAAY,CAAE;AACtD,QAAM,2CAAqB,MAAM,YAAY,CAAE;CACjD;AAEA,OAAM,QAAQ,WAAW,MAAM;AACjC"}
1
+ {"version":3,"file":"init-CEuxl8qP.js","names":[],"sources":["../src/cli/init.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { mkdir } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { generateTypesPackage } from '../utils/types-package';\nimport { loadConfigFile } from '../config/loader';\nimport {\n CompilerPlugin,\n CompilerPluginRuntime,\n isCompilerPlugin,\n} from '../plugins';\nimport { panic } from './common';\nimport { COMMANDKIT_CWD } from '../utils/constants';\n\n/**\n * Creates a command line interface for CommandKit.\n * @param argv The arguments passed to the CLI.\n * @param options The options passed to the CLI.\n */\nexport async function bootstrapCommandkitCLI(\n argv: string[],\n options?: import('commander').ParseOptions | undefined,\n) {\n process.title = 'CommandKit CLI';\n\n // imports are lazily loaded when the cli is used, instead of loading it with the lib itself\n const { Command } = await import('commander');\n const { bootstrapDevelopmentServer } = await import('./development');\n const { bootstrapProductionServer, createProductionBuild } = await import(\n './production'\n );\n const { generateCommand, generateEvent } = await import('./generators');\n const { version } = await import('../version');\n const { showInformation } = await import('./information');\n const { setCLIEnv } = await import('./env');\n\n const program = new Command('commandkit');\n\n program\n .command('dev')\n .version(version)\n .description('Start your bot in development mode.')\n .option(\n '-c, --config [path]',\n 'Path to your commandkit config file.',\n './commandkit.js',\n )\n .action(() => {\n const options = program.opts();\n bootstrapDevelopmentServer(options.config);\n });\n\n program\n .command('info')\n .description(\n 'Show information about the system which can be used to report bugs.',\n )\n .action(async () => {\n await showInformation();\n });\n\n program\n .command('start')\n .description(\n 'Start your bot in production mode after running the build command.',\n )\n .option('-c, --config [path]', 'Path to your commandkit config file.')\n .action(() => {\n const options = program.opts();\n bootstrapProductionServer(options.config);\n });\n\n program\n .command('build')\n .description('Build your project for production usage.')\n .option('-c, --config [path]', 'Path to your commandkit config file.')\n .action(() => {\n setCLIEnv();\n const options = program.opts();\n return createProductionBuild(options.config);\n });\n\n program\n .command('create')\n .description(\n 'Create new files using built-in templates or custom plugin templates',\n )\n .argument(\n '<template>',\n 'The template to use (e.g. command, event, or custom plugin template)',\n )\n .argument('[args...]', 'Additional arguments for the template')\n .action(async (template, args) => {\n setCLIEnv();\n\n // Handle custom plugin templates\n const { plugins } = await loadConfigFile();\n const runtime = new CompilerPluginRuntime(\n plugins.filter((p) => isCompilerPlugin(p)) as CompilerPlugin[],\n );\n\n try {\n await runtime.init();\n const templateHandler = runtime.getTemplate(template);\n\n if (!templateHandler) {\n // Handle built-in templates\n if (template === 'command') {\n const [name] = args;\n if (!name) {\n panic('Command name is required');\n }\n await generateCommand(name);\n return;\n }\n\n if (template === 'event') {\n const [name] = args;\n if (!name) {\n panic('Event name is required');\n }\n await generateEvent(name);\n return;\n }\n\n const valid = Array.from(\n new Set([\n 'command',\n 'event',\n ...Array.from(runtime.getTemplates().keys()),\n ]),\n ).map((t) => `\"${t}\"`);\n\n panic(\n `Template \"${template}\" not found. Available templates: ${valid.join(', ')}`,\n );\n }\n\n await templateHandler(args);\n } catch (e: any) {\n panic(`Failed to execute template \"${template}\": ${e?.message || e}`);\n } finally {\n await runtime.destroy();\n }\n });\n\n const types = join(COMMANDKIT_CWD, 'node_modules', 'commandkit-types');\n\n if (!existsSync(types)) {\n await mkdir(types, { recursive: true }).catch(() => {});\n await generateTypesPackage(true).catch(() => {});\n }\n\n await program.parseAsync(argv, options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,eAAsB,uBACtB,MACA,SACA;AACE,SAAQ,QAAQ;CAGhB,MAAM,EAAE,YAAY,MAAM,OAAO;CACjC,MAAM,EAAE,+BAA+B,2CAAM;CAC7C,MAAM,EAAE,2BAA2B,0BAA0B,2CAAM;CAGnE,MAAM,EAAE,iBAAiB,kBAAkB,2CAAM;CACjD,MAAM,EAAE,YAAY,2CAAM;CAC1B,MAAM,EAAE,oBAAoB,2CAAM;CAClC,MAAM,EAAE,cAAc,2CAAM;CAE5B,MAAM,UAAU,IAAI,QAAQ;AAE5B,SACA,QAAQ,OACR,QAAQ,SACR,YAAY,uCACZ,OACE,uBACA,wCACA,mBAEF,aAAa;EACX,MAAM,YAAU,QAAQ;AACxB,6BAA2B,UAAQ;;AAGrC,SACA,QAAQ,QACR,YACE,uEAEF,OAAO,YAAY;AACjB,QAAM;;AAGR,SACA,QAAQ,SACR,YACE,sEAEF,OAAO,uBAAuB,wCAC9B,aAAa;EACX,MAAM,YAAU,QAAQ;AACxB,4BAA0B,UAAQ;;AAGpC,SACA,QAAQ,SACR,YAAY,4CACZ,OAAO,uBAAuB,wCAC9B,aAAa;AACX;EACA,MAAM,YAAU,QAAQ;AACxB,SAAO,sBAAsB,UAAQ;;AAGvC,SACA,QAAQ,UACR,YACE,wEAEF,SACE,cACA,wEAEF,SAAS,aAAa,yCACtB,OAAO,OAAO,UAAU,SAAS;AAC/B;EAGA,MAAM,EAAE,YAAY,MAAM;EAC1B,MAAM,UAAU,IAAI,yCAClB,QAAQ,QAAQ,MAAM,wCAAiB;AAGzC,MAAI;AACF,SAAM,QAAQ;GACd,MAAM,kBAAkB,QAAQ,YAAY;AAE5C,OAAI,CAAC,iBAAiB;AAEpB,QAAI,aAAa,WAAW;KAC1B,MAAM,CAAC,QAAQ;AACf,SAAI,CAAC,KACH,sBAAM;AAER,WAAM,gBAAgB;AACtB;;AAGF,QAAI,aAAa,SAAS;KACxB,MAAM,CAAC,QAAQ;AACf,SAAI,CAAC,KACH,sBAAM;AAER,WAAM,cAAc;AACpB;;IAGF,MAAM,QAAQ,MAAM,KAClB,IAAI,IAAI;KACR;KACA;KACA,GAAG,MAAM,KAAK,QAAQ,eAAe;QAErC,KAAK,MAAM,IAAI,EAAE;AAEnB,yBACE,aAAa,SAAS,oCAAoC,MAAM,KAAK;;AAIzE,SAAM,gBAAgB;WACf,GAAQ;AACf,wBAAM,+BAA+B,SAAS,4CAAK,EAAG,YAAW;YACzD;AACR,SAAM,QAAQ;;;CAIlB,MAAM,4BAAa,kCAAgB,gBAAgB;AAEnD,KAAI,yBAAY,QAAQ;AACtB,oCAAY,OAAO,EAAE,WAAW,QAAQ,YAAY;AACpD,QAAM,2CAAqB,MAAM,YAAY;;AAG/C,OAAM,QAAQ,WAAW,MAAM"}
package/dist/kv/kv.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"kv.js","names":[],"sources":["../../src/kv/kv.ts"],"sourcesContent":["import { DatabaseSync, StatementSync } from 'node:sqlite';\nimport { deserializer, serializer } from './serde';\nimport { getNestedValue, setNestedValue } from './dotprops';\n\nexport type { SerializedValue } from './serde';\n\n/**\n * Mathematical operators supported by the KV math method\n */\nexport type KvMathOperator = '+' | '-' | '*' | '/' | '^' | '%';\n\n/**\n * Configuration options for the KV store\n */\nexport interface KvOptions {\n /** Enable Write-Ahead Logging for better performance and durability */\n enableWAL?: boolean;\n /** Namespace for the key-value store table */\n namespace?: string;\n}\n\n/**\n * A key-value store implementation using SQLite\n *\n * This class provides a simple, persistent key-value storage solution\n * with support for namespaces, automatic cleanup, iteration, expiration, and JSON serialization.\n *\n * @example\n * ```typescript\n * const kv = new KV('data.db');\n *\n * // Store any JSON-serializable data\n * kv.set('user:123', { name: 'John', age: 30 });\n * kv.set('counter', 42);\n * kv.set('active', true);\n * kv.set('dates', [new Date(), new Date()]);\n *\n * // Use dot notation for nested properties\n * kv.set('user:123.name', 'John');\n * kv.set('user:123.settings.theme', 'dark');\n *\n * // Retrieve data\n * const user = kv.get('user:123'); // { name: 'John', age: 30, settings: { theme: 'dark' } }\n * const name = kv.get('user:123.name'); // 'John'\n * ```\n */\nexport class KV implements Disposable, AsyncDisposable {\n private db: DatabaseSync;\n private statements: Record<string, StatementSync> = {};\n\n /**\n * Creates a new KV store instance\n *\n * @param path - Database file path, buffer, URL, or existing DatabaseSync instance\n * @param options - Configuration options for the KV store\n */\n public constructor(\n path: string | Buffer | URL | DatabaseSync,\n private options: KvOptions = {\n enableWAL: true,\n namespace: 'commandkit_kv',\n },\n ) {\n this.db =\n path instanceof DatabaseSync\n ? path\n : new DatabaseSync(path, { open: true });\n\n if (options.enableWAL) {\n this.db.exec(/* sql */ `PRAGMA journal_mode = WAL;`);\n }\n\n const namespace = this.options.namespace ?? 'commandkit_kv';\n\n this.db.exec(/* sql */ `\n CREATE TABLE IF NOT EXISTS ${namespace} (\n key TEXT PRIMARY KEY,\n value TEXT,\n expires_at INTEGER\n )\n `);\n\n this.statements = {\n get: this.db.prepare(\n /* sql */ `SELECT value, expires_at FROM ${namespace} WHERE key = ?`,\n ),\n set: this.db.prepare(\n /* sql */ `INSERT OR REPLACE INTO ${namespace} (key, value, expires_at) VALUES (?, ?, ?)`,\n ),\n setex: this.db.prepare(\n /* sql */ `INSERT OR REPLACE INTO ${namespace} (key, value, expires_at) VALUES (?, ?, ?)`,\n ),\n delete: this.db.prepare(\n /* sql */ `DELETE FROM ${namespace} WHERE key = ?`,\n ),\n has: this.db.prepare(\n /* sql */ `SELECT COUNT(*) FROM ${namespace} WHERE key = ? AND (expires_at IS NULL OR expires_at > ?)`,\n ),\n keys: this.db.prepare(\n /* sql */ `SELECT key FROM ${namespace} WHERE expires_at IS NULL OR expires_at > ?`,\n ),\n values: this.db.prepare(\n /* sql */ `SELECT value FROM ${namespace} WHERE expires_at IS NULL OR expires_at > ?`,\n ),\n clear: this.db.prepare(/* sql */ `DELETE FROM ${namespace}`),\n count: this.db.prepare(\n /* sql */ `SELECT COUNT(*) FROM ${namespace} WHERE expires_at IS NULL OR expires_at > ?`,\n ),\n all: this.db.prepare(\n /* sql */ `SELECT key, value FROM ${namespace} WHERE expires_at IS NULL OR expires_at > ?`,\n ),\n expire: this.db.prepare(\n /* sql */ `UPDATE ${namespace} SET expires_at = ? WHERE key = ?`,\n ),\n ttl: this.db.prepare(\n /* sql */ `SELECT expires_at FROM ${namespace} WHERE key = ?`,\n ),\n namespaces: this.db.prepare(\n /* sql */ `SELECT name FROM sqlite_master WHERE type = 'table' AND name NOT LIKE 'sqlite_%'`,\n ),\n begin: this.db.prepare(/* sql */ `BEGIN TRANSACTION`),\n commit: this.db.prepare(/* sql */ `COMMIT`),\n rollback: this.db.prepare(/* sql */ `ROLLBACK`),\n };\n }\n\n /**\n * Gets the current timestamp in milliseconds\n */\n private getCurrentTime(): number {\n return Date.now();\n }\n\n /**\n * Checks if the database connection is open\n *\n * @returns `true` if the database is open, `false` otherwise\n */\n public isOpen(): boolean {\n return this.db.isOpen;\n }\n\n /**\n * Gets the underlying SQLite database instance\n *\n * @returns The DatabaseSync instance\n */\n public getDatabase(): DatabaseSync {\n return this.db;\n }\n\n /**\n * Closes the database connection\n */\n public close(): void {\n if (this.db.isOpen) this.db.close();\n }\n\n /**\n * Disposable implementation - closes the database when disposed\n */\n public [Symbol.dispose]() {\n this.close();\n }\n\n /**\n * AsyncDisposable implementation - closes the database when disposed\n */\n public async [Symbol.asyncDispose]() {\n this.close();\n }\n\n /**\n * Retrieves a value by key\n *\n * @param key - The key to retrieve (supports dot notation for nested properties)\n * @returns The value associated with the key, or `undefined` if not found or expired\n *\n * @example\n * ```typescript\n * // Store an object\n * kv.set('user:123', { name: 'John', age: 30, settings: { theme: 'dark' } });\n *\n * // Get the entire object\n * const user = kv.get('user:123');\n * // { name: 'John', age: 30, settings: { theme: 'dark' } }\n *\n * // Get nested properties using dot notation\n * const name = kv.get('user:123.name'); // 'John'\n * const theme = kv.get('user:123.settings.theme'); // 'dark'\n * ```\n */\n public get<T = any>(key: string): T | undefined {\n const result = this.statements.get.get(key);\n\n if (!result) return undefined;\n\n // Check if the key has expired\n if (\n result.expires_at &&\n Number(result.expires_at) <= this.getCurrentTime()\n ) {\n this.delete(key);\n return undefined;\n }\n\n const serialized = JSON.parse(result.value as string);\n const deserialized = deserializer(serialized);\n\n // Handle dot notation for nested properties\n if (key.includes('.')) {\n return getNestedValue(deserialized, key.split('.').slice(1).join('.'));\n }\n\n return deserialized;\n }\n\n /**\n * Sets a key-value pair\n *\n * @param key - The key to set (supports dot notation for nested properties)\n * @param value - The value to associate with the key (any JSON-serializable type)\n *\n * @example\n * ```typescript\n * // Store primitive values\n * kv.set('counter', 42);\n * kv.set('active', true);\n * kv.set('name', 'John');\n *\n * // Store objects\n * kv.set('user:123', { name: 'John', age: 30 });\n *\n * // Store arrays\n * kv.set('tags', ['javascript', 'typescript', 'sqlite']);\n *\n * // Store dates\n * kv.set('created', new Date());\n *\n * // Store maps and sets\n * kv.set('permissions', new Map([['admin', true], ['user', false]]));\n * kv.set('unique_ids', new Set([1, 2, 3, 4, 5]));\n *\n * // Use dot notation for nested properties\n * kv.set('user:123.settings.theme', 'dark');\n * kv.set('user:123.settings.notifications', true);\n * ```\n */\n public set(key: string, value: any): void {\n let serializedValue: string;\n\n if (key.includes('.')) {\n // Handle dot notation for nested properties\n const [baseKey, ...pathParts] = key.split('.');\n const path = pathParts.join('.');\n\n // Get existing value or create new object\n const existing = this.get(baseKey) || {};\n setNestedValue(existing, path, value);\n\n const serialized = serializer(existing);\n serializedValue = JSON.stringify(serialized);\n\n this.statements.set.run(baseKey, serializedValue, null);\n } else {\n const serialized = serializer(value);\n serializedValue = JSON.stringify(serialized);\n\n this.statements.set.run(key, serializedValue, null);\n }\n }\n\n /**\n * Sets a key-value pair with expiration\n *\n * @param key - The key to set (supports dot notation for nested properties)\n * @param value - The value to associate with the key (any JSON-serializable type)\n * @param ttl - Time to live in milliseconds\n *\n * @example\n * ```typescript\n * // Set with 1 hour expiration\n * kv.setex('session:123', { userId: 123, token: 'abc123' }, 60 * 60 * 1000);\n *\n * // Set with 5 minutes expiration\n * kv.setex('temp:data', { cached: true, timestamp: Date.now() }, 5 * 60 * 1000);\n *\n * // Use dot notation with expiration\n * kv.setex('user:123.temp_settings', { theme: 'light' }, 30 * 60 * 1000);\n * ```\n */\n public setex(key: string, value: any, ttl: number): void {\n const expiresAt = this.getCurrentTime() + ttl;\n let serializedValue: string;\n\n if (key.includes('.')) {\n // Handle dot notation for nested properties\n const [baseKey, ...pathParts] = key.split('.');\n const path = pathParts.join('.');\n\n // Get existing value or create new object\n const existing = this.get(baseKey) || {};\n setNestedValue(existing, path, value);\n\n const serialized = serializer(existing);\n serializedValue = JSON.stringify(serialized);\n\n this.statements.setex.run(baseKey, serializedValue, expiresAt);\n } else {\n const serialized = serializer(value);\n serializedValue = JSON.stringify(serialized);\n\n this.statements.setex.run(key, serializedValue, expiresAt);\n }\n }\n\n /**\n * Performs mathematical operations on numeric values in the KV store\n *\n * @param key - The key to perform math operation on (supports dot notation for nested properties)\n * @param operator - The mathematical operator to apply\n * @param value - The value to use in the operation\n * @returns The updated value after the mathematical operation\n * @throws Error if the existing value is not numeric or if the operation is invalid\n *\n * @example\n * ```typescript\n * // Initialize a counter\n * kv.set('counter', 10);\n *\n * // Increment by 5\n * const result1 = kv.math('counter', '+', 5); // 15\n *\n * // Multiply by 2\n * const result2 = kv.math('counter', '*', 2); // 30\n *\n * // Use with bigint\n * kv.set('big_counter', BigInt(1000));\n * const result3 = kv.math('big_counter', '+', BigInt(500)); // 1500n\n *\n * // Use with dot notation\n * kv.set('user:123', { score: 100, level: 5 });\n * const result4 = kv.math('user:123.score', '+', 50); // 150\n * ```\n */\n public math(\n key: string,\n operator: KvMathOperator,\n value: number | bigint,\n ): number | bigint {\n const existingValue = this.get(key);\n\n if (existingValue === undefined) {\n throw new Error(`Key '${key}' does not exist`);\n }\n\n if (\n typeof existingValue !== 'number' &&\n typeof existingValue !== 'bigint'\n ) {\n throw new Error(\n `Value at key '${key}' is not numeric. Expected number or bigint, got ${typeof existingValue}`,\n );\n }\n\n // Handle mixed number/bigint operations by converting to bigint\n const isBigIntOperation =\n typeof existingValue === 'bigint' || typeof value === 'bigint';\n\n const existing = isBigIntOperation\n ? typeof existingValue === 'bigint'\n ? existingValue\n : BigInt(existingValue)\n : (existingValue as number);\n const operand = isBigIntOperation\n ? typeof value === 'bigint'\n ? value\n : BigInt(value)\n : (value as number);\n\n let result: number | bigint;\n\n switch (operator) {\n case '+':\n result = (existing as any) + (operand as any);\n break;\n case '-':\n result = (existing as any) - (operand as any);\n break;\n case '*':\n result = (existing as any) * (operand as any);\n break;\n case '/':\n if (operand === 0 || operand === 0n) {\n throw new Error('Division by zero');\n }\n result = (existing as any) / (operand as any);\n break;\n case '^':\n if (isBigIntOperation && operand < 0n) {\n throw new Error(\n 'Exponentiation with negative exponent is not supported for bigint',\n );\n }\n result = (existing as any) ** (operand as any);\n break;\n case '%':\n if (operand === 0 || operand === 0n) {\n throw new Error('Modulo by zero');\n }\n result = (existing as any) % (operand as any);\n break;\n default:\n throw new Error(`Invalid operator: ${operator}`);\n }\n\n // Update the value in the store\n this.set(key, result);\n\n return result;\n }\n\n /**\n * Sets expiration for an existing key\n *\n * @param key - The key to set expiration for\n * @param ttl - Time to live in milliseconds\n * @returns `true` if the key exists and expiration was set, `false` otherwise\n *\n * @example\n * ```typescript\n * kv.set('user:123', { name: 'John', age: 30 });\n *\n * // Set 30 minute expiration\n * if (kv.expire('user:123', 30 * 60 * 1000)) {\n * console.log('Expiration set successfully');\n * }\n * ```\n */\n public expire(key: string, ttl: number): boolean {\n if (!this.has(key)) return false;\n\n const expiresAt = this.getCurrentTime() + ttl;\n this.statements.expire.run(expiresAt, key);\n return true;\n }\n\n /**\n * Gets the time to live for a key\n *\n * @param key - The key to check\n * @returns Time to live in milliseconds, or `-1` if the key doesn't exist, or `-2` if the key has no expiration\n *\n * @example\n * ```typescript\n * const ttl = kv.ttl('user:123');\n * if (ttl > 0) {\n * console.log(`Key expires in ${ttl}ms`);\n * } else if (ttl === -2) {\n * console.log('Key has no expiration');\n * } else {\n * console.log('Key does not exist');\n * }\n * ```\n */\n public ttl(key: string): number {\n const result = this.statements.ttl.get(key);\n\n if (!result) return -1; // Key doesn't exist\n\n if (!result.expires_at) return -2; // No expiration\n\n const remaining = Number(result.expires_at) - this.getCurrentTime();\n return remaining > 0 ? remaining : -1; // Expired or doesn't exist\n }\n\n /**\n * Deletes a key-value pair\n *\n * @param key - The key to delete\n *\n * @example\n * ```typescript\n * kv.delete('user:123');\n * kv.delete('user:123.settings.theme'); // Delete nested property\n * ```\n */\n public delete(key: string): void {\n this.statements.delete.run(key);\n }\n\n /**\n * Checks if a key exists and is not expired\n *\n * @param key - The key to check\n * @returns `true` if the key exists and is not expired, `false` otherwise\n *\n * @example\n * ```typescript\n * if (kv.has('user:123')) {\n * console.log('User exists and is not expired');\n * }\n *\n * if (kv.has('user:123.settings.theme')) {\n * console.log('Theme setting exists');\n * }\n * ```\n */\n public has(key: string): boolean {\n const result = this.statements.has.get(key, this.getCurrentTime());\n\n return (\n result?.count !== undefined &&\n result.count !== null &&\n Number(result.count) > 0\n );\n }\n\n /**\n * Gets all keys in the current namespace (excluding expired keys)\n *\n * @returns Array of all non-expired keys\n *\n * @example\n * ```typescript\n * const keys = kv.keys();\n * console.log('All keys:', keys);\n * ```\n */\n public keys(): string[] {\n const result = this.statements.keys.all(this.getCurrentTime());\n\n return result.map((row) => row.key as string);\n }\n\n /**\n * Gets all values in the current namespace (excluding expired keys)\n *\n * @returns Array of all non-expired values\n *\n * @example\n * ```typescript\n * const values = kv.values();\n * console.log('All values:', values);\n * ```\n */\n public values(): any[] {\n const result = this.statements.values.all(this.getCurrentTime());\n\n return result.map((row) => {\n const serialized = JSON.parse(row.value as string);\n return deserializer(serialized);\n });\n }\n\n /**\n * Gets the total number of key-value pairs in the current namespace (excluding expired keys)\n *\n * @returns The count of non-expired key-value pairs\n *\n * @example\n * ```typescript\n * const count = kv.count();\n * console.log(`Total entries: ${count}`);\n * ```\n */\n public count(): number {\n const result = this.statements.count.get(this.getCurrentTime());\n\n return Number(result?.count ?? 0);\n }\n\n /**\n * Removes all key-value pairs from the current namespace\n *\n * @example\n * ```typescript\n * kv.clear(); // Removes all entries in current namespace\n * ```\n */\n public clear(): void {\n this.statements.clear.run();\n }\n\n /**\n * Gets all key-value pairs as an object (excluding expired keys)\n *\n * @returns Object with all non-expired key-value pairs\n *\n * @example\n * ```typescript\n * const all = kv.all();\n * console.log('All entries:', all);\n * // Output: { 'key1': value1, 'key2': value2 }\n * ```\n */\n public all(): Record<string, any> {\n const result = this.statements.all.all(this.getCurrentTime());\n\n return Object.fromEntries(\n result.map((row) => {\n const serialized = JSON.parse(row.value as string);\n return [row.key as string, deserializer(serialized)];\n }),\n );\n }\n\n /**\n * Gets all available namespaces (tables) in the database\n *\n * @returns Array of namespace names\n *\n * @example\n * ```typescript\n * const namespaces = kv.namespaces();\n * console.log('Available namespaces:', namespaces);\n * ```\n */\n public namespaces(): string[] {\n const result = this.statements.namespaces.all();\n\n return result.map((row) => row.name as string);\n }\n\n /**\n * Gets the current namespace name\n *\n * @returns The current namespace string\n */\n public getCurrentNamespace(): string {\n return this.options.namespace ?? 'commandkit_kv';\n }\n\n /**\n * Creates a new KV instance with a different namespace\n *\n * @param namespace - The namespace to use for the new instance\n * @returns A new KV instance with the specified namespace\n *\n * @example\n * ```typescript\n * const userKv = kv.namespace('users');\n * const configKv = kv.namespace('config');\n *\n * userKv.set('123', { name: 'John', age: 30 });\n * configKv.set('theme', 'dark');\n * ```\n */\n public namespace(namespace: string): KV {\n return new KV(this.db, {\n enableWAL: this.options.enableWAL,\n namespace,\n });\n }\n\n /**\n * Iterator implementation for iterating over all non-expired key-value pairs\n *\n * @returns Iterator yielding [key, value] tuples\n *\n * @example\n * ```typescript\n * for (const [key, value] of kv) {\n * console.log(`${key}:`, value);\n * }\n *\n * // Or using spread operator\n * const entries = [...kv];\n * ```\n */\n public *[Symbol.iterator](): Iterator<[string, any]> {\n const result = this.statements.all.iterate(this.getCurrentTime());\n\n for (const row of result) {\n const serialized = JSON.parse(row.value as string);\n yield [row.key as string, deserializer(serialized)];\n }\n }\n\n /**\n * Executes a function within a transaction\n *\n * @param fn - Function to execute within the transaction (can be async)\n * @returns The result of the function\n *\n * @example\n * ```typescript\n * // Synchronous transaction\n * kv.transaction(() => {\n * kv.set('user:123', { name: 'John', age: 30 });\n * kv.set('user:456', { name: 'Jane', age: 25 });\n * // If any operation fails, all changes are rolled back\n * });\n *\n * // Async transaction\n * await kv.transaction(async () => {\n * kv.set('user:123', { name: 'John', age: 30 });\n * await someAsyncOperation();\n * kv.set('user:456', { name: 'Jane', age: 25 });\n * // If any operation fails, all changes are rolled back\n * });\n * ```\n */\n public async transaction<T>(fn: () => T | Promise<T>): Promise<T> {\n try {\n // Begin transaction\n this.statements.begin.run();\n\n // Execute the function\n const result = await fn();\n\n // Commit transaction\n this.statements.commit.run();\n\n return result;\n } catch (error) {\n // Rollback transaction on error\n this.statements.rollback.run();\n throw error;\n }\n }\n}\n\n/**\n * Opens a new KV instance\n *\n * @param path - Database file path, buffer, URL, or existing DatabaseSync instance\n * @param options - Configuration options for the KV store\n * @returns A new KV instance\n */\nexport function openKV(\n path: string | Buffer | URL | DatabaseSync = 'commandkit_kv.db',\n options: KvOptions = { enableWAL: true, namespace: 'commandkit_kv' },\n): KV {\n return new KV(path, options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,IAAa,KAA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AAQ;GAClB,MAAM,aAAa,KAAK,MAAM,IAAI;AAClC,UAAO,CAAC,IAAI,KAAe,2BAAa,YAAY;EACrD;CAEL;;;;;;;;;;;;CAaA,AAAO,aAAuB;EAC5B,MAAM,SAAS,KAAK,WAAW,WAAW;AAE1C,SAAO,OAAO,KAAK,QAAQ,IAAI;CACjC;;;;;;CAOA,AAAO,sBAA8B;AACnC,SAAO,KAAK,QAAQ,aAAa;CACnC;;;;;;;;;;;;;;;;CAiBA,AAAO,UAAU,WAAuB;AACtC,SAAO,IAAI,GAAG,KAAK,IAAI;GACrB,WAAW,KAAK,QAAQ;GACxB;GACD;CACH;;;;;;;;;;;;;;;;CAiBA,EAAS,OAAO,YAAqC;EACnD,MAAM,SAAS,KAAK,WAAW,IAAI,QAAQ,KAAK;AAEhD,OAAK,MAAM,OAAO,QAAQ;GACxB,MAAM,aAAa,KAAK,MAAM,IAAI;AAClC,SAAM,CAAC,IAAI,KAAe,2BAAa,YAAY;EACrD;CACF;;;;;;;;;;;;;;;;;;;;;;;;;CA0BA,MAAa,YAAe,IAAsC;AAChE,MAAI;AAEF,QAAK,WAAW,MAAM;GAGtB,MAAM,SAAS,MAAM;AAGrB,QAAK,WAAW,OAAO;AAEvB,UAAO;EACR,SAAQ,OAAO;AAEd,QAAK,WAAW,SAAS;AACzB,SAAM;EACR;CACF;AACF;;;;;;;;AASA,SAAgB,OAChB,OAA6C,oBAC7C,UAAqB;CAAE,WAAW;CAAM,WAAW;CAAiB,EAC/D;AACH,QAAO,IAAI,GAAG,MAAM;AACtB"}
1
+ {"version":3,"file":"kv.js","names":[],"sources":["../../src/kv/kv.ts"],"sourcesContent":["import { DatabaseSync, StatementSync } from 'node:sqlite';\nimport { deserializer, serializer } from './serde';\nimport { getNestedValue, setNestedValue } from './dotprops';\n\nexport type { SerializedValue } from './serde';\n\n/**\n * Mathematical operators supported by the KV math method\n */\nexport type KvMathOperator = '+' | '-' | '*' | '/' | '^' | '%';\n\n/**\n * Configuration options for the KV store\n */\nexport interface KvOptions {\n /** Enable Write-Ahead Logging for better performance and durability */\n enableWAL?: boolean;\n /** Namespace for the key-value store table */\n namespace?: string;\n}\n\n/**\n * A key-value store implementation using SQLite\n *\n * This class provides a simple, persistent key-value storage solution\n * with support for namespaces, automatic cleanup, iteration, expiration, and JSON serialization.\n *\n * @example\n * ```typescript\n * const kv = new KV('data.db');\n *\n * // Store any JSON-serializable data\n * kv.set('user:123', { name: 'John', age: 30 });\n * kv.set('counter', 42);\n * kv.set('active', true);\n * kv.set('dates', [new Date(), new Date()]);\n *\n * // Use dot notation for nested properties\n * kv.set('user:123.name', 'John');\n * kv.set('user:123.settings.theme', 'dark');\n *\n * // Retrieve data\n * const user = kv.get('user:123'); // { name: 'John', age: 30, settings: { theme: 'dark' } }\n * const name = kv.get('user:123.name'); // 'John'\n * ```\n */\nexport class KV implements Disposable, AsyncDisposable {\n private db: DatabaseSync;\n private statements: Record<string, StatementSync> = {};\n\n /**\n * Creates a new KV store instance\n *\n * @param path - Database file path, buffer, URL, or existing DatabaseSync instance\n * @param options - Configuration options for the KV store\n */\n public constructor(\n path: string | Buffer | URL | DatabaseSync,\n private options: KvOptions = {\n enableWAL: true,\n namespace: 'commandkit_kv',\n },\n ) {\n this.db =\n path instanceof DatabaseSync\n ? path\n : new DatabaseSync(path, { open: true });\n\n if (options.enableWAL) {\n this.db.exec(/* sql */ `PRAGMA journal_mode = WAL;`);\n }\n\n const namespace = this.options.namespace ?? 'commandkit_kv';\n\n this.db.exec(/* sql */ `\n CREATE TABLE IF NOT EXISTS ${namespace} (\n key TEXT PRIMARY KEY,\n value TEXT,\n expires_at INTEGER\n )\n `);\n\n this.statements = {\n get: this.db.prepare(\n /* sql */ `SELECT value, expires_at FROM ${namespace} WHERE key = ?`,\n ),\n set: this.db.prepare(\n /* sql */ `INSERT OR REPLACE INTO ${namespace} (key, value, expires_at) VALUES (?, ?, ?)`,\n ),\n setex: this.db.prepare(\n /* sql */ `INSERT OR REPLACE INTO ${namespace} (key, value, expires_at) VALUES (?, ?, ?)`,\n ),\n delete: this.db.prepare(\n /* sql */ `DELETE FROM ${namespace} WHERE key = ?`,\n ),\n has: this.db.prepare(\n /* sql */ `SELECT COUNT(*) FROM ${namespace} WHERE key = ? AND (expires_at IS NULL OR expires_at > ?)`,\n ),\n keys: this.db.prepare(\n /* sql */ `SELECT key FROM ${namespace} WHERE expires_at IS NULL OR expires_at > ?`,\n ),\n values: this.db.prepare(\n /* sql */ `SELECT value FROM ${namespace} WHERE expires_at IS NULL OR expires_at > ?`,\n ),\n clear: this.db.prepare(/* sql */ `DELETE FROM ${namespace}`),\n count: this.db.prepare(\n /* sql */ `SELECT COUNT(*) FROM ${namespace} WHERE expires_at IS NULL OR expires_at > ?`,\n ),\n all: this.db.prepare(\n /* sql */ `SELECT key, value FROM ${namespace} WHERE expires_at IS NULL OR expires_at > ?`,\n ),\n expire: this.db.prepare(\n /* sql */ `UPDATE ${namespace} SET expires_at = ? WHERE key = ?`,\n ),\n ttl: this.db.prepare(\n /* sql */ `SELECT expires_at FROM ${namespace} WHERE key = ?`,\n ),\n namespaces: this.db.prepare(\n /* sql */ `SELECT name FROM sqlite_master WHERE type = 'table' AND name NOT LIKE 'sqlite_%'`,\n ),\n begin: this.db.prepare(/* sql */ `BEGIN TRANSACTION`),\n commit: this.db.prepare(/* sql */ `COMMIT`),\n rollback: this.db.prepare(/* sql */ `ROLLBACK`),\n };\n }\n\n /**\n * Gets the current timestamp in milliseconds\n */\n private getCurrentTime(): number {\n return Date.now();\n }\n\n /**\n * Checks if the database connection is open\n *\n * @returns `true` if the database is open, `false` otherwise\n */\n public isOpen(): boolean {\n return this.db.isOpen;\n }\n\n /**\n * Gets the underlying SQLite database instance\n *\n * @returns The DatabaseSync instance\n */\n public getDatabase(): DatabaseSync {\n return this.db;\n }\n\n /**\n * Closes the database connection\n */\n public close(): void {\n if (this.db.isOpen) this.db.close();\n }\n\n /**\n * Disposable implementation - closes the database when disposed\n */\n public [Symbol.dispose]() {\n this.close();\n }\n\n /**\n * AsyncDisposable implementation - closes the database when disposed\n */\n public async [Symbol.asyncDispose]() {\n this.close();\n }\n\n /**\n * Retrieves a value by key\n *\n * @param key - The key to retrieve (supports dot notation for nested properties)\n * @returns The value associated with the key, or `undefined` if not found or expired\n *\n * @example\n * ```typescript\n * // Store an object\n * kv.set('user:123', { name: 'John', age: 30, settings: { theme: 'dark' } });\n *\n * // Get the entire object\n * const user = kv.get('user:123');\n * // { name: 'John', age: 30, settings: { theme: 'dark' } }\n *\n * // Get nested properties using dot notation\n * const name = kv.get('user:123.name'); // 'John'\n * const theme = kv.get('user:123.settings.theme'); // 'dark'\n * ```\n */\n public get<T = any>(key: string): T | undefined {\n const result = this.statements.get.get(key);\n\n if (!result) return undefined;\n\n // Check if the key has expired\n if (\n result.expires_at &&\n Number(result.expires_at) <= this.getCurrentTime()\n ) {\n this.delete(key);\n return undefined;\n }\n\n const serialized = JSON.parse(result.value as string);\n const deserialized = deserializer(serialized);\n\n // Handle dot notation for nested properties\n if (key.includes('.')) {\n return getNestedValue(deserialized, key.split('.').slice(1).join('.'));\n }\n\n return deserialized;\n }\n\n /**\n * Sets a key-value pair\n *\n * @param key - The key to set (supports dot notation for nested properties)\n * @param value - The value to associate with the key (any JSON-serializable type)\n *\n * @example\n * ```typescript\n * // Store primitive values\n * kv.set('counter', 42);\n * kv.set('active', true);\n * kv.set('name', 'John');\n *\n * // Store objects\n * kv.set('user:123', { name: 'John', age: 30 });\n *\n * // Store arrays\n * kv.set('tags', ['javascript', 'typescript', 'sqlite']);\n *\n * // Store dates\n * kv.set('created', new Date());\n *\n * // Store maps and sets\n * kv.set('permissions', new Map([['admin', true], ['user', false]]));\n * kv.set('unique_ids', new Set([1, 2, 3, 4, 5]));\n *\n * // Use dot notation for nested properties\n * kv.set('user:123.settings.theme', 'dark');\n * kv.set('user:123.settings.notifications', true);\n * ```\n */\n public set(key: string, value: any): void {\n let serializedValue: string;\n\n if (key.includes('.')) {\n // Handle dot notation for nested properties\n const [baseKey, ...pathParts] = key.split('.');\n const path = pathParts.join('.');\n\n // Get existing value or create new object\n const existing = this.get(baseKey) || {};\n setNestedValue(existing, path, value);\n\n const serialized = serializer(existing);\n serializedValue = JSON.stringify(serialized);\n\n this.statements.set.run(baseKey, serializedValue, null);\n } else {\n const serialized = serializer(value);\n serializedValue = JSON.stringify(serialized);\n\n this.statements.set.run(key, serializedValue, null);\n }\n }\n\n /**\n * Sets a key-value pair with expiration\n *\n * @param key - The key to set (supports dot notation for nested properties)\n * @param value - The value to associate with the key (any JSON-serializable type)\n * @param ttl - Time to live in milliseconds\n *\n * @example\n * ```typescript\n * // Set with 1 hour expiration\n * kv.setex('session:123', { userId: 123, token: 'abc123' }, 60 * 60 * 1000);\n *\n * // Set with 5 minutes expiration\n * kv.setex('temp:data', { cached: true, timestamp: Date.now() }, 5 * 60 * 1000);\n *\n * // Use dot notation with expiration\n * kv.setex('user:123.temp_settings', { theme: 'light' }, 30 * 60 * 1000);\n * ```\n */\n public setex(key: string, value: any, ttl: number): void {\n const expiresAt = this.getCurrentTime() + ttl;\n let serializedValue: string;\n\n if (key.includes('.')) {\n // Handle dot notation for nested properties\n const [baseKey, ...pathParts] = key.split('.');\n const path = pathParts.join('.');\n\n // Get existing value or create new object\n const existing = this.get(baseKey) || {};\n setNestedValue(existing, path, value);\n\n const serialized = serializer(existing);\n serializedValue = JSON.stringify(serialized);\n\n this.statements.setex.run(baseKey, serializedValue, expiresAt);\n } else {\n const serialized = serializer(value);\n serializedValue = JSON.stringify(serialized);\n\n this.statements.setex.run(key, serializedValue, expiresAt);\n }\n }\n\n /**\n * Performs mathematical operations on numeric values in the KV store\n *\n * @param key - The key to perform math operation on (supports dot notation for nested properties)\n * @param operator - The mathematical operator to apply\n * @param value - The value to use in the operation\n * @returns The updated value after the mathematical operation\n * @throws Error if the existing value is not numeric or if the operation is invalid\n *\n * @example\n * ```typescript\n * // Initialize a counter\n * kv.set('counter', 10);\n *\n * // Increment by 5\n * const result1 = kv.math('counter', '+', 5); // 15\n *\n * // Multiply by 2\n * const result2 = kv.math('counter', '*', 2); // 30\n *\n * // Use with bigint\n * kv.set('big_counter', BigInt(1000));\n * const result3 = kv.math('big_counter', '+', BigInt(500)); // 1500n\n *\n * // Use with dot notation\n * kv.set('user:123', { score: 100, level: 5 });\n * const result4 = kv.math('user:123.score', '+', 50); // 150\n * ```\n */\n public math(\n key: string,\n operator: KvMathOperator,\n value: number | bigint,\n ): number | bigint {\n const existingValue = this.get(key);\n\n if (existingValue === undefined) {\n throw new Error(`Key '${key}' does not exist`);\n }\n\n if (\n typeof existingValue !== 'number' &&\n typeof existingValue !== 'bigint'\n ) {\n throw new Error(\n `Value at key '${key}' is not numeric. Expected number or bigint, got ${typeof existingValue}`,\n );\n }\n\n // Handle mixed number/bigint operations by converting to bigint\n const isBigIntOperation =\n typeof existingValue === 'bigint' || typeof value === 'bigint';\n\n const existing = isBigIntOperation\n ? typeof existingValue === 'bigint'\n ? existingValue\n : BigInt(existingValue)\n : (existingValue as number);\n const operand = isBigIntOperation\n ? typeof value === 'bigint'\n ? value\n : BigInt(value)\n : (value as number);\n\n let result: number | bigint;\n\n switch (operator) {\n case '+':\n result = (existing as any) + (operand as any);\n break;\n case '-':\n result = (existing as any) - (operand as any);\n break;\n case '*':\n result = (existing as any) * (operand as any);\n break;\n case '/':\n if (operand === 0 || operand === 0n) {\n throw new Error('Division by zero');\n }\n result = (existing as any) / (operand as any);\n break;\n case '^':\n if (isBigIntOperation && operand < 0n) {\n throw new Error(\n 'Exponentiation with negative exponent is not supported for bigint',\n );\n }\n result = (existing as any) ** (operand as any);\n break;\n case '%':\n if (operand === 0 || operand === 0n) {\n throw new Error('Modulo by zero');\n }\n result = (existing as any) % (operand as any);\n break;\n default:\n throw new Error(`Invalid operator: ${operator}`);\n }\n\n // Update the value in the store\n this.set(key, result);\n\n return result;\n }\n\n /**\n * Sets expiration for an existing key\n *\n * @param key - The key to set expiration for\n * @param ttl - Time to live in milliseconds\n * @returns `true` if the key exists and expiration was set, `false` otherwise\n *\n * @example\n * ```typescript\n * kv.set('user:123', { name: 'John', age: 30 });\n *\n * // Set 30 minute expiration\n * if (kv.expire('user:123', 30 * 60 * 1000)) {\n * console.log('Expiration set successfully');\n * }\n * ```\n */\n public expire(key: string, ttl: number): boolean {\n if (!this.has(key)) return false;\n\n const expiresAt = this.getCurrentTime() + ttl;\n this.statements.expire.run(expiresAt, key);\n return true;\n }\n\n /**\n * Gets the time to live for a key\n *\n * @param key - The key to check\n * @returns Time to live in milliseconds, or `-1` if the key doesn't exist, or `-2` if the key has no expiration\n *\n * @example\n * ```typescript\n * const ttl = kv.ttl('user:123');\n * if (ttl > 0) {\n * console.log(`Key expires in ${ttl}ms`);\n * } else if (ttl === -2) {\n * console.log('Key has no expiration');\n * } else {\n * console.log('Key does not exist');\n * }\n * ```\n */\n public ttl(key: string): number {\n const result = this.statements.ttl.get(key);\n\n if (!result) return -1; // Key doesn't exist\n\n if (!result.expires_at) return -2; // No expiration\n\n const remaining = Number(result.expires_at) - this.getCurrentTime();\n return remaining > 0 ? remaining : -1; // Expired or doesn't exist\n }\n\n /**\n * Deletes a key-value pair\n *\n * @param key - The key to delete\n *\n * @example\n * ```typescript\n * kv.delete('user:123');\n * kv.delete('user:123.settings.theme'); // Delete nested property\n * ```\n */\n public delete(key: string): void {\n this.statements.delete.run(key);\n }\n\n /**\n * Checks if a key exists and is not expired\n *\n * @param key - The key to check\n * @returns `true` if the key exists and is not expired, `false` otherwise\n *\n * @example\n * ```typescript\n * if (kv.has('user:123')) {\n * console.log('User exists and is not expired');\n * }\n *\n * if (kv.has('user:123.settings.theme')) {\n * console.log('Theme setting exists');\n * }\n * ```\n */\n public has(key: string): boolean {\n const result = this.statements.has.get(key, this.getCurrentTime());\n\n return (\n result?.count !== undefined &&\n result.count !== null &&\n Number(result.count) > 0\n );\n }\n\n /**\n * Gets all keys in the current namespace (excluding expired keys)\n *\n * @returns Array of all non-expired keys\n *\n * @example\n * ```typescript\n * const keys = kv.keys();\n * console.log('All keys:', keys);\n * ```\n */\n public keys(): string[] {\n const result = this.statements.keys.all(this.getCurrentTime());\n\n return result.map((row) => row.key as string);\n }\n\n /**\n * Gets all values in the current namespace (excluding expired keys)\n *\n * @returns Array of all non-expired values\n *\n * @example\n * ```typescript\n * const values = kv.values();\n * console.log('All values:', values);\n * ```\n */\n public values(): any[] {\n const result = this.statements.values.all(this.getCurrentTime());\n\n return result.map((row) => {\n const serialized = JSON.parse(row.value as string);\n return deserializer(serialized);\n });\n }\n\n /**\n * Gets the total number of key-value pairs in the current namespace (excluding expired keys)\n *\n * @returns The count of non-expired key-value pairs\n *\n * @example\n * ```typescript\n * const count = kv.count();\n * console.log(`Total entries: ${count}`);\n * ```\n */\n public count(): number {\n const result = this.statements.count.get(this.getCurrentTime());\n\n return Number(result?.count ?? 0);\n }\n\n /**\n * Removes all key-value pairs from the current namespace\n *\n * @example\n * ```typescript\n * kv.clear(); // Removes all entries in current namespace\n * ```\n */\n public clear(): void {\n this.statements.clear.run();\n }\n\n /**\n * Gets all key-value pairs as an object (excluding expired keys)\n *\n * @returns Object with all non-expired key-value pairs\n *\n * @example\n * ```typescript\n * const all = kv.all();\n * console.log('All entries:', all);\n * // Output: { 'key1': value1, 'key2': value2 }\n * ```\n */\n public all(): Record<string, any> {\n const result = this.statements.all.all(this.getCurrentTime());\n\n return Object.fromEntries(\n result.map((row) => {\n const serialized = JSON.parse(row.value as string);\n return [row.key as string, deserializer(serialized)];\n }),\n );\n }\n\n /**\n * Gets all available namespaces (tables) in the database\n *\n * @returns Array of namespace names\n *\n * @example\n * ```typescript\n * const namespaces = kv.namespaces();\n * console.log('Available namespaces:', namespaces);\n * ```\n */\n public namespaces(): string[] {\n const result = this.statements.namespaces.all();\n\n return result.map((row) => row.name as string);\n }\n\n /**\n * Gets the current namespace name\n *\n * @returns The current namespace string\n */\n public getCurrentNamespace(): string {\n return this.options.namespace ?? 'commandkit_kv';\n }\n\n /**\n * Creates a new KV instance with a different namespace\n *\n * @param namespace - The namespace to use for the new instance\n * @returns A new KV instance with the specified namespace\n *\n * @example\n * ```typescript\n * const userKv = kv.namespace('users');\n * const configKv = kv.namespace('config');\n *\n * userKv.set('123', { name: 'John', age: 30 });\n * configKv.set('theme', 'dark');\n * ```\n */\n public namespace(namespace: string): KV {\n return new KV(this.db, {\n enableWAL: this.options.enableWAL,\n namespace,\n });\n }\n\n /**\n * Iterator implementation for iterating over all non-expired key-value pairs\n *\n * @returns Iterator yielding [key, value] tuples\n *\n * @example\n * ```typescript\n * for (const [key, value] of kv) {\n * console.log(`${key}:`, value);\n * }\n *\n * // Or using spread operator\n * const entries = [...kv];\n * ```\n */\n public *[Symbol.iterator](): Iterator<[string, any]> {\n const result = this.statements.all.iterate(this.getCurrentTime());\n\n for (const row of result) {\n const serialized = JSON.parse(row.value as string);\n yield [row.key as string, deserializer(serialized)];\n }\n }\n\n /**\n * Executes a function within a transaction\n *\n * @param fn - Function to execute within the transaction (can be async)\n * @returns The result of the function\n *\n * @example\n * ```typescript\n * // Synchronous transaction\n * kv.transaction(() => {\n * kv.set('user:123', { name: 'John', age: 30 });\n * kv.set('user:456', { name: 'Jane', age: 25 });\n * // If any operation fails, all changes are rolled back\n * });\n *\n * // Async transaction\n * await kv.transaction(async () => {\n * kv.set('user:123', { name: 'John', age: 30 });\n * await someAsyncOperation();\n * kv.set('user:456', { name: 'Jane', age: 25 });\n * // If any operation fails, all changes are rolled back\n * });\n * ```\n */\n public async transaction<T>(fn: () => T | Promise<T>): Promise<T> {\n try {\n // Begin transaction\n this.statements.begin.run();\n\n // Execute the function\n const result = await fn();\n\n // Commit transaction\n this.statements.commit.run();\n\n return result;\n } catch (error) {\n // Rollback transaction on error\n this.statements.rollback.run();\n throw error;\n }\n }\n}\n\n/**\n * Opens a new KV instance\n *\n * @param path - Database file path, buffer, URL, or existing DatabaseSync instance\n * @param options - Configuration options for the KV store\n * @returns A new KV instance\n */\nexport function openKV(\n path: string | Buffer | URL | DatabaseSync = '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Q;GAClB,MAAM,aAAa,KAAK,MAAM,IAAI;AAClC,UAAO,CAAC,IAAI,KAAe,2BAAa;;;;;;;;;;;;;;CAgB9C,AAAO,aAAuB;EAC5B,MAAM,SAAS,KAAK,WAAW,WAAW;AAE1C,SAAO,OAAO,KAAK,QAAQ,IAAI;;;;;;;CAQjC,AAAO,sBAA8B;AACnC,SAAO,KAAK,QAAQ,aAAa;;;;;;;;;;;;;;;;;CAkBnC,AAAO,UAAU,WAAuB;AACtC,SAAO,IAAI,GAAG,KAAK,IAAI;GACrB,WAAW,KAAK,QAAQ;GACxB;;;;;;;;;;;;;;;;;;CAmBJ,EAAS,OAAO,YAAqC;EACnD,MAAM,SAAS,KAAK,WAAW,IAAI,QAAQ,KAAK;AAEhD,OAAK,MAAM,OAAO,QAAQ;GACxB,MAAM,aAAa,KAAK,MAAM,IAAI;AAClC,SAAM,CAAC,IAAI,KAAe,2BAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4B3C,MAAa,YAAe,IAAsC;AAChE,MAAI;AAEF,QAAK,WAAW,MAAM;GAGtB,MAAM,SAAS,MAAM;AAGrB,QAAK,WAAW,OAAO;AAEvB,UAAO;WACA,OAAO;AAEd,QAAK,WAAW,SAAS;AACzB,SAAM;;;;;;;;;;;AAYZ,SAAgB,OAChB,OAA6C,oBAC7C,UAAqB;CAAE,WAAW;CAAM,WAAW;GAC9C;AACH,QAAO,IAAI,GAAG,MAAM"}
@@ -1,3 +1,3 @@
1
- import "../ILogger-DBGON5wx.js";
2
- import { DefaultLogger } from "../DefaultLogger-Cy55-uPl.js";
1
+ import "../ILogger-BW8GM-YZ.js";
2
+ import { DefaultLogger } from "../DefaultLogger-XCOl5nLd.js";
3
3
  export { DefaultLogger };
@@ -1,7 +1,7 @@
1
1
  require('../colors-Cd4Oz-r-.js');
2
2
  require('../ActionRow-CmTHbo2t.js');
3
3
  require('../error-codes-C-ViHyu-.js');
4
- const require_commandkit = require('../commandkit-C0BuNRSN.js');
4
+ const require_commandkit = require('../commandkit-CYJ8d2gj.js');
5
5
  require('../common-CcfjYnPG.js');
6
6
  require('../common-vnMIelAE.js');
7
7
  require('../container-z621KfH5.js');
@@ -1,2 +1,2 @@
1
- import { ILogger } from "../ILogger-DBGON5wx.js";
1
+ import { ILogger } from "../ILogger-BW8GM-YZ.js";
2
2
  export { ILogger };
@@ -1,3 +1,3 @@
1
- import "../ILogger-DBGON5wx.js";
2
- import { CommandKitLoggerOptions, Logger, LoggerImpl, createLogger } from "../Logger-iSjA-DWN.js";
1
+ import "../ILogger-BW8GM-YZ.js";
2
+ import { CommandKitLoggerOptions, Logger, LoggerImpl, createLogger } from "../Logger-DyfkPk7u.js";
3
3
  export { CommandKitLoggerOptions, Logger, LoggerImpl, createLogger };
@@ -1,7 +1,7 @@
1
1
  require('../colors-Cd4Oz-r-.js');
2
2
  require('../ActionRow-CmTHbo2t.js');
3
3
  require('../error-codes-C-ViHyu-.js');
4
- const require_commandkit = require('../commandkit-C0BuNRSN.js');
4
+ const require_commandkit = require('../commandkit-CYJ8d2gj.js');
5
5
  require('../common-CcfjYnPG.js');
6
6
  require('../common-vnMIelAE.js');
7
7
  require('../container-z621KfH5.js');
@@ -1,4 +1,4 @@
1
- import { ILogger } from "../ILogger-DBGON5wx.js";
1
+ import { ILogger } from "../ILogger-BW8GM-YZ.js";
2
2
 
3
3
  //#region src/logger/NoopLogger.d.ts
4
4
 
@@ -8,29 +8,59 @@ import { ILogger } from "../ILogger-DBGON5wx.js";
8
8
  declare class NoopLogger implements ILogger {
9
9
  /**
10
10
  * Logs a debug message.
11
- * @param args The message arguments to log.
11
+ * @param message The message to log.
12
12
  */
13
- debug(...args: any[]): void;
13
+ debug(message: any): void;
14
+ /**
15
+ * Logs a debug message using template literals.
16
+ * @param strings The template literal strings.
17
+ * @param values The values to interpolate.
18
+ */
19
+ debug(strings: TemplateStringsArray, ...values: any[]): void;
14
20
  /**
15
21
  * Logs an error message.
16
- * @param args The message arguments to log.
22
+ * @param message The error message to log.
17
23
  */
18
- error(...args: any[]): void;
24
+ error(message: any): void;
25
+ /**
26
+ * Logs an error message using template literals.
27
+ * @param strings The template literal strings.
28
+ * @param values The values to interpolate.
29
+ */
30
+ error(strings: TemplateStringsArray, ...values: any[]): void;
19
31
  /**
20
32
  * Logs a default message.
21
- * @param args The message arguments to log.
33
+ * @param message The message to log.
34
+ */
35
+ log(message: any): void;
36
+ /**
37
+ * Logs a default message using template literals.
38
+ * @param strings The template literal strings.
39
+ * @param values The values to interpolate.
22
40
  */
23
- log(...args: any[]): void;
41
+ log(strings: TemplateStringsArray, ...values: any[]): void;
24
42
  /**
25
43
  * Logs an info message.
26
- * @param args The message arguments to log.
44
+ * @param message The informational message to log.
45
+ */
46
+ info(message: any): void;
47
+ /**
48
+ * Logs an info message using template literals.
49
+ * @param strings The template literal strings.
50
+ * @param values The values to interpolate.
27
51
  */
28
- info(...args: any[]): void;
52
+ info(strings: TemplateStringsArray, ...values: any[]): void;
29
53
  /**
30
54
  * Logs a warning message.
31
- * @param args The message arguments to log.
55
+ * @param message The warning message to log.
56
+ */
57
+ warn(message: any): void;
58
+ /**
59
+ * Logs a warning message using template literals.
60
+ * @param strings The template literal strings.
61
+ * @param values The values to interpolate.
32
62
  */
33
- warn(...args: any[]): void;
63
+ warn(strings: TemplateStringsArray, ...values: any[]): void;
34
64
  }
35
65
  //#endregion
36
66
  export { NoopLogger };
@@ -4,31 +4,11 @@
4
4
  * Noop logger implementation that does nothing.
5
5
  */
6
6
  var NoopLogger = class {
7
- /**
8
- * Logs a debug message.
9
- * @param args The message arguments to log.
10
- */
11
- debug(...args) {}
12
- /**
13
- * Logs an error message.
14
- * @param args The message arguments to log.
15
- */
16
- error(...args) {}
17
- /**
18
- * Logs a default message.
19
- * @param args The message arguments to log.
20
- */
21
- log(...args) {}
22
- /**
23
- * Logs an info message.
24
- * @param args The message arguments to log.
25
- */
26
- info(...args) {}
27
- /**
28
- * Logs a warning message.
29
- * @param args The message arguments to log.
30
- */
31
- warn(...args) {}
7
+ debug(messageOrStrings, ...values) {}
8
+ error(messageOrStrings, ...values) {}
9
+ log(messageOrStrings, ...values) {}
10
+ info(messageOrStrings, ...values) {}
11
+ warn(messageOrStrings, ...values) {}
32
12
  };
33
13
 
34
14
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"NoopLogger.js","names":[],"sources":["../../src/logger/NoopLogger.ts"],"sourcesContent":["import { ILogger } from './ILogger';\n\n/**\n * Noop logger implementation that does nothing.\n */\nexport class NoopLogger implements ILogger {\n /**\n * Logs a debug message.\n * @param args The message arguments to log.\n */\n public debug(...args: any[]): void {}\n\n /**\n * Logs an error message.\n * @param args The message arguments to log.\n */\n public error(...args: any[]): void {}\n\n /**\n * Logs a default message.\n * @param args The message arguments to log.\n */\n public log(...args: any[]): void {}\n\n /**\n * Logs an info message.\n * @param args The message arguments to log.\n */\n public info(...args: any[]): void {}\n\n /**\n * Logs a warning message.\n * @param args The message arguments to log.\n */\n public warn(...args: any[]): void {}\n}\n"],"mappings":";;;;;AAKA,IAAa,aAAb,MAA2C;;;;;CAKzC,AAAO,MAAM,GAAG,MAAmB,CAAC;;;;;CAMpC,AAAO,MAAM,GAAG,MAAmB,CAAC;;;;;CAMpC,AAAO,IAAI,GAAG,MAAmB,CAAC;;;;;CAMlC,AAAO,KAAK,GAAG,MAAmB,CAAC;;;;;CAMnC,AAAO,KAAK,GAAG,MAAmB,CAAC;AACrC"}
1
+ {"version":3,"file":"NoopLogger.js","names":[],"sources":["../../src/logger/NoopLogger.ts"],"sourcesContent":["import { ILogger } from './ILogger';\n\n/**\n * Noop logger implementation that does nothing.\n */\nexport class NoopLogger implements ILogger {\n /**\n * Logs a debug message.\n * @param message The message to log.\n */\n public debug(message: any): void;\n /**\n * Logs a debug message using template literals.\n * @param strings The template literal strings.\n * @param values The values to interpolate.\n */\n public debug(strings: TemplateStringsArray, ...values: any[]): void;\n public debug(\n messageOrStrings: any | TemplateStringsArray,\n ...values: any[]\n ): void {}\n\n /**\n * Logs an error message.\n * @param message The error message to log.\n */\n public error(message: any): void;\n /**\n * Logs an error message using template literals.\n * @param strings The template literal strings.\n * @param values The values to interpolate.\n */\n public error(strings: TemplateStringsArray, ...values: any[]): void;\n public error(\n messageOrStrings: any | TemplateStringsArray,\n ...values: any[]\n ): void {}\n\n /**\n * Logs a default message.\n * @param message The message to log.\n */\n public log(message: any): void;\n /**\n * Logs a default message using template literals.\n * @param strings The template literal strings.\n * @param values The values to interpolate.\n */\n public log(strings: TemplateStringsArray, ...values: any[]): void;\n public log(\n messageOrStrings: any | TemplateStringsArray,\n ...values: any[]\n ): void {}\n\n /**\n * Logs an info message.\n * @param message The informational message to log.\n */\n public info(message: any): void;\n /**\n * Logs an info message using template literals.\n * @param strings The template literal strings.\n * @param values The values to interpolate.\n */\n public info(strings: TemplateStringsArray, ...values: any[]): void;\n public info(\n messageOrStrings: any | TemplateStringsArray,\n ...values: any[]\n ): void {}\n\n /**\n * Logs a warning message.\n * @param message The warning message to log.\n */\n public warn(message: any): void;\n /**\n * Logs a warning message using template literals.\n * @param strings The template literal strings.\n * @param values The values to interpolate.\n */\n public warn(strings: TemplateStringsArray, ...values: any[]): void;\n public warn(\n messageOrStrings: any | TemplateStringsArray,\n ...values: any[]\n ): void {}\n}\n"],"mappings":";;;;;AAKA,IAAa,aAAb,MAA2C;CAYzC,AAAO,MACP,kBACA,GAAG,QACI;CAaP,AAAO,MACP,kBACA,GAAG,QACI;CAaP,AAAO,IACP,kBACA,GAAG,QACI;CAaP,AAAO,KACP,kBACA,GAAG,QACI;CAaP,AAAO,KACP,kBACA,GAAG,QACI"}
@@ -1 +1 @@
1
- {"version":3,"file":"media-gallery-CIKypjbJ.js","names":[],"sources":["../src/components/v2/media-gallery.ts"],"sourcesContent":["import { MediaGalleryBuilder, MediaGalleryItemBuilder } from 'discord.js';\nimport { applyId } from './common';\n\n/**\n * Represents the properties for a media gallery component.\n */\nexport interface MediaGalleryProps {\n id?: number;\n children?: MediaGalleryItemBuilder[];\n}\n\n/**\n * The media gallery component\n * @param props The properties for the media gallery component.\n * @returns The media gallery builder instance.\n * @example ```tsx\n * import { MediaGallery } from 'commandkit';\n *\n * const gallery = (\n * <MediaGallery>\n * <MediaGalleryItem url=\"https://example.com/image1.png\" description=\"Image 1\" />\n * <MediaGalleryItem url=\"https://example.com/image2.png\" description=\"Image 2\" />\n * </MediaGallery>\n * );\n * ```\n */\nexport function MediaGallery(props: MediaGalleryProps) {\n const gallery = new MediaGalleryBuilder();\n\n applyId(props, gallery);\n\n if (props.children != null) {\n if (!Array.isArray(props.children)) props.children = [props.children];\n gallery.addItems(props.children.flat());\n }\n\n return gallery;\n}\n\n/**\n * Represents the properties for a media gallery item component.\n */\nexport interface MediaGalleryItemProps {\n description?: string;\n spoiler?: boolean;\n url?: string;\n}\n\n/**\n * The media gallery item component\n * @param props The properties for the media gallery item component.\n * @returns The media gallery item builder instance.\n * @example ```tsx\n * import { MediaGalleryItem } from 'commandkit';\n *\n * const item = <MediaGalleryItem url=\"https://example.com/image.png\" description=\"An image\" />;\n * ```\n */\nexport function MediaGalleryItem(props: MediaGalleryItemProps) {\n const item = new MediaGalleryItemBuilder();\n\n if (props.description != null) {\n item.setDescription(props.description);\n }\n\n if (props.spoiler != null) {\n item.setSpoiler(props.spoiler);\n }\n\n if (props.url != null) {\n item.setURL(props.url);\n }\n\n return item;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,aAAa,OAA0B;CACrD,MAAM,UAAU,IAAI;AAEpB,wBAAQ,OAAO;AAEf,KAAI,MAAM,YAAY,MAAM;AAC1B,MAAI,CAAC,MAAM,QAAQ,MAAM,UAAW,OAAM,WAAW,CAAC,MAAM,SAAS;AACrE,UAAQ,SAAS,MAAM,SAAS;CAClC;AAEA,QAAO;AACT;;;;;;;;;;;AAqBA,SAAgB,iBAAiB,OAA8B;CAC7D,MAAM,OAAO,IAAI;AAEjB,KAAI,MAAM,eAAe,KACvB,MAAK,eAAe,MAAM;AAG5B,KAAI,MAAM,WAAW,KACnB,MAAK,WAAW,MAAM;AAGxB,KAAI,MAAM,OAAO,KACf,MAAK,OAAO,MAAM;AAGpB,QAAO;AACT"}
1
+ {"version":3,"file":"media-gallery-CIKypjbJ.js","names":[],"sources":["../src/components/v2/media-gallery.ts"],"sourcesContent":["import { MediaGalleryBuilder, MediaGalleryItemBuilder } from 'discord.js';\nimport { applyId } from './common';\n\n/**\n * Represents the properties for a media gallery component.\n */\nexport interface MediaGalleryProps {\n id?: number;\n children?: MediaGalleryItemBuilder[];\n}\n\n/**\n * The media gallery component\n * @param props The properties for the media gallery component.\n * @returns The media gallery builder instance.\n * @example ```tsx\n * import { MediaGallery } from 'commandkit';\n *\n * const gallery = (\n * <MediaGallery>\n * <MediaGalleryItem url=\"https://example.com/image1.png\" description=\"Image 1\" />\n * <MediaGalleryItem url=\"https://example.com/image2.png\" description=\"Image 2\" />\n * </MediaGallery>\n * );\n * ```\n */\nexport function MediaGallery(props: MediaGalleryProps) {\n const gallery = new MediaGalleryBuilder();\n\n applyId(props, gallery);\n\n if (props.children != null) {\n if (!Array.isArray(props.children)) props.children = [props.children];\n gallery.addItems(props.children.flat());\n }\n\n return gallery;\n}\n\n/**\n * Represents the properties for a media gallery item component.\n */\nexport interface MediaGalleryItemProps {\n description?: string;\n spoiler?: boolean;\n url?: string;\n}\n\n/**\n * The media gallery item component\n * @param props The properties for the media gallery item component.\n * @returns The media gallery item builder instance.\n * @example ```tsx\n * import { MediaGalleryItem } from 'commandkit';\n *\n * const item = <MediaGalleryItem url=\"https://example.com/image.png\" description=\"An image\" />;\n * ```\n */\nexport function MediaGalleryItem(props: MediaGalleryItemProps) {\n const item = new MediaGalleryItemBuilder();\n\n if (props.description != null) {\n item.setDescription(props.description);\n }\n\n if (props.spoiler != null) {\n item.setSpoiler(props.spoiler);\n }\n\n if (props.url != null) {\n item.setURL(props.url);\n }\n\n return item;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,aAAa,OAA0B;CACrD,MAAM,UAAU,IAAI;AAEpB,wBAAQ,OAAO;AAEf,KAAI,MAAM,YAAY,MAAM;AAC1B,MAAI,CAAC,MAAM,QAAQ,MAAM,UAAW,OAAM,WAAW,CAAC,MAAM;AAC5D,UAAQ,SAAS,MAAM,SAAS;;AAGlC,QAAO;;;;;;;;;;;;AAsBT,SAAgB,iBAAiB,OAA8B;CAC7D,MAAM,OAAO,IAAI;AAEjB,KAAI,MAAM,eAAe,KACvB,MAAK,eAAe,MAAM;AAG5B,KAAI,MAAM,WAAW,KACnB,MAAK,WAAW,MAAM;AAGxB,KAAI,MAAM,OAAO,KACf,MAAK,OAAO,MAAM;AAGpB,QAAO"}
@@ -1,7 +1,7 @@
1
1
  require('../colors-Cd4Oz-r-.js');
2
2
  require('../ActionRow-CmTHbo2t.js');
3
3
  require('../error-codes-C-ViHyu-.js');
4
- const require_commandkit = require('../commandkit-C0BuNRSN.js');
4
+ const require_commandkit = require('../commandkit-CYJ8d2gj.js');
5
5
  require('../common-CcfjYnPG.js');
6
6
  require('../common-vnMIelAE.js');
7
7
  require('../container-z621KfH5.js');
@@ -1,7 +1,7 @@
1
1
  require('../../colors-Cd4Oz-r-.js');
2
2
  require('../../ActionRow-CmTHbo2t.js');
3
3
  require('../../error-codes-C-ViHyu-.js');
4
- const require_commandkit = require('../../commandkit-C0BuNRSN.js');
4
+ const require_commandkit = require('../../commandkit-CYJ8d2gj.js');
5
5
  require('../../common-CcfjYnPG.js');
6
6
  require('../../common-vnMIelAE.js');
7
7
  require('../../container-z621KfH5.js');
@@ -1,7 +1,7 @@
1
1
  require('../../colors-Cd4Oz-r-.js');
2
2
  require('../../ActionRow-CmTHbo2t.js');
3
3
  require('../../error-codes-C-ViHyu-.js');
4
- const require_commandkit = require('../../commandkit-C0BuNRSN.js');
4
+ const require_commandkit = require('../../commandkit-CYJ8d2gj.js');
5
5
  require('../../common-CcfjYnPG.js');
6
6
  require('../../common-vnMIelAE.js');
7
7
  require('../../container-z621KfH5.js');
@@ -1,7 +1,7 @@
1
1
  require('../../../colors-Cd4Oz-r-.js');
2
2
  require('../../../ActionRow-CmTHbo2t.js');
3
3
  require('../../../error-codes-C-ViHyu-.js');
4
- const require_commandkit = require('../../../commandkit-C0BuNRSN.js');
4
+ const require_commandkit = require('../../../commandkit-CYJ8d2gj.js');
5
5
  require('../../../common-CcfjYnPG.js');
6
6
  require('../../../common-vnMIelAE.js');
7
7
  require('../../../container-z621KfH5.js');
@@ -1,7 +1,7 @@
1
1
  require('../../../colors-Cd4Oz-r-.js');
2
2
  require('../../../ActionRow-CmTHbo2t.js');
3
3
  require('../../../error-codes-C-ViHyu-.js');
4
- const require_commandkit = require('../../../commandkit-C0BuNRSN.js');
4
+ const require_commandkit = require('../../../commandkit-CYJ8d2gj.js');
5
5
  require('../../../common-CcfjYnPG.js');
6
6
  require('../../../common-vnMIelAE.js');
7
7
  require('../../../container-z621KfH5.js');
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-file-url-DHTQj2mU.js","names":[],"sources":["../src/utils/resolve-file-url.ts"],"sourcesContent":["import path from 'path';\n\n/**\n * Convert a local file path to a file URL.\n * @param filePath - The local file's path.\n * @param withTs - Whether to append a timestamp to the URL.\n * @returns - The converted file URL.\n */\nexport function toFileURL(filePath: string, withTs = false) {\n const resolvedPath = path.resolve(filePath);\n return `${'file://' + resolvedPath.replace(/\\\\\\\\|\\\\/g, '/')}${withTs ? `?ts=${Date.now()}` : ''}`;\n}\n"],"mappings":";;;;;;;;;;AAQA,SAAgB,UAAU,UAAkB,SAAS,OAAO;CAC1D,MAAM,eAAe,aAAK,QAAQ;AAClC,QAAO,GAAG,YAAY,aAAa,QAAQ,YAAY,OAAO,SAAS,OAAO,KAAK,UAAU;AAC/F"}
1
+ {"version":3,"file":"resolve-file-url-DHTQj2mU.js","names":[],"sources":["../src/utils/resolve-file-url.ts"],"sourcesContent":["import path from 'path';\n\n/**\n * Convert a local file path to a file URL.\n * @param filePath - The local file's path.\n * @param withTs - Whether to append a timestamp to the URL.\n * @returns - The converted file URL.\n */\nexport function toFileURL(filePath: string, withTs = false) {\n const resolvedPath = path.resolve(filePath);\n return `${'file://' + resolvedPath.replace(/\\\\\\\\|\\\\/g, '/')}${withTs ? `?ts=${Date.now()}` : ''}`;\n}\n"],"mappings":";;;;;;;;;;AAQA,SAAgB,UAAU,UAAkB,SAAS,OAAO;CAC1D,MAAM,eAAe,aAAK,QAAQ;AAClC,QAAO,GAAG,YAAY,aAAa,QAAQ,YAAY,OAAO,SAAS,OAAO,KAAK,UAAU"}
@@ -1 +1 @@
1
- {"version":3,"file":"section-CuYr0Inu.js","names":[],"sources":["../src/components/v2/section.ts"],"sourcesContent":["import {\n ButtonBuilder,\n SectionBuilder,\n TextDisplayBuilder,\n ThumbnailBuilder,\n} from 'discord.js';\nimport { applyId } from './common';\n\n/**\n * Represents the properties for a section component.\n */\nexport interface SectionProps {\n children?: (ThumbnailBuilder | ButtonBuilder | TextDisplayBuilder)[];\n id?: number;\n}\n\n/**\n * The components v2 section component\n * @param props The properties for the section component.\n * @returns The section builder instance.\n * @example ```tsx\n * import { Section } from 'commandkit';\n *\n * const section = <Section>...</Section>;\n * ```\n */\nexport function Section(props: SectionProps): SectionBuilder {\n const section = new SectionBuilder();\n\n applyId(props, section);\n\n if (props.children != null) {\n if (!Array.isArray(props.children)) props.children = [props.children];\n for (const accessory of props.children.flat()) {\n if (accessory instanceof ThumbnailBuilder) {\n section.setThumbnailAccessory(accessory);\n } else if (accessory instanceof ButtonBuilder) {\n section.setButtonAccessory(accessory);\n } else if (accessory instanceof TextDisplayBuilder) {\n section.addTextDisplayComponents(accessory);\n }\n }\n }\n\n return section;\n}\n\n/**\n * Represents the properties for a thumbnail component.\n */\nexport interface ThumbnailProps {\n id?: number;\n description?: string;\n spoiler?: boolean;\n url: string;\n}\n\n/**\n * The thumbnail component\n * @param props The properties for the thumbnail component.\n * @returns The thumbnail builder instance.\n * @example ```tsx\n * import { Thumbnail } from 'commandkit';\n *\n * const thumbnail = <Thumbnail url=\"https://example.com/image.png\" description=\"An image\" />;\n * ```\n */\nexport function Thumbnail(props: ThumbnailProps) {\n const thumbnail = new ThumbnailBuilder({\n description: props.description,\n spoiler: props.spoiler,\n id: props.id,\n media: { url: props.url },\n });\n\n return thumbnail;\n}\n"],"mappings":";;;;;;;;;;;;;;;AA0BA,SAAgB,QAAQ,OAAqC;CAC3D,MAAM,UAAU,IAAI;AAEpB,wBAAQ,OAAO;AAEf,KAAI,MAAM,YAAY,MAAM;AAC1B,MAAI,CAAC,MAAM,QAAQ,MAAM,UAAW,OAAM,WAAW,CAAC,MAAM,SAAS;AACrE,OAAK,MAAM,aAAa,MAAM,SAAS,OACrC,KAAI,qBAAqB,4BACvB,SAAQ,sBAAsB;WACrB,qBAAqB,yBAC9B,SAAQ,mBAAmB;WAClB,qBAAqB,8BAC9B,SAAQ,yBAAyB;CAGvC;AAEA,QAAO;AACT;;;;;;;;;;;AAsBA,SAAgB,UAAU,OAAuB;CAC/C,MAAM,YAAY,IAAI,4BAAiB;EACrC,aAAa,MAAM;EACnB,SAAS,MAAM;EACf,IAAI,MAAM;EACV,OAAO,EAAE,KAAK,MAAM,KAAK;EAC1B;AAED,QAAO;AACT"}
1
+ {"version":3,"file":"section-CuYr0Inu.js","names":[],"sources":["../src/components/v2/section.ts"],"sourcesContent":["import {\n ButtonBuilder,\n SectionBuilder,\n TextDisplayBuilder,\n ThumbnailBuilder,\n} from 'discord.js';\nimport { applyId } from './common';\n\n/**\n * Represents the properties for a section component.\n */\nexport interface SectionProps {\n children?: (ThumbnailBuilder | ButtonBuilder | TextDisplayBuilder)[];\n id?: number;\n}\n\n/**\n * The components v2 section component\n * @param props The properties for the section component.\n * @returns The section builder instance.\n * @example ```tsx\n * import { Section } from 'commandkit';\n *\n * const section = <Section>...</Section>;\n * ```\n */\nexport function Section(props: SectionProps): SectionBuilder {\n const section = new SectionBuilder();\n\n applyId(props, section);\n\n if (props.children != null) {\n if (!Array.isArray(props.children)) props.children = [props.children];\n for (const accessory of props.children.flat()) {\n if (accessory instanceof ThumbnailBuilder) {\n section.setThumbnailAccessory(accessory);\n } else if (accessory instanceof ButtonBuilder) {\n section.setButtonAccessory(accessory);\n } else if (accessory instanceof TextDisplayBuilder) {\n section.addTextDisplayComponents(accessory);\n }\n }\n }\n\n return section;\n}\n\n/**\n * Represents the properties for a thumbnail component.\n */\nexport interface ThumbnailProps {\n id?: number;\n description?: string;\n spoiler?: boolean;\n url: string;\n}\n\n/**\n * The thumbnail component\n * @param props The properties for the thumbnail component.\n * @returns The thumbnail builder instance.\n * @example ```tsx\n * import { Thumbnail } from 'commandkit';\n *\n * const thumbnail = <Thumbnail url=\"https://example.com/image.png\" description=\"An image\" />;\n * ```\n */\nexport function Thumbnail(props: ThumbnailProps) {\n const thumbnail = new ThumbnailBuilder({\n description: props.description,\n spoiler: props.spoiler,\n id: props.id,\n media: { url: props.url },\n });\n\n return thumbnail;\n}\n"],"mappings":";;;;;;;;;;;;;;;AA0BA,SAAgB,QAAQ,OAAqC;CAC3D,MAAM,UAAU,IAAI;AAEpB,wBAAQ,OAAO;AAEf,KAAI,MAAM,YAAY,MAAM;AAC1B,MAAI,CAAC,MAAM,QAAQ,MAAM,UAAW,OAAM,WAAW,CAAC,MAAM;AAC5D,OAAK,MAAM,aAAa,MAAM,SAAS,OACrC,KAAI,qBAAqB,4BACvB,SAAQ,sBAAsB;WACrB,qBAAqB,yBAC9B,SAAQ,mBAAmB;WAClB,qBAAqB,8BAC9B,SAAQ,yBAAyB;;AAKvC,QAAO;;;;;;;;;;;;AAuBT,SAAgB,UAAU,OAAuB;CAC/C,MAAM,YAAY,IAAI,4BAAiB;EACrC,aAAa,MAAM;EACnB,SAAS,MAAM;EACf,IAAI,MAAM;EACV,OAAO,EAAE,KAAK,MAAM;;AAGtB,QAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"separator-DLdWBjSN.js","names":[],"sources":["../src/components/v2/separator.ts"],"sourcesContent":["import { SeparatorBuilder, SeparatorComponentData } from 'discord.js';\n\n/**\n * Represents the properties for a separator component.\n */\nexport interface SeparatorProps extends Omit<SeparatorComponentData, 'type'> {}\n\n/**\n * The components v2 separator component\n * @param props The properties for the separator component.\n * @returns The separator builder instance.\n * @example ```tsx\n * import { Separator } from 'commandkit';\n *\n * const separator = <Separator />;\n * ```\n */\nexport function Separator(props: SeparatorProps) {\n const separator = new SeparatorBuilder(props);\n return separator;\n}\n"],"mappings":";;;;;;;;;;;;;;AAiBA,SAAgB,UAAU,OAAuB;CAC/C,MAAM,YAAY,IAAI,4BAAiB;AACvC,QAAO;AACT"}
1
+ {"version":3,"file":"separator-DLdWBjSN.js","names":[],"sources":["../src/components/v2/separator.ts"],"sourcesContent":["import { SeparatorBuilder, SeparatorComponentData } from 'discord.js';\n\n/**\n * Represents the properties for a separator component.\n */\nexport interface SeparatorProps extends Omit<SeparatorComponentData, 'type'> {}\n\n/**\n * The components v2 separator component\n * @param props The properties for the separator component.\n * @returns The separator builder instance.\n * @example ```tsx\n * import { Separator } from 'commandkit';\n *\n * const separator = <Separator />;\n * ```\n */\nexport function Separator(props: SeparatorProps) {\n const separator = new SeparatorBuilder(props);\n return separator;\n}\n"],"mappings":";;;;;;;;;;;;;;AAiBA,SAAgB,UAAU,OAAuB;CAC/C,MAAM,YAAY,IAAI,4BAAiB;AACvC,QAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"serde-CHySNpFr.js","names":[],"sources":["../src/kv/serde.ts"],"sourcesContent":["import { SerializerType } from './constants';\n\nexport interface SerializedValue {\n t: SerializerType;\n v: any;\n}\n\nexport function serializer(value: any): SerializedValue {\n if (value === null) {\n return { t: SerializerType.Null, v: null };\n }\n\n if (value === undefined) {\n return { t: SerializerType.Undefined, v: undefined };\n }\n\n if (typeof value === 'string') {\n return { t: SerializerType.String, v: value };\n }\n\n if (typeof value === 'number') {\n return { t: SerializerType.Number, v: value };\n }\n\n if (typeof value === 'boolean') {\n return { t: SerializerType.Boolean, v: value };\n }\n\n if (typeof value === 'bigint') {\n return { t: SerializerType.BigInt, v: value.toString() };\n }\n\n if (value instanceof Date) {\n return { t: SerializerType.Date, v: value.toISOString() };\n }\n\n if (Array.isArray(value)) {\n return { t: SerializerType.Array, v: value };\n }\n\n if (value instanceof Map) {\n return { t: SerializerType.Map, v: Array.from(value.entries()) };\n }\n\n if (value instanceof Set) {\n return { t: SerializerType.Set, v: Array.from(value) };\n }\n\n if (Buffer.isBuffer(value)) {\n return { t: SerializerType.Buffer, v: value.toString('base64') };\n }\n\n if (value instanceof RegExp) {\n return {\n t: SerializerType.RegExp,\n v: { source: value.source, flags: value.flags },\n };\n }\n\n if (typeof value === 'object') {\n return { t: SerializerType.Object, v: value };\n }\n\n // Fallback to string\n return { t: SerializerType.String, v: String(value) };\n}\n\nexport function deserializer(serialized: SerializedValue): any {\n switch (serialized.t) {\n case SerializerType.Null:\n return null;\n case SerializerType.Undefined:\n return undefined;\n case SerializerType.String:\n return serialized.v;\n case SerializerType.Number:\n return serialized.v;\n case SerializerType.Boolean:\n return serialized.v;\n case SerializerType.BigInt:\n return BigInt(serialized.v);\n case SerializerType.Date:\n return new Date(serialized.v);\n case SerializerType.Array:\n return serialized.v;\n case SerializerType.Map:\n return new Map(serialized.v);\n case SerializerType.Set:\n return new Set(serialized.v);\n case SerializerType.Buffer:\n return Buffer.from(serialized.v, 'base64');\n case SerializerType.RegExp:\n return new RegExp(serialized.v.source, serialized.v.flags);\n case SerializerType.Object:\n return serialized.v;\n default:\n return serialized.v;\n }\n}\n"],"mappings":";;;AAOA,SAAgB,WAAW,OAA6B;AACtD,KAAI,UAAU,KACZ,QAAO;EAAE,GAAG,iCAAe;EAAM,GAAG;EAAM;AAG5C,KAAI,UAAU,OACZ,QAAO;EAAE,GAAG,iCAAe;EAAW,GAAG;EAAW;AAGtD,KAAI,OAAO,UAAU,SACnB,QAAO;EAAE,GAAG,iCAAe;EAAQ,GAAG;EAAO;AAG/C,KAAI,OAAO,UAAU,SACnB,QAAO;EAAE,GAAG,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,QAAO,IAAI,IAAI,WAAW;EAC5B,KAAK,iCAAe,IAClB,QAAO,IAAI,IAAI,WAAW;EAC5B,KAAK,iCAAe,OAClB,QAAO,OAAO,KAAK,WAAW,GAAG;EACnC,KAAK,iCAAe,OAClB,QAAO,IAAI,OAAO,WAAW,EAAE,QAAQ,WAAW,EAAE;EACtD,KAAK,iCAAe,OAClB,QAAO,WAAW;EACpB,QACE,QAAO,WAAW;CACtB;AACF"}
1
+ {"version":3,"file":"serde-CHySNpFr.js","names":[],"sources":["../src/kv/serde.ts"],"sourcesContent":["import { SerializerType } from './constants';\n\nexport interface SerializedValue {\n t: SerializerType;\n v: any;\n}\n\nexport function serializer(value: any): SerializedValue {\n if (value === null) {\n return { t: SerializerType.Null, v: null };\n }\n\n if (value === undefined) {\n return { t: SerializerType.Undefined, v: undefined };\n }\n\n if (typeof value === 'string') {\n return { t: SerializerType.String, v: value };\n }\n\n if (typeof value === 'number') {\n return { t: SerializerType.Number, v: value };\n }\n\n if (typeof value === 'boolean') {\n return { t: SerializerType.Boolean, v: value };\n }\n\n if (typeof value === 'bigint') {\n return { t: SerializerType.BigInt, v: value.toString() };\n }\n\n if (value instanceof Date) {\n return { t: SerializerType.Date, v: value.toISOString() };\n }\n\n if (Array.isArray(value)) {\n return { t: SerializerType.Array, v: value };\n }\n\n if (value instanceof Map) {\n return { t: SerializerType.Map, v: Array.from(value.entries()) };\n }\n\n if (value instanceof Set) {\n return { t: SerializerType.Set, v: Array.from(value) };\n }\n\n if (Buffer.isBuffer(value)) {\n return { t: SerializerType.Buffer, v: value.toString('base64') };\n }\n\n if (value instanceof RegExp) {\n return {\n t: SerializerType.RegExp,\n v: { source: value.source, flags: value.flags },\n };\n }\n\n if (typeof value === 'object') {\n return { t: SerializerType.Object, v: value };\n }\n\n // Fallback to string\n return { t: SerializerType.String, v: String(value) };\n}\n\nexport function deserializer(serialized: SerializedValue): any {\n switch (serialized.t) {\n case SerializerType.Null:\n return null;\n case SerializerType.Undefined:\n return undefined;\n case SerializerType.String:\n return serialized.v;\n case SerializerType.Number:\n return serialized.v;\n case SerializerType.Boolean:\n return serialized.v;\n case SerializerType.BigInt:\n return BigInt(serialized.v);\n case SerializerType.Date:\n return new Date(serialized.v);\n case SerializerType.Array:\n return serialized.v;\n case SerializerType.Map:\n return new Map(serialized.v);\n case SerializerType.Set:\n return new Set(serialized.v);\n case SerializerType.Buffer:\n return Buffer.from(serialized.v, 'base64');\n case SerializerType.RegExp:\n return new RegExp(serialized.v.source, serialized.v.flags);\n case SerializerType.Object:\n return serialized.v;\n default:\n return serialized.v;\n }\n}\n"],"mappings":";;;AAOA,SAAgB,WAAW,OAA6B;AACtD,KAAI,UAAU,KACZ,QAAO;EAAE,GAAG,iCAAe;EAAM,GAAG;;AAGtC,KAAI,UAAU,OACZ,QAAO;EAAE,GAAG,iCAAe;EAAW,GAAG;;AAG3C,KAAI,OAAO,UAAU,SACnB,QAAO;EAAE,GAAG,iCAAe;EAAQ,GAAG;;AAGxC,KAAI,OAAO,UAAU,SACnB,QAAO;EAAE,GAAG,iCAAe;EAAQ,GAAG;;AAGxC,KAAI,OAAO,UAAU,UACnB,QAAO;EAAE,GAAG,iCAAe;EAAS,GAAG;;AAGzC,KAAI,OAAO,UAAU,SACnB,QAAO;EAAE,GAAG,iCAAe;EAAQ,GAAG,MAAM;;AAG9C,KAAI,iBAAiB,KACnB,QAAO;EAAE,GAAG,iCAAe;EAAM,GAAG,MAAM;;AAG5C,KAAI,MAAM,QAAQ,OAChB,QAAO;EAAE,GAAG,iCAAe;EAAO,GAAG;;AAGvC,KAAI,iBAAiB,IACnB,QAAO;EAAE,GAAG,iCAAe;EAAK,GAAG,MAAM,KAAK,MAAM;;AAGtD,KAAI,iBAAiB,IACnB,QAAO;EAAE,GAAG,iCAAe;EAAK,GAAG,MAAM,KAAK;;AAGhD,KAAI,OAAO,SAAS,OAClB,QAAO;EAAE,GAAG,iCAAe;EAAQ,GAAG,MAAM,SAAS;;AAGvD,KAAI,iBAAiB,OACnB,QAAO;EACL,GAAG,iCAAe;EAClB,GAAG;GAAE,QAAQ,MAAM;GAAQ,OAAO,MAAM;;;AAI5C,KAAI,OAAO,UAAU,SACnB,QAAO;EAAE,GAAG,iCAAe;EAAQ,GAAG;;AAIxC,QAAO;EAAE,GAAG,iCAAe;EAAQ,GAAG,OAAO;;;AAG/C,SAAgB,aAAa,YAAkC;AAC7D,SAAQ,WAAW,GAAnB;EACE,KAAK,iCAAe,KAClB,QAAO;EACT,KAAK,iCAAe,UAClB,QAAO;EACT,KAAK,iCAAe,OAClB,QAAO,WAAW;EACpB,KAAK,iCAAe,OAClB,QAAO,WAAW;EACpB,KAAK,iCAAe,QAClB,QAAO,WAAW;EACpB,KAAK,iCAAe,OAClB,QAAO,OAAO,WAAW;EAC3B,KAAK,iCAAe,KAClB,QAAO,IAAI,KAAK,WAAW;EAC7B,KAAK,iCAAe,MAClB,QAAO,WAAW;EACpB,KAAK,iCAAe,IAClB,QAAO,IAAI,IAAI,WAAW;EAC5B,KAAK,iCAAe,IAClB,QAAO,IAAI,IAAI,WAAW;EAC5B,KAAK,iCAAe,OAClB,QAAO,OAAO,KAAK,WAAW,GAAG;EACnC,KAAK,iCAAe,OAClB,QAAO,IAAI,OAAO,WAAW,EAAE,QAAQ,WAAW,EAAE;EACtD,KAAK,iCAAe,OAClB,QAAO,WAAW;EACpB,QACE,QAAO,WAAW"}
@@ -1 +1 @@
1
- {"version":3,"file":"signals-DHdYrd-n.js","names":[],"sources":["../src/app/interrupt/signals.ts"],"sourcesContent":["import {\n CommandKitErrorCodes,\n createCommandKitError,\n isCommandKitError,\n} from '../../utils/error-codes';\nimport { eventWorkerContext } from '../events/EventWorkerContext';\n\n/**\n * Cancel upcoming middleware execution.\n * If this is called inside pre-stage middleware, the next run will be the actual command, skipping all other pre-stage middlewares.\n * If this is called inside a command itself, it will skip all post-stage middlewares.\n * If this is called inside post-stage middleware, it will skip all other post-stage middlewares.\n */\nexport function exitMiddleware(): never {\n throw createCommandKitError(CommandKitErrorCodes.ExitMiddleware);\n}\n\n/**\n * Rethrow the error if it is a CommandKit error.\n * @param error The error to rethrow.\n * @example try {\n * doSomething();\n * } catch(e) {\n * // do something\n *\n * // throw the error if it's a commandkit error\n * rethrow(e)\n * }\n */\nexport function rethrow(error: unknown): void {\n if (isCommandKitError(error)) throw error;\n}\n\n/**\n * Stops current command assuming it has been redirected to another command.\n */\nexport function redirect(): never {\n throw createCommandKitError(CommandKitErrorCodes.ForwardedCommand);\n}\n\n/**\n * Stops event propagation. This function should be called inside an event handler\n * to prevent further event handling.\n * @example // src/app/events/messageCreate/handler.ts\n * import { stopEvents } from 'commandkit';\n *\n * export default async function messageCreateHandler() {\n * console.log('Message created');\n * // Stop further event propagation\n * stopEvents();\n * }\n */\nexport function stopEvents(): never {\n if (!eventWorkerContext.getStore()) {\n throw new Error('stopEvents() may only be called inside an event handler');\n }\n\n throw createCommandKitError(CommandKitErrorCodes.StopEvents);\n}\n"],"mappings":";;;;;;;;;;AAaA,SAAgB,iBAAwB;AACtC,OAAM,0CAAsB,yCAAqB;AACnD;;;;;;;;;;;;;AAcA,SAAgB,QAAQ,OAAsB;AAC5C,KAAI,sCAAkB,OAAQ,OAAM;AACtC;;;;AAKA,SAAgB,WAAkB;AAChC,OAAM,0CAAsB,yCAAqB;AACnD;;;;;;;;;;;;;AAcA,SAAgB,aAAoB;AAClC,KAAI,CAAC,8CAAmB,WACtB,OAAM,IAAI,MAAM;AAGlB,OAAM,0CAAsB,yCAAqB;AACnD"}
1
+ {"version":3,"file":"signals-DHdYrd-n.js","names":[],"sources":["../src/app/interrupt/signals.ts"],"sourcesContent":["import {\n CommandKitErrorCodes,\n createCommandKitError,\n isCommandKitError,\n} from '../../utils/error-codes';\nimport { eventWorkerContext } from '../events/EventWorkerContext';\n\n/**\n * Cancel upcoming middleware execution.\n * If this is called inside pre-stage middleware, the next run will be the actual command, skipping all other pre-stage middlewares.\n * If this is called inside a command itself, it will skip all post-stage middlewares.\n * If this is called inside post-stage middleware, it will skip all other post-stage middlewares.\n */\nexport function exitMiddleware(): never {\n throw createCommandKitError(CommandKitErrorCodes.ExitMiddleware);\n}\n\n/**\n * Rethrow the error if it is a CommandKit error.\n * @param error The error to rethrow.\n * @example try {\n * doSomething();\n * } catch(e) {\n * // do something\n *\n * // throw the error if it's a commandkit error\n * rethrow(e)\n * }\n */\nexport function rethrow(error: unknown): void {\n if (isCommandKitError(error)) throw error;\n}\n\n/**\n * Stops current command assuming it has been redirected to another command.\n */\nexport function redirect(): never {\n throw createCommandKitError(CommandKitErrorCodes.ForwardedCommand);\n}\n\n/**\n * Stops event propagation. This function should be called inside an event handler\n * to prevent further event handling.\n * @example // src/app/events/messageCreate/handler.ts\n * import { stopEvents } from 'commandkit';\n *\n * export default async function messageCreateHandler() {\n * console.log('Message created');\n * // Stop further event propagation\n * stopEvents();\n * }\n */\nexport function stopEvents(): never {\n if (!eventWorkerContext.getStore()) {\n throw new Error('stopEvents() may only be called inside an event handler');\n }\n\n throw createCommandKitError(CommandKitErrorCodes.StopEvents);\n}\n"],"mappings":";;;;;;;;;;AAaA,SAAgB,iBAAwB;AACtC,OAAM,0CAAsB,yCAAqB;;;;;;;;;;;;;;AAenD,SAAgB,QAAQ,OAAsB;AAC5C,KAAI,sCAAkB,OAAQ,OAAM;;;;;AAMtC,SAAgB,WAAkB;AAChC,OAAM,0CAAsB,yCAAqB;;;;;;;;;;;;;;AAenD,SAAgB,aAAoB;AAClC,KAAI,CAAC,8CAAmB,WACtB,OAAM,IAAI,MAAM;AAGlB,OAAM,0CAAsB,yCAAqB"}
@@ -1 +1 @@
1
- {"version":3,"file":"store-CiqLHedg.js","names":[],"sources":["../src/flags/store.ts"],"sourcesContent":["import type { FeatureFlag } from './feature-flags';\nimport { Collection } from 'discord.js';\n\n/**\n * Represents a store for feature flags.\n * This store extends the Collection class to manage feature flags by their keys.\n */\nexport class FlagStore extends Collection<string, FeatureFlag<any, any>> {}\n"],"mappings":";;;;;;;;AAOA,IAAa,YAAb,cAA+B,sBAA0C,CAAC"}
1
+ {"version":3,"file":"store-CiqLHedg.js","names":[],"sources":["../src/flags/store.ts"],"sourcesContent":["import type { FeatureFlag } from './feature-flags';\nimport { Collection } from 'discord.js';\n\n/**\n * Represents a store for feature flags.\n * This store extends the Collection class to manage feature flags by their keys.\n */\nexport class FlagStore extends Collection<string, FeatureFlag<any, any>> {}\n"],"mappings":";;;;;;;;AAOA,IAAa,YAAb,cAA+B,sBAA0C"}
@@ -1 +1 @@
1
- {"version":3,"file":"text-display--p2-BoUa.js","names":[],"sources":["../src/components/v2/text-display.ts"],"sourcesContent":["import { TextDisplayBuilder, TextDisplayComponentData } from 'discord.js';\n\n/**\n * Represents a type that can be encoded as a string.\n */\nexport type StringEncodable = string | number | boolean;\n\n/**\n * Represents the properties for a text display component.\n * This interface extends the TextDisplayComponentData type from discord.js,\n * excluding the 'type' and 'content' properties.\n */\nexport interface TextDisplayProps\n extends Omit<TextDisplayComponentData, 'type' | 'content'> {\n children?: StringEncodable | StringEncodable[];\n content?: string;\n}\n\n/**\n * The components v2 text display component\n * @param props The properties for the text display component.\n * @returns The text display builder instance.\n * @example ```tsx\n * import { TextDisplay } from 'commandkit';\n *\n * const textDisplay = <TextDisplay content=\"Hello, world!\" />;\n * // or\n * const textDisplay = <TextDisplay>Some text content</TextDisplay>;\n * ```\n */\nexport function TextDisplay(props: TextDisplayProps) {\n const textDisplay = new TextDisplayBuilder(props);\n\n if (!props.content && props.children) {\n if (Array.isArray(props.children)) {\n textDisplay.setContent(props.children.join(' '));\n } else {\n textDisplay.setContent(\n typeof props.children === 'string'\n ? props.children\n : String(props.children),\n );\n }\n }\n\n return textDisplay;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA8BA,SAAgB,YAAY,OAAyB;CACnD,MAAM,cAAc,IAAI,8BAAmB;AAE3C,KAAI,CAAC,MAAM,WAAW,MAAM,SAC1B,KAAI,MAAM,QAAQ,MAAM,UACtB,aAAY,WAAW,MAAM,SAAS,KAAK;KAE3C,aAAY,WACV,OAAO,MAAM,aAAa,WAC1B,MAAM,WACN,OAAO,MAAM;AAKnB,QAAO;AACT"}
1
+ {"version":3,"file":"text-display--p2-BoUa.js","names":[],"sources":["../src/components/v2/text-display.ts"],"sourcesContent":["import { TextDisplayBuilder, TextDisplayComponentData } from 'discord.js';\n\n/**\n * Represents a type that can be encoded as a string.\n */\nexport type StringEncodable = string | number | boolean;\n\n/**\n * Represents the properties for a text display component.\n * This interface extends the TextDisplayComponentData type from discord.js,\n * excluding the 'type' and 'content' properties.\n */\nexport interface TextDisplayProps\n extends Omit<TextDisplayComponentData, 'type' | 'content'> {\n children?: StringEncodable | StringEncodable[];\n content?: string;\n}\n\n/**\n * The components v2 text display component\n * @param props The properties for the text display component.\n * @returns The text display builder instance.\n * @example ```tsx\n * import { TextDisplay } from 'commandkit';\n *\n * const textDisplay = <TextDisplay content=\"Hello, world!\" />;\n * // or\n * const textDisplay = <TextDisplay>Some text content</TextDisplay>;\n * ```\n */\nexport function TextDisplay(props: TextDisplayProps) {\n const textDisplay = new TextDisplayBuilder(props);\n\n if (!props.content && props.children) {\n if (Array.isArray(props.children)) {\n textDisplay.setContent(props.children.join(' '));\n } else {\n textDisplay.setContent(\n typeof props.children === 'string'\n ? props.children\n : String(props.children),\n );\n }\n }\n\n return textDisplay;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA8BA,SAAgB,YAAY,OAAyB;CACnD,MAAM,cAAc,IAAI,8BAAmB;AAE3C,KAAI,CAAC,MAAM,WAAW,MAAM,SAC1B,KAAI,MAAM,QAAQ,MAAM,UACtB,aAAY,WAAW,MAAM,SAAS,KAAK;KAE3C,aAAY,WACV,OAAO,MAAM,aAAa,WAC1B,MAAM,WACN,OAAO,MAAM;AAKnB,QAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"type-checker-1Iu1jJcy.js","names":[],"sources":["../src/cli/type-checker.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { loadTypeScript } from './common';\nimport { join, relative } from 'node:path';\nimport colors from '../utils/colors';\n\nconst TS_NOT_FOUND_ERR = `TypeScript must be installed in order to use the type checker. Please install it using \\`npm install typescript\\` or \\`yarn add typescript\\``;\n\n/**\n * Formats a TypeScript diagnostic message in a pretty, readable format\n * @private\n * @internal\n */\nfunction formatDiagnostic(\n ts: typeof import('typescript'),\n diagnostic: import('typescript').Diagnostic,\n cwd: string,\n): string {\n const messageText = ts.flattenDiagnosticMessageText(\n diagnostic.messageText,\n '\\n',\n );\n\n if (!diagnostic.file) {\n return `${colors.red('error')}: ${messageText}`;\n }\n\n const { line, character } = ts.getLineAndCharacterOfPosition(\n diagnostic.file,\n diagnostic.start!,\n );\n const fileName = relative(cwd, diagnostic.file.fileName);\n const position = `${line + 1}:${character + 1}`;\n const errorCode = diagnostic.code ? `TS${diagnostic.code}` : '';\n\n // Format the error message nicely\n return [\n `${colors.bold(colors.cyan(fileName))}:${colors.bold(colors.yellow(position))} - ${colors.red('error')} ${colors.gray(errorCode)}`,\n `${messageText}`,\n ].join('\\n');\n}\n\n/**\n * Performs a type check on the project using TypeScript.\n * @param path The project root or cwd\n * @private\n * @internal\n */\nexport async function performTypeCheck(path: string) {\n const tsconfigPath = join(path, 'tsconfig.json');\n\n if (!existsSync(tsconfigPath)) return;\n\n const ts = await loadTypeScript(TS_NOT_FOUND_ERR);\n\n // Format host for error reporting\n const formatHost = {\n getCanonicalFileName: (path: string) => path,\n getCurrentDirectory: ts.sys.getCurrentDirectory,\n getNewLine: () => ts.sys.newLine,\n };\n\n // Read tsconfig.json\n const configFile = ts.readConfigFile(tsconfigPath, ts.sys.readFile);\n\n if (configFile.error) {\n console.error(\n colors.red(\n `Error reading tsconfig.json: ${ts.formatDiagnostic(configFile.error, formatHost)}`,\n ),\n );\n process.exit(1);\n }\n\n // Parse the config file\n const parsedConfig = ts.parseJsonConfigFileContent(\n configFile.config,\n ts.sys,\n path,\n );\n\n // Force noEmit to true as we only want type checking\n parsedConfig.options.noEmit = true;\n\n // Create a program\n const program = ts.createProgram({\n rootNames: parsedConfig.fileNames,\n options: parsedConfig.options,\n projectReferences: parsedConfig.projectReferences,\n });\n\n // Get the diagnostics\n const diagnostics = [\n ...program.getOptionsDiagnostics(),\n ...program.getGlobalDiagnostics(),\n ...program.getSyntacticDiagnostics(),\n ...program.getSemanticDiagnostics(),\n ];\n\n // Report any errors\n if (diagnostics.length > 0) {\n console.log('');\n console.error(\n colors.bold(\n colors.red('Type checking failed with the following errors:'),\n ),\n );\n console.log('');\n\n // Group diagnostics by file for better readability\n const byFile = new Map<string, import('typescript').Diagnostic[]>();\n\n for (const diagnostic of diagnostics) {\n const fileName = diagnostic.file ? diagnostic.file.fileName : 'Global';\n if (!byFile.has(fileName)) {\n byFile.set(fileName, []);\n }\n byFile.get(fileName)!.push(diagnostic);\n }\n\n // Pretty-print each diagnostic\n const totalErrors = diagnostics.length;\n let counter = 0;\n\n for (const [_, fileDiags] of byFile) {\n for (const diagnostic of fileDiags) {\n counter++;\n console.log(formatDiagnostic(ts, diagnostic, path));\n // Add separator between errors for better readability, except for the last one\n if (counter < totalErrors) {\n console.log('');\n }\n }\n }\n\n console.log('');\n console.error(\n colors.bold(\n colors.red(`Found ${totalErrors} error${totalErrors > 1 ? 's' : ''}`),\n ),\n );\n console.log('');\n\n process.exit(1);\n }\n\n console.log(colors.green('✓ Type checking completed successfully.'));\n}\n"],"mappings":";;;;;;;AAKA,MAAM,mBAAmB;;;;;;AAOzB,SAAS,iBACT,IACA,YACA,KACS;CACP,MAAM,cAAc,GAAG,6BACrB,WAAW,aACX;AAGF,KAAI,CAAC,WAAW,KACd,QAAO,GAAG,8BAAO,IAAI,SAAS,IAAI;CAGpC,MAAM,EAAE,MAAM,WAAW,GAAG,GAAG,8BAC7B,WAAW,MACX,WAAW;CAEb,MAAM,mCAAoB,KAAK,WAAW,KAAK;CAC/C,MAAM,WAAW,GAAG,OAAO,EAAE,GAAG,YAAY;CAC5C,MAAM,YAAY,WAAW,OAAO,KAAK,WAAW,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AU,IAAI,OAC3B,MAAK,MAAM,cAAc,WAAW;AAClC;AACA,WAAQ,IAAI,iBAAiB,IAAI,YAAY;AAE7C,OAAI,UAAU,YACZ,SAAQ,IAAI;EAEhB;AAGF,UAAQ,IAAI;AACZ,UAAQ,MACN,8BAAO,KACL,8BAAO,IAAI,SAAS,YAAY,QAAQ,cAAc,IAAI,MAAM;AAGpE,UAAQ,IAAI;AAEZ,UAAQ,KAAK;CACf;AAEA,SAAQ,IAAI,8BAAO,MAAM;AAC3B"}
1
+ {"version":3,"file":"type-checker-1Iu1jJcy.js","names":[],"sources":["../src/cli/type-checker.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { loadTypeScript } from './common';\nimport { join, relative } from 'node:path';\nimport colors from '../utils/colors';\n\nconst TS_NOT_FOUND_ERR = `TypeScript must be installed in order to use the type checker. Please install it using \\`npm install typescript\\` or \\`yarn add typescript\\``;\n\n/**\n * Formats a TypeScript diagnostic message in a pretty, readable format\n * @private\n * @internal\n */\nfunction formatDiagnostic(\n ts: typeof import('typescript'),\n diagnostic: import('typescript').Diagnostic,\n cwd: string,\n): string {\n const messageText = ts.flattenDiagnosticMessageText(\n diagnostic.messageText,\n '\\n',\n );\n\n if (!diagnostic.file) {\n return `${colors.red('error')}: ${messageText}`;\n }\n\n const { line, character } = ts.getLineAndCharacterOfPosition(\n diagnostic.file,\n diagnostic.start!,\n );\n const fileName = relative(cwd, diagnostic.file.fileName);\n const position = `${line + 1}:${character + 1}`;\n const errorCode = diagnostic.code ? `TS${diagnostic.code}` : '';\n\n // Format the error message nicely\n return [\n `${colors.bold(colors.cyan(fileName))}:${colors.bold(colors.yellow(position))} - ${colors.red('error')} ${colors.gray(errorCode)}`,\n `${messageText}`,\n ].join('\\n');\n}\n\n/**\n * Performs a type check on the project using TypeScript.\n * @param path The project root or cwd\n * @private\n * @internal\n */\nexport async function performTypeCheck(path: string) {\n const tsconfigPath = join(path, 'tsconfig.json');\n\n if (!existsSync(tsconfigPath)) return;\n\n const ts = await loadTypeScript(TS_NOT_FOUND_ERR);\n\n // Format host for error reporting\n const formatHost = {\n getCanonicalFileName: (path: string) => path,\n getCurrentDirectory: ts.sys.getCurrentDirectory,\n getNewLine: () => ts.sys.newLine,\n };\n\n // Read tsconfig.json\n const configFile = ts.readConfigFile(tsconfigPath, ts.sys.readFile);\n\n if (configFile.error) {\n console.error(\n colors.red(\n `Error reading tsconfig.json: ${ts.formatDiagnostic(configFile.error, formatHost)}`,\n ),\n );\n process.exit(1);\n }\n\n // Parse the config file\n const parsedConfig = ts.parseJsonConfigFileContent(\n configFile.config,\n ts.sys,\n path,\n );\n\n // Force noEmit to true as we only want type checking\n parsedConfig.options.noEmit = true;\n\n // Create a program\n const program = ts.createProgram({\n rootNames: parsedConfig.fileNames,\n options: parsedConfig.options,\n projectReferences: parsedConfig.projectReferences,\n });\n\n // Get the diagnostics\n const diagnostics = [\n ...program.getOptionsDiagnostics(),\n ...program.getGlobalDiagnostics(),\n ...program.getSyntacticDiagnostics(),\n ...program.getSemanticDiagnostics(),\n ];\n\n // Report any errors\n if (diagnostics.length > 0) {\n console.log('');\n console.error(\n colors.bold(\n colors.red('Type checking failed with the following errors:'),\n ),\n );\n console.log('');\n\n // Group diagnostics by file for better readability\n const byFile = new Map<string, import('typescript').Diagnostic[]>();\n\n for (const diagnostic of diagnostics) {\n const fileName = diagnostic.file ? diagnostic.file.fileName : 'Global';\n if (!byFile.has(fileName)) {\n byFile.set(fileName, []);\n }\n byFile.get(fileName)!.push(diagnostic);\n }\n\n // Pretty-print each diagnostic\n const totalErrors = diagnostics.length;\n let counter = 0;\n\n for (const [_, fileDiags] of byFile) {\n for (const diagnostic of fileDiags) {\n counter++;\n console.log(formatDiagnostic(ts, diagnostic, path));\n // Add separator between errors for better readability, except for the last one\n if (counter < totalErrors) {\n console.log('');\n }\n }\n }\n\n console.log('');\n console.error(\n colors.bold(\n colors.red(`Found ${totalErrors} error${totalErrors > 1 ? 's' : ''}`),\n ),\n );\n console.log('');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G,QAAQ;;AAIX,KAAI,YAAY,SAAS,GAAG;AAC1B,UAAQ,IAAI;AACZ,UAAQ,MACN,8BAAO,KACL,8BAAO,IAAI;AAGf,UAAQ,IAAI;EAGZ,MAAM,yBAAS,IAAI;AAEnB,OAAK,MAAM,cAAc,aAAa;GACpC,MAAM,WAAW,WAAW,OAAO,WAAW,KAAK,WAAW;AAC9D,OAAI,CAAC,OAAO,IAAI,UACd,QAAO,IAAI,UAAU;AAEvB,UAAO,IAAI,UAAW,KAAK;;EAI7B,MAAM,cAAc,YAAY;EAChC,IAAI,UAAU;AAEd,OAAK,MAAM,CAAC,GAAG,cAAc,OAC3B,MAAK,MAAM,cAAc,WAAW;AAClC;AACA,WAAQ,IAAI,iBAAiB,IAAI,YAAY;AAE7C,OAAI,UAAU,YACZ,SAAQ,IAAI;;AAKlB,UAAQ,IAAI;AACZ,UAAQ,MACN,8BAAO,KACL,8BAAO,IAAI,SAAS,YAAY,QAAQ,cAAc,IAAI,MAAM;AAGpE,UAAQ,IAAI;AAEZ,UAAQ,KAAK;;AAGf,SAAQ,IAAI,8BAAO,MAAM"}
@@ -1 +1 @@
1
- {"version":3,"file":"types-package-DrnIdWLg.js","names":[],"sources":["../src/utils/types-package.ts"],"sourcesContent":["import { mkdir, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { COMMANDKIT_CWD, COMMANDKIT_IS_DEV } from './constants';\nimport { existsSync } from 'node:fs';\n\n/**\n * @private\n */\nexport async function generateTypesPackage(force = false) {\n const location = join(COMMANDKIT_CWD, 'node_modules', 'commandkit-types');\n if (!COMMANDKIT_IS_DEV && !force) return location;\n const packageJSON = join(location, 'package.json');\n const index = join(location, 'index.js');\n const types = join(location, 'index.d.ts');\n const command = join(location, 'command.d.ts');\n\n const packageJSONContent = {\n name: 'commandkit-types',\n version: '1.0.0',\n description: 'CommandKit types package',\n type: 'commonjs',\n main: 'index.js',\n types: 'index.d.ts',\n };\n\n const indexContent = `module.exports = {};`;\n\n // Restructuring the type declarations to properly extend rather than replace types\n const typesContent = `// Main types index file - imports all type declarations\nimport './command';\nexport {};\n`;\n\n // Properly set up command types to extend the CommandTypeData interface\n const commandTypesContent = `// Auto-generated command types\n export {};\ndeclare module 'commandkit' {\n type CommandTypeData = string\n}`;\n\n await mkdir(location, { recursive: true }).catch(() => {});\n await writeFile(packageJSON, JSON.stringify(packageJSONContent, null, 2));\n await writeFile(index, indexContent);\n await writeFile(types, typesContent);\n await writeFile(command, commandTypesContent);\n\n return location;\n}\n\n/**\n * @private\n */\nexport async function rewriteCommandDeclaration(data: string) {\n const commandTypesContent = `// Auto-generated command types\n declare module 'commandkit' {\n ${data}\n}\n export {};\n`;\n\n const location = join(COMMANDKIT_CWD, 'node_modules', 'commandkit-types');\n\n if (!existsSync(location)) return;\n\n const type = join(location, 'command.d.ts');\n\n await writeFile(type, commandTypesContent, { encoding: 'utf-8' });\n}\n"],"mappings":";;;;;;;;;;AAQA,eAAsB,qBAAqB,QAAQ,OAAO;CACxD,MAAM,+BAAgB,kCAAgB,gBAAgB;AACtD,KAAI,CAAC,uCAAqB,CAAC,MAAO,QAAO;CACzC,MAAM,kCAAmB,UAAU;CACnC,MAAM,4BAAa,UAAU;CAC7B,MAAM,4BAAa,UAAU;CAC7B,MAAM,8BAAe,UAAU;CAE/B,MAAM,qBAAqB;EACzB,MAAM;EACN,SAAS;EACT,aAAa;EACb,MAAM;EACN,MAAM;EACN,OAAO;EACR;CAED,MAAM,eAAe;CAGrB,MAAM,eAAe;;;;CAMrB,MAAM,sBAAsB;;;;;AAM5B,mCAAY,UAAU,EAAE,WAAW,MAAM,EAAE,YAAY,CAAE;AACzD,uCAAgB,aAAa,KAAK,UAAU,oBAAoB,MAAM;AACtE,uCAAgB,OAAO;AACvB,uCAAgB,OAAO;AACvB,uCAAgB,SAAS;AAEzB,QAAO;AACT;;;;AAKA,eAAsB,0BAA0B,MAAc;CAC5D,MAAM,sBAAsB;;MAExB,KAAI;;;;CAKR,MAAM,+BAAgB,kCAAgB,gBAAgB;AAEtD,KAAI,yBAAY,UAAW;CAE3B,MAAM,2BAAY,UAAU;AAE5B,uCAAgB,MAAM,qBAAqB,EAAE,UAAU,SAAS;AAClE"}
1
+ {"version":3,"file":"types-package-DrnIdWLg.js","names":[],"sources":["../src/utils/types-package.ts"],"sourcesContent":["import { mkdir, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { COMMANDKIT_CWD, COMMANDKIT_IS_DEV } from './constants';\nimport { existsSync } from 'node:fs';\n\n/**\n * @private\n */\nexport async function generateTypesPackage(force = false) {\n const location = join(COMMANDKIT_CWD, 'node_modules', 'commandkit-types');\n if (!COMMANDKIT_IS_DEV && !force) return location;\n const packageJSON = join(location, 'package.json');\n const index = join(location, 'index.js');\n const types = join(location, 'index.d.ts');\n const command = join(location, 'command.d.ts');\n\n const packageJSONContent = {\n name: 'commandkit-types',\n version: '1.0.0',\n description: 'CommandKit types package',\n type: 'commonjs',\n main: 'index.js',\n types: 'index.d.ts',\n };\n\n const indexContent = `module.exports = {};`;\n\n // Restructuring the type declarations to properly extend rather than replace types\n const typesContent = `// Main types index file - imports all type declarations\nimport './command';\nexport {};\n`;\n\n // Properly set up command types to extend the CommandTypeData interface\n const commandTypesContent = `// Auto-generated command types\n export {};\ndeclare module 'commandkit' {\n type CommandTypeData = string\n}`;\n\n await mkdir(location, { recursive: true }).catch(() => {});\n await writeFile(packageJSON, JSON.stringify(packageJSONContent, null, 2));\n await writeFile(index, indexContent);\n await writeFile(types, typesContent);\n await writeFile(command, commandTypesContent);\n\n return location;\n}\n\n/**\n * @private\n */\nexport async function rewriteCommandDeclaration(data: string) {\n const commandTypesContent = `// Auto-generated command types\n declare module 'commandkit' {\n ${data}\n}\n export {};\n`;\n\n const location = join(COMMANDKIT_CWD, 'node_modules', 'commandkit-types');\n\n if (!existsSync(location)) return;\n\n const type = join(location, 'command.d.ts');\n\n await writeFile(type, commandTypesContent, { encoding: 'utf-8' });\n}\n"],"mappings":";;;;;;;;;;AAQA,eAAsB,qBAAqB,QAAQ,OAAO;CACxD,MAAM,+BAAgB,kCAAgB,gBAAgB;AACtD,KAAI,CAAC,uCAAqB,CAAC,MAAO,QAAO;CACzC,MAAM,kCAAmB,UAAU;CACnC,MAAM,4BAAa,UAAU;CAC7B,MAAM,4BAAa,UAAU;CAC7B,MAAM,8BAAe,UAAU;CAE/B,MAAM,qBAAqB;EACzB,MAAM;EACN,SAAS;EACT,aAAa;EACb,MAAM;EACN,MAAM;EACN,OAAO;;CAGT,MAAM,eAAe;CAGrB,MAAM,eAAe;;;;CAMrB,MAAM,sBAAsB;;;;;AAM5B,mCAAY,UAAU,EAAE,WAAW,QAAQ,YAAY;AACvD,uCAAgB,aAAa,KAAK,UAAU,oBAAoB,MAAM;AACtE,uCAAgB,OAAO;AACvB,uCAAgB,OAAO;AACvB,uCAAgB,SAAS;AAEzB,QAAO;;;;;AAMT,eAAsB,0BAA0B,MAAc;CAC5D,MAAM,sBAAsB;;MAExB,KAAI;;;;CAKR,MAAM,+BAAgB,kCAAgB,gBAAgB;AAEtD,KAAI,yBAAY,UAAW;CAE3B,MAAM,2BAAY,UAAU;AAE5B,uCAAgB,MAAM,qBAAqB,EAAE,UAAU"}
@@ -1,7 +1,7 @@
1
1
  require('../colors-Cd4Oz-r-.js');
2
2
  require('../ActionRow-CmTHbo2t.js');
3
3
  require('../error-codes-C-ViHyu-.js');
4
- const require_commandkit = require('../commandkit-C0BuNRSN.js');
4
+ const require_commandkit = require('../commandkit-CYJ8d2gj.js');
5
5
  require('../common-CcfjYnPG.js');
6
6
  require('../common-vnMIelAE.js');
7
7
  require('../container-z621KfH5.js');
@@ -1 +1 @@
1
- {"version":3,"file":"async-queue.js","names":[],"sources":["../../../src/utils/useful-stuff/async-queue.ts"],"sourcesContent":["/**\n * Async queue implementation for processing tasks sequentially or with limited concurrency.\n * Useful for rate-limiting, batching, or controlling resource usage.\n */\n\nexport interface AsyncQueueOptions {\n /** Maximum number of concurrent tasks. Default: 1 (sequential) */\n concurrency?: number;\n /** Optional callback invoked when all tasks are completed */\n onDrain?: () => void | Promise<void>;\n /** Optional AbortSignal for cancelling the queue */\n signal?: AbortSignal;\n}\n\nexport type AsyncQueueTask<T> = () => Promise<T>;\n\nexport class AsyncQueue {\n private readonly concurrency: number;\n private readonly onDrain?: () => void | Promise<void>;\n private readonly signal?: AbortSignal;\n private running = 0;\n private paused = false;\n private aborted = false;\n private queue: Array<() => void> = [];\n\n constructor(options: AsyncQueueOptions = {}) {\n this.concurrency = options.concurrency ?? 1;\n this.onDrain = options.onDrain;\n this.signal = options.signal;\n\n if (this.signal) {\n this.signal.addEventListener('abort', () => {\n this.abort();\n });\n }\n }\n\n /**\n * Adds a task to the queue.\n * @param task - The async function to execute.\n * @param signal - Optional AbortSignal for cancelling this specific task.\n * @returns Promise resolving to the result of the task.\n */\n public add<T>(task: AsyncQueueTask<T>, signal?: AbortSignal): Promise<T> {\n if (this.aborted) {\n return Promise.reject(new Error('Queue has been aborted'));\n }\n\n return new Promise<T>((resolve, reject) => {\n const run = async () => {\n if (this.paused || this.aborted) {\n if (this.aborted) {\n reject(new Error('Queue has been aborted'));\n } else {\n this.queue.push(run);\n }\n return;\n }\n\n // Check if task-specific signal is aborted\n if (signal?.aborted) {\n reject(new Error('Task was aborted'));\n return;\n }\n\n this.running++;\n try {\n const result = await task();\n resolve(result);\n } catch (err) {\n reject(err);\n } finally {\n this.running--;\n this.next();\n }\n };\n\n if (this.running < this.concurrency && !this.paused && !this.aborted) {\n run();\n } else {\n this.queue.push(run);\n }\n });\n }\n\n /**\n * Pauses the queue. No new tasks will be started until resumed.\n */\n public pause() {\n this.paused = true;\n }\n\n /**\n * Resumes the queue and processes pending tasks.\n */\n public resume() {\n if (!this.paused) return;\n this.paused = false;\n this.next();\n }\n\n /**\n * Aborts the queue, rejecting all pending tasks.\n */\n public abort() {\n this.aborted = true;\n this.clear();\n }\n\n /**\n * Clears all pending tasks from the queue.\n */\n public clear() {\n this.queue = [];\n }\n\n /**\n * Returns the number of running tasks.\n */\n public getRunning(): number {\n return this.running;\n }\n\n /**\n * Returns the number of pending tasks in the queue.\n */\n public getPending(): number {\n return this.queue.length;\n }\n\n /**\n * Returns true if the queue is currently paused.\n */\n public isPaused(): boolean {\n return this.paused;\n }\n\n /**\n * Returns true if the queue has been aborted.\n */\n public isAborted(): boolean {\n return this.aborted;\n }\n\n private next() {\n if (this.paused || this.aborted) return;\n while (this.running < this.concurrency && this.queue.length > 0) {\n const fn = this.queue.shift();\n if (fn) fn();\n }\n if (this.running === 0 && this.queue.length === 0 && this.onDrain) {\n this.onDrain();\n }\n }\n}\n\n/**\n * Creates a new async queue instance with the specified configuration.\n * @param options - Configuration options for the async queue.\n * @returns New AsyncQueue instance.\n *\n * @example\n * ```typescript\n * const controller = new AbortController();\n * const queue = createAsyncQueue({\n * concurrency: 2,\n * signal: controller.signal\n * });\n * queue.add(async () => await doSomething());\n * controller.abort(); // Aborts the queue\n * ```\n */\nexport function createAsyncQueue(options?: AsyncQueueOptions): AsyncQueue {\n return new AsyncQueue(options);\n}\n"],"mappings":";;AAgBA,IAAa,aAAb,MAAwB;CACtB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAQ,UAAU;CAClB,AAAQ,SAAS;CACjB,AAAQ,UAAU;CAClB,AAAQ,QAA2B,EAAE;CAErC,YAAY,UAA6B,EAAE,EAAE;AAC3C,OAAK,cAAc,QAAQ,eAAe;AAC1C,OAAK,UAAU,QAAQ;AACvB,OAAK,SAAS,QAAQ;AAEtB,MAAI,KAAK,OACP,MAAK,OAAO,iBAAiB,eAAe;AAC1C,QAAK;EACN;CAEL;;;;;;;CAQA,AAAO,IAAO,MAAyB,QAAkC;AACvE,MAAI,KAAK,QACP,QAAO,QAAQ,uBAAO,IAAI,MAAM;AAGlC,SAAO,IAAI,SAAY,SAAS,WAAW;GACzC,MAAM,MAAM,YAAY;AACtB,QAAI,KAAK,UAAU,KAAK,SAAS;AAC/B,SAAI,KAAK,QACP,wBAAO,IAAI,MAAM;SAEjB,MAAK,MAAM,KAAK;AAElB;IACF;AAGA,wDAAI,OAAQ,SAAS;AACnB,4BAAO,IAAI,MAAM;AACjB;IACF;AAEA,SAAK;AACL,QAAI;KACF,MAAM,SAAS,MAAM;AACrB,aAAQ;IACT,SAAQ,KAAK;AACZ,YAAO;IACR,UAAS;AACR,UAAK;AACL,UAAK;IACP;GACD;AAED,OAAI,KAAK,UAAU,KAAK,eAAe,CAAC,KAAK,UAAU,CAAC,KAAK,QAC3D;OAEA,MAAK,MAAM,KAAK;EAEnB;CACH;;;;CAKA,AAAO,QAAQ;AACb,OAAK,SAAS;CAChB;;;;CAKA,AAAO,SAAS;AACd,MAAI,CAAC,KAAK,OAAQ;AAClB,OAAK,SAAS;AACd,OAAK;CACP;;;;CAKA,AAAO,QAAQ;AACb,OAAK,UAAU;AACf,OAAK;CACP;;;;CAKA,AAAO,QAAQ;AACb,OAAK,QAAQ,EAAE;CACjB;;;;CAKA,AAAO,aAAqB;AAC1B,SAAO,KAAK;CACd;;;;CAKA,AAAO,aAAqB;AAC1B,SAAO,KAAK,MAAM;CACpB;;;;CAKA,AAAO,WAAoB;AACzB,SAAO,KAAK;CACd;;;;CAKA,AAAO,YAAqB;AAC1B,SAAO,KAAK;CACd;CAEA,AAAQ,OAAO;AACb,MAAI,KAAK,UAAU,KAAK,QAAS;AACjC,SAAO,KAAK,UAAU,KAAK,eAAe,KAAK,MAAM,SAAS,GAAG;GAC/D,MAAM,KAAK,KAAK,MAAM;AACtB,OAAI,GAAI;EACV;AACA,MAAI,KAAK,YAAY,KAAK,KAAK,MAAM,WAAW,KAAK,KAAK,QACxD,MAAK;CAET;AACF;;;;;;;;;;;;;;;;;AAkBA,SAAgB,iBAAiB,SAAyC;AACxE,QAAO,IAAI,WAAW;AACxB"}
1
+ {"version":3,"file":"async-queue.js","names":[],"sources":["../../../src/utils/useful-stuff/async-queue.ts"],"sourcesContent":["/**\n * Async queue implementation for processing tasks sequentially or with limited concurrency.\n * Useful for rate-limiting, batching, or controlling resource usage.\n */\n\nexport interface AsyncQueueOptions {\n /** Maximum number of concurrent tasks. Default: 1 (sequential) */\n concurrency?: number;\n /** Optional callback invoked when all tasks are completed */\n onDrain?: () => void | Promise<void>;\n /** Optional AbortSignal for cancelling the queue */\n signal?: AbortSignal;\n}\n\nexport type AsyncQueueTask<T> = () => Promise<T>;\n\nexport class AsyncQueue {\n private readonly concurrency: number;\n private readonly onDrain?: () => void | Promise<void>;\n private readonly signal?: AbortSignal;\n private running = 0;\n private paused = false;\n private aborted = false;\n private queue: Array<() => void> = [];\n\n constructor(options: AsyncQueueOptions = {}) {\n this.concurrency = options.concurrency ?? 1;\n this.onDrain = options.onDrain;\n this.signal = options.signal;\n\n if (this.signal) {\n this.signal.addEventListener('abort', () => {\n this.abort();\n });\n }\n }\n\n /**\n * Adds a task to the queue.\n * @param task - The async function to execute.\n * @param signal - Optional AbortSignal for cancelling this specific task.\n * @returns Promise resolving to the result of the task.\n */\n public add<T>(task: AsyncQueueTask<T>, signal?: AbortSignal): Promise<T> {\n if (this.aborted) {\n return Promise.reject(new Error('Queue has been aborted'));\n }\n\n return new Promise<T>((resolve, reject) => {\n const run = async () => {\n if (this.paused || this.aborted) {\n if (this.aborted) {\n reject(new Error('Queue has been aborted'));\n } else {\n this.queue.push(run);\n }\n return;\n }\n\n // Check if task-specific signal is aborted\n if (signal?.aborted) {\n reject(new Error('Task was aborted'));\n return;\n }\n\n this.running++;\n try {\n const result = await task();\n resolve(result);\n } catch (err) {\n reject(err);\n } finally {\n this.running--;\n this.next();\n }\n };\n\n if (this.running < this.concurrency && !this.paused && !this.aborted) {\n run();\n } else {\n this.queue.push(run);\n }\n });\n }\n\n /**\n * Pauses the queue. No new tasks will be started until resumed.\n */\n public pause() {\n this.paused = true;\n }\n\n /**\n * Resumes the queue and processes pending tasks.\n */\n public resume() {\n if (!this.paused) return;\n this.paused = false;\n this.next();\n }\n\n /**\n * Aborts the queue, rejecting all pending tasks.\n */\n public abort() {\n this.aborted = true;\n this.clear();\n }\n\n /**\n * Clears all pending tasks from the queue.\n */\n public clear() {\n this.queue = [];\n }\n\n /**\n * Returns the number of running tasks.\n */\n public getRunning(): number {\n return this.running;\n }\n\n /**\n * Returns the number of pending tasks in the queue.\n */\n public getPending(): number {\n return this.queue.length;\n }\n\n /**\n * Returns true if the queue is currently paused.\n */\n public isPaused(): boolean {\n return this.paused;\n }\n\n /**\n * Returns true if the queue has been aborted.\n */\n public isAborted(): boolean {\n return this.aborted;\n }\n\n private next() {\n if (this.paused || this.aborted) return;\n while (this.running < this.concurrency && this.queue.length > 0) {\n const fn = this.queue.shift();\n if (fn) fn();\n }\n if (this.running === 0 && this.queue.length === 0 && this.onDrain) {\n this.onDrain();\n }\n }\n}\n\n/**\n * Creates a new async queue instance with the specified configuration.\n * @param options - Configuration options for the async queue.\n * @returns New AsyncQueue instance.\n *\n * @example\n * ```typescript\n * const controller = new AbortController();\n * const queue = createAsyncQueue({\n * concurrency: 2,\n * signal: controller.signal\n * });\n * queue.add(async () => await doSomething());\n * controller.abort(); // Aborts the queue\n * ```\n */\nexport function createAsyncQueue(options?: AsyncQueueOptions): AsyncQueue {\n return new AsyncQueue(options);\n}\n"],"mappings":";;AAgBA,IAAa,aAAb,MAAwB;CACtB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAQ,UAAU;CAClB,AAAQ,SAAS;CACjB,AAAQ,UAAU;CAClB,AAAQ,QAA2B;CAEnC,YAAY,UAA6B,IAAI;AAC3C,OAAK,cAAc,QAAQ,eAAe;AAC1C,OAAK,UAAU,QAAQ;AACvB,OAAK,SAAS,QAAQ;AAEtB,MAAI,KAAK,OACP,MAAK,OAAO,iBAAiB,eAAe;AAC1C,QAAK;;;;;;;;;CAWX,AAAO,IAAO,MAAyB,QAAkC;AACvE,MAAI,KAAK,QACP,QAAO,QAAQ,uBAAO,IAAI,MAAM;AAGlC,SAAO,IAAI,SAAY,SAAS,WAAW;GACzC,MAAM,MAAM,Y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