rdrew
6 years ago
13191 changed files with 1302410 additions and 114 deletions
@ -0,0 +1,8 @@ |
|||||||
|
# Ignore the node modules folder (created by 'npm install'). |
||||||
|
node_modules |
||||||
|
|
||||||
|
# We absolutely don't want to have the .sass-cache in git. |
||||||
|
.sass-cache |
||||||
|
.DS_Store |
||||||
|
|
||||||
|
*.swo |
File diff suppressed because one or more lines are too long
@ -1,58 +1,89 @@ |
|||||||
var gulp = require('gulp'), |
'use strict'; |
||||||
plumber = require('gulp-plumber'), |
|
||||||
rename = require('gulp-rename'); |
var gulp = require('gulp'); |
||||||
|
var browserSync = require('browser-sync').create(); |
||||||
|
var imagemin = require('gulp-imagemin'); |
||||||
|
var plumber = require('gulp-plumber'); |
||||||
|
var sass = require('gulp-sass'); |
||||||
var autoprefixer = require('gulp-autoprefixer'); |
var autoprefixer = require('gulp-autoprefixer'); |
||||||
|
var sourcemaps = require('gulp-sourcemaps'); |
||||||
var concat = require('gulp-concat'); |
var concat = require('gulp-concat'); |
||||||
var imagemin = require('gulp-imagemin'), |
//var cache = require('gulp-cache');
|
||||||
cache = require('gulp-cache'); |
|
||||||
var sass = require('gulp-sass'); |
|
||||||
var browserSync = require('browser-sync'); |
//===================
|
||||||
|
// Browsersync Proxy
|
||||||
|
//===================
|
||||||
|
|
||||||
gulp.task('browser-sync', function() { |
gulp.task('browser-sync', function() { |
||||||
browserSync({ |
browserSync.init({ |
||||||
server: { |
proxy: "https://lmmijournal.researchspaces.ca", |
||||||
baseDir: "./" |
serveStatic: ['.'], |
||||||
} |
files: ['./css/style.css','./js/js.js'], |
||||||
}); |
plugins: ['bs-rewrite-rules'], |
||||||
|
rewriteRules: [ |
||||||
|
{ |
||||||
|
match: '/themes/custom/lmmi_journal', |
||||||
|
replace: '' |
||||||
|
} |
||||||
|
] |
||||||
|
}); |
||||||
}); |
}); |
||||||
|
|
||||||
gulp.task('bs-reload', function () { |
|
||||||
browserSync.reload(); |
|
||||||
}); |
|
||||||
|
|
||||||
gulp.task('images', function(){ |
//====================
|
||||||
gulp.src('src/img/**/*') |
// Sass Compilation
|
||||||
.pipe(cache(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true }))) |
//===================
|
||||||
.pipe(gulp.dest('img/')); |
|
||||||
|
gulp.task('sass', function () { |
||||||
|
return gulp.src('./src/scss/**/*.scss') |
||||||
|
.pipe(sourcemaps.init()) |
||||||
|
.pipe(sass().on('error', sass.logError)) |
||||||
|
.pipe(sourcemaps.write()) |
||||||
|
.pipe(gulp.dest('./css')); |
||||||
}); |
}); |
||||||
|
|
||||||
gulp.task('styles', function(){ |
//====================
|
||||||
gulp.src(['src/scss/**/*.scss']) |
// JS Concatination
|
||||||
.pipe(plumber({ |
//===================
|
||||||
errorHandler: function (error) { |
|
||||||
console.log(error.message); |
gulp.task('js', function () { |
||||||
this.emit('end'); |
gulp.src('./src/js/*.js') // path to your files
|
||||||
}})) |
.pipe(concat('js.js')) // concat and name it "concat.js"
|
||||||
.pipe(sass()) |
.pipe(gulp.dest('./js/')); |
||||||
.pipe(autoprefixer('last 2 versions')) |
|
||||||
.pipe(gulp.dest('css/')) |
|
||||||
.pipe(browserSync.reload({stream:true})) |
|
||||||
}); |
}); |
||||||
|
|
||||||
gulp.task('scripts', function(){ |
//====================
|
||||||
return gulp.src('src/js/**/*.js') |
// Image Optimization
|
||||||
.pipe(plumber({ |
//===================
|
||||||
errorHandler: function (error) { |
|
||||||
console.log(error.message); |
gulp.task('images', function(){ |
||||||
this.emit('end'); |
gulp.src('src/img/**/*') |
||||||
}})) |
//.pipe(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true }))
|
||||||
.pipe(concat('main.js')) |
.pipe(imagemin([ |
||||||
.pipe(gulp.dest('js/')) |
imagemin.jpegtran({progressive: true}), |
||||||
.pipe(browserSync.reload({stream:true})) |
imagemin.optipng({optimizationLevel: 5}), |
||||||
|
imagemin.svgo({ |
||||||
|
plugins: [ |
||||||
|
{removeViewBox: true}, |
||||||
|
{cleanupIDs: false} |
||||||
|
] |
||||||
|
}) |
||||||
|
])) |
||||||
|
.pipe(gulp.dest('img/')); |
||||||
}); |
}); |
||||||
|
|
||||||
gulp.task('default', ['browser-sync'], function(){ |
//==================
|
||||||
gulp.watch("src/scss/**/*.scss", ['styles']); |
// Default Gulp Task
|
||||||
gulp.watch("src/js/**/*.js", ['scripts']); |
//=================
|
||||||
gulp.watch("*.html", ['bs-reload']); |
|
||||||
|
gulp.task ('default',['browser-sync'], function(){ |
||||||
|
//watch sass folder and compile changes
|
||||||
|
gulp.watch('src/scss/**/*.scss', ['sass']); |
||||||
|
//watch js folder and compile changes
|
||||||
|
gulp.watch('src/js/**/*.js', ['js']); |
||||||
|
//watch image folder and optimize
|
||||||
|
gulp.watch('src/img/**/*', ['images']); |
||||||
}); |
}); |
||||||
|
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 864 KiB After Width: | Height: | Size: 822 KiB |
@ -0,0 +1,49 @@ |
|||||||
|
(function ($, Drupal) { |
||||||
|
|
||||||
|
Drupal.behaviors.myAwesomeJs = { |
||||||
|
attach: function attach(context, settings) { |
||||||
|
//js goes here
|
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
})(jQuery, Drupal); |
@ -0,0 +1 @@ |
|||||||
|
../autoprefixer/bin/autoprefixer |
@ -0,0 +1 @@ |
|||||||
|
../bin-version-check/cli.js |
@ -0,0 +1 @@ |
|||||||
|
../browser-sync/dist/bin.js |
@ -0,0 +1 @@ |
|||||||
|
../browserslist/cli.js |
@ -0,0 +1 @@ |
|||||||
|
../color-support/bin.js |
@ -0,0 +1 @@ |
|||||||
|
../dev-ip/lib/dev-ip.js |
@ -0,0 +1 @@ |
|||||||
|
../esprima/bin/esparse.js |
@ -0,0 +1 @@ |
|||||||
|
../esprima/bin/esvalidate.js |
@ -0,0 +1 @@ |
|||||||
|
../executable/cli.js |
@ -0,0 +1 @@ |
|||||||
|
../find-versions/cli.js |
@ -0,0 +1 @@ |
|||||||
|
../in-publish/in-install.js |
@ -0,0 +1 @@ |
|||||||
|
../in-publish/in-publish.js |
@ -0,0 +1 @@ |
|||||||
|
../jpegtran-bin/cli.js |
@ -0,0 +1 @@ |
|||||||
|
../js-yaml/bin/js-yaml.js |
@ -0,0 +1 @@ |
|||||||
|
../lpad-align/cli.js |
@ -0,0 +1 @@ |
|||||||
|
../node-gyp/bin/node-gyp.js |
@ -0,0 +1 @@ |
|||||||
|
../node-sass/bin/node-sass |
@ -0,0 +1 @@ |
|||||||
|
../in-publish/not-in-install.js |
@ -0,0 +1 @@ |
|||||||
|
../in-publish/not-in-publish.js |
@ -0,0 +1 @@ |
|||||||
|
../optipng-bin/cli.js |
@ -0,0 +1 @@ |
|||||||
|
../sass-graph/bin/sassgraph |
@ -0,0 +1 @@ |
|||||||
|
../seek-bzip/bin/seek-bunzip |
@ -0,0 +1 @@ |
|||||||
|
../seek-bzip/bin/seek-bzip-table |
@ -0,0 +1 @@ |
|||||||
|
../sshpk/bin/sshpk-conv |
@ -0,0 +1 @@ |
|||||||
|
../sshpk/bin/sshpk-sign |
@ -0,0 +1 @@ |
|||||||
|
../sshpk/bin/sshpk-verify |
@ -0,0 +1 @@ |
|||||||
|
../strip-dirs/cli.js |
@ -0,0 +1 @@ |
|||||||
|
../strip-indent/cli.js |
@ -0,0 +1 @@ |
|||||||
|
../stream-throttle/bin/throttleproxy.js |
@ -0,0 +1 @@ |
|||||||
|
../user-home/cli.js |
@ -0,0 +1 @@ |
|||||||
|
../window-size/cli.js |
@ -0,0 +1,21 @@ |
|||||||
|
The MIT License (MIT) |
||||||
|
|
||||||
|
Copyright (c) 2017 Blaine Bublitz <blaine.bublitz@gmail.com> |
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||||
|
of this software and associated documentation files (the "Software"), to deal |
||||||
|
in the Software without restriction, including without limitation the rights |
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||||
|
copies of the Software, and to permit persons to whom the Software is |
||||||
|
furnished to do so, subject to the following conditions: |
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all |
||||||
|
copies or substantial portions of the Software. |
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||||
|
SOFTWARE. |
@ -0,0 +1,40 @@ |
|||||||
|
# @gulp-sourcemaps/identity-map |
||||||
|
|
||||||
|
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] |
||||||
|
|
||||||
|
Gulp plugin for generating an identity sourcemap for a file. |
||||||
|
|
||||||
|
## Example |
||||||
|
|
||||||
|
```js |
||||||
|
var identityMap = require('@gulp-sourcemaps/identity-map'); |
||||||
|
|
||||||
|
gulp.src(...) |
||||||
|
.pipe(sourcemaps.init()) |
||||||
|
.pipe(identityMap()) // .js and .css files will get a generated sourcemap |
||||||
|
.pipe(sourcemaps.write()) |
||||||
|
.pipe(gulp.dest(...)) |
||||||
|
``` |
||||||
|
|
||||||
|
## API |
||||||
|
|
||||||
|
### `identityMap()` |
||||||
|
|
||||||
|
Returns an `objectMode` Transform stream that processes each file with a `.sourceMap` property and buffered contents. A sourcemap is generated and attached for each `.js` and `.css` file. |
||||||
|
|
||||||
|
## License |
||||||
|
|
||||||
|
MIT |
||||||
|
|
||||||
|
[downloads-image]: http://img.shields.io/npm/dm/@gulp-sourcemaps/identity-map.svg |
||||||
|
[npm-url]: https://npmjs.org/package/@gulp-sourcemaps/identity-map |
||||||
|
[npm-image]: http://img.shields.io/npm/v/@gulp-sourcemaps/identity-map.svg |
||||||
|
|
||||||
|
[travis-url]: https://travis-ci.org/gulp-sourcemaps/identity-map |
||||||
|
[travis-image]: http://img.shields.io/travis/gulp-sourcemaps/identity-map.svg?label=travis-ci |
||||||
|
|
||||||
|
[appveyor-url]: https://ci.appveyor.com/project/phated/identity-map |
||||||
|
[appveyor-image]: https://img.shields.io/appveyor/ci/phated/identity-map.svg?label=appveyor |
||||||
|
|
||||||
|
[coveralls-url]: https://coveralls.io/r/gulp-sourcemaps/identity-map |
||||||
|
[coveralls-image]: http://img.shields.io/coveralls/gulp-sourcemaps/identity-map.svg |
@ -0,0 +1,35 @@ |
|||||||
|
'use strict'; |
||||||
|
|
||||||
|
var through = require('through2'); |
||||||
|
var normalizePath = require('normalize-path'); |
||||||
|
|
||||||
|
var generate = require('./lib/generate'); |
||||||
|
|
||||||
|
function identityMap() { |
||||||
|
|
||||||
|
function transform(file, _, cb) { |
||||||
|
if (!file.sourceMap || !file.isBuffer()) { |
||||||
|
return cb(null, file); |
||||||
|
} |
||||||
|
|
||||||
|
var sourcePath = normalizePath(file.relative); |
||||||
|
var contents = file.contents.toString(); |
||||||
|
|
||||||
|
switch (file.extname) { |
||||||
|
case '.js': { |
||||||
|
file.sourceMap = generate.js(sourcePath, contents); |
||||||
|
break; |
||||||
|
} |
||||||
|
case '.css': { |
||||||
|
file.sourceMap = generate.css(sourcePath, contents); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
cb(null, file); |
||||||
|
} |
||||||
|
|
||||||
|
return through.obj(transform); |
||||||
|
} |
||||||
|
|
||||||
|
module.exports = identityMap; |
@ -0,0 +1,65 @@ |
|||||||
|
'use strict'; |
||||||
|
|
||||||
|
var css = require('css'); |
||||||
|
var acorn = require('acorn'); |
||||||
|
var SourceMapGenerator = require('source-map').SourceMapGenerator; |
||||||
|
|
||||||
|
function generateJs(sourcePath, fileContent) { |
||||||
|
var generator = new SourceMapGenerator({ file: sourcePath }); |
||||||
|
var tokenizer = acorn.tokenizer(fileContent, { allowHashBang: true, locations: true }); |
||||||
|
|
||||||
|
while (true) { |
||||||
|
var token = tokenizer.getToken(); |
||||||
|
|
||||||
|
if (token.type.label === 'eof') { |
||||||
|
break; |
||||||
|
} |
||||||
|
var mapping = { |
||||||
|
original: token.loc.start, |
||||||
|
generated: token.loc.start, |
||||||
|
source: sourcePath, |
||||||
|
}; |
||||||
|
if (token.type.label === 'name') { |
||||||
|
mapping.name = token.value; |
||||||
|
} |
||||||
|
generator.addMapping(mapping); |
||||||
|
} |
||||||
|
generator.setSourceContent(sourcePath, fileContent); |
||||||
|
|
||||||
|
return generator.toJSON(); |
||||||
|
} |
||||||
|
|
||||||
|
function generateCss(sourcePath, fileContent) { |
||||||
|
var generator = new SourceMapGenerator({ file: sourcePath }); |
||||||
|
var ast = css.parse(fileContent, { silent: true }); |
||||||
|
|
||||||
|
function registerTokens(ast) { |
||||||
|
if (ast.position) { |
||||||
|
generator.addMapping({ |
||||||
|
original: ast.position.start, |
||||||
|
generated: ast.position.start, |
||||||
|
source: sourcePath, |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
for (var key in ast) { |
||||||
|
if (key === 'position' || !ast[key]) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
if (Object.prototype.toString.call(ast[key]) === '[object Object]') { |
||||||
|
registerTokens(ast[key]); |
||||||
|
} else if (Array.isArray(ast[key])) { |
||||||
|
ast[key].forEach(registerTokens); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
registerTokens(ast); |
||||||
|
generator.setSourceContent(sourcePath, fileContent); |
||||||
|
|
||||||
|
return generator.toJSON(); |
||||||
|
} |
||||||
|
|
||||||
|
module.exports = { |
||||||
|
js: generateJs, |
||||||
|
css: generateCss, |
||||||
|
}; |
@ -0,0 +1,301 @@ |
|||||||
|
# Change Log |
||||||
|
|
||||||
|
## 0.5.6 |
||||||
|
|
||||||
|
* Fix for regression when people were using numbers as names in source maps. See |
||||||
|
#236. |
||||||
|
|
||||||
|
## 0.5.5 |
||||||
|
|
||||||
|
* Fix "regression" of unsupported, implementation behavior that half the world |
||||||
|
happens to have come to depend on. See #235. |
||||||
|
|
||||||
|
* Fix regression involving function hoisting in SpiderMonkey. See #233. |
||||||
|
|
||||||
|
## 0.5.4 |
||||||
|
|
||||||
|
* Large performance improvements to source-map serialization. See #228 and #229. |
||||||
|
|
||||||
|
## 0.5.3 |
||||||
|
|
||||||
|
* Do not include unnecessary distribution files. See |
||||||
|
commit ef7006f8d1647e0a83fdc60f04f5a7ca54886f86. |
||||||
|
|
||||||
|
## 0.5.2 |
||||||
|
|
||||||
|
* Include browser distributions of the library in package.json's `files`. See |
||||||
|
issue #212. |
||||||
|
|
||||||
|
## 0.5.1 |
||||||
|
|
||||||
|
* Fix latent bugs in IndexedSourceMapConsumer.prototype._parseMappings. See |
||||||
|
ff05274becc9e6e1295ed60f3ea090d31d843379. |
||||||
|
|
||||||
|
## 0.5.0 |
||||||
|
|
||||||
|
* Node 0.8 is no longer supported. |
||||||
|
|
||||||
|
* Use webpack instead of dryice for bundling. |
||||||
|
|
||||||
|
* Big speedups serializing source maps. See pull request #203. |
||||||
|
|
||||||
|
* Fix a bug with `SourceMapConsumer.prototype.sourceContentFor` and sources that |
||||||
|
explicitly start with the source root. See issue #199. |
||||||
|
|
||||||
|
## 0.4.4 |
||||||
|
|
||||||
|
* Fix an issue where using a `SourceMapGenerator` after having created a |
||||||
|
`SourceMapConsumer` from it via `SourceMapConsumer.fromSourceMap` failed. See |
||||||
|
issue #191. |
||||||
|
|
||||||
|
* Fix an issue with where `SourceMapGenerator` would mistakenly consider |
||||||
|
different mappings as duplicates of each other and avoid generating them. See |
||||||
|
issue #192. |
||||||
|
|
||||||
|
## 0.4.3 |
||||||
|
|
||||||
|
* A very large number of performance improvements, particularly when parsing |
||||||
|
source maps. Collectively about 75% of time shaved off of the source map |
||||||
|
parsing benchmark! |
||||||
|
|
||||||
|
* Fix a bug in `SourceMapConsumer.prototype.allGeneratedPositionsFor` and fuzzy |
||||||
|
searching in the presence of a column option. See issue #177. |
||||||
|
|
||||||
|
* Fix a bug with joining a source and its source root when the source is above |
||||||
|
the root. See issue #182. |
||||||
|
|
||||||
|
* Add the `SourceMapConsumer.prototype.hasContentsOfAllSources` method to |
||||||
|
determine when all sources' contents are inlined into the source map. See |
||||||
|
issue #190. |
||||||
|
|
||||||
|
## 0.4.2 |
||||||
|
|
||||||
|
* Add an `.npmignore` file so that the benchmarks aren't pulled down by |
||||||
|
dependent projects. Issue #169. |
||||||
|
|
||||||
|
* Add an optional `column` argument to |
||||||
|
`SourceMapConsumer.prototype.allGeneratedPositionsFor` and better handle lines |
||||||
|
with no mappings. Issues #172 and #173. |
||||||
|
|
||||||
|
## 0.4.1 |
||||||
|
|
||||||
|
* Fix accidentally defining a global variable. #170. |
||||||
|
|
||||||
|
## 0.4.0 |
||||||
|
|
||||||
|
* The default direction for fuzzy searching was changed back to its original |
||||||
|
direction. See #164. |
||||||
|
|
||||||
|
* There is now a `bias` option you can supply to `SourceMapConsumer` to control |
||||||
|
the fuzzy searching direction. See #167. |
||||||
|
|
||||||
|
* About an 8% speed up in parsing source maps. See #159. |
||||||
|
|
||||||
|
* Added a benchmark for parsing and generating source maps. |
||||||
|
|
||||||
|
## 0.3.0 |
||||||
|
|
||||||
|
* Change the default direction that searching for positions fuzzes when there is |
||||||
|
not an exact match. See #154. |
||||||
|
|
||||||
|
* Support for environments using json2.js for JSON serialization. See #156. |
||||||
|
|
||||||
|
## 0.2.0 |
||||||
|
|
||||||
|
* Support for consuming "indexed" source maps which do not have any remote |
||||||
|
sections. See pull request #127. This introduces a minor backwards |
||||||
|
incompatibility if you are monkey patching `SourceMapConsumer.prototype` |
||||||
|
methods. |
||||||
|
|
||||||
|
## 0.1.43 |
||||||
|
|
||||||
|
* Performance improvements for `SourceMapGenerator` and `SourceNode`. See issue |
||||||
|
#148 for some discussion and issues #150, #151, and #152 for implementations. |
||||||
|
|
||||||
|
## 0.1.42 |
||||||
|
|
||||||
|
* Fix an issue where `SourceNode`s from different versions of the source-map |
||||||
|
library couldn't be used in conjunction with each other. See issue #142. |
||||||
|
|
||||||
|
## 0.1.41 |
||||||
|
|
||||||
|
* Fix a bug with getting the source content of relative sources with a "./" |
||||||
|
prefix. See issue #145 and [Bug 1090768](bugzil.la/1090768). |
||||||
|
|
||||||
|
* Add the `SourceMapConsumer.prototype.computeColumnSpans` method to compute the |
||||||
|
column span of each mapping. |
||||||
|
|
||||||
|
* Add the `SourceMapConsumer.prototype.allGeneratedPositionsFor` method to find |
||||||
|
all generated positions associated with a given original source and line. |
||||||
|
|
||||||
|
## 0.1.40 |
||||||
|
|
||||||
|
* Performance improvements for parsing source maps in SourceMapConsumer. |
||||||
|
|
||||||
|
## 0.1.39 |
||||||
|
|
||||||
|
* Fix a bug where setting a source's contents to null before any source content |
||||||
|
had been set before threw a TypeError. See issue #131. |
||||||
|
|
||||||
|
## 0.1.38 |
||||||
|
|
||||||
|
* Fix a bug where finding relative paths from an empty path were creating |
||||||
|
absolute paths. See issue #129. |
||||||
|
|
||||||
|
## 0.1.37 |
||||||
|
|
||||||
|
* Fix a bug where if the source root was an empty string, relative source paths |
||||||
|
would turn into absolute source paths. Issue #124. |
||||||
|
|
||||||
|
## 0.1.36 |
||||||
|
|
||||||
|
* Allow the `names` mapping property to be an empty string. Issue #121. |
||||||
|
|
||||||
|
## 0.1.35 |
||||||
|
|
||||||
|
* A third optional parameter was added to `SourceNode.fromStringWithSourceMap` |
||||||
|
to specify a path that relative sources in the second parameter should be |
||||||
|
relative to. Issue #105. |
||||||
|
|
||||||
|
* If no file property is given to a `SourceMapGenerator`, then the resulting |
||||||
|
source map will no longer have a `null` file property. The property will |
||||||
|
simply not exist. Issue #104. |
||||||
|
|
||||||
|
* Fixed a bug where consecutive newlines were ignored in `SourceNode`s. |
||||||
|
Issue #116. |
||||||
|
|
||||||
|
## 0.1.34 |
||||||
|
|
||||||
|
* Make `SourceNode` work with windows style ("\r\n") newlines. Issue #103. |
||||||
|
|
||||||
|
* Fix bug involving source contents and the |
||||||
|
`SourceMapGenerator.prototype.applySourceMap`. Issue #100. |
||||||
|
|
||||||
|
## 0.1.33 |
||||||
|
|
||||||
|
* Fix some edge cases surrounding path joining and URL resolution. |
||||||
|
|
||||||
|
* Add a third parameter for relative path to |
||||||
|
`SourceMapGenerator.prototype.applySourceMap`. |
||||||
|
|
||||||
|
* Fix issues with mappings and EOLs. |
||||||
|
|
||||||
|
## 0.1.32 |
||||||
|
|
||||||
|
* Fixed a bug where SourceMapConsumer couldn't handle negative relative columns |
||||||
|
(issue 92). |
||||||
|
|
||||||
|
* Fixed test runner to actually report number of failed tests as its process |
||||||
|
exit code. |
||||||
|
|
||||||
|
* Fixed a typo when reporting bad mappings (issue 87). |
||||||
|
|
||||||
|
## 0.1.31 |
||||||
|
|
||||||
|
* Delay parsing the mappings in SourceMapConsumer until queried for a source |
||||||
|
location. |
||||||
|
|
||||||
|
* Support Sass source maps (which at the time of writing deviate from the spec |
||||||
|
in small ways) in SourceMapConsumer. |
||||||
|
|
||||||
|
## 0.1.30 |
||||||
|
|
||||||
|
* Do not join source root with a source, when the source is a data URI. |
||||||
|
|
||||||
|
* Extend the test runner to allow running single specific test files at a time. |
||||||
|
|
||||||
|
* Performance improvements in `SourceNode.prototype.walk` and |
||||||
|
`SourceMapConsumer.prototype.eachMapping`. |
||||||
|
|
||||||
|
* Source map browser builds will now work inside Workers. |
||||||
|
|
||||||
|
* Better error messages when attempting to add an invalid mapping to a |
||||||
|
`SourceMapGenerator`. |
||||||
|
|
||||||
|
## 0.1.29 |
||||||
|
|
||||||
|
* Allow duplicate entries in the `names` and `sources` arrays of source maps |
||||||
|
(usually from TypeScript) we are parsing. Fixes github issue 72. |
||||||
|
|
||||||
|
## 0.1.28 |
||||||
|
|
||||||
|
* Skip duplicate mappings when creating source maps from SourceNode; github |
||||||
|
issue 75. |
||||||
|
|
||||||
|
## 0.1.27 |
||||||
|
|
||||||
|
* Don't throw an error when the `file` property is missing in SourceMapConsumer, |
||||||
|
we don't use it anyway. |
||||||
|
|
||||||
|
## 0.1.26 |
||||||
|
|
||||||
|
* Fix SourceNode.fromStringWithSourceMap for empty maps. Fixes github issue 70. |
||||||
|
|
||||||
|
## 0.1.25 |
||||||
|
|
||||||
|
* Make compatible with browserify |
||||||
|
|
||||||
|
## 0.1.24 |
||||||
|
|
||||||
|
* Fix issue with absolute paths and `file://` URIs. See |
||||||
|
https://bugzilla.mozilla.org/show_bug.cgi?id=885597 |
||||||
|
|
||||||
|
## 0.1.23 |
||||||
|
|
||||||
|
* Fix issue with absolute paths and sourcesContent, github issue 64. |
||||||
|
|
||||||
|
## 0.1.22 |
||||||
|
|
||||||
|
* Ignore duplicate mappings in SourceMapGenerator. Fixes github issue 21. |
||||||
|
|
||||||
|
## 0.1.21 |
||||||
|
|
||||||
|
* Fixed handling of sources that start with a slash so that they are relative to |
||||||
|
the source root's host. |
||||||
|
|
||||||
|
## 0.1.20 |
||||||
|
|
||||||
|
* Fixed github issue #43: absolute URLs aren't joined with the source root |
||||||
|
anymore. |
||||||
|
|
||||||
|
## 0.1.19 |
||||||
|
|
||||||
|
* Using Travis CI to run tests. |
||||||
|
|
||||||
|
## 0.1.18 |
||||||
|
|
||||||
|
* Fixed a bug in the handling of sourceRoot. |
||||||
|
|
||||||
|
## 0.1.17 |
||||||
|
|
||||||
|
* Added SourceNode.fromStringWithSourceMap. |
||||||
|
|
||||||
|
## 0.1.16 |
||||||
|
|
||||||
|
* Added missing documentation. |
||||||
|
|
||||||
|
* Fixed the generating of empty mappings in SourceNode. |
||||||
|
|
||||||
|
## 0.1.15 |
||||||
|
|
||||||
|
* Added SourceMapGenerator.applySourceMap. |
||||||
|
|
||||||
|
## 0.1.14 |
||||||
|
|
||||||
|
* The sourceRoot is now handled consistently. |
||||||
|
|
||||||
|
## 0.1.13 |
||||||
|
|
||||||
|
* Added SourceMapGenerator.fromSourceMap. |
||||||
|
|
||||||
|
## 0.1.12 |
||||||
|
|
||||||
|
* SourceNode now generates empty mappings too. |
||||||
|
|
||||||
|
## 0.1.11 |
||||||
|
|
||||||
|
* Added name support to SourceNode. |
||||||
|
|
||||||
|
## 0.1.10 |
||||||
|
|
||||||
|
* Added sourcesContent support to the customer and generator. |
@ -0,0 +1,28 @@ |
|||||||
|
|
||||||
|
Copyright (c) 2009-2011, Mozilla Foundation and 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. |
||||||
|
|
||||||
|
* Neither the names of the Mozilla Foundation nor the names of project |
||||||
|
contributors may be used to endorse or promote products derived from this |
||||||
|
software without specific prior written permission. |
||||||
|
|
||||||
|
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 HOLDER 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. |
@ -0,0 +1,742 @@ |
|||||||
|
# Source Map |
||||||
|
|
||||||
|
[![Build Status](https://travis-ci.org/mozilla/source-map.png?branch=master)](https://travis-ci.org/mozilla/source-map) |
||||||
|
|
||||||
|
[![NPM](https://nodei.co/npm/source-map.png?downloads=true&downloadRank=true)](https://www.npmjs.com/package/source-map) |
||||||
|
|
||||||
|
This is a library to generate and consume the source map format |
||||||
|
[described here][format]. |
||||||
|
|
||||||
|
[format]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit |
||||||
|
|
||||||
|
## Use with Node |
||||||
|
|
||||||
|
$ npm install source-map |
||||||
|
|
||||||
|
## Use on the Web |
||||||
|
|
||||||
|
<script src="https://raw.githubusercontent.com/mozilla/source-map/master/dist/source-map.min.js" defer></script> |
||||||
|
|
||||||
|
-------------------------------------------------------------------------------- |
||||||
|
|
||||||
|
<!-- `npm run toc` to regenerate the Table of Contents --> |
||||||
|
|
||||||
|
<!-- START doctoc generated TOC please keep comment here to allow auto update --> |
||||||
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> |
||||||
|
## Table of Contents |
||||||
|
|
||||||
|
- [Examples](#examples) |
||||||
|
- [Consuming a source map](#consuming-a-source-map) |
||||||
|
- [Generating a source map](#generating-a-source-map) |
||||||
|
- [With SourceNode (high level API)](#with-sourcenode-high-level-api) |
||||||
|
- [With SourceMapGenerator (low level API)](#with-sourcemapgenerator-low-level-api) |
||||||
|
- [API](#api) |
||||||
|
- [SourceMapConsumer](#sourcemapconsumer) |
||||||
|
- [new SourceMapConsumer(rawSourceMap)](#new-sourcemapconsumerrawsourcemap) |
||||||
|
- [SourceMapConsumer.prototype.computeColumnSpans()](#sourcemapconsumerprototypecomputecolumnspans) |
||||||
|
- [SourceMapConsumer.prototype.originalPositionFor(generatedPosition)](#sourcemapconsumerprototypeoriginalpositionforgeneratedposition) |
||||||
|
- [SourceMapConsumer.prototype.generatedPositionFor(originalPosition)](#sourcemapconsumerprototypegeneratedpositionfororiginalposition) |
||||||
|
- [SourceMapConsumer.prototype.allGeneratedPositionsFor(originalPosition)](#sourcemapconsumerprototypeallgeneratedpositionsfororiginalposition) |
||||||
|
- [SourceMapConsumer.prototype.hasContentsOfAllSources()](#sourcemapconsumerprototypehascontentsofallsources) |
||||||
|
- [SourceMapConsumer.prototype.sourceContentFor(source[, returnNullOnMissing])](#sourcemapconsumerprototypesourcecontentforsource-returnnullonmissing) |
||||||
|
- [SourceMapConsumer.prototype.eachMapping(callback, context, order)](#sourcemapconsumerprototypeeachmappingcallback-context-order) |
||||||
|
- [SourceMapGenerator](#sourcemapgenerator) |
||||||
|
- [new SourceMapGenerator([startOfSourceMap])](#new-sourcemapgeneratorstartofsourcemap) |
||||||
|
- [SourceMapGenerator.fromSourceMap(sourceMapConsumer)](#sourcemapgeneratorfromsourcemapsourcemapconsumer) |
||||||
|
- [SourceMapGenerator.prototype.addMapping(mapping)](#sourcemapgeneratorprototypeaddmappingmapping) |
||||||
|
- [SourceMapGenerator.prototype.setSourceContent(sourceFile, sourceContent)](#sourcemapgeneratorprototypesetsourcecontentsourcefile-sourcecontent) |
||||||
|
- [SourceMapGenerator.prototype.applySourceMap(sourceMapConsumer[, sourceFile[, sourceMapPath]])](#sourcemapgeneratorprototypeapplysourcemapsourcemapconsumer-sourcefile-sourcemappath) |
||||||
|
- [SourceMapGenerator.prototype.toString()](#sourcemapgeneratorprototypetostring) |
||||||
|
- [SourceNode](#sourcenode) |
||||||
|
- [new SourceNode([line, column, source[, chunk[, name]]])](#new-sourcenodeline-column-source-chunk-name) |
||||||
|
- [SourceNode.fromStringWithSourceMap(code, sourceMapConsumer[, relativePath])](#sourcenodefromstringwithsourcemapcode-sourcemapconsumer-relativepath) |
||||||
|
- [SourceNode.prototype.add(chunk)](#sourcenodeprototypeaddchunk) |
||||||
|
- [SourceNode.prototype.prepend(chunk)](#sourcenodeprototypeprependchunk) |
||||||
|
- [SourceNode.prototype.setSourceContent(sourceFile, sourceContent)](#sourcenodeprototypesetsourcecontentsourcefile-sourcecontent) |
||||||
|
- [SourceNode.prototype.walk(fn)](#sourcenodeprototypewalkfn) |
||||||
|
- [SourceNode.prototype.walkSourceContents(fn)](#sourcenodeprototypewalksourcecontentsfn) |
||||||
|
- [SourceNode.prototype.join(sep)](#sourcenodeprototypejoinsep) |
||||||
|
- [SourceNode.prototype.replaceRight(pattern, replacement)](#sourcenodeprototypereplacerightpattern-replacement) |
||||||
|
- [SourceNode.prototype.toString()](#sourcenodeprototypetostring) |
||||||
|
- [SourceNode.prototype.toStringWithSourceMap([startOfSourceMap])](#sourcenodeprototypetostringwithsourcemapstartofsourcemap) |
||||||
|
|
||||||
|
<!-- END doctoc generated TOC please keep comment here to allow auto update --> |
||||||
|
|
||||||
|
## Examples |
||||||
|
|
||||||
|
### Consuming a source map |
||||||
|
|
||||||
|
```js |
||||||
|
var rawSourceMap = { |
||||||
|
version: 3, |
||||||
|
file: 'min.js', |
||||||
|
names: ['bar', 'baz', 'n'], |
||||||
|
sources: ['one.js', 'two.js'], |
||||||
|
sourceRoot: 'http://example.com/www/js/', |
||||||
|
mappings: 'CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA' |
||||||
|
}; |
||||||
|
|
||||||
|
var smc = new SourceMapConsumer(rawSourceMap); |
||||||
|
|
||||||
|
console.log(smc.sources); |
||||||
|
// [ 'http://example.com/www/js/one.js', |
||||||
|
// 'http://example.com/www/js/two.js' ] |
||||||
|
|
||||||
|
console.log(smc.originalPositionFor({ |
||||||
|
line: 2, |
||||||
|
column: 28 |
||||||
|
})); |
||||||
|
// { source: 'http://example.com/www/js/two.js', |
||||||
|
// line: 2, |
||||||
|
// column: 10, |
||||||
|
// name: 'n' } |
||||||
|
|
||||||
|
console.log(smc.generatedPositionFor({ |
||||||
|
source: 'http://example.com/www/js/two.js', |
||||||
|
line: 2, |
||||||
|
column: 10 |
||||||
|
})); |
||||||
|
// { line: 2, column: 28 } |
||||||
|
|
||||||
|
smc.eachMapping(function (m) { |
||||||
|
// ... |
||||||
|
}); |
||||||
|
``` |
||||||
|
|
||||||
|
### Generating a source map |
||||||
|
|
||||||
|
In depth guide: |
||||||
|
[**Compiling to JavaScript, and Debugging with Source Maps**](https://hacks.mozilla.org/2013/05/compiling-to-javascript-and-debugging-with-source-maps/) |
||||||
|
|
||||||
|
#### With SourceNode (high level API) |
||||||
|
|
||||||
|
```js |
||||||
|
function compile(ast) { |
||||||
|
switch (ast.type) { |
||||||
|
case 'BinaryExpression': |
||||||
|
return new SourceNode( |
||||||
|
ast.location.line, |
||||||
|
ast.location.column, |
||||||
|
ast.location.source, |
||||||
|
[compile(ast.left), " + ", compile(ast.right)] |
||||||
|
); |
||||||
|
case 'Literal': |
||||||
|
return new SourceNode( |
||||||
|
ast.location.line, |
||||||
|
ast.location.column, |
||||||
|
ast.location.source, |
||||||
|
String(ast.value) |
||||||
|
); |
||||||
|
// ... |
||||||
|
default: |
||||||
|
throw new Error("Bad AST"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
var ast = parse("40 + 2", "add.js"); |
||||||
|
console.log(compile(ast).toStringWithSourceMap({ |
||||||
|
file: 'add.js' |
||||||
|
})); |
||||||
|
// { code: '40 + 2', |
||||||
|
// map: [object SourceMapGenerator] } |
||||||
|
``` |
||||||
|
|
||||||
|
#### With SourceMapGenerator (low level API) |
||||||
|
|
||||||
|
```js |
||||||
|
var map = new SourceMapGenerator({ |
||||||
|
file: "source-mapped.js" |
||||||
|
}); |
||||||
|
|
||||||
|
map.addMapping({ |
||||||
|
generated: { |
||||||
|
line: 10, |
||||||
|
column: 35 |
||||||
|
}, |
||||||
|
source: "foo.js", |
||||||
|
original: { |
||||||
|
line: 33, |
||||||
|
column: 2 |
||||||
|
}, |
||||||
|
name: "christopher" |
||||||
|
}); |
||||||
|
|
||||||
|
console.log(map.toString()); |
||||||
|
// '{"version":3,"file":"source-mapped.js","sources":["foo.js"],"names":["christopher"],"mappings":";;;;;;;;;mCAgCEA"}' |
||||||
|
``` |
||||||
|
|
||||||
|
## API |
||||||
|
|
||||||
|
Get a reference to the module: |
||||||
|
|
||||||
|
```js |
||||||
|
// Node.js |
||||||
|
var sourceMap = require('source-map'); |
||||||
|
|
||||||
|
// Browser builds |
||||||
|
var sourceMap = window.sourceMap; |
||||||
|
|
||||||
|
// Inside Firefox |
||||||
|
const sourceMap = require("devtools/toolkit/sourcemap/source-map.js"); |
||||||
|
``` |
||||||
|
|
||||||
|
### SourceMapConsumer |
||||||
|
|
||||||
|
A SourceMapConsumer instance represents a parsed source map which we can query |
||||||
|
for information about the original file positions by giving it a file position |
||||||
|
in the generated source. |
||||||
|
|
||||||
|
#### new SourceMapConsumer(rawSourceMap) |
||||||
|
|
||||||
|
The only parameter is the raw source map (either as a string which can be |
||||||
|
`JSON.parse`'d, or an object). According to the spec, source maps have the |
||||||
|
following attributes: |
||||||
|
|
||||||
|
* `version`: Which version of the source map spec this map is following. |
||||||
|
|
||||||
|
* `sources`: An array of URLs to the original source files. |
||||||
|
|
||||||
|
* `names`: An array of identifiers which can be referenced by individual |
||||||
|
mappings. |
||||||
|
|
||||||
|
* `sourceRoot`: Optional. The URL root from which all sources are relative. |
||||||
|
|
||||||
|
* `sourcesContent`: Optional. An array of contents of the original source files. |
||||||
|
|
||||||
|
* `mappings`: A string of base64 VLQs which contain the actual mappings. |
||||||
|
|
||||||
|
* `file`: Optional. The generated filename this source map is associated with. |
||||||
|
|
||||||
|
```js |
||||||
|
var consumer = new sourceMap.SourceMapConsumer(rawSourceMapJsonData); |
||||||
|
``` |
||||||
|
|
||||||
|
#### SourceMapConsumer.prototype.computeColumnSpans() |
||||||
|
|
||||||
|
Compute the last column for each generated mapping. The last column is |
||||||
|
inclusive. |
||||||
|
|
||||||
|
```js |
||||||
|
// Before: |
||||||
|
consumer.allGeneratedPositionsFor({ line: 2, source: "foo.coffee" }) |
||||||
|
// [ { line: 2, |
||||||
|
// column: 1 }, |
||||||
|
// { line: 2, |
||||||
|
// column: 10 }, |
||||||
|
// { line: 2, |
||||||
|
// column: 20 } ] |
||||||
|
|
||||||
|
consumer.computeColumnSpans(); |
||||||
|
|
||||||
|
// After: |
||||||
|
consumer.allGeneratedPositionsFor({ line: 2, source: "foo.coffee" }) |
||||||
|
// [ { line: 2, |
||||||
|
// column: 1, |
||||||
|
// lastColumn: 9 }, |
||||||
|
// { line: 2, |
||||||
|
// column: 10, |
||||||
|
// lastColumn: 19 }, |
||||||
|
// { line: 2, |
||||||
|
// column: 20, |
||||||
|
// lastColumn: Infinity } ] |
||||||
|
|
||||||
|
``` |
||||||
|
|
||||||
|
#### SourceMapConsumer.prototype.originalPositionFor(generatedPosition) |
||||||
|
|
||||||
|
Returns the original source, line, and column information for the generated |
||||||
|
source's line and column positions provided. The only argument is an object with |
||||||
|
the following properties: |
||||||
|
|
||||||
|
* `line`: The line number in the generated source. Line numbers in |
||||||
|
this library are 1-based (note that the underlying source map |
||||||
|
specification uses 0-based line numbers -- this library handles the |
||||||
|
translation). |
||||||
|
|
||||||
|
* `column`: The column number in the generated source. Column numbers |
||||||
|
in this library are 0-based. |
||||||
|
|
||||||
|
* `bias`: Either `SourceMapConsumer.GREATEST_LOWER_BOUND` or |
||||||
|
`SourceMapConsumer.LEAST_UPPER_BOUND`. Specifies whether to return the closest |
||||||
|
element that is smaller than or greater than the one we are searching for, |
||||||
|
respectively, if the exact element cannot be found. Defaults to |
||||||
|
`SourceMapConsumer.GREATEST_LOWER_BOUND`. |
||||||
|
|
||||||
|
and an object is returned with the following properties: |
||||||
|
|
||||||
|
* `source`: The original source file, or null if this information is not |
||||||
|
available. |
||||||
|
|
||||||
|
* `line`: The line number in the original source, or null if this information is |
||||||
|
not available. The line number is 1-based. |
||||||
|
|
||||||
|
* `column`: The column number in the original source, or null if this |
||||||
|
information is not available. The column number is 0-based. |
||||||
|
|
||||||
|
* `name`: The original identifier, or null if this information is not available. |
||||||
|
|
||||||
|
```js |
||||||
|
consumer.originalPositionFor({ line: 2, column: 10 }) |
||||||
|
// { source: 'foo.coffee', |
||||||
|
// line: 2, |
||||||
|
// column: 2, |
||||||
|
// name: null } |
||||||
|
|
||||||
|
consumer.originalPositionFor({ line: 99999999999999999, column: 999999999999999 }) |
||||||
|
// { source: null, |
||||||
|
// line: null, |
||||||
|
// column: null, |
||||||
|
// name: null } |
||||||
|
``` |
||||||
|
|
||||||
|
#### SourceMapConsumer.prototype.generatedPositionFor(originalPosition) |
||||||
|
|
||||||
|
Returns the generated line and column information for the original source, |
||||||
|
line, and column positions provided. The only argument is an object with |
||||||
|
the following properties: |
||||||
|
|
||||||
|
* `source`: The filename of the original source. |
||||||
|
|
||||||
|
* `line`: The line number in the original source. The line number is |
||||||
|
1-based. |
||||||
|
|
||||||
|
* `column`: The column number in the original source. The column |
||||||
|
number is 0-based. |
||||||
|
|
||||||
|
and an object is returned with the following properties: |
||||||
|
|
||||||
|
* `line`: The line number in the generated source, or null. The line |
||||||
|
number is 1-based. |
||||||
|
|
||||||
|
* `column`: The column number in the generated source, or null. The |
||||||
|
column number is 0-based. |
||||||
|
|
||||||
|
```js |
||||||
|
consumer.generatedPositionFor({ source: "example.js", line: 2, column: 10 }) |
||||||
|
// { line: 1, |
||||||
|
// column: 56 } |
||||||
|
``` |
||||||
|
|
||||||
|
#### SourceMapConsumer.prototype.allGeneratedPositionsFor(originalPosition) |
||||||
|
|
||||||
|
Returns all generated line and column information for the original source, line, |
||||||
|
and column provided. If no column is provided, returns all mappings |
||||||
|
corresponding to a either the line we are searching for or the next closest line |
||||||
|
that has any mappings. Otherwise, returns all mappings corresponding to the |
||||||
|
given line and either the column we are searching for or the next closest column |
||||||
|
that has any offsets. |
||||||
|
|
||||||
|
The only argument is an object with the following properties: |
||||||
|
|
||||||
|
* `source`: The filename of the original source. |
||||||
|
|
||||||
|
* `line`: The line number in the original source. The line number is |
||||||
|
1-based. |
||||||
|
|
||||||
|
* `column`: Optional. The column number in the original source. The |
||||||
|
column number is 0-based. |
||||||
|
|
||||||
|
and an array of objects is returned, each with the following properties: |
||||||
|
|
||||||
|
* `line`: The line number in the generated source, or null. The line |
||||||
|
number is 1-based. |
||||||
|
|
||||||
|
* `column`: The column number in the generated source, or null. The |
||||||
|
column number is 0-based. |
||||||
|
|
||||||
|
```js |
||||||
|
consumer.allGeneratedpositionsfor({ line: 2, source: "foo.coffee" }) |
||||||
|
// [ { line: 2, |
||||||
|
// column: 1 }, |
||||||
|
// { line: 2, |
||||||
|
// column: 10 }, |
||||||
|
// { line: 2, |
||||||
|
// column: 20 } ] |
||||||
|
``` |
||||||
|
|
||||||
|
#### SourceMapConsumer.prototype.hasContentsOfAllSources() |
||||||
|
|
||||||
|
Return true if we have the embedded source content for every source listed in |
||||||
|
the source map, false otherwise. |
||||||
|
|
||||||
|
In other words, if this method returns `true`, then |
||||||
|
`consumer.sourceContentFor(s)` will succeed for every source `s` in |
||||||
|
`consumer.sources`. |
||||||
|
|
||||||
|
```js |
||||||
|
// ... |
||||||
|
if (consumer.hasContentsOfAllSources()) { |
||||||
|
consumerReadyCallback(consumer); |
||||||
|
} else { |
||||||
|
fetchSources(consumer, consumerReadyCallback); |
||||||
|
} |
||||||
|
// ... |
||||||
|
``` |
||||||
|
|
||||||
|
#### SourceMapConsumer.prototype.sourceContentFor(source[, returnNullOnMissing]) |
||||||
|
|
||||||
|
Returns the original source content for the source provided. The only |
||||||
|
argument is the URL of the original source file. |
||||||
|
|
||||||
|
If the source content for the given source is not found, then an error is |
||||||
|
thrown. Optionally, pass `true` as the second param to have `null` returned |
||||||
|
instead. |
||||||
|
|
||||||
|
```js |
||||||
|
consumer.sources |
||||||
|
// [ "my-cool-lib.clj" ] |
||||||
|
|
||||||
|
consumer.sourceContentFor("my-cool-lib.clj") |
||||||
|
// "..." |
||||||
|
|
||||||
|
consumer.sourceContentFor("this is not in the source map"); |
||||||
|
// Error: "this is not in the source map" is not in the source map |
||||||
|
|
||||||
|
consumer.sourceContentFor("this is not in the source map", true); |
||||||
|
// null |
||||||
|
``` |
||||||
|
|
||||||
|
#### SourceMapConsumer.prototype.eachMapping(callback, context, order) |
||||||
|
|
||||||
|
Iterate over each mapping between an original source/line/column and a |
||||||
|
generated line/column in this source map. |
||||||
|
|
||||||
|
* `callback`: The function that is called with each mapping. Mappings have the |
||||||
|
form `{ source, generatedLine, generatedColumn, originalLine, originalColumn, |
||||||
|
name }` |
||||||
|
|
||||||
|
* `context`: Optional. If specified, this object will be the value of `this` |
||||||
|
every time that `callback` is called. |
||||||
|
|
||||||
|
* `order`: Either `SourceMapConsumer.GENERATED_ORDER` or |
||||||
|
`SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to iterate over |
||||||
|
the mappings sorted by the generated file's line/column order or the |
||||||
|
original's source/line/column order, respectively. Defaults to |
||||||
|
`SourceMapConsumer.GENERATED_ORDER`. |
||||||
|
|
||||||
|
```js |
||||||
|
consumer.eachMapping(function (m) { console.log(m); }) |
||||||
|
// ... |
||||||
|
// { source: 'illmatic.js', |
||||||
|
// generatedLine: 1, |
||||||
|
// generatedColumn: 0, |
||||||
|
// originalLine: 1, |
||||||
|
// originalColumn: 0, |
||||||
|
// name: null } |
||||||
|
// { source: 'illmatic.js', |
||||||
|
// generatedLine: 2, |
||||||
|
// generatedColumn: 0, |
||||||
|
// originalLine: 2, |
||||||
|
// originalColumn: 0, |
||||||
|
// name: null } |
||||||
|
// ... |
||||||
|
``` |
||||||
|
### SourceMapGenerator |
||||||
|
|
||||||
|
An instance of the SourceMapGenerator represents a source map which is being |
||||||
|
built incrementally. |
||||||
|
|
||||||
|
#### new SourceMapGenerator([startOfSourceMap]) |
||||||
|
|
||||||
|
You may pass an object with the following properties: |
||||||
|
|
||||||
|
* `file`: The filename of the generated source that this source map is |
||||||
|
associated with. |
||||||
|
|
||||||
|
* `sourceRoot`: A root for all relative URLs in this source map. |
||||||
|
|
||||||
|
* `skipValidation`: Optional. When `true`, disables validation of mappings as |
||||||
|
they are added. This can improve performance but should be used with |
||||||
|
discretion, as a last resort. Even then, one should avoid using this flag when |
||||||
|
running tests, if possible. |
||||||
|
|
||||||
|
```js |
||||||
|
var generator = new sourceMap.SourceMapGenerator({ |
||||||
|
file: "my-generated-javascript-file.js", |
||||||
|
sourceRoot: "http://example.com/app/js/" |
||||||
|
}); |
||||||
|
``` |
||||||
|
|
||||||
|
#### SourceMapGenerator.fromSourceMap(sourceMapConsumer) |
||||||
|
|
||||||
|
Creates a new `SourceMapGenerator` from an existing `SourceMapConsumer` instance. |
||||||
|
|
||||||
|
* `sourceMapConsumer` The SourceMap. |
||||||
|
|
||||||
|
```js |
||||||
|
var generator = sourceMap.SourceMapGenerator.fromSourceMap(consumer); |
||||||
|
``` |
||||||
|
|
||||||
|
#### SourceMapGenerator.prototype.addMapping(mapping) |
||||||
|
|
||||||
|
Add a single mapping from original source line and column to the generated |
||||||
|
source's line and column for this source map being created. The mapping object |
||||||
|
should have the following properties: |
||||||
|
|
||||||
|
* `generated`: An object with the generated line and column positions. |
||||||
|
|
||||||
|
* `original`: An object with the original line and column positions. |
||||||
|
|
||||||
|
* `source`: The original source file (relative to the sourceRoot). |
||||||
|
|
||||||
|
* `name`: An optional original token name for this mapping. |
||||||
|
|
||||||
|
```js |
||||||
|
generator.addMapping({ |
||||||
|
source: "module-one.scm", |
||||||
|
original: { line: 128, column: 0 }, |
||||||
|
generated: { line: 3, column: 456 } |
||||||
|
}) |
||||||
|
``` |
||||||
|
|
||||||
|
#### SourceMapGenerator.prototype.setSourceContent(sourceFile, sourceContent) |
||||||
|
|
||||||
|
Set the source content for an original source file. |
||||||
|
|
||||||
|
* `sourceFile` the URL of the original source file. |
||||||
|
|
||||||
|
* `sourceContent` the content of the source file. |
||||||
|
|
||||||
|
```js |
||||||
|
generator.setSourceContent("module-one.scm", |
||||||
|
fs.readFileSync("path/to/module-one.scm")) |
||||||
|
``` |
||||||
|
|
||||||
|
#### SourceMapGenerator.prototype.applySourceMap(sourceMapConsumer[, sourceFile[, sourceMapPath]]) |
||||||
|
|
||||||
|
Applies a SourceMap for a source file to the SourceMap. |
||||||
|
Each mapping to the supplied source file is rewritten using the |
||||||
|
supplied SourceMap. Note: The resolution for the resulting mappings |
||||||
|
is the minimum of this map and the supplied map. |
||||||
|
|
||||||
|
* `sourceMapConsumer`: The SourceMap to be applied. |
||||||
|
|
||||||
|
* `sourceFile`: Optional. The filename of the source file. |
||||||
|
If omitted, sourceMapConsumer.file will be used, if it exists. |
||||||
|
Otherwise an error will be thrown. |
||||||
|
|
||||||
|
* `sourceMapPath`: Optional. The dirname of the path to the SourceMap |
||||||
|
to be applied. If relative, it is relative to the SourceMap. |
||||||
|
|
||||||
|
This parameter is needed when the two SourceMaps aren't in the same |
||||||
|
directory, and the SourceMap to be applied contains relative source |
||||||
|
paths. If so, those relative source paths need to be rewritten |
||||||
|
relative to the SourceMap. |
||||||
|
|
||||||
|
If omitted, it is assumed that both SourceMaps are in the same directory, |
||||||
|
thus not needing any rewriting. (Supplying `'.'` has the same effect.) |
||||||
|
|
||||||
|
#### SourceMapGenerator.prototype.toString() |
||||||
|
|
||||||
|
Renders the source map being generated to a string. |
||||||
|
|
||||||
|
```js |
||||||
|
generator.toString() |
||||||
|
// '{"version":3,"sources":["module-one.scm"],"names":[],"mappings":"...snip...","file":"my-generated-javascript-file.js","sourceRoot":"http://example.com/app/js/"}' |
||||||
|
``` |
||||||
|
|
||||||
|
### SourceNode |
||||||
|
|
||||||
|
SourceNodes provide a way to abstract over interpolating and/or concatenating |
||||||
|
snippets of generated JavaScript source code, while maintaining the line and |
||||||
|
column information associated between those snippets and the original source |
||||||
|
code. This is useful as the final intermediate representation a compiler might |
||||||
|
use before outputting the generated JS and source map. |
||||||
|
|
||||||
|
#### new SourceNode([line, column, source[, chunk[, name]]]) |
||||||
|
|
||||||
|
* `line`: The original line number associated with this source node, or null if |
||||||
|
it isn't associated with an original line. The line number is 1-based. |
||||||
|
|
||||||
|
* `column`: The original column number associated with this source node, or null |
||||||
|
if it isn't associated with an original column. The column number |
||||||
|
is 0-based. |
||||||
|
|
||||||
|
* `source`: The original source's filename; null if no filename is provided. |
||||||
|
|
||||||
|
* `chunk`: Optional. Is immediately passed to `SourceNode.prototype.add`, see |
||||||
|
below. |
||||||
|
|
||||||
|
* `name`: Optional. The original identifier. |
||||||
|
|
||||||
|
```js |
||||||
|
var node = new SourceNode(1, 2, "a.cpp", [ |
||||||
|
new SourceNode(3, 4, "b.cpp", "extern int status;\n"), |
||||||
|
new SourceNode(5, 6, "c.cpp", "std::string* make_string(size_t n);\n"), |
||||||
|
new SourceNode(7, 8, "d.cpp", "int main(int argc, char** argv) {}\n"), |
||||||
|
]); |
||||||
|
``` |
||||||
|
|
||||||
|
#### SourceNode.fromStringWithSourceMap(code, sourceMapConsumer[, relativePath]) |
||||||
|
|
||||||
|
Creates a SourceNode from generated code and a SourceMapConsumer. |
||||||
|
|
||||||
|
* `code`: The generated code |
||||||
|
|
||||||
|
* `sourceMapConsumer` The SourceMap for the generated code |
||||||
|
|
||||||
|
* `relativePath` The optional path that relative sources in `sourceMapConsumer` |
||||||
|
should be relative to. |
||||||
|
|
||||||
|
```js |
||||||
|
var consumer = new SourceMapConsumer(fs.readFileSync("path/to/my-file.js.map", "utf8")); |
||||||
|
var node = SourceNode.fromStringWithSourceMap(fs.readFileSync("path/to/my-file.js"), |
||||||
|
consumer); |
||||||
|
``` |
||||||
|
|
||||||
|
#### SourceNode.prototype.add(chunk) |
||||||
|
|
||||||
|
Add a chunk of generated JS to this source node. |
||||||
|
|
||||||
|
* `chunk`: A string snippet of generated JS code, another instance of |
||||||
|
`SourceNode`, or an array where each member is one of those things. |
||||||
|
|
||||||
|
```js |
||||||
|
node.add(" + "); |
||||||
|
node.add(otherNode); |
||||||
|
node.add([leftHandOperandNode, " + ", rightHandOperandNode]); |
||||||
|
``` |
||||||
|
|
||||||
|
#### SourceNode.prototype.prepend(chunk) |
||||||
|
|
||||||
|
Prepend a chunk of generated JS to this source node. |
||||||
|
|
||||||
|
* `chunk`: A string snippet of generated JS code, another instance of |
||||||
|
`SourceNode`, or an array where each member is one of those things. |
||||||
|
|
||||||
|
```js |
||||||
|
node.prepend("/** Build Id: f783haef86324gf **/\n\n"); |
||||||
|
``` |
||||||
|
|
||||||
|
#### SourceNode.prototype.setSourceContent(sourceFile, sourceContent) |
||||||
|
|
||||||
|
Set the source content for a source file. This will be added to the |
||||||
|
`SourceMap` in the `sourcesContent` field. |
||||||
|
|
||||||
|
* `sourceFile`: The filename of the source file |
||||||
|
|
||||||
|
* `sourceContent`: The content of the source file |
||||||
|
|
||||||
|
```js |
||||||
|
node.setSourceContent("module-one.scm", |
||||||
|
fs.readFileSync("path/to/module-one.scm")) |
||||||
|
``` |
||||||
|
|
||||||
|
#### SourceNode.prototype.walk(fn) |
||||||
|
|
||||||
|
Walk over the tree of JS snippets in this node and its children. The walking |
||||||
|
function is called once for each snippet of JS and is passed that snippet and |
||||||
|
the its original associated source's line/column location. |
||||||
|
|
||||||
|
* `fn`: The traversal function. |
||||||
|
|
||||||
|
```js |
||||||
|
var node = new SourceNode(1, 2, "a.js", [ |
||||||
|
new SourceNode(3, 4, "b.js", "uno"), |
||||||
|
"dos", |
||||||
|
[ |
||||||
|
"tres", |
||||||
|
new SourceNode(5, 6, "c.js", "quatro") |
||||||
|
] |
||||||
|
]); |
||||||
|
|
||||||
|
node.walk(function (code, loc) { console.log("WALK:", code, loc); }) |
||||||
|
// WALK: uno { source: 'b.js', line: 3, column: 4, name: null } |
||||||
|
// WALK: dos { source: 'a.js', line: 1, column: 2, name: null } |
||||||
|
// WALK: tres { source: 'a.js', line: 1, column: 2, name: null } |
||||||
|
// WALK: quatro { source: 'c.js', line: 5, column: 6, name: null } |
||||||
|
``` |
||||||
|
|
||||||
|
#### SourceNode.prototype.walkSourceContents(fn) |
||||||
|
|
||||||
|
Walk over the tree of SourceNodes. The walking function is called for each |
||||||
|
source file content and is passed the filename and source content. |
||||||
|
|
||||||
|
* `fn`: The traversal function. |
||||||
|
|
||||||
|
```js |
||||||
|
var a = new SourceNode(1, 2, "a.js", "generated from a"); |
||||||
|
a.setSourceContent("a.js", "original a"); |
||||||
|
var b = new SourceNode(1, 2, "b.js", "generated from b"); |
||||||
|
b.setSourceContent("b.js", "original b"); |
||||||
|
var c = new SourceNode(1, 2, "c.js", "generated from c"); |
||||||
|
c.setSourceContent("c.js", "original c"); |
||||||
|
|
||||||
|
var node = new SourceNode(null, null, null, [a, b, c]); |
||||||
|
node.walkSourceContents(function (source, contents) { console.log("WALK:", source, ":", contents); }) |
||||||
|
// WALK: a.js : original a |
||||||
|
// WALK: b.js : original b |
||||||
|
// WALK: c.js : original c |
||||||
|
``` |
||||||
|
|
||||||
|
#### SourceNode.prototype.join(sep) |
||||||
|
|
||||||
|
Like `Array.prototype.join` except for SourceNodes. Inserts the separator |
||||||
|
between each of this source node's children. |
||||||
|
|
||||||
|
* `sep`: The separator. |
||||||
|
|
||||||
|
```js |
||||||
|
var lhs = new SourceNode(1, 2, "a.rs", "my_copy"); |
||||||
|
var operand = new SourceNode(3, 4, "a.rs", "="); |
||||||
|
var rhs = new SourceNode(5, 6, "a.rs", "orig.clone()"); |
||||||
|
|
||||||
|
var node = new SourceNode(null, null, null, [ lhs, operand, rhs ]); |
||||||
|
var joinedNode = node.join(" "); |
||||||
|
``` |
||||||
|
|
||||||
|
#### SourceNode.prototype.replaceRight(pattern, replacement) |
||||||
|
|
||||||
|
Call `String.prototype.replace` on the very right-most source snippet. Useful |
||||||
|
for trimming white space from the end of a source node, etc. |
||||||
|
|
||||||
|
* `pattern`: The pattern to replace. |
||||||
|
|
||||||
|
* `replacement`: The thing to replace the pattern with. |
||||||
|
|
||||||
|
```js |
||||||
|
// Trim trailing white space. |
||||||
|
node.replaceRight(/\s*$/, ""); |
||||||
|
``` |
||||||
|
|
||||||
|
#### SourceNode.prototype.toString() |
||||||
|
|
||||||
|
Return the string representation of this source node. Walks over the tree and |
||||||
|
concatenates all the various snippets together to one string. |
||||||
|
|
||||||
|
```js |
||||||
|
var node = new SourceNode(1, 2, "a.js", [ |
||||||
|
new SourceNode(3, 4, "b.js", "uno"), |
||||||
|
"dos", |
||||||
|
[ |
||||||
|
"tres", |
||||||
|
new SourceNode(5, 6, "c.js", "quatro") |
||||||
|
] |
||||||
|
]); |
||||||
|
|
||||||
|
node.toString() |
||||||
|
// 'unodostresquatro' |
||||||
|
``` |
||||||
|
|
||||||
|
#### SourceNode.prototype.toStringWithSourceMap([startOfSourceMap]) |
||||||
|
|
||||||
|
Returns the string representation of this tree of source nodes, plus a |
||||||
|
SourceMapGenerator which contains all the mappings between the generated and |
||||||
|
original sources. |
||||||
|
|
||||||
|
The arguments are the same as those to `new SourceMapGenerator`. |
||||||
|
|
||||||
|
```js |
||||||
|
var node = new SourceNode(1, 2, "a.js", [ |
||||||
|
new SourceNode(3, 4, "b.js", "uno"), |
||||||
|
"dos", |
||||||
|
[ |
||||||
|
"tres", |
||||||
|
new SourceNode(5, 6, "c.js", "quatro") |
||||||
|
] |
||||||
|
]); |
||||||
|
|
||||||
|
node.toStringWithSourceMap({ file: "my-output-file.js" }) |
||||||
|
// { code: 'unodostresquatro', |
||||||
|
// map: [object SourceMapGenerator] } |
||||||
|
``` |
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,121 @@ |
|||||||
|
/* -*- Mode: js; js-indent-level: 2; -*- */ |
||||||
|
/* |
||||||
|
* Copyright 2011 Mozilla Foundation and contributors |
||||||
|
* Licensed under the New BSD license. See LICENSE or: |
||||||
|
* http://opensource.org/licenses/BSD-3-Clause
|
||||||
|
*/ |
||||||
|
|
||||||
|
var util = require('./util'); |
||||||
|
var has = Object.prototype.hasOwnProperty; |
||||||
|
var hasNativeMap = typeof Map !== "undefined"; |
||||||
|
|
||||||
|
/** |
||||||
|
* A data structure which is a combination of an array and a set. Adding a new |
||||||
|
* member is O(1), testing for membership is O(1), and finding the index of an |
||||||
|
* element is O(1). Removing elements from the set is not supported. Only |
||||||
|
* strings are supported for membership. |
||||||
|
*/ |
||||||
|
function ArraySet() { |
||||||
|
this._array = []; |
||||||
|
this._set = hasNativeMap ? new Map() : Object.create(null); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Static method for creating ArraySet instances from an existing array. |
||||||
|
*/ |
||||||
|
ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) { |
||||||
|
var set = new ArraySet(); |
||||||
|
for (var i = 0, len = aArray.length; i < len; i++) { |
||||||
|
set.add(aArray[i], aAllowDuplicates); |
||||||
|
} |
||||||
|
return set; |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Return how many unique items are in this ArraySet. If duplicates have been |
||||||
|
* added, than those do not count towards the size. |
||||||
|
* |
||||||
|
* @returns Number |
||||||
|
*/ |
||||||
|
ArraySet.prototype.size = function ArraySet_size() { |
||||||
|
return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length; |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Add the given string to this set. |
||||||
|
* |
||||||
|
* @param String aStr |
||||||
|
*/ |
||||||
|
ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) { |
||||||
|
var sStr = hasNativeMap ? aStr : util.toSetString(aStr); |
||||||
|
var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr); |
||||||
|
var idx = this._array.length; |
||||||
|
if (!isDuplicate || aAllowDuplicates) { |
||||||
|
this._array.push(aStr); |
||||||
|
} |
||||||
|
if (!isDuplicate) { |
||||||
|
if (hasNativeMap) { |
||||||
|
this._set.set(aStr, idx); |
||||||
|
} else { |
||||||
|
this._set[sStr] = idx; |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Is the given string a member of this set? |
||||||
|
* |
||||||
|
* @param String aStr |
||||||
|
*/ |
||||||
|
ArraySet.prototype.has = function ArraySet_has(aStr) { |
||||||
|
if (hasNativeMap) { |
||||||
|
return this._set.has(aStr); |
||||||
|
} else { |
||||||
|
var sStr = util.toSetString(aStr); |
||||||
|
return has.call(this._set, sStr); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* What is the index of the given string in the array? |
||||||
|
* |
||||||
|
* @param String aStr |
||||||
|
*/ |
||||||
|
ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) { |
||||||
|
if (hasNativeMap) { |
||||||
|
var idx = this._set.get(aStr); |
||||||
|
if (idx >= 0) { |
||||||
|
return idx; |
||||||
|
} |
||||||
|
} else { |
||||||
|
var sStr = util.toSetString(aStr); |
||||||
|
if (has.call(this._set, sStr)) { |
||||||
|
return this._set[sStr]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
throw new Error('"' + aStr + '" is not in the set.'); |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* What is the element at the given index? |
||||||
|
* |
||||||
|
* @param Number aIdx |
||||||
|
*/ |
||||||
|
ArraySet.prototype.at = function ArraySet_at(aIdx) { |
||||||
|
if (aIdx >= 0 && aIdx < this._array.length) { |
||||||
|
return this._array[aIdx]; |
||||||
|
} |
||||||
|
throw new Error('No element indexed by ' + aIdx); |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Returns the array representation of this set (which has the proper indices |
||||||
|
* indicated by indexOf). Note that this is a copy of the internal array used |
||||||
|
* for storing the members so that no one can mess with internal state. |
||||||
|
*/ |
||||||
|
ArraySet.prototype.toArray = function ArraySet_toArray() { |
||||||
|
return this._array.slice(); |
||||||
|
}; |
||||||
|
|
||||||
|
exports.ArraySet = ArraySet; |
@ -0,0 +1,140 @@ |
|||||||
|
/* -*- Mode: js; js-indent-level: 2; -*- */ |
||||||
|
/* |
||||||
|
* Copyright 2011 Mozilla Foundation and contributors |
||||||
|
* Licensed under the New BSD license. See LICENSE or: |
||||||
|
* http://opensource.org/licenses/BSD-3-Clause
|
||||||
|
* |
||||||
|
* Based on the Base 64 VLQ implementation in Closure Compiler: |
||||||
|
* https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
|
||||||
|
* |
||||||
|
* Copyright 2011 The Closure Compiler Authors. 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. |
||||||
|
* * Neither the name of Google Inc. nor the names of its |
||||||
|
* contributors may be used to endorse or promote products derived |
||||||
|
* from this software without specific prior written permission. |
||||||
|
* |
||||||
|
* 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. |
||||||
|
*/ |
||||||
|
|
||||||
|
var base64 = require('./base64'); |
||||||
|
|
||||||
|
// A single base 64 digit can contain 6 bits of data. For the base 64 variable
|
||||||
|
// length quantities we use in the source map spec, the first bit is the sign,
|
||||||
|
// the next four bits are the actual value, and the 6th bit is the
|
||||||
|
// continuation bit. The continuation bit tells us whether there are more
|
||||||
|
// digits in this value following this digit.
|
||||||
|
//
|
||||||
|
// Continuation
|
||||||
|
// | Sign
|
||||||
|
// | |
|
||||||
|
// V V
|
||||||
|
// 101011
|
||||||
|
|
||||||
|
var VLQ_BASE_SHIFT = 5; |
||||||
|
|
||||||
|
// binary: 100000
|
||||||
|
var VLQ_BASE = 1 << VLQ_BASE_SHIFT; |
||||||
|
|
||||||
|
// binary: 011111
|
||||||
|
var VLQ_BASE_MASK = VLQ_BASE - 1; |
||||||
|
|
||||||
|
// binary: 100000
|
||||||
|
var VLQ_CONTINUATION_BIT = VLQ_BASE; |
||||||
|
|
||||||
|
/** |
||||||
|
* Converts from a two-complement value to a value where the sign bit is |
||||||
|
* placed in the least significant bit. For example, as decimals: |
||||||
|
* 1 becomes 2 (10 binary), -1 becomes 3 (11 binary) |
||||||
|
* 2 becomes 4 (100 binary), -2 becomes 5 (101 binary) |
||||||
|
*/ |
||||||
|
function toVLQSigned(aValue) { |
||||||
|
return aValue < 0 |
||||||
|
? ((-aValue) << 1) + 1 |
||||||
|
: (aValue << 1) + 0; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Converts to a two-complement value from a value where the sign bit is |
||||||
|
* placed in the least significant bit. For example, as decimals: |
||||||
|
* 2 (10 binary) becomes 1, 3 (11 binary) becomes -1 |
||||||
|
* 4 (100 binary) becomes 2, 5 (101 binary) becomes -2 |
||||||
|
*/ |
||||||
|
function fromVLQSigned(aValue) { |
||||||
|
var isNegative = (aValue & 1) === 1; |
||||||
|
var shifted = aValue >> 1; |
||||||
|
return isNegative |
||||||
|
? -shifted |
||||||
|
: shifted; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Returns the base 64 VLQ encoded value. |
||||||
|
*/ |
||||||
|
exports.encode = function base64VLQ_encode(aValue) { |
||||||
|
var encoded = ""; |
||||||
|
var digit; |
||||||
|
|
||||||
|
var vlq = toVLQSigned(aValue); |
||||||
|
|
||||||
|
do { |
||||||
|
digit = vlq & VLQ_BASE_MASK; |
||||||
|
vlq >>>= VLQ_BASE_SHIFT; |
||||||
|
if (vlq > 0) { |
||||||
|
// There are still more digits in this value, so we must make sure the
|
||||||
|
// continuation bit is marked.
|
||||||
|
digit |= VLQ_CONTINUATION_BIT; |
||||||
|
} |
||||||
|
encoded += base64.encode(digit); |
||||||
|
} while (vlq > 0); |
||||||
|
|
||||||
|
return encoded; |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Decodes the next base 64 VLQ value from the given string and returns the |
||||||
|
* value and the rest of the string via the out parameter. |
||||||
|
*/ |
||||||
|
exports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) { |
||||||
|
var strLen = aStr.length; |
||||||
|
var result = 0; |
||||||
|
var shift = 0; |
||||||
|
var continuation, digit; |
||||||
|
|
||||||
|
do { |
||||||
|
if (aIndex >= strLen) { |
||||||
|
throw new Error("Expected more digits in base 64 VLQ value."); |
||||||
|
} |
||||||
|
|
||||||
|
digit = base64.decode(aStr.charCodeAt(aIndex++)); |
||||||
|
if (digit === -1) { |
||||||
|
throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1)); |
||||||
|
} |
||||||
|
|
||||||
|
continuation = !!(digit & VLQ_CONTINUATION_BIT); |
||||||
|
digit &= VLQ_BASE_MASK; |
||||||
|
result = result + (digit << shift); |
||||||
|
shift += VLQ_BASE_SHIFT; |
||||||
|
} while (continuation); |
||||||
|
|
||||||
|
aOutParam.value = fromVLQSigned(result); |
||||||
|
aOutParam.rest = aIndex; |
||||||
|
}; |
@ -0,0 +1,67 @@ |
|||||||
|
/* -*- Mode: js; js-indent-level: 2; -*- */ |
||||||
|
/* |
||||||
|
* Copyright 2011 Mozilla Foundation and contributors |
||||||
|
* Licensed under the New BSD license. See LICENSE or: |
||||||
|
* http://opensource.org/licenses/BSD-3-Clause
|
||||||
|
*/ |
||||||
|
|
||||||
|
var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split(''); |
||||||
|
|
||||||
|
/** |
||||||
|
* Encode an integer in the range of 0 to 63 to a single base 64 digit. |
||||||
|
*/ |
||||||
|
exports.encode = function (number) { |
||||||
|
if (0 <= number && number < intToCharMap.length) { |
||||||
|
return intToCharMap[number]; |
||||||
|
} |
||||||
|
throw new TypeError("Must be between 0 and 63: " + number); |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Decode a single base 64 character code digit to an integer. Returns -1 on |
||||||
|
* failure. |
||||||
|
*/ |
||||||
|
exports.decode = function (charCode) { |
||||||
|
var bigA = 65; // 'A'
|
||||||
|
var bigZ = 90; // 'Z'
|
||||||
|
|
||||||
|
var littleA = 97; // 'a'
|
||||||
|
var littleZ = 122; // 'z'
|
||||||
|
|
||||||
|
var zero = 48; // '0'
|
||||||
|
var nine = 57; // '9'
|
||||||
|
|
||||||
|
var plus = 43; // '+'
|
||||||
|
var slash = 47; // '/'
|
||||||
|
|
||||||
|
var littleOffset = 26; |
||||||
|
var numberOffset = 52; |
||||||
|
|
||||||
|
// 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
||||||
|
if (bigA <= charCode && charCode <= bigZ) { |
||||||
|
return (charCode - bigA); |
||||||
|
} |
||||||
|
|
||||||
|
// 26 - 51: abcdefghijklmnopqrstuvwxyz
|
||||||
|
if (littleA <= charCode && charCode <= littleZ) { |
||||||
|
return (charCode - littleA + littleOffset); |
||||||
|
} |
||||||
|
|
||||||
|
// 52 - 61: 0123456789
|
||||||
|
if (zero <= charCode && charCode <= nine) { |
||||||
|
return (charCode - zero + numberOffset); |
||||||
|
} |
||||||
|
|
||||||
|
// 62: +
|
||||||
|
if (charCode == plus) { |
||||||
|
return 62; |
||||||
|
} |
||||||
|
|
||||||
|
// 63: /
|
||||||
|
if (charCode == slash) { |
||||||
|
return 63; |
||||||
|
} |
||||||
|
|
||||||
|
// Invalid base64 digit.
|
||||||
|
return -1; |
||||||
|
}; |
@ -0,0 +1,111 @@ |
|||||||
|
/* -*- Mode: js; js-indent-level: 2; -*- */ |
||||||
|
/* |
||||||
|
* Copyright 2011 Mozilla Foundation and contributors |
||||||
|
* Licensed under the New BSD license. See LICENSE or: |
||||||
|
* http://opensource.org/licenses/BSD-3-Clause
|
||||||
|
*/ |
||||||
|
|
||||||
|
exports.GREATEST_LOWER_BOUND = 1; |
||||||
|
exports.LEAST_UPPER_BOUND = 2; |
||||||
|
|
||||||
|
/** |
||||||
|
* Recursive implementation of binary search. |
||||||
|
* |
||||||
|
* @param aLow Indices here and lower do not contain the needle. |
||||||
|
* @param aHigh Indices here and higher do not contain the needle. |
||||||
|
* @param aNeedle The element being searched for. |
||||||
|
* @param aHaystack The non-empty array being searched. |
||||||
|
* @param aCompare Function which takes two elements and returns -1, 0, or 1. |
||||||
|
* @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or |
||||||
|
* 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the |
||||||
|
* closest element that is smaller than or greater than the one we are |
||||||
|
* searching for, respectively, if the exact element cannot be found. |
||||||
|
*/ |
||||||
|
function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) { |
||||||
|
// This function terminates when one of the following is true:
|
||||||
|
//
|
||||||
|
// 1. We find the exact element we are looking for.
|
||||||
|
//
|
||||||
|
// 2. We did not find the exact element, but we can return the index of
|
||||||
|
// the next-closest element.
|
||||||
|
//
|
||||||
|
// 3. We did not find the exact element, and there is no next-closest
|
||||||
|
// element than the one we are searching for, so we return -1.
|
||||||
|
var mid = Math.floor((aHigh - aLow) / 2) + aLow; |
||||||
|
var cmp = aCompare(aNeedle, aHaystack[mid], true); |
||||||
|
if (cmp === 0) { |
||||||
|
// Found the element we are looking for.
|
||||||
|
return mid; |
||||||
|
} |
||||||
|
else if (cmp > 0) { |
||||||
|
// Our needle is greater than aHaystack[mid].
|
||||||
|
if (aHigh - mid > 1) { |
||||||
|
// The element is in the upper half.
|
||||||
|
return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias); |
||||||
|
} |
||||||
|
|
||||||
|
// The exact needle element was not found in this haystack. Determine if
|
||||||
|
// we are in termination case (3) or (2) and return the appropriate thing.
|
||||||
|
if (aBias == exports.LEAST_UPPER_BOUND) { |
||||||
|
return aHigh < aHaystack.length ? aHigh : -1; |
||||||
|
} else { |
||||||
|
return mid; |
||||||
|
} |
||||||
|
} |
||||||
|
else { |
||||||
|
// Our needle is less than aHaystack[mid].
|
||||||
|
if (mid - aLow > 1) { |
||||||
|
// The element is in the lower half.
|
||||||
|
return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias); |
||||||
|
} |
||||||
|
|
||||||
|
// we are in termination case (3) or (2) and return the appropriate thing.
|
||||||
|
if (aBias == exports.LEAST_UPPER_BOUND) { |
||||||
|
return mid; |
||||||
|
} else { |
||||||
|
return aLow < 0 ? -1 : aLow; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* This is an implementation of binary search which will always try and return |
||||||
|
* the index of the closest element if there is no exact hit. This is because |
||||||
|
* mappings between original and generated line/col pairs are single points, |
||||||
|
* and there is an implicit region between each of them, so a miss just means |
||||||
|
* that you aren't on the very start of a region. |
||||||
|
* |
||||||
|
* @param aNeedle The element you are looking for. |
||||||
|
* @param aHaystack The array that is being searched. |
||||||
|
* @param aCompare A function which takes the needle and an element in the |
||||||
|
* array and returns -1, 0, or 1 depending on whether the needle is less |
||||||
|
* than, equal to, or greater than the element, respectively. |
||||||
|
* @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or |
||||||
|
* 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the |
||||||
|
* closest element that is smaller than or greater than the one we are |
||||||
|
* searching for, respectively, if the exact element cannot be found. |
||||||
|
* Defaults to 'binarySearch.GREATEST_LOWER_BOUND'. |
||||||
|
*/ |
||||||
|
exports.search = function search(aNeedle, aHaystack, aCompare, aBias) { |
||||||
|
if (aHaystack.length === 0) { |
||||||
|
return -1; |
||||||
|
} |
||||||
|
|
||||||
|
var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack, |
||||||
|
aCompare, aBias || exports.GREATEST_LOWER_BOUND); |
||||||
|
if (index < 0) { |
||||||
|
return -1; |
||||||
|
} |
||||||
|
|
||||||
|
// We have found either the exact element, or the next-closest element than
|
||||||
|
// the one we are searching for. However, there may be more than one such
|
||||||
|
// element. Make sure we always return the smallest of these.
|
||||||
|
while (index - 1 >= 0) { |
||||||
|
if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) { |
||||||
|
break; |
||||||
|
} |
||||||
|
--index; |
||||||
|
} |
||||||
|
|
||||||
|
return index; |
||||||
|
}; |
@ -0,0 +1,79 @@ |
|||||||
|
/* -*- Mode: js; js-indent-level: 2; -*- */ |
||||||
|
/* |
||||||
|
* Copyright 2014 Mozilla Foundation and contributors |
||||||
|
* Licensed under the New BSD license. See LICENSE or: |
||||||
|
* http://opensource.org/licenses/BSD-3-Clause
|
||||||
|
*/ |
||||||
|
|
||||||
|
var util = require('./util'); |
||||||
|
|
||||||
|
/** |
||||||
|
* Determine whether mappingB is after mappingA with respect to generated |
||||||
|
* position. |
||||||
|
*/ |
||||||
|
function generatedPositionAfter(mappingA, mappingB) { |
||||||
|
// Optimized for most common case
|
||||||
|
var lineA = mappingA.generatedLine; |
||||||
|
var lineB = mappingB.generatedLine; |
||||||
|
var columnA = mappingA.generatedColumn; |
||||||
|
var columnB = mappingB.generatedColumn; |
||||||
|
return lineB > lineA || lineB == lineA && columnB >= columnA || |
||||||
|
util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* A data structure to provide a sorted view of accumulated mappings in a |
||||||
|
* performance conscious manner. It trades a neglibable overhead in general |
||||||
|
* case for a large speedup in case of mappings being added in order. |
||||||
|
*/ |
||||||
|
function MappingList() { |
||||||
|
this._array = []; |
||||||
|
this._sorted = true; |
||||||
|
// Serves as infimum
|
||||||
|
this._last = {generatedLine: -1, generatedColumn: 0}; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Iterate through internal items. This method takes the same arguments that |
||||||
|
* `Array.prototype.forEach` takes. |
||||||
|
* |
||||||
|
* NOTE: The order of the mappings is NOT guaranteed. |
||||||
|
*/ |
||||||
|
MappingList.prototype.unsortedForEach = |
||||||
|
function MappingList_forEach(aCallback, aThisArg) { |
||||||
|
this._array.forEach(aCallback, aThisArg); |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Add the given source mapping. |
||||||
|
* |
||||||
|
* @param Object aMapping |
||||||
|
*/ |
||||||
|
MappingList.prototype.add = function MappingList_add(aMapping) { |
||||||
|
if (generatedPositionAfter(this._last, aMapping)) { |
||||||
|
this._last = aMapping; |
||||||
|
this._array.push(aMapping); |
||||||
|
} else { |
||||||
|
this._sorted = false; |
||||||
|
this._array.push(aMapping); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Returns the flat, sorted array of mappings. The mappings are sorted by |
||||||
|
* generated position. |
||||||
|
* |
||||||
|
* WARNING: This method returns internal data without copying, for |
||||||
|
* performance. The return value must NOT be mutated, and should be treated as |
||||||
|
* an immutable borrow. If you want to take ownership, you must make your own |
||||||
|
* copy. |
||||||
|
*/ |
||||||
|
MappingList.prototype.toArray = function MappingList_toArray() { |
||||||
|
if (!this._sorted) { |
||||||
|
this._array.sort(util.compareByGeneratedPositionsInflated); |
||||||
|
this._sorted = true; |
||||||
|
} |
||||||
|
return this._array; |
||||||
|
}; |
||||||
|
|
||||||
|
exports.MappingList = MappingList; |
@ -0,0 +1,114 @@ |
|||||||
|
/* -*- Mode: js; js-indent-level: 2; -*- */ |
||||||
|
/* |
||||||
|
* Copyright 2011 Mozilla Foundation and contributors |
||||||
|
* Licensed under the New BSD license. See LICENSE or: |
||||||
|
* http://opensource.org/licenses/BSD-3-Clause
|
||||||
|
*/ |
||||||
|
|
||||||
|
// It turns out that some (most?) JavaScript engines don't self-host
|
||||||
|
// `Array.prototype.sort`. This makes sense because C++ will likely remain
|
||||||
|
// faster than JS when doing raw CPU-intensive sorting. However, when using a
|
||||||
|
// custom comparator function, calling back and forth between the VM's C++ and
|
||||||
|
// JIT'd JS is rather slow *and* loses JIT type information, resulting in
|
||||||
|
// worse generated code for the comparator function than would be optimal. In
|
||||||
|
// fact, when sorting with a comparator, these costs outweigh the benefits of
|
||||||
|
// sorting in C++. By using our own JS-implemented Quick Sort (below), we get
|
||||||
|
// a ~3500ms mean speed-up in `bench/bench.html`.
|
||||||
|
|
||||||
|
/** |
||||||
|
* Swap the elements indexed by `x` and `y` in the array `ary`. |
||||||
|
* |
||||||
|
* @param {Array} ary |
||||||
|
* The array. |
||||||
|
* @param {Number} x |
||||||
|
* The index of the first item. |
||||||
|
* @param {Number} y |
||||||
|
* The index of the second item. |
||||||
|
*/ |
||||||
|
function swap(ary, x, y) { |
||||||
|
var temp = ary[x]; |
||||||
|
ary[x] = ary[y]; |
||||||
|
ary[y] = temp; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Returns a random integer within the range `low .. high` inclusive. |
||||||
|
* |
||||||
|
* @param {Number} low |
||||||
|
* The lower bound on the range. |
||||||
|
* @param {Number} high |
||||||
|
* The upper bound on the range. |
||||||
|
*/ |
||||||
|
function randomIntInRange(low, high) { |
||||||
|
return Math.round(low + (Math.random() * (high - low))); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* The Quick Sort algorithm. |
||||||
|
* |
||||||
|
* @param {Array} ary |
||||||
|
* An array to sort. |
||||||
|
* @param {function} comparator |
||||||
|
* Function to use to compare two items. |
||||||
|
* @param {Number} p |
||||||
|
* Start index of the array |
||||||
|
* @param {Number} r |
||||||
|
* End index of the array |
||||||
|
*/ |
||||||
|
function doQuickSort(ary, comparator, p, r) { |
||||||
|
// If our lower bound is less than our upper bound, we (1) partition the
|
||||||
|
// array into two pieces and (2) recurse on each half. If it is not, this is
|
||||||
|
// the empty array and our base case.
|
||||||
|
|
||||||
|
if (p < r) { |
||||||
|
// (1) Partitioning.
|
||||||
|
//
|
||||||
|
// The partitioning chooses a pivot between `p` and `r` and moves all
|
||||||
|
// elements that are less than or equal to the pivot to the before it, and
|
||||||
|
// all the elements that are greater than it after it. The effect is that
|
||||||
|
// once partition is done, the pivot is in the exact place it will be when
|
||||||
|
// the array is put in sorted order, and it will not need to be moved
|
||||||
|
// again. This runs in O(n) time.
|
||||||
|
|
||||||
|
// Always choose a random pivot so that an input array which is reverse
|
||||||
|
// sorted does not cause O(n^2) running time.
|
||||||
|
var pivotIndex = randomIntInRange(p, r); |
||||||
|
var i = p - 1; |
||||||
|
|
||||||
|
swap(ary, pivotIndex, r); |
||||||
|
var pivot = ary[r]; |
||||||
|
|
||||||
|
// Immediately after `j` is incremented in this loop, the following hold
|
||||||
|
// true:
|
||||||
|
//
|
||||||
|
// * Every element in `ary[p .. i]` is less than or equal to the pivot.
|
||||||
|
//
|
||||||
|
// * Every element in `ary[i+1 .. j-1]` is greater than the pivot.
|
||||||
|
for (var j = p; j < r; j++) { |
||||||
|
if (comparator(ary[j], pivot) <= 0) { |
||||||
|
i += 1; |
||||||
|
swap(ary, i, j); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
swap(ary, i + 1, j); |
||||||
|
var q = i + 1; |
||||||
|
|
||||||
|
// (2) Recurse on each half.
|
||||||
|
|
||||||
|
doQuickSort(ary, comparator, p, q - 1); |
||||||
|
doQuickSort(ary, comparator, q + 1, r); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Sort the given array in-place with the given comparator function. |
||||||
|
* |
||||||
|
* @param {Array} ary |
||||||
|
* An array to sort. |
||||||
|
* @param {function} comparator |
||||||
|
* Function to use to compare two items. |
||||||
|
*/ |
||||||
|
exports.quickSort = function (ary, comparator) { |
||||||
|
doQuickSort(ary, comparator, 0, ary.length - 1); |
||||||
|
}; |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,425 @@ |
|||||||
|
/* -*- Mode: js; js-indent-level: 2; -*- */ |
||||||
|
/* |
||||||
|
* Copyright 2011 Mozilla Foundation and contributors |
||||||
|
* Licensed under the New BSD license. See LICENSE or: |
||||||
|
* http://opensource.org/licenses/BSD-3-Clause
|
||||||
|
*/ |
||||||
|
|
||||||
|
var base64VLQ = require('./base64-vlq'); |
||||||
|
var util = require('./util'); |
||||||
|
var ArraySet = require('./array-set').ArraySet; |
||||||
|
var MappingList = require('./mapping-list').MappingList; |
||||||
|
|
||||||
|
/** |
||||||
|
* An instance of the SourceMapGenerator represents a source map which is |
||||||
|
* being built incrementally. You may pass an object with the following |
||||||
|
* properties: |
||||||
|
* |
||||||
|
* - file: The filename of the generated source. |
||||||
|
* - sourceRoot: A root for all relative URLs in this source map. |
||||||
|
*/ |
||||||
|
function SourceMapGenerator(aArgs) { |
||||||
|
if (!aArgs) { |
||||||
|
aArgs = {}; |
||||||
|
} |
||||||
|
this._file = util.getArg(aArgs, 'file', null); |
||||||
|
this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null); |
||||||
|
this._skipValidation = util.getArg(aArgs, 'skipValidation', false); |
||||||
|
this._sources = new ArraySet(); |
||||||
|
this._names = new ArraySet(); |
||||||
|
this._mappings = new MappingList(); |
||||||
|
this._sourcesContents = null; |
||||||
|
} |
||||||
|
|
||||||
|
SourceMapGenerator.prototype._version = 3; |
||||||
|
|
||||||
|
/** |
||||||
|
* Creates a new SourceMapGenerator based on a SourceMapConsumer |
||||||
|
* |
||||||
|
* @param aSourceMapConsumer The SourceMap. |
||||||
|
*/ |
||||||
|
SourceMapGenerator.fromSourceMap = |
||||||
|
function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) { |
||||||
|
var sourceRoot = aSourceMapConsumer.sourceRoot; |
||||||
|
var generator = new SourceMapGenerator({ |
||||||
|
file: aSourceMapConsumer.file, |
||||||
|
sourceRoot: sourceRoot |
||||||
|
}); |
||||||
|
aSourceMapConsumer.eachMapping(function (mapping) { |
||||||
|
var newMapping = { |
||||||
|
generated: { |
||||||
|
line: mapping.generatedLine, |
||||||
|
column: mapping.generatedColumn |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
if (mapping.source != null) { |
||||||
|
newMapping.source = mapping.source; |
||||||
|
if (sourceRoot != null) { |
||||||
|
newMapping.source = util.relative(sourceRoot, newMapping.source); |
||||||
|
} |
||||||
|
|
||||||
|
newMapping.original = { |
||||||
|
line: mapping.originalLine, |
||||||
|
column: mapping.originalColumn |
||||||
|
}; |
||||||
|
|
||||||
|
if (mapping.name != null) { |
||||||
|
newMapping.name = mapping.name; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
generator.addMapping(newMapping); |
||||||
|
}); |
||||||
|
aSourceMapConsumer.sources.forEach(function (sourceFile) { |
||||||
|
var sourceRelative = sourceFile; |
||||||
|
if (sourceRoot !== null) { |
||||||
|
sourceRelative = util.relative(sourceRoot, sourceFile); |
||||||
|
} |
||||||
|
|
||||||
|
if (!generator._sources.has(sourceRelative)) { |
||||||
|
generator._sources.add(sourceRelative); |
||||||
|
} |
||||||
|
|
||||||
|
var content = aSourceMapConsumer.sourceContentFor(sourceFile); |
||||||
|
if (content != null) { |
||||||
|
generator.setSourceContent(sourceFile, content); |
||||||
|
} |
||||||
|
}); |
||||||
|
return generator; |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Add a single mapping from original source line and column to the generated |
||||||
|
* source's line and column for this source map being created. The mapping |
||||||
|
* object should have the following properties: |
||||||
|
* |
||||||
|
* - generated: An object with the generated line and column positions. |
||||||
|
* - original: An object with the original line and column positions. |
||||||
|
* - source: The original source file (relative to the sourceRoot). |
||||||
|
* - name: An optional original token name for this mapping. |
||||||
|
*/ |
||||||
|
SourceMapGenerator.prototype.addMapping = |
||||||
|
function SourceMapGenerator_addMapping(aArgs) { |
||||||
|
var generated = util.getArg(aArgs, 'generated'); |
||||||
|
var original = util.getArg(aArgs, 'original', null); |
||||||
|
var source = util.getArg(aArgs, 'source', null); |
||||||
|
var name = util.getArg(aArgs, 'name', null); |
||||||
|
|
||||||
|
if (!this._skipValidation) { |
||||||
|
this._validateMapping(generated, original, source, name); |
||||||
|
} |
||||||
|
|
||||||
|
if (source != null) { |
||||||
|
source = String(source); |
||||||
|
if (!this._sources.has(source)) { |
||||||
|
this._sources.add(source); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if (name != null) { |
||||||
|
name = String(name); |
||||||
|
if (!this._names.has(name)) { |
||||||
|
this._names.add(name); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
this._mappings.add({ |
||||||
|
generatedLine: generated.line, |
||||||
|
generatedColumn: generated.column, |
||||||
|
originalLine: original != null && original.line, |
||||||
|
originalColumn: original != null && original.column, |
||||||
|
source: source, |
||||||
|
name: name |
||||||
|
}); |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Set the source content for a source file. |
||||||
|
*/ |
||||||
|
SourceMapGenerator.prototype.setSourceContent = |
||||||
|
function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) { |
||||||
|
var source = aSourceFile; |
||||||
|
if (this._sourceRoot != null) { |
||||||
|
source = util.relative(this._sourceRoot, source); |
||||||
|
} |
||||||
|
|
||||||
|
if (aSourceContent != null) { |
||||||
|
// Add the source content to the _sourcesContents map.
|
||||||
|
// Create a new _sourcesContents map if the property is null.
|
||||||
|
if (!this._sourcesContents) { |
||||||
|
this._sourcesContents = Object.create(null); |
||||||
|
} |
||||||
|
this._sourcesContents[util.toSetString(source)] = aSourceContent; |
||||||
|
} else if (this._sourcesContents) { |
||||||
|
// Remove the source file from the _sourcesContents map.
|
||||||
|
// If the _sourcesContents map is empty, set the property to null.
|
||||||
|
delete this._sourcesContents[util.toSetString(source)]; |
||||||
|
if (Object.keys(this._sourcesContents).length === 0) { |
||||||
|
this._sourcesContents = null; |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Applies the mappings of a sub-source-map for a specific source file to the |
||||||
|
* source map being generated. Each mapping to the supplied source file is |
||||||
|
* rewritten using the supplied source map. Note: The resolution for the |
||||||
|
* resulting mappings is the minimium of this map and the supplied map. |
||||||
|
* |
||||||
|
* @param aSourceMapConsumer The source map to be applied. |
||||||
|
* @param aSourceFile Optional. The filename of the source file. |
||||||
|
* If omitted, SourceMapConsumer's file property will be used. |
||||||
|
* @param aSourceMapPath Optional. The dirname of the path to the source map |
||||||
|
* to be applied. If relative, it is relative to the SourceMapConsumer. |
||||||
|
* This parameter is needed when the two source maps aren't in the same |
||||||
|
* directory, and the source map to be applied contains relative source |
||||||
|
* paths. If so, those relative source paths need to be rewritten |
||||||
|
* relative to the SourceMapGenerator. |
||||||
|
*/ |
||||||
|
SourceMapGenerator.prototype.applySourceMap = |
||||||
|
function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) { |
||||||
|
var sourceFile = aSourceFile; |
||||||
|
// If aSourceFile is omitted, we will use the file property of the SourceMap
|
||||||
|
if (aSourceFile == null) { |
||||||
|
if (aSourceMapConsumer.file == null) { |
||||||
|
throw new Error( |
||||||
|
'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' + |
||||||
|
'or the source map\'s "file" property. Both were omitted.' |
||||||
|
); |
||||||
|
} |
||||||
|
sourceFile = aSourceMapConsumer.file; |
||||||
|
} |
||||||
|
var sourceRoot = this._sourceRoot; |
||||||
|
// Make "sourceFile" relative if an absolute Url is passed.
|
||||||
|
if (sourceRoot != null) { |
||||||
|
sourceFile = util.relative(sourceRoot, sourceFile); |
||||||
|
} |
||||||
|
// Applying the SourceMap can add and remove items from the sources and
|
||||||
|
// the names array.
|
||||||
|
var newSources = new ArraySet(); |
||||||
|
var newNames = new ArraySet(); |
||||||
|
|
||||||
|
// Find mappings for the "sourceFile"
|
||||||
|
this._mappings.unsortedForEach(function (mapping) { |
||||||
|
if (mapping.source === sourceFile && mapping.originalLine != null) { |
||||||
|
// Check if it can be mapped by the source map, then update the mapping.
|
||||||
|
var original = aSourceMapConsumer.originalPositionFor({ |
||||||
|
line: mapping.originalLine, |
||||||
|
column: mapping.originalColumn |
||||||
|
}); |
||||||
|
if (original.source != null) { |
||||||
|
// Copy mapping
|
||||||
|
mapping.source = original.source; |
||||||
|
if (aSourceMapPath != null) { |
||||||
|
mapping.source = util.join(aSourceMapPath, mapping.source) |
||||||
|
} |
||||||
|
if (sourceRoot != null) { |
||||||
|
mapping.source = util.relative(sourceRoot, mapping.source); |
||||||
|
} |
||||||
|
mapping.originalLine = original.line; |
||||||
|
mapping.originalColumn = original.column; |
||||||
|
if (original.name != null) { |
||||||
|
mapping.name = original.name; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
var source = mapping.source; |
||||||
|
if (source != null && !newSources.has(source)) { |
||||||
|
newSources.add(source); |
||||||
|
} |
||||||
|
|
||||||
|
var name = mapping.name; |
||||||
|
if (name != null && !newNames.has(name)) { |
||||||
|
newNames.add(name); |
||||||
|
} |
||||||
|
|
||||||
|
}, this); |
||||||
|
this._sources = newSources; |
||||||
|
this._names = newNames; |
||||||
|
|
||||||
|
// Copy sourcesContents of applied map.
|
||||||
|
aSourceMapConsumer.sources.forEach(function (sourceFile) { |
||||||
|
var content = aSourceMapConsumer.sourceContentFor(sourceFile); |
||||||
|
if (content != null) { |
||||||
|
if (aSourceMapPath != null) { |
||||||
|
sourceFile = util.join(aSourceMapPath, sourceFile); |
||||||
|
} |
||||||
|
if (sourceRoot != null) { |
||||||
|
sourceFile = util.relative(sourceRoot, sourceFile); |
||||||
|
} |
||||||
|
this.setSourceContent(sourceFile, content); |
||||||
|
} |
||||||
|
}, this); |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* A mapping can have one of the three levels of data: |
||||||
|
* |
||||||
|
* 1. Just the generated position. |
||||||
|
* 2. The Generated position, original position, and original source. |
||||||
|
* 3. Generated and original position, original source, as well as a name |
||||||
|
* token. |
||||||
|
* |
||||||
|
* To maintain consistency, we validate that any new mapping being added falls |
||||||
|
* in to one of these categories. |
||||||
|
*/ |
||||||
|
SourceMapGenerator.prototype._validateMapping = |
||||||
|
function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource, |
||||||
|
aName) { |
||||||
|
// When aOriginal is truthy but has empty values for .line and .column,
|
||||||
|
// it is most likely a programmer error. In this case we throw a very
|
||||||
|
// specific error message to try to guide them the right way.
|
||||||
|
// For example: https://github.com/Polymer/polymer-bundler/pull/519
|
||||||
|
if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') { |
||||||
|
throw new Error( |
||||||
|
'original.line and original.column are not numbers -- you probably meant to omit ' + |
||||||
|
'the original mapping entirely and only map the generated position. If so, pass ' + |
||||||
|
'null for the original mapping instead of an object with empty or null values.' |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
if (aGenerated && 'line' in aGenerated && 'column' in aGenerated |
||||||
|
&& aGenerated.line > 0 && aGenerated.column >= 0 |
||||||
|
&& !aOriginal && !aSource && !aName) { |
||||||
|
// Case 1.
|
||||||
|
return; |
||||||
|
} |
||||||
|
else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated |
||||||
|
&& aOriginal && 'line' in aOriginal && 'column' in aOriginal |
||||||
|
&& aGenerated.line > 0 && aGenerated.column >= 0 |
||||||
|
&& aOriginal.line > 0 && aOriginal.column >= 0 |
||||||
|
&& aSource) { |
||||||
|
// Cases 2 and 3.
|
||||||
|
return; |
||||||
|
} |
||||||
|
else { |
||||||
|
throw new Error('Invalid mapping: ' + JSON.stringify({ |
||||||
|
generated: aGenerated, |
||||||
|
source: aSource, |
||||||
|
original: aOriginal, |
||||||
|
name: aName |
||||||
|
})); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Serialize the accumulated mappings in to the stream of base 64 VLQs |
||||||
|
* specified by the source map format. |
||||||
|
*/ |
||||||
|
SourceMapGenerator.prototype._serializeMappings = |
||||||
|
function SourceMapGenerator_serializeMappings() { |
||||||
|
var previousGeneratedColumn = 0; |
||||||
|
var previousGeneratedLine = 1; |
||||||
|
var previousOriginalColumn = 0; |
||||||
|
var previousOriginalLine = 0; |
||||||
|
var previousName = 0; |
||||||
|
var previousSource = 0; |
||||||
|
var result = ''; |
||||||
|
var next; |
||||||
|
var mapping; |
||||||
|
var nameIdx; |
||||||
|
var sourceIdx; |
||||||
|
|
||||||
|
var mappings = this._mappings.toArray(); |
||||||
|
for (var i = 0, len = mappings.length; i < len; i++) { |
||||||
|
mapping = mappings[i]; |
||||||
|
next = '' |
||||||
|
|
||||||
|
if (mapping.generatedLine !== previousGeneratedLine) { |
||||||
|
previousGeneratedColumn = 0; |
||||||
|
while (mapping.generatedLine !== previousGeneratedLine) { |
||||||
|
next += ';'; |
||||||
|
previousGeneratedLine++; |
||||||
|
} |
||||||
|
} |
||||||
|
else { |
||||||
|
if (i > 0) { |
||||||
|
if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
next += ','; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
next += base64VLQ.encode(mapping.generatedColumn |
||||||
|
- previousGeneratedColumn); |
||||||
|
previousGeneratedColumn = mapping.generatedColumn; |
||||||
|
|
||||||
|
if (mapping.source != null) { |
||||||
|
sourceIdx = this._sources.indexOf(mapping.source); |
||||||
|
next += base64VLQ.encode(sourceIdx - previousSource); |
||||||
|
previousSource = sourceIdx; |
||||||
|
|
||||||
|
// lines are stored 0-based in SourceMap spec version 3
|
||||||
|
next += base64VLQ.encode(mapping.originalLine - 1 |
||||||
|
- previousOriginalLine); |
||||||
|
previousOriginalLine = mapping.originalLine - 1; |
||||||
|
|
||||||
|
next += base64VLQ.encode(mapping.originalColumn |
||||||
|
- previousOriginalColumn); |
||||||
|
previousOriginalColumn = mapping.originalColumn; |
||||||
|
|
||||||
|
if (mapping.name != null) { |
||||||
|
nameIdx = this._names.indexOf(mapping.name); |
||||||
|
next += base64VLQ.encode(nameIdx - previousName); |
||||||
|
previousName = nameIdx; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
result += next; |
||||||
|
} |
||||||
|
|
||||||
|
return result; |
||||||
|
}; |
||||||
|
|
||||||
|
SourceMapGenerator.prototype._generateSourcesContent = |
||||||
|
function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) { |
||||||
|
return aSources.map(function (source) { |
||||||
|
if (!this._sourcesContents) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
if (aSourceRoot != null) { |
||||||
|
source = util.relative(aSourceRoot, source); |
||||||
|
} |
||||||
|
var key = util.toSetString(source); |
||||||
|
return Object.prototype.hasOwnProperty.call(this._sourcesContents, key) |
||||||
|
? this._sourcesContents[key] |
||||||
|
: null; |
||||||
|
}, this); |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Externalize the source map. |
||||||
|
*/ |
||||||
|
SourceMapGenerator.prototype.toJSON = |
||||||
|
function SourceMapGenerator_toJSON() { |
||||||
|
var map = { |
||||||
|
version: this._version, |
||||||
|
sources: this._sources.toArray(), |
||||||
|
names: this._names.toArray(), |
||||||
|
mappings: this._serializeMappings() |
||||||
|
}; |
||||||
|
if (this._file != null) { |
||||||
|
map.file = this._file; |
||||||
|
} |
||||||
|
if (this._sourceRoot != null) { |
||||||
|
map.sourceRoot = this._sourceRoot; |
||||||
|
} |
||||||
|
if (this._sourcesContents) { |
||||||
|
map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot); |
||||||
|
} |
||||||
|
|
||||||
|
return map; |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Render the source map being generated to a string. |
||||||
|
*/ |
||||||
|
SourceMapGenerator.prototype.toString = |
||||||
|
function SourceMapGenerator_toString() { |
||||||
|
return JSON.stringify(this.toJSON()); |
||||||
|
}; |
||||||
|
|
||||||
|
exports.SourceMapGenerator = SourceMapGenerator; |
@ -0,0 +1,413 @@ |
|||||||
|
/* -*- Mode: js; js-indent-level: 2; -*- */ |
||||||
|
/* |
||||||
|
* Copyright 2011 Mozilla Foundation and contributors |
||||||
|
* Licensed under the New BSD license. See LICENSE or: |
||||||
|
* http://opensource.org/licenses/BSD-3-Clause
|
||||||
|
*/ |
||||||
|
|
||||||
|
var SourceMapGenerator = require('./source-map-generator').SourceMapGenerator; |
||||||
|
var util = require('./util'); |
||||||
|
|
||||||
|
// Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
|
||||||
|
// operating systems these days (capturing the result).
|
||||||
|
var REGEX_NEWLINE = /(\r?\n)/; |
||||||
|
|
||||||
|
// Newline character code for charCodeAt() comparisons
|
||||||
|
var NEWLINE_CODE = 10; |
||||||
|
|
||||||
|
// Private symbol for identifying `SourceNode`s when multiple versions of
|
||||||
|
// the source-map library are loaded. This MUST NOT CHANGE across
|
||||||
|
// versions!
|
||||||
|
var isSourceNode = "$$$isSourceNode$$$"; |
||||||
|
|
||||||
|
/** |
||||||
|
* SourceNodes provide a way to abstract over interpolating/concatenating |
||||||
|
* snippets of generated JavaScript source code while maintaining the line and |
||||||
|
* column information associated with the original source code. |
||||||
|
* |
||||||
|
* @param aLine The original line number. |
||||||
|
* @param aColumn The original column number. |
||||||
|
* @param aSource The original source's filename. |
||||||
|
* @param aChunks Optional. An array of strings which are snippets of |
||||||
|
* generated JS, or other SourceNodes. |
||||||
|
* @param aName The original identifier. |
||||||
|
*/ |
||||||
|
function SourceNode(aLine, aColumn, aSource, aChunks, aName) { |
||||||
|
this.children = []; |
||||||
|
this.sourceContents = {}; |
||||||
|
this.line = aLine == null ? null : aLine; |
||||||
|
this.column = aColumn == null ? null : aColumn; |
||||||
|
this.source = aSource == null ? null : aSource; |
||||||
|
this.name = aName == null ? null : aName; |
||||||
|
this[isSourceNode] = true; |
||||||
|
if (aChunks != null) this.add(aChunks); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Creates a SourceNode from generated code and a SourceMapConsumer. |
||||||
|
* |
||||||
|
* @param aGeneratedCode The generated code |
||||||
|
* @param aSourceMapConsumer The SourceMap for the generated code |
||||||
|
* @param aRelativePath Optional. The path that relative sources in the |
||||||
|
* SourceMapConsumer should be relative to. |
||||||
|
*/ |
||||||
|
SourceNode.fromStringWithSourceMap = |
||||||
|
function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) { |
||||||
|
// The SourceNode we want to fill with the generated code
|
||||||
|
// and the SourceMap
|
||||||
|
var node = new SourceNode(); |
||||||
|
|
||||||
|
// All even indices of this array are one line of the generated code,
|
||||||
|
// while all odd indices are the newlines between two adjacent lines
|
||||||
|
// (since `REGEX_NEWLINE` captures its match).
|
||||||
|
// Processed fragments are accessed by calling `shiftNextLine`.
|
||||||
|
var remainingLines = aGeneratedCode.split(REGEX_NEWLINE); |
||||||
|
var remainingLinesIndex = 0; |
||||||
|
var shiftNextLine = function() { |
||||||
|
var lineContents = getNextLine(); |
||||||
|
// The last line of a file might not have a newline.
|
||||||
|
var newLine = getNextLine() || ""; |
||||||
|
return lineContents + newLine; |
||||||
|
|
||||||
|
function getNextLine() { |
||||||
|
return remainingLinesIndex < remainingLines.length ? |
||||||
|
remainingLines[remainingLinesIndex++] : undefined; |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
// We need to remember the position of "remainingLines"
|
||||||
|
var lastGeneratedLine = 1, lastGeneratedColumn = 0; |
||||||
|
|
||||||
|
// The generate SourceNodes we need a code range.
|
||||||
|
// To extract it current and last mapping is used.
|
||||||
|
// Here we store the last mapping.
|
||||||
|
var lastMapping = null; |
||||||
|
|
||||||
|
aSourceMapConsumer.eachMapping(function (mapping) { |
||||||
|
if (lastMapping !== null) { |
||||||
|
// We add the code from "lastMapping" to "mapping":
|
||||||
|
// First check if there is a new line in between.
|
||||||
|
if (lastGeneratedLine < mapping.generatedLine) { |
||||||
|
// Associate first line with "lastMapping"
|
||||||
|
addMappingWithCode(lastMapping, shiftNextLine()); |
||||||
|
lastGeneratedLine++; |
||||||
|
lastGeneratedColumn = 0; |
||||||
|
// The remaining code is added without mapping
|
||||||
|
} else { |
||||||
|
// There is no new line in between.
|
||||||
|
// Associate the code between "lastGeneratedColumn" and
|
||||||
|
// "mapping.generatedColumn" with "lastMapping"
|
||||||
|
var nextLine = remainingLines[remainingLinesIndex] || ''; |
||||||
|
var code = nextLine.substr(0, mapping.generatedColumn - |
||||||
|
lastGeneratedColumn); |
||||||
|
remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn - |
||||||
|
lastGeneratedColumn); |
||||||
|
lastGeneratedColumn = mapping.generatedColumn; |
||||||
|
addMappingWithCode(lastMapping, code); |
||||||
|
// No more remaining code, continue
|
||||||
|
lastMapping = mapping; |
||||||
|
return; |
||||||
|
} |
||||||
|
} |
||||||
|
// We add the generated code until the first mapping
|
||||||
|
// to the SourceNode without any mapping.
|
||||||
|
// Each line is added as separate string.
|
||||||
|
while (lastGeneratedLine < mapping.generatedLine) { |
||||||
|
node.add(shiftNextLine()); |
||||||
|
lastGeneratedLine++; |
||||||
|
} |
||||||
|
if (lastGeneratedColumn < mapping.generatedColumn) { |
||||||
|
var nextLine = remainingLines[remainingLinesIndex] || ''; |
||||||
|
node.add(nextLine.substr(0, mapping.generatedColumn)); |
||||||
|
remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn); |
||||||
|
lastGeneratedColumn = mapping.generatedColumn; |
||||||
|
} |
||||||
|
lastMapping = mapping; |
||||||
|
}, this); |
||||||
|
// We have processed all mappings.
|
||||||
|
if (remainingLinesIndex < remainingLines.length) { |
||||||
|
if (lastMapping) { |
||||||
|
// Associate the remaining code in the current line with "lastMapping"
|
||||||
|
addMappingWithCode(lastMapping, shiftNextLine()); |
||||||
|
} |
||||||
|
// and add the remaining lines without any mapping
|
||||||
|
node.add(remainingLines.splice(remainingLinesIndex).join("")); |
||||||
|
} |
||||||
|
|
||||||
|
// Copy sourcesContent into SourceNode
|
||||||
|
aSourceMapConsumer.sources.forEach(function (sourceFile) { |
||||||
|
var content = aSourceMapConsumer.sourceContentFor(sourceFile); |
||||||
|
if (content != null) { |
||||||
|
if (aRelativePath != null) { |
||||||
|
sourceFile = util.join(aRelativePath, sourceFile); |
||||||
|
} |
||||||
|
node.setSourceContent(sourceFile, content); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
return node; |
||||||
|
|
||||||
|
function addMappingWithCode(mapping, code) { |
||||||
|
if (mapping === null || mapping.source === undefined) { |
||||||
|
node.add(code); |
||||||
|
} else { |
||||||
|
var source = aRelativePath |
||||||
|
? util.join(aRelativePath, mapping.source) |
||||||
|
: mapping.source; |
||||||
|
node.add(new SourceNode(mapping.originalLine, |
||||||
|
mapping.originalColumn, |
||||||
|
source, |
||||||
|
code, |
||||||
|
mapping.name)); |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Add a chunk of generated JS to this source node. |
||||||
|
* |
||||||
|
* @param aChunk A string snippet of generated JS code, another instance of |
||||||
|
* SourceNode, or an array where each member is one of those things. |
||||||
|
*/ |
||||||
|
SourceNode.prototype.add = function SourceNode_add(aChunk) { |
||||||
|
if (Array.isArray(aChunk)) { |
||||||
|
aChunk.forEach(function (chunk) { |
||||||
|
this.add(chunk); |
||||||
|
}, this); |
||||||
|
} |
||||||
|
else if (aChunk[isSourceNode] || typeof aChunk === "string") { |
||||||
|
if (aChunk) { |
||||||
|
this.children.push(aChunk); |
||||||
|
} |
||||||
|
} |
||||||
|
else { |
||||||
|
throw new TypeError( |
||||||
|
"Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk |
||||||
|
); |
||||||
|
} |
||||||
|
return this; |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Add a chunk of generated JS to the beginning of this source node. |
||||||
|
* |
||||||
|
* @param aChunk A string snippet of generated JS code, another instance of |
||||||
|
* SourceNode, or an array where each member is one of those things. |
||||||
|
*/ |
||||||
|
SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) { |
||||||
|
if (Array.isArray(aChunk)) { |
||||||
|
for (var i = aChunk.length-1; i >= 0; i--) { |
||||||
|
this.prepend(aChunk[i]); |
||||||
|
} |
||||||
|
} |
||||||
|
else if (aChunk[isSourceNode] || typeof aChunk === "string") { |
||||||
|
this.children.unshift(aChunk); |
||||||
|
} |
||||||
|
else { |
||||||
|
throw new TypeError( |
||||||
|
"Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk |
||||||
|
); |
||||||
|
} |
||||||
|
return this; |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Walk over the tree of JS snippets in this node and its children. The |
||||||
|
* walking function is called once for each snippet of JS and is passed that |
||||||
|
* snippet and the its original associated source's line/column location. |
||||||
|
* |
||||||
|
* @param aFn The traversal function. |
||||||
|
*/ |
||||||
|
SourceNode.prototype.walk = function SourceNode_walk(aFn) { |
||||||
|
var chunk; |
||||||
|
for (var i = 0, len = this.children.length; i < len; i++) { |
||||||
|
chunk = this.children[i]; |
||||||
|
if (chunk[isSourceNode]) { |
||||||
|
chunk.walk(aFn); |
||||||
|
} |
||||||
|
else { |
||||||
|
if (chunk !== '') { |
||||||
|
aFn(chunk, { source: this.source, |
||||||
|
line: this.line, |
||||||
|
column: this.column, |
||||||
|
name: this.name }); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between |
||||||
|
* each of `this.children`. |
||||||
|
* |
||||||
|
* @param aSep The separator. |
||||||
|
*/ |
||||||
|
SourceNode.prototype.join = function SourceNode_join(aSep) { |
||||||
|
var newChildren; |
||||||
|
var i; |
||||||
|
var len = this.children.length; |
||||||
|
if (len > 0) { |
||||||
|
newChildren = []; |
||||||
|
for (i = 0; i < len-1; i++) { |
||||||
|
newChildren.push(this.children[i]); |
||||||
|
newChildren.push(aSep); |
||||||
|
} |
||||||
|
newChildren.push(this.children[i]); |
||||||
|
this.children = newChildren; |
||||||
|
} |
||||||
|
return this; |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Call String.prototype.replace on the very right-most source snippet. Useful |
||||||
|
* for trimming whitespace from the end of a source node, etc. |
||||||
|
* |
||||||
|
* @param aPattern The pattern to replace. |
||||||
|
* @param aReplacement The thing to replace the pattern with. |
||||||
|
*/ |
||||||
|
SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) { |
||||||
|
var lastChild = this.children[this.children.length - 1]; |
||||||
|
if (lastChild[isSourceNode]) { |
||||||
|
lastChild.replaceRight(aPattern, aReplacement); |
||||||
|
} |
||||||
|
else if (typeof lastChild === 'string') { |
||||||
|
this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement); |
||||||
|
} |
||||||
|
else { |
||||||
|
this.children.push(''.replace(aPattern, aReplacement)); |
||||||
|
} |
||||||
|
return this; |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Set the source content for a source file. This will be added to the SourceMapGenerator |
||||||
|
* in the sourcesContent field. |
||||||
|
* |
||||||
|
* @param aSourceFile The filename of the source file |
||||||
|
* @param aSourceContent The content of the source file |
||||||
|
*/ |
||||||
|
SourceNode.prototype.setSourceContent = |
||||||
|
function SourceNode_setSourceContent(aSourceFile, aSourceContent) { |
||||||
|
this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent; |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Walk over the tree of SourceNodes. The walking function is called for each |
||||||
|
* source file content and is passed the filename and source content. |
||||||
|
* |
||||||
|
* @param aFn The traversal function. |
||||||
|
*/ |
||||||
|
SourceNode.prototype.walkSourceContents = |
||||||
|
function SourceNode_walkSourceContents(aFn) { |
||||||
|
for (var i = 0, len = this.children.length; i < len; i++) { |
||||||
|
if (this.children[i][isSourceNode]) { |
||||||
|
this.children[i].walkSourceContents(aFn); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
var sources = Object.keys(this.sourceContents); |
||||||
|
for (var i = 0, len = sources.length; i < len; i++) { |
||||||
|
aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Return the string representation of this source node. Walks over the tree |
||||||
|
* and concatenates all the various snippets together to one string. |
||||||
|
*/ |
||||||
|
SourceNode.prototype.toString = function SourceNode_toString() { |
||||||
|
var str = ""; |
||||||
|
this.walk(function (chunk) { |
||||||
|
str += chunk; |
||||||
|
}); |
||||||
|
return str; |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Returns the string representation of this source node along with a source |
||||||
|
* map. |
||||||
|
*/ |
||||||
|
SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) { |
||||||
|
var generated = { |
||||||
|
code: "", |
||||||
|
line: 1, |
||||||
|
column: 0 |
||||||
|
}; |
||||||
|
var map = new SourceMapGenerator(aArgs); |
||||||
|
var sourceMappingActive = false; |
||||||
|
var lastOriginalSource = null; |
||||||
|
var lastOriginalLine = null; |
||||||
|
var lastOriginalColumn = null; |
||||||
|
var lastOriginalName = null; |
||||||
|
this.walk(function (chunk, original) { |
||||||
|
generated.code += chunk; |
||||||
|
if (original.source !== null |
||||||
|
&& original.line !== null |
||||||
|
&& original.column !== null) { |
||||||
|
if(lastOriginalSource !== original.source |
||||||
|
|| lastOriginalLine !== original.line |
||||||
|
|| lastOriginalColumn !== original.column |
||||||
|
|| lastOriginalName !== original.name) { |
||||||
|
map.addMapping({ |
||||||
|
source: original.source, |
||||||
|
original: { |
||||||
|
line: original.line, |
||||||
|
column: original.column |
||||||
|
}, |
||||||
|
generated: { |
||||||
|
line: generated.line, |
||||||
|
column: generated.column |
||||||
|
}, |
||||||
|
name: original.name |
||||||
|
}); |
||||||
|
} |
||||||
|
lastOriginalSource = original.source; |
||||||
|
lastOriginalLine = original.line; |
||||||
|
lastOriginalColumn = original.column; |
||||||
|
lastOriginalName = original.name; |
||||||
|
sourceMappingActive = true; |
||||||
|
} else if (sourceMappingActive) { |
||||||
|
map.addMapping({ |
||||||
|
generated: { |
||||||
|
line: generated.line, |
||||||
|
column: generated.column |
||||||
|
} |
||||||
|
}); |
||||||
|
lastOriginalSource = null; |
||||||
|
sourceMappingActive = false; |
||||||
|
} |
||||||
|
for (var idx = 0, length = chunk.length; idx < length; idx++) { |
||||||
|
if (chunk.charCodeAt(idx) === NEWLINE_CODE) { |
||||||
|
generated.line++; |
||||||
|
generated.column = 0; |
||||||
|
// Mappings end at eol
|
||||||
|
if (idx + 1 === length) { |
||||||
|
lastOriginalSource = null; |
||||||
|
sourceMappingActive = false; |
||||||
|
} else if (sourceMappingActive) { |
||||||
|
map.addMapping({ |
||||||
|
source: original.source, |
||||||
|
original: { |
||||||
|
line: original.line, |
||||||
|
column: original.column |
||||||
|
}, |
||||||
|
generated: { |
||||||
|
line: generated.line, |
||||||
|
column: generated.column |
||||||
|
}, |
||||||
|
name: original.name |
||||||
|
}); |
||||||
|
} |
||||||
|
} else { |
||||||
|
generated.column++; |
||||||
|
} |
||||||
|
} |
||||||
|
}); |
||||||
|
this.walkSourceContents(function (sourceFile, sourceContent) { |
||||||
|
map.setSourceContent(sourceFile, sourceContent); |
||||||
|
}); |
||||||
|
|
||||||
|
return { code: generated.code, map: map }; |
||||||
|
}; |
||||||
|
|
||||||
|
exports.SourceNode = SourceNode; |
@ -0,0 +1,488 @@ |
|||||||
|
/* -*- Mode: js; js-indent-level: 2; -*- */ |
||||||
|
/* |
||||||
|
* Copyright 2011 Mozilla Foundation and contributors |
||||||
|
* Licensed under the New BSD license. See LICENSE or: |
||||||
|
* http://opensource.org/licenses/BSD-3-Clause
|
||||||
|
*/ |
||||||
|
|
||||||
|
/** |
||||||
|
* This is a helper function for getting values from parameter/options |
||||||
|
* objects. |
||||||
|
* |
||||||
|
* @param args The object we are extracting values from |
||||||
|
* @param name The name of the property we are getting. |
||||||
|
* @param defaultValue An optional value to return if the property is missing |
||||||
|
* from the object. If this is not specified and the property is missing, an |
||||||
|
* error will be thrown. |
||||||
|
*/ |
||||||
|
function getArg(aArgs, aName, aDefaultValue) { |
||||||
|
if (aName in aArgs) { |
||||||
|
return aArgs[aName]; |
||||||
|
} else if (arguments.length === 3) { |
||||||
|
return aDefaultValue; |
||||||
|
} else { |
||||||
|
throw new Error('"' + aName + '" is a required argument.'); |
||||||
|
} |
||||||
|
} |
||||||
|
exports.getArg = getArg; |
||||||
|
|
||||||
|
var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/; |
||||||
|
var dataUrlRegexp = /^data:.+\,.+$/; |
||||||
|
|
||||||
|
function urlParse(aUrl) { |
||||||
|
var match = aUrl.match(urlRegexp); |
||||||
|
if (!match) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
return { |
||||||
|
scheme: match[1], |
||||||
|
auth: match[2], |
||||||
|
host: match[3], |
||||||
|
port: match[4], |
||||||
|
path: match[5] |
||||||
|
}; |
||||||
|
} |
||||||
|
exports.urlParse = urlParse; |
||||||
|
|
||||||
|
function urlGenerate(aParsedUrl) { |
||||||
|
var url = ''; |
||||||
|
if (aParsedUrl.scheme) { |
||||||
|
url += aParsedUrl.scheme + ':'; |
||||||
|
} |
||||||
|
url += '//'; |
||||||
|
if (aParsedUrl.auth) { |
||||||
|
url += aParsedUrl.auth + '@'; |
||||||
|
} |
||||||
|
if (aParsedUrl.host) { |
||||||
|
url += aParsedUrl.host; |
||||||
|
} |
||||||
|
if (aParsedUrl.port) { |
||||||
|
url += ":" + aParsedUrl.port |
||||||
|
} |
||||||
|
if (aParsedUrl.path) { |
||||||
|
url += aParsedUrl.path; |
||||||
|
} |
||||||
|
return url; |
||||||
|
} |
||||||
|
exports.urlGenerate = urlGenerate; |
||||||
|
|
||||||
|
/** |
||||||
|
* Normalizes a path, or the path portion of a URL: |
||||||
|
* |
||||||
|
* - Replaces consecutive slashes with one slash. |
||||||
|
* - Removes unnecessary '.' parts. |
||||||
|
* - Removes unnecessary '<dir>/..' parts. |
||||||
|
* |
||||||
|
* Based on code in the Node.js 'path' core module. |
||||||
|
* |
||||||
|
* @param aPath The path or url to normalize. |
||||||
|
*/ |
||||||
|
function normalize(aPath) { |
||||||
|
var path = aPath; |
||||||
|
var url = urlParse(aPath); |
||||||
|
if (url) { |
||||||
|
if (!url.path) { |
||||||
|
return aPath; |
||||||
|
} |
||||||
|
path = url.path; |
||||||
|
} |
||||||
|
var isAbsolute = exports.isAbsolute(path); |
||||||
|
|
||||||
|
var parts = path.split(/\/+/); |
||||||
|
for (var part, up = 0, i = parts.length - 1; i >= 0; i--) { |
||||||
|
part = parts[i]; |
||||||
|
if (part === '.') { |
||||||
|
parts.splice(i, 1); |
||||||
|
} else if (part === '..') { |
||||||
|
up++; |
||||||
|
} else if (up > 0) { |
||||||
|
if (part === '') { |
||||||
|
// The first part is blank if the path is absolute. Trying to go
|
||||||
|
// above the root is a no-op. Therefore we can remove all '..' parts
|
||||||
|
// directly after the root.
|
||||||
|
parts.splice(i + 1, up); |
||||||
|
up = 0; |
||||||
|
} else { |
||||||
|
parts.splice(i, 2); |
||||||
|
up--; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
path = parts.join('/'); |
||||||
|
|
||||||
|
if (path === '') { |
||||||
|
path = isAbsolute ? '/' : '.'; |
||||||
|
} |
||||||
|
|
||||||
|
if (url) { |
||||||
|
url.path = path; |
||||||
|
return urlGenerate(url); |
||||||
|
} |
||||||
|
return path; |
||||||
|
} |
||||||
|
exports.normalize = normalize; |
||||||
|
|
||||||
|
/** |
||||||
|
* Joins two paths/URLs. |
||||||
|
* |
||||||
|
* @param aRoot The root path or URL. |
||||||
|
* @param aPath The path or URL to be joined with the root. |
||||||
|
* |
||||||
|
* - If aPath is a URL or a data URI, aPath is returned, unless aPath is a |
||||||
|
* scheme-relative URL: Then the scheme of aRoot, if any, is prepended |
||||||
|
* first. |
||||||
|
* - Otherwise aPath is a path. If aRoot is a URL, then its path portion |
||||||
|
* is updated with the result and aRoot is returned. Otherwise the result |
||||||
|
* is returned. |
||||||
|
* - If aPath is absolute, the result is aPath. |
||||||
|
* - Otherwise the two paths are joined with a slash. |
||||||
|
* - Joining for example 'http://' and 'www.example.com' is also supported. |
||||||
|
*/ |
||||||
|
function join(aRoot, aPath) { |
||||||
|
if (aRoot === "") { |
||||||
|
aRoot = "."; |
||||||
|
} |
||||||
|
if (aPath === "") { |
||||||
|
aPath = "."; |
||||||
|
} |
||||||
|
var aPathUrl = urlParse(aPath); |
||||||
|
var aRootUrl = urlParse(aRoot); |
||||||
|
if (aRootUrl) { |
||||||
|
aRoot = aRootUrl.path || '/'; |
||||||
|
} |
||||||
|
|
||||||
|
// `join(foo, '//www.example.org')`
|
||||||
|
if (aPathUrl && !aPathUrl.scheme) { |
||||||
|
if (aRootUrl) { |
||||||
|
aPathUrl.scheme = aRootUrl.scheme; |
||||||
|
} |
||||||
|
return urlGenerate(aPathUrl); |
||||||
|
} |
||||||
|
|
||||||
|
if (aPathUrl || aPath.match(dataUrlRegexp)) { |
||||||
|
return aPath; |
||||||
|
} |
||||||
|
|
||||||
|
// `join('http://', 'www.example.com')`
|
||||||
|
if (aRootUrl && !aRootUrl.host && !aRootUrl.path) { |
||||||
|
aRootUrl.host = aPath; |
||||||
|
return urlGenerate(aRootUrl); |
||||||
|
} |
||||||
|
|
||||||
|
var joined = aPath.charAt(0) === '/' |
||||||
|
? aPath |
||||||
|
: normalize(aRoot.replace(/\/+$/, '') + '/' + aPath); |
||||||
|
|
||||||
|
if (aRootUrl) { |
||||||
|
aRootUrl.path = joined; |
||||||
|
return urlGenerate(aRootUrl); |
||||||
|
} |
||||||
|
return joined; |
||||||
|
} |
||||||
|
exports.join = join; |
||||||
|
|
||||||
|
exports.isAbsolute = function (aPath) { |
||||||
|
return aPath.charAt(0) === '/' || urlRegexp.test(aPath); |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Make a path relative to a URL or another path. |
||||||
|
* |
||||||
|
* @param aRoot The root path or URL. |
||||||
|
* @param aPath The path or URL to be made relative to aRoot. |
||||||
|
*/ |
||||||
|
function relative(aRoot, aPath) { |
||||||
|
if (aRoot === "") { |
||||||
|
aRoot = "."; |
||||||
|
} |
||||||
|
|
||||||
|
aRoot = aRoot.replace(/\/$/, ''); |
||||||
|
|
||||||
|
// It is possible for the path to be above the root. In this case, simply
|
||||||
|
// checking whether the root is a prefix of the path won't work. Instead, we
|
||||||
|
// need to remove components from the root one by one, until either we find
|
||||||
|
// a prefix that fits, or we run out of components to remove.
|
||||||
|
var level = 0; |
||||||
|
while (aPath.indexOf(aRoot + '/') !== 0) { |
||||||
|
var index = aRoot.lastIndexOf("/"); |
||||||
|
if (index < 0) { |
||||||
|
return aPath; |
||||||
|
} |
||||||
|
|
||||||
|
// If the only part of the root that is left is the scheme (i.e. http://,
|
||||||
|
// file:///, etc.), one or more slashes (/), or simply nothing at all, we
|
||||||
|
// have exhausted all components, so the path is not relative to the root.
|
||||||
|
aRoot = aRoot.slice(0, index); |
||||||
|
if (aRoot.match(/^([^\/]+:\/)?\/*$/)) { |
||||||
|
return aPath; |
||||||
|
} |
||||||
|
|
||||||
|
++level; |
||||||
|
} |
||||||
|
|
||||||
|
// Make sure we add a "../" for each component we removed from the root.
|
||||||
|
return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1); |
||||||
|
} |
||||||
|
exports.relative = relative; |
||||||
|
|
||||||
|
var supportsNullProto = (function () { |
||||||
|
var obj = Object.create(null); |
||||||
|
return !('__proto__' in obj); |
||||||
|
}()); |
||||||
|
|
||||||
|
function identity (s) { |
||||||
|
return s; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Because behavior goes wacky when you set `__proto__` on objects, we |
||||||
|
* have to prefix all the strings in our set with an arbitrary character. |
||||||
|
* |
||||||
|
* See https://github.com/mozilla/source-map/pull/31 and
|
||||||
|
* https://github.com/mozilla/source-map/issues/30
|
||||||
|
* |
||||||
|
* @param String aStr |
||||||
|
*/ |
||||||
|
function toSetString(aStr) { |
||||||
|
if (isProtoString(aStr)) { |
||||||
|
return '$' + aStr; |
||||||
|
} |
||||||
|
|
||||||
|
return aStr; |
||||||
|
} |
||||||
|
exports.toSetString = supportsNullProto ? identity : toSetString; |
||||||
|
|
||||||
|
function fromSetString(aStr) { |
||||||
|
if (isProtoString(aStr)) { |
||||||
|
return aStr.slice(1); |
||||||
|
} |
||||||
|
|
||||||
|
return aStr; |
||||||
|
} |
||||||
|
exports.fromSetString = supportsNullProto ? identity : fromSetString; |
||||||
|
|
||||||
|
function isProtoString(s) { |
||||||
|
if (!s) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
var length = s.length; |
||||||
|
|
||||||
|
if (length < 9 /* "__proto__".length */) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
if (s.charCodeAt(length - 1) !== 95 /* '_' */ || |
||||||
|
s.charCodeAt(length - 2) !== 95 /* '_' */ || |
||||||
|
s.charCodeAt(length - 3) !== 111 /* 'o' */ || |
||||||
|
s.charCodeAt(length - 4) !== 116 /* 't' */ || |
||||||
|
s.charCodeAt(length - 5) !== 111 /* 'o' */ || |
||||||
|
s.charCodeAt(length - 6) !== 114 /* 'r' */ || |
||||||
|
s.charCodeAt(length - 7) !== 112 /* 'p' */ || |
||||||
|
s.charCodeAt(length - 8) !== 95 /* '_' */ || |
||||||
|
s.charCodeAt(length - 9) !== 95 /* '_' */) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
for (var i = length - 10; i >= 0; i--) { |
||||||
|
if (s.charCodeAt(i) !== 36 /* '$' */) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Comparator between two mappings where the original positions are compared. |
||||||
|
* |
||||||
|
* Optionally pass in `true` as `onlyCompareGenerated` to consider two |
||||||
|
* mappings with the same original source/line/column, but different generated |
||||||
|
* line and column the same. Useful when searching for a mapping with a |
||||||
|
* stubbed out mapping. |
||||||
|
*/ |
||||||
|
function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) { |
||||||
|
var cmp = strcmp(mappingA.source, mappingB.source); |
||||||
|
if (cmp !== 0) { |
||||||
|
return cmp; |
||||||
|
} |
||||||
|
|
||||||
|
cmp = mappingA.originalLine - mappingB.originalLine; |
||||||
|
if (cmp !== 0) { |
||||||
|
return cmp; |
||||||
|
} |
||||||
|
|
||||||
|
cmp = mappingA.originalColumn - mappingB.originalColumn; |
||||||
|
if (cmp !== 0 || onlyCompareOriginal) { |
||||||
|
return cmp; |
||||||
|
} |
||||||
|
|
||||||
|
cmp = mappingA.generatedColumn - mappingB.generatedColumn; |
||||||
|
if (cmp !== 0) { |
||||||
|
return cmp; |
||||||
|
} |
||||||
|
|
||||||
|
cmp = mappingA.generatedLine - mappingB.generatedLine; |
||||||
|
if (cmp !== 0) { |
||||||
|
return cmp; |
||||||
|
} |
||||||
|
|
||||||
|
return strcmp(mappingA.name, mappingB.name); |
||||||
|
} |
||||||
|
exports.compareByOriginalPositions = compareByOriginalPositions; |
||||||
|
|
||||||
|
/** |
||||||
|
* Comparator between two mappings with deflated source and name indices where |
||||||
|
* the generated positions are compared. |
||||||
|
* |
||||||
|
* Optionally pass in `true` as `onlyCompareGenerated` to consider two |
||||||
|
* mappings with the same generated line and column, but different |
||||||
|
* source/name/original line and column the same. Useful when searching for a |
||||||
|
* mapping with a stubbed out mapping. |
||||||
|
*/ |
||||||
|
function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) { |
||||||
|
var cmp = mappingA.generatedLine - mappingB.generatedLine; |
||||||
|
if (cmp !== 0) { |
||||||
|
return cmp; |
||||||
|
} |
||||||
|
|
||||||
|
cmp = mappingA.generatedColumn - mappingB.generatedColumn; |
||||||
|
if (cmp !== 0 || onlyCompareGenerated) { |
||||||
|
return cmp; |
||||||
|
} |
||||||
|
|
||||||
|
cmp = strcmp(mappingA.source, mappingB.source); |
||||||
|
if (cmp !== 0) { |
||||||
|
return cmp; |
||||||
|
} |
||||||
|
|
||||||
|
cmp = mappingA.originalLine - mappingB.originalLine; |
||||||
|
if (cmp !== 0) { |
||||||
|
return cmp; |
||||||
|
} |
||||||
|
|
||||||
|
cmp = mappingA.originalColumn - mappingB.originalColumn; |
||||||
|
if (cmp !== 0) { |
||||||
|
return cmp; |
||||||
|
} |
||||||
|
|
||||||
|
return strcmp(mappingA.name, mappingB.name); |
||||||
|
} |
||||||
|
exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated; |
||||||
|
|
||||||
|
function strcmp(aStr1, aStr2) { |
||||||
|
if (aStr1 === aStr2) { |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
if (aStr1 === null) { |
||||||
|
return 1; // aStr2 !== null
|
||||||
|
} |
||||||
|
|
||||||
|
if (aStr2 === null) { |
||||||
|
return -1; // aStr1 !== null
|
||||||
|
} |
||||||
|
|
||||||
|
if (aStr1 > aStr2) { |
||||||
|
return 1; |
||||||
|
} |
||||||
|
|
||||||
|
return -1; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Comparator between two mappings with inflated source and name strings where |
||||||
|
* the generated positions are compared. |
||||||
|
*/ |
||||||
|
function compareByGeneratedPositionsInflated(mappingA, mappingB) { |
||||||
|
var cmp = mappingA.generatedLine - mappingB.generatedLine; |
||||||
|
if (cmp !== 0) { |
||||||
|
return cmp; |
||||||
|
} |
||||||
|
|
||||||
|
cmp = mappingA.generatedColumn - mappingB.generatedColumn; |
||||||
|
if (cmp !== 0) { |
||||||
|
return cmp; |
||||||
|
} |
||||||
|
|
||||||
|
cmp = strcmp(mappingA.source, mappingB.source); |
||||||
|
if (cmp !== 0) { |
||||||
|
return cmp; |
||||||
|
} |
||||||
|
|
||||||
|
cmp = mappingA.originalLine - mappingB.originalLine; |
||||||
|
if (cmp !== 0) { |
||||||
|
return cmp; |
||||||
|
} |
||||||
|
|
||||||
|
cmp = mappingA.originalColumn - mappingB.originalColumn; |
||||||
|
if (cmp !== 0) { |
||||||
|
return cmp; |
||||||
|
} |
||||||
|
|
||||||
|
return strcmp(mappingA.name, mappingB.name); |
||||||
|
} |
||||||
|
exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated; |
||||||
|
|
||||||
|
/** |
||||||
|
* Strip any JSON XSSI avoidance prefix from the string (as documented |
||||||
|
* in the source maps specification), and then parse the string as |
||||||
|
* JSON. |
||||||
|
*/ |
||||||
|
function parseSourceMapInput(str) { |
||||||
|
return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, '')); |
||||||
|
} |
||||||
|
exports.parseSourceMapInput = parseSourceMapInput; |
||||||
|
|
||||||
|
/** |
||||||
|
* Compute the URL of a source given the the source root, the source's |
||||||
|
* URL, and the source map's URL. |
||||||
|
*/ |
||||||
|
function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) { |
||||||
|
sourceURL = sourceURL || ''; |
||||||
|
|
||||||
|
if (sourceRoot) { |
||||||
|
// This follows what Chrome does.
|
||||||
|
if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') { |
||||||
|
sourceRoot += '/'; |
||||||
|
} |
||||||
|
// The spec says:
|
||||||
|
// Line 4: An optional source root, useful for relocating source
|
||||||
|
// files on a server or removing repeated values in the
|
||||||
|
// “sources” entry. This value is prepended to the individual
|
||||||
|
// entries in the “source” field.
|
||||||
|
sourceURL = sourceRoot + sourceURL; |
||||||
|
} |
||||||
|
|
||||||
|
// Historically, SourceMapConsumer did not take the sourceMapURL as
|
||||||
|
// a parameter. This mode is still somewhat supported, which is why
|
||||||
|
// this code block is conditional. However, it's preferable to pass
|
||||||
|
// the source map URL to SourceMapConsumer, so that this function
|
||||||
|
// can implement the source URL resolution algorithm as outlined in
|
||||||
|
// the spec. This block is basically the equivalent of:
|
||||||
|
// new URL(sourceURL, sourceMapURL).toString()
|
||||||
|
// ... except it avoids using URL, which wasn't available in the
|
||||||
|
// older releases of node still supported by this library.
|
||||||
|
//
|
||||||
|
// The spec says:
|
||||||
|
// If the sources are not absolute URLs after prepending of the
|
||||||
|
// “sourceRoot”, the sources are resolved relative to the
|
||||||
|
// SourceMap (like resolving script src in a html document).
|
||||||
|
if (sourceMapURL) { |
||||||
|
var parsed = urlParse(sourceMapURL); |
||||||
|
if (!parsed) { |
||||||
|
throw new Error("sourceMapURL could not be parsed"); |
||||||
|
} |
||||||
|
if (parsed.path) { |
||||||
|
// Strip the last path component, but keep the "/".
|
||||||
|
var index = parsed.path.lastIndexOf('/'); |
||||||
|
if (index >= 0) { |
||||||
|
parsed.path = parsed.path.substring(0, index + 1); |
||||||
|
} |
||||||
|
} |
||||||
|
sourceURL = join(urlGenerate(parsed), sourceURL); |
||||||
|
} |
||||||
|
|
||||||
|
return normalize(sourceURL); |
||||||
|
} |
||||||
|
exports.computeSourceURL = computeSourceURL; |
@ -0,0 +1,98 @@ |
|||||||
|
export interface StartOfSourceMap { |
||||||
|
file?: string; |
||||||
|
sourceRoot?: string; |
||||||
|
} |
||||||
|
|
||||||
|
export interface RawSourceMap extends StartOfSourceMap { |
||||||
|
version: string; |
||||||
|
sources: string[]; |
||||||
|
names: string[]; |
||||||
|
sourcesContent?: string[]; |
||||||
|
mappings: string; |
||||||
|
} |
||||||
|
|
||||||
|
export interface Position { |
||||||
|
line: number; |
||||||
|
column: number; |
||||||
|
} |
||||||
|
|
||||||
|
export interface LineRange extends Position { |
||||||
|
lastColumn: number; |
||||||
|
} |
||||||
|
|
||||||
|
export interface FindPosition extends Position { |
||||||
|
// SourceMapConsumer.GREATEST_LOWER_BOUND or SourceMapConsumer.LEAST_UPPER_BOUND
|
||||||
|
bias?: number; |
||||||
|
} |
||||||
|
|
||||||
|
export interface SourceFindPosition extends FindPosition { |
||||||
|
source: string; |
||||||
|
} |
||||||
|
|
||||||
|
export interface MappedPosition extends Position { |
||||||
|
source: string; |
||||||
|
name?: string; |
||||||
|
} |
||||||
|
|
||||||
|
export interface MappingItem { |
||||||
|
source: string; |
||||||
|
generatedLine: number; |
||||||
|
generatedColumn: number; |
||||||
|
originalLine: number; |
||||||
|
originalColumn: number; |
||||||
|
name: string; |
||||||
|
} |
||||||
|
|
||||||
|
export class SourceMapConsumer { |
||||||
|
static GENERATED_ORDER: number; |
||||||
|
static ORIGINAL_ORDER: number; |
||||||
|
|
||||||
|
static GREATEST_LOWER_BOUND: number; |
||||||
|
static LEAST_UPPER_BOUND: number; |
||||||
|
|
||||||
|
constructor(rawSourceMap: RawSourceMap); |
||||||
|
computeColumnSpans(): void; |
||||||
|
originalPositionFor(generatedPosition: FindPosition): MappedPosition; |
||||||
|
generatedPositionFor(originalPosition: SourceFindPosition): LineRange; |
||||||
|
allGeneratedPositionsFor(originalPosition: MappedPosition): Position[]; |
||||||
|
hasContentsOfAllSources(): boolean; |
||||||
|
sourceContentFor(source: string, returnNullOnMissing?: boolean): string; |
||||||
|
eachMapping(callback: (mapping: MappingItem) => void, context?: any, order?: number): void; |
||||||
|
} |
||||||
|
|
||||||
|
export interface Mapping { |
||||||
|
generated: Position; |
||||||
|
original: Position; |
||||||
|
source: string; |
||||||
|
name?: string; |
||||||
|
} |
||||||
|
|
||||||
|
export class SourceMapGenerator { |
||||||
|
constructor(startOfSourceMap?: StartOfSourceMap); |
||||||
|
static fromSourceMap(sourceMapConsumer: SourceMapConsumer): SourceMapGenerator; |
||||||
|
addMapping(mapping: Mapping): void; |
||||||
|
setSourceContent(sourceFile: string, sourceContent: string): void; |
||||||
|
applySourceMap(sourceMapConsumer: SourceMapConsumer, sourceFile?: string, sourceMapPath?: string): void; |
||||||
|
toString(): string; |
||||||
|
} |
||||||
|
|
||||||
|
export interface CodeWithSourceMap { |
||||||
|
code: string; |
||||||
|
map: SourceMapGenerator; |
||||||
|
} |
||||||
|
|
||||||
|
export class SourceNode { |
||||||
|
constructor(); |
||||||
|
constructor(line: number, column: number, source: string); |
||||||
|
constructor(line: number, column: number, source: string, chunk?: string, name?: string); |
||||||
|
static fromStringWithSourceMap(code: string, sourceMapConsumer: SourceMapConsumer, relativePath?: string): SourceNode; |
||||||
|
add(chunk: string): void; |
||||||
|
prepend(chunk: string): void; |
||||||
|
setSourceContent(sourceFile: string, sourceContent: string): void; |
||||||
|
walk(fn: (chunk: string, mapping: MappedPosition) => void): void; |
||||||
|
walkSourceContents(fn: (file: string, content: string) => void): void; |
||||||
|
join(sep: string): SourceNode; |
||||||
|
replaceRight(pattern: string, replacement: string): SourceNode; |
||||||
|
toString(): string; |
||||||
|
toStringWithSourceMap(startOfSourceMap?: StartOfSourceMap): CodeWithSourceMap; |
||||||
|
} |
@ -0,0 +1,8 @@ |
|||||||
|
/* |
||||||
|
* Copyright 2009-2011 Mozilla Foundation and contributors |
||||||
|
* Licensed under the New BSD license. See LICENSE.txt or: |
||||||
|
* http://opensource.org/licenses/BSD-3-Clause
|
||||||
|
*/ |
||||||
|
exports.SourceMapGenerator = require('./lib/source-map-generator').SourceMapGenerator; |
||||||
|
exports.SourceMapConsumer = require('./lib/source-map-consumer').SourceMapConsumer; |
||||||
|
exports.SourceNode = require('./lib/source-node').SourceNode; |
@ -0,0 +1,90 @@ |
|||||||
|
{ |
||||||
|
"_from": "@gulp-sourcemaps/identity-map@1.X", |
||||||
|
"_id": "@gulp-sourcemaps/identity-map@1.0.2", |
||||||
|
"_inBundle": false, |
||||||
|
"_integrity": "sha512-ciiioYMLdo16ShmfHBXJBOFm3xPC4AuwO4xeRpFeHz7WK9PYsWCmigagG2XyzZpubK4a3qNKoUBDhbzHfa50LQ==", |
||||||
|
"_location": "/@gulp-sourcemaps/identity-map", |
||||||
|
"_phantomChildren": {}, |
||||||
|
"_requested": { |
||||||
|
"type": "range", |
||||||
|
"registry": true, |
||||||
|
"raw": "@gulp-sourcemaps/identity-map@1.X", |
||||||
|
"name": "@gulp-sourcemaps/identity-map", |
||||||
|
"escapedName": "@gulp-sourcemaps%2fidentity-map", |
||||||
|
"scope": "@gulp-sourcemaps", |
||||||
|
"rawSpec": "1.X", |
||||||
|
"saveSpec": null, |
||||||
|
"fetchSpec": "1.X" |
||||||
|
}, |
||||||
|
"_requiredBy": [ |
||||||
|
"/gulp-sourcemaps" |
||||||
|
], |
||||||
|
"_resolved": "https://registry.npmjs.org/@gulp-sourcemaps/identity-map/-/identity-map-1.0.2.tgz", |
||||||
|
"_shasum": "1e6fe5d8027b1f285dc0d31762f566bccd73d5a9", |
||||||
|
"_spec": "@gulp-sourcemaps/identity-map@1.X", |
||||||
|
"_where": "/Users/rdrew/themes/lmmi_journal_theme/node_modules/gulp-sourcemaps", |
||||||
|
"author": { |
||||||
|
"name": "Gulp-sourcemaps Team" |
||||||
|
}, |
||||||
|
"bugs": { |
||||||
|
"url": "https://github.com/gulp-sourcemaps/identity-map/issues" |
||||||
|
}, |
||||||
|
"bundleDependencies": false, |
||||||
|
"contributors": [ |
||||||
|
{ |
||||||
|
"name": "Blaine Bublitz", |
||||||
|
"email": "blaine.bublitz@gmail.com" |
||||||
|
} |
||||||
|
], |
||||||
|
"dependencies": { |
||||||
|
"acorn": "^5.0.3", |
||||||
|
"css": "^2.2.1", |
||||||
|
"normalize-path": "^2.1.1", |
||||||
|
"source-map": "^0.6.0", |
||||||
|
"through2": "^2.0.3" |
||||||
|
}, |
||||||
|
"deprecated": false, |
||||||
|
"description": "Gulp plugin for generating an identity sourcemap for a file.", |
||||||
|
"devDependencies": { |
||||||
|
"eslint": "^1.7.3", |
||||||
|
"eslint-config-gulp": "^2.0.0", |
||||||
|
"expect": "^1.19.0", |
||||||
|
"istanbul": "^0.4.3", |
||||||
|
"istanbul-coveralls": "^1.0.3", |
||||||
|
"jscs": "^2.3.5", |
||||||
|
"jscs-preset-gulp": "^1.0.0", |
||||||
|
"mississippi": "^1.3.0", |
||||||
|
"mocha": "^2.4.5", |
||||||
|
"vinyl": "^2.0.1" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.10" |
||||||
|
}, |
||||||
|
"files": [ |
||||||
|
"LICENSE", |
||||||
|
"index.js", |
||||||
|
"lib" |
||||||
|
], |
||||||
|
"homepage": "https://github.com/gulp-sourcemaps/identity-map#readme", |
||||||
|
"keywords": [ |
||||||
|
"sourcemap", |
||||||
|
"identity", |
||||||
|
"generate", |
||||||
|
"stream" |
||||||
|
], |
||||||
|
"license": "MIT", |
||||||
|
"main": "index.js", |
||||||
|
"name": "@gulp-sourcemaps/identity-map", |
||||||
|
"repository": { |
||||||
|
"type": "git", |
||||||
|
"url": "git+https://github.com/gulp-sourcemaps/identity-map.git" |
||||||
|
}, |
||||||
|
"scripts": { |
||||||
|
"cover": "istanbul cover _mocha --report lcovonly", |
||||||
|
"coveralls": "npm run cover && istanbul-coveralls", |
||||||
|
"lint": "eslint . && jscs index.js test/index.js lib/", |
||||||
|
"pretest": "npm run lint", |
||||||
|
"test": "mocha --async-only" |
||||||
|
}, |
||||||
|
"version": "1.0.2" |
||||||
|
} |
@ -0,0 +1,21 @@ |
|||||||
|
The MIT License (MIT) |
||||||
|
|
||||||
|
Copyright (c) 2017 Blaine Bublitz <blaine.bublitz@gmail.com> |
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||||
|
of this software and associated documentation files (the "Software"), to deal |
||||||
|
in the Software without restriction, including without limitation the rights |
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||||
|
copies of the Software, and to permit persons to whom the Software is |
||||||
|
furnished to do so, subject to the following conditions: |
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all |
||||||
|
copies or substantial portions of the Software. |
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||||
|
SOFTWARE. |
@ -0,0 +1,52 @@ |
|||||||
|
# @gulp-sourcemaps/map-sources |
||||||
|
|
||||||
|
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] |
||||||
|
|
||||||
|
Gulp plugin for mapping sources of a sourcemap. |
||||||
|
|
||||||
|
## Example |
||||||
|
|
||||||
|
```js |
||||||
|
var mapSources = require('@gulp-sourcemaps/map-sources'); |
||||||
|
|
||||||
|
gulp.src(...) |
||||||
|
.pipe(sourcemaps.init()) |
||||||
|
.pipe(mapSources(function(sourcePath, file) { |
||||||
|
return '../' + sourcePath; |
||||||
|
})) |
||||||
|
.pipe(sourcemaps.write()) |
||||||
|
.pipe(gulp.dest(...)) |
||||||
|
``` |
||||||
|
|
||||||
|
## API |
||||||
|
|
||||||
|
### `mapSources(mapFn)` |
||||||
|
|
||||||
|
Takes a map function as the only argument. Returns an `objectMode` Transform stream. |
||||||
|
|
||||||
|
#### `mapFn(sourcePath, file)` |
||||||
|
|
||||||
|
The map function is called once per value of the `sources` array of a `sourceMap` attached to each [`Vinyl`][vinyl-url] object passed through the stream. The map function is called with the `sourcePath` string from the `sources` array and the `file` object it originated from. The return value replaces the original value in the array. |
||||||
|
|
||||||
|
If a `Vinyl` object doesn't have a `sourceMap` or `sourceMap.sources` property, the file is passed through the stream without having the `mapFn` called. |
||||||
|
|
||||||
|
All `sources` are normalized to use `/` instead of `\\` as path separators. |
||||||
|
|
||||||
|
## License |
||||||
|
|
||||||
|
MIT |
||||||
|
|
||||||
|
[vinyl-url]: https://github.com/gulpjs/vinyl |
||||||
|
|
||||||
|
[downloads-image]: http://img.shields.io/npm/dm/@gulp-sourcemaps/map-sources.svg |
||||||
|
[npm-url]: https://npmjs.org/package/@gulp-sourcemaps/map-sources |
||||||
|
[npm-image]: http://img.shields.io/npm/v/@gulp-sourcemaps/map-sources.svg |
||||||
|
|
||||||
|
[travis-url]: https://travis-ci.org/gulp-sourcemaps/map-sources |
||||||
|
[travis-image]: http://img.shields.io/travis/gulp-sourcemaps/map-sources.svg?label=travis-ci |
||||||
|
|
||||||
|
[appveyor-url]: https://ci.appveyor.com/project/phated/map-sources |
||||||
|
[appveyor-image]: https://img.shields.io/appveyor/ci/phated/map-sources.svg?label=appveyor |
||||||
|
|
||||||
|
[coveralls-url]: https://coveralls.io/r/gulp-sourcemaps/map-sources |
||||||
|
[coveralls-image]: http://img.shields.io/coveralls/gulp-sourcemaps/map-sources.svg |
@ -0,0 +1,30 @@ |
|||||||
|
'use strict'; |
||||||
|
|
||||||
|
var through = require('through2'); |
||||||
|
var normalize = require('normalize-path'); |
||||||
|
|
||||||
|
function mapSources(mapFn) { |
||||||
|
|
||||||
|
function transform(file, _, cb) { |
||||||
|
if (!file.sourceMap || !file.sourceMap.sources) { |
||||||
|
return cb(null, file); |
||||||
|
} |
||||||
|
|
||||||
|
function mapper(sourcePath) { |
||||||
|
var result = sourcePath; |
||||||
|
if (typeof mapFn === 'function') { |
||||||
|
result = mapFn(sourcePath, file); |
||||||
|
} |
||||||
|
|
||||||
|
return normalize(result); |
||||||
|
} |
||||||
|
|
||||||
|
file.sourceMap.sources = file.sourceMap.sources.map(mapper); |
||||||
|
|
||||||
|
cb(null, file); |
||||||
|
} |
||||||
|
|
||||||
|
return through.obj(transform); |
||||||
|
} |
||||||
|
|
||||||
|
module.exports = mapSources; |
@ -0,0 +1,85 @@ |
|||||||
|
{ |
||||||
|
"_from": "@gulp-sourcemaps/map-sources@1.X", |
||||||
|
"_id": "@gulp-sourcemaps/map-sources@1.0.0", |
||||||
|
"_inBundle": false, |
||||||
|
"_integrity": "sha1-iQrnxdjId/bThIYCFazp1+yUW9o=", |
||||||
|
"_location": "/@gulp-sourcemaps/map-sources", |
||||||
|
"_phantomChildren": {}, |
||||||
|
"_requested": { |
||||||
|
"type": "range", |
||||||
|
"registry": true, |
||||||
|
"raw": "@gulp-sourcemaps/map-sources@1.X", |
||||||
|
"name": "@gulp-sourcemaps/map-sources", |
||||||
|
"escapedName": "@gulp-sourcemaps%2fmap-sources", |
||||||
|
"scope": "@gulp-sourcemaps", |
||||||
|
"rawSpec": "1.X", |
||||||
|
"saveSpec": null, |
||||||
|
"fetchSpec": "1.X" |
||||||
|
}, |
||||||
|
"_requiredBy": [ |
||||||
|
"/gulp-sourcemaps" |
||||||
|
], |
||||||
|
"_resolved": "https://registry.npmjs.org/@gulp-sourcemaps/map-sources/-/map-sources-1.0.0.tgz", |
||||||
|
"_shasum": "890ae7c5d8c877f6d384860215ace9d7ec945bda", |
||||||
|
"_spec": "@gulp-sourcemaps/map-sources@1.X", |
||||||
|
"_where": "/Users/rdrew/themes/lmmi_journal_theme/node_modules/gulp-sourcemaps", |
||||||
|
"author": { |
||||||
|
"name": "Gulp-sourcemaps Team" |
||||||
|
}, |
||||||
|
"bugs": { |
||||||
|
"url": "https://github.com/gulp-sourcemaps/map-sources/issues" |
||||||
|
}, |
||||||
|
"bundleDependencies": false, |
||||||
|
"contributors": [ |
||||||
|
{ |
||||||
|
"name": "Blaine Bublitz", |
||||||
|
"email": "blaine.bublitz@gmail.com" |
||||||
|
} |
||||||
|
], |
||||||
|
"dependencies": { |
||||||
|
"normalize-path": "^2.0.1", |
||||||
|
"through2": "^2.0.3" |
||||||
|
}, |
||||||
|
"deprecated": false, |
||||||
|
"description": "Gulp plugin for mapping sources of a sourcemap.", |
||||||
|
"devDependencies": { |
||||||
|
"eslint": "^1.7.3", |
||||||
|
"eslint-config-gulp": "^2.0.0", |
||||||
|
"expect": "^1.19.0", |
||||||
|
"istanbul": "^0.4.3", |
||||||
|
"istanbul-coveralls": "^1.0.3", |
||||||
|
"jscs": "^2.3.5", |
||||||
|
"jscs-preset-gulp": "^1.0.0", |
||||||
|
"mississippi": "^1.3.0", |
||||||
|
"mocha": "^2.4.5", |
||||||
|
"vinyl": "^2.0.1" |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.10" |
||||||
|
}, |
||||||
|
"files": [ |
||||||
|
"LICENSE", |
||||||
|
"index.js" |
||||||
|
], |
||||||
|
"homepage": "https://github.com/gulp-sourcemaps/map-sources#readme", |
||||||
|
"keywords": [ |
||||||
|
"sourcemap", |
||||||
|
"sources", |
||||||
|
"stream" |
||||||
|
], |
||||||
|
"license": "MIT", |
||||||
|
"main": "index.js", |
||||||
|
"name": "@gulp-sourcemaps/map-sources", |
||||||
|
"repository": { |
||||||
|
"type": "git", |
||||||
|
"url": "git+https://github.com/gulp-sourcemaps/map-sources.git" |
||||||
|
}, |
||||||
|
"scripts": { |
||||||
|
"cover": "istanbul cover _mocha --report lcovonly", |
||||||
|
"coveralls": "npm run cover && istanbul-coveralls", |
||||||
|
"lint": "eslint . && jscs index.js test/", |
||||||
|
"pretest": "npm run lint", |
||||||
|
"test": "mocha --async-only" |
||||||
|
}, |
||||||
|
"version": "1.0.0" |
||||||
|
} |
@ -0,0 +1,46 @@ |
|||||||
|
This software is dual-licensed under the ISC and MIT licenses. |
||||||
|
You may use this software under EITHER of the following licenses. |
||||||
|
|
||||||
|
---------- |
||||||
|
|
||||||
|
The ISC License |
||||||
|
|
||||||
|
Copyright (c) Isaac Z. Schlueter and Contributors |
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any |
||||||
|
purpose with or without fee is hereby granted, provided that the above |
||||||
|
copyright notice and this permission notice appear in all copies. |
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR |
||||||
|
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
||||||
|
|
||||||
|
---------- |
||||||
|
|
||||||
|
Copyright Isaac Z. Schlueter and Contributors |
||||||
|
All rights reserved. |
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person |
||||||
|
obtaining a copy of this software and associated documentation |
||||||
|
files (the "Software"), to deal in the Software without |
||||||
|
restriction, including without limitation the rights to use, |
||||||
|
copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||||
|
copies of the Software, and to permit persons to whom the |
||||||
|
Software is furnished to do so, subject to the following |
||||||
|
conditions: |
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be |
||||||
|
included in all copies or substantial portions of the Software. |
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
||||||
|
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
||||||
|
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
||||||
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||||
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
||||||
|
OTHER DEALINGS IN THE SOFTWARE. |
@ -0,0 +1,23 @@ |
|||||||
|
# abbrev-js |
||||||
|
|
||||||
|
Just like [ruby's Abbrev](http://apidock.com/ruby/Abbrev). |
||||||
|
|
||||||
|
Usage: |
||||||
|
|
||||||
|
var abbrev = require("abbrev"); |
||||||
|
abbrev("foo", "fool", "folding", "flop"); |
||||||
|
|
||||||
|
// returns: |
||||||
|
{ fl: 'flop' |
||||||
|
, flo: 'flop' |
||||||
|
, flop: 'flop' |
||||||
|
, fol: 'folding' |
||||||
|
, fold: 'folding' |
||||||
|
, foldi: 'folding' |
||||||
|
, foldin: 'folding' |
||||||
|
, folding: 'folding' |
||||||
|
, foo: 'foo' |
||||||
|
, fool: 'fool' |
||||||
|
} |
||||||
|
|
||||||
|
This is handy for command-line scripts, or other cases where you want to be able to accept shorthands. |
@ -0,0 +1,61 @@ |
|||||||
|
module.exports = exports = abbrev.abbrev = abbrev |
||||||
|
|
||||||
|
abbrev.monkeyPatch = monkeyPatch |
||||||
|
|
||||||
|
function monkeyPatch () { |
||||||
|
Object.defineProperty(Array.prototype, 'abbrev', { |
||||||
|
value: function () { return abbrev(this) }, |
||||||
|
enumerable: false, configurable: true, writable: true |
||||||
|
}) |
||||||
|
|
||||||
|
Object.defineProperty(Object.prototype, 'abbrev', { |
||||||
|
value: function () { return abbrev(Object.keys(this)) }, |
||||||
|
enumerable: false, configurable: true, writable: true |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
function abbrev (list) { |
||||||
|
if (arguments.length !== 1 || !Array.isArray(list)) { |
||||||
|
list = Array.prototype.slice.call(arguments, 0) |
||||||
|
} |
||||||
|
for (var i = 0, l = list.length, args = [] ; i < l ; i ++) { |
||||||
|
args[i] = typeof list[i] === "string" ? list[i] : String(list[i]) |
||||||
|
} |
||||||
|
|
||||||
|
// sort them lexicographically, so that they're next to their nearest kin
|
||||||
|
args = args.sort(lexSort) |
||||||
|
|
||||||
|
// walk through each, seeing how much it has in common with the next and previous
|
||||||
|
var abbrevs = {} |
||||||
|
, prev = "" |
||||||
|
for (var i = 0, l = args.length ; i < l ; i ++) { |
||||||
|
var current = args[i] |
||||||
|
, next = args[i + 1] || "" |
||||||
|
, nextMatches = true |
||||||
|
, prevMatches = true |
||||||
|
if (current === next) continue |
||||||
|
for (var j = 0, cl = current.length ; j < cl ; j ++) { |
||||||
|
var curChar = current.charAt(j) |
||||||
|
nextMatches = nextMatches && curChar === next.charAt(j) |
||||||
|
prevMatches = prevMatches && curChar === prev.charAt(j) |
||||||
|
if (!nextMatches && !prevMatches) { |
||||||
|
j ++ |
||||||
|
break |
||||||
|
} |
||||||
|
} |
||||||
|
prev = current |
||||||
|
if (j === cl) { |
||||||
|
abbrevs[current] = current |
||||||
|
continue |
||||||
|
} |
||||||
|
for (var a = current.substr(0, j) ; j <= cl ; j ++) { |
||||||
|
abbrevs[a] = current |
||||||
|
a += current.charAt(j) |
||||||
|
} |
||||||
|
} |
||||||
|
return abbrevs |
||||||
|
} |
||||||
|
|
||||||
|
function lexSort (a, b) { |
||||||
|
return a === b ? 0 : a > b ? 1 : -1 |
||||||
|
} |
@ -0,0 +1,89 @@ |
|||||||
|
{ |
||||||
|
"_args": [ |
||||||
|
[ |
||||||
|
"abbrev@1", |
||||||
|
"/Users/rdrew/themes/lmmi_journal_theme/node_modules/nopt" |
||||||
|
] |
||||||
|
], |
||||||
|
"_from": "abbrev@>=1.0.0 <2.0.0", |
||||||
|
"_id": "abbrev@1.1.1", |
||||||
|
"_inCache": true, |
||||||
|
"_installable": true, |
||||||
|
"_location": "/abbrev", |
||||||
|
"_nodeVersion": "8.5.0", |
||||||
|
"_npmOperationalInternal": { |
||||||
|
"host": "s3://npm-registry-packages", |
||||||
|
"tmp": "tmp/abbrev-1.1.1.tgz_1506566833068_0.05750026390887797" |
||||||
|
}, |
||||||
|
"_npmUser": { |
||||||
|
"email": "i@izs.me", |
||||||
|
"name": "isaacs" |
||||||
|
}, |
||||||
|
"_npmVersion": "5.4.2", |
||||||
|
"_phantomChildren": {}, |
||||||
|
"_requested": { |
||||||
|
"name": "abbrev", |
||||||
|
"raw": "abbrev@1", |
||||||
|
"rawSpec": "1", |
||||||
|
"scope": null, |
||||||
|
"spec": ">=1.0.0 <2.0.0", |
||||||
|
"type": "range" |
||||||
|
}, |
||||||
|
"_requiredBy": [ |
||||||
|
"/nopt" |
||||||
|
], |
||||||
|
"_resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", |
||||||
|
"_shasum": "f8f2c887ad10bf67f634f005b6987fed3179aac8", |
||||||
|
"_shrinkwrap": null, |
||||||
|
"_spec": "abbrev@1", |
||||||
|
"_where": "/Users/rdrew/themes/lmmi_journal_theme/node_modules/nopt", |
||||||
|
"author": { |
||||||
|
"email": "i@izs.me", |
||||||
|
"name": "Isaac Z. Schlueter" |
||||||
|
}, |
||||||
|
"bugs": { |
||||||
|
"url": "https://github.com/isaacs/abbrev-js/issues" |
||||||
|
}, |
||||||
|
"dependencies": {}, |
||||||
|
"description": "Like ruby's abbrev module, but in js", |
||||||
|
"devDependencies": { |
||||||
|
"tap": "^10.1" |
||||||
|
}, |
||||||
|
"directories": {}, |
||||||
|
"dist": { |
||||||
|
"integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", |
||||||
|
"shasum": "f8f2c887ad10bf67f634f005b6987fed3179aac8", |
||||||
|
"tarball": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz" |
||||||
|
}, |
||||||
|
"files": [ |
||||||
|
"abbrev.js" |
||||||
|
], |
||||||
|
"gitHead": "a9ee72ebc8fe3975f1b0c7aeb3a8f2a806a432eb", |
||||||
|
"homepage": "https://github.com/isaacs/abbrev-js#readme", |
||||||
|
"license": "ISC", |
||||||
|
"main": "abbrev.js", |
||||||
|
"maintainers": [ |
||||||
|
{ |
||||||
|
"email": "jerry+1@npmjs.com", |
||||||
|
"name": "gabra" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"email": "i@izs.me", |
||||||
|
"name": "isaacs" |
||||||
|
} |
||||||
|
], |
||||||
|
"name": "abbrev", |
||||||
|
"optionalDependencies": {}, |
||||||
|
"readme": "ERROR: No README data found!", |
||||||
|
"repository": { |
||||||
|
"type": "git", |
||||||
|
"url": "git+ssh://git@github.com/isaacs/abbrev-js.git" |
||||||
|
}, |
||||||
|
"scripts": { |
||||||
|
"postpublish": "git push origin --all; git push origin --tags", |
||||||
|
"postversion": "npm publish", |
||||||
|
"preversion": "npm test", |
||||||
|
"test": "tap test.js --100" |
||||||
|
}, |
||||||
|
"version": "1.1.1" |
||||||
|
} |
@ -0,0 +1,224 @@ |
|||||||
|
1.3.5 / 2018-02-28 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.1.18 |
||||||
|
- deps: mime-db@~1.33.0 |
||||||
|
|
||||||
|
1.3.4 / 2017-08-22 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.1.16 |
||||||
|
- deps: mime-db@~1.29.0 |
||||||
|
|
||||||
|
1.3.3 / 2016-05-02 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.1.11 |
||||||
|
- deps: mime-db@~1.23.0 |
||||||
|
* deps: negotiator@0.6.1 |
||||||
|
- perf: improve `Accept` parsing speed |
||||||
|
- perf: improve `Accept-Charset` parsing speed |
||||||
|
- perf: improve `Accept-Encoding` parsing speed |
||||||
|
- perf: improve `Accept-Language` parsing speed |
||||||
|
|
||||||
|
1.3.2 / 2016-03-08 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.1.10 |
||||||
|
- Fix extension of `application/dash+xml` |
||||||
|
- Update primary extension for `audio/mp4` |
||||||
|
- deps: mime-db@~1.22.0 |
||||||
|
|
||||||
|
1.3.1 / 2016-01-19 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.1.9 |
||||||
|
- deps: mime-db@~1.21.0 |
||||||
|
|
||||||
|
1.3.0 / 2015-09-29 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.1.7 |
||||||
|
- deps: mime-db@~1.19.0 |
||||||
|
* deps: negotiator@0.6.0 |
||||||
|
- Fix including type extensions in parameters in `Accept` parsing |
||||||
|
- Fix parsing `Accept` parameters with quoted equals |
||||||
|
- Fix parsing `Accept` parameters with quoted semicolons |
||||||
|
- Lazy-load modules from main entry point |
||||||
|
- perf: delay type concatenation until needed |
||||||
|
- perf: enable strict mode |
||||||
|
- perf: hoist regular expressions |
||||||
|
- perf: remove closures getting spec properties |
||||||
|
- perf: remove a closure from media type parsing |
||||||
|
- perf: remove property delete from media type parsing |
||||||
|
|
||||||
|
1.2.13 / 2015-09-06 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.1.6 |
||||||
|
- deps: mime-db@~1.18.0 |
||||||
|
|
||||||
|
1.2.12 / 2015-07-30 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.1.4 |
||||||
|
- deps: mime-db@~1.16.0 |
||||||
|
|
||||||
|
1.2.11 / 2015-07-16 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.1.3 |
||||||
|
- deps: mime-db@~1.15.0 |
||||||
|
|
||||||
|
1.2.10 / 2015-07-01 |
||||||
|
=================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.1.2 |
||||||
|
- deps: mime-db@~1.14.0 |
||||||
|
|
||||||
|
1.2.9 / 2015-06-08 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.1.1 |
||||||
|
- perf: fix deopt during mapping |
||||||
|
|
||||||
|
1.2.8 / 2015-06-07 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.1.0 |
||||||
|
- deps: mime-db@~1.13.0 |
||||||
|
* perf: avoid argument reassignment & argument slice |
||||||
|
* perf: avoid negotiator recursive construction |
||||||
|
* perf: enable strict mode |
||||||
|
* perf: remove unnecessary bitwise operator |
||||||
|
|
||||||
|
1.2.7 / 2015-05-10 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: negotiator@0.5.3 |
||||||
|
- Fix media type parameter matching to be case-insensitive |
||||||
|
|
||||||
|
1.2.6 / 2015-05-07 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.0.11 |
||||||
|
- deps: mime-db@~1.9.1 |
||||||
|
* deps: negotiator@0.5.2 |
||||||
|
- Fix comparing media types with quoted values |
||||||
|
- Fix splitting media types with quoted commas |
||||||
|
|
||||||
|
1.2.5 / 2015-03-13 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.0.10 |
||||||
|
- deps: mime-db@~1.8.0 |
||||||
|
|
||||||
|
1.2.4 / 2015-02-14 |
||||||
|
================== |
||||||
|
|
||||||
|
* Support Node.js 0.6 |
||||||
|
* deps: mime-types@~2.0.9 |
||||||
|
- deps: mime-db@~1.7.0 |
||||||
|
* deps: negotiator@0.5.1 |
||||||
|
- Fix preference sorting to be stable for long acceptable lists |
||||||
|
|
||||||
|
1.2.3 / 2015-01-31 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.0.8 |
||||||
|
- deps: mime-db@~1.6.0 |
||||||
|
|
||||||
|
1.2.2 / 2014-12-30 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.0.7 |
||||||
|
- deps: mime-db@~1.5.0 |
||||||
|
|
||||||
|
1.2.1 / 2014-12-30 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.0.5 |
||||||
|
- deps: mime-db@~1.3.1 |
||||||
|
|
||||||
|
1.2.0 / 2014-12-19 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: negotiator@0.5.0 |
||||||
|
- Fix list return order when large accepted list |
||||||
|
- Fix missing identity encoding when q=0 exists |
||||||
|
- Remove dynamic building of Negotiator class |
||||||
|
|
||||||
|
1.1.4 / 2014-12-10 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.0.4 |
||||||
|
- deps: mime-db@~1.3.0 |
||||||
|
|
||||||
|
1.1.3 / 2014-11-09 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.0.3 |
||||||
|
- deps: mime-db@~1.2.0 |
||||||
|
|
||||||
|
1.1.2 / 2014-10-14 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: negotiator@0.4.9 |
||||||
|
- Fix error when media type has invalid parameter |
||||||
|
|
||||||
|
1.1.1 / 2014-09-28 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: mime-types@~2.0.2 |
||||||
|
- deps: mime-db@~1.1.0 |
||||||
|
* deps: negotiator@0.4.8 |
||||||
|
- Fix all negotiations to be case-insensitive |
||||||
|
- Stable sort preferences of same quality according to client order |
||||||
|
|
||||||
|
1.1.0 / 2014-09-02 |
||||||
|
================== |
||||||
|
|
||||||
|
* update `mime-types` |
||||||
|
|
||||||
|
1.0.7 / 2014-07-04 |
||||||
|
================== |
||||||
|
|
||||||
|
* Fix wrong type returned from `type` when match after unknown extension |
||||||
|
|
||||||
|
1.0.6 / 2014-06-24 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: negotiator@0.4.7 |
||||||
|
|
||||||
|
1.0.5 / 2014-06-20 |
||||||
|
================== |
||||||
|
|
||||||
|
* fix crash when unknown extension given |
||||||
|
|
||||||
|
1.0.4 / 2014-06-19 |
||||||
|
================== |
||||||
|
|
||||||
|
* use `mime-types` |
||||||
|
|
||||||
|
1.0.3 / 2014-06-11 |
||||||
|
================== |
||||||
|
|
||||||
|
* deps: negotiator@0.4.6 |
||||||
|
- Order by specificity when quality is the same |
||||||
|
|
||||||
|
1.0.2 / 2014-05-29 |
||||||
|
================== |
||||||
|
|
||||||
|
* Fix interpretation when header not in request |
||||||
|
* deps: pin negotiator@0.4.5 |
||||||
|
|
||||||
|
1.0.1 / 2014-01-18 |
||||||
|
================== |
||||||
|
|
||||||
|
* Identity encoding isn't always acceptable |
||||||
|
* deps: negotiator@~0.4.0 |
||||||
|
|
||||||
|
1.0.0 / 2013-12-27 |
||||||
|
================== |
||||||
|
|
||||||
|
* Genesis |
@ -0,0 +1,23 @@ |
|||||||
|
(The MIT License) |
||||||
|
|
||||||
|
Copyright (c) 2014 Jonathan Ong <me@jongleberry.com> |
||||||
|
Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com> |
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining |
||||||
|
a copy of this software and associated documentation files (the |
||||||
|
'Software'), to deal in the Software without restriction, including |
||||||
|
without limitation the rights to use, copy, modify, merge, publish, |
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to |
||||||
|
permit persons to whom the Software is furnished to do so, subject to |
||||||
|
the following conditions: |
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be |
||||||
|
included in all copies or substantial portions of the Software. |
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
||||||
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
@ -0,0 +1,143 @@ |
|||||||
|
# accepts |
||||||
|
|
||||||
|
[![NPM Version][npm-image]][npm-url] |
||||||
|
[![NPM Downloads][downloads-image]][downloads-url] |
||||||
|
[![Node.js Version][node-version-image]][node-version-url] |
||||||
|
[![Build Status][travis-image]][travis-url] |
||||||
|
[![Test Coverage][coveralls-image]][coveralls-url] |
||||||
|
|
||||||
|
Higher level content negotiation based on [negotiator](https://www.npmjs.com/package/negotiator). |
||||||
|
Extracted from [koa](https://www.npmjs.com/package/koa) for general use. |
||||||
|
|
||||||
|
In addition to negotiator, it allows: |
||||||
|
|
||||||
|
- Allows types as an array or arguments list, ie `(['text/html', 'application/json'])` |
||||||
|
as well as `('text/html', 'application/json')`. |
||||||
|
- Allows type shorthands such as `json`. |
||||||
|
- Returns `false` when no types match |
||||||
|
- Treats non-existent headers as `*` |
||||||
|
|
||||||
|
## Installation |
||||||
|
|
||||||
|
This is a [Node.js](https://nodejs.org/en/) module available through the |
||||||
|
[npm registry](https://www.npmjs.com/). Installation is done using the |
||||||
|
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally): |
||||||
|
|
||||||
|
```sh |
||||||
|
$ npm install accepts |
||||||
|
``` |
||||||
|
|
||||||
|
## API |
||||||
|
|
||||||
|
<!-- eslint-disable no-unused-vars --> |
||||||
|
|
||||||
|
```js |
||||||
|
var accepts = require('accepts') |
||||||
|
``` |
||||||
|
|
||||||
|
### accepts(req) |
||||||
|
|
||||||
|
Create a new `Accepts` object for the given `req`. |
||||||
|
|
||||||
|
#### .charset(charsets) |
||||||
|
|
||||||
|
Return the first accepted charset. If nothing in `charsets` is accepted, |
||||||
|
then `false` is returned. |
||||||
|
|
||||||
|
#### .charsets() |
||||||
|
|
||||||
|
Return the charsets that the request accepts, in the order of the client's |
||||||
|
preference (most preferred first). |
||||||
|
|
||||||
|
#### .encoding(encodings) |
||||||
|
|
||||||
|
Return the first accepted encoding. If nothing in `encodings` is accepted, |
||||||
|
then `false` is returned. |
||||||
|
|
||||||
|
#### .encodings() |
||||||
|
|
||||||
|
Return the encodings that the request accepts, in the order of the client's |
||||||
|
preference (most preferred first). |
||||||
|
|
||||||
|
#### .language(languages) |
||||||
|
|
||||||
|
Return the first accepted language. If nothing in `languages` is accepted, |
||||||
|
then `false` is returned. |
||||||
|
|
||||||
|
#### .languages() |
||||||
|
|
||||||
|
Return the languages that the request accepts, in the order of the client's |
||||||
|
preference (most preferred first). |
||||||
|
|
||||||
|
#### .type(types) |
||||||
|
|
||||||
|
Return the first accepted type (and it is returned as the same text as what |
||||||
|
appears in the `types` array). If nothing in `types` is accepted, then `false` |
||||||
|
is returned. |
||||||
|
|
||||||
|
The `types` array can contain full MIME types or file extensions. Any value |
||||||
|
that is not a full MIME types is passed to `require('mime-types').lookup`. |
||||||
|
|
||||||
|
#### .types() |
||||||
|
|
||||||
|
Return the types that the request accepts, in the order of the client's |
||||||
|
preference (most preferred first). |
||||||
|
|
||||||
|
## Examples |
||||||
|
|
||||||
|
### Simple type negotiation |
||||||
|
|
||||||
|
This simple example shows how to use `accepts` to return a different typed |
||||||
|
respond body based on what the client wants to accept. The server lists it's |
||||||
|
preferences in order and will get back the best match between the client and |
||||||
|
server. |
||||||
|
|
||||||
|
```js |
||||||
|
var accepts = require('accepts') |
||||||
|
var http = require('http') |
||||||
|
|
||||||
|
function app (req, res) { |
||||||
|
var accept = accepts(req) |
||||||
|
|
||||||
|
// the order of this list is significant; should be server preferred order |
||||||
|
switch (accept.type(['json', 'html'])) { |
||||||
|
case 'json': |
||||||
|
res.setHeader('Content-Type', 'application/json') |
||||||
|
res.write('{"hello":"world!"}') |
||||||
|
break |
||||||
|
case 'html': |
||||||
|
res.setHeader('Content-Type', 'text/html') |
||||||
|
res.write('<b>hello, world!</b>') |
||||||
|
break |
||||||
|
default: |
||||||
|
// the fallback is text/plain, so no need to specify it above |
||||||
|
res.setHeader('Content-Type', 'text/plain') |
||||||
|
res.write('hello, world!') |
||||||
|
break |
||||||
|
} |
||||||
|
|
||||||
|
res.end() |
||||||
|
} |
||||||
|
|
||||||
|
http.createServer(app).listen(3000) |
||||||
|
``` |
||||||
|
|
||||||
|
You can test this out with the cURL program: |
||||||
|
```sh |
||||||
|
curl -I -H'Accept: text/html' http://localhost:3000/ |
||||||
|
``` |
||||||
|
|
||||||
|
## License |
||||||
|
|
||||||
|
[MIT](LICENSE) |
||||||
|
|
||||||
|
[npm-image]: https://img.shields.io/npm/v/accepts.svg |
||||||
|
[npm-url]: https://npmjs.org/package/accepts |
||||||
|
[node-version-image]: https://img.shields.io/node/v/accepts.svg |
||||||
|
[node-version-url]: https://nodejs.org/en/download/ |
||||||
|
[travis-image]: https://img.shields.io/travis/jshttp/accepts/master.svg |
||||||
|
[travis-url]: https://travis-ci.org/jshttp/accepts |
||||||
|
[coveralls-image]: https://img.shields.io/coveralls/jshttp/accepts/master.svg |
||||||
|
[coveralls-url]: https://coveralls.io/r/jshttp/accepts |
||||||
|
[downloads-image]: https://img.shields.io/npm/dm/accepts.svg |
||||||
|
[downloads-url]: https://npmjs.org/package/accepts |
@ -0,0 +1,238 @@ |
|||||||
|
/*! |
||||||
|
* accepts |
||||||
|
* Copyright(c) 2014 Jonathan Ong |
||||||
|
* Copyright(c) 2015 Douglas Christopher Wilson |
||||||
|
* MIT Licensed |
||||||
|
*/ |
||||||
|
|
||||||
|
'use strict' |
||||||
|
|
||||||
|
/** |
||||||
|
* Module dependencies. |
||||||
|
* @private |
||||||
|
*/ |
||||||
|
|
||||||
|
var Negotiator = require('negotiator') |
||||||
|
var mime = require('mime-types') |
||||||
|
|
||||||
|
/** |
||||||
|
* Module exports. |
||||||
|
* @public |
||||||
|
*/ |
||||||
|
|
||||||
|
module.exports = Accepts |
||||||
|
|
||||||
|
/** |
||||||
|
* Create a new Accepts object for the given req. |
||||||
|
* |
||||||
|
* @param {object} req |
||||||
|
* @public |
||||||
|
*/ |
||||||
|
|
||||||
|
function Accepts (req) { |
||||||
|
if (!(this instanceof Accepts)) { |
||||||
|
return new Accepts(req) |
||||||
|
} |
||||||
|
|
||||||
|
this.headers = req.headers |
||||||
|
this.negotiator = new Negotiator(req) |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Check if the given `type(s)` is acceptable, returning |
||||||
|
* the best match when true, otherwise `undefined`, in which |
||||||
|
* case you should respond with 406 "Not Acceptable". |
||||||
|
* |
||||||
|
* The `type` value may be a single mime type string |
||||||
|
* such as "application/json", the extension name |
||||||
|
* such as "json" or an array `["json", "html", "text/plain"]`. When a list |
||||||
|
* or array is given the _best_ match, if any is returned. |
||||||
|
* |
||||||
|
* Examples: |
||||||
|
* |
||||||
|
* // Accept: text/html
|
||||||
|
* this.types('html'); |
||||||
|
* // => "html"
|
||||||
|
* |
||||||
|
* // Accept: text/*, application/json
|
||||||
|
* this.types('html'); |
||||||
|
* // => "html"
|
||||||
|
* this.types('text/html'); |
||||||
|
* // => "text/html"
|
||||||
|
* this.types('json', 'text'); |
||||||
|
* // => "json"
|
||||||
|
* this.types('application/json'); |
||||||
|
* // => "application/json"
|
||||||
|
* |
||||||
|
* // Accept: text/*, application/json
|
||||||
|
* this.types('image/png'); |
||||||
|
* this.types('png'); |
||||||
|
* // => undefined
|
||||||
|
* |
||||||
|
* // Accept: text/*;q=.5, application/json
|
||||||
|
* this.types(['html', 'json']); |
||||||
|
* this.types('html', 'json'); |
||||||
|
* // => "json"
|
||||||
|
* |
||||||
|
* @param {String|Array} types... |
||||||
|
* @return {String|Array|Boolean} |
||||||
|
* @public |
||||||
|
*/ |
||||||
|
|
||||||
|
Accepts.prototype.type = |
||||||
|
Accepts.prototype.types = function (types_) { |
||||||
|
var types = types_ |
||||||
|
|
||||||
|
// support flattened arguments
|
||||||
|
if (types && !Array.isArray(types)) { |
||||||
|
types = new Array(arguments.length) |
||||||
|
for (var i = 0; i < types.length; i++) { |
||||||
|
types[i] = arguments[i] |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// no types, return all requested types
|
||||||
|
if (!types || types.length === 0) { |
||||||
|
return this.negotiator.mediaTypes() |
||||||
|
} |
||||||
|
|
||||||
|
// no accept header, return first given type
|
||||||
|
if (!this.headers.accept) { |
||||||
|
return types[0] |
||||||
|
} |
||||||
|
|
||||||
|
var mimes = types.map(extToMime) |
||||||
|
var accepts = this.negotiator.mediaTypes(mimes.filter(validMime)) |
||||||
|
var first = accepts[0] |
||||||
|
|
||||||
|
return first |
||||||
|
? types[mimes.indexOf(first)] |
||||||
|
: false |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Return accepted encodings or best fit based on `encodings`. |
||||||
|
* |
||||||
|
* Given `Accept-Encoding: gzip, deflate` |
||||||
|
* an array sorted by quality is returned: |
||||||
|
* |
||||||
|
* ['gzip', 'deflate'] |
||||||
|
* |
||||||
|
* @param {String|Array} encodings... |
||||||
|
* @return {String|Array} |
||||||
|
* @public |
||||||
|
*/ |
||||||
|
|
||||||
|
Accepts.prototype.encoding = |
||||||
|
Accepts.prototype.encodings = function (encodings_) { |
||||||
|
var encodings = encodings_ |
||||||
|
|
||||||
|
// support flattened arguments
|
||||||
|
if (encodings && !Array.isArray(encodings)) { |
||||||
|
encodings = new Array(arguments.length) |
||||||
|
for (var i = 0; i < encodings.length; i++) { |
||||||
|
encodings[i] = arguments[i] |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// no encodings, return all requested encodings
|
||||||
|
if (!encodings || encodings.length === 0) { |
||||||
|
return this.negotiator.encodings() |
||||||
|
} |
||||||
|
|
||||||
|
return this.negotiator.encodings(encodings)[0] || false |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Return accepted charsets or best fit based on `charsets`. |
||||||
|
* |
||||||
|
* Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5` |
||||||
|
* an array sorted by quality is returned: |
||||||
|
* |
||||||
|
* ['utf-8', 'utf-7', 'iso-8859-1'] |
||||||
|
* |
||||||
|
* @param {String|Array} charsets... |
||||||
|
* @return {String|Array} |
||||||
|
* @public |
||||||
|
*/ |
||||||
|
|
||||||
|
Accepts.prototype.charset = |
||||||
|
Accepts.prototype.charsets = function (charsets_) { |
||||||
|
var charsets = charsets_ |
||||||
|
|
||||||
|
// support flattened arguments
|
||||||
|
if (charsets && !Array.isArray(charsets)) { |
||||||
|
charsets = new Array(arguments.length) |
||||||
|
for (var i = 0; i < charsets.length; i++) { |
||||||
|
charsets[i] = arguments[i] |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// no charsets, return all requested charsets
|
||||||
|
if (!charsets || charsets.length === 0) { |
||||||
|
return this.negotiator.charsets() |
||||||
|
} |
||||||
|
|
||||||
|
return this.negotiator.charsets(charsets)[0] || false |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Return accepted languages or best fit based on `langs`. |
||||||
|
* |
||||||
|
* Given `Accept-Language: en;q=0.8, es, pt` |
||||||
|
* an array sorted by quality is returned: |
||||||
|
* |
||||||
|
* ['es', 'pt', 'en'] |
||||||
|
* |
||||||
|
* @param {String|Array} langs... |
||||||
|
* @return {Array|String} |
||||||
|
* @public |
||||||
|
*/ |
||||||
|
|
||||||
|
Accepts.prototype.lang = |
||||||
|
Accepts.prototype.langs = |
||||||
|
Accepts.prototype.language = |
||||||
|
Accepts.prototype.languages = function (languages_) { |
||||||
|
var languages = languages_ |
||||||
|
|
||||||
|
// support flattened arguments
|
||||||
|
if (languages && !Array.isArray(languages)) { |
||||||
|
languages = new Array(arguments.length) |
||||||
|
for (var i = 0; i < languages.length; i++) { |
||||||
|
languages[i] = arguments[i] |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// no languages, return all requested languages
|
||||||
|
if (!languages || languages.length === 0) { |
||||||
|
return this.negotiator.languages() |
||||||
|
} |
||||||
|
|
||||||
|
return this.negotiator.languages(languages)[0] || false |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Convert extnames to mime. |
||||||
|
* |
||||||
|
* @param {String} type |
||||||
|
* @return {String} |
||||||
|
* @private |
||||||
|
*/ |
||||||
|
|
||||||
|
function extToMime (type) { |
||||||
|
return type.indexOf('/') === -1 |
||||||
|
? mime.lookup(type) |
||||||
|
: type |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Check if mime is valid. |
||||||
|
* |
||||||
|
* @param {String} type |
||||||
|
* @return {String} |
||||||
|
* @private |
||||||
|
*/ |
||||||
|
|
||||||
|
function validMime (type) { |
||||||
|
return typeof type === 'string' |
||||||
|
} |
@ -0,0 +1,115 @@ |
|||||||
|
{ |
||||||
|
"_args": [ |
||||||
|
[ |
||||||
|
"accepts@~1.3.4", |
||||||
|
"/Users/rdrew/themes/lmmi_journal_theme/node_modules/serve-index" |
||||||
|
] |
||||||
|
], |
||||||
|
"_from": "accepts@>=1.3.4 <1.4.0", |
||||||
|
"_id": "accepts@1.3.5", |
||||||
|
"_inCache": true, |
||||||
|
"_installable": true, |
||||||
|
"_location": "/accepts", |
||||||
|
"_nodeVersion": "6.11.1", |
||||||
|
"_npmOperationalInternal": { |
||||||
|
"host": "s3://npm-registry-packages", |
||||||
|
"tmp": "tmp/accepts_1.3.5_1519869527663_0.6663620712347182" |
||||||
|
}, |
||||||
|
"_npmUser": { |
||||||
|
"email": "doug@somethingdoug.com", |
||||||
|
"name": "dougwilson" |
||||||
|
}, |
||||||
|
"_npmVersion": "3.10.10", |
||||||
|
"_phantomChildren": {}, |
||||||
|
"_requested": { |
||||||
|
"name": "accepts", |
||||||
|
"raw": "accepts@~1.3.4", |
||||||
|
"rawSpec": "~1.3.4", |
||||||
|
"scope": null, |
||||||
|
"spec": ">=1.3.4 <1.4.0", |
||||||
|
"type": "range" |
||||||
|
}, |
||||||
|
"_requiredBy": [ |
||||||
|
"/engine.io", |
||||||
|
"/serve-index" |
||||||
|
], |
||||||
|
"_resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", |
||||||
|
"_shasum": "eb777df6011723a3b14e8a72c0805c8e86746bd2", |
||||||
|
"_shrinkwrap": null, |
||||||
|
"_spec": "accepts@~1.3.4", |
||||||
|
"_where": "/Users/rdrew/themes/lmmi_journal_theme/node_modules/serve-index", |
||||||
|
"bugs": { |
||||||
|
"url": "https://github.com/jshttp/accepts/issues" |
||||||
|
}, |
||||||
|
"contributors": [ |
||||||
|
{ |
||||||
|
"email": "doug@somethingdoug.com", |
||||||
|
"name": "Douglas Christopher Wilson" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"email": "me@jongleberry.com", |
||||||
|
"name": "Jonathan Ong", |
||||||
|
"url": "http://jongleberry.com" |
||||||
|
} |
||||||
|
], |
||||||
|
"dependencies": { |
||||||
|
"mime-types": "~2.1.18", |
||||||
|
"negotiator": "0.6.1" |
||||||
|
}, |
||||||
|
"description": "Higher-level content negotiation", |
||||||
|
"devDependencies": { |
||||||
|
"eslint": "4.18.1", |
||||||
|
"eslint-config-standard": "11.0.0", |
||||||
|
"eslint-plugin-import": "2.9.0", |
||||||
|
"eslint-plugin-markdown": "1.0.0-beta.6", |
||||||
|
"eslint-plugin-node": "6.0.1", |
||||||
|
"eslint-plugin-promise": "3.6.0", |
||||||
|
"eslint-plugin-standard": "3.0.1", |
||||||
|
"istanbul": "0.4.5", |
||||||
|
"mocha": "~1.21.5" |
||||||
|
}, |
||||||
|
"directories": {}, |
||||||
|
"dist": { |
||||||
|
"fileCount": 5, |
||||||
|
"shasum": "eb777df6011723a3b14e8a72c0805c8e86746bd2", |
||||||
|
"tarball": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", |
||||||
|
"unpackedSize": 16555 |
||||||
|
}, |
||||||
|
"engines": { |
||||||
|
"node": ">= 0.6" |
||||||
|
}, |
||||||
|
"files": [ |
||||||
|
"LICENSE", |
||||||
|
"HISTORY.md", |
||||||
|
"index.js" |
||||||
|
], |
||||||
|
"gitHead": "c38d0e968cdc1526f7cc7a718977ee76655c84f5", |
||||||
|
"homepage": "https://github.com/jshttp/accepts#readme", |
||||||
|
"keywords": [ |
||||||
|
"content", |
||||||
|
"negotiation", |
||||||
|
"accept", |
||||||
|
"accepts" |
||||||
|
], |
||||||
|
"license": "MIT", |
||||||
|
"maintainers": [ |
||||||
|
{ |
||||||
|
"email": "doug@somethingdoug.com", |
||||||
|
"name": "dougwilson" |
||||||
|
} |
||||||
|
], |
||||||
|
"name": "accepts", |
||||||
|
"optionalDependencies": {}, |
||||||
|
"readme": "ERROR: No README data found!", |
||||||
|
"repository": { |
||||||
|
"type": "git", |
||||||
|
"url": "git+https://github.com/jshttp/accepts.git" |
||||||
|
}, |
||||||
|
"scripts": { |
||||||
|
"lint": "eslint --plugin markdown --ext js,md .", |
||||||
|
"test": "mocha --reporter spec --check-leaks --bail test/", |
||||||
|
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", |
||||||
|
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" |
||||||
|
}, |
||||||
|
"version": "1.3.5" |
||||||
|
} |
@ -0,0 +1,79 @@ |
|||||||
|
List of Acorn contributors. Updated before every release. |
||||||
|
|
||||||
|
Adrian Heine |
||||||
|
Adrian Rakovsky |
||||||
|
Alistair Braidwood |
||||||
|
Amila Welihinda |
||||||
|
Andres Suarez |
||||||
|
Angelo |
||||||
|
Aparajita Fishman |
||||||
|
Arian Stolwijk |
||||||
|
Artem Govorov |
||||||
|
Boopesh Mahendran |
||||||
|
Bradley Heinz |
||||||
|
Brandon Mills |
||||||
|
Charles Hughes |
||||||
|
Charmander |
||||||
|
Chris McKnight |
||||||
|
Conrad Irwin |
||||||
|
Daniel Tschinder |
||||||
|
David Bonnet |
||||||
|
Domenico Matteo |
||||||
|
ehmicky |
||||||
|
Eugene Obrezkov |
||||||
|
Felix Maier |
||||||
|
Forbes Lindesay |
||||||
|
Gilad Peleg |
||||||
|
impinball |
||||||
|
Ingvar Stepanyan |
||||||
|
Jackson Ray Hamilton |
||||||
|
Jesse McCarthy |
||||||
|
Jiaxing Wang |
||||||
|
Joel Kemp |
||||||
|
Johannes Herr |
||||||
|
John-David Dalton |
||||||
|
Jordan Klassen |
||||||
|
Jürg Lehni |
||||||
|
Kai Cataldo |
||||||
|
keeyipchan |
||||||
|
Keheliya Gallaba |
||||||
|
Kevin Irish |
||||||
|
Kevin Kwok |
||||||
|
krator |
||||||
|
laosb |
||||||
|
luckyzeng |
||||||
|
Marek |
||||||
|
Marijn Haverbeke |
||||||
|
Martin Carlberg |
||||||
|
Mat Garcia |
||||||
|
Mathias Bynens |
||||||
|
Mathieu 'p01' Henri |
||||||
|
Matthew Bastien |
||||||
|
Max Schaefer |
||||||
|
Max Zerzouri |
||||||
|
Mihai Bazon |
||||||
|
Mike Rennie |
||||||
|
naoh |
||||||
|
Nicholas C. Zakas |
||||||
|
Nick Fitzgerald |
||||||
|
Olivier Thomann |
||||||
|
Oskar Schöldström |
||||||
|
Paul Harper |
||||||
|
Peter Rust |
||||||
|
PlNG |
||||||
|
Prayag Verma |
||||||
|
ReadmeCritic |
||||||
|
r-e-d |
||||||
|
Renée Kooi |
||||||
|
Richard Gibson |
||||||
|
Rich Harris |
||||||
|
Sebastian McKenzie |
||||||
|
Shahar Soel |
||||||
|
Sheel Bedi |
||||||
|
Simen Bekkhus |
||||||
|
Teddy Katz |
||||||
|
Timothy Gu |
||||||
|
Toru Nagashima |
||||||
|
Victor Homyakov |
||||||
|
Wexpo Lyu |
||||||
|
zsjforcn |
@ -0,0 +1,508 @@ |
|||||||
|
## 5.7.3 (2018-09-10) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Fix failure to tokenize regexps after expressions like `x.of`. |
||||||
|
|
||||||
|
Better error message for unterminated template literals. |
||||||
|
|
||||||
|
## 5.7.2 (2018-08-24) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Properly handle `allowAwaitOutsideFunction` in for statements. |
||||||
|
|
||||||
|
Treat function declarations at the top level of modules like let bindings. |
||||||
|
|
||||||
|
Don't allow async function declarations as the only statement under a label. |
||||||
|
|
||||||
|
## 5.7.1 (2018-06-15) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Make sure the walker and bin files are rebuilt on release (the previous release didn't get the up-to-date versions). |
||||||
|
|
||||||
|
## 5.7.0 (2018-06-15) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Fix crash in walker when walking a binding-less catch node. |
||||||
|
|
||||||
|
### New features |
||||||
|
|
||||||
|
Upgraded to Unicode 11. |
||||||
|
|
||||||
|
## 5.6.2 (2018-06-05) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
In the walker, go back to allowing the `baseVisitor` argument to be null to default to the default base everywhere. |
||||||
|
|
||||||
|
## 5.6.1 (2018-06-01) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Fix regression when passing `null` as fourth argument to `walk.recursive`. |
||||||
|
|
||||||
|
## 5.6.0 (2018-05-31) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Fix a bug in the walker that caused a crash when walking an object pattern spread. |
||||||
|
|
||||||
|
### New features |
||||||
|
|
||||||
|
Allow U+2028 and U+2029 in string when ECMAVersion >= 10. |
||||||
|
|
||||||
|
Allow binding-less catch statements when ECMAVersion >= 10. |
||||||
|
|
||||||
|
Add `allowAwaitOutsideFunction` option for parsing top-level `await`. |
||||||
|
|
||||||
|
## 5.5.3 (2018-03-08) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
A _second_ republish of the code in 5.5.1, this time with yarn, to hopefully get valid timestamps. |
||||||
|
|
||||||
|
## 5.5.2 (2018-03-08) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
A republish of the code in 5.5.1 in an attempt to solve an issue with the file timestamps in the npm package being 0. |
||||||
|
|
||||||
|
## 5.5.1 (2018-03-06) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Fix regression in walker causing property values in object patterns to be walked as expressions. |
||||||
|
|
||||||
|
Fix misleading error message for octal escapes in template strings. |
||||||
|
|
||||||
|
## 5.5.0 (2018-02-27) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Support object spread in the AST walker. |
||||||
|
|
||||||
|
### New features |
||||||
|
|
||||||
|
The identifier character categorization is now based on Unicode version 10. |
||||||
|
|
||||||
|
Acorn will now validate the content of regular expressions, including new ES9 features. |
||||||
|
|
||||||
|
## 5.4.1 (2018-02-02) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
5.4.0 somehow accidentally included an old version of walk.js. |
||||||
|
|
||||||
|
## 5.4.0 (2018-02-01) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Disallow duplicate or escaped flags on regular expressions. |
||||||
|
|
||||||
|
Disallow octal escapes in strings in strict mode. |
||||||
|
|
||||||
|
### New features |
||||||
|
|
||||||
|
Add support for async iteration. |
||||||
|
|
||||||
|
Add support for object spread and rest. |
||||||
|
|
||||||
|
## 5.3.0 (2017-12-28) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Fix parsing of floating point literals with leading zeroes in loose mode. |
||||||
|
|
||||||
|
Allow duplicate property names in object patterns. |
||||||
|
|
||||||
|
Don't allow static class methods named `prototype`. |
||||||
|
|
||||||
|
Disallow async functions directly under `if` or `else`. |
||||||
|
|
||||||
|
Parse right-hand-side of `for`/`of` as an assignment expression. |
||||||
|
|
||||||
|
Stricter parsing of `for`/`in`. |
||||||
|
|
||||||
|
Don't allow unicode escapes in contextual keywords. |
||||||
|
|
||||||
|
### New features |
||||||
|
|
||||||
|
Parsing class members was factored into smaller methods to allow plugins to hook into it. |
||||||
|
|
||||||
|
## 5.2.1 (2017-10-30) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Fix a token context corruption bug. |
||||||
|
|
||||||
|
## 5.2.0 (2017-10-30) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Fix token context tracking for `class` and `function` in property-name position. |
||||||
|
|
||||||
|
Make sure `%*` isn't parsed as a valid operator. |
||||||
|
|
||||||
|
The `full` and `fullAncestor` walkers no longer visit nodes multiple times. |
||||||
|
|
||||||
|
Allow shorthand properties `get` and `set` to be followed by default values. |
||||||
|
|
||||||
|
Disallow `super` when not in callee or object position. |
||||||
|
|
||||||
|
### New features |
||||||
|
|
||||||
|
Support [`directive` property](https://github.com/estree/estree/compare/b3de58c9997504d6fba04b72f76e6dd1619ee4eb...1da8e603237144f44710360f8feb7a9977e905e0) on directive expression statements. |
||||||
|
|
||||||
|
## 5.1.2 (2017-09-04) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Disable parsing of legacy HTML-style comments in modules. |
||||||
|
|
||||||
|
Fix parsing of async methods whose names are keywords. |
||||||
|
|
||||||
|
## 5.1.1 (2017-07-06) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Fix problem with disambiguating regexp and division after a class. |
||||||
|
|
||||||
|
## 5.1.0 (2017-07-05) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Fix tokenizing of regexps in an object-desctructuring `for`/`of` loop and after `yield`. |
||||||
|
|
||||||
|
Parse zero-prefixed numbers with non-octal digits as decimal. |
||||||
|
|
||||||
|
Allow object/array patterns in rest parameters. |
||||||
|
|
||||||
|
Don't error when `yield` is used as a property name. |
||||||
|
|
||||||
|
Allow `async` as a shorthand object property. |
||||||
|
|
||||||
|
Make the ES module version of the loose parser actually work. |
||||||
|
|
||||||
|
### New features |
||||||
|
|
||||||
|
Implement the [template literal revision proposal](https://github.com/tc39/proposal-template-literal-revision) for ES9. |
||||||
|
|
||||||
|
New walker functions `full` and `fullAncestor`. |
||||||
|
|
||||||
|
## 5.0.3 (2017-04-01) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Fix spurious duplicate variable definition errors for named functions. |
||||||
|
|
||||||
|
## 5.0.2 (2017-03-30) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
A binary operator after a parenthesized arrow expression is no longer incorrectly treated as an error. |
||||||
|
|
||||||
|
## 5.0.0 (2017-03-28) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Raise an error for duplicated lexical bindings. |
||||||
|
|
||||||
|
Fix spurious error when an assignement expression occurred after a spread expression. |
||||||
|
|
||||||
|
Accept regular expressions after `of` (in `for`/`of`), `yield` (in a generator), and braced arrow functions. |
||||||
|
|
||||||
|
Allow labels in front or `var` declarations, even in strict mode. |
||||||
|
|
||||||
|
### Breaking changes |
||||||
|
|
||||||
|
Parse declarations following `export default` as declaration nodes, not expressions. This means that class and function declarations nodes can now have `null` as their `id`. |
||||||
|
|
||||||
|
## 4.0.11 (2017-02-07) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Allow all forms of member expressions to be parenthesized as lvalue. |
||||||
|
|
||||||
|
## 4.0.10 (2017-02-07) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Don't expect semicolons after default-exported functions or classes, |
||||||
|
even when they are expressions. |
||||||
|
|
||||||
|
Check for use of `'use strict'` directives in non-simple parameter |
||||||
|
functions, even when already in strict mode. |
||||||
|
|
||||||
|
## 4.0.9 (2017-02-06) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Fix incorrect error raised for parenthesized simple assignment |
||||||
|
targets, so that `(x) = 1` parses again. |
||||||
|
|
||||||
|
## 4.0.8 (2017-02-03) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Solve spurious parenthesized pattern errors by temporarily erring on |
||||||
|
the side of accepting programs that our delayed errors don't handle |
||||||
|
correctly yet. |
||||||
|
|
||||||
|
## 4.0.7 (2017-02-02) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Accept invalidly rejected code like `(x).y = 2` again. |
||||||
|
|
||||||
|
Don't raise an error when a function _inside_ strict code has a |
||||||
|
non-simple parameter list. |
||||||
|
|
||||||
|
## 4.0.6 (2017-02-02) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Fix exponential behavior (manifesting itself as a complete hang for |
||||||
|
even relatively small source files) introduced by the new 'use strict' |
||||||
|
check. |
||||||
|
|
||||||
|
## 4.0.5 (2017-02-02) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Disallow parenthesized pattern expressions. |
||||||
|
|
||||||
|
Allow keywords as export names. |
||||||
|
|
||||||
|
Don't allow the `async` keyword to be parenthesized. |
||||||
|
|
||||||
|
Properly raise an error when a keyword contains a character escape. |
||||||
|
|
||||||
|
Allow `"use strict"` to appear after other string literal expressions. |
||||||
|
|
||||||
|
Disallow labeled declarations. |
||||||
|
|
||||||
|
## 4.0.4 (2016-12-19) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Fix issue with loading acorn_loose.js with an AMD loader. |
||||||
|
|
||||||
|
Fix crash when `export` was followed by a keyword that can't be |
||||||
|
exported. |
||||||
|
|
||||||
|
## 4.0.3 (2016-08-16) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Allow regular function declarations inside single-statement `if` |
||||||
|
branches in loose mode. Forbid them entirely in strict mode. |
||||||
|
|
||||||
|
Properly parse properties named `async` in ES2017 mode. |
||||||
|
|
||||||
|
Fix bug where reserved words were broken in ES2017 mode. |
||||||
|
|
||||||
|
## 4.0.2 (2016-08-11) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Don't ignore period or 'e' characters after octal numbers. |
||||||
|
|
||||||
|
Fix broken parsing for call expressions in default parameter values |
||||||
|
of arrow functions. |
||||||
|
|
||||||
|
## 4.0.1 (2016-08-08) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Fix false positives in duplicated export name errors. |
||||||
|
|
||||||
|
## 4.0.0 (2016-08-07) |
||||||
|
|
||||||
|
### Breaking changes |
||||||
|
|
||||||
|
The default `ecmaVersion` option value is now 7. |
||||||
|
|
||||||
|
A number of internal method signatures changed, so plugins might need |
||||||
|
to be updated. |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
The parser now raises errors on duplicated export names. |
||||||
|
|
||||||
|
`arguments` and `eval` can now be used in shorthand properties. |
||||||
|
|
||||||
|
Duplicate parameter names in non-simple argument lists now always |
||||||
|
produce an error. |
||||||
|
|
||||||
|
### New features |
||||||
|
|
||||||
|
The `ecmaVersion` option now also accepts year-style version numbers |
||||||
|
(2015, etc). |
||||||
|
|
||||||
|
Support for `async`/`await` syntax when `ecmaVersion` is >= 8. |
||||||
|
|
||||||
|
Support for trailing commas in call expressions when `ecmaVersion` |
||||||
|
is >= 8. |
||||||
|
|
||||||
|
## 3.3.0 (2016-07-25) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Fix bug in tokenizing of regexp operator after a function declaration. |
||||||
|
|
||||||
|
Fix parser crash when parsing an array pattern with a hole. |
||||||
|
|
||||||
|
### New features |
||||||
|
|
||||||
|
Implement check against complex argument lists in functions that |
||||||
|
enable strict mode in ES7. |
||||||
|
|
||||||
|
## 3.2.0 (2016-06-07) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Improve handling of lack of unicode regexp support in host |
||||||
|
environment. |
||||||
|
|
||||||
|
Properly reject shorthand properties whose name is a keyword. |
||||||
|
|
||||||
|
Don't crash when the loose parser is called without options object. |
||||||
|
|
||||||
|
### New features |
||||||
|
|
||||||
|
Visitors created with `visit.make` now have their base as _prototype_, |
||||||
|
rather than copying properties into a fresh object. |
||||||
|
|
||||||
|
Make it possible to use `visit.ancestor` with a walk state. |
||||||
|
|
||||||
|
## 3.1.0 (2016-04-18) |
||||||
|
|
||||||
|
### Bug fixes |
||||||
|
|
||||||
|
Fix issue where the loose parser created invalid TemplateElement nodes |
||||||
|
for unclosed template literals. |
||||||
|
|
||||||
|
Properly tokenize the division operator directly after a function |
||||||
|
expression. |
||||||
|
|
||||||
|
Allow trailing comma in destructuring arrays. |
||||||
|
|
||||||
|
### New features |
||||||
|
|
||||||
|
The walker now allows defining handlers for `CatchClause` nodes. |
||||||
|
|
||||||
|
## 3.0.4 (2016-02-25) |
||||||
|
|
||||||
|
### Fixes |
||||||
|
|
||||||
|
Allow update expressions as left-hand-side of the ES7 exponential |
||||||
|
operator. |
||||||
|
|
||||||
|
## 3.0.2 (2016-02-10) |
||||||
|
|
||||||
|
### Fixes |
||||||
|
|
||||||
|
Fix bug that accidentally made `undefined` a reserved word when |
||||||
|
parsing ES7. |
||||||
|
|
||||||
|
## 3.0.0 (2016-02-10) |
||||||
|
|
||||||
|
### Breaking changes |
||||||
|
|
||||||
|
The default value of the `ecmaVersion` option is now 6 (used to be 5). |
||||||
|
|
||||||
|
Support for comprehension syntax (which was dropped from the draft |
||||||
|
spec) has been removed. |
||||||
|
|
||||||
|
### Fixes |
||||||
|
|
||||||
|
`let` and `yield` are now “contextual keywords”, meaning you can |
||||||
|
mostly use them as identifiers in ES5 non-strict code. |
||||||
|
|
||||||
|
A parenthesized class or function expression after `export default` is |
||||||
|
now parsed correctly. |
||||||
|
|
||||||
|
### New features |
||||||
|
|
||||||
|
When `ecmaVersion` is set to 7, Acorn will parse the exponentiation |
||||||
|
operator (`**`). |
||||||
|
|
||||||
|
The identifier character ranges are now based on Unicode 8.0.0. |
||||||
|
|
||||||
|
Plugins can now override the `raiseRecoverable` method to override the |
||||||
|
way non-critical errors are handled. |
||||||
|
|
||||||
|
## 2.7.0 (2016-01-04) |
||||||
|
|
||||||
|
### Fixes |
||||||
|
|
||||||
|
Stop allowing rest parameters in setters. |
||||||
|
|
||||||
|
Make sure the loose parser always attaches a `local` property to |
||||||
|
`ImportNamespaceSpecifier` nodes. |
||||||
|
|
||||||
|
Disallow `y` rexexp flag in ES5. |
||||||
|
|
||||||
|
Disallow `\00` and `\000` escapes in strict mode. |
||||||
|
|
||||||
|
Raise an error when an import name is a reserved word. |
||||||
|
|
||||||
|
## 2.6.4 (2015-11-12) |
||||||
|
|
||||||
|
### Fixes |
||||||
|
|
||||||
|
Fix crash in loose parser when parsing invalid object pattern. |
||||||
|
|
||||||
|
### New features |
||||||
|
|
||||||
|
Support plugins in the loose parser. |
||||||
|
|
||||||
|
## 2.6.2 (2015-11-10) |
||||||
|
|
||||||
|
### Fixes |
||||||
|
|
||||||
|
Don't crash when no options object is passed. |
||||||
|
|
||||||
|
## 2.6.0 (2015-11-09) |
||||||
|
|
||||||
|
### Fixes |
||||||
|
|
||||||
|
Add `await` as a reserved word in module sources. |
||||||
|
|
||||||
|
Disallow `yield` in a parameter default value for a generator. |
||||||
|
|
||||||
|
Forbid using a comma after a rest pattern in an array destructuring. |
||||||
|
|
||||||
|
### New features |
||||||
|
|
||||||
|
Support parsing stdin in command-line tool. |
||||||
|
|
||||||
|
## 2.5.2 (2015-10-27) |
||||||
|
|
||||||
|
### Fixes |
||||||
|
|
||||||
|
Fix bug where the walker walked an exported `let` statement as an |
||||||
|
expression. |
||||||
|
|
||||||
|
## 2.5.0 (2015-10-27) |
||||||
|
|
||||||
|
### Fixes |
||||||
|
|
||||||
|
Fix tokenizer support in the command-line tool. |
||||||
|
|
||||||
|
In the loose parser, don't allow non-string-literals as import |
||||||
|
sources. |
||||||
|
|
||||||
|
Stop allowing `new.target` outside of functions. |
||||||
|
|
||||||
|
Remove legacy `guard` and `guardedHandler` properties from try nodes. |
||||||
|
|
||||||
|
Stop allowing multiple `__proto__` properties on an object literal in |
||||||
|
strict mode. |
||||||
|
|
||||||
|
Don't allow rest parameters to be non-identifier patterns. |
||||||
|
|
||||||
|
Check for duplicate paramter names in arrow functions. |
@ -0,0 +1,19 @@ |
|||||||
|
Copyright (C) 2012-2018 by various contributors (see AUTHORS) |
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||||
|
of this software and associated documentation files (the "Software"), to deal |
||||||
|
in the Software without restriction, including without limitation the rights |
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||||
|
copies of the Software, and to permit persons to whom the Software is |
||||||
|
furnished to do so, subject to the following conditions: |
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in |
||||||
|
all copies or substantial portions of the Software. |
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||||
|
THE SOFTWARE. |
@ -0,0 +1,467 @@ |
|||||||
|
# Acorn |
||||||
|
|
||||||
|
[![Build Status](https://travis-ci.org/acornjs/acorn.svg?branch=master)](https://travis-ci.org/acornjs/acorn) |
||||||
|
[![NPM version](https://img.shields.io/npm/v/acorn.svg)](https://www.npmjs.com/package/acorn) |
||||||
|
[![CDNJS](https://img.shields.io/cdnjs/v/acorn.svg)](https://cdnjs.com/libraries/acorn) |
||||||
|
[Author funding status: ![maintainer happiness](https://marijnhaverbeke.nl/fund/status_s.png?force)](https://marijnhaverbeke.nl/fund/) |
||||||
|
|
||||||
|
A tiny, fast JavaScript parser, written completely in JavaScript. |
||||||
|
|
||||||
|
## Community |
||||||
|
|
||||||
|
Acorn is open source software released under an |
||||||
|
[MIT license](https://github.com/acornjs/acorn/blob/master/LICENSE). |
||||||
|
|
||||||
|
You are welcome to |
||||||
|
[report bugs](https://github.com/acornjs/acorn/issues) or create pull |
||||||
|
requests on [github](https://github.com/acornjs/acorn). For questions |
||||||
|
and discussion, please use the |
||||||
|
[Tern discussion forum](https://discuss.ternjs.net). |
||||||
|
|
||||||
|
## Installation |
||||||
|
|
||||||
|
The easiest way to install acorn is with [`npm`][npm]. |
||||||
|
|
||||||
|
[npm]: https://www.npmjs.com/ |
||||||
|
|
||||||
|
```sh |
||||||
|
npm install acorn |
||||||
|
``` |
||||||
|
|
||||||
|
Alternately, you can download the source and build acorn yourself: |
||||||
|
|
||||||
|
```sh |
||||||
|
git clone https://github.com/acornjs/acorn.git |
||||||
|
cd acorn |
||||||
|
npm install |
||||||
|
npm run build |
||||||
|
``` |
||||||
|
|
||||||
|
## Components |
||||||
|
|
||||||
|
When run in a CommonJS (node.js) or AMD environment, exported values |
||||||
|
appear in the interfaces exposed by the individual files, as usual. |
||||||
|
When loaded in the browser (Acorn works in any JS-enabled browser more |
||||||
|
recent than IE5) without any kind of module management, a single |
||||||
|
global object `acorn` will be defined, and all the exported properties |
||||||
|
will be added to that. |
||||||
|
|
||||||
|
### Main parser |
||||||
|
|
||||||
|
This is implemented in `dist/acorn.js`, and is what you get when you |
||||||
|
`require("acorn")` in node.js. |
||||||
|
|
||||||
|
**parse**`(input, options)` is used to parse a JavaScript program. |
||||||
|
The `input` parameter is a string, `options` can be undefined or an |
||||||
|
object setting some of the options listed below. The return value will |
||||||
|
be an abstract syntax tree object as specified by the |
||||||
|
[ESTree spec][estree]. |
||||||
|
|
||||||
|
When encountering a syntax error, the parser will raise a |
||||||
|
`SyntaxError` object with a meaningful message. The error object will |
||||||
|
have a `pos` property that indicates the character offset at which the |
||||||
|
error occurred, and a `loc` object that contains a `{line, column}` |
||||||
|
object referring to that same position. |
||||||
|
|
||||||
|
[estree]: https://github.com/estree/estree |
||||||
|
|
||||||
|
- **ecmaVersion**: Indicates the ECMAScript version to parse. Must be |
||||||
|
either 3, 5, 6 (2015), 7 (2016), 8 (2017), 9 (2018) or 10 (2019, partial |
||||||
|
support). This influences support for strict mode, the set of |
||||||
|
reserved words, and support for new syntax features. Default is 7. |
||||||
|
|
||||||
|
**NOTE**: Only 'stage 4' (finalized) ECMAScript features are being |
||||||
|
implemented by Acorn. |
||||||
|
|
||||||
|
- **sourceType**: Indicate the mode the code should be parsed in. Can be |
||||||
|
either `"script"` or `"module"`. This influences global strict mode |
||||||
|
and parsing of `import` and `export` declarations. |
||||||
|
|
||||||
|
- **onInsertedSemicolon**: If given a callback, that callback will be |
||||||
|
called whenever a missing semicolon is inserted by the parser. The |
||||||
|
callback will be given the character offset of the point where the |
||||||
|
semicolon is inserted as argument, and if `locations` is on, also a |
||||||
|
`{line, column}` object representing this position. |
||||||
|
|
||||||
|
- **onTrailingComma**: Like `onInsertedSemicolon`, but for trailing |
||||||
|
commas. |
||||||
|
|
||||||
|
- **allowReserved**: If `false`, using a reserved word will generate |
||||||
|
an error. Defaults to `true` for `ecmaVersion` 3, `false` for higher |
||||||
|
versions. When given the value `"never"`, reserved words and |
||||||
|
keywords can also not be used as property names (as in Internet |
||||||
|
Explorer's old parser). |
||||||
|
|
||||||
|
- **allowReturnOutsideFunction**: By default, a return statement at |
||||||
|
the top level raises an error. Set this to `true` to accept such |
||||||
|
code. |
||||||
|
|
||||||
|
- **allowImportExportEverywhere**: By default, `import` and `export` |
||||||
|
declarations can only appear at a program's top level. Setting this |
||||||
|
option to `true` allows them anywhere where a statement is allowed. |
||||||
|
|
||||||
|
- **allowAwaitOutsideFunction**: By default, `await` expressions can only appear inside `async` functions. Setting this option to `true` allows to have top-level `await` expressions. They are still not allowed in non-`async` functions, though. |
||||||
|
|
||||||
|
- **allowHashBang**: When this is enabled (off by default), if the |
||||||
|
code starts with the characters `#!` (as in a shellscript), the |
||||||
|
first line will be treated as a comment. |
||||||
|
|
||||||
|
- **locations**: When `true`, each node has a `loc` object attached |
||||||
|
with `start` and `end` subobjects, each of which contains the |
||||||
|
one-based line and zero-based column numbers in `{line, column}` |
||||||
|
form. Default is `false`. |
||||||
|
|
||||||
|
- **onToken**: If a function is passed for this option, each found |
||||||
|
token will be passed in same format as tokens returned from |
||||||
|
`tokenizer().getToken()`. |
||||||
|
|
||||||
|
If array is passed, each found token is pushed to it. |
||||||
|
|
||||||
|
Note that you are not allowed to call the parser from the |
||||||
|
callback—that will corrupt its internal state. |
||||||
|
|
||||||
|
- **onComment**: If a function is passed for this option, whenever a |
||||||
|
comment is encountered the function will be called with the |
||||||
|
following parameters: |
||||||
|
|
||||||
|
- `block`: `true` if the comment is a block comment, false if it |
||||||
|
is a line comment. |
||||||
|
- `text`: The content of the comment. |
||||||
|
- `start`: Character offset of the start of the comment. |
||||||
|
- `end`: Character offset of the end of the comment. |
||||||
|
|
||||||
|
When the `locations` options is on, the `{line, column}` locations |
||||||
|
of the comment’s start and end are passed as two additional |
||||||
|
parameters. |
||||||
|
|
||||||
|
If array is passed for this option, each found comment is pushed |
||||||
|
to it as object in Esprima format: |
||||||
|
|
||||||
|
```javascript |
||||||
|
{ |
||||||
|
"type": "Line" | "Block", |
||||||
|
"value": "comment text", |
||||||
|
"start": Number, |
||||||
|
"end": Number, |
||||||
|
// If `locations` option is on: |
||||||
|
"loc": { |
||||||
|
"start": {line: Number, column: Number} |
||||||
|
"end": {line: Number, column: Number} |
||||||
|
}, |
||||||
|
// If `ranges` option is on: |
||||||
|
"range": [Number, Number] |
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
Note that you are not allowed to call the parser from the |
||||||
|
callback—that will corrupt its internal state. |
||||||
|
|
||||||
|
- **ranges**: Nodes have their start and end characters offsets |
||||||
|
recorded in `start` and `end` properties (directly on the node, |
||||||
|
rather than the `loc` object, which holds line/column data. To also |
||||||
|
add a [semi-standardized][range] `range` property holding a |
||||||
|
`[start, end]` array with the same numbers, set the `ranges` option |
||||||
|
to `true`. |
||||||
|
|
||||||
|
- **program**: It is possible to parse multiple files into a single |
||||||
|
AST by passing the tree produced by parsing the first file as the |
||||||
|
`program` option in subsequent parses. This will add the toplevel |
||||||
|
forms of the parsed file to the "Program" (top) node of an existing |
||||||
|
parse tree. |
||||||
|
|
||||||
|
- **sourceFile**: When the `locations` option is `true`, you can pass |
||||||
|
this option to add a `source` attribute in every node’s `loc` |
||||||
|
object. Note that the contents of this option are not examined or |
||||||
|
processed in any way; you are free to use whatever format you |
||||||
|
choose. |
||||||
|
|
||||||
|
- **directSourceFile**: Like `sourceFile`, but a `sourceFile` property |
||||||
|
will be added (regardless of the `location` option) directly to the |
||||||
|
nodes, rather than the `loc` object. |
||||||
|
|
||||||
|
- **preserveParens**: If this option is `true`, parenthesized expressions |
||||||
|
are represented by (non-standard) `ParenthesizedExpression` nodes |
||||||
|
that have a single `expression` property containing the expression |
||||||
|
inside parentheses. |
||||||
|
|
||||||
|
[range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678 |
||||||
|
|
||||||
|
**parseExpressionAt**`(input, offset, options)` will parse a single |
||||||
|
expression in a string, and return its AST. It will not complain if |
||||||
|
there is more of the string left after the expression. |
||||||
|
|
||||||
|
**getLineInfo**`(input, offset)` can be used to get a `{line, |
||||||
|
column}` object for a given program string and character offset. |
||||||
|
|
||||||
|
**tokenizer**`(input, options)` returns an object with a `getToken` |
||||||
|
method that can be called repeatedly to get the next token, a `{start, |
||||||
|
end, type, value}` object (with added `loc` property when the |
||||||
|
`locations` option is enabled and `range` property when the `ranges` |
||||||
|
option is enabled). When the token's type is `tokTypes.eof`, you |
||||||
|
should stop calling the method, since it will keep returning that same |
||||||
|
token forever. |
||||||
|
|
||||||
|
In ES6 environment, returned result can be used as any other |
||||||
|
protocol-compliant iterable: |
||||||
|
|
||||||
|
```javascript |
||||||
|
for (let token of acorn.tokenizer(str)) { |
||||||
|
// iterate over the tokens |
||||||
|
} |
||||||
|
|
||||||
|
// transform code to array of tokens: |
||||||
|
var tokens = [...acorn.tokenizer(str)]; |
||||||
|
``` |
||||||
|
|
||||||
|
**tokTypes** holds an object mapping names to the token type objects |
||||||
|
that end up in the `type` properties of tokens. |
||||||
|
|
||||||
|
#### Note on using with [Escodegen][escodegen] |
||||||
|
|
||||||
|
Escodegen supports generating comments from AST, attached in |
||||||
|
Esprima-specific format. In order to simulate same format in |
||||||
|
Acorn, consider following example: |
||||||
|
|
||||||
|
```javascript |
||||||
|
var comments = [], tokens = []; |
||||||
|
|
||||||
|
var ast = acorn.parse('var x = 42; // answer', { |
||||||
|
// collect ranges for each node |
||||||
|
ranges: true, |
||||||
|
// collect comments in Esprima's format |
||||||
|
onComment: comments, |
||||||
|
// collect token ranges |
||||||
|
onToken: tokens |
||||||
|
}); |
||||||
|
|
||||||
|
// attach comments using collected information |
||||||
|
escodegen.attachComments(ast, comments, tokens); |
||||||
|
|
||||||
|
// generate code |
||||||
|
console.log(escodegen.generate(ast, {comment: true})); |
||||||
|
// > 'var x = 42; // answer' |
||||||
|
``` |
||||||
|
|
||||||
|
[escodegen]: https://github.com/estools/escodegen |
||||||
|
|
||||||
|
### dist/acorn_loose.js ### |
||||||
|
|
||||||
|
This file implements an error-tolerant parser. It exposes a single |
||||||
|
function. The loose parser is accessible in node.js via `require("acorn/dist/acorn_loose")`. |
||||||
|
|
||||||
|
**parse_dammit**`(input, options)` takes the same arguments and |
||||||
|
returns the same syntax tree as the `parse` function in `acorn.js`, |
||||||
|
but never raises an error, and will do its best to parse syntactically |
||||||
|
invalid code in as meaningful a way as it can. It'll insert identifier |
||||||
|
nodes with name `"✖"` as placeholders in places where it can't make |
||||||
|
sense of the input. Depends on `acorn.js`, because it uses the same |
||||||
|
tokenizer. |
||||||
|
|
||||||
|
### dist/walk.js ### |
||||||
|
|
||||||
|
Implements an abstract syntax tree walker. Will store its interface in |
||||||
|
`acorn.walk` when loaded without a module system. |
||||||
|
|
||||||
|
**simple**`(node, visitors, base, state)` does a 'simple' walk over |
||||||
|
a tree. `node` should be the AST node to walk, and `visitors` an |
||||||
|
object with properties whose names correspond to node types in the |
||||||
|
[ESTree spec][estree]. The properties should contain functions |
||||||
|
that will be called with the node object and, if applicable the state |
||||||
|
at that point. The last two arguments are optional. `base` is a walker |
||||||
|
algorithm, and `state` is a start state. The default walker will |
||||||
|
simply visit all statements and expressions and not produce a |
||||||
|
meaningful state. (An example of a use of state is to track scope at |
||||||
|
each point in the tree.) |
||||||
|
|
||||||
|
```js |
||||||
|
const acorn = require("acorn") |
||||||
|
const walk = require("acorn/dist/walk") |
||||||
|
|
||||||
|
walk.simple(acorn.parse("let x = 10"), { |
||||||
|
Literal(node) { |
||||||
|
console.log(`Found a literal: ${node.value}`) |
||||||
|
} |
||||||
|
}) |
||||||
|
``` |
||||||
|
|
||||||
|
**ancestor**`(node, visitors, base, state)` does a 'simple' walk over |
||||||
|
a tree, building up an array of ancestor nodes (including the current node) |
||||||
|
and passing the array to the callbacks as a third parameter. |
||||||
|
|
||||||
|
```js |
||||||
|
const acorn = require("acorn") |
||||||
|
const walk = require("acorn/dist/walk") |
||||||
|
|
||||||
|
walk.ancestor(acorn.parse("foo('hi')"), { |
||||||
|
Literal(_, ancestors) { |
||||||
|
console.log("This literal's ancestors are:", |
||||||
|
ancestors.map(n => n.type)) |
||||||
|
} |
||||||
|
}) |
||||||
|
``` |
||||||
|
|
||||||
|
**recursive**`(node, state, functions, base)` does a 'recursive' |
||||||
|
walk, where the walker functions are responsible for continuing the |
||||||
|
walk on the child nodes of their target node. `state` is the start |
||||||
|
state, and `functions` should contain an object that maps node types |
||||||
|
to walker functions. Such functions are called with `(node, state, c)` |
||||||
|
arguments, and can cause the walk to continue on a sub-node by calling |
||||||
|
the `c` argument on it with `(node, state)` arguments. The optional |
||||||
|
`base` argument provides the fallback walker functions for node types |
||||||
|
that aren't handled in the `functions` object. If not given, the |
||||||
|
default walkers will be used. |
||||||
|
|
||||||
|
**make**`(functions, base)` builds a new walker object by using the |
||||||
|
walker functions in `functions` and filling in the missing ones by |
||||||
|
taking defaults from `base`. |
||||||
|
|
||||||
|
**full**`(node, callback, base, state)` does a 'full' |
||||||
|
walk over a tree, calling the callback with the arguments (node, state, type) |
||||||
|
for each node |
||||||
|
|
||||||
|
**fullAncestor**`(node, callback, base, state)` does a 'full' walk over |
||||||
|
a tree, building up an array of ancestor nodes (including the current node) |
||||||
|
and passing the array to the callbacks as a third parameter. |
||||||
|
|
||||||
|
```js |
||||||
|
const acorn = require("acorn") |
||||||
|
const walk = require("acorn/dist/walk") |
||||||
|
|
||||||
|
walk.full(acorn.parse("1 + 1"), node => { |
||||||
|
console.log(`There's a ${node.type} node at ${node.ch}`) |
||||||
|
}) |
||||||
|
``` |
||||||
|
|
||||||
|
**findNodeAt**`(node, start, end, test, base, state)` tries to |
||||||
|
locate a node in a tree at the given start and/or end offsets, which |
||||||
|
satisfies the predicate `test`. `start` and `end` can be either `null` |
||||||
|
(as wildcard) or a number. `test` may be a string (indicating a node |
||||||
|
type) or a function that takes `(nodeType, node)` arguments and |
||||||
|
returns a boolean indicating whether this node is interesting. `base` |
||||||
|
and `state` are optional, and can be used to specify a custom walker. |
||||||
|
Nodes are tested from inner to outer, so if two nodes match the |
||||||
|
boundaries, the inner one will be preferred. |
||||||
|
|
||||||
|
**findNodeAround**`(node, pos, test, base, state)` is a lot like |
||||||
|
`findNodeAt`, but will match any node that exists 'around' (spanning) |
||||||
|
the given position. |
||||||
|
|
||||||
|
**findNodeAfter**`(node, pos, test, base, state)` is similar to |
||||||
|
`findNodeAround`, but will match all nodes *after* the given position |
||||||
|
(testing outer nodes before inner nodes). |
||||||
|
|
||||||
|
## Command line interface |
||||||
|
|
||||||
|
The `bin/acorn` utility can be used to parse a file from the command |
||||||
|
line. It accepts as arguments its input file and the following |
||||||
|
options: |
||||||
|
|
||||||
|
- `--ecma3|--ecma5|--ecma6|--ecma7|--ecma8|--ecma9|--ecma10`: Sets the ECMAScript version |
||||||
|
to parse. Default is version 7. |
||||||
|
|
||||||
|
- `--module`: Sets the parsing mode to `"module"`. Is set to `"script"` otherwise. |
||||||
|
|
||||||
|
- `--locations`: Attaches a "loc" object to each node with "start" and |
||||||
|
"end" subobjects, each of which contains the one-based line and |
||||||
|
zero-based column numbers in `{line, column}` form. |
||||||
|
|
||||||
|
- `--allow-hash-bang`: If the code starts with the characters #! (as in a shellscript), the first line will be treated as a comment. |
||||||
|
|
||||||
|
- `--compact`: No whitespace is used in the AST output. |
||||||
|
|
||||||
|
- `--silent`: Do not output the AST, just return the exit status. |
||||||
|
|
||||||
|
- `--help`: Print the usage information and quit. |
||||||
|
|
||||||
|
The utility spits out the syntax tree as JSON data. |
||||||
|
|
||||||
|
## Build system |
||||||
|
|
||||||
|
Acorn is written in ECMAScript 6, as a set of small modules, in the |
||||||
|
project's `src` directory, and compiled down to bigger ECMAScript 3 |
||||||
|
files in `dist` using [Browserify](http://browserify.org) and |
||||||
|
[Babel](http://babeljs.io/). If you are already using Babel, you can |
||||||
|
consider including the modules directly. |
||||||
|
|
||||||
|
The command-line test runner (`npm test`) uses the ES6 modules. The |
||||||
|
browser-based test page (`test/index.html`) uses the compiled modules. |
||||||
|
The `bin/build-acorn.js` script builds the latter from the former. |
||||||
|
|
||||||
|
If you are working on Acorn, you'll probably want to try the code out |
||||||
|
directly, without an intermediate build step. In your scripts, you can |
||||||
|
register the Babel require shim like this: |
||||||
|
|
||||||
|
require("babel-core/register") |
||||||
|
|
||||||
|
That will allow you to directly `require` the ES6 modules. |
||||||
|
|
||||||
|
## Plugins |
||||||
|
|
||||||
|
Acorn is designed support allow plugins which, within reasonable |
||||||
|
bounds, redefine the way the parser works. Plugins can add new token |
||||||
|
types and new tokenizer contexts (if necessary), and extend methods in |
||||||
|
the parser object. This is not a clean, elegant API—using it requires |
||||||
|
an understanding of Acorn's internals, and plugins are likely to break |
||||||
|
whenever those internals are significantly changed. But still, it is |
||||||
|
_possible_, in this way, to create parsers for JavaScript dialects |
||||||
|
without forking all of Acorn. And in principle it is even possible to |
||||||
|
combine such plugins, so that if you have, for example, a plugin for |
||||||
|
parsing types and a plugin for parsing JSX-style XML literals, you |
||||||
|
could load them both and parse code with both JSX tags and types. |
||||||
|
|
||||||
|
A plugin should register itself by adding a property to |
||||||
|
`acorn.plugins`, which holds a function. Calling `acorn.parse`, a |
||||||
|
`plugins` option can be passed, holding an object mapping plugin names |
||||||
|
to configuration values (or just `true` for plugins that don't take |
||||||
|
options). After the parser object has been created, the initialization |
||||||
|
functions for the chosen plugins are called with `(parser, |
||||||
|
configValue)` arguments. They are expected to use the `parser.extend` |
||||||
|
method to extend parser methods. For example, the `readToken` method |
||||||
|
could be extended like this: |
||||||
|
|
||||||
|
```javascript |
||||||
|
parser.extend("readToken", function(nextMethod) { |
||||||
|
return function(code) { |
||||||
|
console.log("Reading a token!") |
||||||
|
return nextMethod.call(this, code) |
||||||
|
} |
||||||
|
}) |
||||||
|
``` |
||||||
|
|
||||||
|
The `nextMethod` argument passed to `extend`'s second argument is the |
||||||
|
previous value of this method, and should usually be called through to |
||||||
|
whenever the extended method does not handle the call itself. |
||||||
|
|
||||||
|
Similarly, the loose parser allows plugins to register themselves via |
||||||
|
`acorn.pluginsLoose`. The extension mechanism is the same as for the |
||||||
|
normal parser: |
||||||
|
|
||||||
|
```javascript |
||||||
|
looseParser.extend("readToken", function(nextMethod) { |
||||||
|
return function() { |
||||||
|
console.log("Reading a token in the loose parser!") |
||||||
|
return nextMethod.call(this) |
||||||
|
} |
||||||
|
}) |
||||||
|
``` |
||||||
|
|
||||||
|
### Existing plugins |
||||||
|
|
||||||
|
- [`acorn-jsx`](https://github.com/RReverser/acorn-jsx): Parse [Facebook JSX syntax extensions](https://github.com/facebook/jsx) |
||||||
|
- [`acorn-objj`](https://github.com/cappuccino/acorn-objj): [Objective-J](http://www.cappuccino-project.org/learn/objective-j.html) language parser built as Acorn plugin |
||||||
|
|
||||||
|
Plugins for ECMAScript proposals: |
||||||
|
|
||||||
|
- [`acorn-stage3`](https://github.com/acornjs/acorn-stage3): Parse most stage 3 proposals, bundling: |
||||||
|
- [`acorn-async-iteration`](https://github.com/acornjs/acorn-async-iteration): Parse [async iteration proposal](https://github.com/tc39/proposal-async-iteration) |
||||||
|
- [`acorn-bigint`](https://github.com/acornjs/acorn-bigint): Parse [BigInt proposal](https://github.com/tc39/proposal-bigint) |
||||||
|
- [`acorn-class-fields`](https://github.com/acornjs/acorn-class-fields): Parse [class fields proposal](https://github.com/tc39/proposal-class-fields) |
||||||
|
- [`acorn-dynamic-import`](https://github.com/kesne/acorn-dynamic-import): Parse [import() proposal](https://github.com/tc39/proposal-dynamic-import) |
||||||
|
- [`acorn-import-meta`](https://github.com/acornjs/acorn-import-meta): Parse [import.meta proposal](https://github.com/tc39/proposal-import-meta) |
||||||
|
- [`acorn-numeric-separator`](https://github.com/acornjs/acorn-numeric-separator): Parse [numeric separator proposal](https://github.com/tc39/proposal-numeric-separator) |
||||||
|
- [`acorn-optional-catch-binding`](https://github.com/acornjs/acorn-optional-catch-binding): Parse [optional catch binding proposal](https://github.com/tc39/proposal-optional-catch-binding) |
||||||
|
- [`acorn-private-methods`](https://github.com/acornjs/acorn-private-methods): parse [private methods, getters and setters proposal](https://github.com/tc39/proposal-private-methods) |
||||||
|
- [`acorn5-object-spread`](https://github.com/adrianheine/acorn5-object-spread): Parse [Object Rest/Spread Properties proposal](https://github.com/tc39/proposal-object-rest-spread) |
||||||
|
- [`acorn-object-rest-spread`](https://github.com/victor-homyakov/acorn-object-rest-spread): Parse [Object Rest/Spread Properties proposal](https://github.com/tc39/proposal-object-rest-spread) |
||||||
|
- [`acorn-es7`](https://github.com/angelozerr/acorn-es7): Parse [decorator syntax proposal](https://github.com/wycats/javascript-decorators) |
||||||
|
- [`acorn-static-class-property-initializer`](https://github.com/victor-homyakov/acorn-static-class-property-initializer): Partial support for static class properties from [ES Class Fields & Static Properties Proposal](https://github.com/tc39/proposal-class-public-fields) to support static property initializers in [React components written as ES6+ classes](https://babeljs.io/blog/2015/07/07/react-on-es6-plus) |
@ -0,0 +1,69 @@ |
|||||||
|
#!/usr/bin/env node
|
||||||
|
'use strict'; |
||||||
|
|
||||||
|
var path = require('path'); |
||||||
|
var fs = require('fs'); |
||||||
|
var acorn = require('../dist/acorn.js'); |
||||||
|
|
||||||
|
var infile; |
||||||
|
var forceFile; |
||||||
|
var silent = false; |
||||||
|
var compact = false; |
||||||
|
var tokenize = false; |
||||||
|
var options = {}; |
||||||
|
|
||||||
|
function help(status) { |
||||||
|
var print = (status === 0) ? console.log : console.error; |
||||||
|
print("usage: " + path.basename(process.argv[1]) + " [--ecma3|--ecma5|--ecma6|--ecma7|--ecma8|--ecma9|...|--ecma2015|--ecma2016|--ecma2017|--ecma2018|...]"); |
||||||
|
print(" [--tokenize] [--locations] [---allow-hash-bang] [--compact] [--silent] [--module] [--help] [--] [infile]"); |
||||||
|
process.exit(status); |
||||||
|
} |
||||||
|
|
||||||
|
for (var i = 2; i < process.argv.length; ++i) { |
||||||
|
var arg = process.argv[i]; |
||||||
|
if ((arg === "-" || arg[0] !== "-") && !infile) { infile = arg; } |
||||||
|
else if (arg === "--" && !infile && i + 2 === process.argv.length) { forceFile = infile = process.argv[++i]; } |
||||||
|
else if (arg === "--locations") { options.locations = true; } |
||||||
|
else if (arg === "--allow-hash-bang") { options.allowHashBang = true; } |
||||||
|
else if (arg === "--silent") { silent = true; } |
||||||
|
else if (arg === "--compact") { compact = true; } |
||||||
|
else if (arg === "--help") { help(0); } |
||||||
|
else if (arg === "--tokenize") { tokenize = true; } |
||||||
|
else if (arg === "--module") { options.sourceType = "module"; } |
||||||
|
else { |
||||||
|
var match = arg.match(/^--ecma(\d+)$/); |
||||||
|
if (match) |
||||||
|
{ options.ecmaVersion = +match[1]; } |
||||||
|
else |
||||||
|
{ help(1); } |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
function run(code) { |
||||||
|
var result; |
||||||
|
try { |
||||||
|
if (!tokenize) { |
||||||
|
result = acorn.parse(code, options); |
||||||
|
} else { |
||||||
|
result = []; |
||||||
|
var tokenizer$$1 = acorn.tokenizer(code, options), token; |
||||||
|
do { |
||||||
|
token = tokenizer$$1.getToken(); |
||||||
|
result.push(token); |
||||||
|
} while (token.type !== acorn.tokTypes.eof) |
||||||
|
} |
||||||
|
} catch (e) { |
||||||
|
console.error(e.message); |
||||||
|
process.exit(1); |
||||||
|
} |
||||||
|
if (!silent) { console.log(JSON.stringify(result, null, compact ? null : 2)); } |
||||||
|
} |
||||||
|
|
||||||
|
if (forceFile || infile && infile !== "-") { |
||||||
|
run(fs.readFileSync(infile, "utf8")); |
||||||
|
} else { |
||||||
|
var code = ""; |
||||||
|
process.stdin.resume(); |
||||||
|
process.stdin.on("data", function (chunk) { return code += chunk; }); |
||||||
|
process.stdin.on("end", function () { return run(code); }); |
||||||
|
} |
@ -0,0 +1,4 @@ |
|||||||
|
#!/usr/bin/env node |
||||||
|
'use strict'; |
||||||
|
|
||||||
|
require('./_acorn.js'); |
@ -0,0 +1,21 @@ |
|||||||
|
const fs = require("fs") |
||||||
|
const path = require("path") |
||||||
|
const run = require("test262-parser-runner") |
||||||
|
const parse = require("..").parse |
||||||
|
|
||||||
|
const unsupportedFeatures = [ |
||||||
|
"BigInt", |
||||||
|
"class-fields", |
||||||
|
"class-fields-private", |
||||||
|
"class-fields-public", |
||||||
|
"numeric-separator-literal" |
||||||
|
]; |
||||||
|
|
||||||
|
run( |
||||||
|
(content, {sourceType}) => parse(content, {sourceType, ecmaVersion: 10}), |
||||||
|
{ |
||||||
|
testsDirectory: path.dirname(require.resolve("test262/package.json")), |
||||||
|
skip: test => (test.attrs.features && unsupportedFeatures.some(f => test.attrs.features.includes(f))), |
||||||
|
whitelist: fs.readFileSync("./bin/test262.whitelist", "utf8").split("\n").filter(v => v) |
||||||
|
} |
||||||
|
) |
@ -0,0 +1,404 @@ |
|||||||
|
annexB/language/function-code/block-decl-func-no-skip-try.js (default) |
||||||
|
annexB/language/function-code/block-decl-func-skip-early-err-block.js (default) |
||||||
|
annexB/language/function-code/block-decl-func-skip-early-err.js (default) |
||||||
|
annexB/language/function-code/block-decl-func-skip-early-err-switch.js (default) |
||||||
|
annexB/language/function-code/block-decl-func-skip-early-err-try.js (default) |
||||||
|
annexB/language/function-code/if-decl-else-decl-a-func-no-skip-try.js (default) |
||||||
|
annexB/language/function-code/if-decl-else-decl-a-func-skip-early-err-block.js (default) |
||||||
|
annexB/language/function-code/if-decl-else-decl-a-func-skip-early-err.js (default) |
||||||
|
annexB/language/function-code/if-decl-else-decl-a-func-skip-early-err-switch.js (default) |
||||||
|
annexB/language/function-code/if-decl-else-decl-a-func-skip-early-err-try.js (default) |
||||||
|
annexB/language/function-code/if-decl-else-decl-b-func-no-skip-try.js (default) |
||||||
|
annexB/language/function-code/if-decl-else-decl-b-func-skip-early-err-block.js (default) |
||||||
|
annexB/language/function-code/if-decl-else-decl-b-func-skip-early-err.js (default) |
||||||
|
annexB/language/function-code/if-decl-else-decl-b-func-skip-early-err-switch.js (default) |
||||||
|
annexB/language/function-code/if-decl-else-decl-b-func-skip-early-err-try.js (default) |
||||||
|
annexB/language/function-code/if-decl-else-stmt-func-no-skip-try.js (default) |
||||||
|
annexB/language/function-code/if-decl-else-stmt-func-skip-early-err-block.js (default) |
||||||
|
annexB/language/function-code/if-decl-else-stmt-func-skip-early-err.js (default) |
||||||
|
annexB/language/function-code/if-decl-else-stmt-func-skip-early-err-switch.js (default) |
||||||
|
annexB/language/function-code/if-decl-else-stmt-func-skip-early-err-try.js (default) |
||||||
|
annexB/language/function-code/if-decl-no-else-func-no-skip-try.js (default) |
||||||
|
annexB/language/function-code/if-decl-no-else-func-skip-early-err-block.js (default) |
||||||
|
annexB/language/function-code/if-decl-no-else-func-skip-early-err.js (default) |
||||||
|
annexB/language/function-code/if-decl-no-else-func-skip-early-err-switch.js (default) |
||||||
|
annexB/language/function-code/if-decl-no-else-func-skip-early-err-try.js (default) |
||||||
|
annexB/language/function-code/if-stmt-else-decl-func-no-skip-try.js (default) |
||||||
|
annexB/language/function-code/if-stmt-else-decl-func-skip-early-err-block.js (default) |
||||||
|
annexB/language/function-code/if-stmt-else-decl-func-skip-early-err.js (default) |
||||||
|
annexB/language/function-code/if-stmt-else-decl-func-skip-early-err-switch.js (default) |
||||||
|
annexB/language/function-code/if-stmt-else-decl-func-skip-early-err-try.js (default) |
||||||
|
annexB/language/function-code/switch-case-func-no-skip-try.js (default) |
||||||
|
annexB/language/function-code/switch-case-func-skip-early-err-block.js (default) |
||||||
|
annexB/language/function-code/switch-case-func-skip-early-err.js (default) |
||||||
|
annexB/language/function-code/switch-case-func-skip-early-err-switch.js (default) |
||||||
|
annexB/language/function-code/switch-case-func-skip-early-err-try.js (default) |
||||||
|
annexB/language/function-code/switch-dflt-func-no-skip-try.js (default) |
||||||
|
annexB/language/function-code/switch-dflt-func-skip-early-err-block.js (default) |
||||||
|
annexB/language/function-code/switch-dflt-func-skip-early-err.js (default) |
||||||
|
annexB/language/function-code/switch-dflt-func-skip-early-err-switch.js (default) |
||||||
|
annexB/language/function-code/switch-dflt-func-skip-early-err-try.js (default) |
||||||
|
annexB/language/global-code/block-decl-global-no-skip-try.js (default) |
||||||
|
annexB/language/global-code/block-decl-global-skip-early-err-block.js (default) |
||||||
|
annexB/language/global-code/block-decl-global-skip-early-err.js (default) |
||||||
|
annexB/language/global-code/block-decl-global-skip-early-err-switch.js (default) |
||||||
|
annexB/language/global-code/block-decl-global-skip-early-err-try.js (default) |
||||||
|
annexB/language/global-code/if-decl-else-decl-a-global-no-skip-try.js (default) |
||||||
|
annexB/language/global-code/if-decl-else-decl-a-global-skip-early-err-block.js (default) |
||||||
|
annexB/language/global-code/if-decl-else-decl-a-global-skip-early-err.js (default) |
||||||
|
annexB/language/global-code/if-decl-else-decl-a-global-skip-early-err-switch.js (default) |
||||||
|
annexB/language/global-code/if-decl-else-decl-a-global-skip-early-err-try.js (default) |
||||||
|
annexB/language/global-code/if-decl-else-decl-b-global-no-skip-try.js (default) |
||||||
|
annexB/language/global-code/if-decl-else-decl-b-global-skip-early-err-block.js (default) |
||||||
|
annexB/language/global-code/if-decl-else-decl-b-global-skip-early-err.js (default) |
||||||
|
annexB/language/global-code/if-decl-else-decl-b-global-skip-early-err-switch.js (default) |
||||||
|
annexB/language/global-code/if-decl-else-decl-b-global-skip-early-err-try.js (default) |
||||||
|
annexB/language/global-code/if-decl-else-stmt-global-no-skip-try.js (default) |
||||||
|
annexB/language/global-code/if-decl-else-stmt-global-skip-early-err-block.js (default) |
||||||
|
annexB/language/global-code/if-decl-else-stmt-global-skip-early-err.js (default) |
||||||
|
annexB/language/global-code/if-decl-else-stmt-global-skip-early-err-switch.js (default) |
||||||
|
annexB/language/global-code/if-decl-else-stmt-global-skip-early-err-try.js (default) |
||||||
|
annexB/language/global-code/if-decl-no-else-global-no-skip-try.js (default) |
||||||
|
annexB/language/global-code/if-decl-no-else-global-skip-early-err-block.js (default) |
||||||
|
annexB/language/global-code/if-decl-no-else-global-skip-early-err.js (default) |
||||||
|
annexB/language/global-code/if-decl-no-else-global-skip-early-err-switch.js (default) |
||||||
|
annexB/language/global-code/if-decl-no-else-global-skip-early-err-try.js (default) |
||||||
|
annexB/language/global-code/if-stmt-else-decl-global-no-skip-try.js (default) |
||||||
|
annexB/language/global-code/if-stmt-else-decl-global-skip-early-err-block.js (default) |
||||||
|
annexB/language/global-code/if-stmt-else-decl-global-skip-early-err.js (default) |
||||||
|
annexB/language/global-code/if-stmt-else-decl-global-skip-early-err-switch.js (default) |
||||||
|
annexB/language/global-code/if-stmt-else-decl-global-skip-early-err-try.js (default) |
||||||
|
annexB/language/global-code/switch-case-global-no-skip-try.js (default) |
||||||
|
annexB/language/global-code/switch-case-global-skip-early-err-block.js (default) |
||||||
|
annexB/language/global-code/switch-case-global-skip-early-err.js (default) |
||||||
|
annexB/language/global-code/switch-case-global-skip-early-err-switch.js (default) |
||||||
|
annexB/language/global-code/switch-case-global-skip-early-err-try.js (default) |
||||||
|
annexB/language/global-code/switch-dflt-global-no-skip-try.js (default) |
||||||
|
annexB/language/global-code/switch-dflt-global-skip-early-err-block.js (default) |
||||||
|
annexB/language/global-code/switch-dflt-global-skip-early-err.js (default) |
||||||
|
annexB/language/global-code/switch-dflt-global-skip-early-err-switch.js (default) |
||||||
|
annexB/language/global-code/switch-dflt-global-skip-early-err-try.js (default) |
||||||
|
annexB/language/statements/try/catch-redeclared-for-in-var.js (default) |
||||||
|
annexB/language/statements/try/catch-redeclared-for-in-var.js (strict mode) |
||||||
|
annexB/language/statements/try/catch-redeclared-for-var.js (default) |
||||||
|
annexB/language/statements/try/catch-redeclared-for-var.js (strict mode) |
||||||
|
annexB/language/statements/try/catch-redeclared-var-statement-captured.js (default) |
||||||
|
annexB/language/statements/try/catch-redeclared-var-statement-captured.js (strict mode) |
||||||
|
annexB/language/statements/try/catch-redeclared-var-statement.js (default) |
||||||
|
annexB/language/statements/try/catch-redeclared-var-statement.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-async-function-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-async-function-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-class-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-function-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-function-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-generator-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-generator-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-var-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-var-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-async-generator-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-async-generator-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-async-function-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-async-function-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-async-generator-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-async-generator-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-class-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-function-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-function-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-generator-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-generator-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-var-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-var-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-async-generator-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-async-generator-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-async-generator-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-async-generator-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-async-generator-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-async-generator-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-async-generator-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-async-generator-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-async-function-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-async-function-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-class-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-const-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-const-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-function-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-function-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-generator-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-generator-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-let-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-let-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-var-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-var-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/const-declaration-attempt-to-redeclare-with-class-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/const-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-async-function-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-async-function-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-class-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-function-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-generator-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-generator-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-var-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-var-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-async-function-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-async-function-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-class-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-function-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-function-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-generator-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-generator-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-var-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-var-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/let-declaration-attempt-to-redeclare-with-class-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/let-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-async-function-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-async-function-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-class-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-function-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-function-declaration.js (strict mode) |
||||||
|
language/block-scope/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-generator-declaration.js (default) |
||||||
|
language/block-scope/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-generator-declaration.js (strict mode) |
||||||
|
language/expressions/async-arrow-function/early-errors-arrow-await-in-formals-default.js (default) |
||||||
|
language/expressions/async-arrow-function/early-errors-arrow-await-in-formals-default.js (strict mode) |
||||||
|
language/expressions/async-arrow-function/early-errors-arrow-body-contains-super-call.js (default) |
||||||
|
language/expressions/async-arrow-function/early-errors-arrow-body-contains-super-call.js (strict mode) |
||||||
|
language/expressions/async-arrow-function/early-errors-arrow-body-contains-super-property.js (default) |
||||||
|
language/expressions/async-arrow-function/early-errors-arrow-body-contains-super-property.js (strict mode) |
||||||
|
language/expressions/async-function/early-errors-expression-body-contains-super-call.js (default) |
||||||
|
language/expressions/async-function/early-errors-expression-body-contains-super-call.js (strict mode) |
||||||
|
language/expressions/async-function/early-errors-expression-body-contains-super-property.js (default) |
||||||
|
language/expressions/async-function/early-errors-expression-body-contains-super-property.js (strict mode) |
||||||
|
language/expressions/async-function/early-errors-expression-formals-contains-super-call.js (default) |
||||||
|
language/expressions/async-function/early-errors-expression-formals-contains-super-call.js (strict mode) |
||||||
|
language/expressions/async-function/early-errors-expression-formals-contains-super-property.js (default) |
||||||
|
language/expressions/async-function/early-errors-expression-formals-contains-super-property.js (strict mode) |
||||||
|
language/expressions/class/method-param-dflt-yield.js (default) |
||||||
|
language/expressions/class/static-method-param-dflt-yield.js (default) |
||||||
|
language/expressions/function/early-body-super-call.js (default) |
||||||
|
language/expressions/function/early-body-super-call.js (strict mode) |
||||||
|
language/expressions/function/early-body-super-prop.js (default) |
||||||
|
language/expressions/function/early-body-super-prop.js (strict mode) |
||||||
|
language/expressions/function/early-params-super-call.js (default) |
||||||
|
language/expressions/function/early-params-super-call.js (strict mode) |
||||||
|
language/expressions/function/early-params-super-prop.js (default) |
||||||
|
language/expressions/function/early-params-super-prop.js (strict mode) |
||||||
|
language/expressions/object/method-definition/early-errors-object-method-body-contains-super-call.js (default) |
||||||
|
language/expressions/object/method-definition/early-errors-object-method-body-contains-super-call.js (strict mode) |
||||||
|
language/expressions/object/method-definition/early-errors-object-method-duplicate-parameters.js (default) |
||||||
|
language/expressions/object/method-definition/early-errors-object-method-formals-contains-super-call.js (default) |
||||||
|
language/expressions/object/method-definition/early-errors-object-method-formals-contains-super-call.js (strict mode) |
||||||
|
language/expressions/object/method-definition/generator-super-call-body.js (default) |
||||||
|
language/expressions/object/method-definition/generator-super-call-body.js (strict mode) |
||||||
|
language/expressions/object/method-definition/generator-super-call-param.js (default) |
||||||
|
language/expressions/object/method-definition/generator-super-call-param.js (strict mode) |
||||||
|
language/expressions/object/prop-def-invalid-async-prefix.js (default) |
||||||
|
language/expressions/object/prop-def-invalid-async-prefix.js (strict mode) |
||||||
|
language/expressions/yield/in-iteration-stmt.js (default) |
||||||
|
language/expressions/yield/in-iteration-stmt.js (strict mode) |
||||||
|
language/expressions/yield/star-in-iteration-stmt.js (default) |
||||||
|
language/expressions/yield/star-in-iteration-stmt.js (strict mode) |
||||||
|
language/global-code/new.target-arrow.js (default) |
||||||
|
language/global-code/new.target-arrow.js (strict mode) |
||||||
|
language/global-code/super-call-arrow.js (default) |
||||||
|
language/global-code/super-call-arrow.js (strict mode) |
||||||
|
language/global-code/super-prop-arrow.js (default) |
||||||
|
language/global-code/super-prop-arrow.js (strict mode) |
||||||
|
language/module-code/early-export-global.js (default) |
||||||
|
language/module-code/early-export-global.js (strict mode) |
||||||
|
language/module-code/early-export-unresolvable.js (default) |
||||||
|
language/module-code/early-export-unresolvable.js (strict mode) |
||||||
|
language/statements/async-function/early-errors-declaration-body-contains-super-call.js (default) |
||||||
|
language/statements/async-function/early-errors-declaration-body-contains-super-call.js (strict mode) |
||||||
|
language/statements/async-function/early-errors-declaration-body-contains-super-property.js (default) |
||||||
|
language/statements/async-function/early-errors-declaration-body-contains-super-property.js (strict mode) |
||||||
|
language/statements/async-function/early-errors-declaration-formals-contains-super-call.js (default) |
||||||
|
language/statements/async-function/early-errors-declaration-formals-contains-super-call.js (strict mode) |
||||||
|
language/statements/async-function/early-errors-declaration-formals-contains-super-property.js (default) |
||||||
|
language/statements/async-function/early-errors-declaration-formals-contains-super-property.js (strict mode) |
||||||
|
language/expressions/async-generator/early-errors-expression-body-contains-super-call.js (default) |
||||||
|
language/expressions/async-generator/early-errors-expression-body-contains-super-call.js (strict mode) |
||||||
|
language/expressions/async-generator/early-errors-expression-body-contains-super-property.js (default) |
||||||
|
language/expressions/async-generator/early-errors-expression-body-contains-super-property.js (strict mode) |
||||||
|
language/expressions/async-generator/early-errors-expression-formals-contains-super-call.js (default) |
||||||
|
language/expressions/async-generator/early-errors-expression-formals-contains-super-call.js (strict mode) |
||||||
|
language/expressions/async-generator/early-errors-expression-formals-contains-super-property.js (default) |
||||||
|
language/expressions/async-generator/early-errors-expression-formals-contains-super-property.js (strict mode) |
||||||
|
language/statements/class/definition/early-errors-class-method-arguments-in-formal-parameters.js (default) |
||||||
|
language/statements/class/definition/early-errors-class-method-body-contains-super-call.js (default) |
||||||
|
language/statements/class/definition/early-errors-class-method-body-contains-super-call.js (strict mode) |
||||||
|
language/statements/class/definition/early-errors-class-method-duplicate-parameters.js (default) |
||||||
|
language/statements/class/definition/early-errors-class-method-eval-in-formal-parameters.js (default) |
||||||
|
language/statements/class/definition/early-errors-class-method-formals-contains-super-call.js (default) |
||||||
|
language/statements/class/definition/early-errors-class-method-formals-contains-super-call.js (strict mode) |
||||||
|
language/statements/class/definition/methods-gen-yield-as-function-expression-binding-identifier.js (default) |
||||||
|
language/statements/class/definition/methods-gen-yield-as-identifier-in-nested-function.js (default) |
||||||
|
language/statements/class/method-param-yield.js (default) |
||||||
|
language/statements/class/static-method-param-yield.js (default) |
||||||
|
language/statements/class/strict-mode/with.js (default) |
||||||
|
language/statements/class/syntax/early-errors/class-body-has-direct-super-missing-class-heritage.js (default) |
||||||
|
language/statements/class/syntax/early-errors/class-body-has-direct-super-missing-class-heritage.js (strict mode) |
||||||
|
language/statements/class/syntax/early-errors/class-body-method-contains-direct-super.js (default) |
||||||
|
language/statements/class/syntax/early-errors/class-body-method-contains-direct-super.js (strict mode) |
||||||
|
language/statements/class/syntax/early-errors/class-body-special-method-generator-contains-direct-super.js (default) |
||||||
|
language/statements/class/syntax/early-errors/class-body-special-method-generator-contains-direct-super.js (strict mode) |
||||||
|
language/statements/class/syntax/early-errors/class-body-special-method-get-contains-direct-super.js (default) |
||||||
|
language/statements/class/syntax/early-errors/class-body-special-method-get-contains-direct-super.js (strict mode) |
||||||
|
language/statements/class/syntax/early-errors/class-body-special-method-set-contains-direct-super.js (default) |
||||||
|
language/statements/class/syntax/early-errors/class-body-special-method-set-contains-direct-super.js (strict mode) |
||||||
|
language/statements/class/syntax/early-errors/class-body-static-method-contains-direct-super.js (default) |
||||||
|
language/statements/class/syntax/early-errors/class-body-static-method-contains-direct-super.js (strict mode) |
||||||
|
language/statements/class/syntax/early-errors/class-body-static-method-get-contains-direct-super.js (default) |
||||||
|
language/statements/class/syntax/early-errors/class-body-static-method-get-contains-direct-super.js (strict mode) |
||||||
|
language/statements/class/syntax/early-errors/class-body-static-method-set-contains-direct-super.js (default) |
||||||
|
language/statements/class/syntax/early-errors/class-body-static-method-set-contains-direct-super.js (strict mode) |
||||||
|
language/statements/class/syntax/early-errors/class-definition-evaluation-block-duplicate-binding.js (default) |
||||||
|
language/statements/class/syntax/early-errors/class-definition-evaluation-block-duplicate-binding.js (strict mode) |
||||||
|
language/statements/class/syntax/early-errors/class-definition-evaluation-scriptbody-duplicate-binding.js (default) |
||||||
|
language/statements/class/syntax/early-errors/class-definition-evaluation-scriptbody-duplicate-binding.js (strict mode) |
||||||
|
language/statements/const/syntax/const-declaring-let-split-across-two-lines.js (default) |
||||||
|
language/statements/do-while/labelled-fn-stmt.js (default) |
||||||
|
language/statements/for/head-let-bound-names-in-stmt.js (default) |
||||||
|
language/statements/for/head-let-bound-names-in-stmt.js (strict mode) |
||||||
|
language/statements/for-in/head-const-bound-names-in-stmt.js (default) |
||||||
|
language/statements/for-in/head-const-bound-names-in-stmt.js (strict mode) |
||||||
|
language/statements/for-in/head-const-bound-names-let.js (default) |
||||||
|
language/statements/for-in/head-let-bound-names-in-stmt.js (default) |
||||||
|
language/statements/for-in/head-let-bound-names-in-stmt.js (strict mode) |
||||||
|
language/statements/for-in/head-let-bound-names-let.js (default) |
||||||
|
language/statements/for-in/labelled-fn-stmt-const.js (default) |
||||||
|
language/statements/for-in/labelled-fn-stmt-let.js (default) |
||||||
|
language/statements/for-in/labelled-fn-stmt-lhs.js (default) |
||||||
|
language/statements/for-in/labelled-fn-stmt-var.js (default) |
||||||
|
language/statements/for-in/let-block-with-newline.js (default) |
||||||
|
language/statements/for-in/let-identifier-with-newline.js (default) |
||||||
|
language/statements/for/labelled-fn-stmt-expr.js (default) |
||||||
|
language/statements/for/labelled-fn-stmt-let.js (default) |
||||||
|
language/statements/for/labelled-fn-stmt-var.js (default) |
||||||
|
language/statements/for/let-block-with-newline.js (default) |
||||||
|
language/statements/for/let-identifier-with-newline.js (default) |
||||||
|
language/statements/for-of/head-const-bound-names-in-stmt.js (default) |
||||||
|
language/statements/for-of/head-const-bound-names-in-stmt.js (strict mode) |
||||||
|
language/statements/for-of/head-const-bound-names-let.js (default) |
||||||
|
language/statements/for-of/head-let-bound-names-in-stmt.js (default) |
||||||
|
language/statements/for-of/head-let-bound-names-in-stmt.js (strict mode) |
||||||
|
language/statements/for-of/head-let-bound-names-let.js (default) |
||||||
|
language/statements/for-of/labelled-fn-stmt-const.js (default) |
||||||
|
language/statements/for-of/labelled-fn-stmt-let.js (default) |
||||||
|
language/statements/for-of/labelled-fn-stmt-lhs.js (default) |
||||||
|
language/statements/for-of/labelled-fn-stmt-var.js (default) |
||||||
|
language/statements/for-of/let-block-with-newline.js (default) |
||||||
|
language/statements/for-of/let-identifier-with-newline.js (default) |
||||||
|
language/statements/for-await-of/let-block-with-newline.js (default) |
||||||
|
language/statements/for-await-of/let-identifier-with-newline.js (default) |
||||||
|
language/statements/function/early-body-super-call.js (default) |
||||||
|
language/statements/function/early-body-super-call.js (strict mode) |
||||||
|
language/statements/function/early-body-super-prop.js (default) |
||||||
|
language/statements/function/early-body-super-prop.js (strict mode) |
||||||
|
language/statements/function/early-params-super-call.js (default) |
||||||
|
language/statements/function/early-params-super-call.js (strict mode) |
||||||
|
language/statements/function/early-params-super-prop.js (default) |
||||||
|
language/statements/function/early-params-super-prop.js (strict mode) |
||||||
|
language/statements/if/if-gen-else-gen.js (default) |
||||||
|
language/statements/if/if-gen-else-stmt.js (default) |
||||||
|
language/statements/if/if-gen-no-else.js (default) |
||||||
|
language/statements/if/if-stmt-else-gen.js (default) |
||||||
|
language/statements/if/labelled-fn-stmt-first.js (default) |
||||||
|
language/statements/if/labelled-fn-stmt-lone.js (default) |
||||||
|
language/statements/if/labelled-fn-stmt-second.js (default) |
||||||
|
language/statements/if/let-block-with-newline.js (default) |
||||||
|
language/statements/if/let-identifier-with-newline.js (default) |
||||||
|
language/statements/labeled/let-block-with-newline.js (default) |
||||||
|
language/statements/labeled/let-identifier-with-newline.js (default) |
||||||
|
language/statements/let/syntax/identifier-let-disallowed-as-boundname.js (default) |
||||||
|
language/statements/let/syntax/let-let-declaration-split-across-two-lines.js (default) |
||||||
|
language/statements/let/syntax/let-let-declaration-with-initializer-split-across-two-lines.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-async-function-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-async-function-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-class-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-function-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-function-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-generator-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-generator-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-var-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-var-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-async-generator-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/async-function-declaration-attempt-to-redeclare-with-async-generator-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-async-function-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-async-function-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-async-generator-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-async-generator-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-class-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-function-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-function-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-generator-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-generator-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-var-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/async-generator-declaration-attempt-to-redeclare-with-var-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-async-generator-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-async-generator-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-async-generator-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-async-generator-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-async-generator-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-async-generator-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-async-generator-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-async-generator-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-async-function-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-async-function-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-class-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-const-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-const-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-function-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-function-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-generator-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-generator-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-let-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-let-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-var-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/class-declaration-attempt-to-redeclare-with-var-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/const-declaration-attempt-to-redeclare-with-class-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/const-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-async-function-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-async-function-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-class-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-function-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-generator-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-generator-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-var-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-var-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-async-function-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-async-function-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-class-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-function-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-function-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-generator-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-generator-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-var-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/generator-declaration-attempt-to-redeclare-with-var-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/let-declaration-attempt-to-redeclare-with-class-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/let-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-async-function-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-async-function-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-class-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-class-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-function-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-function-declaration.js (strict mode) |
||||||
|
language/statements/switch/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-generator-declaration.js (default) |
||||||
|
language/statements/switch/syntax/redeclaration/var-declaration-attempt-to-redeclare-with-generator-declaration.js (strict mode) |
||||||
|
language/statements/while/labelled-fn-stmt.js (default) |
||||||
|
language/statements/while/let-block-with-newline.js (default) |
||||||
|
language/statements/while/let-identifier-with-newline.js (default) |
||||||
|
language/statements/with/labelled-fn-stmt.js (default) |
||||||
|
language/statements/with/let-block-with-newline.js (default) |
||||||
|
language/statements/with/let-identifier-with-newline.js (default) |
||||||
|
language/white-space/mongolian-vowel-separator.js (default) |
||||||
|
language/white-space/mongolian-vowel-separator.js (strict mode) |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue