Comparing version 0.6.3 to 0.6.4
# changelog | ||
## 0.6.4 | ||
* Update dependencies | ||
* General tidy-up | ||
## 0.6.3 | ||
@@ -4,0 +9,0 @@ |
@@ -8,4 +8,4 @@ 'use strict'; | ||
var SOURCEMAPPING_URL = 'sourceMa'; | ||
SOURCEMAPPING_URL += 'ppingURL'; | ||
var _SOURCEMAPPING_URL = 'sourceMa'; | ||
_SOURCEMAPPING_URL += 'ppingURL'; | ||
@@ -17,10 +17,10 @@ function sourcemapComment(url, dest) { | ||
if (ext === '.css') { | ||
return '\n/*# ' + SOURCEMAPPING_URL + '=' + url + ' */\n'; | ||
return '\n/*# ' + _SOURCEMAPPING_URL + '=' + url + ' */\n'; | ||
} | ||
return '\n//# ' + SOURCEMAPPING_URL + '=' + url + '\n'; | ||
return '\n//# ' + _SOURCEMAPPING_URL + '=' + url + '\n'; | ||
} | ||
var SOURCEMAP_COMMENT = new RegExp('\n*(?:' + ('\\/\\/[@#]\\s*' + SOURCEMAPPING_URL + '=([^\'"]+)|') + ( // js | ||
'\\/\\*#?\\s*' + SOURCEMAPPING_URL + '=([^\'"]+)\\s\\*\\/)') + // css | ||
var SOURCEMAP_COMMENT = new RegExp('\n*(?:' + ('\\/\\/[@#]\\s*' + _SOURCEMAPPING_URL + '=([^\'"]+)|') + ( // js | ||
'\\/\\*#?\\s*' + _SOURCEMAPPING_URL + '=([^\'"]+)\\s\\*\\/)') + // css | ||
'\\s*$', 'g'); | ||
@@ -45,4 +45,3 @@ | ||
function slash(path) { | ||
if (typeof path === 'string') return path.replace(/\\/g, '/'); | ||
return path; | ||
return typeof path === 'string' ? path.replace(/\\/g, '/') : path; | ||
} | ||
@@ -199,7 +198,7 @@ | ||
return { | ||
selfDecodingTime: this._stats.decodingTime / 1000000, | ||
totalDecodingTime: (this._stats.decodingTime + tally(this.node.sources, 'decodingTime')) / 1000000, | ||
selfDecodingTime: this._stats.decodingTime / 1e6, | ||
totalDecodingTime: (this._stats.decodingTime + tally(this.node.sources, 'decodingTime')) / 1e6, | ||
encodingTime: this._stats.encodingTime / 1000000, | ||
tracingTime: this._stats.tracingTime / 1000000, | ||
encodingTime: this._stats.encodingTime / 1e6, | ||
tracingTime: this._stats.tracingTime / 1e6, | ||
@@ -213,3 +212,3 @@ untraceable: this._stats.untraceable | ||
var options = arguments[0] === undefined ? {} : arguments[0]; | ||
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
@@ -274,3 +273,3 @@ var allNames = []; | ||
var tracingTime = process.hrtime(tracingStart); | ||
this._stats.tracingTime = 1000000000 * tracingTime[0] + tracingTime[1]; | ||
this._stats.tracingTime = 1e9 * tracingTime[0] + tracingTime[1]; | ||
@@ -281,3 +280,3 @@ // Encode mappings | ||
var encodingTime = process.hrtime(encodingStart); | ||
this._stats.encodingTime = 1000000000 * encodingTime[0] + encodingTime[1]; | ||
this._stats.encodingTime = 1e9 * encodingTime[0] + encodingTime[1]; | ||
@@ -350,6 +349,2 @@ var includeContent = options.includeContent !== false; | ||
function resolveSourcePath(node, sourceRoot, source) { | ||
return path.resolve(path.dirname(node.file), sourceRoot || '', source); | ||
} | ||
var cache = {}; | ||
@@ -484,6 +479,12 @@ | ||
// this looks ridiculous, but it prevents sourcemap tooling from mistaking | ||
// this for an actual sourceMappingURL | ||
var SOURCEMAPPING_URL = 'sourceMa'; | ||
SOURCEMAPPING_URL += 'ppingURL'; | ||
/** | ||
* Turns a sourceMappingURL into a sourcemap | ||
* @param {string} url - the URL (i.e. sourceMappingURL=url). Can | ||
be a base64-encoded data URI | ||
* @param {string} url - the sourceMappingURL. Can be a | ||
base64-encoded data URI | ||
* @param {string} base - the URL against which relative URLS | ||
@@ -501,3 +502,3 @@ should be resolved | ||
if (!match) { | ||
throw new Error('sourceMappingURL is not base64-encoded'); | ||
throw new Error(SOURCEMAPPING_URL + ' is not base64-encoded'); | ||
} | ||
@@ -523,3 +524,3 @@ | ||
// assume we want the last occurence | ||
index = str.lastIndexOf('sourceMappingURL='); | ||
index = str.lastIndexOf(SOURCEMAPPING_URL + '='); | ||
@@ -617,9 +618,11 @@ if (index === -1) { | ||
var decodingTime = process.hrtime(decodingStart); | ||
_this._stats.decodingTime = 1000000000 * decodingTime[0] + decodingTime[1]; | ||
_this._stats.decodingTime = 1e9 * decodingTime[0] + decodingTime[1]; | ||
var sourcesContent = map.sourcesContent || []; | ||
var sourceRoot = path.resolve(path.dirname(_this.file), map.sourceRoot || ''); | ||
_this.sources = map.sources.map(function (source, i) { | ||
return new Node({ | ||
file: source ? resolveSourcePath(_this, map.sourceRoot, source) : null, | ||
file: source ? path.resolve(sourceRoot, source) : null, | ||
content: sourcesContent[i] | ||
@@ -654,16 +657,20 @@ }); | ||
} else { | ||
this.map = map; | ||
this.mappings = decodeMappings(map.mappings); | ||
(function () { | ||
_this2.map = map; | ||
_this2.mappings = decodeMappings(map.mappings); | ||
sourcesContent = map.sourcesContent || []; | ||
sourcesContent = map.sourcesContent || []; | ||
this.sources = map.sources.map(function (source, i) { | ||
var node = new Node({ | ||
file: resolveSourcePath(_this2, map.sourceRoot, source), | ||
content: sourcesContent[i] | ||
var sourceRoot = path.resolve(path.dirname(_this2.file), map.sourceRoot || ''); | ||
_this2.sources = map.sources.map(function (source, i) { | ||
var node = new Node({ | ||
file: path.resolve(sourceRoot, source), | ||
content: sourcesContent[i] | ||
}); | ||
node.loadSync(sourcesContentByPath, sourceMapByPath); | ||
return node; | ||
}); | ||
node.loadSync(sourcesContentByPath, sourceMapByPath); | ||
return node; | ||
}); | ||
})(); | ||
} | ||
@@ -758,3 +765,3 @@ }; | ||
function loadSync(file) { | ||
var options = arguments[1] === undefined ? {} : arguments[1]; | ||
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
@@ -772,3 +779,3 @@ var _init2 = init(file, options); | ||
function init(file) { | ||
var options = arguments[1] === undefined ? {} : arguments[1]; | ||
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
@@ -796,2 +803,3 @@ var node = new Node({ file: file }); | ||
exports.load = load; | ||
exports.loadSync = loadSync; | ||
exports.loadSync = loadSync; | ||
//# sourceMappingURL=sorcery.js.map |
{ | ||
"name": "sorcery", | ||
"description": "Resolve a chain of sourcemaps back to the original source", | ||
"version": "0.6.3", | ||
"version": "0.6.4", | ||
"author": "Rich Harris", | ||
@@ -13,3 +13,3 @@ "repository": "https://github.com/Rich-Harris/sorcery", | ||
"minimist": "^1.1.0", | ||
"sander": "^0.2.2", | ||
"sander": "^0.3.8", | ||
"vlq": "^0.2.1" | ||
@@ -19,14 +19,18 @@ }, | ||
"babel": "^5.1.10", | ||
"browserify": "^9.0.8", | ||
"browserify": "^11.2.0", | ||
"codecov.io": "^0.1.6", | ||
"coffee-script": "^1.9.2", | ||
"esperanto": "^0.6.29", | ||
"eslint": "^1.5.1", | ||
"esperanto": "^0.7.5", | ||
"gobble": "^0.10.1", | ||
"gobble-babel": "^5.0.0", | ||
"gobble-cli": "^0.4.2", | ||
"gobble-rollup": "^0.3.0", | ||
"gobble-cli": "^0.5.0", | ||
"gobble-rollup": "^0.10.0", | ||
"istanbul": "^0.3.22", | ||
"less": "^2.5.0", | ||
"mocha": "^2.1.0", | ||
"promise-map-series": "^0.2.1", | ||
"source-map": "^0.1.40", | ||
"source-map-support": "^0.2.10", | ||
"remap-istanbul": "^0.3.0", | ||
"source-map": "^0.5.1", | ||
"source-map-support": "^0.3.2", | ||
"uglify-js": "^2.4.20" | ||
@@ -42,3 +46,8 @@ }, | ||
"test": "mocha", | ||
"prepublish": "npm test" | ||
"prepublish": "npm test", | ||
"lint": "eslint src", | ||
"pretest-coverage": "npm run build", | ||
"test-coverage": "rm -rf coverage/* && istanbul cover --report json node_modules/.bin/_mocha -- -u exports -R spec test/test.js", | ||
"posttest-coverage": "remap-istanbul -i coverage/coverage-final.json -o coverage/coverage-remapped.json -b dist && remap-istanbul -i coverage/coverage-final.json -o coverage/coverage-remapped.lcov -t lcovonly -b dist && remap-istanbul -i coverage/coverage-final.json -o coverage/coverage-remapped -t html -b dist", | ||
"ci": "npm run test-coverage && codecov < coverage/coverage-remapped.lcov" | ||
}, | ||
@@ -45,0 +54,0 @@ "files": [ |
@@ -46,5 +46,7 @@ import { dirname, resolve } from 'path'; | ||
const sourceRoot = resolve( dirname( this.file ), map.sourceRoot || '' ); | ||
this.sources = map.sources.map( ( source, i ) => { | ||
return new Node({ | ||
file: source ? resolveSourcePath( this, map.sourceRoot, source ) : null, | ||
file: source ? resolve( sourceRoot, source ) : null, | ||
content: sourcesContent[i] | ||
@@ -80,5 +82,7 @@ }); | ||
const sourceRoot = resolve( dirname( this.file ), map.sourceRoot || '' ); | ||
this.sources = map.sources.map( ( source, i ) => { | ||
const node = new Node({ | ||
file: resolveSourcePath( this, map.sourceRoot, source ), | ||
file: resolve( sourceRoot, source ), | ||
content: sourcesContent[i] | ||
@@ -174,5 +178,1 @@ }); | ||
} | ||
function resolveSourcePath ( node, sourceRoot, source ) { | ||
return resolve( dirname( node.file ), sourceRoot || '', source ); | ||
} |
import { dirname, resolve } from 'path'; | ||
import { readFile, readFileSync, Promise } from 'sander'; | ||
import atob from './atob'; | ||
import SOURCEMAPPING_URL from './sourceMappingURL'; | ||
/** | ||
* Turns a sourceMappingURL into a sourcemap | ||
* @param {string} url - the URL (i.e. sourceMappingURL=url). Can | ||
be a base64-encoded data URI | ||
* @param {string} url - the sourceMappingURL. Can be a | ||
base64-encoded data URI | ||
* @param {string} base - the URL against which relative URLS | ||
@@ -20,3 +21,3 @@ should be resolved | ||
if ( !match ) { | ||
throw new Error( 'sourceMappingURL is not base64-encoded' ); | ||
throw new Error( `${SOURCEMAPPING_URL} is not base64-encoded` ); | ||
} | ||
@@ -23,0 +24,0 @@ |
@@ -0,1 +1,3 @@ | ||
import SOURCEMAPPING_URL from './sourceMappingURL'; | ||
export default function getSourceMappingUrl ( str ) { | ||
@@ -5,3 +7,3 @@ var index, substring, url, match; | ||
// assume we want the last occurence | ||
index = str.lastIndexOf( 'sourceMappingURL=' ); | ||
index = str.lastIndexOf( `${SOURCEMAPPING_URL}=` ); | ||
@@ -24,2 +26,2 @@ if ( index === -1 ) { | ||
return url; | ||
} | ||
} |
@@ -1,5 +0,5 @@ | ||
export default function slash(path) { | ||
if (typeof path === 'string') | ||
return path.replace(/\\/g, '/'); | ||
return path; | ||
} | ||
export default function slash ( path ) { | ||
return typeof path === 'string' ? | ||
path.replace( /\\/g, '/' ) : | ||
path; | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
91742
21
1171
18
+ Addedsander@0.3.8(transitive)
- Removedsander@0.2.4(transitive)
Updatedsander@^0.3.8