commandkit 1.2.0-rc.7 → 1.2.0-rc.9

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.
Files changed (124) hide show
  1. package/dist/{CommandKitEventsChannel-B5vbINtP.js → CommandKitEventsChannel-BtRzr3Tz.js} +1 -1
  2. package/dist/{CommandKitEventsChannel-B5vbINtP.js.map → CommandKitEventsChannel-BtRzr3Tz.js.map} +1 -1
  3. package/dist/{CommandsRouter-DZAeB2v_.js → CommandsRouter-Cgcy6cK9.js} +1 -1
  4. package/dist/{CommandsRouter-DZAeB2v_.js.map → CommandsRouter-Cgcy6cK9.js.map} +1 -1
  5. package/dist/{EventWorkerContext-xgEc2N2T.d.ts → EventWorkerContext-BMk7IXpC.d.ts} +2 -2
  6. package/dist/{EventsRouter-Dzpm7ubq.js → EventsRouter-3Gygh-km.js} +1 -1
  7. package/dist/{EventsRouter-Dzpm7ubq.js.map → EventsRouter-3Gygh-km.js.map} +1 -1
  8. package/dist/analytics/analytics-engine.d.ts +1 -1
  9. package/dist/analytics/analytics-engine.js +8 -7
  10. package/dist/analytics/analytics-provider.d.ts +1 -1
  11. package/dist/analytics/utils.js +8 -7
  12. package/dist/{analytics-engine-6_M8tCeD.d.ts → analytics-engine-B7JNRnEN.d.ts} +8 -2
  13. package/dist/app/commands/AppCommandRunner.d.ts +1 -1
  14. package/dist/app/commands/AppCommandRunner.js +8 -7
  15. package/dist/app/commands/Context.d.ts +1 -1
  16. package/dist/app/commands/Context.js +8 -7
  17. package/dist/app/commands/helpers.js +1 -1
  18. package/dist/app/events/EventWorkerContext.d.ts +2 -2
  19. package/dist/app/handlers/AppCommandHandler.d.ts +1 -1
  20. package/dist/app/handlers/AppCommandHandler.js +8 -7
  21. package/dist/app/handlers/AppEventsHandler.d.ts +1 -1
  22. package/dist/app/handlers/AppEventsHandler.js +8 -7
  23. package/dist/app/index.d.ts +1 -1
  24. package/dist/app/index.js +8 -8
  25. package/dist/app/middlewares/permissions.d.ts +1 -1
  26. package/dist/app/middlewares/permissions.js +8 -7
  27. package/dist/app/register/CommandRegistrar.d.ts +1 -1
  28. package/dist/app/register/CommandRegistrar.js +8 -7
  29. package/dist/app/router/CommandsRouter.js +1 -1
  30. package/dist/app/router/EventsRouter.js +1 -1
  31. package/dist/app/router/index.js +3 -3
  32. package/dist/{app-process-u2DXakNv.js → app-process-DoG6Spkf.js} +2 -2
  33. package/dist/{app-process-u2DXakNv.js.map → app-process-DoG6Spkf.js.map} +1 -1
  34. package/dist/{build-e6PlVFfe.js → build-C9ltqPmn.js} +4 -4
  35. package/dist/{build-e6PlVFfe.js.map → build-C9ltqPmn.js.map} +1 -1
  36. package/dist/cli/app-process.js +2 -2
  37. package/dist/cli/build.d.ts +1 -1
  38. package/dist/cli/build.js +10 -9
  39. package/dist/cli/common.d.ts +1 -1
  40. package/dist/cli/common.js +1 -1
  41. package/dist/cli/development.js +11 -10
  42. package/dist/cli/development.js.map +1 -1
  43. package/dist/cli/generators.js +1 -1
  44. package/dist/cli/information.js +1 -1
  45. package/dist/cli/init.js +9 -8
  46. package/dist/cli/production.js +11 -10
  47. package/dist/cli/production.js.map +1 -1
  48. package/dist/cli/type-checker.js +2 -2
  49. package/dist/{commandkit-Dy4V-Rk2.js → commandkit-Bm0gLN8i.js} +46 -29
  50. package/dist/{commandkit-Dy4V-Rk2.js.map → commandkit-Bm0gLN8i.js.map} +1 -1
  51. package/dist/commandkit.d.ts +1 -1
  52. package/dist/commandkit.js +8 -7
  53. package/dist/{common-DVM_onKu.js → common-Dxr9-XPa.js} +1 -1
  54. package/dist/{common-DVM_onKu.js.map → common-Dxr9-XPa.js.map} +1 -1
  55. package/dist/components/index.js +8 -7
  56. package/dist/components/v1/button/Button.js +8 -7
  57. package/dist/components/v1/button/ButtonKit.js +8 -7
  58. package/dist/components/v1/modal/Modal.js +8 -7
  59. package/dist/components/v1/modal/ModalKit.js +8 -7
  60. package/dist/components/v1/select-menu/ChannelSelectMenuKit.js +8 -7
  61. package/dist/components/v1/select-menu/MentionableSelectMenuKit.js +8 -7
  62. package/dist/components/v1/select-menu/RoleSelectMenuKit.js +8 -7
  63. package/dist/components/v1/select-menu/SelectMenu.js +8 -7
  64. package/dist/components/v1/select-menu/StringSelectMenuKit.js +8 -7
  65. package/dist/components/v1/select-menu/UserSelectMenuKit.js +8 -7
  66. package/dist/config/config.d.ts +2 -2
  67. package/dist/config/config.js +8 -7
  68. package/dist/config/default.d.ts +1 -1
  69. package/dist/config/default.js +8 -7
  70. package/dist/config/loader.d.ts +1 -1
  71. package/dist/config/loader.js +8 -7
  72. package/dist/config/types.d.ts +1 -1
  73. package/dist/config/utils.d.ts +1 -1
  74. package/dist/{config-nD7V_D7G.d.ts → config-BhVxyjmZ.d.ts} +2 -2
  75. package/dist/context/async-context.d.ts +1 -1
  76. package/dist/context/async-context.js +8 -7
  77. package/dist/context/environment.d.ts +1 -1
  78. package/dist/context/environment.js +8 -7
  79. package/dist/events/CommandKitEventsChannel.d.ts +1 -1
  80. package/dist/events/CommandKitEventsChannel.js +1 -1
  81. package/dist/{feature-flags-3TQSPAVn.js → feature-flags-nZJB7-e5.js} +2 -2
  82. package/dist/{feature-flags-3TQSPAVn.js.map → feature-flags-nZJB7-e5.js.map} +1 -1
  83. package/dist/flags/FlagProvider.d.ts +1 -1
  84. package/dist/flags/feature-flags.d.ts +1 -1
  85. package/dist/flags/feature-flags.js +9 -8
  86. package/dist/flags/store.d.ts +1 -1
  87. package/dist/flags/store.js +1 -1
  88. package/dist/{helpers-CiuN7y5B.js → helpers-BSwwrKJW.js} +1 -1
  89. package/dist/{helpers-CiuN7y5B.js.map → helpers-BSwwrKJW.js.map} +1 -1
  90. package/dist/index.d.ts +3 -3
  91. package/dist/index.js +11 -11
  92. package/dist/{init-Bo01I_h_.js → init-Cy_bcUt4.js} +3 -3
  93. package/dist/{init-Bo01I_h_.js.map → init-Cy_bcUt4.js.map} +1 -1
  94. package/dist/logger/DefaultLogger.js +8 -7
  95. package/dist/logger/Logger.js +8 -7
  96. package/dist/plugins/CompilerPlugin.d.ts +1 -1
  97. package/dist/plugins/PluginCommon.d.ts +1 -1
  98. package/dist/plugins/RuntimePlugin.d.ts +1 -1
  99. package/dist/plugins/index.d.ts +1 -1
  100. package/dist/plugins/index.js +8 -7
  101. package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.d.ts +1 -1
  102. package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.js +8 -7
  103. package/dist/plugins/plugin-runtime/CompilerPluginRuntime.d.ts +1 -1
  104. package/dist/plugins/plugin-runtime/CompilerPluginRuntime.js +8 -7
  105. package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.d.ts +1 -1
  106. package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.js +8 -7
  107. package/dist/plugins/plugin-runtime/builtin/MacroPlugin.d.ts +1 -1
  108. package/dist/plugins/plugin-runtime/builtin/MacroPlugin.js +8 -7
  109. package/dist/plugins/plugin-runtime/runtime.d.ts +1 -1
  110. package/dist/plugins/types.d.ts +1 -1
  111. package/dist/{store-Hcgz7DSt.js → store-CM6pWVZh.js} +1 -1
  112. package/dist/{store-Hcgz7DSt.js.map → store-CM6pWVZh.js.map} +1 -1
  113. package/dist/{type-checker-M1NIIoWL.js → type-checker-DR7RZFs5.js} +2 -2
  114. package/dist/{type-checker-M1NIIoWL.js.map → type-checker-DR7RZFs5.js.map} +1 -1
  115. package/dist/types.d.ts +1 -1
  116. package/dist/utils/dev-hooks.d.ts +1 -1
  117. package/dist/utils/dev-hooks.js +8 -7
  118. package/dist/utils/utilities.js +8 -7
  119. package/dist/{version-CphQqt4J.js → version-DRSQMx0w.js} +2 -2
  120. package/dist/{version-CphQqt4J.js.map → version-DRSQMx0w.js.map} +1 -1
  121. package/dist/version.js +1 -1
  122. package/hooks.d.ts +3 -1
  123. package/package.json +2 -2
  124. /package/dist/{router-DHnFRADH.js → router-Dn35v30f.js} +0 -0
@@ -1,7 +1,7 @@
1
1
  require('../colors-DL3ucTiT.js');
2
2
  require('../ActionRow-CbdGFWMT.js');
3
3
  require('../error-codes-Ds0bnPvT.js');
4
- const require_commandkit = require('../commandkit-Dy4V-Rk2.js');
4
+ const require_commandkit = require('../commandkit-Bm0gLN8i.js');
5
5
  require('../common-CcfjYnPG.js');
6
6
  require('../common-vnMIelAE.js');
7
7
  require('../container-C6GtfAPW.js');
@@ -27,12 +27,13 @@ require('../constants-BOOGN85p.js');
27
27
  require('../EventWorkerContext-Dq29tieI.js');
28
28
  require('../signals-ChFMD7mB.js');
29
29
  require('../MessageCommandParser-CEuO6Ex3.js');
30
- require('../CommandsRouter-DZAeB2v_.js');
31
- require('../EventsRouter-Dzpm7ubq.js');
32
- require('../router-DHnFRADH.js');
33
- require('../common-DVM_onKu.js');
34
- require('../CommandKitEventsChannel-B5vbINtP.js');
35
- require('../store-Hcgz7DSt.js');
30
+ require('../helpers-BSwwrKJW.js');
31
+ require('../CommandsRouter-Cgcy6cK9.js');
32
+ require('../EventsRouter-3Gygh-km.js');
33
+ require('../router-Dn35v30f.js');
34
+ require('../common-Dxr9-XPa.js');
35
+ require('../CommandKitEventsChannel-BtRzr3Tz.js');
36
+ require('../store-CM6pWVZh.js');
36
37
 
37
38
  exports.CommandKitEnvironment = require_commandkit.CommandKitEnvironment;
38
39
  exports.CommandKitEnvironmentType = require_commandkit.CommandKitEnvironmentType;
@@ -1,4 +1,4 @@
1
- import { CommandKitEventsChannel, ListenerFunction } from "../analytics-engine-6_M8tCeD.js";
1
+ import { CommandKitEventsChannel, ListenerFunction } from "../analytics-engine-B7JNRnEN.js";
2
2
  import "../EventInterceptor-x-R2qshQ.js";
3
3
  import "../ButtonKit-C7r7RPNf.js";
4
4
  import "../ModalKit-Btz58KYn.js";
@@ -1,3 +1,3 @@
1
- const require_CommandKitEventsChannel = require('../CommandKitEventsChannel-B5vbINtP.js');
1
+ const require_CommandKitEventsChannel = require('../CommandKitEventsChannel-BtRzr3Tz.js');
2
2
 
3
3
  exports.CommandKitEventsChannel = require_CommandKitEventsChannel.CommandKitEventsChannel;
@@ -1,4 +1,4 @@
1
- const require_commandkit = require('./commandkit-Dy4V-Rk2.js');
1
+ const require_commandkit = require('./commandkit-Bm0gLN8i.js');
2
2
  const require_constants = require('./constants-BOOGN85p.js');
3
3
  const require_EventWorkerContext = require('./EventWorkerContext-Dq29tieI.js');
4
4
 
@@ -157,4 +157,4 @@ Object.defineProperty(exports, 'setFlagProvider', {
157
157
  return setFlagProvider;
158
158
  }
159
159
  });
160
- //# sourceMappingURL=feature-flags-3TQSPAVn.js.map
160
+ //# sourceMappingURL=feature-flags-nZJB7-e5.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"feature-flags-3TQSPAVn.js","names":[],"sources":["../src/flags/feature-flags.ts"],"sourcesContent":["import { getCommandKit, getContext } from '../context/async-context';\nimport { eventWorkerContext } from '../app/events/EventWorkerContext';\nimport { ParsedEvent } from '../app/router';\nimport { CommandKit } from '../commandkit';\nimport {\n AutocompleteInteraction,\n ChatInputCommandInteraction,\n Client,\n ClientEvents,\n ContextMenuCommandInteraction,\n Guild,\n Message,\n TextBasedChannel,\n} from 'discord.js';\nimport { LoadedCommand } from '../app';\nimport { defer, JsonSerialize } from '../utils/utilities';\nimport { AnalyticsEvents } from '../analytics/constants';\nimport { FlagProvider, FlagConfiguration } from './FlagProvider';\nimport { Logger } from '../logger/Logger';\n\n// Global flag provider\nlet flagProvider: FlagProvider | null = null;\n\n/**\n * Set the global flag provider for all feature flags\n */\nexport function setFlagProvider(provider: FlagProvider): void {\n flagProvider = provider;\n}\n\n/**\n * @private\n */\nexport type MaybePromise<T> = T | Promise<T>;\n\n/**\n * Function type for identifying entities in the context of feature flags.\n * This function should return an object representing the entity that will be used\n * to evaluate the feature flag.\n * It can be synchronous or asynchronous.\n */\nexport type IdentifyFunction<R> = (\n context: EvaluationContext,\n) => MaybePromise<R>;\n\n/**\n * Function type for deciding the outcome of a feature flag based on the provided entities.\n * This function receives an object containing the entities and optionally the provider configuration,\n * and should return the result of the decision.\n * It can be synchronous or asynchronous.\n */\nexport type DecideFunction<E, R> = (data: {\n entities: E;\n provider?: FlagConfiguration | null;\n}) => MaybePromise<R>;\n\n/**\n * Definition for a feature flag, including its key, description, identify function,\n * and decide function.\n * The identify function is used to determine the entities that will be evaluated\n * against the feature flag, while the decide function contains the logic for\n * determining the outcome of the flag based on those entities.\n */\nexport interface FeatureFlagDefinition<R, Entity> {\n /**\n * Unique key for the feature flag.\n * Should be a string that identifies the flag.\n */\n key: string;\n /**\n * Optional description of the feature flag.\n * This can be used for documentation or debugging purposes.\n */\n description?: string;\n /**\n * Optional flag to enable integration with an external flag provider.\n * If true, the flag will use the global flag provider to determine its state.\n * Default: false\n */\n identify?: IdentifyFunction<Entity>;\n /**\n * Function to decide the outcome of the feature flag.\n * This function receives the identified entities and should return the result of the decision.\n */\n decide: DecideFunction<Entity, R>;\n /**\n * Whether to disable analytics tracking for this flag.\n * Default: false\n */\n disableAnalytics?: boolean;\n}\n\n/**\n * Context for evaluating command flags in CommandKit.\n */\nexport interface CommandFlagContext {\n /**\n * The Discord client instance.\n * This is the main entry point for interacting with the Discord API.\n */\n client: Client<true>;\n /**\n * The CommandKit instance, which provides access to the command framework.\n * This includes commands, events, and other features of CommandKit.\n */\n commandkit: CommandKit;\n /**\n * The command context, which includes information about the command being executed.\n * This can include the interaction, message, guild, channel, and the loaded command.\n */\n command: {\n /**\n * The interaction object if the command was invoked via an interaction.\n * This can be a ChatInputCommandInteraction, AutocompleteInteraction, or ContextMenuCommandInteraction.\n */\n interaction?:\n | ChatInputCommandInteraction\n | AutocompleteInteraction\n | ContextMenuCommandInteraction;\n /**\n * The message object if the command was invoked via a message.\n */\n message?: Message;\n /**\n * The guild where the command was invoked, if applicable.\n * This will be null for commands invoked in DMs.\n */\n guild: Guild | null;\n /**\n * The channel where the command was invoked.\n * This can be a text channel, DM channel, or any other type of text-based channel.\n */\n channel: TextBasedChannel | null;\n /**\n * The loaded command instance that is being executed.\n * This contains the command's metadata and logic.\n */\n command: LoadedCommand;\n };\n /**\n * The event context is null for command flags, as they are not tied to a specific event.\n * This is used to differentiate between command and event flags.\n */\n event: null;\n}\n\n/**\n * Context for evaluating event flags in CommandKit.\n */\nexport interface EventFlagContext {\n /**\n * The Discord client instance.\n * This is the main entry point for interacting with the Discord API.\n */\n client: Client<true>;\n /**\n * The CommandKit instance, which provides access to the command framework.\n * This includes commands, events, and other features of CommandKit.\n */\n commandkit: CommandKit;\n /**\n * The event context, which includes information about the event being processed.\n * This can include the parsed event data, the event name, and the namespace if applicable.\n */\n event: {\n /**\n * The parsed event data, which contains the raw data from the event.\n * This can include information like user IDs, channel IDs, and other relevant data.\n */\n data: ParsedEvent;\n /**\n * The name of the event being processed.\n * This is the string identifier for the event, such as 'messageCreate' or 'guildMemberAdd'.\n */\n event: string;\n /**\n * The namespace of the event, if applicable.\n * This can be used to group related events or commands together.\n * It is null if the event does not belong to a specific namespace.\n */\n namespace: string | null;\n /**\n * The arguments passed to the event handler.\n * This is an array of arguments that were passed when the event was triggered.\n * It can be used to access specific data related to the event.\n */\n arguments: any[];\n /**\n * A function to retrieve the arguments for a specific event type.\n * This allows for type-safe access to the arguments based on the event name.\n * @param event - The name of the event to retrieve arguments for.\n */\n argumentsAs<E extends keyof ClientEvents>(event: E): ClientEvents[E];\n };\n /**\n * The command context is null for event flags, as they are not tied to a specific command.\n * This is used to differentiate between command and event flags.\n */\n command: null;\n}\n\n/**\n * Combined context type for feature flag evaluation.\n */\nexport type EvaluationContext = CommandFlagContext | EventFlagContext;\n\n/**\n * Function type for custom evaluation of feature flags.\n * This function can be used to provide a custom evaluation context for the flag.\n * It should return an object representing the entities to be evaluated.\n */\nexport type CustomEvaluationFunction<E> = () => MaybePromise<E>;\n\n/**\n * Context for custom evaluation of feature flags.\n * This allows for more flexible evaluation based on custom logic or external data.\n * The identify function can be a direct object or a function that returns the entities.\n */\nexport type CustomEvaluationContext<E> = {\n /**\n * Optional function to identify the entities for evaluation.\n * This can be a function that returns the entities based on the current context.\n */\n identify: E | CustomEvaluationFunction<E>;\n};\n\nexport interface FlagRunner<E, R> {\n /**\n * Execute the feature flag evaluation with the provided entities.\n * This method will run the identify and decide functions to determine the flag's outcome.\n * @param res - Optional entities to use for evaluation. If not provided, it will call the identify function.\n * @returns A promise that resolves to the result of the feature flag evaluation.\n */\n (): Promise<R>;\n /**\n * Run the feature flag evaluation with a custom context.\n * This allows for more flexible evaluation based on custom logic or external data.\n * @param context - The custom evaluation context containing the identify function or object.\n * @returns A promise that resolves to the result of the feature flag evaluation.\n */\n run(context: CustomEvaluationContext<E>): Promise<R>;\n}\n\n/**\n * Class representing a feature flag in CommandKit.\n */\nexport class FeatureFlag<R, T> {\n private commandkit: CommandKit;\n\n /**\n * Create a new feature flag.\n * @param options - The options for the feature flag.\n */\n public constructor(public readonly options: FeatureFlagDefinition<R, T>) {\n this.commandkit = getCommandKit(true);\n const FlagStore = this.commandkit.flags;\n\n if (FlagStore.has(options.key)) {\n throw new Error(`Feature flag with key \"${options.key}\" already exists.`);\n }\n\n FlagStore.set(options.key, this);\n }\n\n private getContext(): EvaluationContext {\n const env = getContext();\n\n if (env?.context) {\n const {\n client,\n commandkit,\n interaction,\n message,\n guild,\n channel,\n command,\n } = env.context;\n\n return {\n client: client as Client<true>,\n commandkit,\n command: {\n interaction,\n message,\n guild,\n channel,\n command,\n },\n event: null,\n };\n }\n\n const eventCtx = eventWorkerContext.getStore();\n\n if (eventCtx) {\n const { commandkit, data, event, namespace } = eventCtx;\n\n return {\n client: commandkit.client as Client<true>,\n commandkit,\n event: {\n data,\n event,\n namespace,\n arguments: eventCtx.arguments,\n argumentsAs: (eventName) => {\n const args = eventCtx.arguments as ClientEvents[typeof eventName];\n return args;\n },\n },\n command: null,\n };\n }\n\n throw new Error(\n 'Could not determine the execution context. Feature flags may only be used inside a command or event.',\n );\n }\n\n /**\n * Execute the feature flag evaluation.\n * @param res - Optional entities to use for evaluation. If not provided, it will call the identify function.\n * @returns A promise that resolves to the result of the feature flag evaluation.\n */\n public async execute(res?: T): Promise<R> {\n const { decide, identify, disableAnalytics } = this.options;\n\n const identificationStart = performance.now();\n const entities =\n res ??\n (await (async () => {\n const ctx = this.getContext();\n return (await identify?.(ctx)) ?? ({} as T);\n })());\n const identificationTime = performance.now() - identificationStart;\n\n // Get provider configuration if global provider is available\n let providerConfig: FlagConfiguration | null = null;\n if (flagProvider) {\n try {\n providerConfig = await flagProvider.getFlag(this.options.key, entities);\n\n // If provider says flag is disabled, return early with default behavior\n if (providerConfig && !providerConfig.enabled) {\n // For boolean flags, return false; for others, let decide function handle it\n if (typeof decide === 'function') {\n const decisionResult = await decide({\n entities,\n provider: providerConfig,\n });\n return decisionResult as R;\n }\n }\n } catch (error) {\n Logger.error`Error fetching flag provider configuration for \"${this.options.key}\": ${error}`;\n // continue with local decision if provider fails\n }\n }\n\n const decisionStart = performance.now();\n const decisionResult = await decide({\n entities,\n provider: providerConfig,\n });\n const decisionTime = performance.now() - decisionStart;\n\n // Skip analytics if disabled\n if (!disableAnalytics) {\n defer(async () => {\n await this.commandkit.analytics.track({\n name: AnalyticsEvents.FEATURE_FLAG_METRICS,\n data: {\n flag: this.options.key,\n identificationTime: identificationTime.toFixed(2),\n decisionTime: decisionTime.toFixed(2),\n usedProvider: flagProvider !== null,\n providerEnabled: providerConfig?.enabled ?? null,\n },\n });\n });\n\n defer(async () => {\n await this.commandkit.analytics.track({\n name: AnalyticsEvents.FEATURE_FLAG_DECISION,\n id:\n entities &&\n typeof entities === 'object' &&\n 'id' in entities &&\n typeof entities.id === 'string'\n ? entities.id\n : undefined,\n data: {\n flag: this.options.key,\n decision: JsonSerialize(decisionResult, 'unknown'),\n providerUsed: flagProvider !== null,\n },\n });\n });\n }\n\n return decisionResult as R;\n }\n}\n\n/**\n * Create a new feature flag.\n * @param options - The options for the feature flag.\n * @returns A new instance of the FeatureFlag class.\n */\nexport function flag<Returns = boolean, Entity = Record<any, any>>(\n options: FeatureFlagDefinition<Returns, Entity>,\n): FlagRunner<Entity, Returns> {\n const flag = new FeatureFlag<Returns, Entity>(options);\n const runner = flag.execute.bind(flag, undefined) as FlagRunner<\n Entity,\n Returns\n >;\n\n runner.run = async function (ctx) {\n if (!ctx?.identify) {\n throw new Error(\n 'Custom evaluation context must have an identify function or object.',\n );\n }\n\n const context = (\n typeof ctx === 'function'\n ? await (ctx as CustomEvaluationFunction<Entity>)()\n : ctx\n ) as Entity;\n\n const decisionResult = await flag.execute(context);\n\n return decisionResult;\n };\n\n return runner;\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"feature-flags-nZJB7-e5.js","names":[],"sources":["../src/flags/feature-flags.ts"],"sourcesContent":["import { getCommandKit, getContext } from '../context/async-context';\nimport { eventWorkerContext } from '../app/events/EventWorkerContext';\nimport { ParsedEvent } from '../app/router';\nimport { CommandKit } from '../commandkit';\nimport {\n AutocompleteInteraction,\n ChatInputCommandInteraction,\n Client,\n ClientEvents,\n ContextMenuCommandInteraction,\n Guild,\n Message,\n TextBasedChannel,\n} from 'discord.js';\nimport { LoadedCommand } from '../app';\nimport { defer, JsonSerialize } from '../utils/utilities';\nimport { AnalyticsEvents } from '../analytics/constants';\nimport { FlagProvider, FlagConfiguration } from './FlagProvider';\nimport { Logger } from '../logger/Logger';\n\n// Global flag provider\nlet flagProvider: FlagProvider | null = null;\n\n/**\n * Set the global flag provider for all feature flags\n */\nexport function setFlagProvider(provider: FlagProvider): void {\n flagProvider = provider;\n}\n\n/**\n * @private\n */\nexport type MaybePromise<T> = T | Promise<T>;\n\n/**\n * Function type for identifying entities in the context of feature flags.\n * This function should return an object representing the entity that will be used\n * to evaluate the feature flag.\n * It can be synchronous or asynchronous.\n */\nexport type IdentifyFunction<R> = (\n context: EvaluationContext,\n) => MaybePromise<R>;\n\n/**\n * Function type for deciding the outcome of a feature flag based on the provided entities.\n * This function receives an object containing the entities and optionally the provider configuration,\n * and should return the result of the decision.\n * It can be synchronous or asynchronous.\n */\nexport type DecideFunction<E, R> = (data: {\n entities: E;\n provider?: FlagConfiguration | null;\n}) => MaybePromise<R>;\n\n/**\n * Definition for a feature flag, including its key, description, identify function,\n * and decide function.\n * The identify function is used to determine the entities that will be evaluated\n * against the feature flag, while the decide function contains the logic for\n * determining the outcome of the flag based on those entities.\n */\nexport interface FeatureFlagDefinition<R, Entity> {\n /**\n * Unique key for the feature flag.\n * Should be a string that identifies the flag.\n */\n key: string;\n /**\n * Optional description of the feature flag.\n * This can be used for documentation or debugging purposes.\n */\n description?: string;\n /**\n * Optional flag to enable integration with an external flag provider.\n * If true, the flag will use the global flag provider to determine its state.\n * Default: false\n */\n identify?: IdentifyFunction<Entity>;\n /**\n * Function to decide the outcome of the feature flag.\n * This function receives the identified entities and should return the result of the decision.\n */\n decide: DecideFunction<Entity, R>;\n /**\n * Whether to disable analytics tracking for this flag.\n * Default: false\n */\n disableAnalytics?: boolean;\n}\n\n/**\n * Context for evaluating command flags in CommandKit.\n */\nexport interface CommandFlagContext {\n /**\n * The Discord client instance.\n * This is the main entry point for interacting with the Discord API.\n */\n client: Client<true>;\n /**\n * The CommandKit instance, which provides access to the command framework.\n * This includes commands, events, and other features of CommandKit.\n */\n commandkit: CommandKit;\n /**\n * The command context, which includes information about the command being executed.\n * This can include the interaction, message, guild, channel, and the loaded command.\n */\n command: {\n /**\n * The interaction object if the command was invoked via an interaction.\n * This can be a ChatInputCommandInteraction, AutocompleteInteraction, or ContextMenuCommandInteraction.\n */\n interaction?:\n | ChatInputCommandInteraction\n | AutocompleteInteraction\n | ContextMenuCommandInteraction;\n /**\n * The message object if the command was invoked via a message.\n */\n message?: Message;\n /**\n * The guild where the command was invoked, if applicable.\n * This will be null for commands invoked in DMs.\n */\n guild: Guild | null;\n /**\n * The channel where the command was invoked.\n * This can be a text channel, DM channel, or any other type of text-based channel.\n */\n channel: TextBasedChannel | null;\n /**\n * The loaded command instance that is being executed.\n * This contains the command's metadata and logic.\n */\n command: LoadedCommand;\n };\n /**\n * The event context is null for command flags, as they are not tied to a specific event.\n * This is used to differentiate between command and event flags.\n */\n event: null;\n}\n\n/**\n * Context for evaluating event flags in CommandKit.\n */\nexport interface EventFlagContext {\n /**\n * The Discord client instance.\n * This is the main entry point for interacting with the Discord API.\n */\n client: Client<true>;\n /**\n * The CommandKit instance, which provides access to the command framework.\n * This includes commands, events, and other features of CommandKit.\n */\n commandkit: CommandKit;\n /**\n * The event context, which includes information about the event being processed.\n * This can include the parsed event data, the event name, and the namespace if applicable.\n */\n event: {\n /**\n * The parsed event data, which contains the raw data from the event.\n * This can include information like user IDs, channel IDs, and other relevant data.\n */\n data: ParsedEvent;\n /**\n * The name of the event being processed.\n * This is the string identifier for the event, such as 'messageCreate' or 'guildMemberAdd'.\n */\n event: string;\n /**\n * The namespace of the event, if applicable.\n * This can be used to group related events or commands together.\n * It is null if the event does not belong to a specific namespace.\n */\n namespace: string | null;\n /**\n * The arguments passed to the event handler.\n * This is an array of arguments that were passed when the event was triggered.\n * It can be used to access specific data related to the event.\n */\n arguments: any[];\n /**\n * A function to retrieve the arguments for a specific event type.\n * This allows for type-safe access to the arguments based on the event name.\n * @param event - The name of the event to retrieve arguments for.\n */\n argumentsAs<E extends keyof ClientEvents>(event: E): ClientEvents[E];\n };\n /**\n * The command context is null for event flags, as they are not tied to a specific command.\n * This is used to differentiate between command and event flags.\n */\n command: null;\n}\n\n/**\n * Combined context type for feature flag evaluation.\n */\nexport type EvaluationContext = CommandFlagContext | EventFlagContext;\n\n/**\n * Function type for custom evaluation of feature flags.\n * This function can be used to provide a custom evaluation context for the flag.\n * It should return an object representing the entities to be evaluated.\n */\nexport type CustomEvaluationFunction<E> = () => MaybePromise<E>;\n\n/**\n * Context for custom evaluation of feature flags.\n * This allows for more flexible evaluation based on custom logic or external data.\n * The identify function can be a direct object or a function that returns the entities.\n */\nexport type CustomEvaluationContext<E> = {\n /**\n * Optional function to identify the entities for evaluation.\n * This can be a function that returns the entities based on the current context.\n */\n identify: E | CustomEvaluationFunction<E>;\n};\n\nexport interface FlagRunner<E, R> {\n /**\n * Execute the feature flag evaluation with the provided entities.\n * This method will run the identify and decide functions to determine the flag's outcome.\n * @param res - Optional entities to use for evaluation. If not provided, it will call the identify function.\n * @returns A promise that resolves to the result of the feature flag evaluation.\n */\n (): Promise<R>;\n /**\n * Run the feature flag evaluation with a custom context.\n * This allows for more flexible evaluation based on custom logic or external data.\n * @param context - The custom evaluation context containing the identify function or object.\n * @returns A promise that resolves to the result of the feature flag evaluation.\n */\n run(context: CustomEvaluationContext<E>): Promise<R>;\n}\n\n/**\n * Class representing a feature flag in CommandKit.\n */\nexport class FeatureFlag<R, T> {\n private commandkit: CommandKit;\n\n /**\n * Create a new feature flag.\n * @param options - The options for the feature flag.\n */\n public constructor(public readonly options: FeatureFlagDefinition<R, T>) {\n this.commandkit = getCommandKit(true);\n const FlagStore = this.commandkit.flags;\n\n if (FlagStore.has(options.key)) {\n throw new Error(`Feature flag with key \"${options.key}\" already exists.`);\n }\n\n FlagStore.set(options.key, this);\n }\n\n private getContext(): EvaluationContext {\n const env = getContext();\n\n if (env?.context) {\n const {\n client,\n commandkit,\n interaction,\n message,\n guild,\n channel,\n command,\n } = env.context;\n\n return {\n client: client as Client<true>,\n commandkit,\n command: {\n interaction,\n message,\n guild,\n channel,\n command,\n },\n event: null,\n };\n }\n\n const eventCtx = eventWorkerContext.getStore();\n\n if (eventCtx) {\n const { commandkit, data, event, namespace } = eventCtx;\n\n return {\n client: commandkit.client as Client<true>,\n commandkit,\n event: {\n data,\n event,\n namespace,\n arguments: eventCtx.arguments,\n argumentsAs: (eventName) => {\n const args = eventCtx.arguments as ClientEvents[typeof eventName];\n return args;\n },\n },\n command: null,\n };\n }\n\n throw new Error(\n 'Could not determine the execution context. Feature flags may only be used inside a command or event.',\n );\n }\n\n /**\n * Execute the feature flag evaluation.\n * @param res - Optional entities to use for evaluation. If not provided, it will call the identify function.\n * @returns A promise that resolves to the result of the feature flag evaluation.\n */\n public async execute(res?: T): Promise<R> {\n const { decide, identify, disableAnalytics } = this.options;\n\n const identificationStart = performance.now();\n const entities =\n res ??\n (await (async () => {\n const ctx = this.getContext();\n return (await identify?.(ctx)) ?? ({} as T);\n })());\n const identificationTime = performance.now() - identificationStart;\n\n // Get provider configuration if global provider is available\n let providerConfig: FlagConfiguration | null = null;\n if (flagProvider) {\n try {\n providerConfig = await flagProvider.getFlag(this.options.key, entities);\n\n // If provider says flag is disabled, return early with default behavior\n if (providerConfig && !providerConfig.enabled) {\n // For boolean flags, return false; for others, let decide function handle it\n if (typeof decide === 'function') {\n const decisionResult = await decide({\n entities,\n provider: providerConfig,\n });\n return decisionResult as R;\n }\n }\n } catch (error) {\n Logger.error`Error fetching flag provider configuration for \"${this.options.key}\": ${error}`;\n // continue with local decision if provider fails\n }\n }\n\n const decisionStart = performance.now();\n const decisionResult = await decide({\n entities,\n provider: providerConfig,\n });\n const decisionTime = performance.now() - decisionStart;\n\n // Skip analytics if disabled\n if (!disableAnalytics) {\n defer(async () => {\n await this.commandkit.analytics.track({\n name: AnalyticsEvents.FEATURE_FLAG_METRICS,\n data: {\n flag: this.options.key,\n identificationTime: identificationTime.toFixed(2),\n decisionTime: decisionTime.toFixed(2),\n usedProvider: flagProvider !== null,\n providerEnabled: providerConfig?.enabled ?? null,\n },\n });\n });\n\n defer(async () => {\n await this.commandkit.analytics.track({\n name: AnalyticsEvents.FEATURE_FLAG_DECISION,\n id:\n entities &&\n typeof entities === 'object' &&\n 'id' in entities &&\n typeof entities.id === 'string'\n ? entities.id\n : undefined,\n data: {\n flag: this.options.key,\n decision: JsonSerialize(decisionResult, 'unknown'),\n providerUsed: flagProvider !== null,\n },\n });\n });\n }\n\n return decisionResult as R;\n }\n}\n\n/**\n * Create a new feature flag.\n * @param options - The options for the feature flag.\n * @returns A new instance of the FeatureFlag class.\n */\nexport function flag<Returns = boolean, Entity = Record<any, any>>(\n options: FeatureFlagDefinition<Returns, Entity>,\n): FlagRunner<Entity, Returns> {\n const flag = new FeatureFlag<Returns, Entity>(options);\n const runner = flag.execute.bind(flag, undefined) as FlagRunner<\n Entity,\n Returns\n >;\n\n runner.run = async function (ctx) {\n if (!ctx?.identify) {\n throw new Error(\n 'Custom evaluation context must have an identify function or object.',\n );\n }\n\n const context = (\n typeof ctx === 'function'\n ? await (ctx as CustomEvaluationFunction<Entity>)()\n : ctx\n ) as Entity;\n\n const decisionResult = await flag.execute(context);\n\n return decisionResult;\n };\n\n return runner;\n}\n"],"mappings":";;;;;AAqBA,IAAI,eAAoC;;;;AAKxC,SAAgB,gBAAgB,UAA8B;AAC5D,gBAAe;;;;;AA2NjB,IAAa,cAAb,MAA+B;CAC7B,AAAQ;;;;;CAMR,AAAO,YAAY,AAAgB,SAAsC;EAAtC;AACjC,OAAK,aAAa,iCAAc,KAAK;EACrC,MAAM,YAAY,KAAK,WAAW;AAElC,MAAI,UAAU,IAAI,QAAQ,IAAI,CAC5B,OAAM,IAAI,MAAM,0BAA0B,QAAQ,IAAI,mBAAmB;AAG3E,YAAU,IAAI,QAAQ,KAAK,KAAK;;CAGlC,AAAQ,aAAgC;EACtC,MAAM,MAAM,+BAAY;AAExB,gDAAI,IAAK,SAAS;GAChB,MAAM,EACJ,QACA,YACA,aACA,SACA,OACA,SACA,YACE,IAAI;AAER,UAAO;IACG;IACR;IACA,SAAS;KACP;KACA;KACA;KACA;KACA;KACD;IACD,OAAO;IACR;;EAGH,MAAM,WAAW,8CAAmB,UAAU;AAE9C,MAAI,UAAU;GACZ,MAAM,EAAE,YAAY,MAAM,OAAO,cAAc;AAE/C,UAAO;IACL,QAAQ,WAAW;IACnB;IACA,OAAO;KACL;KACA;KACA;KACA,WAAW,SAAS;KACpB,cAAc,cAAc;AAE1B,aADa,SAAS;;KAGzB;IACD,SAAS;IACV;;AAGH,QAAM,IAAI,MACR,uGACD;;;;;;;CAQH,MAAa,QAAQ,KAAqB;EACxC,MAAM,EAAE,QAAQ,UAAU,qBAAqB,KAAK;EAEpD,MAAM,sBAAsB,YAAY,KAAK;EAC7C,MAAM,WACN,OACA,OAAO,YAAY;GACjB,MAAM,MAAM,KAAK,YAAY;AAC7B,UAAQ,2DAAM,SAAW,IAAI,KAAK,EAAE;MAClC;EACJ,MAAM,qBAAqB,YAAY,KAAK,GAAG;EAG/C,IAAI,iBAA2C;AAC/C,MAAI,aACF,KAAI;AACF,oBAAiB,MAAM,aAAa,QAAQ,KAAK,QAAQ,KAAK,SAAS;AAGvE,OAAI,kBAAkB,CAAC,eAAe,SAEpC;QAAI,OAAO,WAAW,WAKpB,QAJuB,MAAM,OAAO;KAClC;KACA,UAAU;KACX,CAAC;;WAIC,OAAO;AACd,6BAAO,KAAK,mDAAmD,KAAK,QAAQ,IAAI,KAAK;;EAKzF,MAAM,gBAAgB,YAAY,KAAK;EACvC,MAAM,iBAAiB,MAAM,OAAO;GAClC;GACA,UAAU;GACX,CAAC;EACF,MAAM,eAAe,YAAY,KAAK,GAAG;AAGzC,MAAI,CAAC,kBAAkB;AACrB,4BAAM,YAAY;AAChB,UAAM,KAAK,WAAW,UAAU,MAAM;KACpC,MAAM,kCAAgB;KACtB,MAAM;MACJ,MAAM,KAAK,QAAQ;MACnB,oBAAoB,mBAAmB,QAAQ,EAAE;MACjD,cAAc,aAAa,QAAQ,EAAE;MACrC,cAAc,iBAAiB;MAC/B,kFAAiB,eAAgB,YAAW;MAC7C;KACF,CAAC;KACF;AAEF,4BAAM,YAAY;AAChB,UAAM,KAAK,WAAW,UAAU,MAAM;KACpC,MAAM,kCAAgB;KACtB,IACA,YACA,OAAO,aAAa,YACpB,QAAQ,YACR,OAAO,SAAS,OAAO,WACvB,SAAS,KACT;KACA,MAAM;MACJ,MAAM,KAAK,QAAQ;MACnB,UAAU,iCAAc,gBAAgB,UAAU;MAClD,cAAc,iBAAiB;MAChC;KACF,CAAC;KACF;;AAGJ,SAAO;;;;;;;;AASX,SAAgB,KAChB,SAC8B;CAC5B,MAAM,SAAO,IAAI,YAA6B,QAAQ;CACtD,MAAM,SAAS,OAAK,QAAQ,KAAK,QAAM,OAAU;AAKjD,QAAO,MAAM,eAAgB,KAAK;AAChC,MAAI,4CAAC,IAAK,UACR,OAAM,IAAI,MACR,sEACD;EAGH,MAAM,UACN,OAAO,QAAQ,aACf,MAAO,KAA0C,GACjD;AAKA,SAFuB,MAAM,OAAK,QAAQ,QAAQ;;AAKpD,QAAO"}
@@ -1,4 +1,4 @@
1
- import { FlagConfiguration, FlagProvider, JsonFlagProvider } from "../analytics-engine-6_M8tCeD.js";
1
+ import { FlagConfiguration, FlagProvider, JsonFlagProvider } from "../analytics-engine-B7JNRnEN.js";
2
2
  import "../EventInterceptor-x-R2qshQ.js";
3
3
  import "../ButtonKit-C7r7RPNf.js";
4
4
  import "../ModalKit-Btz58KYn.js";
@@ -1,4 +1,4 @@
1
- import { CommandFlagContext, CustomEvaluationContext, CustomEvaluationFunction, DecideFunction, EvaluationContext, EventFlagContext, FeatureFlag, FeatureFlagDefinition, FlagRunner, IdentifyFunction, MaybePromise, flag, setFlagProvider } from "../analytics-engine-6_M8tCeD.js";
1
+ import { CommandFlagContext, CustomEvaluationContext, CustomEvaluationFunction, DecideFunction, EvaluationContext, EventFlagContext, FeatureFlag, FeatureFlagDefinition, FlagRunner, IdentifyFunction, MaybePromise, flag, setFlagProvider } from "../analytics-engine-B7JNRnEN.js";
2
2
  import "../EventInterceptor-x-R2qshQ.js";
3
3
  import "../ButtonKit-C7r7RPNf.js";
4
4
  import "../ModalKit-Btz58KYn.js";
@@ -1,7 +1,7 @@
1
1
  require('../colors-DL3ucTiT.js');
2
2
  require('../ActionRow-CbdGFWMT.js');
3
3
  require('../error-codes-Ds0bnPvT.js');
4
- require('../commandkit-Dy4V-Rk2.js');
4
+ require('../commandkit-Bm0gLN8i.js');
5
5
  require('../common-CcfjYnPG.js');
6
6
  require('../common-vnMIelAE.js');
7
7
  require('../container-C6GtfAPW.js');
@@ -27,13 +27,14 @@ require('../constants-BOOGN85p.js');
27
27
  require('../EventWorkerContext-Dq29tieI.js');
28
28
  require('../signals-ChFMD7mB.js');
29
29
  require('../MessageCommandParser-CEuO6Ex3.js');
30
- require('../CommandsRouter-DZAeB2v_.js');
31
- require('../EventsRouter-Dzpm7ubq.js');
32
- require('../router-DHnFRADH.js');
33
- require('../common-DVM_onKu.js');
34
- require('../CommandKitEventsChannel-B5vbINtP.js');
35
- require('../store-Hcgz7DSt.js');
36
- const require_feature_flags = require('../feature-flags-3TQSPAVn.js');
30
+ require('../helpers-BSwwrKJW.js');
31
+ require('../CommandsRouter-Cgcy6cK9.js');
32
+ require('../EventsRouter-3Gygh-km.js');
33
+ require('../router-Dn35v30f.js');
34
+ require('../common-Dxr9-XPa.js');
35
+ require('../CommandKitEventsChannel-BtRzr3Tz.js');
36
+ require('../store-CM6pWVZh.js');
37
+ const require_feature_flags = require('../feature-flags-nZJB7-e5.js');
37
38
 
38
39
  exports.FeatureFlag = require_feature_flags.FeatureFlag;
39
40
  exports.flag = require_feature_flags.flag;
@@ -1,4 +1,4 @@
1
- import { FlagStore } from "../analytics-engine-6_M8tCeD.js";
1
+ import { FlagStore } from "../analytics-engine-B7JNRnEN.js";
2
2
  import "../EventInterceptor-x-R2qshQ.js";
3
3
  import "../ButtonKit-C7r7RPNf.js";
4
4
  import "../ModalKit-Btz58KYn.js";
@@ -1,3 +1,3 @@
1
- const require_store = require('../store-Hcgz7DSt.js');
1
+ const require_store = require('../store-CM6pWVZh.js');
2
2
 
3
3
  exports.FlagStore = require_store.FlagStore;
@@ -33,4 +33,4 @@ Object.defineProperty(exports, 'isMessageSource', {
33
33
  return isMessageSource;
34
34
  }
35
35
  });
36
- //# sourceMappingURL=helpers-CiuN7y5B.js.map
36
+ //# sourceMappingURL=helpers-BSwwrKJW.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers-CiuN7y5B.js","names":[],"sources":["../src/app/commands/helpers.ts"],"sourcesContent":["import { Interaction, Message } from 'discord.js';\n\n/**\n * Union type representing possible command sources.\n */\nexport type CommandSource = Interaction | Message;\n\n/**\n * Type guard to check if a command source is a Discord message.\n * @param source - The command source to check\n * @returns True if the source is a Message\n */\nexport function isMessageSource(source: CommandSource): source is Message {\n return source instanceof Message;\n}\n\n/**\n * Type guard to check if a command source is a Discord interaction.\n * @param source - The command source to check\n * @returns True if the source is an Interaction\n */\nexport function isInteractionSource(\n source: CommandSource,\n): source is Interaction {\n return !isMessageSource(source);\n}\n"],"mappings":";;;;;;;;;;AAYA,SAAgB,gBAAgB,QAA0C;AACxE,QAAO,kBAAkB;;;;;;;AAQ3B,SAAgB,oBAChB,QACwB;AACtB,QAAO,CAAC,gBAAgB,OAAO"}
1
+ {"version":3,"file":"helpers-BSwwrKJW.js","names":[],"sources":["../src/app/commands/helpers.ts"],"sourcesContent":["import { Interaction, Message } from 'discord.js';\n\n/**\n * Union type representing possible command sources.\n */\nexport type CommandSource = Interaction | Message;\n\n/**\n * Type guard to check if a command source is a Discord message.\n * @param source - The command source to check\n * @returns True if the source is a Message\n */\nexport function isMessageSource(source: CommandSource): source is Message {\n return source instanceof Message;\n}\n\n/**\n * Type guard to check if a command source is a Discord interaction.\n * @param source - The command source to check\n * @returns True if the source is an Interaction\n */\nexport function isInteractionSource(\n source: CommandSource,\n): source is Interaction {\n return !isMessageSource(source);\n}\n"],"mappings":";;;;;;;;;;AAYA,SAAgB,gBAAgB,QAA0C;AACxE,QAAO,kBAAkB;;;;;;;AAQ3B,SAAgB,oBAChB,QACwB;AACtB,QAAO,CAAC,gBAAgB,OAAO"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AnyCommandExecute, AppCommand, AppCommandHandler, AppCommandNative, AsyncFunction, AutocompleteCommand, AutocompleteCommandContext, AutocompleteCommandMiddlewareContext, BootstrapFunction, ChatInputCommand, ChatInputCommandContext, CommandBuilderLike, CommandContext, CommandContextOptions, CommandData, CommandDataSchema, CommandDataSchemaKey, CommandDataSchemaValue, CommandExecutionMode, CommandFlagContext, CommandKit, CommandKitConfiguration, CommandKitEnvironment, CommandKitEnvironmentInternalData, CommandKitEnvironmentType, CommandKitEventDispatch, CommandKitHMREvent, CommandKitOptions, CommandKitPlugin, CommandKitPluginRuntime, CommandMetadata, CommandMetadataFunction, CommandRegistrar, CommandTypeData, CommonDirectiveTransformer, CommonDirectiveTransformerOptions, CommonPluginRuntime, CompilerPlugin, CompilerPluginRuntime, Context, ContextParameters, CustomAppCommandProps, CustomEvaluationContext, CustomEvaluationFunction, DecideFunction, EvaluationContext, EventFlagContext, EventHandler, FeatureFlag, FeatureFlagDefinition, FlagRunner, GenericFunction, IdentifyFunction, InteractionCommandContext, InteractionCommandMiddlewareContext, LegacyCommandMetadata, LoadedCommand, MaybeFalsey, MaybePromise, MessageCommand, MessageCommandContext, MessageCommandMiddlewareContext, MessageContextMenuCommand, MessageContextMenuCommandContext, MessageContextMenuCommandMiddlewareContext, MiddlewareContext, MiddlewareContextArgs, PluginTransformParameters, PreRegisterCommandsEvent, PreparedAppCommandExecution, ResolvableCommand, RunCommand, RuntimePlugin, SlashCommandMiddlewareContext, TemplateHandler, TransformedResult, UserContextMenuCommand, UserContextMenuCommandContext, UserContextMenuCommandMiddlewareContext, after, cancelAfter, commandkit, exitContext, flag, getCommandKit, getContext, isCommandWorkerContext, isCompilerPlugin, isRuntimePlugin, makeContextAwareFunction, onApplicationBootstrap, onBootstrap, provideContext, setFlagProvider, useEnvironment, useStore } from "./analytics-engine-6_M8tCeD.js";
1
+ import { AnyCommandExecute, AppCommand, AppCommandHandler, AppCommandNative, AsyncFunction, AutocompleteCommand, AutocompleteCommandContext, AutocompleteCommandMiddlewareContext, BootstrapFunction, ChatInputCommand, ChatInputCommandContext, CommandBuilderLike, CommandContext, CommandContextOptions, CommandData, CommandDataSchema, CommandDataSchemaKey, CommandDataSchemaValue, CommandExecutionMode, CommandFlagContext, CommandKit, CommandKitConfiguration, CommandKitEnvironment, CommandKitEnvironmentInternalData, CommandKitEnvironmentType, CommandKitEventDispatch, CommandKitHMREvent, CommandKitOptions, CommandKitPlugin, CommandKitPluginRuntime, CommandMetadata, CommandMetadataFunction, CommandRegistrar, CommandTypeData, CommonDirectiveTransformer, CommonDirectiveTransformerOptions, CommonPluginRuntime, CompilerPlugin, CompilerPluginRuntime, Context, ContextParameters, CustomAppCommandProps, CustomEvaluationContext, CustomEvaluationFunction, DecideFunction, EvaluationContext, EventFlagContext, EventHandler, FeatureFlag, FeatureFlagDefinition, FlagRunner, GenericFunction, IdentifyFunction, InteractionCommandContext, InteractionCommandMiddlewareContext, LegacyCommandMetadata, LoadedCommand, MaybeFalsey, MaybePromise, MessageCommand, MessageCommandContext, MessageCommandMiddlewareContext, MessageContextMenuCommand, MessageContextMenuCommandContext, MessageContextMenuCommandMiddlewareContext, MiddlewareContext, MiddlewareContextArgs, PluginTransformParameters, PreRegisterCommandsEvent, PreparedAppCommandExecution, ResolvableCommand, RunCommand, RuntimePlugin, SlashCommandMiddlewareContext, TemplateHandler, TransformedResult, UserContextMenuCommand, UserContextMenuCommandContext, UserContextMenuCommandMiddlewareContext, after, cancelAfter, commandkit, exitContext, flag, getCommandKit, getContext, isCommandWorkerContext, isCompilerPlugin, isRuntimePlugin, makeContextAwareFunction, onApplicationBootstrap, onBootstrap, provideContext, setFlagProvider, useEnvironment, useStore } from "./analytics-engine-B7JNRnEN.js";
2
2
  import { EventInterceptor, EventInterceptorContextData, EventInterceptorErrorHandler } from "./EventInterceptor-x-R2qshQ.js";
3
3
  import { ButtonKit, ButtonKitPredicate, CommandKitButtonBuilderInteractionCollectorDispatch, CommandKitButtonBuilderInteractionCollectorDispatchContextData, CommandKitButtonBuilderOnEnd, OnButtonKitClick, OnButtonKitEnd } from "./ButtonKit-C7r7RPNf.js";
4
4
  import { CommandKitModalBuilderInteractionCollectorDispatch, CommandKitModalBuilderInteractionCollectorDispatchContextData, CommandKitModalBuilderOnEnd, ModalKit, ModalKitPredicate, OnModalKitEnd, OnModalKitSubmit } from "./ModalKit-Btz58KYn.js";
@@ -29,9 +29,9 @@ import { Command, CommandsRouter, CommandsRouterOptions, Middleware, ParsedComma
29
29
  import { EventsRouter, EventsRouterOptions, EventsTree, ParsedEvent } from "./EventsRouter-BacqK6z3.js";
30
30
  import "./index-DKcmsWXw.js";
31
31
  import { COMMANDKIT_BOOTSTRAP_MODE, COMMANDKIT_CWD, COMMANDKIT_IS_CLI, COMMANDKIT_IS_DEV, COMMANDKIT_IS_TEST, HMREventType } from "./constants-MKu-Q1jh.js";
32
- import { EventWorkerContext, eventWorkerContext, getEventWorkerContext, isEventWorkerContext, runInEventWorkerContext } from "./EventWorkerContext-xgEc2N2T.js";
32
+ import { EventWorkerContext, eventWorkerContext, getEventWorkerContext, isEventWorkerContext, runInEventWorkerContext } from "./EventWorkerContext-BMk7IXpC.js";
33
33
  import { bootstrapCommandkitCLI } from "./init-DOr-Y3GQ.js";
34
- import { defineConfig, getConfig } from "./config-nD7V_D7G.js";
34
+ import { defineConfig, getConfig } from "./config-BhVxyjmZ.js";
35
35
  import { ILogger } from "./ILogger-BW8GM-YZ.js";
36
36
  import { DefaultLogger } from "./DefaultLogger-XCOl5nLd.js";
37
37
  import { CommandKitLoggerOptions, Logger, LoggerImpl, createLogger } from "./Logger-DyfkPk7u.js";
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ const require_chunk = require('./chunk-nOFOJqeH.js');
3
3
  require('./colors-DL3ucTiT.js');
4
4
  const require_ActionRow = require('./ActionRow-CbdGFWMT.js');
5
5
  const require_error_codes = require('./error-codes-Ds0bnPvT.js');
6
- const require_commandkit = require('./commandkit-Dy4V-Rk2.js');
6
+ const require_commandkit = require('./commandkit-Bm0gLN8i.js');
7
7
  require('./common-CcfjYnPG.js');
8
8
  require('./common-vnMIelAE.js');
9
9
  const require_container = require('./container-C6GtfAPW.js');
@@ -29,18 +29,18 @@ require('./constants-BOOGN85p.js');
29
29
  const require_EventWorkerContext = require('./EventWorkerContext-Dq29tieI.js');
30
30
  const require_signals = require('./signals-ChFMD7mB.js');
31
31
  const require_MessageCommandParser = require('./MessageCommandParser-CEuO6Ex3.js');
32
- const require_CommandsRouter = require('./CommandsRouter-DZAeB2v_.js');
33
- const require_EventsRouter = require('./EventsRouter-Dzpm7ubq.js');
34
- require('./router-DHnFRADH.js');
35
- require('./common-DVM_onKu.js');
36
- require('./CommandKitEventsChannel-B5vbINtP.js');
37
- require('./store-Hcgz7DSt.js');
38
- const require_helpers = require('./helpers-CiuN7y5B.js');
32
+ const require_helpers = require('./helpers-BSwwrKJW.js');
33
+ const require_CommandsRouter = require('./CommandsRouter-Cgcy6cK9.js');
34
+ const require_EventsRouter = require('./EventsRouter-3Gygh-km.js');
35
+ require('./router-Dn35v30f.js');
36
+ require('./common-Dxr9-XPa.js');
37
+ require('./CommandKitEventsChannel-BtRzr3Tz.js');
38
+ require('./store-CM6pWVZh.js');
39
39
  require('./app-HN1cVg8J.js');
40
40
  require('./ILogger-dQ7Y9X1f.js');
41
- const require_version = require('./version-CphQqt4J.js');
42
- const require_feature_flags = require('./feature-flags-3TQSPAVn.js');
43
- const require_init = require('./init-Bo01I_h_.js');
41
+ const require_version = require('./version-DRSQMx0w.js');
42
+ const require_feature_flags = require('./feature-flags-nZJB7-e5.js');
43
+ const require_init = require('./init-Cy_bcUt4.js');
44
44
  let discord_js = require("discord.js");
45
45
  discord_js = require_chunk.__toESM(discord_js);
46
46
 
@@ -1,9 +1,9 @@
1
1
  const require_chunk = require('./chunk-nOFOJqeH.js');
2
- const require_commandkit = require('./commandkit-Dy4V-Rk2.js');
2
+ const require_commandkit = require('./commandkit-Bm0gLN8i.js');
3
3
  const require_constants = require('./constants-B5_Ta7PR.js');
4
4
  const require_CompilerPlugin = require('./CompilerPlugin-M8r3yNAl.js');
5
5
  const require_types_package = require('./types-package-BWArjyBF.js');
6
- const require_common = require('./common-DVM_onKu.js');
6
+ const require_common = require('./common-Dxr9-XPa.js');
7
7
  let node_fs = require("node:fs");
8
8
  node_fs = require_chunk.__toESM(node_fs);
9
9
  let node_path = require("node:path");
@@ -92,4 +92,4 @@ Object.defineProperty(exports, 'bootstrapCommandkitCLI', {
92
92
  return bootstrapCommandkitCLI;
93
93
  }
94
94
  });
95
- //# sourceMappingURL=init-Bo01I_h_.js.map
95
+ //# sourceMappingURL=init-Cy_bcUt4.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"init-Bo01I_h_.js","names":[],"sources":["../src/cli/init.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { mkdir } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { generateTypesPackage } from '../utils/types-package';\nimport { loadConfigFile } from '../config/loader';\nimport {\n CompilerPlugin,\n CompilerPluginRuntime,\n isCompilerPlugin,\n} from '../plugins';\nimport { panic } from './common';\nimport { COMMANDKIT_CWD } from '../utils/constants';\n\n/**\n * Creates a command line interface for CommandKit.\n * @param argv The arguments passed to the CLI.\n * @param options The options passed to the CLI.\n */\nexport async function bootstrapCommandkitCLI(\n argv: string[],\n options?: import('commander').ParseOptions | undefined,\n) {\n process.title = 'CommandKit CLI';\n\n // imports are lazily loaded when the cli is used, instead of loading it with the lib itself\n const { Command } = await import('commander');\n const { bootstrapDevelopmentServer } = await import('./development');\n const { bootstrapProductionServer, createProductionBuild } = await import(\n './production'\n );\n const { generateCommand, generateEvent } = await import('./generators');\n const { version } = await import('../version');\n const { showInformation } = await import('./information');\n const { setCLIEnv } = await import('./env');\n\n const program = new Command('commandkit');\n\n program\n .command('dev')\n .version(version)\n .description('Start your bot in development mode.')\n .option(\n '-c, --config [path]',\n 'Path to your commandkit config file.',\n './commandkit.js',\n )\n .action(() => {\n const options = program.opts();\n bootstrapDevelopmentServer(options.config);\n });\n\n program\n .command('info')\n .description(\n 'Show information about the system which can be used to report bugs.',\n )\n .action(async () => {\n await showInformation();\n });\n\n program\n .command('start')\n .description(\n 'Start your bot in production mode after running the build command.',\n )\n .option('-c, --config [path]', 'Path to your commandkit config file.')\n .action(() => {\n const options = program.opts();\n bootstrapProductionServer(options.config);\n });\n\n program\n .command('build')\n .description('Build your project for production usage.')\n .option('-c, --config [path]', 'Path to your commandkit config file.')\n .action(() => {\n setCLIEnv();\n const options = program.opts();\n return createProductionBuild(options.config);\n });\n\n program\n .command('create')\n .description(\n 'Create new files using built-in templates or custom plugin templates',\n )\n .argument(\n '<template>',\n 'The template to use (e.g. command, event, or custom plugin template)',\n )\n .argument('[args...]', 'Additional arguments for the template')\n .action(async (template, args) => {\n setCLIEnv();\n\n // Handle custom plugin templates\n const { plugins } = await loadConfigFile();\n const runtime = new CompilerPluginRuntime(\n plugins.filter((p) => isCompilerPlugin(p)) as CompilerPlugin[],\n );\n\n try {\n await runtime.init();\n const templateHandler = runtime.getTemplate(template);\n\n if (!templateHandler) {\n // Handle built-in templates\n if (template === 'command') {\n const [name] = args;\n if (!name) {\n panic('Command name is required');\n }\n await generateCommand(name);\n return;\n }\n\n if (template === 'event') {\n const [name] = args;\n if (!name) {\n panic('Event name is required');\n }\n await generateEvent(name);\n return;\n }\n\n const valid = Array.from(\n new Set([\n 'command',\n 'event',\n ...Array.from(runtime.getTemplates().keys()),\n ]),\n ).map((t) => `\"${t}\"`);\n\n panic(\n `Template \"${template}\" not found. Available templates: ${valid.join(', ')}`,\n );\n }\n\n await templateHandler(args);\n } catch (e: any) {\n panic(`Failed to execute template \"${template}\": ${e?.message || e}`);\n } finally {\n await runtime.destroy();\n }\n });\n\n const types = join(COMMANDKIT_CWD, 'node_modules', 'commandkit-types');\n\n if (!existsSync(types)) {\n await mkdir(types, { recursive: true }).catch(() => {});\n await generateTypesPackage(true).catch(() => {});\n }\n\n await program.parseAsync(argv, options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBA,eAAsB,uBACtB,MACA,SACA;AACE,SAAQ,QAAQ;CAGhB,MAAM,EAAE,YAAY,MAAM,OAAO;CACjC,MAAM,EAAE,+BAA+B,2CAAM;CAC7C,MAAM,EAAE,2BAA2B,0BAA0B,2CAAM;CAGnE,MAAM,EAAE,iBAAiB,kBAAkB,2CAAM;CACjD,MAAM,EAAE,YAAY,2CAAM;CAC1B,MAAM,EAAE,oBAAoB,2CAAM;CAClC,MAAM,EAAE,cAAc,2CAAM;CAE5B,MAAM,UAAU,IAAI,QAAQ,aAAa;AAEzC,SACA,QAAQ,MAAM,CACd,QAAQ,QAAQ,CAChB,YAAY,sCAAsC,CAClD,OACE,uBACA,wCACA,kBACD,CACD,aAAa;EACX,MAAM,YAAU,QAAQ,MAAM;AAC9B,6BAA2B,UAAQ,OAAO;GAC1C;AAEF,SACA,QAAQ,OAAO,CACf,YACE,sEACD,CACD,OAAO,YAAY;AACjB,QAAM,iBAAiB;GACvB;AAEF,SACA,QAAQ,QAAQ,CAChB,YACE,qEACD,CACD,OAAO,uBAAuB,uCAAuC,CACrE,aAAa;EACX,MAAM,YAAU,QAAQ,MAAM;AAC9B,4BAA0B,UAAQ,OAAO;GACzC;AAEF,SACA,QAAQ,QAAQ,CAChB,YAAY,2CAA2C,CACvD,OAAO,uBAAuB,uCAAuC,CACrE,aAAa;AACX,aAAW;EACX,MAAM,YAAU,QAAQ,MAAM;AAC9B,SAAO,sBAAsB,UAAQ,OAAO;GAC5C;AAEF,SACA,QAAQ,SAAS,CACjB,YACE,uEACD,CACD,SACE,cACA,uEACD,CACD,SAAS,aAAa,wCAAwC,CAC9D,OAAO,OAAO,UAAU,SAAS;AAC/B,aAAW;EAGX,MAAM,EAAE,YAAY,MAAM,mCAAgB;EAC1C,MAAM,UAAU,IAAI,yCAClB,QAAQ,QAAQ,MAAM,wCAAiB,EAAE,CAAC,CAC3C;AAED,MAAI;AACF,SAAM,QAAQ,MAAM;GACpB,MAAM,kBAAkB,QAAQ,YAAY,SAAS;AAErD,OAAI,CAAC,iBAAiB;AAEpB,QAAI,aAAa,WAAW;KAC1B,MAAM,CAAC,QAAQ;AACf,SAAI,CAAC,KACH,sBAAM,2BAA2B;AAEnC,WAAM,gBAAgB,KAAK;AAC3B;;AAGF,QAAI,aAAa,SAAS;KACxB,MAAM,CAAC,QAAQ;AACf,SAAI,CAAC,KACH,sBAAM,yBAAyB;AAEjC,WAAM,cAAc,KAAK;AACzB;;IAGF,MAAM,QAAQ,MAAM,KAClB,IAAI,IAAI;KACR;KACA;KACA,GAAG,MAAM,KAAK,QAAQ,cAAc,CAAC,MAAM,CAAC;KAAC,CAC5C,CACF,CAAC,KAAK,MAAM,IAAI,EAAE,GAAG;AAEtB,yBACE,aAAa,SAAS,oCAAoC,MAAM,KAAK,KAAK,GAC3E;;AAGH,SAAM,gBAAgB,KAAK;WACpB,GAAQ;AACf,wBAAM,+BAA+B,SAAS,4CAAK,EAAG,YAAW,IAAI;YAC7D;AACR,SAAM,QAAQ,SAAS;;GAEzB;CAEF,MAAM,4BAAa,kCAAgB,gBAAgB,mBAAmB;AAEtE,KAAI,yBAAY,MAAM,EAAE;AACtB,oCAAY,OAAO,EAAE,WAAW,MAAM,CAAC,CAAC,YAAY,GAAG;AACvD,QAAM,2CAAqB,KAAK,CAAC,YAAY,GAAG;;AAGlD,OAAM,QAAQ,WAAW,MAAM,QAAQ"}
1
+ {"version":3,"file":"init-Cy_bcUt4.js","names":[],"sources":["../src/cli/init.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { mkdir } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { generateTypesPackage } from '../utils/types-package';\nimport { loadConfigFile } from '../config/loader';\nimport {\n CompilerPlugin,\n CompilerPluginRuntime,\n isCompilerPlugin,\n} from '../plugins';\nimport { panic } from './common';\nimport { COMMANDKIT_CWD } from '../utils/constants';\n\n/**\n * Creates a command line interface for CommandKit.\n * @param argv The arguments passed to the CLI.\n * @param options The options passed to the CLI.\n */\nexport async function bootstrapCommandkitCLI(\n argv: string[],\n options?: import('commander').ParseOptions | undefined,\n) {\n process.title = 'CommandKit CLI';\n\n // imports are lazily loaded when the cli is used, instead of loading it with the lib itself\n const { Command } = await import('commander');\n const { bootstrapDevelopmentServer } = await import('./development');\n const { bootstrapProductionServer, createProductionBuild } = await import(\n './production'\n );\n const { generateCommand, generateEvent } = await import('./generators');\n const { version } = await import('../version');\n const { showInformation } = await import('./information');\n const { setCLIEnv } = await import('./env');\n\n const program = new Command('commandkit');\n\n program\n .command('dev')\n .version(version)\n .description('Start your bot in development mode.')\n .option(\n '-c, --config [path]',\n 'Path to your commandkit config file.',\n './commandkit.js',\n )\n .action(() => {\n const options = program.opts();\n bootstrapDevelopmentServer(options.config);\n });\n\n program\n .command('info')\n .description(\n 'Show information about the system which can be used to report bugs.',\n )\n .action(async () => {\n await showInformation();\n });\n\n program\n .command('start')\n .description(\n 'Start your bot in production mode after running the build command.',\n )\n .option('-c, --config [path]', 'Path to your commandkit config file.')\n .action(() => {\n const options = program.opts();\n bootstrapProductionServer(options.config);\n });\n\n program\n .command('build')\n .description('Build your project for production usage.')\n .option('-c, --config [path]', 'Path to your commandkit config file.')\n .action(() => {\n setCLIEnv();\n const options = program.opts();\n return createProductionBuild(options.config);\n });\n\n program\n .command('create')\n .description(\n 'Create new files using built-in templates or custom plugin templates',\n )\n .argument(\n '<template>',\n 'The template to use (e.g. command, event, or custom plugin template)',\n )\n .argument('[args...]', 'Additional arguments for the template')\n .action(async (template, args) => {\n setCLIEnv();\n\n // Handle custom plugin templates\n const { plugins } = await loadConfigFile();\n const runtime = new CompilerPluginRuntime(\n plugins.filter((p) => isCompilerPlugin(p)) as CompilerPlugin[],\n );\n\n try {\n await runtime.init();\n const templateHandler = runtime.getTemplate(template);\n\n if (!templateHandler) {\n // Handle built-in templates\n if (template === 'command') {\n const [name] = args;\n if (!name) {\n panic('Command name is required');\n }\n await generateCommand(name);\n return;\n }\n\n if (template === 'event') {\n const [name] = args;\n if (!name) {\n panic('Event name is required');\n }\n await generateEvent(name);\n return;\n }\n\n const valid = Array.from(\n new Set([\n 'command',\n 'event',\n ...Array.from(runtime.getTemplates().keys()),\n ]),\n ).map((t) => `\"${t}\"`);\n\n panic(\n `Template \"${template}\" not found. Available templates: ${valid.join(', ')}`,\n );\n }\n\n await templateHandler(args);\n } catch (e: any) {\n panic(`Failed to execute template \"${template}\": ${e?.message || e}`);\n } finally {\n await runtime.destroy();\n }\n });\n\n const types = join(COMMANDKIT_CWD, 'node_modules', 'commandkit-types');\n\n if (!existsSync(types)) {\n await mkdir(types, { recursive: true }).catch(() => {});\n await generateTypesPackage(true).catch(() => {});\n }\n\n await program.parseAsync(argv, options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBA,eAAsB,uBACtB,MACA,SACA;AACE,SAAQ,QAAQ;CAGhB,MAAM,EAAE,YAAY,MAAM,OAAO;CACjC,MAAM,EAAE,+BAA+B,2CAAM;CAC7C,MAAM,EAAE,2BAA2B,0BAA0B,2CAAM;CAGnE,MAAM,EAAE,iBAAiB,kBAAkB,2CAAM;CACjD,MAAM,EAAE,YAAY,2CAAM;CAC1B,MAAM,EAAE,oBAAoB,2CAAM;CAClC,MAAM,EAAE,cAAc,2CAAM;CAE5B,MAAM,UAAU,IAAI,QAAQ,aAAa;AAEzC,SACA,QAAQ,MAAM,CACd,QAAQ,QAAQ,CAChB,YAAY,sCAAsC,CAClD,OACE,uBACA,wCACA,kBACD,CACD,aAAa;EACX,MAAM,YAAU,QAAQ,MAAM;AAC9B,6BAA2B,UAAQ,OAAO;GAC1C;AAEF,SACA,QAAQ,OAAO,CACf,YACE,sEACD,CACD,OAAO,YAAY;AACjB,QAAM,iBAAiB;GACvB;AAEF,SACA,QAAQ,QAAQ,CAChB,YACE,qEACD,CACD,OAAO,uBAAuB,uCAAuC,CACrE,aAAa;EACX,MAAM,YAAU,QAAQ,MAAM;AAC9B,4BAA0B,UAAQ,OAAO;GACzC;AAEF,SACA,QAAQ,QAAQ,CAChB,YAAY,2CAA2C,CACvD,OAAO,uBAAuB,uCAAuC,CACrE,aAAa;AACX,aAAW;EACX,MAAM,YAAU,QAAQ,MAAM;AAC9B,SAAO,sBAAsB,UAAQ,OAAO;GAC5C;AAEF,SACA,QAAQ,SAAS,CACjB,YACE,uEACD,CACD,SACE,cACA,uEACD,CACD,SAAS,aAAa,wCAAwC,CAC9D,OAAO,OAAO,UAAU,SAAS;AAC/B,aAAW;EAGX,MAAM,EAAE,YAAY,MAAM,mCAAgB;EAC1C,MAAM,UAAU,IAAI,yCAClB,QAAQ,QAAQ,MAAM,wCAAiB,EAAE,CAAC,CAC3C;AAED,MAAI;AACF,SAAM,QAAQ,MAAM;GACpB,MAAM,kBAAkB,QAAQ,YAAY,SAAS;AAErD,OAAI,CAAC,iBAAiB;AAEpB,QAAI,aAAa,WAAW;KAC1B,MAAM,CAAC,QAAQ;AACf,SAAI,CAAC,KACH,sBAAM,2BAA2B;AAEnC,WAAM,gBAAgB,KAAK;AAC3B;;AAGF,QAAI,aAAa,SAAS;KACxB,MAAM,CAAC,QAAQ;AACf,SAAI,CAAC,KACH,sBAAM,yBAAyB;AAEjC,WAAM,cAAc,KAAK;AACzB;;IAGF,MAAM,QAAQ,MAAM,KAClB,IAAI,IAAI;KACR;KACA;KACA,GAAG,MAAM,KAAK,QAAQ,cAAc,CAAC,MAAM,CAAC;KAAC,CAC5C,CACF,CAAC,KAAK,MAAM,IAAI,EAAE,GAAG;AAEtB,yBACE,aAAa,SAAS,oCAAoC,MAAM,KAAK,KAAK,GAC3E;;AAGH,SAAM,gBAAgB,KAAK;WACpB,GAAQ;AACf,wBAAM,+BAA+B,SAAS,4CAAK,EAAG,YAAW,IAAI;YAC7D;AACR,SAAM,QAAQ,SAAS;;GAEzB;CAEF,MAAM,4BAAa,kCAAgB,gBAAgB,mBAAmB;AAEtE,KAAI,yBAAY,MAAM,EAAE;AACtB,oCAAY,OAAO,EAAE,WAAW,MAAM,CAAC,CAAC,YAAY,GAAG;AACvD,QAAM,2CAAqB,KAAK,CAAC,YAAY,GAAG;;AAGlD,OAAM,QAAQ,WAAW,MAAM,QAAQ"}
@@ -1,7 +1,7 @@
1
1
  require('../colors-DL3ucTiT.js');
2
2
  require('../ActionRow-CbdGFWMT.js');
3
3
  require('../error-codes-Ds0bnPvT.js');
4
- const require_commandkit = require('../commandkit-Dy4V-Rk2.js');
4
+ const require_commandkit = require('../commandkit-Bm0gLN8i.js');
5
5
  require('../common-CcfjYnPG.js');
6
6
  require('../common-vnMIelAE.js');
7
7
  require('../container-C6GtfAPW.js');
@@ -27,11 +27,12 @@ require('../constants-BOOGN85p.js');
27
27
  require('../EventWorkerContext-Dq29tieI.js');
28
28
  require('../signals-ChFMD7mB.js');
29
29
  require('../MessageCommandParser-CEuO6Ex3.js');
30
- require('../CommandsRouter-DZAeB2v_.js');
31
- require('../EventsRouter-Dzpm7ubq.js');
32
- require('../router-DHnFRADH.js');
33
- require('../common-DVM_onKu.js');
34
- require('../CommandKitEventsChannel-B5vbINtP.js');
35
- require('../store-Hcgz7DSt.js');
30
+ require('../helpers-BSwwrKJW.js');
31
+ require('../CommandsRouter-Cgcy6cK9.js');
32
+ require('../EventsRouter-3Gygh-km.js');
33
+ require('../router-Dn35v30f.js');
34
+ require('../common-Dxr9-XPa.js');
35
+ require('../CommandKitEventsChannel-BtRzr3Tz.js');
36
+ require('../store-CM6pWVZh.js');
36
37
 
37
38
  exports.DefaultLogger = require_commandkit.DefaultLogger;
@@ -1,7 +1,7 @@
1
1
  require('../colors-DL3ucTiT.js');
2
2
  require('../ActionRow-CbdGFWMT.js');
3
3
  require('../error-codes-Ds0bnPvT.js');
4
- const require_commandkit = require('../commandkit-Dy4V-Rk2.js');
4
+ const require_commandkit = require('../commandkit-Bm0gLN8i.js');
5
5
  require('../common-CcfjYnPG.js');
6
6
  require('../common-vnMIelAE.js');
7
7
  require('../container-C6GtfAPW.js');
@@ -27,12 +27,13 @@ require('../constants-BOOGN85p.js');
27
27
  require('../EventWorkerContext-Dq29tieI.js');
28
28
  require('../signals-ChFMD7mB.js');
29
29
  require('../MessageCommandParser-CEuO6Ex3.js');
30
- require('../CommandsRouter-DZAeB2v_.js');
31
- require('../EventsRouter-Dzpm7ubq.js');
32
- require('../router-DHnFRADH.js');
33
- require('../common-DVM_onKu.js');
34
- require('../CommandKitEventsChannel-B5vbINtP.js');
35
- require('../store-Hcgz7DSt.js');
30
+ require('../helpers-BSwwrKJW.js');
31
+ require('../CommandsRouter-Cgcy6cK9.js');
32
+ require('../EventsRouter-3Gygh-km.js');
33
+ require('../router-Dn35v30f.js');
34
+ require('../common-Dxr9-XPa.js');
35
+ require('../CommandKitEventsChannel-BtRzr3Tz.js');
36
+ require('../store-CM6pWVZh.js');
36
37
 
37
38
  exports.Logger = require_commandkit.Logger;
38
39
  exports.createLogger = require_commandkit.createLogger;
@@ -1,4 +1,4 @@
1
- import { CompilerPlugin, PluginTransformParameters, TransformedResult, isCompilerPlugin } from "../analytics-engine-6_M8tCeD.js";
1
+ import { CompilerPlugin, PluginTransformParameters, TransformedResult, isCompilerPlugin } from "../analytics-engine-B7JNRnEN.js";
2
2
  import "../EventInterceptor-x-R2qshQ.js";
3
3
  import "../ButtonKit-C7r7RPNf.js";
4
4
  import "../ModalKit-Btz58KYn.js";
@@ -1,4 +1,4 @@
1
- import { PluginCommon, PluginOptions, PluginType, isPlugin } from "../analytics-engine-6_M8tCeD.js";
1
+ import { PluginCommon, PluginOptions, PluginType, isPlugin } from "../analytics-engine-B7JNRnEN.js";
2
2
  import "../EventInterceptor-x-R2qshQ.js";
3
3
  import "../ButtonKit-C7r7RPNf.js";
4
4
  import "../ModalKit-Btz58KYn.js";
@@ -1,4 +1,4 @@
1
- import { RuntimePlugin, isRuntimePlugin } from "../analytics-engine-6_M8tCeD.js";
1
+ import { RuntimePlugin, isRuntimePlugin } from "../analytics-engine-B7JNRnEN.js";
2
2
  import "../EventInterceptor-x-R2qshQ.js";
3
3
  import "../ButtonKit-C7r7RPNf.js";
4
4
  import "../ModalKit-Btz58KYn.js";
@@ -1,4 +1,4 @@
1
- import { CommandKitEventDispatch, CommandKitPlugin, CommandKitPluginRuntime, CommonDirectiveTransformer, CommonDirectiveTransformerOptions, CommonPluginRuntime, CompilerPlugin, CompilerPluginRuntime, MaybeFalsey, PluginTransformParameters, RuntimePlugin, TemplateHandler, TransformedResult, isCompilerPlugin, isRuntimePlugin } from "../analytics-engine-6_M8tCeD.js";
1
+ import { CommandKitEventDispatch, CommandKitPlugin, CommandKitPluginRuntime, CommonDirectiveTransformer, CommonDirectiveTransformerOptions, CommonPluginRuntime, CompilerPlugin, CompilerPluginRuntime, MaybeFalsey, PluginTransformParameters, RuntimePlugin, TemplateHandler, TransformedResult, isCompilerPlugin, isRuntimePlugin } from "../analytics-engine-B7JNRnEN.js";
2
2
  import "../EventInterceptor-x-R2qshQ.js";
3
3
  import "../ButtonKit-C7r7RPNf.js";
4
4
  import "../ModalKit-Btz58KYn.js";
@@ -1,7 +1,7 @@
1
1
  require('../colors-DL3ucTiT.js');
2
2
  require('../ActionRow-CbdGFWMT.js');
3
3
  require('../error-codes-Ds0bnPvT.js');
4
- const require_commandkit = require('../commandkit-Dy4V-Rk2.js');
4
+ const require_commandkit = require('../commandkit-Bm0gLN8i.js');
5
5
  require('../common-CcfjYnPG.js');
6
6
  require('../common-vnMIelAE.js');
7
7
  require('../container-C6GtfAPW.js');
@@ -27,12 +27,13 @@ require('../constants-BOOGN85p.js');
27
27
  require('../EventWorkerContext-Dq29tieI.js');
28
28
  require('../signals-ChFMD7mB.js');
29
29
  require('../MessageCommandParser-CEuO6Ex3.js');
30
- require('../CommandsRouter-DZAeB2v_.js');
31
- require('../EventsRouter-Dzpm7ubq.js');
32
- require('../router-DHnFRADH.js');
33
- require('../common-DVM_onKu.js');
34
- require('../CommandKitEventsChannel-B5vbINtP.js');
35
- require('../store-Hcgz7DSt.js');
30
+ require('../helpers-BSwwrKJW.js');
31
+ require('../CommandsRouter-Cgcy6cK9.js');
32
+ require('../EventsRouter-3Gygh-km.js');
33
+ require('../router-Dn35v30f.js');
34
+ require('../common-Dxr9-XPa.js');
35
+ require('../CommandKitEventsChannel-BtRzr3Tz.js');
36
+ require('../store-CM6pWVZh.js');
36
37
 
37
38
  exports.CommandKitPluginRuntime = require_commandkit.CommandKitPluginRuntime;
38
39
  exports.CommonDirectiveTransformer = require_commandkit.CommonDirectiveTransformer;
@@ -1,4 +1,4 @@
1
- import { CommandKitPluginRuntime } from "../../analytics-engine-6_M8tCeD.js";
1
+ import { CommandKitPluginRuntime } from "../../analytics-engine-B7JNRnEN.js";
2
2
  import "../../EventInterceptor-x-R2qshQ.js";
3
3
  import "../../ButtonKit-C7r7RPNf.js";
4
4
  import "../../ModalKit-Btz58KYn.js";
@@ -1,7 +1,7 @@
1
1
  require('../../colors-DL3ucTiT.js');
2
2
  require('../../ActionRow-CbdGFWMT.js');
3
3
  require('../../error-codes-Ds0bnPvT.js');
4
- const require_commandkit = require('../../commandkit-Dy4V-Rk2.js');
4
+ const require_commandkit = require('../../commandkit-Bm0gLN8i.js');
5
5
  require('../../common-CcfjYnPG.js');
6
6
  require('../../common-vnMIelAE.js');
7
7
  require('../../container-C6GtfAPW.js');
@@ -27,11 +27,12 @@ require('../../constants-BOOGN85p.js');
27
27
  require('../../EventWorkerContext-Dq29tieI.js');
28
28
  require('../../signals-ChFMD7mB.js');
29
29
  require('../../MessageCommandParser-CEuO6Ex3.js');
30
- require('../../CommandsRouter-DZAeB2v_.js');
31
- require('../../EventsRouter-Dzpm7ubq.js');
32
- require('../../router-DHnFRADH.js');
33
- require('../../common-DVM_onKu.js');
34
- require('../../CommandKitEventsChannel-B5vbINtP.js');
35
- require('../../store-Hcgz7DSt.js');
30
+ require('../../helpers-BSwwrKJW.js');
31
+ require('../../CommandsRouter-Cgcy6cK9.js');
32
+ require('../../EventsRouter-3Gygh-km.js');
33
+ require('../../router-Dn35v30f.js');
34
+ require('../../common-Dxr9-XPa.js');
35
+ require('../../CommandKitEventsChannel-BtRzr3Tz.js');
36
+ require('../../store-CM6pWVZh.js');
36
37
 
37
38
  exports.CommandKitPluginRuntime = require_commandkit.CommandKitPluginRuntime;
@@ -1,4 +1,4 @@
1
- import { CompilerPluginRuntime } from "../../analytics-engine-6_M8tCeD.js";
1
+ import { CompilerPluginRuntime } from "../../analytics-engine-B7JNRnEN.js";
2
2
  import "../../EventInterceptor-x-R2qshQ.js";
3
3
  import "../../ButtonKit-C7r7RPNf.js";
4
4
  import "../../ModalKit-Btz58KYn.js";
@@ -1,7 +1,7 @@
1
1
  require('../../colors-DL3ucTiT.js');
2
2
  require('../../ActionRow-CbdGFWMT.js');
3
3
  require('../../error-codes-Ds0bnPvT.js');
4
- const require_commandkit = require('../../commandkit-Dy4V-Rk2.js');
4
+ const require_commandkit = require('../../commandkit-Bm0gLN8i.js');
5
5
  require('../../common-CcfjYnPG.js');
6
6
  require('../../common-vnMIelAE.js');
7
7
  require('../../container-C6GtfAPW.js');
@@ -27,11 +27,12 @@ require('../../constants-BOOGN85p.js');
27
27
  require('../../EventWorkerContext-Dq29tieI.js');
28
28
  require('../../signals-ChFMD7mB.js');
29
29
  require('../../MessageCommandParser-CEuO6Ex3.js');
30
- require('../../CommandsRouter-DZAeB2v_.js');
31
- require('../../EventsRouter-Dzpm7ubq.js');
32
- require('../../router-DHnFRADH.js');
33
- require('../../common-DVM_onKu.js');
34
- require('../../CommandKitEventsChannel-B5vbINtP.js');
35
- require('../../store-Hcgz7DSt.js');
30
+ require('../../helpers-BSwwrKJW.js');
31
+ require('../../CommandsRouter-Cgcy6cK9.js');
32
+ require('../../EventsRouter-3Gygh-km.js');
33
+ require('../../router-Dn35v30f.js');
34
+ require('../../common-Dxr9-XPa.js');
35
+ require('../../CommandKitEventsChannel-BtRzr3Tz.js');
36
+ require('../../store-CM6pWVZh.js');
36
37
 
37
38
  exports.CompilerPluginRuntime = require_commandkit.CompilerPluginRuntime;
@@ -1,4 +1,4 @@
1
- import { CommonDirectiveTransformer, CommonDirectiveTransformerOptions } from "../../../analytics-engine-6_M8tCeD.js";
1
+ import { CommonDirectiveTransformer, CommonDirectiveTransformerOptions } from "../../../analytics-engine-B7JNRnEN.js";
2
2
  import "../../../EventInterceptor-x-R2qshQ.js";
3
3
  import "../../../ButtonKit-C7r7RPNf.js";
4
4
  import "../../../ModalKit-Btz58KYn.js";
@@ -1,7 +1,7 @@
1
1
  require('../../../colors-DL3ucTiT.js');
2
2
  require('../../../ActionRow-CbdGFWMT.js');
3
3
  require('../../../error-codes-Ds0bnPvT.js');
4
- const require_commandkit = require('../../../commandkit-Dy4V-Rk2.js');
4
+ const require_commandkit = require('../../../commandkit-Bm0gLN8i.js');
5
5
  require('../../../common-CcfjYnPG.js');
6
6
  require('../../../common-vnMIelAE.js');
7
7
  require('../../../container-C6GtfAPW.js');
@@ -27,11 +27,12 @@ require('../../../constants-BOOGN85p.js');
27
27
  require('../../../EventWorkerContext-Dq29tieI.js');
28
28
  require('../../../signals-ChFMD7mB.js');
29
29
  require('../../../MessageCommandParser-CEuO6Ex3.js');
30
- require('../../../CommandsRouter-DZAeB2v_.js');
31
- require('../../../EventsRouter-Dzpm7ubq.js');
32
- require('../../../router-DHnFRADH.js');
33
- require('../../../common-DVM_onKu.js');
34
- require('../../../CommandKitEventsChannel-B5vbINtP.js');
35
- require('../../../store-Hcgz7DSt.js');
30
+ require('../../../helpers-BSwwrKJW.js');
31
+ require('../../../CommandsRouter-Cgcy6cK9.js');
32
+ require('../../../EventsRouter-3Gygh-km.js');
33
+ require('../../../router-Dn35v30f.js');
34
+ require('../../../common-Dxr9-XPa.js');
35
+ require('../../../CommandKitEventsChannel-BtRzr3Tz.js');
36
+ require('../../../store-CM6pWVZh.js');
36
37
 
37
38
  exports.CommonDirectiveTransformer = require_commandkit.CommonDirectiveTransformer;
@@ -1,4 +1,4 @@
1
- import { CompilerPlugin, MaybeFalsey, PluginTransformParameters, TransformedResult } from "../../../analytics-engine-6_M8tCeD.js";
1
+ import { CompilerPlugin, MaybeFalsey, PluginTransformParameters, TransformedResult } from "../../../analytics-engine-B7JNRnEN.js";
2
2
  import "../../../EventInterceptor-x-R2qshQ.js";
3
3
  import "../../../ButtonKit-C7r7RPNf.js";
4
4
  import "../../../ModalKit-Btz58KYn.js";
@@ -1,7 +1,7 @@
1
1
  require('../../../colors-DL3ucTiT.js');
2
2
  require('../../../ActionRow-CbdGFWMT.js');
3
3
  require('../../../error-codes-Ds0bnPvT.js');
4
- const require_commandkit = require('../../../commandkit-Dy4V-Rk2.js');
4
+ const require_commandkit = require('../../../commandkit-Bm0gLN8i.js');
5
5
  require('../../../common-CcfjYnPG.js');
6
6
  require('../../../common-vnMIelAE.js');
7
7
  require('../../../container-C6GtfAPW.js');
@@ -27,11 +27,12 @@ require('../../../constants-BOOGN85p.js');
27
27
  require('../../../EventWorkerContext-Dq29tieI.js');
28
28
  require('../../../signals-ChFMD7mB.js');
29
29
  require('../../../MessageCommandParser-CEuO6Ex3.js');
30
- require('../../../CommandsRouter-DZAeB2v_.js');
31
- require('../../../EventsRouter-Dzpm7ubq.js');
32
- require('../../../router-DHnFRADH.js');
33
- require('../../../common-DVM_onKu.js');
34
- require('../../../CommandKitEventsChannel-B5vbINtP.js');
35
- require('../../../store-Hcgz7DSt.js');
30
+ require('../../../helpers-BSwwrKJW.js');
31
+ require('../../../CommandsRouter-Cgcy6cK9.js');
32
+ require('../../../EventsRouter-3Gygh-km.js');
33
+ require('../../../router-Dn35v30f.js');
34
+ require('../../../common-Dxr9-XPa.js');
35
+ require('../../../CommandKitEventsChannel-BtRzr3Tz.js');
36
+ require('../../../store-CM6pWVZh.js');
36
37
 
37
38
  exports.MacroPlugin = require_commandkit.MacroPlugin;