Skip to content

Commit 2f1eba1

Browse files
refactor: Reorganize Vue nodes system to domain-driven design architecture
Move Vue nodes code from scattered technical layers to domain-focused structure: - Widget system → src/renderer/extensions/vueNodes/widgets/ - LOD optimization → src/renderer/extensions/vueNodes/lod/ - Layout logic → src/renderer/extensions/vueNodes/layout/ - Node components → src/renderer/extensions/vueNodes/components/ - Test structure mirrors source organization Benefits: - Clear domain boundaries instead of technical layers - Everything Vue nodes related in renderer domain (not workbench) - camelCase naming (vueNodes vs vue-nodes) - Tests co-located with source domains
1 parent 0e236b8 commit 2f1eba1

File tree

71 files changed

+4979
-57
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+4979
-57
lines changed

src/components/graph/vueNodes/LGraphNode.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ import { computed, onErrorCaptured, ref, toRef, watch } from 'vue'
9191
9292
// Import the VueNodeData type
9393
import type { VueNodeData } from '@/composables/graph/useGraphNodeManager'
94-
import { LODLevel, useLOD } from '@/composables/graph/useLOD'
94+
import { LODLevel, useLOD } from '@/renderer/extensions/vueNodes/lod/useLOD'
9595
import { useErrorHandling } from '@/composables/useErrorHandling'
96-
import { useNodeLayout } from '@/renderer/extensions/vue-nodes/composables/useNodeLayout'
96+
import { useNodeLayout } from '@/renderer/extensions/vueNodes/layout/useNodeLayout'
9797
9898
import { LiteGraph } from '../../../lib/litegraph/src/litegraph'
9999
import NodeContent from './NodeContent.vue'

src/components/graph/vueNodes/NodeContent.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import { onErrorCaptured, ref } from 'vue'
1717
1818
import type { VueNodeData } from '@/composables/graph/useGraphNodeManager'
19-
import type { LODLevel } from '@/composables/graph/useLOD'
19+
import type { LODLevel } from '@/renderer/extensions/vueNodes/lod/useLOD'
2020
import { useErrorHandling } from '@/composables/useErrorHandling'
2121
2222
import type { LGraphNode } from '../../../lib/litegraph/src/litegraph'

src/components/graph/vueNodes/NodeHeader.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import { computed, onErrorCaptured, ref, watch } from 'vue'
4545
4646
import EditableText from '@/components/common/EditableText.vue'
4747
import type { VueNodeData } from '@/composables/graph/useGraphNodeManager'
48-
import type { LODLevel } from '@/composables/graph/useLOD'
48+
import type { LODLevel } from '@/renderer/extensions/vueNodes/lod/useLOD'
4949
import { useErrorHandling } from '@/composables/useErrorHandling'
5050
5151
import type { LGraphNode } from '../../../lib/litegraph/src/litegraph'

src/components/graph/vueNodes/NodeSlots.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import { computed, onErrorCaptured, onUnmounted, ref } from 'vue'
3535
3636
import { useEventForwarding } from '@/composables/graph/useEventForwarding'
3737
import type { VueNodeData } from '@/composables/graph/useGraphNodeManager'
38-
import type { LODLevel } from '@/composables/graph/useLOD'
38+
import type { LODLevel } from '@/renderer/extensions/vueNodes/lod/useLOD'
3939
import { useErrorHandling } from '@/composables/useErrorHandling'
4040
import { isSlotObject } from '@/utils/typeGuardUtil'
4141

src/components/graph/vueNodes/NodeWidgets.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,22 @@
4242
import { computed, onErrorCaptured, onUnmounted, ref } from 'vue'
4343
4444
// Import widget components directly
45-
import WidgetInputText from '@/components/graph/vueWidgets/WidgetInputText.vue'
46-
import { widgetTypeToComponent } from '@/components/graph/vueWidgets/widgetRegistry'
45+
import WidgetInputText from '@/renderer/extensions/vueNodes/widgets/components/WidgetInputText.vue'
46+
import { widgetTypeToComponent } from '@/renderer/extensions/vueNodes/widgets/registry/widgetRegistry'
4747
import { useEventForwarding } from '@/composables/graph/useEventForwarding'
4848
import type {
4949
SafeWidgetData,
5050
VueNodeData
5151
} from '@/composables/graph/useGraphNodeManager'
52-
import { LODLevel } from '@/composables/graph/useLOD'
52+
import { LODLevel } from '@/renderer/extensions/vueNodes/lod/useLOD'
5353
import {
5454
ESSENTIAL_WIDGET_TYPES,
5555
useWidgetRenderer
56-
} from '@/composables/graph/useWidgetRenderer'
56+
} from '@/renderer/extensions/vueNodes/widgets/composables/useWidgetRenderer'
5757
import { useErrorHandling } from '@/composables/useErrorHandling'
5858
import type { SimplifiedWidget, WidgetValue } from '@/types/simplifiedWidget'
5959
60-
import type { LGraphNode } from '../../../lib/litegraph/src/litegraph'
60+
import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
6161
import InputSlot from './InputSlot.vue'
6262
6363
interface NodeWidgetsProps {

src/composables/node/useNodeCanvasImagePreview.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useImagePreviewWidget } from '@/composables/widgets/useImagePreviewWidget'
1+
import { useImagePreviewWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useImagePreviewWidget'
22
import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
33

44
const CANVAS_IMAGE_PREVIEW_WIDGET = '$$canvas-image-preview'

src/composables/node/useNodeChatHistory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type ChatHistoryWidget from '@/components/graph/widgets/ChatHistoryWidget.vue'
2-
import { useChatHistoryWidget } from '@/composables/widgets/useChatHistoryWidget'
2+
import { useChatHistoryWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useChatHistoryWidget'
33
import { LGraphNode } from '@/lib/litegraph/src/litegraph'
44

55
const CHAT_HISTORY_WIDGET_NAME = '$$node-chat-history'

src/composables/node/useNodeProgressText.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useTextPreviewWidget } from '@/composables/widgets/useProgressTextWidget'
1+
import { useTextPreviewWidget } from '@/renderer/extensions/vueNodes/widgets/composables/useProgressTextWidget'
22
import { LGraphNode } from '@/lib/litegraph/src/litegraph'
33

44
const TEXT_PREVIEW_WIDGET_NAME = '$$node-text-preview'
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<template>
2+
<div v-if="renderError" class="node-error p-1 text-red-500 text-xs">⚠️</div>
3+
<div
4+
v-else
5+
class="lg-slot lg-slot--input flex items-center cursor-crosshair group"
6+
:class="{
7+
'opacity-70': readonly,
8+
'lg-slot--connected': connected,
9+
'lg-slot--compatible': compatible,
10+
'lg-slot--dot-only': dotOnly,
11+
'pr-2 hover:bg-black/5': !dotOnly
12+
}"
13+
:style="{
14+
height: slotHeight + 'px'
15+
}"
16+
@pointerdown="handleClick"
17+
>
18+
<!-- Connection Dot -->
19+
<div class="w-5 h-5 flex items-center justify-center group/slot">
20+
<div
21+
class="w-2 h-2 rounded-full bg-white transition-all duration-150 group-hover/slot:w-2.5 group-hover/slot:h-2.5 group-hover/slot:border-2 group-hover/slot:border-white"
22+
:style="{
23+
backgroundColor: slotColor
24+
}"
25+
/>
26+
</div>
27+
28+
<!-- Slot Name -->
29+
<span v-if="!dotOnly" class="text-xs text-surface-700 whitespace-nowrap">
30+
{{ slotData.name || `Input ${index}` }}
31+
</span>
32+
</div>
33+
</template>
34+
35+
<script setup lang="ts">
36+
import { computed, onErrorCaptured, ref } from 'vue'
37+
38+
import { useErrorHandling } from '@/composables/useErrorHandling'
39+
import { getSlotColor } from '@/constants/slotColors'
40+
import {
41+
COMFY_VUE_NODE_DIMENSIONS,
42+
INodeSlot,
43+
LGraphNode
44+
} from '@/lib/litegraph/src/litegraph'
45+
46+
interface InputSlotProps {
47+
node?: LGraphNode
48+
slotData: INodeSlot
49+
index: number
50+
connected?: boolean
51+
compatible?: boolean
52+
readonly?: boolean
53+
dotOnly?: boolean
54+
}
55+
56+
const props = defineProps<InputSlotProps>()
57+
58+
const emit = defineEmits<{
59+
'slot-click': [event: PointerEvent]
60+
}>()
61+
62+
// Error boundary implementation
63+
const renderError = ref<string | null>(null)
64+
const { toastErrorHandler } = useErrorHandling()
65+
66+
onErrorCaptured((error) => {
67+
renderError.value = error.message
68+
toastErrorHandler(error)
69+
return false
70+
})
71+
72+
// Get slot color based on type
73+
const slotColor = computed(() => getSlotColor(props.slotData.type))
74+
75+
// Get slot height from litegraph constants
76+
const slotHeight = COMFY_VUE_NODE_DIMENSIONS.components.SLOT_HEIGHT
77+
78+
// Handle click events
79+
const handleClick = (event: PointerEvent) => {
80+
if (!props.readonly) {
81+
emit('slot-click', event)
82+
}
83+
}
84+
</script>

0 commit comments

Comments
 (0)