mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-28 18:22:40 +00:00
Fix DOM widgets after rebase
This commit is contained in:
@@ -5,7 +5,7 @@ import {
|
|||||||
LGraphNode,
|
LGraphNode,
|
||||||
LiteGraph
|
LiteGraph
|
||||||
} from '@comfyorg/litegraph'
|
} from '@comfyorg/litegraph'
|
||||||
import type { Vector2 } from '@comfyorg/litegraph'
|
import type { Subgraph, Vector2 } from '@comfyorg/litegraph'
|
||||||
import type { IBaseWidget } from '@comfyorg/litegraph/dist/types/widgets'
|
import type { IBaseWidget } from '@comfyorg/litegraph/dist/types/widgets'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import type { ToastMessageOptions } from 'primevue/toast'
|
import type { ToastMessageOptions } from 'primevue/toast'
|
||||||
@@ -43,6 +43,7 @@ import { useSubgraphService } from '@/services/subgraphService'
|
|||||||
import { useWorkflowService } from '@/services/workflowService'
|
import { useWorkflowService } from '@/services/workflowService'
|
||||||
import { useApiKeyAuthStore } from '@/stores/apiKeyAuthStore'
|
import { useApiKeyAuthStore } from '@/stores/apiKeyAuthStore'
|
||||||
import { useCommandStore } from '@/stores/commandStore'
|
import { useCommandStore } from '@/stores/commandStore'
|
||||||
|
import { useDomWidgetStore } from '@/stores/domWidgetStore'
|
||||||
import { useExecutionStore } from '@/stores/executionStore'
|
import { useExecutionStore } from '@/stores/executionStore'
|
||||||
import { useExtensionStore } from '@/stores/extensionStore'
|
import { useExtensionStore } from '@/stores/extensionStore'
|
||||||
import { useFirebaseAuthStore } from '@/stores/firebaseAuthStore'
|
import { useFirebaseAuthStore } from '@/stores/firebaseAuthStore'
|
||||||
@@ -73,6 +74,7 @@ import { deserialiseAndCreate } from '@/utils/vintageClipboard'
|
|||||||
|
|
||||||
import { type ComfyApi, PromptExecutionError, api } from './api'
|
import { type ComfyApi, PromptExecutionError, api } from './api'
|
||||||
import { defaultGraph } from './defaultGraph'
|
import { defaultGraph } from './defaultGraph'
|
||||||
|
import type { BaseDOMWidget } from './domWidget'
|
||||||
import { pruneWidgets } from './domWidget'
|
import { pruneWidgets } from './domWidget'
|
||||||
import {
|
import {
|
||||||
getFlacMetadata,
|
getFlacMetadata,
|
||||||
@@ -716,7 +718,7 @@ export class ComfyApp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#addAfterConfigureHandler() {
|
#addAfterConfigureHandler() {
|
||||||
const { graph } = this
|
const { canvas, graph } = this
|
||||||
const { onConfigure } = graph
|
const { onConfigure } = graph
|
||||||
graph.onConfigure = function (...args) {
|
graph.onConfigure = function (...args) {
|
||||||
fixLinkInputSlots(this)
|
fixLinkInputSlots(this)
|
||||||
@@ -733,7 +735,8 @@ export class ComfyApp {
|
|||||||
node.onAfterGraphConfigured?.()
|
node.onAfterGraphConfigured?.()
|
||||||
}
|
}
|
||||||
|
|
||||||
pruneWidgets(this.nodes)
|
const nodes = canvas.subgraph?.nodes ?? graph.nodes
|
||||||
|
pruneWidgets(nodes)
|
||||||
|
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
@@ -792,6 +795,27 @@ export class ComfyApp {
|
|||||||
LiteGraph.alt_drag_do_clone_nodes = true
|
LiteGraph.alt_drag_do_clone_nodes = true
|
||||||
LiteGraph.macGesturesRequireMac = false
|
LiteGraph.macGesturesRequireMac = false
|
||||||
|
|
||||||
|
this.canvas.canvas.addEventListener('litegraph:set-graph', (e) => {
|
||||||
|
type SetGraphType = CustomEvent<{
|
||||||
|
newGraph: LGraph | Subgraph
|
||||||
|
oldGraph: LGraph | Subgraph
|
||||||
|
}>
|
||||||
|
|
||||||
|
// Assertion: Not yet defined in litegraph.
|
||||||
|
const { newGraph } = (e as SetGraphType).detail
|
||||||
|
|
||||||
|
const nodeSet = new Set(newGraph.nodes)
|
||||||
|
const widgetStore = useDomWidgetStore()
|
||||||
|
for (const { widget } of widgetStore.widgetStates.values()) {
|
||||||
|
// Assertions: UnwrapRef
|
||||||
|
if (nodeSet.has(widget.node as LGraphNode)) {
|
||||||
|
widgetStore.registerWidget(widget as BaseDOMWidget)
|
||||||
|
} else {
|
||||||
|
widgetStore.unregisterWidget(widget.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
this.graph.start()
|
this.graph.start()
|
||||||
|
|
||||||
// Ensure the canvas fills the window
|
// Ensure the canvas fills the window
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import type { InputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2'
|
|||||||
import { useDomWidgetStore } from '@/stores/domWidgetStore'
|
import { useDomWidgetStore } from '@/stores/domWidgetStore'
|
||||||
import { generateUUID } from '@/utils/formatUtil'
|
import { generateUUID } from '@/utils/formatUtil'
|
||||||
|
|
||||||
export interface BaseDOMWidget<V extends object | string>
|
export interface BaseDOMWidget<V extends object | string = object | string>
|
||||||
extends IBaseWidget<V, string, DOMWidgetOptions<V>> {
|
extends IBaseWidget<V, string, DOMWidgetOptions<V>> {
|
||||||
// ICustomWidget properties
|
// ICustomWidget properties
|
||||||
type: string
|
type: string
|
||||||
|
|||||||
Reference in New Issue
Block a user