chore: cleanup and build improvements
- vite.config.homepage.ts: Inline CSS for shadow DOM compatibility. Set emitCss=false and cssCodeSplit=false, remove css file from page config. - browser.go: Remove unused InjectGUIBundle method (28 lines) - Makefile: Add GUI assets to clean target for complete cleanup These changes improve the build process and remove unused code.
- commit
- 353ffbf2d600d113701d57e6d2eab9c1bc42befa
- author
- bamen · · 2025-10-13 21:16 UTC
- committer
- bamen · · 2025-10-13 16:35 UTC
- parent
- eac27b2
- signature
- unsigned
3 files · +5 -25
M Makefile +1 -0
| @@ -123,6 +123,7 @@ clean: ## Clean build artifacts | |||
| 123 | 123 | rm -rf $(DIST_DIR) | |
| 124 | 124 | rm -f $(BINARY_NAME) # Remove any old binaries in root | |
| 125 | 125 | rm -rf gui/dist gui/node_modules | |
| 126 | + | rm -f assets/gui/gui.min.js assets/gui/homepage.min.js assets/gui/homepage.css assets/gui/main-world.min.js assets/gui/color-scheme.js | |
| 126 | 127 | go clean -cache | |
| 127 | 128 | go clean -testcache | |
| 128 | 129 | ||
| @@ -123,6 +123,7 @@ clean: ## Clean build artifacts | |||||
| 123 | rm -rf $(DIST_DIR) | 123 | rm -rf $(DIST_DIR) | ||
| 124 | rm -f $(BINARY_NAME) # Remove any old binaries in root | 124 | rm -f $(BINARY_NAME) # Remove any old binaries in root | ||
| 125 | rm -rf gui/dist gui/node_modules | 125 | rm -rf gui/dist gui/node_modules | ||
| 126 | + | rm -f assets/gui/gui.min.js assets/gui/homepage.min.js assets/gui/homepage.css assets/gui/main-world.min.js assets/gui/color-scheme.js | |||
| 126 | go clean -cache | 127 | go clean -cache | ||
| 127 | go clean -testcache | 128 | go clean -testcache | ||
| 128 | 129 | ||||
M gui/vite.config.homepage.ts +4 -3
| @@ -5,13 +5,14 @@ import { pageGenerator } from "./vite-plugin-pages"; | |||
| 5 | 5 | ||
| 6 | 6 | export default defineConfig({ | |
| 7 | 7 | plugins: [ | |
| 8 | - | svelte(), | |
| 8 | + | svelte({ | |
| 9 | + | emitCss: false, // Inline component CSS for shadow DOM compatibility | |
| 10 | + | }), | |
| 9 | 11 | pageGenerator([ | |
| 10 | 12 | { | |
| 11 | 13 | name: "homepage", | |
| 12 | 14 | title: "Dumber Browser", | |
| 13 | 15 | script: "homepage.min.js", | |
| 14 | - | css: "homepage.css", | |
| 15 | 16 | filename: "index.html", | |
| 16 | 17 | }, | |
| 17 | 18 | ]), | |
| @@ -33,7 +34,7 @@ export default defineConfig({ | |||
| 33 | 34 | target: ["es2020", "chrome91", "firefox90"], | |
| 34 | 35 | minify: true, | |
| 35 | 36 | sourcemap: false, | |
| 36 | - | cssCodeSplit: true, | |
| 37 | + | cssCodeSplit: false, | |
| 37 | 38 | assetsInlineLimit: 4096, | |
| 38 | 39 | }, | |
| 39 | 40 | resolve: { | |
| @@ -5,13 +5,14 @@ import { pageGenerator } from "./vite-plugin-pages"; | |||||
| 5 | 5 | ||||
| 6 | export default defineConfig({ | 6 | export default defineConfig({ | ||
| 7 | plugins: [ | 7 | plugins: [ | ||
| 8 | - | svelte(), | 8 | + | svelte({ |
| 9 | + | emitCss: false, // Inline component CSS for shadow DOM compatibility | |||
| 10 | + | }), | |||
| 9 | pageGenerator([ | 11 | pageGenerator([ | ||
| 10 | { | 12 | { | ||
| 11 | name: "homepage", | 13 | name: "homepage", | ||
| 12 | title: "Dumber Browser", | 14 | title: "Dumber Browser", | ||
| 13 | script: "homepage.min.js", | 15 | script: "homepage.min.js", | ||
| 14 | - | css: "homepage.css", | |||
| 15 | filename: "index.html", | 16 | filename: "index.html", | ||
| 16 | }, | 17 | }, | ||
| 17 | ]), | 18 | ]), | ||
| @@ -33,7 +34,7 @@ export default defineConfig({ | |||||
| 33 | target: ["es2020", "chrome91", "firefox90"], | 34 | target: ["es2020", "chrome91", "firefox90"], | ||
| 34 | minify: true, | 35 | minify: true, | ||
| 35 | sourcemap: false, | 36 | sourcemap: false, | ||
| 36 | - | cssCodeSplit: true, | 37 | + | cssCodeSplit: false, |
| 37 | assetsInlineLimit: 4096, | 38 | assetsInlineLimit: 4096, | ||
| 38 | }, | 39 | }, | ||
| 39 | resolve: { | 40 | resolve: { | ||
M internal/services/browser.go +0 -22
| @@ -124,28 +124,6 @@ func (s *BrowserService) GetGUIBundle() string { | |||
| 124 | 124 | return s.guiBundle | |
| 125 | 125 | } | |
| 126 | 126 | ||
| 127 | - | // InjectGUIBundle injects the unified GUI bundle and initializes controls | |
| 128 | - | func (s *BrowserService) InjectGUIBundle(ctx context.Context) error { | |
| 129 | - | _ = ctx | |
| 130 | - | if s.webView == nil { | |
| 131 | - | return fmt.Errorf("webview not attached") | |
| 132 | - | } | |
| 133 | - | if s.guiBundle == "" { | |
| 134 | - | return fmt.Errorf("GUI bundle not loaded") | |
| 135 | - | } | |
| 136 | - | ||
| 137 | - | // Inject the unified GUI bundle first | |
| 138 | - | bundleScript := s.guiBundle + | |
| 139 | - | ";(function(){" + | |
| 140 | - | "if(window.__dumber_gui && window.__dumber_gui.initializeControls){" + | |
| 141 | - | "window.__dumber_gui.initializeControls();" + | |
| 142 | - | "console.log('✅ Controls initialized via GUI bundle');" + | |
| 143 | - | "}else{console.error('❌ GUI bundle not properly loaded');}" + | |
| 144 | - | "})();" | |
| 145 | - | ||
| 146 | - | return s.webView.InjectScript(bundleScript) | |
| 147 | - | } | |
| 148 | - | ||
| 149 | 127 | // InjectToastSystem injects the GUI bundle and initializes the toast system | |
| 150 | 128 | func (s *BrowserService) InjectToastSystem(ctx context.Context, theme string) error { | |
| 151 | 129 | _ = ctx | |
| @@ -124,28 +124,6 @@ func (s *BrowserService) GetGUIBundle() string { | |||||
| 124 | return s.guiBundle | 124 | return s.guiBundle | ||
| 125 | } | 125 | } | ||
| 126 | 126 | ||||
| 127 | - | // InjectGUIBundle injects the unified GUI bundle and initializes controls | |||
| 128 | - | func (s *BrowserService) InjectGUIBundle(ctx context.Context) error { | |||
| 129 | - | _ = ctx | |||
| 130 | - | if s.webView == nil { | |||
| 131 | - | return fmt.Errorf("webview not attached") | |||
| 132 | - | } | |||
| 133 | - | if s.guiBundle == "" { | |||
| 134 | - | return fmt.Errorf("GUI bundle not loaded") | |||
| 135 | - | } | |||
| 136 | - | ||||
| 137 | - | // Inject the unified GUI bundle first | |||
| 138 | - | bundleScript := s.guiBundle + | |||
| 139 | - | ";(function(){" + | |||
| 140 | - | "if(window.__dumber_gui && window.__dumber_gui.initializeControls){" + | |||
| 141 | - | "window.__dumber_gui.initializeControls();" + | |||
| 142 | - | "console.log('✅ Controls initialized via GUI bundle');" + | |||
| 143 | - | "}else{console.error('❌ GUI bundle not properly loaded');}" + | |||
| 144 | - | "})();" | |||
| 145 | - | ||||
| 146 | - | return s.webView.InjectScript(bundleScript) | |||
| 147 | - | } | |||
| 148 | - | ||||
| 149 | // InjectToastSystem injects the GUI bundle and initializes the toast system | 127 | // InjectToastSystem injects the GUI bundle and initializes the toast system | ||
| 150 | func (s *BrowserService) InjectToastSystem(ctx context.Context, theme string) error { | 128 | func (s *BrowserService) InjectToastSystem(ctx context.Context, theme string) error { | ||
| 151 | _ = ctx | 129 | _ = ctx | ||