devtools.js — react Source File
Architecture documentation for devtools.js, a javascript file in the react codebase. 5 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR bb15f9d0_445a_f9fe_a53c_ebedc812876a["devtools.js"] ac587885_e294_a1e9_b13f_5e7b920fdb42["react"] bb15f9d0_445a_f9fe_a53c_ebedc812876a --> ac587885_e294_a1e9_b13f_5e7b920fdb42 8792c1c1_dca5_f137_73ea_c0e268fdbb22["client"] bb15f9d0_445a_f9fe_a53c_ebedc812876a --> 8792c1c1_dca5_f137_73ea_c0e268fdbb22 4da2a32d_4587_3ba6_333e_3caaa253af7d["backend"] bb15f9d0_445a_f9fe_a53c_ebedc812876a --> 4da2a32d_4587_3ba6_333e_3caaa253af7d d6b6d891_63bc_716b_0fbb_d68ca93df1a6["frontend"] bb15f9d0_445a_f9fe_a53c_ebedc812876a --> d6b6d891_63bc_716b_0fbb_d68ca93df1a6 242285d5_15e1_17d4_8225_fb782512d790["devtools"] bb15f9d0_445a_f9fe_a53c_ebedc812876a --> 242285d5_15e1_17d4_8225_fb782512d790 style bb15f9d0_445a_f9fe_a53c_ebedc812876a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/** @flow */
import {createElement} from 'react';
import {createRoot} from 'react-dom/client';
import {
activate as activateBackend,
initialize as initializeBackend,
} from 'react-devtools-inline/backend';
import {initialize as initializeFrontend} from 'react-devtools-inline/frontend';
import {initDevTools} from 'react-devtools-shared/src/devtools';
// 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.
// $FlowFixMe[cannot-resolve-name]
__webpack_public_path__ = '/dist/'; // eslint-disable-line no-undef
const iframe = ((document.getElementById('target'): any): HTMLIFrameElement);
const {contentDocument, contentWindow} = iframe;
// Helps with positioning Overlay UI.
contentWindow.__REACT_DEVTOOLS_TARGET_WINDOW__ = window;
initializeBackend(contentWindow);
// Initialize the front end and activate the backend early so that we are able
// to pass console settings in local storage to the backend before initial render
const DevTools = initializeFrontend(contentWindow);
// Activate the backend only once the DevTools frontend Store has been initialized.
// Otherwise the Store may miss important initial tree op codes.
activateBackend(contentWindow);
const container = ((document.getElementById('devtools'): any): HTMLElement);
let isTestAppMounted = true;
const mountButton = ((document.getElementById(
'mountButton',
): any): HTMLButtonElement);
mountButton.addEventListener('click', function () {
if (isTestAppMounted) {
if (typeof window.unmountTestApp === 'function') {
window.unmountTestApp();
mountButton.innerText = 'Mount test app';
isTestAppMounted = false;
}
} else {
if (typeof window.mountTestApp === 'function') {
window.mountTestApp();
mountButton.innerText = 'Unmount test app';
isTestAppMounted = true;
}
}
});
// TODO (Webpack 5) Hopefully we can remove this prop after the Webpack 5 migration.
function hookNamesModuleLoaderFunction() {
return import('react-devtools-inline/hookNames');
}
inject('dist/app-index.js', () => {
initDevTools({
connect(cb) {
const root = createRoot(container);
root.render(
createElement(DevTools, {
browserTheme: 'light',
enabledInspectedElementContextMenu: true,
hookNamesModuleLoaderFunction,
showTabBar: true,
warnIfLegacyBackendDetected: true,
warnIfUnsupportedVersionDetected: true,
}),
);
},
onReload(reloadFn) {
iframe.onload = reloadFn;
},
});
});
function inject(sourcePath: string, callback: () => void) {
const script = contentDocument.createElement('script');
script.onload = callback;
script.src = sourcePath;
((contentDocument.body: any): HTMLBodyElement).appendChild(script);
}
Domain
Subdomains
Functions
Dependencies
- backend
- client
- devtools
- frontend
- react
Source
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 2 function(s): hookNamesModuleLoaderFunction, inject.
What does devtools.js depend on?
devtools.js imports 5 module(s): backend, client, devtools, frontend, react.
Where is devtools.js in the architecture?
devtools.js is located at packages/react-devtools-shell/src/app/devtools.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-shell/src/app).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free