commandkit 1.0.0-dev.20250511080231 → 1.0.0-dev.20250512141520

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.
package/dist/index.js CHANGED
@@ -59,75 +59,6 @@ var init_colors = __esm({
59
59
  }
60
60
  });
61
61
 
62
- // src/cache/CacheProvider.ts
63
- var _CacheProvider, CacheProvider;
64
- var init_CacheProvider = __esm({
65
- "src/cache/CacheProvider.ts"() {
66
- "use strict";
67
- init_cjs_shims();
68
- _CacheProvider = class _CacheProvider {
69
- };
70
- __name(_CacheProvider, "CacheProvider");
71
- CacheProvider = _CacheProvider;
72
- }
73
- });
74
-
75
- // src/cache/MemoryCache.ts
76
- var _cache, _MemoryCache, MemoryCache;
77
- var init_MemoryCache = __esm({
78
- "src/cache/MemoryCache.ts"() {
79
- "use strict";
80
- init_cjs_shims();
81
- init_CacheProvider();
82
- _MemoryCache = class _MemoryCache extends CacheProvider {
83
- constructor() {
84
- super(...arguments);
85
- __privateAdd(this, _cache, /* @__PURE__ */ new Map());
86
- }
87
- async get(key) {
88
- const entry = __privateGet(this, _cache).get(key);
89
- if (!entry) {
90
- return void 0;
91
- }
92
- if (entry.ttl && Date.now() > entry.ttl) {
93
- __privateGet(this, _cache).delete(key);
94
- return void 0;
95
- }
96
- return entry;
97
- }
98
- async set(key, value, ttl) {
99
- const entry = {
100
- value,
101
- ttl: ttl != null ? Date.now() + ttl : void 0
102
- };
103
- __privateGet(this, _cache).set(key, entry);
104
- }
105
- async exists(key) {
106
- return __privateGet(this, _cache).has(key);
107
- }
108
- async delete(key) {
109
- __privateGet(this, _cache).delete(key);
110
- }
111
- async clear() {
112
- __privateGet(this, _cache).clear();
113
- }
114
- async expire(key, ttl) {
115
- const entry = __privateGet(this, _cache).get(key);
116
- if (!entry) return;
117
- const _ttl = Date.now() + ttl;
118
- if (_ttl < Date.now()) {
119
- __privateGet(this, _cache).delete(key);
120
- return;
121
- }
122
- entry.ttl = _ttl;
123
- }
124
- };
125
- _cache = new WeakMap();
126
- __name(_MemoryCache, "MemoryCache");
127
- MemoryCache = _MemoryCache;
128
- }
129
- });
130
-
131
62
  // src/components/v1/action-row/ActionRow.ts
132
63
  function ActionRow(props) {
133
64
  const row = new import_discord.ActionRowBuilder();
@@ -2087,15 +2018,21 @@ var init_constants = __esm({
2087
2018
  });
2088
2019
 
2089
2020
  // src/plugins/PluginCommon.ts
2090
- var _PluginCommon, PluginCommon;
2021
+ function isPlugin(plugin) {
2022
+ return plugin instanceof PluginCommon;
2023
+ }
2024
+ var import_node_crypto, _PluginCommon, PluginCommon;
2091
2025
  var init_PluginCommon = __esm({
2092
2026
  "src/plugins/PluginCommon.ts"() {
2093
2027
  "use strict";
2094
2028
  init_cjs_shims();
2029
+ import_node_crypto = require("crypto");
2095
2030
  _PluginCommon = class _PluginCommon {
2096
2031
  constructor(options) {
2097
2032
  this.options = options;
2098
2033
  }
2034
+ id = (0, import_node_crypto.randomUUID)();
2035
+ loadedAt = Date.now();
2099
2036
  /**
2100
2037
  * Called when this plugin is activated
2101
2038
  */
@@ -2109,12 +2046,13 @@ var init_PluginCommon = __esm({
2109
2046
  };
2110
2047
  __name(_PluginCommon, "PluginCommon");
2111
2048
  PluginCommon = _PluginCommon;
2049
+ __name(isPlugin, "isPlugin");
2112
2050
  }
2113
2051
  });
2114
2052
 
2115
2053
  // src/plugins/CompilerPlugin.ts
2116
2054
  function isCompilerPlugin(plugin) {
2117
- return plugin instanceof CompilerPlugin;
2055
+ return isPlugin(plugin) && plugin.type === "compiler" /* Compiler */;
2118
2056
  }
2119
2057
  var _CompilerPlugin, CompilerPlugin;
2120
2058
  var init_CompilerPlugin = __esm({
@@ -2123,6 +2061,7 @@ var init_CompilerPlugin = __esm({
2123
2061
  init_cjs_shims();
2124
2062
  init_PluginCommon();
2125
2063
  _CompilerPlugin = class _CompilerPlugin extends PluginCommon {
2064
+ type = "compiler" /* Compiler */;
2126
2065
  /**
2127
2066
  * Called when transformation is requested to this plugin
2128
2067
  * @param params The parameters for the transformation
@@ -2158,7 +2097,7 @@ var init_CompilerPlugin = __esm({
2158
2097
 
2159
2098
  // src/plugins/RuntimePlugin.ts
2160
2099
  function isRuntimePlugin(plugin) {
2161
- return plugin instanceof RuntimePlugin;
2100
+ return isPlugin(plugin) && plugin.type === "runtime" /* Runtime */;
2162
2101
  }
2163
2102
  var _RuntimePlugin, RuntimePlugin;
2164
2103
  var init_RuntimePlugin = __esm({
@@ -2167,6 +2106,7 @@ var init_RuntimePlugin = __esm({
2167
2106
  init_cjs_shims();
2168
2107
  init_PluginCommon();
2169
2108
  _RuntimePlugin = class _RuntimePlugin extends PluginCommon {
2109
+ type = "runtime" /* Runtime */;
2170
2110
  /**
2171
2111
  * Called before commands are loaded
2172
2112
  */
@@ -2477,6 +2417,9 @@ var init_CommandKitPluginRuntime = __esm({
2477
2417
  this.commandkit = commandkit2;
2478
2418
  }
2479
2419
  plugins = new import_discord18.Collection();
2420
+ getPlugins() {
2421
+ return this.plugins;
2422
+ }
2480
2423
  getPlugin(pluginName) {
2481
2424
  return this.plugins.get(pluginName) ?? null;
2482
2425
  }
@@ -2586,6 +2529,9 @@ var init_CompilerPluginRuntime = __esm({
2586
2529
  this.plugins = plugins;
2587
2530
  }
2588
2531
  name = "CompilerPluginRuntime";
2532
+ getPlugins() {
2533
+ return this.plugins;
2534
+ }
2589
2535
  isEmpty() {
2590
2536
  return !this.plugins.length;
2591
2537
  }
@@ -2754,21 +2700,6 @@ var init_runtime = __esm({
2754
2700
  }
2755
2701
  });
2756
2702
 
2757
- // src/plugins/index.ts
2758
- var init_plugins = __esm({
2759
- "src/plugins/index.ts"() {
2760
- "use strict";
2761
- init_cjs_shims();
2762
- init_CompilerPlugin();
2763
- init_RuntimePlugin();
2764
- init_types2();
2765
- init_CommandKitPluginRuntime();
2766
- init_CompilerPluginRuntime();
2767
- init_types3();
2768
- init_runtime();
2769
- }
2770
- });
2771
-
2772
2703
  // src/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.ts
2773
2704
  var _CommonDirectiveTransformer, CommonDirectiveTransformer;
2774
2705
  var init_CommonDirectiveTransformer = __esm({
@@ -2803,27 +2734,19 @@ var init_CommonDirectiveTransformer = __esm({
2803
2734
  }
2804
2735
  });
2805
2736
 
2806
- // src/plugins/plugin-runtime/builtin/CachePlugin.ts
2807
- var _CachePlugin, CachePlugin;
2808
- var init_CachePlugin = __esm({
2809
- "src/plugins/plugin-runtime/builtin/CachePlugin.ts"() {
2737
+ // src/plugins/index.ts
2738
+ var init_plugins = __esm({
2739
+ "src/plugins/index.ts"() {
2810
2740
  "use strict";
2811
2741
  init_cjs_shims();
2742
+ init_CompilerPlugin();
2743
+ init_RuntimePlugin();
2744
+ init_types2();
2745
+ init_CommandKitPluginRuntime();
2746
+ init_CompilerPluginRuntime();
2747
+ init_types3();
2748
+ init_runtime();
2812
2749
  init_CommonDirectiveTransformer();
2813
- _CachePlugin = class _CachePlugin extends CommonDirectiveTransformer {
2814
- name = "CachePlugin";
2815
- constructor(options) {
2816
- super({
2817
- ...options,
2818
- directive: "use cache",
2819
- importPath: "commandkit",
2820
- importName: "__SECRET_USE_CACHE_INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED",
2821
- asyncOnly: true
2822
- });
2823
- }
2824
- };
2825
- __name(_CachePlugin, "CachePlugin");
2826
- CachePlugin = _CachePlugin;
2827
2750
  }
2828
2751
  });
2829
2752
 
@@ -2867,20 +2790,13 @@ var init_default = __esm({
2867
2790
  "src/config/default.ts"() {
2868
2791
  "use strict";
2869
2792
  init_cjs_shims();
2870
- init_CachePlugin();
2871
2793
  init_MacroPlugin();
2872
2794
  defaultConfig = {
2873
- plugins: [
2874
- new CachePlugin({ enabled: true }),
2875
- new MacroPlugin({ enabled: true })
2876
- ],
2795
+ plugins: [new MacroPlugin({ enabled: true })],
2877
2796
  esbuildPlugins: [],
2878
2797
  compilerOptions: {
2879
2798
  macro: {
2880
2799
  development: false
2881
- },
2882
- cache: {
2883
- development: true
2884
2800
  }
2885
2801
  },
2886
2802
  static: true,
@@ -2903,16 +2819,12 @@ function getConfig() {
2903
2819
  return defined;
2904
2820
  }
2905
2821
  function defineConfig(config = {}) {
2906
- var _a, _b;
2822
+ var _a;
2907
2823
  defined = {
2908
2824
  compilerOptions: {
2909
- cache: {
2910
- ...defaultConfig.compilerOptions.cache,
2911
- ...(_a = config.compilerOptions) == null ? void 0 : _a.cache
2912
- },
2913
2825
  macro: {
2914
2826
  ...defaultConfig.compilerOptions.macro,
2915
- ...(_b = config.compilerOptions) == null ? void 0 : _b.macro
2827
+ ...(_a = config.compilerOptions) == null ? void 0 : _a.macro
2916
2828
  }
2917
2829
  },
2918
2830
  distDir: config.distDir ?? defaultConfig.distDir,
@@ -2924,10 +2836,9 @@ function defineConfig(config = {}) {
2924
2836
  ...config.esbuildPlugins ?? [],
2925
2837
  ...defaultConfig.esbuildPlugins ?? []
2926
2838
  ],
2927
- plugins: [
2928
- ...config.plugins ?? [],
2929
- ...defaultConfig.plugins ?? []
2930
- ],
2839
+ plugins: [...config.plugins ?? [], ...defaultConfig.plugins ?? []].flat(
2840
+ Infinity
2841
+ ),
2931
2842
  sourceMap: {
2932
2843
  ...defaultConfig.sourceMap,
2933
2844
  ...config.sourceMap
@@ -3010,7 +2921,7 @@ function findAppDirectory() {
3010
2921
  }
3011
2922
  return null;
3012
2923
  }
3013
- function debounce(fn, ms2) {
2924
+ function debounce(fn, ms) {
3014
2925
  let timer = null;
3015
2926
  let resolve = null;
3016
2927
  return (...args) => {
@@ -3027,7 +2938,7 @@ function debounce(fn, ms2) {
3027
2938
  res(result);
3028
2939
  timer = null;
3029
2940
  resolve = null;
3030
- }, ms2);
2941
+ }, ms);
3031
2942
  });
3032
2943
  };
3033
2944
  }
@@ -3512,12 +3423,12 @@ function cancelAfter(id) {
3512
3423
  }
3513
3424
  env.clearDeferredFunction(id);
3514
3425
  }
3515
- var import_node_crypto, _data, _CommandKitEnvironment, CommandKitEnvironment, CommandKitEnvironmentType;
3426
+ var import_node_crypto2, _data, _CommandKitEnvironment, CommandKitEnvironment, CommandKitEnvironmentType;
3516
3427
  var init_environment = __esm({
3517
3428
  "src/context/environment.ts"() {
3518
3429
  "use strict";
3519
3430
  init_cjs_shims();
3520
- import_node_crypto = require("crypto");
3431
+ import_node_crypto2 = require("crypto");
3521
3432
  init_async_context();
3522
3433
  _CommandKitEnvironment = class _CommandKitEnvironment {
3523
3434
  /**
@@ -3600,7 +3511,7 @@ var init_environment = __esm({
3600
3511
  * @internal
3601
3512
  */
3602
3513
  registerDeferredFunction(fn) {
3603
- const id = (0, import_node_crypto.randomUUID)();
3514
+ const id = (0, import_node_crypto2.randomUUID)();
3604
3515
  __privateGet(this, _data).deferredFunctions.set(id, fn);
3605
3516
  return id;
3606
3517
  }
@@ -4906,11 +4817,12 @@ var init_router = __esm({
4906
4817
  });
4907
4818
 
4908
4819
  // src/app/handlers/AppEventsHandler.ts
4909
- var _AppEventsHandler, AppEventsHandler;
4820
+ var import_discord25, _AppEventsHandler, AppEventsHandler;
4910
4821
  var init_AppEventsHandler = __esm({
4911
4822
  "src/app/handlers/AppEventsHandler.ts"() {
4912
4823
  "use strict";
4913
4824
  init_cjs_shims();
4825
+ import_discord25 = require("discord.js");
4914
4826
  init_Logger();
4915
4827
  init_resolve_file_url();
4916
4828
  init_utilities();
@@ -4919,7 +4831,20 @@ var init_AppEventsHandler = __esm({
4919
4831
  constructor(commandkit2) {
4920
4832
  this.commandkit = commandkit2;
4921
4833
  }
4922
- loadedEvents = /* @__PURE__ */ new Map();
4834
+ loadedEvents = new import_discord25.Collection();
4835
+ getEvents() {
4836
+ if (this.loadedEvents.size === 0) return [];
4837
+ const events = this.loadedEvents.toJSON();
4838
+ return events.map(
4839
+ (event) => ({
4840
+ name: event.name,
4841
+ namespace: event.namespace,
4842
+ onceListeners: event.listeners.filter((listener) => listener.once).length,
4843
+ regularListeners: event.listeners.filter((listener) => !listener.once).length,
4844
+ metadata: event.event
4845
+ })
4846
+ );
4847
+ }
4923
4848
  async reloadEvents() {
4924
4849
  this.unregisterAll();
4925
4850
  await this.loadEvents();
@@ -5399,18 +5324,16 @@ function onBootstrap(fn) {
5399
5324
  function onApplicationBootstrap(fn) {
5400
5325
  onApplicationBootstrapHooks.add(fn);
5401
5326
  }
5402
- var import_node_events2, import_discord25, import_node_path7, import_node_fs7, commandkit, bootstrapHooks, onApplicationBootstrapHooks, _started, _CommandKit_instances, bootstrapHooks_fn, applicationBootstrapHooks_fn, init_fn, initCommands_fn, initEvents_fn, _CommandKit, CommandKit;
5327
+ var import_node_events2, import_discord26, import_node_path7, import_node_fs7, commandkit, bootstrapHooks, onApplicationBootstrapHooks, _started, _CommandKit_instances, bootstrapHooks_fn, applicationBootstrapHooks_fn, init_fn, initCommands_fn, initEvents_fn, _CommandKit, CommandKit;
5403
5328
  var init_CommandKit = __esm({
5404
5329
  "src/CommandKit.ts"() {
5405
5330
  "use strict";
5406
5331
  init_cjs_shims();
5407
5332
  import_node_events2 = __toESM(require("events"));
5408
5333
  init_colors();
5409
- init_CacheProvider();
5410
- init_MemoryCache();
5411
5334
  init_components();
5412
5335
  init_EventInterceptor();
5413
- import_discord25 = require("discord.js");
5336
+ import_discord26 = require("discord.js");
5414
5337
  init_utilities();
5415
5338
  import_node_path7 = require("path");
5416
5339
  init_AppCommandHandler();
@@ -5456,7 +5379,7 @@ var init_CommandKit = __esm({
5456
5379
  __privateAdd(this, _started, false);
5457
5380
  __publicField(this, "eventInterceptor");
5458
5381
  __publicField(this, "config", {
5459
- defaultLocale: import_discord25.Locale.EnglishUS,
5382
+ defaultLocale: import_discord26.Locale.EnglishUS,
5460
5383
  getMessageCommandPrefix: /* @__PURE__ */ __name(() => "!", "getMessageCommandPrefix")
5461
5384
  });
5462
5385
  __publicField(this, "store", /* @__PURE__ */ new Map());
@@ -5466,9 +5389,6 @@ var init_CommandKit = __esm({
5466
5389
  __publicField(this, "eventHandler", new AppEventsHandler(this));
5467
5390
  __publicField(this, "plugins");
5468
5391
  __publicField(this, "events", new CommandKitEventsChannel(this));
5469
- if (options.cacheProvider !== null && (!options.cacheProvider || !(options.cacheProvider instanceof CacheProvider))) {
5470
- options.cacheProvider = new MemoryCache();
5471
- }
5472
5392
  this.plugins = new CommandKitPluginRuntime(this);
5473
5393
  if (!_CommandKit.instance) {
5474
5394
  _CommandKit.instance = this;
@@ -5503,7 +5423,7 @@ var init_CommandKit = __esm({
5503
5423
  this.commandHandler.registerCommandHandler();
5504
5424
  this.incrementClientListenersCount();
5505
5425
  if (token !== false && !this.options.client.isReady()) {
5506
- this.client.once(import_discord25.Events.ClientReady, async () => {
5426
+ this.client.once(import_discord26.Events.ClientReady, async () => {
5507
5427
  await this.commandHandler.registrar.register();
5508
5428
  });
5509
5429
  await this.plugins.execute((ctx, plugin) => {
@@ -5555,26 +5475,6 @@ var init_CommandKit = __esm({
5555
5475
  this.config.defaultLocale = locale;
5556
5476
  return this;
5557
5477
  }
5558
- /**
5559
- * Sets the cache provider.
5560
- * @param provider The cache provider.
5561
- */
5562
- setCacheProvider(provider) {
5563
- if (!(provider instanceof CacheProvider)) {
5564
- throw new Error(
5565
- colors_default.red("Cache provider must be an instance of CacheProvider.")
5566
- );
5567
- }
5568
- this.options.cacheProvider = provider;
5569
- return this;
5570
- }
5571
- /**
5572
- * Resolves the current cache provider.
5573
- */
5574
- getCacheProvider() {
5575
- const provider = this.options.cacheProvider;
5576
- return provider ?? null;
5577
- }
5578
5478
  /**
5579
5479
  * Get the client attached to this CommandKit instance.
5580
5480
  */
@@ -5715,7 +5615,7 @@ var init_version = __esm({
5715
5615
  "use strict";
5716
5616
  init_cjs_shims();
5717
5617
  version = /* @__MACRO__ $version */
5718
- "1.0.0-dev.20250511080231";
5618
+ "1.0.0-dev.20250512141520";
5719
5619
  }
5720
5620
  });
5721
5621
 
@@ -6112,7 +6012,7 @@ async function bootstrapDevelopmentServer(configPath) {
6112
6012
  }, "waitForAcknowledgment");
6113
6013
  const sendHmrEvent = /* @__PURE__ */ __name(async (event, path3) => {
6114
6014
  if (!ps || !ps.send) return false;
6115
- const messageId = (0, import_node_crypto4.randomUUID)();
6015
+ const messageId = (0, import_node_crypto3.randomUUID)();
6116
6016
  const messagePromise = waitForAcknowledgment(messageId);
6117
6017
  ps.send({ event, path: path3, id: messageId });
6118
6018
  try {
@@ -6229,7 +6129,7 @@ ${colors_default.yellowBright("rc")} - Reload all commands
6229
6129
  ${colors_default.yellowBright("re")} - Reload all events`
6230
6130
  );
6231
6131
  }
6232
- var import_path2, import_chokidar, import_promises6, import_node_crypto4, isCommandSource, isEventSource;
6132
+ var import_path2, import_chokidar, import_promises6, import_node_crypto3, isCommandSource, isEventSource;
6233
6133
  var init_development = __esm({
6234
6134
  "src/cli/development.ts"() {
6235
6135
  "use strict";
@@ -6243,7 +6143,7 @@ var init_development = __esm({
6243
6143
  init_utilities();
6244
6144
  init_colors();
6245
6145
  import_promises6 = require("timers/promises");
6246
- import_node_crypto4 = require("crypto");
6146
+ import_node_crypto3 = require("crypto");
6247
6147
  init_constants();
6248
6148
  __name(buildAndStart, "buildAndStart");
6249
6149
  isCommandSource = /* @__PURE__ */ __name((p) => p.replaceAll("\\", "/").includes("src/app/commands"), "isCommandSource");
@@ -6576,7 +6476,7 @@ var init_information = __esm({
6576
6476
  import_node_fs10 = __toESM(require("fs"));
6577
6477
  import_node_path11 = __toESM(require("path"));
6578
6478
  knownPlugins = /* @__MACRO__ $getKnownPlugins */
6579
- ["@commandkit/i18n", "@commandkit/legacy", "@commandkit/redis"];
6479
+ ["@commandkit/cache", "@commandkit/devtools", "@commandkit/i18n", "@commandkit/legacy", "@commandkit/redis"];
6580
6480
  __name(findPackageVersion, "findPackageVersion");
6581
6481
  __name(getBinaryVersion, "getBinaryVersion");
6582
6482
  __name(showInformation, "showInformation");
@@ -6594,7 +6494,6 @@ __export(index_exports, {
6594
6494
  COMMANDKIT_CACHE_TAG: () => COMMANDKIT_CACHE_TAG,
6595
6495
  COMMANDKIT_IS_DEV: () => COMMANDKIT_IS_DEV,
6596
6496
  COMMANDKIT_IS_TEST: () => COMMANDKIT_IS_TEST,
6597
- CacheProvider: () => CacheProvider,
6598
6497
  ChannelSelectMenu: () => ChannelSelectMenu,
6599
6498
  ChannelSelectMenuKit: () => ChannelSelectMenuKit,
6600
6499
  CommandExecutionMode: () => CommandExecutionMode,
@@ -6604,6 +6503,7 @@ __export(index_exports, {
6604
6503
  CommandKitPluginRuntime: () => CommandKitPluginRuntime,
6605
6504
  CommandRegistrar: () => CommandRegistrar,
6606
6505
  CommandsRouter: () => CommandsRouter,
6506
+ CommonDirectiveTransformer: () => CommonDirectiveTransformer,
6607
6507
  CompilerPlugin: () => CompilerPlugin,
6608
6508
  CompilerPluginRuntime: () => CompilerPluginRuntime,
6609
6509
  Container: () => Container,
@@ -6618,7 +6518,6 @@ __export(index_exports, {
6618
6518
  Logger: () => Logger,
6619
6519
  MediaGallery: () => MediaGallery,
6620
6520
  MediaGalleryItem: () => MediaGalleryItem,
6621
- MemoryCache: () => MemoryCache,
6622
6521
  MentionableSelectMenu: () => MentionableSelectMenu,
6623
6522
  MentionableSelectMenuKit: () => MentionableSelectMenuKit,
6624
6523
  MessageCommandOptions: () => MessageCommandOptions,
@@ -6642,12 +6541,8 @@ __export(index_exports, {
6642
6541
  Thumbnail: () => Thumbnail,
6643
6542
  UserSelectMenu: () => UserSelectMenu,
6644
6543
  UserSelectMenuKit: () => UserSelectMenuKit,
6645
- __SECRET_USE_CACHE_INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: () => __SECRET_USE_CACHE_INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
6646
6544
  after: () => after,
6647
6545
  bootstrapCommandkitCLI: () => bootstrapCommandkitCLI,
6648
- cache: () => cache,
6649
- cacheLife: () => cacheLife,
6650
- cacheTag: () => cacheTag,
6651
6546
  cancelAfter: () => cancelAfter,
6652
6547
  commandkit: () => commandkit,
6653
6548
  createElement: () => createElement,
@@ -6667,8 +6562,6 @@ __export(index_exports, {
6667
6562
  getElement: () => getElement,
6668
6563
  getEventWorkerContext: () => getEventWorkerContext,
6669
6564
  getSourceDirectories: () => getSourceDirectories,
6670
- invalidate: () => invalidate,
6671
- isCachedFunction: () => isCachedFunction,
6672
6565
  isCommandKitElement: () => isCommandKitElement,
6673
6566
  isCompilerPlugin: () => isCompilerPlugin,
6674
6567
  isInteractionSource: () => isInteractionSource,
@@ -6680,7 +6573,6 @@ __export(index_exports, {
6680
6573
  provideContext: () => provideContext,
6681
6574
  redirect: () => redirect,
6682
6575
  rethrow: () => rethrow,
6683
- revalidate: () => revalidate,
6684
6576
  runInEventWorkerContext: () => runInEventWorkerContext,
6685
6577
  stopEvents: () => stopEvents,
6686
6578
  useEnvironment: () => useEnvironment,
@@ -6695,188 +6587,6 @@ init_config();
6695
6587
  init_async_context();
6696
6588
  init_environment();
6697
6589
 
6698
- // src/cache/index.ts
6699
- init_cjs_shims();
6700
- init_CacheProvider();
6701
- init_MemoryCache();
6702
-
6703
- // src/cache/use-cache.ts
6704
- init_cjs_shims();
6705
- var import_node_async_hooks3 = require("async_hooks");
6706
- init_async_context();
6707
- var import_node_crypto3 = require("crypto");
6708
- var import_ms = __toESM(require("ms"));
6709
-
6710
- // src/cache/utils.ts
6711
- init_cjs_shims();
6712
- var import_node_crypto2 = require("crypto");
6713
- var tracker = 0n;
6714
- var references = /* @__PURE__ */ new WeakMap();
6715
- var PRIMITIVE_TYPES = /* @__PURE__ */ new Set(
6716
- [
6717
- "string",
6718
- "number",
6719
- "boolean",
6720
- "bigint",
6721
- "undefined"
6722
- ]
6723
- );
6724
- function isSerializablePrimitive(value) {
6725
- return value === null || PRIMITIVE_TYPES.has(typeof value);
6726
- }
6727
- __name(isSerializablePrimitive, "isSerializablePrimitive");
6728
- function createKey(val) {
6729
- return `commandkit:cache:object:${val}`;
6730
- }
6731
- __name(createKey, "createKey");
6732
- function getObjectId(obj) {
6733
- const primitive = isSerializablePrimitive(obj);
6734
- if (primitive) return createKey(obj);
6735
- if (obj instanceof Date) return createKey(obj.getTime());
6736
- if (obj instanceof RegExp) return createKey(obj);
6737
- const ref = references.get(obj);
6738
- if (ref) return createKey(ref);
6739
- const id = tracker++;
6740
- references.set(obj, id);
6741
- return createKey(id);
6742
- }
6743
- __name(getObjectId, "getObjectId");
6744
- async function createObjectHash(...args) {
6745
- const serializedKey = args.map(getObjectId).join(":");
6746
- try {
6747
- const hash = (0, import_node_crypto2.createHash)("sha256");
6748
- hash.update(serializedKey);
6749
- return hash.digest("hex");
6750
- } catch {
6751
- return serializedKey;
6752
- }
6753
- }
6754
- __name(createObjectHash, "createObjectHash");
6755
-
6756
- // src/cache/use-cache.ts
6757
- var cacheContext = new import_node_async_hooks3.AsyncLocalStorage();
6758
- var fnStore = /* @__PURE__ */ new Map();
6759
- var DEFAULT_TTL = (0, import_ms.default)("15m");
6760
- var CACHE_FN_ID = `__cache_fn_id_${Date.now()}__${Math.random()}__`;
6761
- var CACHED_FN_SYMBOL = Symbol("commandkit.cache.sentinel");
6762
- function getCacheProvider() {
6763
- const commandkit2 = getCommandKit(true);
6764
- const provider = commandkit2.getCacheProvider();
6765
- if (!provider) {
6766
- throw new Error(
6767
- `Cache provider was not found, please provide a cache provider to commandkit.`
6768
- );
6769
- }
6770
- return provider;
6771
- }
6772
- __name(getCacheProvider, "getCacheProvider");
6773
- function useCache(fn, id, params) {
6774
- const isLocal = id === CACHE_FN_ID;
6775
- if (id && !isLocal) {
6776
- throw new Error("Illegal use of cache function.");
6777
- }
6778
- const fnId = (0, import_node_crypto3.randomUUID)();
6779
- const memo = /* @__PURE__ */ __name(async (...args) => {
6780
- const forcedName = isLocal ? params == null ? void 0 : params.name : null;
6781
- const keyHash = forcedName ?? await createObjectHash(fnId, ...args);
6782
- const resolvedTTL = isLocal && (params == null ? void 0 : params.ttl) != null ? typeof params.ttl === "string" ? (0, import_ms.default)(params.ttl) : params.ttl : null;
6783
- return cacheContext.run(
6784
- {
6785
- params: {
6786
- name: keyHash,
6787
- ttl: resolvedTTL ?? DEFAULT_TTL
6788
- }
6789
- },
6790
- async () => {
6791
- const provider = getCacheProvider();
6792
- const context2 = cacheContext.getStore();
6793
- if (!context2) {
6794
- throw new Error("Cache context was not found.");
6795
- }
6796
- const storedFn = fnStore.get(keyHash);
6797
- const effectiveKey = (storedFn == null ? void 0 : storedFn.key) ?? context2.params.name;
6798
- const cached = await provider.get(effectiveKey);
6799
- if (cached && cached.value != null) return cached.value;
6800
- const result = await fn(...args);
6801
- if (result != null) {
6802
- const finalKey = context2.params.name;
6803
- const ttl = context2.params.ttl ?? DEFAULT_TTL;
6804
- await provider.set(finalKey, result, ttl);
6805
- fnStore.set(keyHash, {
6806
- key: finalKey,
6807
- hash: keyHash,
6808
- ttl,
6809
- original: fn,
6810
- memo
6811
- });
6812
- }
6813
- return result;
6814
- }
6815
- );
6816
- }, "memo");
6817
- if (!Object.prototype.hasOwnProperty.call(fn, CACHED_FN_SYMBOL)) {
6818
- Object.defineProperty(memo, CACHED_FN_SYMBOL, {
6819
- get() {
6820
- return true;
6821
- },
6822
- configurable: false,
6823
- enumerable: false
6824
- });
6825
- }
6826
- return memo;
6827
- }
6828
- __name(useCache, "useCache");
6829
- function cache(fn, params) {
6830
- return useCache(fn, CACHE_FN_ID, params);
6831
- }
6832
- __name(cache, "cache");
6833
- function cacheTag(tag) {
6834
- const context2 = cacheContext.getStore();
6835
- if (!context2) {
6836
- throw new Error("cacheTag() must be called inside a cached function.");
6837
- }
6838
- if (!tag) {
6839
- throw new Error("cacheTag() must be called with a tag name.");
6840
- }
6841
- context2.params.name = tag;
6842
- }
6843
- __name(cacheTag, "cacheTag");
6844
- function cacheLife(ttl) {
6845
- const context2 = cacheContext.getStore();
6846
- if (!context2) {
6847
- throw new Error("cacheLife() must be called inside a cached function.");
6848
- }
6849
- if (ttl == null || !["string", "number"].includes(typeof ttl)) {
6850
- throw new Error("cacheLife() must be called with a ttl.");
6851
- }
6852
- context2.params.ttl = typeof ttl === "string" ? (0, import_ms.default)(ttl) : ttl;
6853
- }
6854
- __name(cacheLife, "cacheLife");
6855
- async function invalidate(tag) {
6856
- const provider = getCacheProvider();
6857
- const entry = Array.from(fnStore.values()).find(
6858
- (v) => v.key === tag || v.hash === tag
6859
- );
6860
- if (!entry) return;
6861
- await provider.delete(entry.key);
6862
- }
6863
- __name(invalidate, "invalidate");
6864
- async function revalidate(tag, ...args) {
6865
- const provider = getCacheProvider();
6866
- const entry = Array.from(fnStore.values()).find(
6867
- (v) => v.key === tag || v.hash === tag
6868
- );
6869
- if (!entry) return void 0;
6870
- await provider.delete(entry.key);
6871
- return entry.memo(...args);
6872
- }
6873
- __name(revalidate, "revalidate");
6874
- function isCachedFunction(fn) {
6875
- return Object.prototype.hasOwnProperty.call(fn, CACHED_FN_SYMBOL);
6876
- }
6877
- __name(isCachedFunction, "isCachedFunction");
6878
- var __SECRET_USE_CACHE_INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = useCache;
6879
-
6880
6590
  // src/app/index.ts
6881
6591
  init_cjs_shims();
6882
6592
  init_AppCommandHandler();
@@ -6887,9 +6597,9 @@ init_CommandRegistrar();
6887
6597
 
6888
6598
  // src/app/commands/helpers.ts
6889
6599
  init_cjs_shims();
6890
- var import_discord26 = require("discord.js");
6600
+ var import_discord27 = require("discord.js");
6891
6601
  function isMessageSource(source) {
6892
- return source instanceof import_discord26.Message;
6602
+ return source instanceof import_discord27.Message;
6893
6603
  }
6894
6604
  __name(isMessageSource, "isMessageSource");
6895
6605
  function isInteractionSource(source) {
@@ -6982,7 +6692,6 @@ var index_default = CommandKit;
6982
6692
  COMMANDKIT_CACHE_TAG,
6983
6693
  COMMANDKIT_IS_DEV,
6984
6694
  COMMANDKIT_IS_TEST,
6985
- CacheProvider,
6986
6695
  ChannelSelectMenu,
6987
6696
  ChannelSelectMenuKit,
6988
6697
  CommandExecutionMode,
@@ -6992,6 +6701,7 @@ var index_default = CommandKit;
6992
6701
  CommandKitPluginRuntime,
6993
6702
  CommandRegistrar,
6994
6703
  CommandsRouter,
6704
+ CommonDirectiveTransformer,
6995
6705
  CompilerPlugin,
6996
6706
  CompilerPluginRuntime,
6997
6707
  Container,
@@ -7006,7 +6716,6 @@ var index_default = CommandKit;
7006
6716
  Logger,
7007
6717
  MediaGallery,
7008
6718
  MediaGalleryItem,
7009
- MemoryCache,
7010
6719
  MentionableSelectMenu,
7011
6720
  MentionableSelectMenuKit,
7012
6721
  MessageCommandOptions,
@@ -7030,12 +6739,8 @@ var index_default = CommandKit;
7030
6739
  Thumbnail,
7031
6740
  UserSelectMenu,
7032
6741
  UserSelectMenuKit,
7033
- __SECRET_USE_CACHE_INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
7034
6742
  after,
7035
6743
  bootstrapCommandkitCLI,
7036
- cache,
7037
- cacheLife,
7038
- cacheTag,
7039
6744
  cancelAfter,
7040
6745
  commandkit,
7041
6746
  createElement,
@@ -7054,8 +6759,6 @@ var index_default = CommandKit;
7054
6759
  getElement,
7055
6760
  getEventWorkerContext,
7056
6761
  getSourceDirectories,
7057
- invalidate,
7058
- isCachedFunction,
7059
6762
  isCommandKitElement,
7060
6763
  isCompilerPlugin,
7061
6764
  isInteractionSource,
@@ -7067,7 +6770,6 @@ var index_default = CommandKit;
7067
6770
  provideContext,
7068
6771
  redirect,
7069
6772
  rethrow,
7070
- revalidate,
7071
6773
  runInEventWorkerContext,
7072
6774
  stopEvents,
7073
6775
  useEnvironment,