Library to create and parse source maps.

Create a source map using SourceMapBuilder. For example: var json = (new SourceMapBuilder() ..add(inputSpan1, outputSpan1) ..add(inputSpan2, outputSpan2) ..add(inputSpan3, outputSpan3) .toJson(outputFile);

Use the source_span package's SourceSpan and SourceFile classes to specify span locations.

Parse a source map using parse, and call spanFor on the returned mapping object. For example: var mapping = parse(json); mapping.spanFor(outputSpan1.line, outputSpan1.column)

Getting the code

This library is distributed as a pub package. To install this package, add the following to your pubspec.yaml file:

dependencies:
  source_maps: any

After you run pub install, you should be able to access this library by importing package:source_maps/source_maps.dart.

For more information, see the source_maps package on pub.dartlang.org.

Classes

Entry
An entry in the source map builder.
Mapping
A mapping parsed out of a source map.
MappingBundle
MultiSectionMapping
A meta-level map containing sections.
NestedItem
An item added to a NestedPrinter.
NestedPrinter
A more advanced printer that keeps track of offset locations to record source maps, but additionally allows nesting of different kind of items, including NestedPrinters, and it let's you automatically indent text. [...]
Printer
A simple printer that keeps track of offset locations and records source maps locations.
SingleMapping
A map containing direct source mappings.
SourceMapBuilder
Builds a source map given a set of mappings.
SourceMapFileSpan
A wrapper aruond a FileSpan that implements SourceMapSpan.
SourceMapSpan
A SourceSpan for spans coming from or being written to source maps. [...]
TargetEntry
A target segment entry read from a source map
TargetLineEntry
A line entry read from a source map.
TextEditTransaction
Editable text transaction. [...]

Functions

guessIndent(String code, int charOffset) String
Returns all whitespace characters at the start of charOffset's line.
parse(String jsonMap, { Map<String, Map> otherMaps, mapUrl }) Mapping
Parses a source map directly from a json string. [...]
parseExtended(String jsonMap, { Map<String, Map> otherMaps, mapUrl }) Mapping
Parses a source map or source map bundle directly from a json string. [...]
parseJson(Map map, { Map<String, Map> otherMaps, mapUrl }) Mapping
Parses a source map [...]
parseJsonExtended(json, { Map<String, Map> otherMaps, mapUrl }) Mapping
Parses a source map or source map bundle. [...]