@harnessio/pipeline-graph

中文文档
1.11.0发布于 2026/11/13Apache-2.0TypeScriptES Module近 30 天下载 6.1万

A library for generating and interacting with pipeline graphs.

原始使用文档
文档目录5 节
  1. Anatomy
  2. Model
  3. Container and Content nodes
  4. Edges
  5. Canvas

Pipeline Graph

A library for generating and interacting with pipeline graphs.

pipeline graph

Anatomy

  • Model
  • Container and Content nodes
  • Edges
  • Canvas

Model

Type AnyContainerNodeType us a union of LeafContainerNodeType | ParallelContainerNodeType | SerialContainerNodeType and represent one node. LeafContainerNodeType node does not have children while other have.

Example of the model

const model: AnyContainerNodeType[] = [
  {
    type: 'stage',
    children: [{ type: 'step' }, { type: 'step' }]
  }
]

In order to visualize our model we need container and content nodes.

Container and Content nodes

Container node

Container node is responsible for layout and basic user interaction like adding/deleting nodes. There are three containers: Leaf, Serial and Parallel. Leaf render one Content node, while Serial/Parallel renders itself and children.

Container node anatomy:

  • Metadata - At the very root div we have data-path and data-action attributes which are used for event delegation purpose.
  • Relative positioning - root div has position:relative so we can use absolute position for styling in the content node.
  • Ports - Port is div. It's position is used for calculating and drawing links between ports.
  • Add/Delete containers - are used for capturing mouse hover (via css). They have buttons that appears on mouse hover.

Content node

Content nodes are responsible for the content of the node (like text, icons etc.) and visualizing state (like loading or selection)

Pairing Content and Connection nodes

In order to render our graph we have to pair container and content node. For this we uses NodeContent type.

const nodes: NodeContent[] = [
  // register "step" content node which will render "StepContentNode" inside "leaf" container
  {
    type: "step",
    component: StepContentNode,
    containerType: ContainerNode.leaf
  },
  // register "stage" content node which will render "SerialGroupContentNode" inside "serial" container
  {
    type: "stage",
    component: SerialGroupContentNode
    containerType: ContainerNode.serial,
  }
]

Edges

Connection lines between nodes are drawn using svg paths. Lines are calculated using ports (which are part of container nodes).

Canvas

Library provides pan and pinch-to-zoom out of the box. For creating manual controls for zoom in/out and fit we can use useCanvasContext that exposes increment, decrement and fit functions.

Implementing custom controls example

const { increase, decrease, fit } = useCanvasContext()

return <>
    <button onClick={() => increase()}>+</button>
    <button onClick={() => decrease()}>-</button>
    <button onClick={() => fit()}>FIT</button>
</>

版本与发布记录

@harnessio/pipeline-graph 共发布 32 个版本,首次发布于 2025/01/22;过去 12 个月发布了 17 个版本。

版本发布日期距今
1.11.0latest2026/11/134 天前
1.10.02026/10/131 个月前
1.9.72026/08/133 个月前
1.9.62026/02/069 个月前
1.9.52026/02/069 个月前
1.9.42026/02/069 个月前

其他发布通道:alpha → 1.0.0-alpha.0。

关于 @harnessio/pipeline-graph 的常见问题

@harnessio/pipeline-graph 是什么?

A library for generating and interacting with pipeline graphs.

如何安装 @harnessio/pipeline-graph?

在项目目录运行 npm install @harnessio/pipeline-graph,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^17.0.2)、react-dom(^17.0.2)、@types/react(^17.0.3)、@types/react-dom(^17.0.3)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@harnessio/pipeline-graph 支持 TypeScript 吗?

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

@harnessio/pipeline-graph 支持 ESM 还是 CommonJS?

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

@harnessio/pipeline-graph 可以商用吗?

@harnessio/pipeline-graph 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@harnessio/pipeline-graph 的下载量有多少?

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

@harnessio/pipeline-graph 还在维护吗?

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