renderers

package
v1.17.3 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package renderers provides immutable safe renderer registries for TUI data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Normalize

func Normalize(value any) any

Normalize converts arbitrary typed payloads to JSON-shaped values, recursively redacts canonical secret fields, strips terminal controls, and refuses raw heavy content. Heavy values must arrive as an artifact reference.

func SafeText

func SafeText(value string) string

SafeText removes terminal control and escape characters and bounds a display field. Every operator-visible value passes this function.

Types

type Block

type Block struct {
	Kind, ID, Title, Status, Summary string
}

Block is a terminal-neutral rendered summary.

func Generic

func Generic(value Value) Block

Generic renders unknown or malformed values as bounded metadata-only JSON.

type Registry

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

Registry is immutable after construction and safe for concurrent reuse.

func Builtins

func Builtins() Registry

Builtins returns the in-repo renderers through the same registry path used for unknown values. Built-ins intentionally remain metadata-only.

func New

func New(definitions map[string]Renderer) Registry

New constructs a registry from a copied definition map.

func (Registry) Kinds

func (r Registry) Kinds() []string

Kinds returns the deterministic registered inventory.

func (Registry) Render

func (r Registry) Render(value Value) Block

Render dispatches by kind and always returns a safe generic fallback.

type Renderer

type Renderer func(Value) Block

Renderer converts one canonical value to a bounded block.

type Value

type Value struct {
	Kind, ID, Title, Status string
	Payload                 any
}

Value is a renderer input. Payload must already be a canonical redacted wire projection; the registry additionally bounds and escapes it for terminals.

Jump to

Keyboard shortcuts

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