Home / File/ componentTree.ts — react Source File

componentTree.ts — react Source File

Architecture documentation for componentTree.ts, a typescript file in the react codebase. 1 imports, 1 dependents.

File typescript BabelCompiler Validation 1 imports 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  c41109aa_ed41_cf13_fa67_3bdff2ead249["componentTree.ts"]
  a75a30f6_49c1_7063_6401_9377a6508e45["puppeteer"]
  c41109aa_ed41_cf13_fa67_3bdff2ead249 --> a75a30f6_49c1_7063_6401_9377a6508e45
  18cd5de5_c350_7de1_3060_3c6253caf5c4["index.ts"]
  18cd5de5_c350_7de1_3060_3c6253caf5c4 --> c41109aa_ed41_cf13_fa67_3bdff2ead249
  style c41109aa_ed41_cf13_fa67_3bdff2ead249 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import puppeteer from 'puppeteer';

export async function parseReactComponentTree(url: string): Promise<string> {
  try {
    const browser = await puppeteer.connect({
      browserURL: 'http://127.0.0.1:9222',
      defaultViewport: null,
    });

    const pages = await browser.pages();

    let localhostPage = null;
    for (const page of pages) {
      const pageUrl = await page.url();

      if (pageUrl.startsWith(url)) {
        localhostPage = page;
        break;
      }
    }

    if (localhostPage) {
      const componentTree = await localhostPage.evaluate(() => {
        return (window as any).__REACT_DEVTOOLS_GLOBAL_HOOK__.rendererInterfaces
          .get(1)
          .__internal_only_getComponentTree();
      });

      return componentTree;
    } else {
      throw new Error(
        `Could not open the page at ${url}. Is your server running?`,
      );
    }
  } catch (error) {
    throw new Error('Failed extract component tree' + error);
  }
}

Domain

Subdomains

Dependencies

  • puppeteer

Frequently Asked Questions

What does componentTree.ts do?
componentTree.ts is a source file in the react codebase, written in typescript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in componentTree.ts?
componentTree.ts defines 1 function(s): parseReactComponentTree.
What does componentTree.ts depend on?
componentTree.ts imports 1 module(s): puppeteer.
What files import componentTree.ts?
componentTree.ts is imported by 1 file(s): index.ts.
Where is componentTree.ts in the architecture?
componentTree.ts is located at compiler/packages/react-mcp-server/src/tools/componentTree.ts (domain: BabelCompiler, subdomain: Validation, directory: compiler/packages/react-mcp-server/src/tools).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free