* Serialize the accumulated mappings in to the stream of base 64 VLQs * specified by the source map format.
()
| 320 | * specified by the source map format. |
| 321 | */ |
| 322 | _serializeMappings() { |
| 323 | let previousGeneratedColumn = 0; |
| 324 | let previousGeneratedLine = 1; |
| 325 | let previousOriginalColumn = 0; |
| 326 | let previousOriginalLine = 0; |
| 327 | let previousName = 0; |
| 328 | let previousSource = 0; |
| 329 | let result = ""; |
| 330 | let next; |
| 331 | let mapping; |
| 332 | let nameIdx; |
| 333 | let sourceIdx; |
| 334 | |
| 335 | const mappings = this._mappings.toArray(); |
| 336 | for (let i = 0, len = mappings.length; i < len; i++) { |
| 337 | mapping = mappings[i]; |
| 338 | next = ""; |
| 339 | |
| 340 | if (mapping.generatedLine !== previousGeneratedLine) { |
| 341 | previousGeneratedColumn = 0; |
| 342 | while (mapping.generatedLine !== previousGeneratedLine) { |
| 343 | next += ";"; |
| 344 | previousGeneratedLine++; |
| 345 | } |
| 346 | } else if (i > 0) { |
| 347 | if ( |
| 348 | !util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1]) |
| 349 | ) { |
| 350 | continue; |
| 351 | } |
| 352 | next += ","; |
| 353 | } |
| 354 | |
| 355 | next += base64VLQ.encode( |
| 356 | mapping.generatedColumn - previousGeneratedColumn |
| 357 | ); |
| 358 | previousGeneratedColumn = mapping.generatedColumn; |
| 359 | |
| 360 | if (mapping.source != null) { |
| 361 | sourceIdx = this._sources.indexOf(mapping.source); |
| 362 | next += base64VLQ.encode(sourceIdx - previousSource); |
| 363 | previousSource = sourceIdx; |
| 364 | |
| 365 | // lines are stored 0-based in SourceMap spec version 3 |
| 366 | next += base64VLQ.encode( |
| 367 | mapping.originalLine - 1 - previousOriginalLine |
| 368 | ); |
| 369 | previousOriginalLine = mapping.originalLine - 1; |
| 370 | |
| 371 | next += base64VLQ.encode( |
| 372 | mapping.originalColumn - previousOriginalColumn |
| 373 | ); |
| 374 | previousOriginalColumn = mapping.originalColumn; |
| 375 | |
| 376 | if (mapping.name != null) { |
| 377 | nameIdx = this._names.indexOf(mapping.name); |
| 378 | next += base64VLQ.encode(nameIdx - previousName); |
| 379 | previousName = nameIdx; |