commandkit 1.2.1 → 1.2.2

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 (271) hide show
  1. package/README.md +1 -1
  2. package/cache.cjs +2 -0
  3. package/cache.d.ts +1 -0
  4. package/dist/{ActionRow-Bt9qi0Mb.d.ts → ActionRow-DSh9roc5.d.ts} +2 -3
  5. package/dist/{Button-DxJLcZIU.d.ts → Button-BPsE5ju0.d.ts} +5 -6
  6. package/dist/{ButtonKit-BfcyvWfj.d.ts → ButtonKit-CNPmVg3h.d.ts} +2 -3
  7. package/dist/{ChannelSelectMenuKit-DYkudikb.d.ts → ChannelSelectMenuKit-CcOdaLQ6.d.ts} +3 -4
  8. package/dist/CommandTree-qu-8oAEV.d.ts +55 -0
  9. package/dist/CommandsRouter-Co225Ae5.d.ts +242 -0
  10. package/dist/{EventInterceptor-D9JKMcfi.d.ts → EventInterceptor-wg378vJp.d.ts} +1 -2
  11. package/dist/{EventsRouter-EuuSu6NH.d.ts → EventsRouter-Bt63ZuEF.d.ts} +21 -2
  12. package/dist/{MentionableSelectMenuKit-Mu4xqP6B.d.ts → MentionableSelectMenuKit-8_Nkgn_a.d.ts} +3 -4
  13. package/dist/{MessageCommandParser-DPCbHXCS.d.ts → MessageCommandParser-BYbxHOSK.d.ts} +7 -2
  14. package/dist/{Modal-v9rrcMl-.d.ts → Modal-DbWK6VmV.d.ts} +5 -6
  15. package/dist/{ModalKit-XJSM65SV.d.ts → ModalKit-CnmUVpw-.d.ts} +2 -3
  16. package/dist/{RoleSelectMenuKit-CCjcp3HY.d.ts → RoleSelectMenuKit-Bei7DHqD.d.ts} +3 -4
  17. package/dist/{SelectMenu-CY0vvoSu.d.ts → SelectMenu-Bce_PClo.d.ts} +8 -9
  18. package/dist/{StringSelectMenuKit-G5nBTicX.d.ts → StringSelectMenuKit-CBeB9HqT.d.ts} +3 -4
  19. package/dist/TreeArtifact-D6FZ5SVd.d.ts +27 -0
  20. package/dist/{UserSelectMenuKit-D3SO_fXA.d.ts → UserSelectMenuKit-DZmeZ_Tp.d.ts} +3 -4
  21. package/dist/analytics/analytics-engine.d.ts +1 -1
  22. package/dist/analytics/analytics-engine.js +1 -1
  23. package/dist/analytics/analytics-provider.d.ts +1 -1
  24. package/dist/analytics/constants.js +0 -1
  25. package/dist/analytics/constants.js.map +1 -1
  26. package/dist/analytics/utils.js +1 -1
  27. package/dist/{analytics-engine-DnRsHBId.d.ts → analytics-engine-Bz1p7ud3.d.ts} +178 -30
  28. package/dist/app/commands/AppCommandRunner.d.ts +1 -1
  29. package/dist/app/commands/AppCommandRunner.js +1 -1
  30. package/dist/app/commands/Context.d.ts +1 -1
  31. package/dist/app/commands/Context.js +1 -1
  32. package/dist/app/commands/MessageCommandParser.d.ts +1 -1
  33. package/dist/app/commands/MessageCommandParser.js +79 -71
  34. package/dist/app/commands/MessageCommandParser.js.map +1 -1
  35. package/dist/app/commands/helpers.d.ts +1 -1
  36. package/dist/app/commands/helpers.js +0 -1
  37. package/dist/app/commands/helpers.js.map +1 -1
  38. package/dist/app/events/EventWorkerContext.d.ts +3 -3
  39. package/dist/app/events/EventWorkerContext.js +0 -1
  40. package/dist/app/events/EventWorkerContext.js.map +1 -1
  41. package/dist/app/handlers/AppCommandHandler.d.ts +1 -1
  42. package/dist/app/handlers/AppCommandHandler.js +1 -1
  43. package/dist/app/handlers/AppEventsHandler.d.ts +1 -1
  44. package/dist/app/handlers/AppEventsHandler.js +1 -1
  45. package/dist/app/index.d.ts +5 -5
  46. package/dist/app/index.js +1 -1
  47. package/dist/app/interrupt/signals.d.ts +1 -1
  48. package/dist/app/interrupt/signals.js.map +1 -1
  49. package/dist/app/middlewares/permissions.d.ts +1 -2
  50. package/dist/app/middlewares/permissions.js +1 -1
  51. package/dist/app/register/CommandRegistrar.d.ts +1 -1
  52. package/dist/app/register/CommandRegistrar.js +1 -1
  53. package/dist/app/router/CommandTree.d.ts +2 -0
  54. package/dist/app/router/CommandTree.js +1 -0
  55. package/dist/app/router/CommandsRouter.d.ts +2 -2
  56. package/dist/app/router/CommandsRouter.js +445 -24
  57. package/dist/app/router/CommandsRouter.js.map +1 -1
  58. package/dist/app/router/EventsRouter.d.ts +2 -2
  59. package/dist/app/router/EventsRouter.js +56 -3
  60. package/dist/app/router/EventsRouter.js.map +1 -1
  61. package/dist/app/router/TreeArtifact.d.ts +2 -0
  62. package/dist/app/router/TreeArtifact.js +87 -0
  63. package/dist/app/router/TreeArtifact.js.map +1 -0
  64. package/dist/app/router/index.d.ts +6 -3
  65. package/dist/app/router/index.js +8 -1
  66. package/dist/checkbox-DoR0Pcxm.d.ts +27 -0
  67. package/dist/cli/app-process.d.ts +2 -3
  68. package/dist/cli/app-process.js +15 -4
  69. package/dist/cli/app-process.js.map +1 -1
  70. package/dist/cli/build.d.ts +4 -9
  71. package/dist/cli/build.js +33 -5
  72. package/dist/cli/build.js.map +1 -1
  73. package/dist/cli/common.d.ts +3 -6
  74. package/dist/cli/common.js +2 -2
  75. package/dist/cli/common.js.map +1 -1
  76. package/dist/cli/development.d.ts +5 -6
  77. package/dist/cli/development.js +12 -12
  78. package/dist/cli/development.js.map +1 -1
  79. package/dist/cli/env.js.map +1 -1
  80. package/dist/cli/generators.js +0 -1
  81. package/dist/cli/generators.js.map +1 -1
  82. package/dist/cli/information.js +5 -5
  83. package/dist/cli/information.js.map +1 -1
  84. package/dist/cli/init.d.ts +1 -3
  85. package/dist/cli/init.js +37 -12
  86. package/dist/cli/init.js.map +1 -1
  87. package/dist/cli/production.d.ts +1 -3
  88. package/dist/cli/production.js +4 -4
  89. package/dist/cli/production.js.map +1 -1
  90. package/dist/cli/type-checker.js +0 -1
  91. package/dist/cli/type-checker.js.map +1 -1
  92. package/dist/cli/utils.d.ts +0 -1
  93. package/dist/cli/utils.js.map +1 -1
  94. package/dist/{commandkit-Bh7C1_c7.js → commandkit-DNbfLwyR.js} +786 -200
  95. package/dist/commandkit-DNbfLwyR.js.map +1 -0
  96. package/dist/commandkit.d.ts +1 -1
  97. package/dist/commandkit.js +1 -1
  98. package/dist/{common-CCvvgnxi.d.ts → common-CIbPzguv.d.ts} +2 -3
  99. package/dist/components/common/EventInterceptor.d.ts +1 -1
  100. package/dist/components/common/EventInterceptor.js +1 -0
  101. package/dist/components/common/EventInterceptor.js.map +1 -1
  102. package/dist/components/common/element.d.ts +1 -1
  103. package/dist/components/common/element.js +1 -1
  104. package/dist/components/common/types.d.ts +1 -1
  105. package/dist/components/display/common.d.ts +0 -1
  106. package/dist/components/display/common.js +1 -1
  107. package/dist/components/display/container.d.ts +1 -1
  108. package/dist/components/display/container.js +1 -1
  109. package/dist/components/display/file.d.ts +1 -1
  110. package/dist/components/display/file.js +0 -1
  111. package/dist/components/display/file.js.map +1 -1
  112. package/dist/components/display/index.d.ts +9 -8
  113. package/dist/components/display/index.js +1 -1
  114. package/dist/components/display/label.d.ts +1 -1
  115. package/dist/components/display/label.js +1 -1
  116. package/dist/components/display/media-gallery.d.ts +1 -1
  117. package/dist/components/display/media-gallery.js +1 -1
  118. package/dist/components/display/poll.d.ts +1 -1
  119. package/dist/components/display/poll.js +4 -10
  120. package/dist/components/display/poll.js.map +1 -1
  121. package/dist/components/display/section.d.ts +1 -1
  122. package/dist/components/display/section.js +1 -1
  123. package/dist/components/display/separator.d.ts +1 -1
  124. package/dist/components/display/separator.js +0 -1
  125. package/dist/components/display/separator.js.map +1 -1
  126. package/dist/components/display/text-display.d.ts +1 -1
  127. package/dist/components/display/text-display.js +0 -1
  128. package/dist/components/display/text-display.js.map +1 -1
  129. package/dist/components/index.d.ts +26 -23
  130. package/dist/components/index.js +6 -1
  131. package/dist/components/interactive/action-row/ActionRow.d.ts +1 -1
  132. package/dist/components/interactive/action-row/ActionRow.js +0 -1
  133. package/dist/components/interactive/action-row/ActionRow.js.map +1 -1
  134. package/dist/components/interactive/button/Button.d.ts +1 -1
  135. package/dist/components/interactive/button/Button.js +1 -1
  136. package/dist/components/interactive/button/ButtonKit.d.ts +1 -1
  137. package/dist/components/interactive/button/ButtonKit.js +1 -1
  138. package/dist/components/interactive/checkbox/checkbox.d.ts +2 -0
  139. package/dist/components/interactive/checkbox/checkbox.js +6 -0
  140. package/dist/components/interactive/modal/Modal.d.ts +1 -1
  141. package/dist/components/interactive/modal/Modal.js +1 -1
  142. package/dist/components/interactive/modal/ModalKit.d.ts +1 -1
  143. package/dist/components/interactive/modal/ModalKit.js +1 -1
  144. package/dist/components/interactive/radio/radio.d.ts +2 -0
  145. package/dist/components/interactive/radio/radio.js +5 -0
  146. package/dist/components/interactive/select-menu/ChannelSelectMenuKit.d.ts +1 -1
  147. package/dist/components/interactive/select-menu/ChannelSelectMenuKit.js +1 -1
  148. package/dist/components/interactive/select-menu/MentionableSelectMenuKit.d.ts +1 -1
  149. package/dist/components/interactive/select-menu/MentionableSelectMenuKit.js +1 -1
  150. package/dist/components/interactive/select-menu/RoleSelectMenuKit.d.ts +1 -1
  151. package/dist/components/interactive/select-menu/RoleSelectMenuKit.js +1 -1
  152. package/dist/components/interactive/select-menu/SelectMenu.d.ts +1 -1
  153. package/dist/components/interactive/select-menu/SelectMenu.js +1 -1
  154. package/dist/components/interactive/select-menu/StringSelectMenuKit.d.ts +1 -1
  155. package/dist/components/interactive/select-menu/StringSelectMenuKit.js +1 -1
  156. package/dist/components/interactive/select-menu/UserSelectMenuKit.d.ts +1 -1
  157. package/dist/components/interactive/select-menu/UserSelectMenuKit.js +1 -1
  158. package/dist/components/interactive/select-menu/common.d.ts +1 -1
  159. package/dist/config/config.d.ts +1 -2
  160. package/dist/config/config.js +1 -1
  161. package/dist/config/default.d.ts +1 -2
  162. package/dist/config/default.js +1 -1
  163. package/dist/config/loader.d.ts +1 -2
  164. package/dist/config/loader.js +1 -1
  165. package/dist/config/types.d.ts +2 -2
  166. package/dist/config/utils.d.ts +1 -1
  167. package/dist/config/utils.js.map +1 -1
  168. package/dist/{constants-DqtJY0t-.d.ts → constants-B7AfnOFa.d.ts} +1 -1
  169. package/dist/{constants-DwxpkIeH.d.ts → constants-kWgE3L9F.d.ts} +15 -2
  170. package/dist/{container-CYojOA9d.d.ts → container-NVgblXmw.d.ts} +1 -2
  171. package/dist/context/async-context.d.ts +1 -1
  172. package/dist/context/async-context.js +1 -1
  173. package/dist/context/environment.d.ts +1 -1
  174. package/dist/context/environment.js +1 -1
  175. package/dist/{element-DeLvTMfZ.d.ts → element-BMZYAAQ-.d.ts} +3 -4
  176. package/dist/events/CommandKitEventsChannel.d.ts +1 -1
  177. package/dist/events/CommandKitEventsChannel.js +3 -2
  178. package/dist/events/CommandKitEventsChannel.js.map +1 -1
  179. package/dist/{file-DLO1zEcH.d.ts → file-DYAmr697.d.ts} +1 -2
  180. package/dist/flags/FlagProvider.d.ts +1 -1
  181. package/dist/flags/FlagProvider.js +1 -0
  182. package/dist/flags/FlagProvider.js.map +1 -1
  183. package/dist/flags/feature-flags.d.ts +1 -1
  184. package/dist/flags/feature-flags.js +1 -1
  185. package/dist/flags/store.d.ts +1 -1
  186. package/dist/flags/store.js +0 -1
  187. package/dist/flags/store.js.map +1 -1
  188. package/dist/{helpers-zmC44Mcu.d.ts → helpers-vlnRvNJv.d.ts} +1 -2
  189. package/dist/index-CAFaKBs_.d.ts +8 -0
  190. package/dist/index-COt7nfC9.d.ts +2 -0
  191. package/dist/index-DvqHpiuh.d.ts +16 -0
  192. package/dist/index.d.ts +37 -31
  193. package/dist/index.js +14 -2
  194. package/dist/kv/constants.d.ts +1 -1
  195. package/dist/kv/constants.js.map +1 -1
  196. package/dist/kv/dotprops.js.map +1 -1
  197. package/dist/kv/kv.d.ts +0 -1
  198. package/dist/kv/kv.js +1 -1
  199. package/dist/kv/kv.js.map +1 -1
  200. package/dist/kv/serde.d.ts +1 -2
  201. package/dist/kv/serde.js +27 -27
  202. package/dist/kv/serde.js.map +1 -1
  203. package/dist/{label-DqGRqodo.d.ts → label-DClaYktn.d.ts} +1 -2
  204. package/dist/logger/DefaultLogger.d.ts +0 -1
  205. package/dist/logger/DefaultLogger.js +1 -1
  206. package/dist/logger/Logger.d.ts +0 -1
  207. package/dist/logger/Logger.js +1 -1
  208. package/dist/logger/NoopLogger.d.ts +0 -1
  209. package/dist/logger/NoopLogger.js.map +1 -1
  210. package/dist/{media-gallery-Ca8es-eB.d.ts → media-gallery-z2Snzz-u.d.ts} +1 -2
  211. package/dist/plugins/CompilerPlugin.d.ts +1 -1
  212. package/dist/plugins/CompilerPlugin.js +2 -2
  213. package/dist/plugins/CompilerPlugin.js.map +1 -1
  214. package/dist/plugins/PluginCommon.d.ts +1 -1
  215. package/dist/plugins/PluginCommon.js +1 -1
  216. package/dist/plugins/PluginCommon.js.map +1 -1
  217. package/dist/plugins/RuntimePlugin.d.ts +1 -1
  218. package/dist/plugins/RuntimePlugin.js +2 -2
  219. package/dist/plugins/RuntimePlugin.js.map +1 -1
  220. package/dist/plugins/index.d.ts +1 -1
  221. package/dist/plugins/index.js +1 -1
  222. package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.d.ts +1 -1
  223. package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.js +1 -1
  224. package/dist/plugins/plugin-runtime/CompilerPluginRuntime.d.ts +1 -1
  225. package/dist/plugins/plugin-runtime/CompilerPluginRuntime.js +1 -1
  226. package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.d.ts +1 -1
  227. package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.js +1 -1
  228. package/dist/plugins/plugin-runtime/builtin/MacroPlugin.d.ts +1 -2
  229. package/dist/plugins/plugin-runtime/builtin/MacroPlugin.js +1 -1
  230. package/dist/plugins/plugin-runtime/runtime.d.ts +1 -1
  231. package/dist/plugins/types.d.ts +1 -1
  232. package/dist/{poll-DQ6DX_Tt.d.ts → poll-D2QDStsw.d.ts} +4 -14
  233. package/dist/radio-CJH_N4lq.d.ts +20 -0
  234. package/dist/{section-Q8nwx_-q.d.ts → section-DrFBT5b-.d.ts} +1 -2
  235. package/dist/{separator-B8P-kdIK.d.ts → separator-BVm3w6yd.d.ts} +1 -2
  236. package/dist/{signals-CBXwugBW.d.ts → signals-DRMDrCOn.d.ts} +1 -1
  237. package/dist/{text-display-CL9C2yMc.d.ts → text-display-BG0nNqy3.d.ts} +1 -2
  238. package/dist/{types-DZy7U-Ld.d.ts → types-ur7SvktF.d.ts} +1 -1
  239. package/dist/types.d.ts +1 -1
  240. package/dist/utils/colors.d.ts +1 -3
  241. package/dist/utils/colors.js +0 -1
  242. package/dist/utils/colors.js.map +1 -1
  243. package/dist/utils/constants.d.ts +2 -2
  244. package/dist/utils/constants.js +19 -0
  245. package/dist/utils/constants.js.map +1 -1
  246. package/dist/utils/dev-hooks.d.ts +1 -1
  247. package/dist/utils/dev-hooks.js +1 -1
  248. package/dist/utils/error-codes.js +15 -0
  249. package/dist/utils/error-codes.js.map +1 -1
  250. package/dist/utils/resolve-file-url.js +2 -2
  251. package/dist/utils/resolve-file-url.js.map +1 -1
  252. package/dist/utils/types-package.d.ts +6 -2
  253. package/dist/utils/types-package.js +31 -38
  254. package/dist/utils/types-package.js.map +1 -1
  255. package/dist/utils/useful-stuff/async-queue.js.map +1 -1
  256. package/dist/utils/useful-stuff/mutex.js.map +1 -1
  257. package/dist/utils/useful-stuff/ratelimiter.js +4 -1
  258. package/dist/utils/useful-stuff/ratelimiter.js.map +1 -1
  259. package/dist/utils/useful-stuff/semaphore.js.map +1 -1
  260. package/dist/utils/utilities.js +1 -1
  261. package/dist/utils/warning.d.ts +1 -5
  262. package/dist/utils/warning.js.map +1 -1
  263. package/dist/version.js +1 -1
  264. package/dist/version.js.map +1 -1
  265. package/package.json +17 -17
  266. package/dist/CommandsRouter-DiNoF0dq.d.ts +0 -145
  267. package/dist/commandkit-Bh7C1_c7.js.map +0 -1
  268. package/dist/index-BIsCUWAs.d.ts +0 -1
  269. package/dist/index-CwHYpK-f.d.ts +0 -1
  270. package/dist/index-DHrsNvX1.d.ts +0 -1
  271. /package/dist/{chunk-BE-pF4vm.js → rolldown-runtime-C_NdSu1c.js} +0 -0
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_chunk = require('../../chunk-BE-pF4vm.js');
3
2
  let discord_js = require("discord.js");
4
3
  let node_fs = require("node:fs");
5
4
  let node_path = require("node:path");
@@ -11,6 +10,7 @@ let node_fs_promises = require("node:fs/promises");
11
10
  * Events are represented by directories, and handlers are files within those directories.
12
11
  */
13
12
  var EventsRouter = class {
13
+ options;
14
14
  /** Internal storage of parsed events */
15
15
  events = new discord_js.Collection();
16
16
  /**
@@ -29,7 +29,7 @@ var EventsRouter = class {
29
29
  * @param entrypoints - Array of new entrypoint paths
30
30
  */
31
31
  addEntrypoints(entrypoints) {
32
- this.options.entrypoints = Array.from(new Set([...this.options.entrypoints, ...entrypoints]));
32
+ this.options.entrypoints = Array.from(/* @__PURE__ */ new Set([...this.options.entrypoints, ...entrypoints]));
33
33
  }
34
34
  /**
35
35
  * Find a parsed event by its name
@@ -59,6 +59,13 @@ var EventsRouter = class {
59
59
  this.events.clear();
60
60
  }
61
61
  /**
62
+ * Populates router state from pre-resolved event metadata.
63
+ */
64
+ populate(events) {
65
+ this.clear();
66
+ for (const [key, event] of Object.entries(events)) this.events.set(key, event);
67
+ }
68
+ /**
62
69
  * Reload and re-scan the entrypoint directory for events
63
70
  * @returns Promise resolving to the updated events tree
64
71
  */
@@ -71,6 +78,7 @@ var EventsRouter = class {
71
78
  * @returns Promise resolving to the events tree
72
79
  */
73
80
  async scan() {
81
+ this.clear();
74
82
  for (const entrypoint of this.entrypoints) {
75
83
  const dirs = await (0, node_fs_promises.readdir)(entrypoint, { withFileTypes: true });
76
84
  for (const dir of dirs) if (dir.isDirectory()) {
@@ -81,6 +89,33 @@ var EventsRouter = class {
81
89
  return Object.fromEntries(this.events);
82
90
  }
83
91
  /**
92
+ * Incrementally rescans only the event subtree impacted by a changed path.
93
+ */
94
+ async scanIncremental(changedPath, _changeType = "change") {
95
+ const resolvedChangedPath = (0, node_path.normalize)(changedPath);
96
+ const entrypoint = this.entrypoints.find((root) => this.isWithinPath(root, resolvedChangedPath));
97
+ if (!entrypoint) return this.toJSON();
98
+ const branch = this.resolveTopLevelBranch(entrypoint, resolvedChangedPath);
99
+ if (!branch) return this.scan();
100
+ const normalizedBranch = (0, node_path.normalize)(branch);
101
+ for (const [key, event] of this.events.entries()) {
102
+ const listeners = event.listeners.filter((listener) => !this.isWithinPath(normalizedBranch, listener));
103
+ if (!listeners.length && this.isWithinPath(normalizedBranch, event.path)) {
104
+ this.events.delete(key);
105
+ continue;
106
+ }
107
+ this.events.set(key, {
108
+ ...event,
109
+ listeners
110
+ });
111
+ }
112
+ if ((0, node_fs.existsSync)(normalizedBranch)) {
113
+ const branchName = branch.slice(entrypoint.length).replace(/^[/\\]/, "").split(/[/\\]/).filter(Boolean)[0];
114
+ if (branchName) await this.scanEvent(branchName, normalizedBranch, null, [], true);
115
+ }
116
+ return this.toJSON();
117
+ }
118
+ /**
84
119
  * Convert the internal events Collection to a plain object
85
120
  * @returns Events tree as a plain object
86
121
  */
@@ -111,7 +146,7 @@ var EventsRouter = class {
111
146
  if (!isNamespace) {
112
147
  const existing = this.events.get(event);
113
148
  if (existing) {
114
- existing.listeners = Array.from(new Set([...existing.listeners, ...listeners]));
149
+ existing.listeners = Array.from(/* @__PURE__ */ new Set([...existing.listeners, ...listeners]));
115
150
  return;
116
151
  }
117
152
  this.events.set(event, {
@@ -122,6 +157,24 @@ var EventsRouter = class {
122
157
  });
123
158
  }
124
159
  }
160
+ /**
161
+ * @private
162
+ * @internal
163
+ */
164
+ isWithinPath(basePath, targetPath) {
165
+ const rel = (0, node_path.relative)((0, node_path.normalize)(basePath), (0, node_path.normalize)(targetPath));
166
+ if (!rel) return true;
167
+ return !rel.startsWith("..") && !(0, node_path.isAbsolute)(rel);
168
+ }
169
+ /**
170
+ * @private
171
+ * @internal
172
+ */
173
+ resolveTopLevelBranch(entrypoint, changedPath) {
174
+ const rel = (0, node_path.relative)(entrypoint, changedPath).split(/[/\\]/).filter(Boolean);
175
+ if (!rel.length) return null;
176
+ return (0, node_path.join)(entrypoint, rel[0]);
177
+ }
125
178
  };
126
179
 
127
180
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"EventsRouter.js","names":[],"sources":["../../../src/app/router/EventsRouter.ts"],"sourcesContent":["import { Collection } from 'discord.js';\nimport { existsSync } from 'node:fs';\nimport { readdir } from 'node:fs/promises';\nimport { join } from 'node:path';\n\n/**\n * Configuration options for the EventsRouter\n * @interface EventsRouterOptions\n */\nexport interface EventsRouterOptions {\n /** Root directory path where event handlers are located */\n entrypoints: string[];\n}\n\n/**\n * Represents a parsed event with its handlers\n * @interface ParsedEvent\n */\nexport interface ParsedEvent {\n /** Name of the event derived from directory name */\n event: string;\n /** Absolute path to the event directory */\n path: string;\n /** Array of file paths to event listener handlers */\n listeners: string[];\n /** Namespace of the event */\n namespace: string | null;\n}\n\n/** Collection of event names to their parsed metadata */\nexport type EventsTree = Record<string, ParsedEvent>;\n\n/**\n * Router for discovering and managing event handler files in a directory structure.\n * Events are represented by directories, and handlers are files within those directories.\n */\nexport class EventsRouter {\n /** Internal storage of parsed events */\n private events = new Collection<string, ParsedEvent>();\n\n /**\n * Creates a new EventsRouter instance\n * @param options - Configuration options for the router\n * @throws Error if entrypoint is not provided\n */\n public constructor(private options: EventsRouterOptions) {\n if (options.entrypoints) {\n options.entrypoints = Array.from(new Set(options.entrypoints));\n }\n\n if (!options.entrypoints?.length) {\n throw new Error('Entrypoint directory must be provided');\n }\n }\n\n /**\n * Adds new entrypoints to the router\n * @param entrypoints - Array of new entrypoint paths\n */\n public addEntrypoints(entrypoints: string[]) {\n this.options.entrypoints = Array.from(\n new Set([...this.options.entrypoints, ...entrypoints]),\n );\n }\n\n /**\n * Find a parsed event by its name\n * @param event - Name of the event to find\n * @returns Parsed event metadata or null if not found\n */\n public match(event: string): ParsedEvent | null {\n return this.events.get(event) ?? null;\n }\n\n /**\n * Get the entrypoint directory path\n * @returns Entrypoint directory path\n */\n public get entrypoints(): string[] {\n return this.options.entrypoints;\n }\n\n /**\n * Checks if the entrypoint path is valid\n */\n public isValidPath() {\n return this.entrypoints.every((entrypoint) => existsSync(entrypoint));\n }\n\n /**\n * Clear all parsed events\n */\n public clear() {\n this.events.clear();\n }\n\n /**\n * Reload and re-scan the entrypoint directory for events\n * @returns Promise resolving to the updated events tree\n */\n public async reload() {\n this.clear();\n return this.scan();\n }\n\n /**\n * Scan the entrypoint directory for events and their handlers\n * @returns Promise resolving to the events tree\n */\n public async scan(): Promise<EventsTree> {\n for (const entrypoint of this.entrypoints) {\n const dirs = await readdir(entrypoint, { withFileTypes: true });\n\n for (const dir of dirs) {\n if (dir.isDirectory()) {\n const path = join(entrypoint, dir.name);\n await this.scanEvent(dir.name, path, null, [], true);\n }\n }\n }\n\n return Object.fromEntries(this.events);\n }\n\n /**\n * Convert the internal events Collection to a plain object\n * @returns Events tree as a plain object\n */\n public toJSON(): EventsTree {\n return Object.fromEntries(this.events);\n }\n\n /**\n * Recursively scan a directory for event handlers\n * @param event - Name of the event\n * @param path - Path to the event directory\n * @param listeners - Array to collect listener file paths\n * @returns Promise resolving to the parsed event metadata\n */\n private async scanEvent(\n event: string,\n path: string,\n _namespace: string | null = null,\n listeners: string[] = [],\n isRoot = false,\n ): Promise<void> {\n const files = await readdir(path, { withFileTypes: true });\n const isNamespace = isRoot && /^\\(.+\\)$/.test(event);\n\n // if event = (something) pattern then namespace is something\n const namespace = isNamespace ? event.slice(1, -1) : (_namespace ?? null);\n\n files.sort((a, b) => a.name.localeCompare(b.name));\n\n for (const file of files) {\n if (file.name.startsWith('_')) continue;\n\n if (file.isDirectory()) {\n const nextPath = join(path, file.name);\n await this.scanEvent(file.name, nextPath, namespace, listeners);\n continue;\n }\n\n if (file.isFile() && /\\.(m|c)?(j|t)sx?$/.test(file.name)) {\n listeners.push(join(file.parentPath, file.name));\n }\n }\n\n if (!isNamespace) {\n const existing = this.events.get(event);\n\n if (existing) {\n existing.listeners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UACd,OACA,MACA,aAA4B,MAC5B,YAAsB,EAAE,EACxB,SAAS,OACO;EACd,MAAM,QAAQ,oCAAc,MAAM,EAAE,eAAe,MAAM,CAAC;EAC1D,MAAM,cAAc,UAAU,WAAW,KAAK,MAAM;EAGpD,MAAM,YAAY,cAAc,MAAM,MAAM,GAAG,GAAG,GAAG,cAAc;AAEnE,QAAM,MAAM,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,KAAK,CAAC;AAElD,OAAK,MAAM,QAAQ,OAAO;AACxB,OAAI,KAAK,KAAK,WAAW,IAAI,CAAE;AAE/B,OAAI,KAAK,aAAa,EAAE;IACtB,MAAM,+BAAgB,MAAM,KAAK,KAAK;AACtC,UAAM,KAAK,UAAU,KAAK,MAAM,UAAU,WAAW,UAAU;AAC/D;;AAGF,OAAI,KAAK,QAAQ,IAAI,oBAAoB,KAAK,KAAK,KAAK,CACtD,WAAU,yBAAU,KAAK,YAAY,KAAK,KAAK,CAAC;;AAIpD,MAAI,CAAC,aAAa;GAChB,MAAM,WAAW,KAAK,OAAO,IAAI,MAAM;AAEvC,OAAI,UAAU;AACZ,aAAS,YAAY,MAAM,KACzB,IAAI,IAAI,CAAC,GAAG,SAAS,WAAW,GAAG,UAAU,CAAC,CAC/C;AAED;;AAGF,QAAK,OAAO,IAAI,OAAO;IAAE;IAAO;IAAM;IAAW;IAAW,CAAC"}
1
+ {"version":3,"file":"EventsRouter.js","names":[],"sources":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import { a as createRouterTreeArtifact, i as RouterTreeArtifact, n as ROUTER_TREE_ARTIFACT_FILE, o as hydrateRouterTreeArtifact, r as ROUTER_TREE_ARTIFACT_SCHEMA_VERSION, s as validateRouterTreeArtifact, t as ROUTER_TREE_ARTIFACT_DIRECTORY } from "../../TreeArtifact-D6FZ5SVd.js";
2
+ export { ROUTER_TREE_ARTIFACT_DIRECTORY, ROUTER_TREE_ARTIFACT_FILE, ROUTER_TREE_ARTIFACT_SCHEMA_VERSION, RouterTreeArtifact, createRouterTreeArtifact, hydrateRouterTreeArtifact, validateRouterTreeArtifact };
@@ -0,0 +1,87 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ let node_path = require("node:path");
3
+
4
+ //#region src/app/router/TreeArtifact.ts
5
+ const ROUTER_TREE_ARTIFACT_SCHEMA_VERSION = 1;
6
+ const ROUTER_TREE_ARTIFACT_FILE = "router-tree.json";
7
+ const ROUTER_TREE_ARTIFACT_DIRECTORY = ".commandkit";
8
+ function createRouterTreeArtifact(options) {
9
+ const { outputRoot, commandkitVersion } = options;
10
+ return {
11
+ schemaVersion: 1,
12
+ commandkitVersion,
13
+ generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
14
+ commands: mapCommandDataPaths(options.commands, outputRoot, toRelativePath),
15
+ events: mapEventsTreePaths(options.events, outputRoot, toRelativePath)
16
+ };
17
+ }
18
+ function validateRouterTreeArtifact(input, runtimeVersion) {
19
+ if (!input || typeof input !== "object") return false;
20
+ const artifact = input;
21
+ if (artifact.schemaVersion !== 1) return false;
22
+ if (!artifact.commandkitVersion || artifact.commandkitVersion !== runtimeVersion) return false;
23
+ if (!artifact.commands || typeof artifact.commands !== "object") return false;
24
+ if (!artifact.events || typeof artifact.events !== "object") return false;
25
+ return true;
26
+ }
27
+ function hydrateRouterTreeArtifact(artifact, outputRoot) {
28
+ return {
29
+ commands: mapCommandDataPaths(artifact.commands, outputRoot, toAbsolutePath),
30
+ events: mapEventsTreePaths(artifact.events, outputRoot, toAbsolutePath)
31
+ };
32
+ }
33
+ function mapCommandDataPaths(data, root, mapper) {
34
+ return {
35
+ commands: Object.fromEntries(Object.entries(data.commands ?? {}).map(([id, command]) => [id, {
36
+ ...command,
37
+ path: mapper(root, command.path),
38
+ parentPath: mapper(root, command.parentPath)
39
+ }])),
40
+ middlewares: Object.fromEntries(Object.entries(data.middlewares ?? {}).map(([id, middleware]) => [id, {
41
+ ...middleware,
42
+ path: mapper(root, middleware.path),
43
+ parentPath: mapper(root, middleware.parentPath)
44
+ }])),
45
+ treeNodes: Object.fromEntries(Object.entries(data.treeNodes ?? {}).map(([id, node]) => [id, {
46
+ ...node,
47
+ directoryPath: mapper(root, node.directoryPath),
48
+ definitionPath: node.definitionPath === null ? null : mapper(root, node.definitionPath)
49
+ }])),
50
+ compiledRoutes: Object.fromEntries(Object.entries(data.compiledRoutes ?? {}).map(([id, route]) => [id, {
51
+ ...route,
52
+ definitionPath: mapper(root, route.definitionPath)
53
+ }])),
54
+ diagnostics: (data.diagnostics ?? []).map((diagnostic) => ({
55
+ ...diagnostic,
56
+ path: mapper(root, diagnostic.path)
57
+ }))
58
+ };
59
+ }
60
+ function mapEventsTreePaths(events, root, mapper) {
61
+ return Object.fromEntries(Object.entries(events ?? {}).map(([id, event]) => [id, {
62
+ ...event,
63
+ path: mapper(root, event.path),
64
+ listeners: event.listeners.map((listener) => mapper(root, listener))
65
+ }]));
66
+ }
67
+ function toRelativePath(rootPath, path) {
68
+ if (!path) return path;
69
+ const normalizedPath = (0, node_path.normalize)(path);
70
+ if (!(0, node_path.isAbsolute)(normalizedPath)) return normalizedPath;
71
+ return (0, node_path.normalize)((0, node_path.relative)(rootPath, normalizedPath));
72
+ }
73
+ function toAbsolutePath(rootPath, path) {
74
+ if (!path) return path;
75
+ const normalizedPath = (0, node_path.normalize)(path);
76
+ if ((0, node_path.isAbsolute)(normalizedPath)) return normalizedPath;
77
+ return (0, node_path.normalize)((0, node_path.join)(rootPath, normalizedPath));
78
+ }
79
+
80
+ //#endregion
81
+ exports.ROUTER_TREE_ARTIFACT_DIRECTORY = ROUTER_TREE_ARTIFACT_DIRECTORY;
82
+ exports.ROUTER_TREE_ARTIFACT_FILE = ROUTER_TREE_ARTIFACT_FILE;
83
+ exports.ROUTER_TREE_ARTIFACT_SCHEMA_VERSION = ROUTER_TREE_ARTIFACT_SCHEMA_VERSION;
84
+ exports.createRouterTreeArtifact = createRouterTreeArtifact;
85
+ exports.hydrateRouterTreeArtifact = hydrateRouterTreeArtifact;
86
+ exports.validateRouterTreeArtifact = validateRouterTreeArtifact;
87
+ //# sourceMappingURL=TreeArtifact.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TreeArtifact.js","names":[],"sources":[],"mappings":""}
@@ -1,3 +1,6 @@
1
- import { a as ParsedCommandData, i as Middleware, n as CommandsRouter, r as CommandsRouterOptions, t as Command } from "../../CommandsRouter-DiNoF0dq.js";
2
- import { i as ParsedEvent, n as EventsRouterOptions, r as EventsTree, t as EventsRouter } from "../../EventsRouter-EuuSu6NH.js";
3
- export { Command, CommandsRouter, CommandsRouterOptions, EventsRouter, EventsRouterOptions, EventsTree, Middleware, ParsedCommandData, ParsedEvent };
1
+ import { a as CompiledCommandRoute, i as CommandTreeNodeSource, n as CommandTreeNode, r as CommandTreeNodeKind, t as CommandRouteDiagnostic } from "../../CommandTree-qu-8oAEV.js";
2
+ import { a as ParsedCommandData, i as Middleware, n as CommandsRouter, o as RouterFileChangeType, r as CommandsRouterOptions, t as Command } from "../../CommandsRouter-Co225Ae5.js";
3
+ import { a as ParsedEvent, i as EventsTree, n as EventsRouterFileChangeType, r as EventsRouterOptions, t as EventsRouter } from "../../EventsRouter-Bt63ZuEF.js";
4
+ import { a as createRouterTreeArtifact, i as RouterTreeArtifact, n as ROUTER_TREE_ARTIFACT_FILE, o as hydrateRouterTreeArtifact, r as ROUTER_TREE_ARTIFACT_SCHEMA_VERSION, s as validateRouterTreeArtifact, t as ROUTER_TREE_ARTIFACT_DIRECTORY } from "../../TreeArtifact-D6FZ5SVd.js";
5
+ import "../../index-COt7nfC9.js";
6
+ export { Command, CommandRouteDiagnostic, CommandTreeNode, CommandTreeNodeKind, CommandTreeNodeSource, CommandsRouter, CommandsRouterOptions, CompiledCommandRoute, EventsRouter, EventsRouterFileChangeType, EventsRouterOptions, EventsTree, Middleware, ParsedCommandData, ParsedEvent, ROUTER_TREE_ARTIFACT_DIRECTORY, ROUTER_TREE_ARTIFACT_FILE, ROUTER_TREE_ARTIFACT_SCHEMA_VERSION, RouterFileChangeType, RouterTreeArtifact, createRouterTreeArtifact, hydrateRouterTreeArtifact, validateRouterTreeArtifact };
@@ -1,6 +1,13 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_app_router_CommandsRouter = require('./CommandsRouter.js');
3
3
  const require_app_router_EventsRouter = require('./EventsRouter.js');
4
+ const require_app_router_TreeArtifact = require('./TreeArtifact.js');
4
5
 
5
6
  exports.CommandsRouter = require_app_router_CommandsRouter.CommandsRouter;
6
- exports.EventsRouter = require_app_router_EventsRouter.EventsRouter;
7
+ exports.EventsRouter = require_app_router_EventsRouter.EventsRouter;
8
+ exports.ROUTER_TREE_ARTIFACT_DIRECTORY = require_app_router_TreeArtifact.ROUTER_TREE_ARTIFACT_DIRECTORY;
9
+ exports.ROUTER_TREE_ARTIFACT_FILE = require_app_router_TreeArtifact.ROUTER_TREE_ARTIFACT_FILE;
10
+ exports.ROUTER_TREE_ARTIFACT_SCHEMA_VERSION = require_app_router_TreeArtifact.ROUTER_TREE_ARTIFACT_SCHEMA_VERSION;
11
+ exports.createRouterTreeArtifact = require_app_router_TreeArtifact.createRouterTreeArtifact;
12
+ exports.hydrateRouterTreeArtifact = require_app_router_TreeArtifact.hydrateRouterTreeArtifact;
13
+ exports.validateRouterTreeArtifact = require_app_router_TreeArtifact.validateRouterTreeArtifact;
@@ -0,0 +1,27 @@
1
+ import { t as MaybeArray } from "./types-ur7SvktF.js";
2
+ import { CheckboxBuilder, CheckboxComponentData, CheckboxGroupBuilder, CheckboxGroupComponentData, CheckboxGroupOptionBuilder } from "discord.js";
3
+ //#region src/components/interactive/checkbox/checkbox.d.ts
4
+ interface CheckboxProps extends Omit<CheckboxComponentData, 'type' | 'required'> {
5
+ id?: number;
6
+ default?: boolean;
7
+ }
8
+ declare function Checkbox(props: CheckboxProps): CheckboxBuilder;
9
+ interface CheckboxGroupOptionProps {
10
+ label: string;
11
+ value: string;
12
+ description?: string;
13
+ default?: boolean;
14
+ }
15
+ declare function CheckboxGroupOption(props: CheckboxGroupOptionProps): CheckboxGroupOptionBuilder;
16
+ interface CheckboxGroupProps extends Omit<CheckboxGroupComponentData, 'type' | 'options'> {
17
+ id?: number;
18
+ customId: string;
19
+ children?: MaybeArray<CheckboxGroupOptionBuilder>;
20
+ minValues?: number;
21
+ maxValues?: number;
22
+ required?: boolean;
23
+ }
24
+ declare function CheckboxGroup(props: CheckboxGroupProps): CheckboxGroupBuilder;
25
+ //#endregion
26
+ export { CheckboxGroupProps as a, CheckboxGroupOptionProps as i, CheckboxGroup as n, CheckboxProps as o, CheckboxGroupOption as r, Checkbox as t };
27
+ //# sourceMappingURL=checkbox-DoR0Pcxm.d.ts.map
@@ -1,11 +1,10 @@
1
- import * as node_child_process0 from "node:child_process";
2
-
1
+ import { m as ResolvedCommandKitConfig } from "../analytics-engine-Bz1p7ud3.js";
3
2
  //#region src/cli/app-process.d.ts
4
3
  /**
5
4
  * @private
6
5
  * @internal
7
6
  */
8
- declare function createAppProcess(fileName: string, cwd: string, isDev: boolean): node_child_process0.ChildProcess;
7
+ declare function createAppProcess(fileName: string, cwd: string, isDev: boolean, config: ResolvedCommandKitConfig): import("node:child_process").ChildProcess;
9
8
  //#endregion
10
9
  export { createAppProcess };
11
10
  //# sourceMappingURL=app-process.d.ts.map
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_chunk = require('../chunk-BE-pF4vm.js');
3
2
  const require_cli_common = require('./common.js');
4
3
  const require_cli_env = require('./env.js');
5
4
  let node_fs = require("node:fs");
@@ -24,15 +23,27 @@ function getStdio(supportsCommands) {
24
23
  "pipe"
25
24
  ];
26
25
  }
26
+ const RuntimeLookup = [["bun", () => typeof Bun !== "undefined" && typeof Bun.version === "string"], ["deno", () => typeof Deno !== "undefined" && typeof Deno.version === "object" && typeof Deno.version.deno === "string"]];
27
+ function resolveRuntime(config) {
28
+ var _config$experimental;
29
+ const maybeRuntime = config === null || config === void 0 || (_config$experimental = config.experimental) === null || _config$experimental === void 0 ? void 0 : _config$experimental.devServerRuntime;
30
+ if (!maybeRuntime) return "node";
31
+ if (maybeRuntime === "auto") {
32
+ for (const [runtime, check] of RuntimeLookup) if (check()) return runtime;
33
+ return "node";
34
+ }
35
+ return maybeRuntime;
36
+ }
27
37
  /**
28
38
  * @private
29
39
  * @internal
30
40
  */
31
- function createAppProcess(fileName, cwd, isDev) {
41
+ function createAppProcess(fileName, cwd, isDev, config) {
32
42
  var _ps$stdout, _ps$stderr;
33
43
  if (!(0, node_fs.existsSync)((0, node_path.join)(cwd, fileName))) require_cli_common.panic(`Could not locate the entrypoint file: ${fileName}`);
34
44
  const stdio = getStdio(isDev);
35
- const baseArgs = [`--title="CommandKit ${isDev ? "Development" : "Production"}"`, "--enable-source-maps"];
45
+ const targetRuntime = resolveRuntime(config);
46
+ const baseArgs = targetRuntime === "node" ? [`--title="CommandKit ${isDev ? "Development" : "Production"}"`, "--enable-source-maps"] : [];
36
47
  const nodeOptions = process.env.CK_NODE_OPTIONS || process.env.NODE_OPTIONS;
37
48
  let nodeArgs = [...baseArgs];
38
49
  if (nodeOptions) {
@@ -45,7 +56,7 @@ function createAppProcess(fileName, cwd, isDev) {
45
56
  }
46
57
  }
47
58
  nodeArgs.push(fileName);
48
- const ps = (0, node_child_process.spawn)("node", nodeArgs, {
59
+ const ps = (0, node_child_process.spawn)(targetRuntime, nodeArgs, {
49
60
  cwd,
50
61
  windowsHide: true,
51
62
  env: isDev ? require_cli_env.DevEnv() : require_cli_env.ProdEnv(),
@@ -1 +1 @@
1
- {"version":3,"file":"app-process.js","names":[],"sources":["../../src/cli/app-process.ts"],"sourcesContent":["import { IOType, spawn } from 'node:child_process';\nimport { DevEnv, ProdEnv } from './env';\nimport { join } from 'node:path';\nimport { existsSync } from 'node:fs';\nimport { panic } from './common';\n\n/**\n * @private\n * @internal\n */\nfunction getStdio(supportsCommands: boolean) {\n if (supportsCommands) {\n return ['pipe', 'pipe', 'pipe', 'ipc'];\n }\n\n return ['pipe', 'pipe', 'pipe'];\n}\n\n/**\n * @private\n * @internal\n */\nexport function createAppProcess(\n fileName: string,\n cwd: string,\n isDev: boolean,\n) {\n if (!existsSync(join(cwd, fileName))) {\n panic(`Could not locate the entrypoint file: ${fileName}`);\n }\n\n const stdio = getStdio(isDev) as IOType[];\n\n const baseArgs = [\n `--title=\"CommandKit ${isDev ? 'Development' : 'Production'}\"`,\n '--enable-source-maps',\n ];\n\n const nodeOptions = process.env.CK_NODE_OPTIONS || process.env.NODE_OPTIONS;\n let nodeArgs = [...baseArgs];\n\n if (nodeOptions) {\n const options = nodeOptions.trim().split(/\\s+/);\n\n for (const option of options) {\n const optionName = option.split('=')[0];\n const existingIndex = nodeArgs.findIndex((arg) =>\n arg.startsWith(optionName),\n );\n\n if (existingIndex !== -1) {\n nodeArgs[existingIndex] = option;\n } else {\n nodeArgs.push(option);\n }\n }\n }\n\n nodeArgs.push(fileName);\n\n const ps = spawn('node', nodeArgs, {\n cwd,\n windowsHide: true,\n env: isDev ? DevEnv() : ProdEnv(),\n stdio,\n });\n\n ps.stdout?.pipe(process.stdout);\n ps.stderr?.pipe(process.stderr);\n\n return ps;\n}\n"],"mappings":";;;;;;;;;;;;;AAUA,SAAS,SAAS,kBAA2B;AAC3C,KAAI,iBACF,QAAO;EAAC;EAAQ;EAAQ;EAAQ;EAAM;AAGxC,QAAO;EAAC;EAAQ;EAAQ;EAAO;;;;;;AAOjC,SAAgB,iBAChB,UACA,KACA,OACA;;AACE,KAAI,6CAAiB,KAAK,SAAS,CAAC,CAClC,0BAAM,yCAAyC,WAAW;CAG5D,MAAM,QAAQ,SAAS,MAAM;CAE7B,MAAM,WAAW,CACjB,uBAAuB,QAAQ,gBAAgB,aAAa,IAC5D,uBAAuB;CAGvB,MAAM,cAAc,QAAQ,IAAI,mBAAmB,QAAQ,IAAI;CAC/D,IAAI,WAAW,CAAC,GAAG,SAAS;AAE5B,KAAI,aAAa;EACf,MAAM,UAAU,YAAY,MAAM,CAAC,MAAM,MAAM;AAE/C,OAAK,MAAM,UAAU,SAAS;GAC5B,MAAM,aAAa,OAAO,MAAM,IAAI,CAAC;GACrC,MAAM,gBAAgB,SAAS,WAAW,QAC1C,IAAE,WAAI,WAAW,CAChB;AAED,OAAI,kBAAkB,GACpB,UAAS,iBAAiB;OAE1B,UAAS,KAAK,OAAO;;;AAK3B,UAAS,KAAK,SAAS;CAEvB,MAAM,mCAAW,QAAQ,UAAU;EACjC;EACA,aAAa;EACb,KAAK,QAAQ,wBAAQ,GAAG,yBAAS;EACjC;EACD,CAAC;AAEF,kBAAG,wDAAQ,KAAK,QAAQ,OAAO;AAC/B,kBAAG,wDAAQ,KAAK,QAAQ,OAAO;AAE/B,QAAO"}
1
+ {"version":3,"file":"app-process.js","names":[],"sources":[],"mappings":""}
@@ -1,6 +1,6 @@
1
- import { W as CompilerPlugin } from "../analytics-engine-DnRsHBId.js";
2
- import { t as MaybeArray } from "../types-DZy7U-Ld.js";
3
-
1
+ import { G as CompilerPlugin } from "../analytics-engine-Bz1p7ud3.js";
2
+ import { t as MaybeArray } from "../types-ur7SvktF.js";
3
+ import "../index-DvqHpiuh.js";
4
4
  //#region src/cli/build.d.ts
5
5
  /**
6
6
  * @private
@@ -16,12 +16,7 @@ interface ApplicationBuildOptions {
16
16
  * @private
17
17
  * @internal
18
18
  */
19
- declare function buildApplication({
20
- plugins,
21
- rolldownPlugins,
22
- isDev,
23
- configPath
24
- }: ApplicationBuildOptions): Promise<void>;
19
+ declare function buildApplication({ plugins, rolldownPlugins, isDev, configPath }: ApplicationBuildOptions): Promise<void>;
25
20
  //#endregion
26
21
  export { ApplicationBuildOptions, buildApplication };
27
22
  //# sourceMappingURL=build.d.ts.map
package/dist/cli/build.js CHANGED
@@ -1,8 +1,12 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_chunk = require('../chunk-BE-pF4vm.js');
3
- const require_commandkit = require('../commandkit-Bh7C1_c7.js');
2
+ const require_commandkit = require('../commandkit-DNbfLwyR.js');
4
3
  const require_utils_constants = require('../utils/constants.js');
5
4
  const require_config_utils = require('../config/utils.js');
5
+ const require_app_router_CommandsRouter = require('../app/router/CommandsRouter.js');
6
+ const require_app_router_EventsRouter = require('../app/router/EventsRouter.js');
7
+ const require_app_router_TreeArtifact = require('../app/router/TreeArtifact.js');
8
+ require('../app/router/index.js');
9
+ const require_version = require('../version.js');
6
10
  const require_cli_common = require('./common.js');
7
11
  const require_cli_env = require('./env.js');
8
12
  const require_cli_type_checker = require('./type-checker.js');
@@ -87,12 +91,12 @@ async function buildApplication({ plugins, rolldownPlugins, isDev, configPath })
87
91
  },
88
92
  plugins: rolldownPlugins,
89
93
  platform: "node",
90
- skipNodeModulesBundle: true,
94
+ deps: { skipNodeModulesBundle: true },
91
95
  sourcemap: ((_config$sourceMap = config.sourceMap) === null || _config$sourceMap === void 0 ? void 0 : _config$sourceMap[isDev ? "development" : "production"]) ?? true,
92
96
  target: "node16",
93
97
  outDir: dest,
94
98
  env: mergeDefinitionsIfNeeded(config.env || {}, !!isDev),
95
- entry: Array.from(new Set([
99
+ entry: Array.from(/* @__PURE__ */ new Set([
96
100
  "src/**/*.{js,cjs,mjs,ts,cts,mts,jsx,tsx}",
97
101
  `!${config.distDir}`,
98
102
  "!.commandkit",
@@ -105,6 +109,7 @@ async function buildApplication({ plugins, rolldownPlugins, isDev, configPath })
105
109
  }, (_config$compilerOptio2 = config.compilerOptions) === null || _config$compilerOptio2 === void 0 ? void 0 : _config$compilerOptio2.tsdown));
106
110
  await require_cli_common.copyLocaleFiles("src", dest);
107
111
  await injectEntryFile(configPath || require_utils_constants.COMMANDKIT_CWD, !!isDev, !!(((_config$antiCrashScri = config.antiCrashScript) === null || _config$antiCrashScri === void 0 ? void 0 : _config$antiCrashScri[isDev ? "development" : "production"]) ?? (isDev ? true : false)), config.distDir);
112
+ if (config.experimental.pregenerateCommands) await emitPregeneratedRouterArtifact((0, node_path.join)(require_utils_constants.COMMANDKIT_CWD, dest));
108
113
  } catch (error) {
109
114
  console.error("Build failed:", error);
110
115
  if (error instanceof Error) console.error("Error details:", error.stack);
@@ -113,6 +118,27 @@ async function buildApplication({ plugins, rolldownPlugins, isDev, configPath })
113
118
  await pluginRuntime.destroy();
114
119
  }
115
120
  }
121
+ async function emitPregeneratedRouterArtifact(outputRoot) {
122
+ const commandEntrypoint = (0, node_path.join)(outputRoot, "app", "commands");
123
+ const eventsEntrypoint = (0, node_path.join)(outputRoot, "app", "events");
124
+ const commandsRouter = new require_app_router_CommandsRouter.CommandsRouter({ entrypoint: commandEntrypoint });
125
+ const eventsRouter = new require_app_router_EventsRouter.EventsRouter({ entrypoints: [eventsEntrypoint] });
126
+ const artifact = require_app_router_TreeArtifact.createRouterTreeArtifact({
127
+ outputRoot,
128
+ commandkitVersion: require_version.version,
129
+ commands: commandsRouter.isValidPath() ? await commandsRouter.scan() : {
130
+ commands: {},
131
+ middlewares: {},
132
+ treeNodes: {},
133
+ compiledRoutes: {},
134
+ diagnostics: []
135
+ },
136
+ events: eventsRouter.isValidPath() ? await eventsRouter.scan() : {}
137
+ });
138
+ const artifactDirectory = (0, node_path.join)(outputRoot, require_app_router_TreeArtifact.ROUTER_TREE_ARTIFACT_DIRECTORY);
139
+ await (0, node_fs_promises.mkdir)(artifactDirectory, { recursive: true });
140
+ await (0, node_fs_promises.writeFile)((0, node_path.join)(artifactDirectory, require_app_router_TreeArtifact.ROUTER_TREE_ARTIFACT_FILE), JSON.stringify(artifact, null, 2), "utf8");
141
+ }
116
142
  const envScript = (dev) => `// --- Environment Variables Loader ---
117
143
  const $env = [${(dev ? require_cli_env.devEnvFileArgs : require_cli_env.prodEnvFileArgs).map((p) => `"${p}"`).join(", ")}];
118
144
  for (const file of $env) {
@@ -161,7 +187,9 @@ async function bootstrap() {
161
187
  }
162
188
 
163
189
  await bootstrap().catch((e) => {
164
- console.error('Failed to bootstrap CommandKit application:\\n', e.stack);
190
+ const error = new Error('Failed to bootstrap the application', { cause: e });
191
+ console.error(error);
192
+ console.error(\`Caused by \${e?.stack || e}\`);
165
193
  })
166
194
  `);
167
195
  }
@@ -1 +1 @@
1
- {"version":3,"file":"build.js","names":[],"sources":["../../src/cli/build.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { rimraf } from 'rimraf';\nimport type { InlineConfig } from 'tsdown';\n\nimport { MaybeArray } from '../components';\nimport { loadConfigFile } from '../config/loader';\nimport { mergeDeep } from '../config/utils';\nimport { CompilerPlugin, CompilerPluginRuntime } from '../plugins';\nimport { COMMANDKIT_CWD } from '../utils/constants';\nimport { copyLocaleFiles, loadTsdown } from './common';\nimport { devEnvFileArgs, prodEnvFileArgs } from './env';\nimport { performTypeCheck } from './type-checker';\n\n/**\n * @private\n * @internal\n */\nexport interface ApplicationBuildOptions {\n plugins?: MaybeArray<CompilerPlugin>[] | Array<CompilerPlugin>;\n rolldownPlugins?: any[];\n isDev?: boolean;\n configPath?: string;\n}\n\n// emit public env variables and given env variables\n/**\n * @private\n * @internal\n */\nfunction mergeDefinitionsIfNeeded(env: Record<string, string>, isDev: boolean) {\n const values = Object.fromEntries(\n Object.entries(process.env).filter(\n ([k]) => !(k in env) && k.startsWith('COMMANDKIT_PUBLIC_'),\n ),\n );\n\n return {\n ...env,\n ...values,\n ...(isDev\n ? {\n NODE_ENV: 'development',\n COMMANDKIT_BOOTSTRAP_MODE: 'development',\n COMMANDKIT_IS_DEV: 'true',\n COMMANDKIT_IS_TEST: 'false',\n }\n : {\n NODE_ENV: 'production',\n COMMANDKIT_BOOTSTRAP_MODE: 'production',\n COMMANDKIT_IS_DEV: 'false',\n COMMANDKIT_IS_TEST: 'false',\n }),\n };\n}\n\n/**\n * @private\n * @internal\n */\nexport async function buildApplication({\n plugins,\n rolldownPlugins,\n isDev,\n configPath,\n}: ApplicationBuildOptions) {\n const { build } = await loadTsdown();\n const config = await loadConfigFile(configPath);\n\n if (!isDev && !config?.typescript?.ignoreBuildErrors) {\n await performTypeCheck(configPath || COMMANDKIT_CWD);\n }\n\n const pluginRuntime = new CompilerPluginRuntime(\n (plugins || []) as CompilerPlugin[],\n !!isDev,\n );\n\n rolldownPlugins ??= [];\n\n rolldownPlugins.push(pluginRuntime.toJSON());\n\n try {\n const dest = isDev ? '.commandkit' : config.distDir;\n\n // Clean the destination directory\n await rimraf(dest);\n\n await pluginRuntime.init();\n\n await build(\n mergeDeep(\n {\n watch: false,\n dts: false,\n clean: true,\n format: ['esm'],\n shims: true,\n minify: false,\n logLevel: !!isDev ? 'silent' : 'info',\n inputOptions: {\n transform: {\n jsx: {\n runtime: 'automatic',\n importSource: 'commandkit',\n },\n },\n checks: {\n circularDependency: true,\n },\n onwarn: (warning, defaultWarn) => {\n if (warning?.message?.includes('compilerOptions.jsx')) return;\n\n return defaultWarn(warning);\n },\n onLog: (level, log, defaultLog) => {\n if (isDev) return;\n\n return defaultLog(level, log);\n },\n moduleTypes: {\n '.json': 'json',\n '.node': 'binary',\n },\n },\n outExtensions: (context) => {\n return {\n dts: '.d.ts',\n js: context.format === 'cjs' ? '.cjs' : '.js',\n };\n },\n plugins: rolldownPlugins,\n platform: 'node',\n skipNodeModulesBundle: true,\n sourcemap:\n config.sourceMap?.[isDev ? 'development' : 'production'] ?? true,\n target: 'node16',\n outDir: dest,\n env: mergeDefinitionsIfNeeded(config.env || {}, !!isDev),\n entry: Array.from(\n new Set([\n 'src/**/*.{js,cjs,mjs,ts,cts,mts,jsx,tsx}',\n `!${config.distDir}`,\n '!.commandkit',\n '!**/*.test.*',\n '!**/*.spec.*',\n ...(config.entrypoints ?? []),\n ]),\n ),\n outputOptions: {\n sanitizeFileName: (name) => name.replace(/\\0/g, ''),\n },\n unbundle: isDev\n ? true\n : (config.compilerOptions?.disableChunking ?? false),\n } satisfies InlineConfig,\n config.compilerOptions?.tsdown,\n ),\n );\n\n await copyLocaleFiles('src', dest);\n await injectEntryFile(\n configPath || COMMANDKIT_CWD,\n !!isDev,\n !!(\n config.antiCrashScript?.[isDev ? 'development' : 'production'] ??\n (isDev ? true : false)\n ),\n config.distDir,\n );\n } catch (error) {\n console.error('Build failed:', error);\n if (error instanceof Error) {\n console.error('Error details:', error.stack);\n }\n process.exit(1); // Force exit on error\n } finally {\n // Ensure plugins are cleaned up\n await pluginRuntime.destroy();\n }\n}\n\nconst envScript = (dev: boolean) => `// --- Environment Variables Loader ---\nconst $env = [${(dev ? devEnvFileArgs : prodEnvFileArgs).map((p) => `\"${p}\"`).join(', ')}];\nfor (const file of $env) {\n try {\n process.loadEnvFile(file);\n console.log('\\\\x1b[36m✔ Loaded \\\\x1b[0m\\\\x1b[33m%s\\\\x1b[0m', file);\n } catch {}\n}\n`;\n\nconst antiCrashScript = [\n '// --- CommandKit Anti-Crash Monitor ---',\n \" // 'uncaughtException' event is supposed to be used to perform synchronous cleanup before shutting down the process\",\n ' // instead of using it as a means to resume operation.',\n ' // But it exists here due to compatibility reasons with discord bot ecosystem.',\n \" const p = (t) => `\\\\x1b[31m${t}\\\\x1b[0m`, b = '[CommandKit Anti-Crash Monitor]', l = console.log, e1 = 'uncaughtException', e2 = 'unhandledRejection';\",\n ' if (!process.eventNames().includes(e1)) // skip if it is already handled',\n ' process.on(e1, (e) => {',\n ' l(p(`${b} Uncaught Exception`)); l(p(b), p(e.stack || e));',\n ' })',\n ' if (!process.eventNames().includes(e2)) // skip if it is already handled',\n ' process.on(e2, (r) => {',\n ' l(p(`${b} Unhandled promise rejection`)); l(p(`${b} ${r.stack || r}`));',\n ' });',\n '// --- CommandKit Anti-Crash Monitor ---',\n].join('\\n');\n\nconst wrapInAsyncIIFE = (code: string[]) =>\n `;await (async () => {\\n${code.join('\\n\\n')}\\n})();`;\n\nasync function injectEntryFile(\n configPath: string,\n isDev: boolean,\n emitAntiCrashScript: boolean,\n distDir?: string,\n) {\n const dist = isDev ? '.commandkit' : distDir || 'dist';\n const entryFilePath = join(configPath, dist, 'index.js');\n\n // skip if the entry file already exists\n if (existsSync(entryFilePath)) return;\n\n const code = `/* Entrypoint File Generated By CommandKit */\n${isDev ? `\\n\\n// Injected for development\\n${wrapInAsyncIIFE([envScript(isDev), emitAntiCrashScript ? antiCrashScript : ''])}\\n\\n` : wrapInAsyncIIFE([envScript(isDev)])}\n\n\nasync function bootstrap() {\n const { Client } = await import('discord.js');\n const { commandkit } = await import('commandkit');\n const app = await import('./app.js').then((m) => m.default ?? m);\n\n if (!app || !(app instanceof Client)) {\n throw new Error('The app file must default export the discord.js client instance');\n }\n\n commandkit.setClient(app);\n\n await commandkit.start();\n}\n\nawait bootstrap().catch((e) => {\n console.error('Failed to bootstrap CommandKit application:\\\\n', e.stack);\n})\n`;\n\n await writeFile(entryFilePath, code);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA+BA,SAAS,yBAAyB,KAA6B,OAAgB;CAC7E,MAAM,SAAS,OAAO,YACpB,OAAO,QAAQ,QAAQ,IAAI,CAAC,QACzB,CAAC,OAAO,EAAE,KAAK,QAAQ,EAAE,WAAW,qBAAqB,CAC3D,CACF;AAED,QAAO;EACL,GAAG;EACH,GAAG;EACH,GAAI,QACJ;GACE,UAAI;GACJ,2BAAI;GACJ,mBAAI;GACJ,oBAAI;GACL,GACD;GACE,UAAI;GACJ,2BAAI;GACJ,mBAAI;GACJ,oBAAI;GACL;EACF;;;;;;AAOH,eAAsB,iBAAiB,EACrC,SACA,iBACA,OACA,cAC0B;;CAC1B,MAAM,EAAE,UAAU,MAAM,+BAAY;CACpC,MAAM,SAAS,MAAM,kCAAe,WAAW;AAE/C,KAAI,CAAC,SAAS,gEAAC,OAAQ,oFAAY,mBACjC,OAAM,0CAAiB,cAAc,uCAAe;CAGtD,MAAM,gBAAgB,IAAI,yCACvB,WAAW,EAAE,EACd,CAAC,CAAC,MACH;AAED,qBAAoB,EAAE;AAEtB,iBAAgB,KAAK,cAAc,QAAQ,CAAC;AAE5C,KAAI;;EACF,MAAM,OAAO,QAAQ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,MAAM,iBAAiB,MAAM;AACrC,MAAI,iBAAiB,MACnB,SAAQ,MAAM,kBAAkB,MAAM,MAAM;AAE9C,UAAQ,KAAK,EAAE;WACP;AAER,QAAM,cAAc,SAAS;;;AAIjC,MAAM,aAAa,QAAiB;iBACnB,MAAM,iCAAiB,iCAAiB,KAAK,MAAM,IAAI,EAAE,GAAG,CAAC,KAAK,KAAK,CAAC;;;;;;;;AASzF,MAAM,kBAAkB;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAA2C,CAC3C,KAAE,KAAQ;AAEV,MAAM,mBAAmB,SACzB,0BAA0B,KAAE,KAAK,OAAU,CAAC;AAE5C,eAAe,gBACf,YACA,OACA,qBACA,SACA;CAEE,MAAM,oCAAqB,YADd,QAAQ,gBAAgB,WAAW,QACH,WAAW;AAGxD,6BAAe,cAAc,CAAE;AAyB/B,uCAAgB,eAvBH;EACb,QAAQ,oCAAoC,gBAAgB,CAAC,UAAU,MAAM,EAAE,sBAAsB,kBAAkB,GAAG,CAAC,CAAC,QAAQ,gBAAgB,CAAC,UAAU,MAAM,CAAC,CAAC,CAAA;;;;;;;;;;;;;;;;;;;;EAsBnI"}
1
+ {"version":3,"file":"build.js","names":[],"sources":[],"mappings":""}
@@ -1,7 +1,4 @@
1
- import { m as ResolvedCommandKitConfig } from "../analytics-engine-DnRsHBId.js";
2
- import * as tsdown from "tsdown";
3
- import * as typescript from "typescript";
4
-
1
+ import { m as ResolvedCommandKitConfig } from "../analytics-engine-Bz1p7ud3.js";
5
2
  //#region src/cli/common.d.ts
6
3
  /**
7
4
  * @private
@@ -23,7 +20,7 @@ declare function panic(message: any): never;
23
20
  * @private
24
21
  * @internal
25
22
  */
26
- declare function loadTypeScript(e?: string): Promise<typeof typescript>;
23
+ declare function loadTypeScript(e?: string): Promise<typeof import("typescript")>;
27
24
  /**
28
25
  * @private
29
26
  * @internal
@@ -43,7 +40,7 @@ declare function copyLocaleFiles(_from: string, _to: string): Promise<void>;
43
40
  * @private
44
41
  * @internal
45
42
  */
46
- declare function loadTsdown(): Promise<typeof tsdown>;
43
+ declare function loadTsdown(): Promise<typeof import('tsdown')>;
47
44
  //#endregion
48
45
  export { copyLocaleFiles, erase, findEntrypoint, loadConfigFileFromPath, loadTsdown, loadTypeScript, panic, write };
49
46
  //# sourceMappingURL=common.d.ts.map
@@ -1,10 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_chunk = require('../chunk-BE-pF4vm.js');
2
+ const require_rolldown_runtime = require('../rolldown-runtime-C_NdSu1c.js');
3
3
  const require_utils_colors = require('../utils/colors.js');
4
4
  const require_utils_constants = require('../utils/constants.js');
5
5
  const require_utils_types_package = require('../utils/types-package.js');
6
6
  let node_fs = require("node:fs");
7
- node_fs = require_chunk.__toESM(node_fs);
7
+ node_fs = require_rolldown_runtime.__toESM(node_fs);
8
8
  let node_path = require("node:path");
9
9
  let rimraf = require("rimraf");
10
10
  let node_child_process = require("node:child_process");
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","names":[],"sources":["../../src/cli/common.ts"],"sourcesContent":["import { rimrafSync } from 'rimraf';\nimport { join } from 'node:path';\nimport fs from 'node:fs';\nimport colors from '../utils/colors';\nimport { ResolvedCommandKitConfig } from '../config/utils';\nimport { generateTypesPackage } from '../utils/types-package';\nimport { execSync } from 'node:child_process';\nimport { COMMANDKIT_CWD } from '../utils/constants';\n\nlet ts: typeof import('typescript') | undefined;\nlet tsdown: typeof import('tsdown') | undefined;\n\n/**\n * @private\n * @internal\n */\nexport function write(message: any) {\n process.stdout.write(message);\n process.stdout.write('\\n');\n}\n\n/**\n * @private\n * @internal\n */\nexport function findEntrypoint(dir: string) {\n const target = join(dir, 'sharding-manager.js');\n\n // if sharding manager exists, return that file instead\n if (fs.existsSync(target)) return target;\n\n return join(dir, 'index.js');\n}\n\n/**\n * @returns {never}\n * @internal\n * @private\n */\nexport function panic(message: any): never {\n write(colors.red(`Error: ${message}`));\n process.exit(1);\n}\n\n/**\n * @private\n * @internal\n */\nasync function ensureTypeScript(target: string) {\n const isTypeScript = /\\.(c|m)?tsx?$/.test(target);\n\n if (!isTypeScript) return false;\n if (process.features.typescript) return true;\n\n await loadTypeScript();\n\n return true;\n}\n\nlet packageManager: string;\n\n/**\n * @private\n * @internal\n */\nfunction detectPackageManager() {\n if (packageManager) return packageManager;\n\n const lockfiles = {\n 'yarn.lock': 'yarn',\n 'pnpm-lock.yaml': 'pnpm',\n 'package-lock.json': 'npm',\n 'bun.lock': 'bun',\n 'bun.lockb': 'bun',\n 'deno.lock': 'deno',\n };\n\n for (const [lockfile, manager] of Object.entries(lockfiles)) {\n if (fs.existsSync(join(COMMANDKIT_CWD, lockfile))) {\n packageManager = manager;\n break;\n }\n }\n\n if (!packageManager) {\n packageManager = 'npm';\n }\n\n return packageManager;\n}\n\n/**\n * @private\n * @internal\n */\nexport async function loadTypeScript(e?: string) {\n if (ts) return ts;\n\n try {\n ts = await import('typescript');\n } catch (e) {\n if (e instanceof Error && 'code' in e && e.code === 'MODULE_NOT_FOUND') {\n try {\n const packageManager = detectPackageManager();\n const prefix = packageManager === 'deno' ? 'npm:' : '';\n execSync(`${packageManager} add -D ${prefix}typescript`, {\n stdio: 'inherit',\n cwd: COMMANDKIT_CWD,\n });\n\n console.log(\n colors.cyan(\n `TypeScript has been installed automatically, restarting...`,\n ),\n );\n\n ts = await import('typescript');\n\n return ts;\n } catch {\n panic(\n 'TypeScript is not installed and could not be installed automatically. Please install it manually.',\n );\n }\n }\n panic(e || 'TypeScript must be installed to use TypeScript config files.');\n }\n\n return ts;\n}\n\n/**\n * @private\n * @internal\n */\nexport async function loadConfigFileFromPath(\n target: string,\n): Promise<ResolvedCommandKitConfig> {\n await ensureExists(target);\n\n const isTs = await ensureTypeScript(target);\n\n let generatedFilePath: string | undefined;\n\n if (isTs && ts) {\n const { transpileModule } = ts;\n const src = fs.readFileSync(target, 'utf8');\n const { outputText } = transpileModule(src, {\n compilerOptions: {\n module: ts.ModuleKind.ESNext,\n target: ts.ScriptTarget.ESNext,\n moduleResolution: ts.ModuleResolutionKind.NodeNext,\n },\n fileName: target,\n });\n\n await generateTypesPackage();\n\n const nodeModulesPath = COMMANDKIT_CWD;\n\n const tmpFile = join(nodeModulesPath, 'compiled-commandkit.config.mjs');\n\n fs.writeFileSync(tmpFile, outputText);\n\n generatedFilePath = tmpFile;\n\n target = tmpFile;\n }\n\n /**\n * @type {import('..').CommandKitConfig}\n */\n const config = await import(`file://${target}`).then(\n (conf) => conf.default || conf,\n );\n\n if (generatedFilePath) {\n try {\n fs.unlinkSync(generatedFilePath);\n } catch {\n //\n }\n }\n\n return config;\n}\n\n/**\n * @private\n * @internal\n */\nasync function ensureExists(loc: string) {\n const exists = fs.existsSync(loc);\n\n if (!exists) {\n throw new Error(`File not found: ${loc}`);\n }\n}\n\n/**\n * @private\n * @internal\n */\nexport function erase(dir: string) {\n rimrafSync(dir);\n}\n\n/**\n * @private\n * @internal\n */\nexport async function copyLocaleFiles(_from: string, _to: string) {\n const resolvedFrom = join(COMMANDKIT_CWD, _from);\n const resolvedTo = join(COMMANDKIT_CWD, _to);\n\n const localePaths = ['app/locales'];\n const srcLocalePaths = localePaths.map((path) => join(resolvedFrom, path));\n const destLocalePaths = localePaths.map((path) => join(resolvedTo, path));\n\n for (const localePath of srcLocalePaths) {\n if (!fs.existsSync(localePath)) {\n continue;\n }\n\n // copy localePath to destLocalePath\n const destLocalePath = destLocalePaths[srcLocalePaths.indexOf(localePath)];\n\n if (!fs.existsSync(destLocalePath)) {\n fs.promises.mkdir(destLocalePath, { recursive: true }).catch(() => {});\n }\n\n await fs.promises\n .cp(localePath, destLocalePath, {\n recursive: true,\n force: true,\n })\n .catch(() => {});\n }\n}\n\n/**\n * @private\n * @internal\n */\nexport async function loadTsdown(): Promise<typeof import('tsdown')> {\n if (tsdown) return tsdown;\n\n tsdown = await import('tsdown');\n\n return tsdown;\n}\n"],"mappings":";;;;;;;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AAW,eAAe,CAChC,iBAAG,SAAS,MAAM,gBAAgB,EAAE,WAAW,MAAM,CAAC,CAAC,YAAY,GAAG;AAGxE,QAAM,gBAAG,SACT,GAAG,YAAG,gBAAY;GAChB,WAAW;GACX,OAAO;GACR,CAAC,CACF,YAAY,GAAG;;;;;;;AAQnB,eAAsB,aAA+C;AACnE,KAAI,OAAQ,QAAO;AAEnB,UAAS,MAAM,OAAO;AAEtB,QAAO"}
1
+ {"version":3,"file":"common.js","names":[],"sources":[],"mappings":""}
@@ -1,7 +1,6 @@
1
- import { o as HMREventType } from "../constants-DwxpkIeH.js";
1
+ import { o as HMREventChangeType, s as HMREventType } from "../constants-kWgE3L9F.js";
2
+ import { watch } from "chokidar";
2
3
  import { ChildProcess } from "node:child_process";
3
- import * as chokidar from "chokidar";
4
-
5
4
  //#region src/cli/development.d.ts
6
5
  /**
7
6
  * @private
@@ -13,11 +12,11 @@ declare function buildAndStart(configPath: string, skipStart?: boolean): Promise
13
12
  * @internal
14
13
  */
15
14
  declare function bootstrapDevelopmentServer(configPath?: string): Promise<{
16
- watcher: chokidar.FSWatcher;
15
+ watcher: ReturnType<typeof watch>;
17
16
  isConfigUpdate: (path: string) => boolean;
18
17
  performHMR: (path?: string) => Promise<boolean>;
19
- hmrHandler: (path: string) => Promise<void>;
20
- sendHmrEvent: (event: HMREventType, path?: string) => Promise<boolean>;
18
+ hmrHandler: (path: string, changeType?: HMREventChangeType) => Promise<void>;
19
+ sendHmrEvent: (event: HMREventType, path?: string, changeType?: HMREventChangeType) => Promise<boolean>;
21
20
  getProcess: () => ChildProcess | null;
22
21
  buildAndStart: typeof buildAndStart;
23
22
  }>;