@diagc/core

中文文档
1.9.0发布于 2026/11/02AGPL-3.0-onlyTypeScriptES Module零依赖构建来源已验证近 30 天下载 2534

Diagram model, validator, and builder DSL for diagc — no React, no filesystem.

原始使用文档

@diagc/core

The diagram model behind diagc: the DiagramModel types, validate() and the builder DSL. No React, no filesystem — it does not know it is going to be drawn.

npm i -D @diagc/core

Install it alongside the CLI (@diagc/cli) to get types and completion when authoring .diagram.ts files:

import { model } from '@diagc/core';

const m = model('acme', { name: 'Acme platform' });
const web = m.node('web', { name: 'Web app', type: 'service' });
m.relate(web, m.node('db', { name: 'Postgres', type: 'database' }), { kind: 'reads' });

export default m;

diagc compile executes the file and validates whatever it exports, so the CLI works with or without this package installed — it only changes what your editor knows.

Docs and the full model reference: https://github.com/Ferroman/diagc

What 1.0 promises

Semver covers what you need to write or check a diagram: model() and the builder it returns (its classes and option types), the model types such as DiagramModel with the value lists they are built from, and validate(), diagramWarnings() and DiagramValidationError. That is everything @diagc/core exports.

diagc's own packages use a second entry point, @diagc/core/internal: commands, the view compiler, layout helpers. It changes whenever diagc needs it to, in any release, so do not import from it.

License

AGPL-3.0-only, with additional permissions under section 7: diagrams you author, and the pages and images built from them, are yours to license however you like. A commercial license is available. See the project README.

版本与发布记录

@diagc/core 共发布 37 个版本,首次发布于 2026/09/26;过去 12 个月发布了 37 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.9.0latest2026/11/0210 天前
1.8.02026/11/0111 天前
1.7.02026/10/1825 天前
1.6.02026/10/1825 天前
1.5.02026/10/1726 天前
1.4.02026/10/1528 天前

关于 @diagc/core 的常见问题

@diagc/core 是什么?

Diagram model, validator, and builder DSL for diagc — no React, no filesystem.

如何安装 @diagc/core?

在项目目录运行 npm install @diagc/core,或使用 pnpm add / yarn add / bun add。

@diagc/core 支持 TypeScript 吗?

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

@diagc/core 支持 ESM 还是 CommonJS?

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

@diagc/core 需要什么版本的 Node.js?

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

@diagc/core 可以商用吗?

@diagc/core 使用 AGPL-3.0-only 许可。最严格的 Copyleft:除分发外,通过网络向用户提供基于它的服务也需要开源对应源码。闭源 SaaS 使用前务必评估。以上为概括,不构成法律意见,请以许可原文为准。

@diagc/core 的下载量有多少?

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

@diagc/core 还在维护吗?

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