Fix widget autoconfig
This commit is contained in:
@@ -10,7 +10,7 @@ import type { SvelteComponentDev } from "svelte/internal";
|
|||||||
import { Watch } from "@litegraph-ts/nodes-basic";
|
import { Watch } from "@litegraph-ts/nodes-basic";
|
||||||
import type IComfyInputSlot from "$lib/IComfyInputSlot";
|
import type IComfyInputSlot from "$lib/IComfyInputSlot";
|
||||||
import { writable, type Unsubscriber, type Writable, get } from "svelte/store";
|
import { writable, type Unsubscriber, type Writable, get } from "svelte/store";
|
||||||
import { clamp } from "$lib/utils"
|
import { clamp, range } from "$lib/utils"
|
||||||
import layoutState from "$lib/stores/layoutState";
|
import layoutState from "$lib/stores/layoutState";
|
||||||
import type { FileData as GradioFileData } from "@gradio/upload";
|
import type { FileData as GradioFileData } from "@gradio/upload";
|
||||||
import queueState from "$lib/stores/queueState";
|
import queueState from "$lib/stores/queueState";
|
||||||
@@ -143,7 +143,9 @@ export abstract class ComfyWidgetNode<T = any> extends ComfyGraphNode {
|
|||||||
inputNode: LGraphNode,
|
inputNode: LGraphNode,
|
||||||
inputIndex: number
|
inputIndex: number
|
||||||
): boolean {
|
): boolean {
|
||||||
if (this.autoConfig && "config" in input && this.outputs.length === 0) {
|
const anyConnected = range(this.outputs.length).some(i => this.getOutputLinks(i).length > 0);
|
||||||
|
|
||||||
|
if (this.autoConfig && "config" in input && !anyConnected) {
|
||||||
this.doAutoConfig(input as IComfyInputSlot)
|
this.doAutoConfig(input as IComfyInputSlot)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ export function clamp(n: number, min: number, max: number): number {
|
|||||||
return Math.min(Math.max(n, min), max)
|
return Math.min(Math.max(n, min), max)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function range(size: number, startAt: number = 0): ReadonlyArray<number> {
|
||||||
|
return [...Array(size).keys()].map(i => i + startAt);
|
||||||
|
}
|
||||||
|
|
||||||
export function download(filename: string, text: string, type: string = "text/plain") {
|
export function download(filename: string, text: string, type: string = "text/plain") {
|
||||||
const blob = new Blob([text], { type: type });
|
const blob = new Blob([text], { type: type });
|
||||||
const url = URL.createObjectURL(blob);
|
const url = URL.createObjectURL(blob);
|
||||||
|
|||||||
Reference in New Issue
Block a user