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

@ai-matrx/diagrams

v0.4.17

Published

The AI Matrx diagram engine: Archify 3.2.0 as pure functions (validate, layout, render) for ten diagram types, plus the pure-DOM measurement script that turns a rendered diagram into numbers.

Readme

@ai-matrx/diagrams

The AI Matrx diagram engine: Archify 3.2.0 (MIT) refactored into pure functions. A spec goes in; a validated, laid-out, self-contained diagram comes out, in Node or in the browser, with no Node built-ins, no filesystem and no network.

npm install @ai-matrx/diagrams
import { validate, layout, render } from "@ai-matrx/diagrams";

const spec = { meta: { title: "Checkout", subtitle: "Order to paid" }, /* ... */ };

const checked = validate("workflow", spec, { quality: "showcase" });
// { ok, diagnostics: [{ code, severity, message, subject, evidence, supportedFixes }], composition, checks }

const geometry = layout("workflow", spec); // { receipt }  (Archify's --layout-json contract)
const picture = render("workflow", spec, { theme: "dark" }); // { svg, html, receipt }

Ten types: architecture, workflow, sequence, dataflow, lifecycle, erd, class, tree, timeline, waterfall. Every function never throws on bad input: schema errors, layout refusals and unknown types come back as Diagnostics, each saying what is wrong, where, with the numbers, and which fixes are supported.

render().html is Archify's complete standalone explorer page (about 800 KB, fonts included) and is byte-identical to what the Archify CLI writes (the package's parity test proves it for all 25 bundled examples). render().svg is the diagram alone; it takes its colors from the CSS variables of the surrounding page.

Embedding in an app

render(type, spec, { theme, mode: "embed", legend? }) returns the picture for hosting inside your own UI: no header, theme toggle, export menu, toolbar, passport popup, node index or cards. svg is self-themed (theme tokens, classes and fonts inline, all scoped to svg.mxd) and always shows the WHOLE picture: never cropped, never a sideways scroll. bindEmbed fits it to its container in both axes (a content-height host gets the full width with a capped height) and adds zoom (Ctrl/Cmd+wheel or pinch, drag to pan, zoomIn/zoomOut/resetZoom on the handle, or controls: true for built-in buttons). data-mxd-min-width is the legibility floor as a measurement. html is a small document for an iframe srcdoc that fits its window and draws its own zoom buttons. Clicking or activating a node emits diagram:node (detail: {id, label, type}; a CustomEvent on the svg, plus a postMessage to the parent when framed), so your UI decides what to show. When you mount the svg string yourself, call bindEmbed(svgElement) once it is in the document.

Node state over the picture, never moving it: handle.setNodeState({status, current, tone}) (or the nodeState bind option) draws a status per node (idle|pending|running|done|warning|failed|skipped: outline, fill tint, corner glyph; running spins unless the reader prefers reduced motion), one "you are here" node (a dashed ring and aria-current="step", distinct from select), and a categorical tone per node (cyan|green|violet|amber|rose|orange|slate). Every color is one of the picture's own theme tokens. handle.legend() lists only what is drawn, with the color actually used (DIAGRAM_NODE_STATUSES, DIAGRAM_NODE_TONES name the sets).

Choosing a target width

DESKTOP_READER_DIAGRAM_WIDTH is the engine's desktop reader width, currently 930 CSS pixels. A targetWidth below it enables narrow-layout adaptation and, when needed, a wider fallback. At or above it the engine draws the spec as written. A host retrying an adapted diagram in a wide container can use DESKTOP_READER_DIAGRAM_WIDTH - 1 to retain narrow-layout adaptation.

import { DESKTOP_READER_DIAGRAM_WIDTH, render } from "@ai-matrx/diagrams";
const picture = render("workflow", spec, { targetWidth: DESKTOP_READER_DIAGRAM_WIDTH - 1 });

Measuring a render

@ai-matrx/diagrams/measure is one pure-DOM function that turns a rendered diagram into numbers (inspection.v1): text sizes, clipped and truncated text, overlaps, out-of-bounds elements, crossings, labels sitting on lines, and text contrast.

import { measure } from "@ai-matrx/diagrams/measure";
const inspection = measure(document.querySelector("svg")!);

For headless capture, inject the same function as text so a browser and a headless page return the same JSON:

import { MEASURE_SCRIPT, SETTLE_EXPRESSION, measureExpression } from "@ai-matrx/diagrams/measure";
await page.setContent(render("workflow", spec).html!);
await page.evaluate(SETTLE_EXPRESSION); // fonts + the viewer's layout
const inspection = await page.evaluate(measureExpression("svg"));

What is not here

No React (the chat and canvas renderers live in @ai-matrx/rich-content), no browser launching (the scraper does headless capture), no file output, no git or repository-evidence verification, and no network brand capture. Built-in brand ids resolve; a bare URL or digest-pinned brand is refused with a diagnostic. See NOTICE for what was taken from Archify, what changed, and which third-party marks were dropped for licence reasons.

There is a thin CLI (ai-matrx-diagrams render|validate|layout); it exists only for parity testing against the original Archify CLI.