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 CacheRoot ¶ added in v0.2.0
func CacheRoot() string
CacheRoot is mdoc's cache namespace, <UserCacheDir>/mdoc, or "" if the cache dir isn't available on this system. Everything under it is regeneratable (the packaged Chromium snapshot lives in the chromium subdir) and safe to delete.
func ResolveBinary ¶
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 ¶
AppMode starts Chromium in chromeless --app=<url> mode (no tab strip, no URL bar) so the preview window looks like a desktop app.
func (*Browser) RodBrowser ¶
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 ChromiumStatus ¶ added in v0.2.0
type ChromiumStatus struct {
Packaged *InstallResult
System string
}
ChromiumStatus reports what mdoc can currently use before doing any downloads.
func DetectChromium ¶ added in v0.2.0
func DetectChromium(revision int) (*ChromiumStatus, error)
DetectChromium checks the packaged cache and system PATH without changing either. If revision is < 0, the latest revision known to go-rod is used for packaged-cache validation.
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.
func InstallFresh ¶ added in v0.2.0
func InstallFresh(revision int, logger utils.Logger) (*InstallResult, error)
InstallFresh downloads a Chromium snapshot even when the managed cache already contains a compatible binary.
func Packaged ¶ added in v0.2.0
func Packaged(revision int) (*InstallResult, error)
Packaged checks whether the managed Chromium snapshot is already installed. It returns nil, nil when the cache exists but no compatible binary is present.