package sourcemap
import "github.com/evanw/esbuild/internal/sourcemap"
Index ¶
- func AppendSourceMapChunk(j *helpers.Joiner, prevEndState SourceMapState, startState SourceMapState, buffer MappingsBuffer)
- func DecodeVLQ(encoded []byte, start int) (int, int)
- func DecodeVLQUTF16(encoded []uint16) (int32, int, bool)
- type Chunk
- type ChunkBuilder
- func MakeChunkBuilder(inputSourceMap *SourceMap, lineOffsetTables []LineOffsetTable, asciiOnly bool) ChunkBuilder
- func (b *ChunkBuilder) AddSourceMapping(originalLoc logger.Loc, originalName string, output []byte)
- func (b *ChunkBuilder) GenerateChunk(output []byte) Chunk
- type LineColumnOffset
- func (a *LineColumnOffset) Add(b LineColumnOffset)
- func (offset *LineColumnOffset) AdvanceBytes(bytes []byte)
- func (offset *LineColumnOffset) AdvanceString(text string)
- func (a LineColumnOffset) ComesBefore(b LineColumnOffset) bool
- type LineOffsetTable
- type Mapping
- type MappingsBuffer
- type SourceContent
- type SourceMap
- type SourceMapPieces
- func (pieces SourceMapPieces) Finalize(shifts []SourceMapShift) []byte
- func (pieces SourceMapPieces) HasContent() bool
- type SourceMapShift
- type SourceMapState
Functions ¶
func AppendSourceMapChunk ¶
func AppendSourceMapChunk(j *helpers.Joiner, prevEndState SourceMapState, startState SourceMapState, buffer MappingsBuffer)
Source map chunks are computed in parallel for speed. Each chunk is relative to the zero state instead of being relative to the end state of the previous chunk, since it's impossible to know the end state of the previous chunk in a parallel computation.
After all chunks are computed, they are joined together in a second pass. This rewrites the first mapping in each chunk to be relative to the end state of the previous chunk.
func DecodeVLQ ¶
func DecodeVLQUTF16 ¶
Types ¶
type Chunk ¶
type Chunk struct { Buffer MappingsBuffer QuotedNames [][]byte // This end state will be used to rewrite the start of the following source // map chunk so that the delta-encoded VLQ numbers are preserved. EndState SourceMapState // There probably isn't a source mapping at the end of the file (nor should // there be) but if we're appending another source map chunk after this one, // we'll need to know how many characters were in the last line we generated. FinalGeneratedColumn int ShouldIgnore bool }
type ChunkBuilder ¶
type ChunkBuilder struct {
// contains filtered or unexported fields
}
func MakeChunkBuilder ¶
func MakeChunkBuilder(inputSourceMap *SourceMap, lineOffsetTables []LineOffsetTable, asciiOnly bool) ChunkBuilder
func (*ChunkBuilder) AddSourceMapping ¶
func (b *ChunkBuilder) AddSourceMapping(originalLoc logger.Loc, originalName string, output []byte)
func (*ChunkBuilder) GenerateChunk ¶
func (b *ChunkBuilder) GenerateChunk(output []byte) Chunk
type LineColumnOffset ¶
func (*LineColumnOffset) Add ¶
func (a *LineColumnOffset) Add(b LineColumnOffset)
func (*LineColumnOffset) AdvanceBytes ¶
func (offset *LineColumnOffset) AdvanceBytes(bytes []byte)
func (*LineColumnOffset) AdvanceString ¶
func (offset *LineColumnOffset) AdvanceString(text string)
func (LineColumnOffset) ComesBefore ¶
func (a LineColumnOffset) ComesBefore(b LineColumnOffset) bool
type LineOffsetTable ¶
type LineOffsetTable struct {
// contains filtered or unexported fields
}
func GenerateLineOffsetTables ¶
func GenerateLineOffsetTables(contents string, approximateLineCount int32) []LineOffsetTable
type Mapping ¶
type Mapping struct { GeneratedLine int32 // 0-based GeneratedColumn int32 // 0-based count of UTF-16 code units SourceIndex int32 // 0-based OriginalLine int32 // 0-based OriginalColumn int32 // 0-based count of UTF-16 code units OriginalName ast.Index32 // 0-based, optional }
type MappingsBuffer ¶
type SourceContent ¶
type SourceContent struct { // This stores both the unquoted and the quoted values. We try to use the // already-quoted value if possible so we don't need to re-quote it // unnecessarily for maximum performance. Quoted string // But sometimes we need to re-quote the value, such as when it contains // non-ASCII characters and we are in ASCII-only mode. In that case we quote // this parsed UTF-16 value. Value []uint16 }
type SourceMap ¶
type SourceMap struct { Sources []string SourcesContent []SourceContent Mappings []Mapping Names []string }
func (*SourceMap) Find ¶
type SourceMapPieces ¶
func (SourceMapPieces) Finalize ¶
func (pieces SourceMapPieces) Finalize(shifts []SourceMapShift) []byte
func (SourceMapPieces) HasContent ¶
func (pieces SourceMapPieces) HasContent() bool
type SourceMapShift ¶
type SourceMapShift struct { Before LineColumnOffset After LineColumnOffset }
type SourceMapState ¶
type SourceMapState struct { // This isn't stored in the source map. It's only used by the bundler to join // source map chunks together correctly. GeneratedLine int // These are stored in the source map in VLQ format. GeneratedColumn int SourceIndex int OriginalLine int OriginalColumn int OriginalName int HasOriginalName bool }
Coordinates in source maps are stored using relative offsets for size reasons. When joining together chunks of a source map that were emitted in parallel for different parts of a file, we need to fix up the first segment of each chunk to be relative to the end of the previous chunk.
Source Files ¶
- Version
- v0.25.0 (latest)
- Published
- Feb 8, 2025
- Platform
- linux/amd64
- Imports
- 6 packages
- Last checked
- 4 days ago –
Tools for package owners.