@azurioh/discord-kernel 0.1.0
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/LICENSE +21 -0
- package/README.md +77 -0
- package/dist/authz/authorizer.d.ts +45 -0
- package/dist/authz/authorizer.d.ts.map +1 -0
- package/dist/authz/authorizer.js +31 -0
- package/dist/authz/authorizer.js.map +1 -0
- package/dist/authz/require-level-guard.d.ts +23 -0
- package/dist/authz/require-level-guard.d.ts.map +1 -0
- package/dist/authz/require-level-guard.js +37 -0
- package/dist/authz/require-level-guard.js.map +1 -0
- package/dist/clock.d.ts +13 -0
- package/dist/clock.d.ts.map +1 -0
- package/dist/clock.js +13 -0
- package/dist/clock.js.map +1 -0
- package/dist/concurrency/keyed-queue.d.ts +18 -0
- package/dist/concurrency/keyed-queue.d.ts.map +1 -0
- package/dist/concurrency/keyed-queue.js +37 -0
- package/dist/concurrency/keyed-queue.js.map +1 -0
- package/dist/concurrency/run-with-concurrency.d.ts +15 -0
- package/dist/concurrency/run-with-concurrency.d.ts.map +1 -0
- package/dist/concurrency/run-with-concurrency.js +40 -0
- package/dist/concurrency/run-with-concurrency.js.map +1 -0
- package/dist/config/env.d.ts +17 -0
- package/dist/config/env.d.ts.map +1 -0
- package/dist/config/env.js +49 -0
- package/dist/config/env.js.map +1 -0
- package/dist/config/errors.d.ts +14 -0
- package/dist/config/errors.d.ts.map +1 -0
- package/dist/config/errors.js +25 -0
- package/dist/config/errors.js.map +1 -0
- package/dist/datetime.d.ts +34 -0
- package/dist/datetime.d.ts.map +1 -0
- package/dist/datetime.js +188 -0
- package/dist/datetime.js.map +1 -0
- package/dist/discord/api-errors.d.ts +20 -0
- package/dist/discord/api-errors.d.ts.map +1 -0
- package/dist/discord/api-errors.js +90 -0
- package/dist/discord/api-errors.js.map +1 -0
- package/dist/discord/channel-exporter.d.ts +42 -0
- package/dist/discord/channel-exporter.d.ts.map +1 -0
- package/dist/discord/channel-exporter.js +3 -0
- package/dist/discord/channel-exporter.js.map +1 -0
- package/dist/discord/command/autocomplete-dispatcher.d.ts +26 -0
- package/dist/discord/command/autocomplete-dispatcher.d.ts.map +1 -0
- package/dist/discord/command/autocomplete-dispatcher.js +41 -0
- package/dist/discord/command/autocomplete-dispatcher.js.map +1 -0
- package/dist/discord/command/autocomplete.d.ts +18 -0
- package/dist/discord/command/autocomplete.d.ts.map +1 -0
- package/dist/discord/command/autocomplete.js +65 -0
- package/dist/discord/command/autocomplete.js.map +1 -0
- package/dist/discord/command/context.d.ts +33 -0
- package/dist/discord/command/context.d.ts.map +1 -0
- package/dist/discord/command/context.js +48 -0
- package/dist/discord/command/context.js.map +1 -0
- package/dist/discord/command/cooldown-guard.d.ts +25 -0
- package/dist/discord/command/cooldown-guard.d.ts.map +1 -0
- package/dist/discord/command/cooldown-guard.js +60 -0
- package/dist/discord/command/cooldown-guard.js.map +1 -0
- package/dist/discord/command/create-command.d.ts +100 -0
- package/dist/discord/command/create-command.d.ts.map +1 -0
- package/dist/discord/command/create-command.js +245 -0
- package/dist/discord/command/create-command.js.map +1 -0
- package/dist/discord/command/create-context-menu-command.d.ts +51 -0
- package/dist/discord/command/create-context-menu-command.d.ts.map +1 -0
- package/dist/discord/command/create-context-menu-command.js +128 -0
- package/dist/discord/command/create-context-menu-command.js.map +1 -0
- package/dist/discord/command/errors.d.ts +19 -0
- package/dist/discord/command/errors.d.ts.map +1 -0
- package/dist/discord/command/errors.js +27 -0
- package/dist/discord/command/errors.js.map +1 -0
- package/dist/discord/command/guard.d.ts +30 -0
- package/dist/discord/command/guard.d.ts.map +1 -0
- package/dist/discord/command/guard.js +34 -0
- package/dist/discord/command/guard.js.map +1 -0
- package/dist/discord/command/localization.d.ts +9 -0
- package/dist/discord/command/localization.d.ts.map +1 -0
- package/dist/discord/command/localization.js +13 -0
- package/dist/discord/command/localization.js.map +1 -0
- package/dist/discord/command/options.d.ts +113 -0
- package/dist/discord/command/options.d.ts.map +1 -0
- package/dist/discord/command/options.js +509 -0
- package/dist/discord/command/options.js.map +1 -0
- package/dist/discord/command/permission-guard.d.ts +21 -0
- package/dist/discord/command/permission-guard.d.ts.map +1 -0
- package/dist/discord/command/permission-guard.js +69 -0
- package/dist/discord/command/permission-guard.js.map +1 -0
- package/dist/discord/command/router.d.ts +48 -0
- package/dist/discord/command/router.d.ts.map +1 -0
- package/dist/discord/command/router.js +118 -0
- package/dist/discord/command/router.js.map +1 -0
- package/dist/discord/command/types.d.ts +51 -0
- package/dist/discord/command/types.d.ts.map +1 -0
- package/dist/discord/command/types.js +3 -0
- package/dist/discord/command/types.js.map +1 -0
- package/dist/discord/components/component-router.d.ts +116 -0
- package/dist/discord/components/component-router.d.ts.map +1 -0
- package/dist/discord/components/component-router.js +123 -0
- package/dist/discord/components/component-router.js.map +1 -0
- package/dist/discord/components/interactive-message/index.d.ts +3 -0
- package/dist/discord/components/interactive-message/index.d.ts.map +1 -0
- package/dist/discord/components/interactive-message/index.js +11 -0
- package/dist/discord/components/interactive-message/index.js.map +1 -0
- package/dist/discord/components/interactive-message/interactive-message-collector.d.ts +195 -0
- package/dist/discord/components/interactive-message/interactive-message-collector.d.ts.map +1 -0
- package/dist/discord/components/interactive-message/interactive-message-collector.js +151 -0
- package/dist/discord/components/interactive-message/interactive-message-collector.js.map +1 -0
- package/dist/discord/components/interactive-message/mount-interactive-message.d.ts +30 -0
- package/dist/discord/components/interactive-message/mount-interactive-message.d.ts.map +1 -0
- package/dist/discord/components/interactive-message/mount-interactive-message.js +44 -0
- package/dist/discord/components/interactive-message/mount-interactive-message.js.map +1 -0
- package/dist/discord/components/paginator/index.d.ts +5 -0
- package/dist/discord/components/paginator/index.d.ts.map +1 -0
- package/dist/discord/components/paginator/index.js +15 -0
- package/dist/discord/components/paginator/index.js.map +1 -0
- package/dist/discord/components/paginator/mount-paginator.d.ts +25 -0
- package/dist/discord/components/paginator/mount-paginator.d.ts.map +1 -0
- package/dist/discord/components/paginator/mount-paginator.js +41 -0
- package/dist/discord/components/paginator/mount-paginator.js.map +1 -0
- package/dist/discord/components/paginator/page-state.d.ts +21 -0
- package/dist/discord/components/paginator/page-state.d.ts.map +1 -0
- package/dist/discord/components/paginator/page-state.js +44 -0
- package/dist/discord/components/paginator/page-state.js.map +1 -0
- package/dist/discord/components/paginator/paginator-buttons.d.ts +17 -0
- package/dist/discord/components/paginator/paginator-buttons.d.ts.map +1 -0
- package/dist/discord/components/paginator/paginator-buttons.js +45 -0
- package/dist/discord/components/paginator/paginator-buttons.js.map +1 -0
- package/dist/discord/components/paginator/paginator-view.d.ts +26 -0
- package/dist/discord/components/paginator/paginator-view.d.ts.map +1 -0
- package/dist/discord/components/paginator/paginator-view.js +28 -0
- package/dist/discord/components/paginator/paginator-view.js.map +1 -0
- package/dist/discord/components/persistent-paginator.d.ts +47 -0
- package/dist/discord/components/persistent-paginator.d.ts.map +1 -0
- package/dist/discord/components/persistent-paginator.js +137 -0
- package/dist/discord/components/persistent-paginator.js.map +1 -0
- package/dist/discord/components/settings-editor/index.d.ts +7 -0
- package/dist/discord/components/settings-editor/index.d.ts.map +1 -0
- package/dist/discord/components/settings-editor/index.js +22 -0
- package/dist/discord/components/settings-editor/index.js.map +1 -0
- package/dist/discord/components/settings-editor/mount-settings-editor.d.ts +140 -0
- package/dist/discord/components/settings-editor/mount-settings-editor.d.ts.map +1 -0
- package/dist/discord/components/settings-editor/mount-settings-editor.js +344 -0
- package/dist/discord/components/settings-editor/mount-settings-editor.js.map +1 -0
- package/dist/discord/components/settings-editor/navigation.d.ts +49 -0
- package/dist/discord/components/settings-editor/navigation.d.ts.map +1 -0
- package/dist/discord/components/settings-editor/navigation.js +39 -0
- package/dist/discord/components/settings-editor/navigation.js.map +1 -0
- package/dist/discord/components/settings-editor/settings-editor-card.view.d.ts +56 -0
- package/dist/discord/components/settings-editor/settings-editor-card.view.d.ts.map +1 -0
- package/dist/discord/components/settings-editor/settings-editor-card.view.js +284 -0
- package/dist/discord/components/settings-editor/settings-editor-card.view.js.map +1 -0
- package/dist/discord/components/settings-editor/settings-editor-field-modal.d.ts +69 -0
- package/dist/discord/components/settings-editor/settings-editor-field-modal.d.ts.map +1 -0
- package/dist/discord/components/settings-editor/settings-editor-field-modal.js +353 -0
- package/dist/discord/components/settings-editor/settings-editor-field-modal.js.map +1 -0
- package/dist/discord/components/settings-editor/settings-editor-fields.d.ts +216 -0
- package/dist/discord/components/settings-editor/settings-editor-fields.d.ts.map +1 -0
- package/dist/discord/components/settings-editor/settings-editor-fields.js +66 -0
- package/dist/discord/components/settings-editor/settings-editor-fields.js.map +1 -0
- package/dist/discord/components/settings-editor/settings-editor.view.d.ts +303 -0
- package/dist/discord/components/settings-editor/settings-editor.view.d.ts.map +1 -0
- package/dist/discord/components/settings-editor/settings-editor.view.js +316 -0
- package/dist/discord/components/settings-editor/settings-editor.view.js.map +1 -0
- package/dist/discord/events/create-event.d.ts +5 -0
- package/dist/discord/events/create-event.d.ts.map +1 -0
- package/dist/discord/events/create-event.js +8 -0
- package/dist/discord/events/create-event.js.map +1 -0
- package/dist/discord/events/event-router.d.ts +16 -0
- package/dist/discord/events/event-router.d.ts.map +1 -0
- package/dist/discord/events/event-router.js +51 -0
- package/dist/discord/events/event-router.js.map +1 -0
- package/dist/discord/events/types.d.ts +16 -0
- package/dist/discord/events/types.d.ts.map +1 -0
- package/dist/discord/events/types.js +3 -0
- package/dist/discord/events/types.js.map +1 -0
- package/dist/discord/i18n.d.ts +58 -0
- package/dist/discord/i18n.d.ts.map +1 -0
- package/dist/discord/i18n.js +173 -0
- package/dist/discord/i18n.js.map +1 -0
- package/dist/discord/interaction/button.d.ts +39 -0
- package/dist/discord/interaction/button.d.ts.map +1 -0
- package/dist/discord/interaction/button.js +36 -0
- package/dist/discord/interaction/button.js.map +1 -0
- package/dist/discord/interaction/interaction-router.d.ts +21 -0
- package/dist/discord/interaction/interaction-router.d.ts.map +1 -0
- package/dist/discord/interaction/interaction-router.js +24 -0
- package/dist/discord/interaction/interaction-router.js.map +1 -0
- package/dist/discord/interaction/modal.d.ts +171 -0
- package/dist/discord/interaction/modal.d.ts.map +1 -0
- package/dist/discord/interaction/modal.js +264 -0
- package/dist/discord/interaction/modal.js.map +1 -0
- package/dist/discord/interaction/select-menu.d.ts +104 -0
- package/dist/discord/interaction/select-menu.d.ts.map +1 -0
- package/dist/discord/interaction/select-menu.js +126 -0
- package/dist/discord/interaction/select-menu.js.map +1 -0
- package/dist/discord/permissions.d.ts +32 -0
- package/dist/discord/permissions.d.ts.map +1 -0
- package/dist/discord/permissions.js +40 -0
- package/dist/discord/permissions.js.map +1 -0
- package/dist/discord/placeholder-registry-errors.d.ts +10 -0
- package/dist/discord/placeholder-registry-errors.d.ts.map +1 -0
- package/dist/discord/placeholder-registry-errors.js +18 -0
- package/dist/discord/placeholder-registry-errors.js.map +1 -0
- package/dist/discord/placeholder-registry.d.ts +53 -0
- package/dist/discord/placeholder-registry.d.ts.map +1 -0
- package/dist/discord/placeholder-registry.js +52 -0
- package/dist/discord/placeholder-registry.js.map +1 -0
- package/dist/discord/presenter.d.ts +26 -0
- package/dist/discord/presenter.d.ts.map +1 -0
- package/dist/discord/presenter.js +3 -0
- package/dist/discord/presenter.js.map +1 -0
- package/dist/discord/ui/card.d.ts +114 -0
- package/dist/discord/ui/card.d.ts.map +1 -0
- package/dist/discord/ui/card.js +162 -0
- package/dist/discord/ui/card.js.map +1 -0
- package/dist/discord/ui/color-input-errors.d.ts +12 -0
- package/dist/discord/ui/color-input-errors.d.ts.map +1 -0
- package/dist/discord/ui/color-input-errors.js +21 -0
- package/dist/discord/ui/color-input-errors.js.map +1 -0
- package/dist/discord/ui/color-input.d.ts +37 -0
- package/dist/discord/ui/color-input.d.ts.map +1 -0
- package/dist/discord/ui/color-input.js +166 -0
- package/dist/discord/ui/color-input.js.map +1 -0
- package/dist/discord/ui/colors.d.ts +44 -0
- package/dist/discord/ui/colors.d.ts.map +1 -0
- package/dist/discord/ui/colors.js +45 -0
- package/dist/discord/ui/colors.js.map +1 -0
- package/dist/discord/ui/embed.d.ts +16 -0
- package/dist/discord/ui/embed.d.ts.map +1 -0
- package/dist/discord/ui/embed.js +53 -0
- package/dist/discord/ui/embed.js.map +1 -0
- package/dist/discord/ui/message-attachments.d.ts +40 -0
- package/dist/discord/ui/message-attachments.d.ts.map +1 -0
- package/dist/discord/ui/message-attachments.js +27 -0
- package/dist/discord/ui/message-attachments.js.map +1 -0
- package/dist/errors/business-error.d.ts +41 -0
- package/dist/errors/business-error.d.ts.map +1 -0
- package/dist/errors/business-error.js +39 -0
- package/dist/errors/business-error.js.map +1 -0
- package/dist/errors/describe-error.d.ts +29 -0
- package/dist/errors/describe-error.d.ts.map +1 -0
- package/dist/errors/describe-error.js +49 -0
- package/dist/errors/describe-error.js.map +1 -0
- package/dist/errors/incident-ref.d.ts +7 -0
- package/dist/errors/incident-ref.d.ts.map +1 -0
- package/dist/errors/incident-ref.js +13 -0
- package/dist/errors/incident-ref.js.map +1 -0
- package/dist/errors/index.d.ts +4 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +15 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/i18n/business-message.d.ts +14 -0
- package/dist/i18n/business-message.d.ts.map +1 -0
- package/dist/i18n/business-message.js +19 -0
- package/dist/i18n/business-message.js.map +1 -0
- package/dist/i18n/catalog.d.ts +27 -0
- package/dist/i18n/catalog.d.ts.map +1 -0
- package/dist/i18n/catalog.js +25 -0
- package/dist/i18n/catalog.js.map +1 -0
- package/dist/i18n/errors.d.ts +10 -0
- package/dist/i18n/errors.d.ts.map +1 -0
- package/dist/i18n/errors.js +18 -0
- package/dist/i18n/errors.js.map +1 -0
- package/dist/i18n/index.d.ts +6 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +16 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/locale.d.ts +22 -0
- package/dist/i18n/locale.d.ts.map +1 -0
- package/dist/i18n/locale.js +40 -0
- package/dist/i18n/locale.js.map +1 -0
- package/dist/i18n/translator.d.ts +35 -0
- package/dist/i18n/translator.d.ts.map +1 -0
- package/dist/i18n/translator.js +40 -0
- package/dist/i18n/translator.js.map +1 -0
- package/dist/logger.d.ts +28 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +3 -0
- package/dist/logger.js.map +1 -0
- package/dist/module/module.d.ts +42 -0
- package/dist/module/module.d.ts.map +1 -0
- package/dist/module/module.js +3 -0
- package/dist/module/module.js.map +1 -0
- package/dist/persistence/database.d.ts +24 -0
- package/dist/persistence/database.d.ts.map +1 -0
- package/dist/persistence/database.js +3 -0
- package/dist/persistence/database.js.map +1 -0
- package/dist/resilience/retry.d.ts +36 -0
- package/dist/resilience/retry.d.ts.map +1 -0
- package/dist/resilience/retry.js +78 -0
- package/dist/resilience/retry.js.map +1 -0
- package/dist/scheduler/errors.d.ts +25 -0
- package/dist/scheduler/errors.d.ts.map +1 -0
- package/dist/scheduler/errors.js +45 -0
- package/dist/scheduler/errors.js.map +1 -0
- package/dist/scheduler/scheduler.d.ts +68 -0
- package/dist/scheduler/scheduler.d.ts.map +1 -0
- package/dist/scheduler/scheduler.js +162 -0
- package/dist/scheduler/scheduler.js.map +1 -0
- package/package.json +89 -0
- package/src/authz/authorizer.ts +76 -0
- package/src/authz/require-level-guard.ts +42 -0
- package/src/clock.ts +18 -0
- package/src/concurrency/keyed-queue.ts +50 -0
- package/src/concurrency/run-with-concurrency.ts +44 -0
- package/src/config/env.ts +58 -0
- package/src/config/errors.ts +21 -0
- package/src/datetime.ts +221 -0
- package/src/discord/api-errors.ts +91 -0
- package/src/discord/channel-exporter.ts +48 -0
- package/src/discord/command/autocomplete-dispatcher.ts +54 -0
- package/src/discord/command/autocomplete.ts +76 -0
- package/src/discord/command/context.ts +85 -0
- package/src/discord/command/cooldown-guard.ts +81 -0
- package/src/discord/command/create-command.ts +431 -0
- package/src/discord/command/create-context-menu-command.ts +227 -0
- package/src/discord/command/errors.ts +22 -0
- package/src/discord/command/guard.ts +54 -0
- package/src/discord/command/localization.ts +11 -0
- package/src/discord/command/options.ts +847 -0
- package/src/discord/command/permission-guard.ts +74 -0
- package/src/discord/command/router.ts +142 -0
- package/src/discord/command/types.ts +52 -0
- package/src/discord/components/component-router.ts +213 -0
- package/src/discord/components/interactive-message/index.ts +18 -0
- package/src/discord/components/interactive-message/interactive-message-collector.ts +374 -0
- package/src/discord/components/interactive-message/mount-interactive-message.ts +71 -0
- package/src/discord/components/paginator/index.ts +17 -0
- package/src/discord/components/paginator/mount-paginator.ts +69 -0
- package/src/discord/components/paginator/page-state.ts +45 -0
- package/src/discord/components/paginator/paginator-buttons.ts +60 -0
- package/src/discord/components/paginator/paginator-view.ts +61 -0
- package/src/discord/components/persistent-paginator.ts +197 -0
- package/src/discord/components/settings-editor/index.ts +41 -0
- package/src/discord/components/settings-editor/mount-settings-editor.ts +646 -0
- package/src/discord/components/settings-editor/navigation.ts +67 -0
- package/src/discord/components/settings-editor/settings-editor-card.view.ts +344 -0
- package/src/discord/components/settings-editor/settings-editor-field-modal.ts +538 -0
- package/src/discord/components/settings-editor/settings-editor-fields.ts +290 -0
- package/src/discord/components/settings-editor/settings-editor.view.ts +654 -0
- package/src/discord/events/create-event.ts +7 -0
- package/src/discord/events/event-router.ts +53 -0
- package/src/discord/events/types.ts +17 -0
- package/src/discord/i18n.ts +173 -0
- package/src/discord/interaction/button.ts +75 -0
- package/src/discord/interaction/interaction-router.ts +28 -0
- package/src/discord/interaction/modal.ts +505 -0
- package/src/discord/interaction/select-menu.ts +246 -0
- package/src/discord/permissions.ts +57 -0
- package/src/discord/placeholder-registry-errors.ts +11 -0
- package/src/discord/placeholder-registry.ts +77 -0
- package/src/discord/presenter.ts +26 -0
- package/src/discord/ui/card.ts +303 -0
- package/src/discord/ui/color-input-errors.ts +17 -0
- package/src/discord/ui/color-input.ts +179 -0
- package/src/discord/ui/colors.ts +58 -0
- package/src/discord/ui/embed.ts +64 -0
- package/src/discord/ui/message-attachments.ts +57 -0
- package/src/errors/business-error.ts +49 -0
- package/src/errors/describe-error.ts +73 -0
- package/src/errors/incident-ref.ts +10 -0
- package/src/errors/index.ts +12 -0
- package/src/i18n/business-message.ts +23 -0
- package/src/i18n/catalog.ts +41 -0
- package/src/i18n/errors.ts +11 -0
- package/src/i18n/index.ts +11 -0
- package/src/i18n/locale.ts +41 -0
- package/src/i18n/translator.ts +78 -0
- package/src/logger.ts +28 -0
- package/src/module/module.ts +42 -0
- package/src/persistence/database.ts +23 -0
- package/src/resilience/retry.ts +102 -0
- package/src/scheduler/errors.ts +40 -0
- package/src/scheduler/scheduler.ts +248 -0
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mountSettingsEditor = mountSettingsEditor;
|
|
4
|
+
const interactive_message_1 = require("../../../discord/components/interactive-message");
|
|
5
|
+
const navigation_1 = require("../../../discord/components/settings-editor/navigation");
|
|
6
|
+
const settings_editor_view_1 = require("../../../discord/components/settings-editor/settings-editor.view");
|
|
7
|
+
const settings_editor_card_view_1 = require("../../../discord/components/settings-editor/settings-editor-card.view");
|
|
8
|
+
const settings_editor_field_modal_1 = require("../../../discord/components/settings-editor/settings-editor-field-modal");
|
|
9
|
+
const settings_editor_fields_1 = require("../../../discord/components/settings-editor/settings-editor-fields");
|
|
10
|
+
const i18n_1 = require("../../../discord/i18n");
|
|
11
|
+
const button_1 = require("../../../discord/interaction/button");
|
|
12
|
+
const errors_1 = require("../../../errors");
|
|
13
|
+
const i18n_2 = require("../../../i18n");
|
|
14
|
+
/**
|
|
15
|
+
* Mount the editor every customisable ticket embed is edited through: a preview
|
|
16
|
+
* of what members see, a menu of fields, a modal per field, and a confirmed
|
|
17
|
+
* reset.
|
|
18
|
+
*
|
|
19
|
+
* Everything specific to *what* is being edited — where the values are read,
|
|
20
|
+
* where they are written, how the preview is rendered — is supplied by the
|
|
21
|
+
* caller. What lives here is the part both screens would otherwise have written
|
|
22
|
+
* twice: the modal round trip, the read-at-submit-time rule, refusals turned
|
|
23
|
+
* into notices, and re-rendering through the interaction that is still usable.
|
|
24
|
+
*
|
|
25
|
+
* Call it on an already-deferred interaction.
|
|
26
|
+
*/
|
|
27
|
+
async function mountSettingsEditor(interaction, options) {
|
|
28
|
+
const { translator, locale } = options;
|
|
29
|
+
const { ids } = options;
|
|
30
|
+
const mounted = { screen: null };
|
|
31
|
+
const mountedView = { view: null };
|
|
32
|
+
// Every level's fields, flattened: a pick is routed by key, and the key is
|
|
33
|
+
// unique across the screen whichever level offered it.
|
|
34
|
+
const allFields = [
|
|
35
|
+
...options.fields,
|
|
36
|
+
...(options.levels ?? []).flatMap((level) => level.fields),
|
|
37
|
+
];
|
|
38
|
+
/**
|
|
39
|
+
* Run one write and fold its outcome into the state. A refusal is answered
|
|
40
|
+
* identically wherever it comes from: nothing changes but the notice.
|
|
41
|
+
*
|
|
42
|
+
* The `try` covers `write()` alone — a `BusinessError` out of it is a
|
|
43
|
+
* legitimate refusal to show, because nothing landed. `onWritten` runs
|
|
44
|
+
* only once that write has actually succeeded, deliberately outside that
|
|
45
|
+
* `try`: a hook failing after the data is already saved is not a refusal
|
|
46
|
+
* of the write, and folding it into the same catch would tell the
|
|
47
|
+
* administrator their change was rejected when it was not — written and
|
|
48
|
+
* called a refusal is worse than either alone.
|
|
49
|
+
*
|
|
50
|
+
* `onWritten` is a public hook; nothing here trusts it not to throw. Its
|
|
51
|
+
* failure is logged rather than shown or re-thrown: the write already
|
|
52
|
+
* landed, so the administrator is owed the confirmation of what they
|
|
53
|
+
* actually did, and a side effect that failed to keep up (a public panel
|
|
54
|
+
* not yet refreshed, say) is an incident to trace, not a message to hand
|
|
55
|
+
* back to them on a screen that has nothing to do with it.
|
|
56
|
+
*/
|
|
57
|
+
async function applyChange(state, write, notice) {
|
|
58
|
+
let written;
|
|
59
|
+
try {
|
|
60
|
+
written = await write();
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
if (error instanceof errors_1.BusinessError) {
|
|
64
|
+
// A refusal is the one outcome the screen has to say out loud:
|
|
65
|
+
// nothing was written, so the preview shows no trace of it.
|
|
66
|
+
return {
|
|
67
|
+
...state,
|
|
68
|
+
notice: { text: (0, i18n_2.resolveBusinessMessage)(error, translator, locale), tone: "refusal" },
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
await options.onWritten?.();
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
options.logger.error({ err: (0, errors_1.describeError)(error) }, "onWritten failed after a settings editor write had already landed");
|
|
78
|
+
}
|
|
79
|
+
const { subject, assets } = written;
|
|
80
|
+
return { ...state, subject, assets, notice: { text: notice, tone: "confirmation" } };
|
|
81
|
+
}
|
|
82
|
+
/** Undo one step of where the screen is: leave the level for the one above it. */
|
|
83
|
+
function stepBack(clickCtx) {
|
|
84
|
+
const { state } = clickCtx;
|
|
85
|
+
return clickCtx.update({
|
|
86
|
+
...state,
|
|
87
|
+
path: (0, navigation_1.popLevel)(state.path),
|
|
88
|
+
notice: null,
|
|
89
|
+
// Whatever a screen's own accessory button was waiting to have confirmed
|
|
90
|
+
// belonged to the level being left; carrying it up would let a click
|
|
91
|
+
// meant for something else fire it.
|
|
92
|
+
confirming: null,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function fieldNotice(field, submission) {
|
|
96
|
+
return translator.translate(locale, fieldNoticeKey(field, submission), {
|
|
97
|
+
field: translator.translate(locale, field.labelKey),
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Edit one field: ask for its new value in a modal prefilled with the current
|
|
102
|
+
* one — a text input, an upload, or a select of the picker's own shape — save
|
|
103
|
+
* what comes back, and re-render the preview through the modal's own
|
|
104
|
+
* interaction, since `showModal` has already acknowledged the pick or click.
|
|
105
|
+
*
|
|
106
|
+
* `fieldKey` is the key of the field to edit — the select's own picked value
|
|
107
|
+
* on the embeds layout, the key baked into the button's id on the card
|
|
108
|
+
* layout — so both reach the very same round trip, and this is where they
|
|
109
|
+
* meet back up.
|
|
110
|
+
*/
|
|
111
|
+
async function editField(ctx, fieldKey) {
|
|
112
|
+
const view = mountedView.view;
|
|
113
|
+
if (view === null || !(0, settings_editor_fields_1.isEditorField)(allFields, fieldKey)) {
|
|
114
|
+
// `view` is unreachable while `null`: nothing can click a control before
|
|
115
|
+
// `mountInteractiveMessage` sends the message it belongs to, and `view` is
|
|
116
|
+
// assigned before that call. An unrecognised key cannot happen from either
|
|
117
|
+
// control either — both are built from `allFields` — but is not worth
|
|
118
|
+
// throwing over.
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const field = (0, settings_editor_fields_1.editorField)(allFields, fieldKey);
|
|
122
|
+
if ((0, settings_editor_fields_1.isGroupField)(field)) {
|
|
123
|
+
await editGroup(ctx, field);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (!(0, settings_editor_fields_1.isValueField)(field) && !(0, settings_editor_fields_1.isPickerField)(field)) {
|
|
127
|
+
// A level: descending writes nothing, so it answers the click by
|
|
128
|
+
// re-rendering rather than going through `applyChange` — there is no
|
|
129
|
+
// outcome to report.
|
|
130
|
+
const state = mounted.screen?.store.read() ?? ctx.state;
|
|
131
|
+
await ctx.update({
|
|
132
|
+
...state,
|
|
133
|
+
path: (0, navigation_1.pushLevel)(state.path, field.levelKey),
|
|
134
|
+
// The notice belonged to the level being left; carrying it down would
|
|
135
|
+
// credit this one with something that happened elsewhere. Likewise
|
|
136
|
+
// whatever a screen's own accessory button on that level was waiting
|
|
137
|
+
// to have confirmed.
|
|
138
|
+
notice: null,
|
|
139
|
+
confirming: null,
|
|
140
|
+
});
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const submission = await (0, settings_editor_field_modal_1.promptEditorFieldValue)(ctx.interaction, field, options.currentValue(ctx.state.subject, fieldKey), translator, locale);
|
|
144
|
+
if (submission === null) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
// Read at submit time rather than at pick time: a modal can stay open for
|
|
148
|
+
// minutes, during which the screen may have moved on to another subject.
|
|
149
|
+
const state = mounted.screen?.store.read() ?? ctx.state;
|
|
150
|
+
const next = await applyChange(state, () => options.save(state.subject, fieldKey, submission), fieldNotice(field, submission));
|
|
151
|
+
mounted.screen?.store.write(next);
|
|
152
|
+
await submission.interaction.update((0, interactive_message_1.toMessageEditOptions)(view.render(next), [...submission.interaction.message.attachments.values()], next));
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Edit a group: ask for every member field it declares in one modal,
|
|
156
|
+
* prefilled the same way a single field is, and save the whole thing as one
|
|
157
|
+
* write — `options.saveGroup` is what decides what "one write" means for
|
|
158
|
+
* this group, most often a service that already takes a partial patch.
|
|
159
|
+
*/
|
|
160
|
+
async function editGroup(ctx, group) {
|
|
161
|
+
const view = mountedView.view;
|
|
162
|
+
if (view === null) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const prompt = await (0, settings_editor_field_modal_1.promptEditorGroupValue)(ctx.interaction, group, (memberKey) => options.currentValue(ctx.state.subject, memberKey), options.groupLegend?.(ctx.state.subject, group.key) ?? null, translator, locale);
|
|
166
|
+
if (prompt === null) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const { saveGroup } = options;
|
|
170
|
+
if (saveGroup === undefined) {
|
|
171
|
+
// A screen declaring a `group`-kind field must also declare `saveGroup` —
|
|
172
|
+
// a wiring mistake in the module, not something an administrator caused,
|
|
173
|
+
// so the round trip simply ends here rather than throwing at them for it.
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
// Read at submit time rather than at pick time, exactly as `editField`
|
|
177
|
+
// does: a modal can stay open for minutes, during which the screen may
|
|
178
|
+
// have moved on to another subject.
|
|
179
|
+
const state = mounted.screen?.store.read() ?? ctx.state;
|
|
180
|
+
const next = await applyChange(state, () => saveGroup(state.subject, group.key, prompt.values, prompt.interaction), translator.translate(locale, i18n_1.SETTINGS_EDITOR_MESSAGES.fieldSaved, {
|
|
181
|
+
field: translator.translate(locale, group.labelKey),
|
|
182
|
+
}));
|
|
183
|
+
mounted.screen?.store.write(next);
|
|
184
|
+
await prompt.interaction.update((0, interactive_message_1.toMessageEditOptions)(view.render(next), [...prompt.interaction.message.attachments.values()], next));
|
|
185
|
+
}
|
|
186
|
+
const buttons = (0, settings_editor_view_1.createEditorButtons)(ids, translator, locale, {
|
|
187
|
+
// Nothing is written here. Clearing an override that names an uploaded
|
|
188
|
+
// image destroys the bytes with it, so the click that asks and the click
|
|
189
|
+
// that carries it out are deliberately two different ones.
|
|
190
|
+
onReset: (clickCtx) => clickCtx.update({ ...clickCtx.state, confirming: settings_editor_view_1.SETTINGS_EDITOR_RESET_CONFIRMING }),
|
|
191
|
+
onConfirmReset: async (clickCtx) => {
|
|
192
|
+
const next = await applyChange(clickCtx.state, () => options.reset(clickCtx.state.subject), translator.translate(locale, i18n_1.SETTINGS_EDITOR_MESSAGES.resetDone));
|
|
193
|
+
await clickCtx.update({ ...next, confirming: null });
|
|
194
|
+
},
|
|
195
|
+
onCancelReset: (clickCtx) => clickCtx.update({
|
|
196
|
+
...clickCtx.state,
|
|
197
|
+
notice: {
|
|
198
|
+
text: translator.translate(locale, i18n_1.SETTINGS_EDITOR_MESSAGES.resetCancelled),
|
|
199
|
+
tone: "confirmation",
|
|
200
|
+
},
|
|
201
|
+
confirming: null,
|
|
202
|
+
}),
|
|
203
|
+
onReturn: (clickCtx) => stepBack(clickCtx),
|
|
204
|
+
});
|
|
205
|
+
const dressing = {
|
|
206
|
+
clock: options.clock,
|
|
207
|
+
// Read from the client rather than asked of the caller: every screen wants
|
|
208
|
+
// the same avatar, and it is the one thing here nobody has to configure.
|
|
209
|
+
iconUrl: interaction.client.user?.displayAvatarURL() ?? null,
|
|
210
|
+
};
|
|
211
|
+
/**
|
|
212
|
+
* Whether `field` goes somewhere rather than editing anything — the same
|
|
213
|
+
* question `editField` itself answers for its own routing, asked here only
|
|
214
|
+
* to word its button: "Open" for a level, "Edit" for everything else.
|
|
215
|
+
*/
|
|
216
|
+
function isLevelField(field) {
|
|
217
|
+
return !(0, settings_editor_fields_1.isValueField)(field) && !(0, settings_editor_fields_1.isPickerField)(field) && !(0, settings_editor_fields_1.isGroupField)(field);
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Which layout the level owning `field` renders its entries with — the
|
|
221
|
+
* root's own fields are always `"sections"`, since the root has no picker
|
|
222
|
+
* above it for a `"buttons"` row to act on. Looked up once per field rather
|
|
223
|
+
* than threaded through as a parameter: `buildFieldButton` is called from
|
|
224
|
+
* one place, over every field up front, and this is what tells it apart
|
|
225
|
+
* from the level a field belongs to without that caller repeating the walk
|
|
226
|
+
* `createCardEditorView` already does over `options.levels`.
|
|
227
|
+
*/
|
|
228
|
+
const fieldEntryLayout = new Map();
|
|
229
|
+
// The root's own layout is the card chrome's `entryLayout` — the embeds
|
|
230
|
+
// layout never reads this map at all, so a screen without a card chrome
|
|
231
|
+
// simply leaves every root field labelled the default it is never asked for.
|
|
232
|
+
const rootEntryLayout = options.chrome.layout === "card" ? (options.chrome.entryLayout ?? "sections") : "sections";
|
|
233
|
+
for (const field of options.fields) {
|
|
234
|
+
fieldEntryLayout.set(field.key, rootEntryLayout);
|
|
235
|
+
}
|
|
236
|
+
for (const level of options.levels ?? []) {
|
|
237
|
+
const entryLayout = level.entryLayout ?? "sections";
|
|
238
|
+
for (const field of level.fields) {
|
|
239
|
+
fieldEntryLayout.set(field.key, entryLayout);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* The button a card layout's `Section` carries for one menu entry — what
|
|
244
|
+
* picking it from the old field select used to do, now reached by a click.
|
|
245
|
+
* Built for every field up front, whichever level declares it: a button not
|
|
246
|
+
* on the level currently shown is simply never rendered, exactly as
|
|
247
|
+
* `SettingsEditorButtons.returning` is carried whether or not the current
|
|
248
|
+
* state shows it.
|
|
249
|
+
*
|
|
250
|
+
* A level rendering its entries as a `"buttons"` row has no `Section` text
|
|
251
|
+
* to say what each one does, so its button carries the entry's own label —
|
|
252
|
+
* "Declare a game", "This game" — instead of the generic "Open"/"Edit" a
|
|
253
|
+
* `"sections"` level's accessory button wears.
|
|
254
|
+
*/
|
|
255
|
+
function buildFieldButton(field) {
|
|
256
|
+
const navigational = isLevelField(field);
|
|
257
|
+
const label = fieldEntryLayout.get(field.key) === "buttons"
|
|
258
|
+
? translator.translate(locale, field.labelKey)
|
|
259
|
+
: translator.translate(locale, navigational
|
|
260
|
+
? i18n_1.SETTINGS_EDITOR_MESSAGES.openLevelButton
|
|
261
|
+
: i18n_1.SETTINGS_EDITOR_MESSAGES.editFieldButton);
|
|
262
|
+
return (0, button_1.createButton)({
|
|
263
|
+
id: (0, settings_editor_card_view_1.fieldButtonId)(ids, field.key),
|
|
264
|
+
label,
|
|
265
|
+
// The entry's own icon wins when it declares one — the generic one lies
|
|
266
|
+
// for an entry that opens a modal to create something rather than edit
|
|
267
|
+
// what is already there. Left undeclared, this is exactly the generic
|
|
268
|
+
// this repository always rendered.
|
|
269
|
+
emoji: field.icon ?? (navigational ? "➡️" : "✏️"),
|
|
270
|
+
style: "secondary",
|
|
271
|
+
// Frozen along with the rest of the screen while the editor's own reset is
|
|
272
|
+
// waiting for its second click. A screen's own accessory button — a
|
|
273
|
+
// game's own "remove" — gates itself on whatever *it* is waiting to have
|
|
274
|
+
// confirmed instead; this one only ever means the editor's.
|
|
275
|
+
disabled: (state) => state.confirming === settings_editor_view_1.SETTINGS_EDITOR_RESET_CONFIRMING,
|
|
276
|
+
onClick: (clickCtx) => editField(clickCtx, field.key),
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
// The card layout replaces the field select with one button per entry,
|
|
280
|
+
// looked up by the very key `editField` already routes on; the embeds
|
|
281
|
+
// layout keeps the select, and never builds a button nothing would render.
|
|
282
|
+
const fieldButtons = [];
|
|
283
|
+
const selects = [...(options.selects ?? [])];
|
|
284
|
+
let view;
|
|
285
|
+
if (options.chrome.layout === "card") {
|
|
286
|
+
const fieldButtonMap = new Map(allFields.map((field) => [field.key, buildFieldButton(field)]));
|
|
287
|
+
fieldButtons.push(...fieldButtonMap.values());
|
|
288
|
+
view = (0, settings_editor_card_view_1.createCardEditorView)(options.fields, options.levels, buttons, fieldButtonMap, options.chrome, translator, locale, dressing);
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
view = (0, settings_editor_view_1.createEditorView)(ids, options.fields, options.levels, buttons, options.chrome, translator, locale, dressing,
|
|
292
|
+
// Whether *any* group on this screen might open on a legend: `groupLegend`
|
|
293
|
+
// is one hook for the whole screen, not declared per group, so every group
|
|
294
|
+
// here reserves the one component a legend would cost rather than risk a
|
|
295
|
+
// modal that only overflows for the one group that actually gets one.
|
|
296
|
+
options.groupLegend !== undefined);
|
|
297
|
+
selects.unshift({
|
|
298
|
+
id: ids.field,
|
|
299
|
+
onSelect: (pickCtx) => {
|
|
300
|
+
const picked = pickCtx.values[0];
|
|
301
|
+
return picked === undefined ? undefined : editField(pickCtx, picked);
|
|
302
|
+
},
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
mountedView.view = view;
|
|
306
|
+
// The screen's own after the editor's, so a caller cannot shadow a control
|
|
307
|
+
// the editor depends on: `mountInteractiveMessage` routes to the first match.
|
|
308
|
+
const allButtons = [...buttons.all, ...fieldButtons, ...(options.buttons ?? [])];
|
|
309
|
+
mounted.screen = await (0, interactive_message_1.mountInteractiveMessage)(interaction, {
|
|
310
|
+
initialState: {
|
|
311
|
+
subject: options.initial.subject,
|
|
312
|
+
assets: options.initial.assets,
|
|
313
|
+
notice: null,
|
|
314
|
+
confirming: null,
|
|
315
|
+
path: [navigation_1.ROOT_LEVEL_KEY],
|
|
316
|
+
},
|
|
317
|
+
buttons: allButtons,
|
|
318
|
+
selects,
|
|
319
|
+
view,
|
|
320
|
+
ownerId: interaction.user.id,
|
|
321
|
+
logger: options.logger,
|
|
322
|
+
});
|
|
323
|
+
return mounted.screen;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Which notice a submission earns, in the vocabulary its field's own kind
|
|
327
|
+
* understands: an upload always says so; a picker field reads its clear from
|
|
328
|
+
* `submission.ids` being `null`, a value field from `submission.value` being
|
|
329
|
+
* `null` — the two never mean the same thing on the other kind of field.
|
|
330
|
+
*/
|
|
331
|
+
function fieldNoticeKey(field, submission) {
|
|
332
|
+
if (submission.upload !== null) {
|
|
333
|
+
return i18n_1.SETTINGS_EDITOR_MESSAGES.fieldUploaded;
|
|
334
|
+
}
|
|
335
|
+
if ((0, settings_editor_fields_1.isPickerField)(field)) {
|
|
336
|
+
return submission.ids === null
|
|
337
|
+
? i18n_1.SETTINGS_EDITOR_MESSAGES.fieldCleared
|
|
338
|
+
: i18n_1.SETTINGS_EDITOR_MESSAGES.fieldSaved;
|
|
339
|
+
}
|
|
340
|
+
return submission.value === null
|
|
341
|
+
? i18n_1.SETTINGS_EDITOR_MESSAGES.fieldCleared
|
|
342
|
+
: i18n_1.SETTINGS_EDITOR_MESSAGES.fieldSaved;
|
|
343
|
+
}
|
|
344
|
+
//# sourceMappingURL=mount-settings-editor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount-settings-editor.js","sourceRoot":"","sources":["../../../../src/discord/components/settings-editor/mount-settings-editor.ts"],"names":[],"mappings":";;AAuOA,kDAuYC;AAxmBD,kFAOkD;AAClD,gFAKyD;AACzD,oGAOmE;AACnE,8GAGwE;AAKxE,kHAG0E;AAC1E,wGASqE;AACrE,yCAA0D;AAC1D,yDAAgG;AAChG,qCAAwD;AACxD,iCAA8E;AAqK9E;;;;;;;;;;;;GAYG;AACI,KAAK,UAAU,mBAAmB,CACxC,WAAwC,EACxC,OAAuC;IAEvC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IACvC,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CA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or-fields";
|
|
2
|
+
/**
|
|
3
|
+
* The level every screen opens on. Its fields are the ones handed to the editor
|
|
4
|
+
* directly, so a screen with no depth at all never names a level.
|
|
5
|
+
*/
|
|
6
|
+
export declare const ROOT_LEVEL_KEY = "root";
|
|
7
|
+
/**
|
|
8
|
+
* One level of a screen: the settings it offers and what it is called.
|
|
9
|
+
*
|
|
10
|
+
* A screen declares its deeper levels the same way it declares its fields — as
|
|
11
|
+
* pure data — so the menu, the heading and the return control are all built from
|
|
12
|
+
* one source rather than three that have to agree.
|
|
13
|
+
*/
|
|
14
|
+
export interface SettingsEditorLevel<F extends string> {
|
|
15
|
+
/** Identifies the level. A field of kind `level` names one to descend into. */
|
|
16
|
+
readonly key: string;
|
|
17
|
+
/** What this level is called, shown in the heading so the reader knows where they are. */
|
|
18
|
+
readonly titleKey: string;
|
|
19
|
+
readonly fields: readonly SettingsEditorField<F>[];
|
|
20
|
+
/**
|
|
21
|
+
* How this level offers its entries. `"sections"`, the default, gives each
|
|
22
|
+
* its own row with its hint and button; `"buttons"` folds them into a
|
|
23
|
+
* single row, for a level whose entries act on what the picker above has
|
|
24
|
+
* already named and whose hint would only repeat the row.
|
|
25
|
+
*/
|
|
26
|
+
readonly entryLayout?: "sections" | "buttons";
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Where the screen currently is, outermost first.
|
|
30
|
+
*
|
|
31
|
+
* Never empty: the root is always its first entry, which is what makes
|
|
32
|
+
* "is there anywhere to go back to" a length check rather than a special case.
|
|
33
|
+
*/
|
|
34
|
+
export type SettingsEditorPath = readonly string[];
|
|
35
|
+
/** The level being rendered — the last one entered. */
|
|
36
|
+
export declare function currentLevelKey(path: SettingsEditorPath): string;
|
|
37
|
+
/** Whether there is a level above the current one to return to. */
|
|
38
|
+
export declare function canReturn(path: SettingsEditorPath): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Descend into `key`.
|
|
41
|
+
*
|
|
42
|
+
* Re-entering a level already on the path unwinds to it rather than stacking a
|
|
43
|
+
* second copy: a screen that let the same level appear twice would need two
|
|
44
|
+
* clicks of the return control to leave one place.
|
|
45
|
+
*/
|
|
46
|
+
export declare function pushLevel(path: SettingsEditorPath, key: string): SettingsEditorPath;
|
|
47
|
+
/** Go back one level. At the root there is nothing to pop, so the path stands. */
|
|
48
|
+
export declare function popLevel(path: SettingsEditorPath): SettingsEditorPath;
|
|
49
|
+
//# sourceMappingURL=navigation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../../../src/discord/components/settings-editor/navigation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6DAA6D,CAAC;AAEvG;;;GAGG;AACH,eAAO,MAAM,cAAc,SAAS,CAAC;AAErC;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,MAAM;IACpD,+EAA+E;IAC/E,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,0FAA0F;IAC1F,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,SAAS,mBAAmB,CAAC,CAAC,CAAC,EAAE,CAAC;IACnD;;;;;OAKG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;CAC9C;AAED;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,SAAS,MAAM,EAAE,CAAC;AAEnD,uDAAuD;AACvD,wBAAgB,eAAe,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM,CAEhE;AAED,mEAAmE;AACnE,wBAAgB,SAAS,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAE3D;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,kBAAkB,EAAE,GAAG,EAAE,MAAM,GAAG,kBAAkB,CAMnF;AAED,kFAAkF;AAClF,wBAAgB,QAAQ,CAAC,IAAI,EAAE,kBAAkB,GAAG,kBAAkB,CAErE"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ROOT_LEVEL_KEY = void 0;
|
|
4
|
+
exports.currentLevelKey = currentLevelKey;
|
|
5
|
+
exports.canReturn = canReturn;
|
|
6
|
+
exports.pushLevel = pushLevel;
|
|
7
|
+
exports.popLevel = popLevel;
|
|
8
|
+
/**
|
|
9
|
+
* The level every screen opens on. Its fields are the ones handed to the editor
|
|
10
|
+
* directly, so a screen with no depth at all never names a level.
|
|
11
|
+
*/
|
|
12
|
+
exports.ROOT_LEVEL_KEY = "root";
|
|
13
|
+
/** The level being rendered — the last one entered. */
|
|
14
|
+
function currentLevelKey(path) {
|
|
15
|
+
return path[path.length - 1] ?? exports.ROOT_LEVEL_KEY;
|
|
16
|
+
}
|
|
17
|
+
/** Whether there is a level above the current one to return to. */
|
|
18
|
+
function canReturn(path) {
|
|
19
|
+
return path.length > 1;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Descend into `key`.
|
|
23
|
+
*
|
|
24
|
+
* Re-entering a level already on the path unwinds to it rather than stacking a
|
|
25
|
+
* second copy: a screen that let the same level appear twice would need two
|
|
26
|
+
* clicks of the return control to leave one place.
|
|
27
|
+
*/
|
|
28
|
+
function pushLevel(path, key) {
|
|
29
|
+
const existing = path.indexOf(key);
|
|
30
|
+
if (existing !== -1) {
|
|
31
|
+
return path.slice(0, existing + 1);
|
|
32
|
+
}
|
|
33
|
+
return [...path, key];
|
|
34
|
+
}
|
|
35
|
+
/** Go back one level. At the root there is nothing to pop, so the path stands. */
|
|
36
|
+
function popLevel(path) {
|
|
37
|
+
return canReturn(path) ? path.slice(0, -1) : path;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=navigation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigation.js","sourceRoot":"","sources":["../../../../src/discord/components/settings-editor/navigation.ts"],"names":[],"mappings":";;;AAuCA,0CAEC;AAGD,8BAEC;AASD,8BAMC;AAGD,4BAEC;AAhED;;;GAGG;AACU,QAAA,cAAc,GAAG,MAAM,CAAC;AAgCrC,uDAAuD;AACvD,SAAgB,eAAe,CAAC,IAAwB;IACvD,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,sBAAc,CAAC;AAChD,CAAC;AAED,mEAAmE;AACnE,SAAgB,SAAS,CAAC,IAAwB;IACjD,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;AACxB,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,SAAS,CAAC,IAAwB,EAAE,GAAW;IAC9D,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACnC,IAAI,QAAQ,KAAK,CAAC,CAAC,EAAE,CAAC;QACrB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,GAAG,CAAC,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,CAAC;AACvB,CAAC;AAED,kFAAkF;AAClF,SAAgB,QAAQ,CAAC,IAAwB;IAChD,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { InteractiveView } from "../../../discord/components/interactive-message";
|
|
2
|
+
import { type SettingsEditorLevel } from "../../../discord/components/settings-editor/navigation";
|
|
3
|
+
import { type SettingsEditorButtons, type SettingsEditorCardChrome, type SettingsEditorDressing, type SettingsEditorIds, type SettingsEditorState } from "../../../discord/components/settings-editor/settings-editor.view";
|
|
4
|
+
import type { SettingsEditorField } from "../../../discord/components/settings-editor/settings-editor-fields";
|
|
5
|
+
import { type Button } from "../../../discord/interaction/button";
|
|
6
|
+
import type { Locale, Translator } from "../../../i18n";
|
|
7
|
+
/**
|
|
8
|
+
* Discord refuses a card carrying more than {@link import("../../../discord/ui/card").MAX_CARD_COMPONENTS}
|
|
9
|
+
* components; every menu entry a level declares becomes a `Section` — its
|
|
10
|
+
* text plus a button accessory, three components — so this is what a level's
|
|
11
|
+
* own field list may not exceed *before* the chrome fixed around it
|
|
12
|
+
* (breadcrumb, preview, extra blocks, separators, the bottom controls, the
|
|
13
|
+
* signature) is even counted. Generous rather than exact: the fixed chrome
|
|
14
|
+
* costs roughly a dozen components on its own, and no level this repository
|
|
15
|
+
* declares comes within three of this cap.
|
|
16
|
+
*/
|
|
17
|
+
export declare const MAX_CARD_LEVEL_ENTRIES = 10;
|
|
18
|
+
/**
|
|
19
|
+
* How many entries a level declaring `entryLayout: "buttons"` may carry
|
|
20
|
+
* before the rows they compile to — one `ActionRow` per five, however many
|
|
21
|
+
* that takes — would overrun what a container can actually hold.
|
|
22
|
+
*
|
|
23
|
+
* Sits higher than {@link MAX_CARD_LEVEL_ENTRIES} on purpose: a `"buttons"`
|
|
24
|
+
* row costs its `ActionRow` plus the buttons in it, cheaper per entry than a
|
|
25
|
+
* `"sections"` level's `Section` (text, accessory, the `Section` itself —
|
|
26
|
+
* three components apiece). Generous rather than exact, for the same reason
|
|
27
|
+
* {@link MAX_CARD_LEVEL_ENTRIES} is: the fixed chrome (breadcrumb, preview,
|
|
28
|
+
* separators, the bottom controls, the signature) costs roughly a dozen
|
|
29
|
+
* components on its own, and no level this repository declares comes within
|
|
30
|
+
* half of this cap.
|
|
31
|
+
*/
|
|
32
|
+
export declare const MAX_CARD_BUTTON_LEVEL_ENTRIES = 20;
|
|
33
|
+
/**
|
|
34
|
+
* The button a menu entry's own `Section` carries, derived from the field's
|
|
35
|
+
* key rather than declared alongside it — the same relationship `ids.field`
|
|
36
|
+
* already has to the select it used to name, one level of indirection lower.
|
|
37
|
+
*/
|
|
38
|
+
export declare function fieldButtonId(ids: SettingsEditorIds, key: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* The card editor screen: one Components V2 card carrying the breadcrumb, the
|
|
41
|
+
* last notice, whatever the screen adds above the preview, the preview
|
|
42
|
+
* itself, a `Section` per entry of the current level — each with the button
|
|
43
|
+
* `fieldButtonId` names — and the bottom controls, closing with the bot's own
|
|
44
|
+
* signature.
|
|
45
|
+
*
|
|
46
|
+
* The counterpart of `createEditorView` for a screen declaring
|
|
47
|
+
* `chrome.layout === "card"`; the two never mix; {@link mountSettingsEditor}
|
|
48
|
+
* picks whichever this screen's chrome names.
|
|
49
|
+
*
|
|
50
|
+
* Takes no `SettingsEditorIds` of its own, unlike `createEditorView`: every
|
|
51
|
+
* button it renders — reset, back, and one per menu entry — already exists,
|
|
52
|
+
* built by `mountSettingsEditor` against those very ids, so nothing here has
|
|
53
|
+
* to name them again.
|
|
54
|
+
*/
|
|
55
|
+
export declare function createCardEditorView<S, A, F extends string>(fields: readonly SettingsEditorField<F>[], levels: readonly SettingsEditorLevel<F>[] | undefined, buttons: SettingsEditorButtons<S, A>, fieldButtons: ReadonlyMap<string, Button<SettingsEditorState<S, A>>>, chrome: SettingsEditorCardChrome<S, A>, translator: Translator, locale: Locale, dressing: SettingsEditorDressing): InteractiveView<SettingsEditorState<S, A>>;
|
|
56
|
+
//# sourceMappingURL=settings-editor-card.view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings-editor-card.view.d.ts","sourceRoot":"","sources":["../../../../src/discord/components/settings-editor/settings-editor-card.view.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAIN,KAAK,mBAAmB,EACxB,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAGN,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EAEtB,KAA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