index.js — react Source File
Architecture documentation for index.js, a javascript file in the react codebase. 2 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 7fba5194_4415_41ad_1366_ead346337fb8["index.js"] e3778820_57ff_7221_e2fb_64072d11afcc["agent.js"] 7fba5194_4415_41ad_1366_ead346337fb8 --> e3778820_57ff_7221_e2fb_64072d11afcc 0304bbc8_f110_6643_71c6_d26bddc58fde["types.js"] 7fba5194_4415_41ad_1366_ead346337fb8 --> 0304bbc8_f110_6643_71c6_d26bddc58fde style 7fba5194_4415_41ad_1366_ead346337fb8 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.
*
* @flow
*/
import Agent from './agent';
import type {DevToolsHook, RendererID, RendererInterface} from './types';
export type InitBackend = typeof initBackend;
export function initBackend(
hook: DevToolsHook,
agent: Agent,
global: Object,
isReloadAndProfileSupported: boolean,
): () => void {
if (hook == null) {
// DevTools didn't get injected into this page (maybe b'c of the contentType).
return () => {};
}
function registerRendererInterface(
id: RendererID,
rendererInterface: RendererInterface,
) {
agent.registerRendererInterface(id, rendererInterface);
// Now that the Store and the renderer interface are connected,
// it's time to flush the pending operation codes to the frontend.
rendererInterface.flushInitialOperations();
}
const subs = [
hook.sub(
'renderer-attached',
({
id,
rendererInterface,
}: {
id: number,
rendererInterface: RendererInterface,
}) => {
registerRendererInterface(id, rendererInterface);
},
),
hook.sub('unsupported-renderer-version', () => {
agent.onUnsupportedRenderer();
}),
hook.sub('fastRefreshScheduled', agent.onFastRefreshScheduled),
hook.sub('operations', agent.onHookOperations),
hook.sub('traceUpdates', agent.onTraceUpdates),
hook.sub('settingsInitialized', agent.onHookSettings),
// TODO Add additional subscriptions required for profiling mode
];
agent.addListener('getIfHasUnsupportedRendererVersion', () => {
if (hook.hasUnsupportedRendererAttached) {
agent.onUnsupportedRenderer();
}
});
hook.rendererInterfaces.forEach((rendererInterface, id) => {
registerRendererInterface(id, rendererInterface);
});
hook.emit('react-devtools', agent);
hook.reactDevtoolsAgent = agent;
const onAgentShutdown = () => {
subs.forEach(fn => fn());
hook.rendererInterfaces.forEach(rendererInterface => {
rendererInterface.cleanup();
});
hook.reactDevtoolsAgent = null;
};
// Agent's event listeners are cleaned up by Agent in `shutdown` implementation.
agent.addListener('shutdown', onAgentShutdown);
agent.addListener('updateHookSettings', settings => {
hook.settings = settings;
});
agent.addListener('getHookSettings', () => {
if (hook.settings != null) {
agent.onHookSettings(hook.settings);
}
});
if (isReloadAndProfileSupported) {
agent.onReloadAndProfileSupportedByHost();
}
return () => {
subs.forEach(fn => fn());
};
}
Domain
Subdomains
Functions
Source
Frequently Asked Questions
What does index.js do?
index.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 index.js?
index.js defines 1 function(s): initBackend.
What does index.js depend on?
index.js imports 2 module(s): agent.js, types.js.
Where is index.js in the architecture?
index.js is located at packages/react-devtools-shared/src/backend/index.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-shared/src/backend).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free