@@ -3,36 +3,50 @@ import { NodeTypesString } from "./constants.js";
33import { FastGroupsMuter } from "./fast_groups_muter.js" ;
44import { RgthreeToggleNavWidget } from "./utils_widgets.js" ;
55import { filterByColor , filterByTitle , sortBy } from "./utils_fast.js" ;
6+ import { SERVICE as FAST_GROUPS_SERVICE } from "./fast_groups_service.js" ;
67const PROPERTY_SORT = "sort" ;
78const PROPERTY_SORT_CUSTOM_ALPHA = "customSortAlphabet" ;
89const PROPERTY_MATCH_COLORS = "matchColors" ;
910const PROPERTY_MATCH_TITLE = "matchTitle" ;
11+ const PROPERTY_MATCH_TITLE_GROUP = "matchGroupTitle" ;
1012const PROPERTY_RESTRICTION = "toggleRestriction" ;
1113export class FastNodeMuter extends FastGroupsMuter {
1214 constructor ( title = FastNodeMuter . title ) {
1315 super ( title ) ;
1416 this . modeOn = LiteGraph . ALWAYS ;
1517 this . modeOff = LiteGraph . NEVER ;
18+ this . properties [ PROPERTY_MATCH_TITLE_GROUP ] = "" ;
1619 }
1720 static setUp ( clazz ) {
1821 LiteGraph . registerNodeType ( clazz . type , clazz ) ;
1922 clazz . category = clazz . _category ;
2023 }
24+ getNodes ( sort ) {
25+ var _a , _b ;
26+ const matchGroup = ( _a = this . properties ) === null || _a === void 0 ? void 0 : _a [ PROPERTY_MATCH_TITLE_GROUP ] ;
27+ if ( ! matchGroup ) {
28+ const graph = app . graph ;
29+ return [ ...( ( _b = graph . _nodes ) !== null && _b !== void 0 ? _b : [ ] ) ] . filter ( ( n ) => ! n . isVirtualNode ) ;
30+ }
31+ const pattern = new RegExp ( matchGroup , "i" ) ;
32+ const allGroups = FAST_GROUPS_SERVICE . getGroups ( sort ) ;
33+ const filteredGroups = allGroups . filter ( ( group ) => pattern . exec ( group . title ) ) ;
34+ return Array . from ( new Set ( filteredGroups . map ( ( group ) => group . _nodes ) . flat ( ) ) ) ;
35+ }
2136 refreshWidgets ( ) {
22- var _a , _b , _c , _d , _e , _f , _g ;
23- const graph = app . graph ;
37+ var _a , _b , _c , _d , _e , _f ;
2438 let sort = ( ( _a = this . properties ) === null || _a === void 0 ? void 0 : _a [ PROPERTY_SORT ] ) || "position" ;
25- const nodes = [ ... ( ( _b = graph . _nodes ) !== null && _b !== void 0 ? _b : [ ] ) ] . filter ( ( n ) => ! n . isVirtualNode ) ;
39+ const nodes = this . getNodes ( sort ) ;
2640 const alphaSorted = sortBy ( nodes , {
27- customAlphabet : ( _d = ( _c = this . properties ) === null || _c === void 0 ? void 0 : _c [ PROPERTY_SORT_CUSTOM_ALPHA ] ) === null || _d === void 0 ? void 0 : _d . replace ( / \n / g, "" ) ,
41+ customAlphabet : ( _c = ( _b = this . properties ) === null || _b === void 0 ? void 0 : _b [ PROPERTY_SORT_CUSTOM_ALPHA ] ) === null || _c === void 0 ? void 0 : _c . replace ( / \n / g, "" ) ,
2842 sort,
2943 } ) ;
3044 const colorFiltered = filterByColor ( alphaSorted , {
31- matchColors : ( _e = this . properties ) === null || _e === void 0 ? void 0 : _e [ PROPERTY_MATCH_COLORS ] ,
45+ matchColors : ( _d = this . properties ) === null || _d === void 0 ? void 0 : _d [ PROPERTY_MATCH_COLORS ] ,
3246 nodeColorOption : "color" ,
3347 } ) ;
3448 const titleFiltered = filterByTitle ( colorFiltered , {
35- matchTitle : ( _g = ( _f = this . properties ) === null || _f === void 0 ? void 0 : _f [ PROPERTY_MATCH_TITLE ] ) === null || _g === void 0 ? void 0 : _g . trim ( ) ,
49+ matchTitle : ( _f = ( _e = this . properties ) === null || _e === void 0 ? void 0 : _e [ PROPERTY_MATCH_TITLE ] ) === null || _f === void 0 ? void 0 : _f . trim ( ) ,
3650 } ) ;
3751 let index = 0 ;
3852 for ( const node of titleFiltered ) {
@@ -90,6 +104,7 @@ export class FastNodeMuter extends FastGroupsMuter {
90104}
91105FastNodeMuter . type = NodeTypesString . FAST_NODE_MUTER ;
92106FastNodeMuter . title = NodeTypesString . FAST_NODE_MUTER ;
107+ FastNodeMuter [ "@matchTitleGroup" ] = { type : "string" } ;
93108app . registerExtension ( {
94109 name : "rgthree.FastNodeMuter" ,
95110 registerCustomNodes ( ) {
0 commit comments