Socket
Socket
Sign inDemoInstall

sorcery

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sorcery - npm Package Compare versions

Comparing version 0.5.0 to 0.5.1

6

CHANGELOG.md
# changelog
## 0.5.1
* Fix build definition to prevent ES6-only features appearing in dist files
* Hook up to Travis CI
* Update tests to not use gobble (since latest gobble uses sorcery by default)
## 0.5.0

@@ -4,0 +10,0 @@

65

dist/sorcery.js

@@ -7,5 +7,6 @@ 'use strict';

var sander__default = ('default' in sander ? sander['default'] : sander);
var buffer_crc32 = require('buffer-crc32');
var vlq = require('vlq');
var buffer_crc32 = require('buffer-crc32');
var utils_decodeMappings = decodeMappings;
var cache = {};

@@ -96,4 +97,4 @@

*/
var utils_atob = atob;
function atob(base64) {

@@ -113,3 +114,3 @@ return new Buffer(base64, 'base64').toString('utf8');

*/
var utils_getMapFromUrl = getMapFromUrl;
function getMapFromUrl(url, base, sync) {

@@ -123,3 +124,3 @@ if (/^data/.test(url)) {

var json = atob(match[1]);
var json = utils_atob(match[1]);
var map = JSON.parse(json);

@@ -138,2 +139,4 @@ return sync ? map : sander__default.Promise.resolve(map);

var utils_getSourceMappingUrl = getSourceMappingUrl;
function getSourceMappingUrl(str) {

@@ -156,2 +159,3 @@ var index, substring, url, match;

var utils_getMap = getMap;
function getMap(node, sourceMapByPath, sync) {

@@ -162,3 +166,3 @@ if (node.file in sourceMapByPath) {

} else {
var url = getSourceMappingUrl(node.content);
var url = utils_getSourceMappingUrl(node.content);

@@ -170,9 +174,9 @@ if (!url) {

return getMapFromUrl(url, node.file, sync);
return utils_getMapFromUrl(url, node.file, sync);
}
}
var Node___classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var _Node___classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var Node__Promise = sander__default.Promise;
var _Node__Promise = sander__default.Promise;

@@ -184,3 +188,3 @@ var Node = (function () {

Node___classCallCheck(this, Node);
_Node___classCallCheck(this, Node);

@@ -215,3 +219,3 @@ this.file = file ? path__default.resolve(file) : null;

return getMap(_this, sourceMapByPath).then(function (map) {
return utils_getMap(_this, sourceMapByPath).then(function (map) {
if (!map) return null;

@@ -222,3 +226,3 @@

var decodingStart = process.hrtime();
_this.mappings = decodeMappings(map.mappings);
_this.mappings = utils_decodeMappings(map.mappings);
var decodingTime = process.hrtime(decodingStart);

@@ -239,3 +243,3 @@ _this._stats.decodingTime = 1000000000 * decodingTime[0] + decodingTime[1];

});
return Node__Promise.all(promises);
return _Node__Promise.all(promises);
});

@@ -252,3 +256,3 @@ });

var map = getMap(this, sourceMapByPath, true);
var map = utils_getMap(this, sourceMapByPath, true);
var sourcesContent = undefined;

@@ -260,3 +264,3 @@

this.map = map;
this.mappings = decodeMappings(map.mappings);
this.mappings = utils_decodeMappings(map.mappings);

@@ -348,4 +352,4 @@ sourcesContent = map.sourcesContent || [];

var _Node = Node;
function getContent(node, sourcesContentByPath) {

@@ -360,3 +364,3 @@ if (node.file in sourcesContentByPath) {

return Node__Promise.resolve(node.content);
return _Node__Promise.resolve(node.content);
}

@@ -374,4 +378,4 @@

*/
var utils_btoa = btoa;
function btoa(str) {

@@ -381,7 +385,7 @@ return new Buffer(str).toString('base64');

var SourceMap___classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var _SourceMap___classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var SourceMap = (function () {
function SourceMap(properties) {
SourceMap___classCallCheck(this, SourceMap);
_SourceMap___classCallCheck(this, SourceMap);

@@ -402,3 +406,3 @@ this.version = 3;

SourceMap.prototype.toUrl = function toUrl() {
return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
return 'data:application/json;charset=utf-8;base64,' + utils_btoa(this.toString());
};

@@ -409,2 +413,5 @@

var _SourceMap = SourceMap;
var utils_encodeMappings = encodeMappings;
function encodeMappings(decoded) {

@@ -456,3 +463,3 @@ var offsets = {

var Chain___classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
var _Chain___classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };

@@ -463,3 +470,3 @@ var SOURCEMAP_COMMENT = /\s+\/\/#\s+sourceMappingURL=([^\r\n]+)/g;

function Chain(node, sourcesContentByPath) {
Chain___classCallCheck(this, Chain);
_Chain___classCallCheck(this, Chain);

@@ -549,3 +556,3 @@ this.node = node;

var encodingStart = process.hrtime();
var mappings = encodeMappings(resolved);
var mappings = utils_encodeMappings(resolved);
var encodingTime = process.hrtime(encodingStart);

@@ -556,3 +563,3 @@ this._stats.encodingTime = 1000000000 * encodingTime[0] + encodingTime[1];

return new SourceMap({
return new _SourceMap({
file: path.basename(this.node.file),

@@ -590,3 +597,3 @@ sources: allSources.map(function (source) {

var content = this.node.content.replace(SOURCEMAP_COMMENT, '') + `\n//# sourceMappingURL=${ encodeURI(url) }\n`;
var content = this.node.content.replace(SOURCEMAP_COMMENT, '') + ('\n//# sourceMappingURL=' + encodeURI(url) + '\n');

@@ -605,4 +612,4 @@ var promises = [sander__default.writeFile(dest, content)];

var _Chain = Chain;
function tally(nodes, stat) {

@@ -622,3 +629,3 @@ return nodes.reduce(function (total, node) {

return node.load(sourcesContentByPath, sourceMapByPath).then(function () {
return node.isOriginalSource ? null : new Chain(node, sourcesContentByPath);
return node.isOriginalSource ? null : new _Chain(node, sourcesContentByPath);
});

@@ -637,3 +644,3 @@ }

node.loadSync(sourcesContentByPath, sourceMapByPath);
return node.isOriginalSource ? null : new Chain(node, sourcesContentByPath);
return node.isOriginalSource ? null : new _Chain(node, sourcesContentByPath);
}

@@ -644,3 +651,3 @@

var node = new Node({ file: file });
var node = new _Node({ file: file });

@@ -647,0 +654,0 @@ var sourcesContentByPath = {};

{
"name": "sorcery",
"description": "Resolve a chain of sourcemaps back to the original source",
"version": "0.5.0",
"version": "0.5.1",
"author": "Rich Harris",

@@ -17,14 +17,13 @@ "repository": "https://github.com/Rich-Harris/sorcery",

"devDependencies": {
"coffee-script": "^1.8.0",
"babel": "^5.1.10",
"browserify": "^9.0.8",
"coffee-script": "^1.9.2",
"esperanto": "^0.6.29",
"gobble": "^0.7.12",
"gobble-babel": "^5.0.0",
"gobble-browserify": "^0.2.0",
"gobble-coffee": "^0.2.1",
"gobble-esperanto": "^0.2.4",
"gobble-esperanto-bundle": "^0.1.7",
"gobble-uglifyjs": "^0.2.0",
"mocha": "^2.1.0",
"promise-map-series": "^0.2.1",
"source-map": "^0.1.40",
"uglify-js": "^2.4.15"
"uglify-js": "^2.4.20"
},

@@ -31,0 +30,0 @@ "bin": {

@@ -66,2 +66,29 @@ # sorcery.js

#### Advanced options
You can pass an optional second argument to `sorcery.load()` and `sorcery.loadSync()`, with zero or more of the following properties:
* `content` - a map of `filename: contents` pairs. `filename` will be resolved against the current working directory if needs be
* `sourcemaps` - a map of `filename: sourcemap` pairs, where `filename` is the name of the file the sourcemap is related to. This will override any `sourceMappingURL` comments in the file itself.
For example:
```js
sorcery.load( 'some/generated/code.min.js', {
content: {
'some/minified/code.min.js': '...',
'some/transpiled/code.js': '...',
'some/original/code.js': '...'
},
sourcemaps: {
'some/minified/code.min.js': {...},
'some/transpiled/code.js': {...}
}
}).then( chain => {
/* ... */
});
```
Any files not found will be read from the filesystem as normal.
### On the command line

@@ -68,0 +95,0 @@

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