commandkit 1.2.0-dev.20260130122631 → 1.2.0-dev.20260130130954

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 (212) hide show
  1. package/dist/{ActionRow-B-CGmjDp.d.ts → ActionRow-CT-uyxW0.d.ts} +2 -2
  2. package/dist/{Button-C-GPeFA3.d.ts → Button-oMnlpF6W.d.ts} +2 -2
  3. package/dist/{CommandKitEventsChannel-CnT5ymYe.js → CommandKitEventsChannel-DDI0UVh9.js} +1 -1
  4. package/dist/{CommandKitEventsChannel-CnT5ymYe.js.map → CommandKitEventsChannel-DDI0UVh9.js.map} +1 -1
  5. package/dist/{CommandsRouter-C_HLsrGX.js → CommandsRouter-D5mGRFEr.js} +1 -1
  6. package/dist/{CommandsRouter-C_HLsrGX.js.map → CommandsRouter-D5mGRFEr.js.map} +1 -1
  7. package/dist/{CompilerPlugin-CUsGAfgl.js → CompilerPlugin-DZidFuHJ.js} +2 -2
  8. package/dist/{CompilerPlugin-CUsGAfgl.js.map → CompilerPlugin-DZidFuHJ.js.map} +1 -1
  9. package/dist/{EventInterceptor-BWoEJMHZ.js → EventInterceptor-CxA95XYA.js} +1 -1
  10. package/dist/{EventInterceptor-BWoEJMHZ.js.map → EventInterceptor-CxA95XYA.js.map} +1 -1
  11. package/dist/{EventWorkerContext-Dfhgv329.js → EventWorkerContext-CfqamFWu.js} +1 -1
  12. package/dist/{EventWorkerContext-Dfhgv329.js.map → EventWorkerContext-CfqamFWu.js.map} +1 -1
  13. package/dist/{EventsRouter-DZYIha6m.js → EventsRouter-Be5NDOX4.js} +1 -1
  14. package/dist/{EventsRouter-DZYIha6m.js.map → EventsRouter-Be5NDOX4.js.map} +1 -1
  15. package/dist/{MessageCommandParser-Bs9fimmd.js → MessageCommandParser-VMFFGs0R.js} +1 -1
  16. package/dist/{MessageCommandParser-Bs9fimmd.js.map → MessageCommandParser-VMFFGs0R.js.map} +1 -1
  17. package/dist/{Modal-CZT9MZsy.d.ts → Modal--iMEUqSm.d.ts} +2 -2
  18. package/dist/{PluginCommon-BLxWww5u.js → PluginCommon-Bfs8d9s7.js} +1 -1
  19. package/dist/{PluginCommon-BLxWww5u.js.map → PluginCommon-Bfs8d9s7.js.map} +1 -1
  20. package/dist/{RuntimePlugin-CtobluSU.js → RuntimePlugin-BYQXQO8w.js} +2 -2
  21. package/dist/{RuntimePlugin-CtobluSU.js.map → RuntimePlugin-BYQXQO8w.js.map} +1 -1
  22. package/dist/{SelectMenu-q_b3Mjv9.d.ts → SelectMenu-DQbmOp1Y.d.ts} +8 -4
  23. package/dist/analytics/analytics-engine.d.ts +1 -1
  24. package/dist/analytics/analytics-engine.js +17 -22
  25. package/dist/analytics/analytics-provider.d.ts +1 -1
  26. package/dist/analytics/constants.js +1 -1
  27. package/dist/analytics/utils.js +17 -22
  28. package/dist/{analytics-engine-WQhXmx3H.d.ts → analytics-engine-_urJ5QTH.d.ts} +8 -3
  29. package/dist/app/commands/AppCommandRunner.d.ts +1 -1
  30. package/dist/app/commands/AppCommandRunner.js +17 -22
  31. package/dist/app/commands/Context.d.ts +1 -1
  32. package/dist/app/commands/Context.js +17 -22
  33. package/dist/app/commands/MessageCommandParser.js +1 -1
  34. package/dist/app/commands/helpers.js +1 -1
  35. package/dist/app/events/EventWorkerContext.d.ts +1 -1
  36. package/dist/app/events/EventWorkerContext.js +1 -1
  37. package/dist/app/handlers/AppCommandHandler.d.ts +1 -1
  38. package/dist/app/handlers/AppCommandHandler.js +17 -22
  39. package/dist/app/handlers/AppEventsHandler.d.ts +1 -1
  40. package/dist/app/handlers/AppEventsHandler.js +17 -22
  41. package/dist/app/index.d.ts +1 -1
  42. package/dist/app/index.js +17 -22
  43. package/dist/app/interrupt/signals.js +2 -2
  44. package/dist/app/middlewares/permissions.d.ts +1 -1
  45. package/dist/app/middlewares/permissions.js +17 -22
  46. package/dist/app/register/CommandRegistrar.d.ts +1 -1
  47. package/dist/app/register/CommandRegistrar.js +17 -22
  48. package/dist/app/router/CommandsRouter.js +1 -1
  49. package/dist/app/router/EventsRouter.js +1 -1
  50. package/dist/app/router/index.js +3 -3
  51. package/dist/cli/app-process.js +4 -4
  52. package/dist/cli/build.d.ts +1 -1
  53. package/dist/cli/build.js +20 -25
  54. package/dist/cli/build.js.map +1 -1
  55. package/dist/cli/common.d.ts +1 -1
  56. package/dist/cli/common.js +3 -3
  57. package/dist/cli/development.js +20 -25
  58. package/dist/cli/development.js.map +1 -1
  59. package/dist/cli/env.js +1 -1
  60. package/dist/cli/generators.js +3 -3
  61. package/dist/cli/information.js +2 -2
  62. package/dist/cli/init.js +18 -23
  63. package/dist/cli/init.js.map +1 -1
  64. package/dist/cli/production.js +20 -25
  65. package/dist/cli/production.js.map +1 -1
  66. package/dist/cli/type-checker.js +4 -4
  67. package/dist/{commandkit-a_lLZW59.js → commandkit-BUkbAdid.js} +2645 -2190
  68. package/dist/commandkit-BUkbAdid.js.map +1 -0
  69. package/dist/commandkit.d.ts +1 -1
  70. package/dist/commandkit.js +17 -22
  71. package/dist/{common-DSRs_mfw.js → common-zQwj90Nz.js} +3 -3
  72. package/dist/{common-DSRs_mfw.js.map → common-zQwj90Nz.js.map} +1 -1
  73. package/dist/components/common/EventInterceptor.js +1 -1
  74. package/dist/components/common/element.d.ts +2 -2
  75. package/dist/components/common/element.js +27 -8
  76. package/dist/components/display/common.js +20 -2
  77. package/dist/components/display/container.js +20 -2
  78. package/dist/components/display/file.js +1 -1
  79. package/dist/components/display/index.js +25 -15
  80. package/dist/components/display/label.js +20 -2
  81. package/dist/components/display/media-gallery.js +21 -3
  82. package/dist/components/display/poll.js +1 -1
  83. package/dist/components/display/section.js +21 -3
  84. package/dist/components/display/separator.js +1 -1
  85. package/dist/components/display/text-display.js +1 -1
  86. package/dist/components/index.d.ts +6 -6
  87. package/dist/components/index.js +31 -36
  88. package/dist/components/interactive/action-row/ActionRow.d.ts +1 -1
  89. package/dist/components/interactive/button/Button.d.ts +1 -1
  90. package/dist/components/interactive/button/Button.js +17 -22
  91. package/dist/components/interactive/button/ButtonKit.js +17 -22
  92. package/dist/components/interactive/modal/Modal.d.ts +1 -1
  93. package/dist/components/interactive/modal/Modal.js +17 -22
  94. package/dist/components/interactive/modal/ModalKit.js +17 -22
  95. package/dist/components/interactive/select-menu/ChannelSelectMenuKit.js +17 -22
  96. package/dist/components/interactive/select-menu/MentionableSelectMenuKit.js +17 -22
  97. package/dist/components/interactive/select-menu/RoleSelectMenuKit.js +17 -22
  98. package/dist/components/interactive/select-menu/SelectMenu.d.ts +1 -1
  99. package/dist/components/interactive/select-menu/SelectMenu.js +17 -22
  100. package/dist/components/interactive/select-menu/StringSelectMenuKit.js +17 -22
  101. package/dist/components/interactive/select-menu/UserSelectMenuKit.js +17 -22
  102. package/dist/config/config.d.ts +1 -1
  103. package/dist/config/config.js +17 -22
  104. package/dist/config/default.d.ts +1 -1
  105. package/dist/config/default.js +17 -22
  106. package/dist/config/loader.d.ts +1 -1
  107. package/dist/config/loader.js +17 -22
  108. package/dist/config/types.d.ts +1 -1
  109. package/dist/config/utils.d.ts +1 -1
  110. package/dist/config/utils.js +1 -1
  111. package/dist/{constants-Cw8VjCVz.js → constants-BA0TJU6e.js} +1 -1
  112. package/dist/{constants-Cw8VjCVz.js.map → constants-BA0TJU6e.js.map} +1 -1
  113. package/dist/{constants-BFFK-hfP.js → constants-BS9N2avz.js} +1 -1
  114. package/dist/{constants-BFFK-hfP.js.map → constants-BS9N2avz.js.map} +1 -1
  115. package/dist/{constants-CxkFFZ7p.js → constants-CeIMhMD0.js} +1 -1
  116. package/dist/{constants-CxkFFZ7p.js.map → constants-CeIMhMD0.js.map} +1 -1
  117. package/dist/context/async-context.d.ts +1 -1
  118. package/dist/context/async-context.js +17 -22
  119. package/dist/context/environment.d.ts +1 -1
  120. package/dist/context/environment.js +17 -22
  121. package/dist/{element-wQo0heGj.d.ts → element-DZeqbSTk.d.ts} +3 -2
  122. package/dist/{env-CmspDhHy.js → env-FxaiNasU.js} +1 -1
  123. package/dist/{env-CmspDhHy.js.map → env-FxaiNasU.js.map} +1 -1
  124. package/dist/events/CommandKitEventsChannel.d.ts +1 -1
  125. package/dist/events/CommandKitEventsChannel.js +1 -1
  126. package/dist/{file-Ca1kpEtE.js → file-DqI3v90P.js} +1 -1
  127. package/dist/{file-Ca1kpEtE.js.map → file-DqI3v90P.js.map} +1 -1
  128. package/dist/flags/FlagProvider.d.ts +1 -1
  129. package/dist/flags/feature-flags.d.ts +1 -1
  130. package/dist/flags/feature-flags.js +20 -163
  131. package/dist/flags/store.d.ts +1 -1
  132. package/dist/flags/store.js +1 -1
  133. package/dist/{helpers-Btx1FSZx.js → helpers-DSy7EjzP.js} +1 -1
  134. package/dist/{helpers-Btx1FSZx.js.map → helpers-DSy7EjzP.js.map} +1 -1
  135. package/dist/index.d.ts +7 -7
  136. package/dist/index.js +42 -55
  137. package/dist/kv/constants.js +1 -1
  138. package/dist/kv/serde.js +1 -1
  139. package/dist/logger/DefaultLogger.js +17 -22
  140. package/dist/logger/Logger.js +17 -22
  141. package/dist/plugins/CompilerPlugin.d.ts +1 -1
  142. package/dist/plugins/CompilerPlugin.js +1 -1
  143. package/dist/plugins/PluginCommon.d.ts +1 -1
  144. package/dist/plugins/PluginCommon.js +1 -1
  145. package/dist/plugins/RuntimePlugin.d.ts +1 -1
  146. package/dist/plugins/RuntimePlugin.js +1 -1
  147. package/dist/plugins/index.d.ts +1 -1
  148. package/dist/plugins/index.js +19 -24
  149. package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.d.ts +1 -1
  150. package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.js +17 -22
  151. package/dist/plugins/plugin-runtime/CompilerPluginRuntime.d.ts +1 -1
  152. package/dist/plugins/plugin-runtime/CompilerPluginRuntime.js +17 -22
  153. package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.d.ts +1 -1
  154. package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.js +17 -22
  155. package/dist/plugins/plugin-runtime/builtin/MacroPlugin.d.ts +1 -1
  156. package/dist/plugins/plugin-runtime/builtin/MacroPlugin.js +17 -22
  157. package/dist/plugins/plugin-runtime/runtime.d.ts +1 -1
  158. package/dist/plugins/types.d.ts +1 -1
  159. package/dist/{poll-CFe8yvoJ.js → poll-ziQQQbMU.js} +1 -1
  160. package/dist/{poll-CFe8yvoJ.js.map → poll-ziQQQbMU.js.map} +1 -1
  161. package/dist/{resolve-file-url-CdHqwWs3.js → resolve-file-url-BmjHzIKe.js} +1 -1
  162. package/dist/{resolve-file-url-CdHqwWs3.js.map → resolve-file-url-BmjHzIKe.js.map} +1 -1
  163. package/dist/{separator-BUTiW7uz.js → separator-DGwA_b1J.js} +1 -1
  164. package/dist/{separator-BUTiW7uz.js.map → separator-DGwA_b1J.js.map} +1 -1
  165. package/dist/{signals-B8z1wJ6W.js → signals-ewEPW2cO.js} +2 -2
  166. package/dist/{signals-B8z1wJ6W.js.map → signals-ewEPW2cO.js.map} +1 -1
  167. package/dist/{store-D8r_hryO.js → store-DK4JA-fQ.js} +1 -1
  168. package/dist/{store-D8r_hryO.js.map → store-DK4JA-fQ.js.map} +1 -1
  169. package/dist/{text-display-DANahMN3.js → text-display-BVuG7dT-.js} +1 -1
  170. package/dist/{text-display-DANahMN3.js.map → text-display-BVuG7dT-.js.map} +1 -1
  171. package/dist/{type-checker-cVd3Hpnh.js → type-checker-CFpKDDs8.js} +2 -2
  172. package/dist/{type-checker-cVd3Hpnh.js.map → type-checker-CFpKDDs8.js.map} +1 -1
  173. package/dist/{types-package-CsTNfvv2.js → types-package-Bjh_ap0V.js} +2 -2
  174. package/dist/{types-package-CsTNfvv2.js.map → types-package-Bjh_ap0V.js.map} +1 -1
  175. package/dist/types.d.ts +1 -1
  176. package/dist/utils/constants.js +1 -1
  177. package/dist/utils/dev-hooks.d.ts +1 -1
  178. package/dist/utils/dev-hooks.js +17 -22
  179. package/dist/utils/resolve-file-url.js +1 -1
  180. package/dist/utils/types-package.js +2 -2
  181. package/dist/utils/utilities.js +17 -22
  182. package/dist/utils/warning.js +1 -1
  183. package/dist/{utils-Br3eenD1.js → utils-CVaVycsK.js} +1 -1
  184. package/dist/{utils-Br3eenD1.js.map → utils-CVaVycsK.js.map} +1 -1
  185. package/dist/version-CdkD798u.js +18 -0
  186. package/dist/version-CdkD798u.js.map +1 -0
  187. package/dist/version.js +2 -12
  188. package/dist/{warning-CszH8HeS.js → warning-BWiQltHE.js} +1 -1
  189. package/dist/{warning-CszH8HeS.js.map → warning-BWiQltHE.js.map} +1 -1
  190. package/package.json +3 -3
  191. package/dist/commandkit-a_lLZW59.js.map +0 -1
  192. package/dist/common-CEordwf3.js +0 -17
  193. package/dist/common-CEordwf3.js.map +0 -1
  194. package/dist/container-DCPljKVH.js +0 -43
  195. package/dist/container-DCPljKVH.js.map +0 -1
  196. package/dist/element-DibzzA5L.js +0 -84
  197. package/dist/element-DibzzA5L.js.map +0 -1
  198. package/dist/flags/feature-flags.js.map +0 -1
  199. package/dist/index.js.map +0 -1
  200. package/dist/label-B6vXvwLM.js +0 -35
  201. package/dist/label-B6vXvwLM.js.map +0 -1
  202. package/dist/media-gallery-u3gjX7yD.js +0 -61
  203. package/dist/media-gallery-u3gjX7yD.js.map +0 -1
  204. package/dist/section-BC8LF-B2.js +0 -59
  205. package/dist/section-BC8LF-B2.js.map +0 -1
  206. package/dist/version.js.map +0 -1
  207. /package/dist/{common-C2jAjX4U.js → ILogger-JI8VGyJf.js} +0 -0
  208. /package/dist/{display-WDb9wMCv.js → common-vGj3fpz3.js} +0 -0
  209. /package/dist/{router-BvamdzoF.js → router-CtcApqrw.js} +0 -0
  210. /package/dist/{runtime-Skt5NiOc.js → runtime-UJIpkNww.js} +0 -0
  211. /package/dist/{types-Cdh4uaFR.js → types-Bx1EKe0v.js} +0 -0
  212. /package/dist/{types-TC4g3w91.js → types-CAwOz52q.js} +0 -0
@@ -1,17 +0,0 @@
1
-
2
- //#region src/components/display/common.ts
3
- /**
4
- * @private
5
- */
6
- function applyId(props, component) {
7
- if (props.id != null && "setId" in component) component.setId(props.id);
8
- }
9
-
10
- //#endregion
11
- Object.defineProperty(exports, 'applyId', {
12
- enumerable: true,
13
- get: function () {
14
- return applyId;
15
- }
16
- });
17
- //# sourceMappingURL=common-CEordwf3.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"common-CEordwf3.js","names":[],"sources":["../src/components/display/common.ts"],"sourcesContent":["import { ComponentBuilder } from 'discord.js';\n\n/**\n * @private\n */\nexport function applyId(props: { id?: number }, component: ComponentBuilder) {\n if (props.id != null && 'setId' in component) {\n component.setId(props.id);\n }\n}\n"],"mappings":";;;;;AAKA,SAAgB,QAAQ,OAAuB,WAA6B;AAC1E,KAAI,MAAM,MAAM,QAAQ,WAAW,UACjC,WAAU,MAAM,MAAM,GAAG"}
@@ -1,43 +0,0 @@
1
- const require_chunk = require('./chunk-kSYXY2_d.js');
2
- const require_common = require('./common-CEordwf3.js');
3
- let discord_js = require("discord.js");
4
-
5
- //#region src/components/display/container.ts
6
- /**
7
- * The components v2 container component
8
- * @param props - The properties for the container component.
9
- * @returns the container builder instance.
10
- * @example ```tsx
11
- * import { Container } from 'commandkit';
12
- *
13
- * const container = <Container>...</Container>;
14
- * ```
15
- */
16
- function Container(props) {
17
- const container = new discord_js.ContainerBuilder();
18
- require_common.applyId(props, container);
19
- container.setAccentColor((0, discord_js.resolveColor)(props.accentColor));
20
- if (props.spoiler != null) container.setSpoiler(props.spoiler);
21
- if (props.children != null) {
22
- if (!Array.isArray(props.children)) props.children = [props.children];
23
- if (props.children.length === 0) return container;
24
- for (const child of props.children.flat()) {
25
- if (child instanceof discord_js.TextDisplayBuilder) container.addTextDisplayComponents(child);
26
- if (child instanceof discord_js.FileBuilder) container.addFileComponents(child);
27
- if (child instanceof discord_js.ActionRowBuilder) container.addActionRowComponents(child);
28
- if (child instanceof discord_js.SeparatorBuilder) container.addSeparatorComponents(child);
29
- if (child instanceof discord_js.SectionBuilder) container.addSectionComponents(child);
30
- if (child instanceof discord_js.MediaGalleryBuilder) container.addMediaGalleryComponents(child);
31
- }
32
- }
33
- return container;
34
- }
35
-
36
- //#endregion
37
- Object.defineProperty(exports, 'Container', {
38
- enumerable: true,
39
- get: function () {
40
- return Container;
41
- }
42
- });
43
- //# sourceMappingURL=container-DCPljKVH.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"container-DCPljKVH.js","names":[],"sources":["../src/components/display/container.ts"],"sourcesContent":["import {\n ActionRowBuilder,\n ColorResolvable,\n ComponentBuilder,\n ContainerBuilder,\n ContainerComponentData,\n FileBuilder,\n MediaGalleryBuilder,\n resolveColor,\n SectionBuilder,\n SeparatorBuilder,\n TextDisplayBuilder,\n} from 'discord.js';\nimport { applyId } from './common';\n\n/**\n * Represents the properties for a container component.\n */\nexport interface ContainerProps\n extends Omit<ContainerComponentData, 'type' | 'components' | 'accentColor'> {\n accentColor?: ColorResolvable;\n children?: ComponentBuilder[];\n}\n\n/**\n * The components v2 container component\n * @param props - The properties for the container component.\n * @returns the container builder instance.\n * @example ```tsx\n * import { Container } from 'commandkit';\n *\n * const container = <Container>...</Container>;\n * ```\n */\nexport function Container(props: ContainerProps): ContainerBuilder {\n const container = new ContainerBuilder();\n\n applyId(props, container);\n\n if (typeof props.accentColor != null) {\n container.setAccentColor(resolveColor(props.accentColor!));\n }\n\n if (props.spoiler != null) {\n container.setSpoiler(props.spoiler);\n }\n\n if (props.children != null) {\n if (!Array.isArray(props.children)) props.children = [props.children];\n if (props.children.length === 0) return container;\n\n for (const child of props.children.flat()) {\n if (child instanceof TextDisplayBuilder) {\n container.addTextDisplayComponents(child);\n }\n\n if (child instanceof FileBuilder) {\n container.addFileComponents(child);\n }\n\n if (child instanceof ActionRowBuilder) {\n container.addActionRowComponents(child);\n }\n\n if (child instanceof SeparatorBuilder) {\n container.addSeparatorComponents(child);\n }\n\n if (child instanceof SectionBuilder) {\n container.addSectionComponents(child);\n }\n\n if (child instanceof MediaGalleryBuilder) {\n container.addMediaGalleryComponents(child);\n }\n }\n }\n\n return container;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAkCA,SAAgB,UAAU,OAAyC;CACjE,MAAM,YAAY,IAAI,6BAAkB;AAExC,wBAAQ,OAAO,UAAU;AAGvB,WAAU,4CAA4B,MAAM,YAAa,CAAC;AAG5D,KAAI,MAAM,WAAW,KACnB,WAAU,WAAW,MAAM,QAAQ;AAGrC,KAAI,MAAM,YAAY,MAAM;AAC1B,MAAI,CAAC,MAAM,QAAQ,MAAM,SAAS,CAAE,OAAM,WAAW,CAAC,MAAM,SAAS;AACrE,MAAI,MAAM,SAAS,WAAW,EAAG,QAAO;AAExC,OAAK,MAAM,SAAS,MAAM,SAAS,MAAM,EAAE;AACzC,OAAI,iBAAiB,8BACnB,WAAU,yBAAyB,MAAM;AAG3C,OAAI,iBAAiB,uBACnB,WAAU,kBAAkB,MAAM;AAGpC,OAAI,iBAAiB,4BACnB,WAAU,uBAAuB,MAAM;AAGzC,OAAI,iBAAiB,4BACnB,WAAU,uBAAuB,MAAM;AAGzC,OAAI,iBAAiB,0BACnB,WAAU,qBAAqB,MAAM;AAGvC,OAAI,iBAAiB,+BACnB,WAAU,0BAA0B,MAAM;;;AAKhD,QAAO"}
@@ -1,84 +0,0 @@
1
-
2
- //#region src/components/common/element.ts
3
- /**
4
- * Represents the types of elements that can be used in CommandKit.
5
- */
6
- const ElementType = {
7
- ActionRow: "action-row",
8
- Button: "button-kit",
9
- Modal: "modal",
10
- TextInput: "text-input"
11
- };
12
- /**
13
- * Checks if the given element is a CommandKit element.
14
- * @param element The element to check.
15
- * @returns True if the element is a CommandKit element, false otherwise.
16
- */
17
- function isCommandKitElement(element) {
18
- if (typeof element !== "object" || element === null) return false;
19
- if (!Reflect.has(element, "type")) return false;
20
- if (!Reflect.has(element, "data")) return false;
21
- return true;
22
- }
23
- /**
24
- * Gets the element data for a specific CommandKit element.
25
- * @param element The CommandKit element to get the data for.
26
- * @returns The element data for the specified CommandKit element.
27
- */
28
- function getElement(element) {
29
- return element.data;
30
- }
31
- /**
32
- * Represents a fragment of CommandKit elements.
33
- * @param props The properties for the fragment.
34
- * @returns The fragment element.
35
- */
36
- function Fragment(props) {
37
- return Array.isArray(props.children) ? props.children.flat() : [props.children];
38
- }
39
- /**
40
- * The createElement function is used to create CommandKit elements.
41
- * @param type The type of the element to create.
42
- * @param props The properties for the element.
43
- * @param children The children of the element.
44
- * @returns The created CommandKit element.
45
- */
46
- function createElement(type, props, ...children) {
47
- return type({
48
- ...props,
49
- children: props.children ?? children
50
- });
51
- }
52
-
53
- //#endregion
54
- Object.defineProperty(exports, 'ElementType', {
55
- enumerable: true,
56
- get: function () {
57
- return ElementType;
58
- }
59
- });
60
- Object.defineProperty(exports, 'Fragment', {
61
- enumerable: true,
62
- get: function () {
63
- return Fragment;
64
- }
65
- });
66
- Object.defineProperty(exports, 'createElement', {
67
- enumerable: true,
68
- get: function () {
69
- return createElement;
70
- }
71
- });
72
- Object.defineProperty(exports, 'getElement', {
73
- enumerable: true,
74
- get: function () {
75
- return getElement;
76
- }
77
- });
78
- Object.defineProperty(exports, 'isCommandKitElement', {
79
- enumerable: true,
80
- get: function () {
81
- return isCommandKitElement;
82
- }
83
- });
84
- //# sourceMappingURL=element-DibzzA5L.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"element-DibzzA5L.js","names":[],"sources":["../src/components/common/element.ts"],"sourcesContent":["import type { ActionRowBuilder, TextInputBuilder } from 'discord.js';\nimport type { ButtonKit } from '../interactive/button/ButtonKit';\nimport type { ModalKit } from '../interactive/modal/ModalKit';\n\n/**\n * Represents the types of elements that can be used in CommandKit.\n */\nexport const ElementType = {\n ActionRow: 'action-row',\n Button: 'button-kit',\n Modal: 'modal',\n TextInput: 'text-input',\n} as const;\n\n/**\n * The type of element that can be used in CommandKit.\n * This is a union of the keys of the ElementType object.\n */\nexport type ElementType = (typeof ElementType)[keyof typeof ElementType];\n\n/**\n * The data structure that maps each ElementType to its corresponding CommandKit element.\n */\nexport interface CommandKitElementData {\n [ElementType.ActionRow]: ActionRowBuilder;\n [ElementType.Button]: ButtonKit;\n [ElementType.Modal]: ModalKit;\n [ElementType.TextInput]: TextInputBuilder;\n}\n\n/**\n * Represents a CommandKit element with a specific type and data.\n */\nexport type CommandKitElement<Type extends ElementType> =\n CommandKitElementData[Type];\n\n/**\n * Represents any CommandKit element, which can be of any type defined in CommandKitElementData.\n */\nexport type AnyCommandKitElement = CommandKitElement<ElementType>;\n\n/**\n * Checks if the given element is a CommandKit element.\n * @param element The element to check.\n * @returns True if the element is a CommandKit element, false otherwise.\n */\nexport function isCommandKitElement(\n element: unknown,\n): element is CommandKitElement<ElementType> {\n if (typeof element !== 'object' || element === null) return false;\n if (!Reflect.has(element, 'type')) return false;\n if (!Reflect.has(element, 'data')) return false;\n\n return true;\n}\n\n/**\n * Gets the element data for a specific CommandKit element.\n * @param element The CommandKit element to get the data for.\n * @returns The element data for the specified CommandKit element.\n */\nexport function getElement<\n T extends ElementType,\n E extends CommandKitElement<T>,\n>(element: E): CommandKitElementData[T] {\n return element.data as CommandKitElementData[T];\n}\n\n/**\n * Represents the properties for a fragment element in CommandKit.\n */\nexport interface FragmentElementProps {\n children: [];\n}\n\n/**\n * Represents a fragment of CommandKit elements.\n * @param props The properties for the fragment.\n * @returns The fragment element.\n */\nexport function Fragment(\n props: FragmentElementProps,\n): CommandKitElementData[ElementType][] {\n return Array.isArray(props.children)\n ? props.children.flat()\n : [props.children];\n}\n\n/**\n * The createElement function is used to create CommandKit elements.\n * @param type The type of the element to create.\n * @param props The properties for the element.\n * @param children The children of the element.\n * @returns The created CommandKit element.\n */\nexport function createElement(\n type: Function,\n props: Record<string, unknown>,\n ...children: any[]\n): CommandKitElement<ElementType> {\n return type({ ...props, children: props.children ?? children });\n}\n\nexport { createElement as jsx, createElement as jsxs };\n"],"mappings":";;;;;AAOA,MAAa,cAAc;CACzB,WAAW;CACX,QAAQ;CACR,OAAO;CACP,WAAW;CACZ;;;;;;AAkCD,SAAgB,oBAChB,SAC4C;AAC1C,KAAI,OAAO,YAAY,YAAY,YAAY,KAAM,QAAO;AAC5D,KAAI,CAAC,QAAQ,IAAI,SAAS,OAAO,CAAE,QAAO;AAC1C,KAAI,CAAC,QAAQ,IAAI,SAAS,OAAO,CAAE,QAAO;AAE1C,QAAO;;;;;;;AAQT,SAAgB,WAGhB,SAAsC;AACpC,QAAO,QAAQ;;;;;;;AAejB,SAAgB,SAChB,OACuC;AACrC,QAAO,MAAM,QAAQ,MAAM,SAAQ,GACnC,MAAI,SAAM,MAAS,GACnB,CAAC,MAAI,SAAM;;;;;;;;;AAUb,SAAgB,cAChB,MACA,OACA,GAAG,UAC8B;AAC/B,QAAO,KAAK;EAAE,GAAG;EAAO,UAAU,MAAM,YAAY;EAAU,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"feature-flags.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 type { 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":";;;;;;;;;;;;;;;;;;;;;;;;;;IAqBI,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,OAAG,YAAgB;GACjB,MAAE,MAAU,KAAE,YAAe;AAC7B,UAAQ,2DAAE,SAAe,IAAE,KAAO,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,oCAAgB;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,oCAAgB;KACtB,IACA,YACA,OAAE,aAAkB,YACpB,QAAO,YACP,OAAE,SAAO,OAAc,WACvB,SAAM,KACN;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,OAAO,IAAI,YAA6B,QAAQ;CACtD,MAAM,SAAS,KAAK,QAAQ,KAAK,MAAM,OAAU;AAKjD,QAAO,MAAM,eAAgB,KAAK;AAChC,MAAI,4CAAC,IAAK,UACR,OAAM,IAAI,MACR,sEACD;EAGH,MAAM,UACN,OAAE,QAAa,aACf,MAAM,KAAuC,GAC7C;AAKA,SAFuB,MAAM,KAAK,QAAQ,QAAQ;;AAKpD,QAAO"}
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 './components/common/EventInterceptor';\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 { warnDeprecated, emitWarning, warnUnstable } from './utils/warning';\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,kBAAe"}
@@ -1,35 +0,0 @@
1
- const require_chunk = require('./chunk-kSYXY2_d.js');
2
- const require_common = require('./common-CEordwf3.js');
3
- let discord_js = require("discord.js");
4
-
5
- //#region src/components/display/label.ts
6
- /**
7
- * The label component wraps modal components with text as a label and optional description.
8
- * @param props The label properties.
9
- * @returns The label builder instance.
10
- * @example ```tsx
11
- * import { Label } from 'commandkit';
12
- *
13
- * const label = <Label label="Name" description="Enter your name">
14
- * <ShortInput customId="name" label="Name" placeholder="John" required />
15
- * </Label>;
16
- * ```
17
- */
18
- function Label(props) {
19
- const { children, id, ...rest } = props;
20
- const label = new discord_js.LabelBuilder({
21
- ...rest,
22
- component: children
23
- });
24
- require_common.applyId(props, label);
25
- return label;
26
- }
27
-
28
- //#endregion
29
- Object.defineProperty(exports, 'Label', {
30
- enumerable: true,
31
- get: function () {
32
- return Label;
33
- }
34
- });
35
- //# sourceMappingURL=label-B6vXvwLM.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"label-B6vXvwLM.js","names":[],"sources":["../src/components/display/label.ts"],"sourcesContent":["import {\n APIComponentInLabel,\n LabelBuilder,\n type LabelBuilderData,\n} from 'discord.js';\nimport { applyId } from './common';\n\n/**\n * The label properties for the label component.\n */\nexport interface LabelProps\n extends Omit<LabelBuilderData, 'component' | 'type'> {\n /**\n * The component that will be wrapped by the label component.\n */\n children: LabelBuilderData['component'] & {};\n}\n\n/**\n * The label component wraps modal components with text as a label and optional description.\n * @param props The label properties.\n * @returns The label builder instance.\n * @example ```tsx\n * import { Label } from 'commandkit';\n *\n * const label = <Label label=\"Name\" description=\"Enter your name\">\n * <ShortInput customId=\"name\" label=\"Name\" placeholder=\"John\" required />\n * </Label>;\n * ```\n */\nexport function Label(props: LabelProps) {\n const { children, id, ...rest } = props;\n\n const label = new LabelBuilder({\n ...rest,\n // channel select menu builder is missing?\n component: children as unknown as APIComponentInLabel,\n });\n\n applyId(props, label);\n\n return label;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA8BA,SAAgB,MAAM,OAAmB;CACvC,MAAM,EAAE,UAAU,IAAI,GAAG,SAAS;CAElC,MAAM,QAAQ,IAAI,wBAAa;EAC7B,GAAG;EAEH,WAAW;EACZ,CAAC;AAEF,wBAAQ,OAAO,MAAM;AAErB,QAAO"}
@@ -1,61 +0,0 @@
1
- const require_chunk = require('./chunk-kSYXY2_d.js');
2
- const require_common = require('./common-CEordwf3.js');
3
- let discord_js = require("discord.js");
4
-
5
- //#region src/components/display/media-gallery.ts
6
- /**
7
- * The media gallery component
8
- * @param props The properties for the media gallery component.
9
- * @returns The media gallery builder instance.
10
- * @example ```tsx
11
- * import { MediaGallery } from 'commandkit';
12
- *
13
- * const gallery = (
14
- * <MediaGallery>
15
- * <MediaGalleryItem url="https://example.com/image1.png" description="Image 1" />
16
- * <MediaGalleryItem url="https://example.com/image2.png" description="Image 2" />
17
- * </MediaGallery>
18
- * );
19
- * ```
20
- */
21
- function MediaGallery(props) {
22
- const gallery = new discord_js.MediaGalleryBuilder();
23
- require_common.applyId(props, gallery);
24
- if (props.children != null) {
25
- if (!Array.isArray(props.children)) props.children = [props.children];
26
- gallery.addItems(props.children.flat());
27
- }
28
- return gallery;
29
- }
30
- /**
31
- * The media gallery item component
32
- * @param props The properties for the media gallery item component.
33
- * @returns The media gallery item builder instance.
34
- * @example ```tsx
35
- * import { MediaGalleryItem } from 'commandkit';
36
- *
37
- * const item = <MediaGalleryItem url="https://example.com/image.png" description="An image" />;
38
- * ```
39
- */
40
- function MediaGalleryItem(props) {
41
- const item = new discord_js.MediaGalleryItemBuilder();
42
- if (props.description != null) item.setDescription(props.description);
43
- if (props.spoiler != null) item.setSpoiler(props.spoiler);
44
- if (props.url != null) item.setURL(props.url);
45
- return item;
46
- }
47
-
48
- //#endregion
49
- Object.defineProperty(exports, 'MediaGallery', {
50
- enumerable: true,
51
- get: function () {
52
- return MediaGallery;
53
- }
54
- });
55
- Object.defineProperty(exports, 'MediaGalleryItem', {
56
- enumerable: true,
57
- get: function () {
58
- return MediaGalleryItem;
59
- }
60
- });
61
- //# sourceMappingURL=media-gallery-u3gjX7yD.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"media-gallery-u3gjX7yD.js","names":[],"sources":["../src/components/display/media-gallery.ts"],"sourcesContent":["import { MediaGalleryBuilder, MediaGalleryItemBuilder } from 'discord.js';\nimport { applyId } from './common';\n\n/**\n * Represents the properties for a media gallery component.\n */\nexport interface MediaGalleryProps {\n id?: number;\n children?: MediaGalleryItemBuilder[];\n}\n\n/**\n * The media gallery component\n * @param props The properties for the media gallery component.\n * @returns The media gallery builder instance.\n * @example ```tsx\n * import { MediaGallery } from 'commandkit';\n *\n * const gallery = (\n * <MediaGallery>\n * <MediaGalleryItem url=\"https://example.com/image1.png\" description=\"Image 1\" />\n * <MediaGalleryItem url=\"https://example.com/image2.png\" description=\"Image 2\" />\n * </MediaGallery>\n * );\n * ```\n */\nexport function MediaGallery(props: MediaGalleryProps) {\n const gallery = new MediaGalleryBuilder();\n\n applyId(props, gallery);\n\n if (props.children != null) {\n if (!Array.isArray(props.children)) props.children = [props.children];\n gallery.addItems(props.children.flat());\n }\n\n return gallery;\n}\n\n/**\n * Represents the properties for a media gallery item component.\n */\nexport interface MediaGalleryItemProps {\n description?: string;\n spoiler?: boolean;\n url?: string;\n}\n\n/**\n * The media gallery item component\n * @param props The properties for the media gallery item component.\n * @returns The media gallery item builder instance.\n * @example ```tsx\n * import { MediaGalleryItem } from 'commandkit';\n *\n * const item = <MediaGalleryItem url=\"https://example.com/image.png\" description=\"An image\" />;\n * ```\n */\nexport function MediaGalleryItem(props: MediaGalleryItemProps) {\n const item = new MediaGalleryItemBuilder();\n\n if (props.description != null) {\n item.setDescription(props.description);\n }\n\n if (props.spoiler != null) {\n item.setSpoiler(props.spoiler);\n }\n\n if (props.url != null) {\n item.setURL(props.url);\n }\n\n return item;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,aAAa,OAA0B;CACrD,MAAM,UAAU,IAAI,gCAAqB;AAEzC,wBAAQ,OAAO,QAAQ;AAEvB,KAAI,MAAM,YAAY,MAAM;AAC1B,MAAI,CAAC,MAAM,QAAQ,MAAM,SAAS,CAAE,OAAM,WAAW,CAAC,MAAM,SAAS;AACrE,UAAQ,SAAS,MAAM,SAAS,MAAM,CAAC;;AAGzC,QAAO;;;;;;;;;;;;AAsBT,SAAgB,iBAAiB,OAA8B;CAC7D,MAAM,OAAO,IAAI,oCAAyB;AAE1C,KAAI,MAAM,eAAe,KACvB,MAAK,eAAe,MAAM,YAAY;AAGxC,KAAI,MAAM,WAAW,KACnB,MAAK,WAAW,MAAM,QAAQ;AAGhC,KAAI,MAAM,OAAO,KACf,MAAK,OAAO,MAAM,IAAI;AAGxB,QAAO"}
@@ -1,59 +0,0 @@
1
- const require_chunk = require('./chunk-kSYXY2_d.js');
2
- const require_common = require('./common-CEordwf3.js');
3
- let discord_js = require("discord.js");
4
-
5
- //#region src/components/display/section.ts
6
- /**
7
- * The components v2 section component
8
- * @param props The properties for the section component.
9
- * @returns The section builder instance.
10
- * @example ```tsx
11
- * import { Section } from 'commandkit';
12
- *
13
- * const section = <Section>...</Section>;
14
- * ```
15
- */
16
- function Section(props) {
17
- const section = new discord_js.SectionBuilder();
18
- require_common.applyId(props, section);
19
- if (props.children != null) {
20
- if (!Array.isArray(props.children)) props.children = [props.children];
21
- for (const accessory of props.children.flat()) if (accessory instanceof discord_js.ThumbnailBuilder) section.setThumbnailAccessory(accessory);
22
- else if (accessory instanceof discord_js.ButtonBuilder) section.setButtonAccessory(accessory);
23
- else if (accessory instanceof discord_js.TextDisplayBuilder) section.addTextDisplayComponents(accessory);
24
- }
25
- return section;
26
- }
27
- /**
28
- * The thumbnail component
29
- * @param props The properties for the thumbnail component.
30
- * @returns The thumbnail builder instance.
31
- * @example ```tsx
32
- * import { Thumbnail } from 'commandkit';
33
- *
34
- * const thumbnail = <Thumbnail url="https://example.com/image.png" description="An image" />;
35
- * ```
36
- */
37
- function Thumbnail(props) {
38
- return new discord_js.ThumbnailBuilder({
39
- description: props.description,
40
- spoiler: props.spoiler,
41
- id: props.id,
42
- media: { url: props.url }
43
- });
44
- }
45
-
46
- //#endregion
47
- Object.defineProperty(exports, 'Section', {
48
- enumerable: true,
49
- get: function () {
50
- return Section;
51
- }
52
- });
53
- Object.defineProperty(exports, 'Thumbnail', {
54
- enumerable: true,
55
- get: function () {
56
- return Thumbnail;
57
- }
58
- });
59
- //# sourceMappingURL=section-BC8LF-B2.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"section-BC8LF-B2.js","names":[],"sources":["../src/components/display/section.ts"],"sourcesContent":["import {\n ButtonBuilder,\n SectionBuilder,\n TextDisplayBuilder,\n ThumbnailBuilder,\n} from 'discord.js';\nimport { applyId } from './common';\n\n/**\n * Represents the properties for a section component.\n */\nexport interface SectionProps {\n children?: (ThumbnailBuilder | ButtonBuilder | TextDisplayBuilder)[];\n id?: number;\n}\n\n/**\n * The components v2 section component\n * @param props The properties for the section component.\n * @returns The section builder instance.\n * @example ```tsx\n * import { Section } from 'commandkit';\n *\n * const section = <Section>...</Section>;\n * ```\n */\nexport function Section(props: SectionProps): SectionBuilder {\n const section = new SectionBuilder();\n\n applyId(props, section);\n\n if (props.children != null) {\n if (!Array.isArray(props.children)) props.children = [props.children];\n for (const accessory of props.children.flat()) {\n if (accessory instanceof ThumbnailBuilder) {\n section.setThumbnailAccessory(accessory);\n } else if (accessory instanceof ButtonBuilder) {\n section.setButtonAccessory(accessory);\n } else if (accessory instanceof TextDisplayBuilder) {\n section.addTextDisplayComponents(accessory);\n }\n }\n }\n\n return section;\n}\n\n/**\n * Represents the properties for a thumbnail component.\n */\nexport interface ThumbnailProps {\n id?: number;\n description?: string;\n spoiler?: boolean;\n url: string;\n}\n\n/**\n * The thumbnail component\n * @param props The properties for the thumbnail component.\n * @returns The thumbnail builder instance.\n * @example ```tsx\n * import { Thumbnail } from 'commandkit';\n *\n * const thumbnail = <Thumbnail url=\"https://example.com/image.png\" description=\"An image\" />;\n * ```\n */\nexport function Thumbnail(props: ThumbnailProps) {\n const thumbnail = new ThumbnailBuilder({\n description: props.description,\n spoiler: props.spoiler,\n id: props.id,\n media: { url: props.url },\n });\n\n return thumbnail;\n}\n"],"mappings":";;;;;;;;;;;;;;;AA0BA,SAAgB,QAAQ,OAAqC;CAC3D,MAAM,UAAU,IAAI,2BAAgB;AAEpC,wBAAQ,OAAO,QAAQ;AAEvB,KAAI,MAAM,YAAY,MAAM;AAC1B,MAAI,CAAC,MAAM,QAAQ,MAAM,SAAS,CAAE,OAAM,WAAW,CAAC,MAAM,SAAS;AACrE,OAAK,MAAM,aAAa,MAAM,SAAS,MAAM,CAC3C,KAAI,qBAAqB,4BACvB,SAAQ,sBAAsB,UAAU;WAC/B,qBAAqB,yBAC9B,SAAQ,mBAAmB,UAAU;WAC5B,qBAAqB,8BAC9B,SAAQ,yBAAyB,UAAU;;AAKjD,QAAO;;;;;;;;;;;;AAuBT,SAAgB,UAAU,OAAuB;AAQ/C,QAPkB,IAAI,4BAAiB;EACrC,aAAa,MAAM;EACnB,SAAS,MAAM;EACf,IAAI,MAAM;EACV,OAAO,EAAE,KAAK,MAAM,KAAK;EAC1B,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"version.js","names":[],"sources":["../src/version.ts"],"sourcesContent":["/**\n * @private\n */\nfunction $version(): string {\n 'use macro';\n return require('../package.json').version;\n}\n\n/**\n * The current version of CommandKit.\n */\nexport const version: string = $version();\n"],"mappings":";;;;;;;;AAWA,MAAa,UAA4B"}
File without changes
File without changes
File without changes