Skip to content

Commit 9228b94

Browse files
christian-byrneclaudebenceruleanlugithub-actions
committed
[feat] TransformPane - Viewport synchronization layer for Vue nodes (#4304)
Co-authored-by: Claude <[email protected]> Co-authored-by: Benjamin Lu <[email protected]> Co-authored-by: github-actions <[email protected]>
1 parent 57db10f commit 9228b94

File tree

20 files changed

+1687
-64
lines changed

20 files changed

+1687
-64
lines changed

pnpm-lock.yaml

Lines changed: 58 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/graph/DomWidgets.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { computed } from 'vue'
1616
1717
import DomWidget from '@/components/graph/widgets/DomWidget.vue'
1818
import { useChainCallback } from '@/composables/functional/useChainCallback'
19+
import { LiteGraph } from '@/lib/litegraph/src/litegraph'
1920
import { useDomWidgetStore } from '@/stores/domWidgetStore'
2021
import { useCanvasStore } from '@/stores/graphStore'
2122
@@ -27,6 +28,9 @@ const updateWidgets = () => {
2728
const lgCanvas = canvasStore.canvas
2829
if (!lgCanvas) return
2930
31+
// Skip updating DOM widgets when Vue nodes mode is enabled
32+
if (LiteGraph.vueNodesMode) return
33+
3034
const lowQuality = lgCanvas.low_quality
3135
const currentGraph = lgCanvas.graph
3236
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)