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 // CreateWindow controls whether to create a window during WebView initialization.
52 // Set to false when creating WebViews for workspace panes that will be reparented.
53 CreateWindow bool
54}
55
56// CodecPreferencesConfig holds codec preferences for WebKit media playback
57type CodecPreferencesConfig struct {
58 PreferredCodecs []string
59 BlockedCodecs []string
60 ForceAV1 bool
61 CustomUserAgent string
62 DisableTwitchCodecControl bool
63}
64
65// RenderingConfig controls hardware acceleration preferences.
66// Mode accepts: "auto" (default), "gpu", or "cpu".
67// DebugGPU enables compositing indicators if supported.
68type RenderingConfig struct {
69 Mode string
70 DebugGPU bool
71}
72
73// VideoAccelerationConfig controls video hardware acceleration settings.
74type VideoAccelerationConfig struct {
75 EnableVAAPI bool
76 AutoDetectGPU bool
77 VAAPIDriverName string
78 EnableAllDrivers bool
79 LegacyVAAPI bool
80}
81
82// CacheModel represents WebKit cache model options for memory optimization.
83type CacheModel string
84
85const (
86 CacheModelDocumentViewer CacheModel = "document_viewer" // Minimal caching, lowest memory
87 CacheModelWebBrowser CacheModel = "web_browser" // Default, balanced caching
88 CacheModelPrimaryWebBrowser CacheModel = "primary_web_browser" // Maximum caching, highest memory
89)
90
91// MemoryConfig controls memory optimization settings.
92type MemoryConfig struct {
93 // MemoryLimitMB sets the maximum memory limit per WebView in MB (0 = unlimited)
94 MemoryLimitMB int
95
96 // ConservativeThreshold triggers early memory cleanup (0.0-1.0, default 0.33)
97 ConservativeThreshold float64
98
99 // StrictThreshold triggers aggressive memory cleanup (0.0-1.0, default 0.5)
100 StrictThreshold float64
101
102 // KillThreshold kills processes at this memory usage (0.0-1.0, 0 = disabled)
103 KillThreshold float64
104
105 // PollIntervalSeconds sets how often to check memory usage (default 2.0)
106 PollIntervalSeconds float64
107
108 // CacheModel determines caching strategy (default: web_browser)
109 CacheModel CacheModel
110
111 // EnablePageCache enables back/forward page caching (default: true)
112 EnablePageCache bool
113
114 // EnableOfflineAppCache enables offline application caching (default: true)
115 EnableOfflineAppCache bool
116
117 // ProcessRecycleThreshold recycles WebView after N page loads (0 = disabled)
118 ProcessRecycleThreshold int
119
120 // EnableGCInterval enables periodic JS garbage collection in seconds (0 = disabled)
121 EnableGCInterval int
122
123 // EnableMemoryMonitoring logs memory usage and pressure events
124 EnableMemoryMonitoring bool
125}