Home / File/ inspectedElementMutableSource.js — react Source File

inspectedElementMutableSource.js — react Source File

Architecture documentation for inspectedElementMutableSource.js, a javascript file in the react codebase. 8 imports, 0 dependents.

File javascript BabelCompiler Validation 8 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  44256a95_877f_4e93_61c4_25c0f9f35be5["inspectedElementMutableSource.js"]
  a6a22523_be38_c543_6be0_5e0a78f4bcce["lru-cache"]
  44256a95_877f_4e93_61c4_25c0f9f35be5 --> a6a22523_be38_c543_6be0_5e0a78f4bcce
  ee975ccf_fc44_0272_3414_71bca1874ed1["backendAPI"]
  44256a95_877f_4e93_61c4_25c0f9f35be5 --> ee975ccf_fc44_0272_3414_71bca1874ed1
  114016f3_a8fe_e14f_8022_69bffc846065["hydration"]
  44256a95_877f_4e93_61c4_25c0f9f35be5 --> 114016f3_a8fe_e14f_8022_69bffc846065
  aec7978f_0a19_ba93_de9e_ac8cf5ddc74b["types"]
  44256a95_877f_4e93_61c4_25c0f9f35be5 --> aec7978f_0a19_ba93_de9e_ac8cf5ddc74b
  4077b620_5c59_61c2_0910_273f565da757["bridge"]
  44256a95_877f_4e93_61c4_25c0f9f35be5 --> 4077b620_5c59_61c2_0910_273f565da757
  40bf6909_04ae_bfb6_965f_14cfe98b94de["types"]
  44256a95_877f_4e93_61c4_25c0f9f35be5 --> 40bf6909_04ae_bfb6_965f_14cfe98b94de
  fb3ac98a_1cd8_55eb_fa46_d3e77dc6636f["UserError"]
  44256a95_877f_4e93_61c4_25c0f9f35be5 --> fb3ac98a_1cd8_55eb_fa46_d3e77dc6636f
  df0825ed_6346_2148_6996_c1bb83f8c1df["UnknownHookError"]
  44256a95_877f_4e93_61c4_25c0f9f35be5 --> df0825ed_6346_2148_6996_c1bb83f8c1df
  style 44256a95_877f_4e93_61c4_25c0f9f35be5 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 LRU from 'lru-cache';
import {
  convertInspectedElementBackendToFrontend,
  hydrateHelper,
  inspectElement as inspectElementAPI,
  inspectScreen as inspectScreenAPI,
} from 'react-devtools-shared/src/backendAPI';
import {fillInPath} from 'react-devtools-shared/src/hydration';

import type {LRUCache} from 'react-devtools-shared/src/frontend/types';
import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
import type {
  InspectElementError,
  InspectElementFullData,
  InspectElementHydratedPath,
} from 'react-devtools-shared/src/backend/types';
import UserError from 'react-devtools-shared/src/errors/UserError';
import UnknownHookError from 'react-devtools-shared/src/errors/UnknownHookError';
import type {
  Element,
  InspectedElement as InspectedElementFrontend,
  InspectedElementResponseType,
  InspectedElementPath,
} from 'react-devtools-shared/src/frontend/types';

// Maps element ID to inspected data.
// We use an LRU for this rather than a WeakMap because of how the "no-change" optimization works.
// When the frontend polls the backend for an update on the element that's currently inspected,
// the backend will send a "no-change" message if the element hasn't updated (rendered) since the last time it was asked.
// In this case, the frontend cache should reuse the previous (cached) value.
// Using a WeakMap keyed on Element generally works well for this, since Elements are mutable and stable in the Store.
// This doens't work properly though when component filters are changed,
// because this will cause the Store to dump all roots and re-initialize the tree (recreating the Element objects).
// So instead we key on Element ID (which is stable in this case) and use an LRU for eviction.
const inspectedElementCache: LRUCache<number, InspectedElementFrontend> =
  new LRU({
    max: 25,
  });

type InspectElementReturnType = [
  InspectedElementFrontend,
  InspectedElementResponseType,
];

export function inspectElement(
  bridge: FrontendBridge,
  element: Element,
  path: InspectedElementPath | null,
  rendererID: number,
  shouldListenToPauseEvents: boolean = false,
): Promise<InspectElementReturnType> {
// ... (123 more lines)

Domain

Subdomains

Dependencies

  • UnknownHookError
  • UserError
  • backendAPI
  • bridge
  • hydration
  • lru-cache
  • types
  • types

Frequently Asked Questions

What does inspectedElementMutableSource.js do?
inspectedElementMutableSource.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 inspectedElementMutableSource.js?
inspectedElementMutableSource.js defines 2 function(s): clearCacheForTests, inspectElement.
What does inspectedElementMutableSource.js depend on?
inspectedElementMutableSource.js imports 8 module(s): UnknownHookError, UserError, backendAPI, bridge, hydration, lru-cache, types, types.
Where is inspectedElementMutableSource.js in the architecture?
inspectedElementMutableSource.js is located at packages/react-devtools-shared/src/inspectedElementMutableSource.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-shared/src).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free