sourcemap

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2018 License: BSD-3-Clause Imports: 5 Imported by: 6

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

View Source
const BASE64_CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
View Source
const VERSION = 3

The supported sourcemap version.s

View Source
const VLQ_BIT_DATA_SHIFT = 5 // 5 bits of data in each character (except the last, which is 4)
View Source
const VLQ_CONTINUATION_BIT_MASK = 32
View Source
const VLQ_SIGN_BIT_MASK = 1
View Source
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

func (sm *SourceMap) AppendMap(other *SourceMap)

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.

func (*SourceMap) OffsetBy

func (sm *SourceMap) OffsetBy(value string) *SourceMap

OffsetBy returns a source map containing the mappings of this source map offset by the given string.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL