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

@immediate-diagram/renderer

v1.2.3

Published

Pluggable layout engine, SVG renderer, animation engine, and timeline playback for Immediate Diagram.

Readme

@immediate-diagram/renderer

Pluggable layout engine, SVG renderer, animation engine, and timeline playback for Immediate Diagram.

Install

bun add @immediate-diagram/renderer

Note: This package publishes raw .ts source. Requires Bun as runtime.

Features

  • 5 layout strategies — graph (dagre), columnar (sequence), polar (pie/donut), nested (block), geometric (venn)
  • SVG rendering — produces self-contained SVG strings with inline styles and interactive hover/focus
  • Animation engine — CSS transition tracking, state interpolation, DOM patching
  • Timeline playback — headless multi-state sequencing with play/pause/step/scrub

Usage

Parse + Layout + Render

import { parseOrThrow } from "@immediate-diagram/parser";
import { narrowDiagram } from "@immediate-diagram/shared";
import { LayoutEngine, renderDiagram } from "@immediate-diagram/renderer";

const doc = parseOrThrow('flowchart\nA["Start"] --> B["End"]');
const diagram = narrowDiagram(doc);

const engine = new LayoutEngine();
const positioned = engine.layout(diagram);
const svg = renderDiagram(positioned);
// svg is a complete <svg>...</svg> string

Layout Strategies

Each diagram type uses an appropriate layout strategy:

| Strategy | Diagram Types | Implementation | |----------|--------------|----------------| | GraphLayoutStrategy | flowchart, architecture | @dagrejs/dagre (~30KB) | | ColumnarLayoutStrategy | sequence | Custom (zero deps) | | PolarLayoutStrategy | pie, donut | Custom (zero deps) | | NestedLayoutStrategy | block | Custom (zero deps) | | GeometricLayoutStrategy | venn | Custom (zero deps) |

Animation

Apply state overrides and animate between states:

import { applyState, filterHiddenElements } from "@immediate-diagram/renderer";

// Apply a named state to a diagram AST (mutates styles, hides elements)
const stateAst = applyState(diagram, "active");

Timeline Playback

import { createTimelineEngine } from "@immediate-diagram/renderer";

const engine = createTimelineEngine({
  steps: [
    { from: "default", to: "active", durationMs: 1000 },
    { from: "active", to: "done", durationMs: 800 },
  ],
  onStateChange: (from, to) => console.log(`${from} -> ${to}`),
  onProgress: (progress) => console.log(`${(progress * 100).toFixed(0)}%`),
});

engine.play();

API Reference

Layout

  • LayoutEngine — orchestrates strategy selection and layout computation
  • GraphLayoutStrategy — dagre-based directed graph layout
  • ColumnarLayoutStrategy — column-based sequence diagram layout
  • PolarLayoutStrategy — radial pie/donut chart layout
  • GeometricLayoutStrategy — circle-packing Venn diagram layout
  • NestedLayoutStrategy — recursive nested block layout

Rendering

  • renderDiagram(positioned) — renders any PositionedDiagram to SVG string
  • renderGraphDiagram(), renderSequenceDiagram(), renderPieDiagram(), renderBlockDiagram(), renderVennDiagram() — type-specific renderers

Animation

  • applyState(diagram, stateName) — apply state overrides to a diagram AST
  • filterHiddenElements(ast) — remove visible: false elements from AST
  • AnimationEngine — full animation engine with interpolation and DOM patching
  • createFrameController() — rAF-based frame loop controller

Timeline

  • createTimelineEngine() — headless timeline playback
  • TimelineManager — manages multiple timeline definitions
  • createTimelineAnimationConnector() — connects timeline engine to animation engine

Development

bun test            # Run tests
bun run typecheck   # Type checking
bun run bench       # Run benchmarks

License

MIT