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
43f25053
Commit
43f25053
authored
Sep 01, 2023
by
comfyanonymous
Browse files
Merge branch 'fix/widget-wonkyness' of
https://github.com/M1kep/ComfyUI
parents
0e3b6411
69c5e6de
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
18 deletions
+35
-18
web/extensions/core/widgetInputs.js
web/extensions/core/widgetInputs.js
+20
-3
web/scripts/app.js
web/scripts/app.js
+15
-15
No files found.
web/extensions/core/widgetInputs.js
View file @
43f25053
...
@@ -5,7 +5,7 @@ const CONVERTED_TYPE = "converted-widget";
...
@@ -5,7 +5,7 @@ const CONVERTED_TYPE = "converted-widget";
const
VALID_TYPES
=
[
"
STRING
"
,
"
combo
"
,
"
number
"
,
"
BOOLEAN
"
];
const
VALID_TYPES
=
[
"
STRING
"
,
"
combo
"
,
"
number
"
,
"
BOOLEAN
"
];
function
isConvertableWidget
(
widget
,
config
)
{
function
isConvertableWidget
(
widget
,
config
)
{
return
VALID_TYPES
.
includes
(
widget
.
type
)
||
VALID_TYPES
.
includes
(
config
[
0
]);
return
(
VALID_TYPES
.
includes
(
widget
.
type
)
||
VALID_TYPES
.
includes
(
config
[
0
])
)
&&
!
widget
.
options
?.
forceInput
;
}
}
function
hideWidget
(
node
,
widget
,
suffix
=
""
)
{
function
hideWidget
(
node
,
widget
,
suffix
=
""
)
{
...
@@ -103,6 +103,9 @@ app.registerExtension({
...
@@ -103,6 +103,9 @@ app.registerExtension({
let
toInput
=
[];
let
toInput
=
[];
let
toWidget
=
[];
let
toWidget
=
[];
for
(
const
w
of
this
.
widgets
)
{
for
(
const
w
of
this
.
widgets
)
{
if
(
w
.
options
?.
forceInput
)
{
continue
;
}
if
(
w
.
type
===
CONVERTED_TYPE
)
{
if
(
w
.
type
===
CONVERTED_TYPE
)
{
toWidget
.
push
({
toWidget
.
push
({
content
:
`Convert
${
w
.
name
}
to widget`
,
content
:
`Convert
${
w
.
name
}
to widget`
,
...
@@ -130,6 +133,20 @@ app.registerExtension({
...
@@ -130,6 +133,20 @@ app.registerExtension({
return
r
;
return
r
;
};
};
const
origOnNodeCreated
=
nodeType
.
prototype
.
onNodeCreated
nodeType
.
prototype
.
onNodeCreated
=
function
()
{
const
r
=
origOnNodeCreated
?
origOnNodeCreated
.
apply
(
this
)
:
undefined
;
if
(
this
.
widgets
)
{
for
(
const
w
of
this
.
widgets
)
{
if
(
w
?.
options
?.
forceInput
)
{
const
config
=
nodeData
?.
input
?.
required
[
w
.
name
]
||
nodeData
?.
input
?.
optional
?.[
w
.
name
]
||
[
w
.
type
,
w
.
options
||
{}];
convertToInput
(
this
,
w
,
config
);
}
}
}
return
r
;
}
// On initial configure of nodes hide all converted widgets
// On initial configure of nodes hide all converted widgets
const
origOnConfigure
=
nodeType
.
prototype
.
onConfigure
;
const
origOnConfigure
=
nodeType
.
prototype
.
onConfigure
;
nodeType
.
prototype
.
onConfigure
=
function
()
{
nodeType
.
prototype
.
onConfigure
=
function
()
{
...
@@ -137,7 +154,7 @@ app.registerExtension({
...
@@ -137,7 +154,7 @@ app.registerExtension({
if
(
this
.
inputs
)
{
if
(
this
.
inputs
)
{
for
(
const
input
of
this
.
inputs
)
{
for
(
const
input
of
this
.
inputs
)
{
if
(
input
.
widget
)
{
if
(
input
.
widget
&&
!
input
.
widget
.
config
[
1
]?.
forceInput
)
{
const
w
=
this
.
widgets
.
find
((
w
)
=>
w
.
name
===
input
.
widget
.
name
);
const
w
=
this
.
widgets
.
find
((
w
)
=>
w
.
name
===
input
.
widget
.
name
);
if
(
w
)
{
if
(
w
)
{
hideWidget
(
this
,
w
);
hideWidget
(
this
,
w
);
...
@@ -374,7 +391,7 @@ app.registerExtension({
...
@@ -374,7 +391,7 @@ app.registerExtension({
}
}
for
(
const
k
in
config1
[
1
])
{
for
(
const
k
in
config1
[
1
])
{
if
(
k
!==
"
default
"
)
{
if
(
k
!==
"
default
"
&&
k
!==
'
forceInput
'
)
{
if
(
config1
[
1
][
k
]
!==
config2
[
1
][
k
])
{
if
(
config1
[
1
][
k
]
!==
config2
[
1
][
k
])
{
return
false
;
return
false
;
}
}
...
...
web/scripts/app.js
View file @
43f25053
...
@@ -1151,22 +1151,22 @@ export class ComfyApp {
...
@@ -1151,22 +1151,22 @@ export class ComfyApp {
const
inputData
=
inputs
[
inputName
];
const
inputData
=
inputs
[
inputName
];
const
type
=
inputData
[
0
];
const
type
=
inputData
[
0
];
if
(
inputData
[
1
]?.
forceInput
)
{
if
(
Array
.
isArray
(
type
))
{
this
.
addInput
(
inputName
,
type
);
// Enums
Object
.
assign
(
config
,
widgets
.
COMBO
(
this
,
inputName
,
inputData
,
app
)
||
{});
}
else
if
(
`
${
type
}
:
${
inputName
}
`
in
widgets
)
{
// Support custom widgets by Type:Name
Object
.
assign
(
config
,
widgets
[
`
${
type
}
:
${
inputName
}
`
](
this
,
inputName
,
inputData
,
app
)
||
{});
}
else
if
(
type
in
widgets
)
{
// Standard type widgets
Object
.
assign
(
config
,
widgets
[
type
](
this
,
inputName
,
inputData
,
app
)
||
{});
}
else
{
}
else
{
if
(
Array
.
isArray
(
type
))
{
// Node connection inputs
// Enums
this
.
addInput
(
inputName
,
type
);
Object
.
assign
(
config
,
widgets
.
COMBO
(
this
,
inputName
,
inputData
,
app
)
||
{});
}
}
else
if
(
`
${
type
}
:
${
inputName
}
`
in
widgets
)
{
if
(
inputData
[
1
]?.
forceInput
&&
config
?.
widget
)
{
// Support custom widgets by Type:Name
if
(
!
config
.
widget
.
options
)
config
.
widget
.
options
=
{};
Object
.
assign
(
config
,
widgets
[
`
${
type
}
:
${
inputName
}
`
](
this
,
inputName
,
inputData
,
app
)
||
{});
config
.
widget
.
options
.
forceInput
=
inputData
[
1
].
forceInput
;
}
else
if
(
type
in
widgets
)
{
// Standard type widgets
Object
.
assign
(
config
,
widgets
[
type
](
this
,
inputName
,
inputData
,
app
)
||
{});
}
else
{
// Node connection inputs
this
.
addInput
(
inputName
,
type
);
}
}
}
}
}
...
...
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