diff --git a/src/LGraphGroup.ts b/src/LGraphGroup.ts index bd423c232..eec7a0d47 100644 --- a/src/LGraphGroup.ts +++ b/src/LGraphGroup.ts @@ -15,31 +15,20 @@ export class LGraphGroup { color: string title: string font?: string - font_size: number - _bounding: Float32Array - _pos: Point - _size: Size - _nodes: LGraphNode[] - graph?: LGraph - flags: IGraphGroupFlags + font_size: number = LiteGraph.DEFAULT_GROUP_FONT || 24 + _bounding: Float32Array = new Float32Array([10, 10, 140, 80]) + _pos: Point = this._bounding.subarray(0, 2) + _size: Size = this._bounding.subarray(2, 4) + _nodes: LGraphNode[] = [] + graph: LGraph | null = null + flags: IGraphGroupFlags = {} selected?: boolean constructor(title?: string) { - this._ctor(title) - } - - _ctor(title?: string): void { this.title = title || "Group" - this.font_size = LiteGraph.DEFAULT_GROUP_FONT || 24 this.color = LGraphCanvas.node_colors.pale_blue ? LGraphCanvas.node_colors.pale_blue.groupcolor : "#AAA" - this._bounding = new Float32Array([10, 10, 140, 80]) - this._pos = this._bounding.subarray(0, 2) - this._size = this._bounding.subarray(2, 4) - this._nodes = [] - this.graph = null - this.flags = {} } /** Position of the group, as x,y co-ordinates in graph space */ diff --git a/src/LGraphNode.ts b/src/LGraphNode.ts index 6582b23df..2151ad040 100644 --- a/src/LGraphNode.ts +++ b/src/LGraphNode.ts @@ -121,17 +121,17 @@ export class LGraphNode { static filter?: string static skip_list?: boolean - title?: string - graph: LGraph + title: string + graph: LGraph | null = null id?: NodeId - type?: string - inputs: INodeInputSlot[] - outputs: INodeOutputSlot[] + type: string | null = null + inputs: INodeInputSlot[] = [] + outputs: INodeOutputSlot[] = [] // Not used - connections: unknown[] - properties: INodeProperties - properties_info: INodePropertyInfo[] - flags: INodeFlags + connections: unknown[] = [] + properties: INodeProperties = {} + properties_info: INodePropertyInfo[] = [] + flags: INodeFlags = {} widgets?: IWidget[] size: Size @@ -153,8 +153,8 @@ export class LGraphNode { widgets_start_y?: number lostFocusAt?: number gotFocusAt?: number - badges: (LGraphBadge | (() => LGraphBadge))[] - badgePosition: BadgePosition + badges: (LGraphBadge | (() => LGraphBadge))[] = [] + badgePosition: BadgePosition = BadgePosition.TopLeft onOutputRemoved?(this: LGraphNode, slot: number): void onInputRemoved?(this: LGraphNode, slot: number, input: INodeInputSlot): void _collapsed_width: number @@ -182,7 +182,7 @@ export class LGraphNode { block_delete?: boolean showAdvanced?: boolean - _pos: Point + _pos: Point = new Float32Array([10, 10]) public get pos() { return this._pos } @@ -288,31 +288,9 @@ export class LGraphNode { isValidWidgetLink?(slot_index: number, node: LGraphNode, overWidget: IWidget): boolean | undefined constructor(title: string) { - this._ctor(title) - } - - _ctor(title: string): void { + this.id = LiteGraph.use_uuids ? LiteGraph.uuidv4() : -1 this.title = title || "Unnamed" this.size = [LiteGraph.NODE_WIDTH, 60] - this.graph = null - // Initialize _pos with a Float32Array of length 2, default value [10, 10] - this._pos = new Float32Array([10, 10]) - - this.id = LiteGraph.use_uuids ? LiteGraph.uuidv4() : -1 - this.type = null - - //inputs available: array of inputs - this.inputs = [] - this.outputs = [] - this.connections = [] - this.badges = [] - this.badgePosition = BadgePosition.TopLeft - - //local data - this.properties = {} //for the values - this.properties_info = [] //for the info - - this.flags = {} } /**