|
1 | 1 | import { NodeSearchService } from '@/services/nodeSearchService' |
2 | 2 | import { ComfyNodeDef } from '@/types/apiTypes' |
3 | 3 | import { defineStore } from 'pinia' |
4 | | -import { Type, Transform, plainToClass } from 'class-transformer' |
| 4 | +import { Type, Transform, plainToClass, Expose } from 'class-transformer' |
5 | 5 | import { ComfyWidgetConstructor } from '@/scripts/widgets' |
6 | 6 | import { TreeNode } from 'primevue/treenode' |
7 | 7 | import { buildTree } from '@/utils/treeUtil' |
@@ -166,6 +166,23 @@ export class ComfyNodeDefImpl { |
166 | 166 | python_module: string |
167 | 167 | description: string |
168 | 168 |
|
| 169 | + @Transform(({ value, obj }) => value ?? obj.category === '', { |
| 170 | + toClassOnly: true |
| 171 | + }) |
| 172 | + @Type(() => Boolean) |
| 173 | + @Expose() |
| 174 | + deprecated: boolean |
| 175 | + |
| 176 | + @Transform( |
| 177 | + ({ value, obj }) => value ?? obj.category.startsWith('_for_testing'), |
| 178 | + { |
| 179 | + toClassOnly: true |
| 180 | + } |
| 181 | + ) |
| 182 | + @Type(() => Boolean) |
| 183 | + @Expose() |
| 184 | + experimental: boolean |
| 185 | + |
169 | 186 | @Type(() => ComfyInputsSpec) |
170 | 187 | input: ComfyInputsSpec |
171 | 188 |
|
@@ -229,22 +246,34 @@ export const SYSTEM_NODE_DEFS: Record<string, ComfyNodeDef> = { |
229 | 246 | interface State { |
230 | 247 | nodeDefsByName: Record<string, ComfyNodeDefImpl> |
231 | 248 | widgets: Record<string, ComfyWidgetConstructor> |
| 249 | + showDeprecated: boolean |
| 250 | + showExperimental: boolean |
232 | 251 | } |
233 | 252 |
|
234 | 253 | export const useNodeDefStore = defineStore('nodeDef', { |
235 | 254 | state: (): State => ({ |
236 | 255 | nodeDefsByName: {}, |
237 | | - widgets: {} |
| 256 | + widgets: {}, |
| 257 | + showDeprecated: false, |
| 258 | + showExperimental: false |
238 | 259 | }), |
239 | 260 | getters: { |
240 | 261 | nodeDefs(state) { |
241 | 262 | return Object.values(state.nodeDefsByName) |
242 | 263 | }, |
243 | | - nodeSearchService(state) { |
244 | | - return new NodeSearchService(Object.values(state.nodeDefsByName)) |
| 264 | + // Node defs that are not deprecated |
| 265 | + visibleNodeDefs(state) { |
| 266 | + return this.nodeDefs.filter( |
| 267 | + (nodeDef: ComfyNodeDefImpl) => |
| 268 | + (state.showDeprecated || !nodeDef.deprecated) && |
| 269 | + (state.showExperimental || !nodeDef.experimental) |
| 270 | + ) |
| 271 | + }, |
| 272 | + nodeSearchService() { |
| 273 | + return new NodeSearchService(this.visibleNodeDefs) |
245 | 274 | }, |
246 | 275 | nodeTree(): TreeNode { |
247 | | - return buildTree(this.nodeDefs, (nodeDef: ComfyNodeDefImpl) => [ |
| 276 | + return buildTree(this.visibleNodeDefs, (nodeDef: ComfyNodeDefImpl) => [ |
248 | 277 | ...nodeDef.category.split('/'), |
249 | 278 | nodeDef.display_name |
250 | 279 | ]) |
|
0 commit comments