mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 19:09:52 +00:00
Enable ts-strict for slotDefaults.ts (#1290)
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
// @ts-strict-ignore
|
|
||||||
import { app } from '../../scripts/app'
|
import { app } from '../../scripts/app'
|
||||||
import { ComfyWidgets } from '../../scripts/widgets'
|
import { ComfyWidgets } from '../../scripts/widgets'
|
||||||
import { LiteGraph } from '@comfyorg/litegraph'
|
import { LiteGraph } from '@comfyorg/litegraph'
|
||||||
@@ -31,7 +30,7 @@ app.registerExtension({
|
|||||||
slot_types_default_in: {},
|
slot_types_default_in: {},
|
||||||
async beforeRegisterNodeDef(nodeType, nodeData, app) {
|
async beforeRegisterNodeDef(nodeType, nodeData, app) {
|
||||||
var nodeId = nodeData.name
|
var nodeId = nodeData.name
|
||||||
const inputs = nodeData['input']['required'] //only show required inputs to reduce the mess also not logical to create node with optional inputs
|
const inputs = nodeData['input']?.['required'] //only show required inputs to reduce the mess also not logical to create node with optional inputs
|
||||||
for (const inputKey in inputs) {
|
for (const inputKey in inputs) {
|
||||||
var input = inputs[inputKey]
|
var input = inputs[inputKey]
|
||||||
if (typeof input[0] !== 'string') continue
|
if (typeof input[0] !== 'string') continue
|
||||||
@@ -59,9 +58,9 @@ app.registerExtension({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
var outputs = nodeData['output']
|
var outputs = nodeData['output'] ?? []
|
||||||
for (const key in outputs) {
|
for (const el of outputs) {
|
||||||
var type = outputs[key] as string
|
const type = el as string
|
||||||
if (!(type in this.slot_types_default_in)) {
|
if (!(type in this.slot_types_default_in)) {
|
||||||
this.slot_types_default_in[type] = ['Reroute'] // ["Reroute", "Primitive"]; primitive doesn't always work :'()
|
this.slot_types_default_in[type] = ['Reroute'] // ["Reroute", "Primitive"]; primitive doesn't always work :'()
|
||||||
}
|
}
|
||||||
@@ -78,10 +77,11 @@ app.registerExtension({
|
|||||||
LiteGraph.slot_types_out.push(type)
|
LiteGraph.slot_types_out.push(type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var maxNum = this.suggestionsNumber.value
|
var maxNum = this.suggestionsNumber.value
|
||||||
this.setDefaults(maxNum)
|
this.setDefaults(maxNum)
|
||||||
},
|
},
|
||||||
setDefaults(maxNum) {
|
setDefaults(maxNum?: number | null) {
|
||||||
LiteGraph.slot_types_default_out = {}
|
LiteGraph.slot_types_default_out = {}
|
||||||
LiteGraph.slot_types_default_in = {}
|
LiteGraph.slot_types_default_in = {}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user