Home / File/ symbolicateSource.js — react Source File

symbolicateSource.js — react Source File

Architecture documentation for symbolicateSource.js, a javascript file in the react codebase. 3 imports, 1 dependents.

File javascript BabelCompiler Validation 3 imports 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  165c2fb6_ea87_519d_8825_3b32e0b24ca4["symbolicateSource.js"]
  c49d3d32_fac1_6f30_11ac_97739c059095["SourceMapConsumer"]
  165c2fb6_ea87_519d_8825_3b32e0b24ca4 --> c49d3d32_fac1_6f30_11ac_97739c059095
  d8f20c67_f5fa_0f0a_c967_c41fd9ffce07["ReactTypes"]
  165c2fb6_ea87_519d_8825_3b32e0b24ca4 --> d8f20c67_f5fa_0f0a_c967_c41fd9ffce07
  2e5d5bab_71fd_5a80_3fa3_895dcaab6301["FetchFileWithCachingContext"]
  165c2fb6_ea87_519d_8825_3b32e0b24ca4 --> 2e5d5bab_71fd_5a80_3fa3_895dcaab6301
  bc9318d5_95fe_5bef_9896_4557f31e8d9d["utils-test.js"]
  bc9318d5_95fe_5bef_9896_4557f31e8d9d --> 165c2fb6_ea87_519d_8825_3b32e0b24ca4
  style 165c2fb6_ea87_519d_8825_3b32e0b24ca4 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 SourceMapConsumer from 'react-devtools-shared/src/hooks/SourceMapConsumer';

import type {ReactFunctionLocation} from 'shared/ReactTypes';
import type {FetchFileWithCaching} from 'react-devtools-shared/src/devtools/views/Components/FetchFileWithCachingContext';

const symbolicationCache: Map<
  string,
  Promise<SourceMappedLocation | null>,
> = new Map();

export type SourceMappedLocation = {
  location: ReactFunctionLocation,
  ignored: boolean, // Whether the file for this location was ignore listed
};

export function symbolicateSourceWithCache(
  fetchFileWithCaching: FetchFileWithCaching,
  sourceURL: string,
  line: number, // 1-based
  column: number, // 1-based
): Promise<SourceMappedLocation | null> {
  const key = `${sourceURL}:${line}:${column}`;
  const cachedPromise = symbolicationCache.get(key);
  if (cachedPromise != null) {
    return cachedPromise;
  }

  const promise = symbolicateSource(
    fetchFileWithCaching,
    sourceURL,
    line,
    column,
  );
  symbolicationCache.set(key, promise);

  return promise;
}

const SOURCE_MAP_ANNOTATION_PREFIX = 'sourceMappingURL=';
export async function symbolicateSource(
  fetchFileWithCaching: FetchFileWithCaching,
  sourceURL: string,
  lineNumber: number, // 1-based
  columnNumber: number, // 1-based
): Promise<SourceMappedLocation | null> {
  if (!sourceURL || sourceURL.startsWith('<anonymous')) {
    return null;
  }
  const resource = await fetchFileWithCaching(sourceURL).catch(() => null);
  if (resource == null) {
    return null;
// ... (101 more lines)

Domain

Subdomains

Dependencies

  • FetchFileWithCachingContext
  • ReactTypes
  • SourceMapConsumer

Frequently Asked Questions

What does symbolicateSource.js do?
symbolicateSource.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 symbolicateSource.js?
symbolicateSource.js defines 1 function(s): symbolicateSource.
What does symbolicateSource.js depend on?
symbolicateSource.js imports 3 module(s): FetchFileWithCachingContext, ReactTypes, SourceMapConsumer.
What files import symbolicateSource.js?
symbolicateSource.js is imported by 1 file(s): utils-test.js.
Where is symbolicateSource.js in the architecture?
symbolicateSource.js is located at packages/react-devtools-shared/src/symbolicateSource.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