1
1
import type { SuspenseBoundary , VNode } from 'vue'
2
+ import type { DevToolsPluginAPI } from '../../../api'
2
3
import type { ComponentTreeNode , VueAppInstance } from '../../../types'
3
4
import type { ComponentFilter } from './filter'
4
5
// import { devtoolsAppRecords, devtoolsContext } from '../../../state'
@@ -11,19 +12,22 @@ interface ComponentWalkerOptions {
11
12
filterText ?: string
12
13
maxDepth : number | null
13
14
recursively : boolean
15
+ api : InstanceType < typeof DevToolsPluginAPI >
14
16
}
15
17
16
18
export class ComponentWalker {
17
19
maxDepth : number | null
18
20
recursively : boolean
19
21
componentFilter : InstanceType < typeof ComponentFilter >
22
+ api : InstanceType < typeof DevToolsPluginAPI >
20
23
// Dedupe instances (Some instances may be both on a component and on a child abstract/functional component)
21
24
private captureIds : Map < string , undefined > = new Map ( )
22
25
constructor ( options : ComponentWalkerOptions ) {
23
- const { filterText = '' , maxDepth, recursively } = options
26
+ const { filterText = '' , maxDepth, recursively, api } = options
24
27
this . componentFilter = createComponentFilter ( filterText )
25
28
this . maxDepth = maxDepth
26
29
this . recursively = recursively
30
+ this . api = api
27
31
}
28
32
29
33
public getComponentTree ( instance : VueAppInstance ) : Promise < ComponentTreeNode [ ] > {
@@ -157,13 +161,12 @@ export class ComponentWalker {
157
161
this . mark ( instance , true )
158
162
}
159
163
160
- // @TODO : impl
161
- // devtoolsContext.api.visitComponentTree({
162
- // treeNode,
163
- // componentInstance: instance,
164
- // app: instance.appContext.app,
165
- // filter: this.componentFilter.filter,
166
- // })
164
+ this . api . visitComponentTree ( {
165
+ treeNode,
166
+ componentInstance : instance ,
167
+ app : instance . appContext . app ,
168
+ filter : this . componentFilter . filter ,
169
+ } )
167
170
return treeNode
168
171
}
169
172
0 commit comments