@@ -170,60 +170,6 @@ Napi::Object SourceMapBinding::_mappingToObject(Napi::Env env, Mapping &mapping)
170
170
return mappingObject;
171
171
}
172
172
173
- // returns the sorted and processed map with decoded vlqs and all other map data
174
- Napi::Value SourceMapBinding::getMap (const Napi::CallbackInfo &info) {
175
- Napi::Env env = info.Env ();
176
- Napi::HandleScope scope (env);
177
-
178
- Napi::Object obj = Napi::Object::New (env);
179
-
180
- // Sort mappings
181
- _mapping_container.sort ();
182
-
183
- auto sourcesVector = _mapping_container.getSourcesVector ();
184
- int len = sourcesVector.size ();
185
- Napi::Array sourcesArray = Napi::Array::New (env, len);
186
- for (int i = 0 ; i < len; ++i) {
187
- sourcesArray.Set (i, sourcesVector[i]);
188
- }
189
- obj.Set (" sources" , sourcesArray);
190
-
191
- auto sourcesContentVector = _mapping_container.getSourcesContentVector ();
192
- len = sourcesContentVector.size ();
193
- Napi::Array sourcesContentArray = Napi::Array::New (env, len);
194
- for (int i = 0 ; i < len; ++i) {
195
- sourcesContentArray.Set (i, sourcesContentVector[i]);
196
- }
197
- obj.Set (" sourcesContent" , sourcesContentArray);
198
-
199
- auto namesVector = _mapping_container.getNamesVector ();
200
- len = namesVector.size ();
201
- Napi::Array namesArray = Napi::Array::New (env, len);
202
- for (int i = 0 ; i < len; ++i) {
203
- namesArray.Set (i, namesVector[i]);
204
- }
205
- obj.Set (" names" , namesArray);
206
-
207
- auto mappingLinesVector = _mapping_container.getMappingLinesVector ();
208
- Napi::Array mappingsArray = Napi::Array::New (env, _mapping_container.getTotalSegments ());
209
- auto lineEnd = mappingLinesVector.end ();
210
- int currentMapping = 0 ;
211
- for (auto lineIterator = mappingLinesVector.begin (); lineIterator != lineEnd; ++lineIterator) {
212
- auto &line = (*lineIterator);
213
- auto &segments = line._segments ;
214
- auto segmentsEnd = segments.end ();
215
-
216
- for (auto segmentIterator = segments.begin (); segmentIterator != segmentsEnd; ++segmentIterator) {
217
- Mapping &mapping = *segmentIterator;
218
- mappingsArray.Set (currentMapping, _mappingToObject (env, mapping));
219
- ++currentMapping;
220
- }
221
- }
222
- obj.Set (" mappings" , mappingsArray);
223
-
224
- return obj;
225
- }
226
-
227
173
void SourceMapBinding::addIndexedMappings (const Napi::CallbackInfo &info) {
228
174
Napi::Env env = info.Env ();
229
175
Napi::HandleScope scope (env);
@@ -269,7 +215,6 @@ Napi::Value SourceMapBinding::getSourceIndex(const Napi::CallbackInfo &info) {
269
215
return Napi::Number::New (env, index );
270
216
}
271
217
272
-
273
218
Napi::Value SourceMapBinding::getSource (const Napi::CallbackInfo &info) {
274
219
Napi::Env env = info.Env ();
275
220
Napi::HandleScope scope (env);
@@ -283,6 +228,20 @@ Napi::Value SourceMapBinding::getSource(const Napi::CallbackInfo &info) {
283
228
return Napi::String::New (env, _mapping_container.getSource (index ));
284
229
}
285
230
231
+ Napi::Value SourceMapBinding::getSources (const Napi::CallbackInfo &info) {
232
+ Napi::Env env = info.Env ();
233
+ Napi::HandleScope scope (env);
234
+
235
+ auto sourcesVector = _mapping_container.getSourcesVector ();
236
+ int len = sourcesVector.size ();
237
+ Napi::Array sourcesArray = Napi::Array::New (env, len);
238
+ for (int i = 0 ; i < len; ++i) {
239
+ sourcesArray.Set (i, sourcesVector[i]);
240
+ }
241
+
242
+ return sourcesArray;
243
+ }
244
+
286
245
Napi::Value SourceMapBinding::getNameIndex (const Napi::CallbackInfo &info) {
287
246
Napi::Env env = info.Env ();
288
247
Napi::HandleScope scope (env);
@@ -311,6 +270,20 @@ Napi::Value SourceMapBinding::getName(const Napi::CallbackInfo &info) {
311
270
return Napi::String::New (env, _mapping_container.getName (index ));
312
271
}
313
272
273
+ Napi::Value SourceMapBinding::getNames (const Napi::CallbackInfo &info) {
274
+ Napi::Env env = info.Env ();
275
+ Napi::HandleScope scope (env);
276
+
277
+ auto namesVector = _mapping_container.getNamesVector ();
278
+ int len = namesVector.size ();
279
+ Napi::Array namesArray = Napi::Array::New (env, len);
280
+ for (int i = 0 ; i < len; ++i) {
281
+ namesArray.Set (i, namesVector[i]);
282
+ }
283
+
284
+ return namesArray;
285
+ }
286
+
314
287
std::vector<int > SourceMapBinding::_addNames (Napi::Array &namesArray) {
315
288
std::vector<int > insertions;
316
289
insertions.reserve (namesArray.Length ());
@@ -395,6 +368,47 @@ Napi::Value SourceMapBinding::getSourceContent(const Napi::CallbackInfo &info) {
395
368
return Napi::String::New (env, _mapping_container.getSourceContent (_mapping_container.getSourceIndex (sourceName)));
396
369
}
397
370
371
+ Napi::Value SourceMapBinding::getSourcesContent (const Napi::CallbackInfo &info) {
372
+ Napi::Env env = info.Env ();
373
+ Napi::HandleScope scope (env);
374
+
375
+ auto sourcesContentVector = _mapping_container.getSourcesContentVector ();
376
+ int len = sourcesContentVector.size ();
377
+ Napi::Array sourcesContentArray = Napi::Array::New (env, len);
378
+ for (int i = 0 ; i < len; ++i) {
379
+ sourcesContentArray.Set (i, sourcesContentVector[i]);
380
+ }
381
+
382
+ return sourcesContentArray;
383
+ }
384
+
385
+ // returns the sorted and processed mappings with decoded vlqs
386
+ Napi::Value SourceMapBinding::getMappings (const Napi::CallbackInfo &info) {
387
+ Napi::Env env = info.Env ();
388
+ Napi::HandleScope scope (env);
389
+
390
+ // Sort mappings
391
+ _mapping_container.sort ();
392
+
393
+ auto mappingLinesVector = _mapping_container.getMappingLinesVector ();
394
+ Napi::Array mappingsArray = Napi::Array::New (env, _mapping_container.getTotalSegments ());
395
+ auto lineEnd = mappingLinesVector.end ();
396
+ int currentMapping = 0 ;
397
+ for (auto lineIterator = mappingLinesVector.begin (); lineIterator != lineEnd; ++lineIterator) {
398
+ auto &line = (*lineIterator);
399
+ auto &segments = line._segments ;
400
+ auto segmentsEnd = segments.end ();
401
+
402
+ for (auto segmentIterator = segments.begin (); segmentIterator != segmentsEnd; ++segmentIterator) {
403
+ Mapping &mapping = *segmentIterator;
404
+ mappingsArray.Set (currentMapping, _mappingToObject (env, mapping));
405
+ ++currentMapping;
406
+ }
407
+ }
408
+
409
+ return mappingsArray;
410
+ }
411
+
398
412
void SourceMapBinding::addEmptyMap (const Napi::CallbackInfo &info) {
399
413
Napi::Env env = info.Env ();
400
414
Napi::HandleScope scope (env);
@@ -464,16 +478,19 @@ Napi::Object SourceMapBinding::Init(Napi::Env env, Napi::Object exports) {
464
478
InstanceMethod (" addBufferMappings" , &SourceMapBinding::addBufferMappings),
465
479
InstanceMethod (" stringify" , &SourceMapBinding::stringify),
466
480
InstanceMethod (" toBuffer" , &SourceMapBinding::toBuffer),
467
- InstanceMethod (" getMap" , &SourceMapBinding::getMap),
468
481
InstanceMethod (" addIndexedMappings" , &SourceMapBinding::addIndexedMappings),
469
482
InstanceMethod (" addName" , &SourceMapBinding::addName),
470
483
InstanceMethod (" addSource" , &SourceMapBinding::addSource),
471
484
InstanceMethod (" setSourceContent" , &SourceMapBinding::setSourceContent),
472
485
InstanceMethod (" getSourceContent" , &SourceMapBinding::getSourceContent),
486
+ InstanceMethod (" getSourcesContent" , &SourceMapBinding::getSourcesContent),
473
487
InstanceMethod (" getSourceIndex" , &SourceMapBinding::getSourceIndex),
474
488
InstanceMethod (" getSource" , &SourceMapBinding::getSource),
489
+ InstanceMethod (" getSources" , &SourceMapBinding::getSources),
475
490
InstanceMethod (" getNameIndex" , &SourceMapBinding::getNameIndex),
476
491
InstanceMethod (" getName" , &SourceMapBinding::getName),
492
+ InstanceMethod (" getNames" , &SourceMapBinding::getNames),
493
+ InstanceMethod (" getMappings" , &SourceMapBinding::getMappings),
477
494
InstanceMethod (" extends" , &SourceMapBinding::extends),
478
495
InstanceMethod (" addEmptyMap" , &SourceMapBinding::addEmptyMap),
479
496
InstanceMethod (" findClosestMapping" , &SourceMapBinding::findClosestMapping),
0 commit comments