layout

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package layout generates BPMN diagram interchange (BPMN-DI) for models that carry none, and regenerates it for models whose layout a user has tangled. It is the server-side auto-layout the Modeler's "Auto-layout" button calls and the fallback that lets a semantic-only deployed model still render (ADR-0124), implemented as the layered pipeline — rank, order, place, route — whose invariants ADR-0127 pins down.

The package is deliberately free of any engine or server dependency: it reads BPMN XML with its own minimal structs and writes BPMN-DI back, nothing more. It runs when a human fetches or re-arranges a model, never on the processor's hot path.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ensure

func Ensure(src []byte) []byte

Ensure returns src unchanged if it already carries BPMN diagram interchange (a <BPMNDiagram>); otherwise it generates a simple left-to-right layered layout and injects one so bpmn-js can render the model. It is best-effort: on any parse or structural problem it returns src unchanged.

This runs when the UI fetches a model's XML — a rendering concern, never the engine hot path — so models deployed as pure semantic XML (no layout) still show up in the editor and the live overlay.

func EnsureReport added in v0.4.0

func EnsureReport(src []byte) ([]byte, bool)

EnsureReport is Ensure, additionally reporting whether it generated the layout — which a caller storing the result wants to know, so it can say where the diagram came from. False means the model already had one, or none could be generated; in both cases src comes back unchanged.

func Regenerate

func Regenerate(src []byte) []byte

Regenerate discards whatever diagram interchange the model already carries and generates a fresh left-to-right layout in its place. It backs the Modeler's "Auto-layout" button: a diagram a user has tangled by hand is re-flowed by the same generator that lays out a layout-less deployed model. Only shape and edge coordinates change — the semantic model (processes, flows, ids) is untouched.

Best-effort, like Ensure: if a new layout can't be generated (the XML won't parse, or the model has no layout-relevant nodes) src is returned unchanged rather than stripped of the layout it had.

Types

This section is empty.

Jump to

Keyboard shortcuts

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