SourceMapMetadataConsumer.js — react Source File
Architecture documentation for SourceMapMetadataConsumer.js, a javascript file in the react codebase. 6 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 5751162b_425a_76d9_4373_4cf5cde09b49["SourceMapMetadataConsumer.js"] 22acaf1d_d624_cc04_9046_5e8603f3a58d["astUtils.js"] 5751162b_425a_76d9_4373_4cf5cde09b49 --> 22acaf1d_d624_cc04_9046_5e8603f3a58d 1cf4efe1_9da2_a991_9522_cf313b27188c["SourceMapTypes.js"] 5751162b_425a_76d9_4373_4cf5cde09b49 --> 1cf4efe1_9da2_a991_9522_cf313b27188c d816dd9a_2650_2f50_e9eb_2cdf900b512f["generateHookMap.js"] 5751162b_425a_76d9_4373_4cf5cde09b49 --> d816dd9a_2650_2f50_e9eb_2cdf900b512f 5ab6cc34_8610_de9f_93dc_9e7a8742ce9b["getHookNameForLocation.js"] 5751162b_425a_76d9_4373_4cf5cde09b49 --> 5ab6cc34_8610_de9f_93dc_9e7a8742ce9b e39d8e56_d264_6a32_839e_aeea5b5a0b9b["getHookNameForLocation"] 5751162b_425a_76d9_4373_4cf5cde09b49 --> e39d8e56_d264_6a32_839e_aeea5b5a0b9b c90a6ce1_9373_bcb5_541c_01d547b2c401["util"] 5751162b_425a_76d9_4373_4cf5cde09b49 --> c90a6ce1_9373_bcb5_541c_01d547b2c401 76da1f28_5fe1_2c37_5657_67756acc6f55["parseSourceAndMetadata.js"] 76da1f28_5fe1_2c37_5657_67756acc6f55 --> 5751162b_425a_76d9_4373_4cf5cde09b49 style 5751162b_425a_76d9_4373_4cf5cde09b49 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 strict-local
*/
import type {Position} from './astUtils';
import type {
ReactSourceMetadata,
IndexSourceMap,
BasicSourceMap,
MixedSourceMap,
} from './SourceMapTypes';
import type {HookMap} from './generateHookMap';
import * as util from 'source-map-js/lib/util';
import {decodeHookMap} from './generateHookMap';
import {getHookNameForLocation} from './getHookNameForLocation';
type MetadataMap = Map<string, ?ReactSourceMetadata>;
const HOOK_MAP_INDEX_IN_REACT_METADATA = 0;
const REACT_METADATA_INDEX_IN_FB_METADATA = 1;
const REACT_SOURCES_EXTENSION_KEY = 'x_react_sources';
const FB_SOURCES_EXTENSION_KEY = 'x_facebook_sources';
/**
* Extracted from the logic in source-map-js@0.6.2's SourceMapConsumer.
* By default, source names are normalized using the same logic that the `source-map-js@0.6.2` package uses internally.
* This is crucial for keeping the sources list in sync with a `SourceMapConsumer` instance.
*/
function normalizeSourcePath(
sourceInput: string,
map: {+sourceRoot?: ?string, ...},
): string {
const {sourceRoot} = map;
let source = sourceInput;
source = String(source);
// Some source maps produce relative source paths like "./foo.js" instead of
// "foo.js". Normalize these first so that future comparisons will succeed.
// See bugzil.la/1090768.
source = util.normalize(source);
// Always ensure that absolute sources are internally stored relative to
// the source root, if the source root is absolute. Not doing this would
// be particularly problematic when the source root is a prefix of the
// source (valid, but why??). See github issue #199 and bugzil.la/1188982.
source =
sourceRoot != null && util.isAbsolute(sourceRoot) && util.isAbsolute(source)
? util.relative(sourceRoot, source)
: source;
return util.computeSourceURL(sourceRoot, source);
}
/**
* Consumes the `x_react_sources` or `x_facebook_sources` metadata field from a
* source map and exposes ways to query the React DevTools specific metadata
* included in those fields.
// ... (148 more lines)
Domain
Subdomains
Functions
Classes
Dependencies
Source
Frequently Asked Questions
What does SourceMapMetadataConsumer.js do?
SourceMapMetadataConsumer.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 SourceMapMetadataConsumer.js?
SourceMapMetadataConsumer.js defines 1 function(s): normalizeSourcePath.
What does SourceMapMetadataConsumer.js depend on?
SourceMapMetadataConsumer.js imports 6 module(s): SourceMapTypes.js, astUtils.js, generateHookMap.js, getHookNameForLocation, getHookNameForLocation.js, util.
What files import SourceMapMetadataConsumer.js?
SourceMapMetadataConsumer.js is imported by 1 file(s): parseSourceAndMetadata.js.
Where is SourceMapMetadataConsumer.js in the architecture?
SourceMapMetadataConsumer.js is located at packages/react-devtools-shared/src/hooks/SourceMapMetadataConsumer.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-shared/src/hooks).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free