aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/gopkg.in/sourcemap.v1
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/gopkg.in/sourcemap.v1')
-rw-r--r--vendor/gopkg.in/sourcemap.v1/.travis.yml12
-rw-r--r--vendor/gopkg.in/sourcemap.v1/LICENSE25
-rw-r--r--vendor/gopkg.in/sourcemap.v1/Makefile3
-rw-r--r--vendor/gopkg.in/sourcemap.v1/README.md35
-rw-r--r--vendor/gopkg.in/sourcemap.v1/base64vlq/base64_vlq.go95
-rw-r--r--vendor/gopkg.in/sourcemap.v1/consumer.go312
6 files changed, 482 insertions, 0 deletions
diff --git a/vendor/gopkg.in/sourcemap.v1/.travis.yml b/vendor/gopkg.in/sourcemap.v1/.travis.yml
new file mode 100644
index 000000000..814f0e51a
--- /dev/null
+++ b/vendor/gopkg.in/sourcemap.v1/.travis.yml
@@ -0,0 +1,12 @@
+language: go
+
+go:
+ - 1.2
+ - 1.3
+ - 1.4
+ - 1.5
+
+install:
+ - mkdir -p $HOME/gopath/src/gopkg.in
+ - mv $HOME/gopath/src/github.com/go-sourcemap/sourcemap $HOME/gopath/src/gopkg.in/sourcemap.v1
+ - cd $HOME/gopath/src/gopkg.in/sourcemap.v1
diff --git a/vendor/gopkg.in/sourcemap.v1/LICENSE b/vendor/gopkg.in/sourcemap.v1/LICENSE
new file mode 100644
index 000000000..405d20f9c
--- /dev/null
+++ b/vendor/gopkg.in/sourcemap.v1/LICENSE
@@ -0,0 +1,25 @@
+Copyright (c) 2016 The github.com/go-sourcemap/sourcemap Contributors.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/vendor/gopkg.in/sourcemap.v1/Makefile b/vendor/gopkg.in/sourcemap.v1/Makefile
new file mode 100644
index 000000000..08381f928
--- /dev/null
+++ b/vendor/gopkg.in/sourcemap.v1/Makefile
@@ -0,0 +1,3 @@
+all:
+ go test ./... -test.v -test.cpu=1,2,4
+ go test ./... -test.v -test.short -test.race
diff --git a/vendor/gopkg.in/sourcemap.v1/README.md b/vendor/gopkg.in/sourcemap.v1/README.md
new file mode 100644
index 000000000..fb319d20f
--- /dev/null
+++ b/vendor/gopkg.in/sourcemap.v1/README.md
@@ -0,0 +1,35 @@
+# Source Maps consumer for Golang [![Build Status](https://travis-ci.org/go-sourcemap/sourcemap.svg?branch=v1)](https://travis-ci.org/go-sourcemap/sourcemap)
+
+## Installation
+
+Install:
+
+ go get gopkg.in/sourcemap.v1
+
+## Quickstart
+
+```go
+func ExampleParse() {
+ mapURL := "http://code.jquery.com/jquery-2.0.3.min.map"
+ resp, err := http.Get(mapURL)
+ if err != nil {
+ panic(err)
+ }
+ defer resp.Body.Close()
+
+ b, err := ioutil.ReadAll(resp.Body)
+ if err != nil {
+ panic(err)
+ }
+
+ smap, err := sourcemap.Parse(mapURL, b)
+ if err != nil {
+ panic(err)
+ }
+
+ line, column := 5, 6789
+ file, fn, line, col, ok := smap.Source(line, column)
+ fmt.Println(file, fn, line, col, ok)
+ // Output: http://code.jquery.com/jquery-2.0.3.js apply 4360 27 true
+}
+```
diff --git a/vendor/gopkg.in/sourcemap.v1/base64vlq/base64_vlq.go b/vendor/gopkg.in/sourcemap.v1/base64vlq/base64_vlq.go
new file mode 100644
index 000000000..598b40460
--- /dev/null
+++ b/vendor/gopkg.in/sourcemap.v1/base64vlq/base64_vlq.go
@@ -0,0 +1,95 @@
+package base64vlq
+
+import (
+ "io"
+)
+
+const encodeStd = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
+
+const (
+ vlqBaseShift = 5
+ vlqBase = 1 << vlqBaseShift
+ vlqBaseMask = vlqBase - 1
+ vlqSignBit = 1
+ vlqContinuationBit = vlqBase
+)
+
+var (
+ decodeMap [256]int
+)
+
+func init() {
+ for i := 0; i < len(encodeStd); i++ {
+ decodeMap[encodeStd[i]] = i
+ }
+}
+
+func toVLQSigned(n int) int {
+ if n < 0 {
+ return -n<<1 + 1
+ } else {
+ return n << 1
+ }
+}
+
+func fromVLQSigned(n int) int {
+ isNeg := n&vlqSignBit != 0
+ n >>= 1
+ if isNeg {
+ return -n
+ }
+ return n
+}
+
+type Encoder struct {
+ w io.ByteWriter
+}
+
+func NewEncoder(w io.ByteWriter) *Encoder {
+ return &Encoder{
+ w: w,
+ }
+}
+
+func (enc *Encoder) Encode(n int) error {
+ n = toVLQSigned(n)
+ for digit := vlqContinuationBit; digit&vlqContinuationBit != 0; {
+ digit = n & vlqBaseMask
+ n >>= vlqBaseShift
+ if n > 0 {
+ digit |= vlqContinuationBit
+ }
+ err := enc.w.WriteByte(encodeStd[digit])
+ if err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+type Decoder struct {
+ r io.ByteReader
+}
+
+func NewDecoder(r io.ByteReader) *Decoder {
+ return &Decoder{
+ r: r,
+ }
+}
+
+func (dec *Decoder) Decode() (n int, err error) {
+ shift := uint(0)
+ for continuation := true; continuation; {
+ c, err := dec.r.ReadByte()
+ if err != nil {
+ return 0, err
+ }
+
+ digit := decodeMap[c]
+ continuation = digit&vlqContinuationBit != 0
+ digit &= vlqBaseMask
+ n = n + digit<<shift
+ shift += vlqBaseShift
+ }
+ return fromVLQSigned(n), nil
+}
diff --git a/vendor/gopkg.in/sourcemap.v1/consumer.go b/vendor/gopkg.in/sourcemap.v1/consumer.go
new file mode 100644
index 000000000..b66761a6c
--- /dev/null
+++ b/vendor/gopkg.in/sourcemap.v1/consumer.go
@@ -0,0 +1,312 @@
+package sourcemap // import "gopkg.in/sourcemap.v1"
+
+import (
+ "encoding/json"
+ "errors"
+ "fmt"
+ "io"
+ "net/url"
+ "path"
+ "sort"
+ "strconv"
+ "strings"
+
+ "gopkg.in/sourcemap.v1/base64vlq"
+)
+
+type Consumer struct {
+ sourceRootURL *url.URL
+ smap *sourceMap
+ mappings []mapping
+}
+
+func Parse(mapURL string, b []byte) (*Consumer, error) {
+ smap := new(sourceMap)
+ err := json.Unmarshal(b, smap)
+ if err != nil {
+ return nil, err
+ }
+
+ if smap.Version != 3 {
+ return nil, errors.New("sourcemap: only 3rd version is supported")
+ }
+
+ var sourceRootURL *url.URL
+ if smap.SourceRoot != "" {
+ u, err := url.Parse(smap.SourceRoot)
+ if err != nil {
+ return nil, err
+ }
+ if u.IsAbs() {
+ sourceRootURL = u
+ }
+ } else if mapURL != "" {
+ u, err := url.Parse(mapURL)
+ if err != nil {
+ return nil, err
+ }
+ if u.IsAbs() {
+ u.Path = path.Dir(u.Path)
+ sourceRootURL = u
+ }
+ }
+
+ mappings, err := parseMappings(smap.Mappings)
+ if err != nil {
+ return nil, err
+ }
+ // Free memory.
+ smap.Mappings = ""
+
+ return &Consumer{
+ sourceRootURL: sourceRootURL,
+ smap: smap,
+ mappings: mappings,
+ }, nil
+}
+
+func (c *Consumer) File() string {
+ return c.smap.File
+}
+
+func (c *Consumer) Source(genLine, genCol int) (source, name string, line, col int, ok bool) {
+ i := sort.Search(len(c.mappings), func(i int) bool {
+ m := &c.mappings[i]
+ if m.genLine == genLine {
+ return m.genCol >= genCol
+ }
+ return m.genLine >= genLine
+ })
+
+ // Mapping not found.
+ if i == len(c.mappings) {
+ return
+ }
+
+ match := &c.mappings[i]
+
+ // Fuzzy match.
+ if match.genCol > genCol && i > 0 {
+ match = &c.mappings[i-1]
+ }
+
+ if match.sourcesInd >= 0 {
+ source = c.absSource(c.smap.Sources[match.sourcesInd])
+ }
+ if match.namesInd >= 0 {
+ iv := c.smap.Names[match.namesInd]
+ switch v := iv.(type) {
+ case string:
+ name = v
+ case float64:
+ name = strconv.FormatFloat(v, 'f', -1, 64)
+ default:
+ name = fmt.Sprint(iv)
+ }
+ }
+ line = match.sourceLine
+ col = match.sourceCol
+ ok = true
+ return
+}
+
+func (c *Consumer) absSource(source string) string {
+ if path.IsAbs(source) {
+ return source
+ }
+
+ if u, err := url.Parse(source); err == nil && u.IsAbs() {
+ return source
+ }
+
+ if c.sourceRootURL != nil {
+ u := *c.sourceRootURL
+ u.Path = path.Join(c.sourceRootURL.Path, source)
+ return u.String()
+ }
+
+ if c.smap.SourceRoot != "" {
+ return path.Join(c.smap.SourceRoot, source)
+ }
+
+ return source
+}
+
+func (c *Consumer) SourceName(genLine, genCol int, genName string) (name string, ok bool) {
+ ind := sort.Search(len(c.mappings), func(i int) bool {
+ m := c.mappings[i]
+ if m.genLine == genLine {
+ return m.genCol >= genCol
+ }
+ return m.genLine >= genLine
+ })
+
+ // Mapping not found.
+ if ind == len(c.mappings) {
+ return "", false
+ }
+
+ for i := ind; i >= 0; i-- {
+ m := c.mappings[i]
+ if m.namesInd == -1 {
+ continue
+ }
+ if c.smap.Names[m.namesInd] == "" {
+
+ }
+ }
+
+ return
+}
+
+type fn func() (fn, error)
+
+type sourceMap struct {
+ Version int `json:"version"`
+ File string `json:"file"`
+ SourceRoot string `json:"sourceRoot"`
+ Sources []string `json:"sources"`
+ Names []interface{} `json:"names"`
+ Mappings string `json:"mappings"`
+}
+
+type mapping struct {
+ genLine int
+ genCol int
+ sourcesInd int
+ sourceLine int
+ sourceCol int
+ namesInd int
+}
+
+type mappings struct {
+ rd *strings.Reader
+ dec *base64vlq.Decoder
+
+ genLine int
+ genCol int
+ sourcesInd int
+ sourceLine int
+ sourceCol int
+ namesInd int
+
+ value mapping
+ values []mapping
+}
+
+func parseMappings(s string) ([]mapping, error) {
+ rd := strings.NewReader(s)
+ m := &mappings{
+ rd: rd,
+ dec: base64vlq.NewDecoder(rd),
+
+ genLine: 1,
+ sourceLine: 1,
+ }
+ m.zeroValue()
+ err := m.parse()
+ if err != nil {
+ return nil, err
+ }
+ return m.values, nil
+}
+
+func (m *mappings) parse() error {
+ next := m.parseGenCol
+ for {
+ c, err := m.rd.ReadByte()
+ if err == io.EOF {
+ m.pushValue()
+ return nil
+ } else if err != nil {
+ return err
+ }
+
+ switch c {
+ case ',':
+ m.pushValue()
+ next = m.parseGenCol
+ case ';':
+ m.pushValue()
+
+ m.genLine++
+ m.genCol = 0
+
+ next = m.parseGenCol
+ default:
+ m.rd.UnreadByte()
+
+ var err error
+ next, err = next()
+ if err != nil {
+ return err
+ }
+ }
+ }
+}
+
+func (m *mappings) parseGenCol() (fn, error) {
+ n, err := m.dec.Decode()
+ if err != nil {
+ return nil, err
+ }
+ m.genCol += n
+ m.value.genCol = m.genCol
+ return m.parseSourcesInd, nil
+}
+
+func (m *mappings) parseSourcesInd() (fn, error) {
+ n, err := m.dec.Decode()
+ if err != nil {
+ return nil, err
+ }
+ m.sourcesInd += n
+ m.value.sourcesInd = m.sourcesInd
+ return m.parseSourceLine, nil
+}
+
+func (m *mappings) parseSourceLine() (fn, error) {
+ n, err := m.dec.Decode()
+ if err != nil {
+ return nil, err
+ }
+ m.sourceLine += n
+ m.value.sourceLine = m.sourceLine
+ return m.parseSourceCol, nil
+}
+
+func (m *mappings) parseSourceCol() (fn, error) {
+ n, err := m.dec.Decode()
+ if err != nil {
+ return nil, err
+ }
+ m.sourceCol += n
+ m.value.sourceCol = m.sourceCol
+ return m.parseNamesInd, nil
+}
+
+func (m *mappings) parseNamesInd() (fn, error) {
+ n, err := m.dec.Decode()
+ if err != nil {
+ return nil, err
+ }
+ m.namesInd += n
+ m.value.namesInd = m.namesInd
+ return m.parseGenCol, nil
+}
+
+func (m *mappings) zeroValue() {
+ m.value = mapping{
+ genLine: m.genLine,
+ genCol: 0,
+ sourcesInd: -1,
+ sourceLine: 0,
+ sourceCol: 0,
+ namesInd: -1,
+ }
+}
+
+func (m *mappings) pushValue() {
+ m.values = append(m.values, m.value)
+ m.zeroValue()
+}