modes

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(ctx context.Context, settings CompareSettings) error

func WriteCompareArtifacts

func WriteCompareArtifacts(result CompareResult, writeJSONFile bool, writeMarkdownFile bool) error

Types

type Bounds

type Bounds = service.Bounds

type CSSDiffResult

type CSSDiffResult struct {
	Styles []StyleResult `json:"styles"`
}

type Candidate

type Candidate struct {
	Property    string
	Value       string
	Selector    string
	Important   bool
	Specificity Specificity
	Origin      CascadeOrigin
	Order       int
}

type CascadeOrigin

type CascadeOrigin string
const (
	OriginInline    CascadeOrigin = "inline"
	OriginAuthor    CascadeOrigin = "author"
	OriginUserAgent CascadeOrigin = "user-agent"
)

type CompareInputs

type CompareInputs struct {
	URL1      string   `json:"url1"`
	Selector1 string   `json:"selector1"`
	WaitMS1   int      `json:"wait_ms1"`
	URL2      string   `json:"url2"`
	Selector2 string   `json:"selector2"`
	WaitMS2   int      `json:"wait_ms2"`
	ViewportW int      `json:"viewport_w"`
	ViewportH int      `json:"viewport_h"`
	Props     []string `json:"props"`
	Attrs     []string `json:"attrs"`
	OutDir    string   `json:"out_dir"`
}

type CompareResult

type CompareResult struct {
	Inputs CompareInputs `json:"inputs"`

	URL1 CompareSideResult `json:"url1"`
	URL2 CompareSideResult `json:"url2"`

	ComputedDiffs []StyleDiff  `json:"computed_diffs"`
	WinnerDiffs   []WinnerDiff `json:"winner_diffs"`

	PixelDiff PixelDiffStats `json:"pixel_diff"`
}

func GenerateCompareResult

func GenerateCompareResult(ctx context.Context, settings CompareSettings) (CompareResult, error)

type CompareSettings

type CompareSettings struct {
	URL1      string
	Selector1 string
	WaitMS1   int

	URL2      string
	Selector2 string
	WaitMS2   int

	ViewportW int
	ViewportH int

	Props      []string
	Attributes []string

	OutDir string

	WriteJSON     bool
	WriteMarkdown bool
	WritePNGs     bool

	PixelDiffThreshold int
}

type CompareSideResult

type CompareSideResult struct {
	URL      string `json:"url"`
	Selector string `json:"selector"`

	FullScreenshot    string `json:"full_screenshot"`
	ElementScreenshot string `json:"element_screenshot"`

	Computed StyleSnapshot   `json:"computed"`
	Matched  MatchedSnapshot `json:"matched"`
}

type MatchedRule

type MatchedRule struct {
	Selector    string         `json:"selector"`
	Origin      CascadeOrigin  `json:"origin"`
	Specificity Specificity    `json:"specificity"`
	Properties  []RuleProperty `json:"properties"`
}

type MatchedSnapshot

type MatchedSnapshot struct {
	Exists   bool              `json:"exists"`
	Rules    []MatchedRule     `json:"rules"`
	Computed map[string]string `json:"computed"`
	Bounds   *Bounds           `json:"bounds,omitempty"`
}

type MatchedStyleEntry

type MatchedStyleEntry struct {
	Name             string          `json:"name"`
	Selector         string          `json:"selector,omitempty"`
	OriginalSelector string          `json:"original_selector,omitempty"`
	ReactSelector    string          `json:"react_selector,omitempty"`
	Original         MatchedSnapshot `json:"original"`
	React            MatchedSnapshot `json:"react"`
	Winners          []WinnerDiff    `json:"winners"`
}

type MatchedStylesResult

type MatchedStylesResult struct {
	Styles []MatchedStyleEntry `json:"styles"`
}

type PixelDiffStats

type PixelDiffStats struct {
	Threshold      int     `json:"threshold"`
	TotalPixels    int     `json:"total_pixels"`
	ChangedPixels  int     `json:"changed_pixels"`
	ChangedPercent float64 `json:"changed_percent"`

	NormalizedWidth  int `json:"normalized_width"`
	NormalizedHeight int `json:"normalized_height"`

	DiffComparisonPath string `json:"diff_comparison_path"`
	DiffOnlyPath       string `json:"diff_only_path"`
}

type RuleProperty

type RuleProperty struct {
	Name      string `json:"name"`
	Value     string `json:"value"`
	Important bool   `json:"important"`
}

type Specificity

type Specificity struct {
	A int `json:"a"`
	B int `json:"b"`
	C int `json:"c"`
}

func (Specificity) Add

func (s Specificity) Add(other Specificity) Specificity

func (Specificity) Compare

func (s Specificity) Compare(other Specificity) int

func (Specificity) String

func (s Specificity) String() string

type StyleDiff

type StyleDiff struct {
	Property string `json:"property"`
	Original string `json:"original"`
	React    string `json:"react"`
}

type StyleResult

type StyleResult struct {
	Name             string        `json:"name"`
	Selector         string        `json:"selector,omitempty"`
	OriginalSelector string        `json:"original_selector,omitempty"`
	ReactSelector    string        `json:"react_selector,omitempty"`
	Original         StyleSnapshot `json:"original"`
	React            StyleSnapshot `json:"react"`
	Diffs            []StyleDiff   `json:"diffs"`
}

type StyleSnapshot

type StyleSnapshot = service.StyleSnapshot

type Winner

type Winner struct {
	Selector    string        `json:"selector"`
	Value       string        `json:"value"`
	Important   bool          `json:"important"`
	Origin      CascadeOrigin `json:"origin"`
	Specificity Specificity   `json:"specificity"`
}

type WinnerDiff

type WinnerDiff struct {
	Property string `json:"property"`
	Original Winner `json:"original"`
	React    Winner `json:"react"`
}

Jump to

Keyboard shortcuts

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