renderer

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NeedsRendering

func NeedsRendering(mode DetectionMode, body []byte, staticData *parser.PageData) bool

NeedsRendering determines whether a page should be JS-rendered.

Types

type DetectionMode

type DetectionMode string

DetectionMode controls when JS rendering is applied.

const (
	ModeOff    DetectionMode = "off"
	ModeAuto   DetectionMode = "auto"
	ModeAlways DetectionMode = "always"
)

func ParseDetectionMode

func ParseDetectionMode(s string) DetectionMode

ParseDetectionMode converts a string to a DetectionMode.

type Pool

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

Pool manages a single Chrome browser with a pool of reusable pages.

func NewPool

func NewPool(opts PoolOptions) (*Pool, error)

NewPool launches a headless Chrome and creates a page pool.

func (*Pool) Acquire

func (p *Pool) Acquire() (*rod.Page, error)

Acquire returns a page from the pool or creates a new one.

func (*Pool) Close

func (p *Pool) Close()

Close shuts down the browser and all pages.

func (*Pool) Release

func (p *Pool) Release(page *rod.Page)

Release returns a page to the pool or closes it if the pool is full.

func (*Pool) Render

func (p *Pool) Render(ctx context.Context, url string) *RenderResult

Render navigates to the given URL in a headless Chrome page, waits for the page to stabilise, and returns the rendered HTML.

type PoolOptions

type PoolOptions struct {
	MaxPages       int
	PageTimeout    time.Duration
	UserAgent      string
	BlockResources bool
	Headless       bool
}

PoolOptions configures the Chrome page pool.

func DefaultPoolOptions

func DefaultPoolOptions() PoolOptions

type RenderResult

type RenderResult struct {
	RenderedHTML   string
	RenderDuration time.Duration
	JSErrors       []string
	Error          error
}

RenderResult holds the outcome of rendering a URL with Chrome.

Jump to

Keyboard shortcuts

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