Native anatomy and execution demonstration
This is the public native compact model rendered by Mermaid, not a set of HTML
lookalike cards. Set execution evidence to none to inspect the untouched definition,
to typed outcomes for ranOk / ranFailed / neverReached / branchNotTaken (the
edge into the not-taken branch is dashed 6 3), or to log-derived readings for
mermaidEvidenceStyles node reached / unfinished and edge reached / unfinished
(dashed 4 3) / failed. The run readings are explicitly sample data, not business-success claims.
Change the site theme/language, direction and zoom, select with a pointer or keyboard,
then export the actual SVG. Category masks, native shapes, edge labels and typed
state geometry survive those changes.
Use @beehexa/mermaid-tokens for every Mermaid initialization. It returns a fresh
MermaidConfig from @beehexa/design-tokens; Mermaid remains a peer dependency.
Pass the active dark and locale on every render. A theme or language change
requires rendering again: SVG paint and text measurements do not update from CSS alone.
import { createMermaidConfig, createCanvasTheme } from '@beehexa/mermaid-tokens';
mermaid.initialize(createMermaidConfig({ dark: true, locale: 'vi' }));
const canvas = createCanvasTheme({ dark: true, locale: 'vi' });
The factory secures theme, look, themeVariables, themeCSS, fontFamily,
fontSize and htmlLabels before layout. Mermaid 12 appends this secure array
to its own default security keys. Definition init CSS must not replace rich-card
token fonts; topology, definition-owned state styles and unrelated layout directives
remain available. This configuration contract is not a claim that a rendered smoke
matrix has passed.
Meaning before colour
diagram.* roles describe an operational execution graph, not an explanatory
brand schematic or a chart series palette. The same roles apply to the drawing,
its inspector and its exported artifact.
- Default and indeterminate nodes use
node-*neutral pairs. state-ran-okmeans ran without a reported failure, not a verified business success. Informational paint and a completion marker distinguish execution from untouched nodes without using business-success green. HTTP/business outcomes retain their appropriate status labels independently.- Failed nodes use
fail-*, with a failure marker and state text. - Log-only
log-reacheduses a reach marker.log-unfinisheduses warning paint, an ellipsis and a dashed boundary; it is never a proven failure. - Never-reached nodes use
unreached-*and an explicit state label; they are not disabled controls. Not-taken branches usenottaken-*plus a dashed boundary. - Repeat counts use the neutral
badge-*pair. Repetition alone is not a warning. - Category glyphs use
tile-*. They identify step type, not run state. - Selection and hover use
selection-ringas separate geometry outside the node boundary. Never repaint a failed node to indicate that it is selected. - Field labels use
code-key, valuescode-value, oncode-bg. These descriptive fields are not links. Full code blocks retain the existingcolor.code.*pair.
Always keep labels, markers, shapes or dash patterns: colour alone is not evidence. Pair foregrounds only with their named fills. Validate actual SVG text and meaningful line contrast in both themes; token existence does not certify a rendered diagram.
Type, space and interaction
diagram.node-font aliases font.body.default, including taller Vietnamese lines.
Use complete source font styles for node labels, inspector titles, metadata and code.
Do not replace their weight or line height with component-specific recipes. Let
Vietnamese marks and long labels wrap without clipping. diagram.padding is internal
node padding; diagram.export-padding frames fitted/exported drawing bounds. Graph
coordinates and existing layout topology are not spacing-scale choices.
Native compact worker flows keep the actual compactFlowMermaid output and the
public flowStylesheet() from @beehexa/hexasync-template-model. Install that
sheet before Mermaid measures labels, then include it in the SVG for standalone
export. Add hx-flow to the SVG root and bind workerFlowSvgStyle(canvas) from
@beehexa/mermaid-tokens as its inline style. Native card geometry, family masks
and typed state line-work remain native; the adapter owns literal source paint,
neutral category tile/glyph pairs and the canonical tile radius.
The native model now encloses the complete escaped title in renderer-owned <b>
and separates secondary KEY · TYPE metadata with its native <br>. The adapter
binds the entire title to font.heading.xsmall and metadata to font.body.small;
wrapping never changes a title line into metadata. Source supplies the fixed
category tile/glyph dimensions and neutral pair, without replacing native shapes,
family masks, state markers or compact/public address mapping. Authored markup
remains escaped; a consumer must not mutate labels or substitute an emitter.
This anatomy is implemented in the canonical model source. The pinned published
model predates the full-title implementation; local verification uses its built
public export through HEXASYNC_LOCAL_PACKAGES=1, not a source alias. A local
build is not a claim that the model or this site has been released.
Embedded SVG CSS also supplies opaque source edge-label pairs and explicit
"cv05", "cv08" features alongside the complete font shorthand; SVG/export must
not depend on the document’s universal font-feature rule.
Interactive preview nodes opt in with bh-mermaid-interactive-node on the actual
SVG group. Keep native role/tabindex, keyboard handling and real selection state;
bind aria-selected="true" for a supported selectable role or aria-pressed="true"
for a toggle button, never merely for expansion. The embedded
stylesheet adds border.width.focused / diagram.selection-ring outside the node
on hover, focus-visible and selection with state.focus.offset; it never repaints
run-state fill/stroke. bh-mermaid-category-glyph on authored SVG icon paths uses
diagram.tile-glyph, border.width.default and round caps/joins. Path coordinates
and transforms remain graph geometry.
Import @beehexa/mermaid-tokens/css once for HTML surrounding the SVG.
data-bh-diagram="canvas|code|key|value|description|badge" selects existing
diagram.canvas, code-bg, code-key, code-value, node-desc and the paired
repeat-count badge roles. The badge recipe includes its ordinary radius.050
label frame; content font markers and structural composition remain independent.
No local colour, border or canvas-background recipes are required.
Embedded foreignObject text also sets -webkit-text-fill-color: currentcolor.
This bridges HTML-to-image clones to the already resolved SVG label colour rather
than a document host’s inherited text-fill; do not inject a second app stylesheet
during PNG capture.
Actual pan/zoom hosts use bh-diagram-viewport, with
data-bh-dragging="true" only during dragging, for grab/grabbing, touch-action
and user-select behavior. The application retains event handling, pointer capture,
viewport transforms, clipping and fit/export bounds; no native Mermaid layout API
can replace those application gesture mechanics. Rich nodes with decorated outer
rings use data-bh-clickable="true" and data-bh-ring="hover" on the hover ring.
Embedded CSS owns pointer/hover visibility, without changing ring geometry or the
separate selection/disclosure state.
Native evidence-navigation buttons use data-bh-diagram="occurrence" with
aria-current="true" to underline the current occurrence. This is navigation
state, not an execution-status colour; native focus/keyboard behavior stays intact.
Rectangular node/cluster/actor/note surfaces, execution cards, category tiles and
small label surfaces use radius.100 (8 px), including SVG export. Circles,
diamonds and edge paths retain topology geometry. Inspector cards remain 8 px.
Viewport docks use an 8 px frame with 4 px padding and actual 4 px control
buttons, not 8 px Button corners. Dialogs/drawers use radius.150 (12 px).
Follow the Radius role scale.
Authoring previews use diagram.preview-height for both split panels and
diagram.minimum-height for the drawing viewport; fullscreen fills the enclosing
host instead. Read-only split diagrams retain a zero minimum so they shrink with
their host. Structured evidence viewers use diagram.evidence-height; multiple
request-body panes use diagram.evidence-minimum-height to keep every part reachable.
Use a flat opaque sheet. No gradients, glass, decorative animation, animated traversal or state transitions. Retain zoom, fit, fullscreen/escape and PNG export controls. Interaction must not overwrite definition-owned fill, stroke, dashes or failure markers. Controls stay outside the captured SVG host.
Export the rendered theme
Resolve literal token values for Mermaid configuration fields that require them.
Native worker-flow CSS uses its own --hx-* properties; Source supplies their
semantic paint and preserves native literal evidence-edge/arrowhead paint.
Snapshot the rendered theme and opaque canvas background on the SVG host. Export the live, fully decorated drawing at its natural bounds with
exportPadding, not the transformed viewport. Preserve the snapshot even if the
application theme changes before the new drawing lands. Fonts, locale line height,
state paint and outer selection geometry must survive SVG/PNG capture. A transparent
image or white sheet behind dark labels is not a valid fallback.
The native demo snapshots its opaque canvas colour onto each completed SVG before
export. Both the supported published model’s plain <p> labels and local rich
<b> titles retain one completion/reached/unfinished/failure glyph, not colour
alone. Embedded body/title font shorthands explicitly retain Source font.features,
so standalone downloads do not depend on document-wide token CSS for character variants.
All package source is in tokens/diagram.json; consumers must not maintain a
second palette or copy generated token values. Local package references are for
local development only until an authorized release exists.
Use the actual installed model APIs: compactWorkerFlow supplies its public
compact graph and authored-address-to-compact-id map, and compactFlowMermaid
serializes that graph. RenderNodeOverlay accepts only { state?, repeat? };
do not pass roles, caller colour resolvers, stroke overrides or unsupported
renderer options. The native model owns state readings, repeat badges and
implicit indeterminate nodes once any drawn state is supplied.
Log mentions establish only reached or unfinished, never typed ranOk or
ranFailed evidence. The Source mermaidEvidenceStyles adapter accepts compact
node IDs, actual public compact edge indices and explicit { dark, locale }.
Typed evidence takes precedence for named steps and their owned junctions, even when
a failed owner’s junction has no explicit state. Consumers retain authored
address resolution, failure attribution, repeated occurrences and execution data;
source owns theme paint and interaction recipes. No second palette is required.
Edge emphasis uses literal Source colours, not var(...) or custom-property
declarations: Mermaid12’s DSL rejects those functions. Do not append !important
inside the DSL: native coloured-marker cloning treats that suffix as part of
the SVG colour attribute. After rendering/sanitization,
preserveMermaidDefinitionPaint(svg) promotes the actual native edge stroke and
explicit coloured-marker attributes over the worker sheet’s neutral important
paint, without changing paths, marker geometry or IDs. Unknown transitions remain
unknown; consecutive recorded global indices may prove a unique direct edge,
but two executed endpoints alone do not prove a typed traversal.
Shared drawing viewport and dock
Data Flow is the canonical canvas reference: diagram.canvas and diagram.grid,
with diagram.grid-gap (16 px) grid spacing and diagram.grid-dot (1 px) dots in camera coordinates. These are graph
geometry, not reader-target dimensions. .bh-diagram-viewport supplies the Source
dot pattern; bind its --bh-canvas-grid-x, --bh-canvas-grid-y and
--bh-canvas-grid-scale to the existing camera. The SVG root and default stage
body (diagram.group-fill) are transparent on screen, not opaque pale sheets
covering the grid. Native stage boundaries/titles remain intact. Export still
uses the rendered theme’s snapshotted opaque Source canvas.
Put real native controls inside that viewport, outside the transformed drawing
and captured SVG host. bh-diagram-dock on native Space plus bh-control-group
data-bh-variant="dock" supplies the lower-left floating dock and shared native
Data Flow control family. No separate external toolbar/header row and no reserved
blank band. Stop pointer/wheel/non-Escape keyboard propagation on the dock,
preserving native focus, popups and overlay Escape handling. Keep genuine action
differences; do not copy Data Flow-only actions into Mermaid.
The complete native Space role combination keeps both Source insets inside the allocated viewport, including below-readable-minimum hosts. Its width constraint takes precedence over the generic control-group width. Keep one native horizontal scroll row so every action remains fully reachable at larger reader roots; do not clip the last action or override the dock width in a consumer.