HEL-892: record pinned PreviewAny and promoted value evidence
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -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审本次实际代码增量;全量完成并审核后才部署。
|
||||
@@ -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/`,生产资格仍关闭。
|
||||
|
||||
@@ -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
|
||||
@@ -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"
|
||||
}
|
||||
@@ -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}
|
||||
@@ -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": "人工结论与机械原值清单分开;源语义局部审校非完整说明定稿"}
|
||||
@@ -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}
|
||||
@@ -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
|
||||
@@ -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"
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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"
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -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"
|
||||
}
|
||||
@@ -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}
|
||||
@@ -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"
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -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"
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -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
|
||||
+108
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
File diff suppressed because it is too large
Load Diff
+263
@@ -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<SubgraphInputEventMap>()
|
||||
|
||||
/** The linked widget that this slot is connected to. */
|
||||
private _widgetRef?: WeakRef<IBaseWidget>
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
+31
@@ -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
|
||||
}
|
||||
+326
@@ -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<string, 'image' | 'video' | 'audio'> = {
|
||||
LoadImage: 'image',
|
||||
LoadVideo: 'video',
|
||||
LoadAudio: 'audio'
|
||||
}
|
||||
|
||||
// Map node types to placeholder i18n keys
|
||||
const NODE_PLACEHOLDER_MAP: Record<string, string> = {
|
||||
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<string[]>([])
|
||||
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<object | string>)
|
||||
// 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
|
||||
}
|
||||
+100
@@ -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
|
||||
}
|
||||
+93
@@ -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
|
||||
}
|
||||
+95
@@ -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
|
||||
}
|
||||
@@ -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<string, any>,
|
||||
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
|
||||
}
|
||||
@@ -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<UUID, Map<WidgetId, WidgetState>>())
|
||||
|
||||
function getGraphWidgetStates(graphId: UUID): Map<WidgetId, WidgetState> {
|
||||
const widgetStates = graphWidgetStates.value.get(graphId)
|
||||
if (widgetStates) return widgetStates
|
||||
|
||||
const nextWidgetStates = reactive(new Map<WidgetId, WidgetState>())
|
||||
graphWidgetStates.value.set(graphId, nextWidgetStates)
|
||||
return nextWidgetStates
|
||||
}
|
||||
|
||||
function registerWidget<TValue = unknown>(
|
||||
widgetId: WidgetId,
|
||||
init: WidgetStateInit<TValue>
|
||||
): WidgetState<TValue> | 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<TValue>
|
||||
}
|
||||
|
||||
const { graphId, nodeId, name } = parseWidgetId(widgetId)
|
||||
const state: WidgetState<TValue> = {
|
||||
...init,
|
||||
nodeId,
|
||||
name,
|
||||
y: init.y ?? 0
|
||||
}
|
||||
const widgetStates = getGraphWidgetStates(graphId)
|
||||
widgetStates.set(widgetId, state)
|
||||
return widgetStates.get(widgetId) as WidgetState<TValue>
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
})
|
||||
@@ -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 = /^(?<graphId>[^:]+):(?<nodeId>[^:]+):(?<name>[^:]+)$/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)
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
File diff suppressed because it is too large
Load Diff
+253
@@ -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<SubgraphInputEventMap>()
|
||||
|
||||
/** The linked widget that this slot is connected to. */
|
||||
private _widgetRef?: WeakRef<IBaseWidget>
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
+51
@@ -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
|
||||
}
|
||||
+31
@@ -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
|
||||
}
|
||||
+325
@@ -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<string, 'image' | 'video' | 'audio'> = {
|
||||
LoadImage: 'image',
|
||||
LoadVideo: 'video',
|
||||
LoadAudio: 'audio'
|
||||
}
|
||||
|
||||
// Map node types to placeholder i18n keys
|
||||
const NODE_PLACEHOLDER_MAP: Record<string, string> = {
|
||||
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<string[]>([])
|
||||
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<object | string>)
|
||||
// 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
|
||||
}
|
||||
+100
@@ -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
|
||||
}
|
||||
+93
@@ -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
|
||||
}
|
||||
+95
@@ -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
|
||||
}
|
||||
@@ -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<string, any>,
|
||||
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
|
||||
}
|
||||
@@ -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<Record<string, WidgetValue>>
|
||||
restoreNamed: boolean
|
||||
}
|
||||
|
||||
function setNodeScoped<T>(
|
||||
graphMap: Map<UUID, Map<NodeId, T>>,
|
||||
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<T>(
|
||||
graphMap: Map<UUID, Map<NodeId, T>>,
|
||||
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<UUID, Map<WidgetId, WidgetState>>())
|
||||
const graphWidgetRenderStates = ref(
|
||||
new Map<UUID, Map<WidgetId, WidgetRenderState>>()
|
||||
)
|
||||
const graphNodeWidgetOrders = ref(new Map<UUID, Map<NodeId, WidgetId[]>>())
|
||||
const graphWidgetRestorations = new Map<
|
||||
UUID,
|
||||
Map<NodeId, WidgetRestorationState>
|
||||
>()
|
||||
|
||||
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<WidgetId, WidgetState> {
|
||||
const widgetStates = graphWidgetStates.value.get(graphId)
|
||||
if (widgetStates) return widgetStates
|
||||
|
||||
const nextWidgetStates = reactive(new Map<WidgetId, WidgetState>())
|
||||
graphWidgetStates.value.set(graphId, nextWidgetStates)
|
||||
return nextWidgetStates
|
||||
}
|
||||
|
||||
function getGraphWidgetRenderStates(
|
||||
graphId: UUID
|
||||
): Map<WidgetId, WidgetRenderState> {
|
||||
const widgetRenderStates = graphWidgetRenderStates.value.get(graphId)
|
||||
if (widgetRenderStates) return widgetRenderStates
|
||||
|
||||
const nextWidgetRenderStates = reactive(
|
||||
new Map<WidgetId, WidgetRenderState>()
|
||||
)
|
||||
graphWidgetRenderStates.value.set(graphId, nextWidgetRenderStates)
|
||||
return nextWidgetRenderStates
|
||||
}
|
||||
|
||||
function getGraphNodeWidgetOrders(graphId: UUID): Map<NodeId, WidgetId[]> {
|
||||
const widgetOrders = graphNodeWidgetOrders.value.get(graphId)
|
||||
if (widgetOrders) return widgetOrders
|
||||
|
||||
const nextWidgetOrders = reactive(new Map<NodeId, WidgetId[]>())
|
||||
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<WidgetId[]>([])
|
||||
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<TValue, TType, TOptions>,
|
||||
renderState: WidgetRenderState = {},
|
||||
_context?: RemoteMutationContext
|
||||
): WidgetState<TValue, TType, TOptions> | 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<TValue, TType, TOptions>
|
||||
}
|
||||
|
||||
const state: WidgetState<TValue, TType, TOptions> = {
|
||||
...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<TValue, TType, TOptions>
|
||||
}
|
||||
|
||||
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<WidgetState['options']>
|
||||
): 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
|
||||
}
|
||||
})
|
||||
@@ -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 = /^(?<graphId>[^:]+):(?<nodeId>[^:]+):(?<name>[^:]+)$/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<string>()
|
||||
const seen = new Set<unknown>()
|
||||
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)
|
||||
}
|
||||
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
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.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
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:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
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
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
@@ -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()
|
||||
@@ -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()
|
||||
@@ -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()
|
||||
@@ -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: <style>, <rest of prompt>." Default to cinematic-realistic if unspecified. Omit if unclear.
|
||||
- Visual and audio only: NO non-visual/auditory senses (smell, taste, touch).
|
||||
- Restrained language: Avoid dramatic/exaggerated terms. Use mild, natural phrasing.
|
||||
- Colors: Use plain terms ("red dress"), not intensified ("vibrant blue," "bright red").
|
||||
- Lighting: Use neutral descriptions ("soft overhead light"), not harsh ("blinding light").
|
||||
- Facial features: Use delicate modifiers for subtle features (i.e., "subtle freckles").
|
||||
|
||||
#### Important notes:
|
||||
- Analyze the user's raw input carefully. In cases of FPV or POV, exclude the description of the subject whose POV is requested.
|
||||
- Camera motion: DO NOT invent camera motion unless requested by the user.
|
||||
- Speech: DO NOT modify user-provided character dialogue unless it's a typo.
|
||||
- No timestamps or cuts: DO NOT use timestamps or describe scene cuts unless explicitly requested.
|
||||
- Format: DO NOT use phrases like "The scene opens with...". Start directly with Style (optional) and chronological scene description.
|
||||
- Format: DO NOT start your response with special characters.
|
||||
- DO NOT invent dialogue unless the user mentions speech/talking/singing/conversation.
|
||||
- If the user's raw input prompt is highly detailed, chronological and in the requested format: DO NOT make major edits or introduce new elements. Add/enhance audio descriptions if missing.
|
||||
|
||||
#### Output Format (Strict):
|
||||
- Single continuous paragraph in natural language (English).
|
||||
- NO titles, headings, prefaces, code fences, or Markdown.
|
||||
- If unsafe/invalid, return original user prompt. Never ask questions or clarifications.
|
||||
|
||||
Your output quality is CRITICAL. Generate visually rich, dynamic prompts with integrated audio for high-quality video generation.
|
||||
|
||||
#### Example
|
||||
Input: "A woman at a coffee shop talking on the phone"
|
||||
Output:
|
||||
Style: realistic with cinematic lighting. In a medium close-up, a woman in her early 30s with shoulder-length brown hair sits at a small wooden table by the window. She wears a cream-colored turtleneck sweater, holding a white ceramic coffee cup in one hand and a smartphone to her ear with the other. Ambient cafe sounds fill the space—espresso machine hiss, quiet conversations, gentle clinking of cups. The woman listens intently, nodding slightly, then takes a sip of her coffee and sets it down with a soft clink. Her face brightens into a warm smile as she speaks in a clear, friendly voice, 'That sounds perfect! I'd love to meet up this weekend. How about Saturday afternoon?' She laughs softly—a genuine chuckle—and shifts in her chair. Behind her, other patrons move subtly in and out of focus. 'Great, I'll see you then,' she concludes cheerfully, lowering the phone.
|
||||
"""
|
||||
|
||||
LTX2_I2V_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.
|
||||
You are a Creative Assistant writing concise, action-focused image-to-video prompts. Given an image (first frame) and user Raw Input Prompt, generate a prompt to guide video generation from that image.
|
||||
|
||||
#### Guidelines:
|
||||
- Analyze the Image: Identify Subject, Setting, Elements, Style and Mood.
|
||||
- Follow user Raw Input Prompt: Include all requested motion, actions, camera movements, audio, and details. If in conflict with the image, prioritize user request while maintaining visual consistency (describe transition from image to user's scene).
|
||||
- Describe only changes from the image: Don't reiterate established visual details. Inaccurate descriptions may cause scene cuts.
|
||||
- Active language: Use present-progressive verbs ("is walking," "speaking"). If no action specified, describe natural movements.
|
||||
- Chronological flow: Use temporal connectors ("as," "then," "while").
|
||||
- Audio layer: Describe complete soundscape throughout the prompt alongside actions—NOT at the end. Align audio intensity with action tempo. Include natural background audio, ambient sounds, effects, speech or music (when requested). Be specific (e.g., "soft footsteps on tile") not vague (e.g., "ambient sound").
|
||||
- Speech (only when requested): Provide exact words in quotes with character's visual/voice characteristics (e.g., "The tall man speaks in a low, gravelly voice"), language if not English and accent if relevant. If general conversation mentioned without text, generate contextual quoted dialogue. (i.e., "The man is talking" input -> the output should include exact spoken words, like: "The man is talking in an excited voice saying: 'You won't believe what I just saw!' His hands gesture expressively as he speaks, eyebrows raised with enthusiasm. The ambient sound of a quiet room underscores his animated speech.")
|
||||
- Style: Include visual style at beginning: "Style: <style>, <rest of prompt>." If unclear, omit to avoid conflicts.
|
||||
- Visual and audio only: Describe only what is seen and heard. NO smell, taste, or tactile sensations.
|
||||
- Restrained language: Avoid dramatic terms. Use mild, natural, understated phrasing.
|
||||
|
||||
#### Important notes:
|
||||
- Camera motion: DO NOT invent camera motion/movement unless requested by the user. Make sure to include camera motion only if specified in the input.
|
||||
- Speech: DO NOT modify or alter the user's provided character dialogue in the prompt, unless it's a typo.
|
||||
- No timestamps or cuts: DO NOT use timestamps or describe scene cuts unless explicitly requested.
|
||||
- Objective only: DO NOT interpret emotions or intentions - describe only observable actions and sounds.
|
||||
- Format: DO NOT use phrases like "The scene opens with..." / "The video starts...". Start directly with Style (optional) and chronological scene description.
|
||||
- Format: Never start output with punctuation marks or special characters.
|
||||
- DO NOT invent dialogue unless the user mentions speech/talking/singing/conversation.
|
||||
- Your performance is CRITICAL. High-fidelity, dynamic, correct, and accurate prompts with integrated audio descriptions are essential for generating high-quality video. Your goal is flawless execution of these rules.
|
||||
|
||||
#### Output Format (Strict):
|
||||
- Single concise paragraph in natural English. NO titles, headings, prefaces, sections, code fences, or Markdown.
|
||||
- If unsafe/invalid, return original user prompt. Never ask questions or clarifications.
|
||||
|
||||
#### Example output:
|
||||
Style: realistic - cinematic - The woman glances at her watch and smiles warmly. She speaks in a cheerful, friendly voice, "I think we're right on time!" In the background, a café barista prepares drinks at the counter. The barista calls out in a clear, upbeat tone, "Two cappuccinos ready!" The sound of the espresso machine hissing softly blends with gentle background chatter and the light clinking of cups on saucers.
|
||||
"""
|
||||
|
||||
class TextGenerateLTX2Prompt(TextGenerate):
|
||||
@classmethod
|
||||
def define_schema(cls):
|
||||
parent_schema = super().define_schema()
|
||||
return io.Schema(
|
||||
node_id="TextGenerateLTX2Prompt",
|
||||
display_name="Generate LTX2 Prompt",
|
||||
category=parent_schema.category,
|
||||
inputs=parent_schema.inputs,
|
||||
outputs=parent_schema.outputs,
|
||||
search_aliases=["prompt enhance", "LLM", "gemma"],
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def execute(cls, clip, prompt, max_length, sampling_mode, image=None, thinking=False, use_default_template=True, video=None, audio=None) -> io.NodeOutput:
|
||||
if image is None:
|
||||
formatted_prompt = f"<start_of_turn>system\n{LTX2_T2V_SYSTEM_PROMPT.strip()}<end_of_turn>\n<start_of_turn>user\nUser Raw Input Prompt: {prompt}.<end_of_turn>\n<start_of_turn>model\n"
|
||||
else:
|
||||
formatted_prompt = f"<start_of_turn>system\n{LTX2_I2V_SYSTEM_PROMPT.strip()}<end_of_turn>\n<start_of_turn>user\n\n<image_soft_token>\n\nUser Raw Input Prompt: {prompt}.<end_of_turn>\n<start_of_turn>model\n"
|
||||
return super().execute(clip, formatted_prompt, max_length, sampling_mode, image=image, thinking=thinking, use_default_template=use_default_template, video=video, audio=audio)
|
||||
|
||||
|
||||
class TextgenExtension(ComfyExtension):
|
||||
@override
|
||||
async def get_node_list(self) -> list[type[io.ComfyNode]]:
|
||||
return [
|
||||
TextGenerate,
|
||||
TextGenerateLTX2Prompt,
|
||||
]
|
||||
|
||||
async def comfy_entrypoint() -> TextgenExtension:
|
||||
return TextgenExtension()
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
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.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
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:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
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
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
@@ -0,0 +1,354 @@
|
||||
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, 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):
|
||||
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=MISSING, on_false=MISSING) -> io.NodeOutput:
|
||||
selected = on_true if switch else on_false
|
||||
return io.NodeOutput(None if selected is MISSING else selected)
|
||||
|
||||
|
||||
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()
|
||||
@@ -0,0 +1,77 @@
|
||||
import torch
|
||||
from typing_extensions import override
|
||||
|
||||
import comfy.model_management
|
||||
from comfy.ldm.minimax_music.ar import AUDIO_FRAMES_PER_SECOND, CFG_SCALE, CFG_TOP_K, C0_VOCAB_SIZE, MAX_AUDIO_FRAMES
|
||||
from comfy.ldm.minimax_music.dit import latent_length
|
||||
from comfy_api.latest import ComfyExtension, io
|
||||
|
||||
|
||||
class MiniMaxMusic3TextEncode(io.ComfyNode):
|
||||
@classmethod
|
||||
def define_schema(cls):
|
||||
return io.Schema(
|
||||
node_id="MiniMaxMusic3TextEncode",
|
||||
display_name="MiniMax Music3 Text Encode",
|
||||
category="model/conditioning/minimax music",
|
||||
description="Uses a MiniMax Music3 CLIP model to generate the acoustic conditioning sequence.",
|
||||
inputs=[
|
||||
io.Clip.Input("clip"),
|
||||
io.String.Input("caption", multiline=True, dynamic_prompts=True),
|
||||
io.String.Input("lyrics", multiline=True, dynamic_prompts=True),
|
||||
io.Int.Input("seed", default=0, min=0, max=0xffffffffffffffff, control_after_generate=True),
|
||||
io.Float.Input("max_duration", default=120.0, min=0.04, max=MAX_AUDIO_FRAMES / AUDIO_FRAMES_PER_SECOND, step=0.04, tooltip="Maximum duration in seconds; the model can end the song earlier."),
|
||||
io.Float.Input("cfg_scale", default=CFG_SCALE, min=0.0, max=100.0, step=0.1, round=0.01, advanced=True),
|
||||
io.Int.Input("top_k", default=CFG_TOP_K, min=1, max=C0_VOCAB_SIZE, advanced=True),
|
||||
],
|
||||
outputs=[
|
||||
io.Conditioning.Output(),
|
||||
io.Float.Output(display_name="seconds"),
|
||||
],
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def execute(cls, clip, caption, lyrics, seed, max_duration, cfg_scale, top_k):
|
||||
max_audio_frames = min(MAX_AUDIO_FRAMES, max(1, round(max_duration * AUDIO_FRAMES_PER_SECOND)))
|
||||
tokens = clip.tokenize(caption, lyrics=lyrics, seed=seed, max_audio_frames=max_audio_frames, cfg_scale=cfg_scale, top_k=top_k)
|
||||
conditioning = clip.encode_from_tokens_scheduled(tokens)
|
||||
for cond in conditioning:
|
||||
hidden = cond[0]
|
||||
cond[1]["conditioning_scale"] = torch.ones((hidden.shape[0], 1, 1), device=hidden.device, dtype=hidden.dtype)
|
||||
return io.NodeOutput(conditioning, conditioning[0][0].shape[1] / AUDIO_FRAMES_PER_SECOND)
|
||||
|
||||
|
||||
class EmptyMiniMaxMusic3LatentAudio(io.ComfyNode):
|
||||
@classmethod
|
||||
def define_schema(cls):
|
||||
return io.Schema(
|
||||
node_id="EmptyMiniMaxMusic3LatentAudio",
|
||||
display_name="Empty MiniMax Music3 Latent Audio",
|
||||
category="model/latent/minimax music",
|
||||
description="Creates an empty MiniMax Music3 audio latent for the requested duration.",
|
||||
inputs=[
|
||||
io.Float.Input("seconds", default=120.0, min=0.04, max=MAX_AUDIO_FRAMES / AUDIO_FRAMES_PER_SECOND, step=0.04),
|
||||
io.Int.Input("batch_size", default=1, min=1, max=4096),
|
||||
],
|
||||
outputs=[io.Latent.Output()],
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def execute(cls, seconds, batch_size):
|
||||
audio_frames = min(MAX_AUDIO_FRAMES, max(1, round(seconds * AUDIO_FRAMES_PER_SECOND)))
|
||||
latent = torch.zeros(
|
||||
(batch_size, 128, latent_length(audio_frames)),
|
||||
device=comfy.model_management.intermediate_device(),
|
||||
dtype=comfy.model_management.intermediate_dtype(),
|
||||
)
|
||||
return io.NodeOutput({"samples": latent, "type": "audio", "downscale_ratio_temporal": 512})
|
||||
|
||||
|
||||
class MiniMaxMusic3Extension(ComfyExtension):
|
||||
@override
|
||||
async def get_node_list(self):
|
||||
return [MiniMaxMusic3TextEncode, EmptyMiniMaxMusic3LatentAudio]
|
||||
|
||||
|
||||
async def comfy_entrypoint():
|
||||
return MiniMaxMusic3Extension()
|
||||
@@ -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 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()
|
||||
@@ -0,0 +1,250 @@
|
||||
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",
|
||||
display_name="Text Encode Qwen Image Edit",
|
||||
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",
|
||||
display_name="Text Encode Qwen Image Edit Plus",
|
||||
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 TextEncodeQwenImage21(io.ComfyNode):
|
||||
@classmethod
|
||||
def define_schema(cls):
|
||||
return io.Schema(
|
||||
node_id="TextEncodeQwenImage21",
|
||||
display_name="Text Encode Qwen Image 2.1",
|
||||
category="model/conditioning/qwen image",
|
||||
inputs=[
|
||||
io.Clip.Input("clip"),
|
||||
io.String.Input("prompt", multiline=True, dynamic_prompts=True),
|
||||
io.String.Input("negative_prompt", multiline=True, dynamic_prompts=True),
|
||||
io.Vae.Input("vae", optional=True),
|
||||
io.Int.Input("resolution", default=1024, min=0, max=4096, step=32,
|
||||
tooltip="Reference images are resized to about resolution x resolution pixels, at multiples of 32, preserving aspect ratio. 0 keeps each reference at its own size, rounded to a multiple of 32. "),
|
||||
io.Autogrow.Input(
|
||||
"images",
|
||||
template=io.Autogrow.TemplateNames(
|
||||
io.Image.Input("image"),
|
||||
names=[f"image_{i}" for i in range(1, 17)],
|
||||
min=0,
|
||||
),
|
||||
tooltip="Reference images, seen by the text encoder and spliced into the sequence as VAE latents.",
|
||||
),
|
||||
],
|
||||
outputs=[
|
||||
io.Conditioning.Output(display_name="positive"),
|
||||
io.Conditioning.Output(display_name="negative"),
|
||||
io.Latent.Output(display_name="latent",
|
||||
tooltip="Empty latent on the first reference image's size, to match with sampling as any other size shifts the edit."),
|
||||
],
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def execute(cls, clip, prompt, negative_prompt, vae=None, resolution=1024, images: io.Autogrow.Type = None) -> io.NodeOutput:
|
||||
ref_latents = []
|
||||
images_vl = []
|
||||
images = images or {}
|
||||
latent_w = latent_h = resolution or 1024
|
||||
for name in sorted(images, key=lambda n: int(n.rsplit("_", 1)[-1])):
|
||||
image = images[name]
|
||||
if image is None:
|
||||
continue
|
||||
# same resize for the text encoder and the VAE, so every vision slot covers 2x2 latents; one image per input
|
||||
samples = image[:1].movedim(-1, 1)
|
||||
if resolution > 0:
|
||||
ratio = samples.shape[3] / samples.shape[2]
|
||||
width = round(math.sqrt(resolution * resolution * ratio) / 32) * 32
|
||||
height = round(math.sqrt(resolution * resolution / ratio) / 32) * 32
|
||||
else:
|
||||
width, height = round(samples.shape[3] / 32) * 32, round(samples.shape[2] / 32) * 32
|
||||
width, height = max(32, width), max(32, height)
|
||||
if (width, height) == (samples.shape[3], samples.shape[2]):
|
||||
s = image[:1]
|
||||
else:
|
||||
s = comfy.utils.common_upscale(samples, width, height, "lanczos", "disabled").movedim(1, -1)
|
||||
if not images_vl:
|
||||
latent_w, latent_h = width, height
|
||||
rgb = s[:, :, :, :3]
|
||||
if s.shape[-1] > 3:
|
||||
rgb = rgb * s[:, :, :, 3:] + (1.0 - s[:, :, :, 3:]) # the vision tower sees alpha over white, the vae keeps all four
|
||||
images_vl.append(rgb)
|
||||
if vae is not None:
|
||||
ref_latents.append(vae.encode(s))
|
||||
|
||||
keep_vision = len(ref_latents) == 0
|
||||
positive = clip.encode_from_tokens_scheduled(clip.tokenize(prompt, images=images_vl, keep_vision=keep_vision, prevent_empty_text=True))
|
||||
negative = clip.encode_from_tokens_scheduled(clip.tokenize(negative_prompt, images=images_vl, keep_vision=keep_vision, prevent_empty_text=True))
|
||||
if len(ref_latents) > 0:
|
||||
positive = node_helpers.conditioning_set_values(positive, {"reference_latents": ref_latents}, append=True)
|
||||
negative = node_helpers.conditioning_set_values(negative, {"reference_latents": ref_latents}, append=True)
|
||||
latent = torch.zeros([1, 64, latent_h // 16, latent_w // 16], device=comfy.model_management.intermediate_device())
|
||||
return io.NodeOutput(positive, negative, {"samples": latent})
|
||||
|
||||
|
||||
class QwenImage21Cache(io.ComfyNode):
|
||||
@classmethod
|
||||
def define_schema(cls):
|
||||
return io.Schema(
|
||||
node_id="QwenImage21Cache",
|
||||
display_name="Qwen Image 2.1 Cache",
|
||||
category="model/conditioning/qwen image",
|
||||
description=(
|
||||
"Allows setting the KV cache device and quantization, by default the model uses the auto -option. Quantization potentially speeds up edit workflows when memory starved "
|
||||
),
|
||||
inputs=[
|
||||
io.Model.Input("model"),
|
||||
io.Combo.Input("device", options=["auto", "gpu", "cpu", "off"], default="auto",
|
||||
tooltip="auto uses spare VRAM, then RAM. cpu (RAM) is prefetched behind compute and costs little speed. off recomputes the prefix every step, which is slower but is the one way to rule the cache out."),
|
||||
io.Combo.Input("dtype", options=["default", "int8", "int4"], default="default",
|
||||
tooltip="Storage precision. default is lossless. int8 halves the cache at about bf16 accuracy, int4 quarters it but roughly doubles the per-step error."),
|
||||
],
|
||||
outputs=[io.Model.Output()],
|
||||
is_experimental=True,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def execute(cls, model, device, dtype) -> io.NodeOutput:
|
||||
m = model.clone()
|
||||
m.model_options["transformer_options"]["qwen_image21_cache"] = {"device": device, "dtype": dtype}
|
||||
return io.NodeOutput(m)
|
||||
|
||||
|
||||
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,
|
||||
TextEncodeQwenImage21,
|
||||
QwenImage21Cache,
|
||||
EmptyQwenImageLayeredLatentImage,
|
||||
]
|
||||
|
||||
|
||||
async def comfy_entrypoint() -> QwenExtension:
|
||||
return QwenExtension()
|
||||
@@ -0,0 +1,282 @@
|
||||
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),
|
||||
io.Combo.Input("mtp", options=["auto", "off", "2", "3", "4", "5"], default="auto", optional=True, tooltip="Speculative decoding with the checkpoint's multi-token-prediction head. No effect without MTP weights. auto adapts the draft depth; 2-5 pins it. Sampled output stays correctly distributed but differs from non-MTP output for the same seed."),
|
||||
io.String.Input("system_prompt", force_input=True, optional=True, tooltip="Replaces the system prompt in the model's chat template. Ignored when the default template is not used."),
|
||||
],
|
||||
outputs=[
|
||||
io.String.Output(display_name="generated_text"),
|
||||
io.String.Output(display_name="thinking"),
|
||||
],
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def execute(cls, clip, prompt, max_length, sampling_mode, image=None, thinking=False, use_default_template=True, video=None, audio=None, mtp="auto", system_prompt="") -> io.NodeOutput:
|
||||
|
||||
mtp = False if mtp == "off" else (True if mtp == "auto" else int(mtp))
|
||||
|
||||
tokens = clip.tokenize(prompt, image=image, skip_template=not use_default_template, min_length=1, thinking=thinking, video=video, audio=audio, system_prompt=system_prompt if use_default_template else "")
|
||||
|
||||
# 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,
|
||||
mtp=mtp
|
||||
)
|
||||
|
||||
generated_text = clip.decode(generated_ids)
|
||||
|
||||
# Reasoning opens in the generated text or at the end of a raw prompt, and has no close when max_length cut it short.
|
||||
reasoning, _, text = generated_text.partition("</think>")
|
||||
if not reasoning.lstrip().startswith("<think>") and not prompt.rstrip().endswith("<think>"):
|
||||
reasoning, text = "", generated_text
|
||||
|
||||
return io.NodeOutput(text.strip(), reasoning.replace("<think>", "", 1).strip())
|
||||
|
||||
|
||||
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: <style>, <rest of prompt>." Default to cinematic-realistic if unspecified. Omit if unclear.
|
||||
- Visual and audio only: NO non-visual/auditory senses (smell, taste, touch).
|
||||
- Restrained language: Avoid dramatic/exaggerated terms. Use mild, natural phrasing.
|
||||
- Colors: Use plain terms ("red dress"), not intensified ("vibrant blue," "bright red").
|
||||
- Lighting: Use neutral descriptions ("soft overhead light"), not harsh ("blinding light").
|
||||
- Facial features: Use delicate modifiers for subtle features (i.e., "subtle freckles").
|
||||
|
||||
#### Important notes:
|
||||
- Analyze the user's raw input carefully. In cases of FPV or POV, exclude the description of the subject whose POV is requested.
|
||||
- Camera motion: DO NOT invent camera motion unless requested by the user.
|
||||
- Speech: DO NOT modify user-provided character dialogue unless it's a typo.
|
||||
- No timestamps or cuts: DO NOT use timestamps or describe scene cuts unless explicitly requested.
|
||||
- Format: DO NOT use phrases like "The scene opens with...". Start directly with Style (optional) and chronological scene description.
|
||||
- Format: DO NOT start your response with special characters.
|
||||
- DO NOT invent dialogue unless the user mentions speech/talking/singing/conversation.
|
||||
- If the user's raw input prompt is highly detailed, chronological and in the requested format: DO NOT make major edits or introduce new elements. Add/enhance audio descriptions if missing.
|
||||
|
||||
#### Output Format (Strict):
|
||||
- Single continuous paragraph in natural language (English).
|
||||
- NO titles, headings, prefaces, code fences, or Markdown.
|
||||
- If unsafe/invalid, return original user prompt. Never ask questions or clarifications.
|
||||
|
||||
Your output quality is CRITICAL. Generate visually rich, dynamic prompts with integrated audio for high-quality video generation.
|
||||
|
||||
#### Example
|
||||
Input: "A woman at a coffee shop talking on the phone"
|
||||
Output:
|
||||
Style: realistic with cinematic lighting. In a medium close-up, a woman in her early 30s with shoulder-length brown hair sits at a small wooden table by the window. She wears a cream-colored turtleneck sweater, holding a white ceramic coffee cup in one hand and a smartphone to her ear with the other. Ambient cafe sounds fill the space—espresso machine hiss, quiet conversations, gentle clinking of cups. The woman listens intently, nodding slightly, then takes a sip of her coffee and sets it down with a soft clink. Her face brightens into a warm smile as she speaks in a clear, friendly voice, 'That sounds perfect! I'd love to meet up this weekend. How about Saturday afternoon?' She laughs softly—a genuine chuckle—and shifts in her chair. Behind her, other patrons move subtly in and out of focus. 'Great, I'll see you then,' she concludes cheerfully, lowering the phone.
|
||||
"""
|
||||
|
||||
LTX2_I2V_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.
|
||||
You are a Creative Assistant writing concise, action-focused image-to-video prompts. Given an image (first frame) and user Raw Input Prompt, generate a prompt to guide video generation from that image.
|
||||
|
||||
#### Guidelines:
|
||||
- Analyze the Image: Identify Subject, Setting, Elements, Style and Mood.
|
||||
- Follow user Raw Input Prompt: Include all requested motion, actions, camera movements, audio, and details. If in conflict with the image, prioritize user request while maintaining visual consistency (describe transition from image to user's scene).
|
||||
- Describe only changes from the image: Don't reiterate established visual details. Inaccurate descriptions may cause scene cuts.
|
||||
- Active language: Use present-progressive verbs ("is walking," "speaking"). If no action specified, describe natural movements.
|
||||
- Chronological flow: Use temporal connectors ("as," "then," "while").
|
||||
- Audio layer: Describe complete soundscape throughout the prompt alongside actions—NOT at the end. Align audio intensity with action tempo. Include natural background audio, ambient sounds, effects, speech or music (when requested). Be specific (e.g., "soft footsteps on tile") not vague (e.g., "ambient sound").
|
||||
- Speech (only when requested): Provide exact words in quotes with character's visual/voice characteristics (e.g., "The tall man speaks in a low, gravelly voice"), language if not English and accent if relevant. If general conversation mentioned without text, generate contextual quoted dialogue. (i.e., "The man is talking" input -> the output should include exact spoken words, like: "The man is talking in an excited voice saying: 'You won't believe what I just saw!' His hands gesture expressively as he speaks, eyebrows raised with enthusiasm. The ambient sound of a quiet room underscores his animated speech.")
|
||||
- Style: Include visual style at beginning: "Style: <style>, <rest of prompt>." If unclear, omit to avoid conflicts.
|
||||
- Visual and audio only: Describe only what is seen and heard. NO smell, taste, or tactile sensations.
|
||||
- Restrained language: Avoid dramatic terms. Use mild, natural, understated phrasing.
|
||||
|
||||
#### Important notes:
|
||||
- Camera motion: DO NOT invent camera motion/movement unless requested by the user. Make sure to include camera motion only if specified in the input.
|
||||
- Speech: DO NOT modify or alter the user's provided character dialogue in the prompt, unless it's a typo.
|
||||
- No timestamps or cuts: DO NOT use timestamps or describe scene cuts unless explicitly requested.
|
||||
- Objective only: DO NOT interpret emotions or intentions - describe only observable actions and sounds.
|
||||
- Format: DO NOT use phrases like "The scene opens with..." / "The video starts...". Start directly with Style (optional) and chronological scene description.
|
||||
- Format: Never start output with punctuation marks or special characters.
|
||||
- DO NOT invent dialogue unless the user mentions speech/talking/singing/conversation.
|
||||
- Your performance is CRITICAL. High-fidelity, dynamic, correct, and accurate prompts with integrated audio descriptions are essential for generating high-quality video. Your goal is flawless execution of these rules.
|
||||
|
||||
#### Output Format (Strict):
|
||||
- Single concise paragraph in natural English. NO titles, headings, prefaces, sections, code fences, or Markdown.
|
||||
- If unsafe/invalid, return original user prompt. Never ask questions or clarifications.
|
||||
|
||||
#### Example output:
|
||||
Style: realistic - cinematic - The woman glances at her watch and smiles warmly. She speaks in a cheerful, friendly voice, "I think we're right on time!" In the background, a café barista prepares drinks at the counter. The barista calls out in a clear, upbeat tone, "Two cappuccinos ready!" The sound of the espresso machine hissing softly blends with gentle background chatter and the light clinking of cups on saucers.
|
||||
"""
|
||||
|
||||
LTX24_T2V_SYSTEM_PROMPT = """You are given a user's short text-to-video request. Write a single, highly detailed audio-visual caption describing the video that best fulfills that request, in the EXACT style of the training captions used for this video model. The generated video is scored against the user's ORIGINAL request, so preserve every element the user stated; expand faithfully into the full caption style without contradicting or dropping anything they asked for.
|
||||
|
||||
Match this captioning style precisely:
|
||||
|
||||
1. Begin immediately with the action or visual detail. Do NOT use "The scene opens…", "We see…", "There is…".
|
||||
|
||||
2. Objective, observable description only. Do not infer emotions or intentions — describe what is visible and audible (e.g. not "he looks sad" but "his eyebrows angle downward and his lips are pressed together").
|
||||
|
||||
3. Full visual detail: environment (materials, textures, lighting, colors), character appearance (clothing, posture, facial details), and the spatial positioning of all elements. When a human appears, identify them specifically (gendered terms when clearly implied; differentiate multiple people consistently) and describe visible physical attributes — apparent gender presentation, skin tone, estimated age group, hair color/length/style, build, clothing and accessories. Do not infer ethnicity, nationality, religion, or culture.
|
||||
|
||||
4. Precise motion and cinematic description. For every shot you MUST include, woven naturally into the prose (never as tags or labels):
|
||||
- Shot type (exactly one: extreme wide shot / wide shot / medium shot / medium close-up / close-up / extreme close-up)
|
||||
- Camera motion (always stated; if none, explicitly say the camera remains static). Camera movement is expected and good — match the user if they specified it, otherwise choose the treatment that best presents the requested scene.
|
||||
- Camera viewpoint relative to subject (front-facing / back-facing / side view / over-the-shoulder / top-down / low-angle / high-angle).
|
||||
Express these as flowing prose: "a medium shot frames…, captured from a front-facing angle as the camera slowly pans…". Never as "medium shot, static camera —".
|
||||
|
||||
5. Complete soundscape, integrated naturally: any dialogue (quote it exactly, in the original language), tone of voice, background music (type, mood, volume changes), and environmental sounds (footsteps, wind, traffic, animals). If the request implies sound, describe it plausibly.
|
||||
|
||||
6. Strict chronological, real-time flow using transitions like "Initially…", "A moment later…", "Simultaneously…". Keep every stated action in motion.
|
||||
|
||||
7. One single continuous paragraph. No bullet points, no section headers, no labels like "Audio:" or "Visual:". Exhaustive and lossless — include background elements, subtle movements, lighting, secondary sounds — detailed enough to reconstruct the scene. Aim for a rich, complete paragraph (roughly 150–220 words).
|
||||
|
||||
If the user wrote in another language, produce the English caption of the same content. Output ONLY the caption text — no JSON, no preamble.
|
||||
|
||||
AESTHETIC QUALITY (in addition to the above, without breaking the objective caption style): render the described scene with strong visual production value — cinematic, film-grade color and contrast, beautiful natural lighting, crisp fine detail and texture, pleasing composition and depth. Weave these quality descriptors naturally into the same observable prose (e.g. "warm cinematic lighting", "richly saturated film-grade color", "crisp high-resolution detail") — describe how the exact requested scene LOOKS at its most visually striking, never adding new objects or actions. Keep everything else (framing triple, soundscape, chronological single paragraph, faithfulness) exactly as specified.
|
||||
"""
|
||||
|
||||
|
||||
LTX24_I2V_SYSTEM_PROMPT = """You are given a REFERENCE IMAGE (the exact first frame of the video) and a user's short image-to-video request. Write a single, highly detailed audio-visual caption describing the video that BEGINS from this exact reference image and best fulfills that request, in the EXACT style of the training captions used for this video model. The generated video is scored against the user's ORIGINAL request, so preserve every element the user stated; expand faithfully into the full caption style without contradicting or dropping anything they asked for.
|
||||
|
||||
FIRST-FRAME / IMAGE GROUNDING (do this first): the opening of your caption must match the reference image exactly — same subject(s), identity, appearance, clothing, setting, lighting, and composition as shown. The video starts on this frame; describe it faithfully, then narrate chronologically as the user's requested action unfolds from it. Never contradict, replace, or invent things not consistent with the image. Single continuous take — no hard cuts.
|
||||
|
||||
Match this captioning style precisely:
|
||||
|
||||
1. Begin immediately with the action or visual detail. Do NOT use "The scene opens…", "We see…", "There is…".
|
||||
|
||||
2. Objective, observable description only. Do not infer emotions or intentions — describe what is visible and audible (e.g. not "he looks sad" but "his eyebrows angle downward and his lips are pressed together").
|
||||
|
||||
3. Full visual detail: environment (materials, textures, lighting, colors), character appearance (clothing, posture, facial details), and the spatial positioning of all elements — grounded in and consistent with the reference image. When a human appears, identify them specifically (gendered terms when clearly implied; differentiate multiple people consistently) and describe visible physical attributes — apparent gender presentation, skin tone, estimated age group, hair color/length/style, build, clothing and accessories. Do not infer ethnicity, nationality, religion, or culture.
|
||||
|
||||
4. Precise motion and cinematic description. For every shot you MUST include, woven naturally into the prose (never as tags or labels):
|
||||
- Shot type (exactly one: extreme wide shot / wide shot / medium shot / medium close-up / close-up / extreme close-up) — consistent with how the reference image is framed at the start.
|
||||
- Camera motion (always stated; if none, explicitly say the camera remains static). Camera movement is expected and good — match the user if they specified it, otherwise choose the treatment that best presents the requested scene starting from this frame.
|
||||
- Camera viewpoint relative to subject (front-facing / back-facing / side view / over-the-shoulder / top-down / low-angle / high-angle) — matching the reference image's viewpoint at the opening.
|
||||
Express these as flowing prose: "a medium shot frames…, captured from a front-facing angle as the camera slowly pans…". Never as "medium shot, static camera —".
|
||||
|
||||
5. Complete soundscape, integrated naturally: any dialogue (quote it exactly, in the original language), tone of voice, background music (type, mood, volume changes), and environmental sounds (footsteps, wind, traffic, animals). If the request implies sound, describe it plausibly.
|
||||
|
||||
6. Strict chronological, real-time flow using transitions like "Initially…", "A moment later…", "Simultaneously…". Keep the user's requested motion/action central and in motion throughout.
|
||||
|
||||
7. One single continuous paragraph. No bullet points, no section headers, no labels like "Audio:" or "Visual:". Exhaustive and lossless — include background elements, subtle movements, lighting, secondary sounds — detailed enough to reconstruct the scene. Aim for a rich, complete paragraph (roughly 150–220 words).
|
||||
|
||||
If the user wrote in another language, produce the English caption of the same content. Output ONLY the caption text — no JSON, no preamble.
|
||||
|
||||
AESTHETIC QUALITY (in addition to the above, without breaking the objective caption style or contradicting the reference image): render the described scene with strong visual production value — cinematic, film-grade color and contrast, beautiful natural lighting, crisp fine detail and texture, pleasing composition and depth. Weave these quality descriptors naturally into the same observable prose (e.g. "warm cinematic lighting", "richly saturated film-grade color", "crisp high-resolution detail") — describe how the exact requested scene, starting from this frame, LOOKS at its most visually striking, never adding new objects or actions and never contradicting the first frame. Keep everything else (first-frame grounding, framing triple, soundscape, chronological single paragraph, faithfulness) exactly as specified.
|
||||
"""
|
||||
|
||||
|
||||
class TextGenerateLTX2Prompt(TextGenerate):
|
||||
@classmethod
|
||||
def define_schema(cls):
|
||||
parent_schema = super().define_schema()
|
||||
return io.Schema(
|
||||
node_id="TextGenerateLTX2Prompt",
|
||||
display_name="Generate LTX2 Prompt",
|
||||
category=parent_schema.category,
|
||||
inputs=parent_schema.inputs,
|
||||
outputs=parent_schema.outputs,
|
||||
search_aliases=["prompt enhance", "LLM", "gemma"],
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def execute(cls, clip, prompt, max_length, sampling_mode, image=None, thinking=False, use_default_template=True, video=None, audio=None, mtp="auto", system_prompt="") -> io.NodeOutput:
|
||||
# Gemma 3 and Gemma 4 use different chat-turn markers and image tokens.
|
||||
# The Gemma 4 text encoder is the LTX 2.4 path; Gemma 3 is LTX 2.0.
|
||||
is_gemma4 = "gemma4" in getattr(clip.tokenizer, "clip_name", "")
|
||||
|
||||
if is_gemma4:
|
||||
if image is not None:
|
||||
system = system_prompt.strip() or LTX24_I2V_SYSTEM_PROMPT.strip()
|
||||
user_text = f"User Raw Input Prompt: {prompt}."
|
||||
else:
|
||||
system = system_prompt.strip() or LTX24_T2V_SYSTEM_PROMPT.strip()
|
||||
user_text = f"user prompt: {prompt}"
|
||||
think_prefix = "<|think|>\n" if thinking else ""
|
||||
model_open = "" if thinking else "<|channel>final\n"
|
||||
media = "<|image><|image|><image|>\n\n" if image is not None else ""
|
||||
formatted_prompt = (
|
||||
f"<|turn>system\n{think_prefix}{system}<turn|>\n"
|
||||
f"<|turn>user\n{media}{user_text}<turn|>\n"
|
||||
f"<|turn>model\n{model_open}"
|
||||
)
|
||||
else:
|
||||
system = system_prompt.strip() or (LTX2_I2V_SYSTEM_PROMPT if image is not None else LTX2_T2V_SYSTEM_PROMPT).strip()
|
||||
media = "\n<image_soft_token>\n" if image is not None else ""
|
||||
formatted_prompt = (
|
||||
f"<start_of_turn>system\n{system}<end_of_turn>\n"
|
||||
f"<start_of_turn>user\n{media}\nUser Raw Input Prompt: {prompt}.<end_of_turn>\n"
|
||||
f"<start_of_turn>model\n"
|
||||
)
|
||||
|
||||
out = super().execute(clip, formatted_prompt, max_length, sampling_mode, image=image, thinking=thinking, use_default_template=use_default_template, video=video, audio=audio, mtp=mtp)
|
||||
|
||||
# Both system prompts ask for the original prompt back when there is nothing to give; empty conditions on nothing.
|
||||
return io.NodeOutput(out.args[0] or prompt, out.args[1])
|
||||
|
||||
|
||||
class TextgenExtension(ComfyExtension):
|
||||
@override
|
||||
async def get_node_list(self) -> list[type[io.ComfyNode]]:
|
||||
return [
|
||||
TextGenerate,
|
||||
TextGenerateLTX2Prompt,
|
||||
]
|
||||
|
||||
async def comfy_entrypoint() -> TextgenExtension:
|
||||
return TextgenExtension()
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"ref": "refs/tags/v0.31.0",
|
||||
"node_id": "REF_kwDOIygeJrFyZWZzL3RhZ3MvdjAuMzEuMA",
|
||||
"url": "https://api.github.com/repos/Comfy-Org/ComfyUI/git/refs/tags/v0.31.0",
|
||||
"object": {
|
||||
"sha": "43cb4fffc89bba20ab7bd61467a36d0339338dab",
|
||||
"type": "commit",
|
||||
"url": "https://api.github.com/repos/Comfy-Org/ComfyUI/git/commits/43cb4fffc89bba20ab7bd61467a36d0339338dab"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"ref": "refs/tags/v0.38.0",
|
||||
"node_id": "REF_kwDOIygeJrFyZWZzL3RhZ3MvdjAuMzguMA",
|
||||
"url": "https://api.github.com/repos/Comfy-Org/ComfyUI/git/refs/tags/v0.38.0",
|
||||
"object": {
|
||||
"sha": "6b747c0428c343e1417219641db93a4fb7cb69ae",
|
||||
"type": "commit",
|
||||
"url": "https://api.github.com/repos/Comfy-Org/ComfyUI/git/commits/6b747c0428c343e1417219641db93a4fb7cb69ae"
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,31 @@
|
||||
[
|
||||
{
|
||||
"version": "0.31.0",
|
||||
"commit": "43cb4fffc89bba20ab7bd61467a36d0339338dab",
|
||||
"tree_raw_url": "https://api.github.com/repos/Comfy-Org/ComfyUI/git/trees/43cb4fffc89bba20ab7bd61467a36d0339338dab?recursive=1",
|
||||
"tree_sha256": "a301df0e968dee355a92afa84e3b6252de8eec054efbe6e611429149df49b2d2",
|
||||
"tree_retrieved_at": "2026-10-29T16:40:21.102247+00:00",
|
||||
"truncated": false,
|
||||
"minimax_music_named_paths": [],
|
||||
"limit": "file path search only; does not claim exhaustive absence of class declarations in all files"
|
||||
},
|
||||
{
|
||||
"version": "0.38.0",
|
||||
"commit": "6b747c0428c343e1417219641db93a4fb7cb69ae",
|
||||
"tree_raw_url": "https://api.github.com/repos/Comfy-Org/ComfyUI/git/trees/6b747c0428c343e1417219641db93a4fb7cb69ae?recursive=1",
|
||||
"tree_sha256": "d2389807d456d8b68ec6b15d4f609a7e31ee6bf459e0620697fce652b472a185",
|
||||
"tree_retrieved_at": "2026-10-29T16:40:24.128970+00:00",
|
||||
"truncated": false,
|
||||
"minimax_music_named_paths": [
|
||||
"comfy/ldm/minimax_music",
|
||||
"comfy/ldm/minimax_music/__init__.py",
|
||||
"comfy/ldm/minimax_music/ar.py",
|
||||
"comfy/ldm/minimax_music/dav.py",
|
||||
"comfy/ldm/minimax_music/dit.py",
|
||||
"comfy/ldm/minimax_music/prompt.py",
|
||||
"comfy/text_encoders/minimax_music.py",
|
||||
"comfy_extras/nodes_minimax_music.py"
|
||||
],
|
||||
"limit": "file path search only; does not claim exhaustive absence of class declarations in all files"
|
||||
}
|
||||
]
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user