@hanzo/canvas

中文文档
0.2.4发布于 2026/09/05MITTypeScriptES Module零依赖近 30 天下载 5307

Pannable/zoomable PaaS project canvas — a board of service nodes with live status, metric sparklines, deploy timelines, an environment switcher, and a service detail drawer. Host-agnostic @hanzo/gui React surface, brand/white-label aware, shared by every

原始使用文档
文档目录3 节
  1. Install
  2. The pieces
  3. Usage

@hanzo/canvas

A pannable/zoomable PaaS project canvas for any Hanzo console — a board of service nodes with live status, metric sparklines, deploy timelines, an environment switcher, and a service detail drawer.

Built on @hanzo/gui (so it is brand / white-label aware via the design tokens — the same components render in the Hanzo, Lux, and Zoo consoles in each brand) with an optional @xyflow/react peer for the canvas itself.

Every component is presentational and data-prop-driven: the host fetches its /v1 rows and maps them into the plain view-models in ./types. The pure folds (status normalization, layout, relative time) are unit-tested in isolation; the components never reach into a data layer. One way to do everything, decomplected.

Install

pnpm add @hanzo/canvas
# peers: @hanzo/gui, react, react-dom, and (for the canvas) @xyflow/react

The pieces

ExportWhat it is
ProjectCanvasThe pan/zoom board (React Flow): dot-grid, minimap, controls, auto-layout, theme-aware. Dynamic-import with SSR disabled.
ServiceNodeThe layered service card — icon, name, type + /v1 capability, status badge, source ref, replicas, latest-deploy time, metric sparkline.
ServiceStatusBadgeStatus pill (dot + label) with a live pulse for active/deploying.
MetricSparklineA tiny honest sparkline (flat baseline when there is no data — never a fake trend).
DeployTimelineA vertical deploy/build timeline.
EnvSwitcherA segmented environment switcher (production / preview / …).
ServiceDetailDrawerA right-side drawer with a service header + host-supplied tabs (Deployments, Variables, Metrics, Logs, Domains, SBOM).
SourceRef, ReplicaPillSmall primitives — a repo/image source ref and a replica-count pill.
normalizeServiceStatus, layoutGraph, relativeTime, toEpochMs, statusColors, withAlpha, kindLabelPure helpers the host maps its data through.

Usage

import dynamic from 'next/dynamic'
import { type ServiceNodeData } from '@hanzo/canvas'

// The canvas touches browser globals at import — load it client-side only.
const ProjectCanvas = dynamic(
  () => import('@hanzo/canvas').then((m) => m.ProjectCanvas),
  { ssr: false },
)

const nodes: ServiceNodeData[] = apps.map((a) => ({
  id: a.id,
  name: a.name,
  kind: 'app',
  status: normalizeServiceStatus(a.phase ?? a.status),
  source: { kind: 'image', ref: `${a.image.repository}:${a.image.tag}` },
  replicas: a.replicas,
  deployedAt: toEpochMs(a.updatedAt),
  capability: { id: 'platform', label: 'App Platform' },
}))

<ProjectCanvas
  nodes={nodes}
  edges={edges}
  theme={resolvedTheme}
  reducedMotion={reducedMotion}
  onOpenDetail={(svc) => setSelected(svc)}
/>

Status colors are semantic, not brand (green = active, amber = deploying, red = crashed, …) and overridable per brand via the statusPalette prop; all card chrome uses the neutral design tokens, so the canvas takes on each brand's theme automatically.

版本与发布记录

@hanzo/canvas 共发布 5 个版本,首次发布于 2026/07/10;过去 12 个月发布了 5 个版本。

版本发布日期距今
0.2.4latest2026/09/052 个月前
0.2.32026/08/242 个月前
0.2.22026/08/053 个月前
0.2.12026/07/283 个月前
0.1.02026/07/104 个月前

关于 @hanzo/canvas 的常见问题

@hanzo/canvas 是什么?

Pannable/zoomable PaaS project canvas — a board of service nodes with live status, metric sparklines, deploy timelines, an environment switcher, and a service detail drawer. Host-agnostic @hanzo/gui React surface, brand/white-label aware, shared by every

如何安装 @hanzo/canvas?

在项目目录运行 npm install @hanzo/canvas,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=19.2.8)、react-dom(>=19.2.8)、@hanzo/gui(>=8.3.1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@hanzo/canvas 支持 TypeScript 吗?

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

@hanzo/canvas 支持 ESM 还是 CommonJS?

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

@hanzo/canvas 可以商用吗?

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

@hanzo/canvas 的下载量有多少?

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

@hanzo/canvas 还在维护吗?

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