chore(cleanup): remove dead code and emojis from GUI
- commit
- cf05071a6207e8a1ccc4f1048b3f1cb5aada505e
- author
- bnema · · 2025-11-15 10:29 UTC
- parent
- 89e5e22
- signature
- unsigned
4 files · +1 -312
D gui/src/injected/modules/appearance-config.ts +0 -133
| @@ -1,133 +0,0 @@ | |||
| 1 | - | /** | |
| 2 | - | * Appearance Configuration Module | |
| 3 | - | * | |
| 4 | - | * Handles application appearance configuration including color palettes and fonts. | |
| 5 | - | * This config is injected by the native layer at startup and made available to all | |
| 6 | - | * injected modules and components. | |
| 7 | - | */ | |
| 8 | - | ||
| 9 | - | export interface ColorPalette { | |
| 10 | - | background: string; | |
| 11 | - | surface: string; | |
| 12 | - | surfaceVariant: string; | |
| 13 | - | text: string; | |
| 14 | - | muted: string; | |
| 15 | - | accent: string; | |
| 16 | - | border: string; | |
| 17 | - | } | |
| 18 | - | ||
| 19 | - | export interface AppearanceConfig { | |
| 20 | - | theme: "light" | "dark"; | |
| 21 | - | palettes: { | |
| 22 | - | light: ColorPalette; | |
| 23 | - | dark: ColorPalette; | |
| 24 | - | }; | |
| 25 | - | fonts: { | |
| 26 | - | sans: string; | |
| 27 | - | serif: string; | |
| 28 | - | monospace: string; | |
| 29 | - | defaultSize: number; | |
| 30 | - | }; | |
| 31 | - | } | |
| 32 | - | ||
| 33 | - | declare global { | |
| 34 | - | interface Window { | |
| 35 | - | __dumber_appearance_config?: AppearanceConfig; | |
| 36 | - | __dumber_applyPalette?: (theme: "light" | "dark") => void; | |
| 37 | - | } | |
| 38 | - | } | |
| 39 | - | ||
| 40 | - | /** | |
| 41 | - | * Applies the appearance configuration to the document | |
| 42 | - | * Sets CSS custom properties for colors and fonts | |
| 43 | - | */ | |
| 44 | - | export function applyAppearanceConfig(): void { | |
| 45 | - | const config = window.__dumber_appearance_config; | |
| 46 | - | if (!config) { | |
| 47 | - | console.warn("[dumber] Appearance config not available"); | |
| 48 | - | return; | |
| 49 | - | } | |
| 50 | - | ||
| 51 | - | const theme = config.theme || "light"; | |
| 52 | - | const palette = config.palettes[theme]; | |
| 53 | - | const root = document.documentElement; | |
| 54 | - | ||
| 55 | - | // Apply color palette as CSS custom properties | |
| 56 | - | root.style.setProperty("--color-background", palette.background); | |
| 57 | - | root.style.setProperty("--color-surface", palette.surface); | |
| 58 | - | root.style.setProperty("--color-surface-variant", palette.surfaceVariant); | |
| 59 | - | root.style.setProperty("--color-text", palette.text); | |
| 60 | - | root.style.setProperty("--color-muted", palette.muted); | |
| 61 | - | root.style.setProperty("--color-accent", palette.accent); | |
| 62 | - | root.style.setProperty("--color-border", palette.border); | |
| 63 | - | ||
| 64 | - | // Apply font families | |
| 65 | - | root.style.setProperty("--font-sans", config.fonts.sans); | |
| 66 | - | root.style.setProperty("--font-serif", config.fonts.serif); | |
| 67 | - | root.style.setProperty("--font-mono", config.fonts.monospace); | |
| 68 | - | ||
| 69 | - | console.log(`[dumber] Applied ${theme} appearance config`); | |
| 70 | - | ||
| 71 | - | // Dispatch event for components that need to react to appearance changes | |
| 72 | - | document.dispatchEvent( | |
| 73 | - | new CustomEvent("dumber:appearance-applied", { | |
| 74 | - | detail: { theme, palette, fonts: config.fonts }, | |
| 75 | - | }), | |
| 76 | - | ); | |
| 77 | - | } | |
| 78 | - | ||
| 79 | - | /** | |
| 80 | - | * Gets the current theme from appearance config | |
| 81 | - | */ | |
| 82 | - | export function getCurrentTheme(): "light" | "dark" { | |
| 83 | - | return window.__dumber_appearance_config?.theme || "light"; | |
| 84 | - | } | |
| 85 | - | ||
| 86 | - | /** | |
| 87 | - | * Gets the current color palette for the active theme | |
| 88 | - | */ | |
| 89 | - | export function getCurrentPalette(): ColorPalette | null { | |
| 90 | - | const config = window.__dumber_appearance_config; | |
| 91 | - | if (!config) return null; | |
| 92 | - | ||
| 93 | - | return config.palettes[config.theme]; | |
| 94 | - | } | |
| 95 | - | ||
| 96 | - | /** | |
| 97 | - | * Expose palette application function globally for integration with color-scheme module | |
| 98 | - | */ | |
| 99 | - | window.__dumber_applyPalette = (theme: "light" | "dark") => { | |
| 100 | - | const config = window.__dumber_appearance_config; | |
| 101 | - | if (!config) return; | |
| 102 | - | ||
| 103 | - | const palette = config.palettes[theme]; | |
| 104 | - | const root = document.documentElement; | |
| 105 | - | ||
| 106 | - | root.style.setProperty("--color-background", palette.background); | |
| 107 | - | root.style.setProperty("--color-surface", palette.surface); | |
| 108 | - | root.style.setProperty("--color-surface-variant", palette.surfaceVariant); | |
| 109 | - | root.style.setProperty("--color-text", palette.text); | |
| 110 | - | root.style.setProperty("--color-muted", palette.muted); | |
| 111 | - | root.style.setProperty("--color-accent", palette.accent); | |
| 112 | - | root.style.setProperty("--color-border", palette.border); | |
| 113 | - | ||
| 114 | - | console.log(`[dumber] Switched to ${theme} palette`); | |
| 115 | - | }; | |
| 116 | - | ||
| 117 | - | // Auto-initialize if config is already available | |
| 118 | - | if (window.__dumber_appearance_config) { | |
| 119 | - | applyAppearanceConfig(); | |
| 120 | - | } | |
| 121 | - | ||
| 122 | - | // Listen for config injection and apply | |
| 123 | - | document.addEventListener("DOMContentLoaded", () => { | |
| 124 | - | if (window.__dumber_appearance_config) { | |
| 125 | - | applyAppearanceConfig(); | |
| 126 | - | } | |
| 127 | - | }); | |
| 128 | - | ||
| 129 | - | export default { | |
| 130 | - | applyAppearanceConfig, | |
| 131 | - | getCurrentTheme, | |
| 132 | - | getCurrentPalette, | |
| 133 | - | }; | |
| @@ -1,133 +0,0 @@ | |||||
| 1 | - | /** | |||
| 2 | - | * Appearance Configuration Module | |||
| 3 | - | * | |||
| 4 | - | * Handles application appearance configuration including color palettes and fonts. | |||
| 5 | - | * This config is injected by the native layer at startup and made available to all | |||
| 6 | - | * injected modules and components. | |||
| 7 | - | */ | |||
| 8 | - | ||||
| 9 | - | export interface ColorPalette { | |||
| 10 | - | background: string; | |||
| 11 | - | surface: string; | |||
| 12 | - | surfaceVariant: string; | |||
| 13 | - | text: string; | |||
| 14 | - | muted: string; | |||
| 15 | - | accent: string; | |||
| 16 | - | border: string; | |||
| 17 | - | } | |||
| 18 | - | ||||
| 19 | - | export interface AppearanceConfig { | |||
| 20 | - | theme: "light" | "dark"; | |||
| 21 | - | palettes: { | |||
| 22 | - | light: ColorPalette; | |||
| 23 | - | dark: ColorPalette; | |||
| 24 | - | }; | |||
| 25 | - | fonts: { | |||
| 26 | - | sans: string; | |||
| 27 | - | serif: string; | |||
| 28 | - | monospace: string; | |||
| 29 | - | defaultSize: number; | |||
| 30 | - | }; | |||
| 31 | - | } | |||
| 32 | - | ||||
| 33 | - | declare global { | |||
| 34 | - | interface Window { | |||
| 35 | - | __dumber_appearance_config?: AppearanceConfig; | |||
| 36 | - | __dumber_applyPalette?: (theme: "light" | "dark") => void; | |||
| 37 | - | } | |||
| 38 | - | } | |||
| 39 | - | ||||
| 40 | - | /** | |||
| 41 | - | * Applies the appearance configuration to the document | |||
| 42 | - | * Sets CSS custom properties for colors and fonts | |||
| 43 | - | */ | |||
| 44 | - | export function applyAppearanceConfig(): void { | |||
| 45 | - | const config = window.__dumber_appearance_config; | |||
| 46 | - | if (!config) { | |||
| 47 | - | console.warn("[dumber] Appearance config not available"); | |||
| 48 | - | return; | |||
| 49 | - | } | |||
| 50 | - | ||||
| 51 | - | const theme = config.theme || "light"; | |||
| 52 | - | const palette = config.palettes[theme]; | |||
| 53 | - | const root = document.documentElement; | |||
| 54 | - | ||||
| 55 | - | // Apply color palette as CSS custom properties | |||
| 56 | - | root.style.setProperty("--color-background", palette.background); | |||
| 57 | - | root.style.setProperty("--color-surface", palette.surface); | |||
| 58 | - | root.style.setProperty("--color-surface-variant", palette.surfaceVariant); | |||
| 59 | - | root.style.setProperty("--color-text", palette.text); | |||
| 60 | - | root.style.setProperty("--color-muted", palette.muted); | |||
| 61 | - | root.style.setProperty("--color-accent", palette.accent); | |||
| 62 | - | root.style.setProperty("--color-border", palette.border); | |||
| 63 | - | ||||
| 64 | - | // Apply font families | |||
| 65 | - | root.style.setProperty("--font-sans", config.fonts.sans); | |||
| 66 | - | root.style.setProperty("--font-serif", config.fonts.serif); | |||
| 67 | - | root.style.setProperty("--font-mono", config.fonts.monospace); | |||
| 68 | - | ||||
| 69 | - | console.log(`[dumber] Applied ${theme} appearance config`); | |||
| 70 | - | ||||
| 71 | - | // Dispatch event for components that need to react to appearance changes | |||
| 72 | - | document.dispatchEvent( | |||
| 73 | - | new CustomEvent("dumber:appearance-applied", { | |||
| 74 | - | detail: { theme, palette, fonts: config.fonts }, | |||
| 75 | - | }), | |||
| 76 | - | ); | |||
| 77 | - | } | |||
| 78 | - | ||||
| 79 | - | /** | |||
| 80 | - | * Gets the current theme from appearance config | |||
| 81 | - | */ | |||
| 82 | - | export function getCurrentTheme(): "light" | "dark" { | |||
| 83 | - | return window.__dumber_appearance_config?.theme || "light"; | |||
| 84 | - | } | |||
| 85 | - | ||||
| 86 | - | /** | |||
| 87 | - | * Gets the current color palette for the active theme | |||
| 88 | - | */ | |||
| 89 | - | export function getCurrentPalette(): ColorPalette | null { | |||
| 90 | - | const config = window.__dumber_appearance_config; | |||
| 91 | - | if (!config) return null; | |||
| 92 | - | ||||
| 93 | - | return config.palettes[config.theme]; | |||
| 94 | - | } | |||
| 95 | - | ||||
| 96 | - | /** | |||
| 97 | - | * Expose palette application function globally for integration with color-scheme module | |||
| 98 | - | */ | |||
| 99 | - | window.__dumber_applyPalette = (theme: "light" | "dark") => { | |||
| 100 | - | const config = window.__dumber_appearance_config; | |||
| 101 | - | if (!config) return; | |||
| 102 | - | ||||
| 103 | - | const palette = config.palettes[theme]; | |||
| 104 | - | const root = document.documentElement; | |||
| 105 | - | ||||
| 106 | - | root.style.setProperty("--color-background", palette.background); | |||
| 107 | - | root.style.setProperty("--color-surface", palette.surface); | |||
| 108 | - | root.style.setProperty("--color-surface-variant", palette.surfaceVariant); | |||
| 109 | - | root.style.setProperty("--color-text", palette.text); | |||
| 110 | - | root.style.setProperty("--color-muted", palette.muted); | |||
| 111 | - | root.style.setProperty("--color-accent", palette.accent); | |||
| 112 | - | root.style.setProperty("--color-border", palette.border); | |||
| 113 | - | ||||
| 114 | - | console.log(`[dumber] Switched to ${theme} palette`); | |||
| 115 | - | }; | |||
| 116 | - | ||||
| 117 | - | // Auto-initialize if config is already available | |||
| 118 | - | if (window.__dumber_appearance_config) { | |||
| 119 | - | applyAppearanceConfig(); | |||
| 120 | - | } | |||
| 121 | - | ||||
| 122 | - | // Listen for config injection and apply | |||
| 123 | - | document.addEventListener("DOMContentLoaded", () => { | |||
| 124 | - | if (window.__dumber_appearance_config) { | |||
| 125 | - | applyAppearanceConfig(); | |||
| 126 | - | } | |||
| 127 | - | }); | |||
| 128 | - | ||||
| 129 | - | export default { | |||
| 130 | - | applyAppearanceConfig, | |||
| 131 | - | getCurrentTheme, | |||
| 132 | - | getCurrentPalette, | |||
| 133 | - | }; | |||
D gui/src/injected/modules/controls.ts +0 -105
| @@ -1,105 +0,0 @@ | |||
| 1 | - | /** | |
| 2 | - | * Browser Controls Module | |
| 3 | - | * | |
| 4 | - | * Provides global keyboard and mouse controls that work on all domains. | |
| 5 | - | * Only includes essential controls that can work cross-origin: | |
| 6 | - | * - Navigation (back/forward) | |
| 7 | - | * - Mouse navigation buttons | |
| 8 | - | * | |
| 9 | - | * Zoom controls are handled natively by the GTK backend | |
| 10 | - | */ | |
| 11 | - | ||
| 12 | - | export interface ControlsConfig { | |
| 13 | - | // Future configuration options can be added here | |
| 14 | - | _placeholder?: never; // Prevent empty interface warning | |
| 15 | - | } | |
| 16 | - | ||
| 17 | - | let controlsInitialized = false; | |
| 18 | - | ||
| 19 | - | export function initializeControls(_config?: ControlsConfig): void { | |
| 20 | - | if (controlsInitialized) { | |
| 21 | - | console.log("🔄 Browser controls already initialized, skipping"); | |
| 22 | - | return; | |
| 23 | - | } | |
| 24 | - | ||
| 25 | - | console.log("🚀 Initializing browser controls on:", window.location.href); | |
| 26 | - | ||
| 27 | - | // Keyboard event handler for global controls | |
| 28 | - | function handleKeyboardEvent(event: KeyboardEvent): void { | |
| 29 | - | const { altKey, ctrlKey, key } = event; | |
| 30 | - | ||
| 31 | - | try { | |
| 32 | - | // Navigation: Ctrl + Left Arrow (Back) | |
| 33 | - | if (ctrlKey && key === "ArrowLeft") { | |
| 34 | - | event.preventDefault(); | |
| 35 | - | event.stopPropagation(); | |
| 36 | - | ||
| 37 | - | if (window.history.length > 1) { | |
| 38 | - | console.log("⬅️ Navigating back"); | |
| 39 | - | window.history.back(); | |
| 40 | - | } | |
| 41 | - | return; | |
| 42 | - | } | |
| 43 | - | ||
| 44 | - | // Navigation: Ctrl + Right Arrow (Forward) | |
| 45 | - | if (ctrlKey && key === "ArrowRight") { | |
| 46 | - | event.preventDefault(); | |
| 47 | - | event.stopPropagation(); | |
| 48 | - | ||
| 49 | - | console.log("➡️ Navigating forward"); | |
| 50 | - | window.history.forward(); | |
| 51 | - | return; | |
| 52 | - | } | |
| 53 | - | } catch (error) { | |
| 54 | - | console.error("❌ Error in keyboard handler:", error); | |
| 55 | - | } | |
| 56 | - | } | |
| 57 | - | ||
| 58 | - | // Mouse event handler for navigation buttons | |
| 59 | - | function handleMouseEvent(event: MouseEvent): void { | |
| 60 | - | try { | |
| 61 | - | // Mouse button 3 (back button) | |
| 62 | - | if (event.button === 3) { | |
| 63 | - | event.preventDefault(); | |
| 64 | - | event.stopPropagation(); | |
| 65 | - | ||
| 66 | - | if (window.history.length > 1) { | |
| 67 | - | console.log("⬅️ Mouse back button pressed"); | |
| 68 | - | window.history.back(); | |
| 69 | - | } | |
| 70 | - | return; | |
| 71 | - | } | |
| 72 | - | ||
| 73 | - | // Mouse button 4 (forward button) | |
| 74 | - | if (event.button === 4) { | |
| 75 | - | event.preventDefault(); | |
| 76 | - | event.stopPropagation(); | |
| 77 | - | ||
| 78 | - | console.log("➡️ Mouse forward button pressed"); | |
| 79 | - | window.history.forward(); | |
| 80 | - | return; | |
| 81 | - | } | |
| 82 | - | } catch (error) { | |
| 83 | - | console.error("❌ Error in mouse handler:", error); | |
| 84 | - | } | |
| 85 | - | } | |
| 86 | - | ||
| 87 | - | // Add event listeners with high priority (capture phase) | |
| 88 | - | try { | |
| 89 | - | document.addEventListener("keydown", handleKeyboardEvent, true); | |
| 90 | - | document.addEventListener("mousedown", handleMouseEvent, true); | |
| 91 | - | ||
| 92 | - | controlsInitialized = true; | |
| 93 | - | console.log("✅ Browser controls initialized"); | |
| 94 | - | ||
| 95 | - | // Cleanup function for when page is unloaded | |
| 96 | - | window.addEventListener("beforeunload", () => { | |
| 97 | - | document.removeEventListener("keydown", handleKeyboardEvent, true); | |
| 98 | - | document.removeEventListener("mousedown", handleMouseEvent, true); | |
| 99 | - | controlsInitialized = false; | |
| 100 | - | console.log("🧹 Browser controls cleaned up"); | |
| 101 | - | }); | |
| 102 | - | } catch (error) { | |
| 103 | - | console.error("❌ Failed to initialize browser controls:", error); | |
| 104 | - | } | |
| 105 | - | } | |
| @@ -1,105 +0,0 @@ | |||||
| 1 | - | /** | |||
| 2 | - | * Browser Controls Module | |||
| 3 | - | * | |||
| 4 | - | * Provides global keyboard and mouse controls that work on all domains. | |||
| 5 | - | * Only includes essential controls that can work cross-origin: | |||
| 6 | - | * - Navigation (back/forward) | |||
| 7 | - | * - Mouse navigation buttons | |||
| 8 | - | * | |||
| 9 | - | * Zoom controls are handled natively by the GTK backend | |||
| 10 | - | */ | |||
| 11 | - | ||||
| 12 | - | export interface ControlsConfig { | |||
| 13 | - | // Future configuration options can be added here | |||
| 14 | - | _placeholder?: never; // Prevent empty interface warning | |||
| 15 | - | } | |||
| 16 | - | ||||
| 17 | - | let controlsInitialized = false; | |||
| 18 | - | ||||
| 19 | - | export function initializeControls(_config?: ControlsConfig): void { | |||
| 20 | - | if (controlsInitialized) { | |||
| 21 | - | console.log("🔄 Browser controls already initialized, skipping"); | |||
| 22 | - | return; | |||
| 23 | - | } | |||
| 24 | - | ||||
| 25 | - | console.log("🚀 Initializing browser controls on:", window.location.href); | |||
| 26 | - | ||||
| 27 | - | // Keyboard event handler for global controls | |||
| 28 | - | function handleKeyboardEvent(event: KeyboardEvent): void { | |||
| 29 | - | const { altKey, ctrlKey, key } = event; | |||
| 30 | - | ||||
| 31 | - | try { | |||
| 32 | - | // Navigation: Ctrl + Left Arrow (Back) | |||
| 33 | - | if (ctrlKey && key === "ArrowLeft") { | |||
| 34 | - | event.preventDefault(); | |||
| 35 | - | event.stopPropagation(); | |||
| 36 | - | ||||
| 37 | - | if (window.history.length > 1) { | |||
| 38 | - | console.log("⬅️ Navigating back"); | |||
| 39 | - | window.history.back(); | |||
| 40 | - | } | |||
| 41 | - | return; | |||
| 42 | - | } | |||
| 43 | - | ||||
| 44 | - | // Navigation: Ctrl + Right Arrow (Forward) | |||
| 45 | - | if (ctrlKey && key === "ArrowRight") { | |||
| 46 | - | event.preventDefault(); | |||
| 47 | - | event.stopPropagation(); | |||
| 48 | - | ||||
| 49 | - | console.log("➡️ Navigating forward"); | |||
| 50 | - | window.history.forward(); | |||
| 51 | - | return; | |||
| 52 | - | } | |||
| 53 | - | } catch (error) { | |||
| 54 | - | console.error("❌ Error in keyboard handler:", error); | |||
| 55 | - | } | |||
| 56 | - | } | |||
| 57 | - | ||||
| 58 | - | // Mouse event handler for navigation buttons | |||
| 59 | - | function handleMouseEvent(event: MouseEvent): void { | |||
| 60 | - | try { | |||
| 61 | - | // Mouse button 3 (back button) | |||
| 62 | - | if (event.button === 3) { | |||
| 63 | - | event.preventDefault(); | |||
| 64 | - | event.stopPropagation(); | |||
| 65 | - | ||||
| 66 | - | if (window.history.length > 1) { | |||
| 67 | - | console.log("⬅️ Mouse back button pressed"); | |||
| 68 | - | window.history.back(); | |||
| 69 | - | } | |||
| 70 | - | return; | |||
| 71 | - | } | |||
| 72 | - | ||||
| 73 | - | // Mouse button 4 (forward button) | |||
| 74 | - | if (event.button === 4) { | |||
| 75 | - | event.preventDefault(); | |||
| 76 | - | event.stopPropagation(); | |||
| 77 | - | ||||
| 78 | - | console.log("➡️ Mouse forward button pressed"); | |||
| 79 | - | window.history.forward(); | |||
| 80 | - | return; | |||
| 81 | - | } | |||
| 82 | - | } catch (error) { | |||
| 83 | - | console.error("❌ Error in mouse handler:", error); | |||
| 84 | - | } | |||
| 85 | - | } | |||
| 86 | - | ||||
| 87 | - | // Add event listeners with high priority (capture phase) | |||
| 88 | - | try { | |||
| 89 | - | document.addEventListener("keydown", handleKeyboardEvent, true); | |||
| 90 | - | document.addEventListener("mousedown", handleMouseEvent, true); | |||
| 91 | - | ||||
| 92 | - | controlsInitialized = true; | |||
| 93 | - | console.log("✅ Browser controls initialized"); | |||
| 94 | - | ||||
| 95 | - | // Cleanup function for when page is unloaded | |||
| 96 | - | window.addEventListener("beforeunload", () => { | |||
| 97 | - | document.removeEventListener("keydown", handleKeyboardEvent, true); | |||
| 98 | - | document.removeEventListener("mousedown", handleMouseEvent, true); | |||
| 99 | - | controlsInitialized = false; | |||
| 100 | - | console.log("🧹 Browser controls cleaned up"); | |||
| 101 | - | }); | |||
| 102 | - | } catch (error) { | |||
| 103 | - | console.error("❌ Failed to initialize browser controls:", error); | |||
| 104 | - | } | |||
| 105 | - | } | |||
D gui/src/main.ts +0 -73
| @@ -1,73 +0,0 @@ | |||
| 1 | - | import { AppService } from "./services/app.js"; | |
| 2 | - | import { BrowserControlsService } from "./services/browser-controls.js"; | |
| 3 | - | import { DOMRenderer } from "./utils/dom.js"; | |
| 4 | - | ||
| 5 | - | class DumberBrowserApp { | |
| 6 | - | private appService: AppService; | |
| 7 | - | private browserControls: BrowserControlsService; | |
| 8 | - | private domRenderer: DOMRenderer; | |
| 9 | - | ||
| 10 | - | constructor() { | |
| 11 | - | this.appService = new AppService(); | |
| 12 | - | this.browserControls = new BrowserControlsService(); | |
| 13 | - | this.domRenderer = new DOMRenderer(); | |
| 14 | - | } | |
| 15 | - | ||
| 16 | - | async initialize(): Promise<void> { | |
| 17 | - | try { | |
| 18 | - | // Show loading states | |
| 19 | - | this.domRenderer.showLoading("history"); | |
| 20 | - | this.domRenderer.showLoading("shortcuts"); | |
| 21 | - | ||
| 22 | - | // Initialize services | |
| 23 | - | await this.appService.initialize(); | |
| 24 | - | ||
| 25 | - | // Initialize browser controls | |
| 26 | - | await this.browserControls.initialize(); | |
| 27 | - | ||
| 28 | - | // Render the UI | |
| 29 | - | this.render(); | |
| 30 | - | ||
| 31 | - | console.log("✓ Dumber Browser initialized successfully"); | |
| 32 | - | } catch (error) { | |
| 33 | - | console.error("Failed to initialize Dumber Browser:", error); | |
| 34 | - | this.handleInitializationError(); | |
| 35 | - | } | |
| 36 | - | } | |
| 37 | - | ||
| 38 | - | private render(): void { | |
| 39 | - | try { | |
| 40 | - | // Render history | |
| 41 | - | const history = this.appService.getHistory(); | |
| 42 | - | this.domRenderer.displayHistory(history); | |
| 43 | - | ||
| 44 | - | // Render shortcuts | |
| 45 | - | const shortcuts = this.appService.getShortcuts(); | |
| 46 | - | this.domRenderer.displayShortcuts(shortcuts); | |
| 47 | - | } catch (error) { | |
| 48 | - | console.error("Failed to render UI:", error); | |
| 49 | - | this.domRenderer.showError("history", "Failed to load history"); | |
| 50 | - | this.domRenderer.showError("shortcuts", "Failed to load shortcuts"); | |
| 51 | - | } | |
| 52 | - | } | |
| 53 | - | ||
| 54 | - | private handleInitializationError(): void { | |
| 55 | - | this.domRenderer.showError("history", "Failed to initialize application"); | |
| 56 | - | this.domRenderer.showError("shortcuts", "Failed to initialize application"); | |
| 57 | - | } | |
| 58 | - | } | |
| 59 | - | ||
| 60 | - | // Initialize the application when the DOM is ready | |
| 61 | - | function initializeApp(): void { | |
| 62 | - | const app = new DumberBrowserApp(); | |
| 63 | - | app.initialize().catch((error) => { | |
| 64 | - | console.error("Critical error during app initialization:", error); | |
| 65 | - | }); | |
| 66 | - | } | |
| 67 | - | ||
| 68 | - | // Wait for DOM to be ready | |
| 69 | - | if (document.readyState === "loading") { | |
| 70 | - | document.addEventListener("DOMContentLoaded", initializeApp); | |
| 71 | - | } else { | |
| 72 | - | initializeApp(); | |
| 73 | - | } | |
| @@ -1,73 +0,0 @@ | |||||
| 1 | - | import { AppService } from "./services/app.js"; | |||
| 2 | - | import { BrowserControlsService } from "./services/browser-controls.js"; | |||
| 3 | - | import { DOMRenderer } from "./utils/dom.js"; | |||
| 4 | - | ||||
| 5 | - | class DumberBrowserApp { | |||
| 6 | - | private appService: AppService; | |||
| 7 | - | private browserControls: BrowserControlsService; | |||
| 8 | - | private domRenderer: DOMRenderer; | |||
| 9 | - | ||||
| 10 | - | constructor() { | |||
| 11 | - | this.appService = new AppService(); | |||
| 12 | - | this.browserControls = new BrowserControlsService(); | |||
| 13 | - | this.domRenderer = new DOMRenderer(); | |||
| 14 | - | } | |||
| 15 | - | ||||
| 16 | - | async initialize(): Promise<void> { | |||
| 17 | - | try { | |||
| 18 | - | // Show loading states | |||
| 19 | - | this.domRenderer.showLoading("history"); | |||
| 20 | - | this.domRenderer.showLoading("shortcuts"); | |||
| 21 | - | ||||
| 22 | - | // Initialize services | |||
| 23 | - | await this.appService.initialize(); | |||
| 24 | - | ||||
| 25 | - | // Initialize browser controls | |||
| 26 | - | await this.browserControls.initialize(); | |||
| 27 | - | ||||
| 28 | - | // Render the UI | |||
| 29 | - | this.render(); | |||
| 30 | - | ||||
| 31 | - | console.log("✓ Dumber Browser initialized successfully"); | |||
| 32 | - | } catch (error) { | |||
| 33 | - | console.error("Failed to initialize Dumber Browser:", error); | |||
| 34 | - | this.handleInitializationError(); | |||
| 35 | - | } | |||
| 36 | - | } | |||
| 37 | - | ||||
| 38 | - | private render(): void { | |||
| 39 | - | try { | |||
| 40 | - | // Render history | |||
| 41 | - | const history = this.appService.getHistory(); | |||
| 42 | - | this.domRenderer.displayHistory(history); | |||
| 43 | - | ||||
| 44 | - | // Render shortcuts | |||
| 45 | - | const shortcuts = this.appService.getShortcuts(); | |||
| 46 | - | this.domRenderer.displayShortcuts(shortcuts); | |||
| 47 | - | } catch (error) { | |||
| 48 | - | console.error("Failed to render UI:", error); | |||
| 49 | - | this.domRenderer.showError("history", "Failed to load history"); | |||
| 50 | - | this.domRenderer.showError("shortcuts", "Failed to load shortcuts"); | |||
| 51 | - | } | |||
| 52 | - | } | |||
| 53 | - | ||||
| 54 | - | private handleInitializationError(): void { | |||
| 55 | - | this.domRenderer.showError("history", "Failed to initialize application"); | |||
| 56 | - | this.domRenderer.showError("shortcuts", "Failed to initialize application"); | |||
| 57 | - | } | |||
| 58 | - | } | |||
| 59 | - | ||||
| 60 | - | // Initialize the application when the DOM is ready | |||
| 61 | - | function initializeApp(): void { | |||
| 62 | - | const app = new DumberBrowserApp(); | |||
| 63 | - | app.initialize().catch((error) => { | |||
| 64 | - | console.error("Critical error during app initialization:", error); | |||
| 65 | - | }); | |||
| 66 | - | } | |||
| 67 | - | ||||
| 68 | - | // Wait for DOM to be ready | |||
| 69 | - | if (document.readyState === "loading") { | |||
| 70 | - | document.addEventListener("DOMContentLoaded", initializeApp); | |||
| 71 | - | } else { | |||
| 72 | - | initializeApp(); | |||
| 73 | - | } | |||
M gui/src/services/browser-controls.ts +1 -1
| @@ -26,7 +26,7 @@ export class BrowserControlsService { | |||
| 26 | 26 | "info", | |
| 27 | 27 | "frontend", | |
| 28 | 28 | "init", | |
| 29 | - | "BrowserControlsService initialized ✓", | |
| 29 | + | "BrowserControlsService initialized", | |
| 30 | 30 | ); | |
| 31 | 31 | } | |
| 32 | 32 | ||
| @@ -26,7 +26,7 @@ export class BrowserControlsService { | |||||
| 26 | "info", | 26 | "info", | ||
| 27 | "frontend", | 27 | "frontend", | ||
| 28 | "init", | 28 | "init", | ||
| 29 | - | "BrowserControlsService initialized ✓", | 29 | + | "BrowserControlsService initialized", |
| 30 | ); | 30 | ); | ||
| 31 | } | 31 | } | ||
| 32 | 32 | ||||