MCPcopy
hub / github.com/vuejs/devtools-v6 / sendComponentTreeData

Function sendComponentTreeData

packages/app-backend-core/src/component.ts:10–46  ·  view source on GitHub ↗
(appRecord: AppRecord, instanceId: string, filter = '', maxDepth: number = null, recursively = false, ctx: BackendContext)

Source from the content-addressed store, hash-verified

8const $vmQueue = []
9
10export async function sendComponentTreeData(appRecord: AppRecord, instanceId: string, filter = '', maxDepth: number = null, recursively = false, ctx: BackendContext) {
11 if (!instanceId || appRecord !== ctx.currentAppRecord) {
12 return
13 }
14
15 // Flush will send all components in the tree
16 // So we skip individiual tree updates
17 if (
18 instanceId !== '_root'
19 && ctx.currentAppRecord.backend.options.features.includes(BuiltinBackendFeature.FLUSH)
20 ) {
21 return
22 }
23
24 const instance = getComponentInstance(appRecord, instanceId, ctx)
25 if (!instance) {
26 ctx.bridge.send(BridgeEvents.TO_FRONT_COMPONENT_TREE, {
27 instanceId,
28 treeData: null,
29 notFound: true,
30 })
31 }
32 else {
33 if (filter) {
34 filter = filter.toLowerCase()
35 }
36 if (maxDepth == null) {
37 maxDepth = instance === ctx.currentAppRecord.rootInstance ? 2 : 1
38 }
39 const data = await appRecord.backend.api.walkComponentTree(instance, maxDepth, filter, recursively)
40 const payload = {
41 instanceId,
42 treeData: stringify(data),
43 }
44 ctx.bridge.send(BridgeEvents.TO_FRONT_COMPONENT_TREE, payload)
45 }
46}
47
48export async function sendSelectedComponentData(appRecord: AppRecord, instanceId: string, ctx: BackendContext) {
49 if (!instanceId || appRecord !== ctx.currentAppRecord) {

Callers 5

connectFunction · 0.90
connectBridgeFunction · 0.90
performanceMarkEndFunction · 0.90
getFunction · 0.85

Calls 4

stringifyFunction · 0.90
getComponentInstanceFunction · 0.85
sendMethod · 0.80
walkComponentTreeMethod · 0.45

Tested by

no test coverage detected