Turns ou, graph.subgraphs is an optional property; maybe older comfyuis. Fixes #561
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "rgthree-comfy"
|
||||
description = "Making ComfyUI more comfortable."
|
||||
version = "1.0.2508162219"
|
||||
version = "1.0.2508180854"
|
||||
license = { file = "LICENSE" }
|
||||
dependencies = []
|
||||
|
||||
|
||||
@@ -166,9 +166,11 @@ class FastGroupsService {
|
||||
(!this.groupsUnsorted.length || now - this.msLastUnsorted > this.msThreshold)
|
||||
) {
|
||||
this.groupsUnsorted = [...graph._groups];
|
||||
const subgraphs = graph.subgraphs.values();
|
||||
let s;
|
||||
while ((s = subgraphs.next().value)) this.groupsUnsorted.push(...(s.groups ?? []));
|
||||
const subgraphs = graph.subgraphs?.values();
|
||||
if (subgraphs) {
|
||||
let s;
|
||||
while ((s = subgraphs.next().value)) this.groupsUnsorted.push(...(s.groups ?? []));
|
||||
}
|
||||
for (const group of this.groupsUnsorted) {
|
||||
this.recomputeInsideNodesForGroup(group);
|
||||
group.rgthree_hasAnyActiveNode = getGroupNodes(group).some(
|
||||
|
||||
@@ -787,10 +787,12 @@ export function getLinkById(linkId?: number | null) {
|
||||
if (linkId == null) return null;
|
||||
let link: LLink | null = app.graph.links[linkId] ?? null;
|
||||
link = link ?? app.canvas.getCurrentGraph()?.links[linkId] ?? null;
|
||||
const subgraphs = app.graph.rootGraph.subgraphs.values();
|
||||
let subgraph;
|
||||
while (!link && (subgraph = subgraphs.next().value)) {
|
||||
link = subgraph?.links[linkId] ?? null;
|
||||
const subgraphs = app.graph.rootGraph.subgraphs?.values();
|
||||
if (subgraphs) {
|
||||
let subgraph;
|
||||
while (!link && (subgraph = subgraphs.next().value)) {
|
||||
link = subgraph?.links[linkId] ?? null;
|
||||
}
|
||||
}
|
||||
return link;
|
||||
}
|
||||
@@ -802,10 +804,12 @@ export function getNodeById(id: NodeId) {
|
||||
if (id == null) return null;
|
||||
let node = app.graph.getNodeById(id);
|
||||
node = node ?? app.canvas.getCurrentGraph()?.getNodeById(id) ?? null;
|
||||
const subgraphs = app.graph.rootGraph.subgraphs.values();
|
||||
let subgraph;
|
||||
while (!node && (subgraph = subgraphs.next().value)) {
|
||||
node = subgraph?.getNodeById(id) ?? null;
|
||||
const subgraphs = app.graph.rootGraph.subgraphs?.values();
|
||||
if (subgraphs) {
|
||||
let subgraph;
|
||||
while (!node && (subgraph = subgraphs.next().value)) {
|
||||
node = subgraph?.getNodeById(id) ?? null;
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -102,16 +102,18 @@ class FastGroupsService {
|
||||
}
|
||||
}
|
||||
getGroupsUnsorted(now) {
|
||||
var _a, _b;
|
||||
var _a, _b, _c;
|
||||
const canvas = app.canvas;
|
||||
const graph = (_a = canvas.getCurrentGraph()) !== null && _a !== void 0 ? _a : app.graph;
|
||||
if (!canvas.selected_group_moving &&
|
||||
(!this.groupsUnsorted.length || now - this.msLastUnsorted > this.msThreshold)) {
|
||||
this.groupsUnsorted = [...graph._groups];
|
||||
const subgraphs = graph.subgraphs.values();
|
||||
let s;
|
||||
while ((s = subgraphs.next().value))
|
||||
this.groupsUnsorted.push(...((_b = s.groups) !== null && _b !== void 0 ? _b : []));
|
||||
const subgraphs = (_b = graph.subgraphs) === null || _b === void 0 ? void 0 : _b.values();
|
||||
if (subgraphs) {
|
||||
let s;
|
||||
while ((s = subgraphs.next().value))
|
||||
this.groupsUnsorted.push(...((_c = s.groups) !== null && _c !== void 0 ? _c : []));
|
||||
}
|
||||
for (const group of this.groupsUnsorted) {
|
||||
this.recomputeInsideNodesForGroup(group);
|
||||
group.rgthree_hasAnyActiveNode = getGroupNodes(group).some((n) => n.mode === LiteGraph.ALWAYS);
|
||||
|
||||
+14
-10
@@ -513,28 +513,32 @@ export function getOriginNodeByLink(linkId) {
|
||||
return node;
|
||||
}
|
||||
export function getLinkById(linkId) {
|
||||
var _a, _b, _c, _d;
|
||||
var _a, _b, _c, _d, _e;
|
||||
if (linkId == null)
|
||||
return null;
|
||||
let link = (_a = app.graph.links[linkId]) !== null && _a !== void 0 ? _a : null;
|
||||
link = (_c = link !== null && link !== void 0 ? link : (_b = app.canvas.getCurrentGraph()) === null || _b === void 0 ? void 0 : _b.links[linkId]) !== null && _c !== void 0 ? _c : null;
|
||||
const subgraphs = app.graph.rootGraph.subgraphs.values();
|
||||
let subgraph;
|
||||
while (!link && (subgraph = subgraphs.next().value)) {
|
||||
link = (_d = subgraph === null || subgraph === void 0 ? void 0 : subgraph.links[linkId]) !== null && _d !== void 0 ? _d : null;
|
||||
const subgraphs = (_d = app.graph.rootGraph.subgraphs) === null || _d === void 0 ? void 0 : _d.values();
|
||||
if (subgraphs) {
|
||||
let subgraph;
|
||||
while (!link && (subgraph = subgraphs.next().value)) {
|
||||
link = (_e = subgraph === null || subgraph === void 0 ? void 0 : subgraph.links[linkId]) !== null && _e !== void 0 ? _e : null;
|
||||
}
|
||||
}
|
||||
return link;
|
||||
}
|
||||
export function getNodeById(id) {
|
||||
var _a, _b, _c;
|
||||
var _a, _b, _c, _d;
|
||||
if (id == null)
|
||||
return null;
|
||||
let node = app.graph.getNodeById(id);
|
||||
node = (_b = node !== null && node !== void 0 ? node : (_a = app.canvas.getCurrentGraph()) === null || _a === void 0 ? void 0 : _a.getNodeById(id)) !== null && _b !== void 0 ? _b : null;
|
||||
const subgraphs = app.graph.rootGraph.subgraphs.values();
|
||||
let subgraph;
|
||||
while (!node && (subgraph = subgraphs.next().value)) {
|
||||
node = (_c = subgraph === null || subgraph === void 0 ? void 0 : subgraph.getNodeById(id)) !== null && _c !== void 0 ? _c : null;
|
||||
const subgraphs = (_c = app.graph.rootGraph.subgraphs) === null || _c === void 0 ? void 0 : _c.values();
|
||||
if (subgraphs) {
|
||||
let subgraph;
|
||||
while (!node && (subgraph = subgraphs.next().value)) {
|
||||
node = (_d = subgraph === null || subgraph === void 0 ? void 0 : subgraph.getNodeById(id)) !== null && _d !== void 0 ? _d : null;
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user