commandkit 1.0.0-dev.20250517124510 → 1.0.0-dev.20250518115601
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 +17 -2
- package/dist/index.js +50 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -652,8 +652,9 @@ interface SeparatorProps extends Omit<SeparatorComponentData, 'type'> {
|
|
|
652
652
|
}
|
|
653
653
|
declare function Separator(props: SeparatorProps): SeparatorBuilder;
|
|
654
654
|
|
|
655
|
+
type StringEncodable = string | number | boolean;
|
|
655
656
|
interface TextDisplayProps extends Omit<TextDisplayComponentData, 'type' | 'content'> {
|
|
656
|
-
children?:
|
|
657
|
+
children?: StringEncodable | StringEncodable[];
|
|
657
658
|
content?: string;
|
|
658
659
|
}
|
|
659
660
|
declare function TextDisplay(props: TextDisplayProps): TextDisplayBuilder;
|
|
@@ -1543,11 +1544,25 @@ declare abstract class RuntimePlugin<T extends PluginOptions = PluginOptions> ex
|
|
|
1543
1544
|
* @param env The environment of the command. This environment contains the command execution data such as command context and more.
|
|
1544
1545
|
*/
|
|
1545
1546
|
onAfterCommand(ctx: CommandKitPluginRuntime, env: CommandKitEnvironment): Promise<void>;
|
|
1547
|
+
/**
|
|
1548
|
+
* Called before emitting an event
|
|
1549
|
+
* @param ctx The context
|
|
1550
|
+
* @param event The event that is being emitted
|
|
1551
|
+
*/
|
|
1552
|
+
willEmitEvent(ctx: CommandKitPluginRuntime, event: CommandKitEventDispatch): Promise<void>;
|
|
1546
1553
|
}
|
|
1547
1554
|
declare function isRuntimePlugin(plugin: unknown): plugin is RuntimePlugin;
|
|
1548
1555
|
|
|
1549
1556
|
type CommandKitPlugin = RuntimePlugin | CompilerPlugin;
|
|
1550
1557
|
type MaybeFalsey<T> = T | false | null | undefined;
|
|
1558
|
+
interface CommandKitEventDispatch {
|
|
1559
|
+
name: string;
|
|
1560
|
+
args: unknown[];
|
|
1561
|
+
namespace: string | null;
|
|
1562
|
+
once: boolean;
|
|
1563
|
+
metadata: ParsedEvent;
|
|
1564
|
+
accept(): void;
|
|
1565
|
+
}
|
|
1551
1566
|
|
|
1552
1567
|
interface PluginTransformParameters {
|
|
1553
1568
|
args: OnLoadArgs;
|
|
@@ -2006,4 +2021,4 @@ declare function getEventWorkerContext(): EventWorkerContext;
|
|
|
2006
2021
|
*/
|
|
2007
2022
|
declare function bootstrapCommandkitCLI(argv: string[], options?: commander.ParseOptions | undefined): Promise<void>;
|
|
2008
2023
|
|
|
2009
|
-
export { ActionRow, type ActionRowProps, type AnyCommandExecute, type AnyCommandKitElement, AppCommandHandler, type AsyncFunction, type AutocompleteCommand, type AutocompleteCommandContext, type AutocompleteCommandMiddlewareContext, type BootstrapFunction, Button, type ButtonChildrenLike, ButtonKit, type ButtonKitPredicate, type ButtonProps, COMMANDKIT_BOOTSTRAP_MODE, COMMANDKIT_CACHE_TAG, COMMANDKIT_IS_DEV, COMMANDKIT_IS_TEST, ChannelSelectMenu, ChannelSelectMenuKit, type ChannelSelectMenuKitPredicate, type ChannelSelectMenuProps, type ChatInputCommand, type ChatInputCommandContext, type Command, type CommandBuilderLike, type CommandContext, type CommandContextOptions, type CommandData, CommandExecutionMode, type CommandFlagContext, 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, CommandRegistrar, type CommandSource, type CommandTypeData, CommandsRouter, type CommandsRouterOptions, type CommonBuilderKit, CommonDirectiveTransformer, type CommonDirectiveTransformerOptions, type CommonPluginRuntime, type CommonSelectMenuProps, CompilerPlugin, CompilerPluginRuntime, Container, type ContainerProps, Context, type ContextParameters, type CustomEvaluationContext, type CustomEvaluationFunction, type DecideFunction, DefaultLogger, ElementType, type EvaluationContext, type EventFlagContext, EventInterceptor, type EventInterceptorContextData, type EventInterceptorErrorHandler, type EventWorkerContext, EventsRouter, type EventsRouterOptions, type EventsTree, FeatureFlag, type FeatureFlagDefinition, File, type FileProps, type FlagRunner, Fragment, type FragmentElementProps, type GenericFunction, HMREventType, type ILogger, type IdentifyFunction, type InteractionCommandContext, type InteractionCommandMiddlewareContext, type LoadedCommand, type Loader, type Location, Logger, type LoggerImpl, type MaybeArray, type MaybeFalsey, type MaybePromise, MediaGallery, MediaGalleryItem, type MediaGalleryItemProps, type MediaGalleryProps, 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 PreRegisterCommandsEvent, type PreparedAppCommandExecution, type ResolvableCommand, type ResolveBuilderInteraction, type ResolveKind, type ResolveResult, RoleSelectMenu, RoleSelectMenuKit, type RoleSelectMenuKitPredicate, type RoleSelectMenuProps, type RunCommand, RuntimePlugin, Section, type SectionProps, type SelectMenuKitPredicate, type SelectMenuProps, Separator, type SeparatorProps, type Setup, ShortInput, type SlashCommandMiddlewareContext, StopEventPropagationError, StringSelectMenu, StringSelectMenuKit, type StringSelectMenuKitPredicate, StringSelectMenuOption, type StringSelectMenuOptionProps, type StringSelectMenuProps, TextDisplay, type TextDisplayProps, TextInput, type TextInputProps, Thumbnail, type ThumbnailProps, type TransformedResult, type UserContextMenuCommand, type UserContextMenuCommandContext, type UserContextMenuCommandMiddlewareContext, UserSelectMenu, UserSelectMenuKit, type UserSelectMenuKitPredicate, type UserSelectMenuProps, after, bootstrapCommandkitCLI, cancelAfter, commandkit, createElement, createLogger, debounce, CommandKit as default, defineConfig, devOnly, eventWorkerContext, exitContext, exitMiddleware, flag, fromEsbuildPlugin, getCommandKit, getConfig, getContext, getCurrentDirectory, getElement, getEventWorkerContext, getSourceDirectories, isCommandKitElement, isCompilerPlugin, isInteractionSource, isMessageSource, isRuntimePlugin, createElement as jsx, createElement as jsxs, makeContextAwareFunction, onApplicationBootstrap, onBootstrap, provideContext, redirect, rethrow, runInEventWorkerContext, stopEvents, useEnvironment, version };
|
|
2024
|
+
export { ActionRow, type ActionRowProps, type AnyCommandExecute, type AnyCommandKitElement, AppCommandHandler, type AsyncFunction, type AutocompleteCommand, type AutocompleteCommandContext, type AutocompleteCommandMiddlewareContext, type BootstrapFunction, Button, type ButtonChildrenLike, ButtonKit, type ButtonKitPredicate, type ButtonProps, COMMANDKIT_BOOTSTRAP_MODE, COMMANDKIT_CACHE_TAG, COMMANDKIT_IS_DEV, COMMANDKIT_IS_TEST, ChannelSelectMenu, ChannelSelectMenuKit, type ChannelSelectMenuKitPredicate, type ChannelSelectMenuProps, type ChatInputCommand, type ChatInputCommandContext, type Command, type CommandBuilderLike, type CommandContext, type CommandContextOptions, type CommandData, CommandExecutionMode, type CommandFlagContext, CommandKit, type CommandKitButtonBuilderInteractionCollectorDispatch, type CommandKitButtonBuilderInteractionCollectorDispatchContextData, type CommandKitButtonBuilderOnEnd, type CommandKitConfiguration, type CommandKitElement, type CommandKitElementData, CommandKitEnvironment, type CommandKitEnvironmentInternalData, CommandKitEnvironmentType, type CommandKitEventDispatch, type CommandKitHMREvent, type CommandKitLoggerOptions, type CommandKitModalBuilderInteractionCollectorDispatch, type CommandKitModalBuilderInteractionCollectorDispatchContextData, type CommandKitModalBuilderOnEnd, type CommandKitOptions, type CommandKitPlugin, CommandKitPluginRuntime, type CommandKitSelectMenuBuilderInteractionCollectorDispatch, type CommandKitSelectMenuBuilderInteractionCollectorDispatchContextData, type CommandKitSelectMenuBuilderOnEnd, CommandRegistrar, type CommandSource, type CommandTypeData, CommandsRouter, type CommandsRouterOptions, type CommonBuilderKit, CommonDirectiveTransformer, type CommonDirectiveTransformerOptions, type CommonPluginRuntime, type CommonSelectMenuProps, CompilerPlugin, CompilerPluginRuntime, Container, type ContainerProps, Context, type ContextParameters, type CustomEvaluationContext, type CustomEvaluationFunction, type DecideFunction, DefaultLogger, ElementType, type EvaluationContext, type EventFlagContext, EventInterceptor, type EventInterceptorContextData, type EventInterceptorErrorHandler, type EventWorkerContext, EventsRouter, type EventsRouterOptions, type EventsTree, FeatureFlag, type FeatureFlagDefinition, File, type FileProps, type FlagRunner, Fragment, type FragmentElementProps, type GenericFunction, HMREventType, type ILogger, type IdentifyFunction, type InteractionCommandContext, type InteractionCommandMiddlewareContext, type LoadedCommand, type Loader, type Location, Logger, type LoggerImpl, type MaybeArray, type MaybeFalsey, type MaybePromise, MediaGallery, MediaGalleryItem, type MediaGalleryItemProps, type MediaGalleryProps, 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 PreRegisterCommandsEvent, type PreparedAppCommandExecution, type ResolvableCommand, type ResolveBuilderInteraction, type ResolveKind, type ResolveResult, RoleSelectMenu, RoleSelectMenuKit, type RoleSelectMenuKitPredicate, type RoleSelectMenuProps, type RunCommand, RuntimePlugin, Section, type SectionProps, type SelectMenuKitPredicate, type SelectMenuProps, Separator, type SeparatorProps, type Setup, ShortInput, type SlashCommandMiddlewareContext, StopEventPropagationError, type StringEncodable, StringSelectMenu, StringSelectMenuKit, type StringSelectMenuKitPredicate, StringSelectMenuOption, type StringSelectMenuOptionProps, type StringSelectMenuProps, TextDisplay, type TextDisplayProps, TextInput, type TextInputProps, Thumbnail, type ThumbnailProps, type TransformedResult, type UserContextMenuCommand, type UserContextMenuCommandContext, type UserContextMenuCommandMiddlewareContext, UserSelectMenu, UserSelectMenuKit, type UserSelectMenuKitPredicate, type UserSelectMenuProps, after, bootstrapCommandkitCLI, cancelAfter, commandkit, createElement, createLogger, debounce, CommandKit as default, defineConfig, devOnly, eventWorkerContext, exitContext, exitMiddleware, flag, fromEsbuildPlugin, getCommandKit, getConfig, getContext, getCurrentDirectory, getElement, getEventWorkerContext, getSourceDirectories, isCommandKitElement, isCompilerPlugin, isInteractionSource, isMessageSource, isRuntimePlugin, createElement as jsx, createElement as jsxs, makeContextAwareFunction, onApplicationBootstrap, onBootstrap, provideContext, redirect, rethrow, runInEventWorkerContext, stopEvents, useEnvironment, version };
|
package/dist/index.js
CHANGED
|
@@ -1558,7 +1558,6 @@ var init_common2 = __esm({
|
|
|
1558
1558
|
|
|
1559
1559
|
// src/components/v2/container.ts
|
|
1560
1560
|
function Container(props) {
|
|
1561
|
-
var _a;
|
|
1562
1561
|
const container = new import_discord12.ContainerBuilder();
|
|
1563
1562
|
applyId(props, container);
|
|
1564
1563
|
if (typeof props.accentColor != null) {
|
|
@@ -1567,7 +1566,9 @@ function Container(props) {
|
|
|
1567
1566
|
if (props.spoiler != null) {
|
|
1568
1567
|
container.setSpoiler(props.spoiler);
|
|
1569
1568
|
}
|
|
1570
|
-
if (
|
|
1569
|
+
if (props.children != null) {
|
|
1570
|
+
if (!Array.isArray(props.children)) props.children = [props.children];
|
|
1571
|
+
if (props.children.length === 0) return container;
|
|
1571
1572
|
for (const child of props.children.flat()) {
|
|
1572
1573
|
if (child instanceof import_discord12.TextDisplayBuilder) {
|
|
1573
1574
|
container.addTextDisplayComponents(child);
|
|
@@ -1625,6 +1626,7 @@ function MediaGallery(props) {
|
|
|
1625
1626
|
const gallery = new import_discord14.MediaGalleryBuilder();
|
|
1626
1627
|
applyId(props, gallery);
|
|
1627
1628
|
if (props.children != null) {
|
|
1629
|
+
if (!Array.isArray(props.children)) props.children = [props.children];
|
|
1628
1630
|
gallery.addItems(props.children.flat());
|
|
1629
1631
|
}
|
|
1630
1632
|
return gallery;
|
|
@@ -1659,6 +1661,7 @@ function Section(props) {
|
|
|
1659
1661
|
const section = new import_discord15.SectionBuilder();
|
|
1660
1662
|
applyId(props, section);
|
|
1661
1663
|
if (props.children != null) {
|
|
1664
|
+
if (!Array.isArray(props.children)) props.children = [props.children];
|
|
1662
1665
|
for (const accessory of props.children.flat()) {
|
|
1663
1666
|
if (accessory instanceof import_discord15.ThumbnailBuilder) {
|
|
1664
1667
|
section.setThumbnailAccessory(accessory);
|
|
@@ -1714,7 +1717,9 @@ function TextDisplay(props) {
|
|
|
1714
1717
|
if (Array.isArray(props.children)) {
|
|
1715
1718
|
textDisplay.setContent(props.children.join(" "));
|
|
1716
1719
|
} else {
|
|
1717
|
-
textDisplay.setContent(
|
|
1720
|
+
textDisplay.setContent(
|
|
1721
|
+
typeof props.children === "string" ? props.children : String(props.children)
|
|
1722
|
+
);
|
|
1718
1723
|
}
|
|
1719
1724
|
}
|
|
1720
1725
|
return textDisplay;
|
|
@@ -2230,6 +2235,13 @@ var init_RuntimePlugin = __esm({
|
|
|
2230
2235
|
*/
|
|
2231
2236
|
async onAfterCommand(ctx, env) {
|
|
2232
2237
|
}
|
|
2238
|
+
/**
|
|
2239
|
+
* Called before emitting an event
|
|
2240
|
+
* @param ctx The context
|
|
2241
|
+
* @param event The event that is being emitted
|
|
2242
|
+
*/
|
|
2243
|
+
async willEmitEvent(ctx, event) {
|
|
2244
|
+
}
|
|
2233
2245
|
};
|
|
2234
2246
|
__name(_RuntimePlugin, "RuntimePlugin");
|
|
2235
2247
|
RuntimePlugin = _RuntimePlugin;
|
|
@@ -4920,6 +4932,23 @@ var init_AppEventsHandler = __esm({
|
|
|
4920
4932
|
const onListeners = listeners.filter((listener) => !listener.once);
|
|
4921
4933
|
const executedOnceListeners = /* @__PURE__ */ new Set();
|
|
4922
4934
|
const mainHandler = /* @__PURE__ */ __name(async (...args) => {
|
|
4935
|
+
let accepted = false;
|
|
4936
|
+
const event = {
|
|
4937
|
+
name,
|
|
4938
|
+
args,
|
|
4939
|
+
namespace: namespace ?? null,
|
|
4940
|
+
once: false,
|
|
4941
|
+
metadata: data.event,
|
|
4942
|
+
accept() {
|
|
4943
|
+
if (accepted) return;
|
|
4944
|
+
accepted = true;
|
|
4945
|
+
}
|
|
4946
|
+
};
|
|
4947
|
+
await this.commandkit.plugins.execute(async (ctx, plugin) => {
|
|
4948
|
+
var _a;
|
|
4949
|
+
if (accepted) return;
|
|
4950
|
+
return (_a = plugin.willEmitEvent) == null ? void 0 : _a.call(plugin, ctx, event);
|
|
4951
|
+
}).catch(Object);
|
|
4923
4952
|
await runInEventWorkerContext(
|
|
4924
4953
|
{
|
|
4925
4954
|
event: name,
|
|
@@ -4950,6 +4979,23 @@ var init_AppEventsHandler = __esm({
|
|
|
4950
4979
|
}, "mainHandler");
|
|
4951
4980
|
const onceHandler = /* @__PURE__ */ __name(async (...args) => {
|
|
4952
4981
|
let broken = false;
|
|
4982
|
+
let accepted = false;
|
|
4983
|
+
const event = {
|
|
4984
|
+
name,
|
|
4985
|
+
args,
|
|
4986
|
+
namespace: namespace ?? null,
|
|
4987
|
+
once: true,
|
|
4988
|
+
metadata: data.event,
|
|
4989
|
+
accept() {
|
|
4990
|
+
if (accepted) return;
|
|
4991
|
+
accepted = true;
|
|
4992
|
+
}
|
|
4993
|
+
};
|
|
4994
|
+
await this.commandkit.plugins.execute(async (ctx, plugin) => {
|
|
4995
|
+
var _a;
|
|
4996
|
+
if (accepted) return;
|
|
4997
|
+
return (_a = plugin.willEmitEvent) == null ? void 0 : _a.call(plugin, ctx, event);
|
|
4998
|
+
}).catch(Object);
|
|
4953
4999
|
for (const listener of onceListeners) {
|
|
4954
5000
|
if (broken) break;
|
|
4955
5001
|
await runInEventWorkerContext(
|
|
@@ -5656,7 +5702,7 @@ var init_version = __esm({
|
|
|
5656
5702
|
"use strict";
|
|
5657
5703
|
init_cjs_shims();
|
|
5658
5704
|
version = /* @__MACRO__ $version */
|
|
5659
|
-
"1.0.0-dev.
|
|
5705
|
+
"1.0.0-dev.20250518115601";
|
|
5660
5706
|
}
|
|
5661
5707
|
});
|
|
5662
5708
|
|