settings.go RawHistoryFolder
1package webkit
2
3// Config holds initialization settings for the WebKit-based browser components.
4// This will map to WebKit2GTK and GTK settings in the real implementation.
5type Config struct {
6 // Assets provides access to embedded GUI files
7 Assets interface{ ReadFile(string) ([]byte, error) }
8
9 // InitialURL is the first URL to load when creating a WebView.
10 InitialURL string
11
12 // UserAgent allows overriding the default user agent string.
13 UserAgent string
14
15 // EnableDeveloperExtras enables devtools/inspector.
16 EnableDeveloperExtras bool
17
18 // ZoomDefault sets an initial zoom factor (1.0 = 100%).
19 ZoomDefault float64
20
21 // DataDir is the base directory for persistent website data (cookies, localStorage, etc.).
22 DataDir string
23 // CacheDir is the base directory for cache data.
24 CacheDir string
25
26 // Fonts apply to pages that don't specify fonts (browser defaults).
27 DefaultSansFont string
28 DefaultSerifFont string
29 DefaultMonospaceFont string
30 DefaultFontSize int // CSS px (~points)
31
32 // Rendering controls GPU/CPU selection and debug options
33 Rendering RenderingConfig
34
35 // VideoAcceleration controls video hardware acceleration settings
36 VideoAcceleration VideoAccelerationConfig
37
38 // Memory controls memory optimization settings
39 Memory MemoryConfig
40
41 // CodecPreferences for media playback
42 CodecPreferences CodecPreferencesConfig
43
44 // APIToken holds the per-session token used to authenticate dumb://api requests
45 // It's optional; if empty, API token enforcement may be disabled by the app.
46 APIToken string
47
48 // UseDomZoom toggles CSS/DOM-based zoom instead of WebKit's native zoom.
49 UseDomZoom bool
50
51 // Colors defines the light/dark palette tokens for the GUI.
52 Colors ColorPalettes
53
54 // CreateWindow controls whether to create a window during WebView initialization.
55 // Set to false when creating WebViews for workspace panes that will be reparented.
56 CreateWindow bool
57}
58
59// ColorPalette holds semantic UI tokens for a theme.
60type ColorPalette struct {
61 Background string
62 Surface string
63 SurfaceVariant string
64 Text string
65 Muted string
66 Accent string
67 Border string
68}
69
70// ColorPalettes hosts both light and dark color palettes.
71type ColorPalettes struct {
72 Light ColorPalette
73 Dark ColorPalette
74}
75
76// CodecPreferencesConfig holds codec preferences for WebKit media playback
77type CodecPreferencesConfig struct {
78 PreferredCodecs []string
79 BlockedCodecs []string
80 ForceAV1 bool
81 CustomUserAgent string
82 DisableTwitchCodecControl bool
83}
84
85// RenderingConfig controls hardware acceleration preferences.
86// Mode accepts: "auto" (default), "gpu", or "cpu".
87// DebugGPU enables compositing indicators if supported.
88type RenderingConfig struct {
89 Mode string
90 DebugGPU bool
91}
92
93// VideoAccelerationConfig controls video hardware acceleration settings.
94type VideoAccelerationConfig struct {
95 EnableVAAPI bool
96 AutoDetectGPU bool
97 VAAPIDriverName string
98 EnableAllDrivers bool
99 LegacyVAAPI bool
100}
101
102// CacheModel represents WebKit cache model options for memory optimization.
103type CacheModel string
104
105const (
106 CacheModelDocumentViewer CacheModel = "document_viewer" // Minimal caching, lowest memory
107 CacheModelWebBrowser CacheModel = "web_browser" // Default, balanced caching
108 CacheModelPrimaryWebBrowser CacheModel = "primary_web_browser" // Maximum caching, highest memory
109)
110
111// MemoryConfig controls memory optimization settings.
112type MemoryConfig struct {
113 // MemoryLimitMB sets the maximum memory limit per WebView in MB (0 = unlimited)
114 MemoryLimitMB int
115
116 // ConservativeThreshold triggers early memory cleanup (0.0-1.0, default 0.33)
117 ConservativeThreshold float64
118
119 // StrictThreshold triggers aggressive memory cleanup (0.0-1.0, default 0.5)
120 StrictThreshold float64
121
122 // KillThreshold kills processes at this memory usage (0.0-1.0, 0 = disabled)
123 KillThreshold float64
124
125 // PollIntervalSeconds sets how often to check memory usage (default 2.0)
126 PollIntervalSeconds float64
127
128 // CacheModel determines caching strategy (default: web_browser)
129 CacheModel CacheModel
130
131 // EnablePageCache enables back/forward page caching (default: true)
132 EnablePageCache bool
133
134 // EnableOfflineAppCache enables offline application caching (default: true)
135 EnableOfflineAppCache bool
136
137 // ProcessRecycleThreshold recycles WebView after N page loads (0 = disabled)
138 ProcessRecycleThreshold int
139
140 // EnableGCInterval enables periodic JS garbage collection in seconds (0 = disabled)
141 EnableGCInterval int
142
143 // EnableMemoryMonitoring logs memory usage and pressure events
144 EnableMemoryMonitoring bool
145}