mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-05 07:30:11 +00:00
[TS] Fix widget GET_CONFIG on loading primitive nodes (#3374)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -43,4 +43,15 @@ test.describe('Primitive Node', () => {
|
||||
'static_primitive_connected.png'
|
||||
)
|
||||
})
|
||||
|
||||
test('Report missing nodes when connect to missing node', async ({
|
||||
comfyPage
|
||||
}) => {
|
||||
await comfyPage.loadWorkflow(
|
||||
'primitive/primitive_node_connect_missing_node'
|
||||
)
|
||||
// Wait for the element with the .comfy-missing-nodes selector to be visible
|
||||
const missingNodesWarning = comfyPage.page.locator('.comfy-missing-nodes')
|
||||
await expect(missingNodesWarning).toBeVisible()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -212,6 +212,7 @@ app.registerExtension({
|
||||
node.inputs[0].widget = { name: 'value' }
|
||||
// @ts-expect-error fixme ts strict error
|
||||
setWidgetConfig(node.inputs[0], [
|
||||
// @ts-expect-error fixme ts strict error
|
||||
widgetType ?? displayType,
|
||||
widgetConfig
|
||||
])
|
||||
|
||||
@@ -329,8 +329,8 @@ export class PrimitiveNode extends LGraphNode {
|
||||
|
||||
return
|
||||
}
|
||||
// @ts-expect-error fixme ts strict error
|
||||
const config1 = output.widget?.[GET_CONFIG]?.()
|
||||
const config1 = (output.widget?.[GET_CONFIG] as () => InputSpec)?.()
|
||||
if (!config1) return
|
||||
const isNumber = config1[0] === 'INT' || config1[0] === 'FLOAT'
|
||||
if (!isNumber) return
|
||||
|
||||
@@ -359,8 +359,12 @@ export class PrimitiveNode extends LGraphNode {
|
||||
if (!isConvertibleWidget(targetWidget, config2)) return false
|
||||
|
||||
const output = this.outputs[originSlot]
|
||||
// @ts-expect-error fixme ts strict error
|
||||
if (!(output.widget?.[CONFIG] ?? output.widget?.[GET_CONFIG]())) {
|
||||
if (
|
||||
!(
|
||||
output.widget?.[CONFIG] ??
|
||||
(output.widget?.[GET_CONFIG] as () => InputSpec)?.()
|
||||
)
|
||||
) {
|
||||
// No widget defined for this primitive yet so allow it
|
||||
return true
|
||||
}
|
||||
@@ -370,9 +374,10 @@ export class PrimitiveNode extends LGraphNode {
|
||||
|
||||
#isValidConnection(input: INodeInputSlot, forceUpdate?: boolean) {
|
||||
// Only allow connections where the configs match
|
||||
const output = this.outputs[0]
|
||||
// @ts-expect-error fixme ts strict error
|
||||
const config2 = input.widget[GET_CONFIG]()
|
||||
const output = this.outputs?.[0]
|
||||
const config2 = (input.widget?.[GET_CONFIG] as () => InputSpec)?.()
|
||||
if (!config2) return false
|
||||
|
||||
return !!mergeIfValid.call(
|
||||
this,
|
||||
output,
|
||||
@@ -417,9 +422,14 @@ export class PrimitiveNode extends LGraphNode {
|
||||
}
|
||||
}
|
||||
|
||||
export function getWidgetConfig(slot: INodeInputSlot | INodeOutputSlot) {
|
||||
// @ts-expect-error fixme ts strict error
|
||||
return slot.widget[CONFIG] ?? slot.widget[GET_CONFIG]?.() ?? ['*', {}]
|
||||
export function getWidgetConfig(
|
||||
slot: INodeInputSlot | INodeOutputSlot
|
||||
): InputSpec {
|
||||
return (slot.widget?.[CONFIG] ??
|
||||
(slot.widget?.[GET_CONFIG] as () => InputSpec)?.() ?? [
|
||||
'*',
|
||||
{}
|
||||
]) as InputSpec
|
||||
}
|
||||
|
||||
function getConfig(this: LGraphNode, widgetName: string) {
|
||||
@@ -501,7 +511,6 @@ export function mergeIfValid(
|
||||
config1 = getWidgetConfig(output)
|
||||
}
|
||||
|
||||
// @ts-expect-error fixme ts strict error
|
||||
const customSpec = mergeInputSpec(config1, config2)
|
||||
|
||||
if (customSpec || forceUpdate) {
|
||||
@@ -604,8 +613,11 @@ app.registerExtension({
|
||||
// Not a widget input or already handled input
|
||||
if (
|
||||
!(input.type in ComfyWidgets) &&
|
||||
// @ts-expect-error fixme ts strict error
|
||||
!(input.widget?.[GET_CONFIG]?.()?.[0] instanceof Array)
|
||||
!(
|
||||
(
|
||||
input.widget?.[GET_CONFIG] as (() => InputSpec) | undefined
|
||||
)?.()?.[0] instanceof Array
|
||||
)
|
||||
) {
|
||||
return r //also Not a ComfyWidgets input or combo (do nothing)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user