snapshot of https://github.com/cortezaproject/corteza.git (2024.9.x, 2026-09-18; blobs > 131072B omitted)
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s

This commit is contained in:
upstream-mirror
2026-09-18 01:22:23 +05:00
commit 7e385fc126
8391 changed files with 1766236 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
sudo: false
language: go
go:
- 1.12.x
- 1.13.x
- 1.14.x
- tip
matrix:
allow_failures:
- go: tip

View File

@@ -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.

View File

@@ -0,0 +1,4 @@
all:
go test ./...
go test ./... -short -race
go vet

View File

@@ -0,0 +1,43 @@
# Source maps consumer for Golang
[![Build Status](https://travis-ci.org/go-sourcemap/sourcemap.svg)](https://travis-ci.org/go-sourcemap/sourcemap)
API docs: https://godoc.org/github.com/go-sourcemap/sourcemap.
Examples: https://godoc.org/github.com/go-sourcemap/sourcemap#pkg-examples.
Spec: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit.
## Installation
Install:
```shell
go get -u github.com/go-sourcemap/sourcemap
```
## 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
}
```

View File

@@ -0,0 +1,253 @@
package sourcemap
import (
"encoding/json"
"fmt"
"net/url"
"path"
"sort"
)
type sourceMap struct {
Version int `json:"version"`
File string `json:"file"`
SourceRoot string `json:"sourceRoot"`
Sources []string `json:"sources"`
SourcesContent []string `json:"sourcesContent"`
Names []json.RawMessage `json:"names,string"`
Mappings string `json:"mappings"`
mappings []mapping
}
type v3 struct {
sourceMap
Sections []section `json:"sections"`
}
func (m *sourceMap) parse(sourcemapURL string) error {
if err := checkVersion(m.Version); err != nil {
return err
}
var sourceRootURL *url.URL
if m.SourceRoot != "" {
u, err := url.Parse(m.SourceRoot)
if err != nil {
return err
}
if u.IsAbs() {
sourceRootURL = u
}
} else if sourcemapURL != "" {
u, err := url.Parse(sourcemapURL)
if err != nil {
return err
}
if u.IsAbs() {
u.Path = path.Dir(u.Path)
sourceRootURL = u
}
}
for i, src := range m.Sources {
m.Sources[i] = m.absSource(sourceRootURL, src)
}
mappings, err := parseMappings(m.Mappings)
if err != nil {
return err
}
m.mappings = mappings
// Free memory.
m.Mappings = ""
return nil
}
func (m *sourceMap) absSource(root *url.URL, source string) string {
if path.IsAbs(source) {
return source
}
if u, err := url.Parse(source); err == nil && u.IsAbs() {
return source
}
if root != nil {
u := *root
u.Path = path.Join(u.Path, source)
return u.String()
}
if m.SourceRoot != "" {
return path.Join(m.SourceRoot, source)
}
return source
}
func (m *sourceMap) name(idx int) string {
if idx >= len(m.Names) {
return ""
}
raw := m.Names[idx]
if len(raw) == 0 {
return ""
}
if raw[0] == '"' && raw[len(raw)-1] == '"' {
var str string
if err := json.Unmarshal(raw, &str); err == nil {
return str
}
}
return string(raw)
}
type section struct {
Offset struct {
Line int `json:"line"`
Column int `json:"column"`
} `json:"offset"`
Map *sourceMap `json:"map"`
}
type Consumer struct {
sourcemapURL string
file string
sections []section
}
func Parse(sourcemapURL string, b []byte) (*Consumer, error) {
v3 := new(v3)
err := json.Unmarshal(b, v3)
if err != nil {
return nil, err
}
if err := checkVersion(v3.Version); err != nil {
return nil, err
}
if len(v3.Sections) == 0 {
v3.Sections = append(v3.Sections, section{
Map: &v3.sourceMap,
})
}
for _, s := range v3.Sections {
err := s.Map.parse(sourcemapURL)
if err != nil {
return nil, err
}
}
reverse(v3.Sections)
return &Consumer{
sourcemapURL: sourcemapURL,
file: v3.File,
sections: v3.Sections,
}, nil
}
func (c *Consumer) SourcemapURL() string {
return c.sourcemapURL
}
// File returns an optional name of the generated code
// that this source map is associated with.
func (c *Consumer) File() string {
return c.file
}
// Source returns the original source, name, line, and column information
// for the generated source's line and column positions.
func (c *Consumer) Source(
genLine, genColumn int,
) (source, name string, line, column int, ok bool) {
for i := range c.sections {
s := &c.sections[i]
if s.Offset.Line < genLine ||
(s.Offset.Line+1 == genLine && s.Offset.Column <= genColumn) {
genLine -= s.Offset.Line
genColumn -= s.Offset.Column
return c.source(s.Map, genLine, genColumn)
}
}
return
}
func (c *Consumer) source(
m *sourceMap, genLine, genColumn int,
) (source, name string, line, column int, ok bool) {
i := sort.Search(len(m.mappings), func(i int) bool {
m := &m.mappings[i]
if int(m.genLine) == genLine {
return int(m.genColumn) >= genColumn
}
return int(m.genLine) >= genLine
})
// Mapping not found.
if i == len(m.mappings) {
return
}
match := &m.mappings[i]
// Fuzzy match.
if int(match.genLine) > genLine || int(match.genColumn) > genColumn {
if i == 0 {
return
}
match = &m.mappings[i-1]
}
if match.sourcesInd >= 0 {
source = m.Sources[match.sourcesInd]
}
if match.namesInd >= 0 {
name = m.name(int(match.namesInd))
}
line = int(match.sourceLine)
column = int(match.sourceColumn)
ok = true
return
}
// SourceContent returns the original source content for the source.
func (c *Consumer) SourceContent(source string) string {
for i := range c.sections {
s := &c.sections[i]
for i, src := range s.Map.Sources {
if src == source {
if i < len(s.Map.SourcesContent) {
return s.Map.SourcesContent[i]
}
break
}
}
}
return ""
}
func checkVersion(version int) error {
if version == 3 || version == 0 {
return nil
}
return fmt.Errorf(
"sourcemap: got version=%d, but only 3rd version is supported",
version,
)
}
func reverse(ss []section) {
last := len(ss) - 1
for i := 0; i < len(ss)/2; i++ {
ss[i], ss[last-i] = ss[last-i], ss[i]
}
}

View File

@@ -0,0 +1,90 @@
package base64vlq
import "io"
const encodeStd = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
const (
vlqBaseShift = 5
vlqBase = 1 << vlqBaseShift
vlqBaseMask = vlqBase - 1
vlqSignBit = 1
vlqContinuationBit = vlqBase
)
var decodeMap [256]byte
func init() {
for i := 0; i < len(encodeStd); i++ {
decodeMap[encodeStd[i]] = byte(i)
}
}
func toVLQSigned(n int32) int32 {
if n < 0 {
return -n<<1 + 1
}
return n << 1
}
func fromVLQSigned(n int32) int32 {
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 int32) error {
n = toVLQSigned(n)
for digit := int32(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 int32, err error) {
shift := uint(0)
for continuation := true; continuation; {
c, err := dec.r.ReadByte()
if err != nil {
return 0, err
}
c = decodeMap[c]
continuation = c&vlqContinuationBit != 0
n += int32(c&vlqBaseMask) << shift
shift += vlqBaseShift
}
return fromVLQSigned(n), nil
}

View File

@@ -0,0 +1,162 @@
package sourcemap
import (
"errors"
"io"
"strings"
"github.com/go-sourcemap/sourcemap/internal/base64vlq"
)
type fn func(m *mappings) (fn, error)
type mapping struct {
genLine int32
genColumn int32
sourcesInd int32
sourceLine int32
sourceColumn int32
namesInd int32
}
type mappings struct {
rd *strings.Reader
dec base64vlq.Decoder
hasName bool
value mapping
values []mapping
}
func parseMappings(s string) ([]mapping, error) {
if s == "" {
return nil, errors.New("sourcemap: mappings are empty")
}
rd := strings.NewReader(s)
m := &mappings{
rd: rd,
dec: base64vlq.NewDecoder(rd),
values: make([]mapping, 0, mappingsNumber(s)),
}
m.value.genLine = 1
m.value.sourceLine = 1
err := m.parse()
if err != nil {
return nil, err
}
values := m.values
m.values = nil
return values, nil
}
func mappingsNumber(s string) int {
return strings.Count(s, ",") + strings.Count(s, ";")
}
func (m *mappings) parse() error {
next := parseGenCol
for {
c, err := m.rd.ReadByte()
if err == io.EOF {
m.pushValue()
return nil
}
if err != nil {
return err
}
switch c {
case ',':
m.pushValue()
next = parseGenCol
case ';':
m.pushValue()
m.value.genLine++
m.value.genColumn = 0
next = parseGenCol
default:
err := m.rd.UnreadByte()
if err != nil {
return err
}
next, err = next(m)
if err != nil {
return err
}
}
}
}
func parseGenCol(m *mappings) (fn, error) {
n, err := m.dec.Decode()
if err != nil {
return nil, err
}
m.value.genColumn += n
return parseSourcesInd, nil
}
func parseSourcesInd(m *mappings) (fn, error) {
n, err := m.dec.Decode()
if err != nil {
return nil, err
}
m.value.sourcesInd += n
return parseSourceLine, nil
}
func parseSourceLine(m *mappings) (fn, error) {
n, err := m.dec.Decode()
if err != nil {
return nil, err
}
m.value.sourceLine += n
return parseSourceCol, nil
}
func parseSourceCol(m *mappings) (fn, error) {
n, err := m.dec.Decode()
if err != nil {
return nil, err
}
m.value.sourceColumn += n
return parseNamesInd, nil
}
func parseNamesInd(m *mappings) (fn, error) {
n, err := m.dec.Decode()
if err != nil {
return nil, err
}
m.hasName = true
m.value.namesInd += n
return parseGenCol, nil
}
func (m *mappings) pushValue() {
if m.value.sourceLine == 1 && m.value.sourceColumn == 0 {
return
}
if m.hasName {
m.values = append(m.values, m.value)
m.hasName = false
} else {
m.values = append(m.values, mapping{
genLine: m.value.genLine,
genColumn: m.value.genColumn,
sourcesInd: m.value.sourcesInd,
sourceLine: m.value.sourceLine,
sourceColumn: m.value.sourceColumn,
namesInd: -1,
})
}
}