Documentation
¶
Overview ¶
Package port defines interfaces for external dependencies.
Package port defines interfaces for external dependencies.
Package port defines interfaces for external dependencies.
Package port defines application-layer interfaces for external capabilities. Ports abstract infrastructure concerns, allowing the application layer to remain independent of specific implementations (WebKit, GTK, etc.).
Index ¶
- Variables
- type Clipboard
- type ColorPalette
- type ContentInjector
- type DesktopIntegration
- type DesktopIntegrationStatus
- type FileSystem
- type FindController
- type FindOptions
- type GPUVendor
- type LoadEvent
- type MediaDiagnostics
- type MediaDiagnosticsResult
- type Notification
- type NotificationID
- type NotificationType
- type PkgConfigError
- type PkgConfigErrorKind
- type PopupRequest
- type RenderingEnvManager
- type RenderingEnvSettings
- type RuntimeVersionProbe
- type SearchShortcut
- type SessionLogConfig
- type SessionLogger
- type Texture
- type WebUIAppearanceConfig
- type WebUIConfig
- type WebUIConfigSaver
- type WebView
- type WebViewCallbacks
- type WebViewFactory
- type WebViewID
- type WebViewPool
- type WebViewState
- type XDGPaths
Constants ¶
This section is empty.
Variables ¶
var ( // ErrPkgConfigMissing indicates pkg-config is not available on the host. ErrPkgConfigMissing = errors.New("pkg-config missing") // ErrPkgConfigPackageMissing indicates the requested .pc package was not found. ErrPkgConfigPackageMissing = errors.New("pkg-config package missing") )
Functions ¶
This section is empty.
Types ¶
type Clipboard ¶
type Clipboard interface {
// WriteText copies text to the clipboard.
WriteText(ctx context.Context, text string) error
// ReadText reads text from the clipboard.
// Returns empty string if clipboard is empty or contains non-text data.
ReadText(ctx context.Context) (string, error)
// Clear clears the clipboard contents.
Clear(ctx context.Context) error
// HasText returns true if the clipboard contains text data.
HasText(ctx context.Context) (bool, error)
}
Clipboard defines the port interface for clipboard operations. This abstracts platform-specific clipboard implementations (GTK, etc.).
type ColorPalette ¶
type ContentInjector ¶
type ContentInjector interface {
// InjectThemeCSS injects CSS variables into the page for theming.
// The css parameter should contain CSS custom property declarations.
InjectThemeCSS(ctx context.Context, css string) error
}
ContentInjector defines the port interface for injecting scripts and styles into web views. This abstracts platform-specific content injection implementations (WebKit, etc.).
type DesktopIntegration ¶
type DesktopIntegration interface {
// GetStatus checks the current desktop integration state.
GetStatus(ctx context.Context) (*DesktopIntegrationStatus, error)
// InstallDesktopFile writes the desktop file to XDG applications directory.
// Returns the path where the file was installed.
// Idempotent: safe to call multiple times.
InstallDesktopFile(ctx context.Context) (string, error)
// InstallIcon writes the icon file to XDG icons directory.
// Returns the path where the icon was installed.
// Idempotent: safe to call multiple times.
InstallIcon(ctx context.Context, svgData []byte) (string, error)
// RemoveDesktopFile removes the desktop file from XDG applications directory.
// Idempotent: returns nil if file doesn't exist.
RemoveDesktopFile(ctx context.Context) error
// RemoveIcon removes the icon file from XDG icons directory.
// Idempotent: returns nil if file doesn't exist.
RemoveIcon(ctx context.Context) error
// SetAsDefaultBrowser sets dumber as the default web browser using xdg-settings.
// Returns error if desktop file is not installed.
SetAsDefaultBrowser(ctx context.Context) error
// UnsetAsDefaultBrowser resets default browser if dumber is currently default.
// Idempotent: returns nil if not currently default.
UnsetAsDefaultBrowser(ctx context.Context) error
}
DesktopIntegration provides desktop environment integration operations.
type DesktopIntegrationStatus ¶
type DesktopIntegrationStatus struct {
DesktopFileInstalled bool
DesktopFilePath string
IconInstalled bool
IconFilePath string
IsDefaultBrowser bool
ExecutablePath string
}
DesktopIntegrationStatus represents the current state of desktop integration.
type FileSystem ¶
type FileSystem interface {
Exists(ctx context.Context, path string) (bool, error)
IsDirectory(ctx context.Context, path string) (bool, error)
GetSize(ctx context.Context, path string) (int64, error)
RemoveAll(ctx context.Context, path string) error
}
FileSystem provides file system operations for the application layer.
type FindController ¶
type FindController interface {
Search(text string, options FindOptions, maxMatches uint)
CountMatches(text string, options FindOptions, maxMatches uint)
SearchNext()
SearchPrevious()
SearchFinish()
GetSearchText() string
// Signal connections
OnFoundText(callback func(matchCount uint)) uint32
OnFailedToFindText(callback func()) uint32
OnCountedMatches(callback func(matchCount uint)) uint32
DisconnectSignal(id uint32)
}
FindController abstracts WebKit's FindController for clean architecture.
type FindOptions ¶
FindOptions configures search behavior.
type GPUVendor ¶
type GPUVendor string
GPUVendor identifies the GPU manufacturer for vendor-specific optimizations.
const ( // GPUVendorAMD represents AMD/ATI GPUs (vendor ID 0x1002) GPUVendorAMD GPUVendor = "amd" // GPUVendorIntel represents Intel integrated/discrete GPUs (vendor ID 0x8086) GPUVendorIntel GPUVendor = "intel" // GPUVendorNVIDIA represents NVIDIA GPUs (vendor ID 0x10de) GPUVendorNVIDIA GPUVendor = "nvidia" // GPUVendorUnknown represents undetected or unsupported GPUs GPUVendorUnknown GPUVendor = "unknown" )
type MediaDiagnostics ¶
type MediaDiagnostics interface {
// RunDiagnostics checks GStreamer plugins and VA-API availability.
RunDiagnostics(ctx context.Context) *MediaDiagnosticsResult
}
MediaDiagnostics provides video playback capability detection.
type MediaDiagnosticsResult ¶
type MediaDiagnosticsResult struct {
// GStreamer availability
GStreamerAvailable bool
// GStreamer plugins
HasVAPlugin bool // gst-plugins-bad VA (modern stateless decoders)
HasVAAPIPlugin bool // gstreamer-vaapi (legacy)
HasNVCodecPlugin bool // nvcodec for NVIDIA
// Detected hardware decoders
AV1Decoders []string
H264Decoders []string
H265Decoders []string
VP9Decoders []string
// VA-API info
VAAPIAvailable bool
VAAPIDriver string
VAAPIVersion string
// Summary
HWAccelAvailable bool
AV1HWAvailable bool
Warnings []string
}
MediaDiagnosticsResult contains hardware acceleration detection results.
type Notification ¶
type Notification interface {
// Show displays a notification with the given message and type.
// Duration is in milliseconds; pass 0 for default duration.
// Returns an ID that can be used to dismiss the notification.
Show(ctx context.Context, message string, notifType NotificationType, durationMs int) NotificationID
// ShowZoom displays a special zoom level notification.
// These typically appear in a fixed position and auto-dismiss.
ShowZoom(ctx context.Context, zoomPercent int) NotificationID
// Dismiss removes a specific notification by ID.
Dismiss(ctx context.Context, id NotificationID)
// Clear removes all displayed notifications.
Clear(ctx context.Context)
}
Notification represents the port interface for user notifications/toasts. This abstracts the presentation layer (GTK/libadwaita toasts, frontend overlay, etc.).
type NotificationID ¶
type NotificationID string
NotificationID uniquely identifies a displayed notification.
type NotificationType ¶
type NotificationType int
NotificationType indicates the visual style of a notification.
const ( // NotificationInfo is for informational messages. NotificationInfo NotificationType = iota // NotificationSuccess is for success confirmations. NotificationSuccess // NotificationError is for error messages. NotificationError // NotificationWarning is for warning messages. NotificationWarning )
func (NotificationType) String ¶
func (t NotificationType) String() string
String returns a human-readable representation of the notification type.
type PkgConfigError ¶
type PkgConfigError struct {
Kind PkgConfigErrorKind
Package string
Output string
Err error
}
PkgConfigError wraps an error returned by pkg-config probing.
func (*PkgConfigError) Error ¶
func (e *PkgConfigError) Error() string
func (*PkgConfigError) Unwrap ¶
func (e *PkgConfigError) Unwrap() error
type PkgConfigErrorKind ¶
type PkgConfigErrorKind string
PkgConfigErrorKind describes the category of a pkg-config failure.
const ( PkgConfigErrorKindCommandMissing PkgConfigErrorKind = "command_missing" PkgConfigErrorKindPackageMissing PkgConfigErrorKind = "package_missing" PkgConfigErrorKindUnknown PkgConfigErrorKind = "unknown" )
type PopupRequest ¶
type PopupRequest struct {
TargetURI string
FrameName string // e.g., "_blank", custom name, or empty
IsUserGesture bool
ParentViewID WebViewID
}
PopupRequest contains metadata about a popup window request.
type RenderingEnvManager ¶
type RenderingEnvManager interface {
// DetectGPUVendor identifies the primary GPU vendor from system info.
// Uses /sys/class/drm/card*/device/vendor as primary detection method.
DetectGPUVendor(ctx context.Context) GPUVendor
// ApplyEnvironment sets all rendering environment variables.
// Must be called before any GTK/GStreamer initialization.
ApplyEnvironment(ctx context.Context, settings RenderingEnvSettings) error
// GetAppliedVars returns a map of environment variables that were set.
// Useful for logging and debugging.
GetAppliedVars() map[string]string
}
RenderingEnvManager configures rendering environment variables for GStreamer, WebKit, and GTK/GSK. Environment variables must be set BEFORE GTK/WebKit initialization.
type RenderingEnvSettings ¶
type RenderingEnvSettings struct {
// --- GStreamer settings (from MediaConfig) ---
// ForceVSync enables vertical sync for video playback.
ForceVSync bool
// GLRenderingMode controls OpenGL API selection: "auto", "gles2", "gl3", "none".
GLRenderingMode string
// GStreamerDebugLevel sets GStreamer debug verbosity (0-5).
GStreamerDebugLevel int
// VideoBufferSizeMB sets buffer size in megabytes for video streaming.
VideoBufferSizeMB int
// QueueBufferTimeSec sets queue buffer time in seconds for prebuffering.
QueueBufferTimeSec int
// --- WebKit compositor settings (from RenderingConfig) ---
DisableDMABufRenderer bool
ForceCompositingMode bool
DisableCompositingMode bool
// --- GTK/GSK settings (from RenderingConfig) ---
GSKRenderer string
DisableMipmaps bool
PreferGL bool
// --- Debug settings ---
ShowFPS bool
SampleMemory bool
DebugFrames bool
}
RenderingEnvSettings contains all rendering-related environment settings. This is a port-local type to avoid import cycles with config package.
type RuntimeVersionProbe ¶
type RuntimeVersionProbe interface {
PkgConfigModVersion(ctx context.Context, pkgName string, prefix string) (string, error)
}
RuntimeVersionProbe provides runtime dependency discovery.
Implementations may use pkg-config and may apply a prefix override to influence pkg-config search paths.
type SearchShortcut ¶
type SessionLogConfig ¶
type SessionLogger ¶
type SessionLogger interface {
CreateLogger(ctx context.Context, sessionID entity.SessionID, cfg SessionLogConfig) (zerolog.Logger, func(), error)
}
SessionLogger creates a logger tied to a session.
type Texture ¶
type Texture interface {
// GoPointer returns the underlying C pointer for GTK interop.
GoPointer() uintptr
}
Texture represents a graphics texture (abstraction over gdk.Texture). This interface allows the port layer to work with textures without importing GTK/GDK packages directly.
type WebUIAppearanceConfig ¶
type WebUIAppearanceConfig struct {
SansFont string `json:"sans_font"`
SerifFont string `json:"serif_font"`
MonospaceFont string `json:"monospace_font"`
DefaultFontSize int `json:"default_font_size"`
ColorScheme string `json:"color_scheme"`
LightPalette ColorPalette `json:"light_palette"`
DarkPalette ColorPalette `json:"dark_palette"`
}
type WebUIConfig ¶
type WebUIConfig struct {
Appearance WebUIAppearanceConfig `json:"appearance"`
DefaultUIScale float64 `json:"default_ui_scale"`
DefaultSearchEngine string `json:"default_search_engine"`
SearchShortcuts map[string]SearchShortcut `json:"search_shortcuts"`
}
WebUIConfig represents the subset of configuration editable in dumb://config.
type WebUIConfigSaver ¶
type WebUIConfigSaver interface {
SaveWebUIConfig(ctx context.Context, cfg WebUIConfig) error
}
WebUIConfigSaver persists WebUI configuration changes.
type WebView ¶
type WebView interface {
// ID returns the unique identifier for this WebView.
ID() WebViewID
// LoadURI navigates to the specified URI.
LoadURI(ctx context.Context, uri string) error
// LoadHTML loads HTML content with an optional base URI for relative links.
LoadHTML(ctx context.Context, content, baseURI string) error
// Reload reloads the current page.
Reload(ctx context.Context) error
// ReloadBypassCache reloads the current page, bypassing cache.
ReloadBypassCache(ctx context.Context) error
// Stop stops the current page load.
Stop(ctx context.Context) error
// GoBack navigates back in history.
// Returns error if back navigation is not possible.
GoBack(ctx context.Context) error
// GoForward navigates forward in history.
// Returns error if forward navigation is not possible.
GoForward(ctx context.Context) error
// State returns the current WebView state as a snapshot.
State() WebViewState
// URI returns the current URI.
URI() string
// Title returns the current page title.
Title() string
// IsLoading returns true if a page is currently loading.
IsLoading() bool
// EstimatedProgress returns the load progress (0.0 to 1.0).
EstimatedProgress() float64
// CanGoBack returns true if back navigation is available.
CanGoBack() bool
// CanGoForward returns true if forward navigation is available.
CanGoForward() bool
// SetZoomLevel sets the zoom level (1.0 = 100%).
SetZoomLevel(ctx context.Context, level float64) error
// GetZoomLevel returns the current zoom level.
GetZoomLevel() float64
// GetFindController returns the find controller for text search.
// Returns nil if find is not supported.
GetFindController() FindController
// SetCallbacks registers callback handlers for WebView events.
// Pass nil to clear all callbacks.
SetCallbacks(callbacks *WebViewCallbacks)
// IsDestroyed returns true if the WebView has been destroyed.
IsDestroyed() bool
// Destroy releases all resources associated with this WebView.
// After calling Destroy, the WebView should not be used.
Destroy()
}
WebView defines the port interface for browser view operations. This interface abstracts the underlying browser engine (WebKit, etc.) and exposes only the navigation and state capabilities needed by the application layer.
type WebViewCallbacks ¶
type WebViewCallbacks struct {
// OnLoadChanged is called when load state changes.
OnLoadChanged func(event LoadEvent)
// OnTitleChanged is called when the page title changes.
OnTitleChanged func(title string)
// OnURIChanged is called when the URI changes.
OnURIChanged func(uri string)
// OnProgressChanged is called during page load with progress 0.0-1.0.
OnProgressChanged func(progress float64)
// OnFaviconChanged is called when the page favicon changes.
// The parameter is a *gdk.Texture (passed as Texture interface to avoid GTK import in port layer).
OnFaviconChanged func(favicon Texture)
// OnClose is called when the WebView requests to close.
OnClose func()
// OnCreate is called when a popup window is requested.
// Return a WebView to allow the popup, or nil to block it.
OnCreate func(request PopupRequest) WebView
// OnReadyToShow is called when a popup WebView is ready to display.
OnReadyToShow func()
}
WebViewCallbacks defines callback handlers for WebView events. Implementations should invoke these on the main thread/goroutine.
type WebViewFactory ¶
type WebViewFactory interface {
// Create creates a new WebView instance.
Create(ctx context.Context) (WebView, error)
// CreateRelated creates a WebView that shares session/cookies with parent.
// This is required for popup windows to maintain authentication state.
// Popup WebViews bypass the pool since they must be related to a specific parent.
CreateRelated(ctx context.Context, parentID WebViewID) (WebView, error)
}
WebViewFactory creates new WebView instances. This is used when direct WebView creation is needed without pooling.
type WebViewPool ¶
type WebViewPool interface {
// Acquire obtains a WebView from the pool or creates a new one.
// The context can be used for cancellation.
Acquire(ctx context.Context) (WebView, error)
// Release returns a WebView to the pool for reuse.
// The WebView will be reset to a blank state.
// If the pool is full, the WebView will be destroyed.
Release(wv WebView)
// Prewarm creates WebViews in the background to populate the pool.
// Pass count <= 0 to use the default prewarm count.
Prewarm(count int)
// Size returns the current number of available WebViews in the pool.
Size() int
// Close shuts down the pool and destroys all pooled WebViews.
Close()
}
WebViewPool defines the port interface for WebView pooling. Pools maintain pre-created WebViews for fast tab creation.
type WebViewState ¶
type WebViewState struct {
URI string
Title string
IsLoading bool
Progress float64 // 0.0 to 1.0
CanGoBack bool
CanGoFwd bool
ZoomLevel float64
}
WebViewState represents a snapshot of the current WebView state. This is an immutable struct that can be safely passed between components.