services

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package services contains application services that orchestrate business logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ZoomKeyForLog

func ZoomKeyForLog(raw string) string

ZoomKeyForLog exposes the derived zoom key (host or raw URL) for logging from other packages.

Types

type BrowserService

type BrowserService struct {
	// contains filtered or unexported fields
}

BrowserService handles browser-related operations for the built-in browser.

func NewBrowserService

func NewBrowserService(cfg *config.Config, queries db.DatabaseQuerier) *BrowserService

NewBrowserService creates a new BrowserService instance.

func (*BrowserService) AttachWebView

func (s *BrowserService) AttachWebView(view *webkit.WebView)

AttachWebView connects a native WebKit WebView to this service for integration.

func (*BrowserService) ClearHistory

func (s *BrowserService) ClearHistory(ctx context.Context) error

ClearHistory removes all history entries.

func (*BrowserService) CopyCurrentURL

func (s *BrowserService) CopyCurrentURL(ctx context.Context, url string) error

CopyCurrentURL copies the current URL to clipboard (frontend-initiated)

func (*BrowserService) DeleteHistoryEntry

func (s *BrowserService) DeleteHistoryEntry(ctx context.Context, id int64) error

DeleteHistoryEntry removes a specific history entry.

func (*BrowserService) GetConfig

func (s *BrowserService) GetConfig(ctx context.Context) (*config.Config, error)

GetConfig returns the current browser configuration.

func (*BrowserService) GetCurrentURL

func (s *BrowserService) GetCurrentURL(ctx context.Context) (string, error)

GetCurrentURL returns the current URL (this would be implemented by the frontend)

func (*BrowserService) GetGUIBundle

func (s *BrowserService) GetGUIBundle() string

GetGUIBundle returns the loaded GUI bundle string

func (*BrowserService) GetHistoryStats

func (s *BrowserService) GetHistoryStats(ctx context.Context) (map[string]interface{}, error)

GetHistoryStats returns statistics about browser history.

func (*BrowserService) GetInitialURL

func (s *BrowserService) GetInitialURL(ctx context.Context) (string, error)

GetInitialURL returns the initially navigated URL for frontend synchronization

func (*BrowserService) GetRecentHistory

func (s *BrowserService) GetRecentHistory(ctx context.Context, limit int) ([]HistoryEntry, error)

GetRecentHistory returns recent browser history entries.

func (*BrowserService) GetRecentHistoryWithOffset

func (s *BrowserService) GetRecentHistoryWithOffset(ctx context.Context, limit, offset int) ([]HistoryEntry, error)

GetRecentHistoryWithOffset returns recent browser history entries with pagination support.

func (*BrowserService) GetSearchShortcuts

func (s *BrowserService) GetSearchShortcuts(ctx context.Context) (map[string]config.SearchShortcut, error)

GetSearchShortcuts returns available search shortcuts.

func (*BrowserService) GetZoomLevel

func (s *BrowserService) GetZoomLevel(ctx context.Context, url string) (float64, error)

GetZoomLevel retrieves the saved zoom level for a URL.

func (*BrowserService) GoBack

func (s *BrowserService) GoBack(ctx context.Context) error

GoBack provides navigation back functionality

func (*BrowserService) GoForward

func (s *BrowserService) GoForward(ctx context.Context) error

GoForward provides navigation forward functionality

func (*BrowserService) InjectGUIBundle

func (s *BrowserService) InjectGUIBundle(ctx context.Context) error

InjectGUIBundle injects the unified GUI bundle and initializes controls

func (*BrowserService) InjectToastSystem

func (s *BrowserService) InjectToastSystem(ctx context.Context, theme string) error

InjectToastSystem injects the GUI bundle and initializes the toast system

func (*BrowserService) LoadGUIBundle

func (s *BrowserService) LoadGUIBundle(assets embed.FS) error

LoadGUIBundle loads the unified GUI bundle from assets

func (*BrowserService) Navigate

func (s *BrowserService) Navigate(ctx context.Context, url string) (*NavigationResult, error)

Navigate handles navigation to a URL and records it in history.

func (*BrowserService) ResetZoom

func (s *BrowserService) ResetZoom(ctx context.Context, url string) (float64, error)

ResetZoom resets the zoom level to 1.0 for the current URL.

func (*BrowserService) SearchHistory

func (s *BrowserService) SearchHistory(ctx context.Context, query string, limit int) ([]HistoryEntry, error)

SearchHistory searches browser history.

func (*BrowserService) ServiceName

func (s *BrowserService) ServiceName() string

ServiceName returns the service name for frontend binding

func (*BrowserService) SetWindowTitleUpdater

func (s *BrowserService) SetWindowTitleUpdater(updater WindowTitleUpdater)

SetWindowTitleUpdater sets the window title updater interface

func (*BrowserService) SetZoomLevel

func (s *BrowserService) SetZoomLevel(ctx context.Context, url string, zoomLevel float64) error

SetZoomLevel sets the zoom level for a URL.

func (*BrowserService) UpdateConfig

func (s *BrowserService) UpdateConfig(ctx context.Context, newConfig *config.Config) error

UpdateConfig updates the browser configuration.

func (*BrowserService) UpdatePageTitle

func (s *BrowserService) UpdatePageTitle(ctx context.Context, url, title string) error

UpdatePageTitle updates the title of the current page in history and the window title.

func (*BrowserService) ZoomIn

func (s *BrowserService) ZoomIn(ctx context.Context, url string) (float64, error)

ZoomIn increases the zoom level to the next Firefox zoom level.

func (*BrowserService) ZoomOut

func (s *BrowserService) ZoomOut(ctx context.Context, url string) (float64, error)

ZoomOut decreases the zoom level to the previous Firefox zoom level.

type DatabaseHistoryProvider

type DatabaseHistoryProvider struct {
	// contains filtered or unexported fields
}

DatabaseHistoryProvider implements HistoryProvider using the database.

func (*DatabaseHistoryProvider) GetAllHistory

func (h *DatabaseHistoryProvider) GetAllHistory() ([]*db.History, error)

GetAllHistory returns all history entries for fuzzy search.

func (*DatabaseHistoryProvider) GetHistoryByURL

func (h *DatabaseHistoryProvider) GetHistoryByURL(url string) (*db.History, error)

GetHistoryByURL retrieves history entry by exact URL match.

func (*DatabaseHistoryProvider) GetRecentHistory

func (h *DatabaseHistoryProvider) GetRecentHistory(limit int) ([]*db.History, error)

GetRecentHistory returns recent history entries limited by count.

func (*DatabaseHistoryProvider) SearchHistory

func (h *DatabaseHistoryProvider) SearchHistory(query string, limit int) ([]*db.History, error)

SearchHistory performs a basic text search in history.

type HistoryEntry

type HistoryEntry struct {
	ID          int64     `json:"id"`
	URL         string    `json:"url"`
	Title       string    `json:"title"`
	FaviconURL  string    `json:"favicon_url"`
	VisitCount  int32     `json:"visit_count"`
	LastVisited time.Time `json:"last_visited"`
	CreatedAt   time.Time `json:"created_at"`
}

HistoryEntry represents a simplified history entry for frontend.

type NavigationResult struct {
	URL           string        `json:"url"`
	Title         string        `json:"title"`
	Success       bool          `json:"success"`
	Error         string        `json:"error,omitempty"`
	LoadTime      time.Duration `json:"load_time"`
	RedirectChain []string      `json:"redirect_chain,omitempty"`
}

NavigationResult represents the result of a navigation operation.

type ParserService

type ParserService struct {
	// contains filtered or unexported fields
}

ParserService wraps the parser functionality for the application.

func NewParserService

func NewParserService(cfg *config.Config, queries *db.Queries) *ParserService

NewParserService creates a new ParserService instance.

func (*ParserService) CalculateSimilarity

func (s *ParserService) CalculateSimilarity(ctx context.Context, s1, s2 string) (float64, error)

CalculateSimilarity calculates similarity between two strings.

func (*ParserService) FuzzySearchHistory

func (s *ParserService) FuzzySearchHistory(
	ctx context.Context, query string, threshold float64,
) ([]parser.FuzzyMatch, error)

FuzzySearchHistory performs fuzzy search on history entries.

func (*ParserService) GetCompletions

func (s *ParserService) GetCompletions(ctx context.Context, input string, limit int) ([]string, error)

GetCompletions provides URL/search completions based on input.

func (*ParserService) GetFuzzyConfig

func (s *ParserService) GetFuzzyConfig(ctx context.Context) (*parser.FuzzyConfig, error)

GetFuzzyConfig returns current fuzzy matching configuration.

func (*ParserService) GetSupportedShortcuts

func (s *ParserService) GetSupportedShortcuts(ctx context.Context) (map[string]config.SearchShortcut, error)

GetSupportedShortcuts returns configured search shortcuts.

func (*ParserService) ParseInput

func (s *ParserService) ParseInput(ctx context.Context, input string) (*parser.ParseResult, error)

ParseInput parses user input and returns navigation result.

func (*ParserService) PreviewParse

func (s *ParserService) PreviewParse(ctx context.Context, input string) (*parser.ParseResult, error)

PreviewParse provides a preview of what ParseInput would return.

func (*ParserService) ProcessShortcut

func (s *ParserService) ProcessShortcut(ctx context.Context, shortcut, query string) (string, error)

ProcessShortcut processes a shortcut and returns the resulting URL.

func (*ParserService) UpdateFuzzyConfig

func (s *ParserService) UpdateFuzzyConfig(ctx context.Context, config *parser.FuzzyConfig) error

UpdateFuzzyConfig updates the fuzzy matching configuration.

func (*ParserService) ValidateURL

func (s *ParserService) ValidateURL(ctx context.Context, input string) (bool, error)

ValidateURL checks if the input represents a valid URL.

type WindowTitleUpdater

type WindowTitleUpdater interface {
	SetTitle(title string)
}

WindowTitleUpdater interface allows the service to update the window title Decoupled from any specific GUI framework.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL