proxy.js — react Source File
Architecture documentation for proxy.js, a javascript file in the react codebase.
Entity Profile
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.
*
* @flow
*/
/* global chrome */
'use strict';
function injectProxy({target}: {target: any}) {
// Firefox's behaviour for injecting this content script can be unpredictable
// While navigating the history, some content scripts might not be re-injected and still be alive
if (!window.__REACT_DEVTOOLS_PROXY_INJECTED__) {
window.__REACT_DEVTOOLS_PROXY_INJECTED__ = true;
connectPort();
sayHelloToBackendManager();
// The backend waits to install the global hook until notified by the content script.
// In the event of a page reload, the content script might be loaded before the backend manager is injected.
// Because of this we need to poll the backend manager until it has been initialized.
const intervalID: IntervalID = setInterval(() => {
if (backendInitialized) {
clearInterval(intervalID);
} else {
sayHelloToBackendManager();
}
}, 500);
}
}
window.addEventListener('pagereveal', injectProxy);
// For backwards compat with browsers not implementing `pagereveal` which is a fairly new event.
window.addEventListener('pageshow', injectProxy);
window.addEventListener('pagehide', function ({target}) {
if (target !== window.document) {
return;
}
delete window.__REACT_DEVTOOLS_PROXY_INJECTED__;
});
let port = null;
let backendInitialized: boolean = false;
function sayHelloToBackendManager() {
window.postMessage(
{
source: 'react-devtools-content-script',
hello: true,
},
'*',
);
}
function handleMessageFromDevtools(message: any) {
// ... (106 more lines)
Domain
Subdomains
Functions
Source
Frequently Asked Questions
What does proxy.js do?
proxy.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 proxy.js?
proxy.js defines 6 function(s): connectPort, handleDisconnect, handleMessageFromDevtools, handleMessageFromPage, injectProxy, sayHelloToBackendManager.
Where is proxy.js in the architecture?
proxy.js is located at packages/react-devtools-extensions/src/contentScripts/proxy.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-extensions/src/contentScripts).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free