@@ -25,7 +25,7 @@ import 'src/vlq.dart';
25
25
// `)]}'` begins the string representation of the map.
26
26
Mapping parse (String jsonMap,
27
27
{Map <String , Map >? otherMaps, /*String|Uri*/ Object ? mapUrl}) =>
28
- parseJson (jsonDecode (jsonMap), otherMaps: otherMaps, mapUrl: mapUrl);
28
+ parseJson (jsonDecode (jsonMap) as Map , otherMaps: otherMaps, mapUrl: mapUrl);
29
29
30
30
/// Parses a source map or source map bundle directly from a json string.
31
31
///
@@ -50,7 +50,7 @@ Mapping parseJsonExtended(/*List|Map*/ Object? json,
50
50
return parseJson (json as Map );
51
51
}
52
52
53
- /// Parses a source map
53
+ /// Parses a source map.
54
54
///
55
55
/// [mapUrl] , which may be either a [String] or a [Uri] , indicates the URL of
56
56
/// the source map file itself. If it's passed, any URLs in the source
@@ -69,10 +69,10 @@ Mapping parseJson(Map map,
69
69
throw FormatException ('map containing "sections" '
70
70
'cannot contain "mappings", "sources", or "names".' );
71
71
}
72
- return MultiSectionMapping .fromJson (map['sections' ], otherMaps,
72
+ return MultiSectionMapping .fromJson (map['sections' ] as List , otherMaps,
73
73
mapUrl: mapUrl);
74
74
}
75
- return SingleMapping .fromJson (map, mapUrl: mapUrl);
75
+ return SingleMapping .fromJson (map. cast < String , dynamic >() , mapUrl: mapUrl);
76
76
}
77
77
78
78
/// A mapping parsed out of a source map.
@@ -108,21 +108,21 @@ class MultiSectionMapping extends Mapping {
108
108
/// Creates a section mapping from json.
109
109
MultiSectionMapping .fromJson (List sections, Map <String , Map >? otherMaps,
110
110
{/*String|Uri*/ Object ? mapUrl}) {
111
- for (var section in sections) {
112
- var offset = section['offset' ];
111
+ for (var section in sections. cast < Map >() ) {
112
+ var offset = section['offset' ] as Map ? ;
113
113
if (offset == null ) throw FormatException ('section missing offset' );
114
114
115
- var line = section[ ' offset' ] ['line' ];
115
+ var line = offset['line' ] as int ? ;
116
116
if (line == null ) throw FormatException ('offset missing line' );
117
117
118
- var column = section[ ' offset' ] ['column' ];
118
+ var column = offset['column' ] as int ? ;
119
119
if (column == null ) throw FormatException ('offset missing column' );
120
120
121
121
_lineStart.add (line);
122
122
_columnStart.add (column);
123
123
124
- var url = section['url' ];
125
- var map = section['map' ];
124
+ var url = section['url' ] as String ? ;
125
+ var map = section['map' ] as Map ? ;
126
126
127
127
if (url != null && map != null ) {
128
128
throw FormatException ("section can't use both url and map entries" );
@@ -189,7 +189,7 @@ class MappingBundle extends Mapping {
189
189
190
190
MappingBundle .fromJson (List json, {/*String|Uri*/ Object ? mapUrl}) {
191
191
for (var map in json) {
192
- addMapping (parseJson (map, mapUrl: mapUrl) as SingleMapping );
192
+ addMapping (parseJson (map as Map , mapUrl: mapUrl) as SingleMapping );
193
193
}
194
194
}
195
195
@@ -342,18 +342,18 @@ class SingleMapping extends Mapping {
342
342
urls.keys.toList (), names.keys.toList (), lines);
343
343
}
344
344
345
- SingleMapping .fromJson (Map map, {mapUrl})
346
- : targetUrl = map['file' ],
347
- urls = List <String >.from (map['sources' ]),
348
- names = List <String >.from (map['names' ] ?? []),
349
- files = List .filled (map['sources' ].length, null ),
350
- sourceRoot = map['sourceRoot' ],
345
+ SingleMapping .fromJson (Map < String , dynamic > map, {mapUrl})
346
+ : targetUrl = map['file' ] as String ? ,
347
+ urls = List <String >.from (map['sources' ] as List ),
348
+ names = List <String >.from (( map['names' ] as List ? ) ?? []),
349
+ files = List .filled (( map['sources' ] as List ) .length, null ),
350
+ sourceRoot = map['sourceRoot' ] as String ? ,
351
351
lines = < TargetLineEntry > [],
352
- _mapUrl = mapUrl is String ? Uri .parse (mapUrl) : mapUrl,
352
+ _mapUrl = mapUrl is String ? Uri .parse (mapUrl) : ( mapUrl as Uri ? ) ,
353
353
extensions = {} {
354
354
var sourcesContent = map['sourcesContent' ] == null
355
355
? const < String ? > []
356
- : List <String ?>.from (map['sourcesContent' ]);
356
+ : List <String ?>.from (map['sourcesContent' ] as List );
357
357
for (var i = 0 ; i < urls.length && i < sourcesContent.length; i++ ) {
358
358
var source = sourcesContent[i];
359
359
if (source == null ) continue ;
@@ -366,7 +366,7 @@ class SingleMapping extends Mapping {
366
366
var srcLine = 0 ;
367
367
var srcColumn = 0 ;
368
368
var srcNameId = 0 ;
369
- var tokenizer = _MappingTokenizer (map['mappings' ]);
369
+ var tokenizer = _MappingTokenizer (map['mappings' ] as String );
370
370
var entries = < TargetEntry > [];
371
371
372
372
while (tokenizer.hasTokens) {
@@ -432,7 +432,7 @@ class SingleMapping extends Mapping {
432
432
///
433
433
/// If [includeSourceContents] is `true` , this includes the source file
434
434
/// contents from [files] in the map if possible.
435
- Map toJson ({bool includeSourceContents = false }) {
435
+ Map < String , dynamic > toJson ({bool includeSourceContents = false }) {
436
436
var buff = StringBuffer ();
437
437
var line = 0 ;
438
438
var column = 0 ;
@@ -471,12 +471,12 @@ class SingleMapping extends Mapping {
471
471
}
472
472
}
473
473
474
- var result = {
474
+ var result = < String , dynamic > {
475
475
'version' : 3 ,
476
476
'sourceRoot' : sourceRoot ?? '' ,
477
477
'sources' : urls,
478
478
'names' : names,
479
- 'mappings' : buff.toString ()
479
+ 'mappings' : buff.toString (),
480
480
};
481
481
if (targetUrl != null ) result['file' ] = targetUrl! ;
482
482
@@ -690,6 +690,8 @@ class _MappingTokenizer implements Iterator<String> {
690
690
buff.write ('[31m' );
691
691
try {
692
692
buff.write (current);
693
+ // TODO: Determine whether this try / catch can be removed.
694
+ // ignore: avoid_catching_errors
693
695
} on RangeError catch (_) {}
694
696
buff.write ('[0m' );
695
697
for (var i = index + 1 ; i < _internal.length; i++ ) {
0 commit comments