commandkit 0.1.11-dev.20250403165359 → 0.1.11-dev.20250404110151
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.d.ts +22 -1
- package/dist/index.js +22 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1196,6 +1196,7 @@ interface Middleware {
|
|
|
1196
1196
|
relativePath: string;
|
|
1197
1197
|
parentPath: string;
|
|
1198
1198
|
global: boolean;
|
|
1199
|
+
command: string | null;
|
|
1199
1200
|
}
|
|
1200
1201
|
interface ParsedCommandData {
|
|
1201
1202
|
commands: Record<string, Command>;
|
|
@@ -1909,6 +1910,26 @@ declare const version: string;
|
|
|
1909
1910
|
|
|
1910
1911
|
declare function getCurrentDirectory(): string;
|
|
1911
1912
|
declare function getSourceDirectories(): string[];
|
|
1913
|
+
/**
|
|
1914
|
+
* Debounces a function.
|
|
1915
|
+
* @param fn The function to debounce.
|
|
1916
|
+
* @param ms The debounce time in milliseconds.
|
|
1917
|
+
* @returns The debounced function.
|
|
1918
|
+
*/
|
|
1919
|
+
declare function debounce<R, F extends (...args: any[]) => R>(fn: F, ms: number): F;
|
|
1920
|
+
/**
|
|
1921
|
+
* Creates a function from the given function that runs only in development mode.
|
|
1922
|
+
* @param fn The function to run in development mode.
|
|
1923
|
+
* @returns The function that runs only in development mode.
|
|
1924
|
+
* @example
|
|
1925
|
+
* ```ts
|
|
1926
|
+
* const devOnlyFn = devOnly(() => {
|
|
1927
|
+
* console.log('This function runs only in development mode');
|
|
1928
|
+
* });
|
|
1929
|
+
* devOnlyFn(); // This will log the message only in development mode
|
|
1930
|
+
* ```
|
|
1931
|
+
*/
|
|
1932
|
+
declare function devOnly<T extends (...args: any[]) => any>(fn: T): T;
|
|
1912
1933
|
|
|
1913
1934
|
/**
|
|
1914
1935
|
* Creates a command line interface for CommandKit.
|
|
@@ -1917,4 +1938,4 @@ declare function getSourceDirectories(): string[];
|
|
|
1917
1938
|
*/
|
|
1918
1939
|
declare function bootstrapCommandkitCLI(argv: string[], options?: commander.ParseOptions | undefined): Promise<void>;
|
|
1919
1940
|
|
|
1920
|
-
export { ActionRow, type ActionRowProps, type AnyCommandExecute, type AnyCommandKitElement, AppCommandHandler, type AsyncFunction, type AutocompleteCommand, type AutocompleteCommandContext, type AutocompleteCommandMiddlewareContext, Button, type ButtonChildrenLike, ButtonKit, type ButtonKitPredicate, type ButtonProps, COMMANDKIT_CACHE_TAG, COMMANDKIT_IS_DEV, COMMANDKIT_IS_TEST, type CacheContext, type CacheEntry, type CacheMetadata, CacheProvider, ChannelSelectMenu, ChannelSelectMenuKit, type ChannelSelectMenuKitPredicate, type ChannelSelectMenuProps, type Command, type CommandBuilderLike, type CommandContext, type CommandContextOptions, type CommandData, CommandExecutionMode, CommandKit, type CommandKitButtonBuilderInteractionCollectorDispatch, type CommandKitButtonBuilderInteractionCollectorDispatchContextData, type CommandKitButtonBuilderOnEnd, type CommandKitConfiguration, type CommandKitElement, type CommandKitElementData, CommandKitEnvironment, type CommandKitEnvironmentInternalData, CommandKitEnvironmentType, type CommandKitHMREvent, type CommandKitLoggerOptions, type CommandKitModalBuilderInteractionCollectorDispatch, type CommandKitModalBuilderInteractionCollectorDispatchContextData, type CommandKitModalBuilderOnEnd, type CommandKitOptions, type CommandKitPlugin, CommandKitPluginRuntime, type CommandKitSelectMenuBuilderInteractionCollectorDispatch, type CommandKitSelectMenuBuilderInteractionCollectorDispatchContextData, type CommandKitSelectMenuBuilderOnEnd, type CommandSource, type CommandTypeData, CommandsRouter, type CommandsRouterOptions, type CommonBuilderKit, type CommonPluginRuntime, type CommonSelectMenuProps, CompilerPlugin, CompilerPluginRuntime, Context, type ContextParameters, DefaultLogger, ElementType, EventInterceptor, type EventInterceptorContextData, type EventInterceptorErrorHandler, EventsRouter, type EventsRouterOptions, type EventsTree, Fragment, type FragmentElementProps, type GenericFunction, HMREventType, type ILogger, type InteractionCommandContext, type InteractionCommandMiddlewareContext, type LoadedCommand, type Loader, type Location, Logger, type LoggerImpl, type MaybeArray, type MaybeFalsey, MemoryCache, MentionableSelectMenu, MentionableSelectMenuKit, type MentionableSelectMenuKitPredicate, type MentionableSelectMenuProps, type Message, type MessageCommand, type MessageCommandContext, type MessageCommandMiddlewareContext, MessageCommandOptions, type MessageCommandOptionsSchema, MessageCommandParser, type MessageContextMenuCommand, type MessageContextMenuCommandContext, type MessageContextMenuCommandMiddlewareContext, type Middleware, MiddlewareContext, type MiddlewareContextArgs, Modal, ModalKit, type ModalKitPredicate, type ModalProps, type OnButtonKitClick, type OnButtonKitEnd, type OnChannelSelectMenuKitSubmit, type OnLoadArgs, type OnLoadOptions, type OnLoadResult, type OnMentionableSelectMenuKitSubmit, type OnModalKitEnd, type OnModalKitSubmit, type OnResolveArgs, type OnResolveOptions, type OnResolveResult, type OnRoleSelectMenuKitSubmit, type OnSelectMenuKitEnd, type OnSelectMenuKitSubmit, type OnStringSelectMenuKitSubmit, type OnUserSelectMenuKitSubmit, ParagraphInput, type ParsedCommandData, type ParsedEvent, type ParsedMessageCommand, type PluginTransformParameters, type PreparedAppCommandExecution, type ResolvableCommand, type ResolveBuilderInteraction, type ResolveKind, type ResolveResult, RoleSelectMenu, RoleSelectMenuKit, type RoleSelectMenuKitPredicate, type RoleSelectMenuProps, type RunCommand, RuntimePlugin, type SelectMenuKitPredicate, type SelectMenuProps, type Setup, ShortInput, type SlashCommand, type SlashCommandContext, type SlashCommandMiddlewareContext, StringSelectMenu, StringSelectMenuKit, type StringSelectMenuKitPredicate, StringSelectMenuOption, type StringSelectMenuOptionProps, type StringSelectMenuProps, TextInput, type TextInputProps, type TransformedResult, type UserContextMenuCommand, type UserContextMenuCommandContext, type UserContextMenuCommandMiddlewareContext, UserSelectMenu, UserSelectMenuKit, type UserSelectMenuKitPredicate, type UserSelectMenuProps, afterCommand, bootstrapCommandkitCLI, cache, cacheLife, cacheTag, cancelAfterCommand, commandkit, createElement, createLogger, CommandKit as default, defineConfig, exitContext, exitMiddleware, fromEsbuildPlugin, getCommandKit, getConfig, getContext, getCurrentDirectory, getElement, getSourceDirectories, invalidate, isCachedFunction, isCommandKitElement, isCompilerPlugin, isInteractionSource, isMessageSource, isRuntimePlugin, makeContextAwareFunction, provideContext, redirect, rethrow, revalidate, useEnvironment, version, zzz_commandkit_secret_internal_use_cache_wrapper_do_not_use_or_you_will_be_fired };
|
|
1941
|
+
export { ActionRow, type ActionRowProps, type AnyCommandExecute, type AnyCommandKitElement, AppCommandHandler, type AsyncFunction, type AutocompleteCommand, type AutocompleteCommandContext, type AutocompleteCommandMiddlewareContext, Button, type ButtonChildrenLike, ButtonKit, type ButtonKitPredicate, type ButtonProps, COMMANDKIT_CACHE_TAG, COMMANDKIT_IS_DEV, COMMANDKIT_IS_TEST, type CacheContext, type CacheEntry, type CacheMetadata, CacheProvider, ChannelSelectMenu, ChannelSelectMenuKit, type ChannelSelectMenuKitPredicate, type ChannelSelectMenuProps, type Command, type CommandBuilderLike, type CommandContext, type CommandContextOptions, type CommandData, CommandExecutionMode, CommandKit, type CommandKitButtonBuilderInteractionCollectorDispatch, type CommandKitButtonBuilderInteractionCollectorDispatchContextData, type CommandKitButtonBuilderOnEnd, type CommandKitConfiguration, type CommandKitElement, type CommandKitElementData, CommandKitEnvironment, type CommandKitEnvironmentInternalData, CommandKitEnvironmentType, type CommandKitHMREvent, type CommandKitLoggerOptions, type CommandKitModalBuilderInteractionCollectorDispatch, type CommandKitModalBuilderInteractionCollectorDispatchContextData, type CommandKitModalBuilderOnEnd, type CommandKitOptions, type CommandKitPlugin, CommandKitPluginRuntime, type CommandKitSelectMenuBuilderInteractionCollectorDispatch, type CommandKitSelectMenuBuilderInteractionCollectorDispatchContextData, type CommandKitSelectMenuBuilderOnEnd, type CommandSource, type CommandTypeData, CommandsRouter, type CommandsRouterOptions, type CommonBuilderKit, type CommonPluginRuntime, type CommonSelectMenuProps, CompilerPlugin, CompilerPluginRuntime, Context, type ContextParameters, DefaultLogger, ElementType, EventInterceptor, type EventInterceptorContextData, type EventInterceptorErrorHandler, EventsRouter, type EventsRouterOptions, type EventsTree, Fragment, type FragmentElementProps, type GenericFunction, HMREventType, type ILogger, type InteractionCommandContext, type InteractionCommandMiddlewareContext, type LoadedCommand, type Loader, type Location, Logger, type LoggerImpl, type MaybeArray, type MaybeFalsey, MemoryCache, MentionableSelectMenu, MentionableSelectMenuKit, type MentionableSelectMenuKitPredicate, type MentionableSelectMenuProps, type Message, type MessageCommand, type MessageCommandContext, type MessageCommandMiddlewareContext, MessageCommandOptions, type MessageCommandOptionsSchema, MessageCommandParser, type MessageContextMenuCommand, type MessageContextMenuCommandContext, type MessageContextMenuCommandMiddlewareContext, type Middleware, MiddlewareContext, type MiddlewareContextArgs, Modal, ModalKit, type ModalKitPredicate, type ModalProps, type OnButtonKitClick, type OnButtonKitEnd, type OnChannelSelectMenuKitSubmit, type OnLoadArgs, type OnLoadOptions, type OnLoadResult, type OnMentionableSelectMenuKitSubmit, type OnModalKitEnd, type OnModalKitSubmit, type OnResolveArgs, type OnResolveOptions, type OnResolveResult, type OnRoleSelectMenuKitSubmit, type OnSelectMenuKitEnd, type OnSelectMenuKitSubmit, type OnStringSelectMenuKitSubmit, type OnUserSelectMenuKitSubmit, ParagraphInput, type ParsedCommandData, type ParsedEvent, type ParsedMessageCommand, type PluginTransformParameters, type PreparedAppCommandExecution, type ResolvableCommand, type ResolveBuilderInteraction, type ResolveKind, type ResolveResult, RoleSelectMenu, RoleSelectMenuKit, type RoleSelectMenuKitPredicate, type RoleSelectMenuProps, type RunCommand, RuntimePlugin, type SelectMenuKitPredicate, type SelectMenuProps, type Setup, ShortInput, type SlashCommand, type SlashCommandContext, type SlashCommandMiddlewareContext, StringSelectMenu, StringSelectMenuKit, type StringSelectMenuKitPredicate, StringSelectMenuOption, type StringSelectMenuOptionProps, type StringSelectMenuProps, TextInput, type TextInputProps, type TransformedResult, type UserContextMenuCommand, type UserContextMenuCommandContext, type UserContextMenuCommandMiddlewareContext, UserSelectMenu, UserSelectMenuKit, type UserSelectMenuKitPredicate, type UserSelectMenuProps, afterCommand, bootstrapCommandkitCLI, cache, cacheLife, cacheTag, cancelAfterCommand, commandkit, createElement, createLogger, debounce, CommandKit as default, defineConfig, devOnly, exitContext, exitMiddleware, fromEsbuildPlugin, getCommandKit, getConfig, getContext, getCurrentDirectory, getElement, getSourceDirectories, invalidate, isCachedFunction, isCommandKitElement, isCompilerPlugin, isInteractionSource, isMessageSource, isRuntimePlugin, makeContextAwareFunction, provideContext, redirect, rethrow, revalidate, useEnvironment, version, zzz_commandkit_secret_internal_use_cache_wrapper_do_not_use_or_you_will_be_fired };
|
package/dist/index.js
CHANGED
|
@@ -2891,6 +2891,14 @@ function debounce(fn, ms2) {
|
|
|
2891
2891
|
});
|
|
2892
2892
|
};
|
|
2893
2893
|
}
|
|
2894
|
+
function devOnly(fn) {
|
|
2895
|
+
const f = /* @__PURE__ */ __name((...args) => {
|
|
2896
|
+
if (COMMANDKIT_IS_DEV) {
|
|
2897
|
+
return fn(...args);
|
|
2898
|
+
}
|
|
2899
|
+
}, "f");
|
|
2900
|
+
return f;
|
|
2901
|
+
}
|
|
2894
2902
|
var import_node_fs, import_node_path, appDir, currentDir;
|
|
2895
2903
|
var init_utilities = __esm({
|
|
2896
2904
|
"src/utils/utilities.ts"() {
|
|
@@ -2906,6 +2914,7 @@ var init_utilities = __esm({
|
|
|
2906
2914
|
__name(getSourceDirectories, "getSourceDirectories");
|
|
2907
2915
|
__name(findAppDirectory, "findAppDirectory");
|
|
2908
2916
|
__name(debounce, "debounce");
|
|
2917
|
+
__name(devOnly, "devOnly");
|
|
2909
2918
|
}
|
|
2910
2919
|
});
|
|
2911
2920
|
|
|
@@ -4553,7 +4562,7 @@ var init_AppCommandHandler = __esm({
|
|
|
4553
4562
|
});
|
|
4554
4563
|
|
|
4555
4564
|
// src/app/router/CommandsRouter.ts
|
|
4556
|
-
var import_discord17, import_node_fs3, import_promises3, import_node_path3, MIDDLEWARE_PATTERN, GLOBAL_MIDDLEWARE_PATTERN, COMMAND_PATTERN, CATEGORY_PATTERN, _CommandsRouter, CommandsRouter;
|
|
4565
|
+
var import_discord17, import_node_fs3, import_promises3, import_node_path3, MIDDLEWARE_PATTERN, COMMAND_MIDDLEWARE_PATTERN, GLOBAL_MIDDLEWARE_PATTERN, COMMAND_PATTERN, CATEGORY_PATTERN, _CommandsRouter, CommandsRouter;
|
|
4557
4566
|
var init_CommandsRouter = __esm({
|
|
4558
4567
|
"src/app/router/CommandsRouter.ts"() {
|
|
4559
4568
|
"use strict";
|
|
@@ -4563,6 +4572,7 @@ var init_CommandsRouter = __esm({
|
|
|
4563
4572
|
import_promises3 = require("fs/promises");
|
|
4564
4573
|
import_node_path3 = require("path");
|
|
4565
4574
|
MIDDLEWARE_PATTERN = /^\+middleware\.(m|c)?(j|t)sx?$/;
|
|
4575
|
+
COMMAND_MIDDLEWARE_PATTERN = /^\+([^+().][^().]*)\.middleware\.(m|c)?(j|t)sx?$/;
|
|
4566
4576
|
GLOBAL_MIDDLEWARE_PATTERN = /^\+global-middleware\.(m|c)?(j|t)sx?$/;
|
|
4567
4577
|
COMMAND_PATTERN = /^([^+().][^().]*)\.(m|c)?(j|t)sx?$/;
|
|
4568
4578
|
CATEGORY_PATTERN = /^\(.+\)$/;
|
|
@@ -4587,7 +4597,7 @@ var init_CommandsRouter = __esm({
|
|
|
4587
4597
|
return COMMAND_PATTERN.test(name);
|
|
4588
4598
|
}
|
|
4589
4599
|
isMiddleware(name) {
|
|
4590
|
-
return MIDDLEWARE_PATTERN.test(name) || GLOBAL_MIDDLEWARE_PATTERN.test(name);
|
|
4600
|
+
return MIDDLEWARE_PATTERN.test(name) || GLOBAL_MIDDLEWARE_PATTERN.test(name) || COMMAND_MIDDLEWARE_PATTERN.test(name);
|
|
4591
4601
|
}
|
|
4592
4602
|
isCategory(name) {
|
|
4593
4603
|
return CATEGORY_PATTERN.test(name);
|
|
@@ -4659,7 +4669,8 @@ var init_CommandsRouter = __esm({
|
|
|
4659
4669
|
path: path3,
|
|
4660
4670
|
relativePath: this.replaceEntrypoint(path3),
|
|
4661
4671
|
parentPath: entry.parentPath,
|
|
4662
|
-
global: GLOBAL_MIDDLEWARE_PATTERN.test(name)
|
|
4672
|
+
global: GLOBAL_MIDDLEWARE_PATTERN.test(name),
|
|
4673
|
+
command: COMMAND_MIDDLEWARE_PATTERN.test(name) ? name.split(".")[0] || null : null
|
|
4663
4674
|
};
|
|
4664
4675
|
this.middlewares.set(middleware.id, middleware);
|
|
4665
4676
|
}
|
|
@@ -4668,7 +4679,9 @@ var init_CommandsRouter = __esm({
|
|
|
4668
4679
|
this.commands.forEach((command) => {
|
|
4669
4680
|
const commandPath = command.parentPath;
|
|
4670
4681
|
const samePathMiddlewares = Array.from(this.middlewares.values()).filter((middleware) => {
|
|
4671
|
-
|
|
4682
|
+
if (middleware.global) return true;
|
|
4683
|
+
if (middleware.command) return middleware.command === command.name;
|
|
4684
|
+
return middleware.parentPath === commandPath;
|
|
4672
4685
|
}).map((middleware) => middleware.id);
|
|
4673
4686
|
command.middlewares = Array.from(
|
|
4674
4687
|
/* @__PURE__ */ new Set([...command.middlewares, ...samePathMiddlewares])
|
|
@@ -5497,7 +5510,7 @@ var init_version = __esm({
|
|
|
5497
5510
|
"use strict";
|
|
5498
5511
|
init_cjs_shims();
|
|
5499
5512
|
version = /* @__MACRO__ $version */
|
|
5500
|
-
"0.1.11-dev.
|
|
5513
|
+
"0.1.11-dev.20250404110151";
|
|
5501
5514
|
}
|
|
5502
5515
|
});
|
|
5503
5516
|
|
|
@@ -6415,8 +6428,10 @@ __export(index_exports, {
|
|
|
6415
6428
|
commandkit: () => commandkit,
|
|
6416
6429
|
createElement: () => createElement,
|
|
6417
6430
|
createLogger: () => createLogger,
|
|
6431
|
+
debounce: () => debounce,
|
|
6418
6432
|
default: () => index_default,
|
|
6419
6433
|
defineConfig: () => defineConfig,
|
|
6434
|
+
devOnly: () => devOnly,
|
|
6420
6435
|
exitContext: () => exitContext,
|
|
6421
6436
|
exitMiddleware: () => exitMiddleware,
|
|
6422
6437
|
fromEsbuildPlugin: () => fromEsbuildPlugin,
|
|
@@ -6598,7 +6613,9 @@ var index_default = CommandKit;
|
|
|
6598
6613
|
commandkit,
|
|
6599
6614
|
createElement,
|
|
6600
6615
|
createLogger,
|
|
6616
|
+
debounce,
|
|
6601
6617
|
defineConfig,
|
|
6618
|
+
devOnly,
|
|
6602
6619
|
exitContext,
|
|
6603
6620
|
exitMiddleware,
|
|
6604
6621
|
fromEsbuildPlugin,
|