commandkit 1.2.0-dev.20251125125452 → 1.2.0-dev.20260114150514
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/dist/{ActionRow-BtKd-ZRS.d.ts → ActionRow-B-CGmjDp.d.ts} +2 -3
- package/dist/{ActionRow-D6knpVd6.js → ActionRow-CSN_UKmM.js} +2 -2
- package/dist/{ActionRow-D6knpVd6.js.map → ActionRow-CSN_UKmM.js.map} +1 -1
- package/dist/{Button-DiXeKdXO.d.ts → Button-C-GPeFA3.d.ts} +5 -6
- package/dist/{ButtonKit-B_HCmb3D.d.ts → ButtonKit-DKu0VAe4.d.ts} +35 -36
- package/dist/{ChannelSelectMenuKit-DrsqXWiO.d.ts → ChannelSelectMenuKit-HQZ4hH5s.d.ts} +33 -34
- package/dist/{CommandKitEventsChannel-2l9Za-le.js → CommandKitEventsChannel-CnT5ymYe.js} +2 -2
- package/dist/{CommandKitEventsChannel-2l9Za-le.js.map → CommandKitEventsChannel-CnT5ymYe.js.map} +1 -1
- package/dist/{CommandsRouter-Bdkx7SZS.d.ts → CommandsRouter-C7dZEepB.d.ts} +48 -49
- package/dist/{CommandsRouter-NAgpWzTJ.js → CommandsRouter-C_HLsrGX.js} +2 -2
- package/dist/{CommandsRouter-NAgpWzTJ.js.map → CommandsRouter-C_HLsrGX.js.map} +1 -1
- package/dist/{CompilerPlugin-DbN5-ls3.js → CompilerPlugin-CUsGAfgl.js} +2 -2
- package/dist/{CompilerPlugin-DbN5-ls3.js.map → CompilerPlugin-CUsGAfgl.js.map} +1 -1
- package/dist/EventInterceptor-BWoEJMHZ.js.map +1 -1
- package/dist/{EventInterceptor-Dk5Fwu-7.d.ts → EventInterceptor-CZmWpS08.d.ts} +39 -39
- package/dist/{EventWorkerContext-yTm5vI3b.js → EventWorkerContext-Dfhgv329.js} +2 -2
- package/dist/{EventWorkerContext-yTm5vI3b.js.map → EventWorkerContext-Dfhgv329.js.map} +1 -1
- package/dist/{EventsRouter-bILsV3Lh.d.ts → EventsRouter-DZ37r54v.d.ts} +34 -34
- package/dist/{EventsRouter-D4_vBMhl.js → EventsRouter-DZYIha6m.js} +2 -2
- package/dist/{EventsRouter-D4_vBMhl.js.map → EventsRouter-DZYIha6m.js.map} +1 -1
- package/dist/{MentionableSelectMenuKit-DNan_JWk.d.ts → MentionableSelectMenuKit-7URDUM3-.d.ts} +33 -34
- package/dist/{MessageCommandParser-CD7ynlBO.js → MessageCommandParser-Bs9fimmd.js} +2 -2
- package/dist/{MessageCommandParser-CD7ynlBO.js.map → MessageCommandParser-Bs9fimmd.js.map} +1 -1
- package/dist/MessageCommandParser-q3dQcE5N.d.ts +194 -0
- package/dist/{Modal-Dd5plFpo.d.ts → Modal-CZT9MZsy.d.ts} +7 -8
- package/dist/{ModalKit-C8WkeoDl.d.ts → ModalKit-BWXI3Z26.d.ts} +32 -33
- package/dist/{PluginCommon-Bp5T3ubs.js → PluginCommon-BLxWww5u.js} +6 -6
- package/dist/{PluginCommon-Bp5T3ubs.js.map → PluginCommon-BLxWww5u.js.map} +1 -1
- package/dist/{RoleSelectMenuKit-FfGw3CSa.d.ts → RoleSelectMenuKit-BY-JJ18w.d.ts} +33 -34
- package/dist/{RuntimePlugin-Bq6z-Upz.js → RuntimePlugin-CtobluSU.js} +2 -2
- package/dist/{RuntimePlugin-Bq6z-Upz.js.map → RuntimePlugin-CtobluSU.js.map} +1 -1
- package/dist/{SelectMenu-DTWKY-JJ.d.ts → SelectMenu-q_b3Mjv9.d.ts} +8 -9
- package/dist/{StringSelectMenuKit-BMA0rjhA.d.ts → StringSelectMenuKit-lVhUMc3g.d.ts} +33 -34
- package/dist/{UserSelectMenuKit-CRpFbwA9.d.ts → UserSelectMenuKit-CCj4Fpkr.d.ts} +33 -34
- package/dist/analytics/analytics-engine.d.ts +1 -33
- package/dist/analytics/analytics-engine.js +21 -36
- package/dist/analytics/analytics-provider.d.ts +1 -33
- package/dist/analytics/constants.js +1 -1
- package/dist/analytics/utils.js +21 -36
- package/dist/{analytics-engine-DHmLGxFA.d.ts → analytics-engine-WQhXmx3H.d.ts} +840 -840
- package/dist/app/commands/AppCommandRunner.d.ts +1 -33
- package/dist/app/commands/AppCommandRunner.js +21 -36
- package/dist/app/commands/Context.d.ts +1 -33
- package/dist/app/commands/Context.js +21 -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 -35
- package/dist/app/events/EventWorkerContext.js +1 -1
- package/dist/app/handlers/AppCommandHandler.d.ts +1 -33
- package/dist/app/handlers/AppCommandHandler.js +21 -36
- package/dist/app/handlers/AppEventsHandler.d.ts +1 -33
- package/dist/app/handlers/AppEventsHandler.js +21 -36
- package/dist/app/index.d.ts +4 -33
- package/dist/app/index.js +21 -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 -33
- package/dist/app/middlewares/permissions.js +21 -36
- package/dist/app/register/CommandRegistrar.d.ts +1 -33
- package/dist/app/register/CommandRegistrar.js +21 -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 +2 -2
- 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 +61 -6
- package/dist/cli/app-process.js.map +1 -0
- package/dist/cli/build.d.ts +2 -33
- package/dist/cli/build.js +189 -42
- package/dist/cli/build.js.map +1 -0
- package/dist/cli/common.d.ts +1 -33
- package/dist/cli/common.js +3 -3
- package/dist/cli/development.d.ts +1 -2
- package/dist/cli/development.js +30 -44
- package/dist/cli/development.js.map +1 -1
- package/dist/cli/env.js +1 -1
- package/dist/cli/generators.js +4 -4
- package/dist/cli/generators.js.map +1 -1
- package/dist/cli/information.js +2 -2
- package/dist/cli/information.js.map +1 -1
- package/dist/cli/init.d.ts +0 -1
- package/dist/cli/init.js +27 -41
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/production.d.ts +0 -1
- package/dist/cli/production.js +33 -47
- package/dist/cli/production.js.map +1 -1
- package/dist/cli/type-checker.js +4 -4
- 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-CLmBiP9I.js → colors-Csc0X4QJ.js} +2 -2
- package/dist/{colors-CLmBiP9I.js.map → colors-Csc0X4QJ.js.map} +1 -1
- package/dist/{commandkit-B0wT0Mxx.js → commandkit-SIjTLD2R.js} +31 -31
- package/dist/{commandkit-B0wT0Mxx.js.map → commandkit-SIjTLD2R.js.map} +1 -1
- package/dist/commandkit.d.ts +1 -33
- package/dist/commandkit.js +21 -36
- package/dist/{common-B2-sF49Q.js → common-DSRs_mfw.js} +6 -6
- package/dist/{common-B2-sF49Q.js.map → common-DSRs_mfw.js.map} +1 -1
- package/dist/{common-DAxu7-kG.d.ts → common-DnwCYit8.d.ts} +2 -3
- package/dist/components/common/EventInterceptor.d.ts +1 -1
- package/dist/components/common/element.d.ts +1 -4
- package/dist/components/common/types.d.ts +1 -1
- package/dist/components/common/types.js +0 -1
- package/dist/components/display/common.d.ts +0 -1
- package/dist/components/display/container.d.ts +1 -1
- package/dist/components/display/container.js +1 -2
- package/dist/components/display/file.d.ts +1 -1
- package/dist/components/display/file.js +1 -1
- package/dist/components/display/index.d.ts +8 -9
- package/dist/components/display/index.js +8 -9
- package/dist/components/display/label.d.ts +1 -1
- package/dist/components/display/label.js +1 -2
- package/dist/components/display/media-gallery.d.ts +1 -1
- package/dist/components/display/media-gallery.js +1 -2
- package/dist/components/display/poll.d.ts +1 -1
- package/dist/components/display/poll.js +1 -1
- package/dist/components/display/section.d.ts +1 -1
- package/dist/components/display/section.js +1 -2
- package/dist/components/display/separator.d.ts +1 -1
- package/dist/components/display/separator.js +1 -1
- package/dist/components/display/text-display.d.ts +1 -1
- package/dist/components/display/text-display.js +1 -1
- package/dist/components/index.d.ts +22 -25
- package/dist/components/index.js +21 -35
- package/dist/components/interactive/action-row/ActionRow.d.ts +1 -5
- package/dist/components/interactive/action-row/ActionRow.js +1 -1
- package/dist/components/interactive/button/Button.d.ts +1 -6
- package/dist/components/interactive/button/Button.js +21 -36
- package/dist/components/interactive/button/ButtonKit.d.ts +1 -2
- package/dist/components/interactive/button/ButtonKit.js +21 -36
- package/dist/components/interactive/modal/Modal.d.ts +1 -6
- package/dist/components/interactive/modal/Modal.js +21 -36
- package/dist/components/interactive/modal/ModalKit.d.ts +1 -2
- package/dist/components/interactive/modal/ModalKit.js +21 -36
- package/dist/components/interactive/select-menu/ChannelSelectMenuKit.d.ts +1 -3
- package/dist/components/interactive/select-menu/ChannelSelectMenuKit.js +21 -36
- package/dist/components/interactive/select-menu/MentionableSelectMenuKit.d.ts +1 -3
- package/dist/components/interactive/select-menu/MentionableSelectMenuKit.js +21 -36
- package/dist/components/interactive/select-menu/RoleSelectMenuKit.d.ts +1 -3
- package/dist/components/interactive/select-menu/RoleSelectMenuKit.js +21 -36
- package/dist/components/interactive/select-menu/SelectMenu.d.ts +1 -9
- package/dist/components/interactive/select-menu/SelectMenu.js +21 -36
- package/dist/components/interactive/select-menu/StringSelectMenuKit.d.ts +1 -3
- package/dist/components/interactive/select-menu/StringSelectMenuKit.js +21 -36
- package/dist/components/interactive/select-menu/UserSelectMenuKit.d.ts +1 -3
- package/dist/components/interactive/select-menu/UserSelectMenuKit.js +21 -36
- package/dist/components/interactive/select-menu/common.d.ts +1 -2
- package/dist/components/interactive/select-menu/common.js +0 -1
- package/dist/config/config.d.ts +15 -35
- package/dist/config/config.js +21 -36
- package/dist/config/default.d.ts +1 -33
- package/dist/config/default.js +21 -36
- package/dist/config/loader.d.ts +1 -33
- package/dist/config/loader.js +21 -36
- package/dist/config/types.d.ts +1 -33
- package/dist/config/utils.d.ts +1 -33
- package/dist/constants-BFFK-hfP.js +27 -0
- package/dist/{constants-Dy6P2veX.js.map → constants-BFFK-hfP.js.map} +1 -1
- package/dist/{constants-CAMgxUyw.d.ts → constants-CuYW0K10.d.ts} +7 -7
- package/dist/{constants-BqrEmoih.js → constants-Cw8VjCVz.js} +2 -2
- package/dist/{constants-BqrEmoih.js.map → constants-Cw8VjCVz.js.map} +1 -1
- package/dist/{constants-D95ayHBM.d.ts → constants-EpKcj0dH.d.ts} +1 -1
- package/dist/{container-C319x4cG.js → container-DCPljKVH.js} +2 -2
- package/dist/{container-C319x4cG.js.map → container-DCPljKVH.js.map} +1 -1
- package/dist/{container-0C3ZMb_f.d.ts → container-DYcb7zGw.d.ts} +1 -2
- package/dist/context/async-context.d.ts +1 -33
- package/dist/context/async-context.js +21 -36
- package/dist/context/environment.d.ts +1 -33
- package/dist/context/environment.js +21 -36
- package/dist/element-DibzzA5L.js.map +1 -1
- package/dist/{element-CGY5MlNe.d.ts → element-wQo0heGj.d.ts} +3 -4
- package/dist/{env-CQJgOkQD.js → env-CmspDhHy.js} +1 -1
- package/dist/{env-CQJgOkQD.js.map → env-CmspDhHy.js.map} +1 -1
- package/dist/error-codes-Ds0bnPvT.js.map +1 -1
- package/dist/events/CommandKitEventsChannel.d.ts +1 -33
- package/dist/events/CommandKitEventsChannel.js +1 -1
- package/dist/{file-DgEXJx3x.js → file-Ca1kpEtE.js} +2 -2
- package/dist/{file-DgEXJx3x.js.map → file-Ca1kpEtE.js.map} +1 -1
- package/dist/{file-CfUTZjJh.d.ts → file-CrV4lSnl.d.ts} +1 -2
- package/dist/flags/FlagProvider.d.ts +1 -33
- package/dist/flags/feature-flags.d.ts +1 -33
- package/dist/flags/feature-flags.js +162 -40
- package/dist/flags/feature-flags.js.map +1 -0
- package/dist/flags/store.d.ts +1 -33
- package/dist/flags/store.js +1 -1
- package/dist/{helpers-t6PiYdMb.d.ts → helpers-AQPLVY35.d.ts} +1 -2
- package/dist/{helpers-0FUA42u8.js → helpers-Btx1FSZx.js} +2 -2
- package/dist/{helpers-0FUA42u8.js.map → helpers-Btx1FSZx.js.map} +1 -1
- package/dist/index.d.ts +40 -43
- package/dist/index.js +32 -40
- 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 -15
- 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-CQD5hBwB.d.ts → label-37kaNWMH.d.ts} +3 -4
- package/dist/{label-CCHbfQW8.js → label-B6vXvwLM.js} +3 -3
- package/dist/{label-CCHbfQW8.js.map → label-B6vXvwLM.js.map} +1 -1
- package/dist/logger/DefaultLogger.d.ts +66 -3
- package/dist/logger/DefaultLogger.js +21 -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 +21 -36
- package/dist/logger/NoopLogger.d.ts +36 -37
- package/dist/{media-gallery-DalbYf1v.d.ts → media-gallery-Ci3I4ElH.d.ts} +1 -2
- package/dist/{media-gallery-DdU7o9Cf.js → media-gallery-u3gjX7yD.js} +2 -2
- package/dist/{media-gallery-DdU7o9Cf.js.map → media-gallery-u3gjX7yD.js.map} +1 -1
- package/dist/plugins/CompilerPlugin.d.ts +1 -33
- package/dist/plugins/CompilerPlugin.js +1 -2
- package/dist/plugins/PluginCommon.d.ts +1 -33
- package/dist/plugins/PluginCommon.js +1 -1
- package/dist/plugins/RuntimePlugin.d.ts +1 -33
- package/dist/plugins/RuntimePlugin.js +1 -2
- package/dist/plugins/index.d.ts +1 -33
- package/dist/plugins/index.js +23 -36
- package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.d.ts +1 -33
- package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.js +21 -36
- package/dist/plugins/plugin-runtime/CompilerPluginRuntime.d.ts +1 -33
- package/dist/plugins/plugin-runtime/CompilerPluginRuntime.js +21 -36
- package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.d.ts +1 -33
- package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.js +21 -36
- package/dist/plugins/plugin-runtime/builtin/MacroPlugin.d.ts +1 -33
- package/dist/plugins/plugin-runtime/builtin/MacroPlugin.js +21 -36
- package/dist/plugins/plugin-runtime/runtime.d.ts +1 -33
- package/dist/plugins/plugin-runtime/runtime.js +0 -1
- package/dist/plugins/types.d.ts +1 -33
- package/dist/plugins/types.js +0 -1
- package/dist/{poll-6lSMoohv.js → poll-CFe8yvoJ.js} +12 -12
- package/dist/{poll-6lSMoohv.js.map → poll-CFe8yvoJ.js.map} +1 -1
- package/dist/{poll-Bo-skHvn.d.ts → poll-Ddtapd6n.d.ts} +7 -8
- package/dist/{resolve-file-url-CJoD0FAn.js → resolve-file-url-CdHqwWs3.js} +2 -2
- package/dist/{resolve-file-url-CJoD0FAn.js.map → resolve-file-url-CdHqwWs3.js.map} +1 -1
- package/dist/{section-C4qfgzOQ.js → section-BC8LF-B2.js} +2 -2
- package/dist/{section-C4qfgzOQ.js.map → section-BC8LF-B2.js.map} +1 -1
- package/dist/{section-CszS2hd5.d.ts → section-DkUKULnB.d.ts} +1 -2
- package/dist/{separator-CsoRs1aX.js → separator-BUTiW7uz.js} +2 -2
- package/dist/{separator-CsoRs1aX.js.map → separator-BUTiW7uz.js.map} +1 -1
- package/dist/{separator-DfRlVHne.d.ts → separator-CbXsIFCa.d.ts} +1 -2
- package/dist/{signals-C2Ly0wDt.js → signals-B8z1wJ6W.js} +2 -2
- package/dist/{signals-C2Ly0wDt.js.map → signals-B8z1wJ6W.js.map} +1 -1
- package/dist/{signals-DeafthGG.d.ts → signals-BbTgTc0i.d.ts} +1 -1
- package/dist/{store-GrsErvli.js → store-D8r_hryO.js} +2 -2
- package/dist/{store-GrsErvli.js.map → store-D8r_hryO.js.map} +1 -1
- package/dist/{text-display-DvydvE0D.d.ts → text-display-D7j39VC-.d.ts} +1 -2
- package/dist/{text-display-C0oSz5y0.js → text-display-DANahMN3.js} +2 -2
- package/dist/{text-display-C0oSz5y0.js.map → text-display-DANahMN3.js.map} +1 -1
- package/dist/{type-checker-CEt5Inbw.js → type-checker-cVd3Hpnh.js} +4 -4
- package/dist/{type-checker-CEt5Inbw.js.map → type-checker-cVd3Hpnh.js.map} +1 -1
- package/dist/{types-CQwntdAo.d.ts → types-BywA9d2Z.d.ts} +1 -1
- package/dist/{types-package-BxIhhZgZ.js → types-package-CsTNfvv2.js} +2 -2
- package/dist/{types-package-BxIhhZgZ.js.map → types-package-CsTNfvv2.js.map} +1 -1
- package/dist/types.d.ts +1 -33
- package/dist/utils/colors.js +1 -1
- package/dist/utils/constants.d.ts +1 -1
- package/dist/utils/dev-hooks.d.ts +1 -33
- package/dist/utils/dev-hooks.js +21 -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 +1 -1
- package/dist/utils/useful-stuff/async-queue.d.ts +21 -21
- 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.map +1 -1
- package/dist/utils/useful-stuff/semaphore.d.ts +82 -82
- package/dist/utils/utilities.d.ts +113 -2
- package/dist/utils/utilities.js +21 -36
- package/dist/utils/warning.d.ts +25 -2
- package/dist/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.map +1 -1
- package/package.json +5 -5
- package/dist/DefaultLogger-CgCFHJ4J.d.ts +0 -67
- package/dist/EventWorkerContext-CNPnDdUZ.d.ts +0 -43
- package/dist/ILogger-B-vsuZ1C.d.ts +0 -64
- package/dist/ILogger-B0q7p7L1.js +0 -0
- package/dist/Logger-BmHeS1Qd.d.ts +0 -37
- package/dist/MessageCommandParser-JmJWga4L.d.ts +0 -195
- package/dist/app-CrjK9yWX.js +0 -0
- package/dist/app-process-DCkz7RlU.js +0 -65
- package/dist/app-process-DCkz7RlU.js.map +0 -1
- package/dist/build-CaoHQPvm.js +0 -169
- package/dist/build-CaoHQPvm.js.map +0 -1
- package/dist/config-2prRz7_7.d.ts +0 -16
- package/dist/constants-Dy6P2veX.js +0 -27
- package/dist/dotprops-Dp98nRuu.js +0 -36
- package/dist/dotprops-Dp98nRuu.js.map +0 -1
- package/dist/error-codes-BuWUNGpX.d.ts +0 -54
- package/dist/feature-flags-BRF8OH7U.js +0 -160
- package/dist/feature-flags-BRF8OH7U.js.map +0 -1
- package/dist/resolve-file-url-B63_4Wm3.d.ts +0 -11
- package/dist/serde-CqUxaQUh.js +0 -97
- package/dist/serde-CqUxaQUh.js.map +0 -1
- package/dist/serde-DR1JEtRZ.d.ts +0 -12
- package/dist/utilities-BV9Osg71.d.ts +0 -113
- package/dist/utils-DGovVwyA.js +0 -23
- package/dist/utils-DGovVwyA.js.map +0 -1
- package/dist/version-BKZNlkbA.d.ts +0 -8
- package/dist/version-DGfGT6Tx.js +0 -18
- package/dist/version-DGfGT6Tx.js.map +0 -1
- package/dist/warning-BucG024D.d.ts +0 -25
- /package/dist/{index-B5F3AfVc.d.ts → index-BJfko-dP.d.ts} +0 -0
- /package/dist/{index-BLwMeReG.d.ts → index-CCggO_hw.d.ts} +0 -0
- /package/dist/{index-h64gcVNJ.d.ts → index-CLjpoGi1.d.ts} +0 -0
package/dist/build-CaoHQPvm.js
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-nOFOJqeH.js');
|
|
2
|
-
const require_commandkit = require('./commandkit-B0wT0Mxx.js');
|
|
3
|
-
const require_constants = require('./constants-CxkFFZ7p.js');
|
|
4
|
-
const require_utils = require('./utils-Br3eenD1.js');
|
|
5
|
-
const require_common = require('./common-B2-sF49Q.js');
|
|
6
|
-
const require_env = require('./env-CQJgOkQD.js');
|
|
7
|
-
const require_type_checker = require('./type-checker-CEt5Inbw.js');
|
|
8
|
-
let node_fs = require("node:fs");
|
|
9
|
-
let node_path = require("node:path");
|
|
10
|
-
let node_fs_promises = require("node:fs/promises");
|
|
11
|
-
let rimraf = require("rimraf");
|
|
12
|
-
|
|
13
|
-
//#region src/cli/build.ts
|
|
14
|
-
/**
|
|
15
|
-
* @private
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
18
|
-
function mergeDefinitionsIfNeeded(env, isDev) {
|
|
19
|
-
const values = Object.fromEntries(Object.entries(process.env).filter(([k]) => !(k in env) && k.startsWith("COMMANDKIT_PUBLIC_")));
|
|
20
|
-
return {
|
|
21
|
-
...env,
|
|
22
|
-
...values,
|
|
23
|
-
...isDev ? {
|
|
24
|
-
NODE_ENV: "development",
|
|
25
|
-
COMMANDKIT_BOOTSTRAP_MODE: "development",
|
|
26
|
-
COMMANDKIT_IS_DEV: "true",
|
|
27
|
-
COMMANDKIT_IS_TEST: "false"
|
|
28
|
-
} : {
|
|
29
|
-
NODE_ENV: "production",
|
|
30
|
-
COMMANDKIT_BOOTSTRAP_MODE: "production",
|
|
31
|
-
COMMANDKIT_IS_DEV: "false",
|
|
32
|
-
COMMANDKIT_IS_TEST: "false"
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* @private
|
|
38
|
-
* @internal
|
|
39
|
-
*/
|
|
40
|
-
async function buildApplication({ plugins, rolldownPlugins, isDev, configPath }) {
|
|
41
|
-
var _config$typescript;
|
|
42
|
-
const { build } = await require_common.loadTsdown();
|
|
43
|
-
const config = await require_commandkit.loadConfigFile(configPath);
|
|
44
|
-
if (!isDev && !(config === null || config === void 0 || (_config$typescript = config.typescript) === null || _config$typescript === void 0 ? void 0 : _config$typescript.ignoreBuildErrors)) await require_type_checker.performTypeCheck(configPath || require_constants.COMMANDKIT_CWD);
|
|
45
|
-
const pluginRuntime = new require_commandkit.CompilerPluginRuntime(plugins || [], !!isDev);
|
|
46
|
-
rolldownPlugins ??= [];
|
|
47
|
-
rolldownPlugins.push(pluginRuntime.toJSON());
|
|
48
|
-
try {
|
|
49
|
-
var _config$sourceMap, _config$compilerOptio, _config$compilerOptio2, _config$antiCrashScri;
|
|
50
|
-
const dest = isDev ? ".commandkit" : config.distDir;
|
|
51
|
-
await (0, rimraf.rimraf)(dest);
|
|
52
|
-
await pluginRuntime.init();
|
|
53
|
-
await build(require_utils.mergeDeep({
|
|
54
|
-
watch: false,
|
|
55
|
-
dts: false,
|
|
56
|
-
clean: true,
|
|
57
|
-
format: ["esm"],
|
|
58
|
-
shims: true,
|
|
59
|
-
minify: false,
|
|
60
|
-
silent: !!isDev,
|
|
61
|
-
inputOptions: {
|
|
62
|
-
transform: { jsx: {
|
|
63
|
-
runtime: "automatic",
|
|
64
|
-
importSource: "commandkit"
|
|
65
|
-
} },
|
|
66
|
-
checks: { circularDependency: true },
|
|
67
|
-
onwarn: (warning, defaultWarn) => {
|
|
68
|
-
var _warning$message;
|
|
69
|
-
if (warning === null || warning === void 0 || (_warning$message = warning.message) === null || _warning$message === void 0 ? void 0 : _warning$message.includes("compilerOptions.jsx")) return;
|
|
70
|
-
return defaultWarn(warning);
|
|
71
|
-
},
|
|
72
|
-
onLog: (level, log, defaultLog) => {
|
|
73
|
-
if (isDev) return;
|
|
74
|
-
return defaultLog(level, log);
|
|
75
|
-
},
|
|
76
|
-
moduleTypes: {
|
|
77
|
-
".json": "json",
|
|
78
|
-
".node": "binary"
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
plugins: rolldownPlugins,
|
|
82
|
-
platform: "node",
|
|
83
|
-
skipNodeModulesBundle: true,
|
|
84
|
-
sourcemap: ((_config$sourceMap = config.sourceMap) === null || _config$sourceMap === void 0 ? void 0 : _config$sourceMap[isDev ? "development" : "production"]) ?? true,
|
|
85
|
-
target: "node16",
|
|
86
|
-
outDir: dest,
|
|
87
|
-
env: mergeDefinitionsIfNeeded(config.env || {}, !!isDev),
|
|
88
|
-
entry: Array.from(new Set([
|
|
89
|
-
"src/**/*.{js,cjs,mjs,ts,cts,mts,jsx,tsx}",
|
|
90
|
-
`!${config.distDir}`,
|
|
91
|
-
"!.commandkit",
|
|
92
|
-
"!**/*.test.*",
|
|
93
|
-
"!**/*.spec.*",
|
|
94
|
-
...config.entrypoints ?? []
|
|
95
|
-
])),
|
|
96
|
-
outputOptions: { sanitizeFileName: (name) => name },
|
|
97
|
-
unbundle: isDev ? true : ((_config$compilerOptio = config.compilerOptions) === null || _config$compilerOptio === void 0 ? void 0 : _config$compilerOptio.disableChunking) ?? false
|
|
98
|
-
}, (_config$compilerOptio2 = config.compilerOptions) === null || _config$compilerOptio2 === void 0 ? void 0 : _config$compilerOptio2.tsdown));
|
|
99
|
-
await require_common.copyLocaleFiles("src", dest);
|
|
100
|
-
await injectEntryFile(configPath || require_constants.COMMANDKIT_CWD, !!isDev, !!(((_config$antiCrashScri = config.antiCrashScript) === null || _config$antiCrashScri === void 0 ? void 0 : _config$antiCrashScri[isDev ? "development" : "production"]) ?? (isDev ? true : false)), config.distDir);
|
|
101
|
-
} catch (error) {
|
|
102
|
-
console.error("Build failed:", error);
|
|
103
|
-
if (error instanceof Error) console.error("Error details:", error.stack);
|
|
104
|
-
process.exit(1);
|
|
105
|
-
} finally {
|
|
106
|
-
await pluginRuntime.destroy();
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
const envScript = (dev) => `// --- Environment Variables Loader ---
|
|
110
|
-
const $env = [${(dev ? require_env.devEnvFileArgs : require_env.prodEnvFileArgs).map((p) => `"${p}"`).join(", ")}];
|
|
111
|
-
for (const file of $env) {
|
|
112
|
-
try {
|
|
113
|
-
process.loadEnvFile(file);
|
|
114
|
-
console.log('\\x1b[36m✔ Loaded \\x1b[0m\\x1b[33m%s\\x1b[0m', file);
|
|
115
|
-
} catch {}
|
|
116
|
-
}
|
|
117
|
-
`;
|
|
118
|
-
const antiCrashScript = [
|
|
119
|
-
"// --- CommandKit Anti-Crash Monitor ---",
|
|
120
|
-
" // 'uncaughtException' event is supposed to be used to perform synchronous cleanup before shutting down the process",
|
|
121
|
-
" // instead of using it as a means to resume operation.",
|
|
122
|
-
" // But it exists here due to compatibility reasons with discord bot ecosystem.",
|
|
123
|
-
" const p = (t) => `\\x1b[31m${t}\\x1b[0m`, b = '[CommandKit Anti-Crash Monitor]', l = console.log, e1 = 'uncaughtException', e2 = 'unhandledRejection';",
|
|
124
|
-
" if (!process.eventNames().includes(e1)) // skip if it is already handled",
|
|
125
|
-
" process.on(e1, (e) => {",
|
|
126
|
-
" l(p(`${b} Uncaught Exception`)); l(p(b), p(e.stack || e));",
|
|
127
|
-
" })",
|
|
128
|
-
" if (!process.eventNames().includes(e2)) // skip if it is already handled",
|
|
129
|
-
" process.on(e2, (r) => {",
|
|
130
|
-
" l(p(`${b} Unhandled promise rejection`)); l(p(`${b} ${r.stack || r}`));",
|
|
131
|
-
" });",
|
|
132
|
-
"// --- CommandKit Anti-Crash Monitor ---"
|
|
133
|
-
].join("\n");
|
|
134
|
-
const wrapInAsyncIIFE = (code) => `;await (async () => {\n${code.join("\n\n")}\n})();`;
|
|
135
|
-
async function injectEntryFile(configPath, isDev, emitAntiCrashScript, distDir) {
|
|
136
|
-
const entryFilePath = (0, node_path.join)(configPath, isDev ? ".commandkit" : distDir || "dist", "index.js");
|
|
137
|
-
if ((0, node_fs.existsSync)(entryFilePath)) return;
|
|
138
|
-
await (0, node_fs_promises.writeFile)(entryFilePath, `/* Entrypoint File Generated By CommandKit */
|
|
139
|
-
${isDev ? `\n\n// Injected for development\n${wrapInAsyncIIFE([envScript(isDev), emitAntiCrashScript ? antiCrashScript : ""])}\n\n` : wrapInAsyncIIFE([envScript(isDev)])}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
async function bootstrap() {
|
|
143
|
-
const { Client } = await import('discord.js');
|
|
144
|
-
const { commandkit } = await import('commandkit');
|
|
145
|
-
const app = await import('./app.js').then((m) => m.default ?? m);
|
|
146
|
-
|
|
147
|
-
if (!app || !(app instanceof Client)) {
|
|
148
|
-
throw new Error('The app file must default export the discord.js client instance');
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
commandkit.setClient(app);
|
|
152
|
-
|
|
153
|
-
await commandkit.start();
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
await bootstrap().catch((e) => {
|
|
157
|
-
console.error('Failed to bootstrap CommandKit application:\\n', e.stack);
|
|
158
|
-
})
|
|
159
|
-
`);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
//#endregion
|
|
163
|
-
Object.defineProperty(exports, 'buildApplication', {
|
|
164
|
-
enumerable: true,
|
|
165
|
-
get: function () {
|
|
166
|
-
return buildApplication;
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
//# sourceMappingURL=build-CaoHQPvm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-CaoHQPvm.js","names":[],"sources":["../src/cli/build.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { rimraf } from 'rimraf';\nimport type { Options } from 'tsdown';\n\nimport { MaybeArray } from '../components';\nimport { loadConfigFile } from '../config/loader';\nimport { mergeDeep } from '../config/utils';\nimport { CompilerPlugin, CompilerPluginRuntime } from '../plugins';\nimport { COMMANDKIT_CWD } from '../utils/constants';\nimport { copyLocaleFiles, loadTsdown } from './common';\nimport { devEnvFileArgs, prodEnvFileArgs } from './env';\nimport { performTypeCheck } from './type-checker';\n\n/**\n * @private\n * @internal\n */\nexport interface ApplicationBuildOptions {\n plugins?: MaybeArray<CompilerPlugin>[] | Array<CompilerPlugin>;\n rolldownPlugins?: any[];\n isDev?: boolean;\n configPath?: string;\n}\n\n// emit public env variables and given env variables\n/**\n * @private\n * @internal\n */\nfunction mergeDefinitionsIfNeeded(env: Record<string, string>, isDev: boolean) {\n const values = Object.fromEntries(\n Object.entries(process.env).filter(\n ([k]) => !(k in env) && k.startsWith('COMMANDKIT_PUBLIC_'),\n ),\n );\n\n return {\n ...env,\n ...values,\n ...(isDev\n ? {\n NODE_ENV: 'development',\n COMMANDKIT_BOOTSTRAP_MODE: 'development',\n COMMANDKIT_IS_DEV: 'true',\n COMMANDKIT_IS_TEST: 'false',\n }\n : {\n NODE_ENV: 'production',\n COMMANDKIT_BOOTSTRAP_MODE: 'production',\n COMMANDKIT_IS_DEV: 'false',\n COMMANDKIT_IS_TEST: 'false',\n }),\n };\n}\n\n/**\n * @private\n * @internal\n */\nexport async function buildApplication({\n plugins,\n rolldownPlugins,\n isDev,\n configPath,\n}: ApplicationBuildOptions) {\n const { build } = await loadTsdown();\n const config = await loadConfigFile(configPath);\n\n if (!isDev && !config?.typescript?.ignoreBuildErrors) {\n await performTypeCheck(configPath || COMMANDKIT_CWD);\n }\n\n const pluginRuntime = new CompilerPluginRuntime(\n (plugins || []) as CompilerPlugin[],\n !!isDev,\n );\n\n rolldownPlugins ??= [];\n\n rolldownPlugins.push(pluginRuntime.toJSON());\n\n try {\n const dest = isDev ? '.commandkit' : config.distDir;\n\n // Clean the destination directory\n await rimraf(dest);\n\n await pluginRuntime.init();\n\n await build(\n mergeDeep(\n {\n watch: false,\n dts: false,\n clean: true,\n format: ['esm'],\n shims: true,\n minify: false,\n silent: !!isDev,\n inputOptions: {\n transform: {\n jsx: {\n runtime: 'automatic',\n importSource: 'commandkit',\n },\n },\n checks: {\n circularDependency: true,\n },\n onwarn: (warning, defaultWarn) => {\n if (warning?.message?.includes('compilerOptions.jsx')) return;\n\n return defaultWarn(warning);\n },\n onLog: (level, log, defaultLog) => {\n if (isDev) return;\n\n return defaultLog(level, log);\n },\n moduleTypes: {\n '.json': 'json',\n '.node': 'binary',\n },\n },\n plugins: rolldownPlugins,\n platform: 'node',\n skipNodeModulesBundle: true,\n sourcemap:\n config.sourceMap?.[isDev ? 'development' : 'production'] ?? true,\n target: 'node16',\n outDir: dest,\n env: mergeDefinitionsIfNeeded(config.env || {}, !!isDev),\n entry: Array.from(\n new Set([\n 'src/**/*.{js,cjs,mjs,ts,cts,mts,jsx,tsx}',\n `!${config.distDir}`,\n '!.commandkit',\n '!**/*.test.*',\n '!**/*.spec.*',\n ...(config.entrypoints ?? []),\n ]),\n ),\n outputOptions: {\n sanitizeFileName: (name) => name,\n },\n unbundle: isDev\n ? true\n : (config.compilerOptions?.disableChunking ?? false),\n } satisfies Options,\n config.compilerOptions?.tsdown,\n ),\n );\n\n await copyLocaleFiles('src', dest);\n await injectEntryFile(\n configPath || COMMANDKIT_CWD,\n !!isDev,\n !!(\n config.antiCrashScript?.[isDev ? 'development' : 'production'] ??\n (isDev ? true : false)\n ),\n config.distDir,\n );\n } catch (error) {\n console.error('Build failed:', error);\n if (error instanceof Error) {\n console.error('Error details:', error.stack);\n }\n process.exit(1); // Force exit on error\n } finally {\n // Ensure plugins are cleaned up\n await pluginRuntime.destroy();\n }\n}\n\nconst envScript = (dev: boolean) => `// --- Environment Variables Loader ---\nconst $env = [${(dev ? devEnvFileArgs : prodEnvFileArgs).map((p) => `\"${p}\"`).join(', ')}];\nfor (const file of $env) {\n try {\n process.loadEnvFile(file);\n console.log('\\\\x1b[36m✔ Loaded \\\\x1b[0m\\\\x1b[33m%s\\\\x1b[0m', file);\n } catch {}\n}\n`;\n\nconst antiCrashScript = [\n '// --- CommandKit Anti-Crash Monitor ---',\n \" // 'uncaughtException' event is supposed to be used to perform synchronous cleanup before shutting down the process\",\n ' // instead of using it as a means to resume operation.',\n ' // But it exists here due to compatibility reasons with discord bot ecosystem.',\n \" const p = (t) => `\\\\x1b[31m${t}\\\\x1b[0m`, b = '[CommandKit Anti-Crash Monitor]', l = console.log, e1 = 'uncaughtException', e2 = 'unhandledRejection';\",\n ' if (!process.eventNames().includes(e1)) // skip if it is already handled',\n ' process.on(e1, (e) => {',\n ' l(p(`${b} Uncaught Exception`)); l(p(b), p(e.stack || e));',\n ' })',\n ' if (!process.eventNames().includes(e2)) // skip if it is already handled',\n ' process.on(e2, (r) => {',\n ' l(p(`${b} Unhandled promise rejection`)); l(p(`${b} ${r.stack || r}`));',\n ' });',\n '// --- CommandKit Anti-Crash Monitor ---',\n].join('\\n');\n\nconst wrapInAsyncIIFE = (code: string[]) =>\n `;await (async () => {\\n${code.join('\\n\\n')}\\n})();`;\n\nasync function injectEntryFile(\n configPath: string,\n isDev: boolean,\n emitAntiCrashScript: boolean,\n distDir?: string,\n) {\n const dist = isDev ? '.commandkit' : distDir || 'dist';\n const entryFilePath = join(configPath, dist, 'index.js');\n\n // skip if the entry file already exists\n if (existsSync(entryFilePath)) return;\n\n const code = `/* Entrypoint File Generated By CommandKit */\n${isDev ? `\\n\\n// Injected for development\\n${wrapInAsyncIIFE([envScript(isDev), emitAntiCrashScript ? antiCrashScript : ''])}\\n\\n` : wrapInAsyncIIFE([envScript(isDev)])}\n\n\nasync function bootstrap() {\n const { Client } = await import('discord.js');\n const { commandkit } = await import('commandkit');\n const app = await import('./app.js').then((m) => m.default ?? m);\n\n if (!app || !(app instanceof Client)) {\n throw new Error('The app file must default export the discord.js client instance');\n }\n\n commandkit.setClient(app);\n\n await commandkit.start();\n}\n\nawait bootstrap().catch((e) => {\n console.error('Failed to bootstrap CommandKit application:\\\\n', e.stack);\n})\n`;\n\n await writeFile(entryFilePath, code);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA+BA,SAAS,yBAAyB,KAA6B,OAAgB;CAC7E,MAAM,SAAS,OAAO,YACpB,OAAO,QAAQ,QAAQ,IAAI,CAAC,QACzB,CA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;;;EAsBnI"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { _ as CommandKitConfig, m as ResolvedCommandKitConfig } from "./analytics-engine-DHmLGxFA.js";
|
|
2
|
-
|
|
3
|
-
//#region src/config/config.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Get the defined configuration for CommandKit.
|
|
7
|
-
*/
|
|
8
|
-
declare function getConfig(): ResolvedCommandKitConfig;
|
|
9
|
-
/**
|
|
10
|
-
* Define the configuration for CommandKit.
|
|
11
|
-
* @param config The configuration to use.
|
|
12
|
-
*/
|
|
13
|
-
declare function defineConfig(config?: Partial<CommandKitConfig>): ResolvedCommandKitConfig;
|
|
14
|
-
//#endregion
|
|
15
|
-
export { getConfig as n, defineConfig as t };
|
|
16
|
-
//# sourceMappingURL=config-2prRz7_7.d.ts.map
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/kv/constants.ts
|
|
3
|
-
let SerializerType = /* @__PURE__ */ function(SerializerType$1) {
|
|
4
|
-
SerializerType$1[SerializerType$1["String"] = 0] = "String";
|
|
5
|
-
SerializerType$1[SerializerType$1["Number"] = 1] = "Number";
|
|
6
|
-
SerializerType$1[SerializerType$1["Boolean"] = 2] = "Boolean";
|
|
7
|
-
SerializerType$1[SerializerType$1["Object"] = 3] = "Object";
|
|
8
|
-
SerializerType$1[SerializerType$1["Date"] = 4] = "Date";
|
|
9
|
-
SerializerType$1[SerializerType$1["BigInt"] = 5] = "BigInt";
|
|
10
|
-
SerializerType$1[SerializerType$1["Null"] = 6] = "Null";
|
|
11
|
-
SerializerType$1[SerializerType$1["Undefined"] = 7] = "Undefined";
|
|
12
|
-
SerializerType$1[SerializerType$1["Array"] = 8] = "Array";
|
|
13
|
-
SerializerType$1[SerializerType$1["Map"] = 9] = "Map";
|
|
14
|
-
SerializerType$1[SerializerType$1["Set"] = 10] = "Set";
|
|
15
|
-
SerializerType$1[SerializerType$1["Buffer"] = 11] = "Buffer";
|
|
16
|
-
SerializerType$1[SerializerType$1["RegExp"] = 12] = "RegExp";
|
|
17
|
-
return SerializerType$1;
|
|
18
|
-
}({});
|
|
19
|
-
|
|
20
|
-
//#endregion
|
|
21
|
-
Object.defineProperty(exports, 'SerializerType', {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return SerializerType;
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
//# sourceMappingURL=constants-Dy6P2veX.js.map
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/kv/dotprops.ts
|
|
3
|
-
function getNestedValue(obj, path) {
|
|
4
|
-
const keys = path.split(".");
|
|
5
|
-
let current = obj;
|
|
6
|
-
for (const key of keys) {
|
|
7
|
-
if (current === null || current === void 0) return;
|
|
8
|
-
current = current[key];
|
|
9
|
-
}
|
|
10
|
-
return current;
|
|
11
|
-
}
|
|
12
|
-
function setNestedValue(obj, path, value) {
|
|
13
|
-
const keys = path.split(".");
|
|
14
|
-
const lastKey = keys.pop();
|
|
15
|
-
let current = obj;
|
|
16
|
-
for (const key of keys) {
|
|
17
|
-
if (current[key] === null || current[key] === void 0) current[key] = {};
|
|
18
|
-
current = current[key];
|
|
19
|
-
}
|
|
20
|
-
current[lastKey] = value;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
Object.defineProperty(exports, 'getNestedValue', {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return getNestedValue;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, 'setNestedValue', {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return setNestedValue;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
//# sourceMappingURL=dotprops-Dp98nRuu.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dotprops-Dp98nRuu.js","names":[],"sources":["../src/kv/dotprops.ts"],"sourcesContent":["export function getNestedValue(obj: any, path: string): any {\n const keys = path.split('.');\n let current = obj;\n\n for (const key of keys) {\n if (current === null || current === undefined) {\n return undefined;\n }\n current = current[key];\n }\n\n return current;\n}\n\nexport function setNestedValue(obj: any, path: string, value: any): void {\n const keys = path.split('.');\n const lastKey = keys.pop()!;\n let current = obj;\n\n for (const key of keys) {\n if (current[key] === null || current[key] === undefined) {\n current[key] = {};\n }\n current = current[key];\n }\n\n current[lastKey] = value;\n}\n"],"mappings":";;AAAA,SAAgB,eAAe,KAAU,MAAmB;CAC1D,MAAM,OAAO,KAAK,MAAM,IAAI;CAC5B,IAAI,UAAU;AAEd,MAAK,MAAM,OAAO,MAAM;AACtB,MAAI,YAAY,QAAQ,YAAY,OAClC;AAEF,YAAU,QAAQ;;AAGpB,QAAO;;AAGT,SAAgB,eAAe,KAAU,MAAc,OAAkB;CACvE,MAAM,OAAO,KAAK,MAAM,IAAI;CAC5B,MAAM,UAAU,KAAK,KAAK;CAC1B,IAAI,UAAU;AAEd,MAAK,MAAM,OAAO,MAAM;AACtB,MAAI,QAAQ,SAAS,QAAQ,QAAQ,SAAS,OAC5C,SAAQ,OAAO,EAAE;AAEnB,YAAU,QAAQ;;AAGpB,SAAQ,WAAW"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
//#region src/utils/error-codes.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* The error codes used by CommandKit.
|
|
4
|
-
*/
|
|
5
|
-
declare const CommandKitErrorCodes: {
|
|
6
|
-
/**
|
|
7
|
-
* Error code for exiting middleware.
|
|
8
|
-
*/
|
|
9
|
-
readonly StopMiddlewares: symbol;
|
|
10
|
-
/**
|
|
11
|
-
* Error code for forwarded commands.
|
|
12
|
-
*/
|
|
13
|
-
readonly ForwardedCommand: symbol;
|
|
14
|
-
/**
|
|
15
|
-
* Error code for invalid command prefix.
|
|
16
|
-
*/
|
|
17
|
-
readonly InvalidCommandPrefix: symbol;
|
|
18
|
-
/**
|
|
19
|
-
* Error code for plugin capture handle.
|
|
20
|
-
*/
|
|
21
|
-
readonly PluginCaptureHandle: symbol;
|
|
22
|
-
/**
|
|
23
|
-
* Error code for event interruption signal
|
|
24
|
-
*/
|
|
25
|
-
readonly StopEvents: symbol;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* The type for CommandKit errors.
|
|
29
|
-
*/
|
|
30
|
-
type CommandKitError = Error & {
|
|
31
|
-
code: symbol;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Creates a new CommandKit error with the specified code.
|
|
35
|
-
* @param code The error code to assign to the error.
|
|
36
|
-
* @returns A new CommandKit error instance.
|
|
37
|
-
*/
|
|
38
|
-
declare function createCommandKitError(code: symbol): CommandKitError;
|
|
39
|
-
/**
|
|
40
|
-
* Checks if the given error is a CommandKit error.
|
|
41
|
-
* @param error The error to check.
|
|
42
|
-
* @returns True if the error is a CommandKit error, false otherwise.
|
|
43
|
-
*/
|
|
44
|
-
declare function isCommandKitError(error: unknown): error is CommandKitError;
|
|
45
|
-
/**
|
|
46
|
-
* Checks if the given error is of a specific CommandKit error type.
|
|
47
|
-
* @param error The error to check.
|
|
48
|
-
* @param code The error code or an array of error codes to check against.
|
|
49
|
-
* @returns True if the error matches the specified code(s), false otherwise.
|
|
50
|
-
*/
|
|
51
|
-
declare function isErrorType(error: unknown, code: symbol | symbol[]): boolean;
|
|
52
|
-
//#endregion
|
|
53
|
-
export { isErrorType as a, isCommandKitError as i, CommandKitErrorCodes as n, createCommandKitError as r, CommandKitError as t };
|
|
54
|
-
//# sourceMappingURL=error-codes-BuWUNGpX.d.ts.map
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
const require_commandkit = require('./commandkit-B0wT0Mxx.js');
|
|
2
|
-
const require_constants = require('./constants-BqrEmoih.js');
|
|
3
|
-
const require_EventWorkerContext = require('./EventWorkerContext-yTm5vI3b.js');
|
|
4
|
-
|
|
5
|
-
//#region src/flags/feature-flags.ts
|
|
6
|
-
let flagProvider = null;
|
|
7
|
-
/**
|
|
8
|
-
* Set the global flag provider for all feature flags
|
|
9
|
-
*/
|
|
10
|
-
function setFlagProvider(provider) {
|
|
11
|
-
flagProvider = provider;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Class representing a feature flag in CommandKit.
|
|
15
|
-
*/
|
|
16
|
-
var FeatureFlag = class {
|
|
17
|
-
commandkit;
|
|
18
|
-
/**
|
|
19
|
-
* Create a new feature flag.
|
|
20
|
-
* @param options - The options for the feature flag.
|
|
21
|
-
*/
|
|
22
|
-
constructor(options) {
|
|
23
|
-
this.options = options;
|
|
24
|
-
this.commandkit = require_commandkit.getCommandKit(true);
|
|
25
|
-
const FlagStore = this.commandkit.flags;
|
|
26
|
-
if (FlagStore.has(options.key)) throw new Error(`Feature flag with key "${options.key}" already exists.`);
|
|
27
|
-
FlagStore.set(options.key, this);
|
|
28
|
-
}
|
|
29
|
-
getContext() {
|
|
30
|
-
const env = require_commandkit.getContext();
|
|
31
|
-
if (env === null || env === void 0 ? void 0 : env.context) {
|
|
32
|
-
const { client, commandkit, interaction, message, guild, channel, command } = env.context;
|
|
33
|
-
return {
|
|
34
|
-
client,
|
|
35
|
-
commandkit,
|
|
36
|
-
command: {
|
|
37
|
-
interaction,
|
|
38
|
-
message,
|
|
39
|
-
guild,
|
|
40
|
-
channel,
|
|
41
|
-
command
|
|
42
|
-
},
|
|
43
|
-
event: null
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
const eventCtx = require_EventWorkerContext.eventWorkerContext.getStore();
|
|
47
|
-
if (eventCtx) {
|
|
48
|
-
const { commandkit, data, event, namespace } = eventCtx;
|
|
49
|
-
return {
|
|
50
|
-
client: commandkit.client,
|
|
51
|
-
commandkit,
|
|
52
|
-
event: {
|
|
53
|
-
data,
|
|
54
|
-
event,
|
|
55
|
-
namespace,
|
|
56
|
-
arguments: eventCtx.arguments,
|
|
57
|
-
argumentsAs: (eventName) => {
|
|
58
|
-
return eventCtx.arguments;
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
command: null
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
throw new Error("Could not determine the execution context. Feature flags may only be used inside a command or event.");
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Execute the feature flag evaluation.
|
|
68
|
-
* @param res - Optional entities to use for evaluation. If not provided, it will call the identify function.
|
|
69
|
-
* @returns A promise that resolves to the result of the feature flag evaluation.
|
|
70
|
-
*/
|
|
71
|
-
async execute(res) {
|
|
72
|
-
const { decide, identify, disableAnalytics } = this.options;
|
|
73
|
-
const identificationStart = performance.now();
|
|
74
|
-
const entities = res ?? await (async () => {
|
|
75
|
-
const ctx = this.getContext();
|
|
76
|
-
return await (identify === null || identify === void 0 ? void 0 : identify(ctx)) ?? {};
|
|
77
|
-
})();
|
|
78
|
-
const identificationTime = performance.now() - identificationStart;
|
|
79
|
-
let providerConfig = null;
|
|
80
|
-
if (flagProvider) try {
|
|
81
|
-
providerConfig = await flagProvider.getFlag(this.options.key, entities);
|
|
82
|
-
if (providerConfig && !providerConfig.enabled) {
|
|
83
|
-
if (typeof decide === "function") return await decide({
|
|
84
|
-
entities,
|
|
85
|
-
provider: providerConfig
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
} catch (error) {
|
|
89
|
-
require_commandkit.Logger.error`Error fetching flag provider configuration for "${this.options.key}": ${error}`;
|
|
90
|
-
}
|
|
91
|
-
const decisionStart = performance.now();
|
|
92
|
-
const decisionResult = await decide({
|
|
93
|
-
entities,
|
|
94
|
-
provider: providerConfig
|
|
95
|
-
});
|
|
96
|
-
const decisionTime = performance.now() - decisionStart;
|
|
97
|
-
if (!disableAnalytics) {
|
|
98
|
-
require_commandkit.defer(async () => {
|
|
99
|
-
await this.commandkit.analytics.track({
|
|
100
|
-
name: require_constants.AnalyticsEvents.FEATURE_FLAG_METRICS,
|
|
101
|
-
data: {
|
|
102
|
-
flag: this.options.key,
|
|
103
|
-
identificationTime: identificationTime.toFixed(2),
|
|
104
|
-
decisionTime: decisionTime.toFixed(2),
|
|
105
|
-
usedProvider: flagProvider !== null,
|
|
106
|
-
providerEnabled: (providerConfig === null || providerConfig === void 0 ? void 0 : providerConfig.enabled) ?? null
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
require_commandkit.defer(async () => {
|
|
111
|
-
await this.commandkit.analytics.track({
|
|
112
|
-
name: require_constants.AnalyticsEvents.FEATURE_FLAG_DECISION,
|
|
113
|
-
id: entities && typeof entities === "object" && "id" in entities && typeof entities.id === "string" ? entities.id : void 0,
|
|
114
|
-
data: {
|
|
115
|
-
flag: this.options.key,
|
|
116
|
-
decision: require_commandkit.JsonSerialize(decisionResult, "unknown"),
|
|
117
|
-
providerUsed: flagProvider !== null
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
return decisionResult;
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
/**
|
|
126
|
-
* Create a new feature flag.
|
|
127
|
-
* @param options - The options for the feature flag.
|
|
128
|
-
* @returns A new instance of the FeatureFlag class.
|
|
129
|
-
*/
|
|
130
|
-
function flag(options) {
|
|
131
|
-
const flag$1 = new FeatureFlag(options);
|
|
132
|
-
const runner = flag$1.execute.bind(flag$1, void 0);
|
|
133
|
-
runner.run = async function(ctx) {
|
|
134
|
-
if (!(ctx === null || ctx === void 0 ? void 0 : ctx.identify)) throw new Error("Custom evaluation context must have an identify function or object.");
|
|
135
|
-
const context = typeof ctx === "function" ? await ctx() : ctx;
|
|
136
|
-
return await flag$1.execute(context);
|
|
137
|
-
};
|
|
138
|
-
return runner;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
//#endregion
|
|
142
|
-
Object.defineProperty(exports, 'FeatureFlag', {
|
|
143
|
-
enumerable: true,
|
|
144
|
-
get: function () {
|
|
145
|
-
return FeatureFlag;
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
Object.defineProperty(exports, 'flag', {
|
|
149
|
-
enumerable: true,
|
|
150
|
-
get: function () {
|
|
151
|
-
return flag;
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
Object.defineProperty(exports, 'setFlagProvider', {
|
|
155
|
-
enumerable: true,
|
|
156
|
-
get: function () {
|
|
157
|
-
return setFlagProvider;
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
//# sourceMappingURL=feature-flags-BRF8OH7U.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"feature-flags-BRF8OH7U.js","names":[],"sources":["../src/flags/feature-flags.ts"],"sourcesContent":["import { getCommandKit, getContext } from '../context/async-context';\nimport { eventWorkerContext } from '../app/events/EventWorkerContext';\nimport { ParsedEvent } from '../app/router';\nimport type { CommandKit } from '../commandkit';\nimport {\n AutocompleteInteraction,\n ChatInputCommandInteraction,\n Client,\n ClientEvents,\n ContextMenuCommandInteraction,\n Guild,\n Message,\n TextBasedChannel,\n} from 'discord.js';\nimport { LoadedCommand } from '../app';\nimport { defer, JsonSerialize } from '../utils/utilities';\nimport { AnalyticsEvents } from '../analytics/constants';\nimport { FlagProvider, FlagConfiguration } from './FlagProvider';\nimport { Logger } from '../logger/Logger';\n\n// Global flag provider\nlet flagProvider: FlagProvider | null = null;\n\n/**\n * Set the global flag provider for all feature flags\n */\nexport function setFlagProvider(provider: FlagProvider): void {\n flagProvider = provider;\n}\n\n/**\n * @private\n */\nexport type MaybePromise<T> = T | Promise<T>;\n\n/**\n * Function type for identifying entities in the context of feature flags.\n * This function should return an object representing the entity that will be used\n * to evaluate the feature flag.\n * It can be synchronous or asynchronous.\n */\nexport type IdentifyFunction<R> = (\n context: EvaluationContext,\n) => MaybePromise<R>;\n\n/**\n * Function type for deciding the outcome of a feature flag based on the provided entities.\n * This function receives an object containing the entities and optionally the provider configuration,\n * and should return the result of the decision.\n * It can be synchronous or asynchronous.\n */\nexport type DecideFunction<E, R> = (data: {\n entities: E;\n provider?: FlagConfiguration | null;\n}) => MaybePromise<R>;\n\n/**\n * Definition for a feature flag, including its key, description, identify function,\n * and decide function.\n * The identify function is used to determine the entities that will be evaluated\n * against the feature flag, while the decide function contains the logic for\n * determining the outcome of the flag based on those entities.\n */\nexport interface FeatureFlagDefinition<R, Entity> {\n /**\n * Unique key for the feature flag.\n * Should be a string that identifies the flag.\n */\n key: string;\n /**\n * Optional description of the feature flag.\n * This can be used for documentation or debugging purposes.\n */\n description?: string;\n /**\n * Optional flag to enable integration with an external flag provider.\n * If true, the flag will use the global flag provider to determine its state.\n * Default: false\n */\n identify?: IdentifyFunction<Entity>;\n /**\n * Function to decide the outcome of the feature flag.\n * This function receives the identified entities and should return the result of the decision.\n */\n decide: DecideFunction<Entity, R>;\n /**\n * Whether to disable analytics tracking for this flag.\n * Default: false\n */\n disableAnalytics?: boolean;\n}\n\n/**\n * Context for evaluating command flags in CommandKit.\n */\nexport interface CommandFlagContext {\n /**\n * The Discord client instance.\n * This is the main entry point for interacting with the Discord API.\n */\n client: Client<true>;\n /**\n * The CommandKit instance, which provides access to the command framework.\n * This includes commands, events, and other features of CommandKit.\n */\n commandkit: CommandKit;\n /**\n * The command context, which includes information about the command being executed.\n * This can include the interaction, message, guild, channel, and the loaded command.\n */\n command: {\n /**\n * The interaction object if the command was invoked via an interaction.\n * This can be a ChatInputCommandInteraction, AutocompleteInteraction, or ContextMenuCommandInteraction.\n */\n interaction?:\n | ChatInputCommandInteraction\n | AutocompleteInteraction\n | ContextMenuCommandInteraction;\n /**\n * The message object if the command was invoked via a message.\n */\n message?: Message;\n /**\n * The guild where the command was invoked, if applicable.\n * This will be null for commands invoked in DMs.\n */\n guild: Guild | null;\n /**\n * The channel where the command was invoked.\n * This can be a text channel, DM channel, or any other type of text-based channel.\n */\n channel: TextBasedChannel | null;\n /**\n * The loaded command instance that is being executed.\n * This contains the command's metadata and logic.\n */\n command: LoadedCommand;\n };\n /**\n * The event context is null for command flags, as they are not tied to a specific event.\n * This is used to differentiate between command and event flags.\n */\n event: null;\n}\n\n/**\n * Context for evaluating event flags in CommandKit.\n */\nexport interface EventFlagContext {\n /**\n * The Discord client instance.\n * This is the main entry point for interacting with the Discord API.\n */\n client: Client<true>;\n /**\n * The CommandKit instance, which provides access to the command framework.\n * This includes commands, events, and other features of CommandKit.\n */\n commandkit: CommandKit;\n /**\n * The event context, which includes information about the event being processed.\n * This can include the parsed event data, the event name, and the namespace if applicable.\n */\n event: {\n /**\n * The parsed event data, which contains the raw data from the event.\n * This can include information like user IDs, channel IDs, and other relevant data.\n */\n data: ParsedEvent;\n /**\n * The name of the event being processed.\n * This is the string identifier for the event, such as 'messageCreate' or 'guildMemberAdd'.\n */\n event: string;\n /**\n * The namespace of the event, if applicable.\n * This can be used to group related events or commands together.\n * It is null if the event does not belong to a specific namespace.\n */\n namespace: string | null;\n /**\n * The arguments passed to the event handler.\n * This is an array of arguments that were passed when the event was triggered.\n * It can be used to access specific data related to the event.\n */\n arguments: any[];\n /**\n * A function to retrieve the arguments for a specific event type.\n * This allows for type-safe access to the arguments based on the event name.\n * @param event - The name of the event to retrieve arguments for.\n */\n argumentsAs<E extends keyof ClientEvents>(event: E): ClientEvents[E];\n };\n /**\n * The command context is null for event flags, as they are not tied to a specific command.\n * This is used to differentiate between command and event flags.\n */\n command: null;\n}\n\n/**\n * Combined context type for feature flag evaluation.\n */\nexport type EvaluationContext = CommandFlagContext | EventFlagContext;\n\n/**\n * Function type for custom evaluation of feature flags.\n * This function can be used to provide a custom evaluation context for the flag.\n * It should return an object representing the entities to be evaluated.\n */\nexport type CustomEvaluationFunction<E> = () => MaybePromise<E>;\n\n/**\n * Context for custom evaluation of feature flags.\n * This allows for more flexible evaluation based on custom logic or external data.\n * The identify function can be a direct object or a function that returns the entities.\n */\nexport type CustomEvaluationContext<E> = {\n /**\n * Optional function to identify the entities for evaluation.\n * This can be a function that returns the entities based on the current context.\n */\n identify: E | CustomEvaluationFunction<E>;\n};\n\nexport interface FlagRunner<E, R> {\n /**\n * Execute the feature flag evaluation with the provided entities.\n * This method will run the identify and decide functions to determine the flag's outcome.\n * @param res - Optional entities to use for evaluation. If not provided, it will call the identify function.\n * @returns A promise that resolves to the result of the feature flag evaluation.\n */\n (): Promise<R>;\n /**\n * Run the feature flag evaluation with a custom context.\n * This allows for more flexible evaluation based on custom logic or external data.\n * @param context - The custom evaluation context containing the identify function or object.\n * @returns A promise that resolves to the result of the feature flag evaluation.\n */\n run(context: CustomEvaluationContext<E>): Promise<R>;\n}\n\n/**\n * Class representing a feature flag in CommandKit.\n */\nexport class FeatureFlag<R, T> {\n private commandkit: CommandKit;\n\n /**\n * Create a new feature flag.\n * @param options - The options for the feature flag.\n */\n public constructor(public readonly options: FeatureFlagDefinition<R, T>) {\n this.commandkit = getCommandKit(true);\n const FlagStore = this.commandkit.flags;\n\n if (FlagStore.has(options.key)) {\n throw new Error(`Feature flag with key \"${options.key}\" already exists.`);\n }\n\n FlagStore.set(options.key, this);\n }\n\n private getContext(): EvaluationContext {\n const env = getContext();\n\n if (env?.context) {\n const {\n client,\n commandkit,\n interaction,\n message,\n guild,\n channel,\n command,\n } = env.context;\n\n return {\n client: client as Client<true>,\n commandkit,\n command: {\n interaction,\n message,\n guild,\n channel,\n command,\n },\n event: null,\n };\n }\n\n const eventCtx = eventWorkerContext.getStore();\n\n if (eventCtx) {\n const { commandkit, data, event, namespace } = eventCtx;\n\n return {\n client: commandkit.client as Client<true>,\n commandkit,\n event: {\n data,\n event,\n namespace,\n arguments: eventCtx.arguments,\n argumentsAs: (eventName) => {\n const args = eventCtx.arguments as ClientEvents[typeof eventName];\n return args;\n },\n },\n command: null,\n };\n }\n\n throw new Error(\n 'Could not determine the execution context. Feature flags may only be used inside a command or event.',\n );\n }\n\n /**\n * Execute the feature flag evaluation.\n * @param res - Optional entities to use for evaluation. If not provided, it will call the identify function.\n * @returns A promise that resolves to the result of the feature flag evaluation.\n */\n public async execute(res?: T): Promise<R> {\n const { decide, identify, disableAnalytics } = this.options;\n\n const identificationStart = performance.now();\n const entities =\n res ??\n (await (async () => {\n const ctx = this.getContext();\n return (await identify?.(ctx)) ?? ({} as T);\n })());\n const identificationTime = performance.now() - identificationStart;\n\n // Get provider configuration if global provider is available\n let providerConfig: FlagConfiguration | null = null;\n if (flagProvider) {\n try {\n providerConfig = await flagProvider.getFlag(this.options.key, entities);\n\n // If provider says flag is disabled, return early with default behavior\n if (providerConfig && !providerConfig.enabled) {\n // For boolean flags, return false; for others, let decide function handle it\n if (typeof decide === 'function') {\n const decisionResult = await decide({\n entities,\n provider: providerConfig,\n });\n return decisionResult as R;\n }\n }\n } catch (error) {\n Logger.error`Error fetching flag provider configuration for \"${this.options.key}\": ${error}`;\n // continue with local decision if provider fails\n }\n }\n\n const decisionStart = performance.now();\n const decisionResult = await decide({\n entities,\n provider: providerConfig,\n });\n const decisionTime = performance.now() - decisionStart;\n\n // Skip analytics if disabled\n if (!disableAnalytics) {\n defer(async () => {\n await this.commandkit.analytics.track({\n name: AnalyticsEvents.FEATURE_FLAG_METRICS,\n data: {\n flag: this.options.key,\n identificationTime: identificationTime.toFixed(2),\n decisionTime: decisionTime.toFixed(2),\n usedProvider: flagProvider !== null,\n providerEnabled: providerConfig?.enabled ?? null,\n },\n });\n });\n\n defer(async () => {\n await this.commandkit.analytics.track({\n name: AnalyticsEvents.FEATURE_FLAG_DECISION,\n id:\n entities &&\n typeof entities === 'object' &&\n 'id' in entities &&\n typeof entities.id === 'string'\n ? entities.id\n : undefined,\n data: {\n flag: this.options.key,\n decision: JsonSerialize(decisionResult, 'unknown'),\n providerUsed: flagProvider !== null,\n },\n });\n });\n }\n\n return decisionResult as R;\n }\n}\n\n/**\n * Create a new feature flag.\n * @param options - The options for the feature flag.\n * @returns A new instance of the FeatureFlag class.\n */\nexport function flag<Returns = boolean, Entity = Record<any, any>>(\n options: FeatureFlagDefinition<Returns, Entity>,\n): FlagRunner<Entity, Returns> {\n const flag = new FeatureFlag<Returns, Entity>(options);\n const runner = flag.execute.bind(flag, undefined) as FlagRunner<\n Entity,\n Returns\n >;\n\n runner.run = async function (ctx) {\n if (!ctx?.identify) {\n throw new Error(\n 'Custom evaluation context must have an identify function or object.',\n );\n }\n\n const context = (\n typeof ctx === 'function'\n ? await (ctx as CustomEvaluationFunction<Entity>)()\n : ctx\n ) as Entity;\n\n const decisionResult = await flag.execute(context);\n\n return decisionResult;\n };\n\n return runner;\n}\n"],"mappings":";;;;;AAqBA,IAAI,eAAoC;;;;AAKxC,SAAgB,gBAAgB,UAA8B;AAC5D,gBAAe;;;;;AA2NjB,IAAa,cAAb,MAA+B;CAC7B,AAAQ;;;;;CAMR,AAAO,YAAY,AAAgB,SAAsC;EAAtC;AACjC,OAAK,aAAa,iCAAc,KAAK;EACrC,MAAM,YAAY,KAAK,WAAW;AAElC,MAAI,UAAU,IAAI,QAAQ,IAAI,CAC5B,OAAM,IAAI,MAAM,0BAA0B,QAAQ,IAAI,mBAAmB;AAG3E,YAAU,IAAI,QAAQ,KAAK,KAAK;;CAGlC,AAAQ,aAAgC;EACtC,MAAM,MAAM,+BAAY;AAExB,gDAAI,IAAK,SAAS;GAChB,MAAM,EACJ,QACA,YACA,aACA,SACA,OACA,SACA,YACE,IAAI;AAER,UAAO;IACG;IACR;IACA,SAAS;KACP;KACA;KACA;KACA;KACA;KACD;IACD,OAAO;IACR;;EAGH,MAAM,WAAW,8CAAmB,UAAU;AAE9C,MAAI,UAAU;GACZ,MAAM,EAAE,YAAY,MAAM,OAAO,cAAc;AAE/C,UAAO;IACL,QAAQ,WAAW;IACnB;IACA,OAAO;KACL;KACA;KACA;KACA,WAAW,SAAS;KACpB,cAAc,cAAc;AAE1B,aADa,SAAS;;KAGzB;IACD,SAAS;IACV;;AAGH,QAAM,IAAI,MACR,uGACD;;;;;;;CAQH,MAAa,QAAQ,KAAqB;EACxC,MAAM,EAAE,QAAQ,UAAU,qBAAqB,KAAK;EAEpD,MAAM,sBAAsB,YAAY,KAAK;EAC7C,MAAM,WACN,OACA,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KjD,QAAO,MAAM,eAAgB,KAAK;AAChC,MAAI,4CAAC,IAAK,UACR,OAAM,IAAI,MACR,sEACD;EAGH,MAAM,UACN,OAAO,QAAQ,aACf,MAAO,KAA0C,GACjD;AAKA,SAFuB,MAAM,OAAK,QAAQ,QAAQ;;AAKpD,QAAO"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
//#region src/utils/resolve-file-url.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Convert a local file path to a file URL.
|
|
4
|
-
* @param filePath - The local file's path.
|
|
5
|
-
* @param withTs - Whether to append a timestamp to the URL.
|
|
6
|
-
* @returns - The converted file URL.
|
|
7
|
-
*/
|
|
8
|
-
declare function toFileURL(filePath: string, withTs?: boolean): string;
|
|
9
|
-
//#endregion
|
|
10
|
-
export { toFileURL as t };
|
|
11
|
-
//# sourceMappingURL=resolve-file-url-B63_4Wm3.d.ts.map
|
package/dist/serde-CqUxaQUh.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
const require_constants = require('./constants-Dy6P2veX.js');
|
|
2
|
-
|
|
3
|
-
//#region src/kv/serde.ts
|
|
4
|
-
function serializer(value) {
|
|
5
|
-
if (value === null) return {
|
|
6
|
-
t: require_constants.SerializerType.Null,
|
|
7
|
-
v: null
|
|
8
|
-
};
|
|
9
|
-
if (value === void 0) return {
|
|
10
|
-
t: require_constants.SerializerType.Undefined,
|
|
11
|
-
v: void 0
|
|
12
|
-
};
|
|
13
|
-
if (typeof value === "string") return {
|
|
14
|
-
t: require_constants.SerializerType.String,
|
|
15
|
-
v: value
|
|
16
|
-
};
|
|
17
|
-
if (typeof value === "number") return {
|
|
18
|
-
t: require_constants.SerializerType.Number,
|
|
19
|
-
v: value
|
|
20
|
-
};
|
|
21
|
-
if (typeof value === "boolean") return {
|
|
22
|
-
t: require_constants.SerializerType.Boolean,
|
|
23
|
-
v: value
|
|
24
|
-
};
|
|
25
|
-
if (typeof value === "bigint") return {
|
|
26
|
-
t: require_constants.SerializerType.BigInt,
|
|
27
|
-
v: value.toString()
|
|
28
|
-
};
|
|
29
|
-
if (value instanceof Date) return {
|
|
30
|
-
t: require_constants.SerializerType.Date,
|
|
31
|
-
v: value.toISOString()
|
|
32
|
-
};
|
|
33
|
-
if (Array.isArray(value)) return {
|
|
34
|
-
t: require_constants.SerializerType.Array,
|
|
35
|
-
v: value
|
|
36
|
-
};
|
|
37
|
-
if (value instanceof Map) return {
|
|
38
|
-
t: require_constants.SerializerType.Map,
|
|
39
|
-
v: Array.from(value.entries())
|
|
40
|
-
};
|
|
41
|
-
if (value instanceof Set) return {
|
|
42
|
-
t: require_constants.SerializerType.Set,
|
|
43
|
-
v: Array.from(value)
|
|
44
|
-
};
|
|
45
|
-
if (Buffer.isBuffer(value)) return {
|
|
46
|
-
t: require_constants.SerializerType.Buffer,
|
|
47
|
-
v: value.toString("base64")
|
|
48
|
-
};
|
|
49
|
-
if (value instanceof RegExp) return {
|
|
50
|
-
t: require_constants.SerializerType.RegExp,
|
|
51
|
-
v: {
|
|
52
|
-
source: value.source,
|
|
53
|
-
flags: value.flags
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
if (typeof value === "object") return {
|
|
57
|
-
t: require_constants.SerializerType.Object,
|
|
58
|
-
v: value
|
|
59
|
-
};
|
|
60
|
-
return {
|
|
61
|
-
t: require_constants.SerializerType.String,
|
|
62
|
-
v: String(value)
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
function deserializer(serialized) {
|
|
66
|
-
switch (serialized.t) {
|
|
67
|
-
case require_constants.SerializerType.Null: return null;
|
|
68
|
-
case require_constants.SerializerType.Undefined: return;
|
|
69
|
-
case require_constants.SerializerType.String: return serialized.v;
|
|
70
|
-
case require_constants.SerializerType.Number: return serialized.v;
|
|
71
|
-
case require_constants.SerializerType.Boolean: return serialized.v;
|
|
72
|
-
case require_constants.SerializerType.BigInt: return BigInt(serialized.v);
|
|
73
|
-
case require_constants.SerializerType.Date: return new Date(serialized.v);
|
|
74
|
-
case require_constants.SerializerType.Array: return serialized.v;
|
|
75
|
-
case require_constants.SerializerType.Map: return new Map(serialized.v);
|
|
76
|
-
case require_constants.SerializerType.Set: return new Set(serialized.v);
|
|
77
|
-
case require_constants.SerializerType.Buffer: return Buffer.from(serialized.v, "base64");
|
|
78
|
-
case require_constants.SerializerType.RegExp: return new RegExp(serialized.v.source, serialized.v.flags);
|
|
79
|
-
case require_constants.SerializerType.Object: return serialized.v;
|
|
80
|
-
default: return serialized.v;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
//#endregion
|
|
85
|
-
Object.defineProperty(exports, 'deserializer', {
|
|
86
|
-
enumerable: true,
|
|
87
|
-
get: function () {
|
|
88
|
-
return deserializer;
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
Object.defineProperty(exports, 'serializer', {
|
|
92
|
-
enumerable: true,
|
|
93
|
-
get: function () {
|
|
94
|
-
return serializer;
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
//# sourceMappingURL=serde-CqUxaQUh.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serde-CqUxaQUh.js","names":[],"sources":["../src/kv/serde.ts"],"sourcesContent":["import { SerializerType } from './constants';\n\nexport interface SerializedValue {\n t: SerializerType;\n v: any;\n}\n\nexport function serializer(value: any): SerializedValue {\n if (value === null) {\n return { t: SerializerType.Null, v: null };\n }\n\n if (value === undefined) {\n return { t: SerializerType.Undefined, v: undefined };\n }\n\n if (typeof value === 'string') {\n return { t: SerializerType.String, v: value };\n }\n\n if (typeof value === 'number') {\n return { t: SerializerType.Number, v: value };\n }\n\n if (typeof value === 'boolean') {\n return { t: SerializerType.Boolean, v: value };\n }\n\n if (typeof value === 'bigint') {\n return { t: SerializerType.BigInt, v: value.toString() };\n }\n\n if (value instanceof Date) {\n return { t: SerializerType.Date, v: value.toISOString() };\n }\n\n if (Array.isArray(value)) {\n return { t: SerializerType.Array, v: value };\n }\n\n if (value instanceof Map) {\n return { t: SerializerType.Map, v: Array.from(value.entries()) };\n }\n\n if (value instanceof Set) {\n return { t: SerializerType.Set, v: Array.from(value) };\n }\n\n if (Buffer.isBuffer(value)) {\n return { t: SerializerType.Buffer, v: value.toString('base64') };\n }\n\n if (value instanceof RegExp) {\n return {\n t: SerializerType.RegExp,\n v: { source: value.source, flags: value.flags },\n };\n }\n\n if (typeof value === 'object') {\n return { t: SerializerType.Object, v: value };\n }\n\n // Fallback to string\n return { t: SerializerType.String, v: String(value) };\n}\n\nexport function deserializer(serialized: SerializedValue): any {\n switch (serialized.t) {\n case SerializerType.Null:\n return null;\n case SerializerType.Undefined:\n return undefined;\n case SerializerType.String:\n return serialized.v;\n case SerializerType.Number:\n return serialized.v;\n case SerializerType.Boolean:\n return serialized.v;\n case SerializerType.BigInt:\n return BigInt(serialized.v);\n case SerializerType.Date:\n return new Date(serialized.v);\n case SerializerType.Array:\n return serialized.v;\n case SerializerType.Map:\n return new Map(serialized.v);\n case SerializerType.Set:\n return new Set(serialized.v);\n case SerializerType.Buffer:\n return Buffer.from(serialized.v, 'base64');\n case SerializerType.RegExp:\n return new RegExp(serialized.v.source, serialized.v.flags);\n case SerializerType.Object:\n return serialized.v;\n default:\n return serialized.v;\n }\n}\n"],"mappings":";;;AAOA,SAAgB,WAAW,OAA6B;AACtD,KAAI,UAAU,KACZ,QAAO;EAAE,GAAG,iCAAe;EAAM,GAAG;EAAM;AAG5C,KAAI,UAAU,OACZ,QAAO;EAAE,GAAG,iCAAe;EAAW,GAAG;EAAW;AAGtD,KAAI,OAAO,UAAU,SACnB,QAAO;EAAE,GAAG,iCAAe;EAAQ,GAAG;EAAO;AAG/C,KAAI,OAAO,UAAU,SACnB,QAAO;EAAE,GAAG,iCAAe;EAAQ,GAAG;EAAO;AAG/C,KAAI,OAAO,UAAU,UACnB,QAAO;EAAE,GAAG,iCAAe;EAAS,GAAG;EAAO;AAGhD,KAAI,OAAO,UAAU,SACnB,QAAO;EAAE,GAAG,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