From fadece7fdfb07a92a12c145a6aa58c5b8b5500fb Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Mon, 24 Feb 2025 19:29:04 -0500 Subject: [PATCH] Type LGraphNode.addInput/Output (#585) --- src/LGraphNode.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/LGraphNode.ts b/src/LGraphNode.ts index a8c078f2d..edf59f305 100644 --- a/src/LGraphNode.ts +++ b/src/LGraphNode.ts @@ -1063,10 +1063,8 @@ export class LGraphNode implements Positionable, IPinnable, IColorable { addOnTriggerInput(): number { const trigS = this.findInputSlot("onTrigger") - // !trigS || if (trigS == -1) { this.addInput("onTrigger", LiteGraph.EVENT, { - optional: true, nameLocked: true, }) return this.findInputSlot("onTrigger") @@ -1076,10 +1074,8 @@ export class LGraphNode implements Positionable, IPinnable, IColorable { addOnExecutedOutput(): number { const trigS = this.findOutputSlot("onExecuted") - // !trigS || if (trigS == -1) { this.addOutput("onExecuted", LiteGraph.ACTION, { - optional: true, nameLocked: true, }) return this.findOutputSlot("onExecuted") @@ -1349,7 +1345,7 @@ export class LGraphNode implements Positionable, IPinnable, IColorable { addOutput( name?: string, type?: ISlotType, - extra_info?: object, + extra_info?: Partial, ): INodeOutputSlot { const output = new NodeOutputSlot({ name: name, type: type, links: null }) if (extra_info) { @@ -1374,7 +1370,7 @@ export class LGraphNode implements Positionable, IPinnable, IColorable { * add a new output slot to use in this node * @param array of triplets like [[name,type,extra_info],[...]] */ - addOutputs(array: [string, ISlotType, Record][]): void { + addOutputs(array: [string, ISlotType, Partial][]): void { for (let i = 0; i < array.length; ++i) { const info = array[i] const o = new NodeOutputSlot({ name: info[0], type: info[1], links: null }) @@ -1423,7 +1419,7 @@ export class LGraphNode implements Positionable, IPinnable, IColorable { * @param type string defining the input type ("vec3","number",...), it its a generic one use 0 * @param extra_info this can be used to have special properties of an input (label, color, position, etc) */ - addInput(name: string, type: ISlotType, extra_info?: object): INodeInputSlot { + addInput(name: string, type: ISlotType, extra_info?: Partial): INodeInputSlot { type = type || 0 const input: INodeInputSlot = new NodeInputSlot({ name: name, type: type, link: null }) if (extra_info) { @@ -1447,7 +1443,7 @@ export class LGraphNode implements Positionable, IPinnable, IColorable { * add several new input slots in this node * @param array of triplets like [[name,type,extra_info],[...]] */ - addInputs(array: [string, ISlotType, Record][]): void { + addInputs(array: [string, ISlotType, Partial][]): void { for (let i = 0; i < array.length; ++i) { const info = array[i] const o: INodeInputSlot = new NodeInputSlot({ name: info[0], type: info[1], link: null })