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