Expand description
octovia — A bespoke, DOM-free state diagram rendering engine.
§Architecture
The engine processes diagram descriptions through a 5-phase pipeline:
- Parse: Text DSL or JSON → AST.
- Measure: cosmic-text pre-flight layout snaps each node’s box to the 10 px sub-grid (no global width unification).
- Layered Layout: classify back-edges (iterative DFS), assign every forward node a depth via a longest-path topological sort (Kahn / Sugiyama L1), then place layers as columns and stack same-layer nodes vertically.
- Unified Routing + Labelling: a single sequential loop drives
every edge through one A* pass over a
routing::GridOccupancygrid. After each route is committed, a label anchor is searched in the local neighbourhood and the label’s bounding box is also reserved, so subsequent edges and labels treat both routes and labels as impassable terrain. - SVG Output: deterministic SVG string with the transit-map aesthetic (octilinear strokes, end-cap arrows, halo’d labels).
Compiles to WebAssembly (no DOM, no OS fonts, no headless browser).
Modules§
- ast
- Abstract Syntax Tree for the state diagram DSL.
- label_
placement - Phase 5 — Edge label placement.
- layout
- Layered Topological Layout (lightweight Sugiyama).
- measure
- Pre-flight text measurement using
cosmic-text. - parser
- Diagram parsers.
- routing
- Unified routing + label placement phase.
- svg_
output - SVG output phase.
Functions§
- octo_
render - One-shot convenience: parse DSL → full pipeline → SVG string.
- octo_
render_ with_ theme - One-shot convenience with optional theme override.