modes

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InspectFormatBundle       = service.InspectFormatBundle
	InspectFormatPNG          = service.InspectFormatPNG
	InspectFormatHTML         = service.InspectFormatHTML
	InspectFormatCSSJSON      = service.InspectFormatCSSJSON
	InspectFormatCSSMarkdown  = service.InspectFormatCSSMarkdown
	InspectFormatInspectJSON  = service.InspectFormatInspectJSON
	InspectFormatMetadataJSON = service.InspectFormatMetadataJSON
)

Variables

This section is empty.

Functions

func AIReview

func AIReview(ctx context.Context, cfg *config.Config) error

func CSSDiff

func CSSDiff(ctx context.Context, cfg *config.Config) error

func Capture

func Capture(ctx context.Context, cfg *config.Config) error

func Compare

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

func HTMLReport

func HTMLReport(ctx context.Context, cfg *config.Config) error

func MatchedStyles

func MatchedStyles(ctx context.Context, cfg *config.Config) error

func PixelDiff

func PixelDiff(ctx context.Context, cfg *config.Config, threshold int) error

func RunAIReview

func RunAIReview(ctx context.Context, cfg *config.Config) error

func RunAIReviewWithClient

func RunAIReviewWithClient(ctx context.Context, cfg *config.Config, client ai.Client) error

func RunCapture

func RunCapture(ctx context.Context, cfg *config.Config) error

func RunMatchedStyles

func RunMatchedStyles(ctx context.Context, cfg *config.Config) error

func RunPixelDiff

func RunPixelDiff(ctx context.Context, cfgDir string, threshold int) error

func StoryDiscovery

func StoryDiscovery(ctx context.Context, cfg *config.Config) error

func WriteCompareArtifacts

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

Types

type AIResponse

type AIResponse struct {
	Screenshot string    `json:"screenshot"`
	Answer     ai.Answer `json:"answer"`
}

type AIReviewResult

type AIReviewResult struct {
	Sections []AISectionReview `json:"sections"`
}

type AISectionReview

type AISectionReview struct {
	Name     string     `json:"name"`
	Selector string     `json:"selector"`
	Question string     `json:"question"`
	Original AIResponse `json:"original"`
	React    AIResponse `json:"react"`
}

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 CaptureResult

type CaptureResult struct {
	Original   PageResult         `json:"original"`
	React      PageResult         `json:"react"`
	Coverage   CoverageSummary    `json:"coverage"`
	Validation []ValidationResult `json:"validation,omitempty"`
}

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 CoverageSummary

type CoverageSummary struct {
	Total           int `json:"total"`
	OriginalMissing int `json:"original_missing"`
	ReactMissing    int `json:"react_missing"`
	OriginalHidden  int `json:"original_hidden"`
	ReactHidden     int `json:"react_hidden"`
}

type InspectArtifactResult

type InspectArtifactResult = service.InspectArtifactResult

type InspectMetadata

type InspectMetadata = service.InspectMetadata

type InspectOptions

type InspectOptions struct {
	Side string

	Root        bool
	Section     string
	Style       string
	Selector    string
	AllSections bool
	AllStyles   bool

	Props      []string
	Attributes []string

	OutDir     string
	Format     string
	OutputFile string
}

InspectOptions describes a single-side inspection run against an existing css-visual-diff config. It intentionally uses the current low-level config schema: sections are screenshot regions and styles are computed-CSS probes.

type InspectRequest

type InspectRequest = service.InspectRequest

func BuildInspectRequests

func BuildInspectRequests(cfg *config.Config, opts InspectOptions) ([]InspectRequest, error)

type InspectResult

type InspectResult = service.InspectResult

func Inspect

func Inspect(ctx context.Context, cfg *config.Config, opts InspectOptions) (InspectResult, error)

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 PNGStats

type PNGStats struct {
	Width              int    `json:"width"`
	Height             int    `json:"height"`
	TopStripAverage    [3]int `json:"top_strip_average"`
	BottomStripAverage [3]int `json:"bottom_strip_average"`
}

type PageResult

type PageResult struct {
	Name           string          `json:"name"`
	URL            string          `json:"url"`
	FullScreenshot string          `json:"full_screenshot"`
	PreparedHTML   string          `json:"prepared_html,omitempty"`
	InspectJSON    string          `json:"inspect_json,omitempty"`
	Sections       []SectionResult `json:"sections"`
}

type PixelDiffEntry

type PixelDiffEntry struct {
	Section string `json:"section"`

	OriginalScreenshot string `json:"original_screenshot"`
	ReactScreenshot    string `json:"react_screenshot"`

	DiffComparisonPath string `json:"diff_comparison_path,omitempty"`
	DiffOnlyPath       string `json:"diff_only_path,omitempty"`

	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"`

	Skipped    bool   `json:"skipped"`
	SkipReason string `json:"skip_reason,omitempty"`
}

type PixelDiffResult

type PixelDiffResult struct {
	Threshold int              `json:"threshold"`
	Entries   []PixelDiffEntry `json:"entries"`
}

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 SectionResult

type SectionResult struct {
	Name             string    `json:"name"`
	Selector         string    `json:"selector"`
	Exists           bool      `json:"exists"`
	Visible          bool      `json:"visible"`
	Bounds           *Bounds   `json:"bounds,omitempty"`
	TextStart        string    `json:"text_start,omitempty"`
	Screenshot       string    `json:"screenshot"`
	PNG              *PNGStats `json:"png,omitempty"`
	ValidationIssues []string  `json:"validation_issues,omitempty"`
}

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 StoryDiscoveryResult

type StoryDiscoveryResult struct {
	Entries []StoryEntry `json:"entries"`
}

type StoryEntry

type StoryEntry struct {
	ID    string `json:"id"`
	Title string `json:"title"`
	Name  string `json:"name"`
}

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 ValidationResult

type ValidationResult struct {
	Target  string    `json:"target"`
	Section string    `json:"section"`
	Status  string    `json:"status"`
	Issues  []string  `json:"issues,omitempty"`
	PNG     *PNGStats `json:"png,omitempty"`
	Bounds  *Bounds   `json:"bounds,omitempty"`
}

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