Home / File/ frontend.js — react Source File

frontend.js — react Source File

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

File javascript 7 imports

Entity Profile

Dependency Diagram

graph LR
  f4bde5d3_b8b2_21dd_7b11_5246dfdcd8ec["frontend.js"]
  ac587885_e294_a1e9_b13f_5e7b920fdb42["react"]
  f4bde5d3_b8b2_21dd_7b11_5246dfdcd8ec --> ac587885_e294_a1e9_b13f_5e7b920fdb42
  8792c1c1_dca5_f137_73ea_c0e268fdbb22["client"]
  f4bde5d3_b8b2_21dd_7b11_5246dfdcd8ec --> 8792c1c1_dca5_f137_73ea_c0e268fdbb22
  4077b620_5c59_61c2_0910_273f565da757["bridge"]
  f4bde5d3_b8b2_21dd_7b11_5246dfdcd8ec --> 4077b620_5c59_61c2_0910_273f565da757
  baf70b0e_4867_b3ed_962a_e5c9ae820fef["store"]
  f4bde5d3_b8b2_21dd_7b11_5246dfdcd8ec --> baf70b0e_4867_b3ed_962a_e5c9ae820fef
  ce034302_61e9_5cdc_95e6_1e120df583e4["DevTools"]
  f4bde5d3_b8b2_21dd_7b11_5246dfdcd8ec --> ce034302_61e9_5cdc_95e6_1e120df583e4
  aec7978f_0a19_ba93_de9e_ac8cf5ddc74b["types"]
  f4bde5d3_b8b2_21dd_7b11_5246dfdcd8ec --> aec7978f_0a19_ba93_de9e_ac8cf5ddc74b
  2e5d5bab_71fd_5a80_3fa3_895dcaab6301["FetchFileWithCachingContext"]
  f4bde5d3_b8b2_21dd_7b11_5246dfdcd8ec --> 2e5d5bab_71fd_5a80_3fa3_895dcaab6301
  style f4bde5d3_b8b2_21dd_7b11_5246dfdcd8ec 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 * as React from 'react';
import {createRoot} from 'react-dom/client';
import Bridge from 'react-devtools-shared/src/bridge';
import Store from 'react-devtools-shared/src/devtools/store';
import DevTools from 'react-devtools-shared/src/devtools/views/DevTools';

import type {
  BrowserTheme,
  Wall,
} from 'react-devtools-shared/src/frontend/types';
import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
import type {
  CanViewElementSource,
  TabID,
  ViewAttributeSource,
  ViewElementSource,
} from 'react-devtools-shared/src/devtools/views/DevTools';
import type {FetchFileWithCaching} from 'react-devtools-shared/src/devtools/views/Components/FetchFileWithCachingContext';
import type {Config} from 'react-devtools-shared/src/devtools/store';

export function createBridge(wall?: Wall): FrontendBridge {
  if (wall != null) {
    return new Bridge(wall);
  }

  return new Bridge({listen: () => {}, send: () => {}});
}

export function createStore(bridge: FrontendBridge, config?: Config): Store {
  return new Store(bridge, {
    checkBridgeProtocolCompatibility: true,
    supportsTraceUpdates: true,
    supportsClickToInspect: true,
    ...config,
  });
}

type InitializationOptions = {
  bridge: FrontendBridge,
  store: Store,
  theme?: BrowserTheme,
  viewAttributeSourceFunction?: ViewAttributeSource,
  viewElementSourceFunction?: ViewElementSource,
  canViewElementSourceFunction?: CanViewElementSource,
  fetchFileWithCaching?: FetchFileWithCaching,
};

function initializeTab(
  tab: TabID,
  contentWindow: Element | Document,
  options: InitializationOptions,
) {
  const {
    bridge,
    store,
    theme = 'light',
    viewAttributeSourceFunction,
    viewElementSourceFunction,
    canViewElementSourceFunction,
    fetchFileWithCaching,
  } = options;
  const root = createRoot(contentWindow);

  root.render(
    <DevTools
      bridge={bridge}
      browserTheme={theme}
      store={store}
      showTabBar={false}
      overrideTab={tab}
      warnIfLegacyBackendDetected={true}
      enabledInspectedElementContextMenu={true}
      viewAttributeSourceFunction={viewAttributeSourceFunction}
      viewElementSourceFunction={viewElementSourceFunction}
      canViewElementSourceFunction={canViewElementSourceFunction}
      fetchFileWithCaching={fetchFileWithCaching}
    />,
  );
}

export function initializeComponents(
  contentWindow: Element | Document,
  options: InitializationOptions,
): void {
  initializeTab('components', contentWindow, options);
}

export function initializeProfiler(
  contentWindow: Element | Document,
  options: InitializationOptions,
): void {
  initializeTab('profiler', contentWindow, options);
}

Dependencies

  • DevTools
  • FetchFileWithCachingContext
  • bridge
  • client
  • react
  • store
  • types

Frequently Asked Questions

What does frontend.js do?
frontend.js is a source file in the react codebase, written in javascript.
What does frontend.js depend on?
frontend.js imports 7 module(s): DevTools, FetchFileWithCachingContext, bridge, client, react, store, types.
Where is frontend.js in the architecture?
frontend.js is located at packages/react-devtools-fusebox/src/frontend.js (directory: packages/react-devtools-fusebox/src).

Analyze Your Own Codebase

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

Try Supermodel Free