diff --git a/src/components/graph/selectionToolbox/ConfigureSubgraph.vue b/src/components/graph/selectionToolbox/ConfigureSubgraph.vue index 5c361aa73e..ce7f63799e 100644 --- a/src/components/graph/selectionToolbox/ConfigureSubgraph.vue +++ b/src/components/graph/selectionToolbox/ConfigureSubgraph.vue @@ -13,5 +13,5 @@ diff --git a/src/composables/useCoreCommands.ts b/src/composables/useCoreCommands.ts index 966fe40e45..7a18fe00fb 100644 --- a/src/composables/useCoreCommands.ts +++ b/src/composables/useCoreCommands.ts @@ -5,8 +5,7 @@ import { DEFAULT_DARK_COLOR_PALETTE, DEFAULT_LIGHT_COLOR_PALETTE } from '@/constants/coreColorPalettes' -import { tryToggleWidgetPromotion } from '@/core/graph/subgraph/proxyWidgetUtils' -import { showSubgraphNodeDialog } from '@/core/graph/subgraph/useSubgraphNodeDialog' +import { showSubgraphNodeDialog } from '@/workbench/graph/subgraph/useSubgraphNodeDialog' import { t } from '@/i18n' import { LGraphEventMode, @@ -37,6 +36,7 @@ import { api } from '@/scripts/api' import { app } from '@/scripts/app' import { useDialogService } from '@/services/dialogService' import { useLitegraphService } from '@/services/litegraphService' +import { invokeToggleWidgetPromotion } from '@/services/widgetPromotionHandlers' import type { ComfyCommand } from '@/stores/commandStore' import { useExecutionStore } from '@/stores/executionStore' import { useHelpCenterStore } from '@/stores/helpCenterStore' @@ -1027,7 +1027,7 @@ export function useCoreCommands(): ComfyCommand[] { icon: 'icon-[lucide--arrow-left-right]', label: 'Toggle promotion of hovered widget', versionAdded: '1.30.1', - function: tryToggleWidgetPromotion + function: () => invokeToggleWidgetPromotion() }, { id: 'Comfy.OpenManagerDialog', diff --git a/src/core/graph/subgraph/proxyWidget.ts b/src/renderer/graph/subgraph/proxyWidget.ts similarity index 99% rename from src/core/graph/subgraph/proxyWidget.ts rename to src/renderer/graph/subgraph/proxyWidget.ts index ef04bd76b9..cb2432fbd4 100644 --- a/src/core/graph/subgraph/proxyWidget.ts +++ b/src/renderer/graph/subgraph/proxyWidget.ts @@ -1,7 +1,7 @@ import { demoteWidget, promoteRecommendedWidgets -} from '@/core/graph/subgraph/proxyWidgetUtils' +} from '@/renderer/graph/subgraph/proxyWidgetUtils' import { parseProxyWidgets } from '@/core/schemas/proxyWidget' import type { NodeProperty } from '@/lib/litegraph/src/LGraphNode' import type { diff --git a/src/core/graph/subgraph/proxyWidgetUtils.ts b/src/renderer/graph/subgraph/proxyWidgetUtils.ts similarity index 95% rename from src/core/graph/subgraph/proxyWidgetUtils.ts rename to src/renderer/graph/subgraph/proxyWidgetUtils.ts index 27961e54dc..162ae44ee9 100644 --- a/src/core/graph/subgraph/proxyWidgetUtils.ts +++ b/src/renderer/graph/subgraph/proxyWidgetUtils.ts @@ -3,7 +3,7 @@ import type { ProxyWidgetsProperty } from '@/core/schemas/proxyWidget' import { isProxyWidget, isDisconnectedWidget -} from '@/core/graph/subgraph/proxyWidget' +} from '@/renderer/graph/subgraph/proxyWidget' import { t } from '@/i18n' import type { IContextMenuValue, @@ -14,6 +14,7 @@ import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets.ts' import { useToastStore } from '@/platform/updates/common/toastStore' import { useCanvasStore } from '@/renderer/core/canvas/canvasStore' import { useLitegraphService } from '@/services/litegraphService' +import { registerWidgetPromotionHandlers } from '@/services/widgetPromotionHandlers' import { useSubgraphNavigationStore } from '@/stores/subgraphNavigationStore' type PartialNode = Pick @@ -86,7 +87,7 @@ function getParentNodes(): SubgraphNode[] { ) } -export function addWidgetPromotionOptions( +function addWidgetPromotionOptions( options: (IContextMenuValue | null)[], widget: IBaseWidget, node: LGraphNode @@ -111,7 +112,7 @@ export function addWidgetPromotionOptions( }) } } -export function tryToggleWidgetPromotion() { +function tryToggleWidgetPromotion() { const canvas = useCanvasStore().getCanvas() const [x, y] = canvas.graph_mouse const node = canvas.graph?.getNodeOnPos(x, y, canvas.visible_nodes) @@ -174,3 +175,8 @@ export function pruneDisconnected(subgraphNode: SubgraphNode) { .filter((w) => !isDisconnectedWidget(w)) .map((w) => [w._overlay.nodeId, w._overlay.widgetName]) } + +registerWidgetPromotionHandlers({ + addWidgetPromotionOptions, + tryToggleWidgetPromotion +}) diff --git a/src/scripts/app.ts b/src/scripts/app.ts index a0479b5b28..fcd4edc241 100644 --- a/src/scripts/app.ts +++ b/src/scripts/app.ts @@ -5,7 +5,7 @@ import { reactive, unref } from 'vue' import { shallowRef } from 'vue' import { useCanvasPositionConversion } from '@/composables/element/useCanvasPositionConversion' -import { registerProxyWidgets } from '@/core/graph/subgraph/proxyWidget' +import { registerProxyWidgets } from '@/renderer/graph/subgraph/proxyWidget' import { st, t } from '@/i18n' import type { IContextMenuValue } from '@/lib/litegraph/src/interfaces' import { diff --git a/src/services/litegraphService.ts b/src/services/litegraphService.ts index 3fe45fcea2..33ab9197fe 100644 --- a/src/services/litegraphService.ts +++ b/src/services/litegraphService.ts @@ -5,8 +5,7 @@ import { useSelectedLiteGraphItems } from '@/composables/canvas/useSelectedLiteG import { useNodeAnimatedImage } from '@/composables/node/useNodeAnimatedImage' import { useNodeCanvasImagePreview } from '@/composables/node/useNodeCanvasImagePreview' import { useNodeImage, useNodeVideo } from '@/composables/node/useNodeImage' -import { addWidgetPromotionOptions } from '@/core/graph/subgraph/proxyWidgetUtils' -import { showSubgraphNodeDialog } from '@/core/graph/subgraph/useSubgraphNodeDialog' +import { showSubgraphNodeDialog } from '@/workbench/graph/subgraph/useSubgraphNodeDialog' import { st, t } from '@/i18n' import { LGraphCanvas, @@ -58,6 +57,7 @@ import { import { getOrderedInputSpecs } from '@/utils/nodeDefOrderingUtil' import { useExtensionService } from './extensionService' +import { addWidgetPromotionOptions as invokeAddWidgetPromotionOptions } from './widgetPromotionHandlers' export const CONFIG = Symbol() export const GET_CONFIG = Symbol() @@ -826,7 +826,7 @@ export const useLitegraphService = () => { const [x, y] = canvas.graph_mouse const overWidget = this.getWidgetOnPos(x, y, true) if (overWidget) { - addWidgetPromotionOptions(options, overWidget, this) + invokeAddWidgetPromotionOptions(options, overWidget, this) } } diff --git a/src/services/widgetPromotionHandlers.ts b/src/services/widgetPromotionHandlers.ts new file mode 100644 index 0000000000..8a1a2e1e1a --- /dev/null +++ b/src/services/widgetPromotionHandlers.ts @@ -0,0 +1,41 @@ +import { shallowRef } from 'vue' + +import type { + IContextMenuValue, + LGraphNode +} from '@/lib/litegraph/src/litegraph' +import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets' + +type WidgetPromotionHandlers = { + addWidgetPromotionOptions?: ( + options: (IContextMenuValue | null)[], + widget: IBaseWidget, + node: LGraphNode + ) => void + tryToggleWidgetPromotion?: () => void +} + +const handlersRef = shallowRef({}) + +export const registerWidgetPromotionHandlers = ( + handlers: WidgetPromotionHandlers +) => { + handlersRef.value = handlers + return () => { + if (handlersRef.value === handlers) { + handlersRef.value = {} + } + } +} + +export const invokeToggleWidgetPromotion = () => { + handlersRef.value.tryToggleWidgetPromotion?.() +} + +export const addWidgetPromotionOptions = ( + options: (IContextMenuValue | null)[], + widget: IBaseWidget, + node: LGraphNode +) => { + handlersRef.value.addWidgetPromotionOptions?.(options, widget, node) +} diff --git a/src/core/graph/subgraph/SubgraphNode.vue b/src/workbench/graph/subgraph/SubgraphNode.vue similarity index 97% rename from src/core/graph/subgraph/SubgraphNode.vue rename to src/workbench/graph/subgraph/SubgraphNode.vue index 7be5246f2f..6198d671be 100644 --- a/src/core/graph/subgraph/SubgraphNode.vue +++ b/src/workbench/graph/subgraph/SubgraphNode.vue @@ -10,7 +10,12 @@ import { } from 'vue' import SearchBox from '@/components/common/SearchBox.vue' -import SubgraphNodeWidget from '@/core/graph/subgraph/SubgraphNodeWidget.vue' +import { parseProxyWidgets } from '@/core/schemas/proxyWidget' +import type { ProxyWidgetsProperty } from '@/core/schemas/proxyWidget' +import type { LGraphNode } from '@/lib/litegraph/src/litegraph' +import { SubgraphNode } from '@/lib/litegraph/src/subgraph/SubgraphNode' +import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets' +import { useCanvasStore } from '@/renderer/core/canvas/canvasStore' import { demoteWidget, isRecommendedWidget, @@ -19,17 +24,12 @@ import { promoteWidget, pruneDisconnected, widgetItemToProperty -} from '@/core/graph/subgraph/proxyWidgetUtils' -import type { WidgetItem } from '@/core/graph/subgraph/proxyWidgetUtils' -import { parseProxyWidgets } from '@/core/schemas/proxyWidget' -import type { ProxyWidgetsProperty } from '@/core/schemas/proxyWidget' -import type { LGraphNode } from '@/lib/litegraph/src/litegraph' -import { SubgraphNode } from '@/lib/litegraph/src/subgraph/SubgraphNode' -import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets' -import { useCanvasStore } from '@/renderer/core/canvas/canvasStore' +} from '@/renderer/graph/subgraph/proxyWidgetUtils' +import type { WidgetItem } from '@/renderer/graph/subgraph/proxyWidgetUtils' import { DraggableList } from '@/scripts/ui/draggableList' import { useLitegraphService } from '@/services/litegraphService' import { useDialogStore } from '@/stores/dialogStore' +import SubgraphNodeWidget from '@/workbench/graph/subgraph/SubgraphNodeWidget.vue' const canvasStore = useCanvasStore() diff --git a/src/core/graph/subgraph/SubgraphNodeWidget.vue b/src/workbench/graph/subgraph/SubgraphNodeWidget.vue similarity index 100% rename from src/core/graph/subgraph/SubgraphNodeWidget.vue rename to src/workbench/graph/subgraph/SubgraphNodeWidget.vue diff --git a/src/core/graph/subgraph/useSubgraphNodeDialog.ts b/src/workbench/graph/subgraph/useSubgraphNodeDialog.ts similarity index 89% rename from src/core/graph/subgraph/useSubgraphNodeDialog.ts rename to src/workbench/graph/subgraph/useSubgraphNodeDialog.ts index 6004e28509..f87ceffc3a 100644 --- a/src/core/graph/subgraph/useSubgraphNodeDialog.ts +++ b/src/workbench/graph/subgraph/useSubgraphNodeDialog.ts @@ -1,4 +1,4 @@ -import SubgraphNode from '@/core/graph/subgraph/SubgraphNode.vue' +import SubgraphNode from '@/workbench/graph/subgraph/SubgraphNode.vue' import { useDialogStore } from '@/stores/dialogStore' import type { DialogComponentProps } from '@/stores/dialogStore' diff --git a/tests-ui/tests/widgets/proxyWidget.test.ts b/tests-ui/tests/widgets/proxyWidget.test.ts index 940ee66f0e..78b70265b4 100644 --- a/tests-ui/tests/widgets/proxyWidget.test.ts +++ b/tests-ui/tests/widgets/proxyWidget.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test, vi } from 'vitest' -import { registerProxyWidgets } from '@/core/graph/subgraph/proxyWidget' +import { registerProxyWidgets } from '@/renderer/graph/subgraph/proxyWidget' import { parseProxyWidgets } from '@/core/schemas/proxyWidget' import { LGraphNode } from '@/lib/litegraph/src/litegraph' import type { LGraphCanvas, SubgraphNode } from '@/lib/litegraph/src/litegraph'