bootstrap

package
v0.23.2 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package bootstrap provides initialization utilities for the browser.

Package bootstrap provides initialization utilities for the browser.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckMediaRequirements added in v0.22.0

func CheckMediaRequirements(ctx context.Context, cfg *config.Config) error

CheckMediaRequirements verifies GStreamer and media codec availability. Returns error if media subsystem initialization fails.

func CheckRuntimeRequirements added in v0.22.0

func CheckRuntimeRequirements(ctx context.Context, cfg *config.Config) error

CheckRuntimeRequirements verifies WebKitGTK and other runtime dependencies. Returns error if requirements are not met; caller should log details and exit. Note: When running in a Flatpak sandbox, runtime checks are skipped because the Flatpak runtime provides all required libraries.

func CreateLazyDatabase added in v0.22.0

func CreateLazyDatabase() (*sqlite.LazyDB, error)

CreateLazyDatabase creates a lazy database provider that defers initialization. The database is initialized on first access, allowing the UI to render faster.

Currently unused: the application uses OpenDatabase with RunParallelDBWebKit for eager initialization. This function is kept for potential future use when lazy initialization past first paint becomes beneficial.

Types

type BrowserSession

type BrowserSession struct {
	Session    *entity.Session
	Logger     zerolog.Logger
	LogCleanup func()

	Persist func(context.Context) error
	End     func(context.Context) error
}

func StartBrowserSession

func StartBrowserSession(
	ctx context.Context,
	cfg *config.Config,
	sessionRepo repository.SessionRepository,
	deferPersist bool,
) (*BrowserSession, context.Context, error)

type DatabaseResult added in v0.22.0

type DatabaseResult struct {
	DB      *sql.DB
	Cleanup func()
}

DatabaseResult holds database connection and cleanup function.

func OpenDatabase added in v0.22.0

func OpenDatabase(ctx context.Context) (*DatabaseResult, error)

OpenDatabase opens and initializes the SQLite database using XDG paths. Returns error if database cannot be opened or migrations fail.

type DeferredInitInput added in v0.22.0

type DeferredInitInput struct {
	Ctx    context.Context
	Config *config.Config
}

DeferredInitInput holds the input for deferred initialization.

type DeferredInitResult added in v0.22.0

type DeferredInitResult struct {
	RuntimeErr error
	MediaErr   error
	SQLiteErr  error
	Duration   time.Duration
}

DeferredInitResult holds results from deferred initialization checks.

func RunDeferredInit added in v0.22.0

func RunDeferredInit(input DeferredInitInput) DeferredInitResult

RunDeferredInit runs deferred initialization checks off the critical path. This includes SQLite WASM precompile, runtime requirements, and media checks.

type ParallelDBWebKitInput added in v0.22.0

type ParallelDBWebKitInput struct {
	Ctx           context.Context
	Config        *config.Config
	DataDir       string // For WebKit context
	CacheDir      string // For WebKit cache
	ThemeManager  *theme.Manager
	ColorResolver port.ColorSchemeResolver
}

ParallelDBWebKitInput holds inputs for parallel DB and WebKit initialization.

type ParallelDBWebKitResult added in v0.22.0

type ParallelDBWebKitResult struct {
	DB        *sql.DB
	DBCleanup func()
	Stack     WebKitStack
}

ParallelDBWebKitResult holds results from parallel DB and WebKit initialization.

func RunParallelDBWebKit added in v0.22.0

func RunParallelDBWebKit(input ParallelDBWebKitInput) (*ParallelDBWebKitResult, error)

RunParallelDBWebKit initializes database in background while WebKit runs on main thread. Database init happens in goroutine (pure Go/WASM), WebKit must stay on main thread (GTK). This saves ~150ms by overlapping DB migrations with WebKit context creation.

type ParallelInitInput added in v0.22.0

type ParallelInitInput struct {
	Ctx    context.Context
	Config *config.Config
}

ParallelInitInput holds the input for parallel initialization.

type ParallelInitResult added in v0.22.0

type ParallelInitResult struct {
	DataDir         string
	CacheDir        string
	ThemeManager    *theme.Manager
	ColorResolver   port.ColorSchemeResolver
	AdwaitaDetector *colorscheme.AdwaitaDetector
	Duration        time.Duration
}

ParallelInitResult holds the results of parallel initialization phase.

func RunParallelInit added in v0.22.0

func RunParallelInit(input ParallelInitInput) (*ParallelInitResult, error)

RunParallelInit runs the essential parallel initialization phase. This includes directory resolution, color scheme resolver creation, and theme creation. Returns the first fatal error encountered, or nil with the results.

type RuntimeRequirementsError added in v0.22.0

type RuntimeRequirementsError struct {
	Checks []usecase.RuntimeDependencyStatus
}

RuntimeRequirementsError contains details about missing runtime dependencies.

func (*RuntimeRequirementsError) Error added in v0.22.0

func (*RuntimeRequirementsError) LogDetails added in v0.22.0

func (e *RuntimeRequirementsError) LogDetails(ctx context.Context)

LogDetails logs detailed information about missing dependencies.

type StartupTimer added in v0.22.0

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

StartupTimer tracks timing for cold start phases. Thread-safe for use with parallel initialization.

func NewStartupTimer added in v0.22.0

func NewStartupTimer() *StartupTimer

NewStartupTimer creates a new timer starting from now.

func (*StartupTimer) Log added in v0.22.0

func (t *StartupTimer) Log(ctx context.Context)

Log outputs all timing information to the context logger.

func (*StartupTimer) LogDebug added in v0.22.0

func (t *StartupTimer) LogDebug(ctx context.Context)

LogDebug outputs timing as debug level (for less verbose production logs).

func (*StartupTimer) Mark added in v0.22.0

func (t *StartupTimer) Mark(phase string)

Mark records the duration since the last mark (or start) for the given phase.

func (*StartupTimer) MarkDuration added in v0.22.0

func (t *StartupTimer) MarkDuration(phase string, d time.Duration)

MarkDuration records a specific duration for a phase. Useful for operations timed independently (e.g., parallel goroutines).

func (*StartupTimer) Total added in v0.22.0

func (t *StartupTimer) Total() time.Duration

Total returns the total elapsed time since timer creation. Thread-safe: uses mutex for memory visibility guarantees.

type WebKitStack

type WebKitStack struct {
	Context       *webkit.WebKitContext
	Settings      *webkit.SettingsManager
	Injector      *webkit.ContentInjector
	MessageRouter *webkit.MessageRouter
	Pool          *webkit.WebViewPool
	FilterManager *filtering.Manager
}

func BuildWebKitStack

func BuildWebKitStack(input WebKitStackInput) WebKitStack

type WebKitStackInput added in v0.23.0

type WebKitStackInput struct {
	Ctx           context.Context
	Config        *config.Config
	DataDir       string
	CacheDir      string
	ThemeManager  *theme.Manager
	ColorResolver port.ColorSchemeResolver
	Logger        zerolog.Logger
}

WebKitStackInput holds the input for BuildWebKitStack.

Jump to

Keyboard shortcuts

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