Huge refactoring for multiple workflows
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import type { SerializedPrompt } from "$lib/components/ComfyApp";
|
||||
import notify from "$lib/notify";
|
||||
import layoutState, { type DragItemID } from "$lib/stores/layoutState";
|
||||
import { type DragItemID } from "$lib/stores/layoutStates";
|
||||
import queueState from "$lib/stores/queueState";
|
||||
import { BuiltInSlotType, LiteGraph, NodeMode, type ITextWidget, type IToggleWidget, type SerializedLGraphNode, type SlotLayout, type PropertyLayout } from "@litegraph-ts/core";
|
||||
import { get } from "svelte/store";
|
||||
@@ -389,7 +389,7 @@ export class ComfySetNodeModeAction extends ComfyGraphNode {
|
||||
}
|
||||
}
|
||||
|
||||
for (const entry of Object.values(get(layoutState).allItems)) {
|
||||
for (const entry of Object.values(get(this.layoutState).allItems)) {
|
||||
if (entry.dragItem.type === "container") {
|
||||
const container = entry.dragItem;
|
||||
const hasTag = tags.some(t => container.attrs.tags.indexOf(t) != -1);
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
import layoutState from "$lib/stores/layoutState"
|
||||
import layoutStates from "$lib/stores/layoutStates"
|
||||
import { BuiltInSlotType, LGraphNode, LiteGraph, type ITextWidget, type OptionalSlots, type PropertyLayout, type SlotLayout, type Vector2 } from "@litegraph-ts/core"
|
||||
import { get } from "svelte/store"
|
||||
import ComfyGraphNode from "./ComfyGraphNode"
|
||||
|
||||
export interface ComfyConfigureQueuePromptButtonProperties extends Record<string, any> {
|
||||
}
|
||||
|
||||
export default class ComfyConfigureQueuePromptButton extends LGraphNode {
|
||||
override properties: ComfyConfigureQueuePromptButtonProperties = {
|
||||
}
|
||||
|
||||
export default class ComfyConfigureQueuePromptButton extends ComfyGraphNode {
|
||||
static slotLayout: SlotLayout = {
|
||||
inputs: [
|
||||
{ name: "config", type: BuiltInSlotType.ACTION },
|
||||
@@ -28,7 +24,12 @@ export default class ComfyConfigureQueuePromptButton extends LGraphNode {
|
||||
|
||||
override onAction(action: any, param: any, options: { action_call?: string }) {
|
||||
if (action === "config" && param != null) {
|
||||
layoutState.update(state => {
|
||||
if (this.layoutState == null) {
|
||||
console.error(this, this.getRootGraph(), Object.keys(get(layoutStates).all))
|
||||
throw new Error(`Could not find layout attached to this node! ${this.id}`)
|
||||
}
|
||||
|
||||
this.layoutState.update(state => {
|
||||
if (typeof param === "string")
|
||||
state.attrs.queuePromptButtonName = param || ""
|
||||
else if (typeof param === "object" && "buttonName" in param)
|
||||
|
||||
@@ -8,6 +8,8 @@ import type IComfyInputSlot from "$lib/IComfyInputSlot";
|
||||
import uiState from "$lib/stores/uiState";
|
||||
import { get } from "svelte/store";
|
||||
import configState from "$lib/stores/configState";
|
||||
import type { WritableLayoutStateStore } from "$lib/stores/layoutStates";
|
||||
import layoutStates from "$lib/stores/layoutStates";
|
||||
|
||||
export type DefaultWidgetSpec = {
|
||||
defaultWidgetNode: new (name?: string) => ComfyWidgetNode,
|
||||
@@ -100,6 +102,10 @@ export default class ComfyGraphNode extends LGraphNode {
|
||||
return null;
|
||||
}
|
||||
|
||||
get layoutState(): WritableLayoutStateStore | null {
|
||||
return layoutStates.getLayoutByNode(this);
|
||||
}
|
||||
|
||||
constructor(title?: string) {
|
||||
super(title)
|
||||
this.addProperty("tags", [], "array")
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import type IComfyInputSlot from "$lib/IComfyInputSlot";
|
||||
import layoutState from "$lib/stores/layoutState";
|
||||
import { range } from "$lib/utils";
|
||||
import { LConnectionKind, LGraphCanvas, LLink, LiteGraph, NodeMode, type INodeInputSlot, type INodeOutputSlot, type ITextWidget, type LGraphNode, type SerializedLGraphNode, type Vector2 } from "@litegraph-ts/core";
|
||||
import { Watch } from "@litegraph-ts/nodes-basic";
|
||||
@@ -269,7 +268,7 @@ export default abstract class ComfyWidgetNode<T = any> extends ComfyGraphNode {
|
||||
}
|
||||
|
||||
if (options.setWidgetTitle) {
|
||||
const widget = layoutState.findLayoutForNode(this.id as ComfyNodeID)
|
||||
const widget = this.layoutState.findLayoutForNode(this.id as ComfyNodeID)
|
||||
if (widget && input.name !== "") {
|
||||
widget.attrs.title = input.name;
|
||||
}
|
||||
@@ -288,7 +287,7 @@ export default abstract class ComfyWidgetNode<T = any> extends ComfyGraphNode {
|
||||
}
|
||||
|
||||
notifyPropsChanged() {
|
||||
const layoutEntry = layoutState.findLayoutEntryForNode(this.id as ComfyNodeID)
|
||||
const layoutEntry = this.layoutState.findLayoutEntryForNode(this.id as ComfyNodeID)
|
||||
if (layoutEntry && layoutEntry.parent) {
|
||||
layoutEntry.parent.attrsChanged.set(get(layoutEntry.parent.attrsChanged) + 1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user