message: feat(devtools): implement component selection functionality for $ng0 - $ng4 similarly to how chrome devtools does with html elements
diff: @@ -2,10 +2,29 @@ import { ComponentTreeNode } from './component-tree';
  declare const ng: any;
  -const SELECTED_COMPONENT_PROPERTY_KEY_BASE = '$ng0';
  +const SELECTED_COMPONENT_PROPERTY_KEY_PREFIX = '$ng';
  +let selectedComponentKeyPostfix = 0;
  +const getSelectedComponentKey = () => `${SELECTED_COMPONENT_PROPERTY_KEY_PREFIX}${selectedComponentKeyPostfix}`;
  +
  +const selectedNodes: (ComponentTreeNode | null)[] = [];
  export const setConsoleReference = (node: ComponentTreeNode | null) => {
  - Object.defineProperty(window, SELECTED_COMPONENT_PROPERTY_KEY_BASE, {
  + if (selectedNodes.length === 5) {
  + selectedNodes.pop();
  + }
  + selectedNodes.unshift(node);
  + assignConsoleReferencesFromSelectedNodesArray();
  +};
  +
  +const assignConsoleReferencesFromSelectedNodesArray = () => {
  + selectedNodes.forEach((node, index) => {
  + selectedComponentKeyPostfix = index;
  + setDirectiveKey(node, getSelectedComponentKey());
  + });
  +};
  +
  +const setDirectiveKey = (node: ComponentTreeNode | null, key) => {
  + Object.defineProperty(window, key, {
  get: () => {
  if (node && node.nativeElement instanceof HTMLElement) {
  return ng.getComponent(node.nativeElement) || node;
  