mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-02 14:27:40 +00:00
Add support for LiteGraph to convert to classes (#334)
* Add support for LiteGraph to convert to classes * Fix large context menu search regression * Remove debug code * Fix regression from rename & prototype change * Fix super() calls to match LGraphNode
This commit is contained in:
@@ -1983,8 +1983,15 @@ export class ComfyApp {
|
||||
|
||||
async registerNodeDef(nodeId: string, nodeData: ComfyNodeDef) {
|
||||
const self = this
|
||||
const node = Object.assign(
|
||||
function ComfyNode() {
|
||||
const node = class ComfyNode extends LGraphNode {
|
||||
static comfyClass? = nodeData.name
|
||||
// TODO: change to "title?" once litegraph.d.ts has been updated
|
||||
static title = nodeData.display_name || nodeData.name
|
||||
static nodeData? = nodeData
|
||||
static category?: string
|
||||
|
||||
constructor(title?: string) {
|
||||
super(title)
|
||||
var inputs = nodeData['input']['required']
|
||||
if (nodeData['input']['optional'] != undefined) {
|
||||
inputs = Object.assign(
|
||||
@@ -2050,13 +2057,9 @@ export class ComfyApp {
|
||||
this.serialize_widgets = true
|
||||
|
||||
app.#invokeExtensionsAsync('nodeCreated', this)
|
||||
},
|
||||
{
|
||||
title: nodeData.display_name || nodeData.name,
|
||||
comfyClass: nodeData.name,
|
||||
nodeData
|
||||
}
|
||||
)
|
||||
}
|
||||
// @ts-expect-error
|
||||
node.prototype.comfyClass = nodeData.name
|
||||
|
||||
this.#addNodeContextMenuHandler(node)
|
||||
@@ -2064,9 +2067,7 @@ export class ComfyApp {
|
||||
this.#addNodeKeyHandler(node)
|
||||
|
||||
await this.#invokeExtensionsAsync('beforeRegisterNodeDef', node, nodeData)
|
||||
// @ts-expect-error
|
||||
LiteGraph.registerNodeType(nodeId, node)
|
||||
// @ts-expect-error
|
||||
node.category = nodeData.category
|
||||
}
|
||||
|
||||
|
||||
@@ -254,7 +254,6 @@ export function addDomClippingSetting(): void {
|
||||
})
|
||||
}
|
||||
|
||||
//@ts-ignore
|
||||
LGraphNode.prototype.addDOMWidget = function (
|
||||
name: string,
|
||||
type: string,
|
||||
|
||||
Reference in New Issue
Block a user