Home / File/ devtools.js — react Source File

devtools.js — react Source File

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

File javascript BabelCompiler Validation 5 imports 3 functions

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

import * as React from 'react';
import * as ReactDOM from 'react-dom';
import * as ReactDOMClient 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, callback) {
  const script = contentDocument.createElement('script');
  script.onload = callback;
  script.src = sourcePath;

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

function init(appIframe, devtoolsContainer, appSource) {
  const {contentDocument, contentWindow} = appIframe;

  initializeBackend(contentWindow);

  const DevTools = createDevTools(contentWindow);

  inject(contentDocument, appSource, () => {
    ReactDOMClient.createRoot(devtoolsContainer).render(
      <DevTools
        hookNamesModuleLoaderFunction={hookNamesModuleLoaderFunction}
        showTabBar={true}
      />,
    );
  });

  activateBackend(contentWindow);
}

const iframe = document.getElementById('iframe');
const devtoolsContainer = document.getElementById('devtools');

const {protocol, hostname} = window.location;
const port = 8181; // secondary webpack server port
init(
  iframe,
  devtoolsContainer,
  `${protocol}//${hostname}:${port}/dist/e2e-app-regression.js`,
);

// ReactDOM Test Selector APIs used by Playwright e2e tests
window.parent.REACT_DOM_DEVTOOLS =
  'createTestNameSelector' in ReactDOMClient ? ReactDOMClient : ReactDOM;

Domain

Subdomains

Dependencies

  • backend
  • client
  • frontend
  • react
  • react-dom

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 5 module(s): backend, client, frontend, react, react-dom.
Where is devtools.js in the architecture?
devtools.js is located at packages/react-devtools-shell/src/e2e-regression/devtools.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-shell/src/e2e-regression).

Analyze Your Own Codebase

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

Try Supermodel Free