Socket
Socket
Sign inDemoInstall

sorcery

Package Overview
Dependencies
19
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.11.0 to 0.11.1

375

dist/sorcery.cjs.js
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var path = require('path');
var sander = require('sander');
var __commonjs_global = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : this;
function __commonjs(fn, module) { return module = { exports: {} }, fn(module, module.exports, __commonjs_global), module.exports; }
var sourcemapCodec_umd = __commonjs(function (module, exports, global) {
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.sourcemapCodec = {}));
})(__commonjs_global, (function (exports) { 'use strict';
const comma = ','.charCodeAt(0);
const semicolon = ';'.charCodeAt(0);
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
const intToChar = new Uint8Array(64); // 64 possible chars.
const charToInt = new Uint8Array(128); // z is 122 in ASCII
for (let i = 0; i < chars.length; i++) {
const c = chars.charCodeAt(i);
intToChar[i] = c;
charToInt[c] = i;
}
// Provide a fallback for older environments.
const td = typeof TextDecoder !== 'undefined'
? /* #__PURE__ */ new TextDecoder()
: typeof Buffer !== 'undefined'
? {
decode(buf) {
const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
return out.toString();
},
}
: {
decode(buf) {
let out = '';
for (let i = 0; i < buf.length; i++) {
out += String.fromCharCode(buf[i]);
}
return out;
},
};
function decode(mappings) {
const state = new Int32Array(5);
const decoded = [];
let index = 0;
do {
const semi = indexOf(mappings, index);
const line = [];
let sorted = true;
let lastCol = 0;
state[0] = 0;
for (let i = index; i < semi; i++) {
let seg;
i = decodeInteger(mappings, i, state, 0); // genColumn
const col = state[0];
if (col < lastCol)
sorted = false;
lastCol = col;
const comma = ','.charCodeAt(0);
const semicolon = ';'.charCodeAt(0);
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
const intToChar = new Uint8Array(64); // 64 possible chars.
const charToInt = new Uint8Array(128); // z is 122 in ASCII
for (let i = 0; i < chars.length; i++) {
const c = chars.charCodeAt(i);
intToChar[i] = c;
charToInt[c] = i;
}
// Provide a fallback for older environments.
const td = typeof TextDecoder !== 'undefined'
? /* #__PURE__ */ new TextDecoder()
: typeof Buffer !== 'undefined'
? {
decode(buf) {
const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
return out.toString();
},
}
: {
decode(buf) {
let out = '';
for (let i = 0; i < buf.length; i++) {
out += String.fromCharCode(buf[i]);
}
return out;
},
};
function decode(mappings) {
const state = new Int32Array(5);
const decoded = [];
let index = 0;
do {
const semi = indexOf(mappings, index);
const line = [];
let sorted = true;
let lastCol = 0;
state[0] = 0;
for (let i = index; i < semi; i++) {
let seg;
i = decodeInteger(mappings, i, state, 0); // genColumn
const col = state[0];
if (col < lastCol)
sorted = false;
lastCol = col;
if (hasMoreVlq(mappings, i, semi)) {
i = decodeInteger(mappings, i, state, 1); // sourcesIndex
i = decodeInteger(mappings, i, state, 2); // sourceLine
i = decodeInteger(mappings, i, state, 3); // sourceColumn
if (hasMoreVlq(mappings, i, semi)) {
i = decodeInteger(mappings, i, state, 1); // sourcesIndex
i = decodeInteger(mappings, i, state, 2); // sourceLine
i = decodeInteger(mappings, i, state, 3); // sourceColumn
if (hasMoreVlq(mappings, i, semi)) {
i = decodeInteger(mappings, i, state, 4); // namesIndex
seg = [col, state[1], state[2], state[3], state[4]];
}
else {
seg = [col, state[1], state[2], state[3]];
}
i = decodeInteger(mappings, i, state, 4); // namesIndex
seg = [col, state[1], state[2], state[3], state[4]];
}
else {
seg = [col];
seg = [col, state[1], state[2], state[3]];
}
line.push(seg);
}
if (!sorted)
sort(line);
decoded.push(line);
index = semi + 1;
} while (index <= mappings.length);
return decoded;
}
function indexOf(mappings, index) {
const idx = mappings.indexOf(';', index);
return idx === -1 ? mappings.length : idx;
}
function decodeInteger(mappings, pos, state, j) {
let value = 0;
let shift = 0;
let integer = 0;
do {
const c = mappings.charCodeAt(pos++);
integer = charToInt[c];
value |= (integer & 31) << shift;
shift += 5;
} while (integer & 32);
const shouldNegate = value & 1;
value >>>= 1;
if (shouldNegate) {
value = -0x80000000 | -value;
else {
seg = [col];
}
line.push(seg);
}
state[j] += value;
return pos;
if (!sorted)
sort(line);
decoded.push(line);
index = semi + 1;
} while (index <= mappings.length);
return decoded;
}
function indexOf(mappings, index) {
const idx = mappings.indexOf(';', index);
return idx === -1 ? mappings.length : idx;
}
function decodeInteger(mappings, pos, state, j) {
let value = 0;
let shift = 0;
let integer = 0;
do {
const c = mappings.charCodeAt(pos++);
integer = charToInt[c];
value |= (integer & 31) << shift;
shift += 5;
} while (integer & 32);
const shouldNegate = value & 1;
value >>>= 1;
if (shouldNegate) {
value = -0x80000000 | -value;
}
function hasMoreVlq(mappings, i, length) {
if (i >= length)
return false;
return mappings.charCodeAt(i) !== comma;
}
function sort(line) {
line.sort(sortComparator);
}
function sortComparator(a, b) {
return a[0] - b[0];
}
function encode(decoded) {
const state = new Int32Array(5);
const bufLength = 1024 * 16;
const subLength = bufLength - 36;
const buf = new Uint8Array(bufLength);
const sub = buf.subarray(0, subLength);
let pos = 0;
let out = '';
for (let i = 0; i < decoded.length; i++) {
const line = decoded[i];
if (i > 0) {
if (pos === bufLength) {
out += td.decode(buf);
pos = 0;
}
buf[pos++] = semicolon;
state[j] += value;
return pos;
}
function hasMoreVlq(mappings, i, length) {
if (i >= length)
return false;
return mappings.charCodeAt(i) !== comma;
}
function sort(line) {
line.sort(sortComparator);
}
function sortComparator(a, b) {
return a[0] - b[0];
}
function encode(decoded) {
const state = new Int32Array(5);
const bufLength = 1024 * 16;
const subLength = bufLength - 36;
const buf = new Uint8Array(bufLength);
const sub = buf.subarray(0, subLength);
let pos = 0;
let out = '';
for (let i = 0; i < decoded.length; i++) {
const line = decoded[i];
if (i > 0) {
if (pos === bufLength) {
out += td.decode(buf);
pos = 0;
}
if (line.length === 0)
buf[pos++] = semicolon;
}
if (line.length === 0)
continue;
state[0] = 0;
for (let j = 0; j < line.length; j++) {
const segment = line[j];
// We can push up to 5 ints, each int can take at most 7 chars, and we
// may push a comma.
if (pos > subLength) {
out += td.decode(sub);
buf.copyWithin(0, subLength, pos);
pos -= subLength;
}
if (j > 0)
buf[pos++] = comma;
pos = encodeInteger(buf, pos, state, segment, 0); // genColumn
if (segment.length === 1)
continue;
state[0] = 0;
for (let j = 0; j < line.length; j++) {
const segment = line[j];
// We can push up to 5 ints, each int can take at most 7 chars, and we
// may push a comma.
if (pos > subLength) {
out += td.decode(sub);
buf.copyWithin(0, subLength, pos);
pos -= subLength;
}
if (j > 0)
buf[pos++] = comma;
pos = encodeInteger(buf, pos, state, segment, 0); // genColumn
if (segment.length === 1)
continue;
pos = encodeInteger(buf, pos, state, segment, 1); // sourcesIndex
pos = encodeInteger(buf, pos, state, segment, 2); // sourceLine
pos = encodeInteger(buf, pos, state, segment, 3); // sourceColumn
if (segment.length === 4)
continue;
pos = encodeInteger(buf, pos, state, segment, 4); // namesIndex
}
pos = encodeInteger(buf, pos, state, segment, 1); // sourcesIndex
pos = encodeInteger(buf, pos, state, segment, 2); // sourceLine
pos = encodeInteger(buf, pos, state, segment, 3); // sourceColumn
if (segment.length === 4)
continue;
pos = encodeInteger(buf, pos, state, segment, 4); // namesIndex
}
return out + td.decode(buf.subarray(0, pos));
}
function encodeInteger(buf, pos, state, segment, j) {
const next = segment[j];
let num = next - state[j];
state[j] = next;
num = num < 0 ? (-num << 1) | 1 : num << 1;
do {
let clamped = num & 0b011111;
num >>>= 5;
if (num > 0)
clamped |= 0b100000;
buf[pos++] = intToChar[clamped];
} while (num > 0);
return pos;
}
return out + td.decode(buf.subarray(0, pos));
}
function encodeInteger(buf, pos, state, segment, j) {
const next = segment[j];
let num = next - state[j];
state[j] = next;
num = num < 0 ? (-num << 1) | 1 : num << 1;
do {
let clamped = num & 0b011111;
num >>>= 5;
if (num > 0)
clamped |= 0b100000;
buf[pos++] = intToChar[clamped];
} while (num > 0);
return pos;
}
exports.decode = decode;
exports.encode = encode;
Object.defineProperty(exports, '__esModule', { value: true });
}));
});
var codec = (sourcemapCodec_umd && typeof sourcemapCodec_umd === 'object' && 'default' in sourcemapCodec_umd ? sourcemapCodec_umd['default'] : sourcemapCodec_umd);
/**

@@ -316,22 +294,22 @@ * Decodes a base64 string

load: function load ( sourcesContentByPath, sourceMapByPath ) {
var this$1 = this;
var this$1$1 = this;
return getContent( this, sourcesContentByPath ).then( function (content) {
this$1.content = sourcesContentByPath[ this$1.file ] = content;
this$1$1.content = sourcesContentByPath[ this$1$1.file ] = content;
return getMap( this$1, sourceMapByPath ).then( function (map) {
if ( !map ) return null;
return getMap( this$1$1, sourceMapByPath ).then( function (map) {
if ( !map ) { return null; }
this$1.map = map;
this$1$1.map = map;
var decodingStart = process.hrtime();
this$1.mappings = codec.decode( map.mappings );
this$1$1.mappings = decode( map.mappings );
var decodingTime = process.hrtime( decodingStart );
this$1._stats.decodingTime = 1e9 * decodingTime[0] + decodingTime[1];
this$1$1._stats.decodingTime = 1e9 * decodingTime[0] + decodingTime[1];
var sourcesContent = map.sourcesContent || [];
var sourceRoot = path.resolve( path.dirname( this$1.file ), map.sourceRoot || '' );
var sourceRoot = path.resolve( path.dirname( this$1$1.file || '' ), map.sourceRoot || '' );
this$1.sources = map.sources.map( function ( source, i ) {
this$1$1.sources = map.sources.map( function ( source, i ) {
return new Node({

@@ -343,3 +321,3 @@ file: source ? path.resolve( sourceRoot, source ) : null,

var promises = this$1.sources.map( function (node) { return node.load( sourcesContentByPath, sourceMapByPath ); } );
var promises = this$1$1.sources.map( function (node) { return node.load( sourcesContentByPath, sourceMapByPath ); } );
return sander.Promise.all( promises );

@@ -366,7 +344,7 @@ });

this.map = map;
this.mappings = codec.decode( map.mappings );
this.mappings = decode( map.mappings );
sourcesContent = map.sourcesContent || [];
var sourceRoot = path.resolve( path.dirname( this.file ), map.sourceRoot || '' );
var sourceRoot = path.resolve( path.dirname( this.file || '' ), map.sourceRoot || '' );

@@ -401,4 +379,2 @@ this.sources = map.sources.map( function ( source, i ) {

trace: function trace ( lineIndex, columnIndex, name ) {
var this$1 = this;
// If this node doesn't have a source map, we have

@@ -435,3 +411,3 @@ // to assume it is the original source

if ( generatedCodeColumn === columnIndex ) {
if ( segments[i].length < 4 ) return null;
if ( segments[i].length < 4 ) { return null; }

@@ -443,4 +419,4 @@ var sourceFileIndex$1 = segments[i][1];

var parent$1 = this$1.sources[ sourceFileIndex$1 ];
return parent$1.trace( sourceCodeLine$1, sourceCodeColumn, this$1.map.names[ nameIndex$1 ] || name );
var parent$1 = this.sources[ sourceFileIndex$1 ];
return parent$1.trace( sourceCodeLine$1, sourceCodeColumn, this.map.names[ nameIndex$1 ] || name );
}

@@ -508,3 +484,3 @@ }

var SOURCEMAP_COMMENT = new RegExp( "\n*(?:" +
"\\/\\/[@#]\\s*" + SOURCEMAPPING_URL$1 + "=([^'\"]+)|" + // js
"\\/\\/[@#]\\s*" + SOURCEMAPPING_URL$1 + "=([^\n]+)|" + // js
"\\/\\*#?\\s*" + SOURCEMAPPING_URL$1 + "=([^'\"]+)\\s\\*\\/)" + // css

@@ -534,3 +510,3 @@ '\\s*$', 'g' );

apply: function apply ( options ) {
var this$1 = this;
var this$1$1 = this;
if ( options === void 0 ) options = {};

@@ -542,12 +518,12 @@

var applySegment = function ( segment, result ) {
if ( segment.length < 4 ) return;
if ( segment.length < 4 ) { return; }
var traced = this$1.node.sources[ segment[1] ].trace( // source
var traced = this$1$1.node.sources[ segment[1] ].trace( // source
segment[2], // source code line
segment[3], // source code column
this$1.node.map.names[ segment[4] ]
this$1$1.node.map.names[ segment[4] ]
);
if ( !traced ) {
this$1._stats.untraceable += 1;
this$1$1._stats.untraceable += 1;
return;

@@ -591,3 +567,3 @@ }

while ( i-- ) {
line = this$1.node.mappings[i];
line = this.node.mappings[i];
resolved[i] = result = [];

@@ -605,3 +581,3 @@

var encodingStart = process.hrtime();
var mappings = codec.encode( resolved );
var mappings = encode( resolved );
var encodingTime = process.hrtime( encodingStart );

@@ -614,4 +590,4 @@ this._stats.encodingTime = 1e9 * encodingTime[0] + encodingTime[1];

file: path.basename( this.node.file ),
sources: allSources.map( function (source) { return slash( path.relative( options.base || path.dirname( this$1.node.file ), source ) ); } ),
sourcesContent: allSources.map( function (source) { return includeContent ? this$1.sourcesContentByPath[ source ] : null; } ),
sources: allSources.map( function (source) { return slash( path.relative( options.base || path.dirname( this$1$1.node.file ), source ) ); } ),
sourcesContent: allSources.map( function (source) { return includeContent ? this$1$1.sourcesContentByPath[ source ] : null; } ),
names: allNames,

@@ -749,2 +725,1 @@ mappings: mappings

exports.loadSync = loadSync;
//# sourceMappingURL=sorcery.cjs.js.map

@@ -1,186 +0,166 @@

import { resolve, dirname, relative, basename, extname } from 'path';
import { readFileSync, Promise as Promise$1, readFile, writeFileSync, writeFile } from 'sander';
import { resolve, dirname, basename, relative, extname } from 'path';
import { Promise as Promise$1, readFileSync, readFile, writeFile, writeFileSync } from 'sander';
var __commonjs_global = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : this;
function __commonjs(fn, module) { return module = { exports: {} }, fn(module, module.exports, __commonjs_global), module.exports; }
var sourcemapCodec_umd = __commonjs(function (module, exports, global) {
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.sourcemapCodec = {}));
})(__commonjs_global, (function (exports) { 'use strict';
const comma = ','.charCodeAt(0);
const semicolon = ';'.charCodeAt(0);
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
const intToChar = new Uint8Array(64); // 64 possible chars.
const charToInt = new Uint8Array(128); // z is 122 in ASCII
for (let i = 0; i < chars.length; i++) {
const c = chars.charCodeAt(i);
intToChar[i] = c;
charToInt[c] = i;
}
// Provide a fallback for older environments.
const td = typeof TextDecoder !== 'undefined'
? /* #__PURE__ */ new TextDecoder()
: typeof Buffer !== 'undefined'
? {
decode(buf) {
const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
return out.toString();
},
}
: {
decode(buf) {
let out = '';
for (let i = 0; i < buf.length; i++) {
out += String.fromCharCode(buf[i]);
}
return out;
},
};
function decode(mappings) {
const state = new Int32Array(5);
const decoded = [];
let index = 0;
do {
const semi = indexOf(mappings, index);
const line = [];
let sorted = true;
let lastCol = 0;
state[0] = 0;
for (let i = index; i < semi; i++) {
let seg;
i = decodeInteger(mappings, i, state, 0); // genColumn
const col = state[0];
if (col < lastCol)
sorted = false;
lastCol = col;
const comma = ','.charCodeAt(0);
const semicolon = ';'.charCodeAt(0);
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
const intToChar = new Uint8Array(64); // 64 possible chars.
const charToInt = new Uint8Array(128); // z is 122 in ASCII
for (let i = 0; i < chars.length; i++) {
const c = chars.charCodeAt(i);
intToChar[i] = c;
charToInt[c] = i;
}
// Provide a fallback for older environments.
const td = typeof TextDecoder !== 'undefined'
? /* #__PURE__ */ new TextDecoder()
: typeof Buffer !== 'undefined'
? {
decode(buf) {
const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
return out.toString();
},
}
: {
decode(buf) {
let out = '';
for (let i = 0; i < buf.length; i++) {
out += String.fromCharCode(buf[i]);
}
return out;
},
};
function decode(mappings) {
const state = new Int32Array(5);
const decoded = [];
let index = 0;
do {
const semi = indexOf(mappings, index);
const line = [];
let sorted = true;
let lastCol = 0;
state[0] = 0;
for (let i = index; i < semi; i++) {
let seg;
i = decodeInteger(mappings, i, state, 0); // genColumn
const col = state[0];
if (col < lastCol)
sorted = false;
lastCol = col;
if (hasMoreVlq(mappings, i, semi)) {
i = decodeInteger(mappings, i, state, 1); // sourcesIndex
i = decodeInteger(mappings, i, state, 2); // sourceLine
i = decodeInteger(mappings, i, state, 3); // sourceColumn
if (hasMoreVlq(mappings, i, semi)) {
i = decodeInteger(mappings, i, state, 1); // sourcesIndex
i = decodeInteger(mappings, i, state, 2); // sourceLine
i = decodeInteger(mappings, i, state, 3); // sourceColumn
if (hasMoreVlq(mappings, i, semi)) {
i = decodeInteger(mappings, i, state, 4); // namesIndex
seg = [col, state[1], state[2], state[3], state[4]];
}
else {
seg = [col, state[1], state[2], state[3]];
}
i = decodeInteger(mappings, i, state, 4); // namesIndex
seg = [col, state[1], state[2], state[3], state[4]];
}
else {
seg = [col];
seg = [col, state[1], state[2], state[3]];
}
line.push(seg);
}
if (!sorted)
sort(line);
decoded.push(line);
index = semi + 1;
} while (index <= mappings.length);
return decoded;
}
function indexOf(mappings, index) {
const idx = mappings.indexOf(';', index);
return idx === -1 ? mappings.length : idx;
}
function decodeInteger(mappings, pos, state, j) {
let value = 0;
let shift = 0;
let integer = 0;
do {
const c = mappings.charCodeAt(pos++);
integer = charToInt[c];
value |= (integer & 31) << shift;
shift += 5;
} while (integer & 32);
const shouldNegate = value & 1;
value >>>= 1;
if (shouldNegate) {
value = -0x80000000 | -value;
else {
seg = [col];
}
line.push(seg);
}
state[j] += value;
return pos;
if (!sorted)
sort(line);
decoded.push(line);
index = semi + 1;
} while (index <= mappings.length);
return decoded;
}
function indexOf(mappings, index) {
const idx = mappings.indexOf(';', index);
return idx === -1 ? mappings.length : idx;
}
function decodeInteger(mappings, pos, state, j) {
let value = 0;
let shift = 0;
let integer = 0;
do {
const c = mappings.charCodeAt(pos++);
integer = charToInt[c];
value |= (integer & 31) << shift;
shift += 5;
} while (integer & 32);
const shouldNegate = value & 1;
value >>>= 1;
if (shouldNegate) {
value = -0x80000000 | -value;
}
function hasMoreVlq(mappings, i, length) {
if (i >= length)
return false;
return mappings.charCodeAt(i) !== comma;
}
function sort(line) {
line.sort(sortComparator);
}
function sortComparator(a, b) {
return a[0] - b[0];
}
function encode(decoded) {
const state = new Int32Array(5);
const bufLength = 1024 * 16;
const subLength = bufLength - 36;
const buf = new Uint8Array(bufLength);
const sub = buf.subarray(0, subLength);
let pos = 0;
let out = '';
for (let i = 0; i < decoded.length; i++) {
const line = decoded[i];
if (i > 0) {
if (pos === bufLength) {
out += td.decode(buf);
pos = 0;
}
buf[pos++] = semicolon;
state[j] += value;
return pos;
}
function hasMoreVlq(mappings, i, length) {
if (i >= length)
return false;
return mappings.charCodeAt(i) !== comma;
}
function sort(line) {
line.sort(sortComparator);
}
function sortComparator(a, b) {
return a[0] - b[0];
}
function encode(decoded) {
const state = new Int32Array(5);
const bufLength = 1024 * 16;
const subLength = bufLength - 36;
const buf = new Uint8Array(bufLength);
const sub = buf.subarray(0, subLength);
let pos = 0;
let out = '';
for (let i = 0; i < decoded.length; i++) {
const line = decoded[i];
if (i > 0) {
if (pos === bufLength) {
out += td.decode(buf);
pos = 0;
}
if (line.length === 0)
buf[pos++] = semicolon;
}
if (line.length === 0)
continue;
state[0] = 0;
for (let j = 0; j < line.length; j++) {
const segment = line[j];
// We can push up to 5 ints, each int can take at most 7 chars, and we
// may push a comma.
if (pos > subLength) {
out += td.decode(sub);
buf.copyWithin(0, subLength, pos);
pos -= subLength;
}
if (j > 0)
buf[pos++] = comma;
pos = encodeInteger(buf, pos, state, segment, 0); // genColumn
if (segment.length === 1)
continue;
state[0] = 0;
for (let j = 0; j < line.length; j++) {
const segment = line[j];
// We can push up to 5 ints, each int can take at most 7 chars, and we
// may push a comma.
if (pos > subLength) {
out += td.decode(sub);
buf.copyWithin(0, subLength, pos);
pos -= subLength;
}
if (j > 0)
buf[pos++] = comma;
pos = encodeInteger(buf, pos, state, segment, 0); // genColumn
if (segment.length === 1)
continue;
pos = encodeInteger(buf, pos, state, segment, 1); // sourcesIndex
pos = encodeInteger(buf, pos, state, segment, 2); // sourceLine
pos = encodeInteger(buf, pos, state, segment, 3); // sourceColumn
if (segment.length === 4)
continue;
pos = encodeInteger(buf, pos, state, segment, 4); // namesIndex
}
pos = encodeInteger(buf, pos, state, segment, 1); // sourcesIndex
pos = encodeInteger(buf, pos, state, segment, 2); // sourceLine
pos = encodeInteger(buf, pos, state, segment, 3); // sourceColumn
if (segment.length === 4)
continue;
pos = encodeInteger(buf, pos, state, segment, 4); // namesIndex
}
return out + td.decode(buf.subarray(0, pos));
}
function encodeInteger(buf, pos, state, segment, j) {
const next = segment[j];
let num = next - state[j];
state[j] = next;
num = num < 0 ? (-num << 1) | 1 : num << 1;
do {
let clamped = num & 0b011111;
num >>>= 5;
if (num > 0)
clamped |= 0b100000;
buf[pos++] = intToChar[clamped];
} while (num > 0);
return pos;
}
return out + td.decode(buf.subarray(0, pos));
}
function encodeInteger(buf, pos, state, segment, j) {
const next = segment[j];
let num = next - state[j];
state[j] = next;
num = num < 0 ? (-num << 1) | 1 : num << 1;
do {
let clamped = num & 0b011111;
num >>>= 5;
if (num > 0)
clamped |= 0b100000;
buf[pos++] = intToChar[clamped];
} while (num > 0);
return pos;
}
exports.decode = decode;
exports.encode = encode;
Object.defineProperty(exports, '__esModule', { value: true });
}));
});
var codec = (sourcemapCodec_umd && typeof sourcemapCodec_umd === 'object' && 'default' in sourcemapCodec_umd ? sourcemapCodec_umd['default'] : sourcemapCodec_umd);
/**

@@ -312,22 +292,22 @@ * Decodes a base64 string

load: function load ( sourcesContentByPath, sourceMapByPath ) {
var this$1 = this;
var this$1$1 = this;
return getContent( this, sourcesContentByPath ).then( function (content) {
this$1.content = sourcesContentByPath[ this$1.file ] = content;
this$1$1.content = sourcesContentByPath[ this$1$1.file ] = content;
return getMap( this$1, sourceMapByPath ).then( function (map) {
if ( !map ) return null;
return getMap( this$1$1, sourceMapByPath ).then( function (map) {
if ( !map ) { return null; }
this$1.map = map;
this$1$1.map = map;
var decodingStart = process.hrtime();
this$1.mappings = codec.decode( map.mappings );
this$1$1.mappings = decode( map.mappings );
var decodingTime = process.hrtime( decodingStart );
this$1._stats.decodingTime = 1e9 * decodingTime[0] + decodingTime[1];
this$1$1._stats.decodingTime = 1e9 * decodingTime[0] + decodingTime[1];
var sourcesContent = map.sourcesContent || [];
var sourceRoot = resolve( dirname( this$1.file ), map.sourceRoot || '' );
var sourceRoot = resolve( dirname( this$1$1.file || '' ), map.sourceRoot || '' );
this$1.sources = map.sources.map( function ( source, i ) {
this$1$1.sources = map.sources.map( function ( source, i ) {
return new Node({

@@ -339,3 +319,3 @@ file: source ? resolve( sourceRoot, source ) : null,

var promises = this$1.sources.map( function (node) { return node.load( sourcesContentByPath, sourceMapByPath ); } );
var promises = this$1$1.sources.map( function (node) { return node.load( sourcesContentByPath, sourceMapByPath ); } );
return Promise$1.all( promises );

@@ -362,7 +342,7 @@ });

this.map = map;
this.mappings = codec.decode( map.mappings );
this.mappings = decode( map.mappings );
sourcesContent = map.sourcesContent || [];
var sourceRoot = resolve( dirname( this.file ), map.sourceRoot || '' );
var sourceRoot = resolve( dirname( this.file || '' ), map.sourceRoot || '' );

@@ -397,4 +377,2 @@ this.sources = map.sources.map( function ( source, i ) {

trace: function trace ( lineIndex, columnIndex, name ) {
var this$1 = this;
// If this node doesn't have a source map, we have

@@ -431,3 +409,3 @@ // to assume it is the original source

if ( generatedCodeColumn === columnIndex ) {
if ( segments[i].length < 4 ) return null;
if ( segments[i].length < 4 ) { return null; }

@@ -439,4 +417,4 @@ var sourceFileIndex$1 = segments[i][1];

var parent$1 = this$1.sources[ sourceFileIndex$1 ];
return parent$1.trace( sourceCodeLine$1, sourceCodeColumn, this$1.map.names[ nameIndex$1 ] || name );
var parent$1 = this.sources[ sourceFileIndex$1 ];
return parent$1.trace( sourceCodeLine$1, sourceCodeColumn, this.map.names[ nameIndex$1 ] || name );
}

@@ -504,3 +482,3 @@ }

var SOURCEMAP_COMMENT = new RegExp( "\n*(?:" +
"\\/\\/[@#]\\s*" + SOURCEMAPPING_URL$1 + "=([^'\"]+)|" + // js
"\\/\\/[@#]\\s*" + SOURCEMAPPING_URL$1 + "=([^\n]+)|" + // js
"\\/\\*#?\\s*" + SOURCEMAPPING_URL$1 + "=([^'\"]+)\\s\\*\\/)" + // css

@@ -530,3 +508,3 @@ '\\s*$', 'g' );

apply: function apply ( options ) {
var this$1 = this;
var this$1$1 = this;
if ( options === void 0 ) options = {};

@@ -538,12 +516,12 @@

var applySegment = function ( segment, result ) {
if ( segment.length < 4 ) return;
if ( segment.length < 4 ) { return; }
var traced = this$1.node.sources[ segment[1] ].trace( // source
var traced = this$1$1.node.sources[ segment[1] ].trace( // source
segment[2], // source code line
segment[3], // source code column
this$1.node.map.names[ segment[4] ]
this$1$1.node.map.names[ segment[4] ]
);
if ( !traced ) {
this$1._stats.untraceable += 1;
this$1$1._stats.untraceable += 1;
return;

@@ -587,3 +565,3 @@ }

while ( i-- ) {
line = this$1.node.mappings[i];
line = this.node.mappings[i];
resolved[i] = result = [];

@@ -601,3 +579,3 @@

var encodingStart = process.hrtime();
var mappings = codec.encode( resolved );
var mappings = encode( resolved );
var encodingTime = process.hrtime( encodingStart );

@@ -610,4 +588,4 @@ this._stats.encodingTime = 1e9 * encodingTime[0] + encodingTime[1];

file: basename( this.node.file ),
sources: allSources.map( function (source) { return slash( relative( options.base || dirname( this$1.node.file ), source ) ); } ),
sourcesContent: allSources.map( function (source) { return includeContent ? this$1.sourcesContentByPath[ source ] : null; } ),
sources: allSources.map( function (source) { return slash( relative( options.base || dirname( this$1$1.node.file ), source ) ); } ),
sourcesContent: allSources.map( function (source) { return includeContent ? this$1$1.sourcesContentByPath[ source ] : null; } ),
names: allNames,

@@ -744,2 +722,1 @@ mappings: mappings

export { load, loadSync };
//# sourceMappingURL=sorcery.es6.js.map
{
"name": "sorcery",
"description": "Resolve a chain of sourcemaps back to the original source",
"version": "0.11.0",
"version": "0.11.1",
"author": "Rich Harris",

@@ -11,3 +11,3 @@ "repository": "https://github.com/Rich-Harris/sorcery",

"dependencies": {
"buffer-crc32": "^0.2.5",
"buffer-crc32": "^1.0.0",
"minimist": "^1.2.0",

@@ -18,3 +18,6 @@ "sander": "^0.5.0",

"devDependencies": {
"buble": "^0.10.4",
"@rollup/plugin-buble": "^1.0.3",
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-node-resolve": "^15.2.3",
"buble": "^0.20.0",
"codecov.io": "^0.1.6",

@@ -29,6 +32,3 @@ "coffee-script": "^1.10.0",

"remap-istanbul": "^0.6.3",
"rollup": "^0.31.0",
"rollup-plugin-buble": "^0.10.0",
"rollup-plugin-commonjs": "^2.2.1",
"rollup-plugin-npm": "^1.4.0",
"rollup": "^4.18.0",
"source-map": "^0.5.3",

@@ -42,3 +42,3 @@ "source-map-support": "^0.4.0",

"scripts": {
"build": "rm -rf dist && rollup -c -f cjs -o dist/sorcery.cjs.js && rollup -c -f es6 -o dist/sorcery.es6.js",
"build": "rm -rf dist && rollup -c rollup.config.mjs",
"pretest": "npm run build",

@@ -45,0 +45,0 @@ "prepare-tests": "node test/samples/prepare-tests.js",

@@ -9,3 +9,3 @@ # sorcery.js

**Sorcery aims to fix that.** Given an file at the end of a transformation chain (e.g., your minified JavaScript), it will follow the entire chain back to the original source, and generate a new sourcemap that describes the whole process. How? Magic.
**Sorcery aims to fix that.** Given a file at the end of a transformation chain (e.g., your minified JavaScript), it will follow the entire chain back to the original source, and generate a new sourcemap that describes the whole process. How? Magic.

@@ -12,0 +12,0 @@ This is a work-in-progress - suitable for playing around with, but don't rely on it to debug air traffic control software or medical equipment. Other than that, it can't do much harm.

import { basename, dirname, extname, relative, resolve } from 'path';
import { writeFile, writeFileSync } from 'sander';
import codec from '@jridgewell/sourcemap-codec';
import { encode } from '@jridgewell/sourcemap-codec';
import SourceMap from './SourceMap.js';

@@ -9,3 +9,3 @@ import slash from './utils/slash.js';

const SOURCEMAP_COMMENT = new RegExp( `\n*(?:` +
`\\/\\/[@#]\\s*${SOURCEMAPPING_URL}=([^'"]+)|` + // js
`\\/\\/[@#]\\s*${SOURCEMAPPING_URL}=([^\n]+)|` + // js
`\\/\\*#?\\s*${SOURCEMAPPING_URL}=([^'"]+)\\s\\*\\/)` + // css

@@ -100,3 +100,3 @@ '\\s*$', 'g' );

let encodingStart = process.hrtime();
let mappings = codec.encode( resolved );
let mappings = encode( resolved );
let encodingTime = process.hrtime( encodingStart );

@@ -103,0 +103,0 @@ this._stats.encodingTime = 1e9 * encodingTime[0] + encodingTime[1];

import { dirname, resolve } from 'path';
import { readFile, readFileSync, Promise } from 'sander';
import codec from '@jridgewell/sourcemap-codec';
import { decode } from '@jridgewell/sourcemap-codec';
import getMap from './utils/getMap.js';

@@ -40,3 +40,3 @@

let decodingStart = process.hrtime();
this.mappings = codec.decode( map.mappings );
this.mappings = decode( map.mappings );
let decodingTime = process.hrtime( decodingStart );

@@ -47,3 +47,3 @@ this._stats.decodingTime = 1e9 * decodingTime[0] + decodingTime[1];

const sourceRoot = resolve( dirname( this.file ), map.sourceRoot || '' );
const sourceRoot = resolve( dirname( this.file || '' ), map.sourceRoot || '' );

@@ -70,2 +70,4 @@ this.sources = map.sources.map( ( source, i ) => {

this.content = sourcesContentByPath[ this.file ];
} else {
sourcesContentByPath[ this.file ] = this.content;
}

@@ -80,7 +82,7 @@

this.map = map;
this.mappings = codec.decode( map.mappings );
this.mappings = decode( map.mappings );
sourcesContent = map.sourcesContent || [];
const sourceRoot = resolve( dirname( this.file ), map.sourceRoot || '' );
const sourceRoot = resolve( dirname( this.file || '' ), map.sourceRoot || '' );

@@ -87,0 +89,0 @@ this.sources = map.sources.map( ( source, i ) => {

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc