commandkit 1.2.0-rc.11 → 1.2.0-rc.13
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/{COPYING.md → LICENSE.md} +3 -3
- package/README.md +3 -3
- package/bin/index.mjs +1 -1
- package/cli.d.ts +19 -0
- package/config.cjs +3 -0
- package/config.d.ts +1 -0
- package/dist/{ActionRow-DKnFVDME.d.ts → ActionRow-B-CGmjDp.d.ts} +4 -5
- package/dist/{ActionRow-CbdGFWMT.js → ActionRow-CSN_UKmM.js} +3 -4
- package/dist/ActionRow-CSN_UKmM.js.map +1 -0
- package/dist/{Button-4ZUXdA56.d.ts → Button-C-GPeFA3.d.ts} +7 -8
- package/dist/{ButtonKit-C7r7RPNf.d.ts → ButtonKit-DKu0VAe4.d.ts} +37 -38
- package/dist/ChannelSelectMenuKit-HQZ4hH5s.d.ts +66 -0
- package/dist/{CommandKitEventsChannel-BtRzr3Tz.js → CommandKitEventsChannel-CnT5ymYe.js} +2 -2
- package/dist/{CommandKitEventsChannel-BtRzr3Tz.js.map → CommandKitEventsChannel-CnT5ymYe.js.map} +1 -1
- package/dist/{CommandsRouter-CoOA7hkf.d.ts → CommandsRouter-C7dZEepB.d.ts} +49 -50
- package/dist/{CommandsRouter-Dmzw-ikm.js → CommandsRouter-C_HLsrGX.js} +2 -6
- package/dist/{CommandsRouter-Dmzw-ikm.js.map → CommandsRouter-C_HLsrGX.js.map} +1 -1
- package/dist/{CompilerPlugin-M8r3yNAl.js → CompilerPlugin-CUsGAfgl.js} +2 -2
- package/dist/{CompilerPlugin-M8r3yNAl.js.map → CompilerPlugin-CUsGAfgl.js.map} +1 -1
- package/dist/{EventInterceptor-CQEXyUTp.js → EventInterceptor-BWoEJMHZ.js} +1 -1
- package/dist/{EventInterceptor-CQEXyUTp.js.map → EventInterceptor-BWoEJMHZ.js.map} +1 -1
- package/dist/{EventInterceptor-x-R2qshQ.d.ts → EventInterceptor-CZmWpS08.d.ts} +40 -40
- package/dist/{EventWorkerContext-Dq29tieI.js → EventWorkerContext-Dfhgv329.js} +2 -3
- package/dist/EventWorkerContext-Dfhgv329.js.map +1 -0
- package/dist/EventsRouter-DZ37r54v.d.ts +90 -0
- package/dist/{EventsRouter-3Gygh-km.js → EventsRouter-DZYIha6m.js} +2 -6
- package/dist/{EventsRouter-3Gygh-km.js.map → EventsRouter-DZYIha6m.js.map} +1 -1
- package/dist/MentionableSelectMenuKit-7URDUM3-.d.ts +61 -0
- package/dist/{MessageCommandParser-Dl0xxtdr.js → MessageCommandParser-Bs9fimmd.js} +53 -55
- package/dist/{MessageCommandParser-Dl0xxtdr.js.map → MessageCommandParser-Bs9fimmd.js.map} +1 -1
- package/dist/MessageCommandParser-q3dQcE5N.d.ts +194 -0
- package/dist/{Modal-C6UTRdYQ.d.ts → Modal-CZT9MZsy.d.ts} +25 -12
- package/dist/{ModalKit-Btz58KYn.d.ts → ModalKit-BWXI3Z26.d.ts} +34 -35
- package/dist/{PluginCommon-Cvl5yYM_.js → PluginCommon-BLxWww5u.js} +6 -7
- package/dist/{PluginCommon-Cvl5yYM_.js.map → PluginCommon-BLxWww5u.js.map} +1 -1
- package/dist/RoleSelectMenuKit-BY-JJ18w.d.ts +66 -0
- package/dist/{RuntimePlugin-BUecuBIU.js → RuntimePlugin-CtobluSU.js} +2 -2
- package/dist/{RuntimePlugin-BUecuBIU.js.map → RuntimePlugin-CtobluSU.js.map} +1 -1
- package/dist/{SelectMenu-Diy87_ba.d.ts → SelectMenu-q_b3Mjv9.d.ts} +10 -11
- package/dist/StringSelectMenuKit-lVhUMc3g.d.ts +66 -0
- package/dist/UserSelectMenuKit-CCj4Fpkr.d.ts +66 -0
- package/dist/analytics/analytics-engine.d.ts +1 -31
- package/dist/analytics/analytics-engine.js +24 -36
- package/dist/analytics/analytics-provider.d.ts +1 -31
- package/dist/analytics/constants.js +1 -1
- package/dist/analytics/utils.js +24 -36
- package/dist/{analytics-engine-AaAl3kQM.d.ts → analytics-engine-WQhXmx3H.d.ts} +855 -830
- package/dist/app/commands/AppCommandRunner.d.ts +1 -31
- package/dist/app/commands/AppCommandRunner.js +24 -36
- package/dist/app/commands/Context.d.ts +1 -31
- package/dist/app/commands/Context.js +24 -36
- package/dist/app/commands/MessageCommandParser.d.ts +1 -1
- package/dist/app/commands/MessageCommandParser.js +1 -2
- package/dist/app/commands/helpers.d.ts +1 -1
- package/dist/app/commands/helpers.js +1 -1
- package/dist/app/events/EventWorkerContext.d.ts +42 -33
- package/dist/app/events/EventWorkerContext.js +1 -1
- package/dist/app/handlers/AppCommandHandler.d.ts +1 -31
- package/dist/app/handlers/AppCommandHandler.js +24 -36
- package/dist/app/handlers/AppEventsHandler.d.ts +1 -31
- package/dist/app/handlers/AppEventsHandler.js +24 -36
- package/dist/app/index.d.ts +4 -31
- package/dist/app/index.js +24 -37
- package/dist/app/interrupt/signals.d.ts +1 -1
- package/dist/app/interrupt/signals.js +2 -3
- package/dist/app/middlewares/permissions.d.ts +1 -31
- package/dist/app/middlewares/permissions.js +24 -36
- package/dist/app/register/CommandRegistrar.d.ts +1 -31
- package/dist/app/register/CommandRegistrar.js +24 -36
- package/dist/app/router/CommandsRouter.d.ts +1 -1
- package/dist/app/router/CommandsRouter.js +1 -1
- package/dist/app/router/EventsRouter.d.ts +1 -1
- package/dist/app/router/EventsRouter.js +1 -1
- package/dist/app/router/index.d.ts +2 -3
- package/dist/app/router/index.js +3 -3
- package/dist/{chunk-nOFOJqeH.js → chunk-kSYXY2_d.js} +10 -6
- package/dist/cli/app-process.d.ts +0 -1
- package/dist/cli/app-process.js +62 -7
- package/dist/cli/app-process.js.map +1 -0
- package/dist/cli/build.d.ts +2 -31
- package/dist/cli/build.js +191 -41
- package/dist/cli/build.js.map +1 -0
- package/dist/cli/common.d.ts +1 -31
- package/dist/cli/common.js +4 -4
- package/dist/cli/development.d.ts +18 -1
- package/dist/cli/development.js +43 -48
- package/dist/cli/development.js.map +1 -1
- package/dist/cli/env.d.ts +4 -0
- package/dist/cli/env.js +1 -1
- package/dist/cli/generators.js +5 -8
- package/dist/cli/generators.js.map +1 -1
- package/dist/cli/information.js +5 -5
- package/dist/cli/information.js.map +1 -1
- package/dist/cli/init.d.ts +12 -2
- package/dist/cli/init.js +102 -38
- package/dist/cli/init.js.map +1 -0
- package/dist/cli/production.d.ts +0 -1
- package/dist/cli/production.js +38 -49
- package/dist/cli/production.js.map +1 -1
- package/dist/cli/type-checker.js +5 -5
- package/dist/cli/utils.d.ts +0 -1
- package/dist/cli/utils.js +17 -2
- package/dist/cli/utils.js.map +1 -0
- package/dist/{colors-DL3ucTiT.js → colors-Csc0X4QJ.js} +2 -3
- package/dist/{colors-DL3ucTiT.js.map → colors-Csc0X4QJ.js.map} +1 -1
- package/dist/{commandkit-ZoBBh0Q_.js → commandkit-SIjTLD2R.js} +229 -88
- package/dist/commandkit-SIjTLD2R.js.map +1 -0
- package/dist/commandkit.d.ts +1 -31
- package/dist/commandkit.js +24 -36
- package/dist/{common-vnMIelAE.js → common-CEordwf3.js} +3 -3
- package/dist/common-CEordwf3.js.map +1 -0
- package/dist/{common-CrqwC-sx.js → common-DSRs_mfw.js} +10 -14
- package/dist/{common-CrqwC-sx.js.map → common-DSRs_mfw.js.map} +1 -1
- package/dist/{common-DOCvOVC4.d.ts → common-DnwCYit8.d.ts} +4 -5
- package/dist/components/common/EventInterceptor.d.ts +1 -1
- package/dist/components/common/EventInterceptor.js +1 -1
- package/dist/components/common/element.d.ts +1 -4
- package/dist/components/common/element.js +1 -1
- package/dist/components/common/types.d.ts +1 -1
- package/dist/components/common/types.js +0 -1
- package/dist/components/{v2 → display}/common.d.ts +1 -2
- package/dist/components/display/common.js +3 -0
- package/dist/components/display/container.d.ts +2 -0
- package/dist/components/display/container.js +3 -0
- package/dist/components/display/file.d.ts +2 -0
- package/dist/components/display/file.js +3 -0
- package/dist/components/display/index.d.ts +9 -0
- package/dist/components/display/index.js +22 -0
- package/dist/components/display/label.d.ts +2 -0
- package/dist/components/display/label.js +3 -0
- package/dist/components/display/media-gallery.d.ts +2 -0
- package/dist/components/{v2 → display}/media-gallery.js +1 -2
- package/dist/components/display/poll.d.ts +2 -0
- package/dist/components/display/poll.js +5 -0
- package/dist/components/display/section.d.ts +2 -0
- package/dist/components/display/section.js +4 -0
- package/dist/components/display/separator.d.ts +2 -0
- package/dist/components/display/separator.js +3 -0
- package/dist/components/display/text-display.d.ts +2 -0
- package/dist/components/display/text-display.js +3 -0
- package/dist/components/index.d.ts +23 -24
- package/dist/components/index.js +30 -37
- package/dist/components/interactive/action-row/ActionRow.d.ts +2 -0
- package/dist/components/interactive/action-row/ActionRow.js +3 -0
- package/dist/components/interactive/button/Button.d.ts +2 -0
- package/dist/components/interactive/button/Button.js +26 -0
- package/dist/components/interactive/button/ButtonKit.d.ts +2 -0
- package/dist/components/interactive/button/ButtonKit.js +26 -0
- package/dist/components/interactive/modal/Modal.d.ts +2 -0
- package/dist/components/interactive/modal/Modal.js +30 -0
- package/dist/components/interactive/modal/ModalKit.d.ts +2 -0
- package/dist/components/interactive/modal/ModalKit.js +26 -0
- package/dist/components/interactive/select-menu/ChannelSelectMenuKit.d.ts +2 -0
- package/dist/components/interactive/select-menu/ChannelSelectMenuKit.js +26 -0
- package/dist/components/interactive/select-menu/MentionableSelectMenuKit.d.ts +2 -0
- package/dist/components/interactive/select-menu/MentionableSelectMenuKit.js +26 -0
- package/dist/components/interactive/select-menu/RoleSelectMenuKit.d.ts +2 -0
- package/dist/components/interactive/select-menu/RoleSelectMenuKit.js +26 -0
- package/dist/components/interactive/select-menu/SelectMenu.d.ts +2 -0
- package/dist/components/interactive/select-menu/SelectMenu.js +31 -0
- package/dist/components/interactive/select-menu/StringSelectMenuKit.d.ts +2 -0
- package/dist/components/interactive/select-menu/StringSelectMenuKit.js +26 -0
- package/dist/components/interactive/select-menu/UserSelectMenuKit.d.ts +2 -0
- package/dist/components/interactive/select-menu/UserSelectMenuKit.js +26 -0
- package/dist/components/interactive/select-menu/common.d.ts +2 -0
- package/dist/config/config.d.ts +15 -33
- package/dist/config/config.js +24 -36
- package/dist/config/default.d.ts +1 -31
- package/dist/config/default.js +24 -36
- package/dist/config/loader.d.ts +1 -31
- package/dist/config/loader.js +24 -36
- package/dist/config/types.d.ts +1 -31
- package/dist/config/utils.d.ts +1 -31
- package/dist/config/utils.js +1 -1
- package/dist/constants-BFFK-hfP.js +27 -0
- package/dist/{constants-4oxxvaJA.js.map → constants-BFFK-hfP.js.map} +1 -1
- package/dist/{constants-MKu-Q1jh.d.ts → constants-CuYW0K10.d.ts} +14 -8
- package/dist/{constants-BOOGN85p.js → constants-Cw8VjCVz.js} +2 -3
- package/dist/{constants-BOOGN85p.js.map → constants-Cw8VjCVz.js.map} +1 -1
- package/dist/{constants-B5_Ta7PR.js → constants-CxkFFZ7p.js} +16 -1
- package/dist/constants-CxkFFZ7p.js.map +1 -0
- package/dist/{constants-D8PMA9on.d.ts → constants-EpKcj0dH.d.ts} +2 -2
- package/dist/{container-C6GtfAPW.js → container-DCPljKVH.js} +4 -5
- package/dist/container-DCPljKVH.js.map +1 -0
- package/dist/{container-DHBELeJ3.d.ts → container-DYcb7zGw.d.ts} +3 -4
- package/dist/context/async-context.d.ts +1 -31
- package/dist/context/async-context.js +24 -36
- package/dist/context/environment.d.ts +1 -31
- package/dist/context/environment.js +24 -36
- package/dist/{element-Bak9llw_.js → element-DibzzA5L.js} +1 -1
- package/dist/element-DibzzA5L.js.map +1 -0
- package/dist/{element-CAXu1XtK.d.ts → element-wQo0heGj.d.ts} +4 -5
- package/dist/{env-_68PRRoA.js → env-CmspDhHy.js} +7 -3
- package/dist/env-CmspDhHy.js.map +1 -0
- package/dist/error-codes-Ds0bnPvT.js.map +1 -1
- package/dist/events/CommandKitEventsChannel.d.ts +1 -31
- package/dist/events/CommandKitEventsChannel.js +1 -1
- package/dist/{file-DVOELoNv.js → file-Ca1kpEtE.js} +3 -4
- package/dist/file-Ca1kpEtE.js.map +1 -0
- package/dist/{file-DTrr-p09.d.ts → file-CrV4lSnl.d.ts} +3 -4
- package/dist/flags/FlagProvider.d.ts +1 -31
- package/dist/flags/feature-flags.d.ts +1 -31
- package/dist/flags/feature-flags.js +165 -40
- package/dist/flags/feature-flags.js.map +1 -0
- package/dist/flags/store.d.ts +1 -31
- package/dist/flags/store.js +1 -1
- package/dist/{helpers-Wg6P5fRQ.d.ts → helpers-AQPLVY35.d.ts} +2 -3
- package/dist/{helpers-Dl8wW6aO.js → helpers-Btx1FSZx.js} +2 -3
- package/dist/{helpers-Dl8wW6aO.js.map → helpers-Btx1FSZx.js.map} +1 -1
- package/dist/index.d.ts +41 -42
- package/dist/index.js +47 -46
- package/dist/index.js.map +1 -1
- package/dist/kv/constants.d.ts +1 -1
- package/dist/kv/constants.js +1 -1
- package/dist/kv/dotprops.js +25 -3
- package/dist/kv/dotprops.js.map +1 -0
- package/dist/kv/kv.d.ts +289 -290
- package/dist/kv/kv.js +14 -18
- package/dist/kv/kv.js.map +1 -1
- package/dist/kv/serde.d.ts +12 -3
- package/dist/kv/serde.js +86 -4
- package/dist/kv/serde.js.map +1 -0
- package/dist/label-37kaNWMH.d.ts +28 -0
- package/dist/label-B6vXvwLM.js +35 -0
- package/dist/label-B6vXvwLM.js.map +1 -0
- package/dist/logger/DefaultLogger.d.ts +66 -3
- package/dist/logger/DefaultLogger.js +24 -36
- package/dist/logger/ILogger.d.ts +64 -2
- package/dist/logger/ILogger.js +0 -1
- package/dist/logger/Logger.d.ts +36 -3
- package/dist/logger/Logger.js +24 -36
- package/dist/logger/NoopLogger.d.ts +36 -37
- package/dist/{media-gallery-BMsXSot3.d.ts → media-gallery-Ci3I4ElH.d.ts} +3 -4
- package/dist/{media-gallery-zDtJ3kxb.js → media-gallery-u3gjX7yD.js} +4 -5
- package/dist/media-gallery-u3gjX7yD.js.map +1 -0
- package/dist/plugins/CompilerPlugin.d.ts +1 -31
- package/dist/plugins/CompilerPlugin.js +1 -2
- package/dist/plugins/PluginCommon.d.ts +1 -31
- package/dist/plugins/PluginCommon.js +1 -1
- package/dist/plugins/RuntimePlugin.d.ts +1 -31
- package/dist/plugins/RuntimePlugin.js +1 -2
- package/dist/plugins/index.d.ts +1 -31
- package/dist/plugins/index.js +26 -36
- package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.d.ts +1 -31
- package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.js +24 -36
- package/dist/plugins/plugin-runtime/CompilerPluginRuntime.d.ts +1 -31
- package/dist/plugins/plugin-runtime/CompilerPluginRuntime.js +24 -36
- package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.d.ts +1 -31
- package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.js +24 -36
- package/dist/plugins/plugin-runtime/builtin/MacroPlugin.d.ts +1 -31
- package/dist/plugins/plugin-runtime/builtin/MacroPlugin.js +24 -36
- package/dist/plugins/plugin-runtime/runtime.d.ts +1 -31
- package/dist/plugins/plugin-runtime/runtime.js +0 -1
- package/dist/plugins/types.d.ts +1 -31
- package/dist/plugins/types.js +0 -1
- package/dist/poll-CFe8yvoJ.js +100 -0
- package/dist/poll-CFe8yvoJ.js.map +1 -0
- package/dist/poll-Ddtapd6n.d.ts +88 -0
- package/dist/{resolve-file-url-ChIyw-Vf.js → resolve-file-url-CdHqwWs3.js} +2 -2
- package/dist/{resolve-file-url-ChIyw-Vf.js.map → resolve-file-url-CdHqwWs3.js.map} +1 -1
- package/dist/{section-DlvrDoJK.js → section-BC8LF-B2.js} +4 -5
- package/dist/section-BC8LF-B2.js.map +1 -0
- package/dist/{section-Dh_FhPeC.d.ts → section-DkUKULnB.d.ts} +3 -4
- package/dist/{separator-DL6QH5H1.js → separator-BUTiW7uz.js} +3 -4
- package/dist/separator-BUTiW7uz.js.map +1 -0
- package/dist/{separator-CMf6Cyy5.d.ts → separator-CbXsIFCa.d.ts} +3 -4
- package/dist/{signals-ChFMD7mB.js → signals-B8z1wJ6W.js} +2 -2
- package/dist/{signals-ChFMD7mB.js.map → signals-B8z1wJ6W.js.map} +1 -1
- package/dist/{signals-SHg7J1U_.d.ts → signals-BbTgTc0i.d.ts} +2 -2
- package/dist/{store-CM6pWVZh.js → store-D8r_hryO.js} +2 -3
- package/dist/{store-CM6pWVZh.js.map → store-D8r_hryO.js.map} +1 -1
- package/dist/{text-display-DRw3r_lK.d.ts → text-display-D7j39VC-.d.ts} +3 -4
- package/dist/{text-display-DbMumig_.js → text-display-DANahMN3.js} +3 -4
- package/dist/text-display-DANahMN3.js.map +1 -0
- package/dist/{type-checker-ocNSZh0W.js → type-checker-cVd3Hpnh.js} +4 -6
- package/dist/{type-checker-ocNSZh0W.js.map → type-checker-cVd3Hpnh.js.map} +1 -1
- package/dist/{types-CJ-XvOFN.d.ts → types-BywA9d2Z.d.ts} +2 -2
- package/dist/{types-package-BWArjyBF.js → types-package-CsTNfvv2.js} +4 -8
- package/dist/{types-package-BWArjyBF.js.map → types-package-CsTNfvv2.js.map} +1 -1
- package/dist/types.d.ts +1 -31
- package/dist/utils/colors.js +1 -1
- package/dist/utils/constants.d.ts +2 -2
- package/dist/utils/constants.js +3 -2
- package/dist/utils/dev-hooks.d.ts +1 -31
- package/dist/utils/dev-hooks.js +24 -36
- package/dist/utils/error-codes.d.ts +54 -2
- package/dist/utils/resolve-file-url.d.ts +11 -2
- package/dist/utils/resolve-file-url.js +1 -1
- package/dist/utils/types-package.js +2 -2
- package/dist/utils/useful-stuff/async-queue.d.ts +21 -21
- package/dist/utils/useful-stuff/async-queue.js +1 -2
- 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/ratelimiter.d.ts +56 -56
- package/dist/utils/useful-stuff/ratelimiter.js +1 -2
- 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 -3
- package/dist/utils/useful-stuff/semaphore.js.map +1 -1
- package/dist/utils/utilities.d.ts +113 -2
- package/dist/utils/utilities.js +27 -37
- package/dist/utils/{warn-unstable.d.ts → warning.d.ts} +12 -3
- package/dist/utils/warning.js +5 -0
- package/dist/{utils-KsNof0Xz.js → utils-Br3eenD1.js} +1 -1
- package/dist/{utils-KsNof0Xz.js.map → utils-Br3eenD1.js.map} +1 -1
- package/dist/version.d.ts +8 -2
- package/dist/version.js +12 -2
- package/dist/version.js.map +1 -0
- package/dist/warning-CszH8HeS.js +53 -0
- package/dist/warning-CszH8HeS.js.map +1 -0
- package/hooks.cjs +11 -4
- package/package.json +14 -7
- package/dist/ActionRow-CbdGFWMT.js.map +0 -1
- package/dist/ChannelSelectMenuKit-BrXvBYNH.d.ts +0 -67
- package/dist/DefaultLogger-XCOl5nLd.d.ts +0 -67
- package/dist/EventWorkerContext-Dq29tieI.js.map +0 -1
- package/dist/EventWorkerContext-XNgriym3.d.ts +0 -43
- package/dist/EventsRouter-BacqK6z3.d.ts +0 -90
- package/dist/ILogger-BW8GM-YZ.d.ts +0 -64
- package/dist/Logger-DyfkPk7u.d.ts +0 -37
- package/dist/MentionableSelectMenuKit-CPTKqx-O.d.ts +0 -62
- package/dist/MessageCommandParser-BsGMOTDo.d.ts +0 -195
- package/dist/RoleSelectMenuKit-C26lU3sN.d.ts +0 -67
- package/dist/StringSelectMenuKit-Bhs8U6WI.d.ts +0 -67
- package/dist/UserSelectMenuKit-CfqFJdxz.d.ts +0 -67
- package/dist/app-process-cj2vF12T.js +0 -68
- package/dist/app-process-cj2vF12T.js.map +0 -1
- package/dist/build-B5qTswWF.js +0 -174
- package/dist/build-B5qTswWF.js.map +0 -1
- package/dist/commandkit-ZoBBh0Q_.js.map +0 -1
- package/dist/common-vnMIelAE.js.map +0 -1
- package/dist/components/v1/action-row/ActionRow.d.ts +0 -6
- package/dist/components/v1/action-row/ActionRow.js +0 -3
- package/dist/components/v1/button/Button.d.ts +0 -7
- package/dist/components/v1/button/Button.js +0 -38
- package/dist/components/v1/button/ButtonKit.d.ts +0 -3
- package/dist/components/v1/button/ButtonKit.js +0 -38
- package/dist/components/v1/modal/Modal.d.ts +0 -7
- package/dist/components/v1/modal/Modal.js +0 -41
- package/dist/components/v1/modal/ModalKit.d.ts +0 -3
- package/dist/components/v1/modal/ModalKit.js +0 -38
- package/dist/components/v1/select-menu/ChannelSelectMenuKit.d.ts +0 -4
- package/dist/components/v1/select-menu/ChannelSelectMenuKit.js +0 -38
- package/dist/components/v1/select-menu/MentionableSelectMenuKit.d.ts +0 -4
- package/dist/components/v1/select-menu/MentionableSelectMenuKit.js +0 -38
- package/dist/components/v1/select-menu/RoleSelectMenuKit.d.ts +0 -4
- package/dist/components/v1/select-menu/RoleSelectMenuKit.js +0 -38
- package/dist/components/v1/select-menu/SelectMenu.d.ts +0 -10
- package/dist/components/v1/select-menu/SelectMenu.js +0 -43
- package/dist/components/v1/select-menu/StringSelectMenuKit.d.ts +0 -4
- package/dist/components/v1/select-menu/StringSelectMenuKit.js +0 -38
- package/dist/components/v1/select-menu/UserSelectMenuKit.d.ts +0 -4
- package/dist/components/v1/select-menu/UserSelectMenuKit.js +0 -38
- package/dist/components/v1/select-menu/common.d.ts +0 -3
- package/dist/components/v1/select-menu/common.js +0 -1
- package/dist/components/v2/common.js +0 -3
- package/dist/components/v2/container.d.ts +0 -2
- package/dist/components/v2/container.js +0 -4
- package/dist/components/v2/file.d.ts +0 -2
- package/dist/components/v2/file.js +0 -3
- package/dist/components/v2/index.d.ts +0 -8
- package/dist/components/v2/index.js +0 -17
- package/dist/components/v2/media-gallery.d.ts +0 -2
- package/dist/components/v2/section.d.ts +0 -2
- package/dist/components/v2/section.js +0 -5
- package/dist/components/v2/separator.d.ts +0 -2
- package/dist/components/v2/separator.js +0 -3
- package/dist/components/v2/text-display.d.ts +0 -2
- package/dist/components/v2/text-display.js +0 -3
- package/dist/config-D-JMp2IO.d.ts +0 -16
- package/dist/constants-4oxxvaJA.js +0 -27
- package/dist/constants-B5_Ta7PR.js.map +0 -1
- package/dist/container-C6GtfAPW.js.map +0 -1
- package/dist/dotprops-tnhpnszJ.js +0 -36
- package/dist/dotprops-tnhpnszJ.js.map +0 -1
- package/dist/element-Bak9llw_.js.map +0 -1
- package/dist/env-_68PRRoA.js.map +0 -1
- package/dist/error-codes-B4TyW4Ct.d.ts +0 -54
- package/dist/feature-flags-CKNrjgqg.js +0 -160
- package/dist/feature-flags-CKNrjgqg.js.map +0 -1
- package/dist/file-DVOELoNv.js.map +0 -1
- package/dist/init-DOr-Y3GQ.d.ts +0 -13
- package/dist/init-_7_QDifv.js +0 -95
- package/dist/init-_7_QDifv.js.map +0 -1
- package/dist/media-gallery-zDtJ3kxb.js.map +0 -1
- package/dist/resolve-file-url-yO8bUxok.d.ts +0 -11
- package/dist/section-DlvrDoJK.js.map +0 -1
- package/dist/separator-DL6QH5H1.js.map +0 -1
- package/dist/serde-BYaKrsOV.d.ts +0 -12
- package/dist/serde-Cc8iUa9J.js +0 -97
- package/dist/serde-Cc8iUa9J.js.map +0 -1
- package/dist/text-display-DbMumig_.js.map +0 -1
- package/dist/utilities-DtdPlr4c.d.ts +0 -87
- package/dist/utils/warn-unstable.js +0 -26
- package/dist/utils/warn-unstable.js.map +0 -1
- package/dist/utils-DCSnVAZ6.js +0 -23
- package/dist/utils-DCSnVAZ6.js.map +0 -1
- package/dist/v2-DofkPKHs.js +0 -0
- package/dist/version--Q1nmlBz.js +0 -18
- package/dist/version--Q1nmlBz.js.map +0 -1
- package/dist/version-CtJtBJXI.d.ts +0 -8
- /package/dist/{ILogger-dQ7Y9X1f.js → common-C2jAjX4U.js} +0 -0
- /package/dist/{app-HN1cVg8J.js → components/interactive/select-menu/common.js} +0 -0
- /package/dist/{common-CcfjYnPG.js → display-WDb9wMCv.js} +0 -0
- /package/dist/{index-CUPkUUOR.d.ts → index-BJfko-dP.d.ts} +0 -0
- /package/dist/{index-Dw5cCt-A.d.ts → index-CCggO_hw.d.ts} +0 -0
- /package/dist/{index-E7Wvm5uX.d.ts → index-CLjpoGi1.d.ts} +0 -0
- /package/dist/{router-Dn35v30f.js → router-BvamdzoF.js} +0 -0
- /package/dist/{runtime-DB9CiPfe.js → runtime-Skt5NiOc.js} +0 -0
- /package/dist/{types-CUZOquUl.js → types-Cdh4uaFR.js} +0 -0
- /package/dist/{types-q0Nm882H.js → types-TC4g3w91.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"semaphore.js","names":[],"sources":["../../../src/utils/useful-stuff/semaphore.ts"],"sourcesContent":["/**\n * Async semaphore implementation for controlling access to a limited pool of resources.\n * Allows a specified number of concurrent operations while blocking additional requests.\n */\n\n/**\n * Interface for semaphore storage implementations.\n * Provides methods to store, retrieve, and manage semaphore permit data.\n */\nexport interface SemaphoreStorage {\n /**\n * Attempts to acquire a permit for a given key\n * @param key - The unique identifier for the semaphore\n * @param timeout - Optional timeout in milliseconds for permit acquisition\n * @param signal - Optional AbortSignal for cancelling the acquisition\n * @returns Promise resolving to true if permit was acquired, false if timeout or no permits available\n */\n acquire(\n key: string,\n timeout?: number,\n signal?: AbortSignal,\n ): Promise<boolean>;\n\n /**\n * Releases a permit for a given key\n * @param key - The unique identifier for the semaphore\n * @returns Promise that resolves when the permit is released\n */\n release(key: string): Promise<void>;\n\n /**\n * Gets the number of available permits for a given key\n * @param key - The unique identifier for the semaphore\n * @returns Promise resolving to the number of available permits\n */\n getAvailablePermits(key: string): Promise<number>;\n\n /**\n * Gets the total number of permits for a given key\n * @param key - The unique identifier for the semaphore\n * @returns Promise resolving to the total number of permits\n */\n getTotalPermits(key: string): Promise<number>;\n}\n\n/**\n * Configuration options for semaphore\n */\nexport interface SemaphoreOptions {\n /** Maximum number of concurrent permits allowed. Default: 1 */\n permits?: number;\n /** Default timeout in milliseconds for permit acquisition. Default: 30000 */\n timeout?: number;\n /** Storage implementation for persisting semaphore data. Default: {@link MemorySemaphoreStorage} */\n storage?: SemaphoreStorage;\n}\n\n/**\n * In-memory storage implementation for semaphore permits.\n * Suitable for single-instance applications.\n */\nexport class MemorySemaphoreStorage implements SemaphoreStorage {\n private readonly semaphores = new Map<\n string,\n { total: number; available: number }\n >();\n\n /**\n * Attempts to acquire a permit for a given key\n * @param key - The unique identifier for the semaphore\n * @param timeout - Optional timeout in milliseconds for permit acquisition\n * @param signal - Optional AbortSignal for cancelling the acquisition\n * @returns Promise resolving to true if permit was acquired, false if timeout or no permits available\n */\n async acquire(\n key: string,\n timeout: number = 30000,\n signal?: AbortSignal,\n ): Promise<boolean> {\n const startTime = Date.now();\n\n while (Date.now() - startTime < timeout) {\n // Check if aborted\n if (signal?.aborted) {\n throw new Error('Permit acquisition was aborted');\n }\n\n const semaphore = this.semaphores.get(key);\n if (semaphore && semaphore.available > 0) {\n semaphore.available--;\n return true;\n }\n await this.delay(10);\n }\n\n return false;\n }\n\n /**\n * Releases a permit for a given key\n * @param key - The unique identifier for the semaphore\n * @returns Promise that resolves when the permit is released\n */\n async release(key: string): Promise<void> {\n const semaphore = this.semaphores.get(key);\n if (semaphore && semaphore.available < semaphore.total) {\n semaphore.available++;\n }\n }\n\n /**\n * Gets the number of available permits for a given key\n * @param key - The unique identifier for the semaphore\n * @returns Promise resolving to the number of available permits\n */\n async getAvailablePermits(key: string): Promise<number> {\n const semaphore = this.semaphores.get(key);\n return semaphore ? semaphore.available : 0;\n }\n\n /**\n * Gets the total number of permits for a given key\n * @param key - The unique identifier for the semaphore\n * @returns Promise resolving to the total number of permits\n */\n async getTotalPermits(key: string): Promise<number> {\n const semaphore = this.semaphores.get(key);\n return semaphore ? semaphore.total : 0;\n }\n\n /**\n * Initializes a semaphore with the specified number of permits\n * @param key - The unique identifier for the semaphore\n * @param permits - The total number of permits to allocate\n */\n initialize(key: string, permits: number): void {\n this.semaphores.set(key, { total: permits, available: permits });\n }\n\n private delay(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n}\n\n/**\n * Async semaphore implementation that controls access to a limited pool of resources.\n * Allows a specified number of concurrent operations while blocking additional requests.\n */\nexport class Semaphore {\n private storage: SemaphoreStorage;\n private readonly defaultPermits: number;\n private readonly defaultTimeout: number;\n\n /**\n * Creates a new semaphore instance\n * @param options - Configuration options for the semaphore\n */\n public constructor(options: SemaphoreOptions = {}) {\n this.storage = options.storage || new MemorySemaphoreStorage();\n this.defaultPermits = options.permits || 1;\n this.defaultTimeout = options.timeout || 30000;\n }\n\n /**\n * Sets the storage implementation for the semaphore\n * @param storage - The storage implementation to use\n */\n public setStorage(storage: SemaphoreStorage) {\n this.storage = storage;\n }\n\n /**\n * Gets the storage implementation for the semaphore\n * @returns The storage implementation\n */\n public getStorage(): SemaphoreStorage {\n return this.storage;\n }\n\n /**\n * Acquires a permit for the given key\n * @param key - The unique identifier for the semaphore\n * @param timeout - Optional timeout in milliseconds for permit acquisition\n * @param signal - Optional AbortSignal for cancelling the acquisition\n * @returns Promise resolving to true if permit was acquired, false if timeout\n */\n public async acquire(\n key: string,\n timeout?: number,\n signal?: AbortSignal,\n ): Promise<boolean> {\n // Initialize semaphore if it doesn't exist\n if (this.storage instanceof MemorySemaphoreStorage) {\n const totalPermits = await this.storage.getTotalPermits(key);\n if (totalPermits === 0) {\n (this.storage as MemorySemaphoreStorage).initialize(\n key,\n this.defaultPermits,\n );\n }\n }\n\n return this.storage.acquire(key, timeout || this.defaultTimeout, signal);\n }\n\n /**\n * Releases a permit for the given key\n * @param key - The unique identifier for the semaphore\n * @returns Promise that resolves when the permit is released\n */\n public async release(key: string): Promise<void> {\n return this.storage.release(key);\n }\n\n /**\n * Gets the number of available permits for the given key\n * @param key - The unique identifier for the semaphore\n * @returns Promise resolving to the number of available permits\n */\n public async getAvailablePermits(key: string): Promise<number> {\n return this.storage.getAvailablePermits(key);\n }\n\n /**\n * Gets the total number of permits for the given key\n * @param key - The unique identifier for the semaphore\n * @returns Promise resolving to the total number of permits\n */\n public async getTotalPermits(key: string): Promise<number> {\n return this.storage.getTotalPermits(key);\n }\n\n /**\n * Gets the number of acquired permits for the given key\n * @param key - The unique identifier for the semaphore\n * @returns Promise resolving to the number of acquired permits\n */\n public async getAcquiredPermits(key: string): Promise<number> {\n const total = await this.getTotalPermits(key);\n const available = await this.getAvailablePermits(key);\n return total - available;\n }\n\n /**\n * Executes a function with a permit from the semaphore\n * @param key - The unique identifier for the semaphore\n * @param fn - The function to execute with a permit\n * @param timeout - Optional timeout in milliseconds for permit acquisition\n * @param signal - Optional AbortSignal for cancelling the permit acquisition\n * @returns Promise resolving to the result of the function execution\n * @throws Error if permit acquisition fails or function execution fails\n */\n public async withPermit<T>(\n key: string,\n fn: () => Promise<T> | T,\n timeout?: number,\n signal?: AbortSignal,\n ): Promise<T> {\n const acquired = await this.acquire(key, timeout, signal);\n if (!acquired) {\n throw new Error(`Failed to acquire permit for key: ${key}`);\n }\n\n try {\n return await fn();\n } finally {\n await this.release(key);\n }\n }\n\n /**\n * Gets the current configuration of the semaphore\n * @returns Object containing the current permits and timeout values\n */\n public getConfig(): Omit<SemaphoreOptions, 'storage'> {\n return {\n permits: this.defaultPermits,\n timeout: this.defaultTimeout,\n };\n }\n}\n\n/**\n * Default semaphore instance for global use\n */\nexport const defaultSemaphore = new Semaphore();\n\n/**\n * Convenience function to execute a function with a permit using the default semaphore.\n *\n * @param key - The unique identifier for the semaphore\n * @param fn - The function to execute with a permit\n * @param timeout - Optional timeout in milliseconds for permit acquisition\n * @param signal - Optional AbortSignal for cancelling the permit acquisition\n * @returns Promise resolving to the result of the function execution\n *\n * @example\n * ```typescript\n * const controller = new AbortController();\n * const result = await withPermit('database-connection', async () => {\n * // This code runs with a permit from the semaphore\n * return await executeDatabaseQuery();\n * }, 30000, controller.signal);\n * controller.abort(); // Cancels the permit acquisition\n * ```\n */\nexport async function withPermit<T>(\n key: string,\n fn: () => Promise<T> | T,\n timeout?: number,\n signal?: AbortSignal,\n): Promise<T> {\n return defaultSemaphore.withPermit(key, fn, timeout, signal);\n}\n\n/**\n * Creates a new semaphore instance with the specified configuration\n * @param options - Configuration options for the semaphore\n * @returns New Semaphore instance\n *\n * @example\n * ```typescript\n * const semaphore = createSemaphore({\n * permits: 5,\n * timeout: 60000,\n * storage: new RedisSemaphoreStorage()\n * });\n * ```\n */\nexport function createSemaphore(options: SemaphoreOptions): Semaphore {\n return new Semaphore(options);\n}\n\n/**\n * Acquires a permit using the default semaphore\n * @param key - The unique identifier for the semaphore\n * @param timeout - Optional timeout in milliseconds for permit acquisition\n * @param signal - Optional AbortSignal for cancelling the acquisition\n * @returns Promise resolving to true if permit was acquired, false if timeout\n */\nexport async function acquirePermit(\n key: string,\n timeout?: number,\n signal?: AbortSignal,\n): Promise<boolean> {\n return defaultSemaphore.acquire(key, timeout, signal);\n}\n\n/**\n * Releases a permit using the default semaphore\n * @param key - The unique identifier for the semaphore\n * @returns Promise that resolves when the permit is released\n */\nexport async function releasePermit(key: string): Promise<void> {\n return defaultSemaphore.release(key);\n}\n\n/**\n * Gets the number of available permits using the default semaphore\n * @param key - The unique identifier for the semaphore\n * @returns Promise resolving to the number of available permits\n */\nexport async function getAvailablePermits(key: string): Promise<number> {\n return defaultSemaphore.getAvailablePermits(key);\n}\n\n/**\n * Gets the number of acquired permits using the default semaphore\n * @param key - The unique identifier for the semaphore\n * @returns Promise resolving to the number of acquired permits\n */\nexport async function getAcquiredPermits(key: string): Promise<number> {\n return defaultSemaphore.getAcquiredPermits(key);\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"semaphore.js","names":[],"sources":["../../../src/utils/useful-stuff/semaphore.ts"],"sourcesContent":["/**\n * Async semaphore implementation for controlling access to a limited pool of resources.\n * Allows a specified number of concurrent operations while blocking additional requests.\n */\n\n/**\n * Interface for semaphore storage implementations.\n * Provides methods to store, retrieve, and manage semaphore permit data.\n */\nexport interface SemaphoreStorage {\n /**\n * Attempts to acquire a permit for a given key\n * @param key - The unique identifier for the semaphore\n * @param timeout - Optional timeout in milliseconds for permit acquisition\n * @param signal - Optional AbortSignal for cancelling the acquisition\n * @returns Promise resolving to true if permit was acquired, false if timeout or no permits available\n */\n acquire(\n key: string,\n timeout?: number,\n signal?: AbortSignal,\n ): Promise<boolean>;\n\n /**\n * Releases a permit for a given key\n * @param key - The unique identifier for the semaphore\n * @returns Promise that resolves when the permit is released\n */\n release(key: string): Promise<void>;\n\n /**\n * Gets the number of available permits for a given key\n * @param key - The unique identifier for the semaphore\n * @returns Promise resolving to the number of available permits\n */\n getAvailablePermits(key: string): Promise<number>;\n\n /**\n * Gets the total number of permits for a given key\n * @param key - The unique identifier for the semaphore\n * @returns Promise resolving to the total number of permits\n */\n getTotalPermits(key: string): Promise<number>;\n}\n\n/**\n * Configuration options for semaphore\n */\nexport interface SemaphoreOptions {\n /** Maximum number of concurrent permits allowed. Default: 1 */\n permits?: number;\n /** Default timeout in milliseconds for permit acquisition. Default: 30000 */\n timeout?: number;\n /** Storage implementation for persisting semaphore data. Default: {@link MemorySemaphoreStorage} */\n storage?: SemaphoreStorage;\n}\n\n/**\n * In-memory storage implementation for semaphore permits.\n * Suitable for single-instance applications.\n */\nexport class MemorySemaphoreStorage implements SemaphoreStorage {\n private readonly semaphores = new Map<\n string,\n { total: number; available: number }\n >();\n\n /**\n * Attempts to acquire a permit for a given key\n * @param key - The unique identifier for the semaphore\n * @param timeout - Optional timeout in milliseconds for permit acquisition\n * @param signal - Optional AbortSignal for cancelling the acquisition\n * @returns Promise resolving to true if permit was acquired, false if timeout or no permits available\n */\n async acquire(\n key: string,\n timeout: number = 30000,\n signal?: AbortSignal,\n ): Promise<boolean> {\n const startTime = Date.now();\n\n while (Date.now() - startTime < timeout) {\n // Check if aborted\n if (signal?.aborted) {\n throw new Error('Permit acquisition was aborted');\n }\n\n const semaphore = this.semaphores.get(key);\n if (semaphore && semaphore.available > 0) {\n semaphore.available--;\n return true;\n }\n await this.delay(10);\n }\n\n return false;\n }\n\n /**\n * Releases a permit for a given key\n * @param key - The unique identifier for the semaphore\n * @returns Promise that resolves when the permit is released\n */\n async release(key: string): Promise<void> {\n const semaphore = this.semaphores.get(key);\n if (semaphore && semaphore.available < semaphore.total) {\n semaphore.available++;\n }\n }\n\n /**\n * Gets the number of available permits for a given key\n * @param key - The unique identifier for the semaphore\n * @returns Promise resolving to the number of available permits\n */\n async getAvailablePermits(key: string): Promise<number> {\n const semaphore = this.semaphores.get(key);\n return semaphore ? semaphore.available : 0;\n }\n\n /**\n * Gets the total number of permits for a given key\n * @param key - The unique identifier for the semaphore\n * @returns Promise resolving to the total number of permits\n */\n async getTotalPermits(key: string): Promise<number> {\n const semaphore = this.semaphores.get(key);\n return semaphore ? semaphore.total : 0;\n }\n\n /**\n * Initializes a semaphore with the specified number of permits\n * @param key - The unique identifier for the semaphore\n * @param permits - The total number of permits to allocate\n */\n initialize(key: string, permits: number): void {\n this.semaphores.set(key, { total: permits, available: permits });\n }\n\n private delay(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n}\n\n/**\n * Async semaphore implementation that controls access to a limited pool of resources.\n * Allows a specified number of concurrent operations while blocking additional requests.\n */\nexport class Semaphore {\n private storage: SemaphoreStorage;\n private readonly defaultPermits: number;\n private readonly defaultTimeout: number;\n\n /**\n * Creates a new semaphore instance\n * @param options - Configuration options for the semaphore\n */\n public constructor(options: SemaphoreOptions = {}) {\n this.storage = options.storage || new MemorySemaphoreStorage();\n this.defaultPermits = options.permits || 1;\n this.defaultTimeout = options.timeout || 30000;\n }\n\n /**\n * Sets the storage implementation for the semaphore\n * @param storage - The storage implementation to use\n */\n public setStorage(storage: SemaphoreStorage) {\n this.storage = storage;\n }\n\n /**\n * Gets the storage implementation for the semaphore\n * @returns The storage implementation\n */\n public getStorage(): SemaphoreStorage {\n return this.storage;\n }\n\n /**\n * Acquires a permit for the given key\n * @param key - The unique identifier for the semaphore\n * @param timeout - Optional timeout in milliseconds for permit acquisition\n * @param signal - Optional AbortSignal for cancelling the acquisition\n * @returns Promise resolving to true if permit was acquired, false if timeout\n */\n public async acquire(\n key: string,\n timeout?: number,\n signal?: AbortSignal,\n ): Promise<boolean> {\n // Initialize semaphore if it doesn't exist\n if (this.storage instanceof MemorySemaphoreStorage) {\n const totalPermits = await this.storage.getTotalPermits(key);\n if (totalPermits === 0) {\n (this.storage as MemorySemaphoreStorage).initialize(\n key,\n this.defaultPermits,\n );\n }\n }\n\n return this.storage.acquire(key, timeout || this.defaultTimeout, signal);\n }\n\n /**\n * Releases a permit for the given key\n * @param key - The unique identifier for the semaphore\n * @returns Promise that resolves when the permit is released\n */\n public async release(key: string): Promise<void> {\n return this.storage.release(key);\n }\n\n /**\n * Gets the number of available permits for the given key\n * @param key - The unique identifier for the semaphore\n * @returns Promise resolving to the number of available permits\n */\n public async getAvailablePermits(key: string): Promise<number> {\n return this.storage.getAvailablePermits(key);\n }\n\n /**\n * Gets the total number of permits for the given key\n * @param key - The unique identifier for the semaphore\n * @returns Promise resolving to the total number of permits\n */\n public async getTotalPermits(key: string): Promise<number> {\n return this.storage.getTotalPermits(key);\n }\n\n /**\n * Gets the number of acquired permits for the given key\n * @param key - The unique identifier for the semaphore\n * @returns Promise resolving to the number of acquired permits\n */\n public async getAcquiredPermits(key: string): Promise<number> {\n const total = await this.getTotalPermits(key);\n const available = await this.getAvailablePermits(key);\n return total - available;\n }\n\n /**\n * Executes a function with a permit from the semaphore\n * @param key - The unique identifier for the semaphore\n * @param fn - The function to execute with a permit\n * @param timeout - Optional timeout in milliseconds for permit acquisition\n * @param signal - Optional AbortSignal for cancelling the permit acquisition\n * @returns Promise resolving to the result of the function execution\n * @throws Error if permit acquisition fails or function execution fails\n */\n public async withPermit<T>(\n key: string,\n fn: () => Promise<T> | T,\n timeout?: number,\n signal?: AbortSignal,\n ): Promise<T> {\n const acquired = await this.acquire(key, timeout, signal);\n if (!acquired) {\n throw new Error(`Failed to acquire permit for key: ${key}`);\n }\n\n try {\n return await fn();\n } finally {\n await this.release(key);\n }\n }\n\n /**\n * Gets the current configuration of the semaphore\n * @returns Object containing the current permits and timeout values\n */\n public getConfig(): Omit<SemaphoreOptions, 'storage'> {\n return {\n permits: this.defaultPermits,\n timeout: this.defaultTimeout,\n };\n }\n}\n\n/**\n * Default semaphore instance for global use\n */\nexport const defaultSemaphore = new Semaphore();\n\n/**\n * Convenience function to execute a function with a permit using the default semaphore.\n *\n * @param key - The unique identifier for the semaphore\n * @param fn - The function to execute with a permit\n * @param timeout - Optional timeout in milliseconds for permit acquisition\n * @param signal - Optional AbortSignal for cancelling the permit acquisition\n * @returns Promise resolving to the result of the function execution\n *\n * @example\n * ```typescript\n * const controller = new AbortController();\n * const result = await withPermit('database-connection', async () => {\n * // This code runs with a permit from the semaphore\n * return await executeDatabaseQuery();\n * }, 30000, controller.signal);\n * controller.abort(); // Cancels the permit acquisition\n * ```\n */\nexport async function withPermit<T>(\n key: string,\n fn: () => Promise<T> | T,\n timeout?: number,\n signal?: AbortSignal,\n): Promise<T> {\n return defaultSemaphore.withPermit(key, fn, timeout, signal);\n}\n\n/**\n * Creates a new semaphore instance with the specified configuration\n * @param options - Configuration options for the semaphore\n * @returns New Semaphore instance\n *\n * @example\n * ```typescript\n * const semaphore = createSemaphore({\n * permits: 5,\n * timeout: 60000,\n * storage: new RedisSemaphoreStorage()\n * });\n * ```\n */\nexport function createSemaphore(options: SemaphoreOptions): Semaphore {\n return new Semaphore(options);\n}\n\n/**\n * Acquires a permit using the default semaphore\n * @param key - The unique identifier for the semaphore\n * @param timeout - Optional timeout in milliseconds for permit acquisition\n * @param signal - Optional AbortSignal for cancelling the acquisition\n * @returns Promise resolving to true if permit was acquired, false if timeout\n */\nexport async function acquirePermit(\n key: string,\n timeout?: number,\n signal?: AbortSignal,\n): Promise<boolean> {\n return defaultSemaphore.acquire(key, timeout, signal);\n}\n\n/**\n * Releases a permit using the default semaphore\n * @param key - The unique identifier for the semaphore\n * @returns Promise that resolves when the permit is released\n */\nexport async function releasePermit(key: string): Promise<void> {\n return defaultSemaphore.release(key);\n}\n\n/**\n * Gets the number of available permits using the default semaphore\n * @param key - The unique identifier for the semaphore\n * @returns Promise resolving to the number of available permits\n */\nexport async function getAvailablePermits(key: string): Promise<number> {\n return defaultSemaphore.getAvailablePermits(key);\n}\n\n/**\n * Gets the number of acquired permits using the default semaphore\n * @param key - The unique identifier for the semaphore\n * @returns Promise resolving to the number of acquired permits\n */\nexport async function getAcquiredPermits(key: string): Promise<number> {\n return defaultSemaphore.getAcquiredPermits(key);\n}\n"],"mappings":"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"}
|
|
@@ -1,2 +1,113 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/utils/utilities.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Returns the current working directory of the CommandKit application.
|
|
4
|
+
* This is typically the directory where the source code is located.
|
|
5
|
+
*/
|
|
6
|
+
declare function getCurrentDirectory(): string;
|
|
7
|
+
/**
|
|
8
|
+
* Returns the possible source directories for the CommandKit application.
|
|
9
|
+
* This includes the `src`, `.commandkit`, and the distribution directory.
|
|
10
|
+
* @returns An array of possible source directories.
|
|
11
|
+
*/
|
|
12
|
+
declare function getSourceDirectories(): string[];
|
|
13
|
+
/**
|
|
14
|
+
* Returns the path to the app directory.
|
|
15
|
+
* @returns The path to the app directory or `null` if not found.
|
|
16
|
+
*/
|
|
17
|
+
declare function findAppDirectory(): string | null;
|
|
18
|
+
/**
|
|
19
|
+
* Debounces a function.
|
|
20
|
+
* @param fn The function to debounce.
|
|
21
|
+
* @param ms The debounce time in milliseconds.
|
|
22
|
+
* @returns The debounced function.
|
|
23
|
+
* @example
|
|
24
|
+
* const debouncedFn = debounce(() => {
|
|
25
|
+
* console.log('Debounced function called');
|
|
26
|
+
* }, 300);
|
|
27
|
+
*
|
|
28
|
+
* debouncedFn(); // Will only execute after 300ms of inactivity
|
|
29
|
+
* debouncedFn(); // Will reset the timer
|
|
30
|
+
* debouncedFn(); // Will reset the timer again
|
|
31
|
+
*/
|
|
32
|
+
declare function debounce<R, F extends (...args: any[]) => R>(fn: F, ms: number): F;
|
|
33
|
+
/**
|
|
34
|
+
* Defers the execution of a function.
|
|
35
|
+
* @param fn The function to defer.
|
|
36
|
+
* @param timeout The time in milliseconds to wait before executing the function. Defaults to 0.
|
|
37
|
+
* @example
|
|
38
|
+
* defer(() => {
|
|
39
|
+
* console.log('This will run after a delay');
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* console.log('This will run immediately');
|
|
43
|
+
*/
|
|
44
|
+
declare function defer<T>(fn: () => T, timeout?: number): void;
|
|
45
|
+
/**
|
|
46
|
+
* Serializes a value to JSON.
|
|
47
|
+
* @param value The value to serialize.
|
|
48
|
+
* @param defaultValue The default value to return if the value is not serializable.
|
|
49
|
+
* @returns The serialized value.
|
|
50
|
+
*/
|
|
51
|
+
declare function JsonSerialize<R = any>(value: any, defaultValue?: R): R;
|
|
52
|
+
/**
|
|
53
|
+
* Creates a function from the given function that runs only in development mode.
|
|
54
|
+
* @param fn The function to run in development mode.
|
|
55
|
+
* @returns The function that runs only in development mode.
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* const devOnlyFn = devOnly(() => {
|
|
59
|
+
* console.log('This function runs only in development mode');
|
|
60
|
+
* });
|
|
61
|
+
* devOnlyFn(); // This will log the message only in development mode
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
declare function devOnly<T extends (...args: any[]) => any>(fn: T): T;
|
|
65
|
+
/**
|
|
66
|
+
* Creates a function from the given function that runs only in build mode.
|
|
67
|
+
* @param fn The function to run in build mode.
|
|
68
|
+
* @returns The function that runs only in build mode.
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* const buildOnlyFn = buildOnly(() => {
|
|
72
|
+
* console.log('This function runs only in build mode');
|
|
73
|
+
* });
|
|
74
|
+
* buildOnlyFn(); // This will log the message only in build mode
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
declare function buildOnly<T extends (...args: any[]) => any>(fn: T): T;
|
|
78
|
+
/**
|
|
79
|
+
* Creates a function from the given function that runs only outside of build mode.
|
|
80
|
+
* @param fn The function to run outside of build mode.
|
|
81
|
+
* @returns The function that runs only outside of build mode.
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* const noBuildOnlyFn = noBuildOnly(() => {
|
|
85
|
+
* console.log('This function runs only outside of build mode');
|
|
86
|
+
* });
|
|
87
|
+
* noBuildOnlyFn(); // This will log the message only outside of build mode
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
declare function noBuildOnly<T extends (...args: any[]) => any>(fn: T): T;
|
|
91
|
+
/**
|
|
92
|
+
* Represents a simple proxy object that mirrors a target object.
|
|
93
|
+
*/
|
|
94
|
+
interface SimpleProxy<T extends object> {
|
|
95
|
+
/**
|
|
96
|
+
* The proxied object that mirrors the target.
|
|
97
|
+
*/
|
|
98
|
+
proxy: T;
|
|
99
|
+
/**
|
|
100
|
+
* Sets a new target object for the proxy.
|
|
101
|
+
* @param newTarget The new target object to set.
|
|
102
|
+
*/
|
|
103
|
+
setTarget(newTarget: T): void;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Creates a simple proxy object that mirrors the target object.
|
|
107
|
+
* @param target The target object to proxy.
|
|
108
|
+
* @returns The proxied object.
|
|
109
|
+
*/
|
|
110
|
+
declare function createProxy<T extends object>(target: T): SimpleProxy<T>;
|
|
111
|
+
//#endregion
|
|
112
|
+
export { JsonSerialize, SimpleProxy, buildOnly, createProxy, debounce, defer, devOnly, findAppDirectory, getCurrentDirectory, getSourceDirectories, noBuildOnly };
|
|
113
|
+
//# sourceMappingURL=utilities.d.ts.map
|
package/dist/utils/utilities.js
CHANGED
|
@@ -1,45 +1,35 @@
|
|
|
1
|
-
require('../colors-
|
|
2
|
-
require('../ActionRow-
|
|
3
|
-
require('../
|
|
4
|
-
|
|
5
|
-
require('../
|
|
6
|
-
require('../
|
|
7
|
-
require('../
|
|
8
|
-
require('../
|
|
9
|
-
require('../
|
|
10
|
-
require('../
|
|
11
|
-
require('../
|
|
12
|
-
require('../
|
|
13
|
-
require('../
|
|
14
|
-
require('../
|
|
15
|
-
require('../
|
|
16
|
-
require('../
|
|
17
|
-
require('../
|
|
18
|
-
require('../
|
|
19
|
-
require('../
|
|
20
|
-
require('../
|
|
21
|
-
require('../
|
|
22
|
-
require('../
|
|
23
|
-
require('../
|
|
24
|
-
require('../
|
|
25
|
-
require('../types-package-BWArjyBF.js');
|
|
26
|
-
require('../constants-BOOGN85p.js');
|
|
27
|
-
require('../EventWorkerContext-Dq29tieI.js');
|
|
28
|
-
require('../signals-ChFMD7mB.js');
|
|
29
|
-
require('../helpers-Dl8wW6aO.js');
|
|
30
|
-
require('../MessageCommandParser-Dl0xxtdr.js');
|
|
31
|
-
require('../CommandsRouter-Dmzw-ikm.js');
|
|
32
|
-
require('../EventsRouter-3Gygh-km.js');
|
|
33
|
-
require('../router-Dn35v30f.js');
|
|
34
|
-
require('../common-CrqwC-sx.js');
|
|
35
|
-
require('../CommandKitEventsChannel-BtRzr3Tz.js');
|
|
36
|
-
require('../store-CM6pWVZh.js');
|
|
1
|
+
require('../colors-Csc0X4QJ.js');
|
|
2
|
+
require('../ActionRow-CSN_UKmM.js');
|
|
3
|
+
const require_commandkit = require('../commandkit-SIjTLD2R.js');
|
|
4
|
+
require('../container-DCPljKVH.js');
|
|
5
|
+
require('../file-Ca1kpEtE.js');
|
|
6
|
+
require('../media-gallery-u3gjX7yD.js');
|
|
7
|
+
require('../section-BC8LF-B2.js');
|
|
8
|
+
require('../separator-BUTiW7uz.js');
|
|
9
|
+
require('../text-display-DANahMN3.js');
|
|
10
|
+
require('../label-B6vXvwLM.js');
|
|
11
|
+
require('../poll-CFe8yvoJ.js');
|
|
12
|
+
require('../display-WDb9wMCv.js');
|
|
13
|
+
require('../constants-CxkFFZ7p.js');
|
|
14
|
+
require('../types-package-CsTNfvv2.js');
|
|
15
|
+
require('../constants-Cw8VjCVz.js');
|
|
16
|
+
require('../EventWorkerContext-Dfhgv329.js');
|
|
17
|
+
require('../signals-B8z1wJ6W.js');
|
|
18
|
+
require('../helpers-Btx1FSZx.js');
|
|
19
|
+
require('../MessageCommandParser-Bs9fimmd.js');
|
|
20
|
+
require('../CommandsRouter-C_HLsrGX.js');
|
|
21
|
+
require('../EventsRouter-DZYIha6m.js');
|
|
22
|
+
require('../router-BvamdzoF.js');
|
|
23
|
+
require('../common-DSRs_mfw.js');
|
|
24
|
+
require('../store-D8r_hryO.js');
|
|
37
25
|
|
|
38
26
|
exports.JsonSerialize = require_commandkit.JsonSerialize;
|
|
27
|
+
exports.buildOnly = require_commandkit.buildOnly;
|
|
39
28
|
exports.createProxy = require_commandkit.createProxy;
|
|
40
29
|
exports.debounce = require_commandkit.debounce;
|
|
41
30
|
exports.defer = require_commandkit.defer;
|
|
42
31
|
exports.devOnly = require_commandkit.devOnly;
|
|
43
32
|
exports.findAppDirectory = require_commandkit.findAppDirectory;
|
|
44
33
|
exports.getCurrentDirectory = require_commandkit.getCurrentDirectory;
|
|
45
|
-
exports.getSourceDirectories = require_commandkit.getSourceDirectories;
|
|
34
|
+
exports.getSourceDirectories = require_commandkit.getSourceDirectories;
|
|
35
|
+
exports.noBuildOnly = require_commandkit.noBuildOnly;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region src/utils/
|
|
1
|
+
//#region src/utils/warning.d.ts
|
|
2
2
|
/**
|
|
3
3
|
* Emit a warning message to the console as a CommandKitWarning.
|
|
4
4
|
* @param message - The warning message to emit.
|
|
@@ -11,6 +11,15 @@ declare function emitWarning(message: string, code?: string): void;
|
|
|
11
11
|
* @example warnUnstable('MyUnstableFeature');
|
|
12
12
|
*/
|
|
13
13
|
declare function warnUnstable(name: string): void;
|
|
14
|
+
declare function warnDeprecated({
|
|
15
|
+
what,
|
|
16
|
+
message,
|
|
17
|
+
where
|
|
18
|
+
}: {
|
|
19
|
+
what: string;
|
|
20
|
+
where?: string;
|
|
21
|
+
message?: string;
|
|
22
|
+
}): void;
|
|
14
23
|
//#endregion
|
|
15
|
-
export { emitWarning, warnUnstable };
|
|
16
|
-
//# sourceMappingURL=
|
|
24
|
+
export { emitWarning, warnDeprecated, warnUnstable };
|
|
25
|
+
//# sourceMappingURL=warning.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils-
|
|
1
|
+
{"version":3,"file":"utils-Br3eenD1.js","names":[],"sources":["../src/config/utils.ts"],"sourcesContent":["import { CommandKitConfig } from './types';\n\n/**\n * @private\n */\nexport type DeepRequired<T, OptionalKeys extends keyof T = never> = {\n [P in keyof T]-?: P extends OptionalKeys ? Partial<T[P]> : DeepRequired<T[P]>;\n};\n\n/**\n * @private\n */\nexport type DeepPartial<T> = {\n [P in keyof T]?: DeepPartial<T[P]>;\n};\n\n/**\n * @private\n * @example\n * ```ts\n * const target = { a: 1, b: { c: 2 } };\n * const source = { b: { d: 3 } };\n * const result = mergeDeep(target, source);\n * // result = { a: 1, b: { c: 2, d: 3 } }\n * ```\n */\nexport const mergeDeep = <T extends Record<string, any>>(\n target: T,\n source?: T,\n tracker = new WeakMap<object, boolean>(),\n): T => {\n if (!source) return target;\n const isObject = (obj: unknown) =>\n obj && typeof obj === 'object' && !Array.isArray(obj);\n\n // Prevent infinite recursion\n if (tracker.has(target)) {\n return target;\n }\n\n // Mark the target as visited\n tracker.set(target, true);\n\n const output: T = { ...target };\n if (isObject(target) && isObject(source)) {\n Object.keys(source).forEach((key) => {\n if (isObject(source[key])) {\n if (!(key in target)) {\n Object.assign(output, { [key]: source[key] });\n } else {\n output[key as keyof T] = mergeDeep(target[key], source[key], tracker);\n }\n } else {\n Object.assign(output, { [key]: source[key] });\n }\n });\n }\n\n return output as T;\n};\n\nexport type ResolvedCommandKitConfig = DeepRequired<\n CommandKitConfig,\n 'compilerOptions'\n>;\n"],"mappings":";;;;;;;;;;;;AA0BA,MAAa,aACb,QACA,QACA,0BAAU,IAAE,SAA4B,KACjC;AACL,KAAI,CAAC,OAAQ,QAAO;CACpB,MAAM,YAAY,QAClB,OAAO,OAAE,QAAa,YAAY,CAAC,MAAE,QAAM,IAAQ;AAGnD,KAAI,QAAQ,IAAI,OAAO,CACrB,QAAO;AAIT,SAAQ,IAAI,QAAQ,KAAK;CAEzB,MAAM,SAAY,EAAE,GAAG,QAAQ;AAC/B,KAAI,SAAS,OAAO,IAAI,SAAS,OAAO,CACtC,QAAO,KAAK,OAAO,CAAC,SAAS,QAAQ;AACnC,MAAI,SAAS,OAAO,KAAK,CACvB,KAAI,EAAE,OAAO,QACX,QAAO,OAAO,QAAQ,GAAG,MAAM,OAAO,MAAM,CAAC;MAE7C,QAAO,OAAkB,UAAU,OAAO,MAAM,OAAO,MAAM,QAAQ;MAGvE,QAAO,OAAO,QAAQ,GAAG,MAAM,OAAO,MAAM,CAAC;GAE/C;AAGJ,QAAO"}
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
const require_version = require('./version--Q1nmlBz.js');
|
|
2
1
|
|
|
3
|
-
|
|
2
|
+
//#region src/version.ts
|
|
3
|
+
/**
|
|
4
|
+
* @private
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* The current version of CommandKit.
|
|
8
|
+
*/
|
|
9
|
+
const version = "1.2.0-rc.13";
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
exports.version = version;
|
|
13
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","names":[],"sources":["../src/version.ts"],"sourcesContent":["/**\n * @private\n */\nfunction $version(): string {\n 'use macro';\n return require('../package.json').version;\n}\n\n/**\n * The current version of CommandKit.\n */\nexport const version: string = $version();\n"],"mappings":";;;;;;;;AAWA,MAAa,UAA4B"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/utils/warning.ts
|
|
3
|
+
const WARNED_KEYS = /* @__PURE__ */ new Set();
|
|
4
|
+
const DEPRECATED_KEYS = /* @__PURE__ */ new Set();
|
|
5
|
+
/**
|
|
6
|
+
* Emit a warning message to the console as a CommandKitWarning.
|
|
7
|
+
* @param message - The warning message to emit.
|
|
8
|
+
* @param code - The warning code (default is 'CommandKitWarning').
|
|
9
|
+
*/
|
|
10
|
+
function emitWarning(message, code = "CommandKitWarning") {
|
|
11
|
+
process.emitWarning(message, { code });
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Emit a warning for unstable features in CommandKit.
|
|
15
|
+
* @param name - The name of the unstable feature.
|
|
16
|
+
* @example warnUnstable('MyUnstableFeature');
|
|
17
|
+
*/
|
|
18
|
+
function warnUnstable(name) {
|
|
19
|
+
if (WARNED_KEYS.has(name)) return;
|
|
20
|
+
WARNED_KEYS.add(name);
|
|
21
|
+
emitWarning(`${name} is unstable and may change in future versions.`, "CommandKitUnstableWarning");
|
|
22
|
+
}
|
|
23
|
+
function warnDeprecated({ what, message, where }) {
|
|
24
|
+
const name = `${what}:${where}`;
|
|
25
|
+
if (DEPRECATED_KEYS.has(name)) return;
|
|
26
|
+
DEPRECATED_KEYS.add(name);
|
|
27
|
+
emitWarning([
|
|
28
|
+
`${what} is deprecated`,
|
|
29
|
+
where ? `in ${where}` : "",
|
|
30
|
+
message || "and may be removed in future versions."
|
|
31
|
+
].filter(Boolean).join(" "), "CommandKitDeprecatedWarning");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
Object.defineProperty(exports, 'emitWarning', {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: function () {
|
|
38
|
+
return emitWarning;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
Object.defineProperty(exports, 'warnDeprecated', {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: function () {
|
|
44
|
+
return warnDeprecated;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
Object.defineProperty(exports, 'warnUnstable', {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
get: function () {
|
|
50
|
+
return warnUnstable;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=warning-CszH8HeS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warning-CszH8HeS.js","names":[],"sources":["../src/utils/warning.ts"],"sourcesContent":["const WARNED_KEYS = new Set<string>();\nconst DEPRECATED_KEYS = new Set<string>();\n\n/**\n * Emit a warning message to the console as a CommandKitWarning.\n * @param message - The warning message to emit.\n * @param code - The warning code (default is 'CommandKitWarning').\n */\nexport function emitWarning(message: string, code = 'CommandKitWarning') {\n process.emitWarning(message, { code });\n}\n\n/**\n * Emit a warning for unstable features in CommandKit.\n * @param name - The name of the unstable feature.\n * @example warnUnstable('MyUnstableFeature');\n */\nexport function warnUnstable(name: string) {\n if (WARNED_KEYS.has(name)) return;\n\n WARNED_KEYS.add(name);\n\n emitWarning(\n `${name} is unstable and may change in future versions.`,\n 'CommandKitUnstableWarning',\n );\n}\nexport function warnDeprecated({\n what,\n message,\n where,\n}: {\n what: string;\n where?: string;\n message?: string;\n}) {\n const name = `${what}:${where}`;\n\n if (DEPRECATED_KEYS.has(name)) return;\n\n DEPRECATED_KEYS.add(name);\n\n emitWarning(\n [\n `${what} is deprecated`,\n where ? `in ${where}` : '',\n message || 'and may be removed in future versions.',\n ]\n .filter(Boolean)\n .join(' '),\n 'CommandKitDeprecatedWarning',\n );\n}\n"],"mappings":";;AAAA,MAAM,8BAAc,IAAI,KAAa;AACrC,MAAM,kCAAkB,IAAI,KAAa;;;;;;AAOzC,SAAgB,YAAY,SAAiB,OAAO,qBAAqB;AACvE,SAAQ,YAAY,SAAS,EAAE,MAAM,CAAC;;;;;;;AAQxC,SAAgB,aAAa,MAAc;AACzC,KAAI,YAAY,IAAI,KAAK,CAAE;AAE3B,aAAY,IAAI,KAAK;AAErB,aACE,GAAG,KAAK,kDACR,4BACD;;AAEH,SAAgB,eAAe,EAC7B,MACA,SACA,SAKC;CACD,MAAM,OAAO,GAAG,KAAK,GAAG;AAExB,KAAI,gBAAgB,IAAI,KAAK,CAAE;AAE/B,iBAAgB,IAAI,KAAK;AAEzB,aACE;EACA,GAAG,KAAE;EACL,QAAQ,MAAM,UAAU;EACxB,WAAW;EAAyC,CAEpD,OAAG,QAAO,CACV,KAAG,IAAM,EACT,8BACD"}
|
package/hooks.cjs
CHANGED
|
@@ -9,11 +9,18 @@ const {
|
|
|
9
9
|
} = require('./dist/app/events/EventWorkerContext.js');
|
|
10
10
|
|
|
11
11
|
function useAnyEnvironment() {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
try {
|
|
13
|
+
const commandCtx = getContext();
|
|
14
|
+
if (commandCtx) return commandCtx;
|
|
15
|
+
} catch {}
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
const eventWorkerCtx = getEventWorkerContext();
|
|
19
|
+
if (eventWorkerCtx) return eventWorkerCtx;
|
|
20
|
+
} catch {}
|
|
14
21
|
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
22
|
+
const maybeCommandKit = getCommandKit();
|
|
23
|
+
if (maybeCommandKit) return { commandkit: maybeCommandKit };
|
|
17
24
|
|
|
18
25
|
throw new Error(
|
|
19
26
|
'No environment found. This hook must be used within a CommandKit environment.',
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "commandkit",
|
|
3
3
|
"description": "Beginner friendly command & event handler for Discord.js",
|
|
4
|
-
"version": "1.2.0-rc.
|
|
4
|
+
"version": "1.2.0-rc.13",
|
|
5
5
|
"license": "GPL-3.0-only",
|
|
6
6
|
"type": "commonjs",
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -46,7 +46,9 @@
|
|
|
46
46
|
"./mutex.cjs",
|
|
47
47
|
"./mutex.d.ts",
|
|
48
48
|
"./kv.cjs",
|
|
49
|
-
"./kv.d.ts"
|
|
49
|
+
"./kv.d.ts",
|
|
50
|
+
"./cli.cjs",
|
|
51
|
+
"./cli.d.ts"
|
|
50
52
|
],
|
|
51
53
|
"exports": {
|
|
52
54
|
".": {
|
|
@@ -143,11 +145,16 @@
|
|
|
143
145
|
"require": "./semaphore.cjs",
|
|
144
146
|
"import": "./semaphore.cjs",
|
|
145
147
|
"types": "./semaphore.d.ts"
|
|
148
|
+
},
|
|
149
|
+
"./cli": {
|
|
150
|
+
"require": "./cli.cjs",
|
|
151
|
+
"import": "./cli.cjs",
|
|
152
|
+
"types": "./cli.d.ts"
|
|
146
153
|
}
|
|
147
154
|
},
|
|
148
155
|
"repository": {
|
|
149
156
|
"type": "git",
|
|
150
|
-
"url": "https://github.com/
|
|
157
|
+
"url": "https://github.com/neplextech/commandkit",
|
|
151
158
|
"directory": "packages/commandkit"
|
|
152
159
|
},
|
|
153
160
|
"homepage": "https://commandkit.dev",
|
|
@@ -169,18 +176,18 @@
|
|
|
169
176
|
"picocolors": "^1.1.1",
|
|
170
177
|
"rfdc": "^1.3.1",
|
|
171
178
|
"rimraf": "^6.0.0",
|
|
172
|
-
"tsdown": "^0.
|
|
179
|
+
"tsdown": "^0.20.0-beta.3",
|
|
173
180
|
"use-macro": "^1.1.0"
|
|
174
181
|
},
|
|
175
182
|
"devDependencies": {
|
|
176
183
|
"@types/ms": "^2.0.0",
|
|
177
184
|
"@types/node": "^22.10.2",
|
|
178
185
|
"@types/yargs": "^17.0.32",
|
|
179
|
-
"discord.js": "^14.
|
|
186
|
+
"discord.js": "^14.24.0",
|
|
180
187
|
"tsx": "^4.19.2",
|
|
181
|
-
"typescript": "^5.
|
|
188
|
+
"typescript": "^5.9.3",
|
|
182
189
|
"vitest": "^3.0.5",
|
|
183
|
-
"tsconfig": "0.0.0-rc.
|
|
190
|
+
"tsconfig": "0.0.0-rc.13"
|
|
184
191
|
},
|
|
185
192
|
"engines": {
|
|
186
193
|
"node": ">=24"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ActionRow-CbdGFWMT.js","names":[],"sources":["../src/components/v1/action-row/ActionRow.ts"],"sourcesContent":["import { ActionRowBuilder } from 'discord.js';\nimport { AnyCommandKitElement, CommandKitElement } from '../../common/element';\n\n/**\n * The properties for the action row component.\n */\nexport interface ActionRowProps {\n children?: AnyCommandKitElement[] | AnyCommandKitElement;\n}\n\n/**\n * The action row component.\n * @param props The action row properties.\n * @returns The commandkit element.\n * @example <ActionRow><Button label=\"Click me\" style={ButtonStyle.Primary} customId=\"click_me\" /></ActionRow>\n */\nexport function ActionRow(\n props: ActionRowProps,\n): CommandKitElement<'action-row'> {\n const row = new ActionRowBuilder();\n\n if (Array.isArray(props.children)) {\n // @ts-ignore\n row.setComponents(...props.children);\n } else if (props.children) {\n // @ts-ignore\n row.setComponents(props.children);\n }\n\n return row;\n}\n"],"mappings":";;;;;;;;;;;AAgBA,SAAgB,UAChB,OACkC;CAChC,MAAM,MAAM,IAAI,6BAAkB;AAElC,KAAI,MAAM,QAAQ,MAAM,SAAS,CAE/B,KAAI,cAAc,GAAG,MAAM,SAAS;UAC3B,MAAM,SAEf,KAAI,cAAc,MAAM,SAAS;AAGnC,QAAO"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { EventInterceptorErrorHandler } from "./EventInterceptor-x-R2qshQ.js";
|
|
2
|
-
import { CommandKitSelectMenuBuilderInteractionCollectorDispatch, CommandKitSelectMenuBuilderInteractionCollectorDispatchContextData, CommandKitSelectMenuBuilderOnEnd, OnSelectMenuKitSubmit, SelectMenuKitPredicate } from "./common-DOCvOVC4.js";
|
|
3
|
-
import { ChannelSelectMenuBuilder, ChannelSelectMenuInteraction } from "discord.js";
|
|
4
|
-
|
|
5
|
-
//#region src/components/v1/select-menu/ChannelSelectMenuKit.d.ts
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Type for the handler function that is called when the channel select menu is submitted.
|
|
9
|
-
*/
|
|
10
|
-
type OnChannelSelectMenuKitSubmit = OnSelectMenuKitSubmit<ChannelSelectMenuInteraction, ChannelSelectMenuKit>;
|
|
11
|
-
/**
|
|
12
|
-
* Type for the predicate function that filters channel select menu interactions.
|
|
13
|
-
* It receives a ChannelSelectMenuInteraction and returns a boolean or a Promise that resolves to a boolean.
|
|
14
|
-
*/
|
|
15
|
-
type ChannelSelectMenuKitPredicate = SelectMenuKitPredicate<ChannelSelectMenuInteraction>;
|
|
16
|
-
/**
|
|
17
|
-
* A builder for creating channel select menus with additional features like interaction collectors and event handling.
|
|
18
|
-
* This class extends the ChannelSelectMenuBuilder from discord.js and adds methods for handling interactions.
|
|
19
|
-
* It allows you to set a handler for when the channel select menu is submitted, filter interactions, and handle the end of the interaction collector.
|
|
20
|
-
*/
|
|
21
|
-
declare class ChannelSelectMenuKit extends ChannelSelectMenuBuilder {
|
|
22
|
-
#private;
|
|
23
|
-
/**
|
|
24
|
-
* Sets the handler to run when the modal is submitted.
|
|
25
|
-
* @param handler - The handler to run when the modal is submitted.
|
|
26
|
-
* @param data - The context data for the interaction collector.
|
|
27
|
-
* @returns This instance of the modal builder.
|
|
28
|
-
* @example
|
|
29
|
-
* ```ts
|
|
30
|
-
* const modal = new ChannelSelectMenuKit()
|
|
31
|
-
* .setTitle('My Modal')
|
|
32
|
-
* .setCustomId('my-modal')
|
|
33
|
-
* .filter((interaction) => interaction.Channel.id === '1234567890')
|
|
34
|
-
* .onSelect(async (interaction) => {
|
|
35
|
-
* await interaction.reply('You submitted the modal!');
|
|
36
|
-
* })
|
|
37
|
-
* .addComponents(actionRow1, actionRow2);
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
onSelect(handler: CommandKitSelectMenuBuilderInteractionCollectorDispatch<ChannelSelectMenuInteraction, ChannelSelectMenuKit>, data?: CommandKitSelectMenuBuilderInteractionCollectorDispatchContextData): this;
|
|
41
|
-
/**
|
|
42
|
-
* Sets the handler to run when the interaction collector ends.
|
|
43
|
-
* @param handler - The handler to run when the interaction collector ends.
|
|
44
|
-
* @returns This instance of the modal builder.
|
|
45
|
-
*/
|
|
46
|
-
onEnd(handler: CommandKitSelectMenuBuilderOnEnd): this;
|
|
47
|
-
/**
|
|
48
|
-
* Sets the handler to run when the interaction collector ends.
|
|
49
|
-
* @param handler - The handler to run when the interaction collector ends.
|
|
50
|
-
* @returns This instance of the modal builder.
|
|
51
|
-
*/
|
|
52
|
-
onError(handler: EventInterceptorErrorHandler): this;
|
|
53
|
-
/**
|
|
54
|
-
* Sets a filter for the interaction collector.
|
|
55
|
-
* @param predicate - The filter to use for the interaction collector.
|
|
56
|
-
* @returns This instance of the modal builder.
|
|
57
|
-
*/
|
|
58
|
-
filter(predicate: SelectMenuKitPredicate<ChannelSelectMenuInteraction>): this;
|
|
59
|
-
private get customId();
|
|
60
|
-
/**
|
|
61
|
-
* Cleans up the interaction collector and removes the handler.
|
|
62
|
-
*/
|
|
63
|
-
dispose(): this;
|
|
64
|
-
}
|
|
65
|
-
//#endregion
|
|
66
|
-
export { ChannelSelectMenuKit, ChannelSelectMenuKitPredicate, OnChannelSelectMenuKitSubmit };
|
|
67
|
-
//# sourceMappingURL=ChannelSelectMenuKit-BrXvBYNH.d.ts.map
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { ILogger } from "./ILogger-BW8GM-YZ.js";
|
|
2
|
-
|
|
3
|
-
//#region src/logger/DefaultLogger.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Default logger implementation that logs messages to the console.
|
|
7
|
-
* It formats the log messages with timestamps, log levels, and context information.
|
|
8
|
-
*/
|
|
9
|
-
declare class DefaultLogger implements ILogger {
|
|
10
|
-
stdout: NodeJS.WriteStream & {
|
|
11
|
-
fd: 1;
|
|
12
|
-
};
|
|
13
|
-
stderr: NodeJS.WriteStream & {
|
|
14
|
-
fd: 2;
|
|
15
|
-
};
|
|
16
|
-
private logger;
|
|
17
|
-
/**
|
|
18
|
-
* Creates a new instance of DefaultLogger.
|
|
19
|
-
* @param stdout The output stream for standard messages (default: process.stdout).
|
|
20
|
-
* @param stderr The output stream for error messages (default: process.stderr).
|
|
21
|
-
*/
|
|
22
|
-
constructor(stdout?: NodeJS.WriteStream & {
|
|
23
|
-
fd: 1;
|
|
24
|
-
}, stderr?: NodeJS.WriteStream & {
|
|
25
|
-
fd: 2;
|
|
26
|
-
});
|
|
27
|
-
private _formatTime;
|
|
28
|
-
private _getContext;
|
|
29
|
-
private _getLevelLabel;
|
|
30
|
-
private _getPrefix;
|
|
31
|
-
private _log;
|
|
32
|
-
private _logTemplate;
|
|
33
|
-
/**
|
|
34
|
-
* Logs a debug message.
|
|
35
|
-
* @param message The message to log.
|
|
36
|
-
*/
|
|
37
|
-
debug(message: any): void;
|
|
38
|
-
debug(strings: TemplateStringsArray, ...values: any[]): void;
|
|
39
|
-
/**
|
|
40
|
-
* Logs an error message.
|
|
41
|
-
* @param message The error message to log.
|
|
42
|
-
*/
|
|
43
|
-
error(message: any): void;
|
|
44
|
-
error(strings: TemplateStringsArray, ...values: any[]): void;
|
|
45
|
-
/**
|
|
46
|
-
* Logs a default message.
|
|
47
|
-
* @param message The message to log.
|
|
48
|
-
*/
|
|
49
|
-
log(message: any): void;
|
|
50
|
-
log(strings: TemplateStringsArray, ...values: any[]): void;
|
|
51
|
-
/**
|
|
52
|
-
* Logs an info message.
|
|
53
|
-
* @param message The informational message to log.
|
|
54
|
-
*/
|
|
55
|
-
info(message: any): void;
|
|
56
|
-
info(strings: TemplateStringsArray, ...values: any[]): void;
|
|
57
|
-
/**
|
|
58
|
-
* Logs a warning message.
|
|
59
|
-
* @param message The warning message to log.
|
|
60
|
-
*/
|
|
61
|
-
warn(message: any): void;
|
|
62
|
-
warn(strings: TemplateStringsArray, ...values: any[]): void;
|
|
63
|
-
private _isTemplateStringsArray;
|
|
64
|
-
}
|
|
65
|
-
//#endregion
|
|
66
|
-
export { DefaultLogger };
|
|
67
|
-
//# sourceMappingURL=DefaultLogger-XCOl5nLd.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EventWorkerContext-Dq29tieI.js","names":[],"sources":["../src/app/events/EventWorkerContext.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks';\nimport { ParsedEvent } from '../router';\nimport { CommandKit } from '../../commandkit';\n\n/**\n * Context object containing information about the currently executing event.\n */\nexport interface EventWorkerContext {\n event: string;\n namespace: string | null;\n data: ParsedEvent;\n commandkit: CommandKit;\n arguments: any[];\n variables: Map<string, any>;\n}\n\n/**\n * @private\n * @internal\n */\nconst kEventWorker = Symbol('commandkitEventWorker');\n\n/**\n * Async local storage for event worker context.\n */\nexport const eventWorkerContext = new AsyncLocalStorage<EventWorkerContext>();\n\n/**\n * Runs a callback within an event worker context.\n * @param context - The event worker context\n * @param callback - The callback to execute\n * @returns The result of the callback\n */\nexport function runInEventWorkerContext<T>(\n context: EventWorkerContext,\n callback: () => T,\n): T {\n Reflect.set(context, kEventWorker, true);\n\n return eventWorkerContext.run(context, callback);\n}\n\n/**\n * Gets the current event worker context.\n * @returns The current event worker context\n * @throws Error if no context is found\n */\nexport function getEventWorkerContext(): EventWorkerContext {\n const context = eventWorkerContext.getStore();\n\n if (!context) {\n throw new Error('Event worker context not found');\n }\n\n return context;\n}\n\n/**\n * Type guard to check if an object is an event worker context.\n * @param worker - The object to check\n * @returns True if the object is an event worker context\n */\nexport function isEventWorkerContext(\n worker: any,\n): worker is EventWorkerContext {\n return worker && Reflect.get(worker, kEventWorker) === true;\n}\n"],"mappings":";;;;;;;;;AAoBA,MAAM,eAAe,OAAO,wBAAwB;;;;AAKpD,MAAa,qBAAqB,IAAI,oCAAuC;;;;;;;AAQ7E,SAAgB,wBAChB,SACA,UACI;AACF,SAAQ,IAAI,SAAS,cAAc,KAAK;AAExC,QAAO,mBAAmB,IAAI,SAAS,SAAS;;;;;;;AAQlD,SAAgB,wBAA4C;CAC1D,MAAM,UAAU,mBAAmB,UAAU;AAE7C,KAAI,CAAC,QACH,OAAM,IAAI,MAAM,iCAAiC;AAGnD,QAAO;;;;;;;AAQT,SAAgB,qBAChB,QAC+B;AAC7B,QAAO,UAAU,QAAQ,IAAI,QAAQ,aAAa,KAAK"}
|