index.js — react Source File
Architecture documentation for index.js, a javascript file in the react codebase. 4 imports, 2 dependents.
Entity Profile
Dependency Diagram
graph LR c252378b_d680_96f7_afbe_5200374b78e8["index.js"] 2e686050_4065_de33_2d80_1361879d66c9["canvas.js"] c252378b_d680_96f7_afbe_5200374b78e8 --> 2e686050_4065_de33_2d80_1361879d66c9 68d130b4_8767_c9b9_03b4_1510bf2fc934["utils.js"] c252378b_d680_96f7_afbe_5200374b78e8 --> 68d130b4_8767_c9b9_03b4_1510bf2fc934 0304bbc8_f110_6643_71c6_d26bddc58fde["types.js"] c252378b_d680_96f7_afbe_5200374b78e8 --> 0304bbc8_f110_6643_71c6_d26bddc58fde 7812cbae_0bd0_497c_0a05_31fe0a8d0fde["agent"] c252378b_d680_96f7_afbe_5200374b78e8 --> 7812cbae_0bd0_497c_0a05_31fe0a8d0fde e3778820_57ff_7221_e2fb_64072d11afcc["agent.js"] e3778820_57ff_7221_e2fb_64072d11afcc --> c252378b_d680_96f7_afbe_5200374b78e8 2e686050_4065_de33_2d80_1361879d66c9["canvas.js"] 2e686050_4065_de33_2d80_1361879d66c9 --> c252378b_d680_96f7_afbe_5200374b78e8 style c252378b_d680_96f7_afbe_5200374b78e8 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 'react-devtools-shared/src/backend/agent';
import {destroy as destroyCanvas, draw} from './canvas';
import {extractHOCNames, getNestedBoundingClientRect} from '../utils';
import type {HostInstance} from '../../types';
import type {Rect} from '../utils';
// How long the rect should be shown for?
const DISPLAY_DURATION = 250;
// What's the longest we are willing to show the overlay for?
// This can be important if we're getting a flurry of events (e.g. scroll update).
const MAX_DISPLAY_DURATION = 3000;
// How long should a rect be considered valid for?
const REMEASUREMENT_AFTER_DURATION = 250;
// Markers for different types of HOCs
const HOC_MARKERS = new Map([
['Forget', '✨'],
['Memo', '🧠'],
]);
// Some environments (e.g. React Native / Hermes) don't support the performance API yet.
const getCurrentTime =
// $FlowFixMe[method-unbinding]
typeof performance === 'object' && typeof performance.now === 'function'
? () => performance.now()
: () => Date.now();
export type Data = {
count: number,
expirationTime: number,
lastMeasuredAt: number,
rect: Rect | null,
displayName: string | null,
};
const nodeToData: Map<HostInstance, Data> = new Map();
let agent: Agent = ((null: any): Agent);
let drawAnimationFrameID: AnimationFrameID | null = null;
let isEnabled: boolean = false;
let redrawTimeoutID: TimeoutID | null = null;
export function initialize(injectedAgent: Agent): void {
agent = injectedAgent;
agent.addListener('traceUpdates', traceUpdates);
}
export function toggleEnabled(value: boolean): void {
// ... (105 more lines)
Domain
Subdomains
Imported By
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 3 function(s): getCurrentTime, initialize, toggleEnabled.
What does index.js depend on?
index.js imports 4 module(s): agent, canvas.js, types.js, utils.js.
What files import index.js?
index.js is imported by 2 file(s): agent.js, canvas.js.
Where is index.js in the architecture?
index.js is located at packages/react-devtools-shared/src/backend/views/TraceUpdates/index.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-shared/src/backend/views/TraceUpdates).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free