layout

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: Apache-2.0 Imports: 7 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

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilSnapshot        = errors.New("layout snapshot is nil")
	ErrNilLayout          = errors.New("layout is nil")
	ErrInvalidConfig      = errors.New("layout configuration is invalid")
	ErrInvalidContainment = errors.New("snapshot containment is invalid")
	ErrLayoutOverflow     = errors.New("layout coordinate overflow")
	ErrLayoutTooLarge     = errors.New("layout is too large")
	ErrInvalidViewport    = errors.New("layout viewport is invalid")
	ErrInvalidLOD         = errors.New("layout level of detail is invalid")
	ErrViewportNodeLimit  = errors.New("layout viewport node limit is invalid")
	ErrViewportTooLarge   = errors.New("layout viewport exceeds cell limit")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	SymbolWidth  Coord
	SymbolHeight Coord
	SymbolGap    Coord

	FilePadding       Coord
	FileGap           Coord
	PackagePadding    Coord
	PackageGap        Coord
	RepositoryPadding Coord
	RepositoryGap     Coord

	// Columns fixes the width of every child grid. Zero balances each
	// container instead: ceil(sqrt(children)), so a workspace does not become
	// a column dozens of screens tall that no viewport can read.
	Columns  int
	CellSize Coord

	// MaxIndexedCellsPerNode prevents large containers from being copied into
	// thousands of grid buckets. Such nodes are kept in an ordered overflow
	// list and checked directly during a query.
	MaxIndexedCellsPerNode int
	MaxQueryCells          int
	MaxQueryNodes          int
}

Config controls the deterministic hierarchy packer and spatial index.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the reproducible layout configuration used by the viewer unless a caller supplies an explicit configuration.

func (Config) Validate

func (config Config) Validate() error

Validate checks all configuration values before layout allocation begins.

type Coord

type Coord int64

Coord is a signed fixed-point layout coordinate. Layout calculations never use floating-point arithmetic, so identical snapshot/configuration pairs produce byte-identical positions on every supported architecture.

type DenseID

type DenseID uint32

DenseID is scoped by NodeRef.Kind and therefore cannot be mistaken for a repository, package, file, or symbol ID outside that discriminant.

type GridStats

type GridStats struct {
	Cells          int
	IndexedEntries int
	OverflowNodes  int
}

GridStats describes the spatial index without exposing its mutable maps.

type LOD

type LOD uint8

LOD is the deepest hierarchy level returned by a viewport query. A query at LODPackages may return repositories and packages, but never files or symbols.

const (
	LODRepositories LOD = iota
	LODPackages
	LODFiles
	LODSymbols
)

type Layout

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

Layout is an immutable hierarchy layout and its read-only spatial index.

func Build

func Build(ctx context.Context, snapshot *hotsnapshot.GraphSnapshot, config Config) (*Layout, error)

Build lays out repository -> package -> file -> symbol with deterministic row-major packing. It never performs force simulation or graph traversal.

func (*Layout) Bounds

func (layout *Layout) Bounds() Rect

Bounds returns the root layout bounds. An empty snapshot has zero bounds.

func (*Layout) Config

func (layout *Layout) Config() Config

Config returns the value configuration used to build the layout.

func (*Layout) GridStats

func (layout *Layout) GridStats() GridStats

GridStats returns deterministic aggregate index statistics.

func (*Layout) MarshalBinary

func (layout *Layout) MarshalBinary() ([]byte, error)

MarshalBinary returns a deterministic internal layout encoding used to compare two builds. It is not the HTTP viewer wire protocol.

func (*Layout) Nodes

func (layout *Layout) Nodes() []Node

Nodes returns a copy of all nodes in deterministic repository/package/file/ symbol order.

func (*Layout) QueryViewport

func (layout *Layout) QueryViewport(query ViewportQuery) (ViewportResult, error)

QueryViewport returns all nodes whose bounds intersect query.Bounds and whose detail level is at most query.MaxLevel. It uses the deterministic grid order, then restores immutable node order before applying MaxNodes.

func (*Layout) SnapshotID

func (layout *Layout) SnapshotID() uint64

SnapshotID returns the source HotSnapshot identifier.

type Node

type Node struct {
	Kind   NodeKind
	Level  LOD
	ID     DenseID
	Parent NodeRef
	Bounds Rect
}

Node is an immutable positioned hierarchy node. ID is interpreted according to Kind and is the dense ID in the source HotSnapshot table.

type NodeKind

type NodeKind uint8

NodeKind identifies the hierarchy level represented by a Node.

const (
	NodeNone NodeKind = iota
	NodeRepository
	NodePackage
	NodeFile
	NodeSymbol
)

type NodeRef

type NodeRef struct {
	Kind NodeKind
	ID   DenseID
}

NodeRef identifies a dense snapshot node together with its table.

type Rect

type Rect struct {
	MinX Coord
	MinY Coord
	MaxX Coord
	MaxY Coord
}

Rect is a half-open axis-aligned rectangle: [MinX, MaxX) x [MinY, MaxY).

func (Rect) Intersects

func (rect Rect) Intersects(other Rect) bool

Intersects reports whether two half-open rectangles share area.

func (Rect) Valid

func (rect Rect) Valid() bool

Valid reports whether the rectangle has positive area.

type ViewportQuery

type ViewportQuery struct {
	Bounds   Rect
	MaxLevel LOD
	MaxNodes int
}

ViewportQuery limits a spatial query by bounds, detail level, and result count. Bounds use the same half-open convention as Rect.

type ViewportResult

type ViewportResult struct {
	Nodes     []Node
	Truncated bool
}

ViewportResult is ordered by the immutable layout node order. Truncated is true only when at least one additional matching node was omitted by MaxNodes.

Jump to

Keyboard shortcuts

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