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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OpenRobot.Litegraph.Common" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OpenRobot.Litegraph.Common" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="OpenRobot.Litegraph.Common" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OpenRobot.Litegraph.Common --version 1.0.0
                    
#r "nuget: OpenRobot.Litegraph.Common, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OpenRobot.Litegraph.Common@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OpenRobot.Litegraph.Common&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=OpenRobot.Litegraph.Common&version=1.0.0
                    
Install as a Cake Tool

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 的唯一读写口径

已知限制

  1. 不能在图模型上造图:FlowGraph.Nodes / Links 与 FlowNode.Inputs / Outputs 的 setter 是 internal, 只有 OpenRobot.Litegraph.Core 写得进去。要在进程里得到一张图,走 FlowGraphParser.Parse / LitegraphService.Load,不要指望 new FlowGraph { Nodes = ... }。
  2. 不做连线合法性判断:PortTypeMap 只给映射与显示后缀,端口类型能不能连由 Core 的校验器判。
  3. Snapshot() 不保留原始 JSON:它给的是深拷贝字典,数值统一成 double。 需要逐字保留原文(例如把画布原样回存云端)时,请自己留着原始字符串,不要在包里往返。
  4. Js 不是 JS 引擎:只覆盖画布节点用到的那几个转换与比较,不要拿它求值任意表达式。

版本历史

1.0.0(首次发布)

  • 画布图模型 FlowGraph / FlowNode / FlowPort / FlowLink / FlowPropertyBag
  • NodeTypes 46 个节点类型常量、PortTypeMap、VariableCatalog、ConditionRule
  • Js JS 语义取值、ValueFormat 文本格式化、LitegraphJson 共享 JSON 选项
  • 零外部依赖
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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