Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
b9b178b8
Commit
b9b178b8
authored
Oct 05, 2023
by
pythongosssss
Browse files
More cleanup of old type data
Fix connecting combos of same type from different types of node
parent
80932ddf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
14 deletions
+20
-14
web/extensions/core/widgetInputs.js
web/extensions/core/widgetInputs.js
+20
-14
No files found.
web/extensions/core/widgetInputs.js
View file @
b9b178b8
...
...
@@ -61,11 +61,11 @@ function showWidget(widget) {
function
convertToInput
(
node
,
widget
,
config
)
{
hideWidget
(
node
,
widget
);
const
{
linkT
ype
}
=
getWidgetType
(
config
,
`
${
node
.
comfyClass
}
|
${
widget
.
name
}
`
);
const
{
t
ype
}
=
getWidgetType
(
config
);
// Add input and store widget config for creating on primitive node
const
sz
=
node
.
size
;
node
.
addInput
(
widget
.
name
,
linkT
ype
,
{
node
.
addInput
(
widget
.
name
,
t
ype
,
{
widget
:
{
name
:
widget
.
name
,
getConfig
:
()
=>
config
},
});
...
...
@@ -90,15 +90,13 @@ function convertToWidget(node, widget) {
node
.
setSize
([
Math
.
max
(
sz
[
0
],
node
.
size
[
0
]),
Math
.
max
(
sz
[
1
],
node
.
size
[
1
])]);
}
function
getWidgetType
(
config
,
comboType
)
{
function
getWidgetType
(
config
)
{
// Special handling for COMBO so we restrict links based on the entries
let
type
=
config
[
0
];
let
linkType
=
type
;
if
(
type
instanceof
Array
)
{
type
=
"
COMBO
"
;
linkType
=
comboType
;
}
return
{
type
,
linkType
};
return
{
type
};
}
app
.
registerExtension
({
...
...
@@ -148,13 +146,24 @@ app.registerExtension({
for
(
const
input
of
this
.
inputs
)
{
if
(
input
.
widget
)
{
// Cleanup old widget config
delete
input
.
widget
.
config
;
if
(
!
input
.
widget
.
getConfig
)
{
input
.
widget
.
getConfig
=
getConfig
.
bind
(
this
,
input
.
widget
.
name
);
}
// Cleanup old widget config
if
(
input
.
widget
.
config
)
{
if
(
input
.
widget
.
config
[
0
]
instanceof
Array
)
{
// If we are an old converted combo then replace the input type and the stored link data
input
.
type
=
"
COMBO
"
;
const
link
=
app
.
graph
.
links
[
input
.
link
];
if
(
link
)
{
link
.
type
=
input
.
type
;
}
}
delete
input
.
widget
.
config
;
}
const
w
=
this
.
widgets
.
find
((
w
)
=>
w
.
name
===
input
.
widget
.
name
);
if
(
w
)
{
hideWidget
(
this
,
w
);
...
...
@@ -372,9 +381,9 @@ app.registerExtension({
widget
=
input
.
widget
;
}
const
{
type
,
linkType
}
=
getWidgetType
(
widget
.
getConfig
()
,
`
${
theirNode
.
comfyClass
}
|
${
widget
.
name
}
`
);
const
{
type
}
=
getWidgetType
(
widget
.
getConfig
());
// Update our output to restrict to the widget type
this
.
outputs
[
0
].
type
=
linkT
ype
;
this
.
outputs
[
0
].
type
=
t
ype
;
this
.
outputs
[
0
].
name
=
type
;
this
.
outputs
[
0
].
widget
=
widget
;
...
...
@@ -483,9 +492,6 @@ app.registerExtension({
const
config2
=
input
.
widget
.
getConfig
();
if
(
config1
[
0
]
instanceof
Array
)
{
// These checks shouldnt actually be necessary as the types should match
// but double checking doesn't hurt
// New input isnt a combo
if
(
!
(
config2
[
0
]
instanceof
Array
))
{
console
.
log
(
`connection rejected: tried to connect combo to
${
config2
[
0
]}
`
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment