@@ -21,7 +21,49 @@ const LinkControls = ({
21
21
return nodeList ;
22
22
} ;
23
23
24
- const nodeList = collectNodes ( snapShots ) ;
24
+ const shouldIncludeNode = ( node ) => {
25
+ // Return false if node has any context properties
26
+ if ( node ?. componentData ?. context && Object . keys ( node . componentData . context ) . length > 0 ) {
27
+ return false ;
28
+ }
29
+ // Return false if node name ends with 'Provider'
30
+ if ( node ?. name && node . name . endsWith ( 'Provider' ) ) {
31
+ return false ;
32
+ }
33
+ return true ;
34
+ } ;
35
+
36
+ const processTreeData = ( node ) => {
37
+ if ( ! node ) return null ;
38
+
39
+ // Create a new node
40
+ const newNode = { ...node } ;
41
+
42
+ if ( node . children ) {
43
+ // Process all children first
44
+ const processedChildren = node . children
45
+ . map ( ( child ) => processTreeData ( child ) )
46
+ . filter ( Boolean ) ; // Remove null results
47
+
48
+ // For each child that shouldn't be included, replace it with its children
49
+ newNode . children = processedChildren . reduce ( ( acc , child ) => {
50
+ if ( shouldIncludeNode ( child ) ) {
51
+ // If child should be included, add it directly
52
+ acc . push ( child ) ;
53
+ } else {
54
+ // If child should be filtered out, add its children instead
55
+ if ( child . children ) {
56
+ acc . push ( ...child . children ) ;
57
+ }
58
+ }
59
+ return acc ;
60
+ } , [ ] ) ;
61
+ }
62
+
63
+ return newNode ;
64
+ } ;
65
+ const filtered = processTreeData ( snapShots ) ;
66
+ const nodeList = collectNodes ( filtered ) ;
25
67
26
68
return (
27
69
< div className = 'link-controls' >
0 commit comments