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

mermaid-flow-player

v0.1.6

Published

Animate Mermaid-rendered diagrams with semantic node/edge steps and scenarios

Readme

mermaid-flow-player

Animate Mermaid-rendered diagrams (flowcharts, etc.) with a semantic API: target nodes by ID (e.g. A, B, X1) and play scenarios (steps over time) without depending on Mermaid's internal DOM structure.

Use via CDN with no install required. (Not published to npm; only built dist is published. Use CDN URLs or build from source and host the scripts yourself.)

Quick start (CDN)

One script: CSS is bundled and injected by the library. Add Mermaid, then the flow player:

<!-- 1. Mermaid -->
<script src="https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.min.js"></script>

<!-- 2. Flow player (auto mode: zero config, styles injected automatically) -->
<script type="module" src="https://cdn.jsdelivr.net/npm/mermaid-flow-player/auto.js"></script>

Every .mermaid diagram gets play controls automatically. Or use the API with the full library (one script, styles still injected):

<script type="module">
  import { createFlowPlayer } from 'https://cdn.jsdelivr.net/npm/mermaid-flow-player';

  const player = createFlowPlayer({
    root: document.getElementById('diagram')
  });

  await player.ready();
  await player.play(player.path('A', 'B', 'C'));
</script>

CDN URL builder: docs site → CDN Builder. Pick options and copy script tags or query params.

Usage (programmatic)

import { createFlowPlayer } from 'https://cdn.jsdelivr.net/npm/mermaid-flow-player';

const root = document.getElementById("diagram");
const player = createFlowPlayer({
  root,
  persist: "visited",
  dim: "others",
  edgeMode: "bestEffort",
});

await player.ready();
await player.play(player.path("A", "B", "C", "E", "F", "G", "J"), { speed: 1.1 });

Use stable, simple node IDs in your Mermaid diagram (e.g. A, B, X1) so path() and steps line up.

Features

Multi-Diagram Support

Auto-detects and animates 7 diagram types:

  • Flowcharts, Sequence Diagrams, State Diagrams, Gantt Charts, User Journey, Class Diagrams, ER Diagrams

All diagram types use the same animation API; just change your Mermaid diagram type and the player adapts automatically.

Narration

Automatically update narration text as animation progresses:

createFlowPlayer({
  root: diagram,
  narrationTarget: '#narration',
});

await player.play([
  { type: 'node', id: 'A', note: 'Starting...' },
  { type: 'node', id: 'B', note: 'Processing...' },
]);

Animation Easing

Control animation timing with 30+ easing functions: standard CSS, back, elastic, bounce, power curves, and custom cubic-bezier().

createFlowPlayer({
  root: diagram,
  easing: {
    default: 'ease-out-back',
    states: {
      active: 'ease-out-elastic',
      success: 'ease-out-bounce',
    }
  }
});

Enhanced Edge Animation

Multi-strategy edge detection with automatic fallback:

createFlowPlayer({
  root: diagram,
  edgeMode: 'bestEffort',
  edgeDetection: {
    strategy: ['title', 'data-attr', 'text', 'path-trace'],
    debug: true,
  }
});

Scenario Builder API

Build complex animations with a fluent, chainable API:

import { createScenarioBuilder } from 'https://cdn.jsdelivr.net/npm/mermaid-flow-player@latest';

await createScenarioBuilder()
  .node('Start', { note: 'Beginning' })
  .wait(500)
  .node('Process', { state: 'active' })
  .node('End', { state: 'success' })
  .play(player);

Features: chainable methods, diagram-specific builders (flowchart, sequence, state), repeat(), conditional(), template registry.

Plugin System

Extend functionality with lifecycle hooks:

import { createFlowPlayer, type Plugin } from 'https://cdn.jsdelivr.net/npm/mermaid-flow-player@latest';
import { AnalyticsPlugin, KeyboardControlsPlugin } from 'https://cdn.jsdelivr.net/npm/mermaid-flow-player@latest';

const player = createFlowPlayer({
  root: diagram,
  plugins: [AnalyticsPlugin, KeyboardControlsPlugin],
});

Built-in plugins: AnalyticsPlugin (event tracking), KeyboardControlsPlugin (Space/R/Arrow keys).

Web Component

Drop-in <mermaid-flow-player> custom element. Diagram from inner text (or diagram attribute):

<script src="https://cdn.jsdelivr.net/npm/mermaid-flow-player@latest/mermaid-flow-player.element.js"></script>

<mermaid-flow-player autoplay controls>
  graph LR; A-->B-->C
</mermaid-flow-player>

Interactive Mode

Step-through with user-controlled path selection:

const player = createFlowPlayer({ root: diagram, mode: 'interactive' });
await player.nextStep();

Validation and user feedback

Diagram validity comes from Mermaid (they run in the browser). We propagate their errors; listen for mfp:error or use normalizeMermaidError(e) when you call mermaid.run() / mermaid.render(). For scenario-vs-index (after render), use player.validateScenario(steps) and show result.availableNodeIds for suggestions.

import { normalizeMermaidError } from '…';
try {
  await mermaid.run({ nodes: [el] });
} catch (e) {
  const payload = normalizeMermaidError(e);
  showInUI(payload.message, payload.detail);
}

Scenario-vs-index (after the diagram has rendered): use player.validateScenario(steps) to check that step IDs exist and get availableNodeIds for "Did you mean: A, B, C?". assertIds(ids) throws with available node IDs in the message.

Auto Modes

Zero-config usage:

import { autoInit } from 'https://cdn.jsdelivr.net/npm/mermaid-flow-player@latest/auto-init.js';
autoInit({ controls: true, narration: true });

URL Query Parameter Configuration

Configure via URL without JavaScript: page.html?theme=dark&speed=1.5&dim=none

| Parameter | Values | Default | |-----------|--------|---------| | theme | light, dark, auto | auto | | speed | 0.1 to 10 | 1.2 | | dim | none, others | others | | persist | none, visited | visited | | edge | off, bestEffort | off | | mode | sequential, interactive | sequential | | selector | CSS selector (e.g. .my-diagram) | .mermaid (auto modes only) | | debug | (presence) | false | | autoplay | (presence) | false |

License

MIT