Documentation
¶
Overview ¶
Package entity defines domain entities for the browser.
Package entity contains domain entities representing core business concepts. These entities are pure Go types with no infrastructure dependencies.
Package entity defines domain entities for dumber.
Index ¶
- Constants
- Variables
- func CanPersist(permType PermissionType) bool
- func GetAccents(char rune, uppercase bool) []rune
- func HasAccents(char rune) bool
- func IsAutoAllow(permType PermissionType) bool
- func PermissionTypesToStrings(types []PermissionType) []string
- type ConfigKeyInfo
- type DailyVisitCount
- type DomainStat
- type Favorite
- type FavoriteID
- type FavoriteTree
- type Folder
- type FolderID
- type HistoryAnalytics
- type HistoryEntry
- type HistoryMatch
- type HistoryStats
- type HourlyDistribution
- type IDGenerator
- type Pane
- type PaneID
- type PaneNode
- func (n *PaneNode) ActivePane() *PaneNode
- func (n *PaneNode) FindPane(id PaneID) *PaneNode
- func (n *PaneNode) IsContainer() bool
- func (n *PaneNode) IsLeaf() bool
- func (n *PaneNode) IsSplit() bool
- func (n *PaneNode) LeafCount() int
- func (n *PaneNode) Left() *PaneNode
- func (n *PaneNode) Right() *PaneNode
- func (n *PaneNode) StackedPanes() []*PaneNode
- func (n *PaneNode) VisibleAreaCount() int
- func (n *PaneNode) Walk(fn func(*PaneNode) bool)
- type PaneNodeSnapshot
- type PaneRect
- type PaneSnapshot
- type PermissionDecision
- type PermissionRecord
- type PermissionSet
- type PermissionType
- type PurgeResult
- type PurgeTarget
- type PurgeTargetType
- type Session
- type SessionID
- type SessionInfo
- type SessionPurgeItem
- type SessionState
- type SessionType
- type SplitDirection
- type Tab
- type TabID
- type TabList
- func (tl *TabList) ActiveTab() *Tab
- func (tl *TabList) Add(tab *Tab)
- func (tl *TabList) Count() int
- func (tl *TabList) Find(id TabID) *Tab
- func (tl *TabList) Move(id TabID, newPos int) bool
- func (tl *TabList) Remove(id TabID) bool
- func (tl *TabList) ReplaceFrom(other *TabList)
- func (tl *TabList) SetActive(id TabID)
- func (tl *TabList) TabAt(index int) *Tab
- type TabSnapshot
- type Tag
- type TagID
- type UpdateInfo
- type UpdateStatus
- type WindowType
- type Workspace
- type WorkspaceID
- type WorkspaceSnapshot
- type ZoomLevel
Constants ¶
const ( ZoomDefault = 1.0 ZoomMin = 0.25 // 25% ZoomMax = 5.0 // 500% ZoomStep = 0.1 // 10% increments )
Default zoom constants
const SessionStateVersion = 1
SessionStateVersion is the current schema version for session state. Increment when making breaking changes to the serialization format.
Variables ¶
var AccentMap = map[rune][]rune{
'a': {'à', 'á', 'â', 'ä', 'ã', 'å', 'æ'},
'c': {'ç', 'ć', 'č'},
'e': {'è', 'é', 'ê', 'ë', 'ę', 'ė'},
'i': {'ì', 'í', 'î', 'ï', 'į'},
'n': {'ñ', 'ń'},
'o': {'ò', 'ó', 'ô', 'ö', 'õ', 'ø', 'œ'},
's': {'ß', 'ś', 'š'},
'u': {'ù', 'ú', 'û', 'ü', 'ū'},
'y': {'ÿ', 'ý'},
}
AccentMap maps base characters to their accented variants. The order determines display order in the accent picker.
var ErrInvalidSession = errors.New("invalid session")
Functions ¶
func CanPersist ¶ added in v0.27.0
func CanPersist(permType PermissionType) bool
CanPersist returns true if this permission type can be persisted. Per W3C spec, display capture permissions cannot be persisted.
func GetAccents ¶ added in v0.23.0
GetAccents returns the accent variants for a character. If uppercase is true, returns uppercase variants. Returns nil if the character has no accent variants.
func HasAccents ¶ added in v0.23.0
HasAccents returns true if the given character has accent variants.
func IsAutoAllow ¶ added in v0.27.0
func IsAutoAllow(permType PermissionType) bool
IsAutoAllow returns true if this permission type should be auto-allowed.
func PermissionTypesToStrings ¶ added in v0.27.0
func PermissionTypesToStrings(types []PermissionType) []string
PermissionTypesToStrings converts permission types to strings for logging.
Types ¶
type ConfigKeyInfo ¶ added in v0.22.0
type ConfigKeyInfo struct {
// Key is the full dotted path to the config key (e.g., "appearance.color_scheme")
Key string `json:"key"`
// Type is the Go type name (e.g., "string", "int", "bool", "float64")
Type string `json:"type"`
// Default is the default value as a string representation
Default string `json:"default"`
// Description explains the purpose of this config key
Description string `json:"description"`
// Values contains valid enum values (for string enums)
// Empty if not an enum type
Values []string `json:"values,omitempty"`
// Range describes numeric constraints (e.g., "1-72", "0.1-5.0")
// Empty if no range constraint
Range string `json:"range,omitempty"`
// Section groups related keys (e.g., "Appearance", "Logging")
Section string `json:"section"`
}
ConfigKeyInfo describes a single configuration key for schema documentation.
type DailyVisitCount ¶
type DailyVisitCount struct {
Day string `json:"day"`
Entries int64 `json:"entries"`
Visits int64 `json:"visits"`
}
DailyVisitCount contains visit counts by day.
type DomainStat ¶
type DomainStat struct {
Domain string `json:"domain"`
PageCount int64 `json:"page_count"`
TotalVisits int64 `json:"total_visits"`
LastVisit time.Time `json:"last_visit"`
}
DomainStat contains per-domain visit statistics.
type Favorite ¶
type Favorite struct {
ID FavoriteID `json:"id"`
URL string `json:"url"`
Title string `json:"title"`
FaviconURL string `json:"favicon_url"`
FolderID *FolderID `json:"folder_id"` // nil = root level
ShortcutKey *int `json:"shortcut_key"` // 1-9 for quick access (Alt+1 through Alt+9)
Position int `json:"position"` // Order within folder
Tags []Tag `json:"tags,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Favorite represents a bookmarked URL.
func NewFavorite ¶
NewFavorite creates a new favorite for a URL.
func (*Favorite) HasShortcut ¶
HasShortcut returns true if this favorite has a keyboard shortcut.
type FavoriteTree ¶
type FavoriteTree struct {
RootFolders []*Folder
RootFavorites []*Favorite
FolderMap map[FolderID]*Folder // Quick lookup
ChildFolders map[FolderID][]*Folder // Children of each folder
ChildFavorites map[FolderID][]*Favorite // Favorites in each folder
}
FavoriteTree represents a hierarchical view of folders and favorites.
func NewFavoriteTree ¶
func NewFavoriteTree() *FavoriteTree
NewFavoriteTree creates an empty favorite tree.
type Folder ¶
type Folder struct {
ID FolderID `json:"id"`
Name string `json:"name"`
Icon string `json:"icon"` // Optional icon identifier
ParentID *FolderID `json:"parent_id"` // nil = root level
Position int `json:"position"` // Order within parent
CreatedAt time.Time `json:"created_at"`
}
Folder represents a container for organizing favorites.
type HistoryAnalytics ¶
type HistoryAnalytics struct {
TotalEntries int64 `json:"total_entries"`
TotalVisits int64 `json:"total_visits"`
UniqueDays int64 `json:"unique_days"`
TopDomains []*DomainStat `json:"top_domains"`
DailyVisits []*DailyVisitCount `json:"daily_visits"`
HourlyDistribution []*HourlyDistribution `json:"hourly_distribution"`
}
HistoryAnalytics contains all analytics data for the homepage.
type HistoryEntry ¶
type HistoryEntry struct {
ID int64 `json:"id"`
URL string `json:"url"`
Title string `json:"title"`
FaviconURL string `json:"favicon_url"`
VisitCount int64 `json:"visit_count"`
LastVisited time.Time `json:"last_visited"`
CreatedAt time.Time `json:"created_at"`
}
HistoryEntry represents a visited URL in browsing history.
func NewHistoryEntry ¶
func NewHistoryEntry(url, title string) *HistoryEntry
NewHistoryEntry creates a new history entry for a URL.
func (*HistoryEntry) IncrementVisit ¶
func (h *HistoryEntry) IncrementVisit()
IncrementVisit updates the entry for a new visit.
type HistoryMatch ¶
type HistoryMatch struct {
Entry *HistoryEntry
Score float64 // Match score (higher is better)
}
HistoryMatch represents a history entry that matched a search query. Used for fuzzy search results with scoring.
type HistoryStats ¶
type HistoryStats struct {
TotalEntries int64 `json:"total_entries"`
TotalVisits int64 `json:"total_visits"`
UniqueDays int64 `json:"unique_days"`
}
HistoryStats contains aggregated history statistics.
type HourlyDistribution ¶
HourlyDistribution contains visit counts by hour of day.
type IDGenerator ¶ added in v0.21.0
type IDGenerator func() string
IDGenerator is a function that generates unique IDs.
type Pane ¶
type Pane struct {
ID PaneID
URI string
Title string
FaviconURL string
WindowType WindowType
ZoomFactor float64
CanGoBack bool
CanForward bool
IsLoading bool
CreatedAt time.Time
// Popup-specific fields
IsRelated bool // Shares context with parent
ParentPaneID *PaneID // Parent pane if this is a related popup
AutoClose bool // Auto-close on OAuth success
RequestID string // Request ID for popup tracking
}
Pane represents a single browsing context (a WebView container). This is the leaf-level entity that holds navigation state.
type PaneNode ¶
type PaneNode struct {
ID string
Pane *Pane // Non-nil for leaf nodes
Parent *PaneNode // nil for root
Children []*PaneNode
// Layout
SplitDir SplitDirection
SplitRatio float64 // 0.0-1.0, position of divider
// Stacked panes (alternative to split)
IsStacked bool
ActiveStackIndex int
}
PaneNode represents a node in the workspace pane tree structure. It can be either:
- Leaf node: Contains a single Pane
- Split node: Contains two children (left/right or top/bottom)
- Stacked node: Contains multiple panes in a tabbed view
func (*PaneNode) ActivePane ¶
ActivePane returns the currently visible pane in a stacked container.
func (*PaneNode) IsContainer ¶
IsContainer returns true if this is a split or stacked container.
func (*PaneNode) StackedPanes ¶
StackedPanes returns the list of panes if this is a stacked container.
func (*PaneNode) VisibleAreaCount ¶ added in v0.25.0
VisibleAreaCount returns the number of visible pane areas in the tree. A stacked node counts as 1 visible area (only one pane visible at a time). A leaf node counts as 1 visible area. A split node's visible areas are the sum of its children's visible areas.
type PaneNodeSnapshot ¶ added in v0.21.0
type PaneNodeSnapshot struct {
ID string `json:"id"`
Pane *PaneSnapshot `json:"pane,omitempty"` // Non-nil for leaf nodes
Children []*PaneNodeSnapshot `json:"children,omitempty"` // Non-nil for containers
SplitDir SplitDirection `json:"split_dir"`
SplitRatio float64 `json:"split_ratio"`
IsStacked bool `json:"is_stacked"`
ActiveStackIndex int `json:"active_stack_index"`
}
PaneNodeSnapshot captures a node in the pane tree.
type PaneRect ¶
type PaneRect struct {
PaneID PaneID
X, Y int // Top-left position relative to workspace container
W, H int // Width and height
}
PaneRect represents a pane's screen position and size. Used for geometric navigation to find adjacent panes by position.
func (PaneRect) OverlapsHorizontally ¶ added in v0.24.0
OverlapsHorizontally returns true if the two rectangles overlap in the X axis. Used for up/down navigation to prefer panes at the same horizontal level.
func (PaneRect) OverlapsVertically ¶ added in v0.24.0
OverlapsVertically returns true if the two rectangles overlap in the Y axis. Used for left/right navigation to prefer panes at the same vertical level.
type PaneSnapshot ¶ added in v0.21.0
type PaneSnapshot struct {
ID PaneID `json:"id"`
URI string `json:"uri"`
Title string `json:"title"`
ZoomFactor float64 `json:"zoom_factor"`
}
PaneSnapshot captures the essential state of a pane.
type PermissionDecision ¶ added in v0.27.0
type PermissionDecision string
PermissionDecision represents the user's decision for a permission.
const ( // PermissionGranted means the permission was allowed. PermissionGranted PermissionDecision = "granted" // PermissionDenied means the permission was denied. PermissionDenied PermissionDecision = "denied" // PermissionPrompt means no decision has been made yet (default state). PermissionPrompt PermissionDecision = "prompt" )
type PermissionRecord ¶ added in v0.27.0
type PermissionRecord struct {
Origin string // The origin (domain) this permission applies to
Type PermissionType // The type of permission
Decision PermissionDecision // The decision: granted, denied, or prompt
UpdatedAt int64 // Unix timestamp in seconds when this record was last updated
}
PermissionRecord stores a permission decision for a specific origin and type.
func (*PermissionRecord) IsDenied ¶ added in v0.27.0
func (p *PermissionRecord) IsDenied() bool
IsDenied returns true if the permission is denied.
func (*PermissionRecord) IsGranted ¶ added in v0.27.0
func (p *PermissionRecord) IsGranted() bool
IsGranted returns true if the permission is granted.
type PermissionSet ¶ added in v0.27.0
type PermissionSet struct {
Types []PermissionType
Decision PermissionDecision
}
PermissionSet represents multiple permission decisions for a single request. This is used when handling combined permission requests (e.g., mic + camera).
type PermissionType ¶ added in v0.27.0
type PermissionType string
PermissionType represents the type of permission being requested.
const ( // PermissionTypeMicrophone represents microphone access permission. PermissionTypeMicrophone PermissionType = "microphone" // PermissionTypeCamera represents camera access permission. PermissionTypeCamera PermissionType = "camera" // PermissionTypeDisplay represents screen sharing/display capture permission. PermissionTypeDisplay PermissionType = "display" // PermissionTypeDeviceInfo represents device enumeration permission. PermissionTypeDeviceInfo PermissionType = "device_info" // PermissionTypeClipboard represents clipboard access permission. PermissionTypeClipboard PermissionType = "clipboard" // PermissionTypeNotification represents notification permission. PermissionTypeNotification PermissionType = "notification" // PermissionTypeGeolocation represents geolocation permission. PermissionTypeGeolocation PermissionType = "geolocation" // PermissionTypePointerLock represents pointer lock permission. PermissionTypePointerLock PermissionType = "pointer_lock" // PermissionTypeMediaKeySystem represents DRM/media key system permission. PermissionTypeMediaKeySystem PermissionType = "media_key_system" // PermissionTypeWebsiteDataAccess represents 3rd party cookie/data access permission. PermissionTypeWebsiteDataAccess PermissionType = "website_data_access" )
type PurgeResult ¶
type PurgeResult struct {
Target PurgeTarget
Success bool
Error error
}
PurgeResult represents the outcome of purging a single target.
type PurgeTarget ¶
type PurgeTarget struct {
Type PurgeTargetType
Path string
Description string
Size int64
Exists bool
}
PurgeTarget represents something that can be purged.
type PurgeTargetType ¶
type PurgeTargetType int
PurgeTargetType identifies what kind of purgeable item this is.
const ( PurgeTargetConfig PurgeTargetType = iota PurgeTargetData PurgeTargetState PurgeTargetCache PurgeTargetFilterJSON PurgeTargetFilterStore PurgeTargetFilterCache PurgeTargetDesktopFile PurgeTargetIcon )
type Session ¶
Session captures metadata about a dumber run. A browser session is expected to have a corresponding log file.
type SessionID ¶
type SessionID string
SessionID uniquely identifies an application session. For now it matches the log session ID format (YYYYMMDD_HHMMSS_xxxx).
type SessionInfo ¶ added in v0.21.0
type SessionInfo struct {
Session *Session
State *SessionState
TabCount int
PaneCount int
IsActive bool // Has active lock file
IsCurrent bool // Is the current session
UpdatedAt time.Time // When the state was last saved
}
SessionInfo provides summary information for the session manager UI.
type SessionPurgeItem ¶ added in v0.21.0
type SessionPurgeItem struct {
Info SessionInfo
Selected bool
}
SessionPurgeItem represents an inactive session in the purge selection UI.
type SessionState ¶ added in v0.21.0
type SessionState struct {
Version int `json:"version"`
SessionID SessionID `json:"session_id"`
Tabs []TabSnapshot `json:"tabs"`
ActiveTabIndex int `json:"active_tab_index"`
SavedAt time.Time `json:"saved_at"`
}
SessionState represents a complete snapshot of a browser session. This is serialized to JSON and stored in the database.
func SnapshotFromTabList ¶ added in v0.21.0
func SnapshotFromTabList(sessionID SessionID, tabs *TabList) *SessionState
SnapshotFromTabList creates a SessionState from a live TabList.
func (*SessionState) CountPanes ¶ added in v0.21.0
func (s *SessionState) CountPanes() int
CountPanes returns the total number of panes in the session state.
type SessionType ¶
type SessionType string
SessionType distinguishes long-running browser sessions from ephemeral CLI invocations.
const ( SessionTypeBrowser SessionType = "browser" SessionTypeCLI SessionType = "cli" )
type SplitDirection ¶
type SplitDirection int
SplitDirection indicates how a pane container splits its children.
const ( SplitNone SplitDirection = iota // Leaf node or stacked container SplitHorizontal // Left/right split SplitVertical // Top/bottom split )
type Tab ¶
type Tab struct {
ID TabID
Name string // Display name (often derived from active pane title)
Workspace *Workspace // The workspace this tab contains
Position int // Position in the tab bar (0-indexed)
IsPinned bool // Pinned tabs stay at the left
CreatedAt time.Time
}
Tab represents a browser tab containing a workspace. Tabs are the top-level container in the browser's tab bar.
func NewTab ¶
func NewTab(tabID TabID, workspaceID WorkspaceID, initialPane *Pane) *Tab
NewTab creates a new tab with an initial pane.
type TabList ¶
type TabList struct {
Tabs []*Tab
ActiveTabID TabID
PreviousActiveTabID TabID // Tracks last active tab for Alt+Tab style switching
}
TabList manages an ordered collection of tabs.
func TabListFromSnapshot ¶ added in v0.21.0
func TabListFromSnapshot(state *SessionState, idGen IDGenerator) *TabList
TabListFromSnapshot reconstructs a TabList from a SessionState snapshot. Generates new IDs for all entities using the provided generator. This is the inverse of SnapshotFromTabList.
func (*TabList) ReplaceFrom ¶ added in v0.21.0
ReplaceFrom replaces this TabList's contents with those from another TabList. This modifies in-place so existing references to this TabList remain valid.
type TabSnapshot ¶ added in v0.21.0
type TabSnapshot struct {
ID TabID `json:"id"`
Name string `json:"name"`
Position int `json:"position"`
IsPinned bool `json:"is_pinned"`
Workspace WorkspaceSnapshot `json:"workspace"`
}
TabSnapshot captures the state of a single tab.
type Tag ¶
type Tag struct {
ID TagID `json:"id"`
Name string `json:"name"`
Color string `json:"color"` // Hex color code (e.g., "#FF5733")
CreatedAt time.Time `json:"created_at"`
}
Tag represents a label that can be applied to favorites.
type UpdateInfo ¶ added in v0.21.0
type UpdateInfo struct {
// CurrentVersion is the version of the running binary.
CurrentVersion string
// LatestVersion is the latest available version from GitHub.
LatestVersion string
// IsNewer is true if LatestVersion is newer than CurrentVersion.
IsNewer bool
// ReleaseURL is the URL to the GitHub release page.
ReleaseURL string
// DownloadURL is the direct download URL for the binary archive.
DownloadURL string
// PublishedAt is when the release was published.
PublishedAt time.Time
// ReleaseNotes contains the release changelog (optional).
ReleaseNotes string
}
UpdateInfo holds information about an available update.
type UpdateStatus ¶ added in v0.21.0
type UpdateStatus int
UpdateStatus represents the current state of the update process.
const ( // UpdateStatusUnknown means update status hasn't been checked yet. UpdateStatusUnknown UpdateStatus = iota // UpdateStatusUpToDate means the current version is the latest. UpdateStatusUpToDate // UpdateStatusAvailable means a newer version is available. UpdateStatusAvailable // UpdateStatusDownloading means the update is being downloaded. UpdateStatusDownloading // UpdateStatusReady means the update is downloaded and staged for exit. UpdateStatusReady // UpdateStatusFailed means the update check or download failed. UpdateStatusFailed )
func (UpdateStatus) String ¶ added in v0.21.0
func (s UpdateStatus) String() string
String returns a human-readable string for the update status.
type WindowType ¶
type WindowType int
WindowType indicates the type of browser window.
const ( WindowMain WindowType = iota // Regular browser tab WindowPopup // Popup window (OAuth, feature-restricted) )
type Workspace ¶
type Workspace struct {
ID WorkspaceID
Name string
Root *PaneNode // Root of the pane tree
ActivePaneID PaneID // Currently focused pane
CreatedAt time.Time
}
Workspace represents a collection of panes arranged in a tree layout. Each tab contains exactly one workspace.
func NewWorkspace ¶
func NewWorkspace(id WorkspaceID, initialPane *Pane) *Workspace
NewWorkspace creates a new workspace with an initial pane.
func (*Workspace) ActivePane ¶
ActivePane returns the currently active pane node.
func (*Workspace) VisibleAreaCount ¶ added in v0.25.0
VisibleAreaCount returns the number of visible pane areas. Stacked panes count as 1 (only one visible at a time).
type WorkspaceSnapshot ¶ added in v0.21.0
type WorkspaceSnapshot struct {
ID WorkspaceID `json:"id"`
Root *PaneNodeSnapshot `json:"root"`
ActivePaneID PaneID `json:"active_pane_id"`
}
WorkspaceSnapshot captures the pane tree layout.
type ZoomLevel ¶
type ZoomLevel struct {
Domain string // Domain name (e.g., "github.com")
ZoomFactor float64 // Zoom factor (1.0 = 100%, 1.5 = 150%)
UpdatedAt time.Time
}
ZoomLevel represents the zoom factor for a specific domain. Allows users to set persistent zoom levels per-site.
func NewZoomLevel ¶
NewZoomLevel creates a new zoom level for a domain.
func (*ZoomLevel) Percentage ¶
Percentage returns the zoom factor as a percentage (e.g., 150 for 1.5).