visualizer

package
v0.19.8 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 55 Imported by: 1 module, 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 ErrEmptyTx = errors.New("empty tx")
View Source
var HtmlDiagram []byte

Functions

func IsStateInherited added in v0.18.0

func IsStateInherited(state string, machStates am.S) bool

func PresetBird added in v0.16.1

func PresetBird(r *Renderer)

func PresetMap

func PresetMap(r *Renderer)

func PresetSingle

func PresetSingle(r *Renderer)

func UpdateCache added in v0.13.0

func UpdateCache(
	ctx context.Context, filepath string, dom *goquery.Document, filters *Filters,
) error

UpdateCache updates [dom] according to [fragments], and saves to filepath. Only single-machine diagrams are supported.

Types

type D2Layout added in v0.19.6

type D2Layout string

D2Layout is a D2 layout engine name for SVG/PNG output.

const (
	// D2LayoutNone writes the .d2 source only and skips layout, SVG and PNG.
	D2LayoutNone D2Layout = "none"
	// D2LayoutElk is the ELK layout engine.
	D2LayoutElk D2Layout = "elk"
	// D2LayoutDagre is the Dagre layout engine.
	D2LayoutDagre D2Layout = "dagre"
	// D2LayoutTala is the native TALA layout and edge-routing engine.
	D2LayoutTala D2Layout = "tala"
)

type Filters added in v0.18.8

type Filters struct {
	// Machine to filter TODO inline as map[string] to other fields
	MachId string
	// list of states to process
	Index am.S
	// currently active states (inactive = states - active)
	Active am.S
	// currently highlighted states (dimmed = states - highlighted)
	Highlighted am.S
	// currently visible states (hidden = states - visible)
	Visible am.S
	// currently selected states
	Selected am.S
	// {StateFrom, StateTo, [am.Relation.String()]}
	HighlightedRels [][3]string
}

Filters filter a rendered graph for the desired output.

func (*Filters) Empty added in v0.18.8

func (f *Filters) Empty() bool

type Renderer added in v0.16.1

type Renderer struct {

	// Render only these machines as starting points.
	RenderMachs []string
	// Render only these states
	RenderAllowlist am.S
	// Render states as zoomed in (incl their rels)
	RenderZoom am.S
	// Render machine IDs as box titles.
	RenderMachTitles bool
	// Render only machines matching the regular expressions as starting points.
	RenderMachsRe []*regexp.Regexp
	// Skip rendering of these machines.
	RenderSkipMachs []string
	// TODO RenderSkipMachsRe       []regexp.Regexp
	// Distance to render from starting machines.
	RenderDistance int
	// How deep to render from starting machines. Same as RenderDistance, but only
	// for submachines.
	RenderDepth int

	// Render states bubbles.
	RenderStates bool
	// With RenderStates, false will hide Start, and without RenderStates true
	// will render Start.
	RenderStart bool
	// With RenderStates, false will hide Exception, and without RenderStates true
	// will render Exception.
	RenderException bool
	// With RenderStates, false will hide Ready, and without RenderStates true
	// will render Ready.
	RenderReady bool
	// Render states which have pipes being rendered, even if the state should
	// not be rendered.
	RenderPipeStates bool
	// Render group of pipes as mach->mach
	RenderPipes bool
	// Render pipes to non-rendered machines / states.
	RenderHalfPipes bool
	// Render detailed pipes as state -> state
	RenderDetailedPipes bool
	// Render relation between states. TODO After relation
	// TODO specific relations
	RenderRelations bool
	// Style currently active states. TODO style errors red
	RenderActive bool
	// Render the parent relation. Ignored when RenderNestSubmachines.
	RenderParentRel bool
	// Render submachines nested inside their parents. See also RenderDepth.
	RenderNestSubmachines bool
	// Render a tags box for machines having some.
	// TODO doesnt work?
	RenderTags bool
	// Render RPC connections
	RenderConns bool
	// Render RPC connections to non-rendered machines.
	RenderHalfConns bool
	// Render a parent relation to and from non-rendered machines.
	RenderHalfHierarchy bool
	// Render inherited states.
	RenderInherited bool
	// Mark inherited states. TODO refac to RenderMarkOwnStates
	RenderMarkInherited bool

	// Filename without an extension.
	OutputFilename string
	// Render a D2 svg in addition to the plain text version.
	OutputD2Svg bool
	// Render a Mermaid svg in addition to the plain text version.
	OutputMermaidSvg bool
	// Layout engine used for D2 SVG/PNG output: D2LayoutElk (default),
	// D2LayoutDagre, D2LayoutTala, or D2LayoutNone (write the .d2 source only).
	OutputD2Layout D2Layout
	// Also rasterize the diagram into a PNG (pure Go, no browser required).
	OutputPng bool

	// Output a D2 diagram (default)
	OutputD2 bool
	// Output a Mermaid diagram (basic support only).
	OutputMermaid bool
	// contains filtered or unexported fields
}

func NewRenderer added in v0.16.1

func NewRenderer(
	graph *amgraph.Graph, logger func(msg string, args ...any),
) *Renderer

func (*Renderer) GenDiagrams added in v0.16.1

func (r *Renderer) GenDiagrams(ctx context.Context) error

func (*Renderer) RenderDefaults added in v0.16.1

func (r *Renderer) RenderDefaults()

type Transition added in v0.18.0

type Transition struct {
	Tx         *dbg.DbgMsgTx
	PrevTx     *dbg.DbgMsgTx
	TxParsed   *dbgtypes.MsgTxParsed
	StateTrace []*dbgtypes.StateTraceItem
	Log        *slog.Logger
	// Render only the following states
	Group am.S
}

func (*Transition) D2 added in v0.18.0

func (t *Transition) D2(
	ctx context.Context, statesIndex am.S,
) (string, []byte, error)

D2 will generate a D2 sequence diagram and an svg of a given transition.

func (*Transition) Mermaid added in v0.18.0

func (t *Transition) Mermaid(statesIndex am.S) (string, string, error)

type Visualizer

type Visualizer struct {
	Mach *am.Machine
	R    *Renderer

	Graph *amgraph.Graph
}

func New

func New(ctx context.Context, name string) (*Visualizer, error)

New creates a new Visualizer - state machine, RPC server, and a renderer.

func (*Visualizer) ClientMsgEnter added in v0.16.1

func (v *Visualizer) ClientMsgEnter(e *am.Event) bool

func (*Visualizer) ClientMsgState added in v0.16.1

func (v *Visualizer) ClientMsgState(e *am.Event)

func (*Visualizer) Clients added in v0.16.1

func (v *Visualizer) Clients() map[string]amgraph.Machine

func (*Visualizer) ConnectEventEnter added in v0.16.1

func (v *Visualizer) ConnectEventEnter(e *am.Event) bool

func (*Visualizer) ConnectEventState added in v0.16.1

func (v *Visualizer) ConnectEventState(e *am.Event)

func (*Visualizer) HImportData added in v0.16.1

func (v *Visualizer) HImportData(filename string) error

func (*Visualizer) ImportSchema added in v0.19.6

func (v *Visualizer) ImportSchema(filename string) error

ImportSchema imports a machine schema from a YAML file and adds it to the graph.

Directories

Path Synopsis
Package states contains a stateful schema-v2 for Visualizer.
Package states contains a stateful schema-v2 for Visualizer.

Jump to

Keyboard shortcuts

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