/** * Settings Store for FlowDrop (Svelte 5 Runes) * * Provides unified state management for all user-configurable settings with: * - Hybrid persistence (localStorage primary, optional API sync) * - Category-specific getter functions for performance * - Deep merge support for partial updates * - Integrated theme system with system preference detection * * @module stores/settingsStore */ import type { FlowDropSettings, ThemeSettings, EditorSettings, UISettings, BehaviorSettings, ApiSettings, PartialSettings, SyncStatus, ResolvedTheme, ThemePreference, SettingsChangeCallback, SettingsCategory } from '../types/settings.js'; export type { ThemePreference, ResolvedTheme } from '../types/settings.js'; /** * Get current settings (replaces settingsStore derived store) */ export declare function getSettings(): FlowDropSettings; /** * Get sync status (replaces syncStatusStore derived store) */ export declare function getSyncStatus(): { status: SyncStatus; lastSyncedAt: number | null; error: string | null; }; /** * Get theme settings (replaces themeSettings derived store) */ export declare function getThemeSettings(): ThemeSettings; /** * Get editor settings (replaces editorSettings derived store) */ export declare function getEditorSettings(): EditorSettings; /** * Get UI settings (replaces uiSettings derived store) */ export declare function getUiSettings(): UISettings; /** * Get behavior settings (replaces behaviorSettings derived store) */ export declare function getBehaviorSettings(): BehaviorSettings; /** * Get API settings (replaces apiSettings derived store) */ export declare function getApiSettings(): ApiSettings; /** * Get theme preference (replaces theme derived store) */ export declare function getTheme(): ThemePreference; /** * Get resolved theme - the actual theme applied ('light' or 'dark') * When preference is 'auto', resolves based on system preference * (replaces resolvedTheme derived store) */ export declare function getResolvedTheme(): ResolvedTheme; /** * Get system theme state (for internal use) */ export declare function getSystemThemeState(): ResolvedTheme; /** * Initialize the system theme change listener. * Sets up a media query listener for the system color scheme preference. * * @returns Cleanup function that removes the listener */ export declare function initThemeListener(): () => void; /** * Update settings with partial values * * @param partial - Partial settings to merge */ export declare function updateSettings(partial: PartialSettings): void; /** * Reset settings to defaults * * @param categories - Optional categories to reset (all if not specified) */ export declare function resetSettings(categories?: SettingsCategory[]): void; /** * Set the theme preference * * @param newTheme - The new theme preference ('light', 'dark', or 'auto') */ export declare function setTheme(newTheme: ThemePreference): void; /** * Toggle between light and dark themes * If currently 'auto', switches to the opposite of system preference */ export declare function toggleTheme(): void; /** * Cycle through theme options: light -> dark -> auto -> light */ export declare function cycleTheme(): void; /** * Clean up the theme subscription created by initializeTheme(). * Call this when tearing down the settings system (e.g., in tests or * component cleanup) to prevent memory leaks. */ export declare function cleanupThemeSubscription(): void; /** * Initialize the theme system * Should be called once on app startup * * This function: * 1. Applies the current resolved theme to the document * 2. Sets up reactivity to apply theme changes * * Note: In Svelte 5, we use $effect for reactivity. Since $effect can only * be used in component context or $effect.root, we use $effect.root here * to create a standalone reactive scope. */ export declare function initializeTheme(): void; /** * Check if theme system is initialized * Useful for SSR scenarios * * @returns true if running in browser and theme is applied */ export declare function isThemeInitialized(): boolean; /** * Set the settings service for API operations * * @param service - Settings service instance */ export declare function setSettingsService(service: { savePreferences: (settings: FlowDropSettings) => Promise; getPreferences: () => Promise; } | null): void; /** * Sync current settings to the backend API * * @returns Promise that resolves when sync is complete */ export declare function syncSettingsToApi(): Promise; /** * Load settings from the backend API * * @returns Promise that resolves when load is complete */ export declare function loadSettingsFromApi(): Promise; /** * Subscribe to settings changes * * @param callback - Function to call when settings change * @returns Unsubscribe function */ export declare function onSettingsChange(callback: SettingsChangeCallback): () => void; /** * Initialize the settings system * * @param options - Initialization options */ export declare function initializeSettings(options?: { /** Custom default settings to merge */ defaults?: PartialSettings; /** Enable API sync on initialization */ apiSync?: boolean; }): Promise;