sitelook

package
v0.47.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 5 Imported by: 0 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.

Documentation

Overview

Package sitelook lets a website worker SEE pages: a reference the user pointed at, or the site it is building. Capture scrolls through a rendered page one viewport at a time (so scroll-triggered reveals play, as they do for a visitor) and returns each screen as an image; Inspect measures the rendered page's design system (type scale, palette, layout rhythm, sections, motion) from computed styles, which is what a designer reads off a page and what grepping its HTML and CSS can't recover.

Both run memcode's own fixed scripts in an ephemeral headless Chrome; no model-written code runs in the page.

Index

Constants

View Source
const MaxScreens = 8

MaxScreens bounds one capture.

Variables

View Source
var Viewports = []Viewport{
	{Name: "desktop", Width: 1440, Height: 900},
	{Name: "laptop", Width: 1280, Height: 800},
	{Name: "tablet", Width: 834, Height: 1112, Mobile: true},
	{Name: "mobile", Width: 390, Height: 844, Mobile: true},
}

Viewports are the sizes a site is judged at.

Functions

This section is empty.

Types

type Browser

type Browser interface {
	Emulate(ctx context.Context, width, height int, mobile bool) error
	Navigate(ctx context.Context, url string) error
	Eval(ctx context.Context, js string) (string, error)
	Screenshot(ctx context.Context, fullPage bool) ([]byte, string, error)
	ClearConsole()
	Console(level string) []string
}

Browser is the slice of browser.Session this package drives.

type Layout

type Layout struct {
	ContentWidth  int      `json:"contentWidth"`
	Gutter        int      `json:"gutter"`
	SectionPad    []string `json:"sectionPad"`
	ButtonRadius  string   `json:"buttonRadius"`
	CardRadius    string   `json:"cardRadius"`
	Buttons       []string `json:"buttons"`
	Borders       string   `json:"borders"`
	Shadows       int      `json:"shadows"`
	StickyHeader  bool     `json:"stickyHeader"`
	HeaderHeight  int      `json:"headerHeight"`
	FullBleedImgs int      `json:"fullBleed"`
}

Layout is the page's spatial system.

type Look

type Look struct {
	URL        string
	Title      string
	Viewport   Viewport
	PageHeight int
	Screens    []Screen
	Errors     []string // console errors and uncaught exceptions while loading
}

Look is a captured page.

func Capture

func Capture(ctx context.Context, b Browser, url string, vp Viewport, from, count int) (Look, error)

Capture renders url at vp and captures up to count screens starting at page offset from, scrolling between them.

type Media

type Media struct {
	Images int `json:"img"`
	Videos int `json:"video"`
	SVGs   int `json:"svg"`
	Canvas int `json:"canvas"`
	BGImgs int `json:"bgimg"`
}

Media is the page's imagery.

type Motion

type Motion struct {
	Libraries    []string `json:"libs"`
	Animated     int      `json:"animated"`     // elements carrying scroll/reveal markers
	Transitions  int      `json:"transitions"`  // elements with CSS transitions
	Running      int      `json:"running"`      // Web Animations running now
	Autoplay     int      `json:"autoplay"`     // autoplaying videos
	SmoothScroll bool     `json:"smoothScroll"` // a smooth-scroll library or CSS
	Markers      []string `json:"markers"`      // attribute names used for reveals
}

Motion is how the page moves.

type Report

type Report struct {
	URL      string      `json:"-"`
	Viewport Viewport    `json:"-"`
	Title    string      `json:"title"`
	Height   int         `json:"height"`
	Fonts    []string    `json:"fonts"`
	Type     []TypeStyle `json:"type"`
	Surfaces []Share     `json:"surfaces"`
	Text     []Share     `json:"text"`
	Accents  []Share     `json:"accents"`
	Layout   Layout      `json:"layout"`
	Sections []Section   `json:"sections"`
	Motion   Motion      `json:"motion"`
	Media    Media       `json:"media"`
	Errors   []string    `json:"-"`
}

Report is a page's measured design system.

func Inspect

func Inspect(ctx context.Context, b Browser, url string, vp Viewport) (Report, error)

Inspect renders url at vp and measures its design system.

func (Report) Format

func (r Report) Format() string

Format renders the report compactly for the model.

type Screen

type Screen struct {
	Top   int // page offset (CSS px) of the screen's top edge
	Image []byte
	Mime  string
}

Screen is one viewport-sized capture.

type Section

type Section struct {
	Top     int    `json:"top"`
	Height  int    `json:"height"`
	BG      string `json:"bg"`
	Heading string `json:"heading"`
	Size    int    `json:"size"`
	Cols    int    `json:"cols"`
	Media   string `json:"media"`
	Tag     string `json:"tag"`
}

Section is one band of the page, top to bottom.

type Share

type Share struct {
	Color string  `json:"color"`
	Pct   float64 `json:"pct"`
}

Share is a color and how much of the page it covers.

type TypeStyle

type TypeStyle struct {
	Tag       string  `json:"tag"`
	Family    string  `json:"family"`
	Size      float64 `json:"size"`
	Weight    string  `json:"weight"`
	Line      float64 `json:"line"`   // line-height ÷ size (0 = normal)
	Track     float64 `json:"track"`  // letter-spacing in em
	Case      string  `json:"case"`   // text-transform when not none
	Italic    bool    `json:"italic"` // font-style italic
	Color     string  `json:"color"`
	Chars     int     `json:"chars"`
	Sample    string  `json:"sample"`
	MaxWidth  int     `json:"measure"` // widest line box seen, px
	Alignment string  `json:"align"`
}

TypeStyle is one distinct text style in use.

type Viewport

type Viewport struct {
	Name          string
	Width, Height int
	Mobile        bool
}

Viewport is a device size to render at.

func ViewportNamed

func ViewportNamed(name string) (Viewport, bool)

ViewportNamed finds a viewport by name ("" is desktop).

Jump to

Keyboard shortcuts

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