mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 10:42:44 +00:00
[Cleanup] Remove combo connection type check (#2838)
This commit is contained in:
@@ -551,26 +551,6 @@ function getWidgetType(config: InputSpec) {
|
|||||||
return { type }
|
return { type }
|
||||||
}
|
}
|
||||||
|
|
||||||
function isValidCombo(combo: string[], obj: unknown) {
|
|
||||||
// New input isnt a combo
|
|
||||||
if (!(obj instanceof Array)) {
|
|
||||||
console.log(`connection rejected: tried to connect combo to ${obj}`)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
// New input combo has a different size
|
|
||||||
if (combo.length !== obj.length) {
|
|
||||||
console.log(`connection rejected: combo lists dont match`)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
// New input combo has different elements
|
|
||||||
if (combo.find((v, i) => obj[i] !== v)) {
|
|
||||||
console.log(`connection rejected: combo lists dont match`)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
export function setWidgetConfig(
|
export function setWidgetConfig(
|
||||||
slot: INodeInputSlot | INodeOutputSlot,
|
slot: INodeInputSlot | INodeOutputSlot,
|
||||||
config: InputSpec
|
config: InputSpec
|
||||||
@@ -931,37 +911,6 @@ app.registerExtension({
|
|||||||
|
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prevent connecting COMBO lists to converted inputs that dont match types
|
|
||||||
const onConnectInput = nodeType.prototype.onConnectInput
|
|
||||||
nodeType.prototype.onConnectInput = function (
|
|
||||||
this: LGraphNode,
|
|
||||||
targetSlot: number,
|
|
||||||
type: string,
|
|
||||||
output: INodeOutputSlot,
|
|
||||||
originNode: LGraphNode,
|
|
||||||
originSlot: number
|
|
||||||
) {
|
|
||||||
// @ts-expect-error onConnectInput has 5 arguments
|
|
||||||
const v = onConnectInput?.(this, arguments)
|
|
||||||
// Not a combo, ignore
|
|
||||||
if (type !== 'COMBO') return v
|
|
||||||
// Primitive output, allow that to handle
|
|
||||||
if (originNode.outputs[originSlot].widget) return v
|
|
||||||
|
|
||||||
// Ensure target is also a combo
|
|
||||||
const targetCombo = this.inputs[targetSlot].widget?.[GET_CONFIG]?.()?.[0]
|
|
||||||
if (!targetCombo || !(targetCombo instanceof Array)) return v
|
|
||||||
|
|
||||||
// Check they match
|
|
||||||
const originConfig =
|
|
||||||
originNode.constructor?.nodeData?.output?.[originSlot]
|
|
||||||
if (!originConfig || !isValidCombo(targetCombo, originConfig)) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
registerCustomNodes() {
|
registerCustomNodes() {
|
||||||
LiteGraph.registerNodeType(
|
LiteGraph.registerNodeType(
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
import { fromZodError } from 'zod-validation-error'
|
import { fromZodError } from 'zod-validation-error'
|
||||||
|
|
||||||
|
const zComboOption = z.union([z.string(), z.number()])
|
||||||
const zRemoteWidgetConfig = z.object({
|
const zRemoteWidgetConfig = z.object({
|
||||||
route: z.string().url().or(z.string().startsWith('/')),
|
route: z.string().url().or(z.string().startsWith('/')),
|
||||||
refresh: z.number().gte(128).safe().or(z.number().lte(0).safe()).optional(),
|
refresh: z.number().gte(128).safe().or(z.number().lte(0).safe()).optional(),
|
||||||
@@ -71,7 +72,7 @@ const zComboInputOptions = zBaseInputOptions.extend({
|
|||||||
allow_batch: z.boolean().optional(),
|
allow_batch: z.boolean().optional(),
|
||||||
video_upload: z.boolean().optional(),
|
video_upload: z.boolean().optional(),
|
||||||
remote: zRemoteWidgetConfig.optional(),
|
remote: zRemoteWidgetConfig.optional(),
|
||||||
options: z.array(z.union([z.string(), z.number()])).optional()
|
options: z.array(zComboOption).optional()
|
||||||
})
|
})
|
||||||
|
|
||||||
const zIntInputSpec = z.tuple([z.literal('INT'), zIntInputOptions.optional()])
|
const zIntInputSpec = z.tuple([z.literal('INT'), zIntInputOptions.optional()])
|
||||||
@@ -87,8 +88,12 @@ const zStringInputSpec = z.tuple([
|
|||||||
z.literal('STRING'),
|
z.literal('STRING'),
|
||||||
zStringInputOptions.optional()
|
zStringInputOptions.optional()
|
||||||
])
|
])
|
||||||
|
/**
|
||||||
|
* Legacy combo syntax.
|
||||||
|
* @deprecated Use `zComboInputSpecV2` instead.
|
||||||
|
*/
|
||||||
const zComboInputSpec = z.tuple([
|
const zComboInputSpec = z.tuple([
|
||||||
z.array(z.union([z.string(), z.number()])),
|
z.array(zComboOption),
|
||||||
zComboInputOptions.optional()
|
zComboInputOptions.optional()
|
||||||
])
|
])
|
||||||
const zComboInputSpecV2 = z.tuple([
|
const zComboInputSpecV2 = z.tuple([
|
||||||
@@ -193,7 +198,7 @@ const zComfyInputsSpec = z.object({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const zComfyNodeDataType = z.string()
|
const zComfyNodeDataType = z.string()
|
||||||
const zComfyComboOutput = z.array(z.any())
|
const zComfyComboOutput = z.array(zComboOption)
|
||||||
const zComfyOutputTypesSpec = z.array(
|
const zComfyOutputTypesSpec = z.array(
|
||||||
z.union([zComfyNodeDataType, zComfyComboOutput])
|
z.union([zComfyNodeDataType, zComfyComboOutput])
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user