browser

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package browser manages headless Chrome/Chromium for rendering themes.

Package browser - headless rendering using Chrome DevTools Protocol.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnsupportedPlatform is returned for unsupported OS/arch combinations.
	ErrUnsupportedPlatform = errors.New("unsupported platform")
	// ErrBrowserNotFound is returned when the browser binary is not found.
	ErrBrowserNotFound = errors.New("browser not found")
	// ErrDownloadFailed is returned when browser download fails.
	ErrDownloadFailed = errors.New("browser download failed")
)

Functions

func BrowserPath

func BrowserPath() (string, error)

BrowserPath returns the path to the Chrome binary if installed.

func Download

func Download(ctx context.Context, progress func(downloaded, total int64)) error

Download downloads and installs Chrome for Testing.

func GetChromePath

func GetChromePath() (string, error)

GetChromePath returns the path to Chrome, preferring cached version. Falls back to system Chrome if cached version is not available.

func IsInstalled

func IsInstalled() bool

IsInstalled checks if Chrome is installed in the cache directory.

func Remove

func Remove() error

Remove removes the cached browser.

func SystemChromePath

func SystemChromePath() (string, error)

SystemChromePath tries to find a system-installed Chrome/Chromium.

func Version

func Version() string

Version returns the version of Chrome for Testing being used.

Types

type Renderer

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

Renderer manages a headless Chrome instance for rendering themes.

func NewRenderer

func NewRenderer(width, height int) (*Renderer, error)

NewRenderer creates a new headless browser renderer.

func (*Renderer) Capture

func (r *Renderer) Capture() (image.Image, error)

Capture takes a screenshot and returns it as an image.

func (*Renderer) CaptureToFile

func (r *Renderer) CaptureToFile(path string) error

CaptureToFile takes a screenshot and saves it to a file.

func (*Renderer) SendSensorData

func (r *Renderer) SendSensorData(jsonData string) error

SendSensorData sends sensor data to the theme via JavaScript.

func (*Renderer) ServerPort

func (r *Renderer) ServerPort() int

ServerPort returns the port the theme server is running on.

func (*Renderer) Start

func (r *Renderer) Start(ctx context.Context, themeDistDir string) error

Start starts the headless browser and serves the theme.

func (*Renderer) Stop

func (r *Renderer) Stop()

Stop stops the renderer and cleans up.

Jump to

Keyboard shortcuts

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