Documentation
¶
Overview ¶
sourcemap is a package which defines types and methods for working with V3 of the SourceMap spec: https://goo.gl/Bn7iTo
Index ¶
- Constants
- type ParsedSourceMap
- type SourceMap
- func (sm *SourceMap) AddMapping(lineNumber int, colPosition int, mapping SourceMapping)
- func (sm *SourceMap) AppendMap(other *SourceMap)
- func (sm *SourceMap) Build(generatedFilePath string, sourceRoot string) *ParsedSourceMap
- func (sm *SourceMap) GetMapping(lineNumber int, colPosition int) (SourceMapping, bool)
- func (sm *SourceMap) OffsetBy(value string) *SourceMap
- type SourceMapping
Constants ¶
const BASE64_CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
const VERSION = 3
The supported sourcemap version.s
const VLQ_BIT_DATA_SHIFT = 5 // 5 bits of data in each character (except the last, which is 4)
const VLQ_CONTINUATION_BIT_MASK = 32
const VLQ_SIGN_BIT_MASK = 1
const VLQ_VALUE_MASK = VLQ_CONTINUATION_BIT_MASK - 1
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ParsedSourceMap ¶
type ParsedSourceMap struct {
// contains filtered or unexported fields
}
ParsedSourceMap is an in-memory immutable representation of an existing source map.
func Parse ¶
func Parse(encoded []byte) (*ParsedSourceMap, error)
Parse parses a sourcemap as contained in the byte data into an in-memory source map.
func (*ParsedSourceMap) GeneratedFilePath ¶
func (psm *ParsedSourceMap) GeneratedFilePath() string
GeneratedFilePath returns the generated file path for the source map.
func (*ParsedSourceMap) LookupMapping ¶
func (psm *ParsedSourceMap) LookupMapping(lineNumber int, colPosition int) (SourceMapping, bool)
LookupMapping returns the mapping for the given (0-indexed) line number and column position, if any.
func (*ParsedSourceMap) Marshal ¶
func (psm *ParsedSourceMap) Marshal() ([]byte, error)
Marshal turns the parsed source map into its JSON form.
func (*ParsedSourceMap) SourceRoot ¶
func (psm *ParsedSourceMap) SourceRoot() string
SourceRoot returns the source root for the source map, if any.
type SourceMap ¶
type SourceMap struct {
// contains filtered or unexported fields
}
SourceMap is an in-memory representation of a source map being constructed.
func NewSourceMap ¶
func NewSourceMap() *SourceMap
NewSourceMap returns a new source map for construction.
func (*SourceMap) AddMapping ¶
func (sm *SourceMap) AddMapping(lineNumber int, colPosition int, mapping SourceMapping)
AddMapping adds a new mapping for the given generated line number and column position to this map.
func (*SourceMap) AppendMap ¶
AppendMap adds all the mappings found in the other source map to this source map.
func (*SourceMap) Build ¶
func (sm *SourceMap) Build(generatedFilePath string, sourceRoot string) *ParsedSourceMap
Build returns the built source map.
func (*SourceMap) GetMapping ¶
func (sm *SourceMap) GetMapping(lineNumber int, colPosition int) (SourceMapping, bool)
GetMapping returns the source mapping entry for the given generated line number and column position, if any.
type SourceMapping ¶
type SourceMapping struct { // SourcePath is the path of the original source file for this position. SourcePath string // LineNumber is the 0-indexed line number in the original file. LineNumber int // ColumnPosition is the 0-indexed column position in the original file. ColumnPosition int // Name is the original name of the token, if any. Name string }
SourceMapping represents a mapping from a position in the input source file to an output source file.