JsSourceMapper Class
Maps the positions of generated scripts (bundles, the output of a compiler) to their original sources with source maps: the location of a JsException and the stack traces. It does not change the execution of the scripts: the errors and the stack property that the scripts see keep the generated positions.
public sealed class JsSourceMapperRemarks
The source map of a script is found by the URL of the script (the URL given to JsRealm.Execute or to JsRealm.ParseModule): added with JsSourceMapper.Add, or returned by the resolver of the constructor, which is called once per URL. A position whose script has no source map, or that no mapping of the source map contains, is not changed. The methods can be called from any thread.
Constructors
| Name | Description |
|---|---|
| JsSourceMapper() | Initializes a new instance of the JsSourceMapper class whose source maps are added with JsSourceMapper.Add. |
| JsSourceMapper(Func<string, JsSourceMap?>) | Initializes a new instance of the JsSourceMapper class that gets the source maps from a resolver. |
JsSourceMapper overloads
JsSourceMapper()
JsSourceMapper.csInitializes a new instance of the JsSourceMapper class whose source maps are added with JsSourceMapper.Add.
public JsSourceMapper()JsSourceMapper(Func<string, JsSourceMap?>)
JsSourceMapper.csInitializes a new instance of the JsSourceMapper class that gets the source maps from a resolver.
public JsSourceMapper(Func<string, JsSourceMap?> resolver)Parameters
resolverFunc<string, JsSourceMap?>- Returns the source map of the script of a URL, or null when it has none (e.g. it reads the file of the
//# sourceMappingURL=comment of the script). It is called once per URL; an exception it throws goes to the caller of the method that maps the position, and the resolver is called again for the next position of the URL.
Methods
| Name | Description |
|---|---|
| Add(string, JsSourceMap) | Sets the source map of the script of a URL. |
| MapLocation(JsSourceLocation) | Gets the original position of a position of a generated script, or the position itself when it cannot be mapped. |
| MapLocation(JsSourceLocation?) | Gets the original position of a position of a generated script (e.g. JsException.Location), or the position itself when it cannot be mapped. |
| MapStackTrace(string) | Replaces the positions of the frames of a stack trace (the stack property of an error, or the result of JsEngine.CaptureStackTrace) by their original positions. The lines that are not frames, and the frames that cannot be mapped, are not changed. |
Add(string, JsSourceMap)
JsSourceMapper.csSets the source map of the script of a URL.
public void Add(string url, JsSourceMap sourceMap)Parameters
urlstring- The URL of the generated script.
sourceMapJsSourceMap- The source map of the script.
MapLocation overloads
MapLocation(JsSourceLocation)
JsSourceMapper.csGets the original position of a position of a generated script, or the position itself when it cannot be mapped.
public JsSourceLocation MapLocation(JsSourceLocation location)MapLocation(JsSourceLocation?)
JsSourceMapper.csGets the original position of a position of a generated script (e.g. JsException.Location), or the position itself when it cannot be mapped.
public JsSourceLocation? MapLocation(JsSourceLocation? location)MapStackTrace(string)
JsSourceMapper.csReplaces the positions of the frames of a stack trace (the stack property of an error, or the result of JsEngine.CaptureStackTrace) by their original positions. The lines that are not frames, and the frames that cannot be mapped, are not changed.