Revert "Revert "Convert i/o slot to class in LGraphNode.configure"" (#518)

* Revert "Revert "Convert i/o slot to class in LGraphNode.configure (#506)" (#511)"

This reverts commit d029bd8924.

* nit
This commit is contained in:
Chenlei Hu
2025-02-12 11:06:35 -05:00
committed by GitHub
parent e87b17fb27
commit 7813e5207a
2 changed files with 56 additions and 22 deletions

View File

@@ -596,39 +596,37 @@ export class LGraphNode implements Positionable, IPinnable {
this.title = this.constructor.title
}
if (this.inputs) {
for (let i = 0; i < this.inputs.length; ++i) {
const input = this.inputs[i]
const link = this.graph ? this.graph._links.get(input.link) : null
this.onConnectionsChange?.(NodeSlotType.INPUT, i, true, link, input)
this.onInputAdded?.(input)
}
this.inputs ??= []
this.inputs = this.inputs.map(input => toClass(NodeInputSlot, input))
for (const [i, input] of this.inputs.entries()) {
const link = this.graph ? this.graph._links.get(input.link) : null
this.onConnectionsChange?.(NodeSlotType.INPUT, i, true, link, input)
this.onInputAdded?.(input)
}
if (this.outputs) {
for (let i = 0; i < this.outputs.length; ++i) {
const output = this.outputs[i]
if (!output.links) {
continue
}
for (let j = 0; j < output.links.length; ++j) {
const link = this.graph
? this.graph._links.get(output.links[j])
: null
this.onConnectionsChange?.(NodeSlotType.OUTPUT, i, true, link, output)
}
this.onOutputAdded?.(output)
this.outputs ??= []
this.outputs = this.outputs.map(output => toClass(NodeOutputSlot, output))
for (const [i, output] of this.outputs.entries()) {
if (!output.links) {
continue
}
for (const linkId of output.links) {
const link = this.graph
? this.graph._links.get(linkId)
: null
this.onConnectionsChange?.(NodeSlotType.OUTPUT, i, true, link, output)
}
this.onOutputAdded?.(output)
}
if (this.widgets) {
for (let i = 0; i < this.widgets.length; ++i) {
const w = this.widgets[i]
for (const w of this.widgets) {
if (!w) continue
if (w.options?.property && this.properties[w.options.property] != undefined)
w.value = JSON.parse(JSON.stringify(this.properties[w.options.property]))
}
if (info.widgets_values) {
for (let i = 0; i < info.widgets_values.length; ++i) {
if (this.widgets[i]) {