@bendyline/squisq-graph

中文文档
2.13.1发布于 2026/10/29MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 2946

Graph layout for squisq: a compound layered layout with orthogonal edge routing, nested containers with shared border ports, deterministic, dependency-free, and runnable in a Web Worker

原始使用文档

@bendyline/squisq-graph

Graph layout for squisq: a compound layered ("Sugiyama") layout with orthogonal edge routing. Give it boxes, optional containers, and edges; it returns positions for every box and an axis-aligned route for every edge.

  • Edges flow one way. Cycles are broken by drawing the fewest edges against the flow, and nodes are ordered to cross as little as possible.
  • Containers stay whole. Nodes may nest inside container nodes to any depth. Each container is laid out on its own, so its contents never leak out, and edges leave it through ports on its border. Edges toward the same neighbor share one port (or, with portSharing: 'container', every edge shares one port per side).
  • Fans read as trees. Long edges into one node share their bend points, and runs that converge in a channel share a track, so a hub draws as a trunk with branches rather than a comb of parallel lines.
  • Deterministic. The same input always gives the same output; ties are broken by input order. graphSignature fingerprints a graph and its options for caching.
  • Any unit. Size nodes in pixels, or in character cells with integerCoordinates: true.
  • Off the main thread. createWorkerLayoutEngine runs layouts in a Web Worker and falls back to the calling thread where none can start.

Zero runtime dependencies; runs in the browser and Node.

import { layoutGraph, polylinePath } from '@bendyline/squisq-graph';

const result = layoutGraph(
  {
    nodes: [
      { id: 'src', width: 60, height: 24 },
      { id: 'a.ts', width: 80, height: 28, parent: 'src' },
      { id: 'b.ts', width: 80, height: 28, parent: 'src' },
      { id: 'main.ts', width: 90, height: 28 },
    ],
    edges: [
      { id: 'm-a', source: 'main.ts', target: 'a.ts' },
      { id: 'a-b', source: 'a.ts', target: 'b.ts' },
    ],
  },
  { direction: 'right' },
);

for (const edge of result.edges) {
  const d = polylinePath(edge.points, { radius: 6 });
  // <path d={d} marker-end="url(#arrow)" />
}

In squisq itself it places auto-laid-out nodes of the diagram template and backs the ASCII diagram editor's Arrange action (arrangeAsciiDiagram).

Part of the squisq monorepo. MIT licensed.

版本与发布记录

@bendyline/squisq-graph 共发布 3 个版本,首次发布于 2026/10/21;过去 12 个月发布了 3 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.13.1latest2026/10/2910 天前
2.13.02026/10/2117 天前
0.0.0-stage2026/10/2117 天前

关于 @bendyline/squisq-graph 的常见问题

@bendyline/squisq-graph 是什么?

Graph layout for squisq: a compound layered layout with orthogonal edge routing, nested containers with shared border ports, deterministic, dependency-free, and runnable in a Web Worker

如何安装 @bendyline/squisq-graph?

在项目目录运行 npm install @bendyline/squisq-graph,或使用 pnpm add / yarn add / bun add。

@bendyline/squisq-graph 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@bendyline/squisq-graph 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@bendyline/squisq-graph 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^22.22.2 || ^24.15.0 || >=26.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@bendyline/squisq-graph 可以商用吗?

@bendyline/squisq-graph 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bendyline/squisq-graph 的下载量有多少?

根据 npm 官方下载统计,@bendyline/squisq-graph 在 2026/10/08 – 2026/11/06 这 30 天内被下载 2,946 次,日均约 98 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bendyline/squisq-graph 还在维护吗?

最新版本 2.13.1 发布于 2026/10/29(10 天前);至今共发布 3 个版本,其中过去 12 个月发布了 3 个;首次发布于 2026/10/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。