screenshots

package
v1.261004.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: MIT Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProviderAXe   = "axe"
	ProviderMacOS = "macos"
)
View Source
const (
	MatrixCellSuccess       = "success"
	MatrixCellFailed        = "failed"
	MatrixCellCanceled      = "canceled"
	MatrixCellCleanupFailed = "cleanup_failed"
)
View Source
const DefaultTextBoxColor = "#00000099"

DefaultTextBoxColor is the fill used behind captions when a text box is enabled without an explicit color: 60% black, legible under the default white title and gray subtitle.

View Source
const (
	// FrameResumeStateRel is the repo-local resume file.
	FrameResumeStateRel = ".asc/reports/screenshots-frame/state.json"
)

Variables

View Source
var (
	// ErrMatrixPlanRead indicates that a matrix plan could not be read.
	ErrMatrixPlanRead = errors.New("read matrix plan")
	// ErrMatrixPlanParseJSON indicates that a matrix plan is not valid JSON/JSONC.
	ErrMatrixPlanParseJSON = errors.New("parse matrix plan JSON")
	// ErrMatrixInventoryTimeout indicates that the bounded simulator inventory
	// command reached its own deadline without caller cancellation.
	ErrMatrixInventoryTimeout = errors.New("simulator inventory timed out")
)
View Source
var (
	// ErrPlanRead indicates plan file read failure.
	ErrPlanRead = errors.New("read plan")
	// ErrPlanParseJSON indicates plan JSON decode failure.
	ErrPlanParseJSON = errors.New("parse plan JSON")
)

Functions

func BuildLocaleLaunchArguments added in v1.260904.0

func BuildLocaleLaunchArguments(locale string) ([]string, error)

BuildLocaleLaunchArguments returns arguments accepted by simctl launch.

func FingerprintFrameResume

func FingerprintFrameResume(fp FrameResumeFingerprint) string

func FrameColorValues

func FrameColorValues(device FrameDevice) []string

FrameColorValues returns the --frame-color values for device, default first.

func FrameDeviceValues

func FrameDeviceValues() []string

FrameDeviceValues returns allowed --device values in CLI display order.

func HashFile

func HashFile(ctx context.Context, path string) (digest string, returnErr error)

HashFile returns the SHA-256 hex digest of path.

func IsFontFilePath

func IsFontFilePath(value string) bool

IsFontFilePath reports whether a --font value names a font file rather than an installed family: it ends in a font extension or contains a path separator, the same test Koubou applies.

func LoadApprovals added in v1.260404.0

func LoadApprovals(path string) (map[string]bool, error)

LoadApprovals reads approved review keys from disk.

func OverlayEnablesTextBox

func OverlayEnablesTextBox(config OverlayConfig) bool

OverlayEnablesTextBox reports whether any overlay entry turns the box on.

func ResolveFrameColor

func ResolveFrameColor(device FrameDevice, raw string) (string, error)

ResolveFrameColor normalizes and validates a --frame-color value for device. An empty value selects the device's default color.

func ResolveFrameDeviceFromConfig

func ResolveFrameDeviceFromConfig(configPath, fallback string) string

ResolveFrameDeviceFromConfig resolves the config device to a supported CLI slug.

func ResolveReviewOutputDir

func ResolveReviewOutputDir(outputDir string) (string, error)

ResolveReviewOutputDir resolves output dir with defaults and ensures absolute path.

func SaveApprovals

func SaveApprovals(path string, approvals map[string]bool) error

SaveApprovals writes approved keys to disk in a stable JSON format.

func SaveFrameResumeState

func SaveFrameResumeState(root rootfs.Root, name string, state FrameResumeState) error

SaveFrameResumeState writes state beneath root without following a symlink at the destination.

func TextBoxFingerprint

func TextBoxFingerprint(canvas *CanvasOptions) string

TextBoxFingerprint is the resume key for canvas's text box; empty when none.

func TextPositionValues

func TextPositionValues() []string

TextPositionValues returns the allowed --text-position values.

func ValidateMatrixPlan added in v1.260904.0

func ValidateMatrixPlan(plan *MatrixPlan, base *Plan) error

ValidateMatrixPlan validates all matrix inputs that can be checked without executing commands. The base plan must already be loaded and validated.

func ValidateOverlayTextBoxes

func ValidateOverlayTextBoxes(config OverlayConfig, flagEnabled bool) error

ValidateOverlayTextBoxes checks every entry's text box keys. flagEnabled reports whether --text-box turns the box on for every input, which lets an entry set box details without its own textBox: true.

func ValidateTextBoxColor

func ValidateTextBoxColor(color string) error

ValidateTextBoxColor accepts the hex forms Koubou's TextBoxConfig accepts.

func WatchAndRegenerate

func WatchAndRegenerate(ctx context.Context, configPath string, debounce time.Duration, onCycle func(results []WatchCycleResult, err error), opts *WatchOptions) error

WatchAndRegenerate watches a Koubou YAML config file (and the raw asset directories it references) for changes, then re-runs kou generate on each change. It blocks until ctx is cancelled.

func WithFrameResumeLock

func WithFrameResumeLock(ctx context.Context, root rootfs.Root, fn func() error) (returnErr error)

WithFrameResumeLock serializes resume-state read-modify-write for one working tree.

Types

type AXeProvider

type AXeProvider struct{}

AXeProvider captures a screenshot via the AXe CLI.

func (*AXeProvider) Capture

func (p *AXeProvider) Capture(ctx context.Context, req CaptureRequest) (string, error)

Capture launches the requested app and captures a screenshot via AXe.

type CanvasOptions

type CanvasOptions struct {
	Title         string
	Subtitle      string
	BGColor       string       // solid background hex color (e.g. "#ffffff"); text overlays default to a dark gradient
	TitleColor    string       // title text color; defaults to canvasDefaultTitleColor
	SubtitleColor string       // subtitle text color; defaults to canvasDefaultSubtitleColor
	Font          string       // font family for title and subtitle; empty uses Koubou's default (Arial)
	TextPosition  TextPosition // top (default) or bottom

	// TextBox draws a box behind each title and subtitle; nil draws none.
	TextBox *TextBoxOptions
	// FontFile, when set, replaces Font: the file is copied into the private
	// Koubou work root and referenced from the generated YAML.
	FontFile *FontFile
}

CanvasOptions controls title/subtitle/color overlays and backgrounds. They apply to every device: canvas devices (e.g. --device mac) and bezel frames. All fields are optional; zero values use defaults.

func OverlayToCanvas

func OverlayToCanvas(entry OverlayEntry) CanvasOptions

OverlayToCanvas converts a matched overlay into canvas options.

type CaptureRequest

type CaptureRequest struct {
	Provider  string // ProviderAXe or ProviderMacOS
	BundleID  string
	UDID      string // simulator UDID or "booted"
	Name      string // output file name (without extension)
	OutputDir string // directory to write PNG
}

CaptureRequest holds parameters for a single screenshot capture.

type CaptureResult

type CaptureResult struct {
	Path     string `json:"path"`
	Provider string `json:"provider"`
	Width    int    `json:"width"`
	Height   int    `json:"height"`
	BundleID string `json:"bundle_id"`
	UDID     string `json:"udid"`
}

CaptureResult is the structured result of a successful capture.

func Capture

func Capture(ctx context.Context, req CaptureRequest) (*CaptureResult, error)

Capture runs the appropriate provider and validates the output file.

func CaptureWithProvider

func CaptureWithProvider(ctx context.Context, req CaptureRequest, p Provider) (*CaptureResult, error)

CaptureWithProvider runs the given provider (or selects by req.Provider if nil) and validates the output file. Used for testing with a mock provider.

type FontFile

type FontFile struct {
	Ext  string // lower-case .ttf, .otf, or .ttc
	Data []byte
}

FontFile is a font read by asc and copied into the private Koubou work root so the renderer never reads the operator's path.

func LoadFontFile

func LoadFontFile(path string) (*FontFile, error)

LoadFontFile reads a .ttf, .otf, or .ttc file without following a symlink at the final path and checks its font signature.

func (*FontFile) Hash

func (font *FontFile) Hash() string

Hash returns the SHA-256 digest of the font bytes.

type FrameAspectMismatch

type FrameAspectMismatch struct {
	InputWidth   int
	InputHeight  int
	ScreenWidth  int
	ScreenHeight int
}

FrameAspectMismatch describes an input whose aspect ratio differs from the device screen, so Koubou letterboxes it inside the frame.

func CheckFrameInputAspect

func CheckFrameInputAspect(path string, device FrameDevice) (*FrameAspectMismatch, error)

CheckFrameInputAspect reads the PNG at path and returns a mismatch when its aspect ratio differs from device's screen by more than frameAspectTolerance. It returns nil when the aspect ratios match or the device has no fixed screen size. The Mac canvas profile is checked too: Koubou 0.20.0 fits a canvas screenshot inside the upload size and leaves background bands, as it does inside a bezel.

type FrameDevice

type FrameDevice string

FrameDevice identifies a supported frame profile.

const (
	FrameDeviceIPhoneAir     FrameDevice = "iphone-air"
	FrameDeviceIPhone17Pro   FrameDevice = "iphone-17-pro"
	FrameDeviceIPhone17PM    FrameDevice = "iphone-17-pro-max"
	FrameDeviceIPhone16e     FrameDevice = "iphone-16e"
	FrameDeviceIPhone17      FrameDevice = "iphone-17"
	FrameDeviceMac           FrameDevice = "mac"
	FrameDeviceIPadPro13     FrameDevice = "ipad-pro-13"
	FrameDeviceIPadPro11     FrameDevice = "ipad-pro-11"
	FrameDeviceIPadAir13     FrameDevice = "ipad-air-13"
	FrameDeviceIPadAir11     FrameDevice = "ipad-air-11"
	FrameDeviceIPadMini      FrameDevice = "ipad-mini"
	FrameDeviceWatchSeries11 FrameDevice = "watch-series-11"
	FrameDeviceWatchUltra3   FrameDevice = "watch-ultra-3"
	FrameDeviceAppleTV       FrameDevice = "apple-tv"
)

func DefaultFrameDevice

func DefaultFrameDevice() FrameDevice

DefaultFrameDevice returns the default frame device.

func ParseFrameDevice

func ParseFrameDevice(raw string) (FrameDevice, error)

ParseFrameDevice normalizes and validates a frame device value.

type FrameDeviceOption

type FrameDeviceOption struct {
	ID                string   `json:"id"`
	Default           bool     `json:"default"`
	Family            string   `json:"family,omitempty"`
	DefaultFrameColor string   `json:"defaultFrameColor,omitempty"`
	FrameColors       []string `json:"frameColors,omitempty"`
}

FrameDeviceOption describes one supported frame device value.

func FrameDeviceOptions

func FrameDeviceOptions() []FrameDeviceOption

FrameDeviceOptions returns supported values with default marker.

type FrameInputSnapshot

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

FrameInputSnapshot is a bounded, regular-file copy of a frame input. The copy stays protected until Close, so hashing it and handing its path to an external renderer describe the same bytes.

func OpenFrameInputSnapshot

func OpenFrameInputSnapshot(ctx context.Context, inputPath string) (*FrameInputSnapshot, error)

OpenFrameInputSnapshot validates and copies inputPath into a private, protected staging file.

func OpenFrameInputSnapshotInRoot

func OpenFrameInputSnapshotInRoot(ctx context.Context, root rootfs.Root, name string) (*FrameInputSnapshot, error)

OpenFrameInputSnapshotInRoot validates and copies the regular file name, opened beneath the caller-owned root without following symlinks, into a private, protected staging file. The caller keeps ownership of root.

func (*FrameInputSnapshot) Close

func (snapshot *FrameInputSnapshot) Close() error

Close releases the protected staging file and its private directory.

func (*FrameInputSnapshot) Path

func (snapshot *FrameInputSnapshot) Path() string

Path returns the protected path suitable for a renderer invocation.

func (*FrameInputSnapshot) SourceHash

func (snapshot *FrameInputSnapshot) SourceHash() string

SourceHash returns the SHA-256 digest of the exact bytes in Path.

type FrameRequest

type FrameRequest struct {
	InputPath  string         // required when ConfigPath is empty
	OutputPath string         // optional for custom config mode; required for input mode
	Device     string         // device slug; defaults to iphone-air when empty
	FrameColor string         // frame color variant; empty selects the device default
	ConfigPath string         // optional Koubou YAML config path
	Canvas     *CanvasOptions // optional text overlays and background

	// Kept for backwards compatibility; ignored in Koubou mode.
	FrameRoot   string
	ScreenBleed int
}

FrameRequest holds options for composing one screenshot.

type FrameResult

type FrameResult struct {
	OutputHash   string `json:"-"` // Digest of bytes published by this render.
	Path         string `json:"path"`
	FramePath    string `json:"frame_path"`
	Device       string `json:"device"`
	DisplayType  string `json:"display_type,omitempty"`
	UploadWidth  int    `json:"upload_width,omitempty"`
	UploadHeight int    `json:"upload_height,omitempty"`
	Normalized   bool   `json:"normalized"`
	Skipped      bool   `json:"skipped,omitempty"`
	Width        int    `json:"width"`
	Height       int    `json:"height"`
}

FrameResult is the structured output for one composed frame image.

func Frame

func Frame(ctx context.Context, req FrameRequest) (result *FrameResult, returnErr error)

Frame composes screenshots through Koubou's YAML pipeline. The directory of req.OutputPath is anchored before Koubou runs, so replacing it or a parent with a symlink during the render cannot redirect the published image.

func FrameIntoOutputRoot

func FrameIntoOutputRoot(ctx context.Context, req FrameRequest, outputRoot rootfs.Root) (*FrameResult, error)

FrameIntoOutputRoot is Frame for callers that anchor the operator-selected output directory once and publish several images into it. req.OutputPath must lie beneath outputRoot; the caller keeps ownership of outputRoot.

func ResumeEntry

func ResumeEntry(ctx context.Context, state FrameResumeState, outputPath, fingerprint string) (FrameResult, bool)

ResumeEntry returns the stored frame result when the fingerprint still matches and the framed file still contains the completed render's bytes.

type FrameResumeEntry

type FrameResumeEntry struct {
	Fingerprint string      `json:"fingerprint"`
	OutputHash  string      `json:"outputHash"`
	Result      FrameResult `json:"result"`
}

type FrameResumeFingerprint

type FrameResumeFingerprint struct {
	SourceHash    string
	Device        string
	Title         string
	Subtitle      string
	TitleColor    string
	SubtitleColor string
	Background    string
	OverlayHash   string
	FrameColor    string
	Font          string
	TextPosition  string
	TextBox       string // TextBoxOptions settings; empty when no box is drawn
	FontFileHash  string // SHA-256 of a --font file; empty for a family name
}

FrameResumeFingerprint is the render-affecting resume key.

type FrameResumeState

type FrameResumeState struct {
	Files map[string]FrameResumeEntry `json:"files"`
}

FrameResumeState records completed framed outputs.

func LoadFrameResumeState

func LoadFrameResumeState(root rootfs.Root, name string) (FrameResumeState, error)

LoadFrameResumeState reads state through root, returning an empty map when the file is missing. The path must stay inside the operator-selected root.

type MatrixAppearance added in v1.260904.0

type MatrixAppearance interface {
	Snapshot(ctx context.Context, udid string) (state string, err error)
	Set(ctx context.Context, udid, appearance string) error
	Restore(ctx context.Context, udid, state string) error
}

MatrixAppearance controls simulator appearance state around a cell.

type MatrixCell added in v1.260904.0

type MatrixCell struct {
	ID              string
	Device          string
	UDID            string
	Locale          string
	Appearance      string
	Content         string
	LaunchArguments []string
	RawDir          string
	FramedDir       string
	RawPaths        []string
	FramedPaths     []string
}

MatrixCell is an expanded matrix invocation. UDID and launch arguments are intentionally internal and are never serialized in result or review artifacts.

func ExpandMatrix added in v1.260904.0

func ExpandMatrix(plan *MatrixPlan, base *Plan) ([]MatrixCell, error)

ExpandMatrix returns cells in declaration order: device, locale, appearance, then content variant. Paths are logical paths until RunMatrix resolves them.

type MatrixCellError added in v1.260904.0

type MatrixCellError struct {
	Stage   string `json:"stage"`
	Code    string `json:"code"`
	Message string `json:"message"`
}

MatrixCellError is a sanitized, stable failure contract. It intentionally has no raw subprocess output, simulator identifier, or launch arguments.

type MatrixCellResult added in v1.260904.0

type MatrixCellResult struct {
	ID           string                   `json:"id"`
	Device       string                   `json:"device"`
	Locale       string                   `json:"locale"`
	Appearance   string                   `json:"appearance"`
	Content      string                   `json:"contentVariant"`
	Status       string                   `json:"status"`
	Attempts     int                      `json:"attempts"`
	DurationMS   int64                    `json:"durationMs"`
	RawPaths     []string                 `json:"rawPaths,omitempty"`
	FramedPaths  []string                 `json:"framedPaths,omitempty"`
	Screenshots  []MatrixScreenshotResult `json:"screenshots,omitempty"`
	Steps        []RunStepResult          `json:"steps,omitempty"`
	FailureStage string                   `json:"failureStage,omitempty"`
	FailureCode  string                   `json:"failureCode,omitempty"`
	Error        *MatrixCellError         `json:"error,omitempty"`
	// contains filtered or unexported fields
}

MatrixCellResult is the privacy-safe result for one cell.

type MatrixContentVariant added in v1.260904.0

type MatrixContentVariant struct {
	ID              string   `json:"id"`
	LaunchArguments []string `json:"launch_arguments,omitempty"`
}

MatrixContentVariant supplies literal launch arguments for one content fixture.

type MatrixDependencies added in v1.260904.0

type MatrixDependencies struct {
	RunPlan func(context.Context, *Plan) (*RunResult, error)
	// RunPlanRooted is the matrix-only provider contract. The destination root
	// is retained for the whole attempt and must be used for every output write.
	// It is additive so existing test/integration callbacks keep compiling while
	// normal matrix execution avoids handing a replaceable pathname to adapters.
	// RunPlan and RunPlanRooted are mutually exclusive; supplying both is a
	// validation error rather than an implicit precedence choice.
	RunPlanRooted func(context.Context, *Plan, rootfs.Root) (*RunResult, error)
	Frame         func(context.Context, FrameRequest) (*FrameResult, error)
	// FrameRooted is the rooted counterpart of Frame. Implementations must use
	// the supplied root for the final output publication. Frame and FrameRooted
	// are mutually exclusive for the same reason as the plan callbacks.
	FrameRooted func(context.Context, FrameRequest, rootfs.Root) (*FrameResult, error)
	Appearance  MatrixAppearance
	CheckDevice func(context.Context, MatrixDevice) error
}

MatrixDependencies makes external execution replaceable by tests without changing the normal command behavior.

type MatrixDevice added in v1.260904.0

type MatrixDevice struct {
	ID   string `json:"id"`
	UDID string `json:"udid"`
}

MatrixDevice identifies an already-existing, booted simulator.

type MatrixExecution added in v1.260904.0

type MatrixExecution struct {
	MaxConcurrency int    `json:"max_concurrency,omitempty"`
	MaxAttempts    int    `json:"max_attempts,omitempty"`
	RetryBackoffMS int    `json:"retry_backoff_ms,omitempty"`
	RetryBackoff   string `json:"retry_backoff,omitempty"`
	// contains filtered or unexported fields
}

MatrixExecution controls matrix scheduling and retry behavior.

func (*MatrixExecution) UnmarshalJSON added in v1.260904.0

func (e *MatrixExecution) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes execution settings while recording which bounded limits were stated explicitly. encoding/json cannot otherwise distinguish "max_concurrency": 0 from an omitted field, so a mistaken zero would silently run with the default instead of being reported. Unknown-field strictness is preserved here because a custom unmarshaler bypasses the outer decoder's DisallowUnknownFields.

type MatrixFrame added in v1.260904.0

type MatrixFrame struct {
	Enabled              bool              `json:"enabled"`
	DeviceByMatrixDevice map[string]string `json:"device_by_matrix_device,omitempty"`
}

MatrixFrame configures optional local framing for matrix artifacts.

type MatrixOptions added in v1.260904.0

type MatrixOptions struct {
	MaxConcurrency    int
	MaxConcurrencySet bool
	MaxAttempts       int
	MaxAttemptsSet    bool
	RetryBackoff      time.Duration
	RetryBackoffSet   bool
}

MatrixOptions contains command-line overrides. Zero values use plan defaults.

type MatrixOutput added in v1.260904.0

type MatrixOutput struct {
	RawDir    string      `json:"raw_dir,omitempty"`
	FramedDir string      `json:"framed_dir,omitempty"`
	ReviewDir string      `json:"review_dir,omitempty"`
	Frame     MatrixFrame `json:"frame,omitempty"`
}

MatrixOutput configures the three local artifact directories.

type MatrixPlan added in v1.260904.0

type MatrixPlan struct {
	Version         int                    `json:"version"`
	BasePlan        string                 `json:"base_plan"`
	Devices         []MatrixDevice         `json:"devices"`
	Locales         []string               `json:"locales"`
	Appearances     []string               `json:"appearances"`
	ContentVariants []MatrixContentVariant `json:"content_variants"`
	Execution       MatrixExecution        `json:"execution,omitempty"`
	Output          MatrixOutput           `json:"output,omitempty"`
	// contains filtered or unexported fields
}

MatrixPlan describes the Cartesian product to execute over a base screenshot plan.

func LoadMatrixPlan added in v1.260904.0

func LoadMatrixPlan(path string) (*MatrixPlan, error)

LoadMatrixPlan reads a JSON or JSONC matrix plan without resolving its base plan.

type MatrixResult added in v1.260904.0

type MatrixResult struct {
	PlanPath      string              `json:"planPath"`
	BundleID      string              `json:"bundleId,omitempty"`
	RawDir        string              `json:"rawDir"`
	FramedDir     string              `json:"framedDir"`
	ReviewDir     string              `json:"reviewDir"`
	Status        string              `json:"status"`
	TotalCells    int                 `json:"totalCells"`
	Succeeded     int                 `json:"succeeded"`
	Failed        int                 `json:"failed"`
	Canceled      int                 `json:"canceled"`
	Retried       int                 `json:"retried"`
	CleanupFailed int                 `json:"cleanupFailed,omitempty"`
	Cells         []MatrixCellResult  `json:"cells"`
	Review        *MatrixReviewResult `json:"review,omitempty"`

	// Total is retained internally for callers that build reports directly;
	// the public output uses totalCells.
	Total int `json:"-"`
}

MatrixResult is printed after a matrix run and is also the source for review artifacts.

func RunMatrix added in v1.260904.0

func RunMatrix(ctx context.Context, matrixPath string, matrixPlan *MatrixPlan, options MatrixOptions) (*MatrixResult, error)

RunMatrix loads the base plan, validates the complete matrix, executes local cells, and writes a report even when execution is partially unsuccessful.

func RunMatrixWithDependencies added in v1.260904.0

func RunMatrixWithDependencies(ctx context.Context, matrixPath string, matrixPlan *MatrixPlan, options MatrixOptions, dependencies MatrixDependencies) (*MatrixResult, error)

RunMatrixWithDependencies is the testable implementation of RunMatrix.

type MatrixReviewManifest added in v1.260904.0

type MatrixReviewManifest = asc.MatrixReviewManifest

MatrixReviewManifest and MatrixReviewResult are aliases for the governed output contracts. The screenshots package keeps execution details private while the asc package owns public JSON field naming and renderers.

func LoadMatrixReviewManifest added in v1.260904.0

func LoadMatrixReviewManifest(path string) (*MatrixReviewManifest, error)

LoadMatrixReviewManifest parses a generated matrix review manifest.

type MatrixReviewRequest added in v1.260904.0

type MatrixReviewRequest struct {
	Result      *MatrixResult
	OutputDir   string
	LockContext context.Context
}

MatrixReviewRequest describes the local report to write after a matrix run.

type MatrixReviewResult added in v1.260904.0

type MatrixReviewResult = asc.MatrixReviewResult

MatrixReviewManifest and MatrixReviewResult are aliases for the governed output contracts. The screenshots package keeps execution details private while the asc package owns public JSON field naming and renderers.

func GenerateMatrixReview added in v1.260904.0

func GenerateMatrixReview(ctx context.Context, request MatrixReviewRequest) (*MatrixReviewResult, error)

GenerateMatrixReview writes an offline HTML report and its JSON manifest. It includes every planned cell, including failed and canceled cells.

type MatrixScreenshotResult added in v1.260904.0

type MatrixScreenshotResult struct {
	Name       string `json:"name"`
	Status     string `json:"status"`
	RawPath    string `json:"rawPath,omitempty"`
	FramedPath string `json:"framedPath,omitempty"`
	Width      int    `json:"width,omitempty"`
	Height     int    `json:"height,omitempty"`
}

MatrixScreenshotResult describes one screenshot step in a cell review.

type MatrixValidationError added in v1.260904.0

type MatrixValidationError struct {
	Err error
}

MatrixValidationError marks failures that are deterministic input errors and must be reported with CLI usage semantics before any run side effect.

func (*MatrixValidationError) Error added in v1.260904.0

func (e *MatrixValidationError) Error() string

func (*MatrixValidationError) Unwrap added in v1.260904.0

func (e *MatrixValidationError) Unwrap() error

type OverlayConfig

type OverlayConfig struct {
	Default OverlayEntry   `json:"default"`
	Data    []OverlayEntry `json:"data"`
}

OverlayConfig is the --overlay-config schema.

func LoadOverlayConfig

func LoadOverlayConfig(path string) (OverlayConfig, string, error)

LoadOverlayConfig reads and validates an overlay JSON file without following a symlink at the final path. The returned hash is of those exact bytes.

func ParseOverlayConfig

func ParseOverlayConfig(data []byte) (OverlayConfig, error)

ParseOverlayConfig validates overlay JSON bytes.

type OverlayEntry

type OverlayEntry struct {
	Filter     string `json:"filter,omitempty"`
	Title      string `json:"title,omitempty"`
	Keyword    string `json:"keyword,omitempty"`
	Background string `json:"background,omitempty"`

	// Text box keys mirror --text-box, --text-box-color, --text-box-padding,
	// and --text-box-radius for the inputs this entry matches.
	TextBox        bool   `json:"textBox,omitempty"`
	TextBoxColor   string `json:"textBoxColor,omitempty"`
	TextBoxPadding *int   `json:"textBoxPadding,omitempty"`
	TextBoxRadius  *int   `json:"textBoxRadius,omitempty"`
}

OverlayEntry is one title and keyword overlay.

func MatchOverlay

func MatchOverlay(config OverlayConfig, name string) OverlayEntry

MatchOverlay selects the first data entry whose filter is a substring of name, otherwise the default entry.

type Plan

type Plan struct {
	Version  int          `json:"version"`
	App      PlanApp      `json:"app"`
	Defaults PlanDefaults `json:"defaults,omitempty"`
	Steps    []PlanStep   `json:"steps"`
}

Plan defines a deterministic screenshot automation sequence.

func LoadPlan

func LoadPlan(path string) (*Plan, error)

LoadPlan reads and validates a plan file.

func LoadPlanUnvalidated

func LoadPlanUnvalidated(path string) (*Plan, error)

LoadPlanUnvalidated reads and parses a plan file without validation.

type PlanApp

type PlanApp struct {
	BundleID        string   `json:"bundle_id"`
	UDID            string   `json:"udid,omitempty"`
	OutputDir       string   `json:"output_dir,omitempty"`
	LaunchArguments []string `json:"launch_arguments,omitempty"`
	// contains filtered or unexported fields
}

PlanApp contains app/simulator defaults for a run.

type PlanDefaults

type PlanDefaults struct {
	PostActionDelayMS int `json:"post_action_delay_ms,omitempty"`
}

PlanDefaults defines default timing behavior.

type PlanStep

type PlanStep struct {
	Action         StepAction `json:"action"`
	Name           *string    `json:"name,omitempty"`
	Label          *string    `json:"label,omitempty"`
	ID             *string    `json:"id,omitempty"`
	Contains       *string    `json:"contains,omitempty"`
	Text           *string    `json:"text,omitempty"`
	Keycodes       []int      `json:"keycodes,omitempty"`
	X              *float64   `json:"x,omitempty"`
	Y              *float64   `json:"y,omitempty"`
	DurationMS     *int       `json:"duration_ms,omitempty"`
	TimeoutMS      *int       `json:"timeout_ms,omitempty"`
	PollIntervalMS *int       `json:"poll_interval_ms,omitempty"`
}

PlanStep is one executable action in the plan.

type PlanValidationCode

type PlanValidationCode string

PlanValidationCode classifies validation failures.

const (
	PlanErrUnsupportedVersion PlanValidationCode = "unsupported_version"
	PlanErrMissingBundleID    PlanValidationCode = "missing_bundle_id"
	PlanErrMissingSteps       PlanValidationCode = "missing_steps"
	PlanErrNegativeDelay      PlanValidationCode = "negative_post_action_delay"
	PlanErrMissingAction      PlanValidationCode = "missing_action"
	PlanErrTapMissingTarget   PlanValidationCode = "tap_missing_target"
	PlanErrTypeMissingText    PlanValidationCode = "type_missing_text"
	PlanErrKeycodesMissing    PlanValidationCode = "keycodes_missing"
	PlanErrKeycodeInvalid     PlanValidationCode = "keycode_invalid"
	PlanErrWaitMissingMS      PlanValidationCode = "wait_missing_duration_ms"
	PlanErrWaitForMissingBy   PlanValidationCode = "wait_for_missing_matcher"
	PlanErrWaitForNegTimeout  PlanValidationCode = "wait_for_negative_timeout"
	PlanErrWaitForNegPoll     PlanValidationCode = "wait_for_negative_poll"
	PlanErrScreenshotNoName   PlanValidationCode = "screenshot_missing_name"
	PlanErrUnsupportedAction  PlanValidationCode = "unsupported_action"
)

type PlanValidationError

type PlanValidationError struct {
	Code    PlanValidationCode
	Step    int
	Message string
}

PlanValidationError describes a structured plan validation failure.

func (*PlanValidationError) Error

func (e *PlanValidationError) Error() string

type Provider

type Provider interface {
	Capture(ctx context.Context, req CaptureRequest) (pngPath string, err error)
}

Provider captures a single screenshot and returns the path to the PNG.

type ReviewApproveRequest

type ReviewApproveRequest struct {
	OutputDir    string
	ManifestPath string
	ApprovalPath string
	AllReady     bool
	Keys         []string
	ScreenshotID string
	Locale       string
	Device       string
}

ReviewApproveRequest configures updates to approved.json.

type ReviewApproveResult

type ReviewApproveResult struct {
	ManifestPath  string   `json:"manifest_path"`
	ApprovalPath  string   `json:"approval_path"`
	Matched       int      `json:"matched"`
	Added         int      `json:"added"`
	TotalApproved int      `json:"total_approved"`
	Keys          []string `json:"keys,omitempty"`
}

ReviewApproveResult summarizes approval updates.

func ApproveReview

func ApproveReview(ctx context.Context, req ReviewApproveRequest) (*ReviewApproveResult, error)

ApproveReview writes/updates approval keys for review entries.

type ReviewEntry

type ReviewEntry struct {
	Key               string   `json:"key"`
	ScreenshotID      string   `json:"screenshot_id"`
	Locale            string   `json:"locale,omitempty"`
	Device            string   `json:"device,omitempty"`
	FramedPath        string   `json:"framed_path"`
	FramedRelative    string   `json:"framed_relative_path"`
	RawPath           string   `json:"raw_path,omitempty"`
	RawRelative       string   `json:"raw_relative_path,omitempty"`
	Width             int      `json:"width"`
	Height            int      `json:"height"`
	DisplayTypes      []string `json:"display_types,omitempty"`
	ValidAppStoreSize bool     `json:"valid_app_store_size"`
	Status            string   `json:"status"`
	Approved          bool     `json:"approved"`
	ApprovalState     string   `json:"approval_state"`
}

ReviewEntry represents one framed screenshot row in review artifacts.

type ReviewManifest

type ReviewManifest struct {
	GeneratedAt  string        `json:"generated_at"`
	RawDir       string        `json:"raw_dir,omitempty"`
	FramedDir    string        `json:"framed_dir"`
	OutputDir    string        `json:"output_dir"`
	ApprovalPath string        `json:"approval_path"`
	Summary      ReviewSummary `json:"summary"`
	Entries      []ReviewEntry `json:"entries"`
}

ReviewManifest is the JSON artifact for agent/human checks.

func LoadReviewManifest

func LoadReviewManifest(path string) (*ReviewManifest, error)

LoadReviewManifest parses a generated review manifest from disk.

type ReviewOpenRequest

type ReviewOpenRequest struct {
	OutputDir string
	HTMLPath  string
	DryRun    bool
}

ReviewOpenRequest configures opening a generated review HTML file.

type ReviewOpenResult

type ReviewOpenResult struct {
	HTMLPath string `json:"html_path"`
	Opened   bool   `json:"opened"`
}

ReviewOpenResult describes the resolved review HTML path and open state.

func OpenReview

func OpenReview(ctx context.Context, req ReviewOpenRequest) (*ReviewOpenResult, error)

OpenReview opens the generated review HTML in the default browser.

type ReviewRequest

type ReviewRequest struct {
	RawDir       string // optional; missing raw files are reported
	FramedDir    string // required
	OutputDir    string // optional, defaults to ./screenshots/review
	ApprovalPath string // optional, defaults to <output-dir>/approved.json
}

ReviewRequest configures generation of screenshot review artifacts.

type ReviewResult

type ReviewResult struct {
	ManifestPath string `json:"manifest_path"`
	HTMLPath     string `json:"html_path"`
	ApprovalPath string `json:"approval_path"`
	FramedDir    string `json:"framed_dir"`
	Total        int    `json:"total"`
	Ready        int    `json:"ready"`
	MissingRaw   int    `json:"missing_raw"`
	InvalidSize  int    `json:"invalid_size"`
	Approved     int    `json:"approved"`
	Pending      int    `json:"pending"`
}

ReviewResult is printed by CLI after artifacts are written.

func GenerateReview

func GenerateReview(ctx context.Context, req ReviewRequest) (*ReviewResult, error)

GenerateReview creates manifest and HTML side-by-side report artifacts.

type ReviewSummary

type ReviewSummary struct {
	Total           int `json:"total"`
	Ready           int `json:"ready"`
	MissingRaw      int `json:"missing_raw"`
	InvalidSize     int `json:"invalid_size"`
	Approved        int `json:"approved"`
	PendingApproval int `json:"pending_approval"`
}

ReviewSummary aggregates status/approval totals across all entries.

type RunResult

type RunResult struct {
	BundleID  string          `json:"bundle_id"`
	UDID      string          `json:"udid"`
	OutputDir string          `json:"output_dir"`
	Steps     []RunStepResult `json:"steps"`
}

RunResult is the structured output for a plan run.

func RunPlan

func RunPlan(ctx context.Context, plan *Plan) (*RunResult, error)

RunPlan executes a validated plan.

type RunStepResult

type RunStepResult struct {
	Index      int    `json:"index"`
	Action     string `json:"action"`
	Status     string `json:"status"`
	DurationMS int64  `json:"duration_ms"`
	Error      string `json:"error,omitempty"`
}

RunStepResult reports one executed step.

type StepAction

type StepAction string

StepAction is one supported automation step.

const (
	ActionLaunch      StepAction = "launch"
	ActionTap         StepAction = "tap"
	ActionType        StepAction = "type"
	ActionKeySequence StepAction = "key_sequence"
	ActionWait        StepAction = "wait"
	ActionWaitFor     StepAction = "wait_for"
	ActionScreenshot  StepAction = "screenshot"
)

type TextBoxOptions

type TextBoxOptions struct {
	Color   string // #RGB, #RRGGBB, or #RRGGBBAA; empty uses DefaultTextBoxColor
	Padding *int   // pixels; nil scales with each item's font size
	Radius  *int   // corner radius in pixels; nil lets Koubou use the padding
}

TextBoxOptions draws a filled box behind each title and subtitle overlay.

func OverlayTextBox

func OverlayTextBox(entry OverlayEntry) *TextBoxOptions

OverlayTextBox returns the text box an --overlay-config entry enables, or nil when the entry leaves it off.

type TextPosition

type TextPosition string

TextPosition places title and subtitle overlays above or below the device.

const (
	TextPositionTop    TextPosition = "top"
	TextPositionBottom TextPosition = "bottom"
)

func ParseTextPosition

func ParseTextPosition(raw string) (TextPosition, error)

ParseTextPosition normalizes a --text-position value. Empty selects top.

type WatchCycleResult

type WatchCycleResult struct {
	Name    string `json:"name"`
	Path    string `json:"path"`
	Success bool   `json:"success"`
	Error   string `json:"error,omitempty"`
}

WatchCycleResult describes one screenshot generated per watch cycle.

type WatchOptions

type WatchOptions struct {
	// ReviewOutputDir, when non-empty, triggers automatic review HTML/manifest
	// regeneration after each successful kou generate cycle.
	ReviewOutputDir string
	// ReviewRawDir is the raw screenshots directory for review generation.
	ReviewRawDir string
}

WatchOptions configures optional review regeneration after each watch cycle.

Jump to

Keyboard shortcuts

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