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

@realflow/core

v0.2.1

Published

Headless, zero-dependency engine for node-based UIs: reactive graph store, spatial indexing, auto-layout, undo/redo, interactions.

Readme

@realflow/core

npm version license types

The headless, zero-dependency engine behind RealFlow — a reactive graph store, spatial index, edge-path math, auto-layouts, undo/redo, graph algorithms and an AI-operations layer. No DOM, no React, no dependencies: it runs in the browser, in Node.js, in a worker, or in a test.

@realflow/core is what powers @realflow/react, but you can use it on its own for server-side validation, CLI tooling, or any place you need graph logic without a renderer.

npm install @realflow/core

What's inside

  • Reactive store (FlowStore) — fine-grained pub/sub where each node and edge has its own topic (node:<id>, edge:<id>), so a change touches only what subscribed to it.
  • Spatial hash index — O(1)-ish viewport queries and culling for large graphs.
  • Edge geometrybezier / smoothstep / step / straight, plus orthogonal routing that goes around nodes (Hanan-grid A*).
  • Auto-layoutlayered (Sugiyama, handles cycles), tree, force (seeded/deterministic), radial, grid. Zero deps — no dagre, no elkjs. Plus off-thread (layoutInWorker) and incrementalLayout.
  • Transactional history — every mutation recorded with its inverse; group with transact(label, fn); drags coalesce into one entry.
  • Graph algorithmstopologicalSort, hasCycle, connectedComponents, shortestPath, getAncestors, getDescendants, getIncomers, getOutgoers.
  • AI operations — a validated JSON operation format (applyOperations) that never throws, an LLM tool schema (operationSchema, OPERATIONS_PROMPT), and graph serializers (describeGraph, toMermaid).
  • Real-time collaboration — transport-agnostic Collab (Lamport-clock LWW, order-independent convergence) and Presence.

Quick start

import {
  FlowStore, topologicalSort, hasCycle,
  applyOperations, describeGraph, toMermaid,
} from '@realflow/core';

const store = new FlowStore({
  nodes: [
    { id: 'fetch', position: { x: 0, y: 0 }, data: { label: 'Fetch' } },
    { id: 'parse', position: { x: 240, y: 0 }, data: { label: 'Parse' } },
  ],
  edges: [{ id: 'e1', source: 'fetch', target: 'parse' }],
});

// Graph algorithms on the live store
topologicalSort(store); // ['fetch', 'parse']
hasCycle(store);        // false

// Drive it with validated operations (great for LLM tool-calling / server-side).
// Never throws — invalid ops are collected as errors; one batch = one undo entry.
const { errors } = applyOperations(store, [
  { op: 'add_node', id: 'retry', label: 'Retry (3x)' },
  { op: 'connect', source: 'parse', target: 'retry' },
  { op: 'set_status', id: 'fetch', status: 'running', message: 'batch 4/12' },
]);

// Compact serializations for a model's context
describeGraph(store); // structured JSON
toMermaid(store);     // Mermaid diagram source

Server-side validation

Because the engine is dependency-free and never touches the DOM, you can validate agent- or client-supplied graphs on the server with the exact logic the UI runs:

import { FlowStore, applyOperations, hasCycle } from '@realflow/core';

export function validateGraph(snapshot, ops) {
  const store = new FlowStore();
  store.loadSnapshot(snapshot);
  const { errors } = applyOperations(store, ops);
  if (errors.length) return { ok: false, errors };
  if (hasCycle(store)) return { ok: false, errors: ['graph must be acyclic'] };
  return { ok: true, snapshot: store.toSnapshot() };
}

Related packages

| Package | What it is | | --- | --- | | @realflow/react | React renderer built on this engine | | @realflow/compat | React Flow (xyflow) API compatibility adapter |

Documentation

License

MIT © RealFlow contributors.