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 32c34769_fd19_010a_b41f_6b377927190a["devtools.js"] ac587885_e294_a1e9_b13f_5e7b920fdb42["react"] 32c34769_fd19_010a_b41f_6b377927190a --> ac587885_e294_a1e9_b13f_5e7b920fdb42 8792c1c1_dca5_f137_73ea_c0e268fdbb22["client"] 32c34769_fd19_010a_b41f_6b377927190a --> 8792c1c1_dca5_f137_73ea_c0e268fdbb22 4da2a32d_4587_3ba6_333e_3caaa253af7d["backend"] 32c34769_fd19_010a_b41f_6b377927190a --> 4da2a32d_4587_3ba6_333e_3caaa253af7d d6b6d891_63bc_716b_0fbb_d68ca93df1a6["frontend"] 32c34769_fd19_010a_b41f_6b377927190a --> d6b6d891_63bc_716b_0fbb_d68ca93df1a6 55d27179_f566_db64_927b_e95655abee00["constants"] 32c34769_fd19_010a_b41f_6b377927190a --> 55d27179_f566_db64_927b_e95655abee00 style 32c34769_fd19_010a_b41f_6b377927190a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @noflow
*/
import * as React from 'react';
import {createRoot} from 'react-dom/client';
import {
activate as activateBackend,
createBridge as createBackendBridge,
initialize as initializeBackend,
} from 'react-devtools-inline/backend';
import {
createBridge as createFrontendBridge,
createStore,
initialize as createDevTools,
} from 'react-devtools-inline/frontend';
import {__DEBUG__} from 'react-devtools-shared/src/constants';
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;
// Wire each DevTools instance directly to its app.
// By default, DevTools dispatches "message" events on the window,
// but this means that only one instance of DevTools can live on a page.
const wall = {
_listeners: [],
listen(listener) {
if (__DEBUG__) {
console.log('[Shell] Wall.listen()');
}
wall._listeners.push(listener);
},
send(event, payload) {
if (__DEBUG__) {
console.log('[Shell] Wall.send()', {event, payload});
}
wall._listeners.forEach(listener => listener({event, payload}));
},
};
const backendBridge = createBackendBridge(contentWindow, wall);
initializeBackend(contentWindow);
const frontendBridge = createFrontendBridge(contentWindow, wall);
const store = createStore(frontendBridge);
const DevTools = createDevTools(contentWindow, {
bridge: frontendBridge,
store,
});
inject(contentDocument, appSource, () => {
createRoot(devtoolsContainer).render(<DevTools />);
});
activateBackend(contentWindow, {bridge: backendBridge});
}
const appIframeLeft = document.getElementById('iframe-left');
const appIframeRight = document.getElementById('iframe-right');
const devtoolsContainerLeft = document.getElementById('devtools-left');
const devtoolsContainerRight = document.getElementById('devtools-right');
init(appIframeLeft, devtoolsContainerLeft, 'dist/multi-left.js');
init(appIframeRight, devtoolsContainerRight, 'dist/multi-right.js');
Domain
Subdomains
Dependencies
- backend
- client
- constants
- 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): init, inject.
What does devtools.js depend on?
devtools.js imports 5 module(s): backend, client, constants, frontend, react.
Where is devtools.js in the architecture?
devtools.js is located at packages/react-devtools-shell/src/multi/devtools.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-shell/src/multi).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free