OpenRobot.Litegraph.Common
1.0.0
dotnet add package OpenRobot.Litegraph.Common --version 1.0.0
NuGet\Install-Package OpenRobot.Litegraph.Common -Version 1.0.0
<PackageReference Include="OpenRobot.Litegraph.Common" Version="1.0.0" />
<PackageVersion Include="OpenRobot.Litegraph.Common" Version="1.0.0" />
<PackageReference Include="OpenRobot.Litegraph.Common" />
paket add OpenRobot.Litegraph.Common --version 1.0.0
#r "nuget: OpenRobot.Litegraph.Common, 1.0.0"
#:package OpenRobot.Litegraph.Common@1.0.0
#addin nuget:?package=OpenRobot.Litegraph.Common&version=1.0.0
#tool nuget:?package=OpenRobot.Litegraph.Common&version=1.0.0
OpenRobot.Litegraph.Common
Litegraph 流程引擎的基础模型层(net8.0):画布图模型 + JS 语义取值 + 共享文本工具。 只描述「一张图画的是什么」,不含解析、校验与执行。
- 只读图模型:
FlowGraph/FlowNode/FlowLink/FlowPort/FlowPropertyBag是解析产物,也是节点处理器的输入。 集合在装配期一次写入、运行期只读,对外只暴露IReadOnlyList视图。 - 节点类型常量集中:
NodeTypes收全部 46 个nodeType字面量,PortTypeMap给数据类型到端口类型 / 显示后缀的映射。 宿主与处理器一律引用常量,不手写字符串。 - JS 语义对齐:
Js实现前端 Litegraph 依赖的那套取值语义(松散比较、真值判断、类型强转、整数值不带小数尾巴), 保证同一份画布在浏览器里和在 C# 里算出同一个结果。 - 零外部依赖:nuspec 依赖 group 为空。不引日志、不引 DI、不读配置,任何形态的宿主都能直接引用。
安装
<PackageReference Include="OpenRobot.Litegraph.Common" Version="1.0.0" />
包由本仓库产出:
dotnet pack Litegraph/OpenRobot.Litegraph.Common/OpenRobot.Litegraph.Common.csproj -c Release
依赖:无。包内只用 BCL 的 System.Text.Json 与 System.Globalization。
数字与日期格式化一律走
CultureInfo.InvariantCulture,不随宿主区域设置变化。
快速开始
图模型由解析器产出(OpenRobot.Litegraph.Core 的 FlowGraphParser / LitegraphService),
本包提供类型与只读视图。拿到 FlowGraph 之后按 nodeType 分发、用类型化 getter 读配置:
using OpenRobot.Litegraph.Common.Models;
using OpenRobot.Litegraph.Common.Text;
foreach (var node in graph.Nodes)
{
if (node.NodeType == NodeTypes.TriggerTimer)
{
// 缺键、类型不对都回落默认值,不抛
var interval = node.Properties.GetInt("interval", 1000);
Console.WriteLine($"#{node.Id} {node.Title} 每 {ValueFormat.Duration(interval)} 触发一次");
}
}
查上下级
FlowGraph 自带邻接查询,不必自己遍历 Links:
var node = graph.GetNode(7)!;
foreach (var link in graph.IncomingLinks(node))
{
var origin = graph.OriginOf(link); // 上游节点
var connected = graph.IsInputConnected(node, link.TargetSlot);
}
格式化日志
ValueFormat 统一了截断与时间口径,避免各处自己拼字符串:
ValueFormat.Format(7000.0); // "7000"
ValueFormat.Format(null); // "<null>"
ValueFormat.FormatList(new object?[] { 1, "a" }); // 1, "a"
ValueFormat.Duration(420); // "420ms"
ValueFormat.Duration(1234.5); // "1.234s"
ValueFormat.Time(DateTimeOffset.Now); // "14:03:22.517"
API 速查
图模型
| 类型 | 说明 |
|---|---|
FlowGraph |
一张画布:Nodes / Links / ById / GetNode(id) / IncomingLinks / OutgoingLinks / FindUpstreamFlowStarts |
FlowNode |
节点:Id / NodeType / Title / Inputs / Outputs / Properties / Binding / IsMuted |
FlowLink |
连线:Id / OriginId / OriginSlot / TargetId / TargetSlot / Type |
FlowPort |
端口:Name / Type / Label / Index / IsInput / IsLinked / IncomingLinks |
FlowPropertyBag |
properties 字典:GetString / GetInt / GetDouble / GetBool / GetList / GetObject,全部带默认值 |
NodeRuntimeBinding |
节点运行期挂载点:Init / Timer / Unsubscribe / Cts / Lane + DisposeAll() |
FlowSectionKind |
区域种类:主流程 / 子流程 / 触发流程 |
常量与目录
| 类型 | 说明 |
|---|---|
NodeTypes |
46 个 nodeType 常量(smart/link/call、smart/trigger/timer、smart/logic/if …) |
PortTypeMap |
PortType(dataType) / TypeSuffix(dataType) / LabelWithType(...):数据类型 → 端口类型与显示后缀 |
VariableCatalog |
用户变量表按 id / 名字查找,DataTypeOf / DefaultValueOf |
ConditionRule |
条件节点的 Operator / RightOperand / RightValue,From(bag, prefix) 直接从 properties 取 |
文本与取值
| 类型 | 说明 |
|---|---|
Js |
JS 语义:Number / String / LooseEquals / StrictEquals / Truthy / Coerce / Round / DoubleToString |
ValueFormat |
Format / FormatList / FormatNamed / Truncate / Duration / Time;默认上限 512 字符 |
LitegraphJson |
共享的 JsonSerializerOptions / JsonDocumentOptions,图 JSON 的唯一读写口径 |
已知限制
- 不能在图模型上造图:
FlowGraph.Nodes/Links与FlowNode.Inputs/Outputs的 setter 是internal, 只有OpenRobot.Litegraph.Core写得进去。要在进程里得到一张图,走FlowGraphParser.Parse/LitegraphService.Load,不要指望new FlowGraph { Nodes = ... }。 - 不做连线合法性判断:
PortTypeMap只给映射与显示后缀,端口类型能不能连由 Core 的校验器判。 Snapshot()不保留原始 JSON:它给的是深拷贝字典,数值统一成double。 需要逐字保留原文(例如把画布原样回存云端)时,请自己留着原始字符串,不要在包里往返。Js不是 JS 引擎:只覆盖画布节点用到的那几个转换与比较,不要拿它求值任意表达式。
版本历史
1.0.0(首次发布)
- 画布图模型
FlowGraph/FlowNode/FlowPort/FlowLink/FlowPropertyBag NodeTypes46 个节点类型常量、PortTypeMap、VariableCatalog、ConditionRuleJsJS 语义取值、ValueFormat文本格式化、LitegraphJson共享 JSON 选项- 零外部依赖
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on OpenRobot.Litegraph.Common:
| Package | Downloads |
|---|---|
|
OpenRobot.Litegraph.Core
Litegraph 流程引擎核心:画布解析与校验、图模型、46 个内置节点处理器、同步/异步通道、触发流程与主流程 tick、执行记录诊断。 |
|
|
OpenRobot.Litegraph.Cloud
Litegraph 云端对接:画布拉取与备份、云端工件(画布/元数据)发布、ABP 信封解析;传输层留缝,可走 HTTP 直连或宿主自己的出网通道。 |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 50 | 10/28/2026 |