mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-02 14:27:40 +00:00
[API] Require always-exported node properties be defined (#821)
Now required: - `type` - `pos` - `size` - `flags` - `order` - `mode`
This commit is contained in:
@@ -659,7 +659,6 @@ export class LGraph implements LinkNetwork, Serialisable<SerialisableGraph> {
|
||||
}
|
||||
|
||||
ancestors.sort(function (a, b) {
|
||||
// @ts-expect-error deprecated
|
||||
return a.order - b.order
|
||||
})
|
||||
return ancestors
|
||||
@@ -1113,12 +1112,10 @@ export class LGraph implements LinkNetwork, Serialisable<SerialisableGraph> {
|
||||
checkNodeTypes() {
|
||||
const { _nodes } = this
|
||||
for (const [i, node] of _nodes.entries()) {
|
||||
// @ts-expect-error deprecated
|
||||
const ctor = LiteGraph.registered_node_types[node.type]
|
||||
if (node.constructor == ctor) continue
|
||||
|
||||
console.log("node being replaced by newer version:", node.type)
|
||||
// @ts-expect-error deprecated
|
||||
const newnode = LiteGraph.createNode(node.type)
|
||||
if (!newnode) continue
|
||||
_nodes[i] = newnode
|
||||
|
||||
@@ -173,7 +173,7 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
|
||||
|
||||
graph: LGraph | null = null
|
||||
id: NodeId
|
||||
type: string | null = null
|
||||
type: string = ""
|
||||
inputs: INodeInputSlot[] = []
|
||||
outputs: INodeOutputSlot[] = []
|
||||
// Not used
|
||||
@@ -190,9 +190,9 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
|
||||
|
||||
locked?: boolean
|
||||
|
||||
// Execution order, automatically computed during run
|
||||
order?: number
|
||||
mode?: LGraphEventMode
|
||||
/** Execution order, automatically computed during run @see {@link LGraph.computeExecutionOrder} */
|
||||
order: number = 0
|
||||
mode: LGraphEventMode = LGraphEventMode.ALWAYS
|
||||
last_serialization?: ISerialisedNode
|
||||
serialize_widgets?: boolean
|
||||
/**
|
||||
@@ -323,6 +323,7 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
|
||||
return this._pos
|
||||
}
|
||||
|
||||
/** Node position does not necessarily correlate to the top-left corner. */
|
||||
public set pos(value) {
|
||||
if (!value || value.length < 2) return
|
||||
|
||||
@@ -587,9 +588,10 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
|
||||
overWidget: IWidget,
|
||||
): boolean | undefined
|
||||
|
||||
constructor(title: string) {
|
||||
constructor(title: string, type?: string) {
|
||||
this.id = LiteGraph.use_uuids ? LiteGraph.uuidv4() : -1
|
||||
this.title = title || "Unnamed"
|
||||
this.type = type ?? ""
|
||||
this.size = [LiteGraph.NODE_WIDTH, 60]
|
||||
this.pos = [10, 10]
|
||||
}
|
||||
@@ -690,7 +692,7 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
|
||||
// create serialization object
|
||||
const o: ISerialisedNode = {
|
||||
id: this.id,
|
||||
type: this.type ?? undefined,
|
||||
type: this.type,
|
||||
pos: [this.pos[0], this.pos[1]],
|
||||
size: [this.size[0], this.size[1]],
|
||||
flags: LiteGraph.cloneObject(this.flags),
|
||||
|
||||
@@ -68,7 +68,7 @@ export interface LiteGraphCanvasEvent extends CustomEvent<CanvasEventDetail> {}
|
||||
|
||||
export interface LGraphNodeConstructor<T extends LGraphNode = LGraphNode> {
|
||||
title: string
|
||||
type?: string
|
||||
type: string
|
||||
size?: Size
|
||||
min_height?: number
|
||||
slot_start_y?: number
|
||||
|
||||
@@ -67,12 +67,12 @@ export type ISerialisableNodeOutput = Omit<INodeOutputSlot, "_layoutElement" | "
|
||||
export interface ISerialisedNode {
|
||||
title?: string
|
||||
id: NodeId
|
||||
type?: string
|
||||
pos?: Point
|
||||
size?: Size
|
||||
flags?: INodeFlags
|
||||
order?: number
|
||||
mode?: number
|
||||
type: string
|
||||
pos: Point
|
||||
size: Size
|
||||
flags: INodeFlags
|
||||
order: number
|
||||
mode: number
|
||||
outputs?: ISerialisableNodeOutput[]
|
||||
inputs?: ISerialisableNodeInput[]
|
||||
properties?: Dictionary<NodeProperty | undefined>
|
||||
|
||||
@@ -82,7 +82,7 @@ LGraph {
|
||||
},
|
||||
"locked": undefined,
|
||||
"lostFocusAt": undefined,
|
||||
"mode": undefined,
|
||||
"mode": 0,
|
||||
"mouseOver": undefined,
|
||||
"order": 0,
|
||||
"outputs": [],
|
||||
@@ -95,7 +95,7 @@ LGraph {
|
||||
"serialize_widgets": undefined,
|
||||
"showAdvanced": undefined,
|
||||
"title": undefined,
|
||||
"type": null,
|
||||
"type": "",
|
||||
"widgets": undefined,
|
||||
"widgets_start_y": undefined,
|
||||
"widgets_up": undefined,
|
||||
@@ -148,7 +148,7 @@ LGraph {
|
||||
},
|
||||
"locked": undefined,
|
||||
"lostFocusAt": undefined,
|
||||
"mode": undefined,
|
||||
"mode": 0,
|
||||
"mouseOver": undefined,
|
||||
"order": 0,
|
||||
"outputs": [],
|
||||
@@ -161,7 +161,7 @@ LGraph {
|
||||
"serialize_widgets": undefined,
|
||||
"showAdvanced": undefined,
|
||||
"title": undefined,
|
||||
"type": null,
|
||||
"type": "",
|
||||
"widgets": undefined,
|
||||
"widgets_start_y": undefined,
|
||||
"widgets_up": undefined,
|
||||
@@ -215,7 +215,7 @@ LGraph {
|
||||
},
|
||||
"locked": undefined,
|
||||
"lostFocusAt": undefined,
|
||||
"mode": undefined,
|
||||
"mode": 0,
|
||||
"mouseOver": undefined,
|
||||
"order": 0,
|
||||
"outputs": [],
|
||||
@@ -228,7 +228,7 @@ LGraph {
|
||||
"serialize_widgets": undefined,
|
||||
"showAdvanced": undefined,
|
||||
"title": undefined,
|
||||
"type": null,
|
||||
"type": "",
|
||||
"widgets": undefined,
|
||||
"widgets_start_y": undefined,
|
||||
"widgets_up": undefined,
|
||||
|
||||
Reference in New Issue
Block a user