commandkit 1.0.0-dev.20250624020525 → 1.0.0-dev.20250624130949
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/{CommandKit-DV3O3x3J.js → CommandKit-BZVEqKzs.js} +51 -36
- package/dist/CommandKit-BZVEqKzs.js.map +1 -0
- package/dist/{CommandKit-SL7ggUn-.d.ts → CommandKit-CGl1oEv3.d.ts} +108 -13
- package/dist/CommandKit.d.ts +1 -1
- package/dist/CommandKit.js +1 -1
- package/dist/{DefaultLogger-pWzrSxMd.d.ts → DefaultLogger-Cy55-uPl.d.ts} +2 -2
- package/dist/{EventWorkerContext-D9Q_ENWf.d.ts → EventWorkerContext-rYysGdKJ.d.ts} +2 -2
- package/dist/{ILogger-Cs5SFzqd.d.ts → ILogger-DBGON5wx.d.ts} +1 -1
- package/dist/{Logger-5ew_YS4P.d.ts → Logger-iSjA-DWN.d.ts} +2 -2
- package/dist/analytics/analytics-engine.d.ts +1 -1
- package/dist/analytics/analytics-engine.js +1 -1
- package/dist/analytics/analytics-provider.d.ts +1 -1
- package/dist/analytics/utils.js +1 -1
- package/dist/app/commands/AppCommandRunner.d.ts +1 -1
- package/dist/app/commands/AppCommandRunner.js +1 -1
- package/dist/app/commands/Context.d.ts +1 -1
- package/dist/app/commands/Context.js +1 -1
- package/dist/app/events/EventWorkerContext.d.ts +2 -2
- package/dist/app/handlers/AppCommandHandler.d.ts +1 -1
- package/dist/app/handlers/AppCommandHandler.js +1 -1
- package/dist/app/handlers/AppEventsHandler.d.ts +1 -1
- package/dist/app/handlers/AppEventsHandler.js +1 -1
- package/dist/app/index.d.ts +1 -1
- package/dist/app/index.js +1 -1
- package/dist/app/register/CommandRegistrar.d.ts +1 -1
- package/dist/app/register/CommandRegistrar.js +1 -1
- package/dist/{build-CjQg1n-5.js → build-CI-WOwAi.js} +2 -2
- package/dist/{build-CjQg1n-5.js.map → build-CI-WOwAi.js.map} +1 -1
- package/dist/cli/app-process.d.ts +2 -2
- package/dist/cli/build.d.ts +1 -1
- package/dist/cli/build.js +2 -2
- package/dist/cli/common.d.ts +3 -5
- package/dist/cli/development.js +7 -5
- package/dist/cli/development.js.map +1 -1
- package/dist/cli/information.js +1 -1
- package/dist/cli/init.d.ts +1 -1
- package/dist/cli/init.js +2 -2
- package/dist/cli/production.js +2 -2
- package/dist/components/index.js +1 -1
- package/dist/components/v1/button/Button.js +1 -1
- package/dist/components/v1/button/ButtonKit.js +1 -1
- package/dist/components/v1/modal/Modal.js +1 -1
- package/dist/components/v1/modal/ModalKit.js +1 -1
- package/dist/components/v1/select-menu/ChannelSelectMenuKit.js +1 -1
- package/dist/components/v1/select-menu/MentionableSelectMenuKit.js +1 -1
- package/dist/components/v1/select-menu/RoleSelectMenuKit.js +1 -1
- package/dist/components/v1/select-menu/SelectMenu.js +1 -1
- package/dist/components/v1/select-menu/StringSelectMenuKit.js +1 -1
- package/dist/components/v1/select-menu/UserSelectMenuKit.js +1 -1
- package/dist/config/config.d.ts +2 -4
- package/dist/config/config.js +1 -1
- package/dist/config/default.d.ts +1 -3
- package/dist/config/default.js +1 -1
- package/dist/config/loader.d.ts +1 -3
- package/dist/config/loader.js +1 -1
- package/dist/config/types.d.ts +1 -2
- package/dist/config/utils.d.ts +1 -3
- package/dist/{config-Cs_7avuG.d.ts → config-BL8EHesJ.d.ts} +2 -3
- package/dist/context/async-context.d.ts +1 -1
- package/dist/context/async-context.js +1 -1
- package/dist/context/environment.d.ts +1 -1
- package/dist/context/environment.js +1 -1
- package/dist/events/CommandKitEventsChannel.d.ts +1 -1
- package/dist/{feature-flags-CFoqosTw.js → feature-flags-IU-pT6k_.js} +2 -2
- package/dist/{feature-flags-CFoqosTw.js.map → feature-flags-IU-pT6k_.js.map} +1 -1
- package/dist/flags/FlagProvider.d.ts +1 -1
- package/dist/flags/feature-flags.d.ts +1 -1
- package/dist/flags/feature-flags.js +2 -2
- package/dist/flags/store.d.ts +1 -1
- package/dist/index.d.ts +9 -11
- package/dist/index.js +4 -4
- package/dist/{init-muFynnQh.js → init-D3mhxEzo.js} +2 -2
- package/dist/{init-muFynnQh.js.map → init-D3mhxEzo.js.map} +1 -1
- package/dist/{init-CT348Okf.d.ts → init-DsaK1AfD.d.ts} +1 -1
- package/dist/logger/DefaultLogger.d.ts +2 -2
- package/dist/logger/DefaultLogger.js +1 -1
- package/dist/logger/ILogger.d.ts +1 -1
- package/dist/logger/Logger.d.ts +2 -2
- package/dist/logger/Logger.js +1 -1
- package/dist/logger/NoopLogger.d.ts +37 -0
- package/dist/logger/NoopLogger.js +36 -0
- package/dist/logger/NoopLogger.js.map +1 -0
- package/dist/plugins/CompilerPlugin.d.ts +1 -1
- package/dist/plugins/PluginCommon.d.ts +1 -1
- package/dist/plugins/RuntimePlugin.d.ts +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.d.ts +1 -1
- package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.js +1 -1
- package/dist/plugins/plugin-runtime/CompilerPluginRuntime.d.ts +1 -1
- package/dist/plugins/plugin-runtime/CompilerPluginRuntime.js +1 -1
- package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.d.ts +1 -1
- package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.js +1 -1
- package/dist/plugins/plugin-runtime/builtin/MacroPlugin.d.ts +1 -1
- package/dist/plugins/plugin-runtime/builtin/MacroPlugin.js +1 -1
- package/dist/plugins/plugin-runtime/runtime.d.ts +1 -1
- package/dist/plugins/types.d.ts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/{utilities-CQUaua43.d.ts → utilities-DtdPlr4c.d.ts} +1 -1
- package/dist/utils/dev-hooks.d.ts +1 -1
- package/dist/utils/dev-hooks.js +1 -1
- package/dist/utils/utilities.d.ts +1 -1
- package/dist/utils/utilities.js +1 -1
- package/dist/{version-DggMfP_1.d.ts → version-CtJtBJXI.d.ts} +1 -1
- package/dist/{version-D3SkBVwJ.js → version-t3Nw0T3Q.js} +2 -2
- package/dist/{version-D3SkBVwJ.js.map → version-t3Nw0T3Q.js.map} +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/logger.cjs +2 -0
- package/logger.d.ts +3 -0
- package/package.json +2 -2
- package/dist/CommandKit-DV3O3x3J.js.map +0 -1
- package/dist/types-DI20wefl.d.ts +0 -78
- package/dist/utils-NtJ5thv2.d.ts +0 -20
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EventInterceptor } from "./EventInterceptor-x-R2qshQ.js";
|
|
2
2
|
import { Fragment, createElement } from "./element-CAXu1XtK.js";
|
|
3
|
+
import { MaybeArray } from "./types-CJ-XvOFN.js";
|
|
3
4
|
import { MessageCommandOptions, MessageCommandParser } from "./MessageCommandParser-ROLibZPX.js";
|
|
4
5
|
import { Command, CommandsRouter, Middleware } from "./CommandsRouter-CoOA7hkf.js";
|
|
5
6
|
import { EventsRouter, ParsedEvent } from "./EventsRouter-BacqK6z3.js";
|
|
@@ -42,6 +43,7 @@ interface CommandContext<T extends Interaction, Cached extends CacheType> {
|
|
|
42
43
|
type CommandData = Prettify<Omit<RESTPostAPIApplicationCommandsJSONBody, 'description'> & {
|
|
43
44
|
description?: string;
|
|
44
45
|
guilds?: string[];
|
|
46
|
+
aliases?: string[];
|
|
45
47
|
}>;
|
|
46
48
|
//#endregion
|
|
47
49
|
//#region src/app/commands/Context.d.ts
|
|
@@ -739,16 +741,6 @@ declare class AppCommandHandler {
|
|
|
739
741
|
* @internal
|
|
740
742
|
*/
|
|
741
743
|
private loadedMiddlewares;
|
|
742
|
-
/**
|
|
743
|
-
* @private
|
|
744
|
-
* @internal
|
|
745
|
-
*/
|
|
746
|
-
private commandNameToId;
|
|
747
|
-
/**
|
|
748
|
-
* @private
|
|
749
|
-
* @internal
|
|
750
|
-
*/
|
|
751
|
-
private subcommandPathToId;
|
|
752
744
|
/**
|
|
753
745
|
* Command registrar for handling Discord API registration.
|
|
754
746
|
*/
|
|
@@ -800,6 +792,12 @@ declare class AppCommandHandler {
|
|
|
800
792
|
* @returns Prepared command execution data or null if command not found
|
|
801
793
|
*/
|
|
802
794
|
prepareCommandRun(source: Interaction | Message, cmdName?: string): Promise<PreparedAppCommandExecution | null>;
|
|
795
|
+
/**
|
|
796
|
+
* Finds a command by name.
|
|
797
|
+
* @param name - The command name to search for
|
|
798
|
+
* @returns The loaded command or null if not found
|
|
799
|
+
*/
|
|
800
|
+
private findCommandByName;
|
|
803
801
|
/**
|
|
804
802
|
* Reloads all commands and middleware from scratch.
|
|
805
803
|
*/
|
|
@@ -1854,6 +1852,99 @@ declare class AnalyticsEngine {
|
|
|
1854
1852
|
track(event: AnalyticsEvent): Promise<void>;
|
|
1855
1853
|
}
|
|
1856
1854
|
//#endregion
|
|
1855
|
+
//#region src/config/types.d.ts
|
|
1856
|
+
interface CommandKitConfig {
|
|
1857
|
+
/**
|
|
1858
|
+
* The plugins to use with CommandKit.
|
|
1859
|
+
* Can be a single plugin, an array of plugins, or a nested array of plugins.
|
|
1860
|
+
*/
|
|
1861
|
+
plugins?: MaybeArray<CommandKitPlugin>[] | Array<CommandKitPlugin>;
|
|
1862
|
+
/**
|
|
1863
|
+
* The rolldown plugins to use with CommandKit.
|
|
1864
|
+
*/
|
|
1865
|
+
rolldownPlugins?: any[];
|
|
1866
|
+
/**
|
|
1867
|
+
* The compiler options to use with CommandKit.
|
|
1868
|
+
*/
|
|
1869
|
+
compilerOptions?: {
|
|
1870
|
+
/**
|
|
1871
|
+
* Macro compiler configuration.
|
|
1872
|
+
*/
|
|
1873
|
+
macro?: {
|
|
1874
|
+
/**
|
|
1875
|
+
* Whether to enable macro function compilation in development mode.
|
|
1876
|
+
* @default false
|
|
1877
|
+
*/
|
|
1878
|
+
development?: boolean;
|
|
1879
|
+
};
|
|
1880
|
+
};
|
|
1881
|
+
/**
|
|
1882
|
+
* The typescript configuration to use with CommandKit.
|
|
1883
|
+
*/
|
|
1884
|
+
typescript?: {
|
|
1885
|
+
/**
|
|
1886
|
+
* Whether to ignore type checking during builds.
|
|
1887
|
+
*/
|
|
1888
|
+
ignoreBuildErrors?: boolean;
|
|
1889
|
+
};
|
|
1890
|
+
/**
|
|
1891
|
+
* Whether to generate static command handler data in production builds.
|
|
1892
|
+
*/
|
|
1893
|
+
static?: boolean;
|
|
1894
|
+
/**
|
|
1895
|
+
* Statically define the environment variables to use.
|
|
1896
|
+
*/
|
|
1897
|
+
env?: Record<string, string>;
|
|
1898
|
+
/**
|
|
1899
|
+
* The custom build directory name to use.
|
|
1900
|
+
* @default `dist`
|
|
1901
|
+
*/
|
|
1902
|
+
distDir?: string;
|
|
1903
|
+
/**
|
|
1904
|
+
* Whether or not to enable the source map generation.
|
|
1905
|
+
*/
|
|
1906
|
+
sourceMap?: {
|
|
1907
|
+
/**
|
|
1908
|
+
* Whether to enable source map generation in development mode.
|
|
1909
|
+
*/
|
|
1910
|
+
development?: boolean;
|
|
1911
|
+
/**
|
|
1912
|
+
* Whether to enable source map generation in production mode.
|
|
1913
|
+
*/
|
|
1914
|
+
production?: boolean;
|
|
1915
|
+
};
|
|
1916
|
+
/**
|
|
1917
|
+
* Whether or not to enable the typed commands.
|
|
1918
|
+
* @default true
|
|
1919
|
+
*/
|
|
1920
|
+
typedCommands?: boolean;
|
|
1921
|
+
/**
|
|
1922
|
+
* Whether or not to disable the prefix commands.
|
|
1923
|
+
* @default false
|
|
1924
|
+
*/
|
|
1925
|
+
disablePrefixCommands?: boolean;
|
|
1926
|
+
/**
|
|
1927
|
+
* Whether or not to show a warning when a prefix command is not found. This only affects development mode.
|
|
1928
|
+
* @default true
|
|
1929
|
+
*/
|
|
1930
|
+
showUnknownPrefixCommandsWarning?: boolean;
|
|
1931
|
+
}
|
|
1932
|
+
//#endregion
|
|
1933
|
+
//#region src/config/utils.d.ts
|
|
1934
|
+
/**
|
|
1935
|
+
* @private
|
|
1936
|
+
*/
|
|
1937
|
+
type DeepRequired<T> = { [P in keyof T]-?: DeepRequired<T[P]> };
|
|
1938
|
+
/**
|
|
1939
|
+
* @private
|
|
1940
|
+
*/
|
|
1941
|
+
type DeepPartial<T> = { [P in keyof T]?: DeepPartial<T[P]> };
|
|
1942
|
+
/**
|
|
1943
|
+
* @private
|
|
1944
|
+
*/
|
|
1945
|
+
declare const mergeDeep: <T extends Record<string, any>>(target: T, source: T) => T;
|
|
1946
|
+
type ResolvedCommandKitConfig = DeepRequired<CommandKitConfig>;
|
|
1947
|
+
//#endregion
|
|
1857
1948
|
//#region src/CommandKit.d.ts
|
|
1858
1949
|
/**
|
|
1859
1950
|
* Configurations for the CommandKit instance.
|
|
@@ -1924,7 +2015,11 @@ declare class CommandKit extends EventEmitter {
|
|
|
1924
2015
|
/**
|
|
1925
2016
|
* The configuration for the CommandKit instance.
|
|
1926
2017
|
*/
|
|
1927
|
-
readonly
|
|
2018
|
+
readonly appConfig: CommandKitConfiguration;
|
|
2019
|
+
/**
|
|
2020
|
+
* The configuration for the CommandKit environment.
|
|
2021
|
+
*/
|
|
2022
|
+
config: ResolvedCommandKitConfig;
|
|
1928
2023
|
/**
|
|
1929
2024
|
* A key-value store for storing arbitrary data.
|
|
1930
2025
|
*/
|
|
@@ -2041,5 +2136,5 @@ declare class CommandKit extends EventEmitter {
|
|
|
2041
2136
|
*/
|
|
2042
2137
|
declare const commandkit: CommandKit;
|
|
2043
2138
|
//#endregion
|
|
2044
|
-
export { AnalyticsEngine, AnalyticsEvent, AnalyticsProvider, AnyCommandExecute, AppCommand, AppCommandHandler, AppCommandNative, AppCommandRunner, AppEventsHandler, AppEventsHandlerLoadedData, AsyncFunction, AutocompleteCommand, AutocompleteCommandContext, AutocompleteCommandMiddlewareContext, BootstrapFunction, ChatInputCommand, ChatInputCommandContext, CommandBuilderLike, CommandContext, CommandContextOptions, CommandData, CommandDataSchema, CommandDataSchemaKey, CommandDataSchemaValue, CommandExecutionMode, CommandFlagContext, CommandKit, CommandKitConfiguration, CommandKitEnvironment, CommandKitEnvironmentInternalData, CommandKitEnvironmentType, CommandKitEventDispatch, CommandKitEventsChannel, CommandKitHMREvent, CommandKitOptions, CommandKitPlugin, CommandKitPluginRuntime, CommandRegistrar, CommandTypeData, CommonDirectiveTransformer, CommonDirectiveTransformerOptions, CommonPluginRuntime, CompilerPlugin, CompilerPluginRuntime, Context, ContextParameters, CustomAppCommandProps, CustomEvaluationContext, CustomEvaluationFunction, DecideFunction, EvaluationContext, EventFlagContext, EventListener, FeatureFlag, FeatureFlagDefinition, FilterFunction, FlagConfiguration, FlagProvider, FlagRunner, FlagStore, GenericFunction, IdentifyEvent, IdentifyFunction, InteractionCommandContext, InteractionCommandMiddlewareContext, IpcMessageCommand, JsonFlagProvider, ListenerFunction, LoadedCommand, LoadedEvent, MaybeFalsey, MaybePromise, MessageCommand, MessageCommandContext, MessageCommandMiddlewareContext, MessageContextMenuCommand, MessageContextMenuCommandContext, MessageContextMenuCommandMiddlewareContext, MiddlewareContext, MiddlewareContextArgs, PluginCommon, PluginOptions, PluginTransformParameters, PluginType, PreRegisterCommandsEvent, PreparedAppCommandExecution, ResolvableCommand, RunCommand, RunCommandOptions, RuntimePlugin, SlashCommandMiddlewareContext, TemplateHandler, TransformedResult, UserContextMenuCommand, UserContextMenuCommandContext, UserContextMenuCommandMiddlewareContext, after, cancelAfter, commandkit, exitContext, flag, getCommandKit, getContext, isCommandWorkerContext, isCompilerPlugin, isPlugin, isRuntimePlugin, makeContextAwareFunction, onApplicationBootstrap, onBootstrap, provideContext, registerDevHooks, setFlagProvider, useEnvironment };
|
|
2045
|
-
//# sourceMappingURL=CommandKit-
|
|
2139
|
+
export { AnalyticsEngine, AnalyticsEvent, AnalyticsProvider, AnyCommandExecute, AppCommand, AppCommandHandler, AppCommandNative, AppCommandRunner, AppEventsHandler, AppEventsHandlerLoadedData, AsyncFunction, AutocompleteCommand, AutocompleteCommandContext, AutocompleteCommandMiddlewareContext, BootstrapFunction, ChatInputCommand, ChatInputCommandContext, CommandBuilderLike, CommandContext, CommandContextOptions, CommandData, CommandDataSchema, CommandDataSchemaKey, CommandDataSchemaValue, CommandExecutionMode, CommandFlagContext, CommandKit, CommandKitConfig, CommandKitConfiguration, CommandKitEnvironment, CommandKitEnvironmentInternalData, CommandKitEnvironmentType, CommandKitEventDispatch, CommandKitEventsChannel, CommandKitHMREvent, CommandKitOptions, CommandKitPlugin, CommandKitPluginRuntime, CommandRegistrar, CommandTypeData, CommonDirectiveTransformer, CommonDirectiveTransformerOptions, CommonPluginRuntime, CompilerPlugin, CompilerPluginRuntime, Context, ContextParameters, CustomAppCommandProps, CustomEvaluationContext, CustomEvaluationFunction, DecideFunction, DeepPartial, DeepRequired, EvaluationContext, EventFlagContext, EventListener, FeatureFlag, FeatureFlagDefinition, FilterFunction, FlagConfiguration, FlagProvider, FlagRunner, FlagStore, GenericFunction, IdentifyEvent, IdentifyFunction, InteractionCommandContext, InteractionCommandMiddlewareContext, IpcMessageCommand, JsonFlagProvider, ListenerFunction, LoadedCommand, LoadedEvent, MaybeFalsey, MaybePromise, MessageCommand, MessageCommandContext, MessageCommandMiddlewareContext, MessageContextMenuCommand, MessageContextMenuCommandContext, MessageContextMenuCommandMiddlewareContext, MiddlewareContext, MiddlewareContextArgs, PluginCommon, PluginOptions, PluginTransformParameters, PluginType, PreRegisterCommandsEvent, PreparedAppCommandExecution, ResolvableCommand, ResolvedCommandKitConfig, RunCommand, RunCommandOptions, RuntimePlugin, SlashCommandMiddlewareContext, TemplateHandler, TransformedResult, UserContextMenuCommand, UserContextMenuCommandContext, UserContextMenuCommandMiddlewareContext, after, cancelAfter, commandkit, exitContext, flag, getCommandKit, getContext, isCommandWorkerContext, isCompilerPlugin, isPlugin, isRuntimePlugin, makeContextAwareFunction, mergeDeep, onApplicationBootstrap, onBootstrap, provideContext, registerDevHooks, setFlagProvider, useEnvironment };
|
|
2140
|
+
//# sourceMappingURL=CommandKit-CGl1oEv3.d.ts.map
|
package/dist/CommandKit.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BootstrapFunction, CommandKit, CommandKitConfiguration, commandkit, onApplicationBootstrap, onBootstrap } from "./CommandKit-
|
|
1
|
+
import { BootstrapFunction, CommandKit, CommandKitConfiguration, commandkit, onApplicationBootstrap, onBootstrap } from "./CommandKit-CGl1oEv3.js";
|
|
2
2
|
import "./EventInterceptor-x-R2qshQ.js";
|
|
3
3
|
import "./ButtonKit-C7r7RPNf.js";
|
|
4
4
|
import "./ModalKit-Btz58KYn.js";
|
package/dist/CommandKit.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require('./colors-Cd4Oz-r-.js');
|
|
2
2
|
require('./ActionRow-CmTHbo2t.js');
|
|
3
3
|
require('./error-codes-DXOuid4c.js');
|
|
4
|
-
const require_CommandKit = require('./CommandKit-
|
|
4
|
+
const require_CommandKit = require('./CommandKit-BZVEqKzs.js');
|
|
5
5
|
require('./common-CcfjYnPG.js');
|
|
6
6
|
require('./common-vnMIelAE.js');
|
|
7
7
|
require('./container-DCjIgp-B.js');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ILogger } from "./ILogger-
|
|
1
|
+
import { ILogger } from "./ILogger-DBGON5wx.js";
|
|
2
2
|
|
|
3
3
|
//#region src/logger/DefaultLogger.d.ts
|
|
4
4
|
|
|
@@ -57,4 +57,4 @@ declare class DefaultLogger implements ILogger {
|
|
|
57
57
|
}
|
|
58
58
|
//#endregion
|
|
59
59
|
export { DefaultLogger };
|
|
60
|
-
//# sourceMappingURL=DefaultLogger-
|
|
60
|
+
//# sourceMappingURL=DefaultLogger-Cy55-uPl.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommandKit } from "./CommandKit-
|
|
1
|
+
import { CommandKit } from "./CommandKit-CGl1oEv3.js";
|
|
2
2
|
import { ParsedEvent } from "./EventsRouter-BacqK6z3.js";
|
|
3
3
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
4
|
|
|
@@ -40,4 +40,4 @@ declare function getEventWorkerContext(): EventWorkerContext;
|
|
|
40
40
|
declare function isEventWorkerContext(worker: any): worker is EventWorkerContext;
|
|
41
41
|
//#endregion
|
|
42
42
|
export { EventWorkerContext, eventWorkerContext, getEventWorkerContext, isEventWorkerContext, runInEventWorkerContext };
|
|
43
|
-
//# sourceMappingURL=EventWorkerContext-
|
|
43
|
+
//# sourceMappingURL=EventWorkerContext-rYysGdKJ.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ILogger } from "./ILogger-
|
|
1
|
+
import { ILogger } from "./ILogger-DBGON5wx.js";
|
|
2
2
|
|
|
3
3
|
//#region src/logger/Logger.d.ts
|
|
4
4
|
|
|
@@ -34,4 +34,4 @@ declare function createLogger(options: CommandKitLoggerOptions): LoggerImpl;
|
|
|
34
34
|
declare const Logger: LoggerImpl;
|
|
35
35
|
//#endregion
|
|
36
36
|
export { CommandKitLoggerOptions, Logger, LoggerImpl, createLogger };
|
|
37
|
-
//# sourceMappingURL=Logger-
|
|
37
|
+
//# sourceMappingURL=Logger-iSjA-DWN.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnalyticsEngine, FilterFunction } from "../CommandKit-
|
|
1
|
+
import { AnalyticsEngine, FilterFunction } from "../CommandKit-CGl1oEv3.js";
|
|
2
2
|
import "../EventInterceptor-x-R2qshQ.js";
|
|
3
3
|
import "../ButtonKit-C7r7RPNf.js";
|
|
4
4
|
import "../ModalKit-Btz58KYn.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require('../colors-Cd4Oz-r-.js');
|
|
2
2
|
require('../ActionRow-CmTHbo2t.js');
|
|
3
3
|
require('../error-codes-DXOuid4c.js');
|
|
4
|
-
const require_CommandKit = require('../CommandKit-
|
|
4
|
+
const require_CommandKit = require('../CommandKit-BZVEqKzs.js');
|
|
5
5
|
require('../common-CcfjYnPG.js');
|
|
6
6
|
require('../common-vnMIelAE.js');
|
|
7
7
|
require('../container-DCjIgp-B.js');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnalyticsEvent, AnalyticsProvider, IdentifyEvent } from "../CommandKit-
|
|
1
|
+
import { AnalyticsEvent, AnalyticsProvider, IdentifyEvent } from "../CommandKit-CGl1oEv3.js";
|
|
2
2
|
import "../EventInterceptor-x-R2qshQ.js";
|
|
3
3
|
import "../ButtonKit-C7r7RPNf.js";
|
|
4
4
|
import "../ModalKit-Btz58KYn.js";
|
package/dist/analytics/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require('../colors-Cd4Oz-r-.js');
|
|
2
2
|
require('../ActionRow-CmTHbo2t.js');
|
|
3
3
|
require('../error-codes-DXOuid4c.js');
|
|
4
|
-
const require_CommandKit = require('../CommandKit-
|
|
4
|
+
const require_CommandKit = require('../CommandKit-BZVEqKzs.js');
|
|
5
5
|
require('../common-CcfjYnPG.js');
|
|
6
6
|
require('../common-vnMIelAE.js');
|
|
7
7
|
require('../container-DCjIgp-B.js');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AppCommandRunner, RunCommandOptions } from "../../CommandKit-
|
|
1
|
+
import { AppCommandRunner, RunCommandOptions } from "../../CommandKit-CGl1oEv3.js";
|
|
2
2
|
import "../../EventInterceptor-x-R2qshQ.js";
|
|
3
3
|
import "../../ButtonKit-C7r7RPNf.js";
|
|
4
4
|
import "../../ModalKit-Btz58KYn.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require('../../colors-Cd4Oz-r-.js');
|
|
2
2
|
require('../../ActionRow-CmTHbo2t.js');
|
|
3
3
|
require('../../error-codes-DXOuid4c.js');
|
|
4
|
-
const require_CommandKit = require('../../CommandKit-
|
|
4
|
+
const require_CommandKit = require('../../CommandKit-BZVEqKzs.js');
|
|
5
5
|
require('../../common-CcfjYnPG.js');
|
|
6
6
|
require('../../common-vnMIelAE.js');
|
|
7
7
|
require('../../container-DCjIgp-B.js');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyCommandExecute, AutocompleteCommand, AutocompleteCommandContext, AutocompleteCommandMiddlewareContext, ChatInputCommand, ChatInputCommandContext, CommandContextOptions, CommandExecutionMode, Context, ContextParameters, InteractionCommandContext, InteractionCommandMiddlewareContext, MessageCommand, MessageCommandContext, MessageCommandMiddlewareContext, MessageContextMenuCommand, MessageContextMenuCommandContext, MessageContextMenuCommandMiddlewareContext, MiddlewareContext, MiddlewareContextArgs, SlashCommandMiddlewareContext, UserContextMenuCommand, UserContextMenuCommandContext, UserContextMenuCommandMiddlewareContext } from "../../CommandKit-
|
|
1
|
+
import { AnyCommandExecute, AutocompleteCommand, AutocompleteCommandContext, AutocompleteCommandMiddlewareContext, ChatInputCommand, ChatInputCommandContext, CommandContextOptions, CommandExecutionMode, Context, ContextParameters, InteractionCommandContext, InteractionCommandMiddlewareContext, MessageCommand, MessageCommandContext, MessageCommandMiddlewareContext, MessageContextMenuCommand, MessageContextMenuCommandContext, MessageContextMenuCommandMiddlewareContext, MiddlewareContext, MiddlewareContextArgs, SlashCommandMiddlewareContext, UserContextMenuCommand, UserContextMenuCommandContext, UserContextMenuCommandMiddlewareContext } from "../../CommandKit-CGl1oEv3.js";
|
|
2
2
|
import "../../EventInterceptor-x-R2qshQ.js";
|
|
3
3
|
import "../../ButtonKit-C7r7RPNf.js";
|
|
4
4
|
import "../../ModalKit-Btz58KYn.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require('../../colors-Cd4Oz-r-.js');
|
|
2
2
|
require('../../ActionRow-CmTHbo2t.js');
|
|
3
3
|
require('../../error-codes-DXOuid4c.js');
|
|
4
|
-
const require_CommandKit = require('../../CommandKit-
|
|
4
|
+
const require_CommandKit = require('../../CommandKit-BZVEqKzs.js');
|
|
5
5
|
require('../../common-CcfjYnPG.js');
|
|
6
6
|
require('../../common-vnMIelAE.js');
|
|
7
7
|
require('../../container-DCjIgp-B.js');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../../CommandKit-
|
|
1
|
+
import "../../CommandKit-CGl1oEv3.js";
|
|
2
2
|
import "../../EventInterceptor-x-R2qshQ.js";
|
|
3
3
|
import "../../ButtonKit-C7r7RPNf.js";
|
|
4
4
|
import "../../ModalKit-Btz58KYn.js";
|
|
@@ -29,5 +29,5 @@ import "../../CommandsRouter-CoOA7hkf.js";
|
|
|
29
29
|
import "../../EventsRouter-BacqK6z3.js";
|
|
30
30
|
import "../../index-CUPkUUOR.js";
|
|
31
31
|
import "../../constants-BTttfrm3.js";
|
|
32
|
-
import { EventWorkerContext, eventWorkerContext, getEventWorkerContext, isEventWorkerContext, runInEventWorkerContext } from "../../EventWorkerContext-
|
|
32
|
+
import { EventWorkerContext, eventWorkerContext, getEventWorkerContext, isEventWorkerContext, runInEventWorkerContext } from "../../EventWorkerContext-rYysGdKJ.js";
|
|
33
33
|
export { EventWorkerContext, eventWorkerContext, getEventWorkerContext, isEventWorkerContext, runInEventWorkerContext };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AppCommand, AppCommandHandler, AppCommandNative, CommandBuilderLike, CommandDataSchema, CommandDataSchemaKey, CommandDataSchemaValue, CommandTypeData, CustomAppCommandProps, LoadedCommand, PreparedAppCommandExecution, ResolvableCommand, RunCommand } from "../../CommandKit-
|
|
1
|
+
import { AppCommand, AppCommandHandler, AppCommandNative, CommandBuilderLike, CommandDataSchema, CommandDataSchemaKey, CommandDataSchemaValue, CommandTypeData, CustomAppCommandProps, LoadedCommand, PreparedAppCommandExecution, ResolvableCommand, RunCommand } from "../../CommandKit-CGl1oEv3.js";
|
|
2
2
|
import "../../EventInterceptor-x-R2qshQ.js";
|
|
3
3
|
import "../../ButtonKit-C7r7RPNf.js";
|
|
4
4
|
import "../../ModalKit-Btz58KYn.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require('../../colors-Cd4Oz-r-.js');
|
|
2
2
|
require('../../ActionRow-CmTHbo2t.js');
|
|
3
3
|
require('../../error-codes-DXOuid4c.js');
|
|
4
|
-
const require_CommandKit = require('../../CommandKit-
|
|
4
|
+
const require_CommandKit = require('../../CommandKit-BZVEqKzs.js');
|
|
5
5
|
require('../../common-CcfjYnPG.js');
|
|
6
6
|
require('../../common-vnMIelAE.js');
|
|
7
7
|
require('../../container-DCjIgp-B.js');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AppEventsHandler, AppEventsHandlerLoadedData, EventListener, LoadedEvent } from "../../CommandKit-
|
|
1
|
+
import { AppEventsHandler, AppEventsHandlerLoadedData, EventListener, LoadedEvent } from "../../CommandKit-CGl1oEv3.js";
|
|
2
2
|
import "../../EventInterceptor-x-R2qshQ.js";
|
|
3
3
|
import "../../ButtonKit-C7r7RPNf.js";
|
|
4
4
|
import "../../ModalKit-Btz58KYn.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require('../../colors-Cd4Oz-r-.js');
|
|
2
2
|
require('../../ActionRow-CmTHbo2t.js');
|
|
3
3
|
require('../../error-codes-DXOuid4c.js');
|
|
4
|
-
const require_CommandKit = require('../../CommandKit-
|
|
4
|
+
const require_CommandKit = require('../../CommandKit-BZVEqKzs.js');
|
|
5
5
|
require('../../common-CcfjYnPG.js');
|
|
6
6
|
require('../../common-vnMIelAE.js');
|
|
7
7
|
require('../../container-DCjIgp-B.js');
|
package/dist/app/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyCommandExecute, AppCommand, AppCommandHandler, AppCommandNative, AutocompleteCommand, AutocompleteCommandContext, AutocompleteCommandMiddlewareContext, ChatInputCommand, ChatInputCommandContext, CommandBuilderLike, CommandContextOptions, CommandDataSchema, CommandDataSchemaKey, CommandDataSchemaValue, CommandExecutionMode, CommandRegistrar, CommandTypeData, Context, ContextParameters, CustomAppCommandProps, InteractionCommandContext, InteractionCommandMiddlewareContext, LoadedCommand, MessageCommand, MessageCommandContext, MessageCommandMiddlewareContext, MessageContextMenuCommand, MessageContextMenuCommandContext, MessageContextMenuCommandMiddlewareContext, MiddlewareContext, MiddlewareContextArgs, PreRegisterCommandsEvent, PreparedAppCommandExecution, ResolvableCommand, RunCommand, SlashCommandMiddlewareContext, UserContextMenuCommand, UserContextMenuCommandContext, UserContextMenuCommandMiddlewareContext } from "../CommandKit-
|
|
1
|
+
import { AnyCommandExecute, AppCommand, AppCommandHandler, AppCommandNative, AutocompleteCommand, AutocompleteCommandContext, AutocompleteCommandMiddlewareContext, ChatInputCommand, ChatInputCommandContext, CommandBuilderLike, CommandContextOptions, CommandDataSchema, CommandDataSchemaKey, CommandDataSchemaValue, CommandExecutionMode, CommandRegistrar, CommandTypeData, Context, ContextParameters, CustomAppCommandProps, InteractionCommandContext, InteractionCommandMiddlewareContext, LoadedCommand, MessageCommand, MessageCommandContext, MessageCommandMiddlewareContext, MessageContextMenuCommand, MessageContextMenuCommandContext, MessageContextMenuCommandMiddlewareContext, MiddlewareContext, MiddlewareContextArgs, PreRegisterCommandsEvent, PreparedAppCommandExecution, ResolvableCommand, RunCommand, SlashCommandMiddlewareContext, UserContextMenuCommand, UserContextMenuCommandContext, UserContextMenuCommandMiddlewareContext } from "../CommandKit-CGl1oEv3.js";
|
|
2
2
|
import "../EventInterceptor-x-R2qshQ.js";
|
|
3
3
|
import "../ButtonKit-C7r7RPNf.js";
|
|
4
4
|
import "../ModalKit-Btz58KYn.js";
|
package/dist/app/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require('../colors-Cd4Oz-r-.js');
|
|
2
2
|
require('../ActionRow-CmTHbo2t.js');
|
|
3
3
|
require('../error-codes-DXOuid4c.js');
|
|
4
|
-
const require_CommandKit = require('../CommandKit-
|
|
4
|
+
const require_CommandKit = require('../CommandKit-BZVEqKzs.js');
|
|
5
5
|
require('../common-CcfjYnPG.js');
|
|
6
6
|
require('../common-vnMIelAE.js');
|
|
7
7
|
require('../container-DCjIgp-B.js');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommandRegistrar, PreRegisterCommandsEvent } from "../../CommandKit-
|
|
1
|
+
import { CommandRegistrar, PreRegisterCommandsEvent } from "../../CommandKit-CGl1oEv3.js";
|
|
2
2
|
import "../../EventInterceptor-x-R2qshQ.js";
|
|
3
3
|
import "../../ButtonKit-C7r7RPNf.js";
|
|
4
4
|
import "../../ModalKit-Btz58KYn.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require('../../colors-Cd4Oz-r-.js');
|
|
2
2
|
require('../../ActionRow-CmTHbo2t.js');
|
|
3
3
|
require('../../error-codes-DXOuid4c.js');
|
|
4
|
-
const require_CommandKit = require('../../CommandKit-
|
|
4
|
+
const require_CommandKit = require('../../CommandKit-BZVEqKzs.js');
|
|
5
5
|
require('../../common-CcfjYnPG.js');
|
|
6
6
|
require('../../common-vnMIelAE.js');
|
|
7
7
|
require('../../container-DCjIgp-B.js');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-nOFOJqeH.js');
|
|
2
|
-
const require_CommandKit = require('./CommandKit-
|
|
2
|
+
const require_CommandKit = require('./CommandKit-BZVEqKzs.js');
|
|
3
3
|
const require_common = require('./common-DUta5JO9.js');
|
|
4
4
|
const require_env = require('./env-DakvrBzy.js');
|
|
5
5
|
const require_type_checker = require('./type-checker-BhbQMKkv.js');
|
|
@@ -149,4 +149,4 @@ Object.defineProperty(exports, 'buildApplication', {
|
|
|
149
149
|
return buildApplication;
|
|
150
150
|
}
|
|
151
151
|
});
|
|
152
|
-
//# sourceMappingURL=build-
|
|
152
|
+
//# sourceMappingURL=build-CI-WOwAi.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-
|
|
1
|
+
{"version":3,"file":"build-CI-WOwAi.js","names":[],"sources":["../src/cli/build.ts"],"sourcesContent":["import { build } from 'tsdown';\nimport { CompilerPlugin, CompilerPluginRuntime } from '../plugins';\nimport { loadConfigFile } from '../config/loader';\nimport { writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { DevEnv, devEnvFileArgs, ProdEnv, prodEnvFileArgs } from './env';\nimport { rimraf } from 'rimraf';\nimport { performTypeCheck } from './type-checker';\nimport { copyLocaleFiles } from './common';\nimport { MaybeArray } from '../components';\n\n/**\n * @private\n * @internal\n */\nexport interface ApplicationBuildOptions {\n plugins?: MaybeArray<CompilerPlugin>[] | Array<CompilerPlugin>;\n rolldownPlugins?: any[];\n isDev?: boolean;\n configPath?: string;\n}\n\n// emit public env variables and given env variables\n/**\n * @private\n * @internal\n */\nfunction mergeDefinitionsIfNeeded(env: Record<string, string>) {\n const values = Object.fromEntries(\n Object.entries(process.env).filter(\n ([k]) => !(k in env) && k.startsWith('COMMANDKIT_PUBLIC_'),\n ),\n );\n\n return {\n ...env,\n ...values,\n };\n}\n\n/**\n * @private\n * @internal\n */\nexport async function buildApplication({\n plugins,\n rolldownPlugins,\n isDev,\n configPath,\n}: ApplicationBuildOptions) {\n const config = await loadConfigFile(configPath);\n\n if (!isDev && !config?.typescript?.ignoreBuildErrors) {\n await performTypeCheck(configPath || process.cwd());\n }\n\n const pluginRuntime = new CompilerPluginRuntime(\n (plugins || []) as CompilerPlugin[],\n );\n\n rolldownPlugins ??= [];\n\n rolldownPlugins.push(pluginRuntime.toJSON());\n\n try {\n const dest = isDev ? '.commandkit' : config.distDir;\n\n // Clean the destination directory\n await rimraf(dest);\n\n await pluginRuntime.init();\n\n await build({\n watch: false,\n dts: false,\n clean: true,\n format: ['esm'],\n shims: true,\n minify: false,\n silent: !!isDev,\n inputOptions: {\n transform: {\n jsx: {\n runtime: 'automatic',\n importSource: 'commandkit',\n },\n },\n checks: {\n circularDependency: true,\n },\n onwarn: (warning, defaultWarn) => {\n if (warning?.message?.includes('compilerOptions.jsx')) return;\n\n return defaultWarn(warning);\n },\n onLog: (level, log, defaultLog) => {\n if (isDev) return;\n\n return defaultLog(level, log);\n },\n moduleTypes: {\n '.json': 'js',\n '.node': 'binary',\n },\n },\n plugins: rolldownPlugins,\n platform: 'node',\n skipNodeModulesBundle: true,\n sourcemap: true,\n target: 'node16',\n outDir: dest,\n env: mergeDefinitionsIfNeeded(config.env || {}),\n entry: [\n 'src',\n `!${config.distDir}`,\n '!.commandkit',\n '!**/*.test.*',\n '!**/*.spec.*',\n ],\n unbundle: !!isDev,\n });\n\n await copyLocaleFiles('src', dest);\n await injectEntryFile(configPath || process.cwd(), !!isDev, config.distDir);\n } catch (error) {\n console.error('Build failed:', error);\n if (error instanceof Error) {\n console.error('Error details:', error.stack);\n }\n process.exit(1); // Force exit on error\n } finally {\n // Ensure plugins are cleaned up\n await pluginRuntime.destroy();\n }\n}\n\nconst envScript = (dev: boolean) => `// --- Environment Variables Loader ---\nconst $env = [${(dev ? devEnvFileArgs : prodEnvFileArgs).map((p) => `\"${p}\"`).join(', ')}];\nfor (const file of $env) {\n try {\n process.loadEnvFile(file);\n console.log('\\\\x1b[36m✔ Loaded \\\\x1b[0m\\\\x1b[33m%s\\\\x1b[0m', file);\n } catch {}\n}\n`;\n\nconst antiCrashScript = [\n '// --- CommandKit Anti-Crash Monitor ---',\n \" // 'uncaughtException' event is supposed to be used to perform synchronous cleanup before shutting down the process\",\n ' // instead of using it as a means to resume operation.',\n ' // But it exists here due to compatibility reasons with discord bot ecosystem.',\n \" const p = (t) => `\\\\x1b[31m${t}\\\\x1b[0m`, b = '[CommandKit Anti-Crash Monitor]', l = console.log, e1 = 'uncaughtException', e2 = 'unhandledRejection';\",\n ' if (!process.eventNames().includes(e1)) // skip if it is already handled',\n ' process.on(e1, (e) => {',\n ' l(p(`${b} Uncaught Exception`)); l(p(b), p(e.stack || e));',\n ' })',\n ' if (!process.eventNames().includes(e2)) // skip if it is already handled',\n ' process.on(e2, (r) => {',\n ' l(p(`${b} Unhandled promise rejection`)); l(p(`${b} ${r.stack || r}`));',\n ' });',\n '// --- CommandKit Anti-Crash Monitor ---',\n].join('\\n');\n\nconst wrapInAsyncIIFE = (code: string[]) =>\n `;await (async () => {\\n${code.join('\\n\\n')}\\n})();`;\n\nasync function injectEntryFile(\n configPath: string,\n isDev: boolean,\n distDir?: string,\n) {\n const code = `/* Entrypoint File Generated By CommandKit */\n${isDev ? `\\n\\n// Injected for development\\n${wrapInAsyncIIFE([envScript(isDev), antiCrashScript])}\\n\\n` : wrapInAsyncIIFE([envScript(isDev)])}\n\nimport { commandkit } from 'commandkit';\nimport { Client } from 'discord.js';\n\nasync function bootstrap() {\n const app = await import('./app.js').then((m) => m.default ?? m);\n\n if (!app || !(app instanceof Client)) {\n throw new Error('The app file must default export the discord.js client instance');\n }\n\n commandkit.setClient(app);\n\n await commandkit.start();\n}\n\nawait bootstrap().catch((e) => {\n console.error('Failed to bootstrap CommandKit application:\\\\n', e.stack);\n})\n`;\n\n const dist = isDev ? '.commandkit' : distDir || 'dist';\n\n await writeFile(join(configPath, dist, 'index.js'), code);\n}\n"],"mappings":";;;;;;;;;;;;;;;AA2BA,SAAS,yBAAyB,KAA6B;CAC7D,MAAM,SAAS,OAAO,YACpB,OAAO,QAAQ,QAAQ,IAAI,CAAC,OAC1B,CAAC,CAAC,EAAE,OAAO,KAAK,QAAQ,EAAE,WAAW,qBAAqB,CAC3D,CACF;AAED,QAAO;EACL,GAAG;EACH,GAAG;CACJ;AACH;;;;;AAMA,eAAsB,iBAAiB,EACrC,SACA,iBACA,OACA,YACwB,EAAE;;CAC1B,MAAM,SAAS,MAAM,kCAAe,WAAW;AAE/C,MAAK,yEAAU,OAAQ,oFAAY,mBACjC,OAAM,sCAAiB,cAAc,QAAQ,KAAK,CAAC;CAGrD,MAAM,gBAAgB,IAAI,yCACvB,WAAW,CAAE;AAGhB,qBAAoB,CAAE;AAEtB,iBAAgB,KAAK,cAAc,QAAQ,CAAC;AAE5C,KAAI;EACF,MAAM,OAAO,QAAQ,gBAAgB,OAAO;AAG5C,QAAM,mBAAO,KAAK;AAElB,QAAM,cAAc,MAAM;AAE1B,QAAM,kBAAM;GACV,OAAO;GACP,KAAK;GACL,OAAO;GACP,QAAQ,CAAC,KAAM;G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AQ;EACd,SAAS,mCAAmC,gBAAgB,CAAC,UAAU,MAAM,EAAE,eAAgB,EAAC,CAAC,QAAQ,gBAAgB,CAAC,UAAU,MAAM,AAAC,EAAC,CAAA;;;;;;;;;;;;;;;;;;;;;CAsB5I,MAAM,OAAO,QAAQ,gBAAgB,WAAW;AAEhD,OAAM,gCAAU,oBAAK,YAAY,MAAM,WAAW,EAAE,KAAK;AAC3D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as child_process0 from "child_process";
|
|
2
2
|
|
|
3
3
|
//#region src/cli/app-process.d.ts
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ import * as child_process4 from "child_process";
|
|
|
6
6
|
* @private
|
|
7
7
|
* @internal
|
|
8
8
|
*/
|
|
9
|
-
declare function createAppProcess(fileName: string, cwd: string, isDev: boolean):
|
|
9
|
+
declare function createAppProcess(fileName: string, cwd: string, isDev: boolean): child_process0.ChildProcess;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { createAppProcess };
|
|
12
12
|
//# sourceMappingURL=app-process.d.ts.map
|
package/dist/cli/build.d.ts
CHANGED
package/dist/cli/build.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require('../colors-Cd4Oz-r-.js');
|
|
2
2
|
require('../ActionRow-CmTHbo2t.js');
|
|
3
3
|
require('../error-codes-DXOuid4c.js');
|
|
4
|
-
require('../CommandKit-
|
|
4
|
+
require('../CommandKit-BZVEqKzs.js');
|
|
5
5
|
require('../common-CcfjYnPG.js');
|
|
6
6
|
require('../common-vnMIelAE.js');
|
|
7
7
|
require('../container-DCjIgp-B.js');
|
|
@@ -34,6 +34,6 @@ require('../CommandKitEventsChannel-BSdcgY3Q.js');
|
|
|
34
34
|
require('../store-CyzliDXj.js');
|
|
35
35
|
require('../env-DakvrBzy.js');
|
|
36
36
|
require('../type-checker-BhbQMKkv.js');
|
|
37
|
-
const require_build = require('../build-
|
|
37
|
+
const require_build = require('../build-CI-WOwAi.js');
|
|
38
38
|
|
|
39
39
|
exports.buildApplication = require_build.buildApplication;
|
package/dist/cli/common.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../CommandKit-
|
|
1
|
+
import { ResolvedCommandKitConfig } from "../CommandKit-CGl1oEv3.js";
|
|
2
2
|
import "../EventInterceptor-x-R2qshQ.js";
|
|
3
3
|
import "../ButtonKit-C7r7RPNf.js";
|
|
4
4
|
import "../ModalKit-Btz58KYn.js";
|
|
@@ -29,9 +29,7 @@ import "../CommandsRouter-CoOA7hkf.js";
|
|
|
29
29
|
import "../EventsRouter-BacqK6z3.js";
|
|
30
30
|
import "../index-CUPkUUOR.js";
|
|
31
31
|
import "../constants-BTttfrm3.js";
|
|
32
|
-
import "
|
|
33
|
-
import { ResolvedCommandKitConfig } from "../utils-NtJ5thv2.js";
|
|
34
|
-
import * as typescript5 from "typescript";
|
|
32
|
+
import * as typescript1 from "typescript";
|
|
35
33
|
|
|
36
34
|
//#region src/cli/common.d.ts
|
|
37
35
|
/**
|
|
@@ -59,7 +57,7 @@ declare function findPackageJSON(): any;
|
|
|
59
57
|
* @private
|
|
60
58
|
* @internal
|
|
61
59
|
*/
|
|
62
|
-
declare function loadTypeScript(e?: string): Promise<typeof
|
|
60
|
+
declare function loadTypeScript(e?: string): Promise<typeof typescript1>;
|
|
63
61
|
/**
|
|
64
62
|
* @private
|
|
65
63
|
* @internal
|
package/dist/cli/development.js
CHANGED
|
@@ -2,7 +2,7 @@ const require_chunk = require('../chunk-nOFOJqeH.js');
|
|
|
2
2
|
const require_colors = require('../colors-Cd4Oz-r-.js');
|
|
3
3
|
require('../ActionRow-CmTHbo2t.js');
|
|
4
4
|
require('../error-codes-DXOuid4c.js');
|
|
5
|
-
const require_CommandKit = require('../CommandKit-
|
|
5
|
+
const require_CommandKit = require('../CommandKit-BZVEqKzs.js');
|
|
6
6
|
require('../common-CcfjYnPG.js');
|
|
7
7
|
require('../common-vnMIelAE.js');
|
|
8
8
|
require('../container-DCjIgp-B.js');
|
|
@@ -36,7 +36,7 @@ require('../store-CyzliDXj.js');
|
|
|
36
36
|
require('../env-DakvrBzy.js');
|
|
37
37
|
const require_app_process = require('../app-process-kobgJPMW.js');
|
|
38
38
|
require('../type-checker-BhbQMKkv.js');
|
|
39
|
-
const require_build = require('../build-
|
|
39
|
+
const require_build = require('../build-CI-WOwAi.js');
|
|
40
40
|
const node_crypto = require_chunk.__toESM(require("node:crypto"));
|
|
41
41
|
const path = require_chunk.__toESM(require("path"));
|
|
42
42
|
const chokidar = require_chunk.__toESM(require("chokidar"));
|
|
@@ -188,15 +188,17 @@ async function bootstrapDevelopmentServer(configPath) {
|
|
|
188
188
|
watcher.on("error", (e) => {
|
|
189
189
|
console.error(e);
|
|
190
190
|
});
|
|
191
|
-
|
|
192
|
-
const end = performance.now();
|
|
193
|
-
console.log(`${require_colors.colors_default.greenBright("Development server started in")} ${require_colors.colors_default.yellowBright(`${(end - start).toFixed(2)}ms`)}
|
|
191
|
+
console.log(`${require_colors.colors_default.greenBright("Bootstrapped CommandKit Development Environment in")} ${require_colors.colors_default.yellowBright(`${(performance.now() - start).toFixed(2)}ms`)}
|
|
194
192
|
${require_colors.colors_default.greenBright("Watching for changes in")} ${require_colors.colors_default.yellowBright("src")} ${require_colors.colors_default.greenBright("directory")}
|
|
195
193
|
|
|
196
194
|
${require_colors.colors_default.greenBright("Commands:")}
|
|
197
195
|
${require_colors.colors_default.yellowBright("r")} - Restart the server
|
|
198
196
|
${require_colors.colors_default.yellowBright("rc")} - Reload all commands
|
|
199
197
|
${require_colors.colors_default.yellowBright("re")} - Reload all events`);
|
|
198
|
+
const buildStart = performance.now();
|
|
199
|
+
ps = await buildAndStart(cwd);
|
|
200
|
+
const buildEnd = performance.now();
|
|
201
|
+
console.log(`\n${require_colors.colors_default.greenBright("Development mode compilation took")} ${require_colors.colors_default.yellowBright(`${(buildEnd - buildStart).toFixed(2)}ms`)}\n`);
|
|
200
202
|
}
|
|
201
203
|
|
|
202
204
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"development.js","names":[],"sources":["../../src/cli/development.ts"],"sourcesContent":["import { join } from 'path';\nimport { getPossibleConfigPaths, loadConfigFile } from '../config/loader';\nimport { isCompilerPlugin } from '../plugins';\nimport { createAppProcess } from './app-process';\nimport { buildApplication } from './build';\nimport { watch } from 'chokidar';\nimport { debounce } from '../utils/utilities';\nimport colors from '../utils/colors';\nimport { ChildProcess } from 'node:child_process';\nimport { setTimeout as sleep } from 'node:timers/promises';\nimport { randomUUID } from 'node:crypto';\nimport { HMREventType } from '../utils/constants';\nimport { findEntrypoint } from './common';\n\n/**\n * @private\n * @internal\n */\nasync function buildAndStart(configPath: string, skipStart = false) {\n const config = await loadConfigFile(configPath);\n const mainFile = findEntrypoint('.commandkit');\n\n await buildApplication({\n configPath,\n isDev: true,\n plugins: config.plugins.flat(2).filter((p) => isCompilerPlugin(p)),\n rolldownPlugins: config.rolldownPlugins,\n });\n\n if (skipStart) return null as never;\n\n const ps = createAppProcess(mainFile, configPath, true);\n\n return ps;\n}\n\n/**\n * @private\n * @internal\n */\nconst isCommandSource = (p: string) =>\n p.replaceAll('\\\\', '/').includes('src/app/commands');\n\n/**\n * @private\n * @internal\n */\nconst isEventSource = (p: string) =>\n p.replaceAll('\\\\', '/').includes('src/app/events');\n\n/**\n * @private\n * @internal\n */\nexport async function bootstrapDevelopmentServer(configPath?: string) {\n process.env.COMMANDKIT_BOOTSTRAP_MODE = 'development';\n const start = performance.now();\n const cwd = configPath || process.cwd();\n const configPaths = getPossibleConfigPaths(cwd);\n\n const watcher = watch([join(cwd, 'src'), ...configPaths], {\n ignoreInitial: true,\n });\n\n let ps: ChildProcess | null = null;\n\n const waitForAcknowledgment = (messageId: string): Promise<boolean> => {\n return new Promise((resolve) => {\n if (!ps) return resolve(false);\n\n let _handled = false;\n const onMessage = (message: any) => {\n _handled = true;\n if (typeof message !== 'object' || message === null) return;\n\n const { type, id, handled } = message;\n if (type === 'commandkit-hmr-ack' && id === messageId) {\n ps?.off('message', onMessage);\n resolve(!!handled);\n }\n };\n\n ps.once('message', onMessage);\n\n if (!_handled) {\n sleep(3000).then(() => {\n ps?.off('message', onMessage);\n resolve(false);\n });\n }\n });\n };\n\n const sendHmrEvent = async (\n event: HMREventType,\n path?: string,\n ): Promise<boolean> => {\n if (!ps || !ps.send) return false;\n\n const messageId = randomUUID();\n const messagePromise = waitForAcknowledgment(messageId);\n\n ps.send({ event, path, id: messageId });\n\n // Wait for acknowledgment or timeout after 3 seconds\n try {\n let triggered = false;\n const res = !!(await Promise.race([\n messagePromise,\n sleep(3000).then(() => {\n if (!triggered) {\n console.warn(\n colors.yellow(\n `HMR acknowledgment timed out for event ${event} on path ${path}`,\n ),\n );\n }\n return false;\n }),\n ]));\n\n triggered = true;\n\n return res;\n } catch (error) {\n console.error(\n colors.red(`Error waiting for HMR acknowledgment: ${error}`),\n );\n return false;\n }\n };\n\n const performHMR = debounce(async (path?: string): Promise<boolean> => {\n if (!path || !ps) return false;\n\n let eventType: HMREventType | null = null;\n let eventDescription = '';\n\n if (isCommandSource(path)) {\n eventType = HMREventType.ReloadCommands;\n eventDescription = 'command(s)';\n } else if (isEventSource(path)) {\n eventType = HMREventType.ReloadEvents;\n eventDescription = 'event(s)';\n } else {\n eventType = HMREventType.Unknown;\n eventDescription = 'unknown source';\n }\n\n if (eventType) {\n console.log(\n `${colors.cyanBright(`Attempting to reload ${eventDescription} at`)} ${colors.yellowBright(path)}`,\n );\n\n await buildAndStart(cwd, true);\n const hmrHandled = await sendHmrEvent(eventType, path);\n\n if (hmrHandled) {\n console.log(\n `${colors.greenBright(`Successfully hot reloaded ${eventDescription} at`)} ${colors.yellowBright(path)}`,\n );\n return true;\n }\n }\n\n return false;\n }, 300);\n\n const isConfigUpdate = (path: string) => {\n const isConfig = configPaths.some((configPath) => path === configPath);\n\n if (!isConfig) return false;\n\n console.log(\n colors.yellowBright(\n 'It seems like commandkit config file was updated, please restart the server manually to apply changes.',\n ),\n );\n\n return isConfig;\n };\n\n const hmrHandler = async (path: string) => {\n if (isConfigUpdate(path)) return;\n const hmr = await performHMR(path);\n if (hmr) return;\n\n console.log(\n `${colors.yellowBright('⚡️ Performing full restart due to the changes in')} ${colors.cyanBright(path)}`,\n );\n\n ps?.kill();\n ps = await buildAndStart(cwd);\n };\n\n process.stdin.on('data', async (d) => {\n const command = d.toString().trim();\n\n switch (command) {\n case 'r':\n console.log(`Received restart command, restarting...`);\n ps?.kill();\n ps = null;\n ps = await buildAndStart(cwd);\n break;\n case 'rc':\n console.log(`Received reload commands command, reloading...`);\n await sendHmrEvent(HMREventType.ReloadCommands);\n break;\n case 're':\n console.log(`Received reload events command, reloading...`);\n await sendHmrEvent(HMREventType.ReloadEvents);\n break;\n break;\n }\n });\n\n watcher.on('change', hmrHandler);\n watcher.on('add', hmrHandler);\n watcher.on('unlink', hmrHandler);\n watcher.on('unlinkDir', hmrHandler);\n watcher.on('error', (e) => {\n console.error(e);\n });\n\n ps = await buildAndStart(cwd);\n\n const end = performance.now();\n\n console.log(\n `${colors.greenBright('Development server started in')} ${colors.yellowBright(`${(end - start).toFixed(2)}ms`)}\n${colors.greenBright('Watching for changes in')} ${colors.yellowBright('src')} ${colors.greenBright('directory')}\n\n${colors.greenBright('Commands:')}\n${colors.yellowBright('r')} - Restart the server\n${colors.yellowBright('rc')} - Reload all commands\n${colors.yellowBright('re')} - Reload all events`,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,eAAe,cAAc,YAAoB,YAAY,OAAO;CAClE,MAAM,SAAS,MAAM,kCAAe,WAAW;CAC/C,MAAM,WAAW,gCAAe,cAAc;AAE9C,OAAM,+BAAiB;EACrB;EACA,OAAO;EACP,SAAS,OAAO,QAAQ,KAAK,EAAE,CAAC,OAAO,CAAC,MAAM,wCAAiB,EAAE,CAAC;EAClE,iBAAiB,OAAO;CACzB,EAAC;A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[],"sources":["../../src/cli/development.ts"],"sourcesContent":["import { join } from 'path';\nimport { getPossibleConfigPaths, loadConfigFile } from '../config/loader';\nimport { isCompilerPlugin } from '../plugins';\nimport { createAppProcess } from './app-process';\nimport { buildApplication } from './build';\nimport { watch } from 'chokidar';\nimport { debounce } from '../utils/utilities';\nimport colors from '../utils/colors';\nimport { ChildProcess } from 'node:child_process';\nimport { setTimeout as sleep } from 'node:timers/promises';\nimport { randomUUID } from 'node:crypto';\nimport { HMREventType } from '../utils/constants';\nimport { findEntrypoint } from './common';\n\n/**\n * @private\n * @internal\n */\nasync function buildAndStart(configPath: string, skipStart = false) {\n const config = await loadConfigFile(configPath);\n const mainFile = findEntrypoint('.commandkit');\n\n await buildApplication({\n configPath,\n isDev: true,\n plugins: config.plugins.flat(2).filter((p) => isCompilerPlugin(p)),\n rolldownPlugins: config.rolldownPlugins,\n });\n\n if (skipStart) return null as never;\n\n const ps = createAppProcess(mainFile, configPath, true);\n\n return ps;\n}\n\n/**\n * @private\n * @internal\n */\nconst isCommandSource = (p: string) =>\n p.replaceAll('\\\\', '/').includes('src/app/commands');\n\n/**\n * @private\n * @internal\n */\nconst isEventSource = (p: string) =>\n p.replaceAll('\\\\', '/').includes('src/app/events');\n\n/**\n * @private\n * @internal\n */\nexport async function bootstrapDevelopmentServer(configPath?: string) {\n process.env.COMMANDKIT_BOOTSTRAP_MODE = 'development';\n const start = performance.now();\n const cwd = configPath || process.cwd();\n const configPaths = getPossibleConfigPaths(cwd);\n\n const watcher = watch([join(cwd, 'src'), ...configPaths], {\n ignoreInitial: true,\n });\n\n let ps: ChildProcess | null = null;\n\n const waitForAcknowledgment = (messageId: string): Promise<boolean> => {\n return new Promise((resolve) => {\n if (!ps) return resolve(false);\n\n let _handled = false;\n const onMessage = (message: any) => {\n _handled = true;\n if (typeof message !== 'object' || message === null) return;\n\n const { type, id, handled } = message;\n if (type === 'commandkit-hmr-ack' && id === messageId) {\n ps?.off('message', onMessage);\n resolve(!!handled);\n }\n };\n\n ps.once('message', onMessage);\n\n if (!_handled) {\n sleep(3000).then(() => {\n ps?.off('message', onMessage);\n resolve(false);\n });\n }\n });\n };\n\n const sendHmrEvent = async (\n event: HMREventType,\n path?: string,\n ): Promise<boolean> => {\n if (!ps || !ps.send) return false;\n\n const messageId = randomUUID();\n const messagePromise = waitForAcknowledgment(messageId);\n\n ps.send({ event, path, id: messageId });\n\n // Wait for acknowledgment or timeout after 3 seconds\n try {\n let triggered = false;\n const res = !!(await Promise.race([\n messagePromise,\n sleep(3000).then(() => {\n if (!triggered) {\n console.warn(\n colors.yellow(\n `HMR acknowledgment timed out for event ${event} on path ${path}`,\n ),\n );\n }\n return false;\n }),\n ]));\n\n triggered = true;\n\n return res;\n } catch (error) {\n console.error(\n colors.red(`Error waiting for HMR acknowledgment: ${error}`),\n );\n return false;\n }\n };\n\n const performHMR = debounce(async (path?: string): Promise<boolean> => {\n if (!path || !ps) return false;\n\n let eventType: HMREventType | null = null;\n let eventDescription = '';\n\n if (isCommandSource(path)) {\n eventType = HMREventType.ReloadCommands;\n eventDescription = 'command(s)';\n } else if (isEventSource(path)) {\n eventType = HMREventType.ReloadEvents;\n eventDescription = 'event(s)';\n } else {\n eventType = HMREventType.Unknown;\n eventDescription = 'unknown source';\n }\n\n if (eventType) {\n console.log(\n `${colors.cyanBright(`Attempting to reload ${eventDescription} at`)} ${colors.yellowBright(path)}`,\n );\n\n await buildAndStart(cwd, true);\n const hmrHandled = await sendHmrEvent(eventType, path);\n\n if (hmrHandled) {\n console.log(\n `${colors.greenBright(`Successfully hot reloaded ${eventDescription} at`)} ${colors.yellowBright(path)}`,\n );\n return true;\n }\n }\n\n return false;\n }, 300);\n\n const isConfigUpdate = (path: string) => {\n const isConfig = configPaths.some((configPath) => path === configPath);\n\n if (!isConfig) return false;\n\n console.log(\n colors.yellowBright(\n 'It seems like commandkit config file was updated, please restart the server manually to apply changes.',\n ),\n );\n\n return isConfig;\n };\n\n const hmrHandler = async (path: string) => {\n if (isConfigUpdate(path)) return;\n const hmr = await performHMR(path);\n if (hmr) return;\n\n console.log(\n `${colors.yellowBright('⚡️ Performing full restart due to the changes in')} ${colors.cyanBright(path)}`,\n );\n\n ps?.kill();\n ps = await buildAndStart(cwd);\n };\n\n process.stdin.on('data', async (d) => {\n const command = d.toString().trim();\n\n switch (command) {\n case 'r':\n console.log(`Received restart command, restarting...`);\n ps?.kill();\n ps = null;\n ps = await buildAndStart(cwd);\n break;\n case 'rc':\n console.log(`Received reload commands command, reloading...`);\n await sendHmrEvent(HMREventType.ReloadCommands);\n break;\n case 're':\n console.log(`Received reload events command, reloading...`);\n await sendHmrEvent(HMREventType.ReloadEvents);\n break;\n break;\n }\n });\n\n watcher.on('change', hmrHandler);\n watcher.on('add', hmrHandler);\n watcher.on('unlink', hmrHandler);\n watcher.on('unlinkDir', hmrHandler);\n watcher.on('error', (e) => {\n console.error(e);\n });\n\n console.log(`${colors.greenBright('Bootstrapped CommandKit Development Environment in')} ${colors.yellowBright(`${(performance.now() - start).toFixed(2)}ms`)}\n${colors.greenBright('Watching for changes in')} ${colors.yellowBright('src')} ${colors.greenBright('directory')}\n\n${colors.greenBright('Commands:')}\n${colors.yellowBright('r')} - Restart the server\n${colors.yellowBright('rc')} - Reload all commands\n${colors.yellowBright('re')} - Reload all events`);\n\n const buildStart = performance.now();\n\n ps = await buildAndStart(cwd);\n\n const buildEnd = performance.now();\n\n console.log(\n `\\n${colors.greenBright('Development mode compilation took')} ${colors.yellowBright(`${(buildEnd - buildStart).toFixed(2)}ms`)}\\n`,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,eAAe,cAAc,YAAoB,YAAY,OAAO;CAClE,MAAM,SAAS,MAAM,kCAAe,WAAW;CAC/C,MAAM,WAAW,gCAAe,cAAc;AAE9C,OAAM,+BAAiB;EACrB;EACA,OAAO;EACP,SAAS,OAAO,QAAQ,KAAK,EAAE,CAAC,OAAO,CAAC,MA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AK;AAEpC,MAAK,MAAM,cAAc,IAAI;CAE7B,MAAM,WAAW,YAAY,KAAK;AAElC,SAAQ,KACL,IAAI,8BAAO,YAAY,oCAAoC,CAAC,GAAG,8BAAO,cAAc,EAAE,CAAC,WAAW,YAAY,QAAQ,EAAE,CAAC,IAAI,CAAC,IAChI;AACH"}
|
package/dist/cli/information.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require('../chunk-nOFOJqeH.js');
|
|
2
|
-
const require_version = require('../version-
|
|
2
|
+
const require_version = require('../version-t3Nw0T3Q.js');
|
|
3
3
|
const node_fs = require_chunk.__toESM(require("node:fs"));
|
|
4
4
|
const node_path = require_chunk.__toESM(require("node:path"));
|
|
5
5
|
const node_child_process = require_chunk.__toESM(require("node:child_process"));
|
package/dist/cli/init.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { bootstrapCommandkitCLI } from "../init-
|
|
1
|
+
import { bootstrapCommandkitCLI } from "../init-DsaK1AfD.js";
|
|
2
2
|
export { bootstrapCommandkitCLI };
|