Socket
Socket
Sign inDemoInstall

@jridgewell/sourcemap-codec

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jridgewell/sourcemap-codec - npm Package Compare versions

Comparing version 1.4.16-beta.0 to 1.5.0

dist/types/strings.d.ts

577

dist/sourcemap-codec.umd.js

@@ -7,2 +7,4 @@ (function (global, factory) {

const comma = ','.charCodeAt(0);
const semicolon = ';'.charCodeAt(0);
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';

@@ -16,28 +18,3 @@ const intToChar = new Uint8Array(64); // 64 possible chars.

}
const comma = ','.charCodeAt(0);
const semicolon = ';'.charCodeAt(0);
function hasMoreVlq(mappings, i, length) {
if (i >= length)
return false;
return mappings.charCodeAt(i) !== comma;
}
function indexOf(mappings, char, index) {
const idx = mappings.indexOf(char, index);
return idx === -1 ? mappings.length : idx;
}
let posOut = 0;
function resetPos() {
posOut = 0;
}
function decodeFirstOctet(mappings, pos) {
const c = mappings.charCodeAt(pos);
let value = charToInt[c];
const shouldNegate = value & 1;
value >>>= 1;
if (shouldNegate) {
value = -0x80000000 | -value;
}
return value;
}
function decodeInteger(mappings, pos, relative) {
function decodeInteger(reader, relative) {
let value = 0;

@@ -47,3 +24,3 @@ let shift = 0;

do {
const c = mappings.charCodeAt(pos++);
const c = reader.next();
integer = charToInt[c];

@@ -58,6 +35,5 @@ value |= (integer & 31) << shift;

}
posOut = pos;
return relative + value;
}
function encodeInteger(buf, pos, num, relative) {
function encodeInteger(builder, num, relative) {
let delta = num - relative;

@@ -70,21 +46,13 @@ delta = delta < 0 ? (-delta << 1) | 1 : delta << 1;

clamped |= 0b100000;
buf[pos++] = intToChar[clamped];
builder.write(intToChar[clamped]);
} while (delta > 0);
posOut = pos;
return num;
}
function maybeFlush(build, buf, pos, copy, length) {
if (pos < length) {
posOut = pos;
return build;
}
const out = td.decode(buf);
copy.copyWithin(0, length, pos);
posOut = pos - length;
return build + out;
function hasMoreVlq(reader, max) {
if (reader.pos >= max)
return false;
return reader.peek() !== comma;
}
function write(buf, pos, value) {
buf[pos] = value;
posOut = pos + 1;
}
const bufLength = 1024 * 16;
// Provide a fallback for older environments.

@@ -109,13 +77,50 @@ const td = typeof TextDecoder !== 'undefined'

};
class StringWriter {
constructor() {
this.pos = 0;
this.out = '';
this.buffer = new Uint8Array(bufLength);
}
write(v) {
const { buffer } = this;
buffer[this.pos++] = v;
if (this.pos === bufLength) {
this.out += td.decode(buffer);
this.pos = 0;
}
}
flush() {
const { buffer, out, pos } = this;
return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
}
}
class StringReader {
constructor(buffer) {
this.pos = 0;
this.buffer = buffer;
}
next() {
return this.buffer.charCodeAt(this.pos++);
}
peek() {
return this.buffer.charCodeAt(this.pos);
}
indexOf(char) {
const { buffer, pos } = this;
const idx = buffer.indexOf(char, pos);
return idx === -1 ? buffer.length : idx;
}
}
const NO_NAME = -1;
const NO_SOURCE = -1;
const EMPTY = [];
function decodeOriginalScopes(input) {
let line = 0;
const { length } = input;
const reader = new StringReader(input);
const scopes = [];
const stack = [];
for (let i = 0; i < input.length; i = posOut + 1) {
line = decodeInteger(input, i, line);
const column = decodeInteger(input, posOut, 0);
if (!hasMoreVlq(input, posOut, input.length)) {
let line = 0;
for (; reader.pos < length; reader.pos++) {
line = decodeInteger(reader, line);
const column = decodeInteger(reader, 0);
if (!hasMoreVlq(reader, length)) {
const last = stack.pop();

@@ -126,17 +131,17 @@ last[2] = line;

}
const kind = decodeInteger(input, posOut, 0);
const fields = decodeInteger(input, posOut, 0);
const name = fields & 0b0001 ? decodeInteger(input, posOut, 0) : NO_NAME;
const scope = name === NO_NAME ? [line, column, 0, 0, kind] : [line, column, 0, 0, kind, name];
const kind = decodeInteger(reader, 0);
const fields = decodeInteger(reader, 0);
const hasName = fields & 0b0001;
const scope = (hasName ? [line, column, 0, 0, kind, decodeInteger(reader, 0)] : [line, column, 0, 0, kind]);
let vars = EMPTY;
if (hasMoreVlq(reader, length)) {
vars = [];
do {
const varsIndex = decodeInteger(reader, 0);
vars.push(varsIndex);
} while (hasMoreVlq(reader, length));
}
scope.vars = vars;
scopes.push(scope);
stack.push(scope);
const index = indexOf(input, ',', posOut);
if (posOut < index) {
const vars = [];
scope.vars = vars;
while (posOut < index) {
const varsIndex = decodeInteger(input, posOut, 0);
vars.push(varsIndex);
}
}
}

@@ -146,59 +151,42 @@ return scopes;

function encodeOriginalScopes(scopes) {
let out = '';
if (scopes.length === 0)
return out;
const bufLength = 1024 * 16;
const subLength = bufLength - (7 * 6 + 1);
const buf = new Uint8Array(bufLength);
const sub = buf.subarray(0, subLength);
resetPos();
const endStack = [];
let lastEndLine = scopes[0][2] + 1;
let lastEndColumn = scopes[0][3];
let line = 0;
for (let i = 0; i < scopes.length; i++) {
const scope = scopes[i];
const { 0: startLine, 1: startColumn, 2: endLine, 3: endColumn, 4: kind } = scope;
const name = scope.length === 6 ? scope[5] : NO_NAME;
const vars = 'vars' in scope ? scope.vars : [];
out = maybeFlush(out, buf, posOut, buf, bufLength);
if (i > 0)
write(buf, posOut, comma);
while (startLine > lastEndLine || (startLine === lastEndLine && startColumn >= lastEndColumn)) {
out = maybeFlush(out, sub, posOut, buf, subLength);
line = encodeInteger(buf, posOut, lastEndLine, line);
encodeInteger(buf, posOut, lastEndColumn, 0);
write(buf, posOut, comma);
lastEndColumn = endStack.pop();
lastEndLine = endStack.pop();
const writer = new StringWriter();
for (let i = 0; i < scopes.length;) {
i = _encodeOriginalScopes(scopes, i, writer, [0]);
}
return writer.flush();
}
function _encodeOriginalScopes(scopes, index, writer, state) {
const scope = scopes[index];
const { 0: startLine, 1: startColumn, 2: endLine, 3: endColumn, 4: kind, vars } = scope;
if (index > 0)
writer.write(comma);
state[0] = encodeInteger(writer, startLine, state[0]);
encodeInteger(writer, startColumn, 0);
encodeInteger(writer, kind, 0);
const fields = scope.length === 6 ? 0b0001 : 0;
encodeInteger(writer, fields, 0);
if (scope.length === 6)
encodeInteger(writer, scope[5], 0);
for (const v of vars) {
encodeInteger(writer, v, 0);
}
for (index++; index < scopes.length;) {
const next = scopes[index];
const { 0: l, 1: c } = next;
if (l > endLine || (l === endLine && c >= endColumn)) {
break;
}
line = encodeInteger(buf, posOut, startLine, line);
encodeInteger(buf, posOut, startColumn, 0);
endStack.push(lastEndLine);
endStack.push(lastEndColumn);
lastEndLine = endLine;
lastEndColumn = endColumn;
encodeInteger(buf, posOut, kind, 0);
const fields = name === NO_NAME ? 0 : 1;
encodeInteger(buf, posOut, fields, 0);
if (name !== NO_NAME)
encodeInteger(buf, posOut, name, 0);
for (const v of vars) {
out = maybeFlush(out, sub, posOut, buf, subLength);
encodeInteger(buf, posOut, v, 0);
}
index = _encodeOriginalScopes(scopes, index, writer, state);
}
while (endStack.length > 0) {
out = maybeFlush(out, sub, posOut, buf, subLength);
write(buf, posOut, comma);
line = encodeInteger(buf, posOut, lastEndLine, line);
encodeInteger(buf, posOut, lastEndColumn, 0);
lastEndColumn = endStack.pop();
lastEndLine = endStack.pop();
}
return out + td.decode(buf.subarray(0, posOut));
writer.write(comma);
state[0] = encodeInteger(writer, endLine, state[0]);
encodeInteger(writer, endColumn, 0);
return index;
}
function decodeGeneratedRanges(input) {
const { length } = input;
const reader = new StringReader(input);
const ranges = [];
const stack = [];
let genLine = 0;
let genColumn = 0;
let definitionSourcesIndex = 0;

@@ -211,195 +199,160 @@ let definitionScopeIndex = 0;

let bindingColumn = 0;
const ranges = [];
const stack = [];
let index = 0;
do {
const semi = indexOf(input, ';', index);
genColumn = 0;
for (let i = index; i < semi; i = posOut + 1) {
genColumn = decodeInteger(input, i, genColumn);
if (hasMoreVlq(input, posOut, semi)) {
const fields = decodeInteger(input, posOut, 0);
let defSourcesIndex = NO_SOURCE;
let defScopeIndex = NO_SOURCE;
if (fields & 0b0001) {
defSourcesIndex = decodeInteger(input, posOut, definitionSourcesIndex);
if (definitionSourcesIndex !== defSourcesIndex) {
definitionScopeIndex = 0;
definitionSourcesIndex = defSourcesIndex;
}
defScopeIndex = definitionScopeIndex = decodeInteger(input, posOut, definitionScopeIndex);
}
const range = [genLine, genColumn, 0, 0, defSourcesIndex, defScopeIndex];
if (fields & 0b0010) {
const callSourcesIndex = decodeInteger(input, posOut, callsiteSourcesIndex);
const sameSource = callSourcesIndex === callsiteSourcesIndex;
const callLine = decodeInteger(input, posOut, sameSource ? callsiteLine : 0);
const sameLine = sameSource && callLine === callsiteLine;
callsiteColumn = decodeInteger(input, posOut, sameLine ? callsiteColumn : 0);
callsiteSourcesIndex = callSourcesIndex;
callsiteLine = callLine;
range.callsite = [callsiteSourcesIndex, callsiteLine, callsiteColumn];
}
if (fields & 0b0100) {
range.isScope = true;
}
if (hasMoreVlq(input, posOut, semi)) {
const bindings = [];
range.bindings = bindings;
do {
bindingLine = genLine;
bindingColumn = genColumn;
let name = decodeInteger(input, posOut, 0);
const hasExpressions = decodeFirstOctet(input, posOut);
const binding = [[name]];
bindings.push(binding);
if (hasExpressions < -1) {
const expressionsCount = decodeInteger(input, posOut, 0);
for (let i = -1; i > expressionsCount; i--) {
const prevBindingLine = bindingLine;
bindingLine = decodeInteger(input, posOut, bindingLine);
bindingColumn = decodeInteger(input, posOut, bindingLine === prevBindingLine ? bindingColumn : 0);
name = decodeInteger(input, posOut, 0);
}
binding.push([name, bindingLine, bindingColumn]);
}
} while (hasMoreVlq(input, posOut, semi));
}
ranges.push(range);
stack.push(range);
const semi = reader.indexOf(';');
let genColumn = 0;
for (; reader.pos < semi; reader.pos++) {
genColumn = decodeInteger(reader, genColumn);
if (!hasMoreVlq(reader, semi)) {
const last = stack.pop();
last[2] = genLine;
last[3] = genColumn;
continue;
}
const fields = decodeInteger(reader, 0);
const hasDefinition = fields & 0b0001;
const hasCallsite = fields & 0b0010;
const hasScope = fields & 0b0100;
let callsite = null;
let bindings = EMPTY;
let range;
if (hasDefinition) {
const defSourcesIndex = decodeInteger(reader, definitionSourcesIndex);
definitionScopeIndex = decodeInteger(reader, definitionSourcesIndex === defSourcesIndex ? definitionScopeIndex : 0);
definitionSourcesIndex = defSourcesIndex;
range = [genLine, genColumn, 0, 0, defSourcesIndex, definitionScopeIndex];
}
else {
const range = stack.pop();
range[2] = genLine;
range[3] = genColumn;
range = [genLine, genColumn, 0, 0];
}
range.isScope = !!hasScope;
if (hasCallsite) {
const prevCsi = callsiteSourcesIndex;
const prevLine = callsiteLine;
callsiteSourcesIndex = decodeInteger(reader, callsiteSourcesIndex);
const sameSource = prevCsi === callsiteSourcesIndex;
callsiteLine = decodeInteger(reader, sameSource ? callsiteLine : 0);
callsiteColumn = decodeInteger(reader, sameSource && prevLine === callsiteLine ? callsiteColumn : 0);
callsite = [callsiteSourcesIndex, callsiteLine, callsiteColumn];
}
range.callsite = callsite;
if (hasMoreVlq(reader, semi)) {
bindings = [];
do {
bindingLine = genLine;
bindingColumn = genColumn;
const expressionsCount = decodeInteger(reader, 0);
let expressionRanges;
if (expressionsCount < -1) {
expressionRanges = [[decodeInteger(reader, 0)]];
for (let i = -1; i > expressionsCount; i--) {
const prevBl = bindingLine;
bindingLine = decodeInteger(reader, bindingLine);
bindingColumn = decodeInteger(reader, bindingLine === prevBl ? bindingColumn : 0);
const expression = decodeInteger(reader, 0);
expressionRanges.push([expression, bindingLine, bindingColumn]);
}
}
else {
expressionRanges = [[expressionsCount]];
}
bindings.push(expressionRanges);
} while (hasMoreVlq(reader, semi));
}
range.bindings = bindings;
ranges.push(range);
stack.push(range);
}
genLine++;
index = semi + 1;
} while (index <= input.length);
reader.pos = semi + 1;
} while (reader.pos < length);
return ranges;
}
function encodeGeneratedRanges(ranges) {
let out = '';
if (ranges.length === 0)
return out;
const bufLength = 1024 * 16;
const subLength = bufLength - (7 * 7 + 1);
const buf = new Uint8Array(bufLength);
const sub = buf.subarray(0, subLength);
resetPos();
const endStack = [];
let lastEndLine = ranges[0][2] + 1;
let lastEndColumn = ranges[0][3];
let line = 0;
let genColumn = 0;
let definitionSourcesIndex = 0;
let definitionScopeIndex = 0;
let callsiteSourcesIndex = 0;
let callsiteLine = 0;
let callsiteColumn = 0;
for (let i = 0; i < ranges.length; i++) {
const range = ranges[i];
const { 0: startLine, 1: startColumn, 2: endLine, 3: endColumn, 4: defSourcesIndex, 5: defScopeIndex, } = range;
const isScope = 'isScope' in range && range.isScope;
const hasCallsite = 'callsite' in range;
const hasBindings = 'bindings' in range;
while (startLine > lastEndLine || (startLine === lastEndLine && startColumn >= lastEndColumn)) {
if (line < lastEndLine) {
out = catchupLine(out, buf, bufLength, line, lastEndLine);
line = lastEndLine;
genColumn = 0;
}
else {
out = maybeFlush(out, buf, posOut, buf, bufLength);
write(buf, posOut, comma);
}
out = maybeFlush(out, sub, posOut, buf, subLength);
genColumn = encodeInteger(buf, posOut, lastEndColumn, genColumn);
lastEndColumn = endStack.pop();
lastEndLine = endStack.pop();
return '';
const writer = new StringWriter();
for (let i = 0; i < ranges.length;) {
i = _encodeGeneratedRanges(ranges, i, writer, [0, 0, 0, 0, 0, 0, 0]);
}
return writer.flush();
}
function _encodeGeneratedRanges(ranges, index, writer, state) {
const range = ranges[index];
const { 0: startLine, 1: startColumn, 2: endLine, 3: endColumn, isScope, callsite, bindings, } = range;
if (state[0] < startLine) {
catchupLine(writer, state[0], startLine);
state[0] = startLine;
state[1] = 0;
}
else if (index > 0) {
writer.write(comma);
}
state[1] = encodeInteger(writer, range[1], state[1]);
const fields = (range.length === 6 ? 0b0001 : 0) | (callsite ? 0b0010 : 0) | (isScope ? 0b0100 : 0);
encodeInteger(writer, fields, 0);
if (range.length === 6) {
const { 4: sourcesIndex, 5: scopesIndex } = range;
if (sourcesIndex !== state[2]) {
state[3] = 0;
}
if (line < startLine) {
out = catchupLine(out, buf, bufLength, line, startLine);
line = startLine;
genColumn = 0;
state[2] = encodeInteger(writer, sourcesIndex, state[2]);
state[3] = encodeInteger(writer, scopesIndex, state[3]);
}
if (callsite) {
const { 0: sourcesIndex, 1: callLine, 2: callColumn } = range.callsite;
if (sourcesIndex !== state[4]) {
state[5] = 0;
state[6] = 0;
}
else if (i > 0) {
out = maybeFlush(out, buf, posOut, buf, bufLength);
write(buf, posOut, comma);
else if (callLine !== state[5]) {
state[6] = 0;
}
out = maybeFlush(out, sub, posOut, buf, subLength);
genColumn = encodeInteger(buf, posOut, range[1], genColumn);
endStack.push(lastEndLine);
endStack.push(lastEndColumn);
lastEndLine = endLine;
lastEndColumn = endColumn;
const fields = (defSourcesIndex === NO_SOURCE ? 0 : 0b0001) |
(hasCallsite ? 0b0010 : 0) |
(isScope ? 0b0100 : 0);
encodeInteger(buf, posOut, fields, 0);
if (defSourcesIndex !== NO_SOURCE) {
if (defSourcesIndex !== definitionSourcesIndex)
definitionScopeIndex = 0;
definitionSourcesIndex = encodeInteger(buf, posOut, defSourcesIndex, definitionSourcesIndex);
definitionScopeIndex = encodeInteger(buf, posOut, defScopeIndex, definitionScopeIndex);
}
if (hasCallsite) {
const { 0: callSourcesIndex, 1: callLine, 2: callColumn } = range.callsite;
if (callSourcesIndex !== callsiteSourcesIndex) {
callsiteLine = 0;
callsiteColumn = 0;
state[4] = encodeInteger(writer, sourcesIndex, state[4]);
state[5] = encodeInteger(writer, callLine, state[5]);
state[6] = encodeInteger(writer, callColumn, state[6]);
}
if (bindings) {
for (const binding of bindings) {
if (binding.length > 1)
encodeInteger(writer, -binding.length, 0);
const expression = binding[0][0];
encodeInteger(writer, expression, 0);
let bindingStartLine = startLine;
let bindingStartColumn = startColumn;
for (let i = 1; i < binding.length; i++) {
const expRange = binding[i];
bindingStartLine = encodeInteger(writer, expRange[1], bindingStartLine);
bindingStartColumn = encodeInteger(writer, expRange[2], bindingStartColumn);
encodeInteger(writer, expRange[0], 0);
}
else if (callLine !== callsiteLine) {
callsiteColumn = 0;
}
callsiteSourcesIndex = encodeInteger(buf, posOut, callSourcesIndex, callsiteSourcesIndex);
callsiteLine = encodeInteger(buf, posOut, callLine, callsiteLine);
callsiteColumn = encodeInteger(buf, posOut, callColumn, callsiteColumn);
}
if (hasBindings) {
for (const binding of range.bindings) {
out = maybeFlush(out, sub, posOut, buf, subLength);
encodeInteger(buf, posOut, binding[0][0], 0);
if (binding.length > 1) {
encodeInteger(buf, posOut, -binding.length, 0);
let bindingStartLine = startLine;
let bindingStartColumn = startColumn;
for (let i = 1; i < binding.length; i++) {
out = maybeFlush(out, sub, posOut, buf, subLength);
const expression = binding[i];
bindingStartLine = encodeInteger(buf, posOut, expression[1], bindingStartLine);
bindingStartColumn = encodeInteger(buf, posOut, expression[2], bindingStartColumn);
encodeInteger(buf, posOut, expression[0], 0);
}
}
}
}
}
while (endStack.length > 0) {
if (line < lastEndLine) {
out = catchupLine(out, buf, bufLength, line, lastEndLine);
line = lastEndLine;
genColumn = 0;
for (index++; index < ranges.length;) {
const next = ranges[index];
const { 0: l, 1: c } = next;
if (l > endLine || (l === endLine && c >= endColumn)) {
break;
}
else {
out = maybeFlush(out, buf, posOut, buf, bufLength);
write(buf, posOut, comma);
}
out = maybeFlush(out, sub, posOut, buf, subLength);
genColumn = encodeInteger(buf, posOut, lastEndColumn, genColumn);
lastEndColumn = endStack.pop();
lastEndLine = endStack.pop();
index = _encodeGeneratedRanges(ranges, index, writer, state);
}
return out + td.decode(buf.subarray(0, posOut));
if (state[0] < endLine) {
catchupLine(writer, state[0], endLine);
state[0] = endLine;
state[1] = 0;
}
else {
writer.write(comma);
}
state[1] = encodeInteger(writer, endColumn, state[1]);
return index;
}
function catchupLine(build, buf, bufLength, lastLine, line) {
function catchupLine(writer, lastLine, line) {
do {
build = maybeFlush(build, buf, posOut, buf, bufLength);
write(buf, posOut, semicolon);
writer.write(semicolon);
} while (++lastLine < line);
return build;
}
function decode(mappings) {
const { length } = mappings;
const reader = new StringReader(mappings);
const decoded = [];

@@ -411,5 +364,4 @@ let genColumn = 0;

let namesIndex = 0;
let index = 0;
do {
const semi = indexOf(mappings, ';', index);
const semi = reader.indexOf(';');
const line = [];

@@ -419,14 +371,14 @@ let sorted = true;

genColumn = 0;
for (let i = index; i < semi; i = posOut + 1) {
while (reader.pos < semi) {
let seg;
genColumn = decodeInteger(mappings, i, genColumn);
genColumn = decodeInteger(reader, genColumn);
if (genColumn < lastCol)
sorted = false;
lastCol = genColumn;
if (hasMoreVlq(mappings, posOut, semi)) {
sourcesIndex = decodeInteger(mappings, posOut, sourcesIndex);
sourceLine = decodeInteger(mappings, posOut, sourceLine);
sourceColumn = decodeInteger(mappings, posOut, sourceColumn);
if (hasMoreVlq(mappings, posOut, semi)) {
namesIndex = decodeInteger(mappings, posOut, namesIndex);
if (hasMoreVlq(reader, semi)) {
sourcesIndex = decodeInteger(reader, sourcesIndex);
sourceLine = decodeInteger(reader, sourceLine);
sourceColumn = decodeInteger(reader, sourceColumn);
if (hasMoreVlq(reader, semi)) {
namesIndex = decodeInteger(reader, namesIndex);
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex];

@@ -442,2 +394,3 @@ }

line.push(seg);
reader.pos++;
}

@@ -447,4 +400,4 @@ if (!sorted)

decoded.push(line);
index = semi + 1;
} while (index <= mappings.length);
reader.pos = semi + 1;
} while (reader.pos <= length);
return decoded;

@@ -459,11 +412,3 @@ }

function encode(decoded) {
const bufLength = 1024 * 16;
// We can push up to 5 ints, each int can take at most 7 chars, and we
// may push a comma.
const subLength = bufLength - (7 * 5 + 1);
const buf = new Uint8Array(bufLength);
const sub = buf.subarray(0, subLength);
resetPos();
let out = '';
let genColumn = 0;
const writer = new StringWriter();
let sourcesIndex = 0;

@@ -475,25 +420,23 @@ let sourceLine = 0;

const line = decoded[i];
out = maybeFlush(out, buf, posOut, buf, bufLength);
if (i > 0)
write(buf, posOut, semicolon);
writer.write(semicolon);
if (line.length === 0)
continue;
genColumn = 0;
let genColumn = 0;
for (let j = 0; j < line.length; j++) {
const segment = line[j];
out = maybeFlush(out, sub, posOut, buf, subLength);
if (j > 0)
write(buf, posOut, comma);
genColumn = encodeInteger(buf, posOut, segment[0], genColumn);
writer.write(comma);
genColumn = encodeInteger(writer, segment[0], genColumn);
if (segment.length === 1)
continue;
sourcesIndex = encodeInteger(buf, posOut, segment[1], sourcesIndex);
sourceLine = encodeInteger(buf, posOut, segment[2], sourceLine);
sourceColumn = encodeInteger(buf, posOut, segment[3], sourceColumn);
sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
sourceLine = encodeInteger(writer, segment[2], sourceLine);
sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
if (segment.length === 4)
continue;
namesIndex = encodeInteger(buf, posOut, segment[4], namesIndex);
namesIndex = encodeInteger(writer, segment[4], namesIndex);
}
}
return out + td.decode(buf.subarray(0, posOut));
return writer.flush();
}

@@ -500,0 +443,0 @@

@@ -8,37 +8,43 @@ declare type Line = number;

declare type ScopesIndex = number;
export declare type OriginalScope = {
0: Line;
1: Column;
2: Line;
3: Column;
4: Kind;
vars?: Var[];
length: 5;
} | {
0: Line;
1: Column;
2: Line;
3: Column;
4: Kind;
5: Name;
vars?: Var[];
length: 6;
};
declare type Mix<A, B, O> = (A & O) | (B & O);
export declare type OriginalScope = Mix<[
Line,
Column,
Line,
Column,
Kind
], [
Line,
Column,
Line,
Column,
Kind,
Name
], {
vars: Var[];
}>;
export declare type GeneratedRange = Mix<[
Line,
Column,
Line,
Column
], [
Line,
Column,
Line,
Column,
SourcesIndex,
ScopesIndex
], {
callsite: CallSite | null;
bindings: Binding[];
isScope: boolean;
}>;
export declare type CallSite = [SourcesIndex, Line, Column];
declare type Binding = BindingExpressionRange[];
export declare type BindingExpressionRange = [Name] | [Name, Line, Column];
export declare function decodeOriginalScopes(input: string): OriginalScope[];
export declare function encodeOriginalScopes(scopes: OriginalScope[]): string;
export declare type GeneratedRange = {
0: Line;
1: Column;
2: Line;
3: Column;
4: SourcesIndex;
5: ScopesIndex;
callsite?: CallSite;
bindings?: ExpressionBinding[][];
isScope?: boolean;
};
export declare type CallSite = [SourcesIndex, Line, Column];
export declare type ExpressionBinding = [Name] | [Name, Line, Column];
export declare function decodeGeneratedRanges(input: string): GeneratedRange[];
export declare function encodeGeneratedRanges(ranges: GeneratedRange[]): string;
export {};
export { decodeOriginalScopes, encodeOriginalScopes, decodeGeneratedRanges, encodeGeneratedRanges, } from './scopes';
export type { OriginalScope, GeneratedRange, CallSite, ExpressionBinding } from './scopes';
export type { OriginalScope, GeneratedRange, CallSite, BindingExpressionRange } from './scopes';
export declare type SourceMapSegment = [number] | [number, number, number, number] | [number, number, number, number, number];

@@ -4,0 +4,0 @@ export declare type SourceMapLine = SourceMapSegment[];

@@ -0,14 +1,6 @@

import type { StringReader, StringWriter } from './strings';
export declare const comma: number;
export declare const semicolon: number;
export declare function hasMoreVlq(mappings: string, i: number, length: number): boolean;
export declare function indexOf(mappings: string, char: string, index: number): number;
export declare let posOut: number;
export declare function resetPos(): void;
export declare function decodeFirstOctet(mappings: string, pos: number): number;
export declare function decodeInteger(mappings: string, pos: number, relative: number): number;
export declare function encodeInteger(buf: Uint8Array, pos: number, num: number, relative: number): number;
export declare function maybeFlush(build: string, buf: Uint8Array, pos: number, copy: Uint8Array, length: number): string;
export declare function write(buf: Uint8Array, pos: number, value: number): void;
export declare const td: TextDecoder | {
decode(buf: Uint8Array): string;
};
export declare function decodeInteger(reader: StringReader, relative: number): number;
export declare function encodeInteger(builder: StringWriter, num: number, relative: number): number;
export declare function hasMoreVlq(reader: StringReader, max: number): boolean;
{
"name": "@jridgewell/sourcemap-codec",
"version": "1.4.16-beta.0",
"version": "1.5.0",
"description": "Encode/decode sourcemap mappings",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc