commandkit 0.1.11-dev.20250402101800 → 0.1.11-dev.20250402134911

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 CHANGED
@@ -796,6 +796,39 @@ declare function getContext(): CommandKitEnvironment | undefined;
796
796
  */
797
797
  declare function useEnvironment(): CommandKitEnvironment;
798
798
 
799
+ declare class DefaultLocalizationStrategy implements LocalizationStrategy {
800
+ private readonly commandkit;
801
+ private translations;
802
+ constructor(commandkit: CommandKit);
803
+ locateTranslation(scope: string, locale: Locale): Promise<Translation | null>;
804
+ private generateLocaleTypes;
805
+ getTranslationStrict(scope: string, locale: Locale): Promise<Translation>;
806
+ getTranslation(scope: string, locale: Locale): Promise<Translation | null>;
807
+ translate(request: LocalizationTranslationRequest): Promise<TranslationResult>;
808
+ private applyTranslation;
809
+ }
810
+
811
+ /**
812
+ * Cancel upcoming middleware execution.
813
+ * If this is called inside pre-stage middleware, the next run will be the actual command, skipping all other pre-stage middlewares.
814
+ * If this is called inside a command itself, it will skip all post-stage middlewares.
815
+ * If this is called inside post-stage middleware, it will skip all other post-stage middlewares.
816
+ */
817
+ declare function exitMiddleware(): never;
818
+ /**
819
+ * Rethrow the error if it is a CommandKit error.
820
+ * @param error The error to rethrow.
821
+ */
822
+ declare function rethrow(error: unknown): void;
823
+ /**
824
+ * Stops current command assuming it has been redirected to another command.
825
+ */
826
+ declare function redirect(): never;
827
+
828
+ type CommandSource = Interaction | Message$1;
829
+ declare function isMessageSource(source: CommandSource): source is Message$1;
830
+ declare function isInteractionSource(source: CommandSource): source is Interaction;
831
+
799
832
  interface CommandKitEnvironmentInternalData {
800
833
  executionError: Error | null;
801
834
  type: CommandKitEnvironmentType | null;
@@ -804,6 +837,7 @@ interface CommandKitEnvironmentInternalData {
804
837
  marker: string;
805
838
  markStart: number;
806
839
  markEnd: number;
840
+ context: Context | null;
807
841
  }
808
842
  declare class CommandKitEnvironment {
809
843
  #private;
@@ -813,6 +847,16 @@ declare class CommandKitEnvironment {
813
847
  * @param commandkit - The commandkit instance.
814
848
  */
815
849
  constructor(commandkit: CommandKit);
850
+ /**
851
+ * Set the context.
852
+ * @param context - The context to set.
853
+ */
854
+ setContext(context: Context): void;
855
+ /**
856
+ * Get the context. `null` if not set.
857
+ * @internal
858
+ */
859
+ get context(): Context | null;
816
860
  /**
817
861
  * Get the execution error.
818
862
  * @internal
@@ -1153,21 +1197,6 @@ interface CacheMetadata {
1153
1197
  /** Custom name for the cache entry */
1154
1198
  name?: string;
1155
1199
  }
1156
- /**
1157
- * Internal cache implementation
1158
- * @internal
1159
- * @private
1160
- * This is used directly by the compiler if the function is annotated with `"use cache"` directive.
1161
- * @example
1162
- * ```ts
1163
- * async function myCachedFunction() {
1164
- * "use cache";
1165
- * // can use cacheTag() and cacheLife() here to customize cache behavior
1166
- * return await db.query('SELECT * FROM users');
1167
- * }
1168
- * ```
1169
- */
1170
- declare function useCache<R extends any[], F extends AsyncFunction<R>>(fn: F, id?: string, params?: CacheMetadata): F;
1171
1200
  /**
1172
1201
  * Wraps an async function with caching capability
1173
1202
  * @template R - Array of argument types
@@ -1244,6 +1273,12 @@ declare function revalidate<T = unknown>(tag: string, ...args: any[]): Promise<T
1244
1273
  * ```
1245
1274
  */
1246
1275
  declare function isCachedFunction(fn: GenericFunction): boolean;
1276
+ /**
1277
+ * **WARNING!!!! DO NOT USE THIS UNLESS YOU KNOW WHAT YOU ARE DOING!**
1278
+ * @private
1279
+ * @internal
1280
+ */
1281
+ declare const zzz_commandkit_secret_internal_use_cache_wrapper_do_not_use_or_you_will_be_fired: any;
1247
1282
 
1248
1283
  interface Command {
1249
1284
  id: string;
@@ -1640,41 +1675,22 @@ declare abstract class PluginCommon<T extends PluginOptions = PluginOptions, C e
1640
1675
  deactivate(ctx: C): Promise<void>;
1641
1676
  }
1642
1677
 
1643
- declare class DefaultLocalizationStrategy implements LocalizationStrategy {
1644
- private readonly commandkit;
1645
- private translations;
1646
- constructor(commandkit: CommandKit);
1647
- locateTranslation(scope: string, locale: Locale): Promise<Translation | null>;
1648
- private generateLocaleTypes;
1649
- getTranslationStrict(scope: string, locale: Locale): Promise<Translation>;
1650
- getTranslation(scope: string, locale: Locale): Promise<Translation | null>;
1651
- translate(request: LocalizationTranslationRequest): Promise<TranslationResult>;
1652
- private applyTranslation;
1653
- }
1654
-
1655
- /**
1656
- * Cancel upcoming middleware execution.
1657
- * If this is called inside pre-stage middleware, the next run will be the actual command, skipping all other pre-stage middlewares.
1658
- * If this is called inside a command itself, it will skip all post-stage middlewares.
1659
- * If this is called inside post-stage middleware, it will skip all other post-stage middlewares.
1660
- */
1661
- declare function exitMiddleware(): never;
1678
+ declare const COMMANDKIT_CACHE_TAG: unique symbol;
1679
+ declare const COMMANDKIT_IS_DEV: boolean;
1680
+ declare const COMMANDKIT_IS_TEST: boolean;
1662
1681
  /**
1663
- * Rethrow the error if it is a CommandKit error.
1664
- * @param error The error to rethrow.
1682
+ * Types of Hot Module Replacement events
1665
1683
  */
1666
- declare function rethrow(error: unknown): void;
1667
- /**
1668
- * Stops current command assuming it has been redirected to another command.
1669
- */
1670
- declare function redirect(): never;
1671
-
1672
- type CommandSource = Interaction | Message$1;
1673
- declare function isMessageSource(source: CommandSource): source is Message$1;
1674
- declare function isInteractionSource(source: CommandSource): source is Interaction;
1684
+ declare const HMREventType: {
1685
+ readonly ReloadCommands: "reload-commands";
1686
+ readonly ReloadEvents: "reload-events";
1687
+ readonly ReloadLocales: "reload-locales";
1688
+ readonly Unknown: "unknown";
1689
+ };
1690
+ type HMREventType = (typeof HMREventType)[keyof typeof HMREventType];
1675
1691
 
1676
1692
  interface CommandKitHMREvent {
1677
- event: string;
1693
+ event: HMREventType;
1678
1694
  path: string;
1679
1695
  accept: () => void;
1680
1696
  preventDefault: () => void;
@@ -1767,8 +1783,8 @@ interface CommandKitConfiguration {
1767
1783
  declare let commandkit: CommandKit;
1768
1784
  declare class CommandKit extends EventEmitter {
1769
1785
  #private;
1770
- private options;
1771
- readonly eventInterceptor: EventInterceptor;
1786
+ private readonly options;
1787
+ eventInterceptor: EventInterceptor;
1772
1788
  static readonly createElement: typeof createElement;
1773
1789
  static readonly Fragment: typeof Fragment;
1774
1790
  readonly config: CommandKitConfiguration;
@@ -1999,6 +2015,7 @@ declare const Logger: LoggerImpl;
1999
2015
  declare const version: string;
2000
2016
 
2001
2017
  declare function getCurrentDirectory(): string;
2018
+ declare function getSourceDirectories(): string[];
2002
2019
 
2003
2020
  /**
2004
2021
  * Creates a command line interface for CommandKit.
@@ -2007,4 +2024,4 @@ declare function getCurrentDirectory(): string;
2007
2024
  */
2008
2025
  declare function bootstrapCommandkitCLI(argv: string[], options?: commander.ParseOptions | undefined): Promise<void>;
2009
2026
 
2010
- export { ActionRow, type ActionRowProps, type AnyCommandExecute, type AnyCommandKitElement, type ApiTranslatableCommandOptions, AppCommandHandler, type AsyncFunction, type AutocompleteCommand, type AutocompleteCommandContext, type AutocompleteCommandMiddlewareContext, Button, type ButtonChildrenLike, ButtonKit, type ButtonKitPredicate, type ButtonProps, type CacheContext, type CacheEntry, type CacheMetadata, CacheProvider, ChannelSelectMenu, ChannelSelectMenuKit, type ChannelSelectMenuKitPredicate, type ChannelSelectMenuProps, type Command, 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 CommandKitLoggerOptions, type CommandKitModalBuilderInteractionCollectorDispatch, type CommandKitModalBuilderInteractionCollectorDispatchContextData, type CommandKitModalBuilderOnEnd, type CommandKitOptions, type CommandKitPlugin, CommandKitPluginRuntime, type CommandKitSelectMenuBuilderInteractionCollectorDispatch, type CommandKitSelectMenuBuilderInteractionCollectorDispatchContextData, type CommandKitSelectMenuBuilderOnEnd, type CommandLocalizationTypeData, type CommandSource, type CommandTypeData, CommandsRouter, type CommandsRouterOptions, type CommonBuilderKit, type CommonPluginRuntime, type CommonSelectMenuProps, CompilerPlugin, CompilerPluginRuntime, Context, type ContextParameters, DefaultLocalizationStrategy, DefaultLogger, ElementType, EventInterceptor, type EventInterceptorContextData, type EventInterceptorErrorHandler, EventsRouter, type EventsRouterOptions, type EventsTree, Fragment, type FragmentElementProps, type GenericFunction, type ILogger, type InteractionCommandContext, type InteractionCommandMiddlewareContext, type LoadedCommand, type Loader, Localization, type LocalizationConfig, type LocalizationStrategy, type LocalizationTranslationRequest, 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 TranslatableArguments, type TranslatableCommand, type TranslatableCommandName, type TranslatableCommandOptions, type Translation, type TranslationResult, type Translator, 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, invalidate, isCachedFunction, isCommandKitElement, isCompilerPlugin, isInteractionSource, isMessageSource, isRuntimePlugin, makeContextAwareFunction, provideContext, redirect, rethrow, revalidate, useCache as super_duper_secret_internal_for_use_cache_directive_of_commandkit_cli_do_not_use_it_directly_or_you_will_be_fired_from_your_job_kthxbai, useEnvironment, version };
2027
+ export { ActionRow, type ActionRowProps, type AnyCommandExecute, type AnyCommandKitElement, type ApiTranslatableCommandOptions, 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 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 CommandLocalizationTypeData, type CommandSource, type CommandTypeData, CommandsRouter, type CommandsRouterOptions, type CommonBuilderKit, type CommonPluginRuntime, type CommonSelectMenuProps, CompilerPlugin, CompilerPluginRuntime, Context, type ContextParameters, DefaultLocalizationStrategy, 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, Localization, type LocalizationConfig, type LocalizationStrategy, type LocalizationTranslationRequest, 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 TranslatableArguments, type TranslatableCommand, type TranslatableCommandName, type TranslatableCommandOptions, type Translation, type TranslationResult, type Translator, 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 };