Publish current ComfyUI O1Key code baseline

Replace the prior release tree with the current plugin, frontend, tests, and documentation. Document retired node IDs and the public Gitea update source.
This commit is contained in:
Jony
2026-09-24 19:56:48 +08:00
parent 3e337722ab
commit ba920f2b66
183 changed files with 49496 additions and 9934 deletions
+59
View File
@@ -0,0 +1,59 @@
import { app } from "../../../scripts/app.js";
// ── DynamicCombo 节点加载工作流后被自动缩小的修复 ─────────────────────────────
//
// 现象:把含 DynamicCombo 的节点(如「K3 图生视频 首尾帧 多分镜」)手动拉大,
// 切走再切回工作流,节点高度会被自动压扁。
//
// 根因(ComfyUI 核心行为,非本仓库代码):
// core/graph/widgets/dynamicWidgets.ts 的 updateWidgets() 在重建子控件后执行
// node.size[1] = node.computeSize([...node.size])[1]
// 把高度强制压回「最小内容高」。而 LGraphNode.configure() 的顺序是:
// 1) 先把 this.size 还原成保存的(被用户拉大的)尺寸
// 2) 再还原 widgets_values —— 给 DynamicCombo 赋值触发上面那行,高度被压扁
// 3) 最后才触发 onConfigure
// 所以只压高度、宽度不变,表现为节点「自动缩小」。
//
// 修复:在 onConfigure(此时压扁已发生,但保存尺寸仍在 info.size 里)把尺寸还原回去。
// 仅当当前尺寸比保存值更小时才还原,避免覆盖其它合理布局。
function hasDynamicCombo(nodeData) {
try {
return JSON.stringify(nodeData?.input ?? {}).includes("COMFY_DYNAMICCOMBO_V3");
} catch (e) {
return false;
}
}
app.registerExtension({
name: "o1key.keepNodeSize",
beforeRegisterNodeDef(nodeType, nodeData) {
if (!hasDynamicCombo(nodeData)) return;
const origOnConfigure = nodeType.prototype.onConfigure;
nodeType.prototype.onConfigure = function (info) {
origOnConfigure?.apply(this, arguments);
const saved = info?.size;
if (!saved) return;
const savedW = Number(saved[0]) || Number(saved["0"]) || 0;
const savedH = Number(saved[1]) || Number(saved["1"]) || 0;
if (savedW <= 0 && savedH <= 0) return;
const restore = () => {
const w = Math.max(this.size[0], savedW);
const h = Math.max(this.size[1], savedH);
// 仅在被压小时还原,避免无谓重排
if (this.size[0] < w - 0.5 || this.size[1] < h - 0.5) {
this.setSize([w, h]);
this.setDirtyCanvas?.(true, true);
}
};
restore();
// 兜底:个别布局在下一帧才结算,再还原一次(已加守卫,幂等)
requestAnimationFrame(restore);
};
},
});