| 83 | } |
| 84 | |
| 85 | func (d *MappingsDecoder) Next() (value *Mapping, done bool) { |
| 86 | for !d.done && d.pos < len(d.mappings) { |
| 87 | ch := d.mappings[d.pos] |
| 88 | if ch == ';' { |
| 89 | // new line |
| 90 | d.generatedLine++ |
| 91 | d.generatedCharacter = 0 |
| 92 | d.pos++ |
| 93 | continue |
| 94 | } |
| 95 | |
| 96 | if ch == ',' { |
| 97 | // Next entry is on same line - no action needed |
| 98 | d.pos++ |
| 99 | continue |
| 100 | } |
| 101 | |
| 102 | hasSource := false |
| 103 | hasName := false |
| 104 | d.generatedCharacter += core.UTF16Offset(d.base64VLQFormatDecode()) |
| 105 | if d.hasReportedError() { |
| 106 | return d.stopIterating() |
| 107 | } |
| 108 | if d.generatedCharacter < 0 { |
| 109 | return d.setErrorAndStopIterating("Invalid generatedCharacter found") |
| 110 | } |
| 111 | |
| 112 | if !d.isSourceMappingSegmentEnd() { |
| 113 | hasSource = true |
| 114 | |
| 115 | d.sourceIndex += SourceIndex(d.base64VLQFormatDecode()) |
| 116 | if d.hasReportedError() { |
| 117 | return d.stopIterating() |
| 118 | } |
| 119 | if d.sourceIndex < 0 { |
| 120 | return d.setErrorAndStopIterating("Invalid sourceIndex found") |
| 121 | } |
| 122 | if d.isSourceMappingSegmentEnd() { |
| 123 | return d.setErrorAndStopIterating("Unsupported Format: No entries after sourceIndex") |
| 124 | } |
| 125 | |
| 126 | d.sourceLine += d.base64VLQFormatDecode() |
| 127 | if d.hasReportedError() { |
| 128 | return d.stopIterating() |
| 129 | } |
| 130 | if d.sourceLine < 0 { |
| 131 | return d.setErrorAndStopIterating("Invalid sourceLine found") |
| 132 | } |
| 133 | if d.isSourceMappingSegmentEnd() { |
| 134 | return d.setErrorAndStopIterating("Unsupported Format: No entries after sourceLine") |
| 135 | } |
| 136 | |
| 137 | d.sourceCharacter += core.UTF16Offset(d.base64VLQFormatDecode()) |
| 138 | if d.hasReportedError() { |
| 139 | return d.stopIterating() |
| 140 | } |
| 141 | if d.sourceCharacter < 0 { |
| 142 | return d.setErrorAndStopIterating("Invalid sourceCharacter found") |