11import type { SuspenseBoundary , VNode } from 'vue'
2+ import type { DevToolsPluginAPI } from '../../../api'
23import type { ComponentTreeNode , VueAppInstance } from '../../../types'
34import type { ComponentFilter } from './filter'
45// import { devtoolsAppRecords, devtoolsContext } from '../../../state'
@@ -11,19 +12,22 @@ interface ComponentWalkerOptions {
1112 filterText ?: string
1213 maxDepth : number | null
1314 recursively : boolean
15+ api : InstanceType < typeof DevToolsPluginAPI >
1416}
1517
1618export class ComponentWalker {
1719 maxDepth : number | null
1820 recursively : boolean
1921 componentFilter : InstanceType < typeof ComponentFilter >
22+ api : InstanceType < typeof DevToolsPluginAPI >
2023 // Dedupe instances (Some instances may be both on a component and on a child abstract/functional component)
2124 private captureIds : Map < string , undefined > = new Map ( )
2225 constructor ( options : ComponentWalkerOptions ) {
23- const { filterText = '' , maxDepth, recursively } = options
26+ const { filterText = '' , maxDepth, recursively, api } = options
2427 this . componentFilter = createComponentFilter ( filterText )
2528 this . maxDepth = maxDepth
2629 this . recursively = recursively
30+ this . api = api
2731 }
2832
2933 public getComponentTree ( instance : VueAppInstance ) : Promise < ComponentTreeNode [ ] > {
@@ -157,13 +161,12 @@ export class ComponentWalker {
157161 this . mark ( instance , true )
158162 }
159163
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+ } )
167170 return treeNode
168171 }
169172
0 commit comments