commandkit 1.2.0-dev.20260228005229 → 1.2.0-dev.20260301010539
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/{ActionRow-CT-uyxW0.d.ts → ActionRow-Bt9qi0Mb.d.ts} +2 -2
- package/dist/{Button-oMnlpF6W.d.ts → Button-DxJLcZIU.d.ts} +5 -5
- package/dist/{ButtonKit-DKu0VAe4.d.ts → ButtonKit-BfcyvWfj.d.ts} +35 -35
- package/dist/{ChannelSelectMenuKit-HQZ4hH5s.d.ts → ChannelSelectMenuKit-DYkudikb.d.ts} +33 -33
- package/dist/{CommandsRouter-C7dZEepB.d.ts → CommandsRouter-DiNoF0dq.d.ts} +48 -48
- package/dist/{EventInterceptor-CZmWpS08.d.ts → EventInterceptor-D9JKMcfi.d.ts} +39 -39
- package/dist/{EventsRouter-DZ37r54v.d.ts → EventsRouter-EuuSu6NH.d.ts} +34 -34
- package/dist/{MentionableSelectMenuKit-7URDUM3-.d.ts → MentionableSelectMenuKit-Mu4xqP6B.d.ts} +33 -33
- package/dist/MessageCommandParser-DPCbHXCS.d.ts +194 -0
- package/dist/{Modal--iMEUqSm.d.ts → Modal-v9rrcMl-.d.ts} +7 -7
- package/dist/{ModalKit-BWXI3Z26.d.ts → ModalKit-XJSM65SV.d.ts} +32 -32
- package/dist/{RoleSelectMenuKit-BY-JJ18w.d.ts → RoleSelectMenuKit-CCjcp3HY.d.ts} +33 -33
- package/dist/{SelectMenu-DQbmOp1Y.d.ts → SelectMenu-CY0vvoSu.d.ts} +8 -8
- package/dist/{StringSelectMenuKit-lVhUMc3g.d.ts → StringSelectMenuKit-G5nBTicX.d.ts} +33 -33
- package/dist/{UserSelectMenuKit-CCj4Fpkr.d.ts → UserSelectMenuKit-D3SO_fXA.d.ts} +33 -33
- package/dist/analytics/analytics-engine.d.ts +1 -1
- package/dist/analytics/analytics-engine.js +2 -19
- package/dist/analytics/analytics-provider.d.ts +1 -1
- package/dist/analytics/analytics-provider.js +1 -0
- package/dist/analytics/constants.js +26 -3
- package/dist/analytics/constants.js.map +1 -0
- package/dist/analytics/utils.js +2 -19
- package/dist/{analytics-engine-_urJ5QTH.d.ts → analytics-engine-DnRsHBId.d.ts} +843 -843
- package/dist/app/commands/AppCommandRunner.d.ts +1 -1
- package/dist/app/commands/AppCommandRunner.js +2 -19
- package/dist/app/commands/Context.d.ts +1 -1
- package/dist/app/commands/Context.js +2 -19
- package/dist/app/commands/MessageCommandParser.d.ts +1 -1
- package/dist/app/commands/MessageCommandParser.js +261 -3
- package/dist/app/commands/MessageCommandParser.js.map +1 -0
- package/dist/app/commands/helpers.d.ts +1 -1
- package/dist/app/commands/helpers.js +25 -3
- package/dist/app/commands/helpers.js.map +1 -0
- package/dist/app/events/EventWorkerContext.d.ts +2 -2
- package/dist/app/events/EventWorkerContext.js +48 -5
- package/dist/app/events/EventWorkerContext.js.map +1 -0
- package/dist/app/handlers/AppCommandHandler.d.ts +1 -1
- package/dist/app/handlers/AppCommandHandler.js +2 -19
- package/dist/app/handlers/AppEventsHandler.d.ts +1 -1
- package/dist/app/handlers/AppEventsHandler.js +2 -19
- package/dist/app/index.d.ts +4 -4
- package/dist/app/index.js +13 -27
- package/dist/app/interrupt/signals.d.ts +1 -1
- package/dist/app/interrupt/signals.js +54 -6
- package/dist/app/interrupt/signals.js.map +1 -0
- package/dist/app/middlewares/permissions.d.ts +1 -1
- package/dist/app/middlewares/permissions.js +2 -19
- package/dist/app/register/CommandRegistrar.d.ts +1 -1
- package/dist/app/register/CommandRegistrar.js +2 -19
- package/dist/app/router/CommandsRouter.d.ts +1 -1
- package/dist/app/router/CommandsRouter.js +210 -2
- package/dist/app/router/CommandsRouter.js.map +1 -0
- package/dist/app/router/EventsRouter.d.ts +1 -1
- package/dist/app/router/EventsRouter.js +128 -2
- package/dist/app/router/EventsRouter.js.map +1 -0
- package/dist/app/router/index.d.ts +2 -2
- package/dist/app/router/index.js +5 -5
- package/dist/{chunk-kSYXY2_d.js → chunk-BE-pF4vm.js} +1 -1
- package/dist/cli/app-process.d.ts +2 -2
- package/dist/cli/app-process.js +6 -8
- package/dist/cli/app-process.js.map +1 -1
- package/dist/cli/build.d.ts +2 -2
- package/dist/cli/build.js +14 -29
- package/dist/cli/build.js.map +1 -1
- package/dist/cli/common.d.ts +5 -5
- package/dist/cli/common.js +182 -12
- package/dist/cli/common.js.map +1 -0
- package/dist/cli/development.d.ts +3 -3
- package/dist/cli/development.js +38 -54
- package/dist/cli/development.js.map +1 -1
- package/dist/cli/env.js +73 -9
- package/dist/cli/env.js.map +1 -0
- package/dist/cli/generators.js +10 -10
- package/dist/cli/generators.js.map +1 -1
- package/dist/cli/information.js +9 -8
- package/dist/cli/information.js.map +1 -1
- package/dist/cli/init.d.ts +2 -2
- package/dist/cli/init.js +14 -28
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/production.d.ts +2 -2
- package/dist/cli/production.js +11 -28
- package/dist/cli/production.js.map +1 -1
- package/dist/cli/type-checker.js +83 -6
- package/dist/cli/type-checker.js.map +1 -0
- package/dist/cli/utils.js +1 -0
- package/dist/cli/utils.js.map +1 -1
- package/dist/{commandkit-B1_NP74k.js → commandkit--k6yDJEr.js} +192 -192
- package/dist/{commandkit-B1_NP74k.js.map → commandkit--k6yDJEr.js.map} +1 -1
- package/dist/commandkit.d.ts +1 -1
- package/dist/commandkit.js +2 -19
- package/dist/{common-DnwCYit8.d.ts → common-CCvvgnxi.d.ts} +2 -2
- package/dist/components/common/EventInterceptor.d.ts +1 -1
- package/dist/components/common/EventInterceptor.js +137 -2
- package/dist/components/common/EventInterceptor.js.map +1 -0
- package/dist/components/common/element.d.ts +1 -1
- package/dist/components/common/element.js +2 -19
- package/dist/components/common/types.d.ts +1 -1
- package/dist/components/common/types.js +1 -0
- package/dist/components/display/common.js +2 -19
- package/dist/components/display/container.d.ts +1 -1
- package/dist/components/display/container.js +2 -19
- package/dist/components/display/file.d.ts +1 -1
- package/dist/components/display/file.js +23 -2
- package/dist/components/display/file.js.map +1 -0
- package/dist/components/display/index.d.ts +8 -8
- package/dist/components/display/index.js +12 -25
- package/dist/components/display/label.d.ts +1 -1
- package/dist/components/display/label.js +2 -19
- package/dist/components/display/media-gallery.d.ts +1 -1
- package/dist/components/display/media-gallery.js +2 -19
- package/dist/components/display/poll.d.ts +1 -1
- package/dist/components/display/poll.js +85 -4
- package/dist/{poll-ziQQQbMU.js.map → components/display/poll.js.map} +1 -1
- package/dist/components/display/section.d.ts +1 -1
- package/dist/components/display/section.js +2 -19
- package/dist/components/display/separator.d.ts +1 -1
- package/dist/components/display/separator.js +21 -2
- package/dist/components/display/separator.js.map +1 -0
- package/dist/components/display/text-display.d.ts +1 -1
- package/dist/components/display/text-display.js +26 -2
- package/dist/components/display/text-display.js.map +1 -0
- package/dist/components/index.d.ts +22 -22
- package/dist/components/index.js +14 -26
- package/dist/components/interactive/action-row/ActionRow.d.ts +1 -1
- package/dist/components/interactive/action-row/ActionRow.js +20 -2
- package/dist/{ActionRow-CSN_UKmM.js.map → components/interactive/action-row/ActionRow.js.map} +1 -1
- package/dist/components/interactive/button/Button.d.ts +1 -1
- package/dist/components/interactive/button/Button.js +2 -19
- package/dist/components/interactive/button/ButtonKit.d.ts +1 -1
- package/dist/components/interactive/button/ButtonKit.js +2 -19
- package/dist/components/interactive/modal/Modal.d.ts +1 -1
- package/dist/components/interactive/modal/Modal.js +2 -19
- package/dist/components/interactive/modal/ModalKit.d.ts +1 -1
- package/dist/components/interactive/modal/ModalKit.js +2 -19
- package/dist/components/interactive/select-menu/ChannelSelectMenuKit.d.ts +1 -1
- package/dist/components/interactive/select-menu/ChannelSelectMenuKit.js +2 -19
- package/dist/components/interactive/select-menu/MentionableSelectMenuKit.d.ts +1 -1
- package/dist/components/interactive/select-menu/MentionableSelectMenuKit.js +2 -19
- package/dist/components/interactive/select-menu/RoleSelectMenuKit.d.ts +1 -1
- package/dist/components/interactive/select-menu/RoleSelectMenuKit.js +2 -19
- package/dist/components/interactive/select-menu/SelectMenu.d.ts +1 -1
- package/dist/components/interactive/select-menu/SelectMenu.js +2 -19
- package/dist/components/interactive/select-menu/StringSelectMenuKit.d.ts +1 -1
- package/dist/components/interactive/select-menu/StringSelectMenuKit.js +2 -19
- package/dist/components/interactive/select-menu/UserSelectMenuKit.d.ts +1 -1
- package/dist/components/interactive/select-menu/UserSelectMenuKit.js +2 -19
- package/dist/components/interactive/select-menu/common.d.ts +1 -1
- package/dist/components/interactive/select-menu/common.js +1 -0
- package/dist/config/config.d.ts +1 -1
- package/dist/config/config.js +2 -19
- package/dist/config/default.d.ts +1 -1
- package/dist/config/default.js +2 -19
- package/dist/config/loader.d.ts +1 -1
- package/dist/config/loader.js +2 -19
- package/dist/config/types.d.ts +1 -1
- package/dist/config/types.js +1 -0
- package/dist/config/utils.d.ts +1 -1
- package/dist/config/utils.js +29 -2
- package/dist/config/utils.js.map +1 -0
- package/dist/{constants-EpKcj0dH.d.ts → constants-DqtJY0t-.d.ts} +2 -2
- package/dist/{constants-CuYW0K10.d.ts → constants-DwxpkIeH.d.ts} +7 -7
- package/dist/{container-DYcb7zGw.d.ts → container-CYojOA9d.d.ts} +1 -1
- package/dist/context/async-context.d.ts +1 -1
- package/dist/context/async-context.js +2 -19
- package/dist/context/environment.d.ts +1 -1
- package/dist/context/environment.js +2 -19
- package/dist/{element-DZeqbSTk.d.ts → element-DeLvTMfZ.d.ts} +3 -3
- package/dist/events/CommandKitEventsChannel.d.ts +1 -1
- package/dist/events/CommandKitEventsChannel.js +83 -2
- package/dist/events/CommandKitEventsChannel.js.map +1 -0
- package/dist/{file-CrV4lSnl.d.ts → file-DLO1zEcH.d.ts} +1 -1
- package/dist/flags/FlagProvider.d.ts +1 -1
- package/dist/flags/FlagProvider.js +1 -0
- package/dist/flags/FlagProvider.js.map +1 -1
- package/dist/flags/feature-flags.d.ts +1 -1
- package/dist/flags/feature-flags.js +2 -19
- package/dist/flags/store.d.ts +1 -1
- package/dist/flags/store.js +13 -2
- package/dist/flags/store.js.map +1 -0
- package/dist/{helpers-AQPLVY35.d.ts → helpers-zmC44Mcu.d.ts} +1 -1
- package/dist/index.d.ts +30 -30
- package/dist/index.js +61 -67
- package/dist/kv/constants.d.ts +1 -1
- package/dist/kv/constants.js +22 -2
- package/dist/kv/constants.js.map +1 -0
- package/dist/kv/dotprops.js +1 -0
- package/dist/kv/dotprops.js.map +1 -1
- package/dist/kv/kv.d.ts +288 -288
- package/dist/kv/kv.js +2 -1
- package/dist/kv/kv.js.map +1 -1
- package/dist/kv/serde.d.ts +1 -1
- package/dist/kv/serde.js +29 -28
- package/dist/kv/serde.js.map +1 -1
- package/dist/{label-37kaNWMH.d.ts → label-DqGRqodo.d.ts} +3 -3
- package/dist/logger/DefaultLogger.d.ts +19 -19
- package/dist/logger/DefaultLogger.js +2 -19
- package/dist/logger/ILogger.d.ts +35 -35
- package/dist/logger/ILogger.js +1 -0
- package/dist/logger/Logger.d.ts +5 -5
- package/dist/logger/Logger.js +2 -19
- package/dist/logger/NoopLogger.d.ts +35 -35
- package/dist/logger/NoopLogger.js +1 -0
- package/dist/logger/NoopLogger.js.map +1 -1
- package/dist/{media-gallery-Ci3I4ElH.d.ts → media-gallery-Ca8es-eB.d.ts} +1 -1
- package/dist/plugins/CompilerPlugin.d.ts +1 -1
- package/dist/plugins/CompilerPlugin.js +33 -3
- package/dist/plugins/CompilerPlugin.js.map +1 -0
- package/dist/plugins/PluginCommon.d.ts +1 -1
- package/dist/plugins/PluginCommon.js +55 -4
- package/dist/plugins/PluginCommon.js.map +1 -0
- package/dist/plugins/RuntimePlugin.d.ts +1 -1
- package/dist/plugins/RuntimePlugin.js +124 -3
- package/dist/plugins/RuntimePlugin.js.map +1 -0
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.js +8 -25
- package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.d.ts +1 -1
- package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.js +2 -19
- package/dist/plugins/plugin-runtime/CompilerPluginRuntime.d.ts +1 -1
- package/dist/plugins/plugin-runtime/CompilerPluginRuntime.js +2 -19
- package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.d.ts +1 -1
- package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.js +2 -19
- package/dist/plugins/plugin-runtime/builtin/MacroPlugin.d.ts +1 -1
- package/dist/plugins/plugin-runtime/builtin/MacroPlugin.js +2 -19
- package/dist/plugins/plugin-runtime/runtime.d.ts +1 -1
- package/dist/plugins/plugin-runtime/runtime.js +1 -0
- package/dist/plugins/types.d.ts +1 -1
- package/dist/plugins/types.js +1 -0
- package/dist/{poll-Ddtapd6n.d.ts → poll-DQ6DX_Tt.d.ts} +8 -8
- package/dist/{section-DkUKULnB.d.ts → section-Q8nwx_-q.d.ts} +1 -1
- package/dist/{separator-CbXsIFCa.d.ts → separator-B8P-kdIK.d.ts} +1 -1
- package/dist/{signals-BbTgTc0i.d.ts → signals-CBXwugBW.d.ts} +1 -1
- package/dist/{text-display-D7j39VC-.d.ts → text-display-CL9C2yMc.d.ts} +1 -1
- package/dist/{types-BywA9d2Z.d.ts → types-DZy7U-Ld.d.ts} +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -0
- package/dist/utils/colors.js +9 -3
- package/dist/utils/colors.js.map +1 -0
- package/dist/utils/constants.d.ts +1 -1
- package/dist/utils/constants.js +50 -8
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/dev-hooks.d.ts +1 -1
- package/dist/utils/dev-hooks.js +2 -19
- package/dist/utils/error-codes.d.ts +10 -10
- package/dist/utils/error-codes.js +53 -5
- package/dist/utils/error-codes.js.map +1 -0
- package/dist/utils/resolve-file-url.js +18 -2
- package/dist/utils/resolve-file-url.js.map +1 -0
- package/dist/utils/types-package.js +61 -4
- package/dist/utils/types-package.js.map +1 -0
- package/dist/utils/useful-stuff/async-queue.d.ts +21 -21
- package/dist/utils/useful-stuff/async-queue.js +1 -0
- package/dist/utils/useful-stuff/async-queue.js.map +1 -1
- package/dist/utils/useful-stuff/mutex.d.ts +62 -62
- package/dist/utils/useful-stuff/mutex.js +1 -0
- package/dist/utils/useful-stuff/mutex.js.map +1 -1
- package/dist/utils/useful-stuff/ratelimiter.d.ts +56 -56
- package/dist/utils/useful-stuff/ratelimiter.js +1 -0
- package/dist/utils/useful-stuff/ratelimiter.js.map +1 -1
- package/dist/utils/useful-stuff/semaphore.d.ts +82 -82
- package/dist/utils/useful-stuff/semaphore.js +1 -0
- package/dist/utils/useful-stuff/semaphore.js.map +1 -1
- package/dist/utils/utilities.d.ts +5 -5
- package/dist/utils/utilities.js +2 -19
- package/dist/utils/warning.js +38 -4
- package/dist/utils/warning.js.map +1 -0
- package/dist/version.js +13 -2
- package/dist/version.js.map +1 -0
- package/package.json +11 -14
- package/dist/ActionRow-CSN_UKmM.js +0 -25
- package/dist/CommandKitEventsChannel-DDI0UVh9.js +0 -88
- package/dist/CommandKitEventsChannel-DDI0UVh9.js.map +0 -1
- package/dist/CommandsRouter-D5mGRFEr.js +0 -215
- package/dist/CommandsRouter-D5mGRFEr.js.map +0 -1
- package/dist/CompilerPlugin-DZidFuHJ.js +0 -43
- package/dist/CompilerPlugin-DZidFuHJ.js.map +0 -1
- package/dist/EventInterceptor-CxA95XYA.js +0 -142
- package/dist/EventInterceptor-CxA95XYA.js.map +0 -1
- package/dist/EventWorkerContext-CfqamFWu.js +0 -68
- package/dist/EventWorkerContext-CfqamFWu.js.map +0 -1
- package/dist/EventsRouter-Be5NDOX4.js +0 -133
- package/dist/EventsRouter-Be5NDOX4.js.map +0 -1
- package/dist/ILogger-JI8VGyJf.js +0 -0
- package/dist/MessageCommandParser-VMFFGs0R.js +0 -271
- package/dist/MessageCommandParser-VMFFGs0R.js.map +0 -1
- package/dist/MessageCommandParser-q3dQcE5N.d.ts +0 -194
- package/dist/PluginCommon-Bfs8d9s7.js +0 -70
- package/dist/PluginCommon-Bfs8d9s7.js.map +0 -1
- package/dist/RuntimePlugin-BYQXQO8w.js +0 -134
- package/dist/RuntimePlugin-BYQXQO8w.js.map +0 -1
- package/dist/colors-Csc0X4QJ.js +0 -14
- package/dist/colors-Csc0X4QJ.js.map +0 -1
- package/dist/common-vGj3fpz3.js +0 -0
- package/dist/common-zQwj90Nz.js +0 -222
- package/dist/common-zQwj90Nz.js.map +0 -1
- package/dist/constants-BA0TJU6e.js +0 -36
- package/dist/constants-BA0TJU6e.js.map +0 -1
- package/dist/constants-BS9N2avz.js +0 -27
- package/dist/constants-BS9N2avz.js.map +0 -1
- package/dist/constants-CeIMhMD0.js +0 -85
- package/dist/constants-CeIMhMD0.js.map +0 -1
- package/dist/env-FxaiNasU.js +0 -113
- package/dist/env-FxaiNasU.js.map +0 -1
- package/dist/error-codes-Ds0bnPvT.js +0 -73
- package/dist/error-codes-Ds0bnPvT.js.map +0 -1
- package/dist/file-DqI3v90P.js +0 -28
- package/dist/file-DqI3v90P.js.map +0 -1
- package/dist/helpers-DSy7EjzP.js +0 -35
- package/dist/helpers-DSy7EjzP.js.map +0 -1
- package/dist/poll-ziQQQbMU.js +0 -100
- package/dist/resolve-file-url-BmjHzIKe.js +0 -23
- package/dist/resolve-file-url-BmjHzIKe.js.map +0 -1
- package/dist/router-CtcApqrw.js +0 -0
- package/dist/runtime-UJIpkNww.js +0 -0
- package/dist/separator-DGwA_b1J.js +0 -26
- package/dist/separator-DGwA_b1J.js.map +0 -1
- package/dist/signals-ewEPW2cO.js +0 -74
- package/dist/signals-ewEPW2cO.js.map +0 -1
- package/dist/store-DK4JA-fQ.js +0 -18
- package/dist/store-DK4JA-fQ.js.map +0 -1
- package/dist/text-display-BVuG7dT-.js +0 -31
- package/dist/text-display-BVuG7dT-.js.map +0 -1
- package/dist/type-checker-CFpKDDs8.js +0 -88
- package/dist/type-checker-CFpKDDs8.js.map +0 -1
- package/dist/types-Bx1EKe0v.js +0 -0
- package/dist/types-CAwOz52q.js +0 -0
- package/dist/types-package-Bjh_ap0V.js +0 -71
- package/dist/types-package-Bjh_ap0V.js.map +0 -1
- package/dist/utils-CVaVycsK.js +0 -34
- package/dist/utils-CVaVycsK.js.map +0 -1
- package/dist/version-DJ8LkIWx.js +0 -18
- package/dist/version-DJ8LkIWx.js.map +0 -1
- package/dist/warning-BWiQltHE.js +0 -53
- package/dist/warning-BWiQltHE.js.map +0 -1
- /package/dist/{index-BJfko-dP.d.ts → index-BIsCUWAs.d.ts} +0 -0
- /package/dist/{index-CCggO_hw.d.ts → index-CwHYpK-f.d.ts} +0 -0
- /package/dist/{index-CLjpoGi1.d.ts → index-DHrsNvX1.d.ts} +0 -0
package/dist/utils/constants.js
CHANGED
|
@@ -1,9 +1,51 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
//#region src/utils/constants.ts
|
|
4
|
+
/**
|
|
5
|
+
* The current working directory of the CommandKit instance.
|
|
6
|
+
*/
|
|
7
|
+
const COMMANDKIT_CWD = process.env.COMMANDKIT_CWD || process.cwd();
|
|
8
|
+
/**
|
|
9
|
+
* Indicates whether CommandKit is running in development mode.
|
|
10
|
+
*/
|
|
11
|
+
const COMMANDKIT_IS_DEV = process.env.COMMANDKIT_IS_DEV === "true";
|
|
12
|
+
/**
|
|
13
|
+
* Indicates whether CommandKit is running in CLI thread.
|
|
14
|
+
*/
|
|
15
|
+
const COMMANDKIT_IS_CLI = process.env.COMMANDKIT_IS_CLI === "true";
|
|
16
|
+
/**
|
|
17
|
+
* Indicates whether CommandKit is running in test mode.
|
|
18
|
+
*/
|
|
19
|
+
const COMMANDKIT_IS_TEST = process.env.COMMANDKIT_IS_TEST === "true";
|
|
20
|
+
/**
|
|
21
|
+
* Indicates that CommandKit is running in a build-like environment.
|
|
22
|
+
* @private
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
function isBuildLikeEnvironment() {
|
|
26
|
+
if (process.env.COMMANDKIT_INTERNAL_IS_CLI_PROCESS === "true") return true;
|
|
27
|
+
return process.env.COMMANDKIT_IS_BUILD === "true";
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The current bootstrap mode of CommandKit.
|
|
31
|
+
* This can be 'development' or 'production'.
|
|
32
|
+
*/
|
|
33
|
+
const COMMANDKIT_BOOTSTRAP_MODE = process.env.COMMANDKIT_BOOTSTRAP_MODE || "development";
|
|
34
|
+
/**
|
|
35
|
+
* Types of Hot Module Replacement events
|
|
36
|
+
*/
|
|
37
|
+
const HMREventType = {
|
|
38
|
+
ReloadCommands: "reload-commands",
|
|
39
|
+
ReloadEvents: "reload-events",
|
|
40
|
+
Unknown: "unknown"
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
exports.COMMANDKIT_BOOTSTRAP_MODE = COMMANDKIT_BOOTSTRAP_MODE;
|
|
45
|
+
exports.COMMANDKIT_CWD = COMMANDKIT_CWD;
|
|
46
|
+
exports.COMMANDKIT_IS_CLI = COMMANDKIT_IS_CLI;
|
|
47
|
+
exports.COMMANDKIT_IS_DEV = COMMANDKIT_IS_DEV;
|
|
48
|
+
exports.COMMANDKIT_IS_TEST = COMMANDKIT_IS_TEST;
|
|
49
|
+
exports.HMREventType = HMREventType;
|
|
50
|
+
exports.isBuildLikeEnvironment = isBuildLikeEnvironment;
|
|
51
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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 * The type for HMR events.\n */\nexport type HMREventType = (typeof HMREventType)[keyof typeof HMREventType];\n"],"mappings":";;;;;;AAGA,MAAa,iBAAiB,QAAQ,IAAI,kBAAkB,QAAQ,KAAK;;;;AAKzE,MAAa,oBAAoB,QAAQ,IAAI,sBAAsB;;;;AAKnE,MAAa,oBAAoB,QAAQ,IAAI,sBAAsB;;;;AAKnE,MAAa,qBAAqB,QAAQ,IAAI,uBAAuB;;;;;;AAOrE,SAAgB,yBAAyB;AAEvC,KADc,QAAQ,IAAI,uCAAuC,OACtD,QAAO;AAElB,QAAO,QAAQ,IAAI,wBAAwB;;;;;;AAO7C,MAAa,4BAA6B,QAAQ,IAClD,6BAA6B;;;;AAK7B,MAAa,eAAe;CAI1B,gBAAgB;CAIhB,cAAc;CAId,SAAS;CACV"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { et as CommandKitHMREvent, nt as registerDevHooks, tt as IpcMessageCommand } from "../analytics-engine-
|
|
1
|
+
import { et as CommandKitHMREvent, nt as registerDevHooks, tt as IpcMessageCommand } from "../analytics-engine-DnRsHBId.js";
|
|
2
2
|
export { CommandKitHMREvent, IpcMessageCommand, registerDevHooks };
|
package/dist/utils/dev-hooks.js
CHANGED
|
@@ -1,21 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
require('../
|
|
3
|
-
const require_commandkit = require('../commandkit-B1_NP74k.js');
|
|
4
|
-
require('../constants-CeIMhMD0.js');
|
|
5
|
-
require('../types-package-Bjh_ap0V.js');
|
|
6
|
-
require('../constants-BA0TJU6e.js');
|
|
7
|
-
require('../EventWorkerContext-CfqamFWu.js');
|
|
8
|
-
require('../signals-ewEPW2cO.js');
|
|
9
|
-
require('../helpers-DSy7EjzP.js');
|
|
10
|
-
require('../MessageCommandParser-VMFFGs0R.js');
|
|
11
|
-
require('../CommandsRouter-D5mGRFEr.js');
|
|
12
|
-
require('../EventsRouter-Be5NDOX4.js');
|
|
13
|
-
require('../router-CtcApqrw.js');
|
|
14
|
-
require('../file-DqI3v90P.js');
|
|
15
|
-
require('../separator-DGwA_b1J.js');
|
|
16
|
-
require('../text-display-BVuG7dT-.js');
|
|
17
|
-
require('../poll-ziQQQbMU.js');
|
|
18
|
-
require('../common-zQwj90Nz.js');
|
|
19
|
-
require('../store-DK4JA-fQ.js');
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_commandkit = require('../commandkit--k6yDJEr.js');
|
|
20
3
|
|
|
21
4
|
exports.registerDevHooks = require_commandkit.registerDevHooks;
|
|
@@ -4,24 +4,24 @@
|
|
|
4
4
|
*/
|
|
5
5
|
declare const CommandKitErrorCodes: {
|
|
6
6
|
/**
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
* Error code for exiting middleware.
|
|
8
|
+
*/
|
|
9
9
|
readonly StopMiddlewares: symbol;
|
|
10
10
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
* Error code for forwarded commands.
|
|
12
|
+
*/
|
|
13
13
|
readonly ForwardedCommand: symbol;
|
|
14
14
|
/**
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
* Error code for invalid command prefix.
|
|
16
|
+
*/
|
|
17
17
|
readonly InvalidCommandPrefix: symbol;
|
|
18
18
|
/**
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
* Error code for plugin capture handle.
|
|
20
|
+
*/
|
|
21
21
|
readonly PluginCaptureHandle: symbol;
|
|
22
22
|
/**
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
* Error code for event interruption signal
|
|
24
|
+
*/
|
|
25
25
|
readonly StopEvents: symbol;
|
|
26
26
|
};
|
|
27
27
|
/**
|
|
@@ -1,6 +1,54 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
//#region src/utils/error-codes.ts
|
|
4
|
+
/**
|
|
5
|
+
* The error codes used by CommandKit.
|
|
6
|
+
*/
|
|
7
|
+
const CommandKitErrorCodes = {
|
|
8
|
+
StopMiddlewares: Symbol("kStopMiddlewares"),
|
|
9
|
+
ForwardedCommand: Symbol("kForwardedCommand"),
|
|
10
|
+
InvalidCommandPrefix: Symbol("kInvalidCommandPrefix"),
|
|
11
|
+
PluginCaptureHandle: Symbol("kPluginCaptureHandle"),
|
|
12
|
+
StopEvents: Symbol("kStopEvents")
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new CommandKit error with the specified code.
|
|
16
|
+
* @param code The error code to assign to the error.
|
|
17
|
+
* @returns A new CommandKit error instance.
|
|
18
|
+
*/
|
|
19
|
+
function createCommandKitError(code) {
|
|
20
|
+
const error = /* @__PURE__ */ new Error();
|
|
21
|
+
Reflect.set(error, "code", code);
|
|
22
|
+
return error;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Checks if the given error is a CommandKit error.
|
|
26
|
+
* @param error The error to check.
|
|
27
|
+
* @returns True if the error is a CommandKit error, false otherwise.
|
|
28
|
+
*/
|
|
29
|
+
function isCommandKitError(error) {
|
|
30
|
+
if (!(error instanceof Error)) return false;
|
|
31
|
+
const code = Reflect.get(error, "code");
|
|
32
|
+
for (const key in CommandKitErrorCodes) if (CommandKitErrorCodes[key] === code) return true;
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Checks if the given error is of a specific CommandKit error type.
|
|
37
|
+
* @param error The error to check.
|
|
38
|
+
* @param code The error code or an array of error codes to check against.
|
|
39
|
+
* @returns True if the error matches the specified code(s), false otherwise.
|
|
40
|
+
*/
|
|
41
|
+
function isErrorType(error, code) {
|
|
42
|
+
if (!isCommandKitError(error)) return false;
|
|
43
|
+
const errorCode = Reflect.get(error, "code");
|
|
44
|
+
if (!errorCode) return false;
|
|
45
|
+
if (Array.isArray(code)) return code.includes(errorCode);
|
|
46
|
+
return errorCode === code;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
exports.CommandKitErrorCodes = CommandKitErrorCodes;
|
|
51
|
+
exports.createCommandKitError = createCommandKitError;
|
|
52
|
+
exports.isCommandKitError = isCommandKitError;
|
|
53
|
+
exports.isErrorType = isErrorType;
|
|
54
|
+
//# sourceMappingURL=error-codes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,mBAAmB;CAI3C,kBAAkB,OAAO,oBAAoB;CAI7C,sBAAsB,OAAO,wBAAwB;CAIrD,qBAAqB,OAAO,uBAAuB;CAInD,YAAY,OAAO,cAAc;CAClC;;;;;;AAYD,SAAgB,sBAAsB,MAA+B;CACnE,MAAM,wBAAQ,IAAI,OAAO;AAEzB,SAAQ,IAAI,OAAO,QAAQ,KAAK;AAEhC,QAAO;;;;;;;AAQT,SAAgB,kBAAkB,OAA0C;AAC1E,KAAI,EAAE,iBAAiB,OAAQ,QAAO;CACtC,MAAM,OAAO,QAAQ,IAAI,OAAO,OAAO;AAEvC,MAAK,MAAM,OAAO,qBAChB,KAAI,qBAAqB,SAA8C,KACvE,QAAE;AAGJ,QAAO;;;;;;;;AAST,SAAgB,YAAY,OAAgB,MAAkC;AAC5E,KAAI,CAAC,kBAAkB,MAAM,CAAE,QAAO;CACtC,MAAM,YAAY,QAAQ,IAAI,OAAO,OAAO;AAE5C,KAAI,CAAC,UAAW,QAAO;AAEvB,KAAI,MAAM,QAAQ,KAAK,CAAE,QAAO,KAAK,SAAS,UAAU;AAExD,QAAO,cAAc"}
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_chunk = require('../chunk-BE-pF4vm.js');
|
|
3
|
+
let path = require("path");
|
|
4
|
+
path = require_chunk.__toESM(path);
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
//#region src/utils/resolve-file-url.ts
|
|
7
|
+
/**
|
|
8
|
+
* Convert a local file path to a file URL.
|
|
9
|
+
* @param filePath - The local file's path.
|
|
10
|
+
* @param withTs - Whether to append a timestamp to the URL.
|
|
11
|
+
* @returns - The converted file URL.
|
|
12
|
+
*/
|
|
13
|
+
function toFileURL(filePath, withTs = false) {
|
|
14
|
+
return `${"file://" + path.default.resolve(filePath).replace(/\\\\|\\/g, "/")}${withTs ? `?ts=${Date.now()}` : ""}`;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
exports.toFileURL = toFileURL;
|
|
19
|
+
//# sourceMappingURL=resolve-file-url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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;AAE1D,QAAO,GAAG,YADW,aAAK,QAAQ,SAAS,CACR,QAAQ,YAAY,IAAI,GAAG,SAAS,OAAO,KAAK,KAAK,KAAK"}
|
|
@@ -1,5 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_chunk = require('../chunk-BE-pF4vm.js');
|
|
3
|
+
const require_utils_constants = require('./constants.js');
|
|
4
|
+
let node_fs = require("node:fs");
|
|
5
|
+
let node_path = require("node:path");
|
|
6
|
+
let node_fs_promises = require("node:fs/promises");
|
|
3
7
|
|
|
4
|
-
|
|
5
|
-
|
|
8
|
+
//#region src/utils/types-package.ts
|
|
9
|
+
/**
|
|
10
|
+
* @private
|
|
11
|
+
*/
|
|
12
|
+
async function generateTypesPackage(force = false) {
|
|
13
|
+
const location = (0, node_path.join)(require_utils_constants.COMMANDKIT_CWD, "node_modules", "commandkit-types");
|
|
14
|
+
if (!require_utils_constants.COMMANDKIT_IS_DEV && !force) return location;
|
|
15
|
+
const packageJSON = (0, node_path.join)(location, "package.json");
|
|
16
|
+
const index = (0, node_path.join)(location, "index.js");
|
|
17
|
+
const types = (0, node_path.join)(location, "index.d.ts");
|
|
18
|
+
const command = (0, node_path.join)(location, "command.d.ts");
|
|
19
|
+
const packageJSONContent = {
|
|
20
|
+
name: "commandkit-types",
|
|
21
|
+
version: "1.0.0",
|
|
22
|
+
description: "CommandKit types package",
|
|
23
|
+
type: "commonjs",
|
|
24
|
+
main: "index.js",
|
|
25
|
+
types: "index.d.ts"
|
|
26
|
+
};
|
|
27
|
+
const indexContent = `module.exports = {};`;
|
|
28
|
+
const typesContent = `// Main types index file - imports all type declarations
|
|
29
|
+
import './command';
|
|
30
|
+
export {};
|
|
31
|
+
`;
|
|
32
|
+
const commandTypesContent = `// Auto-generated command types
|
|
33
|
+
export {};
|
|
34
|
+
declare module 'commandkit' {
|
|
35
|
+
type CommandTypeData = string
|
|
36
|
+
}`;
|
|
37
|
+
await (0, node_fs_promises.mkdir)(location, { recursive: true }).catch(() => {});
|
|
38
|
+
await (0, node_fs_promises.writeFile)(packageJSON, JSON.stringify(packageJSONContent, null, 2));
|
|
39
|
+
await (0, node_fs_promises.writeFile)(index, indexContent);
|
|
40
|
+
await (0, node_fs_promises.writeFile)(types, typesContent);
|
|
41
|
+
await (0, node_fs_promises.writeFile)(command, commandTypesContent);
|
|
42
|
+
return location;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* @private
|
|
46
|
+
*/
|
|
47
|
+
async function rewriteCommandDeclaration(data) {
|
|
48
|
+
const commandTypesContent = `// Auto-generated command types
|
|
49
|
+
declare module 'commandkit' {
|
|
50
|
+
${data}
|
|
51
|
+
}
|
|
52
|
+
export {};
|
|
53
|
+
`;
|
|
54
|
+
const location = (0, node_path.join)(require_utils_constants.COMMANDKIT_CWD, "node_modules", "commandkit-types");
|
|
55
|
+
if (!(0, node_fs.existsSync)(location)) return;
|
|
56
|
+
await (0, node_fs_promises.writeFile)((0, node_path.join)(location, "command.d.ts"), commandTypesContent, { encoding: "utf-8" });
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
exports.generateTypesPackage = generateTypesPackage;
|
|
61
|
+
exports.rewriteCommandDeclaration = rewriteCommandDeclaration;
|
|
62
|
+
//# sourceMappingURL=types-package.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-package.js","names":[],"sources":["../../src/utils/types-package.ts"],"sourcesContent":["import { mkdir, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { COMMANDKIT_CWD, COMMANDKIT_IS_DEV } from './constants';\nimport { existsSync } from 'node:fs';\n\n/**\n * @private\n */\nexport async function generateTypesPackage(force = false) {\n const location = join(COMMANDKIT_CWD, 'node_modules', 'commandkit-types');\n if (!COMMANDKIT_IS_DEV && !force) return location;\n const packageJSON = join(location, 'package.json');\n const index = join(location, 'index.js');\n const types = join(location, 'index.d.ts');\n const command = join(location, 'command.d.ts');\n\n const packageJSONContent = {\n name: 'commandkit-types',\n version: '1.0.0',\n description: 'CommandKit types package',\n type: 'commonjs',\n main: 'index.js',\n types: 'index.d.ts',\n };\n\n const indexContent = `module.exports = {};`;\n\n // Restructuring the type declarations to properly extend rather than replace types\n const typesContent = `// Main types index file - imports all type declarations\nimport './command';\nexport {};\n`;\n\n // Properly set up command types to extend the CommandTypeData interface\n const commandTypesContent = `// Auto-generated command types\n export {};\ndeclare module 'commandkit' {\n type CommandTypeData = string\n}`;\n\n await mkdir(location, { recursive: true }).catch(() => {});\n await writeFile(packageJSON, JSON.stringify(packageJSONContent, null, 2));\n await writeFile(index, indexContent);\n await writeFile(types, typesContent);\n await writeFile(command, commandTypesContent);\n\n return location;\n}\n\n/**\n * @private\n */\nexport async function rewriteCommandDeclaration(data: string) {\n const commandTypesContent = `// Auto-generated command types\n declare module 'commandkit' {\n ${data}\n}\n export {};\n`;\n\n const location = join(COMMANDKIT_CWD, 'node_modules', 'commandkit-types');\n\n if (!existsSync(location)) return;\n\n const type = join(location, 'command.d.ts');\n\n await writeFile(type, commandTypesContent, { encoding: 'utf-8' });\n}\n"],"mappings":";;;;;;;;;;;AAQA,eAAsB,qBAAqB,QAAQ,OAAO;CACxD,MAAM,+BAAgB,wCAAgB,gBAAgB,mBAAmB;AACzE,KAAI,CAAC,6CAAqB,CAAC,MAAO,QAAO;CACzC,MAAM,kCAAmB,UAAU,eAAe;CAClD,MAAM,4BAAa,UAAU,WAAW;CACxC,MAAM,4BAAa,UAAU,aAAa;CAC1C,MAAM,8BAAe,UAAU,eAAe;CAE9C,MAAM,qBAAqB;EACzB,MAAM;EACN,SAAS;EACT,aAAa;EACb,MAAM;EACN,MAAM;EACN,OAAO;EACR;CAED,MAAM,eAAe;CAGrB,MAAM,eAAe;;;;CAMrB,MAAM,sBAAsB;;;;;AAM5B,mCAAY,UAAU,EAAE,WAAW,MAAM,CAAC,CAAC,YAAY,GAAG;AAC1D,uCAAgB,aAAa,KAAK,UAAU,oBAAoB,MAAM,EAAE,CAAC;AACzE,uCAAgB,OAAO,aAAa;AACpC,uCAAgB,OAAO,aAAa;AACpC,uCAAgB,SAAS,oBAAoB;AAE7C,QAAO;;;;;AAMT,eAAsB,0BAA0B,MAAc;CAC5D,MAAM,sBAAsB;;MAExB,KAAI;;;;CAKR,MAAM,+BAAgB,wCAAgB,gBAAgB,mBAAmB;AAEzE,KAAI,yBAAY,SAAS,CAAE;AAI3B,2DAFkB,UAAU,eAAe,EAErB,qBAAqB,EAAE,UAAU,SAAS,CAAC"}
|
|
@@ -22,43 +22,43 @@ declare class AsyncQueue {
|
|
|
22
22
|
private queue;
|
|
23
23
|
constructor(options?: AsyncQueueOptions);
|
|
24
24
|
/**
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
* Adds a task to the queue.
|
|
26
|
+
* @param task - The async function to execute.
|
|
27
|
+
* @param signal - Optional AbortSignal for cancelling this specific task.
|
|
28
|
+
* @returns Promise resolving to the result of the task.
|
|
29
|
+
*/
|
|
30
30
|
add<T>(task: AsyncQueueTask<T>, signal?: AbortSignal): Promise<T>;
|
|
31
31
|
/**
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
* Pauses the queue. No new tasks will be started until resumed.
|
|
33
|
+
*/
|
|
34
34
|
pause(): void;
|
|
35
35
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
* Resumes the queue and processes pending tasks.
|
|
37
|
+
*/
|
|
38
38
|
resume(): void;
|
|
39
39
|
/**
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
* Aborts the queue, rejecting all pending tasks.
|
|
41
|
+
*/
|
|
42
42
|
abort(): void;
|
|
43
43
|
/**
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
* Clears all pending tasks from the queue.
|
|
45
|
+
*/
|
|
46
46
|
clear(): void;
|
|
47
47
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
* Returns the number of running tasks.
|
|
49
|
+
*/
|
|
50
50
|
getRunning(): number;
|
|
51
51
|
/**
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
* Returns the number of pending tasks in the queue.
|
|
53
|
+
*/
|
|
54
54
|
getPending(): number;
|
|
55
55
|
/**
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
* Returns true if the queue is currently paused.
|
|
57
|
+
*/
|
|
58
58
|
isPaused(): boolean;
|
|
59
59
|
/**
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
* Returns true if the queue has been aborted.
|
|
61
|
+
*/
|
|
62
62
|
isAborted(): boolean;
|
|
63
63
|
private next;
|
|
64
64
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async-queue.js","names":[],"sources":["../../../src/utils/useful-stuff/async-queue.ts"],"sourcesContent":["/**\n * Async queue implementation for processing tasks sequentially or with limited concurrency.\n * Useful for rate-limiting, batching, or controlling resource usage.\n */\n\nexport interface AsyncQueueOptions {\n /** Maximum number of concurrent tasks. Default: 1 (sequential) */\n concurrency?: number;\n /** Optional callback invoked when all tasks are completed */\n onDrain?: () => void | Promise<void>;\n /** Optional AbortSignal for cancelling the queue */\n signal?: AbortSignal;\n}\n\nexport type AsyncQueueTask<T> = () => Promise<T>;\n\nexport class AsyncQueue {\n private readonly concurrency: number;\n private readonly onDrain?: () => void | Promise<void>;\n private readonly signal?: AbortSignal;\n private running = 0;\n private paused = false;\n private aborted = false;\n private queue: Array<() => void> = [];\n\n constructor(options: AsyncQueueOptions = {}) {\n this.concurrency = options.concurrency ?? 1;\n this.onDrain = options.onDrain;\n this.signal = options.signal;\n\n if (this.signal) {\n this.signal.addEventListener('abort', () => {\n this.abort();\n });\n }\n }\n\n /**\n * Adds a task to the queue.\n * @param task - The async function to execute.\n * @param signal - Optional AbortSignal for cancelling this specific task.\n * @returns Promise resolving to the result of the task.\n */\n public add<T>(task: AsyncQueueTask<T>, signal?: AbortSignal): Promise<T> {\n if (this.aborted) {\n return Promise.reject(new Error('Queue has been aborted'));\n }\n\n return new Promise<T>((resolve, reject) => {\n const run = async () => {\n if (this.paused || this.aborted) {\n if (this.aborted) {\n reject(new Error('Queue has been aborted'));\n } else {\n this.queue.push(run);\n }\n return;\n }\n\n // Check if task-specific signal is aborted\n if (signal?.aborted) {\n reject(new Error('Task was aborted'));\n return;\n }\n\n this.running++;\n try {\n const result = await task();\n resolve(result);\n } catch (err) {\n reject(err);\n } finally {\n this.running--;\n this.next();\n }\n };\n\n if (this.running < this.concurrency && !this.paused && !this.aborted) {\n run();\n } else {\n this.queue.push(run);\n }\n });\n }\n\n /**\n * Pauses the queue. No new tasks will be started until resumed.\n */\n public pause() {\n this.paused = true;\n }\n\n /**\n * Resumes the queue and processes pending tasks.\n */\n public resume() {\n if (!this.paused) return;\n this.paused = false;\n this.next();\n }\n\n /**\n * Aborts the queue, rejecting all pending tasks.\n */\n public abort() {\n this.aborted = true;\n this.clear();\n }\n\n /**\n * Clears all pending tasks from the queue.\n */\n public clear() {\n this.queue = [];\n }\n\n /**\n * Returns the number of running tasks.\n */\n public getRunning(): number {\n return this.running;\n }\n\n /**\n * Returns the number of pending tasks in the queue.\n */\n public getPending(): number {\n return this.queue.length;\n }\n\n /**\n * Returns true if the queue is currently paused.\n */\n public isPaused(): boolean {\n return this.paused;\n }\n\n /**\n * Returns true if the queue has been aborted.\n */\n public isAborted(): boolean {\n return this.aborted;\n }\n\n private next() {\n if (this.paused || this.aborted) return;\n while (this.running < this.concurrency && this.queue.length > 0) {\n const fn = this.queue.shift();\n if (fn) fn();\n }\n if (this.running === 0 && this.queue.length === 0 && this.onDrain) {\n this.onDrain();\n }\n }\n}\n\n/**\n * Creates a new async queue instance with the specified configuration.\n * @param options - Configuration options for the async queue.\n * @returns New AsyncQueue instance.\n *\n * @example\n * ```typescript\n * const controller = new AbortController();\n * const queue = createAsyncQueue({\n * concurrency: 2,\n * signal: controller.signal\n * });\n * queue.add(async () => await doSomething());\n * controller.abort(); // Aborts the queue\n * ```\n */\nexport function createAsyncQueue(options?: AsyncQueueOptions): AsyncQueue {\n return new AsyncQueue(options);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"async-queue.js","names":[],"sources":["../../../src/utils/useful-stuff/async-queue.ts"],"sourcesContent":["/**\n * Async queue implementation for processing tasks sequentially or with limited concurrency.\n * Useful for rate-limiting, batching, or controlling resource usage.\n */\n\nexport interface AsyncQueueOptions {\n /** Maximum number of concurrent tasks. Default: 1 (sequential) */\n concurrency?: number;\n /** Optional callback invoked when all tasks are completed */\n onDrain?: () => void | Promise<void>;\n /** Optional AbortSignal for cancelling the queue */\n signal?: AbortSignal;\n}\n\nexport type AsyncQueueTask<T> = () => Promise<T>;\n\nexport class AsyncQueue {\n private readonly concurrency: number;\n private readonly onDrain?: () => void | Promise<void>;\n private readonly signal?: AbortSignal;\n private running = 0;\n private paused = false;\n private aborted = false;\n private queue: Array<() => void> = [];\n\n constructor(options: AsyncQueueOptions = {}) {\n this.concurrency = options.concurrency ?? 1;\n this.onDrain = options.onDrain;\n this.signal = options.signal;\n\n if (this.signal) {\n this.signal.addEventListener('abort', () => {\n this.abort();\n });\n }\n }\n\n /**\n * Adds a task to the queue.\n * @param task - The async function to execute.\n * @param signal - Optional AbortSignal for cancelling this specific task.\n * @returns Promise resolving to the result of the task.\n */\n public add<T>(task: AsyncQueueTask<T>, signal?: AbortSignal): Promise<T> {\n if (this.aborted) {\n return Promise.reject(new Error('Queue has been aborted'));\n }\n\n return new Promise<T>((resolve, reject) => {\n const run = async () => {\n if (this.paused || this.aborted) {\n if (this.aborted) {\n reject(new Error('Queue has been aborted'));\n } else {\n this.queue.push(run);\n }\n return;\n }\n\n // Check if task-specific signal is aborted\n if (signal?.aborted) {\n reject(new Error('Task was aborted'));\n return;\n }\n\n this.running++;\n try {\n const result = await task();\n resolve(result);\n } catch (err) {\n reject(err);\n } finally {\n this.running--;\n this.next();\n }\n };\n\n if (this.running < this.concurrency && !this.paused && !this.aborted) {\n run();\n } else {\n this.queue.push(run);\n }\n });\n }\n\n /**\n * Pauses the queue. No new tasks will be started until resumed.\n */\n public pause() {\n this.paused = true;\n }\n\n /**\n * Resumes the queue and processes pending tasks.\n */\n public resume() {\n if (!this.paused) return;\n this.paused = false;\n this.next();\n }\n\n /**\n * Aborts the queue, rejecting all pending tasks.\n */\n public abort() {\n this.aborted = true;\n this.clear();\n }\n\n /**\n * Clears all pending tasks from the queue.\n */\n public clear() {\n this.queue = [];\n }\n\n /**\n * Returns the number of running tasks.\n */\n public getRunning(): number {\n return this.running;\n }\n\n /**\n * Returns the number of pending tasks in the queue.\n */\n public getPending(): number {\n return this.queue.length;\n }\n\n /**\n * Returns true if the queue is currently paused.\n */\n public isPaused(): boolean {\n return this.paused;\n }\n\n /**\n * Returns true if the queue has been aborted.\n */\n public isAborted(): boolean {\n return this.aborted;\n }\n\n private next() {\n if (this.paused || this.aborted) return;\n while (this.running < this.concurrency && this.queue.length > 0) {\n const fn = this.queue.shift();\n if (fn) fn();\n }\n if (this.running === 0 && this.queue.length === 0 && this.onDrain) {\n this.onDrain();\n }\n }\n}\n\n/**\n * Creates a new async queue instance with the specified configuration.\n * @param options - Configuration options for the async queue.\n * @returns New AsyncQueue instance.\n *\n * @example\n * ```typescript\n * const controller = new AbortController();\n * const queue = createAsyncQueue({\n * concurrency: 2,\n * signal: controller.signal\n * });\n * queue.add(async () => await doSomething());\n * controller.abort(); // Aborts the queue\n * ```\n */\nexport function createAsyncQueue(options?: AsyncQueueOptions): AsyncQueue {\n return new AsyncQueue(options);\n}\n"],"mappings":";;;AAgBA,IAAa,aAAb,MAAwB;CACtB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAQ,UAAU;CAClB,AAAQ,SAAS;CACjB,AAAQ,UAAU;CAClB,AAAQ,QAA2B,EAAE;CAErC,YAAY,UAA6B,EAAE,EAAE;AAC3C,OAAK,cAAc,QAAQ,eAAe;AAC1C,OAAK,UAAU,QAAQ;AACvB,OAAK,SAAS,QAAQ;AAEtB,MAAI,KAAK,OACP,MAAK,OAAO,iBAAiB,eAAe;AAC1C,QAAK,OAAO;IACZ;;;;;;;;CAUN,AAAO,IAAO,MAAyB,QAAkC;AACvE,MAAI,KAAK,QACP,QAAO,QAAQ,uBAAO,IAAI,MAAM,yBAAyB,CAAC;AAG5D,SAAO,IAAI,SAAY,SAAS,WAAW;GACzC,MAAM,MAAM,YAAY;AACtB,QAAI,KAAK,UAAU,KAAK,SAAS;AAC/B,SAAI,KAAK,QACP,wBAAO,IAAI,MAAM,yBAAyB,CAAC;SAE3C,MAAK,MAAM,KAAK,IAAI;AAEtB;;AAIF,wDAAI,OAAQ,SAAS;AACnB,4BAAO,IAAI,MAAM,mBAAmB,CAAC;AACrC;;AAGF,SAAK;AACL,QAAI;AAEF,aADe,MAAM,MAAM,CACZ;aACR,KAAK;AACZ,YAAO,IAAI;cACH;AACR,UAAK;AACL,UAAK,MAAM;;;AAIf,OAAI,KAAK,UAAU,KAAK,eAAe,CAAC,KAAK,UAAU,CAAC,KAAK,QAC3D,MAAK;OAEL,MAAK,MAAM,KAAK,IAAI;IAEtB;;;;;CAMJ,AAAO,QAAQ;AACb,OAAK,SAAS;;;;;CAMhB,AAAO,SAAS;AACd,MAAI,CAAC,KAAK,OAAQ;AAClB,OAAK,SAAS;AACd,OAAK,MAAM;;;;;CAMb,AAAO,QAAQ;AACb,OAAK,UAAU;AACf,OAAK,OAAO;;;;;CAMd,AAAO,QAAQ;AACb,OAAK,QAAQ,EAAE;;;;;CAMjB,AAAO,aAAqB;AAC1B,SAAO,KAAK;;;;;CAMd,AAAO,aAAqB;AAC1B,SAAO,KAAK,MAAM;;;;;CAMpB,AAAO,WAAoB;AACzB,SAAO,KAAK;;;;;CAMd,AAAO,YAAqB;AAC1B,SAAO,KAAK;;CAGd,AAAQ,OAAO;AACb,MAAI,KAAK,UAAU,KAAK,QAAS;AACjC,SAAO,KAAK,UAAU,KAAK,eAAe,KAAK,MAAM,SAAS,GAAG;GAC/D,MAAM,KAAK,KAAK,MAAM,OAAO;AAC7B,OAAI,GAAI,KAAI;;AAEd,MAAI,KAAK,YAAY,KAAK,KAAK,MAAM,WAAW,KAAK,KAAK,QACxD,MAAK,SAAS;;;;;;;;;;;;;;;;;;;AAqBpB,SAAgB,iBAAiB,SAAyC;AACxE,QAAO,IAAI,WAAW,QAAQ"}
|
|
@@ -9,24 +9,24 @@
|
|
|
9
9
|
*/
|
|
10
10
|
interface MutexStorage {
|
|
11
11
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
* Attempts to acquire a lock for a given key
|
|
13
|
+
* @param key - The unique identifier for the mutex lock
|
|
14
|
+
* @param timeout - Optional timeout in milliseconds for the lock
|
|
15
|
+
* @param signal - Optional AbortSignal for cancelling the acquisition
|
|
16
|
+
* @returns Promise resolving to true if lock was acquired, false if timeout or already locked
|
|
17
|
+
*/
|
|
18
18
|
acquire(key: string, timeout?: number, signal?: AbortSignal): Promise<boolean>;
|
|
19
19
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
* Releases the lock for a given key
|
|
21
|
+
* @param key - The unique identifier for the mutex lock
|
|
22
|
+
* @returns Promise that resolves when the lock is released
|
|
23
|
+
*/
|
|
24
24
|
release(key: string): Promise<void>;
|
|
25
25
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
* Checks if a lock is currently held for a given key
|
|
27
|
+
* @param key - The unique identifier for the mutex lock
|
|
28
|
+
* @returns Promise resolving to true if the lock is held, false otherwise
|
|
29
|
+
*/
|
|
30
30
|
isLocked(key: string): Promise<boolean>;
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
@@ -45,24 +45,24 @@ interface MutexOptions {
|
|
|
45
45
|
declare class MemoryMutexStorage implements MutexStorage {
|
|
46
46
|
private readonly locks;
|
|
47
47
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
* Attempts to acquire a lock for a given key
|
|
49
|
+
* @param key - The unique identifier for the mutex lock
|
|
50
|
+
* @param timeout - Optional timeout in milliseconds for the lock
|
|
51
|
+
* @param signal - Optional AbortSignal for cancelling the acquisition
|
|
52
|
+
* @returns Promise resolving to true if lock was acquired, false if timeout or already locked
|
|
53
|
+
*/
|
|
54
54
|
acquire(key: string, timeout?: number, signal?: AbortSignal): Promise<boolean>;
|
|
55
55
|
/**
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
* Releases the lock for a given key
|
|
57
|
+
* @param key - The unique identifier for the mutex lock
|
|
58
|
+
* @returns Promise that resolves when the lock is released
|
|
59
|
+
*/
|
|
60
60
|
release(key: string): Promise<void>;
|
|
61
61
|
/**
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
* Checks if a lock is currently held for a given key
|
|
63
|
+
* @param key - The unique identifier for the mutex lock
|
|
64
|
+
* @returns Promise resolving to true if the lock is held, false otherwise
|
|
65
|
+
*/
|
|
66
66
|
isLocked(key: string): Promise<boolean>;
|
|
67
67
|
private generateHolderId;
|
|
68
68
|
private delay;
|
|
@@ -75,54 +75,54 @@ declare class Mutex {
|
|
|
75
75
|
private storage;
|
|
76
76
|
private readonly defaultTimeout;
|
|
77
77
|
/**
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
* Creates a new mutex instance
|
|
79
|
+
* @param options - Configuration options for the mutex
|
|
80
|
+
*/
|
|
81
81
|
constructor(options?: MutexOptions);
|
|
82
82
|
/**
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
* Sets the storage implementation for the mutex
|
|
84
|
+
* @param storage - The storage implementation to use
|
|
85
|
+
*/
|
|
86
86
|
setStorage(storage: MutexStorage): void;
|
|
87
87
|
/**
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
* Gets the storage implementation for the mutex
|
|
89
|
+
* @returns The storage implementation
|
|
90
|
+
*/
|
|
91
91
|
getStorage(): MutexStorage;
|
|
92
92
|
/**
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
93
|
+
* Acquires a lock for the given key
|
|
94
|
+
* @param key - The unique identifier for the mutex lock
|
|
95
|
+
* @param timeout - Optional timeout in milliseconds for lock acquisition
|
|
96
|
+
* @param signal - Optional AbortSignal for cancelling the acquisition
|
|
97
|
+
* @returns Promise resolving to true if lock was acquired, false if timeout
|
|
98
|
+
*/
|
|
99
99
|
acquire(key: string, timeout?: number, signal?: AbortSignal): Promise<boolean>;
|
|
100
100
|
/**
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
* Releases the lock for the given key
|
|
102
|
+
* @param key - The unique identifier for the mutex lock
|
|
103
|
+
* @returns Promise that resolves when the lock is released
|
|
104
|
+
*/
|
|
105
105
|
release(key: string): Promise<void>;
|
|
106
106
|
/**
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
* Checks if a lock is currently held for the given key
|
|
108
|
+
* @param key - The unique identifier for the mutex lock
|
|
109
|
+
* @returns Promise resolving to true if the lock is held, false otherwise
|
|
110
|
+
*/
|
|
111
111
|
isLocked(key: string): Promise<boolean>;
|
|
112
112
|
/**
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
113
|
+
* Executes a function with exclusive access to the resource
|
|
114
|
+
* @param key - The unique identifier for the mutex lock
|
|
115
|
+
* @param fn - The function to execute with exclusive access
|
|
116
|
+
* @param timeout - Optional timeout in milliseconds for lock acquisition
|
|
117
|
+
* @param signal - Optional AbortSignal for cancelling the lock acquisition
|
|
118
|
+
* @returns Promise resolving to the result of the function execution
|
|
119
|
+
* @throws Error if lock acquisition fails or function execution fails
|
|
120
|
+
*/
|
|
121
121
|
withLock<T>(key: string, fn: () => Promise<T> | T, timeout?: number, signal?: AbortSignal): Promise<T>;
|
|
122
122
|
/**
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
* Gets the current configuration of the mutex
|
|
124
|
+
* @returns Object containing the current timeout value
|
|
125
|
+
*/
|
|
126
126
|
getConfig(): Omit<MutexOptions, 'storage'>;
|
|
127
127
|
}
|
|
128
128
|
/**
|