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

@eraserlabs/layout

v0.2.0

Published

Eraser's layout geometry and corridor connection router.

Downloads

3,778

Readme

@eraserlabs/layout

Introduction

@eraserlabs/layout is the layout package used by eraser-diagrams. It can also be used independently as a connection router for diagrams whose entities have already been sized and positioned, with @eraserlabs/utils as its only dependency.

Its main routine is the corridor router: it produces orthogonal routes, understands nested containers, avoids obstacles, and can route some or all connections in a diagram, respecting the current coordinates of lines that have already been routed.

For lines that should not travel around anything, straightConnectionEndpoints computes the two terminal points of a single direct segment between the entities' drawn boundaries — the centre-to-centre sight line clipped to each outline, or to the bounding box when an entity has none, with an authored face pinning its endpoint to that face's port. It is a standalone function rather than a routing mode: straight connections are held out of the corridor batch entirely, which is how eraser-diagrams implements connectorStyle: 'straight'.

Why

We could not find a standalone router for arbitrary nested diagrams that also supported partial routing. Existing options tend to be coupled to a complete graph-layout engine or editor, assume a flat diagram, or require every connection to be regenerated together.

@eraserlabs/layout treats entity placement as input. It routes connections around that existing geometry while allowing unaffected routes to remain fixed, which makes it suitable for both initial rendering, incremental edits, and fully interactive drag editing in a GUI editor.

Usage

import {
  LayoutManager,
  routeCorridorConnectionBatch,
  type LayoutEntity,
  type NewConnection,
} from '@eraserlabs/layout';

const entities: LayoutEntity[] = [
  { id: 'client', x: 0, y: 70, width: 120, height: 60 },
  {
    id: 'services',
    x: 220,
    y: 0,
    width: 320,
    height: 200,
    isContainer: true,
  },
  {
    id: 'api',
    containerId: 'services',
    x: 270,
    y: 70,
    width: 100,
    height: 60,
  },
];

const connections: NewConnection[] = [
  { id: 'client-api', from: 'client', to: 'api' },
];

const layoutManager = new LayoutManager({ entities, connections: [] });

routeCorridorConnectionBatch({
  layoutManager,
  connectionsToRoute: connections,
});

const route = layoutManager.getConnectionById('client-api');

layoutManager contains the positioned entities and any existing connections. Entity coordinates are absolute; containerId identifies nesting and isContainer identifies containers. connectionsToRoute selects the new or existing connections to route by their from and to entity IDs. The optional options field of the same argument object controls repair (repair, repairTimeBudgetMs), label placement (labels), port preservation (preservePorts), and whether unaffected routes are pinned (pinUnaffectedRoutes).

Existing connections not included in connectionsToRoute remain fixed by default, enabling partial routing. Pass every connection to reroute a complete diagram. Each result is { connectionId, status }, where status is 'valid' for a connection that received a corridor route and 'fallback' for one that fell back to direct geometry; the resulting polyline is available from the manager as an absolute x / y origin with relative [x, y] points.