Home / File/ parseSourceAndMetadata.js — react Source File

parseSourceAndMetadata.js — react Source File

Architecture documentation for parseSourceAndMetadata.js, a javascript file in the react codebase. 15 imports, 2 dependents.

File javascript CompilerCore BabelIntegration 15 imports 2 dependents 6 functions

Entity Profile

Dependency Diagram

graph LR
  7fd1d14f_2952_9d88_cf59_6fc20b19b6d2["parseSourceAndMetadata.js"]
  36f643cb_8035_2b25_5816_569886c45d3d["astUtils.js"]
  7fd1d14f_2952_9d88_cf59_6fc20b19b6d2 --> 36f643cb_8035_2b25_5816_569886c45d3d
  6bbfcda0_8d25_e500_dc66_8b4e0c163fd3["getHookName"]
  7fd1d14f_2952_9d88_cf59_6fc20b19b6d2 --> 6bbfcda0_8d25_e500_dc66_8b4e0c163fd3
  e34ebc73_e01b_728b_cf52_c43058ebfc6e["ErrorTester.js"]
  7fd1d14f_2952_9d88_cf59_6fc20b19b6d2 --> e34ebc73_e01b_728b_cf52_c43058ebfc6e
  1a5bfb7a_be95_856a_8c5f_cb6833de46ec["areSourceMapsAppliedToErrors"]
  7fd1d14f_2952_9d88_cf59_6fc20b19b6d2 --> 1a5bfb7a_be95_856a_8c5f_cb6833de46ec
  3f28de42_7704_ff75_1669_a43087980aa0["SourceMapMetadataConsumer.js"]
  7fd1d14f_2952_9d88_cf59_6fc20b19b6d2 --> 3f28de42_7704_ff75_1669_a43087980aa0
  0a3c0409_d16f_3bee_b619_847f1175b357["SourceMapMetadataConsumer"]
  7fd1d14f_2952_9d88_cf59_6fc20b19b6d2 --> 0a3c0409_d16f_3bee_b619_847f1175b357
  b1824769_d8c8_3066_9465_9e69b3c58598["SourceMapConsumer.js"]
  7fd1d14f_2952_9d88_cf59_6fc20b19b6d2 --> b1824769_d8c8_3066_9465_9e69b3c58598
  9e233ad5_d9ff_e5ad_ef9f_bd414f8651af["loadSourceAndMetadata.js"]
  7fd1d14f_2952_9d88_cf59_6fc20b19b6d2 --> 9e233ad5_d9ff_e5ad_ef9f_bd414f8651af
  1addb605_871c_6609_61fa_c3874942c16f["parser"]
  7fd1d14f_2952_9d88_cf59_6fc20b19b6d2 --> 1addb605_871c_6609_61fa_c3874942c16f
  80797d61_02c1_e1cb_219a_9d971efd5991["lru-cache"]
  7fd1d14f_2952_9d88_cf59_6fc20b19b6d2 --> 80797d61_02c1_e1cb_219a_9d971efd5991
  20a9897d_bc06_6f5b_935f_1dff5785c426["constants"]
  7fd1d14f_2952_9d88_cf59_6fc20b19b6d2 --> 20a9897d_bc06_6f5b_935f_1dff5785c426
  3431173d_e2a0_f12b_d2fa_5cd77ce31c54["hookSourceLocation"]
  7fd1d14f_2952_9d88_cf59_6fc20b19b6d2 --> 3431173d_e2a0_f12b_d2fa_5cd77ce31c54
  3c663233_7ba9_9e5a_be2a_77dc66af5ae0["PerformanceLoggingUtils"]
  7fd1d14f_2952_9d88_cf59_6fc20b19b6d2 --> 3c663233_7ba9_9e5a_be2a_77dc66af5ae0
  37acb7fe_ee24_a044_2fac_efae0556c848["ReactDebugHooks"]
  7fd1d14f_2952_9d88_cf59_6fc20b19b6d2 --> 37acb7fe_ee24_a044_2fac_efae0556c848
  style 7fd1d14f_2952_9d88_cf59_6fc20b19b6d2 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
 */

// For an overview of why the code in this file is structured this way,
// refer to header comments in loadSourceAndMetadata.

import {parse} from '@babel/parser';
import LRU from 'lru-cache';
import {getHookName} from '../astUtils';
import {areSourceMapsAppliedToErrors} from '../ErrorTester';
import {__DEBUG__} from 'react-devtools-shared/src/constants';
import {getHookSourceLocationKey} from 'react-devtools-shared/src/hookSourceLocation';
import {SourceMapMetadataConsumer} from '../SourceMapMetadataConsumer';
import {
  withAsyncPerfMeasurements,
  withSyncPerfMeasurements,
} from 'react-devtools-shared/src/PerformanceLoggingUtils';
import SourceMapConsumer from '../SourceMapConsumer';

import type {SourceMapConsumerType} from '../SourceMapConsumer';
import type {
  HooksList,
  LocationKeyToHookSourceAndMetadata,
} from './loadSourceAndMetadata';
import type {HookSource} from 'react-debug-tools/src/ReactDebugHooks';
import type {
  HookNames,
  LRUCache,
} from 'react-devtools-shared/src/frontend/types';

type AST = mixed;

type HookParsedMetadata = {
  // API for consuming metadfata present in extended source map.
  metadataConsumer: SourceMapMetadataConsumer | null,

  // AST for original source code; typically comes from a consumed source map.
  originalSourceAST: AST | null,

  // Source code (React components or custom hooks) containing primitive hook calls.
  // If no source map has been provided, this code will be the same as runtimeSourceCode.
  originalSourceCode: string | null,

  // Original source URL if there is a source map, or the same as runtimeSourceURL.
  originalSourceURL: string | null,

  // Line number in original source code.
  originalSourceLineNumber: number | null,

  // Column number in original source code.
  originalSourceColumnNumber: number | null,

  // Alternate APIs from source-map for parsing source maps (if detected).
  sourceMapConsumer: SourceMapConsumerType | null,
// ... (382 more lines)

Domain

Subdomains

Frequently Asked Questions

What does parseSourceAndMetadata.js do?
parseSourceAndMetadata.js is a source file in the react codebase, written in javascript. It belongs to the CompilerCore domain, BabelIntegration subdomain.
What functions are defined in parseSourceAndMetadata.js?
parseSourceAndMetadata.js defines 6 function(s): findHookNames, initializeHookParsedMetadata, parseSourceAST, parseSourceAndMetadata, parseSourceMaps, purgeCachedMetadata.
What does parseSourceAndMetadata.js depend on?
parseSourceAndMetadata.js imports 15 module(s): ErrorTester.js, PerformanceLoggingUtils, ReactDebugHooks, SourceMapConsumer.js, SourceMapMetadataConsumer, SourceMapMetadataConsumer.js, areSourceMapsAppliedToErrors, astUtils.js, and 7 more.
What files import parseSourceAndMetadata.js?
parseSourceAndMetadata.js is imported by 2 file(s): index.js, parseSourceAndMetadata.worker.js.
Where is parseSourceAndMetadata.js in the architecture?
parseSourceAndMetadata.js is located at packages/react-devtools-shared/src/hooks/parseHookNames/parseSourceAndMetadata.js (domain: CompilerCore, subdomain: BabelIntegration, directory: packages/react-devtools-shared/src/hooks/parseHookNames).

Analyze Your Own Codebase

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

Try Supermodel Free