/** * useCommandHandlers Hook * * Constructs the CommandHandlers object that is passed to createBuiltinCommands(). * Extracted from App.tsx to reduce its size and keep handler logic co-located. */ import type { FeaturesConfig, PluginatorConfig } from '../../core/types/config.js'; import type { Plugin } from '../../core/types/index.js'; import { type CommandHandlers, type UICommand } from '../commands/index.js'; import type { Tab } from '../components/layout/Header.js'; import { type SetupWizardState } from '../components/wizard/wizard-types.js'; import type { OverlayContextValue, OverlayDataContextValue } from '../state/contexts/index.js'; import type { TabId } from '../state/index.js'; export type { CommandHandlers }; /** * Everything the command handlers need from App state. * All fields are required; make optional fields explicit with `| null` / `| undefined`. */ export interface UseCommandHandlersDeps { scanServers: () => void; handleCheckUpdates: () => void; handleQuickSync: () => void; handleQuickMigrate: () => void; handleQuickBackup: () => void; handleDownloadServer: () => void; handleAutoUpdate: () => void; handleUninstall: () => void; setActiveTab: (index: number) => void; visibleTabs: Tab[]; hiddenTabsSet: Set; goToTabById: (tabId: TabId) => void; overlays: OverlayContextValue; overlayData: Pick; setupWizardState: SetupWizardState | null; setSetupWizardState: (state: SetupWizardState | null) => void; addNotification: (type: 'info' | 'success' | 'warning' | 'error', message: string, options?: { duration?: number; dedupe?: boolean; }) => void; info: (message: string) => void; success: (message: string) => void; showError: (message: string) => void; setShowLoginDialog: (v: boolean) => void; setShowAccountView: (v: boolean) => void; doLogout: () => Promise; isAuthenticated: boolean; config: PluginatorConfig; featuresConfig: FeaturesConfig | null; setFeaturesConfig: (config: FeaturesConfig) => void; allPlugins: Plugin[]; plugins: { length: number; }; sources: { clearCache: () => void; }[]; activeTabId: string; updates: { length: number; }; uiStateContext: { state: unknown; }; tier: string | undefined | null; devMode: boolean; debugEnabled: boolean; keyboardFeatures: { isRecording: () => boolean; stopRecording: () => void; startRecording: (register: string) => boolean; playRegister: (register: string) => Promise; jumpBack: () => { view: string; } | null; jumpForward: () => { view: string; } | null; toggleAccessibility: () => void; state: { accessibilityEnabled: boolean; }; }; chordMode: { toggle: () => boolean; }; vimMode: { toggleVimMode: () => boolean; }; searchQuery: string; setSearchQuery: (q: string) => void; setShowFavoritesOnly: (fn: boolean | ((prev: boolean) => boolean)) => void; refreshPluginsFromCache: () => void; loadLogs: () => void; clearScreen: () => void; exit: () => void; devCommands: UICommand[]; } /** * Constructs a memoized CommandHandlers object from App state. * * The returned object is intentionally NOT re-created on every state change — * frequently-changing deps (plugins.length, updates.length, activeTabId, uiState, * isAuthenticated, keyboardFeatures callbacks, chordMode, vimMode, info, sources, * setupWizardState, etc.) are captured by closure but excluded from the dep array to * prevent costly regeneration of the full command list on every render. */ export declare function useCommandHandlers(deps: UseCommandHandlersDeps): CommandHandlers; /** * Build the full command list (builtin + snapshot + debug + devCommands). * * This is a thin wrapper that calls createBuiltinCommands with the memoized handlers * and then appends dev-mode-only command arrays (snapshot, debug, extra devCommands). * The snapshot and debug command arrays are defined inline so they have closure access * to setResultDialog / setSnapshotSelectDialog / addNotification from deps. * * Returns the final UICommand[] array ready to be passed to the command palette. */ export declare function useCommandList(handlers: CommandHandlers, deps: Pick): UICommand[]; //# sourceMappingURL=useCommandHandlers.d.ts.map