Home / File/ devtools.js — react Source File

devtools.js — react Source File

Architecture documentation for devtools.js, a javascript file in the react codebase. 4 imports, 0 dependents.

File javascript BabelCompiler Validation 4 imports 3 functions

Entity Profile

Dependency Diagram

graph LR
  845af5f3_68dc_5673_3728_e66cd88a1b6f["devtools.js"]
  ac587885_e294_a1e9_b13f_5e7b920fdb42["react"]
  845af5f3_68dc_5673_3728_e66cd88a1b6f --> ac587885_e294_a1e9_b13f_5e7b920fdb42
  8792c1c1_dca5_f137_73ea_c0e268fdbb22["client"]
  845af5f3_68dc_5673_3728_e66cd88a1b6f --> 8792c1c1_dca5_f137_73ea_c0e268fdbb22
  4da2a32d_4587_3ba6_333e_3caaa253af7d["backend"]
  845af5f3_68dc_5673_3728_e66cd88a1b6f --> 4da2a32d_4587_3ba6_333e_3caaa253af7d
  d6b6d891_63bc_716b_0fbb_d68ca93df1a6["frontend"]
  845af5f3_68dc_5673_3728_e66cd88a1b6f --> d6b6d891_63bc_716b_0fbb_d68ca93df1a6
  style 845af5f3_68dc_5673_3728_e66cd88a1b6f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import * as React from 'react';
import {createRoot} from 'react-dom/client';
import {
  activate as activateBackend,
  initialize as initializeBackend,
} from 'react-devtools-inline/backend';
import {initialize as createDevTools} from 'react-devtools-inline/frontend';

// This is a pretty gross hack to make the runtime loaded named-hooks-code work.
// TODO (Webpack 5) Hoepfully we can remove this once we upgrade to Webpack 5.
__webpack_public_path__ = '/dist/'; // eslint-disable-line no-undef

// TODO (Webpack 5) Hopefully we can remove this prop after the Webpack 5 migration.
function hookNamesModuleLoaderFunction() {
  return import('react-devtools-inline/hookNames');
}

function inject(contentDocument, sourcePath) {
  const script = contentDocument.createElement('script');
  script.src = sourcePath;

  ((contentDocument.body: any): HTMLBodyElement).appendChild(script);
}

function init(
  appSource: string,
  appIframe: HTMLIFrameElement,
  devtoolsContainer: HTMLElement,
  loadDevToolsButton: HTMLButtonElement,
) {
  const {contentDocument, contentWindow} = appIframe;

  initializeBackend(contentWindow);

  inject(contentDocument, appSource);

  loadDevToolsButton.addEventListener('click', () => {
    const DevTools = createDevTools(contentWindow);
    createRoot(devtoolsContainer).render(
      <DevTools
        hookNamesModuleLoaderFunction={hookNamesModuleLoaderFunction}
        showTabBar={true}
      />,
    );
    activateBackend(contentWindow);
  });
}

init(
  'dist/perf-regression-app.js',
  document.getElementById('iframe'),
  document.getElementById('devtools'),
  document.getElementById('load-devtools'),
);

Domain

Subdomains

Dependencies

  • backend
  • client
  • frontend
  • react

Frequently Asked Questions

What does devtools.js do?
devtools.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in devtools.js?
devtools.js defines 3 function(s): hookNamesModuleLoaderFunction, init, inject.
What does devtools.js depend on?
devtools.js imports 4 module(s): backend, client, frontend, react.
Where is devtools.js in the architecture?
devtools.js is located at packages/react-devtools-shell/src/perf-regression/devtools.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-shell/src/perf-regression).

Analyze Your Own Codebase

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

Try Supermodel Free