Various fixes/features
This commit is contained in:
@@ -113,12 +113,16 @@ export default class ComfyComboNode extends ComfyWidgetNode<string> {
|
||||
const comfyInput = input as IComfyInputSlot;
|
||||
const otherProps = comfyInput.config;
|
||||
|
||||
console.warn("CHECK COMBO CONNECTION", otherProps, thisProps)
|
||||
|
||||
// Ensure combo options match
|
||||
if (!(otherProps.values instanceof Array))
|
||||
return false;
|
||||
if (thisProps.values.find((v, i) => otherProps.values.indexOf(v) === -1))
|
||||
return false;
|
||||
|
||||
console.warn("PASSED")
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +72,9 @@ export default class ComfyGalleryNode extends ComfyWidgetNode<ComfyBoxImageMetad
|
||||
}
|
||||
|
||||
override parseValue(param: any): ComfyBoxImageMetadata[] {
|
||||
if (param == null)
|
||||
return []
|
||||
|
||||
const meta = parseWhateverIntoImageMetadata(param) || [];
|
||||
|
||||
console.debug("[ComfyGalleryNode] Received output!", param)
|
||||
@@ -81,6 +84,7 @@ export default class ComfyGalleryNode extends ComfyWidgetNode<ComfyBoxImageMetad
|
||||
return currentValue.concat(meta)
|
||||
}
|
||||
else {
|
||||
this.notifyPropsChanged();
|
||||
return meta;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ export default class ComfyImageUploadNode extends ComfyWidgetNode<ComfyBoxImageM
|
||||
|
||||
override svelteComponentType = ImageUploadWidget;
|
||||
override defaultValue = [];
|
||||
override outputSlotName = "images";
|
||||
override storeActionName = "store";
|
||||
override saveUserState = false;
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ export default class ComfyTextNode extends ComfyWidgetNode<string> {
|
||||
|
||||
static slotLayout: SlotLayout = {
|
||||
inputs: [
|
||||
{ name: "value", type: "string" },
|
||||
{ name: "store", type: BuiltInSlotType.ACTION }
|
||||
],
|
||||
outputs: [
|
||||
@@ -24,6 +25,7 @@ export default class ComfyTextNode extends ComfyWidgetNode<string> {
|
||||
]
|
||||
}
|
||||
|
||||
override inputSlotName = "value";
|
||||
override svelteComponentType = TextWidget
|
||||
override defaultValue = "";
|
||||
|
||||
|
||||
@@ -73,12 +73,14 @@ export default abstract class ComfyWidgetNode<T = any> extends ComfyGraphNode {
|
||||
// shownInputProperties: string[] = []
|
||||
|
||||
/** Names of properties to add as outputs */
|
||||
private shownOutputProperties: Record<string, { type: string, index: number }> = {}
|
||||
private shownOutputProperties: Record<string, { type: string, outputName: string }> = {}
|
||||
outputProperties: { name: string, type: string }[] = []
|
||||
|
||||
override isBackendNode = false;
|
||||
override serialize_widgets = true;
|
||||
|
||||
// input slots
|
||||
inputSlotName: string | null = "value";
|
||||
storeActionName: string | null = "store";
|
||||
|
||||
// output slots
|
||||
@@ -105,15 +107,16 @@ export default abstract class ComfyWidgetNode<T = any> extends ComfyGraphNode {
|
||||
}
|
||||
|
||||
addPropertyAsOutput(propertyName: string, type: string) {
|
||||
if (this.shownOutputProperties["@" + propertyName])
|
||||
if (this.shownOutputProperties[propertyName])
|
||||
return;
|
||||
|
||||
if (!(propertyName in this.properties)) {
|
||||
throw `No property named ${propertyName} found!`
|
||||
}
|
||||
|
||||
this.shownOutputProperties["@" + propertyName] = { type, index: this.outputs.length }
|
||||
this.addOutput("@" + propertyName, type)
|
||||
const outputName = "@" + propertyName;
|
||||
this.shownOutputProperties[propertyName] = { type, outputName }
|
||||
this.addOutput(outputName, type)
|
||||
}
|
||||
|
||||
formatValue(value: any): string {
|
||||
@@ -174,8 +177,11 @@ export default abstract class ComfyWidgetNode<T = any> extends ComfyGraphNode {
|
||||
override onPropertyChanged(property: string, value: any, prevValue?: any) {
|
||||
if (this.shownOutputProperties != null) {
|
||||
const data = this.shownOutputProperties[property]
|
||||
if (data)
|
||||
this.setOutputData(data.index, value)
|
||||
if (data) {
|
||||
const index = this.findOutputSlotIndexByName(data.outputName)
|
||||
if (index !== -1)
|
||||
this.setOutputData(index, value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,6 +189,15 @@ export default abstract class ComfyWidgetNode<T = any> extends ComfyGraphNode {
|
||||
* Logic to run if this widget can be treated as output (slider, combo, text)
|
||||
*/
|
||||
override onExecute(param: any, options: object) {
|
||||
if (this.inputSlotName != null) {
|
||||
const inputIndex = this.findInputSlotIndexByName(this.inputSlotName)
|
||||
if (inputIndex !== -1) {
|
||||
const data = this.getInputData(inputIndex)
|
||||
if (data != null) { // TODO can "null" be a legitimate value here?
|
||||
this.setValue(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.outputSlotName != null) {
|
||||
const outputIndex = this.findOutputSlotIndexByName(this.outputSlotName)
|
||||
if (outputIndex !== -1)
|
||||
@@ -190,7 +205,9 @@ export default abstract class ComfyWidgetNode<T = any> extends ComfyGraphNode {
|
||||
}
|
||||
for (const propName in this.shownOutputProperties) {
|
||||
const data = this.shownOutputProperties[propName]
|
||||
this.setOutputData(data.index, this.properties[propName])
|
||||
const index = this.findOutputSlotIndexByName(data.outputName)
|
||||
if (index !== -1)
|
||||
this.setOutputData(index, this.properties[propName])
|
||||
}
|
||||
|
||||
// Fire a pending change event after one full step of the graph has
|
||||
|
||||
Reference in New Issue
Block a user