Typescript LGraphNode (#207)

* nit - Fix whitespace

* nit - Remove outdated comments

* nit - Remove redundant jsdoc tag

* Format only

* Add TS types

* nit - Auto let/const

* Convert special-case vars

* nit - Redeclared params / vars

* nit - const/let

* Refactor - minor logic change

* Add TS types - overloads w/workaround

* Refactor - prefer typeof over constructor check

* Add TS types

* Remove unused params

* nit - Refactor

* Refactor LGraphNode.findSlotByType

* nit - Refactor / format

* Refactor - optional chaining

* Fix TS type - node shape
This commit is contained in:
filtered
2024-10-13 01:53:25 +11:00
committed by GitHub
parent f1bb7153da
commit 96866e8624
4 changed files with 1190 additions and 1575 deletions

View File

@@ -94,6 +94,7 @@ export class LGraph {
onSerialize?(data: ISerialisedGraph): void
onConfigure?(data: ISerialisedGraph): void
onGetNodeMenuOptions?(options: IContextMenuValue[], node: LGraphNode): void
onNodeConnectionChange?(nodeSlotType: ISlotType, targetNode: LGraphNode, slotIndex: number, sourceNode?: LGraphNode, sourceSlotIndex?: number): void
private _input_nodes?: LGraphNode[]

File diff suppressed because it is too large Load Diff

View File

@@ -99,6 +99,13 @@ export interface LiteGraphCanvasGroupEvent extends CustomEvent<{
/** https://github.com/jagenjo/litegraph.js/blob/master/guides/README.md#lgraphnode */
export interface LGraphNodeConstructor<T extends LGraphNode = LGraphNode> {
title?: string
type?: string
size?: Size
min_height?: number
slot_start_y?: number
widgets_info?: any
collapsable?: boolean
nodeData: any
new(): T
}

View File

@@ -5,6 +5,7 @@ import type { LGraphNode, NodeId } from "@/LGraphNode"
import type { LiteGraph } from "@/litegraph"
import type { LinkId, LLink } from "@/LLink"
import type { TWidgetValue } from "@/types/widgets"
import { RenderShape } from "./globalEnums"
/** Serialised LGraphNode */
export interface ISerialisedNode {
@@ -19,7 +20,7 @@ export interface ISerialisedNode {
outputs?: INodeOutputSlot[]
inputs?: INodeInputSlot[]
properties?: Dictionary<unknown>
shape?: Rect
shape?: RenderShape
boxcolor?: CanvasColour
color?: CanvasColour
bgcolor?: string