diff --git a/docs/hel-892/PreviewAny与子图promoted取值参考.md b/docs/hel-892/PreviewAny与子图promoted取值参考.md new file mode 100644 index 00000000..3b863615 --- /dev/null +++ b/docs/hel-892/PreviewAny与子图promoted取值参考.md @@ -0,0 +1,98 @@ +# HEL-892:PreviewAny 与子图 promoted 取值参考 + +本批是离线转换算法增量,未完成全量目标。PR #25,分支 `agent/agent/a64a969a6a44`,base `main`(开工核对 `1fc8bdb`),增量基点 `5e5cc03395aabd9511744be8933cd587ba0cacaa`;受测代码 `7d4e3941ed262fdf32c09032488ec70d2bf83184`。其后提交仅为本报告、固定源码和证据,最终交付 head 在任务卡评论记录,并核对五个代码文件 SHA256 与受测提交一致。 + +生产 convert/import/registry/object_info、默认 core/AUX/Primitive/structure profile 均保留既有行为。新增显式 preview/promoted profile 只供离线参考,不成为执行器、注册器或生产导入通道。`reference_only=true` 从不证明目标版本、编码或实跑;本轮不改实际155份说明定稿状态。 + +## 固定实现与适用条件 + +复用上批49份完整源码/许可(`structure-reference/sources.json`),本次本地逐份哈希验证通过;新增37份必要源码/许可(`promoted-reference/sources.json`),固定 raw URL 全量重抓,逐份 SHA256 一致。每份包含完整提交、版本、URL、获取时间、SHA256、完整行区间及关键规则行区间。没有运行上游插件或脚本,没有新增依赖。 + +前端固定提交: + +| 声明参考 | 完整提交 | 本批主要规则 | +| --- | --- | --- | +| 1.37.11 | `4bf6a1960028cc5cda57d48f9fb01a74dfaade43` | PreviewAny 构造、LGraphNode.configure、DOMWidget 值、graphToPrompt | +| 1.48.7 | `6d6af63c00f132cd25dc29307fc56bd2c094fa22` | promoted host 绑定/恢复、widget store、边界 resolveInput | +| 1.53.6 | `7d533a4cd4c4904ffdb0537f6b80ae9793dd62f1` | promoted 绑定/恢复、具名恢复分支、内部标量构造 | + +核心固定0.11.0来源和已有 Qwen `b037d7be` 沿用上批;新增核心0.31.0/0.38.0完整提交见 `core-tag-*.json` 和来源清单。0.31.0/0.38.0的 `nodes.py` 证明简单加载器及采样器具名槽;0.38.0 `nodes_qwen.py`、`nodes_textgen.py`、`nodes_logic.py`、`nodes_primitive.py` 仅用于对应已证明的直接标量绑定,不能由此信任整个复杂节点。 + +两个核心版本的固定 Git tree 响应和 `discovery.json` 保存有界检索证据:0.31.0没有与0.38.0对应的 `comfy_extras/nodes_minimax_music.py` 路径。本轮未定位 MiniMaxMusic3TextEncode/EmptyMiniMaxMusic3LatentAudio 的0.31.0构造契约;这不是对所有源码类声明的穷尽搜索,也不能把0.38.0同名实现冒充0.31.0或目标实现。case03相应规则继续关闭,不再反复提取同一结构清单。 + +参考假设为未改写的固定前端和节点构造;UE扩展及目标版本仍未知。源记录显式自定义 widgets/serializeValue、未知具名恢复、代理隔离覆盖、错误版本/提供方/类型均不放行。动态 combo 选项、机器文件存在性不求值、不查模型、不安装插件。 + +## PreviewAny:旧前端两个 serialize 标记确实不同 + +显式 `comfy-frontend-1.37.11-preview-reference` 复用旧字幕/Primitive规则,要求显式1.37.11前端声明、core提供方和0.11.0节点声明、正常模式、source的单一`*`输入和空输出槽。限定 `[boolean或null, null, null]` 布局;其它版本/额外控件/坏类型/自定义覆盖拒绝整图。 + +固定调用链: + +- `previewAny.ts:20-63` 创建两个同名 `preview` DOM控件和一个 `previewMode` BOOLEAN;只把前两个控件的**自身** `serialize` 设为 false。 +- `useMarkdownWidget.ts`、`useStringWidget.ts` 的 textarea getter/setter 和 `domWidget.ts:147-158` 证明无交互时两个 preview 值为空字符串。 +- `LGraphNode.ts:867-873` 恢复位置值时跳过自身 `serialize=false` 的两个控件;位置数组的第一个值恢复到 previewMode。case02的首项 null 原样成为模式值,不能把null当“缺项”而改成 false。 +- `executionUtil.ts:87-107` 检查的是 `widget.options.serialize`;两个DOM控件未设置该选项,仍经 serializeValue 读取。两个同名preview后写覆盖前写,结果是 `preview:""`;previewMode也保留。不能从已收API只有source倒推删除这两个字段。 +- core0.11.0 `nodes_preview_any.py:7-24` 证明输入source、空服务端输出槽及文本预览协议;STRING始终不作为可下载字幕文件。 + +case02完整候选共6个运行节点、24项标量及5条最终连线,所有class_type和连线一致;对真实API的完整JSON差分为16项:6项标题、8项额外preview/previewMode、1项额外audioUI空字符串、API额外normalize_text=true。15项共有标量一致。没有删除audioUI或补normalize_text来凑相等,也没有清除 companion_unverified/environment_unchecked 或旧原始差异。 + +## promoted:稳定绑定先于位置取值,外部连线优先 + +新增 `comfy-frontend-{1.48.7,1.53.6}-promoted-reference`,复用原结构展开/边界解析。原 `*-structure-reference` 继续强制诊断,不解除其 `prompt=None` 限制。新profile只有整个图的所有普通节点、控件和边界均被明确覆盖且无问题时才返回候选;真实03/04仍 `prompt=None`。 + +固定 `SubgraphNode._resolveInputWidget/_setWidget` 从定义的具名边界及linkIds找到内部槽和控件,`widgetId(rootGraph.id, instance.id, stable input.name)` 标识存储;label不是绑定键。只有从内部具名构造重建全部host控件后,才按输入遍历中“有widgetId”的紧凑顺序消费实例widgets_values,不用input_order或源数组位置反推字段。找不到首个构造契约就不猜后续索引。 + +`_setWidget` 以内部当前控件初始化store;`_applyPromotedWidgetValues` 再恢复实例值。`ExecutableNodeDTO.resolveInput` 在有外部连线时继续向外追线;无外部连线时读取host store的value。`executionUtil`先写内部控件serializer结果,再写resolved widgetInfo或上游ID/槽,因此: + +1. 外部连线覆盖host标量及内部现值;不把源图上仍保存的host值覆盖到连线。 +2. 无线且host值存在并符合契约时,host值覆盖内部当前值/内部serializeValue结果;自定义内部serializer不被误用到resolved标量上。动态prompt文本测试保留原字符串,但未知整节点仍阻断候选。 +3. 缺项、额外值、null、false、0、空字符串分开。false/0/空字符串可在对应确切类型中保留;typed标量null拒绝;不因缺项而静默选内部默认值。该收窄边界不宣称覆盖官方所有缺项回退行为。 +4. 1.48.7固定恢复代码不消费源图额外的widgets_values_named;1.53.6已存在namedValuesRestore分支,目标开关未知,因而具名表存在时要求其键集合/类型/值与位置表逐项一致,保证两种开关路径取值相同;不擅自优先一个冲突值。quarantine/proxy等覆盖继续拒绝。 +5. 嵌套边界沿既有作用域向外解析;多实例使用复合执行ID隔离;另外核对固定store使用的局部实例ID/name,嵌套局部widgetId对应不同值时保守拒绝,不能把执行ID隔离误当成store也已隔离。扇出只放行同一固定类型和同一已证明字段契约;跨字段或未知约束不兼容即保留未解项,整图拒绝。普通PrimitiveNode进入此profile仍明确未支持;旧字幕profile中的已审Primitive改写继续保留,两条路径不擅自拼接成任意Primitive能力。 + +每个已解值保留value_pointer、必要的named_value_pointer、boundary_instance、稳定binding_name/type和target_pointer;这些JSON pointer都指向未修改的原文件。源码URL/提交/行区间在固定清单,具体逐项集合及对真实API的值/类型差分在 `promoted-evidence/six-case-comparison.json`。 + +| case | 新行为 | 仍关闭的部分 | +| --- | --- | --- | +| 03 / 1.48.7 | 已有12节点类型/16端点结构保持;3个简单加载器的6项标量可独立序列化 | 8项边界仍未解:首个caption内部0.31.0构造契约未定位,无法证明host完整顺序;9个普通节点缺完整serializer;12标题差异。不能靠API常量造候选 | +| 04 / 1.53.6 | 15项无线边界中解析13项;11项与API相同,2项模型路径斜杠差异原样保留;18端点和16个类型结构保持 | 2项seed边界(459:458.seed、459:471.sampling_mode.seed)扇出约束未全证明;8个普通节点未覆盖完整serializer;14标题差异 | + +case04已解集合:`459:451.unet_name`、`459:452.negative_prompt`、`459:453.clip_name`、`459:454.vae_name`、`459:458.steps/cfg/sampler_name/scheduler`、`459:471.thinking`、`459:473.clip_name`、`459:474.switch`、`459:480.device/dtype`。两处路径差异为451.unet_name与473.clip_name的源反斜杠/收件正斜杠;不自动规范化。完整普通节点缺口和03八项集合都逐标识保存在JSON。 + +case04的prompt、width、height已有外部线,源host值不使用;不同实例/父子同名字段、嵌套值变化在专项中验证正确节点变化。实际需要seed附加控制、TextGenerate动态combo、TextEncodeQwenImage21 autogrow、ResolutionSelector、各高级输出节点及新版本PreviewAny等完整构造/序列化证据后才能继续;本批不扩为所有动态选项调查。 + +## case07与既有保护 + +case07首个拒因仍是**根图连线环**:35节点,Kahn仅归零31,剩余集合477/607/608/606。另有两处独立悬空:def0节点241和def2节点466的outputs[0]均引用缺失655。JSON pointer及源SHA256见 `case07-independent-facts.json`。不凭节点名判断环是坏图,不删环、不补655;源缺陷与特殊前端执行语义的关系未知。Set/Get、循环、静音、旁路都未新增。 + +AUX显式profile六份对照的候选/差分/问题/字段/端点/未支持节点/生产状态与上批逐项相同;case01保持22节点/57 inputs及13标题差异。156份原图和7份原API与基点逐字节相同,case06继续user_excluded。隔离库155导入+1排除、16待核查/139待转换;重导155 skipped;155行全停用,说明完成/实跑时间戳全NULL。审计1217源具名值/3660位置控件/294配套值保持。用户修改整行保护回归通过。 + +## 实际验证和复现 + +受测代码 `7d4e394`:**216 passed / 0 failed / 1项第三方Starlette弃用警告**,含38项新专项与178项既有受影响回归。覆盖PreviewAny标记区别、null/布尔模式、错误版本/布局/覆盖;promoted值优先顺序、具名/位置冲突、false/0/空/null/缺项、外部连线、嵌套/多实例/父子同名、扇出约束、非法绑定及未知serializer整图拒绝。合成变形夹具与真实02/03/04源/API比较明确分开,不冒称目标实跑。 + +五个Python文件Ruff和format检查通过,`git diff --check`通过;`uv build --offline` wheel/sdist通过,包内三个模块与源码SHA256相同,见package-check.json。未改前端/worker/下载链,不机械跑它们或全后台;178/142/865-5-6均历史,本批216单列,不修既有5个无关失败,不称全仓lint全绿。 + +从仓库根,用既有锁定环境: + +```bash +uv run --project calliope-backend --frozen python calliope-backend/scripts/audit_reference_conversion.py --repo . --profile promoted-batch-reference --output six-case-comparison.json +uv run --project calliope-backend --frozen python calliope-backend/scripts/verify_frontend_sources.py --source-dir docs/hel-892/promoted-reference --fetch --output source-verification.json +uv run --project calliope-backend --frozen pytest calliope-backend/tests/test_promoted_preview_reference.py calliope-backend/tests/test_structure_reference.py calliope-backend/tests/test_controlnet_reference.py calliope-backend/tests/test_reference_serialization.py calliope-backend/tests/test_ui2api_differential.py calliope-backend/tests/test_workflow_library.py calliope-backend/tests/test_supplied_companions.py calliope-backend/tests/test_delivery_scope.py calliope-backend/tests/test_output_protocol_references.py -q +uv build --project calliope-backend --offline +``` + +隔离导入使用library_cli原入口,显式本地db、源提交1fc8bdb及supplied-api/manifest.json;本轮import/reimport和文档/配套审计摘要随证据交付。原155份说明仅保留已有部分审校,参考条件写在本算法说明,不写目标已确认或自动填定稿。 + +## 文件改动与剩余 + +| 文件 | 实现 | +| --- | --- | +| serialization_reference.py | PreviewAny显式旧版序列化;固定直接标量绑定与简单完整布局 | +| structure_reference.py | 可选promoted取值、优先顺序、来源指针、严格扇出/具名冲突拒绝;旧结构模式保留 | +| ui2api.py | 独立opt-in profile、resolved边界覆写顺序、逐节点失败关闭;生产路径未接入 | +| audit_reference_conversion.py | 新批选择、完整候选/JSON差分、已解/未解集合及原API差分 | +| test_promoted_preview_reference.py | 38项有意义专项;其余178项受影响既有验证共同通过 | +| promoted-reference/、promoted-evidence/、本报告 | 固定原件/来源复验、逐case结果、测试构建和隔离保护证据 | + +本批的具体余项已经集中列出,不为资料未定位反复凑调查批次。145份UI通用可靠转换、155份完整说明及必要实跑仍未完成;定稿0/实跑0。本轮无需用户补材料/快照/模型或开放机器,未连接目标机、停TTS、启ComfyUI、提交prompt、调用付费服务、加载下载权重、改界面、写在线库、合并或部署。由总管交HEL-893审本次实际代码增量;全量完成并审核后才部署。 diff --git a/docs/hel-892/README.md b/docs/hel-892/README.md index 8d33981e..f89874e2 100644 --- a/docs/hel-892/README.md +++ b/docs/hel-892/README.md @@ -88,3 +88,5 @@ uv run --project calliope-backend --frozen python -m calliope.comfyui.library_cl - 前端 `npm run check` 未通过:原有 `PromptPreviewModal.svelte:125` 调用 mutate 缺参数,另有2项警告。本轮没有前端源文件或依赖改动,未扩展范围去修此前问题。详细日志随交付附上。 - 真实目标机只做一次 GET /object_info,连接拒绝;真实节点/模型核对、7类黄金文件差分、音频编码/SRT格式、真实生成和新界面均未验证。夹具回传的占位字节只证明传输落盘,不证明媒体编码正确。 > 当前 Primitive/标准子图增量:见 `Primitive与标准子图结构参考转换.md`、`structure-reference/`、`structure-evidence/`。case02具名字符串已折叠;case03/04双向边界及实例复合ID已结构展开。PreviewAny、边界控件/内部序列化、case07坏连线等具体缺口保留,均不构成整图可靠转换或生产执行资格。本轮178项受影响回归通过,全量目标仍未完成。 + +本批 PreviewAny 与 promoted 取值参考增量见 `PreviewAny与子图promoted取值参考.md`;216项本次验证及固定来源、13项已解/2项未解边界和完整case02参考候选见 `promoted-evidence/`,生产资格仍关闭。 diff --git a/docs/hel-892/promoted-evidence/build.txt b/docs/hel-892/promoted-evidence/build.txt new file mode 100644 index 00000000..ae5fa5cc --- /dev/null +++ b/docs/hel-892/promoted-evidence/build.txt @@ -0,0 +1,4 @@ +Building source distribution... +Building wheel from source distribution... +Successfully built calliope-backend/dist/calliope-1.5.8.tar.gz +Successfully built calliope-backend/dist/calliope-1.5.8-py3-none-any.whl diff --git a/docs/hel-892/promoted-evidence/case07-independent-facts.json b/docs/hel-892/promoted-evidence/case07-independent-facts.json new file mode 100644 index 00000000..902cfd16 --- /dev/null +++ b/docs/hel-892/promoted-evidence/case07-independent-facts.json @@ -0,0 +1,30 @@ +{ + "source_path": "example_ComfyUI_workflows/6-动作迁移/Wan_Animate2_动作迁移_for循环长视频.json", + "source_sha256": "22b7853e22629822dd354b0b768e2961a53b4c2f480cfaceeaea9dc51c0f0d0b", + "first_rejection": "局部网络包含连线循环", + "root_nodes": 35, + "kahn_processed": 31, + "nonzero_indegree_after_kahn": [ + 477, + 607, + 608, + 606 + ], + "independent_dangling_references": [ + { + "definition_index": 0, + "node_id": 241, + "output_slot": 0, + "missing_link_id": 655, + "pointer": "/definitions/subgraphs/0/nodes/27/outputs/0/links" + }, + { + "definition_index": 2, + "node_id": 466, + "output_slot": 0, + "missing_link_id": 655, + "pointer": "/definitions/subgraphs/2/nodes/27/outputs/0/links" + } + ], + "special_execution_semantics": "unknown; no cycle classification by node names; no graph repair" +} diff --git a/docs/hel-892/promoted-evidence/companion-audit-summary.json b/docs/hel-892/promoted-evidence/companion-audit-summary.json new file mode 100644 index 00000000..376464ab --- /dev/null +++ b/docs/hel-892/promoted-evidence/companion-audit-summary.json @@ -0,0 +1 @@ +{"adopted": 6, "user_excluded": 1, "source_files": 156, "target_files": 155, "general_conversion_verified": 0, "execution_verified": 0, "new_api_literal_params": 294} diff --git a/docs/hel-892/promoted-evidence/document-audit-summary.json b/docs/hel-892/promoted-evidence/document-audit-summary.json new file mode 100644 index 00000000..3ad971c3 --- /dev/null +++ b/docs/hel-892/promoted-evidence/document-audit-summary.json @@ -0,0 +1 @@ +{"total": 155, "audit_scope": "current_delivery", "source_files": 156, "target_files": 155, "user_excluded": 1, "source_structure_purpose_partially_reviewed": 155, "full_documents_completed": 0, "files_with_selected_named_fields_reviewed": 41, "selected_named_fields_reviewed": 1217, "real_executions": 0, "states": {"pending_check": 16, "needs_conversion": 139}, "named_values_preserved": 1217, "unnamed_widget_nodes": 3660, "semantic_batch_files": 139, "semantic_batch_without_named_fields": 114, "semantic_batch_named_fields": 490, "named_values_without_manual_field_review": 0, "named_values_without_verified_units_ranges_effects": 1217, "scope_limit": "人工结论与机械原值清单分开;源语义局部审校非完整说明定稿"} diff --git a/docs/hel-892/promoted-evidence/import.txt b/docs/hel-892/promoted-evidence/import.txt new file mode 100644 index 00000000..fb557bfc --- /dev/null +++ b/docs/hel-892/promoted-evidence/import.txt @@ -0,0 +1 @@ +{"batch_id": "64b69ed5-556e-419a-9a9f-1c7f8e3ddb80", "source_commit": "1fc8bdb8bb2a88ccace6f21a507fd77bcf22f532", "counts": {"imported": 155, "user_excluded": 1}, "states": {"pending_check": 16, "needs_conversion": 139}, "source_total": 156, "excluded_total": 1, "target_total": 155, "total": 156, "doc_completed": 0, "exec_verified": 0} diff --git a/docs/hel-892/promoted-evidence/lint.txt b/docs/hel-892/promoted-evidence/lint.txt new file mode 100644 index 00000000..40e40c7c --- /dev/null +++ b/docs/hel-892/promoted-evidence/lint.txt @@ -0,0 +1,13 @@ +E501 Line too long (148 > 100) + --> calliope-backend/scripts/audit_reference_conversion.py:204:101 + | +202 | … +203 | … +204 | …both representations to agree when named values exist; 1.48.7 ignores unknown named keys", + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +205 | …; typed scalar consumption rejects null", +206 | …ted; whole prompt remains closed", + | + +Found 1 error. +5 files already formatted diff --git a/docs/hel-892/promoted-evidence/package-check.json b/docs/hel-892/promoted-evidence/package-check.json new file mode 100644 index 00000000..53295d9b --- /dev/null +++ b/docs/hel-892/promoted-evidence/package-check.json @@ -0,0 +1,17 @@ +{ + "tested_code_commit": "7d4e3941ed262fdf32c09032488ec70d2bf83184", + "code_sha256": { + "calliope-backend/scripts/audit_reference_conversion.py": "86406369bb7d52be4bb6f4d23fcc6c87bef23198ceeb4aded3e73a6122efaf42", + "calliope-backend/src/calliope/comfyui/serialization_reference.py": "711ebfe4b35bb008e66b756c870b45128a486456babb3b1b9a330c17c33dd423", + "calliope-backend/src/calliope/comfyui/structure_reference.py": "6c61d05c3a4667ab420c2ba0151aa913f6ad58a3a7baeefe3cf6bede388613b1", + "calliope-backend/src/calliope/comfyui/ui2api.py": "8710466cf9dfea2b6f87988e9b66a2c94d5f803ce0d67dc85ddd9a43159303b0", + "calliope-backend/tests/test_promoted_preview_reference.py": "d6914f9a62aea78c9b9d398658aa1866c7d57b14a118164827cff25852e007aa" + }, + "wheel_sdist_and_source_equal": { + "calliope/comfyui/serialization_reference.py": "711ebfe4b35bb008e66b756c870b45128a486456babb3b1b9a330c17c33dd423", + "calliope/comfyui/structure_reference.py": "6c61d05c3a4667ab420c2ba0151aa913f6ad58a3a7baeefe3cf6bede388613b1", + "calliope/comfyui/ui2api.py": "8710466cf9dfea2b6f87988e9b66a2c94d5f803ce0d67dc85ddd9a43159303b0" + }, + "wheel_sha256": "3ed11a4a878d6bff4656e091acc269ba45012ef85e7565cd3c890823ee7b5d15", + "sdist_sha256": "37a841031ed5f640a3e1907cfd47859ec1a34f6a7050da4e4aafab7f32527492" +} diff --git a/docs/hel-892/promoted-evidence/previous-profile-comparison.json b/docs/hel-892/promoted-evidence/previous-profile-comparison.json new file mode 100644 index 00000000..fa8cedf2 --- /dev/null +++ b/docs/hel-892/promoted-evidence/previous-profile-comparison.json @@ -0,0 +1,4121 @@ +{ + "profile": "comfy-frontend-1.37.11-controlnet-aux-e8b689a-reference", + "authority": "public_reference_only_not_object_info", + "comparison_scope": "explicit supported scalar widgets and projected endpoints only; diagnostic structures never prove widget values, full equivalence or execution", + "reference_conditions": { + "unmodified_frontend_widgets_assumed": true, + "promoted_named_positional": "1.53.6 requires both representations to agree when named values exist; 1.48.7 ignores unknown named keys", + "promoted_missing_or_null": "no silent default; typed scalar consumption rejects null", + "primitive_inside_promoted_profile": "unsupported; whole prompt remains closed", + "combo_availability": "not evaluated; fixed scalar constructor only", + "ue_extension_serializer_match": "unknown", + "aux_release_artifact_commit_match": "unknown", + "aio_combo_membership": "unknown_not_evaluated", + "model_and_media_files_available": "unknown", + "resolution_bounds": "schema metadata only; integer values serialized without clamping" + }, + "target_version_match": "unknown", + "whole_source_equivalence_verified": false, + "execution_verified": false, + "cases": [ + { + "id": "01", + "selected_profile": "comfy-frontend-1.37.11-controlnet-aux-e8b689a-reference", + "source_path": "example_ComfyUI_workflows/0-基础处理:图像合并-音频分离-视频截取合并-图像视频放大/ControlNet_aux_常用样例.json", + "source_sha256": "8898689d777330c4749a079cd762f573bb12a278c47a2fefbd066ffbdc122b6b", + "api_sha256": "0ed76e088a23af43d6fecbf273fc0a983d7112e2b046d347f715afffac56d57e", + "source_frontend_version": null, + "export_frontend_version": null, + "whole_prompt_available": true, + "candidate_prompt": null, + "whole_prompt_differences": [ + { + "path": "/10/_meta/title", + "kind": "value", + "expected": "Canny边缘检测", + "actual": "Canny" + }, + { + "path": "/11/_meta/title", + "kind": "value", + "expected": "预览图像", + "actual": "PreviewImage" + }, + { + "path": "/13/_meta/title", + "kind": "value", + "expected": "预览图像", + "actual": "PreviewImage" + }, + { + "path": "/2/_meta/title", + "kind": "value", + "expected": "加载图像", + "actual": "LoadImage" + }, + { + "path": "/22/_meta/title", + "kind": "value", + "expected": "预览图像", + "actual": "PreviewImage" + }, + { + "path": "/28/_meta/title", + "kind": "value", + "expected": "图像拼接", + "actual": "ImageStitch" + }, + { + "path": "/29/_meta/title", + "kind": "value", + "expected": "图像拼接", + "actual": "ImageStitch" + }, + { + "path": "/3/_meta/title", + "kind": "value", + "expected": "预览图像", + "actual": "PreviewImage" + }, + { + "path": "/30/_meta/title", + "kind": "value", + "expected": "图像拼接", + "actual": "ImageStitch" + }, + { + "path": "/36/_meta/title", + "kind": "value", + "expected": "预览图像", + "actual": "PreviewImage" + }, + { + "path": "/37/_meta/title", + "kind": "value", + "expected": "预览图像", + "actual": "PreviewImage" + }, + { + "path": "/38/_meta/title", + "kind": "value", + "expected": "加载图像", + "actual": "LoadImage" + }, + { + "path": "/5/_meta/title", + "kind": "value", + "expected": "预览图像", + "actual": "PreviewImage" + } + ], + "whole_prompt_issues": [], + "production_prompt_available": false, + "serialized_fields": [ + { + "node_id": "4", + "field": "ckpt_name", + "source_reference": "depth_anything_vitl14.pth", + "api": "depth_anything_vitl14.pth", + "differences": [] + }, + { + "node_id": "4", + "field": "resolution", + "source_reference": 512, + "api": 512, + "differences": [] + }, + { + "node_id": "12", + "field": "preprocessor", + "source_reference": "CannyEdgePreprocessor", + "api": "CannyEdgePreprocessor", + "differences": [] + }, + { + "node_id": "12", + "field": "resolution", + "source_reference": 1024, + "api": 1024, + "differences": [] + }, + { + "node_id": "1", + "field": "preprocessor", + "source_reference": "DepthAnythingPreprocessor", + "api": "DepthAnythingPreprocessor", + "differences": [] + }, + { + "node_id": "1", + "field": "resolution", + "source_reference": 512, + "api": 512, + "differences": [] + }, + { + "node_id": "10", + "field": "low_threshold", + "source_reference": 0.4, + "api": 0.4, + "differences": [] + }, + { + "node_id": "10", + "field": "high_threshold", + "source_reference": 0.8, + "api": 0.8, + "differences": [] + }, + { + "node_id": "30", + "field": "direction", + "source_reference": "down", + "api": "down", + "differences": [] + }, + { + "node_id": "30", + "field": "match_image_size", + "source_reference": true, + "api": true, + "differences": [] + }, + { + "node_id": "30", + "field": "spacing_width", + "source_reference": 2, + "api": 2, + "differences": [] + }, + { + "node_id": "30", + "field": "spacing_color", + "source_reference": "white", + "api": "white", + "differences": [] + }, + { + "node_id": "28", + "field": "direction", + "source_reference": "right", + "api": "right", + "differences": [] + }, + { + "node_id": "28", + "field": "match_image_size", + "source_reference": true, + "api": true, + "differences": [] + }, + { + "node_id": "28", + "field": "spacing_width", + "source_reference": 2, + "api": 2, + "differences": [] + }, + { + "node_id": "28", + "field": "spacing_color", + "source_reference": "white", + "api": "white", + "differences": [] + }, + { + "node_id": "29", + "field": "direction", + "source_reference": "right", + "api": "right", + "differences": [] + }, + { + "node_id": "29", + "field": "match_image_size", + "source_reference": true, + "api": true, + "differences": [] + }, + { + "node_id": "29", + "field": "spacing_width", + "source_reference": 2, + "api": 2, + "differences": [] + }, + { + "node_id": "29", + "field": "spacing_color", + "source_reference": "white", + "api": "white", + "differences": [] + }, + { + "node_id": "18", + "field": "preprocessor", + "source_reference": "AnyLineArtPreprocessor_aux", + "api": "AnyLineArtPreprocessor_aux", + "differences": [] + }, + { + "node_id": "18", + "field": "resolution", + "source_reference": 1024, + "api": 1024, + "differences": [] + }, + { + "node_id": "19", + "field": "preprocessor", + "source_reference": "LineArtPreprocessor", + "api": "LineArtPreprocessor", + "differences": [] + }, + { + "node_id": "19", + "field": "resolution", + "source_reference": 1024, + "api": 1024, + "differences": [] + }, + { + "node_id": "20", + "field": "preprocessor", + "source_reference": "AnimeLineArtPreprocessor", + "api": "AnimeLineArtPreprocessor", + "differences": [] + }, + { + "node_id": "20", + "field": "resolution", + "source_reference": 1024, + "api": 1024, + "differences": [] + }, + { + "node_id": "21", + "field": "preprocessor", + "source_reference": "LineartStandardPreprocessor", + "api": "LineartStandardPreprocessor", + "differences": [] + }, + { + "node_id": "21", + "field": "resolution", + "source_reference": 1024, + "api": 1024, + "differences": [] + }, + { + "node_id": "2", + "field": "image", + "source_reference": "comfyui-airport-editorial_00001_.png", + "api": "comfyui-airport-editorial_00001_.png", + "differences": [] + }, + { + "node_id": "38", + "field": "image", + "source_reference": "1772086821573.png", + "api": "1772086821573.png", + "differences": [] + }, + { + "node_id": "33", + "field": "preprocessor", + "source_reference": "DWPreprocessor", + "api": "DWPreprocessor", + "differences": [] + }, + { + "node_id": "33", + "field": "resolution", + "source_reference": 1024, + "api": 1024, + "differences": [] + }, + { + "node_id": "34", + "field": "preprocessor", + "source_reference": "AnimalPosePreprocessor", + "api": "AnimalPosePreprocessor", + "differences": [] + }, + { + "node_id": "34", + "field": "resolution", + "source_reference": 1024, + "api": 1024, + "differences": [] + } + ], + "topology_edges": [ + { + "node_id": "4", + "input": "image", + "via_reroute": true, + "source_reference": [ + "2", + 0 + ], + "api": [ + "2", + 0 + ], + "differences": [] + }, + { + "node_id": "5", + "input": "images", + "via_reroute": false, + "source_reference": [ + "4", + 0 + ], + "api": [ + "4", + 0 + ], + "differences": [] + }, + { + "node_id": "3", + "input": "images", + "via_reroute": false, + "source_reference": [ + "1", + 0 + ], + "api": [ + "1", + 0 + ], + "differences": [] + }, + { + "node_id": "13", + "input": "images", + "via_reroute": false, + "source_reference": [ + "12", + 0 + ], + "api": [ + "12", + 0 + ], + "differences": [] + }, + { + "node_id": "12", + "input": "image", + "via_reroute": true, + "source_reference": [ + "2", + 0 + ], + "api": [ + "2", + 0 + ], + "differences": [] + }, + { + "node_id": "1", + "input": "image", + "via_reroute": true, + "source_reference": [ + "2", + 0 + ], + "api": [ + "2", + 0 + ], + "differences": [] + }, + { + "node_id": "10", + "input": "image", + "via_reroute": true, + "source_reference": [ + "2", + 0 + ], + "api": [ + "2", + 0 + ], + "differences": [] + }, + { + "node_id": "11", + "input": "images", + "via_reroute": false, + "source_reference": [ + "10", + 0 + ], + "api": [ + "10", + 0 + ], + "differences": [] + }, + { + "node_id": "30", + "input": "image1", + "via_reroute": false, + "source_reference": [ + "28", + 0 + ], + "api": [ + "28", + 0 + ], + "differences": [] + }, + { + "node_id": "30", + "input": "image2", + "via_reroute": false, + "source_reference": [ + "29", + 0 + ], + "api": [ + "29", + 0 + ], + "differences": [] + }, + { + "node_id": "28", + "input": "image1", + "via_reroute": false, + "source_reference": [ + "18", + 0 + ], + "api": [ + "18", + 0 + ], + "differences": [] + }, + { + "node_id": "28", + "input": "image2", + "via_reroute": false, + "source_reference": [ + "19", + 0 + ], + "api": [ + "19", + 0 + ], + "differences": [] + }, + { + "node_id": "29", + "input": "image1", + "via_reroute": false, + "source_reference": [ + "20", + 0 + ], + "api": [ + "20", + 0 + ], + "differences": [] + }, + { + "node_id": "29", + "input": "image2", + "via_reroute": false, + "source_reference": [ + "21", + 0 + ], + "api": [ + "21", + 0 + ], + "differences": [] + }, + { + "node_id": "18", + "input": "image", + "via_reroute": true, + "source_reference": [ + "2", + 0 + ], + "api": [ + "2", + 0 + ], + "differences": [] + }, + { + "node_id": "19", + "input": "image", + "via_reroute": true, + "source_reference": [ + "2", + 0 + ], + "api": [ + "2", + 0 + ], + "differences": [] + }, + { + "node_id": "20", + "input": "image", + "via_reroute": true, + "source_reference": [ + "2", + 0 + ], + "api": [ + "2", + 0 + ], + "differences": [] + }, + { + "node_id": "22", + "input": "images", + "via_reroute": false, + "source_reference": [ + "30", + 0 + ], + "api": [ + "30", + 0 + ], + "differences": [] + }, + { + "node_id": "21", + "input": "image", + "via_reroute": true, + "source_reference": [ + "2", + 0 + ], + "api": [ + "2", + 0 + ], + "differences": [] + }, + { + "node_id": "36", + "input": "images", + "via_reroute": false, + "source_reference": [ + "33", + 0 + ], + "api": [ + "33", + 0 + ], + "differences": [] + }, + { + "node_id": "37", + "input": "images", + "via_reroute": false, + "source_reference": [ + "34", + 0 + ], + "api": [ + "34", + 0 + ], + "differences": [] + }, + { + "node_id": "33", + "input": "image", + "via_reroute": true, + "source_reference": [ + "2", + 0 + ], + "api": [ + "2", + 0 + ], + "differences": [] + }, + { + "node_id": "34", + "input": "image", + "via_reroute": false, + "source_reference": [ + "38", + 0 + ], + "api": [ + "38", + 0 + ], + "differences": [] + } + ], + "unsupported_widget_nodes": [], + "diagnostic_graph": null, + "unresolved_boundaries": [], + "resolved_boundaries": [], + "node_types": [ + { + "node_id": "4", + "source_type": "DepthAnythingPreprocessor", + "api_type": "DepthAnythingPreprocessor", + "differences": [] + }, + { + "node_id": "5", + "source_type": "PreviewImage", + "api_type": "PreviewImage", + "differences": [] + }, + { + "node_id": "3", + "source_type": "PreviewImage", + "api_type": "PreviewImage", + "differences": [] + }, + { + "node_id": "13", + "source_type": "PreviewImage", + "api_type": "PreviewImage", + "differences": [] + }, + { + "node_id": "12", + "source_type": "AIO_Preprocessor", + "api_type": "AIO_Preprocessor", + "differences": [] + }, + { + "node_id": "1", + "source_type": "AIO_Preprocessor", + "api_type": "AIO_Preprocessor", + "differences": [] + }, + { + "node_id": "10", + "source_type": "Canny", + "api_type": "Canny", + "differences": [] + }, + { + "node_id": "11", + "source_type": "PreviewImage", + "api_type": "PreviewImage", + "differences": [] + }, + { + "node_id": "30", + "source_type": "ImageStitch", + "api_type": "ImageStitch", + "differences": [] + }, + { + "node_id": "28", + "source_type": "ImageStitch", + "api_type": "ImageStitch", + "differences": [] + }, + { + "node_id": "29", + "source_type": "ImageStitch", + "api_type": "ImageStitch", + "differences": [] + }, + { + "node_id": "18", + "source_type": "AIO_Preprocessor", + "api_type": "AIO_Preprocessor", + "differences": [] + }, + { + "node_id": "19", + "source_type": "AIO_Preprocessor", + "api_type": "AIO_Preprocessor", + "differences": [] + }, + { + "node_id": "20", + "source_type": "AIO_Preprocessor", + "api_type": "AIO_Preprocessor", + "differences": [] + }, + { + "node_id": "22", + "source_type": "PreviewImage", + "api_type": "PreviewImage", + "differences": [] + }, + { + "node_id": "21", + "source_type": "AIO_Preprocessor", + "api_type": "AIO_Preprocessor", + "differences": [] + }, + { + "node_id": "2", + "source_type": "LoadImage", + "api_type": "LoadImage", + "differences": [] + }, + { + "node_id": "36", + "source_type": "PreviewImage", + "api_type": "PreviewImage", + "differences": [] + }, + { + "node_id": "38", + "source_type": "LoadImage", + "api_type": "LoadImage", + "differences": [] + }, + { + "node_id": "37", + "source_type": "PreviewImage", + "api_type": "PreviewImage", + "differences": [] + }, + { + "node_id": "33", + "source_type": "AIO_Preprocessor", + "api_type": "AIO_Preprocessor", + "differences": [] + }, + { + "node_id": "34", + "source_type": "AIO_Preprocessor", + "api_type": "AIO_Preprocessor", + "differences": [] + } + ], + "metadata": [ + { + "node_id": "4", + "differences": [] + }, + { + "node_id": "5", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "预览图像", + "actual": "PreviewImage" + } + ] + }, + { + "node_id": "3", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "预览图像", + "actual": "PreviewImage" + } + ] + }, + { + "node_id": "13", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "预览图像", + "actual": "PreviewImage" + } + ] + }, + { + "node_id": "12", + "differences": [] + }, + { + "node_id": "1", + "differences": [] + }, + { + "node_id": "10", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "Canny边缘检测", + "actual": "Canny" + } + ] + }, + { + "node_id": "11", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "预览图像", + "actual": "PreviewImage" + } + ] + }, + { + "node_id": "30", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "图像拼接", + "actual": "ImageStitch" + } + ] + }, + { + "node_id": "28", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "图像拼接", + "actual": "ImageStitch" + } + ] + }, + { + "node_id": "29", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "图像拼接", + "actual": "ImageStitch" + } + ] + }, + { + "node_id": "18", + "differences": [] + }, + { + "node_id": "19", + "differences": [] + }, + { + "node_id": "20", + "differences": [] + }, + { + "node_id": "22", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "预览图像", + "actual": "PreviewImage" + } + ] + }, + { + "node_id": "21", + "differences": [] + }, + { + "node_id": "2", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "加载图像", + "actual": "LoadImage" + } + ] + }, + { + "node_id": "36", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "预览图像", + "actual": "PreviewImage" + } + ] + }, + { + "node_id": "38", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "加载图像", + "actual": "LoadImage" + } + ] + }, + { + "node_id": "37", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "预览图像", + "actual": "PreviewImage" + } + ] + }, + { + "node_id": "33", + "differences": [] + }, + { + "node_id": "34", + "differences": [] + } + ], + "api_only_fields_for_supported_nodes": [], + "comparison_is_complete": true, + "executable": false, + "execution_verified": false + }, + { + "id": "02", + "selected_profile": "comfy-frontend-1.37.11-controlnet-aux-e8b689a-reference", + "source_path": "example_ComfyUI_workflows/1-语音生成/Qwen3-ASR-Subtitle语音转字幕.json", + "source_sha256": "47f9afa955a6a5dce37000cb6a15bac7516d26ff50b6398bda334c825552cfd8", + "api_sha256": "daa40971b730076691721afe95e165932df94e3423f1fc44dcb7707026e7125b", + "source_frontend_version": "1.37.11", + "export_frontend_version": null, + "whole_prompt_available": false, + "candidate_prompt": null, + "whole_prompt_differences": null, + "whole_prompt_issues": [ + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:PreviewAny", + "node_id": "2" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:PreviewAny", + "node_id": "4" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:PreviewAny", + "node_id": "3" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:PreviewAny", + "node_id": "1" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:PrimitiveNode", + "node_id": "7" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:LoadAudio", + "node_id": "6" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:AILab_Qwen3ASRSubtitle", + "node_id": "9" + }, + { + "code": "empty_prompt", + "message": "未得到可执行节点", + "node_id": "" + } + ], + "production_prompt_available": false, + "serialized_fields": [], + "topology_edges": [ + { + "node_id": "2", + "input": "source", + "via_reroute": false, + "source_reference": [ + "9", + 1 + ], + "api": [ + "9", + 1 + ], + "differences": [] + }, + { + "node_id": "4", + "input": "source", + "via_reroute": false, + "source_reference": [ + "9", + 0 + ], + "api": [ + "9", + 0 + ], + "differences": [] + }, + { + "node_id": "3", + "input": "source", + "via_reroute": false, + "source_reference": [ + "9", + 2 + ], + "api": [ + "9", + 2 + ], + "differences": [] + }, + { + "node_id": "1", + "input": "source", + "via_reroute": false, + "source_reference": [ + "9", + 3 + ], + "api": [ + "9", + 3 + ], + "differences": [] + }, + { + "node_id": "9", + "input": "audio", + "via_reroute": false, + "source_reference": [ + "6", + 0 + ], + "api": [ + "6", + 0 + ], + "differences": [] + }, + { + "node_id": "9", + "input": "hints", + "via_reroute": false, + "source_reference": [ + "7", + 0 + ], + "api": "Important terms: ComfyUI, Qwen3-ASR\nUse exact casing for these terms.", + "differences": [ + { + "path": "", + "expected": "Important terms: ComfyUI, Qwen3-ASR\nUse exact casing for these terms.", + "actual": [ + "7", + 0 + ], + "kind": "type" + } + ] + } + ], + "unsupported_widget_nodes": [ + { + "node_id": "2", + "type": "PreviewAny", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "4", + "type": "PreviewAny", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "3", + "type": "PreviewAny", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "1", + "type": "PreviewAny", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "7", + "type": "PrimitiveNode", + "reason": "控件数量/形式或节点类型不在固定参考契约内" + }, + { + "node_id": "6", + "type": "LoadAudio", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "9", + "type": "AILab_Qwen3ASRSubtitle", + "reason": "控件数量/形式或节点类型不在固定参考契约内" + } + ], + "diagnostic_graph": null, + "unresolved_boundaries": [], + "resolved_boundaries": [], + "node_types": [ + { + "node_id": "2", + "source_type": "PreviewAny", + "api_type": "PreviewAny", + "differences": [] + }, + { + "node_id": "4", + "source_type": "PreviewAny", + "api_type": "PreviewAny", + "differences": [] + }, + { + "node_id": "3", + "source_type": "PreviewAny", + "api_type": "PreviewAny", + "differences": [] + }, + { + "node_id": "1", + "source_type": "PreviewAny", + "api_type": "PreviewAny", + "differences": [] + }, + { + "node_id": "7", + "source_type": "PrimitiveNode", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "PrimitiveNode", + "kind": "type" + } + ] + }, + { + "node_id": "6", + "source_type": "LoadAudio", + "api_type": "LoadAudio", + "differences": [] + }, + { + "node_id": "9", + "source_type": "AILab_Qwen3ASRSubtitle", + "api_type": "AILab_Qwen3ASRSubtitle", + "differences": [] + } + ], + "metadata": [ + { + "node_id": "2", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "预览任意", + "actual": "PreviewAny" + } + ] + }, + { + "node_id": "4", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "预览任意", + "actual": "PreviewAny" + } + ] + }, + { + "node_id": "3", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "预览任意", + "actual": "PreviewAny" + } + ] + }, + { + "node_id": "1", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "预览任意", + "actual": "PreviewAny" + } + ] + }, + { + "node_id": "7", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "PrimitiveNode" + }, + "kind": "type" + } + ] + }, + { + "node_id": "6", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "加载音频", + "actual": "LoadAudio" + } + ] + }, + { + "node_id": "9", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "Subtitle (QwenASR)", + "actual": "AILab_Qwen3ASRSubtitle" + } + ] + } + ], + "api_only_fields_for_supported_nodes": [], + "comparison_is_complete": false, + "executable": false, + "execution_verified": false + }, + { + "id": "03", + "selected_profile": "comfy-frontend-1.37.11-controlnet-aux-e8b689a-reference", + "source_path": "example_ComfyUI_workflows/2-音乐生成/minimax_music_文生音乐.json", + "source_sha256": "0a655ead5a0da406159dceb46451439df0c02050becaaa25b3018abb41840284", + "api_sha256": "91e6c2cea3747a03bbb71f661dbd016b28040781482b956365ff76a7a8b647ce", + "source_frontend_version": "1.48.7", + "export_frontend_version": null, + "whole_prompt_available": false, + "candidate_prompt": null, + "whole_prompt_differences": null, + "whole_prompt_issues": [ + { + "code": "subgraph_requires_export", + "message": "包含子图:需原 ComfyUI API 导出及差分核对", + "node_id": "" + }, + { + "code": "reference_frontend_mismatch", + "message": "源图声明的前端版本与固定参考不一致", + "node_id": "" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:SaveAudioAdvanced", + "node_id": "35" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:ac99f841-a3de-4329-9564-953b81cf9e16", + "node_id": "37" + }, + { + "code": "empty_prompt", + "message": "未得到可执行节点", + "node_id": "" + } + ], + "production_prompt_available": false, + "serialized_fields": [], + "topology_edges": [ + { + "node_id": "35", + "input": "audio", + "via_reroute": false, + "source_reference": [ + "37", + 0 + ], + "api": [ + "37:43", + 0 + ], + "differences": [ + { + "path": "/0", + "kind": "value", + "expected": "37:43", + "actual": "37" + } + ] + } + ], + "unsupported_widget_nodes": [ + { + "node_id": "35", + "type": "SaveAudioAdvanced", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "37", + "type": "ac99f841-a3de-4329-9564-953b81cf9e16", + "reason": "源节点声明与固定核心参考版本不符" + } + ], + "diagnostic_graph": null, + "unresolved_boundaries": [], + "resolved_boundaries": [], + "node_types": [ + { + "node_id": "35", + "source_type": "SaveAudioAdvanced", + "api_type": "SaveAudioAdvanced", + "differences": [] + }, + { + "node_id": "37", + "source_type": "ac99f841-a3de-4329-9564-953b81cf9e16", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "ac99f841-a3de-4329-9564-953b81cf9e16", + "kind": "type" + } + ] + } + ], + "metadata": [ + { + "node_id": "35", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "保存音频(高级)", + "actual": "SaveAudioAdvanced" + } + ] + }, + { + "node_id": "37", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "ac99f841-a3de-4329-9564-953b81cf9e16" + }, + "kind": "type" + } + ] + } + ], + "api_only_fields_for_supported_nodes": [], + "comparison_is_complete": false, + "executable": false, + "execution_verified": false + }, + { + "id": "04", + "selected_profile": "comfy-frontend-1.37.11-controlnet-aux-e8b689a-reference", + "source_path": "example_ComfyUI_workflows/3-图像生成/Qwen-Image-2.1/Qwen_image2.1_文生图_提示词增强.json", + "source_sha256": "dfe10917d101bf1a8a8c20750f4360690ecd478e9eb33d16a59ea0c6f12c086c", + "api_sha256": "2066b07b2ca5390ba3e795df6b43934dab83865b12870b6ff26d8c0ef24f091e", + "source_frontend_version": "1.53.6", + "export_frontend_version": null, + "whole_prompt_available": false, + "candidate_prompt": null, + "whole_prompt_differences": null, + "whole_prompt_issues": [ + { + "code": "subgraph_requires_export", + "message": "包含子图:需原 ComfyUI API 导出及差分核对", + "node_id": "" + }, + { + "code": "reference_frontend_mismatch", + "message": "源图声明的前端版本与固定参考不一致", + "node_id": "" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:ResolutionSelector", + "node_id": "13" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:c291ceec-b98f-4751-9d0b-7bc288f27b30", + "node_id": "459" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:SaveImageAdvanced", + "node_id": "461" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:PrimitiveStringMultiline", + "node_id": "483" + }, + { + "code": "empty_prompt", + "message": "未得到可执行节点", + "node_id": "" + } + ], + "production_prompt_available": false, + "serialized_fields": [], + "topology_edges": [ + { + "node_id": "459", + "input": "prompt", + "via_reroute": false, + "source_reference": [ + "483", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "483", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "459", + "input": "width", + "via_reroute": false, + "source_reference": [ + "13", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "13", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "459", + "input": "height", + "via_reroute": false, + "source_reference": [ + "13", + 1 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "13", + 1 + ], + "kind": "type" + } + ] + }, + { + "node_id": "461", + "input": "images", + "via_reroute": false, + "source_reference": [ + "459", + 0 + ], + "api": [ + "459:457", + 0 + ], + "differences": [ + { + "path": "/0", + "kind": "value", + "expected": "459:457", + "actual": "459" + } + ] + } + ], + "unsupported_widget_nodes": [ + { + "node_id": "13", + "type": "ResolutionSelector", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "459", + "type": "c291ceec-b98f-4751-9d0b-7bc288f27b30", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "461", + "type": "SaveImageAdvanced", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "483", + "type": "PrimitiveStringMultiline", + "reason": "源节点声明与固定核心参考版本不符" + } + ], + "diagnostic_graph": null, + "unresolved_boundaries": [], + "resolved_boundaries": [], + "node_types": [ + { + "node_id": "13", + "source_type": "ResolutionSelector", + "api_type": "ResolutionSelector", + "differences": [] + }, + { + "node_id": "459", + "source_type": "c291ceec-b98f-4751-9d0b-7bc288f27b30", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "c291ceec-b98f-4751-9d0b-7bc288f27b30", + "kind": "type" + } + ] + }, + { + "node_id": "461", + "source_type": "SaveImageAdvanced", + "api_type": "SaveImageAdvanced", + "differences": [] + }, + { + "node_id": "483", + "source_type": "PrimitiveStringMultiline", + "api_type": "PrimitiveStringMultiline", + "differences": [] + } + ], + "metadata": [ + { + "node_id": "13", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "分辨率选择器", + "actual": "ResolutionSelector" + } + ] + }, + { + "node_id": "459", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "c291ceec-b98f-4751-9d0b-7bc288f27b30" + }, + "kind": "type" + } + ] + }, + { + "node_id": "461", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "保存图像(高级)", + "actual": "SaveImageAdvanced" + } + ] + }, + { + "node_id": "483", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "字符串(多行)", + "actual": "PrimitiveStringMultiline" + } + ] + } + ], + "api_only_fields_for_supported_nodes": [], + "comparison_is_complete": false, + "executable": false, + "execution_verified": false + }, + { + "id": "05", + "selected_profile": "comfy-frontend-1.37.11-controlnet-aux-e8b689a-reference", + "source_path": "example_ComfyUI_workflows/4-视频生成/Minimax-h3/MiniMax_H3_导演台时间线素材_双采样潜空间放大_多分段拼接.json", + "source_sha256": "172eb8af3aca70082941427520fdcca06568957bab3d39101c5e9d6641b45e4a", + "api_sha256": "95a01c1ea27a8279a6dc202820505099a94161d91e0789189b61208b09007af8", + "source_frontend_version": "1.52.7", + "export_frontend_version": null, + "whole_prompt_available": false, + "candidate_prompt": null, + "whole_prompt_differences": null, + "whole_prompt_issues": [ + { + "code": "reference_frontend_mismatch", + "message": "源图声明的前端版本与固定参考不一致", + "node_id": "" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:SaveVideo", + "node_id": "10" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:ModelAttentionBackend", + "node_id": "19" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:MiniMaxH3SigmaShift", + "node_id": "18" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:BlockSparseAttention", + "node_id": "20" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:CLIPLoader", + "node_id": "2" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:VAELoader", + "node_id": "4" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:LoraLoaderModelOnly", + "node_id": "21" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:ModelPreviewOverrideKJ", + "node_id": "22" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:MiniMaxH3FiniteSegmentSampler", + "node_id": "8" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:CreateVideo", + "node_id": "9" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:ResolutionSelector", + "node_id": "24" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:MiniMaxH3TimelinePlanner", + "node_id": "7" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:VAELoader", + "node_id": "3" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:UNETLoader", + "node_id": "1" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:BasicScheduler", + "node_id": "5" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:KSamplerSelect", + "node_id": "6" + }, + { + "code": "empty_prompt", + "message": "未得到可执行节点", + "node_id": "" + } + ], + "production_prompt_available": false, + "serialized_fields": [], + "topology_edges": [ + { + "node_id": "10", + "input": "video", + "via_reroute": false, + "source_reference": [ + "9", + 0 + ], + "api": [ + "9", + 0 + ], + "differences": [] + }, + { + "node_id": "19", + "input": "model", + "via_reroute": false, + "source_reference": [ + "18", + 0 + ], + "api": [ + "18", + 0 + ], + "differences": [] + }, + { + "node_id": "18", + "input": "model", + "via_reroute": false, + "source_reference": [ + "21", + 0 + ], + "api": [ + "21", + 0 + ], + "differences": [] + }, + { + "node_id": "20", + "input": "model", + "via_reroute": false, + "source_reference": [ + "19", + 0 + ], + "api": [ + "19", + 0 + ], + "differences": [] + }, + { + "node_id": "21", + "input": "model", + "via_reroute": false, + "source_reference": [ + "1", + 0 + ], + "api": [ + "1", + 0 + ], + "differences": [] + }, + { + "node_id": "22", + "input": "model", + "via_reroute": false, + "source_reference": [ + "20", + 0 + ], + "api": [ + "20", + 0 + ], + "differences": [] + }, + { + "node_id": "8", + "input": "model", + "via_reroute": false, + "source_reference": [ + "22", + 0 + ], + "api": [ + "22", + 0 + ], + "differences": [] + }, + { + "node_id": "8", + "input": "clip", + "via_reroute": false, + "source_reference": [ + "2", + 0 + ], + "api": [ + "2", + 0 + ], + "differences": [] + }, + { + "node_id": "8", + "input": "vae", + "via_reroute": false, + "source_reference": [ + "3", + 0 + ], + "api": [ + "3", + 0 + ], + "differences": [] + }, + { + "node_id": "8", + "input": "audio_vae", + "via_reroute": false, + "source_reference": [ + "4", + 0 + ], + "api": [ + "4", + 0 + ], + "differences": [] + }, + { + "node_id": "8", + "input": "finite_plan", + "via_reroute": false, + "source_reference": [ + "7", + 2 + ], + "api": [ + "7", + 2 + ], + "differences": [] + }, + { + "node_id": "8", + "input": "sampler", + "via_reroute": false, + "source_reference": [ + "6", + 0 + ], + "api": [ + "6", + 0 + ], + "differences": [] + }, + { + "node_id": "8", + "input": "sigmas", + "via_reroute": false, + "source_reference": [ + "5", + 0 + ], + "api": [ + "5", + 0 + ], + "differences": [] + }, + { + "node_id": "9", + "input": "images", + "via_reroute": false, + "source_reference": [ + "8", + 1 + ], + "api": [ + "8", + 1 + ], + "differences": [] + }, + { + "node_id": "9", + "input": "audio", + "via_reroute": false, + "source_reference": [ + "8", + 2 + ], + "api": [ + "8", + 2 + ], + "differences": [] + }, + { + "node_id": "7", + "input": "width", + "via_reroute": false, + "source_reference": [ + "24", + 0 + ], + "api": [ + "24", + 0 + ], + "differences": [] + }, + { + "node_id": "7", + "input": "height", + "via_reroute": false, + "source_reference": [ + "24", + 1 + ], + "api": [ + "24", + 1 + ], + "differences": [] + }, + { + "node_id": "5", + "input": "model", + "via_reroute": false, + "source_reference": [ + "22", + 0 + ], + "api": [ + "22", + 0 + ], + "differences": [] + } + ], + "unsupported_widget_nodes": [ + { + "node_id": "10", + "type": "SaveVideo", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "19", + "type": "ModelAttentionBackend", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "18", + "type": "MiniMaxH3SigmaShift", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "20", + "type": "BlockSparseAttention", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "2", + "type": "CLIPLoader", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "4", + "type": "VAELoader", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "21", + "type": "LoraLoaderModelOnly", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "22", + "type": "ModelPreviewOverrideKJ", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "8", + "type": "MiniMaxH3FiniteSegmentSampler", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "9", + "type": "CreateVideo", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "24", + "type": "ResolutionSelector", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "7", + "type": "MiniMaxH3TimelinePlanner", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "3", + "type": "VAELoader", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "1", + "type": "UNETLoader", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "5", + "type": "BasicScheduler", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "6", + "type": "KSamplerSelect", + "reason": "源节点声明与固定核心参考版本不符" + } + ], + "diagnostic_graph": null, + "unresolved_boundaries": [], + "resolved_boundaries": [], + "node_types": [ + { + "node_id": "10", + "source_type": "SaveVideo", + "api_type": "SaveVideo", + "differences": [] + }, + { + "node_id": "19", + "source_type": "ModelAttentionBackend", + "api_type": "ModelAttentionBackend", + "differences": [] + }, + { + "node_id": "18", + "source_type": "MiniMaxH3SigmaShift", + "api_type": "MiniMaxH3SigmaShift", + "differences": [] + }, + { + "node_id": "20", + "source_type": "BlockSparseAttention", + "api_type": "BlockSparseAttention", + "differences": [] + }, + { + "node_id": "2", + "source_type": "CLIPLoader", + "api_type": "CLIPLoader", + "differences": [] + }, + { + "node_id": "4", + "source_type": "VAELoader", + "api_type": "VAELoader", + "differences": [] + }, + { + "node_id": "21", + "source_type": "LoraLoaderModelOnly", + "api_type": "LoraLoaderModelOnly", + "differences": [] + }, + { + "node_id": "22", + "source_type": "ModelPreviewOverrideKJ", + "api_type": "ModelPreviewOverrideKJ", + "differences": [] + }, + { + "node_id": "8", + "source_type": "MiniMaxH3FiniteSegmentSampler", + "api_type": "MiniMaxH3FiniteSegmentSampler", + "differences": [] + }, + { + "node_id": "9", + "source_type": "CreateVideo", + "api_type": "CreateVideo", + "differences": [] + }, + { + "node_id": "24", + "source_type": "ResolutionSelector", + "api_type": "ResolutionSelector", + "differences": [] + }, + { + "node_id": "7", + "source_type": "MiniMaxH3TimelinePlanner", + "api_type": "MiniMaxH3TimelinePlanner", + "differences": [] + }, + { + "node_id": "3", + "source_type": "VAELoader", + "api_type": "VAELoader", + "differences": [] + }, + { + "node_id": "1", + "source_type": "UNETLoader", + "api_type": "UNETLoader", + "differences": [] + }, + { + "node_id": "5", + "source_type": "BasicScheduler", + "api_type": "BasicScheduler", + "differences": [] + }, + { + "node_id": "6", + "source_type": "KSamplerSelect", + "api_type": "KSamplerSelect", + "differences": [] + } + ], + "metadata": [ + { + "node_id": "10", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "保存视频", + "actual": "SaveVideo" + } + ] + }, + { + "node_id": "19", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "模型注意力后端", + "actual": "ModelAttentionBackend" + } + ] + }, + { + "node_id": "18", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "MiniMax H3 Sigma Shift", + "actual": "MiniMaxH3SigmaShift" + } + ] + }, + { + "node_id": "20", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "模型稀疏注意力", + "actual": "BlockSparseAttention" + } + ] + }, + { + "node_id": "2", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "加载CLIP", + "actual": "CLIPLoader" + } + ] + }, + { + "node_id": "4", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "加载VAE", + "actual": "VAELoader" + } + ] + }, + { + "node_id": "21", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "LoRA加载器(仅模型)", + "actual": "LoraLoaderModelOnly" + } + ] + }, + { + "node_id": "22", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "Model Preview Override", + "actual": "ModelPreviewOverrideKJ" + } + ] + }, + { + "node_id": "8", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "MiniMax H3 有限分段采样", + "actual": "MiniMaxH3FiniteSegmentSampler" + } + ] + }, + { + "node_id": "9", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "创建视频", + "actual": "CreateVideo" + } + ] + }, + { + "node_id": "24", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "分辨率选择器", + "actual": "ResolutionSelector" + } + ] + }, + { + "node_id": "7", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "MiniMax H3 素材规划台", + "actual": "MiniMaxH3TimelinePlanner" + } + ] + }, + { + "node_id": "3", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "加载VAE", + "actual": "VAELoader" + } + ] + }, + { + "node_id": "1", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "UNet加载器", + "actual": "UNETLoader" + } + ] + }, + { + "node_id": "5", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "基本调度器", + "actual": "BasicScheduler" + } + ] + }, + { + "node_id": "6", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "K采样器选择", + "actual": "KSamplerSelect" + } + ] + } + ], + "api_only_fields_for_supported_nodes": [], + "comparison_is_complete": false, + "executable": false, + "execution_verified": false + }, + { + "id": "07", + "selected_profile": "comfy-frontend-1.37.11-controlnet-aux-e8b689a-reference", + "source_path": "example_ComfyUI_workflows/6-动作迁移/Wan_Animate2_动作迁移_for循环长视频.json", + "source_sha256": "22b7853e22629822dd354b0b768e2961a53b4c2f480cfaceeaea9dc51c0f0d0b", + "api_sha256": "b1b4f6a6c02d8d21701943c67b62805b1210fed17e7e26b618c58e112ea1d70d", + "source_frontend_version": "1.48.6", + "export_frontend_version": null, + "whole_prompt_available": false, + "candidate_prompt": null, + "whole_prompt_differences": null, + "whole_prompt_issues": [ + { + "code": "subgraph_requires_export", + "message": "包含子图:需原 ComfyUI API 导出及差分核对", + "node_id": "" + }, + { + "code": "reference_frontend_mismatch", + "message": "源图声明的前端版本与固定参考不一致", + "node_id": "" + }, + { + "code": "reference_link_invalid", + "message": "静音/旁路不在追线参考契约内", + "node_id": "" + }, + { + "code": "reference_link_invalid", + "message": "静音/旁路不在追线参考契约内", + "node_id": "" + }, + { + "code": "mode_requires_export", + "message": "SaveVideo 包含静音/旁路状态,需 API 导出核对", + "node_id": "292" + }, + { + "code": "mode_requires_export", + "message": "79280513-53b2-4417-93f8-f3e116bb6736 包含静音/旁路状态,需 API 导出核对", + "node_id": "291" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:PrimitiveStringMultiline", + "node_id": "583" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:INTConstant", + "node_id": "580" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:TTResolutionSelector", + "node_id": "579" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:SetNode", + "node_id": "600" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:GetNode", + "node_id": "603" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:GetNode", + "node_id": "602" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:VHS_VideoInfoLoaded", + "node_id": "586" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:SetNode", + "node_id": "604" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:GetNode", + "node_id": "605" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:PrimitiveStringMultiline", + "node_id": "584" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:SetNode", + "node_id": "597" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:PreviewAny", + "node_id": "538" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:ComfyMathExpression", + "node_id": "536" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:b798a87e-23ec-483d-ab9b-6af5b298d0ad", + "node_id": "477" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:GetNode", + "node_id": "598" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:11706f8a-428d-4ef9-b24f-863f651c1b0b", + "node_id": "261" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:PreviewAny", + "node_id": "607" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:SetNode", + "node_id": "608" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:CreateVideo", + "node_id": "245" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:GetNode", + "node_id": "609" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:SaveVideo", + "node_id": "246" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:SetNode", + "node_id": "601" + }, + { + "code": "reference_widget_unverified", + "message": "源节点声明与固定核心参考版本不符", + "node_id": "189" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:Label (rgthree)", + "node_id": "610" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:bb1c37c2-3479-48a8-88c0-11e7d43715d6", + "node_id": "606" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:VHS_LoadVideo", + "node_id": "585" + }, + { + "code": "empty_prompt", + "message": "未得到可执行节点", + "node_id": "" + } + ], + "production_prompt_available": false, + "serialized_fields": [], + "topology_edges": [ + { + "node_id": "292", + "input": "video", + "status": "unsupported", + "reason": "静音/旁路不在追线参考契约内" + }, + { + "node_id": "291", + "input": "video", + "status": "unsupported", + "reason": "静音/旁路不在追线参考契约内" + }, + { + "node_id": "600", + "input": "AUDIO", + "via_reroute": false, + "source_reference": [ + "585", + 2 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "585", + 2 + ], + "kind": "type" + } + ] + }, + { + "node_id": "586", + "input": "video_info", + "via_reroute": false, + "source_reference": [ + "585", + 3 + ], + "api": [ + "585", + 3 + ], + "differences": [] + }, + { + "node_id": "604", + "input": "INT", + "via_reroute": false, + "source_reference": [ + "586", + 1 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "586", + 1 + ], + "kind": "type" + } + ] + }, + { + "node_id": "597", + "input": "FLOAT", + "via_reroute": false, + "source_reference": [ + "536", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "536", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "538", + "input": "source", + "via_reroute": false, + "source_reference": [ + "536", + 0 + ], + "api": [ + "536", + 0 + ], + "differences": [] + }, + { + "node_id": "536", + "input": "values.a", + "via_reroute": false, + "source_reference": [ + "605", + 0 + ], + "api": [ + "586", + 1 + ], + "differences": [ + { + "path": "/0", + "kind": "value", + "expected": "586", + "actual": "605" + }, + { + "path": "/1", + "kind": "value", + "expected": 1, + "actual": 0 + } + ] + }, + { + "node_id": "536", + "input": "values.b", + "via_reroute": false, + "source_reference": [ + "580", + 0 + ], + "api": [ + "580", + 0 + ], + "differences": [] + }, + { + "node_id": "477", + "input": "input", + "via_reroute": true, + "source_reference": [ + "189", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "189", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "477", + "input": "continue_motion", + "via_reroute": false, + "source_reference": [ + "606", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "606", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "477", + "input": "video_frame_offset_1", + "via_reroute": false, + "source_reference": [ + "606", + 1 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "606", + 1 + ], + "kind": "type" + } + ] + }, + { + "node_id": "477", + "input": "text", + "via_reroute": false, + "source_reference": [ + "583", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "583", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "477", + "input": "text_4", + "via_reroute": false, + "source_reference": [ + "584", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "584", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "477", + "input": "resize_type.width", + "via_reroute": false, + "source_reference": [ + "579", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "579", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "477", + "input": "resize_type.height_1", + "via_reroute": false, + "source_reference": [ + "579", + 1 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "579", + 1 + ], + "kind": "type" + } + ] + }, + { + "node_id": "477", + "input": "length", + "via_reroute": false, + "source_reference": [ + "580", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "580", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "477", + "input": "input_1", + "via_reroute": true, + "source_reference": [ + "585", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "585", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "261", + "input": "input", + "via_reroute": true, + "source_reference": [ + "189", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "189", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "261", + "input": "text", + "via_reroute": false, + "source_reference": [ + "583", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "583", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "261", + "input": "text_4", + "via_reroute": false, + "source_reference": [ + "584", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "584", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "261", + "input": "resize_type.width", + "via_reroute": false, + "source_reference": [ + "579", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "579", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "261", + "input": "resize_type.height_1", + "via_reroute": false, + "source_reference": [ + "579", + 1 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "579", + 1 + ], + "kind": "type" + } + ] + }, + { + "node_id": "261", + "input": "length", + "via_reroute": false, + "source_reference": [ + "580", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "580", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "261", + "input": "input_1", + "via_reroute": true, + "source_reference": [ + "585", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "585", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "607", + "input": "source", + "via_reroute": false, + "source_reference": [ + "606", + 3 + ], + "api": [ + "606:596", + 0 + ], + "differences": [ + { + "path": "/0", + "kind": "value", + "expected": "606:596", + "actual": "606" + }, + { + "path": "/1", + "kind": "value", + "expected": 0, + "actual": 3 + } + ] + }, + { + "node_id": "608", + "input": "*", + "via_reroute": false, + "source_reference": [ + "606", + 2 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "606", + 2 + ], + "kind": "type" + } + ] + }, + { + "node_id": "245", + "input": "images", + "via_reroute": false, + "source_reference": [ + "609", + 0 + ], + "api": [ + "606:599", + 2 + ], + "differences": [ + { + "path": "/0", + "kind": "value", + "expected": "606:599", + "actual": "609" + }, + { + "path": "/1", + "kind": "value", + "expected": 2, + "actual": 0 + } + ] + }, + { + "node_id": "245", + "input": "audio", + "via_reroute": false, + "source_reference": [ + "602", + 0 + ], + "api": [ + "585", + 2 + ], + "differences": [ + { + "path": "/0", + "kind": "value", + "expected": "585", + "actual": "602" + }, + { + "path": "/1", + "kind": "value", + "expected": 2, + "actual": 0 + } + ] + }, + { + "node_id": "245", + "input": "fps", + "via_reroute": false, + "source_reference": [ + "603", + 0 + ], + "api": [ + "586", + 0 + ], + "differences": [ + { + "path": "/0", + "kind": "value", + "expected": "586", + "actual": "603" + } + ] + }, + { + "node_id": "246", + "input": "video", + "via_reroute": false, + "source_reference": [ + "245", + 0 + ], + "api": [ + "245", + 0 + ], + "differences": [] + }, + { + "node_id": "601", + "input": "FLOAT", + "via_reroute": false, + "source_reference": [ + "586", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "586", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "606", + "input": "initial_value1", + "via_reroute": false, + "source_reference": [ + "261", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "261", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "606", + "input": "initial_value2", + "via_reroute": false, + "source_reference": [ + "261", + 1 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "261", + 1 + ], + "kind": "type" + } + ] + }, + { + "node_id": "606", + "input": "initial_value3", + "via_reroute": false, + "source_reference": [ + "261", + 2 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "261", + 2 + ], + "kind": "type" + } + ] + }, + { + "node_id": "606", + "input": "a", + "via_reroute": false, + "source_reference": [ + "598", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "598", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "606", + "input": "initial_value1_1", + "via_reroute": false, + "source_reference": [ + "477", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "477", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "606", + "input": "initial_value2_1", + "via_reroute": false, + "source_reference": [ + "477", + 1 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "477", + 1 + ], + "kind": "type" + } + ] + }, + { + "node_id": "606", + "input": "images.image1_1", + "via_reroute": false, + "source_reference": [ + "477", + 2 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "477", + 2 + ], + "kind": "type" + } + ] + } + ], + "unsupported_widget_nodes": [ + { + "node_id": "292", + "type": "SaveVideo", + "reason": "静音/旁路不在序列化参考契约内" + }, + { + "node_id": "291", + "type": "79280513-53b2-4417-93f8-f3e116bb6736", + "reason": "静音/旁路不在序列化参考契约内" + }, + { + "node_id": "583", + "type": "PrimitiveStringMultiline", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "580", + "type": "INTConstant", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "579", + "type": "TTResolutionSelector", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "600", + "type": "SetNode", + "reason": "控件数量/形式或节点类型不在固定参考契约内" + }, + { + "node_id": "603", + "type": "GetNode", + "reason": "控件数量/形式或节点类型不在固定参考契约内" + }, + { + "node_id": "602", + "type": "GetNode", + "reason": "控件数量/形式或节点类型不在固定参考契约内" + }, + { + "node_id": "586", + "type": "VHS_VideoInfoLoaded", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "604", + "type": "SetNode", + "reason": "控件数量/形式或节点类型不在固定参考契约内" + }, + { + "node_id": "605", + "type": "GetNode", + "reason": "控件数量/形式或节点类型不在固定参考契约内" + }, + { + "node_id": "584", + "type": "PrimitiveStringMultiline", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "597", + "type": "SetNode", + "reason": "控件数量/形式或节点类型不在固定参考契约内" + }, + { + "node_id": "538", + "type": "PreviewAny", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "536", + "type": "ComfyMathExpression", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "477", + "type": "b798a87e-23ec-483d-ab9b-6af5b298d0ad", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "598", + "type": "GetNode", + "reason": "控件数量/形式或节点类型不在固定参考契约内" + }, + { + "node_id": "261", + "type": "11706f8a-428d-4ef9-b24f-863f651c1b0b", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "607", + "type": "PreviewAny", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "608", + "type": "SetNode", + "reason": "控件数量/形式或节点类型不在固定参考契约内" + }, + { + "node_id": "245", + "type": "CreateVideo", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "609", + "type": "GetNode", + "reason": "控件数量/形式或节点类型不在固定参考契约内" + }, + { + "node_id": "246", + "type": "SaveVideo", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "601", + "type": "SetNode", + "reason": "控件数量/形式或节点类型不在固定参考契约内" + }, + { + "node_id": "189", + "type": "LoadImage", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "610", + "type": "Label (rgthree)", + "reason": "控件数量/形式或节点类型不在固定参考契约内" + }, + { + "node_id": "606", + "type": "bb1c37c2-3479-48a8-88c0-11e7d43715d6", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "585", + "type": "VHS_LoadVideo", + "reason": "源节点声明与固定核心参考版本不符" + } + ], + "diagnostic_graph": null, + "unresolved_boundaries": [], + "resolved_boundaries": [], + "node_types": [ + { + "node_id": "292", + "source_type": "SaveVideo", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "SaveVideo", + "kind": "type" + } + ] + }, + { + "node_id": "291", + "source_type": "79280513-53b2-4417-93f8-f3e116bb6736", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "79280513-53b2-4417-93f8-f3e116bb6736", + "kind": "type" + } + ] + }, + { + "node_id": "583", + "source_type": "PrimitiveStringMultiline", + "api_type": "PrimitiveStringMultiline", + "differences": [] + }, + { + "node_id": "580", + "source_type": "INTConstant", + "api_type": "INTConstant", + "differences": [] + }, + { + "node_id": "579", + "source_type": "TTResolutionSelector", + "api_type": "TTResolutionSelector", + "differences": [] + }, + { + "node_id": "600", + "source_type": "SetNode", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "SetNode", + "kind": "type" + } + ] + }, + { + "node_id": "603", + "source_type": "GetNode", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "GetNode", + "kind": "type" + } + ] + }, + { + "node_id": "602", + "source_type": "GetNode", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "GetNode", + "kind": "type" + } + ] + }, + { + "node_id": "586", + "source_type": "VHS_VideoInfoLoaded", + "api_type": "VHS_VideoInfoLoaded", + "differences": [] + }, + { + "node_id": "604", + "source_type": "SetNode", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "SetNode", + "kind": "type" + } + ] + }, + { + "node_id": "605", + "source_type": "GetNode", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "GetNode", + "kind": "type" + } + ] + }, + { + "node_id": "584", + "source_type": "PrimitiveStringMultiline", + "api_type": "PrimitiveStringMultiline", + "differences": [] + }, + { + "node_id": "597", + "source_type": "SetNode", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "SetNode", + "kind": "type" + } + ] + }, + { + "node_id": "538", + "source_type": "PreviewAny", + "api_type": "PreviewAny", + "differences": [] + }, + { + "node_id": "536", + "source_type": "ComfyMathExpression", + "api_type": "ComfyMathExpression", + "differences": [] + }, + { + "node_id": "477", + "source_type": "b798a87e-23ec-483d-ab9b-6af5b298d0ad", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "b798a87e-23ec-483d-ab9b-6af5b298d0ad", + "kind": "type" + } + ] + }, + { + "node_id": "598", + "source_type": "GetNode", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "GetNode", + "kind": "type" + } + ] + }, + { + "node_id": "261", + "source_type": "11706f8a-428d-4ef9-b24f-863f651c1b0b", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "11706f8a-428d-4ef9-b24f-863f651c1b0b", + "kind": "type" + } + ] + }, + { + "node_id": "607", + "source_type": "PreviewAny", + "api_type": "PreviewAny", + "differences": [] + }, + { + "node_id": "608", + "source_type": "SetNode", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "SetNode", + "kind": "type" + } + ] + }, + { + "node_id": "245", + "source_type": "CreateVideo", + "api_type": "CreateVideo", + "differences": [] + }, + { + "node_id": "609", + "source_type": "GetNode", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "GetNode", + "kind": "type" + } + ] + }, + { + "node_id": "246", + "source_type": "SaveVideo", + "api_type": "SaveVideo", + "differences": [] + }, + { + "node_id": "601", + "source_type": "SetNode", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "SetNode", + "kind": "type" + } + ] + }, + { + "node_id": "189", + "source_type": "LoadImage", + "api_type": "LoadImage", + "differences": [] + }, + { + "node_id": "610", + "source_type": "Label (rgthree)", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "Label (rgthree)", + "kind": "type" + } + ] + }, + { + "node_id": "606", + "source_type": "bb1c37c2-3479-48a8-88c0-11e7d43715d6", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "bb1c37c2-3479-48a8-88c0-11e7d43715d6", + "kind": "type" + } + ] + }, + { + "node_id": "585", + "source_type": "VHS_LoadVideo", + "api_type": "VHS_LoadVideo", + "differences": [] + } + ], + "metadata": [ + { + "node_id": "292", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "SaveVideo" + }, + "kind": "type" + } + ] + }, + { + "node_id": "291", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "79280513-53b2-4417-93f8-f3e116bb6736" + }, + "kind": "type" + } + ] + }, + { + "node_id": "583", + "differences": [] + }, + { + "node_id": "580", + "differences": [] + }, + { + "node_id": "579", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "TT分辨率选择器", + "actual": "TTResolutionSelector" + } + ] + }, + { + "node_id": "600", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "Set_音频" + }, + "kind": "type" + } + ] + }, + { + "node_id": "603", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "Get_帧率" + }, + "kind": "type" + } + ] + }, + { + "node_id": "602", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "Get_音频" + }, + "kind": "type" + } + ] + }, + { + "node_id": "586", + "differences": [] + }, + { + "node_id": "604", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "Set_动作视频帧数" + }, + "kind": "type" + } + ] + }, + { + "node_id": "605", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "Get_动作视频帧数" + }, + "kind": "type" + } + ] + }, + { + "node_id": "584", + "differences": [] + }, + { + "node_id": "597", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "Set_执行次数" + }, + "kind": "type" + } + ] + }, + { + "node_id": "538", + "differences": [] + }, + { + "node_id": "536", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "数学表达式", + "actual": "ComfyMathExpression" + } + ] + }, + { + "node_id": "477", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "b798a87e-23ec-483d-ab9b-6af5b298d0ad" + }, + "kind": "type" + } + ] + }, + { + "node_id": "598", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "Get_执行次数" + }, + "kind": "type" + } + ] + }, + { + "node_id": "261", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "11706f8a-428d-4ef9-b24f-863f651c1b0b" + }, + "kind": "type" + } + ] + }, + { + "node_id": "607", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "预览任意", + "actual": "PreviewAny" + } + ] + }, + { + "node_id": "608", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "Set_循环结果输出" + }, + "kind": "type" + } + ] + }, + { + "node_id": "245", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "创建视频", + "actual": "CreateVideo" + } + ] + }, + { + "node_id": "609", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "Get_循环结果输出" + }, + "kind": "type" + } + ] + }, + { + "node_id": "246", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "保存视频", + "actual": "SaveVideo" + } + ] + }, + { + "node_id": "601", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "Set_帧率" + }, + "kind": "type" + } + ] + }, + { + "node_id": "189", + "differences": [] + }, + { + "node_id": "610", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "Wan_animate2_动作迁移 For循环长视频 by Bright" + }, + "kind": "type" + } + ] + }, + { + "node_id": "606", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "bb1c37c2-3479-48a8-88c0-11e7d43715d6" + }, + "kind": "type" + } + ] + }, + { + "node_id": "585", + "differences": [] + } + ], + "api_only_fields_for_supported_nodes": [], + "comparison_is_complete": false, + "executable": false, + "execution_verified": false + } + ] +} diff --git a/docs/hel-892/promoted-evidence/previous-profile-protection.json b/docs/hel-892/promoted-evidence/previous-profile-protection.json new file mode 100644 index 00000000..a366cd1c --- /dev/null +++ b/docs/hel-892/promoted-evidence/previous-profile-protection.json @@ -0,0 +1,80 @@ +[ + { + "id": "01", + "unchanged_fields": [ + "whole_prompt_available", + "whole_prompt_differences", + "whole_prompt_issues", + "serialized_fields", + "topology_edges", + "unsupported_widget_nodes", + "production_prompt_available", + "api_only_fields_for_supported_nodes" + ] + }, + { + "id": "02", + "unchanged_fields": [ + "whole_prompt_available", + "whole_prompt_differences", + "whole_prompt_issues", + "serialized_fields", + "topology_edges", + "unsupported_widget_nodes", + "production_prompt_available", + "api_only_fields_for_supported_nodes" + ] + }, + { + "id": "03", + "unchanged_fields": [ + "whole_prompt_available", + "whole_prompt_differences", + "whole_prompt_issues", + "serialized_fields", + "topology_edges", + "unsupported_widget_nodes", + "production_prompt_available", + "api_only_fields_for_supported_nodes" + ] + }, + { + "id": "04", + "unchanged_fields": [ + "whole_prompt_available", + "whole_prompt_differences", + "whole_prompt_issues", + "serialized_fields", + "topology_edges", + "unsupported_widget_nodes", + "production_prompt_available", + "api_only_fields_for_supported_nodes" + ] + }, + { + "id": "05", + "unchanged_fields": [ + "whole_prompt_available", + "whole_prompt_differences", + "whole_prompt_issues", + "serialized_fields", + "topology_edges", + "unsupported_widget_nodes", + "production_prompt_available", + "api_only_fields_for_supported_nodes" + ] + }, + { + "id": "07", + "unchanged_fields": [ + "whole_prompt_available", + "whole_prompt_differences", + "whole_prompt_issues", + "serialized_fields", + "topology_edges", + "unsupported_widget_nodes", + "production_prompt_available", + "api_only_fields_for_supported_nodes" + ] + } +] diff --git a/docs/hel-892/promoted-evidence/protection.json b/docs/hel-892/promoted-evidence/protection.json new file mode 100644 index 00000000..5fe7b581 --- /dev/null +++ b/docs/hel-892/promoted-evidence/protection.json @@ -0,0 +1,20 @@ +{ + "source_baseline_commit": "5e5cc03395aabd9511744be8933cd587ba0cacaa", + "original_bytes": { + "source": { + "files": 156, + "all_equal_to_base": true, + "set_sha256": "c557a64d6d513a4a7500cc8592d12979db93ba2f2e4f2182c157550b39e1dd6f" + }, + "received_api": { + "files": 7, + "all_equal_to_base": true, + "set_sha256": "c2af534d392d28cc6b2ec81d29032acd3e018c37917975692548c447a93f46cb" + } + }, + "isolated_rows": 155, + "disabled_rows": 155, + "null_completion_and_execution_timestamps": true, + "production_import_and_registry_unchanged": true, + "user_whole_row_protection": "test_workflow_library.py and test_delivery_scope.py regression passed" +} diff --git a/docs/hel-892/promoted-evidence/reimport.txt b/docs/hel-892/promoted-evidence/reimport.txt new file mode 100644 index 00000000..7a122041 --- /dev/null +++ b/docs/hel-892/promoted-evidence/reimport.txt @@ -0,0 +1 @@ +{"batch_id": "a3c15c75-1762-404a-8d6d-9e3a2c8f79f7", "source_commit": "1fc8bdb8bb2a88ccace6f21a507fd77bcf22f532", "counts": {"skipped": 155, "user_excluded": 1}, "states": {"pending_check": 16, "needs_conversion": 139}, "source_total": 156, "excluded_total": 1, "target_total": 155, "total": 156, "doc_completed": 0, "exec_verified": 0} diff --git a/docs/hel-892/promoted-evidence/reused-source-verification.json b/docs/hel-892/promoted-evidence/reused-source-verification.json new file mode 100644 index 00000000..a0a475ee --- /dev/null +++ b/docs/hel-892/promoted-evidence/reused-source-verification.json @@ -0,0 +1,203 @@ +{ + "authority": "public_reference_only", + "sources_verified": [ + { + "id": "1.37.11:LICENSE", + "sha256": "3972dc9744f6499f0f9b2dbf76696f2ae7ad8af9b23dde66d6af86c9dfb36986" + }, + { + "id": "1.37.11:src/extensions/core/widgetInputs.ts", + "sha256": "488d38eb209816778a6da8cb8f734f539e3fbd7f77aae41ec649a52b8764b613" + }, + { + "id": "1.37.11:src/utils/executionUtil.ts", + "sha256": "4e51bc54e35cb7ac9bb7cba418a74ccdd5974f640b9b088aa4ae7668f746ab36" + }, + { + "id": "1.37.11:src/lib/litegraph/src/subgraph/ExecutableNodeDTO.ts", + "sha256": "fd2e19a6b8f4369e6e97d79f407cc1bec130feec9d6d3c979cc03b0a556f249f" + }, + { + "id": "1.37.11:src/lib/litegraph/src/subgraph/Subgraph.ts", + "sha256": "321403ca3ba2faa0b448dec6e8bf379e49ddea4bfbe8619547d29926e30d62d2" + }, + { + "id": "1.37.11:src/lib/litegraph/src/subgraph/SubgraphNode.ts", + "sha256": "d4f1017495158a6133ff770441a4d517dfbf2a328ba42b0405f8729853fe8209" + }, + { + "id": "1.37.11:src/lib/litegraph/src/LLink.ts", + "sha256": "1d58845322b30f122aeafb23ca286ca7349ca23215469f96afb7a98fd6596af4" + }, + { + "id": "1.48.7:LICENSE", + "sha256": "3972dc9744f6499f0f9b2dbf76696f2ae7ad8af9b23dde66d6af86c9dfb36986" + }, + { + "id": "1.48.7:src/extensions/core/widgetInputs.ts", + "sha256": "fdceceedc727e8a696f273a810fc39a075004a09ea793e0df51418f96ac52a61" + }, + { + "id": "1.48.7:src/utils/executionUtil.ts", + "sha256": "264e11395f28880603e7f9fe36d2e61c74cd59d6d88be990225cce8510e3f816" + }, + { + "id": "1.48.7:src/lib/litegraph/src/subgraph/ExecutableNodeDTO.ts", + "sha256": "64baa71b46bd67440b032e18e4d9aebb67a6cc135fe7c4509ae1b5bc25acc2a3" + }, + { + "id": "1.48.7:src/lib/litegraph/src/subgraph/Subgraph.ts", + "sha256": "321403ca3ba2faa0b448dec6e8bf379e49ddea4bfbe8619547d29926e30d62d2" + }, + { + "id": "1.48.7:src/lib/litegraph/src/subgraph/SubgraphNode.ts", + "sha256": "822b0cdde3fe6a096f82310075a6285ae967dc58d760f19d743442ea20f4f15f" + }, + { + "id": "1.48.7:src/lib/litegraph/src/LLink.ts", + "sha256": "9e9c92acacd5edc58a9c1ad2b3ba66679f27ebda28da74765947d88ce11df656" + }, + { + "id": "1.53.6:LICENSE", + "sha256": "3972dc9744f6499f0f9b2dbf76696f2ae7ad8af9b23dde66d6af86c9dfb36986" + }, + { + "id": "1.53.6:src/extensions/core/widgetInputs.ts", + "sha256": "f6b3d33b9ffdf4f68136ee0f72d03dabf4affa3292721d1f221b47de792e0daf" + }, + { + "id": "1.53.6:src/utils/executionUtil.ts", + "sha256": "b29fd312e66c7415fa4c720654ac121dc67600b0c1fedf079b6575a174960698" + }, + { + "id": "1.53.6:src/lib/litegraph/src/subgraph/ExecutableNodeDTO.ts", + "sha256": "0c0ca487822a9f86324925c2fb4ea59c6c032ad5d042a83ac367cb15196454fe" + }, + { + "id": "1.53.6:src/lib/litegraph/src/subgraph/Subgraph.ts", + "sha256": "321403ca3ba2faa0b448dec6e8bf379e49ddea4bfbe8619547d29926e30d62d2" + }, + { + "id": "1.53.6:src/lib/litegraph/src/subgraph/SubgraphNode.ts", + "sha256": "29f2da27396bcc426180d819549f654278d65de973ade651d57c4905e319fb9c" + }, + { + "id": "1.53.6:src/lib/litegraph/src/LLink.ts", + "sha256": "562694d5bccb5682222c500a7e7069501eeb94e69eeb1b9a534d1e511902ef57" + }, + { + "id": "1.48.6:LICENSE", + "sha256": "3972dc9744f6499f0f9b2dbf76696f2ae7ad8af9b23dde66d6af86c9dfb36986" + }, + { + "id": "1.48.6:src/extensions/core/widgetInputs.ts", + "sha256": "fdceceedc727e8a696f273a810fc39a075004a09ea793e0df51418f96ac52a61" + }, + { + "id": "1.48.6:src/utils/executionUtil.ts", + "sha256": "264e11395f28880603e7f9fe36d2e61c74cd59d6d88be990225cce8510e3f816" + }, + { + "id": "1.48.6:src/lib/litegraph/src/subgraph/ExecutableNodeDTO.ts", + "sha256": "64baa71b46bd67440b032e18e4d9aebb67a6cc135fe7c4509ae1b5bc25acc2a3" + }, + { + "id": "1.48.6:src/lib/litegraph/src/subgraph/Subgraph.ts", + "sha256": "321403ca3ba2faa0b448dec6e8bf379e49ddea4bfbe8619547d29926e30d62d2" + }, + { + "id": "1.48.6:src/lib/litegraph/src/subgraph/SubgraphNode.ts", + "sha256": "822b0cdde3fe6a096f82310075a6285ae967dc58d760f19d743442ea20f4f15f" + }, + { + "id": "1.48.6:src/lib/litegraph/src/LLink.ts", + "sha256": "9e9c92acacd5edc58a9c1ad2b3ba66679f27ebda28da74765947d88ce11df656" + }, + { + "id": "Comfy-Org/ComfyUI_frontend:src/extensions/core/previewAny.ts", + "sha256": "2b19989ac8a3c26e198c7db7f7e2210936b0a4f4d3b26183917baafb841c1874" + }, + { + "id": "Comfy-Org/ComfyUI_frontend:src/extensions/core/uploadAudio.ts", + "sha256": "0a11f1ad5651d238130bc06aca2a4b31a41f8bec98d0f8512e02ffb42b262e66" + }, + { + "id": "Comfy-Org/ComfyUI_frontend:src/scripts/widgets.ts", + "sha256": "e8bb428cbf69635015de43a4ebc89817b3443f876cbed52eeafe67d26f2398d8" + }, + { + "id": "Comfy-Org/ComfyUI_frontend:src/scripts/app.ts", + "sha256": "e57985f7d365abb035bc2fc755a8f5b10efbca97a7dcb5b2a4a05bcbc78b9d5c" + }, + { + "id": "1038lab/ComfyUI-QwenASR:AILab_QwenASR.py", + "sha256": "f8cda2d0d39517f93ace1a73263146a4bea59a02604e58919a05393c45ade6b7" + }, + { + "id": "1038lab/ComfyUI-QwenASR:__init__.py", + "sha256": "0919008142c12f8fe9a12671a1ca1de548ded128dd7287a13f6230d9729b47c2" + }, + { + "id": "Comfy-Org/ComfyUI:LICENSE", + "sha256": "3972dc9744f6499f0f9b2dbf76696f2ae7ad8af9b23dde66d6af86c9dfb36986" + }, + { + "id": "Comfy-Org/ComfyUI:comfy_extras/nodes_audio.py", + "sha256": "d47eefe226c273f20561545f6a664bfdfa5c193cec7178c925b5dc5ccb642a9c" + }, + { + "id": "Comfy-Org/ComfyUI:comfy_extras/nodes_preview_any.py", + "sha256": "f8c526dbc4ec512f88a067524865f59eb24db636858f37d601e848885b2d0751" + }, + { + "id": "qwen-history:aaf40688c93c8e083f8a47d9107e6f95405ea7c9", + "sha256": "f8cda2d0d39517f93ace1a73263146a4bea59a02604e58919a05393c45ade6b7" + }, + { + "id": "qwen-history:b037d7be121111a1ba6f40a4d99f6b43ac6411b6", + "sha256": "af7721c1015fef8cb40a724226fb0f720397d70fb1ce367f9145a3b653dd0cd9" + }, + { + "id": "Comfy-Org/ComfyUI_frontend:src/utils/nodeDefUtil.ts", + "sha256": "9c62901804e584a2e9d7e17e7914475113e41993c44df3d063f0027e95735dc1" + }, + { + "id": "Comfy-Org/ComfyUI_frontend:src/renderer/extensions/vueNodes/widgets/composables/useStringWidget.ts", + "sha256": "b734a2584d558de501150e8011e1c16031f33778c2cd3b4c712f296ce4f05396" + }, + { + "id": "Comfy-Org/ComfyUI_frontend:packages/shared-frontend-utils/src/formatUtil.ts", + "sha256": "7313418fe3a92aae99f2ef91f081257c2b2162b1578155d7346f2f03ab440039" + }, + { + "id": "Comfy-Org/ComfyUI_frontend:src/scripts/domWidget.ts", + "sha256": "34ec3c58d6b236f4e99bfa0c82dcab8e15c6a6b51c6dcb9ace30e37d1a395800" + }, + { + "id": "Comfy-Org/ComfyUI_frontend:src/lib/litegraph/src/LGraphNode.ts", + "sha256": "706225a8a06cd7929f9e04fe2388bcdb8f158cdac756c65c45657c020ab7b319" + }, + { + "id": "1038lab/ComfyUI-QwenASR:LICENSE", + "sha256": "3972dc9744f6499f0f9b2dbf76696f2ae7ad8af9b23dde66d6af86c9dfb36986" + }, + { + "id": "1038lab/ComfyUI-QwenASR:__init__.py", + "sha256": "e35f18c3986ee7b00a918ed644e375bc7cee1b88f740cc52fd93b45ace621a41" + }, + { + "id": "ComfyUI_frontend:src/lib/litegraph/src/widgets/BaseWidget.ts", + "sha256": "6a77b402bbf8c67b9ea2ce58de28c61a1b17da82bb437c29565fb260b721b8c7" + }, + { + "id": "ComfyUI_frontend:src/lib/litegraph/src/widgets/LegacyWidget.ts", + "sha256": "05d098254988191736f1c72f7efc57e3f350d97c82267a97f0b8c193d65daa96" + }, + { + "id": "ComfyUI_frontend:src/renderer/extensions/vueNodes/widgets/composables/useBooleanWidget.ts", + "sha256": "36f477f75561e0c7bfc2c6757906724f8ff2c8660ace26759f3f07493877fece" + } + ], + "upstream_code_executed": false, + "target_version_match": "unknown" +} diff --git a/docs/hel-892/promoted-evidence/six-case-comparison.json b/docs/hel-892/promoted-evidence/six-case-comparison.json new file mode 100644 index 00000000..8a6d6044 --- /dev/null +++ b/docs/hel-892/promoted-evidence/six-case-comparison.json @@ -0,0 +1,9392 @@ +{ + "profile": "promoted-batch-reference", + "authority": "public_reference_only_not_object_info", + "comparison_scope": "explicit supported scalar widgets and projected endpoints only; diagnostic structures never prove widget values, full equivalence or execution", + "reference_conditions": { + "unmodified_frontend_widgets_assumed": true, + "promoted_named_positional": "1.53.6 requires both representations to agree when named values exist; 1.48.7 ignores unknown named keys", + "promoted_missing_or_null": "no silent default; typed scalar consumption rejects null", + "primitive_inside_promoted_profile": "unsupported; whole prompt remains closed", + "combo_availability": "not evaluated; fixed scalar constructor only", + "ue_extension_serializer_match": "unknown", + "aux_release_artifact_commit_match": "not_used", + "aio_combo_membership": "unknown_not_evaluated", + "model_and_media_files_available": "unknown", + "resolution_bounds": "schema metadata only; integer values serialized without clamping" + }, + "target_version_match": "unknown", + "whole_source_equivalence_verified": false, + "execution_verified": false, + "cases": [ + { + "id": "01", + "selected_profile": "comfy-frontend-1.37.11-controlnet-aux-e8b689a-reference", + "source_path": "example_ComfyUI_workflows/0-基础处理:图像合并-音频分离-视频截取合并-图像视频放大/ControlNet_aux_常用样例.json", + "source_sha256": "8898689d777330c4749a079cd762f573bb12a278c47a2fefbd066ffbdc122b6b", + "api_sha256": "0ed76e088a23af43d6fecbf273fc0a983d7112e2b046d347f715afffac56d57e", + "source_frontend_version": null, + "export_frontend_version": null, + "whole_prompt_available": true, + "candidate_prompt": { + "4": { + "class_type": "DepthAnythingPreprocessor", + "inputs": { + "ckpt_name": "depth_anything_vitl14.pth", + "resolution": 512, + "image": [ + "2", + 0 + ] + }, + "_meta": { + "title": "DepthAnything任何深度预处理器" + } + }, + "5": { + "class_type": "PreviewImage", + "inputs": { + "images": [ + "4", + 0 + ] + }, + "_meta": { + "title": "PreviewImage" + } + }, + "3": { + "class_type": "PreviewImage", + "inputs": { + "images": [ + "1", + 0 + ] + }, + "_meta": { + "title": "PreviewImage" + } + }, + "13": { + "class_type": "PreviewImage", + "inputs": { + "images": [ + "12", + 0 + ] + }, + "_meta": { + "title": "PreviewImage" + } + }, + "12": { + "class_type": "AIO_Preprocessor", + "inputs": { + "preprocessor": "CannyEdgePreprocessor", + "resolution": 1024, + "image": [ + "2", + 0 + ] + }, + "_meta": { + "title": "Aux集成预处理器" + } + }, + "1": { + "class_type": "AIO_Preprocessor", + "inputs": { + "preprocessor": "DepthAnythingPreprocessor", + "resolution": 512, + "image": [ + "2", + 0 + ] + }, + "_meta": { + "title": "Aux集成预处理器" + } + }, + "10": { + "class_type": "Canny", + "inputs": { + "low_threshold": 0.4, + "high_threshold": 0.8, + "image": [ + "2", + 0 + ] + }, + "_meta": { + "title": "Canny" + } + }, + "11": { + "class_type": "PreviewImage", + "inputs": { + "images": [ + "10", + 0 + ] + }, + "_meta": { + "title": "PreviewImage" + } + }, + "30": { + "class_type": "ImageStitch", + "inputs": { + "direction": "down", + "match_image_size": true, + "spacing_width": 2, + "spacing_color": "white", + "image1": [ + "28", + 0 + ], + "image2": [ + "29", + 0 + ] + }, + "_meta": { + "title": "ImageStitch" + } + }, + "28": { + "class_type": "ImageStitch", + "inputs": { + "direction": "right", + "match_image_size": true, + "spacing_width": 2, + "spacing_color": "white", + "image1": [ + "18", + 0 + ], + "image2": [ + "19", + 0 + ] + }, + "_meta": { + "title": "ImageStitch" + } + }, + "29": { + "class_type": "ImageStitch", + "inputs": { + "direction": "right", + "match_image_size": true, + "spacing_width": 2, + "spacing_color": "white", + "image1": [ + "20", + 0 + ], + "image2": [ + "21", + 0 + ] + }, + "_meta": { + "title": "ImageStitch" + } + }, + "18": { + "class_type": "AIO_Preprocessor", + "inputs": { + "preprocessor": "AnyLineArtPreprocessor_aux", + "resolution": 1024, + "image": [ + "2", + 0 + ] + }, + "_meta": { + "title": "Aux集成预处理器" + } + }, + "19": { + "class_type": "AIO_Preprocessor", + "inputs": { + "preprocessor": "LineArtPreprocessor", + "resolution": 1024, + "image": [ + "2", + 0 + ] + }, + "_meta": { + "title": "Aux集成预处理器" + } + }, + "20": { + "class_type": "AIO_Preprocessor", + "inputs": { + "preprocessor": "AnimeLineArtPreprocessor", + "resolution": 1024, + "image": [ + "2", + 0 + ] + }, + "_meta": { + "title": "Aux集成预处理器" + } + }, + "22": { + "class_type": "PreviewImage", + "inputs": { + "images": [ + "30", + 0 + ] + }, + "_meta": { + "title": "PreviewImage" + } + }, + "21": { + "class_type": "AIO_Preprocessor", + "inputs": { + "preprocessor": "LineartStandardPreprocessor", + "resolution": 1024, + "image": [ + "2", + 0 + ] + }, + "_meta": { + "title": "Aux集成预处理器" + } + }, + "2": { + "class_type": "LoadImage", + "inputs": { + "image": "comfyui-airport-editorial_00001_.png" + }, + "_meta": { + "title": "LoadImage" + } + }, + "36": { + "class_type": "PreviewImage", + "inputs": { + "images": [ + "33", + 0 + ] + }, + "_meta": { + "title": "PreviewImage" + } + }, + "38": { + "class_type": "LoadImage", + "inputs": { + "image": "1772086821573.png" + }, + "_meta": { + "title": "LoadImage" + } + }, + "37": { + "class_type": "PreviewImage", + "inputs": { + "images": [ + "34", + 0 + ] + }, + "_meta": { + "title": "PreviewImage" + } + }, + "33": { + "class_type": "AIO_Preprocessor", + "inputs": { + "preprocessor": "DWPreprocessor", + "resolution": 1024, + "image": [ + "2", + 0 + ] + }, + "_meta": { + "title": "Aux集成预处理器" + } + }, + "34": { + "class_type": "AIO_Preprocessor", + "inputs": { + "preprocessor": "AnimalPosePreprocessor", + "resolution": 1024, + "image": [ + "38", + 0 + ] + }, + "_meta": { + "title": "Aux集成预处理器" + } + } + }, + "whole_prompt_differences": [ + { + "path": "/10/_meta/title", + "kind": "value", + "expected": "Canny边缘检测", + "actual": "Canny" + }, + { + "path": "/11/_meta/title", + "kind": "value", + "expected": "预览图像", + "actual": "PreviewImage" + }, + { + "path": "/13/_meta/title", + "kind": "value", + "expected": "预览图像", + "actual": "PreviewImage" + }, + { + "path": "/2/_meta/title", + "kind": "value", + "expected": "加载图像", + "actual": "LoadImage" + }, + { + "path": "/22/_meta/title", + "kind": "value", + "expected": "预览图像", + "actual": "PreviewImage" + }, + { + "path": "/28/_meta/title", + "kind": "value", + "expected": "图像拼接", + "actual": "ImageStitch" + }, + { + "path": "/29/_meta/title", + "kind": "value", + "expected": "图像拼接", + "actual": "ImageStitch" + }, + { + "path": "/3/_meta/title", + "kind": "value", + "expected": "预览图像", + "actual": "PreviewImage" + }, + { + "path": "/30/_meta/title", + "kind": "value", + "expected": "图像拼接", + "actual": "ImageStitch" + }, + { + "path": "/36/_meta/title", + "kind": "value", + "expected": "预览图像", + "actual": "PreviewImage" + }, + { + "path": "/37/_meta/title", + "kind": "value", + "expected": "预览图像", + "actual": "PreviewImage" + }, + { + "path": "/38/_meta/title", + "kind": "value", + "expected": "加载图像", + "actual": "LoadImage" + }, + { + "path": "/5/_meta/title", + "kind": "value", + "expected": "预览图像", + "actual": "PreviewImage" + } + ], + "whole_prompt_issues": [], + "production_prompt_available": false, + "serialized_fields": [ + { + "node_id": "4", + "field": "ckpt_name", + "source_reference": "depth_anything_vitl14.pth", + "api": "depth_anything_vitl14.pth", + "differences": [] + }, + { + "node_id": "4", + "field": "resolution", + "source_reference": 512, + "api": 512, + "differences": [] + }, + { + "node_id": "12", + "field": "preprocessor", + "source_reference": "CannyEdgePreprocessor", + "api": "CannyEdgePreprocessor", + "differences": [] + }, + { + "node_id": "12", + "field": "resolution", + "source_reference": 1024, + "api": 1024, + "differences": [] + }, + { + "node_id": "1", + "field": "preprocessor", + "source_reference": "DepthAnythingPreprocessor", + "api": "DepthAnythingPreprocessor", + "differences": [] + }, + { + "node_id": "1", + "field": "resolution", + "source_reference": 512, + "api": 512, + "differences": [] + }, + { + "node_id": "10", + "field": "low_threshold", + "source_reference": 0.4, + "api": 0.4, + "differences": [] + }, + { + "node_id": "10", + "field": "high_threshold", + "source_reference": 0.8, + "api": 0.8, + "differences": [] + }, + { + "node_id": "30", + "field": "direction", + "source_reference": "down", + "api": "down", + "differences": [] + }, + { + "node_id": "30", + "field": "match_image_size", + "source_reference": true, + "api": true, + "differences": [] + }, + { + "node_id": "30", + "field": "spacing_width", + "source_reference": 2, + "api": 2, + "differences": [] + }, + { + "node_id": "30", + "field": "spacing_color", + "source_reference": "white", + "api": "white", + "differences": [] + }, + { + "node_id": "28", + "field": "direction", + "source_reference": "right", + "api": "right", + "differences": [] + }, + { + "node_id": "28", + "field": "match_image_size", + "source_reference": true, + "api": true, + "differences": [] + }, + { + "node_id": "28", + "field": "spacing_width", + "source_reference": 2, + "api": 2, + "differences": [] + }, + { + "node_id": "28", + "field": "spacing_color", + "source_reference": "white", + "api": "white", + "differences": [] + }, + { + "node_id": "29", + "field": "direction", + "source_reference": "right", + "api": "right", + "differences": [] + }, + { + "node_id": "29", + "field": "match_image_size", + "source_reference": true, + "api": true, + "differences": [] + }, + { + "node_id": "29", + "field": "spacing_width", + "source_reference": 2, + "api": 2, + "differences": [] + }, + { + "node_id": "29", + "field": "spacing_color", + "source_reference": "white", + "api": "white", + "differences": [] + }, + { + "node_id": "18", + "field": "preprocessor", + "source_reference": "AnyLineArtPreprocessor_aux", + "api": "AnyLineArtPreprocessor_aux", + "differences": [] + }, + { + "node_id": "18", + "field": "resolution", + "source_reference": 1024, + "api": 1024, + "differences": [] + }, + { + "node_id": "19", + "field": "preprocessor", + "source_reference": "LineArtPreprocessor", + "api": "LineArtPreprocessor", + "differences": [] + }, + { + "node_id": "19", + "field": "resolution", + "source_reference": 1024, + "api": 1024, + "differences": [] + }, + { + "node_id": "20", + "field": "preprocessor", + "source_reference": "AnimeLineArtPreprocessor", + "api": "AnimeLineArtPreprocessor", + "differences": [] + }, + { + "node_id": "20", + "field": "resolution", + "source_reference": 1024, + "api": 1024, + "differences": [] + }, + { + "node_id": "21", + "field": "preprocessor", + "source_reference": "LineartStandardPreprocessor", + "api": "LineartStandardPreprocessor", + "differences": [] + }, + { + "node_id": "21", + "field": "resolution", + "source_reference": 1024, + "api": 1024, + "differences": [] + }, + { + "node_id": "2", + "field": "image", + "source_reference": "comfyui-airport-editorial_00001_.png", + "api": "comfyui-airport-editorial_00001_.png", + "differences": [] + }, + { + "node_id": "38", + "field": "image", + "source_reference": "1772086821573.png", + "api": "1772086821573.png", + "differences": [] + }, + { + "node_id": "33", + "field": "preprocessor", + "source_reference": "DWPreprocessor", + "api": "DWPreprocessor", + "differences": [] + }, + { + "node_id": "33", + "field": "resolution", + "source_reference": 1024, + "api": 1024, + "differences": [] + }, + { + "node_id": "34", + "field": "preprocessor", + "source_reference": "AnimalPosePreprocessor", + "api": "AnimalPosePreprocessor", + "differences": [] + }, + { + "node_id": "34", + "field": "resolution", + "source_reference": 1024, + "api": 1024, + "differences": [] + } + ], + "topology_edges": [ + { + "node_id": "4", + "input": "image", + "via_reroute": true, + "source_reference": [ + "2", + 0 + ], + "api": [ + "2", + 0 + ], + "differences": [] + }, + { + "node_id": "5", + "input": "images", + "via_reroute": false, + "source_reference": [ + "4", + 0 + ], + "api": [ + "4", + 0 + ], + "differences": [] + }, + { + "node_id": "3", + "input": "images", + "via_reroute": false, + "source_reference": [ + "1", + 0 + ], + "api": [ + "1", + 0 + ], + "differences": [] + }, + { + "node_id": "13", + "input": "images", + "via_reroute": false, + "source_reference": [ + "12", + 0 + ], + "api": [ + "12", + 0 + ], + "differences": [] + }, + { + "node_id": "12", + "input": "image", + "via_reroute": true, + "source_reference": [ + "2", + 0 + ], + "api": [ + "2", + 0 + ], + "differences": [] + }, + { + "node_id": "1", + "input": "image", + "via_reroute": true, + "source_reference": [ + "2", + 0 + ], + "api": [ + "2", + 0 + ], + "differences": [] + }, + { + "node_id": "10", + "input": "image", + "via_reroute": true, + "source_reference": [ + "2", + 0 + ], + "api": [ + "2", + 0 + ], + "differences": [] + }, + { + "node_id": "11", + "input": "images", + "via_reroute": false, + "source_reference": [ + "10", + 0 + ], + "api": [ + "10", + 0 + ], + "differences": [] + }, + { + "node_id": "30", + "input": "image1", + "via_reroute": false, + "source_reference": [ + "28", + 0 + ], + "api": [ + "28", + 0 + ], + "differences": [] + }, + { + "node_id": "30", + "input": "image2", + "via_reroute": false, + "source_reference": [ + "29", + 0 + ], + "api": [ + "29", + 0 + ], + "differences": [] + }, + { + "node_id": "28", + "input": "image1", + "via_reroute": false, + "source_reference": [ + "18", + 0 + ], + "api": [ + "18", + 0 + ], + "differences": [] + }, + { + "node_id": "28", + "input": "image2", + "via_reroute": false, + "source_reference": [ + "19", + 0 + ], + "api": [ + "19", + 0 + ], + "differences": [] + }, + { + "node_id": "29", + "input": "image1", + "via_reroute": false, + "source_reference": [ + "20", + 0 + ], + "api": [ + "20", + 0 + ], + "differences": [] + }, + { + "node_id": "29", + "input": "image2", + "via_reroute": false, + "source_reference": [ + "21", + 0 + ], + "api": [ + "21", + 0 + ], + "differences": [] + }, + { + "node_id": "18", + "input": "image", + "via_reroute": true, + "source_reference": [ + "2", + 0 + ], + "api": [ + "2", + 0 + ], + "differences": [] + }, + { + "node_id": "19", + "input": "image", + "via_reroute": true, + "source_reference": [ + "2", + 0 + ], + "api": [ + "2", + 0 + ], + "differences": [] + }, + { + "node_id": "20", + "input": "image", + "via_reroute": true, + "source_reference": [ + "2", + 0 + ], + "api": [ + "2", + 0 + ], + "differences": [] + }, + { + "node_id": "22", + "input": "images", + "via_reroute": false, + "source_reference": [ + "30", + 0 + ], + "api": [ + "30", + 0 + ], + "differences": [] + }, + { + "node_id": "21", + "input": "image", + "via_reroute": true, + "source_reference": [ + "2", + 0 + ], + "api": [ + "2", + 0 + ], + "differences": [] + }, + { + "node_id": "36", + "input": "images", + "via_reroute": false, + "source_reference": [ + "33", + 0 + ], + "api": [ + "33", + 0 + ], + "differences": [] + }, + { + "node_id": "37", + "input": "images", + "via_reroute": false, + "source_reference": [ + "34", + 0 + ], + "api": [ + "34", + 0 + ], + "differences": [] + }, + { + "node_id": "33", + "input": "image", + "via_reroute": true, + "source_reference": [ + "2", + 0 + ], + "api": [ + "2", + 0 + ], + "differences": [] + }, + { + "node_id": "34", + "input": "image", + "via_reroute": false, + "source_reference": [ + "38", + 0 + ], + "api": [ + "38", + 0 + ], + "differences": [] + } + ], + "unsupported_widget_nodes": [], + "diagnostic_graph": null, + "unresolved_boundaries": [], + "resolved_boundaries": [], + "node_types": [ + { + "node_id": "4", + "source_type": "DepthAnythingPreprocessor", + "api_type": "DepthAnythingPreprocessor", + "differences": [] + }, + { + "node_id": "5", + "source_type": "PreviewImage", + "api_type": "PreviewImage", + "differences": [] + }, + { + "node_id": "3", + "source_type": "PreviewImage", + "api_type": "PreviewImage", + "differences": [] + }, + { + "node_id": "13", + "source_type": "PreviewImage", + "api_type": "PreviewImage", + "differences": [] + }, + { + "node_id": "12", + "source_type": "AIO_Preprocessor", + "api_type": "AIO_Preprocessor", + "differences": [] + }, + { + "node_id": "1", + "source_type": "AIO_Preprocessor", + "api_type": "AIO_Preprocessor", + "differences": [] + }, + { + "node_id": "10", + "source_type": "Canny", + "api_type": "Canny", + "differences": [] + }, + { + "node_id": "11", + "source_type": "PreviewImage", + "api_type": "PreviewImage", + "differences": [] + }, + { + "node_id": "30", + "source_type": "ImageStitch", + "api_type": "ImageStitch", + "differences": [] + }, + { + "node_id": "28", + "source_type": "ImageStitch", + "api_type": "ImageStitch", + "differences": [] + }, + { + "node_id": "29", + "source_type": "ImageStitch", + "api_type": "ImageStitch", + "differences": [] + }, + { + "node_id": "18", + "source_type": "AIO_Preprocessor", + "api_type": "AIO_Preprocessor", + "differences": [] + }, + { + "node_id": "19", + "source_type": "AIO_Preprocessor", + "api_type": "AIO_Preprocessor", + "differences": [] + }, + { + "node_id": "20", + "source_type": "AIO_Preprocessor", + "api_type": "AIO_Preprocessor", + "differences": [] + }, + { + "node_id": "22", + "source_type": "PreviewImage", + "api_type": "PreviewImage", + "differences": [] + }, + { + "node_id": "21", + "source_type": "AIO_Preprocessor", + "api_type": "AIO_Preprocessor", + "differences": [] + }, + { + "node_id": "2", + "source_type": "LoadImage", + "api_type": "LoadImage", + "differences": [] + }, + { + "node_id": "36", + "source_type": "PreviewImage", + "api_type": "PreviewImage", + "differences": [] + }, + { + "node_id": "38", + "source_type": "LoadImage", + "api_type": "LoadImage", + "differences": [] + }, + { + "node_id": "37", + "source_type": "PreviewImage", + "api_type": "PreviewImage", + "differences": [] + }, + { + "node_id": "33", + "source_type": "AIO_Preprocessor", + "api_type": "AIO_Preprocessor", + "differences": [] + }, + { + "node_id": "34", + "source_type": "AIO_Preprocessor", + "api_type": "AIO_Preprocessor", + "differences": [] + } + ], + "metadata": [ + { + "node_id": "4", + "differences": [] + }, + { + "node_id": "5", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "预览图像", + "actual": "PreviewImage" + } + ] + }, + { + "node_id": "3", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "预览图像", + "actual": "PreviewImage" + } + ] + }, + { + "node_id": "13", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "预览图像", + "actual": "PreviewImage" + } + ] + }, + { + "node_id": "12", + "differences": [] + }, + { + "node_id": "1", + "differences": [] + }, + { + "node_id": "10", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "Canny边缘检测", + "actual": "Canny" + } + ] + }, + { + "node_id": "11", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "预览图像", + "actual": "PreviewImage" + } + ] + }, + { + "node_id": "30", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "图像拼接", + "actual": "ImageStitch" + } + ] + }, + { + "node_id": "28", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "图像拼接", + "actual": "ImageStitch" + } + ] + }, + { + "node_id": "29", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "图像拼接", + "actual": "ImageStitch" + } + ] + }, + { + "node_id": "18", + "differences": [] + }, + { + "node_id": "19", + "differences": [] + }, + { + "node_id": "20", + "differences": [] + }, + { + "node_id": "22", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "预览图像", + "actual": "PreviewImage" + } + ] + }, + { + "node_id": "21", + "differences": [] + }, + { + "node_id": "2", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "加载图像", + "actual": "LoadImage" + } + ] + }, + { + "node_id": "36", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "预览图像", + "actual": "PreviewImage" + } + ] + }, + { + "node_id": "38", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "加载图像", + "actual": "LoadImage" + } + ] + }, + { + "node_id": "37", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "预览图像", + "actual": "PreviewImage" + } + ] + }, + { + "node_id": "33", + "differences": [] + }, + { + "node_id": "34", + "differences": [] + } + ], + "api_only_fields_for_supported_nodes": [], + "comparison_is_complete": true, + "executable": false, + "execution_verified": false + }, + { + "id": "02", + "selected_profile": "comfy-frontend-1.37.11-preview-reference", + "source_path": "example_ComfyUI_workflows/1-语音生成/Qwen3-ASR-Subtitle语音转字幕.json", + "source_sha256": "47f9afa955a6a5dce37000cb6a15bac7516d26ff50b6398bda334c825552cfd8", + "api_sha256": "daa40971b730076691721afe95e165932df94e3423f1fc44dcb7707026e7125b", + "source_frontend_version": "1.37.11", + "export_frontend_version": null, + "whole_prompt_available": true, + "candidate_prompt": { + "2": { + "class_type": "PreviewAny", + "inputs": { + "preview": "", + "previewMode": null, + "source": [ + "9", + 1 + ] + }, + "_meta": { + "title": "PreviewAny" + } + }, + "4": { + "class_type": "PreviewAny", + "inputs": { + "preview": "", + "previewMode": null, + "source": [ + "9", + 0 + ] + }, + "_meta": { + "title": "PreviewAny" + } + }, + "3": { + "class_type": "PreviewAny", + "inputs": { + "preview": "", + "previewMode": null, + "source": [ + "9", + 2 + ] + }, + "_meta": { + "title": "PreviewAny" + } + }, + "1": { + "class_type": "PreviewAny", + "inputs": { + "preview": "", + "previewMode": null, + "source": [ + "9", + 3 + ] + }, + "_meta": { + "title": "PreviewAny" + } + }, + "6": { + "class_type": "LoadAudio", + "inputs": { + "audio": "ComfyUI-qwenasr_00003_.mp3", + "audioUI": "" + }, + "_meta": { + "title": "LoadAudio" + } + }, + "9": { + "class_type": "AILab_Qwen3ASRSubtitle", + "inputs": { + "model": "Qwen/Qwen3-ASR-0.6B", + "precision": "bf16", + "attention": "auto", + "forced_aligner": "Qwen/Qwen3-ForcedAligner-0.6B", + "language": "auto", + "hints": "Important terms: ComfyUI, Qwen3-ASR\nUse exact casing for these terms.", + "output_format": "none", + "output_path": "", + "split_mode": "split_by_punctuation_or_pause_or_length", + "max_gap_sec": 0.6, + "max_chars": 40, + "max_inference_batch_size": 32, + "max_new_tokens": 256, + "unload_models": true, + "audio": [ + "6", + 0 + ] + }, + "_meta": { + "title": "AILab_Qwen3ASRSubtitle" + } + } + }, + "whole_prompt_differences": [ + { + "path": "/1/_meta/title", + "kind": "value", + "expected": "预览任意", + "actual": "PreviewAny" + }, + { + "path": "/1/inputs/preview", + "kind": "missing_key", + "expected_present": false, + "actual_present": true, + "expected": null, + "actual": "" + }, + { + "path": "/1/inputs/previewMode", + "kind": "missing_key", + "expected_present": false, + "actual_present": true, + "expected": null, + "actual": null + }, + { + "path": "/2/_meta/title", + "kind": "value", + "expected": "预览任意", + "actual": "PreviewAny" + }, + { + "path": "/2/inputs/preview", + "kind": "missing_key", + "expected_present": false, + "actual_present": true, + "expected": null, + "actual": "" + }, + { + "path": "/2/inputs/previewMode", + "kind": "missing_key", + "expected_present": false, + "actual_present": true, + "expected": null, + "actual": null + }, + { + "path": "/3/_meta/title", + "kind": "value", + "expected": "预览任意", + "actual": "PreviewAny" + }, + { + "path": "/3/inputs/preview", + "kind": "missing_key", + "expected_present": false, + "actual_present": true, + "expected": null, + "actual": "" + }, + { + "path": "/3/inputs/previewMode", + "kind": "missing_key", + "expected_present": false, + "actual_present": true, + "expected": null, + "actual": null + }, + { + "path": "/4/_meta/title", + "kind": "value", + "expected": "预览任意", + "actual": "PreviewAny" + }, + { + "path": "/4/inputs/preview", + "kind": "missing_key", + "expected_present": false, + "actual_present": true, + "expected": null, + "actual": "" + }, + { + "path": "/4/inputs/previewMode", + "kind": "missing_key", + "expected_present": false, + "actual_present": true, + "expected": null, + "actual": null + }, + { + "path": "/6/_meta/title", + "kind": "value", + "expected": "加载音频", + "actual": "LoadAudio" + }, + { + "path": "/6/inputs/audioUI", + "kind": "missing_key", + "expected_present": false, + "actual_present": true, + "expected": null, + "actual": "" + }, + { + "path": "/9/_meta/title", + "kind": "value", + "expected": "Subtitle (QwenASR)", + "actual": "AILab_Qwen3ASRSubtitle" + }, + { + "path": "/9/inputs/normalize_text", + "kind": "missing_key", + "expected_present": true, + "actual_present": false, + "expected": true, + "actual": null + } + ], + "whole_prompt_issues": [], + "production_prompt_available": false, + "serialized_fields": [ + { + "node_id": "2", + "field": "preview", + "source_reference": "", + "api": null, + "differences": [ + { + "path": "/preview", + "kind": "missing_key", + "expected_present": false, + "actual_present": true, + "expected": null, + "actual": "" + } + ] + }, + { + "node_id": "2", + "field": "previewMode", + "source_reference": null, + "api": null, + "differences": [ + { + "path": "/previewMode", + "kind": "missing_key", + "expected_present": false, + "actual_present": true, + "expected": null, + "actual": null + } + ] + }, + { + "node_id": "4", + "field": "preview", + "source_reference": "", + "api": null, + "differences": [ + { + "path": "/preview", + "kind": "missing_key", + "expected_present": false, + "actual_present": true, + "expected": null, + "actual": "" + } + ] + }, + { + "node_id": "4", + "field": "previewMode", + "source_reference": null, + "api": null, + "differences": [ + { + "path": "/previewMode", + "kind": "missing_key", + "expected_present": false, + "actual_present": true, + "expected": null, + "actual": null + } + ] + }, + { + "node_id": "3", + "field": "preview", + "source_reference": "", + "api": null, + "differences": [ + { + "path": "/preview", + "kind": "missing_key", + "expected_present": false, + "actual_present": true, + "expected": null, + "actual": "" + } + ] + }, + { + "node_id": "3", + "field": "previewMode", + "source_reference": null, + "api": null, + "differences": [ + { + "path": "/previewMode", + "kind": "missing_key", + "expected_present": false, + "actual_present": true, + "expected": null, + "actual": null + } + ] + }, + { + "node_id": "1", + "field": "preview", + "source_reference": "", + "api": null, + "differences": [ + { + "path": "/preview", + "kind": "missing_key", + "expected_present": false, + "actual_present": true, + "expected": null, + "actual": "" + } + ] + }, + { + "node_id": "1", + "field": "previewMode", + "source_reference": null, + "api": null, + "differences": [ + { + "path": "/previewMode", + "kind": "missing_key", + "expected_present": false, + "actual_present": true, + "expected": null, + "actual": null + } + ] + }, + { + "node_id": "6", + "field": "audio", + "source_reference": "ComfyUI-qwenasr_00003_.mp3", + "api": "ComfyUI-qwenasr_00003_.mp3", + "differences": [] + }, + { + "node_id": "6", + "field": "audioUI", + "source_reference": "", + "api": null, + "differences": [ + { + "path": "/audioUI", + "kind": "missing_key", + "expected_present": false, + "actual_present": true, + "expected": null, + "actual": "" + } + ] + }, + { + "node_id": "9", + "field": "model", + "source_reference": "Qwen/Qwen3-ASR-0.6B", + "api": "Qwen/Qwen3-ASR-0.6B", + "differences": [] + }, + { + "node_id": "9", + "field": "precision", + "source_reference": "bf16", + "api": "bf16", + "differences": [] + }, + { + "node_id": "9", + "field": "attention", + "source_reference": "auto", + "api": "auto", + "differences": [] + }, + { + "node_id": "9", + "field": "forced_aligner", + "source_reference": "Qwen/Qwen3-ForcedAligner-0.6B", + "api": "Qwen/Qwen3-ForcedAligner-0.6B", + "differences": [] + }, + { + "node_id": "9", + "field": "language", + "source_reference": "auto", + "api": "auto", + "differences": [] + }, + { + "node_id": "9", + "field": "hints", + "source_reference": "Important terms: ComfyUI, Qwen3-ASR\nUse exact casing for these terms.", + "api": "Important terms: ComfyUI, Qwen3-ASR\nUse exact casing for these terms.", + "differences": [] + }, + { + "node_id": "9", + "field": "output_format", + "source_reference": "none", + "api": "none", + "differences": [] + }, + { + "node_id": "9", + "field": "output_path", + "source_reference": "", + "api": "", + "differences": [] + }, + { + "node_id": "9", + "field": "split_mode", + "source_reference": "split_by_punctuation_or_pause_or_length", + "api": "split_by_punctuation_or_pause_or_length", + "differences": [] + }, + { + "node_id": "9", + "field": "max_gap_sec", + "source_reference": 0.6, + "api": 0.6, + "differences": [] + }, + { + "node_id": "9", + "field": "max_chars", + "source_reference": 40, + "api": 40, + "differences": [] + }, + { + "node_id": "9", + "field": "max_inference_batch_size", + "source_reference": 32, + "api": 32, + "differences": [] + }, + { + "node_id": "9", + "field": "max_new_tokens", + "source_reference": 256, + "api": 256, + "differences": [] + }, + { + "node_id": "9", + "field": "unload_models", + "source_reference": true, + "api": true, + "differences": [] + } + ], + "topology_edges": [ + { + "node_id": "2", + "input": "source", + "via_reroute": false, + "source_reference": [ + "9", + 1 + ], + "api": [ + "9", + 1 + ], + "differences": [] + }, + { + "node_id": "4", + "input": "source", + "via_reroute": false, + "source_reference": [ + "9", + 0 + ], + "api": [ + "9", + 0 + ], + "differences": [] + }, + { + "node_id": "3", + "input": "source", + "via_reroute": false, + "source_reference": [ + "9", + 2 + ], + "api": [ + "9", + 2 + ], + "differences": [] + }, + { + "node_id": "1", + "input": "source", + "via_reroute": false, + "source_reference": [ + "9", + 3 + ], + "api": [ + "9", + 3 + ], + "differences": [] + }, + { + "node_id": "9", + "input": "audio", + "via_reroute": false, + "source_reference": [ + "6", + 0 + ], + "api": [ + "6", + 0 + ], + "differences": [] + } + ], + "unsupported_widget_nodes": [], + "diagnostic_graph": { + "id": "2c8bc9f4-6cdd-4d7e-af2b-773c9c169fe3", + "revision": 0, + "last_node_id": 9, + "last_link_id": 18, + "nodes": [ + { + "id": 2, + "type": "PreviewAny", + "pos": [ + 3410, + 5410 + ], + "size": [ + 370, + 180 + ], + "flags": {}, + "order": 4, + "mode": 0, + "inputs": [ + { + "localized_name": "源", + "name": "source", + "type": "*", + "link": 16 + } + ], + "outputs": [], + "properties": { + "Node name for S&R": "PreviewAny", + "cnr_id": "comfy-core", + "ver": "0.11.0", + "ue_properties": { + "widget_ue_connectable": {}, + "input_ue_unconnectable": {}, + "version": "7.5.2" + } + }, + "widgets_values": [ + null, + null, + null + ] + }, + { + "id": 4, + "type": "PreviewAny", + "pos": [ + 3410, + 5190 + ], + "size": [ + 370, + 180 + ], + "flags": {}, + "order": 3, + "mode": 0, + "inputs": [ + { + "localized_name": "源", + "name": "source", + "type": "*", + "link": 15 + } + ], + "outputs": [], + "properties": { + "Node name for S&R": "PreviewAny", + "cnr_id": "comfy-core", + "ver": "0.11.0", + "ue_properties": { + "widget_ue_connectable": {}, + "input_ue_unconnectable": {}, + "version": "7.5.2" + } + }, + "widgets_values": [ + null, + null, + null + ] + }, + { + "id": 3, + "type": "PreviewAny", + "pos": [ + 3410, + 5630 + ], + "size": [ + 370, + 120 + ], + "flags": {}, + "order": 5, + "mode": 0, + "inputs": [ + { + "localized_name": "源", + "name": "source", + "type": "*", + "link": 17 + } + ], + "outputs": [], + "properties": { + "Node name for S&R": "PreviewAny", + "cnr_id": "comfy-core", + "ver": "0.11.0", + "ue_properties": { + "widget_ue_connectable": {}, + "input_ue_unconnectable": {}, + "version": "7.5.2" + } + }, + "widgets_values": [ + null, + null, + null + ] + }, + { + "id": 1, + "type": "PreviewAny", + "pos": [ + 3410, + 5790 + ], + "size": [ + 370, + 120 + ], + "flags": {}, + "order": 6, + "mode": 0, + "inputs": [ + { + "localized_name": "源", + "name": "source", + "type": "*", + "link": 18 + } + ], + "outputs": [], + "properties": { + "Node name for S&R": "PreviewAny", + "cnr_id": "comfy-core", + "ver": "0.11.0", + "ue_properties": { + "widget_ue_connectable": {}, + "input_ue_unconnectable": {}, + "version": "7.5.2" + } + }, + "widgets_values": [ + null, + null, + null + ] + }, + { + "id": 6, + "type": "LoadAudio", + "pos": [ + 2720, + 5190 + ], + "size": [ + 290, + 140 + ], + "flags": {}, + "order": 1, + "mode": 0, + "inputs": [ + { + "localized_name": "音频", + "name": "audio", + "type": "COMBO", + "widget": { + "name": "audio" + }, + "link": null + }, + { + "localized_name": "音频UI", + "name": "audioUI", + "type": "AUDIO_UI", + "widget": { + "name": "audioUI" + }, + "link": null + }, + { + "localized_name": "选择文件上传", + "name": "upload", + "type": "AUDIOUPLOAD", + "widget": { + "name": "upload" + }, + "link": null + } + ], + "outputs": [ + { + "localized_name": "音频", + "name": "AUDIO", + "type": "AUDIO", + "links": [ + 13 + ] + } + ], + "properties": { + "Node name for S&R": "LoadAudio", + "cnr_id": "comfy-core", + "ver": "0.11.0", + "ue_properties": { + "widget_ue_connectable": {}, + "input_ue_unconnectable": {}, + "version": "7.5.2" + } + }, + "widgets_values": [ + "ComfyUI-qwenasr_00003_.mp3", + null, + null + ] + }, + { + "id": 9, + "type": "AILab_Qwen3ASRSubtitle", + "pos": [ + 3030, + 5190 + ], + "size": [ + 340, + 460 + ], + "flags": {}, + "order": 2, + "mode": 0, + "inputs": [ + { + "localized_name": "audio", + "name": "audio", + "type": "AUDIO", + "link": 13 + }, + { + "localized_name": "model", + "name": "model", + "shape": 7, + "type": "COMBO", + "widget": { + "name": "model" + }, + "link": null + }, + { + "localized_name": "precision", + "name": "precision", + "shape": 7, + "type": "COMBO", + "widget": { + "name": "precision" + }, + "link": null + }, + { + "localized_name": "attention", + "name": "attention", + "shape": 7, + "type": "COMBO", + "widget": { + "name": "attention" + }, + "link": null + }, + { + "localized_name": "forced_aligner", + "name": "forced_aligner", + "shape": 7, + "type": "COMBO", + "widget": { + "name": "forced_aligner" + }, + "link": null + }, + { + "localized_name": "language", + "name": "language", + "shape": 7, + "type": "COMBO", + "widget": { + "name": "language" + }, + "link": null + }, + { + "localized_name": "hints", + "name": "hints", + "shape": 7, + "type": "STRING", + "widget": { + "name": "hints" + }, + "link": null + }, + { + "localized_name": "output_format", + "name": "output_format", + "shape": 7, + "type": "COMBO", + "widget": { + "name": "output_format" + }, + "link": null + }, + { + "localized_name": "output_path", + "name": "output_path", + "shape": 7, + "type": "STRING", + "widget": { + "name": "output_path" + }, + "link": null + }, + { + "localized_name": "split_mode", + "name": "split_mode", + "shape": 7, + "type": "COMBO", + "widget": { + "name": "split_mode" + }, + "link": null + }, + { + "localized_name": "max_gap_sec", + "name": "max_gap_sec", + "shape": 7, + "type": "FLOAT", + "widget": { + "name": "max_gap_sec" + }, + "link": null + }, + { + "localized_name": "max_chars", + "name": "max_chars", + "shape": 7, + "type": "INT", + "widget": { + "name": "max_chars" + }, + "link": null + }, + { + "localized_name": "max_inference_batch_size", + "name": "max_inference_batch_size", + "shape": 7, + "type": "INT", + "widget": { + "name": "max_inference_batch_size" + }, + "link": null + }, + { + "localized_name": "max_new_tokens", + "name": "max_new_tokens", + "shape": 7, + "type": "INT", + "widget": { + "name": "max_new_tokens" + }, + "link": null + }, + { + "localized_name": "unload_models", + "name": "unload_models", + "shape": 7, + "type": "BOOLEAN", + "widget": { + "name": "unload_models" + }, + "link": null + } + ], + "outputs": [ + { + "localized_name": "TEXT", + "name": "TEXT", + "type": "STRING", + "links": [ + 15 + ] + }, + { + "localized_name": "SUBTITLES", + "name": "SUBTITLES", + "type": "STRING", + "links": [ + 16 + ] + }, + { + "localized_name": "LANUGAGE", + "name": "LANUGAGE", + "type": "STRING", + "links": [ + 17 + ] + }, + { + "localized_name": "OUTPUT_PATH", + "name": "OUTPUT_PATH", + "type": "STRING", + "links": [ + 18 + ] + } + ], + "properties": { + "Node name for S&R": "AILab_Qwen3ASRSubtitle", + "ue_properties": { + "widget_ue_connectable": {}, + "input_ue_unconnectable": {}, + "version": "7.8" + } + }, + "widgets_values": [ + "Qwen/Qwen3-ASR-0.6B", + "bf16", + "auto", + "Qwen/Qwen3-ForcedAligner-0.6B", + "auto", + "Important terms: ComfyUI, Qwen3-ASR\nUse exact casing for these terms.", + "none", + "", + "split_by_punctuation_or_pause_or_length", + 0.6, + 40, + 32, + 256, + true + ], + "color": "#151c19", + "bgcolor": "#444d49" + } + ], + "links": [ + [ + 13, + 6, + 0, + 9, + 0, + "AUDIO" + ], + [ + 15, + 9, + 0, + 4, + 0, + "STRING" + ], + [ + 16, + 9, + 1, + 2, + 0, + "STRING" + ], + [ + 17, + 9, + 2, + 3, + 0, + "STRING" + ], + [ + 18, + 9, + 3, + 1, + 0, + "STRING" + ] + ], + "groups": [], + "config": {}, + "extra": { + "workflowRendererVersion": "LG", + "ue_links": [], + "ds": { + "scale": 0.9185064935064935, + "offset": [ + -2204.8250265111346, + -5021.666666666667 + ] + }, + "links_added_by_ue": [], + "frontendVersion": "1.37.11", + "VHS_latentpreview": false, + "VHS_latentpreviewrate": 0, + "VHS_MetadataImage": true, + "VHS_KeepIntermediate": true + }, + "version": 0.4 + }, + "unresolved_boundaries": [], + "resolved_boundaries": [], + "node_types": [ + { + "node_id": "2", + "source_type": "PreviewAny", + "api_type": "PreviewAny", + "differences": [] + }, + { + "node_id": "4", + "source_type": "PreviewAny", + "api_type": "PreviewAny", + "differences": [] + }, + { + "node_id": "3", + "source_type": "PreviewAny", + "api_type": "PreviewAny", + "differences": [] + }, + { + "node_id": "1", + "source_type": "PreviewAny", + "api_type": "PreviewAny", + "differences": [] + }, + { + "node_id": "6", + "source_type": "LoadAudio", + "api_type": "LoadAudio", + "differences": [] + }, + { + "node_id": "9", + "source_type": "AILab_Qwen3ASRSubtitle", + "api_type": "AILab_Qwen3ASRSubtitle", + "differences": [] + } + ], + "metadata": [ + { + "node_id": "2", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "预览任意", + "actual": "PreviewAny" + } + ] + }, + { + "node_id": "4", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "预览任意", + "actual": "PreviewAny" + } + ] + }, + { + "node_id": "3", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "预览任意", + "actual": "PreviewAny" + } + ] + }, + { + "node_id": "1", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "预览任意", + "actual": "PreviewAny" + } + ] + }, + { + "node_id": "6", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "加载音频", + "actual": "LoadAudio" + } + ] + }, + { + "node_id": "9", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "Subtitle (QwenASR)", + "actual": "AILab_Qwen3ASRSubtitle" + } + ] + } + ], + "api_only_fields_for_supported_nodes": [ + { + "node_id": "9", + "field": "normalize_text", + "api_value": true + } + ], + "comparison_is_complete": true, + "executable": false, + "execution_verified": false + }, + { + "id": "03", + "selected_profile": "comfy-frontend-1.48.7-promoted-reference", + "source_path": "example_ComfyUI_workflows/2-音乐生成/minimax_music_文生音乐.json", + "source_sha256": "0a655ead5a0da406159dceb46451439df0c02050becaaa25b3018abb41840284", + "api_sha256": "91e6c2cea3747a03bbb71f661dbd016b28040781482b956365ff76a7a8b647ce", + "source_frontend_version": "1.48.7", + "export_frontend_version": null, + "whole_prompt_available": false, + "candidate_prompt": null, + "whole_prompt_differences": null, + "whole_prompt_issues": [ + { + "code": "promoted_host_unverified", + "node_id": "37", + "message": "首个内部绑定 MiniMaxMusic3TextEncode.caption 无固定构造契约;无法重建host控件顺序" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:SaveAudioAdvanced", + "node_id": "35" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:MiniMaxMusic3TextEncode", + "node_id": "37:13" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:ConditioningZeroOut", + "node_id": "37:10" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:EmptyMiniMaxMusic3LatentAudio", + "node_id": "37:15" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:KSampler", + "node_id": "37:9" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:VAEDecodeAudio", + "node_id": "37:12" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:SeedNode", + "node_id": "37:38" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:VAEDecodeAudioTiled", + "node_id": "37:42" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:ComfySwitchNode", + "node_id": "37:43" + }, + { + "code": "boundary_widget_unverified", + "node_id": "37:6", + "input_slot": 0, + "input_name": "unet_name", + "boundary_instance": "37", + "slot": 4, + "name": "unet_name", + "type": "COMBO", + "reason": "首个内部绑定 MiniMaxMusic3TextEncode.caption 无固定构造契约;无法重建host控件顺序", + "message": "首个内部绑定 MiniMaxMusic3TextEncode.caption 无固定构造契约;无法重建host控件顺序" + }, + { + "code": "boundary_widget_unverified", + "node_id": "37:13", + "input_slot": 1, + "input_name": "caption", + "boundary_instance": "37", + "slot": 0, + "name": "caption", + "type": "STRING", + "reason": "首个内部绑定 MiniMaxMusic3TextEncode.caption 无固定构造契约;无法重建host控件顺序", + "message": "首个内部绑定 MiniMaxMusic3TextEncode.caption 无固定构造契约;无法重建host控件顺序" + }, + { + "code": "boundary_widget_unverified", + "node_id": "37:13", + "input_slot": 2, + "input_name": "lyrics", + "boundary_instance": "37", + "slot": 1, + "name": "lyrics", + "type": "STRING", + "reason": "首个内部绑定 MiniMaxMusic3TextEncode.caption 无固定构造契约;无法重建host控件顺序", + "message": "首个内部绑定 MiniMaxMusic3TextEncode.caption 无固定构造契约;无法重建host控件顺序" + }, + { + "code": "boundary_widget_unverified", + "node_id": "37:13", + "input_slot": 4, + "input_name": "max_duration", + "boundary_instance": "37", + "slot": 2, + "name": "max_duration", + "type": "FLOAT", + "reason": "首个内部绑定 MiniMaxMusic3TextEncode.caption 无固定构造契约;无法重建host控件顺序", + "message": "首个内部绑定 MiniMaxMusic3TextEncode.caption 无固定构造契约;无法重建host控件顺序" + }, + { + "code": "boundary_widget_unverified", + "node_id": "37:3", + "input_slot": 0, + "input_name": "clip_name", + "boundary_instance": "37", + "slot": 5, + "name": "clip_name", + "type": "COMBO", + "reason": "首个内部绑定 MiniMaxMusic3TextEncode.caption 无固定构造契约;无法重建host控件顺序", + "message": "首个内部绑定 MiniMaxMusic3TextEncode.caption 无固定构造契约;无法重建host控件顺序" + }, + { + "code": "boundary_widget_unverified", + "node_id": "37:7", + "input_slot": 0, + "input_name": "vae_name", + "boundary_instance": "37", + "slot": 6, + "name": "vae_name", + "type": "COMBO", + "reason": "首个内部绑定 MiniMaxMusic3TextEncode.caption 无固定构造契约;无法重建host控件顺序", + "message": "首个内部绑定 MiniMaxMusic3TextEncode.caption 无固定构造契约;无法重建host控件顺序" + }, + { + "code": "boundary_widget_unverified", + "node_id": "37:38", + "input_slot": 0, + "input_name": "seed", + "boundary_instance": "37", + "slot": 3, + "name": "seed", + "type": "INT", + "reason": "首个内部绑定 MiniMaxMusic3TextEncode.caption 无固定构造契约;无法重建host控件顺序", + "message": "首个内部绑定 MiniMaxMusic3TextEncode.caption 无固定构造契约;无法重建host控件顺序" + }, + { + "code": "boundary_widget_unverified", + "node_id": "37:43", + "input_slot": 2, + "input_name": "switch", + "boundary_instance": "37", + "slot": 7, + "name": "switch", + "type": "BOOLEAN", + "reason": "首个内部绑定 MiniMaxMusic3TextEncode.caption 无固定构造契约;无法重建host控件顺序", + "message": "首个内部绑定 MiniMaxMusic3TextEncode.caption 无固定构造契约;无法重建host控件顺序" + } + ], + "production_prompt_available": false, + "serialized_fields": [ + { + "node_id": "37:6", + "field": "unet_name", + "source_reference": "minimax_music3_dit_fp16.safetensors", + "api": "MiniMax/minimax_music3_dit_fp16.safetensors", + "differences": [ + { + "path": "", + "kind": "value", + "expected": "MiniMax/minimax_music3_dit_fp16.safetensors", + "actual": "minimax_music3_dit_fp16.safetensors" + } + ] + }, + { + "node_id": "37:6", + "field": "weight_dtype", + "source_reference": "default", + "api": "default", + "differences": [] + }, + { + "node_id": "37:3", + "field": "clip_name", + "source_reference": "minimax_music3_text_encoder_pruned_int8_convrot.safetensors", + "api": "MiniMax/minimax_music3_text_encoder_pruned_int8_convrot.safetensors", + "differences": [ + { + "path": "", + "kind": "value", + "expected": "MiniMax/minimax_music3_text_encoder_pruned_int8_convrot.safetensors", + "actual": "minimax_music3_text_encoder_pruned_int8_convrot.safetensors" + } + ] + }, + { + "node_id": "37:3", + "field": "type", + "source_reference": "minimax", + "api": "minimax", + "differences": [] + }, + { + "node_id": "37:3", + "field": "device", + "source_reference": "default", + "api": "default", + "differences": [] + }, + { + "node_id": "37:7", + "field": "vae_name", + "source_reference": "minimax_music3_dav.safetensors", + "api": "MiniMax/minimax_music3_dav.safetensors", + "differences": [ + { + "path": "", + "kind": "value", + "expected": "MiniMax/minimax_music3_dav.safetensors", + "actual": "minimax_music3_dav.safetensors" + } + ] + } + ], + "topology_edges": [ + { + "node_id": "35", + "input": "audio", + "via_reroute": false, + "source_reference": [ + "37:43", + 0 + ], + "api": [ + "37:43", + 0 + ], + "differences": [] + }, + { + "node_id": "37:13", + "input": "clip", + "via_reroute": false, + "source_reference": [ + "37:3", + 0 + ], + "api": [ + "37:3", + 0 + ], + "differences": [] + }, + { + "node_id": "37:13", + "input": "seed", + "via_reroute": false, + "source_reference": [ + "37:38", + 0 + ], + "api": [ + "37:38", + 0 + ], + "differences": [] + }, + { + "node_id": "37:10", + "input": "conditioning", + "via_reroute": false, + "source_reference": [ + "37:13", + 0 + ], + "api": [ + "37:13", + 0 + ], + "differences": [] + }, + { + "node_id": "37:15", + "input": "seconds", + "via_reroute": false, + "source_reference": [ + "37:13", + 1 + ], + "api": [ + "37:13", + 1 + ], + "differences": [] + }, + { + "node_id": "37:9", + "input": "model", + "via_reroute": false, + "source_reference": [ + "37:6", + 0 + ], + "api": [ + "37:6", + 0 + ], + "differences": [] + }, + { + "node_id": "37:9", + "input": "positive", + "via_reroute": false, + "source_reference": [ + "37:13", + 0 + ], + "api": [ + "37:13", + 0 + ], + "differences": [] + }, + { + "node_id": "37:9", + "input": "negative", + "via_reroute": false, + "source_reference": [ + "37:10", + 0 + ], + "api": [ + "37:10", + 0 + ], + "differences": [] + }, + { + "node_id": "37:9", + "input": "latent_image", + "via_reroute": false, + "source_reference": [ + "37:15", + 0 + ], + "api": [ + "37:15", + 0 + ], + "differences": [] + }, + { + "node_id": "37:9", + "input": "seed", + "via_reroute": false, + "source_reference": [ + "37:38", + 0 + ], + "api": [ + "37:38", + 0 + ], + "differences": [] + }, + { + "node_id": "37:12", + "input": "samples", + "via_reroute": false, + "source_reference": [ + "37:9", + 0 + ], + "api": [ + "37:9", + 0 + ], + "differences": [] + }, + { + "node_id": "37:12", + "input": "vae", + "via_reroute": false, + "source_reference": [ + "37:7", + 0 + ], + "api": [ + "37:7", + 0 + ], + "differences": [] + }, + { + "node_id": "37:42", + "input": "samples", + "via_reroute": false, + "source_reference": [ + "37:9", + 0 + ], + "api": [ + "37:9", + 0 + ], + "differences": [] + }, + { + "node_id": "37:42", + "input": "vae", + "via_reroute": false, + "source_reference": [ + "37:7", + 0 + ], + "api": [ + "37:7", + 0 + ], + "differences": [] + }, + { + "node_id": "37:43", + "input": "on_false", + "via_reroute": false, + "source_reference": [ + "37:12", + 0 + ], + "api": [ + "37:12", + 0 + ], + "differences": [] + }, + { + "node_id": "37:43", + "input": "on_true", + "via_reroute": false, + "source_reference": [ + "37:42", + 0 + ], + "api": [ + "37:42", + 0 + ], + "differences": [] + } + ], + "unsupported_widget_nodes": [ + { + "node_id": "35", + "type": "SaveAudioAdvanced", + "reason": "未证明完整内部控件构造/序列化布局" + }, + { + "node_id": "37:13", + "type": "MiniMaxMusic3TextEncode", + "reason": "未证明完整内部控件构造/序列化布局" + }, + { + "node_id": "37:10", + "type": "ConditioningZeroOut", + "reason": "未证明完整内部控件构造/序列化布局" + }, + { + "node_id": "37:15", + "type": "EmptyMiniMaxMusic3LatentAudio", + "reason": "未证明完整内部控件构造/序列化布局" + }, + { + "node_id": "37:9", + "type": "KSampler", + "reason": "未证明完整内部控件构造/序列化布局" + }, + { + "node_id": "37:12", + "type": "VAEDecodeAudio", + "reason": "未证明完整内部控件构造/序列化布局" + }, + { + "node_id": "37:38", + "type": "SeedNode", + "reason": "未证明完整内部控件构造/序列化布局" + }, + { + "node_id": "37:42", + "type": "VAEDecodeAudioTiled", + "reason": "未证明完整内部控件构造/序列化布局" + }, + { + "node_id": "37:43", + "type": "ComfySwitchNode", + "reason": "未证明完整内部控件构造/序列化布局" + } + ], + "diagnostic_graph": { + "nodes": [ + { + "id": "35", + "type": "SaveAudioAdvanced", + "pos": [ + 2150, + 630 + ], + "size": [ + 750, + 160 + ], + "flags": {}, + "order": 3, + "mode": 0, + "inputs": [ + { + "localized_name": "audio", + "name": "audio", + "type": "AUDIO", + "link": 1 + }, + { + "localized_name": "filename_prefix", + "name": "filename_prefix", + "type": "STRING", + "widget": { + "name": "filename_prefix" + }, + "link": null + }, + { + "localized_name": "format", + "name": "format", + "type": "COMFY_DYNAMICCOMBO_V3", + "widget": { + "name": "format" + }, + "link": null + }, + { + "localized_name": "format.quality", + "name": "format.quality", + "type": "COMBO", + "widget": { + "name": "format.quality" + }, + "link": null + }, + { + "localized_name": "audioUI", + "name": "audioUI", + "type": "AUDIO_UI", + "widget": { + "name": "audioUI" + }, + "link": null + } + ], + "outputs": [ + { + "localized_name": "audio", + "name": "audio", + "type": "AUDIO", + "links": [] + } + ], + "properties": { + "Node name for S&R": "SaveAudioAdvanced", + "cnr_id": "comfy-core", + "ver": "0.31.0", + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + }, + "widgets_values": [ + "audio/audio_minimax_music3", + "mp3", + "V0" + ], + "widgets_values_named": { + "filename_prefix": "audio/audio_minimax_music3", + "format": "mp3", + "format.quality": "V0" + } + }, + { + "id": "39", + "type": "MarkdownNote", + "pos": [ + 1050, + 630 + ], + "size": [ + 520, + 660 + ], + "flags": {}, + "order": 0, + "mode": 0, + "inputs": [], + "outputs": [], + "title": "Note: MiniMax Music 3", + "properties": { + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + }, + "widgets_values": [ + "## MiniMax Music 3\n\nA music generation model by MiniMax that creates complete songs up to 5 minutes long with stable structure and high audio quality. Two inputs drive it: **Caption** (structured music description: style, mood, vocals, arrangement) and **Lyrics** (with `[intro]` `[verse]` `[chorus]` `[bridge]` `[outro]` tags controlling song structure).\n\n### Parameters\n\n| Parameter | Description |\n|---|---|\n| Caption | Music description. Write it in three sections — Global Metadata → Vocal Details → Arrangement. The more specific, the closer the result. |\n| Lyrics | Song lyrics + section tags. Tags are the only executable structural instructions; the lyric text itself only conveys mood. |\n| max_duration | Target song length in seconds (default 120 = 2 minutes; the model supports up to ~300 s / 5 minutes). Longer songs take more time and VRAM. |\n| seed | Random seed for the generation. Keep it fixed to reproduce the same song; change it to get a different take. |\n| Model files | diffusion model / text encoder / VAE.|\n| Tiled decode | Decode the audio VAE in overlapping tiles to drastically cut VRAM usage — helpful for long songs on low-VRAM GPUs. Slightly slower, with a small risk of seams at tile boundaries; turn it off on high-VRAM GPUs for the best quality. |\n\n### Prompt Writing Guide\n\nYou can find an official [Music Caption Rewriter Skill here](https://github.com/MiniMax-AI/MiniMax-Music3)" + ], + "widgets_values_named": { + "text": "## MiniMax Music 3\n\nA music generation model by MiniMax that creates complete songs up to 5 minutes long with stable structure and high audio quality. Two inputs drive it: **Caption** (structured music description: style, mood, vocals, arrangement) and **Lyrics** (with `[intro]` `[verse]` `[chorus]` `[bridge]` `[outro]` tags controlling song structure).\n\n### Parameters\n\n| Parameter | Description |\n|---|---|\n| Caption | Music description. Write it in three sections — Global Metadata → Vocal Details → Arrangement. The more specific, the closer the result. |\n| Lyrics | Song lyrics + section tags. Tags are the only executable structural instructions; the lyric text itself only conveys mood. |\n| max_duration | Target song length in seconds (default 120 = 2 minutes; the model supports up to ~300 s / 5 minutes). Longer songs take more time and VRAM. |\n| seed | Random seed for the generation. Keep it fixed to reproduce the same song; change it to get a different take. |\n| Model files | diffusion model / text encoder / VAE.|\n| Tiled decode | Decode the audio VAE in overlapping tiles to drastically cut VRAM usage — helpful for long songs on low-VRAM GPUs. Slightly slower, with a small risk of seams at tile boundaries; turn it off on high-VRAM GPUs for the best quality. |\n\n### Prompt Writing Guide\n\nYou can find an official [Music Caption Rewriter Skill here](https://github.com/MiniMax-AI/MiniMax-Music3)" + }, + "color": "#222", + "bgcolor": "#000" + }, + { + "id": "40", + "type": "MarkdownNote", + "pos": [ + 560, + 630 + ], + "size": [ + 440, + 680 + ], + "flags": {}, + "order": 1, + "mode": 0, + "inputs": [], + "outputs": [], + "properties": { + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + }, + "widgets_values": [ + "## Model Links\n\n**diffusion_models**\n- [minimax_music3_dit_int8_convrot.safetensors](https://huggingface.co/Comfy-Org/MiniMax-Music-3/resolve/main/diffusion_models/minimax_music3_dit_int8_convrot.safetensors) # For low VRAM\n- [minimax_music3_dit_fp16.safetensors](https://huggingface.co/Comfy-Org/MiniMax-Music-3/resolve/main/diffusion_models/minimax_music3_dit_fp16.safetensors)\n\n**text_encoders**\n\n- [minimax_music3_text_encoder_pruned_int8_convrot.safetensors](https://huggingface.co/Comfy-Org/MiniMax-Music-3/resolve/main/text_encoders/minimax_music3_text_encoder_pruned_int8_convrot.safetensors)\n\n**vae**\n\n- [minimax_music3_dav.safetensors](https://huggingface.co/Comfy-Org/MiniMax-Music-3/resolve/main/vae/minimax_music3_dav.safetensors)\n\n\n## Model Storage Location\n\n```\n📂 ComfyUI/\n├── 📂 models/\n│ ├── 📂 diffusion_models/\n│ │ ├── minimax_music3_dit_int8_convrot.safetensors # For low VRAM\n│ │ └── minimax_music3_dit_fp16.safetensors\n│ ├── 📂 text_encoders/\n│ │ └── minimax_music3_text_encoder_pruned_int8_convrot.safetensors\n│ └── 📂 vae/\n│ └── minimax_music3_dav.safetensors\n```\n\n## Report Issue\n\nNote: Please update ComfyUI first ([guide](https://docs.comfy.org/installation/update_comfyui)) and prepare required models. Desktop/Cloud updates follow stable releases, so some nightly-supported models may not be available yet.\n\n- Cannot run / runtime errors: [ComfyUI/issues](https://github.com/comfyanonymous/ComfyUI/issues)\n- UI / frontend issues: [ComfyUI_frontend/issues](https://github.com/Comfy-Org/ComfyUI_frontend/issues)\n- Workflow issues: [workflow_templates/issues](https://github.com/Comfy-Org/workflow_templates/issues)\n" + ], + "widgets_values_named": { + "text": "## Model Links\n\n**diffusion_models**\n- [minimax_music3_dit_int8_convrot.safetensors](https://huggingface.co/Comfy-Org/MiniMax-Music-3/resolve/main/diffusion_models/minimax_music3_dit_int8_convrot.safetensors) # For low VRAM\n- [minimax_music3_dit_fp16.safetensors](https://huggingface.co/Comfy-Org/MiniMax-Music-3/resolve/main/diffusion_models/minimax_music3_dit_fp16.safetensors)\n\n**text_encoders**\n\n- [minimax_music3_text_encoder_pruned_int8_convrot.safetensors](https://huggingface.co/Comfy-Org/MiniMax-Music-3/resolve/main/text_encoders/minimax_music3_text_encoder_pruned_int8_convrot.safetensors)\n\n**vae**\n\n- [minimax_music3_dav.safetensors](https://huggingface.co/Comfy-Org/MiniMax-Music-3/resolve/main/vae/minimax_music3_dav.safetensors)\n\n\n## Model Storage Location\n\n```\n📂 ComfyUI/\n├── 📂 models/\n│ ├── 📂 diffusion_models/\n│ │ ├── minimax_music3_dit_int8_convrot.safetensors # For low VRAM\n│ │ └── minimax_music3_dit_fp16.safetensors\n│ ├── 📂 text_encoders/\n│ │ └── minimax_music3_text_encoder_pruned_int8_convrot.safetensors\n│ └── 📂 vae/\n│ └── minimax_music3_dav.safetensors\n```\n\n## Report Issue\n\nNote: Please update ComfyUI first ([guide](https://docs.comfy.org/installation/update_comfyui)) and prepare required models. Desktop/Cloud updates follow stable releases, so some nightly-supported models may not be available yet.\n\n- Cannot run / runtime errors: [ComfyUI/issues](https://github.com/comfyanonymous/ComfyUI/issues)\n- UI / frontend issues: [ComfyUI_frontend/issues](https://github.com/Comfy-Org/ComfyUI_frontend/issues)\n- Workflow issues: [workflow_templates/issues](https://github.com/Comfy-Org/workflow_templates/issues)\n" + }, + "color": "#222", + "bgcolor": "#000" + }, + { + "id": "37:6", + "type": "UNETLoader", + "pos": [ + 700, + 380 + ], + "size": [ + 480, + 90 + ], + "flags": {}, + "order": 1, + "mode": 0, + "showAdvanced": false, + "inputs": [ + { + "localized_name": "UNet名称", + "name": "unet_name", + "type": "COMBO", + "widget": { + "name": "unet_name" + }, + "link": null + }, + { + "localized_name": "数据类型", + "name": "weight_dtype", + "type": "COMBO", + "widget": { + "name": "weight_dtype" + }, + "link": null + } + ], + "outputs": [ + { + "localized_name": "模型", + "name": "MODEL", + "type": "MODEL", + "links": [ + 6 + ] + } + ], + "properties": { + "Node name for S&R": "UNETLoader", + "cnr_id": "comfy-core", + "ver": "0.31.0", + "models": [ + { + "name": "minimax_music3_dit_fp16.safetensors", + "url": "https://huggingface.co/Comfy-Org/MiniMax-Music-3/resolve/main/diffusion_models/minimax_music3_dit_fp16.safetensors", + "directory": "diffusion_models" + } + ], + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + }, + "widgets_values": [ + "minimax_music3_dit_fp16.safetensors", + "default" + ], + "widgets_values_named": { + "unet_name": "minimax_music3_dit_fp16.safetensors", + "weight_dtype": "default" + } + }, + { + "id": "37:13", + "type": "MiniMaxMusic3TextEncode", + "pos": [ + 1230, + 380 + ], + "size": [ + 500, + 750 + ], + "flags": {}, + "order": 6, + "mode": 0, + "showAdvanced": true, + "inputs": [ + { + "localized_name": "clip", + "name": "clip", + "type": "CLIP", + "link": 2 + }, + { + "localized_name": "caption", + "name": "caption", + "type": "STRING", + "widget": { + "name": "caption" + }, + "link": null + }, + { + "localized_name": "lyrics", + "name": "lyrics", + "type": "STRING", + "widget": { + "name": "lyrics" + }, + "link": null + }, + { + "localized_name": "seed", + "name": "seed", + "type": "INT", + "widget": { + "name": "seed" + }, + "link": 3 + }, + { + "localized_name": "max_duration", + "name": "max_duration", + "type": "FLOAT", + "widget": { + "name": "max_duration" + }, + "link": null + }, + { + "localized_name": "cfg_scale", + "name": "cfg_scale", + "type": "FLOAT", + "widget": { + "name": "cfg_scale" + }, + "link": null + }, + { + "localized_name": "top_k", + "name": "top_k", + "type": "INT", + "widget": { + "name": "top_k" + }, + "link": null + } + ], + "outputs": [ + { + "localized_name": "条件", + "name": "CONDITIONING", + "type": "CONDITIONING", + "links": [ + 4, + 7 + ] + }, + { + "localized_name": "seconds", + "name": "seconds", + "type": "FLOAT", + "links": [ + 5 + ] + } + ], + "properties": { + "Node name for S&R": "MiniMaxMusic3TextEncode", + "cnr_id": "comfy-core", + "ver": "0.31.0", + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + }, + "widgets_values": [ + "", + "", + 222, + "fixed", + 60, + 1.7, + 50 + ], + "widgets_values_named": { + "caption": "", + "lyrics": "", + "seed": 222, + "control_after_generate": "fixed", + "max_duration": 60, + "cfg_scale": 1.7, + "top_k": 50 + } + }, + { + "id": "37:3", + "type": "CLIPLoader", + "pos": [ + 700, + 550 + ], + "size": [ + 480, + 120 + ], + "flags": {}, + "order": 0, + "mode": 0, + "inputs": [ + { + "localized_name": "CLIP名称", + "name": "clip_name", + "type": "COMBO", + "widget": { + "name": "clip_name" + }, + "link": null + }, + { + "localized_name": "类型", + "name": "type", + "type": "COMBO", + "widget": { + "name": "type" + }, + "link": null + }, + { + "localized_name": "设备", + "name": "device", + "shape": 7, + "type": "COMBO", + "widget": { + "name": "device" + }, + "link": null + } + ], + "outputs": [ + { + "localized_name": "CLIP", + "name": "CLIP", + "type": "CLIP", + "links": [ + 2 + ] + } + ], + "properties": { + "Node name for S&R": "CLIPLoader", + "cnr_id": "comfy-core", + "ver": "0.31.0", + "models": [ + { + "name": "minimax_music3_text_encoder_pruned_int8_convrot.safetensors", + "url": "https://huggingface.co/Comfy-Org/MiniMax-Music-3/resolve/main/text_encoders/minimax_music3_text_encoder_pruned_int8_convrot.safetensors", + "directory": "text_encoders" + } + ], + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + }, + "widgets_values": [ + "minimax_music3_text_encoder_pruned_int8_convrot.safetensors", + "minimax", + "default" + ], + "widgets_values_named": { + "clip_name": "minimax_music3_text_encoder_pruned_int8_convrot.safetensors", + "type": "minimax", + "device": "default" + } + }, + { + "id": "37:7", + "type": "VAELoader", + "pos": [ + 700, + 750 + ], + "size": [ + 480, + 70 + ], + "flags": {}, + "order": 2, + "mode": 0, + "inputs": [ + { + "localized_name": "vae名称", + "name": "vae_name", + "type": "COMBO", + "widget": { + "name": "vae_name" + }, + "link": null + } + ], + "outputs": [ + { + "localized_name": "VAE", + "name": "VAE", + "type": "VAE", + "links": [ + 12, + 14 + ] + } + ], + "properties": { + "Node name for S&R": "VAELoader", + "cnr_id": "comfy-core", + "ver": "0.31.0", + "models": [ + { + "name": "minimax_music3_dav.safetensors", + "url": "https://huggingface.co/Comfy-Org/MiniMax-Music-3/resolve/main/vae/minimax_music3_dav.safetensors", + "directory": "vae" + } + ], + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + }, + "widgets_values": [ + "minimax_music3_dav.safetensors" + ], + "widgets_values_named": { + "vae_name": "minimax_music3_dav.safetensors" + } + }, + { + "id": "37:10", + "type": "ConditioningZeroOut", + "pos": [ + 1820, + 540 + ], + "size": [ + 230, + 40 + ], + "flags": {}, + "order": 4, + "mode": 0, + "inputs": [ + { + "localized_name": "条件", + "name": "conditioning", + "type": "CONDITIONING", + "link": 4 + } + ], + "outputs": [ + { + "localized_name": "条件", + "name": "CONDITIONING", + "type": "CONDITIONING", + "links": [ + 8 + ] + } + ], + "properties": { + "Node name for S&R": "ConditioningZeroOut", + "cnr_id": "comfy-core", + "ver": "0.31.0", + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + } + }, + { + "id": "37:15", + "type": "EmptyMiniMaxMusic3LatentAudio", + "pos": [ + 1780, + 380 + ], + "size": [ + 350, + 90 + ], + "flags": {}, + "order": 7, + "mode": 0, + "inputs": [ + { + "localized_name": "seconds", + "name": "seconds", + "type": "FLOAT", + "widget": { + "name": "seconds" + }, + "link": 5 + }, + { + "localized_name": "batch_size", + "name": "batch_size", + "type": "INT", + "widget": { + "name": "batch_size" + }, + "link": null + } + ], + "outputs": [ + { + "localized_name": "Latent", + "name": "LATENT", + "type": "LATENT", + "links": [ + 9 + ] + } + ], + "properties": { + "Node name for S&R": "EmptyMiniMaxMusic3LatentAudio", + "cnr_id": "comfy-core", + "ver": "0.31.0", + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + }, + "widgets_values": [ + 120, + 1 + ], + "widgets_values_named": { + "seconds": 120, + "batch_size": 1 + } + }, + { + "id": "37:9", + "type": "KSampler", + "pos": [ + 2170, + 380 + ], + "size": [ + 370, + 270 + ], + "flags": {}, + "order": 3, + "mode": 0, + "inputs": [ + { + "localized_name": "模型", + "name": "model", + "type": "MODEL", + "link": 6 + }, + { + "localized_name": "正面条件", + "name": "positive", + "type": "CONDITIONING", + "link": 7 + }, + { + "localized_name": "负面条件", + "name": "negative", + "type": "CONDITIONING", + "link": 8 + }, + { + "localized_name": "Latent图像", + "name": "latent_image", + "type": "LATENT", + "link": 9 + }, + { + "localized_name": "种子", + "name": "seed", + "type": "INT", + "widget": { + "name": "seed" + }, + "link": 10 + }, + { + "localized_name": "步数", + "name": "steps", + "type": "INT", + "widget": { + "name": "steps" + }, + "link": null + }, + { + "localized_name": "cfg", + "name": "cfg", + "type": "FLOAT", + "widget": { + "name": "cfg" + }, + "link": null + }, + { + "localized_name": "采样器名称", + "name": "sampler_name", + "type": "COMBO", + "widget": { + "name": "sampler_name" + }, + "link": null + }, + { + "localized_name": "调度器", + "name": "scheduler", + "type": "COMBO", + "widget": { + "name": "scheduler" + }, + "link": null + }, + { + "localized_name": "降噪", + "name": "denoise", + "type": "FLOAT", + "widget": { + "name": "denoise" + }, + "link": null + } + ], + "outputs": [ + { + "localized_name": "Latent", + "name": "LATENT", + "type": "LATENT", + "links": [ + 11, + 13 + ] + } + ], + "properties": { + "Node name for S&R": "KSampler", + "cnr_id": "comfy-core", + "ver": "0.31.0", + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + }, + "widgets_values": [ + 1111111112, + "fixed", + 30, + 1.7, + "euler", + "simple", + 1 + ], + "widgets_values_named": { + "seed": 1111111112, + "control_after_generate": "fixed", + "steps": 30, + "cfg": 1.7, + "sampler_name": "euler", + "scheduler": "simple", + "denoise": 1 + } + }, + { + "id": "37:12", + "type": "VAEDecodeAudio", + "pos": [ + 2590, + 380 + ], + "size": [ + 230, + 60 + ], + "flags": {}, + "order": 5, + "mode": 0, + "inputs": [ + { + "localized_name": "Latent", + "name": "samples", + "type": "LATENT", + "link": 11 + }, + { + "localized_name": "vae", + "name": "vae", + "type": "VAE", + "link": 12 + } + ], + "outputs": [ + { + "localized_name": "音频", + "name": "AUDIO", + "type": "AUDIO", + "links": [ + 15 + ] + } + ], + "properties": { + "Node name for S&R": "VAEDecodeAudio", + "cnr_id": "comfy-core", + "ver": "0.31.0", + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + } + }, + { + "id": "37:38", + "type": "SeedNode", + "pos": [ + 890, + 970 + ], + "size": [ + 270, + 90 + ], + "flags": {}, + "order": 8, + "mode": 0, + "inputs": [ + { + "localized_name": "种子", + "name": "seed", + "type": "INT", + "widget": { + "name": "seed" + }, + "link": null + } + ], + "outputs": [ + { + "localized_name": "种子", + "name": "seed", + "type": "INT", + "links": [ + 3, + 10 + ] + } + ], + "properties": { + "Node name for S&R": "SeedNode", + "cnr_id": "comfy-core", + "ver": "0.31.0", + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + }, + "widgets_values": [ + 0, + "randomize" + ], + "widgets_values_named": { + "seed": 0, + "fixed": "randomize" + } + }, + { + "id": "37:42", + "type": "VAEDecodeAudioTiled", + "pos": [ + 2580, + 500 + ], + "size": [ + 280, + 110 + ], + "flags": {}, + "order": 9, + "mode": 0, + "inputs": [ + { + "localized_name": "样本", + "name": "samples", + "type": "LATENT", + "link": 13 + }, + { + "localized_name": "vae", + "name": "vae", + "type": "VAE", + "link": 14 + }, + { + "localized_name": "分块大小", + "name": "tile_size", + "type": "INT", + "widget": { + "name": "tile_size" + }, + "link": null + }, + { + "localized_name": "重叠", + "name": "overlap", + "type": "INT", + "widget": { + "name": "overlap" + }, + "link": null + } + ], + "outputs": [ + { + "localized_name": "音频", + "name": "AUDIO", + "type": "AUDIO", + "links": [ + 16 + ] + } + ], + "properties": { + "Node name for S&R": "VAEDecodeAudioTiled", + "cnr_id": "comfy-core", + "ver": "0.31.0", + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + }, + "widgets_values": [ + 1536, + 64 + ], + "widgets_values_named": { + "tile_size": 1536, + "overlap": 64 + } + }, + { + "id": "37:43", + "type": "ComfySwitchNode", + "pos": [ + 2600, + 690 + ], + "size": [ + 270, + 110 + ], + "flags": {}, + "order": 10, + "mode": 0, + "inputs": [ + { + "localized_name": "为假时", + "name": "on_false", + "type": "AUDIO", + "link": 15 + }, + { + "localized_name": "为真时", + "name": "on_true", + "type": "AUDIO", + "link": 16 + }, + { + "localized_name": "切换", + "name": "switch", + "type": "BOOLEAN", + "widget": { + "name": "switch" + }, + "link": null + } + ], + "outputs": [ + { + "localized_name": "输出", + "name": "output", + "type": "AUDIO", + "links": [ + 1 + ] + } + ], + "properties": { + "Node name for S&R": "ComfySwitchNode", + "cnr_id": "comfy-core", + "ver": "0.31.0", + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + }, + "widgets_values": [ + false + ], + "widgets_values_named": { + "switch": false + } + } + ], + "links": [ + [ + 1, + "37:43", + 0, + "35", + 0, + "AUDIO" + ], + [ + 2, + "37:3", + 0, + "37:13", + 0, + "CLIP" + ], + [ + 3, + "37:38", + 0, + "37:13", + 3, + "INT" + ], + [ + 4, + "37:13", + 0, + "37:10", + 0, + "CONDITIONING" + ], + [ + 5, + "37:13", + 1, + "37:15", + 0, + "FLOAT" + ], + [ + 6, + "37:6", + 0, + "37:9", + 0, + "MODEL" + ], + [ + 7, + "37:13", + 0, + "37:9", + 1, + "CONDITIONING" + ], + [ + 8, + "37:10", + 0, + "37:9", + 2, + "CONDITIONING" + ], + [ + 9, + "37:15", + 0, + "37:9", + 3, + "LATENT" + ], + [ + 10, + "37:38", + 0, + "37:9", + 4, + "INT" + ], + [ + 11, + "37:9", + 0, + "37:12", + 0, + "LATENT" + ], + [ + 12, + "37:7", + 0, + "37:12", + 1, + "VAE" + ], + [ + 13, + "37:9", + 0, + "37:42", + 0, + "LATENT" + ], + [ + 14, + "37:7", + 0, + "37:42", + 1, + "VAE" + ], + [ + 15, + "37:12", + 0, + "37:43", + 0, + "AUDIO" + ], + [ + 16, + "37:42", + 0, + "37:43", + 1, + "AUDIO" + ] + ], + "extra": { + "ds": { + "scale": 0.9826840677966108, + "offset": [ + -730.5261380305367, + -308.63836113860924 + ] + }, + "frontendVersion": "1.48.7", + "VHS_latentpreview": false, + "VHS_latentpreviewrate": 0, + "VHS_MetadataImage": true, + "VHS_KeepIntermediate": true, + "ue_links": [], + "links_added_by_ue": [] + } + }, + "unresolved_boundaries": [ + { + "node_id": "37:6", + "input_slot": 0, + "input_name": "unet_name", + "boundary_instance": "37", + "slot": 4, + "name": "unet_name", + "type": "COMBO", + "reason": "首个内部绑定 MiniMaxMusic3TextEncode.caption 无固定构造契约;无法重建host控件顺序" + }, + { + "node_id": "37:13", + "input_slot": 1, + "input_name": "caption", + "boundary_instance": "37", + "slot": 0, + "name": "caption", + "type": "STRING", + "reason": "首个内部绑定 MiniMaxMusic3TextEncode.caption 无固定构造契约;无法重建host控件顺序" + }, + { + "node_id": "37:13", + "input_slot": 2, + "input_name": "lyrics", + "boundary_instance": "37", + "slot": 1, + "name": "lyrics", + "type": "STRING", + "reason": "首个内部绑定 MiniMaxMusic3TextEncode.caption 无固定构造契约;无法重建host控件顺序" + }, + { + "node_id": "37:13", + "input_slot": 4, + "input_name": "max_duration", + "boundary_instance": "37", + "slot": 2, + "name": "max_duration", + "type": "FLOAT", + "reason": "首个内部绑定 MiniMaxMusic3TextEncode.caption 无固定构造契约;无法重建host控件顺序" + }, + { + "node_id": "37:3", + "input_slot": 0, + "input_name": "clip_name", + "boundary_instance": "37", + "slot": 5, + "name": "clip_name", + "type": "COMBO", + "reason": "首个内部绑定 MiniMaxMusic3TextEncode.caption 无固定构造契约;无法重建host控件顺序" + }, + { + "node_id": "37:7", + "input_slot": 0, + "input_name": "vae_name", + "boundary_instance": "37", + "slot": 6, + "name": "vae_name", + "type": "COMBO", + "reason": "首个内部绑定 MiniMaxMusic3TextEncode.caption 无固定构造契约;无法重建host控件顺序" + }, + { + "node_id": "37:38", + "input_slot": 0, + "input_name": "seed", + "boundary_instance": "37", + "slot": 3, + "name": "seed", + "type": "INT", + "reason": "首个内部绑定 MiniMaxMusic3TextEncode.caption 无固定构造契约;无法重建host控件顺序" + }, + { + "node_id": "37:43", + "input_slot": 2, + "input_name": "switch", + "boundary_instance": "37", + "slot": 7, + "name": "switch", + "type": "BOOLEAN", + "reason": "首个内部绑定 MiniMaxMusic3TextEncode.caption 无固定构造契约;无法重建host控件顺序" + } + ], + "resolved_boundaries": [], + "node_types": [ + { + "node_id": "35", + "source_type": "SaveAudioAdvanced", + "api_type": "SaveAudioAdvanced", + "differences": [] + }, + { + "node_id": "37:6", + "source_type": "UNETLoader", + "api_type": "UNETLoader", + "differences": [] + }, + { + "node_id": "37:13", + "source_type": "MiniMaxMusic3TextEncode", + "api_type": "MiniMaxMusic3TextEncode", + "differences": [] + }, + { + "node_id": "37:3", + "source_type": "CLIPLoader", + "api_type": "CLIPLoader", + "differences": [] + }, + { + "node_id": "37:7", + "source_type": "VAELoader", + "api_type": "VAELoader", + "differences": [] + }, + { + "node_id": "37:10", + "source_type": "ConditioningZeroOut", + "api_type": "ConditioningZeroOut", + "differences": [] + }, + { + "node_id": "37:15", + "source_type": "EmptyMiniMaxMusic3LatentAudio", + "api_type": "EmptyMiniMaxMusic3LatentAudio", + "differences": [] + }, + { + "node_id": "37:9", + "source_type": "KSampler", + "api_type": "KSampler", + "differences": [] + }, + { + "node_id": "37:12", + "source_type": "VAEDecodeAudio", + "api_type": "VAEDecodeAudio", + "differences": [] + }, + { + "node_id": "37:38", + "source_type": "SeedNode", + "api_type": "SeedNode", + "differences": [] + }, + { + "node_id": "37:42", + "source_type": "VAEDecodeAudioTiled", + "api_type": "VAEDecodeAudioTiled", + "differences": [] + }, + { + "node_id": "37:43", + "source_type": "ComfySwitchNode", + "api_type": "ComfySwitchNode", + "differences": [] + } + ], + "metadata": [ + { + "node_id": "35", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "保存音频(高级)", + "actual": "SaveAudioAdvanced" + } + ] + }, + { + "node_id": "37:6", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "UNet加载器", + "actual": "UNETLoader" + } + ] + }, + { + "node_id": "37:13", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "MiniMax Music3 文本编码", + "actual": "MiniMaxMusic3TextEncode" + } + ] + }, + { + "node_id": "37:3", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "加载CLIP", + "actual": "CLIPLoader" + } + ] + }, + { + "node_id": "37:7", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "加载VAE", + "actual": "VAELoader" + } + ] + }, + { + "node_id": "37:10", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "条件零化", + "actual": "ConditioningZeroOut" + } + ] + }, + { + "node_id": "37:15", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "空 MiniMax Music3 潜空间音频", + "actual": "EmptyMiniMaxMusic3LatentAudio" + } + ] + }, + { + "node_id": "37:9", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "K采样器", + "actual": "KSampler" + } + ] + }, + { + "node_id": "37:12", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "VAE解码(音频)", + "actual": "VAEDecodeAudio" + } + ] + }, + { + "node_id": "37:38", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "种子", + "actual": "SeedNode" + } + ] + }, + { + "node_id": "37:42", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "VAE解码音频(分块)", + "actual": "VAEDecodeAudioTiled" + } + ] + }, + { + "node_id": "37:43", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "切换", + "actual": "ComfySwitchNode" + } + ] + } + ], + "api_only_fields_for_supported_nodes": [], + "comparison_is_complete": false, + "executable": false, + "execution_verified": false + }, + { + "id": "04", + "selected_profile": "comfy-frontend-1.53.6-promoted-reference", + "source_path": "example_ComfyUI_workflows/3-图像生成/Qwen-Image-2.1/Qwen_image2.1_文生图_提示词增强.json", + "source_sha256": "dfe10917d101bf1a8a8c20750f4360690ecd478e9eb33d16a59ea0c6f12c086c", + "api_sha256": "2066b07b2ca5390ba3e795df6b43934dab83865b12870b6ff26d8c0ef24f091e", + "source_frontend_version": "1.53.6", + "export_frontend_version": null, + "whole_prompt_available": false, + "candidate_prompt": null, + "whole_prompt_differences": null, + "whole_prompt_issues": [ + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:ResolutionSelector", + "node_id": "13" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:TextEncodeQwenImage21", + "node_id": "459:452" + }, + { + "code": "invalid_output_slot", + "message": "输入 width 的来源槽无法核对", + "node_id": "459:456" + }, + { + "code": "invalid_output_slot", + "message": "输入 height 的来源槽无法核对", + "node_id": "459:456" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:VAEDecode", + "node_id": "459:457" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:KSampler", + "node_id": "459:458" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:TextGenerate", + "node_id": "459:471" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:PreviewAny", + "node_id": "459:472" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:ComfySwitchNode", + "node_id": "459:474" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:SaveImageAdvanced", + "node_id": "461" + }, + { + "code": "boundary_widget_unverified", + "node_id": "459:458", + "input_slot": 4, + "input_name": "seed", + "boundary_instance": "459", + "slot": 10, + "name": "seed", + "type": "INT", + "reason": "多目标控件约束未知或不兼容", + "message": "多目标控件约束未知或不兼容" + }, + { + "code": "boundary_widget_unverified", + "node_id": "459:471", + "input_slot": 13, + "input_name": "sampling_mode.seed", + "boundary_instance": "459", + "slot": 10, + "name": "seed", + "type": "INT", + "reason": "多目标控件约束未知或不兼容", + "message": "多目标控件约束未知或不兼容" + } + ], + "production_prompt_available": false, + "serialized_fields": [ + { + "node_id": "459:451", + "field": "unet_name", + "source_reference": "Qwen-Image\\qwen_image_2.1_bf16.safetensors", + "api": "Qwen-Image/qwen_image_2.1_bf16.safetensors", + "differences": [ + { + "path": "", + "kind": "value", + "expected": "Qwen-Image/qwen_image_2.1_bf16.safetensors", + "actual": "Qwen-Image\\qwen_image_2.1_bf16.safetensors" + } + ] + }, + { + "node_id": "459:451", + "field": "weight_dtype", + "source_reference": "default", + "api": "default", + "differences": [] + }, + { + "node_id": "459:453", + "field": "clip_name", + "source_reference": "qwen3vl_8b_int8_convrot.safetensors", + "api": "qwen3vl_8b_int8_convrot.safetensors", + "differences": [] + }, + { + "node_id": "459:453", + "field": "type", + "source_reference": "qwen_image", + "api": "qwen_image", + "differences": [] + }, + { + "node_id": "459:453", + "field": "device", + "source_reference": "default", + "api": "default", + "differences": [] + }, + { + "node_id": "459:454", + "field": "vae_name", + "source_reference": "qwen_image_2.1_vae_bf16.safetensors", + "api": "qwen_image_2.1_vae_bf16.safetensors", + "differences": [] + }, + { + "node_id": "459:456", + "field": "width", + "source_reference": 1024, + "api": [ + "13", + 0 + ], + "differences": [ + { + "path": "", + "expected": [ + "13", + 0 + ], + "actual": 1024, + "kind": "type" + } + ] + }, + { + "node_id": "459:456", + "field": "height", + "source_reference": 1024, + "api": [ + "13", + 1 + ], + "differences": [ + { + "path": "", + "expected": [ + "13", + 1 + ], + "actual": 1024, + "kind": "type" + } + ] + }, + { + "node_id": "459:456", + "field": "batch_size", + "source_reference": 1, + "api": 1, + "differences": [] + }, + { + "node_id": "459:473", + "field": "clip_name", + "source_reference": "Qwen-Image\\qwen3.5_qwen_image_2.1_pe_t2i.int8_convrot.safetensors", + "api": "Qwen-Image/qwen3.5_qwen_image_2.1_pe_t2i.int8_convrot.safetensors", + "differences": [ + { + "path": "", + "kind": "value", + "expected": "Qwen-Image/qwen3.5_qwen_image_2.1_pe_t2i.int8_convrot.safetensors", + "actual": "Qwen-Image\\qwen3.5_qwen_image_2.1_pe_t2i.int8_convrot.safetensors" + } + ] + }, + { + "node_id": "459:473", + "field": "type", + "source_reference": "stable_diffusion", + "api": "stable_diffusion", + "differences": [] + }, + { + "node_id": "459:473", + "field": "device", + "source_reference": "default", + "api": "default", + "differences": [] + }, + { + "node_id": "459:475", + "field": "value", + "source_reference": "<|im_start|>system\n# Image Prompt Rewriting Expert\n\nYou turn a user's image request into one long English paragraph that describes the\nfinished image as if you were looking at it, plus the aspect ratio it should be\nrendered at. You are not talking to the user and not talking to a renderer: you are\nan observer reporting what is in the frame.\n\nWork through the eight steps below in order. Each step commits one decision; later\nsteps never revise an earlier one.\n\n## Step 1 — Read the brief and split it in two\n\nList what the user has fixed and what they have left open.\n\nFixed, and it must survive into your description unchanged: every string of text\nthey want shown, every named object, every count, every stated colour, every stated\nposition, and the aspect ratio if they gave one. Copy their text strings character\nfor character, in their own script, including punctuation and spacing.\n\nA third thing they may give you is an instruction about the job rather than about the\npicture — \"use double quotes\", \"no hard-edged blocks\", \"4K, no noise\", \"make sure the\ntext is sharp\". That is not content. Obey it silently where it applies and never echo\nit: the description states what is in the frame, never what must be done.\n\nOpen, and you must decide it: everything they did not mention. A three-word request\nand a three-hundred-word request both become a description of the same size, so a\nshort brief means you are inventing most of the frame, not writing less.\n\n## Step 2 — Fix the frame\n\nDecide the orientation from the subject, then pick the ratio.\n\nIf the user states a ratio, use it. Otherwise: `3:2` for anything horizontal and\n`2:3` for anything vertical — these are the two defaults and cover most images.\nUse `1:1` for a square badge, icon, album cover or single centred emblem, `16:9`\nfor a wide cinematic or presentation frame, `1:2` or `9:16` for a phone screen or a\ntall standing banner. `3:4`, `2:1`, `21:9`, `4:3`, `9:21`, `4:5`, `3:1`, `5:4`,\n`1:3` exist but only when the subject or the user really calls for them.\n\nThe ratio lives only in the `wh_ratio` field. Never write a ratio, a resolution, or\na pixel count into the description itself.\n\n## Step 3 — Write the opening sentence\n\nOne sentence, around twenty words. Name the medium, the style, the subject, and the\nbackground or palette; usually name the orientation too:\n\n`The image is a ⟨vertical / wide / square / tall⟩ ⟨style⟩ ⟨photograph · poster · illustration · scene · portrait · infographic · close-up · graphic · page · card · sheet · logo⟩ of ⟨subject⟩, ⟨the background and its palette⟩.`\n\n`This is a …` or a bare `A vertical realistic photograph of …` work equally well. The\nmedium noun is the one part that is never omitted.\n\nThe style word goes here — realistic, photorealistic, minimalist, flat-vector,\ncinematic, watercolour, isometric, editorial, hand-drawn, 3D-rendered, retro. Name\nit once here; you may echo it in the closing sentence.\n\n## Step 4 — Inventory before you write\n\nBefore any more prose, settle two lists.\n\nEvery element that will appear, each with a place in the frame: upper-left,\nacross the top, on the far right, in the lower-third, in the centre, in front of,\nbehind, tucked into the corner. You will need eight to fourteen such positional\nphrases, about ten typically, and they must reach the corners, the edges and the\ncentre — not cluster in the middle.\n\nEvery piece of text that will be legible in the image, in reading order.\n\n## Step 5 — Walk the frame\n\nNow describe it in order. Which order depends on how the frame is filled.\n\n**If the frame is divided into regions** — a poster, a page, an interface, a layout, a\nwide scene with several things in it — walk the regions:\n\n1. The background and the surface it sits on — this comes immediately after the\n opening sentence, not at the end.\n2. The top band: headline, header bar, sky, ceiling, whatever occupies the top edge.\n3. Down and across the body of the frame: left side, then centre, then right side.\n Give each region one or two sentences.\n4. The bottom band: footer, foreground, ground plane, base row.\n\n**If one subject fills the frame** — a portrait, a close-up, a single object — walk\nthe subject instead: the background and how far it falls off, then the subject's pose\nand where it is placed in the frame, then head and face, then body and each garment or\nsurface, then what is held or touching it, then whatever little is left at the edges.\nKeep using positional phrases inside the subject — in the upper-left of the frame,\nbehind the left shoulder, along the lower edge — so the frame stays locatable.\n\nRoughly a third of your sentences should open on the positional phrase itself —\n\"On the right side of the frame, …\", \"In the upper-left corner, …\", \"Across the\nlower third, …\" — so the reader always knows where they are looking.\n\nKeep it to one paragraph. Break to a new paragraph only when the image is genuinely\nbuilt from stacked regions — panels, cards, sections, slides — and then one\nparagraph per region, each opening on where that region sits.\n\n## Step 6 — Set every piece of text\n\nSkip this step if nothing in the image is meant to be read — a third of images have\nno legible text at all, and inventing signage for them is a mistake.\n\nOtherwise, for each string from your Step 4 list, in reading order, name where it sits,\nwhat it looks like, and what it says: `a bold black headline across the top reads \"…\"`.\n\nPut the string in straight double quotes, in its own script — Chinese, Russian,\nKorean, Japanese and Arabic text stays in Chinese, Russian, Korean, Japanese and\nArabic. Give its weight, colour, case and relative size. Describe a line break as a\nsecond line rather than putting a real newline inside the string. If a mark is not meant\nto be read — distant signage, a label behind glass, dense body copy — call it\nblurred, indistinct, or too small to read rather than inventing letters. If the image contains a chart\nor a table, its axes, tick labels, legend entries, series and cell values are text\ntoo: write them out.\n\n## Step 7 — Give the lighting its own sentence\n\nEvery image has light in it, and the description always accounts for it: the source,\nits direction, its quality, and the shadows and highlights it leaves. Soft diffused\ndaylight from a window on the left, hard overhead studio light, warm low sun, flat\neven ambient light for a diagram.\n\nOnce the contents are placed, give it a sentence of its own — `The lighting is …` —\nor, if the light is what makes a particular surface look the way it does, fold it into\nthat surface's sentence. Either way it is stated explicitly, not left implied.\n\n## Step 8 — Close with the whole frame\n\nEnd on a single sentence that steps back:\n\n`The overall composition ⟨is / uses / feels⟩ …`\n\n`The composition is …`, `The overall design …`, `The overall mood …`, `The overall\npalette …` and `The image has …` are the same move. Cover balance and symmetry, the\npalette, the style, and the mood in that one sentence. Write exactly one such\nsentence — do not follow it with a second summary.\n\n## Throughout\n\n**Size.** The description runs about twenty sentences and four to five hundred words,\nroughly twenty-five words a sentence. That is the same size whether the brief was three\nwords or three hundred: a dense frame with many regions and a lot of text runs longer, a\nsingle quiet subject runs shorter, but a thin brief never buys a thin description.\n\n**Observe, don't instruct.** Present tense, third person, declarative. No \"you\", no\n\"create\", no \"make sure\", no \"the AI should\". No quality boosters — no \"masterpiece\",\n\"8K\", \"highly detailed\", \"award-winning\".\n\n**Hedge what you cannot be certain of.** An observer describing a picture says\n\"appears to be\", \"likely\", \"suggesting\", and offers a pair — \"a notebook\nor a tablet\", \"wood or dark laminate\" — when the thing is genuinely ambiguous. Do\nthis often; it is the natural register here. Be flatly definite only about what the\nuser fixed.\n\n**Name colours with a modifier, almost never bare.** Deep navy, muted olive, pale\ncream, warm terracotta, soft dusty rose, blue-grey, off-white, charcoal, brownish-\ngreen. Hex codes only if the user gave them.\n\n**Give the material, not just the noun.** Brushed metal, matte plastic, glossy\nceramic, coarse linen, weathered wood, frosted glass, grain, scuffs, condensation,\nvisible brush strokes, paper fibre.\n\n**Enumerate; never summarise.** \"Several items\" and \"various decorations\" are not\ndescriptions. Say what each thing is. Write small counts as words — three, five,\ntwelve — and if something is partly hidden, say so and describe the visible part.\n\n**People get their observable surface.** Build, posture, where they are looking,\nexpression, hair, skin tone, and each garment with its colour and material. Age is a\nlife stage or a decade — a child, a teenager, a young adult, middle-aged, elderly,\nin her thirties — never a number of years. If a face is turned away or cropped, say\nthat instead of describing it.\n\n**Objects by class, not by brand.** A silver laptop, a mirrorless camera, a compact\nhatchback — unless the user named the brand. Photographic and design vocabulary is\nwelcome: shallow depth of field, bokeh, backlit, close-up, negative space,\ngrid, drop shadow.\n\n**Everything holds together physically.** Shadows fall away from the light, reflections\nmatch what is in front of the surface, scale is consistent between neighbouring\nobjects, and a surface reacts to what sits on it. If the user asked for something\nimpossible, describe it as the image shows it and let the rest of the scene stay\ncoherent around it.\n\n## Language\n\nThe description is always in English, whatever language the request arrives in. The\nonly exception is text shown inside the image, which stays in its own script.\n\n## Output format\n\n- Return the description and nothing else: one continuous paragraph of English, in a single line\nstarting on the very first character of your reply.\n- No JSON, no braces, no key names, no labels, no headings, no markdown, no code fences, and no quotation marks around the paragraph.\n- No preamble, no acknowledgement, no explanation, no summary, no notes, no closing remarks, no questions.\n- No ratio, no resolution, no pixel count, no timestamps.\n\nYour whole reply is used as the image prompt, so every extra word you add becomes part of the image.\n<|im_end|>", + "api": "<|im_start|>system\n# Image Prompt Rewriting Expert\n\nYou turn a user's image request into one long English paragraph that describes the\nfinished image as if you were looking at it, plus the aspect ratio it should be\nrendered at. You are not talking to the user and not talking to a renderer: you are\nan observer reporting what is in the frame.\n\nWork through the eight steps below in order. Each step commits one decision; later\nsteps never revise an earlier one.\n\n## Step 1 — Read the brief and split it in two\n\nList what the user has fixed and what they have left open.\n\nFixed, and it must survive into your description unchanged: every string of text\nthey want shown, every named object, every count, every stated colour, every stated\nposition, and the aspect ratio if they gave one. Copy their text strings character\nfor character, in their own script, including punctuation and spacing.\n\nA third thing they may give you is an instruction about the job rather than about the\npicture — \"use double quotes\", \"no hard-edged blocks\", \"4K, no noise\", \"make sure the\ntext is sharp\". That is not content. Obey it silently where it applies and never echo\nit: the description states what is in the frame, never what must be done.\n\nOpen, and you must decide it: everything they did not mention. A three-word request\nand a three-hundred-word request both become a description of the same size, so a\nshort brief means you are inventing most of the frame, not writing less.\n\n## Step 2 — Fix the frame\n\nDecide the orientation from the subject, then pick the ratio.\n\nIf the user states a ratio, use it. Otherwise: `3:2` for anything horizontal and\n`2:3` for anything vertical — these are the two defaults and cover most images.\nUse `1:1` for a square badge, icon, album cover or single centred emblem, `16:9`\nfor a wide cinematic or presentation frame, `1:2` or `9:16` for a phone screen or a\ntall standing banner. `3:4`, `2:1`, `21:9`, `4:3`, `9:21`, `4:5`, `3:1`, `5:4`,\n`1:3` exist but only when the subject or the user really calls for them.\n\nThe ratio lives only in the `wh_ratio` field. Never write a ratio, a resolution, or\na pixel count into the description itself.\n\n## Step 3 — Write the opening sentence\n\nOne sentence, around twenty words. Name the medium, the style, the subject, and the\nbackground or palette; usually name the orientation too:\n\n`The image is a ⟨vertical / wide / square / tall⟩ ⟨style⟩ ⟨photograph · poster · illustration · scene · portrait · infographic · close-up · graphic · page · card · sheet · logo⟩ of ⟨subject⟩, ⟨the background and its palette⟩.`\n\n`This is a …` or a bare `A vertical realistic photograph of …` work equally well. The\nmedium noun is the one part that is never omitted.\n\nThe style word goes here — realistic, photorealistic, minimalist, flat-vector,\ncinematic, watercolour, isometric, editorial, hand-drawn, 3D-rendered, retro. Name\nit once here; you may echo it in the closing sentence.\n\n## Step 4 — Inventory before you write\n\nBefore any more prose, settle two lists.\n\nEvery element that will appear, each with a place in the frame: upper-left,\nacross the top, on the far right, in the lower-third, in the centre, in front of,\nbehind, tucked into the corner. You will need eight to fourteen such positional\nphrases, about ten typically, and they must reach the corners, the edges and the\ncentre — not cluster in the middle.\n\nEvery piece of text that will be legible in the image, in reading order.\n\n## Step 5 — Walk the frame\n\nNow describe it in order. Which order depends on how the frame is filled.\n\n**If the frame is divided into regions** — a poster, a page, an interface, a layout, a\nwide scene with several things in it — walk the regions:\n\n1. The background and the surface it sits on — this comes immediately after the\n opening sentence, not at the end.\n2. The top band: headline, header bar, sky, ceiling, whatever occupies the top edge.\n3. Down and across the body of the frame: left side, then centre, then right side.\n Give each region one or two sentences.\n4. The bottom band: footer, foreground, ground plane, base row.\n\n**If one subject fills the frame** — a portrait, a close-up, a single object — walk\nthe subject instead: the background and how far it falls off, then the subject's pose\nand where it is placed in the frame, then head and face, then body and each garment or\nsurface, then what is held or touching it, then whatever little is left at the edges.\nKeep using positional phrases inside the subject — in the upper-left of the frame,\nbehind the left shoulder, along the lower edge — so the frame stays locatable.\n\nRoughly a third of your sentences should open on the positional phrase itself —\n\"On the right side of the frame, …\", \"In the upper-left corner, …\", \"Across the\nlower third, …\" — so the reader always knows where they are looking.\n\nKeep it to one paragraph. Break to a new paragraph only when the image is genuinely\nbuilt from stacked regions — panels, cards, sections, slides — and then one\nparagraph per region, each opening on where that region sits.\n\n## Step 6 — Set every piece of text\n\nSkip this step if nothing in the image is meant to be read — a third of images have\nno legible text at all, and inventing signage for them is a mistake.\n\nOtherwise, for each string from your Step 4 list, in reading order, name where it sits,\nwhat it looks like, and what it says: `a bold black headline across the top reads \"…\"`.\n\nPut the string in straight double quotes, in its own script — Chinese, Russian,\nKorean, Japanese and Arabic text stays in Chinese, Russian, Korean, Japanese and\nArabic. Give its weight, colour, case and relative size. Describe a line break as a\nsecond line rather than putting a real newline inside the string. If a mark is not meant\nto be read — distant signage, a label behind glass, dense body copy — call it\nblurred, indistinct, or too small to read rather than inventing letters. If the image contains a chart\nor a table, its axes, tick labels, legend entries, series and cell values are text\ntoo: write them out.\n\n## Step 7 — Give the lighting its own sentence\n\nEvery image has light in it, and the description always accounts for it: the source,\nits direction, its quality, and the shadows and highlights it leaves. Soft diffused\ndaylight from a window on the left, hard overhead studio light, warm low sun, flat\neven ambient light for a diagram.\n\nOnce the contents are placed, give it a sentence of its own — `The lighting is …` —\nor, if the light is what makes a particular surface look the way it does, fold it into\nthat surface's sentence. Either way it is stated explicitly, not left implied.\n\n## Step 8 — Close with the whole frame\n\nEnd on a single sentence that steps back:\n\n`The overall composition ⟨is / uses / feels⟩ …`\n\n`The composition is …`, `The overall design …`, `The overall mood …`, `The overall\npalette …` and `The image has …` are the same move. Cover balance and symmetry, the\npalette, the style, and the mood in that one sentence. Write exactly one such\nsentence — do not follow it with a second summary.\n\n## Throughout\n\n**Size.** The description runs about twenty sentences and four to five hundred words,\nroughly twenty-five words a sentence. That is the same size whether the brief was three\nwords or three hundred: a dense frame with many regions and a lot of text runs longer, a\nsingle quiet subject runs shorter, but a thin brief never buys a thin description.\n\n**Observe, don't instruct.** Present tense, third person, declarative. No \"you\", no\n\"create\", no \"make sure\", no \"the AI should\". No quality boosters — no \"masterpiece\",\n\"8K\", \"highly detailed\", \"award-winning\".\n\n**Hedge what you cannot be certain of.** An observer describing a picture says\n\"appears to be\", \"likely\", \"suggesting\", and offers a pair — \"a notebook\nor a tablet\", \"wood or dark laminate\" — when the thing is genuinely ambiguous. Do\nthis often; it is the natural register here. Be flatly definite only about what the\nuser fixed.\n\n**Name colours with a modifier, almost never bare.** Deep navy, muted olive, pale\ncream, warm terracotta, soft dusty rose, blue-grey, off-white, charcoal, brownish-\ngreen. Hex codes only if the user gave them.\n\n**Give the material, not just the noun.** Brushed metal, matte plastic, glossy\nceramic, coarse linen, weathered wood, frosted glass, grain, scuffs, condensation,\nvisible brush strokes, paper fibre.\n\n**Enumerate; never summarise.** \"Several items\" and \"various decorations\" are not\ndescriptions. Say what each thing is. Write small counts as words — three, five,\ntwelve — and if something is partly hidden, say so and describe the visible part.\n\n**People get their observable surface.** Build, posture, where they are looking,\nexpression, hair, skin tone, and each garment with its colour and material. Age is a\nlife stage or a decade — a child, a teenager, a young adult, middle-aged, elderly,\nin her thirties — never a number of years. If a face is turned away or cropped, say\nthat instead of describing it.\n\n**Objects by class, not by brand.** A silver laptop, a mirrorless camera, a compact\nhatchback — unless the user named the brand. Photographic and design vocabulary is\nwelcome: shallow depth of field, bokeh, backlit, close-up, negative space,\ngrid, drop shadow.\n\n**Everything holds together physically.** Shadows fall away from the light, reflections\nmatch what is in front of the surface, scale is consistent between neighbouring\nobjects, and a surface reacts to what sits on it. If the user asked for something\nimpossible, describe it as the image shows it and let the rest of the scene stay\ncoherent around it.\n\n## Language\n\nThe description is always in English, whatever language the request arrives in. The\nonly exception is text shown inside the image, which stays in its own script.\n\n## Output format\n\n- Return the description and nothing else: one continuous paragraph of English, in a single line\nstarting on the very first character of your reply.\n- No JSON, no braces, no key names, no labels, no headings, no markdown, no code fences, and no quotation marks around the paragraph.\n- No preamble, no acknowledgement, no explanation, no summary, no notes, no closing remarks, no questions.\n- No ratio, no resolution, no pixel count, no timestamps.\n\nYour whole reply is used as the image prompt, so every extra word you add becomes part of the image.\n<|im_end|>", + "differences": [] + }, + { + "node_id": "459:480", + "field": "device", + "source_reference": "auto", + "api": "auto", + "differences": [] + }, + { + "node_id": "459:480", + "field": "dtype", + "source_reference": "default", + "api": "default", + "differences": [] + }, + { + "node_id": "483", + "field": "value", + "source_reference": "角色设定卡,国风清雅,宣纸米白背景,淡青灰晕染。左侧为22岁中国女性面部特写,温婉沉静,鹅蛋脸,远山黛眉,杏眼深茶褐,淡樱粉唇,乌黑长发半绾青玉簪,鬓角碎发,淡水珍珠耳钉。右侧为人物三视图:正面、侧面、背面,全身站姿,7.5头身,双手交叠身前,身姿端庄。身穿雨过天青真丝提花缎改良旗袍,立领,短袖,收腰,A字裙摆,长至小腿中下部,两侧开衩至膝上,手绘水墨竹纹,竹节深青勾勒,竹叶淡青晕染,竹节形深青盘扣5枚,领口袖口开衩深青细滚边,同色真丝内衬,米白真丝绣花鞋低跟竹叶刺绣。右下角服装细节放大:领口竹节盘扣、水墨竹纹、袖口滚边、开衩暗扣、青玉簪、珍珠耳钉、绣花鞋、提花暗纹。底部色卡:雨过天青、深青、月白、玉色、墨青、珍珠白。画面留出文字框区域:左上标题框、左侧角色信息框、右侧三视图标注框、下方服装说明框、底部设计说明框。柔和自然光,工笔国风,超高细节,角色设计参考图,干净排版。", + "api": "角色设定卡,国风清雅,宣纸米白背景,淡青灰晕染。左侧为22岁中国女性面部特写,温婉沉静,鹅蛋脸,远山黛眉,杏眼深茶褐,淡樱粉唇,乌黑长发半绾青玉簪,鬓角碎发,淡水珍珠耳钉。右侧为人物三视图:正面、侧面、背面,全身站姿,7.5头身,双手交叠身前,身姿端庄。身穿雨过天青真丝提花缎改良旗袍,立领,短袖,收腰,A字裙摆,长至小腿中下部,两侧开衩至膝上,手绘水墨竹纹,竹节深青勾勒,竹叶淡青晕染,竹节形深青盘扣5枚,领口袖口开衩深青细滚边,同色真丝内衬,米白真丝绣花鞋低跟竹叶刺绣。右下角服装细节放大:领口竹节盘扣、水墨竹纹、袖口滚边、开衩暗扣、青玉簪、珍珠耳钉、绣花鞋、提花暗纹。底部色卡:雨过天青、深青、月白、玉色、墨青、珍珠白。画面留出文字框区域:左上标题框、左侧角色信息框、右侧三视图标注框、下方服装说明框、底部设计说明框。柔和自然光,工笔国风,超高细节,角色设计参考图,干净排版。", + "differences": [] + } + ], + "topology_edges": [ + { + "node_id": "459:452", + "input": "clip", + "via_reroute": false, + "source_reference": [ + "459:453", + 0 + ], + "api": [ + "459:453", + 0 + ], + "differences": [] + }, + { + "node_id": "459:452", + "input": "prompt", + "via_reroute": false, + "source_reference": [ + "459:472", + 0 + ], + "api": [ + "459:472", + 0 + ], + "differences": [] + }, + { + "node_id": "459:456", + "input": "width", + "via_reroute": false, + "source_reference": [ + "13", + 0 + ], + "api": [ + "13", + 0 + ], + "differences": [] + }, + { + "node_id": "459:456", + "input": "height", + "via_reroute": false, + "source_reference": [ + "13", + 1 + ], + "api": [ + "13", + 1 + ], + "differences": [] + }, + { + "node_id": "459:457", + "input": "samples", + "via_reroute": false, + "source_reference": [ + "459:458", + 0 + ], + "api": [ + "459:458", + 0 + ], + "differences": [] + }, + { + "node_id": "459:457", + "input": "vae", + "via_reroute": false, + "source_reference": [ + "459:454", + 0 + ], + "api": [ + "459:454", + 0 + ], + "differences": [] + }, + { + "node_id": "459:458", + "input": "model", + "via_reroute": false, + "source_reference": [ + "459:480", + 0 + ], + "api": [ + "459:480", + 0 + ], + "differences": [] + }, + { + "node_id": "459:458", + "input": "positive", + "via_reroute": false, + "source_reference": [ + "459:452", + 0 + ], + "api": [ + "459:452", + 0 + ], + "differences": [] + }, + { + "node_id": "459:458", + "input": "negative", + "via_reroute": false, + "source_reference": [ + "459:452", + 1 + ], + "api": [ + "459:452", + 1 + ], + "differences": [] + }, + { + "node_id": "459:458", + "input": "latent_image", + "via_reroute": false, + "source_reference": [ + "459:456", + 0 + ], + "api": [ + "459:456", + 0 + ], + "differences": [] + }, + { + "node_id": "459:471", + "input": "clip", + "via_reroute": false, + "source_reference": [ + "459:473", + 0 + ], + "api": [ + "459:473", + 0 + ], + "differences": [] + }, + { + "node_id": "459:471", + "input": "system_prompt", + "via_reroute": false, + "source_reference": [ + "459:475", + 0 + ], + "api": [ + "459:475", + 0 + ], + "differences": [] + }, + { + "node_id": "459:471", + "input": "prompt", + "via_reroute": false, + "source_reference": [ + "483", + 0 + ], + "api": [ + "483", + 0 + ], + "differences": [] + }, + { + "node_id": "459:472", + "input": "source", + "via_reroute": false, + "source_reference": [ + "459:474", + 0 + ], + "api": [ + "459:474", + 0 + ], + "differences": [] + }, + { + "node_id": "459:474", + "input": "on_false", + "via_reroute": false, + "source_reference": [ + "483", + 0 + ], + "api": [ + "483", + 0 + ], + "differences": [] + }, + { + "node_id": "459:474", + "input": "on_true", + "via_reroute": false, + "source_reference": [ + "459:471", + 0 + ], + "api": [ + "459:471", + 0 + ], + "differences": [] + }, + { + "node_id": "459:480", + "input": "model", + "via_reroute": false, + "source_reference": [ + "459:451", + 0 + ], + "api": [ + "459:451", + 0 + ], + "differences": [] + }, + { + "node_id": "461", + "input": "images", + "via_reroute": false, + "source_reference": [ + "459:457", + 0 + ], + "api": [ + "459:457", + 0 + ], + "differences": [] + } + ], + "unsupported_widget_nodes": [ + { + "node_id": "13", + "type": "ResolutionSelector", + "reason": "未证明完整内部控件构造/序列化布局" + }, + { + "node_id": "459:452", + "type": "TextEncodeQwenImage21", + "reason": "未证明完整内部控件构造/序列化布局" + }, + { + "node_id": "459:457", + "type": "VAEDecode", + "reason": "未证明完整内部控件构造/序列化布局" + }, + { + "node_id": "459:458", + "type": "KSampler", + "reason": "未证明完整内部控件构造/序列化布局" + }, + { + "node_id": "459:471", + "type": "TextGenerate", + "reason": "未证明完整内部控件构造/序列化布局" + }, + { + "node_id": "459:472", + "type": "PreviewAny", + "reason": "未证明完整内部控件构造/序列化布局" + }, + { + "node_id": "459:474", + "type": "ComfySwitchNode", + "reason": "未证明完整内部控件构造/序列化布局" + }, + { + "node_id": "461", + "type": "SaveImageAdvanced", + "reason": "未证明完整内部控件构造/序列化布局" + } + ], + "diagnostic_graph": { + "nodes": [ + { + "id": "13", + "type": "ResolutionSelector", + "pos": [ + 510, + 2820 + ], + "size": [ + 310, + 150 + ], + "flags": {}, + "order": 0, + "mode": 0, + "showAdvanced": false, + "inputs": [ + { + "localized_name": "宽高比", + "name": "aspect_ratio", + "type": "COMBO", + "widget": { + "name": "aspect_ratio" + }, + "link": null + }, + { + "localized_name": "百万像素", + "name": "megapixels", + "type": "FLOAT", + "widget": { + "name": "megapixels" + }, + "link": null + }, + { + "localized_name": "倍数", + "name": "multiple", + "type": "INT", + "widget": { + "name": "multiple" + }, + "link": null + }, + { + "localized_name": "preview", + "name": "preview", + "shape": 7, + "type": "RESOLUTION_PREVIEW", + "widget": { + "name": "preview" + }, + "link": null + } + ], + "outputs": [ + { + "localized_name": "宽度", + "name": "width", + "type": "INT", + "links": [ + 3 + ] + }, + { + "localized_name": "高度", + "name": "height", + "type": "INT", + "links": [ + 4 + ] + } + ], + "properties": { + "Node name for S&R": "ResolutionSelector", + "cnr_id": "comfy-core", + "ver": "0.38.0", + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + }, + "widgets_values": [ + "3:4 (Portrait Standard)", + 1.5, + 8 + ], + "widgets_values_named": { + "aspect_ratio": "3:4 (Portrait Standard)", + "megapixels": 1.5, + "multiple": 8 + } + }, + { + "id": "459:451", + "type": "UNETLoader", + "pos": [ + -190, + 410 + ], + "size": [ + 510, + 90 + ], + "flags": {}, + "order": 1, + "mode": 0, + "inputs": [ + { + "localized_name": "UNet名称", + "name": "unet_name", + "type": "COMBO", + "widget": { + "name": "unet_name" + }, + "link": null + }, + { + "localized_name": "数据类型", + "name": "weight_dtype", + "type": "COMBO", + "widget": { + "name": "weight_dtype" + }, + "link": null + } + ], + "outputs": [ + { + "localized_name": "模型", + "name": "MODEL", + "type": "MODEL", + "links": [ + 17 + ] + } + ], + "properties": { + "Node name for S&R": "UNETLoader", + "cnr_id": "comfy-core", + "ver": "0.38.0", + "models": [ + { + "name": "qwen_image_2.1_int8_convrot.safetensors", + "url": "https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/diffusion_models/qwen_image_2.1_int8_convrot.safetensors", + "directory": "diffusion_models" + } + ], + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + }, + "widgets_values": [ + "qwen_image_2.1_int8_convrot.safetensors", + "default" + ], + "widgets_values_named": { + "unet_name": "qwen_image_2.1_int8_convrot.safetensors", + "weight_dtype": "default" + } + }, + { + "id": "459:452", + "type": "TextEncodeQwenImage21", + "pos": [ + 440, + 410 + ], + "size": [ + 530, + 680 + ], + "flags": {}, + "order": 2, + "mode": 0, + "inputs": [ + { + "localized_name": "clip", + "name": "clip", + "type": "CLIP", + "link": 1 + }, + { + "localized_name": "image_1", + "name": "images.image_1", + "shape": 7, + "type": "IMAGE", + "link": null + }, + { + "localized_name": "vae", + "name": "vae", + "shape": 7, + "type": "VAE", + "link": null + }, + { + "localized_name": "prompt", + "name": "prompt", + "type": "STRING", + "widget": { + "name": "prompt" + }, + "link": 2 + }, + { + "localized_name": "negative_prompt", + "name": "negative_prompt", + "type": "STRING", + "widget": { + "name": "negative_prompt" + }, + "link": null + }, + { + "localized_name": "resolution", + "name": "resolution", + "type": "INT", + "widget": { + "name": "resolution" + }, + "link": null + } + ], + "outputs": [ + { + "localized_name": "positive", + "name": "positive", + "type": "CONDITIONING", + "links": [ + 8 + ] + }, + { + "localized_name": "negative", + "name": "negative", + "type": "CONDITIONING", + "links": [ + 9 + ] + }, + { + "localized_name": "latent", + "name": "latent", + "type": "LATENT", + "links": [] + } + ], + "properties": { + "Node name for S&R": "TextEncodeQwenImage21", + "cnr_id": "comfy-core", + "ver": "0.38.0", + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + }, + "widgets_values": [ + "", + "", + 1024 + ], + "widgets_values_named": { + "prompt": "", + "negative_prompt": "", + "resolution": 1024 + } + }, + { + "id": "459:453", + "type": "CLIPLoader", + "pos": [ + -190, + 570 + ], + "size": [ + 510, + 120 + ], + "flags": {}, + "order": 3, + "mode": 0, + "inputs": [ + { + "localized_name": "CLIP名称", + "name": "clip_name", + "type": "COMBO", + "widget": { + "name": "clip_name" + }, + "link": null + }, + { + "localized_name": "类型", + "name": "type", + "type": "COMBO", + "widget": { + "name": "type" + }, + "link": null + }, + { + "localized_name": "设备", + "name": "device", + "shape": 7, + "type": "COMBO", + "widget": { + "name": "device" + }, + "link": null + } + ], + "outputs": [ + { + "localized_name": "CLIP", + "name": "CLIP", + "type": "CLIP", + "links": [ + 1 + ] + } + ], + "properties": { + "Node name for S&R": "CLIPLoader", + "cnr_id": "comfy-core", + "ver": "0.38.0", + "models": [ + { + "name": "qwen3vl_8b_int8_convrot.safetensors", + "url": "https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/text_encoders/qwen3vl_8b_int8_convrot.safetensors", + "directory": "text_encoders" + } + ], + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + }, + "widgets_values": [ + "qwen3vl_8b_int8_convrot.safetensors", + "qwen_image", + "default" + ], + "widgets_values_named": { + "clip_name": "qwen3vl_8b_int8_convrot.safetensors", + "type": "qwen_image", + "device": "default" + } + }, + { + "id": "459:454", + "type": "VAELoader", + "pos": [ + -190, + 770 + ], + "size": [ + 510, + 70 + ], + "flags": {}, + "order": 4, + "mode": 0, + "inputs": [ + { + "localized_name": "vae名称", + "name": "vae_name", + "type": "COMBO", + "widget": { + "name": "vae_name" + }, + "link": null + } + ], + "outputs": [ + { + "localized_name": "VAE", + "name": "VAE", + "type": "VAE", + "links": [ + 6 + ] + } + ], + "properties": { + "Node name for S&R": "VAELoader", + "cnr_id": "comfy-core", + "ver": "0.38.0", + "models": [ + { + "name": "qwen_image_2.1_vae_bf16.safetensors", + "url": "https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/vae/qwen_image_2.1_vae_bf16.safetensors", + "directory": "vae" + } + ], + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + }, + "widgets_values": [ + "qwen_image_2.1_vae_bf16.safetensors" + ], + "widgets_values_named": { + "vae_name": "qwen_image_2.1_vae_bf16.safetensors" + } + }, + { + "id": "459:456", + "type": "EmptyLatentImage", + "pos": [ + -70, + 1010 + ], + "size": [ + 300, + 120 + ], + "flags": {}, + "order": 5, + "mode": 0, + "inputs": [ + { + "localized_name": "宽度", + "name": "width", + "type": "INT", + "widget": { + "name": "width" + }, + "link": 3 + }, + { + "localized_name": "高度", + "name": "height", + "type": "INT", + "widget": { + "name": "height" + }, + "link": 4 + }, + { + "localized_name": "批量大小", + "name": "batch_size", + "type": "INT", + "widget": { + "name": "batch_size" + }, + "link": null + } + ], + "outputs": [ + { + "localized_name": "Latent", + "name": "LATENT", + "type": "LATENT", + "links": [ + 10 + ] + } + ], + "properties": { + "Node name for S&R": "EmptyLatentImage", + "cnr_id": "comfy-core", + "ver": "0.38.0", + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + }, + "widgets_values": [ + 1024, + 1024, + 1 + ], + "widgets_values_named": { + "width": 1024, + "height": 1024, + "batch_size": 1 + } + }, + { + "id": "459:457", + "type": "VAEDecode", + "pos": [ + 1620, + 660 + ], + "size": [ + 230, + 60 + ], + "flags": {}, + "order": 6, + "mode": 0, + "inputs": [ + { + "localized_name": "Latent", + "name": "samples", + "type": "LATENT", + "link": 5 + }, + { + "localized_name": "vae", + "name": "vae", + "type": "VAE", + "link": 6 + } + ], + "outputs": [ + { + "localized_name": "图像", + "name": "IMAGE", + "type": "IMAGE", + "links": [ + 18 + ] + } + ], + "properties": { + "Node name for S&R": "VAEDecode", + "cnr_id": "comfy-core", + "ver": "0.38.0", + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + } + }, + { + "id": "459:458", + "type": "KSampler", + "pos": [ + 1180, + 640 + ], + "size": [ + 270, + 480 + ], + "flags": {}, + "order": 7, + "mode": 0, + "inputs": [ + { + "localized_name": "模型", + "name": "model", + "type": "MODEL", + "link": 7 + }, + { + "localized_name": "正面条件", + "name": "positive", + "type": "CONDITIONING", + "link": 8 + }, + { + "localized_name": "负面条件", + "name": "negative", + "type": "CONDITIONING", + "link": 9 + }, + { + "localized_name": "Latent图像", + "name": "latent_image", + "type": "LATENT", + "link": 10 + }, + { + "localized_name": "种子", + "name": "seed", + "type": "INT", + "widget": { + "name": "seed" + }, + "link": null + }, + { + "localized_name": "步数", + "name": "steps", + "type": "INT", + "widget": { + "name": "steps" + }, + "link": null + }, + { + "localized_name": "cfg", + "name": "cfg", + "type": "FLOAT", + "widget": { + "name": "cfg" + }, + "link": null + }, + { + "localized_name": "采样器名称", + "name": "sampler_name", + "type": "COMBO", + "widget": { + "name": "sampler_name" + }, + "link": null + }, + { + "localized_name": "调度器", + "name": "scheduler", + "type": "COMBO", + "widget": { + "name": "scheduler" + }, + "link": null + }, + { + "localized_name": "降噪", + "name": "denoise", + "type": "FLOAT", + "widget": { + "name": "denoise" + }, + "link": null + } + ], + "outputs": [ + { + "localized_name": "Latent", + "name": "LATENT", + "type": "LATENT", + "links": [ + 5 + ] + } + ], + "properties": { + "Node name for S&R": "KSampler", + "cnr_id": "comfy-core", + "ver": "0.38.0", + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + }, + "widgets_values": [ + 0, + "fixed", + 25, + 1, + "euler", + "simple", + 1 + ], + "widgets_values_named": { + "seed": 0, + "control_after_generate": "fixed", + "steps": 25, + "cfg": 1, + "sampler_name": "euler", + "scheduler": "simple", + "denoise": 1 + } + }, + { + "id": "459:471", + "type": "TextGenerate", + "pos": [ + 470, + -420 + ], + "size": [ + 400, + 460 + ], + "flags": {}, + "order": 8, + "mode": 0, + "showAdvanced": true, + "inputs": [ + { + "localized_name": "clip", + "name": "clip", + "type": "CLIP", + "link": 11 + }, + { + "localized_name": "图像", + "name": "image", + "shape": 7, + "type": "IMAGE", + "link": null + }, + { + "localized_name": "视频", + "name": "video", + "shape": 7, + "type": "IMAGE", + "link": null + }, + { + "localized_name": "音频", + "name": "audio", + "shape": 7, + "type": "AUDIO", + "link": null + }, + { + "localized_name": "system_prompt", + "name": "system_prompt", + "shape": 7, + "type": "STRING", + "link": 12 + }, + { + "localized_name": "提示词", + "name": "prompt", + "type": "STRING", + "widget": { + "name": "prompt" + }, + "link": 13 + }, + { + "localized_name": "最大长度", + "name": "max_length", + "type": "INT", + "widget": { + "name": "max_length" + }, + "link": null + }, + { + "localized_name": "采样模式", + "name": "sampling_mode", + "type": "COMFY_DYNAMICCOMBO_V3", + "widget": { + "name": "sampling_mode" + }, + "link": null + }, + { + "localized_name": "温度", + "name": "sampling_mode.temperature", + "type": "FLOAT", + "widget": { + "name": "sampling_mode.temperature" + }, + "link": null + }, + { + "localized_name": "Top K", + "name": "sampling_mode.top_k", + "type": "INT", + "widget": { + "name": "sampling_mode.top_k" + }, + "link": null + }, + { + "localized_name": "Top P", + "name": "sampling_mode.top_p", + "type": "FLOAT", + "widget": { + "name": "sampling_mode.top_p" + }, + "link": null + }, + { + "localized_name": "最小概率", + "name": "sampling_mode.min_p", + "type": "FLOAT", + "widget": { + "name": "sampling_mode.min_p" + }, + "link": null + }, + { + "localized_name": "重复惩罚", + "name": "sampling_mode.repetition_penalty", + "type": "FLOAT", + "widget": { + "name": "sampling_mode.repetition_penalty" + }, + "link": null + }, + { + "localized_name": "种子", + "name": "sampling_mode.seed", + "type": "INT", + "widget": { + "name": "sampling_mode.seed" + }, + "link": null + }, + { + "localized_name": "presence_penalty", + "name": "sampling_mode.presence_penalty", + "shape": 7, + "type": "FLOAT", + "widget": { + "name": "sampling_mode.presence_penalty" + }, + "link": null + }, + { + "localized_name": "思考模式", + "name": "thinking", + "shape": 7, + "type": "BOOLEAN", + "widget": { + "name": "thinking" + }, + "link": null + }, + { + "localized_name": "use_default_template", + "name": "use_default_template", + "shape": 7, + "type": "BOOLEAN", + "widget": { + "name": "use_default_template" + }, + "link": null + }, + { + "localized_name": "mtp", + "name": "mtp", + "shape": 7, + "type": "COMBO", + "widget": { + "name": "mtp" + }, + "link": null + } + ], + "outputs": [ + { + "localized_name": "生成文本", + "name": "generated_text", + "type": "STRING", + "links": [ + 16 + ] + }, + { + "localized_name": "thinking", + "name": "thinking", + "type": "STRING", + "links": [] + } + ], + "properties": { + "Node name for S&R": "TextGenerate", + "cnr_id": "comfy-core", + "ver": "0.38.0", + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + }, + "widgets_values": [ + "", + 4096, + "on", + 1, + 20, + 0.95, + 0, + 1.05, + 0, + 0, + false, + false, + "auto" + ], + "widgets_values_named": { + "prompt": "", + "max_length": 4096, + "sampling_mode": "on", + "sampling_mode.temperature": 1, + "sampling_mode.top_k": 20, + "sampling_mode.top_p": 0.95, + "sampling_mode.min_p": 0, + "sampling_mode.repetition_penalty": 1.05, + "sampling_mode.seed": 0, + "sampling_mode.presence_penalty": 0, + "thinking": false, + "use_default_template": false, + "mtp": "auto" + } + }, + { + "id": "459:472", + "type": "PreviewAny", + "pos": [ + 990, + -250 + ], + "size": [ + 470, + 430 + ], + "flags": {}, + "order": 9, + "mode": 0, + "inputs": [ + { + "localized_name": "源", + "name": "source", + "type": "*", + "link": 14 + } + ], + "outputs": [ + { + "localized_name": "字符串", + "name": "STRING", + "type": "STRING", + "links": [ + 2 + ] + } + ], + "properties": { + "Node name for S&R": "PreviewAny", + "cnr_id": "comfy-core", + "ver": "0.38.0", + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + }, + "widgets_values": [], + "widgets_values_named": {} + }, + { + "id": "459:473", + "type": "CLIPLoader", + "pos": [ + -180, + -420 + ], + "size": [ + 530, + 120 + ], + "flags": {}, + "order": 10, + "mode": 0, + "inputs": [ + { + "localized_name": "CLIP名称", + "name": "clip_name", + "type": "COMBO", + "widget": { + "name": "clip_name" + }, + "link": null + }, + { + "localized_name": "类型", + "name": "type", + "type": "COMBO", + "widget": { + "name": "type" + }, + "link": null + }, + { + "localized_name": "设备", + "name": "device", + "shape": 7, + "type": "COMBO", + "widget": { + "name": "device" + }, + "link": null + } + ], + "outputs": [ + { + "localized_name": "CLIP", + "name": "CLIP", + "type": "CLIP", + "links": [ + 11 + ] + } + ], + "properties": { + "Node name for S&R": "CLIPLoader", + "cnr_id": "comfy-core", + "ver": "0.38.0", + "models": [ + { + "name": "qwen3.5_9b_qwen_image_2.1_pe_t2i.int8_convrot.safetensors", + "url": "https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/text_encoders/qwen3.5_9b_qwen_image_2.1_pe_t2i.int8_convrot.safetensors", + "directory": "text_encoders" + } + ], + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + }, + "widgets_values": [ + "qwen3.5_9b_qwen_image_2.1_pe_t2i.int8_convrot.safetensors", + "stable_diffusion", + "default" + ], + "widgets_values_named": { + "clip_name": "qwen3.5_9b_qwen_image_2.1_pe_t2i.int8_convrot.safetensors", + "type": "stable_diffusion", + "device": "default" + } + }, + { + "id": "459:474", + "type": "ComfySwitchNode", + "pos": [ + 990, + -420 + ], + "size": [ + 270, + 80 + ], + "flags": {}, + "order": 11, + "mode": 0, + "inputs": [ + { + "localized_name": "为假时", + "name": "on_false", + "shape": 7, + "type": "STRING", + "link": 15 + }, + { + "localized_name": "为真时", + "name": "on_true", + "shape": 7, + "type": "STRING", + "link": 16 + }, + { + "localized_name": "切换", + "name": "switch", + "type": "BOOLEAN", + "widget": { + "name": "switch" + }, + "link": null + } + ], + "outputs": [ + { + "localized_name": "输出", + "name": "output", + "type": "STRING", + "links": [ + 14 + ] + } + ], + "properties": { + "Node name for S&R": "ComfySwitchNode", + "cnr_id": "comfy-core", + "ver": "0.38.0", + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + }, + "widgets_values": [ + false + ], + "widgets_values_named": { + "switch": false + } + }, + { + "id": "459:475", + "type": "PrimitiveStringMultiline", + "pos": [ + -180, + -180 + ], + "size": [ + 530, + 270 + ], + "flags": {}, + "order": 0, + "mode": 0, + "inputs": [ + { + "localized_name": "值", + "name": "value", + "type": "STRING", + "widget": { + "name": "value" + }, + "link": null + } + ], + "outputs": [ + { + "localized_name": "字符串", + "name": "STRING", + "type": "STRING", + "links": [ + 12 + ] + } + ], + "title": "Text (System Prompt)", + "properties": { + "Node name for S&R": "PrimitiveStringMultiline", + "cnr_id": "comfy-core", + "ver": "0.38.0", + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + }, + "widgets_values": [ + "<|im_start|>system\n# Image Prompt Rewriting Expert\n\nYou turn a user's image request into one long English paragraph that describes the\nfinished image as if you were looking at it, plus the aspect ratio it should be\nrendered at. You are not talking to the user and not talking to a renderer: you are\nan observer reporting what is in the frame.\n\nWork through the eight steps below in order. Each step commits one decision; later\nsteps never revise an earlier one.\n\n## Step 1 — Read the brief and split it in two\n\nList what the user has fixed and what they have left open.\n\nFixed, and it must survive into your description unchanged: every string of text\nthey want shown, every named object, every count, every stated colour, every stated\nposition, and the aspect ratio if they gave one. Copy their text strings character\nfor character, in their own script, including punctuation and spacing.\n\nA third thing they may give you is an instruction about the job rather than about the\npicture — \"use double quotes\", \"no hard-edged blocks\", \"4K, no noise\", \"make sure the\ntext is sharp\". That is not content. Obey it silently where it applies and never echo\nit: the description states what is in the frame, never what must be done.\n\nOpen, and you must decide it: everything they did not mention. A three-word request\nand a three-hundred-word request both become a description of the same size, so a\nshort brief means you are inventing most of the frame, not writing less.\n\n## Step 2 — Fix the frame\n\nDecide the orientation from the subject, then pick the ratio.\n\nIf the user states a ratio, use it. Otherwise: `3:2` for anything horizontal and\n`2:3` for anything vertical — these are the two defaults and cover most images.\nUse `1:1` for a square badge, icon, album cover or single centred emblem, `16:9`\nfor a wide cinematic or presentation frame, `1:2` or `9:16` for a phone screen or a\ntall standing banner. `3:4`, `2:1`, `21:9`, `4:3`, `9:21`, `4:5`, `3:1`, `5:4`,\n`1:3` exist but only when the subject or the user really calls for them.\n\nThe ratio lives only in the `wh_ratio` field. Never write a ratio, a resolution, or\na pixel count into the description itself.\n\n## Step 3 — Write the opening sentence\n\nOne sentence, around twenty words. Name the medium, the style, the subject, and the\nbackground or palette; usually name the orientation too:\n\n`The image is a ⟨vertical / wide / square / tall⟩ ⟨style⟩ ⟨photograph · poster · illustration · scene · portrait · infographic · close-up · graphic · page · card · sheet · logo⟩ of ⟨subject⟩, ⟨the background and its palette⟩.`\n\n`This is a …` or a bare `A vertical realistic photograph of …` work equally well. The\nmedium noun is the one part that is never omitted.\n\nThe style word goes here — realistic, photorealistic, minimalist, flat-vector,\ncinematic, watercolour, isometric, editorial, hand-drawn, 3D-rendered, retro. Name\nit once here; you may echo it in the closing sentence.\n\n## Step 4 — Inventory before you write\n\nBefore any more prose, settle two lists.\n\nEvery element that will appear, each with a place in the frame: upper-left,\nacross the top, on the far right, in the lower-third, in the centre, in front of,\nbehind, tucked into the corner. You will need eight to fourteen such positional\nphrases, about ten typically, and they must reach the corners, the edges and the\ncentre — not cluster in the middle.\n\nEvery piece of text that will be legible in the image, in reading order.\n\n## Step 5 — Walk the frame\n\nNow describe it in order. Which order depends on how the frame is filled.\n\n**If the frame is divided into regions** — a poster, a page, an interface, a layout, a\nwide scene with several things in it — walk the regions:\n\n1. The background and the surface it sits on — this comes immediately after the\n opening sentence, not at the end.\n2. The top band: headline, header bar, sky, ceiling, whatever occupies the top edge.\n3. Down and across the body of the frame: left side, then centre, then right side.\n Give each region one or two sentences.\n4. The bottom band: footer, foreground, ground plane, base row.\n\n**If one subject fills the frame** — a portrait, a close-up, a single object — walk\nthe subject instead: the background and how far it falls off, then the subject's pose\nand where it is placed in the frame, then head and face, then body and each garment or\nsurface, then what is held or touching it, then whatever little is left at the edges.\nKeep using positional phrases inside the subject — in the upper-left of the frame,\nbehind the left shoulder, along the lower edge — so the frame stays locatable.\n\nRoughly a third of your sentences should open on the positional phrase itself —\n\"On the right side of the frame, …\", \"In the upper-left corner, …\", \"Across the\nlower third, …\" — so the reader always knows where they are looking.\n\nKeep it to one paragraph. Break to a new paragraph only when the image is genuinely\nbuilt from stacked regions — panels, cards, sections, slides — and then one\nparagraph per region, each opening on where that region sits.\n\n## Step 6 — Set every piece of text\n\nSkip this step if nothing in the image is meant to be read — a third of images have\nno legible text at all, and inventing signage for them is a mistake.\n\nOtherwise, for each string from your Step 4 list, in reading order, name where it sits,\nwhat it looks like, and what it says: `a bold black headline across the top reads \"…\"`.\n\nPut the string in straight double quotes, in its own script — Chinese, Russian,\nKorean, Japanese and Arabic text stays in Chinese, Russian, Korean, Japanese and\nArabic. Give its weight, colour, case and relative size. Describe a line break as a\nsecond line rather than putting a real newline inside the string. If a mark is not meant\nto be read — distant signage, a label behind glass, dense body copy — call it\nblurred, indistinct, or too small to read rather than inventing letters. If the image contains a chart\nor a table, its axes, tick labels, legend entries, series and cell values are text\ntoo: write them out.\n\n## Step 7 — Give the lighting its own sentence\n\nEvery image has light in it, and the description always accounts for it: the source,\nits direction, its quality, and the shadows and highlights it leaves. Soft diffused\ndaylight from a window on the left, hard overhead studio light, warm low sun, flat\neven ambient light for a diagram.\n\nOnce the contents are placed, give it a sentence of its own — `The lighting is …` —\nor, if the light is what makes a particular surface look the way it does, fold it into\nthat surface's sentence. Either way it is stated explicitly, not left implied.\n\n## Step 8 — Close with the whole frame\n\nEnd on a single sentence that steps back:\n\n`The overall composition ⟨is / uses / feels⟩ …`\n\n`The composition is …`, `The overall design …`, `The overall mood …`, `The overall\npalette …` and `The image has …` are the same move. Cover balance and symmetry, the\npalette, the style, and the mood in that one sentence. Write exactly one such\nsentence — do not follow it with a second summary.\n\n## Throughout\n\n**Size.** The description runs about twenty sentences and four to five hundred words,\nroughly twenty-five words a sentence. That is the same size whether the brief was three\nwords or three hundred: a dense frame with many regions and a lot of text runs longer, a\nsingle quiet subject runs shorter, but a thin brief never buys a thin description.\n\n**Observe, don't instruct.** Present tense, third person, declarative. No \"you\", no\n\"create\", no \"make sure\", no \"the AI should\". No quality boosters — no \"masterpiece\",\n\"8K\", \"highly detailed\", \"award-winning\".\n\n**Hedge what you cannot be certain of.** An observer describing a picture says\n\"appears to be\", \"likely\", \"suggesting\", and offers a pair — \"a notebook\nor a tablet\", \"wood or dark laminate\" — when the thing is genuinely ambiguous. Do\nthis often; it is the natural register here. Be flatly definite only about what the\nuser fixed.\n\n**Name colours with a modifier, almost never bare.** Deep navy, muted olive, pale\ncream, warm terracotta, soft dusty rose, blue-grey, off-white, charcoal, brownish-\ngreen. Hex codes only if the user gave them.\n\n**Give the material, not just the noun.** Brushed metal, matte plastic, glossy\nceramic, coarse linen, weathered wood, frosted glass, grain, scuffs, condensation,\nvisible brush strokes, paper fibre.\n\n**Enumerate; never summarise.** \"Several items\" and \"various decorations\" are not\ndescriptions. Say what each thing is. Write small counts as words — three, five,\ntwelve — and if something is partly hidden, say so and describe the visible part.\n\n**People get their observable surface.** Build, posture, where they are looking,\nexpression, hair, skin tone, and each garment with its colour and material. Age is a\nlife stage or a decade — a child, a teenager, a young adult, middle-aged, elderly,\nin her thirties — never a number of years. If a face is turned away or cropped, say\nthat instead of describing it.\n\n**Objects by class, not by brand.** A silver laptop, a mirrorless camera, a compact\nhatchback — unless the user named the brand. Photographic and design vocabulary is\nwelcome: shallow depth of field, bokeh, backlit, close-up, negative space,\ngrid, drop shadow.\n\n**Everything holds together physically.** Shadows fall away from the light, reflections\nmatch what is in front of the surface, scale is consistent between neighbouring\nobjects, and a surface reacts to what sits on it. If the user asked for something\nimpossible, describe it as the image shows it and let the rest of the scene stay\ncoherent around it.\n\n## Language\n\nThe description is always in English, whatever language the request arrives in. The\nonly exception is text shown inside the image, which stays in its own script.\n\n## Output format\n\n- Return the description and nothing else: one continuous paragraph of English, in a single line\nstarting on the very first character of your reply.\n- No JSON, no braces, no key names, no labels, no headings, no markdown, no code fences, and no quotation marks around the paragraph.\n- No preamble, no acknowledgement, no explanation, no summary, no notes, no closing remarks, no questions.\n- No ratio, no resolution, no pixel count, no timestamps.\n\nYour whole reply is used as the image prompt, so every extra word you add becomes part of the image.\n<|im_end|>" + ], + "widgets_values_named": { + "value": "<|im_start|>system\n# Image Prompt Rewriting Expert\n\nYou turn a user's image request into one long English paragraph that describes the\nfinished image as if you were looking at it, plus the aspect ratio it should be\nrendered at. You are not talking to the user and not talking to a renderer: you are\nan observer reporting what is in the frame.\n\nWork through the eight steps below in order. Each step commits one decision; later\nsteps never revise an earlier one.\n\n## Step 1 — Read the brief and split it in two\n\nList what the user has fixed and what they have left open.\n\nFixed, and it must survive into your description unchanged: every string of text\nthey want shown, every named object, every count, every stated colour, every stated\nposition, and the aspect ratio if they gave one. Copy their text strings character\nfor character, in their own script, including punctuation and spacing.\n\nA third thing they may give you is an instruction about the job rather than about the\npicture — \"use double quotes\", \"no hard-edged blocks\", \"4K, no noise\", \"make sure the\ntext is sharp\". That is not content. Obey it silently where it applies and never echo\nit: the description states what is in the frame, never what must be done.\n\nOpen, and you must decide it: everything they did not mention. A three-word request\nand a three-hundred-word request both become a description of the same size, so a\nshort brief means you are inventing most of the frame, not writing less.\n\n## Step 2 — Fix the frame\n\nDecide the orientation from the subject, then pick the ratio.\n\nIf the user states a ratio, use it. Otherwise: `3:2` for anything horizontal and\n`2:3` for anything vertical — these are the two defaults and cover most images.\nUse `1:1` for a square badge, icon, album cover or single centred emblem, `16:9`\nfor a wide cinematic or presentation frame, `1:2` or `9:16` for a phone screen or a\ntall standing banner. `3:4`, `2:1`, `21:9`, `4:3`, `9:21`, `4:5`, `3:1`, `5:4`,\n`1:3` exist but only when the subject or the user really calls for them.\n\nThe ratio lives only in the `wh_ratio` field. Never write a ratio, a resolution, or\na pixel count into the description itself.\n\n## Step 3 — Write the opening sentence\n\nOne sentence, around twenty words. Name the medium, the style, the subject, and the\nbackground or palette; usually name the orientation too:\n\n`The image is a ⟨vertical / wide / square / tall⟩ ⟨style⟩ ⟨photograph · poster · illustration · scene · portrait · infographic · close-up · graphic · page · card · sheet · logo⟩ of ⟨subject⟩, ⟨the background and its palette⟩.`\n\n`This is a …` or a bare `A vertical realistic photograph of …` work equally well. The\nmedium noun is the one part that is never omitted.\n\nThe style word goes here — realistic, photorealistic, minimalist, flat-vector,\ncinematic, watercolour, isometric, editorial, hand-drawn, 3D-rendered, retro. Name\nit once here; you may echo it in the closing sentence.\n\n## Step 4 — Inventory before you write\n\nBefore any more prose, settle two lists.\n\nEvery element that will appear, each with a place in the frame: upper-left,\nacross the top, on the far right, in the lower-third, in the centre, in front of,\nbehind, tucked into the corner. You will need eight to fourteen such positional\nphrases, about ten typically, and they must reach the corners, the edges and the\ncentre — not cluster in the middle.\n\nEvery piece of text that will be legible in the image, in reading order.\n\n## Step 5 — Walk the frame\n\nNow describe it in order. Which order depends on how the frame is filled.\n\n**If the frame is divided into regions** — a poster, a page, an interface, a layout, a\nwide scene with several things in it — walk the regions:\n\n1. The background and the surface it sits on — this comes immediately after the\n opening sentence, not at the end.\n2. The top band: headline, header bar, sky, ceiling, whatever occupies the top edge.\n3. Down and across the body of the frame: left side, then centre, then right side.\n Give each region one or two sentences.\n4. The bottom band: footer, foreground, ground plane, base row.\n\n**If one subject fills the frame** — a portrait, a close-up, a single object — walk\nthe subject instead: the background and how far it falls off, then the subject's pose\nand where it is placed in the frame, then head and face, then body and each garment or\nsurface, then what is held or touching it, then whatever little is left at the edges.\nKeep using positional phrases inside the subject — in the upper-left of the frame,\nbehind the left shoulder, along the lower edge — so the frame stays locatable.\n\nRoughly a third of your sentences should open on the positional phrase itself —\n\"On the right side of the frame, …\", \"In the upper-left corner, …\", \"Across the\nlower third, …\" — so the reader always knows where they are looking.\n\nKeep it to one paragraph. Break to a new paragraph only when the image is genuinely\nbuilt from stacked regions — panels, cards, sections, slides — and then one\nparagraph per region, each opening on where that region sits.\n\n## Step 6 — Set every piece of text\n\nSkip this step if nothing in the image is meant to be read — a third of images have\nno legible text at all, and inventing signage for them is a mistake.\n\nOtherwise, for each string from your Step 4 list, in reading order, name where it sits,\nwhat it looks like, and what it says: `a bold black headline across the top reads \"…\"`.\n\nPut the string in straight double quotes, in its own script — Chinese, Russian,\nKorean, Japanese and Arabic text stays in Chinese, Russian, Korean, Japanese and\nArabic. Give its weight, colour, case and relative size. Describe a line break as a\nsecond line rather than putting a real newline inside the string. If a mark is not meant\nto be read — distant signage, a label behind glass, dense body copy — call it\nblurred, indistinct, or too small to read rather than inventing letters. If the image contains a chart\nor a table, its axes, tick labels, legend entries, series and cell values are text\ntoo: write them out.\n\n## Step 7 — Give the lighting its own sentence\n\nEvery image has light in it, and the description always accounts for it: the source,\nits direction, its quality, and the shadows and highlights it leaves. Soft diffused\ndaylight from a window on the left, hard overhead studio light, warm low sun, flat\neven ambient light for a diagram.\n\nOnce the contents are placed, give it a sentence of its own — `The lighting is …` —\nor, if the light is what makes a particular surface look the way it does, fold it into\nthat surface's sentence. Either way it is stated explicitly, not left implied.\n\n## Step 8 — Close with the whole frame\n\nEnd on a single sentence that steps back:\n\n`The overall composition ⟨is / uses / feels⟩ …`\n\n`The composition is …`, `The overall design …`, `The overall mood …`, `The overall\npalette …` and `The image has …` are the same move. Cover balance and symmetry, the\npalette, the style, and the mood in that one sentence. Write exactly one such\nsentence — do not follow it with a second summary.\n\n## Throughout\n\n**Size.** The description runs about twenty sentences and four to five hundred words,\nroughly twenty-five words a sentence. That is the same size whether the brief was three\nwords or three hundred: a dense frame with many regions and a lot of text runs longer, a\nsingle quiet subject runs shorter, but a thin brief never buys a thin description.\n\n**Observe, don't instruct.** Present tense, third person, declarative. No \"you\", no\n\"create\", no \"make sure\", no \"the AI should\". No quality boosters — no \"masterpiece\",\n\"8K\", \"highly detailed\", \"award-winning\".\n\n**Hedge what you cannot be certain of.** An observer describing a picture says\n\"appears to be\", \"likely\", \"suggesting\", and offers a pair — \"a notebook\nor a tablet\", \"wood or dark laminate\" — when the thing is genuinely ambiguous. Do\nthis often; it is the natural register here. Be flatly definite only about what the\nuser fixed.\n\n**Name colours with a modifier, almost never bare.** Deep navy, muted olive, pale\ncream, warm terracotta, soft dusty rose, blue-grey, off-white, charcoal, brownish-\ngreen. Hex codes only if the user gave them.\n\n**Give the material, not just the noun.** Brushed metal, matte plastic, glossy\nceramic, coarse linen, weathered wood, frosted glass, grain, scuffs, condensation,\nvisible brush strokes, paper fibre.\n\n**Enumerate; never summarise.** \"Several items\" and \"various decorations\" are not\ndescriptions. Say what each thing is. Write small counts as words — three, five,\ntwelve — and if something is partly hidden, say so and describe the visible part.\n\n**People get their observable surface.** Build, posture, where they are looking,\nexpression, hair, skin tone, and each garment with its colour and material. Age is a\nlife stage or a decade — a child, a teenager, a young adult, middle-aged, elderly,\nin her thirties — never a number of years. If a face is turned away or cropped, say\nthat instead of describing it.\n\n**Objects by class, not by brand.** A silver laptop, a mirrorless camera, a compact\nhatchback — unless the user named the brand. Photographic and design vocabulary is\nwelcome: shallow depth of field, bokeh, backlit, close-up, negative space,\ngrid, drop shadow.\n\n**Everything holds together physically.** Shadows fall away from the light, reflections\nmatch what is in front of the surface, scale is consistent between neighbouring\nobjects, and a surface reacts to what sits on it. If the user asked for something\nimpossible, describe it as the image shows it and let the rest of the scene stay\ncoherent around it.\n\n## Language\n\nThe description is always in English, whatever language the request arrives in. The\nonly exception is text shown inside the image, which stays in its own script.\n\n## Output format\n\n- Return the description and nothing else: one continuous paragraph of English, in a single line\nstarting on the very first character of your reply.\n- No JSON, no braces, no key names, no labels, no headings, no markdown, no code fences, and no quotation marks around the paragraph.\n- No preamble, no acknowledgement, no explanation, no summary, no notes, no closing remarks, no questions.\n- No ratio, no resolution, no pixel count, no timestamps.\n\nYour whole reply is used as the image prompt, so every extra word you add becomes part of the image.\n<|im_end|>" + } + }, + { + "id": "459:480", + "type": "QwenImage21Cache", + "pos": [ + 1190, + 460 + ], + "size": [ + 270, + 90 + ], + "flags": {}, + "order": 12, + "mode": 0, + "inputs": [ + { + "localized_name": "model", + "name": "model", + "type": "MODEL", + "link": 17 + }, + { + "localized_name": "device", + "name": "device", + "type": "COMBO", + "widget": { + "name": "device" + }, + "link": null + }, + { + "localized_name": "dtype", + "name": "dtype", + "type": "COMBO", + "widget": { + "name": "dtype" + }, + "link": null + } + ], + "outputs": [ + { + "localized_name": "模型", + "name": "MODEL", + "type": "MODEL", + "links": [ + 7 + ] + } + ], + "properties": { + "Node name for S&R": "QwenImage21Cache", + "cnr_id": "comfy-core", + "ver": "0.38.0", + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + }, + "widgets_values": [ + "auto", + "default" + ], + "widgets_values_named": { + "device": "auto", + "dtype": "default" + } + }, + { + "id": "461", + "type": "SaveImageAdvanced", + "pos": [ + 1400, + 2460 + ], + "size": [ + 850, + 610 + ], + "flags": { + "pinned": true + }, + "order": 5, + "mode": 0, + "inputs": [ + { + "localized_name": "图像", + "name": "images", + "type": "IMAGE", + "link": 18 + }, + { + "localized_name": "文件名前缀", + "name": "filename_prefix", + "type": "STRING", + "widget": { + "name": "filename_prefix" + }, + "link": null + }, + { + "localized_name": "格式", + "name": "format", + "type": "COMFY_DYNAMICCOMBO_V3", + "widget": { + "name": "format" + }, + "link": null + }, + { + "localized_name": "位深度", + "name": "format.bit_depth", + "type": "COMBO", + "widget": { + "name": "format.bit_depth" + }, + "link": null + }, + { + "localized_name": "输入色彩空间", + "name": "format.input_color_space", + "type": "COMBO", + "widget": { + "name": "format.input_color_space" + }, + "link": null + } + ], + "outputs": [ + { + "localized_name": "images", + "name": "images", + "type": "IMAGE", + "links": [] + } + ], + "properties": { + "Node name for S&R": "SaveImageAdvanced", + "cnr_id": "comfy-core", + "ver": "0.38.0", + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + }, + "widgets_values": [ + "image/Qwen_image_2.1", + "png", + "8-bit", + "sRGB" + ], + "widgets_values_named": { + "filename_prefix": "image/Qwen_image_2.1", + "format": "png", + "format.bit_depth": "8-bit", + "format.input_color_space": "sRGB" + } + }, + { + "id": "463", + "type": "MarkdownNote", + "pos": [ + -350, + 2470 + ], + "size": [ + 420, + 620 + ], + "flags": {}, + "order": 1, + "mode": 0, + "inputs": [], + "outputs": [], + "title": "Note: Model links", + "properties": { + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + }, + "widgets_values": [ + "Guide: [Subgraph](https://docs.comfy.org/interface/features/subgraph)\n\n## Model Links\n\n- [Hugging Face:Comfy-Org/Qwen-Image-2.1](https://huggingface.co/Comfy-Org/Qwen-Image-2.1)\n- [ModelScope:Comfy-Org/Qwen-Image-2.1](https://modelscope.cn/models/Comfy-Org/Qwen-Image-2.1)\n\n**diffusion_models**\n\n- [qwen_image_2.1_int8_convrot.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/diffusion_models/qwen_image_2.1_int8_convrot.safetensors)\n\n**text_encoders**\n\n- [qwen3vl_8b_int8_convrot.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/text_encoders/qwen3vl_8b_int8_convrot.safetensors)\n- [qwen3.5_9b_qwen_image_2.1_pe_t2i.int8_convrot.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/text_encoders/qwen3.5_9b_qwen_image_2.1_pe_t2i.int8_convrot.safetensors)\n\n**vae**\n\n- [qwen_image_2.1_vae_bf16.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/vae/qwen_image_2.1_vae_bf16.safetensors)\n\n\n## Model Storage Location\n\n```\n📂 ComfyUI/\n├── 📂 models/\n│ ├── 📂 diffusion_models/\n│ │ └── qwen_image_2.1_int8_convrot.safetensors\n│ ├── 📂 text_encoders/\n│ │ ├── qwen3vl_8b_int8_convrot.safetensors\n│ │ └── qwen3.5_9b_qwen_image_2.1_pe_t2i.int8_convrot.safetensors\n│ └── 📂 vae/\n│ └── qwen_image_2.1_vae_bf16.safetensors\n```\n\n## Report Issue\n\nNote: Please update ComfyUI first ([guide](https://docs.comfy.org/installation/update_comfyui)) and prepare required models. Desktop/Cloud updates follow stable releases, so some nightly-supported models may not be available yet.\n\n- Cannot run / runtime errors: [ComfyUI/issues](https://github.com/comfyanonymous/ComfyUI/issues)\n- UI / frontend issues: [ComfyUI_frontend/issues](https://github.com/Comfy-Org/ComfyUI_frontend/issues)\n- Workflow issues: [workflow_templates/issues](https://github.com/Comfy-Org/workflow_templates/issues)\n" + ], + "widgets_values_named": { + "text": "Guide: [Subgraph](https://docs.comfy.org/interface/features/subgraph)\n\n## Model Links\n\n- [Hugging Face:Comfy-Org/Qwen-Image-2.1](https://huggingface.co/Comfy-Org/Qwen-Image-2.1)\n- [ModelScope:Comfy-Org/Qwen-Image-2.1](https://modelscope.cn/models/Comfy-Org/Qwen-Image-2.1)\n\n**diffusion_models**\n\n- [qwen_image_2.1_int8_convrot.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/diffusion_models/qwen_image_2.1_int8_convrot.safetensors)\n\n**text_encoders**\n\n- [qwen3vl_8b_int8_convrot.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/text_encoders/qwen3vl_8b_int8_convrot.safetensors)\n- [qwen3.5_9b_qwen_image_2.1_pe_t2i.int8_convrot.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/text_encoders/qwen3.5_9b_qwen_image_2.1_pe_t2i.int8_convrot.safetensors)\n\n**vae**\n\n- [qwen_image_2.1_vae_bf16.safetensors](https://huggingface.co/Comfy-Org/Qwen-Image-2.1/resolve/main/vae/qwen_image_2.1_vae_bf16.safetensors)\n\n\n## Model Storage Location\n\n```\n📂 ComfyUI/\n├── 📂 models/\n│ ├── 📂 diffusion_models/\n│ │ └── qwen_image_2.1_int8_convrot.safetensors\n│ ├── 📂 text_encoders/\n│ │ ├── qwen3vl_8b_int8_convrot.safetensors\n│ │ └── qwen3.5_9b_qwen_image_2.1_pe_t2i.int8_convrot.safetensors\n│ └── 📂 vae/\n│ └── qwen_image_2.1_vae_bf16.safetensors\n```\n\n## Report Issue\n\nNote: Please update ComfyUI first ([guide](https://docs.comfy.org/installation/update_comfyui)) and prepare required models. Desktop/Cloud updates follow stable releases, so some nightly-supported models may not be available yet.\n\n- Cannot run / runtime errors: [ComfyUI/issues](https://github.com/comfyanonymous/ComfyUI/issues)\n- UI / frontend issues: [ComfyUI_frontend/issues](https://github.com/Comfy-Org/ComfyUI_frontend/issues)\n- Workflow issues: [workflow_templates/issues](https://github.com/Comfy-Org/workflow_templates/issues)\n" + }, + "color": "#222", + "bgcolor": "#000" + }, + { + "id": "468", + "type": "MarkdownNote", + "pos": [ + 100, + 2470 + ], + "size": [ + 350, + 240 + ], + "flags": {}, + "order": 2, + "mode": 0, + "inputs": [], + "outputs": [], + "title": "Note: Usage", + "properties": { + "ue_properties": { + "widget_ue_connectable": {}, + "version": "7.8", + "input_ue_unconnectable": {} + } + }, + "widgets_values": [ + "## Size\nQwen Image 2.1 has native 2K (2048*2048) support for direct output.\n\nOutput size comes from ResolutionSelector (width/height). Default is 1 megapixel (1024*1024). For native 2K, set 1:1 and 4 megapixels (2048*2048). Prefer multiples of 32.\n\n## Transparent Image\n\nTo generate a transparent image, wrap the prompt like this and replace the middle with the subject:\n\n---\nThis is an RGBA format image with transparency. `[your description]`. The image has an alpha channel and a transparent background.\n\n---\nSave as PNG to keep the alpha channel.\n\n## Parameters\n\n- prompt: what to generate. For RGBA, see Note: transparent.\n- negative_prompt: unused while cfg is 1.\n- cfg: keep 1 for the Qwen Image 2.1 official path. Raise it only if you use a negative prompt.\n- steps: Qwen Image 2.1 official pipeline uses about 40-50 with euler. This template starts at 25. More advanced samplers need fewer steps.\n" + ], + "widgets_values_named": { + "text": "## Size\nQwen Image 2.1 has native 2K (2048*2048) support for direct output.\n\nOutput size comes from ResolutionSelector (width/height). Default is 1 megapixel (1024*1024). For native 2K, set 1:1 and 4 megapixels (2048*2048). Prefer multiples of 32.\n\n## Transparent Image\n\nTo generate a transparent image, wrap the prompt like this and replace the middle with the subject:\n\n---\nThis is an RGBA format image with transparency. `[your description]`. The image has an alpha channel and a transparent background.\n\n---\nSave as PNG to keep the alpha channel.\n\n## Parameters\n\n- prompt: what to generate. For RGBA, see Note: transparent.\n- negative_prompt: unused while cfg is 1.\n- cfg: keep 1 for the Qwen Image 2.1 official path. Raise it only if you use a negative prompt.\n- steps: Qwen Image 2.1 official pipeline uses about 40-50 with euler. This template starts at 25. More advanced samplers need fewer steps.\n" + }, + "color": "#222", + "bgcolor": "#000" + }, + { + "id": "483", + "type": "PrimitiveStringMultiline", + "pos": [ + 490, + 2480 + ], + "size": [ + 370, + 280 + ], + "flags": {}, + "order": 3, + "mode": 0, + "inputs": [ + { + "localized_name": "值", + "name": "value", + "type": "STRING", + "widget": { + "name": "value" + }, + "link": null + } + ], + "outputs": [ + { + "localized_name": "字符串", + "name": "STRING", + "type": "STRING", + "links": [ + 13, + 15 + ] + } + ], + "properties": { + "Node name for S&R": "PrimitiveStringMultiline", + "cnr_id": "comfy-core", + "ver": "0.38.0", + "ue_properties": { + "widget_ue_connectable": {}, + "input_ue_unconnectable": {}, + "version": "7.8" + } + }, + "widgets_values": [ + "角色设定卡,国风清雅,宣纸米白背景,淡青灰晕染。左侧为22岁中国女性面部特写,温婉沉静,鹅蛋脸,远山黛眉,杏眼深茶褐,淡樱粉唇,乌黑长发半绾青玉簪,鬓角碎发,淡水珍珠耳钉。右侧为人物三视图:正面、侧面、背面,全身站姿,7.5头身,双手交叠身前,身姿端庄。身穿雨过天青真丝提花缎改良旗袍,立领,短袖,收腰,A字裙摆,长至小腿中下部,两侧开衩至膝上,手绘水墨竹纹,竹节深青勾勒,竹叶淡青晕染,竹节形深青盘扣5枚,领口袖口开衩深青细滚边,同色真丝内衬,米白真丝绣花鞋低跟竹叶刺绣。右下角服装细节放大:领口竹节盘扣、水墨竹纹、袖口滚边、开衩暗扣、青玉簪、珍珠耳钉、绣花鞋、提花暗纹。底部色卡:雨过天青、深青、月白、玉色、墨青、珍珠白。画面留出文字框区域:左上标题框、左侧角色信息框、右侧三视图标注框、下方服装说明框、底部设计说明框。柔和自然光,工笔国风,超高细节,角色设计参考图,干净排版。" + ], + "widgets_values_named": { + "value": "角色设定卡,国风清雅,宣纸米白背景,淡青灰晕染。左侧为22岁中国女性面部特写,温婉沉静,鹅蛋脸,远山黛眉,杏眼深茶褐,淡樱粉唇,乌黑长发半绾青玉簪,鬓角碎发,淡水珍珠耳钉。右侧为人物三视图:正面、侧面、背面,全身站姿,7.5头身,双手交叠身前,身姿端庄。身穿雨过天青真丝提花缎改良旗袍,立领,短袖,收腰,A字裙摆,长至小腿中下部,两侧开衩至膝上,手绘水墨竹纹,竹节深青勾勒,竹叶淡青晕染,竹节形深青盘扣5枚,领口袖口开衩深青细滚边,同色真丝内衬,米白真丝绣花鞋低跟竹叶刺绣。右下角服装细节放大:领口竹节盘扣、水墨竹纹、袖口滚边、开衩暗扣、青玉簪、珍珠耳钉、绣花鞋、提花暗纹。底部色卡:雨过天青、深青、月白、玉色、墨青、珍珠白。画面留出文字框区域:左上标题框、左侧角色信息框、右侧三视图标注框、下方服装说明框、底部设计说明框。柔和自然光,工笔国风,超高细节,角色设计参考图,干净排版。" + } + } + ], + "links": [ + [ + 1, + "459:453", + 0, + "459:452", + 0, + "CLIP" + ], + [ + 2, + "459:472", + 0, + "459:452", + 3, + "STRING" + ], + [ + 3, + "13", + 0, + "459:456", + 0, + "INT" + ], + [ + 4, + "13", + 1, + "459:456", + 1, + "INT" + ], + [ + 5, + "459:458", + 0, + "459:457", + 0, + "LATENT" + ], + [ + 6, + "459:454", + 0, + "459:457", + 1, + "VAE" + ], + [ + 7, + "459:480", + 0, + "459:458", + 0, + "MODEL" + ], + [ + 8, + "459:452", + 0, + "459:458", + 1, + "CONDITIONING" + ], + [ + 9, + "459:452", + 1, + "459:458", + 2, + "CONDITIONING" + ], + [ + 10, + "459:456", + 0, + "459:458", + 3, + "LATENT" + ], + [ + 11, + "459:473", + 0, + "459:471", + 0, + "CLIP" + ], + [ + 12, + "459:475", + 0, + "459:471", + 4, + "STRING" + ], + [ + 13, + "483", + 0, + "459:471", + 5, + "STRING" + ], + [ + 14, + "459:474", + 0, + "459:472", + 0, + "STRING" + ], + [ + 15, + "483", + 0, + "459:474", + 0, + "STRING" + ], + [ + 16, + "459:471", + 0, + "459:474", + 1, + "STRING" + ], + [ + 17, + "459:451", + 0, + "459:480", + 0, + "MODEL" + ], + [ + 18, + "459:457", + 0, + "461", + 0, + "IMAGE" + ] + ], + "extra": { + "frontendVersion": "1.53.6", + "VHS_latentpreview": false, + "VHS_latentpreviewrate": 0, + "VHS_MetadataImage": true, + "VHS_KeepIntermediate": true, + "ue_links": [], + "links_added_by_ue": [], + "ds": { + "scale": 1.4255683750168113, + "offset": [ + -400.4819012765797, + -2387.517758813288 + ] + } + } + }, + "unresolved_boundaries": [ + { + "node_id": "459:458", + "input_slot": 4, + "input_name": "seed", + "boundary_instance": "459", + "slot": 10, + "name": "seed", + "type": "INT", + "reason": "多目标控件约束未知或不兼容" + }, + { + "node_id": "459:471", + "input_slot": 13, + "input_name": "sampling_mode.seed", + "boundary_instance": "459", + "slot": 10, + "name": "seed", + "type": "INT", + "reason": "多目标控件约束未知或不兼容" + } + ], + "resolved_boundaries": [ + { + "node_id": "459:451", + "input_slot": 0, + "input_name": "unet_name", + "boundary_instance": "459", + "slot": 11, + "name": "unet_name", + "type": "COMBO", + "value": "Qwen-Image\\qwen_image_2.1_bf16.safetensors", + "value_pointer": "/nodes/1/widgets_values/11", + "binding_name": "unet_name", + "binding_type": "COMBO", + "compatible": true, + "named_value_pointer": "/nodes/1/widgets_values_named/unet_name", + "target_pointer": "/definitions/subgraphs/0/nodes/0/inputs/0", + "precedence": [ + "external_link", + "promoted_value", + "internal_serializer" + ], + "api": "Qwen-Image/qwen_image_2.1_bf16.safetensors", + "differences": [ + { + "path": "", + "kind": "value", + "expected": "Qwen-Image/qwen_image_2.1_bf16.safetensors", + "actual": "Qwen-Image\\qwen_image_2.1_bf16.safetensors" + } + ] + }, + { + "node_id": "459:452", + "input_slot": 4, + "input_name": "negative_prompt", + "boundary_instance": "459", + "slot": 3, + "name": "negative_prompt", + "type": "STRING", + "value": "", + "value_pointer": "/nodes/1/widgets_values/3", + "binding_name": "negative_prompt", + "binding_type": "STRING", + "compatible": true, + "named_value_pointer": "/nodes/1/widgets_values_named/negative_prompt", + "target_pointer": "/definitions/subgraphs/0/nodes/1/inputs/4", + "precedence": [ + "external_link", + "promoted_value", + "internal_serializer" + ], + "api": "", + "differences": [] + }, + { + "node_id": "459:453", + "input_slot": 0, + "input_name": "clip_name", + "boundary_instance": "459", + "slot": 12, + "name": "clip_name", + "type": "COMBO", + "value": "qwen3vl_8b_int8_convrot.safetensors", + "value_pointer": "/nodes/1/widgets_values/12", + "binding_name": "clip_name", + "binding_type": "COMBO", + "compatible": true, + "named_value_pointer": "/nodes/1/widgets_values_named/clip_name", + "target_pointer": "/definitions/subgraphs/0/nodes/2/inputs/0", + "precedence": [ + "external_link", + "promoted_value", + "internal_serializer" + ], + "api": "qwen3vl_8b_int8_convrot.safetensors", + "differences": [] + }, + { + "node_id": "459:454", + "input_slot": 0, + "input_name": "vae_name", + "boundary_instance": "459", + "slot": 13, + "name": "vae_name", + "type": "COMBO", + "value": "qwen_image_2.1_vae_bf16.safetensors", + "value_pointer": "/nodes/1/widgets_values/13", + "binding_name": "vae_name", + "binding_type": "COMBO", + "compatible": true, + "named_value_pointer": "/nodes/1/widgets_values_named/vae_name", + "target_pointer": "/definitions/subgraphs/0/nodes/3/inputs/0", + "precedence": [ + "external_link", + "promoted_value", + "internal_serializer" + ], + "api": "qwen_image_2.1_vae_bf16.safetensors", + "differences": [] + }, + { + "node_id": "459:458", + "input_slot": 5, + "input_name": "steps", + "boundary_instance": "459", + "slot": 5, + "name": "steps", + "type": "INT", + "value": 25, + "value_pointer": "/nodes/1/widgets_values/5", + "binding_name": "steps", + "binding_type": "INT", + "compatible": true, + "named_value_pointer": "/nodes/1/widgets_values_named/steps", + "target_pointer": "/definitions/subgraphs/0/nodes/6/inputs/5", + "precedence": [ + "external_link", + "promoted_value", + "internal_serializer" + ], + "api": 25, + "differences": [] + }, + { + "node_id": "459:458", + "input_slot": 6, + "input_name": "cfg", + "boundary_instance": "459", + "slot": 4, + "name": "cfg", + "type": "FLOAT", + "value": 1, + "value_pointer": "/nodes/1/widgets_values/4", + "binding_name": "cfg", + "binding_type": "FLOAT", + "compatible": true, + "named_value_pointer": "/nodes/1/widgets_values_named/cfg", + "target_pointer": "/definitions/subgraphs/0/nodes/6/inputs/6", + "precedence": [ + "external_link", + "promoted_value", + "internal_serializer" + ], + "api": 1, + "differences": [] + }, + { + "node_id": "459:458", + "input_slot": 7, + "input_name": "sampler_name", + "boundary_instance": "459", + "slot": 8, + "name": "scheduler", + "type": "COMBO", + "value": "euler", + "value_pointer": "/nodes/1/widgets_values/8", + "binding_name": "scheduler", + "binding_type": "COMBO", + "compatible": true, + "named_value_pointer": "/nodes/1/widgets_values_named/scheduler", + "target_pointer": "/definitions/subgraphs/0/nodes/6/inputs/7", + "precedence": [ + "external_link", + "promoted_value", + "internal_serializer" + ], + "api": "euler", + "differences": [] + }, + { + "node_id": "459:458", + "input_slot": 8, + "input_name": "scheduler", + "boundary_instance": "459", + "slot": 9, + "name": "scheduler_1", + "type": "COMBO", + "value": "simple", + "value_pointer": "/nodes/1/widgets_values/9", + "binding_name": "scheduler_1", + "binding_type": "COMBO", + "compatible": true, + "named_value_pointer": "/nodes/1/widgets_values_named/scheduler_1", + "target_pointer": "/definitions/subgraphs/0/nodes/6/inputs/8", + "precedence": [ + "external_link", + "promoted_value", + "internal_serializer" + ], + "api": "simple", + "differences": [] + }, + { + "node_id": "459:471", + "input_slot": 15, + "input_name": "thinking", + "boundary_instance": "459", + "slot": 2, + "name": "thinking", + "type": "BOOLEAN", + "value": false, + "value_pointer": "/nodes/1/widgets_values/2", + "binding_name": "thinking", + "binding_type": "BOOLEAN", + "compatible": true, + "named_value_pointer": "/nodes/1/widgets_values_named/thinking", + "target_pointer": "/definitions/subgraphs/0/nodes/7/inputs/15", + "precedence": [ + "external_link", + "promoted_value", + "internal_serializer" + ], + "api": false, + "differences": [] + }, + { + "node_id": "459:473", + "input_slot": 0, + "input_name": "clip_name", + "boundary_instance": "459", + "slot": 14, + "name": "clip_name_1", + "type": "COMBO", + "value": "Qwen-Image\\qwen3.5_qwen_image_2.1_pe_t2i.int8_convrot.safetensors", + "value_pointer": "/nodes/1/widgets_values/14", + "binding_name": "clip_name_1", + "binding_type": "COMBO", + "compatible": true, + "named_value_pointer": "/nodes/1/widgets_values_named/clip_name_1", + "target_pointer": "/definitions/subgraphs/0/nodes/9/inputs/0", + "precedence": [ + "external_link", + "promoted_value", + "internal_serializer" + ], + "api": "Qwen-Image/qwen3.5_qwen_image_2.1_pe_t2i.int8_convrot.safetensors", + "differences": [ + { + "path": "", + "kind": "value", + "expected": "Qwen-Image/qwen3.5_qwen_image_2.1_pe_t2i.int8_convrot.safetensors", + "actual": "Qwen-Image\\qwen3.5_qwen_image_2.1_pe_t2i.int8_convrot.safetensors" + } + ] + }, + { + "node_id": "459:474", + "input_slot": 2, + "input_name": "switch", + "boundary_instance": "459", + "slot": 1, + "name": "switch", + "type": "BOOLEAN", + "value": true, + "value_pointer": "/nodes/1/widgets_values/1", + "binding_name": "switch", + "binding_type": "BOOLEAN", + "compatible": true, + "named_value_pointer": "/nodes/1/widgets_values_named/switch", + "target_pointer": "/definitions/subgraphs/0/nodes/10/inputs/2", + "precedence": [ + "external_link", + "promoted_value", + "internal_serializer" + ], + "api": true, + "differences": [] + }, + { + "node_id": "459:480", + "input_slot": 1, + "input_name": "device", + "boundary_instance": "459", + "slot": 15, + "name": "device", + "type": "COMBO", + "value": "auto", + "value_pointer": "/nodes/1/widgets_values/15", + "binding_name": "device", + "binding_type": "COMBO", + "compatible": true, + "named_value_pointer": "/nodes/1/widgets_values_named/device", + "target_pointer": "/definitions/subgraphs/0/nodes/12/inputs/1", + "precedence": [ + "external_link", + "promoted_value", + "internal_serializer" + ], + "api": "auto", + "differences": [] + }, + { + "node_id": "459:480", + "input_slot": 2, + "input_name": "dtype", + "boundary_instance": "459", + "slot": 16, + "name": "dtype_1", + "type": "COMBO", + "value": "default", + "value_pointer": "/nodes/1/widgets_values/16", + "binding_name": "dtype_1", + "binding_type": "COMBO", + "compatible": true, + "named_value_pointer": "/nodes/1/widgets_values_named/dtype_1", + "target_pointer": "/definitions/subgraphs/0/nodes/12/inputs/2", + "precedence": [ + "external_link", + "promoted_value", + "internal_serializer" + ], + "api": "default", + "differences": [] + } + ], + "node_types": [ + { + "node_id": "13", + "source_type": "ResolutionSelector", + "api_type": "ResolutionSelector", + "differences": [] + }, + { + "node_id": "459:451", + "source_type": "UNETLoader", + "api_type": "UNETLoader", + "differences": [] + }, + { + "node_id": "459:452", + "source_type": "TextEncodeQwenImage21", + "api_type": "TextEncodeQwenImage21", + "differences": [] + }, + { + "node_id": "459:453", + "source_type": "CLIPLoader", + "api_type": "CLIPLoader", + "differences": [] + }, + { + "node_id": "459:454", + "source_type": "VAELoader", + "api_type": "VAELoader", + "differences": [] + }, + { + "node_id": "459:456", + "source_type": "EmptyLatentImage", + "api_type": "EmptyLatentImage", + "differences": [] + }, + { + "node_id": "459:457", + "source_type": "VAEDecode", + "api_type": "VAEDecode", + "differences": [] + }, + { + "node_id": "459:458", + "source_type": "KSampler", + "api_type": "KSampler", + "differences": [] + }, + { + "node_id": "459:471", + "source_type": "TextGenerate", + "api_type": "TextGenerate", + "differences": [] + }, + { + "node_id": "459:472", + "source_type": "PreviewAny", + "api_type": "PreviewAny", + "differences": [] + }, + { + "node_id": "459:473", + "source_type": "CLIPLoader", + "api_type": "CLIPLoader", + "differences": [] + }, + { + "node_id": "459:474", + "source_type": "ComfySwitchNode", + "api_type": "ComfySwitchNode", + "differences": [] + }, + { + "node_id": "459:475", + "source_type": "PrimitiveStringMultiline", + "api_type": "PrimitiveStringMultiline", + "differences": [] + }, + { + "node_id": "459:480", + "source_type": "QwenImage21Cache", + "api_type": "QwenImage21Cache", + "differences": [] + }, + { + "node_id": "461", + "source_type": "SaveImageAdvanced", + "api_type": "SaveImageAdvanced", + "differences": [] + }, + { + "node_id": "483", + "source_type": "PrimitiveStringMultiline", + "api_type": "PrimitiveStringMultiline", + "differences": [] + } + ], + "metadata": [ + { + "node_id": "13", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "分辨率选择器", + "actual": "ResolutionSelector" + } + ] + }, + { + "node_id": "459:451", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "UNet加载器", + "actual": "UNETLoader" + } + ] + }, + { + "node_id": "459:452", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "文本编码 Qwen Image 2.1", + "actual": "TextEncodeQwenImage21" + } + ] + }, + { + "node_id": "459:453", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "加载CLIP", + "actual": "CLIPLoader" + } + ] + }, + { + "node_id": "459:454", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "加载VAE", + "actual": "VAELoader" + } + ] + }, + { + "node_id": "459:456", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "空Latent图像", + "actual": "EmptyLatentImage" + } + ] + }, + { + "node_id": "459:457", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "VAE解码", + "actual": "VAEDecode" + } + ] + }, + { + "node_id": "459:458", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "K采样器", + "actual": "KSampler" + } + ] + }, + { + "node_id": "459:471", + "differences": [] + }, + { + "node_id": "459:472", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "预览任意", + "actual": "PreviewAny" + } + ] + }, + { + "node_id": "459:473", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "加载CLIP", + "actual": "CLIPLoader" + } + ] + }, + { + "node_id": "459:474", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "切换", + "actual": "ComfySwitchNode" + } + ] + }, + { + "node_id": "459:475", + "differences": [] + }, + { + "node_id": "459:480", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "Qwen Image 2.1 缓存", + "actual": "QwenImage21Cache" + } + ] + }, + { + "node_id": "461", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "保存图像(高级)", + "actual": "SaveImageAdvanced" + } + ] + }, + { + "node_id": "483", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "字符串(多行)", + "actual": "PrimitiveStringMultiline" + } + ] + } + ], + "api_only_fields_for_supported_nodes": [], + "comparison_is_complete": false, + "executable": false, + "execution_verified": false + }, + { + "id": "05", + "selected_profile": "comfy-frontend-1.37.11-controlnet-aux-e8b689a-reference", + "source_path": "example_ComfyUI_workflows/4-视频生成/Minimax-h3/MiniMax_H3_导演台时间线素材_双采样潜空间放大_多分段拼接.json", + "source_sha256": "172eb8af3aca70082941427520fdcca06568957bab3d39101c5e9d6641b45e4a", + "api_sha256": "95a01c1ea27a8279a6dc202820505099a94161d91e0789189b61208b09007af8", + "source_frontend_version": "1.52.7", + "export_frontend_version": null, + "whole_prompt_available": false, + "candidate_prompt": null, + "whole_prompt_differences": null, + "whole_prompt_issues": [ + { + "code": "reference_frontend_mismatch", + "message": "源图声明的前端版本与固定参考不一致", + "node_id": "" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:SaveVideo", + "node_id": "10" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:ModelAttentionBackend", + "node_id": "19" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:MiniMaxH3SigmaShift", + "node_id": "18" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:BlockSparseAttention", + "node_id": "20" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:CLIPLoader", + "node_id": "2" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:VAELoader", + "node_id": "4" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:LoraLoaderModelOnly", + "node_id": "21" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:ModelPreviewOverrideKJ", + "node_id": "22" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:MiniMaxH3FiniteSegmentSampler", + "node_id": "8" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:CreateVideo", + "node_id": "9" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:ResolutionSelector", + "node_id": "24" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:MiniMaxH3TimelinePlanner", + "node_id": "7" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:VAELoader", + "node_id": "3" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:UNETLoader", + "node_id": "1" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:BasicScheduler", + "node_id": "5" + }, + { + "code": "reference_node_unsupported", + "message": "固定参考契约未覆盖节点:KSamplerSelect", + "node_id": "6" + }, + { + "code": "empty_prompt", + "message": "未得到可执行节点", + "node_id": "" + } + ], + "production_prompt_available": false, + "serialized_fields": [], + "topology_edges": [ + { + "node_id": "10", + "input": "video", + "via_reroute": false, + "source_reference": [ + "9", + 0 + ], + "api": [ + "9", + 0 + ], + "differences": [] + }, + { + "node_id": "19", + "input": "model", + "via_reroute": false, + "source_reference": [ + "18", + 0 + ], + "api": [ + "18", + 0 + ], + "differences": [] + }, + { + "node_id": "18", + "input": "model", + "via_reroute": false, + "source_reference": [ + "21", + 0 + ], + "api": [ + "21", + 0 + ], + "differences": [] + }, + { + "node_id": "20", + "input": "model", + "via_reroute": false, + "source_reference": [ + "19", + 0 + ], + "api": [ + "19", + 0 + ], + "differences": [] + }, + { + "node_id": "21", + "input": "model", + "via_reroute": false, + "source_reference": [ + "1", + 0 + ], + "api": [ + "1", + 0 + ], + "differences": [] + }, + { + "node_id": "22", + "input": "model", + "via_reroute": false, + "source_reference": [ + "20", + 0 + ], + "api": [ + "20", + 0 + ], + "differences": [] + }, + { + "node_id": "8", + "input": "model", + "via_reroute": false, + "source_reference": [ + "22", + 0 + ], + "api": [ + "22", + 0 + ], + "differences": [] + }, + { + "node_id": "8", + "input": "clip", + "via_reroute": false, + "source_reference": [ + "2", + 0 + ], + "api": [ + "2", + 0 + ], + "differences": [] + }, + { + "node_id": "8", + "input": "vae", + "via_reroute": false, + "source_reference": [ + "3", + 0 + ], + "api": [ + "3", + 0 + ], + "differences": [] + }, + { + "node_id": "8", + "input": "audio_vae", + "via_reroute": false, + "source_reference": [ + "4", + 0 + ], + "api": [ + "4", + 0 + ], + "differences": [] + }, + { + "node_id": "8", + "input": "finite_plan", + "via_reroute": false, + "source_reference": [ + "7", + 2 + ], + "api": [ + "7", + 2 + ], + "differences": [] + }, + { + "node_id": "8", + "input": "sampler", + "via_reroute": false, + "source_reference": [ + "6", + 0 + ], + "api": [ + "6", + 0 + ], + "differences": [] + }, + { + "node_id": "8", + "input": "sigmas", + "via_reroute": false, + "source_reference": [ + "5", + 0 + ], + "api": [ + "5", + 0 + ], + "differences": [] + }, + { + "node_id": "9", + "input": "images", + "via_reroute": false, + "source_reference": [ + "8", + 1 + ], + "api": [ + "8", + 1 + ], + "differences": [] + }, + { + "node_id": "9", + "input": "audio", + "via_reroute": false, + "source_reference": [ + "8", + 2 + ], + "api": [ + "8", + 2 + ], + "differences": [] + }, + { + "node_id": "7", + "input": "width", + "via_reroute": false, + "source_reference": [ + "24", + 0 + ], + "api": [ + "24", + 0 + ], + "differences": [] + }, + { + "node_id": "7", + "input": "height", + "via_reroute": false, + "source_reference": [ + "24", + 1 + ], + "api": [ + "24", + 1 + ], + "differences": [] + }, + { + "node_id": "5", + "input": "model", + "via_reroute": false, + "source_reference": [ + "22", + 0 + ], + "api": [ + "22", + 0 + ], + "differences": [] + } + ], + "unsupported_widget_nodes": [ + { + "node_id": "10", + "type": "SaveVideo", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "19", + "type": "ModelAttentionBackend", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "18", + "type": "MiniMaxH3SigmaShift", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "20", + "type": "BlockSparseAttention", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "2", + "type": "CLIPLoader", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "4", + "type": "VAELoader", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "21", + "type": "LoraLoaderModelOnly", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "22", + "type": "ModelPreviewOverrideKJ", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "8", + "type": "MiniMaxH3FiniteSegmentSampler", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "9", + "type": "CreateVideo", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "24", + "type": "ResolutionSelector", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "7", + "type": "MiniMaxH3TimelinePlanner", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "3", + "type": "VAELoader", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "1", + "type": "UNETLoader", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "5", + "type": "BasicScheduler", + "reason": "源节点声明与固定核心参考版本不符" + }, + { + "node_id": "6", + "type": "KSamplerSelect", + "reason": "源节点声明与固定核心参考版本不符" + } + ], + "diagnostic_graph": null, + "unresolved_boundaries": [], + "resolved_boundaries": [], + "node_types": [ + { + "node_id": "10", + "source_type": "SaveVideo", + "api_type": "SaveVideo", + "differences": [] + }, + { + "node_id": "19", + "source_type": "ModelAttentionBackend", + "api_type": "ModelAttentionBackend", + "differences": [] + }, + { + "node_id": "18", + "source_type": "MiniMaxH3SigmaShift", + "api_type": "MiniMaxH3SigmaShift", + "differences": [] + }, + { + "node_id": "20", + "source_type": "BlockSparseAttention", + "api_type": "BlockSparseAttention", + "differences": [] + }, + { + "node_id": "2", + "source_type": "CLIPLoader", + "api_type": "CLIPLoader", + "differences": [] + }, + { + "node_id": "4", + "source_type": "VAELoader", + "api_type": "VAELoader", + "differences": [] + }, + { + "node_id": "21", + "source_type": "LoraLoaderModelOnly", + "api_type": "LoraLoaderModelOnly", + "differences": [] + }, + { + "node_id": "22", + "source_type": "ModelPreviewOverrideKJ", + "api_type": "ModelPreviewOverrideKJ", + "differences": [] + }, + { + "node_id": "8", + "source_type": "MiniMaxH3FiniteSegmentSampler", + "api_type": "MiniMaxH3FiniteSegmentSampler", + "differences": [] + }, + { + "node_id": "9", + "source_type": "CreateVideo", + "api_type": "CreateVideo", + "differences": [] + }, + { + "node_id": "24", + "source_type": "ResolutionSelector", + "api_type": "ResolutionSelector", + "differences": [] + }, + { + "node_id": "7", + "source_type": "MiniMaxH3TimelinePlanner", + "api_type": "MiniMaxH3TimelinePlanner", + "differences": [] + }, + { + "node_id": "3", + "source_type": "VAELoader", + "api_type": "VAELoader", + "differences": [] + }, + { + "node_id": "1", + "source_type": "UNETLoader", + "api_type": "UNETLoader", + "differences": [] + }, + { + "node_id": "5", + "source_type": "BasicScheduler", + "api_type": "BasicScheduler", + "differences": [] + }, + { + "node_id": "6", + "source_type": "KSamplerSelect", + "api_type": "KSamplerSelect", + "differences": [] + } + ], + "metadata": [ + { + "node_id": "10", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "保存视频", + "actual": "SaveVideo" + } + ] + }, + { + "node_id": "19", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "模型注意力后端", + "actual": "ModelAttentionBackend" + } + ] + }, + { + "node_id": "18", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "MiniMax H3 Sigma Shift", + "actual": "MiniMaxH3SigmaShift" + } + ] + }, + { + "node_id": "20", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "模型稀疏注意力", + "actual": "BlockSparseAttention" + } + ] + }, + { + "node_id": "2", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "加载CLIP", + "actual": "CLIPLoader" + } + ] + }, + { + "node_id": "4", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "加载VAE", + "actual": "VAELoader" + } + ] + }, + { + "node_id": "21", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "LoRA加载器(仅模型)", + "actual": "LoraLoaderModelOnly" + } + ] + }, + { + "node_id": "22", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "Model Preview Override", + "actual": "ModelPreviewOverrideKJ" + } + ] + }, + { + "node_id": "8", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "MiniMax H3 有限分段采样", + "actual": "MiniMaxH3FiniteSegmentSampler" + } + ] + }, + { + "node_id": "9", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "创建视频", + "actual": "CreateVideo" + } + ] + }, + { + "node_id": "24", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "分辨率选择器", + "actual": "ResolutionSelector" + } + ] + }, + { + "node_id": "7", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "MiniMax H3 素材规划台", + "actual": "MiniMaxH3TimelinePlanner" + } + ] + }, + { + "node_id": "3", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "加载VAE", + "actual": "VAELoader" + } + ] + }, + { + "node_id": "1", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "UNet加载器", + "actual": "UNETLoader" + } + ] + }, + { + "node_id": "5", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "基本调度器", + "actual": "BasicScheduler" + } + ] + }, + { + "node_id": "6", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "K采样器选择", + "actual": "KSamplerSelect" + } + ] + } + ], + "api_only_fields_for_supported_nodes": [], + "comparison_is_complete": false, + "executable": false, + "execution_verified": false + }, + { + "id": "07", + "selected_profile": "comfy-frontend-1.48.6-structure-reference", + "source_path": "example_ComfyUI_workflows/6-动作迁移/Wan_Animate2_动作迁移_for循环长视频.json", + "source_sha256": "22b7853e22629822dd354b0b768e2961a53b4c2f480cfaceeaea9dc51c0f0d0b", + "api_sha256": "b1b4f6a6c02d8d21701943c67b62805b1210fed17e7e26b618c58e112ea1d70d", + "source_frontend_version": "1.48.6", + "export_frontend_version": null, + "whole_prompt_available": false, + "candidate_prompt": null, + "whole_prompt_differences": null, + "whole_prompt_issues": [ + { + "code": "reference_structure_invalid", + "message": "局部网络包含连线循环" + } + ], + "production_prompt_available": false, + "serialized_fields": [], + "topology_edges": [ + { + "node_id": "292", + "input": "video", + "status": "unsupported", + "reason": "静音/旁路不在追线参考契约内" + }, + { + "node_id": "291", + "input": "video", + "status": "unsupported", + "reason": "静音/旁路不在追线参考契约内" + }, + { + "node_id": "600", + "input": "AUDIO", + "via_reroute": false, + "source_reference": [ + "585", + 2 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "585", + 2 + ], + "kind": "type" + } + ] + }, + { + "node_id": "586", + "input": "video_info", + "via_reroute": false, + "source_reference": [ + "585", + 3 + ], + "api": [ + "585", + 3 + ], + "differences": [] + }, + { + "node_id": "604", + "input": "INT", + "via_reroute": false, + "source_reference": [ + "586", + 1 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "586", + 1 + ], + "kind": "type" + } + ] + }, + { + "node_id": "597", + "input": "FLOAT", + "via_reroute": false, + "source_reference": [ + "536", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "536", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "538", + "input": "source", + "via_reroute": false, + "source_reference": [ + "536", + 0 + ], + "api": [ + "536", + 0 + ], + "differences": [] + }, + { + "node_id": "536", + "input": "values.a", + "via_reroute": false, + "source_reference": [ + "605", + 0 + ], + "api": [ + "586", + 1 + ], + "differences": [ + { + "path": "/0", + "kind": "value", + "expected": "586", + "actual": "605" + }, + { + "path": "/1", + "kind": "value", + "expected": 1, + "actual": 0 + } + ] + }, + { + "node_id": "536", + "input": "values.b", + "via_reroute": false, + "source_reference": [ + "580", + 0 + ], + "api": [ + "580", + 0 + ], + "differences": [] + }, + { + "node_id": "477", + "input": "input", + "via_reroute": true, + "source_reference": [ + "189", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "189", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "477", + "input": "continue_motion", + "via_reroute": false, + "source_reference": [ + "606", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "606", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "477", + "input": "video_frame_offset_1", + "via_reroute": false, + "source_reference": [ + "606", + 1 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "606", + 1 + ], + "kind": "type" + } + ] + }, + { + "node_id": "477", + "input": "text", + "via_reroute": false, + "source_reference": [ + "583", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "583", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "477", + "input": "text_4", + "via_reroute": false, + "source_reference": [ + "584", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "584", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "477", + "input": "resize_type.width", + "via_reroute": false, + "source_reference": [ + "579", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "579", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "477", + "input": "resize_type.height_1", + "via_reroute": false, + "source_reference": [ + "579", + 1 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "579", + 1 + ], + "kind": "type" + } + ] + }, + { + "node_id": "477", + "input": "length", + "via_reroute": false, + "source_reference": [ + "580", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "580", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "477", + "input": "input_1", + "via_reroute": true, + "source_reference": [ + "585", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "585", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "261", + "input": "input", + "via_reroute": true, + "source_reference": [ + "189", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "189", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "261", + "input": "text", + "via_reroute": false, + "source_reference": [ + "583", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "583", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "261", + "input": "text_4", + "via_reroute": false, + "source_reference": [ + "584", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "584", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "261", + "input": "resize_type.width", + "via_reroute": false, + "source_reference": [ + "579", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "579", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "261", + "input": "resize_type.height_1", + "via_reroute": false, + "source_reference": [ + "579", + 1 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "579", + 1 + ], + "kind": "type" + } + ] + }, + { + "node_id": "261", + "input": "length", + "via_reroute": false, + "source_reference": [ + "580", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "580", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "261", + "input": "input_1", + "via_reroute": true, + "source_reference": [ + "585", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "585", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "607", + "input": "source", + "via_reroute": false, + "source_reference": [ + "606", + 3 + ], + "api": [ + "606:596", + 0 + ], + "differences": [ + { + "path": "/0", + "kind": "value", + "expected": "606:596", + "actual": "606" + }, + { + "path": "/1", + "kind": "value", + "expected": 0, + "actual": 3 + } + ] + }, + { + "node_id": "608", + "input": "*", + "via_reroute": false, + "source_reference": [ + "606", + 2 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "606", + 2 + ], + "kind": "type" + } + ] + }, + { + "node_id": "245", + "input": "images", + "via_reroute": false, + "source_reference": [ + "609", + 0 + ], + "api": [ + "606:599", + 2 + ], + "differences": [ + { + "path": "/0", + "kind": "value", + "expected": "606:599", + "actual": "609" + }, + { + "path": "/1", + "kind": "value", + "expected": 2, + "actual": 0 + } + ] + }, + { + "node_id": "245", + "input": "audio", + "via_reroute": false, + "source_reference": [ + "602", + 0 + ], + "api": [ + "585", + 2 + ], + "differences": [ + { + "path": "/0", + "kind": "value", + "expected": "585", + "actual": "602" + }, + { + "path": "/1", + "kind": "value", + "expected": 2, + "actual": 0 + } + ] + }, + { + "node_id": "245", + "input": "fps", + "via_reroute": false, + "source_reference": [ + "603", + 0 + ], + "api": [ + "586", + 0 + ], + "differences": [ + { + "path": "/0", + "kind": "value", + "expected": "586", + "actual": "603" + } + ] + }, + { + "node_id": "246", + "input": "video", + "via_reroute": false, + "source_reference": [ + "245", + 0 + ], + "api": [ + "245", + 0 + ], + "differences": [] + }, + { + "node_id": "601", + "input": "FLOAT", + "via_reroute": false, + "source_reference": [ + "586", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "586", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "606", + "input": "initial_value1", + "via_reroute": false, + "source_reference": [ + "261", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "261", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "606", + "input": "initial_value2", + "via_reroute": false, + "source_reference": [ + "261", + 1 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "261", + 1 + ], + "kind": "type" + } + ] + }, + { + "node_id": "606", + "input": "initial_value3", + "via_reroute": false, + "source_reference": [ + "261", + 2 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "261", + 2 + ], + "kind": "type" + } + ] + }, + { + "node_id": "606", + "input": "a", + "via_reroute": false, + "source_reference": [ + "598", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "598", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "606", + "input": "initial_value1_1", + "via_reroute": false, + "source_reference": [ + "477", + 0 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "477", + 0 + ], + "kind": "type" + } + ] + }, + { + "node_id": "606", + "input": "initial_value2_1", + "via_reroute": false, + "source_reference": [ + "477", + 1 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "477", + 1 + ], + "kind": "type" + } + ] + }, + { + "node_id": "606", + "input": "images.image1_1", + "via_reroute": false, + "source_reference": [ + "477", + 2 + ], + "api": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": [ + "477", + 2 + ], + "kind": "type" + } + ] + } + ], + "unsupported_widget_nodes": [ + { + "node_id": "292", + "type": "SaveVideo", + "reason": "未知参考版本" + }, + { + "node_id": "291", + "type": "79280513-53b2-4417-93f8-f3e116bb6736", + "reason": "未知参考版本" + }, + { + "node_id": "583", + "type": "PrimitiveStringMultiline", + "reason": "未知参考版本" + }, + { + "node_id": "580", + "type": "INTConstant", + "reason": "未知参考版本" + }, + { + "node_id": "579", + "type": "TTResolutionSelector", + "reason": "未知参考版本" + }, + { + "node_id": "600", + "type": "SetNode", + "reason": "未知参考版本" + }, + { + "node_id": "603", + "type": "GetNode", + "reason": "未知参考版本" + }, + { + "node_id": "602", + "type": "GetNode", + "reason": "未知参考版本" + }, + { + "node_id": "586", + "type": "VHS_VideoInfoLoaded", + "reason": "未知参考版本" + }, + { + "node_id": "604", + "type": "SetNode", + "reason": "未知参考版本" + }, + { + "node_id": "605", + "type": "GetNode", + "reason": "未知参考版本" + }, + { + "node_id": "584", + "type": "PrimitiveStringMultiline", + "reason": "未知参考版本" + }, + { + "node_id": "597", + "type": "SetNode", + "reason": "未知参考版本" + }, + { + "node_id": "538", + "type": "PreviewAny", + "reason": "未知参考版本" + }, + { + "node_id": "536", + "type": "ComfyMathExpression", + "reason": "未知参考版本" + }, + { + "node_id": "477", + "type": "b798a87e-23ec-483d-ab9b-6af5b298d0ad", + "reason": "未知参考版本" + }, + { + "node_id": "598", + "type": "GetNode", + "reason": "未知参考版本" + }, + { + "node_id": "261", + "type": "11706f8a-428d-4ef9-b24f-863f651c1b0b", + "reason": "未知参考版本" + }, + { + "node_id": "607", + "type": "PreviewAny", + "reason": "未知参考版本" + }, + { + "node_id": "608", + "type": "SetNode", + "reason": "未知参考版本" + }, + { + "node_id": "245", + "type": "CreateVideo", + "reason": "未知参考版本" + }, + { + "node_id": "609", + "type": "GetNode", + "reason": "未知参考版本" + }, + { + "node_id": "246", + "type": "SaveVideo", + "reason": "未知参考版本" + }, + { + "node_id": "601", + "type": "SetNode", + "reason": "未知参考版本" + }, + { + "node_id": "189", + "type": "LoadImage", + "reason": "未知参考版本" + }, + { + "node_id": "610", + "type": "Label (rgthree)", + "reason": "未知参考版本" + }, + { + "node_id": "606", + "type": "bb1c37c2-3479-48a8-88c0-11e7d43715d6", + "reason": "未知参考版本" + }, + { + "node_id": "585", + "type": "VHS_LoadVideo", + "reason": "未知参考版本" + } + ], + "diagnostic_graph": null, + "unresolved_boundaries": [], + "resolved_boundaries": [], + "node_types": [ + { + "node_id": "292", + "source_type": "SaveVideo", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "SaveVideo", + "kind": "type" + } + ] + }, + { + "node_id": "291", + "source_type": "79280513-53b2-4417-93f8-f3e116bb6736", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "79280513-53b2-4417-93f8-f3e116bb6736", + "kind": "type" + } + ] + }, + { + "node_id": "583", + "source_type": "PrimitiveStringMultiline", + "api_type": "PrimitiveStringMultiline", + "differences": [] + }, + { + "node_id": "580", + "source_type": "INTConstant", + "api_type": "INTConstant", + "differences": [] + }, + { + "node_id": "579", + "source_type": "TTResolutionSelector", + "api_type": "TTResolutionSelector", + "differences": [] + }, + { + "node_id": "600", + "source_type": "SetNode", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "SetNode", + "kind": "type" + } + ] + }, + { + "node_id": "603", + "source_type": "GetNode", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "GetNode", + "kind": "type" + } + ] + }, + { + "node_id": "602", + "source_type": "GetNode", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "GetNode", + "kind": "type" + } + ] + }, + { + "node_id": "586", + "source_type": "VHS_VideoInfoLoaded", + "api_type": "VHS_VideoInfoLoaded", + "differences": [] + }, + { + "node_id": "604", + "source_type": "SetNode", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "SetNode", + "kind": "type" + } + ] + }, + { + "node_id": "605", + "source_type": "GetNode", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "GetNode", + "kind": "type" + } + ] + }, + { + "node_id": "584", + "source_type": "PrimitiveStringMultiline", + "api_type": "PrimitiveStringMultiline", + "differences": [] + }, + { + "node_id": "597", + "source_type": "SetNode", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "SetNode", + "kind": "type" + } + ] + }, + { + "node_id": "538", + "source_type": "PreviewAny", + "api_type": "PreviewAny", + "differences": [] + }, + { + "node_id": "536", + "source_type": "ComfyMathExpression", + "api_type": "ComfyMathExpression", + "differences": [] + }, + { + "node_id": "477", + "source_type": "b798a87e-23ec-483d-ab9b-6af5b298d0ad", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "b798a87e-23ec-483d-ab9b-6af5b298d0ad", + "kind": "type" + } + ] + }, + { + "node_id": "598", + "source_type": "GetNode", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "GetNode", + "kind": "type" + } + ] + }, + { + "node_id": "261", + "source_type": "11706f8a-428d-4ef9-b24f-863f651c1b0b", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "11706f8a-428d-4ef9-b24f-863f651c1b0b", + "kind": "type" + } + ] + }, + { + "node_id": "607", + "source_type": "PreviewAny", + "api_type": "PreviewAny", + "differences": [] + }, + { + "node_id": "608", + "source_type": "SetNode", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "SetNode", + "kind": "type" + } + ] + }, + { + "node_id": "245", + "source_type": "CreateVideo", + "api_type": "CreateVideo", + "differences": [] + }, + { + "node_id": "609", + "source_type": "GetNode", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "GetNode", + "kind": "type" + } + ] + }, + { + "node_id": "246", + "source_type": "SaveVideo", + "api_type": "SaveVideo", + "differences": [] + }, + { + "node_id": "601", + "source_type": "SetNode", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "SetNode", + "kind": "type" + } + ] + }, + { + "node_id": "189", + "source_type": "LoadImage", + "api_type": "LoadImage", + "differences": [] + }, + { + "node_id": "610", + "source_type": "Label (rgthree)", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "Label (rgthree)", + "kind": "type" + } + ] + }, + { + "node_id": "606", + "source_type": "bb1c37c2-3479-48a8-88c0-11e7d43715d6", + "api_type": null, + "differences": [ + { + "path": "", + "expected": null, + "actual": "bb1c37c2-3479-48a8-88c0-11e7d43715d6", + "kind": "type" + } + ] + }, + { + "node_id": "585", + "source_type": "VHS_LoadVideo", + "api_type": "VHS_LoadVideo", + "differences": [] + } + ], + "metadata": [ + { + "node_id": "292", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "SaveVideo" + }, + "kind": "type" + } + ] + }, + { + "node_id": "291", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "79280513-53b2-4417-93f8-f3e116bb6736" + }, + "kind": "type" + } + ] + }, + { + "node_id": "583", + "differences": [] + }, + { + "node_id": "580", + "differences": [] + }, + { + "node_id": "579", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "TT分辨率选择器", + "actual": "TTResolutionSelector" + } + ] + }, + { + "node_id": "600", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "Set_音频" + }, + "kind": "type" + } + ] + }, + { + "node_id": "603", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "Get_帧率" + }, + "kind": "type" + } + ] + }, + { + "node_id": "602", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "Get_音频" + }, + "kind": "type" + } + ] + }, + { + "node_id": "586", + "differences": [] + }, + { + "node_id": "604", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "Set_动作视频帧数" + }, + "kind": "type" + } + ] + }, + { + "node_id": "605", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "Get_动作视频帧数" + }, + "kind": "type" + } + ] + }, + { + "node_id": "584", + "differences": [] + }, + { + "node_id": "597", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "Set_执行次数" + }, + "kind": "type" + } + ] + }, + { + "node_id": "538", + "differences": [] + }, + { + "node_id": "536", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "数学表达式", + "actual": "ComfyMathExpression" + } + ] + }, + { + "node_id": "477", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "b798a87e-23ec-483d-ab9b-6af5b298d0ad" + }, + "kind": "type" + } + ] + }, + { + "node_id": "598", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "Get_执行次数" + }, + "kind": "type" + } + ] + }, + { + "node_id": "261", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "11706f8a-428d-4ef9-b24f-863f651c1b0b" + }, + "kind": "type" + } + ] + }, + { + "node_id": "607", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "预览任意", + "actual": "PreviewAny" + } + ] + }, + { + "node_id": "608", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "Set_循环结果输出" + }, + "kind": "type" + } + ] + }, + { + "node_id": "245", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "创建视频", + "actual": "CreateVideo" + } + ] + }, + { + "node_id": "609", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "Get_循环结果输出" + }, + "kind": "type" + } + ] + }, + { + "node_id": "246", + "differences": [ + { + "path": "/title", + "kind": "value", + "expected": "保存视频", + "actual": "SaveVideo" + } + ] + }, + { + "node_id": "601", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "Set_帧率" + }, + "kind": "type" + } + ] + }, + { + "node_id": "189", + "differences": [] + }, + { + "node_id": "610", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "Wan_animate2_动作迁移 For循环长视频 by Bright" + }, + "kind": "type" + } + ] + }, + { + "node_id": "606", + "differences": [ + { + "path": "", + "expected": null, + "actual": { + "title": "bb1c37c2-3479-48a8-88c0-11e7d43715d6" + }, + "kind": "type" + } + ] + }, + { + "node_id": "585", + "differences": [] + } + ], + "api_only_fields_for_supported_nodes": [], + "comparison_is_complete": false, + "executable": false, + "execution_verified": false + } + ] +} diff --git a/docs/hel-892/promoted-evidence/source-refetch.json b/docs/hel-892/promoted-evidence/source-refetch.json new file mode 100644 index 00000000..810713ef --- /dev/null +++ b/docs/hel-892/promoted-evidence/source-refetch.json @@ -0,0 +1,155 @@ +{ + "authority": "public_reference_only", + "sources_verified": [ + { + "id": "1.37.11:src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts", + "sha256": "d51c760e6dbfedad73d86bd4836620130bc4f482a150fe1a9b9d3ad446da7543" + }, + { + "id": "1.48.7:src/stores/widgetValueStore.ts", + "sha256": "c2aa35433b597a922a86ff4880d2f00647c73cced7183611780013a121354b52" + }, + { + "id": "1.48.7:src/types/widgetId.ts", + "sha256": "7730cccc80b6436ce0316f589f11d71c459a128d44459473da274174134beb35" + }, + { + "id": "1.48.7:src/lib/litegraph/src/subgraph/SubgraphInput.ts", + "sha256": "f7683d58aa9e30a8a52448ad3771a6cf8550ac455eb4595f68b4a115be7bc4c5" + }, + { + "id": "1.48.7:src/lib/litegraph/src/LGraphNode.ts", + "sha256": "7d312ebe5182c4c69d45b5d5e4434dfd42405f72455310886acded76ce1d60ed" + }, + { + "id": "1.53.6:src/stores/widgetValueStore.ts", + "sha256": "ecf18bbc714070a7e67a00599ae09b711d1b6eebf5675dd7a6d56ef6d3a3e40a" + }, + { + "id": "1.53.6:src/types/widgetId.ts", + "sha256": "a803a0701d0f8f29e6af3e44519c8a6e8f6a45704416bc48cca56ea67bcc16af" + }, + { + "id": "1.53.6:src/lib/litegraph/src/subgraph/SubgraphInput.ts", + "sha256": "a729607feeae4afebbd9c25ada167987dd31984b9e7c1b378e9bccd0de124660" + }, + { + "id": "1.53.6:src/lib/litegraph/src/LGraphNode.ts", + "sha256": "01f7e784e32acef112a4b91d94f33253d7a898acc4796c8ab014500c1cd8d682" + }, + { + "id": "1.53.6:src/lib/litegraph/src/subgraph/promotedWidgetStoreProjection.ts", + "sha256": "2caccfda18d4715e1a4d77ce5026db3170d03b590dbe1ec15c41a47b9ea568c6" + }, + { + "id": "0.31.0:LICENSE", + "sha256": "3972dc9744f6499f0f9b2dbf76696f2ae7ad8af9b23dde66d6af86c9dfb36986" + }, + { + "id": "0.31.0:nodes.py", + "sha256": "aa7e2a87bb7c1b43273736eef9fcf4811cb55497c5bde2e201135b244b97431a" + }, + { + "id": "0.31.0:comfy_extras/nodes_qwen.py", + "sha256": "b8d18d9f897c4bd5a4b2651b30643bed277f1808e033c9c376dc21025fed00a5" + }, + { + "id": "0.38.0:LICENSE", + "sha256": "3972dc9744f6499f0f9b2dbf76696f2ae7ad8af9b23dde66d6af86c9dfb36986" + }, + { + "id": "0.38.0:nodes.py", + "sha256": "fe624b0c1b6a3cd124a2214e5700b61337589144c2f0668900a04f8ccc031e38" + }, + { + "id": "0.38.0:comfy_extras/nodes_minimax_music.py", + "sha256": "ff0c9d6dfcd63b76fea0bf52026ee408272dc7a1ffc43fa6ced2097608e25af5" + }, + { + "id": "0.38.0:comfy_extras/nodes_qwen.py", + "sha256": "54ce02aa9e167c0b497ce026ac6b558f539427d2d1ed4fc1fcc2ec8e6bc529da" + }, + { + "id": "0.31.0:comfy_extras/nodes_logic.py", + "sha256": "2cb1ce149ce616c0b12a67962ed7b799eb398fbcdeb20dcec4c5210eb6af6df1" + }, + { + "id": "0.31.0:comfy_extras/nodes_primitive.py", + "sha256": "ee3882214ebdd0d20c8061691075cebb1642c303e162f6d22ae525d75aa59b2d" + }, + { + "id": "0.31.0:comfy_extras/nodes_textgen.py", + "sha256": "b328e8a2dc89cfd3a93ab49c1be880a3e89ec4521eef506823753617c86c99e9" + }, + { + "id": "0.38.0:comfy_extras/nodes_logic.py", + "sha256": "6a146d3a814e37c65c9e749c2fde6d8f0ea8c1fc3f215cb249009e87303908bf" + }, + { + "id": "0.38.0:comfy_extras/nodes_primitive.py", + "sha256": "329963dd20fbf8985539b7b990780291f4b82ee9cfd42b96b571288b77eaa47a" + }, + { + "id": "0.38.0:comfy_extras/nodes_textgen.py", + "sha256": "ce41b40babe829cf8773aee3c3e43079f91205db921f6d964685e5fb0e5d7f54" + }, + { + "id": "1.48.7:src/renderer/extensions/vueNodes/widgets/composables/useStringWidget.ts", + "sha256": "9d015f423d90ac563f55c9f92d016948ac0e4496d660f6020bced8fa0e0d43a6" + }, + { + "id": "1.48.7:src/renderer/extensions/vueNodes/widgets/composables/useBooleanWidget.ts", + "sha256": "36f477f75561e0c7bfc2c6757906724f8ff2c8660ace26759f3f07493877fece" + }, + { + "id": "1.48.7:src/renderer/extensions/vueNodes/widgets/composables/useIntWidget.ts", + "sha256": "8720d5a8194c9987eddbb42d0e925bcbb20e96e94f52c5f21750ba90b2113e02" + }, + { + "id": "1.48.7:src/renderer/extensions/vueNodes/widgets/composables/useFloatWidget.ts", + "sha256": "8485d1edc17e911e65e38055e704045245f2de8310a54b87d429e7ed111accef" + }, + { + "id": "1.48.7:src/extensions/core/dynamicPrompts.ts", + "sha256": "31004dc7ba9b8ea5c8caa92ab3a15a0e63af8a822f57cb487079aad84d06f4bd" + }, + { + "id": "1.53.6:src/renderer/extensions/vueNodes/widgets/composables/useStringWidget.ts", + "sha256": "9d015f423d90ac563f55c9f92d016948ac0e4496d660f6020bced8fa0e0d43a6" + }, + { + "id": "1.53.6:src/renderer/extensions/vueNodes/widgets/composables/useBooleanWidget.ts", + "sha256": "36f477f75561e0c7bfc2c6757906724f8ff2c8660ace26759f3f07493877fece" + }, + { + "id": "1.53.6:src/renderer/extensions/vueNodes/widgets/composables/useIntWidget.ts", + "sha256": "8720d5a8194c9987eddbb42d0e925bcbb20e96e94f52c5f21750ba90b2113e02" + }, + { + "id": "1.53.6:src/renderer/extensions/vueNodes/widgets/composables/useFloatWidget.ts", + "sha256": "8485d1edc17e911e65e38055e704045245f2de8310a54b87d429e7ed111accef" + }, + { + "id": "1.53.6:src/extensions/core/dynamicPrompts.ts", + "sha256": "31004dc7ba9b8ea5c8caa92ab3a15a0e63af8a822f57cb487079aad84d06f4bd" + }, + { + "id": "1.48.7:src/renderer/extensions/vueNodes/widgets/composables/useComboWidget.ts", + "sha256": "4f2621d7b7ce770e2592ba0aad7b786a51de9d6d1e1cdc3efd51f79b22009c91" + }, + { + "id": "1.48.7:src/scripts/widgets.ts", + "sha256": "ecdcd4a6acade9718598aa93fa87901997e0befdcc7ffdc16a55a2de519871d2" + }, + { + "id": "1.53.6:src/renderer/extensions/vueNodes/widgets/composables/useComboWidget.ts", + "sha256": "1790b25076266242dc7e61e14e3496c80476317dbe4acad6635063b638f79065" + }, + { + "id": "1.53.6:src/scripts/widgets.ts", + "sha256": "932a143a1a48c93aa3bee43b6dc3f932cd7f9a946802530650b4acdd41d36bd5" + } + ], + "upstream_code_executed": false, + "target_version_match": "unknown" +} diff --git a/docs/hel-892/promoted-evidence/source-verification.json b/docs/hel-892/promoted-evidence/source-verification.json new file mode 100644 index 00000000..810713ef --- /dev/null +++ b/docs/hel-892/promoted-evidence/source-verification.json @@ -0,0 +1,155 @@ +{ + "authority": "public_reference_only", + "sources_verified": [ + { + "id": "1.37.11:src/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget.ts", + "sha256": "d51c760e6dbfedad73d86bd4836620130bc4f482a150fe1a9b9d3ad446da7543" + }, + { + "id": "1.48.7:src/stores/widgetValueStore.ts", + "sha256": "c2aa35433b597a922a86ff4880d2f00647c73cced7183611780013a121354b52" + }, + { + "id": "1.48.7:src/types/widgetId.ts", + "sha256": "7730cccc80b6436ce0316f589f11d71c459a128d44459473da274174134beb35" + }, + { + "id": "1.48.7:src/lib/litegraph/src/subgraph/SubgraphInput.ts", + "sha256": "f7683d58aa9e30a8a52448ad3771a6cf8550ac455eb4595f68b4a115be7bc4c5" + }, + { + "id": "1.48.7:src/lib/litegraph/src/LGraphNode.ts", + "sha256": "7d312ebe5182c4c69d45b5d5e4434dfd42405f72455310886acded76ce1d60ed" + }, + { + "id": "1.53.6:src/stores/widgetValueStore.ts", + "sha256": "ecf18bbc714070a7e67a00599ae09b711d1b6eebf5675dd7a6d56ef6d3a3e40a" + }, + { + "id": "1.53.6:src/types/widgetId.ts", + "sha256": "a803a0701d0f8f29e6af3e44519c8a6e8f6a45704416bc48cca56ea67bcc16af" + }, + { + "id": "1.53.6:src/lib/litegraph/src/subgraph/SubgraphInput.ts", + "sha256": "a729607feeae4afebbd9c25ada167987dd31984b9e7c1b378e9bccd0de124660" + }, + { + "id": "1.53.6:src/lib/litegraph/src/LGraphNode.ts", + "sha256": "01f7e784e32acef112a4b91d94f33253d7a898acc4796c8ab014500c1cd8d682" + }, + { + "id": "1.53.6:src/lib/litegraph/src/subgraph/promotedWidgetStoreProjection.ts", + "sha256": "2caccfda18d4715e1a4d77ce5026db3170d03b590dbe1ec15c41a47b9ea568c6" + }, + { + "id": "0.31.0:LICENSE", + "sha256": "3972dc9744f6499f0f9b2dbf76696f2ae7ad8af9b23dde66d6af86c9dfb36986" + }, + { + "id": "0.31.0:nodes.py", + "sha256": "aa7e2a87bb7c1b43273736eef9fcf4811cb55497c5bde2e201135b244b97431a" + }, + { + "id": "0.31.0:comfy_extras/nodes_qwen.py", + "sha256": "b8d18d9f897c4bd5a4b2651b30643bed277f1808e033c9c376dc21025fed00a5" + }, + { + "id": "0.38.0:LICENSE", + "sha256": "3972dc9744f6499f0f9b2dbf76696f2ae7ad8af9b23dde66d6af86c9dfb36986" + }, + { + "id": "0.38.0:nodes.py", + "sha256": "fe624b0c1b6a3cd124a2214e5700b61337589144c2f0668900a04f8ccc031e38" + }, + { + "id": "0.38.0:comfy_extras/nodes_minimax_music.py", + "sha256": "ff0c9d6dfcd63b76fea0bf52026ee408272dc7a1ffc43fa6ced2097608e25af5" + }, + { + "id": "0.38.0:comfy_extras/nodes_qwen.py", + "sha256": "54ce02aa9e167c0b497ce026ac6b558f539427d2d1ed4fc1fcc2ec8e6bc529da" + }, + { + "id": "0.31.0:comfy_extras/nodes_logic.py", + "sha256": "2cb1ce149ce616c0b12a67962ed7b799eb398fbcdeb20dcec4c5210eb6af6df1" + }, + { + "id": "0.31.0:comfy_extras/nodes_primitive.py", + "sha256": "ee3882214ebdd0d20c8061691075cebb1642c303e162f6d22ae525d75aa59b2d" + }, + { + "id": "0.31.0:comfy_extras/nodes_textgen.py", + "sha256": "b328e8a2dc89cfd3a93ab49c1be880a3e89ec4521eef506823753617c86c99e9" + }, + { + "id": "0.38.0:comfy_extras/nodes_logic.py", + "sha256": "6a146d3a814e37c65c9e749c2fde6d8f0ea8c1fc3f215cb249009e87303908bf" + }, + { + "id": "0.38.0:comfy_extras/nodes_primitive.py", + "sha256": "329963dd20fbf8985539b7b990780291f4b82ee9cfd42b96b571288b77eaa47a" + }, + { + "id": "0.38.0:comfy_extras/nodes_textgen.py", + "sha256": "ce41b40babe829cf8773aee3c3e43079f91205db921f6d964685e5fb0e5d7f54" + }, + { + "id": "1.48.7:src/renderer/extensions/vueNodes/widgets/composables/useStringWidget.ts", + "sha256": "9d015f423d90ac563f55c9f92d016948ac0e4496d660f6020bced8fa0e0d43a6" + }, + { + "id": "1.48.7:src/renderer/extensions/vueNodes/widgets/composables/useBooleanWidget.ts", + "sha256": "36f477f75561e0c7bfc2c6757906724f8ff2c8660ace26759f3f07493877fece" + }, + { + "id": "1.48.7:src/renderer/extensions/vueNodes/widgets/composables/useIntWidget.ts", + "sha256": "8720d5a8194c9987eddbb42d0e925bcbb20e96e94f52c5f21750ba90b2113e02" + }, + { + "id": "1.48.7:src/renderer/extensions/vueNodes/widgets/composables/useFloatWidget.ts", + "sha256": "8485d1edc17e911e65e38055e704045245f2de8310a54b87d429e7ed111accef" + }, + { + "id": "1.48.7:src/extensions/core/dynamicPrompts.ts", + "sha256": "31004dc7ba9b8ea5c8caa92ab3a15a0e63af8a822f57cb487079aad84d06f4bd" + }, + { + "id": "1.53.6:src/renderer/extensions/vueNodes/widgets/composables/useStringWidget.ts", + "sha256": "9d015f423d90ac563f55c9f92d016948ac0e4496d660f6020bced8fa0e0d43a6" + }, + { + "id": "1.53.6:src/renderer/extensions/vueNodes/widgets/composables/useBooleanWidget.ts", + "sha256": "36f477f75561e0c7bfc2c6757906724f8ff2c8660ace26759f3f07493877fece" + }, + { + "id": "1.53.6:src/renderer/extensions/vueNodes/widgets/composables/useIntWidget.ts", + "sha256": "8720d5a8194c9987eddbb42d0e925bcbb20e96e94f52c5f21750ba90b2113e02" + }, + { + "id": "1.53.6:src/renderer/extensions/vueNodes/widgets/composables/useFloatWidget.ts", + "sha256": "8485d1edc17e911e65e38055e704045245f2de8310a54b87d429e7ed111accef" + }, + { + "id": "1.53.6:src/extensions/core/dynamicPrompts.ts", + "sha256": "31004dc7ba9b8ea5c8caa92ab3a15a0e63af8a822f57cb487079aad84d06f4bd" + }, + { + "id": "1.48.7:src/renderer/extensions/vueNodes/widgets/composables/useComboWidget.ts", + "sha256": "4f2621d7b7ce770e2592ba0aad7b786a51de9d6d1e1cdc3efd51f79b22009c91" + }, + { + "id": "1.48.7:src/scripts/widgets.ts", + "sha256": "ecdcd4a6acade9718598aa93fa87901997e0befdcc7ffdc16a55a2de519871d2" + }, + { + "id": "1.53.6:src/renderer/extensions/vueNodes/widgets/composables/useComboWidget.ts", + "sha256": "1790b25076266242dc7e61e14e3496c80476317dbe4acad6635063b638f79065" + }, + { + "id": "1.53.6:src/scripts/widgets.ts", + "sha256": "932a143a1a48c93aa3bee43b6dc3f932cd7f9a946802530650b4acdd41d36bd5" + } + ], + "upstream_code_executed": false, + "target_version_match": "unknown" +} diff --git a/docs/hel-892/promoted-evidence/summary.json b/docs/hel-892/promoted-evidence/summary.json new file mode 100644 index 00000000..4ec9831a --- /dev/null +++ b/docs/hel-892/promoted-evidence/summary.json @@ -0,0 +1,475 @@ +{ + "increment_base": "5e5cc03395aabd9511744be8933cd587ba0cacaa", + "tested_code_commit": "7d4e3941ed262fdf32c09032488ec70d2bf83184", + "code_sha256": { + "calliope-backend/scripts/audit_reference_conversion.py": "86406369bb7d52be4bb6f4d23fcc6c87bef23198ceeb4aded3e73a6122efaf42", + "calliope-backend/src/calliope/comfyui/serialization_reference.py": "711ebfe4b35bb008e66b756c870b45128a486456babb3b1b9a330c17c33dd423", + "calliope-backend/src/calliope/comfyui/structure_reference.py": "6c61d05c3a4667ab420c2ba0151aa913f6ad58a3a7baeefe3cf6bede388613b1", + "calliope-backend/src/calliope/comfyui/ui2api.py": "8710466cf9dfea2b6f87988e9b66a2c94d5f803ce0d67dc85ddd9a43159303b0", + "calliope-backend/tests/test_promoted_preview_reference.py": "d6914f9a62aea78c9b9d398658aa1866c7d57b14a118164827cff25852e007aa" + }, + "tests": { + "passed": 216, + "failed": 0, + "warnings": 1, + "new_specialized_tests": 38 + }, + "pointers_verified": [ + { + "case": "04", + "node_id": "459:451", + "field": "unet_name", + "pointer": "/nodes/1/widgets_values/11" + }, + { + "case": "04", + "node_id": "459:451", + "field": "unet_name", + "pointer": "/nodes/1/widgets_values_named/unet_name" + }, + { + "case": "04", + "node_id": "459:452", + "field": "negative_prompt", + "pointer": "/nodes/1/widgets_values/3" + }, + { + "case": "04", + "node_id": "459:452", + "field": "negative_prompt", + "pointer": "/nodes/1/widgets_values_named/negative_prompt" + }, + { + "case": "04", + "node_id": "459:453", + "field": "clip_name", + "pointer": "/nodes/1/widgets_values/12" + }, + { + "case": "04", + "node_id": "459:453", + "field": "clip_name", + "pointer": "/nodes/1/widgets_values_named/clip_name" + }, + { + "case": "04", + "node_id": "459:454", + "field": "vae_name", + "pointer": "/nodes/1/widgets_values/13" + }, + { + "case": "04", + "node_id": "459:454", + "field": "vae_name", + "pointer": "/nodes/1/widgets_values_named/vae_name" + }, + { + "case": "04", + "node_id": "459:458", + "field": "steps", + "pointer": "/nodes/1/widgets_values/5" + }, + { + "case": "04", + "node_id": "459:458", + "field": "steps", + "pointer": "/nodes/1/widgets_values_named/steps" + }, + { + "case": "04", + "node_id": "459:458", + "field": "cfg", + "pointer": "/nodes/1/widgets_values/4" + }, + { + "case": "04", + "node_id": "459:458", + "field": "cfg", + "pointer": "/nodes/1/widgets_values_named/cfg" + }, + { + "case": "04", + "node_id": "459:458", + "field": "sampler_name", + "pointer": "/nodes/1/widgets_values/8" + }, + { + "case": "04", + "node_id": "459:458", + "field": "sampler_name", + "pointer": "/nodes/1/widgets_values_named/scheduler" + }, + { + "case": "04", + "node_id": "459:458", + "field": "scheduler", + "pointer": "/nodes/1/widgets_values/9" + }, + { + "case": "04", + "node_id": "459:458", + "field": "scheduler", + "pointer": "/nodes/1/widgets_values_named/scheduler_1" + }, + { + "case": "04", + "node_id": "459:471", + "field": "thinking", + "pointer": "/nodes/1/widgets_values/2" + }, + { + "case": "04", + "node_id": "459:471", + "field": "thinking", + "pointer": "/nodes/1/widgets_values_named/thinking" + }, + { + "case": "04", + "node_id": "459:473", + "field": "clip_name", + "pointer": "/nodes/1/widgets_values/14" + }, + { + "case": "04", + "node_id": "459:473", + "field": "clip_name", + "pointer": "/nodes/1/widgets_values_named/clip_name_1" + }, + { + "case": "04", + "node_id": "459:474", + "field": "switch", + "pointer": "/nodes/1/widgets_values/1" + }, + { + "case": "04", + "node_id": "459:474", + "field": "switch", + "pointer": "/nodes/1/widgets_values_named/switch" + }, + { + "case": "04", + "node_id": "459:480", + "field": "device", + "pointer": "/nodes/1/widgets_values/15" + }, + { + "case": "04", + "node_id": "459:480", + "field": "device", + "pointer": "/nodes/1/widgets_values_named/device" + }, + { + "case": "04", + "node_id": "459:480", + "field": "dtype", + "pointer": "/nodes/1/widgets_values/16" + }, + { + "case": "04", + "node_id": "459:480", + "field": "dtype", + "pointer": "/nodes/1/widgets_values_named/dtype_1" + } + ], + "cases": [ + { + "id": "01", + "prompt": true, + "resolved": 0, + "unresolved": 0, + "unsupported_whole_node_serializers": [] + }, + { + "id": "02", + "prompt": true, + "resolved": 0, + "unresolved": 0, + "unsupported_whole_node_serializers": [] + }, + { + "id": "03", + "prompt": false, + "resolved": 0, + "unresolved": 8, + "unsupported_whole_node_serializers": [ + { + "node_id": "35", + "type": "SaveAudioAdvanced" + }, + { + "node_id": "37:13", + "type": "MiniMaxMusic3TextEncode" + }, + { + "node_id": "37:10", + "type": "ConditioningZeroOut" + }, + { + "node_id": "37:15", + "type": "EmptyMiniMaxMusic3LatentAudio" + }, + { + "node_id": "37:9", + "type": "KSampler" + }, + { + "node_id": "37:12", + "type": "VAEDecodeAudio" + }, + { + "node_id": "37:38", + "type": "SeedNode" + }, + { + "node_id": "37:42", + "type": "VAEDecodeAudioTiled" + }, + { + "node_id": "37:43", + "type": "ComfySwitchNode" + } + ] + }, + { + "id": "04", + "prompt": false, + "resolved": 13, + "unresolved": 2, + "unsupported_whole_node_serializers": [ + { + "node_id": "13", + "type": "ResolutionSelector" + }, + { + "node_id": "459:452", + "type": "TextEncodeQwenImage21" + }, + { + "node_id": "459:457", + "type": "VAEDecode" + }, + { + "node_id": "459:458", + "type": "KSampler" + }, + { + "node_id": "459:471", + "type": "TextGenerate" + }, + { + "node_id": "459:472", + "type": "PreviewAny" + }, + { + "node_id": "459:474", + "type": "ComfySwitchNode" + }, + { + "node_id": "461", + "type": "SaveImageAdvanced" + } + ] + }, + { + "id": "05", + "prompt": false, + "resolved": 0, + "unresolved": 0, + "unsupported_whole_node_serializers": [ + { + "node_id": "10", + "type": "SaveVideo" + }, + { + "node_id": "19", + "type": "ModelAttentionBackend" + }, + { + "node_id": "18", + "type": "MiniMaxH3SigmaShift" + }, + { + "node_id": "20", + "type": "BlockSparseAttention" + }, + { + "node_id": "2", + "type": "CLIPLoader" + }, + { + "node_id": "4", + "type": "VAELoader" + }, + { + "node_id": "21", + "type": "LoraLoaderModelOnly" + }, + { + "node_id": "22", + "type": "ModelPreviewOverrideKJ" + }, + { + "node_id": "8", + "type": "MiniMaxH3FiniteSegmentSampler" + }, + { + "node_id": "9", + "type": "CreateVideo" + }, + { + "node_id": "24", + "type": "ResolutionSelector" + }, + { + "node_id": "7", + "type": "MiniMaxH3TimelinePlanner" + }, + { + "node_id": "3", + "type": "VAELoader" + }, + { + "node_id": "1", + "type": "UNETLoader" + }, + { + "node_id": "5", + "type": "BasicScheduler" + }, + { + "node_id": "6", + "type": "KSamplerSelect" + } + ] + }, + { + "id": "07", + "prompt": false, + "resolved": 0, + "unresolved": 0, + "unsupported_whole_node_serializers": [ + { + "node_id": "292", + "type": "SaveVideo" + }, + { + "node_id": "291", + "type": "79280513-53b2-4417-93f8-f3e116bb6736" + }, + { + "node_id": "583", + "type": "PrimitiveStringMultiline" + }, + { + "node_id": "580", + "type": "INTConstant" + }, + { + "node_id": "579", + "type": "TTResolutionSelector" + }, + { + "node_id": "600", + "type": "SetNode" + }, + { + "node_id": "603", + "type": "GetNode" + }, + { + "node_id": "602", + "type": "GetNode" + }, + { + "node_id": "586", + "type": "VHS_VideoInfoLoaded" + }, + { + "node_id": "604", + "type": "SetNode" + }, + { + "node_id": "605", + "type": "GetNode" + }, + { + "node_id": "584", + "type": "PrimitiveStringMultiline" + }, + { + "node_id": "597", + "type": "SetNode" + }, + { + "node_id": "538", + "type": "PreviewAny" + }, + { + "node_id": "536", + "type": "ComfyMathExpression" + }, + { + "node_id": "477", + "type": "b798a87e-23ec-483d-ab9b-6af5b298d0ad" + }, + { + "node_id": "598", + "type": "GetNode" + }, + { + "node_id": "261", + "type": "11706f8a-428d-4ef9-b24f-863f651c1b0b" + }, + { + "node_id": "607", + "type": "PreviewAny" + }, + { + "node_id": "608", + "type": "SetNode" + }, + { + "node_id": "245", + "type": "CreateVideo" + }, + { + "node_id": "609", + "type": "GetNode" + }, + { + "node_id": "246", + "type": "SaveVideo" + }, + { + "node_id": "601", + "type": "SetNode" + }, + { + "node_id": "189", + "type": "LoadImage" + }, + { + "node_id": "610", + "type": "Label (rgthree)" + }, + { + "node_id": "606", + "type": "bb1c37c2-3479-48a8-88c0-11e7d43715d6" + }, + { + "node_id": "585", + "type": "VHS_LoadVideo" + } + ] + } + ], + "production_eligibility_relaxed": false, + "full_goal_completed": false, + "execution_verified": false, + "historical_only": [ + "178 (prior batch)", + "142", + "865 passed / 5 baseline failed / 6 skipped" + ] +} diff --git a/docs/hel-892/promoted-evidence/tests.txt b/docs/hel-892/promoted-evidence/tests.txt new file mode 100644 index 00000000..c8eee9d2 --- /dev/null +++ b/docs/hel-892/promoted-evidence/tests.txt @@ -0,0 +1,10 @@ +........................................................................ [ 33%] +........................................................................ [ 66%] +........................................................................ [100%] +=============================== warnings summary =============================== +calliope-backend/.venv/lib/python3.11/site-packages/starlette/testclient.py:53 + /home/xiaomo/multica_workspaces/hello-af23464d222e/hel-892-4d084da46a89/workdir/aigc-home/calliope-backend/.venv/lib/python3.11/site-packages/starlette/testclient.py:53: DeprecationWarning: The anyio.abc.BlockingPortal alias is deprecated, use anyio.from_thread.BlockingPortal instead. + _PortalFactoryType = Callable[[], AbstractContextManager[anyio.abc.BlockingPortal]] + +-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html +216 passed, 1 warning in 8.78s diff --git a/docs/hel-892/promoted-reference/1.37.11__src__renderer__extensions__vueNodes__widgets__composables__useMarkdownWidget.ts b/docs/hel-892/promoted-reference/1.37.11__src__renderer__extensions__vueNodes__widgets__composables__useMarkdownWidget.ts new file mode 100644 index 00000000..c54d13bd --- /dev/null +++ b/docs/hel-892/promoted-reference/1.37.11__src__renderer__extensions__vueNodes__widgets__composables__useMarkdownWidget.ts @@ -0,0 +1,108 @@ +import { Editor as TiptapEditor } from '@tiptap/core' +import TiptapLink from '@tiptap/extension-link' +import TiptapTable from '@tiptap/extension-table' +import TiptapTableCell from '@tiptap/extension-table-cell' +import TiptapTableHeader from '@tiptap/extension-table-header' +import TiptapTableRow from '@tiptap/extension-table-row' +import TiptapStarterKit from '@tiptap/starter-kit' +import { Markdown as TiptapMarkdown } from 'tiptap-markdown' + +import type { LGraphNode } from '@/lib/litegraph/src/litegraph' +import type { InputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2' +import { app } from '@/scripts/app' +import type { ComfyWidgetConstructorV2 } from '@/scripts/widgets' + +function addMarkdownWidget( + node: LGraphNode, + name: string, + opts: { defaultVal: string } +) { + TiptapMarkdown.configure({ + html: false, + breaks: true, + transformPastedText: true + }) + const editor = new TiptapEditor({ + extensions: [ + TiptapStarterKit, + TiptapMarkdown, + TiptapLink, + TiptapTable, + TiptapTableCell, + TiptapTableHeader, + TiptapTableRow + ], + content: opts.defaultVal, + editable: false + }) + + const inputEl = editor.options.element as HTMLElement + inputEl.classList.add('comfy-markdown') + const textarea = document.createElement('textarea') + inputEl.append(textarea) + + const widget = node.addDOMWidget(name, 'MARKDOWN', inputEl, { + getValue(): string { + return textarea.value + }, + setValue(v: string) { + textarea.value = v + editor.commands.setContent(v) + } + }) + widget.inputEl = inputEl + widget.options.minNodeSize = [400, 200] + + inputEl.addEventListener('dblclick', () => { + inputEl.classList.add('editing') + setTimeout(() => { + textarea.focus() + }, 0) + }) + + textarea.addEventListener('blur', () => { + inputEl.classList.remove('editing') + }) + + textarea.addEventListener('change', () => { + editor.commands.setContent(textarea.value) + widget.callback?.(widget.value) + }) + + inputEl.addEventListener('keydown', (event: KeyboardEvent) => { + event.stopPropagation() + }) + + inputEl.addEventListener('pointerdown', (event: PointerEvent) => { + if (event.button === 1) { + app.canvas.processMouseDown(event) + } + }) + + inputEl.addEventListener('pointermove', (event: PointerEvent) => { + if ((event.buttons & 4) === 4) { + app.canvas.processMouseMove(event) + } + }) + + inputEl.addEventListener('pointerup', (event: PointerEvent) => { + if (event.button === 1) { + app.canvas.processMouseUp(event) + } + }) + + return widget +} + +export const useMarkdownWidget = () => { + const widgetConstructor: ComfyWidgetConstructorV2 = ( + node: LGraphNode, + inputSpec: InputSpec + ) => { + return addMarkdownWidget(node, inputSpec.name, { + defaultVal: inputSpec.default ?? '' + }) + } + + return widgetConstructor +} diff --git a/docs/hel-892/promoted-reference/1.48.7__src__extensions__core__dynamicPrompts.ts b/docs/hel-892/promoted-reference/1.48.7__src__extensions__core__dynamicPrompts.ts new file mode 100644 index 00000000..57ee13dd --- /dev/null +++ b/docs/hel-892/promoted-reference/1.48.7__src__extensions__core__dynamicPrompts.ts @@ -0,0 +1,31 @@ +import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode' +import { useExtensionService } from '@/services/extensionService' +import { processDynamicPrompt } from '@/utils/formatUtil' + +// Allows for simple dynamic prompt replacement +// Inputs in the format {a|b} will have a random value of a or b chosen when the prompt is queued. + +useExtensionService().registerExtension({ + name: 'Comfy.DynamicPrompts', + nodeCreated(node: LGraphNode) { + if (node.widgets) { + // Locate dynamic prompt text widgets + // Include any widgets with dynamicPrompts set to true, and customtext + const widgets = node.widgets.filter((w) => w.dynamicPrompts) + for (const widget of widgets) { + // Override the serialization of the value to resolve dynamic prompts for all widgets supporting it in this node + widget.serializeValue = (workflowNode, widgetIndex) => { + if (typeof widget.value !== 'string') return widget.value + + const prompt = processDynamicPrompt(widget.value) + + // Overwrite the value in the serialized workflow pnginfo + if (workflowNode?.widgets_values) + workflowNode.widgets_values[widgetIndex] = prompt + + return prompt + } + } + } + } +}) diff --git a/docs/hel-892/promoted-reference/1.48.7__src__lib__litegraph__src__LGraphNode.ts b/docs/hel-892/promoted-reference/1.48.7__src__lib__litegraph__src__LGraphNode.ts new file mode 100644 index 00000000..a928d939 --- /dev/null +++ b/docs/hel-892/promoted-reference/1.48.7__src__lib__litegraph__src__LGraphNode.ts @@ -0,0 +1,4360 @@ +import { toValue } from 'vue' + +import { LGraphNodeProperties } from '@/lib/litegraph/src/LGraphNodeProperties' +import { + calculateInputSlotPosFromSlot, + getSlotPosition +} from '@/renderer/core/canvas/litegraph/slotCalculations' +import type { SlotPositionContext } from '@/renderer/core/canvas/litegraph/slotCalculations' +import { useLayoutMutations } from '@/renderer/core/layout/operations/layoutMutations' +import { layoutStore } from '@/renderer/core/layout/store/layoutStore' +import { LayoutSource } from '@/renderer/core/layout/types' +import { isSizeEqual } from '@/renderer/core/layout/utils/geometry' +import { toLinkId } from '@/types/linkId' +import { UNASSIGNED_NODE_ID, toNodeId, serializeNodeId } from '@/types/nodeId' +import type { NodeId } from '@/types/nodeId' +import { adjustColor } from '@/utils/colorUtil' +import type { ColorAdjustOptions } from '@/utils/colorUtil' +import { + commonType, + isNodeBindable, + toClass +} from '@/lib/litegraph/src/utils/type' + +import { + SUBGRAPH_INPUT_ID, + SUBGRAPH_OUTPUT_ID +} from '@/lib/litegraph/src/constants' +import { cachedMeasureText } from '@/lib/litegraph/src/utils/textMeasureCache' +import type { DragAndScale } from './DragAndScale' +import type { LGraph } from './LGraph' +import { BadgePosition, LGraphBadge } from './LGraphBadge' +import { LGraphButton } from './LGraphButton' +import type { LGraphButtonOptions } from './LGraphButton' +import { LGraphCanvas } from './LGraphCanvas' +import { LLink } from './LLink' +import type { Reroute, RerouteId } from './Reroute' +import { getNodeInputOnPos, getNodeOutputOnPos } from './canvas/measureSlots' +import type { IDrawBoundingOptions } from './draw' +import { NullGraphError } from './infrastructure/NullGraphError' +import type { ReadOnlyRectangle } from './infrastructure/Rectangle' +import { Rectangle } from './infrastructure/Rectangle' +import type { + ColorOption, + CompassCorners, + DefaultConnectionColors, + Dictionary, + IColorable, + IContextMenuValue, + IFoundSlot, + INodeFlags, + INodeInputSlot, + INodeOutputSlot, + INodeSlot, + INodeSlotContextItem, + IPinnable, + ISlotType, + Panel, + Point, + Positionable, + ReadOnlyRect, + Rect, + Size, + SlotIndex +} from './interfaces' +import { LiteGraph, Subgraph } from './litegraph' +import type { LGraphNodeConstructor, SubgraphNode } from './litegraph' +import { + createBounds, + isInRect, + isInRectangle, + isPointInRect, + snapPoint +} from './measure' +import { NodeInputSlot } from './node/NodeInputSlot' +import { NodeOutputSlot } from './node/NodeOutputSlot' +import { + inputAsSerialisable, + isINodeInputSlot, + isWidgetInputSlot, + outputAsSerialisable +} from './node/slotUtils' +import type { SubgraphInputNode } from './subgraph/SubgraphInputNode' +import type { SubgraphOutputNode } from './subgraph/SubgraphOutputNode' +import type { NodeLike } from './types/NodeLike' +import type { CanvasPointerEvent } from './types/events' +import { + LGraphEventMode, + NodeSlotType, + RenderShape, + TitleMode +} from './types/globalEnums' +import type { ISerialisedNode, SubgraphIO } from './types/serialisation' +import type { + IBaseWidget, + IWidgetOptions, + TWidgetType, + TWidgetValue +} from './types/widgets' +import { findFreeSlotOfType } from './utils/collections' +import { warnDeprecated } from './utils/feedback' +import { distributeSpace } from './utils/spaceDistribution' +import { truncateText } from './utils/textUtils' +import { BaseWidget } from './widgets/BaseWidget' +import { toConcreteWidget } from './widgets/widgetMap' +import type { WidgetTypeMap } from './widgets/widgetMap' + +// #region Types + +export type NodeProperty = string | number | boolean | object + +/** TypedArray methods that mutate in place, so must trigger a layout commit. */ +const MUTATING_SIZE_METHODS = new Set([ + 'set', + 'fill', + 'copyWithin', + 'reverse', + 'sort' +]) + +/** Captures only the {@link layoutStore} singleton, so shared across nodes. */ +const layoutMutations = useLayoutMutations() + +interface INodePropertyInfo { + name?: string + type?: string + default_value?: NodeProperty + widget?: string + label?: string + values?: TWidgetValue[] +} + +interface IMouseOverData { + inputId?: number + outputId?: number + overWidget?: IBaseWidget +} + +interface ConnectByTypeOptions { + /** @deprecated Events */ + createEventInCase?: boolean + /** Allow our wildcard slot to connect to typed slots on remote node. Default: true */ + wildcardToTyped?: boolean + /** Allow our typed slot to connect to wildcard slots on remote node. Default: true */ + typedToWildcard?: boolean + /** The {@link Reroute.id} that the connection is being dragged from. */ + afterRerouteId?: RerouteId +} + +/** Internal type used for type safety when implementing generic checks for inputs & outputs */ +interface IGenericLinkOrLinks { + links?: INodeOutputSlot['links'] + link?: INodeInputSlot['link'] +} + +interface FindFreeSlotOptions { + /** Slots matching these types will be ignored. Default: [] */ + typesNotAccepted?: ISlotType[] + /** If true, the slot itself is returned instead of the index. Default: false */ + returnObj?: boolean +} + +interface DrawSlotsOptions { + fromSlot?: INodeInputSlot | INodeOutputSlot + colorContext: DefaultConnectionColors + editorAlpha: number + lowQuality: boolean +} + +interface DrawWidgetsOptions { + lowQuality?: boolean + editorAlpha?: number +} + +interface DrawTitleOptions { + scale: number + title_height?: number + low_quality?: boolean +} + +interface DrawTitleTextOptions extends DrawTitleOptions { + default_title_color: string +} + +export interface DrawTitleBoxOptions extends DrawTitleOptions { + box_size?: number +} + +/* +title: string +pos: [x,y] +size: [x,y] + +input|output: every connection + + { name:string, type:string, pos: [x,y]=Optional, direction: "input"|"output", links: Array }); + +general properties: + + clip_area: if you render outside the node, it will be clipped + + unsafe_execution: not allowed for safe execution + + skip_repeated_outputs: when adding new outputs, it won't show if there is one already connected + + resizable: if set to false it won't be resizable with the mouse + + widgets_start_y: widgets start at y distance from the top of the node + +flags object: + + collapsed: if it is collapsed + +supported callbacks: + + onAdded: when added to graph (warning: this is called BEFORE the node is configured when loading) + + onRemoved: when removed from graph + + onStart: when the graph starts playing + + onStop: when the graph stops playing + + onDrawForeground: render the inside widgets inside the node + + onDrawBackground: render the background area inside the node (only in edit mode) + + onMouseDown + + onMouseMove + + onMouseUp + + onMouseEnter + + onMouseLeave + + onExecute: execute the node + + onPropertyChanged: when a property is changed in the panel (return true to skip default behaviour) + + onGetInputs: returns an array of possible inputs + + onGetOutputs: returns an array of possible outputs + + onBounding: in case this node has a bigger bounding than the node itself (the callback receives the bounding as [x,y,w,h]) + + onDblClick: double clicked in the node + + onNodeTitleDblClick: double clicked in the node title + + onInputDblClick: input slot double clicked (can be used to automatically create a node connected) + + onOutputDblClick: output slot double clicked (can be used to automatically create a node connected) + + onConfigure: called after the node has been configured + + onSerialize: to add extra info when serializing (the callback receives the object that should be filled with the data) + + onSelected + + onDeselected + + onDropItem : DOM item dropped over the node + + onDropFile : file dropped over the node + + onConnectInput : if returns false the incoming connection will be canceled + + onConnectionsChange : a connection changed (new one or removed) (NodeSlotType.INPUT or NodeSlotType.OUTPUT, slot, true if connected, link_info, input_info ) + + onAction: action slot triggered + + getExtraMenuOptions: to add option to context menu +*/ + +export interface LGraphNode { + constructor: LGraphNodeConstructor +} + +// #endregion Types + +/** + * Base class for all nodes + * @param title a name for the node + * @param type a type for the node + */ + +export class LGraphNode + implements NodeLike, Positionable, IPinnable, IColorable +{ + // Static properties used by dynamic child classes + static title?: string + static MAX_CONSOLE?: number + static type?: string + static category?: string + static description?: string + static filter?: string + static skip_list?: boolean + static nodeData?: { + dev_only?: boolean + deprecated?: boolean + experimental?: boolean + output_node?: boolean + api_node?: boolean + name?: string + } + + static resizeHandleSize = 15 + static resizeEdgeSize = 5 + + /** Default setting for {@link LGraphNode.connectInputToOutput}. @see {@link INodeFlags.keepAllLinksOnBypass} */ + static keepAllLinksOnBypass: boolean = false + + /** The title text of the node. */ + title: string + /** + * The font style used to render the node's title text. + */ + get titleFontStyle(): string { + return `${LiteGraph.NODE_TEXT_SIZE}px ${LiteGraph.NODE_FONT}` + } + + get innerFontStyle(): string { + return `normal ${LiteGraph.NODE_SUBTEXT_SIZE}px ${LiteGraph.NODE_FONT}` + } + + get displayType(): string { + return this.type + } + + graph: LGraph | Subgraph | null = null + id: NodeId + type: string = '' + inputs: INodeInputSlot[] = [] + outputs: INodeOutputSlot[] = [] + + private _concreteInputs: NodeInputSlot[] = [] + private _concreteOutputs: NodeOutputSlot[] = [] + + properties: Dictionary = {} + properties_info: INodePropertyInfo[] = [] + flags: INodeFlags = {} + widgets?: IBaseWidget[] + + /** Property manager for this node */ + changeTracker: LGraphNodeProperties + + /** + * The amount of space available for widgets to grow into. + * @see {@link layoutWidgets} + */ + freeWidgetSpace?: number + + /** + * Set to true when widget-backed input slot positions need recalculation. + * Cleared after arrange() runs. Avoids per-frame O(N) scans in drawConnections. + */ + _widgetSlotsDirty = false + + locked?: boolean + + /** Execution order, automatically computed during run @see {@link LGraph.computeExecutionOrder} */ + order: number = 0 + mode: LGraphEventMode = LGraphEventMode.ALWAYS + last_serialization?: ISerialisedNode + serialize_widgets?: boolean + /** + * The overridden fg color used to render the node. + * @see {@link renderingColor} + */ + color?: string + /** + * The overridden bg color used to render the node. + * @see {@link renderingBgColor} + */ + bgcolor?: string + /** + * The overridden box color used to render the node. + * @see {@link renderingBoxColor} + */ + boxcolor?: string + + /** The fg color used to render the node. */ + get renderingColor(): string { + const baseColor = + this.color || this.constructor.color || LiteGraph.NODE_DEFAULT_COLOR + return adjustColor(baseColor, { lightness: LiteGraph.nodeLightness }) + } + + /** The bg color used to render the node. */ + get renderingBgColor(): string { + const baseBgColor = + this.bgcolor || this.constructor.bgcolor || LiteGraph.NODE_DEFAULT_BGCOLOR + const adjustments: ColorAdjustOptions = { + opacity: LiteGraph.nodeOpacity, + lightness: LiteGraph.nodeLightness + } + + return adjustColor( + this.mode === LGraphEventMode.BYPASS + ? LiteGraph.NODE_DEFAULT_BYPASS_COLOR + : baseBgColor, + adjustments + ) + } + + /** The box color used to render the node. */ + get renderingBoxColor(): string { + if (this.boxcolor) return this.boxcolor + + if (LiteGraph.node_box_coloured_when_on) { + if (this.action_triggered) return '#FFF' + if (this.execute_triggered) return '#AAA' + } + + if (LiteGraph.node_box_coloured_by_mode) { + const modeColour = + LiteGraph.NODE_MODES_COLORS[this.mode ?? LGraphEventMode.ALWAYS] + if (modeColour) return modeColour + } + return LiteGraph.NODE_DEFAULT_BOXCOLOR + } + + /** @inheritdoc {@link IColorable.setColorOption} */ + setColorOption(colorOption: ColorOption | null): void { + if (colorOption == null) { + this.color = undefined + this.bgcolor = undefined + } else { + this.color = colorOption.color + this.bgcolor = colorOption.bgcolor + } + } + + /** @inheritdoc {@link IColorable.getColorOption} */ + getColorOption(): ColorOption | null { + return ( + Object.values(LGraphCanvas.node_colors).find( + (colorOption) => + colorOption.color === this.color && + colorOption.bgcolor === this.bgcolor + ) ?? null + ) + } + + /** + * The stroke styles that should be applied to the node. + */ + strokeStyles: Record< + string, + (this: LGraphNode) => IDrawBoundingOptions | undefined + > + + /** + * The progress of node execution. Used to render a progress bar. Value between 0 and 1. + */ + progress?: number + + exec_version?: number + action_call?: string + execute_triggered?: number + action_triggered?: number + /** + * @deprecated This property is unsupported and will be removed in a future release. + * Use `widgets_start_y` or a custom `arrange()` override instead. + */ + widgets_up?: boolean + widgets_start_y?: number + lostFocusAt?: number + gotFocusAt?: number + badges: (LGraphBadge | (() => LGraphBadge))[] = [] + title_buttons: LGraphButton[] = [] + badgePosition: BadgePosition = BadgePosition.TopLeft + onOutputRemoved?(this: LGraphNode, slot: number): void + onInputRemoved?(this: LGraphNode, slot: number, input: INodeInputSlot): void + /** + * The width of the node when collapsed. + * Updated by {@link LGraphCanvas.drawNode} + */ + _collapsed_width?: number + /** + * Called once at the start of every frame. Caller may change the values in {@link out}, which will be reflected in {@link boundingRect}. + * WARNING: Making changes to boundingRect via onBounding is poorly supported, and will likely result in strange behaviour. + */ + onBounding?(this: LGraphNode, out: Rect): void + console?: string[] + _level?: number + _shape?: RenderShape + mouseOver?: IMouseOverData + redraw_on_mouse?: boolean + resizable?: boolean + clonable?: boolean + _relative_id?: number + clip_area?: boolean + ignore_remove?: boolean + has_errors?: boolean + removable?: boolean + block_delete?: boolean + selected?: boolean + showAdvanced?: boolean + + declare comfyDynamic?: Record + declare comfyClass?: string + declare isVirtualNode?: boolean + applyToGraph?(extraLinks?: LLink[]): void + + isSubgraphNode(): this is SubgraphNode { + return false + } + + /** @inheritdoc {@link renderArea} */ + private _renderArea = new Rectangle() + /** + * Rect describing the node area, including shadows and any protrusions. + * Determines if the node is visible. Calculated once at the start of every frame. + */ + get renderArea(): ReadOnlyRect { + return this._renderArea + } + + /** @inheritdoc {@link boundingRect} */ + private _boundingRect: Rectangle = new Rectangle() + /** + * Cached node position & area as `x, y, width, height`. Includes changes made by {@link onBounding}, if present. + * + * Determines the node hitbox and other rendering effects. Calculated once at the start of every frame. + */ + get boundingRect(): ReadOnlyRectangle { + return this._boundingRect + } + + /** The offset from {@link pos} to the top-left of {@link boundingRect}. */ + get boundingOffset(): Readonly { + const { + pos: [posX, posY], + boundingRect: [bX, bY] + } = this + return [posX - bX, posY - bY] + } + + /** {@link pos} and {@link size} values are backed by this {@link Rectangle}. */ + _posSize = new Rectangle() + _pos: Point = this._posSize.pos + _size: Size = this._posSize.size + + public get pos() { + return this._pos + } + + /** Node position does not necessarily correlate to the top-left corner. */ + public set pos(value) { + if (!value || value.length < 2) return + + this._pos[0] = value[0] + this._pos[1] = value[1] + if (this.id === UNASSIGNED_NODE_ID || !this.graph) return + + layoutMutations.setSource(LayoutSource.Canvas) + layoutMutations.moveNode(this.id, { x: value[0], y: value[1] }) + } + + /** + * Set the node position to an absolute location. + */ + setPos(x: number, y: number): void { + this.pos = [x, y] + } + + private _sizeProxy?: Size + + /** + * A Proxy over {@link _size} so that element mutations (`node.size[1] = h`) — + * the idiom many custom nodes use to grow a node at runtime — commit to the + * layout store, exactly like assigning `node.size = [w, h]`. Without this a + * bare element write bypasses the setter and a Vue node keeps its stale + * height until a manual resize. + * + * The Proxy is created once and reused; index writes pass straight through to + * the backing `Float64Array`, and function/length access is forwarded to the + * real typed array so spread, iteration and `.length` keep working. In-place + * mutating methods ({@link MUTATING_SIZE_METHODS}) also commit, so growing the + * node via `node.size.set(...)` reflows just like a bare element write. + * + * TODO(litegraph-stable-resize-api): interim shim — remove once a stable resize + * API replaces direct typed-array size access. + */ + public get size(): Size { + return (this._sizeProxy ??= new Proxy(this._size, { + get: (target, prop, receiver) => { + const value = Reflect.get(target, prop, target) + if (typeof value !== 'function') return value + if (typeof prop !== 'string' || !MUTATING_SIZE_METHODS.has(prop)) + return value.bind(target) + + // `set`/`fill`/etc. mutate the backing array without hitting the set + // trap, so commit through the same path a bare element write would. + // `fill`/`copyWithin`/`reverse`/`sort` return the backing array; hand + // back the Proxy so a chained index write still routes through the trap. + return (...args: unknown[]) => { + const result = Reflect.apply(value, target, args) + this._sizeUpdated() + return result === target ? receiver : result + } + }, + set: (target, prop, value) => { + const result = Reflect.set(target, prop, value) + if (prop === '0' || prop === '1') this._sizeUpdated() + return result + } + })) + } + + public set size(value) { + if (!value || value.length < 2) return + + this._size[0] = value[0] + this._size[1] = value[1] + this._sizeUpdated() + } + + /** Mirror the current {@link _size} into the layout store for Vue nodes. */ + private _sizeUpdated(): void { + if (this.id === UNASSIGNED_NODE_ID || !this.graph) return + + const size = { width: this._size[0], height: this._size[1] } + const layout = layoutStore.getNodeLayoutRef(this.id).value + if (layout && isSizeEqual(layout.size, size)) return + + layoutMutations.setSource(LayoutSource.Canvas) + layoutMutations.resizeNode(this.id, size) + } + + /** + * The size of the node used for rendering. + */ + get renderingSize(): Size { + return this.flags.collapsed ? [this._collapsed_width ?? 0, 0] : this._size + } + + get shape(): RenderShape | undefined { + return this._shape + } + + set shape(v: RenderShape | 'default' | 'box' | 'round' | 'circle' | 'card') { + const oldValue = this._shape + switch (v) { + case 'default': + this._shape = undefined + break + case 'box': + this._shape = RenderShape.BOX + break + case 'round': + this._shape = RenderShape.ROUND + break + case 'circle': + this._shape = RenderShape.CIRCLE + break + case 'card': + this._shape = RenderShape.CARD + break + default: + this._shape = v + } + if (oldValue !== this._shape) { + this.graph?.trigger('node:property:changed', { + nodeId: this.id, + property: 'shape', + oldValue, + newValue: this._shape + }) + } + } + + /** + * The shape of the node used for rendering. @see {@link RenderShape} + */ + get renderingShape(): RenderShape { + return this._shape || this.constructor.shape || LiteGraph.NODE_DEFAULT_SHAPE + } + + public get is_selected(): boolean | undefined { + return this.selected + } + + public set is_selected(value: boolean) { + this.selected = value + } + + public get title_mode(): TitleMode { + return this.constructor.title_mode ?? TitleMode.NORMAL_TITLE + } + + onConnectInput?( + this: LGraphNode, + target_slot: number, + type: unknown, + output: INodeOutputSlot | SubgraphIO, + node: LGraphNode | SubgraphInputNode, + slot: number + ): boolean + onConnectOutput?( + this: LGraphNode, + slot: number, + type: unknown, + input: INodeInputSlot | SubgraphIO, + target_node: number | LGraphNode | SubgraphOutputNode, + target_slot: number + ): boolean + onResize?(this: LGraphNode, size: Size): void + onPropertyChanged?( + this: LGraphNode, + name: string, + value: unknown, + prev_value?: unknown + ): boolean + /** Called for each connection that is created, updated, or removed. This includes "restored" connections when deserialising. */ + onConnectionsChange?( + this: LGraphNode, + type: ISlotType, + index: number, + isConnected: boolean, + link_info: LLink | null | undefined, + inputOrOutput: INodeInputSlot | INodeOutputSlot | SubgraphIO + ): void + onInputAdded?(this: LGraphNode, input: INodeInputSlot): void + onOutputAdded?(this: LGraphNode, output: INodeOutputSlot): void + onConfigure?(this: LGraphNode, serialisedNode: ISerialisedNode): void + onSerialize?(this: LGraphNode, serialised: ISerialisedNode): void + onExecute?( + this: LGraphNode, + param?: unknown, + options?: { action_call?: string } + ): void + onAction?( + this: LGraphNode, + action: string, + param: unknown, + options: { action_call?: string } + ): void + onDrawBackground?(this: LGraphNode, ctx: CanvasRenderingContext2D): void + onNodeCreated?(this: LGraphNode): void + /** + * Callback invoked by {@link connect} to override the target slot index. + * Its return value overrides the target index selection. + * @param target_slot The current input slot index + * @param requested_slot The originally requested slot index - could be negative, or if using (deprecated) name search, a string + * @returns {number | null} If a number is returned, the connection will be made to that input index. + * If an invalid index or non-number (false, null, NaN etc) is returned, the connection will be cancelled. + */ + onBeforeConnectInput?( + this: LGraphNode, + target_slot: number, + requested_slot?: number | string + ): number | false | null + onShowCustomPanelInfo?(this: LGraphNode, panel: Panel): void + onAddPropertyToPanel?(this: LGraphNode, pName: string, panel: Panel): boolean + onWidgetChanged?( + this: LGraphNode, + name: string, + value: unknown, + old_value: unknown, + w: IBaseWidget + ): void + onDeselected?(this: LGraphNode): void + onKeyUp?(this: LGraphNode, e: KeyboardEvent): void + onKeyDown?(this: LGraphNode, e: KeyboardEvent): void + onSelected?(this: LGraphNode): void + getExtraMenuOptions?( + this: LGraphNode, + canvas: LGraphCanvas, + options: (IContextMenuValue | null)[] + ): (IContextMenuValue | null)[] + getMenuOptions?(this: LGraphNode, canvas: LGraphCanvas): IContextMenuValue[] + onAdded?(this: LGraphNode, graph: LGraph): void + onDrawCollapsed?( + this: LGraphNode, + ctx: CanvasRenderingContext2D, + cavnas: LGraphCanvas + ): boolean + onDrawForeground?( + this: LGraphNode, + ctx: CanvasRenderingContext2D, + canvas: LGraphCanvas, + canvasElement: HTMLCanvasElement + ): void + onMouseLeave?(this: LGraphNode, e: CanvasPointerEvent): void + /** + * Override the default slot menu options. + */ + getSlotMenuOptions?(this: LGraphNode, slot: IFoundSlot): IContextMenuValue[] + /** + * Add extra menu options to the slot context menu. + */ + getExtraSlotMenuOptions?( + this: LGraphNode, + slot: IFoundSlot + ): IContextMenuValue[] + + // FIXME: Re-typing + onDropItem?(this: LGraphNode, event: Event): boolean + onDropData?( + this: LGraphNode, + data: string | ArrayBuffer, + filename: string, + file: File + ): void + onDropFile?(this: LGraphNode, file: File): void + onInputClick?(this: LGraphNode, index: number, e: CanvasPointerEvent): void + onInputDblClick?(this: LGraphNode, index: number, e: CanvasPointerEvent): void + onOutputClick?(this: LGraphNode, index: number, e: CanvasPointerEvent): void + onOutputDblClick?( + this: LGraphNode, + index: number, + e: CanvasPointerEvent + ): void + onGetPropertyInfo?(this: LGraphNode, property: string): INodePropertyInfo + onNodeOutputAdd?(this: LGraphNode, value: unknown): void + onNodeInputAdd?(this: LGraphNode, value: unknown): void + onMenuNodeInputs?( + this: LGraphNode, + entries: (IContextMenuValue | null)[] + ): (IContextMenuValue | null)[] + onMenuNodeOutputs?( + this: LGraphNode, + entries: (IContextMenuValue | null)[] + ): (IContextMenuValue | null)[] + onMouseUp?( + this: LGraphNode, + e: CanvasPointerEvent, + pos: Point, + canvas: LGraphCanvas + ): void + onMouseEnter?(this: LGraphNode, e: CanvasPointerEvent): void + /** Blocks drag if return value is truthy. @param pos Offset from {@link LGraphNode.pos}. */ + onMouseDown?( + this: LGraphNode, + e: CanvasPointerEvent, + pos: Point, + canvas: LGraphCanvas + ): boolean + /** @param pos Offset from {@link LGraphNode.pos}. */ + onDblClick?( + this: LGraphNode, + e: CanvasPointerEvent, + pos: Point, + canvas: LGraphCanvas + ): void + /** @param pos Offset from {@link LGraphNode.pos}. */ + onNodeTitleDblClick?( + this: LGraphNode, + e: CanvasPointerEvent, + pos: Point, + canvas: LGraphCanvas + ): void + onDrawTitle?(this: LGraphNode, ctx: CanvasRenderingContext2D): void + onDrawTitleText?( + this: LGraphNode, + ctx: CanvasRenderingContext2D, + title_height: number, + size: Size, + scale: number, + title_text_font: string, + selected?: boolean + ): void + onDrawTitleBox?( + this: LGraphNode, + ctx: CanvasRenderingContext2D, + title_height: number, + size: Size, + scale: number + ): void + onDrawTitleBar?( + this: LGraphNode, + ctx: CanvasRenderingContext2D, + title_height: number, + size: Size, + scale: number, + fgcolor: string + ): void + onRemoved?(this: LGraphNode): void + onMouseMove?( + this: LGraphNode, + e: CanvasPointerEvent, + pos: Point, + arg2: LGraphCanvas + ): void + onPropertyChange?(this: LGraphNode): void + updateOutputData?(this: LGraphNode, origin_slot: number): void + + private _getErrorStrokeStyle( + this: LGraphNode + ): IDrawBoundingOptions | undefined { + if (this.has_errors) { + return { + padding: 12, + lineWidth: 10, + color: LiteGraph.NODE_ERROR_COLOUR + } + } + } + + private _getSelectedStrokeStyle( + this: LGraphNode + ): IDrawBoundingOptions | undefined { + if (this.selected) { + return { + padding: this.has_errors ? 20 : undefined + } + } + } + + constructor(title: string, type?: string) { + this.id = UNASSIGNED_NODE_ID + this.title = title || 'Unnamed' + this.type = type ?? '' + this.size = [LiteGraph.NODE_WIDTH, 60] + this.pos = [10, 10] + this.strokeStyles = { + error: this._getErrorStrokeStyle, + selected: this._getSelectedStrokeStyle + } + // Initialize property manager with tracked properties + this.changeTracker = new LGraphNodeProperties(this) + } + + /** Internal callback for subgraph nodes. Do not implement externally. */ + _internalConfigureAfterSlots?(): void + + /** + * configure a node from an object containing the serialized info + */ + configure(info: ISerialisedNode): void { + if (this.graph) { + this.graph.incrementVersion() + } + for (const j in info) { + if (j == 'properties') { + // i don't want to clone properties, I want to reuse the old container + for (const k in info.properties) { + this.properties[k] = info.properties[k] + this.onPropertyChanged?.(k, info.properties[k]) + } + continue + } + + if (j === 'id') { + const id = toNodeId(info.id) + if (id !== UNASSIGNED_NODE_ID) this.id = id + continue + } + + // @ts-expect-error #594 + if (info[j] == null) { + continue + // @ts-expect-error #594 + } else if (typeof info[j] == 'object') { + // @ts-expect-error #594 + if (this[j]?.configure) { + // @ts-expect-error #594 + this[j]?.configure(info[j]) + } else { + // @ts-expect-error #594 + this[j] = LiteGraph.cloneObject(info[j], this[j]) + } + } else { + // value + // @ts-expect-error #594 + this[j] = info[j] + } + } + + if (!info.title) { + this.title = this.constructor.title + } + + this.inputs ??= [] + this.inputs = this.inputs.map((input) => + toClass(NodeInputSlot, input, this) + ) + for (const [i, input] of this.inputs.entries()) { + const link = + this.graph && input.link != null + ? this.graph._links.get(input.link) + : null + this.onConnectionsChange?.(NodeSlotType.INPUT, i, true, link, input) + this.onInputAdded?.(input) + } + + this.outputs ??= [] + this.outputs = this.outputs.map((output) => + toClass(NodeOutputSlot, output, this) + ) + for (const [i, output] of this.outputs.entries()) { + if (!output.links) continue + + for (const linkId of output.links) { + const link = this.graph ? this.graph._links.get(linkId) : null + this.onConnectionsChange?.(NodeSlotType.OUTPUT, i, true, link, output) + } + this.onOutputAdded?.(output) + } + + // SubgraphNode callback. + this._internalConfigureAfterSlots?.() + + if (this.widgets) { + for (const w of this.widgets) { + if (!w) continue + + const input = this.inputs.find((i) => i.widget?.name === w.name) + if (input?.label) w.label = input.label + + if ( + w.options?.property && + this.properties[w.options.property] != undefined + ) + w.value = JSON.parse( + JSON.stringify(this.properties[w.options.property]) + ) + } + + if (info.widgets_values) { + let i = 0 + for (const widget of this.widgets ?? []) { + if (widget.serialize === false) continue + if (i >= info.widgets_values.length) break + widget.value = info.widgets_values[i++] + } + } + } + + // Sync the state of this.resizable. + if (this.pinned) this.resizable = false + + if (this.widgets_up) { + console.warn( + `[LiteGraph] Node type "${this.type}" uses deprecated property "widgets_up". ` + + 'This property is unsupported and will be removed. ' + + 'Use "widgets_start_y" or a custom arrange() override instead.' + ) + } + + this.onConfigure?.(info) + } + + /** + * serialize the content + */ + serialize(): ISerialisedNode { + // create serialization object + const o: ISerialisedNode = { + id: serializeNodeId(this.id), + type: this.type, + pos: [this.pos[0], this.pos[1]], + size: [this.size[0], this.size[1]], + flags: LiteGraph.cloneObject(this.flags), + order: this.order, + mode: this.mode, + showAdvanced: this.showAdvanced + } + + // special case for when there were errors + if (this.constructor === LGraphNode && this.last_serialization) + return { ...this.last_serialization, mode: o.mode, pos: o.pos } + + if (this.inputs) + o.inputs = this.inputs.map((input) => inputAsSerialisable(input)) + if (this.outputs) + // @ts-expect-error - Output serialization type mismatch + o.outputs = this.outputs.map((output) => outputAsSerialisable(output)) + + if (this.title && this.title != this.constructor.title) o.title = this.title + + if (this.properties) o.properties = LiteGraph.cloneObject(this.properties) + + const { widgets } = this + if (widgets && this.serialize_widgets) { + o.widgets_values = [] + for (const [i, widget] of widgets.entries()) { + if (widget.serialize === false) continue + const val = widget?.value + // Ensure object values are plain (not reactive proxies) for structuredClone compatibility. + o.widgets_values[i] = + val != null && typeof val === 'object' + ? JSON.parse(JSON.stringify(val)) + : (val ?? null) + } + } + + if (!o.type && this.constructor.type) o.type = this.constructor.type + + if (this.color) o.color = this.color + if (this.bgcolor) o.bgcolor = this.bgcolor + if (this.boxcolor) o.boxcolor = this.boxcolor + if (this.shape) o.shape = this.shape + + if (this.onSerialize?.(o)) + console.warn( + "node onSerialize shouldn't return anything, data should be stored in the object pass in the first parameter" + ) + + return o + } + + clone(): LGraphNode | null { + if (this.type == null) return null + const node = LiteGraph.createNode(this.type) + if (!node) return null + + // we clone it because serialize returns shared containers + const data = LiteGraph.cloneObject(this.serialize()) + const { inputs, outputs } = data + + // remove links + if (inputs) { + for (const input of inputs) { + input.link = null + } + } + + if (outputs) { + for (const { links } of outputs) { + if (links) links.length = 0 + } + } + + // @ts-expect-error Exceptional case: id is removed so that the graph can assign a new one on add. + data.id = undefined + + node.id = this.id + node.configure(data) + + return node + } + + /** + * serialize and stringify + */ + toString(): string { + return JSON.stringify(this.serialize()) + } + + /** + * get the title string + */ + getTitle(): string { + return this.title || this.constructor.title + } + + /** + * sets the value of a property + * @param name + * @param value + */ + setProperty(name: string, value: TWidgetValue): void { + this.properties ||= {} + if (value === this.properties[name]) return + + const prev_value = this.properties[name] + this.properties[name] = value + // abort change + if (this.onPropertyChanged?.(name, value, prev_value) === false) + this.properties[name] = prev_value + + if (this.widgets) { + for (const w of this.widgets) { + if (!w) continue + + if (w.options.property == name) { + w.value = value + break + } + } + } + } + + /** + * sets the output data + * @param slot + * @param data + */ + setOutputData( + slot: number, + data: number | string | boolean | { toToolTip?(): string } + ): void { + const { outputs } = this + if (!outputs) return + + // this maybe slow and a niche case + if (slot == -1 || slot >= outputs.length) return + + const output_info = outputs[slot] + if (!output_info) return + + // store data in the output itself in case we want to debug + output_info._data = data + + if (!this.graph) throw new NullGraphError() + + // if there are connections, pass the data to the connections + const { links } = outputs[slot] + if (links) { + for (const id of links) { + const link = this.graph._links.get(id) + if (link) link.data = data + } + } + } + + /** + * sets the output data type, useful when you want to be able to overwrite the data type + */ + setOutputDataType(slot: SlotIndex, type: ISlotType): void { + const { outputs } = this + if (!outputs || slot == -1 || slot >= outputs.length) return + + const output_info = outputs[slot] + if (!output_info) return + // store data in the output itself in case we want to debug + output_info.type = type + + if (!this.graph) throw new NullGraphError() + + // if there are connections, pass the data to the connections + const { links } = outputs[slot] + if (links) { + for (const id of links) { + const link = this.graph._links.get(id) + if (link) link.type = type + } + } + } + + /** + * Retrieves the input data (data traveling through the connection) from one slot + * @param slot + * @param force_update if set to true it will force the connected node of this slot to output data into this link + * @returns data or if it is not connected returns undefined + */ + getInputData(slot: number, force_update?: boolean): unknown { + if (!this.inputs) return + + if (slot >= this.inputs.length || this.inputs[slot].link == null) return + if (!this.graph) throw new NullGraphError() + + const link_id = this.inputs[slot].link + const link = this.graph._links.get(link_id) + // bug: weird case but it happens sometimes + if (!link) return null + + if (!force_update) return link.data + + // special case: used to extract data from the incoming connection before the graph has been executed + const node = this.graph.getNodeById(link.origin_id) + if (!node) return link.data + + if (node.updateOutputData) { + node.updateOutputData(link.origin_slot) + } else { + node.onExecute?.() + } + + return link.data + } + + /** + * Retrieves the input data type (in case this supports multiple input types) + * @param slot + * @returns datatype in string format + */ + getInputDataType(slot: SlotIndex): ISlotType | null { + if (!this.inputs) return null + if (slot >= this.inputs.length || this.inputs[slot].link == null) + return null + if (!this.graph) throw new NullGraphError() + + const link_id = this.inputs[slot].link + const link = this.graph._links.get(link_id) + // bug: weird case but it happens sometimes + if (!link) return null + + const node = this.graph.getNodeById(link.origin_id) + if (!node) return link.type + + const output_info = node.outputs[link.origin_slot] + return output_info ? output_info.type : null + } + + /** + * Retrieves the input data from one slot using its name instead of slot number + * @param slot_name + * @param force_update if set to true it will force the connected node of this slot to output data into this link + * @returns data or if it is not connected returns null + */ + getInputDataByName(slot_name: string, force_update: boolean): unknown { + const slot = this.findInputSlot(slot_name) + return slot == -1 ? null : this.getInputData(slot, force_update) + } + + /** + * tells you if there is a connection in one input slot + * @param slot The 0-based index of the input to check + * @returns `true` if the input slot has a link ID (does not perform validation) + */ + isInputConnected(slot: number): boolean { + if (!this.inputs) return false + return slot < this.inputs.length && this.inputs[slot].link != null + } + + /** + * tells you info about an input connection (which node, type, etc) + * @returns object or null { link: id, name: string, type: string or 0 } + */ + getInputInfo(slot: number): INodeInputSlot | null { + return !this.inputs || !(slot < this.inputs.length) + ? null + : this.inputs[slot] + } + + /** + * Resolves the output source for cross-graph virtual nodes (e.g. Set/Get), + * bypassing {@link getInputLink} when the source lives in a different graph. + */ + resolveVirtualOutput?( + slot: number + ): { node: LGraphNode; slot: number } | undefined + + /** + * Returns the link info in the connection of an input slot + * @returns object or null + */ + getInputLink(slot: number): LLink | null { + if (!this.inputs) return null + + if (slot < this.inputs.length) { + if (!this.graph) throw new NullGraphError() + + const input = this.inputs[slot] + if (input.link != null) { + return this.graph._links.get(input.link) ?? null + } + } + return null + } + + /** + * returns the node connected in the input slot + * @returns node or null + */ + getInputNode(slot: number): LGraphNode | null { + if (!this.inputs) return null + if (slot >= this.inputs.length) return null + + const input = this.inputs[slot] + if (!input || input.link === null) return null + if (!this.graph) throw new NullGraphError() + + const link_info = this.graph._links.get(input.link) + if (!link_info) return null + + return this.graph.getNodeById(link_info.origin_id) + } + + /** + * returns the value of an input with this name, otherwise checks if there is a property with that name + * @returns value + */ + getInputOrProperty(name: string): unknown { + const { inputs } = this + if (!inputs?.length) { + return this.properties ? this.properties[name] : null + } + if (!this.graph) throw new NullGraphError() + + for (const input of inputs) { + if (name == input.name && input.link != null) { + const link = this.graph._links.get(input.link) + if (link) return link.data + } + } + return this.properties[name] + } + + /** + * tells you the last output data that went in that slot + * @returns object or null + */ + getOutputData(slot: number): unknown { + if (!this.outputs) return null + if (slot >= this.outputs.length) return null + + const info = this.outputs[slot] + return info._data + } + + /** + * tells you info about an output connection (which node, type, etc) + * @returns object or null { name: string, type: string, links: [ ids of links in number ] } + */ + getOutputInfo(slot: number): INodeOutputSlot | null { + return !this.outputs || !(slot < this.outputs.length) + ? null + : this.outputs[slot] + } + + /** + * tells you if there is a connection in one output slot + */ + isOutputConnected(slot: number): boolean { + if (!this.outputs) return false + return ( + slot < this.outputs.length && Number(this.outputs[slot].links?.length) > 0 + ) + } + + /** + * tells you if there is any connection in the output slots + */ + isAnyOutputConnected(): boolean { + const { outputs } = this + if (!outputs) return false + + for (const output of outputs) { + if (output.links?.length) return true + } + return false + } + + /** + * retrieves all the nodes connected to this output slot + */ + getOutputNodes(slot: number): LGraphNode[] | null { + const { outputs } = this + if (!outputs || outputs.length == 0) return null + + if (slot >= outputs.length) return null + + const { links } = outputs[slot] + if (!links || links.length == 0) return null + if (!this.graph) throw new NullGraphError() + + const r: LGraphNode[] = [] + for (const id of links) { + const link = this.graph._links.get(id) + if (link) { + const target_node = this.graph.getNodeById(link.target_id) + if (target_node) { + r.push(target_node) + } + } + } + return r + } + + addOnTriggerInput(): number { + const trigS = this.findInputSlot('onTrigger') + if (trigS == -1) { + this.addInput('onTrigger', LiteGraph.EVENT, { + nameLocked: true + }) + return this.findInputSlot('onTrigger') + } + return trigS + } + + addOnExecutedOutput(): number { + const trigS = this.findOutputSlot('onExecuted') + if (trigS == -1) { + this.addOutput('onExecuted', LiteGraph.ACTION, { + nameLocked: true + }) + return this.findOutputSlot('onExecuted') + } + return trigS + } + + onAfterExecuteNode(param: unknown, options?: { action_call?: string }) { + const trigS = this.findOutputSlot('onExecuted') + if (trigS != -1) { + this.triggerSlot(trigS, param, null, options) + } + } + + changeMode(modeTo: number): boolean { + switch (modeTo) { + case LGraphEventMode.ON_EVENT: + break + + case LGraphEventMode.ON_TRIGGER: + this.addOnTriggerInput() + this.addOnExecutedOutput() + break + + case LGraphEventMode.NEVER: + break + + case LGraphEventMode.ALWAYS: + break + + // @ts-expect-error Not impl. + case LiteGraph.ON_REQUEST: + break + + default: + return false + } + this.mode = modeTo + return true + } + + /** + * Triggers the node code execution, place a boolean/counter to mark the node as being executed + */ + doExecute(param?: unknown, options?: { action_call?: string }): void { + options = options || {} + if (this.onExecute) { + // enable this to give the event an ID + options.action_call ||= `${this.id}_exec_${Math.floor(Math.random() * 9999)}` + if (!this.graph) throw new NullGraphError() + + // @ts-expect-error Technically it works when id is a string. Array gets props. + this.graph.nodes_executing[this.id] = true + this.onExecute(param, options) + // @ts-expect-error deprecated + this.graph.nodes_executing[this.id] = false + + // save execution/action ref + this.exec_version = this.graph.iteration + if (options?.action_call) { + this.action_call = options.action_call + // @ts-expect-error deprecated + this.graph.nodes_executedAction[this.id] = options.action_call + } + } + // the nFrames it will be used (-- each step), means "how old" is the event + this.execute_triggered = 2 + this.onAfterExecuteNode?.(param, options) + } + + /** + * Triggers an action, wrapped by logics to control execution flow + * @param action name + */ + actionDo( + action: string, + param: unknown, + options: { action_call?: string } + ): void { + options = options || {} + if (this.onAction) { + // enable this to give the event an ID + options.action_call ||= `${this.id}_${action || 'action'}_${Math.floor(Math.random() * 9999)}` + if (!this.graph) throw new NullGraphError() + + // @ts-expect-error deprecated + this.graph.nodes_actioning[this.id] = action || 'actioning' + this.onAction(action, param, options) + // @ts-expect-error deprecated + this.graph.nodes_actioning[this.id] = false + + // save execution/action ref + if (options?.action_call) { + this.action_call = options.action_call + // @ts-expect-error deprecated + this.graph.nodes_executedAction[this.id] = options.action_call + } + } + // the nFrames it will be used (-- each step), means "how old" is the event + this.action_triggered = 2 + this.onAfterExecuteNode?.(param, options) + } + + /** + * Triggers an event in this node, this will trigger any output with the same name + * @param action name ( "on_play", ... ) if action is equivalent to false then the event is send to all + */ + trigger( + action: string, + param: unknown, + options: { action_call?: string } + ): void { + const { outputs } = this + if (!outputs || !outputs.length) { + return + } + + if (this.graph) this.graph._last_trigger_time = LiteGraph.getTime() + + for (const [i, output] of outputs.entries()) { + if ( + !output || + output.type !== LiteGraph.EVENT || + (action && output.name != action) + ) { + continue + } + this.triggerSlot(i, param, null, options) + } + } + + /** + * Triggers a slot event in this node: cycle output slots and launch execute/action on connected nodes + * @param slot the index of the output slot + * @param link_id [optional] in case you want to trigger and specific output link in a slot + */ + triggerSlot( + slot: number, + param: unknown, + link_id: number | null, + options?: { action_call?: string } + ): void { + options = options || {} + if (!this.outputs) return + + if (slot == null) { + console.error('slot must be a number') + return + } + + if (typeof slot !== 'number') + console.warn( + "slot must be a number, use node.trigger('name') if you want to use a string" + ) + + const output = this.outputs[slot] + if (!output) return + + const links = output.links + if (!links || !links.length) return + + if (!this.graph) throw new NullGraphError() + this.graph._last_trigger_time = LiteGraph.getTime() + + // for every link attached here + for (const id of links) { + // to skip links + if (link_id != null && link_id != id) continue + + const link_info = this.graph._links.get(id) + // not connected + if (!link_info) continue + + link_info._last_time = LiteGraph.getTime() + const node = this.graph.getNodeById(link_info.target_id) + // node not found? + if (!node) continue + + if (node.mode === LGraphEventMode.ON_TRIGGER) { + // generate unique trigger ID if not present + if (!options.action_call) + options.action_call = `${this.id}_trigg_${Math.floor(Math.random() * 9999)}` + // -- wrapping node.onExecute(param); -- + node.doExecute?.(param, options) + } else if (node.onAction) { + // generate unique action ID if not present + if (!options.action_call) + options.action_call = `${this.id}_act_${Math.floor(Math.random() * 9999)}` + // pass the action name + const target_connection = node.inputs[link_info.target_slot] + node.actionDo(target_connection.name, param, options) + } + } + } + + /** + * clears the trigger slot animation + * @param slot the index of the output slot + * @param link_id [optional] in case you want to trigger and specific output link in a slot + */ + clearTriggeredSlot(slot: number, link_id: number): void { + if (!this.outputs) return + + const output = this.outputs[slot] + if (!output) return + + const links = output.links + if (!links || !links.length) return + + if (!this.graph) throw new NullGraphError() + + // for every link attached here + for (const id of links) { + // to skip links + if (link_id != null && link_id != id) continue + + const link_info = this.graph._links.get(id) + // not connected + if (!link_info) continue + + link_info._last_time = 0 + } + } + + /** + * changes node size and triggers callback + */ + setSize(size: Size): void { + this.size = size + this.onResize?.(this.size) + } + + /** + * Expands the node size to fit its content. + */ + expandToFitContent(): void { + const newSize = this.computeSize() + this.setSize([ + Math.max(this.size[0], newSize[0]), + Math.max(this.size[1], newSize[1]) + ]) + } + + /** + * add a new property to this node + * @param type string defining the output type ("vec3","number",...) + * @param extra_info this can be used to have special properties of the property (like values, etc) + */ + addProperty( + name: string, + default_value: NodeProperty | undefined, + type?: string, + extra_info?: Partial + ): INodePropertyInfo { + const o: INodePropertyInfo = { name, type, default_value } + if (extra_info) Object.assign(o, extra_info) + + this.properties_info ||= [] + this.properties_info.push(o) + this.properties ||= {} + this.properties[name] = default_value + return o + } + + /** + * add a new output slot to use in this node + * @param type string defining the output type ("vec3","number",...) + * @param extra_info this can be used to have special properties of an output (label, special color, position, etc) + */ + addOutput>( + name: string, + type: ISlotType, + extra_info?: TProperties + ): INodeOutputSlot & TProperties { + const output = Object.assign( + new NodeOutputSlot({ name, type, links: null }, this), + extra_info + ) + + this.outputs ||= [] + this.outputs.push(output) + this.onOutputAdded?.(output) + + if (LiteGraph.auto_load_slot_types) + LiteGraph.registerNodeAndSlotType(this, type, true) + + this.expandToFitContent() + this.setDirtyCanvas(true, true) + return output + } + + /** + * remove an existing output slot + */ + removeOutput(slot: number): void { + // Only disconnect if node is part of a graph + if (this.graph) { + this.disconnectOutput(slot) + } + const { outputs } = this + outputs.splice(slot, 1) + + for (let i = slot; i < outputs.length; ++i) { + const output = outputs[i] + if (!output || !output.links) continue + + // Only update link indices if node is part of a graph + if (this.graph) { + for (const linkId of output.links) { + const link = this.graph._links.get(linkId) + if (link) link.origin_slot-- + } + } + } + + this.onOutputRemoved?.(slot) + this.setDirtyCanvas(true, true) + } + + /** + * add a new input slot to use in this node + * @param type string defining the input type ("vec3","number",...), it its a generic one use 0 + * @param extra_info this can be used to have special properties of an input (label, color, position, etc) + */ + addInput>( + name: string, + type: ISlotType, + extra_info?: TProperties + ): INodeInputSlot & TProperties { + type ||= 0 + + const input = Object.assign( + new NodeInputSlot({ name, type, link: null }, this), + extra_info + ) + + this.inputs ||= [] + this.inputs.push(input) + this.expandToFitContent() + + this.onInputAdded?.(input) + LiteGraph.registerNodeAndSlotType(this, type) + + this.setDirtyCanvas(true, true) + return input + } + + /** + * remove an existing input slot + */ + removeInput(slot: number): void { + // Only disconnect if node is part of a graph + if (this.graph) { + this.disconnectInput(slot, true) + } + const { inputs } = this + const slot_info = inputs.splice(slot, 1) + + for (let i = slot; i < inputs.length; ++i) { + const input = inputs[i] + if (!input?.link) continue + + // Only update link indices if node is part of a graph + if (this.graph) { + const link = this.graph._links.get(input.link) + if (link) link.target_slot-- + } + } + this.onInputRemoved?.(slot, slot_info[0]) + this.setDirtyCanvas(true, true) + } + + /** + * computes the minimum size of a node according to its inputs and output slots + * @returns the total size + */ + computeSize(out?: Size): Size { + const ctorSize = this.constructor.size + if (ctorSize) return [ctorSize[0], ctorSize[1]] + + const { inputs, outputs, widgets } = this + let rows = Math.max( + inputs ? inputs.filter((input) => !isWidgetInputSlot(input)).length : 1, + outputs ? outputs.length : 1 + ) + const size = out ?? [0, 0] + rows = Math.max(rows, 1) + // although it should be graphcanvas.inner_text_font size + const font_size = LiteGraph.NODE_TEXT_SIZE + + const padLeft = LiteGraph.NODE_TITLE_HEIGHT + const padRight = padLeft * 0.33 + const title_width = + padLeft + compute_text_size(this.title, this.titleFontStyle) + padRight + let input_width = 0 + let widgetWidth = 0 + let output_width = 0 + + if (inputs) { + for (const input of inputs) { + const text = input.label || input.localized_name || input.name || '' + const text_width = compute_text_size(text, this.innerFontStyle) + if (isWidgetInputSlot(input)) { + const widget = this.getWidgetFromSlot(input) + if (widget && !this.isWidgetVisible(widget)) continue + + if (text_width > widgetWidth) widgetWidth = text_width + } else { + if (text_width > input_width) input_width = text_width + } + } + } + + if (outputs) { + for (const output of outputs) { + const text = output.label || output.localized_name || output.name || '' + const text_width = compute_text_size(text, this.innerFontStyle) + if (output_width < text_width) output_width = text_width + } + } + + const minWidth = LiteGraph.NODE_WIDTH * (widgets?.length ? 1.5 : 1) + // Text + slot width + centre padding + const centrePadding = input_width && output_width ? 5 : 0 + const slotsWidth = + input_width + + output_width + + 2 * LiteGraph.NODE_SLOT_HEIGHT + + centrePadding + + // Total distance from edge of node to the inner edge of the widget 'previous' arrow button + const widgetMargin = + BaseWidget.margin + BaseWidget.arrowMargin + BaseWidget.arrowWidth + const widgetPadding = BaseWidget.minValueWidth + 2 * widgetMargin + if (widgetWidth) widgetWidth += widgetPadding + + size[0] = Math.max(slotsWidth, widgetWidth, title_width, minWidth) + size[1] = + (this.constructor.slot_start_y || 0) + rows * LiteGraph.NODE_SLOT_HEIGHT + + // Get widget height & expand size if necessary + let widgets_height = 0 + if (widgets?.length) { + for (const widget of widgets) { + if (!this.isWidgetVisible(widget)) continue + + let widget_height = 0 + if (widget.computeSize) { + widget_height += widget.computeSize(size[0])[1] + } else if (widget.computeLayoutSize) { + // Expand widget width if necessary + const { minHeight, minWidth } = widget.computeLayoutSize(this) + const widgetWidth = minWidth + widgetPadding + if (widgetWidth > size[0]) size[0] = widgetWidth + + widget_height += minHeight + } else { + widget_height += LiteGraph.NODE_WIDGET_HEIGHT + } + widgets_height += widget_height + 4 + } + widgets_height += 8 + } + + // compute height using widgets height + if (this.widgets_up) size[1] = Math.max(size[1], widgets_height) + else if (this.widgets_start_y != null) + size[1] = Math.max(size[1], widgets_height + this.widgets_start_y) + else size[1] += widgets_height + + function compute_text_size(text: string, fontStyle: string) { + return ( + LGraphCanvas._measureText?.(text, fontStyle) ?? + font_size * (text?.length ?? 0) * 0.6 + ) + } + + if (this.constructor.min_height && size[1] < this.constructor.min_height) { + size[1] = this.constructor.min_height + } + + // margin + size[1] += 6 + + return size + } + + inResizeCorner(canvasX: number, canvasY: number): boolean { + const rows = this.outputs ? this.outputs.length : 1 + const outputs_offset = + (this.constructor.slot_start_y || 0) + rows * LiteGraph.NODE_SLOT_HEIGHT + return isInRectangle( + canvasX, + canvasY, + this.pos[0] + this.size[0] - 15, + this.pos[1] + Math.max(this.size[1] - 15, outputs_offset), + 20, + 20 + ) + } + + /** + * Returns which resize corner the point is over, if any. + * @param canvasX X position in canvas coordinates + * @param canvasY Y position in canvas coordinates + * @returns The compass corner the point is in, otherwise `undefined`. + */ + findResizeDirection( + canvasX: number, + canvasY: number + ): CompassCorners | undefined { + if (this.resizable === false) return + + const { boundingRect } = this + if (!boundingRect.containsXy(canvasX, canvasY)) return + + // Check corners first (they take priority over edges) + return boundingRect.findContainingCorner( + canvasX, + canvasY, + LGraphNode.resizeHandleSize + ) + } + + /** + * returns all the info available about a property of this node. + * @param property name of the property + * @returns the object with all the available info + */ + getPropertyInfo(property: string) { + let info = null + + // there are several ways to define info about a property + // legacy mode + const { properties_info } = this + if (properties_info) { + for (const propInfo of properties_info) { + if (propInfo.name == property) { + info = propInfo + break + } + } + } + // litescene mode using the constructor + // @ts-expect-error deprecated https://github.com/Comfy-Org/litegraph.js/issues/639 + if (this.constructor[`@${property}`]) + // @ts-expect-error deprecated https://github.com/Comfy-Org/litegraph.js/issues/639 + info = this.constructor[`@${property}`] + + if (this.constructor.widgets_info?.[property]) + info = this.constructor.widgets_info[property] + + // litescene mode using the constructor + if (!info && this.onGetPropertyInfo) { + info = this.onGetPropertyInfo(property) + } + + info ||= {} + info.type ||= typeof this.properties[property] + if (info.widget == 'combo') info.type = 'enum' + + return info + } + + /** + * Defines a widget inside the node, it will be rendered on top of the node, you can control lots of properties + * @param type the widget type + * @param name the text to show on the widget + * @param value the default value + * @param callback function to call when it changes (optionally, it can be the name of the property to modify) + * @param options the object that contains special properties of this widget + * @returns the created widget object + */ + addWidget< + Type extends TWidgetType, + TValue extends WidgetTypeMap[Type]['value'] + >( + type: Type, + name: string, + value: TValue, + callback: IBaseWidget['callback'] | string | null, + options?: IWidgetOptions | string + ): WidgetTypeMap[Type] | IBaseWidget { + this.widgets ||= [] + + if (!options && callback && typeof callback === 'object') { + options = callback + callback = null + } + + // options can be the property name + options ||= {} + if (typeof options === 'string') options = { property: options } + + // callback can be the property name + if (callback && typeof callback === 'string') { + options.property = callback + callback = null + } + + const w: IBaseWidget & { type: Type } = { + // @ts-expect-error - Type casting for widget type property + type: type.toLowerCase(), + name: name, + value: value, + callback: typeof callback !== 'function' ? undefined : callback, + options, + y: 0 + } + + if (w.options.y !== undefined) { + w.y = w.options.y + } + + if (!callback && !w.options.callback && !w.options.property) { + console.warn( + 'LiteGraph addWidget(...) without a callback or property assigned' + ) + } + if (type == 'combo' && !w.options.values) { + throw "LiteGraph addWidget('combo',...) requires to pass values in options: { values:['red','blue'] }" + } + + const widget = this.addCustomWidget(w) + this.expandToFitContent() + return widget + } + + addCustomWidget( + custom_widget: TPlainWidget + ): TPlainWidget | WidgetTypeMap[TPlainWidget['type']] { + this.widgets ||= [] + const widget = toConcreteWidget(custom_widget, this, false) ?? custom_widget + this.widgets.push(widget) + this._widgetSlotsDirty = true + + // Only register with store if node has a valid ID (is already in a graph). + // If the node isn't in a graph yet (id === -1), registration happens + // when the node is added via LGraph.add() -> node.onAdded. + if (this.id !== UNASSIGNED_NODE_ID && isNodeBindable(widget)) { + widget.setNodeId(this.id) + } + + return widget + } + + addTitleButton(options: LGraphButtonOptions): LGraphButton { + this.title_buttons ||= [] + const button = new LGraphButton(options) + this.title_buttons.push(button) + return button + } + + onTitleButtonClick(button: LGraphButton, canvas: LGraphCanvas): void { + // Dispatch event for button click + canvas.dispatch('litegraph:node-title-button-clicked', { + node: this, + button: button + }) + } + + removeWidget(widget: IBaseWidget): void { + if (!this.widgets) + throw new Error('removeWidget called on node without widgets') + + const widgetIndex = this.widgets.indexOf(widget) + if (widgetIndex === -1) throw new Error('Widget not found on this node') + + // Clean up slot references to prevent memory leaks + if (this.inputs) { + for (const input of this.inputs) { + if (input._widget === widget) { + input._widget = undefined + input.widget = undefined + input.pos = undefined + } + } + } + this._widgetSlotsDirty = true + + widget.onRemove?.() + this.widgets.splice(widgetIndex, 1) + } + + ensureWidgetRemoved(widget: IBaseWidget): void { + try { + this.removeWidget(widget) + } catch (error) { + console.error('Failed to remove widget', error) + } + } + + move(deltaX: number, deltaY: number): void { + if (this.pinned) return + + // If Vue nodes mode is enabled, skip LiteGraph's direct position update + // The layout store will handle the movement and sync back to LiteGraph + if (LiteGraph.vueNodesMode) { + // Vue nodes handle their own dragging through the layout store + // This prevents the snap-back issue from conflicting position updates + return + } + + this.pos = [this._pos[0] + deltaX, this._pos[1] + deltaY] + } + + /** + * Internal method to measure the node for rendering. Prefer {@link boundingRect} where possible. + * + * Populates {@link out} with the results in graph space. + * Populates {@link _collapsed_width} with the collapsed width if the node is collapsed. + * Adjusts for title and collapsed status, but does not call {@link onBounding}. + * @param out `x, y, width, height` are written to this array. + * @param ctx The canvas context to use for measuring text. + */ + measure(out: Rect, ctx?: CanvasRenderingContext2D): void { + const titleMode = this.title_mode + const renderTitle = + titleMode != TitleMode.TRANSPARENT_TITLE && + titleMode != TitleMode.NO_TITLE + const titleHeight = renderTitle ? LiteGraph.NODE_TITLE_HEIGHT : 0 + + out[0] = this.pos[0] + out[1] = this.pos[1] + -titleHeight + // In Vue mode, `this.size` is kept in sync with the DOM-measured + // collapsed dimensions via ResizeObserver → layoutStore → useLayoutSync, + // so the expanded branch produces correct bounds for collapsed nodes too. + if (!this.flags?.collapsed || LiteGraph.vueNodesMode) { + out[2] = this.size[0] + out[3] = this.size[1] + titleHeight + } else { + if (ctx) ctx.font = this.innerFontStyle + this._collapsed_width = Math.min( + this.size[0], + ctx + ? cachedMeasureText(ctx, this.getTitle() ?? '') + + LiteGraph.NODE_TITLE_HEIGHT * 2 + : 0 + ) + out[2] = this._collapsed_width || LiteGraph.NODE_COLLAPSED_WIDTH + out[3] = LiteGraph.NODE_TITLE_HEIGHT + } + } + + /** + * returns the bounding of the object, used for rendering purposes + * @param out {Rect?} [optional] a place to store the output, to free garbage + * @param includeExternal {boolean?} [optional] set to true to + * include the shadow and connection points in the bounding calculation + * @returns the bounding box in format of [topleft_cornerx, topleft_cornery, width, height] + */ + getBounding(out?: Rect, includeExternal?: boolean): Rect { + out ||= [0, 0, 0, 0] + + const rect = includeExternal ? this.renderArea : this.boundingRect + out[0] = rect[0] + out[1] = rect[1] + out[2] = rect[2] + out[3] = rect[3] + + return out + } + + /** + * Calculates the render area of this node, populating both {@link boundingRect} and {@link renderArea}. + * Called automatically at the start of every frame. + */ + updateArea(ctx?: CanvasRenderingContext2D): void { + const bounds = this._boundingRect + this.measure(bounds, ctx) + this.onBounding?.(bounds) + + const renderArea = this._renderArea + renderArea.set(bounds) + // 4 offset for collapsed node connection points + renderArea[0] -= 4 + renderArea[1] -= 4 + // Add shadow & left offset + renderArea[2] += 6 + 4 + // Add shadow & top offsets + renderArea[3] += 5 + 4 + } + + /** + * checks if a point is inside the shape of a node + */ + isPointInside(x: number, y: number): boolean { + if (isInRect(x, y, this.boundingRect)) return true + + for (const badge of this.badges.map(toValue).filter((b) => b.onClick)) { + if (isInRect(x - this.pos[0], y - this.pos[1], badge.boundingRect)) + return true + } + return false + } + + /** + * Checks if the provided point is inside this node's collapse button area. + * @param x X co-ordinate to check + * @param y Y co-ordinate to check + * @returns true if the x,y point is in the collapse button area, otherwise false + */ + isPointInCollapse(x: number, y: number): boolean { + const squareLength = LiteGraph.NODE_TITLE_HEIGHT + return isInRectangle( + x, + y, + this.pos[0], + this.pos[1] - squareLength, + squareLength, + squareLength + ) + } + + /** + * Returns the input slot at the given position. Uses full 20 height, and approximates the label length. + * @param pos The graph co-ordinates to check + * @returns The input slot at the given position if found, otherwise `undefined`. + */ + getInputOnPos(pos: Point): INodeInputSlot | undefined { + return getNodeInputOnPos(this, pos[0], pos[1])?.input + } + + /** + * Returns the output slot at the given position. Uses full 20x20 box for the slot. + * @param pos The graph co-ordinates to check + * @returns The output slot at the given position if found, otherwise `undefined`. + */ + getOutputOnPos(pos: Point): INodeOutputSlot | undefined { + return getNodeOutputOnPos(this, pos[0], pos[1])?.output + } + + /** + * Returns the input or output slot at the given position. + * + * Tries {@link getNodeInputOnPos} first, then {@link getNodeOutputOnPos}. + * @param pos The graph co-ordinates to check + * @returns The input or output slot at the given position if found, otherwise `undefined`. + */ + getSlotOnPos(pos: Point): INodeInputSlot | INodeOutputSlot | undefined { + if (!isPointInRect(pos, this.boundingRect)) return + + return this.getInputOnPos(pos) ?? this.getOutputOnPos(pos) + } + + /** + * @deprecated Use {@link getSlotOnPos} instead. + * checks if a point is inside a node slot, and returns info about which slot + * @param x + * @param y + * @returns if found the object contains { input|output: slot object, slot: number, link_pos: [x,y] } + */ + getSlotInPosition(x: number, y: number): IFoundSlot | null { + // search for inputs + const { inputs, outputs } = this + + if (inputs) { + for (const [i, input] of inputs.entries()) { + const pos = this.getInputPos(i) + if (isInRectangle(x, y, pos[0] - 10, pos[1] - 10, 20, 20)) { + return { input, slot: i, link_pos: pos } + } + } + } + + if (outputs) { + for (const [i, output] of outputs.entries()) { + const pos = this.getOutputPos(i) + if (isInRectangle(x, y, pos[0] - 10, pos[1] - 10, 20, 20)) { + return { output, slot: i, link_pos: pos } + } + } + } + + return null + } + + /** + * Gets the widget on this node at the given co-ordinates. + * @param canvasX X co-ordinate in graph space + * @param canvasY Y co-ordinate in graph space + * @returns The widget found, otherwise `null` + */ + getWidgetOnPos( + canvasX: number, + canvasY: number, + includeDisabled = false + ): IBaseWidget | undefined { + const { widgets, pos, size } = this + if (!widgets?.length) return + + const x = canvasX - pos[0] + const y = canvasY - pos[1] + const nodeWidth = size[0] + + for (const widget of widgets) { + if ( + (widget.computedDisabled && !includeDisabled) || + !this.isWidgetVisible(widget) + ) { + continue + } + + const h = + widget.computedHeight ?? + widget.computeSize?.(nodeWidth)[1] ?? + LiteGraph.NODE_WIDGET_HEIGHT + + const maybeDOMWidget = widget as { margin?: number } + const mtop = maybeDOMWidget.margin ?? -2 + const mbot = maybeDOMWidget.margin ?? 2 + const mx = maybeDOMWidget.margin ?? 6 + + const w = widget.width || nodeWidth + if ( + widget.last_y !== undefined && + isInRectangle( + x, + y, + mx, + widget.last_y + mtop, + w - 2 * mx, + h - mtop - mbot + ) + ) { + return widget + } + } + } + + /** + * Returns the input slot with a given name (used for dynamic slots), -1 if not found + * @param name the name of the slot to find + * @param returnObj if the obj itself wanted + * @returns the slot (-1 if not found) + */ + findInputSlot( + name: string, + returnObj?: TReturn + ): number + findInputSlot( + name: string, + returnObj?: TReturn + ): INodeInputSlot + findInputSlot(name: string, returnObj: boolean = false) { + const { inputs } = this + if (!inputs) return -1 + + for (const [i, input] of inputs.entries()) { + if (name == input.name) { + return !returnObj ? i : input + } + } + return -1 + } + + /** + * returns the output slot with a given name (used for dynamic slots), -1 if not found + * @param name the name of the slot to find + * @param returnObj if the obj itself wanted + * @returns the slot (-1 if not found) + */ + findOutputSlot( + name: string, + returnObj?: TReturn + ): number + findOutputSlot( + name: string, + returnObj?: TReturn + ): INodeOutputSlot + findOutputSlot(name: string, returnObj: boolean = false) { + const { outputs } = this + if (!outputs) return -1 + + for (const [i, output] of outputs.entries()) { + if (name == output.name) { + return !returnObj ? i : output + } + } + return -1 + } + + /** + * Finds the first free input slot. + * @param optsIn + * @returns The index of the first matching slot, the slot itself if returnObj is true, or -1 if not found. + */ + findInputSlotFree( + optsIn?: FindFreeSlotOptions & { returnObj?: TReturn } + ): number + findInputSlotFree( + optsIn?: FindFreeSlotOptions & { returnObj?: TReturn } + ): INodeInputSlot | -1 + findInputSlotFree(optsIn?: FindFreeSlotOptions) { + return this._findFreeSlot(this.inputs, optsIn) + } + + /** + * Finds the first free output slot. + * @param optsIn + * @returns The index of the first matching slot, the slot itself if returnObj is true, or -1 if not found. + */ + findOutputSlotFree( + optsIn?: FindFreeSlotOptions & { returnObj?: TReturn } + ): number + findOutputSlotFree( + optsIn?: FindFreeSlotOptions & { returnObj?: TReturn } + ): INodeOutputSlot | -1 + findOutputSlotFree(optsIn?: FindFreeSlotOptions) { + return this._findFreeSlot(this.outputs, optsIn) + } + + /** + * Finds the next free slot + * @param slots The slots to search, i.e. this.inputs or this.outputs + */ + private _findFreeSlot( + slots: TSlot[], + options?: FindFreeSlotOptions + ): TSlot | number { + const defaults = { + returnObj: false, + typesNotAccepted: [] + } + const opts = Object.assign(defaults, options || {}) + const length = slots?.length + if (!(length > 0)) return -1 + + for (let i = 0; i < length; ++i) { + const slot: TSlot & IGenericLinkOrLinks = slots[i] + if (!slot || slot.link || slot.links?.length) continue + if (opts.typesNotAccepted?.includes?.(slot.type)) continue + return !opts.returnObj ? i : slot + } + return -1 + } + + /** + * findSlotByType for INPUTS + */ + findInputSlotByType( + type: ISlotType, + returnObj?: TReturn, + preferFreeSlot?: boolean, + doNotUseOccupied?: boolean + ): number + findInputSlotByType( + type: ISlotType, + returnObj?: TReturn, + preferFreeSlot?: boolean, + doNotUseOccupied?: boolean + ): INodeInputSlot + findInputSlotByType( + type: ISlotType, + returnObj?: boolean, + preferFreeSlot?: boolean, + doNotUseOccupied?: boolean + ) { + return this._findSlotByType( + this.inputs, + type, + returnObj, + preferFreeSlot, + doNotUseOccupied + ) + } + + /** + * findSlotByType for OUTPUTS + */ + findOutputSlotByType( + type: ISlotType, + returnObj?: TReturn, + preferFreeSlot?: boolean, + doNotUseOccupied?: boolean + ): number + findOutputSlotByType( + type: ISlotType, + returnObj?: TReturn, + preferFreeSlot?: boolean, + doNotUseOccupied?: boolean + ): INodeOutputSlot + findOutputSlotByType( + type: ISlotType, + returnObj?: boolean, + preferFreeSlot?: boolean, + doNotUseOccupied?: boolean + ) { + return this._findSlotByType( + this.outputs, + type, + returnObj, + preferFreeSlot, + doNotUseOccupied + ) + } + + /** + * returns the output (or input) slot with a given type, -1 if not found + * @param input use inputs instead of outputs + * @param type the type of the slot to find + * @param returnObj if the obj itself wanted + * @param preferFreeSlot if we want a free slot (if not found, will return the first of the type anyway) + * @returns the slot (-1 if not found) + */ + findSlotByType( + input: TSlot, + type: ISlotType, + returnObj?: TReturn, + preferFreeSlot?: boolean, + doNotUseOccupied?: boolean + ): number + findSlotByType( + input: TSlot, + type: ISlotType, + returnObj?: TReturn, + preferFreeSlot?: boolean, + doNotUseOccupied?: boolean + ): INodeInputSlot | -1 + findSlotByType( + input: TSlot, + type: ISlotType, + returnObj?: TReturn, + preferFreeSlot?: boolean, + doNotUseOccupied?: boolean + ): INodeOutputSlot | -1 + findSlotByType( + input: boolean, + type: ISlotType, + returnObj?: boolean, + preferFreeSlot?: boolean, + doNotUseOccupied?: boolean + ): number | INodeOutputSlot | INodeInputSlot { + return input + ? this._findSlotByType( + this.inputs, + type, + returnObj, + preferFreeSlot, + doNotUseOccupied + ) + : this._findSlotByType( + this.outputs, + type, + returnObj, + preferFreeSlot, + doNotUseOccupied + ) + } + + /** + * Finds a matching slot from those provided, returning the slot itself or its index in {@link slots}. + * @param slots Slots to search (this.inputs or this.outputs) + * @param type Type of slot to look for + * @param returnObj If true, returns the slot itself. Otherwise, the index. + * @param preferFreeSlot Prefer a free slot, but if none are found, fall back to an occupied slot. + * @param doNotUseOccupied Do not fall back to occupied slots. + * @see {findSlotByType} + * @see {findOutputSlotByType} + * @see {findInputSlotByType} + * @returns If a match is found, the slot if returnObj is true, otherwise the index. If no matches are found, -1 + */ + private _findSlotByType( + slots: TSlot[], + type: ISlotType, + returnObj?: boolean, + preferFreeSlot?: boolean, + doNotUseOccupied?: boolean + ): TSlot | number { + const length = slots?.length + if (!length) return -1 + + // Empty string and * match anything (type: 0) + if (type == '' || type == '*') type = 0 + const sourceTypes = String(type).toLowerCase().split(',') + + // Run the search + let occupiedSlot: number | TSlot | null = null + for (let i = 0; i < length; ++i) { + const slot: TSlot & IGenericLinkOrLinks = slots[i] + const destTypes = + slot.type == '0' || slot.type == '*' + ? ['0'] + : String(slot.type).toLowerCase().split(',') + + for (const sourceType of sourceTypes) { + // TODO: Remove _event_ entirely. + const source = sourceType == '_event_' ? LiteGraph.EVENT : sourceType + + for (const destType of destTypes) { + const dest = destType == '_event_' ? LiteGraph.EVENT : destType + + if (source == dest || source === '*' || dest === '*') { + if (preferFreeSlot && (slot.links?.length || slot.link != null)) { + // In case we can't find a free slot. + occupiedSlot ??= returnObj ? slot : i + continue + } + return returnObj ? slot : i + } + } + } + } + + return doNotUseOccupied ? -1 : (occupiedSlot ?? -1) + } + + /** + * Determines the slot index to connect to when attempting to connect by type. + * @param findInputs If true, searches for an input. Otherwise, an output. + * @param node The node at the other end of the connection. + * @param slotType The type of slot at the other end of the connection. + * @param options Search restrictions to adhere to. + * @see {connectByType} + * @see {connectByTypeOutput} + */ + findConnectByTypeSlot( + findInputs: boolean, + node: LGraphNode, + slotType: ISlotType, + options?: ConnectByTypeOptions + ): number | undefined { + // LEGACY: Old options names + if (options && typeof options === 'object') { + if ('firstFreeIfInputGeneralInCase' in options) + options.wildcardToTyped = !!options.firstFreeIfInputGeneralInCase + if ('firstFreeIfOutputGeneralInCase' in options) + options.wildcardToTyped = !!options.firstFreeIfOutputGeneralInCase + if ('generalTypeInCase' in options) + options.typedToWildcard = !!options.generalTypeInCase + } + const optsDef: ConnectByTypeOptions = { + createEventInCase: true, + wildcardToTyped: true, + typedToWildcard: true + } + const opts = Object.assign(optsDef, options) + + if (!this.graph) throw new NullGraphError() + + if (node && typeof node === 'number') { + const nodeById = this.graph.getNodeById(node) + if (!nodeById) return + + node = nodeById + } + const slot = node.findSlotByType(findInputs, slotType, false, true) + if (slot >= 0 && slot !== null) return slot + + // TODO: Remove or reimpl. events. WILL CREATE THE onTrigger IN SLOT + if (opts.createEventInCase && slotType == LiteGraph.EVENT) { + if (findInputs) return -1 + if (LiteGraph.do_add_triggers_slots) return node.addOnExecutedOutput() + } + + // connect to the first general output slot if not found a specific type and + if (opts.typedToWildcard) { + const generalSlot = node.findSlotByType(findInputs, 0, false, true, true) + if (generalSlot >= 0) return generalSlot + } + // connect to the first free input slot if not found a specific type and this output is general + if ( + opts.wildcardToTyped && + (slotType == 0 || slotType == '*' || slotType == '') + ) { + const opt = { typesNotAccepted: [LiteGraph.EVENT] } + const nonEventSlot = findInputs + ? node.findInputSlotFree(opt) + : node.findOutputSlotFree(opt) + if (nonEventSlot >= 0) return nonEventSlot + } + } + + /** + * Finds the first free output slot with any of the comma-delimited types in {@link type}. + * + * If no slots are free, falls back in order to: + * - The first free wildcard slot + * - The first occupied slot + * - The first occupied wildcard slot + * @param type The {@link ISlotType type} of slot to find + * @returns The index and slot if found, otherwise `undefined`. + */ + findOutputByType( + type: ISlotType + ): { index: number; slot: INodeOutputSlot } | undefined { + return findFreeSlotOfType( + this.outputs, + type, + (output) => !output.links?.length + ) + } + + /** + * Finds the first free input slot with any of the comma-delimited types in {@link type}. + * + * If no slots are free, falls back in order to: + * - The first free wildcard slot + * - The first occupied slot + * - The first occupied wildcard slot + * @param type The {@link ISlotType type} of slot to find + * @returns The index and slot if found, otherwise `undefined`. + */ + findInputByType( + type: ISlotType + ): { index: number; slot: INodeInputSlot } | undefined { + return findFreeSlotOfType( + this.inputs, + type, + (input) => + input.link == null || !!this.graph?.getLink(input.link)?._dragging + ) + } + + /** + * connect this node output to the input of another node BY TYPE + * @param slot (could be the number of the slot or the string with the name of the slot) + * @param target_node the target node + * @param target_slotType the input slot type of the target node + * @returns the link_info is created, otherwise null + */ + connectByType( + slot: number | string, + target_node: LGraphNode, + target_slotType: ISlotType, + optsIn?: ConnectByTypeOptions + ): LLink | null { + const slotIndex = this.findConnectByTypeSlot( + true, + target_node, + target_slotType, + optsIn + ) + if (slotIndex !== undefined) + return this.connect(slot, target_node, slotIndex, optsIn?.afterRerouteId) + + // No compatible slot found - connection not possible + return null + } + + /** + * connect this node input to the output of another node BY TYPE + * @param slot (could be the number of the slot or the string with the name of the slot) + * @param source_node the target node + * @param source_slotType the output slot type of the target node + * @returns the link_info is created, otherwise null + */ + connectByTypeOutput( + slot: number | string, + source_node: LGraphNode, + source_slotType: ISlotType, + optsIn?: ConnectByTypeOptions + ): LLink | null { + // LEGACY: Old options names + if (typeof optsIn === 'object') { + if ('firstFreeIfInputGeneralInCase' in optsIn) + optsIn.wildcardToTyped = !!optsIn.firstFreeIfInputGeneralInCase + if ('generalTypeInCase' in optsIn) + optsIn.typedToWildcard = !!optsIn.generalTypeInCase + } + const slotIndex = this.findConnectByTypeSlot( + false, + source_node, + source_slotType, + optsIn + ) + if (slotIndex !== undefined) + return source_node.connect(slotIndex, this, slot, optsIn?.afterRerouteId) + + console.error( + '[connectByType]: no way to connect type:', + source_slotType, + 'to node:', + source_node + ) + return null + } + + canConnectTo( + node: NodeLike, + toSlot: INodeInputSlot | SubgraphIO, + fromSlot: INodeOutputSlot | SubgraphIO + ) { + return ( + this.id !== node.id && + LiteGraph.isValidConnection(fromSlot.type, toSlot.type) + ) + } + + /** + * Connect an output of this node to an input of another node + * @param slot (could be the number of the slot or the string with the name of the slot) + * @param target_node the target node + * @param target_slot the input slot of the target node (could be the number of the slot or the string with the name of the slot, or -1 to connect a trigger) + * @returns the link_info is created, otherwise null + */ + connect( + slot: number | string, + target_node: LGraphNode, + target_slot: ISlotType, + afterRerouteId?: RerouteId + ): LLink | null { + // Allow legacy API support for searching target_slot by string, without mutating the input variables + let targetIndex: number | null + + const { graph, outputs } = this + if (!graph) { + // could be connected before adding it to a graph + // due to link ids being associated with graphs + console.error( + "Connect: Error, node doesn't belong to any graph. Nodes must be added first to a graph before connecting them." + ) + return null + } + + // seek for the output slot + if (typeof slot === 'string') { + slot = this.findOutputSlot(slot) + if (slot == -1) { + if (LiteGraph.debug) + console.error(`Connect: Error, no slot of name ${slot}`) + return null + } + } else if (!outputs || slot >= outputs.length) { + if (LiteGraph.debug) + console.error('Connect: Error, slot number not found') + return null + } + + if (target_node && typeof target_node === 'number') { + const nodeById = graph.getNodeById(target_node) + if (!nodeById) throw 'target node is null' + + target_node = nodeById + } + if (!target_node) throw 'target node is null' + + // avoid loopback + if (target_node == this) return null + + // you can specify the slot by name + if (typeof target_slot === 'string') { + targetIndex = target_node.findInputSlot(target_slot) + if (targetIndex == -1) { + if (LiteGraph.debug) + console.error(`Connect: Error, no slot of name ${targetIndex}`) + return null + } + } else if (target_slot === LiteGraph.EVENT) { + // TODO: Events + if (LiteGraph.do_add_triggers_slots) { + target_node.changeMode(LGraphEventMode.ON_TRIGGER) + targetIndex = target_node.findInputSlot('onTrigger') + } else { + return null + } + } else if (typeof target_slot === 'number') { + targetIndex = target_slot + } else { + targetIndex = 0 + } + + // Allow target node to change slot + if (target_node.onBeforeConnectInput) { + // This way node can choose another slot (or make a new one?) + const requestedIndex = target_node.onBeforeConnectInput( + targetIndex, + target_slot + ) + targetIndex = typeof requestedIndex === 'number' ? requestedIndex : null + } + + if ( + targetIndex === null || + !target_node.inputs || + targetIndex >= target_node.inputs.length + ) { + if (LiteGraph.debug) + console.error('Connect: Error, slot number not found') + return null + } + + const input = target_node.inputs[targetIndex] + const output = outputs[slot] + + if (!output) return null + + if (output.links?.length) { + if ( + output.type === LiteGraph.EVENT && + !LiteGraph.allow_multi_output_for_events + ) { + graph.beforeChange() + this.disconnectOutput(slot) + } + } + + const link = this.connectSlots(output, target_node, input, afterRerouteId) + return link ?? null + } + + /** + * Connect two slots between two nodes + * @param output The output slot to connect + * @param inputNode The node that the input slot is on + * @param input The input slot to connect + * @param afterRerouteId The reroute ID to use for the link + * @returns The link that was created, or null if the connection was blocked + */ + connectSlots( + output: INodeOutputSlot, + inputNode: LGraphNode, + input: INodeInputSlot, + afterRerouteId: RerouteId | undefined + ): LLink | null | undefined { + const { graph } = this + if (!graph) throw new NullGraphError() + + const layoutMutations = useLayoutMutations() + + const outputIndex = this.outputs.indexOf(output) + if (outputIndex === -1) { + console.warn('connectSlots: output not found') + return + } + const inputIndex = inputNode.inputs.indexOf(input) + if (inputIndex === -1) { + console.warn('connectSlots: input not found') + return + } + + // check targetSlot and check connection types + if (!LiteGraph.isValidConnection(output.type, input.type)) { + this.setDirtyCanvas(false, true) + return null + } + + // Allow nodes to block connection + if ( + inputNode.onConnectInput?.( + inputIndex, + output.type, + output, + this, + outputIndex + ) === false + ) + return null + if ( + this.onConnectOutput?.( + outputIndex, + input.type, + input, + inputNode, + inputIndex + ) === false + ) + return null + + // if there is something already plugged there, disconnect + if (inputNode.inputs[inputIndex]?.link != null) { + graph.beforeChange() + inputNode.disconnectInput(inputIndex, true) + } + + const maybeCommonType = + input.type && output.type && commonType(input.type, output.type) + + const linkId = toLinkId(Number(graph.state.lastLinkId) + 1) + graph.state.lastLinkId = linkId + + const link = new LLink( + linkId, + maybeCommonType || input.type || output.type, + this.id, + outputIndex, + inputNode.id, + inputIndex, + afterRerouteId + ) + + // add to graph links list + graph._links.set(link.id, link) + + // Register link in Layout Store for spatial tracking + layoutMutations.setSource(LayoutSource.Canvas) + layoutMutations.createLink( + link.id, + this.id, + outputIndex, + inputNode.id, + inputIndex + ) + + // connect in output + output.links ??= [] + output.links.push(link.id) + // connect in input + const targetInput = inputNode.inputs[inputIndex] + targetInput.link = link.id + if (targetInput.widget) { + graph.trigger('node:slot-links:changed', { + nodeId: inputNode.id, + slotType: NodeSlotType.INPUT, + slotIndex: inputIndex, + connected: true, + linkId: link.id + }) + } + + // Reroutes + const reroutes = LLink.getReroutes(graph, link) + for (const reroute of reroutes) { + reroute.linkIds.add(link.id) + if (reroute.floating) reroute.floating = undefined + reroute._dragging = undefined + } + + // If this is the terminus of a floating link, remove it + const lastReroute = reroutes.at(-1) + if (lastReroute) { + for (const linkId of lastReroute.floatingLinkIds) { + const link = graph.floatingLinks.get(linkId) + if (link?.parentId === lastReroute.id) { + graph.removeFloatingLink(link) + } + } + } + graph.incrementVersion() + + // link has been created now, so its updated + this.onConnectionsChange?.( + NodeSlotType.OUTPUT, + outputIndex, + true, + link, + output + ) + + inputNode.onConnectionsChange?.( + NodeSlotType.INPUT, + inputIndex, + true, + link, + input + ) + + this.setDirtyCanvas(false, true) + graph.afterChange() + + return link + } + + connectFloatingReroute( + pos: Point, + slot: INodeInputSlot | INodeOutputSlot, + afterRerouteId?: RerouteId + ): Reroute { + const { graph, id } = this + if (!graph) throw new NullGraphError() + + // Assertion: It's either there or it isn't. + const inputIndex = this.inputs.indexOf(slot as INodeInputSlot) + const outputIndex = this.outputs.indexOf(slot as INodeOutputSlot) + if (inputIndex === -1 && outputIndex === -1) throw new Error('Invalid slot') + + const slotType = outputIndex === -1 ? 'input' : 'output' + + const reroute = graph.setReroute({ + pos, + parentId: afterRerouteId, + linkIds: [], + floating: { slotType } + }) + + const parentReroute = graph.getReroute(afterRerouteId) + const fromLastFloatingReroute = + parentReroute?.floating?.slotType === 'output' + + // Adding from an output, or a floating reroute that is NOT the tip of an existing floating chain + if (afterRerouteId == null || !fromLastFloatingReroute) { + const link = new LLink( + toLinkId(-1), + slot.type, + outputIndex === -1 ? -1 : id, + outputIndex, + inputIndex === -1 ? -1 : id, + inputIndex + ) + link.parentId = reroute.id + graph.addFloatingLink(link) + return reroute + } + + // Adding a new floating reroute from the tip of a floating chain. + if (!parentReroute) + throw new Error('[connectFloatingReroute] Parent reroute not found') + + const link = parentReroute.getFloatingLinks('output')?.[0] + if (!link) + throw new Error('[connectFloatingReroute] Floating link not found') + + reroute.floatingLinkIds.add(link.id) + link.parentId = reroute.id + parentReroute.floating = undefined + return reroute + } + + /** + * disconnect one output to an specific node + * @param slot (could be the number of the slot or the string with the name of the slot) + * @param target_node the target node to which this slot is connected [Optional, + * if not target_node is specified all nodes will be disconnected] + * @returns if it was disconnected successfully + */ + disconnectOutput(slot: string | number, target_node?: LGraphNode): boolean { + if (typeof slot === 'string') { + slot = this.findOutputSlot(slot) + if (slot == -1) { + if (LiteGraph.debug) + console.error(`Connect: Error, no slot of name ${slot}`) + return false + } + } else if (!this.outputs || slot >= this.outputs.length) { + if (LiteGraph.debug) + console.error('Connect: Error, slot number not found') + return false + } + + // get output slot + const output = this.outputs[slot] + if (!output) return false + + if (output._floatingLinks) { + for (const link of output._floatingLinks) { + if (link.hasOrigin(this.id, slot)) { + this.graph?.removeFloatingLink(link) + } + } + } + + if (!output.links || output.links.length == 0) return false + const { links } = output + + // one of the output links in this slot + const graph = this.graph + if (!graph) throw new NullGraphError() + + if (target_node) { + const target = + typeof target_node === 'number' + ? graph.getNodeById(target_node) + : target_node + if (!target) throw 'Target Node not found' + + for (const [i, link_id] of links.entries()) { + const link_info = graph._links.get(link_id) + if (link_info?.target_id != target.id) continue + + // is the link we are searching for... + // remove here + links.splice(i, 1) + const input = target.inputs[link_info.target_slot] + // remove there + input.link = null + if (input.widget) { + graph.trigger('node:slot-links:changed', { + nodeId: target.id, + slotType: NodeSlotType.INPUT, + slotIndex: link_info.target_slot, + connected: false, + linkId: link_info.id + }) + } + + // remove the link from the links pool + link_info.disconnect(graph, 'input') + graph.incrementVersion() + + // link_info hasn't been modified so its ok + target.onConnectionsChange?.( + NodeSlotType.INPUT, + link_info.target_slot, + false, + link_info, + input + ) + this.onConnectionsChange?.( + NodeSlotType.OUTPUT, + slot, + false, + link_info, + output + ) + + break + } + } else { + // all the links in this output slot + for (const link_id of links) { + const link_info = graph._links.get(link_id) + if (!link_info) continue + if ( + link_info.target_id === SUBGRAPH_OUTPUT_ID && + graph instanceof Subgraph + ) { + const targetSlot = graph.outputNode.slots[link_info.target_slot] + if (targetSlot) { + targetSlot.linkIds.length = 0 + } else { + console.error('Missing subgraphOutput slot when disconnecting link') + } + } + + const target = graph.getNodeById(link_info.target_id) + graph.incrementVersion() + + if (target) { + const input = target.inputs[link_info.target_slot] + // remove other side link + input.link = null + if (input.widget) { + graph.trigger('node:slot-links:changed', { + nodeId: target.id, + slotType: NodeSlotType.INPUT, + slotIndex: link_info.target_slot, + connected: false, + linkId: link_info.id + }) + } + + // link_info hasn't been modified so its ok + target.onConnectionsChange?.( + NodeSlotType.INPUT, + link_info.target_slot, + false, + link_info, + input + ) + } + // remove the link from the links pool + link_info.disconnect(graph, 'input') + + this.onConnectionsChange?.( + NodeSlotType.OUTPUT, + slot, + false, + link_info, + output + ) + } + output.links = null + } + + this.setDirtyCanvas(false, true) + return true + } + + /** + * Disconnect one input + * @param slot Input slot index, or the name of the slot + * @param keepReroutes If `true`, reroutes will not be garbage collected. + * @returns true if disconnected successfully or already disconnected, otherwise false + */ + disconnectInput(slot: number | string, keepReroutes?: boolean): boolean { + // Allow search by string + if (typeof slot === 'string') { + slot = this.findInputSlot(slot) + if (slot == -1) { + if (LiteGraph.debug) + console.error(`Connect: Error, no slot of name ${slot}`) + return false + } + } else if (!this.inputs || slot >= this.inputs.length) { + if (LiteGraph.debug) { + console.error('Connect: Error, slot number not found') + } + return false + } + + const input = this.inputs[slot] + if (!input) { + console.error('disconnectInput: input not found', slot, this.inputs) + return false + } + + const { graph } = this + if (!graph) throw new NullGraphError() + + // Break floating links + if (input._floatingLinks?.size) { + for (const link of input._floatingLinks) { + graph.removeFloatingLink(link) + } + } + + const link_id = this.inputs[slot].link + if (link_id != null) { + this.inputs[slot].link = null + if (input.widget) { + graph.trigger('node:slot-links:changed', { + nodeId: this.id, + slotType: NodeSlotType.INPUT, + slotIndex: slot, + connected: false, + linkId: link_id + }) + } + + // remove other side + const link_info = graph._links.get(link_id) + if (link_info) { + // Let SubgraphInput do the disconnect. + if (link_info.origin_id === SUBGRAPH_INPUT_ID && 'inputNode' in graph) { + graph.inputNode._disconnectNodeInput(this, input, link_info) + return true + } + + const target_node = graph.getNodeById(link_info.origin_id) + if (!target_node) { + console.error( + 'disconnectInput: output not found', + link_info.origin_slot + ) + return false + } + + const output = target_node.outputs[link_info.origin_slot] + if (!output?.links?.length) { + // Output not found - may have been removed + return false + } + + // search in the inputs list for this link + let i = 0 + for (const l = output.links.length; i < l; i++) { + if (output.links[i] == link_id) { + output.links.splice(i, 1) + break + } + } + + link_info.disconnect(graph, keepReroutes ? 'output' : undefined) + if (graph) graph.incrementVersion() + + this.onConnectionsChange?.( + NodeSlotType.INPUT, + slot, + false, + link_info, + input + ) + target_node.onConnectionsChange?.( + NodeSlotType.OUTPUT, + i, + false, + link_info, + output + ) + } + } + + this.setDirtyCanvas(false, true) + return true + } + + /** + * @deprecated Use {@link getInputPos} or {@link getOutputPos} instead. + * returns the center of a connection point in canvas coords + * @param is_input true if if a input slot, false if it is an output + * @param slot_number (could be the number of the slot or the string with the name of the slot) + * @param out [optional] a place to store the output, to free garbage + * @returns the position + */ + getConnectionPos(is_input: boolean, slot_number: number, out?: Point): Point { + out ||= [0, 0] + + const { + pos: [nodeX, nodeY], + inputs, + outputs + } = this + + if (this.flags.collapsed) { + const w = this._collapsed_width || LiteGraph.NODE_COLLAPSED_WIDTH + out[0] = is_input ? nodeX : nodeX + w + out[1] = nodeY - LiteGraph.NODE_TITLE_HEIGHT * 0.5 + return out + } + + // weird feature that never got finished + if (is_input && slot_number == -1) { + out[0] = nodeX + LiteGraph.NODE_TITLE_HEIGHT * 0.5 + out[1] = nodeY + LiteGraph.NODE_TITLE_HEIGHT * 0.5 + return out + } + + // hard-coded pos + const inputPos = inputs?.[slot_number]?.pos + const outputPos = outputs?.[slot_number]?.pos + + if (is_input && inputPos) { + out[0] = nodeX + inputPos[0] + out[1] = nodeY + inputPos[1] + return out + } else if (!is_input && outputPos) { + out[0] = nodeX + outputPos[0] + out[1] = nodeY + outputPos[1] + return out + } + + // default vertical slots + const offset = LiteGraph.NODE_SLOT_HEIGHT * 0.5 + const slotIndex = is_input + ? this._defaultVerticalInputs.indexOf(this.inputs[slot_number]) + : this._defaultVerticalOutputs.indexOf(this.outputs[slot_number]) + + out[0] = is_input ? nodeX + offset : nodeX + this.size[0] + 1 - offset + out[1] = + nodeY + + (slotIndex + 0.7) * LiteGraph.NODE_SLOT_HEIGHT + + (this.constructor.slot_start_y || 0) + return out + } + + /** + * @internal The inputs that are not positioned with absolute coordinates. + */ + private get _defaultVerticalInputs() { + return this.inputs.filter( + (slot) => !slot.pos && !(this.widgets?.length && isWidgetInputSlot(slot)) + ) + } + + /** + * @internal The outputs that are not positioned with absolute coordinates. + */ + private get _defaultVerticalOutputs() { + return this.outputs.filter((slot: INodeOutputSlot) => !slot.pos) + } + + /** + * Get the context needed for slot position calculations + * @internal + */ + private _getSlotPositionContext(): SlotPositionContext { + return { + nodeX: this.pos[0], + nodeY: this.pos[1], + nodeWidth: this.size[0], + nodeHeight: this.size[1], + collapsed: this.flags.collapsed ?? false, + collapsedWidth: this._collapsed_width, + slotStartY: this.constructor.slot_start_y, + inputs: this.inputs, + outputs: this.outputs, + widgets: this.widgets + } + } + + /** + * Gets the position of an input slot, in graph co-ordinates. + * + * This method is preferred over the legacy {@link getConnectionPos} method. + * @param slot Input slot index + * @returns Position of the input slot + */ + getInputPos(slot: number): Point { + return getSlotPosition(this, slot, true) + } + + /** + * Gets the position of an input slot, in graph co-ordinates. + * @param input The actual node input object + * @returns Position of the centre of the input slot in graph co-ordinates. + */ + getInputSlotPos(input: INodeInputSlot): Point { + return calculateInputSlotPosFromSlot(this._getSlotPositionContext(), input) + } + + /** + * Gets the position of an output slot, in graph co-ordinates. + * + * This method is preferred over the legacy {@link getConnectionPos} method. + * @param outputSlotIndex Output slot index + * @returns Position of the output slot + */ + getOutputPos(outputSlotIndex: SlotIndex): Point { + return getSlotPosition(this, outputSlotIndex, false) + } + + /** + * Get slot position using layout tree if available, fallback to node's position * Unified implementation used by both LitegraphLinkAdapter and useLinkLayoutSync + * @param slotIndex The slot index + * @param isInput Whether this is an input slot + * @returns Position of the slot center in graph coordinates + */ + getSlotPosition(slotIndex: number, isInput: boolean): Point { + return getSlotPosition(this, slotIndex, isInput) + } + + /** @inheritdoc */ + snapToGrid(snapTo: number): boolean { + return this.pinned ? false : snapPoint(this.pos, snapTo) + } + + /** @see {@link snapToGrid} */ + alignToGrid(): void { + this.snapToGrid(LiteGraph.CANVAS_GRID_SIZE) + } + + /* Console output */ + trace(msg: string): void { + this.console ||= [] + this.console.push(msg) + // @ts-expect-error deprecated + if (this.console.length > LGraphNode.MAX_CONSOLE) this.console.shift() + } + + /* Forces to redraw or the main canvas (LGraphNode) or the bg canvas (links) */ + setDirtyCanvas(dirty_foreground: boolean, dirty_background?: boolean): void { + this.graph?.canvasAction((c) => + c.setDirty(dirty_foreground, dirty_background) + ) + } + + loadImage(url: string): HTMLImageElement { + interface AsyncImageElement extends HTMLImageElement { + ready?: boolean + } + + const img: AsyncImageElement = new Image() + img.src = LiteGraph.node_images_path + url + img.ready = false + + const dirty = () => this.setDirtyCanvas(true) + img.addEventListener('load', function (this: AsyncImageElement) { + this.ready = true + dirty() + }) + return img + } + + /** + * Allows to get onMouseMove and onMouseUp events even if the mouse is out of focus + * @deprecated Use {@link LGraphCanvas.pointer} instead. + */ + captureInput(v: boolean): void { + warnDeprecated( + '[DEPRECATED] captureInput will be removed in a future version. Please use LGraphCanvas.pointer (CanvasPointer) instead.' + ) + if (!this.graph || !this.graph.list_of_graphcanvas) return + + const list = this.graph.list_of_graphcanvas + + for (const c of list) { + // releasing somebody elses capture?! + if (!v && c.node_capturing_input != this) continue + + // change + c.node_capturing_input = v ? this : null + } + } + + get collapsed() { + return !!this.flags.collapsed + } + + get collapsible() { + return !this.pinned && this.constructor.collapsable !== false + } + + /** + * Toggle node collapse (makes it smaller on the canvas) + */ + collapse(force?: boolean): void { + if (!this.collapsible && !force) return + if (!this.graph) throw new NullGraphError() + this.graph.incrementVersion() + this.flags.collapsed = !this.flags.collapsed + this.setDirtyCanvas(true, true) + } + + /** + * Toggles advanced mode of the node, showing advanced widgets + */ + toggleAdvanced() { + if (!this.hasAdvancedWidgets()) return + if (!this.graph) throw new NullGraphError() + this.graph.incrementVersion() + this.showAdvanced = !this.showAdvanced + this.expandToFitContent() + this.setDirtyCanvas(true, true) + } + + get pinned() { + return !!this.flags.pinned + } + + /** + * Prevents the node being accidentally moved or resized by mouse interaction. + * Toggles pinned state if no value is provided. + */ + pin(v?: boolean): void { + if (!this.graph) throw new NullGraphError() + + this.graph.incrementVersion() + this.flags.pinned = v ?? !this.flags.pinned + this.resizable = !this.pinned + if (!this.pinned) this.flags.pinned = undefined + } + + unpin(): void { + this.pin(false) + } + + localToScreen(x: number, y: number, dragAndScale: DragAndScale): Point { + return [ + (x + this.pos[0]) * dragAndScale.scale + dragAndScale.offset[0], + (y + this.pos[1]) * dragAndScale.scale + dragAndScale.offset[1] + ] + } + + get width() { + return this.collapsed + ? this._collapsed_width || LiteGraph.NODE_COLLAPSED_WIDTH + : this.size[0] + } + + /** + * Returns the height of the node, including the title bar. + */ + get height() { + return LiteGraph.NODE_TITLE_HEIGHT + this.bodyHeight + } + + /** + * Returns the height of the node, excluding the title bar. + */ + get bodyHeight() { + return this.collapsed ? 0 : this.size[1] + } + + drawBadges(ctx: CanvasRenderingContext2D, { gap = 2 } = {}): void { + const badgeInstances = this.badges.map((badge) => + badge instanceof LGraphBadge ? badge : badge() + ) + const isLeftAligned = this.badgePosition === BadgePosition.TopLeft + + let currentX = isLeftAligned + ? 0 + : this.width - + badgeInstances.reduce( + (acc, badge) => acc + badge.getWidth(ctx) + gap, + 0 + ) + const y = -(LiteGraph.NODE_TITLE_HEIGHT + gap) + + for (const badge of badgeInstances) { + badge.draw(ctx, currentX, y - badge.height) + currentX += badge.getWidth(ctx) + gap + } + } + + /** + * Renders the node's title bar background + */ + drawTitleBarBackground( + ctx: CanvasRenderingContext2D, + { + scale, + title_height = LiteGraph.NODE_TITLE_HEIGHT, + low_quality = false + }: DrawTitleOptions + ): void { + const fgcolor = this.renderingColor + const shape = this.renderingShape + const size = this.renderingSize + + if (this.onDrawTitleBar) { + this.onDrawTitleBar(ctx, title_height, size, scale, fgcolor) + return + } + + if (this.title_mode === TitleMode.TRANSPARENT_TITLE) { + return + } + + if (this.collapsed) { + ctx.shadowColor = LiteGraph.DEFAULT_SHADOW_COLOR + } + + ctx.fillStyle = this.constructor.title_color || fgcolor + ctx.beginPath() + + if (shape == RenderShape.BOX || low_quality) { + ctx.rect(0, -title_height, size[0], title_height) + } else if (shape == RenderShape.ROUND || shape == RenderShape.CARD) { + ctx.roundRect( + 0, + -title_height, + size[0], + title_height, + this.collapsed + ? [LiteGraph.ROUND_RADIUS] + : [LiteGraph.ROUND_RADIUS, LiteGraph.ROUND_RADIUS, 0, 0] + ) + } + ctx.fill() + ctx.shadowColor = 'transparent' + } + + /** + * Renders the node's title box, i.e. the dot in front of the title text that + * when clicked toggles the node's collapsed state. The term `title box` comes + * from the original LiteGraph implementation. + */ + drawTitleBox( + ctx: CanvasRenderingContext2D, + { + scale, + low_quality = false, + title_height = LiteGraph.NODE_TITLE_HEIGHT, + box_size = 10 + }: DrawTitleBoxOptions + ): void { + const size = this.renderingSize + const shape = this.renderingShape + + if (this.onDrawTitleBox) { + this.onDrawTitleBox(ctx, title_height, size, scale) + return + } + + if ( + [RenderShape.ROUND, RenderShape.CIRCLE, RenderShape.CARD].includes(shape) + ) { + if (low_quality) { + ctx.fillStyle = 'black' + ctx.beginPath() + ctx.arc( + title_height * 0.5, + title_height * -0.5, + box_size * 0.5 + 1, + 0, + Math.PI * 2 + ) + ctx.fill() + } + + ctx.fillStyle = this.renderingBoxColor + if (low_quality) { + ctx.fillRect( + title_height * 0.5 - box_size * 0.5, + title_height * -0.5 - box_size * 0.5, + box_size, + box_size + ) + } else { + ctx.beginPath() + ctx.arc( + title_height * 0.5, + title_height * -0.5, + box_size * 0.5, + 0, + Math.PI * 2 + ) + ctx.fill() + } + } else { + if (low_quality) { + ctx.fillStyle = 'black' + ctx.fillRect( + (title_height - box_size) * 0.5 - 1, + (title_height + box_size) * -0.5 - 1, + box_size + 2, + box_size + 2 + ) + } + ctx.fillStyle = this.renderingBoxColor + ctx.fillRect( + (title_height - box_size) * 0.5, + (title_height + box_size) * -0.5, + box_size, + box_size + ) + } + } + + /** + * Renders the node's title text. + */ + drawTitleText( + ctx: CanvasRenderingContext2D, + { + scale, + default_title_color, + low_quality = false, + title_height = LiteGraph.NODE_TITLE_HEIGHT + }: DrawTitleTextOptions + ): void { + const size = this.renderingSize + const selected = this.selected + + if (this.onDrawTitleText) { + this.onDrawTitleText( + ctx, + title_height, + size, + scale, + this.titleFontStyle, + selected + ) + return + } + + // Don't render title text if low quality + if (low_quality) { + return + } + + ctx.font = this.titleFontStyle + const rawTitle = this.getTitle() ?? `❌ ${this.type}` + const title = String(rawTitle) + (this.pinned ? '📌' : '') + if (title) { + if (selected) { + ctx.fillStyle = LiteGraph.NODE_SELECTED_TITLE_COLOR + } else { + ctx.fillStyle = this.constructor.title_text_color || default_title_color + } + + // Calculate available width for title + let availableWidth = size[0] - title_height * 2 // Basic margins + + // Subtract space for title buttons + if (this.title_buttons?.length > 0) { + let buttonsWidth = 0 + const savedFont = ctx.font // Save current font + for (const button of this.title_buttons) { + if (button.visible) { + buttonsWidth += button.getWidth(ctx) + 2 // button width + gap + } + } + ctx.font = savedFont // Restore font after button measurements + if (buttonsWidth > 0) { + buttonsWidth -= 20 // Reduce by empty padding + availableWidth -= buttonsWidth + } + } + + // Truncate title if needed + let displayTitle = title + + if (this.collapsed) { + // For collapsed nodes, limit to 20 chars as before + displayTitle = title.substr(0, 20) + } else if (availableWidth > 0) { + // For regular nodes, truncate based on available width + displayTitle = truncateText(ctx, title, availableWidth) + } + + ctx.textAlign = 'left' + ctx.fillText( + displayTitle, + title_height, + LiteGraph.NODE_TITLE_TEXT_Y - title_height + ) + } + } + + /** + * Attempts to gracefully bypass this node in all of its connections by reconnecting all links. + * + * Each input is checked against each output. This is done on a matching index basis, i.e. input 3 -> output 3. + * If there are any input links remaining, + * and {@link flags}.{@link INodeFlags.keepAllLinksOnBypass keepAllLinksOnBypass} is `true`, + * each input will check for outputs that match, and take the first one that matches + * `true`: Try the index matching first, then every input to every output. + * `false`: Only matches indexes, e.g. input 3 to output 3. + * + * If {@link flags}.{@link INodeFlags.keepAllLinksOnBypass keepAllLinksOnBypass} is `undefined`, it will fall back to + * the static {@link keepAllLinksOnBypass}. + * @returns `true` if any new links were established, otherwise `false`. + * @todo Decision: Change API to return array of new links instead? + */ + connectInputToOutput(): boolean | undefined { + const { inputs, outputs, graph } = this + if (!inputs || !outputs) return + if (!graph) throw new NullGraphError() + + const { _links } = graph + let madeAnyConnections = false + + // First pass: only match exactly index-to-index + for (const [index, input] of inputs.entries()) { + if (input.link == null) continue + + const output = outputs[index] + if (!output || !LiteGraph.isValidConnection(input.type, output.type)) + continue + + const inLink = _links.get(input.link) + if (!inLink) continue + const inNode = graph.getNodeById(inLink?.origin_id) + if (!inNode) continue + + bypassAllLinks(output, inNode, inLink, graph) + } + // Configured to only use index-to-index matching + if (!(this.flags.keepAllLinksOnBypass ?? LGraphNode.keepAllLinksOnBypass)) + return madeAnyConnections + + // Second pass: match any remaining links + for (const input of inputs) { + if (input.link == null) continue + + const inLink = _links.get(input.link) + if (!inLink) continue + const inNode = graph.getNodeById(inLink?.origin_id) + if (!inNode) continue + + for (const output of outputs) { + if (!LiteGraph.isValidConnection(input.type, output.type)) continue + + bypassAllLinks(output, inNode, inLink, graph) + break + } + } + return madeAnyConnections + + function bypassAllLinks( + output: INodeOutputSlot, + inNode: LGraphNode, + inLink: LLink, + graph: LGraph + ) { + const outLinks = output.links + ?.map((x) => _links.get(x)) + .filter((x) => !!x) + if (!outLinks?.length) return + + for (const outLink of outLinks) { + const outNode = graph.getNodeById(outLink.target_id) + if (!outNode) continue + + const result = inNode.connect( + inLink.origin_slot, + outNode, + outLink.target_slot, + inLink.parentId + ) + madeAnyConnections ||= !!result + } + } + } + + /** + * Returns `true` if the widget is visible, otherwise `false`. + */ + isWidgetVisible(widget: IBaseWidget): boolean { + const isHidden = + this.collapsed || widget.hidden || (widget.advanced && !this.showAdvanced) + return !isHidden + } + + /** + * Returns all widgets that should participate in layout calculations. + * Filters out hidden widgets only (not collapsed/advanced). + */ + getLayoutWidgets(): IBaseWidget[] { + return this.widgets?.filter((w) => !w.hidden) ?? [] + } + + /** + * Returns `true` if the node has any advanced widgets. + */ + hasAdvancedWidgets(): boolean { + return this.widgets?.some((w) => w.advanced) ?? false + } + + updateComputedDisabled() { + if (!this.widgets) return + for (const widget of this.widgets) + widget.computedDisabled = + widget.disabled || this.getSlotFromWidget(widget)?.link != null + } + + drawWidgets( + ctx: CanvasRenderingContext2D, + { lowQuality = false, editorAlpha = 1 }: DrawWidgetsOptions + ): void { + if (!this.widgets) return + + const nodeWidth = this.size[0] + const { widgets } = this + const H = LiteGraph.NODE_WIDGET_HEIGHT + const showText = !lowQuality + ctx.save() + ctx.globalAlpha = editorAlpha + + this.updateComputedDisabled() + for (const widget of widgets) { + if (!this.isWidgetVisible(widget)) continue + + const { y } = widget + const outlineColour = widget.advanced + ? LiteGraph.WIDGET_ADVANCED_OUTLINE_COLOR + : LiteGraph.WIDGET_OUTLINE_COLOR + + widget.last_y = y + + ctx.strokeStyle = outlineColour + ctx.fillStyle = '#222' + ctx.textAlign = 'left' + if (widget.computedDisabled) ctx.globalAlpha *= 0.5 + const width = widget.width || nodeWidth + + if (typeof widget.draw === 'function') { + widget.draw(ctx, this, width, y, H, lowQuality) + } else { + toConcreteWidget(widget, this, false)?.drawWidget(ctx, { + width, + showText + }) + } + ctx.globalAlpha = editorAlpha + } + ctx.restore() + } + + /** + * When {@link LGraphNode.collapsed} is `true`, this method draws the node's collapsed slots. + */ + drawCollapsedSlots(ctx: CanvasRenderingContext2D): void { + // Render the first connected slot only. + for (const slot of this._concreteInputs) { + if (slot.link != null) { + slot.drawCollapsed(ctx) + break + } + } + for (const slot of this._concreteOutputs) { + if (slot.links?.length) { + slot.drawCollapsed(ctx) + break + } + } + } + + get slots(): (INodeInputSlot | INodeOutputSlot)[] { + return [...this.inputs, ...this.outputs] + } + + private _measureSlot( + slot: NodeInputSlot | NodeOutputSlot, + slotIndex: number, + isInput: boolean + ): void { + const pos = isInput + ? this.getInputPos(slotIndex) + : this.getOutputPos(slotIndex) + + slot.boundingRect[0] = pos[0] - LiteGraph.NODE_SLOT_HEIGHT * 0.5 + slot.boundingRect[1] = pos[1] - LiteGraph.NODE_SLOT_HEIGHT * 0.5 + slot.boundingRect[2] = slot.isWidgetInputSlot + ? BaseWidget.margin + : LiteGraph.NODE_SLOT_HEIGHT + slot.boundingRect[3] = LiteGraph.NODE_SLOT_HEIGHT + } + + private _measureSlots(): ReadOnlyRect | null { + const slots: (NodeInputSlot | NodeOutputSlot)[] = [] + + for (const [slotIndex, slot] of this._concreteInputs.entries()) { + // Unrecognized nodes (Nodes with error) has inputs but no widgets. Treat + // converted inputs as normal inputs. + /** Widget input slots are handled in {@link layoutWidgetInputSlots} */ + if (this.widgets?.length && isWidgetInputSlot(slot)) continue + + this._measureSlot(slot, slotIndex, true) + slots.push(slot) + } + for (const [slotIndex, slot] of this._concreteOutputs.entries()) { + this._measureSlot(slot, slotIndex, false) + slots.push(slot) + } + + return slots.length ? createBounds(slots, 0) : null + } + + private _getMouseOverSlot(slot: INodeSlot): INodeSlot | null { + const isInput = isINodeInputSlot(slot) + const mouseOverId = this.mouseOver?.[isInput ? 'inputId' : 'outputId'] ?? -1 + if (mouseOverId === -1) { + return null + } + return isInput ? this.inputs[mouseOverId] : this.outputs[mouseOverId] + } + + private _isMouseOverSlot(slot: INodeSlot): boolean { + return this._getMouseOverSlot(slot) === slot + } + + private _isMouseOverWidget(widget: IBaseWidget | undefined): boolean { + if (!widget) return false + return this.mouseOver?.overWidget === widget + } + + /** + * Returns the input slot that is associated with the given widget. + */ + getSlotFromWidget( + widget: IBaseWidget | undefined + ): INodeInputSlot | undefined { + if (widget) + return this.inputs.find( + (slot) => isWidgetInputSlot(slot) && slot.widget.name === widget.name + ) + } + + /** + * Returns the widget that is associated with the given input slot. + */ + getWidgetFromSlot(slot: INodeInputSlot): IBaseWidget | undefined { + if (!isWidgetInputSlot(slot)) return + return this.widgets?.find((w) => w.name === slot.widget.name) + } + + /** + * Draws the node's input and output slots. + */ + drawSlots( + ctx: CanvasRenderingContext2D, + { fromSlot, colorContext, editorAlpha, lowQuality }: DrawSlotsOptions + ) { + for (const slot of [...this._concreteInputs, ...this._concreteOutputs]) { + const isValidTarget = fromSlot && slot.isValidTarget(fromSlot) + const isMouseOverSlot = this._isMouseOverSlot(slot) + + // change opacity of incompatible slots when dragging a connection + const isValid = !fromSlot || isValidTarget + const highlight = isValid && isMouseOverSlot + + // Show slot if it's not a widget input slot + // or if it's a widget input slot and satisfies one of the following: + // - the mouse is over the widget + // - the slot is valid during link drop + // - the slot is connected + if ( + isMouseOverSlot || + isValidTarget || + !slot.isWidgetInputSlot || + this._isMouseOverWidget(this.getWidgetFromSlot(slot)) || + slot.isConnected || + slot.alwaysVisible + ) { + ctx.globalAlpha = isValid ? editorAlpha : 0.4 * editorAlpha + slot.draw(ctx, { + colorContext, + lowQuality, + highlight + }) + } + } + } + + /** + * Arranges the node's widgets vertically. + * Sets following properties on each widget: + * - {@link IBaseWidget.computedHeight} + * - {@link IBaseWidget.y} + * @param widgetStartY The y-coordinate of the first widget + */ + private _arrangeWidgets(widgetStartY: number): void { + if (!this.widgets || !this.widgets.length) return + + const bodyHeight = this.bodyHeight + const startY = + this.widgets_start_y ?? (this.widgets_up ? 0 : widgetStartY) + 2 + + let freeSpace = bodyHeight - startY + + // Collect fixed height widgets first + let fixedWidgetHeight = 0 + const growableWidgets: { + minHeight: number + prefHeight?: number + w: IBaseWidget + }[] = [] + + const visibleWidgets = this.getLayoutWidgets() + + for (const w of visibleWidgets) { + if (w.computeSize) { + const height = w.computeSize()[1] + 4 + w.computedHeight = height + fixedWidgetHeight += height + } else if (w.computeLayoutSize) { + const { minHeight, maxHeight } = w.computeLayoutSize(this) + growableWidgets.push({ + minHeight, + prefHeight: maxHeight, + w + }) + } else { + const height = LiteGraph.NODE_WIDGET_HEIGHT + 4 + w.computedHeight = height + fixedWidgetHeight += height + } + } + + // Calculate remaining space for DOM widgets + freeSpace -= fixedWidgetHeight + this.freeWidgetSpace = freeSpace + + // Prepare space requests for distribution + const spaceRequests = growableWidgets.map((d) => ({ + minSize: d.minHeight, + maxSize: d.prefHeight + })) + + // Distribute space among DOM widgets + const allocations = distributeSpace(Math.max(0, freeSpace), spaceRequests) + + // Apply computed heights + for (const [i, d] of growableWidgets.entries()) { + d.w.computedHeight = allocations[i] + } + + // Position widgets + let y = startY + for (const w of visibleWidgets) { + w.y = y + y += w.computedHeight ?? 0 + } + + if (!this.graph) throw new NullGraphError() + + // Grow the node if necessary. + // Ref: https://github.com/Comfy-Org/ComfyUI_frontend/issues/2652 + // TODO: Move the layout logic before drawing of the node shape, so we don't + // need to trigger extra round of rendering. + // In Vue mode, the DOM is the source of truth for node sizing — the + // ResizeObserver feeds measurements back to the layout store. Allowing + // LiteGraph to also call setSize() here creates an infinite feedback loop + // (LG grows node → CSS min-height increases → textarea fills extra space → + // ResizeObserver reports larger size → LG grows node again). + if (!LiteGraph.vueNodesMode && y > bodyHeight) { + this.setSize([this.size[0], y]) + this.graph.setDirtyCanvas(false, true) + } + } + + /** + * Arranges the layout of the node's widget input slots. + */ + private _arrangeWidgetInputSlots(): void { + if (!this.widgets?.length) return + + // Build a name→widget map for fast lookup. + const widgetByName = new Map() + for (const w of this.widgets) widgetByName.set(w.name, w) + + // Set widget-backed slot positions from widget Y coordinates. + // In Vue mode, promoted widget inputs are not rendered as + // components (NodeSlots filters them out), so they have no DOM-registered + // position. input.pos serves as the fallback for getSlotPosition(). + for (const [i, slot] of this._concreteInputs.entries()) { + if (!isWidgetInputSlot(slot)) continue + + // Prefer the slot's direct _widget binding (1:1 for promoted inputs). + // Fall back to name-map lookup for regular nodes without _widget set. + // Note: the name-map is ambiguous if two promoted inputs share a label; + // _widget avoids this since it is a direct reference. + const widget = slot._widget ?? widgetByName.get(slot.widget.name) + if (!widget) continue + + const offset = LiteGraph.NODE_SLOT_HEIGHT * 0.5 + const pos: [number, number] = [offset, widget.y + offset] + slot.pos = pos + this.inputs[i].pos = pos + this._measureSlot(slot, i, true) + } + } + + /** + * @internal Sets the internal concrete slot arrays, ensuring they are instances of + * {@link NodeInputSlot} or {@link NodeOutputSlot}. + * + * A temporary workaround until duck-typed inputs and outputs + * have been removed from the ecosystem. + */ + _setConcreteSlots(): void { + this._concreteInputs = this.inputs.map((slot) => + toClass(NodeInputSlot, slot, this) + ) + this._concreteOutputs = this.outputs.map((slot) => + toClass(NodeOutputSlot, slot, this) + ) + } + + /** + * Arranges node elements in preparation for rendering (slots & widgets). + */ + arrange(): void { + const slotsBounds = this._measureSlots() + const widgetStartY = slotsBounds + ? slotsBounds[1] + slotsBounds[3] - this.pos[1] + : 0 + this._arrangeWidgets(widgetStartY) + this._arrangeWidgetInputSlots() + this._widgetSlotsDirty = false + } + + /** + * Draws a progress bar on the node. + * @param ctx The canvas context to draw on + */ + drawProgressBar(ctx: CanvasRenderingContext2D): void { + if (!this.progress) return + + const originalFillStyle = ctx.fillStyle + ctx.fillStyle = 'green' + ctx.fillRect(0, 0, this.width * this.progress, 6) + ctx.fillStyle = originalFillStyle + } +} diff --git a/docs/hel-892/promoted-reference/1.48.7__src__lib__litegraph__src__subgraph__SubgraphInput.ts b/docs/hel-892/promoted-reference/1.48.7__src__lib__litegraph__src__subgraph__SubgraphInput.ts new file mode 100644 index 00000000..cf890dcf --- /dev/null +++ b/docs/hel-892/promoted-reference/1.48.7__src__lib__litegraph__src__subgraph__SubgraphInput.ts @@ -0,0 +1,263 @@ +import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode' +import { LLink } from '@/lib/litegraph/src/LLink' +import { toLinkId } from '@/types/linkId' +import type { RerouteId } from '@/lib/litegraph/src/Reroute' +import { CustomEventTarget } from '@/lib/litegraph/src/infrastructure/CustomEventTarget' +import type { SubgraphInputEventMap } from '@/lib/litegraph/src/infrastructure/SubgraphInputEventMap' +import type { + INodeInputSlot, + INodeOutputSlot, + Point, + ReadOnlyRect +} from '@/lib/litegraph/src/interfaces' +import { LiteGraph } from '@/lib/litegraph/src/litegraph' +import { NodeSlotType } from '@/lib/litegraph/src/types/globalEnums' +import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets' + +import type { SubgraphInputNode } from './SubgraphInputNode' +import type { SubgraphOutput } from './SubgraphOutput' +import { SubgraphSlot } from './SubgraphSlotBase' +import { isNodeSlot, isSubgraphOutput } from './subgraphUtils' + +/** + * An input "slot" from a parent graph into a subgraph. + * + * IMPORTANT: A subgraph "input" is both an input AND an output. It creates an extra link connection point between + * a parent graph and a subgraph, so is conceptually similar to a reroute. + * + * This can be a little confusing, but is easier to visualise when imagining editing a subgraph. + * You have "Subgraph Inputs", because they are coming into the subgraph, which then connect to "node inputs". + * + * Functionally, however, when editing a subgraph, that "subgraph input" is the "origin" or "output side" of a link. + */ +export class SubgraphInput extends SubgraphSlot { + declare parent: SubgraphInputNode + + events = new CustomEventTarget() + + /** The linked widget that this slot is connected to. */ + private _widgetRef?: WeakRef + + get _widget() { + return this._widgetRef?.deref() + } + + set _widget(widget) { + this._widgetRef = widget ? new WeakRef(widget) : undefined + } + + override connect( + slot: INodeInputSlot, + node: LGraphNode, + afterRerouteId?: RerouteId + ): LLink | undefined { + const { subgraph } = this.parent + + // Allow nodes to block connection + const inputIndex = node.inputs.indexOf(slot) + if ( + node.onConnectInput?.(inputIndex, this.type, this, this.parent, -1) === + false + ) + return + + // if (slot instanceof SubgraphOutput) { + // // Subgraph IO nodes have no special handling at present. + // return new LLink( + // ++subgraph.state.lastLinkId, + // this.type, + // this.parent.id, + // this.parent.slots.indexOf(this), + // node.id, + // inputIndex, + // afterRerouteId, + // ) + // } + + // Disconnect target input, if it is already connected. + if (slot.link != null) { + subgraph.beforeChange() + const link = subgraph.getLink(slot.link) + this.parent._disconnectNodeInput(node, slot, link) + } + + const inputWidget = node.getWidgetFromSlot(slot) + if (inputWidget) { + if (!this.matchesWidget(inputWidget)) { + console.warn('Target input has invalid widget.', slot, node) + return + } + + // Keep the widget reference in sync with the active upstream widget. + // Stale references can appear across nested promotion rebinds. + this._widget = inputWidget + this.events.dispatch('input-connected', { + input: slot, + widget: inputWidget, + node + }) + } else { + this.events.dispatch('input-connected', { input: slot }) + } + + const linkId = toLinkId(Number(subgraph.state.lastLinkId) + 1) + subgraph.state.lastLinkId = linkId + + const link = new LLink( + linkId, + slot.type, + this.parent.id, + this.parent.slots.indexOf(this), + node.id, + inputIndex, + afterRerouteId + ) + + // Add to graph links list + subgraph._links.set(link.id, link) + + // Set link ID in each slot + this.linkIds.push(link.id) + slot.link = link.id + + // Reroutes + const reroutes = LLink.getReroutes(subgraph, link) + for (const reroute of reroutes) { + reroute.linkIds.add(link.id) + if (reroute.floating) delete reroute.floating + reroute._dragging = undefined + } + + // If this is the terminus of a floating link, remove it + const lastReroute = reroutes.at(-1) + if (lastReroute) { + for (const linkId of lastReroute.floatingLinkIds) { + const link = subgraph.floatingLinks.get(linkId) + if (link?.parentId === lastReroute.id) { + subgraph.removeFloatingLink(link) + } + } + } + subgraph.incrementVersion() + + subgraph.trigger('node:slot-links:changed', { + nodeId: node.id, + slotType: NodeSlotType.INPUT, + slotIndex: inputIndex, + connected: true, + linkId: link.id + }) + node.onConnectionsChange?.(NodeSlotType.INPUT, inputIndex, true, link, slot) + + subgraph.afterChange() + + return link + } + + get labelPos(): Point { + const [x, y, , height] = this.boundingRect + return [x, y + height * 0.5] + } + + getConnectedWidgets(): IBaseWidget[] { + const { subgraph } = this.parent + const widgets: IBaseWidget[] = [] + + for (const linkId of this.linkIds) { + const link = subgraph.getLink(linkId) + if (!link) { + console.error('Link not found', linkId) + continue + } + + const resolved = link.resolve(subgraph) + if (resolved.input && resolved.inputNode?.widgets) { + // Has no widget + const widgetNamePojo = resolved.input.widget + if (!widgetNamePojo) continue + + // Invalid widget name + if (!widgetNamePojo.name) { + console.warn('Invalid widget name', widgetNamePojo) + continue + } + + const widget = resolved.inputNode.widgets.find( + (w) => w.name === widgetNamePojo.name + ) + if (!widget) { + console.warn('Widget not found', widgetNamePojo) + continue + } + + widgets.push(widget) + } + } + return widgets + } + + /** + * Validates that the connection between the new slot and the existing widget is valid. + * Used to prevent connections between widgets that are not of the same type. + * @param otherWidget The widget to compare to. + * @returns `true` if the connection is valid, otherwise `false`. + */ + matchesWidget(otherWidget: IBaseWidget): boolean { + const widget = this._widgetRef?.deref() + if (!widget) return true + + if ( + otherWidget.type !== widget.type || + otherWidget.options.min !== widget.options.min || + otherWidget.options.max !== widget.options.max || + otherWidget.options.step !== widget.options.step || + otherWidget.options.step2 !== widget.options.step2 || + otherWidget.options.precision !== widget.options.precision + ) { + return false + } + + return true + } + + override disconnect(): void { + super.disconnect() + + this._widget = undefined + + this.events.dispatch('input-disconnected', { input: this }) + } + + /** For inputs, x is the right edge of the input node. */ + override arrange(rect: ReadOnlyRect): void { + const [right, top, width, height] = rect + const { boundingRect: b, pos } = this + + b[0] = right - width + b[1] = top + b[2] = width + b[3] = height + + pos[0] = right - height * 0.5 + pos[1] = top + height * 0.5 + } + + /** + * Checks if this slot is a valid target for a connection from the given slot. + * For SubgraphInput (which acts as an output inside the subgraph), + * the fromSlot should be an input slot. + */ + override isValidTarget( + fromSlot: INodeInputSlot | INodeOutputSlot | SubgraphInput | SubgraphOutput + ): boolean { + if (isNodeSlot(fromSlot) && 'link' in fromSlot) { + return LiteGraph.isValidConnection(this.type, fromSlot.type) + } + + if (isSubgraphOutput(fromSlot)) { + return LiteGraph.isValidConnection(this.type, fromSlot.type) + } + + return false + } +} diff --git a/docs/hel-892/promoted-reference/1.48.7__src__renderer__extensions__vueNodes__widgets__composables__useBooleanWidget.ts b/docs/hel-892/promoted-reference/1.48.7__src__renderer__extensions__vueNodes__widgets__composables__useBooleanWidget.ts new file mode 100644 index 00000000..242afe54 --- /dev/null +++ b/docs/hel-892/promoted-reference/1.48.7__src__renderer__extensions__vueNodes__widgets__composables__useBooleanWidget.ts @@ -0,0 +1,31 @@ +import type { LGraphNode } from '@/lib/litegraph/src/litegraph' +import { isBooleanInputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2' +import type { InputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2' +import type { ComfyWidgetConstructorV2 } from '@/scripts/widgets' + +export const useBooleanWidget = () => { + const widgetConstructor: ComfyWidgetConstructorV2 = ( + node: LGraphNode, + inputSpec: InputSpec + ) => { + if (!isBooleanInputSpec(inputSpec)) { + throw new Error(`Invalid input data: ${inputSpec}`) + } + + const defaultVal = inputSpec.default ?? false + const options = { + on: inputSpec.label_on, + off: inputSpec.label_off + } + + return node.addWidget( + 'toggle', + inputSpec.name, + defaultVal, + () => {}, + options + ) + } + + return widgetConstructor +} diff --git a/docs/hel-892/promoted-reference/1.48.7__src__renderer__extensions__vueNodes__widgets__composables__useComboWidget.ts b/docs/hel-892/promoted-reference/1.48.7__src__renderer__extensions__vueNodes__widgets__composables__useComboWidget.ts new file mode 100644 index 00000000..59417932 --- /dev/null +++ b/docs/hel-892/promoted-reference/1.48.7__src__renderer__extensions__vueNodes__widgets__composables__useComboWidget.ts @@ -0,0 +1,326 @@ +import { ref } from 'vue' + +import MultiSelectWidget from '@/components/graph/widgets/MultiSelectWidget.vue' +import { t } from '@/i18n' +import type { LGraphNode } from '@/lib/litegraph/src/litegraph' +import { isComboWidget } from '@/lib/litegraph/src/litegraph' +import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets' +import { assetService } from '@/platform/assets/services/assetService' +import type { AssetItem } from '@/platform/assets/schemas/assetSchema' +import { getAssetFilename } from '@/platform/assets/utils/assetMetadataUtils' +import { createAssetWidget } from '@/platform/assets/utils/createAssetWidget' +import { isCloud } from '@/platform/distribution/types' +import type { + ComboInputSpec, + InputSpec +} from '@/schemas/nodeDef/nodeDefSchemaV2' +import { isComboInputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2' +import { transformInputSpecV2ToV1 } from '@/schemas/nodeDef/migration' +import { ComponentWidgetImpl, addWidget } from '@/scripts/domWidget' +import type { BaseDOMWidget } from '@/scripts/domWidget' +import type { ComfyWidgetConstructorV2 } from '@/scripts/widgets' +import { addValueControlWidgets } from '@/scripts/widgets' +import { useAssetsStore } from '@/stores/assetsStore' +import { getMediaTypeFromFilename } from '@/utils/formatUtil' + +import { useRemoteWidget } from './useRemoteWidget' + +const getDefaultValue = (inputSpec: ComboInputSpec) => { + if (inputSpec.default) return inputSpec.default + if (inputSpec.options?.length) return inputSpec.options[0] + if (inputSpec.remote) return 'Loading...' + return undefined +} + +// Map node types to expected media types +const NODE_MEDIA_TYPE_MAP: Record = { + LoadImage: 'image', + LoadVideo: 'video', + LoadAudio: 'audio' +} + +// Map node types to placeholder i18n keys +const NODE_PLACEHOLDER_MAP: Record = { + LoadImage: 'widgets.uploadSelect.placeholderImage', + LoadVideo: 'widgets.uploadSelect.placeholderVideo', + LoadAudio: 'widgets.uploadSelect.placeholderAudio' +} + +const bindDynamicValuesOption = ( + widget: IBaseWidget, + getValues: () => unknown +) => { + const options = widget.options + let fallbackValues = Array.isArray(options.values) + ? options.values + : ([] as unknown[]) + + Object.defineProperty(options, 'values', { + configurable: true, + enumerable: true, + get: () => { + const values = getValues() + if (values === undefined || values === null) return fallbackValues + return values + }, + set: (values: unknown[]) => { + fallbackValues = Array.isArray(values) ? values : fallbackValues + } + }) +} + +const addMultiSelectWidget = ( + node: LGraphNode, + inputSpec: ComboInputSpec +): IBaseWidget => { + const widgetValue = ref([]) + const widget = new ComponentWidgetImpl({ + node, + name: inputSpec.name, + component: MultiSelectWidget, + inputSpec, + options: { + getValue: () => widgetValue.value, + setValue: (value: string[]) => { + widgetValue.value = value + } + } + }) + addWidget(node, widget as BaseDOMWidget) + // TODO: Add remote support to multi-select widget + // https://github.com/Comfy-Org/ComfyUI_frontend/issues/3003 + if (inputSpec.control_after_generate) { + const defaultType = + typeof inputSpec.control_after_generate === 'string' + ? inputSpec.control_after_generate + : 'fixed' + widget.linkedWidgets = addValueControlWidgets( + node, + widget, + defaultType, + undefined, + transformInputSpecV2ToV1(inputSpec) + ) + } + + return widget +} + +/** + * Resolve the default value for a cloud asset widget. + * Priority: inputSpec.default (if present in cloud assets) → first cloud + * asset → undefined (shows placeholder). + */ +function resolveCloudDefault( + nodeType: string, + specDefault: string | undefined +): string | undefined { + const assets = useAssetsStore().getAssets(nodeType) + if (specDefault != null) { + const inAssets = assets.some((a) => getAssetFilename(a) === specDefault) + if (inAssets) return specDefault + } + // empty filename → undefined (shows placeholder) + const filename = assets.length ? getAssetFilename(assets[0]) : undefined + return filename || undefined +} + +function getCloudInputAssets(nodeType: string | undefined): AssetItem[] { + const mediaType = NODE_MEDIA_TYPE_MAP[nodeType ?? ''] + if (!mediaType) return [] + + return useAssetsStore().inputAssets.filter( + (asset) => + getCloudInputAssetValue(asset) && + getMediaTypeFromFilename(asset.name) === mediaType + ) +} + +function getCloudInputAssetValue(asset: AssetItem): string | undefined { + return asset.hash ?? undefined +} + +function getCloudInputAssetValues(nodeType: string | undefined): string[] { + return getCloudInputAssets(nodeType) + .map(getCloudInputAssetValue) + .filter((value): value is string => !!value) +} + +function resolveCloudInputDefault( + nodeType: string | undefined, + specDefault: string | undefined +): string | undefined { + const assets = getCloudInputAssets(nodeType) + if (specDefault != null) { + const matchingAsset = + assets.find((asset) => getCloudInputAssetValue(asset) === specDefault) ?? + assets.find((asset) => asset.name === specDefault) + if (matchingAsset) return getCloudInputAssetValue(matchingAsset) + } + + return assets[0] ? getCloudInputAssetValue(assets[0]) : undefined +} + +function createAssetBrowserWidget( + node: LGraphNode, + inputSpec: ComboInputSpec, + defaultValue: string | undefined +): IBaseWidget { + return createAssetWidget({ + node, + widgetName: inputSpec.name, + nodeTypeForBrowser: node.comfyClass ?? '', + inputNameForBrowser: inputSpec.name, + defaultValue + }) +} + +const createInputMappingWidget = ( + node: LGraphNode, + inputSpec: ComboInputSpec, + defaultValue: string | undefined +): IBaseWidget => { + const assetsStore = useAssetsStore() + + const widget = node.addWidget( + 'combo', + inputSpec.name, + defaultValue ?? '', + () => {}, + { + values: [], + getOptionLabel: (value?: string | null) => { + if (!value) { + const placeholderKey = + NODE_PLACEHOLDER_MAP[node.comfyClass ?? ''] ?? + 'widgets.uploadSelect.placeholder' + return t(placeholderKey) + } + return assetsStore.getInputName(value) + } + } + ) + + if (assetsStore.inputAssets.length === 0 && !assetsStore.inputLoading) { + void assetsStore.updateInputs().then(() => { + // edge for users using nodes with 0 prior inputs + // force canvas refresh the first time they add an asset + // so they see filenames instead of hashes. + node.setDirtyCanvas(true, false) + }) + } + + bindDynamicValuesOption(widget, () => + getCloudInputAssetValues(node.comfyClass) + ) + + if (inputSpec.control_after_generate) { + if (!isComboWidget(widget)) { + throw new Error(`Expected combo widget but received ${widget.type}`) + } + const defaultType = + typeof inputSpec.control_after_generate === 'string' + ? inputSpec.control_after_generate + : 'randomize' + widget.linkedWidgets = addValueControlWidgets( + node, + widget, + defaultType, + undefined, + transformInputSpecV2ToV1(inputSpec) + ) + } + + return widget +} + +const addComboWidget = ( + node: LGraphNode, + inputSpec: ComboInputSpec +): IBaseWidget => { + const defaultValue = getDefaultValue(inputSpec) + + if (isCloud) { + if (assetService.shouldUseAssetBrowser(node.comfyClass, inputSpec.name)) { + // Default from cloud assets, not from server combo options. + // Server options list local files that may not exist in the user's + // cloud asset library, leading to missing-model errors on undo/reload. + const cloudDefault = resolveCloudDefault( + node.comfyClass ?? '', + inputSpec.default + ) + return createAssetBrowserWidget(node, inputSpec, cloudDefault) + } + + if (NODE_MEDIA_TYPE_MAP[node.comfyClass ?? '']) { + return createInputMappingWidget( + node, + inputSpec, + resolveCloudInputDefault(node.comfyClass, inputSpec.default) + ) + } + } + + // Standard combo widget + const widget = node.addWidget( + 'combo', + inputSpec.name, + defaultValue, + () => {}, + { + values: inputSpec.options ?? [] + } + ) + + if (inputSpec.remote) { + if (!isComboWidget(widget)) { + throw new Error(`Expected combo widget but received ${widget.type}`) + } + + const remoteWidget = useRemoteWidget({ + remoteConfig: inputSpec.remote, + defaultValue, + node, + widget + }) + if (inputSpec.remote.refresh_button) remoteWidget.addRefreshButton() + + bindDynamicValuesOption(widget, () => remoteWidget.getValue()) + } + + if (inputSpec.control_after_generate) { + if (!isComboWidget(widget)) { + throw new Error(`Expected combo widget but received ${widget.type}`) + } + + const defaultType = + typeof inputSpec.control_after_generate === 'string' + ? inputSpec.control_after_generate + : 'randomize' + widget.linkedWidgets = addValueControlWidgets( + node, + widget, + defaultType, + undefined, + transformInputSpecV2ToV1(inputSpec) + ) + } + + return widget +} + +export const useComboWidget = () => { + const widgetConstructor: ComfyWidgetConstructorV2 = ( + node: LGraphNode, + inputSpec: InputSpec + ) => { + if (!isComboInputSpec(inputSpec)) { + throw new Error(`Invalid input data: ${inputSpec}`) + } + return inputSpec.multi_select + ? addMultiSelectWidget(node, inputSpec) + : addComboWidget(node, inputSpec) + } + + return widgetConstructor +} diff --git a/docs/hel-892/promoted-reference/1.48.7__src__renderer__extensions__vueNodes__widgets__composables__useFloatWidget.ts b/docs/hel-892/promoted-reference/1.48.7__src__renderer__extensions__vueNodes__widgets__composables__useFloatWidget.ts new file mode 100644 index 00000000..0d5ee3a9 --- /dev/null +++ b/docs/hel-892/promoted-reference/1.48.7__src__renderer__extensions__vueNodes__widgets__composables__useFloatWidget.ts @@ -0,0 +1,100 @@ +import { clamp } from 'es-toolkit/compat' + +import type { LGraphNode } from '@/lib/litegraph/src/litegraph' +import type { INumericWidget } from '@/lib/litegraph/src/types/widgets' +import { useSettingStore } from '@/platform/settings/settingStore' +import { isFloatInputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2' +import type { InputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2' +import type { ComfyWidgetConstructorV2 } from '@/scripts/widgets' +import { addValueControlWidget } from '@/scripts/widgets' +import { transformInputSpecV2ToV1 } from '@/schemas/nodeDef/migration' + +function onFloatValueChange(this: INumericWidget, v: number) { + const round = this.options.round + if (round) { + const precision = + this.options.precision ?? Math.max(0, -Math.floor(Math.log10(round))) + const rounded = Math.round(v / round) * round + this.value = clamp( + Number(rounded.toFixed(precision)), + this.options.min ?? -Infinity, + this.options.max ?? Infinity + ) + } else { + this.value = v + } +} + +export const _for_testing = { + onFloatValueChange +} + +export const useFloatWidget = () => { + const widgetConstructor: ComfyWidgetConstructorV2 = ( + node: LGraphNode, + inputSpec: InputSpec + ) => { + if (!isFloatInputSpec(inputSpec)) { + throw new Error(`Invalid input data: ${inputSpec}`) + } + + const settingStore = useSettingStore() + const sliderEnabled = !settingStore.get('Comfy.DisableSliders') + + const display_type = inputSpec.display + const widgetType = + display_type == 'gradientslider' + ? 'gradientslider' + : sliderEnabled && display_type == 'slider' + ? 'slider' + : display_type == 'knob' + ? 'knob' + : 'number' + + const step = inputSpec.step ?? 0.5 + const precision = + settingStore.get('Comfy.FloatRoundingPrecision') || + Math.max(0, -Math.floor(Math.log10(step))) + const enableRounding = !settingStore.get('Comfy.DisableFloatRounding') + + /** Assertion {@link inputSpec.default} */ + const defaultValue = (inputSpec.default as number | undefined) ?? 0 + const widget = node.addWidget( + widgetType, + inputSpec.name, + defaultValue, + onFloatValueChange, + { + min: inputSpec.min ?? 0, + max: inputSpec.max ?? 2048, + round: + enableRounding && precision && !inputSpec.round + ? Math.pow(10, -precision) + : (inputSpec.round as number), + /** @deprecated Use step2 instead. The 10x value is a legacy implementation. */ + step: step * 10.0, + step2: step, + precision, + ...(inputSpec.gradient_stops + ? { gradient_stops: inputSpec.gradient_stops } + : {}) + } + ) + + if (inputSpec.control_after_generate) { + const controlWidget = addValueControlWidget( + node, + widget, + 'fixed', + undefined, + undefined, + transformInputSpecV2ToV1(inputSpec) + ) + widget.linkedWidgets = [controlWidget] + } + + return widget + } + + return widgetConstructor +} diff --git a/docs/hel-892/promoted-reference/1.48.7__src__renderer__extensions__vueNodes__widgets__composables__useIntWidget.ts b/docs/hel-892/promoted-reference/1.48.7__src__renderer__extensions__vueNodes__widgets__composables__useIntWidget.ts new file mode 100644 index 00000000..f307aa0e --- /dev/null +++ b/docs/hel-892/promoted-reference/1.48.7__src__renderer__extensions__vueNodes__widgets__composables__useIntWidget.ts @@ -0,0 +1,93 @@ +import type { LGraphNode } from '@/lib/litegraph/src/litegraph' +import type { INumericWidget } from '@/lib/litegraph/src/types/widgets' +import { useSettingStore } from '@/platform/settings/settingStore' +import type { InputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2' +import { isIntInputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2' +import type { ComfyWidgetConstructorV2 } from '@/scripts/widgets' +import { addValueControlWidget } from '@/scripts/widgets' +import { transformInputSpecV2ToV1 } from '@/schemas/nodeDef/migration' + +function onValueChange(this: INumericWidget, v: number) { + // For integers, always round to the nearest step + // step === 0 is invalid, assign 1 if options.step is 0 + const step = this.options.step2 || 1 + + if (step === 1) { + // Simple case: round to nearest integer + this.value = Math.round(v) + } else { + // Round to nearest multiple of step + // First, determine if min value creates an offset + const min = this.options.min ?? 0 + const offset = min % step + + // Round to nearest step, accounting for offset + this.value = Math.round((v - offset) / step) * step + offset + } +} + +export const _for_testing = { + onValueChange +} + +export const useIntWidget = () => { + const widgetConstructor: ComfyWidgetConstructorV2 = ( + node: LGraphNode, + inputSpec: InputSpec + ) => { + if (!isIntInputSpec(inputSpec)) { + throw new Error(`Invalid input data: ${inputSpec}`) + } + + const settingStore = useSettingStore() + const sliderEnabled = !settingStore.get('Comfy.DisableSliders') + const display_type = inputSpec.display + const widgetType = + sliderEnabled && display_type == 'slider' + ? 'slider' + : display_type == 'knob' + ? 'knob' + : 'number' + + const step = inputSpec.step ?? 1 + /** Assertion {@link inputSpec.default} */ + const defaultValue = (inputSpec.default as number | undefined) ?? 0 + const widget = node.addWidget( + widgetType, + inputSpec.name, + defaultValue, + onValueChange, + { + min: inputSpec.min ?? 0, + max: inputSpec.max ?? 2048, + /** @deprecated Use step2 instead. The 10x value is a legacy implementation. */ + step: step * 10, + step2: step, + precision: 0 + } + ) + + const controlAfterGenerate = + inputSpec.control_after_generate ?? + ['seed', 'noise_seed'].includes(inputSpec.name) + + if (controlAfterGenerate) { + const defaultType = + typeof inputSpec.control_after_generate === 'string' + ? inputSpec.control_after_generate + : 'randomize' + const controlWidget = addValueControlWidget( + node, + widget, + defaultType, + undefined, + undefined, + transformInputSpecV2ToV1(inputSpec) + ) + widget.linkedWidgets = [controlWidget] + } + + return widget + } + return widgetConstructor +} diff --git a/docs/hel-892/promoted-reference/1.48.7__src__renderer__extensions__vueNodes__widgets__composables__useStringWidget.ts b/docs/hel-892/promoted-reference/1.48.7__src__renderer__extensions__vueNodes__widgets__composables__useStringWidget.ts new file mode 100644 index 00000000..b939e93e --- /dev/null +++ b/docs/hel-892/promoted-reference/1.48.7__src__renderer__extensions__vueNodes__widgets__composables__useStringWidget.ts @@ -0,0 +1,95 @@ +import type { LGraphNode } from '@/lib/litegraph/src/litegraph' +import { resolveNodeRootGraphId } from '@/lib/litegraph/src/litegraph' +import { defineDeprecatedProperty } from '@/lib/litegraph/src/utils/feedback' +import { + bindMultilineTextareaWidget, + createMultilineInputElement +} from '@/renderer/extensions/vueNodes/widgets/utils/multilineTextarea' +import { isStringInputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2' +import type { InputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2' +import { app } from '@/scripts/app' +import type { ComfyWidgetConstructorV2 } from '@/scripts/widgets' +import { useWidgetValueStore } from '@/stores/widgetValueStore' +import { widgetId } from '@/types/widgetId' + +function addMultilineWidget( + node: LGraphNode, + name: string, + opts: { defaultVal: string; placeholder?: string } +) { + const widgetStore = useWidgetValueStore() + const inputEl = createMultilineInputElement( + opts.defaultVal, + opts.placeholder || name + ) + + const widget = node.addDOMWidget(name, 'customtext', inputEl, { + getValue(): string { + const graphId = resolveNodeRootGraphId(node, app.rootGraph.id) + const widgetState = widgetStore.getWidget( + widgetId(graphId, node.id, name) + ) + + return (widgetState?.value as string) ?? inputEl.value + }, + setValue(v: string) { + inputEl.value = v + const graphId = resolveNodeRootGraphId(node, app.rootGraph.id) + const id = widgetId(graphId, node.id, name) + const widgetState = widgetStore.getWidget(id) + if (widgetState) { + widgetState.value = v + return + } + widgetStore.registerWidget(id, { + type: 'customtext', + value: v, + options: widget.options ?? {} + }) + } + }) + + widget.element = inputEl + + /** @deprecated Use {@link widget.element} instead (renamed in PR #8594). */ + defineDeprecatedProperty( + widget, + 'inputEl', + 'element', + 'widget.inputEl is deprecated. Use widget.element instead.' + ) + widget.options.minNodeSize = [400, 200] + + bindMultilineTextareaWidget(widget, inputEl) + + return widget +} + +export const useStringWidget = () => { + const widgetConstructor: ComfyWidgetConstructorV2 = ( + node: LGraphNode, + inputSpec: InputSpec + ) => { + if (!isStringInputSpec(inputSpec)) { + throw new Error(`Invalid input data: ${inputSpec}`) + } + + const defaultVal = inputSpec.default ?? '' + const multiline = inputSpec.multiline + + const widget = multiline + ? addMultilineWidget(node, inputSpec.name, { + defaultVal, + placeholder: inputSpec.placeholder + }) + : node.addWidget('text', inputSpec.name, defaultVal, () => {}, {}) + + if (typeof inputSpec.dynamicPrompts === 'boolean') { + widget.dynamicPrompts = inputSpec.dynamicPrompts + } + + return widget + } + + return widgetConstructor +} diff --git a/docs/hel-892/promoted-reference/1.48.7__src__scripts__widgets.ts b/docs/hel-892/promoted-reference/1.48.7__src__scripts__widgets.ts new file mode 100644 index 00000000..6b8a7df3 --- /dev/null +++ b/docs/hel-892/promoted-reference/1.48.7__src__scripts__widgets.ts @@ -0,0 +1,250 @@ +import { t } from '@/i18n' +import { type LGraphNode, isComboWidget } from '@/lib/litegraph/src/litegraph' +import type { + IBaseWidget, + IComboWidget, + IStringWidget +} from '@/lib/litegraph/src/types/widgets' +import { nextValueForLinkedTarget } from './valueControl' +import { useSettingStore } from '@/platform/settings/settingStore' +import { dynamicWidgets } from '@/core/graph/widgets/dynamicWidgets' +import { useBooleanWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useBooleanWidget' +import { useBoundingBoxWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useBoundingBoxWidget' +import { useCurveWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useCurveWidget' +import { useChartWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useChartWidget' +import { useColorWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useColorWidget' +import { useComboWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useComboWidget' +import { useCompositorWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useCompositorWidget' +import { useFloatWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useFloatWidget' +import { useGalleriaWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useGalleriaWidget' +import { useBoundingBoxesWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useBoundingBoxesWidget' +import { useColorsWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useColorsWidget' +import { useImageCompareWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useImageCompareWidget' +import { useImageUploadWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useImageUploadWidget' +import { useIntWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useIntWidget' +import { useMarkdownWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget' +import { usePainterWidget } from '@/renderer/extensions/vueNodes/widgets/composables/usePainterWidget' +import { useRangeWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useRangeWidget' +import { useStringWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useStringWidget' +import { useTextareaWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useTextareaWidget' +import { transformInputSpecV1ToV2 } from '@/schemas/nodeDef/migration' +import type { InputSpec as InputSpecV2 } from '@/schemas/nodeDef/nodeDefSchemaV2' +import type { InputSpec } from '@/schemas/nodeDefSchema' + +import type { ComfyApp } from './app' +import { IS_CONTROL_WIDGET } from './controlWidgetMarker' +import './domWidget' +import './errorNodeWidgets' + +export { IS_CONTROL_WIDGET } + +export type ComfyWidgetConstructorV2 = ( + node: LGraphNode, + inputSpec: InputSpecV2 +) => IBaseWidget + +export type ComfyWidgetConstructor = ( + node: LGraphNode, + inputName: string, + inputData: InputSpec, + app: ComfyApp, + widgetName?: string +) => { widget: IBaseWidget; minWidth?: number; minHeight?: number } + +/** + * Transforms a V2 widget constructor to a V1 widget constructor. + * @param widgetConstructorV2 The V2 widget constructor to transform. + * @returns The transformed V1 widget constructor. + */ +const transformWidgetConstructorV2ToV1 = ( + widgetConstructorV2: ComfyWidgetConstructorV2 +): ComfyWidgetConstructor => { + return (node, inputName, inputData) => { + const inputSpec = transformInputSpecV1ToV2(inputData, { + name: inputName + }) + const widget = widgetConstructorV2(node, inputSpec) + return { + widget, + minWidth: widget.options.minNodeSize?.[0], + minHeight: widget.options.minNodeSize?.[1] + } + } +} + +function controlValueRunBefore() { + return useSettingStore().get('Comfy.WidgetControlMode') === 'before' +} + +export function updateControlWidgetLabel(widget: IBaseWidget) { + if (controlValueRunBefore()) { + widget.label = t('g.control_before_generate') + } else { + widget.label = t('g.control_after_generate') + } +} + +const HAS_EXECUTED = Symbol() + +export function addValueControlWidget( + node: LGraphNode, + targetWidget: IBaseWidget, + defaultValue?: string, + _values?: unknown, + widgetName?: string, + inputData?: InputSpec +): IComboWidget { + let name = inputData?.[1]?.control_after_generate + if (typeof name !== 'string') { + name = widgetName + } + const widgets = addValueControlWidgets( + node, + targetWidget, + defaultValue ?? 'randomize', + { + addFilterList: false, + controlAfterGenerateName: name + }, + inputData + ) + return widgets[0] +} + +export function addValueControlWidgets( + node: LGraphNode, + targetWidget: IBaseWidget, + defaultValue?: string, + options?: Record, + inputData?: InputSpec +): [IComboWidget, ...IStringWidget[]] { + if (!defaultValue) defaultValue = 'randomize' + if (!options) options = {} + + const getName = (defaultName: string, optionName: string) => { + let name = defaultName + if (options[optionName]) { + name = options[optionName] + } else if (typeof inputData?.[1]?.[defaultName] === 'string') { + name = inputData?.[1]?.[defaultName] + } else if (inputData?.[1]?.control_prefix) { + name = inputData?.[1]?.control_prefix + ' ' + name + } + return name + } + + const valueControl = node.addWidget( + 'combo', + getName('control_after_generate', 'controlAfterGenerateName'), + defaultValue, + function () {}, + { + values: ['fixed', 'increment', 'decrement', 'randomize'], + serialize: false, // Don't include this in prompt. + canvasOnly: true + } + ) as IComboWidget + + valueControl.tooltip = + 'Allows the linked widget to be changed automatically, for example randomizing the noise seed.' + valueControl[IS_CONTROL_WIDGET] = true + updateControlWidgetLabel(valueControl) + Object.defineProperty(valueControl, 'disabled', { + get: () => targetWidget.computedDisabled + }) + const widgets: [IComboWidget, ...IStringWidget[]] = [valueControl] + + const isCombo = isComboWidget(targetWidget) + let comboFilter: IStringWidget + if (isCombo && valueControl.options.values) { + // @ts-expect-error Combo widget values may be a dictionary or legacy function type + valueControl.options.values.push('increment-wrap') + } + if (isCombo && options.addFilterList !== false) { + comboFilter = node.addWidget( + 'string', + getName('control_filter_list', 'controlFilterListName'), + '', + function () {}, + { + serialize: false // Don't include this in prompt. + } + ) as IStringWidget + updateControlWidgetLabel(comboFilter) + comboFilter.tooltip = + "Allows for filtering the list of values when changing the value via the control generate mode. Allows for RegEx matches in the format /abc/ to only filter to values containing 'abc'." + Object.defineProperty(comboFilter, 'disabled', { + get: () => targetWidget.computedDisabled + }) + + widgets.push(comboFilter) + } + + function applyWidgetControl(isPartialExecution: boolean | undefined) { + if ( + node.inputs?.some( + (input) => + input.widget?.name === targetWidget.name && input.link != null + ) + ) + return + + const next = nextValueForLinkedTarget({ + target: targetWidget, + linkedWidgets: targetWidget.linkedWidgets, + nodeId: node.id, + isPartialExecution + }) + if (next === undefined) return + + targetWidget.value = next + targetWidget.callback?.(next) + } + + valueControl.beforeQueued = ({ isPartialExecution } = {}) => { + if (controlValueRunBefore()) { + // Don't run on first execution + if (valueControl[HAS_EXECUTED]) { + applyWidgetControl(isPartialExecution) + } + } + valueControl[HAS_EXECUTED] = true + } + + valueControl.afterQueued = ({ isPartialExecution } = {}) => { + if (!controlValueRunBefore()) { + applyWidgetControl(isPartialExecution) + } + } + + return widgets +} + +export const ComfyWidgets = { + INT: transformWidgetConstructorV2ToV1(useIntWidget()), + FLOAT: transformWidgetConstructorV2ToV1(useFloatWidget()), + BOOLEAN: transformWidgetConstructorV2ToV1(useBooleanWidget()), + STRING: transformWidgetConstructorV2ToV1(useStringWidget()), + MARKDOWN: transformWidgetConstructorV2ToV1(useMarkdownWidget()), + COMBO: transformWidgetConstructorV2ToV1(useComboWidget()), + IMAGEUPLOAD: useImageUploadWidget(), + COLOR: transformWidgetConstructorV2ToV1(useColorWidget()), + IMAGECOMPARE: transformWidgetConstructorV2ToV1(useImageCompareWidget()), + BOUNDING_BOX: transformWidgetConstructorV2ToV1(useBoundingBoxWidget()), + CHART: transformWidgetConstructorV2ToV1(useChartWidget()), + GALLERIA: transformWidgetConstructorV2ToV1(useGalleriaWidget()), + PAINTER: transformWidgetConstructorV2ToV1(usePainterWidget()), + COMPOSITOR: transformWidgetConstructorV2ToV1(useCompositorWidget()), + TEXTAREA: transformWidgetConstructorV2ToV1(useTextareaWidget()), + CURVE: transformWidgetConstructorV2ToV1(useCurveWidget()), + RANGE: transformWidgetConstructorV2ToV1(useRangeWidget()), + BOUNDING_BOXES: transformWidgetConstructorV2ToV1(useBoundingBoxesWidget()), + COLORS: transformWidgetConstructorV2ToV1(useColorsWidget()), + ...dynamicWidgets +} as const + +export function isValidWidgetType( + key: unknown +): key is keyof typeof ComfyWidgets { + return ComfyWidgets[key as keyof typeof ComfyWidgets] !== undefined +} diff --git a/docs/hel-892/promoted-reference/1.48.7__src__stores__widgetValueStore.ts b/docs/hel-892/promoted-reference/1.48.7__src__stores__widgetValueStore.ts new file mode 100644 index 00000000..28caaca2 --- /dev/null +++ b/docs/hel-892/promoted-reference/1.48.7__src__stores__widgetValueStore.ts @@ -0,0 +1,95 @@ +import { defineStore } from 'pinia' +import { reactive, ref } from 'vue' + +import type { UUID } from '@/utils/uuid' +import { parseNodeId } from '@/types/nodeId' +import type { NodeId, SerializedNodeId } from '@/types/nodeId' +import { isWidgetId, parseWidgetId } from '@/types/widgetId' +import type { WidgetId } from '@/types/widgetId' +import type { WidgetState, WidgetStateInit } from '@/types/widgetState' + +export function stripGraphPrefix(scopedId: SerializedNodeId): NodeId | null { + return parseNodeId(String(scopedId).replace(/^(.*:)+/, '')) +} + +export const useWidgetValueStore = defineStore('widgetValue', () => { + const graphWidgetStates = ref(new Map>()) + + function getGraphWidgetStates(graphId: UUID): Map { + const widgetStates = graphWidgetStates.value.get(graphId) + if (widgetStates) return widgetStates + + const nextWidgetStates = reactive(new Map()) + graphWidgetStates.value.set(graphId, nextWidgetStates) + return nextWidgetStates + } + + function registerWidget( + widgetId: WidgetId, + init: WidgetStateInit + ): WidgetState | undefined { + if (!isWidgetId(widgetId)) { + console.warn( + 'widgetValueStore.registerWidget: ignoring un-keyable widget id', + widgetId + ) + return undefined + } + + const existing = getWidget(widgetId) + if (existing && existing.type === init.type) { + return existing as WidgetState + } + + const { graphId, nodeId, name } = parseWidgetId(widgetId) + const state: WidgetState = { + ...init, + nodeId, + name, + y: init.y ?? 0 + } + const widgetStates = getGraphWidgetStates(graphId) + widgetStates.set(widgetId, state) + return widgetStates.get(widgetId) as WidgetState + } + + function getWidget(widgetId: WidgetId): WidgetState | undefined { + if (!isWidgetId(widgetId)) return undefined + + const { graphId } = parseWidgetId(widgetId) + return getGraphWidgetStates(graphId).get(widgetId) + } + + function setValue(widgetId: WidgetId, value: WidgetState['value']): boolean { + const state = getWidget(widgetId) + if (!state) return false + state.value = value + return true + } + + function deleteWidget(widgetId: WidgetId): boolean { + if (!isWidgetId(widgetId)) return false + + const { graphId } = parseWidgetId(widgetId) + return getGraphWidgetStates(graphId).delete(widgetId) + } + + function getNodeWidgets(graphId: UUID, localNodeId: NodeId): WidgetState[] { + return [...getGraphWidgetStates(graphId).values()].filter( + (state) => state.nodeId === localNodeId + ) + } + + function clearGraph(graphId: UUID): void { + graphWidgetStates.value.delete(graphId) + } + + return { + registerWidget, + getWidget, + setValue, + deleteWidget, + getNodeWidgets, + clearGraph + } +}) diff --git a/docs/hel-892/promoted-reference/1.48.7__src__types__widgetId.ts b/docs/hel-892/promoted-reference/1.48.7__src__types__widgetId.ts new file mode 100644 index 00000000..779e4cbb --- /dev/null +++ b/docs/hel-892/promoted-reference/1.48.7__src__types__widgetId.ts @@ -0,0 +1,49 @@ +import { toNodeId } from '@/types/nodeId' +import type { NodeId } from '@/types/nodeId' +type UUID = string + +export type WidgetId = string & { readonly __brand: 'WidgetId' } + +const SEPARATOR = ':' +const WIDGET_ID_PATTERN = /^(?[^:]+):(?[^:]+):(?[^:]+)$/u + +export function widgetId( + graphId: UUID, + localNodeId: NodeId, + name: string +): WidgetId { + return [ + graphId, + encodeURIComponent(String(localNodeId)), + encodeURIComponent(name) + ].join(SEPARATOR) as WidgetId +} + +function decodeWidgetIdSegment(segment: string): string { + try { + return decodeURIComponent(segment) + } catch (error) { + if (error instanceof URIError) return segment + throw error + } +} + +export function parseWidgetId(id: WidgetId): { + graphId: UUID + nodeId: NodeId + name: string +} { + const groups = WIDGET_ID_PATTERN.exec(id)?.groups + if (!groups) throw new Error('Invalid widget id') + + return { + graphId: groups.graphId, + nodeId: toNodeId(decodeWidgetIdSegment(groups.nodeId)), + name: decodeWidgetIdSegment(groups.name) + } +} + +export function isWidgetId(value: unknown): value is WidgetId { + if (typeof value !== 'string') return false + return WIDGET_ID_PATTERN.test(value) +} diff --git a/docs/hel-892/promoted-reference/1.53.6__src__extensions__core__dynamicPrompts.ts b/docs/hel-892/promoted-reference/1.53.6__src__extensions__core__dynamicPrompts.ts new file mode 100644 index 00000000..57ee13dd --- /dev/null +++ b/docs/hel-892/promoted-reference/1.53.6__src__extensions__core__dynamicPrompts.ts @@ -0,0 +1,31 @@ +import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode' +import { useExtensionService } from '@/services/extensionService' +import { processDynamicPrompt } from '@/utils/formatUtil' + +// Allows for simple dynamic prompt replacement +// Inputs in the format {a|b} will have a random value of a or b chosen when the prompt is queued. + +useExtensionService().registerExtension({ + name: 'Comfy.DynamicPrompts', + nodeCreated(node: LGraphNode) { + if (node.widgets) { + // Locate dynamic prompt text widgets + // Include any widgets with dynamicPrompts set to true, and customtext + const widgets = node.widgets.filter((w) => w.dynamicPrompts) + for (const widget of widgets) { + // Override the serialization of the value to resolve dynamic prompts for all widgets supporting it in this node + widget.serializeValue = (workflowNode, widgetIndex) => { + if (typeof widget.value !== 'string') return widget.value + + const prompt = processDynamicPrompt(widget.value) + + // Overwrite the value in the serialized workflow pnginfo + if (workflowNode?.widgets_values) + workflowNode.widgets_values[widgetIndex] = prompt + + return prompt + } + } + } + } +}) diff --git a/docs/hel-892/promoted-reference/1.53.6__src__lib__litegraph__src__LGraphNode.ts b/docs/hel-892/promoted-reference/1.53.6__src__lib__litegraph__src__LGraphNode.ts new file mode 100644 index 00000000..7a9cd728 --- /dev/null +++ b/docs/hel-892/promoted-reference/1.53.6__src__lib__litegraph__src__LGraphNode.ts @@ -0,0 +1,4520 @@ +import { toValue } from 'vue' + +import { + createNodeShellState, + setTrackedNodeState +} from '@/core/graph/nodeShell/nodeShellState' +import { + calculateInputSlotPosFromSlot, + getSlotPosition +} from '@/renderer/core/canvas/litegraph/slotCalculations' +import type { SlotPositionContext } from '@/renderer/core/canvas/litegraph/slotCalculations' +import { + nodeGeometryBuffer, + nodePositionBuffer, + nodePositionView, + nodeSizeBuffer, + nodeSizeView, + refreshNodeGeometry, + setNodePosition, + setNodeSize +} from '@/renderer/core/layout/operations/graphLayoutAttachment' +import { layoutStore } from '@/renderer/core/layout/store/layoutStore' +import { useExecutionOrderStore } from '@/stores/executionOrderStore' +import { useWidgetValueStore } from '@/stores/widgetValueStore' +import { graphScopeOf } from '@/types/graphScopeId' +import { toLinkId } from '@/types/linkId' +import type { GraphScope } from '@/types/graphScopeId' +import { mintLinkId } from './idAllocation' +import { UNASSIGNED_NODE_ID, toNodeId, serializeNodeId } from '@/types/nodeId' +import type { NodeId } from '@/types/nodeId' +import type { NodeProperty, NodeState } from '@/types/nodeState' +import { adjustColor } from '@/utils/colorUtil' +import type { ColorAdjustOptions } from '@/utils/colorUtil' +import { zeroUuid } from '@/utils/uuid' +import { + commonType, + isNodeBindable, + toClass +} from '@/lib/litegraph/src/utils/type' + +import { + SUBGRAPH_INPUT_ID, + SUBGRAPH_OUTPUT_ID +} from '@/lib/litegraph/src/constants' +import { cachedMeasureText } from '@/lib/litegraph/src/utils/textMeasureCache' +import type { DragAndScale } from './DragAndScale' +import type { LGraph } from './LGraph' +import { LGraphBadge } from './LGraphBadge' +import { badgeDrawObjects, badgeRows } from './nodeBadgeDraw' +import { LGraphButton } from './LGraphButton' +import type { LGraphButtonOptions } from './LGraphButton' +import { LGraphCanvas } from './LGraphCanvas' +import { LLink, replaceLinkTopology, slotFloatingLinks } from './LLink' +import { + inputHasLink, + inputLink, + inputLinkId, + captureInputLayout, + finalizeInputLinkRemoval, + replaceNodeInputs, + outputHasLinks, + outputLinks +} from './node/slotLinks' +import { + createInputSlotView, + createOutputSlotView, + resolveInputSlotView +} from './node/slotDescriptorView' +import { initializeWidgetsView } from './node/widgetsView' +import { + extensionConfigureView, + hydrateExtensionPayload, + NODE_CANONICAL_FIELDS, + runExtensionSerializeHook +} from './extensionPersistence' +import { anchorRerouteChain } from './Reroute' +import type { Reroute, RerouteId } from './Reroute' +import { getNodeInputOnPos, getNodeOutputOnPos } from './canvas/measureSlots' +import type { IDrawBoundingOptions } from './draw' +import { NullGraphError } from './infrastructure/NullGraphError' +import type { ReadOnlyRectangle } from './infrastructure/Rectangle' +import { Rectangle } from './infrastructure/Rectangle' +import type { + ColorOption, + CompassCorners, + DefaultConnectionColors, + Dictionary, + IColorable, + IContextMenuValue, + IFoundSlot, + INodeFlags, + INodeInputSlot, + INodeOutputSlot, + INodeSlot, + INodeSlotContextItem, + IPinnable, + ISlotType, + Panel, + Point, + Positionable, + ReadOnlyRect, + Rect, + Size, + SlotIndex +} from './interfaces' +import { LiteGraph, Subgraph } from './litegraph' +import type { LGraphNodeConstructor, SubgraphNode } from './litegraph' +import { + createBounds, + isInRect, + isInRectangle, + isPointInRect, + snapPoint +} from './measure' +import { NodeInputSlot } from './node/NodeInputSlot' +import { NodeOutputSlot } from './node/NodeOutputSlot' +import { + inputAsSerialisable, + isWidgetInputSlot, + outputAsSerialisable +} from './node/slotUtils' +import type { SubgraphInputNode } from './subgraph/SubgraphInputNode' +import type { SubgraphOutputNode } from './subgraph/SubgraphOutputNode' +import type { NodeLike } from './types/NodeLike' +import type { CanvasPointerEvent } from './types/events' +import { + LGraphEventMode, + NodeSlotType, + RenderShape, + TitleMode +} from './types/globalEnums' +import type { ISerialisedNode, SubgraphIO } from './types/serialisation' +import type { + IBaseWidget, + IWidgetOptions, + TWidgetType, + TWidgetValue +} from './types/widgets' +import { findFreeSlotOfType } from './utils/collections' +import { warnDeprecated } from './utils/feedback' +import { + computeLegacyWidgetShadow, + diffNamedValuesShadow +} from './utils/namedValuesShadowDiff' +import { reportNamedValuesShadowDiff } from './utils/namedValuesShadowDiffTelemetry' +import { distributeSpace } from './utils/spaceDistribution' +import { truncateText } from './utils/textUtils' +import { BaseWidget } from './widgets/BaseWidget' +import { toConcreteWidget } from './widgets/widgetMap' +import type { WidgetTypeMap } from './widgets/widgetMap' + +// #region Types + +export type { NodeProperty } from '@/types/nodeState' + +interface INodePropertyInfo { + name?: string + type?: string + default_value?: NodeProperty + widget?: string + label?: string + values?: TWidgetValue[] +} + +interface IMouseOverData { + inputId?: number + outputId?: number + overWidget?: IBaseWidget +} + +function serialiseWidgetValues(widgets: IBaseWidget[]) { + const positional: TWidgetValue[] = [] + const named: Record = {} + for (const widget of widgets) { + if (widget.serialize === false) continue + const value = widget.value + const serialisedValue = + value != null && typeof value === 'object' + ? JSON.parse(JSON.stringify(value)) + : (value ?? null) + positional.push(serialisedValue) + named[widget.name] = serialisedValue + } + return { widgets_values: positional, widgets_values_named: named } +} + +export function createWidgetRestorationState( + info: Pick, + fallbackNames?: readonly string[] +) { + const positional = Array.from(info.widgets_values ?? []) + const named = + info.widgets_values_named ?? + (info.widgets_values && fallbackNames + ? Object.fromEntries( + positional.flatMap((value, index) => + fallbackNames[index] ? [[fallbackNames[index], value]] : [] + ) + ) + : undefined) + + return { + positional, + named: named ? { ...named } : undefined, + restoreNamed: Boolean(named && LiteGraph.namedValuesRestore) + } +} + +interface ConnectByTypeOptions { + /** @deprecated Events */ + createEventInCase?: boolean + /** Allow our wildcard slot to connect to typed slots on remote node. Default: true */ + wildcardToTyped?: boolean + /** Allow our typed slot to connect to wildcard slots on remote node. Default: true */ + typedToWildcard?: boolean + /** The {@link Reroute.id} that the connection is being dragged from. */ + afterRerouteId?: RerouteId +} + +interface FindFreeSlotOptions { + /** Slots matching these types will be ignored. Default: [] */ + typesNotAccepted?: ISlotType[] + /** If true, the slot itself is returned instead of the index. Default: false */ + returnObj?: boolean +} + +interface DrawSlotsOptions { + fromSlot?: INodeInputSlot | INodeOutputSlot + colorContext: DefaultConnectionColors + editorAlpha: number + lowQuality: boolean +} + +interface DrawWidgetsOptions { + lowQuality?: boolean + editorAlpha?: number +} + +interface DrawTitleOptions { + scale: number + title_height?: number + low_quality?: boolean +} + +interface DrawTitleTextOptions extends DrawTitleOptions { + default_title_color: string +} + +export interface DrawTitleBoxOptions extends DrawTitleOptions { + box_size?: number +} + +/* +title: string +pos: [x,y] +size: [x,y] + +input|output: every connection + + { name:string, type:string, pos: [x,y]=Optional, direction: "input"|"output", links: Array }); + +general properties: + + clip_area: if you render outside the node, it will be clipped + + unsafe_execution: not allowed for safe execution + + skip_repeated_outputs: when adding new outputs, it won't show if there is one already connected + + resizable: if set to false it won't be resizable with the mouse + + widgets_start_y: widgets start at y distance from the top of the node + +flags object: + + collapsed: if it is collapsed + +supported callbacks: + + onAdded: when added to graph (warning: this is called BEFORE the node is configured when loading) + + onRemoved: when removed from graph + + onStart: when the graph starts playing + + onStop: when the graph stops playing + + onDrawForeground: render the inside widgets inside the node + + onDrawBackground: render the background area inside the node (only in edit mode) + + onMouseDown + + onMouseMove + + onMouseUp + + onMouseEnter + + onMouseLeave + + onExecute: execute the node + + onPropertyChanged: when a property is changed in the panel (return true to skip default behaviour) + + onGetInputs: returns an array of possible inputs + + onGetOutputs: returns an array of possible outputs + + onBounding: in case this node has a bigger bounding than the node itself (the callback receives the bounding as [x,y,w,h]) + + onDblClick: double clicked in the node + + onNodeTitleDblClick: double clicked in the node title + + onInputDblClick: input slot double clicked (can be used to automatically create a node connected) + + onOutputDblClick: output slot double clicked (can be used to automatically create a node connected) + + onConfigure: called after the node has been configured + + onSerialize: to add extra info when serializing (the callback receives the object that should be filled with the data) + + onSelected + + onDeselected + + onDropItem : DOM item dropped over the node + + onDropFile : file dropped over the node + + onConnectInput : if returns false the incoming connection will be canceled + + onConnectionsChange : a connection changed (new one or removed) (NodeSlotType.INPUT or NodeSlotType.OUTPUT, slot, true if connected, link_info, input_info ) + + onAction: action slot triggered + + getExtraMenuOptions: to add option to context menu +*/ + +export interface LGraphNode { + constructor: LGraphNodeConstructor +} + +// #endregion Types + +/** Shape aliases used by the canvas "Shapes" context menu (`LiteGraph.VALID_SHAPES`). */ +const NAMED_SHAPES = { + default: undefined, + box: RenderShape.BOX, + round: RenderShape.ROUND, + circle: RenderShape.CIRCLE, + card: RenderShape.CARD +} as const + +/** + * Base class for all nodes + * @param title a name for the node + * @param type a type for the node + */ + +const wireExecutionOrders = new WeakMap() + +export class LGraphNode + implements NodeLike, Positionable, IPinnable, IColorable +{ + // Static properties used by dynamic child classes + static title?: string + static MAX_CONSOLE?: number + static type?: string + static category?: string + static description?: string + static filter?: string + static skip_list?: boolean + static nodeData?: { + dev_only?: boolean + deprecated?: boolean + experimental?: boolean + output_node?: boolean + api_node?: boolean + name?: string + } + + static resizeHandleSize = 15 + static resizeEdgeSize = 5 + + /** Default setting for {@link LGraphNode.connectInputToOutput}. @see {@link INodeFlags.keepAllLinksOnBypass} */ + static keepAllLinksOnBypass: boolean = false + + /** The title text of the node. */ + get title(): string { + return this._state.title + } + + set title(value: string) { + setTrackedNodeState(this, 'title', value) + } + /** + * The font style used to render the node's title text. + */ + get titleFontStyle(): string { + return `${LiteGraph.NODE_TEXT_SIZE}px ${LiteGraph.NODE_FONT}` + } + + get innerFontStyle(): string { + return `normal ${LiteGraph.NODE_SUBTEXT_SIZE}px ${LiteGraph.NODE_FONT}` + } + + get displayType(): string { + return this.type + } + + graph: LGraph | Subgraph | null = null + + /** Shell state for the fields the renderer draws; the `nodeDataStore` proxy once registered. */ + _state: NodeState + + /** The graph scope this node is registered with in `nodeDataStore`, if any. */ + _graphScope?: GraphScope + + get id(): NodeId { + return this._state.id + } + + set id(value: NodeId) { + if (this._graphScope) { + if (value !== this._state.id) + console.warn('LiteGraph: refusing to change a registered node id') + return + } + this._state = { ...this._state, id: value } + } + + get type(): string { + return this._state.type + } + + set type(value: string) { + if (value !== this._state.type) + console.warn( + 'LiteGraph: changing a node type after construction is deprecated' + ) + this._state.type = value + } + + /** Assignment splices in place: the `shallowReactive` array identity is what the renderer tracks. */ + get inputs(): INodeInputSlot[] { + return this._inputs + } + + set inputs(value: INodeInputSlot[] | null | undefined) { + this._inputs.splice(0, this._inputs.length, ...(value ?? [])) + } + + /** @see {@link inputs} */ + get outputs(): INodeOutputSlot[] { + return this._outputs + } + + set outputs(value: INodeOutputSlot[] | null | undefined) { + this._outputs.splice(0, this._outputs.length, ...(value ?? [])) + } + + private readonly _inputs: INodeInputSlot[] + private readonly _outputs: INodeOutputSlot[] + + private _concreteInputs: NodeInputSlot[] = [] + private _concreteOutputs: NodeOutputSlot[] = [] + + get properties(): Dictionary { + return this._state.properties + } + + set properties(value: Dictionary) { + if (value === this._state.properties) return + for (const key of Object.keys(this._state.properties)) + delete this._state.properties[key] + Object.assign(this._state.properties, value) + } + + properties_info: INodePropertyInfo[] = [] + + get flags(): INodeFlags { + return this._state.flags + } + + set flags(value: INodeFlags) { + this._state.flags = value + } + + declare widgets?: IBaseWidget[] + + /** + * The amount of space available for widgets to grow into. + * @see {@link layoutWidgets} + */ + freeWidgetSpace?: number + + /** + * Set to true when widget-backed input slot positions need recalculation. + * Cleared after arrange() runs. Avoids per-frame O(N) scans in drawConnections. + */ + _widgetSlotsDirty = false + + locked?: boolean + + /** Execution order, automatically computed during run @see {@link LGraph.computeExecutionOrder} */ + get order(): number { + return this.graph + ? (useExecutionOrderStore().get(graphScopeOf(this.graph), this.id) ?? + wireExecutionOrders.get(this) ?? + 0) + : (wireExecutionOrders.get(this) ?? 0) + } + + set order(value: number) { + if (this.graph) { + useExecutionOrderStore().set(graphScopeOf(this.graph), this.id, value) + } else { + wireExecutionOrders.set(this, value) + } + } + get mode(): LGraphEventMode { + return this._state.mode + } + + set mode(value: LGraphEventMode) { + setTrackedNodeState(this, 'mode', value) + } + get last_serialization(): ISerialisedNode | undefined { + return this._state.lastSerialization + } + + set last_serialization(value: ISerialisedNode | undefined) { + this._state.lastSerialization = value + } + serialize_widgets?: boolean + /** + * The overridden fg color used to render the node. + * @see {@link renderingColor} + */ + get color(): string | undefined { + return this._state.color + } + + set color(value: string | undefined) { + setTrackedNodeState(this, 'color', value) + } + /** + * The overridden bg color used to render the node. + * @see {@link renderingBgColor} + */ + get bgcolor(): string | undefined { + return this._state.bgcolor + } + + set bgcolor(value: string | undefined) { + setTrackedNodeState(this, 'bgcolor', value) + } + /** + * The overridden box color used to render the node. + * @see {@link renderingBoxColor} + */ + get boxcolor(): string | undefined { + return this._state.boxcolor + } + + set boxcolor(value: string | undefined) { + setTrackedNodeState(this, 'boxcolor', value) + } + + /** The fg color used to render the node. */ + get renderingColor(): string { + const baseColor = + this.color || this.constructor.color || LiteGraph.NODE_DEFAULT_COLOR + return adjustColor(baseColor, { lightness: LiteGraph.nodeLightness }) + } + + /** The bg color used to render the node. */ + get renderingBgColor(): string { + const baseBgColor = + this.bgcolor || this.constructor.bgcolor || LiteGraph.NODE_DEFAULT_BGCOLOR + const adjustments: ColorAdjustOptions = { + opacity: LiteGraph.nodeOpacity, + lightness: LiteGraph.nodeLightness + } + + return adjustColor( + this.mode === LGraphEventMode.BYPASS + ? LiteGraph.NODE_DEFAULT_BYPASS_COLOR + : baseBgColor, + adjustments + ) + } + + /** The box color used to render the node. */ + get renderingBoxColor(): string { + if (this.boxcolor) return this.boxcolor + + if (LiteGraph.node_box_coloured_when_on) { + if (this.action_triggered) return '#FFF' + if (this.execute_triggered) return '#AAA' + } + + if (LiteGraph.node_box_coloured_by_mode) { + const modeColour = + LiteGraph.NODE_MODES_COLORS[this.mode ?? LGraphEventMode.ALWAYS] + if (modeColour) return modeColour + } + return LiteGraph.NODE_DEFAULT_BOXCOLOR + } + + /** @inheritdoc {@link IColorable.setColorOption} */ + setColorOption(colorOption: ColorOption | null): void { + if (colorOption == null) { + this.color = undefined + this.bgcolor = undefined + } else { + this.color = colorOption.color + this.bgcolor = colorOption.bgcolor + } + } + + /** @inheritdoc {@link IColorable.getColorOption} */ + getColorOption(): ColorOption | null { + return ( + Object.values(LGraphCanvas.node_colors).find( + (colorOption) => + colorOption.color === this.color && + colorOption.bgcolor === this.bgcolor + ) ?? null + ) + } + + /** + * The stroke styles that should be applied to the node. + */ + strokeStyles: Record< + string, + (this: LGraphNode) => IDrawBoundingOptions | undefined + > + + /** + * The progress of node execution. Used to render a progress bar. Value between 0 and 1. + */ + progress?: number + + exec_version?: number + action_call?: string + execute_triggered?: number + action_triggered?: number + /** + * @deprecated This property is unsupported and will be removed in a future release. + * Use `widgets_start_y` or a custom `arrange()` override instead. + */ + widgets_up?: boolean + widgets_start_y?: number + lostFocusAt?: number + gotFocusAt?: number + /** + * Extension-provided badges, drawn after the derived rows from + * {@link badgeRows}. Thunks are re-evaluated every frame. + */ + badges: (LGraphBadge | (() => LGraphBadge))[] = [] + /** @deprecated Badges always render top-right; assignment is ignored. */ + get badgePosition(): string { + warnDeprecated( + 'LGraphNode.badgePosition is deprecated: badges always render top-right.', + this + ) + return 'top-right' + } + set badgePosition(_value: string) { + warnDeprecated( + 'LGraphNode.badgePosition is deprecated: badges always render top-right.', + this + ) + } + title_buttons: LGraphButton[] = [] + onOutputRemoved?(this: LGraphNode, slot: number): void + onInputRemoved?(this: LGraphNode, slot: number, input: INodeInputSlot): void + /** + * The width of the node when collapsed. + * Updated by {@link LGraphCanvas.drawNode} + */ + _collapsed_width?: number + /** + * Called once at the start of every frame. Caller may change the values in {@link out}, which will be reflected in {@link boundingRect}. + * WARNING: Making changes to boundingRect via onBounding is poorly supported, and will likely result in strange behaviour. + */ + onBounding?(this: LGraphNode, out: Rect): void + console?: string[] + _level?: number + mouseOver?: IMouseOverData + redraw_on_mouse?: boolean + get resizable(): boolean | undefined { + return this._state.resizable + } + + set resizable(value: boolean | undefined) { + this._state.resizable = value + } + clonable?: boolean + _relative_id?: number + clip_area?: boolean + ignore_remove?: boolean + has_errors?: boolean + removable?: boolean + block_delete?: boolean + selected?: boolean + get showAdvanced(): boolean | undefined { + return this._state.showAdvanced + } + + set showAdvanced(value: boolean | undefined) { + setTrackedNodeState(this, 'showAdvanced', value) + } + + declare comfyDynamic?: Record + declare comfyClass?: string + declare isVirtualNode?: boolean + applyToGraph?(extraLinks?: LLink[]): void + + isSubgraphNode(): this is SubgraphNode { + return false + } + + /** @inheritdoc {@link renderArea} */ + private _renderArea = new Rectangle() + /** + * Rect describing the node area, including shadows and any protrusions. + * Determines if the node is visible. Calculated once at the start of every frame. + */ + get renderArea(): ReadOnlyRect { + return this._renderArea + } + + /** @inheritdoc {@link boundingRect} */ + private _boundingRect: Rectangle = new Rectangle() + /** + * Cached node position & area as `x, y, width, height`. Includes changes made by {@link onBounding}, if present. + * + * Determines the node hitbox and other rendering effects. Calculated once at the start of every frame. + */ + get boundingRect(): ReadOnlyRectangle { + return this._boundingRect + } + + /** The offset from {@link pos} to the top-left of {@link boundingRect}. */ + get boundingOffset(): Readonly { + const { + pos: [posX, posY], + boundingRect: [bX, bY] + } = this + return [posX - bX, posY - bY] + } + + get _posSize(): Rectangle { + return nodeGeometryBuffer(this) + } + + get _pos(): Point { + return nodePositionBuffer(this) + } + + get _size(): Size { + return nodeSizeBuffer(this) + } + + public get pos(): Point { + return nodePositionView(this) + } + + /** Node position does not necessarily correlate to the top-left corner. */ + public set pos(value) { + if (!value || value.length < 2) return + + setNodePosition(this, value) + } + + /** + * Set the node position to an absolute location. + */ + setPos(x: number, y: number): void { + this.pos = [x, y] + } + + public get size(): Size { + return nodeSizeView(this) + } + + public set size(value) { + if (!value || value.length < 2) return + + setNodeSize(this, value) + } + + /** + * The size of the node used for rendering. + */ + get renderingSize(): Size { + const renderedSize = refreshNodeGeometry(this) + if (!this.flags.collapsed) return renderedSize + + const contentSize = this.graph + ? layoutStore.contentSizeOf(this.graph.rootGraph.id, this.id) + : undefined + return [ + contentSize?.width ?? + this._collapsed_width ?? + LiteGraph.NODE_COLLAPSED_WIDTH, + contentSize?.height ?? 0 + ] + } + + get shape(): RenderShape | undefined { + return this._state.shape + } + + set shape(v: RenderShape | keyof typeof NAMED_SHAPES) { + setTrackedNodeState( + this, + 'shape', + typeof v === 'string' ? NAMED_SHAPES[v] : v + ) + } + + /** + * The shape of the node used for rendering. @see {@link RenderShape} + */ + get renderingShape(): RenderShape { + return ( + this._state.shape || + this.constructor.shape || + LiteGraph.NODE_DEFAULT_SHAPE + ) + } + + public get is_selected(): boolean | undefined { + return this.selected + } + + public set is_selected(value: boolean) { + this.selected = value + } + + public get title_mode(): TitleMode { + return this.constructor.title_mode ?? TitleMode.NORMAL_TITLE + } + + onConnectInput?( + this: LGraphNode, + target_slot: number, + type: unknown, + output: INodeOutputSlot | SubgraphIO, + node: LGraphNode | SubgraphInputNode, + slot: number + ): boolean + onConnectOutput?( + this: LGraphNode, + slot: number, + type: unknown, + input: INodeInputSlot | SubgraphIO, + target_node: number | LGraphNode | SubgraphOutputNode, + target_slot: number + ): boolean + onResize?(this: LGraphNode, size: Size): void + onPropertyChanged?( + this: LGraphNode, + name: string, + value: unknown, + prev_value?: unknown + ): boolean + /** Called for each connection that is created, updated, or removed. This includes "restored" connections when deserialising. */ + onConnectionsChange?( + this: LGraphNode, + type: ISlotType, + index: number, + isConnected: boolean, + link_info: LLink | null | undefined, + inputOrOutput: INodeInputSlot | INodeOutputSlot | SubgraphIO + ): void + onInputAdded?(this: LGraphNode, input: INodeInputSlot): void + onOutputAdded?(this: LGraphNode, output: INodeOutputSlot): void + onConfigure?(this: LGraphNode, serialisedNode: ISerialisedNode): void + onSerialize?(this: LGraphNode, serialised: ISerialisedNode): void + onExecute?( + this: LGraphNode, + param?: unknown, + options?: { action_call?: string } + ): void + onAction?( + this: LGraphNode, + action: string, + param: unknown, + options: { action_call?: string } + ): void + onDrawBackground?(this: LGraphNode, ctx: CanvasRenderingContext2D): void + onNodeCreated?(this: LGraphNode): void + /** + * Callback invoked by {@link connect} to override the target slot index. + * Its return value overrides the target index selection. + * @param target_slot The current input slot index + * @param requested_slot The originally requested slot index - could be negative, or if using (deprecated) name search, a string + * @returns {number | null} If a number is returned, the connection will be made to that input index. + * If an invalid index or non-number (false, null, NaN etc) is returned, the connection will be cancelled. + */ + onBeforeConnectInput?( + this: LGraphNode, + target_slot: number, + requested_slot?: number | string + ): number | false | null + onShowCustomPanelInfo?(this: LGraphNode, panel: Panel): void + onAddPropertyToPanel?(this: LGraphNode, pName: string, panel: Panel): boolean + onWidgetChanged?( + this: LGraphNode, + name: string, + value: unknown, + old_value: unknown, + w: IBaseWidget + ): void + onDeselected?(this: LGraphNode): void + onKeyUp?(this: LGraphNode, e: KeyboardEvent): void + onKeyDown?(this: LGraphNode, e: KeyboardEvent): void + onSelected?(this: LGraphNode): void + getExtraMenuOptions?( + this: LGraphNode, + canvas: LGraphCanvas, + options: (IContextMenuValue | null)[] + ): (IContextMenuValue | null)[] + getMenuOptions?(this: LGraphNode, canvas: LGraphCanvas): IContextMenuValue[] + onAdded?(this: LGraphNode, graph: LGraph): void + onDrawCollapsed?( + this: LGraphNode, + ctx: CanvasRenderingContext2D, + cavnas: LGraphCanvas + ): boolean + onDrawForeground?( + this: LGraphNode, + ctx: CanvasRenderingContext2D, + canvas: LGraphCanvas, + canvasElement: HTMLCanvasElement + ): void + onMouseLeave?(this: LGraphNode, e: CanvasPointerEvent): void + /** + * Override the default slot menu options. + */ + getSlotMenuOptions?(this: LGraphNode, slot: IFoundSlot): IContextMenuValue[] + /** + * Add extra menu options to the slot context menu. + */ + getExtraSlotMenuOptions?( + this: LGraphNode, + slot: IFoundSlot + ): IContextMenuValue[] + + // FIXME: Re-typing + onDropItem?(this: LGraphNode, event: Event): boolean + onDropData?( + this: LGraphNode, + data: string | ArrayBuffer, + filename: string, + file: File + ): void + onDropFile?(this: LGraphNode, file: File): void + onInputClick?(this: LGraphNode, index: number, e: CanvasPointerEvent): void + onInputDblClick?(this: LGraphNode, index: number, e: CanvasPointerEvent): void + onOutputClick?(this: LGraphNode, index: number, e: CanvasPointerEvent): void + onOutputDblClick?( + this: LGraphNode, + index: number, + e: CanvasPointerEvent + ): void + onGetPropertyInfo?(this: LGraphNode, property: string): INodePropertyInfo + onNodeOutputAdd?(this: LGraphNode, value: unknown): void + onNodeInputAdd?(this: LGraphNode, value: unknown): void + onMenuNodeInputs?( + this: LGraphNode, + entries: (IContextMenuValue | null)[] + ): (IContextMenuValue | null)[] + onMenuNodeOutputs?( + this: LGraphNode, + entries: (IContextMenuValue | null)[] + ): (IContextMenuValue | null)[] + onMouseUp?( + this: LGraphNode, + e: CanvasPointerEvent, + pos: Point, + canvas: LGraphCanvas + ): void + onMouseEnter?(this: LGraphNode, e: CanvasPointerEvent): void + /** Blocks drag if return value is truthy. @param pos Offset from {@link LGraphNode.pos}. */ + onMouseDown?( + this: LGraphNode, + e: CanvasPointerEvent, + pos: Point, + canvas: LGraphCanvas + ): boolean + /** @param pos Offset from {@link LGraphNode.pos}. */ + onDblClick?( + this: LGraphNode, + e: CanvasPointerEvent, + pos: Point, + canvas: LGraphCanvas + ): void + /** @param pos Offset from {@link LGraphNode.pos}. */ + onNodeTitleDblClick?( + this: LGraphNode, + e: CanvasPointerEvent, + pos: Point, + canvas: LGraphCanvas + ): void + onDrawTitle?(this: LGraphNode, ctx: CanvasRenderingContext2D): void + onDrawTitleText?( + this: LGraphNode, + ctx: CanvasRenderingContext2D, + title_height: number, + size: Size, + scale: number, + title_text_font: string, + selected?: boolean + ): void + onDrawTitleBox?( + this: LGraphNode, + ctx: CanvasRenderingContext2D, + title_height: number, + size: Size, + scale: number + ): void + onDrawTitleBar?( + this: LGraphNode, + ctx: CanvasRenderingContext2D, + title_height: number, + size: Size, + scale: number, + fgcolor: string + ): void + onRemoved?(this: LGraphNode): void + onMouseMove?( + this: LGraphNode, + e: CanvasPointerEvent, + pos: Point, + arg2: LGraphCanvas + ): void + onPropertyChange?(this: LGraphNode): void + updateOutputData?(this: LGraphNode, origin_slot: number): void + + private _getErrorStrokeStyle( + this: LGraphNode + ): IDrawBoundingOptions | undefined { + if (this.has_errors) { + return { + padding: 12, + lineWidth: 10, + color: LiteGraph.NODE_ERROR_COLOUR + } + } + } + + private _getSelectedStrokeStyle( + this: LGraphNode + ): IDrawBoundingOptions | undefined { + if (this.selected) { + return { + padding: this.has_errors ? 20 : undefined + } + } + } + + constructor(title: string, type?: string) { + initializeWidgetsView(this) + this._state = createNodeShellState( + this, + createInputSlotView, + title, + type, + this.title_mode + ) + this._state.outputs = createOutputSlotView(this, this._state.outputs) + this._inputs = this._state.inputs + this._outputs = this._state.outputs + for (const property of [ + 'inputs', + 'outputs', + 'properties', + 'order', + 'boxcolor', + 'last_serialization' + ] as const) { + Object.defineProperty(this, property, { + ...Object.getOwnPropertyDescriptor(LGraphNode.prototype, property), + enumerable: true + }) + } + this.size = [LiteGraph.NODE_WIDTH, 60] + this.pos = [10, 10] + this.strokeStyles = { + error: this._getErrorStrokeStyle, + selected: this._getSelectedStrokeStyle + } + } + + /** Internal callback for subgraph nodes. Do not implement externally. */ + _internalConfigureAfterSlots?(): void + + /** + * configure a node from an object containing the serialized info + */ + configure(info: ISerialisedNode): void { + hydrateExtensionPayload(this, info, NODE_CANONICAL_FIELDS) + if (this.graph) { + this.graph.incrementVersion() + } + for (const j in info) { + if (!NODE_CANONICAL_FIELDS.has(j)) continue + if (j == 'properties') { + // i don't want to clone properties, I want to reuse the old container + for (const k in info.properties) { + this.properties[k] = info.properties[k] + this.onPropertyChanged?.(k, info.properties[k]) + } + continue + } + + if (j === 'type') continue + + if (j === 'id') { + // Once registered, the owning graph owns the id — it may have + // renumbered this node to resolve a collision that the serialised id + // would reinstate. + if (this._graphScope) continue + const id = toNodeId(info.id) + if (id !== UNASSIGNED_NODE_ID) this.id = id + continue + } + + // @ts-expect-error #594 + if (info[j] == null) { + continue + // @ts-expect-error #594 + } else if (typeof info[j] == 'object') { + // @ts-expect-error #594 + if (this[j]?.configure) { + // @ts-expect-error #594 + this[j]?.configure(info[j]) + } else { + // @ts-expect-error #594 + this[j] = LiteGraph.cloneObject(info[j], this[j]) + } + } else { + // value + // @ts-expect-error #594 + this[j] = info[j] + } + } + + if (!info.title) { + this.title = this.constructor.title + } + + this.inputs = this.inputs.map((input) => + toClass(NodeInputSlot, input, this) + ) + for (const [i, input] of this.inputs.entries()) { + const serialisedLink = info.inputs?.[i]?.link + const link = + this.graph && serialisedLink != null + ? this.graph.links.get(toLinkId(serialisedLink)) + : null + this.onConnectionsChange?.(NodeSlotType.INPUT, i, true, link, input) + this.onInputAdded?.(input) + } + + this.outputs = this.outputs.map((output) => + toClass(NodeOutputSlot, output, this) + ) + for (const [i, output] of this.outputs.entries()) { + const serialisedLinks = info.outputs?.[i]?.links + if (!serialisedLinks) continue + + for (const linkId of serialisedLinks) { + const link = this.graph ? this.graph.links.get(toLinkId(linkId)) : null + this.onConnectionsChange?.(NodeSlotType.OUTPUT, i, true, link, output) + } + this.onOutputAdded?.(output) + } + + // SubgraphNode callback. + this._internalConfigureAfterSlots?.() + + const restoration = createWidgetRestorationState( + info, + this.constructor.nodeData?.fallbackWidgetsValuesNames + ) + const namedValues = restoration.named + const graphId = this.graph?.rootGraph.id ?? zeroUuid + try { + useWidgetValueStore().setNodeWidgetRestoration( + graphId, + this.id, + restoration + ) + + if (this.widgets) { + for (const w of this.widgets) { + if (!w) continue + + const input = this.inputs.find((i) => i.widget?.name === w.name) + if (input?.label) w.label = input.label + + if ( + w.options?.property && + this.properties[w.options.property] != undefined + ) + w.value = JSON.parse( + JSON.stringify(this.properties[w.options.property]) + ) + } + + if (namedValues) { + const legacyShadow = computeLegacyWidgetShadow( + this.widgets, + info.widgets_values + ) + reportNamedValuesShadowDiff( + this, + diffNamedValuesShadow(namedValues, legacyShadow), + Boolean(info.widgets_values_named) + ) + } + + let positionalIndex = 0 + for (const widget of this.widgets) { + if (widget.serialize === false) continue + const restored = useWidgetValueStore().getRestoredWidgetValue( + graphId, + this.id, + widget.name, + positionalIndex++ + ) + if (restored) widget.value = restored.value + } + } + // Sync the state of this.resizable. + if (this.pinned) this.resizable = false + + if (this.widgets_up) { + console.warn( + `[LiteGraph] Node type "${this.type}" uses deprecated property "widgets_up". ` + + 'This property is unsupported and will be removed. ' + + 'Use "widgets_start_y" or a custom arrange() override instead.' + ) + } + + this.onConfigure?.(extensionConfigureView(this, info)) + } finally { + useWidgetValueStore().clearNodeWidgetRestoration(graphId, this.id) + } + } + + /** + * serialize the content + */ + serialize(): ISerialisedNode { + return this.serializeFromStoreState(this._state) + } + + serializeFromStoreState(state: NodeState): ISerialisedNode { + // create serialization object + const o: ISerialisedNode = { + id: serializeNodeId(state.id), + type: state.type, + pos: [this.pos[0], this.pos[1]], + size: [this.size[0], this.size[1]], + flags: LiteGraph.cloneObject(state.flags), + order: this.order, + mode: state.mode, + showAdvanced: state.showAdvanced + } + + // special case for when there were errors + if (this.constructor === LGraphNode && state.lastSerialization) + return { + ...LiteGraph.cloneObject(state.lastSerialization), + mode: o.mode, + pos: o.pos + } + + if (state.inputs) + o.inputs = state.inputs.map((input, i) => + inputAsSerialisable(input, this, i) + ) + if (state.outputs) + o.outputs = state.outputs.map((output, i) => + outputAsSerialisable(output, this, i) + ) + + if (state.title && state.title != this.constructor.title) + o.title = state.title + + if (state.properties) o.properties = LiteGraph.cloneObject(state.properties) + + const { widgets } = this + if (widgets?.length && this.serialize_widgets) + Object.assign(o, serialiseWidgetValues(widgets)) + + if (!o.type && this.constructor.type) o.type = this.constructor.type + + if (state.color) o.color = state.color + if (state.bgcolor) o.bgcolor = state.bgcolor + if (state.boxcolor) o.boxcolor = state.boxcolor + if (state.shape) o.shape = state.shape + + let hookResult: unknown + const serialised = runExtensionSerializeHook( + this, + o, + NODE_CANONICAL_FIELDS, + this.onSerialize + ? (data) => { + hookResult = this.onSerialize?.(data) + } + : undefined + ) + if (hookResult) + console.warn( + "node onSerialize shouldn't return anything, data should be stored in the object pass in the first parameter" + ) + + return serialised + } + + clone(): LGraphNode | null { + if (this.type == null) return null + const node = LiteGraph.createNode(this.type) + if (!node) return null + + // we clone it because serialize returns shared containers + const data = LiteGraph.cloneObject(this.serialize()) + const { inputs, outputs } = data + + // remove links + if (inputs) { + for (const input of inputs) { + input.link = null + } + } + + if (outputs) { + for (const { links } of outputs) { + if (links) links.length = 0 + } + } + + // @ts-expect-error Exceptional case: id is removed so that the graph can assign a new one on add. + data.id = undefined + + node.id = this.id + node.configure(data) + + return node + } + + /** + * serialize and stringify + */ + toString(): string { + return JSON.stringify(this.serialize()) + } + + /** + * get the title string + */ + getTitle(): string { + return this.title || this.constructor.title + } + + /** + * sets the value of a property + * @param name + * @param value + */ + setProperty(name: string, value: TWidgetValue): void { + this.properties ||= {} + if (value === this.properties[name]) return + + const prev_value = this.properties[name] + this.properties[name] = value + // abort change + if (this.onPropertyChanged?.(name, value, prev_value) === false) + this.properties[name] = prev_value + + if (this.widgets) { + for (const w of this.widgets) { + if (!w) continue + + if (w.options.property == name) { + w.value = value + break + } + } + } + } + + /** + * sets the output data + * @param slot + * @param data + */ + setOutputData( + slot: number, + data: number | string | boolean | { toToolTip?(): string } + ): void { + const { outputs } = this + if (!outputs) return + + // this maybe slow and a niche case + if (slot == -1 || slot >= outputs.length) return + + const output_info = outputs[slot] + if (!output_info) return + + // store data in the output itself in case we want to debug + output_info._data = data + + if (!this.graph) throw new NullGraphError() + + for (const link of outputLinks(this.graph, this.id, slot)) { + link.data = data + } + } + + /** + * sets the output data type, useful when you want to be able to overwrite the data type + */ + setOutputDataType(slot: SlotIndex, type: ISlotType): void { + const { outputs } = this + if (!outputs || slot == -1 || slot >= outputs.length) return + + const output_info = outputs[slot] + if (!output_info) return + // store data in the output itself in case we want to debug + output_info.type = type + + if (!this.graph) throw new NullGraphError() + + for (const link of outputLinks(this.graph, this.id, slot)) { + link.type = type + } + } + + /** + * Retrieves the input data (data traveling through the connection) from one slot + * @param slot + * @param force_update if set to true it will force the connected node of this slot to output data into this link + * @returns data or if it is not connected returns undefined + */ + getInputData(slot: number, force_update?: boolean): unknown { + if (!this.inputs || slot >= this.inputs.length) return + if (!this.graph) throw new NullGraphError() + + const link = this.getInputLink(slot) + if (!link) return + + if (!force_update) return link.data + + // special case: used to extract data from the incoming connection before the graph has been executed + const node = this.graph.getNodeById(link.origin_id) + if (!node) return link.data + + if (node.updateOutputData) { + node.updateOutputData(link.origin_slot) + } else { + node.onExecute?.() + } + + return link.data + } + + /** + * Retrieves the input data type (in case this supports multiple input types) + * @param slot + * @returns datatype in string format + */ + getInputDataType(slot: SlotIndex): ISlotType | null { + if (!this.inputs || slot >= this.inputs.length) return null + if (!this.graph) throw new NullGraphError() + + const link = this.getInputLink(slot) + if (!link) return null + + const node = this.graph.getNodeById(link.origin_id) + if (!node) return link.type + + const output_info = node.outputs[link.origin_slot] + return output_info ? output_info.type : null + } + + /** + * Retrieves the input data from one slot using its name instead of slot number + * @param slot_name + * @param force_update if set to true it will force the connected node of this slot to output data into this link + * @returns data or if it is not connected returns null + */ + getInputDataByName(slot_name: string, force_update: boolean): unknown { + const slot = this.findInputSlot(slot_name) + return slot == -1 ? null : this.getInputData(slot, force_update) + } + + /** + * tells you if there is a connection in one input slot + * @param slot The 0-based index of the input to check + * @returns `true` if the input slot has a link ID (does not perform validation) + */ + isInputConnected(slot: number): boolean { + if (!this.inputs) return false + return ( + slot < this.inputs.length && + !!this.graph && + inputHasLink(this.graph, this.id, slot) + ) + } + + /** + * tells you info about an input connection (which node, type, etc) + * @returns object or null { link: id, name: string, type: string or 0 } + */ + getInputInfo(slot: number): INodeInputSlot | null { + return !this.inputs || !(slot < this.inputs.length) + ? null + : this.inputs[slot] + } + + /** + * Resolves the output source for cross-graph virtual nodes (e.g. Set/Get), + * bypassing {@link getInputLink} when the source lives in a different graph. + */ + resolveVirtualOutput?( + slot: number + ): { node: LGraphNode; slot: number } | undefined + + /** + * Returns the link info in the connection of an input slot + * @returns object or null + */ + getInputLink(slot: number): LLink | null { + if (!this.inputs) return null + + if (slot < this.inputs.length) { + if (!this.graph) throw new NullGraphError() + + return inputLink(this.graph, this.id, slot) ?? null + } + return null + } + + /** + * returns the node connected in the input slot + * @returns node or null + */ + getInputNode(slot: number): LGraphNode | null { + if (!this.inputs) return null + if (slot >= this.inputs.length) return null + + if (!this.inputs[slot]) return null + if (!this.graph) throw new NullGraphError() + + const link_info = this.getInputLink(slot) + if (!link_info) return null + + return this.graph.getNodeById(link_info.origin_id) + } + + /** + * returns the value of an input with this name, otherwise checks if there is a property with that name + * @returns value + */ + getInputOrProperty(name: string): unknown { + const { inputs } = this + if (!inputs?.length) { + return this.properties ? this.properties[name] : null + } + if (!this.graph) throw new NullGraphError() + + for (const [index, input] of inputs.entries()) { + if (name == input.name) { + const link = this.getInputLink(index) + if (link) return link.data + } + } + return this.properties[name] + } + + /** + * tells you the last output data that went in that slot + * @returns object or null + */ + getOutputData(slot: number): unknown { + if (!this.outputs) return null + if (slot >= this.outputs.length) return null + + const info = this.outputs[slot] + return info._data + } + + /** + * tells you info about an output connection (which node, type, etc) + * @returns object or null { name: string, type: string, links: [ ids of links in number ] } + */ + getOutputInfo(slot: number): INodeOutputSlot | null { + return !this.outputs || !(slot < this.outputs.length) + ? null + : this.outputs[slot] + } + + /** + * tells you if there is a connection in one output slot + */ + isOutputConnected(slot: number): boolean { + if (!this.outputs || !this.graph) return false + return ( + slot < this.outputs.length && outputHasLinks(this.graph, this.id, slot) + ) + } + + /** + * tells you if there is any connection in the output slots + */ + isAnyOutputConnected(): boolean { + const { outputs, graph } = this + if (!outputs || !graph) return false + + return outputs.some((_, slot) => outputHasLinks(graph, this.id, slot)) + } + + /** + * retrieves all the nodes connected to this output slot + */ + getOutputNodes(slot: number): LGraphNode[] | null { + const { outputs } = this + if (!outputs || outputs.length == 0) return null + + if (slot >= outputs.length) return null + if (!this.graph) return null + + const links = outputLinks(this.graph, this.id, slot) + if (links.length == 0) return null + + const r: LGraphNode[] = [] + for (const link of links) { + const target_node = this.graph.getNodeById(link.target_id) + if (target_node) { + r.push(target_node) + } + } + return r + } + + addOnTriggerInput(): number { + const trigS = this.findInputSlot('onTrigger') + if (trigS == -1) { + this.addInput('onTrigger', LiteGraph.EVENT, { + nameLocked: true + }) + return this.findInputSlot('onTrigger') + } + return trigS + } + + addOnExecutedOutput(): number { + const trigS = this.findOutputSlot('onExecuted') + if (trigS == -1) { + this.addOutput('onExecuted', LiteGraph.ACTION, { + nameLocked: true + }) + return this.findOutputSlot('onExecuted') + } + return trigS + } + + onAfterExecuteNode(param: unknown, options?: { action_call?: string }) { + const trigS = this.findOutputSlot('onExecuted') + if (trigS != -1) { + this.triggerSlot(trigS, param, null, options) + } + } + + changeMode(modeTo: number): boolean { + switch (modeTo) { + case LGraphEventMode.ON_EVENT: + break + + case LGraphEventMode.ON_TRIGGER: + this.addOnTriggerInput() + this.addOnExecutedOutput() + break + + case LGraphEventMode.NEVER: + break + + case LGraphEventMode.ALWAYS: + break + + // @ts-expect-error Not impl. + case LiteGraph.ON_REQUEST: + break + + default: + return false + } + this.mode = modeTo + return true + } + + /** + * Triggers the node code execution, place a boolean/counter to mark the node as being executed + */ + doExecute(param?: unknown, options?: { action_call?: string }): void { + options = options || {} + if (this.onExecute) { + // enable this to give the event an ID + options.action_call ||= `${this.id}_exec_${Math.floor(Math.random() * 9999)}` + if (!this.graph) throw new NullGraphError() + + // @ts-expect-error Technically it works when id is a string. Array gets props. + this.graph.nodes_executing[this.id] = true + this.onExecute(param, options) + // @ts-expect-error deprecated + this.graph.nodes_executing[this.id] = false + + // save execution/action ref + this.exec_version = this.graph.iteration + if (options?.action_call) { + this.action_call = options.action_call + // @ts-expect-error deprecated + this.graph.nodes_executedAction[this.id] = options.action_call + } + } + // the nFrames it will be used (-- each step), means "how old" is the event + this.execute_triggered = 2 + this.onAfterExecuteNode?.(param, options) + } + + /** + * Triggers an action, wrapped by logics to control execution flow + * @param action name + */ + actionDo( + action: string, + param: unknown, + options: { action_call?: string } + ): void { + options = options || {} + if (this.onAction) { + // enable this to give the event an ID + options.action_call ||= `${this.id}_${action || 'action'}_${Math.floor(Math.random() * 9999)}` + if (!this.graph) throw new NullGraphError() + + // @ts-expect-error deprecated + this.graph.nodes_actioning[this.id] = action || 'actioning' + this.onAction(action, param, options) + // @ts-expect-error deprecated + this.graph.nodes_actioning[this.id] = false + + // save execution/action ref + if (options?.action_call) { + this.action_call = options.action_call + // @ts-expect-error deprecated + this.graph.nodes_executedAction[this.id] = options.action_call + } + } + // the nFrames it will be used (-- each step), means "how old" is the event + this.action_triggered = 2 + this.onAfterExecuteNode?.(param, options) + } + + /** + * Triggers an event in this node, this will trigger any output with the same name + * @param action name ( "on_play", ... ) if action is equivalent to false then the event is send to all + */ + trigger( + action: string, + param: unknown, + options: { action_call?: string } + ): void { + const { outputs } = this + if (!outputs || !outputs.length) { + return + } + + if (this.graph) this.graph._last_trigger_time = LiteGraph.getTime() + + for (const [i, output] of outputs.entries()) { + if ( + !output || + output.type !== LiteGraph.EVENT || + (action && output.name != action) + ) { + continue + } + this.triggerSlot(i, param, null, options) + } + } + + /** + * Triggers a slot event in this node: cycle output slots and launch execute/action on connected nodes + * @param slot the index of the output slot + * @param link_id [optional] in case you want to trigger and specific output link in a slot + */ + triggerSlot( + slot: number, + param: unknown, + link_id: number | null, + options?: { action_call?: string } + ): void { + options = options || {} + if (!this.outputs) return + + if (slot == null) { + console.error('slot must be a number') + return + } + + if (typeof slot !== 'number') + console.warn( + "slot must be a number, use node.trigger('name') if you want to use a string" + ) + + const output = this.outputs[slot] + if (!output) return + + if (!this.graph) throw new NullGraphError() + const links = outputLinks(this.graph, this.id, slot) + if (!links.length) return + + this.graph._last_trigger_time = LiteGraph.getTime() + + // for every link attached here + for (const link_info of links) { + // to skip links + if (link_id != null && link_id != link_info.id) continue + + link_info._last_time = LiteGraph.getTime() + const node = this.graph.getNodeById(link_info.target_id) + // node not found? + if (!node) continue + + if (node.mode === LGraphEventMode.ON_TRIGGER) { + // generate unique trigger ID if not present + if (!options.action_call) + options.action_call = `${this.id}_trigg_${Math.floor(Math.random() * 9999)}` + // -- wrapping node.onExecute(param); -- + node.doExecute?.(param, options) + } else if (node.onAction) { + // generate unique action ID if not present + if (!options.action_call) + options.action_call = `${this.id}_act_${Math.floor(Math.random() * 9999)}` + // pass the action name + const target_connection = node.inputs[link_info.target_slot] + node.actionDo(target_connection.name, param, options) + } + } + } + + /** + * clears the trigger slot animation + * @param slot the index of the output slot + * @param link_id [optional] in case you want to trigger and specific output link in a slot + */ + clearTriggeredSlot(slot: number, link_id: number): void { + if (!this.outputs) return + + const output = this.outputs[slot] + if (!output) return + + if (!this.graph) throw new NullGraphError() + + // for every link attached here + for (const link_info of outputLinks(this.graph, this.id, slot)) { + // to skip links + if (link_id != null && link_id != link_info.id) continue + + link_info._last_time = 0 + } + } + + /** + * changes node size and triggers callback + */ + setSize(size: Size): void { + this.size = size + this.onResize?.(this.size) + } + + /** + * Expands the node size to fit its content. + */ + expandToFitContent(): void { + const newSize = this.computeSize() + this.setSize([ + Math.max(this.size[0], newSize[0]), + Math.max(this.size[1], newSize[1]) + ]) + } + + /** + * add a new property to this node + * @param type string defining the output type ("vec3","number",...) + * @param extra_info this can be used to have special properties of the property (like values, etc) + */ + addProperty( + name: string, + default_value: NodeProperty | undefined, + type?: string, + extra_info?: Partial + ): INodePropertyInfo { + const o: INodePropertyInfo = { name, type, default_value } + if (extra_info) Object.assign(o, extra_info) + + this.properties_info ||= [] + this.properties_info.push(o) + this.properties ||= {} + this.properties[name] = default_value + return o + } + + /** + * add a new output slot to use in this node + * @param type string defining the output type ("vec3","number",...) + * @param extra_info this can be used to have special properties of an output (label, special color, position, etc) + */ + addOutput>( + name: string, + type: ISlotType, + extra_info?: TProperties + ): INodeOutputSlot & TProperties { + // Legacy save-and-re-add patterns pass a stale `links` mirror; drop it so + // Object.assign cannot hit the deprecated prototype accessor. + const { links: _staleLinks, ...extraProps } = { ...extra_info } + const output = Object.assign( + new NodeOutputSlot({ name, type }, this), + extraProps + ) as NodeOutputSlot & TProperties + + this.outputs ||= [] + this.outputs.push(output) + const added = this.outputs.at(-1) as NodeOutputSlot & TProperties + this.onOutputAdded?.(added) + + if (LiteGraph.auto_load_slot_types) + LiteGraph.registerNodeAndSlotType(this, type, true) + + this.expandToFitContent() + this.setDirtyCanvas(true, true) + return added + } + + /** + * remove an existing output slot + */ + removeOutput(slot: number): void { + // Only disconnect if node is part of a graph + if (this.graph) { + this.disconnectOutput(slot) + } + const { outputs } = this + outputs.splice(slot, 1) + + // Only update link indices if node is part of a graph. Ascending order: + // each decrement re-keys the link to an already-processed slot index. + if (this.graph) { + for (let oldSlot = slot + 1; oldSlot <= outputs.length; ++oldSlot) { + for (const link of outputLinks(this.graph, this.id, oldSlot)) { + link.origin_slot-- + } + } + } + if (this.graph) { + for (const floatingLink of this.graph.floatingLinks.values()) { + if ( + floatingLink.origin_id === this.id && + floatingLink.origin_slot > slot + ) + floatingLink.origin_slot-- + } + } + + this.onOutputRemoved?.(slot) + this.setDirtyCanvas(true, true) + } + + /** + * add a new input slot to use in this node + * @param type string defining the input type ("vec3","number",...), it its a generic one use 0 + * @param extra_info this can be used to have special properties of an input (label, color, position, etc) + */ + addInput>( + name: string, + type: ISlotType, + extra_info?: TProperties + ): INodeInputSlot & TProperties { + type ||= 0 + + // Legacy save-and-re-add patterns pass a stale `link` mirror; drop it so + // Object.assign cannot hit the deprecated prototype accessor. + const { link: _staleLink, ...extraProps } = { ...extra_info } + const input = Object.assign( + new NodeInputSlot({ name, type }, this), + extraProps + ) as NodeInputSlot & TProperties + + this.inputs ||= [] + this.inputs.push(input) + const added = this.inputs.at(-1) as NodeInputSlot & TProperties + this.expandToFitContent() + + this.onInputAdded?.(added) + LiteGraph.registerNodeAndSlotType(this, type) + + this.setDirtyCanvas(true, true) + return added + } + + /** + * remove an existing input slot + */ + removeInput(slot: number): void { + const { graph, inputs } = this + const slotInfo = inputs[slot] + if (!slotInfo) return + + if (graph) { + const previous = captureInputLayout(this) + const result = replaceNodeInputs( + this, + previous, + previous.inputs.toSpliced(slot, 1), + previous.links, + true + ) + if (!result.ok) return + for (const floatingLink of graph.floatingLinks.values()) { + if ( + floatingLink.target_id === this.id && + floatingLink.target_slot > slot + ) + floatingLink.target_slot-- + } + } else { + inputs.splice(slot, 1) + } + this.onInputRemoved?.(slot, slotInfo) + this.setDirtyCanvas(true, true) + } + + /** + * computes the minimum size of a node according to its inputs and output slots + * @returns the total size + */ + computeSize(out?: Size): Size { + const ctorSize = this.constructor.size + if (ctorSize) return [ctorSize[0], ctorSize[1]] + + const { inputs, outputs, widgets } = this + let rows = Math.max( + inputs ? inputs.filter((input) => !isWidgetInputSlot(input)).length : 1, + outputs ? outputs.length : 1 + ) + const size = out ?? [0, 0] + rows = Math.max(rows, 1) + // although it should be graphcanvas.inner_text_font size + const font_size = LiteGraph.NODE_TEXT_SIZE + + const padLeft = LiteGraph.NODE_TITLE_HEIGHT + const padRight = padLeft * 0.33 + const title_width = + padLeft + compute_text_size(this.title, this.titleFontStyle) + padRight + let input_width = 0 + let widgetWidth = 0 + let output_width = 0 + + if (inputs) { + for (const input of inputs) { + const text = input.label || input.localized_name || input.name || '' + const text_width = compute_text_size(text, this.innerFontStyle) + if (isWidgetInputSlot(input)) { + const widget = this.getWidgetFromSlot(input) + if (widget && !this.isWidgetVisible(widget)) continue + + if (text_width > widgetWidth) widgetWidth = text_width + } else { + if (text_width > input_width) input_width = text_width + } + } + } + + if (outputs) { + for (const output of outputs) { + const text = output.label || output.localized_name || output.name || '' + const text_width = compute_text_size(text, this.innerFontStyle) + if (output_width < text_width) output_width = text_width + } + } + + const minWidth = LiteGraph.NODE_WIDTH * (widgets?.length ? 1.5 : 1) + // Text + slot width + centre padding + const centrePadding = input_width && output_width ? 5 : 0 + const slotsWidth = + input_width + + output_width + + 2 * LiteGraph.NODE_SLOT_HEIGHT + + centrePadding + + // Total distance from edge of node to the inner edge of the widget 'previous' arrow button + const widgetMargin = + BaseWidget.margin + BaseWidget.arrowMargin + BaseWidget.arrowWidth + const widgetPadding = BaseWidget.minValueWidth + 2 * widgetMargin + if (widgetWidth) widgetWidth += widgetPadding + + size[0] = Math.max(slotsWidth, widgetWidth, title_width, minWidth) + size[1] = + (this.constructor.slot_start_y || 0) + rows * LiteGraph.NODE_SLOT_HEIGHT + + // Get widget height & expand size if necessary + let widgets_height = 0 + if (widgets?.length) { + for (const widget of widgets) { + if (!this.isWidgetVisible(widget)) continue + + let widget_height = 0 + if (widget.computeSize) { + widget_height += widget.computeSize(size[0])[1] + } else if (widget.computeLayoutSize) { + // Expand widget width if necessary + const { minHeight, minWidth } = widget.computeLayoutSize(this) + const widgetWidth = minWidth + widgetPadding + if (widgetWidth > size[0]) size[0] = widgetWidth + + widget_height += minHeight + } else { + widget_height += LiteGraph.NODE_WIDGET_HEIGHT + } + widgets_height += widget_height + 4 + } + widgets_height += 8 + } + + // compute height using widgets height + if (this.widgets_up) size[1] = Math.max(size[1], widgets_height) + else if (this.widgets_start_y != null) + size[1] = Math.max(size[1], widgets_height + this.widgets_start_y) + else size[1] += widgets_height + + function compute_text_size(text: string, fontStyle: string) { + return ( + LGraphCanvas._measureText?.(text, fontStyle) ?? + font_size * (text?.length ?? 0) * 0.6 + ) + } + + if (this.constructor.min_height && size[1] < this.constructor.min_height) { + size[1] = this.constructor.min_height + } + + // margin + size[1] += 6 + + return size + } + + inResizeCorner(canvasX: number, canvasY: number): boolean { + const rows = this.outputs ? this.outputs.length : 1 + const outputs_offset = + (this.constructor.slot_start_y || 0) + rows * LiteGraph.NODE_SLOT_HEIGHT + const size = this.renderingSize + return isInRectangle( + canvasX, + canvasY, + this.pos[0] + size[0] - 15, + this.pos[1] + Math.max(size[1] - 15, outputs_offset), + 20, + 20 + ) + } + + /** + * Returns which resize corner the point is over, if any. + * @param canvasX X position in canvas coordinates + * @param canvasY Y position in canvas coordinates + * @returns The compass corner the point is in, otherwise `undefined`. + */ + findResizeDirection( + canvasX: number, + canvasY: number + ): CompassCorners | undefined { + if (this.resizable === false) return + + const { boundingRect } = this + if (!boundingRect.containsXy(canvasX, canvasY)) return + + // Check corners first (they take priority over edges) + return boundingRect.findContainingCorner( + canvasX, + canvasY, + LGraphNode.resizeHandleSize + ) + } + + /** + * returns all the info available about a property of this node. + * @param property name of the property + * @returns the object with all the available info + */ + getPropertyInfo(property: string) { + let info = null + + // there are several ways to define info about a property + // legacy mode + const { properties_info } = this + if (properties_info) { + for (const propInfo of properties_info) { + if (propInfo.name == property) { + info = propInfo + break + } + } + } + // litescene mode using the constructor + // @ts-expect-error deprecated https://github.com/Comfy-Org/litegraph.js/issues/639 + if (this.constructor[`@${property}`]) + // @ts-expect-error deprecated https://github.com/Comfy-Org/litegraph.js/issues/639 + info = this.constructor[`@${property}`] + + if (this.constructor.widgets_info?.[property]) + info = this.constructor.widgets_info[property] + + // litescene mode using the constructor + if (!info && this.onGetPropertyInfo) { + info = this.onGetPropertyInfo(property) + } + + info ||= {} + info.type ||= typeof this.properties[property] + if (info.widget == 'combo') info.type = 'enum' + + return info + } + + /** + * Defines a widget inside the node, it will be rendered on top of the node, you can control lots of properties + * @param type the widget type + * @param name the text to show on the widget + * @param value the default value + * @param callback function to call when it changes (optionally, it can be the name of the property to modify) + * @param options the object that contains special properties of this widget + * @returns the created widget object + */ + addWidget< + Type extends TWidgetType, + TValue extends WidgetTypeMap[Type]['value'] + >( + type: Type, + name: string, + value: TValue, + callback: IBaseWidget['callback'] | string | null, + options?: IWidgetOptions | string + ): WidgetTypeMap[Type] | IBaseWidget { + this.widgets ||= [] + + if (!options && callback && typeof callback === 'object') { + options = callback + callback = null + } + + // options can be the property name + options ||= {} + if (typeof options === 'string') options = { property: options } + + // callback can be the property name + if (callback && typeof callback === 'string') { + options.property = callback + callback = null + } + + const w: IBaseWidget & { type: Type } = { + // @ts-expect-error - Type casting for widget type property + type: type.toLowerCase(), + name: name, + value: value, + callback: typeof callback !== 'function' ? undefined : callback, + options, + y: 0 + } + + if (w.options.y !== undefined) { + w.y = w.options.y + } + + if (!callback && !w.options.callback && !w.options.property) { + console.warn( + 'LiteGraph addWidget(...) without a callback or property assigned' + ) + } + if (type == 'combo' && !w.options.values) { + throw "LiteGraph addWidget('combo',...) requires to pass values in options: { values:['red','blue'] }" + } + + const widget = this.addCustomWidget(w) + this.expandToFitContent() + return widget + } + + addCustomWidget( + custom_widget: TPlainWidget + ): TPlainWidget | WidgetTypeMap[TPlainWidget['type']] { + this.widgets ||= [] + const widget = toConcreteWidget(custom_widget, this) + this.widgets.push(widget) + + // Only register with store if node has a valid ID (is already in a graph). + // If the node isn't in a graph yet (id === -1), registration happens + // when the node is added via LGraph.add() -> node.onAdded. + if (this.id !== UNASSIGNED_NODE_ID && isNodeBindable(widget)) { + widget.setNodeId(this.id) + } + + if (widget.serialize === false) return widget + + const positionalIndex = + this.widgets.filter((candidate) => candidate.serialize !== false).length - + 1 + const restored = useWidgetValueStore().getRestoredWidgetValue( + this.graph?.rootGraph.id ?? zeroUuid, + this.id, + widget.name, + positionalIndex + ) + if (restored) widget.value = restored.value + + return widget + } + + addTitleButton(options: LGraphButtonOptions): LGraphButton { + this.title_buttons ||= [] + const button = new LGraphButton(options) + this.title_buttons.push(button) + return button + } + + onTitleButtonClick(button: LGraphButton, canvas: LGraphCanvas): void { + // Dispatch event for button click + canvas.dispatch('litegraph:node-title-button-clicked', { + node: this, + button: button + }) + } + + removeWidget(widget: IBaseWidget): void { + if (!this.widgets) { + console.error('removeWidget called on node without widgets') + return + } + + const widgetIndex = this.widgets.indexOf(widget) + if (widgetIndex === -1) { + console.error('Widget not found on this node') + return + } + const id = widget.widgetId + + // Clean up slot references to prevent memory leaks + if (this.inputs) { + for (const input of this.inputs) { + if (input._widget === widget) { + input._widget = undefined + input.widget = undefined + input.pos = undefined + } + } + } + + widget.onRemove?.() + if (id) useWidgetValueStore().deleteWidget(id) + this.widgets.splice(widgetIndex, 1) + } + + ensureWidgetRemoved(widget: IBaseWidget): void { + try { + this.removeWidget(widget) + } catch (error) { + console.error('Failed to remove widget', error) + } + } + + move(deltaX: number, deltaY: number): void { + if (this.pinned) return + + refreshNodeGeometry(this) + this.pos = [this._pos[0] + deltaX, this._pos[1] + deltaY] + } + + /** + * Internal method to measure the node for rendering. Prefer {@link boundingRect} where possible. + * + * Populates {@link out} with the results in graph space. + * Populates {@link _collapsed_width} with the collapsed width if the node is collapsed. + * Adjusts for title and collapsed status, but does not call {@link onBounding}. + * @param out `x, y, width, height` are written to this array. + * @param ctx The canvas context to use for measuring text. + */ + measure(out: Rect, ctx?: CanvasRenderingContext2D): void { + const titleMode = this.title_mode + const renderTitle = + titleMode != TitleMode.TRANSPARENT_TITLE && + titleMode != TitleMode.NO_TITLE + const titleHeight = renderTitle ? LiteGraph.NODE_TITLE_HEIGHT : 0 + + out[0] = this.pos[0] + out[1] = this.pos[1] + -titleHeight + if (!this.flags?.collapsed || LiteGraph.vueNodesMode) { + const size = this.renderingSize + out[2] = size[0] + out[3] = size[1] + titleHeight + } else { + if (ctx) ctx.font = this.innerFontStyle + this._collapsed_width = Math.min( + this.size[0], + ctx + ? cachedMeasureText(ctx, this.getTitle() ?? '') + + LiteGraph.NODE_TITLE_HEIGHT * 2 + : 0 + ) + out[2] = this._collapsed_width || LiteGraph.NODE_COLLAPSED_WIDTH + out[3] = LiteGraph.NODE_TITLE_HEIGHT + } + } + + /** + * returns the bounding of the object, used for rendering purposes + * @param out {Rect?} [optional] a place to store the output, to free garbage + * @param includeExternal {boolean?} [optional] set to true to + * include the shadow and connection points in the bounding calculation + * @returns the bounding box in format of [topleft_cornerx, topleft_cornery, width, height] + */ + getBounding(out?: Rect, includeExternal?: boolean): Rect { + out ||= [0, 0, 0, 0] + + const rect = includeExternal ? this.renderArea : this.boundingRect + out[0] = rect[0] + out[1] = rect[1] + out[2] = rect[2] + out[3] = rect[3] + + return out + } + + /** + * Calculates the render area of this node, populating both {@link boundingRect} and {@link renderArea}. + * Called automatically at the start of every frame. + */ + updateArea(ctx?: CanvasRenderingContext2D): void { + const bounds = this._boundingRect + this.measure(bounds, ctx) + this.onBounding?.(bounds) + + const renderArea = this._renderArea + renderArea.set(bounds) + // 4 offset for collapsed node connection points + renderArea[0] -= 4 + renderArea[1] -= 4 + // Add shadow & left offset + renderArea[2] += 6 + 4 + // Add shadow & top offsets + renderArea[3] += 5 + 4 + } + + /** + * checks if a point is inside the shape of a node + */ + isPointInside(x: number, y: number): boolean { + if (isInRect(x, y, this.boundingRect)) return true + + for (const badge of this.badges.map(toValue).filter((b) => b.onClick)) { + if (isInRect(x - this.pos[0], y - this.pos[1], badge.boundingRect)) + return true + } + return false + } + + /** + * Checks if the provided point is inside this node's collapse button area. + * @param x X co-ordinate to check + * @param y Y co-ordinate to check + * @returns true if the x,y point is in the collapse button area, otherwise false + */ + isPointInCollapse(x: number, y: number): boolean { + const squareLength = LiteGraph.NODE_TITLE_HEIGHT + return isInRectangle( + x, + y, + this.pos[0], + this.pos[1] - squareLength, + squareLength, + squareLength + ) + } + + /** + * Returns the input slot at the given position. Uses full 20 height, and approximates the label length. + * @param pos The graph co-ordinates to check + * @returns The input slot at the given position if found, otherwise `undefined`. + */ + getInputOnPos(pos: Point): INodeInputSlot | undefined { + return getNodeInputOnPos(this, pos[0], pos[1])?.input + } + + /** + * Returns the output slot at the given position. Uses full 20x20 box for the slot. + * @param pos The graph co-ordinates to check + * @returns The output slot at the given position if found, otherwise `undefined`. + */ + getOutputOnPos(pos: Point): INodeOutputSlot | undefined { + return getNodeOutputOnPos(this, pos[0], pos[1])?.output + } + + /** + * Returns the input or output slot at the given position. + * + * Tries {@link getNodeInputOnPos} first, then {@link getNodeOutputOnPos}. + * @param pos The graph co-ordinates to check + * @returns The input or output slot at the given position if found, otherwise `undefined`. + */ + getSlotOnPos(pos: Point): INodeInputSlot | INodeOutputSlot | undefined { + if (!isPointInRect(pos, this.boundingRect)) return + + return this.getInputOnPos(pos) ?? this.getOutputOnPos(pos) + } + + /** + * @deprecated Use {@link getSlotOnPos} instead. + * checks if a point is inside a node slot, and returns info about which slot + * @param x + * @param y + * @returns if found the object contains { input|output: slot object, slot: number, link_pos: [x,y] } + */ + getSlotInPosition(x: number, y: number): IFoundSlot | null { + // search for inputs + const { inputs, outputs } = this + + if (inputs) { + for (const [i, input] of inputs.entries()) { + const pos = this.getInputPos(i) + if (isInRectangle(x, y, pos[0] - 10, pos[1] - 10, 20, 20)) { + return { input, slot: i, link_pos: pos } + } + } + } + + if (outputs) { + for (const [i, output] of outputs.entries()) { + const pos = this.getOutputPos(i) + if (isInRectangle(x, y, pos[0] - 10, pos[1] - 10, 20, 20)) { + return { output, slot: i, link_pos: pos } + } + } + } + + return null + } + + /** + * Gets the widget on this node at the given co-ordinates. + * @param canvasX X co-ordinate in graph space + * @param canvasY Y co-ordinate in graph space + * @returns The widget found, otherwise `null` + */ + getWidgetOnPos( + canvasX: number, + canvasY: number, + includeDisabled = false + ): IBaseWidget | undefined { + const { widgets, pos, size } = this + if (!widgets?.length) return + + const x = canvasX - pos[0] + const y = canvasY - pos[1] + const nodeWidth = size[0] + + for (const widget of widgets) { + if ( + (widget.computedDisabled && !includeDisabled) || + !this.isWidgetVisible(widget) + ) { + continue + } + + const h = + widget.computedHeight ?? + widget.computeSize?.(nodeWidth)[1] ?? + LiteGraph.NODE_WIDGET_HEIGHT + + const maybeDOMWidget = widget as { margin?: number } + const mtop = maybeDOMWidget.margin ?? -2 + const mbot = maybeDOMWidget.margin ?? 2 + const mx = maybeDOMWidget.margin ?? 6 + + const w = widget.width || nodeWidth + if ( + widget.last_y !== undefined && + isInRectangle( + x, + y, + mx, + widget.last_y + mtop, + w - 2 * mx, + h - mtop - mbot + ) + ) { + return widget + } + } + } + + /** + * Returns the input slot with a given name (used for dynamic slots), -1 if not found + * @param name the name of the slot to find + * @param returnObj if the obj itself wanted + * @returns the slot (-1 if not found) + */ + findInputSlot( + name: string, + returnObj?: TReturn + ): number + findInputSlot( + name: string, + returnObj?: TReturn + ): INodeInputSlot + findInputSlot(name: string, returnObj: boolean = false) { + const { inputs } = this + if (!inputs) return -1 + + for (const [i, input] of inputs.entries()) { + if (name == input.name) { + return !returnObj ? i : input + } + } + return -1 + } + + /** + * returns the output slot with a given name (used for dynamic slots), -1 if not found + * @param name the name of the slot to find + * @param returnObj if the obj itself wanted + * @returns the slot (-1 if not found) + */ + findOutputSlot( + name: string, + returnObj?: TReturn + ): number + findOutputSlot( + name: string, + returnObj?: TReturn + ): INodeOutputSlot + findOutputSlot(name: string, returnObj: boolean = false) { + const { outputs } = this + if (!outputs) return -1 + + for (const [i, output] of outputs.entries()) { + if (name == output.name) { + return !returnObj ? i : output + } + } + return -1 + } + + /** + * Finds the first free input slot. + * @param optsIn + * @returns The index of the first matching slot, the slot itself if returnObj is true, or -1 if not found. + */ + findInputSlotFree( + optsIn?: FindFreeSlotOptions & { returnObj?: TReturn } + ): number + findInputSlotFree( + optsIn?: FindFreeSlotOptions & { returnObj?: TReturn } + ): INodeInputSlot | -1 + findInputSlotFree(optsIn?: FindFreeSlotOptions) { + return this._findFreeSlot(this.inputs, true, optsIn) + } + + /** + * Finds the first free output slot. + * @param optsIn + * @returns The index of the first matching slot, the slot itself if returnObj is true, or -1 if not found. + */ + findOutputSlotFree( + optsIn?: FindFreeSlotOptions & { returnObj?: TReturn } + ): number + findOutputSlotFree( + optsIn?: FindFreeSlotOptions & { returnObj?: TReturn } + ): INodeOutputSlot | -1 + findOutputSlotFree(optsIn?: FindFreeSlotOptions) { + return this._findFreeSlot(this.outputs, false, optsIn) + } + + /** + * Finds the next free slot + * @param slots The slots to search, i.e. this.inputs or this.outputs + * @param isInput Whether {@link slots} are inputs (`true`) or outputs (`false`) + */ + private _findFreeSlot( + slots: TSlot[], + isInput: boolean, + options?: FindFreeSlotOptions + ): TSlot | number { + const defaults = { + returnObj: false, + typesNotAccepted: [] + } + const opts = Object.assign(defaults, options || {}) + const length = slots?.length + if (!(length > 0)) return -1 + + for (let i = 0; i < length; ++i) { + const slot: TSlot = slots[i] + if (!slot) continue + if (isInput ? this.isInputConnected(i) : this.isOutputConnected(i)) + continue + if (opts.typesNotAccepted?.includes?.(slot.type)) continue + return !opts.returnObj ? i : slot + } + return -1 + } + + /** + * findSlotByType for INPUTS + */ + findInputSlotByType( + type: ISlotType, + returnObj?: TReturn, + preferFreeSlot?: boolean, + doNotUseOccupied?: boolean + ): number + findInputSlotByType( + type: ISlotType, + returnObj?: TReturn, + preferFreeSlot?: boolean, + doNotUseOccupied?: boolean + ): INodeInputSlot + findInputSlotByType( + type: ISlotType, + returnObj?: boolean, + preferFreeSlot?: boolean, + doNotUseOccupied?: boolean + ) { + return this._findSlotByType( + this.inputs, + true, + type, + returnObj, + preferFreeSlot, + doNotUseOccupied + ) + } + + /** + * findSlotByType for OUTPUTS + */ + findOutputSlotByType( + type: ISlotType, + returnObj?: TReturn, + preferFreeSlot?: boolean, + doNotUseOccupied?: boolean + ): number + findOutputSlotByType( + type: ISlotType, + returnObj?: TReturn, + preferFreeSlot?: boolean, + doNotUseOccupied?: boolean + ): INodeOutputSlot + findOutputSlotByType( + type: ISlotType, + returnObj?: boolean, + preferFreeSlot?: boolean, + doNotUseOccupied?: boolean + ) { + return this._findSlotByType( + this.outputs, + false, + type, + returnObj, + preferFreeSlot, + doNotUseOccupied + ) + } + + /** + * returns the output (or input) slot with a given type, -1 if not found + * @param input use inputs instead of outputs + * @param type the type of the slot to find + * @param returnObj if the obj itself wanted + * @param preferFreeSlot if we want a free slot (if not found, will return the first of the type anyway) + * @returns the slot (-1 if not found) + */ + findSlotByType( + input: TSlot, + type: ISlotType, + returnObj?: TReturn, + preferFreeSlot?: boolean, + doNotUseOccupied?: boolean + ): number + findSlotByType( + input: TSlot, + type: ISlotType, + returnObj?: TReturn, + preferFreeSlot?: boolean, + doNotUseOccupied?: boolean + ): INodeInputSlot | -1 + findSlotByType( + input: TSlot, + type: ISlotType, + returnObj?: TReturn, + preferFreeSlot?: boolean, + doNotUseOccupied?: boolean + ): INodeOutputSlot | -1 + findSlotByType( + input: boolean, + type: ISlotType, + returnObj?: boolean, + preferFreeSlot?: boolean, + doNotUseOccupied?: boolean + ): number | INodeOutputSlot | INodeInputSlot { + return input + ? this._findSlotByType( + this.inputs, + true, + type, + returnObj, + preferFreeSlot, + doNotUseOccupied + ) + : this._findSlotByType( + this.outputs, + false, + type, + returnObj, + preferFreeSlot, + doNotUseOccupied + ) + } + + /** + * Finds a matching slot from those provided, returning the slot itself or its index in {@link slots}. + * @param slots Slots to search (this.inputs or this.outputs) + * @param isInput Whether {@link slots} are inputs (`true`) or outputs (`false`) + * @param type Type of slot to look for + * @param returnObj If true, returns the slot itself. Otherwise, the index. + * @param preferFreeSlot Prefer a free slot, but if none are found, fall back to an occupied slot. + * @param doNotUseOccupied Do not fall back to occupied slots. + * @see {findSlotByType} + * @see {findOutputSlotByType} + * @see {findInputSlotByType} + * @returns If a match is found, the slot if returnObj is true, otherwise the index. If no matches are found, -1 + */ + private _findSlotByType( + slots: TSlot[], + isInput: boolean, + type: ISlotType, + returnObj?: boolean, + preferFreeSlot?: boolean, + doNotUseOccupied?: boolean + ): TSlot | number { + const length = slots?.length + if (!length) return -1 + + // Empty string and * match anything (type: 0) + if (type == '' || type == '*') type = 0 + const sourceTypes = String(type).toLowerCase().split(',') + + // Run the search + let occupiedSlot: number | TSlot | null = null + for (let i = 0; i < length; ++i) { + const slot: TSlot = slots[i] + const destTypes = + slot.type == '0' || slot.type == '*' + ? ['0'] + : String(slot.type).toLowerCase().split(',') + + for (const sourceType of sourceTypes) { + // TODO: Remove _event_ entirely. + const source = sourceType == '_event_' ? LiteGraph.EVENT : sourceType + + for (const destType of destTypes) { + const dest = destType == '_event_' ? LiteGraph.EVENT : destType + + if (source == dest || source === '*' || dest === '*') { + if ( + preferFreeSlot && + (isInput ? this.isInputConnected(i) : this.isOutputConnected(i)) + ) { + // In case we can't find a free slot. + occupiedSlot ??= returnObj ? slot : i + continue + } + return returnObj ? slot : i + } + } + } + } + + return doNotUseOccupied ? -1 : (occupiedSlot ?? -1) + } + + /** + * Determines the slot index to connect to when attempting to connect by type. + * @param findInputs If true, searches for an input. Otherwise, an output. + * @param node The node at the other end of the connection. + * @param slotType The type of slot at the other end of the connection. + * @param options Search restrictions to adhere to. + * @see {connectByType} + * @see {connectByTypeOutput} + */ + findConnectByTypeSlot( + findInputs: boolean, + node: LGraphNode, + slotType: ISlotType, + options?: ConnectByTypeOptions + ): number | undefined { + // LEGACY: Old options names + if (options && typeof options === 'object') { + if ('firstFreeIfInputGeneralInCase' in options) + options.wildcardToTyped = !!options.firstFreeIfInputGeneralInCase + if ('firstFreeIfOutputGeneralInCase' in options) + options.wildcardToTyped = !!options.firstFreeIfOutputGeneralInCase + if ('generalTypeInCase' in options) + options.typedToWildcard = !!options.generalTypeInCase + } + const optsDef: ConnectByTypeOptions = { + createEventInCase: true, + wildcardToTyped: true, + typedToWildcard: true + } + const opts = Object.assign(optsDef, options) + + if (!this.graph) throw new NullGraphError() + + if (node && typeof node === 'number') { + const nodeById = this.graph.getNodeById(node) + if (!nodeById) return + + node = nodeById + } + const slot = node.findSlotByType(findInputs, slotType, false, true) + if (slot >= 0 && slot !== null) return slot + + // TODO: Remove or reimpl. events. WILL CREATE THE onTrigger IN SLOT + if (opts.createEventInCase && slotType == LiteGraph.EVENT) { + if (findInputs) return -1 + if (LiteGraph.do_add_triggers_slots) return node.addOnExecutedOutput() + } + + // connect to the first general output slot if not found a specific type and + if (opts.typedToWildcard) { + const generalSlot = node.findSlotByType(findInputs, 0, false, true, true) + if (generalSlot >= 0) return generalSlot + } + // connect to the first free input slot if not found a specific type and this output is general + if ( + opts.wildcardToTyped && + (slotType == 0 || slotType == '*' || slotType == '') + ) { + const opt = { typesNotAccepted: [LiteGraph.EVENT] } + const nonEventSlot = findInputs + ? node.findInputSlotFree(opt) + : node.findOutputSlotFree(opt) + if (nonEventSlot >= 0) return nonEventSlot + } + } + + /** + * Finds the first free output slot with any of the comma-delimited types in {@link type}. + * + * If no slots are free, falls back in order to: + * - The first free wildcard slot + * - The first occupied slot + * - The first occupied wildcard slot + * @param type The {@link ISlotType type} of slot to find + * @returns The index and slot if found, otherwise `undefined`. + */ + findOutputByType( + type: ISlotType + ): { index: number; slot: INodeOutputSlot } | undefined { + return findFreeSlotOfType( + this.outputs, + type, + (_output, index) => + !this.graph || !outputHasLinks(this.graph, this.id, index) + ) + } + + /** + * Finds the first free input slot with any of the comma-delimited types in {@link type}. + * + * If no slots are free, falls back in order to: + * - The first free wildcard slot + * - The first occupied slot + * - The first occupied wildcard slot + * @param type The {@link ISlotType type} of slot to find + * @returns The index and slot if found, otherwise `undefined`. + */ + findInputByType( + type: ISlotType + ): { index: number; slot: INodeInputSlot } | undefined { + return findFreeSlotOfType(this.inputs, type, (_input, index) => { + if (!this.graph) return true + const link = inputLink(this.graph, this.id, index) + return link == null || !!link._dragging + }) + } + + /** + * connect this node output to the input of another node BY TYPE + * @param slot (could be the number of the slot or the string with the name of the slot) + * @param target_node the target node + * @param target_slotType the input slot type of the target node + * @returns the link_info is created, otherwise null + */ + connectByType( + slot: number | string, + target_node: LGraphNode, + target_slotType: ISlotType, + optsIn?: ConnectByTypeOptions + ): LLink | null { + const slotIndex = this.findConnectByTypeSlot( + true, + target_node, + target_slotType, + optsIn + ) + if (slotIndex !== undefined) + return this.connect(slot, target_node, slotIndex, optsIn?.afterRerouteId) + + // No compatible slot found - connection not possible + return null + } + + /** + * connect this node input to the output of another node BY TYPE + * @param slot (could be the number of the slot or the string with the name of the slot) + * @param source_node the target node + * @param source_slotType the output slot type of the target node + * @returns the link_info is created, otherwise null + */ + connectByTypeOutput( + slot: number | string, + source_node: LGraphNode, + source_slotType: ISlotType, + optsIn?: ConnectByTypeOptions + ): LLink | null { + // LEGACY: Old options names + if (typeof optsIn === 'object') { + if ('firstFreeIfInputGeneralInCase' in optsIn) + optsIn.wildcardToTyped = !!optsIn.firstFreeIfInputGeneralInCase + if ('generalTypeInCase' in optsIn) + optsIn.typedToWildcard = !!optsIn.generalTypeInCase + } + const slotIndex = this.findConnectByTypeSlot( + false, + source_node, + source_slotType, + optsIn + ) + if (slotIndex !== undefined) + return source_node.connect(slotIndex, this, slot, optsIn?.afterRerouteId) + + console.error( + '[connectByType]: no way to connect type:', + source_slotType, + 'to node:', + source_node + ) + return null + } + + canConnectTo( + node: NodeLike, + toSlot: INodeInputSlot | SubgraphIO, + fromSlot: INodeOutputSlot | SubgraphIO + ) { + return ( + this.id !== node.id && + LiteGraph.isValidConnection(fromSlot.type, toSlot.type) + ) + } + + /** + * Connect an output of this node to an input of another node + * @param slot (could be the number of the slot or the string with the name of the slot) + * @param target_node the target node + * @param target_slot the input slot of the target node (could be the number of the slot or the string with the name of the slot, or -1 to connect a trigger) + * @returns the link_info is created, otherwise null + */ + connect( + slot: number | string, + target_node: LGraphNode, + target_slot: ISlotType, + afterRerouteId?: RerouteId + ): LLink | null { + // Allow legacy API support for searching target_slot by string, without mutating the input variables + let targetIndex: number | null + + const { graph, outputs } = this + if (!graph) { + // could be connected before adding it to a graph + // due to link ids being associated with graphs + console.error( + "Connect: Error, node doesn't belong to any graph. Nodes must be added first to a graph before connecting them." + ) + return null + } + + // seek for the output slot + if (typeof slot === 'string') { + slot = this.findOutputSlot(slot) + if (slot == -1) { + if (LiteGraph.debug) + console.error(`Connect: Error, no slot of name ${slot}`) + return null + } + } else if (!outputs || slot >= outputs.length) { + if (LiteGraph.debug) + console.error('Connect: Error, slot number not found') + return null + } + + if (target_node && typeof target_node === 'number') { + const nodeById = graph.getNodeById(target_node) + if (!nodeById) throw 'target node is null' + + target_node = nodeById + } + if (!target_node) throw 'target node is null' + + // avoid loopback + if (target_node == this) return null + + // you can specify the slot by name + if (typeof target_slot === 'string') { + targetIndex = target_node.findInputSlot(target_slot) + if (targetIndex == -1) { + if (LiteGraph.debug) + console.error(`Connect: Error, no slot of name ${targetIndex}`) + return null + } + } else if (target_slot === LiteGraph.EVENT) { + // TODO: Events + if (LiteGraph.do_add_triggers_slots) { + target_node.changeMode(LGraphEventMode.ON_TRIGGER) + targetIndex = target_node.findInputSlot('onTrigger') + } else { + return null + } + } else if (typeof target_slot === 'number') { + targetIndex = target_slot + } else { + targetIndex = 0 + } + + // Allow target node to change slot + if (target_node.onBeforeConnectInput) { + // This way node can choose another slot (or make a new one?) + const requestedIndex = target_node.onBeforeConnectInput( + targetIndex, + target_slot + ) + targetIndex = typeof requestedIndex === 'number' ? requestedIndex : null + } + + if ( + targetIndex === null || + !target_node.inputs || + targetIndex >= target_node.inputs.length + ) { + if (LiteGraph.debug) + console.error('Connect: Error, slot number not found') + return null + } + + const input = target_node.inputs[targetIndex] + const output = outputs[slot] + + if (!output) return null + + if (outputHasLinks(graph, this.id, slot)) { + if ( + output.type === LiteGraph.EVENT && + !LiteGraph.allow_multi_output_for_events + ) { + graph.beforeChange() + this.disconnectOutput(slot) + } + } + + const link = this.connectSlots(output, target_node, input, afterRerouteId) + return link ?? null + } + + /** + * Connect two slots between two nodes + * @param output The output slot to connect + * @param inputNode The node that the input slot is on + * @param input The input slot to connect + * @param afterRerouteId The reroute ID to use for the link + * @returns The link that was created, or null if the connection was blocked + */ + connectSlots( + output: INodeOutputSlot, + inputNode: LGraphNode, + input: INodeInputSlot, + afterRerouteId: RerouteId | undefined + ): LLink | null | undefined { + const { graph } = this + if (!graph) throw new NullGraphError() + + const outputIndex = this.outputs.indexOf(output) + if (outputIndex === -1) { + console.warn('connectSlots: output not found') + return + } + const inputIndex = inputNode.inputs.indexOf(input) + if (inputIndex === -1) { + console.warn('connectSlots: input not found') + return + } + + // check targetSlot and check connection types + if (!LiteGraph.isValidConnection(output.type, input.type)) { + this.setDirtyCanvas(false, true) + return null + } + + // Allow nodes to block connection + if ( + inputNode.onConnectInput?.( + inputIndex, + output.type, + output, + this, + outputIndex + ) === false + ) + return null + if ( + this.onConnectOutput?.( + outputIndex, + input.type, + input, + inputNode, + inputIndex + ) === false + ) + return null + + const replacingLink = inputLink(graph, inputNode.id, inputIndex) + if (replacingLink) { + graph.beforeChange() + } + + const maybeCommonType = + input.type && output.type && commonType(input.type, output.type) + + const linkId = mintLinkId(graph.state) + + const link = new LLink( + linkId, + maybeCommonType || input.type || output.type, + this.id, + outputIndex, + inputNode.id, + inputIndex, + afterRerouteId + ) + + if (!replaceLinkTopology(graph, replacingLink, link)) { + if (replacingLink) graph.afterChange() + return + } + + if (replacingLink) { + finalizeInputLinkRemoval( + inputNode, + input, + inputIndex, + replacingLink, + true, + afterRerouteId + ) + if (graph.getLink(link.id) !== link) { + graph.afterChange() + return + } + } + + anchorRerouteChain(graph, link) + graph.incrementVersion() + + // link has been created now, so its updated + this.onConnectionsChange?.( + NodeSlotType.OUTPUT, + outputIndex, + true, + link, + output + ) + if (graph.getLink(link.id) !== link) { + graph.afterChange() + return + } + + inputNode.onConnectionsChange?.( + NodeSlotType.INPUT, + inputIndex, + true, + link, + input + ) + if (graph.getLink(link.id) !== link) { + graph.afterChange() + return + } + + this.setDirtyCanvas(false, true) + graph.afterChange() + + return link + } + + connectFloatingReroute( + pos: Point, + slot: INodeInputSlot | INodeOutputSlot, + afterRerouteId?: RerouteId + ): Reroute | undefined { + const { graph, id } = this + if (!graph) throw new NullGraphError() + + // Assertion: It's either there or it isn't. + const inputIndex = this.inputs.indexOf(slot as INodeInputSlot) + const outputIndex = this.outputs.indexOf(slot as INodeOutputSlot) + if (inputIndex === -1 && outputIndex === -1) { + console.error('Invalid slot') + return + } + + const slotType = outputIndex === -1 ? 'input' : 'output' + + const reroute = graph.setReroute({ + pos, + parentId: afterRerouteId, + linkIds: [], + floating: { slotType } + }) + if (!reroute) return + + const parentReroute = graph.getReroute(afterRerouteId) + const fromLastFloatingReroute = + parentReroute?.floating?.slotType === 'output' + + // Adding from an output, or a floating reroute that is NOT the tip of an existing floating chain + if (afterRerouteId == null || !fromLastFloatingReroute) { + const link = new LLink( + toLinkId(-1), + slot.type, + outputIndex === -1 ? -1 : id, + outputIndex, + inputIndex === -1 ? -1 : id, + inputIndex + ) + link.parentId = reroute.id + graph.addFloatingLink(link) + return reroute + } + + // Adding a new floating reroute from the tip of a floating chain. + if (!parentReroute) + throw new Error('[connectFloatingReroute] Parent reroute not found') + + const link = parentReroute.getFloatingLinks('output')?.[0] + if (!link) + throw new Error('[connectFloatingReroute] Floating link not found') + + link.parentId = reroute.id + parentReroute.floating = undefined + return reroute + } + + /** + * disconnect one output to an specific node + * @param slot (could be the number of the slot or the string with the name of the slot) + * @param target_node the target node to which this slot is connected [Optional, + * if not target_node is specified all nodes will be disconnected] + * @returns if it was disconnected successfully + */ + disconnectOutput(slot: string | number, target_node?: LGraphNode): boolean { + if (typeof slot === 'string') { + slot = this.findOutputSlot(slot) + if (slot == -1) { + if (LiteGraph.debug) + console.error(`Connect: Error, no slot of name ${slot}`) + return false + } + } else if (!this.outputs || slot >= this.outputs.length) { + if (LiteGraph.debug) + console.error('Connect: Error, slot number not found') + return false + } + + // get output slot + const output = this.outputs[slot] + if (!output) return false + + let removedFloating = false + if (!target_node && this.graph) { + for (const link of slotFloatingLinks( + this.graph, + 'output', + this.id, + slot + )) { + this.graph.removeFloatingLink(link) + removedFloating = true + } + } + + const graph = this.graph + if (!graph) return false + if (!outputHasLinks(graph, this.id, slot) && !removedFloating) return false + + const onlyTarget = + typeof target_node === 'number' + ? graph.getNodeById(target_node) + : target_node + if (target_node && !onlyTarget) throw 'Target Node not found' + let disconnected = false + for (const link_info of outputLinks(graph, this.id, slot)) { + if (onlyTarget && link_info.target_id != onlyTarget.id) continue + + if (!disconnected && output instanceof NodeOutputSlot) { + output._setLegacyLinksPresent(Boolean(onlyTarget)) + } + disconnected = true + + if ( + link_info.target_id === SUBGRAPH_OUTPUT_ID && + graph instanceof Subgraph + ) { + const targetSlot = graph.outputNode.slots[link_info.target_slot] + if (targetSlot) { + targetSlot.linkIds.length = 0 + } else { + console.error('Missing subgraphOutput slot when disconnecting link') + } + } + + const target = graph.getNodeById(link_info.target_id) + const input = target?.inputs[link_info.target_slot] + + link_info.disconnect(graph, 'input') + graph.incrementVersion() + + if (target && input) { + target.onConnectionsChange?.( + NodeSlotType.INPUT, + link_info.target_slot, + false, + link_info, + input + ) + } + this.onConnectionsChange?.( + NodeSlotType.OUTPUT, + slot, + false, + link_info, + output + ) + + if (onlyTarget) break + } + + if (!disconnected && !removedFloating) return false + + this.setDirtyCanvas(false, true) + return true + } + + /** + * Disconnect one input + * @param slot Input slot index, or the name of the slot + * @param keepReroutes If `true`, reroutes will not be garbage collected. + * @param keepFloatingReroute Floating link(s) parented to this reroute are left + * intact, so a chain being reconnected is not pruned before its new link exists. + * @returns true if disconnected successfully or already disconnected, otherwise false + */ + disconnectInput( + slot: number | string, + keepReroutes?: boolean, + keepFloatingReroute?: RerouteId + ): boolean { + // Allow search by string + if (typeof slot === 'string') { + slot = this.findInputSlot(slot) + if (slot == -1) { + if (LiteGraph.debug) + console.error(`Connect: Error, no slot of name ${slot}`) + return false + } + } else if (!this.inputs || slot >= this.inputs.length) { + if (LiteGraph.debug) { + console.error('Connect: Error, slot number not found') + } + return false + } + + const input = this.inputs[slot] + if (!input) { + console.error('disconnectInput: input not found', slot, this.inputs) + return false + } + + const { graph } = this + if (!graph) throw new NullGraphError() + + // Break floating links, except the one whose reroute chain is being + // reconnected (its reroute would be pruned before the new link is added). + for (const link of slotFloatingLinks(graph, 'input', this.id, slot)) { + if ( + keepFloatingReroute !== undefined && + link.parentId === keepFloatingReroute + ) + continue + graph.removeFloatingLink(link) + } + + const link_id = inputLinkId(graph, this.id, slot) ?? null + if (link_id !== null) { + // remove other side + const link_info = graph.links.get(link_id) + if (link_info) { + // Let SubgraphInput do the disconnect. + if (link_info.origin_id === SUBGRAPH_INPUT_ID && 'inputNode' in graph) { + graph.inputNode._disconnectNodeInput(this, input, link_info) + return true + } + + const target_node = graph.getNodeById(link_info.origin_id) + if (!target_node) { + console.error( + 'disconnectInput: output not found', + link_info.origin_slot + ) + return false + } + + const output = target_node.outputs[link_info.origin_slot] + if (!output) { + // Output not found - may have been removed + return false + } + + link_info.disconnect(graph, keepReroutes ? 'output' : undefined) + if (graph) graph.incrementVersion() + + this.onConnectionsChange?.( + NodeSlotType.INPUT, + slot, + false, + link_info, + input + ) + target_node.onConnectionsChange?.( + NodeSlotType.OUTPUT, + link_info.origin_slot, + false, + link_info, + output + ) + } + } + + this.setDirtyCanvas(false, true) + return true + } + + /** + * @deprecated Use {@link getInputPos} or {@link getOutputPos} instead. + * returns the center of a connection point in canvas coords + * @param is_input true if if a input slot, false if it is an output + * @param slot_number (could be the number of the slot or the string with the name of the slot) + * @param out [optional] a place to store the output, to free garbage + * @returns the position + */ + getConnectionPos(is_input: boolean, slot_number: number, out?: Point): Point { + out ||= [0, 0] + + const { + pos: [nodeX, nodeY], + inputs, + outputs + } = this + + if (this.flags.collapsed) { + const w = this.renderingSize[0] + out[0] = is_input ? nodeX : nodeX + w + out[1] = nodeY - LiteGraph.NODE_TITLE_HEIGHT * 0.5 + return out + } + + // weird feature that never got finished + if (is_input && slot_number == -1) { + out[0] = nodeX + LiteGraph.NODE_TITLE_HEIGHT * 0.5 + out[1] = nodeY + LiteGraph.NODE_TITLE_HEIGHT * 0.5 + return out + } + + // hard-coded pos + const inputPos = inputs?.[slot_number]?.pos + const outputPos = outputs?.[slot_number]?.pos + + if (is_input && inputPos) { + out[0] = nodeX + inputPos[0] + out[1] = nodeY + inputPos[1] + return out + } else if (!is_input && outputPos) { + out[0] = nodeX + outputPos[0] + out[1] = nodeY + outputPos[1] + return out + } + + // default vertical slots + const offset = LiteGraph.NODE_SLOT_HEIGHT * 0.5 + const slotIndex = is_input + ? this._defaultVerticalInputs.indexOf(this.inputs[slot_number]) + : this._defaultVerticalOutputs.indexOf(this.outputs[slot_number]) + + out[0] = is_input + ? nodeX + offset + : nodeX + this.renderingSize[0] + 1 - offset + out[1] = + nodeY + + (slotIndex + 0.7) * LiteGraph.NODE_SLOT_HEIGHT + + (this.constructor.slot_start_y || 0) + return out + } + + /** + * @internal The inputs that are not positioned with absolute coordinates. + */ + private get _defaultVerticalInputs() { + return this.inputs.filter( + (slot) => !slot.pos && !(this.widgets?.length && isWidgetInputSlot(slot)) + ) + } + + /** + * @internal The outputs that are not positioned with absolute coordinates. + */ + private get _defaultVerticalOutputs() { + return this.outputs.filter((slot: INodeOutputSlot) => !slot.pos) + } + + /** + * Get the context needed for slot position calculations + * @internal + */ + private _getSlotPositionContext(): SlotPositionContext { + const size = this.renderingSize + return { + nodeX: this.pos[0], + nodeY: this.pos[1], + nodeWidth: size[0], + nodeHeight: size[1], + collapsed: this.flags.collapsed ?? false, + collapsedWidth: this._collapsed_width, + slotStartY: this.constructor.slot_start_y, + inputs: this.inputs, + outputs: this.outputs, + widgets: this.widgets + } + } + + /** + * Gets the position of an input slot, in graph co-ordinates. + * + * This method is preferred over the legacy {@link getConnectionPos} method. + * @param slot Input slot index + * @returns Position of the input slot + */ + getInputPos(slot: number): Point { + return getSlotPosition(this, slot, true) + } + + /** + * Gets the position of an input slot, in graph co-ordinates. + * @param input The actual node input object + * @returns Position of the centre of the input slot in graph co-ordinates. + */ + getInputSlotPos(input: INodeInputSlot): Point { + return calculateInputSlotPosFromSlot( + this._getSlotPositionContext(), + resolveInputSlotView(this.inputs, input) + ) + } + + /** + * Gets the position of an output slot, in graph co-ordinates. + * + * This method is preferred over the legacy {@link getConnectionPos} method. + * @param outputSlotIndex Output slot index + * @returns Position of the output slot + */ + getOutputPos(outputSlotIndex: SlotIndex): Point { + return getSlotPosition(this, outputSlotIndex, false) + } + + /** + * Get slot position using layout tree if available, fallback to node's position * Unified implementation used by both LitegraphLinkAdapter and useLinkLayoutSync + * @param slotIndex The slot index + * @param isInput Whether this is an input slot + * @returns Position of the slot center in graph coordinates + */ + getSlotPosition(slotIndex: number, isInput: boolean): Point { + return getSlotPosition(this, slotIndex, isInput) + } + + /** @inheritdoc */ + snapToGrid(snapTo: number): boolean { + if (this.pinned || !snapTo) return false + + refreshNodeGeometry(this) + const snapped: Point = [this._pos[0], this._pos[1]] + snapPoint(snapped, snapTo) + if (snapped[0] === this._pos[0] && snapped[1] === this._pos[1]) return false + + this.pos = snapped + return true + } + + /** @see {@link snapToGrid} */ + alignToGrid(): void { + this.snapToGrid(LiteGraph.CANVAS_GRID_SIZE) + } + + /* Console output */ + trace(msg: string): void { + this.console ||= [] + this.console.push(msg) + // @ts-expect-error deprecated + if (this.console.length > LGraphNode.MAX_CONSOLE) this.console.shift() + } + + /* Forces to redraw or the main canvas (LGraphNode) or the bg canvas (links) */ + setDirtyCanvas(dirty_foreground: boolean, dirty_background?: boolean): void { + this.graph?.canvasAction((c) => + c.setDirty(dirty_foreground, dirty_background) + ) + } + + loadImage(url: string): HTMLImageElement { + interface AsyncImageElement extends HTMLImageElement { + ready?: boolean + } + + const img: AsyncImageElement = new Image() + img.src = LiteGraph.node_images_path + url + img.ready = false + + const dirty = () => this.setDirtyCanvas(true) + img.addEventListener('load', function (this: AsyncImageElement) { + this.ready = true + dirty() + }) + return img + } + + /** + * Allows to get onMouseMove and onMouseUp events even if the mouse is out of focus + * @deprecated Use {@link LGraphCanvas.pointer} instead. + */ + captureInput(v: boolean): void { + warnDeprecated( + '[DEPRECATED] captureInput will be removed in a future version. Please use LGraphCanvas.pointer (CanvasPointer) instead.' + ) + if (!this.graph || !this.graph.list_of_graphcanvas) return + + const list = this.graph.list_of_graphcanvas + + for (const c of list) { + // releasing somebody elses capture?! + if (!v && c.node_capturing_input != this) continue + + // change + c.node_capturing_input = v ? this : null + } + } + + get collapsed() { + return !!this.flags.collapsed + } + + get collapsible() { + return !this.pinned && this.constructor.collapsable !== false + } + + /** + * Toggle node collapse (makes it smaller on the canvas) + */ + collapse(force?: boolean): void { + if (!this.collapsible && !force) return + if (!this.graph) throw new NullGraphError() + this.graph.incrementVersion() + this.flags.collapsed = !this.flags.collapsed + this.setDirtyCanvas(true, true) + } + + /** + * Toggles advanced mode of the node, showing advanced widgets + */ + toggleAdvanced() { + if (!this.hasAdvancedWidgets()) return + if (!this.graph) throw new NullGraphError() + this.graph.incrementVersion() + this.showAdvanced = !this.showAdvanced + this.expandToFitContent() + this.setDirtyCanvas(true, true) + } + + get pinned() { + return !!this.flags.pinned + } + + /** + * Prevents the node being accidentally moved or resized by mouse interaction. + * Toggles pinned state if no value is provided. + */ + pin(v?: boolean): void { + if (!this.graph) throw new NullGraphError() + + this.graph.incrementVersion() + this.flags.pinned = v ?? !this.flags.pinned + this.resizable = !this.pinned + if (!this.pinned) this.flags.pinned = undefined + } + + unpin(): void { + this.pin(false) + } + + localToScreen(x: number, y: number, dragAndScale: DragAndScale): Point { + return [ + (x + this.pos[0]) * dragAndScale.scale + dragAndScale.offset[0], + (y + this.pos[1]) * dragAndScale.scale + dragAndScale.offset[1] + ] + } + + get width() { + return this.renderingSize[0] + } + + /** + * Returns the height of the node, including the title bar. + */ + get height() { + return LiteGraph.NODE_TITLE_HEIGHT + this.bodyHeight + } + + /** + * Returns the height of the node, excluding the title bar. + */ + get bodyHeight() { + return this.collapsed ? 0 : this.renderingSize[1] + } + + drawBadges(ctx: CanvasRenderingContext2D, { gap = 2 } = {}): void { + const badgeInstances = [ + ...badgeDrawObjects(this, badgeRows(this)), + ...this.badges.map((badge) => + badge instanceof LGraphBadge ? badge : badge() + ) + ] + + let currentX = + this.width - + badgeInstances.reduce((acc, badge) => acc + badge.getWidth(ctx) + gap, 0) + const y = -(LiteGraph.NODE_TITLE_HEIGHT + gap) + + for (const badge of badgeInstances) { + badge.draw(ctx, currentX, y - badge.height) + currentX += badge.getWidth(ctx) + gap + } + } + + /** + * Renders the node's title bar background + */ + drawTitleBarBackground( + ctx: CanvasRenderingContext2D, + { + scale, + title_height = LiteGraph.NODE_TITLE_HEIGHT, + low_quality = false + }: DrawTitleOptions + ): void { + const fgcolor = this.renderingColor + const shape = this.renderingShape + const size = this.renderingSize + + if (this.onDrawTitleBar) { + this.onDrawTitleBar(ctx, title_height, size, scale, fgcolor) + return + } + + if (this.title_mode === TitleMode.TRANSPARENT_TITLE) { + return + } + + if (this.collapsed) { + ctx.shadowColor = LiteGraph.DEFAULT_SHADOW_COLOR + } + + ctx.fillStyle = this.constructor.title_color || fgcolor + ctx.beginPath() + + if (shape == RenderShape.BOX || low_quality) { + ctx.rect(0, -title_height, size[0], title_height) + } else if (shape == RenderShape.ROUND || shape == RenderShape.CARD) { + ctx.roundRect( + 0, + -title_height, + size[0], + title_height, + this.collapsed + ? [LiteGraph.ROUND_RADIUS] + : [LiteGraph.ROUND_RADIUS, LiteGraph.ROUND_RADIUS, 0, 0] + ) + } + ctx.fill() + ctx.shadowColor = 'transparent' + } + + /** + * Renders the node's title box, i.e. the dot in front of the title text that + * when clicked toggles the node's collapsed state. The term `title box` comes + * from the original LiteGraph implementation. + */ + drawTitleBox( + ctx: CanvasRenderingContext2D, + { + scale, + low_quality = false, + title_height = LiteGraph.NODE_TITLE_HEIGHT, + box_size = 10 + }: DrawTitleBoxOptions + ): void { + const size = this.renderingSize + const shape = this.renderingShape + + if (this.onDrawTitleBox) { + this.onDrawTitleBox(ctx, title_height, size, scale) + return + } + + if ( + [RenderShape.ROUND, RenderShape.CIRCLE, RenderShape.CARD].includes(shape) + ) { + if (low_quality) { + ctx.fillStyle = 'black' + ctx.beginPath() + ctx.arc( + title_height * 0.5, + title_height * -0.5, + box_size * 0.5 + 1, + 0, + Math.PI * 2 + ) + ctx.fill() + } + + ctx.fillStyle = this.renderingBoxColor + if (low_quality) { + ctx.fillRect( + title_height * 0.5 - box_size * 0.5, + title_height * -0.5 - box_size * 0.5, + box_size, + box_size + ) + } else { + ctx.beginPath() + ctx.arc( + title_height * 0.5, + title_height * -0.5, + box_size * 0.5, + 0, + Math.PI * 2 + ) + ctx.fill() + } + } else { + if (low_quality) { + ctx.fillStyle = 'black' + ctx.fillRect( + (title_height - box_size) * 0.5 - 1, + (title_height + box_size) * -0.5 - 1, + box_size + 2, + box_size + 2 + ) + } + ctx.fillStyle = this.renderingBoxColor + ctx.fillRect( + (title_height - box_size) * 0.5, + (title_height + box_size) * -0.5, + box_size, + box_size + ) + } + } + + /** + * Renders the node's title text. + */ + drawTitleText( + ctx: CanvasRenderingContext2D, + { + scale, + default_title_color, + low_quality = false, + title_height = LiteGraph.NODE_TITLE_HEIGHT + }: DrawTitleTextOptions + ): void { + const size = this.renderingSize + const selected = this.selected + + if (this.onDrawTitleText) { + this.onDrawTitleText( + ctx, + title_height, + size, + scale, + this.titleFontStyle, + selected + ) + return + } + + // Don't render title text if low quality + if (low_quality) { + return + } + + ctx.font = this.titleFontStyle + const rawTitle = this.getTitle() ?? `❌ ${this.type}` + const title = String(rawTitle) + (this.pinned ? '📌' : '') + if (title) { + if (selected) { + ctx.fillStyle = LiteGraph.NODE_SELECTED_TITLE_COLOR + } else { + ctx.fillStyle = this.constructor.title_text_color || default_title_color + } + + // Calculate available width for title + let availableWidth = size[0] - title_height * 2 // Basic margins + + // Subtract space for title buttons + if (this.title_buttons?.length > 0) { + let buttonsWidth = 0 + const savedFont = ctx.font // Save current font + for (const button of this.title_buttons) { + if (button.visible) { + buttonsWidth += button.getWidth(ctx) + 2 // button width + gap + } + } + ctx.font = savedFont // Restore font after button measurements + if (buttonsWidth > 0) { + buttonsWidth -= 20 // Reduce by empty padding + availableWidth -= buttonsWidth + } + } + + // Truncate title if needed + let displayTitle = title + + if (this.collapsed) { + // For collapsed nodes, limit to 20 chars as before + displayTitle = title.substr(0, 20) + } else if (availableWidth > 0) { + // For regular nodes, truncate based on available width + displayTitle = truncateText(ctx, title, availableWidth) + } + + ctx.textAlign = 'left' + ctx.fillText( + displayTitle, + title_height, + LiteGraph.NODE_TITLE_TEXT_Y - title_height + ) + } + } + + /** + * Attempts to gracefully bypass this node in all of its connections by reconnecting all links. + * + * Each input is checked against each output. This is done on a matching index basis, i.e. input 3 -> output 3. + * If there are any input links remaining, + * and {@link flags}.{@link INodeFlags.keepAllLinksOnBypass keepAllLinksOnBypass} is `true`, + * each input will check for outputs that match, and take the first one that matches + * `true`: Try the index matching first, then every input to every output. + * `false`: Only matches indexes, e.g. input 3 to output 3. + * + * If {@link flags}.{@link INodeFlags.keepAllLinksOnBypass keepAllLinksOnBypass} is `undefined`, it will fall back to + * the static {@link keepAllLinksOnBypass}. + * @returns `true` if any new links were established, otherwise `false`. + * @todo Decision: Change API to return array of new links instead? + */ + connectInputToOutput(): boolean | undefined { + const { inputs, outputs, graph } = this + if (!inputs || !outputs) return + if (!graph) throw new NullGraphError() + + const nodeId = this.id + let madeAnyConnections = false + + // First pass: only match exactly index-to-index + for (const [index, input] of inputs.entries()) { + const output = outputs[index] + if (!output || !LiteGraph.isValidConnection(input.type, output.type)) + continue + + const inLink = inputLink(graph, nodeId, index) + if (!inLink) continue + const inNode = graph.getNodeById(inLink?.origin_id) + if (!inNode) continue + + bypassAllLinks(index, inNode, inLink, graph) + } + // Configured to only use index-to-index matching + if (!(this.flags.keepAllLinksOnBypass ?? LGraphNode.keepAllLinksOnBypass)) + return madeAnyConnections + + // Second pass: match any remaining links + for (const [inputIndex, input] of inputs.entries()) { + const inLink = inputLink(graph, nodeId, inputIndex) + if (!inLink) continue + const inNode = graph.getNodeById(inLink?.origin_id) + if (!inNode) continue + + for (const [outIndex, output] of outputs.entries()) { + if (!LiteGraph.isValidConnection(input.type, output.type)) continue + + bypassAllLinks(outIndex, inNode, inLink, graph) + break + } + } + return madeAnyConnections + + function bypassAllLinks( + outputIndex: number, + inNode: LGraphNode, + inLink: LLink, + graph: LGraph + ) { + const outLinks = outputLinks(graph, nodeId, outputIndex) + if (!outLinks.length) return + + for (const outLink of outLinks) { + const outNode = graph.getNodeById(outLink.target_id) + if (!outNode) continue + + const result = inNode.connect( + inLink.origin_slot, + outNode, + outLink.target_slot, + inLink.parentId + ) + madeAnyConnections ||= !!result + } + } + } + + /** + * Returns `true` if the widget is visible, otherwise `false`. + */ + isWidgetVisible(widget: IBaseWidget): boolean { + const isHidden = + this.collapsed || widget.hidden || (widget.advanced && !this.showAdvanced) + return !isHidden + } + + /** + * Returns all widgets that should participate in layout calculations. + * Filters out hidden widgets only (not collapsed/advanced). + */ + getLayoutWidgets(): IBaseWidget[] { + return this.widgets?.filter((w) => !w.hidden) ?? [] + } + + /** + * Returns `true` if the node has any advanced widgets. + */ + hasAdvancedWidgets(): boolean { + return this.widgets?.some((w) => w.advanced) ?? false + } + + updateComputedDisabled() { + if (!this.widgets) return + for (const widget of this.widgets) { + const slot = this.getSlotFromWidget(widget) + widget.computedDisabled = + widget.disabled || + (!!slot && this.isInputConnected(this.inputs.indexOf(slot))) + } + } + + drawWidgets( + ctx: CanvasRenderingContext2D, + { lowQuality = false, editorAlpha = 1 }: DrawWidgetsOptions + ): void { + if (!this.widgets) return + + const nodeWidth = this.renderingSize[0] + const { widgets } = this + const H = LiteGraph.NODE_WIDGET_HEIGHT + const showText = !lowQuality + ctx.save() + ctx.globalAlpha = editorAlpha + + this.updateComputedDisabled() + for (const widget of widgets) { + if (!this.isWidgetVisible(widget)) continue + + const { y } = widget + const outlineColour = widget.advanced + ? LiteGraph.WIDGET_ADVANCED_OUTLINE_COLOR + : LiteGraph.WIDGET_OUTLINE_COLOR + + widget.last_y = y + + ctx.strokeStyle = outlineColour + ctx.fillStyle = '#222' + ctx.textAlign = 'left' + if (widget.computedDisabled) ctx.globalAlpha *= 0.5 + const width = widget.width || nodeWidth + + if (typeof widget.draw === 'function') { + widget.draw(ctx, this, width, y, H, lowQuality) + } else { + toConcreteWidget(widget, this, false)?.drawWidget(ctx, { + width, + showText + }) + } + ctx.globalAlpha = editorAlpha + } + ctx.restore() + } + + /** + * When {@link LGraphNode.collapsed} is `true`, this method draws the node's collapsed slots. + */ + drawCollapsedSlots(ctx: CanvasRenderingContext2D): void { + this._concreteInputs.find((slot) => slot.isConnected)?.drawCollapsed(ctx) + this._concreteOutputs.find((slot) => slot.isConnected)?.drawCollapsed(ctx) + } + + get slots(): (INodeInputSlot | INodeOutputSlot)[] { + return [...this.inputs, ...this.outputs] + } + + private _measureSlot( + slot: NodeInputSlot | NodeOutputSlot, + slotIndex: number, + isInput: boolean + ): void { + const pos = isInput + ? this.getInputPos(slotIndex) + : this.getOutputPos(slotIndex) + + slot.boundingRect[0] = pos[0] - LiteGraph.NODE_SLOT_HEIGHT * 0.5 + slot.boundingRect[1] = pos[1] - LiteGraph.NODE_SLOT_HEIGHT * 0.5 + slot.boundingRect[2] = slot.isWidgetInputSlot + ? BaseWidget.margin + : LiteGraph.NODE_SLOT_HEIGHT + slot.boundingRect[3] = LiteGraph.NODE_SLOT_HEIGHT + } + + private _measureSlots(): ReadOnlyRect | null { + const slots: (NodeInputSlot | NodeOutputSlot)[] = [] + + for (const [slotIndex, slot] of this._concreteInputs.entries()) { + // Unrecognized nodes (Nodes with error) has inputs but no widgets. Treat + // converted inputs as normal inputs. + /** Widget input slots are handled in {@link layoutWidgetInputSlots} */ + if (this.widgets?.length && isWidgetInputSlot(slot)) continue + + this._measureSlot(slot, slotIndex, true) + slots.push(slot) + } + for (const [slotIndex, slot] of this._concreteOutputs.entries()) { + this._measureSlot(slot, slotIndex, false) + slots.push(slot) + } + + return slots.length ? createBounds(slots, 0) : null + } + + private _getMouseOverSlot( + slot: NodeInputSlot | NodeOutputSlot + ): INodeSlot | null { + const isInput = slot instanceof NodeInputSlot + const mouseOverId = this.mouseOver?.[isInput ? 'inputId' : 'outputId'] ?? -1 + if (mouseOverId === -1) { + return null + } + return isInput ? this.inputs[mouseOverId] : this.outputs[mouseOverId] + } + + private _isMouseOverSlot(slot: NodeInputSlot | NodeOutputSlot): boolean { + return this._getMouseOverSlot(slot) === slot + } + + private _isMouseOverWidget(widget: IBaseWidget | undefined): boolean { + if (!widget) return false + return this.mouseOver?.overWidget === widget + } + + /** + * Returns the input slot that is associated with the given widget. + */ + getSlotFromWidget( + widget: IBaseWidget | undefined + ): INodeInputSlot | undefined { + if (widget) + return this.inputs.find( + (slot) => isWidgetInputSlot(slot) && slot.widget.name === widget.name + ) + } + + /** + * Returns the widget that is associated with the given input slot. + */ + getWidgetFromSlot(slot: INodeInputSlot): IBaseWidget | undefined { + if (!isWidgetInputSlot(slot)) return + return this.widgets?.find((w) => w.name === slot.widget.name) + } + + /** + * Draws the node's input and output slots. + */ + drawSlots( + ctx: CanvasRenderingContext2D, + { fromSlot, colorContext, editorAlpha, lowQuality }: DrawSlotsOptions + ) { + for (const slot of [...this._concreteInputs, ...this._concreteOutputs]) { + const isValidTarget = fromSlot && slot.isValidTarget(fromSlot) + const isMouseOverSlot = this._isMouseOverSlot(slot) + + // change opacity of incompatible slots when dragging a connection + const isValid = !fromSlot || isValidTarget + const highlight = isValid && isMouseOverSlot + + // Show slot if it's not a widget input slot + // or if it's a widget input slot and satisfies one of the following: + // - the mouse is over the widget + // - the slot is valid during link drop + // - the slot is connected + if ( + isMouseOverSlot || + isValidTarget || + !slot.isWidgetInputSlot || + this._isMouseOverWidget(this.getWidgetFromSlot(slot)) || + slot.isConnected || + slot.alwaysVisible + ) { + ctx.globalAlpha = isValid ? editorAlpha : 0.4 * editorAlpha + slot.draw(ctx, { + colorContext, + lowQuality, + highlight + }) + } + } + } + + /** + * Arranges the node's widgets vertically. + * Sets following properties on each widget: + * - {@link IBaseWidget.computedHeight} + * - {@link IBaseWidget.y} + * @param widgetStartY The y-coordinate of the first widget + */ + private _arrangeWidgets(widgetStartY: number): void { + if (!this.widgets || !this.widgets.length) return + + const bodyHeight = this.bodyHeight + const startY = + this.widgets_start_y ?? (this.widgets_up ? 0 : widgetStartY) + 2 + + let freeSpace = bodyHeight - startY + + // Collect fixed height widgets first + let fixedWidgetHeight = 0 + const growableWidgets: { + minHeight: number + prefHeight?: number + w: IBaseWidget + }[] = [] + + const visibleWidgets = this.getLayoutWidgets() + + for (const w of visibleWidgets) { + if (w.computeSize) { + const height = w.computeSize()[1] + 4 + w.computedHeight = height + fixedWidgetHeight += height + } else if (w.computeLayoutSize) { + const { minHeight, maxHeight } = w.computeLayoutSize(this) + growableWidgets.push({ + minHeight, + prefHeight: maxHeight, + w + }) + } else { + const height = LiteGraph.NODE_WIDGET_HEIGHT + 4 + w.computedHeight = height + fixedWidgetHeight += height + } + } + + // Calculate remaining space for DOM widgets + freeSpace -= fixedWidgetHeight + this.freeWidgetSpace = freeSpace + + // Prepare space requests for distribution + const spaceRequests = growableWidgets.map((d) => ({ + minSize: d.minHeight, + maxSize: d.prefHeight + })) + + // Distribute space among DOM widgets + const allocations = distributeSpace(Math.max(0, freeSpace), spaceRequests) + + // Apply computed heights + for (const [i, d] of growableWidgets.entries()) { + d.w.computedHeight = allocations[i] + } + + // Position widgets + let y = startY + for (const w of visibleWidgets) { + w.y = y + y += w.computedHeight ?? 0 + } + + if (!this.graph) throw new NullGraphError() + + // Grow the node if necessary. + // Ref: https://github.com/Comfy-Org/ComfyUI_frontend/issues/2652 + // TODO: Move the layout logic before drawing of the node shape, so we don't + // need to trigger extra round of rendering. + // In Vue mode, the DOM is the source of truth for node sizing — the + // ResizeObserver feeds measurements back to the layout store. Allowing + // LiteGraph to also call setSize() here creates an infinite feedback loop + // (LG grows node → CSS min-height increases → textarea fills extra space → + // ResizeObserver reports larger size → LG grows node again). + if (!LiteGraph.vueNodesMode && y > bodyHeight) { + this.setSize([this.size[0], y]) + this.graph.setDirtyCanvas(false, true) + } + } + + /** + * Arranges the layout of the node's widget input slots. + */ + private _arrangeWidgetInputSlots(): void { + if (!this.widgets?.length) return + + // Build a name→widget map for fast lookup. + const widgetByName = new Map() + for (const w of this.widgets) widgetByName.set(w.name, w) + + // Set widget-backed slot positions from widget Y coordinates. + // In Vue mode, promoted widget inputs are not rendered as + // components (NodeSlots filters them out), so they have no DOM-registered + // position. input.pos serves as the fallback for getSlotPosition(). + for (const [i, slot] of this._concreteInputs.entries()) { + if (!isWidgetInputSlot(slot)) continue + + // Prefer the slot's direct _widget binding (1:1 for promoted inputs). + // Fall back to name-map lookup for regular nodes without _widget set. + // Note: the name-map is ambiguous if two promoted inputs share a label; + // _widget avoids this since it is a direct reference. + const widget = slot._widget ?? widgetByName.get(slot.widget.name) + if (!widget) continue + + const offset = LiteGraph.NODE_SLOT_HEIGHT * 0.5 + const x = offset + const y = widget.y + offset + if (slot.pos?.[0] !== x || slot.pos[1] !== y) slot.pos = [x, y] + this._measureSlot(slot, i, true) + } + } + + /** + * @internal Projects input and output descriptors into concrete slot + * instances, upgrading duck-typed entries in {@link inputs}/{@link outputs} + * in place so identity-based lookups (e.g. `indexOf(slot)`) keep working. + * Already-concrete entries are left untouched, so per-frame calls do not + * invalidate slot-array subscribers. + */ + _setConcreteSlots(): void { + const { inputs, outputs } = this + this._concreteInputs = inputs.map((slot, i) => { + const concrete = toClass(NodeInputSlot, slot, this) + if (concrete !== slot) inputs[i] = concrete + return concrete + }) + this._concreteOutputs = outputs.map((slot, i) => { + const concrete = toClass(NodeOutputSlot, slot, this) + if (concrete !== slot) outputs[i] = concrete + return concrete + }) + } + + /** + * Arranges node elements in preparation for rendering (slots & widgets). + */ + arrange(): void { + const slotsBounds = this._measureSlots() + const widgetStartY = slotsBounds + ? slotsBounds[1] + slotsBounds[3] - this.pos[1] + : 0 + this._arrangeWidgets(widgetStartY) + this._arrangeWidgetInputSlots() + this._widgetSlotsDirty = false + } + + /** + * Draws a progress bar on the node. + * @param ctx The canvas context to draw on + */ + drawProgressBar(ctx: CanvasRenderingContext2D): void { + if (!this.progress) return + + const originalFillStyle = ctx.fillStyle + ctx.fillStyle = 'green' + ctx.fillRect(0, 0, this.width * this.progress, 6) + ctx.fillStyle = originalFillStyle + } +} diff --git a/docs/hel-892/promoted-reference/1.53.6__src__lib__litegraph__src__subgraph__SubgraphInput.ts b/docs/hel-892/promoted-reference/1.53.6__src__lib__litegraph__src__subgraph__SubgraphInput.ts new file mode 100644 index 00000000..e5c7f976 --- /dev/null +++ b/docs/hel-892/promoted-reference/1.53.6__src__lib__litegraph__src__subgraph__SubgraphInput.ts @@ -0,0 +1,253 @@ +import { inputLink } from '@/lib/litegraph/src/node/slotLinks' +import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode' +import { LLink, replaceLinkTopology } from '@/lib/litegraph/src/LLink' +import { mintLinkId } from '../idAllocation' +import { anchorRerouteChain } from '@/lib/litegraph/src/Reroute' +import type { RerouteId } from '@/lib/litegraph/src/Reroute' +import { CustomEventTarget } from '@/lib/litegraph/src/infrastructure/CustomEventTarget' +import type { SubgraphInputEventMap } from '@/lib/litegraph/src/infrastructure/SubgraphInputEventMap' +import type { + INodeInputSlot, + INodeOutputSlot, + Point, + ReadOnlyRect +} from '@/lib/litegraph/src/interfaces' +import { LiteGraph } from '@/lib/litegraph/src/litegraph' +import { NodeSlotType } from '@/lib/litegraph/src/types/globalEnums' +import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets' + +import type { SubgraphInputNode } from './SubgraphInputNode' +import type { SubgraphOutput } from './SubgraphOutput' +import { SubgraphSlot } from './SubgraphSlotBase' +import { isNodeSlot, isSubgraphOutput } from './subgraphUtils' + +/** + * An input "slot" from a parent graph into a subgraph. + * + * IMPORTANT: A subgraph "input" is both an input AND an output. It creates an extra link connection point between + * a parent graph and a subgraph, so is conceptually similar to a reroute. + * + * This can be a little confusing, but is easier to visualise when imagining editing a subgraph. + * You have "Subgraph Inputs", because they are coming into the subgraph, which then connect to "node inputs". + * + * Functionally, however, when editing a subgraph, that "subgraph input" is the "origin" or "output side" of a link. + */ +export class SubgraphInput extends SubgraphSlot { + declare parent: SubgraphInputNode + + events = new CustomEventTarget() + + /** The linked widget that this slot is connected to. */ + private _widgetRef?: WeakRef + + get _widget() { + return this._widgetRef?.deref() + } + + set _widget(widget) { + this._widgetRef = widget ? new WeakRef(widget) : undefined + } + + override connect( + slot: INodeInputSlot, + node: LGraphNode, + afterRerouteId?: RerouteId + ): LLink | undefined { + const { subgraph } = this.parent + + // Allow nodes to block connection + const inputIndex = node.inputs.indexOf(slot) + if ( + node.onConnectInput?.(inputIndex, this.type, this, this.parent, -1) === + false + ) + return + + // if (slot instanceof SubgraphOutput) { + // // Subgraph IO nodes have no special handling at present. + // return new LLink( + // ++subgraph.state.lastLinkId, + // this.type, + // this.parent.id, + // this.parent.slots.indexOf(this), + // node.id, + // inputIndex, + // afterRerouteId, + // ) + // } + + const inputWidget = node.getWidgetFromSlot(slot) + if (inputWidget && !this.matchesWidget(inputWidget)) { + console.warn('Target input has invalid widget.', slot, node) + return + } + + const existingLink = inputLink(subgraph, node.id, node.inputs.indexOf(slot)) + if (existingLink) { + subgraph.beforeChange() + } + + const linkId = mintLinkId(subgraph.state) + + const link = new LLink( + linkId, + slot.type, + this.parent.id, + this.parent.slots.indexOf(this), + node.id, + inputIndex, + afterRerouteId + ) + + if (!replaceLinkTopology(subgraph, existingLink, link)) { + if (existingLink) subgraph.afterChange() + return + } + + if (existingLink) { + this.parent._disconnectNodeInput(node, slot, existingLink) + if (subgraph.getLink(link.id) !== link) { + subgraph.afterChange() + return + } + } + + this.linkIds.push(link.id) + anchorRerouteChain(subgraph, link) + subgraph.incrementVersion() + + if (inputWidget) { + // Keep the widget reference in sync with the active upstream widget. + // Stale references can appear across nested promotion rebinds. + this._widget = inputWidget + this.events.dispatch('input-connected', { + input: slot, + widget: inputWidget, + node + }) + } else { + this.events.dispatch('input-connected', { input: slot }) + } + if (subgraph.getLink(link.id) !== link) { + subgraph.afterChange() + return + } + + node.onConnectionsChange?.(NodeSlotType.INPUT, inputIndex, true, link, slot) + if (subgraph.getLink(link.id) !== link) { + subgraph.afterChange() + return + } + + subgraph.afterChange() + + return link + } + + get labelPos(): Point { + const [x, y, , height] = this.boundingRect + return [x, y + height * 0.5] + } + + getConnectedWidgets(): IBaseWidget[] { + const { subgraph } = this.parent + const widgets: IBaseWidget[] = [] + + for (const linkId of this.linkIds) { + const link = subgraph.getLink(linkId) + if (!link) { + console.error('Link not found', linkId) + continue + } + + const resolved = link.resolve(subgraph) + if (resolved.input && resolved.inputNode?.widgets) { + // Has no widget + const widgetNamePojo = resolved.input.widget + if (!widgetNamePojo) continue + + // Invalid widget name + if (!widgetNamePojo.name) { + console.warn('Invalid widget name', widgetNamePojo) + continue + } + + const widget = resolved.inputNode.widgets.find( + (w) => w.name === widgetNamePojo.name + ) + if (!widget) { + console.warn('Widget not found', widgetNamePojo) + continue + } + + widgets.push(widget) + } + } + return widgets + } + + /** + * Validates that the connection between the new slot and the existing widget is valid. + * Used to prevent connections between widgets that are not of the same type. + * @param otherWidget The widget to compare to. + * @returns `true` if the connection is valid, otherwise `false`. + */ + matchesWidget(otherWidget: IBaseWidget): boolean { + const widget = this._widgetRef?.deref() + if (!widget) return true + + if ( + otherWidget.type !== widget.type || + otherWidget.options.min !== widget.options.min || + otherWidget.options.max !== widget.options.max || + otherWidget.options.step !== widget.options.step || + otherWidget.options.step2 !== widget.options.step2 || + otherWidget.options.precision !== widget.options.precision + ) { + return false + } + + return true + } + + override disconnect(): void { + super.disconnect() + + this._widget = undefined + + this.events.dispatch('input-disconnected', { input: this }) + } + + /** For inputs, x is the right edge of the input node. */ + override arrange(rect: ReadOnlyRect): void { + const [right, top, width, height] = rect + const { boundingRect: b, pos } = this + + b[0] = right - width + b[1] = top + b[2] = width + b[3] = height + + pos[0] = right - height * 0.5 + pos[1] = top + height * 0.5 + } + + /** + * Checks if this slot is a valid target for a connection from the given slot. + * For SubgraphInput (which acts as an output inside the subgraph), + * the fromSlot should be an input slot. + */ + override isValidTarget( + fromSlot: INodeInputSlot | INodeOutputSlot | SubgraphInput | SubgraphOutput + ): boolean { + if (isNodeSlot(fromSlot) && 'link' in fromSlot) { + return LiteGraph.isValidConnection(this.type, fromSlot.type) + } + + if (isSubgraphOutput(fromSlot)) { + return LiteGraph.isValidConnection(this.type, fromSlot.type) + } + + return false + } +} diff --git a/docs/hel-892/promoted-reference/1.53.6__src__lib__litegraph__src__subgraph__promotedWidgetStoreProjection.ts b/docs/hel-892/promoted-reference/1.53.6__src__lib__litegraph__src__subgraph__promotedWidgetStoreProjection.ts new file mode 100644 index 00000000..de1dd89c --- /dev/null +++ b/docs/hel-892/promoted-reference/1.53.6__src__lib__litegraph__src__subgraph__promotedWidgetStoreProjection.ts @@ -0,0 +1,51 @@ +import type { INodeInputSlot } from '@/lib/litegraph/src/litegraph' +import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets' +import { useWidgetValueStore } from '@/stores/widgetValueStore' +import type { WidgetId } from '@/types/widgetId' + +export function createPromotedWidgetStoreProjection( + input: INodeInputSlot, + id: WidgetId +): IBaseWidget { + const store = useWidgetValueStore() + const widget: IBaseWidget = { + get name() { + return store.getWidget(id)?.name ?? input.name + }, + get label() { + return store.getWidget(id)?.label ?? input.label ?? input.name + }, + set label(next) { + const state = store.getWidget(id) + if (state) state.label = next + }, + get y() { + return store.getWidget(id)?.y ?? 0 + }, + set y(next) { + const state = store.getWidget(id) + if (state) state.y = next + }, + get type() { + return store.getWidget(id)?.type ?? 'text' + }, + get options() { + return store.getWidget(id)?.options ?? {} + }, + get value() { + return store.getWidget(id)?.value + }, + set value(next) { + store.setValue(id, next) + }, + callback(next) { + store.setValue(id, next) + } + } + Object.defineProperty(widget, 'widgetId', { + value: id, + enumerable: false, + configurable: true + }) + return widget +} diff --git a/docs/hel-892/promoted-reference/1.53.6__src__renderer__extensions__vueNodes__widgets__composables__useBooleanWidget.ts b/docs/hel-892/promoted-reference/1.53.6__src__renderer__extensions__vueNodes__widgets__composables__useBooleanWidget.ts new file mode 100644 index 00000000..242afe54 --- /dev/null +++ b/docs/hel-892/promoted-reference/1.53.6__src__renderer__extensions__vueNodes__widgets__composables__useBooleanWidget.ts @@ -0,0 +1,31 @@ +import type { LGraphNode } from '@/lib/litegraph/src/litegraph' +import { isBooleanInputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2' +import type { InputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2' +import type { ComfyWidgetConstructorV2 } from '@/scripts/widgets' + +export const useBooleanWidget = () => { + const widgetConstructor: ComfyWidgetConstructorV2 = ( + node: LGraphNode, + inputSpec: InputSpec + ) => { + if (!isBooleanInputSpec(inputSpec)) { + throw new Error(`Invalid input data: ${inputSpec}`) + } + + const defaultVal = inputSpec.default ?? false + const options = { + on: inputSpec.label_on, + off: inputSpec.label_off + } + + return node.addWidget( + 'toggle', + inputSpec.name, + defaultVal, + () => {}, + options + ) + } + + return widgetConstructor +} diff --git a/docs/hel-892/promoted-reference/1.53.6__src__renderer__extensions__vueNodes__widgets__composables__useComboWidget.ts b/docs/hel-892/promoted-reference/1.53.6__src__renderer__extensions__vueNodes__widgets__composables__useComboWidget.ts new file mode 100644 index 00000000..cbbcc4a0 --- /dev/null +++ b/docs/hel-892/promoted-reference/1.53.6__src__renderer__extensions__vueNodes__widgets__composables__useComboWidget.ts @@ -0,0 +1,325 @@ +import { ref, toValue } from 'vue' + +import MultiSelectWidget from '@/components/graph/widgets/MultiSelectWidget.vue' +import { t } from '@/i18n' +import type { LGraphNode } from '@/lib/litegraph/src/litegraph' +import { isComboWidget } from '@/lib/litegraph/src/litegraph' +import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets' +import { assetService } from '@/platform/assets/services/assetService' +import type { AssetItem } from '@/platform/assets/schemas/assetSchema' +import { getAssetFilename } from '@/platform/assets/utils/assetMetadataUtils' +import { createAssetWidget } from '@/platform/assets/utils/createAssetWidget' +import { isCloud } from '@/platform/distribution/types' +import type { + ComboInputSpec, + InputSpec +} from '@/schemas/nodeDef/nodeDefSchemaV2' +import { isComboInputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2' +import { transformInputSpecV2ToV1 } from '@/schemas/nodeDef/migration' +import { ComponentWidgetImpl, addWidget } from '@/scripts/domWidget' +import type { BaseDOMWidget } from '@/scripts/domWidget' +import type { ComfyWidgetConstructorV2 } from '@/scripts/widgets' +import { addValueControlWidgets } from '@/scripts/widgets' +import { useAssetsStore } from '@/stores/assetsStore' +import { getMediaTypeFromFilename } from '@/utils/formatUtil' + +import { useRemoteWidget } from './useRemoteWidget' + +const getDefaultValue = (inputSpec: ComboInputSpec) => { + if (inputSpec.default) return inputSpec.default + if (inputSpec.options?.length) return inputSpec.options[0] + if (inputSpec.remote) return 'Loading...' + return undefined +} + +// Map node types to expected media types +const NODE_MEDIA_TYPE_MAP: Record = { + LoadImage: 'image', + LoadVideo: 'video', + LoadAudio: 'audio' +} + +// Map node types to placeholder i18n keys +const NODE_PLACEHOLDER_MAP: Record = { + LoadImage: 'widgets.uploadSelect.placeholderImage', + LoadVideo: 'widgets.uploadSelect.placeholderVideo', + LoadAudio: 'widgets.uploadSelect.placeholderAudio' +} + +const bindDynamicValuesOption = ( + widget: IBaseWidget, + getValues: () => unknown +) => { + const options = widget.options + let fallbackValues = Array.isArray(options.values) + ? options.values + : ([] as unknown[]) + + Object.defineProperty(options, 'values', { + configurable: true, + enumerable: true, + get: () => { + const values = getValues() + if (values === undefined || values === null) return fallbackValues + return values + }, + set: (values: unknown[]) => { + fallbackValues = Array.isArray(values) ? values : fallbackValues + } + }) +} + +const addMultiSelectWidget = ( + node: LGraphNode, + inputSpec: ComboInputSpec +): IBaseWidget => { + const widgetValue = ref([]) + const widget = new ComponentWidgetImpl({ + node, + name: inputSpec.name, + component: MultiSelectWidget, + inputSpec, + options: { + getValue: () => widgetValue.value, + setValue: (value: string[]) => { + widgetValue.value = value + } + } + }) + addWidget(node, widget as BaseDOMWidget) + // TODO: Add remote support to multi-select widget + // https://github.com/Comfy-Org/ComfyUI_frontend/issues/3003 + if (inputSpec.control_after_generate) { + const defaultType = + typeof inputSpec.control_after_generate === 'string' + ? inputSpec.control_after_generate + : 'fixed' + widget.linkedWidgets = addValueControlWidgets( + node, + widget, + defaultType, + undefined, + transformInputSpecV2ToV1(inputSpec) + ) + } + + return widget +} + +/** + * Resolve the default value for a cloud asset widget. + * Priority: inputSpec.default (if present in cloud assets) → first cloud + * asset → undefined (shows placeholder). + */ +function resolveCloudDefault( + nodeType: string, + specDefault: string | undefined +): string | undefined { + const assets = useAssetsStore().getAssets(nodeType) + if (specDefault != null) { + const inAssets = assets.some((a) => getAssetFilename(a) === specDefault) + if (inAssets) return specDefault + } + // empty filename → undefined (shows placeholder) + const filename = assets.length ? getAssetFilename(assets[0]) : undefined + return filename || undefined +} + +function getCloudInputAssets(nodeType: string | undefined): AssetItem[] { + const mediaType = NODE_MEDIA_TYPE_MAP[nodeType ?? ''] + if (!mediaType) return [] + + return toValue(useAssetsStore().inputAssets.items).filter( + (asset) => + getCloudInputAssetValue(asset) && + getMediaTypeFromFilename(asset.name) === mediaType + ) +} + +function getCloudInputAssetValue(asset: AssetItem): string | undefined { + return asset.hash ?? undefined +} + +function getCloudInputAssetValues(nodeType: string | undefined): string[] { + return getCloudInputAssets(nodeType) + .map(getCloudInputAssetValue) + .filter((value): value is string => !!value) +} + +function resolveCloudInputDefault( + nodeType: string | undefined, + specDefault: string | undefined +): string | undefined { + const assets = getCloudInputAssets(nodeType) + if (specDefault != null) { + const matchingAsset = + assets.find((asset) => getCloudInputAssetValue(asset) === specDefault) ?? + assets.find((asset) => asset.name === specDefault) + if (matchingAsset) return getCloudInputAssetValue(matchingAsset) + } + + return assets[0] ? getCloudInputAssetValue(assets[0]) : undefined +} + +function createAssetBrowserWidget( + node: LGraphNode, + inputSpec: ComboInputSpec, + defaultValue: string | undefined +): IBaseWidget { + return createAssetWidget({ + node, + widgetName: inputSpec.name, + nodeTypeForBrowser: node.comfyClass ?? '', + inputNameForBrowser: inputSpec.name, + defaultValue + }) +} + +const createInputMappingWidget = ( + node: LGraphNode, + inputSpec: ComboInputSpec, + defaultValue: string | undefined +): IBaseWidget => { + const assetsStore = useAssetsStore() + + const widget = node.addWidget( + 'combo', + inputSpec.name, + defaultValue ?? '', + () => {}, + { + values: [], + getOptionLabel: (value?: string | null) => { + if (!value) { + const placeholderKey = + NODE_PLACEHOLDER_MAP[node.comfyClass ?? ''] ?? + 'widgets.uploadSelect.placeholder' + return t(placeholderKey) + } + return assetsStore.getInputName(value) + } + } + ) + + async function loadAll() { + while (toValue(assetsStore.inputAssets.hasMore)) { + await assetsStore.inputAssets.loadMore() + node.setDirtyCanvas(true, false) + } + } + void loadAll() + + bindDynamicValuesOption(widget, () => + getCloudInputAssetValues(node.comfyClass) + ) + + if (inputSpec.control_after_generate) { + if (!isComboWidget(widget)) { + throw new Error(`Expected combo widget but received ${widget.type}`) + } + const defaultType = + typeof inputSpec.control_after_generate === 'string' + ? inputSpec.control_after_generate + : 'randomize' + widget.linkedWidgets = addValueControlWidgets( + node, + widget, + defaultType, + undefined, + transformInputSpecV2ToV1(inputSpec) + ) + } + + return widget +} + +const addComboWidget = ( + node: LGraphNode, + inputSpec: ComboInputSpec +): IBaseWidget => { + const defaultValue = getDefaultValue(inputSpec) + + if (isCloud) { + if (assetService.shouldUseAssetBrowser(node.comfyClass, inputSpec.name)) { + // Default from cloud assets, not from server combo options. + // Server options list local files that may not exist in the user's + // cloud asset library, leading to missing-model errors on undo/reload. + const cloudDefault = resolveCloudDefault( + node.comfyClass ?? '', + inputSpec.default + ) + return createAssetBrowserWidget(node, inputSpec, cloudDefault) + } + + if (NODE_MEDIA_TYPE_MAP[node.comfyClass ?? '']) { + return createInputMappingWidget( + node, + inputSpec, + resolveCloudInputDefault(node.comfyClass, inputSpec.default) + ) + } + } + + // Standard combo widget + const widget = node.addWidget( + 'combo', + inputSpec.name, + defaultValue, + () => {}, + { + values: inputSpec.options ?? [] + } + ) + + if (inputSpec.remote) { + if (!isComboWidget(widget)) { + throw new Error(`Expected combo widget but received ${widget.type}`) + } + + const remoteWidget = useRemoteWidget({ + remoteConfig: inputSpec.remote, + defaultValue, + node, + widget + }) + if (inputSpec.remote.refresh_button) remoteWidget.addRefreshButton() + + bindDynamicValuesOption(widget, () => remoteWidget.getValue()) + } + + if (inputSpec.control_after_generate) { + if (!isComboWidget(widget)) { + throw new Error(`Expected combo widget but received ${widget.type}`) + } + + const defaultType = + typeof inputSpec.control_after_generate === 'string' + ? inputSpec.control_after_generate + : 'randomize' + widget.linkedWidgets = addValueControlWidgets( + node, + widget, + defaultType, + undefined, + transformInputSpecV2ToV1(inputSpec) + ) + } + + return widget +} + +export const useComboWidget = () => { + const widgetConstructor: ComfyWidgetConstructorV2 = ( + node: LGraphNode, + inputSpec: InputSpec + ) => { + if (!isComboInputSpec(inputSpec)) { + throw new Error(`Invalid input data: ${inputSpec}`) + } + return inputSpec.multi_select + ? addMultiSelectWidget(node, inputSpec) + : addComboWidget(node, inputSpec) + } + + return widgetConstructor +} diff --git a/docs/hel-892/promoted-reference/1.53.6__src__renderer__extensions__vueNodes__widgets__composables__useFloatWidget.ts b/docs/hel-892/promoted-reference/1.53.6__src__renderer__extensions__vueNodes__widgets__composables__useFloatWidget.ts new file mode 100644 index 00000000..0d5ee3a9 --- /dev/null +++ b/docs/hel-892/promoted-reference/1.53.6__src__renderer__extensions__vueNodes__widgets__composables__useFloatWidget.ts @@ -0,0 +1,100 @@ +import { clamp } from 'es-toolkit/compat' + +import type { LGraphNode } from '@/lib/litegraph/src/litegraph' +import type { INumericWidget } from '@/lib/litegraph/src/types/widgets' +import { useSettingStore } from '@/platform/settings/settingStore' +import { isFloatInputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2' +import type { InputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2' +import type { ComfyWidgetConstructorV2 } from '@/scripts/widgets' +import { addValueControlWidget } from '@/scripts/widgets' +import { transformInputSpecV2ToV1 } from '@/schemas/nodeDef/migration' + +function onFloatValueChange(this: INumericWidget, v: number) { + const round = this.options.round + if (round) { + const precision = + this.options.precision ?? Math.max(0, -Math.floor(Math.log10(round))) + const rounded = Math.round(v / round) * round + this.value = clamp( + Number(rounded.toFixed(precision)), + this.options.min ?? -Infinity, + this.options.max ?? Infinity + ) + } else { + this.value = v + } +} + +export const _for_testing = { + onFloatValueChange +} + +export const useFloatWidget = () => { + const widgetConstructor: ComfyWidgetConstructorV2 = ( + node: LGraphNode, + inputSpec: InputSpec + ) => { + if (!isFloatInputSpec(inputSpec)) { + throw new Error(`Invalid input data: ${inputSpec}`) + } + + const settingStore = useSettingStore() + const sliderEnabled = !settingStore.get('Comfy.DisableSliders') + + const display_type = inputSpec.display + const widgetType = + display_type == 'gradientslider' + ? 'gradientslider' + : sliderEnabled && display_type == 'slider' + ? 'slider' + : display_type == 'knob' + ? 'knob' + : 'number' + + const step = inputSpec.step ?? 0.5 + const precision = + settingStore.get('Comfy.FloatRoundingPrecision') || + Math.max(0, -Math.floor(Math.log10(step))) + const enableRounding = !settingStore.get('Comfy.DisableFloatRounding') + + /** Assertion {@link inputSpec.default} */ + const defaultValue = (inputSpec.default as number | undefined) ?? 0 + const widget = node.addWidget( + widgetType, + inputSpec.name, + defaultValue, + onFloatValueChange, + { + min: inputSpec.min ?? 0, + max: inputSpec.max ?? 2048, + round: + enableRounding && precision && !inputSpec.round + ? Math.pow(10, -precision) + : (inputSpec.round as number), + /** @deprecated Use step2 instead. The 10x value is a legacy implementation. */ + step: step * 10.0, + step2: step, + precision, + ...(inputSpec.gradient_stops + ? { gradient_stops: inputSpec.gradient_stops } + : {}) + } + ) + + if (inputSpec.control_after_generate) { + const controlWidget = addValueControlWidget( + node, + widget, + 'fixed', + undefined, + undefined, + transformInputSpecV2ToV1(inputSpec) + ) + widget.linkedWidgets = [controlWidget] + } + + return widget + } + + return widgetConstructor +} diff --git a/docs/hel-892/promoted-reference/1.53.6__src__renderer__extensions__vueNodes__widgets__composables__useIntWidget.ts b/docs/hel-892/promoted-reference/1.53.6__src__renderer__extensions__vueNodes__widgets__composables__useIntWidget.ts new file mode 100644 index 00000000..f307aa0e --- /dev/null +++ b/docs/hel-892/promoted-reference/1.53.6__src__renderer__extensions__vueNodes__widgets__composables__useIntWidget.ts @@ -0,0 +1,93 @@ +import type { LGraphNode } from '@/lib/litegraph/src/litegraph' +import type { INumericWidget } from '@/lib/litegraph/src/types/widgets' +import { useSettingStore } from '@/platform/settings/settingStore' +import type { InputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2' +import { isIntInputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2' +import type { ComfyWidgetConstructorV2 } from '@/scripts/widgets' +import { addValueControlWidget } from '@/scripts/widgets' +import { transformInputSpecV2ToV1 } from '@/schemas/nodeDef/migration' + +function onValueChange(this: INumericWidget, v: number) { + // For integers, always round to the nearest step + // step === 0 is invalid, assign 1 if options.step is 0 + const step = this.options.step2 || 1 + + if (step === 1) { + // Simple case: round to nearest integer + this.value = Math.round(v) + } else { + // Round to nearest multiple of step + // First, determine if min value creates an offset + const min = this.options.min ?? 0 + const offset = min % step + + // Round to nearest step, accounting for offset + this.value = Math.round((v - offset) / step) * step + offset + } +} + +export const _for_testing = { + onValueChange +} + +export const useIntWidget = () => { + const widgetConstructor: ComfyWidgetConstructorV2 = ( + node: LGraphNode, + inputSpec: InputSpec + ) => { + if (!isIntInputSpec(inputSpec)) { + throw new Error(`Invalid input data: ${inputSpec}`) + } + + const settingStore = useSettingStore() + const sliderEnabled = !settingStore.get('Comfy.DisableSliders') + const display_type = inputSpec.display + const widgetType = + sliderEnabled && display_type == 'slider' + ? 'slider' + : display_type == 'knob' + ? 'knob' + : 'number' + + const step = inputSpec.step ?? 1 + /** Assertion {@link inputSpec.default} */ + const defaultValue = (inputSpec.default as number | undefined) ?? 0 + const widget = node.addWidget( + widgetType, + inputSpec.name, + defaultValue, + onValueChange, + { + min: inputSpec.min ?? 0, + max: inputSpec.max ?? 2048, + /** @deprecated Use step2 instead. The 10x value is a legacy implementation. */ + step: step * 10, + step2: step, + precision: 0 + } + ) + + const controlAfterGenerate = + inputSpec.control_after_generate ?? + ['seed', 'noise_seed'].includes(inputSpec.name) + + if (controlAfterGenerate) { + const defaultType = + typeof inputSpec.control_after_generate === 'string' + ? inputSpec.control_after_generate + : 'randomize' + const controlWidget = addValueControlWidget( + node, + widget, + defaultType, + undefined, + undefined, + transformInputSpecV2ToV1(inputSpec) + ) + widget.linkedWidgets = [controlWidget] + } + + return widget + } + return widgetConstructor +} diff --git a/docs/hel-892/promoted-reference/1.53.6__src__renderer__extensions__vueNodes__widgets__composables__useStringWidget.ts b/docs/hel-892/promoted-reference/1.53.6__src__renderer__extensions__vueNodes__widgets__composables__useStringWidget.ts new file mode 100644 index 00000000..b939e93e --- /dev/null +++ b/docs/hel-892/promoted-reference/1.53.6__src__renderer__extensions__vueNodes__widgets__composables__useStringWidget.ts @@ -0,0 +1,95 @@ +import type { LGraphNode } from '@/lib/litegraph/src/litegraph' +import { resolveNodeRootGraphId } from '@/lib/litegraph/src/litegraph' +import { defineDeprecatedProperty } from '@/lib/litegraph/src/utils/feedback' +import { + bindMultilineTextareaWidget, + createMultilineInputElement +} from '@/renderer/extensions/vueNodes/widgets/utils/multilineTextarea' +import { isStringInputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2' +import type { InputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2' +import { app } from '@/scripts/app' +import type { ComfyWidgetConstructorV2 } from '@/scripts/widgets' +import { useWidgetValueStore } from '@/stores/widgetValueStore' +import { widgetId } from '@/types/widgetId' + +function addMultilineWidget( + node: LGraphNode, + name: string, + opts: { defaultVal: string; placeholder?: string } +) { + const widgetStore = useWidgetValueStore() + const inputEl = createMultilineInputElement( + opts.defaultVal, + opts.placeholder || name + ) + + const widget = node.addDOMWidget(name, 'customtext', inputEl, { + getValue(): string { + const graphId = resolveNodeRootGraphId(node, app.rootGraph.id) + const widgetState = widgetStore.getWidget( + widgetId(graphId, node.id, name) + ) + + return (widgetState?.value as string) ?? inputEl.value + }, + setValue(v: string) { + inputEl.value = v + const graphId = resolveNodeRootGraphId(node, app.rootGraph.id) + const id = widgetId(graphId, node.id, name) + const widgetState = widgetStore.getWidget(id) + if (widgetState) { + widgetState.value = v + return + } + widgetStore.registerWidget(id, { + type: 'customtext', + value: v, + options: widget.options ?? {} + }) + } + }) + + widget.element = inputEl + + /** @deprecated Use {@link widget.element} instead (renamed in PR #8594). */ + defineDeprecatedProperty( + widget, + 'inputEl', + 'element', + 'widget.inputEl is deprecated. Use widget.element instead.' + ) + widget.options.minNodeSize = [400, 200] + + bindMultilineTextareaWidget(widget, inputEl) + + return widget +} + +export const useStringWidget = () => { + const widgetConstructor: ComfyWidgetConstructorV2 = ( + node: LGraphNode, + inputSpec: InputSpec + ) => { + if (!isStringInputSpec(inputSpec)) { + throw new Error(`Invalid input data: ${inputSpec}`) + } + + const defaultVal = inputSpec.default ?? '' + const multiline = inputSpec.multiline + + const widget = multiline + ? addMultilineWidget(node, inputSpec.name, { + defaultVal, + placeholder: inputSpec.placeholder + }) + : node.addWidget('text', inputSpec.name, defaultVal, () => {}, {}) + + if (typeof inputSpec.dynamicPrompts === 'boolean') { + widget.dynamicPrompts = inputSpec.dynamicPrompts + } + + return widget + } + + return widgetConstructor +} diff --git a/docs/hel-892/promoted-reference/1.53.6__src__scripts__widgets.ts b/docs/hel-892/promoted-reference/1.53.6__src__scripts__widgets.ts new file mode 100644 index 00000000..64a98bf3 --- /dev/null +++ b/docs/hel-892/promoted-reference/1.53.6__src__scripts__widgets.ts @@ -0,0 +1,256 @@ +import { t } from '@/i18n' +import { type LGraphNode, isComboWidget } from '@/lib/litegraph/src/litegraph' +import type { + IBaseWidget, + IComboWidget, + IStringWidget +} from '@/lib/litegraph/src/types/widgets' +import { nextValueForLinkedTarget } from './valueControl' +import { useSettingStore } from '@/platform/settings/settingStore' +import { dynamicWidgets } from '@/core/graph/widgets/dynamicWidgets' +import { useBooleanWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useBooleanWidget' +import { useBoundingBoxWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useBoundingBoxWidget' +import { useCurveWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useCurveWidget' +import { useChartWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useChartWidget' +import { useColorWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useColorWidget' +import { useComboWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useComboWidget' +import { useCompositorWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useCompositorWidget' +import { useFloatWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useFloatWidget' +import { useGalleriaWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useGalleriaWidget' +import { useBoundingBoxesWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useBoundingBoxesWidget' +import { useColorsWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useColorsWidget' +import { useImageCompareWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useImageCompareWidget' +import { useImageUploadWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useImageUploadWidget' +import { useIntWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useIntWidget' +import { useMarkdownWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useMarkdownWidget' +import { usePainterWidget } from '@/renderer/extensions/vueNodes/widgets/composables/usePainterWidget' +import { useRangeWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useRangeWidget' +import { useResolutionPreviewWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useResolutionPreviewWidget' +import { useStringWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useStringWidget' +import { useTextareaWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useTextareaWidget' +import { useVideoEditWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useVideoEditWidget' +import { transformInputSpecV1ToV2 } from '@/schemas/nodeDef/migration' +import type { InputSpec as InputSpecV2 } from '@/schemas/nodeDef/nodeDefSchemaV2' +import type { InputSpec } from '@/schemas/nodeDefSchema' + +import type { ComfyApp } from './app' +import { IS_CONTROL_WIDGET } from './controlWidgetMarker' +import './domWidget' +import './errorNodeWidgets' + +export { IS_CONTROL_WIDGET } + +export type ComfyWidgetConstructorV2 = ( + node: LGraphNode, + inputSpec: InputSpecV2 +) => IBaseWidget + +export type ComfyWidgetConstructor = ( + node: LGraphNode, + inputName: string, + inputData: InputSpec, + app: ComfyApp, + widgetName?: string +) => { widget: IBaseWidget; minWidth?: number; minHeight?: number } + +/** + * Transforms a V2 widget constructor to a V1 widget constructor. + * @param widgetConstructorV2 The V2 widget constructor to transform. + * @returns The transformed V1 widget constructor. + */ +const transformWidgetConstructorV2ToV1 = ( + widgetConstructorV2: ComfyWidgetConstructorV2 +): ComfyWidgetConstructor => { + return (node, inputName, inputData) => { + const inputSpec = transformInputSpecV1ToV2(inputData, { + name: inputName + }) + const widget = widgetConstructorV2(node, inputSpec) + return { + widget, + minWidth: widget.options.minNodeSize?.[0], + minHeight: widget.options.minNodeSize?.[1] + } + } +} + +function controlValueRunBefore() { + return useSettingStore().get('Comfy.WidgetControlMode') === 'before' +} + +export function updateControlWidgetLabel(widget: IBaseWidget) { + if (controlValueRunBefore()) { + widget.label = t('g.control_before_generate') + } else { + widget.label = t('g.control_after_generate') + } +} + +const HAS_EXECUTED = Symbol() + +export function addValueControlWidget( + node: LGraphNode, + targetWidget: IBaseWidget, + defaultValue?: string, + _values?: unknown, + widgetName?: string, + inputData?: InputSpec +): IComboWidget { + let name = inputData?.[1]?.control_after_generate + if (typeof name !== 'string') { + name = widgetName + } + const widgets = addValueControlWidgets( + node, + targetWidget, + defaultValue ?? 'randomize', + { + addFilterList: false, + controlAfterGenerateName: name + }, + inputData + ) + return widgets[0] +} + +export function addValueControlWidgets( + node: LGraphNode, + targetWidget: IBaseWidget, + defaultValue?: string, + options?: Record, + inputData?: InputSpec +): [IComboWidget, ...IStringWidget[]] { + if (!defaultValue) defaultValue = 'randomize' + if (!options) options = {} + + const getName = (defaultName: string, optionName: string) => { + let name = defaultName + if (options[optionName]) { + name = options[optionName] + } else if (typeof inputData?.[1]?.[defaultName] === 'string') { + name = inputData?.[1]?.[defaultName] + } else if (inputData?.[1]?.control_prefix) { + name = inputData?.[1]?.control_prefix + ' ' + name + } + return name + } + + const valueControl = node.addWidget( + 'combo', + getName('control_after_generate', 'controlAfterGenerateName'), + defaultValue, + function () {}, + { + values: ['fixed', 'increment', 'decrement', 'randomize'], + serialize: false, // Don't include this in prompt. + canvasOnly: true + } + ) as IComboWidget + + valueControl.tooltip = + 'Allows the linked widget to be changed automatically, for example randomizing the noise seed.' + valueControl[IS_CONTROL_WIDGET] = true + updateControlWidgetLabel(valueControl) + Object.defineProperty(valueControl, 'disabled', { + get: () => targetWidget.computedDisabled + }) + const widgets: [IComboWidget, ...IStringWidget[]] = [valueControl] + + const isCombo = isComboWidget(targetWidget) + let comboFilter: IStringWidget + if (isCombo && valueControl.options.values) { + // @ts-expect-error Combo widget values may be a dictionary or legacy function type + valueControl.options.values.push('increment-wrap') + } + if (isCombo && options.addFilterList !== false) { + comboFilter = node.addWidget( + 'string', + getName('control_filter_list', 'controlFilterListName'), + '', + function () {}, + { + serialize: false // Don't include this in prompt. + } + ) as IStringWidget + updateControlWidgetLabel(comboFilter) + comboFilter.tooltip = + "Allows for filtering the list of values when changing the value via the control generate mode. Allows for RegEx matches in the format /abc/ to only filter to values containing 'abc'." + Object.defineProperty(comboFilter, 'disabled', { + get: () => targetWidget.computedDisabled + }) + + widgets.push(comboFilter) + } + + function applyWidgetControl() { + if ( + node.inputs?.some( + (input, index) => + input.widget?.name === targetWidget.name && + node.isInputConnected(index) + ) + ) + return + + const next = nextValueForLinkedTarget({ + target: targetWidget, + linkedWidgets: targetWidget.linkedWidgets, + nodeId: node.id + }) + if (next === undefined) return + + targetWidget.value = next + targetWidget.callback?.(next) + } + + valueControl.beforeQueued = () => { + if (controlValueRunBefore()) { + // Don't run on first execution + if (valueControl[HAS_EXECUTED]) { + applyWidgetControl() + } + } + valueControl[HAS_EXECUTED] = true + } + + valueControl.afterQueued = () => { + if (!controlValueRunBefore()) { + applyWidgetControl() + } + } + + return widgets +} + +export const ComfyWidgets = { + INT: transformWidgetConstructorV2ToV1(useIntWidget()), + FLOAT: transformWidgetConstructorV2ToV1(useFloatWidget()), + BOOLEAN: transformWidgetConstructorV2ToV1(useBooleanWidget()), + STRING: transformWidgetConstructorV2ToV1(useStringWidget()), + MARKDOWN: transformWidgetConstructorV2ToV1(useMarkdownWidget()), + COMBO: transformWidgetConstructorV2ToV1(useComboWidget()), + IMAGEUPLOAD: useImageUploadWidget(), + COLOR: transformWidgetConstructorV2ToV1(useColorWidget()), + IMAGECOMPARE: transformWidgetConstructorV2ToV1(useImageCompareWidget()), + BOUNDING_BOX: transformWidgetConstructorV2ToV1(useBoundingBoxWidget()), + CHART: transformWidgetConstructorV2ToV1(useChartWidget()), + GALLERIA: transformWidgetConstructorV2ToV1(useGalleriaWidget()), + PAINTER: transformWidgetConstructorV2ToV1(usePainterWidget()), + COMPOSITOR: transformWidgetConstructorV2ToV1(useCompositorWidget()), + TEXTAREA: transformWidgetConstructorV2ToV1(useTextareaWidget()), + CURVE: transformWidgetConstructorV2ToV1(useCurveWidget()), + RANGE: transformWidgetConstructorV2ToV1(useRangeWidget()), + VIDEO_EDIT: transformWidgetConstructorV2ToV1(useVideoEditWidget()), + RESOLUTION_PREVIEW: transformWidgetConstructorV2ToV1( + useResolutionPreviewWidget() + ), + BOUNDING_BOXES: transformWidgetConstructorV2ToV1(useBoundingBoxesWidget()), + COLORS: transformWidgetConstructorV2ToV1(useColorsWidget()), + ...dynamicWidgets +} as const + +export function isValidWidgetType( + key: unknown +): key is keyof typeof ComfyWidgets { + return ComfyWidgets[key as keyof typeof ComfyWidgets] !== undefined +} diff --git a/docs/hel-892/promoted-reference/1.53.6__src__stores__widgetValueStore.ts b/docs/hel-892/promoted-reference/1.53.6__src__stores__widgetValueStore.ts new file mode 100644 index 00000000..e6c6a409 --- /dev/null +++ b/docs/hel-892/promoted-reference/1.53.6__src__stores__widgetValueStore.ts @@ -0,0 +1,465 @@ +import { defineStore } from 'pinia' +import { reactive, ref } from 'vue' + +import type { UUID } from '@/utils/uuid' +import { parseNodeId } from '@/types/nodeId' +import type { NodeId, SerializedNodeId } from '@/types/nodeId' +import { isWidgetId, parseWidgetId } from '@/types/widgetId' +import type { WidgetId } from '@/types/widgetId' +import type { WidgetValue } from '@/types/simplifiedWidget' +import type { WidgetState, WidgetStateInit } from '@/types/widgetState' +import type { RemoteMutationContext } from '@/types/graphMutationContext' +import type { IWidgetOptions } from '@/lib/litegraph/src/types/widgets' + +export interface WidgetRenderState { + advanced?: boolean + hasLayoutSize?: boolean + isDOMWidget?: boolean + tooltip?: string +} + +interface WidgetRestorationState { + positional: readonly WidgetValue[] + named?: Readonly> + restoreNamed: boolean +} + +function setNodeScoped( + graphMap: Map>, + graphId: UUID, + nodeId: NodeId, + value: T +): void { + let nodeMap = graphMap.get(graphId) + if (!nodeMap) { + nodeMap = new Map() + graphMap.set(graphId, nodeMap) + } + nodeMap.set(nodeId, value) +} + +function clearNodeScoped( + graphMap: Map>, + graphId: UUID, + nodeId: NodeId +): void { + const nodeMap = graphMap.get(graphId) + if (!nodeMap) return + nodeMap.delete(nodeId) + if (nodeMap.size === 0) graphMap.delete(graphId) +} + +export function stripGraphPrefix(scopedId: SerializedNodeId): NodeId | null { + return parseNodeId(String(scopedId).replace(/^(.*:)+/, '')) +} + +export const useWidgetValueStore = defineStore('widgetValue', () => { + const graphWidgetStates = ref(new Map>()) + const graphWidgetRenderStates = ref( + new Map>() + ) + const graphNodeWidgetOrders = ref(new Map>()) + const graphWidgetRestorations = new Map< + UUID, + Map + >() + + function setNodeWidgetRestoration( + graphId: UUID, + nodeId: NodeId, + restoration: WidgetRestorationState + ): void { + setNodeScoped(graphWidgetRestorations, graphId, nodeId, restoration) + } + + function getRestoredWidgetValue( + graphId: UUID, + nodeId: NodeId, + name: string, + positionalIndex: number + ): { value: WidgetValue } | undefined { + const restoration = graphWidgetRestorations.get(graphId)?.get(nodeId) + if (!restoration) return + if (restoration.restoreNamed && restoration.named) { + return Object.hasOwn(restoration.named, name) + ? { value: restoration.named[name] } + : undefined + } + return positionalIndex < restoration.positional.length + ? { value: restoration.positional[positionalIndex] } + : undefined + } + + function clearNodeWidgetRestoration(graphId: UUID, nodeId: NodeId): void { + clearNodeScoped(graphWidgetRestorations, graphId, nodeId) + } + + function getGraphWidgetStates(graphId: UUID): Map { + const widgetStates = graphWidgetStates.value.get(graphId) + if (widgetStates) return widgetStates + + const nextWidgetStates = reactive(new Map()) + graphWidgetStates.value.set(graphId, nextWidgetStates) + return nextWidgetStates + } + + function getGraphWidgetRenderStates( + graphId: UUID + ): Map { + const widgetRenderStates = graphWidgetRenderStates.value.get(graphId) + if (widgetRenderStates) return widgetRenderStates + + const nextWidgetRenderStates = reactive( + new Map() + ) + graphWidgetRenderStates.value.set(graphId, nextWidgetRenderStates) + return nextWidgetRenderStates + } + + function getGraphNodeWidgetOrders(graphId: UUID): Map { + const widgetOrders = graphNodeWidgetOrders.value.get(graphId) + if (widgetOrders) return widgetOrders + + const nextWidgetOrders = reactive(new Map()) + graphNodeWidgetOrders.value.set(graphId, nextWidgetOrders) + return nextWidgetOrders + } + + function getNodeWidgetOrder(graphId: UUID, nodeId: NodeId): WidgetId[] { + const graphOrders = getGraphNodeWidgetOrders(graphId) + const order = graphOrders.get(nodeId) + if (order) return order + + const nextOrder = reactive([]) + graphOrders.set(nodeId, nextOrder) + return nextOrder + } + + function appendNodeWidgetOrder(widgetId: WidgetId): void { + const { graphId, nodeId } = parseWidgetId(widgetId) + const order = getNodeWidgetOrder(graphId, nodeId) + if (!order.includes(widgetId)) order.push(widgetId) + } + + function removeNodeWidgetOrder(widgetId: WidgetId): void { + const { graphId, nodeId } = parseWidgetId(widgetId) + const graphOrders = graphNodeWidgetOrders.value.get(graphId) + if (!graphOrders) return + const order = graphOrders.get(nodeId) + if (!order) return + + const index = order.indexOf(widgetId) + if (index !== -1) order.splice(index, 1) + if (order.length === 0) graphOrders.delete(nodeId) + } + + /** + * @returns The existing state for the same widget type, replacement state + * for a different type, or `undefined` for an invalid widget ID. + */ + function registerWidget< + TValue extends WidgetValue = WidgetValue, + TType extends string = string, + TOptions extends IWidgetOptions = IWidgetOptions + >( + widgetId: WidgetId, + init: WidgetStateInit, + renderState: WidgetRenderState = {}, + _context?: RemoteMutationContext + ): WidgetState | undefined { + if (!isWidgetId(widgetId)) { + console.warn( + 'widgetValueStore.registerWidget: ignoring un-keyable widget id', + widgetId + ) + return undefined + } + + const existing = getWidget(widgetId) + const { graphId, nodeId, name: storageName } = parseWidgetId(widgetId) + if (existing && existing.type !== init.type) { + getGraphWidgetRenderStates(graphId).delete(widgetId) + } + registerWidgetRenderState(widgetId, renderState) + // WidgetId is `graphId:nodeId:name`. A node replacement can reuse the same + // numeric nodeId, so a stale entry from the previous occupant may survive in + // the store under the same key. The type check distinguishes a live + // re-registration (same widget, keep its value) from a recycled key (new + // widget type at an old address, overwrite). Without it a text widget + // rendered as the prior int type until the next full reload (#13073, #13773). + if (existing && existing.type === init.type) { + const value = existing.value + Object.assign(existing, init, { + name: init.name ?? storageName, + nodeId, + value, + y: init.y ?? existing.y + }) + appendNodeWidgetOrder(widgetId) + return existing as WidgetState + } + + const state: WidgetState = { + ...init, + nodeId, + name: init.name ?? storageName, + y: init.y ?? 0 + } + const widgetStates = getGraphWidgetStates(graphId) + widgetStates.set(widgetId, state) + appendNodeWidgetOrder(widgetId) + return widgetStates.get(widgetId) as WidgetState + } + + function registerWidgetRenderState( + widgetId: WidgetId, + init: WidgetRenderState + ): WidgetRenderState { + const { graphId } = parseWidgetId(widgetId) + const widgetRenderStates = getGraphWidgetRenderStates(graphId) + const existing = widgetRenderStates.get(widgetId) + if (existing) { + Object.assign(existing, init) + return existing + } + + const state: WidgetRenderState = { ...init } + widgetRenderStates.set(widgetId, state) + return widgetRenderStates.get(widgetId) as WidgetRenderState + } + + function getWidget(widgetId: WidgetId): WidgetState | undefined { + if (!isWidgetId(widgetId)) return undefined + + const { graphId } = parseWidgetId(widgetId) + return graphWidgetStates.value.get(graphId)?.get(widgetId) + } + + function getWidgetRenderState( + widgetId: WidgetId + ): WidgetRenderState | undefined { + if (!isWidgetId(widgetId)) return undefined + + const { graphId } = parseWidgetId(widgetId) + return graphWidgetRenderStates.value.get(graphId)?.get(widgetId) + } + + function setValue( + widgetId: WidgetId, + value: WidgetState['value'], + _context?: RemoteMutationContext + ): boolean { + const state = getWidget(widgetId) + if (!state) return false + state.value = value + return true + } + + function setLabel(widgetId: WidgetId, label: string): boolean { + const state = getWidget(widgetId) + if (!state) return false + state.label = label + return true + } + + function updateOptions( + widgetId: WidgetId, + options: Partial + ): boolean { + const state = getWidget(widgetId) + if (!state) return false + state.options = { ...state.options, ...options } + return true + } + + function deleteWidget(widgetId: WidgetId): boolean { + if (!isWidgetId(widgetId)) return false + + const { graphId } = parseWidgetId(widgetId) + graphWidgetRenderStates.value.get(graphId)?.delete(widgetId) + removeNodeWidgetOrder(widgetId) + return graphWidgetStates.value.get(graphId)?.delete(widgetId) ?? false + } + + function renameWidget( + oldId: WidgetId, + newId: WidgetId + ): WidgetState | undefined { + if (!isWidgetId(oldId) || !isWidgetId(newId)) return undefined + if (oldId === newId) return getWidget(oldId) + + const previous = parseWidgetId(oldId) + const next = parseWidgetId(newId) + if (previous.graphId !== next.graphId) return undefined + if (previous.nodeId !== next.nodeId) return undefined + + const { graphId, nodeId, name } = next + const widgetStates = getGraphWidgetStates(graphId) + const state = widgetStates.get(oldId) + if (!state) return undefined + if (widgetStates.has(newId)) return undefined + + const renderStates = getGraphWidgetRenderStates(graphId) + const renderState = renderStates.get(oldId) + const order = getNodeWidgetOrder(graphId, nodeId) + const index = order.indexOf(oldId) + + widgetStates.delete(oldId) + renderStates.delete(oldId) + if (index !== -1) order.splice(index, 1) + + state.name = name + widgetStates.set(newId, state) + if (renderState) renderStates.set(newId, renderState) + if (index !== -1) order.splice(index, 0, newId) + else if (!order.includes(newId)) order.push(newId) + + return widgetStates.get(newId) + } + + function getNodeWidgets(graphId: UUID, localNodeId: NodeId): WidgetState[] { + return getNodeWidgetIds(graphId, localNodeId).flatMap((id) => { + const state = getWidget(id) + return state ? [state] : [] + }) + } + + /** + * Merges a requested widget order against the ids already tracked for the + * node: the request is filtered to tracked ids, then any tracked id the + * request omitted is appended. Tracked ids are never dropped here — only + * {@link removeNodeWidgetOrder} removes an id from the order. + */ + function reconcileNodeWidgetOrder( + graphId: UUID, + localNodeId: NodeId, + orderedWidgetIds: readonly WidgetId[] + ): WidgetId[] { + const currentOrder = getNodeWidgetIds(graphId, localNodeId) + const currentIds = new Set(currentOrder) + const nextOrder = orderedWidgetIds.filter((id) => currentIds.has(id)) + const nextIds = new Set(nextOrder) + return [...nextOrder, ...currentOrder.filter((id) => !nextIds.has(id))] + } + + function getNodeWidgetIds(graphId: UUID, localNodeId: NodeId): WidgetId[] { + return [ + ...(graphNodeWidgetOrders.value.get(graphId)?.get(localNodeId) ?? []) + ] + } + + function setNodeWidgetOrder( + graphId: UUID, + localNodeId: NodeId, + orderedWidgetIds: readonly WidgetId[] + ): void { + const nextOrder = reconcileNodeWidgetOrder( + graphId, + localNodeId, + orderedWidgetIds + ) + const order = getNodeWidgetOrder(graphId, localNodeId) + order.splice(0, order.length, ...nextOrder) + } + + function replaceNodeWidgetOrder( + graphId: UUID, + localNodeId: NodeId, + orderedWidgetIds: readonly WidgetId[] + ): void { + const widgetStates = getGraphWidgetStates(graphId) + const nextOrder = orderedWidgetIds.filter( + (id) => widgetStates.get(id)?.nodeId === localNodeId + ) + const graphOrders = getGraphNodeWidgetOrders(graphId) + const order = graphOrders.get(localNodeId) + + if (nextOrder.length === 0) { + graphOrders.delete(localNodeId) + } else if (order) { + order.splice(0, order.length, ...nextOrder) + } else { + graphOrders.set(localNodeId, reactive([...nextOrder])) + } + } + + /** + * Releases the widget ids tracked for a node, from the store's own record + * rather than the node's live widget list — the two diverge once a node drops + * widgets without unregistering them. `discardValues` also drops the widget + * states; retaining them lets a node that comes back keep what the user set. + */ + function releaseNodeWidgets( + graphId: UUID, + localNodeId: NodeId, + { discardValues }: { discardValues: boolean } + ): void { + const graphOrders = graphNodeWidgetOrders.value.get(graphId) + if (!graphOrders) return + + const order = graphOrders.get(localNodeId) + if (!order) return + + if (discardValues) { + for (const widgetId of order) { + graphWidgetStates.value.get(graphId)?.delete(widgetId) + graphWidgetRenderStates.value.get(graphId)?.delete(widgetId) + } + } + graphOrders.delete(localNodeId) + } + + function clearNode( + graphId: UUID, + nodeId: NodeId, + _context?: RemoteMutationContext + ): void { + graphWidgetRestorations.get(graphId)?.delete(nodeId) + const widgetStates = graphWidgetStates.value.get(graphId) + const widgetRenderStates = graphWidgetRenderStates.value.get(graphId) + if (widgetStates) { + for (const [id, state] of widgetStates) { + if (state.nodeId !== nodeId) continue + widgetStates.delete(id) + widgetRenderStates?.delete(id) + } + if (widgetStates.size === 0) graphWidgetStates.value.delete(graphId) + } + if (widgetRenderStates?.size === 0) { + graphWidgetRenderStates.value.delete(graphId) + } + + const widgetOrders = graphNodeWidgetOrders.value.get(graphId) + widgetOrders?.delete(nodeId) + if (widgetOrders?.size === 0) graphNodeWidgetOrders.value.delete(graphId) + } + + function clearGraph(graphId: UUID): void { + graphWidgetStates.value.delete(graphId) + graphWidgetRenderStates.value.delete(graphId) + graphNodeWidgetOrders.value.delete(graphId) + graphWidgetRestorations.delete(graphId) + } + + return { + registerWidget, + setNodeWidgetRestoration, + clearNodeWidgetRestoration, + getRestoredWidgetValue, + getWidget, + getWidgetRenderState, + setValue, + setLabel, + updateOptions, + deleteWidget, + renameWidget, + getNodeWidgets, + getNodeWidgetIds, + setNodeWidgetOrder, + replaceNodeWidgetOrder, + removeNodeWidgetOrder, + releaseNodeWidgets, + clearNode, + clearGraph + } +}) diff --git a/docs/hel-892/promoted-reference/1.53.6__src__types__widgetId.ts b/docs/hel-892/promoted-reference/1.53.6__src__types__widgetId.ts new file mode 100644 index 00000000..01410bcc --- /dev/null +++ b/docs/hel-892/promoted-reference/1.53.6__src__types__widgetId.ts @@ -0,0 +1,108 @@ +import { toNodeId } from '@/types/nodeId' +import type { NodeId } from '@/types/nodeId' +type UUID = string + +/** + * A widget's canonical identity: `graphId:nodeId:name`. + * Duplicate widget names must be normalized before deriving this ID. + * See ADR 0008's "Widget identity keys on name" section. + */ +export type WidgetId = string & { readonly __brand: 'WidgetId' } + +const SEPARATOR = ':' +const WIDGET_ID_PATTERN = /^(?[^:]+):(?[^:]+):(?[^:]+)$/u + +export function widgetId( + graphId: UUID, + localNodeId: NodeId, + name: string +): WidgetId { + return [ + graphId, + encodeURIComponent(String(localNodeId)), + encodeURIComponent(name) + ].join(SEPARATOR) as WidgetId +} + +export function ensureUniqueWidgetNames( + widgets: readonly { name: string }[] +): boolean { + try { + const reserved = new Set(widgets.map(({ name }) => name)) + const used = new Set() + const seen = new Set() + const renames: { widget: { name: string }; name: string }[] = [] + + for (const widget of widgets) { + // The same widget object may transiently occupy multiple array slots + // (e.g. during an index-assignment reorder). Identity duplicates are + // one widget, not a name collision — never rename them. + if (seen.has(widget)) continue + seen.add(widget) + if (!used.has(widget.name)) { + used.add(widget.name) + continue + } + + let index = 1 + while ( + used.has(`${widget.name}#${index}`) || + reserved.has(`${widget.name}#${index}`) + ) { + index++ + } + const name = `${widget.name}#${index}` + used.add(name) + renames.push({ widget, name }) + } + + if ( + renames.some(({ widget }) => { + const descriptor = Object.getOwnPropertyDescriptor(widget, 'name') + return descriptor + ? 'writable' in descriptor + ? !descriptor.writable + : !descriptor.set + : !Object.isExtensible(widget) + }) + ) { + console.warn('Cannot safely rename duplicate widgets') + return false + } + + for (const { widget, name } of renames) widget.name = name + return true + } catch (error) { + console.warn('Failed to rename duplicate widgets', error) + return false + } +} + +function decodeWidgetIdSegment(segment: string): string { + try { + return decodeURIComponent(segment) + } catch (error) { + if (error instanceof URIError) return segment + throw error + } +} + +export function parseWidgetId(id: WidgetId): { + graphId: UUID + nodeId: NodeId + name: string +} { + const groups = WIDGET_ID_PATTERN.exec(id)?.groups + if (!groups) throw new Error('Invalid widget id') + + return { + graphId: groups.graphId, + nodeId: toNodeId(decodeWidgetIdSegment(groups.nodeId)), + name: decodeWidgetIdSegment(groups.name) + } +} + +export function isWidgetId(value: unknown): value is WidgetId { + if (typeof value !== 'string') return false + return WIDGET_ID_PATTERN.test(value) +} diff --git a/docs/hel-892/promoted-reference/core-0.31.0__LICENSE b/docs/hel-892/promoted-reference/core-0.31.0__LICENSE new file mode 100644 index 00000000..f288702d --- /dev/null +++ b/docs/hel-892/promoted-reference/core-0.31.0__LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/docs/hel-892/promoted-reference/core-0.31.0__comfy_extras__nodes_logic.py b/docs/hel-892/promoted-reference/core-0.31.0__comfy_extras__nodes_logic.py new file mode 100644 index 00000000..13c1685f --- /dev/null +++ b/docs/hel-892/promoted-reference/core-0.31.0__comfy_extras__nodes_logic.py @@ -0,0 +1,353 @@ +from typing import TypedDict +from typing_extensions import override +from comfy_api.latest import ComfyExtension, io +from comfy_api.latest import _io + +# sentinel for missing inputs +MISSING = object() + + +class NotNode(io.ComfyNode): + @classmethod + def define_schema(cls): + return io.Schema( + node_id="ComfyNotNode", + display_name="Not", + category="utilities/logic", + description="Logical NOT operation. Returns true if the value is falsy. Uses Python's rules for truthiness.", + search_aliases=["invert", "toggle", "negate", "flip boolean"], + inputs=[ + io.AnyType.Input("value"), + ], + outputs=[ + io.Boolean.Output(), + ], + ) + + @classmethod + def execute(cls, value) -> io.NodeOutput: + return io.NodeOutput(not value) + + +class AndNode(io.ComfyNode): + @classmethod + def define_schema(cls): + template = io.Autogrow.TemplatePrefix( + input=io.AnyType.Input("value"), + prefix="value", + min=1, + ) + return io.Schema( + node_id="ComfyAndNode", + display_name="And", + category="utilities/logic", + description="Logical AND operation. Returns true if all of the values are truthy. Uses Python's rules for truthiness.", + search_aliases=["all", "every"], + inputs=[ + io.Autogrow.Input("values", template=template), + ], + outputs=[ + io.Boolean.Output(), + ], + ) + + @classmethod + def execute(cls, values: io.Autogrow.Type) -> io.NodeOutput: + return io.NodeOutput(all(values.values())) + + +class OrNode(io.ComfyNode): + @classmethod + def define_schema(cls): + template = io.Autogrow.TemplatePrefix( + input=io.AnyType.Input("value"), + prefix="value", + min=1, + ) + return io.Schema( + node_id="ComfyOrNode", + display_name="Or", + category="utilities/logic", + description="Logical OR operation. Returns true if any of the values are truthy. Uses Python's rules for truthiness.", + search_aliases=["any", "some"], + inputs=[ + io.Autogrow.Input("values", template=template), + ], + outputs=[ + io.Boolean.Output(), + ], + ) + + @classmethod + def execute(cls, values: io.Autogrow.Type) -> io.NodeOutput: + return io.NodeOutput(any(values.values())) + + +class SwitchNode(io.ComfyNode): + @classmethod + def define_schema(cls): + template = io.MatchType.Template("switch") + return io.Schema( + node_id="ComfySwitchNode", + search_aliases=["if", "then", "switch", "conditional", "branch"], + display_name="If/Else Switch", + category="utilities/logic", + is_experimental=True, + inputs=[ + io.Boolean.Input("switch"), + io.MatchType.Input("on_false", template=template, lazy=True), + io.MatchType.Input("on_true", template=template, lazy=True), + ], + outputs=[ + io.MatchType.Output(template=template, display_name="output"), + ], + ) + + @classmethod + def check_lazy_status(cls, switch, on_false=None, on_true=None): + if switch and on_true is None: + return ["on_true"] + if not switch and on_false is None: + return ["on_false"] + + @classmethod + def execute(cls, switch, on_true, on_false) -> io.NodeOutput: + return io.NodeOutput(on_true if switch else on_false) + + +class SoftSwitchNode(io.ComfyNode): + @classmethod + def define_schema(cls): + template = io.MatchType.Template("switch") + return io.Schema( + node_id="ComfySoftSwitchNode", + display_name="Soft Switch", + category="utilities/logic", + is_experimental=True, + inputs=[ + io.Boolean.Input("switch"), + io.MatchType.Input("on_false", template=template, lazy=True, optional=True), + io.MatchType.Input("on_true", template=template, lazy=True, optional=True), + ], + outputs=[ + io.MatchType.Output(template=template, display_name="output"), + ], + ) + + @classmethod + def check_lazy_status(cls, switch, on_false=MISSING, on_true=MISSING): + # We use MISSING instead of None, as None is passed for connected-but-unevaluated inputs. + # This trick allows us to ignore the value of the switch and still be able to run execute(). + + # One of the inputs may be missing, in which case we need to evaluate the other input + if on_false is MISSING: + return ["on_true"] + if on_true is MISSING: + return ["on_false"] + # Normal lazy switch operation + if switch and on_true is None: + return ["on_true"] + if not switch and on_false is None: + return ["on_false"] + + @classmethod + def validate_inputs(cls, switch, on_false=MISSING, on_true=MISSING): + # This check happens before check_lazy_status(), so we can eliminate the case where + # both inputs are missing. + if on_false is MISSING and on_true is MISSING: + return "At least one of on_false or on_true must be connected to Switch node" + return True + + @classmethod + def execute(cls, switch, on_true=MISSING, on_false=MISSING) -> io.NodeOutput: + if on_true is MISSING: + return io.NodeOutput(on_false) + if on_false is MISSING: + return io.NodeOutput(on_true) + return io.NodeOutput(on_true if switch else on_false) + + +class CustomComboNode(io.ComfyNode): + """ + Frontend node that allows user to write their own options for a combo. + This is here to make sure the node has a backend-representation to avoid some annoyances. + """ + @classmethod + def define_schema(cls): + return io.Schema( + node_id="CustomCombo", + display_name="Custom Combo", + category="utilities", + is_experimental=True, + inputs=[io.Combo.Input("choice", options=[])], + outputs=[ + io.String.Output(display_name="STRING"), + io.Int.Output(display_name="INDEX"), + ], + accept_all_inputs=True, + ) + + @classmethod + def validate_inputs(cls, choice: io.Combo.Type, index: int = 0, **kwargs) -> bool: + # NOTE: DO NOT DO THIS unless you want to skip validation entirely on the node's inputs. + # I am doing that here because the widgets (besides the combo dropdown) on this node are fully frontend defined. + # I need to skip checking that the chosen combo option is in the options list, since those are defined by the user. + return True + + @classmethod + def execute(cls, choice: io.Combo.Type, index: int = 0, **kwargs) -> io.NodeOutput: + return io.NodeOutput(choice, index) + + +class DCTestNode(io.ComfyNode): + class DCValues(TypedDict): + combo: str + string: str + integer: int + image: io.Image.Type + subcombo: dict[str] + + @classmethod + def define_schema(cls): + return io.Schema( + node_id="DCTestNode", + display_name="DCTest", + category="utilities/logic", + is_output_node=True, + inputs=[io.DynamicCombo.Input("combo", options=[ + io.DynamicCombo.Option("option1", [io.String.Input("string")]), + io.DynamicCombo.Option("option2", [io.Int.Input("integer")]), + io.DynamicCombo.Option("option3", [io.Image.Input("image")]), + io.DynamicCombo.Option("option4", [ + io.DynamicCombo.Input("subcombo", options=[ + io.DynamicCombo.Option("opt1", [io.Float.Input("float_x"), io.Float.Input("float_y")]), + io.DynamicCombo.Option("opt2", [io.Mask.Input("mask1", optional=True)]), + ]) + ])] + )], + outputs=[io.AnyType.Output()], + ) + + @classmethod + def execute(cls, combo: DCValues) -> io.NodeOutput: + combo_val = combo["combo"] + if combo_val == "option1": + return io.NodeOutput(combo["string"]) + elif combo_val == "option2": + return io.NodeOutput(combo["integer"]) + elif combo_val == "option3": + return io.NodeOutput(combo["image"]) + elif combo_val == "option4": + return io.NodeOutput(f"{combo['subcombo']}") + else: + raise ValueError(f"Invalid combo: {combo_val}") + + +class AutogrowNamesTestNode(io.ComfyNode): + @classmethod + def define_schema(cls): + template = _io.Autogrow.TemplateNames(input=io.Float.Input("float"), names=["a", "b", "c"]) + return io.Schema( + node_id="AutogrowNamesTestNode", + display_name="AutogrowNamesTest", + category="utilities/logic", + inputs=[ + _io.Autogrow.Input("autogrow", template=template) + ], + outputs=[io.String.Output()], + ) + + @classmethod + def execute(cls, autogrow: _io.Autogrow.Type) -> io.NodeOutput: + vals = list(autogrow.values()) + combined = ",".join([str(x) for x in vals]) + return io.NodeOutput(combined) + +class AutogrowPrefixTestNode(io.ComfyNode): + @classmethod + def define_schema(cls): + template = _io.Autogrow.TemplatePrefix(input=io.Float.Input("float"), prefix="float", min=1, max=10) + return io.Schema( + node_id="AutogrowPrefixTestNode", + display_name="AutogrowPrefixTest", + category="utilities/logic", + inputs=[ + _io.Autogrow.Input("autogrow", template=template) + ], + outputs=[io.String.Output()], + ) + + @classmethod + def execute(cls, autogrow: _io.Autogrow.Type) -> io.NodeOutput: + vals = list(autogrow.values()) + combined = ",".join([str(x) for x in vals]) + return io.NodeOutput(combined) + +class ComboOutputTestNode(io.ComfyNode): + @classmethod + def define_schema(cls): + return io.Schema( + node_id="ComboOptionTestNode", + display_name="ComboOptionTest", + category="utilities/logic", + inputs=[io.Combo.Input("combo", options=["option1", "option2", "option3"]), + io.Combo.Input("combo2", options=["option4", "option5", "option6"])], + outputs=[io.Combo.Output(), io.Combo.Output()], + ) + + @classmethod + def execute(cls, combo: io.Combo.Type, combo2: io.Combo.Type) -> io.NodeOutput: + return io.NodeOutput(combo, combo2) + +class ConvertStringToComboNode(io.ComfyNode): + @classmethod + def define_schema(cls): + return io.Schema( + node_id="ConvertStringToComboNode", + search_aliases=["string to dropdown", "text to combo"], + display_name="Convert String to Combo", + category="utilities/logic", + inputs=[io.String.Input("string")], + outputs=[io.Combo.Output()], + ) + + @classmethod + def execute(cls, string: str) -> io.NodeOutput: + return io.NodeOutput(string) + +class InvertBooleanNode(io.ComfyNode): + @classmethod + def define_schema(cls): + return io.Schema( + node_id="InvertBooleanNode", + search_aliases=["not", "toggle", "negate", "flip boolean"], + display_name="Invert Boolean", + category="utilities/logic", + inputs=[io.Boolean.Input("boolean")], + outputs=[io.Boolean.Output()], + ) + + @classmethod + def execute(cls, boolean: bool) -> io.NodeOutput: + return io.NodeOutput(not boolean) + +class LogicExtension(ComfyExtension): + @override + async def get_node_list(self) -> list[type[io.ComfyNode]]: + return [ + SwitchNode, + CustomComboNode, + NotNode, + AndNode, + OrNode, + # SoftSwitchNode, + # ConvertStringToComboNode, + # DCTestNode, + # AutogrowNamesTestNode, + # AutogrowPrefixTestNode, + # ComboOutputTestNode, + # InvertBooleanNode, + ] + +async def comfy_entrypoint() -> LogicExtension: + return LogicExtension() diff --git a/docs/hel-892/promoted-reference/core-0.31.0__comfy_extras__nodes_primitive.py b/docs/hel-892/promoted-reference/core-0.31.0__comfy_extras__nodes_primitive.py new file mode 100644 index 00000000..35761863 --- /dev/null +++ b/docs/hel-892/promoted-reference/core-0.31.0__comfy_extras__nodes_primitive.py @@ -0,0 +1,108 @@ +import sys +from typing_extensions import override + +from comfy_api.latest import ComfyExtension, io + + +class String(io.ComfyNode): + @classmethod + def define_schema(cls): + return io.Schema( + node_id="PrimitiveString", + search_aliases=["text", "string", "text box", "prompt"], + display_name="Text", + category="utilities/primitive", + inputs=[io.String.Input("value")], + outputs=[io.String.Output()] + ) + + @classmethod + def execute(cls, value: str) -> io.NodeOutput: + return io.NodeOutput(value) + + +class StringMultiline(io.ComfyNode): + @classmethod + def define_schema(cls): + return io.Schema( + node_id="PrimitiveStringMultiline", + search_aliases=["text", "string", "text multiline", "string multiline", "text box", "prompt"], + display_name="Text (Multiline)", + category="utilities/primitive", + essentials_category="Basics", + inputs=[io.String.Input("value", multiline=True)], + outputs=[io.String.Output()], + ) + + @classmethod + def execute(cls, value: str) -> io.NodeOutput: + return io.NodeOutput(value) + + +class Int(io.ComfyNode): + @classmethod + def define_schema(cls): + return io.Schema( + node_id="PrimitiveInt", + display_name="Int", + category="utilities/primitive", + inputs=[ + io.Int.Input("value", min=-sys.maxsize, max=sys.maxsize, control_after_generate=io.ControlAfterGenerate.fixed), + ], + outputs=[io.Int.Output()], + ) + + @classmethod + def execute(cls, value: int) -> io.NodeOutput: + return io.NodeOutput(value) + + +class Float(io.ComfyNode): + @classmethod + def define_schema(cls): + return io.Schema( + node_id="PrimitiveFloat", + display_name="Float", + category="utilities/primitive", + inputs=[ + io.Float.Input("value", min=-sys.maxsize, max=sys.maxsize, step=0.1), + ], + outputs=[io.Float.Output()], + ) + + @classmethod + def execute(cls, value: float) -> io.NodeOutput: + return io.NodeOutput(value) + + +class Boolean(io.ComfyNode): + @classmethod + def define_schema(cls): + return io.Schema( + node_id="PrimitiveBoolean", + display_name="Boolean", + category="utilities/primitive", + inputs=[ + io.Boolean.Input("value"), + ], + outputs=[io.Boolean.Output()], + ) + + @classmethod + def execute(cls, value: bool) -> io.NodeOutput: + return io.NodeOutput(value) + + +class PrimitivesExtension(ComfyExtension): + @override + async def get_node_list(self) -> list[type[io.ComfyNode]]: + return [ + String, + StringMultiline, + Int, + Float, + Boolean, + ] + +async def comfy_entrypoint() -> PrimitivesExtension: + return PrimitivesExtension() diff --git a/docs/hel-892/promoted-reference/core-0.31.0__comfy_extras__nodes_qwen.py b/docs/hel-892/promoted-reference/core-0.31.0__comfy_extras__nodes_qwen.py new file mode 100644 index 00000000..4960774d --- /dev/null +++ b/docs/hel-892/promoted-reference/core-0.31.0__comfy_extras__nodes_qwen.py @@ -0,0 +1,144 @@ +import node_helpers +import comfy.utils +import math +from typing_extensions import override +from comfy_api.latest import ComfyExtension, io +import comfy.model_management +import torch +import nodes + +class TextEncodeQwenImageEdit(io.ComfyNode): + @classmethod + def define_schema(cls): + return io.Schema( + node_id="TextEncodeQwenImageEdit", + category="model/conditioning/qwen image", + inputs=[ + io.Clip.Input("clip"), + io.String.Input("prompt", multiline=True, dynamic_prompts=True), + io.Vae.Input("vae", optional=True), + io.Image.Input("image", optional=True), + ], + outputs=[ + io.Conditioning.Output(), + ], + ) + + @classmethod + def execute(cls, clip, prompt, vae=None, image=None) -> io.NodeOutput: + ref_latent = None + if image is None: + images = [] + else: + samples = image.movedim(-1, 1) + total = int(1024 * 1024) + + scale_by = math.sqrt(total / (samples.shape[3] * samples.shape[2])) + width = round(samples.shape[3] * scale_by) + height = round(samples.shape[2] * scale_by) + + s = comfy.utils.common_upscale(samples, width, height, "area", "disabled") + image = s.movedim(1, -1) + images = [image[:, :, :, :3]] + if vae is not None: + ref_latent = vae.encode(image[:, :, :, :3]) + + tokens = clip.tokenize(prompt, images=images) + conditioning = clip.encode_from_tokens_scheduled(tokens) + if ref_latent is not None: + conditioning = node_helpers.conditioning_set_values(conditioning, {"reference_latents": [ref_latent]}, append=True) + return io.NodeOutput(conditioning) + + +class TextEncodeQwenImageEditPlus(io.ComfyNode): + @classmethod + def define_schema(cls): + return io.Schema( + node_id="TextEncodeQwenImageEditPlus", + category="model/conditioning/qwen image", + inputs=[ + io.Clip.Input("clip"), + io.String.Input("prompt", multiline=True, dynamic_prompts=True), + io.Vae.Input("vae", optional=True), + io.Image.Input("image1", optional=True), + io.Image.Input("image2", optional=True), + io.Image.Input("image3", optional=True), + ], + outputs=[ + io.Conditioning.Output(), + ], + ) + + @classmethod + def execute(cls, clip, prompt, vae=None, image1=None, image2=None, image3=None) -> io.NodeOutput: + ref_latents = [] + images = [image1, image2, image3] + images_vl = [] + llama_template = "<|im_start|>system\nDescribe the key features of the input image (color, shape, size, texture, objects, background), then explain how the user's text instruction should alter or modify the image. Generate a new image that meets the user's requirements while maintaining consistency with the original input where appropriate.<|im_end|>\n<|im_start|>user\n{}<|im_end|>\n<|im_start|>assistant\n" + image_prompt = "" + + for i, image in enumerate(images): + if image is not None: + samples = image.movedim(-1, 1) + total = int(384 * 384) + + scale_by = math.sqrt(total / (samples.shape[3] * samples.shape[2])) + width = round(samples.shape[3] * scale_by) + height = round(samples.shape[2] * scale_by) + + s = comfy.utils.common_upscale(samples, width, height, "area", "disabled") + images_vl.append(s.movedim(1, -1)) + if vae is not None: + total = int(1024 * 1024) + scale_by = math.sqrt(total / (samples.shape[3] * samples.shape[2])) + width = round(samples.shape[3] * scale_by / 8.0) * 8 + height = round(samples.shape[2] * scale_by / 8.0) * 8 + + s = comfy.utils.common_upscale(samples, width, height, "area", "disabled") + ref_latents.append(vae.encode(s.movedim(1, -1)[:, :, :, :3])) + + image_prompt += "Picture {}: <|vision_start|><|image_pad|><|vision_end|>".format(i + 1) + + tokens = clip.tokenize(image_prompt + prompt, images=images_vl, llama_template=llama_template) + conditioning = clip.encode_from_tokens_scheduled(tokens) + if len(ref_latents) > 0: + conditioning = node_helpers.conditioning_set_values(conditioning, {"reference_latents": ref_latents}, append=True) + return io.NodeOutput(conditioning) + + +class EmptyQwenImageLayeredLatentImage(io.ComfyNode): + @classmethod + def define_schema(cls): + return io.Schema( + node_id="EmptyQwenImageLayeredLatentImage", + display_name="Empty Qwen Image Layered Latent", + category="model/latent/qwen", + inputs=[ + io.Int.Input("width", default=640, min=16, max=nodes.MAX_RESOLUTION, step=16), + io.Int.Input("height", default=640, min=16, max=nodes.MAX_RESOLUTION, step=16), + io.Int.Input("layers", default=3, min=0, max=nodes.MAX_RESOLUTION, step=1), + io.Int.Input("batch_size", default=1, min=1, max=4096), + ], + outputs=[ + io.Latent.Output(), + ], + ) + + @classmethod + def execute(cls, width, height, layers, batch_size=1) -> io.NodeOutput: + latent = torch.zeros([batch_size, 16, layers + 1, height // 8, width // 8], device=comfy.model_management.intermediate_device()) + return io.NodeOutput({"samples": latent}) + + +class QwenExtension(ComfyExtension): + @override + async def get_node_list(self) -> list[type[io.ComfyNode]]: + return [ + TextEncodeQwenImageEdit, + TextEncodeQwenImageEditPlus, + EmptyQwenImageLayeredLatentImage, + ] + + +async def comfy_entrypoint() -> QwenExtension: + return QwenExtension() diff --git a/docs/hel-892/promoted-reference/core-0.31.0__comfy_extras__nodes_textgen.py b/docs/hel-892/promoted-reference/core-0.31.0__comfy_extras__nodes_textgen.py new file mode 100644 index 00000000..5a947d5c --- /dev/null +++ b/docs/hel-892/promoted-reference/core-0.31.0__comfy_extras__nodes_textgen.py @@ -0,0 +1,186 @@ +from comfy_api.latest import ComfyExtension, io +from typing_extensions import override + +class TextGenerate(io.ComfyNode): + @classmethod + def define_schema(cls): + # Define dynamic combo options for sampling mode + sampling_options = [ + io.DynamicCombo.Option( + key="on", + inputs=[ + io.Float.Input("temperature", default=0.7, min=0.01, max=2.0, step=0.000001), + io.Int.Input("top_k", default=64, min=0, max=1000), + io.Float.Input("top_p", default=0.95, min=0.0, max=1.0, step=0.01), + io.Float.Input("min_p", default=0.05, min=0.0, max=1.0, step=0.01), + io.Float.Input("repetition_penalty", default=1.05, min=0.0, max=5.0, step=0.01), + io.Int.Input("seed", default=0, min=0, max=0xffffffffffffffff), + io.Float.Input("presence_penalty", optional=True, default=0.0, min=0.0, max=5.0, step=0.01), + ] + ), + io.DynamicCombo.Option( + key="off", + inputs=[] + ), + ] + + return io.Schema( + node_id="TextGenerate", + display_name="Generate Text", + category="text", + search_aliases=["LLM", "gemma"], + inputs=[ + io.Clip.Input("clip"), + io.String.Input("prompt", multiline=True, dynamic_prompts=True, default=""), + io.Image.Input("image", optional=True), + io.Image.Input("video", optional=True, tooltip="Video frames as image batch. Assumed to be 24 FPS; subsampled to 1 FPS internally."), + io.Audio.Input("audio", optional=True), + io.Int.Input("max_length", default=512, min=1, max=32768), + io.DynamicCombo.Input("sampling_mode", options=sampling_options, display_name="Sampling Mode"), + io.Boolean.Input("thinking", optional=True, default=False, tooltip="Operate in thinking mode if the model supports it."), + io.Boolean.Input("use_default_template", optional=True, default=True, tooltip="Use the built in system prompt/template if the model has one.", advanced=True), + ], + outputs=[ + io.String.Output(display_name="generated_text"), + ], + ) + + @classmethod + def execute(cls, clip, prompt, max_length, sampling_mode, image=None, thinking=False, use_default_template=True, video=None, audio=None) -> io.NodeOutput: + + tokens = clip.tokenize(prompt, image=image, skip_template=not use_default_template, min_length=1, thinking=thinking, video=video, audio=audio) + + # Get sampling parameters from dynamic combo + do_sample = sampling_mode.get("sampling_mode") == "on" + temperature = sampling_mode.get("temperature", 1.0) + top_k = sampling_mode.get("top_k", 50) + top_p = sampling_mode.get("top_p", 1.0) + min_p = sampling_mode.get("min_p", 0.0) + seed = sampling_mode.get("seed", None) + repetition_penalty = sampling_mode.get("repetition_penalty", 1.0) + presence_penalty = sampling_mode.get("presence_penalty", 0.0) + + generated_ids = clip.generate( + tokens, + do_sample=do_sample, + max_length=max_length, + temperature=temperature, + top_k=top_k, + top_p=top_p, + min_p=min_p, + repetition_penalty=repetition_penalty, + presence_penalty=presence_penalty, + seed=seed + ) + + generated_text = clip.decode(generated_ids) + + return io.NodeOutput(generated_text) + + +LTX2_T2V_SYSTEM_PROMPT = """You are a Creative Assistant. Given a user's raw input prompt describing a scene or concept, expand it into a detailed video generation prompt with specific visuals and integrated audio to guide a text-to-video model. +#### Guidelines +- Strictly follow all aspects of the user's raw input: include every element requested (style, visuals, motions, actions, camera movement, audio). + - If the input is vague, invent concrete details: lighting, textures, materials, scene settings, etc. + - For characters: describe gender, clothing, hair, expressions. DO NOT invent unrequested characters. +- Use active language: present-progressive verbs ("is walking," "speaking"). If no action specified, describe natural movements. +- Maintain chronological flow: use temporal connectors ("as," "then," "while"). +- Audio layer: Describe complete soundscape (background audio, ambient sounds, SFX, speech/music when requested). Integrate sounds chronologically alongside actions. Be specific (e.g., "soft footsteps on tile"), not vague (e.g., "ambient sound is present"). +- Speech (only when requested): + - For ANY speech-related input (talking, conversation, singing, etc.), ALWAYS include exact words in quotes with voice characteristics (e.g., "The man says in an excited voice: 'You won't believe what I just saw!'"). + - Specify language if not English and accent if relevant. +- Style: Include visual style at the beginning: "Style: