commandkit 1.2.4 → 1.2.6
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/analytics/analytics-engine.js +1 -1
- package/dist/analytics/constants.js.map +1 -1
- package/dist/analytics/utils.js +1 -1
- package/dist/app/commands/AppCommandRunner.js +1 -1
- package/dist/app/commands/Context.js +1 -1
- package/dist/app/commands/MessageCommandParser.js.map +1 -1
- package/dist/app/commands/helpers.js.map +1 -1
- package/dist/app/events/EventWorkerContext.js.map +1 -1
- package/dist/app/handlers/AppCommandHandler.js +1 -1
- package/dist/app/handlers/AppEventsHandler.js +1 -1
- package/dist/app/index.js +1 -1
- package/dist/app/interrupt/signals.js.map +1 -1
- package/dist/app/middlewares/permissions.js +1 -1
- package/dist/app/register/CommandRegistrar.js +1 -1
- package/dist/app/router/CommandsRouter.js.map +1 -1
- package/dist/app/router/EventsRouter.js.map +1 -1
- package/dist/app/router/TreeArtifact.js.map +1 -1
- package/dist/cli/app-process.js.map +1 -1
- package/dist/cli/build.js +1 -1
- package/dist/cli/build.js.map +1 -1
- package/dist/cli/common.js.map +1 -1
- package/dist/cli/development.js +1 -1
- package/dist/cli/development.js.map +1 -1
- package/dist/cli/env.js.map +1 -1
- package/dist/cli/generators.js.map +1 -1
- package/dist/cli/information.js.map +1 -1
- package/dist/cli/init.js +1 -1
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/production.js +1 -1
- package/dist/cli/production.js.map +1 -1
- package/dist/cli/type-checker.js.map +1 -1
- package/dist/cli/utils.js.map +1 -1
- package/dist/{commandkit-5cCZPGBF.js → commandkit-Ck5bsJYv.js} +32 -11
- package/dist/commandkit-Ck5bsJYv.js.map +1 -0
- package/dist/commandkit.js +1 -1
- package/dist/components/common/EventInterceptor.js.map +1 -1
- package/dist/components/common/element.js +1 -1
- package/dist/components/display/common.js +1 -1
- package/dist/components/display/container.js +1 -1
- package/dist/components/display/file.js.map +1 -1
- package/dist/components/display/index.js +1 -1
- package/dist/components/display/label.js +1 -1
- package/dist/components/display/media-gallery.js +1 -1
- package/dist/components/display/poll.js.map +1 -1
- package/dist/components/display/section.js +1 -1
- package/dist/components/display/separator.js.map +1 -1
- package/dist/components/display/text-display.js.map +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/interactive/action-row/ActionRow.js.map +1 -1
- package/dist/components/interactive/button/Button.js +1 -1
- package/dist/components/interactive/button/ButtonKit.js +1 -1
- package/dist/components/interactive/checkbox/checkbox.js +1 -1
- package/dist/components/interactive/modal/Modal.js +1 -1
- package/dist/components/interactive/modal/ModalKit.js +1 -1
- package/dist/components/interactive/radio/radio.js +1 -1
- package/dist/components/interactive/select-menu/ChannelSelectMenuKit.js +1 -1
- package/dist/components/interactive/select-menu/MentionableSelectMenuKit.js +1 -1
- package/dist/components/interactive/select-menu/RoleSelectMenuKit.js +1 -1
- package/dist/components/interactive/select-menu/SelectMenu.js +1 -1
- package/dist/components/interactive/select-menu/StringSelectMenuKit.js +1 -1
- package/dist/components/interactive/select-menu/UserSelectMenuKit.js +1 -1
- package/dist/config/config.js +1 -1
- package/dist/config/default.js +1 -1
- package/dist/config/loader.js +1 -1
- package/dist/config/utils.js.map +1 -1
- package/dist/context/async-context.js +1 -1
- package/dist/context/environment.js +1 -1
- package/dist/events/CommandKitEventsChannel.js.map +1 -1
- package/dist/flags/FlagProvider.js.map +1 -1
- package/dist/flags/feature-flags.js +1 -1
- package/dist/flags/store.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/kv/constants.js.map +1 -1
- package/dist/kv/dotprops.js.map +1 -1
- package/dist/kv/kv.js.map +1 -1
- package/dist/kv/serde.js.map +1 -1
- package/dist/logger/DefaultLogger.js +1 -1
- package/dist/logger/Logger.js +1 -1
- package/dist/logger/NoopLogger.js.map +1 -1
- package/dist/plugins/CompilerPlugin.js.map +1 -1
- package/dist/plugins/PluginCommon.js.map +1 -1
- package/dist/plugins/RuntimePlugin.js.map +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.js +1 -1
- package/dist/plugins/plugin-runtime/CompilerPluginRuntime.js +1 -1
- package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.js +1 -1
- package/dist/plugins/plugin-runtime/builtin/MacroPlugin.js +1 -1
- package/dist/utils/colors.js.map +1 -1
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/dev-hooks.js +1 -1
- package/dist/utils/error-codes.js.map +1 -1
- package/dist/utils/resolve-file-url.js.map +1 -1
- package/dist/utils/types-package.js.map +1 -1
- package/dist/utils/useful-stuff/async-queue.js.map +1 -1
- package/dist/utils/useful-stuff/mutex.js.map +1 -1
- package/dist/utils/useful-stuff/ratelimiter.js.map +1 -1
- package/dist/utils/useful-stuff/semaphore.js.map +1 -1
- package/dist/utils/utilities.js +1 -1
- package/dist/utils/warning.js.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +3 -3
- package/dist/commandkit-5cCZPGBF.js.map +0 -1
package/dist/commandkit.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_commandkit = require("./commandkit-
|
|
2
|
+
const require_commandkit = require("./commandkit-Ck5bsJYv.js");
|
|
3
3
|
|
|
4
4
|
exports.CommandKit = require_commandkit.CommandKit;
|
|
5
5
|
exports.commandkit = require_commandkit.commandkit;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventInterceptor.js","names":[],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"EventInterceptor.js","names":[],"sources":["../../../src/components/common/EventInterceptor.ts"],"sourcesContent":["import { Awaitable, Client, ClientEvents, Events } from 'discord.js';\n\nexport interface EventInterceptorContextData<E extends keyof ClientEvents> {\n /**\n * The filter to use for the collector.\n */\n filter?: (...args: ClientEvents[E]) => Awaitable<boolean>;\n /**\n * The duration (in ms) that the collector should run for.\n */\n time?: number;\n /**\n * If the collector should automatically reset the timer when a button is clicked.\n */\n autoReset?: boolean;\n /**\n * Whether the collector should run only once.\n */\n once?: boolean;\n /**\n * The handler to run when the collector ends.\n */\n onEnd?: (reason: string) => Awaitable<void>;\n /**\n * The handler to run upon an error.\n */\n onError?: EventInterceptorErrorHandler;\n}\n\n/**\n * The error handler for the event interceptor.\n */\nexport type EventInterceptorErrorHandler = (error: Error) => Awaitable<void>;\n\n/**\n * The event interceptor class that allows subscribing to events and handling them with custom logic.\n * It also supports automatic cleanup of expired subscriptions.\n */\nexport class EventInterceptor {\n private subscribers = new Map<\n keyof ClientEvents,\n Set<(...args: any[]) => void>\n >();\n private globalHandlers = new Map<\n keyof ClientEvents,\n (...args: any[]) => void\n >();\n private cleanupTimer: NodeJS.Timeout | null = null;\n\n /**\n * Creates the event interceptor.\n */\n public constructor(public readonly client: Client) {\n this.#cleanupLoop();\n }\n\n #cleanupLoop() {\n if (this.cleanupTimer) clearInterval(this.cleanupTimer);\n\n this.cleanupTimer = setInterval(() => {\n for (const [event, handlers] of this.subscribers) {\n for (const handler of handlers) {\n const options = Reflect.get(\n handler,\n 'options',\n ) as EventInterceptorContextData<keyof ClientEvents> & {\n registeredAt: number;\n };\n\n const isExpired =\n options.time && Date.now() - options.registeredAt > options.time;\n\n if (isExpired) {\n this.unsubscribe(event, handler, 'time');\n }\n }\n }\n }, 60_000).unref();\n }\n\n /**\n * Destroys the event interceptor.\n */\n public destroy(): void {\n if (this.cleanupTimer) {\n clearInterval(this.cleanupTimer);\n this.cleanupTimer = null;\n }\n\n for (const [event, handlers] of this.subscribers) {\n for (const handler of handlers) {\n this.unsubscribe(event, handler, 'destroy');\n }\n }\n\n this.subscribers.clear();\n this.globalHandlers.clear();\n }\n\n /**\n * Whether the event has subscribers.\n * @param event The event to check.\n */\n public hasSubscribers(event: keyof ClientEvents): boolean {\n return this.subscribers.has(event);\n }\n\n /**\n * Returns the number of subscribers for the event.\n * @param event The event to check.\n */\n public getSubscriberCount(event: keyof ClientEvents): number {\n const handlers = this.subscribers.get(event);\n return handlers?.size ?? 0;\n }\n\n /**\n * Whether the event has global handlers.\n */\n public hasGlobalHandlers(): boolean {\n return this.globalHandlers.size > 0;\n }\n\n /**\n * Returns the number of global handlers.\n */\n public getGlobalHandlersCount(): number {\n return this.subscribers.size;\n }\n\n /**\n * Subscribes to an event.\n * @param event The event to subscribe to.\n * @param listener The listener to call when the event is emitted.\n * @returns A function to unsubscribe from the event.\n */\n public subscribe<Event extends keyof ClientEvents>(\n event: Event,\n listener: (...args: ClientEvents[Event]) => void,\n options?: EventInterceptorContextData<Event>,\n ): () => void {\n if (!this.subscribers.has(event)) {\n this.subscribers.set(event, new Set());\n this.client.on(event, this.createGlobalHandler(event));\n this.client.setMaxListeners(this.client.getMaxListeners() + 1);\n }\n\n options ??= {};\n\n // @ts-ignore\n options.registeredAt = Date.now();\n\n Reflect.set(listener, 'options', options);\n\n this.subscribers.get(event)!.add(listener);\n\n return () => {\n this.unsubscribe(event, listener);\n };\n }\n\n /**\n * Unsubscribes from an event.\n * @param event The event to unsubscribe from.\n */\n public unsubscribe<Event extends keyof ClientEvents>(\n event: Event,\n listener: (...args: ClientEvents[Event]) => void,\n reason?: string,\n ): void {\n const handlers = this.subscribers.get(event);\n if (!handlers) return;\n\n handlers.delete(listener);\n\n if (handlers.size < 1) {\n this.subscribers.delete(event);\n this.client.removeListener(event, this.globalHandlers.get(event)!);\n this.globalHandlers.delete(event);\n this.client.setMaxListeners(\n Math.max(this.client.getMaxListeners() - 1, 0),\n );\n }\n\n Reflect.get(listener, 'options').onEnd?.(reason ?? 'unsubscribe');\n }\n\n /**\n * Creates a global handler for the event.\n * @param event The event to create a global handler for.\n * @returns The global handler.\n */\n private createGlobalHandler<Event extends keyof ClientEvents>(\n event: Event,\n ): (...args: ClientEvents[Event]) => void {\n if (this.globalHandlers.has(event)) {\n return this.globalHandlers.get(event)!;\n }\n\n const handler = async (...args: ClientEvents[Event]) => {\n const subscribers = this.subscribers.get(event);\n if (subscribers && subscribers.size > 0) {\n for (const subscriber of subscribers) {\n const options = Reflect.get(\n subscriber,\n 'options',\n ) as EventInterceptorContextData<Event> & { registeredAt: number };\n\n const isExpired =\n options.time && Date.now() - options.registeredAt > options.time;\n\n if (isExpired) {\n this.unsubscribe(event, subscriber, 'time');\n continue;\n }\n\n if (options.autoReset) {\n options.registeredAt = Date.now();\n }\n\n if (options.filter && !(await options.filter(...args))) {\n continue;\n }\n\n try {\n await subscriber(...args);\n } catch (e) {\n if (options.onError) {\n await options.onError(<Error>e);\n } else {\n throw e;\n }\n } finally {\n if (options.once) {\n this.unsubscribe(event, subscriber, 'once');\n }\n }\n }\n }\n };\n\n this.globalHandlers.set(event, handler);\n\n return handler;\n }\n}\n"],"mappings":";;;;;;AAsCA,IAAa,mBAAb,MAA8B;CAcO;CAbnC,AAAQ,8BAAc,IAAI,IAGxB;CACF,AAAQ,iCAAiB,IAAI,IAG3B;CACF,AAAQ,eAAsC;;;;CAK9C,AAAO,YAAY,AAAgB,QAAgB;EAAhB;EACjC,KAAK,aAAa;CACpB;CAEA,eAAe;EACb,IAAI,KAAK,cAAc,cAAc,KAAK,YAAY;EAEtD,KAAK,eAAe,kBAAkB;GACpC,KAAK,MAAM,CAAC,OAAO,aAAa,KAAK,aACnC,KAAK,MAAM,WAAW,UAAU;IAC9B,MAAM,UAAU,QAAQ,IACtB,SACA,SACF;IAOA,IAFE,QAAQ,QAAQ,KAAK,IAAI,IAAI,QAAQ,eAAe,QAAQ,MAG5D,KAAK,YAAY,OAAO,SAAS,MAAM;GAE3C;EAEJ,GAAG,GAAM,CAAC,CAAC,MAAM;CACnB;;;;CAKA,AAAO,UAAgB;EACrB,IAAI,KAAK,cAAc;GACrB,cAAc,KAAK,YAAY;GAC/B,KAAK,eAAe;EACtB;EAEA,KAAK,MAAM,CAAC,OAAO,aAAa,KAAK,aACnC,KAAK,MAAM,WAAW,UACpB,KAAK,YAAY,OAAO,SAAS,SAAS;EAI9C,KA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;;;;;;CAOA,AAAQ,oBACN,OACwC;EACxC,IAAI,KAAK,eAAe,IAAI,KAAK,GAC/B,OAAO,KAAK,eAAe,IAAI,KAAK;EAGtC,MAAM,UAAU,OAAO,GAAG,SAA8B;GACtD,MAAM,cAAc,KAAK,YAAY,IAAI,KAAK;GAC9C,IAAI,eAAe,YAAY,OAAO,GACpC,KAAK,MAAM,cAAc,aAAa;IACpC,MAAM,UAAU,QAAQ,IACtB,YACA,SACF;IAKA,IAFE,QAAQ,QAAQ,KAAK,IAAI,IAAI,QAAQ,eAAe,QAAQ,MAE/C;KACb,KAAK,YAAY,OAAO,YAAY,MAAM;KAC1C;IACF;IAEA,IAAI,QAAQ,WACV,QAAQ,eAAe,KAAK,IAAI;IAGlC,IAAI,QAAQ,UAAU,CAAE,MAAM,QAAQ,OAAO,GAAG,IAAI,GAClD;IAGF,IAAI;KACF,MAAM,WAAW,GAAG,IAAI;IAC1B,SAAS,GAAG;KACV,IAAI,QAAQ,SACV,MAAM,QAAQ,QAAe,CAAC;UAE9B,MAAM;IAEV,UAAU;KACR,IAAI,QAAQ,MACV,KAAK,YAAY,OAAO,YAAY,MAAM;IAE9C;GACF;EAEJ;EAEA,KAAK,eAAe,IAAI,OAAO,OAAO;EAEtC,OAAO;CACT;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_commandkit = require("../../commandkit-
|
|
2
|
+
const require_commandkit = require("../../commandkit-Ck5bsJYv.js");
|
|
3
3
|
|
|
4
4
|
exports.ElementType = require_commandkit.ElementType;
|
|
5
5
|
exports.Fragment = require_commandkit.Fragment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.js","names":["FileBuilder"],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"file.js","names":["FileBuilder"],"sources":["../../../src/components/display/file.ts"],"sourcesContent":["import { FileBuilder, FileComponentData } from 'discord.js';\n\n/**\n * Represents the properties for a file component.\n */\nexport interface FileProps extends Omit<FileComponentData, 'type' | 'file'> {\n url: string;\n}\n\n/**\n * The file component\n * @param props - The properties for the file component.\n * @returns The file builder instance.\n * @example ```tsx\n * import { File } from 'commandkit';\n *\n * const file = <File url=\"https://example.com/file.png\" />;\n * ```\n */\nexport function File(props: FileProps) {\n const file = new FileBuilder(props);\n\n if (props.url != null) {\n file.setURL(props.url);\n }\n\n return file;\n}\n"],"mappings":";;;;;;;;;;;;;;AAmBA,SAAgB,KAAK,OAAkB;CACrC,MAAM,OAAO,IAAIA,uBAAY,KAAK;CAElC,IAAI,MAAM,OAAO,MACf,KAAK,OAAO,MAAM,GAAG;CAGvB,OAAO;AACT"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_commandkit = require("../../commandkit-
|
|
2
|
+
const require_commandkit = require("../../commandkit-Ck5bsJYv.js");
|
|
3
3
|
const require_components_display_file = require("./file.js");
|
|
4
4
|
const require_components_display_separator = require("./separator.js");
|
|
5
5
|
const require_components_display_text_display = require("./text-display.js");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_commandkit = require("../../commandkit-
|
|
2
|
+
const require_commandkit = require("../../commandkit-Ck5bsJYv.js");
|
|
3
3
|
|
|
4
4
|
exports.MediaGallery = require_commandkit.MediaGallery;
|
|
5
5
|
exports.MediaGalleryItem = require_commandkit.MediaGalleryItem;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poll.js","names":["PollLayoutType"],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"poll.js","names":["PollLayoutType"],"sources":["../../../src/components/display/poll.ts"],"sourcesContent":["import {\n PollLayoutType,\n type PollAnswerData,\n type PollData,\n type PollQuestionMedia,\n} from 'discord.js';\n\n/**\n * The poll properties for the poll component.\n */\nexport interface PollProps extends Partial<\n Omit<PollData, 'question' | 'answers'>\n> {\n /**\n * The poll children components (question and answers).\n */\n children: PollChildrenType[];\n}\n\nenum PollChildType {\n Answer,\n Question,\n}\n\ntype PollChild<T, Type extends PollChildType> = T & {\n $$typeof: Type;\n};\n\nexport type PollChildrenType =\n | PollChild<PollQuestionProps, PollChildType.Question>\n | PollChild<PollAnswerProps, PollChildType.Answer>;\n\n/**\n * The poll component creates a Discord poll with a question and multiple answer options.\n * @param props The poll properties.\n * @returns The poll data object.\n * @example ```tsx\n * import { Poll, PollQuestion, PollAnswer } from 'commandkit';\n *\n * const poll = <Poll duration={24} allowMultiselect={false}>\n * <PollQuestion>What's your favorite color?</PollQuestion>\n * <PollAnswer emoji=\"🟥\">Red</PollAnswer>\n * <PollAnswer emoji=\"🟦\">Blue</PollAnswer>\n * <PollAnswer emoji=\"🟩\">Green</PollAnswer>\n * </Poll>;\n * ```\n */\nexport function Poll({ children, ...props }: PollProps): PollData {\n const question = children.find(\n (child): child is PollChild<PollQuestionProps, PollChildType.Question> =>\n child.$$typeof === PollChildType.Question,\n );\n\n if (!question) {\n throw new Error('Poll question is required');\n }\n\n const answers = children.filter(\n (child): child is PollChild<PollAnswerProps, PollChildType.Answer> =>\n child.$$typeof === PollChildType.Answer,\n );\n\n const { children: questionChildren, ...questionProps } = question;\n const { duration, allowMultiselect, layoutType, ...restProps } = props;\n\n return {\n duration: duration ?? 24,\n allowMultiselect: allowMultiselect ?? false,\n layoutType: layoutType ?? PollLayoutType.Default,\n ...restProps,\n question: { text: questionChildren, ...questionProps },\n answers: answers.map(\n ({ children: answerChildren, $$typeof, ...answerProps }) => ({\n text: answerChildren,\n ...answerProps,\n }),\n ),\n };\n}\n\n/**\n * The poll question properties for the poll question component.\n */\nexport interface PollQuestionProps extends Omit<PollQuestionMedia, 'text'> {\n /**\n * The question text content.\n */\n children: PollQuestionMedia['text'];\n}\n\n/**\n * The poll question component defines the question text for a Discord poll.\n * @param props The poll question properties.\n * @returns The poll question media object.\n * @example ```tsx\n * import { PollQuestion } from 'commandkit';\n *\n * const question = <PollQuestion>What's your favorite programming language?</PollQuestion>;\n * ```\n */\nexport function PollQuestion({\n children,\n ...props\n}: PollQuestionProps): PollChild<PollQuestionMedia, PollChildType.Question> {\n return { ...props, text: children, $$typeof: PollChildType.Question };\n}\n\n/**\n * The poll answer properties for the poll answer component.\n */\nexport interface PollAnswerProps extends Omit<PollAnswerData, 'text'> {\n /**\n * The answer text content.\n */\n children: PollAnswerData['text'];\n}\n\n/**\n * The poll answer component defines an answer option for a Discord poll.\n * @param props The poll answer properties.\n * @returns The poll answer data object.\n * @example ```tsx\n * import { PollAnswer } from 'commandkit';\n *\n * const answer = <PollAnswer emoji=\"🟦\">TypeScript</PollAnswer>;\n * ```\n */\nexport function PollAnswer({\n children,\n ...props\n}: PollAnswerProps): PollChild<PollAnswerData, PollChildType.Answer> {\n return { ...props, text: children, $$typeof: PollChildType.Answer };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA+CA,SAAgB,KAAK,EAAE,UAAU,GAAG,SAA8B;CAChE,MAAM,WAAW,SAAS,MACvB,UACC,MAAM,cACV;CAEA,IAAI,CAAC,UACH,MAAM,IAAI,MAAM,2BAA2B;CAG7C,MAAM,UAAU,SAAS,QACtB,UACC,MAAM,cACV;CAEA,MAAM,EAAE,UAAU,kBAAkB,GAAG,kBAAkB;CACzD,MAAM,EAAE,UAAU,kBAAkB,YAAY,GAAG,cAAc;CAEjE,OAAO;EACL,UAAU,YAAY;EACtB,kBAAkB,oBAAoB;EACtC,YAAY,cAAcA,0BAAe;EACzC,GAAG;EACH,UAAU;GAAE,MAAM;GAAkB,GAAG;EAAc;EACrD,SAAS,QAAQ,KACd,EAAE,UAAU,gBAAgB,UAAU,GAAG,mBAAmB;GAC3D,MAAM;GACN,GAAG;EACL,EACF;CACF;AACF;;;;;;;;;;;AAsBA,SAAgB,aAAa,EAC3B,UACA,GAAG,SACuE;CAC1E,OAAO;EAAE,GAAG;EAAO,MAAM;EAAU;CAAiC;AACtE;;;;;;;;;;;AAsBA,SAAgB,WAAW,EACzB,UACA,GAAG,SACgE;CACnE,OAAO;EAAE,GAAG;EAAO,MAAM;EAAU;CAA+B;AACpE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_commandkit = require("../../commandkit-
|
|
2
|
+
const require_commandkit = require("../../commandkit-Ck5bsJYv.js");
|
|
3
3
|
|
|
4
4
|
exports.Section = require_commandkit.Section;
|
|
5
5
|
exports.Thumbnail = require_commandkit.Thumbnail;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"separator.js","names":["SeparatorBuilder"],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"separator.js","names":["SeparatorBuilder"],"sources":["../../../src/components/display/separator.ts"],"sourcesContent":["import { SeparatorBuilder, SeparatorComponentData } from 'discord.js';\n\n/**\n * Represents the properties for a separator component.\n */\nexport interface SeparatorProps extends Omit<SeparatorComponentData, 'type'> {}\n\n/**\n * The components v2 separator component\n * @param props The properties for the separator component.\n * @returns The separator builder instance.\n * @example ```tsx\n * import { Separator } from 'commandkit';\n *\n * const separator = <Separator />;\n * ```\n */\nexport function Separator(props: SeparatorProps) {\n const separator = new SeparatorBuilder(props);\n return separator;\n}\n"],"mappings":";;;;;;;;;;;;;;AAiBA,SAAgB,UAAU,OAAuB;CAE/C,OAAO,IADeA,4BAAiB,KACxB;AACjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-display.js","names":["TextDisplayBuilder"],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"text-display.js","names":["TextDisplayBuilder"],"sources":["../../../src/components/display/text-display.ts"],"sourcesContent":["import { TextDisplayBuilder, TextDisplayComponentData } from 'discord.js';\n\n/**\n * Represents a type that can be encoded as a string.\n */\nexport type StringEncodable = string | number | boolean;\n\n/**\n * Represents the properties for a text display component.\n * This interface extends the TextDisplayComponentData type from discord.js,\n * excluding the 'type' and 'content' properties.\n */\nexport interface TextDisplayProps extends Omit<\n TextDisplayComponentData,\n 'type' | 'content'\n> {\n children?: StringEncodable | StringEncodable[];\n content?: string;\n}\n\n/**\n * The components v2 text display component\n * @param props The properties for the text display component.\n * @returns The text display builder instance.\n * @example ```tsx\n * import { TextDisplay } from 'commandkit';\n *\n * const textDisplay = <TextDisplay content=\"Hello, world!\" />;\n * // or\n * const textDisplay = <TextDisplay>Some text content</TextDisplay>;\n * ```\n */\nexport function TextDisplay(props: TextDisplayProps) {\n const textDisplay = new TextDisplayBuilder(props);\n\n if (!props.content && props.children) {\n if (Array.isArray(props.children)) {\n textDisplay.setContent(props.children.join(' '));\n } else {\n textDisplay.setContent(\n typeof props.children === 'string'\n ? props.children\n : String(props.children),\n );\n }\n }\n\n return textDisplay;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgCA,SAAgB,YAAY,OAAyB;CACnD,MAAM,cAAc,IAAIA,8BAAmB,KAAK;CAEhD,IAAI,CAAC,MAAM,WAAW,MAAM,UAAU;EACpC,IAAI,MAAM,QAAQ,MAAM,QAAQ,GAC9B,YAAY,WAAW,MAAM,SAAS,KAAK,GAAG,CAAC;OAE/C,YAAY,WACV,OAAO,MAAM,aAAa,WACtB,MAAM,WACN,OAAO,MAAM,QAAQ,CAC3B;CAEJ;CAEA,OAAO;AACT"}
|
package/dist/components/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_components_interactive_action_row_ActionRow = require("./interactive/action-row/ActionRow.js");
|
|
3
|
-
const require_commandkit = require("../commandkit-
|
|
3
|
+
const require_commandkit = require("../commandkit-Ck5bsJYv.js");
|
|
4
4
|
const require_components_display_file = require("./display/file.js");
|
|
5
5
|
const require_components_display_separator = require("./display/separator.js");
|
|
6
6
|
const require_components_display_text_display = require("./display/text-display.js");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionRow.js","names":["ActionRowBuilder"],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"ActionRow.js","names":["ActionRowBuilder"],"sources":["../../../../src/components/interactive/action-row/ActionRow.ts"],"sourcesContent":["import { ActionRowBuilder } from 'discord.js';\nimport { AnyCommandKitElement, CommandKitElement } from '../../common/element';\n\n/**\n * The properties for the action row component.\n */\nexport interface ActionRowProps {\n children?: AnyCommandKitElement[] | AnyCommandKitElement;\n}\n\n/**\n * The action row component.\n * @param props The action row properties.\n * @returns The commandkit element.\n * @example <ActionRow><Button label=\"Click me\" style={ButtonStyle.Primary} customId=\"click_me\" /></ActionRow>\n */\nexport function ActionRow(\n props: ActionRowProps,\n): CommandKitElement<'action-row'> {\n const row = new ActionRowBuilder();\n\n if (Array.isArray(props.children)) {\n // @ts-ignore\n row.setComponents(...props.children);\n } else if (props.children) {\n // @ts-ignore\n row.setComponents(props.children);\n }\n\n return row;\n}\n"],"mappings":";;;;;;;;;;AAgBA,SAAgB,UACd,OACiC;CACjC,MAAM,MAAM,IAAIA,4BAAiB;CAEjC,IAAI,MAAM,QAAQ,MAAM,QAAQ,GAE9B,IAAI,cAAc,GAAG,MAAM,QAAQ;MAC9B,IAAI,MAAM,UAEf,IAAI,cAAc,MAAM,QAAQ;CAGlC,OAAO;AACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_commandkit = require("../../../commandkit-
|
|
2
|
+
const require_commandkit = require("../../../commandkit-Ck5bsJYv.js");
|
|
3
3
|
|
|
4
4
|
exports.ButtonKit = require_commandkit.ButtonKit;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_commandkit = require("../../../commandkit-
|
|
2
|
+
const require_commandkit = require("../../../commandkit-Ck5bsJYv.js");
|
|
3
3
|
|
|
4
4
|
exports.Checkbox = require_commandkit.Checkbox;
|
|
5
5
|
exports.CheckboxGroup = require_commandkit.CheckboxGroup;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_commandkit = require("../../../commandkit-
|
|
2
|
+
const require_commandkit = require("../../../commandkit-Ck5bsJYv.js");
|
|
3
3
|
|
|
4
4
|
exports.FileUpload = require_commandkit.FileUpload;
|
|
5
5
|
exports.Modal = require_commandkit.Modal;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_commandkit = require("../../../commandkit-
|
|
2
|
+
const require_commandkit = require("../../../commandkit-Ck5bsJYv.js");
|
|
3
3
|
|
|
4
4
|
exports.RadioGroup = require_commandkit.RadioGroup;
|
|
5
5
|
exports.RadioGroupOption = require_commandkit.RadioGroupOption;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_commandkit = require("../../../commandkit-
|
|
2
|
+
const require_commandkit = require("../../../commandkit-Ck5bsJYv.js");
|
|
3
3
|
|
|
4
4
|
exports.ChannelSelectMenuKit = require_commandkit.ChannelSelectMenuKit;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_commandkit = require("../../../commandkit-
|
|
2
|
+
const require_commandkit = require("../../../commandkit-Ck5bsJYv.js");
|
|
3
3
|
|
|
4
4
|
exports.MentionableSelectMenuKit = require_commandkit.MentionableSelectMenuKit;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_commandkit = require("../../../commandkit-
|
|
2
|
+
const require_commandkit = require("../../../commandkit-Ck5bsJYv.js");
|
|
3
3
|
|
|
4
4
|
exports.RoleSelectMenuKit = require_commandkit.RoleSelectMenuKit;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_commandkit = require("../../../commandkit-
|
|
2
|
+
const require_commandkit = require("../../../commandkit-Ck5bsJYv.js");
|
|
3
3
|
|
|
4
4
|
exports.ChannelSelectMenu = require_commandkit.ChannelSelectMenu;
|
|
5
5
|
exports.MentionableSelectMenu = require_commandkit.MentionableSelectMenu;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_commandkit = require("../../../commandkit-
|
|
2
|
+
const require_commandkit = require("../../../commandkit-Ck5bsJYv.js");
|
|
3
3
|
|
|
4
4
|
exports.StringSelectMenuKit = require_commandkit.StringSelectMenuKit;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_commandkit = require("../../../commandkit-
|
|
2
|
+
const require_commandkit = require("../../../commandkit-Ck5bsJYv.js");
|
|
3
3
|
|
|
4
4
|
exports.UserSelectMenuKit = require_commandkit.UserSelectMenuKit;
|
package/dist/config/config.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_commandkit = require("../commandkit-
|
|
2
|
+
const require_commandkit = require("../commandkit-Ck5bsJYv.js");
|
|
3
3
|
|
|
4
4
|
exports.defineConfig = require_commandkit.defineConfig;
|
|
5
5
|
exports.getConfig = require_commandkit.getConfig;
|
package/dist/config/default.js
CHANGED
package/dist/config/loader.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_commandkit = require("../commandkit-
|
|
2
|
+
const require_commandkit = require("../commandkit-Ck5bsJYv.js");
|
|
3
3
|
|
|
4
4
|
exports.getPossibleConfigPaths = require_commandkit.getPossibleConfigPaths;
|
|
5
5
|
exports.loadConfigFile = require_commandkit.loadConfigFile;
|
package/dist/config/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../src/config/utils.ts"],"sourcesContent":["import { CommandKitConfig } from './types';\n\n/**\n * @private\n */\nexport type DeepRequired<T, OptionalKeys extends keyof T = never> = {\n [P in keyof T]-?: P extends OptionalKeys ? Partial<T[P]> : DeepRequired<T[P]>;\n};\n\n/**\n * @private\n */\nexport type DeepPartial<T> = {\n [P in keyof T]?: DeepPartial<T[P]>;\n};\n\n/**\n * @private\n * @example\n * ```ts\n * const target = { a: 1, b: { c: 2 } };\n * const source = { b: { d: 3 } };\n * const result = mergeDeep(target, source);\n * // result = { a: 1, b: { c: 2, d: 3 } }\n * ```\n */\nexport const mergeDeep = <T extends Record<string, any>>(\n target: T,\n source?: T,\n tracker = new WeakMap<object, boolean>(),\n): T => {\n if (!source) return target;\n const isObject = (obj: unknown) =>\n obj && typeof obj === 'object' && !Array.isArray(obj);\n\n // Prevent infinite recursion\n if (tracker.has(target)) {\n return target;\n }\n\n // Mark the target as visited\n tracker.set(target, true);\n\n const output: T = { ...target };\n if (isObject(target) && isObject(source)) {\n Object.keys(source).forEach((key) => {\n if (isObject(source[key])) {\n if (!(key in target)) {\n Object.assign(output, { [key]: source[key] });\n } else {\n output[key as keyof T] = mergeDeep(target[key], source[key], tracker);\n }\n } else {\n Object.assign(output, { [key]: source[key] });\n }\n });\n }\n\n return output as T;\n};\n\nexport type ResolvedCommandKitConfig = DeepRequired<\n CommandKitConfig,\n 'compilerOptions'\n>;\n"],"mappings":";;;;;;;;;;;;AA0BA,MAAa,aACX,QACA,QACA,0BAAU,IAAI,QAAyB,MACjC;CACN,IAAI,CAAC,QAAQ,OAAO;CACpB,MAAM,YAAY,QAChB,OAAO,OAAO,QAAQ,YAAY,CAAC,MAAM,QAAQ,GAAG;CAGtD,IAAI,QAAQ,IAAI,MAAM,GACpB,OAAO;CAIT,QAAQ,IAAI,QAAQ,IAAI;CAExB,MAAM,SAAY,EAAE,GAAG,OAAO;CAC9B,IAAI,SAAS,MAAM,KAAK,SAAS,MAAM,GACrC,OAAO,KAAK,MAAM,CAAC,CAAC,SAAS,QAAQ;EACnC,IAAI,SAAS,OAAO,IAAI,GAAG;GACzB,IAAI,EAAE,OAAO,SACX,OAAO,OAAO,QAAQ,GAAG,MAAM,OAAO,KAAK,CAAC;QAE5C,OAAO,OAAkB,UAAU,OAAO,MAAM,OAAO,MAAM,OAAO;EAExE,OACE,OAAO,OAAO,QAAQ,GAAG,MAAM,OAAO,KAAK,CAAC;CAEhD,CAAC;CAGH,OAAO;AACT"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_commandkit = require("../commandkit-
|
|
2
|
+
const require_commandkit = require("../commandkit-Ck5bsJYv.js");
|
|
3
3
|
|
|
4
4
|
exports.exitContext = require_commandkit.exitContext;
|
|
5
5
|
exports.getCommandKit = require_commandkit.getCommandKit;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_commandkit = require("../commandkit-
|
|
2
|
+
const require_commandkit = require("../commandkit-Ck5bsJYv.js");
|
|
3
3
|
|
|
4
4
|
exports.CommandKitEnvironment = require_commandkit.CommandKitEnvironment;
|
|
5
5
|
exports.CommandKitEnvironmentType = require_commandkit.CommandKitEnvironmentType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandKitEventsChannel.js","names":["EventEmitter"],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"CommandKitEventsChannel.js","names":["EventEmitter"],"sources":["../../src/events/CommandKitEventsChannel.ts"],"sourcesContent":["import EventEmitter from 'node:events';\nimport type { CommandKit } from '../commandkit';\nimport type { AsyncFunction, GenericFunction } from '../context/async-context';\n\n/**\n * The function type for event listeners.\n */\nexport type ListenerFunction = GenericFunction | AsyncFunction;\n\n/**\n * Represents a channel for emitting and listening to events in CommandKit.\n * This class provides methods to manage event listeners and emit events\n * within a specific namespace.\n */\nexport class CommandKitEventsChannel {\n private emitter = new EventEmitter();\n\n /**\n * Creates a new instance of CommandKitEventsChannel.\n * @param commandkit The CommandKit instance that this channel belongs to.\n */\n public constructor(public readonly commandkit: CommandKit) {}\n\n /**\n * Creates a namespaced event channel. This allows you to manage events\n * within a specific namespace, preventing conflicts with other event channels.\n * This is useful for organizing events related to different parts of your application.\n * @param namespace The namespace for the event channel.\n * @returns An object containing methods for managing events within the namespace.\n * @example commandkit.events.to('customNamespace').emit('eventName', data);\n */\n public to(namespace: string) {\n return {\n on: this.on.bind(this, namespace),\n off: this.off.bind(this, namespace),\n once: this.once.bind(this, namespace),\n emit: this.emit.bind(this, namespace),\n removeAllListeners: this.removeAllListeners.bind(this, namespace),\n };\n }\n\n /**\n * Register an event listener for a specific event within the namespace.\n * @param namespace The namespace for the event channel.\n * @param event The name of the event to listen for.\n * @param listener The function to call when the event is emitted.\n */\n public on(namespace: string, event: string, listener: ListenerFunction) {\n this.emitter.on(`${namespace}:${event}`, listener);\n }\n\n /**\n * Unregister an event listener for a specific event within the namespace.\n * @param namespace The namespace for the event channel.\n * @param event The name of the event to stop listening for.\n * @param listener The function that was registered as the listener.\n */\n public off(namespace: string, event: string, listener: ListenerFunction) {\n this.emitter.off(`${namespace}:${event}`, listener);\n }\n\n /**\n * Register an event listener that will be called only once for a specific event\n * within the namespace.\n * @param namespace The namespace for the event channel.\n * @param event The name of the event to listen for.\n * @param listener The function to call when the event is emitted.\n */\n public once(namespace: string, event: string, listener: ListenerFunction) {\n this.emitter.once(`${namespace}:${event}`, listener);\n }\n\n /**\n * Emit an event within the specified namespace, calling all registered listeners.\n * @param namespace The namespace for the event channel.\n * @param event The name of the event to emit.\n * @param args The arguments to pass to the listeners.\n * @returns A boolean indicating whether any listeners were called.\n */\n public emit(namespace: string, event: string, ...args: any[]) {\n return this.emitter.emit(`${namespace}:${event}`, ...args);\n }\n\n /**\n * Remove all listeners for a specific event or all events within the namespace.\n * @param namespace The namespace for the event channel.\n * @param event The name of the event to remove listeners for. If not provided, all listeners for all events in the namespace will be removed.\n */\n public removeAllListeners(namespace: string): void;\n public removeAllListeners(namespace: string, event: string): void;\n public removeAllListeners(namespace: string, event?: string): void {\n if (event) {\n this.emitter.removeAllListeners(`${namespace}:${event}`);\n } else {\n this.emitter.removeAllListeners(namespace);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;AAcA,IAAa,0BAAb,MAAqC;CAOA;CANnC,AAAQ,UAAU,IAAIA,oBAAa;;;;;CAMnC,AAAO,YAAY,AAAgB,YAAwB;EAAxB;CAAyB;;;;;;;;;CAU5D,AAAO,GAAG,WAAmB;EAC3B,OAAO;GACL,IAAI,KAAK,GAAG,KAAK,MAAM,SAAS;GAChC,KAAK,KAAK,IAAI,KAAK,MAAM,SAAS;GAClC,MAAM,KAAK,KAAK,KAAK,MAAM,SAAS;GACpC,MAAM,KAAK,KAAK,KAAK,MAAM,SAAS;GACpC,oBAAoB,KAAK,mBAAmB,KAAK,MAAM,SAAS;EAClE;CACF;;;;;;;CAQA,AAAO,GAAG,WAAmB,OAAe,UAA4B;EACtE,KAAK,QAAQ,GAAG,GAAG,UAAU,GAAG,SAAS,QAAQ;CACnD;;;;;;;CAQA,AAAO,IAAI,WAAmB,OAAe,UAA4B;EACvE,KAAK,QAAQ,IAAI,GAAG,UAAU,GAAG,SAAS,QAAQ;CACpD;;;;;;;;CASA,AAAO,KAAK,WAAmB,OAAe,UAA4B;EACxE,KAAK,QAAQ,KAAK,GAAG,UAAU,GAAG,SAAS,QAAQ;CACrD;;;;;;;;CASA,AAAO,KAAK,WAAmB,OAAe,GAAG,MAAa;EAC5D,OAAO,KAAK,QAAQ,KAAK,GAAG,UAAU,GAAG,SAAS,GAAG,IAAI;CAC3D;CASA,AAAO,mBAAmB,WAAmB,OAAsB;EACjE,IAAI,OACF,KAAK,QAAQ,mBAAmB,GAAG,UAAU,GAAG,OAAO;OAEvD,KAAK,QAAQ,mBAAmB,SAAS;CAE7C;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlagProvider.js","names":[],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"FlagProvider.js","names":[],"sources":["../../src/flags/FlagProvider.ts"],"sourcesContent":["import type { MaybePromise } from './feature-flags';\n\n/**\n * Interface for external feature flag providers.\n * Implement this interface to integrate with external flag management systems\n * like LaunchDarkly, Split, Unleash, etc.\n */\nexport interface FlagProvider {\n /**\n * Initialize the provider (e.g., establish connections, load initial config)\n */\n initialize?(): MaybePromise<void>;\n\n /**\n * Get the current value/configuration for a feature flag\n * @param key - The feature flag key\n * @param context - Optional context for flag evaluation\n * @returns The flag configuration or null if not found\n */\n getFlag(key: string, context?: any): MaybePromise<FlagConfiguration | null>;\n\n /**\n * Check if a flag exists in the external system\n * @param key - The feature flag key\n */\n hasFlag(key: string): MaybePromise<boolean>;\n\n /**\n * Cleanup resources when the provider is no longer needed\n */\n destroy?(): MaybePromise<void>;\n}\n\n/**\n * Configuration returned by external flag providers\n */\nexport interface FlagConfiguration {\n /**\n * Whether the flag is enabled/disabled at the provider level\n */\n enabled: boolean;\n\n /**\n * Optional configuration data that can be used in the decide function\n */\n config?: Record<string, any>;\n\n /**\n * Optional percentage for gradual rollouts (0-100)\n */\n percentage?: number;\n\n /**\n * Optional targeting rules or segments\n */\n targeting?: {\n segments?: string[];\n rules?: Array<{\n condition: string;\n value: any;\n }>;\n };\n}\n\n/**\n * Example implementation for a simple JSON-based flag provider\n */\nexport class JsonFlagProvider implements FlagProvider {\n private flags: Map<string, FlagConfiguration> = new Map();\n\n public constructor(private config: Record<string, FlagConfiguration>) {\n Object.entries(config).forEach(([key, value]) => {\n this.flags.set(key, value);\n });\n }\n\n public async getFlag(key: string): Promise<FlagConfiguration | null> {\n return this.flags.get(key) || null;\n }\n\n public async hasFlag(key: string): Promise<boolean> {\n return this.flags.has(key);\n }\n\n public async destroy(): Promise<void> {\n this.flags.clear();\n }\n}\n"],"mappings":";;;;;AAmEA,IAAa,mBAAb,MAAsD;CAGzB;CAF3B,AAAQ,wBAAwC,IAAI,IAAI;CAExD,AAAO,YAAY,AAAQ,QAA2C;EAA3C;EACzB,OAAO,QAAQ,MAAM,CAAC,CAAC,SAAS,CAAC,KAAK,WAAW;GAC/C,KAAK,MAAM,IAAI,KAAK,KAAK;EAC3B,CAAC;CACH;CAEA,MAAa,QAAQ,KAAgD;EACnE,OAAO,KAAK,MAAM,IAAI,GAAG,KAAK;CAChC;CAEA,MAAa,QAAQ,KAA+B;EAClD,OAAO,KAAK,MAAM,IAAI,GAAG;CAC3B;CAEA,MAAa,UAAyB;EACpC,KAAK,MAAM,MAAM;CACnB;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_commandkit = require("../commandkit-
|
|
2
|
+
const require_commandkit = require("../commandkit-Ck5bsJYv.js");
|
|
3
3
|
|
|
4
4
|
exports.FeatureFlag = require_commandkit.FeatureFlag;
|
|
5
5
|
exports.flag = require_commandkit.flag;
|
package/dist/flags/store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","names":["Collection"],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"store.js","names":["Collection"],"sources":["../../src/flags/store.ts"],"sourcesContent":["import type { FeatureFlag } from './feature-flags';\nimport { Collection } from 'discord.js';\n\n/**\n * Represents a store for feature flags.\n * This store extends the Collection class to manage feature flags by their keys.\n */\nexport class FlagStore extends Collection<string, FeatureFlag<any, any>> {}\n"],"mappings":";;;;;;;;AAOA,IAAa,YAAb,cAA+BA,sBAA0C,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
2
|
const require_components_interactive_action_row_ActionRow = require("./components/interactive/action-row/ActionRow.js");
|
|
3
3
|
const require_utils_error_codes = require("./utils/error-codes.js");
|
|
4
|
-
const require_commandkit = require("./commandkit-
|
|
4
|
+
const require_commandkit = require("./commandkit-Ck5bsJYv.js");
|
|
5
5
|
const require_plugins_CompilerPlugin = require("./plugins/CompilerPlugin.js");
|
|
6
6
|
const require_plugins_RuntimePlugin = require("./plugins/RuntimePlugin.js");
|
|
7
7
|
const require_utils_constants = require("./utils/constants.js");
|
package/dist/kv/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":[],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../../src/kv/constants.ts"],"sourcesContent":["export enum SerializerType {\n String,\n Number,\n Boolean,\n Object,\n Date,\n BigInt,\n Null,\n Undefined,\n Array,\n Map,\n Set,\n Buffer,\n RegExp,\n}\n"],"mappings":";;AAAA,IAAY,iBAAL;CACL;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;AACF"}
|
package/dist/kv/dotprops.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dotprops.js","names":[],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"dotprops.js","names":[],"sources":["../../src/kv/dotprops.ts"],"sourcesContent":["export function getNestedValue(obj: any, path: string): any {\n const keys = path.split('.');\n let current = obj;\n\n for (const key of keys) {\n if (current === null || current === undefined) {\n return undefined;\n }\n current = current[key];\n }\n\n return current;\n}\n\nexport function setNestedValue(obj: any, path: string, value: any): void {\n const keys = path.split('.');\n const lastKey = keys.pop()!;\n let current = obj;\n\n for (const key of keys) {\n if (current[key] === null || current[key] === undefined) {\n current[key] = {};\n }\n current = current[key];\n }\n\n current[lastKey] = value;\n}\n"],"mappings":";;AAAA,SAAgB,eAAe,KAAU,MAAmB;CAC1D,MAAM,OAAO,KAAK,MAAM,GAAG;CAC3B,IAAI,UAAU;CAEd,KAAK,MAAM,OAAO,MAAM;EACtB,IAAI,YAAY,QAAQ,YAAY,QAClC;EAEF,UAAU,QAAQ;CACpB;CAEA,OAAO;AACT;AAEA,SAAgB,eAAe,KAAU,MAAc,OAAkB;CACvE,MAAM,OAAO,KAAK,MAAM,GAAG;CAC3B,MAAM,UAAU,KAAK,IAAI;CACzB,IAAI,UAAU;CAEd,KAAK,MAAM,OAAO,MAAM;EACtB,IAAI,QAAQ,SAAS,QAAQ,QAAQ,SAAS,QAC5C,QAAQ,OAAO,CAAC;EAElB,UAAU,QAAQ;CACpB;CAEA,QAAQ,WAAW;AACrB"}
|
package/dist/kv/kv.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kv.js","names":["DatabaseSync","deserializer","getNestedValue","serializer"],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"kv.js","names":["DatabaseSync","deserializer","getNestedValue","serializer"],"sources":["../../src/kv/kv.ts"],"sourcesContent":["import { DatabaseSync, StatementSync } from 'node:sqlite';\nimport { deserializer, serializer } from './serde';\nimport { getNestedValue, setNestedValue } from './dotprops';\n\nexport type { SerializedValue } from './serde';\n\n/**\n * Mathematical operators supported by the KV math method\n */\nexport type KvMathOperator = '+' | '-' | '*' | '/' | '^' | '%';\n\n/**\n * Configuration options for the KV store\n */\nexport interface KvOptions {\n /** Enable Write-Ahead Logging for better performance and durability */\n enableWAL?: boolean;\n /** Namespace for the key-value store table */\n namespace?: string;\n}\n\n/**\n * A key-value store implementation using SQLite\n *\n * This class provides a simple, persistent key-value storage solution\n * with support for namespaces, automatic cleanup, iteration, expiration, and JSON serialization.\n *\n * @example\n * ```typescript\n * const kv = new KV('data.db');\n *\n * // Store any JSON-serializable data\n * kv.set('user:123', { name: 'John', age: 30 });\n * kv.set('counter', 42);\n * kv.set('active', true);\n * kv.set('dates', [new Date(), new Date()]);\n *\n * // Use dot notation for nested properties\n * kv.set('user:123.name', 'John');\n * kv.set('user:123.settings.theme', 'dark');\n *\n * // Retrieve data\n * const user = kv.get('user:123'); // { name: 'John', age: 30, settings: { theme: 'dark' } }\n * const name = kv.get('user:123.name'); // 'John'\n * ```\n */\nexport class KV implements Disposable, AsyncDisposable {\n private db: DatabaseSync;\n private statements: Record<string, StatementSync> = {};\n\n /**\n * Creates a new KV store instance\n *\n * @param path - Database file path, buffer, URL, or existing DatabaseSync instance\n * @param options - Configuration options for the KV store\n */\n public constructor(\n path: string | Buffer | URL | DatabaseSync,\n private options: KvOptions = {\n enableWAL: true,\n namespace: 'commandkit_kv',\n },\n ) {\n this.db =\n path instanceof DatabaseSync\n ? path\n : new DatabaseSync(path, { open: true });\n\n if (options.enableWAL) {\n this.db.exec(/* sql */ `PRAGMA journal_mode = WAL;`);\n }\n\n const namespace = this.options.namespace ?? 'commandkit_kv';\n\n this.db.exec(/* sql */ `\n CREATE TABLE IF NOT EXISTS ${namespace} (\n key TEXT PRIMARY KEY,\n value TEXT,\n expires_at INTEGER\n )\n `);\n\n this.statements = {\n get: this.db.prepare(\n /* sql */ `SELECT value, expires_at FROM ${namespace} WHERE key = ?`,\n ),\n set: this.db.prepare(\n /* sql */ `INSERT OR REPLACE INTO ${namespace} (key, value, expires_at) VALUES (?, ?, ?)`,\n ),\n setex: this.db.prepare(\n /* sql */ `INSERT OR REPLACE INTO ${namespace} (key, value, expires_at) VALUES (?, ?, ?)`,\n ),\n delete: this.db.prepare(\n /* sql */ `DELETE FROM ${namespace} WHERE key = ?`,\n ),\n has: this.db.prepare(\n /* sql */ `SELECT COUNT(*) FROM ${namespace} WHERE key = ? AND (expires_at IS NULL OR expires_at > ?)`,\n ),\n keys: this.db.prepare(\n /* sql */ `SELECT key FROM ${namespace} WHERE expires_at IS NULL OR expires_at > ?`,\n ),\n values: this.db.prepare(\n /* sql */ `SELECT value FROM ${namespace} WHERE expires_at IS NULL OR expires_at > ?`,\n ),\n clear: this.db.prepare(/* sql */ `DELETE FROM ${namespace}`),\n count: this.db.prepare(\n /* sql */ `SELECT COUNT(*) FROM ${namespace} WHERE expires_at IS NULL OR expires_at > ?`,\n ),\n all: this.db.prepare(\n /* sql */ `SELECT key, value FROM ${namespace} WHERE expires_at IS NULL OR expires_at > ?`,\n ),\n expire: this.db.prepare(\n /* sql */ `UPDATE ${namespace} SET expires_at = ? WHERE key = ?`,\n ),\n ttl: this.db.prepare(\n /* sql */ `SELECT expires_at FROM ${namespace} WHERE key = ?`,\n ),\n namespaces: this.db.prepare(\n /* sql */ `SELECT name FROM sqlite_master WHERE type = 'table' AND name NOT LIKE 'sqlite_%'`,\n ),\n begin: this.db.prepare(/* sql */ `BEGIN TRANSACTION`),\n commit: this.db.prepare(/* sql */ `COMMIT`),\n rollback: this.db.prepare(/* sql */ `ROLLBACK`),\n };\n }\n\n /**\n * Gets the current timestamp in milliseconds\n */\n private getCurrentTime(): number {\n return Date.now();\n }\n\n /**\n * Checks if the database connection is open\n *\n * @returns `true` if the database is open, `false` otherwise\n */\n public isOpen(): boolean {\n return this.db.isOpen;\n }\n\n /**\n * Gets the underlying SQLite database instance\n *\n * @returns The DatabaseSync instance\n */\n public getDatabase(): DatabaseSync {\n return this.db;\n }\n\n /**\n * Closes the database connection\n */\n public close(): void {\n if (this.db.isOpen) this.db.close();\n }\n\n /**\n * Disposable implementation - closes the database when disposed\n */\n public [Symbol.dispose]() {\n this.close();\n }\n\n /**\n * AsyncDisposable implementation - closes the database when disposed\n */\n public async [Symbol.asyncDispose]() {\n this.close();\n }\n\n /**\n * Retrieves a value by key\n *\n * @param key - The key to retrieve (supports dot notation for nested properties)\n * @returns The value associated with the key, or `undefined` if not found or expired\n *\n * @example\n * ```typescript\n * // Store an object\n * kv.set('user:123', { name: 'John', age: 30, settings: { theme: 'dark' } });\n *\n * // Get the entire object\n * const user = kv.get('user:123');\n * // { name: 'John', age: 30, settings: { theme: 'dark' } }\n *\n * // Get nested properties using dot notation\n * const name = kv.get('user:123.name'); // 'John'\n * const theme = kv.get('user:123.settings.theme'); // 'dark'\n * ```\n */\n public get<T = any>(key: string): T | undefined {\n const result = this.statements.get.get(key);\n\n if (!result) return undefined;\n\n // Check if the key has expired\n if (\n result.expires_at &&\n Number(result.expires_at) <= this.getCurrentTime()\n ) {\n this.delete(key);\n return undefined;\n }\n\n const serialized = JSON.parse(result.value as string);\n const deserialized = deserializer(serialized);\n\n // Handle dot notation for nested properties\n if (key.includes('.')) {\n return getNestedValue(deserialized, key.split('.').slice(1).join('.'));\n }\n\n return deserialized;\n }\n\n /**\n * Sets a key-value pair\n *\n * @param key - The key to set (supports dot notation for nested properties)\n * @param value - The value to associate with the key (any JSON-serializable type)\n *\n * @example\n * ```typescript\n * // Store primitive values\n * kv.set('counter', 42);\n * kv.set('active', true);\n * kv.set('name', 'John');\n *\n * // Store objects\n * kv.set('user:123', { name: 'John', age: 30 });\n *\n * // Store arrays\n * kv.set('tags', ['javascript', 'typescript', 'sqlite']);\n *\n * // Store dates\n * kv.set('created', new Date());\n *\n * // Store maps and sets\n * kv.set('permissions', new Map([['admin', true], ['user', false]]));\n * kv.set('unique_ids', new Set([1, 2, 3, 4, 5]));\n *\n * // Use dot notation for nested properties\n * kv.set('user:123.settings.theme', 'dark');\n * kv.set('user:123.settings.notifications', true);\n * ```\n */\n public set(key: string, value: any): void {\n let serializedValue: string;\n\n if (key.includes('.')) {\n // Handle dot notation for nested properties\n const [baseKey, ...pathParts] = key.split('.');\n const path = pathParts.join('.');\n\n // Get existing value or create new object\n const existing = this.get(baseKey) || {};\n setNestedValue(existing, path, value);\n\n const serialized = serializer(existing);\n serializedValue = JSON.stringify(serialized);\n\n this.statements.set.run(baseKey, serializedValue, null);\n } else {\n const serialized = serializer(value);\n serializedValue = JSON.stringify(serialized);\n\n this.statements.set.run(key, serializedValue, null);\n }\n }\n\n /**\n * Sets a key-value pair with expiration\n *\n * @param key - The key to set (supports dot notation for nested properties)\n * @param value - The value to associate with the key (any JSON-serializable type)\n * @param ttl - Time to live in milliseconds\n *\n * @example\n * ```typescript\n * // Set with 1 hour expiration\n * kv.setex('session:123', { userId: 123, token: 'abc123' }, 60 * 60 * 1000);\n *\n * // Set with 5 minutes expiration\n * kv.setex('temp:data', { cached: true, timestamp: Date.now() }, 5 * 60 * 1000);\n *\n * // Use dot notation with expiration\n * kv.setex('user:123.temp_settings', { theme: 'light' }, 30 * 60 * 1000);\n * ```\n */\n public setex(key: string, value: any, ttl: number): void {\n const expiresAt = this.getCurrentTime() + ttl;\n let serializedValue: string;\n\n if (key.includes('.')) {\n // Handle dot notation for nested properties\n const [baseKey, ...pathParts] = key.split('.');\n const path = pathParts.join('.');\n\n // Get existing value or create new object\n const existing = this.get(baseKey) || {};\n setNestedValue(existing, path, value);\n\n const serialized = serializer(existing);\n serializedValue = JSON.stringify(serialized);\n\n this.statements.setex.run(baseKey, serializedValue, expiresAt);\n } else {\n const serialized = serializer(value);\n serializedValue = JSON.stringify(serialized);\n\n this.statements.setex.run(key, serializedValue, expiresAt);\n }\n }\n\n /**\n * Performs mathematical operations on numeric values in the KV store\n *\n * @param key - The key to perform math operation on (supports dot notation for nested properties)\n * @param operator - The mathematical operator to apply\n * @param value - The value to use in the operation\n * @returns The updated value after the mathematical operation\n * @throws Error if the existing value is not numeric or if the operation is invalid\n *\n * @example\n * ```typescript\n * // Initialize a counter\n * kv.set('counter', 10);\n *\n * // Increment by 5\n * const result1 = kv.math('counter', '+', 5); // 15\n *\n * // Multiply by 2\n * const result2 = kv.math('counter', '*', 2); // 30\n *\n * // Use with bigint\n * kv.set('big_counter', BigInt(1000));\n * const result3 = kv.math('big_counter', '+', BigInt(500)); // 1500n\n *\n * // Use with dot notation\n * kv.set('user:123', { score: 100, level: 5 });\n * const result4 = kv.math('user:123.score', '+', 50); // 150\n * ```\n */\n public math(\n key: string,\n operator: KvMathOperator,\n value: number | bigint,\n ): number | bigint {\n const existingValue = this.get(key);\n\n if (existingValue === undefined) {\n throw new Error(`Key '${key}' does not exist`);\n }\n\n if (\n typeof existingValue !== 'number' &&\n typeof existingValue !== 'bigint'\n ) {\n throw new Error(\n `Value at key '${key}' is not numeric. Expected number or bigint, got ${typeof existingValue}`,\n );\n }\n\n // Handle mixed number/bigint operations by converting to bigint\n const isBigIntOperation =\n typeof existingValue === 'bigint' || typeof value === 'bigint';\n\n const existing = isBigIntOperation\n ? typeof existingValue === 'bigint'\n ? existingValue\n : BigInt(existingValue)\n : (existingValue as number);\n const operand = isBigIntOperation\n ? typeof value === 'bigint'\n ? value\n : BigInt(value)\n : (value as number);\n\n let result: number | bigint;\n\n switch (operator) {\n case '+':\n result = (existing as any) + (operand as any);\n break;\n case '-':\n result = (existing as any) - (operand as any);\n break;\n case '*':\n result = (existing as any) * (operand as any);\n break;\n case '/':\n if (operand === 0 || operand === 0n) {\n throw new Error('Division by zero');\n }\n result = (existing as any) / (operand as any);\n break;\n case '^':\n if (isBigIntOperation && operand < 0n) {\n throw new Error(\n 'Exponentiation with negative exponent is not supported for bigint',\n );\n }\n result = (existing as any) ** (operand as any);\n break;\n case '%':\n if (operand === 0 || operand === 0n) {\n throw new Error('Modulo by zero');\n }\n result = (existing as any) % (operand as any);\n break;\n default:\n throw new Error(`Invalid operator: ${operator}`);\n }\n\n // Update the value in the store\n this.set(key, result);\n\n return result;\n }\n\n /**\n * Sets expiration for an existing key\n *\n * @param key - The key to set expiration for\n * @param ttl - Time to live in milliseconds\n * @returns `true` if the key exists and expiration was set, `false` otherwise\n *\n * @example\n * ```typescript\n * kv.set('user:123', { name: 'John', age: 30 });\n *\n * // Set 30 minute expiration\n * if (kv.expire('user:123', 30 * 60 * 1000)) {\n * console.log('Expiration set successfully');\n * }\n * ```\n */\n public expire(key: string, ttl: number): boolean {\n if (!this.has(key)) return false;\n\n const expiresAt = this.getCurrentTime() + ttl;\n this.statements.expire.run(expiresAt, key);\n return true;\n }\n\n /**\n * Gets the time to live for a key\n *\n * @param key - The key to check\n * @returns Time to live in milliseconds, or `-1` if the key doesn't exist, or `-2` if the key has no expiration\n *\n * @example\n * ```typescript\n * const ttl = kv.ttl('user:123');\n * if (ttl > 0) {\n * console.log(`Key expires in ${ttl}ms`);\n * } else if (ttl === -2) {\n * console.log('Key has no expiration');\n * } else {\n * console.log('Key does not exist');\n * }\n * ```\n */\n public ttl(key: string): number {\n const result = this.statements.ttl.get(key);\n\n if (!result) return -1; // Key doesn't exist\n\n if (!result.expires_at) return -2; // No expiration\n\n const remaining = Number(result.expires_at) - this.getCurrentTime();\n return remaining > 0 ? remaining : -1; // Expired or doesn't exist\n }\n\n /**\n * Deletes a key-value pair\n *\n * @param key - The key to delete\n *\n * @example\n * ```typescript\n * kv.delete('user:123');\n * kv.delete('user:123.settings.theme'); // Delete nested property\n * ```\n */\n public delete(key: string): void {\n this.statements.delete.run(key);\n }\n\n /**\n * Checks if a key exists and is not expired\n *\n * @param key - The key to check\n * @returns `true` if the key exists and is not expired, `false` otherwise\n *\n * @example\n * ```typescript\n * if (kv.has('user:123')) {\n * console.log('User exists and is not expired');\n * }\n *\n * if (kv.has('user:123.settings.theme')) {\n * console.log('Theme setting exists');\n * }\n * ```\n */\n public has(key: string): boolean {\n const result = this.statements.has.get(key, this.getCurrentTime());\n\n return (\n result?.count !== undefined &&\n result.count !== null &&\n Number(result.count) > 0\n );\n }\n\n /**\n * Gets all keys in the current namespace (excluding expired keys)\n *\n * @returns Array of all non-expired keys\n *\n * @example\n * ```typescript\n * const keys = kv.keys();\n * console.log('All keys:', keys);\n * ```\n */\n public keys(): string[] {\n const result = this.statements.keys.all(this.getCurrentTime());\n\n return result.map((row) => row.key as string);\n }\n\n /**\n * Gets all values in the current namespace (excluding expired keys)\n *\n * @returns Array of all non-expired values\n *\n * @example\n * ```typescript\n * const values = kv.values();\n * console.log('All values:', values);\n * ```\n */\n public values(): any[] {\n const result = this.statements.values.all(this.getCurrentTime());\n\n return result.map((row) => {\n const serialized = JSON.parse(row.value as string);\n return deserializer(serialized);\n });\n }\n\n /**\n * Gets the total number of key-value pairs in the current namespace (excluding expired keys)\n *\n * @returns The count of non-expired key-value pairs\n *\n * @example\n * ```typescript\n * const count = kv.count();\n * console.log(`Total entries: ${count}`);\n * ```\n */\n public count(): number {\n const result = this.statements.count.get(this.getCurrentTime());\n\n return Number(result?.count ?? 0);\n }\n\n /**\n * Removes all key-value pairs from the current namespace\n *\n * @example\n * ```typescript\n * kv.clear(); // Removes all entries in current namespace\n * ```\n */\n public clear(): void {\n this.statements.clear.run();\n }\n\n /**\n * Gets all key-value pairs as an object (excluding expired keys)\n *\n * @returns Object with all non-expired key-value pairs\n *\n * @example\n * ```typescript\n * const all = kv.all();\n * console.log('All entries:', all);\n * // Output: { 'key1': value1, 'key2': value2 }\n * ```\n */\n public all(): Record<string, any> {\n const result = this.statements.all.all(this.getCurrentTime());\n\n return Object.fromEntries(\n result.map((row) => {\n const serialized = JSON.parse(row.value as string);\n return [row.key as string, deserializer(serialized)];\n }),\n );\n }\n\n /**\n * Gets all available namespaces (tables) in the database\n *\n * @returns Array of namespace names\n *\n * @example\n * ```typescript\n * const namespaces = kv.namespaces();\n * console.log('Available namespaces:', namespaces);\n * ```\n */\n public namespaces(): string[] {\n const result = this.statements.namespaces.all();\n\n return result.map((row) => row.name as string);\n }\n\n /**\n * Gets the current namespace name\n *\n * @returns The current namespace string\n */\n public getCurrentNamespace(): string {\n return this.options.namespace ?? 'commandkit_kv';\n }\n\n /**\n * Creates a new KV instance with a different namespace\n *\n * @param namespace - The namespace to use for the new instance\n * @returns A new KV instance with the specified namespace\n *\n * @example\n * ```typescript\n * const userKv = kv.namespace('users');\n * const configKv = kv.namespace('config');\n *\n * userKv.set('123', { name: 'John', age: 30 });\n * configKv.set('theme', 'dark');\n * ```\n */\n public namespace(namespace: string): KV {\n return new KV(this.db, {\n enableWAL: this.options.enableWAL,\n namespace,\n });\n }\n\n /**\n * Iterator implementation for iterating over all non-expired key-value pairs\n *\n * @returns Iterator yielding [key, value] tuples\n *\n * @example\n * ```typescript\n * for (const [key, value] of kv) {\n * console.log(`${key}:`, value);\n * }\n *\n * // Or using spread operator\n * const entries = [...kv];\n * ```\n */\n public *[Symbol.iterator](): Iterator<[string, any]> {\n const result = this.statements.all.iterate(this.getCurrentTime());\n\n for (const row of result) {\n const serialized = JSON.parse(row.value as string);\n yield [row.key as string, deserializer(serialized)];\n }\n }\n\n /**\n * Executes a function within a transaction\n *\n * @param fn - Function to execute within the transaction (can be async)\n * @returns The result of the function\n *\n * @example\n * ```typescript\n * // Synchronous transaction\n * kv.transaction(() => {\n * kv.set('user:123', { name: 'John', age: 30 });\n * kv.set('user:456', { name: 'Jane', age: 25 });\n * // If any operation fails, all changes are rolled back\n * });\n *\n * // Async transaction\n * await kv.transaction(async () => {\n * kv.set('user:123', { name: 'John', age: 30 });\n * await someAsyncOperation();\n * kv.set('user:456', { name: 'Jane', age: 25 });\n * // If any operation fails, all changes are rolled back\n * });\n * ```\n */\n public async transaction<T>(fn: () => T | Promise<T>): Promise<T> {\n try {\n // Begin transaction\n this.statements.begin.run();\n\n // Execute the function\n const result = await fn();\n\n // Commit transaction\n this.statements.commit.run();\n\n return result;\n } catch (error) {\n // Rollback transaction on error\n this.statements.rollback.run();\n throw error;\n }\n }\n}\n\n/**\n * Opens a new KV instance\n *\n * @param path - Database file path, buffer, URL, or existing DatabaseSync instance\n * @param options - Configuration options for the KV store\n * @returns A new KV instance\n */\nexport function openKV(\n path: string | Buffer | URL | DatabaseSync = 'commandkit_kv.db',\n options: KvOptions = { enableWAL: true, namespace: 'commandkit_kv' },\n): KV {\n return new KV(path, options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,IAAa,KAAb,MAAa,GAA0C;CAY3C;CAXV,AAAQ;CACR,AAAQ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WAAW,MAAM,IAAI;GAG1B,MAAM,SAAS,MAAM,GAAG;GAGxB,KAAK,WAAW,OAAO,IAAI;GAE3B,OAAO;EACT,SAAS,OAAO;GAEd,KAAK,WAAW,SAAS,IAAI;GAC7B,MAAM;EACR;CACF;AACF;;;;;;;;AASA,SAAgB,OACd,OAA6C,oBAC7C,UAAqB;CAAE,WAAW;CAAM,WAAW;AAAgB,GAC/D;CACJ,OAAO,IAAI,GAAG,MAAM,OAAO;AAC7B"}
|
package/dist/kv/serde.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serde.js","names":[],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"serde.js","names":[],"sources":["../../src/kv/serde.ts"],"sourcesContent":["import { SerializerType } from './constants';\n\nexport interface SerializedValue {\n t: SerializerType;\n v: any;\n}\n\nexport function serializer(value: any): SerializedValue {\n if (value === null) {\n return { t: SerializerType.Null, v: null };\n }\n\n if (value === undefined) {\n return { t: SerializerType.Undefined, v: undefined };\n }\n\n if (typeof value === 'string') {\n return { t: SerializerType.String, v: value };\n }\n\n if (typeof value === 'number') {\n return { t: SerializerType.Number, v: value };\n }\n\n if (typeof value === 'boolean') {\n return { t: SerializerType.Boolean, v: value };\n }\n\n if (typeof value === 'bigint') {\n return { t: SerializerType.BigInt, v: value.toString() };\n }\n\n if (value instanceof Date) {\n return { t: SerializerType.Date, v: value.toISOString() };\n }\n\n if (Array.isArray(value)) {\n return { t: SerializerType.Array, v: value };\n }\n\n if (value instanceof Map) {\n return { t: SerializerType.Map, v: Array.from(value.entries()) };\n }\n\n if (value instanceof Set) {\n return { t: SerializerType.Set, v: Array.from(value) };\n }\n\n if (Buffer.isBuffer(value)) {\n return { t: SerializerType.Buffer, v: value.toString('base64') };\n }\n\n if (value instanceof RegExp) {\n return {\n t: SerializerType.RegExp,\n v: { source: value.source, flags: value.flags },\n };\n }\n\n if (typeof value === 'object') {\n return { t: SerializerType.Object, v: value };\n }\n\n // Fallback to string\n return { t: SerializerType.String, v: String(value) };\n}\n\nexport function deserializer(serialized: SerializedValue): any {\n switch (serialized.t) {\n case SerializerType.Null:\n return null;\n case SerializerType.Undefined:\n return undefined;\n case SerializerType.String:\n return serialized.v;\n case SerializerType.Number:\n return serialized.v;\n case SerializerType.Boolean:\n return serialized.v;\n case SerializerType.BigInt:\n return BigInt(serialized.v);\n case SerializerType.Date:\n return new Date(serialized.v);\n case SerializerType.Array:\n return serialized.v;\n case SerializerType.Map:\n return new Map(serialized.v);\n case SerializerType.Set:\n return new Set(serialized.v);\n case SerializerType.Buffer:\n return Buffer.from(serialized.v, 'base64');\n case SerializerType.RegExp:\n return new RegExp(serialized.v.source, serialized.v.flags);\n case SerializerType.Object:\n return serialized.v;\n default:\n return serialized.v;\n }\n}\n"],"mappings":";;;;AAOA,SAAgB,WAAW,OAA6B;CACtD,IAAI,UAAU,MACZ,OAAO;EAAE;EAAwB,GAAG;CAAK;CAG3C,IAAI,UAAU,QACZ,OAAO;EAAE;EAA6B,GAAG;CAAU;CAGrD,IAAI,OAAO,UAAU,UACnB,OAAO;EAAE;EAA0B,GAAG;CAAM;CAG9C,IAAI,OAAO,UAAU,UACnB,OAAO;EAAE;EAA0B,GAAG;CAAM;CAG9C,IAAI,OAAO,UAAU,WACnB,OAAO;EAAE;EAA2B,GAAG;CAAM;CAG/C,IAAI,OAAO,UAAU,UACnB,OAAO;EAAE;EAA0B,GAAG,MAAM,SAAS;CAAE;CAGzD,IAAI,iBAAiB,MACnB,OAAO;EAAE;EAAwB,GAAG,MAAM,YAAY;CAAE;CAG1D,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO;EAAE;EAAyB,GAAG;CAAM;CAG7C,IAAI,iBAAiB,KACnB,OAAO;EAAE;EAAuB,GAAG,MAAM,KAAK,MAAM,QAAQ,CAAC;CAAE;CAGjE,IAAI,iBAAiB,KACnB,OAAO;EAAE;EAAuB,GAAG,MAAM,KAAK,KAAK;CAAE;CAGvD,IAAI,OAAO,SAAS,KAAK,GACvB,OAAO;EAAE;EAA0B,GAAG,MAAM,SAAS,QAAQ;CAAE;CAGjE,IAAI,iBAAiB,QACnB,OAAO;EACL;EACA,GAAG;GAAE,QAAQ,MAAM;GAAQ,OAAO,MAAM;EAAM;CAChD;CAGF,IAAI,OAAO,UAAU,UACnB,OAAO;EAAE;EAA0B,GAAG;CAAM;CAI9C,OAAO;EAAE;EAA0B,GAAG,OAAO,KAAK;CAAE;AACtD;AAEA,SAAgB,aAAa,YAAkC;CAC7D,QAAQ,WAAW,GAAnB;EACE,QACE,OAAO;EACT,QACE;EACF,QACE,OAAO,WAAW;EACpB,QACE,OAAO,WAAW;EACpB,QACE,OAAO,WAAW;EACpB,QACE,OAAO,OAAO,WAAW,CAAC;EAC5B,QACE,OAAO,IAAI,KAAK,WAAW,CAAC;EAC9B,QACE,OAAO,WAAW;EACpB,QACE,OAAO,IAAI,IAAI,WAAW,CAAC;EAC7B,SACE,OAAO,IAAI,IAAI,WAAW,CAAC;EAC7B,SACE,OAAO,OAAO,KAAK,WAAW,GAAG,QAAQ;EAC3C,SACE,OAAO,IAAI,OAAO,WAAW,EAAE,QAAQ,WAAW,EAAE,KAAK;EAC3D,QACE,OAAO,WAAW;EACpB,SACE,OAAO,WAAW;CACtB;AACF"}
|
package/dist/logger/Logger.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_commandkit = require("../commandkit-
|
|
2
|
+
const require_commandkit = require("../commandkit-Ck5bsJYv.js");
|
|
3
3
|
|
|
4
4
|
exports.Logger = require_commandkit.Logger;
|
|
5
5
|
exports.createLogger = require_commandkit.createLogger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoopLogger.js","names":[],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"NoopLogger.js","names":[],"sources":["../../src/logger/NoopLogger.ts"],"sourcesContent":["import { ILogger } from './ILogger';\n\n/**\n * Noop logger implementation that does nothing.\n */\nexport class NoopLogger implements ILogger {\n /**\n * Logs a debug message.\n * @param message The message to log.\n */\n public debug(message: any): void;\n /**\n * Logs a debug message using template literals.\n * @param strings The template literal strings.\n * @param values The values to interpolate.\n */\n public debug(strings: TemplateStringsArray, ...values: any[]): void;\n public debug(\n messageOrStrings: any | TemplateStringsArray,\n ...values: any[]\n ): void {}\n\n /**\n * Logs an error message.\n * @param message The error message to log.\n */\n public error(message: any): void;\n /**\n * Logs an error message using template literals.\n * @param strings The template literal strings.\n * @param values The values to interpolate.\n */\n public error(strings: TemplateStringsArray, ...values: any[]): void;\n public error(\n messageOrStrings: any | TemplateStringsArray,\n ...values: any[]\n ): void {}\n\n /**\n * Logs a default message.\n * @param message The message to log.\n */\n public log(message: any): void;\n /**\n * Logs a default message using template literals.\n * @param strings The template literal strings.\n * @param values The values to interpolate.\n */\n public log(strings: TemplateStringsArray, ...values: any[]): void;\n public log(\n messageOrStrings: any | TemplateStringsArray,\n ...values: any[]\n ): void {}\n\n /**\n * Logs an info message.\n * @param message The informational message to log.\n */\n public info(message: any): void;\n /**\n * Logs an info message using template literals.\n * @param strings The template literal strings.\n * @param values The values to interpolate.\n */\n public info(strings: TemplateStringsArray, ...values: any[]): void;\n public info(\n messageOrStrings: any | TemplateStringsArray,\n ...values: any[]\n ): void {}\n\n /**\n * Logs a warning message.\n * @param message The warning message to log.\n */\n public warn(message: any): void;\n /**\n * Logs a warning message using template literals.\n * @param strings The template literal strings.\n * @param values The values to interpolate.\n */\n public warn(strings: TemplateStringsArray, ...values: any[]): void;\n public warn(\n messageOrStrings: any | TemplateStringsArray,\n ...values: any[]\n ): void {}\n}\n"],"mappings":";;;;;AAKA,IAAa,aAAb,MAA2C;CAYzC,AAAO,MACL,kBACA,GAAG,QACG,CAAC;CAaT,AAAO,MACL,kBACA,GAAG,QACG,CAAC;CAaT,AAAO,IACL,kBACA,GAAG,QACG,CAAC;CAaT,AAAO,KACL,kBACA,GAAG,QACG,CAAC;CAaT,AAAO,KACL,kBACA,GAAG,QACG,CAAC;AACX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompilerPlugin.js","names":["PluginCommon","isPlugin"],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"CompilerPlugin.js","names":["PluginCommon","isPlugin"],"sources":["../../src/plugins/CompilerPlugin.ts"],"sourcesContent":["import {\n isPlugin,\n PluginCommon,\n PluginOptions,\n PluginType,\n} from './PluginCommon';\nimport { MaybeFalsey } from './types';\nimport { CompilerPluginRuntime } from './plugin-runtime/CompilerPluginRuntime';\n\n/**\n * The parameters for the transformation function of a compiler plugin.\n */\nexport interface PluginTransformParameters {\n /**\n * The code to be transformed.\n */\n code: string;\n /**\n * The filename of the code being transformed.\n */\n id: string;\n}\n\nexport interface TransformedResult {\n /**\n * The transformed code.\n */\n code?: string;\n /**\n * The source map for the transformed code, if applicable.\n */\n map?: string | null;\n}\n\n/**\n * CommandKit plugin that runs at compile time.\n */\nexport abstract class CompilerPlugin<\n T extends PluginOptions = PluginOptions,\n> extends PluginCommon<T, CompilerPluginRuntime> {\n /**\n * The type of the plugin, which is Compiler.\n */\n public readonly type = PluginType.Compiler;\n\n /**\n * Called when transformation is requested to this plugin\n * @param params The parameters for the transformation\n * @returns The transformed result\n */\n public async transform(\n params: PluginTransformParameters,\n ): Promise<MaybeFalsey<TransformedResult>> {\n return null;\n }\n}\n\n/**\n * Type guard to check if the given object is a CompilerPlugin.\n * @param plugin The object to check.\n * @returns Boolean indicating whether the object is a CompilerPlugin.\n */\nexport function isCompilerPlugin(plugin: unknown): plugin is CompilerPlugin {\n return (\n plugin instanceof CompilerPlugin ||\n (isPlugin(plugin) && plugin.type === PluginType.Compiler)\n );\n}\n"],"mappings":";;;;;;;AAqCA,IAAsB,iBAAtB,cAEUA,0CAAuC;;;;CAI/C,AAAgB;;;;;;CAOhB,MAAa,UACX,QACyC;EACzC,OAAO;CACT;AACF;;;;;;AAOA,SAAgB,iBAAiB,QAA2C;CAC1E,OACE,kBAAkB,kBACjBC,sCAAS,MAAM,KAAK,OAAO;AAEhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginCommon.js","names":["randomUUID"],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"PluginCommon.js","names":["randomUUID"],"sources":["../../src/plugins/PluginCommon.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport { CommonPluginRuntime } from './plugin-runtime/runtime';\n\n/**\n * The options for a CommandKit plugin.\n */\nexport type PluginOptions = Record<string, any>;\n\n/**\n * Enum representing the type of plugin.\n * - Compiler: A plugin that runs at compile time.\n * - Runtime: A plugin that runs at runtime.\n */\nexport enum PluginType {\n Compiler = 'compiler',\n Runtime = 'runtime',\n}\n\n/**\n * Base class for CommandKit plugins.\n */\nexport abstract class PluginCommon<\n T extends PluginOptions = PluginOptions,\n C extends CommonPluginRuntime = CommonPluginRuntime,\n> {\n /**\n * The type of the plugin, either Compiler or Runtime.\n */\n public abstract readonly type: PluginType;\n /**\n * Unique identifier for the plugin instance.\n */\n public readonly id = randomUUID();\n /**\n * The time when the plugin was loaded, in milliseconds since the Unix epoch.\n */\n public readonly loadedAt = Date.now();\n /**\n * The name of the plugin.\n */\n public abstract readonly name: string;\n\n /**\n * Creates a new instance of the plugin.\n */\n public constructor(protected readonly options: T) {}\n\n /**\n * Called when this plugin is activated\n */\n public async activate(ctx: C): Promise<void> {}\n\n /**\n * Called when this plugin is deactivated\n */\n public async deactivate(ctx: C): Promise<void> {}\n}\n\n/**\n * Whether the given object is a CommandKit plugin.\n * @param plugin The object to check.\n * @returns Boolean indicating whether the object is a plugin.\n */\nexport function isPlugin(\n plugin: unknown,\n): plugin is PluginCommon<PluginOptions> {\n return plugin instanceof PluginCommon;\n}\n"],"mappings":";;;;;;;;;AAaA,IAAY,aAAL;CACL;CACA;;AACF;;;;AAKA,IAAsB,eAAtB,MAGE;CAqBsC;;;;CAbtC,AAAgB,SAAKA,wBAAW;;;;CAIhC,AAAgB,WAAW,KAAK,IAAI;;;;CASpC,AAAO,YAAY,AAAmB,SAAY;EAAZ;CAAa;;;;CAKnD,MAAa,SAAS,KAAuB,CAAC;;;;CAK9C,MAAa,WAAW,KAAuB,CAAC;AAClD;;;;;;AAOA,SAAgB,SACd,QACuC;CACvC,OAAO,kBAAkB;AAC3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RuntimePlugin.js","names":["PluginCommon","isPlugin"],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"RuntimePlugin.js","names":["PluginCommon","isPlugin"],"sources":["../../src/plugins/RuntimePlugin.ts"],"sourcesContent":["import { Interaction, Message } from 'discord.js';\nimport {\n isPlugin,\n PluginCommon,\n PluginOptions,\n PluginType,\n} from './PluginCommon';\nimport type { CommandKitPluginRuntime } from './plugin-runtime/CommandKitPluginRuntime';\nimport { CommandBuilderLike, PreparedAppCommandExecution } from '../app';\nimport { CommandKitEnvironment } from '../context/environment';\nimport { CommandKitHMREvent } from '../utils/dev-hooks';\nimport { PreRegisterCommandsEvent } from '../app/register/CommandRegistrar';\nimport { CommandKitEventDispatch } from './types';\n\n/**\n * CommandKit plugin that runs at the runtime.\n */\nexport abstract class RuntimePlugin<\n T extends PluginOptions = PluginOptions,\n> extends PluginCommon<T, CommandKitPluginRuntime> {\n public readonly type = PluginType.Runtime;\n public readonly preload = new Set<string>();\n\n /**\n * Called before commands are loaded\n */\n public async onBeforeCommandsLoad(\n ctx: CommandKitPluginRuntime,\n ): Promise<void> {}\n\n /**\n * Called after commands are loaded\n */\n public async onAfterCommandsLoad(\n ctx: CommandKitPluginRuntime,\n ): Promise<void> {}\n\n /**\n * Called before events are loaded\n */\n public async onBeforeEventsLoad(\n ctx: CommandKitPluginRuntime,\n ): Promise<void> {}\n\n /**\n * Called after events are loaded\n */\n public async onAfterEventsLoad(ctx: CommandKitPluginRuntime): Promise<void> {}\n\n /**\n * Called before the client logs in\n */\n public async onBeforeClientLogin(\n ctx: CommandKitPluginRuntime,\n ): Promise<void> {}\n\n /**\n * Called after the client logs in\n */\n public async onAfterClientLogin(\n ctx: CommandKitPluginRuntime,\n ): Promise<void> {}\n\n /**\n * Called before interaction is handled\n * @param interaction The interaction\n */\n public async onBeforeInteraction(\n ctx: CommandKitPluginRuntime,\n interaction: Interaction,\n ): Promise<void> {}\n\n /**\n * Called before message command is processed\n * @param message The message\n */\n public async onBeforeMessageCommand(\n ctx: CommandKitPluginRuntime,\n message: Message,\n ): Promise<void> {}\n\n /**\n * Called before command is executed. This method can execute the command itself.\n * @param source The source that triggered the command\n * @param command The command\n * @param execute The function that executes the command\n */\n public async executeCommand(\n ctx: CommandKitPluginRuntime,\n env: CommandKitEnvironment,\n source: Interaction | Message,\n command: PreparedAppCommandExecution,\n execute: () => Promise<any>,\n ): Promise<boolean> {\n return false;\n }\n\n /**\n * Called after events router is initialized\n * @param ctx The context\n */\n public async onEventsRouterInit(\n ctx: CommandKitPluginRuntime,\n ): Promise<void> {}\n\n /**\n * Called after commands router is initialized\n * @param ctx The context\n */\n public async onCommandsRouterInit(\n ctx: CommandKitPluginRuntime,\n ): Promise<void> {}\n\n /**\n * Called when HMR event is received\n * @param ctx The context\n * @param event The event\n */\n public async performHMR(\n ctx: CommandKitPluginRuntime,\n event: CommandKitHMREvent,\n ): Promise<void> {}\n\n /**\n * Called before command is loaded for registration. This method can be used to modify the command data before it is loaded.\n * @param ctx The context\n * @param commands The command that is being loaded. This is a CommandBuilderLike object which represents Discord's command\n */\n async prepareCommand(\n ctx: CommandKitPluginRuntime,\n commands: CommandBuilderLike,\n ): Promise<CommandBuilderLike | null> {\n return null;\n }\n\n /**\n * Called before command is registered to discord. This method can cancel the registration of the command and handle it manually.\n * @param ctx The context\n * @param data The command registration data\n */\n async onBeforeRegisterCommands(\n ctx: CommandKitPluginRuntime,\n event: PreRegisterCommandsEvent,\n ): Promise<void> {}\n\n /**\n * Called before global commands registration. This method can cancel the registration of the command and handle it manually.\n * This method is called after `onBeforeRegisterCommands` if that stage was not handled.\n * @param ctx The context\n * @param event The command registration data\n */\n async onBeforeRegisterGlobalCommands(\n ctx: CommandKitPluginRuntime,\n event: PreRegisterCommandsEvent,\n ): Promise<void> {}\n\n /**\n * Called before guild commands registration. This method can cancel the registration of the command and handle it manually.\n * This method is called before guilds of the command are resolved. It is called after `onBeforeRegisterCommands` if that stage was not handled.\n * @param ctx The context\n * @param event The command registration data\n */\n async onBeforePrepareGuildCommandsRegistration(\n ctx: CommandKitPluginRuntime,\n event: PreRegisterCommandsEvent,\n ): Promise<void> {}\n\n /**\n * Called before guild commands registration. This method can cancel the registration of the command and handle it manually.\n * This method is called after guilds of the command are resolved. It is called after `onBeforePrepareGuildCommandsRegistration` if that stage was not handled.\n * @param ctx The context\n * @param event The command registration data\n */\n async onBeforeRegisterGuildCommands(\n ctx: CommandKitPluginRuntime,\n event: PreRegisterCommandsEvent,\n ): Promise<void> {}\n\n /**\n * Called after command and all of its deferred functions are executed.\n * @param ctx The context\n * @param env The environment of the command. This environment contains the command execution data such as command context and more.\n */\n async onAfterCommand(\n ctx: CommandKitPluginRuntime,\n env: CommandKitEnvironment,\n ) {}\n\n /**\n * Called before emitting an event\n * @param ctx The context\n * @param event The event that is being emitted\n */\n public async willEmitEvent(\n ctx: CommandKitPluginRuntime,\n event: CommandKitEventDispatch,\n ) {}\n}\n\nexport function isRuntimePlugin(plugin: unknown): plugin is RuntimePlugin {\n return (\n plugin instanceof RuntimePlugin ||\n (isPlugin(plugin) && plugin.type === PluginType.Runtime)\n );\n}\n"],"mappings":";;;;;;;AAiBA,IAAsB,gBAAtB,cAEUA,0CAAyC;CACjD,AAAgB;CAChB,AAAgB,0BAAU,IAAI,IAAY;;;;CAK1C,MAAa,qBACX,KACe,CAAC;;;;CAKlB,MAAa,oBACX,KACe,CAAC;;;;CAKlB,MAAa,mBACX,KACe,CAAC;;;;CAKlB,MAAa,kBAAkB,KAA6C,CAAC;;;;CAK7E,MAAa,oBACX,KACe,CAAC;;;;CAKlB,MAAa,mBACX,KACe,CAAC;;;;;CAMlB,MAAa,oBACX,KACA,aACe,CAAC;;;;;CAMlB,MAAa,uBACX,KACA,SACe,CAAC;;;;;;;CAQlB,MAAa,eACX,KACA,KACA,QACA,SACA,SACkB;EAClB,OAAO;CACT;;;;;CAMA,MAAa,mBACX,KACe,CAAC;;;;;CAMlB,MAAa,qBACX,KACe,CAAC;;;;;;CAOlB,MAAa,WACX,KACA,OACe,CAAC;;;;;;CAOlB,MAAM,eACJ,KACA,UACoC;EACpC,OAAO;CACT;;;;;;CAOA,MAAM,yBACJ,KACA,OACe,CAAC;;;;;;;CAQlB,MAAM,+BACJ,KACA,OACe,CAAC;;;;;;;CAQlB,MAAM,yCACJ,KACA,OACe,CAAC;;;;;;;CAQlB,MAAM,8BACJ,KACA,OACe,CAAC;;;;;;CAOlB,MAAM,eACJ,KACA,KACA,CAAC;;;;;;CAOH,MAAa,cACX,KACA,OACA,CAAC;AACL;AAEA,SAAgB,gBAAgB,QAA0C;CACxE,OACE,kBAAkB,iBACjBC,sCAAS,MAAM,KAAK,OAAO;AAEhC"}
|
package/dist/plugins/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_commandkit = require("../commandkit-
|
|
2
|
+
const require_commandkit = require("../commandkit-Ck5bsJYv.js");
|
|
3
3
|
const require_plugins_CompilerPlugin = require("./CompilerPlugin.js");
|
|
4
4
|
const require_plugins_RuntimePlugin = require("./RuntimePlugin.js");
|
|
5
5
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_commandkit = require("../../commandkit-
|
|
2
|
+
const require_commandkit = require("../../commandkit-Ck5bsJYv.js");
|
|
3
3
|
|
|
4
4
|
exports.CommandKitPluginRuntime = require_commandkit.CommandKitPluginRuntime;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_commandkit = require("../../commandkit-
|
|
2
|
+
const require_commandkit = require("../../commandkit-Ck5bsJYv.js");
|
|
3
3
|
|
|
4
4
|
exports.CompilerPluginRuntime = require_commandkit.CompilerPluginRuntime;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_commandkit = require("../../../commandkit-
|
|
2
|
+
const require_commandkit = require("../../../commandkit-Ck5bsJYv.js");
|
|
3
3
|
|
|
4
4
|
exports.CommonDirectiveTransformer = require_commandkit.CommonDirectiveTransformer;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_commandkit = require("../../../commandkit-
|
|
2
|
+
const require_commandkit = require("../../../commandkit-Ck5bsJYv.js");
|
|
3
3
|
|
|
4
4
|
exports.MacroPlugin = require_commandkit.MacroPlugin;
|
package/dist/utils/colors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colors.js","names":["createColors"],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"colors.js","names":["createColors"],"sources":["../../src/utils/colors.ts"],"sourcesContent":["import { createColors } from 'picocolors';\n\nexport default createColors(true);\n"],"mappings":";;;;AAEA,yBAAeA,yBAAa,IAAI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":[],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../../src/utils/constants.ts"],"sourcesContent":["/**\n * The current working directory of the CommandKit instance.\n */\nexport const COMMANDKIT_CWD = process.env.COMMANDKIT_CWD || process.cwd();\n\n/**\n * Indicates whether CommandKit is running in development mode.\n */\nexport const COMMANDKIT_IS_DEV = process.env.COMMANDKIT_IS_DEV === 'true';\n\n/**\n * Indicates whether CommandKit is running in CLI thread.\n */\nexport const COMMANDKIT_IS_CLI = process.env.COMMANDKIT_IS_CLI === 'true';\n\n/**\n * Indicates whether CommandKit is running in test mode.\n */\nexport const COMMANDKIT_IS_TEST = process.env.COMMANDKIT_IS_TEST === 'true';\n\n/**\n * Indicates that CommandKit is running in a build-like environment.\n * @private\n * @internal\n */\nexport function isBuildLikeEnvironment() {\n const isCLI = process.env.COMMANDKIT_INTERNAL_IS_CLI_PROCESS === 'true';\n if (isCLI) return true;\n\n return process.env.COMMANDKIT_IS_BUILD === 'true';\n}\n\n/**\n * The current bootstrap mode of CommandKit.\n * This can be 'development' or 'production'.\n */\nexport const COMMANDKIT_BOOTSTRAP_MODE = (process.env\n .COMMANDKIT_BOOTSTRAP_MODE || 'development') as 'development' | 'production';\n\n/**\n * Types of Hot Module Replacement events\n */\nexport const HMREventType = {\n /**\n * HMR event for reloading commands.\n */\n ReloadCommands: 'reload-commands',\n /**\n * HMR event for reloading events.\n */\n ReloadEvents: 'reload-events',\n /**\n * HMR event for reloading unknown path, typically used by the plugins.\n */\n Unknown: 'unknown',\n} as const;\n\n/**\n * File system change types delivered through HMR messages.\n */\nexport const HMREventChangeType = {\n Add: 'add',\n Change: 'change',\n Unlink: 'unlink',\n UnlinkDir: 'unlinkDir',\n} as const;\n\n/**\n * The type for HMR events.\n */\nexport type HMREventType = (typeof HMREventType)[keyof typeof HMREventType];\n\n/**\n * The type for file change events in HMR payloads.\n */\nexport type HMREventChangeType =\n (typeof HMREventChangeType)[keyof typeof HMREventChangeType];\n"],"mappings":";;;;;AAGA,MAAa,iBAAiB,QAAQ,IAAI,kBAAkB,QAAQ,IAAI;;;;AAKxE,MAAa,oBAAoB,QAAQ,IAAI,sBAAsB;;;;AAKnE,MAAa,oBAAoB,QAAQ,IAAI,sBAAsB;;;;AAKnE,MAAa,qBAAqB,QAAQ,IAAI,uBAAuB;;;;;;AAOrE,SAAgB,yBAAyB;CAEvC,IADc,QAAQ,IAAI,uCAAuC,QACtD,OAAO;CAElB,OAAO,QAAQ,IAAI,wBAAwB;AAC7C;;;;;AAMA,MAAa,4BAA6B,QAAQ,IAC/C,6BAA6B;;;;AAKhC,MAAa,eAAe;;;;CAI1B,gBAAgB;;;;CAIhB,cAAc;;;;CAId,SAAS;AACX;;;;AAKA,MAAa,qBAAqB;CAChC,KAAK;CACL,QAAQ;CACR,QAAQ;CACR,WAAW;AACb"}
|
package/dist/utils/dev-hooks.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_commandkit = require("../commandkit-
|
|
2
|
+
const require_commandkit = require("../commandkit-Ck5bsJYv.js");
|
|
3
3
|
|
|
4
4
|
exports.registerDevHooks = require_commandkit.registerDevHooks;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-codes.js","names":[],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"error-codes.js","names":[],"sources":["../../src/utils/error-codes.ts"],"sourcesContent":["/**\n * The error codes used by CommandKit.\n */\nexport const CommandKitErrorCodes = {\n /**\n * Error code for exiting middleware.\n */\n StopMiddlewares: Symbol('kStopMiddlewares'),\n /**\n * Error code for forwarded commands.\n */\n ForwardedCommand: Symbol('kForwardedCommand'),\n /**\n * Error code for invalid command prefix.\n */\n InvalidCommandPrefix: Symbol('kInvalidCommandPrefix'),\n /**\n * Error code for plugin capture handle.\n */\n PluginCaptureHandle: Symbol('kPluginCaptureHandle'),\n /**\n * Error code for event interruption signal\n */\n StopEvents: Symbol('kStopEvents'),\n} as const;\n\n/**\n * The type for CommandKit errors.\n */\nexport type CommandKitError = Error & { code: symbol };\n\n/**\n * Creates a new CommandKit error with the specified code.\n * @param code The error code to assign to the error.\n * @returns A new CommandKit error instance.\n */\nexport function createCommandKitError(code: symbol): CommandKitError {\n const error = new Error() as CommandKitError;\n\n Reflect.set(error, 'code', code);\n\n return error;\n}\n\n/**\n * Checks if the given error is a CommandKit error.\n * @param error The error to check.\n * @returns True if the error is a CommandKit error, false otherwise.\n */\nexport function isCommandKitError(error: unknown): error is CommandKitError {\n if (!(error instanceof Error)) return false;\n const code = Reflect.get(error, 'code');\n\n for (const key in CommandKitErrorCodes) {\n if (CommandKitErrorCodes[key as keyof typeof CommandKitErrorCodes] === code)\n return true;\n }\n\n return false;\n}\n\n/**\n * Checks if the given error is of a specific CommandKit error type.\n * @param error The error to check.\n * @param code The error code or an array of error codes to check against.\n * @returns True if the error matches the specified code(s), false otherwise.\n */\nexport function isErrorType(error: unknown, code: symbol | symbol[]): boolean {\n if (!isCommandKitError(error)) return false;\n const errorCode = Reflect.get(error, 'code');\n\n if (!errorCode) return false;\n\n if (Array.isArray(code)) return code.includes(errorCode);\n\n return errorCode === code;\n}\n"],"mappings":";;;;;AAGA,MAAa,uBAAuB;;;;CAIlC,iBAAiB,OAAO,kBAAkB;;;;CAI1C,kBAAkB,OAAO,mBAAmB;;;;CAI5C,sBAAsB,OAAO,uBAAuB;;;;CAIpD,qBAAqB,OAAO,sBAAsB;;;;CAIlD,YAAY,OAAO,aAAa;AAClC;;;;;;AAYA,SAAgB,sBAAsB,MAA+B;CACnE,MAAM,wBAAQ,IAAI,MAAM;CAExB,QAAQ,IAAI,OAAO,QAAQ,IAAI;CAE/B,OAAO;AACT;;;;;;AAOA,SAAgB,kBAAkB,OAA0C;CAC1E,IAAI,EAAE,iBAAiB,QAAQ,OAAO;CACtC,MAAM,OAAO,QAAQ,IAAI,OAAO,MAAM;CAEtC,KAAK,MAAM,OAAO,sBAChB,IAAI,qBAAqB,SAA8C,MACrE,OAAO;CAGX,OAAO;AACT;;;;;;;AAQA,SAAgB,YAAY,OAAgB,MAAkC;CAC5E,IAAI,CAAC,kBAAkB,KAAK,GAAG,OAAO;CACtC,MAAM,YAAY,QAAQ,IAAI,OAAO,MAAM;CAE3C,IAAI,CAAC,WAAW,OAAO;CAEvB,IAAI,MAAM,QAAQ,IAAI,GAAG,OAAO,KAAK,SAAS,SAAS;CAEvD,OAAO,cAAc;AACvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-file-url.js","names":[],"sources":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"resolve-file-url.js","names":[],"sources":["../../src/utils/resolve-file-url.ts"],"sourcesContent":["import path from 'path';\n\n/**\n * Convert a local file path to a file URL.\n * @param filePath - The local file's path.\n * @param withTs - Whether to append a timestamp to the URL.\n * @returns - The converted file URL.\n */\nexport function toFileURL(filePath: string, withTs = false) {\n const resolvedPath = path.resolve(filePath);\n return `${'file://' + resolvedPath.replace(/\\\\\\\\|\\\\/g, '/')}${withTs ? `?ts=${Date.now()}` : ''}`;\n}\n"],"mappings":";;;;;;;;;;;;AAQA,SAAgB,UAAU,UAAkB,SAAS,OAAO;CAE1D,OAAO,GAAG,YADW,aAAK,QAAQ,QACD,CAAC,CAAC,QAAQ,YAAY,GAAG,IAAI,SAAS,OAAO,KAAK,IAAI,MAAM;AAC/F"}
|