refactor(devtools): abstract and reuse the tree visualizer #62264
+2,031
−2,099
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Abstract the injector tree visualizer so it can be used for both the Injector Tree and Router Tree tabs without having to rely on separate identical implementations.
Changes
In essence, there is now a single class called
TreeVisualizer
that works withTreeNode
s. ATreeNode
should have alabel
andTreeNode
children
. If the tree visualizer user items do not satisfy this format, they should be transformed. TheTreeVisualizer
exposes two additional config options – the node and link modifiers – that can be used for applying any instance-specific changes to the SVG elements (e.g. classes, data attributes, etc.). The implementation of the tree visualizer is almost unchanged.Motivation
#62048 – such fixes and improvements require syncing the injector tree and router tree implementations.
Future improvements
Since we now have a single tree visualizer, it makes sense to integrate it in the
tree-visualizer-host
component via composition. The API will be exposed as part of the component and won't require manually tying the host and the visualizer.