Preserve source-map extensions in SingleMapping
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8411c74..af62d94 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+## 0.10.8
+
+* Preserve source-map extensions in `SingleMapping`. Extensions are keys in the
+ json map that start with `"x_"`.
+
## 0.10.7
* Set max SDK version to `<3.0.0`, and adjust other dependencies.
diff --git a/lib/parser.dart b/lib/parser.dart
index a500b13..7fe4565 100644
--- a/lib/parser.dart
+++ b/lib/parser.dart
@@ -278,8 +278,11 @@
final Uri _mapUrl;
+ final Map<String, dynamic> extensions;
+
SingleMapping._(this.targetUrl, this.files, this.urls, this.names, this.lines)
- : _mapUrl = null;
+ : _mapUrl = null,
+ extensions = {};
factory SingleMapping.fromEntries(Iterable<builder.Entry> entries,
[String fileUrl]) {
@@ -341,7 +344,8 @@
files = new List(map['sources'].length),
sourceRoot = map['sourceRoot'],
lines = <TargetLineEntry>[],
- _mapUrl = mapUrl is String ? Uri.parse(mapUrl) : mapUrl {
+ _mapUrl = mapUrl is String ? Uri.parse(mapUrl) : mapUrl,
+ extensions = {} {
var sourcesContent = map['sourcesContent'] == null
? const []
: new List<String>.from(map['sourcesContent']);
@@ -414,6 +418,10 @@
if (!entries.isEmpty) {
lines.add(new TargetLineEntry(line, entries));
}
+
+ map.forEach((name, value) {
+ if (name.startsWith("x_")) extensions[name] = value;
+ });
}
/// Encodes the Mapping mappings as a json map.
@@ -471,6 +479,7 @@
if (includeSourceContents) {
result['sourcesContent'] = files.map((file) => file?.getText(0)).toList();
}
+ extensions.forEach((name, value) => result[name] = value);
return result;
}
diff --git a/pubspec.yaml b/pubspec.yaml
index 0f4980e..49ab53d 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: source_maps
-version: 0.10.7
+version: 0.10.8
description: Library to programmatically manipulate source map files.
author: Dart Team <misc@dartlang.org>