replay

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

tundra-browser-replay

A headless-browser driver over a typed Recording AST — replays are typed data, never an emitted bash script.

What

Model a browser replay as an ordered Recording of typed Steps (navigate, click, type, waitFor, wait, screenshot), Validate it, and hand it to a Driver to execute. The core ships a deterministic, offline NoopDriver (the canonical test/disabled driver); the real headless-browser driver lives in the build-tag-gated chromedp leaf sub-package, so the core stays zero-dep. It is a pure, generic browser-replay primitive: it models any recording and names no particular project.

Why

Tools that need to drive a browser (UI-based rotators, scrapers, smoke tests) otherwise each fork a puppeteer-replay-style flow or — worse — a program that emits bash. tundra-browser-replay is the one shared, typed replay model so the recording is data the fleet can validate, diff, and replay through one seam.

Install

go get github.com/pleme-io/tundra-browser-replay

The real browser driver is gated behind a build tag (keeps the heavy dependency out of the default graph):

go build -tags chromedp ./...

Nix (via substrate):

outputs = { self, nixpkgs, substrate, ... }:
  (import substrate.goLibraryFlakeBuilder { inherit nixpkgs; }) {
    name = "tundra-browser-replay"; version = "0.1.0"; src = self;
  };

Usage

Built on: errors-go (typed, code-carrying errors).

rec := replay.New("login",
    replay.WithSteps(
        replay.Step{Kind: replay.Navigate, Target: "https://app.example.com"},
        replay.Step{Kind: replay.Type, Selector: "#user", Value: "alice"},
        replay.Step{Kind: replay.Click, Selector: "#submit"},
        replay.Step{Kind: replay.WaitFor, Selector: "#dashboard"},
    ),
)

var d replay.Driver = &replay.NoopDriver{} // or the gated chromedp.Driver
if err := d.Run(ctx, rec); err != nil {
    return errs.Exit(err)
}

Configuration

None for the core — it is a pure library. A consumer that loads a recording or browser settings from a configured source uses shikumi-go for that config and passes the typed values to New / the driver.

Release

Pull-model (Go modules): an annotated vX.Y.Z tag is the release; proxy.golang.org + pkg.go.dev index it. See the GSDS module delivery FSM.

Documentation

Overview

Package replay is the fleet's typed model + driver seam for headless-browser replays — so no tool emits or shells out to a browser-replay bash script. A Recording is a typed AST of steps (navigate, click, type, wait, …); a Driver executes it; the core ships a deterministic no-op/test driver. The real browser driver (chromedp) is an import-gated leaf sub-package so the core stays zero-dep and offline-buildable (Law 6).

It is a pure, generic browser-replay primitive: it models any recording and never names or imports any particular project.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

type Driver interface {
	// Run executes every step of the recording in order, stopping at the first
	// error.
	Run(ctx context.Context, rec *Recording) error
}

Driver executes a Recording. The browser-replay implementation lives in an import-gated leaf sub-package (chromedp); the core ships NoopDriver for tests and the disabled path (Law 2 — the driver is the universal seam, the AST is transport-independent).

type NoopDriver

type NoopDriver struct {
	// Executed accumulates the kinds of steps Run walked, in order.
	Executed []StepKind
}

NoopDriver records the steps it was asked to run without touching a browser. It validates the recording first, so it is the canonical offline test driver.

func (*NoopDriver) Run

func (d *NoopDriver) Run(ctx context.Context, rec *Recording) error

Run validates the recording, then records each step's kind. It never performs any side effect.

type Option

type Option func(*Recording)

Option configures a Recording.

func WithStep

func WithStep(s Step) Option

WithStep appends a single step.

func WithSteps

func WithSteps(steps ...Step) Option

WithSteps appends multiple steps.

type Recording

type Recording struct {
	// Name is a human label for the recording.
	Name string
	// Steps are executed in order.
	Steps []Step
}

Recording is a typed, ordered sequence of steps — the replay AST. The zero value is an empty (valid) recording; build it through New.

func New

func New(name string, opts ...Option) *Recording

New builds a Recording from a name and options.

func (*Recording) Validate

func (r *Recording) Validate() error

Validate reports the first structural problem with the recording as a typed, code-carrying error. Each step kind has required fields.

type Step

type Step struct {
	Kind     StepKind
	Selector string        // for Click/Type/WaitFor
	Value    string        // for Type
	Target   string        // for Navigate (URL) / Screenshot (name)
	Duration time.Duration // for Wait / WaitFor timeout
}

Step is one typed action in a Recording.

type StepKind

type StepKind string

StepKind enumerates the supported replay actions. New kinds are additive.

const (
	// Navigate loads Target as a URL.
	Navigate StepKind = "navigate"
	// Click clicks the element matched by Selector.
	Click StepKind = "click"
	// Type sets Value on the element matched by Selector.
	Type StepKind = "type"
	// WaitFor waits until the element matched by Selector is present.
	WaitFor StepKind = "waitFor"
	// Wait pauses for Duration.
	Wait StepKind = "wait"
	// Screenshot captures the current page (Target names the artifact).
	Screenshot StepKind = "screenshot"
)

Directories

Path Synopsis
Package chromedp is the import-gated, real headless-browser driver for the replay Recording AST.
Package chromedp is the import-gated, real headless-browser driver for the replay Recording AST.

Jump to

Keyboard shortcuts

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