commandkit 1.0.0-dev.20250620145559 → 1.0.0-dev.20250620150332

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 (115) hide show
  1. package/dist/{CommandKit-CGSAQCVq.js → CommandKit-Bg1f3YHm.js} +180 -12
  2. package/dist/CommandKit-Bg1f3YHm.js.map +1 -0
  3. package/dist/CommandKit.js +14 -15
  4. package/dist/{CommandKitEventsChannel-Bgw0XCOl.js → CommandKitEventsChannel-BSdcgY3Q.js} +1 -1
  5. package/dist/{CommandKitEventsChannel-Bgw0XCOl.js.map → CommandKitEventsChannel-BSdcgY3Q.js.map} +1 -1
  6. package/dist/{CommandsRouter-CJJ0_WSr.js → CommandsRouter-Bs9UuowL.js} +1 -1
  7. package/dist/{CommandsRouter-CJJ0_WSr.js.map → CommandsRouter-Bs9UuowL.js.map} +1 -1
  8. package/dist/{EventWorkerContext-CSlD9rbx.js → EventWorkerContext-DxfS_0fJ.js} +1 -1
  9. package/dist/{EventWorkerContext-CSlD9rbx.js.map → EventWorkerContext-DxfS_0fJ.js.map} +1 -1
  10. package/dist/{EventsRouter-C_J0M3uO.js → EventsRouter-B7oifgM6.js} +1 -1
  11. package/dist/{EventsRouter-C_J0M3uO.js.map → EventsRouter-B7oifgM6.js.map} +1 -1
  12. package/dist/{MessageCommandParser-Dw8jeqmB.js → MessageCommandParser-CUZrGknY.js} +1 -1
  13. package/dist/{MessageCommandParser-Dw8jeqmB.js.map → MessageCommandParser-CUZrGknY.js.map} +1 -1
  14. package/dist/analytics/analytics-engine.js +14 -15
  15. package/dist/analytics/constants.js +1 -1
  16. package/dist/analytics/utils.js +14 -15
  17. package/dist/app/commands/AppCommandRunner.js +14 -15
  18. package/dist/app/commands/Context.js +14 -15
  19. package/dist/app/commands/MessageCommandParser.js +1 -1
  20. package/dist/app/commands/helpers.js +1 -1
  21. package/dist/app/events/EventWorkerContext.js +1 -1
  22. package/dist/app/handlers/AppCommandHandler.js +14 -15
  23. package/dist/app/handlers/AppEventsHandler.js +14 -15
  24. package/dist/app/index.js +16 -17
  25. package/dist/app/interrupt/signals.js +2 -2
  26. package/dist/app/register/CommandRegistrar.js +14 -15
  27. package/dist/app/router/CommandsRouter.js +1 -1
  28. package/dist/app/router/EventsRouter.js +1 -1
  29. package/dist/app/router/index.js +3 -3
  30. package/dist/{app-process-pMHblAN_.js → app-process-kobgJPMW.js} +3 -3
  31. package/dist/{app-process-pMHblAN_.js.map → app-process-kobgJPMW.js.map} +1 -1
  32. package/dist/{build-zALOnWYu.js → build-JmLwv2AC.js} +6 -7
  33. package/dist/{build-zALOnWYu.js.map → build-JmLwv2AC.js.map} +1 -1
  34. package/dist/cli/app-process.js +4 -4
  35. package/dist/cli/build.js +17 -18
  36. package/dist/cli/common.js +2 -2
  37. package/dist/cli/development.js +18 -19
  38. package/dist/cli/development.js.map +1 -1
  39. package/dist/cli/env.js +1 -1
  40. package/dist/cli/generators.js +2 -2
  41. package/dist/cli/information.js +1 -1
  42. package/dist/cli/init.js +15 -16
  43. package/dist/cli/production.js +19 -20
  44. package/dist/cli/production.js.map +1 -1
  45. package/dist/cli/type-checker.js +3 -3
  46. package/dist/cli/utils.js +1 -1
  47. package/dist/{common-CfxtI2et.js → common-DUta5JO9.js} +2 -2
  48. package/dist/{common-CfxtI2et.js.map → common-DUta5JO9.js.map} +1 -1
  49. package/dist/components/index.js +14 -15
  50. package/dist/components/v1/button/Button.js +14 -15
  51. package/dist/components/v1/button/ButtonKit.js +14 -15
  52. package/dist/components/v1/modal/Modal.js +14 -15
  53. package/dist/components/v1/modal/ModalKit.js +14 -15
  54. package/dist/components/v1/select-menu/ChannelSelectMenuKit.js +14 -15
  55. package/dist/components/v1/select-menu/MentionableSelectMenuKit.js +14 -15
  56. package/dist/components/v1/select-menu/RoleSelectMenuKit.js +14 -15
  57. package/dist/components/v1/select-menu/SelectMenu.js +14 -15
  58. package/dist/components/v1/select-menu/StringSelectMenuKit.js +14 -15
  59. package/dist/components/v1/select-menu/UserSelectMenuKit.js +14 -15
  60. package/dist/config/config.js +14 -15
  61. package/dist/config/default.js +14 -15
  62. package/dist/config/loader.js +14 -15
  63. package/dist/{constants-CUND8XkG.js → constants-R96vEAFD.js} +1 -1
  64. package/dist/{constants-CUND8XkG.js.map → constants-R96vEAFD.js.map} +1 -1
  65. package/dist/context/async-context.js +14 -15
  66. package/dist/context/environment.js +14 -15
  67. package/dist/{env-_68PRRoA.js → env-DakvrBzy.js} +1 -1
  68. package/dist/{env-_68PRRoA.js.map → env-DakvrBzy.js.map} +1 -1
  69. package/dist/events/CommandKitEventsChannel.js +1 -1
  70. package/dist/{feature-flags-cY5-mCX0.js → feature-flags-M80Ab_1D.js} +4 -4
  71. package/dist/{feature-flags-cY5-mCX0.js.map → feature-flags-M80Ab_1D.js.map} +1 -1
  72. package/dist/flags/feature-flags.js +15 -16
  73. package/dist/flags/store.js +1 -1
  74. package/dist/{helpers-BUlN3lIz.js → helpers-DfV6HlgI.js} +1 -1
  75. package/dist/{helpers-BUlN3lIz.js.map → helpers-DfV6HlgI.js.map} +1 -1
  76. package/dist/index.js +21 -22
  77. package/dist/index.js.map +1 -1
  78. package/dist/{init-D77HLYw2.js → init-D_en8rGZ.js} +5 -6
  79. package/dist/{init-D77HLYw2.js.map → init-D_en8rGZ.js.map} +1 -1
  80. package/dist/logger/DefaultLogger.js +14 -15
  81. package/dist/logger/ILogger.js +1 -1
  82. package/dist/logger/Logger.js +14 -15
  83. package/dist/plugins/index.js +15 -16
  84. package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.js +14 -15
  85. package/dist/plugins/plugin-runtime/CompilerPluginRuntime.js +35 -2
  86. package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.js +14 -15
  87. package/dist/plugins/plugin-runtime/builtin/MacroPlugin.js +14 -15
  88. package/dist/plugins/plugin-runtime/runtime.js +1 -1
  89. package/dist/{resolve-file-url-DHTQj2mU.js → resolve-file-url-9aPt6A_n.js} +1 -1
  90. package/dist/{resolve-file-url-DHTQj2mU.js.map → resolve-file-url-9aPt6A_n.js.map} +1 -1
  91. package/dist/{signals-CMIyUXUZ.js → signals-lSAO5hOr.js} +2 -2
  92. package/dist/{signals-CMIyUXUZ.js.map → signals-lSAO5hOr.js.map} +1 -1
  93. package/dist/{store-CiqLHedg.js → store-CyzliDXj.js} +1 -1
  94. package/dist/{store-CiqLHedg.js.map → store-CyzliDXj.js.map} +1 -1
  95. package/dist/{type-checker-BLpiXCUL.js → type-checker-BhbQMKkv.js} +2 -2
  96. package/dist/{type-checker-BLpiXCUL.js.map → type-checker-BhbQMKkv.js.map} +1 -1
  97. package/dist/{types-package-BY7QWDFc.js → types-package-MDczrp9f.js} +1 -1
  98. package/dist/{types-package-BY7QWDFc.js.map → types-package-MDczrp9f.js.map} +1 -1
  99. package/dist/utils/dev-hooks.js +14 -15
  100. package/dist/utils/resolve-file-url.js +1 -1
  101. package/dist/utils/types-package.js +1 -1
  102. package/dist/utils/utilities.js +14 -15
  103. package/dist/{utils-DCSnVAZ6.js → utils-n4MoGDDR.js} +1 -1
  104. package/dist/{utils-DCSnVAZ6.js.map → utils-n4MoGDDR.js.map} +1 -1
  105. package/dist/{version-DdoVtSAc.js → version-YuWSVn4x.js} +2 -2
  106. package/dist/{version-DdoVtSAc.js.map → version-YuWSVn4x.js.map} +1 -1
  107. package/dist/version.js +1 -1
  108. package/package.json +2 -2
  109. package/dist/CommandKit-CGSAQCVq.js.map +0 -1
  110. package/dist/CompilerPluginRuntime-OliJW0v-.js +0 -171
  111. package/dist/CompilerPluginRuntime-OliJW0v-.js.map +0 -1
  112. /package/dist/{ILogger-dQ7Y9X1f.js → ILogger-BMIMljYD.js} +0 -0
  113. /package/dist/{app-HN1cVg8J.js → app-gCenKq8k.js} +0 -0
  114. /package/dist/{router-DHnFRADH.js → router-wA3kFzES.js} +0 -0
  115. /package/dist/{runtime-DB9CiPfe.js → runtime-5fxB4uhe.js} +0 -0
@@ -6,17 +6,17 @@ const require_EventInterceptor = require('./EventInterceptor-CQ4PBpBJ.js');
6
6
  const require_constants = require('./constants-BttALJIr.js');
7
7
  const require_CompilerPlugin = require('./CompilerPlugin-CjoZAAR8.js');
8
8
  const require_RuntimePlugin = require('./RuntimePlugin-CBgBLXTG.js');
9
- const require_resolve_file_url = require('./resolve-file-url-DHTQj2mU.js');
10
- const require_types_package = require('./types-package-BY7QWDFc.js');
11
- const require_EventWorkerContext = require('./EventWorkerContext-CSlD9rbx.js');
12
- const require_signals = require('./signals-CMIyUXUZ.js');
13
- const require_constants$1 = require('./constants-CUND8XkG.js');
14
- const require_MessageCommandParser = require('./MessageCommandParser-Dw8jeqmB.js');
15
- const require_CommandsRouter = require('./CommandsRouter-CJJ0_WSr.js');
16
- const require_EventsRouter = require('./EventsRouter-C_J0M3uO.js');
17
- const require_common = require('./common-CfxtI2et.js');
18
- const require_CommandKitEventsChannel = require('./CommandKitEventsChannel-Bgw0XCOl.js');
19
- const require_store = require('./store-CiqLHedg.js');
9
+ const require_resolve_file_url = require('./resolve-file-url-9aPt6A_n.js');
10
+ const require_types_package = require('./types-package-MDczrp9f.js');
11
+ const require_EventWorkerContext = require('./EventWorkerContext-DxfS_0fJ.js');
12
+ const require_signals = require('./signals-lSAO5hOr.js');
13
+ const require_constants$1 = require('./constants-R96vEAFD.js');
14
+ const require_MessageCommandParser = require('./MessageCommandParser-CUZrGknY.js');
15
+ const require_CommandsRouter = require('./CommandsRouter-Bs9UuowL.js');
16
+ const require_EventsRouter = require('./EventsRouter-B7oifgM6.js');
17
+ const require_common = require('./common-DUta5JO9.js');
18
+ const require_CommandKitEventsChannel = require('./CommandKitEventsChannel-BSdcgY3Q.js');
19
+ const require_store = require('./store-CyzliDXj.js');
20
20
  const node_events = require_chunk.__toESM(require("node:events"));
21
21
  const discord_js = require_chunk.__toESM(require("discord.js"));
22
22
  const node_async_hooks = require_chunk.__toESM(require("node:async_hooks"));
@@ -1469,6 +1469,168 @@ var CommandKitPluginRuntime = class {
1469
1469
  }
1470
1470
  };
1471
1471
 
1472
+ //#endregion
1473
+ //#region src/plugins/plugin-runtime/CompilerPluginRuntime.ts
1474
+ /**
1475
+ * Enum representing the execution mode of a plugin.
1476
+ * It can be either 'activate' or 'deactivate'.
1477
+ * @private
1478
+ */
1479
+ var PluginExecutionMode = /* @__PURE__ */ function(PluginExecutionMode$1) {
1480
+ PluginExecutionMode$1["Activate"] = "activate";
1481
+ PluginExecutionMode$1["Deactivate"] = "deactivate";
1482
+ return PluginExecutionMode$1;
1483
+ }(PluginExecutionMode || {});
1484
+ /**
1485
+ * CompilerPluginRuntime is a runtime for managing compiler plugins in CommandKit.
1486
+ */
1487
+ var CompilerPluginRuntime = class {
1488
+ name = "CompilerPluginRuntime";
1489
+ initialized = false;
1490
+ templates = /* @__PURE__ */ new Map();
1491
+ #pluginContext = new node_async_hooks.AsyncLocalStorage();
1492
+ /**
1493
+ * Creates a new instance of CompilerPluginRuntime.
1494
+ * @param plugins An array of compiler plugins to be managed by this runtime.
1495
+ */
1496
+ constructor(plugins) {
1497
+ this.plugins = plugins;
1498
+ this.plugins = this.plugins.filter((p) => !!p && require_CompilerPlugin.isCompilerPlugin(p));
1499
+ }
1500
+ /**
1501
+ * Returns the plugins managed by this runtime.
1502
+ */
1503
+ getPlugins() {
1504
+ return this.plugins;
1505
+ }
1506
+ /**
1507
+ * Checks if there are no plugins registered in this runtime.
1508
+ */
1509
+ isEmpty() {
1510
+ return !this.plugins.length;
1511
+ }
1512
+ /**
1513
+ * Registers a template handler for a given name.
1514
+ * This method must be called inside the activate() method of a plugin.
1515
+ * @param name - The name of the template to register.
1516
+ * @param handler - The handler function for the template.
1517
+ */
1518
+ registerTemplate(name, handler) {
1519
+ const ctx = this.#pluginContext.getStore();
1520
+ if (!ctx || ctx.mode !== PluginExecutionMode.Activate) throw new Error("registerTemplate() must be called inside activate() method");
1521
+ if (this.templates.has(name)) throw new Error(`Template "${name}" already exists`);
1522
+ this.templates.set(name, {
1523
+ handler,
1524
+ plugin: ctx.plugin
1525
+ });
1526
+ }
1527
+ /**
1528
+ * Unregisters a template handler for a given name.
1529
+ * This method must be called inside the deactivate() method of a plugin.
1530
+ * @param name - The name of the template to unregister.
1531
+ */
1532
+ unregisterTemplate(name) {
1533
+ const ctx = this.#pluginContext.getStore();
1534
+ if (!ctx || ctx.mode !== PluginExecutionMode.Deactivate) throw new Error("unregisterTemplate() must be called inside deactivate() method");
1535
+ const template = this.templates.get(name);
1536
+ if (!template) throw new Error(`Template "${name}" does not exist`);
1537
+ if (template.plugin !== ctx.plugin) throw new Error(`Template "${name}" is owned by plugin "${template.plugin.name}" and cannot be unregistered by "${ctx.plugin.name}"`);
1538
+ this.templates.delete(name);
1539
+ }
1540
+ /**
1541
+ * Retrieves a template handler by its name.
1542
+ * @param name - The name of the template to retrieve.
1543
+ * @returns The template handler if found, otherwise undefined.
1544
+ */
1545
+ getTemplate(name) {
1546
+ var _this$templates$get;
1547
+ return (_this$templates$get = this.templates.get(name)) === null || _this$templates$get === void 0 ? void 0 : _this$templates$get.handler;
1548
+ }
1549
+ /**
1550
+ * Returns a map of all registered templates with their handlers.
1551
+ * The keys are the template names and the values are the template handlers.
1552
+ */
1553
+ getTemplates() {
1554
+ return new Map(Array.from(this.templates.entries()).map(([name, entry]) => [name, entry.handler]));
1555
+ }
1556
+ /**
1557
+ * Transforms the given code using all registered plugins.
1558
+ * Each plugin's transform method is called in sequence, allowing them to modify the code.
1559
+ * @param code - The code to be transformed.
1560
+ * @param id - The identifier for the code being transformed (e.g., filename).
1561
+ * @returns An object containing the transformed code and an optional source map.
1562
+ */
1563
+ async transform(code, id) {
1564
+ let map = null;
1565
+ for (const plugin of this.plugins) try {
1566
+ var _plugin$transform;
1567
+ const res = await ((_plugin$transform = plugin.transform) === null || _plugin$transform === void 0 ? void 0 : _plugin$transform.call(plugin, {
1568
+ code,
1569
+ id
1570
+ }));
1571
+ if (!res) continue;
1572
+ if (res.code) code = res.code;
1573
+ if (res.map) map = res.map;
1574
+ } catch (e) {
1575
+ const err = e instanceof Error ? e : new Error(e);
1576
+ throw new Error(`Plugin ${plugin.name} failed to transform: ${err.message}`);
1577
+ }
1578
+ return {
1579
+ code,
1580
+ map
1581
+ };
1582
+ }
1583
+ /**
1584
+ * Initializes the plugin runtime by activating all registered plugins.
1585
+ * This method should be called once to set up the plugins.
1586
+ */
1587
+ async init() {
1588
+ if (this.initialized) return;
1589
+ for (const plugin of this.plugins) try {
1590
+ await this.#pluginContext.run({
1591
+ plugin,
1592
+ mode: PluginExecutionMode.Activate
1593
+ }, async () => {
1594
+ var _plugin$activate;
1595
+ await ((_plugin$activate = plugin.activate) === null || _plugin$activate === void 0 ? void 0 : _plugin$activate.call(plugin, this));
1596
+ });
1597
+ } catch (e) {
1598
+ console.error(`Plugin ${plugin.name} failed to activate with ${(e === null || e === void 0 ? void 0 : e.stack) || e}`);
1599
+ }
1600
+ this.initialized = true;
1601
+ }
1602
+ /**
1603
+ * Destroys the plugin runtime by deactivating all registered plugins.
1604
+ * This method should be called when the runtime is no longer needed.
1605
+ */
1606
+ async destroy() {
1607
+ if (!this.initialized) return;
1608
+ for (const plugin of this.plugins) try {
1609
+ await this.#pluginContext.run({
1610
+ plugin,
1611
+ mode: PluginExecutionMode.Deactivate
1612
+ }, async () => {
1613
+ var _plugin$deactivate;
1614
+ await ((_plugin$deactivate = plugin.deactivate) === null || _plugin$deactivate === void 0 ? void 0 : _plugin$deactivate.call(plugin, this));
1615
+ });
1616
+ } catch (e) {
1617
+ console.error(`Plugin ${plugin.name} failed to deactivate with ${(e === null || e === void 0 ? void 0 : e.stack) || e}`);
1618
+ }
1619
+ this.initialized = false;
1620
+ }
1621
+ /**
1622
+ * Converts the plugin runtime to a JSON representation.
1623
+ * This is useful for serialization or debugging purposes.
1624
+ * @returns An object containing the name of the runtime and the transform method.
1625
+ */
1626
+ toJSON() {
1627
+ return {
1628
+ name: this.name,
1629
+ transform: this.transform.bind(this)
1630
+ };
1631
+ }
1632
+ };
1633
+
1472
1634
  //#endregion
1473
1635
  //#region src/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.ts
1474
1636
  /**
@@ -3812,6 +3974,12 @@ Object.defineProperty(exports, 'CommonDirectiveTransformer', {
3812
3974
  return CommonDirectiveTransformer;
3813
3975
  }
3814
3976
  });
3977
+ Object.defineProperty(exports, 'CompilerPluginRuntime', {
3978
+ enumerable: true,
3979
+ get: function () {
3980
+ return CompilerPluginRuntime;
3981
+ }
3982
+ });
3815
3983
  Object.defineProperty(exports, 'Context', {
3816
3984
  enumerable: true,
3817
3985
  get: function () {
@@ -4100,4 +4268,4 @@ Object.defineProperty(exports, 'useEnvironment', {
4100
4268
  return useEnvironment;
4101
4269
  }
4102
4270
  });
4103
- //# sourceMappingURL=CommandKit-CGSAQCVq.js.map
4271
+ //# sourceMappingURL=CommandKit-Bg1f3YHm.js.map