npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@svjeez/mermaid

v0.6.1

Published

Mermaid text to animated svjeez diagrams: flowcharts, sequence diagrams and state diagrams, parsed by hand with no dependencies.

Readme

@svjeez/mermaid

Mermaid text for svjeez scenes. mermaid() reads a flowchart, sequence diagram or state diagram and hands it to svjeez's flowchart(), sequence() or stateMachine(), so the diagram comes out themed, laid out and animated like any other svjeez diagram. The parser is a small hand-written one with no dependencies, and it never needs a DOM, so it runs while the scene builds.

Install

npm i -D @svjeez/mermaid svjeez

Use

import { mermaid } from "@svjeez/mermaid";
import { render } from "svjeez";

const chart = mermaid(
  `flowchart LR
    pr([PR opened]) --> lint[Run linters]
    lint --> ok{Clean?}
    ok -->|yes| post([Post review])
    ok -->|no| fix[Draft fixes] --> lint`,
  { x: 40, y: 40, play: { at: 0.4, step: 0.4 } },
);

export default () =>
  render(
    { width: chart.bounds.w + 80, height: chart.bounds.h + 80, duration: 6, title: "Review" },
    chart.node,
  );

mermaid(text, options) returns the svjeez diagram, plus kind and the parsed doc. Narrow on kind to reach what only one diagram has:

const d = mermaid(text);

if (d.kind === "state") d.walk(["Idle", "Run"], { at: 1 });
if (d.kind === "flowchart") d.route("a", "b");
if (d.kind === "sequence") d.message(0);

The options are svjeez's own, passed straight through: theme, font, fontSize, x, y, anchor, class, direction (flowcharts and state diagrams) and play (flowcharts and sequence diagrams). Each kind reads the options it knows. direction in the options wins over the one in the text.

parse(text) returns the plain model without importing svjeez: a FlowchartDoc, SequenceDoc or StateDoc, told apart by kind. Use it to lint or transform Mermaid text, or to build the svjeez spec yourself.

What it reads

Anything else throws a MermaidSyntaxError with the line number, the line and what is supported. A line is never dropped. %% comment lines, blank lines and a trailing ; are ignored, and <br> in a label becomes a space.

Flowcharts

  • flowchart or graph, then TD, TB, LR, BT or RL. Without a direction it is TD. svjeez lays out TB and LR only, so mermaid() throws on BT and RL unless you pass direction.

  • Node forms, which pick a svjeez node role:

    | Mermaid | Form | svjeez role | | --- | --- | --- | | A[text] | rectangle | task | | A(text) | rounded | task | | A([text]) | stadium | input | | A{text} | diamond | decision | | A((text)) | circle | output | | A[[text]] | subroutine | tool | | A[(text)] | cylinder | store |

    Quote a label that holds a bracket: A["list[0]"]. The table is exported as FORM_ROLES.

  • Edges -->, ---, -.->, ==>, with labels as -->|text| or -- text -->. Edge styles are parsed into the model, but svjeez draws every edge as a solid arrow.

  • Chains A --> B --> C and lists A & B --> C & D.

  • subgraph id [Title], subgraph Title and end. A node mentioned inside a subgraph belongs to the first subgraph that mentions it. Subgraphs cannot nest, cannot be empty and cannot be an edge's end.

  • Not supported: classDef, class, style, linkStyle, click, direction and title lines, ::: classes, other arrow heads such as --o.

Sequence diagrams

  • participant A, actor A and participant A as Alice. A participant first named in a message is declared there. An actor draws with the input role and a participant with task.
  • Messages A->>B: text, with ->>, -->>, ->, -->, -x, --x, -) and --). A -- arrow draws dashed, like a reply. svjeez draws every head the same, and A->>A loops on the right.
  • Note over A: text, on one actor.
  • Not supported, and rejected: Note left of, Note right of, notes over several actors, activate, deactivate, the + and - activation marks, loop, alt, opt, par and the other blocks, autonumber, box, create, destroy.

State diagrams

  • stateDiagram or stateDiagram-v2.
  • [*] --> A is the start, and A --> [*] marks A final. Every scope needs exactly one start, and the start and end lines take no label.
  • A --> B and A --> B : label.
  • state "Long name" as A, and composite states state A { ... } with their own start. Transitions may cross levels.
  • direction LR or TB once, at the top.
  • Not supported: <<choice>>, <<fork>> and <<join>>, note, concurrency with --, A : description, direction inside a composite.

The model

parse() and mermaid().doc give plain data.

  • FlowchartDoc: direction, nodes (id, label, form), edges (from, to, label, line, arrow) and subgraphs (id, title, nodes).
  • SequenceDoc: participants (id, label, role) and items, each a message (from, to, text, line, head) or a note (actor, text).
  • StateDoc: initial, direction, states (id, label, final, inner) and transitions (from, to, label).

Errors

MermaidSyntaxError has line and source beside its message, such as Mermaid syntax error on line 4 ("classDef red fill:#f00"): classDef is not supported: …. mermaid() also throws for a BT or RL flowchart. Errors from svjeez itself, such as a walk() through a state that does not exist, keep svjeez's message.