(appRecord: AppRecord, instanceId: string, filter = '', maxDepth: number = null, recursively = false, ctx: BackendContext)
| 8 | const $vmQueue = [] |
| 9 | |
| 10 | export 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 | |
| 48 | export async function sendSelectedComponentData(appRecord: AppRecord, instanceId: string, ctx: BackendContext) { |
| 49 | if (!instanceId || appRecord !== ctx.currentAppRecord) { |
no test coverage detected