JsSourceMap Class

A source map (https://tc39.es/ecma426/, version 3): the positions of the original sources of a generated script, such as a bundle or the output of a compiler. Use it with a JsSourceMapper to show the errors of the script at their original positions.

public sealed class JsSourceMap

Properties

NameDescription
FileGets the name of the generated file (the file field), or null.
SourcesGets the URLs of the original sources: the sources field, prefixed by sourceRoot and resolved against the URL of the source map when they are relative.

Gets the name of the generated file (the file field), or null.

public string? File { get; }

Property value

string?

Gets the URLs of the original sources: the sources field, prefixed by sourceRoot and resolved against the URL of the source map when they are relative.

public IReadOnlyList<string> Sources { get; }

Property value

IReadOnlyList<string>

Methods

NameDescription
Parse(string, string?)Parses a source map.
TryGetOriginalLocation(int, int, JsSourceLocation)Gets the original position of a position of the generated code.
TryParse(string, string?, JsSourceMap?)Parses a source map; returns false when the text is not a valid source map of version 3.

Parse(string, string?)

JsSourceMap.cs

Parses a source map.

public static JsSourceMap Parse(string json, string? url = null)

Parameters

json string
The JSON text of the source map.
url string?
The URL (or the path) of the source map, against which the relative URLs of the sources are resolved, or null.

Returns

JsSourceMap

Exceptions

FormatException
The text is not a valid source map of version 3.

TryGetOriginalLocation(int, int, JsSourceLocation)

JsSourceMap.cs

Gets the original position of a position of the generated code.

public bool TryGetOriginalLocation(int line, int column, out JsSourceLocation location)

Parameters

line int
The 1-based line in the generated code.
column int
The 1-based column (in UTF-16 code units) in the generated code.
location JsSourceLocation
The original position: the URL of the original source, and the 1-based line and column of the mapping that contains the position.

Returns

bool false when no mapping contains the position, or when its mapping has no original source.

TryParse(string, string?, JsSourceMap?)

JsSourceMap.cs

Parses a source map; returns false when the text is not a valid source map of version 3.

public static bool TryParse(string json, string? url, out JsSourceMap? sourceMap)

Parameters

json string
The JSON text of the source map.
url string?
The URL (or the path) of the source map, against which the relative URLs of the sources are resolved, or null.
sourceMap JsSourceMap?
The source map.

Returns

bool