SourceMapConsumer.js — react Source File
Architecture documentation for SourceMapConsumer.js, a javascript file in the react codebase. 3 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR f84cdd87_26a7_958c_306d_f0c8ef51b27d["SourceMapConsumer.js"] 1cf4efe1_9da2_a991_9522_cf313b27188c["SourceMapTypes.js"] f84cdd87_26a7_958c_306d_f0c8ef51b27d --> 1cf4efe1_9da2_a991_9522_cf313b27188c 7e1e25cd_0db6_762f_27ad_866e33149c52["PerformanceLoggingUtils"] f84cdd87_26a7_958c_306d_f0c8ef51b27d --> 7e1e25cd_0db6_762f_27ad_866e33149c52 8b964ac1_528c_b6d4_9dc8_e2ee21534ee0["sourcemap-codec"] f84cdd87_26a7_958c_306d_f0c8ef51b27d --> 8b964ac1_528c_b6d4_9dc8_e2ee21534ee0 76da1f28_5fe1_2c37_5657_67756acc6f55["parseSourceAndMetadata.js"] 76da1f28_5fe1_2c37_5657_67756acc6f55 --> f84cdd87_26a7_958c_306d_f0c8ef51b27d style f84cdd87_26a7_958c_306d_f0c8ef51b27d 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 {withSyncPerfMeasurements} from 'react-devtools-shared/src/PerformanceLoggingUtils';
import {decode} from '@jridgewell/sourcemap-codec';
import type {
IndexSourceMap,
IndexSourceMapSection,
BasicSourceMap,
MixedSourceMap,
} from './SourceMapTypes';
type SearchPosition = {
columnNumber: number,
lineNumber: number,
};
type ResultPosition = {
column: number,
line: number,
sourceContent: string | null,
sourceURL: string | null,
ignored: boolean,
};
export type SourceMapConsumerType = {
originalPositionFor: SearchPosition => ResultPosition,
};
type Mappings = Array<Array<Array<number>>>;
export default function SourceMapConsumer(
sourceMapJSON: MixedSourceMap | IndexSourceMapSection,
): SourceMapConsumerType {
if (sourceMapJSON.sections != null) {
return IndexedSourceMapConsumer(((sourceMapJSON: any): IndexSourceMap));
} else {
return BasicSourceMapConsumer(((sourceMapJSON: any): BasicSourceMap));
}
}
function BasicSourceMapConsumer(sourceMapJSON: BasicSourceMap) {
const decodedMappings: Mappings = withSyncPerfMeasurements(
'Decoding source map mappings with @jridgewell/sourcemap-codec',
() => decode(sourceMapJSON.mappings),
);
function originalPositionFor({
columnNumber,
lineNumber,
}: SearchPosition): ResultPosition {
// Error.prototype.stack columns are 1-based (like most IDEs) but ASTs are 0-based.
const targetColumnNumber = columnNumber - 1;
// ... (178 more lines)
Domain
Dependencies
- PerformanceLoggingUtils
- SourceMapTypes.js
- sourcemap-codec
Source
Frequently Asked Questions
What does SourceMapConsumer.js do?
SourceMapConsumer.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain.
What does SourceMapConsumer.js depend on?
SourceMapConsumer.js imports 3 module(s): PerformanceLoggingUtils, SourceMapTypes.js, sourcemap-codec.
What files import SourceMapConsumer.js?
SourceMapConsumer.js is imported by 1 file(s): parseSourceAndMetadata.js.
Where is SourceMapConsumer.js in the architecture?
SourceMapConsumer.js is located at packages/react-devtools-shared/src/hooks/SourceMapConsumer.js (domain: BabelCompiler, 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