move data model to workfbench

This commit is contained in:
bymyself
2025-11-11 11:34:37 -08:00
parent 6c9743c1a6
commit 8bb1d5724b
10 changed files with 60 additions and 25 deletions

View File

@@ -13,5 +13,5 @@
<script setup lang="ts">
import Button from 'primevue/button'
import { showSubgraphNodeDialog } from '@/core/graph/subgraph/useSubgraphNodeDialog'
import { showSubgraphNodeDialog } from '@/workbench/graph/subgraph/useSubgraphNodeDialog'
</script>

View File

@@ -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,
@@ -36,7 +35,10 @@ import { selectionBounds } from '@/renderer/core/layout/utils/layoutMath'
import { api } from '@/scripts/api'
import { app } from '@/scripts/app'
import { useDialogService } from '@/services/dialogService'
import { useLitegraphService } from '@/services/litegraphService'
import {
invokeToggleWidgetPromotion,
useLitegraphService
} from '@/services/litegraphService'
import type { ComfyCommand } from '@/stores/commandStore'
import { useExecutionStore } from '@/stores/executionStore'
import { useHelpCenterStore } from '@/stores/helpCenterStore'
@@ -1027,7 +1029,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',

View File

@@ -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 {

View File

@@ -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,
@@ -13,7 +13,10 @@ import type { SubgraphNode } from '@/lib/litegraph/src/subgraph/SubgraphNode'
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,
useLitegraphService
} from '@/services/litegraphService'
import { useSubgraphNavigationStore } from '@/stores/subgraphNavigationStore'
type PartialNode = Pick<LGraphNode, 'title' | 'id' | 'type'>
@@ -86,7 +89,7 @@ function getParentNodes(): SubgraphNode[] {
)
}
export function addWidgetPromotionOptions(
function addWidgetPromotionOptions(
options: (IContextMenuValue<unknown> | null)[],
widget: IBaseWidget,
node: LGraphNode
@@ -111,7 +114,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 +177,8 @@ export function pruneDisconnected(subgraphNode: SubgraphNode) {
.filter((w) => !isDisconnectedWidget(w))
.map((w) => [w._overlay.nodeId, w._overlay.widgetName])
}
registerWidgetPromotionHandlers({
addWidgetPromotionOptions,
tryToggleWidgetPromotion
})

View File

@@ -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 {

View File

@@ -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,
@@ -22,6 +21,7 @@ import type {
Point,
Subgraph
} from '@/lib/litegraph/src/litegraph'
import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets'
import type {
ExportedSubgraphInstance,
ISerialisableNodeInput,
@@ -62,6 +62,27 @@ import { useExtensionService } from './extensionService'
export const CONFIG = Symbol()
export const GET_CONFIG = Symbol()
type WidgetPromotionHandlers = {
addWidgetPromotionOptions?: (
options: (IContextMenuValue<unknown> | null)[],
widget: IBaseWidget,
node: LGraphNode
) => void
tryToggleWidgetPromotion?: () => void
}
let widgetPromotionHandlers: WidgetPromotionHandlers = {}
export const registerWidgetPromotionHandlers = (
handlers: WidgetPromotionHandlers
) => {
widgetPromotionHandlers = handlers
}
export const invokeToggleWidgetPromotion = () => {
widgetPromotionHandlers.tryToggleWidgetPromotion?.()
}
/**
* Service that augments litegraph with ComfyUI specific functionality.
*/
@@ -826,7 +847,11 @@ export const useLitegraphService = () => {
const [x, y] = canvas.graph_mouse
const overWidget = this.getWidgetOnPos(x, y, true)
if (overWidget) {
addWidgetPromotionOptions(options, overWidget, this)
widgetPromotionHandlers.addWidgetPromotionOptions?.(
options,
overWidget,
this
)
}
}

View File

@@ -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()

View File

@@ -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'

View File

@@ -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'