commandkit 1.2.0-rc.9 → 1.2.1

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 (421) hide show
  1. package/LICENSE +19 -3
  2. package/README.md +45 -26
  3. package/bin/index.mjs +1 -1
  4. package/cli.d.ts +19 -0
  5. package/config.cjs +3 -0
  6. package/config.d.ts +1 -0
  7. package/dist/{ActionRow-DKnFVDME.d.ts → ActionRow-Bt9qi0Mb.d.ts} +4 -5
  8. package/dist/{Button-4ZUXdA56.d.ts → Button-DxJLcZIU.d.ts} +7 -8
  9. package/dist/{ButtonKit-C7r7RPNf.d.ts → ButtonKit-BfcyvWfj.d.ts} +4 -5
  10. package/dist/{ChannelSelectMenuKit-BrXvBYNH.d.ts → ChannelSelectMenuKit-DYkudikb.d.ts} +5 -6
  11. package/dist/{CommandsRouter-CoOA7hkf.d.ts → CommandsRouter-DiNoF0dq.d.ts} +2 -3
  12. package/dist/{EventInterceptor-x-R2qshQ.d.ts → EventInterceptor-D9JKMcfi.d.ts} +2 -2
  13. package/dist/{EventsRouter-BacqK6z3.d.ts → EventsRouter-EuuSu6NH.d.ts} +2 -2
  14. package/dist/{MentionableSelectMenuKit-CPTKqx-O.d.ts → MentionableSelectMenuKit-Mu4xqP6B.d.ts} +5 -6
  15. package/dist/{MessageCommandParser-ROLibZPX.d.ts → MessageCommandParser-DPCbHXCS.d.ts} +4 -5
  16. package/dist/{Modal-C6UTRdYQ.d.ts → Modal-v9rrcMl-.d.ts} +25 -12
  17. package/dist/{ModalKit-Btz58KYn.d.ts → ModalKit-XJSM65SV.d.ts} +4 -5
  18. package/dist/{RoleSelectMenuKit-C26lU3sN.d.ts → RoleSelectMenuKit-CCjcp3HY.d.ts} +5 -6
  19. package/dist/{SelectMenu-Diy87_ba.d.ts → SelectMenu-CY0vvoSu.d.ts} +17 -14
  20. package/dist/{StringSelectMenuKit-Bhs8U6WI.d.ts → StringSelectMenuKit-G5nBTicX.d.ts} +5 -6
  21. package/dist/{UserSelectMenuKit-CfqFJdxz.d.ts → UserSelectMenuKit-D3SO_fXA.d.ts} +5 -6
  22. package/dist/analytics/analytics-engine.d.ts +1 -31
  23. package/dist/analytics/analytics-engine.js +2 -36
  24. package/dist/analytics/analytics-provider.d.ts +1 -31
  25. package/dist/analytics/analytics-provider.js +1 -0
  26. package/dist/analytics/constants.js +26 -3
  27. package/dist/analytics/constants.js.map +1 -0
  28. package/dist/analytics/utils.js +2 -36
  29. package/dist/{analytics-engine-B7JNRnEN.d.ts → analytics-engine-DnRsHBId.d.ts} +48 -34
  30. package/dist/app/commands/AppCommandRunner.d.ts +1 -31
  31. package/dist/app/commands/AppCommandRunner.js +2 -36
  32. package/dist/app/commands/Context.d.ts +1 -31
  33. package/dist/app/commands/Context.js +2 -36
  34. package/dist/app/commands/MessageCommandParser.d.ts +1 -1
  35. package/dist/app/commands/MessageCommandParser.js +261 -4
  36. package/dist/app/commands/MessageCommandParser.js.map +1 -0
  37. package/dist/app/commands/helpers.d.ts +1 -1
  38. package/dist/app/commands/helpers.js +25 -3
  39. package/dist/app/commands/helpers.js.map +1 -0
  40. package/dist/app/events/EventWorkerContext.d.ts +42 -33
  41. package/dist/app/events/EventWorkerContext.js +48 -5
  42. package/dist/app/events/EventWorkerContext.js.map +1 -0
  43. package/dist/app/handlers/AppCommandHandler.d.ts +1 -31
  44. package/dist/app/handlers/AppCommandHandler.js +2 -36
  45. package/dist/app/handlers/AppEventsHandler.d.ts +1 -31
  46. package/dist/app/handlers/AppEventsHandler.js +2 -36
  47. package/dist/app/index.d.ts +4 -31
  48. package/dist/app/index.js +13 -45
  49. package/dist/app/interrupt/signals.d.ts +1 -1
  50. package/dist/app/interrupt/signals.js +54 -7
  51. package/dist/app/interrupt/signals.js.map +1 -0
  52. package/dist/app/middlewares/permissions.d.ts +1 -31
  53. package/dist/app/middlewares/permissions.js +2 -36
  54. package/dist/app/register/CommandRegistrar.d.ts +1 -31
  55. package/dist/app/register/CommandRegistrar.js +2 -36
  56. package/dist/app/router/CommandsRouter.d.ts +1 -1
  57. package/dist/app/router/CommandsRouter.js +210 -2
  58. package/dist/app/router/CommandsRouter.js.map +1 -0
  59. package/dist/app/router/EventsRouter.d.ts +1 -1
  60. package/dist/app/router/EventsRouter.js +128 -2
  61. package/dist/app/router/EventsRouter.js.map +1 -0
  62. package/dist/app/router/index.d.ts +2 -3
  63. package/dist/app/router/index.js +5 -5
  64. package/dist/{chunk-nOFOJqeH.js → chunk-BE-pF4vm.js} +11 -7
  65. package/dist/cli/app-process.d.ts +2 -3
  66. package/dist/cli/app-process.js +60 -7
  67. package/dist/cli/app-process.js.map +1 -0
  68. package/dist/cli/build.d.ts +2 -31
  69. package/dist/cli/build.js +171 -41
  70. package/dist/cli/build.js.map +1 -0
  71. package/dist/cli/common.d.ts +10 -34
  72. package/dist/cli/common.js +182 -11
  73. package/dist/cli/common.js.map +1 -0
  74. package/dist/cli/development.d.ts +18 -1
  75. package/dist/cli/development.js +52 -78
  76. package/dist/cli/development.js.map +1 -1
  77. package/dist/cli/env.d.ts +4 -0
  78. package/dist/cli/env.js +73 -9
  79. package/dist/cli/env.js.map +1 -0
  80. package/dist/cli/generators.js +10 -13
  81. package/dist/cli/generators.js.map +1 -1
  82. package/dist/cli/information.js +11 -10
  83. package/dist/cli/information.js.map +1 -1
  84. package/dist/cli/init.d.ts +12 -2
  85. package/dist/cli/init.js +83 -38
  86. package/dist/cli/init.js.map +1 -0
  87. package/dist/cli/production.d.ts +2 -3
  88. package/dist/cli/production.js +19 -52
  89. package/dist/cli/production.js.map +1 -1
  90. package/dist/cli/type-checker.js +83 -6
  91. package/dist/cli/type-checker.js.map +1 -0
  92. package/dist/cli/utils.d.ts +0 -1
  93. package/dist/cli/utils.js +18 -2
  94. package/dist/cli/utils.js.map +1 -0
  95. package/dist/{commandkit-Bm0gLN8i.js → commandkit-Bh7C1_c7.js} +3219 -2616
  96. package/dist/commandkit-Bh7C1_c7.js.map +1 -0
  97. package/dist/commandkit.d.ts +1 -31
  98. package/dist/commandkit.js +2 -36
  99. package/dist/{common-DOCvOVC4.d.ts → common-CCvvgnxi.d.ts} +4 -5
  100. package/dist/components/common/EventInterceptor.d.ts +1 -1
  101. package/dist/components/common/EventInterceptor.js +137 -2
  102. package/dist/components/common/EventInterceptor.js.map +1 -0
  103. package/dist/components/common/element.d.ts +2 -5
  104. package/dist/components/common/element.js +10 -8
  105. package/dist/components/common/types.d.ts +1 -1
  106. package/dist/components/common/types.js +1 -1
  107. package/dist/components/{v2 → display}/common.d.ts +1 -2
  108. package/dist/components/display/common.js +4 -0
  109. package/dist/components/display/container.d.ts +2 -0
  110. package/dist/components/display/container.js +4 -0
  111. package/dist/components/display/file.d.ts +2 -0
  112. package/dist/{file-DVOELoNv.js → components/display/file.js} +5 -10
  113. package/dist/components/display/file.js.map +1 -0
  114. package/dist/components/display/index.d.ts +9 -0
  115. package/dist/components/display/index.js +19 -0
  116. package/dist/components/display/label.d.ts +2 -0
  117. package/dist/components/display/label.js +4 -0
  118. package/dist/components/display/media-gallery.d.ts +2 -0
  119. package/dist/components/display/media-gallery.js +5 -0
  120. package/dist/components/display/poll.d.ts +2 -0
  121. package/dist/components/display/poll.js +86 -0
  122. package/dist/components/display/poll.js.map +1 -0
  123. package/dist/components/display/section.d.ts +2 -0
  124. package/dist/components/display/section.js +5 -0
  125. package/dist/components/display/separator.d.ts +2 -0
  126. package/dist/{separator-DL6QH5H1.js → components/display/separator.js} +5 -10
  127. package/dist/components/display/separator.js.map +1 -0
  128. package/dist/components/display/text-display.d.ts +2 -0
  129. package/dist/{text-display-DbMumig_.js → components/display/text-display.js} +5 -10
  130. package/dist/components/display/text-display.js.map +1 -0
  131. package/dist/components/index.d.ts +23 -24
  132. package/dist/components/index.js +29 -53
  133. package/dist/components/interactive/action-row/ActionRow.d.ts +2 -0
  134. package/dist/{ActionRow-CbdGFWMT.js → components/interactive/action-row/ActionRow.js} +5 -10
  135. package/dist/components/interactive/action-row/ActionRow.js.map +1 -0
  136. package/dist/components/interactive/button/Button.d.ts +2 -0
  137. package/dist/components/interactive/button/Button.js +4 -0
  138. package/dist/components/interactive/button/ButtonKit.d.ts +2 -0
  139. package/dist/components/interactive/button/ButtonKit.js +4 -0
  140. package/dist/components/interactive/modal/Modal.d.ts +2 -0
  141. package/dist/components/interactive/modal/Modal.js +8 -0
  142. package/dist/components/interactive/modal/ModalKit.d.ts +2 -0
  143. package/dist/components/interactive/modal/ModalKit.js +4 -0
  144. package/dist/components/interactive/select-menu/ChannelSelectMenuKit.d.ts +2 -0
  145. package/dist/components/interactive/select-menu/ChannelSelectMenuKit.js +4 -0
  146. package/dist/components/interactive/select-menu/MentionableSelectMenuKit.d.ts +2 -0
  147. package/dist/components/interactive/select-menu/MentionableSelectMenuKit.js +4 -0
  148. package/dist/components/interactive/select-menu/RoleSelectMenuKit.d.ts +2 -0
  149. package/dist/components/interactive/select-menu/RoleSelectMenuKit.js +4 -0
  150. package/dist/components/interactive/select-menu/SelectMenu.d.ts +2 -0
  151. package/dist/components/interactive/select-menu/SelectMenu.js +9 -0
  152. package/dist/components/interactive/select-menu/StringSelectMenuKit.d.ts +2 -0
  153. package/dist/components/interactive/select-menu/StringSelectMenuKit.js +4 -0
  154. package/dist/components/interactive/select-menu/UserSelectMenuKit.d.ts +2 -0
  155. package/dist/components/interactive/select-menu/UserSelectMenuKit.js +4 -0
  156. package/dist/components/interactive/select-menu/common.d.ts +2 -0
  157. package/dist/components/interactive/select-menu/common.js +1 -0
  158. package/dist/config/config.d.ts +15 -33
  159. package/dist/config/config.js +2 -36
  160. package/dist/config/default.d.ts +1 -31
  161. package/dist/config/default.js +2 -36
  162. package/dist/config/loader.d.ts +1 -31
  163. package/dist/config/loader.js +2 -36
  164. package/dist/config/types.d.ts +1 -31
  165. package/dist/config/types.js +1 -0
  166. package/dist/config/utils.d.ts +1 -31
  167. package/dist/config/utils.js +29 -2
  168. package/dist/config/utils.js.map +1 -0
  169. package/dist/{constants-D8PMA9on.d.ts → constants-DqtJY0t-.d.ts} +3 -3
  170. package/dist/{constants-MKu-Q1jh.d.ts → constants-DwxpkIeH.d.ts} +8 -2
  171. package/dist/{container-DHBELeJ3.d.ts → container-CYojOA9d.d.ts} +3 -4
  172. package/dist/context/async-context.d.ts +1 -31
  173. package/dist/context/async-context.js +2 -36
  174. package/dist/context/environment.d.ts +1 -31
  175. package/dist/context/environment.js +2 -36
  176. package/dist/{element-CAXu1XtK.d.ts → element-DeLvTMfZ.d.ts} +5 -5
  177. package/dist/events/CommandKitEventsChannel.d.ts +1 -31
  178. package/dist/events/CommandKitEventsChannel.js +83 -2
  179. package/dist/events/CommandKitEventsChannel.js.map +1 -0
  180. package/dist/{file-DTrr-p09.d.ts → file-DLO1zEcH.d.ts} +3 -4
  181. package/dist/flags/FlagProvider.d.ts +1 -31
  182. package/dist/flags/FlagProvider.js +1 -0
  183. package/dist/flags/FlagProvider.js.map +1 -1
  184. package/dist/flags/feature-flags.d.ts +1 -31
  185. package/dist/flags/feature-flags.js +5 -40
  186. package/dist/flags/store.d.ts +1 -31
  187. package/dist/flags/store.js +13 -2
  188. package/dist/flags/store.js.map +1 -0
  189. package/dist/{helpers-Wg6P5fRQ.d.ts → helpers-zmC44Mcu.d.ts} +2 -3
  190. package/dist/index-BIsCUWAs.d.ts +1 -0
  191. package/dist/index-CwHYpK-f.d.ts +1 -0
  192. package/dist/index-DHrsNvX1.d.ts +1 -0
  193. package/dist/index.d.ts +41 -42
  194. package/dist/index.js +80 -98
  195. package/dist/kv/constants.d.ts +1 -1
  196. package/dist/kv/constants.js +22 -2
  197. package/dist/kv/constants.js.map +1 -0
  198. package/dist/kv/dotprops.js +26 -3
  199. package/dist/kv/dotprops.js.map +1 -0
  200. package/dist/kv/kv.d.ts +1 -2
  201. package/dist/kv/kv.js +15 -18
  202. package/dist/kv/kv.js.map +1 -1
  203. package/dist/kv/serde.d.ts +12 -3
  204. package/dist/kv/serde.js +87 -4
  205. package/dist/kv/serde.js.map +1 -0
  206. package/dist/label-DqGRqodo.d.ts +28 -0
  207. package/dist/logger/DefaultLogger.d.ts +66 -3
  208. package/dist/logger/DefaultLogger.js +2 -36
  209. package/dist/logger/ILogger.d.ts +64 -2
  210. package/dist/logger/ILogger.js +1 -1
  211. package/dist/logger/Logger.d.ts +36 -3
  212. package/dist/logger/Logger.js +2 -36
  213. package/dist/logger/NoopLogger.d.ts +1 -2
  214. package/dist/logger/NoopLogger.js +1 -0
  215. package/dist/logger/NoopLogger.js.map +1 -1
  216. package/dist/{media-gallery-BMsXSot3.d.ts → media-gallery-Ca8es-eB.d.ts} +3 -4
  217. package/dist/plugins/CompilerPlugin.d.ts +1 -31
  218. package/dist/plugins/CompilerPlugin.js +33 -4
  219. package/dist/plugins/CompilerPlugin.js.map +1 -0
  220. package/dist/plugins/PluginCommon.d.ts +1 -31
  221. package/dist/plugins/PluginCommon.js +55 -4
  222. package/dist/plugins/PluginCommon.js.map +1 -0
  223. package/dist/plugins/RuntimePlugin.d.ts +1 -31
  224. package/dist/plugins/RuntimePlugin.js +124 -4
  225. package/dist/plugins/RuntimePlugin.js.map +1 -0
  226. package/dist/plugins/index.d.ts +1 -31
  227. package/dist/plugins/index.js +8 -40
  228. package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.d.ts +1 -31
  229. package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.js +2 -36
  230. package/dist/plugins/plugin-runtime/CompilerPluginRuntime.d.ts +1 -31
  231. package/dist/plugins/plugin-runtime/CompilerPluginRuntime.js +2 -36
  232. package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.d.ts +1 -31
  233. package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.js +2 -36
  234. package/dist/plugins/plugin-runtime/builtin/MacroPlugin.d.ts +1 -31
  235. package/dist/plugins/plugin-runtime/builtin/MacroPlugin.js +2 -36
  236. package/dist/plugins/plugin-runtime/runtime.d.ts +1 -31
  237. package/dist/plugins/plugin-runtime/runtime.js +1 -1
  238. package/dist/plugins/types.d.ts +1 -31
  239. package/dist/plugins/types.js +1 -1
  240. package/dist/poll-DQ6DX_Tt.d.ts +88 -0
  241. package/dist/{section-Dh_FhPeC.d.ts → section-Q8nwx_-q.d.ts} +3 -4
  242. package/dist/{separator-CMf6Cyy5.d.ts → separator-B8P-kdIK.d.ts} +3 -4
  243. package/dist/{signals-SHg7J1U_.d.ts → signals-CBXwugBW.d.ts} +2 -2
  244. package/dist/{text-display-DRw3r_lK.d.ts → text-display-CL9C2yMc.d.ts} +3 -4
  245. package/dist/{types-CJ-XvOFN.d.ts → types-DZy7U-Ld.d.ts} +2 -2
  246. package/dist/types.d.ts +2 -32
  247. package/dist/types.js +1 -0
  248. package/dist/utils/colors.js +9 -3
  249. package/dist/utils/colors.js.map +1 -0
  250. package/dist/utils/constants.d.ts +2 -2
  251. package/dist/utils/constants.js +50 -7
  252. package/dist/utils/constants.js.map +1 -0
  253. package/dist/utils/dev-hooks.d.ts +1 -31
  254. package/dist/utils/dev-hooks.js +2 -36
  255. package/dist/utils/error-codes.d.ts +54 -2
  256. package/dist/utils/error-codes.js +53 -5
  257. package/dist/utils/error-codes.js.map +1 -0
  258. package/dist/utils/resolve-file-url.d.ts +11 -2
  259. package/dist/utils/resolve-file-url.js +18 -2
  260. package/dist/utils/resolve-file-url.js.map +1 -0
  261. package/dist/utils/types-package.js +61 -4
  262. package/dist/utils/types-package.js.map +1 -0
  263. package/dist/utils/useful-stuff/async-queue.js +2 -2
  264. package/dist/utils/useful-stuff/async-queue.js.map +1 -1
  265. package/dist/utils/useful-stuff/mutex.js +1 -0
  266. package/dist/utils/useful-stuff/mutex.js.map +1 -1
  267. package/dist/utils/useful-stuff/ratelimiter.js +2 -2
  268. package/dist/utils/useful-stuff/ratelimiter.js.map +1 -1
  269. package/dist/utils/useful-stuff/semaphore.js +2 -3
  270. package/dist/utils/useful-stuff/semaphore.js.map +1 -1
  271. package/dist/utils/utilities.d.ts +113 -2
  272. package/dist/utils/utilities.js +5 -37
  273. package/dist/utils/{warn-unstable.d.ts → warning.d.ts} +12 -3
  274. package/dist/utils/{warn-unstable.js → warning.js} +15 -2
  275. package/dist/utils/warning.js.map +1 -0
  276. package/dist/version.d.ts +8 -2
  277. package/dist/version.js +13 -2
  278. package/dist/version.js.map +1 -0
  279. package/hooks.cjs +11 -4
  280. package/package.json +22 -18
  281. package/ratelimit.cjs +0 -1
  282. package/dist/ActionRow-CbdGFWMT.js.map +0 -1
  283. package/dist/CommandKitEventsChannel-BtRzr3Tz.js +0 -88
  284. package/dist/CommandKitEventsChannel-BtRzr3Tz.js.map +0 -1
  285. package/dist/CommandsRouter-Cgcy6cK9.js +0 -220
  286. package/dist/CommandsRouter-Cgcy6cK9.js.map +0 -1
  287. package/dist/CompilerPlugin-M8r3yNAl.js +0 -43
  288. package/dist/CompilerPlugin-M8r3yNAl.js.map +0 -1
  289. package/dist/DefaultLogger-XCOl5nLd.d.ts +0 -67
  290. package/dist/EventInterceptor-CQEXyUTp.js +0 -142
  291. package/dist/EventInterceptor-CQEXyUTp.js.map +0 -1
  292. package/dist/EventWorkerContext-BMk7IXpC.d.ts +0 -43
  293. package/dist/EventWorkerContext-Dq29tieI.js +0 -69
  294. package/dist/EventWorkerContext-Dq29tieI.js.map +0 -1
  295. package/dist/EventsRouter-3Gygh-km.js +0 -137
  296. package/dist/EventsRouter-3Gygh-km.js.map +0 -1
  297. package/dist/ILogger-BW8GM-YZ.d.ts +0 -64
  298. package/dist/ILogger-dQ7Y9X1f.js +0 -0
  299. package/dist/Logger-DyfkPk7u.d.ts +0 -37
  300. package/dist/MessageCommandParser-CEuO6Ex3.js +0 -269
  301. package/dist/MessageCommandParser-CEuO6Ex3.js.map +0 -1
  302. package/dist/PluginCommon-Cvl5yYM_.js +0 -71
  303. package/dist/PluginCommon-Cvl5yYM_.js.map +0 -1
  304. package/dist/RuntimePlugin-BUecuBIU.js +0 -134
  305. package/dist/RuntimePlugin-BUecuBIU.js.map +0 -1
  306. package/dist/app-HN1cVg8J.js +0 -0
  307. package/dist/app-process-DoG6Spkf.js +0 -68
  308. package/dist/app-process-DoG6Spkf.js.map +0 -1
  309. package/dist/build-C9ltqPmn.js +0 -175
  310. package/dist/build-C9ltqPmn.js.map +0 -1
  311. package/dist/colors-DL3ucTiT.js +0 -15
  312. package/dist/colors-DL3ucTiT.js.map +0 -1
  313. package/dist/commandkit-Bm0gLN8i.js.map +0 -1
  314. package/dist/common-CcfjYnPG.js +0 -0
  315. package/dist/common-Dxr9-XPa.js +0 -211
  316. package/dist/common-Dxr9-XPa.js.map +0 -1
  317. package/dist/common-vnMIelAE.js +0 -17
  318. package/dist/common-vnMIelAE.js.map +0 -1
  319. package/dist/components/v1/action-row/ActionRow.d.ts +0 -6
  320. package/dist/components/v1/action-row/ActionRow.js +0 -3
  321. package/dist/components/v1/button/Button.d.ts +0 -7
  322. package/dist/components/v1/button/Button.js +0 -38
  323. package/dist/components/v1/button/ButtonKit.d.ts +0 -3
  324. package/dist/components/v1/button/ButtonKit.js +0 -38
  325. package/dist/components/v1/modal/Modal.d.ts +0 -7
  326. package/dist/components/v1/modal/Modal.js +0 -41
  327. package/dist/components/v1/modal/ModalKit.d.ts +0 -3
  328. package/dist/components/v1/modal/ModalKit.js +0 -38
  329. package/dist/components/v1/select-menu/ChannelSelectMenuKit.d.ts +0 -4
  330. package/dist/components/v1/select-menu/ChannelSelectMenuKit.js +0 -38
  331. package/dist/components/v1/select-menu/MentionableSelectMenuKit.d.ts +0 -4
  332. package/dist/components/v1/select-menu/MentionableSelectMenuKit.js +0 -38
  333. package/dist/components/v1/select-menu/RoleSelectMenuKit.d.ts +0 -4
  334. package/dist/components/v1/select-menu/RoleSelectMenuKit.js +0 -38
  335. package/dist/components/v1/select-menu/SelectMenu.d.ts +0 -10
  336. package/dist/components/v1/select-menu/SelectMenu.js +0 -43
  337. package/dist/components/v1/select-menu/StringSelectMenuKit.d.ts +0 -4
  338. package/dist/components/v1/select-menu/StringSelectMenuKit.js +0 -38
  339. package/dist/components/v1/select-menu/UserSelectMenuKit.d.ts +0 -4
  340. package/dist/components/v1/select-menu/UserSelectMenuKit.js +0 -38
  341. package/dist/components/v1/select-menu/common.d.ts +0 -3
  342. package/dist/components/v1/select-menu/common.js +0 -1
  343. package/dist/components/v2/common.js +0 -3
  344. package/dist/components/v2/container.d.ts +0 -2
  345. package/dist/components/v2/container.js +0 -4
  346. package/dist/components/v2/file.d.ts +0 -2
  347. package/dist/components/v2/file.js +0 -3
  348. package/dist/components/v2/index.d.ts +0 -8
  349. package/dist/components/v2/index.js +0 -17
  350. package/dist/components/v2/media-gallery.d.ts +0 -2
  351. package/dist/components/v2/media-gallery.js +0 -5
  352. package/dist/components/v2/section.d.ts +0 -2
  353. package/dist/components/v2/section.js +0 -5
  354. package/dist/components/v2/separator.d.ts +0 -2
  355. package/dist/components/v2/separator.js +0 -3
  356. package/dist/components/v2/text-display.d.ts +0 -2
  357. package/dist/components/v2/text-display.js +0 -3
  358. package/dist/config-BhVxyjmZ.d.ts +0 -16
  359. package/dist/constants-4oxxvaJA.js +0 -27
  360. package/dist/constants-4oxxvaJA.js.map +0 -1
  361. package/dist/constants-B5_Ta7PR.js +0 -70
  362. package/dist/constants-B5_Ta7PR.js.map +0 -1
  363. package/dist/constants-BOOGN85p.js +0 -37
  364. package/dist/constants-BOOGN85p.js.map +0 -1
  365. package/dist/container-C6GtfAPW.js +0 -44
  366. package/dist/container-C6GtfAPW.js.map +0 -1
  367. package/dist/dotprops-tnhpnszJ.js +0 -36
  368. package/dist/dotprops-tnhpnszJ.js.map +0 -1
  369. package/dist/element-Bak9llw_.js +0 -84
  370. package/dist/element-Bak9llw_.js.map +0 -1
  371. package/dist/env-_68PRRoA.js +0 -109
  372. package/dist/env-_68PRRoA.js.map +0 -1
  373. package/dist/error-codes-B4TyW4Ct.d.ts +0 -54
  374. package/dist/error-codes-Ds0bnPvT.js +0 -73
  375. package/dist/error-codes-Ds0bnPvT.js.map +0 -1
  376. package/dist/feature-flags-nZJB7-e5.js +0 -160
  377. package/dist/feature-flags-nZJB7-e5.js.map +0 -1
  378. package/dist/file-DVOELoNv.js.map +0 -1
  379. package/dist/helpers-BSwwrKJW.js +0 -36
  380. package/dist/helpers-BSwwrKJW.js.map +0 -1
  381. package/dist/index-DKcmsWXw.d.ts +0 -1
  382. package/dist/index-DSBMRX9A.d.ts +0 -1
  383. package/dist/index-DdqikUQD.d.ts +0 -1
  384. package/dist/index.js.map +0 -1
  385. package/dist/init-Cy_bcUt4.js +0 -95
  386. package/dist/init-Cy_bcUt4.js.map +0 -1
  387. package/dist/init-DOr-Y3GQ.d.ts +0 -13
  388. package/dist/media-gallery-zDtJ3kxb.js +0 -62
  389. package/dist/media-gallery-zDtJ3kxb.js.map +0 -1
  390. package/dist/resolve-file-url-ChIyw-Vf.js +0 -23
  391. package/dist/resolve-file-url-ChIyw-Vf.js.map +0 -1
  392. package/dist/resolve-file-url-yO8bUxok.d.ts +0 -11
  393. package/dist/router-Dn35v30f.js +0 -0
  394. package/dist/runtime-DB9CiPfe.js +0 -0
  395. package/dist/section-DlvrDoJK.js +0 -60
  396. package/dist/section-DlvrDoJK.js.map +0 -1
  397. package/dist/separator-DL6QH5H1.js.map +0 -1
  398. package/dist/serde-BYaKrsOV.d.ts +0 -12
  399. package/dist/serde-Cc8iUa9J.js +0 -97
  400. package/dist/serde-Cc8iUa9J.js.map +0 -1
  401. package/dist/signals-ChFMD7mB.js +0 -74
  402. package/dist/signals-ChFMD7mB.js.map +0 -1
  403. package/dist/store-CM6pWVZh.js +0 -19
  404. package/dist/store-CM6pWVZh.js.map +0 -1
  405. package/dist/text-display-DbMumig_.js.map +0 -1
  406. package/dist/type-checker-DR7RZFs5.js +0 -90
  407. package/dist/type-checker-DR7RZFs5.js.map +0 -1
  408. package/dist/types-CUZOquUl.js +0 -0
  409. package/dist/types-package-BWArjyBF.js +0 -75
  410. package/dist/types-package-BWArjyBF.js.map +0 -1
  411. package/dist/types-q0Nm882H.js +0 -0
  412. package/dist/utilities-DtdPlr4c.d.ts +0 -87
  413. package/dist/utils/warn-unstable.js.map +0 -1
  414. package/dist/utils-DCSnVAZ6.js +0 -23
  415. package/dist/utils-DCSnVAZ6.js.map +0 -1
  416. package/dist/utils-KsNof0Xz.js +0 -34
  417. package/dist/utils-KsNof0Xz.js.map +0 -1
  418. package/dist/v2-DofkPKHs.js +0 -0
  419. package/dist/version-CtJtBJXI.d.ts +0 -8
  420. package/dist/version-DRSQMx0w.js +0 -18
  421. package/dist/version-DRSQMx0w.js.map +0 -1
@@ -1,109 +0,0 @@
1
-
2
- //#region src/cli/env.ts
3
- /**
4
- * @private
5
- * @internal
6
- */
7
- function DevEnv(_static = false) {
8
- const common = {
9
- NODE_ENV: "development",
10
- COMMANDKIT_IS_DEV: "true"
11
- };
12
- if (_static) return Object.assign({}, common);
13
- return Object.assign({}, process.env, common);
14
- }
15
- /**
16
- * @private
17
- * @internal
18
- */
19
- function ProdEnv(_static = false) {
20
- const common = {
21
- NODE_ENV: "production",
22
- COMMANDKIT_IS_DEV: "false"
23
- };
24
- if (_static) return Object.assign({}, common);
25
- return Object.assign({}, process.env, common);
26
- }
27
- /**
28
- * @private
29
- * @internal
30
- */
31
- const CommonEnvFiles = [".env", ".env.local"];
32
- /**
33
- * @private
34
- * @internal
35
- */
36
- const DevEnvFiles = [".env.development", ".env.development.local"];
37
- /**
38
- * @private
39
- * @internal
40
- */
41
- const ProdEnvFiles = [".env.production", ".env.production.local"];
42
- /**
43
- * @private
44
- * @internal
45
- */
46
- const devEnvFileArgs = [...CommonEnvFiles, ...DevEnvFiles];
47
- /**
48
- * @private
49
- * @internal
50
- */
51
- const prodEnvFileArgs = [...CommonEnvFiles, ...ProdEnvFiles];
52
- /**
53
- * @private
54
- * @internal
55
- */
56
- function setCLIEnv() {
57
- process.env.COMMANDKIT_IS_CLI = "true";
58
- }
59
-
60
- //#endregion
61
- Object.defineProperty(exports, 'CommonEnvFiles', {
62
- enumerable: true,
63
- get: function () {
64
- return CommonEnvFiles;
65
- }
66
- });
67
- Object.defineProperty(exports, 'DevEnv', {
68
- enumerable: true,
69
- get: function () {
70
- return DevEnv;
71
- }
72
- });
73
- Object.defineProperty(exports, 'DevEnvFiles', {
74
- enumerable: true,
75
- get: function () {
76
- return DevEnvFiles;
77
- }
78
- });
79
- Object.defineProperty(exports, 'ProdEnv', {
80
- enumerable: true,
81
- get: function () {
82
- return ProdEnv;
83
- }
84
- });
85
- Object.defineProperty(exports, 'ProdEnvFiles', {
86
- enumerable: true,
87
- get: function () {
88
- return ProdEnvFiles;
89
- }
90
- });
91
- Object.defineProperty(exports, 'devEnvFileArgs', {
92
- enumerable: true,
93
- get: function () {
94
- return devEnvFileArgs;
95
- }
96
- });
97
- Object.defineProperty(exports, 'prodEnvFileArgs', {
98
- enumerable: true,
99
- get: function () {
100
- return prodEnvFileArgs;
101
- }
102
- });
103
- Object.defineProperty(exports, 'setCLIEnv', {
104
- enumerable: true,
105
- get: function () {
106
- return setCLIEnv;
107
- }
108
- });
109
- //# sourceMappingURL=env-_68PRRoA.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"env-_68PRRoA.js","names":[],"sources":["../src/cli/env.ts"],"sourcesContent":["/**\n * @private\n * @internal\n */\nexport function DevEnv(_static = false) {\n const common = {\n NODE_ENV: 'development',\n COMMANDKIT_IS_DEV: 'true',\n };\n\n if (_static) return Object.assign({}, common);\n\n return Object.assign({}, process.env, common);\n}\n\n/**\n * @private\n * @internal\n */\nexport function ProdEnv(_static = false) {\n const common = {\n NODE_ENV: 'production',\n COMMANDKIT_IS_DEV: 'false',\n };\n\n if (_static) return Object.assign({}, common);\n\n return Object.assign({}, process.env, common);\n}\n\n/**\n * @private\n * @internal\n */\nexport const CommonEnvFiles = ['.env', '.env.local'];\n/**\n * @private\n * @internal\n */\nexport const DevEnvFiles = ['.env.development', '.env.development.local'];\n/**\n * @private\n * @internal\n */\nexport const ProdEnvFiles = ['.env.production', '.env.production.local'];\n/**\n * @private\n * @internal\n */\nexport const devEnvFileArgs = [...CommonEnvFiles, ...DevEnvFiles];\n/**\n * @private\n * @internal\n */\nexport const prodEnvFileArgs = [...CommonEnvFiles, ...ProdEnvFiles];\n/**\n * @private\n * @internal\n */\nexport function setCLIEnv() {\n process.env.COMMANDKIT_IS_CLI = 'true';\n}\n"],"mappings":";;;;;;AAIA,SAAgB,OAAO,UAAU,OAAO;CACtC,MAAM,SAAS;EACb,UAAU;EACV,mBAAmB;EACpB;AAED,KAAI,QAAS,QAAO,OAAO,OAAO,EAAE,EAAE,OAAO;AAE7C,QAAO,OAAO,OAAO,EAAE,EAAE,QAAQ,KAAK,OAAO;;;;;;AAO/C,SAAgB,QAAQ,UAAU,OAAO;CACvC,MAAM,SAAS;EACb,UAAU;EACV,mBAAmB;EACpB;AAED,KAAI,QAAS,QAAO,OAAO,OAAO,EAAE,EAAE,OAAO;AAE7C,QAAO,OAAO,OAAO,EAAE,EAAE,QAAQ,KAAK,OAAO;;;;;;AAO/C,MAAa,iBAAiB,CAAC,QAAQ,aAAa;;;;;AAKpD,MAAa,cAAc,CAAC,oBAAoB,yBAAyB;;;;;AAKzE,MAAa,eAAe,CAAC,mBAAmB,wBAAwB;;;;;AAKxE,MAAa,iBAAiB,CAAC,GAAG,gBAAgB,GAAG,YAAY;;;;;AAKjE,MAAa,kBAAkB,CAAC,GAAG,gBAAgB,GAAG,aAAa;;;;;AAKnE,SAAgB,YAAY;AAC1B,SAAQ,IAAI,oBAAoB"}
@@ -1,54 +0,0 @@
1
- //#region src/utils/error-codes.d.ts
2
- /**
3
- * The error codes used by CommandKit.
4
- */
5
- declare const CommandKitErrorCodes: {
6
- /**
7
- * Error code for exiting middleware.
8
- */
9
- readonly StopMiddlewares: symbol;
10
- /**
11
- * Error code for forwarded commands.
12
- */
13
- readonly ForwardedCommand: symbol;
14
- /**
15
- * Error code for invalid command prefix.
16
- */
17
- readonly InvalidCommandPrefix: symbol;
18
- /**
19
- * Error code for plugin capture handle.
20
- */
21
- readonly PluginCaptureHandle: symbol;
22
- /**
23
- * Error code for event interruption signal
24
- */
25
- readonly StopEvents: symbol;
26
- };
27
- /**
28
- * The type for CommandKit errors.
29
- */
30
- type CommandKitError = Error & {
31
- code: symbol;
32
- };
33
- /**
34
- * Creates a new CommandKit error with the specified code.
35
- * @param code The error code to assign to the error.
36
- * @returns A new CommandKit error instance.
37
- */
38
- declare function createCommandKitError(code: symbol): CommandKitError;
39
- /**
40
- * Checks if the given error is a CommandKit error.
41
- * @param error The error to check.
42
- * @returns True if the error is a CommandKit error, false otherwise.
43
- */
44
- declare function isCommandKitError(error: unknown): error is CommandKitError;
45
- /**
46
- * Checks if the given error is of a specific CommandKit error type.
47
- * @param error The error to check.
48
- * @param code The error code or an array of error codes to check against.
49
- * @returns True if the error matches the specified code(s), false otherwise.
50
- */
51
- declare function isErrorType(error: unknown, code: symbol | symbol[]): boolean;
52
- //#endregion
53
- export { CommandKitError, CommandKitErrorCodes, createCommandKitError, isCommandKitError, isErrorType };
54
- //# sourceMappingURL=error-codes-B4TyW4Ct.d.ts.map
@@ -1,73 +0,0 @@
1
-
2
- //#region src/utils/error-codes.ts
3
- /**
4
- * The error codes used by CommandKit.
5
- */
6
- const CommandKitErrorCodes = {
7
- StopMiddlewares: Symbol("kStopMiddlewares"),
8
- ForwardedCommand: Symbol("kForwardedCommand"),
9
- InvalidCommandPrefix: Symbol("kInvalidCommandPrefix"),
10
- PluginCaptureHandle: Symbol("kPluginCaptureHandle"),
11
- StopEvents: Symbol("kStopEvents")
12
- };
13
- /**
14
- * Creates a new CommandKit error with the specified code.
15
- * @param code The error code to assign to the error.
16
- * @returns A new CommandKit error instance.
17
- */
18
- function createCommandKitError(code) {
19
- const error = /* @__PURE__ */ new Error();
20
- Reflect.set(error, "code", code);
21
- return error;
22
- }
23
- /**
24
- * Checks if the given error is a CommandKit error.
25
- * @param error The error to check.
26
- * @returns True if the error is a CommandKit error, false otherwise.
27
- */
28
- function isCommandKitError(error) {
29
- if (!(error instanceof Error)) return false;
30
- const code = Reflect.get(error, "code");
31
- for (const key in CommandKitErrorCodes) if (CommandKitErrorCodes[key] === code) return true;
32
- return false;
33
- }
34
- /**
35
- * Checks if the given error is of a specific CommandKit error type.
36
- * @param error The error to check.
37
- * @param code The error code or an array of error codes to check against.
38
- * @returns True if the error matches the specified code(s), false otherwise.
39
- */
40
- function isErrorType(error, code) {
41
- if (!isCommandKitError(error)) return false;
42
- const errorCode = Reflect.get(error, "code");
43
- if (!errorCode) return false;
44
- if (Array.isArray(code)) return code.includes(errorCode);
45
- return errorCode === code;
46
- }
47
-
48
- //#endregion
49
- Object.defineProperty(exports, 'CommandKitErrorCodes', {
50
- enumerable: true,
51
- get: function () {
52
- return CommandKitErrorCodes;
53
- }
54
- });
55
- Object.defineProperty(exports, 'createCommandKitError', {
56
- enumerable: true,
57
- get: function () {
58
- return createCommandKitError;
59
- }
60
- });
61
- Object.defineProperty(exports, 'isCommandKitError', {
62
- enumerable: true,
63
- get: function () {
64
- return isCommandKitError;
65
- }
66
- });
67
- Object.defineProperty(exports, 'isErrorType', {
68
- enumerable: true,
69
- get: function () {
70
- return isErrorType;
71
- }
72
- });
73
- //# sourceMappingURL=error-codes-Ds0bnPvT.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error-codes-Ds0bnPvT.js","names":[],"sources":["../src/utils/error-codes.ts"],"sourcesContent":["/**\n * The error codes used by CommandKit.\n */\nexport const CommandKitErrorCodes = {\n /**\n * Error code for exiting middleware.\n */\n StopMiddlewares: Symbol('kStopMiddlewares'),\n /**\n * Error code for forwarded commands.\n */\n ForwardedCommand: Symbol('kForwardedCommand'),\n /**\n * Error code for invalid command prefix.\n */\n InvalidCommandPrefix: Symbol('kInvalidCommandPrefix'),\n /**\n * Error code for plugin capture handle.\n */\n PluginCaptureHandle: Symbol('kPluginCaptureHandle'),\n /**\n * Error code for event interruption signal\n */\n StopEvents: Symbol('kStopEvents'),\n} as const;\n\n/**\n * The type for CommandKit errors.\n */\nexport type CommandKitError = Error & { code: symbol };\n\n/**\n * Creates a new CommandKit error with the specified code.\n * @param code The error code to assign to the error.\n * @returns A new CommandKit error instance.\n */\nexport function createCommandKitError(code: symbol): CommandKitError {\n const error = new Error() as CommandKitError;\n\n Reflect.set(error, 'code', code);\n\n return error;\n}\n\n/**\n * Checks if the given error is a CommandKit error.\n * @param error The error to check.\n * @returns True if the error is a CommandKit error, false otherwise.\n */\nexport function isCommandKitError(error: unknown): error is CommandKitError {\n if (!(error instanceof Error)) return false;\n const code = Reflect.get(error, 'code');\n\n for (const key in CommandKitErrorCodes) {\n if (CommandKitErrorCodes[key as keyof typeof CommandKitErrorCodes] === code)\n return true;\n }\n\n return false;\n}\n\n/**\n * Checks if the given error is of a specific CommandKit error type.\n * @param error The error to check.\n * @param code The error code or an array of error codes to check against.\n * @returns True if the error matches the specified code(s), false otherwise.\n */\nexport function isErrorType(error: unknown, code: symbol | symbol[]): boolean {\n if (!isCommandKitError(error)) return false;\n const errorCode = Reflect.get(error, 'code');\n\n if (!errorCode) return false;\n\n if (Array.isArray(code)) return code.includes(errorCode);\n\n return errorCode === code;\n}\n"],"mappings":";;;;;AAGA,MAAa,uBAAuB;CAIlC,iBAAiB,OAAO,mBAAmB;CAI3C,kBAAkB,OAAO,oBAAoB;CAI7C,sBAAsB,OAAO,wBAAwB;CAIrD,qBAAqB,OAAO,uBAAuB;CAInD,YAAY,OAAO,cAAc;CAClC;;;;;;AAYD,SAAgB,sBAAsB,MAA+B;CACnE,MAAM,wBAAQ,IAAI,OAAO;AAEzB,SAAQ,IAAI,OAAO,QAAQ,KAAK;AAEhC,QAAO;;;;;;;AAQT,SAAgB,kBAAkB,OAA0C;AAC1E,KAAI,EAAE,iBAAiB,OAAQ,QAAO;CACtC,MAAM,OAAO,QAAQ,IAAI,OAAO,OAAO;AAEvC,MAAK,MAAM,OAAO,qBAChB,KAAI,qBAAqB,SAA8C,KACvE,QAAO;AAGT,QAAO;;;;;;;;AAST,SAAgB,YAAY,OAAgB,MAAkC;AAC5E,KAAI,CAAC,kBAAkB,MAAM,CAAE,QAAO;CACtC,MAAM,YAAY,QAAQ,IAAI,OAAO,OAAO;AAE5C,KAAI,CAAC,UAAW,QAAO;AAEvB,KAAI,MAAM,QAAQ,KAAK,CAAE,QAAO,KAAK,SAAS,UAAU;AAExD,QAAO,cAAc"}
@@ -1,160 +0,0 @@
1
- const require_commandkit = require('./commandkit-Bm0gLN8i.js');
2
- const require_constants = require('./constants-BOOGN85p.js');
3
- const require_EventWorkerContext = require('./EventWorkerContext-Dq29tieI.js');
4
-
5
- //#region src/flags/feature-flags.ts
6
- let flagProvider = null;
7
- /**
8
- * Set the global flag provider for all feature flags
9
- */
10
- function setFlagProvider(provider) {
11
- flagProvider = provider;
12
- }
13
- /**
14
- * Class representing a feature flag in CommandKit.
15
- */
16
- var FeatureFlag = class {
17
- commandkit;
18
- /**
19
- * Create a new feature flag.
20
- * @param options - The options for the feature flag.
21
- */
22
- constructor(options) {
23
- this.options = options;
24
- this.commandkit = require_commandkit.getCommandKit(true);
25
- const FlagStore = this.commandkit.flags;
26
- if (FlagStore.has(options.key)) throw new Error(`Feature flag with key "${options.key}" already exists.`);
27
- FlagStore.set(options.key, this);
28
- }
29
- getContext() {
30
- const env = require_commandkit.getContext();
31
- if (env === null || env === void 0 ? void 0 : env.context) {
32
- const { client, commandkit, interaction, message, guild, channel, command } = env.context;
33
- return {
34
- client,
35
- commandkit,
36
- command: {
37
- interaction,
38
- message,
39
- guild,
40
- channel,
41
- command
42
- },
43
- event: null
44
- };
45
- }
46
- const eventCtx = require_EventWorkerContext.eventWorkerContext.getStore();
47
- if (eventCtx) {
48
- const { commandkit, data, event, namespace } = eventCtx;
49
- return {
50
- client: commandkit.client,
51
- commandkit,
52
- event: {
53
- data,
54
- event,
55
- namespace,
56
- arguments: eventCtx.arguments,
57
- argumentsAs: (eventName) => {
58
- return eventCtx.arguments;
59
- }
60
- },
61
- command: null
62
- };
63
- }
64
- throw new Error("Could not determine the execution context. Feature flags may only be used inside a command or event.");
65
- }
66
- /**
67
- * Execute the feature flag evaluation.
68
- * @param res - Optional entities to use for evaluation. If not provided, it will call the identify function.
69
- * @returns A promise that resolves to the result of the feature flag evaluation.
70
- */
71
- async execute(res) {
72
- const { decide, identify, disableAnalytics } = this.options;
73
- const identificationStart = performance.now();
74
- const entities = res ?? await (async () => {
75
- const ctx = this.getContext();
76
- return await (identify === null || identify === void 0 ? void 0 : identify(ctx)) ?? {};
77
- })();
78
- const identificationTime = performance.now() - identificationStart;
79
- let providerConfig = null;
80
- if (flagProvider) try {
81
- providerConfig = await flagProvider.getFlag(this.options.key, entities);
82
- if (providerConfig && !providerConfig.enabled) {
83
- if (typeof decide === "function") return await decide({
84
- entities,
85
- provider: providerConfig
86
- });
87
- }
88
- } catch (error) {
89
- require_commandkit.Logger.error`Error fetching flag provider configuration for "${this.options.key}": ${error}`;
90
- }
91
- const decisionStart = performance.now();
92
- const decisionResult = await decide({
93
- entities,
94
- provider: providerConfig
95
- });
96
- const decisionTime = performance.now() - decisionStart;
97
- if (!disableAnalytics) {
98
- require_commandkit.defer(async () => {
99
- await this.commandkit.analytics.track({
100
- name: require_constants.AnalyticsEvents.FEATURE_FLAG_METRICS,
101
- data: {
102
- flag: this.options.key,
103
- identificationTime: identificationTime.toFixed(2),
104
- decisionTime: decisionTime.toFixed(2),
105
- usedProvider: flagProvider !== null,
106
- providerEnabled: (providerConfig === null || providerConfig === void 0 ? void 0 : providerConfig.enabled) ?? null
107
- }
108
- });
109
- });
110
- require_commandkit.defer(async () => {
111
- await this.commandkit.analytics.track({
112
- name: require_constants.AnalyticsEvents.FEATURE_FLAG_DECISION,
113
- id: entities && typeof entities === "object" && "id" in entities && typeof entities.id === "string" ? entities.id : void 0,
114
- data: {
115
- flag: this.options.key,
116
- decision: require_commandkit.JsonSerialize(decisionResult, "unknown"),
117
- providerUsed: flagProvider !== null
118
- }
119
- });
120
- });
121
- }
122
- return decisionResult;
123
- }
124
- };
125
- /**
126
- * Create a new feature flag.
127
- * @param options - The options for the feature flag.
128
- * @returns A new instance of the FeatureFlag class.
129
- */
130
- function flag(options) {
131
- const flag$1 = new FeatureFlag(options);
132
- const runner = flag$1.execute.bind(flag$1, void 0);
133
- runner.run = async function(ctx) {
134
- if (!(ctx === null || ctx === void 0 ? void 0 : ctx.identify)) throw new Error("Custom evaluation context must have an identify function or object.");
135
- const context = typeof ctx === "function" ? await ctx() : ctx;
136
- return await flag$1.execute(context);
137
- };
138
- return runner;
139
- }
140
-
141
- //#endregion
142
- Object.defineProperty(exports, 'FeatureFlag', {
143
- enumerable: true,
144
- get: function () {
145
- return FeatureFlag;
146
- }
147
- });
148
- Object.defineProperty(exports, 'flag', {
149
- enumerable: true,
150
- get: function () {
151
- return flag;
152
- }
153
- });
154
- Object.defineProperty(exports, 'setFlagProvider', {
155
- enumerable: true,
156
- get: function () {
157
- return setFlagProvider;
158
- }
159
- });
160
- //# sourceMappingURL=feature-flags-nZJB7-e5.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"feature-flags-nZJB7-e5.js","names":[],"sources":["../src/flags/feature-flags.ts"],"sourcesContent":["import { getCommandKit, getContext } from '../context/async-context';\nimport { eventWorkerContext } from '../app/events/EventWorkerContext';\nimport { ParsedEvent } from '../app/router';\nimport { CommandKit } from '../commandkit';\nimport {\n AutocompleteInteraction,\n ChatInputCommandInteraction,\n Client,\n ClientEvents,\n ContextMenuCommandInteraction,\n Guild,\n Message,\n TextBasedChannel,\n} from 'discord.js';\nimport { LoadedCommand } from '../app';\nimport { defer, JsonSerialize } from '../utils/utilities';\nimport { AnalyticsEvents } from '../analytics/constants';\nimport { FlagProvider, FlagConfiguration } from './FlagProvider';\nimport { Logger } from '../logger/Logger';\n\n// Global flag provider\nlet flagProvider: FlagProvider | null = null;\n\n/**\n * Set the global flag provider for all feature flags\n */\nexport function setFlagProvider(provider: FlagProvider): void {\n flagProvider = provider;\n}\n\n/**\n * @private\n */\nexport type MaybePromise<T> = T | Promise<T>;\n\n/**\n * Function type for identifying entities in the context of feature flags.\n * This function should return an object representing the entity that will be used\n * to evaluate the feature flag.\n * It can be synchronous or asynchronous.\n */\nexport type IdentifyFunction<R> = (\n context: EvaluationContext,\n) => MaybePromise<R>;\n\n/**\n * Function type for deciding the outcome of a feature flag based on the provided entities.\n * This function receives an object containing the entities and optionally the provider configuration,\n * and should return the result of the decision.\n * It can be synchronous or asynchronous.\n */\nexport type DecideFunction<E, R> = (data: {\n entities: E;\n provider?: FlagConfiguration | null;\n}) => MaybePromise<R>;\n\n/**\n * Definition for a feature flag, including its key, description, identify function,\n * and decide function.\n * The identify function is used to determine the entities that will be evaluated\n * against the feature flag, while the decide function contains the logic for\n * determining the outcome of the flag based on those entities.\n */\nexport interface FeatureFlagDefinition<R, Entity> {\n /**\n * Unique key for the feature flag.\n * Should be a string that identifies the flag.\n */\n key: string;\n /**\n * Optional description of the feature flag.\n * This can be used for documentation or debugging purposes.\n */\n description?: string;\n /**\n * Optional flag to enable integration with an external flag provider.\n * If true, the flag will use the global flag provider to determine its state.\n * Default: false\n */\n identify?: IdentifyFunction<Entity>;\n /**\n * Function to decide the outcome of the feature flag.\n * This function receives the identified entities and should return the result of the decision.\n */\n decide: DecideFunction<Entity, R>;\n /**\n * Whether to disable analytics tracking for this flag.\n * Default: false\n */\n disableAnalytics?: boolean;\n}\n\n/**\n * Context for evaluating command flags in CommandKit.\n */\nexport interface CommandFlagContext {\n /**\n * The Discord client instance.\n * This is the main entry point for interacting with the Discord API.\n */\n client: Client<true>;\n /**\n * The CommandKit instance, which provides access to the command framework.\n * This includes commands, events, and other features of CommandKit.\n */\n commandkit: CommandKit;\n /**\n * The command context, which includes information about the command being executed.\n * This can include the interaction, message, guild, channel, and the loaded command.\n */\n command: {\n /**\n * The interaction object if the command was invoked via an interaction.\n * This can be a ChatInputCommandInteraction, AutocompleteInteraction, or ContextMenuCommandInteraction.\n */\n interaction?:\n | ChatInputCommandInteraction\n | AutocompleteInteraction\n | ContextMenuCommandInteraction;\n /**\n * The message object if the command was invoked via a message.\n */\n message?: Message;\n /**\n * The guild where the command was invoked, if applicable.\n * This will be null for commands invoked in DMs.\n */\n guild: Guild | null;\n /**\n * The channel where the command was invoked.\n * This can be a text channel, DM channel, or any other type of text-based channel.\n */\n channel: TextBasedChannel | null;\n /**\n * The loaded command instance that is being executed.\n * This contains the command's metadata and logic.\n */\n command: LoadedCommand;\n };\n /**\n * The event context is null for command flags, as they are not tied to a specific event.\n * This is used to differentiate between command and event flags.\n */\n event: null;\n}\n\n/**\n * Context for evaluating event flags in CommandKit.\n */\nexport interface EventFlagContext {\n /**\n * The Discord client instance.\n * This is the main entry point for interacting with the Discord API.\n */\n client: Client<true>;\n /**\n * The CommandKit instance, which provides access to the command framework.\n * This includes commands, events, and other features of CommandKit.\n */\n commandkit: CommandKit;\n /**\n * The event context, which includes information about the event being processed.\n * This can include the parsed event data, the event name, and the namespace if applicable.\n */\n event: {\n /**\n * The parsed event data, which contains the raw data from the event.\n * This can include information like user IDs, channel IDs, and other relevant data.\n */\n data: ParsedEvent;\n /**\n * The name of the event being processed.\n * This is the string identifier for the event, such as 'messageCreate' or 'guildMemberAdd'.\n */\n event: string;\n /**\n * The namespace of the event, if applicable.\n * This can be used to group related events or commands together.\n * It is null if the event does not belong to a specific namespace.\n */\n namespace: string | null;\n /**\n * The arguments passed to the event handler.\n * This is an array of arguments that were passed when the event was triggered.\n * It can be used to access specific data related to the event.\n */\n arguments: any[];\n /**\n * A function to retrieve the arguments for a specific event type.\n * This allows for type-safe access to the arguments based on the event name.\n * @param event - The name of the event to retrieve arguments for.\n */\n argumentsAs<E extends keyof ClientEvents>(event: E): ClientEvents[E];\n };\n /**\n * The command context is null for event flags, as they are not tied to a specific command.\n * This is used to differentiate between command and event flags.\n */\n command: null;\n}\n\n/**\n * Combined context type for feature flag evaluation.\n */\nexport type EvaluationContext = CommandFlagContext | EventFlagContext;\n\n/**\n * Function type for custom evaluation of feature flags.\n * This function can be used to provide a custom evaluation context for the flag.\n * It should return an object representing the entities to be evaluated.\n */\nexport type CustomEvaluationFunction<E> = () => MaybePromise<E>;\n\n/**\n * Context for custom evaluation of feature flags.\n * This allows for more flexible evaluation based on custom logic or external data.\n * The identify function can be a direct object or a function that returns the entities.\n */\nexport type CustomEvaluationContext<E> = {\n /**\n * Optional function to identify the entities for evaluation.\n * This can be a function that returns the entities based on the current context.\n */\n identify: E | CustomEvaluationFunction<E>;\n};\n\nexport interface FlagRunner<E, R> {\n /**\n * Execute the feature flag evaluation with the provided entities.\n * This method will run the identify and decide functions to determine the flag's outcome.\n * @param res - Optional entities to use for evaluation. If not provided, it will call the identify function.\n * @returns A promise that resolves to the result of the feature flag evaluation.\n */\n (): Promise<R>;\n /**\n * Run the feature flag evaluation with a custom context.\n * This allows for more flexible evaluation based on custom logic or external data.\n * @param context - The custom evaluation context containing the identify function or object.\n * @returns A promise that resolves to the result of the feature flag evaluation.\n */\n run(context: CustomEvaluationContext<E>): Promise<R>;\n}\n\n/**\n * Class representing a feature flag in CommandKit.\n */\nexport class FeatureFlag<R, T> {\n private commandkit: CommandKit;\n\n /**\n * Create a new feature flag.\n * @param options - The options for the feature flag.\n */\n public constructor(public readonly options: FeatureFlagDefinition<R, T>) {\n this.commandkit = getCommandKit(true);\n const FlagStore = this.commandkit.flags;\n\n if (FlagStore.has(options.key)) {\n throw new Error(`Feature flag with key \"${options.key}\" already exists.`);\n }\n\n FlagStore.set(options.key, this);\n }\n\n private getContext(): EvaluationContext {\n const env = getContext();\n\n if (env?.context) {\n const {\n client,\n commandkit,\n interaction,\n message,\n guild,\n channel,\n command,\n } = env.context;\n\n return {\n client: client as Client<true>,\n commandkit,\n command: {\n interaction,\n message,\n guild,\n channel,\n command,\n },\n event: null,\n };\n }\n\n const eventCtx = eventWorkerContext.getStore();\n\n if (eventCtx) {\n const { commandkit, data, event, namespace } = eventCtx;\n\n return {\n client: commandkit.client as Client<true>,\n commandkit,\n event: {\n data,\n event,\n namespace,\n arguments: eventCtx.arguments,\n argumentsAs: (eventName) => {\n const args = eventCtx.arguments as ClientEvents[typeof eventName];\n return args;\n },\n },\n command: null,\n };\n }\n\n throw new Error(\n 'Could not determine the execution context. Feature flags may only be used inside a command or event.',\n );\n }\n\n /**\n * Execute the feature flag evaluation.\n * @param res - Optional entities to use for evaluation. If not provided, it will call the identify function.\n * @returns A promise that resolves to the result of the feature flag evaluation.\n */\n public async execute(res?: T): Promise<R> {\n const { decide, identify, disableAnalytics } = this.options;\n\n const identificationStart = performance.now();\n const entities =\n res ??\n (await (async () => {\n const ctx = this.getContext();\n return (await identify?.(ctx)) ?? ({} as T);\n })());\n const identificationTime = performance.now() - identificationStart;\n\n // Get provider configuration if global provider is available\n let providerConfig: FlagConfiguration | null = null;\n if (flagProvider) {\n try {\n providerConfig = await flagProvider.getFlag(this.options.key, entities);\n\n // If provider says flag is disabled, return early with default behavior\n if (providerConfig && !providerConfig.enabled) {\n // For boolean flags, return false; for others, let decide function handle it\n if (typeof decide === 'function') {\n const decisionResult = await decide({\n entities,\n provider: providerConfig,\n });\n return decisionResult as R;\n }\n }\n } catch (error) {\n Logger.error`Error fetching flag provider configuration for \"${this.options.key}\": ${error}`;\n // continue with local decision if provider fails\n }\n }\n\n const decisionStart = performance.now();\n const decisionResult = await decide({\n entities,\n provider: providerConfig,\n });\n const decisionTime = performance.now() - decisionStart;\n\n // Skip analytics if disabled\n if (!disableAnalytics) {\n defer(async () => {\n await this.commandkit.analytics.track({\n name: AnalyticsEvents.FEATURE_FLAG_METRICS,\n data: {\n flag: this.options.key,\n identificationTime: identificationTime.toFixed(2),\n decisionTime: decisionTime.toFixed(2),\n usedProvider: flagProvider !== null,\n providerEnabled: providerConfig?.enabled ?? null,\n },\n });\n });\n\n defer(async () => {\n await this.commandkit.analytics.track({\n name: AnalyticsEvents.FEATURE_FLAG_DECISION,\n id:\n entities &&\n typeof entities === 'object' &&\n 'id' in entities &&\n typeof entities.id === 'string'\n ? entities.id\n : undefined,\n data: {\n flag: this.options.key,\n decision: JsonSerialize(decisionResult, 'unknown'),\n providerUsed: flagProvider !== null,\n },\n });\n });\n }\n\n return decisionResult as R;\n }\n}\n\n/**\n * Create a new feature flag.\n * @param options - The options for the feature flag.\n * @returns A new instance of the FeatureFlag class.\n */\nexport function flag<Returns = boolean, Entity = Record<any, any>>(\n options: FeatureFlagDefinition<Returns, Entity>,\n): FlagRunner<Entity, Returns> {\n const flag = new FeatureFlag<Returns, Entity>(options);\n const runner = flag.execute.bind(flag, undefined) as FlagRunner<\n Entity,\n Returns\n >;\n\n runner.run = async function (ctx) {\n if (!ctx?.identify) {\n throw new Error(\n 'Custom evaluation context must have an identify function or object.',\n );\n }\n\n const context = (\n typeof ctx === 'function'\n ? await (ctx as CustomEvaluationFunction<Entity>)()\n : ctx\n ) as Entity;\n\n const decisionResult = await flag.execute(context);\n\n return decisionResult;\n };\n\n return runner;\n}\n"],"mappings":";;;;;AAqBA,IAAI,eAAoC;;;;AAKxC,SAAgB,gBAAgB,UAA8B;AAC5D,gBAAe;;;;;AA2NjB,IAAa,cAAb,MAA+B;CAC7B,AAAQ;;;;;CAMR,AAAO,YAAY,AAAgB,SAAsC;EAAtC;AACjC,OAAK,aAAa,iCAAc,KAAK;EACrC,MAAM,YAAY,KAAK,WAAW;AAElC,MAAI,UAAU,IAAI,QAAQ,IAAI,CAC5B,OAAM,IAAI,MAAM,0BAA0B,QAAQ,IAAI,mBAAmB;AAG3E,YAAU,IAAI,QAAQ,KAAK,KAAK;;CAGlC,AAAQ,aAAgC;EACtC,MAAM,MAAM,+BAAY;AAExB,gDAAI,IAAK,SAAS;GAChB,MAAM,EACJ,QACA,YACA,aACA,SACA,OACA,SACA,YACE,IAAI;AAER,UAAO;IACG;IACR;IACA,SAAS;KACP;KACA;KACA;KACA;KACA;KACD;IACD,OAAO;IACR;;EAGH,MAAM,WAAW,8CAAmB,UAAU;AAE9C,MAAI,UAAU;GACZ,MAAM,EAAE,YAAY,MAAM,OAAO,cAAc;AAE/C,UAAO;IACL,QAAQ,WAAW;IACnB;IACA,OAAO;KACL;KACA;KACA;KACA,WAAW,SAAS;KACpB,cAAc,cAAc;AAE1B,aADa,SAAS;;KAGzB;IACD,SAAS;IACV;;AAGH,QAAM,IAAI,MACR,uGACD;;;;;;;CAQH,MAAa,QAAQ,KAAqB;EACxC,MAAM,EAAE,QAAQ,UAAU,qBAAqB,KAAK;EAEpD,MAAM,sBAAsB,YAAY,KAAK;EAC7C,MAAM,WACN,OACA,OAAO,YAAY;GACjB,MAAM,MAAM,KAAK,YAAY;AAC7B,UAAQ,2DAAM,SAAW,IAAI,KAAK,EAAE;MAClC;EACJ,MAAM,qBAAqB,YAAY,KAAK,GAAG;EAG/C,IAAI,iBAA2C;AAC/C,MAAI,aACF,KAAI;AACF,oBAAiB,MAAM,aAAa,QAAQ,KAAK,QAAQ,KAAK,SAAS;AAGvE,OAAI,kBAAkB,CAAC,eAAe,SAEpC;QAAI,OAAO,WAAW,WAKpB,QAJuB,MAAM,OAAO;KAClC;KACA,UAAU;KACX,CAAC;;WAIC,OAAO;AACd,6BAAO,KAAK,mDAAmD,KAAK,QAAQ,IAAI,KAAK;;EAKzF,MAAM,gBAAgB,YAAY,KAAK;EACvC,MAAM,iBAAiB,MAAM,OAAO;GAClC;GACA,UAAU;GACX,CAAC;EACF,MAAM,eAAe,YAAY,KAAK,GAAG;AAGzC,MAAI,CAAC,kBAAkB;AACrB,4BAAM,YAAY;AAChB,UAAM,KAAK,WAAW,UAAU,MAAM;KACpC,MAAM,kCAAgB;KACtB,MAAM;MACJ,MAAM,KAAK,QAAQ;MACnB,oBAAoB,mBAAmB,QAAQ,EAAE;MACjD,cAAc,aAAa,QAAQ,EAAE;MACrC,cAAc,iBAAiB;MAC/B,kFAAiB,eAAgB,YAAW;MAC7C;KACF,CAAC;KACF;AAEF,4BAAM,YAAY;AAChB,UAAM,KAAK,WAAW,UAAU,MAAM;KACpC,MAAM,kCAAgB;KACtB,IACA,YACA,OAAO,aAAa,YACpB,QAAQ,YACR,OAAO,SAAS,OAAO,WACvB,SAAS,KACT;KACA,MAAM;MACJ,MAAM,KAAK,QAAQ;MACnB,UAAU,iCAAc,gBAAgB,UAAU;MAClD,cAAc,iBAAiB;MAChC;KACF,CAAC;KACF;;AAGJ,SAAO;;;;;;;;AASX,SAAgB,KAChB,SAC8B;CAC5B,MAAM,SAAO,IAAI,YAA6B,QAAQ;CACtD,MAAM,SAAS,OAAK,QAAQ,KAAK,QAAM,OAAU;AAKjD,QAAO,MAAM,eAAgB,KAAK;AAChC,MAAI,4CAAC,IAAK,UACR,OAAM,IAAI,MACR,sEACD;EAGH,MAAM,UACN,OAAO,QAAQ,aACf,MAAO,KAA0C,GACjD;AAKA,SAFuB,MAAM,OAAK,QAAQ,QAAQ;;AAKpD,QAAO"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-DVOELoNv.js","names":[],"sources":["../src/components/v2/file.ts"],"sourcesContent":["import { FileBuilder, FileComponentData } from 'discord.js';\n\n/**\n * Represents the properties for a file component.\n */\nexport interface FileProps extends Omit<FileComponentData, 'type' | 'file'> {\n url: string;\n}\n\n/**\n * The file component\n * @param props - The properties for the file component.\n * @returns The file builder instance.\n * @example ```tsx\n * import { File } from 'commandkit';\n *\n * const file = <File url=\"https://example.com/file.png\" />;\n * ```\n */\nexport function File(props: FileProps) {\n const file = new FileBuilder(props);\n\n if (props.url != null) {\n file.setURL(props.url);\n }\n\n return file;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAmBA,SAAgB,KAAK,OAAkB;CACrC,MAAM,OAAO,IAAI,uBAAY,MAAM;AAEnC,KAAI,MAAM,OAAO,KACf,MAAK,OAAO,MAAM,IAAI;AAGxB,QAAO"}
@@ -1,36 +0,0 @@
1
- const require_chunk = require('./chunk-nOFOJqeH.js');
2
- let discord_js = require("discord.js");
3
- discord_js = require_chunk.__toESM(discord_js);
4
-
5
- //#region src/app/commands/helpers.ts
6
- /**
7
- * Type guard to check if a command source is a Discord message.
8
- * @param source - The command source to check
9
- * @returns True if the source is a Message
10
- */
11
- function isMessageSource(source) {
12
- return source instanceof discord_js.Message;
13
- }
14
- /**
15
- * Type guard to check if a command source is a Discord interaction.
16
- * @param source - The command source to check
17
- * @returns True if the source is an Interaction
18
- */
19
- function isInteractionSource(source) {
20
- return !isMessageSource(source);
21
- }
22
-
23
- //#endregion
24
- Object.defineProperty(exports, 'isInteractionSource', {
25
- enumerable: true,
26
- get: function () {
27
- return isInteractionSource;
28
- }
29
- });
30
- Object.defineProperty(exports, 'isMessageSource', {
31
- enumerable: true,
32
- get: function () {
33
- return isMessageSource;
34
- }
35
- });
36
- //# sourceMappingURL=helpers-BSwwrKJW.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers-BSwwrKJW.js","names":[],"sources":["../src/app/commands/helpers.ts"],"sourcesContent":["import { Interaction, Message } from 'discord.js';\n\n/**\n * Union type representing possible command sources.\n */\nexport type CommandSource = Interaction | Message;\n\n/**\n * Type guard to check if a command source is a Discord message.\n * @param source - The command source to check\n * @returns True if the source is a Message\n */\nexport function isMessageSource(source: CommandSource): source is Message {\n return source instanceof Message;\n}\n\n/**\n * Type guard to check if a command source is a Discord interaction.\n * @param source - The command source to check\n * @returns True if the source is an Interaction\n */\nexport function isInteractionSource(\n source: CommandSource,\n): source is Interaction {\n return !isMessageSource(source);\n}\n"],"mappings":";;;;;;;;;;AAYA,SAAgB,gBAAgB,QAA0C;AACxE,QAAO,kBAAkB;;;;;;;AAQ3B,SAAgB,oBAChB,QACwB;AACtB,QAAO,CAAC,gBAAgB,OAAO"}
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { CommandKit } from './commandkit';\n\nexport default CommandKit;\n\nexport * from './commandkit';\nexport * from './components';\nexport * from './config/config';\nexport * from './context/async-context';\nexport {\n type CommandKitEnvironmentInternalData,\n CommandKitEnvironment,\n CommandKitEnvironmentType,\n cancelAfter as unstable_cancelAfter,\n after as unstable_after,\n} from './context/environment';\nexport * from './app/index';\nexport * from './logger/DefaultLogger';\nexport * from './logger/ILogger';\nexport * from './logger/Logger';\nexport * from './app/router/index';\nexport type * from './types';\nexport * from './version';\nexport * from './plugins/index';\nexport * from './flags/feature-flags';\nexport {\n getCurrentDirectory,\n getSourceDirectories,\n devOnly,\n debounce,\n defer,\n} from './utils/utilities';\nexport { toFileURL } from './utils/resolve-file-url';\nexport * from './app/interrupt/signals';\nexport type { CommandKitHMREvent } from './utils/dev-hooks';\nexport * from './utils/constants';\nexport * from './app/events/EventWorkerContext';\nexport { CommandKitErrorCodes, isErrorType } from './utils/error-codes';\nexport { Collection, type Client } from 'discord.js';\n\n// cli\nexport { bootstrapCommandkitCLI } from './cli/init';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,kBAAe"}
@@ -1,95 +0,0 @@
1
- const require_chunk = require('./chunk-nOFOJqeH.js');
2
- const require_commandkit = require('./commandkit-Bm0gLN8i.js');
3
- const require_constants = require('./constants-B5_Ta7PR.js');
4
- const require_CompilerPlugin = require('./CompilerPlugin-M8r3yNAl.js');
5
- const require_types_package = require('./types-package-BWArjyBF.js');
6
- const require_common = require('./common-Dxr9-XPa.js');
7
- let node_fs = require("node:fs");
8
- node_fs = require_chunk.__toESM(node_fs);
9
- let node_path = require("node:path");
10
- node_path = require_chunk.__toESM(node_path);
11
- let node_fs_promises = require("node:fs/promises");
12
- node_fs_promises = require_chunk.__toESM(node_fs_promises);
13
-
14
- //#region src/cli/init.ts
15
- /**
16
- * Creates a command line interface for CommandKit.
17
- * @param argv The arguments passed to the CLI.
18
- * @param options The options passed to the CLI.
19
- */
20
- async function bootstrapCommandkitCLI(argv, options) {
21
- process.title = "CommandKit CLI";
22
- const { Command } = await import("commander");
23
- const { bootstrapDevelopmentServer } = await Promise.resolve().then(() => require("./cli/development.js"));
24
- const { bootstrapProductionServer, createProductionBuild } = await Promise.resolve().then(() => require("./cli/production.js"));
25
- const { generateCommand, generateEvent } = await Promise.resolve().then(() => require("./cli/generators.js"));
26
- const { version } = await Promise.resolve().then(() => require("./version.js"));
27
- const { showInformation } = await Promise.resolve().then(() => require("./cli/information.js"));
28
- const { setCLIEnv } = await Promise.resolve().then(() => require("./cli/env.js"));
29
- const program = new Command("commandkit");
30
- program.command("dev").version(version).description("Start your bot in development mode.").option("-c, --config [path]", "Path to your commandkit config file.", "./commandkit.js").action(() => {
31
- const options$1 = program.opts();
32
- bootstrapDevelopmentServer(options$1.config);
33
- });
34
- program.command("info").description("Show information about the system which can be used to report bugs.").action(async () => {
35
- await showInformation();
36
- });
37
- program.command("start").description("Start your bot in production mode after running the build command.").option("-c, --config [path]", "Path to your commandkit config file.").action(() => {
38
- const options$1 = program.opts();
39
- bootstrapProductionServer(options$1.config);
40
- });
41
- program.command("build").description("Build your project for production usage.").option("-c, --config [path]", "Path to your commandkit config file.").action(() => {
42
- setCLIEnv();
43
- const options$1 = program.opts();
44
- return createProductionBuild(options$1.config);
45
- });
46
- program.command("create").description("Create new files using built-in templates or custom plugin templates").argument("<template>", "The template to use (e.g. command, event, or custom plugin template)").argument("[args...]", "Additional arguments for the template").action(async (template, args) => {
47
- setCLIEnv();
48
- const { plugins } = await require_commandkit.loadConfigFile();
49
- const runtime = new require_commandkit.CompilerPluginRuntime(plugins.filter((p) => require_CompilerPlugin.isCompilerPlugin(p)));
50
- try {
51
- await runtime.init();
52
- const templateHandler = runtime.getTemplate(template);
53
- if (!templateHandler) {
54
- if (template === "command") {
55
- const [name] = args;
56
- if (!name) require_common.panic("Command name is required");
57
- await generateCommand(name);
58
- return;
59
- }
60
- if (template === "event") {
61
- const [name] = args;
62
- if (!name) require_common.panic("Event name is required");
63
- await generateEvent(name);
64
- return;
65
- }
66
- const valid = Array.from(new Set([
67
- "command",
68
- "event",
69
- ...Array.from(runtime.getTemplates().keys())
70
- ])).map((t) => `"${t}"`);
71
- require_common.panic(`Template "${template}" not found. Available templates: ${valid.join(", ")}`);
72
- }
73
- await templateHandler(args);
74
- } catch (e) {
75
- require_common.panic(`Failed to execute template "${template}": ${(e === null || e === void 0 ? void 0 : e.message) || e}`);
76
- } finally {
77
- await runtime.destroy();
78
- }
79
- });
80
- const types = (0, node_path.join)(require_constants.COMMANDKIT_CWD, "node_modules", "commandkit-types");
81
- if (!(0, node_fs.existsSync)(types)) {
82
- await (0, node_fs_promises.mkdir)(types, { recursive: true }).catch(() => {});
83
- await require_types_package.generateTypesPackage(true).catch(() => {});
84
- }
85
- await program.parseAsync(argv, options);
86
- }
87
-
88
- //#endregion
89
- Object.defineProperty(exports, 'bootstrapCommandkitCLI', {
90
- enumerable: true,
91
- get: function () {
92
- return bootstrapCommandkitCLI;
93
- }
94
- });
95
- //# sourceMappingURL=init-Cy_bcUt4.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"init-Cy_bcUt4.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,aAAa;AAEzC,SACA,QAAQ,MAAM,CACd,QAAQ,QAAQ,CAChB,YAAY,sCAAsC,CAClD,OACE,uBACA,wCACA,kBACD,CACD,aAAa;EACX,MAAM,YAAU,QAAQ,MAAM;AAC9B,6BAA2B,UAAQ,OAAO;GAC1C;AAEF,SACA,QAAQ,OAAO,CACf,YACE,sEACD,CACD,OAAO,YAAY;AACjB,QAAM,iBAAiB;GACvB;AAEF,SACA,QAAQ,QAAQ,CAChB,YACE,qEACD,CACD,OAAO,uBAAuB,uCAAuC,CACrE,aAAa;EACX,MAAM,YAAU,QAAQ,MAAM;AAC9B,4BAA0B,UAAQ,OAAO;GACzC;AAEF,SACA,QAAQ,QAAQ,CAChB,YAAY,2CAA2C,CACvD,OAAO,uBAAuB,uCAAuC,CACrE,aAAa;AACX,aAAW;EACX,MAAM,YAAU,QAAQ,MAAM;AAC9B,SAAO,sBAAsB,UAAQ,OAAO;GAC5C;AAEF,SACA,QAAQ,SAAS,CACjB,YACE,uEACD,CACD,SACE,cACA,uEACD,CACD,SAAS,aAAa,wCAAwC,CAC9D,OAAO,OAAO,UAAU,SAAS;AAC/B,aAAW;EAGX,MAAM,EAAE,YAAY,MAAM,mCAAgB;EAC1C,MAAM,UAAU,IAAI,yCAClB,QAAQ,QAAQ,MAAM,wCAAiB,EAAE,CAAC,CAC3C;AAED,MAAI;AACF,SAAM,QAAQ,MAAM;GACpB,MAAM,kBAAkB,QAAQ,YAAY,SAAS;AAErD,OAAI,CAAC,iBAAiB;AAEpB,QAAI,aAAa,WAAW;KAC1B,MAAM,CAAC,QAAQ;AACf,SAAI,CAAC,KACH,sBAAM,2BAA2B;AAEnC,WAAM,gBAAgB,KAAK;AAC3B;;AAGF,QAAI,aAAa,SAAS;KACxB,MAAM,CAAC,QAAQ;AACf,SAAI,CAAC,KACH,sBAAM,yBAAyB;AAEjC,WAAM,cAAc,KAAK;AACzB;;IAGF,MAAM,QAAQ,MAAM,KAClB,IAAI,IAAI;KACR;KACA;KACA,GAAG,MAAM,KAAK,QAAQ,cAAc,CAAC,MAAM,CAAC;KAAC,CAC5C,CACF,CAAC,KAAK,MAAM,IAAI,EAAE,GAAG;AAEtB,yBACE,aAAa,SAAS,oCAAoC,MAAM,KAAK,KAAK,GAC3E;;AAGH,SAAM,gBAAgB,KAAK;WACpB,GAAQ;AACf,wBAAM,+BAA+B,SAAS,4CAAK,EAAG,YAAW,IAAI;YAC7D;AACR,SAAM,QAAQ,SAAS;;GAEzB;CAEF,MAAM,4BAAa,kCAAgB,gBAAgB,mBAAmB;AAEtE,KAAI,yBAAY,MAAM,EAAE;AACtB,oCAAY,OAAO,EAAE,WAAW,MAAM,CAAC,CAAC,YAAY,GAAG;AACvD,QAAM,2CAAqB,KAAK,CAAC,YAAY,GAAG;;AAGlD,OAAM,QAAQ,WAAW,MAAM,QAAQ"}
@@ -1,13 +0,0 @@
1
- import * as commander0 from "commander";
2
-
3
- //#region src/cli/init.d.ts
4
-
5
- /**
6
- * Creates a command line interface for CommandKit.
7
- * @param argv The arguments passed to the CLI.
8
- * @param options The options passed to the CLI.
9
- */
10
- declare function bootstrapCommandkitCLI(argv: string[], options?: commander0.ParseOptions | undefined): Promise<void>;
11
- //#endregion
12
- export { bootstrapCommandkitCLI };
13
- //# sourceMappingURL=init-DOr-Y3GQ.d.ts.map