5
5
// Refer to the "LICENSE" file in the root directory for more information.
6
6
//
7
7
import * as React from "react" ;
8
- import { Position , NodeProps , Connection , Edge , Node } from "@xyflow/react" ;
8
+ import { Position , NodeProps , Connection , Edge } from "@xyflow/react" ;
9
9
import {
10
10
BlocksIcon as ExtensionIcon ,
11
11
TerminalIcon ,
@@ -18,28 +18,14 @@ import { Separator } from "@/components/ui/Separator";
18
18
import { cn } from "@/lib/utils" ;
19
19
import { dispatchCustomNodeActionPopup } from "@/utils/popup" ;
20
20
import CustomHandle from "@/flow/CustomHandle" ;
21
- import { EConnectionType , type TConnectionItem } from "@/types/graphs" ;
21
+ import { EConnectionType } from "@/types/graphs" ;
22
+
23
+ import type { TCustomNode , TCustomNodeData } from "@/types/flow" ;
22
24
23
25
const onConnect = ( params : Connection | Edge ) =>
24
26
console . log ( "Handle onConnect" , params ) ;
25
27
26
- export type TCustomNodeData = {
27
- name : string ;
28
- addon : string ;
29
- sourceCmds : TConnectionItem [ ] ;
30
- targetCmds : TConnectionItem [ ] ;
31
- sourceData : TConnectionItem [ ] ;
32
- targetData : TConnectionItem [ ] ;
33
- sourceAudioFrame : TConnectionItem [ ] ;
34
- targetAudioFrame : TConnectionItem [ ] ;
35
- sourceVideoFrame : TConnectionItem [ ] ;
36
- targetVideoFrame : TConnectionItem [ ] ;
37
- url ?: string ;
38
- } ;
39
-
40
- export type CustomNodeType = Node < TCustomNodeData , "customNode" > ;
41
-
42
- export function CustomNode ( { data, isConnectable } : NodeProps < CustomNodeType > ) {
28
+ export function CustomNode ( { data, isConnectable } : NodeProps < TCustomNode > ) {
43
29
return (
44
30
< >
45
31
< div
@@ -119,7 +105,7 @@ const HandleGroupItem = (props: {
119
105
target ?: boolean ;
120
106
} ) =>
121
107
( ) => {
122
- dispatchCustomNodeActionPopup ( "connections" , data . addon , undefined , {
108
+ dispatchCustomNodeActionPopup ( "connections" , data . name , undefined , {
123
109
filters : {
124
110
type,
125
111
source,
@@ -132,11 +118,11 @@ const HandleGroupItem = (props: {
132
118
< div className = "flex items-center gap-x-4 justify-between" >
133
119
< div className = "flex items-center gap-x-2" >
134
120
< CustomHandle
135
- key = { `target-${ data . addon } -${ connectionType } ` }
121
+ key = { `target-${ data . name } -${ connectionType } ` }
136
122
type = "target"
137
123
position = { Position . Left }
138
- id = { `target-${ data . addon } -${ connectionType } ` }
139
- label = { data . addon }
124
+ id = { `target-${ data . name } -${ connectionType } ` }
125
+ label = { data . name }
140
126
labelOffsetX = { 0 }
141
127
isConnectable = { isConnectable }
142
128
onConnect = { onConnect }
@@ -148,16 +134,16 @@ const HandleGroupItem = (props: {
148
134
} ) }
149
135
>
150
136
{ connectionType === EConnectionType . CMD && (
151
- < span > { data . targetCmds ?. length || 0 } </ span >
137
+ < span > { data . src [ connectionType ] ?. length || 0 } </ span >
152
138
) }
153
139
{ connectionType === EConnectionType . DATA && (
154
- < span > { data . targetData ?. length || 0 } </ span >
140
+ < span > { data . src [ connectionType ] ?. length || 0 } </ span >
155
141
) }
156
142
{ connectionType === EConnectionType . AUDIO_FRAME && (
157
- < span > { data . targetAudioFrame ?. length || 0 } </ span >
143
+ < span > { data . src [ connectionType ] ?. length || 0 } </ span >
158
144
) }
159
145
{ connectionType === EConnectionType . VIDEO_FRAME && (
160
- < span > { data . targetVideoFrame ?. length || 0 } </ span >
146
+ < span > { data . src [ connectionType ] ?. length || 0 } </ span >
161
147
) }
162
148
</ ConnectionCount >
163
149
</ div >
@@ -191,24 +177,24 @@ const HandleGroupItem = (props: {
191
177
} ) }
192
178
>
193
179
{ connectionType === EConnectionType . CMD && (
194
- < span > { data . sourceCmds ?. length || 0 } </ span >
180
+ < span > { data . target [ connectionType ] ?. length || 0 } </ span >
195
181
) }
196
182
{ connectionType === EConnectionType . DATA && (
197
- < span > { data . sourceData ?. length || 0 } </ span >
183
+ < span > { data . target [ connectionType ] ?. length || 0 } </ span >
198
184
) }
199
185
{ connectionType === EConnectionType . AUDIO_FRAME && (
200
- < span > { data . sourceAudioFrame ?. length || 0 } </ span >
186
+ < span > { data . target [ connectionType ] ?. length || 0 } </ span >
201
187
) }
202
188
{ connectionType === EConnectionType . VIDEO_FRAME && (
203
- < span > { data . sourceVideoFrame ?. length || 0 } </ span >
189
+ < span > { data . target [ connectionType ] ?. length || 0 } </ span >
204
190
) }
205
191
</ ConnectionCount >
206
192
< CustomHandle
207
- key = { `source-${ data . addon } -${ connectionType } ` }
193
+ key = { `source-${ data . name } -${ connectionType } ` }
208
194
type = "source"
209
195
position = { Position . Right }
210
- id = { `source-${ data . addon } -${ connectionType } ` }
211
- label = { data . addon }
196
+ id = { `source-${ data . name } -${ connectionType } ` }
197
+ label = { data . name }
212
198
labelOffsetX = { 0 }
213
199
isConnectable = { isConnectable }
214
200
/>
0 commit comments