Skip to main content

Module diagrams

Module diagrams 

Source
Expand description

The diagram engine: every Mermaid fence drawn to SVG on the server, by the vendored pele bundle running in QuickJS.

A QuickJS runtime can’t move between threads, so one thread of its own — the diagram thread — owns it, with pele loaded once, and draws what it is sent over a channel. In front of it, a cache keeps each drawing by the diagram’s source. Each drawing gets a time limit, enforced by QuickJS’s interrupt handler, and the runtime a memory limit; a runtime that hit one is dropped, and the next diagram gets a fresh one.

Functions§

draw_all
Draws each diagram, from the cache when it was drawn before.
draw_fences
Replaces each Mermaid block of rendered HTML — <pre lang="mermaid">, as the highlighter leaves it — with its drawing in a <div class="diagram">, or, when it can’t be drawn, with the error block: Diagram error:, the reason, and the diagram’s source.
start
Starts the diagram thread, which loads pele in the background, so the first page with a diagram doesn’t wait for it.

Type Aliases§

Drawn
What drawing a diagram gave: its SVG, or why there is none.