browser

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package browser wraps go-rod with two flavors used by mdoc:

  • Headless: a one-shot headless instance for the print pipeline.
  • AppMode: a chromeless app window pointing at a URL, used by `mdoc open`.

Both share the same chromium discovery logic (packaged in the user cache directory, with a system Chromium as fallback).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveBinary

func ResolveBinary() (string, error)

ResolveBinary returns the chromium binary path: prefers the packaged copy under <UserCacheDir>/mdoc/chromium, falls back to a system Chromium found via launcher.LookPath().

Types

type Browser

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

Browser is a thin handle around a go-rod browser + initial page.

func AppMode

func AppMode(url string) (*Browser, error)

AppMode starts Chromium in chromeless --app=<url> mode (no tab strip, no URL bar) so the preview window looks like a desktop app.

func Headless

func Headless() (*Browser, error)

Headless starts a headless Chromium with a single blank page.

func (*Browser) Close

func (b *Browser) Close()

Close shuts down the browser process.

func (*Browser) Page

func (b *Browser) Page() *rod.Page

Page returns the initial page/tab created with the browser.

func (*Browser) RodBrowser

func (b *Browser) RodBrowser() *rod.Browser

RodBrowser exposes the underlying go-rod browser for callers that need to wait on browser-level events (e.g. detecting the user closing an app-mode window).

type InstallResult

type InstallResult struct {
	// BinPath is the absolute path of the Chromium executable.
	BinPath string
	// Revision is the Chromium revision that ended up installed.
	Revision int
	// Downloaded is true when this call actually fetched and unpacked a
	// new Chromium; false when a compatible one was already in the cache.
	Downloaded bool
}

InstallResult describes the outcome of an Install call.

func Install

func Install(revision int, logger utils.Logger) (*InstallResult, error)

Install downloads a Chromium snapshot into <UserCacheDir>/mdoc/chromium. If revision is < 0, the latest revision known to go-rod is used. When a compatible binary is already present nothing is downloaded.

If logger is non-nil it receives go-rod's fetchup events (Download:, Progress:, Downloaded:, Unzip:) for the CLI to render its own UI.

Jump to

Keyboard shortcuts

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