|
| 1 | +import type { PluginConfig } from "../types.js"; |
| 2 | +import type { |
| 3 | + BackendCategoryOption, |
| 4 | + BackendNumberSettingKey, |
| 5 | + BackendNumberSettingOption, |
| 6 | + BackendSettingFocusKey, |
| 7 | + BackendToggleSettingKey, |
| 8 | + BackendToggleSettingOption, |
| 9 | +} from "./backend-settings-schema.js"; |
| 10 | + |
| 11 | +export async function promptBackendCategorySettingsEntry(params: { |
| 12 | + initial: PluginConfig; |
| 13 | + category: BackendCategoryOption; |
| 14 | + initialFocus: BackendSettingFocusKey; |
| 15 | + promptBackendCategorySettingsMenu: (args: { |
| 16 | + initial: PluginConfig; |
| 17 | + category: BackendCategoryOption; |
| 18 | + initialFocus: BackendSettingFocusKey; |
| 19 | + ui: ReturnType<typeof import("../ui/runtime.js").getUiRuntimeOptions>; |
| 20 | + cloneBackendPluginConfig: (config: PluginConfig) => PluginConfig; |
| 21 | + buildBackendSettingsPreview: ( |
| 22 | + config: PluginConfig, |
| 23 | + ui: ReturnType<typeof import("../ui/runtime.js").getUiRuntimeOptions>, |
| 24 | + focusKey: BackendSettingFocusKey, |
| 25 | + deps: { |
| 26 | + highlightPreviewToken: ( |
| 27 | + text: string, |
| 28 | + ui: ReturnType<typeof import("../ui/runtime.js").getUiRuntimeOptions>, |
| 29 | + ) => string; |
| 30 | + }, |
| 31 | + ) => { label: string; hint: string }; |
| 32 | + highlightPreviewToken: ( |
| 33 | + text: string, |
| 34 | + ui: ReturnType<typeof import("../ui/runtime.js").getUiRuntimeOptions>, |
| 35 | + ) => string; |
| 36 | + resolveFocusedBackendNumberKey: ( |
| 37 | + focus: BackendSettingFocusKey, |
| 38 | + numberOptions: BackendNumberSettingOption[], |
| 39 | + ) => BackendNumberSettingKey; |
| 40 | + clampBackendNumber: ( |
| 41 | + option: BackendNumberSettingOption, |
| 42 | + value: number, |
| 43 | + ) => number; |
| 44 | + formatBackendNumberValue: ( |
| 45 | + option: BackendNumberSettingOption, |
| 46 | + value: number, |
| 47 | + ) => string; |
| 48 | + formatDashboardSettingState: (enabled: boolean) => string; |
| 49 | + applyBackendCategoryDefaults: ( |
| 50 | + config: PluginConfig, |
| 51 | + selectedCategory: BackendCategoryOption, |
| 52 | + ) => PluginConfig; |
| 53 | + getBackendCategoryInitialFocus: ( |
| 54 | + category: BackendCategoryOption, |
| 55 | + ) => BackendSettingFocusKey; |
| 56 | + backendDefaults: PluginConfig; |
| 57 | + toggleOptionByKey: ReadonlyMap< |
| 58 | + BackendToggleSettingKey, |
| 59 | + BackendToggleSettingOption |
| 60 | + >; |
| 61 | + numberOptionByKey: ReadonlyMap< |
| 62 | + BackendNumberSettingKey, |
| 63 | + BackendNumberSettingOption |
| 64 | + >; |
| 65 | + select: <T>( |
| 66 | + items: import("../ui/select.js").MenuItem<T>[], |
| 67 | + options: { |
| 68 | + message: string; |
| 69 | + subtitle: string; |
| 70 | + help: string; |
| 71 | + clearScreen: boolean; |
| 72 | + theme: ReturnType< |
| 73 | + typeof import("../ui/runtime.js").getUiRuntimeOptions |
| 74 | + >["theme"]; |
| 75 | + selectedEmphasis: "minimal"; |
| 76 | + initialCursor?: number; |
| 77 | + onCursorChange: (event: { cursor: number }) => void; |
| 78 | + onInput: (raw: string) => T | undefined; |
| 79 | + }, |
| 80 | + ) => Promise<T | null>; |
| 81 | + copy: { |
| 82 | + previewHeading: string; |
| 83 | + backendToggleHeading: string; |
| 84 | + backendNumberHeading: string; |
| 85 | + backendDecrease: string; |
| 86 | + backendIncrease: string; |
| 87 | + backendResetCategory: string; |
| 88 | + backendBackToCategories: string; |
| 89 | + backendCategoryTitle: string; |
| 90 | + backendCategoryHelp: string; |
| 91 | + }; |
| 92 | + }) => Promise<{ draft: PluginConfig; focusKey: BackendSettingFocusKey }>; |
| 93 | + ui: ReturnType<typeof import("../ui/runtime.js").getUiRuntimeOptions>; |
| 94 | + cloneBackendPluginConfig: (config: PluginConfig) => PluginConfig; |
| 95 | + buildBackendSettingsPreview: ( |
| 96 | + config: PluginConfig, |
| 97 | + ui: ReturnType<typeof import("../ui/runtime.js").getUiRuntimeOptions>, |
| 98 | + focusKey: BackendSettingFocusKey, |
| 99 | + deps: { |
| 100 | + highlightPreviewToken: ( |
| 101 | + text: string, |
| 102 | + ui: ReturnType<typeof import("../ui/runtime.js").getUiRuntimeOptions>, |
| 103 | + ) => string; |
| 104 | + }, |
| 105 | + ) => { label: string; hint: string }; |
| 106 | + highlightPreviewToken: ( |
| 107 | + text: string, |
| 108 | + ui: ReturnType<typeof import("../ui/runtime.js").getUiRuntimeOptions>, |
| 109 | + ) => string; |
| 110 | + resolveFocusedBackendNumberKey: ( |
| 111 | + focus: BackendSettingFocusKey, |
| 112 | + numberOptions: BackendNumberSettingOption[], |
| 113 | + ) => BackendNumberSettingKey; |
| 114 | + clampBackendNumber: ( |
| 115 | + option: BackendNumberSettingOption, |
| 116 | + value: number, |
| 117 | + ) => number; |
| 118 | + formatBackendNumberValue: ( |
| 119 | + option: BackendNumberSettingOption, |
| 120 | + value: number, |
| 121 | + ) => string; |
| 122 | + formatDashboardSettingState: (enabled: boolean) => string; |
| 123 | + applyBackendCategoryDefaults: ( |
| 124 | + config: PluginConfig, |
| 125 | + selectedCategory: BackendCategoryOption, |
| 126 | + ) => PluginConfig; |
| 127 | + getBackendCategoryInitialFocus: ( |
| 128 | + category: BackendCategoryOption, |
| 129 | + ) => BackendSettingFocusKey; |
| 130 | + backendDefaults: PluginConfig; |
| 131 | + toggleOptionByKey: ReadonlyMap< |
| 132 | + BackendToggleSettingKey, |
| 133 | + BackendToggleSettingOption |
| 134 | + >; |
| 135 | + numberOptionByKey: ReadonlyMap< |
| 136 | + BackendNumberSettingKey, |
| 137 | + BackendNumberSettingOption |
| 138 | + >; |
| 139 | + select: <T>( |
| 140 | + items: import("../ui/select.js").MenuItem<T>[], |
| 141 | + options: { |
| 142 | + message: string; |
| 143 | + subtitle: string; |
| 144 | + help: string; |
| 145 | + clearScreen: boolean; |
| 146 | + theme: ReturnType< |
| 147 | + typeof import("../ui/runtime.js").getUiRuntimeOptions |
| 148 | + >["theme"]; |
| 149 | + selectedEmphasis: "minimal"; |
| 150 | + initialCursor?: number; |
| 151 | + onCursorChange: (event: { cursor: number }) => void; |
| 152 | + onInput: (raw: string) => T | undefined; |
| 153 | + }, |
| 154 | + ) => Promise<T | null>; |
| 155 | + copy: { |
| 156 | + previewHeading: string; |
| 157 | + backendToggleHeading: string; |
| 158 | + backendNumberHeading: string; |
| 159 | + backendDecrease: string; |
| 160 | + backendIncrease: string; |
| 161 | + backendResetCategory: string; |
| 162 | + backendBackToCategories: string; |
| 163 | + backendCategoryTitle: string; |
| 164 | + backendCategoryHelp: string; |
| 165 | + }; |
| 166 | +}): Promise<{ draft: PluginConfig; focusKey: BackendSettingFocusKey }> { |
| 167 | + return params.promptBackendCategorySettingsMenu({ |
| 168 | + initial: params.initial, |
| 169 | + category: params.category, |
| 170 | + initialFocus: params.initialFocus, |
| 171 | + ui: params.ui, |
| 172 | + cloneBackendPluginConfig: params.cloneBackendPluginConfig, |
| 173 | + buildBackendSettingsPreview: params.buildBackendSettingsPreview, |
| 174 | + highlightPreviewToken: params.highlightPreviewToken, |
| 175 | + resolveFocusedBackendNumberKey: params.resolveFocusedBackendNumberKey, |
| 176 | + clampBackendNumber: params.clampBackendNumber, |
| 177 | + formatBackendNumberValue: params.formatBackendNumberValue, |
| 178 | + formatDashboardSettingState: params.formatDashboardSettingState, |
| 179 | + applyBackendCategoryDefaults: params.applyBackendCategoryDefaults, |
| 180 | + getBackendCategoryInitialFocus: params.getBackendCategoryInitialFocus, |
| 181 | + backendDefaults: params.backendDefaults, |
| 182 | + toggleOptionByKey: params.toggleOptionByKey, |
| 183 | + numberOptionByKey: params.numberOptionByKey, |
| 184 | + select: params.select, |
| 185 | + copy: params.copy, |
| 186 | + }); |
| 187 | +} |
0 commit comments