commandkit 1.0.0-dev.20250601124817 → 1.0.0-dev.20250601132421

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 (95) hide show
  1. package/dist/{CommandKit-DbKHr6qT.js → CommandKit-BhdXwM9b.js} +90 -15
  2. package/dist/CommandKit-BhdXwM9b.js.map +1 -0
  3. package/dist/{CommandKit-DDSUNOAe.d.ts → CommandKit-Dbkak3_n.d.ts} +11 -8
  4. package/dist/CommandKit.d.ts +1 -1
  5. package/dist/CommandKit.js +2 -7
  6. package/dist/{EventWorkerContext-CjU5wt-a.d.ts → EventWorkerContext-6BHysn1E.d.ts} +2 -2
  7. package/dist/app/commands/AppCommandRunner.d.ts +1 -1
  8. package/dist/app/commands/AppCommandRunner.js +1 -1
  9. package/dist/app/commands/Context.d.ts +1 -1
  10. package/dist/app/commands/Context.js +1 -1
  11. package/dist/app/events/EventWorkerContext.d.ts +2 -2
  12. package/dist/app/handlers/AppCommandHandler.d.ts +1 -1
  13. package/dist/app/handlers/AppCommandHandler.js +1 -1
  14. package/dist/app/handlers/AppEventsHandler.d.ts +1 -1
  15. package/dist/app/handlers/AppEventsHandler.js +1 -1
  16. package/dist/app/index.d.ts +1 -1
  17. package/dist/app/index.js +1 -1
  18. package/dist/app/register/CommandRegistrar.d.ts +1 -1
  19. package/dist/app/register/CommandRegistrar.js +1 -1
  20. package/dist/{build-BB9ezwQN.js → build-D45Rr7KV.js} +10 -6
  21. package/dist/{build-BB9ezwQN.js.map → build-D45Rr7KV.js.map} +1 -1
  22. package/dist/cli/app-process.d.ts +2 -2
  23. package/dist/cli/build.d.ts +1 -1
  24. package/dist/cli/build.js +2 -2
  25. package/dist/cli/common.d.ts +5 -5
  26. package/dist/cli/development.js +2 -2
  27. package/dist/cli/information.js +1 -1
  28. package/dist/cli/init.d.ts +1 -1
  29. package/dist/cli/init.js +2 -2
  30. package/dist/cli/production.d.ts +2 -2
  31. package/dist/cli/production.js +2 -2
  32. package/dist/components/index.js +1 -1
  33. package/dist/components/v1/button/Button.js +1 -1
  34. package/dist/components/v1/button/ButtonKit.js +1 -1
  35. package/dist/components/v1/modal/Modal.js +1 -1
  36. package/dist/components/v1/modal/ModalKit.js +1 -1
  37. package/dist/components/v1/select-menu/ChannelSelectMenuKit.js +1 -1
  38. package/dist/components/v1/select-menu/MentionableSelectMenuKit.js +1 -1
  39. package/dist/components/v1/select-menu/RoleSelectMenuKit.js +1 -1
  40. package/dist/components/v1/select-menu/SelectMenu.js +1 -1
  41. package/dist/components/v1/select-menu/StringSelectMenuKit.js +1 -1
  42. package/dist/components/v1/select-menu/UserSelectMenuKit.js +1 -1
  43. package/dist/config/config.d.ts +4 -4
  44. package/dist/config/config.js +1 -1
  45. package/dist/config/default.d.ts +3 -3
  46. package/dist/config/default.js +1 -1
  47. package/dist/config/loader.d.ts +3 -3
  48. package/dist/config/loader.js +1 -1
  49. package/dist/config/types.d.ts +2 -2
  50. package/dist/config/utils.d.ts +3 -3
  51. package/dist/{config-LPxTebft.d.ts → config-1zOALegW.d.ts} +3 -3
  52. package/dist/context/async-context.d.ts +1 -1
  53. package/dist/context/async-context.js +1 -1
  54. package/dist/context/environment.d.ts +1 -1
  55. package/dist/context/environment.js +1 -1
  56. package/dist/events/CommandKitEventsChannel.d.ts +1 -1
  57. package/dist/{feature-flags-DqKVc2-p.js → feature-flags-xogLBr7K.js} +2 -2
  58. package/dist/{feature-flags-DqKVc2-p.js.map → feature-flags-xogLBr7K.js.map} +1 -1
  59. package/dist/flags/feature-flags.d.ts +1 -1
  60. package/dist/flags/feature-flags.js +2 -2
  61. package/dist/flags/store.d.ts +1 -1
  62. package/dist/index.d.ts +7 -7
  63. package/dist/index.js +5 -10
  64. package/dist/{init-O2deAczC.js → init-B6_jkuag.js} +2 -2
  65. package/dist/{init-O2deAczC.js.map → init-B6_jkuag.js.map} +1 -1
  66. package/dist/{init-CEa28dgv.d.ts → init-CT348Okf.d.ts} +3 -3
  67. package/dist/logger/DefaultLogger.js +1 -1
  68. package/dist/logger/Logger.js +1 -1
  69. package/dist/plugins/CompilerPlugin.d.ts +1 -1
  70. package/dist/plugins/PluginCommon.d.ts +1 -1
  71. package/dist/plugins/RuntimePlugin.d.ts +1 -1
  72. package/dist/plugins/index.d.ts +1 -1
  73. package/dist/plugins/index.js +1 -1
  74. package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.d.ts +1 -1
  75. package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.js +1 -1
  76. package/dist/plugins/plugin-runtime/CompilerPluginRuntime.d.ts +1 -1
  77. package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.d.ts +1 -1
  78. package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.js +1 -1
  79. package/dist/plugins/plugin-runtime/builtin/MacroPlugin.d.ts +1 -1
  80. package/dist/plugins/plugin-runtime/builtin/MacroPlugin.js +1 -1
  81. package/dist/plugins/plugin-runtime/runtime.d.ts +1 -1
  82. package/dist/plugins/types.d.ts +1 -1
  83. package/dist/{types-w2bWHUve.d.ts → types-BiXh_it_.d.ts} +2 -2
  84. package/dist/types.d.ts +1 -1
  85. package/dist/{utilities-oDL3vjhR.d.ts → utilities-DpA7EalK.d.ts} +12 -2
  86. package/dist/utils/dev-hooks.d.ts +1 -1
  87. package/dist/utils/dev-hooks.js +1 -1
  88. package/dist/utils/utilities.d.ts +2 -2
  89. package/dist/utils/utilities.js +2 -1
  90. package/dist/{utils-Dprjd7Oz.d.ts → utils-IW7KDBhF.d.ts} +2 -2
  91. package/dist/{version-BLxI87nt.js → version-B_LxfzVV.js} +2 -2
  92. package/dist/{version-BLxI87nt.js.map → version-B_LxfzVV.js.map} +1 -1
  93. package/dist/version.js +1 -1
  94. package/package.json +2 -2
  95. package/dist/CommandKit-DbKHr6qT.js.map +0 -1
@@ -1448,6 +1448,61 @@ function stopEvents() {
1448
1448
  if (!require_EventWorkerContext.eventWorkerContext.getStore()) throw new Error("stopEvents() may only be called inside an event handler");
1449
1449
  throw new StopEventPropagationError();
1450
1450
  }
1451
+ /**
1452
+ * Creates a simple proxy object that mirrors the target object.
1453
+ * @param target The target object to proxy.
1454
+ * @returns The proxied object.
1455
+ */
1456
+ function createProxy(target) {
1457
+ let _target = target;
1458
+ const proxy = new Proxy(_target, {
1459
+ get(target$1, prop, receiver) {
1460
+ return Reflect.get(_target, prop, receiver);
1461
+ },
1462
+ set(target$1, prop, value, receiver) {
1463
+ return Reflect.set(_target, prop, value, receiver);
1464
+ },
1465
+ deleteProperty(target$1, prop) {
1466
+ return Reflect.deleteProperty(_target, prop);
1467
+ },
1468
+ has(target$1, prop) {
1469
+ return Reflect.has(_target, prop);
1470
+ },
1471
+ ownKeys(target$1) {
1472
+ return Reflect.ownKeys(_target);
1473
+ },
1474
+ getOwnPropertyDescriptor(target$1, prop) {
1475
+ return Reflect.getOwnPropertyDescriptor(_target, prop);
1476
+ },
1477
+ defineProperty(target$1, prop, attributes) {
1478
+ return Reflect.defineProperty(_target, prop, attributes);
1479
+ },
1480
+ getPrototypeOf(target$1) {
1481
+ return Reflect.getPrototypeOf(_target);
1482
+ },
1483
+ setPrototypeOf(target$1, proto) {
1484
+ return Reflect.setPrototypeOf(_target, proto);
1485
+ },
1486
+ isExtensible(target$1) {
1487
+ return Reflect.isExtensible(_target);
1488
+ },
1489
+ preventExtensions(target$1) {
1490
+ return Reflect.preventExtensions(_target);
1491
+ },
1492
+ apply(target$1, thisArg, args) {
1493
+ return Reflect.apply(_target, thisArg, args);
1494
+ },
1495
+ construct(target$1, args, newTarget) {
1496
+ return Reflect.construct(_target, args, newTarget);
1497
+ }
1498
+ });
1499
+ return {
1500
+ proxy,
1501
+ setTarget(newTarget) {
1502
+ _target = newTarget;
1503
+ }
1504
+ };
1505
+ }
1451
1506
 
1452
1507
  //#endregion
1453
1508
  //#region src/app/register/CommandRegistrar.ts
@@ -2685,7 +2740,6 @@ function registerDevHooks(commandkit$1) {
2685
2740
 
2686
2741
  //#endregion
2687
2742
  //#region src/CommandKit.ts
2688
- let commandkit;
2689
2743
  const bootstrapHooks = /* @__PURE__ */ new Set();
2690
2744
  const onApplicationBootstrapHooks = /* @__PURE__ */ new Set();
2691
2745
  /**
@@ -2722,7 +2776,8 @@ function onApplicationBootstrap(fn) {
2722
2776
  }
2723
2777
  var CommandKit = class CommandKit extends node_events.default {
2724
2778
  #started = false;
2725
- options;
2779
+ #clientProxy = createProxy({});
2780
+ #client;
2726
2781
  eventInterceptor;
2727
2782
  static createElement = require_element.createElement;
2728
2783
  static Fragment = require_element.Fragment;
@@ -2745,14 +2800,12 @@ var CommandKit = class CommandKit extends node_events.default {
2745
2800
  * @param options - The default CommandKit configuration.
2746
2801
  * @see {@link https://commandkit.js.org/docs/guide/commandkit-setup}
2747
2802
  */
2748
- constructor(options) {
2803
+ constructor(options = {}) {
2749
2804
  if (CommandKit.instance) process.emitWarning("CommandKit instance already exists. Having multiple instance in same project is discouraged and it may lead to unexpected behavior.", { code: "MultiInstanceWarning" });
2750
- if (!options.client) throw new Error(require_colors.colors_default.red("\"client\" is required when instantiating CommandKit."));
2751
2805
  super();
2752
- this.options = options;
2753
2806
  if (!CommandKit.instance) CommandKit.instance = this;
2807
+ if (options === null || options === void 0 ? void 0 : options.client) this.setClient(options.client);
2754
2808
  this.plugins = new CommandKitPluginRuntime(this);
2755
- commandkit = CommandKit.instance;
2756
2809
  this.#bootstrapHooks();
2757
2810
  }
2758
2811
  async #bootstrapHooks() {
@@ -2781,7 +2834,7 @@ var CommandKit = class CommandKit extends node_events.default {
2781
2834
  */
2782
2835
  async start(token) {
2783
2836
  if (this.#started) return;
2784
- if (!this.options.client) throw new Error(require_colors.colors_default.red("\"client\" is required when starting CommandKit."));
2837
+ if (!this.#client) throw new Error(require_colors.colors_default.red("\"client\" is required when starting CommandKit."));
2785
2838
  this.eventInterceptor = new require_EventInterceptor.EventInterceptor(this.client);
2786
2839
  if (require_constants.COMMANDKIT_IS_DEV) try {
2787
2840
  registerDevHooks(this);
@@ -2793,7 +2846,7 @@ var CommandKit = class CommandKit extends node_events.default {
2793
2846
  await this.#init();
2794
2847
  this.commandHandler.registerCommandHandler();
2795
2848
  this.incrementClientListenersCount();
2796
- if (token !== false && !this.options.client.isReady()) {
2849
+ if (token !== false && !this.client.isReady()) {
2797
2850
  this.client.once(discord_js.Events.ClientReady, async () => {
2798
2851
  await this.commandHandler.registrar.register();
2799
2852
  });
@@ -2801,13 +2854,13 @@ var CommandKit = class CommandKit extends node_events.default {
2801
2854
  var _plugin$onBeforeClien;
2802
2855
  return (_plugin$onBeforeClien = plugin.onBeforeClientLogin) === null || _plugin$onBeforeClien === void 0 ? void 0 : _plugin$onBeforeClien.call(plugin, ctx);
2803
2856
  });
2804
- const botToken = token ?? this.options.client.token ?? process.env.TOKEN ?? process.env.DISCORD_TOKEN;
2805
- await this.options.client.login(botToken);
2857
+ const botToken = token ?? this.client.token ?? process.env.TOKEN ?? process.env.DISCORD_TOKEN;
2858
+ await this.client.login(botToken);
2806
2859
  await this.plugins.execute((ctx, plugin) => {
2807
2860
  var _plugin$onAfterClient;
2808
2861
  return (_plugin$onAfterClient = plugin.onAfterClientLogin) === null || _plugin$onAfterClient === void 0 ? void 0 : _plugin$onAfterClient.call(plugin, ctx);
2809
2862
  });
2810
- } else if (this.options.client.isReady()) await this.commandHandler.registrar.register();
2863
+ } else if (this.client.isReady()) await this.commandHandler.registrar.register();
2811
2864
  this.#started = true;
2812
2865
  await this.#applicationBootstrapHooks();
2813
2866
  }
@@ -2846,7 +2899,22 @@ var CommandKit = class CommandKit extends node_events.default {
2846
2899
  * Get the client attached to this CommandKit instance.
2847
2900
  */
2848
2901
  get client() {
2849
- return this.options.client;
2902
+ var _this$clientProxy;
2903
+ const client = this.#client || ((_this$clientProxy = this.#clientProxy) === null || _this$clientProxy === void 0 ? void 0 : _this$clientProxy.proxy);
2904
+ if (!client) throw new Error("Client instance is not set");
2905
+ return client;
2906
+ }
2907
+ /**
2908
+ * Sets the client attached to this CommandKit instance.
2909
+ * @param client The client to set.
2910
+ */
2911
+ setClient(client) {
2912
+ this.#client = client;
2913
+ if (this.#clientProxy) {
2914
+ this.#clientProxy.setTarget(client);
2915
+ this.#clientProxy = null;
2916
+ }
2917
+ return this;
2850
2918
  }
2851
2919
  async #init() {
2852
2920
  const appDir$1 = this.getAppDirectory();
@@ -2895,13 +2963,13 @@ var CommandKit = class CommandKit extends node_events.default {
2895
2963
  * Increment the client listeners count.
2896
2964
  */
2897
2965
  incrementClientListenersCount() {
2898
- this.options.client.setMaxListeners(this.options.client.getMaxListeners() + 1);
2966
+ this.client.setMaxListeners(this.client.getMaxListeners() + 1);
2899
2967
  }
2900
2968
  /**
2901
2969
  * Decrement the client listeners count.
2902
2970
  */
2903
2971
  decrementClientListenersCount() {
2904
- this.options.client.setMaxListeners(this.options.client.getMaxListeners() - 1);
2972
+ this.client.setMaxListeners(this.client.getMaxListeners() - 1);
2905
2973
  }
2906
2974
  /**
2907
2975
  * Path to the app directory. Returns `null` if not found.
@@ -2922,6 +2990,7 @@ var CommandKit = class CommandKit extends node_events.default {
2922
2990
  }
2923
2991
  }
2924
2992
  };
2993
+ const commandkit = CommandKit.instance || new CommandKit();
2925
2994
 
2926
2995
  //#endregion
2927
2996
  Object.defineProperty(exports, 'AppCommandHandler', {
@@ -3152,6 +3221,12 @@ Object.defineProperty(exports, 'createLogger', {
3152
3221
  return createLogger;
3153
3222
  }
3154
3223
  });
3224
+ Object.defineProperty(exports, 'createProxy', {
3225
+ enumerable: true,
3226
+ get: function () {
3227
+ return createProxy;
3228
+ }
3229
+ });
3155
3230
  Object.defineProperty(exports, 'debounce', {
3156
3231
  enumerable: true,
3157
3232
  get: function () {
@@ -3278,4 +3353,4 @@ Object.defineProperty(exports, 'useEnvironment', {
3278
3353
  return useEnvironment;
3279
3354
  }
3280
3355
  });
3281
- //# sourceMappingURL=CommandKit-DbKHr6qT.js.map
3356
+ //# sourceMappingURL=CommandKit-BhdXwM9b.js.map