From 754c1e5438457385fc8fa52abfcedf8ccd519925 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Wed, 5 Jul 2017 14:14:30 -0400 Subject: [PATCH] Upgrade to Babel 6 --- .../admin/components/ip-lookup.js.es6 | 2 +- .../admin/components/permalink-form.js.es6 | 2 +- .../javascripts/admin/models/api-key.js.es6 | 2 +- .../admin/routes/admin-reports.js.es6 | 2 +- app/assets/javascripts/deprecated.js | 2 +- .../discourse-common/resolver.js.es6 | 4 +- app/assets/javascripts/discourse-loader.js | 6 +- app/assets/javascripts/discourse.js.es6 | 6 +- .../components/search-advanced-options.js.es6 | 4 +- .../controllers/discovery/topics.js.es6 | 2 +- .../discourse/controllers/flag.js.es6 | 2 +- .../discourse/controllers/invite.js.es6 | 6 +- .../discourse/controllers/user.js.es6 | 2 +- .../javascripts/discourse/helpers/raw.js.es6 | 2 +- .../initializers/auto-load-modules.js.es6 | 4 +- .../javascripts/discourse/lib/autosize.js.es6 | 10 +- .../discourse/lib/plugin-connectors.js.es6 | 2 +- .../javascripts/discourse/lib/search.js.es6 | 6 +- .../discourse/mapping-router.js.es6 | 2 +- .../javascripts/discourse/models/post.js.es6 | 2 +- .../discourse/routes/application.js.es6 | 2 +- .../ember-computed-decorators.js.es6 | 1 - .../engines/discourse-markdown-it.js.es6 | 2 +- .../engines/discourse-markdown.js.es6 | 4 +- .../wizard/initializers/load-helpers.js.es6 | 2 +- .../javascripts/wizard/test/test_helper.js | 8 +- app/assets/javascripts/wizard/wizard.js.es6 | 2 +- app/models/theme_field.rb | 2 +- .../tilt/es6_module_transpiler_template.rb | 28 +- lib/freedom_patches/raw_handlebars.rb | 10 +- .../lib/details-cooked-test.js.es6 | 2 +- test/javascripts/helpers/qunit-helpers.js.es6 | 2 +- .../initializers/localization-test.js.es6 | 4 +- test/javascripts/mdtest/mdtest.js.es6.erb | 2 +- vendor/assets/javascripts/babel.js | 129871 +++++++-------- 35 files changed, 62713 insertions(+), 67299 deletions(-) diff --git a/app/assets/javascripts/admin/components/ip-lookup.js.es6 b/app/assets/javascripts/admin/components/ip-lookup.js.es6 index 0c9b73d54ac..58b71d73d25 100644 --- a/app/assets/javascripts/admin/components/ip-lookup.js.es6 +++ b/app/assets/javascripts/admin/components/ip-lookup.js.es6 @@ -44,7 +44,7 @@ export default Ember.Component.extend({ self.set("totalOthersWithSameIP", result.total); }); - const AdminUser = require('admin/models/admin-user').default; + const AdminUser = requirejs('admin/models/admin-user').default; AdminUser.findAll("active", data).then(function (users) { self.setProperties({ other_accounts: users, diff --git a/app/assets/javascripts/admin/components/permalink-form.js.es6 b/app/assets/javascripts/admin/components/permalink-form.js.es6 index 2bde845c0c6..321f613589c 100644 --- a/app/assets/javascripts/admin/components/permalink-form.js.es6 +++ b/app/assets/javascripts/admin/components/permalink-form.js.es6 @@ -18,7 +18,7 @@ export default Ember.Component.extend({ actions: { submit: function() { - const Permalink = require('admin/models/permalink').default; + const Permalink = requirejs('admin/models/permalink').default; if (!this.get('formSubmitted')) { const self = this; diff --git a/app/assets/javascripts/admin/models/api-key.js.es6 b/app/assets/javascripts/admin/models/api-key.js.es6 index 2a7cf867783..274b2fd09b3 100644 --- a/app/assets/javascripts/admin/models/api-key.js.es6 +++ b/app/assets/javascripts/admin/models/api-key.js.es6 @@ -37,7 +37,7 @@ ApiKey.reopenClass({ @returns {ApiKey} the ApiKey instance **/ create: function() { - const AdminUser = require('admin/models/admin-user').default; + const AdminUser = requirejs('admin/models/admin-user').default; var result = this._super.apply(this, arguments); if (result.user) { result.user = AdminUser.create(result.user); diff --git a/app/assets/javascripts/admin/routes/admin-reports.js.es6 b/app/assets/javascripts/admin/routes/admin-reports.js.es6 index 47ece705808..fc609296646 100644 --- a/app/assets/javascripts/admin/routes/admin-reports.js.es6 +++ b/app/assets/javascripts/admin/routes/admin-reports.js.es6 @@ -10,7 +10,7 @@ export default Discourse.Route.extend({ queryParams: { mode: {}, "start_date": {}, "end_date": {}, "category_id": {}, "group_id": {} }, model: function(params) { - const Report = require('admin/models/report').default; + const Report = requirejs('admin/models/report').default; return Report.find(params.type, params['start_date'], params['end_date'], params['category_id'], params['group_id']); }, diff --git a/app/assets/javascripts/deprecated.js b/app/assets/javascripts/deprecated.js index 151ed975d0c..a4174c50c84 100644 --- a/app/assets/javascripts/deprecated.js +++ b/app/assets/javascripts/deprecated.js @@ -1,5 +1,5 @@ (function() { - var Discourse = require('discourse').default; + var Discourse = requirejs('discourse').default; Discourse.dialect_deprecated = true; diff --git a/app/assets/javascripts/discourse-common/resolver.js.es6 b/app/assets/javascripts/discourse-common/resolver.js.es6 index b400d0b788a..1bbc1b432bf 100644 --- a/app/assets/javascripts/discourse-common/resolver.js.es6 +++ b/app/assets/javascripts/discourse-common/resolver.js.es6 @@ -38,7 +38,7 @@ export function buildResolver(baseName) { resolveRouter(parsedName) { const routerPath = `${baseName}/router`; if (requirejs.entries[routerPath]) { - const module = require(routerPath, null, null, true); + const module = requirejs(routerPath, null, null, true); return module.default; } return this._super(parsedName); @@ -79,7 +79,7 @@ export function buildResolver(baseName) { var module; if (moduleName) { - module = require(moduleName, null, null, true /* force sync */); + module = requirejs(moduleName, null, null, true /* force sync */); if (module && module['default']) { module = module['default']; } } return module; diff --git a/app/assets/javascripts/discourse-loader.js b/app/assets/javascripts/discourse-loader.js index 2d9f1d9f35f..dee43e5a9c1 100644 --- a/app/assets/javascripts/discourse-loader.js +++ b/app/assets/javascripts/discourse-loader.js @@ -1,4 +1,4 @@ -var define, require, requirejs; +var define, requirejs; (function() { @@ -54,7 +54,7 @@ var define, require, requirejs; var name = this.name; return this._require || (this._require = function(dep) { - return require(resolve(dep, name)); + return requirejs(resolve(dep, name)); }); }; @@ -127,7 +127,7 @@ var define, require, requirejs; if (!mod) { throw new Error('Could not find module `' + name + '` imported from `' + origin + '`'); } - return require(name); + return requirejs(name); } function missingModule(name) { diff --git a/app/assets/javascripts/discourse.js.es6 b/app/assets/javascripts/discourse.js.es6 index 5ca85473c5b..1c572af7ba4 100644 --- a/app/assets/javascripts/discourse.js.es6 +++ b/app/assets/javascripts/discourse.js.es6 @@ -102,7 +102,7 @@ const Discourse = Ember.Application.extend({ Object.keys(requirejs._eak_seen).forEach(function(key) { if (/\/pre\-initializers\//.test(key)) { - const module = require(key, null, null, true); + const module = requirejs(key, null, null, true); if (!module) { throw new Error(key + ' must export an initializer.'); } const init = module.default; @@ -117,7 +117,7 @@ const Discourse = Ember.Application.extend({ Object.keys(requirejs._eak_seen).forEach(function(key) { if (/\/initializers\//.test(key)) { - const module = require(key, null, null, true); + const module = requirejs(key, null, null, true); if (!module) { throw new Error(key + ' must export an initializer.'); } const init = module.default; @@ -131,7 +131,7 @@ const Discourse = Ember.Application.extend({ }); // Plugins that are registered via ` - */ - -var runScripts = function runScripts() { - var scripts = []; - var types = ["text/ecmascript-6", "text/6to5", "text/babel", "module"]; - var index = 0; - - /** - * Transform and execute script. Ensures correct load order. - */ - - var exec = function exec() { - var param = scripts[index]; - if (param instanceof Array) { - transform.run.apply(transform, param); - index++; - exec(); - } - }; - - /** - * Load, transform, and execute all scripts. - */ - - var run = function run(script, i) { - var opts = {}; - - if (script.src) { - transform.load(script.src, function (param) { - scripts[i] = param; - exec(); - }, opts, true); - } else { - opts.filename = "embedded"; - scripts[i] = [script.innerHTML, opts]; - } - }; - - // Collect scripts with Babel `types`. - - var _scripts = global.document.getElementsByTagName("script"); - - for (var i = 0; i < _scripts.length; ++i) { - var _script = _scripts[i]; - if (types.indexOf(_script.type) >= 0) scripts.push(_script); - } - - for (i in scripts) { - run(scripts[i], i); - } - - exec(); -}; - -/** - * Register load event to transform and execute scripts. - */ - -if (global.addEventListener) { - global.addEventListener("DOMContentLoaded", runScripts, false); -} else if (global.attachEvent) { - global.attachEvent("onload", runScripts); -} -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"15":15,"49":49,"611":611,"66":66}],15:[function(_dereq_,module,exports){ -"use strict"; - -exports.__esModule = true; -exports.register = register; -exports.polyfill = polyfill; -exports.transformFile = transformFile; -exports.transformFileSync = transformFileSync; -exports.parse = parse; -// istanbul ignore next - -function _interopRequire(obj) { return obj && obj.__esModule ? obj["default"] : obj; } - -// istanbul ignore next - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } } - -// istanbul ignore next - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } - -var _lodashLangIsFunction = _dereq_(508); - -var _lodashLangIsFunction2 = _interopRequireDefault(_lodashLangIsFunction); - -var _transformation = _dereq_(66); - -var _transformation2 = _interopRequireDefault(_transformation); - -var _babylon = _dereq_(613); - -var babylon = _interopRequireWildcard(_babylon); - -var _util = _dereq_(182); - -var util = _interopRequireWildcard(_util); - -var _fs = _dereq_(1); - -var _fs2 = _interopRequireDefault(_fs); - -var _types = _dereq_(179); - -var t = _interopRequireWildcard(_types); - -exports.util = util; -exports.acorn = babylon; -exports.transform = _transformation2["default"]; -exports.pipeline = _transformation.pipeline; -exports.canCompile = _util.canCompile; - -var _transformationFile = _dereq_(46); - -exports.File = _interopRequire(_transformationFile); - -var _transformationFileOptionsConfig = _dereq_(48); - -exports.options = _interopRequire(_transformationFileOptionsConfig); - -var _transformationPlugin = _dereq_(82); - -exports.Plugin = _interopRequire(_transformationPlugin); - -var _transformationTransformer = _dereq_(83); - -exports.Transformer = _interopRequire(_transformationTransformer); - -var _transformationPipeline = _dereq_(80); - -exports.Pipeline = _interopRequire(_transformationPipeline); - -var _traversal = _dereq_(148); - -exports.traverse = _interopRequire(_traversal); - -var _toolsBuildExternalHelpers = _dereq_(45); - -exports.buildExternalHelpers = _interopRequire(_toolsBuildExternalHelpers); - -var _package = _dereq_(611); - -exports.version = _package.version; -exports.types = t; - -/** - * Register Babel and polyfill globally. - */ - -function register(opts) { - var callback = _dereq_(17); - if (opts != null) callback(opts); - return callback; -} - -/** - * Register polyfill globally. - */ - -function polyfill() { - _dereq_(44); -} - -/** - * Asynchronously transform `filename` with optional `opts`, calls `callback` when complete. - */ - -function transformFile(filename, opts, callback) { - if (_lodashLangIsFunction2["default"](opts)) { - callback = opts; - opts = {}; - } - - opts.filename = filename; - - _fs2["default"].readFile(filename, function (err, code) { - if (err) return callback(err); - - var result; - - try { - result = _transformation2["default"](code, opts); - } catch (err) { - return callback(err); - } - - callback(null, result); - }); -} - -/** - * Synchronous form of `transformFile`. - */ - -function transformFileSync(filename) { - var opts = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - - opts.filename = filename; - return _transformation2["default"](_fs2["default"].readFileSync(filename, "utf8"), opts); -} - -/** - * Parse script with Babel's parser. - */ - -function parse(code) { - var opts = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - - opts.allowHashBang = true; - opts.sourceType = "module"; - opts.ecmaVersion = Infinity; - opts.plugins = { - jsx: true, - flow: true - }; - opts.features = {}; - - for (var key in _transformation2["default"].pipeline.transformers) { - opts.features[key] = true; - } - - var ast = babylon.parse(code, opts); - - if (opts.onToken) { - // istanbul ignore next - - var _opts$onToken; - - (_opts$onToken = opts.onToken).push.apply(_opts$onToken, ast.tokens); - } - - if (opts.onComment) { - // istanbul ignore next - - var _opts$onComment; - - (_opts$onComment = opts.onComment).push.apply(_opts$onComment, ast.comments); - } - - return ast.program; -} -},{"1":1,"148":148,"17":17,"179":179,"182":182,"44":44,"45":45,"46":46,"48":48,"508":508,"611":611,"613":613,"66":66,"80":80,"82":82,"83":83}],16:[function(_dereq_,module,exports){ -// required to safely use babel/register within a browserify codebase - -"use strict"; - -exports.__esModule = true; - -_dereq_(44); - -exports["default"] = function () {}; - -module.exports = exports["default"]; -},{"44":44}],17:[function(_dereq_,module,exports){ -"use strict"; - -exports.__esModule = true; -// istanbul ignore next - -function _interopRequire(obj) { return obj && obj.__esModule ? obj["default"] : obj; } - -_dereq_(44); - -var _node = _dereq_(16); - -exports["default"] = _interopRequire(_node); -module.exports = exports["default"]; -},{"16":16,"44":44}],18:[function(_dereq_,module,exports){ -"use strict"; - -exports.__esModule = true; -// istanbul ignore next - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } - -// istanbul ignore next - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -var _repeating = _dereq_(592); - -var _repeating2 = _interopRequireDefault(_repeating); - -var _trimRight = _dereq_(609); - -var _trimRight2 = _interopRequireDefault(_trimRight); - -var _lodashLangIsBoolean = _dereq_(506); - -var _lodashLangIsBoolean2 = _interopRequireDefault(_lodashLangIsBoolean); - -var _lodashCollectionIncludes = _dereq_(421); - -var _lodashCollectionIncludes2 = _interopRequireDefault(_lodashCollectionIncludes); - -var _lodashLangIsNumber = _dereq_(510); - -var _lodashLangIsNumber2 = _interopRequireDefault(_lodashLangIsNumber); - -/** - * Buffer for collecting generated output. - */ - -var Buffer = (function () { - function Buffer(position, format) { - _classCallCheck(this, Buffer); - - this.parenPushNewlineState = null; - - this.position = position; - this._indent = format.indent.base; - this.format = format; - this.buf = ""; - } - - /** - * Get the current trimmed buffer. - */ - - Buffer.prototype.get = function get() { - return _trimRight2["default"](this.buf); - }; - - /** - * Get the current indent. - */ - - Buffer.prototype.getIndent = function getIndent() { - if (this.format.compact || this.format.concise) { - return ""; - } else { - return _repeating2["default"](this.format.indent.style, this._indent); - } - }; - - /** - * Get the current indent size. - */ - - Buffer.prototype.indentSize = function indentSize() { - return this.getIndent().length; - }; - - /** - * Increment indent size. - */ - - Buffer.prototype.indent = function indent() { - this._indent++; - }; - - /** - * Decrement indent size. - */ - - Buffer.prototype.dedent = function dedent() { - this._indent--; - }; - - /** - * Add a semicolon to the buffer. - */ - - Buffer.prototype.semicolon = function semicolon() { - this.push(";"); - }; - - /** - * Ensure last character is a semicolon. - */ - - Buffer.prototype.ensureSemicolon = function ensureSemicolon() { - if (!this.isLast(";")) this.semicolon(); - }; - - /** - * Add a right brace to the buffer. - */ - - Buffer.prototype.rightBrace = function rightBrace() { - this.newline(true); - //if (this.format.compact) this._removeLast(";"); - this.push("}"); - }; - - /** - * Add a keyword to the buffer. - */ - - Buffer.prototype.keyword = function keyword(name) { - this.push(name); - this.space(); - }; - - /** - * Add a space to the buffer unless it is compact (override with force). - */ - - Buffer.prototype.space = function space(force) { - if (!force && this.format.compact) return; - - if (force || this.buf && !this.isLast(" ") && !this.isLast("\n")) { - this.push(" "); - } - }; - - /** - * Remove the last character. - */ - - Buffer.prototype.removeLast = function removeLast(cha) { - if (this.format.compact) return; - return this._removeLast(cha); - }; - - Buffer.prototype._removeLast = function _removeLast(cha) { - if (!this._isLast(cha)) return; - this.buf = this.buf.substr(0, this.buf.length - 1); - this.position.unshift(cha); - }; - - /** - * Set some state that will be modified if a newline has been inserted before any - * non-space characters. - * - * This is to prevent breaking semantics for terminatorless separator nodes. eg: - * - * return foo; - * - * returns `foo`. But if we do: - * - * return - * foo; - * - * `undefined` will be returned and not `foo` due to the terminator. - */ - - Buffer.prototype.startTerminatorless = function startTerminatorless() { - return this.parenPushNewlineState = { - printed: false - }; - }; - - /** - * Print an ending parentheses if a starting one has been printed. - */ - - Buffer.prototype.endTerminatorless = function endTerminatorless(state) { - if (state.printed) { - this.dedent(); - this.newline(); - this.push(")"); - } - }; - - /** - * Add a newline (or many newlines), maintaining formatting. - * Strips multiple newlines if removeLast is true. - */ - - Buffer.prototype.newline = function newline(i, removeLast) { - if (this.format.compact || this.format.retainLines) return; - - if (this.format.concise) { - this.space(); - return; - } - - removeLast = removeLast || false; - - if (_lodashLangIsNumber2["default"](i)) { - i = Math.min(2, i); - - if (this.endsWith("{\n") || this.endsWith(":\n")) i--; - if (i <= 0) return; - - while (i > 0) { - this._newline(removeLast); - i--; - } - return; - } - - if (_lodashLangIsBoolean2["default"](i)) { - removeLast = i; - } - - this._newline(removeLast); - }; - - /** - * Adds a newline unless there is already two previous newlines. - */ - - Buffer.prototype._newline = function _newline(removeLast) { - // never allow more than two lines - if (this.endsWith("\n\n")) return; - - // remove the last newline - if (removeLast && this.isLast("\n")) this.removeLast("\n"); - - this.removeLast(" "); - this._removeSpacesAfterLastNewline(); - this._push("\n"); - }; - - /** - * If buffer ends with a newline and some spaces after it, trim those spaces. - */ - - Buffer.prototype._removeSpacesAfterLastNewline = function _removeSpacesAfterLastNewline() { - var lastNewlineIndex = this.buf.lastIndexOf("\n"); - if (lastNewlineIndex === -1) { - return; - } - - var index = this.buf.length - 1; - while (index > lastNewlineIndex) { - if (this.buf[index] !== " ") { - break; - } - - index--; - } - - if (index === lastNewlineIndex) { - this.buf = this.buf.substring(0, index + 1); - } - }; - - /** - * Push a string to the buffer, maintaining indentation and newlines. - */ - - Buffer.prototype.push = function push(str, noIndent) { - if (!this.format.compact && this._indent && !noIndent && str !== "\n") { - // we have an indent level and we aren't pushing a newline - var indent = this.getIndent(); - - // replace all newlines with newlines with the indentation - str = str.replace(/\n/g, "\n" + indent); - - // we've got a newline before us so prepend on the indentation - if (this.isLast("\n")) this._push(indent); - } - - this._push(str); - }; - - /** - * Push a string to the buffer. - */ - - Buffer.prototype._push = function _push(str) { - // see startTerminatorless() instance method - var parenPushNewlineState = this.parenPushNewlineState; - if (parenPushNewlineState) { - for (var i = 0; i < str.length; i++) { - var cha = str[i]; - - // we can ignore spaces since they wont interupt a terminatorless separator - if (cha === " ") continue; - - this.parenPushNewlineState = null; - - if (cha === "\n" || cha === "/") { - // we're going to break this terminator expression so we need to add a parentheses - this._push("("); - this.indent(); - parenPushNewlineState.printed = true; - } - - break; - } - } - - // - this.position.push(str); - this.buf += str; - }; - - /** - * Test if the buffer ends with a string. - */ - - Buffer.prototype.endsWith = function endsWith(str) { - var buf = arguments.length <= 1 || arguments[1] === undefined ? this.buf : arguments[1]; - - if (str.length === 1) { - return buf[buf.length - 1] === str; - } else { - return buf.slice(-str.length) === str; - } - }; - - /** - * Test if a character is last in the buffer. - */ - - Buffer.prototype.isLast = function isLast(cha) { - if (this.format.compact) return false; - return this._isLast(cha); - }; - - Buffer.prototype._isLast = function _isLast(cha) { - var buf = this.buf; - var last = buf[buf.length - 1]; - - if (Array.isArray(cha)) { - return _lodashCollectionIncludes2["default"](cha, last); - } else { - return cha === last; - } - }; - - return Buffer; -})(); - -exports["default"] = Buffer; -module.exports = exports["default"]; -},{"421":421,"506":506,"510":510,"592":592,"609":609}],19:[function(_dereq_,module,exports){ -/** - * Print File.program - */ - -"use strict"; - -exports.__esModule = true; -exports.File = File; -exports.Program = Program; -exports.BlockStatement = BlockStatement; -exports.Noop = Noop; - -function File(node, print) { - print.plain(node.program); -} - -/** - * Print all nodes in a Program.body. - */ - -function Program(node, print) { - print.sequence(node.body); -} - -/** - * Print BlockStatement, collapses empty blocks, prints body. - */ - -function BlockStatement(node, print) { - this.push("{"); - if (node.body.length) { - this.newline(); - print.sequence(node.body, { indent: true }); - if (!this.format.retainLines) this.removeLast("\n"); - this.rightBrace(); - } else { - print.printInnerComments(); - this.push("}"); - } -} - -/** - * What is my purpose? - * Why am I here? - * Why are any of us here? - * Does any of this really matter? - */ - -function Noop() {} -},{}],20:[function(_dereq_,module,exports){ -/** - * Print ClassDeclaration, prints decorators, typeParameters, extends, implements, and body. - */ - -"use strict"; - -exports.__esModule = true; -exports.ClassDeclaration = ClassDeclaration; -exports.ClassBody = ClassBody; -exports.ClassProperty = ClassProperty; -exports.MethodDefinition = MethodDefinition; - -function ClassDeclaration(node, print) { - print.list(node.decorators, { separator: "" }); - this.push("class"); - - if (node.id) { - this.push(" "); - print.plain(node.id); - } - - print.plain(node.typeParameters); - - if (node.superClass) { - this.push(" extends "); - print.plain(node.superClass); - print.plain(node.superTypeParameters); - } - - if (node["implements"]) { - this.push(" implements "); - print.join(node["implements"], { separator: ", " }); - } - - this.space(); - print.plain(node.body); -} - -/** - * Alias ClassDeclaration printer as ClassExpression. - */ - -exports.ClassExpression = ClassDeclaration; - -/** - * Print ClassBody, collapses empty blocks, prints body. - */ - -function ClassBody(node, print) { - this.push("{"); - if (node.body.length === 0) { - print.printInnerComments(); - this.push("}"); - } else { - this.newline(); - - this.indent(); - print.sequence(node.body); - this.dedent(); - - this.rightBrace(); - } -} - -/** - * Print ClassProperty, prints decorators, static, key, typeAnnotation, and value. - * Also: semicolons, deal with it. - */ - -function ClassProperty(node, print) { - print.list(node.decorators, { separator: "" }); - - if (node["static"]) this.push("static "); - print.plain(node.key); - print.plain(node.typeAnnotation); - if (node.value) { - this.space(); - this.push("="); - this.space(); - print.plain(node.value); - } - this.semicolon(); -} - -/** - * Print MethodDefinition, prints decorations, static, and method. - */ - -function MethodDefinition(node, print) { - print.list(node.decorators, { separator: "" }); - - if (node["static"]) { - this.push("static "); - } - - this._method(node, print); -} -},{}],21:[function(_dereq_,module,exports){ -/** - * Prints ComprehensionBlock, prints left and right. - */ - -"use strict"; - -exports.__esModule = true; -exports.ComprehensionBlock = ComprehensionBlock; -exports.ComprehensionExpression = ComprehensionExpression; - -function ComprehensionBlock(node, print) { - this.keyword("for"); - this.push("("); - print.plain(node.left); - this.push(" of "); - print.plain(node.right); - this.push(")"); -} - -/** - * Prints ComprehensionExpression, prints blocks, filter, and body. Handles generators. - */ - -function ComprehensionExpression(node, print) { - this.push(node.generator ? "(" : "["); - - print.join(node.blocks, { separator: " " }); - this.space(); - - if (node.filter) { - this.keyword("if"); - this.push("("); - print.plain(node.filter); - this.push(")"); - this.space(); - } - - print.plain(node.body); - - this.push(node.generator ? ")" : "]"); -} -},{}],22:[function(_dereq_,module,exports){ -"use strict"; - -exports.__esModule = true; -exports.UnaryExpression = UnaryExpression; -exports.DoExpression = DoExpression; -exports.ParenthesizedExpression = ParenthesizedExpression; -exports.UpdateExpression = UpdateExpression; -exports.ConditionalExpression = ConditionalExpression; -exports.NewExpression = NewExpression; -exports.SequenceExpression = SequenceExpression; -exports.ThisExpression = ThisExpression; -exports.Super = Super; -exports.Decorator = Decorator; -exports.CallExpression = CallExpression; -exports.EmptyStatement = EmptyStatement; -exports.ExpressionStatement = ExpressionStatement; -exports.AssignmentPattern = AssignmentPattern; -exports.AssignmentExpression = AssignmentExpression; -exports.BindExpression = BindExpression; -exports.MemberExpression = MemberExpression; -exports.MetaProperty = MetaProperty; -// istanbul ignore next - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } } - -// istanbul ignore next - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } - -var _isInteger = _dereq_(406); - -var _isInteger2 = _interopRequireDefault(_isInteger); - -var _lodashLangIsNumber = _dereq_(510); - -var _lodashLangIsNumber2 = _interopRequireDefault(_lodashLangIsNumber); - -var _node = _dereq_(31); - -var _node2 = _interopRequireDefault(_node); - -var _types = _dereq_(179); - -var t = _interopRequireWildcard(_types); - -/** - * RegExp for testing scientific notation in literals. - */ - -var SCIENTIFIC_NOTATION = /e/i; -var ZERO_DECIMAL_INTEGER = /\.0+$/; - -/** - * RegExp for testing if a numeric literal is - * a BinaryIntegerLiteral, OctalIntegerLiteral or HexIntegerLiteral. - */ - -var NON_DECIMAL_NUMERIC_LITERAL = /^0(b|o|x)/i; - -/** - * Prints UnaryExpression, prints operator and argument. - */ - -function UnaryExpression(node, print) { - var needsSpace = /[a-z]$/.test(node.operator); - var arg = node.argument; - - if (t.isUpdateExpression(arg) || t.isUnaryExpression(arg)) { - needsSpace = true; - } - - if (t.isUnaryExpression(arg) && arg.operator === "!") { - needsSpace = false; - } - - this.push(node.operator); - if (needsSpace) this.push(" "); - print.plain(node.argument); -} - -/** - * Prints DoExpression, prints body. - */ - -function DoExpression(node, print) { - this.push("do"); - this.space(); - print.plain(node.body); -} - -/** - * Prints ParenthesizedExpression, prints expression. - */ - -function ParenthesizedExpression(node, print) { - this.push("("); - print.plain(node.expression); - this.push(")"); -} - -/** - * Prints UpdateExpression, prints operator and argument. - */ - -function UpdateExpression(node, print) { - if (node.prefix) { - this.push(node.operator); - print.plain(node.argument); - } else { - print.plain(node.argument); - this.push(node.operator); - } -} - -/** - * Prints ConditionalExpression, prints test, consequent, and alternate. - */ - -function ConditionalExpression(node, print) { - print.plain(node.test); - this.space(); - this.push("?"); - this.space(); - print.plain(node.consequent); - this.space(); - this.push(":"); - this.space(); - print.plain(node.alternate); -} - -/** - * Prints NewExpression, prints callee and arguments. - */ - -function NewExpression(node, print) { - this.push("new "); - print.plain(node.callee); - this.push("("); - print.list(node.arguments); - this.push(")"); -} - -/** - * Prints SequenceExpression.expressions. - */ - -function SequenceExpression(node, print) { - print.list(node.expressions); -} - -/** - * Prints ThisExpression. - */ - -function ThisExpression() { - this.push("this"); -} - -/** - * Prints Super. - */ - -function Super() { - this.push("super"); -} - -/** - * Prints Decorator, prints expression. - */ - -function Decorator(node, print) { - this.push("@"); - print.plain(node.expression); - this.newline(); -} - -/** - * Prints CallExpression, prints callee and arguments. - */ - -function CallExpression(node, print) { - print.plain(node.callee); - - this.push("("); - - var isPrettyCall = node._prettyCall && !this.format.retainLines && !this.format.compact; - - var separator; - if (isPrettyCall) { - separator = ",\n"; - this.newline(); - this.indent(); - } - - print.list(node.arguments, { separator: separator }); - - if (isPrettyCall) { - this.newline(); - this.dedent(); - } - - this.push(")"); -} - -/** - * Builds yield or await expression printer. - * Prints delegate, all, and argument. - */ - -var buildYieldAwait = function buildYieldAwait(keyword) { - return function (node, print) { - this.push(keyword); - - if (node.delegate || node.all) { - this.push("*"); - } - - if (node.argument) { - this.push(" "); - var terminatorState = this.startTerminatorless(); - print.plain(node.argument); - this.endTerminatorless(terminatorState); - } - }; -}; - -/** - * Create YieldExpression and AwaitExpression printers. - */ - -var YieldExpression = buildYieldAwait("yield"); -exports.YieldExpression = YieldExpression; -var AwaitExpression = buildYieldAwait("await"); - -exports.AwaitExpression = AwaitExpression; -/** - * Prints EmptyStatement. - */ - -function EmptyStatement() { - this.semicolon(); -} - -/** - * Prints ExpressionStatement, prints expression. - */ - -function ExpressionStatement(node, print) { - print.plain(node.expression); - this.semicolon(); -} - -/** - * Prints AssignmentPattern, prints left and right. - */ - -function AssignmentPattern(node, print) { - print.plain(node.left); - this.push(" = "); - print.plain(node.right); -} - -/** - * Prints AssignmentExpression, prints left, operator, and right. - */ - -function AssignmentExpression(node, print, parent) { - // Somewhere inside a for statement `init` node but doesn't usually - // needs a paren except for `in` expressions: `for (a in b ? a : b;;)` - var parens = this._inForStatementInit && node.operator === "in" && !_node2["default"].needsParens(node, parent); - - if (parens) { - this.push("("); - } - - // todo: add cases where the spaces can be dropped when in compact mode - print.plain(node.left); - - var spaces = node.operator === "in" || node.operator === "instanceof"; - spaces = true; // todo: https://github.com/babel/babel/issues/1835 - this.space(spaces); - - this.push(node.operator); - - if (!spaces) { - // space is mandatory to avoid outputting regexps - set = set.map(function (s, si, set) { - return s.map(this.parse, this) - }, this) - - this.debug(this.pattern, set) - - // filter out everything that didn't compile properly. - set = set.filter(function (s) { - return s.indexOf(false) === -1 - }) - - this.debug(this.pattern, set) - - this.set = set -} - -Minimatch.prototype.parseNegate = parseNegate -function parseNegate () { - var pattern = this.pattern - var negate = false - var options = this.options - var negateOffset = 0 - - if (options.nonegate) return - - for (var i = 0, l = pattern.length - ; i < l && pattern.charAt(i) === '!' - ; i++) { - negate = !negate - negateOffset++ - } - - if (negateOffset) this.pattern = pattern.substr(negateOffset) - this.negate = negate -} - -// Brace expansion: -// a{b,c}d -> abd acd -// a{b,}c -> abc ac -// a{0..3}d -> a0d a1d a2d a3d -// a{b,c{d,e}f}g -> abg acdfg acefg -// a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg -// -// Invalid sets are not expanded. -// a{2..}b -> a{2..}b -// a{b}c -> a{b}c -minimatch.braceExpand = function (pattern, options) { - return braceExpand(pattern, options) -} - -Minimatch.prototype.braceExpand = braceExpand - -function braceExpand (pattern, options) { - if (!options) { - if (this instanceof Minimatch) { - options = this.options - } else { - options = {} - } - } - - pattern = typeof pattern === 'undefined' - ? this.pattern : pattern - - if (typeof pattern === 'undefined') { - throw new Error('undefined pattern') - } - - if (options.nobrace || - !pattern.match(/\{.*\}/)) { - // shortcut. no need to expand. - return [pattern] - } - - return expand(pattern) -} - -// parse a component of the expanded set. -// At this point, no pattern may contain "/" in it -// so we're going to return a 2d array, where each entry is the full -// pattern, split on '/', and then turned into a regular expression. -// A regexp is made at the end which joins each array with an -// escaped /, and another full one which joins each regexp with |. -// -// Following the lead of Bash 4.1, note that "**" only has special meaning -// when it is the *only* thing in a path portion. Otherwise, any series -// of * is equivalent to a single *. Globstar behavior is enabled by -// default, and can be disabled by setting options.noglobstar. -Minimatch.prototype.parse = parse -var SUBPARSE = {} -function parse (pattern, isSub) { - var options = this.options - - // shortcuts - if (!options.noglobstar && pattern === '**') return GLOBSTAR - if (pattern === '') return '' - - var re = '' - var hasMagic = !!options.nocase - var escaping = false - // ? => one single character - var patternListStack = [] - var negativeLists = [] - var plType - var stateChar - var inClass = false - var reClassStart = -1 - var classStart = -1 - // . and .. never match anything that doesn't start with ., - // even when options.dot is set. - var patternStart = pattern.charAt(0) === '.' ? '' // anything - // not (start or / followed by . or .. followed by / or end) - : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' - : '(?!\\.)' - var self = this - - function clearStateChar () { - if (stateChar) { - // we had some state-tracking character - // that wasn't consumed by this pass. - switch (stateChar) { - case '*': - re += star - hasMagic = true - break - case '?': - re += qmark - hasMagic = true - break - default: - re += '\\' + stateChar - break - } - self.debug('clearStateChar %j %j', stateChar, re) - stateChar = false - } - } - - for (var i = 0, len = pattern.length, c - ; (i < len) && (c = pattern.charAt(i)) - ; i++) { - this.debug('%s\t%s %s %j', pattern, i, re, c) - - // skip over any that are escaped. - if (escaping && reSpecials[c]) { - re += '\\' + c - escaping = false - continue - } - - switch (c) { - case '/': - // completely not allowed, even escaped. - // Should already be path-split by now. - return false - - case '\\': - clearStateChar() - escaping = true - continue - - // the various stateChar values - // for the "extglob" stuff. - case '?': - case '*': - case '+': - case '@': - case '!': - this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c) - - // all of those are literals inside a class, except that - // the glob [!a] means [^a] in regexp - if (inClass) { - this.debug(' in class') - if (c === '!' && i === classStart + 1) c = '^' - re += c - continue - } - - // if we already have a stateChar, then it means - // that there was something like ** or +? in there. - // Handle the stateChar, then proceed with this one. - self.debug('call clearStateChar %j', stateChar) - clearStateChar() - stateChar = c - // if extglob is disabled, then +(asdf|foo) isn't a thing. - // just clear the statechar *now*, rather than even diving into - // the patternList stuff. - if (options.noext) clearStateChar() - continue - - case '(': - if (inClass) { - re += '(' - continue - } - - if (!stateChar) { - re += '\\(' - continue - } - - plType = stateChar - patternListStack.push({ - type: plType, - start: i - 1, - reStart: re.length - }) - // negation is (?:(?!js)[^/]*) - re += stateChar === '!' ? '(?:(?!(?:' : '(?:' - this.debug('plType %j %j', stateChar, re) - stateChar = false - continue - - case ')': - if (inClass || !patternListStack.length) { - re += '\\)' - continue - } - - clearStateChar() - hasMagic = true - re += ')' - var pl = patternListStack.pop() - plType = pl.type - // negation is (?:(?!js)[^/]*) - // The others are (?:) - switch (plType) { - case '!': - negativeLists.push(pl) - re += ')[^/]*?)' - pl.reEnd = re.length - break - case '?': - case '+': - case '*': - re += plType - break - case '@': break // the default anyway - } - continue - - case '|': - if (inClass || !patternListStack.length || escaping) { - re += '\\|' - escaping = false - continue - } - - clearStateChar() - re += '|' - continue - - // these are mostly the same in regexp and glob - case '[': - // swallow any state-tracking char before the [ - clearStateChar() - - if (inClass) { - re += '\\' + c - continue - } - - inClass = true - classStart = i - reClassStart = re.length - re += c - continue - - case ']': - // a right bracket shall lose its special - // meaning and represent itself in - // a bracket expression if it occurs - // first in the list. -- POSIX.2 2.8.3.2 - if (i === classStart + 1 || !inClass) { - re += '\\' + c - escaping = false - continue - } - - // handle the case where we left a class open. - // "[z-a]" is valid, equivalent to "\[z-a\]" - if (inClass) { - // split where the last [ was, make sure we don't have - // an invalid re. if so, re-walk the contents of the - // would-be class to re-translate any characters that - // were passed through as-is - // TODO: It would probably be faster to determine this - // without a try/catch and a new RegExp, but it's tricky - // to do safely. For now, this is safe and works. - var cs = pattern.substring(classStart + 1, i) - try { - RegExp('[' + cs + ']') - } catch (er) { - // not a valid class! - var sp = this.parse(cs, SUBPARSE) - re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]' - hasMagic = hasMagic || sp[1] - inClass = false - continue - } - } - - // finish up the class. - hasMagic = true - inClass = false - re += c - continue - - default: - // swallow any state char that wasn't consumed - clearStateChar() - - if (escaping) { - // no need - escaping = false - } else if (reSpecials[c] - && !(c === '^' && inClass)) { - re += '\\' - } - - re += c - - } // switch - } // for - - // handle the case where we left a class open. - // "[abc" is valid, equivalent to "\[abc" - if (inClass) { - // split where the last [ was, and escape it - // this is a huge pita. We now have to re-walk - // the contents of the would-be class to re-translate - // any characters that were passed through as-is - cs = pattern.substr(classStart + 1) - sp = this.parse(cs, SUBPARSE) - re = re.substr(0, reClassStart) + '\\[' + sp[0] - hasMagic = hasMagic || sp[1] - } - - // handle the case where we had a +( thing at the *end* - // of the pattern. - // each pattern list stack adds 3 chars, and we need to go through - // and escape any | chars that were passed through as-is for the regexp. - // Go through and escape them, taking care not to double-escape any - // | chars that were already escaped. - for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) { - var tail = re.slice(pl.reStart + 3) - // maybe some even number of \, then maybe 1 \, followed by a | - tail = tail.replace(/((?:\\{2})*)(\\?)\|/g, function (_, $1, $2) { - if (!$2) { - // the | isn't already escaped, so escape it. - $2 = '\\' - } - - // need to escape all those slashes *again*, without escaping the - // one that we need for escaping the | character. As it works out, - // escaping an even number of slashes can be done by simply repeating - // it exactly after itself. That's why this trick works. - // - // I am sorry that you have to see this. - return $1 + $1 + $2 + '|' - }) - - this.debug('tail=%j\n %s', tail, tail) - var t = pl.type === '*' ? star - : pl.type === '?' ? qmark - : '\\' + pl.type - - hasMagic = true - re = re.slice(0, pl.reStart) + t + '\\(' + tail - } - - // handle trailing things that only matter at the very end. - clearStateChar() - if (escaping) { - // trailing \\ - re += '\\\\' - } - - // only need to apply the nodot start if the re starts with - // something that could conceivably capture a dot - var addPatternStart = false - switch (re.charAt(0)) { - case '.': - case '[': - case '(': addPatternStart = true - } - - // Hack to work around lack of negative lookbehind in JS - // A pattern like: *.!(x).!(y|z) needs to ensure that a name - // like 'a.xyz.yz' doesn't match. So, the first negative - // lookahead, has to look ALL the way ahead, to the end of - // the pattern. - for (var n = negativeLists.length - 1; n > -1; n--) { - var nl = negativeLists[n] - - var nlBefore = re.slice(0, nl.reStart) - var nlFirst = re.slice(nl.reStart, nl.reEnd - 8) - var nlLast = re.slice(nl.reEnd - 8, nl.reEnd) - var nlAfter = re.slice(nl.reEnd) - - nlLast += nlAfter - - // Handle nested stuff like *(*.js|!(*.json)), where open parens - // mean that we should *not* include the ) in the bit that is considered - // "after" the negated section. - var openParensBefore = nlBefore.split('(').length - 1 - var cleanAfter = nlAfter - for (i = 0; i < openParensBefore; i++) { - cleanAfter = cleanAfter.replace(/\)[+*?]?/, '') - } - nlAfter = cleanAfter - - var dollar = '' - if (nlAfter === '' && isSub !== SUBPARSE) { - dollar = '$' - } - var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast - re = newRe - } - - // if the re is not "" at this point, then we need to make sure - // it doesn't match against an empty path part. - // Otherwise a/* will match a/, which it should not. - if (re !== '' && hasMagic) { - re = '(?=.)' + re - } - - if (addPatternStart) { - re = patternStart + re - } - - // parsing just a piece of a larger pattern. - if (isSub === SUBPARSE) { - return [re, hasMagic] - } - - // skip the regexp for non-magical patterns - // unescape anything in it, though, so that it'll be - // an exact match against a file etc. - if (!hasMagic) { - return globUnescape(pattern) - } - - var flags = options.nocase ? 'i' : '' - var regExp = new RegExp('^' + re + '$', flags) - - regExp._glob = pattern - regExp._src = re - - return regExp -} - -minimatch.makeRe = function (pattern, options) { - return new Minimatch(pattern, options || {}).makeRe() -} - -Minimatch.prototype.makeRe = makeRe -function makeRe () { - if (this.regexp || this.regexp === false) return this.regexp - - // at this point, this.set is a 2d array of partial - // pattern strings, or "**". - // - // It's better to use .match(). This function shouldn't - // be used, really, but it's pretty convenient sometimes, - // when you just want to work with a regex. - var set = this.set - - if (!set.length) { - this.regexp = false - return this.regexp - } - var options = this.options - - var twoStar = options.noglobstar ? star - : options.dot ? twoStarDot - : twoStarNoDot - var flags = options.nocase ? 'i' : '' - - var re = set.map(function (pattern) { - return pattern.map(function (p) { - return (p === GLOBSTAR) ? twoStar - : (typeof p === 'string') ? regExpEscape(p) - : p._src - }).join('\\\/') - }).join('|') - - // must match entire pattern - // ending in a * or ** will make it less strict. - re = '^(?:' + re + ')$' - - // can match anything, as long as it's not this. - if (this.negate) re = '^(?!' + re + ').*$' - - try { - this.regexp = new RegExp(re, flags) - } catch (ex) { - this.regexp = false - } - return this.regexp -} - -minimatch.match = function (list, pattern, options) { - options = options || {} - var mm = new Minimatch(pattern, options) - list = list.filter(function (f) { - return mm.match(f) - }) - if (mm.options.nonull && !list.length) { - list.push(pattern) - } - return list -} - -Minimatch.prototype.match = match -function match (f, partial) { - this.debug('match', f, this.pattern) - // short-circuit in the case of busted things. - // comments, etc. - if (this.comment) return false - if (this.empty) return f === '' - - if (f === '/' && partial) return true - - var options = this.options - - // windows: need to use /, not \ - if (path.sep !== '/') { - f = f.split(path.sep).join('/') - } - - // treat the test path as a set of pathparts. - f = f.split(slashSplit) - this.debug(this.pattern, 'split', f) - - // just ONE of the pattern sets in this.set needs to match - // in order for it to be valid. If negating, then just one - // match means that we have failed. - // Either way, return on the first hit. - - var set = this.set - this.debug(this.pattern, 'set', set) - - // Find the basename of the path by looking for the last non-empty segment - var filename - var i - for (i = f.length - 1; i >= 0; i--) { - filename = f[i] - if (filename) break - } - - for (i = 0; i < set.length; i++) { - var pattern = set[i] - var file = f - if (options.matchBase && pattern.length === 1) { - file = [filename] - } - var hit = this.matchOne(file, pattern, partial) - if (hit) { - if (options.flipNegate) return true - return !this.negate - } - } - - // didn't get any hits. this is success if it's a negative - // pattern, failure otherwise. - if (options.flipNegate) return false - return this.negate -} - -// set partial to true to test if, for example, -// "/a/b" matches the start of "/*/b/*/d" -// Partial means, if you run out of file before you run -// out of pattern, then that's fine, as long as all -// the parts match. -Minimatch.prototype.matchOne = function (file, pattern, partial) { - var options = this.options - - this.debug('matchOne', - { 'this': this, file: file, pattern: pattern }) - - this.debug('matchOne', file.length, pattern.length) - - for (var fi = 0, - pi = 0, - fl = file.length, - pl = pattern.length - ; (fi < fl) && (pi < pl) - ; fi++, pi++) { - this.debug('matchOne loop') - var p = pattern[pi] - var f = file[fi] - - this.debug(pattern, p, f) - - // should be impossible. - // some invalid regexp stuff in the set. - if (p === false) return false - - if (p === GLOBSTAR) { - this.debug('GLOBSTAR', [pattern, p, f]) - - // "**" - // a/**/b/**/c would match the following: - // a/b/x/y/z/c - // a/x/y/z/b/c - // a/b/x/b/x/c - // a/b/c - // To do this, take the rest of the pattern after - // the **, and see if it would match the file remainder. - // If so, return success. - // If not, the ** "swallows" a segment, and try again. - // This is recursively awful. - // - // a/**/b/**/c matching a/b/x/y/z/c - // - a matches a - // - doublestar - // - matchOne(b/x/y/z/c, b/**/c) - // - b matches b - // - doublestar - // - matchOne(x/y/z/c, c) -> no - // - matchOne(y/z/c, c) -> no - // - matchOne(z/c, c) -> no - // - matchOne(c, c) yes, hit - var fr = fi - var pr = pi + 1 - if (pr === pl) { - this.debug('** at the end') - // a ** at the end will just swallow the rest. - // We have found a match. - // however, it will not swallow /.x, unless - // options.dot is set. - // . and .. are *never* matched by **, for explosively - // exponential reasons. - for (; fi < fl; fi++) { - if (file[fi] === '.' || file[fi] === '..' || - (!options.dot && file[fi].charAt(0) === '.')) return false - } - return true - } - - // ok, let's see if we can swallow whatever we can. - while (fr < fl) { - var swallowee = file[fr] - - this.debug('\nglobstar while', file, fr, pattern, pr, swallowee) - - // XXX remove this slice. Just pass the start index. - if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) { - this.debug('globstar found match!', fr, fl, swallowee) - // found a match. - return true - } else { - // can't swallow "." or ".." ever. - // can only swallow ".foo" when explicitly asked. - if (swallowee === '.' || swallowee === '..' || - (!options.dot && swallowee.charAt(0) === '.')) { - this.debug('dot detected!', file, fr, pattern, pr) - break - } - - // ** swallows a segment, and continue. - this.debug('globstar swallow a segment, and continue') - fr++ - } - } - - // no match was found. - // However, in partial mode, we can't say this is necessarily over. - // If there's more *pattern* left, then - if (partial) { - // ran out of file - this.debug('\n>>> no match, partial?', file, fr, pattern, pr) - if (fr === fl) return true - } - return false - } - - // something other than ** - // non-magic patterns just have to match exactly - // patterns with magic have been turned into regexps. - var hit - if (typeof p === 'string') { - if (options.nocase) { - hit = f.toLowerCase() === p.toLowerCase() - } else { - hit = f === p - } - this.debug('string match', p, f, hit) - } else { - hit = f.match(p) - this.debug('pattern match', p, f, hit) - } - - if (!hit) return false - } - - // Note: ending in / means that we'll get a final "" - // at the end of the pattern. This can only match a - // corresponding "" at the end of the file. - // If the file ends in /, then it can only match a - // a pattern that ends in /, unless the pattern just - // doesn't have any more for it. But, a/b/ should *not* - // match "a/b/*", even though "" matches against the - // [^/]*? pattern, except in partial mode, where it might - // simply not be reached yet. - // However, a/b/ should still satisfy a/* - - // now either we fell off the end of the pattern, or we're done. - if (fi === fl && pi === pl) { - // ran out of pattern and filename at the same time. - // an exact hit! - return true - } else if (fi === fl) { - // ran out of file, but still had pattern left. - // this is ok if we're doing the match as part of - // a glob fs traversal. - return partial - } else if (pi === pl) { - // ran out of pattern, still have file left. - // this is only acceptable if we're on the very last - // empty segment of a file with a trailing slash. - // a/* should match a/b/ - var emptyFileEnd = (fi === fl - 1) && (file[fi] === '') - return emptyFileEnd - } - - // should be unreachable. - throw new Error('wtf?') -} - -// replace stuff like \* with * -function globUnescape (s) { - return s.replace(/\\(.)/g, '$1') -} - -function regExpEscape (s) { - return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&') -} - -},{"531":531,"9":9}],531:[function(_dereq_,module,exports){ -var concatMap = _dereq_(533); -var balanced = _dereq_(532); - -module.exports = expandTop; - -var escSlash = '\0SLASH'+Math.random()+'\0'; -var escOpen = '\0OPEN'+Math.random()+'\0'; -var escClose = '\0CLOSE'+Math.random()+'\0'; -var escComma = '\0COMMA'+Math.random()+'\0'; -var escPeriod = '\0PERIOD'+Math.random()+'\0'; - -function numeric(str) { - return parseInt(str, 10) == str - ? parseInt(str, 10) - : str.charCodeAt(0); -} - -function escapeBraces(str) { - return str.split('\\\\').join(escSlash) - .split('\\{').join(escOpen) - .split('\\}').join(escClose) - .split('\\,').join(escComma) - .split('\\.').join(escPeriod); -} - -function unescapeBraces(str) { - return str.split(escSlash).join('\\') - .split(escOpen).join('{') - .split(escClose).join('}') - .split(escComma).join(',') - .split(escPeriod).join('.'); -} - - -// Basically just str.split(","), but handling cases -// where we have nested braced sections, which should be -// treated as individual members, like {a,{b,c},d} -function parseCommaParts(str) { - if (!str) - return ['']; - - var parts = []; - var m = balanced('{', '}', str); - - if (!m) - return str.split(','); - - var pre = m.pre; - var body = m.body; - var post = m.post; - var p = pre.split(','); - - p[p.length-1] += '{' + body + '}'; - var postParts = parseCommaParts(post); - if (post.length) { - p[p.length-1] += postParts.shift(); - p.push.apply(p, postParts); - } - - parts.push.apply(parts, p); - - return parts; -} - -function expandTop(str) { - if (!str) - return []; - - return expand(escapeBraces(str), true).map(unescapeBraces); -} - -function identity(e) { - return e; -} - -function embrace(str) { - return '{' + str + '}'; -} -function isPadded(el) { - return /^-?0\d/.test(el); -} - -function lte(i, y) { - return i <= y; -} -function gte(i, y) { - return i >= y; -} - -function expand(str, isTop) { - var expansions = []; - - var m = balanced('{', '}', str); - if (!m || /\$$/.test(m.pre)) return [str]; - - var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body); - var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body); - var isSequence = isNumericSequence || isAlphaSequence; - var isOptions = /^(.*,)+(.+)?$/.test(m.body); - if (!isSequence && !isOptions) { - // {a},b} - if (m.post.match(/,.*}/)) { - str = m.pre + '{' + m.body + escClose + m.post; - return expand(str); - } - return [str]; - } - - var n; - if (isSequence) { - n = m.body.split(/\.\./); - } else { - n = parseCommaParts(m.body); - if (n.length === 1) { - // x{{a,b}}y ==> x{a}y x{b}y - n = expand(n[0], false).map(embrace); - if (n.length === 1) { - var post = m.post.length - ? expand(m.post, false) - : ['']; - return post.map(function(p) { - return m.pre + n[0] + p; - }); - } - } - } - - // at this point, n is the parts, and we know it's not a comma set - // with a single entry. - - // no need to expand pre, since it is guaranteed to be free of brace-sets - var pre = m.pre; - var post = m.post.length - ? expand(m.post, false) - : ['']; - - var N; - - if (isSequence) { - var x = numeric(n[0]); - var y = numeric(n[1]); - var width = Math.max(n[0].length, n[1].length) - var incr = n.length == 3 - ? Math.abs(numeric(n[2])) - : 1; - var test = lte; - var reverse = y < x; - if (reverse) { - incr *= -1; - test = gte; - } - var pad = n.some(isPadded); - - N = []; - - for (var i = x; test(i, y); i += incr) { - var c; - if (isAlphaSequence) { - c = String.fromCharCode(i); - if (c === '\\') - c = ''; - } else { - c = String(i); - if (pad) { - var need = width - c.length; - if (need > 0) { - var z = new Array(need + 1).join('0'); - if (i < 0) - c = '-' + z + c.slice(1); - else - c = z + c; - } - } - } - N.push(c); - } - } else { - N = concatMap(n, function(el) { return expand(el, false) }); - } - - for (var j = 0; j < N.length; j++) { - for (var k = 0; k < post.length; k++) { - var expansion = pre + N[j] + post[k]; - if (!isTop || isSequence || expansion) - expansions.push(expansion); - } - } - - return expansions; -} - - -},{"532":532,"533":533}],532:[function(_dereq_,module,exports){ -module.exports = balanced; -function balanced(a, b, str) { - var bal = 0; - var m = {}; - var ended = false; - - for (var i = 0; i < str.length; i++) { - if (a == str.substr(i, a.length)) { - if (!('start' in m)) m.start = i; - bal++; - } - else if (b == str.substr(i, b.length) && 'start' in m) { - ended = true; - bal--; - if (!bal) { - m.end = i; - m.pre = str.substr(0, m.start); - m.body = (m.end - m.start > 1) - ? str.substring(m.start + a.length, m.end) - : ''; - m.post = str.slice(m.end + b.length); - return m; - } - } - } - - // if we opened more than we closed, find the one we closed - if (bal && ended) { - var start = m.start + a.length; - m = balanced(a, b, str.substr(start)); - if (m) { - m.start += start; - m.end += start; - m.pre = str.slice(0, start) + m.pre; - } - return m; - } -} - -},{}],533:[function(_dereq_,module,exports){ -module.exports = function (xs, fn) { - var res = []; - for (var i = 0; i < xs.length; i++) { - var x = fn(xs[i], i); - if (isArray(x)) res.push.apply(res, x); - else res.push(x); - } - return res; -}; - -var isArray = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; - -},{}],534:[function(_dereq_,module,exports){ -'use strict'; -var fs = _dereq_(1) - -module.exports = function (pth, cb) { - var fn = typeof fs.access === 'function' ? fs.access : fs.stat; - - fn(pth, function (err) { - cb(null, !err); + + module.exports = isArrayLike; + +/***/ }), +/* 25 */ +/***/ (function(module, exports) { + + 'use strict'; + + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + + /** + * Checks if `value` is object-like. A value is object-like if it's not `null` + * and has a `typeof` result of "object". + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + * @example + * + * _.isObjectLike({}); + * // => true + * + * _.isObjectLike([1, 2, 3]); + * // => true + * + * _.isObjectLike(_.noop); + * // => false + * + * _.isObjectLike(null); + * // => false + */ + function isObjectLike(value) { + return value != null && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) == 'object'; + } + + module.exports = isObjectLike; + +/***/ }), +/* 26 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + exports.__esModule = true; + exports.DEPRECATED_KEYS = exports.BUILDER_KEYS = exports.NODE_FIELDS = exports.ALIAS_KEYS = exports.VISITOR_KEYS = undefined; + + var _getIterator2 = __webpack_require__(2); + + var _getIterator3 = _interopRequireDefault(_getIterator2); + + var _stringify = __webpack_require__(34); + + var _stringify2 = _interopRequireDefault(_stringify); + + var _typeof2 = __webpack_require__(11); + + var _typeof3 = _interopRequireDefault(_typeof2); + + exports.assertEach = assertEach; + exports.assertOneOf = assertOneOf; + exports.assertNodeType = assertNodeType; + exports.assertNodeOrValueType = assertNodeOrValueType; + exports.assertValueType = assertValueType; + exports.chain = chain; + exports.default = defineType; + + var _index = __webpack_require__(1); + + var t = _interopRequireWildcard(_index); + + function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } else { + var newObj = {};if (obj != null) { + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; + } + }newObj.default = obj;return newObj; + } + } + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + var VISITOR_KEYS = exports.VISITOR_KEYS = {}; + var ALIAS_KEYS = exports.ALIAS_KEYS = {}; + var NODE_FIELDS = exports.NODE_FIELDS = {}; + var BUILDER_KEYS = exports.BUILDER_KEYS = {}; + var DEPRECATED_KEYS = exports.DEPRECATED_KEYS = {}; + + function getType(val) { + if (Array.isArray(val)) { + return "array"; + } else if (val === null) { + return "null"; + } else if (val === undefined) { + return "undefined"; + } else { + return typeof val === "undefined" ? "undefined" : (0, _typeof3.default)(val); + } + } + + function assertEach(callback) { + function validator(node, key, val) { + if (!Array.isArray(val)) return; + + for (var i = 0; i < val.length; i++) { + callback(node, key + "[" + i + "]", val[i]); + } + } + validator.each = callback; + return validator; + } + + function assertOneOf() { + for (var _len = arguments.length, vals = Array(_len), _key = 0; _key < _len; _key++) { + vals[_key] = arguments[_key]; + } + + function validate(node, key, val) { + if (vals.indexOf(val) < 0) { + throw new TypeError("Property " + key + " expected value to be one of " + (0, _stringify2.default)(vals) + " but got " + (0, _stringify2.default)(val)); + } + } + + validate.oneOf = vals; + + return validate; + } + + function assertNodeType() { + for (var _len2 = arguments.length, types = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + types[_key2] = arguments[_key2]; + } + + function validate(node, key, val) { + var valid = false; + + for (var _iterator = types, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) { + var _ref; + + if (_isArray) { + if (_i >= _iterator.length) break; + _ref = _iterator[_i++]; + } else { + _i = _iterator.next(); + if (_i.done) break; + _ref = _i.value; + } + + var type = _ref; + + if (t.is(type, val)) { + valid = true; + break; + } + } + + if (!valid) { + throw new TypeError("Property " + key + " of " + node.type + " expected node to be of a type " + (0, _stringify2.default)(types) + " " + ("but instead got " + (0, _stringify2.default)(val && val.type))); + } + } + + validate.oneOfNodeTypes = types; + + return validate; + } + + function assertNodeOrValueType() { + for (var _len3 = arguments.length, types = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + types[_key3] = arguments[_key3]; + } + + function validate(node, key, val) { + var valid = false; + + for (var _iterator2 = types, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : (0, _getIterator3.default)(_iterator2);;) { + var _ref2; + + if (_isArray2) { + if (_i2 >= _iterator2.length) break; + _ref2 = _iterator2[_i2++]; + } else { + _i2 = _iterator2.next(); + if (_i2.done) break; + _ref2 = _i2.value; + } + + var type = _ref2; + + if (getType(val) === type || t.is(type, val)) { + valid = true; + break; + } + } + + if (!valid) { + throw new TypeError("Property " + key + " of " + node.type + " expected node to be of a type " + (0, _stringify2.default)(types) + " " + ("but instead got " + (0, _stringify2.default)(val && val.type))); + } + } + + validate.oneOfNodeOrValueTypes = types; + + return validate; + } + + function assertValueType(type) { + function validate(node, key, val) { + var valid = getType(val) === type; + + if (!valid) { + throw new TypeError("Property " + key + " expected type of " + type + " but got " + getType(val)); + } + } + + validate.type = type; + + return validate; + } + + function chain() { + for (var _len4 = arguments.length, fns = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { + fns[_key4] = arguments[_key4]; + } + + function validate() { + for (var _iterator3 = fns, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : (0, _getIterator3.default)(_iterator3);;) { + var _ref3; + + if (_isArray3) { + if (_i3 >= _iterator3.length) break; + _ref3 = _iterator3[_i3++]; + } else { + _i3 = _iterator3.next(); + if (_i3.done) break; + _ref3 = _i3.value; + } + + var fn = _ref3; + + fn.apply(undefined, arguments); + } + } + validate.chainOf = fns; + return validate; + } + + function defineType(type) { + var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + var inherits = opts.inherits && store[opts.inherits] || {}; + + opts.fields = opts.fields || inherits.fields || {}; + opts.visitor = opts.visitor || inherits.visitor || []; + opts.aliases = opts.aliases || inherits.aliases || []; + opts.builder = opts.builder || inherits.builder || opts.visitor || []; + + if (opts.deprecatedAlias) { + DEPRECATED_KEYS[opts.deprecatedAlias] = type; + } + + for (var _iterator4 = opts.visitor.concat(opts.builder), _isArray4 = Array.isArray(_iterator4), _i4 = 0, _iterator4 = _isArray4 ? _iterator4 : (0, _getIterator3.default)(_iterator4);;) { + var _ref4; + + if (_isArray4) { + if (_i4 >= _iterator4.length) break; + _ref4 = _iterator4[_i4++]; + } else { + _i4 = _iterator4.next(); + if (_i4.done) break; + _ref4 = _i4.value; + } + + var _key5 = _ref4; + + opts.fields[_key5] = opts.fields[_key5] || {}; + } + + for (var key in opts.fields) { + var field = opts.fields[key]; + + if (opts.builder.indexOf(key) === -1) { + field.optional = true; + } + if (field.default === undefined) { + field.default = null; + } else if (!field.validate) { + field.validate = assertValueType(getType(field.default)); + } + } + + VISITOR_KEYS[type] = opts.visitor; + BUILDER_KEYS[type] = opts.builder; + NODE_FIELDS[type] = opts.fields; + ALIAS_KEYS[type] = opts.aliases; + + store[type] = opts; + } + + var store = {}; + +/***/ }), +/* 27 */ +/***/ (function(module, exports) { + + "use strict"; + + var hasOwnProperty = {}.hasOwnProperty; + module.exports = function (it, key) { + return hasOwnProperty.call(it, key); + }; + +/***/ }), +/* 28 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var dP = __webpack_require__(23), + createDesc = __webpack_require__(92); + module.exports = __webpack_require__(20) ? function (object, key, value) { + return dP.f(object, key, createDesc(1, value)); + } : function (object, key, value) { + object[key] = value; + return object; + }; + +/***/ }), +/* 29 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var _Symbol = __webpack_require__(44), + getRawTag = __webpack_require__(525), + objectToString = __webpack_require__(550); + + /** `Object#toString` result references. */ + var nullTag = '[object Null]', + undefinedTag = '[object Undefined]'; + + /** Built-in value references. */ + var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined; + + /** + * The base implementation of `getTag` without fallbacks for buggy environments. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ + function baseGetTag(value) { + if (value == null) { + return value === undefined ? undefinedTag : nullTag; + } + return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value); + } + + module.exports = baseGetTag; + +/***/ }), +/* 30 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var assignValue = __webpack_require__(158), + baseAssignValue = __webpack_require__(159); + + /** + * Copies properties of `source` to `object`. + * + * @private + * @param {Object} source The object to copy properties from. + * @param {Array} props The property identifiers to copy. + * @param {Object} [object={}] The object to copy properties to. + * @param {Function} [customizer] The function to customize copied values. + * @returns {Object} Returns `object`. + */ + function copyObject(source, props, object, customizer) { + var isNew = !object; + object || (object = {}); + + var index = -1, + length = props.length; + + while (++index < length) { + var key = props[index]; + + var newValue = customizer ? customizer(object[key], source[key], key, object, source) : undefined; + + if (newValue === undefined) { + newValue = source[key]; + } + if (isNew) { + baseAssignValue(object, key, newValue); + } else { + assignValue(object, key, newValue); + } + } + return object; + } + + module.exports = copyObject; + +/***/ }), +/* 31 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var arrayLikeKeys = __webpack_require__(240), + baseKeys = __webpack_require__(491), + isArrayLike = __webpack_require__(24); + + /** + * Creates an array of the own enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. See the + * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) + * for more details. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keys(new Foo); + * // => ['a', 'b'] (iteration order is not guaranteed) + * + * _.keys('hi'); + * // => ['0', '1'] + */ + function keys(object) { + return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); + } + + module.exports = keys; + +/***/ }), +/* 32 */ +/***/ (function(module, exports) { + + "use strict"; + + module.exports = { + filename: { + type: "filename", + description: "filename to use when reading from stdin - this will be used in source-maps, errors etc", + default: "unknown", + shorthand: "f" + }, + + filenameRelative: { + hidden: true, + type: "string" + }, + + inputSourceMap: { + hidden: true + }, + + env: { + hidden: true, + default: {} + }, + + mode: { + description: "", + hidden: true + }, + + retainLines: { + type: "boolean", + default: false, + description: "retain line numbers - will result in really ugly code" + }, + + highlightCode: { + description: "enable/disable ANSI syntax highlighting of code frames (on by default)", + type: "boolean", + default: true + }, + + suppressDeprecationMessages: { + type: "boolean", + default: false, + hidden: true + }, + + presets: { + type: "list", + description: "", + default: [] + }, + + plugins: { + type: "list", + default: [], + description: "" + }, + + ignore: { + type: "list", + description: "list of glob paths to **not** compile", + default: [] + }, + + only: { + type: "list", + description: "list of glob paths to **only** compile" + }, + + code: { + hidden: true, + default: true, + type: "boolean" + }, + + metadata: { + hidden: true, + default: true, + type: "boolean" + }, + + ast: { + hidden: true, + default: true, + type: "boolean" + }, + + extends: { + type: "string", + hidden: true + }, + + comments: { + type: "boolean", + default: true, + description: "write comments to generated output (true by default)" + }, + + shouldPrintComment: { + hidden: true, + description: "optional callback to control whether a comment should be inserted, when this is used the comments option is ignored" + }, + + wrapPluginVisitorMethod: { + hidden: true, + description: "optional callback to wrap all visitor methods" + }, + + compact: { + type: "booleanString", + default: "auto", + description: "do not include superfluous whitespace characters and line terminators [true|false|auto]" + }, + + minified: { + type: "boolean", + default: false, + description: "save as much bytes when printing [true|false]" + }, + + sourceMap: { + alias: "sourceMaps", + hidden: true + }, + + sourceMaps: { + type: "booleanString", + description: "[true|false|inline]", + default: false, + shorthand: "s" + }, + + sourceMapTarget: { + type: "string", + description: "set `file` on returned source map" + }, + + sourceFileName: { + type: "string", + description: "set `sources[0]` on returned source map" + }, + + sourceRoot: { + type: "filename", + description: "the root from which all sources are relative" + }, + + babelrc: { + description: "Whether or not to look up .babelrc and .babelignore files", + type: "boolean", + default: true + }, + + sourceType: { + description: "", + default: "module" + }, + + auxiliaryCommentBefore: { + type: "string", + description: "print a comment before any injected non-user code" + }, + + auxiliaryCommentAfter: { + type: "string", + description: "print a comment after any injected non-user code" + }, + + resolveModuleSource: { + hidden: true + }, + + getModuleId: { + hidden: true + }, + + moduleRoot: { + type: "filename", + description: "optional prefix for the AMD module formatter that will be prepend to the filename on module definitions" + }, + + moduleIds: { + type: "boolean", + default: false, + shorthand: "M", + description: "insert an explicit id for modules" + }, + + moduleId: { + description: "specify a custom name for module ids", + type: "string" + }, + + passPerPreset: { + description: "Whether to spawn a traversal pass per a preset. By default all presets are merged.", + type: "boolean", + default: false, + hidden: true + }, + + parserOpts: { + description: "Options to pass into the parser, or to change parsers (parserOpts.parser)", + default: false + }, + + generatorOpts: { + description: "Options to pass into the generator, or to change generators (generatorOpts.generator)", + default: false + } + }; + +/***/ }), +/* 33 */ +/***/ (function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(process) {"use strict"; + + exports.__esModule = true; + + var _objectWithoutProperties2 = __webpack_require__(362); + + var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2); + + var _stringify = __webpack_require__(34); + + var _stringify2 = _interopRequireDefault(_stringify); + + var _assign = __webpack_require__(85); + + var _assign2 = _interopRequireDefault(_assign); + + var _getIterator2 = __webpack_require__(2); + + var _getIterator3 = _interopRequireDefault(_getIterator2); + + var _typeof2 = __webpack_require__(11); + + var _typeof3 = _interopRequireDefault(_typeof2); + + var _classCallCheck2 = __webpack_require__(3); + + var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); + + var _node = __webpack_require__(178); + + var context = _interopRequireWildcard(_node); + + var _plugin2 = __webpack_require__(63); + + var _plugin3 = _interopRequireDefault(_plugin2); + + var _babelMessages = __webpack_require__(18); + + var messages = _interopRequireWildcard(_babelMessages); + + var _index = __webpack_require__(51); + + var _resolvePlugin = __webpack_require__(180); + + var _resolvePlugin2 = _interopRequireDefault(_resolvePlugin); + + var _resolvePreset = __webpack_require__(181); + + var _resolvePreset2 = _interopRequireDefault(_resolvePreset); + + var _cloneDeepWith = __webpack_require__(566); + + var _cloneDeepWith2 = _interopRequireDefault(_cloneDeepWith); + + var _clone = __webpack_require__(109); + + var _clone2 = _interopRequireDefault(_clone); + + var _merge = __webpack_require__(289); + + var _merge2 = _interopRequireDefault(_merge); + + var _config2 = __webpack_require__(32); + + var _config3 = _interopRequireDefault(_config2); + + var _removed = __webpack_require__(53); + + var _removed2 = _interopRequireDefault(_removed); + + var _buildConfigChain = __webpack_require__(50); + + var _buildConfigChain2 = _interopRequireDefault(_buildConfigChain); + + var _path = __webpack_require__(17); + + var _path2 = _interopRequireDefault(_path); + + function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } else { + var newObj = {};if (obj != null) { + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; + } + }newObj.default = obj;return newObj; + } + } + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + var OptionManager = function () { + function OptionManager(log) { + (0, _classCallCheck3.default)(this, OptionManager); + + this.resolvedConfigs = []; + this.options = OptionManager.createBareOptions(); + this.log = log; + } + + OptionManager.memoisePluginContainer = function memoisePluginContainer(fn, loc, i, alias) { + for (var _iterator = OptionManager.memoisedPlugins, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) { + var _ref; + + if (_isArray) { + if (_i >= _iterator.length) break; + _ref = _iterator[_i++]; + } else { + _i = _iterator.next(); + if (_i.done) break; + _ref = _i.value; + } + + var cache = _ref; + + if (cache.container === fn) return cache.plugin; + } + + var obj = void 0; + + if (typeof fn === "function") { + obj = fn(context); + } else { + obj = fn; + } + + if ((typeof obj === "undefined" ? "undefined" : (0, _typeof3.default)(obj)) === "object") { + var _plugin = new _plugin3.default(obj, alias); + OptionManager.memoisedPlugins.push({ + container: fn, + plugin: _plugin + }); + return _plugin; + } else { + throw new TypeError(messages.get("pluginNotObject", loc, i, typeof obj === "undefined" ? "undefined" : (0, _typeof3.default)(obj)) + loc + i); + } + }; + + OptionManager.createBareOptions = function createBareOptions() { + var opts = {}; + + for (var _key in _config3.default) { + var opt = _config3.default[_key]; + opts[_key] = (0, _clone2.default)(opt.default); + } + + return opts; + }; + + OptionManager.normalisePlugin = function normalisePlugin(plugin, loc, i, alias) { + plugin = plugin.__esModule ? plugin.default : plugin; + + if (!(plugin instanceof _plugin3.default)) { + if (typeof plugin === "function" || (typeof plugin === "undefined" ? "undefined" : (0, _typeof3.default)(plugin)) === "object") { + plugin = OptionManager.memoisePluginContainer(plugin, loc, i, alias); + } else { + throw new TypeError(messages.get("pluginNotFunction", loc, i, typeof plugin === "undefined" ? "undefined" : (0, _typeof3.default)(plugin))); + } + } + + plugin.init(loc, i); + + return plugin; + }; + + OptionManager.normalisePlugins = function normalisePlugins(loc, dirname, plugins) { + return plugins.map(function (val, i) { + var plugin = void 0, + options = void 0; + + if (!val) { + throw new TypeError("Falsy value found in plugins"); + } + + if (Array.isArray(val)) { + plugin = val[0]; + options = val[1]; + } else { + plugin = val; + } + + var alias = typeof plugin === "string" ? plugin : loc + "$" + i; + + if (typeof plugin === "string") { + var pluginLoc = (0, _resolvePlugin2.default)(plugin, dirname); + if (pluginLoc) { + plugin = __webpack_require__(175)(pluginLoc); + } else { + throw new ReferenceError(messages.get("pluginUnknown", plugin, loc, i, dirname)); + } + } + + plugin = OptionManager.normalisePlugin(plugin, loc, i, alias); + + return [plugin, options]; + }); + }; + + OptionManager.prototype.mergeOptions = function mergeOptions(_ref2) { + var _this = this; + + var rawOpts = _ref2.options, + extendingOpts = _ref2.extending, + alias = _ref2.alias, + loc = _ref2.loc, + dirname = _ref2.dirname; + + alias = alias || "foreign"; + if (!rawOpts) return; + + if ((typeof rawOpts === "undefined" ? "undefined" : (0, _typeof3.default)(rawOpts)) !== "object" || Array.isArray(rawOpts)) { + this.log.error("Invalid options type for " + alias, TypeError); + } + + var opts = (0, _cloneDeepWith2.default)(rawOpts, function (val) { + if (val instanceof _plugin3.default) { + return val; + } + }); + + dirname = dirname || process.cwd(); + loc = loc || alias; + + for (var _key2 in opts) { + var option = _config3.default[_key2]; + + if (!option && this.log) { + if (_removed2.default[_key2]) { + this.log.error("Using removed Babel 5 option: " + alias + "." + _key2 + " - " + _removed2.default[_key2].message, ReferenceError); + } else { + var unknownOptErr = "Unknown option: " + alias + "." + _key2 + ". Check out http://babeljs.io/docs/usage/options/ for more information about options."; + var presetConfigErr = "A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example:\n\nInvalid:\n `{ presets: [{option: value}] }`\nValid:\n `{ presets: [['presetName', {option: value}]] }`\n\nFor more detailed information on preset configuration, please see http://babeljs.io/docs/plugins/#pluginpresets-options."; + + this.log.error(unknownOptErr + "\n\n" + presetConfigErr, ReferenceError); + } + } + } + + (0, _index.normaliseOptions)(opts); + + if (opts.plugins) { + opts.plugins = OptionManager.normalisePlugins(loc, dirname, opts.plugins); + } + + if (opts.presets) { + if (opts.passPerPreset) { + opts.presets = this.resolvePresets(opts.presets, dirname, function (preset, presetLoc) { + _this.mergeOptions({ + options: preset, + extending: preset, + alias: presetLoc, + loc: presetLoc, + dirname: dirname + }); + }); + } else { + this.mergePresets(opts.presets, dirname); + delete opts.presets; + } + } + + if (rawOpts === extendingOpts) { + (0, _assign2.default)(extendingOpts, opts); + } else { + (0, _merge2.default)(extendingOpts || this.options, opts); + } + }; + + OptionManager.prototype.mergePresets = function mergePresets(presets, dirname) { + var _this2 = this; + + this.resolvePresets(presets, dirname, function (presetOpts, presetLoc) { + _this2.mergeOptions({ + options: presetOpts, + alias: presetLoc, + loc: presetLoc, + dirname: _path2.default.dirname(presetLoc || "") + }); + }); + }; + + OptionManager.prototype.resolvePresets = function resolvePresets(presets, dirname, onResolve) { + return presets.map(function (val) { + var options = void 0; + if (Array.isArray(val)) { + if (val.length > 2) { + throw new Error("Unexpected extra options " + (0, _stringify2.default)(val.slice(2)) + " passed to preset."); + } + + var _val = val; + val = _val[0]; + options = _val[1]; + } + + var presetLoc = void 0; + try { + if (typeof val === "string") { + presetLoc = (0, _resolvePreset2.default)(val, dirname); + + if (!presetLoc) { + throw new Error("Couldn't find preset " + (0, _stringify2.default)(val) + " relative to directory " + (0, _stringify2.default)(dirname)); + } + + val = __webpack_require__(175)(presetLoc); + } + + if ((typeof val === "undefined" ? "undefined" : (0, _typeof3.default)(val)) === "object" && val.__esModule) { + if (val.default) { + val = val.default; + } else { + var _val2 = val, + __esModule = _val2.__esModule, + rest = (0, _objectWithoutProperties3.default)(_val2, ["__esModule"]); + + val = rest; + } + } + + if ((typeof val === "undefined" ? "undefined" : (0, _typeof3.default)(val)) === "object" && val.buildPreset) val = val.buildPreset; + + if (typeof val !== "function" && options !== undefined) { + throw new Error("Options " + (0, _stringify2.default)(options) + " passed to " + (presetLoc || "a preset") + " which does not accept options."); + } + + if (typeof val === "function") val = val(context, options, { dirname: dirname }); + + if ((typeof val === "undefined" ? "undefined" : (0, _typeof3.default)(val)) !== "object") { + throw new Error("Unsupported preset format: " + val + "."); + } + + onResolve && onResolve(val, presetLoc); + } catch (e) { + if (presetLoc) { + e.message += " (While processing preset: " + (0, _stringify2.default)(presetLoc) + ")"; + } + throw e; + } + return val; + }); + }; + + OptionManager.prototype.normaliseOptions = function normaliseOptions() { + var opts = this.options; + + for (var _key3 in _config3.default) { + var option = _config3.default[_key3]; + var val = opts[_key3]; + + if (!val && option.optional) continue; + + if (option.alias) { + opts[option.alias] = opts[option.alias] || val; + } else { + opts[_key3] = val; + } + } + }; + + OptionManager.prototype.init = function init() { + var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + for (var _iterator2 = (0, _buildConfigChain2.default)(opts, this.log), _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : (0, _getIterator3.default)(_iterator2);;) { + var _ref3; + + if (_isArray2) { + if (_i2 >= _iterator2.length) break; + _ref3 = _iterator2[_i2++]; + } else { + _i2 = _iterator2.next(); + if (_i2.done) break; + _ref3 = _i2.value; + } + + var _config = _ref3; + + this.mergeOptions(_config); + } + + this.normaliseOptions(opts); + + return this.options; + }; + + return OptionManager; + }(); + + exports.default = OptionManager; + + OptionManager.memoisedPlugins = []; + module.exports = exports["default"]; + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8))) + +/***/ }), +/* 34 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + module.exports = { "default": __webpack_require__(401), __esModule: true }; + +/***/ }), +/* 35 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + exports.__esModule = true; + + var _getIterator2 = __webpack_require__(2); + + var _getIterator3 = _interopRequireDefault(_getIterator2); + + var _classCallCheck2 = __webpack_require__(3); + + var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); + + var _virtualTypes = __webpack_require__(220); + + var virtualTypes = _interopRequireWildcard(_virtualTypes); + + var _debug2 = __webpack_require__(234); + + var _debug3 = _interopRequireDefault(_debug2); + + var _invariant = __webpack_require__(457); + + var _invariant2 = _interopRequireDefault(_invariant); + + var _index = __webpack_require__(7); + + var _index2 = _interopRequireDefault(_index); + + var _assign = __webpack_require__(170); + + var _assign2 = _interopRequireDefault(_assign); + + var _scope = __webpack_require__(133); + + var _scope2 = _interopRequireDefault(_scope); + + var _babelTypes = __webpack_require__(1); + + var t = _interopRequireWildcard(_babelTypes); + + var _cache = __webpack_require__(86); + + function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } else { + var newObj = {};if (obj != null) { + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; + } + }newObj.default = obj;return newObj; + } + } + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + var _debug = (0, _debug3.default)("babel"); + + var NodePath = function () { + function NodePath(hub, parent) { + (0, _classCallCheck3.default)(this, NodePath); + + this.parent = parent; + this.hub = hub; + this.contexts = []; + this.data = {}; + this.shouldSkip = false; + this.shouldStop = false; + this.removed = false; + this.state = null; + this.opts = null; + this.skipKeys = null; + this.parentPath = null; + this.context = null; + this.container = null; + this.listKey = null; + this.inList = false; + this.parentKey = null; + this.key = null; + this.node = null; + this.scope = null; + this.type = null; + this.typeAnnotation = null; + } + + NodePath.get = function get(_ref) { + var hub = _ref.hub, + parentPath = _ref.parentPath, + parent = _ref.parent, + container = _ref.container, + listKey = _ref.listKey, + key = _ref.key; + + if (!hub && parentPath) { + hub = parentPath.hub; + } + + (0, _invariant2.default)(parent, "To get a node path the parent needs to exist"); + + var targetNode = container[key]; + + var paths = _cache.path.get(parent) || []; + if (!_cache.path.has(parent)) { + _cache.path.set(parent, paths); + } + + var path = void 0; + + for (var i = 0; i < paths.length; i++) { + var pathCheck = paths[i]; + if (pathCheck.node === targetNode) { + path = pathCheck; + break; + } + } + + if (!path) { + path = new NodePath(hub, parent); + paths.push(path); + } + + path.setup(parentPath, container, listKey, key); + + return path; + }; + + NodePath.prototype.getScope = function getScope(scope) { + var ourScope = scope; + + if (this.isScope()) { + ourScope = new _scope2.default(this, scope); + } + + return ourScope; + }; + + NodePath.prototype.setData = function setData(key, val) { + return this.data[key] = val; + }; + + NodePath.prototype.getData = function getData(key, def) { + var val = this.data[key]; + if (!val && def) val = this.data[key] = def; + return val; + }; + + NodePath.prototype.buildCodeFrameError = function buildCodeFrameError(msg) { + var Error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : SyntaxError; + + return this.hub.file.buildCodeFrameError(this.node, msg, Error); + }; + + NodePath.prototype.traverse = function traverse(visitor, state) { + (0, _index2.default)(this.node, visitor, this.scope, state, this); + }; + + NodePath.prototype.mark = function mark(type, message) { + this.hub.file.metadata.marked.push({ + type: type, + message: message, + loc: this.node.loc + }); + }; + + NodePath.prototype.set = function set(key, node) { + t.validate(this.node, key, node); + this.node[key] = node; + }; + + NodePath.prototype.getPathLocation = function getPathLocation() { + var parts = []; + var path = this; + do { + var key = path.key; + if (path.inList) key = path.listKey + "[" + key + "]"; + parts.unshift(key); + } while (path = path.parentPath); + return parts.join("."); + }; + + NodePath.prototype.debug = function debug(buildMessage) { + if (!_debug.enabled) return; + _debug(this.getPathLocation() + " " + this.type + ": " + buildMessage()); + }; + + return NodePath; + }(); + + exports.default = NodePath; + + (0, _assign2.default)(NodePath.prototype, __webpack_require__(364)); + (0, _assign2.default)(NodePath.prototype, __webpack_require__(370)); + (0, _assign2.default)(NodePath.prototype, __webpack_require__(378)); + (0, _assign2.default)(NodePath.prototype, __webpack_require__(368)); + (0, _assign2.default)(NodePath.prototype, __webpack_require__(367)); + (0, _assign2.default)(NodePath.prototype, __webpack_require__(373)); + (0, _assign2.default)(NodePath.prototype, __webpack_require__(366)); + (0, _assign2.default)(NodePath.prototype, __webpack_require__(377)); + (0, _assign2.default)(NodePath.prototype, __webpack_require__(376)); + (0, _assign2.default)(NodePath.prototype, __webpack_require__(369)); + (0, _assign2.default)(NodePath.prototype, __webpack_require__(365)); + + var _loop2 = function _loop2() { + if (_isArray) { + if (_i >= _iterator.length) return "break"; + _ref2 = _iterator[_i++]; + } else { + _i = _iterator.next(); + if (_i.done) return "break"; + _ref2 = _i.value; + } + + var type = _ref2; + + var typeKey = "is" + type; + NodePath.prototype[typeKey] = function (opts) { + return t[typeKey](this.node, opts); + }; + + NodePath.prototype["assert" + type] = function (opts) { + if (!this[typeKey](opts)) { + throw new TypeError("Expected node path of type " + type); + } + }; + }; + + for (var _iterator = t.TYPES, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) { + var _ref2; + + var _ret2 = _loop2(); + + if (_ret2 === "break") break; + } + + var _loop = function _loop(type) { + if (type[0] === "_") return "continue"; + if (t.TYPES.indexOf(type) < 0) t.TYPES.push(type); + + var virtualType = virtualTypes[type]; + + NodePath.prototype["is" + type] = function (opts) { + return virtualType.checkPath(this, opts); + }; + }; + + for (var type in virtualTypes) { + var _ret = _loop(type); + + if (_ret === "continue") continue; + } + module.exports = exports["default"]; + +/***/ }), +/* 36 */ +/***/ (function(module, exports) { + + "use strict"; + + module.exports = function (exec) { + try { + return !!exec(); + } catch (e) { + return true; + } + }; + +/***/ }), +/* 37 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + // to indexed object, toObject with fallback for non-array-like ES3 strings + var IObject = __webpack_require__(140), + defined = __webpack_require__(88); + module.exports = function (it) { + return IObject(defined(it)); + }; + +/***/ }), +/* 38 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var baseIsNative = __webpack_require__(488), + getValue = __webpack_require__(526); + + /** + * Gets the native function at `key` of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the method to get. + * @returns {*} Returns the function if it's native, else `undefined`. + */ + function getNative(object, key) { + var value = getValue(object, key); + return baseIsNative(value) ? value : undefined; + } + + module.exports = getNative; + +/***/ }), +/* 39 */ +/***/ (function(module, exports) { + + "use strict"; + + module.exports = function (module) { + if (!module.webpackPolyfill) { + module.deprecate = function () {}; + module.paths = []; + // module.parent = undefined by default + module.children = []; + module.webpackPolyfill = 1; + } + return module; + }; + +/***/ }), +/* 40 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + exports.__esModule = true; + + exports.default = function (_ref) { + var node = _ref.node, + parent = _ref.parent, + scope = _ref.scope, + id = _ref.id; + + if (node.id) return; + + if ((t.isObjectProperty(parent) || t.isObjectMethod(parent, { kind: "method" })) && (!parent.computed || t.isLiteral(parent.key))) { + id = parent.key; + } else if (t.isVariableDeclarator(parent)) { + id = parent.id; + + if (t.isIdentifier(id)) { + var binding = scope.parent.getBinding(id.name); + if (binding && binding.constant && scope.getBinding(id.name) === binding) { + node.id = id; + node.id[t.NOT_LOCAL_BINDING] = true; + return; + } + } + } else if (t.isAssignmentExpression(parent)) { + id = parent.left; + } else if (!id) { + return; + } + + var name = void 0; + if (id && t.isLiteral(id)) { + name = id.value; + } else if (id && t.isIdentifier(id)) { + name = id.name; + } else { + return; + } + + name = t.toBindingIdentifierName(name); + id = t.identifier(name); + + id[t.NOT_LOCAL_BINDING] = true; + + var state = visit(node, name, scope); + return wrap(state, node, id, scope) || node; + }; + + var _babelHelperGetFunctionArity = __webpack_require__(185); + + var _babelHelperGetFunctionArity2 = _interopRequireDefault(_babelHelperGetFunctionArity); + + var _babelTemplate = __webpack_require__(4); + + var _babelTemplate2 = _interopRequireDefault(_babelTemplate); + + var _babelTypes = __webpack_require__(1); + + var t = _interopRequireWildcard(_babelTypes); + + function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } else { + var newObj = {};if (obj != null) { + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; + } + }newObj.default = obj;return newObj; + } + } + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + var buildPropertyMethodAssignmentWrapper = (0, _babelTemplate2.default)("\n (function (FUNCTION_KEY) {\n function FUNCTION_ID() {\n return FUNCTION_KEY.apply(this, arguments);\n }\n\n FUNCTION_ID.toString = function () {\n return FUNCTION_KEY.toString();\n }\n\n return FUNCTION_ID;\n })(FUNCTION)\n"); + + var buildGeneratorPropertyMethodAssignmentWrapper = (0, _babelTemplate2.default)("\n (function (FUNCTION_KEY) {\n function* FUNCTION_ID() {\n return yield* FUNCTION_KEY.apply(this, arguments);\n }\n\n FUNCTION_ID.toString = function () {\n return FUNCTION_KEY.toString();\n };\n\n return FUNCTION_ID;\n })(FUNCTION)\n"); + + var visitor = { + "ReferencedIdentifier|BindingIdentifier": function ReferencedIdentifierBindingIdentifier(path, state) { + if (path.node.name !== state.name) return; + + var localDeclar = path.scope.getBindingIdentifier(state.name); + if (localDeclar !== state.outerDeclar) return; + + state.selfReference = true; + path.stop(); + } + }; + + function wrap(state, method, id, scope) { + if (state.selfReference) { + if (scope.hasBinding(id.name) && !scope.hasGlobal(id.name)) { + scope.rename(id.name); + } else { + if (!t.isFunction(method)) return; + + var build = buildPropertyMethodAssignmentWrapper; + if (method.generator) build = buildGeneratorPropertyMethodAssignmentWrapper; + var _template = build({ + FUNCTION: method, + FUNCTION_ID: id, + FUNCTION_KEY: scope.generateUidIdentifier(id.name) + }).expression; + _template.callee._skipModulesRemap = true; + + var params = _template.callee.body.body[0].params; + for (var i = 0, len = (0, _babelHelperGetFunctionArity2.default)(method); i < len; i++) { + params.push(scope.generateUidIdentifier("x")); + } + + return _template; + } + } + + method.id = id; + scope.getProgramParent().references[id.name] = true; + } + + function visit(node, name, scope) { + var state = { + selfAssignment: false, + selfReference: false, + outerDeclar: scope.getBindingIdentifier(name), + references: [], + name: name + }; + + var binding = scope.getOwnBinding(name); + + if (binding) { + if (binding.kind === "param") { + state.selfReference = true; + } else {} + } else if (state.outerDeclar || scope.hasGlobal(name)) { + scope.traverse(node, visitor, state); + } + + return state; + } + + module.exports = exports["default"]; + +/***/ }), +/* 41 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + exports.__esModule = true; + + var _setPrototypeOf = __webpack_require__(357); + + var _setPrototypeOf2 = _interopRequireDefault(_setPrototypeOf); + + var _create = __webpack_require__(9); + + var _create2 = _interopRequireDefault(_create); + + var _typeof2 = __webpack_require__(11); + + var _typeof3 = _interopRequireDefault(_typeof2); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + exports.default = function (subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + (typeof superClass === "undefined" ? "undefined" : (0, _typeof3.default)(superClass))); + } + + subClass.prototype = (0, _create2.default)(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) _setPrototypeOf2.default ? (0, _setPrototypeOf2.default)(subClass, superClass) : subClass.__proto__ = superClass; + }; + +/***/ }), +/* 42 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + exports.__esModule = true; + + var _typeof2 = __webpack_require__(11); + + var _typeof3 = _interopRequireDefault(_typeof2); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + exports.default = function (self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return call && ((typeof call === "undefined" ? "undefined" : (0, _typeof3.default)(call)) === "object" || typeof call === "function") ? call : self; + }; + +/***/ }), +/* 43 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + // 19.1.2.14 / 15.2.3.14 Object.keys(O) + var $keys = __webpack_require__(232), + enumBugKeys = __webpack_require__(139); + + module.exports = Object.keys || function keys(O) { + return $keys(O, enumBugKeys); + }; + +/***/ }), +/* 44 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var root = __webpack_require__(15); + + /** Built-in value references. */ + var _Symbol = root.Symbol; + + module.exports = _Symbol; + +/***/ }), +/* 45 */ +/***/ (function(module, exports) { + + "use strict"; + + /** + * Performs a + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * comparison between two values to determine if they are equivalent. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @example + * + * var object = { 'a': 1 }; + * var other = { 'a': 1 }; + * + * _.eq(object, object); + * // => true + * + * _.eq(object, other); + * // => false + * + * _.eq('a', 'a'); + * // => true + * + * _.eq('a', Object('a')); + * // => false + * + * _.eq(NaN, NaN); + * // => true + */ + function eq(value, other) { + return value === other || value !== value && other !== other; + } + + module.exports = eq; + +/***/ }), +/* 46 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var arrayLikeKeys = __webpack_require__(240), + baseKeysIn = __webpack_require__(492), + isArrayLike = __webpack_require__(24); + + /** + * Creates an array of the own and inherited enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keysIn(new Foo); + * // => ['a', 'b', 'c'] (iteration order is not guaranteed) + */ + function keysIn(object) { + return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); + } + + module.exports = keysIn; + +/***/ }), +/* 47 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var toFinite = __webpack_require__(588); + + /** + * Converts `value` to an integer. + * + * **Note:** This method is loosely based on + * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {number} Returns the converted integer. + * @example + * + * _.toInteger(3.2); + * // => 3 + * + * _.toInteger(Number.MIN_VALUE); + * // => 0 + * + * _.toInteger(Infinity); + * // => 1.7976931348623157e+308 + * + * _.toInteger('3.2'); + * // => 3 + */ + function toInteger(value) { + var result = toFinite(value), + remainder = result % 1; + + return result === result ? remainder ? result - remainder : result : 0; + } + + module.exports = toInteger; + +/***/ }), +/* 48 */ +/***/ (function(module, exports) { + + /* WEBPACK VAR INJECTION */(function(__webpack_amd_options__) {module.exports = __webpack_amd_options__; + + /* WEBPACK VAR INJECTION */}.call(exports, {})) + +/***/ }), +/* 49 */ +/***/ (function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(process) {"use strict"; + + exports.__esModule = true; + exports.File = undefined; + + var _getIterator2 = __webpack_require__(2); + + var _getIterator3 = _interopRequireDefault(_getIterator2); + + var _create = __webpack_require__(9); + + var _create2 = _interopRequireDefault(_create); + + var _assign = __webpack_require__(85); + + var _assign2 = _interopRequireDefault(_assign); + + var _classCallCheck2 = __webpack_require__(3); + + var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); + + var _possibleConstructorReturn2 = __webpack_require__(42); + + var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2); + + var _inherits2 = __webpack_require__(41); + + var _inherits3 = _interopRequireDefault(_inherits2); + + var _babelHelpers = __webpack_require__(190); + + var _babelHelpers2 = _interopRequireDefault(_babelHelpers); + + var _metadata = __webpack_require__(120); + + var metadataVisitor = _interopRequireWildcard(_metadata); + + var _convertSourceMap = __webpack_require__(399); + + var _convertSourceMap2 = _interopRequireDefault(_convertSourceMap); + + var _optionManager = __webpack_require__(33); + + var _optionManager2 = _interopRequireDefault(_optionManager); + + var _pluginPass = __webpack_require__(295); + + var _pluginPass2 = _interopRequireDefault(_pluginPass); + + var _babelTraverse = __webpack_require__(7); + + var _babelTraverse2 = _interopRequireDefault(_babelTraverse); + + var _sourceMap = __webpack_require__(284); + + var _sourceMap2 = _interopRequireDefault(_sourceMap); + + var _babelGenerator = __webpack_require__(182); + + var _babelGenerator2 = _interopRequireDefault(_babelGenerator); + + var _babelCodeFrame = __webpack_require__(177); + + var _babelCodeFrame2 = _interopRequireDefault(_babelCodeFrame); + + var _defaults = __webpack_require__(268); + + var _defaults2 = _interopRequireDefault(_defaults); + + var _logger = __webpack_require__(119); + + var _logger2 = _interopRequireDefault(_logger); + + var _store = __webpack_require__(118); + + var _store2 = _interopRequireDefault(_store); + + var _babylon = __webpack_require__(87); + + var _util = __webpack_require__(121); + + var util = _interopRequireWildcard(_util); + + var _path = __webpack_require__(17); + + var _path2 = _interopRequireDefault(_path); + + var _babelTypes = __webpack_require__(1); + + var t = _interopRequireWildcard(_babelTypes); + + var _resolve = __webpack_require__(117); + + var _resolve2 = _interopRequireDefault(_resolve); + + var _blockHoist = __webpack_require__(292); + + var _blockHoist2 = _interopRequireDefault(_blockHoist); + + var _shadowFunctions = __webpack_require__(293); + + var _shadowFunctions2 = _interopRequireDefault(_shadowFunctions); + + function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } else { + var newObj = {};if (obj != null) { + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; + } + }newObj.default = obj;return newObj; + } + } + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + var shebangRegex = /^#!.*/; + + var INTERNAL_PLUGINS = [[_blockHoist2.default], [_shadowFunctions2.default]]; + + var errorVisitor = { + enter: function enter(path, state) { + var loc = path.node.loc; + if (loc) { + state.loc = loc; + path.stop(); + } + } + }; + + var File = function (_Store) { + (0, _inherits3.default)(File, _Store); + + function File() { + var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + var pipeline = arguments[1]; + (0, _classCallCheck3.default)(this, File); + + var _this = (0, _possibleConstructorReturn3.default)(this, _Store.call(this)); + + _this.pipeline = pipeline; + + _this.log = new _logger2.default(_this, opts.filename || "unknown"); + _this.opts = _this.initOptions(opts); + + _this.parserOpts = { + sourceType: _this.opts.sourceType, + sourceFileName: _this.opts.filename, + plugins: [] + }; + + _this.pluginVisitors = []; + _this.pluginPasses = []; + + _this.buildPluginsForOptions(_this.opts); + + if (_this.opts.passPerPreset) { + _this.perPresetOpts = []; + _this.opts.presets.forEach(function (presetOpts) { + var perPresetOpts = (0, _assign2.default)((0, _create2.default)(_this.opts), presetOpts); + _this.perPresetOpts.push(perPresetOpts); + _this.buildPluginsForOptions(perPresetOpts); + }); + } + + _this.metadata = { + usedHelpers: [], + marked: [], + modules: { + imports: [], + exports: { + exported: [], + specifiers: [] + } + } + }; + + _this.dynamicImportTypes = {}; + _this.dynamicImportIds = {}; + _this.dynamicImports = []; + _this.declarations = {}; + _this.usedHelpers = {}; + + _this.path = null; + _this.ast = {}; + + _this.code = ""; + _this.shebang = ""; + + _this.hub = new _babelTraverse.Hub(_this); + return _this; + } + + File.prototype.getMetadata = function getMetadata() { + var has = false; + for (var _iterator = this.ast.program.body, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) { + var _ref; + + if (_isArray) { + if (_i >= _iterator.length) break; + _ref = _iterator[_i++]; + } else { + _i = _iterator.next(); + if (_i.done) break; + _ref = _i.value; + } + + var node = _ref; + + if (t.isModuleDeclaration(node)) { + has = true; + break; + } + } + if (has) { + this.path.traverse(metadataVisitor, this); + } + }; + + File.prototype.initOptions = function initOptions(opts) { + opts = new _optionManager2.default(this.log, this.pipeline).init(opts); + + if (opts.inputSourceMap) { + opts.sourceMaps = true; + } + + if (opts.moduleId) { + opts.moduleIds = true; + } + + opts.basename = _path2.default.basename(opts.filename, _path2.default.extname(opts.filename)); + + opts.ignore = util.arrayify(opts.ignore, util.regexify); + + if (opts.only) opts.only = util.arrayify(opts.only, util.regexify); + + (0, _defaults2.default)(opts, { + moduleRoot: opts.sourceRoot + }); + + (0, _defaults2.default)(opts, { + sourceRoot: opts.moduleRoot + }); + + (0, _defaults2.default)(opts, { + filenameRelative: opts.filename + }); + + var basenameRelative = _path2.default.basename(opts.filenameRelative); + + (0, _defaults2.default)(opts, { + sourceFileName: basenameRelative, + sourceMapTarget: basenameRelative + }); + + return opts; + }; + + File.prototype.buildPluginsForOptions = function buildPluginsForOptions(opts) { + if (!Array.isArray(opts.plugins)) { + return; + } + + var plugins = opts.plugins.concat(INTERNAL_PLUGINS); + var currentPluginVisitors = []; + var currentPluginPasses = []; + + for (var _iterator2 = plugins, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : (0, _getIterator3.default)(_iterator2);;) { + var _ref2; + + if (_isArray2) { + if (_i2 >= _iterator2.length) break; + _ref2 = _iterator2[_i2++]; + } else { + _i2 = _iterator2.next(); + if (_i2.done) break; + _ref2 = _i2.value; + } + + var ref = _ref2; + var plugin = ref[0], + pluginOpts = ref[1]; + + currentPluginVisitors.push(plugin.visitor); + currentPluginPasses.push(new _pluginPass2.default(this, plugin, pluginOpts)); + + if (plugin.manipulateOptions) { + plugin.manipulateOptions(opts, this.parserOpts, this); + } + } + + this.pluginVisitors.push(currentPluginVisitors); + this.pluginPasses.push(currentPluginPasses); + }; + + File.prototype.getModuleName = function getModuleName() { + var opts = this.opts; + if (!opts.moduleIds) { + return null; + } + + if (opts.moduleId != null && !opts.getModuleId) { + return opts.moduleId; + } + + var filenameRelative = opts.filenameRelative; + var moduleName = ""; + + if (opts.moduleRoot != null) { + moduleName = opts.moduleRoot + "/"; + } + + if (!opts.filenameRelative) { + return moduleName + opts.filename.replace(/^\//, ""); + } + + if (opts.sourceRoot != null) { + var sourceRootRegEx = new RegExp("^" + opts.sourceRoot + "\/?"); + filenameRelative = filenameRelative.replace(sourceRootRegEx, ""); + } + + filenameRelative = filenameRelative.replace(/\.(\w*?)$/, ""); + + moduleName += filenameRelative; + + moduleName = moduleName.replace(/\\/g, "/"); + + if (opts.getModuleId) { + return opts.getModuleId(moduleName) || moduleName; + } else { + return moduleName; + } + }; + + File.prototype.resolveModuleSource = function resolveModuleSource(source) { + var resolveModuleSource = this.opts.resolveModuleSource; + if (resolveModuleSource) source = resolveModuleSource(source, this.opts.filename); + return source; + }; + + File.prototype.addImport = function addImport(source, imported) { + var name = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : imported; + + var alias = source + ":" + imported; + var id = this.dynamicImportIds[alias]; + + if (!id) { + source = this.resolveModuleSource(source); + id = this.dynamicImportIds[alias] = this.scope.generateUidIdentifier(name); + + var specifiers = []; + + if (imported === "*") { + specifiers.push(t.importNamespaceSpecifier(id)); + } else if (imported === "default") { + specifiers.push(t.importDefaultSpecifier(id)); + } else { + specifiers.push(t.importSpecifier(id, t.identifier(imported))); + } + + var declar = t.importDeclaration(specifiers, t.stringLiteral(source)); + declar._blockHoist = 3; + + this.path.unshiftContainer("body", declar); + } + + return id; + }; + + File.prototype.addHelper = function addHelper(name) { + var declar = this.declarations[name]; + if (declar) return declar; + + if (!this.usedHelpers[name]) { + this.metadata.usedHelpers.push(name); + this.usedHelpers[name] = true; + } + + var generator = this.get("helperGenerator"); + var runtime = this.get("helpersNamespace"); + if (generator) { + var res = generator(name); + if (res) return res; + } else if (runtime) { + return t.memberExpression(runtime, t.identifier(name)); + } + + var ref = (0, _babelHelpers2.default)(name); + var uid = this.declarations[name] = this.scope.generateUidIdentifier(name); + + if (t.isFunctionExpression(ref) && !ref.id) { + ref.body._compact = true; + ref._generated = true; + ref.id = uid; + ref.type = "FunctionDeclaration"; + this.path.unshiftContainer("body", ref); + } else { + ref._compact = true; + this.scope.push({ + id: uid, + init: ref, + unique: true + }); + } + + return uid; + }; + + File.prototype.addTemplateObject = function addTemplateObject(helperName, strings, raw) { + var stringIds = raw.elements.map(function (string) { + return string.value; + }); + var name = helperName + "_" + raw.elements.length + "_" + stringIds.join(","); + + var declar = this.declarations[name]; + if (declar) return declar; + + var uid = this.declarations[name] = this.scope.generateUidIdentifier("templateObject"); + + var helperId = this.addHelper(helperName); + var init = t.callExpression(helperId, [strings, raw]); + init._compact = true; + this.scope.push({ + id: uid, + init: init, + _blockHoist: 1.9 }); + return uid; + }; + + File.prototype.buildCodeFrameError = function buildCodeFrameError(node, msg) { + var Error = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : SyntaxError; + + var loc = node && (node.loc || node._loc); + + var err = new Error(msg); + + if (loc) { + err.loc = loc.start; + } else { + (0, _babelTraverse2.default)(node, errorVisitor, this.scope, err); + + err.message += " (This is an error on an internal node. Probably an internal error"; + + if (err.loc) { + err.message += ". Location has been estimated."; + } + + err.message += ")"; + } + + return err; + }; + + File.prototype.mergeSourceMap = function mergeSourceMap(map) { + var inputMap = this.opts.inputSourceMap; + + if (inputMap) { + var inputMapConsumer = new _sourceMap2.default.SourceMapConsumer(inputMap); + var outputMapConsumer = new _sourceMap2.default.SourceMapConsumer(map); + + var mergedGenerator = new _sourceMap2.default.SourceMapGenerator({ + file: inputMapConsumer.file, + sourceRoot: inputMapConsumer.sourceRoot + }); + + var source = outputMapConsumer.sources[0]; + + inputMapConsumer.eachMapping(function (mapping) { + var generatedPosition = outputMapConsumer.generatedPositionFor({ + line: mapping.generatedLine, + column: mapping.generatedColumn, + source: source + }); + if (generatedPosition.column != null) { + mergedGenerator.addMapping({ + source: mapping.source, + + original: mapping.source == null ? null : { + line: mapping.originalLine, + column: mapping.originalColumn + }, + + generated: generatedPosition + }); + } + }); + + var mergedMap = mergedGenerator.toJSON(); + inputMap.mappings = mergedMap.mappings; + return inputMap; + } else { + return map; + } + }; + + File.prototype.parse = function parse(code) { + var parseCode = _babylon.parse; + var parserOpts = this.opts.parserOpts; + + if (parserOpts) { + parserOpts = (0, _assign2.default)({}, this.parserOpts, parserOpts); + + if (parserOpts.parser) { + if (typeof parserOpts.parser === "string") { + var dirname = _path2.default.dirname(this.opts.filename) || process.cwd(); + var parser = (0, _resolve2.default)(parserOpts.parser, dirname); + if (parser) { + parseCode = __webpack_require__(174)(parser).parse; + } else { + throw new Error("Couldn't find parser " + parserOpts.parser + " with \"parse\" method " + ("relative to directory " + dirname)); + } + } else { + parseCode = parserOpts.parser; + } + + parserOpts.parser = { + parse: function parse(source) { + return (0, _babylon.parse)(source, parserOpts); + } + }; + } + } + + this.log.debug("Parse start"); + var ast = parseCode(code, parserOpts || this.parserOpts); + this.log.debug("Parse stop"); + return ast; + }; + + File.prototype._addAst = function _addAst(ast) { + this.path = _babelTraverse.NodePath.get({ + hub: this.hub, + parentPath: null, + parent: ast, + container: ast, + key: "program" + }).setContext(); + this.scope = this.path.scope; + this.ast = ast; + this.getMetadata(); + }; + + File.prototype.addAst = function addAst(ast) { + this.log.debug("Start set AST"); + this._addAst(ast); + this.log.debug("End set AST"); + }; + + File.prototype.transform = function transform() { + for (var i = 0; i < this.pluginPasses.length; i++) { + var pluginPasses = this.pluginPasses[i]; + this.call("pre", pluginPasses); + this.log.debug("Start transform traverse"); + + var visitor = _babelTraverse2.default.visitors.merge(this.pluginVisitors[i], pluginPasses, this.opts.wrapPluginVisitorMethod); + (0, _babelTraverse2.default)(this.ast, visitor, this.scope); + + this.log.debug("End transform traverse"); + this.call("post", pluginPasses); + } + + return this.generate(); + }; + + File.prototype.wrap = function wrap(code, callback) { + code = code + ""; + + try { + if (this.shouldIgnore()) { + return this.makeResult({ code: code, ignored: true }); + } else { + return callback(); + } + } catch (err) { + if (err._babel) { + throw err; + } else { + err._babel = true; + } + + var message = err.message = this.opts.filename + ": " + err.message; + + var loc = err.loc; + if (loc) { + err.codeFrame = (0, _babelCodeFrame2.default)(code, loc.line, loc.column + 1, this.opts); + message += "\n" + err.codeFrame; + } + + if (process.browser) { + err.message = message; + } + + if (err.stack) { + var newStack = err.stack.replace(err.message, message); + err.stack = newStack; + } + + throw err; + } + }; + + File.prototype.addCode = function addCode(code) { + code = (code || "") + ""; + code = this.parseInputSourceMap(code); + this.code = code; + }; + + File.prototype.parseCode = function parseCode() { + this.parseShebang(); + var ast = this.parse(this.code); + this.addAst(ast); + }; + + File.prototype.shouldIgnore = function shouldIgnore() { + var opts = this.opts; + return util.shouldIgnore(opts.filename, opts.ignore, opts.only); + }; + + File.prototype.call = function call(key, pluginPasses) { + for (var _iterator3 = pluginPasses, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : (0, _getIterator3.default)(_iterator3);;) { + var _ref3; + + if (_isArray3) { + if (_i3 >= _iterator3.length) break; + _ref3 = _iterator3[_i3++]; + } else { + _i3 = _iterator3.next(); + if (_i3.done) break; + _ref3 = _i3.value; + } + + var pass = _ref3; + + var plugin = pass.plugin; + var fn = plugin[key]; + if (fn) fn.call(pass, this); + } + }; + + File.prototype.parseInputSourceMap = function parseInputSourceMap(code) { + var opts = this.opts; + + if (opts.inputSourceMap !== false) { + var inputMap = _convertSourceMap2.default.fromSource(code); + if (inputMap) { + opts.inputSourceMap = inputMap.toObject(); + code = _convertSourceMap2.default.removeComments(code); + } + } + + return code; + }; + + File.prototype.parseShebang = function parseShebang() { + var shebangMatch = shebangRegex.exec(this.code); + if (shebangMatch) { + this.shebang = shebangMatch[0]; + this.code = this.code.replace(shebangRegex, ""); + } + }; + + File.prototype.makeResult = function makeResult(_ref4) { + var code = _ref4.code, + map = _ref4.map, + ast = _ref4.ast, + ignored = _ref4.ignored; + + var result = { + metadata: null, + options: this.opts, + ignored: !!ignored, + code: null, + ast: null, + map: map || null + }; + + if (this.opts.code) { + result.code = code; + } + + if (this.opts.ast) { + result.ast = ast; + } + + if (this.opts.metadata) { + result.metadata = this.metadata; + } + + return result; + }; + + File.prototype.generate = function generate() { + var opts = this.opts; + var ast = this.ast; + + var result = { ast: ast }; + if (!opts.code) return this.makeResult(result); + + var gen = _babelGenerator2.default; + if (opts.generatorOpts.generator) { + gen = opts.generatorOpts.generator; + + if (typeof gen === "string") { + var dirname = _path2.default.dirname(this.opts.filename) || process.cwd(); + var generator = (0, _resolve2.default)(gen, dirname); + if (generator) { + gen = __webpack_require__(174)(generator).print; + } else { + throw new Error("Couldn't find generator " + gen + " with \"print\" method relative " + ("to directory " + dirname)); + } + } + } + + this.log.debug("Generation start"); + + var _result = gen(ast, opts.generatorOpts ? (0, _assign2.default)(opts, opts.generatorOpts) : opts, this.code); + result.code = _result.code; + result.map = _result.map; + + this.log.debug("Generation end"); + + if (this.shebang) { + result.code = this.shebang + "\n" + result.code; + } + + if (result.map) { + result.map = this.mergeSourceMap(result.map); + } + + if (opts.sourceMaps === "inline" || opts.sourceMaps === "both") { + result.code += "\n" + _convertSourceMap2.default.fromObject(result.map).toComment(); + } + + if (opts.sourceMaps === "inline") { + result.map = null; + } + + return this.makeResult(result); + }; + + return File; + }(_store2.default); + + exports.default = File; + exports.File = File; + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8))) + +/***/ }), +/* 50 */ +/***/ (function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(process) {"use strict"; + + exports.__esModule = true; + + var _assign = __webpack_require__(85); + + var _assign2 = _interopRequireDefault(_assign); + + var _classCallCheck2 = __webpack_require__(3); + + var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); + + exports.default = buildConfigChain; + + var _resolve = __webpack_require__(117); + + var _resolve2 = _interopRequireDefault(_resolve); + + var _json = __webpack_require__(461); + + var _json2 = _interopRequireDefault(_json); + + var _pathIsAbsolute = __webpack_require__(595); + + var _pathIsAbsolute2 = _interopRequireDefault(_pathIsAbsolute); + + var _path = __webpack_require__(17); + + var _path2 = _interopRequireDefault(_path); + + var _fs = __webpack_require__(115); + + var _fs2 = _interopRequireDefault(_fs); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + var existsCache = {}; + var jsonCache = {}; + + var BABELIGNORE_FILENAME = ".babelignore"; + var BABELRC_FILENAME = ".babelrc"; + var PACKAGE_FILENAME = "package.json"; + + function exists(filename) { + var cached = existsCache[filename]; + if (cached == null) { + return existsCache[filename] = _fs2.default.existsSync(filename); + } else { + return cached; + } + } + + function buildConfigChain() { + var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + var log = arguments[1]; + + var filename = opts.filename; + var builder = new ConfigChainBuilder(log); + + if (opts.babelrc !== false) { + builder.findConfigs(filename); + } + + builder.mergeConfig({ + options: opts, + alias: "base", + dirname: filename && _path2.default.dirname(filename) + }); + + return builder.configs; + } + + var ConfigChainBuilder = function () { + function ConfigChainBuilder(log) { + (0, _classCallCheck3.default)(this, ConfigChainBuilder); + + this.resolvedConfigs = []; + this.configs = []; + this.log = log; + } + + ConfigChainBuilder.prototype.findConfigs = function findConfigs(loc) { + if (!loc) return; + + if (!(0, _pathIsAbsolute2.default)(loc)) { + loc = _path2.default.join(process.cwd(), loc); + } + + var foundConfig = false; + var foundIgnore = false; + + while (loc !== (loc = _path2.default.dirname(loc))) { + if (!foundConfig) { + var configLoc = _path2.default.join(loc, BABELRC_FILENAME); + if (exists(configLoc)) { + this.addConfig(configLoc); + foundConfig = true; + } + + var pkgLoc = _path2.default.join(loc, PACKAGE_FILENAME); + if (!foundConfig && exists(pkgLoc)) { + foundConfig = this.addConfig(pkgLoc, "babel", JSON); + } + } + + if (!foundIgnore) { + var ignoreLoc = _path2.default.join(loc, BABELIGNORE_FILENAME); + if (exists(ignoreLoc)) { + this.addIgnoreConfig(ignoreLoc); + foundIgnore = true; + } + } + + if (foundIgnore && foundConfig) return; + } + }; + + ConfigChainBuilder.prototype.addIgnoreConfig = function addIgnoreConfig(loc) { + var file = _fs2.default.readFileSync(loc, "utf8"); + var lines = file.split("\n"); + + lines = lines.map(function (line) { + return line.replace(/#(.*?)$/, "").trim(); + }).filter(function (line) { + return !!line; + }); + + if (lines.length) { + this.mergeConfig({ + options: { ignore: lines }, + alias: loc, + dirname: _path2.default.dirname(loc) + }); + } + }; + + ConfigChainBuilder.prototype.addConfig = function addConfig(loc, key) { + var json = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _json2.default; + + if (this.resolvedConfigs.indexOf(loc) >= 0) { + return false; + } + + this.resolvedConfigs.push(loc); + + var content = _fs2.default.readFileSync(loc, "utf8"); + var options = void 0; + + try { + options = jsonCache[content] = jsonCache[content] || json.parse(content); + if (key) options = options[key]; + } catch (err) { + err.message = loc + ": Error while parsing JSON - " + err.message; + throw err; + } + + this.mergeConfig({ + options: options, + alias: loc, + dirname: _path2.default.dirname(loc) + }); + + return !!options; + }; + + ConfigChainBuilder.prototype.mergeConfig = function mergeConfig(_ref) { + var options = _ref.options, + alias = _ref.alias, + loc = _ref.loc, + dirname = _ref.dirname; + + if (!options) { + return false; + } + + options = (0, _assign2.default)({}, options); + + dirname = dirname || process.cwd(); + loc = loc || alias; + + if (options.extends) { + var extendsLoc = (0, _resolve2.default)(options.extends, dirname); + if (extendsLoc) { + this.addConfig(extendsLoc); + } else { + if (this.log) this.log.error("Couldn't resolve extends clause of " + options.extends + " in " + alias); + } + delete options.extends; + } + + this.configs.push({ + options: options, + alias: alias, + loc: loc, + dirname: dirname + }); + + var envOpts = void 0; + var envKey = process.env.BABEL_ENV || ("production") || "development"; + if (options.env) { + envOpts = options.env[envKey]; + delete options.env; + } + + this.mergeConfig({ + options: envOpts, + alias: alias + ".env." + envKey, + dirname: dirname + }); + }; + + return ConfigChainBuilder; + }(); + + module.exports = exports["default"]; + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8))) + +/***/ }), +/* 51 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + exports.__esModule = true; + exports.config = undefined; + exports.normaliseOptions = normaliseOptions; + + var _parsers = __webpack_require__(52); + + var parsers = _interopRequireWildcard(_parsers); + + var _config = __webpack_require__(32); + + var _config2 = _interopRequireDefault(_config); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } else { + var newObj = {};if (obj != null) { + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; + } + }newObj.default = obj;return newObj; + } + } + + exports.config = _config2.default; + function normaliseOptions() { + var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + for (var key in options) { + var val = options[key]; + if (val == null) continue; + + var opt = _config2.default[key]; + if (opt && opt.alias) opt = _config2.default[opt.alias]; + if (!opt) continue; + + var parser = parsers[opt.type]; + if (parser) val = parser(val); + + options[key] = val; + } + + return options; + } + +/***/ }), +/* 52 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + exports.__esModule = true; + exports.filename = undefined; + exports.boolean = boolean; + exports.booleanString = booleanString; + exports.list = list; + + var _slash = __webpack_require__(280); + + var _slash2 = _interopRequireDefault(_slash); + + var _util = __webpack_require__(121); + + var util = _interopRequireWildcard(_util); + + function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } else { + var newObj = {};if (obj != null) { + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; + } + }newObj.default = obj;return newObj; + } + } + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + var filename = exports.filename = _slash2.default; + + function boolean(val) { + return !!val; + } + + function booleanString(val) { + return util.booleanify(val); + } + + function list(val) { + return util.list(val); + } + +/***/ }), +/* 53 */ +/***/ (function(module, exports) { + + "use strict"; + + module.exports = { + "auxiliaryComment": { + "message": "Use `auxiliaryCommentBefore` or `auxiliaryCommentAfter`" + }, + "blacklist": { + "message": "Put the specific transforms you want in the `plugins` option" + }, + "breakConfig": { + "message": "This is not a necessary option in Babel 6" + }, + "experimental": { + "message": "Put the specific transforms you want in the `plugins` option" + }, + "externalHelpers": { + "message": "Use the `external-helpers` plugin instead. Check out http://babeljs.io/docs/plugins/external-helpers/" + }, + "extra": { + "message": "" + }, + "jsxPragma": { + "message": "use the `pragma` option in the `react-jsx` plugin . Check out http://babeljs.io/docs/plugins/transform-react-jsx/" + }, + + "loose": { + "message": "Specify the `loose` option for the relevant plugin you are using or use a preset that sets the option." + }, + "metadataUsedHelpers": { + "message": "Not required anymore as this is enabled by default" + }, + "modules": { + "message": "Use the corresponding module transform plugin in the `plugins` option. Check out http://babeljs.io/docs/plugins/#modules" + }, + "nonStandard": { + "message": "Use the `react-jsx` and `flow-strip-types` plugins to support JSX and Flow. Also check out the react preset http://babeljs.io/docs/plugins/preset-react/" + }, + "optional": { + "message": "Put the specific transforms you want in the `plugins` option" + }, + "sourceMapName": { + "message": "Use the `sourceMapTarget` option" + }, + "stage": { + "message": "Check out the corresponding stage-x presets http://babeljs.io/docs/plugins/#presets" + }, + "whitelist": { + "message": "Put the specific transforms you want in the `plugins` option" + } + }; + +/***/ }), +/* 54 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + // optional / simple context binding + var aFunction = __webpack_require__(414); + module.exports = function (fn, that, length) { + aFunction(fn); + if (that === undefined) return fn; + switch (length) { + case 1: + return function (a) { + return fn.call(that, a); + }; + case 2: + return function (a, b) { + return fn.call(that, a, b); + }; + case 3: + return function (a, b, c) { + return fn.call(that, a, b, c); + }; + } + return function () /* ...args */{ + return fn.apply(that, arguments); + }; + }; + +/***/ }), +/* 55 */ +/***/ (function(module, exports) { + + "use strict"; + + module.exports = {}; + +/***/ }), +/* 56 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + + var META = __webpack_require__(95)('meta'), + isObject = __webpack_require__(22), + has = __webpack_require__(27), + setDesc = __webpack_require__(23).f, + id = 0; + var isExtensible = Object.isExtensible || function () { + return true; + }; + var FREEZE = !__webpack_require__(36)(function () { + return isExtensible(Object.preventExtensions({})); }); -}; - -module.exports.sync = function (pth) { - var fn = typeof fs.accessSync === 'function' ? fs.accessSync : fs.statSync; - - try { - fn(pth); - return true; - } catch (err) { - return false; - } -}; - -},{"1":1}],535:[function(_dereq_,module,exports){ -(function (process){ -'use strict'; - -function posix(path) { - return path.charAt(0) === '/'; -}; - -function win32(path) { - // https://github.com/joyent/node/blob/b3fcc245fb25539909ef1d5eaa01dbf92e168633/lib/path.js#L56 - var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/; - var result = splitDeviceRe.exec(path); - var device = result[1] || ''; - var isUnc = !!device && device.charAt(1) !== ':'; - - // UNC paths are always absolute - return !!result[2] || isUnc; -}; - -module.exports = process.platform === 'win32' ? win32 : posix; -module.exports.posix = posix; -module.exports.win32 = win32; - -}).call(this,_dereq_(10)) -},{"10":10}],536:[function(_dereq_,module,exports){ -"use strict"; - -var originalObject = Object; -var originalDefProp = Object.defineProperty; -var originalCreate = Object.create; - -function defProp(obj, name, value) { - if (originalDefProp) try { - originalDefProp.call(originalObject, obj, name, { value: value }); - } catch (definePropertyIsBrokenInIE8) { - obj[name] = value; - } else { - obj[name] = value; - } -} - -// For functions that will be invoked using .call or .apply, we need to -// define those methods on the function objects themselves, rather than -// inheriting them from Function.prototype, so that a malicious or clumsy -// third party cannot interfere with the functionality of this module by -// redefining Function.prototype.call or .apply. -function makeSafeToCall(fun) { - if (fun) { - defProp(fun, "call", fun.call); - defProp(fun, "apply", fun.apply); - } - return fun; -} - -makeSafeToCall(originalDefProp); -makeSafeToCall(originalCreate); - -var hasOwn = makeSafeToCall(Object.prototype.hasOwnProperty); -var numToStr = makeSafeToCall(Number.prototype.toString); -var strSlice = makeSafeToCall(String.prototype.slice); - -var cloner = function(){}; -function create(prototype) { - if (originalCreate) { - return originalCreate.call(originalObject, prototype); - } - cloner.prototype = prototype || null; - return new cloner; -} - -var rand = Math.random; -var uniqueKeys = create(null); - -function makeUniqueKey() { - // Collisions are highly unlikely, but this module is in the business of - // making guarantees rather than safe bets. - do var uniqueKey = internString(strSlice.call(numToStr.call(rand(), 36), 2)); - while (hasOwn.call(uniqueKeys, uniqueKey)); - return uniqueKeys[uniqueKey] = uniqueKey; -} - -function internString(str) { - var obj = {}; - obj[str] = true; - return Object.keys(obj)[0]; -} - -// External users might find this function useful, but it is not necessary -// for the typical use of this module. -defProp(exports, "makeUniqueKey", makeUniqueKey); - -// Object.getOwnPropertyNames is the only way to enumerate non-enumerable -// properties, so if we wrap it to ignore our secret keys, there should be -// no way (except guessing) to access those properties. -var originalGetOPNs = Object.getOwnPropertyNames; -Object.getOwnPropertyNames = function getOwnPropertyNames(object) { - for (var names = originalGetOPNs(object), - src = 0, - dst = 0, - len = names.length; - src < len; - ++src) { - if (!hasOwn.call(uniqueKeys, names[src])) { - if (src > dst) { - names[dst] = names[src]; - } - ++dst; - } - } - names.length = dst; - return names; -}; - -function defaultCreatorFn(object) { - return create(null); -} - -function makeAccessor(secretCreatorFn) { - var brand = makeUniqueKey(); - var passkey = create(null); - - secretCreatorFn = secretCreatorFn || defaultCreatorFn; - - function register(object) { - var secret; // Created lazily. - - function vault(key, forget) { - // Only code that has access to the passkey can retrieve (or forget) - // the secret object. - if (key === passkey) { - return forget - ? secret = null - : secret || (secret = secretCreatorFn(object)); - } - } - - defProp(object, brand, vault); - } - - function accessor(object) { - if (!hasOwn.call(object, brand)) - register(object); - return object[brand](passkey); - } - - accessor.forget = function(object) { - if (hasOwn.call(object, brand)) - object[brand](passkey, true); - }; - - return accessor; -} - -defProp(exports, "makeAccessor", makeAccessor); - -},{}],537:[function(_dereq_,module,exports){ -/** - * Copyright (c) 2014, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * https://raw.github.com/facebook/regenerator/master/LICENSE file. An - * additional grant of patent rights can be found in the PATENTS file in - * the same directory. - */ - -var assert = _dereq_(2); -var types = _dereq_(568).types; -var isArray = types.builtInTypes.array; -var b = types.builders; -var n = types.namedTypes; -var leap = _dereq_(539); -var meta = _dereq_(540); -var util = _dereq_(541); -var runtimeProperty = util.runtimeProperty; -var hasOwn = Object.prototype.hasOwnProperty; - -function Emitter(contextId) { - assert.ok(this instanceof Emitter); - n.Identifier.assert(contextId); - - // Used to generate unique temporary names. - this.nextTempId = 0; - - Object.defineProperties(this, { - // In order to make sure the context object does not collide with - // anything in the local scope, we might have to rename it, so we - // refer to it symbolically instead of just assuming that it will be - // called "context". - contextId: { value: contextId }, - - // An append-only list of Statements that grows each time this.emit is - // called. - listing: { value: [] }, - - // A sparse array whose keys correspond to locations in this.listing - // that have been marked as branch/jump targets. - marked: { value: [true] }, - - // The last location will be marked when this.getDispatchLoop is - // called. - finalLoc: { value: loc() }, - - // A list of all leap.TryEntry statements emitted. - tryEntries: { value: [] } - }); - - // The .leapManager property needs to be defined by a separate - // defineProperties call so that .finalLoc will be visible to the - // leap.LeapManager constructor. - Object.defineProperties(this, { - // Each time we evaluate the body of a loop, we tell this.leapManager - // to enter a nested loop context that determines the meaning of break - // and continue statements therein. - leapManager: { value: new leap.LeapManager(this) } - }); -} - -var Ep = Emitter.prototype; -exports.Emitter = Emitter; - -// Offsets into this.listing that could be used as targets for branches or -// jumps are represented as numeric Literal nodes. This representation has -// the amazingly convenient benefit of allowing the exact value of the -// location to be determined at any time, even after generating code that -// refers to the location. -function loc() { - return b.literal(-1); -} - -// Sets the exact value of the given location to the offset of the next -// Statement emitted. -Ep.mark = function(loc) { - n.Literal.assert(loc); - var index = this.listing.length; - if (loc.value === -1) { - loc.value = index; - } else { - // Locations can be marked redundantly, but their values cannot change - // once set the first time. - assert.strictEqual(loc.value, index); - } - this.marked[index] = true; - return loc; -}; - -Ep.emit = function(node) { - if (n.Expression.check(node)) - node = b.expressionStatement(node); - n.Statement.assert(node); - this.listing.push(node); -}; - -// Shorthand for emitting assignment statements. This will come in handy -// for assignments to temporary variables. -Ep.emitAssign = function(lhs, rhs) { - this.emit(this.assign(lhs, rhs)); - return lhs; -}; - -// Shorthand for an assignment statement. -Ep.assign = function(lhs, rhs) { - return b.expressionStatement( - b.assignmentExpression("=", lhs, rhs)); -}; - -// Convenience function for generating expressions like context.next, -// context.sent, and context.rval. -Ep.contextProperty = function(name, computed) { - return b.memberExpression( - this.contextId, - computed ? b.literal(name) : b.identifier(name), - !!computed - ); -}; - -// Shorthand for setting context.rval and jumping to `context.stop()`. -Ep.stop = function(rval) { - if (rval) { - this.setReturnValue(rval); - } - - this.jump(this.finalLoc); -}; - -Ep.setReturnValue = function(valuePath) { - n.Expression.assert(valuePath.value); - - this.emitAssign( - this.contextProperty("rval"), - this.explodeExpression(valuePath) - ); -}; - -Ep.clearPendingException = function(tryLoc, assignee) { - n.Literal.assert(tryLoc); - - var catchCall = b.callExpression( - this.contextProperty("catch", true), - [tryLoc] - ); - - if (assignee) { - this.emitAssign(assignee, catchCall); - } else { - this.emit(catchCall); - } -}; - -// Emits code for an unconditional jump to the given location, even if the -// exact value of the location is not yet known. -Ep.jump = function(toLoc) { - this.emitAssign(this.contextProperty("next"), toLoc); - this.emit(b.breakStatement()); -}; - -// Conditional jump. -Ep.jumpIf = function(test, toLoc) { - n.Expression.assert(test); - n.Literal.assert(toLoc); - - this.emit(b.ifStatement( - test, - b.blockStatement([ - this.assign(this.contextProperty("next"), toLoc), - b.breakStatement() - ]) - )); -}; - -// Conditional jump, with the condition negated. -Ep.jumpIfNot = function(test, toLoc) { - n.Expression.assert(test); - n.Literal.assert(toLoc); - - var negatedTest; - if (n.UnaryExpression.check(test) && - test.operator === "!") { - // Avoid double negation. - negatedTest = test.argument; - } else { - negatedTest = b.unaryExpression("!", test); - } - - this.emit(b.ifStatement( - negatedTest, - b.blockStatement([ - this.assign(this.contextProperty("next"), toLoc), - b.breakStatement() - ]) - )); -}; - -// Returns a unique MemberExpression that can be used to store and -// retrieve temporary values. Since the object of the member expression is -// the context object, which is presumed to coexist peacefully with all -// other local variables, and since we just increment `nextTempId` -// monotonically, uniqueness is assured. -Ep.makeTempVar = function() { - return this.contextProperty("t" + this.nextTempId++); -}; - -Ep.getContextFunction = function(id) { - return b.functionExpression( - id || null/*Anonymous*/, - [this.contextId], - b.blockStatement([this.getDispatchLoop()]), - false, // Not a generator anymore! - false // Nor an expression. - ); -}; - -// Turns this.listing into a loop of the form -// -// while (1) switch (context.next) { -// case 0: -// ... -// case n: -// return context.stop(); -// } -// -// Each marked location in this.listing will correspond to one generated -// case statement. -Ep.getDispatchLoop = function() { - var self = this; - var cases = []; - var current; - - // If we encounter a break, continue, or return statement in a switch - // case, we can skip the rest of the statements until the next case. - var alreadyEnded = false; - - self.listing.forEach(function(stmt, i) { - if (self.marked.hasOwnProperty(i)) { - cases.push(b.switchCase( - b.literal(i), - current = [])); - alreadyEnded = false; - } - - if (!alreadyEnded) { - current.push(stmt); - if (isSwitchCaseEnder(stmt)) - alreadyEnded = true; - } - }); - - // Now that we know how many statements there will be in this.listing, - // we can finally resolve this.finalLoc.value. - this.finalLoc.value = this.listing.length; - - cases.push( - b.switchCase(this.finalLoc, [ - // Intentionally fall through to the "end" case... - ]), - - // So that the runtime can jump to the final location without having - // to know its offset, we provide the "end" case as a synonym. - b.switchCase(b.literal("end"), [ - // This will check/clear both context.thrown and context.rval. - b.returnStatement( - b.callExpression(this.contextProperty("stop"), []) - ) - ]) - ); - - return b.whileStatement( - b.literal(1), - b.switchStatement( - b.assignmentExpression( - "=", - this.contextProperty("prev"), - this.contextProperty("next") - ), - cases - ) - ); -}; - -// See comment above re: alreadyEnded. -function isSwitchCaseEnder(stmt) { - return n.BreakStatement.check(stmt) - || n.ContinueStatement.check(stmt) - || n.ReturnStatement.check(stmt) - || n.ThrowStatement.check(stmt); -} - -Ep.getTryLocsList = function() { - if (this.tryEntries.length === 0) { - // To avoid adding a needless [] to the majority of runtime.wrap - // argument lists, force the caller to handle this case specially. - return null; - } - - var lastLocValue = 0; - - return b.arrayExpression( - this.tryEntries.map(function(tryEntry) { - var thisLocValue = tryEntry.firstLoc.value; - assert.ok(thisLocValue >= lastLocValue, "try entries out of order"); - lastLocValue = thisLocValue; - - var ce = tryEntry.catchEntry; - var fe = tryEntry.finallyEntry; - - var locs = [ - tryEntry.firstLoc, - // The null here makes a hole in the array. - ce ? ce.firstLoc : null - ]; - - if (fe) { - locs[2] = fe.firstLoc; - locs[3] = fe.afterLoc; - } - - return b.arrayExpression(locs); - }) - ); -}; - -// All side effects must be realized in order. - -// If any subexpression harbors a leap, all subexpressions must be -// neutered of side effects. - -// No destructive modification of AST nodes. - -Ep.explode = function(path, ignoreResult) { - assert.ok(path instanceof types.NodePath); - - var node = path.value; - var self = this; - - n.Node.assert(node); - - if (n.Statement.check(node)) - return self.explodeStatement(path); - - if (n.Expression.check(node)) - return self.explodeExpression(path, ignoreResult); - - if (n.Declaration.check(node)) - throw getDeclError(node); - - switch (node.type) { - case "Program": - return path.get("body").map( - self.explodeStatement, - self - ); - - case "VariableDeclarator": - throw getDeclError(node); - - // These node types should be handled by their parent nodes - // (ObjectExpression, SwitchStatement, and TryStatement, respectively). - case "Property": - case "SwitchCase": - case "CatchClause": - throw new Error( - node.type + " nodes should be handled by their parents"); - - default: - throw new Error( - "unknown Node of type " + - JSON.stringify(node.type)); - } -}; - -function getDeclError(node) { - return new Error( - "all declarations should have been transformed into " + - "assignments before the Exploder began its work: " + - JSON.stringify(node)); -} - -Ep.explodeStatement = function(path, labelId) { - assert.ok(path instanceof types.NodePath); - - var stmt = path.value; - var self = this; - - n.Statement.assert(stmt); - - if (labelId) { - n.Identifier.assert(labelId); - } else { - labelId = null; - } - - // Explode BlockStatement nodes even if they do not contain a yield, - // because we don't want or need the curly braces. - if (n.BlockStatement.check(stmt)) { - return path.get("body").each( - self.explodeStatement, - self - ); - } - - if (!meta.containsLeap(stmt)) { - // Technically we should be able to avoid emitting the statement - // altogether if !meta.hasSideEffects(stmt), but that leads to - // confusing generated code (for instance, `while (true) {}` just - // disappears) and is probably a more appropriate job for a dedicated - // dead code elimination pass. - self.emit(stmt); - return; - } - - switch (stmt.type) { - case "ExpressionStatement": - self.explodeExpression(path.get("expression"), true); - break; - - case "LabeledStatement": - var after = loc(); - - // Did you know you can break from any labeled block statement or - // control structure? Well, you can! Note: when a labeled loop is - // encountered, the leap.LabeledEntry created here will immediately - // enclose a leap.LoopEntry on the leap manager's stack, and both - // entries will have the same label. Though this works just fine, it - // may seem a bit redundant. In theory, we could check here to - // determine if stmt knows how to handle its own label; for example, - // stmt happens to be a WhileStatement and so we know it's going to - // establish its own LoopEntry when we explode it (below). Then this - // LabeledEntry would be unnecessary. Alternatively, we might be - // tempted not to pass stmt.label down into self.explodeStatement, - // because we've handled the label here, but that's a mistake because - // labeled loops may contain labeled continue statements, which is not - // something we can handle in this generic case. All in all, I think a - // little redundancy greatly simplifies the logic of this case, since - // it's clear that we handle all possible LabeledStatements correctly - // here, regardless of whether they interact with the leap manager - // themselves. Also remember that labels and break/continue-to-label - // statements are rare, and all of this logic happens at transform - // time, so it has no additional runtime cost. - self.leapManager.withEntry( - new leap.LabeledEntry(after, stmt.label), - function() { - self.explodeStatement(path.get("body"), stmt.label); - } - ); - - self.mark(after); - - break; - - case "WhileStatement": - var before = loc(); - var after = loc(); - - self.mark(before); - self.jumpIfNot(self.explodeExpression(path.get("test")), after); - self.leapManager.withEntry( - new leap.LoopEntry(after, before, labelId), - function() { self.explodeStatement(path.get("body")); } - ); - self.jump(before); - self.mark(after); - - break; - - case "DoWhileStatement": - var first = loc(); - var test = loc(); - var after = loc(); - - self.mark(first); - self.leapManager.withEntry( - new leap.LoopEntry(after, test, labelId), - function() { self.explode(path.get("body")); } - ); - self.mark(test); - self.jumpIf(self.explodeExpression(path.get("test")), first); - self.mark(after); - - break; - - case "ForStatement": - var head = loc(); - var update = loc(); - var after = loc(); - - if (stmt.init) { - // We pass true here to indicate that if stmt.init is an expression - // then we do not care about its result. - self.explode(path.get("init"), true); - } - - self.mark(head); - - if (stmt.test) { - self.jumpIfNot(self.explodeExpression(path.get("test")), after); - } else { - // No test means continue unconditionally. - } - - self.leapManager.withEntry( - new leap.LoopEntry(after, update, labelId), - function() { self.explodeStatement(path.get("body")); } - ); - - self.mark(update); - - if (stmt.update) { - // We pass true here to indicate that if stmt.update is an - // expression then we do not care about its result. - self.explode(path.get("update"), true); - } - - self.jump(head); - - self.mark(after); - - break; - - case "ForInStatement": - var head = loc(); - var after = loc(); - - var keyIterNextFn = self.makeTempVar(); - self.emitAssign( - keyIterNextFn, - b.callExpression( - runtimeProperty("keys"), - [self.explodeExpression(path.get("right"))] - ) - ); - - self.mark(head); - - var keyInfoTmpVar = self.makeTempVar(); - self.jumpIf( - b.memberExpression( - b.assignmentExpression( - "=", - keyInfoTmpVar, - b.callExpression(keyIterNextFn, []) - ), - b.identifier("done"), - false - ), - after - ); - - self.emitAssign( - stmt.left, - b.memberExpression( - keyInfoTmpVar, - b.identifier("value"), - false - ) - ); - - self.leapManager.withEntry( - new leap.LoopEntry(after, head, labelId), - function() { self.explodeStatement(path.get("body")); } - ); - - self.jump(head); - - self.mark(after); - - break; - - case "BreakStatement": - self.emitAbruptCompletion({ - type: "break", - target: self.leapManager.getBreakLoc(stmt.label) - }); - - break; - - case "ContinueStatement": - self.emitAbruptCompletion({ - type: "continue", - target: self.leapManager.getContinueLoc(stmt.label) - }); - - break; - - case "SwitchStatement": - // Always save the discriminant into a temporary variable in case the - // test expressions overwrite values like context.sent. - var disc = self.emitAssign( - self.makeTempVar(), - self.explodeExpression(path.get("discriminant")) - ); - - var after = loc(); - var defaultLoc = loc(); - var condition = defaultLoc; - var caseLocs = []; - - // If there are no cases, .cases might be undefined. - var cases = stmt.cases || []; - - for (var i = cases.length - 1; i >= 0; --i) { - var c = cases[i]; - n.SwitchCase.assert(c); - - if (c.test) { - condition = b.conditionalExpression( - b.binaryExpression("===", disc, c.test), - caseLocs[i] = loc(), - condition - ); - } else { - caseLocs[i] = defaultLoc; - } - } - - self.jump(self.explodeExpression( - new types.NodePath(condition, path, "discriminant") - )); - - self.leapManager.withEntry( - new leap.SwitchEntry(after), - function() { - path.get("cases").each(function(casePath) { - var c = casePath.value; - var i = casePath.name; - - self.mark(caseLocs[i]); - - casePath.get("consequent").each( - self.explodeStatement, - self - ); - }); - } - ); - - self.mark(after); - if (defaultLoc.value === -1) { - self.mark(defaultLoc); - assert.strictEqual(after.value, defaultLoc.value); - } - - break; - - case "IfStatement": - var elseLoc = stmt.alternate && loc(); - var after = loc(); - - self.jumpIfNot( - self.explodeExpression(path.get("test")), - elseLoc || after - ); - - self.explodeStatement(path.get("consequent")); - - if (elseLoc) { - self.jump(after); - self.mark(elseLoc); - self.explodeStatement(path.get("alternate")); - } - - self.mark(after); - - break; - - case "ReturnStatement": - self.emitAbruptCompletion({ - type: "return", - value: self.explodeExpression(path.get("argument")) - }); - - break; - - case "WithStatement": - throw new Error( - node.type + " not supported in generator functions."); - - case "TryStatement": - var after = loc(); - - var handler = stmt.handler; - if (!handler && stmt.handlers) { - handler = stmt.handlers[0] || null; - } - - var catchLoc = handler && loc(); - var catchEntry = catchLoc && new leap.CatchEntry( - catchLoc, - handler.param - ); - - var finallyLoc = stmt.finalizer && loc(); - var finallyEntry = finallyLoc && - new leap.FinallyEntry(finallyLoc, after); - - var tryEntry = new leap.TryEntry( - self.getUnmarkedCurrentLoc(), - catchEntry, - finallyEntry - ); - - self.tryEntries.push(tryEntry); - self.updateContextPrevLoc(tryEntry.firstLoc); - - self.leapManager.withEntry(tryEntry, function() { - self.explodeStatement(path.get("block")); - - if (catchLoc) { - if (finallyLoc) { - // If we have both a catch block and a finally block, then - // because we emit the catch block first, we need to jump over - // it to the finally block. - self.jump(finallyLoc); - - } else { - // If there is no finally block, then we need to jump over the - // catch block to the fall-through location. - self.jump(after); - } - - self.updateContextPrevLoc(self.mark(catchLoc)); - - var bodyPath = path.get("handler", "body"); - var safeParam = self.makeTempVar(); - self.clearPendingException(tryEntry.firstLoc, safeParam); - - var catchScope = bodyPath.scope; - var catchParamName = handler.param.name; - n.CatchClause.assert(catchScope.node); - assert.strictEqual(catchScope.lookup(catchParamName), catchScope); - - types.visit(bodyPath, { - visitIdentifier: function(path) { - if (util.isReference(path, catchParamName) && - path.scope.lookup(catchParamName) === catchScope) { - return safeParam; - } - - this.traverse(path); - }, - - visitFunction: function(path) { - if (path.scope.declares(catchParamName)) { - // Don't descend into nested scopes that shadow the catch - // parameter with their own declarations. This isn't - // logically necessary because of the path.scope.lookup we - // do in visitIdentifier, but it saves time. - return false; - } - - this.traverse(path); - } - }); - - self.leapManager.withEntry(catchEntry, function() { - self.explodeStatement(bodyPath); - }); - } - - if (finallyLoc) { - self.updateContextPrevLoc(self.mark(finallyLoc)); - - self.leapManager.withEntry(finallyEntry, function() { - self.explodeStatement(path.get("finalizer")); - }); - - self.emit(b.returnStatement(b.callExpression( - self.contextProperty("finish"), - [finallyEntry.firstLoc] - ))); - } - }); - - self.mark(after); - - break; - - case "ThrowStatement": - self.emit(b.throwStatement( - self.explodeExpression(path.get("argument")) - )); - - break; - - default: - throw new Error( - "unknown Statement of type " + - JSON.stringify(stmt.type)); - } -}; - -Ep.emitAbruptCompletion = function(record) { - if (!isValidCompletion(record)) { - assert.ok( - false, - "invalid completion record: " + - JSON.stringify(record) - ); - } - - assert.notStrictEqual( - record.type, "normal", - "normal completions are not abrupt" - ); - - var abruptArgs = [b.literal(record.type)]; - - if (record.type === "break" || - record.type === "continue") { - n.Literal.assert(record.target); - abruptArgs[1] = record.target; - } else if (record.type === "return" || - record.type === "throw") { - if (record.value) { - n.Expression.assert(record.value); - abruptArgs[1] = record.value; - } - } - - this.emit( - b.returnStatement( - b.callExpression( - this.contextProperty("abrupt"), - abruptArgs - ) - ) - ); -}; - -function isValidCompletion(record) { - var type = record.type; - - if (type === "normal") { - return !hasOwn.call(record, "target"); - } - - if (type === "break" || - type === "continue") { - return !hasOwn.call(record, "value") - && n.Literal.check(record.target); - } - - if (type === "return" || - type === "throw") { - return hasOwn.call(record, "value") - && !hasOwn.call(record, "target"); - } - - return false; -} - - -// Not all offsets into emitter.listing are potential jump targets. For -// example, execution typically falls into the beginning of a try block -// without jumping directly there. This method returns the current offset -// without marking it, so that a switch case will not necessarily be -// generated for this offset (I say "not necessarily" because the same -// location might end up being marked in the process of emitting other -// statements). There's no logical harm in marking such locations as jump -// targets, but minimizing the number of switch cases keeps the generated -// code shorter. -Ep.getUnmarkedCurrentLoc = function() { - return b.literal(this.listing.length); -}; - -// The context.prev property takes the value of context.next whenever we -// evaluate the switch statement discriminant, which is generally good -// enough for tracking the last location we jumped to, but sometimes -// context.prev needs to be more precise, such as when we fall -// successfully out of a try block and into a finally block without -// jumping. This method exists to update context.prev to the freshest -// available location. If we were implementing a full interpreter, we -// would know the location of the current instruction with complete -// precision at all times, but we don't have that luxury here, as it would -// be costly and verbose to set context.prev before every statement. -Ep.updateContextPrevLoc = function(loc) { - if (loc) { - n.Literal.assert(loc); - - if (loc.value === -1) { - // If an uninitialized location literal was passed in, set its value - // to the current this.listing.length. - loc.value = this.listing.length; - } else { - // Otherwise assert that the location matches the current offset. - assert.strictEqual(loc.value, this.listing.length); - } - - } else { - loc = this.getUnmarkedCurrentLoc(); - } - - // Make sure context.prev is up to date in case we fell into this try - // statement without jumping to it. TODO Consider avoiding this - // assignment when we know control must have jumped here. - this.emitAssign(this.contextProperty("prev"), loc); -}; - -Ep.explodeExpression = function(path, ignoreResult) { - assert.ok(path instanceof types.NodePath); - - var expr = path.value; - if (expr) { - n.Expression.assert(expr); - } else { - return expr; - } - - var self = this; - var result; // Used optionally by several cases below. - - function finish(expr) { - n.Expression.assert(expr); - if (ignoreResult) { - self.emit(expr); - } else { - return expr; - } - } - - // If the expression does not contain a leap, then we either emit the - // expression as a standalone statement or return it whole. - if (!meta.containsLeap(expr)) { - return finish(expr); - } - - // If any child contains a leap (such as a yield or labeled continue or - // break statement), then any sibling subexpressions will almost - // certainly have to be exploded in order to maintain the order of their - // side effects relative to the leaping child(ren). - var hasLeapingChildren = meta.containsLeap.onlyChildren(expr); - - // In order to save the rest of explodeExpression from a combinatorial - // trainwreck of special cases, explodeViaTempVar is responsible for - // deciding when a subexpression needs to be "exploded," which is my - // very technical term for emitting the subexpression as an assignment - // to a temporary variable and the substituting the temporary variable - // for the original subexpression. Think of exploded view diagrams, not - // Michael Bay movies. The point of exploding subexpressions is to - // control the precise order in which the generated code realizes the - // side effects of those subexpressions. - function explodeViaTempVar(tempVar, childPath, ignoreChildResult) { - assert.ok(childPath instanceof types.NodePath); - - assert.ok( - !ignoreChildResult || !tempVar, - "Ignoring the result of a child expression but forcing it to " + - "be assigned to a temporary variable?" - ); - - var result = self.explodeExpression(childPath, ignoreChildResult); - - if (ignoreChildResult) { - // Side effects already emitted above. - - } else if (tempVar || (hasLeapingChildren && - !n.Literal.check(result))) { - // If tempVar was provided, then the result will always be assigned - // to it, even if the result does not otherwise need to be assigned - // to a temporary variable. When no tempVar is provided, we have - // the flexibility to decide whether a temporary variable is really - // necessary. Unfortunately, in general, a temporary variable is - // required whenever any child contains a yield expression, since it - // is difficult to prove (at all, let alone efficiently) whether - // this result would evaluate to the same value before and after the - // yield (see #206). One narrow case where we can prove it doesn't - // matter (and thus we do not need a temporary variable) is when the - // result in question is a Literal value. - result = self.emitAssign( - tempVar || self.makeTempVar(), - result - ); - } - return result; - } - - // If ignoreResult is true, then we must take full responsibility for - // emitting the expression with all its side effects, and we should not - // return a result. - - switch (expr.type) { - case "MemberExpression": - return finish(b.memberExpression( - self.explodeExpression(path.get("object")), - expr.computed - ? explodeViaTempVar(null, path.get("property")) - : expr.property, - expr.computed - )); - - case "CallExpression": - var calleePath = path.get("callee"); - var argsPath = path.get("arguments"); - - var newCallee; - var newArgs = []; - - var hasLeapingArgs = false; - argsPath.each(function(argPath) { - hasLeapingArgs = hasLeapingArgs || - meta.containsLeap(argPath.value); - }); - - if (n.MemberExpression.check(calleePath.value)) { - if (hasLeapingArgs) { - // If the arguments of the CallExpression contained any yield - // expressions, then we need to be sure to evaluate the callee - // before evaluating the arguments, but if the callee was a member - // expression, then we must be careful that the object of the - // member expression still gets bound to `this` for the call. - - var newObject = explodeViaTempVar( - // Assign the exploded callee.object expression to a temporary - // variable so that we can use it twice without reevaluating it. - self.makeTempVar(), - calleePath.get("object") - ); - - var newProperty = calleePath.value.computed - ? explodeViaTempVar(null, calleePath.get("property")) - : calleePath.value.property; - - newArgs.unshift(newObject); - - newCallee = b.memberExpression( - b.memberExpression( - newObject, - newProperty, - calleePath.value.computed - ), - b.identifier("call"), - false - ); - - } else { - newCallee = self.explodeExpression(calleePath); - } - - } else { - newCallee = self.explodeExpression(calleePath); - - if (n.MemberExpression.check(newCallee)) { - // If the callee was not previously a MemberExpression, then the - // CallExpression was "unqualified," meaning its `this` object - // should be the global object. If the exploded expression has - // become a MemberExpression (e.g. a context property, probably a - // temporary variable), then we need to force it to be unqualified - // by using the (0, object.property)(...) trick; otherwise, it - // will receive the object of the MemberExpression as its `this` - // object. - newCallee = b.sequenceExpression([ - b.literal(0), - newCallee - ]); - } - } - - argsPath.each(function(argPath) { - newArgs.push(explodeViaTempVar(null, argPath)); - }); - - return finish(b.callExpression( - newCallee, - newArgs - )); - - case "NewExpression": - return finish(b.newExpression( - explodeViaTempVar(null, path.get("callee")), - path.get("arguments").map(function(argPath) { - return explodeViaTempVar(null, argPath); - }) - )); - - case "ObjectExpression": - return finish(b.objectExpression( - path.get("properties").map(function(propPath) { - return b.property( - propPath.value.kind, - propPath.value.key, - explodeViaTempVar(null, propPath.get("value")) - ); - }) - )); - - case "ArrayExpression": - return finish(b.arrayExpression( - path.get("elements").map(function(elemPath) { - return explodeViaTempVar(null, elemPath); - }) - )); - - case "SequenceExpression": - var lastIndex = expr.expressions.length - 1; - - path.get("expressions").each(function(exprPath) { - if (exprPath.name === lastIndex) { - result = self.explodeExpression(exprPath, ignoreResult); - } else { - self.explodeExpression(exprPath, true); - } - }); - - return result; - - case "LogicalExpression": - var after = loc(); - - if (!ignoreResult) { - result = self.makeTempVar(); - } - - var left = explodeViaTempVar(result, path.get("left")); - - if (expr.operator === "&&") { - self.jumpIfNot(left, after); - } else { - assert.strictEqual(expr.operator, "||"); - self.jumpIf(left, after); - } - - explodeViaTempVar(result, path.get("right"), ignoreResult); - - self.mark(after); - - return result; - - case "ConditionalExpression": - var elseLoc = loc(); - var after = loc(); - var test = self.explodeExpression(path.get("test")); - - self.jumpIfNot(test, elseLoc); - - if (!ignoreResult) { - result = self.makeTempVar(); - } - - explodeViaTempVar(result, path.get("consequent"), ignoreResult); - self.jump(after); - - self.mark(elseLoc); - explodeViaTempVar(result, path.get("alternate"), ignoreResult); - - self.mark(after); - - return result; - - case "UnaryExpression": - return finish(b.unaryExpression( - expr.operator, - // Can't (and don't need to) break up the syntax of the argument. - // Think about delete a[b]. - self.explodeExpression(path.get("argument")), - !!expr.prefix - )); - - case "BinaryExpression": - return finish(b.binaryExpression( - expr.operator, - explodeViaTempVar(null, path.get("left")), - explodeViaTempVar(null, path.get("right")) - )); - - case "AssignmentExpression": - return finish(b.assignmentExpression( - expr.operator, - self.explodeExpression(path.get("left")), - self.explodeExpression(path.get("right")) - )); - - case "UpdateExpression": - return finish(b.updateExpression( - expr.operator, - self.explodeExpression(path.get("argument")), - expr.prefix - )); - - case "YieldExpression": - var after = loc(); - var arg = expr.argument && self.explodeExpression(path.get("argument")); - - if (arg && expr.delegate) { - var result = self.makeTempVar(); - - self.emit(b.returnStatement(b.callExpression( - self.contextProperty("delegateYield"), [ - arg, - b.literal(result.property.name), - after - ] - ))); - - self.mark(after); - - return result; - } - - self.emitAssign(self.contextProperty("next"), after); - self.emit(b.returnStatement(arg || null)); - self.mark(after); - - return self.contextProperty("sent"); - - default: - throw new Error( - "unknown Expression of type " + - JSON.stringify(expr.type)); - } -}; - -},{"2":2,"539":539,"540":540,"541":541,"568":568}],538:[function(_dereq_,module,exports){ -/** - * Copyright (c) 2014, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * https://raw.github.com/facebook/regenerator/master/LICENSE file. An - * additional grant of patent rights can be found in the PATENTS file in - * the same directory. - */ - -var assert = _dereq_(2); -var types = _dereq_(568).types; -var n = types.namedTypes; -var b = types.builders; -var hasOwn = Object.prototype.hasOwnProperty; - -// The hoist function takes a FunctionExpression or FunctionDeclaration -// and replaces any Declaration nodes in its body with assignments, then -// returns a VariableDeclaration containing just the names of the removed -// declarations. -exports.hoist = function(funPath) { - assert.ok(funPath instanceof types.NodePath); - n.Function.assert(funPath.value); - - var vars = {}; - - function varDeclToExpr(vdec, includeIdentifiers) { - n.VariableDeclaration.assert(vdec); - var exprs = []; - - vdec.declarations.forEach(function(dec) { - vars[dec.id.name] = dec.id; - - if (dec.init) { - exprs.push(b.assignmentExpression( - "=", dec.id, dec.init - )); - } else if (includeIdentifiers) { - exprs.push(dec.id); - } - }); - - if (exprs.length === 0) - return null; - - if (exprs.length === 1) - return exprs[0]; - - return b.sequenceExpression(exprs); - } - - types.visit(funPath.get("body"), { - visitVariableDeclaration: function(path) { - var expr = varDeclToExpr(path.value, false); - if (expr === null) { - path.replace(); - } else { - // We don't need to traverse this expression any further because - // there can't be any new declarations inside an expression. - return b.expressionStatement(expr); - } - - // Since the original node has been either removed or replaced, - // avoid traversing it any further. - return false; - }, - - visitForStatement: function(path) { - var init = path.value.init; - if (n.VariableDeclaration.check(init)) { - path.get("init").replace(varDeclToExpr(init, false)); - } - this.traverse(path); - }, - - visitForInStatement: function(path) { - var left = path.value.left; - if (n.VariableDeclaration.check(left)) { - path.get("left").replace(varDeclToExpr(left, true)); - } - this.traverse(path); - }, - - visitFunctionDeclaration: function(path) { - var node = path.value; - vars[node.id.name] = node.id; - - var parentNode = path.parent.node; - var assignment = b.expressionStatement( - b.assignmentExpression( - "=", - node.id, - b.functionExpression( - node.id, - node.params, - node.body, - node.generator, - node.expression - ) - ) - ); - - if (n.BlockStatement.check(path.parent.node)) { - // Insert the assignment form before the first statement in the - // enclosing block. - path.parent.get("body").unshift(assignment); - - // Remove the function declaration now that we've inserted the - // equivalent assignment form at the beginning of the block. - path.replace(); - - } else { - // If the parent node is not a block statement, then we can just - // replace the declaration with the equivalent assignment form - // without worrying about hoisting it. - path.replace(assignment); - } - - // Don't hoist variables out of inner functions. - return false; - }, - - visitFunctionExpression: function(path) { - // Don't descend into nested function expressions. - return false; - } - }); - - var paramNames = {}; - funPath.get("params").each(function(paramPath) { - var param = paramPath.value; - if (n.Identifier.check(param)) { - paramNames[param.name] = param; - } else { - // Variables declared by destructuring parameter patterns will be - // harmlessly re-declared. - } - }); - - var declarations = []; - - Object.keys(vars).forEach(function(name) { - if (!hasOwn.call(paramNames, name)) { - declarations.push(b.variableDeclarator(vars[name], null)); - } - }); - - if (declarations.length === 0) { - return null; // Be sure to handle this case! - } - - return b.variableDeclaration("var", declarations); -}; - -},{"2":2,"568":568}],539:[function(_dereq_,module,exports){ -/** - * Copyright (c) 2014, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * https://raw.github.com/facebook/regenerator/master/LICENSE file. An - * additional grant of patent rights can be found in the PATENTS file in - * the same directory. - */ - -var assert = _dereq_(2); -var types = _dereq_(568).types; -var n = types.namedTypes; -var b = types.builders; -var inherits = _dereq_(13).inherits; -var hasOwn = Object.prototype.hasOwnProperty; - -function Entry() { - assert.ok(this instanceof Entry); -} - -function FunctionEntry(returnLoc) { - Entry.call(this); - n.Literal.assert(returnLoc); - this.returnLoc = returnLoc; -} - -inherits(FunctionEntry, Entry); -exports.FunctionEntry = FunctionEntry; - -function LoopEntry(breakLoc, continueLoc, label) { - Entry.call(this); - - n.Literal.assert(breakLoc); - n.Literal.assert(continueLoc); - - if (label) { - n.Identifier.assert(label); - } else { - label = null; - } - - this.breakLoc = breakLoc; - this.continueLoc = continueLoc; - this.label = label; -} - -inherits(LoopEntry, Entry); -exports.LoopEntry = LoopEntry; - -function SwitchEntry(breakLoc) { - Entry.call(this); - n.Literal.assert(breakLoc); - this.breakLoc = breakLoc; -} - -inherits(SwitchEntry, Entry); -exports.SwitchEntry = SwitchEntry; - -function TryEntry(firstLoc, catchEntry, finallyEntry) { - Entry.call(this); - - n.Literal.assert(firstLoc); - - if (catchEntry) { - assert.ok(catchEntry instanceof CatchEntry); - } else { - catchEntry = null; - } - - if (finallyEntry) { - assert.ok(finallyEntry instanceof FinallyEntry); - } else { - finallyEntry = null; - } - - // Have to have one or the other (or both). - assert.ok(catchEntry || finallyEntry); - - this.firstLoc = firstLoc; - this.catchEntry = catchEntry; - this.finallyEntry = finallyEntry; -} - -inherits(TryEntry, Entry); -exports.TryEntry = TryEntry; - -function CatchEntry(firstLoc, paramId) { - Entry.call(this); - - n.Literal.assert(firstLoc); - n.Identifier.assert(paramId); - - this.firstLoc = firstLoc; - this.paramId = paramId; -} - -inherits(CatchEntry, Entry); -exports.CatchEntry = CatchEntry; - -function FinallyEntry(firstLoc, afterLoc) { - Entry.call(this); - n.Literal.assert(firstLoc); - n.Literal.assert(afterLoc); - this.firstLoc = firstLoc; - this.afterLoc = afterLoc; -} - -inherits(FinallyEntry, Entry); -exports.FinallyEntry = FinallyEntry; - -function LabeledEntry(breakLoc, label) { - Entry.call(this); - - n.Literal.assert(breakLoc); - n.Identifier.assert(label); - - this.breakLoc = breakLoc; - this.label = label; -} - -inherits(LabeledEntry, Entry); -exports.LabeledEntry = LabeledEntry; - -function LeapManager(emitter) { - assert.ok(this instanceof LeapManager); - - var Emitter = _dereq_(537).Emitter; - assert.ok(emitter instanceof Emitter); - - this.emitter = emitter; - this.entryStack = [new FunctionEntry(emitter.finalLoc)]; -} - -var LMp = LeapManager.prototype; -exports.LeapManager = LeapManager; - -LMp.withEntry = function(entry, callback) { - assert.ok(entry instanceof Entry); - this.entryStack.push(entry); - try { - callback.call(this.emitter); - } finally { - var popped = this.entryStack.pop(); - assert.strictEqual(popped, entry); - } -}; - -LMp._findLeapLocation = function(property, label) { - for (var i = this.entryStack.length - 1; i >= 0; --i) { - var entry = this.entryStack[i]; - var loc = entry[property]; - if (loc) { - if (label) { - if (entry.label && - entry.label.name === label.name) { - return loc; - } - } else if (entry instanceof LabeledEntry) { - // Ignore LabeledEntry entries unless we are actually breaking to - // a label. - } else { - return loc; - } - } - } - - return null; -}; - -LMp.getBreakLoc = function(label) { - return this._findLeapLocation("breakLoc", label); -}; - -LMp.getContinueLoc = function(label) { - return this._findLeapLocation("continueLoc", label); -}; - -},{"13":13,"2":2,"537":537,"568":568}],540:[function(_dereq_,module,exports){ -/** - * Copyright (c) 2014, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * https://raw.github.com/facebook/regenerator/master/LICENSE file. An - * additional grant of patent rights can be found in the PATENTS file in - * the same directory. - */ - -var assert = _dereq_(2); -var m = _dereq_(536).makeAccessor(); -var types = _dereq_(568).types; -var isArray = types.builtInTypes.array; -var n = types.namedTypes; -var hasOwn = Object.prototype.hasOwnProperty; - -function makePredicate(propertyName, knownTypes) { - function onlyChildren(node) { - n.Node.assert(node); - - // Assume no side effects until we find out otherwise. - var result = false; - - function check(child) { - if (result) { - // Do nothing. - } else if (isArray.check(child)) { - child.some(check); - } else if (n.Node.check(child)) { - assert.strictEqual(result, false); - result = predicate(child); - } - return result; - } - - types.eachField(node, function(name, child) { - check(child); - }); - - return result; - } - - function predicate(node) { - n.Node.assert(node); - - var meta = m(node); - if (hasOwn.call(meta, propertyName)) - return meta[propertyName]; - - // Certain types are "opaque," which means they have no side - // effects or leaps and we don't care about their subexpressions. - if (hasOwn.call(opaqueTypes, node.type)) - return meta[propertyName] = false; - - if (hasOwn.call(knownTypes, node.type)) - return meta[propertyName] = true; - - return meta[propertyName] = onlyChildren(node); - } - - predicate.onlyChildren = onlyChildren; - - return predicate; -} - -var opaqueTypes = { - FunctionExpression: true -}; - -// These types potentially have side effects regardless of what side -// effects their subexpressions have. -var sideEffectTypes = { - CallExpression: true, // Anything could happen! - ForInStatement: true, // Modifies the key variable. - UnaryExpression: true, // Think delete. - BinaryExpression: true, // Might invoke .toString() or .valueOf(). - AssignmentExpression: true, // Side-effecting by definition. - UpdateExpression: true, // Updates are essentially assignments. - NewExpression: true // Similar to CallExpression. -}; - -// These types are the direct cause of all leaps in control flow. -var leapTypes = { - YieldExpression: true, - BreakStatement: true, - ContinueStatement: true, - ReturnStatement: true, - ThrowStatement: true -}; - -// All leap types are also side effect types. -for (var type in leapTypes) { - if (hasOwn.call(leapTypes, type)) { - sideEffectTypes[type] = leapTypes[type]; - } -} - -exports.hasSideEffects = makePredicate("hasSideEffects", sideEffectTypes); -exports.containsLeap = makePredicate("containsLeap", leapTypes); - -},{"2":2,"536":536,"568":568}],541:[function(_dereq_,module,exports){ -/** - * Copyright (c) 2014, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * https://raw.github.com/facebook/regenerator/master/LICENSE file. An - * additional grant of patent rights can be found in the PATENTS file in - * the same directory. - */ - -var assert = _dereq_(2); -var types = _dereq_(568).types; -var n = types.namedTypes; -var b = types.builders; -var hasOwn = Object.prototype.hasOwnProperty; - -exports.defaults = function(obj) { - var len = arguments.length; - var extension; - - for (var i = 1; i < len; ++i) { - if ((extension = arguments[i])) { - for (var key in extension) { - if (hasOwn.call(extension, key) && !hasOwn.call(obj, key)) { - obj[key] = extension[key]; - } - } - } - } - - return obj; -}; - -exports.runtimeProperty = function(name) { - return b.memberExpression( - b.identifier("regeneratorRuntime"), - b.identifier(name), - false - ); -}; - -// Inspired by the isReference function from ast-util: -// https://github.com/eventualbuddha/ast-util/blob/9bf91c5ce8/lib/index.js#L466-L506 -exports.isReference = function(path, name) { - var node = path.value; - - if (!n.Identifier.check(node)) { - return false; - } - - if (name && node.name !== name) { - return false; - } - - var parent = path.parent.value; - - switch (parent.type) { - case "VariableDeclarator": - return path.name === "init"; - - case "MemberExpression": - return path.name === "object" || ( - parent.computed && path.name === "property" - ); - - case "FunctionExpression": - case "FunctionDeclaration": - case "ArrowFunctionExpression": - if (path.name === "id") { - return false; - } - - if (path.parentPath.name === "params" && - parent.params === path.parentPath.value && - parent.params[path.name] === node) { - return false; - } - - return true; - - case "ClassDeclaration": - case "ClassExpression": - return path.name !== "id"; - - case "CatchClause": - return path.name !== "param"; - - case "Property": - case "MethodDefinition": - return path.name !== "key"; - - case "ImportSpecifier": - case "ImportDefaultSpecifier": - case "ImportNamespaceSpecifier": - case "LabeledStatement": - return false; - - default: - return true; - } -}; - -},{"2":2,"568":568}],542:[function(_dereq_,module,exports){ -/** - * Copyright (c) 2014, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * https://raw.github.com/facebook/regenerator/master/LICENSE file. An - * additional grant of patent rights can be found in the PATENTS file in - * the same directory. - */ - -var assert = _dereq_(2); -var fs = _dereq_(1); -var recast = _dereq_(568); -var types = recast.types; -var n = types.namedTypes; -var b = types.builders; -var isArray = types.builtInTypes.array; -var isObject = types.builtInTypes.object; -var NodePath = types.NodePath; -var hoist = _dereq_(538).hoist; -var Emitter = _dereq_(537).Emitter; -var util = _dereq_(541); -var runtimeProperty = util.runtimeProperty; -var getMarkInfo = _dereq_(536).makeAccessor(); - -exports.transform = function transform(node, options) { - options = options || {}; - - var path = node instanceof NodePath ? node : new NodePath(node); - visitor.visit(path, options); - node = path.value; - - if (options.includeRuntime === true || - (options.includeRuntime === 'if used' && visitor.wasChangeReported())) { - injectRuntime(n.File.check(node) ? node.program : node); - } - - options.madeChanges = visitor.wasChangeReported(); - - return node; -}; - -function injectRuntime(program) { - n.Program.assert(program); - - // Include the runtime by modifying the AST rather than by concatenating - // strings. This technique will allow for more accurate source mapping. - var runtimePath = _dereq_(543).runtime.path; - var runtime = fs.readFileSync(runtimePath, "utf8"); - var runtimeBody = recast.parse(runtime, { - sourceFileName: runtimePath - }).program.body; - - var body = program.body; - body.unshift.apply(body, runtimeBody); -} - -var visitor = types.PathVisitor.fromMethodsObject({ - reset: function(node, options) { - this.options = options; - }, - - visitFunction: function(path) { - // Calling this.traverse(path) first makes for a post-order traversal. - this.traverse(path); - - var node = path.value; - var shouldTransformAsync = node.async && !this.options.disableAsync; - - if (!node.generator && !shouldTransformAsync) { - return; - } - - this.reportChanged(); - - if (node.expression) { - // Transform expression lambdas into normal functions. - node.expression = false; - node.body = b.blockStatement([ - b.returnStatement(node.body) - ]); - } - - if (shouldTransformAsync) { - awaitVisitor.visit(path.get("body")); - } - - var outerBody = []; - var innerBody = []; - var bodyPath = path.get("body", "body"); - - bodyPath.each(function(childPath) { - var node = childPath.value; - if (node && node._blockHoist != null) { - outerBody.push(node); - } else { - innerBody.push(node); - } - }); - - if (outerBody.length > 0) { - // Only replace the inner body if we actually hoisted any statements - // to the outer body. - bodyPath.replace(innerBody); - } - - var outerFnExpr = getOuterFnExpr(path); - // Note that getOuterFnExpr has the side-effect of ensuring that the - // function has a name (so node.id will always be an Identifier), even - // if a temporary name has to be synthesized. - n.Identifier.assert(node.id); - var innerFnId = b.identifier(node.id.name + "$"); - var contextId = path.scope.declareTemporary("context$"); - var argsId = path.scope.declareTemporary("args$"); - - // Turn all declarations into vars, and replace the original - // declarations with equivalent assignment expressions. - var vars = hoist(path); - - var didRenameArguments = renameArguments(path, argsId); - if (didRenameArguments) { - vars = vars || b.variableDeclaration("var", []); - vars.declarations.push(b.variableDeclarator( - argsId, b.identifier("arguments") - )); - } - - var emitter = new Emitter(contextId); - emitter.explode(path.get("body")); - - if (vars && vars.declarations.length > 0) { - outerBody.push(vars); - } - - var wrapArgs = [ - emitter.getContextFunction(innerFnId), - // Async functions that are not generators don't care about the - // outer function because they don't need it to be marked and don't - // inherit from its .prototype. - node.generator ? outerFnExpr : b.literal(null), - b.thisExpression() - ]; - - var tryLocsList = emitter.getTryLocsList(); - if (tryLocsList) { - wrapArgs.push(tryLocsList); - } - - var wrapCall = b.callExpression( - runtimeProperty(shouldTransformAsync ? "async" : "wrap"), - wrapArgs - ); - - outerBody.push(b.returnStatement(wrapCall)); - node.body = b.blockStatement(outerBody); - - var wasGeneratorFunction = node.generator; - if (wasGeneratorFunction) { - node.generator = false; - } - - if (shouldTransformAsync) { - node.async = false; - } - - if (wasGeneratorFunction && - n.Expression.check(node)) { - return b.callExpression(runtimeProperty("mark"), [node]); - } - }, - - visitForOfStatement: function(path) { - this.traverse(path); - - var node = path.value; - var tempIterId = path.scope.declareTemporary("t$"); - var tempIterDecl = b.variableDeclarator( - tempIterId, - b.callExpression( - runtimeProperty("values"), - [node.right] - ) - ); - - var tempInfoId = path.scope.declareTemporary("t$"); - var tempInfoDecl = b.variableDeclarator(tempInfoId, null); - - var init = node.left; - var loopId; - if (n.VariableDeclaration.check(init)) { - loopId = init.declarations[0].id; - init.declarations.push(tempIterDecl, tempInfoDecl); - } else { - loopId = init; - init = b.variableDeclaration("var", [ - tempIterDecl, - tempInfoDecl - ]); - } - n.Identifier.assert(loopId); - - var loopIdAssignExprStmt = b.expressionStatement( - b.assignmentExpression( - "=", - loopId, - b.memberExpression( - tempInfoId, - b.identifier("value"), - false - ) - ) - ); - - if (n.BlockStatement.check(node.body)) { - node.body.body.unshift(loopIdAssignExprStmt); - } else { - node.body = b.blockStatement([ - loopIdAssignExprStmt, - node.body - ]); - } - - return b.forStatement( - init, - b.unaryExpression( - "!", - b.memberExpression( - b.assignmentExpression( - "=", - tempInfoId, - b.callExpression( - b.memberExpression( - tempIterId, - b.identifier("next"), - false - ), - [] - ) - ), - b.identifier("done"), - false - ) - ), - null, - node.body - ); - } -}); - -// Given a NodePath for a Function, return an Expression node that can be -// used to refer reliably to the function object from inside the function. -// This expression is essentially a replacement for arguments.callee, with -// the key advantage that it works in strict mode. -function getOuterFnExpr(funPath) { - var node = funPath.value; - n.Function.assert(node); - - if (node.generator && // Non-generator functions don't need to be marked. - n.FunctionDeclaration.check(node)) { - var pp = funPath.parent; - - while (pp && !(n.BlockStatement.check(pp.value) || - n.Program.check(pp.value))) { - pp = pp.parent; - } - - if (!pp) { - return node.id; - } - - var markDecl = getRuntimeMarkDecl(pp); - var markedArray = markDecl.declarations[0].id; - var funDeclIdArray = markDecl.declarations[0].init.callee.object; - n.ArrayExpression.assert(funDeclIdArray); - - var index = funDeclIdArray.elements.length; - funDeclIdArray.elements.push(node.id); - - return b.memberExpression( - markedArray, - b.literal(index), - true - ); - } - - return node.id || ( - node.id = funPath.scope.parent.declareTemporary("callee$") - ); -} - -function getRuntimeMarkDecl(blockPath) { - assert.ok(blockPath instanceof NodePath); - var block = blockPath.node; - isArray.assert(block.body); - - var info = getMarkInfo(block); - if (info.decl) { - return info.decl; - } - - info.decl = b.variableDeclaration("var", [ - b.variableDeclarator( - blockPath.scope.declareTemporary("marked"), - b.callExpression( - b.memberExpression( - b.arrayExpression([]), - b.identifier("map"), - false - ), - [runtimeProperty("mark")] - ) - ) - ]); - - for (var i = 0; i < block.body.length; ++i) { - if (!shouldNotHoistAbove(blockPath.get("body", i))) { - break; - } - } - - blockPath.get("body").insertAt(i, info.decl); - - return info.decl; -} - -function shouldNotHoistAbove(stmtPath) { - var value = stmtPath.value; - n.Statement.assert(value); - - // If the first statement is a "use strict" declaration, make sure to - // insert hoisted declarations afterwards. - return n.ExpressionStatement.check(value) && - n.Literal.check(value.expression) && - value.expression.value === "use strict"; -} - -function renameArguments(funcPath, argsId) { - assert.ok(funcPath instanceof types.NodePath); - var func = funcPath.value; - var didRenameArguments = false; - - recast.visit(funcPath, { - visitFunction: function(path) { - if (path.value === func) { - this.traverse(path); - } else { - return false; - } - }, - - visitIdentifier: function(path) { - if (path.value.name === "arguments" && - util.isReference(path)) { - path.replace(argsId); - didRenameArguments = true; - return false; - } - - this.traverse(path); - } - }); - - // If the traversal replaced any arguments references, then we need to - // alias the outer function's arguments binding (be it the implicit - // arguments object or some other parameter or variable) to the variable - // named by argsId. - return didRenameArguments; -} - -var awaitVisitor = types.PathVisitor.fromMethodsObject({ - visitFunction: function(path) { - return false; // Don't descend into nested function scopes. - }, - - visitAwaitExpression: function(path) { - // Convert await and await* expressions to yield expressions. - var argument = path.value.argument; - - // If the parser supports await* syntax using a boolean .all property - // (#171), desugar that syntax to yield Promise.all(argument). - if (path.value.all) { - argument = b.callExpression( - b.memberExpression( - b.identifier("Promise"), - b.identifier("all"), - false - ), - [argument] - ); - } - - // Transforming `await x` to `yield regeneratorRuntime.awrap(x)` - // causes the argument to be wrapped in such a way that the runtime - // can distinguish between awaited and merely yielded values. - return b.yieldExpression( - b.callExpression( - runtimeProperty("awrap"), - [argument] - ), - false - ); - } -}); - -},{"1":1,"2":2,"536":536,"537":537,"538":538,"541":541,"543":543,"568":568}],543:[function(_dereq_,module,exports){ -(function (__dirname){ -/** - * Copyright (c) 2014, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * https://raw.github.com/facebook/regenerator/master/LICENSE file. An - * additional grant of patent rights can be found in the PATENTS file in - * the same directory. - */ - -var assert = _dereq_(2); -var path = _dereq_(9); -var fs = _dereq_(1); -var through = _dereq_(1); -var transform = _dereq_(542).transform; -var utils = _dereq_(541); -var recast = _dereq_(568); -var types = recast.types; -var genOrAsyncFunExp = /\bfunction\s*\*|\basync\b/; -var blockBindingExp = /\b(let|const)\s+/; - -function exports(file, options) { - var data = []; - return through(write, end); - - function write(buf) { - data.push(buf); - } - - function end() { - this.queue(compile(data.join(""), options).code); - this.queue(null); - } -} - -// To get a writable stream for use as a browserify transform, call -// require("regenerator")(). -module.exports = exports; - -// To include the runtime globally in the current node process, call -// require("regenerator").runtime(). -function runtime() { - _dereq_(585); -} -exports.runtime = runtime; -runtime.path = path.join(__dirname, "runtime.js"); - -function compile(source, options) { - options = normalizeOptions(options); - - if (!genOrAsyncFunExp.test(source)) { - return { - // Shortcut: no generators or async functions to transform. - code: (options.includeRuntime === true ? fs.readFileSync( - path.join(__dirname, "runtime.js"), "utf-8" - ) + "\n" : "") + source - }; - } - - var recastOptions = getRecastOptions(options); - var ast = recast.parse(source, recastOptions); - var nodePath = new types.NodePath(ast); - var programPath = nodePath.get("program"); - - if (shouldVarify(source, options)) { - // Transpile let/const into var declarations. - varifyAst(programPath.node); - } - - transform(programPath, options); - - return recast.print(nodePath, recastOptions); -} - -function normalizeOptions(options) { - options = utils.defaults(options || {}, { - includeRuntime: false, - supportBlockBinding: true - }); - - if (!options.esprima) { - options.esprima = _dereq_(1); - } - - assert.ok( - /harmony/.test(options.esprima.version), - "Bad esprima version: " + options.esprima.version - ); - - return options; -} - -function getRecastOptions(options) { - var recastOptions = { - range: true - }; - - function copy(name) { - if (name in options) { - recastOptions[name] = options[name]; - } - } - - copy("esprima"); - copy("sourceFileName"); - copy("sourceMapName"); - copy("inputSourceMap"); - copy("sourceRoot"); - - return recastOptions; -} - -function shouldVarify(source, options) { - var supportBlockBinding = !!options.supportBlockBinding; - if (supportBlockBinding) { - if (!blockBindingExp.test(source)) { - supportBlockBinding = false; - } - } - - return supportBlockBinding; -} - -function varify(source, options) { - var recastOptions = getRecastOptions(normalizeOptions(options)); - var ast = recast.parse(source, recastOptions); - varifyAst(ast.program); - return recast.print(ast, recastOptions).code; -} - -function varifyAst(ast) { - types.namedTypes.Program.assert(ast); - - var defsResult = _dereq_(544)(ast, { - ast: true, - disallowUnknownReferences: false, - disallowDuplicated: false, - disallowVars: false, - loopClosures: "iife" - }); - - if (defsResult.errors) { - throw new Error(defsResult.errors.join("\n")) - } - - return ast; -} - -// Convenience for just translating let/const to var declarations. -exports.varify = varify; - -// Allow packages that depend on Regenerator to use the same copy of -// ast-types, in case multiple versions are installed by NPM. -exports.types = types; - -// Transforms a string of source code, returning the { code, map? } result -// from recast.print. -exports.compile = compile; - -// To modify an AST directly, call require("regenerator").transform(ast). -exports.transform = transform; - -}).call(this,"/node_modules/regenerator") -},{"1":1,"2":2,"541":541,"542":542,"544":544,"568":568,"585":585,"9":9}],544:[function(_dereq_,module,exports){ -"use strict"; - -var assert = _dereq_(2); -var is = _dereq_(555); -var fmt = _dereq_(554); -var stringmap = _dereq_(556); -var stringset = _dereq_(557); -var alter = _dereq_(550); -var traverse = _dereq_(552); -var breakable = _dereq_(553); -var Scope = _dereq_(548); -var error = _dereq_(545); -var getline = error.getline; -var options = _dereq_(547); -var Stats = _dereq_(549); -var jshint_vars = _dereq_(546); - - -function isConstLet(kind) { - return is.someof(kind, ["const", "let"]); -} - -function isVarConstLet(kind) { - return is.someof(kind, ["var", "const", "let"]); -} - -function isNonFunctionBlock(node) { - return node.type === "BlockStatement" && is.noneof(node.$parent.type, ["FunctionDeclaration", "FunctionExpression"]); -} - -function isForWithConstLet(node) { - return node.type === "ForStatement" && node.init && node.init.type === "VariableDeclaration" && isConstLet(node.init.kind); -} - -function isForInOfWithConstLet(node) { - return isForInOf(node) && node.left.type === "VariableDeclaration" && isConstLet(node.left.kind); -} - -function isForInOf(node) { - return is.someof(node.type, ["ForInStatement", "ForOfStatement"]); -} - -function isFunction(node) { - return is.someof(node.type, ["FunctionDeclaration", "FunctionExpression"]); -} - -function isLoop(node) { - return is.someof(node.type, ["ForStatement", "ForInStatement", "ForOfStatement", "WhileStatement", "DoWhileStatement"]); -} - -function isReference(node) { - var parent = node.$parent; - return node.$refToScope || - node.type === "Identifier" && - !(parent.type === "VariableDeclarator" && parent.id === node) && // var|let|const $ - !(parent.type === "MemberExpression" && parent.computed === false && parent.property === node) && // obj.$ - !(parent.type === "Property" && parent.key === node) && // {$: ...} - !(parent.type === "LabeledStatement" && parent.label === node) && // $: ... - !(parent.type === "CatchClause" && parent.param === node) && // catch($) - !(isFunction(parent) && parent.id === node) && // function $(.. - !(isFunction(parent) && is.someof(node, parent.params)) && // function f($).. - true; -} - -function isLvalue(node) { - return isReference(node) && - ((node.$parent.type === "AssignmentExpression" && node.$parent.left === node) || - (node.$parent.type === "UpdateExpression" && node.$parent.argument === node)); -} - -function createScopes(node, parent) { - assert(!node.$scope); - - node.$parent = parent; - node.$scope = node.$parent ? node.$parent.$scope : null; // may be overridden - - if (node.type === "Program") { - // Top-level program is a scope - // There's no block-scope under it - node.$scope = new Scope({ - kind: "hoist", - node: node, - parent: null, - }); - - } else if (isFunction(node)) { - // Function is a scope, with params in it - // There's no block-scope under it - - node.$scope = new Scope({ - kind: "hoist", - node: node, - parent: node.$parent.$scope, - }); - - // function has a name - if (node.id) { - assert(node.id.type === "Identifier"); - - if (node.type === "FunctionDeclaration") { - // Function name goes in parent scope for declared functions - node.$parent.$scope.add(node.id.name, "fun", node.id, null); - } else if (node.type === "FunctionExpression") { - // Function name goes in function's scope for named function expressions - node.$scope.add(node.id.name, "fun", node.id, null); - } else { - assert(false); - } - } - - node.params.forEach(function(param) { - node.$scope.add(param.name, "param", param, null); - }); - - } else if (node.type === "VariableDeclaration") { - // Variable declarations names goes in current scope - assert(isVarConstLet(node.kind)); - node.declarations.forEach(function(declarator) { - assert(declarator.type === "VariableDeclarator"); - var name = declarator.id.name; - if (options.disallowVars && node.kind === "var") { - error(getline(declarator), "var {0} is not allowed (use let or const)", name); - } - node.$scope.add(name, node.kind, declarator.id, declarator.range[1]); - }); - - } else if (isForWithConstLet(node) || isForInOfWithConstLet(node)) { - // For(In/Of) loop with const|let declaration is a scope, with declaration in it - // There may be a block-scope under it - node.$scope = new Scope({ - kind: "block", - node: node, - parent: node.$parent.$scope, - }); - - } else if (isNonFunctionBlock(node)) { - // A block node is a scope unless parent is a function - node.$scope = new Scope({ - kind: "block", - node: node, - parent: node.$parent.$scope, - }); - - } else if (node.type === "CatchClause") { - var identifier = node.param; - - node.$scope = new Scope({ - kind: "catch-block", - node: node, - parent: node.$parent.$scope, - }); - node.$scope.add(identifier.name, "caught", identifier, null); - - // All hoist-scope keeps track of which variables that are propagated through, - // i.e. an reference inside the scope points to a declaration outside the scope. - // This is used to mark "taint" the name since adding a new variable in the scope, - // with a propagated name, would change the meaning of the existing references. - // - // catch(e) is special because even though e is a variable in its own scope, - // we want to make sure that catch(e){let e} is never transformed to - // catch(e){var e} (but rather var e$0). For that reason we taint the use of e - // in the closest hoist-scope, i.e. where var e$0 belongs. - node.$scope.closestHoistScope().markPropagates(identifier.name); - } -} - -function createTopScope(programScope, environments, globals) { - function inject(obj) { - for (var name in obj) { - var writeable = obj[name]; - var kind = (writeable ? "var" : "const"); - if (topScope.hasOwn(name)) { - topScope.remove(name); - } - topScope.add(name, kind, {loc: {start: {line: -1}}}, -1); - } - } - - var topScope = new Scope({ - kind: "hoist", - node: {}, - parent: null, - }); - - var complementary = { - undefined: false, - Infinity: false, - console: false, - }; - - inject(complementary); - inject(jshint_vars.reservedVars); - inject(jshint_vars.ecmaIdentifiers); - if (environments) { - environments.forEach(function(env) { - if (!jshint_vars[env]) { - error(-1, 'environment "{0}" not found', env); - } else { - inject(jshint_vars[env]); - } - }); - } - if (globals) { - inject(globals); - } - - // link it in - programScope.parent = topScope; - topScope.children.push(programScope); - - return topScope; -} - -function setupReferences(ast, allIdentifiers, opts) { - var analyze = (is.own(opts, "analyze") ? opts.analyze : true); - - function visit(node) { - if (!isReference(node)) { - return; - } - allIdentifiers.add(node.name); - - var scope = node.$scope.lookup(node.name); - if (analyze && !scope && options.disallowUnknownReferences) { - error(getline(node), "reference to unknown global variable {0}", node.name); - } - // check const and let for referenced-before-declaration - if (analyze && scope && is.someof(scope.getKind(node.name), ["const", "let"])) { - var allowedFromPos = scope.getFromPos(node.name); - var referencedAtPos = node.range[0]; - assert(is.finitenumber(allowedFromPos)); - assert(is.finitenumber(referencedAtPos)); - if (referencedAtPos < allowedFromPos) { - if (!node.$scope.hasFunctionScopeBetween(scope)) { - error(getline(node), "{0} is referenced before its declaration", node.name); - } - } - } - node.$refToScope = scope; - } - - traverse(ast, {pre: visit}); -} - -// TODO for loops init and body props are parallel to each other but init scope is outer that of body -// TODO is this a problem? - -function varify(ast, stats, allIdentifiers, changes) { - function unique(name) { - assert(allIdentifiers.has(name)); - for (var cnt = 0; ; cnt++) { - var genName = name + "$" + String(cnt); - if (!allIdentifiers.has(genName)) { - return genName; - } - } - } - - function renameDeclarations(node) { - if (node.type === "VariableDeclaration" && isConstLet(node.kind)) { - var hoistScope = node.$scope.closestHoistScope(); - var origScope = node.$scope; - - // text change const|let => var - changes.push({ - start: node.range[0], - end: node.range[0] + node.kind.length, - str: "var", - }); - - node.declarations.forEach(function(declarator) { - assert(declarator.type === "VariableDeclarator"); - var name = declarator.id.name; - - stats.declarator(node.kind); - - // rename if - // 1) name already exists in hoistScope, or - // 2) name is already propagated (passed) through hoistScope or manually tainted - var rename = (origScope !== hoistScope && - (hoistScope.hasOwn(name) || hoistScope.doesPropagate(name))); - - var newName = (rename ? unique(name) : name); - - origScope.remove(name); - hoistScope.add(newName, "var", declarator.id, declarator.range[1]); - - origScope.moves = origScope.moves || stringmap(); - origScope.moves.set(name, { - name: newName, - scope: hoistScope, - }); - - allIdentifiers.add(newName); - - if (newName !== name) { - stats.rename(name, newName, getline(declarator)); - - declarator.id.originalName = name; - declarator.id.name = newName; - - // textchange var x => var x$1 - changes.push({ - start: declarator.id.range[0], - end: declarator.id.range[1], - str: newName, - }); - } - }); - - // ast change const|let => var - node.kind = "var"; - } - } - - function renameReferences(node) { - if (!node.$refToScope) { - return; - } - var move = node.$refToScope.moves && node.$refToScope.moves.get(node.name); - if (!move) { - return; - } - node.$refToScope = move.scope; - - if (node.name !== move.name) { - node.originalName = node.name; - node.name = move.name; - - if (node.alterop) { - // node has no range because it is the result of another alter operation - var existingOp = null; - for (var i = 0; i < changes.length; i++) { - var op = changes[i]; - if (op.node === node) { - existingOp = op; - break; - } - } - assert(existingOp); - - // modify op - existingOp.str = move.name; - } else { - changes.push({ - start: node.range[0], - end: node.range[1], - str: move.name, - }); - } - } - } - - traverse(ast, {pre: renameDeclarations}); - traverse(ast, {pre: renameReferences}); - ast.$scope.traverse({pre: function(scope) { - delete scope.moves; - }}); -} - - -function detectLoopClosures(ast) { - traverse(ast, {pre: visit}); - - function detectIifyBodyBlockers(body, node) { - return breakable(function(brk) { - traverse(body, {pre: function(n) { - // if we hit an inner function of the loop body, don't traverse further - if (isFunction(n)) { - return false; - } - - var err = true; // reset to false in else-statement below - var msg = "loop-variable {0} is captured by a loop-closure that can't be transformed due to use of {1} at line {2}"; - if (n.type === "BreakStatement") { - error(getline(node), msg, node.name, "break", getline(n)); - } else if (n.type === "ContinueStatement") { - error(getline(node), msg, node.name, "continue", getline(n)); - } else if (n.type === "ReturnStatement") { - error(getline(node), msg, node.name, "return", getline(n)); - } else if (n.type === "YieldExpression") { - error(getline(node), msg, node.name, "yield", getline(n)); - } else if (n.type === "Identifier" && n.name === "arguments") { - error(getline(node), msg, node.name, "arguments", getline(n)); - } else if (n.type === "VariableDeclaration" && n.kind === "var") { - error(getline(node), msg, node.name, "var", getline(n)); - } else { - err = false; - } - if (err) { - brk(true); // break traversal - } - }}); - return false; - }); - } - - function visit(node) { - // forbidden pattern: - // * * * * - var loopNode = null; - if (isReference(node) && node.$refToScope && isConstLet(node.$refToScope.getKind(node.name))) { - // traverse nodes up towards root from constlet-def - // if we hit a function (before a loop) - ok! - // if we hit a loop - maybe-ouch - // if we reach root - ok! - for (var n = node.$refToScope.node; ; ) { - if (isFunction(n)) { - // we're ok (function-local) - return; - } else if (isLoop(n)) { - loopNode = n; - // maybe not ok (between loop and function) - break; - } - n = n.$parent; - if (!n) { - // ok (reached root) - return; - } - } - - assert(isLoop(loopNode)); - - // traverse scopes from reference-scope up towards definition-scope - // if we hit a function, ouch! - var defScope = node.$refToScope; - var generateIIFE = (options.loopClosures === "iife"); - - for (var s = node.$scope; s; s = s.parent) { - if (s === defScope) { - // we're ok - return; - } else if (isFunction(s.node)) { - // not ok (there's a function between the reference and definition) - // may be transformable via IIFE - - if (!generateIIFE) { - var msg = "loop-variable {0} is captured by a loop-closure. Tried \"loopClosures\": \"iife\" in defs-config.json?"; - return error(getline(node), msg, node.name); - } - - // here be dragons - // for (let x = ..; .. ; ..) { (function(){x})() } is forbidden because of current - // spec and VM status - if (loopNode.type === "ForStatement" && defScope.node === loopNode) { - var declarationNode = defScope.getNode(node.name); - return error(getline(declarationNode), "Not yet specced ES6 feature. {0} is declared in for-loop header and then captured in loop closure", declarationNode.name); - } - - // speak now or forever hold your peace - if (detectIifyBodyBlockers(loopNode.body, node)) { - // error already generated - return; - } - - // mark loop for IIFE-insertion - loopNode.$iify = true; - } - } - } - } -} - -function transformLoopClosures(root, ops, options) { - function insertOp(pos, str, node) { - var op = { - start: pos, - end: pos, - str: str, - } - if (node) { - op.node = node; - } - ops.push(op); - } - - traverse(root, {pre: function(node) { - if (!node.$iify) { - return; - } - - var hasBlock = (node.body.type === "BlockStatement"); - - var insertHead = (hasBlock ? - node.body.range[0] + 1 : // just after body { - node.body.range[0]); // just before existing expression - var insertFoot = (hasBlock ? - node.body.range[1] - 1 : // just before body } - node.body.range[1]); // just after existing expression - - var forInName = (isForInOf(node) && node.left.declarations[0].id.name);; - var iifeHead = fmt("(function({0}){", forInName ? forInName : ""); - var iifeTail = fmt("}).call(this{0});", forInName ? ", " + forInName : ""); - - // modify AST - var iifeFragment = options.parse(iifeHead + iifeTail); - var iifeExpressionStatement = iifeFragment.body[0]; - var iifeBlockStatement = iifeExpressionStatement.expression.callee.object.body; - - if (hasBlock) { - var forBlockStatement = node.body; - var tmp = forBlockStatement.body; - forBlockStatement.body = [iifeExpressionStatement]; - iifeBlockStatement.body = tmp; - } else { - var tmp$0 = node.body; - node.body = iifeExpressionStatement; - iifeBlockStatement.body[0] = tmp$0; - } - - // create ops - insertOp(insertHead, iifeHead); - - if (forInName) { - insertOp(insertFoot, "}).call(this, "); - - var args = iifeExpressionStatement.expression.arguments; - var iifeArgumentIdentifier = args[1]; - iifeArgumentIdentifier.alterop = true; - insertOp(insertFoot, forInName, iifeArgumentIdentifier); - - insertOp(insertFoot, ");"); - } else { - insertOp(insertFoot, iifeTail); - } - }}); -} - -function detectConstAssignment(ast) { - traverse(ast, {pre: function(node) { - if (isLvalue(node)) { - var scope = node.$scope.lookup(node.name); - if (scope && scope.getKind(node.name) === "const") { - error(getline(node), "can't assign to const variable {0}", node.name); - } - } - }}); -} - -function detectConstantLets(ast) { - traverse(ast, {pre: function(node) { - if (isLvalue(node)) { - var scope = node.$scope.lookup(node.name); - if (scope) { - scope.markWrite(node.name); - } - } - }}); - - ast.$scope.detectUnmodifiedLets(); -} - -function setupScopeAndReferences(root, opts) { - // setup scopes - traverse(root, {pre: createScopes}); - var topScope = createTopScope(root.$scope, options.environments, options.globals); - - // allIdentifiers contains all declared and referenced vars - // collect all declaration names (including those in topScope) - var allIdentifiers = stringset(); - topScope.traverse({pre: function(scope) { - allIdentifiers.addMany(scope.decls.keys()); - }}); - - // setup node.$refToScope, check for errors. - // also collects all referenced names to allIdentifiers - setupReferences(root, allIdentifiers, opts); - return allIdentifiers; -} - -function cleanupTree(root) { - traverse(root, {pre: function(node) { - for (var prop in node) { - if (prop[0] === "$") { - delete node[prop]; - } - } - }}); -} - -function run(src, config) { - // alter the options singleton with user configuration - for (var key in config) { - options[key] = config[key]; - } - - var parsed; - - if (is.object(src)) { - if (!options.ast) { - return { - errors: [ - "Can't produce string output when input is an AST. " + - "Did you forget to set options.ast = true?" - ], - }; - } - - // Received an AST object as src, so no need to parse it. - parsed = src; - - } else if (is.string(src)) { - try { - parsed = options.parse(src, { - loc: true, - range: true, - }); - } catch (e) { - return { - errors: [ - fmt("line {0} column {1}: Error during input file parsing\n{2}\n{3}", - e.lineNumber, - e.column, - src.split("\n")[e.lineNumber - 1], - fmt.repeat(" ", e.column - 1) + "^") - ], - }; - } - - } else { - return { - errors: ["Input was neither an AST object nor a string."], - }; - } - - var ast = parsed; - - // TODO detect unused variables (never read) - error.reset(); - - var allIdentifiers = setupScopeAndReferences(ast, {}); - - // static analysis passes - detectLoopClosures(ast); - detectConstAssignment(ast); - //detectConstantLets(ast); - - var changes = []; - transformLoopClosures(ast, changes, options); - - //ast.$scope.print(); process.exit(-1); - - if (error.errors.length >= 1) { - return { - errors: error.errors, - }; - } - - if (changes.length > 0) { - cleanupTree(ast); - allIdentifiers = setupScopeAndReferences(ast, {analyze: false}); - } - assert(error.errors.length === 0); - - // change constlet declarations to var, renamed if needed - // varify modifies the scopes and AST accordingly and - // returns a list of change fragments (to use with alter) - var stats = new Stats(); - varify(ast, stats, allIdentifiers, changes); - - if (options.ast) { - // return the modified AST instead of src code - // get rid of all added $ properties first, such as $parent and $scope - cleanupTree(ast); - return { - stats: stats, - ast: ast, - }; - } else { - // apply changes produced by varify and return the transformed src - var transformedSrc = alter(src, changes); - return { - stats: stats, - src: transformedSrc, - }; - } -} - -module.exports = run; - -},{"2":2,"545":545,"546":546,"547":547,"548":548,"549":549,"550":550,"552":552,"553":553,"554":554,"555":555,"556":556,"557":557}],545:[function(_dereq_,module,exports){ -"use strict"; - -var fmt = _dereq_(554); -var assert = _dereq_(2); - -function error(line, var_args) { - assert(arguments.length >= 2); - - var msg = (arguments.length === 2 ? - String(var_args) : fmt.apply(fmt, Array.prototype.slice.call(arguments, 1))); - - error.errors.push(line === -1 ? msg : fmt("line {0}: {1}", line, msg)); -} - -error.reset = function() { - error.errors = []; -}; - -error.getline = function(node) { - if (node && node.loc && node.loc.start) { - return node.loc.start.line; - } - return -1; -}; - -error.reset(); - -module.exports = error; - -},{"2":2,"554":554}],546:[function(_dereq_,module,exports){ -// jshint -W001 - -"use strict"; - -// Identifiers provided by the ECMAScript standard. - -exports.reservedVars = { - arguments : false, - NaN : false -}; - -exports.ecmaIdentifiers = { - Array : false, - Boolean : false, - Date : false, - decodeURI : false, - decodeURIComponent : false, - encodeURI : false, - encodeURIComponent : false, - Error : false, - "eval" : false, - EvalError : false, - Function : false, - hasOwnProperty : false, - isFinite : false, - isNaN : false, - JSON : false, - Math : false, - Map : false, - Number : false, - Object : false, - parseInt : false, - parseFloat : false, - RangeError : false, - ReferenceError : false, - RegExp : false, - Set : false, - String : false, - SyntaxError : false, - TypeError : false, - URIError : false, - WeakMap : false -}; - -// Global variables commonly provided by a web browser environment. - -exports.browser = { - ArrayBuffer : false, - ArrayBufferView : false, - Audio : false, - Blob : false, - addEventListener : false, - applicationCache : false, - atob : false, - blur : false, - btoa : false, - clearInterval : false, - clearTimeout : false, - close : false, - closed : false, - DataView : false, - DOMParser : false, - defaultStatus : false, - document : false, - Element : false, - event : false, - FileReader : false, - Float32Array : false, - Float64Array : false, - FormData : false, - focus : false, - frames : false, - getComputedStyle : false, - HTMLElement : false, - HTMLAnchorElement : false, - HTMLBaseElement : false, - HTMLBlockquoteElement: false, - HTMLBodyElement : false, - HTMLBRElement : false, - HTMLButtonElement : false, - HTMLCanvasElement : false, - HTMLDirectoryElement : false, - HTMLDivElement : false, - HTMLDListElement : false, - HTMLFieldSetElement : false, - HTMLFontElement : false, - HTMLFormElement : false, - HTMLFrameElement : false, - HTMLFrameSetElement : false, - HTMLHeadElement : false, - HTMLHeadingElement : false, - HTMLHRElement : false, - HTMLHtmlElement : false, - HTMLIFrameElement : false, - HTMLImageElement : false, - HTMLInputElement : false, - HTMLIsIndexElement : false, - HTMLLabelElement : false, - HTMLLayerElement : false, - HTMLLegendElement : false, - HTMLLIElement : false, - HTMLLinkElement : false, - HTMLMapElement : false, - HTMLMenuElement : false, - HTMLMetaElement : false, - HTMLModElement : false, - HTMLObjectElement : false, - HTMLOListElement : false, - HTMLOptGroupElement : false, - HTMLOptionElement : false, - HTMLParagraphElement : false, - HTMLParamElement : false, - HTMLPreElement : false, - HTMLQuoteElement : false, - HTMLScriptElement : false, - HTMLSelectElement : false, - HTMLStyleElement : false, - HTMLTableCaptionElement: false, - HTMLTableCellElement : false, - HTMLTableColElement : false, - HTMLTableElement : false, - HTMLTableRowElement : false, - HTMLTableSectionElement: false, - HTMLTextAreaElement : false, - HTMLTitleElement : false, - HTMLUListElement : false, - HTMLVideoElement : false, - history : false, - Int16Array : false, - Int32Array : false, - Int8Array : false, - Image : false, - length : false, - localStorage : false, - location : false, - MessageChannel : false, - MessageEvent : false, - MessagePort : false, - moveBy : false, - moveTo : false, - MutationObserver : false, - name : false, - Node : false, - NodeFilter : false, - navigator : false, - onbeforeunload : true, - onblur : true, - onerror : true, - onfocus : true, - onload : true, - onresize : true, - onunload : true, - open : false, - openDatabase : false, - opener : false, - Option : false, - parent : false, - print : false, - removeEventListener : false, - resizeBy : false, - resizeTo : false, - screen : false, - scroll : false, - scrollBy : false, - scrollTo : false, - sessionStorage : false, - setInterval : false, - setTimeout : false, - SharedWorker : false, - status : false, - top : false, - Uint16Array : false, - Uint32Array : false, - Uint8Array : false, - Uint8ClampedArray : false, - WebSocket : false, - window : false, - Worker : false, - XMLHttpRequest : false, - XMLSerializer : false, - XPathEvaluator : false, - XPathException : false, - XPathExpression : false, - XPathNamespace : false, - XPathNSResolver : false, - XPathResult : false -}; - -exports.devel = { - alert : false, - confirm: false, - console: false, - Debug : false, - opera : false, - prompt : false -}; - -exports.worker = { - importScripts: true, - postMessage : true, - self : true -}; - -// Widely adopted global names that are not part of ECMAScript standard -exports.nonstandard = { - escape : false, - unescape: false -}; - -// Globals provided by popular JavaScript environments. - -exports.couch = { - "require" : false, - respond : false, - getRow : false, - emit : false, - send : false, - start : false, - sum : false, - log : false, - exports : false, - module : false, - provides : false -}; - -exports.node = { - __filename : false, - __dirname : false, - Buffer : false, - DataView : false, - console : false, - exports : true, // In Node it is ok to exports = module.exports = foo(); - GLOBAL : false, - global : false, - module : false, - process : false, - require : false, - setTimeout : false, - clearTimeout : false, - setInterval : false, - clearInterval: false -}; - -exports.phantom = { - phantom : true, - require : true, - WebPage : true -}; - -exports.rhino = { - defineClass : false, - deserialize : false, - gc : false, - help : false, - importPackage: false, - "java" : false, - load : false, - loadClass : false, - print : false, - quit : false, - readFile : false, - readUrl : false, - runCommand : false, - seal : false, - serialize : false, - spawn : false, - sync : false, - toint32 : false, - version : false -}; - -exports.wsh = { - ActiveXObject : true, - Enumerator : true, - GetObject : true, - ScriptEngine : true, - ScriptEngineBuildVersion : true, - ScriptEngineMajorVersion : true, - ScriptEngineMinorVersion : true, - VBArray : true, - WSH : true, - WScript : true, - XDomainRequest : true -}; - -// Globals provided by popular JavaScript libraries. - -exports.dojo = { - dojo : false, - dijit : false, - dojox : false, - define : false, - "require": false -}; - -exports.jquery = { - "$" : false, - jQuery : false -}; - -exports.mootools = { - "$" : false, - "$$" : false, - Asset : false, - Browser : false, - Chain : false, - Class : false, - Color : false, - Cookie : false, - Core : false, - Document : false, - DomReady : false, - DOMEvent : false, - DOMReady : false, - Drag : false, - Element : false, - Elements : false, - Event : false, - Events : false, - Fx : false, - Group : false, - Hash : false, - HtmlTable : false, - Iframe : false, - IframeShim : false, - InputValidator: false, - instanceOf : false, - Keyboard : false, - Locale : false, - Mask : false, - MooTools : false, - Native : false, - Options : false, - OverText : false, - Request : false, - Scroller : false, - Slick : false, - Slider : false, - Sortables : false, - Spinner : false, - Swiff : false, - Tips : false, - Type : false, - typeOf : false, - URI : false, - Window : false -}; - -exports.prototypejs = { - "$" : false, - "$$" : false, - "$A" : false, - "$F" : false, - "$H" : false, - "$R" : false, - "$break" : false, - "$continue" : false, - "$w" : false, - Abstract : false, - Ajax : false, - Class : false, - Enumerable : false, - Element : false, - Event : false, - Field : false, - Form : false, - Hash : false, - Insertion : false, - ObjectRange : false, - PeriodicalExecuter: false, - Position : false, - Prototype : false, - Selector : false, - Template : false, - Toggle : false, - Try : false, - Autocompleter : false, - Builder : false, - Control : false, - Draggable : false, - Draggables : false, - Droppables : false, - Effect : false, - Sortable : false, - SortableObserver : false, - Sound : false, - Scriptaculous : false -}; - -exports.yui = { - YUI : false, - Y : false, - YUI_config: false -}; - - -},{}],547:[function(_dereq_,module,exports){ -// default configuration - -module.exports = { - disallowVars: false, - disallowDuplicated: true, - disallowUnknownReferences: true, - parse: _dereq_(1).parse, -}; - -},{"1":1}],548:[function(_dereq_,module,exports){ -"use strict"; - -var assert = _dereq_(2); -var stringmap = _dereq_(556); -var stringset = _dereq_(557); -var is = _dereq_(555); -var fmt = _dereq_(554); -var error = _dereq_(545); -var getline = error.getline; -var options = _dereq_(547); - -function Scope(args) { - assert(is.someof(args.kind, ["hoist", "block", "catch-block"])); - assert(is.object(args.node)); - assert(args.parent === null || is.object(args.parent)); - - // kind === "hoist": function scopes, program scope, injected globals - // kind === "block": ES6 block scopes - // kind === "catch-block": catch block scopes - this.kind = args.kind; - - // the AST node the block corresponds to - this.node = args.node; - - // parent scope - this.parent = args.parent; - - // children scopes for easier traversal (populated internally) - this.children = []; - - // scope declarations. decls[variable_name] = { - // kind: "fun" for functions, - // "param" for function parameters, - // "caught" for catch parameter - // "var", - // "const", - // "let" - // node: the AST node the declaration corresponds to - // from: source code index from which it is visible at earliest - // (only stored for "const", "let" [and "var"] nodes) - // } - this.decls = stringmap(); - - // names of all declarations within this scope that was ever written - // TODO move to decls.w? - // TODO create corresponding read? - this.written = stringset(); - - // names of all variables declared outside this hoist scope but - // referenced in this scope (immediately or in child). - // only stored on hoist scopes for efficiency - // (because we currently generate lots of empty block scopes) - this.propagates = (this.kind === "hoist" ? stringset() : null); - - // scopes register themselves with their parents for easier traversal - if (this.parent) { - this.parent.children.push(this); - } -} - -Scope.prototype.print = function(indent) { - indent = indent || 0; - var scope = this; - var names = this.decls.keys().map(function(name) { - return fmt("{0} [{1}]", name, scope.decls.get(name).kind); - }).join(", "); - var propagates = this.propagates ? this.propagates.items().join(", ") : ""; - console.log(fmt("{0}{1}: {2}. propagates: {3}", fmt.repeat(" ", indent), this.node.type, names, propagates)); - this.children.forEach(function(c) { - c.print(indent + 2); - }); -}; - -Scope.prototype.add = function(name, kind, node, referableFromPos) { - assert(is.someof(kind, ["fun", "param", "var", "caught", "const", "let"])); - - function isConstLet(kind) { - return is.someof(kind, ["const", "let"]); - } - - var scope = this; - - // search nearest hoist-scope for fun, param and var's - // const, let and caught variables go directly in the scope (which may be hoist, block or catch-block) - if (is.someof(kind, ["fun", "param", "var"])) { - while (scope.kind !== "hoist") { - if (scope.decls.has(name) && isConstLet(scope.decls.get(name).kind)) { // could be caught - return error(getline(node), "{0} is already declared", name); - } - scope = scope.parent; - } - } - // name exists in scope and either new or existing kind is const|let => error - if (scope.decls.has(name) && (options.disallowDuplicated || isConstLet(scope.decls.get(name).kind) || isConstLet(kind))) { - return error(getline(node), "{0} is already declared", name); - } - - var declaration = { - kind: kind, - node: node, - }; - if (referableFromPos) { - assert(is.someof(kind, ["var", "const", "let"])); - declaration.from = referableFromPos; - } - scope.decls.set(name, declaration); -}; - -Scope.prototype.getKind = function(name) { - assert(is.string(name)); - var decl = this.decls.get(name); - return decl ? decl.kind : null; -}; - -Scope.prototype.getNode = function(name) { - assert(is.string(name)); - var decl = this.decls.get(name); - return decl ? decl.node : null; -}; - -Scope.prototype.getFromPos = function(name) { - assert(is.string(name)); - var decl = this.decls.get(name); - return decl ? decl.from : null; -}; - -Scope.prototype.hasOwn = function(name) { - return this.decls.has(name); -}; - -Scope.prototype.remove = function(name) { - return this.decls.remove(name); -}; - -Scope.prototype.doesPropagate = function(name) { - return this.propagates.has(name); -}; - -Scope.prototype.markPropagates = function(name) { - this.propagates.add(name); -}; - -Scope.prototype.closestHoistScope = function() { - var scope = this; - while (scope.kind !== "hoist") { - scope = scope.parent; - } - return scope; -}; - -Scope.prototype.hasFunctionScopeBetween = function(outer) { - function isFunction(node) { - return is.someof(node.type, ["FunctionDeclaration", "FunctionExpression"]); - } - - for (var scope = this; scope; scope = scope.parent) { - if (scope === outer) { - return false; - } - if (isFunction(scope.node)) { - return true; - } - } - - throw new Error("wasn't inner scope of outer"); -}; - -Scope.prototype.lookup = function(name) { - for (var scope = this; scope; scope = scope.parent) { - if (scope.decls.has(name)) { - return scope; - } else if (scope.kind === "hoist") { - scope.propagates.add(name); - } - } - return null; -}; - -Scope.prototype.markWrite = function(name) { - assert(is.string(name)); - this.written.add(name); -}; - -// detects let variables that are never modified (ignores top-level) -Scope.prototype.detectUnmodifiedLets = function() { - var outmost = this; - - function detect(scope) { - if (scope !== outmost) { - scope.decls.keys().forEach(function(name) { - if (scope.getKind(name) === "let" && !scope.written.has(name)) { - return error(getline(scope.getNode(name)), "{0} is declared as let but never modified so could be const", name); - } - }); - } - - scope.children.forEach(function(childScope) { - detect(childScope); - }); - } - detect(this); -}; - -Scope.prototype.traverse = function(options) { - options = options || {}; - var pre = options.pre; - var post = options.post; - - function visit(scope) { - if (pre) { - pre(scope); - } - scope.children.forEach(function(childScope) { - visit(childScope); - }); - if (post) { - post(scope); - } - } - - visit(this); -}; - -module.exports = Scope; - -},{"2":2,"545":545,"547":547,"554":554,"555":555,"556":556,"557":557}],549:[function(_dereq_,module,exports){ -var fmt = _dereq_(554); -var is = _dereq_(555); -var assert = _dereq_(2); - -function Stats() { - this.lets = 0; - this.consts = 0; - this.renames = []; -} - -Stats.prototype.declarator = function(kind) { - assert(is.someof(kind, ["const", "let"])); - if (kind === "const") { - this.consts++; - } else { - this.lets++; - } -}; - -Stats.prototype.rename = function(oldName, newName, line) { - this.renames.push({ - oldName: oldName, - newName: newName, - line: line, - }); -}; - -Stats.prototype.toString = function() { -// console.log("defs.js stats for file {0}:", filename) - - var renames = this.renames.map(function(r) { - return r; - }).sort(function(a, b) { - return a.line - b.line; - }); // sort a copy of renames - - var renameStr = renames.map(function(rename) { - return fmt("\nline {0}: {1} => {2}", rename.line, rename.oldName, rename.newName); - }).join(""); - - var sum = this.consts + this.lets; - var constlets = (sum === 0 ? - "can't calculate const coverage (0 consts, 0 lets)" : - fmt("{0}% const coverage ({1} consts, {2} lets)", - Math.floor(100 * this.consts / sum), this.consts, this.lets)); - - return constlets + renameStr + "\n"; -}; - -module.exports = Stats; - -},{"2":2,"554":554,"555":555}],550:[function(_dereq_,module,exports){ -// alter.js -// MIT licensed, see LICENSE file -// Copyright (c) 2013 Olov Lassus - -var assert = _dereq_(2); -var stableSort = _dereq_(551); - -// fragments is a list of {start: index, end: index, str: string to replace with} -function alter(str, fragments) { - "use strict"; - - var isArray = Array.isArray || function(v) { - return Object.prototype.toString.call(v) === "[object Array]"; - };; - - assert(typeof str === "string"); - assert(isArray(fragments)); - - // stableSort isn't in-place so no need to copy array first - var sortedFragments = stableSort(fragments, function(a, b) { - return a.start - b.start; - }); - - var outs = []; - - var pos = 0; - for (var i = 0; i < sortedFragments.length; i++) { - var frag = sortedFragments[i]; - - assert(pos <= frag.start); - assert(frag.start <= frag.end); - outs.push(str.slice(pos, frag.start)); - outs.push(frag.str); - pos = frag.end; - } - if (pos < str.length) { - outs.push(str.slice(pos)); - } - - return outs.join(""); -} - -if (typeof module !== "undefined" && typeof module.exports !== "undefined") { - module.exports = alter; -} - -},{"2":2,"551":551}],551:[function(_dereq_,module,exports){ -//! stable.js 0.1.5, https://github.com/Two-Screen/stable -//! © 2014 Angry Bytes and contributors. MIT licensed. - -(function() { - -// A stable array sort, because `Array#sort()` is not guaranteed stable. -// This is an implementation of merge sort, without recursion. - -var stable = function(arr, comp) { - return exec(arr.slice(), comp); -}; - -stable.inplace = function(arr, comp) { - var result = exec(arr, comp); - - // This simply copies back if the result isn't in the original array, - // which happens on an odd number of passes. - if (result !== arr) { - pass(result, null, arr.length, arr); - } - - return arr; -}; - -// Execute the sort using the input array and a second buffer as work space. -// Returns one of those two, containing the final result. -function exec(arr, comp) { - if (typeof(comp) !== 'function') { - comp = function(a, b) { - return String(a).localeCompare(b); - }; - } - - // Short-circuit when there's nothing to sort. - var len = arr.length; - if (len <= 1) { - return arr; - } - - // Rather than dividing input, simply iterate chunks of 1, 2, 4, 8, etc. - // Chunks are the size of the left or right hand in merge sort. - // Stop when the left-hand covers all of the array. - var buffer = new Array(len); - for (var chk = 1; chk < len; chk *= 2) { - pass(arr, comp, chk, buffer); - - var tmp = arr; - arr = buffer; - buffer = tmp; - } - - return arr; -} - -// Run a single pass with the given chunk size. -var pass = function(arr, comp, chk, result) { - var len = arr.length; - var i = 0; - // Step size / double chunk size. - var dbl = chk * 2; - // Bounds of the left and right chunks. - var l, r, e; - // Iterators over the left and right chunk. - var li, ri; - - // Iterate over pairs of chunks. - for (l = 0; l < len; l += dbl) { - r = l + chk; - e = r + chk; - if (r > len) r = len; - if (e > len) e = len; - - // Iterate both chunks in parallel. - li = l; - ri = r; - while (true) { - // Compare the chunks. - if (li < r && ri < e) { - // This works for a regular `sort()` compatible comparator, - // but also for a simple comparator like: `a > b` - if (comp(arr[li], arr[ri]) <= 0) { - result[i++] = arr[li++]; - } - else { - result[i++] = arr[ri++]; - } - } - // Nothing to compare, just flush what's left. - else if (li < r) { - result[i++] = arr[li++]; - } - else if (ri < e) { - result[i++] = arr[ri++]; - } - // Both iterators are at the chunk ends. - else { - break; - } - } - } -}; - -// Export using CommonJS or to the window. -if (typeof(module) !== 'undefined') { - module.exports = stable; -} -else { - window.stable = stable; -} - -})(); - -},{}],552:[function(_dereq_,module,exports){ -function traverse(root, options) { - "use strict"; - - options = options || {}; - var pre = options.pre; - var post = options.post; - var skipProperty = options.skipProperty; - - function visit(node, parent, prop, idx) { - if (!node || typeof node.type !== "string") { - return; - } - - var res = undefined; - if (pre) { - res = pre(node, parent, prop, idx); - } - - if (res !== false) { - for (var prop in node) { - if (skipProperty ? skipProperty(prop, node) : prop[0] === "$") { - continue; - } - - var child = node[prop]; - - if (Array.isArray(child)) { - for (var i = 0; i < child.length; i++) { - visit(child[i], node, prop, i); - } - } else { - visit(child, node, prop); - } - } - } - - if (post) { - post(node, parent, prop, idx); - } - } - - visit(root, null); -}; - -if (typeof module !== "undefined" && typeof module.exports !== "undefined") { - module.exports = traverse; -} - -},{}],553:[function(_dereq_,module,exports){ -// breakable.js -// MIT licensed, see LICENSE file -// Copyright (c) 2013-2014 Olov Lassus - -var breakable = (function() { - "use strict"; - - function Val(val, brk) { - this.val = val; - this.brk = brk; - } - - function make_brk() { - return function brk(val) { - throw new Val(val, brk); - }; - } - - function breakable(fn) { - var brk = make_brk(); - try { - return fn(brk); - } catch (e) { - if (e instanceof Val && e.brk === brk) { - return e.val; - } - throw e; - } - } - - return breakable; -})(); - -if (typeof module !== "undefined" && typeof module.exports !== "undefined") { - module.exports = breakable; -} - -},{}],554:[function(_dereq_,module,exports){ -// simple-fmt.js -// MIT licensed, see LICENSE file -// Copyright (c) 2013 Olov Lassus - -var fmt = (function() { - "use strict"; - - function fmt(str, var_args) { - var args = Array.prototype.slice.call(arguments, 1); - return str.replace(/\{(\d+)\}/g, function(s, match) { - return (match in args ? args[match] : s); - }); - } - - function obj(str, obj) { - return str.replace(/\{([_$a-zA-Z0-9][_$a-zA-Z0-9]*)\}/g, function(s, match) { - return (match in obj ? obj[match] : s); - }); - } - - function repeat(str, n) { - return (new Array(n + 1)).join(str); - } - - fmt.fmt = fmt; - fmt.obj = obj; - fmt.repeat = repeat; - return fmt; -})(); - -if (typeof module !== "undefined" && typeof module.exports !== "undefined") { - module.exports = fmt; -} - -},{}],555:[function(_dereq_,module,exports){ -// simple-is.js -// MIT licensed, see LICENSE file -// Copyright (c) 2013 Olov Lassus - -var is = (function() { - "use strict"; - - var hasOwnProperty = Object.prototype.hasOwnProperty; - var toString = Object.prototype.toString; - var _undefined = void 0; - - return { - nan: function(v) { - return v !== v; - }, - boolean: function(v) { - return typeof v === "boolean"; - }, - number: function(v) { - return typeof v === "number"; - }, - string: function(v) { - return typeof v === "string"; - }, - fn: function(v) { - return typeof v === "function"; - }, - object: function(v) { - return v !== null && typeof v === "object"; - }, - primitive: function(v) { - var t = typeof v; - return v === null || v === _undefined || - t === "boolean" || t === "number" || t === "string"; - }, - array: Array.isArray || function(v) { - return toString.call(v) === "[object Array]"; - }, - finitenumber: function(v) { - return typeof v === "number" && isFinite(v); - }, - someof: function(v, values) { - return values.indexOf(v) >= 0; - }, - noneof: function(v, values) { - return values.indexOf(v) === -1; - }, - own: function(obj, prop) { - return hasOwnProperty.call(obj, prop); - }, - }; -})(); - -if (typeof module !== "undefined" && typeof module.exports !== "undefined") { - module.exports = is; -} - -},{}],556:[function(_dereq_,module,exports){ -// stringmap.js -// MIT licensed, see LICENSE file -// Copyright (c) 2013 Olov Lassus - -var StringMap = (function() { - "use strict"; - - // to save us a few characters - var hasOwnProperty = Object.prototype.hasOwnProperty; - - var create = (function() { - function hasOwnEnumerableProps(obj) { - for (var prop in obj) { - if (hasOwnProperty.call(obj, prop)) { - return true; - } - } - return false; - } - // FF <= 3.6: - // o = {}; o.hasOwnProperty("__proto__" or "__count__" or "__parent__") => true - // o = {"__proto__": null}; Object.prototype.hasOwnProperty.call(o, "__proto__" or "__count__" or "__parent__") => false - function hasOwnPollutedProps(obj) { - return hasOwnProperty.call(obj, "__count__") || hasOwnProperty.call(obj, "__parent__"); - } - - var useObjectCreate = false; - if (typeof Object.create === "function") { - if (!hasOwnEnumerableProps(Object.create(null))) { - useObjectCreate = true; - } - } - if (useObjectCreate === false) { - if (hasOwnEnumerableProps({})) { - throw new Error("StringMap environment error 0, please file a bug at https://github.com/olov/stringmap/issues"); - } - } - // no throw yet means we can create objects without own enumerable props (safe-guard against VMs and shims) - - var o = (useObjectCreate ? Object.create(null) : {}); - var useProtoClear = false; - if (hasOwnPollutedProps(o)) { - o.__proto__ = null; - if (hasOwnEnumerableProps(o) || hasOwnPollutedProps(o)) { - throw new Error("StringMap environment error 1, please file a bug at https://github.com/olov/stringmap/issues"); - } - useProtoClear = true; - } - // no throw yet means we can create objects without own polluted props (safe-guard against VMs and shims) - - return function() { - var o = (useObjectCreate ? Object.create(null) : {}); - if (useProtoClear) { - o.__proto__ = null; - } - return o; - }; - })(); - - // stringmap ctor - function stringmap(optional_object) { - // use with or without new - if (!(this instanceof stringmap)) { - return new stringmap(optional_object); - } - this.obj = create(); - this.hasProto = false; // false (no __proto__ key) or true (has __proto__ key) - this.proto = undefined; // value for __proto__ key when hasProto is true, undefined otherwise - - if (optional_object) { - this.setMany(optional_object); - } - }; - - // primitive methods that deals with data representation - stringmap.prototype.has = function(key) { - // The type-check of key in has, get, set and delete is important because otherwise an object - // {toString: function() { return "__proto__"; }} can avoid the key === "__proto__" test. - // The alternative to type-checking would be to force string conversion, i.e. key = String(key); - if (typeof key !== "string") { - throw new Error("StringMap expected string key"); - } - return (key === "__proto__" ? - this.hasProto : - hasOwnProperty.call(this.obj, key)); - }; - - stringmap.prototype.get = function(key) { - if (typeof key !== "string") { - throw new Error("StringMap expected string key"); - } - return (key === "__proto__" ? - this.proto : - (hasOwnProperty.call(this.obj, key) ? this.obj[key] : undefined)); - }; - - stringmap.prototype.set = function(key, value) { - if (typeof key !== "string") { - throw new Error("StringMap expected string key"); - } - if (key === "__proto__") { - this.hasProto = true; - this.proto = value; - } else { - this.obj[key] = value; - } - }; - - stringmap.prototype.remove = function(key) { - if (typeof key !== "string") { - throw new Error("StringMap expected string key"); - } - var didExist = this.has(key); - if (key === "__proto__") { - this.hasProto = false; - this.proto = undefined; - } else { - delete this.obj[key]; - } - return didExist; - }; - - // alias remove to delete but beware: - // sm.delete("key"); // OK in ES5 and later - // sm['delete']("key"); // OK in all ES versions - // sm.remove("key"); // OK in all ES versions - stringmap.prototype['delete'] = stringmap.prototype.remove; - - stringmap.prototype.isEmpty = function() { - for (var key in this.obj) { - if (hasOwnProperty.call(this.obj, key)) { - return false; - } - } - return !this.hasProto; - }; - - stringmap.prototype.size = function() { - var len = 0; - for (var key in this.obj) { - if (hasOwnProperty.call(this.obj, key)) { - ++len; - } - } - return (this.hasProto ? len + 1 : len); - }; - - stringmap.prototype.keys = function() { - var keys = []; - for (var key in this.obj) { - if (hasOwnProperty.call(this.obj, key)) { - keys.push(key); - } - } - if (this.hasProto) { - keys.push("__proto__"); - } - return keys; - }; - - stringmap.prototype.values = function() { - var values = []; - for (var key in this.obj) { - if (hasOwnProperty.call(this.obj, key)) { - values.push(this.obj[key]); - } - } - if (this.hasProto) { - values.push(this.proto); - } - return values; - }; - - stringmap.prototype.items = function() { - var items = []; - for (var key in this.obj) { - if (hasOwnProperty.call(this.obj, key)) { - items.push([key, this.obj[key]]); - } - } - if (this.hasProto) { - items.push(["__proto__", this.proto]); - } - return items; - }; - - - // methods that rely on the above primitives - stringmap.prototype.setMany = function(object) { - if (object === null || (typeof object !== "object" && typeof object !== "function")) { - throw new Error("StringMap expected Object"); - } - for (var key in object) { - if (hasOwnProperty.call(object, key)) { - this.set(key, object[key]); - } - } - return this; - }; - - stringmap.prototype.merge = function(other) { - var keys = other.keys(); - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - this.set(key, other.get(key)); - } - return this; - }; - - stringmap.prototype.map = function(fn) { - var keys = this.keys(); - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - keys[i] = fn(this.get(key), key); // re-use keys array for results - } - return keys; - }; - - stringmap.prototype.forEach = function(fn) { - var keys = this.keys(); - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - fn(this.get(key), key); - } - }; - - stringmap.prototype.clone = function() { - var other = stringmap(); - return other.merge(this); - }; - - stringmap.prototype.toString = function() { - var self = this; - return "{" + this.keys().map(function(key) { - return JSON.stringify(key) + ":" + JSON.stringify(self.get(key)); - }).join(",") + "}"; - }; - - return stringmap; -})(); - -if (typeof module !== "undefined" && typeof module.exports !== "undefined") { - module.exports = StringMap; -} - -},{}],557:[function(_dereq_,module,exports){ -// stringset.js -// MIT licensed, see LICENSE file -// Copyright (c) 2013 Olov Lassus - -var StringSet = (function() { - "use strict"; - - // to save us a few characters - var hasOwnProperty = Object.prototype.hasOwnProperty; - - var create = (function() { - function hasOwnEnumerableProps(obj) { - for (var prop in obj) { - if (hasOwnProperty.call(obj, prop)) { - return true; - } - } - return false; - } - - // FF <= 3.6: - // o = {}; o.hasOwnProperty("__proto__" or "__count__" or "__parent__") => true - // o = {"__proto__": null}; Object.prototype.hasOwnProperty.call(o, "__proto__" or "__count__" or "__parent__") => false - function hasOwnPollutedProps(obj) { - return hasOwnProperty.call(obj, "__count__") || hasOwnProperty.call(obj, "__parent__"); - } - - var useObjectCreate = false; - if (typeof Object.create === "function") { - if (!hasOwnEnumerableProps(Object.create(null))) { - useObjectCreate = true; - } - } - if (useObjectCreate === false) { - if (hasOwnEnumerableProps({})) { - throw new Error("StringSet environment error 0, please file a bug at https://github.com/olov/stringset/issues"); - } - } - // no throw yet means we can create objects without own enumerable props (safe-guard against VMs and shims) - - var o = (useObjectCreate ? Object.create(null) : {}); - var useProtoClear = false; - if (hasOwnPollutedProps(o)) { - o.__proto__ = null; - if (hasOwnEnumerableProps(o) || hasOwnPollutedProps(o)) { - throw new Error("StringSet environment error 1, please file a bug at https://github.com/olov/stringset/issues"); - } - useProtoClear = true; - } - // no throw yet means we can create objects without own polluted props (safe-guard against VMs and shims) - - return function() { - var o = (useObjectCreate ? Object.create(null) : {}); - if (useProtoClear) { - o.__proto__ = null; - } - return o; - }; - })(); - - // stringset ctor - function stringset(optional_array) { - // use with or without new - if (!(this instanceof stringset)) { - return new stringset(optional_array); - } - this.obj = create(); - this.hasProto = false; // false (no __proto__ item) or true (has __proto__ item) - - if (optional_array) { - this.addMany(optional_array); - } - }; - - // primitive methods that deals with data representation - stringset.prototype.has = function(item) { - // The type-check of item in has, get, set and delete is important because otherwise an object - // {toString: function() { return "__proto__"; }} can avoid the item === "__proto__" test. - // The alternative to type-checking would be to force string conversion, i.e. item = String(item); - if (typeof item !== "string") { - throw new Error("StringSet expected string item"); - } - return (item === "__proto__" ? - this.hasProto : - hasOwnProperty.call(this.obj, item)); - }; - - stringset.prototype.add = function(item) { - if (typeof item !== "string") { - throw new Error("StringSet expected string item"); - } - if (item === "__proto__") { - this.hasProto = true; - } else { - this.obj[item] = true; - } - }; - - stringset.prototype.remove = function(item) { - if (typeof item !== "string") { - throw new Error("StringSet expected string item"); - } - var didExist = this.has(item); - if (item === "__proto__") { - this.hasProto = false; - } else { - delete this.obj[item]; - } - return didExist; - }; - - // alias remove to delete but beware: - // ss.delete("key"); // OK in ES5 and later - // ss['delete']("key"); // OK in all ES versions - // ss.remove("key"); // OK in all ES versions - stringset.prototype['delete'] = stringset.prototype.remove; - - stringset.prototype.isEmpty = function() { - for (var item in this.obj) { - if (hasOwnProperty.call(this.obj, item)) { - return false; - } - } - return !this.hasProto; - }; - - stringset.prototype.size = function() { - var len = 0; - for (var item in this.obj) { - if (hasOwnProperty.call(this.obj, item)) { - ++len; - } - } - return (this.hasProto ? len + 1 : len); - }; - - stringset.prototype.items = function() { - var items = []; - for (var item in this.obj) { - if (hasOwnProperty.call(this.obj, item)) { - items.push(item); - } - } - if (this.hasProto) { - items.push("__proto__"); - } - return items; - }; - - - // methods that rely on the above primitives - stringset.prototype.addMany = function(items) { - if (!Array.isArray(items)) { - throw new Error("StringSet expected array"); - } - for (var i = 0; i < items.length; i++) { - this.add(items[i]); - } - return this; - }; - - stringset.prototype.merge = function(other) { - this.addMany(other.items()); - return this; - }; - - stringset.prototype.clone = function() { - var other = stringset(); - return other.merge(this); - }; - - stringset.prototype.toString = function() { - return "{" + this.items().map(JSON.stringify).join(",") + "}"; - }; - - return stringset; -})(); - -if (typeof module !== "undefined" && typeof module.exports !== "undefined") { - module.exports = StringSet; -} - -},{}],558:[function(_dereq_,module,exports){ -var assert = _dereq_(2); -var types = _dereq_(566); -var n = types.namedTypes; -var isArray = types.builtInTypes.array; -var isObject = types.builtInTypes.object; -var linesModule = _dereq_(560); -var fromString = linesModule.fromString; -var Lines = linesModule.Lines; -var concat = linesModule.concat; -var util = _dereq_(567); -var comparePos = util.comparePos; -var childNodesCacheKey = _dereq_(536).makeUniqueKey(); - -// TODO Move a non-caching implementation of this function into ast-types, -// and implement a caching wrapper function here. -function getSortedChildNodes(node, resultArray) { - if (!node) { - return; - } - - // The .loc checks below are sensitive to some of the problems that - // are fixed by this utility function. Specifically, if it decides to - // set node.loc to null, indicating that the node's .loc information - // is unreliable, then we don't want to add node to the resultArray. - util.fixFaultyLocations(node); - - if (resultArray) { - if (n.Node.check(node) && - n.SourceLocation.check(node.loc)) { - // This reverse insertion sort almost always takes constant - // time because we almost always (maybe always?) append the - // nodes in order anyway. - for (var i = resultArray.length - 1; i >= 0; --i) { - if (comparePos(resultArray[i].loc.end, - node.loc.start) <= 0) { - break; - } - } - resultArray.splice(i + 1, 0, node); - return; - } - } else if (node[childNodesCacheKey]) { - return node[childNodesCacheKey]; - } - - var names; - if (isArray.check(node)) { - names = Object.keys(node); - } else if (isObject.check(node)) { - names = types.getFieldNames(node); - } else { - return; - } - - if (!resultArray) { - Object.defineProperty(node, childNodesCacheKey, { - value: resultArray = [], - enumerable: false - }); - } - - for (var i = 0, nameCount = names.length; i < nameCount; ++i) { - getSortedChildNodes(node[names[i]], resultArray); - } - - return resultArray; -} - -// As efficiently as possible, decorate the comment object with -// .precedingNode, .enclosingNode, and/or .followingNode properties, at -// least one of which is guaranteed to be defined. -function decorateComment(node, comment) { - var childNodes = getSortedChildNodes(node); - - // Time to dust off the old binary search robes and wizard hat. - var left = 0, right = childNodes.length; - while (left < right) { - var middle = (left + right) >> 1; - var child = childNodes[middle]; - - if (comparePos(child.loc.start, comment.loc.start) <= 0 && - comparePos(comment.loc.end, child.loc.end) <= 0) { - // The comment is completely contained by this child node. - decorateComment(comment.enclosingNode = child, comment); - return; // Abandon the binary search at this level. - } - - if (comparePos(child.loc.end, comment.loc.start) <= 0) { - // This child node falls completely before the comment. - // Because we will never consider this node or any nodes - // before it again, this node must be the closest preceding - // node we have encountered so far. - var precedingNode = child; - left = middle + 1; - continue; - } - - if (comparePos(comment.loc.end, child.loc.start) <= 0) { - // This child node falls completely after the comment. - // Because we will never consider this node or any nodes after - // it again, this node must be the closest following node we - // have encountered so far. - var followingNode = child; - right = middle; - continue; - } - - throw new Error("Comment location overlaps with node location"); - } - - if (precedingNode) { - comment.precedingNode = precedingNode; - } - - if (followingNode) { - comment.followingNode = followingNode; - } -} - -exports.attach = function(comments, ast, lines) { - if (!isArray.check(comments)) { - return; - } - - var tiesToBreak = []; - - comments.forEach(function(comment) { - comment.loc.lines = lines; - decorateComment(ast, comment); - - var pn = comment.precedingNode; - var en = comment.enclosingNode; - var fn = comment.followingNode; - - if (pn && fn) { - var tieCount = tiesToBreak.length; - if (tieCount > 0) { - var lastTie = tiesToBreak[tieCount - 1]; - - assert.strictEqual( - lastTie.precedingNode === comment.precedingNode, - lastTie.followingNode === comment.followingNode - ); - - if (lastTie.followingNode !== comment.followingNode) { - breakTies(tiesToBreak, lines); - } - } - - tiesToBreak.push(comment); - - } else if (pn) { - // No contest: we have a trailing comment. - breakTies(tiesToBreak, lines); - addTrailingComment(pn, comment); - - } else if (fn) { - // No contest: we have a leading comment. - breakTies(tiesToBreak, lines); - addLeadingComment(fn, comment); - - } else if (en) { - // The enclosing node has no child nodes at all, so what we - // have here is a dangling comment, e.g. [/* crickets */]. - breakTies(tiesToBreak, lines); - addDanglingComment(en, comment); - - } else { - throw new Error("AST contains no nodes at all?"); - } - }); - - breakTies(tiesToBreak, lines); - - comments.forEach(function(comment) { - // These node references were useful for breaking ties, but we - // don't need them anymore, and they create cycles in the AST that - // may lead to infinite recursion if we don't delete them here. - delete comment.precedingNode; - delete comment.enclosingNode; - delete comment.followingNode; - }); -}; - -function breakTies(tiesToBreak, lines) { - var tieCount = tiesToBreak.length; - if (tieCount === 0) { - return; - } - - var pn = tiesToBreak[0].precedingNode; - var fn = tiesToBreak[0].followingNode; - var gapEndPos = fn.loc.start; - - // Iterate backwards through tiesToBreak, examining the gaps - // between the tied comments. In order to qualify as leading, a - // comment must be separated from fn by an unbroken series of - // whitespace-only gaps (or other comments). - for (var indexOfFirstLeadingComment = tieCount; - indexOfFirstLeadingComment > 0; - --indexOfFirstLeadingComment) { - var comment = tiesToBreak[indexOfFirstLeadingComment - 1]; - assert.strictEqual(comment.precedingNode, pn); - assert.strictEqual(comment.followingNode, fn); - - var gap = lines.sliceString(comment.loc.end, gapEndPos); - if (/\S/.test(gap)) { - // The gap string contained something other than whitespace. - break; - } - - gapEndPos = comment.loc.start; - } - - while (indexOfFirstLeadingComment <= tieCount && - (comment = tiesToBreak[indexOfFirstLeadingComment]) && - // If the comment is a //-style comment and indented more - // deeply than the node itself, reconsider it as trailing. - comment.type === "Line" && - comment.loc.start.column > fn.loc.start.column) { - ++indexOfFirstLeadingComment; - } - - tiesToBreak.forEach(function(comment, i) { - if (i < indexOfFirstLeadingComment) { - addTrailingComment(pn, comment); - } else { - addLeadingComment(fn, comment); - } - }); - - tiesToBreak.length = 0; -} - -function addCommentHelper(node, comment) { - var comments = node.comments || (node.comments = []); - comments.push(comment); -} - -function addLeadingComment(node, comment) { - comment.leading = true; - comment.trailing = false; - addCommentHelper(node, comment); -} - -function addDanglingComment(node, comment) { - comment.leading = false; - comment.trailing = false; - addCommentHelper(node, comment); -} - -function addTrailingComment(node, comment) { - comment.leading = false; - comment.trailing = true; - addCommentHelper(node, comment); -} - -function printLeadingComment(commentPath, print) { - var comment = commentPath.getValue(); - n.Comment.assert(comment); - - var loc = comment.loc; - var lines = loc && loc.lines; - var parts = [print(commentPath)]; - - if (comment.trailing) { - // When we print trailing comments as leading comments, we don't - // want to bring any trailing spaces along. - parts.push("\n"); - - } else if (lines instanceof Lines) { - var trailingSpace = lines.slice( - loc.end, - lines.skipSpaces(loc.end) - ); - - if (trailingSpace.length === 1) { - // If the trailing space contains no newlines, then we want to - // preserve it exactly as we found it. - parts.push(trailingSpace); - } else { - // If the trailing space contains newlines, then replace it - // with just that many newlines, with all other spaces removed. - parts.push(new Array(trailingSpace.length).join("\n")); - } - - } else { - parts.push("\n"); - } - - return concat(parts); -} - -function printTrailingComment(commentPath, print) { - var comment = commentPath.getValue(commentPath); - n.Comment.assert(comment); - - var loc = comment.loc; - var lines = loc && loc.lines; - var parts = []; - - if (lines instanceof Lines) { - var fromPos = lines.skipSpaces(loc.start, true) || lines.firstPos(); - var leadingSpace = lines.slice(fromPos, loc.start); - - if (leadingSpace.length === 1) { - // If the leading space contains no newlines, then we want to - // preserve it exactly as we found it. - parts.push(leadingSpace); - } else { - // If the leading space contains newlines, then replace it - // with just that many newlines, sans all other spaces. - parts.push(new Array(leadingSpace.length).join("\n")); - } - } - - parts.push(print(commentPath)); - - return concat(parts); -} - -exports.printComments = function(path, print) { - var value = path.getValue(); - var innerLines = print(path); - var comments = n.Node.check(value) && - types.getFieldValue(value, "comments"); - - if (!comments || comments.length === 0) { - return innerLines; - } - - var leadingParts = []; - var trailingParts = [innerLines]; - - path.each(function(commentPath) { - var comment = commentPath.getValue(); - var leading = types.getFieldValue(comment, "leading"); - var trailing = types.getFieldValue(comment, "trailing"); - - if (leading || (trailing && comment.type !== "Block")) { - leadingParts.push(printLeadingComment(commentPath, print)); - } else if (trailing) { - assert.strictEqual(comment.type, "Block"); - trailingParts.push(printTrailingComment(commentPath, print)); - } - }, "comments"); - - leadingParts.push.apply(leadingParts, trailingParts); - return concat(leadingParts); -}; - -},{"2":2,"536":536,"560":560,"566":566,"567":567}],559:[function(_dereq_,module,exports){ -var assert = _dereq_(2); -var types = _dereq_(566); -var n = types.namedTypes; -var Node = n.Node; -var isArray = types.builtInTypes.array; -var isNumber = types.builtInTypes.number; - -function FastPath(value) { - assert.ok(this instanceof FastPath); - this.stack = [value]; -} - -var FPp = FastPath.prototype; -module.exports = FastPath; - -// Static convenience function for coercing a value to a FastPath. -FastPath.from = function(obj) { - if (obj instanceof FastPath) { - // Return a defensive copy of any existing FastPath instances. - return obj.copy(); - } - - if (obj instanceof types.NodePath) { - // For backwards compatibility, unroll NodePath instances into - // lightweight FastPath [..., name, value] stacks. - var copy = Object.create(FastPath.prototype); - var stack = [obj.value]; - for (var pp; (pp = obj.parentPath); obj = pp) - stack.push(obj.name, pp.value); - copy.stack = stack.reverse(); - return copy; - } - - // Otherwise use obj as the value of the new FastPath instance. - return new FastPath(obj); -}; - -FPp.copy = function copy() { - var copy = Object.create(FastPath.prototype); - copy.stack = this.stack.slice(0); - return copy; -}; - -// The name of the current property is always the penultimate element of -// this.stack, and always a String. -FPp.getName = function getName() { - var s = this.stack; - var len = s.length; - if (len > 1) { - return s[len - 2]; - } - // Since the name is always a string, null is a safe sentinel value to - // return if we do not know the name of the (root) value. - return null; -}; - -// The value of the current property is always the final element of -// this.stack. -FPp.getValue = function getValue() { - var s = this.stack; - return s[s.length - 1]; -}; - -function getNodeHelper(path, count) { - var s = path.stack; - - for (var i = s.length - 1; i >= 0; i -= 2) { - var value = s[i]; - if (n.Node.check(value) && --count < 0) { - return value; - } - } - - return null; -} - -FPp.getNode = function getNode(count) { - return getNodeHelper(this, ~~count); -}; - -FPp.getParentNode = function getParentNode(count) { - return getNodeHelper(this, ~~count + 1); -}; - -// The length of the stack can be either even or odd, depending on whether -// or not we have a name for the root value. The difference between the -// index of the root value and the index of the final value is always -// even, though, which allows us to return the root value in constant time -// (i.e. without iterating backwards through the stack). -FPp.getRootValue = function getRootValue() { - var s = this.stack; - if (s.length % 2 === 0) { - return s[1]; - } - return s[0]; -}; - -// Temporarily push properties named by string arguments given after the -// callback function onto this.stack, then call the callback with a -// reference to this (modified) FastPath object. Note that the stack will -// be restored to its original state after the callback is finished, so it -// is probably a mistake to retain a reference to the path. -FPp.call = function call(callback/*, name1, name2, ... */) { - var s = this.stack; - var origLen = s.length; - var value = s[origLen - 1]; - var argc = arguments.length; - for (var i = 1; i < argc; ++i) { - var name = arguments[i]; - value = value[name]; - s.push(name, value); - } - var result = callback(this); - s.length = origLen; - return result; -}; - -// Similar to FastPath.prototype.call, except that the value obtained by -// accessing this.getValue()[name1][name2]... should be array-like. The -// callback will be called with a reference to this path object for each -// element of the array. -FPp.each = function each(callback/*, name1, name2, ... */) { - var s = this.stack; - var origLen = s.length; - var value = s[origLen - 1]; - var argc = arguments.length; - - for (var i = 1; i < argc; ++i) { - var name = arguments[i]; - value = value[name]; - s.push(name, value); - } - - for (var i = 0; i < value.length; ++i) { - if (i in value) { - s.push(i, value[i]); - // If the callback needs to know the value of i, call - // path.getName(), assuming path is the parameter name. - callback(this); - s.length -= 2; - } - } - - s.length = origLen; -}; - -// Similar to FastPath.prototype.each, except that the results of the -// callback function invocations are stored in an array and returned at -// the end of the iteration. -FPp.map = function map(callback/*, name1, name2, ... */) { - var s = this.stack; - var origLen = s.length; - var value = s[origLen - 1]; - var argc = arguments.length; - - for (var i = 1; i < argc; ++i) { - var name = arguments[i]; - value = value[name]; - s.push(name, value); - } - - var result = new Array(value.length); - - for (var i = 0; i < value.length; ++i) { - if (i in value) { - s.push(i, value[i]); - result[i] = callback(this, i); - s.length -= 2; - } - } - - s.length = origLen; - - return result; -}; - -// Inspired by require("ast-types").NodePath.prototype.needsParens, but -// more efficient because we're iterating backwards through a stack. -FPp.needsParens = function(assumeExpressionContext) { - var parent = this.getParentNode(); - if (!parent) { - return false; - } - - var name = this.getName(); - var node = this.getNode(); - - // If the value of this path is some child of a Node and not a Node - // itself, then it doesn't need parentheses. Only Node objects (in - // fact, only Expression nodes) need parentheses. - if (this.getValue() !== node) { - return false; - } - - // Only expressions need parentheses. - if (!n.Expression.check(node)) { - return false; - } - - // Identifiers never need parentheses. - if (node.type === "Identifier") { - return false; - } - - if (parent.type === "ParenthesizedExpression") { - return false; - } - - switch (node.type) { - case "UnaryExpression": - case "SpreadElement": - case "SpreadProperty": - return parent.type === "MemberExpression" - && name === "object" - && parent.object === node; - - case "BinaryExpression": - case "LogicalExpression": - switch (parent.type) { - case "CallExpression": - return name === "callee" - && parent.callee === node; - - case "UnaryExpression": - case "SpreadElement": - case "SpreadProperty": - return true; - - case "MemberExpression": - return name === "object" - && parent.object === node; - - case "BinaryExpression": - case "LogicalExpression": - var po = parent.operator; - var pp = PRECEDENCE[po]; - var no = node.operator; - var np = PRECEDENCE[no]; - - if (pp > np) { - return true; - } - - if (pp === np && name === "right") { - assert.strictEqual(parent.right, node); - return true; - } - - default: - return false; - } - - case "SequenceExpression": - switch (parent.type) { - case "ForStatement": - // Although parentheses wouldn't hurt around sequence - // expressions in the head of for loops, traditional style - // dictates that e.g. i++, j++ should not be wrapped with - // parentheses. - return false; - - case "ExpressionStatement": - return name !== "expression"; - - default: - // Otherwise err on the side of overparenthesization, adding - // explicit exceptions above if this proves overzealous. - return true; - } - - case "YieldExpression": - switch (parent.type) { - case "BinaryExpression": - case "LogicalExpression": - case "UnaryExpression": - case "SpreadElement": - case "SpreadProperty": - case "CallExpression": - case "MemberExpression": - case "NewExpression": - case "ConditionalExpression": - case "YieldExpression": - return true; - - default: - return false; - } - - case "Literal": - return parent.type === "MemberExpression" - && isNumber.check(node.value) - && name === "object" - && parent.object === node; - - case "AssignmentExpression": - case "ConditionalExpression": - switch (parent.type) { - case "UnaryExpression": - case "SpreadElement": - case "SpreadProperty": - case "BinaryExpression": - case "LogicalExpression": - return true; - - case "CallExpression": - return name === "callee" - && parent.callee === node; - - case "ConditionalExpression": - return name === "test" - && parent.test === node; - - case "MemberExpression": - return name === "object" - && parent.object === node; - - default: - return false; - } - - case "ArrowFunctionExpression": - return isBinary(parent); - - case "ObjectExpression": - if (parent.type === "ArrowFunctionExpression" && - name === "body") { - return true; - } - - default: - if (parent.type === "NewExpression" && - name === "callee" && - parent.callee === node) { - return containsCallExpression(node); - } - } - - if (assumeExpressionContext !== true && - !this.canBeFirstInStatement() && - this.firstInStatement()) - return true; - - return false; -}; - -function isBinary(node) { - return n.BinaryExpression.check(node) - || n.LogicalExpression.check(node); -} - -function isUnaryLike(node) { - return n.UnaryExpression.check(node) - // I considered making SpreadElement and SpreadProperty subtypes - // of UnaryExpression, but they're not really Expression nodes. - || (n.SpreadElement && n.SpreadElement.check(node)) - || (n.SpreadProperty && n.SpreadProperty.check(node)); -} - -var PRECEDENCE = {}; -[["||"], - ["&&"], - ["|"], - ["^"], - ["&"], - ["==", "===", "!=", "!=="], - ["<", ">", "<=", ">=", "in", "instanceof"], - [">>", "<<", ">>>"], - ["+", "-"], - ["*", "/", "%"] -].forEach(function(tier, i) { - tier.forEach(function(op) { - PRECEDENCE[op] = i; - }); -}); - -function containsCallExpression(node) { - if (n.CallExpression.check(node)) { - return true; - } - - if (isArray.check(node)) { - return node.some(containsCallExpression); - } - - if (n.Node.check(node)) { - return types.someField(node, function(name, child) { - return containsCallExpression(child); - }); - } - - return false; -} - -FPp.canBeFirstInStatement = function() { - var node = this.getNode(); - return !n.FunctionExpression.check(node) - && !n.ObjectExpression.check(node); -}; - -FPp.firstInStatement = function() { - var s = this.stack; - var parentName, parent; - var childName, child; - - for (var i = s.length - 1; i >= 0; i -= 2) { - if (n.Node.check(s[i])) { - childName = parentName; - child = parent; - parentName = s[i - 1]; - parent = s[i]; - } - - if (!parent || !child) { - continue; - } - - if (n.BlockStatement.check(parent) && - parentName === "body" && - childName === 0) { - assert.strictEqual(parent.body[0], child); - return true; - } - - if (n.ExpressionStatement.check(parent) && - childName === "expression") { - assert.strictEqual(parent.expression, child); - return true; - } - - if (n.SequenceExpression.check(parent) && - parentName === "expressions" && - childName === 0) { - assert.strictEqual(parent.expressions[0], child); - continue; - } - - if (n.CallExpression.check(parent) && - childName === "callee") { - assert.strictEqual(parent.callee, child); - continue; - } - - if (n.MemberExpression.check(parent) && - childName === "object") { - assert.strictEqual(parent.object, child); - continue; - } - - if (n.ConditionalExpression.check(parent) && - childName === "test") { - assert.strictEqual(parent.test, child); - continue; - } - - if (isBinary(parent) && - childName === "left") { - assert.strictEqual(parent.left, child); - continue; - } - - if (n.UnaryExpression.check(parent) && - !parent.prefix && - childName === "argument") { - assert.strictEqual(parent.argument, child); - continue; - } - - return false; - } - - return true; -}; - -},{"2":2,"566":566}],560:[function(_dereq_,module,exports){ -var assert = _dereq_(2); -var sourceMap = _dereq_(607); -var normalizeOptions = _dereq_(562).normalize; -var secretKey = _dereq_(536).makeUniqueKey(); -var types = _dereq_(566); -var isString = types.builtInTypes.string; -var comparePos = _dereq_(567).comparePos; -var Mapping = _dereq_(561); - -// Goals: -// 1. Minimize new string creation. -// 2. Keep (de)identation O(lines) time. -// 3. Permit negative indentations. -// 4. Enforce immutability. -// 5. No newline characters. - -function getSecret(lines) { - return lines[secretKey]; -} - -function Lines(infos, sourceFileName) { - assert.ok(this instanceof Lines); - assert.ok(infos.length > 0); - - if (sourceFileName) { - isString.assert(sourceFileName); - } else { - sourceFileName = null; - } - - Object.defineProperty(this, secretKey, { - value: { - infos: infos, - mappings: [], - name: sourceFileName, - cachedSourceMap: null - } - }); - - if (sourceFileName) { - getSecret(this).mappings.push(new Mapping(this, { - start: this.firstPos(), - end: this.lastPos() - })); - } -} - -// Exposed for instanceof checks. The fromString function should be used -// to create new Lines objects. -exports.Lines = Lines; -var Lp = Lines.prototype; - -// These properties used to be assigned to each new object in the Lines -// constructor, but we can more efficiently stuff them into the secret and -// let these lazy accessors compute their values on-the-fly. -Object.defineProperties(Lp, { - length: { - get: function() { - return getSecret(this).infos.length; - } - }, - - name: { - get: function() { - return getSecret(this).name; - } - } -}); - -function copyLineInfo(info) { - return { - line: info.line, - indent: info.indent, - sliceStart: info.sliceStart, - sliceEnd: info.sliceEnd - }; -} - -var fromStringCache = {}; -var hasOwn = fromStringCache.hasOwnProperty; -var maxCacheKeyLen = 10; - -function countSpaces(spaces, tabWidth) { - var count = 0; - var len = spaces.length; - - for (var i = 0; i < len; ++i) { - switch (spaces.charCodeAt(i)) { - case 9: // '\t' - assert.strictEqual(typeof tabWidth, "number"); - assert.ok(tabWidth > 0); - - var next = Math.ceil(count / tabWidth) * tabWidth; - if (next === count) { - count += tabWidth; - } else { - count = next; - } - - break; - - case 11: // '\v' - case 12: // '\f' - case 13: // '\r' - case 0xfeff: // zero-width non-breaking space - // These characters contribute nothing to indentation. - break; - - case 32: // ' ' - default: // Treat all other whitespace like ' '. - count += 1; - break; - } - } - - return count; -} -exports.countSpaces = countSpaces; - -var leadingSpaceExp = /^\s*/; - -// As specified here: http://www.ecma-international.org/ecma-262/6.0/#sec-line-terminators -var lineTerminatorSeqExp = - /\u000D\u000A|\u000D(?!\u000A)|\u000A|\u2028|\u2029/; - -/** - * @param {Object} options - Options object that configures printing. - */ -function fromString(string, options) { - if (string instanceof Lines) - return string; - - string += ""; - - var tabWidth = options && options.tabWidth; - var tabless = string.indexOf("\t") < 0; - var cacheable = !options && tabless && (string.length <= maxCacheKeyLen); - - assert.ok(tabWidth || tabless, "No tab width specified but encountered tabs in string\n" + string); - - if (cacheable && hasOwn.call(fromStringCache, string)) - return fromStringCache[string]; - - var lines = new Lines(string.split(lineTerminatorSeqExp).map(function(line) { - var spaces = leadingSpaceExp.exec(line)[0]; - return { - line: line, - indent: countSpaces(spaces, tabWidth), - sliceStart: spaces.length, - sliceEnd: line.length - }; - }), normalizeOptions(options).sourceFileName); - - if (cacheable) - fromStringCache[string] = lines; - - return lines; -} -exports.fromString = fromString; - -function isOnlyWhitespace(string) { - return !/\S/.test(string); -} - -Lp.toString = function(options) { - return this.sliceString(this.firstPos(), this.lastPos(), options); -}; - -Lp.getSourceMap = function(sourceMapName, sourceRoot) { - if (!sourceMapName) { - // Although we could make up a name or generate an anonymous - // source map, instead we assume that any consumer who does not - // provide a name does not actually want a source map. - return null; - } - - var targetLines = this; - - function updateJSON(json) { - json = json || {}; - - isString.assert(sourceMapName); - json.file = sourceMapName; - - if (sourceRoot) { - isString.assert(sourceRoot); - json.sourceRoot = sourceRoot; - } - - return json; - } - - var secret = getSecret(targetLines); - if (secret.cachedSourceMap) { - // Since Lines objects are immutable, we can reuse any source map - // that was previously generated. Nevertheless, we return a new - // JSON object here to protect the cached source map from outside - // modification. - return updateJSON(secret.cachedSourceMap.toJSON()); - } - - var smg = new sourceMap.SourceMapGenerator(updateJSON()); - var sourcesToContents = {}; - - secret.mappings.forEach(function(mapping) { - var sourceCursor = mapping.sourceLines.skipSpaces( - mapping.sourceLoc.start - ) || mapping.sourceLines.lastPos(); - - var targetCursor = targetLines.skipSpaces( - mapping.targetLoc.start - ) || targetLines.lastPos(); - - while (comparePos(sourceCursor, mapping.sourceLoc.end) < 0 && - comparePos(targetCursor, mapping.targetLoc.end) < 0) { - - var sourceChar = mapping.sourceLines.charAt(sourceCursor); - var targetChar = targetLines.charAt(targetCursor); - assert.strictEqual(sourceChar, targetChar); - - var sourceName = mapping.sourceLines.name; - - // Add mappings one character at a time for maximum resolution. - smg.addMapping({ - source: sourceName, - original: { line: sourceCursor.line, - column: sourceCursor.column }, - generated: { line: targetCursor.line, - column: targetCursor.column } - }); - - if (!hasOwn.call(sourcesToContents, sourceName)) { - var sourceContent = mapping.sourceLines.toString(); - smg.setSourceContent(sourceName, sourceContent); - sourcesToContents[sourceName] = sourceContent; - } - - targetLines.nextPos(targetCursor, true); - mapping.sourceLines.nextPos(sourceCursor, true); - } - }); - - secret.cachedSourceMap = smg; - - return smg.toJSON(); -}; - -Lp.bootstrapCharAt = function(pos) { - assert.strictEqual(typeof pos, "object"); - assert.strictEqual(typeof pos.line, "number"); - assert.strictEqual(typeof pos.column, "number"); - - var line = pos.line, - column = pos.column, - strings = this.toString().split(lineTerminatorSeqExp), - string = strings[line - 1]; - - if (typeof string === "undefined") - return ""; - - if (column === string.length && - line < strings.length) - return "\n"; - - if (column >= string.length) - return ""; - - return string.charAt(column); -}; - -Lp.charAt = function(pos) { - assert.strictEqual(typeof pos, "object"); - assert.strictEqual(typeof pos.line, "number"); - assert.strictEqual(typeof pos.column, "number"); - - var line = pos.line, - column = pos.column, - secret = getSecret(this), - infos = secret.infos, - info = infos[line - 1], - c = column; - - if (typeof info === "undefined" || c < 0) - return ""; - - var indent = this.getIndentAt(line); - if (c < indent) - return " "; - - c += info.sliceStart - indent; - - if (c === info.sliceEnd && - line < this.length) - return "\n"; - - if (c >= info.sliceEnd) - return ""; - - return info.line.charAt(c); -}; - -Lp.stripMargin = function(width, skipFirstLine) { - if (width === 0) - return this; - - assert.ok(width > 0, "negative margin: " + width); - - if (skipFirstLine && this.length === 1) - return this; - - var secret = getSecret(this); - - var lines = new Lines(secret.infos.map(function(info, i) { - if (info.line && (i > 0 || !skipFirstLine)) { - info = copyLineInfo(info); - info.indent = Math.max(0, info.indent - width); - } - return info; - })); - - if (secret.mappings.length > 0) { - var newMappings = getSecret(lines).mappings; - assert.strictEqual(newMappings.length, 0); - secret.mappings.forEach(function(mapping) { - newMappings.push(mapping.indent(width, skipFirstLine, true)); - }); - } - - return lines; -}; - -Lp.indent = function(by) { - if (by === 0) - return this; - - var secret = getSecret(this); - - var lines = new Lines(secret.infos.map(function(info) { - if (info.line) { - info = copyLineInfo(info); - info.indent += by; - } - return info - })); - - if (secret.mappings.length > 0) { - var newMappings = getSecret(lines).mappings; - assert.strictEqual(newMappings.length, 0); - secret.mappings.forEach(function(mapping) { - newMappings.push(mapping.indent(by)); - }); - } - - return lines; -}; - -Lp.indentTail = function(by) { - if (by === 0) - return this; - - if (this.length < 2) - return this; - - var secret = getSecret(this); - - var lines = new Lines(secret.infos.map(function(info, i) { - if (i > 0 && info.line) { - info = copyLineInfo(info); - info.indent += by; - } - - return info; - })); - - if (secret.mappings.length > 0) { - var newMappings = getSecret(lines).mappings; - assert.strictEqual(newMappings.length, 0); - secret.mappings.forEach(function(mapping) { - newMappings.push(mapping.indent(by, true)); - }); - } - - return lines; -}; - -Lp.getIndentAt = function(line) { - assert.ok(line >= 1, "no line " + line + " (line numbers start from 1)"); - var secret = getSecret(this), - info = secret.infos[line - 1]; - return Math.max(info.indent, 0); -}; - -Lp.guessTabWidth = function() { - var secret = getSecret(this); - if (hasOwn.call(secret, "cachedTabWidth")) { - return secret.cachedTabWidth; - } - - var counts = []; // Sparse array. - var lastIndent = 0; - - for (var line = 1, last = this.length; line <= last; ++line) { - var info = secret.infos[line - 1]; - var sliced = info.line.slice(info.sliceStart, info.sliceEnd); - - // Whitespace-only lines don't tell us much about the likely tab - // width of this code. - if (isOnlyWhitespace(sliced)) { - continue; - } - - var diff = Math.abs(info.indent - lastIndent); - counts[diff] = ~~counts[diff] + 1; - lastIndent = info.indent; - } - - var maxCount = -1; - var result = 2; - - for (var tabWidth = 1; - tabWidth < counts.length; - tabWidth += 1) { - if (hasOwn.call(counts, tabWidth) && - counts[tabWidth] > maxCount) { - maxCount = counts[tabWidth]; - result = tabWidth; - } - } - - return secret.cachedTabWidth = result; -}; - -Lp.isOnlyWhitespace = function() { - return isOnlyWhitespace(this.toString()); -}; - -Lp.isPrecededOnlyByWhitespace = function(pos) { - var secret = getSecret(this); - var info = secret.infos[pos.line - 1]; - var indent = Math.max(info.indent, 0); - - var diff = pos.column - indent; - if (diff <= 0) { - // If pos.column does not exceed the indentation amount, then - // there must be only whitespace before it. - return true; - } - - var start = info.sliceStart; - var end = Math.min(start + diff, info.sliceEnd); - var prefix = info.line.slice(start, end); - - return isOnlyWhitespace(prefix); -}; - -Lp.getLineLength = function(line) { - var secret = getSecret(this), - info = secret.infos[line - 1]; - return this.getIndentAt(line) + info.sliceEnd - info.sliceStart; -}; - -Lp.nextPos = function(pos, skipSpaces) { - var l = Math.max(pos.line, 0), - c = Math.max(pos.column, 0); - - if (c < this.getLineLength(l)) { - pos.column += 1; - - return skipSpaces - ? !!this.skipSpaces(pos, false, true) - : true; - } - - if (l < this.length) { - pos.line += 1; - pos.column = 0; - - return skipSpaces - ? !!this.skipSpaces(pos, false, true) - : true; - } - - return false; -}; - -Lp.prevPos = function(pos, skipSpaces) { - var l = pos.line, - c = pos.column; - - if (c < 1) { - l -= 1; - - if (l < 1) - return false; - - c = this.getLineLength(l); - - } else { - c = Math.min(c - 1, this.getLineLength(l)); - } - - pos.line = l; - pos.column = c; - - return skipSpaces - ? !!this.skipSpaces(pos, true, true) - : true; -}; - -Lp.firstPos = function() { - // Trivial, but provided for completeness. - return { line: 1, column: 0 }; -}; - -Lp.lastPos = function() { - return { - line: this.length, - column: this.getLineLength(this.length) - }; -}; - -Lp.skipSpaces = function(pos, backward, modifyInPlace) { - if (pos) { - pos = modifyInPlace ? pos : { - line: pos.line, - column: pos.column - }; - } else if (backward) { - pos = this.lastPos(); - } else { - pos = this.firstPos(); - } - - if (backward) { - while (this.prevPos(pos)) { - if (!isOnlyWhitespace(this.charAt(pos)) && - this.nextPos(pos)) { - return pos; - } - } - - return null; - - } else { - while (isOnlyWhitespace(this.charAt(pos))) { - if (!this.nextPos(pos)) { - return null; - } - } - - return pos; - } -}; - -Lp.trimLeft = function() { - var pos = this.skipSpaces(this.firstPos(), false, true); - return pos ? this.slice(pos) : emptyLines; -}; - -Lp.trimRight = function() { - var pos = this.skipSpaces(this.lastPos(), true, true); - return pos ? this.slice(this.firstPos(), pos) : emptyLines; -}; - -Lp.trim = function() { - var start = this.skipSpaces(this.firstPos(), false, true); - if (start === null) - return emptyLines; - - var end = this.skipSpaces(this.lastPos(), true, true); - assert.notStrictEqual(end, null); - - return this.slice(start, end); -}; - -Lp.eachPos = function(callback, startPos, skipSpaces) { - var pos = this.firstPos(); - - if (startPos) { - pos.line = startPos.line, - pos.column = startPos.column - } - - if (skipSpaces && !this.skipSpaces(pos, false, true)) { - return; // Encountered nothing but spaces. - } - - do callback.call(this, pos); - while (this.nextPos(pos, skipSpaces)); -}; - -Lp.bootstrapSlice = function(start, end) { - var strings = this.toString().split( - lineTerminatorSeqExp - ).slice( - start.line - 1, - end.line - ); - - strings.push(strings.pop().slice(0, end.column)); - strings[0] = strings[0].slice(start.column); - - return fromString(strings.join("\n")); -}; - -Lp.slice = function(start, end) { - if (!end) { - if (!start) { - // The client seems to want a copy of this Lines object, but - // Lines objects are immutable, so it's perfectly adequate to - // return the same object. - return this; - } - - // Slice to the end if no end position was provided. - end = this.lastPos(); - } - - var secret = getSecret(this); - var sliced = secret.infos.slice(start.line - 1, end.line); - - if (start.line === end.line) { - sliced[0] = sliceInfo(sliced[0], start.column, end.column); - } else { - assert.ok(start.line < end.line); - sliced[0] = sliceInfo(sliced[0], start.column); - sliced.push(sliceInfo(sliced.pop(), 0, end.column)); - } - - var lines = new Lines(sliced); - - if (secret.mappings.length > 0) { - var newMappings = getSecret(lines).mappings; - assert.strictEqual(newMappings.length, 0); - secret.mappings.forEach(function(mapping) { - var sliced = mapping.slice(this, start, end); - if (sliced) { - newMappings.push(sliced); - } - }, this); - } - - return lines; -}; - -function sliceInfo(info, startCol, endCol) { - var sliceStart = info.sliceStart; - var sliceEnd = info.sliceEnd; - var indent = Math.max(info.indent, 0); - var lineLength = indent + sliceEnd - sliceStart; - - if (typeof endCol === "undefined") { - endCol = lineLength; - } - - startCol = Math.max(startCol, 0); - endCol = Math.min(endCol, lineLength); - endCol = Math.max(endCol, startCol); - - if (endCol < indent) { - indent = endCol; - sliceEnd = sliceStart; - } else { - sliceEnd -= lineLength - endCol; - } - - lineLength = endCol; - lineLength -= startCol; - - if (startCol < indent) { - indent -= startCol; - } else { - startCol -= indent; - indent = 0; - sliceStart += startCol; - } - - assert.ok(indent >= 0); - assert.ok(sliceStart <= sliceEnd); - assert.strictEqual(lineLength, indent + sliceEnd - sliceStart); - - if (info.indent === indent && - info.sliceStart === sliceStart && - info.sliceEnd === sliceEnd) { - return info; - } - - return { - line: info.line, - indent: indent, - sliceStart: sliceStart, - sliceEnd: sliceEnd - }; -} - -Lp.bootstrapSliceString = function(start, end, options) { - return this.slice(start, end).toString(options); -}; - -Lp.sliceString = function(start, end, options) { - if (!end) { - if (!start) { - // The client seems to want a copy of this Lines object, but - // Lines objects are immutable, so it's perfectly adequate to - // return the same object. - return this; - } - - // Slice to the end if no end position was provided. - end = this.lastPos(); - } - - options = normalizeOptions(options); - - var infos = getSecret(this).infos; - var parts = []; - var tabWidth = options.tabWidth; - - for (var line = start.line; line <= end.line; ++line) { - var info = infos[line - 1]; - - if (line === start.line) { - if (line === end.line) { - info = sliceInfo(info, start.column, end.column); - } else { - info = sliceInfo(info, start.column); - } - } else if (line === end.line) { - info = sliceInfo(info, 0, end.column); - } - - var indent = Math.max(info.indent, 0); - - var before = info.line.slice(0, info.sliceStart); - if (options.reuseWhitespace && - isOnlyWhitespace(before) && - countSpaces(before, options.tabWidth) === indent) { - // Reuse original spaces if the indentation is correct. - parts.push(info.line.slice(0, info.sliceEnd)); - continue; - } - - var tabs = 0; - var spaces = indent; - - if (options.useTabs) { - tabs = Math.floor(indent / tabWidth); - spaces -= tabs * tabWidth; - } - - var result = ""; - - if (tabs > 0) { - result += new Array(tabs + 1).join("\t"); - } - - if (spaces > 0) { - result += new Array(spaces + 1).join(" "); - } - - result += info.line.slice(info.sliceStart, info.sliceEnd); - - parts.push(result); - } - - return parts.join(options.lineTerminator); -}; - -Lp.isEmpty = function() { - return this.length < 2 && this.getLineLength(1) < 1; -}; - -Lp.join = function(elements) { - var separator = this; - var separatorSecret = getSecret(separator); - var infos = []; - var mappings = []; - var prevInfo; - - function appendSecret(secret) { - if (secret === null) - return; - - if (prevInfo) { - var info = secret.infos[0]; - var indent = new Array(info.indent + 1).join(" "); - var prevLine = infos.length; - var prevColumn = Math.max(prevInfo.indent, 0) + - prevInfo.sliceEnd - prevInfo.sliceStart; - - prevInfo.line = prevInfo.line.slice( - 0, prevInfo.sliceEnd) + indent + info.line.slice( - info.sliceStart, info.sliceEnd); - - prevInfo.sliceEnd = prevInfo.line.length; - - if (secret.mappings.length > 0) { - secret.mappings.forEach(function(mapping) { - mappings.push(mapping.add(prevLine, prevColumn)); - }); - } - - } else if (secret.mappings.length > 0) { - mappings.push.apply(mappings, secret.mappings); - } - - secret.infos.forEach(function(info, i) { - if (!prevInfo || i > 0) { - prevInfo = copyLineInfo(info); - infos.push(prevInfo); - } - }); - } - - function appendWithSeparator(secret, i) { - if (i > 0) - appendSecret(separatorSecret); - appendSecret(secret); - } - - elements.map(function(elem) { - var lines = fromString(elem); - if (lines.isEmpty()) - return null; - return getSecret(lines); - }).forEach(separator.isEmpty() - ? appendSecret - : appendWithSeparator); - - if (infos.length < 1) - return emptyLines; - - var lines = new Lines(infos); - - getSecret(lines).mappings = mappings; - - return lines; -}; - -exports.concat = function(elements) { - return emptyLines.join(elements); -}; - -Lp.concat = function(other) { - var args = arguments, - list = [this]; - list.push.apply(list, args); - assert.strictEqual(list.length, args.length + 1); - return emptyLines.join(list); -}; - -// The emptyLines object needs to be created all the way down here so that -// Lines.prototype will be fully populated. -var emptyLines = fromString(""); - -},{"2":2,"536":536,"561":561,"562":562,"566":566,"567":567,"607":607}],561:[function(_dereq_,module,exports){ -var assert = _dereq_(2); -var types = _dereq_(566); -var isString = types.builtInTypes.string; -var isNumber = types.builtInTypes.number; -var SourceLocation = types.namedTypes.SourceLocation; -var Position = types.namedTypes.Position; -var linesModule = _dereq_(560); -var comparePos = _dereq_(567).comparePos; - -function Mapping(sourceLines, sourceLoc, targetLoc) { - assert.ok(this instanceof Mapping); - assert.ok(sourceLines instanceof linesModule.Lines); - SourceLocation.assert(sourceLoc); - - if (targetLoc) { - // In certain cases it's possible for targetLoc.{start,end}.column - // values to be negative, which technically makes them no longer - // valid SourceLocation nodes, so we need to be more forgiving. - assert.ok( - isNumber.check(targetLoc.start.line) && - isNumber.check(targetLoc.start.column) && - isNumber.check(targetLoc.end.line) && - isNumber.check(targetLoc.end.column) - ); - } else { - // Assume identity mapping if no targetLoc specified. - targetLoc = sourceLoc; - } - - Object.defineProperties(this, { - sourceLines: { value: sourceLines }, - sourceLoc: { value: sourceLoc }, - targetLoc: { value: targetLoc } - }); -} - -var Mp = Mapping.prototype; -module.exports = Mapping; - -Mp.slice = function(lines, start, end) { - assert.ok(lines instanceof linesModule.Lines); - Position.assert(start); - - if (end) { - Position.assert(end); - } else { - end = lines.lastPos(); - } - - var sourceLines = this.sourceLines; - var sourceLoc = this.sourceLoc; - var targetLoc = this.targetLoc; - - function skip(name) { - var sourceFromPos = sourceLoc[name]; - var targetFromPos = targetLoc[name]; - var targetToPos = start; - - if (name === "end") { - targetToPos = end; - } else { - assert.strictEqual(name, "start"); - } - - return skipChars( - sourceLines, sourceFromPos, - lines, targetFromPos, targetToPos - ); - } - - if (comparePos(start, targetLoc.start) <= 0) { - if (comparePos(targetLoc.end, end) <= 0) { - targetLoc = { - start: subtractPos(targetLoc.start, start.line, start.column), - end: subtractPos(targetLoc.end, start.line, start.column) - }; - - // The sourceLoc can stay the same because the contents of the - // targetLoc have not changed. - - } else if (comparePos(end, targetLoc.start) <= 0) { - return null; - - } else { - sourceLoc = { - start: sourceLoc.start, - end: skip("end") - }; - - targetLoc = { - start: subtractPos(targetLoc.start, start.line, start.column), - end: subtractPos(end, start.line, start.column) - }; - } - - } else { - if (comparePos(targetLoc.end, start) <= 0) { - return null; - } - - if (comparePos(targetLoc.end, end) <= 0) { - sourceLoc = { - start: skip("start"), - end: sourceLoc.end - }; - - targetLoc = { - // Same as subtractPos(start, start.line, start.column): - start: { line: 1, column: 0 }, - end: subtractPos(targetLoc.end, start.line, start.column) - }; - - } else { - sourceLoc = { - start: skip("start"), - end: skip("end") - }; - - targetLoc = { - // Same as subtractPos(start, start.line, start.column): - start: { line: 1, column: 0 }, - end: subtractPos(end, start.line, start.column) - }; - } - } - - return new Mapping(this.sourceLines, sourceLoc, targetLoc); -}; - -Mp.add = function(line, column) { - return new Mapping(this.sourceLines, this.sourceLoc, { - start: addPos(this.targetLoc.start, line, column), - end: addPos(this.targetLoc.end, line, column) - }); -}; - -function addPos(toPos, line, column) { - return { - line: toPos.line + line - 1, - column: (toPos.line === 1) - ? toPos.column + column - : toPos.column - }; -} - -Mp.subtract = function(line, column) { - return new Mapping(this.sourceLines, this.sourceLoc, { - start: subtractPos(this.targetLoc.start, line, column), - end: subtractPos(this.targetLoc.end, line, column) - }); -}; - -function subtractPos(fromPos, line, column) { - return { - line: fromPos.line - line + 1, - column: (fromPos.line === line) - ? fromPos.column - column - : fromPos.column - }; -} - -Mp.indent = function(by, skipFirstLine, noNegativeColumns) { - if (by === 0) { - return this; - } - - var targetLoc = this.targetLoc; - var startLine = targetLoc.start.line; - var endLine = targetLoc.end.line; - - if (skipFirstLine && startLine === 1 && endLine === 1) { - return this; - } - - targetLoc = { - start: targetLoc.start, - end: targetLoc.end - }; - - if (!skipFirstLine || startLine > 1) { - var startColumn = targetLoc.start.column + by; - targetLoc.start = { - line: startLine, - column: noNegativeColumns - ? Math.max(0, startColumn) - : startColumn - }; - } - - if (!skipFirstLine || endLine > 1) { - var endColumn = targetLoc.end.column + by; - targetLoc.end = { - line: endLine, - column: noNegativeColumns - ? Math.max(0, endColumn) - : endColumn - }; - } - - return new Mapping(this.sourceLines, this.sourceLoc, targetLoc); -}; - -function skipChars( - sourceLines, sourceFromPos, - targetLines, targetFromPos, targetToPos -) { - assert.ok(sourceLines instanceof linesModule.Lines); - assert.ok(targetLines instanceof linesModule.Lines); - Position.assert(sourceFromPos); - Position.assert(targetFromPos); - Position.assert(targetToPos); - - var targetComparison = comparePos(targetFromPos, targetToPos); - if (targetComparison === 0) { - // Trivial case: no characters to skip. - return sourceFromPos; - } - - if (targetComparison < 0) { - // Skipping forward. - - var sourceCursor = sourceLines.skipSpaces(sourceFromPos); - var targetCursor = targetLines.skipSpaces(targetFromPos); - - var lineDiff = targetToPos.line - targetCursor.line; - sourceCursor.line += lineDiff; - targetCursor.line += lineDiff; - - if (lineDiff > 0) { - // If jumping to later lines, reset columns to the beginnings - // of those lines. - sourceCursor.column = 0; - targetCursor.column = 0; - } else { - assert.strictEqual(lineDiff, 0); - } - - while (comparePos(targetCursor, targetToPos) < 0 && - targetLines.nextPos(targetCursor, true)) { - assert.ok(sourceLines.nextPos(sourceCursor, true)); - assert.strictEqual( - sourceLines.charAt(sourceCursor), - targetLines.charAt(targetCursor) - ); - } - - } else { - // Skipping backward. - - var sourceCursor = sourceLines.skipSpaces(sourceFromPos, true); - var targetCursor = targetLines.skipSpaces(targetFromPos, true); - - var lineDiff = targetToPos.line - targetCursor.line; - sourceCursor.line += lineDiff; - targetCursor.line += lineDiff; - - if (lineDiff < 0) { - // If jumping to earlier lines, reset columns to the ends of - // those lines. - sourceCursor.column = sourceLines.getLineLength(sourceCursor.line); - targetCursor.column = targetLines.getLineLength(targetCursor.line); - } else { - assert.strictEqual(lineDiff, 0); - } - - while (comparePos(targetToPos, targetCursor) < 0 && - targetLines.prevPos(targetCursor, true)) { - assert.ok(sourceLines.prevPos(sourceCursor, true)); - assert.strictEqual( - sourceLines.charAt(sourceCursor), - targetLines.charAt(targetCursor) - ); - } - } - - return sourceCursor; -} - -},{"2":2,"560":560,"566":566,"567":567}],562:[function(_dereq_,module,exports){ -var defaults = { - // If you want to use a different branch of esprima, or any other - // module that supports a .parse function, pass that module object to - // recast.parse as options.esprima. - esprima: _dereq_(1), - - // Number of spaces the pretty-printer should use per tab for - // indentation. If you do not pass this option explicitly, it will be - // (quite reliably!) inferred from the original code. - tabWidth: 4, - - // If you really want the pretty-printer to use tabs instead of - // spaces, make this option true. - useTabs: false, - - // The reprinting code leaves leading whitespace untouched unless it - // has to reindent a line, or you pass false for this option. - reuseWhitespace: true, - - // Override this option to use a different line terminator, e.g. \r\n. - lineTerminator: _dereq_(8).EOL, - - // Some of the pretty-printer code (such as that for printing function - // parameter lists) makes a valiant attempt to prevent really long - // lines. You can adjust the limit by changing this option; however, - // there is no guarantee that line length will fit inside this limit. - wrapColumn: 74, // Aspirational for now. - - // Pass a string as options.sourceFileName to recast.parse to tell the - // reprinter to keep track of reused code so that it can construct a - // source map automatically. - sourceFileName: null, - - // Pass a string as options.sourceMapName to recast.print, and - // (provided you passed options.sourceFileName earlier) the - // PrintResult of recast.print will have a .map property for the - // generated source map. - sourceMapName: null, - - // If provided, this option will be passed along to the source map - // generator as a root directory for relative source file paths. - sourceRoot: null, - - // If you provide a source map that was generated from a previous call - // to recast.print as options.inputSourceMap, the old source map will - // be composed with the new source map. - inputSourceMap: null, - - // If you want esprima to generate .range information (recast only - // uses .loc internally), pass true for this option. - range: false, - - // If you want esprima not to throw exceptions when it encounters - // non-fatal errors, keep this option true. - tolerant: true, - - // If you want to override the quotes used in string literals, specify - // either "single", "double", or "auto" here ("auto" will select the one - // which results in the shorter literal) - // Otherwise, the input marks will be preserved - quote: null, - - // If you want to print trailing commas in object literals, - // array expressions, functions calls and function definitions pass true - // for this option. - trailingComma: false, -}, hasOwn = defaults.hasOwnProperty; - -// Copy options and fill in default values. -exports.normalize = function(options) { - options = options || defaults; - - function get(key) { - return hasOwn.call(options, key) - ? options[key] - : defaults[key]; - } - - return { - tabWidth: +get("tabWidth"), - useTabs: !!get("useTabs"), - reuseWhitespace: !!get("reuseWhitespace"), - lineTerminator: get("lineTerminator"), - wrapColumn: Math.max(get("wrapColumn"), 0), - sourceFileName: get("sourceFileName"), - sourceMapName: get("sourceMapName"), - sourceRoot: get("sourceRoot"), - inputSourceMap: get("inputSourceMap"), - esprima: get("esprima"), - range: get("range"), - tolerant: get("tolerant"), - quote: get("quote"), - trailingComma: get("trailingComma"), - }; -}; - -},{"1":1,"8":8}],563:[function(_dereq_,module,exports){ -var assert = _dereq_(2); -var types = _dereq_(566); -var n = types.namedTypes; -var b = types.builders; -var isObject = types.builtInTypes.object; -var isArray = types.builtInTypes.array; -var isFunction = types.builtInTypes.function; -var Patcher = _dereq_(564).Patcher; -var normalizeOptions = _dereq_(562).normalize; -var fromString = _dereq_(560).fromString; -var attachComments = _dereq_(558).attach; -var util = _dereq_(567); - -exports.parse = function parse(source, options) { - options = normalizeOptions(options); - - var lines = fromString(source, options); - - var sourceWithoutTabs = lines.toString({ - tabWidth: options.tabWidth, - reuseWhitespace: false, - useTabs: false - }); - - var comments = []; - var program = options.esprima.parse(sourceWithoutTabs, { - loc: true, - locations: true, - range: options.range, - comment: true, - onComment: comments, - tolerant: options.tolerant, - ecmaVersion: 6, - sourceType: 'module' - }); - - program.loc = program.loc || { - start: lines.firstPos(), - end: lines.lastPos() - }; - - program.loc.lines = lines; - program.loc.indent = 0; - - // Expand the Program node's .loc to include all comments, since - // typically its .loc.start and .loc.end will coincide with those of - // the first and last statements, respectively, excluding any comments - // that fall outside that region. - var trueProgramLoc = util.getTrueLoc(program, lines); - program.loc.start = trueProgramLoc.start; - program.loc.end = trueProgramLoc.end; - - if (program.comments) { - comments = program.comments; - delete program.comments; - } - - // In order to ensure we reprint leading and trailing program - // comments, wrap the original Program node with a File node. - var file = b.file(program); - file.loc = { - lines: lines, - indent: 0, - start: lines.firstPos(), - end: lines.lastPos() - }; - - // Passing file.program here instead of just file means that initial - // comments will be attached to program.body[0] instead of program. - attachComments( - comments, - program.body.length ? file.program : file, - lines - ); - - // Return a copy of the original AST so that any changes made may be - // compared to the original. - return new TreeCopier(lines).copy(file); -}; - -function TreeCopier(lines) { - assert.ok(this instanceof TreeCopier); - this.lines = lines; - this.indent = 0; -} - -var TCp = TreeCopier.prototype; - -TCp.copy = function(node) { - if (isArray.check(node)) { - return node.map(this.copy, this); - } - - if (!isObject.check(node)) { - return node; - } - - util.fixFaultyLocations(node); - - var copy = Object.create(Object.getPrototypeOf(node), { - original: { // Provide a link from the copy to the original. - value: node, - configurable: false, - enumerable: false, - writable: true - } - }); - - var loc = node.loc; - var oldIndent = this.indent; - var newIndent = oldIndent; - - if (loc) { - // When node is a comment, we set node.loc.indent to - // node.loc.start.column so that, when/if we print the comment by - // itself, we can strip that much whitespace from the left margin - // of the comment. This only really matters for multiline Block - // comments, but it doesn't hurt for Line comments. - if (node.type === "Block" || node.type === "Line" || - this.lines.isPrecededOnlyByWhitespace(loc.start)) { - newIndent = this.indent = loc.start.column; - } - - loc.lines = this.lines; - loc.indent = newIndent; - } - - var keys = Object.keys(node); - var keyCount = keys.length; - for (var i = 0; i < keyCount; ++i) { - var key = keys[i]; - if (key === "loc") { - copy[key] = node[key]; - } else { - copy[key] = this.copy(node[key]); - } - } - - this.indent = oldIndent; - - return copy; -}; - -},{"2":2,"558":558,"560":560,"562":562,"564":564,"566":566,"567":567}],564:[function(_dereq_,module,exports){ -var assert = _dereq_(2); -var linesModule = _dereq_(560); -var types = _dereq_(566); -var getFieldValue = types.getFieldValue; -var Printable = types.namedTypes.Printable; -var Expression = types.namedTypes.Expression; -var SourceLocation = types.namedTypes.SourceLocation; -var util = _dereq_(567); -var comparePos = util.comparePos; -var FastPath = _dereq_(559); -var isObject = types.builtInTypes.object; -var isArray = types.builtInTypes.array; -var isString = types.builtInTypes.string; -var riskyAdjoiningCharExp = /[0-9a-z_$]/i; - -function Patcher(lines) { - assert.ok(this instanceof Patcher); - assert.ok(lines instanceof linesModule.Lines); - - var self = this, - replacements = []; - - self.replace = function(loc, lines) { - if (isString.check(lines)) - lines = linesModule.fromString(lines); - - replacements.push({ - lines: lines, - start: loc.start, - end: loc.end - }); - }; - - self.get = function(loc) { - // If no location is provided, return the complete Lines object. - loc = loc || { - start: { line: 1, column: 0 }, - end: { line: lines.length, - column: lines.getLineLength(lines.length) } - }; - - var sliceFrom = loc.start, - toConcat = []; - - function pushSlice(from, to) { - assert.ok(comparePos(from, to) <= 0); - toConcat.push(lines.slice(from, to)); - } - - replacements.sort(function(a, b) { - return comparePos(a.start, b.start); - }).forEach(function(rep) { - if (comparePos(sliceFrom, rep.start) > 0) { - // Ignore nested replacement ranges. - } else { - pushSlice(sliceFrom, rep.start); - toConcat.push(rep.lines); - sliceFrom = rep.end; - } - }); - - pushSlice(sliceFrom, loc.end); - - return linesModule.concat(toConcat); - }; -} -exports.Patcher = Patcher; - -var Pp = Patcher.prototype; - -Pp.tryToReprintComments = function(newNode, oldNode, print) { - var patcher = this; - - if (!newNode.comments && - !oldNode.comments) { - // We were (vacuously) able to reprint all the comments! - return true; - } - - var newPath = FastPath.from(newNode); - var oldPath = FastPath.from(oldNode); - - newPath.stack.push("comments", getSurroundingComments(newNode)); - oldPath.stack.push("comments", getSurroundingComments(oldNode)); - - var reprints = []; - var ableToReprintComments = - findArrayReprints(newPath, oldPath, reprints); - - // No need to pop anything from newPath.stack or oldPath.stack, since - // newPath and oldPath are fresh local variables. - - if (ableToReprintComments && reprints.length > 0) { - reprints.forEach(function(reprint) { - var oldComment = reprint.oldPath.getValue(); - assert.ok(oldComment.leading || oldComment.trailing); - patcher.replace( - oldComment.loc, - // Comments can't have .comments, so it doesn't matter - // whether we print with comments or without. - print(reprint.newPath).indentTail(oldComment.loc.indent) - ); - }); - } - - return ableToReprintComments; -}; - -// Get all comments that are either leading or trailing, ignoring any -// comments that occur inside node.loc. Returns an empty array for nodes -// with no leading or trailing comments. -function getSurroundingComments(node) { - var result = []; - if (node.comments && - node.comments.length > 0) { - node.comments.forEach(function(comment) { - if (comment.leading || comment.trailing) { - result.push(comment); - } - }); - } - return result; -} - -Pp.deleteComments = function(node) { - if (!node.comments) { - return; - } - - var patcher = this; - - node.comments.forEach(function(comment) { - if (comment.leading) { - // Delete leading comments along with any trailing whitespace - // they might have. - patcher.replace({ - start: comment.loc.start, - end: node.loc.lines.skipSpaces( - comment.loc.end, false, false) - }, ""); - - } else if (comment.trailing) { - // Delete trailing comments along with any leading whitespace - // they might have. - patcher.replace({ - start: node.loc.lines.skipSpaces( - comment.loc.start, true, false), - end: comment.loc.end - }, ""); - } - }); -}; - -exports.getReprinter = function(path) { - assert.ok(path instanceof FastPath); - - // Make sure that this path refers specifically to a Node, rather than - // some non-Node subproperty of a Node. - var node = path.getValue(); - if (!Printable.check(node)) - return; - - var orig = node.original; - var origLoc = orig && orig.loc; - var lines = origLoc && origLoc.lines; - var reprints = []; - - if (!lines || !findReprints(path, reprints)) - return; - - return function(print) { - var patcher = new Patcher(lines); - - reprints.forEach(function(reprint) { - var newNode = reprint.newPath.getValue(); - var oldNode = reprint.oldPath.getValue(); - - SourceLocation.assert(oldNode.loc, true); - - var needToPrintNewPathWithComments = - !patcher.tryToReprintComments(newNode, oldNode, print) - - if (needToPrintNewPathWithComments) { - // Since we were not able to preserve all leading/trailing - // comments, we delete oldNode's comments, print newPath - // with comments, and then patch the resulting lines where - // oldNode used to be. - patcher.deleteComments(oldNode); - } - - var pos = util.copyPos(oldNode.loc.start); - var needsLeadingSpace = lines.prevPos(pos) && - riskyAdjoiningCharExp.test(lines.charAt(pos)); - - var newLines = print( - reprint.newPath, - needToPrintNewPathWithComments - ).indentTail(oldNode.loc.indent); - - var needsTrailingSpace = - riskyAdjoiningCharExp.test(lines.charAt(oldNode.loc.end)); - - // If we try to replace the argument of a ReturnStatement like - // return"asdf" with e.g. a literal null expression, we run - // the risk of ending up with returnnull, so we need to add an - // extra leading space in situations where that might - // happen. Likewise for "asdf"in obj. See #170. - if (needsLeadingSpace || needsTrailingSpace) { - var newParts = []; - needsLeadingSpace && newParts.push(" "); - newParts.push(newLines); - needsTrailingSpace && newParts.push(" "); - newLines = linesModule.concat(newParts); - } - - patcher.replace(oldNode.loc, newLines); - }); - - // Recall that origLoc is the .loc of an ancestor node that is - // guaranteed to contain all the reprinted nodes and comments. - return patcher.get(origLoc).indentTail(-orig.loc.indent); - }; -}; - -function findReprints(newPath, reprints) { - var newNode = newPath.getValue(); - Printable.assert(newNode); - - var oldNode = newNode.original; - Printable.assert(oldNode); - - assert.deepEqual(reprints, []); - - if (newNode.type !== oldNode.type) { - return false; - } - - var oldPath = new FastPath(oldNode); - var canReprint = findChildReprints(newPath, oldPath, reprints); - - if (!canReprint) { - // Make absolutely sure the calling code does not attempt to reprint - // any nodes. - reprints.length = 0; - } - - return canReprint; -} - -function findAnyReprints(newPath, oldPath, reprints) { - var newNode = newPath.getValue(); - var oldNode = oldPath.getValue(); - - if (newNode === oldNode) - return true; - - if (isArray.check(newNode)) - return findArrayReprints(newPath, oldPath, reprints); - - if (isObject.check(newNode)) - return findObjectReprints(newPath, oldPath, reprints); - - return false; -} - -function findArrayReprints(newPath, oldPath, reprints) { - var newNode = newPath.getValue(); - var oldNode = oldPath.getValue(); - isArray.assert(newNode); - var len = newNode.length; - - if (!(isArray.check(oldNode) && - oldNode.length === len)) - return false; - - for (var i = 0; i < len; ++i) { - newPath.stack.push(i, newNode[i]); - oldPath.stack.push(i, oldNode[i]); - var canReprint = findAnyReprints(newPath, oldPath, reprints); - newPath.stack.length -= 2; - oldPath.stack.length -= 2; - if (!canReprint) { - return false; - } - } - - return true; -} - -function findObjectReprints(newPath, oldPath, reprints) { - var newNode = newPath.getValue(); - isObject.assert(newNode); - - if (newNode.original === null) { - // If newNode.original node was set to null, reprint the node. - return false; - } - - var oldNode = oldPath.getValue(); - if (!isObject.check(oldNode)) - return false; - - if (Printable.check(newNode)) { - if (!Printable.check(oldNode)) { - return false; - } - - // Here we need to decide whether the reprinted code for newNode - // is appropriate for patching into the location of oldNode. - - if (newNode.type === oldNode.type) { - var childReprints = []; - - if (findChildReprints(newPath, oldPath, childReprints)) { - reprints.push.apply(reprints, childReprints); - } else if (oldNode.loc) { - // If we have no .loc information for oldNode, then we - // won't be able to reprint it. - reprints.push({ - oldPath: oldPath.copy(), - newPath: newPath.copy() - }); - } else { - return false; - } - - return true; - } - - if (Expression.check(newNode) && - Expression.check(oldNode) && - // If we have no .loc information for oldNode, then we won't - // be able to reprint it. - oldNode.loc) { - - // If both nodes are subtypes of Expression, then we should be - // able to fill the location occupied by the old node with - // code printed for the new node with no ill consequences. - reprints.push({ - oldPath: oldPath.copy(), - newPath: newPath.copy() - }); - - return true; - } - - // The nodes have different types, and at least one of the types - // is not a subtype of the Expression type, so we cannot safely - // assume the nodes are syntactically interchangeable. - return false; - } - - return findChildReprints(newPath, oldPath, reprints); -} - -// This object is reused in hasOpeningParen and hasClosingParen to avoid -// having to allocate a temporary object. -var reusablePos = { line: 1, column: 0 }; -var nonSpaceExp = /\S/; - -function hasOpeningParen(oldPath) { - var oldNode = oldPath.getValue(); - var loc = oldNode.loc; - var lines = loc && loc.lines; - - if (lines) { - var pos = reusablePos; - pos.line = loc.start.line; - pos.column = loc.start.column; - - while (lines.prevPos(pos)) { - var ch = lines.charAt(pos); - - if (ch === "(") { - // If we found an opening parenthesis but it occurred before - // the start of the original subtree for this reprinting, then - // we must not return true for hasOpeningParen(oldPath). - return comparePos(oldPath.getRootValue().loc.start, pos) <= 0; - } - - if (nonSpaceExp.test(ch)) { - return false; - } - } - } - - return false; -} - -function hasClosingParen(oldPath) { - var oldNode = oldPath.getValue(); - var loc = oldNode.loc; - var lines = loc && loc.lines; - - if (lines) { - var pos = reusablePos; - pos.line = loc.end.line; - pos.column = loc.end.column; - - do { - var ch = lines.charAt(pos); - - if (ch === ")") { - // If we found a closing parenthesis but it occurred after the - // end of the original subtree for this reprinting, then we - // must not return true for hasClosingParen(oldPath). - return comparePos(pos, oldPath.getRootValue().loc.end) <= 0; - } - - if (nonSpaceExp.test(ch)) { - return false; - } - - } while (lines.nextPos(pos)); - } - - return false; -} - -function hasParens(oldPath) { - // This logic can technically be fooled if the node has parentheses - // but there are comments intervening between the parentheses and the - // node. In such cases the node will be harmlessly wrapped in an - // additional layer of parentheses. - return hasOpeningParen(oldPath) && hasClosingParen(oldPath); -} - -function findChildReprints(newPath, oldPath, reprints) { - var newNode = newPath.getValue(); - var oldNode = oldPath.getValue(); - - isObject.assert(newNode); - isObject.assert(oldNode); - - if (newNode.original === null) { - // If newNode.original node was set to null, reprint the node. - return false; - } - - // If this type of node cannot come lexically first in its enclosing - // statement (e.g. a function expression or object literal), and it - // seems to be doing so, then the only way we can ignore this problem - // and save ourselves from falling back to the pretty printer is if an - // opening parenthesis happens to precede the node. For example, - // (function(){ ... }()); does not need to be reprinted, even though - // the FunctionExpression comes lexically first in the enclosing - // ExpressionStatement and fails the hasParens test, because the - // parent CallExpression passes the hasParens test. If we relied on - // the path.needsParens() && !hasParens(oldNode) check below, the - // absence of a closing parenthesis after the FunctionExpression would - // trigger pretty-printing unnecessarily. - if (!newPath.canBeFirstInStatement() && - newPath.firstInStatement() && - !hasOpeningParen(oldPath)) - return false; - - // If this node needs parentheses and will not be wrapped with - // parentheses when reprinted, then return false to skip reprinting - // and let it be printed generically. - if (newPath.needsParens(true) && !hasParens(oldPath)) { - return false; - } - - for (var k in util.getUnionOfKeys(newNode, oldNode)) { - if (k === "loc") - continue; - - newPath.stack.push(k, types.getFieldValue(newNode, k)); - oldPath.stack.push(k, types.getFieldValue(oldNode, k)); - var canReprint = findAnyReprints(newPath, oldPath, reprints); - newPath.stack.length -= 2; - oldPath.stack.length -= 2; - - if (!canReprint) { - return false; - } - } - - return true; -} - -},{"2":2,"559":559,"560":560,"566":566,"567":567}],565:[function(_dereq_,module,exports){ -var assert = _dereq_(2); -var sourceMap = _dereq_(607); -var printComments = _dereq_(558).printComments; -var linesModule = _dereq_(560); -var fromString = linesModule.fromString; -var concat = linesModule.concat; -var normalizeOptions = _dereq_(562).normalize; -var getReprinter = _dereq_(564).getReprinter; -var types = _dereq_(566); -var namedTypes = types.namedTypes; -var isString = types.builtInTypes.string; -var isObject = types.builtInTypes.object; -var FastPath = _dereq_(559); -var util = _dereq_(567); - -function PrintResult(code, sourceMap) { - assert.ok(this instanceof PrintResult); - - isString.assert(code); - this.code = code; - - if (sourceMap) { - isObject.assert(sourceMap); - this.map = sourceMap; - } -} - -var PRp = PrintResult.prototype; -var warnedAboutToString = false; - -PRp.toString = function() { - if (!warnedAboutToString) { - console.warn( - "Deprecation warning: recast.print now returns an object with " + - "a .code property. You appear to be treating the object as a " + - "string, which might still work but is strongly discouraged." - ); - - warnedAboutToString = true; - } - - return this.code; -}; - -var emptyPrintResult = new PrintResult(""); - -function Printer(originalOptions) { - assert.ok(this instanceof Printer); - - var explicitTabWidth = originalOptions && originalOptions.tabWidth; - var options = normalizeOptions(originalOptions); - assert.notStrictEqual(options, originalOptions); - - // It's common for client code to pass the same options into both - // recast.parse and recast.print, but the Printer doesn't need (and - // can be confused by) options.sourceFileName, so we null it out. - options.sourceFileName = null; - - function printWithComments(path) { - assert.ok(path instanceof FastPath); - return printComments(path, print); - } - - function print(path, includeComments) { - if (includeComments) - return printWithComments(path); - - assert.ok(path instanceof FastPath); - - if (!explicitTabWidth) { - var oldTabWidth = options.tabWidth; - var loc = path.getNode().loc; - if (loc && loc.lines && loc.lines.guessTabWidth) { - options.tabWidth = loc.lines.guessTabWidth(); - var lines = maybeReprint(path); - options.tabWidth = oldTabWidth; - return lines; - } - } - - return maybeReprint(path); - } - - function maybeReprint(path) { - var reprinter = getReprinter(path); - if (reprinter) - return maybeAddParens(path, reprinter(print)); - return printRootGenerically(path); - } - - // Print the root node generically, but then resume reprinting its - // children non-generically. - function printRootGenerically(path) { - return genericPrint(path, options, printWithComments); - } - - // Print the entire AST generically. - function printGenerically(path) { - return genericPrint(path, options, printGenerically); - } - - this.print = function(ast) { - if (!ast) { - return emptyPrintResult; - } - - var lines = print(FastPath.from(ast), true); - - return new PrintResult( - lines.toString(options), - util.composeSourceMaps( - options.inputSourceMap, - lines.getSourceMap( - options.sourceMapName, - options.sourceRoot - ) - ) - ); - }; - - this.printGenerically = function(ast) { - if (!ast) { - return emptyPrintResult; - } - - var path = FastPath.from(ast); - var oldReuseWhitespace = options.reuseWhitespace; - - // Do not reuse whitespace (or anything else, for that matter) - // when printing generically. - options.reuseWhitespace = false; - - // TODO Allow printing of comments? - var pr = new PrintResult(printGenerically(path).toString(options)); - options.reuseWhitespace = oldReuseWhitespace; - return pr; - }; -} - -exports.Printer = Printer; - -function maybeAddParens(path, lines) { - return path.needsParens() ? concat(["(", lines, ")"]) : lines; -} - -function genericPrint(path, options, printPath) { - assert.ok(path instanceof FastPath); - return maybeAddParens(path, genericPrintNoParens(path, options, printPath)); -} - -function genericPrintNoParens(path, options, print) { - var n = path.getValue(); - - if (!n) { - return fromString(""); - } - - if (typeof n === "string") { - return fromString(n, options); - } - - namedTypes.Printable.assert(n); - - switch (n.type) { - case "File": - return path.call(print, "program"); - - case "Program": - return path.call(function(bodyPath) { - return printStatementSequence(bodyPath, options, print); - }, "body"); - - case "Noop": // Babel extension. - case "EmptyStatement": - return fromString(""); - - case "ExpressionStatement": - return concat([path.call(print, "expression"), ";"]); - - case "ParenthesizedExpression": // Babel extension. - return concat(["(", path.call(print, "expression"), ")"]); - - case "BinaryExpression": - case "LogicalExpression": - case "AssignmentExpression": - return fromString(" ").join([ - path.call(print, "left"), - n.operator, - path.call(print, "right") - ]); - - case "AssignmentPattern": - return concat([ - path.call(print, "left"), - "=", - path.call(print, "right") - ]); - - case "MemberExpression": - var parts = [path.call(print, "object")]; - - var property = path.call(print, "property"); - if (n.computed) { - parts.push("[", property, "]"); - } else { - parts.push(".", property); - } - - return concat(parts); - - case "MetaProperty": - return concat([ - path.call(print, "meta"), - ".", - path.call(print, "property") - ]); - - case "BindExpression": - var parts = []; - - if (n.object) { - parts.push(path.call(print, "object")); - } - - parts.push("::", path.call(print, "callee")); - - return concat(parts); - - case "Path": - return fromString(".").join(n.body); - - case "Identifier": - return concat([ - fromString(n.name, options), - path.call(print, "typeAnnotation") - ]); - - case "SpreadElement": - case "SpreadElementPattern": - case "SpreadProperty": - case "SpreadPropertyPattern": - case "RestElement": - return concat(["...", path.call(print, "argument")]); - - case "FunctionDeclaration": - case "FunctionExpression": - var parts = []; - - if (n.async) - parts.push("async "); - - parts.push("function"); - - if (n.generator) - parts.push("*"); - - if (n.id) { - parts.push( - " ", - path.call(print, "id"), - path.call(print, "typeParameters") - ); - } - - parts.push( - "(", - printFunctionParams(path, options, print), - ")", - path.call(print, "returnType"), - " ", - path.call(print, "body") - ); - - return concat(parts); - - case "ArrowFunctionExpression": - var parts = []; - - if (n.async) - parts.push("async "); - - if ( - n.params.length === 1 && - !n.rest && - n.params[0].type !== 'SpreadElementPattern' && - n.params[0].type !== 'RestElement' - ) { - parts.push(path.call(print, "params", 0)); - } else { - parts.push( - "(", - printFunctionParams(path, options, print), - ")" - ); - } - - parts.push(" => ", path.call(print, "body")); - - return concat(parts); - - case "MethodDefinition": - var parts = []; - - if (n.static) { - parts.push("static "); - } - - parts.push(printMethod(path, options, print)); - - return concat(parts); - - case "YieldExpression": - var parts = ["yield"]; - - if (n.delegate) - parts.push("*"); - - if (n.argument) - parts.push(" ", path.call(print, "argument")); - - return concat(parts); - - case "AwaitExpression": - var parts = ["await"]; - - if (n.all) - parts.push("*"); - - if (n.argument) - parts.push(" ", path.call(print, "argument")); - - return concat(parts); - - case "ModuleDeclaration": - var parts = ["module", path.call(print, "id")]; - - if (n.source) { - assert.ok(!n.body); - parts.push("from", path.call(print, "source")); - } else { - parts.push(path.call(print, "body")); - } - - return fromString(" ").join(parts); - - case "ImportSpecifier": - var parts = []; - - if (n.imported) { - parts.push(path.call(print, "imported")); - if (n.local && - n.local.name !== n.imported.name) { - parts.push(" as ", path.call(print, "local")); - } - } else if (n.id) { - parts.push(path.call(print, "id")); - if (n.name) { - parts.push(" as ", path.call(print, "name")); - } - } - - return concat(parts); - - case "ExportSpecifier": - var parts = []; - - if (n.local) { - parts.push(path.call(print, "local")); - if (n.exported && - n.exported.name !== n.local.name) { - parts.push(" as ", path.call(print, "exported")); - } - } else if (n.id) { - parts.push(path.call(print, "id")); - if (n.name) { - parts.push(" as ", path.call(print, "name")); - } - } - - return concat(parts); - - case "ExportBatchSpecifier": - return fromString("*"); - - case "ImportNamespaceSpecifier": - var parts = ["* as "]; - if (n.local) { - parts.push(path.call(print, "local")); - } else if (n.id) { - parts.push(path.call(print, "id")); - } - return concat(parts); - - case "ImportDefaultSpecifier": - if (n.local) { - return path.call(print, "local"); - } - return path.call(print, "id"); - - case "ExportDeclaration": - var parts = ["export"]; - - if (n["default"]) { - parts.push(" default"); - - } else if (n.specifiers && - n.specifiers.length > 0) { - - if (n.specifiers.length === 1 && - n.specifiers[0].type === "ExportBatchSpecifier") { - parts.push(" *"); - } else { - parts.push( - " { ", - fromString(", ").join(path.map(print, "specifiers")), - " }" - ); - } - - if (n.source) - parts.push(" from ", path.call(print, "source")); - - parts.push(";"); - - return concat(parts); - } - - if (n.declaration) { - var decLines = path.call(print, "declaration"); - parts.push(" ", decLines); - if (lastNonSpaceCharacter(decLines) !== ";") { - parts.push(";"); - } - } - - return concat(parts); - - case "ExportDefaultDeclaration": - return concat([ - "export default ", - path.call(print, "declaration") - ]); - - case "ExportNamedDeclaration": - var parts = ["export "]; - - if (n.declaration) { - parts.push(path.call(print, "declaration")); - } - - if (n.specifiers && - n.specifiers.length > 0) { - parts.push( - n.declaration ? ", {" : "{", - fromString(", ").join(path.map(print, "specifiers")), - "}" - ); - } - - if (n.source) { - parts.push(" from ", path.call(print, "source")); - } - - return concat(parts); - - case "ExportAllDeclaration": - var parts = ["export *"]; - - if (n.exported) { - parts.push(" as ", path.call(print, "exported")); - } - - return concat([ - " from ", - path.call(print, "source") - ]); - - case "ExportNamespaceSpecifier": - return concat(["* as ", path.call(print, "exported")]); - - case "ExportDefaultSpecifier": - return path.call(print, "exported"); - - case "ImportDeclaration": - var parts = ["import "]; - - if (n.importKind && n.importKind !== "value") { - parts.push(n.importKind + " "); - } - - if (n.specifiers && - n.specifiers.length > 0) { - - var foundImportSpecifier = false; - - path.each(function(specifierPath) { - var i = specifierPath.getName(); - if (i > 0) { - parts.push(", "); - } - - var value = specifierPath.getValue(); - - if (namedTypes.ImportDefaultSpecifier.check(value) || - namedTypes.ImportNamespaceSpecifier.check(value)) { - assert.strictEqual(foundImportSpecifier, false); - } else { - namedTypes.ImportSpecifier.assert(value); - if (!foundImportSpecifier) { - foundImportSpecifier = true; - parts.push("{"); - } - } - - parts.push(print(specifierPath)); - }, "specifiers"); - - if (foundImportSpecifier) { - parts.push("}"); - } - - parts.push(" from "); - } - - parts.push(path.call(print, "source"), ";"); - - return concat(parts); - - case "BlockStatement": - var naked = path.call(function(bodyPath) { - return printStatementSequence(bodyPath, options, print); - }, "body"); - - if (naked.isEmpty()) { - return fromString("{}"); - } - - return concat([ - "{\n", - naked.indent(options.tabWidth), - "\n}" - ]); - - case "ReturnStatement": - var parts = ["return"]; - - if (n.argument) { - var argLines = path.call(print, "argument"); - if (argLines.length > 1 && - (namedTypes.XJSElement && - namedTypes.XJSElement.check(n.argument) || - namedTypes.JSXElement && - namedTypes.JSXElement.check(n.argument))) { - parts.push( - " (\n", - argLines.indent(options.tabWidth), - "\n)" - ); - } else { - parts.push(" ", argLines); - } - } - - parts.push(";"); - - return concat(parts); - - case "CallExpression": - return concat([ - path.call(print, "callee"), - printArgumentsList(path, options, print) - ]); - - case "ObjectExpression": - case "ObjectPattern": - case "ObjectTypeAnnotation": - var allowBreak = false; - var isTypeAnnotation = n.type === "ObjectTypeAnnotation"; - var separator = isTypeAnnotation ? ';' : ','; - var fields = []; - - if (isTypeAnnotation) { - fields.push("indexers", "callProperties"); - } - - fields.push("properties"); - - var len = 0; - fields.forEach(function(field) { - len += n[field].length; - }); - - var oneLine = (isTypeAnnotation && len === 1) || len === 0; - var parts = [oneLine ? "{" : "{\n"]; - - var i = 0; - fields.forEach(function(field) { - path.each(function(childPath) { - var lines = print(childPath); - - if (!oneLine) { - lines = lines.indent(options.tabWidth); - } - - var multiLine = !isTypeAnnotation && lines.length > 1; - if (multiLine && allowBreak) { - // Similar to the logic for BlockStatement. - parts.push("\n"); - } - - parts.push(lines); - - if (i < len - 1) { - // Add an extra line break if the previous object property - // had a multi-line value. - parts.push(separator + (multiLine ? "\n\n" : "\n")); - allowBreak = !multiLine; - } else if (len !== 1 && isTypeAnnotation) { - parts.push(separator); - } else if (options.trailingComma) { - parts.push(separator); - } - i++; - }, field); - }); - - parts.push(oneLine ? "}" : "\n}"); - - return concat(parts); - - case "PropertyPattern": - return concat([ - path.call(print, "key"), - ": ", - path.call(print, "pattern") - ]); - - case "Property": // Non-standard AST node type. - if (n.method || n.kind === "get" || n.kind === "set") { - return printMethod(path, options, print); - } - - var parts = []; - - if (n.decorators) { - path.each(function(decoratorPath) { - parts.push(print(decoratorPath), "\n"); - }, "decorators"); - } - - var key = path.call(print, "key"); - if (n.computed) { - parts.push("[", key, "]"); - } else { - parts.push(key); - } - - if (! n.shorthand) { - parts.push(": ", path.call(print, "value")); - } - - return concat(parts); - - case "Decorator": - return concat(["@", path.call(print, "expression")]); - - case "ArrayExpression": - case "ArrayPattern": - var elems = n.elements, - len = elems.length; - - var printed = path.map(print, "elements"); - var joined = fromString(", ").join(printed); - var oneLine = joined.getLineLength(1) <= options.wrapColumn; - var parts = [oneLine ? "[" : "[\n"]; - - path.each(function(elemPath) { - var i = elemPath.getName(); - var elem = elemPath.getValue(); - if (!elem) { - // If the array expression ends with a hole, that hole - // will be ignored by the interpreter, but if it ends with - // two (or more) holes, we need to write out two (or more) - // commas so that the resulting code is interpreted with - // both (all) of the holes. - parts.push(","); - } else { - var lines = printed[i]; - if (oneLine) { - if (i > 0) - parts.push(" "); - } else { - lines = lines.indent(options.tabWidth); - } - parts.push(lines); - if (i < len - 1 || (!oneLine && options.trailingComma)) - parts.push(","); - if (!oneLine) - parts.push("\n"); - } - }, "elements"); - - parts.push("]"); - - return concat(parts); - - case "SequenceExpression": - return fromString(", ").join(path.map(print, "expressions")); - - case "ThisExpression": - return fromString("this"); - - case "Super": - return fromString("super"); - - case "Literal": - if (typeof n.value !== "string") - return fromString(n.value, options); - - return fromString(nodeStr(n.value, options), options); - - case "ModuleSpecifier": - if (n.local) { - throw new Error( - "The ESTree ModuleSpecifier type should be abstract" - ); - } - - // The Esprima ModuleSpecifier type is just a string-valued - // Literal identifying the imported-from module. - return fromString(nodeStr(n.value, options), options); - - case "UnaryExpression": - var parts = [n.operator]; - if (/[a-z]$/.test(n.operator)) - parts.push(" "); - parts.push(path.call(print, "argument")); - return concat(parts); - - case "UpdateExpression": - var parts = [path.call(print, "argument"), n.operator]; - - if (n.prefix) - parts.reverse(); - - return concat(parts); - - case "ConditionalExpression": - return concat([ - "(", path.call(print, "test"), - " ? ", path.call(print, "consequent"), - " : ", path.call(print, "alternate"), ")" - ]); - - case "NewExpression": - var parts = ["new ", path.call(print, "callee")]; - var args = n.arguments; - if (args) { - parts.push(printArgumentsList(path, options, print)); - } - - return concat(parts); - - case "VariableDeclaration": - var parts = [n.kind, " "]; - var maxLen = 0; - var printed = path.map(function(childPath) { - var lines = print(childPath); - maxLen = Math.max(lines.length, maxLen); - return lines; - }, "declarations"); - - if (maxLen === 1) { - parts.push(fromString(", ").join(printed)); - } else if (printed.length > 1 ) { - parts.push( - fromString(",\n").join(printed) - .indentTail(n.kind.length + 1) - ); - } else { - parts.push(printed[0]); - } - - // We generally want to terminate all variable declarations with a - // semicolon, except when they are children of for loops. - var parentNode = path.getParentNode(); - if (!namedTypes.ForStatement.check(parentNode) && - !namedTypes.ForInStatement.check(parentNode) && - !(namedTypes.ForOfStatement && - namedTypes.ForOfStatement.check(parentNode))) { - parts.push(";"); - } - - return concat(parts); - - case "VariableDeclarator": - return n.init ? fromString(" = ").join([ - path.call(print, "id"), - path.call(print, "init") - ]) : path.call(print, "id"); - - case "WithStatement": - return concat([ - "with (", - path.call(print, "object"), - ") ", - path.call(print, "body") - ]); - - case "IfStatement": - var con = adjustClause(path.call(print, "consequent"), options), - parts = ["if (", path.call(print, "test"), ")", con]; - - if (n.alternate) - parts.push( - endsWithBrace(con) ? " else" : "\nelse", - adjustClause(path.call(print, "alternate"), options)); - - return concat(parts); - - case "ForStatement": - // TODO Get the for (;;) case right. - var init = path.call(print, "init"), - sep = init.length > 1 ? ";\n" : "; ", - forParen = "for (", - indented = fromString(sep).join([ - init, - path.call(print, "test"), - path.call(print, "update") - ]).indentTail(forParen.length), - head = concat([forParen, indented, ")"]), - clause = adjustClause(path.call(print, "body"), options), - parts = [head]; - - if (head.length > 1) { - parts.push("\n"); - clause = clause.trimLeft(); - } - - parts.push(clause); - - return concat(parts); - - case "WhileStatement": - return concat([ - "while (", - path.call(print, "test"), - ")", - adjustClause(path.call(print, "body"), options) - ]); - - case "ForInStatement": - // Note: esprima can't actually parse "for each (". - return concat([ - n.each ? "for each (" : "for (", - path.call(print, "left"), - " in ", - path.call(print, "right"), - ")", - adjustClause(path.call(print, "body"), options) - ]); - - case "ForOfStatement": - return concat([ - "for (", - path.call(print, "left"), - " of ", - path.call(print, "right"), - ")", - adjustClause(path.call(print, "body"), options) - ]); - - case "DoWhileStatement": - var doBody = concat([ - "do", - adjustClause(path.call(print, "body"), options) - ]), parts = [doBody]; - - if (endsWithBrace(doBody)) - parts.push(" while"); - else - parts.push("\nwhile"); - - parts.push(" (", path.call(print, "test"), ");"); - - return concat(parts); - - case "DoExpression": - var statements = path.call(function(bodyPath) { - return printStatementSequence(bodyPath, options, print); - }, "body"); - - return concat([ - "do {\n", - statements.indent(options.tabWidth), - "\n}" - ]); - - case "BreakStatement": - var parts = ["break"]; - if (n.label) - parts.push(" ", path.call(print, "label")); - parts.push(";"); - return concat(parts); - - case "ContinueStatement": - var parts = ["continue"]; - if (n.label) - parts.push(" ", path.call(print, "label")); - parts.push(";"); - return concat(parts); - - case "LabeledStatement": - return concat([ - path.call(print, "label"), - ":\n", - path.call(print, "body") - ]); - - case "TryStatement": - var parts = [ - "try ", - path.call(print, "block") - ]; - - if (n.handler) { - parts.push(" ", path.call(print, "handler")); - } else if (n.handlers) { - path.each(function(handlerPath) { - parts.push(" ", print(handlerPath)); - }, "handlers"); - } - - if (n.finalizer) { - parts.push(" finally ", path.call(print, "finalizer")); - } - - return concat(parts); - - case "CatchClause": - var parts = ["catch (", path.call(print, "param")]; - - if (n.guard) - // Note: esprima does not recognize conditional catch clauses. - parts.push(" if ", path.call(print, "guard")); - - parts.push(") ", path.call(print, "body")); - - return concat(parts); - - case "ThrowStatement": - return concat(["throw ", path.call(print, "argument"), ";"]); - - case "SwitchStatement": - return concat([ - "switch (", - path.call(print, "discriminant"), - ") {\n", - fromString("\n").join(path.map(print, "cases")), - "\n}" - ]); - - // Note: ignoring n.lexical because it has no printing consequences. - - case "SwitchCase": - var parts = []; - - if (n.test) - parts.push("case ", path.call(print, "test"), ":"); - else - parts.push("default:"); - - if (n.consequent.length > 0) { - parts.push("\n", path.call(function(consequentPath) { - return printStatementSequence(consequentPath, options, print); - }, "consequent").indent(options.tabWidth)); - } - - return concat(parts); - - case "DebuggerStatement": - return fromString("debugger;"); - - // JSX extensions below. - - case "XJSAttribute": - case "JSXAttribute": - var parts = [path.call(print, "name")]; - if (n.value) - parts.push("=", path.call(print, "value")); - return concat(parts); - - case "XJSIdentifier": - case "JSXIdentifier": - return fromString(n.name, options); - - case "XJSNamespacedName": - case "JSXNamespacedName": - return fromString(":").join([ - path.call(print, "namespace"), - path.call(print, "name") - ]); - - case "XJSMemberExpression": - case "JSXMemberExpression": - return fromString(".").join([ - path.call(print, "object"), - path.call(print, "property") - ]); - - case "XJSSpreadAttribute": - case "JSXSpreadAttribute": - return concat(["{...", path.call(print, "argument"), "}"]); - - case "XJSExpressionContainer": - case "JSXExpressionContainer": - return concat(["{", path.call(print, "expression"), "}"]); - - case "XJSElement": - case "JSXElement": - var openingLines = path.call(print, "openingElement"); - - if (n.openingElement.selfClosing) { - assert.ok(!n.closingElement); - return openingLines; - } - - var childLines = concat( - path.map(function(childPath) { - var child = childPath.getValue(); - - if (namedTypes.Literal.check(child) && - typeof child.value === "string") { - if (/\S/.test(child.value)) { - return child.value.replace(/^\s+|\s+$/g, ""); - } else if (/\n/.test(child.value)) { - return "\n"; - } - } - - return print(childPath); - }, "children") - ).indentTail(options.tabWidth); - - var closingLines = path.call(print, "closingElement"); - - return concat([ - openingLines, - childLines, - closingLines - ]); - - case "XJSOpeningElement": - case "JSXOpeningElement": - var parts = ["<", path.call(print, "name")]; - var attrParts = []; - - path.each(function(attrPath) { - attrParts.push(" ", print(attrPath)); - }, "attributes"); - - var attrLines = concat(attrParts); - - var needLineWrap = ( - attrLines.length > 1 || - attrLines.getLineLength(1) > options.wrapColumn - ); - - if (needLineWrap) { - attrParts.forEach(function(part, i) { - if (part === " ") { - assert.strictEqual(i % 2, 0); - attrParts[i] = "\n"; - } - }); - - attrLines = concat(attrParts).indentTail(options.tabWidth); - } - - parts.push(attrLines, n.selfClosing ? " />" : ">"); - - return concat(parts); - - case "XJSClosingElement": - case "JSXClosingElement": - return concat([""]); - - case "XJSText": - case "JSXText": - return fromString(n.value, options); - - case "XJSEmptyExpression": - case "JSXEmptyExpression": - return fromString(""); - - case "TypeAnnotatedIdentifier": - return concat([ - path.call(print, "annotation"), - " ", - path.call(print, "identifier") - ]); - - case "ClassBody": - if (n.body.length === 0) { - return fromString("{}"); - } - - return concat([ - "{\n", - path.call(function(bodyPath) { - return printStatementSequence(bodyPath, options, print); - }, "body").indent(options.tabWidth), - "\n}" - ]); - - case "ClassPropertyDefinition": - var parts = ["static ", path.call(print, "definition")]; - if (!namedTypes.MethodDefinition.check(n.definition)) - parts.push(";"); - return concat(parts); - - case "ClassProperty": - var parts = []; - if (n.static) - parts.push("static "); - - parts.push(path.call(print, "key")); - if (n.typeAnnotation) - parts.push(path.call(print, "typeAnnotation")); - - if (n.value) - parts.push(" = ", path.call(print, "value")); - - parts.push(";"); - return concat(parts); - - case "ClassDeclaration": - case "ClassExpression": - var parts = ["class"]; - - if (n.id) { - parts.push( - " ", - path.call(print, "id"), - path.call(print, "typeParameters") - ); - } - - if (n.superClass) { - parts.push( - " extends ", - path.call(print, "superClass"), - path.call(print, "superTypeParameters") - ); - } - - if (n["implements"]) { - parts.push( - " implements ", - fromString(", ").join(path.map(print, "implements")) - ); - } - - parts.push(" ", path.call(print, "body")); - - return concat(parts); - - case "TemplateElement": - return fromString(n.value.raw, options); - - case "TemplateLiteral": - var expressions = path.map(print, "expressions"); - var parts = ["`"]; - - path.each(function(childPath) { - var i = childPath.getName(); - parts.push(print(childPath)); - if (i < expressions.length) { - parts.push("${", expressions[i], "}"); - } - }, "quasis"); - - parts.push("`"); - - return concat(parts); - - case "TaggedTemplateExpression": - return concat([ - path.call(print, "tag"), - path.call(print, "quasi") - ]); - - // These types are unprintable because they serve as abstract - // supertypes for other (printable) types. - case "Node": - case "Printable": - case "SourceLocation": - case "Position": - case "Statement": - case "Function": - case "Pattern": - case "Expression": - case "Declaration": - case "Specifier": - case "NamedSpecifier": - case "Comment": // Supertype of Block and Line. - case "MemberTypeAnnotation": // Flow - case "TupleTypeAnnotation": // Flow - case "Type": // Flow - throw new Error("unprintable type: " + JSON.stringify(n.type)); - - case "CommentBlock": // Babel block comment. - case "Block": // Esprima block comment. - return concat(["/*", fromString(n.value, options), "*/"]); - - case "CommentLine": // Babel line comment. - case "Line": // Esprima line comment. - return concat(["//", fromString(n.value, options)]); - - // Type Annotations for Facebook Flow, typically stripped out or - // transformed away before printing. - case "TypeAnnotation": - var parts = []; - - if (n.typeAnnotation) { - if (n.typeAnnotation.type !== "FunctionTypeAnnotation") { - parts.push(": "); - } - parts.push(path.call(print, "typeAnnotation")); - return concat(parts); - } - - return fromString(""); - - case "AnyTypeAnnotation": - return fromString("any", options); - - case "MixedTypeAnnotation": - return fromString("mixed", options); - - case "ArrayTypeAnnotation": - return concat([ - path.call(print, "elementType"), - "[]" - ]); - - case "BooleanTypeAnnotation": - return fromString("boolean", options); - - case "BooleanLiteralTypeAnnotation": - assert.strictEqual(typeof n.value, "boolean"); - return fromString("" + n.value, options); - - case "DeclareClass": - return concat([ - fromString("declare class ", options), - path.call(print, "id"), - " ", - path.call(print, "body"), - ]); - - case "DeclareFunction": - return concat([ - fromString("declare function ", options), - path.call(print, "id"), - ";" - ]); - - case "DeclareModule": - return concat([ - fromString("declare module ", options), - path.call(print, "id"), - " ", - path.call(print, "body"), - ]); - - case "DeclareVariable": - return concat([ - fromString("declare var ", options), - path.call(print, "id"), - ";" - ]); - - case "FunctionTypeAnnotation": - // FunctionTypeAnnotation is ambiguous: - // declare function(a: B): void; OR - // var A: (a: B) => void; - var parts = []; - var parent = path.getParentNode(0); - var isArrowFunctionTypeAnnotation = !( - namedTypes.ObjectTypeCallProperty.check(parent) || - namedTypes.DeclareFunction.check(path.getParentNode(2)) - ); - - var needsColon = - isArrowFunctionTypeAnnotation && - !namedTypes.FunctionTypeParam.check(parent); - - if (needsColon) { - parts.push(": "); - } - - parts.push( - "(", - fromString(", ").join(path.map(print, "params")), - ")" - ); - - // The returnType is not wrapped in a TypeAnnotation, so the colon - // needs to be added separately. - if (n.returnType) { - parts.push( - isArrowFunctionTypeAnnotation ? " => " : ": ", - path.call(print, "returnType") - ); - } - - return concat(parts); - - case "FunctionTypeParam": - return concat([ - path.call(print, "name"), - ": ", - path.call(print, "typeAnnotation"), - ]); - - case "GenericTypeAnnotation": - return concat([ - path.call(print, "id"), - path.call(print, "typeParameters") - ]); - - case "InterfaceDeclaration": - var parts = [ - fromString("interface ", options), - path.call(print, "id"), - path.call(print, "typeParameters"), - " " - ]; - - if (n["extends"]) { - parts.push( - "extends ", - fromString(", ").join(path.map(print, "extends")) - ); - } - - parts.push(" ", path.call(print, "body")); - - return concat(parts); - - case "ClassImplements": - case "InterfaceExtends": - return concat([ - path.call(print, "id"), - path.call(print, "typeParameters") - ]); - - case "IntersectionTypeAnnotation": - return fromString(" & ").join(path.map(print, "types")); - - case "NullableTypeAnnotation": - return concat([ - "?", - path.call(print, "typeAnnotation") - ]); - - case "NumberTypeAnnotation": - return fromString("number", options); - - case "ObjectTypeCallProperty": - return path.call(print, "value"); - - case "ObjectTypeIndexer": - return concat([ - "[", - path.call(print, "id"), - ": ", - path.call(print, "key"), - "]: ", - path.call(print, "value") - ]); - - case "ObjectTypeProperty": - return concat([ - path.call(print, "key"), - ": ", - path.call(print, "value") - ]); - - case "QualifiedTypeIdentifier": - return concat([ - path.call(print, "qualification"), - ".", - path.call(print, "id") - ]); - - case "StringLiteralTypeAnnotation": - return fromString(nodeStr(n.value, options), options); - - case "NumberLiteralTypeAnnotation": - assert.strictEqual(typeof n.value, "number"); - return fromString("" + n.value, options); - - case "StringTypeAnnotation": - return fromString("string", options); - - case "TypeAlias": - return concat([ - "type ", - path.call(print, "id"), - " = ", - path.call(print, "right"), - ";" - ]); - - case "TypeCastExpression": - return concat([ - "(", - path.call(print, "expression"), - path.call(print, "typeAnnotation"), - ")" - ]); - - case "TypeParameterDeclaration": - case "TypeParameterInstantiation": - return concat([ - "<", - fromString(", ").join(path.map(print, "params")), - ">" - ]); - - case "TypeofTypeAnnotation": - return concat([ - fromString("typeof ", options), - path.call(print, "argument") - ]); - - case "UnionTypeAnnotation": - return fromString(" | ").join(path.map(print, "types")); - - case "VoidTypeAnnotation": - return fromString("void", options); - - // Unhandled types below. If encountered, nodes of these types should - // be either left alone or desugared into AST types that are fully - // supported by the pretty-printer. - case "ClassHeritage": // TODO - case "ComprehensionBlock": // TODO - case "ComprehensionExpression": // TODO - case "Glob": // TODO - case "GeneratorExpression": // TODO - case "LetStatement": // TODO - case "LetExpression": // TODO - case "GraphExpression": // TODO - case "GraphIndexExpression": // TODO - - // XML types that nobody cares about or needs to print. - case "XMLDefaultDeclaration": - case "XMLAnyName": - case "XMLQualifiedIdentifier": - case "XMLFunctionQualifiedIdentifier": - case "XMLAttributeSelector": - case "XMLFilterExpression": - case "XML": - case "XMLElement": - case "XMLList": - case "XMLEscape": - case "XMLText": - case "XMLStartTag": - case "XMLEndTag": - case "XMLPointTag": - case "XMLName": - case "XMLAttribute": - case "XMLCdata": - case "XMLComment": - case "XMLProcessingInstruction": - default: - debugger; - throw new Error("unknown type: " + JSON.stringify(n.type)); - } - - return p; -} - -function printStatementSequence(path, options, print) { - var inClassBody = - namedTypes.ClassBody && - namedTypes.ClassBody.check(path.getParentNode()); - - var filtered = []; - var sawComment = false; - var sawStatement = false; - - path.each(function(stmtPath) { - var i = stmtPath.getName(); - var stmt = stmtPath.getValue(); - - // Just in case the AST has been modified to contain falsy - // "statements," it's safer simply to skip them. - if (!stmt) { - return; - } - - // Skip printing EmptyStatement nodes to avoid leaving stray - // semicolons lying around. - if (stmt.type === "EmptyStatement") { - return; - } - - if (namedTypes.Comment.check(stmt)) { - // The pretty printer allows a dangling Comment node to act as - // a Statement when the Comment can't be attached to any other - // non-Comment node in the tree. - sawComment = true; - } else if (!inClassBody) { - namedTypes.Statement.assert(stmt); - sawStatement = true; - } - - // We can't hang onto stmtPath outside of this function, because - // it's just a reference to a mutable FastPath object, so we have - // to go ahead and print it here. - filtered.push({ - node: stmt, - printed: print(stmtPath) - }); - }); - - if (sawComment) { - assert.strictEqual( - sawStatement, false, - "Comments may appear as statements in otherwise empty statement " + - "lists, but may not coexist with non-Comment nodes." - ); - } - - var prevTrailingSpace = null; - var len = filtered.length; - var parts = []; - - filtered.forEach(function(info, i) { - var printed = info.printed; - var stmt = info.node; - var multiLine = printed.length > 1; - var notFirst = i > 0; - var notLast = i < len - 1; - var leadingSpace; - var trailingSpace; - var lines = stmt && stmt.loc && stmt.loc.lines; - var trueLoc = lines && options.reuseWhitespace && - util.getTrueLoc(stmt, lines); - - if (notFirst) { - if (trueLoc) { - var beforeStart = lines.skipSpaces(trueLoc.start, true); - var beforeStartLine = beforeStart ? beforeStart.line : 1; - var leadingGap = trueLoc.start.line - beforeStartLine; - leadingSpace = Array(leadingGap + 1).join("\n"); - } else { - leadingSpace = multiLine ? "\n\n" : "\n"; - } - } else { - leadingSpace = ""; - } - - if (notLast) { - if (trueLoc) { - var afterEnd = lines.skipSpaces(trueLoc.end); - var afterEndLine = afterEnd ? afterEnd.line : lines.length; - var trailingGap = afterEndLine - trueLoc.end.line; - trailingSpace = Array(trailingGap + 1).join("\n"); - } else { - trailingSpace = multiLine ? "\n\n" : "\n"; - } - } else { - trailingSpace = ""; - } - - parts.push( - maxSpace(prevTrailingSpace, leadingSpace), - printed - ); - - if (notLast) { - prevTrailingSpace = trailingSpace; - } else if (trailingSpace) { - parts.push(trailingSpace); - } - }); - - return concat(parts); -} - -function maxSpace(s1, s2) { - if (!s1 && !s2) { - return fromString(""); - } - - if (!s1) { - return fromString(s2); - } - - if (!s2) { - return fromString(s1); - } - - var spaceLines1 = fromString(s1); - var spaceLines2 = fromString(s2); - - if (spaceLines2.length > spaceLines1.length) { - return spaceLines2; - } - - return spaceLines1; -} - -function printMethod(path, options, print) { - var node = path.getNode(); - var kind = node.kind; - var parts = []; - - namedTypes.FunctionExpression.assert(node.value); - - if (node.decorators) { - path.each(function(decoratorPath) { - parts.push(print(decoratorPath), "\n"); - }, "decorators"); - } - - if (node.value.async) { - parts.push("async "); - } - - if (!kind || kind === "init" || kind === "method" || kind === "constructor") { - if (node.value.generator) { - parts.push("*"); - } - } else { - assert.ok(kind === "get" || kind === "set"); - parts.push(kind, " "); - } - - var key = path.call(print, "key"); - if (node.computed) { - key = concat(["[", key, "]"]); - } - - parts.push( - key, - path.call(print, "value", "typeParameters"), - "(", - path.call(function(valuePath) { - return printFunctionParams(valuePath, options, print); - }, "value"), - ")", - path.call(print, "value", "returnType"), - " ", - path.call(print, "value", "body") - ); - - return concat(parts); -} - -function printArgumentsList(path, options, print) { - var printed = path.map(print, "arguments"); - - var joined = fromString(", ").join(printed); - if (joined.getLineLength(1) > options.wrapColumn) { - joined = fromString(",\n").join(printed); - return concat([ - "(\n", - joined.indent(options.tabWidth), - options.trailingComma ? ",\n)" : "\n)" - ]); - } - - return concat(["(", joined, ")"]); -} - -function printFunctionParams(path, options, print) { - var fun = path.getValue(); - namedTypes.Function.assert(fun); - - var printed = path.map(print, "params"); - - if (fun.defaults) { - path.each(function(defExprPath) { - var i = defExprPath.getName(); - var p = printed[i]; - if (p && defExprPath.getValue()) { - printed[i] = concat([p, "=", print(defExprPath)]); - } - }, "defaults"); - } - - if (fun.rest) { - printed.push(concat(["...", path.call(print, "rest")])); - } - - var joined = fromString(", ").join(printed); - if (joined.length > 1 || - joined.getLineLength(1) > options.wrapColumn) { - joined = fromString(",\n").join(printed); - if (options.trailingComma && !fun.rest) { - joined = concat([joined, ",\n"]); - } - return concat(["\n", joined.indent(options.tabWidth)]); - } - - return joined; -} - -function adjustClause(clause, options) { - if (clause.length > 1) - return concat([" ", clause]); - - return concat([ - "\n", - maybeAddSemicolon(clause).indent(options.tabWidth) - ]); -} - -function lastNonSpaceCharacter(lines) { - var pos = lines.lastPos(); - do { - var ch = lines.charAt(pos); - if (/\S/.test(ch)) - return ch; - } while (lines.prevPos(pos)); -} - -function endsWithBrace(lines) { - return lastNonSpaceCharacter(lines) === "}"; -} - -function swapQuotes(str) { - return str.replace(/['"]/g, function(m) { - return m === '"' ? '\'' : '"'; - }); -} - -function nodeStr(str, options) { - isString.assert(str); - switch (options.quote) { - case "auto": - var double = JSON.stringify(str); - var single = swapQuotes(JSON.stringify(swapQuotes(str))); - return double.length > single.length ? single : double; - case "single": - return swapQuotes(JSON.stringify(swapQuotes(str))); - case "double": - default: - return JSON.stringify(str); - } -} - -function maybeAddSemicolon(lines) { - var eoc = lastNonSpaceCharacter(lines); - if (!eoc || "\n};".indexOf(eoc) < 0) - return concat([lines, ";"]); - return lines; -} - -},{"2":2,"558":558,"559":559,"560":560,"562":562,"564":564,"566":566,"567":567,"607":607}],566:[function(_dereq_,module,exports){ -// This module was originally created so that Recast could add its own -// custom types to the AST type system (in particular, the File type), but -// those types are now incorporated into ast-types, so this module doesn't -// have much to do anymore. Still, it might prove useful in the future. -module.exports = _dereq_(584); - -},{"584":584}],567:[function(_dereq_,module,exports){ -var assert = _dereq_(2); -var types = _dereq_(566); -var getFieldValue = types.getFieldValue; -var n = types.namedTypes; -var sourceMap = _dereq_(607); -var SourceMapConsumer = sourceMap.SourceMapConsumer; -var SourceMapGenerator = sourceMap.SourceMapGenerator; -var hasOwn = Object.prototype.hasOwnProperty; - -function getUnionOfKeys() { - var result = {}; - var argc = arguments.length; - for (var i = 0; i < argc; ++i) { - var keys = Object.keys(arguments[i]); - var keyCount = keys.length; - for (var j = 0; j < keyCount; ++j) { - result[keys[j]] = true; - } - } - return result; -} -exports.getUnionOfKeys = getUnionOfKeys; - -function comparePos(pos1, pos2) { - return (pos1.line - pos2.line) || (pos1.column - pos2.column); -} -exports.comparePos = comparePos; - -function copyPos(pos) { - return { - line: pos.line, - column: pos.column - }; -} -exports.copyPos = copyPos; - -exports.composeSourceMaps = function(formerMap, latterMap) { - if (formerMap) { - if (!latterMap) { - return formerMap; - } - } else { - return latterMap || null; - } - - var smcFormer = new SourceMapConsumer(formerMap); - var smcLatter = new SourceMapConsumer(latterMap); - var smg = new SourceMapGenerator({ - file: latterMap.file, - sourceRoot: latterMap.sourceRoot - }); - - var sourcesToContents = {}; - - smcLatter.eachMapping(function(mapping) { - var origPos = smcFormer.originalPositionFor({ - line: mapping.originalLine, - column: mapping.originalColumn - }); - - var sourceName = origPos.source; - if (sourceName === null) { - return; - } - - smg.addMapping({ - source: sourceName, - original: copyPos(origPos), - generated: { - line: mapping.generatedLine, - column: mapping.generatedColumn - }, - name: mapping.name - }); - - var sourceContent = smcFormer.sourceContentFor(sourceName); - if (sourceContent && !hasOwn.call(sourcesToContents, sourceName)) { - sourcesToContents[sourceName] = sourceContent; - smg.setSourceContent(sourceName, sourceContent); - } - }); - - return smg.toJSON(); -}; - -exports.getTrueLoc = function(node, lines) { - // It's possible that node is newly-created (not parsed by Esprima), - // in which case it probably won't have a .loc property (or an - // .original property for that matter). That's fine; we'll just - // pretty-print it as usual. - if (!node.loc) { - return null; - } - - var start = node.loc.start; - var end = node.loc.end; - - // If the node has any comments, their locations might contribute to - // the true start/end positions of the node. - if (node.comments) { - node.comments.forEach(function(comment) { - if (comment.loc) { - if (comparePos(comment.loc.start, start) < 0) { - start = comment.loc.start; - } - - if (comparePos(end, comment.loc.end) < 0) { - end = comment.loc.end; - } - } - }); - } - - return { - // Finally, trim any leading or trailing whitespace from the true - // location of the node. - start: lines.skipSpaces(start, false, false), - end: lines.skipSpaces(end, true, false) - }; -}; - -exports.fixFaultyLocations = function(node) { - if ((n.MethodDefinition && n.MethodDefinition.check(node)) || - (n.Property.check(node) && (node.method || node.shorthand))) { - // If the node is a MethodDefinition or a .method or .shorthand - // Property, then the location information stored in - // node.value.loc is very likely untrustworthy (just the {body} - // part of a method, or nothing in the case of shorthand - // properties), so we null out that information to prevent - // accidental reuse of bogus source code during reprinting. - node.value.loc = null; - - if (n.FunctionExpression.check(node.value)) { - // FunctionExpression method values should be anonymous, - // because their .id fields are ignored anyway. - node.value.id = null; - } - } - - var loc = node.loc; - if (loc) { - if (loc.start.line < 1) { - loc.start.line = 1; - } - - if (loc.end.line < 1) { - loc.end.line = 1; - } - } -}; - -},{"2":2,"566":566,"607":607}],568:[function(_dereq_,module,exports){ -(function (process){ -var types = _dereq_(566); -var parse = _dereq_(563).parse; -var Printer = _dereq_(565).Printer; - -function print(node, options) { - return new Printer(options).print(node); -} - -function prettyPrint(node, options) { - return new Printer(options).printGenerically(node); -} - -function run(transformer, options) { - return runFile(process.argv[2], transformer, options); -} - -function runFile(path, transformer, options) { - _dereq_(1).readFile(path, "utf-8", function(err, code) { - if (err) { - console.error(err); - return; - } - - runString(code, transformer, options); - }); -} - -function defaultWriteback(output) { - process.stdout.write(output); -} - -function runString(code, transformer, options) { - var writeback = options && options.writeback || defaultWriteback; - transformer(parse(code, options), function(node) { - writeback(print(node, options).code); - }); -} - -Object.defineProperties(exports, { - /** - * Parse a string of code into an augmented syntax tree suitable for - * arbitrary modification and reprinting. - */ - parse: { - enumerable: true, - value: parse - }, - - /** - * Traverse and potentially modify an abstract syntax tree using a - * convenient visitor syntax: - * - * recast.visit(ast, { - * names: [], - * visitIdentifier: function(path) { - * var node = path.value; - * this.visitor.names.push(node.name); - * this.traverse(path); - * } - * }); - */ - visit: { - enumerable: true, - value: types.visit - }, - - /** - * Reprint a modified syntax tree using as much of the original source - * code as possible. - */ - print: { - enumerable: true, - value: print - }, - - /** - * Print without attempting to reuse any original source code. - */ - prettyPrint: { - enumerable: false, - value: prettyPrint - }, - - /** - * Customized version of require("ast-types"). - */ - types: { - enumerable: false, - value: types - }, - - /** - * Convenient command-line interface (see e.g. example/add-braces). - */ - run: { - enumerable: false, - value: run - } -}); - -}).call(this,_dereq_(10)) -},{"1":1,"10":10,"563":563,"565":565,"566":566}],569:[function(_dereq_,module,exports){ -_dereq_(573); - -var types = _dereq_(583); -var defaults = _dereq_(582).defaults; -var def = types.Type.def; -var or = types.Type.or; - -def("Noop") - .bases("Node") - .build(); - -def("DoExpression") - .bases("Expression") - .build("body") - .field("body", [def("Statement")]); - -def("Super") - .bases("Expression") - .build(); - -def("BindExpression") - .bases("Expression") - .build("object", "callee") - .field("object", or(def("Expression"), null)) - .field("callee", def("Expression")); - -def("Decorator") - .bases("Node") - .build("expression") - .field("expression", def("Expression")); - -def("Property") - .field("decorators", - or([def("Decorator")], null), - defaults["null"]); - -def("MethodDefinition") - .field("decorators", - or([def("Decorator")], null), - defaults["null"]); - -def("MetaProperty") - .bases("Expression") - .build("meta", "property") - .field("meta", def("Identifier")) - .field("property", def("Identifier")); - -def("ParenthesizedExpression") - .bases("Expression") - .build("expression") - .field("expression", def("Expression")); - -def("ImportSpecifier") - .bases("ModuleSpecifier") - .build("imported", "local") - .field("imported", def("Identifier")); - -def("ImportDefaultSpecifier") - .bases("ModuleSpecifier") - .build("local"); - -def("ImportNamespaceSpecifier") - .bases("ModuleSpecifier") - .build("local"); - -def("ExportDefaultDeclaration") - .bases("Declaration") - .build("declaration") - .field("declaration", or(def("Declaration"), def("Expression"))); - -def("ExportNamedDeclaration") - .bases("Declaration") - .build("declaration", "specifiers", "source") - .field("declaration", or(def("Declaration"), null)) - .field("specifiers", [def("ExportSpecifier")], defaults.emptyArray) - .field("source", or(def("Literal"), null), defaults["null"]); - -def("ExportSpecifier") - .bases("ModuleSpecifier") - .build("local", "exported") - .field("exported", def("Identifier")); - -def("ExportNamespaceSpecifier") - .bases("Specifier") - .build("exported") - .field("exported", def("Identifier")); - -def("ExportDefaultSpecifier") - .bases("Specifier") - .build("exported") - .field("exported", def("Identifier")); - -def("ExportAllDeclaration") - .bases("Declaration") - .build("exported", "source") - .field("exported", or(def("Identifier"), null)) - .field("source", def("Literal")); - -def("CommentBlock") - .bases("Comment") - .build("value", /*optional:*/ "leading", "trailing"); - -def("CommentLine") - .bases("Comment") - .build("value", /*optional:*/ "leading", "trailing"); - -},{"573":573,"582":582,"583":583}],570:[function(_dereq_,module,exports){ -var types = _dereq_(583); -var Type = types.Type; -var def = Type.def; -var or = Type.or; -var shared = _dereq_(582); -var defaults = shared.defaults; -var geq = shared.geq; - -// Abstract supertype of all syntactic entities that are allowed to have a -// .loc field. -def("Printable") - .field("loc", or( - def("SourceLocation"), - null - ), defaults["null"], true); - -def("Node") - .bases("Printable") - .field("type", String) - .field("comments", or( - [def("Comment")], - null - ), defaults["null"], true); - -def("SourceLocation") - .build("start", "end", "source") - .field("start", def("Position")) - .field("end", def("Position")) - .field("source", or(String, null), defaults["null"]); - -def("Position") - .build("line", "column") - .field("line", geq(1)) - .field("column", geq(0)); - -def("File") - .bases("Node") - .build("program") - .field("program", def("Program")); - -def("Program") - .bases("Node") - .build("body") - .field("body", [def("Statement")]); - -def("Function") - .bases("Node") - .field("id", or(def("Identifier"), null), defaults["null"]) - .field("params", [def("Pattern")]) - .field("body", def("BlockStatement")); - -def("Statement").bases("Node"); - -// The empty .build() here means that an EmptyStatement can be constructed -// (i.e. it's not abstract) but that it needs no arguments. -def("EmptyStatement").bases("Statement").build(); - -def("BlockStatement") - .bases("Statement") - .build("body") - .field("body", [def("Statement")]); - -// TODO Figure out how to silently coerce Expressions to -// ExpressionStatements where a Statement was expected. -def("ExpressionStatement") - .bases("Statement") - .build("expression") - .field("expression", def("Expression")); - -def("IfStatement") - .bases("Statement") - .build("test", "consequent", "alternate") - .field("test", def("Expression")) - .field("consequent", def("Statement")) - .field("alternate", or(def("Statement"), null), defaults["null"]); - -def("LabeledStatement") - .bases("Statement") - .build("label", "body") - .field("label", def("Identifier")) - .field("body", def("Statement")); - -def("BreakStatement") - .bases("Statement") - .build("label") - .field("label", or(def("Identifier"), null), defaults["null"]); - -def("ContinueStatement") - .bases("Statement") - .build("label") - .field("label", or(def("Identifier"), null), defaults["null"]); - -def("WithStatement") - .bases("Statement") - .build("object", "body") - .field("object", def("Expression")) - .field("body", def("Statement")); - -def("SwitchStatement") - .bases("Statement") - .build("discriminant", "cases", "lexical") - .field("discriminant", def("Expression")) - .field("cases", [def("SwitchCase")]) - .field("lexical", Boolean, defaults["false"]); - -def("ReturnStatement") - .bases("Statement") - .build("argument") - .field("argument", or(def("Expression"), null)); - -def("ThrowStatement") - .bases("Statement") - .build("argument") - .field("argument", def("Expression")); - -def("TryStatement") - .bases("Statement") - .build("block", "handler", "finalizer") - .field("block", def("BlockStatement")) - .field("handler", or(def("CatchClause"), null), function() { - return this.handlers && this.handlers[0] || null; - }) - .field("handlers", [def("CatchClause")], function() { - return this.handler ? [this.handler] : []; - }, true) // Indicates this field is hidden from eachField iteration. - .field("guardedHandlers", [def("CatchClause")], defaults.emptyArray) - .field("finalizer", or(def("BlockStatement"), null), defaults["null"]); - -def("CatchClause") - .bases("Node") - .build("param", "guard", "body") - .field("param", def("Pattern")) - .field("guard", or(def("Expression"), null), defaults["null"]) - .field("body", def("BlockStatement")); - -def("WhileStatement") - .bases("Statement") - .build("test", "body") - .field("test", def("Expression")) - .field("body", def("Statement")); - -def("DoWhileStatement") - .bases("Statement") - .build("body", "test") - .field("body", def("Statement")) - .field("test", def("Expression")); - -def("ForStatement") - .bases("Statement") - .build("init", "test", "update", "body") - .field("init", or( - def("VariableDeclaration"), - def("Expression"), - null)) - .field("test", or(def("Expression"), null)) - .field("update", or(def("Expression"), null)) - .field("body", def("Statement")); - -def("ForInStatement") - .bases("Statement") - .build("left", "right", "body") - .field("left", or( - def("VariableDeclaration"), - def("Expression"))) - .field("right", def("Expression")) - .field("body", def("Statement")); - -def("DebuggerStatement").bases("Statement").build(); - -def("Declaration").bases("Statement"); - -def("FunctionDeclaration") - .bases("Function", "Declaration") - .build("id", "params", "body") - .field("id", def("Identifier")); - -def("FunctionExpression") - .bases("Function", "Expression") - .build("id", "params", "body"); - -def("VariableDeclaration") - .bases("Declaration") - .build("kind", "declarations") - .field("kind", or("var", "let", "const")) - .field("declarations", [def("VariableDeclarator")]); - -def("VariableDeclarator") - .bases("Node") - .build("id", "init") - .field("id", def("Pattern")) - .field("init", or(def("Expression"), null)); - -// TODO Are all Expressions really Patterns? -def("Expression").bases("Node", "Pattern"); - -def("ThisExpression").bases("Expression").build(); - -def("ArrayExpression") - .bases("Expression") - .build("elements") - .field("elements", [or(def("Expression"), null)]); - -def("ObjectExpression") - .bases("Expression") - .build("properties") - .field("properties", [def("Property")]); - -// TODO Not in the Mozilla Parser API, but used by Esprima. -def("Property") - .bases("Node") // Want to be able to visit Property Nodes. - .build("kind", "key", "value") - .field("kind", or("init", "get", "set")) - .field("key", or(def("Literal"), def("Identifier"))) - .field("value", def("Expression")); - -def("SequenceExpression") - .bases("Expression") - .build("expressions") - .field("expressions", [def("Expression")]); - -var UnaryOperator = or( - "-", "+", "!", "~", - "typeof", "void", "delete"); - -def("UnaryExpression") - .bases("Expression") - .build("operator", "argument", "prefix") - .field("operator", UnaryOperator) - .field("argument", def("Expression")) - // Esprima doesn't bother with this field, presumably because it's - // always true for unary operators. - .field("prefix", Boolean, defaults["true"]); - -var BinaryOperator = or( - "==", "!=", "===", "!==", - "<", "<=", ">", ">=", - "<<", ">>", ">>>", - "+", "-", "*", "/", "%", - "&", // TODO Missing from the Parser API. - "|", "^", "in", - "instanceof", ".."); - -def("BinaryExpression") - .bases("Expression") - .build("operator", "left", "right") - .field("operator", BinaryOperator) - .field("left", def("Expression")) - .field("right", def("Expression")); - -var AssignmentOperator = or( - "=", "+=", "-=", "*=", "/=", "%=", - "<<=", ">>=", ">>>=", - "|=", "^=", "&="); - -def("AssignmentExpression") - .bases("Expression") - .build("operator", "left", "right") - .field("operator", AssignmentOperator) - .field("left", def("Pattern")) - .field("right", def("Expression")); - -var UpdateOperator = or("++", "--"); - -def("UpdateExpression") - .bases("Expression") - .build("operator", "argument", "prefix") - .field("operator", UpdateOperator) - .field("argument", def("Expression")) - .field("prefix", Boolean); - -var LogicalOperator = or("||", "&&"); - -def("LogicalExpression") - .bases("Expression") - .build("operator", "left", "right") - .field("operator", LogicalOperator) - .field("left", def("Expression")) - .field("right", def("Expression")); - -def("ConditionalExpression") - .bases("Expression") - .build("test", "consequent", "alternate") - .field("test", def("Expression")) - .field("consequent", def("Expression")) - .field("alternate", def("Expression")); - -def("NewExpression") - .bases("Expression") - .build("callee", "arguments") - .field("callee", def("Expression")) - // The Mozilla Parser API gives this type as [or(def("Expression"), - // null)], but null values don't really make sense at the call site. - // TODO Report this nonsense. - .field("arguments", [def("Expression")]); - -def("CallExpression") - .bases("Expression") - .build("callee", "arguments") - .field("callee", def("Expression")) - // See comment for NewExpression above. - .field("arguments", [def("Expression")]); - -def("MemberExpression") - .bases("Expression") - .build("object", "property", "computed") - .field("object", def("Expression")) - .field("property", or(def("Identifier"), def("Expression"))) - .field("computed", Boolean, defaults["false"]); - -def("Pattern").bases("Node"); - -def("SwitchCase") - .bases("Node") - .build("test", "consequent") - .field("test", or(def("Expression"), null)) - .field("consequent", [def("Statement")]); - -def("Identifier") - // But aren't Expressions and Patterns already Nodes? TODO Report this. - .bases("Node", "Expression", "Pattern") - .build("name") - .field("name", String); - -def("Literal") - // But aren't Expressions already Nodes? TODO Report this. - .bases("Node", "Expression") - .build("value") - .field("value", or(String, Boolean, null, Number, RegExp)) - .field("regex", or({ - pattern: String, - flags: String - }, null), function() { - if (this.value instanceof RegExp) { - var flags = ""; - - if (this.value.ignoreCase) flags += "i"; - if (this.value.multiline) flags += "m"; - if (this.value.global) flags += "g"; - - return { - pattern: this.value.source, - flags: flags - }; - } - - return null; - }); - -// Abstract (non-buildable) comment supertype. Not a Node. -def("Comment") - .bases("Printable") - .field("value", String) - // A .leading comment comes before the node, whereas a .trailing - // comment comes after it. These two fields should not both be true, - // but they might both be false when the comment falls inside a node - // and the node has no children for the comment to lead or trail, - // e.g. { /*dangling*/ }. - .field("leading", Boolean, defaults["true"]) - .field("trailing", Boolean, defaults["false"]); - -},{"582":582,"583":583}],571:[function(_dereq_,module,exports){ -_dereq_(570); -var types = _dereq_(583); -var def = types.Type.def; -var or = types.Type.or; - -// Note that none of these types are buildable because the Mozilla Parser -// API doesn't specify any builder functions, and nobody uses E4X anymore. - -def("XMLDefaultDeclaration") - .bases("Declaration") - .field("namespace", def("Expression")); - -def("XMLAnyName").bases("Expression"); - -def("XMLQualifiedIdentifier") - .bases("Expression") - .field("left", or(def("Identifier"), def("XMLAnyName"))) - .field("right", or(def("Identifier"), def("Expression"))) - .field("computed", Boolean); - -def("XMLFunctionQualifiedIdentifier") - .bases("Expression") - .field("right", or(def("Identifier"), def("Expression"))) - .field("computed", Boolean); - -def("XMLAttributeSelector") - .bases("Expression") - .field("attribute", def("Expression")); - -def("XMLFilterExpression") - .bases("Expression") - .field("left", def("Expression")) - .field("right", def("Expression")); - -def("XMLElement") - .bases("XML", "Expression") - .field("contents", [def("XML")]); - -def("XMLList") - .bases("XML", "Expression") - .field("contents", [def("XML")]); - -def("XML").bases("Node"); - -def("XMLEscape") - .bases("XML") - .field("expression", def("Expression")); - -def("XMLText") - .bases("XML") - .field("text", String); - -def("XMLStartTag") - .bases("XML") - .field("contents", [def("XML")]); - -def("XMLEndTag") - .bases("XML") - .field("contents", [def("XML")]); - -def("XMLPointTag") - .bases("XML") - .field("contents", [def("XML")]); - -def("XMLName") - .bases("XML") - .field("contents", or(String, [def("XML")])); - -def("XMLAttribute") - .bases("XML") - .field("value", String); - -def("XMLCdata") - .bases("XML") - .field("contents", String); - -def("XMLComment") - .bases("XML") - .field("contents", String); - -def("XMLProcessingInstruction") - .bases("XML") - .field("target", String) - .field("contents", or(String, null)); - -},{"570":570,"583":583}],572:[function(_dereq_,module,exports){ -_dereq_(570); -var types = _dereq_(583); -var def = types.Type.def; -var or = types.Type.or; -var defaults = _dereq_(582).defaults; - -def("Function") - .field("generator", Boolean, defaults["false"]) - .field("expression", Boolean, defaults["false"]) - .field("defaults", [or(def("Expression"), null)], defaults.emptyArray) - // TODO This could be represented as a RestElement in .params. - .field("rest", or(def("Identifier"), null), defaults["null"]); - -// The ESTree way of representing a ...rest parameter. -def("RestElement") - .bases("Pattern") - .build("argument") - .field("argument", def("Pattern")); - -def("SpreadElementPattern") - .bases("Pattern") - .build("argument") - .field("argument", def("Pattern")); - -def("FunctionDeclaration") - .build("id", "params", "body", "generator", "expression"); - -def("FunctionExpression") - .build("id", "params", "body", "generator", "expression"); - -// The Parser API calls this ArrowExpression, but Esprima and all other -// actual parsers use ArrowFunctionExpression. -def("ArrowFunctionExpression") - .bases("Function", "Expression") - .build("params", "body", "expression") - // The forced null value here is compatible with the overridden - // definition of the "id" field in the Function interface. - .field("id", null, defaults["null"]) - // Arrow function bodies are allowed to be expressions. - .field("body", or(def("BlockStatement"), def("Expression"))) - // The current spec forbids arrow generators, so I have taken the - // liberty of enforcing that. TODO Report this. - .field("generator", false, defaults["false"]); - -def("YieldExpression") - .bases("Expression") - .build("argument", "delegate") - .field("argument", or(def("Expression"), null)) - .field("delegate", Boolean, defaults["false"]); - -def("GeneratorExpression") - .bases("Expression") - .build("body", "blocks", "filter") - .field("body", def("Expression")) - .field("blocks", [def("ComprehensionBlock")]) - .field("filter", or(def("Expression"), null)); - -def("ComprehensionExpression") - .bases("Expression") - .build("body", "blocks", "filter") - .field("body", def("Expression")) - .field("blocks", [def("ComprehensionBlock")]) - .field("filter", or(def("Expression"), null)); - -def("ComprehensionBlock") - .bases("Node") - .build("left", "right", "each") - .field("left", def("Pattern")) - .field("right", def("Expression")) - .field("each", Boolean); - -def("Property") - .field("key", or(def("Literal"), def("Identifier"), def("Expression"))) - .field("value", or(def("Expression"), def("Pattern"))) - .field("method", Boolean, defaults["false"]) - .field("shorthand", Boolean, defaults["false"]) - .field("computed", Boolean, defaults["false"]); - -def("PropertyPattern") - .bases("Pattern") - .build("key", "pattern") - .field("key", or(def("Literal"), def("Identifier"), def("Expression"))) - .field("pattern", def("Pattern")) - .field("computed", Boolean, defaults["false"]); - -def("ObjectPattern") - .bases("Pattern") - .build("properties") - .field("properties", [or(def("PropertyPattern"), def("Property"))]); - -def("ArrayPattern") - .bases("Pattern") - .build("elements") - .field("elements", [or(def("Pattern"), null)]); - -def("MethodDefinition") - .bases("Declaration") - .build("kind", "key", "value", "static") - .field("kind", or("constructor", "method", "get", "set")) - .field("key", or(def("Literal"), def("Identifier"), def("Expression"))) - .field("value", def("Function")) - .field("computed", Boolean, defaults["false"]) - .field("static", Boolean, defaults["false"]); - -def("SpreadElement") - .bases("Node") - .build("argument") - .field("argument", def("Expression")); - -def("ArrayExpression") - .field("elements", [or( - def("Expression"), - def("SpreadElement"), - def("RestElement"), - null - )]); - -def("NewExpression") - .field("arguments", [or(def("Expression"), def("SpreadElement"))]); - -def("CallExpression") - .field("arguments", [or(def("Expression"), def("SpreadElement"))]); - -// Note: this node type is *not* an AssignmentExpression with a Pattern on -// the left-hand side! The existing AssignmentExpression type already -// supports destructuring assignments. AssignmentPattern nodes may appear -// wherever a Pattern is allowed, and the right-hand side represents a -// default value to be destructured against the left-hand side, if no -// value is otherwise provided. For example: default parameter values. -def("AssignmentPattern") - .bases("Pattern") - .build("left", "right") - .field("left", def("Pattern")) - .field("right", def("Expression")); - -var ClassBodyElement = or( - def("MethodDefinition"), - def("VariableDeclarator"), - def("ClassPropertyDefinition"), - def("ClassProperty") -); - -def("ClassProperty") - .bases("Declaration") - .build("key") - .field("key", or(def("Literal"), def("Identifier"), def("Expression"))) - .field("computed", Boolean, defaults["false"]); - -def("ClassPropertyDefinition") // static property - .bases("Declaration") - .build("definition") - // Yes, Virginia, circular definitions are permitted. - .field("definition", ClassBodyElement); - -def("ClassBody") - .bases("Declaration") - .build("body") - .field("body", [ClassBodyElement]); - -def("ClassDeclaration") - .bases("Declaration") - .build("id", "body", "superClass") - .field("id", or(def("Identifier"), null)) - .field("body", def("ClassBody")) - .field("superClass", or(def("Expression"), null), defaults["null"]); - -def("ClassExpression") - .bases("Expression") - .build("id", "body", "superClass") - .field("id", or(def("Identifier"), null), defaults["null"]) - .field("body", def("ClassBody")) - .field("superClass", or(def("Expression"), null), defaults["null"]) - .field("implements", [def("ClassImplements")], defaults.emptyArray); - -def("ClassImplements") - .bases("Node") - .build("id") - .field("id", def("Identifier")) - .field("superClass", or(def("Expression"), null), defaults["null"]); - -// Specifier and ModuleSpecifier are abstract non-standard types -// introduced for definitional convenience. -def("Specifier").bases("Node"); - -// This supertype is shared/abused by both def/babel.js and -// def/esprima.js. In the future, it will be possible to load only one set -// of definitions appropriate for a given parser, but until then we must -// rely on default functions to reconcile the conflicting AST formats. -def("ModuleSpecifier") - .bases("Specifier") - // This local field is used by Babel/Acorn. It should not technically - // be optional in the Babel/Acorn AST format, but it must be optional - // in the Esprima AST format. - .field("local", or(def("Identifier"), null), defaults["null"]) - // The id and name fields are used by Esprima. The id field should not - // technically be optional in the Esprima AST format, but it must be - // optional in the Babel/Acorn AST format. - .field("id", or(def("Identifier"), null), defaults["null"]) - .field("name", or(def("Identifier"), null), defaults["null"]); - -def("TaggedTemplateExpression") - .bases("Expression") - .build("tag", "quasi") - .field("tag", def("Expression")) - .field("quasi", def("TemplateLiteral")); - -def("TemplateLiteral") - .bases("Expression") - .build("quasis", "expressions") - .field("quasis", [def("TemplateElement")]) - .field("expressions", [def("Expression")]); - -def("TemplateElement") - .bases("Node") - .build("value", "tail") - .field("value", {"cooked": String, "raw": String}) - .field("tail", Boolean); - -},{"570":570,"582":582,"583":583}],573:[function(_dereq_,module,exports){ -_dereq_(572); - -var types = _dereq_(583); -var def = types.Type.def; -var or = types.Type.or; -var builtin = types.builtInTypes; -var defaults = _dereq_(582).defaults; - -def("Function") - .field("async", Boolean, defaults["false"]); - -def("SpreadProperty") - .bases("Node") - .build("argument") - .field("argument", def("Expression")); - -def("ObjectExpression") - .field("properties", [or(def("Property"), def("SpreadProperty"))]); - -def("SpreadPropertyPattern") - .bases("Pattern") - .build("argument") - .field("argument", def("Pattern")); - -def("ObjectPattern") - .field("properties", [or( - def("Property"), - def("PropertyPattern"), - def("SpreadPropertyPattern") - )]); - -def("AwaitExpression") - .bases("Expression") - .build("argument", "all") - .field("argument", or(def("Expression"), null)) - .field("all", Boolean, defaults["false"]); - -},{"572":572,"582":582,"583":583}],574:[function(_dereq_,module,exports){ -_dereq_(573); - -var types = _dereq_(583); -var defaults = _dereq_(582).defaults; -var def = types.Type.def; -var or = types.Type.or; - -def("VariableDeclaration") - .field("declarations", [or( - def("VariableDeclarator"), - def("Identifier") // Esprima deviation. - )]); - -def("Property") - .field("value", or( - def("Expression"), - def("Pattern") // Esprima deviation. - )); - -def("ArrayPattern") - .field("elements", [or( - def("Pattern"), - def("SpreadElement"), - null - )]); - -def("ObjectPattern") - .field("properties", [or( - def("Property"), - def("PropertyPattern"), - def("SpreadPropertyPattern"), - def("SpreadProperty") // Used by Esprima. - )]); - -// Like ModuleSpecifier, except type:"ExportSpecifier" and buildable. -// export {} [from ...]; -def("ExportSpecifier") - .bases("ModuleSpecifier") - .build("id", "name"); - -// export <*> from ...; -def("ExportBatchSpecifier") - .bases("Specifier") - .build(); - -// Like ModuleSpecifier, except type:"ImportSpecifier" and buildable. -// import {} from ...; -def("ImportSpecifier") - .bases("ModuleSpecifier") - .build("id", "name"); - -// import <* as id> from ...; -def("ImportNamespaceSpecifier") - .bases("ModuleSpecifier") - .build("id"); - -// import from ...; -def("ImportDefaultSpecifier") - .bases("ModuleSpecifier") - .build("id"); - -def("ExportDeclaration") - .bases("Declaration") - .build("default", "declaration", "specifiers", "source") - .field("default", Boolean) - .field("declaration", or( - def("Declaration"), - def("Expression"), // Implies default. - null - )) - .field("specifiers", [or( - def("ExportSpecifier"), - def("ExportBatchSpecifier") - )], defaults.emptyArray) - .field("source", or( - def("Literal"), - null - ), defaults["null"]); - -def("ImportDeclaration") - .bases("Declaration") - .build("specifiers", "source") - .field("specifiers", [or( - def("ImportSpecifier"), - def("ImportNamespaceSpecifier"), - def("ImportDefaultSpecifier") - )], defaults.emptyArray) - .field("source", def("Literal")); - -def("Block") - .bases("Comment") - .build("value", /*optional:*/ "leading", "trailing"); - -def("Line") - .bases("Comment") - .build("value", /*optional:*/ "leading", "trailing"); - -},{"573":573,"582":582,"583":583}],575:[function(_dereq_,module,exports){ -_dereq_(573); - -var types = _dereq_(583); -var def = types.Type.def; -var or = types.Type.or; -var defaults = _dereq_(582).defaults; - -def("JSXAttribute") - .bases("Node") - .build("name", "value") - .field("name", or(def("JSXIdentifier"), def("JSXNamespacedName"))) - .field("value", or( - def("Literal"), // attr="value" - def("JSXExpressionContainer"), // attr={value} - null // attr= or just attr - ), defaults["null"]); - -def("JSXIdentifier") - .bases("Identifier") - .build("name") - .field("name", String); - -def("JSXNamespacedName") - .bases("Node") - .build("namespace", "name") - .field("namespace", def("JSXIdentifier")) - .field("name", def("JSXIdentifier")); - -def("JSXMemberExpression") - .bases("MemberExpression") - .build("object", "property") - .field("object", or(def("JSXIdentifier"), def("JSXMemberExpression"))) - .field("property", def("JSXIdentifier")) - .field("computed", Boolean, defaults.false); - -var JSXElementName = or( - def("JSXIdentifier"), - def("JSXNamespacedName"), - def("JSXMemberExpression") -); - -def("JSXSpreadAttribute") - .bases("Node") - .build("argument") - .field("argument", def("Expression")); - -var JSXAttributes = [or( - def("JSXAttribute"), - def("JSXSpreadAttribute") -)]; - -def("JSXExpressionContainer") - .bases("Expression") - .build("expression") - .field("expression", def("Expression")); - -def("JSXElement") - .bases("Expression") - .build("openingElement", "closingElement", "children") - .field("openingElement", def("JSXOpeningElement")) - .field("closingElement", or(def("JSXClosingElement"), null), defaults["null"]) - .field("children", [or( - def("JSXElement"), - def("JSXExpressionContainer"), - def("JSXText"), - def("Literal") // TODO Esprima should return JSXText instead. - )], defaults.emptyArray) - .field("name", JSXElementName, function() { - // Little-known fact: the `this` object inside a default function - // is none other than the partially-built object itself, and any - // fields initialized directly from builder function arguments - // (like openingElement, closingElement, and children) are - // guaranteed to be available. - return this.openingElement.name; - }, true) // hidden from traversal - .field("selfClosing", Boolean, function() { - return this.openingElement.selfClosing; - }, true) // hidden from traversal - .field("attributes", JSXAttributes, function() { - return this.openingElement.attributes; - }, true); // hidden from traversal - -def("JSXOpeningElement") - .bases("Node") // TODO Does this make sense? Can't really be an JSXElement. - .build("name", "attributes", "selfClosing") - .field("name", JSXElementName) - .field("attributes", JSXAttributes, defaults.emptyArray) - .field("selfClosing", Boolean, defaults["false"]); - -def("JSXClosingElement") - .bases("Node") // TODO Same concern. - .build("name") - .field("name", JSXElementName); - -def("JSXText") - .bases("Literal") - .build("value") - .field("value", String); - -def("JSXEmptyExpression").bases("Expression").build(); - -// Type Annotations -def("Type").bases("Node"); - -def("AnyTypeAnnotation") - .bases("Type") - .build(); - -def("MixedTypeAnnotation") - .bases("Type") - .build(); - -def("VoidTypeAnnotation") - .bases("Type") - .build(); - -def("NumberTypeAnnotation") - .bases("Type") - .build(); - -def("NumberLiteralTypeAnnotation") - .bases("Type") - .build("value", "raw") - .field("value", Number) - .field("raw", String); - -def("StringTypeAnnotation") - .bases("Type") - .build(); - -def("StringLiteralTypeAnnotation") - .bases("Type") - .build("value", "raw") - .field("value", String) - .field("raw", String); - -def("BooleanTypeAnnotation") - .bases("Type") - .build(); - -def("BooleanLiteralTypeAnnotation") - .bases("Type") - .build("value", "raw") - .field("value", Boolean) - .field("raw", String); - -def("TypeAnnotation") - .bases("Node") - .build("typeAnnotation") - .field("typeAnnotation", def("Type")); - -def("NullableTypeAnnotation") - .bases("Type") - .build("typeAnnotation") - .field("typeAnnotation", def("Type")); - -def("FunctionTypeAnnotation") - .bases("Type") - .build("params", "returnType", "rest", "typeParameters") - .field("params", [def("FunctionTypeParam")]) - .field("returnType", def("Type")) - .field("rest", or(def("FunctionTypeParam"), null)) - .field("typeParameters", or(def("TypeParameterDeclaration"), null)); - -def("FunctionTypeParam") - .bases("Node") - .build("name", "typeAnnotation", "optional") - .field("name", def("Identifier")) - .field("typeAnnotation", def("Type")) - .field("optional", Boolean); - -def("ArrayTypeAnnotation") - .bases("Type") - .build("elementType") - .field("elementType", def("Type")); - -def("ObjectTypeAnnotation") - .bases("Type") - .build("properties") - .field("properties", [def("ObjectTypeProperty")]) - .field("indexers", [def("ObjectTypeIndexer")], defaults.emptyArray) - .field("callProperties", - [def("ObjectTypeCallProperty")], - defaults.emptyArray); - -def("ObjectTypeProperty") - .bases("Node") - .build("key", "value", "optional") - .field("key", or(def("Literal"), def("Identifier"))) - .field("value", def("Type")) - .field("optional", Boolean); - -def("ObjectTypeIndexer") - .bases("Node") - .build("id", "key", "value") - .field("id", def("Identifier")) - .field("key", def("Type")) - .field("value", def("Type")); - -def("ObjectTypeCallProperty") - .bases("Node") - .build("value") - .field("value", def("FunctionTypeAnnotation")) - .field("static", Boolean, false); - -def("QualifiedTypeIdentifier") - .bases("Node") - .build("qualification", "id") - .field("qualification", - or(def("Identifier"), - def("QualifiedTypeIdentifier"))) - .field("id", def("Identifier")); - -def("GenericTypeAnnotation") - .bases("Type") - .build("id", "typeParameters") - .field("id", or(def("Identifier"), def("QualifiedTypeIdentifier"))) - .field("typeParameters", or(def("TypeParameterInstantiation"), null)); - -def("MemberTypeAnnotation") - .bases("Type") - .build("object", "property") - .field("object", def("Identifier")) - .field("property", - or(def("MemberTypeAnnotation"), - def("GenericTypeAnnotation"))); - -def("UnionTypeAnnotation") - .bases("Type") - .build("types") - .field("types", [def("Type")]); - -def("IntersectionTypeAnnotation") - .bases("Type") - .build("types") - .field("types", [def("Type")]); - -def("TypeofTypeAnnotation") - .bases("Type") - .build("argument") - .field("argument", def("Type")); - -def("Identifier") - .field("typeAnnotation", or(def("TypeAnnotation"), null), defaults["null"]); - -def("TypeParameterDeclaration") - .bases("Node") - .build("params") - .field("params", [def("Identifier")]); - -def("TypeParameterInstantiation") - .bases("Node") - .build("params") - .field("params", [def("Type")]); - -def("Function") - .field("returnType", - or(def("TypeAnnotation"), null), - defaults["null"]) - .field("typeParameters", - or(def("TypeParameterDeclaration"), null), - defaults["null"]); - -def("ClassProperty") - .build("key", "value", "typeAnnotation", "static") - .field("value", or(def("Expression"), null)) - .field("typeAnnotation", or(def("TypeAnnotation"), null)) - .field("static", Boolean, defaults["false"]); - -def("ClassImplements") - .field("typeParameters", - or(def("TypeParameterInstantiation"), null), - defaults["null"]); - -def("InterfaceDeclaration") - .bases("Statement") - .build("id", "body", "extends") - .field("id", def("Identifier")) - .field("typeParameters", - or(def("TypeParameterDeclaration"), null), - defaults["null"]) - .field("body", def("ObjectTypeAnnotation")) - .field("extends", [def("InterfaceExtends")]); - -def("InterfaceExtends") - .bases("Node") - .build("id") - .field("id", def("Identifier")) - .field("typeParameters", or(def("TypeParameterInstantiation"), null)); - -def("TypeAlias") - .bases("Statement") - .build("id", "typeParameters", "right") - .field("id", def("Identifier")) - .field("typeParameters", or(def("TypeParameterDeclaration"), null)) - .field("right", def("Type")); - -def("TypeCastExpression") - .bases("Expression") - .build("expression", "typeAnnotation") - .field("expression", def("Expression")) - .field("typeAnnotation", def("TypeAnnotation")); - -def("TupleTypeAnnotation") - .bases("Type") - .build("types") - .field("types", [def("Type")]); - -def("DeclareVariable") - .bases("Statement") - .build("id") - .field("id", def("Identifier")); - -def("DeclareFunction") - .bases("Statement") - .build("id") - .field("id", def("Identifier")); - -def("DeclareClass") - .bases("InterfaceDeclaration") - .build("id"); - -def("DeclareModule") - .bases("Statement") - .build("id", "body") - .field("id", or(def("Identifier"), def("Literal"))) - .field("body", def("BlockStatement")); - -},{"573":573,"582":582,"583":583}],576:[function(_dereq_,module,exports){ -_dereq_(570); -var types = _dereq_(583); -var def = types.Type.def; -var or = types.Type.or; -var shared = _dereq_(582); -var geq = shared.geq; -var defaults = shared.defaults; - -def("Function") - // SpiderMonkey allows expression closures: function(x) x+1 - .field("body", or(def("BlockStatement"), def("Expression"))); - -def("ForInStatement") - .build("left", "right", "body", "each") - .field("each", Boolean, defaults["false"]); - -def("ForOfStatement") - .bases("Statement") - .build("left", "right", "body") - .field("left", or( - def("VariableDeclaration"), - def("Expression"))) - .field("right", def("Expression")) - .field("body", def("Statement")); - -def("LetStatement") - .bases("Statement") - .build("head", "body") - // TODO Deviating from the spec by reusing VariableDeclarator here. - .field("head", [def("VariableDeclarator")]) - .field("body", def("Statement")); - -def("LetExpression") - .bases("Expression") - .build("head", "body") - // TODO Deviating from the spec by reusing VariableDeclarator here. - .field("head", [def("VariableDeclarator")]) - .field("body", def("Expression")); - -def("GraphExpression") - .bases("Expression") - .build("index", "expression") - .field("index", geq(0)) - .field("expression", def("Literal")); - -def("GraphIndexExpression") - .bases("Expression") - .build("index") - .field("index", geq(0)); - -},{"570":570,"582":582,"583":583}],577:[function(_dereq_,module,exports){ -var types = _dereq_(584); -var getFieldNames = types.getFieldNames; -var getFieldValue = types.getFieldValue; -var isArray = types.builtInTypes.array; -var isObject = types.builtInTypes.object; -var isDate = types.builtInTypes.Date; -var isRegExp = types.builtInTypes.RegExp; -var hasOwn = Object.prototype.hasOwnProperty; - -function astNodesAreEquivalent(a, b, problemPath) { - if (isArray.check(problemPath)) { - problemPath.length = 0; - } else { - problemPath = null; - } - - return areEquivalent(a, b, problemPath); -} - -astNodesAreEquivalent.assert = function(a, b) { - var problemPath = []; - if (!astNodesAreEquivalent(a, b, problemPath)) { - if (problemPath.length === 0) { - if (a !== b) { - throw new Error("Nodes must be equal"); - } - } else { - throw new Error( - "Nodes differ in the following path: " + - problemPath.map(subscriptForProperty).join("") - ); - } - } -}; - -function subscriptForProperty(property) { - if (/[_$a-z][_$a-z0-9]*/i.test(property)) { - return "." + property; - } - return "[" + JSON.stringify(property) + "]"; -} - -function areEquivalent(a, b, problemPath) { - if (a === b) { - return true; - } - - if (isArray.check(a)) { - return arraysAreEquivalent(a, b, problemPath); - } - - if (isObject.check(a)) { - return objectsAreEquivalent(a, b, problemPath); - } - - if (isDate.check(a)) { - return isDate.check(b) && (+a === +b); - } - - if (isRegExp.check(a)) { - return isRegExp.check(b) && ( - a.source === b.source && - a.global === b.global && - a.multiline === b.multiline && - a.ignoreCase === b.ignoreCase - ); - } - - return a == b; -} - -function arraysAreEquivalent(a, b, problemPath) { - isArray.assert(a); - var aLength = a.length; - - if (!isArray.check(b) || b.length !== aLength) { - if (problemPath) { - problemPath.push("length"); - } - return false; - } - - for (var i = 0; i < aLength; ++i) { - if (problemPath) { - problemPath.push(i); - } - - if (i in a !== i in b) { - return false; - } - - if (!areEquivalent(a[i], b[i], problemPath)) { - return false; - } - - if (problemPath) { - var problemPathTail = problemPath.pop(); - if (problemPathTail !== i) { - throw new Error("" + problemPathTail); - } - } - } - - return true; -} - -function objectsAreEquivalent(a, b, problemPath) { - isObject.assert(a); - if (!isObject.check(b)) { - return false; - } - - // Fast path for a common property of AST nodes. - if (a.type !== b.type) { - if (problemPath) { - problemPath.push("type"); - } - return false; - } - - var aNames = getFieldNames(a); - var aNameCount = aNames.length; - - var bNames = getFieldNames(b); - var bNameCount = bNames.length; - - if (aNameCount === bNameCount) { - for (var i = 0; i < aNameCount; ++i) { - var name = aNames[i]; - var aChild = getFieldValue(a, name); - var bChild = getFieldValue(b, name); - - if (problemPath) { - problemPath.push(name); - } - - if (!areEquivalent(aChild, bChild, problemPath)) { - return false; - } - - if (problemPath) { - var problemPathTail = problemPath.pop(); - if (problemPathTail !== name) { - throw new Error("" + problemPathTail); - } - } - } - - return true; - } - - if (!problemPath) { - return false; - } - - // Since aNameCount !== bNameCount, we need to find some name that's - // missing in aNames but present in bNames, or vice-versa. - - var seenNames = Object.create(null); - - for (i = 0; i < aNameCount; ++i) { - seenNames[aNames[i]] = true; - } - - for (i = 0; i < bNameCount; ++i) { - name = bNames[i]; - - if (!hasOwn.call(seenNames, name)) { - problemPath.push(name); - return false; - } - - delete seenNames[name]; - } - - for (name in seenNames) { - problemPath.push(name); - break; - } - - return false; -} - -module.exports = astNodesAreEquivalent; - -},{"584":584}],578:[function(_dereq_,module,exports){ -var types = _dereq_(583); -var n = types.namedTypes; -var b = types.builders; -var isNumber = types.builtInTypes.number; -var isArray = types.builtInTypes.array; -var Path = _dereq_(580); -var Scope = _dereq_(581); - -function NodePath(value, parentPath, name) { - if (!(this instanceof NodePath)) { - throw new Error("NodePath constructor cannot be invoked without 'new'"); - } - Path.call(this, value, parentPath, name); -} - -var NPp = NodePath.prototype = Object.create(Path.prototype, { - constructor: { - value: NodePath, - enumerable: false, - writable: true, - configurable: true - } -}); - -Object.defineProperties(NPp, { - node: { - get: function() { - Object.defineProperty(this, "node", { - configurable: true, // Enable deletion. - value: this._computeNode() - }); - - return this.node; - } - }, - - parent: { - get: function() { - Object.defineProperty(this, "parent", { - configurable: true, // Enable deletion. - value: this._computeParent() - }); - - return this.parent; - } - }, - - scope: { - get: function() { - Object.defineProperty(this, "scope", { - configurable: true, // Enable deletion. - value: this._computeScope() - }); - - return this.scope; - } - } -}); - -NPp.replace = function() { - delete this.node; - delete this.parent; - delete this.scope; - return Path.prototype.replace.apply(this, arguments); -}; - -NPp.prune = function() { - var remainingNodePath = this.parent; - - this.replace(); - - return cleanUpNodesAfterPrune(remainingNodePath); -}; - -// The value of the first ancestor Path whose value is a Node. -NPp._computeNode = function() { - var value = this.value; - if (n.Node.check(value)) { - return value; - } - - var pp = this.parentPath; - return pp && pp.node || null; -}; - -// The first ancestor Path whose value is a Node distinct from this.node. -NPp._computeParent = function() { - var value = this.value; - var pp = this.parentPath; - - if (!n.Node.check(value)) { - while (pp && !n.Node.check(pp.value)) { - pp = pp.parentPath; - } - - if (pp) { - pp = pp.parentPath; - } - } - - while (pp && !n.Node.check(pp.value)) { - pp = pp.parentPath; - } - - return pp || null; -}; - -// The closest enclosing scope that governs this node. -NPp._computeScope = function() { - var value = this.value; - var pp = this.parentPath; - var scope = pp && pp.scope; - - if (n.Node.check(value) && - Scope.isEstablishedBy(value)) { - scope = new Scope(this, scope); - } - - return scope || null; -}; - -NPp.getValueProperty = function(name) { - return types.getFieldValue(this.value, name); -}; - -/** - * Determine whether this.node needs to be wrapped in parentheses in order - * for a parser to reproduce the same local AST structure. - * - * For instance, in the expression `(1 + 2) * 3`, the BinaryExpression - * whose operator is "+" needs parentheses, because `1 + 2 * 3` would - * parse differently. - * - * If assumeExpressionContext === true, we don't worry about edge cases - * like an anonymous FunctionExpression appearing lexically first in its - * enclosing statement and thus needing parentheses to avoid being parsed - * as a FunctionDeclaration with a missing name. - */ -NPp.needsParens = function(assumeExpressionContext) { - var pp = this.parentPath; - if (!pp) { - return false; - } - - var node = this.value; - - // Only expressions need parentheses. - if (!n.Expression.check(node)) { - return false; - } - - // Identifiers never need parentheses. - if (node.type === "Identifier") { - return false; - } - - while (!n.Node.check(pp.value)) { - pp = pp.parentPath; - if (!pp) { - return false; - } - } - - var parent = pp.value; - - switch (node.type) { - case "UnaryExpression": - case "SpreadElement": - case "SpreadProperty": - return parent.type === "MemberExpression" - && this.name === "object" - && parent.object === node; - - case "BinaryExpression": - case "LogicalExpression": - switch (parent.type) { - case "CallExpression": - return this.name === "callee" - && parent.callee === node; - - case "UnaryExpression": - case "SpreadElement": - case "SpreadProperty": - return true; - - case "MemberExpression": - return this.name === "object" - && parent.object === node; - - case "BinaryExpression": - case "LogicalExpression": - var po = parent.operator; - var pp = PRECEDENCE[po]; - var no = node.operator; - var np = PRECEDENCE[no]; - - if (pp > np) { - return true; - } - - if (pp === np && this.name === "right") { - if (parent.right !== node) { - throw new Error("Nodes must be equal"); - } - return true; - } - - default: - return false; - } - - case "SequenceExpression": - switch (parent.type) { - case "ForStatement": - // Although parentheses wouldn't hurt around sequence - // expressions in the head of for loops, traditional style - // dictates that e.g. i++, j++ should not be wrapped with - // parentheses. - return false; - - case "ExpressionStatement": - return this.name !== "expression"; - - default: - // Otherwise err on the side of overparenthesization, adding - // explicit exceptions above if this proves overzealous. - return true; - } - - case "YieldExpression": - switch (parent.type) { - case "BinaryExpression": - case "LogicalExpression": - case "UnaryExpression": - case "SpreadElement": - case "SpreadProperty": - case "CallExpression": - case "MemberExpression": - case "NewExpression": - case "ConditionalExpression": - case "YieldExpression": - return true; - - default: - return false; - } - - case "Literal": - return parent.type === "MemberExpression" - && isNumber.check(node.value) - && this.name === "object" - && parent.object === node; - - case "AssignmentExpression": - case "ConditionalExpression": - switch (parent.type) { - case "UnaryExpression": - case "SpreadElement": - case "SpreadProperty": - case "BinaryExpression": - case "LogicalExpression": - return true; - - case "CallExpression": - return this.name === "callee" - && parent.callee === node; - - case "ConditionalExpression": - return this.name === "test" - && parent.test === node; - - case "MemberExpression": - return this.name === "object" - && parent.object === node; - - default: - return false; - } - - default: - if (parent.type === "NewExpression" && - this.name === "callee" && - parent.callee === node) { - return containsCallExpression(node); - } - } - - if (assumeExpressionContext !== true && - !this.canBeFirstInStatement() && - this.firstInStatement()) - return true; - - return false; -}; - -function isBinary(node) { - return n.BinaryExpression.check(node) - || n.LogicalExpression.check(node); -} - -function isUnaryLike(node) { - return n.UnaryExpression.check(node) - // I considered making SpreadElement and SpreadProperty subtypes - // of UnaryExpression, but they're not really Expression nodes. - || (n.SpreadElement && n.SpreadElement.check(node)) - || (n.SpreadProperty && n.SpreadProperty.check(node)); -} - -var PRECEDENCE = {}; -[["||"], - ["&&"], - ["|"], - ["^"], - ["&"], - ["==", "===", "!=", "!=="], - ["<", ">", "<=", ">=", "in", "instanceof"], - [">>", "<<", ">>>"], - ["+", "-"], - ["*", "/", "%"] -].forEach(function(tier, i) { - tier.forEach(function(op) { - PRECEDENCE[op] = i; - }); -}); - -function containsCallExpression(node) { - if (n.CallExpression.check(node)) { - return true; - } - - if (isArray.check(node)) { - return node.some(containsCallExpression); - } - - if (n.Node.check(node)) { - return types.someField(node, function(name, child) { - return containsCallExpression(child); - }); - } - - return false; -} - -NPp.canBeFirstInStatement = function() { - var node = this.node; - return !n.FunctionExpression.check(node) - && !n.ObjectExpression.check(node); -}; - -NPp.firstInStatement = function() { - return firstInStatement(this); -}; - -function firstInStatement(path) { - for (var node, parent; path.parent; path = path.parent) { - node = path.node; - parent = path.parent.node; - - if (n.BlockStatement.check(parent) && - path.parent.name === "body" && - path.name === 0) { - if (parent.body[0] !== node) { - throw new Error("Nodes must be equal"); - } - return true; - } - - if (n.ExpressionStatement.check(parent) && - path.name === "expression") { - if (parent.expression !== node) { - throw new Error("Nodes must be equal"); - } - return true; - } - - if (n.SequenceExpression.check(parent) && - path.parent.name === "expressions" && - path.name === 0) { - if (parent.expressions[0] !== node) { - throw new Error("Nodes must be equal"); - } - continue; - } - - if (n.CallExpression.check(parent) && - path.name === "callee") { - if (parent.callee !== node) { - throw new Error("Nodes must be equal"); - } - continue; - } - - if (n.MemberExpression.check(parent) && - path.name === "object") { - if (parent.object !== node) { - throw new Error("Nodes must be equal"); - } - continue; - } - - if (n.ConditionalExpression.check(parent) && - path.name === "test") { - if (parent.test !== node) { - throw new Error("Nodes must be equal"); - } - continue; - } - - if (isBinary(parent) && - path.name === "left") { - if (parent.left !== node) { - throw new Error("Nodes must be equal"); - } - continue; - } - - if (n.UnaryExpression.check(parent) && - !parent.prefix && - path.name === "argument") { - if (parent.argument !== node) { - throw new Error("Nodes must be equal"); - } - continue; - } - - return false; - } - - return true; -} - -/** - * Pruning certain nodes will result in empty or incomplete nodes, here we clean those nodes up. - */ -function cleanUpNodesAfterPrune(remainingNodePath) { - if (n.VariableDeclaration.check(remainingNodePath.node)) { - var declarations = remainingNodePath.get('declarations').value; - if (!declarations || declarations.length === 0) { - return remainingNodePath.prune(); - } - } else if (n.ExpressionStatement.check(remainingNodePath.node)) { - if (!remainingNodePath.get('expression').value) { - return remainingNodePath.prune(); - } - } else if (n.IfStatement.check(remainingNodePath.node)) { - cleanUpIfStatementAfterPrune(remainingNodePath); - } - - return remainingNodePath; -} - -function cleanUpIfStatementAfterPrune(ifStatement) { - var testExpression = ifStatement.get('test').value; - var alternate = ifStatement.get('alternate').value; - var consequent = ifStatement.get('consequent').value; - - if (!consequent && !alternate) { - var testExpressionStatement = b.expressionStatement(testExpression); - - ifStatement.replace(testExpressionStatement); - } else if (!consequent && alternate) { - var negatedTestExpression = b.unaryExpression('!', testExpression, true); - - if (n.UnaryExpression.check(testExpression) && testExpression.operator === '!') { - negatedTestExpression = testExpression.argument; - } - - ifStatement.get("test").replace(negatedTestExpression); - ifStatement.get("consequent").replace(alternate); - ifStatement.get("alternate").replace(); - } -} - -module.exports = NodePath; - -},{"580":580,"581":581,"583":583}],579:[function(_dereq_,module,exports){ -var types = _dereq_(583); -var NodePath = _dereq_(578); -var Printable = types.namedTypes.Printable; -var isArray = types.builtInTypes.array; -var isObject = types.builtInTypes.object; -var isFunction = types.builtInTypes.function; -var hasOwn = Object.prototype.hasOwnProperty; -var undefined; - -function PathVisitor() { - if (!(this instanceof PathVisitor)) { - throw new Error( - "PathVisitor constructor cannot be invoked without 'new'" - ); - } - - // Permanent state. - this._reusableContextStack = []; - - this._methodNameTable = computeMethodNameTable(this); - this._shouldVisitComments = - hasOwn.call(this._methodNameTable, "Block") || - hasOwn.call(this._methodNameTable, "Line"); - - this.Context = makeContextConstructor(this); - - // State reset every time PathVisitor.prototype.visit is called. - this._visiting = false; - this._changeReported = false; -} - -function computeMethodNameTable(visitor) { - var typeNames = Object.create(null); - - for (var methodName in visitor) { - if (/^visit[A-Z]/.test(methodName)) { - typeNames[methodName.slice("visit".length)] = true; - } - } - - var supertypeTable = types.computeSupertypeLookupTable(typeNames); - var methodNameTable = Object.create(null); - - var typeNames = Object.keys(supertypeTable); - var typeNameCount = typeNames.length; - for (var i = 0; i < typeNameCount; ++i) { - var typeName = typeNames[i]; - methodName = "visit" + supertypeTable[typeName]; - if (isFunction.check(visitor[methodName])) { - methodNameTable[typeName] = methodName; - } - } - - return methodNameTable; -} - -PathVisitor.fromMethodsObject = function fromMethodsObject(methods) { - if (methods instanceof PathVisitor) { - return methods; - } - - if (!isObject.check(methods)) { - // An empty visitor? - return new PathVisitor; - } - - function Visitor() { - if (!(this instanceof Visitor)) { - throw new Error( - "Visitor constructor cannot be invoked without 'new'" - ); - } - PathVisitor.call(this); - } - - var Vp = Visitor.prototype = Object.create(PVp); - Vp.constructor = Visitor; - - extend(Vp, methods); - extend(Visitor, PathVisitor); - - isFunction.assert(Visitor.fromMethodsObject); - isFunction.assert(Visitor.visit); - - return new Visitor; -}; - -function extend(target, source) { - for (var property in source) { - if (hasOwn.call(source, property)) { - target[property] = source[property]; - } - } - - return target; -} - -PathVisitor.visit = function visit(node, methods) { - return PathVisitor.fromMethodsObject(methods).visit(node); -}; - -var PVp = PathVisitor.prototype; - -PVp.visit = function() { - if (this._visiting) { - throw new Error( - "Recursively calling visitor.visit(path) resets visitor state. " + - "Try this.visit(path) or this.traverse(path) instead." - ); - } - - // Private state that needs to be reset before every traversal. - this._visiting = true; - this._changeReported = false; - this._abortRequested = false; - - var argc = arguments.length; - var args = new Array(argc) - for (var i = 0; i < argc; ++i) { - args[i] = arguments[i]; - } - - if (!(args[0] instanceof NodePath)) { - args[0] = new NodePath({ root: args[0] }).get("root"); - } - - // Called with the same arguments as .visit. - this.reset.apply(this, args); - - try { - var root = this.visitWithoutReset(args[0]); - var didNotThrow = true; - } finally { - this._visiting = false; - - if (!didNotThrow && this._abortRequested) { - // If this.visitWithoutReset threw an exception and - // this._abortRequested was set to true, return the root of - // the AST instead of letting the exception propagate, so that - // client code does not have to provide a try-catch block to - // intercept the AbortRequest exception. Other kinds of - // exceptions will propagate without being intercepted and - // rethrown by a catch block, so their stacks will accurately - // reflect the original throwing context. - return args[0].value; - } - } - - return root; -}; - -PVp.AbortRequest = function AbortRequest() {}; -PVp.abort = function() { - var visitor = this; - visitor._abortRequested = true; - var request = new visitor.AbortRequest(); - - // If you decide to catch this exception and stop it from propagating, - // make sure to call its cancel method to avoid silencing other - // exceptions that might be thrown later in the traversal. - request.cancel = function() { - visitor._abortRequested = false; - }; - - throw request; -}; - -PVp.reset = function(path/*, additional arguments */) { - // Empty stub; may be reassigned or overridden by subclasses. -}; - -PVp.visitWithoutReset = function(path) { - if (this instanceof this.Context) { - // Since this.Context.prototype === this, there's a chance we - // might accidentally call context.visitWithoutReset. If that - // happens, re-invoke the method against context.visitor. - return this.visitor.visitWithoutReset(path); - } - - if (!(path instanceof NodePath)) { - throw new Error(""); - } - - var value = path.value; - - var methodName = value && - typeof value === "object" && - typeof value.type === "string" && - this._methodNameTable[value.type]; - - if (methodName) { - var context = this.acquireContext(path); - try { - return context.invokeVisitorMethod(methodName); - } finally { - this.releaseContext(context); - } - - } else { - // If there was no visitor method to call, visit the children of - // this node generically. - return visitChildren(path, this); - } -}; - -function visitChildren(path, visitor) { - if (!(path instanceof NodePath)) { - throw new Error(""); - } - if (!(visitor instanceof PathVisitor)) { - throw new Error(""); - } - - var value = path.value; - - if (isArray.check(value)) { - path.each(visitor.visitWithoutReset, visitor); - } else if (!isObject.check(value)) { - // No children to visit. - } else { - var childNames = types.getFieldNames(value); - - // The .comments field of the Node type is hidden, so we only - // visit it if the visitor defines visitBlock or visitLine, and - // value.comments is defined. - if (visitor._shouldVisitComments && - value.comments && - childNames.indexOf("comments") < 0) { - childNames.push("comments"); - } - - var childCount = childNames.length; - var childPaths = []; - - for (var i = 0; i < childCount; ++i) { - var childName = childNames[i]; - if (!hasOwn.call(value, childName)) { - value[childName] = types.getFieldValue(value, childName); - } - childPaths.push(path.get(childName)); - } - - for (var i = 0; i < childCount; ++i) { - visitor.visitWithoutReset(childPaths[i]); - } - } - - return path.value; -} - -PVp.acquireContext = function(path) { - if (this._reusableContextStack.length === 0) { - return new this.Context(path); - } - return this._reusableContextStack.pop().reset(path); -}; - -PVp.releaseContext = function(context) { - if (!(context instanceof this.Context)) { - throw new Error(""); - } - this._reusableContextStack.push(context); - context.currentPath = null; -}; - -PVp.reportChanged = function() { - this._changeReported = true; -}; - -PVp.wasChangeReported = function() { - return this._changeReported; -}; - -function makeContextConstructor(visitor) { - function Context(path) { - if (!(this instanceof Context)) { - throw new Error(""); - } - if (!(this instanceof PathVisitor)) { - throw new Error(""); - } - if (!(path instanceof NodePath)) { - throw new Error(""); - } - - Object.defineProperty(this, "visitor", { - value: visitor, - writable: false, - enumerable: true, - configurable: false - }); - - this.currentPath = path; - this.needToCallTraverse = true; - - Object.seal(this); - } - - if (!(visitor instanceof PathVisitor)) { - throw new Error(""); - } - - // Note that the visitor object is the prototype of Context.prototype, - // so all visitor methods are inherited by context objects. - var Cp = Context.prototype = Object.create(visitor); - - Cp.constructor = Context; - extend(Cp, sharedContextProtoMethods); - - return Context; -} - -// Every PathVisitor has a different this.Context constructor and -// this.Context.prototype object, but those prototypes can all use the -// same reset, invokeVisitorMethod, and traverse function objects. -var sharedContextProtoMethods = Object.create(null); - -sharedContextProtoMethods.reset = -function reset(path) { - if (!(this instanceof this.Context)) { - throw new Error(""); - } - if (!(path instanceof NodePath)) { - throw new Error(""); - } - - this.currentPath = path; - this.needToCallTraverse = true; - - return this; -}; - -sharedContextProtoMethods.invokeVisitorMethod = -function invokeVisitorMethod(methodName) { - if (!(this instanceof this.Context)) { - throw new Error(""); - } - if (!(this.currentPath instanceof NodePath)) { - throw new Error(""); - } - - var result = this.visitor[methodName].call(this, this.currentPath); - - if (result === false) { - // Visitor methods return false to indicate that they have handled - // their own traversal needs, and we should not complain if - // this.needToCallTraverse is still true. - this.needToCallTraverse = false; - - } else if (result !== undefined) { - // Any other non-undefined value returned from the visitor method - // is interpreted as a replacement value. - this.currentPath = this.currentPath.replace(result)[0]; - - if (this.needToCallTraverse) { - // If this.traverse still hasn't been called, visit the - // children of the replacement node. - this.traverse(this.currentPath); - } - } - - if (this.needToCallTraverse !== false) { - throw new Error( - "Must either call this.traverse or return false in " + methodName - ); - } - - var path = this.currentPath; - return path && path.value; -}; - -sharedContextProtoMethods.traverse = -function traverse(path, newVisitor) { - if (!(this instanceof this.Context)) { - throw new Error(""); - } - if (!(path instanceof NodePath)) { - throw new Error(""); - } - if (!(this.currentPath instanceof NodePath)) { - throw new Error(""); - } - - this.needToCallTraverse = false; - - return visitChildren(path, PathVisitor.fromMethodsObject( - newVisitor || this.visitor - )); -}; - -sharedContextProtoMethods.visit = -function visit(path, newVisitor) { - if (!(this instanceof this.Context)) { - throw new Error(""); - } - if (!(path instanceof NodePath)) { - throw new Error(""); - } - if (!(this.currentPath instanceof NodePath)) { - throw new Error(""); - } - - this.needToCallTraverse = false; - - return PathVisitor.fromMethodsObject( - newVisitor || this.visitor - ).visitWithoutReset(path); -}; - -sharedContextProtoMethods.reportChanged = function reportChanged() { - this.visitor.reportChanged(); -}; - -sharedContextProtoMethods.abort = function abort() { - this.needToCallTraverse = false; - this.visitor.abort(); -}; - -module.exports = PathVisitor; - -},{"578":578,"583":583}],580:[function(_dereq_,module,exports){ -var Op = Object.prototype; -var hasOwn = Op.hasOwnProperty; -var types = _dereq_(583); -var isArray = types.builtInTypes.array; -var isNumber = types.builtInTypes.number; -var Ap = Array.prototype; -var slice = Ap.slice; -var map = Ap.map; - -function Path(value, parentPath, name) { - if (!(this instanceof Path)) { - throw new Error("Path constructor cannot be invoked without 'new'"); - } - - if (parentPath) { - if (!(parentPath instanceof Path)) { - throw new Error(""); - } - } else { - parentPath = null; - name = null; - } - - // The value encapsulated by this Path, generally equal to - // parentPath.value[name] if we have a parentPath. - this.value = value; - - // The immediate parent Path of this Path. - this.parentPath = parentPath; - - // The name of the property of parentPath.value through which this - // Path's value was reached. - this.name = name; - - // Calling path.get("child") multiple times always returns the same - // child Path object, for both performance and consistency reasons. - this.__childCache = null; -} - -var Pp = Path.prototype; - -function getChildCache(path) { - // Lazily create the child cache. This also cheapens cache - // invalidation, since you can just reset path.__childCache to null. - return path.__childCache || (path.__childCache = Object.create(null)); -} - -function getChildPath(path, name) { - var cache = getChildCache(path); - var actualChildValue = path.getValueProperty(name); - var childPath = cache[name]; - if (!hasOwn.call(cache, name) || - // Ensure consistency between cache and reality. - childPath.value !== actualChildValue) { - childPath = cache[name] = new path.constructor( - actualChildValue, path, name - ); - } - return childPath; -} - -// This method is designed to be overridden by subclasses that need to -// handle missing properties, etc. -Pp.getValueProperty = function getValueProperty(name) { - return this.value[name]; -}; - -Pp.get = function get(name) { - var path = this; - var names = arguments; - var count = names.length; - - for (var i = 0; i < count; ++i) { - path = getChildPath(path, names[i]); - } - - return path; -}; - -Pp.each = function each(callback, context) { - var childPaths = []; - var len = this.value.length; - var i = 0; - - // Collect all the original child paths before invoking the callback. - for (var i = 0; i < len; ++i) { - if (hasOwn.call(this.value, i)) { - childPaths[i] = this.get(i); - } - } - - // Invoke the callback on just the original child paths, regardless of - // any modifications made to the array by the callback. I chose these - // semantics over cleverly invoking the callback on new elements because - // this way is much easier to reason about. - context = context || this; - for (i = 0; i < len; ++i) { - if (hasOwn.call(childPaths, i)) { - callback.call(context, childPaths[i]); - } - } -}; - -Pp.map = function map(callback, context) { - var result = []; - - this.each(function(childPath) { - result.push(callback.call(this, childPath)); - }, context); - - return result; -}; - -Pp.filter = function filter(callback, context) { - var result = []; - - this.each(function(childPath) { - if (callback.call(this, childPath)) { - result.push(childPath); - } - }, context); - - return result; -}; - -function emptyMoves() {} -function getMoves(path, offset, start, end) { - isArray.assert(path.value); - - if (offset === 0) { - return emptyMoves; - } - - var length = path.value.length; - if (length < 1) { - return emptyMoves; - } - - var argc = arguments.length; - if (argc === 2) { - start = 0; - end = length; - } else if (argc === 3) { - start = Math.max(start, 0); - end = length; - } else { - start = Math.max(start, 0); - end = Math.min(end, length); - } - - isNumber.assert(start); - isNumber.assert(end); - - var moves = Object.create(null); - var cache = getChildCache(path); - - for (var i = start; i < end; ++i) { - if (hasOwn.call(path.value, i)) { - var childPath = path.get(i); - if (childPath.name !== i) { - throw new Error(""); - } - var newIndex = i + offset; - childPath.name = newIndex; - moves[newIndex] = childPath; - delete cache[i]; - } - } - - delete cache.length; - - return function() { - for (var newIndex in moves) { - var childPath = moves[newIndex]; - if (childPath.name !== +newIndex) { - throw new Error(""); - } - cache[newIndex] = childPath; - path.value[newIndex] = childPath.value; - } - }; -} - -Pp.shift = function shift() { - var move = getMoves(this, -1); - var result = this.value.shift(); - move(); - return result; -}; - -Pp.unshift = function unshift(node) { - var move = getMoves(this, arguments.length); - var result = this.value.unshift.apply(this.value, arguments); - move(); - return result; -}; - -Pp.push = function push(node) { - isArray.assert(this.value); - delete getChildCache(this).length - return this.value.push.apply(this.value, arguments); -}; - -Pp.pop = function pop() { - isArray.assert(this.value); - var cache = getChildCache(this); - delete cache[this.value.length - 1]; - delete cache.length; - return this.value.pop(); -}; - -Pp.insertAt = function insertAt(index, node) { - var argc = arguments.length; - var move = getMoves(this, argc - 1, index); - if (move === emptyMoves) { - return this; - } - - index = Math.max(index, 0); - - for (var i = 1; i < argc; ++i) { - this.value[index + i - 1] = arguments[i]; - } - - move(); - - return this; -}; - -Pp.insertBefore = function insertBefore(node) { - var pp = this.parentPath; - var argc = arguments.length; - var insertAtArgs = [this.name]; - for (var i = 0; i < argc; ++i) { - insertAtArgs.push(arguments[i]); - } - return pp.insertAt.apply(pp, insertAtArgs); -}; - -Pp.insertAfter = function insertAfter(node) { - var pp = this.parentPath; - var argc = arguments.length; - var insertAtArgs = [this.name + 1]; - for (var i = 0; i < argc; ++i) { - insertAtArgs.push(arguments[i]); - } - return pp.insertAt.apply(pp, insertAtArgs); -}; - -function repairRelationshipWithParent(path) { - if (!(path instanceof Path)) { - throw new Error(""); - } - - var pp = path.parentPath; - if (!pp) { - // Orphan paths have no relationship to repair. - return path; - } - - var parentValue = pp.value; - var parentCache = getChildCache(pp); - - // Make sure parentCache[path.name] is populated. - if (parentValue[path.name] === path.value) { - parentCache[path.name] = path; - } else if (isArray.check(parentValue)) { - // Something caused path.name to become out of date, so attempt to - // recover by searching for path.value in parentValue. - var i = parentValue.indexOf(path.value); - if (i >= 0) { - parentCache[path.name = i] = path; - } - } else { - // If path.value disagrees with parentValue[path.name], and - // path.name is not an array index, let path.value become the new - // parentValue[path.name] and update parentCache accordingly. - parentValue[path.name] = path.value; - parentCache[path.name] = path; - } - - if (parentValue[path.name] !== path.value) { - throw new Error(""); - } - if (path.parentPath.get(path.name) !== path) { - throw new Error(""); - } - - return path; -} - -Pp.replace = function replace(replacement) { - var results = []; - var parentValue = this.parentPath.value; - var parentCache = getChildCache(this.parentPath); - var count = arguments.length; - - repairRelationshipWithParent(this); - - if (isArray.check(parentValue)) { - var originalLength = parentValue.length; - var move = getMoves(this.parentPath, count - 1, this.name + 1); - - var spliceArgs = [this.name, 1]; - for (var i = 0; i < count; ++i) { - spliceArgs.push(arguments[i]); - } - - var splicedOut = parentValue.splice.apply(parentValue, spliceArgs); - - if (splicedOut[0] !== this.value) { - throw new Error(""); - } - if (parentValue.length !== (originalLength - 1 + count)) { - throw new Error(""); - } - - move(); - - if (count === 0) { - delete this.value; - delete parentCache[this.name]; - this.__childCache = null; - - } else { - if (parentValue[this.name] !== replacement) { - throw new Error(""); - } - - if (this.value !== replacement) { - this.value = replacement; - this.__childCache = null; - } - - for (i = 0; i < count; ++i) { - results.push(this.parentPath.get(this.name + i)); - } - - if (results[0] !== this) { - throw new Error(""); - } - } - - } else if (count === 1) { - if (this.value !== replacement) { - this.__childCache = null; - } - this.value = parentValue[this.name] = replacement; - results.push(this); - - } else if (count === 0) { - delete parentValue[this.name]; - delete this.value; - this.__childCache = null; - - // Leave this path cached as parentCache[this.name], even though - // it no longer has a value defined. - - } else { - throw new Error("Could not replace path"); - } - - return results; -}; - -module.exports = Path; - -},{"583":583}],581:[function(_dereq_,module,exports){ -var types = _dereq_(583); -var Type = types.Type; -var namedTypes = types.namedTypes; -var Node = namedTypes.Node; -var Expression = namedTypes.Expression; -var isArray = types.builtInTypes.array; -var hasOwn = Object.prototype.hasOwnProperty; -var b = types.builders; - -function Scope(path, parentScope) { - if (!(this instanceof Scope)) { - throw new Error("Scope constructor cannot be invoked without 'new'"); - } - if (!(path instanceof _dereq_(578))) { - throw new Error(""); - } - ScopeType.assert(path.value); - - var depth; - - if (parentScope) { - if (!(parentScope instanceof Scope)) { - throw new Error(""); - } - depth = parentScope.depth + 1; - } else { - parentScope = null; - depth = 0; - } - - Object.defineProperties(this, { - path: { value: path }, - node: { value: path.value }, - isGlobal: { value: !parentScope, enumerable: true }, - depth: { value: depth }, - parent: { value: parentScope }, - bindings: { value: {} } - }); -} - -var scopeTypes = [ - // Program nodes introduce global scopes. - namedTypes.Program, - - // Function is the supertype of FunctionExpression, - // FunctionDeclaration, ArrowExpression, etc. - namedTypes.Function, - - // In case you didn't know, the caught parameter shadows any variable - // of the same name in an outer scope. - namedTypes.CatchClause -]; - -var ScopeType = Type.or.apply(Type, scopeTypes); - -Scope.isEstablishedBy = function(node) { - return ScopeType.check(node); -}; - -var Sp = Scope.prototype; - -// Will be overridden after an instance lazily calls scanScope. -Sp.didScan = false; - -Sp.declares = function(name) { - this.scan(); - return hasOwn.call(this.bindings, name); -}; - -Sp.declareTemporary = function(prefix) { - if (prefix) { - if (!/^[a-z$_]/i.test(prefix)) { - throw new Error(""); - } - } else { - prefix = "t$"; - } - - // Include this.depth in the name to make sure the name does not - // collide with any variables in nested/enclosing scopes. - prefix += this.depth.toString(36) + "$"; - - this.scan(); - - var index = 0; - while (this.declares(prefix + index)) { - ++index; - } - - var name = prefix + index; - return this.bindings[name] = types.builders.identifier(name); -}; - -Sp.injectTemporary = function(identifier, init) { - identifier || (identifier = this.declareTemporary()); - - var bodyPath = this.path.get("body"); - if (namedTypes.BlockStatement.check(bodyPath.value)) { - bodyPath = bodyPath.get("body"); - } - - bodyPath.unshift( - b.variableDeclaration( - "var", - [b.variableDeclarator(identifier, init || null)] - ) - ); - - return identifier; -}; - -Sp.scan = function(force) { - if (force || !this.didScan) { - for (var name in this.bindings) { - // Empty out this.bindings, just in cases. - delete this.bindings[name]; - } - scanScope(this.path, this.bindings); - this.didScan = true; - } -}; - -Sp.getBindings = function () { - this.scan(); - return this.bindings; -}; - -function scanScope(path, bindings) { - var node = path.value; - ScopeType.assert(node); - - if (namedTypes.CatchClause.check(node)) { - // A catch clause establishes a new scope but the only variable - // bound in that scope is the catch parameter. Any other - // declarations create bindings in the outer scope. - addPattern(path.get("param"), bindings); - - } else { - recursiveScanScope(path, bindings); - } -} - -function recursiveScanScope(path, bindings) { - var node = path.value; - - if (path.parent && - namedTypes.FunctionExpression.check(path.parent.node) && - path.parent.node.id) { - addPattern(path.parent.get("id"), bindings); - } - - if (!node) { - // None of the remaining cases matter if node is falsy. - - } else if (isArray.check(node)) { - path.each(function(childPath) { - recursiveScanChild(childPath, bindings); - }); - - } else if (namedTypes.Function.check(node)) { - path.get("params").each(function(paramPath) { - addPattern(paramPath, bindings); - }); - - recursiveScanChild(path.get("body"), bindings); - - } else if (namedTypes.VariableDeclarator.check(node)) { - addPattern(path.get("id"), bindings); - recursiveScanChild(path.get("init"), bindings); - - } else if (node.type === "ImportSpecifier" || - node.type === "ImportNamespaceSpecifier" || - node.type === "ImportDefaultSpecifier") { - addPattern( - // Esprima used to use the .name field to refer to the local - // binding identifier for ImportSpecifier nodes, but .id for - // ImportNamespaceSpecifier and ImportDefaultSpecifier nodes. - // ESTree/Acorn/ESpree use .local for all three node types. - path.get(node.local ? "local" : - node.name ? "name" : "id"), - bindings - ); - - } else if (Node.check(node) && !Expression.check(node)) { - types.eachField(node, function(name, child) { - var childPath = path.get(name); - if (childPath.value !== child) { - throw new Error(""); - } - recursiveScanChild(childPath, bindings); - }); - } -} - -function recursiveScanChild(path, bindings) { - var node = path.value; - - if (!node || Expression.check(node)) { - // Ignore falsy values and Expressions. - - } else if (namedTypes.FunctionDeclaration.check(node)) { - addPattern(path.get("id"), bindings); - - } else if (namedTypes.ClassDeclaration && - namedTypes.ClassDeclaration.check(node)) { - addPattern(path.get("id"), bindings); - - } else if (ScopeType.check(node)) { - if (namedTypes.CatchClause.check(node)) { - var catchParamName = node.param.name; - var hadBinding = hasOwn.call(bindings, catchParamName); - - // Any declarations that occur inside the catch body that do - // not have the same name as the catch parameter should count - // as bindings in the outer scope. - recursiveScanScope(path.get("body"), bindings); - - // If a new binding matching the catch parameter name was - // created while scanning the catch body, ignore it because it - // actually refers to the catch parameter and not the outer - // scope that we're currently scanning. - if (!hadBinding) { - delete bindings[catchParamName]; - } - } - - } else { - recursiveScanScope(path, bindings); - } -} - -function addPattern(patternPath, bindings) { - var pattern = patternPath.value; - namedTypes.Pattern.assert(pattern); - - if (namedTypes.Identifier.check(pattern)) { - if (hasOwn.call(bindings, pattern.name)) { - bindings[pattern.name].push(patternPath); - } else { - bindings[pattern.name] = [patternPath]; - } - - } else if (namedTypes.ObjectPattern && - namedTypes.ObjectPattern.check(pattern)) { - patternPath.get('properties').each(function(propertyPath) { - var property = propertyPath.value; - if (namedTypes.Pattern.check(property)) { - addPattern(propertyPath, bindings); - } else if (namedTypes.Property.check(property)) { - addPattern(propertyPath.get('value'), bindings); - } else if (namedTypes.SpreadProperty && - namedTypes.SpreadProperty.check(property)) { - addPattern(propertyPath.get('argument'), bindings); - } - }); - - } else if (namedTypes.ArrayPattern && - namedTypes.ArrayPattern.check(pattern)) { - patternPath.get('elements').each(function(elementPath) { - var element = elementPath.value; - if (namedTypes.Pattern.check(element)) { - addPattern(elementPath, bindings); - } else if (namedTypes.SpreadElement && - namedTypes.SpreadElement.check(element)) { - addPattern(elementPath.get("argument"), bindings); - } - }); - - } else if (namedTypes.PropertyPattern && - namedTypes.PropertyPattern.check(pattern)) { - addPattern(patternPath.get('pattern'), bindings); - - } else if ((namedTypes.SpreadElementPattern && - namedTypes.SpreadElementPattern.check(pattern)) || - (namedTypes.SpreadPropertyPattern && - namedTypes.SpreadPropertyPattern.check(pattern))) { - addPattern(patternPath.get('argument'), bindings); - } -} - -Sp.lookup = function(name) { - for (var scope = this; scope; scope = scope.parent) - if (scope.declares(name)) - break; - return scope; -}; - -Sp.getGlobalScope = function() { - var scope = this; - while (!scope.isGlobal) - scope = scope.parent; - return scope; -}; - -module.exports = Scope; - -},{"578":578,"583":583}],582:[function(_dereq_,module,exports){ -var types = _dereq_(583); -var Type = types.Type; -var builtin = types.builtInTypes; -var isNumber = builtin.number; - -// An example of constructing a new type with arbitrary constraints from -// an existing type. -exports.geq = function(than) { - return new Type(function(value) { - return isNumber.check(value) && value >= than; - }, isNumber + " >= " + than); -}; - -// Default value-returning functions that may optionally be passed as a -// third argument to Def.prototype.field. -exports.defaults = { - // Functions were used because (among other reasons) that's the most - // elegant way to allow for the emptyArray one always to give a new - // array instance. - "null": function() { return null }, - "emptyArray": function() { return [] }, - "false": function() { return false }, - "true": function() { return true }, - "undefined": function() {} -}; - -var naiveIsPrimitive = Type.or( - builtin.string, - builtin.number, - builtin.boolean, - builtin.null, - builtin.undefined -); - -exports.isPrimitive = new Type(function(value) { - if (value === null) - return true; - var type = typeof value; - return !(type === "object" || - type === "function"); -}, naiveIsPrimitive.toString()); - -},{"583":583}],583:[function(_dereq_,module,exports){ -var Ap = Array.prototype; -var slice = Ap.slice; -var map = Ap.map; -var each = Ap.forEach; -var Op = Object.prototype; -var objToStr = Op.toString; -var funObjStr = objToStr.call(function(){}); -var strObjStr = objToStr.call(""); -var hasOwn = Op.hasOwnProperty; - -// A type is an object with a .check method that takes a value and returns -// true or false according to whether the value matches the type. - -function Type(check, name) { - var self = this; - if (!(self instanceof Type)) { - throw new Error("Type constructor cannot be invoked without 'new'"); - } - - // Unfortunately we can't elegantly reuse isFunction and isString, - // here, because this code is executed while defining those types. - if (objToStr.call(check) !== funObjStr) { - throw new Error(check + " is not a function"); - } - - // The `name` parameter can be either a function or a string. - var nameObjStr = objToStr.call(name); - if (!(nameObjStr === funObjStr || - nameObjStr === strObjStr)) { - throw new Error(name + " is neither a function nor a string"); - } - - Object.defineProperties(self, { - name: { value: name }, - check: { - value: function(value, deep) { - var result = check.call(self, value, deep); - if (!result && deep && objToStr.call(deep) === funObjStr) - deep(self, value); - return result; - } - } - }); -} - -var Tp = Type.prototype; - -// Throughout this file we use Object.defineProperty to prevent -// redefinition of exported properties. -exports.Type = Type; - -// Like .check, except that failure triggers an AssertionError. -Tp.assert = function(value, deep) { - if (!this.check(value, deep)) { - var str = shallowStringify(value); - throw new Error(str + " does not match type " + this); - } - return true; -}; - -function shallowStringify(value) { - if (isObject.check(value)) - return "{" + Object.keys(value).map(function(key) { - return key + ": " + value[key]; - }).join(", ") + "}"; - - if (isArray.check(value)) - return "[" + value.map(shallowStringify).join(", ") + "]"; - - return JSON.stringify(value); -} - -Tp.toString = function() { - var name = this.name; - - if (isString.check(name)) - return name; - - if (isFunction.check(name)) - return name.call(this) + ""; - - return name + " type"; -}; - -var builtInCtorFns = []; -var builtInCtorTypes = []; -var builtInTypes = {}; -exports.builtInTypes = builtInTypes; - -function defBuiltInType(example, name) { - var objStr = objToStr.call(example); - - var type = new Type(function(value) { - return objToStr.call(value) === objStr; - }, name); - - builtInTypes[name] = type; - - if (example && typeof example.constructor === "function") { - builtInCtorFns.push(example.constructor); - builtInCtorTypes.push(type); - } - - return type; -} - -// These types check the underlying [[Class]] attribute of the given -// value, rather than using the problematic typeof operator. Note however -// that no subtyping is considered; so, for instance, isObject.check -// returns false for [], /./, new Date, and null. -var isString = defBuiltInType("truthy", "string"); -var isFunction = defBuiltInType(function(){}, "function"); -var isArray = defBuiltInType([], "array"); -var isObject = defBuiltInType({}, "object"); -var isRegExp = defBuiltInType(/./, "RegExp"); -var isDate = defBuiltInType(new Date, "Date"); -var isNumber = defBuiltInType(3, "number"); -var isBoolean = defBuiltInType(true, "boolean"); -var isNull = defBuiltInType(null, "null"); -var isUndefined = defBuiltInType(void 0, "undefined"); - -// There are a number of idiomatic ways of expressing types, so this -// function serves to coerce them all to actual Type objects. Note that -// providing the name argument is not necessary in most cases. -function toType(from, name) { - // The toType function should of course be idempotent. - if (from instanceof Type) - return from; - - // The Def type is used as a helper for constructing compound - // interface types for AST nodes. - if (from instanceof Def) - return from.type; - - // Support [ElemType] syntax. - if (isArray.check(from)) - return Type.fromArray(from); - - // Support { someField: FieldType, ... } syntax. - if (isObject.check(from)) - return Type.fromObject(from); - - if (isFunction.check(from)) { - var bicfIndex = builtInCtorFns.indexOf(from); - if (bicfIndex >= 0) { - return builtInCtorTypes[bicfIndex]; - } - - // If isFunction.check(from), and from is not a built-in - // constructor, assume from is a binary predicate function we can - // use to define the type. - return new Type(from, name); - } - - // As a last resort, toType returns a type that matches any value that - // is === from. This is primarily useful for literal values like - // toType(null), but it has the additional advantage of allowing - // toType to be a total function. - return new Type(function(value) { - return value === from; - }, isUndefined.check(name) ? function() { - return from + ""; - } : name); -} - -// Returns a type that matches the given value iff any of type1, type2, -// etc. match the value. -Type.or = function(/* type1, type2, ... */) { - var types = []; - var len = arguments.length; - for (var i = 0; i < len; ++i) - types.push(toType(arguments[i])); - - return new Type(function(value, deep) { - for (var i = 0; i < len; ++i) - if (types[i].check(value, deep)) - return true; - return false; - }, function() { - return types.join(" | "); - }); -}; - -Type.fromArray = function(arr) { - if (!isArray.check(arr)) { - throw new Error(""); - } - if (arr.length !== 1) { - throw new Error("only one element type is permitted for typed arrays"); - } - return toType(arr[0]).arrayOf(); -}; - -Tp.arrayOf = function() { - var elemType = this; - return new Type(function(value, deep) { - return isArray.check(value) && value.every(function(elem) { - return elemType.check(elem, deep); - }); - }, function() { - return "[" + elemType + "]"; - }); -}; - -Type.fromObject = function(obj) { - var fields = Object.keys(obj).map(function(name) { - return new Field(name, obj[name]); - }); - - return new Type(function(value, deep) { - return isObject.check(value) && fields.every(function(field) { - return field.type.check(value[field.name], deep); - }); - }, function() { - return "{ " + fields.join(", ") + " }"; - }); -}; - -function Field(name, type, defaultFn, hidden) { - var self = this; - - if (!(self instanceof Field)) { - throw new Error("Field constructor cannot be invoked without 'new'"); - } - isString.assert(name); - - type = toType(type); - - var properties = { - name: { value: name }, - type: { value: type }, - hidden: { value: !!hidden } - }; - - if (isFunction.check(defaultFn)) { - properties.defaultFn = { value: defaultFn }; - } - - Object.defineProperties(self, properties); -} - -var Fp = Field.prototype; - -Fp.toString = function() { - return JSON.stringify(this.name) + ": " + this.type; -}; - -Fp.getValue = function(obj) { - var value = obj[this.name]; - - if (!isUndefined.check(value)) - return value; - - if (this.defaultFn) - value = this.defaultFn.call(obj); - - return value; -}; - -// Define a type whose name is registered in a namespace (the defCache) so -// that future definitions will return the same type given the same name. -// In particular, this system allows for circular and forward definitions. -// The Def object d returned from Type.def may be used to configure the -// type d.type by calling methods such as d.bases, d.build, and d.field. -Type.def = function(typeName) { - isString.assert(typeName); - return hasOwn.call(defCache, typeName) - ? defCache[typeName] - : defCache[typeName] = new Def(typeName); -}; - -// In order to return the same Def instance every time Type.def is called -// with a particular name, those instances need to be stored in a cache. -var defCache = Object.create(null); - -function Def(typeName) { - var self = this; - if (!(self instanceof Def)) { - throw new Error("Def constructor cannot be invoked without 'new'"); - } - - Object.defineProperties(self, { - typeName: { value: typeName }, - baseNames: { value: [] }, - ownFields: { value: Object.create(null) }, - - // These two are populated during finalization. - allSupertypes: { value: Object.create(null) }, // Includes own typeName. - supertypeList: { value: [] }, // Linear inheritance hierarchy. - allFields: { value: Object.create(null) }, // Includes inherited fields. - fieldNames: { value: [] }, // Non-hidden keys of allFields. - - type: { - value: new Type(function(value, deep) { - return self.check(value, deep); - }, typeName) - } - }); -} - -Def.fromValue = function(value) { - if (value && typeof value === "object") { - var type = value.type; - if (typeof type === "string" && - hasOwn.call(defCache, type)) { - var d = defCache[type]; - if (d.finalized) { - return d; - } - } - } - - return null; -}; - -var Dp = Def.prototype; - -Dp.isSupertypeOf = function(that) { - if (that instanceof Def) { - if (this.finalized !== true || - that.finalized !== true) { - throw new Error(""); - } - return hasOwn.call(that.allSupertypes, this.typeName); - } else { - throw new Error(that + " is not a Def"); - } -}; - -// Note that the list returned by this function is a copy of the internal -// supertypeList, *without* the typeName itself as the first element. -exports.getSupertypeNames = function(typeName) { - if (!hasOwn.call(defCache, typeName)) { - throw new Error(""); - } - var d = defCache[typeName]; - if (d.finalized !== true) { - throw new Error(""); - } - return d.supertypeList.slice(1); -}; - -// Returns an object mapping from every known type in the defCache to the -// most specific supertype whose name is an own property of the candidates -// object. -exports.computeSupertypeLookupTable = function(candidates) { - var table = {}; - var typeNames = Object.keys(defCache); - var typeNameCount = typeNames.length; - - for (var i = 0; i < typeNameCount; ++i) { - var typeName = typeNames[i]; - var d = defCache[typeName]; - if (d.finalized !== true) { - throw new Error("" + typeName); - } - for (var j = 0; j < d.supertypeList.length; ++j) { - var superTypeName = d.supertypeList[j]; - if (hasOwn.call(candidates, superTypeName)) { - table[typeName] = superTypeName; - break; - } - } - } - - return table; -}; - -Dp.checkAllFields = function(value, deep) { - var allFields = this.allFields; - if (this.finalized !== true) { - throw new Error("" + this.typeName); - } - - function checkFieldByName(name) { - var field = allFields[name]; - var type = field.type; - var child = field.getValue(value); - return type.check(child, deep); - } - - return isObject.check(value) - && Object.keys(allFields).every(checkFieldByName); -}; - -Dp.check = function(value, deep) { - if (this.finalized !== true) { - throw new Error( - "prematurely checking unfinalized type " + this.typeName - ); - } - - // A Def type can only match an object value. - if (!isObject.check(value)) - return false; - - var vDef = Def.fromValue(value); - if (!vDef) { - // If we couldn't infer the Def associated with the given value, - // and we expected it to be a SourceLocation or a Position, it was - // probably just missing a "type" field (because Esprima does not - // assign a type property to such nodes). Be optimistic and let - // this.checkAllFields make the final decision. - if (this.typeName === "SourceLocation" || - this.typeName === "Position") { - return this.checkAllFields(value, deep); - } - - // Calling this.checkAllFields for any other type of node is both - // bad for performance and way too forgiving. - return false; - } - - // If checking deeply and vDef === this, then we only need to call - // checkAllFields once. Calling checkAllFields is too strict when deep - // is false, because then we only care about this.isSupertypeOf(vDef). - if (deep && vDef === this) - return this.checkAllFields(value, deep); - - // In most cases we rely exclusively on isSupertypeOf to make O(1) - // subtyping determinations. This suffices in most situations outside - // of unit tests, since interface conformance is checked whenever new - // instances are created using builder functions. - if (!this.isSupertypeOf(vDef)) - return false; - - // The exception is when deep is true; then, we recursively check all - // fields. - if (!deep) - return true; - - // Use the more specific Def (vDef) to perform the deep check, but - // shallow-check fields defined by the less specific Def (this). - return vDef.checkAllFields(value, deep) - && this.checkAllFields(value, false); -}; - -Dp.bases = function() { - var args = slice.call(arguments); - var bases = this.baseNames; - - if (this.finalized) { - if (args.length !== bases.length) { - throw new Error(""); - } - for (var i = 0; i < args.length; i++) { - if (args[i] !== bases[i]) { - throw new Error(""); - } - } - return this; - } - - args.forEach(function(baseName) { - isString.assert(baseName); - - // This indexOf lookup may be O(n), but the typical number of base - // names is very small, and indexOf is a native Array method. - if (bases.indexOf(baseName) < 0) - bases.push(baseName); - }); - - return this; // For chaining. -}; - -// False by default until .build(...) is called on an instance. -Object.defineProperty(Dp, "buildable", { value: false }); - -var builders = {}; -exports.builders = builders; - -// This object is used as prototype for any node created by a builder. -var nodePrototype = {}; - -// Call this function to define a new method to be shared by all AST -// nodes. The replaced method (if any) is returned for easy wrapping. -exports.defineMethod = function(name, func) { - var old = nodePrototype[name]; - - // Pass undefined as func to delete nodePrototype[name]. - if (isUndefined.check(func)) { - delete nodePrototype[name]; - - } else { - isFunction.assert(func); - - Object.defineProperty(nodePrototype, name, { - enumerable: true, // For discoverability. - configurable: true, // For delete proto[name]. - value: func - }); - } - - return old; -}; - -var isArrayOfString = isString.arrayOf(); - -// Calling the .build method of a Def simultaneously marks the type as -// buildable (by defining builders[getBuilderName(typeName)]) and -// specifies the order of arguments that should be passed to the builder -// function to create an instance of the type. -Dp.build = function(/* param1, param2, ... */) { - var self = this; - - var newBuildParams = slice.call(arguments); - isArrayOfString.assert(newBuildParams); - - // Calling Def.prototype.build multiple times has the effect of merely - // redefining this property. - Object.defineProperty(self, "buildParams", { - value: newBuildParams, - writable: false, - enumerable: false, - configurable: true - }); - - if (self.buildable) { - // If this Def is already buildable, update self.buildParams and - // continue using the old builder function. - return self; - } - - // Every buildable type will have its "type" field filled in - // automatically. This includes types that are not subtypes of Node, - // like SourceLocation, but that seems harmless (TODO?). - self.field("type", String, function() { return self.typeName }); - - // Override Dp.buildable for this Def instance. - Object.defineProperty(self, "buildable", { value: true }); - - Object.defineProperty(builders, getBuilderName(self.typeName), { - enumerable: true, - - value: function() { - var args = arguments; - var argc = args.length; - var built = Object.create(nodePrototype); - - if (!self.finalized) { - throw new Error( - "attempting to instantiate unfinalized type " + - self.typeName - ); - } - - function add(param, i) { - if (hasOwn.call(built, param)) - return; - - var all = self.allFields; - if (!hasOwn.call(all, param)) { - throw new Error("" + param); - } - - var field = all[param]; - var type = field.type; - var value; - - if (isNumber.check(i) && i < argc) { - value = args[i]; - } else if (field.defaultFn) { - // Expose the partially-built object to the default - // function as its `this` object. - value = field.defaultFn.call(built); - } else { - var message = "no value or default function given for field " + - JSON.stringify(param) + " of " + self.typeName + "(" + - self.buildParams.map(function(name) { - return all[name]; - }).join(", ") + ")"; - throw new Error(message); - } - - if (!type.check(value)) { - throw new Error( - shallowStringify(value) + - " does not match field " + field + - " of type " + self.typeName - ); - } - - // TODO Could attach getters and setters here to enforce - // dynamic type safety. - built[param] = value; - } - - self.buildParams.forEach(function(param, i) { - add(param, i); - }); - - Object.keys(self.allFields).forEach(function(param) { - add(param); // Use the default value. - }); - - // Make sure that the "type" field was filled automatically. - if (built.type !== self.typeName) { - throw new Error(""); - } - - return built; - } - }); - - return self; // For chaining. -}; - -function getBuilderName(typeName) { - return typeName.replace(/^[A-Z]+/, function(upperCasePrefix) { - var len = upperCasePrefix.length; - switch (len) { - case 0: return ""; - // If there's only one initial capital letter, just lower-case it. - case 1: return upperCasePrefix.toLowerCase(); - default: - // If there's more than one initial capital letter, lower-case - // all but the last one, so that XMLDefaultDeclaration (for - // example) becomes xmlDefaultDeclaration. - return upperCasePrefix.slice( - 0, len - 1).toLowerCase() + - upperCasePrefix.charAt(len - 1); - } - }); -} -exports.getBuilderName = getBuilderName; - -function getStatementBuilderName(typeName) { - typeName = getBuilderName(typeName); - return typeName.replace(/(Expression)?$/, "Statement"); -} -exports.getStatementBuilderName = getStatementBuilderName; - -// The reason fields are specified using .field(...) instead of an object -// literal syntax is somewhat subtle: the object literal syntax would -// support only one key and one value, but with .field(...) we can pass -// any number of arguments to specify the field. -Dp.field = function(name, type, defaultFn, hidden) { - if (this.finalized) { - console.error("Ignoring attempt to redefine field " + - JSON.stringify(name) + " of finalized type " + - JSON.stringify(this.typeName)); - return this; - } - this.ownFields[name] = new Field(name, type, defaultFn, hidden); - return this; // For chaining. -}; - -var namedTypes = {}; -exports.namedTypes = namedTypes; - -// Like Object.keys, but aware of what fields each AST type should have. -function getFieldNames(object) { - var d = Def.fromValue(object); - if (d) { - return d.fieldNames.slice(0); - } - - if ("type" in object) { - throw new Error( - "did not recognize object of type " + - JSON.stringify(object.type) - ); - } - - return Object.keys(object); -} -exports.getFieldNames = getFieldNames; - -// Get the value of an object property, taking object.type and default -// functions into account. -function getFieldValue(object, fieldName) { - var d = Def.fromValue(object); - if (d) { - var field = d.allFields[fieldName]; - if (field) { - return field.getValue(object); - } - } - - return object[fieldName]; -} -exports.getFieldValue = getFieldValue; - -// Iterate over all defined fields of an object, including those missing -// or undefined, passing each field name and effective value (as returned -// by getFieldValue) to the callback. If the object has no corresponding -// Def, the callback will never be called. -exports.eachField = function(object, callback, context) { - getFieldNames(object).forEach(function(name) { - callback.call(this, name, getFieldValue(object, name)); - }, context); -}; - -// Similar to eachField, except that iteration stops as soon as the -// callback returns a truthy value. Like Array.prototype.some, the final -// result is either true or false to indicates whether the callback -// returned true for any element or not. -exports.someField = function(object, callback, context) { - return getFieldNames(object).some(function(name) { - return callback.call(this, name, getFieldValue(object, name)); - }, context); -}; - -// This property will be overridden as true by individual Def instances -// when they are finalized. -Object.defineProperty(Dp, "finalized", { value: false }); - -Dp.finalize = function() { - var self = this; - - // It's not an error to finalize a type more than once, but only the - // first call to .finalize does anything. - if (!self.finalized) { - var allFields = self.allFields; - var allSupertypes = self.allSupertypes; - - self.baseNames.forEach(function(name) { - var def = defCache[name]; - if (def instanceof Def) { - def.finalize(); - extend(allFields, def.allFields); - extend(allSupertypes, def.allSupertypes); - } else { - var message = "unknown supertype name " + - JSON.stringify(name) + - " for subtype " + - JSON.stringify(self.typeName); - throw new Error(message); - } - }); - - // TODO Warn if fields are overridden with incompatible types. - extend(allFields, self.ownFields); - allSupertypes[self.typeName] = self; - - self.fieldNames.length = 0; - for (var fieldName in allFields) { - if (hasOwn.call(allFields, fieldName) && - !allFields[fieldName].hidden) { - self.fieldNames.push(fieldName); - } - } - - // Types are exported only once they have been finalized. - Object.defineProperty(namedTypes, self.typeName, { - enumerable: true, - value: self.type - }); - - Object.defineProperty(self, "finalized", { value: true }); - - // A linearization of the inheritance hierarchy. - populateSupertypeList(self.typeName, self.supertypeList); - - if (self.buildable && self.supertypeList.lastIndexOf("Expression") >= 0) { - wrapExpressionBuilderWithStatement(self.typeName); - } - } -}; - -// Adds an additional builder for Expression subtypes -// that wraps the built Expression in an ExpressionStatements. -function wrapExpressionBuilderWithStatement(typeName) { - var wrapperName = getStatementBuilderName(typeName); - - // skip if the builder already exists - if (builders[wrapperName]) return; - - // the builder function to wrap with builders.ExpressionStatement - var wrapped = builders[getBuilderName(typeName)]; - - // skip if there is nothing to wrap - if (!wrapped) return; - - builders[wrapperName] = function() { - return builders.expressionStatement(wrapped.apply(builders, arguments)); - }; -} - -function populateSupertypeList(typeName, list) { - list.length = 0; - list.push(typeName); - - var lastSeen = Object.create(null); - - for (var pos = 0; pos < list.length; ++pos) { - typeName = list[pos]; - var d = defCache[typeName]; - if (d.finalized !== true) { - throw new Error(""); - } - - // If we saw typeName earlier in the breadth-first traversal, - // delete the last-seen occurrence. - if (hasOwn.call(lastSeen, typeName)) { - delete list[lastSeen[typeName]]; - } - - // Record the new index of the last-seen occurrence of typeName. - lastSeen[typeName] = pos; - - // Enqueue the base names of this type. - list.push.apply(list, d.baseNames); - } - - // Compaction loop to remove array holes. - for (var to = 0, from = to, len = list.length; from < len; ++from) { - if (hasOwn.call(list, from)) { - list[to++] = list[from]; - } - } - - list.length = to; -} - -function extend(into, from) { - Object.keys(from).forEach(function(name) { - into[name] = from[name]; - }); - - return into; -}; - -exports.finalize = function() { - Object.keys(defCache).forEach(function(name) { - defCache[name].finalize(); - }); -}; - -},{}],584:[function(_dereq_,module,exports){ -var types = _dereq_(583); - -// This core module of AST types captures ES5 as it is parsed today by -// git://github.com/ariya/esprima.git#master. -_dereq_(570); - -// Feel free to add to or remove from this list of extension modules to -// configure the precise type hierarchy that you need. -_dereq_(572); -_dereq_(573); -_dereq_(576); -_dereq_(571); -_dereq_(575); -_dereq_(574); -_dereq_(569); - -types.finalize(); - -exports.Type = types.Type; -exports.builtInTypes = types.builtInTypes; -exports.namedTypes = types.namedTypes; -exports.builders = types.builders; -exports.defineMethod = types.defineMethod; -exports.getFieldNames = types.getFieldNames; -exports.getFieldValue = types.getFieldValue; -exports.eachField = types.eachField; -exports.someField = types.someField; -exports.getSupertypeNames = types.getSupertypeNames; -exports.astNodesAreEquivalent = _dereq_(577); -exports.finalize = types.finalize; -exports.NodePath = _dereq_(578); -exports.PathVisitor = _dereq_(579); -exports.visit = exports.PathVisitor.visit; - -},{"569":569,"570":570,"571":571,"572":572,"573":573,"574":574,"575":575,"576":576,"577":577,"578":578,"579":579,"583":583}],585:[function(_dereq_,module,exports){ -(function (process,global){ -/** - * Copyright (c) 2014, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * https://raw.github.com/facebook/regenerator/master/LICENSE file. An - * additional grant of patent rights can be found in the PATENTS file in - * the same directory. - */ - -!(function(global) { - "use strict"; - - var hasOwn = Object.prototype.hasOwnProperty; - var undefined; // More compressible than void 0. - var iteratorSymbol = - typeof Symbol === "function" && Symbol.iterator || "@@iterator"; - - var inModule = typeof module === "object"; - var runtime = global.regeneratorRuntime; - if (runtime) { - if (inModule) { - // If regeneratorRuntime is defined globally and we're in a module, - // make the exports object identical to regeneratorRuntime. - module.exports = runtime; - } - // Don't bother evaluating the rest of this file if the runtime was - // already defined globally. - return; - } - - // Define the runtime globally (as expected by generated code) as either - // module.exports (if we're in a module) or a new, empty object. - runtime = global.regeneratorRuntime = inModule ? module.exports : {}; - - function wrap(innerFn, outerFn, self, tryLocsList) { - // If outerFn provided, then outerFn.prototype instanceof Generator. - var generator = Object.create((outerFn || Generator).prototype); - var context = new Context(tryLocsList || []); - - // The ._invoke method unifies the implementations of the .next, - // .throw, and .return methods. - generator._invoke = makeInvokeMethod(innerFn, self, context); - - return generator; - } - runtime.wrap = wrap; - - // Try/catch helper to minimize deoptimizations. Returns a completion - // record like context.tryEntries[i].completion. This interface could - // have been (and was previously) designed to take a closure to be - // invoked without arguments, but in all the cases we care about we - // already have an existing method we want to call, so there's no need - // to create a new function object. We can even get away with assuming - // the method takes exactly one argument, since that happens to be true - // in every case, so we don't have to touch the arguments object. The - // only additional allocation required is the completion record, which - // has a stable shape and so hopefully should be cheap to allocate. - function tryCatch(fn, obj, arg) { - try { - return { type: "normal", arg: fn.call(obj, arg) }; - } catch (err) { - return { type: "throw", arg: err }; - } - } - - var GenStateSuspendedStart = "suspendedStart"; - var GenStateSuspendedYield = "suspendedYield"; - var GenStateExecuting = "executing"; - var GenStateCompleted = "completed"; - - // Returning this object from the innerFn has the same effect as - // breaking out of the dispatch switch statement. - var ContinueSentinel = {}; - - // Dummy constructor functions that we use as the .constructor and - // .constructor.prototype properties for functions that return Generator - // objects. For full spec compliance, you may wish to configure your - // minifier not to mangle the names of these two functions. - function Generator() {} - function GeneratorFunction() {} - function GeneratorFunctionPrototype() {} - - var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype; - GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; - GeneratorFunctionPrototype.constructor = GeneratorFunction; - GeneratorFunction.displayName = "GeneratorFunction"; - - // Helper for defining the .next, .throw, and .return methods of the - // Iterator interface in terms of a single ._invoke method. - function defineIteratorMethods(prototype) { - ["next", "throw", "return"].forEach(function(method) { - prototype[method] = function(arg) { - return this._invoke(method, arg); - }; - }); - } - - runtime.isGeneratorFunction = function(genFun) { - var ctor = typeof genFun === "function" && genFun.constructor; - return ctor - ? ctor === GeneratorFunction || - // For the native GeneratorFunction constructor, the best we can - // do is to check its .name property. - (ctor.displayName || ctor.name) === "GeneratorFunction" - : false; - }; - - runtime.mark = function(genFun) { - if (Object.setPrototypeOf) { - Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); - } else { - genFun.__proto__ = GeneratorFunctionPrototype; - } - genFun.prototype = Object.create(Gp); - return genFun; - }; - - // Within the body of any async function, `await x` is transformed to - // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test - // `value instanceof AwaitArgument` to determine if the yielded value is - // meant to be awaited. Some may consider the name of this method too - // cutesy, but they are curmudgeons. - runtime.awrap = function(arg) { - return new AwaitArgument(arg); - }; - - function AwaitArgument(arg) { - this.arg = arg; - } - - function AsyncIterator(generator) { - // This invoke function is written in a style that assumes some - // calling function (or Promise) will handle exceptions. - function invoke(method, arg) { - var result = generator[method](arg); - var value = result.value; - return value instanceof AwaitArgument - ? Promise.resolve(value.arg).then(invokeNext, invokeThrow) - : Promise.resolve(value).then(function(unwrapped) { - // When a yielded Promise is resolved, its final value becomes - // the .value of the Promise<{value,done}> result for the - // current iteration. If the Promise is rejected, however, the - // result for this iteration will be rejected with the same - // reason. Note that rejections of yielded Promises are not - // thrown back into the generator function, as is the case - // when an awaited Promise is rejected. This difference in - // behavior between yield and await is important, because it - // allows the consumer to decide what to do with the yielded - // rejection (swallow it and continue, manually .throw it back - // into the generator, abandon iteration, whatever). With - // await, by contrast, there is no opportunity to examine the - // rejection reason outside the generator function, so the - // only option is to throw it from the await expression, and - // let the generator function handle the exception. - result.value = unwrapped; - return result; - }); - } - - if (typeof process === "object" && process.domain) { - invoke = process.domain.bind(invoke); - } - - var invokeNext = invoke.bind(generator, "next"); - var invokeThrow = invoke.bind(generator, "throw"); - var invokeReturn = invoke.bind(generator, "return"); - var previousPromise; - - function enqueue(method, arg) { - function callInvokeWithMethodAndArg() { - return invoke(method, arg); - } - - return previousPromise = - // If enqueue has been called before, then we want to wait until - // all previous Promises have been resolved before calling invoke, - // so that results are always delivered in the correct order. If - // enqueue has not been called before, then it is important to - // call invoke immediately, without waiting on a callback to fire, - // so that the async generator function has the opportunity to do - // any necessary setup in a predictable way. This predictability - // is why the Promise constructor synchronously invokes its - // executor callback, and why async functions synchronously - // execute code before the first await. Since we implement simple - // async functions in terms of async generators, it is especially - // important to get this right, even though it requires care. - previousPromise ? previousPromise.then( - callInvokeWithMethodAndArg, - // Avoid propagating failures to Promises returned by later - // invocations of the iterator. - callInvokeWithMethodAndArg - ) : new Promise(function (resolve) { - resolve(callInvokeWithMethodAndArg()); - }); - } - - // Define the unified helper method that is used to implement .next, - // .throw, and .return (see defineIteratorMethods). - this._invoke = enqueue; - } - - defineIteratorMethods(AsyncIterator.prototype); - - // Note that simple async functions are implemented on top of - // AsyncIterator objects; they just return a Promise for the value of - // the final result produced by the iterator. - runtime.async = function(innerFn, outerFn, self, tryLocsList) { - var iter = new AsyncIterator( - wrap(innerFn, outerFn, self, tryLocsList) - ); - - return runtime.isGeneratorFunction(outerFn) - ? iter // If outerFn is a generator, return the full iterator. - : iter.next().then(function(result) { - return result.done ? result.value : iter.next(); - }); - }; - - function makeInvokeMethod(innerFn, self, context) { - var state = GenStateSuspendedStart; - - return function invoke(method, arg) { - if (state === GenStateExecuting) { - throw new Error("Generator is already running"); - } - - if (state === GenStateCompleted) { - if (method === "throw") { - throw arg; - } - - // Be forgiving, per 25.3.3.3.3 of the spec: - // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume - return doneResult(); - } - - while (true) { - var delegate = context.delegate; - if (delegate) { - if (method === "return" || - (method === "throw" && delegate.iterator[method] === undefined)) { - // A return or throw (when the delegate iterator has no throw - // method) always terminates the yield* loop. - context.delegate = null; - - // If the delegate iterator has a return method, give it a - // chance to clean up. - var returnMethod = delegate.iterator["return"]; - if (returnMethod) { - var record = tryCatch(returnMethod, delegate.iterator, arg); - if (record.type === "throw") { - // If the return method threw an exception, let that - // exception prevail over the original return or throw. - method = "throw"; - arg = record.arg; - continue; - } - } - - if (method === "return") { - // Continue with the outer return, now that the delegate - // iterator has been terminated. - continue; - } - } - - var record = tryCatch( - delegate.iterator[method], - delegate.iterator, - arg - ); - - if (record.type === "throw") { - context.delegate = null; - - // Like returning generator.throw(uncaught), but without the - // overhead of an extra function call. - method = "throw"; - arg = record.arg; - continue; - } - - // Delegate generator ran and handled its own exceptions so - // regardless of what the method was, we continue as if it is - // "next" with an undefined arg. - method = "next"; - arg = undefined; - - var info = record.arg; - if (info.done) { - context[delegate.resultName] = info.value; - context.next = delegate.nextLoc; - } else { - state = GenStateSuspendedYield; - return info; - } - - context.delegate = null; - } - - if (method === "next") { - if (state === GenStateSuspendedYield) { - context.sent = arg; - } else { - context.sent = undefined; - } - - } else if (method === "throw") { - if (state === GenStateSuspendedStart) { - state = GenStateCompleted; - throw arg; - } - - if (context.dispatchException(arg)) { - // If the dispatched exception was caught by a catch block, - // then let that catch block handle the exception normally. - method = "next"; - arg = undefined; - } - - } else if (method === "return") { - context.abrupt("return", arg); - } - - state = GenStateExecuting; - - var record = tryCatch(innerFn, self, context); - if (record.type === "normal") { - // If an exception is thrown from innerFn, we leave state === - // GenStateExecuting and loop back for another invocation. - state = context.done - ? GenStateCompleted - : GenStateSuspendedYield; - - var info = { - value: record.arg, - done: context.done - }; - - if (record.arg === ContinueSentinel) { - if (context.delegate && method === "next") { - // Deliberately forget the last sent value so that we don't - // accidentally pass it on to the delegate. - arg = undefined; - } - } else { - return info; - } - - } else if (record.type === "throw") { - state = GenStateCompleted; - // Dispatch the exception by looping back around to the - // context.dispatchException(arg) call above. - method = "throw"; - arg = record.arg; - } - } - }; - } - - // Define Generator.prototype.{next,throw,return} in terms of the - // unified ._invoke helper method. - defineIteratorMethods(Gp); - - Gp[iteratorSymbol] = function() { - return this; - }; - - Gp.toString = function() { - return "[object Generator]"; - }; - - function pushTryEntry(locs) { - var entry = { tryLoc: locs[0] }; - - if (1 in locs) { - entry.catchLoc = locs[1]; - } - - if (2 in locs) { - entry.finallyLoc = locs[2]; - entry.afterLoc = locs[3]; - } - - this.tryEntries.push(entry); - } - - function resetTryEntry(entry) { - var record = entry.completion || {}; - record.type = "normal"; - delete record.arg; - entry.completion = record; - } - - function Context(tryLocsList) { - // The root entry object (effectively a try statement without a catch - // or a finally block) gives us a place to store values thrown from - // locations where there is no enclosing try statement. - this.tryEntries = [{ tryLoc: "root" }]; - tryLocsList.forEach(pushTryEntry, this); - this.reset(true); - } - - runtime.keys = function(object) { - var keys = []; - for (var key in object) { - keys.push(key); - } - keys.reverse(); - - // Rather than returning an object with a next method, we keep - // things simple and return the next function itself. - return function next() { - while (keys.length) { - var key = keys.pop(); - if (key in object) { - next.value = key; - next.done = false; - return next; - } - } - - // To avoid creating an additional object, we just hang the .value - // and .done properties off the next function object itself. This - // also ensures that the minifier will not anonymize the function. - next.done = true; - return next; - }; - }; - - function values(iterable) { - if (iterable) { - var iteratorMethod = iterable[iteratorSymbol]; - if (iteratorMethod) { - return iteratorMethod.call(iterable); - } - - if (typeof iterable.next === "function") { - return iterable; - } - - if (!isNaN(iterable.length)) { - var i = -1, next = function next() { - while (++i < iterable.length) { - if (hasOwn.call(iterable, i)) { - next.value = iterable[i]; - next.done = false; - return next; - } - } - - next.value = undefined; - next.done = true; - - return next; - }; - - return next.next = next; - } - } - - // Return an iterator with no values. - return { next: doneResult }; - } - runtime.values = values; - - function doneResult() { - return { value: undefined, done: true }; - } - - Context.prototype = { - constructor: Context, - - reset: function(skipTempReset) { - this.prev = 0; - this.next = 0; - this.sent = undefined; - this.done = false; - this.delegate = null; - - this.tryEntries.forEach(resetTryEntry); - - if (!skipTempReset) { - for (var name in this) { - // Not sure about the optimal order of these conditions: - if (name.charAt(0) === "t" && - hasOwn.call(this, name) && - !isNaN(+name.slice(1))) { - this[name] = undefined; - } - } - } - }, - - stop: function() { - this.done = true; - - var rootEntry = this.tryEntries[0]; - var rootRecord = rootEntry.completion; - if (rootRecord.type === "throw") { - throw rootRecord.arg; - } - - return this.rval; - }, - - dispatchException: function(exception) { - if (this.done) { - throw exception; - } - - var context = this; - function handle(loc, caught) { - record.type = "throw"; - record.arg = exception; - context.next = loc; - return !!caught; - } - - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; - var record = entry.completion; - - if (entry.tryLoc === "root") { - // Exception thrown outside of any try block that could handle - // it, so set the completion value of the entire function to - // throw the exception. - return handle("end"); - } - - if (entry.tryLoc <= this.prev) { - var hasCatch = hasOwn.call(entry, "catchLoc"); - var hasFinally = hasOwn.call(entry, "finallyLoc"); - - if (hasCatch && hasFinally) { - if (this.prev < entry.catchLoc) { - return handle(entry.catchLoc, true); - } else if (this.prev < entry.finallyLoc) { - return handle(entry.finallyLoc); - } - - } else if (hasCatch) { - if (this.prev < entry.catchLoc) { - return handle(entry.catchLoc, true); - } - - } else if (hasFinally) { - if (this.prev < entry.finallyLoc) { - return handle(entry.finallyLoc); - } - - } else { - throw new Error("try statement without catch or finally"); - } - } - } - }, - - abrupt: function(type, arg) { - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; - if (entry.tryLoc <= this.prev && - hasOwn.call(entry, "finallyLoc") && - this.prev < entry.finallyLoc) { - var finallyEntry = entry; - break; - } - } - - if (finallyEntry && - (type === "break" || - type === "continue") && - finallyEntry.tryLoc <= arg && - arg <= finallyEntry.finallyLoc) { - // Ignore the finally entry if control is not jumping to a - // location outside the try/catch block. - finallyEntry = null; - } - - var record = finallyEntry ? finallyEntry.completion : {}; - record.type = type; - record.arg = arg; - - if (finallyEntry) { - this.next = finallyEntry.finallyLoc; - } else { - this.complete(record); - } - - return ContinueSentinel; - }, - - complete: function(record, afterLoc) { - if (record.type === "throw") { - throw record.arg; - } - - if (record.type === "break" || - record.type === "continue") { - this.next = record.arg; - } else if (record.type === "return") { - this.rval = record.arg; - this.next = "end"; - } else if (record.type === "normal" && afterLoc) { - this.next = afterLoc; - } - }, - - finish: function(finallyLoc) { - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; - if (entry.finallyLoc === finallyLoc) { - this.complete(entry.completion, entry.afterLoc); - resetTryEntry(entry); - return ContinueSentinel; - } - } - }, - - "catch": function(tryLoc) { - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; - if (entry.tryLoc === tryLoc) { - var record = entry.completion; - if (record.type === "throw") { - var thrown = record.arg; - resetTryEntry(entry); - } - return thrown; - } - } - - // The context.catch method must only be called with a location - // argument that corresponds to a known catch block. - throw new Error("illegal catch attempt"); - }, - - delegateYield: function(iterable, resultName, nextLoc) { - this.delegate = { - iterator: values(iterable), - resultName: resultName, - nextLoc: nextLoc - }; - - return ContinueSentinel; - } - }; -})( - // Among the various tricks for obtaining a reference to the global - // object, this seems to be the most reliable technique that does not - // use indirect eval (which violates Content Security Policy). - typeof global === "object" ? global : - typeof window === "object" ? window : - typeof self === "object" ? self : this -); - -}).call(this,_dereq_(10),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"10":10}],586:[function(_dereq_,module,exports){ -// Generated by `/scripts/character-class-escape-sets.js`. Do not edit. -var regenerate = _dereq_(588); - -exports.REGULAR = { - 'd': regenerate() - .addRange(0x30, 0x39), - 'D': regenerate() - .addRange(0x0, 0x2F) - .addRange(0x3A, 0xFFFF), - 's': regenerate(0x20, 0xA0, 0x1680, 0x180E, 0x202F, 0x205F, 0x3000, 0xFEFF) - .addRange(0x9, 0xD) - .addRange(0x2000, 0x200A) - .addRange(0x2028, 0x2029), - 'S': regenerate() - .addRange(0x0, 0x8) - .addRange(0xE, 0x1F) - .addRange(0x21, 0x9F) - .addRange(0xA1, 0x167F) - .addRange(0x1681, 0x180D) - .addRange(0x180F, 0x1FFF) - .addRange(0x200B, 0x2027) - .addRange(0x202A, 0x202E) - .addRange(0x2030, 0x205E) - .addRange(0x2060, 0x2FFF) - .addRange(0x3001, 0xFEFE) - .addRange(0xFF00, 0xFFFF), - 'w': regenerate(0x5F) - .addRange(0x30, 0x39) - .addRange(0x41, 0x5A) - .addRange(0x61, 0x7A), - 'W': regenerate(0x60) - .addRange(0x0, 0x2F) - .addRange(0x3A, 0x40) - .addRange(0x5B, 0x5E) - .addRange(0x7B, 0xFFFF) -}; - -exports.UNICODE = { - 'd': regenerate() - .addRange(0x30, 0x39), - 'D': regenerate() - .addRange(0x0, 0x2F) - .addRange(0x3A, 0x10FFFF), - 's': regenerate(0x20, 0xA0, 0x1680, 0x180E, 0x202F, 0x205F, 0x3000, 0xFEFF) - .addRange(0x9, 0xD) - .addRange(0x2000, 0x200A) - .addRange(0x2028, 0x2029), - 'S': regenerate() - .addRange(0x0, 0x8) - .addRange(0xE, 0x1F) - .addRange(0x21, 0x9F) - .addRange(0xA1, 0x167F) - .addRange(0x1681, 0x180D) - .addRange(0x180F, 0x1FFF) - .addRange(0x200B, 0x2027) - .addRange(0x202A, 0x202E) - .addRange(0x2030, 0x205E) - .addRange(0x2060, 0x2FFF) - .addRange(0x3001, 0xFEFE) - .addRange(0xFF00, 0x10FFFF), - 'w': regenerate(0x5F) - .addRange(0x30, 0x39) - .addRange(0x41, 0x5A) - .addRange(0x61, 0x7A), - 'W': regenerate(0x60) - .addRange(0x0, 0x2F) - .addRange(0x3A, 0x40) - .addRange(0x5B, 0x5E) - .addRange(0x7B, 0x10FFFF) -}; - -exports.UNICODE_IGNORE_CASE = { - 'd': regenerate() - .addRange(0x30, 0x39), - 'D': regenerate() - .addRange(0x0, 0x2F) - .addRange(0x3A, 0x10FFFF), - 's': regenerate(0x20, 0xA0, 0x1680, 0x180E, 0x202F, 0x205F, 0x3000, 0xFEFF) - .addRange(0x9, 0xD) - .addRange(0x2000, 0x200A) - .addRange(0x2028, 0x2029), - 'S': regenerate() - .addRange(0x0, 0x8) - .addRange(0xE, 0x1F) - .addRange(0x21, 0x9F) - .addRange(0xA1, 0x167F) - .addRange(0x1681, 0x180D) - .addRange(0x180F, 0x1FFF) - .addRange(0x200B, 0x2027) - .addRange(0x202A, 0x202E) - .addRange(0x2030, 0x205E) - .addRange(0x2060, 0x2FFF) - .addRange(0x3001, 0xFEFE) - .addRange(0xFF00, 0x10FFFF), - 'w': regenerate(0x5F, 0x17F, 0x212A) - .addRange(0x30, 0x39) - .addRange(0x41, 0x5A) - .addRange(0x61, 0x7A), - 'W': regenerate(0x4B, 0x53, 0x60) - .addRange(0x0, 0x2F) - .addRange(0x3A, 0x40) - .addRange(0x5B, 0x5E) - .addRange(0x7B, 0x10FFFF) -}; - -},{"588":588}],587:[function(_dereq_,module,exports){ -module.exports={ - "75": 8490, - "83": 383, - "107": 8490, - "115": 383, - "181": 924, - "197": 8491, - "383": 83, - "452": 453, - "453": 452, - "455": 456, - "456": 455, - "458": 459, - "459": 458, - "497": 498, - "498": 497, - "837": 8126, - "914": 976, - "917": 1013, - "920": 1012, - "921": 8126, - "922": 1008, - "924": 181, - "928": 982, - "929": 1009, - "931": 962, - "934": 981, - "937": 8486, - "962": 931, - "976": 914, - "977": 1012, - "981": 934, - "982": 928, - "1008": 922, - "1009": 929, - "1012": [ - 920, - 977 - ], - "1013": 917, - "7776": 7835, - "7835": 7776, - "8126": [ - 837, - 921 - ], - "8486": 937, - "8490": 75, - "8491": 197, - "66560": 66600, - "66561": 66601, - "66562": 66602, - "66563": 66603, - "66564": 66604, - "66565": 66605, - "66566": 66606, - "66567": 66607, - "66568": 66608, - "66569": 66609, - "66570": 66610, - "66571": 66611, - "66572": 66612, - "66573": 66613, - "66574": 66614, - "66575": 66615, - "66576": 66616, - "66577": 66617, - "66578": 66618, - "66579": 66619, - "66580": 66620, - "66581": 66621, - "66582": 66622, - "66583": 66623, - "66584": 66624, - "66585": 66625, - "66586": 66626, - "66587": 66627, - "66588": 66628, - "66589": 66629, - "66590": 66630, - "66591": 66631, - "66592": 66632, - "66593": 66633, - "66594": 66634, - "66595": 66635, - "66596": 66636, - "66597": 66637, - "66598": 66638, - "66599": 66639, - "66600": 66560, - "66601": 66561, - "66602": 66562, - "66603": 66563, - "66604": 66564, - "66605": 66565, - "66606": 66566, - "66607": 66567, - "66608": 66568, - "66609": 66569, - "66610": 66570, - "66611": 66571, - "66612": 66572, - "66613": 66573, - "66614": 66574, - "66615": 66575, - "66616": 66576, - "66617": 66577, - "66618": 66578, - "66619": 66579, - "66620": 66580, - "66621": 66581, - "66622": 66582, - "66623": 66583, - "66624": 66584, - "66625": 66585, - "66626": 66586, - "66627": 66587, - "66628": 66588, - "66629": 66589, - "66630": 66590, - "66631": 66591, - "66632": 66592, - "66633": 66593, - "66634": 66594, - "66635": 66595, - "66636": 66596, - "66637": 66597, - "66638": 66598, - "66639": 66599, - "68736": 68800, - "68737": 68801, - "68738": 68802, - "68739": 68803, - "68740": 68804, - "68741": 68805, - "68742": 68806, - "68743": 68807, - "68744": 68808, - "68745": 68809, - "68746": 68810, - "68747": 68811, - "68748": 68812, - "68749": 68813, - "68750": 68814, - "68751": 68815, - "68752": 68816, - "68753": 68817, - "68754": 68818, - "68755": 68819, - "68756": 68820, - "68757": 68821, - "68758": 68822, - "68759": 68823, - "68760": 68824, - "68761": 68825, - "68762": 68826, - "68763": 68827, - "68764": 68828, - "68765": 68829, - "68766": 68830, - "68767": 68831, - "68768": 68832, - "68769": 68833, - "68770": 68834, - "68771": 68835, - "68772": 68836, - "68773": 68837, - "68774": 68838, - "68775": 68839, - "68776": 68840, - "68777": 68841, - "68778": 68842, - "68779": 68843, - "68780": 68844, - "68781": 68845, - "68782": 68846, - "68783": 68847, - "68784": 68848, - "68785": 68849, - "68786": 68850, - "68800": 68736, - "68801": 68737, - "68802": 68738, - "68803": 68739, - "68804": 68740, - "68805": 68741, - "68806": 68742, - "68807": 68743, - "68808": 68744, - "68809": 68745, - "68810": 68746, - "68811": 68747, - "68812": 68748, - "68813": 68749, - "68814": 68750, - "68815": 68751, - "68816": 68752, - "68817": 68753, - "68818": 68754, - "68819": 68755, - "68820": 68756, - "68821": 68757, - "68822": 68758, - "68823": 68759, - "68824": 68760, - "68825": 68761, - "68826": 68762, - "68827": 68763, - "68828": 68764, - "68829": 68765, - "68830": 68766, - "68831": 68767, - "68832": 68768, - "68833": 68769, - "68834": 68770, - "68835": 68771, - "68836": 68772, - "68837": 68773, - "68838": 68774, - "68839": 68775, - "68840": 68776, - "68841": 68777, - "68842": 68778, - "68843": 68779, - "68844": 68780, - "68845": 68781, - "68846": 68782, - "68847": 68783, - "68848": 68784, - "68849": 68785, - "68850": 68786, - "71840": 71872, - "71841": 71873, - "71842": 71874, - "71843": 71875, - "71844": 71876, - "71845": 71877, - "71846": 71878, - "71847": 71879, - "71848": 71880, - "71849": 71881, - "71850": 71882, - "71851": 71883, - "71852": 71884, - "71853": 71885, - "71854": 71886, - "71855": 71887, - "71856": 71888, - "71857": 71889, - "71858": 71890, - "71859": 71891, - "71860": 71892, - "71861": 71893, - "71862": 71894, - "71863": 71895, - "71864": 71896, - "71865": 71897, - "71866": 71898, - "71867": 71899, - "71868": 71900, - "71869": 71901, - "71870": 71902, - "71871": 71903, - "71872": 71840, - "71873": 71841, - "71874": 71842, - "71875": 71843, - "71876": 71844, - "71877": 71845, - "71878": 71846, - "71879": 71847, - "71880": 71848, - "71881": 71849, - "71882": 71850, - "71883": 71851, - "71884": 71852, - "71885": 71853, - "71886": 71854, - "71887": 71855, - "71888": 71856, - "71889": 71857, - "71890": 71858, - "71891": 71859, - "71892": 71860, - "71893": 71861, - "71894": 71862, - "71895": 71863, - "71896": 71864, - "71897": 71865, - "71898": 71866, - "71899": 71867, - "71900": 71868, - "71901": 71869, - "71902": 71870, - "71903": 71871 -} - -},{}],588:[function(_dereq_,module,exports){ -(function (global){ -/*! https://mths.be/regenerate v1.2.0 by @mathias | MIT license */ -;(function(root) { - - // Detect free variables `exports`. - var freeExports = typeof exports == 'object' && exports; - - // Detect free variable `module`. - var freeModule = typeof module == 'object' && module && - module.exports == freeExports && module; - - // Detect free variable `global`, from Node.js or Browserified code, - // and use it as `root`. - var freeGlobal = typeof global == 'object' && global; - if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) { - root = freeGlobal; - } - - /*--------------------------------------------------------------------------*/ - - var ERRORS = { - 'rangeOrder': 'A range\u2019s `stop` value must be greater than or equal ' + - 'to the `start` value.', - 'codePointRange': 'Invalid code point value. Code points range from ' + - 'U+000000 to U+10FFFF.' + var setMeta = function setMeta(it) { + setDesc(it, META, { value: { + i: 'O' + ++id, // object ID + w: {} // weak collections IDs + } }); + }; + var fastKey = function fastKey(it, create) { + // return primitive with prefix + if (!isObject(it)) return (typeof it === 'undefined' ? 'undefined' : _typeof(it)) == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it; + if (!has(it, META)) { + // can't set metadata to uncaught frozen object + if (!isExtensible(it)) return 'F'; + // not necessary to add metadata + if (!create) return 'E'; + // add missing metadata + setMeta(it); + // return object ID + }return it[META].i; + }; + var getWeak = function getWeak(it, create) { + if (!has(it, META)) { + // can't set metadata to uncaught frozen object + if (!isExtensible(it)) return true; + // not necessary to add metadata + if (!create) return false; + // add missing metadata + setMeta(it); + // return hash weak collections IDs + }return it[META].w; + }; + // add metadata on freeze-family methods calling + var onFreeze = function onFreeze(it) { + if (FREEZE && meta.NEED && isExtensible(it) && !has(it, META)) setMeta(it); + return it; + }; + var meta = module.exports = { + KEY: META, + NEED: false, + fastKey: fastKey, + getWeak: getWeak, + onFreeze: onFreeze }; - // https://mathiasbynens.be/notes/javascript-encoding#surrogate-pairs - var HIGH_SURROGATE_MIN = 0xD800; - var HIGH_SURROGATE_MAX = 0xDBFF; - var LOW_SURROGATE_MIN = 0xDC00; - var LOW_SURROGATE_MAX = 0xDFFF; +/***/ }), +/* 57 */ +/***/ (function(module, exports, __webpack_require__) { - // In Regenerate output, `\0` will never be preceded by `\` because we sort - // by code point value, so let’s keep this regular expression simple. - var regexNull = /\\x00([^0123456789]|$)/g; + 'use strict'; - var object = {}; - var hasOwnProperty = object.hasOwnProperty; - var extend = function(destination, source) { - var key; - for (key in source) { - if (hasOwnProperty.call(source, key)) { - destination[key] = source[key]; + __webpack_require__(437); + var global = __webpack_require__(14), + hide = __webpack_require__(28), + Iterators = __webpack_require__(55), + TO_STRING_TAG = __webpack_require__(12)('toStringTag'); + + for (var collections = ['NodeList', 'DOMTokenList', 'MediaList', 'StyleSheetList', 'CSSRuleList'], i = 0; i < 5; i++) { + var NAME = collections[i], + Collection = global[NAME], + proto = Collection && Collection.prototype; + if (proto && !proto[TO_STRING_TAG]) hide(proto, TO_STRING_TAG, NAME); + Iterators[NAME] = Iterators.Array; + } + +/***/ }), +/* 58 */ +/***/ (function(module, exports) { + + "use strict"; + + /** + * A specialized version of `_.map` for arrays without support for iteratee + * shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + */ + function arrayMap(array, iteratee) { + var index = -1, + length = array == null ? 0 : array.length, + result = Array(length); + + while (++index < length) { + result[index] = iteratee(array[index], index, array); + } + return result; + } + + module.exports = arrayMap; + +/***/ }), +/* 59 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + + var baseMatches = __webpack_require__(493), + baseMatchesProperty = __webpack_require__(494), + identity = __webpack_require__(110), + isArray = __webpack_require__(6), + property = __webpack_require__(583); + + /** + * The base implementation of `_.iteratee`. + * + * @private + * @param {*} [value=_.identity] The value to convert to an iteratee. + * @returns {Function} Returns the iteratee. + */ + function baseIteratee(value) { + // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. + // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. + if (typeof value == 'function') { + return value; + } + if (value == null) { + return identity; + } + if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) == 'object') { + return isArray(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value); + } + return property(value); + } + + module.exports = baseIteratee; + +/***/ }), +/* 60 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + + var baseGetTag = __webpack_require__(29), + isObjectLike = __webpack_require__(25); + + /** `Object#toString` result references. */ + var symbolTag = '[object Symbol]'; + + /** + * Checks if `value` is classified as a `Symbol` primitive or object. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. + * @example + * + * _.isSymbol(Symbol.iterator); + * // => true + * + * _.isSymbol('abc'); + * // => false + */ + function isSymbol(value) { + return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) == 'symbol' || isObjectLike(value) && baseGetTag(value) == symbolTag; + } + + module.exports = isSymbol; + +/***/ }), +/* 61 */ +/***/ (function(module, exports) { + + 'use strict'; + + /* -*- 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+))?(\S*)$/; + 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 '/..' 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) === '/' || !!aPath.match(urlRegexp); + }; + + /** + * 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 = 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 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 = 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 mappingA.name - mappingB.name; + } + exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated; + + function strcmp(aStr1, aStr2) { + if (aStr1 === aStr2) { + return 0; + } + + 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; + +/***/ }), +/* 62 */ +/***/ (function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(global) {'use strict'; + + // compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js + // original notice: + + /*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ + + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + + function compare(a, b) { + if (a === b) { + return 0; + } + + var x = a.length; + var y = b.length; + + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i]; + y = b[i]; + break; + } + } + + if (x < y) { + return -1; + } + if (y < x) { + return 1; + } + return 0; + } + function isBuffer(b) { + if (global.Buffer && typeof global.Buffer.isBuffer === 'function') { + return global.Buffer.isBuffer(b); + } + return !!(b != null && b._isBuffer); + } + + // based on node assert, original notice: + + // http://wiki.commonjs.org/wiki/Unit_Testing/1.0 + // + // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8! + // + // Originally from narwhal.js (http://narwhaljs.org) + // Copyright (c) 2009 Thomas Robinson <280north.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 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. + + var util = __webpack_require__(116); + var hasOwn = Object.prototype.hasOwnProperty; + var pSlice = Array.prototype.slice; + var functionsHaveNames = function () { + return function foo() {}.name === 'foo'; + }(); + function pToString(obj) { + return Object.prototype.toString.call(obj); + } + function isView(arrbuf) { + if (isBuffer(arrbuf)) { + return false; + } + if (typeof global.ArrayBuffer !== 'function') { + return false; + } + if (typeof ArrayBuffer.isView === 'function') { + return ArrayBuffer.isView(arrbuf); + } + if (!arrbuf) { + return false; + } + if (arrbuf instanceof DataView) { + return true; + } + if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) { + return true; + } + return false; + } + // 1. The assert module provides functions that throw + // AssertionError's when particular conditions are not met. The + // assert module must conform to the following interface. + + var assert = module.exports = ok; + + // 2. The AssertionError is defined in assert. + // new assert.AssertionError({ message: message, + // actual: actual, + // expected: expected }) + + var regex = /\s*function\s+([^\(\s]*)\s*/; + // based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js + function getName(func) { + if (!util.isFunction(func)) { + return; + } + if (functionsHaveNames) { + return func.name; + } + var str = func.toString(); + var match = str.match(regex); + return match && match[1]; + } + assert.AssertionError = function AssertionError(options) { + this.name = 'AssertionError'; + this.actual = options.actual; + this.expected = options.expected; + this.operator = options.operator; + if (options.message) { + this.message = options.message; + this.generatedMessage = false; + } else { + this.message = getMessage(this); + this.generatedMessage = true; + } + var stackStartFunction = options.stackStartFunction || fail; + if (Error.captureStackTrace) { + Error.captureStackTrace(this, stackStartFunction); + } else { + // non v8 browsers so we can have a stacktrace + var err = new Error(); + if (err.stack) { + var out = err.stack; + + // try to strip useless frames + var fn_name = getName(stackStartFunction); + var idx = out.indexOf('\n' + fn_name); + if (idx >= 0) { + // once we have located the function frame + // we need to strip out everything before it (and its line) + var next_line = out.indexOf('\n', idx + 1); + out = out.substring(next_line + 1); + } + + this.stack = out; + } + } + }; + + // assert.AssertionError instanceof Error + util.inherits(assert.AssertionError, Error); + + function truncate(s, n) { + if (typeof s === 'string') { + return s.length < n ? s : s.slice(0, n); + } else { + return s; + } + } + function inspect(something) { + if (functionsHaveNames || !util.isFunction(something)) { + return util.inspect(something); + } + var rawname = getName(something); + var name = rawname ? ': ' + rawname : ''; + return '[Function' + name + ']'; + } + function getMessage(self) { + return truncate(inspect(self.actual), 128) + ' ' + self.operator + ' ' + truncate(inspect(self.expected), 128); + } + + // At present only the three keys mentioned above are used and + // understood by the spec. Implementations or sub modules can pass + // other keys to the AssertionError's constructor - they will be + // ignored. + + // 3. All of the following functions must throw an AssertionError + // when a corresponding condition is not met, with a message that + // may be undefined if not provided. All assertion methods provide + // both the actual and expected values to the assertion error for + // display purposes. + + function fail(actual, expected, message, operator, stackStartFunction) { + throw new assert.AssertionError({ + message: message, + actual: actual, + expected: expected, + operator: operator, + stackStartFunction: stackStartFunction + }); + } + + // EXTENSION! allows for well behaved errors defined elsewhere. + assert.fail = fail; + + // 4. Pure assertion tests whether a value is truthy, as determined + // by !!guard. + // assert.ok(guard, message_opt); + // This statement is equivalent to assert.equal(true, !!guard, + // message_opt);. To test strictly for the value true, use + // assert.strictEqual(true, guard, message_opt);. + + function ok(value, message) { + if (!value) fail(value, true, message, '==', assert.ok); + } + assert.ok = ok; + + // 5. The equality assertion tests shallow, coercive equality with + // ==. + // assert.equal(actual, expected, message_opt); + + assert.equal = function equal(actual, expected, message) { + if (actual != expected) fail(actual, expected, message, '==', assert.equal); + }; + + // 6. The non-equality assertion tests for whether two objects are not equal + // with != assert.notEqual(actual, expected, message_opt); + + assert.notEqual = function notEqual(actual, expected, message) { + if (actual == expected) { + fail(actual, expected, message, '!=', assert.notEqual); + } + }; + + // 7. The equivalence assertion tests a deep equality relation. + // assert.deepEqual(actual, expected, message_opt); + + assert.deepEqual = function deepEqual(actual, expected, message) { + if (!_deepEqual(actual, expected, false)) { + fail(actual, expected, message, 'deepEqual', assert.deepEqual); + } + }; + + assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) { + if (!_deepEqual(actual, expected, true)) { + fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual); + } + }; + + function _deepEqual(actual, expected, strict, memos) { + // 7.1. All identical values are equivalent, as determined by ===. + if (actual === expected) { + return true; + } else if (isBuffer(actual) && isBuffer(expected)) { + return compare(actual, expected) === 0; + + // 7.2. If the expected value is a Date object, the actual value is + // equivalent if it is also a Date object that refers to the same time. + } else if (util.isDate(actual) && util.isDate(expected)) { + return actual.getTime() === expected.getTime(); + + // 7.3 If the expected value is a RegExp object, the actual value is + // equivalent if it is also a RegExp object with the same source and + // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`). + } else if (util.isRegExp(actual) && util.isRegExp(expected)) { + return actual.source === expected.source && actual.global === expected.global && actual.multiline === expected.multiline && actual.lastIndex === expected.lastIndex && actual.ignoreCase === expected.ignoreCase; + + // 7.4. Other pairs that do not both pass typeof value == 'object', + // equivalence is determined by ==. + } else if ((actual === null || (typeof actual === 'undefined' ? 'undefined' : _typeof(actual)) !== 'object') && (expected === null || (typeof expected === 'undefined' ? 'undefined' : _typeof(expected)) !== 'object')) { + return strict ? actual === expected : actual == expected; + + // If both values are instances of typed arrays, wrap their underlying + // ArrayBuffers in a Buffer each to increase performance + // This optimization requires the arrays to have the same type as checked by + // Object.prototype.toString (aka pToString). Never perform binary + // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their + // bit patterns are not identical. + } else if (isView(actual) && isView(expected) && pToString(actual) === pToString(expected) && !(actual instanceof Float32Array || actual instanceof Float64Array)) { + return compare(new Uint8Array(actual.buffer), new Uint8Array(expected.buffer)) === 0; + + // 7.5 For all other Object pairs, including Array objects, equivalence is + // determined by having the same number of owned properties (as verified + // with Object.prototype.hasOwnProperty.call), the same set of keys + // (although not necessarily the same order), equivalent values for every + // corresponding key, and an identical 'prototype' property. Note: this + // accounts for both named and indexed properties on Arrays. + } else if (isBuffer(actual) !== isBuffer(expected)) { + return false; + } else { + memos = memos || { actual: [], expected: [] }; + + var actualIndex = memos.actual.indexOf(actual); + if (actualIndex !== -1) { + if (actualIndex === memos.expected.indexOf(expected)) { + return true; + } + } + + memos.actual.push(actual); + memos.expected.push(expected); + + return objEquiv(actual, expected, strict, memos); + } + } + + function isArguments(object) { + return Object.prototype.toString.call(object) == '[object Arguments]'; + } + + function objEquiv(a, b, strict, actualVisitedObjects) { + if (a === null || a === undefined || b === null || b === undefined) return false; + // if one is a primitive, the other must be same + if (util.isPrimitive(a) || util.isPrimitive(b)) return a === b; + if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) return false; + var aIsArgs = isArguments(a); + var bIsArgs = isArguments(b); + if (aIsArgs && !bIsArgs || !aIsArgs && bIsArgs) return false; + if (aIsArgs) { + a = pSlice.call(a); + b = pSlice.call(b); + return _deepEqual(a, b, strict); + } + var ka = objectKeys(a); + var kb = objectKeys(b); + var key, i; + // having the same number of owned properties (keys incorporates + // hasOwnProperty) + if (ka.length !== kb.length) return false; + //the same set of keys (although not necessarily the same order), + ka.sort(); + kb.sort(); + //~~~cheap key test + for (i = ka.length - 1; i >= 0; i--) { + if (ka[i] !== kb[i]) return false; + } + //equivalent values for every corresponding key, and + //~~~possibly expensive deep test + for (i = ka.length - 1; i >= 0; i--) { + key = ka[i]; + if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects)) return false; + } + return true; + } + + // 8. The non-equivalence assertion tests for any deep inequality. + // assert.notDeepEqual(actual, expected, message_opt); + + assert.notDeepEqual = function notDeepEqual(actual, expected, message) { + if (_deepEqual(actual, expected, false)) { + fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual); + } + }; + + assert.notDeepStrictEqual = notDeepStrictEqual; + function notDeepStrictEqual(actual, expected, message) { + if (_deepEqual(actual, expected, true)) { + fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual); + } + } + + // 9. The strict equality assertion tests strict equality, as determined by ===. + // assert.strictEqual(actual, expected, message_opt); + + assert.strictEqual = function strictEqual(actual, expected, message) { + if (actual !== expected) { + fail(actual, expected, message, '===', assert.strictEqual); + } + }; + + // 10. The strict non-equality assertion tests for strict inequality, as + // determined by !==. assert.notStrictEqual(actual, expected, message_opt); + + assert.notStrictEqual = function notStrictEqual(actual, expected, message) { + if (actual === expected) { + fail(actual, expected, message, '!==', assert.notStrictEqual); + } + }; + + function expectedException(actual, expected) { + if (!actual || !expected) { + return false; + } + + if (Object.prototype.toString.call(expected) == '[object RegExp]') { + return expected.test(actual); + } + + try { + if (actual instanceof expected) { + return true; + } + } catch (e) { + // Ignore. The instanceof check doesn't work for arrow functions. + } + + if (Error.isPrototypeOf(expected)) { + return false; + } + + return expected.call({}, actual) === true; + } + + function _tryBlock(block) { + var error; + try { + block(); + } catch (e) { + error = e; + } + return error; + } + + function _throws(shouldThrow, block, expected, message) { + var actual; + + if (typeof block !== 'function') { + throw new TypeError('"block" argument must be a function'); + } + + if (typeof expected === 'string') { + message = expected; + expected = null; + } + + actual = _tryBlock(block); + + message = (expected && expected.name ? ' (' + expected.name + ').' : '.') + (message ? ' ' + message : '.'); + + if (shouldThrow && !actual) { + fail(actual, expected, 'Missing expected exception' + message); + } + + var userProvidedMessage = typeof message === 'string'; + var isUnwantedException = !shouldThrow && util.isError(actual); + var isUnexpectedException = !shouldThrow && actual && !expected; + + if (isUnwantedException && userProvidedMessage && expectedException(actual, expected) || isUnexpectedException) { + fail(actual, expected, 'Got unwanted exception' + message); + } + + if (shouldThrow && actual && expected && !expectedException(actual, expected) || !shouldThrow && actual) { + throw actual; + } + } + + // 11. Expected to throw an error: + // assert.throws(block, Error_opt, message_opt); + + assert.throws = function (block, /*optional*/error, /*optional*/message) { + _throws(true, block, error, message); + }; + + // EXTENSION! This is annoying to write outside this module. + assert.doesNotThrow = function (block, /*optional*/error, /*optional*/message) { + _throws(false, block, error, message); + }; + + assert.ifError = function (err) { + if (err) throw err; + }; + + var objectKeys = Object.keys || function (obj) { + var keys = []; + for (var key in obj) { + if (hasOwn.call(obj, key)) keys.push(key); + } + return keys; + }; + /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) + +/***/ }), +/* 63 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + exports.__esModule = true; + + var _getIterator2 = __webpack_require__(2); + + var _getIterator3 = _interopRequireDefault(_getIterator2); + + var _classCallCheck2 = __webpack_require__(3); + + var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); + + var _possibleConstructorReturn2 = __webpack_require__(42); + + var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2); + + var _inherits2 = __webpack_require__(41); + + var _inherits3 = _interopRequireDefault(_inherits2); + + var _optionManager = __webpack_require__(33); + + var _optionManager2 = _interopRequireDefault(_optionManager); + + var _babelMessages = __webpack_require__(18); + + var messages = _interopRequireWildcard(_babelMessages); + + var _store = __webpack_require__(118); + + var _store2 = _interopRequireDefault(_store); + + var _babelTraverse = __webpack_require__(7); + + var _babelTraverse2 = _interopRequireDefault(_babelTraverse); + + var _assign = __webpack_require__(170); + + var _assign2 = _interopRequireDefault(_assign); + + var _clone = __webpack_require__(109); + + var _clone2 = _interopRequireDefault(_clone); + + function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } else { + var newObj = {};if (obj != null) { + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; + } + }newObj.default = obj;return newObj; + } + } + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + var GLOBAL_VISITOR_PROPS = ["enter", "exit"]; + + var Plugin = function (_Store) { + (0, _inherits3.default)(Plugin, _Store); + + function Plugin(plugin, key) { + (0, _classCallCheck3.default)(this, Plugin); + + var _this = (0, _possibleConstructorReturn3.default)(this, _Store.call(this)); + + _this.initialized = false; + _this.raw = (0, _assign2.default)({}, plugin); + _this.key = _this.take("name") || key; + + _this.manipulateOptions = _this.take("manipulateOptions"); + _this.post = _this.take("post"); + _this.pre = _this.take("pre"); + _this.visitor = _this.normaliseVisitor((0, _clone2.default)(_this.take("visitor")) || {}); + return _this; + } + + Plugin.prototype.take = function take(key) { + var val = this.raw[key]; + delete this.raw[key]; + return val; + }; + + Plugin.prototype.chain = function chain(target, key) { + if (!target[key]) return this[key]; + if (!this[key]) return target[key]; + + var fns = [target[key], this[key]]; + + return function () { + var val = void 0; + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + for (var _iterator = fns, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) { + var _ref; + + if (_isArray) { + if (_i >= _iterator.length) break; + _ref = _iterator[_i++]; + } else { + _i = _iterator.next(); + if (_i.done) break; + _ref = _i.value; + } + + var fn = _ref; + + if (fn) { + var ret = fn.apply(this, args); + if (ret != null) val = ret; + } + } + return val; + }; + }; + + Plugin.prototype.maybeInherit = function maybeInherit(loc) { + var inherits = this.take("inherits"); + if (!inherits) return; + + inherits = _optionManager2.default.normalisePlugin(inherits, loc, "inherits"); + + this.manipulateOptions = this.chain(inherits, "manipulateOptions"); + this.post = this.chain(inherits, "post"); + this.pre = this.chain(inherits, "pre"); + this.visitor = _babelTraverse2.default.visitors.merge([inherits.visitor, this.visitor]); + }; + + Plugin.prototype.init = function init(loc, i) { + if (this.initialized) return; + this.initialized = true; + + this.maybeInherit(loc); + + for (var key in this.raw) { + throw new Error(messages.get("pluginInvalidProperty", loc, i, key)); + } + }; + + Plugin.prototype.normaliseVisitor = function normaliseVisitor(visitor) { + for (var _iterator2 = GLOBAL_VISITOR_PROPS, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : (0, _getIterator3.default)(_iterator2);;) { + var _ref2; + + if (_isArray2) { + if (_i2 >= _iterator2.length) break; + _ref2 = _iterator2[_i2++]; + } else { + _i2 = _iterator2.next(); + if (_i2.done) break; + _ref2 = _i2.value; + } + + var key = _ref2; + + if (visitor[key]) { + throw new Error("Plugins aren't allowed to specify catch-all enter/exit handlers. " + "Please target individual nodes."); + } + } + + _babelTraverse2.default.explode(visitor); + return visitor; + }; + + return Plugin; + }(_store2.default); + + exports.default = Plugin; + module.exports = exports["default"]; + +/***/ }), +/* 64 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + exports.__esModule = true; + + var _getIterator2 = __webpack_require__(2); + + var _getIterator3 = _interopRequireDefault(_getIterator2); + + exports.default = function (_ref) { + var messages = _ref.messages; + + return { + visitor: { + Scope: function Scope(_ref2) { + var scope = _ref2.scope; + + for (var name in scope.bindings) { + var binding = scope.bindings[name]; + if (binding.kind !== "const" && binding.kind !== "module") continue; + + for (var _iterator = binding.constantViolations, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) { + var _ref3; + + if (_isArray) { + if (_i >= _iterator.length) break; + _ref3 = _iterator[_i++]; + } else { + _i = _iterator.next(); + if (_i.done) break; + _ref3 = _i.value; + } + + var violation = _ref3; + + throw violation.buildCodeFrameError(messages.get("readOnly", name)); + } + } + } + } + }; + }; + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + module.exports = exports["default"]; + +/***/ }), +/* 65 */ +/***/ (function(module, exports) { + + "use strict"; + + exports.__esModule = true; + + exports.default = function () { + return { + manipulateOptions: function manipulateOptions(opts, parserOpts) { + parserOpts.plugins.push("asyncFunctions"); + } + }; + }; + + module.exports = exports["default"]; + +/***/ }), +/* 66 */ +/***/ (function(module, exports) { + + "use strict"; + + exports.__esModule = true; + + exports.default = function (_ref) { + var t = _ref.types; + + return { + visitor: { + ArrowFunctionExpression: function ArrowFunctionExpression(path, state) { + if (state.opts.spec) { + var node = path.node; + + if (node.shadow) return; + + node.shadow = { this: false }; + node.type = "FunctionExpression"; + + var boundThis = t.thisExpression(); + boundThis._forceShadow = path; + + path.ensureBlock(); + path.get("body").unshiftContainer("body", t.expressionStatement(t.callExpression(state.addHelper("newArrowCheck"), [t.thisExpression(), boundThis]))); + + path.replaceWith(t.callExpression(t.memberExpression(node, t.identifier("bind")), [t.thisExpression()])); + } else { + path.arrowFunctionToShadowed(); + } + } + } + }; + }; + + module.exports = exports["default"]; + +/***/ }), +/* 67 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + exports.__esModule = true; + + var _getIterator2 = __webpack_require__(2); + + var _getIterator3 = _interopRequireDefault(_getIterator2); + + exports.default = function (_ref) { + var t = _ref.types; + + function statementList(key, path) { + var paths = path.get(key); + + for (var _iterator = paths, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) { + var _ref2; + + if (_isArray) { + if (_i >= _iterator.length) break; + _ref2 = _iterator[_i++]; + } else { + _i = _iterator.next(); + if (_i.done) break; + _ref2 = _i.value; + } + + var _path = _ref2; + + var func = _path.node; + if (!_path.isFunctionDeclaration()) continue; + + var declar = t.variableDeclaration("let", [t.variableDeclarator(func.id, t.toExpression(func))]); + + declar._blockHoist = 2; + + func.id = null; + + _path.replaceWith(declar); + } + } + + return { + visitor: { + BlockStatement: function BlockStatement(path) { + var node = path.node, + parent = path.parent; + + if (t.isFunction(parent, { body: node }) || t.isExportDeclaration(parent)) { + return; + } + + statementList("body", path); + }, + SwitchCase: function SwitchCase(path) { + statementList("consequent", path); + } + } + }; + }; + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + module.exports = exports["default"]; + +/***/ }), +/* 68 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + exports.__esModule = true; + + var _symbol = __webpack_require__(10); + + var _symbol2 = _interopRequireDefault(_symbol); + + var _create = __webpack_require__(9); + + var _create2 = _interopRequireDefault(_create); + + var _classCallCheck2 = __webpack_require__(3); + + var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); + + exports.default = function () { + return { + visitor: { + VariableDeclaration: function VariableDeclaration(path, file) { + var node = path.node, + parent = path.parent, + scope = path.scope; + + if (!isBlockScoped(node)) return; + convertBlockScopedToVar(path, null, parent, scope, true); + + if (node._tdzThis) { + var nodes = [node]; + + for (var i = 0; i < node.declarations.length; i++) { + var decl = node.declarations[i]; + if (decl.init) { + var assign = t.assignmentExpression("=", decl.id, decl.init); + assign._ignoreBlockScopingTDZ = true; + nodes.push(t.expressionStatement(assign)); + } + decl.init = file.addHelper("temporalUndefined"); + } + + node._blockHoist = 2; + + if (path.isCompletionRecord()) { + nodes.push(t.expressionStatement(scope.buildUndefinedNode())); + } + + path.replaceWithMultiple(nodes); + } + }, + Loop: function Loop(path, file) { + var node = path.node, + parent = path.parent, + scope = path.scope; + + t.ensureBlock(node); + var blockScoping = new BlockScoping(path, path.get("body"), parent, scope, file); + var replace = blockScoping.run(); + if (replace) path.replaceWith(replace); + }, + CatchClause: function CatchClause(path, file) { + var parent = path.parent, + scope = path.scope; + + var blockScoping = new BlockScoping(null, path.get("body"), parent, scope, file); + blockScoping.run(); + }, + "BlockStatement|SwitchStatement|Program": function BlockStatementSwitchStatementProgram(path, file) { + if (!ignoreBlock(path)) { + var blockScoping = new BlockScoping(null, path, path.parent, path.scope, file); + blockScoping.run(); + } + } + } + }; + }; + + var _babelTraverse = __webpack_require__(7); + + var _babelTraverse2 = _interopRequireDefault(_babelTraverse); + + var _tdz = __webpack_require__(326); + + var _babelTypes = __webpack_require__(1); + + var t = _interopRequireWildcard(_babelTypes); + + var _values = __webpack_require__(275); + + var _values2 = _interopRequireDefault(_values); + + var _extend = __webpack_require__(569); + + var _extend2 = _interopRequireDefault(_extend); + + var _babelTemplate = __webpack_require__(4); + + var _babelTemplate2 = _interopRequireDefault(_babelTemplate); + + function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } else { + var newObj = {};if (obj != null) { + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; + } + }newObj.default = obj;return newObj; + } + } + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function ignoreBlock(path) { + return t.isLoop(path.parent) || t.isCatchClause(path.parent); + } + + var buildRetCheck = (0, _babelTemplate2.default)("\n if (typeof RETURN === \"object\") return RETURN.v;\n"); + + function isBlockScoped(node) { + if (!t.isVariableDeclaration(node)) return false; + if (node[t.BLOCK_SCOPED_SYMBOL]) return true; + if (node.kind !== "let" && node.kind !== "const") return false; + return true; + } + + function convertBlockScopedToVar(path, node, parent, scope) { + var moveBindingsToParent = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false; + + if (!node) { + node = path.node; + } + + if (!t.isFor(parent)) { + for (var i = 0; i < node.declarations.length; i++) { + var declar = node.declarations[i]; + declar.init = declar.init || scope.buildUndefinedNode(); + } + } + + node[t.BLOCK_SCOPED_SYMBOL] = true; + node.kind = "var"; + + if (moveBindingsToParent) { + var parentScope = scope.getFunctionParent(); + var ids = path.getBindingIdentifiers(); + for (var name in ids) { + var binding = scope.getOwnBinding(name); + if (binding) binding.kind = "var"; + scope.moveBindingTo(name, parentScope); + } + } + } + + function isVar(node) { + return t.isVariableDeclaration(node, { kind: "var" }) && !isBlockScoped(node); + } + + var letReferenceBlockVisitor = _babelTraverse2.default.visitors.merge([{ + Loop: { + enter: function enter(path, state) { + state.loopDepth++; + }, + exit: function exit(path, state) { + state.loopDepth--; + } + }, + Function: function Function(path, state) { + if (state.loopDepth > 0) { + path.traverse(letReferenceFunctionVisitor, state); + } + return path.skip(); + } + }, _tdz.visitor]); + + var letReferenceFunctionVisitor = _babelTraverse2.default.visitors.merge([{ + ReferencedIdentifier: function ReferencedIdentifier(path, state) { + var ref = state.letReferences[path.node.name]; + + if (!ref) return; + + var localBinding = path.scope.getBindingIdentifier(path.node.name); + if (localBinding && localBinding !== ref) return; + + state.closurify = true; + } + }, _tdz.visitor]); + + var hoistVarDeclarationsVisitor = { + enter: function enter(path, self) { + var node = path.node, + parent = path.parent; + + if (path.isForStatement()) { + if (isVar(node.init, node)) { + var nodes = self.pushDeclar(node.init); + if (nodes.length === 1) { + node.init = nodes[0]; + } else { + node.init = t.sequenceExpression(nodes); + } + } + } else if (path.isFor()) { + if (isVar(node.left, node)) { + self.pushDeclar(node.left); + node.left = node.left.declarations[0].id; + } + } else if (isVar(node, parent)) { + path.replaceWithMultiple(self.pushDeclar(node).map(function (expr) { + return t.expressionStatement(expr); + })); + } else if (path.isFunction()) { + return path.skip(); + } + } + }; + + var loopLabelVisitor = { + LabeledStatement: function LabeledStatement(_ref, state) { + var node = _ref.node; + + state.innerLabels.push(node.label.name); + } + }; + + var continuationVisitor = { + enter: function enter(path, state) { + if (path.isAssignmentExpression() || path.isUpdateExpression()) { + var bindings = path.getBindingIdentifiers(); + for (var name in bindings) { + if (state.outsideReferences[name] !== path.scope.getBindingIdentifier(name)) continue; + state.reassignments[name] = true; + } + } + } + }; + + function loopNodeTo(node) { + if (t.isBreakStatement(node)) { + return "break"; + } else if (t.isContinueStatement(node)) { + return "continue"; + } + } + + var loopVisitor = { + Loop: function Loop(path, state) { + var oldIgnoreLabeless = state.ignoreLabeless; + state.ignoreLabeless = true; + path.traverse(loopVisitor, state); + state.ignoreLabeless = oldIgnoreLabeless; + path.skip(); + }, + Function: function Function(path) { + path.skip(); + }, + SwitchCase: function SwitchCase(path, state) { + var oldInSwitchCase = state.inSwitchCase; + state.inSwitchCase = true; + path.traverse(loopVisitor, state); + state.inSwitchCase = oldInSwitchCase; + path.skip(); + }, + "BreakStatement|ContinueStatement|ReturnStatement": function BreakStatementContinueStatementReturnStatement(path, state) { + var node = path.node, + parent = path.parent, + scope = path.scope; + + if (node[this.LOOP_IGNORE]) return; + + var replace = void 0; + var loopText = loopNodeTo(node); + + if (loopText) { + if (node.label) { + if (state.innerLabels.indexOf(node.label.name) >= 0) { + return; + } + + loopText = loopText + "|" + node.label.name; + } else { + if (state.ignoreLabeless) return; + + if (state.inSwitchCase) return; + + if (t.isBreakStatement(node) && t.isSwitchCase(parent)) return; + } + + state.hasBreakContinue = true; + state.map[loopText] = node; + replace = t.stringLiteral(loopText); + } + + if (path.isReturnStatement()) { + state.hasReturn = true; + replace = t.objectExpression([t.objectProperty(t.identifier("v"), node.argument || scope.buildUndefinedNode())]); + } + + if (replace) { + replace = t.returnStatement(replace); + replace[this.LOOP_IGNORE] = true; + path.skip(); + path.replaceWith(t.inherits(replace, node)); + } + } + }; + + var BlockScoping = function () { + function BlockScoping(loopPath, blockPath, parent, scope, file) { + (0, _classCallCheck3.default)(this, BlockScoping); + + this.parent = parent; + this.scope = scope; + this.file = file; + + this.blockPath = blockPath; + this.block = blockPath.node; + + this.outsideLetReferences = (0, _create2.default)(null); + this.hasLetReferences = false; + this.letReferences = (0, _create2.default)(null); + this.body = []; + + if (loopPath) { + this.loopParent = loopPath.parent; + this.loopLabel = t.isLabeledStatement(this.loopParent) && this.loopParent.label; + this.loopPath = loopPath; + this.loop = loopPath.node; + } + } + + BlockScoping.prototype.run = function run() { + var block = this.block; + if (block._letDone) return; + block._letDone = true; + + var needsClosure = this.getLetReferences(); + + if (t.isFunction(this.parent) || t.isProgram(this.block)) { + this.updateScopeInfo(); + return; + } + + if (!this.hasLetReferences) return; + + if (needsClosure) { + this.wrapClosure(); + } else { + this.remap(); + } + + this.updateScopeInfo(needsClosure); + + if (this.loopLabel && !t.isLabeledStatement(this.loopParent)) { + return t.labeledStatement(this.loopLabel, this.loop); + } + }; + + BlockScoping.prototype.updateScopeInfo = function updateScopeInfo(wrappedInClosure) { + var scope = this.scope; + var parentScope = scope.getFunctionParent(); + var letRefs = this.letReferences; + + for (var key in letRefs) { + var ref = letRefs[key]; + var binding = scope.getBinding(ref.name); + if (!binding) continue; + if (binding.kind === "let" || binding.kind === "const") { + binding.kind = "var"; + + if (wrappedInClosure) { + scope.removeBinding(ref.name); + } else { + scope.moveBindingTo(ref.name, parentScope); + } + } + } + }; + + BlockScoping.prototype.remap = function remap() { + var letRefs = this.letReferences; + var scope = this.scope; + + for (var key in letRefs) { + var ref = letRefs[key]; + + if (scope.parentHasBinding(key) || scope.hasGlobal(key)) { + if (scope.hasOwnBinding(key)) scope.rename(ref.name); + + if (this.blockPath.scope.hasOwnBinding(key)) this.blockPath.scope.rename(ref.name); + } + } + }; + + BlockScoping.prototype.wrapClosure = function wrapClosure() { + if (this.file.opts.throwIfClosureRequired) { + throw this.blockPath.buildCodeFrameError("Compiling let/const in this block would add a closure " + "(throwIfClosureRequired)."); + } + var block = this.block; + + var outsideRefs = this.outsideLetReferences; + + if (this.loop) { + for (var name in outsideRefs) { + var id = outsideRefs[name]; + + if (this.scope.hasGlobal(id.name) || this.scope.parentHasBinding(id.name)) { + delete outsideRefs[id.name]; + delete this.letReferences[id.name]; + + this.scope.rename(id.name); + + this.letReferences[id.name] = id; + outsideRefs[id.name] = id; + } + } + } + + this.has = this.checkLoop(); + + this.hoistVarDeclarations(); + + var params = (0, _values2.default)(outsideRefs); + var args = (0, _values2.default)(outsideRefs); + + var isSwitch = this.blockPath.isSwitchStatement(); + + var fn = t.functionExpression(null, params, t.blockStatement(isSwitch ? [block] : block.body)); + fn.shadow = true; + + this.addContinuations(fn); + + var ref = fn; + + if (this.loop) { + ref = this.scope.generateUidIdentifier("loop"); + this.loopPath.insertBefore(t.variableDeclaration("var", [t.variableDeclarator(ref, fn)])); + } + + var call = t.callExpression(ref, args); + var ret = this.scope.generateUidIdentifier("ret"); + + var hasYield = _babelTraverse2.default.hasType(fn.body, this.scope, "YieldExpression", t.FUNCTION_TYPES); + if (hasYield) { + fn.generator = true; + call = t.yieldExpression(call, true); + } + + var hasAsync = _babelTraverse2.default.hasType(fn.body, this.scope, "AwaitExpression", t.FUNCTION_TYPES); + if (hasAsync) { + fn.async = true; + call = t.awaitExpression(call); + } + + this.buildClosure(ret, call); + + if (isSwitch) this.blockPath.replaceWithMultiple(this.body);else block.body = this.body; + }; + + BlockScoping.prototype.buildClosure = function buildClosure(ret, call) { + var has = this.has; + if (has.hasReturn || has.hasBreakContinue) { + this.buildHas(ret, call); + } else { + this.body.push(t.expressionStatement(call)); + } + }; + + BlockScoping.prototype.addContinuations = function addContinuations(fn) { + var state = { + reassignments: {}, + outsideReferences: this.outsideLetReferences + }; + + this.scope.traverse(fn, continuationVisitor, state); + + for (var i = 0; i < fn.params.length; i++) { + var param = fn.params[i]; + if (!state.reassignments[param.name]) continue; + + var newParam = this.scope.generateUidIdentifier(param.name); + fn.params[i] = newParam; + + this.scope.rename(param.name, newParam.name, fn); + + fn.body.body.push(t.expressionStatement(t.assignmentExpression("=", param, newParam))); + } + }; + + BlockScoping.prototype.getLetReferences = function getLetReferences() { + var _this = this; + + var block = this.block; + + var declarators = []; + + if (this.loop) { + var init = this.loop.left || this.loop.init; + if (isBlockScoped(init)) { + declarators.push(init); + (0, _extend2.default)(this.outsideLetReferences, t.getBindingIdentifiers(init)); + } + } + + var addDeclarationsFromChild = function addDeclarationsFromChild(path, node) { + node = node || path.node; + if (t.isClassDeclaration(node) || t.isFunctionDeclaration(node) || isBlockScoped(node)) { + if (isBlockScoped(node)) { + convertBlockScopedToVar(path, node, block, _this.scope); + } + declarators = declarators.concat(node.declarations || node); + } + if (t.isLabeledStatement(node)) { + addDeclarationsFromChild(path.get("body"), node.body); + } + }; + + if (block.body) { + for (var i = 0; i < block.body.length; i++) { + var declarPath = this.blockPath.get("body")[i]; + addDeclarationsFromChild(declarPath); + } + } + + if (block.cases) { + for (var _i = 0; _i < block.cases.length; _i++) { + var consequents = block.cases[_i].consequent; + + for (var j = 0; j < consequents.length; j++) { + var _declarPath = this.blockPath.get("cases")[_i]; + var declar = consequents[j]; + addDeclarationsFromChild(_declarPath, declar); + } + } + } + + for (var _i2 = 0; _i2 < declarators.length; _i2++) { + var _declar = declarators[_i2]; + + var keys = t.getBindingIdentifiers(_declar, false, true); + (0, _extend2.default)(this.letReferences, keys); + this.hasLetReferences = true; + } + + if (!this.hasLetReferences) return; + + var state = { + letReferences: this.letReferences, + closurify: false, + file: this.file, + loopDepth: 0 + }; + + var loopOrFunctionParent = this.blockPath.find(function (path) { + return path.isLoop() || path.isFunction(); + }); + if (loopOrFunctionParent && loopOrFunctionParent.isLoop()) { + state.loopDepth++; + } + + this.blockPath.traverse(letReferenceBlockVisitor, state); + + return state.closurify; + }; + + BlockScoping.prototype.checkLoop = function checkLoop() { + var state = { + hasBreakContinue: false, + ignoreLabeless: false, + inSwitchCase: false, + innerLabels: [], + hasReturn: false, + isLoop: !!this.loop, + map: {}, + LOOP_IGNORE: (0, _symbol2.default)() + }; + + this.blockPath.traverse(loopLabelVisitor, state); + this.blockPath.traverse(loopVisitor, state); + + return state; + }; + + BlockScoping.prototype.hoistVarDeclarations = function hoistVarDeclarations() { + this.blockPath.traverse(hoistVarDeclarationsVisitor, this); + }; + + BlockScoping.prototype.pushDeclar = function pushDeclar(node) { + var declars = []; + var names = t.getBindingIdentifiers(node); + for (var name in names) { + declars.push(t.variableDeclarator(names[name])); + } + + this.body.push(t.variableDeclaration(node.kind, declars)); + + var replace = []; + + for (var i = 0; i < node.declarations.length; i++) { + var declar = node.declarations[i]; + if (!declar.init) continue; + + var expr = t.assignmentExpression("=", declar.id, declar.init); + replace.push(t.inherits(expr, declar)); + } + + return replace; + }; + + BlockScoping.prototype.buildHas = function buildHas(ret, call) { + var body = this.body; + + body.push(t.variableDeclaration("var", [t.variableDeclarator(ret, call)])); + + var retCheck = void 0; + var has = this.has; + var cases = []; + + if (has.hasReturn) { + retCheck = buildRetCheck({ + RETURN: ret + }); + } + + if (has.hasBreakContinue) { + for (var key in has.map) { + cases.push(t.switchCase(t.stringLiteral(key), [has.map[key]])); + } + + if (has.hasReturn) { + cases.push(t.switchCase(null, [retCheck])); + } + + if (cases.length === 1) { + var single = cases[0]; + body.push(t.ifStatement(t.binaryExpression("===", ret, single.test), single.consequent[0])); + } else { + if (this.loop) { + for (var i = 0; i < cases.length; i++) { + var caseConsequent = cases[i].consequent[0]; + if (t.isBreakStatement(caseConsequent) && !caseConsequent.label) { + caseConsequent.label = this.loopLabel = this.loopLabel || this.scope.generateUidIdentifier("loop"); + } + } + } + + body.push(t.switchStatement(ret, cases)); + } + } else { + if (has.hasReturn) { + body.push(retCheck); + } + } + }; + + return BlockScoping; + }(); + + module.exports = exports["default"]; + +/***/ }), +/* 69 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + exports.__esModule = true; + + var _symbol = __webpack_require__(10); + + var _symbol2 = _interopRequireDefault(_symbol); + + exports.default = function (_ref) { + var t = _ref.types; + + var VISITED = (0, _symbol2.default)(); + + return { + visitor: { + ExportDefaultDeclaration: function ExportDefaultDeclaration(path) { + if (!path.get("declaration").isClassDeclaration()) return; + + var node = path.node; + + var ref = node.declaration.id || path.scope.generateUidIdentifier("class"); + node.declaration.id = ref; + + path.replaceWith(node.declaration); + path.insertAfter(t.exportDefaultDeclaration(ref)); + }, + ClassDeclaration: function ClassDeclaration(path) { + var node = path.node; + + var ref = node.id || path.scope.generateUidIdentifier("class"); + + path.replaceWith(t.variableDeclaration("let", [t.variableDeclarator(ref, t.toExpression(node))])); + }, + ClassExpression: function ClassExpression(path, state) { + var node = path.node; + + if (node[VISITED]) return; + + var inferred = (0, _babelHelperFunctionName2.default)(path); + if (inferred && inferred !== node) return path.replaceWith(inferred); + + node[VISITED] = true; + + var Constructor = _vanilla2.default; + if (state.opts.loose) Constructor = _loose2.default; + + path.replaceWith(new Constructor(path, state.file).run()); + } + } + }; + }; + + var _loose = __webpack_require__(327); + + var _loose2 = _interopRequireDefault(_loose); + + var _vanilla = __webpack_require__(203); + + var _vanilla2 = _interopRequireDefault(_vanilla); + + var _babelHelperFunctionName = __webpack_require__(40); + + var _babelHelperFunctionName2 = _interopRequireDefault(_babelHelperFunctionName); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + module.exports = exports["default"]; + +/***/ }), +/* 70 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + exports.__esModule = true; + + var _getIterator2 = __webpack_require__(2); + + var _getIterator3 = _interopRequireDefault(_getIterator2); + + exports.default = function (_ref) { + var t = _ref.types, + template = _ref.template; + + var buildMutatorMapAssign = template("\n MUTATOR_MAP_REF[KEY] = MUTATOR_MAP_REF[KEY] || {};\n MUTATOR_MAP_REF[KEY].KIND = VALUE;\n "); + + function getValue(prop) { + if (t.isObjectProperty(prop)) { + return prop.value; + } else if (t.isObjectMethod(prop)) { + return t.functionExpression(null, prop.params, prop.body, prop.generator, prop.async); + } + } + + function pushAssign(objId, prop, body) { + if (prop.kind === "get" && prop.kind === "set") { + pushMutatorDefine(objId, prop, body); + } else { + body.push(t.expressionStatement(t.assignmentExpression("=", t.memberExpression(objId, prop.key, prop.computed || t.isLiteral(prop.key)), getValue(prop)))); + } + } + + function pushMutatorDefine(_ref2, prop) { + var objId = _ref2.objId, + body = _ref2.body, + getMutatorId = _ref2.getMutatorId, + scope = _ref2.scope; + + var key = !prop.computed && t.isIdentifier(prop.key) ? t.stringLiteral(prop.key.name) : prop.key; + + var maybeMemoise = scope.maybeGenerateMemoised(key); + if (maybeMemoise) { + body.push(t.expressionStatement(t.assignmentExpression("=", maybeMemoise, key))); + key = maybeMemoise; + } + + body.push.apply(body, buildMutatorMapAssign({ + MUTATOR_MAP_REF: getMutatorId(), + KEY: key, + VALUE: getValue(prop), + KIND: t.identifier(prop.kind) + })); + } + + function loose(info) { + for (var _iterator = info.computedProps, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) { + var _ref3; + + if (_isArray) { + if (_i >= _iterator.length) break; + _ref3 = _iterator[_i++]; + } else { + _i = _iterator.next(); + if (_i.done) break; + _ref3 = _i.value; + } + + var prop = _ref3; + + if (prop.kind === "get" || prop.kind === "set") { + pushMutatorDefine(info, prop); + } else { + pushAssign(info.objId, prop, info.body); + } + } + } + + function spec(info) { + var objId = info.objId, + body = info.body, + computedProps = info.computedProps, + state = info.state; + + for (var _iterator2 = computedProps, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : (0, _getIterator3.default)(_iterator2);;) { + var _ref4; + + if (_isArray2) { + if (_i2 >= _iterator2.length) break; + _ref4 = _iterator2[_i2++]; + } else { + _i2 = _iterator2.next(); + if (_i2.done) break; + _ref4 = _i2.value; + } + + var prop = _ref4; + + var key = t.toComputedKey(prop); + + if (prop.kind === "get" || prop.kind === "set") { + pushMutatorDefine(info, prop); + } else if (t.isStringLiteral(key, { value: "__proto__" })) { + pushAssign(objId, prop, body); + } else { + if (computedProps.length === 1) { + return t.callExpression(state.addHelper("defineProperty"), [info.initPropExpression, key, getValue(prop)]); + } else { + body.push(t.expressionStatement(t.callExpression(state.addHelper("defineProperty"), [objId, key, getValue(prop)]))); + } + } + } + } + + return { + visitor: { + ObjectExpression: { + exit: function exit(path, state) { + var node = path.node, + parent = path.parent, + scope = path.scope; + + var hasComputed = false; + for (var _iterator3 = node.properties, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : (0, _getIterator3.default)(_iterator3);;) { + var _ref5; + + if (_isArray3) { + if (_i3 >= _iterator3.length) break; + _ref5 = _iterator3[_i3++]; + } else { + _i3 = _iterator3.next(); + if (_i3.done) break; + _ref5 = _i3.value; + } + + var prop = _ref5; + + hasComputed = prop.computed === true; + if (hasComputed) break; + } + if (!hasComputed) return; + + var initProps = []; + var computedProps = []; + var foundComputed = false; + + for (var _iterator4 = node.properties, _isArray4 = Array.isArray(_iterator4), _i4 = 0, _iterator4 = _isArray4 ? _iterator4 : (0, _getIterator3.default)(_iterator4);;) { + var _ref6; + + if (_isArray4) { + if (_i4 >= _iterator4.length) break; + _ref6 = _iterator4[_i4++]; + } else { + _i4 = _iterator4.next(); + if (_i4.done) break; + _ref6 = _i4.value; + } + + var _prop = _ref6; + + if (_prop.computed) { + foundComputed = true; + } + + if (foundComputed) { + computedProps.push(_prop); + } else { + initProps.push(_prop); + } + } + + var objId = scope.generateUidIdentifierBasedOnNode(parent); + var initPropExpression = t.objectExpression(initProps); + var body = []; + + body.push(t.variableDeclaration("var", [t.variableDeclarator(objId, initPropExpression)])); + + var callback = spec; + if (state.opts.loose) callback = loose; + + var mutatorRef = void 0; + + var getMutatorId = function getMutatorId() { + if (!mutatorRef) { + mutatorRef = scope.generateUidIdentifier("mutatorMap"); + + body.push(t.variableDeclaration("var", [t.variableDeclarator(mutatorRef, t.objectExpression([]))])); + } + + return mutatorRef; + }; + + var single = callback({ + scope: scope, + objId: objId, + body: body, + computedProps: computedProps, + initPropExpression: initPropExpression, + getMutatorId: getMutatorId, + state: state + }); + + if (mutatorRef) { + body.push(t.expressionStatement(t.callExpression(state.addHelper("defineEnumerableProperties"), [objId, mutatorRef]))); + } + + if (single) { + path.replaceWith(single); + } else { + body.push(t.expressionStatement(objId)); + path.replaceWithMultiple(body); + } + } + } + } + }; + }; + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + module.exports = exports["default"]; + +/***/ }), +/* 71 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + exports.__esModule = true; + + var _classCallCheck2 = __webpack_require__(3); + + var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); + + var _getIterator2 = __webpack_require__(2); + + var _getIterator3 = _interopRequireDefault(_getIterator2); + + exports.default = function (_ref) { + var t = _ref.types; + + function variableDeclarationHasPattern(node) { + for (var _iterator = node.declarations, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) { + var _ref2; + + if (_isArray) { + if (_i >= _iterator.length) break; + _ref2 = _iterator[_i++]; + } else { + _i = _iterator.next(); + if (_i.done) break; + _ref2 = _i.value; + } + + var declar = _ref2; + + if (t.isPattern(declar.id)) { + return true; + } + } + return false; + } + + function hasRest(pattern) { + for (var _iterator2 = pattern.elements, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : (0, _getIterator3.default)(_iterator2);;) { + var _ref3; + + if (_isArray2) { + if (_i2 >= _iterator2.length) break; + _ref3 = _iterator2[_i2++]; + } else { + _i2 = _iterator2.next(); + if (_i2.done) break; + _ref3 = _i2.value; + } + + var elem = _ref3; + + if (t.isRestElement(elem)) { + return true; + } + } + return false; + } + + var arrayUnpackVisitor = { + ReferencedIdentifier: function ReferencedIdentifier(path, state) { + if (state.bindings[path.node.name]) { + state.deopt = true; + path.stop(); + } + } + }; + + var DestructuringTransformer = function () { + function DestructuringTransformer(opts) { + (0, _classCallCheck3.default)(this, DestructuringTransformer); + + this.blockHoist = opts.blockHoist; + this.operator = opts.operator; + this.arrays = {}; + this.nodes = opts.nodes || []; + this.scope = opts.scope; + this.file = opts.file; + this.kind = opts.kind; + } + + DestructuringTransformer.prototype.buildVariableAssignment = function buildVariableAssignment(id, init) { + var op = this.operator; + if (t.isMemberExpression(id)) op = "="; + + var node = void 0; + + if (op) { + node = t.expressionStatement(t.assignmentExpression(op, id, init)); + } else { + node = t.variableDeclaration(this.kind, [t.variableDeclarator(id, init)]); + } + + node._blockHoist = this.blockHoist; + + return node; + }; + + DestructuringTransformer.prototype.buildVariableDeclaration = function buildVariableDeclaration(id, init) { + var declar = t.variableDeclaration("var", [t.variableDeclarator(id, init)]); + declar._blockHoist = this.blockHoist; + return declar; + }; + + DestructuringTransformer.prototype.push = function push(id, init) { + if (t.isObjectPattern(id)) { + this.pushObjectPattern(id, init); + } else if (t.isArrayPattern(id)) { + this.pushArrayPattern(id, init); + } else if (t.isAssignmentPattern(id)) { + this.pushAssignmentPattern(id, init); + } else { + this.nodes.push(this.buildVariableAssignment(id, init)); + } + }; + + DestructuringTransformer.prototype.toArray = function toArray(node, count) { + if (this.file.opts.loose || t.isIdentifier(node) && this.arrays[node.name]) { + return node; + } else { + return this.scope.toArray(node, count); + } + }; + + DestructuringTransformer.prototype.pushAssignmentPattern = function pushAssignmentPattern(pattern, valueRef) { + + var tempValueRef = this.scope.generateUidIdentifierBasedOnNode(valueRef); + + var declar = t.variableDeclaration("var", [t.variableDeclarator(tempValueRef, valueRef)]); + declar._blockHoist = this.blockHoist; + this.nodes.push(declar); + + var tempConditional = t.conditionalExpression(t.binaryExpression("===", tempValueRef, t.identifier("undefined")), pattern.right, tempValueRef); + + var left = pattern.left; + if (t.isPattern(left)) { + var tempValueDefault = t.expressionStatement(t.assignmentExpression("=", tempValueRef, tempConditional)); + tempValueDefault._blockHoist = this.blockHoist; + + this.nodes.push(tempValueDefault); + this.push(left, tempValueRef); + } else { + this.nodes.push(this.buildVariableAssignment(left, tempConditional)); + } + }; + + DestructuringTransformer.prototype.pushObjectRest = function pushObjectRest(pattern, objRef, spreadProp, spreadPropIndex) { + + var keys = []; + + for (var i = 0; i < pattern.properties.length; i++) { + var prop = pattern.properties[i]; + + if (i >= spreadPropIndex) break; + + if (t.isRestProperty(prop)) continue; + + var key = prop.key; + if (t.isIdentifier(key) && !prop.computed) key = t.stringLiteral(prop.key.name); + keys.push(key); + } + + keys = t.arrayExpression(keys); + + var value = t.callExpression(this.file.addHelper("objectWithoutProperties"), [objRef, keys]); + this.nodes.push(this.buildVariableAssignment(spreadProp.argument, value)); + }; + + DestructuringTransformer.prototype.pushObjectProperty = function pushObjectProperty(prop, propRef) { + if (t.isLiteral(prop.key)) prop.computed = true; + + var pattern = prop.value; + var objRef = t.memberExpression(propRef, prop.key, prop.computed); + + if (t.isPattern(pattern)) { + this.push(pattern, objRef); + } else { + this.nodes.push(this.buildVariableAssignment(pattern, objRef)); + } + }; + + DestructuringTransformer.prototype.pushObjectPattern = function pushObjectPattern(pattern, objRef) { + + if (!pattern.properties.length) { + this.nodes.push(t.expressionStatement(t.callExpression(this.file.addHelper("objectDestructuringEmpty"), [objRef]))); + } + + if (pattern.properties.length > 1 && !this.scope.isStatic(objRef)) { + var temp = this.scope.generateUidIdentifierBasedOnNode(objRef); + this.nodes.push(this.buildVariableDeclaration(temp, objRef)); + objRef = temp; + } + + for (var i = 0; i < pattern.properties.length; i++) { + var prop = pattern.properties[i]; + if (t.isRestProperty(prop)) { + this.pushObjectRest(pattern, objRef, prop, i); + } else { + this.pushObjectProperty(prop, objRef); + } + } + }; + + DestructuringTransformer.prototype.canUnpackArrayPattern = function canUnpackArrayPattern(pattern, arr) { + if (!t.isArrayExpression(arr)) return false; + + if (pattern.elements.length > arr.elements.length) return; + if (pattern.elements.length < arr.elements.length && !hasRest(pattern)) return false; + + for (var _iterator3 = pattern.elements, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : (0, _getIterator3.default)(_iterator3);;) { + var _ref4; + + if (_isArray3) { + if (_i3 >= _iterator3.length) break; + _ref4 = _iterator3[_i3++]; + } else { + _i3 = _iterator3.next(); + if (_i3.done) break; + _ref4 = _i3.value; + } + + var elem = _ref4; + + if (!elem) return false; + + if (t.isMemberExpression(elem)) return false; + } + + for (var _iterator4 = arr.elements, _isArray4 = Array.isArray(_iterator4), _i4 = 0, _iterator4 = _isArray4 ? _iterator4 : (0, _getIterator3.default)(_iterator4);;) { + var _ref5; + + if (_isArray4) { + if (_i4 >= _iterator4.length) break; + _ref5 = _iterator4[_i4++]; + } else { + _i4 = _iterator4.next(); + if (_i4.done) break; + _ref5 = _i4.value; + } + + var _elem = _ref5; + + if (t.isSpreadElement(_elem)) return false; + + if (t.isCallExpression(_elem)) return false; + + if (t.isMemberExpression(_elem)) return false; + } + + var bindings = t.getBindingIdentifiers(pattern); + var state = { deopt: false, bindings: bindings }; + this.scope.traverse(arr, arrayUnpackVisitor, state); + return !state.deopt; + }; + + DestructuringTransformer.prototype.pushUnpackedArrayPattern = function pushUnpackedArrayPattern(pattern, arr) { + for (var i = 0; i < pattern.elements.length; i++) { + var elem = pattern.elements[i]; + if (t.isRestElement(elem)) { + this.push(elem.argument, t.arrayExpression(arr.elements.slice(i))); + } else { + this.push(elem, arr.elements[i]); + } + } + }; + + DestructuringTransformer.prototype.pushArrayPattern = function pushArrayPattern(pattern, arrayRef) { + if (!pattern.elements) return; + + if (this.canUnpackArrayPattern(pattern, arrayRef)) { + return this.pushUnpackedArrayPattern(pattern, arrayRef); + } + + var count = !hasRest(pattern) && pattern.elements.length; + + var toArray = this.toArray(arrayRef, count); + + if (t.isIdentifier(toArray)) { + arrayRef = toArray; + } else { + arrayRef = this.scope.generateUidIdentifierBasedOnNode(arrayRef); + this.arrays[arrayRef.name] = true; + this.nodes.push(this.buildVariableDeclaration(arrayRef, toArray)); + } + + for (var i = 0; i < pattern.elements.length; i++) { + var elem = pattern.elements[i]; + + if (!elem) continue; + + var elemRef = void 0; + + if (t.isRestElement(elem)) { + elemRef = this.toArray(arrayRef); + elemRef = t.callExpression(t.memberExpression(elemRef, t.identifier("slice")), [t.numericLiteral(i)]); + + elem = elem.argument; + } else { + elemRef = t.memberExpression(arrayRef, t.numericLiteral(i), true); + } + + this.push(elem, elemRef); + } + }; + + DestructuringTransformer.prototype.init = function init(pattern, ref) { + + if (!t.isArrayExpression(ref) && !t.isMemberExpression(ref)) { + var memo = this.scope.maybeGenerateMemoised(ref, true); + if (memo) { + this.nodes.push(this.buildVariableDeclaration(memo, ref)); + ref = memo; + } + } + + this.push(pattern, ref); + + return this.nodes; + }; + + return DestructuringTransformer; + }(); + + return { + visitor: { + ExportNamedDeclaration: function ExportNamedDeclaration(path) { + var declaration = path.get("declaration"); + if (!declaration.isVariableDeclaration()) return; + if (!variableDeclarationHasPattern(declaration.node)) return; + + var specifiers = []; + + for (var name in path.getOuterBindingIdentifiers(path)) { + var id = t.identifier(name); + specifiers.push(t.exportSpecifier(id, id)); + } + + path.replaceWith(declaration.node); + path.insertAfter(t.exportNamedDeclaration(null, specifiers)); + }, + ForXStatement: function ForXStatement(path, file) { + var node = path.node, + scope = path.scope; + + var left = node.left; + + if (t.isPattern(left)) { + + var temp = scope.generateUidIdentifier("ref"); + + node.left = t.variableDeclaration("var", [t.variableDeclarator(temp)]); + + path.ensureBlock(); + + node.body.body.unshift(t.variableDeclaration("var", [t.variableDeclarator(left, temp)])); + + return; + } + + if (!t.isVariableDeclaration(left)) return; + + var pattern = left.declarations[0].id; + if (!t.isPattern(pattern)) return; + + var key = scope.generateUidIdentifier("ref"); + node.left = t.variableDeclaration(left.kind, [t.variableDeclarator(key, null)]); + + var nodes = []; + + var destructuring = new DestructuringTransformer({ + kind: left.kind, + file: file, + scope: scope, + nodes: nodes + }); + + destructuring.init(pattern, key); + + path.ensureBlock(); + + var block = node.body; + block.body = nodes.concat(block.body); + }, + CatchClause: function CatchClause(_ref6, file) { + var node = _ref6.node, + scope = _ref6.scope; + + var pattern = node.param; + if (!t.isPattern(pattern)) return; + + var ref = scope.generateUidIdentifier("ref"); + node.param = ref; + + var nodes = []; + + var destructuring = new DestructuringTransformer({ + kind: "let", + file: file, + scope: scope, + nodes: nodes + }); + destructuring.init(pattern, ref); + + node.body.body = nodes.concat(node.body.body); + }, + AssignmentExpression: function AssignmentExpression(path, file) { + var node = path.node, + scope = path.scope; + + if (!t.isPattern(node.left)) return; + + var nodes = []; + + var destructuring = new DestructuringTransformer({ + operator: node.operator, + file: file, + scope: scope, + nodes: nodes + }); + + var ref = void 0; + if (path.isCompletionRecord() || !path.parentPath.isExpressionStatement()) { + ref = scope.generateUidIdentifierBasedOnNode(node.right, "ref"); + + nodes.push(t.variableDeclaration("var", [t.variableDeclarator(ref, node.right)])); + + if (t.isArrayExpression(node.right)) { + destructuring.arrays[ref.name] = true; + } + } + + destructuring.init(node.left, ref || node.right); + + if (ref) { + nodes.push(t.expressionStatement(ref)); + } + + path.replaceWithMultiple(nodes); + }, + VariableDeclaration: function VariableDeclaration(path, file) { + var node = path.node, + scope = path.scope, + parent = path.parent; + + if (t.isForXStatement(parent)) return; + if (!parent || !path.container) return; + if (!variableDeclarationHasPattern(node)) return; + + var nodes = []; + var declar = void 0; + + for (var i = 0; i < node.declarations.length; i++) { + declar = node.declarations[i]; + + var patternId = declar.init; + var pattern = declar.id; + + var destructuring = new DestructuringTransformer({ + blockHoist: node._blockHoist, + nodes: nodes, + scope: scope, + kind: node.kind, + file: file + }); + + if (t.isPattern(pattern)) { + destructuring.init(pattern, patternId); + + if (+i !== node.declarations.length - 1) { + t.inherits(nodes[nodes.length - 1], declar); + } + } else { + nodes.push(t.inherits(destructuring.buildVariableAssignment(declar.id, declar.init), declar)); + } + } + + var nodesOut = []; + for (var _iterator5 = nodes, _isArray5 = Array.isArray(_iterator5), _i5 = 0, _iterator5 = _isArray5 ? _iterator5 : (0, _getIterator3.default)(_iterator5);;) { + var _ref7; + + if (_isArray5) { + if (_i5 >= _iterator5.length) break; + _ref7 = _iterator5[_i5++]; + } else { + _i5 = _iterator5.next(); + if (_i5.done) break; + _ref7 = _i5.value; + } + + var _node = _ref7; + + var tail = nodesOut[nodesOut.length - 1]; + if (tail && t.isVariableDeclaration(tail) && t.isVariableDeclaration(_node) && tail.kind === _node.kind) { + var _tail$declarations; + + (_tail$declarations = tail.declarations).push.apply(_tail$declarations, _node.declarations); + } else { + nodesOut.push(_node); + } + } + + for (var _iterator6 = nodesOut, _isArray6 = Array.isArray(_iterator6), _i6 = 0, _iterator6 = _isArray6 ? _iterator6 : (0, _getIterator3.default)(_iterator6);;) { + var _ref8; + + if (_isArray6) { + if (_i6 >= _iterator6.length) break; + _ref8 = _iterator6[_i6++]; + } else { + _i6 = _iterator6.next(); + if (_i6.done) break; + _ref8 = _i6.value; + } + + var nodeOut = _ref8; + + if (!nodeOut.declarations) continue; + for (var _iterator7 = nodeOut.declarations, _isArray7 = Array.isArray(_iterator7), _i7 = 0, _iterator7 = _isArray7 ? _iterator7 : (0, _getIterator3.default)(_iterator7);;) { + var _ref9; + + if (_isArray7) { + if (_i7 >= _iterator7.length) break; + _ref9 = _iterator7[_i7++]; + } else { + _i7 = _iterator7.next(); + if (_i7.done) break; + _ref9 = _i7.value; + } + + var declaration = _ref9; + var name = declaration.id.name; + + if (scope.bindings[name]) { + scope.bindings[name].kind = nodeOut.kind; + } + } + } + + if (nodesOut.length === 1) { + path.replaceWith(nodesOut[0]); + } else { + path.replaceWithMultiple(nodesOut); + } + } + } + }; + }; + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + module.exports = exports["default"]; + +/***/ }), +/* 72 */ +/***/ (function(module, exports) { + + "use strict"; + + exports.__esModule = true; + + exports.default = function (_ref) { + var messages = _ref.messages, + template = _ref.template, + t = _ref.types; + + var buildForOfArray = template("\n for (var KEY = 0; KEY < ARR.length; KEY++) BODY;\n "); + + var buildForOfLoose = template("\n for (var LOOP_OBJECT = OBJECT,\n IS_ARRAY = Array.isArray(LOOP_OBJECT),\n INDEX = 0,\n LOOP_OBJECT = IS_ARRAY ? LOOP_OBJECT : LOOP_OBJECT[Symbol.iterator]();;) {\n var ID;\n if (IS_ARRAY) {\n if (INDEX >= LOOP_OBJECT.length) break;\n ID = LOOP_OBJECT[INDEX++];\n } else {\n INDEX = LOOP_OBJECT.next();\n if (INDEX.done) break;\n ID = INDEX.value;\n }\n }\n "); + + var buildForOf = template("\n var ITERATOR_COMPLETION = true;\n var ITERATOR_HAD_ERROR_KEY = false;\n var ITERATOR_ERROR_KEY = undefined;\n try {\n for (var ITERATOR_KEY = OBJECT[Symbol.iterator](), STEP_KEY; !(ITERATOR_COMPLETION = (STEP_KEY = ITERATOR_KEY.next()).done); ITERATOR_COMPLETION = true) {\n }\n } catch (err) {\n ITERATOR_HAD_ERROR_KEY = true;\n ITERATOR_ERROR_KEY = err;\n } finally {\n try {\n if (!ITERATOR_COMPLETION && ITERATOR_KEY.return) {\n ITERATOR_KEY.return();\n }\n } finally {\n if (ITERATOR_HAD_ERROR_KEY) {\n throw ITERATOR_ERROR_KEY;\n }\n }\n }\n "); + + function _ForOfStatementArray(path) { + var node = path.node, + scope = path.scope; + + var nodes = []; + var right = node.right; + + if (!t.isIdentifier(right) || !scope.hasBinding(right.name)) { + var uid = scope.generateUidIdentifier("arr"); + nodes.push(t.variableDeclaration("var", [t.variableDeclarator(uid, right)])); + right = uid; + } + + var iterationKey = scope.generateUidIdentifier("i"); + + var loop = buildForOfArray({ + BODY: node.body, + KEY: iterationKey, + ARR: right + }); + + t.inherits(loop, node); + t.ensureBlock(loop); + + var iterationValue = t.memberExpression(right, iterationKey, true); + + var left = node.left; + if (t.isVariableDeclaration(left)) { + left.declarations[0].init = iterationValue; + loop.body.body.unshift(left); + } else { + loop.body.body.unshift(t.expressionStatement(t.assignmentExpression("=", left, iterationValue))); + } + + if (path.parentPath.isLabeledStatement()) { + loop = t.labeledStatement(path.parentPath.node.label, loop); + } + + nodes.push(loop); + + return nodes; + } + + return { + visitor: { + ForOfStatement: function ForOfStatement(path, state) { + if (path.get("right").isArrayExpression()) { + if (path.parentPath.isLabeledStatement()) { + return path.parentPath.replaceWithMultiple(_ForOfStatementArray(path)); + } else { + return path.replaceWithMultiple(_ForOfStatementArray(path)); + } + } + + var callback = spec; + if (state.opts.loose) callback = loose; + + var node = path.node; + + var build = callback(path, state); + var declar = build.declar; + var loop = build.loop; + var block = loop.body; + + path.ensureBlock(); + + if (declar) { + block.body.push(declar); + } + + block.body = block.body.concat(node.body.body); + + t.inherits(loop, node); + t.inherits(loop.body, node.body); + + if (build.replaceParent) { + path.parentPath.replaceWithMultiple(build.node); + path.remove(); + } else { + path.replaceWithMultiple(build.node); + } + } + } + }; + + function loose(path, file) { + var node = path.node, + scope = path.scope, + parent = path.parent; + var left = node.left; + + var declar = void 0, + id = void 0; + + if (t.isIdentifier(left) || t.isPattern(left) || t.isMemberExpression(left)) { + id = left; + } else if (t.isVariableDeclaration(left)) { + id = scope.generateUidIdentifier("ref"); + declar = t.variableDeclaration(left.kind, [t.variableDeclarator(left.declarations[0].id, id)]); + } else { + throw file.buildCodeFrameError(left, messages.get("unknownForHead", left.type)); + } + + var iteratorKey = scope.generateUidIdentifier("iterator"); + var isArrayKey = scope.generateUidIdentifier("isArray"); + + var loop = buildForOfLoose({ + LOOP_OBJECT: iteratorKey, + IS_ARRAY: isArrayKey, + OBJECT: node.right, + INDEX: scope.generateUidIdentifier("i"), + ID: id + }); + + if (!declar) { + loop.body.body.shift(); + } + + var isLabeledParent = t.isLabeledStatement(parent); + var labeled = void 0; + + if (isLabeledParent) { + labeled = t.labeledStatement(parent.label, loop); + } + + return { + replaceParent: isLabeledParent, + declar: declar, + node: labeled || loop, + loop: loop + }; + } + + function spec(path, file) { + var node = path.node, + scope = path.scope, + parent = path.parent; + + var left = node.left; + var declar = void 0; + + var stepKey = scope.generateUidIdentifier("step"); + var stepValue = t.memberExpression(stepKey, t.identifier("value")); + + if (t.isIdentifier(left) || t.isPattern(left) || t.isMemberExpression(left)) { + declar = t.expressionStatement(t.assignmentExpression("=", left, stepValue)); + } else if (t.isVariableDeclaration(left)) { + declar = t.variableDeclaration(left.kind, [t.variableDeclarator(left.declarations[0].id, stepValue)]); + } else { + throw file.buildCodeFrameError(left, messages.get("unknownForHead", left.type)); + } + + var iteratorKey = scope.generateUidIdentifier("iterator"); + + var template = buildForOf({ + ITERATOR_HAD_ERROR_KEY: scope.generateUidIdentifier("didIteratorError"), + ITERATOR_COMPLETION: scope.generateUidIdentifier("iteratorNormalCompletion"), + ITERATOR_ERROR_KEY: scope.generateUidIdentifier("iteratorError"), + ITERATOR_KEY: iteratorKey, + STEP_KEY: stepKey, + OBJECT: node.right, + BODY: null + }); + + var isLabeledParent = t.isLabeledStatement(parent); + + var tryBody = template[3].block.body; + var loop = tryBody[0]; + + if (isLabeledParent) { + tryBody[0] = t.labeledStatement(parent.label, loop); + } + + return { + replaceParent: isLabeledParent, + declar: declar, + loop: loop, + node: template + }; + } + }; + + module.exports = exports["default"]; + +/***/ }), +/* 73 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + exports.__esModule = true; + + exports.default = function () { + return { + visitor: { + FunctionExpression: { + exit: function exit(path) { + if (path.key !== "value" && !path.parentPath.isObjectProperty()) { + var replacement = (0, _babelHelperFunctionName2.default)(path); + if (replacement) path.replaceWith(replacement); + } + } + }, + + ObjectProperty: function ObjectProperty(path) { + var value = path.get("value"); + if (value.isFunction()) { + var newNode = (0, _babelHelperFunctionName2.default)(value); + if (newNode) value.replaceWith(newNode); + } + } + } + }; + }; + + var _babelHelperFunctionName = __webpack_require__(40); + + var _babelHelperFunctionName2 = _interopRequireDefault(_babelHelperFunctionName); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + module.exports = exports["default"]; + +/***/ }), +/* 74 */ +/***/ (function(module, exports) { + + "use strict"; + + exports.__esModule = true; + + exports.default = function () { + return { + visitor: { + NumericLiteral: function NumericLiteral(_ref) { + var node = _ref.node; + + if (node.extra && /^0[ob]/i.test(node.extra.raw)) { + node.extra = undefined; + } + }, + StringLiteral: function StringLiteral(_ref2) { + var node = _ref2.node; + + if (node.extra && /\\[u]/gi.test(node.extra.raw)) { + node.extra = undefined; + } + } + } + }; + }; + + module.exports = exports["default"]; + +/***/ }), +/* 75 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + exports.__esModule = true; + + var _keys = __webpack_require__(13); + + var _keys2 = _interopRequireDefault(_keys); + + var _create = __webpack_require__(9); + + var _create2 = _interopRequireDefault(_create); + + var _getIterator2 = __webpack_require__(2); + + var _getIterator3 = _interopRequireDefault(_getIterator2); + + var _symbol = __webpack_require__(10); + + var _symbol2 = _interopRequireDefault(_symbol); + + exports.default = function () { + var REASSIGN_REMAP_SKIP = (0, _symbol2.default)(); + + var reassignmentVisitor = { + ReferencedIdentifier: function ReferencedIdentifier(path) { + var name = path.node.name; + var remap = this.remaps[name]; + if (!remap) return; + + if (this.scope.getBinding(name) !== path.scope.getBinding(name)) return; + + if (path.parentPath.isCallExpression({ callee: path.node })) { + path.replaceWith(t.sequenceExpression([t.numericLiteral(0), remap])); + } else if (path.isJSXIdentifier() && t.isMemberExpression(remap)) { + var object = remap.object, + property = remap.property; + + path.replaceWith(t.JSXMemberExpression(t.JSXIdentifier(object.name), t.JSXIdentifier(property.name))); + } else { + path.replaceWith(remap); + } + this.requeueInParent(path); + }, + AssignmentExpression: function AssignmentExpression(path) { + var node = path.node; + if (node[REASSIGN_REMAP_SKIP]) return; + + var left = path.get("left"); + if (!left.isIdentifier()) return; + + var name = left.node.name; + var exports = this.exports[name]; + if (!exports) return; + + if (this.scope.getBinding(name) !== path.scope.getBinding(name)) return; + + node[REASSIGN_REMAP_SKIP] = true; + + for (var _iterator = exports, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) { + var _ref; + + if (_isArray) { + if (_i >= _iterator.length) break; + _ref = _iterator[_i++]; + } else { + _i = _iterator.next(); + if (_i.done) break; + _ref = _i.value; + } + + var reid = _ref; + + node = buildExportsAssignment(reid, node).expression; + } + + path.replaceWith(node); + this.requeueInParent(path); + }, + UpdateExpression: function UpdateExpression(path) { + var arg = path.get("argument"); + if (!arg.isIdentifier()) return; + + var name = arg.node.name; + var exports = this.exports[name]; + if (!exports) return; + + if (this.scope.getBinding(name) !== path.scope.getBinding(name)) return; + + var node = t.assignmentExpression(path.node.operator[0] + "=", arg.node, t.numericLiteral(1)); + + if (path.parentPath.isExpressionStatement() && !path.isCompletionRecord() || path.node.prefix) { + path.replaceWith(node); + this.requeueInParent(path); + return; + } + + var nodes = []; + nodes.push(node); + + var operator = void 0; + if (path.node.operator === "--") { + operator = "+"; + } else { + operator = "-"; + } + nodes.push(t.binaryExpression(operator, arg.node, t.numericLiteral(1))); + + path.replaceWithMultiple(t.sequenceExpression(nodes)); + } + }; + + return { + inherits: __webpack_require__(212), + + visitor: { + ThisExpression: function ThisExpression(path, state) { + if (this.ranCommonJS) return; + + if (state.opts.allowTopLevelThis !== true && !path.findParent(function (path) { + return !path.is("shadow") && THIS_BREAK_KEYS.indexOf(path.type) >= 0; + })) { + path.replaceWith(t.identifier("undefined")); + } + }, + + Program: { + exit: function exit(path) { + this.ranCommonJS = true; + + var strict = !!this.opts.strict; + var noInterop = !!this.opts.noInterop; + + var scope = path.scope; + + scope.rename("module"); + scope.rename("exports"); + scope.rename("require"); + + var hasExports = false; + var hasImports = false; + + var body = path.get("body"); + var imports = (0, _create2.default)(null); + var exports = (0, _create2.default)(null); + + var nonHoistedExportNames = (0, _create2.default)(null); + + var topNodes = []; + var remaps = (0, _create2.default)(null); + + var requires = (0, _create2.default)(null); + + function addRequire(source, blockHoist) { + var cached = requires[source]; + if (cached) return cached; + + var ref = path.scope.generateUidIdentifier((0, _path2.basename)(source, (0, _path2.extname)(source))); + + var varDecl = t.variableDeclaration("var", [t.variableDeclarator(ref, buildRequire(t.stringLiteral(source)).expression)]); + + if (imports[source]) { + varDecl.loc = imports[source].loc; + } + + if (typeof blockHoist === "number" && blockHoist > 0) { + varDecl._blockHoist = blockHoist; + } + + topNodes.push(varDecl); + + return requires[source] = ref; + } + + function addTo(obj, key, arr) { + var existing = obj[key] || []; + obj[key] = existing.concat(arr); + } + + for (var _iterator2 = body, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : (0, _getIterator3.default)(_iterator2);;) { + var _ref2; + + if (_isArray2) { + if (_i2 >= _iterator2.length) break; + _ref2 = _iterator2[_i2++]; + } else { + _i2 = _iterator2.next(); + if (_i2.done) break; + _ref2 = _i2.value; + } + + var _path = _ref2; + + if (_path.isExportDeclaration()) { + hasExports = true; + + var specifiers = [].concat(_path.get("declaration"), _path.get("specifiers")); + for (var _iterator4 = specifiers, _isArray4 = Array.isArray(_iterator4), _i4 = 0, _iterator4 = _isArray4 ? _iterator4 : (0, _getIterator3.default)(_iterator4);;) { + var _ref4; + + if (_isArray4) { + if (_i4 >= _iterator4.length) break; + _ref4 = _iterator4[_i4++]; + } else { + _i4 = _iterator4.next(); + if (_i4.done) break; + _ref4 = _i4.value; + } + + var _specifier2 = _ref4; + + var ids = _specifier2.getBindingIdentifiers(); + if (ids.__esModule) { + throw _specifier2.buildCodeFrameError("Illegal export \"__esModule\""); + } + } + } + + if (_path.isImportDeclaration()) { + var _importsEntry$specifi; + + hasImports = true; + + var key = _path.node.source.value; + var importsEntry = imports[key] || { + specifiers: [], + maxBlockHoist: 0, + loc: _path.node.loc + }; + + (_importsEntry$specifi = importsEntry.specifiers).push.apply(_importsEntry$specifi, _path.node.specifiers); + + if (typeof _path.node._blockHoist === "number") { + importsEntry.maxBlockHoist = Math.max(_path.node._blockHoist, importsEntry.maxBlockHoist); + } + + imports[key] = importsEntry; + + _path.remove(); + } else if (_path.isExportDefaultDeclaration()) { + var declaration = _path.get("declaration"); + if (declaration.isFunctionDeclaration()) { + var id = declaration.node.id; + var defNode = t.identifier("default"); + if (id) { + addTo(exports, id.name, defNode); + topNodes.push(buildExportsAssignment(defNode, id)); + _path.replaceWith(declaration.node); + } else { + topNodes.push(buildExportsAssignment(defNode, t.toExpression(declaration.node))); + _path.remove(); + } + } else if (declaration.isClassDeclaration()) { + var _id = declaration.node.id; + var _defNode = t.identifier("default"); + if (_id) { + addTo(exports, _id.name, _defNode); + _path.replaceWithMultiple([declaration.node, buildExportsAssignment(_defNode, _id)]); + } else { + _path.replaceWith(buildExportsAssignment(_defNode, t.toExpression(declaration.node))); + + _path.parentPath.requeue(_path.get("expression.left")); + } + } else { + _path.replaceWith(buildExportsAssignment(t.identifier("default"), declaration.node)); + + _path.parentPath.requeue(_path.get("expression.left")); + } + } else if (_path.isExportNamedDeclaration()) { + var _declaration = _path.get("declaration"); + if (_declaration.node) { + if (_declaration.isFunctionDeclaration()) { + var _id2 = _declaration.node.id; + addTo(exports, _id2.name, _id2); + topNodes.push(buildExportsAssignment(_id2, _id2)); + _path.replaceWith(_declaration.node); + } else if (_declaration.isClassDeclaration()) { + var _id3 = _declaration.node.id; + addTo(exports, _id3.name, _id3); + _path.replaceWithMultiple([_declaration.node, buildExportsAssignment(_id3, _id3)]); + nonHoistedExportNames[_id3.name] = true; + } else if (_declaration.isVariableDeclaration()) { + var declarators = _declaration.get("declarations"); + for (var _iterator5 = declarators, _isArray5 = Array.isArray(_iterator5), _i5 = 0, _iterator5 = _isArray5 ? _iterator5 : (0, _getIterator3.default)(_iterator5);;) { + var _ref5; + + if (_isArray5) { + if (_i5 >= _iterator5.length) break; + _ref5 = _iterator5[_i5++]; + } else { + _i5 = _iterator5.next(); + if (_i5.done) break; + _ref5 = _i5.value; + } + + var decl = _ref5; + + var _id4 = decl.get("id"); + + var init = decl.get("init"); + if (!init.node) init.replaceWith(t.identifier("undefined")); + + if (_id4.isIdentifier()) { + addTo(exports, _id4.node.name, _id4.node); + init.replaceWith(buildExportsAssignment(_id4.node, init.node).expression); + nonHoistedExportNames[_id4.node.name] = true; + } else {} + } + _path.replaceWith(_declaration.node); + } + continue; + } + + var _specifiers = _path.get("specifiers"); + var nodes = []; + var _source = _path.node.source; + if (_source) { + var ref = addRequire(_source.value, _path.node._blockHoist); + + for (var _iterator6 = _specifiers, _isArray6 = Array.isArray(_iterator6), _i6 = 0, _iterator6 = _isArray6 ? _iterator6 : (0, _getIterator3.default)(_iterator6);;) { + var _ref6; + + if (_isArray6) { + if (_i6 >= _iterator6.length) break; + _ref6 = _iterator6[_i6++]; + } else { + _i6 = _iterator6.next(); + if (_i6.done) break; + _ref6 = _i6.value; + } + + var _specifier3 = _ref6; + + if (_specifier3.isExportNamespaceSpecifier()) {} else if (_specifier3.isExportDefaultSpecifier()) {} else if (_specifier3.isExportSpecifier()) { + if (!noInterop && _specifier3.node.local.name === "default") { + topNodes.push(buildExportsFrom(t.stringLiteral(_specifier3.node.exported.name), t.memberExpression(t.callExpression(this.addHelper("interopRequireDefault"), [ref]), _specifier3.node.local))); + } else { + topNodes.push(buildExportsFrom(t.stringLiteral(_specifier3.node.exported.name), t.memberExpression(ref, _specifier3.node.local))); + } + nonHoistedExportNames[_specifier3.node.exported.name] = true; + } + } + } else { + for (var _iterator7 = _specifiers, _isArray7 = Array.isArray(_iterator7), _i7 = 0, _iterator7 = _isArray7 ? _iterator7 : (0, _getIterator3.default)(_iterator7);;) { + var _ref7; + + if (_isArray7) { + if (_i7 >= _iterator7.length) break; + _ref7 = _iterator7[_i7++]; + } else { + _i7 = _iterator7.next(); + if (_i7.done) break; + _ref7 = _i7.value; + } + + var _specifier4 = _ref7; + + if (_specifier4.isExportSpecifier()) { + addTo(exports, _specifier4.node.local.name, _specifier4.node.exported); + nonHoistedExportNames[_specifier4.node.exported.name] = true; + nodes.push(buildExportsAssignment(_specifier4.node.exported, _specifier4.node.local)); + } + } + } + _path.replaceWithMultiple(nodes); + } else if (_path.isExportAllDeclaration()) { + var exportNode = buildExportAll({ + OBJECT: addRequire(_path.node.source.value, _path.node._blockHoist) + }); + exportNode.loc = _path.node.loc; + topNodes.push(exportNode); + _path.remove(); + } + } + + for (var source in imports) { + var _imports$source = imports[source], + specifiers = _imports$source.specifiers, + maxBlockHoist = _imports$source.maxBlockHoist; + + if (specifiers.length) { + var uid = addRequire(source, maxBlockHoist); + + var wildcard = void 0; + + for (var i = 0; i < specifiers.length; i++) { + var specifier = specifiers[i]; + if (t.isImportNamespaceSpecifier(specifier)) { + if (strict || noInterop) { + remaps[specifier.local.name] = uid; + } else { + var varDecl = t.variableDeclaration("var", [t.variableDeclarator(specifier.local, t.callExpression(this.addHelper("interopRequireWildcard"), [uid]))]); + + if (maxBlockHoist > 0) { + varDecl._blockHoist = maxBlockHoist; + } + + topNodes.push(varDecl); + } + wildcard = specifier.local; + } else if (t.isImportDefaultSpecifier(specifier)) { + specifiers[i] = t.importSpecifier(specifier.local, t.identifier("default")); + } + } + + for (var _iterator3 = specifiers, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : (0, _getIterator3.default)(_iterator3);;) { + var _ref3; + + if (_isArray3) { + if (_i3 >= _iterator3.length) break; + _ref3 = _iterator3[_i3++]; + } else { + _i3 = _iterator3.next(); + if (_i3.done) break; + _ref3 = _i3.value; + } + + var _specifier = _ref3; + + if (t.isImportSpecifier(_specifier)) { + var target = uid; + if (_specifier.imported.name === "default") { + if (wildcard) { + target = wildcard; + } else if (!noInterop) { + target = wildcard = path.scope.generateUidIdentifier(uid.name); + var _varDecl = t.variableDeclaration("var", [t.variableDeclarator(target, t.callExpression(this.addHelper("interopRequireDefault"), [uid]))]); + + if (maxBlockHoist > 0) { + _varDecl._blockHoist = maxBlockHoist; + } + + topNodes.push(_varDecl); + } + } + remaps[_specifier.local.name] = t.memberExpression(target, t.cloneWithoutLoc(_specifier.imported)); + } + } + } else { + var requireNode = buildRequire(t.stringLiteral(source)); + requireNode.loc = imports[source].loc; + topNodes.push(requireNode); + } + } + + if (hasImports && (0, _keys2.default)(nonHoistedExportNames).length) { + var maxHoistedExportsNodeAssignmentLength = 100; + var nonHoistedExportNamesArr = (0, _keys2.default)(nonHoistedExportNames); + + var _loop = function _loop(currentExportsNodeAssignmentLength) { + var nonHoistedExportNamesChunk = nonHoistedExportNamesArr.slice(currentExportsNodeAssignmentLength, currentExportsNodeAssignmentLength + maxHoistedExportsNodeAssignmentLength); + + var hoistedExportsNode = t.identifier("undefined"); + + nonHoistedExportNamesChunk.forEach(function (name) { + hoistedExportsNode = buildExportsAssignment(t.identifier(name), hoistedExportsNode).expression; + }); + + var node = t.expressionStatement(hoistedExportsNode); + node._blockHoist = 3; + + topNodes.unshift(node); + }; + + for (var currentExportsNodeAssignmentLength = 0; currentExportsNodeAssignmentLength < nonHoistedExportNamesArr.length; currentExportsNodeAssignmentLength += maxHoistedExportsNodeAssignmentLength) { + _loop(currentExportsNodeAssignmentLength); + } + } + + if (hasExports && !strict) { + var buildTemplate = buildExportsModuleDeclaration; + if (this.opts.loose) buildTemplate = buildLooseExportsModuleDeclaration; + + var declar = buildTemplate(); + declar._blockHoist = 3; + + topNodes.unshift(declar); + } + + path.unshiftContainer("body", topNodes); + path.traverse(reassignmentVisitor, { + remaps: remaps, + scope: scope, + exports: exports, + requeueInParent: function requeueInParent(newPath) { + return path.requeue(newPath); + } + }); + } + } + } + }; + }; + + var _path2 = __webpack_require__(17); + + var _babelTemplate = __webpack_require__(4); + + var _babelTemplate2 = _interopRequireDefault(_babelTemplate); + + var _babelTypes = __webpack_require__(1); + + var t = _interopRequireWildcard(_babelTypes); + + function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } else { + var newObj = {};if (obj != null) { + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; + } + }newObj.default = obj;return newObj; + } + } + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + var buildRequire = (0, _babelTemplate2.default)("\n require($0);\n"); + + var buildExportsModuleDeclaration = (0, _babelTemplate2.default)("\n Object.defineProperty(exports, \"__esModule\", {\n value: true\n });\n"); + + var buildExportsFrom = (0, _babelTemplate2.default)("\n Object.defineProperty(exports, $0, {\n enumerable: true,\n get: function () {\n return $1;\n }\n });\n"); + + var buildLooseExportsModuleDeclaration = (0, _babelTemplate2.default)("\n exports.__esModule = true;\n"); + + var buildExportsAssignment = (0, _babelTemplate2.default)("\n exports.$0 = $1;\n"); + + var buildExportAll = (0, _babelTemplate2.default)("\n Object.keys(OBJECT).forEach(function (key) {\n if (key === \"default\" || key === \"__esModule\") return;\n Object.defineProperty(exports, key, {\n enumerable: true,\n get: function () {\n return OBJECT[key];\n }\n });\n });\n"); + + var THIS_BREAK_KEYS = ["FunctionExpression", "FunctionDeclaration", "ClassProperty", "ClassMethod", "ObjectMethod"]; + + module.exports = exports["default"]; + +/***/ }), +/* 76 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + exports.__esModule = true; + + var _getIterator2 = __webpack_require__(2); + + var _getIterator3 = _interopRequireDefault(_getIterator2); + + var _symbol = __webpack_require__(10); + + var _symbol2 = _interopRequireDefault(_symbol); + + exports.default = function (_ref) { + var t = _ref.types; + + function Property(path, node, scope, getObjectRef, file) { + var replaceSupers = new _babelHelperReplaceSupers2.default({ + getObjectRef: getObjectRef, + methodNode: node, + methodPath: path, + isStatic: true, + scope: scope, + file: file + }); + + replaceSupers.replace(); + } + + var CONTAINS_SUPER = (0, _symbol2.default)(); + + return { + visitor: { + Super: function Super(path) { + var parentObj = path.findParent(function (path) { + return path.isObjectExpression(); + }); + if (parentObj) parentObj.node[CONTAINS_SUPER] = true; + }, + + ObjectExpression: { + exit: function exit(path, file) { + if (!path.node[CONTAINS_SUPER]) return; + + var objectRef = void 0; + var getObjectRef = function getObjectRef() { + return objectRef = objectRef || path.scope.generateUidIdentifier("obj"); + }; + + var propPaths = path.get("properties"); + for (var _iterator = propPaths, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) { + var _ref2; + + if (_isArray) { + if (_i >= _iterator.length) break; + _ref2 = _iterator[_i++]; + } else { + _i = _iterator.next(); + if (_i.done) break; + _ref2 = _i.value; + } + + var propPath = _ref2; + + if (propPath.isObjectProperty()) propPath = propPath.get("value"); + Property(propPath, propPath.node, path.scope, getObjectRef, file); + } + + if (objectRef) { + path.scope.push({ id: objectRef }); + path.replaceWith(t.assignmentExpression("=", objectRef, path.node)); + } + } + } + } + }; + }; + + var _babelHelperReplaceSupers = __webpack_require__(189); + + var _babelHelperReplaceSupers2 = _interopRequireDefault(_babelHelperReplaceSupers); + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + module.exports = exports["default"]; + +/***/ }), +/* 77 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + exports.__esModule = true; + + var _getIterator2 = __webpack_require__(2); + + var _getIterator3 = _interopRequireDefault(_getIterator2); + + exports.default = function () { + return { + visitor: _babelTraverse.visitors.merge([{ + ArrowFunctionExpression: function ArrowFunctionExpression(path) { + var params = path.get("params"); + for (var _iterator = params, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) { + var _ref; + + if (_isArray) { + if (_i >= _iterator.length) break; + _ref = _iterator[_i++]; + } else { + _i = _iterator.next(); + if (_i.done) break; + _ref = _i.value; + } + + var param = _ref; + + if (param.isRestElement() || param.isAssignmentPattern()) { + path.arrowFunctionToShadowed(); + break; + } + } + } + }, destructuring.visitor, rest.visitor, def.visitor]) + }; + }; + + var _babelTraverse = __webpack_require__(7); + + var _destructuring = __webpack_require__(330); + + var destructuring = _interopRequireWildcard(_destructuring); + + var _default = __webpack_require__(329); + + var def = _interopRequireWildcard(_default); + + var _rest = __webpack_require__(331); + + var rest = _interopRequireWildcard(_rest); + + function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } else { + var newObj = {};if (obj != null) { + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; + } + }newObj.default = obj;return newObj; + } + } + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + module.exports = exports["default"]; + +/***/ }), +/* 78 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + exports.__esModule = true; + + exports.default = function () { + return { + visitor: { + ObjectMethod: function ObjectMethod(path) { + var node = path.node; + + if (node.kind === "method") { + var func = t.functionExpression(null, node.params, node.body, node.generator, node.async); + func.returnType = node.returnType; + + path.replaceWith(t.objectProperty(node.key, func, node.computed)); + } + }, + ObjectProperty: function ObjectProperty(_ref) { + var node = _ref.node; + + if (node.shorthand) { + node.shorthand = false; + } + } + } + }; + }; + + var _babelTypes = __webpack_require__(1); + + var t = _interopRequireWildcard(_babelTypes); + + function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } else { + var newObj = {};if (obj != null) { + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; + } + }newObj.default = obj;return newObj; + } + } + + module.exports = exports["default"]; + +/***/ }), +/* 79 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + exports.__esModule = true; + + var _getIterator2 = __webpack_require__(2); + + var _getIterator3 = _interopRequireDefault(_getIterator2); + + exports.default = function (_ref) { + var t = _ref.types; + + function getSpreadLiteral(spread, scope, state) { + if (state.opts.loose && !t.isIdentifier(spread.argument, { name: "arguments" })) { + return spread.argument; + } else { + return scope.toArray(spread.argument, true); + } + } + + function hasSpread(nodes) { + for (var i = 0; i < nodes.length; i++) { + if (t.isSpreadElement(nodes[i])) { + return true; + } + } + return false; + } + + function build(props, scope, state) { + var nodes = []; + + var _props = []; + + function push() { + if (!_props.length) return; + nodes.push(t.arrayExpression(_props)); + _props = []; + } + + for (var _iterator = props, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) { + var _ref2; + + if (_isArray) { + if (_i >= _iterator.length) break; + _ref2 = _iterator[_i++]; + } else { + _i = _iterator.next(); + if (_i.done) break; + _ref2 = _i.value; + } + + var prop = _ref2; + + if (t.isSpreadElement(prop)) { + push(); + nodes.push(getSpreadLiteral(prop, scope, state)); + } else { + _props.push(prop); + } + } + + push(); + + return nodes; + } + + return { + visitor: { + ArrayExpression: function ArrayExpression(path, state) { + var node = path.node, + scope = path.scope; + + var elements = node.elements; + if (!hasSpread(elements)) return; + + var nodes = build(elements, scope, state); + var first = nodes.shift(); + + if (!t.isArrayExpression(first)) { + nodes.unshift(first); + first = t.arrayExpression([]); + } + + path.replaceWith(t.callExpression(t.memberExpression(first, t.identifier("concat")), nodes)); + }, + CallExpression: function CallExpression(path, state) { + var node = path.node, + scope = path.scope; + + var args = node.arguments; + if (!hasSpread(args)) return; + + var calleePath = path.get("callee"); + if (calleePath.isSuper()) return; + + var contextLiteral = t.identifier("undefined"); + + node.arguments = []; + + var nodes = void 0; + if (args.length === 1 && args[0].argument.name === "arguments") { + nodes = [args[0].argument]; + } else { + nodes = build(args, scope, state); + } + + var first = nodes.shift(); + if (nodes.length) { + node.arguments.push(t.callExpression(t.memberExpression(first, t.identifier("concat")), nodes)); + } else { + node.arguments.push(first); + } + + var callee = node.callee; + + if (calleePath.isMemberExpression()) { + var temp = scope.maybeGenerateMemoised(callee.object); + if (temp) { + callee.object = t.assignmentExpression("=", temp, callee.object); + contextLiteral = temp; + } else { + contextLiteral = callee.object; + } + t.appendToMemberExpression(callee, t.identifier("apply")); + } else { + node.callee = t.memberExpression(node.callee, t.identifier("apply")); + } + + if (t.isSuper(contextLiteral)) { + contextLiteral = t.thisExpression(); + } + + node.arguments.unshift(contextLiteral); + }, + NewExpression: function NewExpression(path, state) { + var node = path.node, + scope = path.scope; + + var args = node.arguments; + if (!hasSpread(args)) return; + + var nodes = build(args, scope, state); + + var context = t.arrayExpression([t.nullLiteral()]); + + args = t.callExpression(t.memberExpression(context, t.identifier("concat")), nodes); + + path.replaceWith(t.newExpression(t.callExpression(t.memberExpression(t.memberExpression(t.memberExpression(t.identifier("Function"), t.identifier("prototype")), t.identifier("bind")), t.identifier("apply")), [node.callee, args]), [])); + } + } + }; + }; + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + module.exports = exports["default"]; + +/***/ }), +/* 80 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + exports.__esModule = true; + + exports.default = function () { + return { + visitor: { + RegExpLiteral: function RegExpLiteral(path) { + var node = path.node; + + if (!regex.is(node, "y")) return; + + path.replaceWith(t.newExpression(t.identifier("RegExp"), [t.stringLiteral(node.pattern), t.stringLiteral(node.flags)])); + } + } + }; + }; + + var _babelHelperRegex = __webpack_require__(188); + + var regex = _interopRequireWildcard(_babelHelperRegex); + + var _babelTypes = __webpack_require__(1); + + var t = _interopRequireWildcard(_babelTypes); + + function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } else { + var newObj = {};if (obj != null) { + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; + } + }newObj.default = obj;return newObj; + } + } + + module.exports = exports["default"]; + +/***/ }), +/* 81 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + exports.__esModule = true; + + var _getIterator2 = __webpack_require__(2); + + var _getIterator3 = _interopRequireDefault(_getIterator2); + + exports.default = function (_ref) { + var t = _ref.types; + + function isString(node) { + return t.isLiteral(node) && typeof node.value === "string"; + } + + function buildBinaryExpression(left, right) { + return t.binaryExpression("+", left, right); + } + + return { + visitor: { + TaggedTemplateExpression: function TaggedTemplateExpression(path, state) { + var node = path.node; + + var quasi = node.quasi; + var args = []; + + var strings = []; + var raw = []; + + for (var _iterator = quasi.quasis, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) { + var _ref2; + + if (_isArray) { + if (_i >= _iterator.length) break; + _ref2 = _iterator[_i++]; + } else { + _i = _iterator.next(); + if (_i.done) break; + _ref2 = _i.value; + } + + var elem = _ref2; + + strings.push(t.stringLiteral(elem.value.cooked)); + raw.push(t.stringLiteral(elem.value.raw)); + } + + strings = t.arrayExpression(strings); + raw = t.arrayExpression(raw); + + var templateName = "taggedTemplateLiteral"; + if (state.opts.loose) templateName += "Loose"; + + var templateObject = state.file.addTemplateObject(templateName, strings, raw); + args.push(templateObject); + + args = args.concat(quasi.expressions); + + path.replaceWith(t.callExpression(node.tag, args)); + }, + TemplateLiteral: function TemplateLiteral(path, state) { + var nodes = []; + + var expressions = path.get("expressions"); + + for (var _iterator2 = path.node.quasis, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : (0, _getIterator3.default)(_iterator2);;) { + var _ref3; + + if (_isArray2) { + if (_i2 >= _iterator2.length) break; + _ref3 = _iterator2[_i2++]; + } else { + _i2 = _iterator2.next(); + if (_i2.done) break; + _ref3 = _i2.value; + } + + var elem = _ref3; + + nodes.push(t.stringLiteral(elem.value.cooked)); + + var expr = expressions.shift(); + if (expr) { + if (state.opts.spec && !expr.isBaseType("string") && !expr.isBaseType("number")) { + nodes.push(t.callExpression(t.identifier("String"), [expr.node])); + } else { + nodes.push(expr.node); + } + } + } + + nodes = nodes.filter(function (n) { + return !t.isLiteral(n, { value: "" }); + }); + + if (!isString(nodes[0]) && !isString(nodes[1])) { + nodes.unshift(t.stringLiteral("")); + } + + if (nodes.length > 1) { + var root = buildBinaryExpression(nodes.shift(), nodes.shift()); + + for (var _iterator3 = nodes, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : (0, _getIterator3.default)(_iterator3);;) { + var _ref4; + + if (_isArray3) { + if (_i3 >= _iterator3.length) break; + _ref4 = _iterator3[_i3++]; + } else { + _i3 = _iterator3.next(); + if (_i3.done) break; + _ref4 = _i3.value; + } + + var node = _ref4; + + root = buildBinaryExpression(root, node); + } + + path.replaceWith(root); + } else { + path.replaceWith(nodes[0]); + } + } + } + }; + }; + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + module.exports = exports["default"]; + +/***/ }), +/* 82 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + exports.__esModule = true; + + var _symbol = __webpack_require__(10); + + var _symbol2 = _interopRequireDefault(_symbol); + + exports.default = function (_ref) { + var t = _ref.types; + + var IGNORE = (0, _symbol2.default)(); + + return { + visitor: { + Scope: function Scope(_ref2) { + var scope = _ref2.scope; + + if (!scope.getBinding("Symbol")) { + return; + } + + scope.rename("Symbol"); + }, + UnaryExpression: function UnaryExpression(path) { + var node = path.node, + parent = path.parent; + + if (node[IGNORE]) return; + if (path.find(function (path) { + return path.node && !!path.node._generated; + })) return; + + if (path.parentPath.isBinaryExpression() && t.EQUALITY_BINARY_OPERATORS.indexOf(parent.operator) >= 0) { + var opposite = path.getOpposite(); + if (opposite.isLiteral() && opposite.node.value !== "symbol" && opposite.node.value !== "object") { + return; + } + } + + if (node.operator === "typeof") { + var call = t.callExpression(this.addHelper("typeof"), [node.argument]); + if (path.get("argument").isIdentifier()) { + var undefLiteral = t.stringLiteral("undefined"); + var unary = t.unaryExpression("typeof", node.argument); + unary[IGNORE] = true; + path.replaceWith(t.conditionalExpression(t.binaryExpression("===", unary, undefLiteral), undefLiteral, call)); + } else { + path.replaceWith(call); + } + } + } + } + }; + }; + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + module.exports = exports["default"]; + +/***/ }), +/* 83 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + exports.__esModule = true; + + exports.default = function () { + return { + visitor: { + RegExpLiteral: function RegExpLiteral(_ref) { + var node = _ref.node; + + if (!regex.is(node, "u")) return; + node.pattern = (0, _regexpuCore2.default)(node.pattern, node.flags); + regex.pullFlag(node, "u"); + } + } + }; + }; + + var _regexpuCore = __webpack_require__(603); + + var _regexpuCore2 = _interopRequireDefault(_regexpuCore); + + var _babelHelperRegex = __webpack_require__(188); + + var regex = _interopRequireWildcard(_babelHelperRegex); + + function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } else { + var newObj = {};if (obj != null) { + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; + } + }newObj.default = obj;return newObj; + } + } + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + module.exports = exports["default"]; + +/***/ }), +/* 84 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + module.exports = __webpack_require__(597); + +/***/ }), +/* 85 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + module.exports = { "default": __webpack_require__(404), __esModule: true }; + +/***/ }), +/* 86 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + exports.__esModule = true; + exports.scope = exports.path = undefined; + + var _weakMap = __webpack_require__(360); + + var _weakMap2 = _interopRequireDefault(_weakMap); + + exports.clear = clear; + exports.clearPath = clearPath; + exports.clearScope = clearScope; + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + var path = exports.path = new _weakMap2.default(); + var scope = exports.scope = new _weakMap2.default(); + + function clear() { + clearPath(); + clearScope(); + } + + function clearPath() { + exports.path = path = new _weakMap2.default(); + } + + function clearScope() { + exports.scope = scope = new _weakMap2.default(); + } + +/***/ }), +/* 87 */ +/***/ (function(module, exports) { + + 'use strict'; + + var _typeof2 = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + + Object.defineProperty(exports, '__esModule', { value: true }); + + /* eslint max-len: 0 */ + + // This is a trick taken from Esprima. It turns out that, on + // non-Chrome browsers, to check whether a string is in a set, a + // predicate containing a big ugly `switch` statement is faster than + // a regular expression, and on Chrome the two are about on par. + // This function uses `eval` (non-lexical) to produce such a + // predicate from a space-separated string of words. + // + // It starts by sorting the words by length. + + function makePredicate(words) { + words = words.split(" "); + return function (str) { + return words.indexOf(str) >= 0; + }; + } + + // Reserved word lists for various dialects of the language + + var reservedWords = { + 6: makePredicate("enum await"), + strict: makePredicate("implements interface let package private protected public static yield"), + strictBind: makePredicate("eval arguments") + }; + + // And the keywords + + var isKeyword = makePredicate("break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this let const class extends export import yield super"); + + // ## Character categories + + // Big ugly regular expressions that match characters in the + // whitespace, identifier, and identifier-start categories. These + // are only applied when a character is found to actually have a + // code point above 128. + // Generated by `bin/generate-identifier-regex.js`. + + var nonASCIIidentifierStartChars = '\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC'; + var nonASCIIidentifierChars = '\u200C\u200D\xB7\u0300-\u036F\u0387\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u0669\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u06F0-\u06F9\u0711\u0730-\u074A\u07A6-\u07B0\u07C0-\u07C9\u07EB-\u07F3\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D4-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0966-\u096F\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09E6-\u09EF\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B66-\u0B6F\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CE6-\u0CEF\u0D01-\u0D03\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D66-\u0D6F\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0E50-\u0E59\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0ED0-\u0ED9\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1040-\u1049\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109D\u135D-\u135F\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u18A9\u1920-\u192B\u1930-\u193B\u1946-\u194F\u19D0-\u19DA\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AB0-\u1ABD\u1B00-\u1B04\u1B34-\u1B44\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BB0-\u1BB9\u1BE6-\u1BF3\u1C24-\u1C37\u1C40-\u1C49\u1C50-\u1C59\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF8\u1CF9\u1DC0-\u1DF5\u1DFB-\u1DFF\u203F\u2040\u2054\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA620-\uA629\uA66F\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F1\uA900-\uA909\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9D0-\uA9D9\uA9E5\uA9F0-\uA9F9\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA50-\uAA59\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uABF0-\uABF9\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFF10-\uFF19\uFF3F'; + + var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]"); + var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]"); + + nonASCIIidentifierStartChars = nonASCIIidentifierChars = null; + + // These are a run-length and offset encoded representation of the + // >0xffff code points that are a valid part of identifiers. The + // offset starts at 0x10000, and each pair of numbers represents an + // offset to the next range, and then a size of the range. They were + // generated by `bin/generate-identifier-regex.js`. + // eslint-disable-next-line comma-spacing + var astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 17, 26, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 157, 310, 10, 21, 11, 7, 153, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 26, 45, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 785, 52, 76, 44, 33, 24, 27, 35, 42, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 85, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 159, 52, 19, 3, 54, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 86, 25, 391, 63, 32, 0, 449, 56, 264, 8, 2, 36, 18, 0, 50, 29, 881, 921, 103, 110, 18, 195, 2749, 1070, 4050, 582, 8634, 568, 8, 30, 114, 29, 19, 47, 17, 3, 32, 20, 6, 18, 881, 68, 12, 0, 67, 12, 65, 0, 32, 6124, 20, 754, 9486, 1, 3071, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 4149, 196, 60, 67, 1213, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42710, 42, 4148, 12, 221, 3, 5761, 10591, 541]; + // eslint-disable-next-line comma-spacing + var astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 1306, 2, 54, 14, 32, 9, 16, 3, 46, 10, 54, 9, 7, 2, 37, 13, 2, 9, 52, 0, 13, 2, 49, 13, 10, 2, 4, 9, 83, 11, 7, 0, 161, 11, 6, 9, 7, 3, 57, 0, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 87, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 423, 9, 838, 7, 2, 7, 17, 9, 57, 21, 2, 13, 19882, 9, 135, 4, 60, 6, 26, 9, 1016, 45, 17, 3, 19723, 1, 5319, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 2214, 6, 110, 6, 6, 9, 792487, 239]; + + // This has a complexity linear to the value of the code. The + // assumption is that looking up astral identifier characters is + // rare. + function isInAstralSet(code, set) { + var pos = 0x10000; + for (var i = 0; i < set.length; i += 2) { + pos += set[i]; + if (pos > code) return false; + + pos += set[i + 1]; + if (pos >= code) return true; + } + } + + // Test whether a given character code starts an identifier. + + function isIdentifierStart(code) { + if (code < 65) return code === 36; + if (code < 91) return true; + if (code < 97) return code === 95; + if (code < 123) return true; + if (code <= 0xffff) return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)); + return isInAstralSet(code, astralIdentifierStartCodes); + } + + // Test whether a given character is part of an identifier. + + function isIdentifierChar(code) { + if (code < 48) return code === 36; + if (code < 58) return true; + if (code < 65) return false; + if (code < 91) return true; + if (code < 97) return code === 95; + if (code < 123) return true; + if (code <= 0xffff) return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code)); + return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes); + } + + // A second optional argument can be given to further configure + var defaultOptions = { + // Source type ("script" or "module") for different semantics + sourceType: "script", + // Source filename. + sourceFilename: undefined, + // Line from which to start counting source. Useful for + // integration with other tools. + startLine: 1, + // When enabled, a return at the top level is not considered an + // error. + allowReturnOutsideFunction: false, + // When enabled, import/export statements are not constrained to + // appearing at the top of the program. + allowImportExportEverywhere: false, + // TODO + allowSuperOutsideMethod: false, + // An array of plugins to enable + plugins: [], + // TODO + strictMode: null + }; + + // Interpret and default an options object + + function getOptions(opts) { + var options = {}; + for (var key in defaultOptions) { + options[key] = opts && key in opts ? opts[key] : defaultOptions[key]; + } + return options; + } + + var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) { + return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); + } : function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); + }; + + var classCallCheck = function classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + }; + + var inherits = function inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + (typeof superClass === 'undefined' ? 'undefined' : _typeof2(superClass))); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + }; + + var possibleConstructorReturn = function possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return call && ((typeof call === 'undefined' ? 'undefined' : _typeof2(call)) === "object" || typeof call === "function") ? call : self; + }; + + // ## Token types + + // The assignment of fine-grained, information-carrying type objects + // allows the tokenizer to store the information it has about a + // token in a way that is very cheap for the parser to look up. + + // All token type variables start with an underscore, to make them + // easy to recognize. + + // The `beforeExpr` property is used to disambiguate between regular + // expressions and divisions. It is set on all token types that can + // be followed by an expression (thus, a slash after them would be a + // regular expression). + // + // `isLoop` marks a keyword as starting a loop, which is important + // to know when parsing a label, in order to allow or disallow + // continue jumps to that label. + + var beforeExpr = true; + var startsExpr = true; + var isLoop = true; + var isAssign = true; + var prefix = true; + var postfix = true; + + var TokenType = function TokenType(label) { + var conf = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + classCallCheck(this, TokenType); + + this.label = label; + this.keyword = conf.keyword; + this.beforeExpr = !!conf.beforeExpr; + this.startsExpr = !!conf.startsExpr; + this.rightAssociative = !!conf.rightAssociative; + this.isLoop = !!conf.isLoop; + this.isAssign = !!conf.isAssign; + this.prefix = !!conf.prefix; + this.postfix = !!conf.postfix; + this.binop = conf.binop || null; + this.updateContext = null; + }; + + var KeywordTokenType = function (_TokenType) { + inherits(KeywordTokenType, _TokenType); + + function KeywordTokenType(name) { + var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + classCallCheck(this, KeywordTokenType); + + options.keyword = name; + + return possibleConstructorReturn(this, _TokenType.call(this, name, options)); + } + + return KeywordTokenType; + }(TokenType); + + var BinopTokenType = function (_TokenType2) { + inherits(BinopTokenType, _TokenType2); + + function BinopTokenType(name, prec) { + classCallCheck(this, BinopTokenType); + return possibleConstructorReturn(this, _TokenType2.call(this, name, { beforeExpr: beforeExpr, binop: prec })); + } + + return BinopTokenType; + }(TokenType); + + var types = { + num: new TokenType("num", { startsExpr: startsExpr }), + regexp: new TokenType("regexp", { startsExpr: startsExpr }), + string: new TokenType("string", { startsExpr: startsExpr }), + name: new TokenType("name", { startsExpr: startsExpr }), + eof: new TokenType("eof"), + + // Punctuation token types. + bracketL: new TokenType("[", { beforeExpr: beforeExpr, startsExpr: startsExpr }), + bracketR: new TokenType("]"), + braceL: new TokenType("{", { beforeExpr: beforeExpr, startsExpr: startsExpr }), + braceBarL: new TokenType("{|", { beforeExpr: beforeExpr, startsExpr: startsExpr }), + braceR: new TokenType("}"), + braceBarR: new TokenType("|}"), + parenL: new TokenType("(", { beforeExpr: beforeExpr, startsExpr: startsExpr }), + parenR: new TokenType(")"), + comma: new TokenType(",", { beforeExpr: beforeExpr }), + semi: new TokenType(";", { beforeExpr: beforeExpr }), + colon: new TokenType(":", { beforeExpr: beforeExpr }), + doubleColon: new TokenType("::", { beforeExpr: beforeExpr }), + dot: new TokenType("."), + question: new TokenType("?", { beforeExpr: beforeExpr }), + arrow: new TokenType("=>", { beforeExpr: beforeExpr }), + template: new TokenType("template"), + ellipsis: new TokenType("...", { beforeExpr: beforeExpr }), + backQuote: new TokenType("`", { startsExpr: startsExpr }), + dollarBraceL: new TokenType("${", { beforeExpr: beforeExpr, startsExpr: startsExpr }), + at: new TokenType("@"), + + // Operators. These carry several kinds of properties to help the + // parser use them properly (the presence of these properties is + // what categorizes them as operators). + // + // `binop`, when present, specifies that this operator is a binary + // operator, and will refer to its precedence. + // + // `prefix` and `postfix` mark the operator as a prefix or postfix + // unary operator. + // + // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as + // binary operators with a very low precedence, that should result + // in AssignmentExpression nodes. + + eq: new TokenType("=", { beforeExpr: beforeExpr, isAssign: isAssign }), + assign: new TokenType("_=", { beforeExpr: beforeExpr, isAssign: isAssign }), + incDec: new TokenType("++/--", { prefix: prefix, postfix: postfix, startsExpr: startsExpr }), + prefix: new TokenType("prefix", { beforeExpr: beforeExpr, prefix: prefix, startsExpr: startsExpr }), + logicalOR: new BinopTokenType("||", 1), + logicalAND: new BinopTokenType("&&", 2), + bitwiseOR: new BinopTokenType("|", 3), + bitwiseXOR: new BinopTokenType("^", 4), + bitwiseAND: new BinopTokenType("&", 5), + equality: new BinopTokenType("==/!=", 6), + relational: new BinopTokenType("", 7), + bitShift: new BinopTokenType("<>", 8), + plusMin: new TokenType("+/-", { beforeExpr: beforeExpr, binop: 9, prefix: prefix, startsExpr: startsExpr }), + modulo: new BinopTokenType("%", 10), + star: new BinopTokenType("*", 10), + slash: new BinopTokenType("/", 10), + exponent: new TokenType("**", { beforeExpr: beforeExpr, binop: 11, rightAssociative: true }) + }; + + var keywords = { + "break": new KeywordTokenType("break"), + "case": new KeywordTokenType("case", { beforeExpr: beforeExpr }), + "catch": new KeywordTokenType("catch"), + "continue": new KeywordTokenType("continue"), + "debugger": new KeywordTokenType("debugger"), + "default": new KeywordTokenType("default", { beforeExpr: beforeExpr }), + "do": new KeywordTokenType("do", { isLoop: isLoop, beforeExpr: beforeExpr }), + "else": new KeywordTokenType("else", { beforeExpr: beforeExpr }), + "finally": new KeywordTokenType("finally"), + "for": new KeywordTokenType("for", { isLoop: isLoop }), + "function": new KeywordTokenType("function", { startsExpr: startsExpr }), + "if": new KeywordTokenType("if"), + "return": new KeywordTokenType("return", { beforeExpr: beforeExpr }), + "switch": new KeywordTokenType("switch"), + "throw": new KeywordTokenType("throw", { beforeExpr: beforeExpr }), + "try": new KeywordTokenType("try"), + "var": new KeywordTokenType("var"), + "let": new KeywordTokenType("let"), + "const": new KeywordTokenType("const"), + "while": new KeywordTokenType("while", { isLoop: isLoop }), + "with": new KeywordTokenType("with"), + "new": new KeywordTokenType("new", { beforeExpr: beforeExpr, startsExpr: startsExpr }), + "this": new KeywordTokenType("this", { startsExpr: startsExpr }), + "super": new KeywordTokenType("super", { startsExpr: startsExpr }), + "class": new KeywordTokenType("class"), + "extends": new KeywordTokenType("extends", { beforeExpr: beforeExpr }), + "export": new KeywordTokenType("export"), + "import": new KeywordTokenType("import", { startsExpr: startsExpr }), + "yield": new KeywordTokenType("yield", { beforeExpr: beforeExpr, startsExpr: startsExpr }), + "null": new KeywordTokenType("null", { startsExpr: startsExpr }), + "true": new KeywordTokenType("true", { startsExpr: startsExpr }), + "false": new KeywordTokenType("false", { startsExpr: startsExpr }), + "in": new KeywordTokenType("in", { beforeExpr: beforeExpr, binop: 7 }), + "instanceof": new KeywordTokenType("instanceof", { beforeExpr: beforeExpr, binop: 7 }), + "typeof": new KeywordTokenType("typeof", { beforeExpr: beforeExpr, prefix: prefix, startsExpr: startsExpr }), + "void": new KeywordTokenType("void", { beforeExpr: beforeExpr, prefix: prefix, startsExpr: startsExpr }), + "delete": new KeywordTokenType("delete", { beforeExpr: beforeExpr, prefix: prefix, startsExpr: startsExpr }) + }; + + // Map keyword names to token types. + Object.keys(keywords).forEach(function (name) { + types["_" + name] = keywords[name]; + }); + + // Matches a whole line break (where CRLF is considered a single + // line break). Used to count lines. + + var lineBreak = /\r\n?|\n|\u2028|\u2029/; + var lineBreakG = new RegExp(lineBreak.source, "g"); + + function isNewLine(code) { + return code === 10 || code === 13 || code === 0x2028 || code === 0x2029; + } + + var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/; + + // The algorithm used to determine whether a regexp can appear at a + // given point in the program is loosely based on sweet.js' approach. + // See https://github.com/mozilla/sweet.js/wiki/design + + var TokContext = function TokContext(token, isExpr, preserveSpace, override) { + classCallCheck(this, TokContext); + + this.token = token; + this.isExpr = !!isExpr; + this.preserveSpace = !!preserveSpace; + this.override = override; + }; + + var types$1 = { + braceStatement: new TokContext("{", false), + braceExpression: new TokContext("{", true), + templateQuasi: new TokContext("${", true), + parenStatement: new TokContext("(", false), + parenExpression: new TokContext("(", true), + template: new TokContext("`", true, true, function (p) { + return p.readTmplToken(); + }), + functionExpression: new TokContext("function", true) + }; + + // Token-specific context update code + + types.parenR.updateContext = types.braceR.updateContext = function () { + if (this.state.context.length === 1) { + this.state.exprAllowed = true; + return; + } + + var out = this.state.context.pop(); + if (out === types$1.braceStatement && this.curContext() === types$1.functionExpression) { + this.state.context.pop(); + this.state.exprAllowed = false; + } else if (out === types$1.templateQuasi) { + this.state.exprAllowed = true; + } else { + this.state.exprAllowed = !out.isExpr; + } + }; + + types.name.updateContext = function (prevType) { + this.state.exprAllowed = false; + + if (prevType === types._let || prevType === types._const || prevType === types._var) { + if (lineBreak.test(this.input.slice(this.state.end))) { + this.state.exprAllowed = true; + } + } + }; + + types.braceL.updateContext = function (prevType) { + this.state.context.push(this.braceIsBlock(prevType) ? types$1.braceStatement : types$1.braceExpression); + this.state.exprAllowed = true; + }; + + types.dollarBraceL.updateContext = function () { + this.state.context.push(types$1.templateQuasi); + this.state.exprAllowed = true; + }; + + types.parenL.updateContext = function (prevType) { + var statementParens = prevType === types._if || prevType === types._for || prevType === types._with || prevType === types._while; + this.state.context.push(statementParens ? types$1.parenStatement : types$1.parenExpression); + this.state.exprAllowed = true; + }; + + types.incDec.updateContext = function () { + // tokExprAllowed stays unchanged + }; + + types._function.updateContext = function () { + if (this.curContext() !== types$1.braceStatement) { + this.state.context.push(types$1.functionExpression); + } + + this.state.exprAllowed = false; + }; + + types.backQuote.updateContext = function () { + if (this.curContext() === types$1.template) { + this.state.context.pop(); + } else { + this.state.context.push(types$1.template); + } + this.state.exprAllowed = false; + }; + + // These are used when `options.locations` is on, for the + // `startLoc` and `endLoc` properties. + + var Position = function Position(line, col) { + classCallCheck(this, Position); + + this.line = line; + this.column = col; + }; + + var SourceLocation = function SourceLocation(start, end) { + classCallCheck(this, SourceLocation); + + this.start = start; + this.end = end; + }; + + // The `getLineInfo` function is mostly useful when the + // `locations` option is off (for performance reasons) and you + // want to find the line/column position for a given character + // offset. `input` should be the code string that the offset refers + // into. + + function getLineInfo(input, offset) { + for (var line = 1, cur = 0;;) { + lineBreakG.lastIndex = cur; + var match = lineBreakG.exec(input); + if (match && match.index < offset) { + ++line; + cur = match.index + match[0].length; + } else { + return new Position(line, offset - cur); + } + } + } + + var State = function () { + function State() { + classCallCheck(this, State); + } + + State.prototype.init = function init(options, input) { + this.strict = options.strictMode === false ? false : options.sourceType === "module"; + + this.input = input; + + this.potentialArrowAt = -1; + + this.inMethod = this.inFunction = this.inGenerator = this.inAsync = this.inPropertyName = this.inType = this.inClassProperty = this.noAnonFunctionType = false; + + this.labels = []; + + this.decorators = []; + + this.tokens = []; + + this.comments = []; + + this.trailingComments = []; + this.leadingComments = []; + this.commentStack = []; + + this.pos = this.lineStart = 0; + this.curLine = options.startLine; + + this.type = types.eof; + this.value = null; + this.start = this.end = this.pos; + this.startLoc = this.endLoc = this.curPosition(); + + this.lastTokEndLoc = this.lastTokStartLoc = null; + this.lastTokStart = this.lastTokEnd = this.pos; + + this.context = [types$1.braceStatement]; + this.exprAllowed = true; + + this.containsEsc = this.containsOctal = false; + this.octalPosition = null; + + this.invalidTemplateEscapePosition = null; + + this.exportedIdentifiers = []; + + return this; + }; + + // TODO + + + // TODO + + + // Used to signify the start of a potential arrow function + + + // Flags to track whether we are in a function, a generator. + + + // Labels in scope. + + + // Leading decorators. + + + // Token store. + + + // Comment store. + + + // Comment attachment store + + + // The current position of the tokenizer in the input. + + + // Properties of the current token: + // Its type + + + // For tokens that include more information than their type, the value + + + // Its start and end offset + + + // And, if locations are used, the {line, column} object + // corresponding to those offsets + + + // Position information for the previous token + + + // The context stack is used to superficially track syntactic + // context to predict whether a regular expression is allowed in a + // given position. + + + // Used to signal to callers of `readWord1` whether the word + // contained any escape sequences. This is needed because words with + // escape sequences must not be interpreted as keywords. + + + // TODO + + + // Names of exports store. `default` is stored as a name for both + // `export default foo;` and `export { foo as default };`. + + + State.prototype.curPosition = function curPosition() { + return new Position(this.curLine, this.pos - this.lineStart); + }; + + State.prototype.clone = function clone(skipArrays) { + var state = new State(); + for (var key in this) { + var val = this[key]; + + if ((!skipArrays || key === "context") && Array.isArray(val)) { + val = val.slice(); + } + + state[key] = val; + } + return state; + }; + + return State; + }(); + + // Object type used to represent tokens. Note that normally, tokens + // simply exist as properties on the parser object. This is only + // used for the onToken callback and the external tokenizer. + + var Token = function Token(state) { + classCallCheck(this, Token); + + this.type = state.type; + this.value = state.value; + this.start = state.start; + this.end = state.end; + this.loc = new SourceLocation(state.startLoc, state.endLoc); + }; + + // ## Tokenizer + + function codePointToString(code) { + // UTF-16 Decoding + if (code <= 0xFFFF) { + return String.fromCharCode(code); + } else { + return String.fromCharCode((code - 0x10000 >> 10) + 0xD800, (code - 0x10000 & 1023) + 0xDC00); + } + } + + var Tokenizer = function () { + function Tokenizer(options, input) { + classCallCheck(this, Tokenizer); + + this.state = new State(); + this.state.init(options, input); + } + + // Move to the next token + + Tokenizer.prototype.next = function next() { + if (!this.isLookahead) { + this.state.tokens.push(new Token(this.state)); + } + + this.state.lastTokEnd = this.state.end; + this.state.lastTokStart = this.state.start; + this.state.lastTokEndLoc = this.state.endLoc; + this.state.lastTokStartLoc = this.state.startLoc; + this.nextToken(); + }; + + // TODO + + Tokenizer.prototype.eat = function eat(type) { + if (this.match(type)) { + this.next(); + return true; + } else { + return false; + } + }; + + // TODO + + Tokenizer.prototype.match = function match(type) { + return this.state.type === type; + }; + + // TODO + + Tokenizer.prototype.isKeyword = function isKeyword$$1(word) { + return isKeyword(word); + }; + + // TODO + + Tokenizer.prototype.lookahead = function lookahead() { + var old = this.state; + this.state = old.clone(true); + + this.isLookahead = true; + this.next(); + this.isLookahead = false; + + var curr = this.state.clone(true); + this.state = old; + return curr; + }; + + // Toggle strict mode. Re-reads the next number or string to please + // pedantic tests (`"use strict"; 010;` should fail). + + Tokenizer.prototype.setStrict = function setStrict(strict) { + this.state.strict = strict; + if (!this.match(types.num) && !this.match(types.string)) return; + this.state.pos = this.state.start; + while (this.state.pos < this.state.lineStart) { + this.state.lineStart = this.input.lastIndexOf("\n", this.state.lineStart - 2) + 1; + --this.state.curLine; + } + this.nextToken(); + }; + + Tokenizer.prototype.curContext = function curContext() { + return this.state.context[this.state.context.length - 1]; + }; + + // Read a single token, updating the parser object's token-related + // properties. + + Tokenizer.prototype.nextToken = function nextToken() { + var curContext = this.curContext(); + if (!curContext || !curContext.preserveSpace) this.skipSpace(); + + this.state.containsOctal = false; + this.state.octalPosition = null; + this.state.start = this.state.pos; + this.state.startLoc = this.state.curPosition(); + if (this.state.pos >= this.input.length) return this.finishToken(types.eof); + + if (curContext.override) { + return curContext.override(this); + } else { + return this.readToken(this.fullCharCodeAtPos()); + } + }; + + Tokenizer.prototype.readToken = function readToken(code) { + // Identifier or keyword. '\uXXXX' sequences are allowed in + // identifiers, so '\' also dispatches to that. + if (isIdentifierStart(code) || code === 92 /* '\' */) { + return this.readWord(); + } else { + return this.getTokenFromCode(code); + } + }; + + Tokenizer.prototype.fullCharCodeAtPos = function fullCharCodeAtPos() { + var code = this.input.charCodeAt(this.state.pos); + if (code <= 0xd7ff || code >= 0xe000) return code; + + var next = this.input.charCodeAt(this.state.pos + 1); + return (code << 10) + next - 0x35fdc00; + }; + + Tokenizer.prototype.pushComment = function pushComment(block, text, start, end, startLoc, endLoc) { + var comment = { + type: block ? "CommentBlock" : "CommentLine", + value: text, + start: start, + end: end, + loc: new SourceLocation(startLoc, endLoc) + }; + + if (!this.isLookahead) { + this.state.tokens.push(comment); + this.state.comments.push(comment); + this.addComment(comment); + } + }; + + Tokenizer.prototype.skipBlockComment = function skipBlockComment() { + var startLoc = this.state.curPosition(); + var start = this.state.pos; + var end = this.input.indexOf("*/", this.state.pos += 2); + if (end === -1) this.raise(this.state.pos - 2, "Unterminated comment"); + + this.state.pos = end + 2; + lineBreakG.lastIndex = start; + var match = void 0; + while ((match = lineBreakG.exec(this.input)) && match.index < this.state.pos) { + ++this.state.curLine; + this.state.lineStart = match.index + match[0].length; + } + + this.pushComment(true, this.input.slice(start + 2, end), start, this.state.pos, startLoc, this.state.curPosition()); + }; + + Tokenizer.prototype.skipLineComment = function skipLineComment(startSkip) { + var start = this.state.pos; + var startLoc = this.state.curPosition(); + var ch = this.input.charCodeAt(this.state.pos += startSkip); + while (this.state.pos < this.input.length && ch !== 10 && ch !== 13 && ch !== 8232 && ch !== 8233) { + ++this.state.pos; + ch = this.input.charCodeAt(this.state.pos); + } + + this.pushComment(false, this.input.slice(start + startSkip, this.state.pos), start, this.state.pos, startLoc, this.state.curPosition()); + }; + + // Called at the start of the parse and after every token. Skips + // whitespace and comments, and. + + Tokenizer.prototype.skipSpace = function skipSpace() { + loop: while (this.state.pos < this.input.length) { + var ch = this.input.charCodeAt(this.state.pos); + switch (ch) { + case 32:case 160: + // ' ' + ++this.state.pos; + break; + + case 13: + if (this.input.charCodeAt(this.state.pos + 1) === 10) { + ++this.state.pos; + } + + case 10:case 8232:case 8233: + ++this.state.pos; + ++this.state.curLine; + this.state.lineStart = this.state.pos; + break; + + case 47: + // '/' + switch (this.input.charCodeAt(this.state.pos + 1)) { + case 42: + // '*' + this.skipBlockComment(); + break; + + case 47: + this.skipLineComment(2); + break; + + default: + break loop; + } + break; + + default: + if (ch > 8 && ch < 14 || ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) { + ++this.state.pos; + } else { + break loop; + } + } + } + }; + + // Called at the end of every token. Sets `end`, `val`, and + // maintains `context` and `exprAllowed`, and skips the space after + // the token, so that the next one's `start` will point at the + // right position. + + Tokenizer.prototype.finishToken = function finishToken(type, val) { + this.state.end = this.state.pos; + this.state.endLoc = this.state.curPosition(); + var prevType = this.state.type; + this.state.type = type; + this.state.value = val; + + this.updateContext(prevType); + }; + + // ### Token reading + + // This is the function that is called to fetch the next token. It + // is somewhat obscure, because it works in character codes rather + // than characters, and because operator parsing has been inlined + // into it. + // + // All in the name of speed. + // + + + Tokenizer.prototype.readToken_dot = function readToken_dot() { + var next = this.input.charCodeAt(this.state.pos + 1); + if (next >= 48 && next <= 57) { + return this.readNumber(true); + } + + var next2 = this.input.charCodeAt(this.state.pos + 2); + if (next === 46 && next2 === 46) { + // 46 = dot '.' + this.state.pos += 3; + return this.finishToken(types.ellipsis); + } else { + ++this.state.pos; + return this.finishToken(types.dot); + } + }; + + Tokenizer.prototype.readToken_slash = function readToken_slash() { + // '/' + if (this.state.exprAllowed) { + ++this.state.pos; + return this.readRegexp(); + } + + var next = this.input.charCodeAt(this.state.pos + 1); + if (next === 61) { + return this.finishOp(types.assign, 2); + } else { + return this.finishOp(types.slash, 1); + } + }; + + Tokenizer.prototype.readToken_mult_modulo = function readToken_mult_modulo(code) { + // '%*' + var type = code === 42 ? types.star : types.modulo; + var width = 1; + var next = this.input.charCodeAt(this.state.pos + 1); + + if (next === 42) { + // '*' + width++; + next = this.input.charCodeAt(this.state.pos + 2); + type = types.exponent; + } + + if (next === 61) { + width++; + type = types.assign; + } + + return this.finishOp(type, width); + }; + + Tokenizer.prototype.readToken_pipe_amp = function readToken_pipe_amp(code) { + // '|&' + var next = this.input.charCodeAt(this.state.pos + 1); + if (next === code) return this.finishOp(code === 124 ? types.logicalOR : types.logicalAND, 2); + if (next === 61) return this.finishOp(types.assign, 2); + if (code === 124 && next === 125 && this.hasPlugin("flow")) return this.finishOp(types.braceBarR, 2); + return this.finishOp(code === 124 ? types.bitwiseOR : types.bitwiseAND, 1); + }; + + Tokenizer.prototype.readToken_caret = function readToken_caret() { + // '^' + var next = this.input.charCodeAt(this.state.pos + 1); + if (next === 61) { + return this.finishOp(types.assign, 2); + } else { + return this.finishOp(types.bitwiseXOR, 1); + } + }; + + Tokenizer.prototype.readToken_plus_min = function readToken_plus_min(code) { + // '+-' + var next = this.input.charCodeAt(this.state.pos + 1); + + if (next === code) { + if (next === 45 && this.input.charCodeAt(this.state.pos + 2) === 62 && lineBreak.test(this.input.slice(this.state.lastTokEnd, this.state.pos))) { + // A `-->` line comment + this.skipLineComment(3); + this.skipSpace(); + return this.nextToken(); + } + return this.finishOp(types.incDec, 2); + } + + if (next === 61) { + return this.finishOp(types.assign, 2); + } else { + return this.finishOp(types.plusMin, 1); + } + }; + + Tokenizer.prototype.readToken_lt_gt = function readToken_lt_gt(code) { + // '<>' + var next = this.input.charCodeAt(this.state.pos + 1); + var size = 1; + + if (next === code) { + size = code === 62 && this.input.charCodeAt(this.state.pos + 2) === 62 ? 3 : 2; + if (this.input.charCodeAt(this.state.pos + size) === 61) return this.finishOp(types.assign, size + 1); + return this.finishOp(types.bitShift, size); + } + + if (next === 33 && code === 60 && this.input.charCodeAt(this.state.pos + 2) === 45 && this.input.charCodeAt(this.state.pos + 3) === 45) { + if (this.inModule) this.unexpected(); + // ` regexps + );set = set.map(function (s, si, set) { + return s.map(this.parse, this); + }, this); + + this.debug(this.pattern, set + + // filter out everything that didn't compile properly. + );set = set.filter(function (s) { + return s.indexOf(false) === -1; + }); + + this.debug(this.pattern, set); + + this.set = set; + } + + Minimatch.prototype.parseNegate = parseNegate; + function parseNegate() { + var pattern = this.pattern; + var negate = false; + var options = this.options; + var negateOffset = 0; + + if (options.nonegate) return; + + for (var i = 0, l = pattern.length; i < l && pattern.charAt(i) === '!'; i++) { + negate = !negate; + negateOffset++; + } + + if (negateOffset) this.pattern = pattern.substr(negateOffset); + this.negate = negate; + } + + // Brace expansion: + // a{b,c}d -> abd acd + // a{b,}c -> abc ac + // a{0..3}d -> a0d a1d a2d a3d + // a{b,c{d,e}f}g -> abg acdfg acefg + // a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg + // + // Invalid sets are not expanded. + // a{2..}b -> a{2..}b + // a{b}c -> a{b}c + minimatch.braceExpand = function (pattern, options) { + return braceExpand(pattern, options); + }; + + Minimatch.prototype.braceExpand = braceExpand; + + function braceExpand(pattern, options) { + if (!options) { + if (this instanceof Minimatch) { + options = this.options; + } else { + options = {}; + } + } + + pattern = typeof pattern === 'undefined' ? this.pattern : pattern; + + if (typeof pattern === 'undefined') { + throw new TypeError('undefined pattern'); + } + + if (options.nobrace || !pattern.match(/\{.*\}/)) { + // shortcut. no need to expand. + return [pattern]; + } + + return expand(pattern); + } + + // parse a component of the expanded set. + // At this point, no pattern may contain "/" in it + // so we're going to return a 2d array, where each entry is the full + // pattern, split on '/', and then turned into a regular expression. + // A regexp is made at the end which joins each array with an + // escaped /, and another full one which joins each regexp with |. + // + // Following the lead of Bash 4.1, note that "**" only has special meaning + // when it is the *only* thing in a path portion. Otherwise, any series + // of * is equivalent to a single *. Globstar behavior is enabled by + // default, and can be disabled by setting options.noglobstar. + Minimatch.prototype.parse = parse; + var SUBPARSE = {}; + function parse(pattern, isSub) { + if (pattern.length > 1024 * 64) { + throw new TypeError('pattern is too long'); + } + + var options = this.options; + + // shortcuts + if (!options.noglobstar && pattern === '**') return GLOBSTAR; + if (pattern === '') return ''; + + var re = ''; + var hasMagic = !!options.nocase; + var escaping = false; + // ? => one single character + var patternListStack = []; + var negativeLists = []; + var stateChar; + var inClass = false; + var reClassStart = -1; + var classStart = -1; + // . and .. never match anything that doesn't start with ., + // even when options.dot is set. + var patternStart = pattern.charAt(0) === '.' ? '' // anything + // not (start or / followed by . or .. followed by / or end) + : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' : '(?!\\.)'; + var self = this; + + function clearStateChar() { + if (stateChar) { + // we had some state-tracking character + // that wasn't consumed by this pass. + switch (stateChar) { + case '*': + re += star; + hasMagic = true; + break; + case '?': + re += qmark; + hasMagic = true; + break; + default: + re += '\\' + stateChar; + break; + } + self.debug('clearStateChar %j %j', stateChar, re); + stateChar = false; + } + } + + for (var i = 0, len = pattern.length, c; i < len && (c = pattern.charAt(i)); i++) { + this.debug('%s\t%s %s %j', pattern, i, re, c + + // skip over any that are escaped. + );if (escaping && reSpecials[c]) { + re += '\\' + c; + escaping = false; + continue; + } + + switch (c) { + case '/': + // completely not allowed, even escaped. + // Should already be path-split by now. + return false; + + case '\\': + clearStateChar(); + escaping = true; + continue; + + // the various stateChar values + // for the "extglob" stuff. + case '?': + case '*': + case '+': + case '@': + case '!': + this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c + + // all of those are literals inside a class, except that + // the glob [!a] means [^a] in regexp + );if (inClass) { + this.debug(' in class'); + if (c === '!' && i === classStart + 1) c = '^'; + re += c; + continue; + } + + // if we already have a stateChar, then it means + // that there was something like ** or +? in there. + // Handle the stateChar, then proceed with this one. + self.debug('call clearStateChar %j', stateChar); + clearStateChar(); + stateChar = c; + // if extglob is disabled, then +(asdf|foo) isn't a thing. + // just clear the statechar *now*, rather than even diving into + // the patternList stuff. + if (options.noext) clearStateChar(); + continue; + + case '(': + if (inClass) { + re += '('; + continue; + } + + if (!stateChar) { + re += '\\('; + continue; + } + + patternListStack.push({ + type: stateChar, + start: i - 1, + reStart: re.length, + open: plTypes[stateChar].open, + close: plTypes[stateChar].close + } + // negation is (?:(?!js)[^/]*) + );re += stateChar === '!' ? '(?:(?!(?:' : '(?:'; + this.debug('plType %j %j', stateChar, re); + stateChar = false; + continue; + + case ')': + if (inClass || !patternListStack.length) { + re += '\\)'; + continue; + } + + clearStateChar(); + hasMagic = true; + var pl = patternListStack.pop + // negation is (?:(?!js)[^/]*) + // The others are (?:) + ();re += pl.close; + if (pl.type === '!') { + negativeLists.push(pl); + } + pl.reEnd = re.length; + continue; + + case '|': + if (inClass || !patternListStack.length || escaping) { + re += '\\|'; + escaping = false; + continue; + } + + clearStateChar(); + re += '|'; + continue; + + // these are mostly the same in regexp and glob + case '[': + // swallow any state-tracking char before the [ + clearStateChar(); + + if (inClass) { + re += '\\' + c; + continue; + } + + inClass = true; + classStart = i; + reClassStart = re.length; + re += c; + continue; + + case ']': + // a right bracket shall lose its special + // meaning and represent itself in + // a bracket expression if it occurs + // first in the list. -- POSIX.2 2.8.3.2 + if (i === classStart + 1 || !inClass) { + re += '\\' + c; + escaping = false; + continue; + } + + // handle the case where we left a class open. + // "[z-a]" is valid, equivalent to "\[z-a\]" + if (inClass) { + // split where the last [ was, make sure we don't have + // an invalid re. if so, re-walk the contents of the + // would-be class to re-translate any characters that + // were passed through as-is + // TODO: It would probably be faster to determine this + // without a try/catch and a new RegExp, but it's tricky + // to do safely. For now, this is safe and works. + var cs = pattern.substring(classStart + 1, i); + try { + RegExp('[' + cs + ']'); + } catch (er) { + // not a valid class! + var sp = this.parse(cs, SUBPARSE); + re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'; + hasMagic = hasMagic || sp[1]; + inClass = false; + continue; + } + } + + // finish up the class. + hasMagic = true; + inClass = false; + re += c; + continue; + + default: + // swallow any state char that wasn't consumed + clearStateChar(); + + if (escaping) { + // no need + escaping = false; + } else if (reSpecials[c] && !(c === '^' && inClass)) { + re += '\\'; + } + + re += c; + + } // switch + } // for + + // handle the case where we left a class open. + // "[abc" is valid, equivalent to "\[abc" + if (inClass) { + // split where the last [ was, and escape it + // this is a huge pita. We now have to re-walk + // the contents of the would-be class to re-translate + // any characters that were passed through as-is + cs = pattern.substr(classStart + 1); + sp = this.parse(cs, SUBPARSE); + re = re.substr(0, reClassStart) + '\\[' + sp[0]; + hasMagic = hasMagic || sp[1]; + } + + // handle the case where we had a +( thing at the *end* + // of the pattern. + // each pattern list stack adds 3 chars, and we need to go through + // and escape any | chars that were passed through as-is for the regexp. + // Go through and escape them, taking care not to double-escape any + // | chars that were already escaped. + for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) { + var tail = re.slice(pl.reStart + pl.open.length); + this.debug('setting tail', re, pl + // maybe some even number of \, then maybe 1 \, followed by a | + );tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) { + if (!$2) { + // the | isn't already escaped, so escape it. + $2 = '\\'; + } + + // need to escape all those slashes *again*, without escaping the + // one that we need for escaping the | character. As it works out, + // escaping an even number of slashes can be done by simply repeating + // it exactly after itself. That's why this trick works. + // + // I am sorry that you have to see this. + return $1 + $1 + $2 + '|'; + }); + + this.debug('tail=%j\n %s', tail, tail, pl, re); + var t = pl.type === '*' ? star : pl.type === '?' ? qmark : '\\' + pl.type; + + hasMagic = true; + re = re.slice(0, pl.reStart) + t + '\\(' + tail; + } + + // handle trailing things that only matter at the very end. + clearStateChar(); + if (escaping) { + // trailing \\ + re += '\\\\'; + } + + // only need to apply the nodot start if the re starts with + // something that could conceivably capture a dot + var addPatternStart = false; + switch (re.charAt(0)) { + case '.': + case '[': + case '(': + addPatternStart = true; + } + + // Hack to work around lack of negative lookbehind in JS + // A pattern like: *.!(x).!(y|z) needs to ensure that a name + // like 'a.xyz.yz' doesn't match. So, the first negative + // lookahead, has to look ALL the way ahead, to the end of + // the pattern. + for (var n = negativeLists.length - 1; n > -1; n--) { + var nl = negativeLists[n]; + + var nlBefore = re.slice(0, nl.reStart); + var nlFirst = re.slice(nl.reStart, nl.reEnd - 8); + var nlLast = re.slice(nl.reEnd - 8, nl.reEnd); + var nlAfter = re.slice(nl.reEnd); + + nlLast += nlAfter; + + // Handle nested stuff like *(*.js|!(*.json)), where open parens + // mean that we should *not* include the ) in the bit that is considered + // "after" the negated section. + var openParensBefore = nlBefore.split('(').length - 1; + var cleanAfter = nlAfter; + for (i = 0; i < openParensBefore; i++) { + cleanAfter = cleanAfter.replace(/\)[+*?]?/, ''); + } + nlAfter = cleanAfter; + + var dollar = ''; + if (nlAfter === '' && isSub !== SUBPARSE) { + dollar = '$'; + } + var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast; + re = newRe; + } + + // if the re is not "" at this point, then we need to make sure + // it doesn't match against an empty path part. + // Otherwise a/* will match a/, which it should not. + if (re !== '' && hasMagic) { + re = '(?=.)' + re; + } + + if (addPatternStart) { + re = patternStart + re; + } + + // parsing just a piece of a larger pattern. + if (isSub === SUBPARSE) { + return [re, hasMagic]; + } + + // skip the regexp for non-magical patterns + // unescape anything in it, though, so that it'll be + // an exact match against a file etc. + if (!hasMagic) { + return globUnescape(pattern); + } + + var flags = options.nocase ? 'i' : ''; + try { + var regExp = new RegExp('^' + re + '$', flags); + } catch (er) { + // If it was an invalid regular expression, then it can't match + // anything. This trick looks for a character after the end of + // the string, which is of course impossible, except in multi-line + // mode, but it's not a /m regex. + return new RegExp('$.'); + } + + regExp._glob = pattern; + regExp._src = re; + + return regExp; + } + + minimatch.makeRe = function (pattern, options) { + return new Minimatch(pattern, options || {}).makeRe(); + }; + + Minimatch.prototype.makeRe = makeRe; + function makeRe() { + if (this.regexp || this.regexp === false) return this.regexp; + + // at this point, this.set is a 2d array of partial + // pattern strings, or "**". + // + // It's better to use .match(). This function shouldn't + // be used, really, but it's pretty convenient sometimes, + // when you just want to work with a regex. + var set = this.set; + + if (!set.length) { + this.regexp = false; + return this.regexp; + } + var options = this.options; + + var twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot; + var flags = options.nocase ? 'i' : ''; + + var re = set.map(function (pattern) { + return pattern.map(function (p) { + return p === GLOBSTAR ? twoStar : typeof p === 'string' ? regExpEscape(p) : p._src; + }).join('\\\/'); + }).join('|' + + // must match entire pattern + // ending in a * or ** will make it less strict. + );re = '^(?:' + re + ')$'; + + // can match anything, as long as it's not this. + if (this.negate) re = '^(?!' + re + ').*$'; + + try { + this.regexp = new RegExp(re, flags); + } catch (ex) { + this.regexp = false; + } + return this.regexp; + } + + minimatch.match = function (list, pattern, options) { + options = options || {}; + var mm = new Minimatch(pattern, options); + list = list.filter(function (f) { + return mm.match(f); + }); + if (mm.options.nonull && !list.length) { + list.push(pattern); + } + return list; + }; + + Minimatch.prototype.match = match; + function match(f, partial) { + this.debug('match', f, this.pattern + // short-circuit in the case of busted things. + // comments, etc. + );if (this.comment) return false; + if (this.empty) return f === ''; + + if (f === '/' && partial) return true; + + var options = this.options; + + // windows: need to use /, not \ + if (path.sep !== '/') { + f = f.split(path.sep).join('/'); + } + + // treat the test path as a set of pathparts. + f = f.split(slashSplit); + this.debug(this.pattern, 'split', f + + // just ONE of the pattern sets in this.set needs to match + // in order for it to be valid. If negating, then just one + // match means that we have failed. + // Either way, return on the first hit. + + );var set = this.set; + this.debug(this.pattern, 'set', set + + // Find the basename of the path by looking for the last non-empty segment + );var filename; + var i; + for (i = f.length - 1; i >= 0; i--) { + filename = f[i]; + if (filename) break; + } + + for (i = 0; i < set.length; i++) { + var pattern = set[i]; + var file = f; + if (options.matchBase && pattern.length === 1) { + file = [filename]; + } + var hit = this.matchOne(file, pattern, partial); + if (hit) { + if (options.flipNegate) return true; + return !this.negate; + } + } + + // didn't get any hits. this is success if it's a negative + // pattern, failure otherwise. + if (options.flipNegate) return false; + return this.negate; + } + + // set partial to true to test if, for example, + // "/a/b" matches the start of "/*/b/*/d" + // Partial means, if you run out of file before you run + // out of pattern, then that's fine, as long as all + // the parts match. + Minimatch.prototype.matchOne = function (file, pattern, partial) { + var options = this.options; + + this.debug('matchOne', { 'this': this, file: file, pattern: pattern }); + + this.debug('matchOne', file.length, pattern.length); + + for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) { + this.debug('matchOne loop'); + var p = pattern[pi]; + var f = file[fi]; + + this.debug(pattern, p, f + + // should be impossible. + // some invalid regexp stuff in the set. + );if (p === false) return false; + + if (p === GLOBSTAR) { + this.debug('GLOBSTAR', [pattern, p, f] + + // "**" + // a/**/b/**/c would match the following: + // a/b/x/y/z/c + // a/x/y/z/b/c + // a/b/x/b/x/c + // a/b/c + // To do this, take the rest of the pattern after + // the **, and see if it would match the file remainder. + // If so, return success. + // If not, the ** "swallows" a segment, and try again. + // This is recursively awful. + // + // a/**/b/**/c matching a/b/x/y/z/c + // - a matches a + // - doublestar + // - matchOne(b/x/y/z/c, b/**/c) + // - b matches b + // - doublestar + // - matchOne(x/y/z/c, c) -> no + // - matchOne(y/z/c, c) -> no + // - matchOne(z/c, c) -> no + // - matchOne(c, c) yes, hit + );var fr = fi; + var pr = pi + 1; + if (pr === pl) { + this.debug('** at the end' + // a ** at the end will just swallow the rest. + // We have found a match. + // however, it will not swallow /.x, unless + // options.dot is set. + // . and .. are *never* matched by **, for explosively + // exponential reasons. + );for (; fi < fl; fi++) { + if (file[fi] === '.' || file[fi] === '..' || !options.dot && file[fi].charAt(0) === '.') return false; + } + return true; + } + + // ok, let's see if we can swallow whatever we can. + while (fr < fl) { + var swallowee = file[fr]; + + this.debug('\nglobstar while', file, fr, pattern, pr, swallowee + + // XXX remove this slice. Just pass the start index. + );if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) { + this.debug('globstar found match!', fr, fl, swallowee + // found a match. + );return true; + } else { + // can't swallow "." or ".." ever. + // can only swallow ".foo" when explicitly asked. + if (swallowee === '.' || swallowee === '..' || !options.dot && swallowee.charAt(0) === '.') { + this.debug('dot detected!', file, fr, pattern, pr); + break; + } + + // ** swallows a segment, and continue. + this.debug('globstar swallow a segment, and continue'); + fr++; + } + } + + // no match was found. + // However, in partial mode, we can't say this is necessarily over. + // If there's more *pattern* left, then + if (partial) { + // ran out of file + this.debug('\n>>> no match, partial?', file, fr, pattern, pr); + if (fr === fl) return true; + } + return false; + } + + // something other than ** + // non-magic patterns just have to match exactly + // patterns with magic have been turned into regexps. + var hit; + if (typeof p === 'string') { + if (options.nocase) { + hit = f.toLowerCase() === p.toLowerCase(); + } else { + hit = f === p; + } + this.debug('string match', p, f, hit); + } else { + hit = f.match(p); + this.debug('pattern match', p, f, hit); + } + + if (!hit) return false; + } + + // Note: ending in / means that we'll get a final "" + // at the end of the pattern. This can only match a + // corresponding "" at the end of the file. + // If the file ends in /, then it can only match a + // a pattern that ends in /, unless the pattern just + // doesn't have any more for it. But, a/b/ should *not* + // match "a/b/*", even though "" matches against the + // [^/]*? pattern, except in partial mode, where it might + // simply not be reached yet. + // However, a/b/ should still satisfy a/* + + // now either we fell off the end of the pattern, or we're done. + if (fi === fl && pi === pl) { + // ran out of pattern and filename at the same time. + // an exact hit! + return true; + } else if (fi === fl) { + // ran out of file, but still had pattern left. + // this is ok if we're doing the match as part of + // a glob fs traversal. + return partial; + } else if (pi === pl) { + // ran out of pattern, still have file left. + // this is only acceptable if we're on the very last + // empty segment of a file with a trailing slash. + // a/* should match a/b/ + var emptyFileEnd = fi === fl - 1 && file[fi] === ''; + return emptyFileEnd; + } + + // should be unreachable. + throw new Error('wtf?'); + }; + + // replace stuff like \* with * + function globUnescape(s) { + return s.replace(/\\(.)/g, '$1'); + } + + function regExpEscape(s) { + return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); + } + +/***/ }), +/* 593 */ +/***/ (function(module, exports) { + + 'use strict'; + + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + + /** + * Helpers. + */ + + var s = 1000; + var m = s * 60; + var h = m * 60; + var d = h * 24; + var y = d * 365.25; + + /** + * Parse or format the given `val`. + * + * Options: + * + * - `long` verbose formatting [false] + * + * @param {String|Number} val + * @param {Object} [options] + * @throws {Error} throw an error if val is not a non-empty string or a number + * @return {String|Number} + * @api public + */ + + module.exports = function (val, options) { + options = options || {}; + var type = typeof val === 'undefined' ? 'undefined' : _typeof(val); + if (type === 'string' && val.length > 0) { + return parse(val); + } else if (type === 'number' && isNaN(val) === false) { + return options.long ? fmtLong(val) : fmtShort(val); + } + throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val)); + }; + + /** + * Parse the given `str` and return milliseconds. + * + * @param {String} str + * @return {Number} + * @api private + */ + + function parse(str) { + str = String(str); + if (str.length > 100) { + return; + } + var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str); + if (!match) { + return; + } + var n = parseFloat(match[1]); + var type = (match[2] || 'ms').toLowerCase(); + switch (type) { + case 'years': + case 'year': + case 'yrs': + case 'yr': + case 'y': + return n * y; + case 'days': + case 'day': + case 'd': + return n * d; + case 'hours': + case 'hour': + case 'hrs': + case 'hr': + case 'h': + return n * h; + case 'minutes': + case 'minute': + case 'mins': + case 'min': + case 'm': + return n * m; + case 'seconds': + case 'second': + case 'secs': + case 'sec': + case 's': + return n * s; + case 'milliseconds': + case 'millisecond': + case 'msecs': + case 'msec': + case 'ms': + return n; + default: + return undefined; + } + } + + /** + * Short format for `ms`. + * + * @param {Number} ms + * @return {String} + * @api private + */ + + function fmtShort(ms) { + if (ms >= d) { + return Math.round(ms / d) + 'd'; + } + if (ms >= h) { + return Math.round(ms / h) + 'h'; + } + if (ms >= m) { + return Math.round(ms / m) + 'm'; + } + if (ms >= s) { + return Math.round(ms / s) + 's'; + } + return ms + 'ms'; + } + + /** + * Long format for `ms`. + * + * @param {Number} ms + * @return {String} + * @api private + */ + + function fmtLong(ms) { + return plural(ms, d, 'day') || plural(ms, h, 'hour') || plural(ms, m, 'minute') || plural(ms, s, 'second') || ms + ' ms'; + } + + /** + * Pluralization helper. + */ + + function plural(ms, n, name) { + if (ms < n) { + return; + } + if (ms < n * 1.5) { + return Math.floor(ms / n) + ' ' + name; + } + return Math.ceil(ms / n) + ' ' + name + 's'; + } + +/***/ }), +/* 594 */ +/***/ (function(module, exports) { + + 'use strict'; + + module.exports = Number.isNaN || function (x) { + return x !== x; + }; + +/***/ }), +/* 595 */ +/***/ (function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(process) {'use strict'; + + function posix(path) { + return path.charAt(0) === '/'; + } + + function win32(path) { + // https://github.com/nodejs/node/blob/b3fcc245fb25539909ef1d5eaa01dbf92e168633/lib/path.js#L56 + var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/; + var result = splitDeviceRe.exec(path); + var device = result[1] || ''; + var isUnc = Boolean(device && device.charAt(1) !== ':'); + + // UNC paths are always absolute + return Boolean(result[2] || isUnc); + } + + module.exports = process.platform === 'win32' ? win32 : posix; + module.exports.posix = posix; + module.exports.win32 = win32; + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8))) + +/***/ }), +/* 596 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _keys = __webpack_require__(13); + + var _keys2 = _interopRequireDefault(_keys); + + var _babelTypes = __webpack_require__(1); + + var t = _interopRequireWildcard(_babelTypes); + + function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } else { + var newObj = {};if (obj != null) { + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; + } + }newObj.default = obj;return newObj; + } + } + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + var hasOwn = Object.prototype.hasOwnProperty; + + // The hoist function takes a FunctionExpression or FunctionDeclaration + // and replaces any Declaration nodes in its body with assignments, then + // returns a VariableDeclaration containing just the names of the removed + // declarations. + /** + * Copyright (c) 2014, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * https://raw.github.com/facebook/regenerator/master/LICENSE file. An + * additional grant of patent rights can be found in the PATENTS file in + * the same directory. + */ + + exports.hoist = function (funPath) { + t.assertFunction(funPath.node); + + var vars = {}; + + function varDeclToExpr(vdec, includeIdentifiers) { + t.assertVariableDeclaration(vdec); + // TODO assert.equal(vdec.kind, "var"); + var exprs = []; + + vdec.declarations.forEach(function (dec) { + // Note: We duplicate 'dec.id' here to ensure that the variable declaration IDs don't + // have the same 'loc' value, since that can make sourcemaps and retainLines behave poorly. + vars[dec.id.name] = t.identifier(dec.id.name); + + if (dec.init) { + exprs.push(t.assignmentExpression("=", dec.id, dec.init)); + } else if (includeIdentifiers) { + exprs.push(dec.id); + } + }); + + if (exprs.length === 0) return null; + + if (exprs.length === 1) return exprs[0]; + + return t.sequenceExpression(exprs); + } + + funPath.get("body").traverse({ + VariableDeclaration: { + exit: function exit(path) { + var expr = varDeclToExpr(path.node, false); + if (expr === null) { + path.remove(); + } else { + // We don't need to traverse this expression any further because + // there can't be any new declarations inside an expression. + path.replaceWith(t.expressionStatement(expr)); + } + + // Since the original node has been either removed or replaced, + // avoid traversing it any further. + path.skip(); + } + }, + + ForStatement: function ForStatement(path) { + var init = path.node.init; + if (t.isVariableDeclaration(init)) { + path.get("init").replaceWith(varDeclToExpr(init, false)); + } + }, + + ForXStatement: function ForXStatement(path) { + var left = path.get("left"); + if (left.isVariableDeclaration()) { + left.replaceWith(varDeclToExpr(left.node, true)); + } + }, + + FunctionDeclaration: function FunctionDeclaration(path) { + var node = path.node; + vars[node.id.name] = node.id; + + var assignment = t.expressionStatement(t.assignmentExpression("=", node.id, t.functionExpression(node.id, node.params, node.body, node.generator, node.expression))); + + if (path.parentPath.isBlockStatement()) { + // Insert the assignment form before the first statement in the + // enclosing block. + path.parentPath.unshiftContainer("body", assignment); + + // Remove the function declaration now that we've inserted the + // equivalent assignment form at the beginning of the block. + path.remove(); + } else { + // If the parent node is not a block statement, then we can just + // replace the declaration with the equivalent assignment form + // without worrying about hoisting it. + path.replaceWith(assignment); + } + + // Don't hoist variables out of inner functions. + path.skip(); + }, + + FunctionExpression: function FunctionExpression(path) { + // Don't descend into nested function expressions. + path.skip(); + } + }); + + var paramNames = {}; + funPath.get("params").forEach(function (paramPath) { + var param = paramPath.node; + if (t.isIdentifier(param)) { + paramNames[param.name] = param; + } else { + // Variables declared by destructuring parameter patterns will be + // harmlessly re-declared. + } + }); + + var declarations = []; + + (0, _keys2.default)(vars).forEach(function (name) { + if (!hasOwn.call(paramNames, name)) { + declarations.push(t.variableDeclarator(vars[name], null)); + } + }); + + if (declarations.length === 0) { + return null; // Be sure to handle this case! + } + + return t.variableDeclaration("var", declarations); + }; + +/***/ }), +/* 597 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + exports.__esModule = true; + + exports.default = function () { + return __webpack_require__(601); + }; + +/***/ }), +/* 598 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _assert = __webpack_require__(62); + + var _assert2 = _interopRequireDefault(_assert); + + var _babelTypes = __webpack_require__(1); + + var t = _interopRequireWildcard(_babelTypes); + + var _util = __webpack_require__(116); + + function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } else { + var newObj = {};if (obj != null) { + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; + } + }newObj.default = obj;return newObj; + } + } + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + function Entry() { + _assert2.default.ok(this instanceof Entry); + } /** + * Copyright (c) 2014, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * https://raw.github.com/facebook/regenerator/master/LICENSE file. An + * additional grant of patent rights can be found in the PATENTS file in + * the same directory. + */ + + function FunctionEntry(returnLoc) { + Entry.call(this); + t.assertLiteral(returnLoc); + this.returnLoc = returnLoc; + } + + (0, _util.inherits)(FunctionEntry, Entry); + exports.FunctionEntry = FunctionEntry; + + function LoopEntry(breakLoc, continueLoc, label) { + Entry.call(this); + + t.assertLiteral(breakLoc); + t.assertLiteral(continueLoc); + + if (label) { + t.assertIdentifier(label); + } else { + label = null; + } + + this.breakLoc = breakLoc; + this.continueLoc = continueLoc; + this.label = label; + } + + (0, _util.inherits)(LoopEntry, Entry); + exports.LoopEntry = LoopEntry; + + function SwitchEntry(breakLoc) { + Entry.call(this); + t.assertLiteral(breakLoc); + this.breakLoc = breakLoc; + } + + (0, _util.inherits)(SwitchEntry, Entry); + exports.SwitchEntry = SwitchEntry; + + function TryEntry(firstLoc, catchEntry, finallyEntry) { + Entry.call(this); + + t.assertLiteral(firstLoc); + + if (catchEntry) { + _assert2.default.ok(catchEntry instanceof CatchEntry); + } else { + catchEntry = null; + } + + if (finallyEntry) { + _assert2.default.ok(finallyEntry instanceof FinallyEntry); + } else { + finallyEntry = null; + } + + // Have to have one or the other (or both). + _assert2.default.ok(catchEntry || finallyEntry); + + this.firstLoc = firstLoc; + this.catchEntry = catchEntry; + this.finallyEntry = finallyEntry; + } + + (0, _util.inherits)(TryEntry, Entry); + exports.TryEntry = TryEntry; + + function CatchEntry(firstLoc, paramId) { + Entry.call(this); + + t.assertLiteral(firstLoc); + t.assertIdentifier(paramId); + + this.firstLoc = firstLoc; + this.paramId = paramId; + } + + (0, _util.inherits)(CatchEntry, Entry); + exports.CatchEntry = CatchEntry; + + function FinallyEntry(firstLoc, afterLoc) { + Entry.call(this); + t.assertLiteral(firstLoc); + t.assertLiteral(afterLoc); + this.firstLoc = firstLoc; + this.afterLoc = afterLoc; + } + + (0, _util.inherits)(FinallyEntry, Entry); + exports.FinallyEntry = FinallyEntry; + + function LabeledEntry(breakLoc, label) { + Entry.call(this); + + t.assertLiteral(breakLoc); + t.assertIdentifier(label); + + this.breakLoc = breakLoc; + this.label = label; + } + + (0, _util.inherits)(LabeledEntry, Entry); + exports.LabeledEntry = LabeledEntry; + + function LeapManager(emitter) { + _assert2.default.ok(this instanceof LeapManager); + + var Emitter = __webpack_require__(278).Emitter; + _assert2.default.ok(emitter instanceof Emitter); + + this.emitter = emitter; + this.entryStack = [new FunctionEntry(emitter.finalLoc)]; + } + + var LMp = LeapManager.prototype; + exports.LeapManager = LeapManager; + + LMp.withEntry = function (entry, callback) { + _assert2.default.ok(entry instanceof Entry); + this.entryStack.push(entry); + try { + callback.call(this.emitter); + } finally { + var popped = this.entryStack.pop(); + _assert2.default.strictEqual(popped, entry); + } + }; + + LMp._findLeapLocation = function (property, label) { + for (var i = this.entryStack.length - 1; i >= 0; --i) { + var entry = this.entryStack[i]; + var loc = entry[property]; + if (loc) { + if (label) { + if (entry.label && entry.label.name === label.name) { + return loc; + } + } else if (entry instanceof LabeledEntry) { + // Ignore LabeledEntry entries unless we are actually breaking to + // a label. + } else { + return loc; + } + } + } + + return null; + }; + + LMp.getBreakLoc = function (label) { + return this._findLeapLocation("breakLoc", label); + }; + + LMp.getContinueLoc = function (label) { + return this._findLeapLocation("continueLoc", label); + }; + +/***/ }), +/* 599 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _assert = __webpack_require__(62); + + var _assert2 = _interopRequireDefault(_assert); + + var _babelTypes = __webpack_require__(1); + + var t = _interopRequireWildcard(_babelTypes); + + function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } else { + var newObj = {};if (obj != null) { + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; + } + }newObj.default = obj;return newObj; + } + } + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + var m = __webpack_require__(276).makeAccessor(); /** + * Copyright (c) 2014, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * https://raw.github.com/facebook/regenerator/master/LICENSE file. An + * additional grant of patent rights can be found in the PATENTS file in + * the same directory. + */ + + var hasOwn = Object.prototype.hasOwnProperty; + + function makePredicate(propertyName, knownTypes) { + function onlyChildren(node) { + t.assertNode(node); + + // Assume no side effects until we find out otherwise. + var result = false; + + function check(child) { + if (result) { + // Do nothing. + } else if (Array.isArray(child)) { + child.some(check); + } else if (t.isNode(child)) { + _assert2.default.strictEqual(result, false); + result = predicate(child); + } + return result; + } + + var keys = t.VISITOR_KEYS[node.type]; + if (keys) { + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var child = node[key]; + check(child); + } + } + + return result; + } + + function predicate(node) { + t.assertNode(node); + + var meta = m(node); + if (hasOwn.call(meta, propertyName)) return meta[propertyName]; + + // Certain types are "opaque," which means they have no side + // effects or leaps and we don't care about their subexpressions. + if (hasOwn.call(opaqueTypes, node.type)) return meta[propertyName] = false; + + if (hasOwn.call(knownTypes, node.type)) return meta[propertyName] = true; + + return meta[propertyName] = onlyChildren(node); + } + + predicate.onlyChildren = onlyChildren; + + return predicate; + } + + var opaqueTypes = { + FunctionExpression: true, + ArrowFunctionExpression: true + }; + + // These types potentially have side effects regardless of what side + // effects their subexpressions have. + var sideEffectTypes = { + CallExpression: true, // Anything could happen! + ForInStatement: true, // Modifies the key variable. + UnaryExpression: true, // Think delete. + BinaryExpression: true, // Might invoke .toString() or .valueOf(). + AssignmentExpression: true, // Side-effecting by definition. + UpdateExpression: true, // Updates are essentially assignments. + NewExpression: true // Similar to CallExpression. + }; + + // These types are the direct cause of all leaps in control flow. + var leapTypes = { + YieldExpression: true, + BreakStatement: true, + ContinueStatement: true, + ReturnStatement: true, + ThrowStatement: true + }; + + // All leap types are also side effect types. + for (var type in leapTypes) { + if (hasOwn.call(leapTypes, type)) { + sideEffectTypes[type] = leapTypes[type]; + } + } + + exports.hasSideEffects = makePredicate("hasSideEffects", sideEffectTypes); + exports.containsLeap = makePredicate("containsLeap", leapTypes); + +/***/ }), +/* 600 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + exports.__esModule = true; + exports.default = replaceShorthandObjectMethod; + + var _babelTypes = __webpack_require__(1); + + var t = _interopRequireWildcard(_babelTypes); + + function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } else { + var newObj = {};if (obj != null) { + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; + } + }newObj.default = obj;return newObj; + } + } + + // this function converts a shorthand object generator method into a normal + // (non-shorthand) object property which is a generator function expression. for + // example, this: + // + // var foo = { + // *bar(baz) { return 5; } + // } + // + // should be replaced with: + // + // var foo = { + // bar: function*(baz) { return 5; } + // } + // + // to do this, it clones the parameter array and the body of the object generator + // method into a new FunctionExpression. + // + // this method can be passed any Function AST node path, and it will return + // either: + // a) the path that was passed in (iff the path did not need to be replaced) or + // b) the path of the new FunctionExpression that was created as a replacement + // (iff the path did need to be replaced) + // + // In either case, though, the caller can count on the fact that the return value + // is a Function AST node path. + // + // If this function is called with an AST node path that is not a Function (or with an + // argument that isn't an AST node path), it will throw an error. + function replaceShorthandObjectMethod(path) { + if (!path.node || !t.isFunction(path.node)) { + throw new Error("replaceShorthandObjectMethod can only be called on Function AST node paths."); + } + + // this function only replaces shorthand object methods (called ObjectMethod + // in Babel-speak). + if (!t.isObjectMethod(path.node)) { + return path; + } + + // this function only replaces generators. + if (!path.node.generator) { + return path; + } + + var parameters = path.node.params.map(function (param) { + return t.cloneDeep(param); + }); + + var functionExpression = t.functionExpression(null, // id + parameters, // params + t.cloneDeep(path.node.body), // body + path.node.generator, path.node.async); + + path.replaceWith(t.objectProperty(t.cloneDeep(path.node.key), // key + functionExpression, //value + path.node.computed, // computed + false // shorthand + )); + + // path now refers to the ObjectProperty AST node path, but we want to return a + // Function AST node path for the function expression we created. we know that + // the FunctionExpression we just created is the value of the ObjectProperty, + // so return the "value" path off of this path. + return path.get("value"); + } + +/***/ }), +/* 601 */ +/***/ (function(module, exports, __webpack_require__) { + + "use strict"; + + var _assert = __webpack_require__(62); + + var _assert2 = _interopRequireDefault(_assert); + + var _babelTypes = __webpack_require__(1); + + var t = _interopRequireWildcard(_babelTypes); + + var _hoist = __webpack_require__(596); + + var _emit = __webpack_require__(278); + + var _replaceShorthandObjectMethod = __webpack_require__(600); + + var _replaceShorthandObjectMethod2 = _interopRequireDefault(_replaceShorthandObjectMethod); + + var _util = __webpack_require__(279); + + var util = _interopRequireWildcard(_util); + + function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } else { + var newObj = {};if (obj != null) { + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; + } + }newObj.default = obj;return newObj; + } + } + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; + } + + /** + * Copyright (c) 2014, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * https://raw.github.com/facebook/regenerator/master/LICENSE file. An + * additional grant of patent rights can be found in the PATENTS file in + * the same directory. + */ + + var getMarkInfo = __webpack_require__(276).makeAccessor(); + + exports.visitor = { + Function: { + exit: function exit(path, state) { + var node = path.node; + + if (node.generator) { + if (node.async) { + // Async generator + if (state.opts.asyncGenerators === false) return; + } else { + // Plain generator + if (state.opts.generators === false) return; + } + } else if (node.async) { + // Async function + if (state.opts.async === false) return; + } else { + // Not a generator or async function. + return; + } + + // if this is an ObjectMethod, we need to convert it to an ObjectProperty + path = (0, _replaceShorthandObjectMethod2.default)(path); + node = path.node; + + var contextId = path.scope.generateUidIdentifier("context"); + var argsId = path.scope.generateUidIdentifier("args"); + + path.ensureBlock(); + var bodyBlockPath = path.get("body"); + + if (node.async) { + bodyBlockPath.traverse(awaitVisitor); + } + + bodyBlockPath.traverse(functionSentVisitor, { + context: contextId + }); + + var outerBody = []; + var innerBody = []; + + bodyBlockPath.get("body").forEach(function (childPath) { + var node = childPath.node; + if (t.isExpressionStatement(node) && t.isStringLiteral(node.expression)) { + // Babylon represents directives like "use strict" as elements + // of a bodyBlockPath.node.directives array, but they could just + // as easily be represented (by other parsers) as traditional + // string-literal-valued expression statements, so we need to + // handle that here. (#248) + outerBody.push(node); + } else if (node && node._blockHoist != null) { + outerBody.push(node); + } else { + innerBody.push(node); + } + }); + + if (outerBody.length > 0) { + // Only replace the inner body if we actually hoisted any statements + // to the outer body. + bodyBlockPath.node.body = innerBody; + } + + var outerFnExpr = getOuterFnExpr(path); + // Note that getOuterFnExpr has the side-effect of ensuring that the + // function has a name (so node.id will always be an Identifier), even + // if a temporary name has to be synthesized. + t.assertIdentifier(node.id); + var innerFnId = t.identifier(node.id.name + "$"); + + // Turn all declarations into vars, and replace the original + // declarations with equivalent assignment expressions. + var vars = (0, _hoist.hoist)(path); + + var didRenameArguments = renameArguments(path, argsId); + if (didRenameArguments) { + vars = vars || t.variableDeclaration("var", []); + var argumentIdentifier = t.identifier("arguments"); + // we need to do this as otherwise arguments in arrow functions gets hoisted + argumentIdentifier._shadowedFunctionLiteral = path; + vars.declarations.push(t.variableDeclarator(argsId, argumentIdentifier)); + } + + var emitter = new _emit.Emitter(contextId); + emitter.explode(path.get("body")); + + if (vars && vars.declarations.length > 0) { + outerBody.push(vars); + } + + var wrapArgs = [emitter.getContextFunction(innerFnId), + // Async functions that are not generators don't care about the + // outer function because they don't need it to be marked and don't + // inherit from its .prototype. + node.generator ? outerFnExpr : t.nullLiteral(), t.thisExpression()]; + + var tryLocsList = emitter.getTryLocsList(); + if (tryLocsList) { + wrapArgs.push(tryLocsList); + } + + var wrapCall = t.callExpression(util.runtimeProperty(node.async ? "async" : "wrap"), wrapArgs); + + outerBody.push(t.returnStatement(wrapCall)); + node.body = t.blockStatement(outerBody); + + var oldDirectives = bodyBlockPath.node.directives; + if (oldDirectives) { + // Babylon represents directives like "use strict" as elements of + // a bodyBlockPath.node.directives array. (#248) + node.body.directives = oldDirectives; + } + + var wasGeneratorFunction = node.generator; + if (wasGeneratorFunction) { + node.generator = false; + } + + if (node.async) { + node.async = false; + } + + if (wasGeneratorFunction && t.isExpression(node)) { + path.replaceWith(t.callExpression(util.runtimeProperty("mark"), [node])); + } + + // Generators are processed in 'exit' handlers so that regenerator only has to run on + // an ES5 AST, but that means traversal will not pick up newly inserted references + // to things like 'regeneratorRuntime'. To avoid this, we explicitly requeue. + path.requeue(); + } + } + }; + + // Given a NodePath for a Function, return an Expression node that can be + // used to refer reliably to the function object from inside the function. + // This expression is essentially a replacement for arguments.callee, with + // the key advantage that it works in strict mode. + function getOuterFnExpr(funPath) { + var node = funPath.node; + t.assertFunction(node); + + if (!node.id) { + // Default-exported function declarations, and function expressions may not + // have a name to reference, so we explicitly add one. + node.id = funPath.scope.parent.generateUidIdentifier("callee"); + } + + if (node.generator && // Non-generator functions don't need to be marked. + t.isFunctionDeclaration(node)) { + var pp = funPath.findParent(function (path) { + return path.isProgram() || path.isBlockStatement(); + }); + + if (!pp) { + return node.id; + } + + var markDecl = getRuntimeMarkDecl(pp); + var markedArray = markDecl.declarations[0].id; + var funDeclIdArray = markDecl.declarations[0].init.callee.object; + t.assertArrayExpression(funDeclIdArray); + + var index = funDeclIdArray.elements.length; + funDeclIdArray.elements.push(node.id); + + return t.memberExpression(markedArray, t.numericLiteral(index), true); + } + + return node.id; + } + + function getRuntimeMarkDecl(blockPath) { + var block = blockPath.node; + _assert2.default.ok(Array.isArray(block.body)); + + var info = getMarkInfo(block); + if (info.decl) { + return info.decl; + } + + info.decl = t.variableDeclaration("var", [t.variableDeclarator(blockPath.scope.generateUidIdentifier("marked"), t.callExpression(t.memberExpression(t.arrayExpression([]), t.identifier("map"), false), [util.runtimeProperty("mark")]))]); + + blockPath.unshiftContainer("body", info.decl); + + return info.decl; + } + + function renameArguments(funcPath, argsId) { + var state = { + didRenameArguments: false, + argsId: argsId + }; + + funcPath.traverse(argumentsVisitor, state); + + // If the traversal replaced any arguments references, then we need to + // alias the outer function's arguments binding (be it the implicit + // arguments object or some other parameter or variable) to the variable + // named by argsId. + return state.didRenameArguments; + } + + var argumentsVisitor = { + "FunctionExpression|FunctionDeclaration": function FunctionExpressionFunctionDeclaration(path) { + path.skip(); + }, + + Identifier: function Identifier(path, state) { + if (path.node.name === "arguments" && util.isReference(path)) { + path.replaceWith(state.argsId); + state.didRenameArguments = true; + } + } + }; + + var functionSentVisitor = { + MetaProperty: function MetaProperty(path) { + var node = path.node; + + if (node.meta.name === "function" && node.property.name === "sent") { + path.replaceWith(t.memberExpression(this.context, t.identifier("_sent"))); + } + } + }; + + var awaitVisitor = { + Function: function Function(path) { + path.skip(); // Don't descend into nested function scopes. + }, + + AwaitExpression: function AwaitExpression(path) { + // Convert await expressions to yield expressions. + var argument = path.node.argument; + + // Transforming `await x` to `yield regeneratorRuntime.awrap(x)` + // causes the argument to be wrapped in such a way that the runtime + // can distinguish between awaited and merely yielded values. + path.replaceWith(t.yieldExpression(t.callExpression(util.runtimeProperty("awrap"), [argument]), false)); + } + }; + +/***/ }), +/* 602 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + // Generated by `/scripts/character-class-escape-sets.js`. Do not edit. + var regenerate = __webpack_require__(277); + + exports.REGULAR = { + 'd': regenerate().addRange(0x30, 0x39), + 'D': regenerate().addRange(0x0, 0x2F).addRange(0x3A, 0xFFFF), + 's': regenerate(0x20, 0xA0, 0x1680, 0x202F, 0x205F, 0x3000, 0xFEFF).addRange(0x9, 0xD).addRange(0x2000, 0x200A).addRange(0x2028, 0x2029), + 'S': regenerate().addRange(0x0, 0x8).addRange(0xE, 0x1F).addRange(0x21, 0x9F).addRange(0xA1, 0x167F).addRange(0x1681, 0x1FFF).addRange(0x200B, 0x2027).addRange(0x202A, 0x202E).addRange(0x2030, 0x205E).addRange(0x2060, 0x2FFF).addRange(0x3001, 0xFEFE).addRange(0xFF00, 0xFFFF), + 'w': regenerate(0x5F).addRange(0x30, 0x39).addRange(0x41, 0x5A).addRange(0x61, 0x7A), + 'W': regenerate(0x60).addRange(0x0, 0x2F).addRange(0x3A, 0x40).addRange(0x5B, 0x5E).addRange(0x7B, 0xFFFF) + }; + + exports.UNICODE = { + 'd': regenerate().addRange(0x30, 0x39), + 'D': regenerate().addRange(0x0, 0x2F).addRange(0x3A, 0x10FFFF), + 's': regenerate(0x20, 0xA0, 0x1680, 0x202F, 0x205F, 0x3000, 0xFEFF).addRange(0x9, 0xD).addRange(0x2000, 0x200A).addRange(0x2028, 0x2029), + 'S': regenerate().addRange(0x0, 0x8).addRange(0xE, 0x1F).addRange(0x21, 0x9F).addRange(0xA1, 0x167F).addRange(0x1681, 0x1FFF).addRange(0x200B, 0x2027).addRange(0x202A, 0x202E).addRange(0x2030, 0x205E).addRange(0x2060, 0x2FFF).addRange(0x3001, 0xFEFE).addRange(0xFF00, 0x10FFFF), + 'w': regenerate(0x5F).addRange(0x30, 0x39).addRange(0x41, 0x5A).addRange(0x61, 0x7A), + 'W': regenerate(0x60).addRange(0x0, 0x2F).addRange(0x3A, 0x40).addRange(0x5B, 0x5E).addRange(0x7B, 0x10FFFF) + }; + + exports.UNICODE_IGNORE_CASE = { + 'd': regenerate().addRange(0x30, 0x39), + 'D': regenerate().addRange(0x0, 0x2F).addRange(0x3A, 0x10FFFF), + 's': regenerate(0x20, 0xA0, 0x1680, 0x202F, 0x205F, 0x3000, 0xFEFF).addRange(0x9, 0xD).addRange(0x2000, 0x200A).addRange(0x2028, 0x2029), + 'S': regenerate().addRange(0x0, 0x8).addRange(0xE, 0x1F).addRange(0x21, 0x9F).addRange(0xA1, 0x167F).addRange(0x1681, 0x1FFF).addRange(0x200B, 0x2027).addRange(0x202A, 0x202E).addRange(0x2030, 0x205E).addRange(0x2060, 0x2FFF).addRange(0x3001, 0xFEFE).addRange(0xFF00, 0x10FFFF), + 'w': regenerate(0x5F, 0x17F, 0x212A).addRange(0x30, 0x39).addRange(0x41, 0x5A).addRange(0x61, 0x7A), + 'W': regenerate(0x4B, 0x53, 0x60).addRange(0x0, 0x2F).addRange(0x3A, 0x40).addRange(0x5B, 0x5E).addRange(0x7B, 0x10FFFF) + }; + +/***/ }), +/* 603 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var generate = __webpack_require__(604).generate; + var parse = __webpack_require__(605).parse; + var regenerate = __webpack_require__(277); + var iuMappings = __webpack_require__(622); + var ESCAPE_SETS = __webpack_require__(602); + + function getCharacterClassEscapeSet(character) { + if (unicode) { + if (ignoreCase) { + return ESCAPE_SETS.UNICODE_IGNORE_CASE[character]; + } + return ESCAPE_SETS.UNICODE[character]; + } + return ESCAPE_SETS.REGULAR[character]; + } + + var object = {}; + var hasOwnProperty = object.hasOwnProperty; + function has(object, property) { + return hasOwnProperty.call(object, property); + } + + // Prepare a Regenerate set containing all code points, used for negative + // character classes (if any). + var UNICODE_SET = regenerate().addRange(0x0, 0x10FFFF); + // Without the `u` flag, the range stops at 0xFFFF. + // https://mths.be/es6#sec-pattern-semantics + var BMP_SET = regenerate().addRange(0x0, 0xFFFF); + + // Prepare a Regenerate set containing all code points that are supposed to be + // matched by `/./u`. https://mths.be/es6#sec-atom + var DOT_SET_UNICODE = UNICODE_SET.clone // all Unicode code points + ().remove( + // minus `LineTerminator`s (https://mths.be/es6#sec-line-terminators): + 0x000A, // Line Feed + 0x000D, // Carriage Return + 0x2028, // Line Separator + 0x2029 // Paragraph Separator + ); + // Prepare a Regenerate set containing all code points that are supposed to be + // matched by `/./` (only BMP code points). + var DOT_SET = DOT_SET_UNICODE.clone().intersection(BMP_SET); + + // Add a range of code points + any case-folded code points in that range to a + // set. + regenerate.prototype.iuAddRange = function (min, max) { + var $this = this; + do { + var folded = caseFold(min); + if (folded) { + $this.add(folded); + } + } while (++min <= max); + return $this; + }; + + function assign(target, source) { + for (var key in source) { + // Note: `hasOwnProperty` is not needed here. + target[key] = source[key]; + } + } + + function update(item, pattern) { + // TODO: Test if memoizing `pattern` here is worth the effort. + if (!pattern) { + return; + } + var tree = parse(pattern, ''); + switch (tree.type) { + case 'characterClass': + case 'group': case 'value': - set.add(item.codePoint); + // No wrapping needed. + break; + default: + // Wrap the pattern in a non-capturing group. + tree = wrap(tree, pattern); + } + assign(item, tree); + } + + function wrap(tree, pattern) { + // Wrap the pattern in a non-capturing group. + return { + 'type': 'group', + 'behavior': 'ignore', + 'body': [tree], + 'raw': '(?:' + pattern + ')' + }; + } + + function caseFold(codePoint) { + return has(iuMappings, codePoint) ? iuMappings[codePoint] : false; + } + + var ignoreCase = false; + var unicode = false; + function processCharacterClass(characterClassItem) { + var set = regenerate(); + var body = characterClassItem.body.forEach(function (item) { + switch (item.type) { + case 'value': + set.add(item.codePoint); + if (ignoreCase && unicode) { + var folded = caseFold(item.codePoint); + if (folded) { + set.add(folded); + } + } + break; + case 'characterClassRange': + var min = item.min.codePoint; + var max = item.max.codePoint; + set.addRange(min, max); + if (ignoreCase && unicode) { + set.iuAddRange(min, max); + } + break; + case 'characterClassEscape': + set.add(getCharacterClassEscapeSet(item.value)); + break; + // The `default` clause is only here as a safeguard; it should never be + // reached. Code coverage tools should ignore it. + /* istanbul ignore next */ + default: + throw Error('Unknown term type: ' + item.type); + } + }); + if (characterClassItem.negative) { + set = (unicode ? UNICODE_SET : BMP_SET).clone().remove(set); + } + update(characterClassItem, set.toString()); + return characterClassItem; + } + + function processTerm(item) { + switch (item.type) { + case 'dot': + update(item, (unicode ? DOT_SET_UNICODE : DOT_SET).toString()); + break; + case 'characterClass': + item = processCharacterClass(item); + break; + case 'characterClassEscape': + update(item, getCharacterClassEscapeSet(item.value).toString()); + break; + case 'alternative': + case 'disjunction': + case 'group': + case 'quantifier': + item.body = item.body.map(processTerm); + break; + case 'value': + var codePoint = item.codePoint; + var set = regenerate(codePoint); if (ignoreCase && unicode) { - var folded = caseFold(item.codePoint); + var folded = caseFold(codePoint); if (folded) { set.add(folded); } } + update(item, set.toString()); break; - case 'characterClassRange': - var min = item.min.codePoint; - var max = item.max.codePoint; - set.addRange(min, max); - if (ignoreCase && unicode) { - set.iuAddRange(min, max); - } - break; - case 'characterClassEscape': - set.add(getCharacterClassEscapeSet(item.value)); + case 'anchor': + case 'empty': + case 'group': + case 'reference': + // Nothing to do here. break; // The `default` clause is only here as a safeguard; it should never be // reached. Code coverage tools should ignore it. @@ -58701,8723 +57686,5161 @@ function processCharacterClass(characterClassItem) { default: throw Error('Unknown term type: ' + item.type); } - }); - if (characterClassItem.negative) { - set = (unicode ? UNICODE_SET : BMP_SET).clone().remove(set); - } - update(characterClassItem, set.toString()); - return characterClassItem; -} + return item; + }; -function processTerm(item) { - switch (item.type) { - case 'dot': - update( - item, - (unicode ? DOT_SET_UNICODE : DOT_SET).toString() - ); - break; - case 'characterClass': - item = processCharacterClass(item); - break; - case 'characterClassEscape': - update( - item, - getCharacterClassEscapeSet(item.value).toString() - ); - break; - case 'alternative': - case 'disjunction': - case 'group': - case 'quantifier': - item.body = item.body.map(processTerm); - break; - case 'value': - var codePoint = item.codePoint; - var set = regenerate(codePoint); - if (ignoreCase && unicode) { - var folded = caseFold(codePoint); - if (folded) { - set.add(folded); - } - } - update(item, set.toString()); - break; - case 'anchor': - case 'empty': - case 'group': - case 'reference': - // Nothing to do here. - break; - // The `default` clause is only here as a safeguard; it should never be - // reached. Code coverage tools should ignore it. - /* istanbul ignore next */ - default: - throw Error('Unknown term type: ' + item.type); - } - return item; -}; + module.exports = function (pattern, flags) { + var tree = parse(pattern, flags); + ignoreCase = flags ? flags.indexOf('i') > -1 : false; + unicode = flags ? flags.indexOf('u') > -1 : false; + assign(tree, processTerm(tree)); + return generate(tree); + }; -module.exports = function(pattern, flags) { - var tree = parse(pattern, flags); - ignoreCase = flags ? flags.indexOf('i') > -1 : false; - unicode = flags ? flags.indexOf('u') > -1 : false; - assign(tree, processTerm(tree)); - return generate(tree); -}; +/***/ }), +/* 604 */ +/***/ (function(module, exports, __webpack_require__) { -},{"586":586,"587":587,"588":588,"589":589,"590":590}],592:[function(_dereq_,module,exports){ -'use strict'; -var isFinite = _dereq_(593); + var __WEBPACK_AMD_DEFINE_RESULT__;/* WEBPACK VAR INJECTION */(function(module, global) {'use strict'; -module.exports = function (str, n) { - if (typeof str !== 'string') { - throw new TypeError('Expected a string as the first argument'); - } + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - if (n < 0 || !isFinite(n)) { - throw new TypeError('Expected a finite positive number'); - } + /*! + * RegJSGen + * Copyright 2014 Benjamin Tan + * Available under MIT license + */ + ;(function () { + 'use strict'; - var ret = ''; + /** Used to determine if values are of the language type `Object` */ - do { - if (n & 1) { - ret += str; + var objectTypes = { + 'function': true, + 'object': true + }; + + /** Used as a reference to the global object */ + var root = objectTypes[typeof window === 'undefined' ? 'undefined' : _typeof(window)] && window || this; + + /** Backup possible global object */ + var oldRoot = root; + + /** Detect free variable `exports` */ + var freeExports = objectTypes[ false ? 'undefined' : _typeof(exports)] && exports; + + /** Detect free variable `module` */ + var freeModule = objectTypes[ false ? 'undefined' : _typeof(module)] && module && !module.nodeType && module; + + /** Detect free variable `global` from Node.js or Browserified code and use it as `root` */ + var freeGlobal = freeExports && freeModule && (typeof global === 'undefined' ? 'undefined' : _typeof(global)) == 'object' && global; + if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal)) { + root = freeGlobal; + } + + /*--------------------------------------------------------------------------*/ + + /*! Based on https://mths.be/fromcodepoint v0.2.0 by @mathias */ + + var stringFromCharCode = String.fromCharCode; + var floor = Math.floor; + function fromCodePoint() { + var MAX_SIZE = 0x4000; + var codeUnits = []; + var highSurrogate; + var lowSurrogate; + var index = -1; + var length = arguments.length; + if (!length) { + return ''; + } + var result = ''; + while (++index < length) { + var codePoint = Number(arguments[index]); + if (!isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity` + codePoint < 0 || // not a valid Unicode code point + codePoint > 0x10FFFF || // not a valid Unicode code point + floor(codePoint) != codePoint // not an integer + ) { + throw RangeError('Invalid code point: ' + codePoint); + } + if (codePoint <= 0xFFFF) { + // BMP code point + codeUnits.push(codePoint); + } else { + // Astral code point; split in surrogate halves + // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae + codePoint -= 0x10000; + highSurrogate = (codePoint >> 10) + 0xD800; + lowSurrogate = codePoint % 0x400 + 0xDC00; + codeUnits.push(highSurrogate, lowSurrogate); + } + if (index + 1 == length || codeUnits.length > MAX_SIZE) { + result += stringFromCharCode.apply(null, codeUnits); + codeUnits.length = 0; + } + } + return result; + } + + function assertType(type, expected) { + if (expected.indexOf('|') == -1) { + if (type == expected) { + return; + } + + throw Error('Invalid node type: ' + type); + } + + expected = assertType.hasOwnProperty(expected) ? assertType[expected] : assertType[expected] = RegExp('^(?:' + expected + ')$'); + + if (expected.test(type)) { + return; + } + + throw Error('Invalid node type: ' + type); + } + + /*--------------------------------------------------------------------------*/ + + function generate(node) { + var type = node.type; + + if (generate.hasOwnProperty(type) && typeof generate[type] == 'function') { + return generate[type](node); + } + + throw Error('Invalid node type: ' + type); + } + + /*--------------------------------------------------------------------------*/ + + function generateAlternative(node) { + assertType(node.type, 'alternative'); + + var terms = node.body, + length = terms ? terms.length : 0; + + if (length == 1) { + return generateTerm(terms[0]); + } else { + var i = -1, + result = ''; + + while (++i < length) { + result += generateTerm(terms[i]); + } + + return result; + } + } + + function generateAnchor(node) { + assertType(node.type, 'anchor'); + + switch (node.kind) { + case 'start': + return '^'; + case 'end': + return '$'; + case 'boundary': + return '\\b'; + case 'not-boundary': + return '\\B'; + default: + throw Error('Invalid assertion'); + } + } + + function generateAtom(node) { + assertType(node.type, 'anchor|characterClass|characterClassEscape|dot|group|reference|value'); + + return generate(node); + } + + function generateCharacterClass(node) { + assertType(node.type, 'characterClass'); + + var classRanges = node.body, + length = classRanges ? classRanges.length : 0; + + var i = -1, + result = '['; + + if (node.negative) { + result += '^'; + } + + while (++i < length) { + result += generateClassAtom(classRanges[i]); + } + + result += ']'; + + return result; + } + + function generateCharacterClassEscape(node) { + assertType(node.type, 'characterClassEscape'); + + return '\\' + node.value; + } + + function generateCharacterClassRange(node) { + assertType(node.type, 'characterClassRange'); + + var min = node.min, + max = node.max; + + if (min.type == 'characterClassRange' || max.type == 'characterClassRange') { + throw Error('Invalid character class range'); + } + + return generateClassAtom(min) + '-' + generateClassAtom(max); + } + + function generateClassAtom(node) { + assertType(node.type, 'anchor|characterClassEscape|characterClassRange|dot|value'); + + return generate(node); + } + + function generateDisjunction(node) { + assertType(node.type, 'disjunction'); + + var body = node.body, + length = body ? body.length : 0; + + if (length == 0) { + throw Error('No body'); + } else if (length == 1) { + return generate(body[0]); + } else { + var i = -1, + result = ''; + + while (++i < length) { + if (i != 0) { + result += '|'; + } + result += generate(body[i]); + } + + return result; + } + } + + function generateDot(node) { + assertType(node.type, 'dot'); + + return '.'; + } + + function generateGroup(node) { + assertType(node.type, 'group'); + + var result = '('; + + switch (node.behavior) { + case 'normal': + break; + case 'ignore': + result += '?:'; + break; + case 'lookahead': + result += '?='; + break; + case 'negativeLookahead': + result += '?!'; + break; + default: + throw Error('Invalid behaviour: ' + node.behaviour); + } + + var body = node.body, + length = body ? body.length : 0; + + if (length == 1) { + result += generate(body[0]); + } else { + var i = -1; + + while (++i < length) { + result += generate(body[i]); + } + } + + result += ')'; + + return result; + } + + function generateQuantifier(node) { + assertType(node.type, 'quantifier'); + + var quantifier = '', + min = node.min, + max = node.max; + + switch (max) { + case undefined: + case null: + switch (min) { + case 0: + quantifier = '*'; + break; + case 1: + quantifier = '+'; + break; + default: + quantifier = '{' + min + ',}'; + break; + } + break; + default: + if (min == max) { + quantifier = '{' + min + '}'; + } else if (min == 0 && max == 1) { + quantifier = '?'; + } else { + quantifier = '{' + min + ',' + max + '}'; + } + break; + } + + if (!node.greedy) { + quantifier += '?'; + } + + return generateAtom(node.body[0]) + quantifier; + } + + function generateReference(node) { + assertType(node.type, 'reference'); + + return '\\' + node.matchIndex; + } + + function generateTerm(node) { + assertType(node.type, 'anchor|characterClass|characterClassEscape|empty|group|quantifier|reference|value'); + + return generate(node); + } + + function generateValue(node) { + assertType(node.type, 'value'); + + var kind = node.kind, + codePoint = node.codePoint; + + switch (kind) { + case 'controlLetter': + return '\\c' + fromCodePoint(codePoint + 64); + case 'hexadecimalEscape': + return '\\x' + ('00' + codePoint.toString(16).toUpperCase()).slice(-2); + case 'identifier': + return '\\' + fromCodePoint(codePoint); + case 'null': + return '\\' + codePoint; + case 'octal': + return '\\' + codePoint.toString(8); + case 'singleEscape': + switch (codePoint) { + case 0x0008: + return '\\b'; + case 0x009: + return '\\t'; + case 0x00A: + return '\\n'; + case 0x00B: + return '\\v'; + case 0x00C: + return '\\f'; + case 0x00D: + return '\\r'; + default: + throw Error('Invalid codepoint: ' + codePoint); + } + case 'symbol': + return fromCodePoint(codePoint); + case 'unicodeEscape': + return '\\u' + ('0000' + codePoint.toString(16).toUpperCase()).slice(-4); + case 'unicodeCodePointEscape': + return '\\u{' + codePoint.toString(16).toUpperCase() + '}'; + default: + throw Error('Unsupported node kind: ' + kind); + } + } + + /*--------------------------------------------------------------------------*/ + + generate.alternative = generateAlternative; + generate.anchor = generateAnchor; + generate.characterClass = generateCharacterClass; + generate.characterClassEscape = generateCharacterClassEscape; + generate.characterClassRange = generateCharacterClassRange; + generate.disjunction = generateDisjunction; + generate.dot = generateDot; + generate.group = generateGroup; + generate.quantifier = generateQuantifier; + generate.reference = generateReference; + generate.value = generateValue; + + /*--------------------------------------------------------------------------*/ + + // export regjsgen + // some AMD build optimizers, like r.js, check for condition patterns like the following: + if ("function" == 'function' && _typeof(__webpack_require__(48)) == 'object' && __webpack_require__(48)) { + // define as an anonymous module so, through path mapping, it can be aliased + !(__WEBPACK_AMD_DEFINE_RESULT__ = function () { + return { + 'generate': generate + }; + }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } + // check for `exports` after `define` in case a build optimizer adds an `exports` object + else if (freeExports && freeModule) { + // in Narwhal, Node.js, Rhino -require, or RingoJS + freeExports.generate = generate; + } + // in a browser or Rhino + else { + root.regjsgen = { + 'generate': generate + }; + } + }).call(undefined); + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(39)(module), (function() { return this; }()))) + +/***/ }), +/* 605 */ +/***/ (function(module, exports) { + + 'use strict'; + + // regjsparser + // + // ================================================================== + // + // See ECMA-262 Standard: 15.10.1 + // + // NOTE: The ECMA-262 standard uses the term "Assertion" for /^/. Here the + // term "Anchor" is used. + // + // Pattern :: + // Disjunction + // + // Disjunction :: + // Alternative + // Alternative | Disjunction + // + // Alternative :: + // [empty] + // Alternative Term + // + // Term :: + // Anchor + // Atom + // Atom Quantifier + // + // Anchor :: + // ^ + // $ + // \ b + // \ B + // ( ? = Disjunction ) + // ( ? ! Disjunction ) + // + // Quantifier :: + // QuantifierPrefix + // QuantifierPrefix ? + // + // QuantifierPrefix :: + // * + // + + // ? + // { DecimalDigits } + // { DecimalDigits , } + // { DecimalDigits , DecimalDigits } + // + // Atom :: + // PatternCharacter + // . + // \ AtomEscape + // CharacterClass + // ( Disjunction ) + // ( ? : Disjunction ) + // + // PatternCharacter :: + // SourceCharacter but not any of: ^ $ \ . * + ? ( ) [ ] { } | + // + // AtomEscape :: + // DecimalEscape + // CharacterEscape + // CharacterClassEscape + // + // CharacterEscape[U] :: + // ControlEscape + // c ControlLetter + // HexEscapeSequence + // RegExpUnicodeEscapeSequence[?U] (ES6) + // IdentityEscape[?U] + // + // ControlEscape :: + // one of f n r t v + // ControlLetter :: + // one of + // a b c d e f g h i j k l m n o p q r s t u v w x y z + // A B C D E F G H I J K L M N O P Q R S T U V W X Y Z + // + // IdentityEscape :: + // SourceCharacter but not IdentifierPart + // + // + // + // DecimalEscape :: + // DecimalIntegerLiteral [lookahead ∉ DecimalDigit] + // + // CharacterClassEscape :: + // one of d D s S w W + // + // CharacterClass :: + // [ [lookahead ∉ {^}] ClassRanges ] + // [ ^ ClassRanges ] + // + // ClassRanges :: + // [empty] + // NonemptyClassRanges + // + // NonemptyClassRanges :: + // ClassAtom + // ClassAtom NonemptyClassRangesNoDash + // ClassAtom - ClassAtom ClassRanges + // + // NonemptyClassRangesNoDash :: + // ClassAtom + // ClassAtomNoDash NonemptyClassRangesNoDash + // ClassAtomNoDash - ClassAtom ClassRanges + // + // ClassAtom :: + // - + // ClassAtomNoDash + // + // ClassAtomNoDash :: + // SourceCharacter but not one of \ or ] or - + // \ ClassEscape + // + // ClassEscape :: + // DecimalEscape + // b + // CharacterEscape + // CharacterClassEscape + + (function () { + + function parse(str, flags) { + function addRaw(node) { + node.raw = str.substring(node.range[0], node.range[1]); + return node; + } + + function updateRawStart(node, start) { + node.range[0] = start; + return addRaw(node); + } + + function createAnchor(kind, rawLength) { + return addRaw({ + type: 'anchor', + kind: kind, + range: [pos - rawLength, pos] + }); + } + + function createValue(kind, codePoint, from, to) { + return addRaw({ + type: 'value', + kind: kind, + codePoint: codePoint, + range: [from, to] + }); + } + + function createEscaped(kind, codePoint, value, fromOffset) { + fromOffset = fromOffset || 0; + return createValue(kind, codePoint, pos - (value.length + fromOffset), pos); + } + + function createCharacter(matches) { + var _char = matches[0]; + var first = _char.charCodeAt(0); + if (hasUnicodeFlag) { + var second; + if (_char.length === 1 && first >= 0xD800 && first <= 0xDBFF) { + second = lookahead().charCodeAt(0); + if (second >= 0xDC00 && second <= 0xDFFF) { + // Unicode surrogate pair + pos++; + return createValue('symbol', (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000, pos - 2, pos); + } + } + } + return createValue('symbol', first, pos - 1, pos); + } + + function createDisjunction(alternatives, from, to) { + return addRaw({ + type: 'disjunction', + body: alternatives, + range: [from, to] + }); + } + + function createDot() { + return addRaw({ + type: 'dot', + range: [pos - 1, pos] + }); + } + + function createCharacterClassEscape(value) { + return addRaw({ + type: 'characterClassEscape', + value: value, + range: [pos - 2, pos] + }); + } + + function createReference(matchIndex) { + return addRaw({ + type: 'reference', + matchIndex: parseInt(matchIndex, 10), + range: [pos - 1 - matchIndex.length, pos] + }); + } + + function createGroup(behavior, disjunction, from, to) { + return addRaw({ + type: 'group', + behavior: behavior, + body: disjunction, + range: [from, to] + }); + } + + function createQuantifier(min, max, from, to) { + if (to == null) { + from = pos - 1; + to = pos; + } + + return addRaw({ + type: 'quantifier', + min: min, + max: max, + greedy: true, + body: null, // set later on + range: [from, to] + }); + } + + function createAlternative(terms, from, to) { + return addRaw({ + type: 'alternative', + body: terms, + range: [from, to] + }); + } + + function createCharacterClass(classRanges, negative, from, to) { + return addRaw({ + type: 'characterClass', + body: classRanges, + negative: negative, + range: [from, to] + }); + } + + function createClassRange(min, max, from, to) { + // See 15.10.2.15: + if (min.codePoint > max.codePoint) { + bail('invalid range in character class', min.raw + '-' + max.raw, from, to); + } + + return addRaw({ + type: 'characterClassRange', + min: min, + max: max, + range: [from, to] + }); + } + + function flattenBody(body) { + if (body.type === 'alternative') { + return body.body; + } else { + return [body]; + } + } + + function isEmpty(obj) { + return obj.type === 'empty'; + } + + function incr(amount) { + amount = amount || 1; + var res = str.substring(pos, pos + amount); + pos += amount || 1; + return res; + } + + function skip(value) { + if (!match(value)) { + bail('character', value); + } + } + + function match(value) { + if (str.indexOf(value, pos) === pos) { + return incr(value.length); + } + } + + function lookahead() { + return str[pos]; + } + + function current(value) { + return str.indexOf(value, pos) === pos; + } + + function next(value) { + return str[pos + 1] === value; + } + + function matchReg(regExp) { + var subStr = str.substring(pos); + var res = subStr.match(regExp); + if (res) { + res.range = []; + res.range[0] = pos; + incr(res[0].length); + res.range[1] = pos; + } + return res; + } + + function parseDisjunction() { + // Disjunction :: + // Alternative + // Alternative | Disjunction + var res = [], + from = pos; + res.push(parseAlternative()); + + while (match('|')) { + res.push(parseAlternative()); + } + + if (res.length === 1) { + return res[0]; + } + + return createDisjunction(res, from, pos); + } + + function parseAlternative() { + var res = [], + from = pos; + var term; + + // Alternative :: + // [empty] + // Alternative Term + while (term = parseTerm()) { + res.push(term); + } + + if (res.length === 1) { + return res[0]; + } + + return createAlternative(res, from, pos); + } + + function parseTerm() { + // Term :: + // Anchor + // Atom + // Atom Quantifier + + if (pos >= str.length || current('|') || current(')')) { + return null; /* Means: The term is empty */ + } + + var anchor = parseAnchor(); + + if (anchor) { + return anchor; + } + + var atom = parseAtom(); + if (!atom) { + bail('Expected atom'); + } + var quantifier = parseQuantifier() || false; + if (quantifier) { + quantifier.body = flattenBody(atom); + // The quantifier contains the atom. Therefore, the beginning of the + // quantifier range is given by the beginning of the atom. + updateRawStart(quantifier, atom.range[0]); + return quantifier; + } + return atom; + } + + function parseGroup(matchA, typeA, matchB, typeB) { + var type = null, + from = pos; + + if (match(matchA)) { + type = typeA; + } else if (match(matchB)) { + type = typeB; + } else { + return false; + } + + var body = parseDisjunction(); + if (!body) { + bail('Expected disjunction'); + } + skip(')'); + var group = createGroup(type, flattenBody(body), from, pos); + + if (type == 'normal') { + // Keep track of the number of closed groups. This is required for + // parseDecimalEscape(). In case the string is parsed a second time the + // value already holds the total count and no incrementation is required. + if (firstIteration) { + closedCaptureCounter++; + } + } + return group; + } + + function parseAnchor() { + // Anchor :: + // ^ + // $ + // \ b + // \ B + // ( ? = Disjunction ) + // ( ? ! Disjunction ) + var res, + from = pos; + + if (match('^')) { + return createAnchor('start', 1 /* rawLength */); + } else if (match('$')) { + return createAnchor('end', 1 /* rawLength */); + } else if (match('\\b')) { + return createAnchor('boundary', 2 /* rawLength */); + } else if (match('\\B')) { + return createAnchor('not-boundary', 2 /* rawLength */); + } else { + return parseGroup('(?=', 'lookahead', '(?!', 'negativeLookahead'); + } + } + + function parseQuantifier() { + // Quantifier :: + // QuantifierPrefix + // QuantifierPrefix ? + // + // QuantifierPrefix :: + // * + // + + // ? + // { DecimalDigits } + // { DecimalDigits , } + // { DecimalDigits , DecimalDigits } + + var res, + from = pos; + var quantifier; + var min, max; + + if (match('*')) { + quantifier = createQuantifier(0); + } else if (match('+')) { + quantifier = createQuantifier(1); + } else if (match('?')) { + quantifier = createQuantifier(0, 1); + } else if (res = matchReg(/^\{([0-9]+)\}/)) { + min = parseInt(res[1], 10); + quantifier = createQuantifier(min, min, res.range[0], res.range[1]); + } else if (res = matchReg(/^\{([0-9]+),\}/)) { + min = parseInt(res[1], 10); + quantifier = createQuantifier(min, undefined, res.range[0], res.range[1]); + } else if (res = matchReg(/^\{([0-9]+),([0-9]+)\}/)) { + min = parseInt(res[1], 10); + max = parseInt(res[2], 10); + if (min > max) { + bail('numbers out of order in {} quantifier', '', from, pos); + } + quantifier = createQuantifier(min, max, res.range[0], res.range[1]); + } + + if (quantifier) { + if (match('?')) { + quantifier.greedy = false; + quantifier.range[1] += 1; + } + } + + return quantifier; + } + + function parseAtom() { + // Atom :: + // PatternCharacter + // . + // \ AtomEscape + // CharacterClass + // ( Disjunction ) + // ( ? : Disjunction ) + + var res; + + // jviereck: allow ']', '}' here as well to be compatible with browser's + // implementations: ']'.match(/]/); + // if (res = matchReg(/^[^^$\\.*+?()[\]{}|]/)) { + if (res = matchReg(/^[^^$\\.*+?(){[|]/)) { + // PatternCharacter + return createCharacter(res); + } else if (match('.')) { + // . + return createDot(); + } else if (match('\\')) { + // \ AtomEscape + res = parseAtomEscape(); + if (!res) { + bail('atomEscape'); + } + return res; + } else if (res = parseCharacterClass()) { + return res; + } else { + // ( Disjunction ) + // ( ? : Disjunction ) + return parseGroup('(?:', 'ignore', '(', 'normal'); + } + } + + function parseUnicodeSurrogatePairEscape(firstEscape) { + if (hasUnicodeFlag) { + var first, second; + if (firstEscape.kind == 'unicodeEscape' && (first = firstEscape.codePoint) >= 0xD800 && first <= 0xDBFF && current('\\') && next('u')) { + var prevPos = pos; + pos++; + var secondEscape = parseClassEscape(); + if (secondEscape.kind == 'unicodeEscape' && (second = secondEscape.codePoint) >= 0xDC00 && second <= 0xDFFF) { + // Unicode surrogate pair + firstEscape.range[1] = secondEscape.range[1]; + firstEscape.codePoint = (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; + firstEscape.type = 'value'; + firstEscape.kind = 'unicodeCodePointEscape'; + addRaw(firstEscape); + } else { + pos = prevPos; + } + } + } + return firstEscape; + } + + function parseClassEscape() { + return parseAtomEscape(true); + } + + function parseAtomEscape(insideCharacterClass) { + // AtomEscape :: + // DecimalEscape + // CharacterEscape + // CharacterClassEscape + + var res, + from = pos; + + res = parseDecimalEscape(); + if (res) { + return res; + } + + // For ClassEscape + if (insideCharacterClass) { + if (match('b')) { + // 15.10.2.19 + // The production ClassEscape :: b evaluates by returning the + // CharSet containing the one character (Unicode value 0008). + return createEscaped('singleEscape', 0x0008, '\\b'); + } else if (match('B')) { + bail('\\B not possible inside of CharacterClass', '', from); + } + } + + res = parseCharacterEscape(); + + return res; + } + + function parseDecimalEscape() { + // DecimalEscape :: + // DecimalIntegerLiteral [lookahead ∉ DecimalDigit] + // CharacterClassEscape :: one of d D s S w W + + var res, match; + + if (res = matchReg(/^(?!0)\d+/)) { + match = res[0]; + var refIdx = parseInt(res[0], 10); + if (refIdx <= closedCaptureCounter) { + // If the number is smaller than the normal-groups found so + // far, then it is a reference... + return createReference(res[0]); + } else { + // ... otherwise it needs to be interpreted as a octal (if the + // number is in an octal format). If it is NOT octal format, + // then the slash is ignored and the number is matched later + // as normal characters. + + // Recall the negative decision to decide if the input must be parsed + // a second time with the total normal-groups. + backrefDenied.push(refIdx); + + // Reset the position again, as maybe only parts of the previous + // matched numbers are actual octal numbers. E.g. in '019' only + // the '01' should be matched. + incr(-res[0].length); + if (res = matchReg(/^[0-7]{1,3}/)) { + return createEscaped('octal', parseInt(res[0], 8), res[0], 1); + } else { + // If we end up here, we have a case like /\91/. Then the + // first slash is to be ignored and the 9 & 1 to be treated + // like ordinary characters. Create a character for the + // first number only here - other number-characters + // (if available) will be matched later. + res = createCharacter(matchReg(/^[89]/)); + return updateRawStart(res, res.range[0] - 1); + } + } + } + // Only allow octal numbers in the following. All matched numbers start + // with a zero (if the do not, the previous if-branch is executed). + // If the number is not octal format and starts with zero (e.g. `091`) + // then only the zeros `0` is treated here and the `91` are ordinary + // characters. + // Example: + // /\091/.exec('\091')[0].length === 3 + else if (res = matchReg(/^[0-7]{1,3}/)) { + match = res[0]; + if (/^0{1,3}$/.test(match)) { + // If they are all zeros, then only take the first one. + return createEscaped('null', 0x0000, '0', match.length + 1); + } else { + return createEscaped('octal', parseInt(match, 8), match, 1); + } + } else if (res = matchReg(/^[dDsSwW]/)) { + return createCharacterClassEscape(res[0]); + } + return false; + } + + function parseCharacterEscape() { + // CharacterEscape :: + // ControlEscape + // c ControlLetter + // HexEscapeSequence + // UnicodeEscapeSequence + // IdentityEscape + + var res; + if (res = matchReg(/^[fnrtv]/)) { + // ControlEscape + var codePoint = 0; + switch (res[0]) { + case 't': + codePoint = 0x009;break; + case 'n': + codePoint = 0x00A;break; + case 'v': + codePoint = 0x00B;break; + case 'f': + codePoint = 0x00C;break; + case 'r': + codePoint = 0x00D;break; + } + return createEscaped('singleEscape', codePoint, '\\' + res[0]); + } else if (res = matchReg(/^c([a-zA-Z])/)) { + // c ControlLetter + return createEscaped('controlLetter', res[1].charCodeAt(0) % 32, res[1], 2); + } else if (res = matchReg(/^x([0-9a-fA-F]{2})/)) { + // HexEscapeSequence + return createEscaped('hexadecimalEscape', parseInt(res[1], 16), res[1], 2); + } else if (res = matchReg(/^u([0-9a-fA-F]{4})/)) { + // UnicodeEscapeSequence + return parseUnicodeSurrogatePairEscape(createEscaped('unicodeEscape', parseInt(res[1], 16), res[1], 2)); + } else if (hasUnicodeFlag && (res = matchReg(/^u\{([0-9a-fA-F]+)\}/))) { + // RegExpUnicodeEscapeSequence (ES6 Unicode code point escape) + return createEscaped('unicodeCodePointEscape', parseInt(res[1], 16), res[1], 4); + } else { + // IdentityEscape + return parseIdentityEscape(); + } + } + + // Taken from the Esprima parser. + function isIdentifierPart(ch) { + // Generated by `tools/generate-identifier-regex.js`. + var NonAsciiIdentifierPart = new RegExp('[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B2\u08E4-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA69D\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2D\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]'); + + return ch === 36 || ch === 95 || // $ (dollar) and _ (underscore) + ch >= 65 && ch <= 90 || // A..Z + ch >= 97 && ch <= 122 || // a..z + ch >= 48 && ch <= 57 || // 0..9 + ch === 92 || // \ (backslash) + ch >= 0x80 && NonAsciiIdentifierPart.test(String.fromCharCode(ch)); + } + + function parseIdentityEscape() { + // IdentityEscape :: + // SourceCharacter but not IdentifierPart + // + // + + var ZWJ = '\u200C'; + var ZWNJ = '\u200D'; + + var tmp; + + if (!isIdentifierPart(lookahead())) { + tmp = incr(); + return createEscaped('identifier', tmp.charCodeAt(0), tmp, 1); + } + + if (match(ZWJ)) { + // + return createEscaped('identifier', 0x200C, ZWJ); + } else if (match(ZWNJ)) { + // + return createEscaped('identifier', 0x200D, ZWNJ); + } + + return null; + } + + function parseCharacterClass() { + // CharacterClass :: + // [ [lookahead ∉ {^}] ClassRanges ] + // [ ^ ClassRanges ] + + var res, + from = pos; + if (res = matchReg(/^\[\^/)) { + res = parseClassRanges(); + skip(']'); + return createCharacterClass(res, true, from, pos); + } else if (match('[')) { + res = parseClassRanges(); + skip(']'); + return createCharacterClass(res, false, from, pos); + } + + return null; + } + + function parseClassRanges() { + // ClassRanges :: + // [empty] + // NonemptyClassRanges + + var res; + if (current(']')) { + // Empty array means nothing insinde of the ClassRange. + return []; + } else { + res = parseNonemptyClassRanges(); + if (!res) { + bail('nonEmptyClassRanges'); + } + return res; + } + } + + function parseHelperClassRanges(atom) { + var from, to, res; + if (current('-') && !next(']')) { + // ClassAtom - ClassAtom ClassRanges + skip('-'); + + res = parseClassAtom(); + if (!res) { + bail('classAtom'); + } + to = pos; + var classRanges = parseClassRanges(); + if (!classRanges) { + bail('classRanges'); + } + from = atom.range[0]; + if (classRanges.type === 'empty') { + return [createClassRange(atom, res, from, to)]; + } + return [createClassRange(atom, res, from, to)].concat(classRanges); + } + + res = parseNonemptyClassRangesNoDash(); + if (!res) { + bail('nonEmptyClassRangesNoDash'); + } + + return [atom].concat(res); + } + + function parseNonemptyClassRanges() { + // NonemptyClassRanges :: + // ClassAtom + // ClassAtom NonemptyClassRangesNoDash + // ClassAtom - ClassAtom ClassRanges + + var atom = parseClassAtom(); + if (!atom) { + bail('classAtom'); + } + + if (current(']')) { + // ClassAtom + return [atom]; + } + + // ClassAtom NonemptyClassRangesNoDash + // ClassAtom - ClassAtom ClassRanges + return parseHelperClassRanges(atom); + } + + function parseNonemptyClassRangesNoDash() { + // NonemptyClassRangesNoDash :: + // ClassAtom + // ClassAtomNoDash NonemptyClassRangesNoDash + // ClassAtomNoDash - ClassAtom ClassRanges + + var res = parseClassAtom(); + if (!res) { + bail('classAtom'); + } + if (current(']')) { + // ClassAtom + return res; + } + + // ClassAtomNoDash NonemptyClassRangesNoDash + // ClassAtomNoDash - ClassAtom ClassRanges + return parseHelperClassRanges(res); + } + + function parseClassAtom() { + // ClassAtom :: + // - + // ClassAtomNoDash + if (match('-')) { + return createCharacter('-'); + } else { + return parseClassAtomNoDash(); + } + } + + function parseClassAtomNoDash() { + // ClassAtomNoDash :: + // SourceCharacter but not one of \ or ] or - + // \ ClassEscape + + var res; + if (res = matchReg(/^[^\\\]-]/)) { + return createCharacter(res[0]); + } else if (match('\\')) { + res = parseClassEscape(); + if (!res) { + bail('classEscape'); + } + + return parseUnicodeSurrogatePairEscape(res); + } + } + + function bail(message, details, from, to) { + from = from == null ? pos : from; + to = to == null ? from : to; + + var contextStart = Math.max(0, from - 10); + var contextEnd = Math.min(to + 10, str.length); + + // Output a bit of context and a line pointing to where our error is. + // + // We are assuming that there are no actual newlines in the content as this is a regular expression. + var context = ' ' + str.substring(contextStart, contextEnd); + var pointer = ' ' + new Array(from - contextStart + 1).join(' ') + '^'; + + throw SyntaxError(message + ' at position ' + from + (details ? ': ' + details : '') + '\n' + context + '\n' + pointer); + } + + var backrefDenied = []; + var closedCaptureCounter = 0; + var firstIteration = true; + var hasUnicodeFlag = (flags || "").indexOf("u") !== -1; + var pos = 0; + + // Convert the input to a string and treat the empty string special. + str = String(str); + if (str === '') { + str = '(?:)'; + } + + var result = parseDisjunction(); + + if (result.range[1] !== str.length) { + bail('Could not parse entire input - got stuck', '', result.range[1]); + } + + // The spec requires to interpret the `\2` in `/\2()()/` as backreference. + // As the parser collects the number of capture groups as the string is + // parsed it is impossible to make these decisions at the point when the + // `\2` is handled. In case the local decision turns out to be wrong after + // the parsing has finished, the input string is parsed a second time with + // the total number of capture groups set. + // + // SEE: https://github.com/jviereck/regjsparser/issues/70 + for (var i = 0; i < backrefDenied.length; i++) { + if (backrefDenied[i] <= closedCaptureCounter) { + // Parse the input a second time. + pos = 0; + firstIteration = false; + return parseDisjunction(); + } + } + + return result; + } + + var regjsparser = { + parse: parse + }; + + if (typeof module !== 'undefined' && module.exports) { + module.exports = regjsparser; + } else { + window.regjsparser = regjsparser; + } + })(); + +/***/ }), +/* 606 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + var isFinite = __webpack_require__(458); + + module.exports = function (str, n) { + if (typeof str !== 'string') { + throw new TypeError('Expected `input` to be a string'); } - str += str; - } while (n = n >> 1); + if (n < 0 || !isFinite(n)) { + throw new TypeError('Expected `count` to be a positive finite number'); + } - return ret; -}; + var ret = ''; -},{"593":593}],593:[function(_dereq_,module,exports){ -arguments[4][407][0].apply(exports,arguments) -},{"407":407,"594":594}],594:[function(_dereq_,module,exports){ -arguments[4][408][0].apply(exports,arguments) -},{"408":408}],595:[function(_dereq_,module,exports){ -'use strict'; -module.exports = /^#!.*/; + do { + if (n & 1) { + ret += str; + } -},{}],596:[function(_dereq_,module,exports){ -'use strict'; -module.exports = function (str) { - var isExtendedLengthPath = /^\\\\\?\\/.test(str); - var hasNonAscii = /[^\x00-\x80]+/.test(str); + str += str; + } while (n >>= 1); - if (isExtendedLengthPath || hasNonAscii) { - return str; + return ret; + }; + +/***/ }), +/* 607 */ +/***/ (function(module, exports) { + + 'use strict'; + + /* -*- 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; + }; + +/***/ }), +/* 608 */ +/***/ (function(module, exports) { + + "use strict"; + + /* -*- 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; + } + } } - return str.replace(/\\/g, '/'); -}; - -},{}],597:[function(_dereq_,module,exports){ -/* -*- 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 = _dereq_(606); - - /** - * 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 = {}; - } - - /** - * 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 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 = util.toSetString(aStr); - var isDuplicate = this._set.hasOwnProperty(sStr); - var idx = this._array.length; - if (!isDuplicate || aAllowDuplicates) { - this._array.push(aStr); - } - if (!isDuplicate) { - this._set[sStr] = idx; - } - }; - - /** - * Is the given string a member of this set? - * - * @param String aStr - */ - ArraySet.prototype.has = function ArraySet_has(aStr) { - var sStr = util.toSetString(aStr); - return this._set.hasOwnProperty(sStr); - }; - - /** - * What is the index of the given string in the array? - * - * @param String aStr - */ - ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) { - var sStr = util.toSetString(aStr); - if (this._set.hasOwnProperty(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; -} - -},{"606":606}],598:[function(_dereq_,module,exports){ -/* -*- 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 = _dereq_(599); - - // 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; - }; -} - -},{"599":599}],599:[function(_dereq_,module,exports){ -/* -*- 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; - }; -} - -},{}],600:[function(_dereq_,module,exports){ -/* -*- 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; - }; -} - -},{}],601:[function(_dereq_,module,exports){ -/* -*- 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 = _dereq_(606); - - /** - * 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; -} - -},{"606":606}],602:[function(_dereq_,module,exports){ -/* -*- 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); - }; -} - -},{}],603:[function(_dereq_,module,exports){ -/* -*- 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 = _dereq_(606); - var binarySearch = _dereq_(600); - var ArraySet = _dereq_(597).ArraySet; - var base64VLQ = _dereq_(598); - var quickSort = _dereq_(602).quickSort; - - function SourceMapConsumer(aSourceMap) { - var sourceMap = aSourceMap; - if (typeof aSourceMap === 'string') { - sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, '')); - } - - return sourceMap.sections != null - ? new IndexedSourceMapConsumer(sourceMap) - : new BasicSourceMapConsumer(sourceMap); - } - - SourceMapConsumer.fromSourceMap = function(aSourceMap) { - return BasicSourceMapConsumer.fromSourceMap(aSourceMap); - } - - /** - * The version of the source mapping spec that we are consuming. - */ - SourceMapConsumer.prototype._version = 3; - - // `__generatedMappings` and `__originalMappings` are arrays that hold the - // parsed mapping coordinates from the source map's "mappings" attribute. They - // are lazily instantiated, accessed via the `_generatedMappings` and - // `_originalMappings` getters respectively, and we only parse the mappings - // and create these arrays once queried for a source location. We jump through - // these hoops because there can be many thousands of mappings, and parsing - // them is expensive, so we only want to do it if we must. - // - // Each object in the arrays is of the form: - // - // { - // generatedLine: The line number in the generated code, - // generatedColumn: The column number in the generated code, - // source: The path to the original source file that generated this - // chunk of code, - // originalLine: The line number in the original source that - // corresponds to this chunk of generated code, - // originalColumn: The column number in the original source that - // corresponds to this chunk of generated code, - // name: The name of the original symbol which generated this chunk of - // code. - // } - // - // All properties except for `generatedLine` and `generatedColumn` can be - // `null`. - // - // `_generatedMappings` is ordered by the generated positions. - // - // `_originalMappings` is ordered by the original positions. - - SourceMapConsumer.prototype.__generatedMappings = null; - Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', { - get: function () { - if (!this.__generatedMappings) { - this._parseMappings(this._mappings, this.sourceRoot); - } - - return this.__generatedMappings; - } - }); - - SourceMapConsumer.prototype.__originalMappings = null; - Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', { - get: function () { - if (!this.__originalMappings) { - this._parseMappings(this._mappings, this.sourceRoot); - } - - return this.__originalMappings; - } - }); - - SourceMapConsumer.prototype._charIsMappingSeparator = - function SourceMapConsumer_charIsMappingSeparator(aStr, index) { - var c = aStr.charAt(index); - return c === ";" || c === ","; - }; - - /** - * Parse the mappings in a string in to a data structure which we can easily - * query (the ordered arrays in the `this.__generatedMappings` and - * `this.__originalMappings` properties). - */ - SourceMapConsumer.prototype._parseMappings = - function SourceMapConsumer_parseMappings(aStr, aSourceRoot) { - throw new Error("Subclasses must implement _parseMappings"); - }; - - SourceMapConsumer.GENERATED_ORDER = 1; - SourceMapConsumer.ORIGINAL_ORDER = 2; - - SourceMapConsumer.GREATEST_LOWER_BOUND = 1; - SourceMapConsumer.LEAST_UPPER_BOUND = 2; - - /** - * Iterate over each mapping between an original source/line/column and a - * generated line/column in this source map. - * - * @param Function aCallback - * The function that is called with each mapping. - * @param Object aContext - * Optional. If specified, this object will be the value of `this` every - * time that `aCallback` is called. - * @param aOrder - * 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`. - */ - SourceMapConsumer.prototype.eachMapping = - function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) { - var context = aContext || null; - var order = aOrder || SourceMapConsumer.GENERATED_ORDER; - - var mappings; - switch (order) { - case SourceMapConsumer.GENERATED_ORDER: - mappings = this._generatedMappings; - break; - case SourceMapConsumer.ORIGINAL_ORDER: - mappings = this._originalMappings; - break; - default: - throw new Error("Unknown order of iteration."); - } - - var sourceRoot = this.sourceRoot; - mappings.map(function (mapping) { - var source = mapping.source === null ? null : this._sources.at(mapping.source); - if (source != null && sourceRoot != null) { - source = util.join(sourceRoot, source); - } - return { - source: source, - generatedLine: mapping.generatedLine, - generatedColumn: mapping.generatedColumn, - originalLine: mapping.originalLine, - originalColumn: mapping.originalColumn, - name: mapping.name === null ? null : this._names.at(mapping.name) - }; - }, this).forEach(aCallback, context); - }; - - /** - * 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. - * - column: Optional. the column number in the original source. - * - * and an array of objects is returned, each with the following properties: - * - * - line: The line number in the generated source, or null. - * - column: The column number in the generated source, or null. - */ - SourceMapConsumer.prototype.allGeneratedPositionsFor = - function SourceMapConsumer_allGeneratedPositionsFor(aArgs) { - var line = util.getArg(aArgs, 'line'); - - // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping - // returns the index of the closest mapping less than the needle. By - // setting needle.originalColumn to 0, we thus find the last mapping for - // the given line, provided such a mapping exists. - var needle = { - source: util.getArg(aArgs, 'source'), - originalLine: line, - originalColumn: util.getArg(aArgs, 'column', 0) - }; - - if (this.sourceRoot != null) { - needle.source = util.relative(this.sourceRoot, needle.source); - } - if (!this._sources.has(needle.source)) { - return []; - } - needle.source = this._sources.indexOf(needle.source); - - var mappings = []; - - var index = this._findMapping(needle, - this._originalMappings, - "originalLine", - "originalColumn", - util.compareByOriginalPositions, - binarySearch.LEAST_UPPER_BOUND); - if (index >= 0) { - var mapping = this._originalMappings[index]; - - if (aArgs.column === undefined) { - var originalLine = mapping.originalLine; - - // Iterate until either we run out of mappings, or we run into - // a mapping for a different line than the one we found. Since - // mappings are sorted, this is guaranteed to find all mappings for - // the line we found. - while (mapping && mapping.originalLine === originalLine) { - mappings.push({ - line: util.getArg(mapping, 'generatedLine', null), - column: util.getArg(mapping, 'generatedColumn', null), - lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null) - }); - - mapping = this._originalMappings[++index]; - } - } else { - var originalColumn = mapping.originalColumn; - - // Iterate until either we run out of mappings, or we run into - // a mapping for a different line than the one we were searching for. - // Since mappings are sorted, this is guaranteed to find all mappings for - // the line we are searching for. - while (mapping && - mapping.originalLine === line && - mapping.originalColumn == originalColumn) { - mappings.push({ - line: util.getArg(mapping, 'generatedLine', null), - column: util.getArg(mapping, 'generatedColumn', null), - lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null) - }); - - mapping = this._originalMappings[++index]; - } - } - } - - return mappings; - }; - - exports.SourceMapConsumer = SourceMapConsumer; - - /** - * A BasicSourceMapConsumer 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. - * - * The only parameter is the raw source map (either as a JSON string, or - * already parsed to 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 referrenced 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 file this source map is associated with. - * - * Here is an example source map, taken from the source map spec[0]: - * - * { - * version : 3, - * file: "out.js", - * sourceRoot : "", - * sources: ["foo.js", "bar.js"], - * names: ["src", "maps", "are", "fun"], - * mappings: "AA,AB;;ABCDE;" - * } - * - * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1# - */ - function BasicSourceMapConsumer(aSourceMap) { - var sourceMap = aSourceMap; - if (typeof aSourceMap === 'string') { - sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, '')); - } - - var version = util.getArg(sourceMap, 'version'); - var sources = util.getArg(sourceMap, 'sources'); - // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which - // requires the array) to play nice here. - var names = util.getArg(sourceMap, 'names', []); - var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null); - var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null); - var mappings = util.getArg(sourceMap, 'mappings'); - var file = util.getArg(sourceMap, 'file', null); - - // Once again, Sass deviates from the spec and supplies the version as a - // string rather than a number, so we use loose equality checking here. - if (version != this._version) { - throw new Error('Unsupported version: ' + version); - } - - sources = sources - // Some source maps produce relative source paths like "./foo.js" instead of - // "foo.js". Normalize these first so that future comparisons will succeed. - // See bugzil.la/1090768. - .map(util.normalize) - // Always ensure that absolute sources are internally stored relative to - // the source root, if the source root is absolute. Not doing this would - // be particularly problematic when the source root is a prefix of the - // source (valid, but why??). See github issue #199 and bugzil.la/1188982. - .map(function (source) { - return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source) - ? util.relative(sourceRoot, source) - : source; - }); - - // Pass `true` below to allow duplicate names and sources. While source maps - // are intended to be compressed and deduplicated, the TypeScript compiler - // sometimes generates source maps with duplicates in them. See Github issue - // #72 and bugzil.la/889492. - this._names = ArraySet.fromArray(names, true); - this._sources = ArraySet.fromArray(sources, true); - - this.sourceRoot = sourceRoot; - this.sourcesContent = sourcesContent; - this._mappings = mappings; - this.file = file; - } - - BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype); - BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer; - - /** - * Create a BasicSourceMapConsumer from a SourceMapGenerator. - * - * @param SourceMapGenerator aSourceMap - * The source map that will be consumed. - * @returns BasicSourceMapConsumer - */ - BasicSourceMapConsumer.fromSourceMap = - function SourceMapConsumer_fromSourceMap(aSourceMap) { - var smc = Object.create(BasicSourceMapConsumer.prototype); - - var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true); - var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true); - smc.sourceRoot = aSourceMap._sourceRoot; - smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(), - smc.sourceRoot); - smc.file = aSourceMap._file; - - // Because we are modifying the entries (by converting string sources and - // names to indices into the sources and names ArraySets), we have to make - // a copy of the entry or else bad things happen. Shared mutable state - // strikes again! See github issue #191. - - var generatedMappings = aSourceMap._mappings.toArray().slice(); - var destGeneratedMappings = smc.__generatedMappings = []; - var destOriginalMappings = smc.__originalMappings = []; - - for (var i = 0, length = generatedMappings.length; i < length; i++) { - var srcMapping = generatedMappings[i]; - var destMapping = new Mapping; - destMapping.generatedLine = srcMapping.generatedLine; - destMapping.generatedColumn = srcMapping.generatedColumn; - - if (srcMapping.source) { - destMapping.source = sources.indexOf(srcMapping.source); - destMapping.originalLine = srcMapping.originalLine; - destMapping.originalColumn = srcMapping.originalColumn; - - if (srcMapping.name) { - destMapping.name = names.indexOf(srcMapping.name); - } - - destOriginalMappings.push(destMapping); - } - - destGeneratedMappings.push(destMapping); - } - - quickSort(smc.__originalMappings, util.compareByOriginalPositions); - - return smc; - }; - - /** - * The version of the source mapping spec that we are consuming. - */ - BasicSourceMapConsumer.prototype._version = 3; - - /** - * The list of original sources. - */ - Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', { - get: function () { - return this._sources.toArray().map(function (s) { - return this.sourceRoot != null ? util.join(this.sourceRoot, s) : s; - }, this); - } - }); - - /** - * Provide the JIT with a nice shape / hidden class. - */ - function Mapping() { - this.generatedLine = 0; - this.generatedColumn = 0; - this.source = null; - this.originalLine = null; - this.originalColumn = null; - this.name = null; - } - - /** - * Parse the mappings in a string in to a data structure which we can easily - * query (the ordered arrays in the `this.__generatedMappings` and - * `this.__originalMappings` properties). - */ - BasicSourceMapConsumer.prototype._parseMappings = - function SourceMapConsumer_parseMappings(aStr, aSourceRoot) { - var generatedLine = 1; - var previousGeneratedColumn = 0; - var previousOriginalLine = 0; - var previousOriginalColumn = 0; - var previousSource = 0; - var previousName = 0; - var length = aStr.length; - var index = 0; - var cachedSegments = {}; - var temp = {}; - var originalMappings = []; - var generatedMappings = []; - var mapping, str, segment, end, value; - - while (index < length) { - if (aStr.charAt(index) === ';') { - generatedLine++; - index++; - previousGeneratedColumn = 0; - } - else if (aStr.charAt(index) === ',') { - index++; - } - else { - mapping = new Mapping(); - mapping.generatedLine = generatedLine; - - // Because each offset is encoded relative to the previous one, - // many segments often have the same encoding. We can exploit this - // fact by caching the parsed variable length fields of each segment, - // allowing us to avoid a second parse if we encounter the same - // segment again. - for (end = index; end < length; end++) { - if (this._charIsMappingSeparator(aStr, end)) { - break; - } - } - str = aStr.slice(index, end); - - segment = cachedSegments[str]; - if (segment) { - index += str.length; - } else { - segment = []; - while (index < end) { - base64VLQ.decode(aStr, index, temp); - value = temp.value; - index = temp.rest; - segment.push(value); - } - - if (segment.length === 2) { - throw new Error('Found a source, but no line and column'); - } - - if (segment.length === 3) { - throw new Error('Found a source and line, but no column'); - } - - cachedSegments[str] = segment; - } - - // Generated column. - mapping.generatedColumn = previousGeneratedColumn + segment[0]; - previousGeneratedColumn = mapping.generatedColumn; - - if (segment.length > 1) { - // Original source. - mapping.source = previousSource + segment[1]; - previousSource += segment[1]; - - // Original line. - mapping.originalLine = previousOriginalLine + segment[2]; - previousOriginalLine = mapping.originalLine; - // Lines are stored 0-based - mapping.originalLine += 1; - - // Original column. - mapping.originalColumn = previousOriginalColumn + segment[3]; - previousOriginalColumn = mapping.originalColumn; - - if (segment.length > 4) { - // Original name. - mapping.name = previousName + segment[4]; - previousName += segment[4]; - } - } - - generatedMappings.push(mapping); - if (typeof mapping.originalLine === 'number') { - originalMappings.push(mapping); - } - } - } - - quickSort(generatedMappings, util.compareByGeneratedPositionsDeflated); - this.__generatedMappings = generatedMappings; - - quickSort(originalMappings, util.compareByOriginalPositions); - this.__originalMappings = originalMappings; - }; - - /** - * Find the mapping that best matches the hypothetical "needle" mapping that - * we are searching for in the given "haystack" of mappings. - */ - BasicSourceMapConsumer.prototype._findMapping = - function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName, - aColumnName, aComparator, aBias) { - // To return the position we are searching for, we must first find the - // mapping for the given position and then return the opposite position it - // points to. Because the mappings are sorted, we can use binary search to - // find the best mapping. - - if (aNeedle[aLineName] <= 0) { - throw new TypeError('Line must be greater than or equal to 1, got ' - + aNeedle[aLineName]); - } - if (aNeedle[aColumnName] < 0) { - throw new TypeError('Column must be greater than or equal to 0, got ' - + aNeedle[aColumnName]); - } - - return binarySearch.search(aNeedle, aMappings, aComparator, aBias); - }; - - /** - * Compute the last column for each generated mapping. The last column is - * inclusive. - */ - BasicSourceMapConsumer.prototype.computeColumnSpans = - function SourceMapConsumer_computeColumnSpans() { - for (var index = 0; index < this._generatedMappings.length; ++index) { - var mapping = this._generatedMappings[index]; - - // Mappings do not contain a field for the last generated columnt. We - // can come up with an optimistic estimate, however, by assuming that - // mappings are contiguous (i.e. given two consecutive mappings, the - // first mapping ends where the second one starts). - if (index + 1 < this._generatedMappings.length) { - var nextMapping = this._generatedMappings[index + 1]; - - if (mapping.generatedLine === nextMapping.generatedLine) { - mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1; - continue; - } - } - - // The last mapping for each line spans the entire line. - mapping.lastGeneratedColumn = Infinity; - } - }; - - /** - * 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. - * - column: The column number in the generated source. - * - 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. - * - line: The line number in the original source, or null. - * - column: The column number in the original source, or null. - * - name: The original identifier, or null. - */ - BasicSourceMapConsumer.prototype.originalPositionFor = - function SourceMapConsumer_originalPositionFor(aArgs) { - var needle = { - generatedLine: util.getArg(aArgs, 'line'), - generatedColumn: util.getArg(aArgs, 'column') - }; - - var index = this._findMapping( - needle, - this._generatedMappings, - "generatedLine", - "generatedColumn", - util.compareByGeneratedPositionsDeflated, - util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND) - ); - - if (index >= 0) { - var mapping = this._generatedMappings[index]; - - if (mapping.generatedLine === needle.generatedLine) { - var source = util.getArg(mapping, 'source', null); - if (source !== null) { - source = this._sources.at(source); - if (this.sourceRoot != null) { - source = util.join(this.sourceRoot, source); - } - } - var name = util.getArg(mapping, 'name', null); - if (name !== null) { - name = this._names.at(name); - } - return { - source: source, - line: util.getArg(mapping, 'originalLine', null), - column: util.getArg(mapping, 'originalColumn', null), - name: name - }; - } - } - - return { - source: null, - line: null, - column: null, - name: null - }; - }; - - /** - * Return true if we have the source content for every source in the source - * map, false otherwise. - */ - BasicSourceMapConsumer.prototype.hasContentsOfAllSources = - function BasicSourceMapConsumer_hasContentsOfAllSources() { - if (!this.sourcesContent) { - return false; - } - return this.sourcesContent.length >= this._sources.size() && - !this.sourcesContent.some(function (sc) { return sc == null; }); - }; - - /** - * Returns the original source content. The only argument is the url of the - * original source file. Returns null if no original source content is - * available. - */ - BasicSourceMapConsumer.prototype.sourceContentFor = - function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) { - if (!this.sourcesContent) { - return null; - } - - if (this.sourceRoot != null) { - aSource = util.relative(this.sourceRoot, aSource); - } - - if (this._sources.has(aSource)) { - return this.sourcesContent[this._sources.indexOf(aSource)]; - } - - var url; - if (this.sourceRoot != null - && (url = util.urlParse(this.sourceRoot))) { - // XXX: file:// URIs and absolute paths lead to unexpected behavior for - // many users. We can help them out when they expect file:// URIs to - // behave like it would if they were running a local HTTP server. See - // https://bugzilla.mozilla.org/show_bug.cgi?id=885597. - var fileUriAbsPath = aSource.replace(/^file:\/\//, ""); - if (url.scheme == "file" - && this._sources.has(fileUriAbsPath)) { - return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)] - } - - if ((!url.path || url.path == "/") - && this._sources.has("/" + aSource)) { - return this.sourcesContent[this._sources.indexOf("/" + aSource)]; - } - } - - // This function is used recursively from - // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we - // don't want to throw if we can't find the source - we just want to - // return null, so we provide a flag to exit gracefully. - if (nullOnMissing) { - return null; - } - else { - throw new Error('"' + aSource + '" is not in the SourceMap.'); - } - }; - - /** - * 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. - * - column: The column number in the original source. - * - 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: - * - * - line: The line number in the generated source, or null. - * - column: The column number in the generated source, or null. - */ - BasicSourceMapConsumer.prototype.generatedPositionFor = - function SourceMapConsumer_generatedPositionFor(aArgs) { - var source = util.getArg(aArgs, 'source'); - if (this.sourceRoot != null) { - source = util.relative(this.sourceRoot, source); - } - if (!this._sources.has(source)) { - return { - line: null, - column: null, - lastColumn: null - }; - } - source = this._sources.indexOf(source); - - var needle = { - source: source, - originalLine: util.getArg(aArgs, 'line'), - originalColumn: util.getArg(aArgs, 'column') - }; - - var index = this._findMapping( - needle, - this._originalMappings, - "originalLine", - "originalColumn", - util.compareByOriginalPositions, - util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND) - ); - - if (index >= 0) { - var mapping = this._originalMappings[index]; - - if (mapping.source === needle.source) { - return { - line: util.getArg(mapping, 'generatedLine', null), - column: util.getArg(mapping, 'generatedColumn', null), - lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null) - }; - } - } - - return { - line: null, - column: null, - lastColumn: null - }; - }; - - exports.BasicSourceMapConsumer = BasicSourceMapConsumer; - - /** - * An IndexedSourceMapConsumer instance represents a parsed source map which - * we can query for information. It differs from BasicSourceMapConsumer in - * that it takes "indexed" source maps (i.e. ones with a "sections" field) as - * input. - * - * The only parameter is a raw source map (either as a JSON string, or already - * parsed to an object). According to the spec for indexed source maps, they - * have the following attributes: - * - * - version: Which version of the source map spec this map is following. - * - file: Optional. The generated file this source map is associated with. - * - sections: A list of section definitions. - * - * Each value under the "sections" field has two fields: - * - offset: The offset into the original specified at which this section - * begins to apply, defined as an object with a "line" and "column" - * field. - * - map: A source map definition. This source map could also be indexed, - * but doesn't have to be. - * - * Instead of the "map" field, it's also possible to have a "url" field - * specifying a URL to retrieve a source map from, but that's currently - * unsupported. - * - * Here's an example source map, taken from the source map spec[0], but - * modified to omit a section which uses the "url" field. - * - * { - * version : 3, - * file: "app.js", - * sections: [{ - * offset: {line:100, column:10}, - * map: { - * version : 3, - * file: "section.js", - * sources: ["foo.js", "bar.js"], - * names: ["src", "maps", "are", "fun"], - * mappings: "AAAA,E;;ABCDE;" - * } - * }], - * } - * - * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt - */ - function IndexedSourceMapConsumer(aSourceMap) { - var sourceMap = aSourceMap; - if (typeof aSourceMap === 'string') { - sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, '')); - } - - var version = util.getArg(sourceMap, 'version'); - var sections = util.getArg(sourceMap, 'sections'); - - if (version != this._version) { - throw new Error('Unsupported version: ' + version); - } - - this._sources = new ArraySet(); - this._names = new ArraySet(); - - var lastOffset = { - line: -1, - column: 0 - }; - this._sections = sections.map(function (s) { - if (s.url) { - // The url field will require support for asynchronicity. - // See https://github.com/mozilla/source-map/issues/16 - throw new Error('Support for url field in sections not implemented.'); - } - var offset = util.getArg(s, 'offset'); - var offsetLine = util.getArg(offset, 'line'); - var offsetColumn = util.getArg(offset, 'column'); - - if (offsetLine < lastOffset.line || - (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) { - throw new Error('Section offsets must be ordered and non-overlapping.'); - } - lastOffset = offset; - - return { - generatedOffset: { - // The offset fields are 0-based, but we use 1-based indices when - // encoding/decoding from VLQ. - generatedLine: offsetLine + 1, - generatedColumn: offsetColumn + 1 - }, - consumer: new SourceMapConsumer(util.getArg(s, 'map')) - } - }); - } - - IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype); - IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer; - - /** - * The version of the source mapping spec that we are consuming. - */ - IndexedSourceMapConsumer.prototype._version = 3; - - /** - * The list of original sources. - */ - Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', { - get: function () { - var sources = []; - for (var i = 0; i < this._sections.length; i++) { - for (var j = 0; j < this._sections[i].consumer.sources.length; j++) { - sources.push(this._sections[i].consumer.sources[j]); - } - } - return sources; - } - }); - - /** - * 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. - * - column: The column number in the generated source. - * - * and an object is returned with the following properties: - * - * - source: The original source file, or null. - * - line: The line number in the original source, or null. - * - column: The column number in the original source, or null. - * - name: The original identifier, or null. - */ - IndexedSourceMapConsumer.prototype.originalPositionFor = - function IndexedSourceMapConsumer_originalPositionFor(aArgs) { - var needle = { - generatedLine: util.getArg(aArgs, 'line'), - generatedColumn: util.getArg(aArgs, 'column') - }; - - // Find the section containing the generated position we're trying to map - // to an original position. - var sectionIndex = binarySearch.search(needle, this._sections, - function(needle, section) { - var cmp = needle.generatedLine - section.generatedOffset.generatedLine; - if (cmp) { - return cmp; - } - - return (needle.generatedColumn - - section.generatedOffset.generatedColumn); - }); - var section = this._sections[sectionIndex]; - - if (!section) { - return { - source: null, - line: null, - column: null, - name: null - }; - } - - return section.consumer.originalPositionFor({ - line: needle.generatedLine - - (section.generatedOffset.generatedLine - 1), - column: needle.generatedColumn - - (section.generatedOffset.generatedLine === needle.generatedLine - ? section.generatedOffset.generatedColumn - 1 - : 0), - bias: aArgs.bias - }); - }; - - /** - * Return true if we have the source content for every source in the source - * map, false otherwise. - */ - IndexedSourceMapConsumer.prototype.hasContentsOfAllSources = - function IndexedSourceMapConsumer_hasContentsOfAllSources() { - return this._sections.every(function (s) { - return s.consumer.hasContentsOfAllSources(); - }); - }; - - /** - * Returns the original source content. The only argument is the url of the - * original source file. Returns null if no original source content is - * available. - */ - IndexedSourceMapConsumer.prototype.sourceContentFor = - function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) { - for (var i = 0; i < this._sections.length; i++) { - var section = this._sections[i]; - - var content = section.consumer.sourceContentFor(aSource, true); - if (content) { - return content; - } - } - if (nullOnMissing) { - return null; - } - else { - throw new Error('"' + aSource + '" is not in the SourceMap.'); - } - }; - - /** - * 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. - * - column: The column number in the original source. - * - * and an object is returned with the following properties: - * - * - line: The line number in the generated source, or null. - * - column: The column number in the generated source, or null. - */ - IndexedSourceMapConsumer.prototype.generatedPositionFor = - function IndexedSourceMapConsumer_generatedPositionFor(aArgs) { - for (var i = 0; i < this._sections.length; i++) { - var section = this._sections[i]; - - // Only consider this section if the requested source is in the list of - // sources of the consumer. - if (section.consumer.sources.indexOf(util.getArg(aArgs, 'source')) === -1) { - continue; - } - var generatedPosition = section.consumer.generatedPositionFor(aArgs); - if (generatedPosition) { - var ret = { - line: generatedPosition.line + - (section.generatedOffset.generatedLine - 1), - column: generatedPosition.column + - (section.generatedOffset.generatedLine === generatedPosition.line - ? section.generatedOffset.generatedColumn - 1 - : 0) - }; - return ret; - } - } - - return { - line: null, - column: null - }; - }; - - /** - * Parse the mappings in a string in to a data structure which we can easily - * query (the ordered arrays in the `this.__generatedMappings` and - * `this.__originalMappings` properties). - */ - IndexedSourceMapConsumer.prototype._parseMappings = - function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) { - this.__generatedMappings = []; - this.__originalMappings = []; - for (var i = 0; i < this._sections.length; i++) { - var section = this._sections[i]; - var sectionMappings = section.consumer._generatedMappings; - for (var j = 0; j < sectionMappings.length; j++) { - var mapping = sectionMappings[j]; - - var source = section.consumer._sources.at(mapping.source); - if (section.consumer.sourceRoot !== null) { - source = util.join(section.consumer.sourceRoot, source); - } - this._sources.add(source); - source = this._sources.indexOf(source); - - var name = section.consumer._names.at(mapping.name); - this._names.add(name); - name = this._names.indexOf(name); - - // The mappings coming from the consumer for the section have - // generated positions relative to the start of the section, so we - // need to offset them to be relative to the start of the concatenated - // generated file. - var adjustedMapping = { - source: source, - generatedLine: mapping.generatedLine + - (section.generatedOffset.generatedLine - 1), - generatedColumn: mapping.generatedColumn + - (section.generatedOffset.generatedLine === mapping.generatedLine - ? section.generatedOffset.generatedColumn - 1 - : 0), - originalLine: mapping.originalLine, - originalColumn: mapping.originalColumn, - name: name - }; - - this.__generatedMappings.push(adjustedMapping); - if (typeof adjustedMapping.originalLine === 'number') { - this.__originalMappings.push(adjustedMapping); - } - } - } - - quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated); - quickSort(this.__originalMappings, util.compareByOriginalPositions); - }; - - exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer; -} - -},{"597":597,"598":598,"600":600,"602":602,"606":606}],604:[function(_dereq_,module,exports){ -/* -*- 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 = _dereq_(598); - var util = _dereq_(606); - var ArraySet = _dereq_(597).ArraySet; - var MappingList = _dereq_(601).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 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 && !this._sources.has(source)) { - this._sources.add(source); - } - - if (name != null && !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 = {}; - } - 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) { - 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 mapping; - var nameIdx; - var sourceIdx; - - var mappings = this._mappings.toArray(); - for (var i = 0, len = mappings.length; i < len; i++) { - mapping = mappings[i]; - - if (mapping.generatedLine !== previousGeneratedLine) { - previousGeneratedColumn = 0; - while (mapping.generatedLine !== previousGeneratedLine) { - result += ';'; - previousGeneratedLine++; - } - } - else { - if (i > 0) { - if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) { - continue; - } - result += ','; - } - } - - result += base64VLQ.encode(mapping.generatedColumn - - previousGeneratedColumn); - previousGeneratedColumn = mapping.generatedColumn; - - if (mapping.source != null) { - sourceIdx = this._sources.indexOf(mapping.source); - result += base64VLQ.encode(sourceIdx - previousSource); - previousSource = sourceIdx; - - // lines are stored 0-based in SourceMap spec version 3 - result += base64VLQ.encode(mapping.originalLine - 1 - - previousOriginalLine); - previousOriginalLine = mapping.originalLine - 1; - - result += base64VLQ.encode(mapping.originalColumn - - previousOriginalColumn); - previousOriginalColumn = mapping.originalColumn; - - if (mapping.name != null) { - nameIdx = this._names.indexOf(mapping.name); - result += base64VLQ.encode(nameIdx - previousName); - previousName = nameIdx; - } - } - } - - 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; -} - -},{"597":597,"598":598,"601":601,"606":606}],605:[function(_dereq_,module,exports){ -/* -*- 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 = _dereq_(604).SourceMapGenerator; - var util = _dereq_(606); - - // 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 removed from this array, by calling `shiftNextLine`. - var remainingLines = aGeneratedCode.split(REGEX_NEWLINE); - var shiftNextLine = function() { - var lineContents = remainingLines.shift(); - // The last line of a file might not have a newline. - var newLine = remainingLines.shift() || ""; - return lineContents + newLine; - }; - - // 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[0]; - var code = nextLine.substr(0, mapping.generatedColumn - - lastGeneratedColumn); - remainingLines[0] = 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[0]; - node.add(nextLine.substr(0, mapping.generatedColumn)); - remainingLines[0] = nextLine.substr(mapping.generatedColumn); - lastGeneratedColumn = mapping.generatedColumn; - } - lastMapping = mapping; - }, this); - // We have processed all mappings. - if (remainingLines.length > 0) { - 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.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; -} - -},{"604":604,"606":606}],606:[function(_dereq_,module,exports){ -/* -*- 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+))?(\S*)$/; - 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 consequtive slashes with one slash. - * - Removes unnecessary '.' parts. - * - Removes unnecessary '/..' 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) === '/' || !!aPath.match(urlRegexp); - }; - - /** - * 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; - - /** - * 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) { - return '$' + aStr; - } - exports.toSetString = toSetString; - - function fromSetString(aStr) { - return aStr.substr(1); - } - exports.fromSetString = fromSetString; - - /** - * 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 = 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 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 = 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 mappingA.name - mappingB.name; - } - exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated; - - function strcmp(aStr1, aStr2) { - if (aStr1 === aStr2) { - return 0; - } - - 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; -} - -},{}],607:[function(_dereq_,module,exports){ -/* - * 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 = _dereq_(604).SourceMapGenerator; -exports.SourceMapConsumer = _dereq_(603).SourceMapConsumer; -exports.SourceNode = _dereq_(605).SourceNode; - -},{"603":603,"604":604,"605":605}],608:[function(_dereq_,module,exports){ -'use strict'; -module.exports = function toFastProperties(obj) { - /*jshint -W027*/ - function f() {} - f.prototype = obj; - new f(); - return; - eval(obj); -}; - -},{}],609:[function(_dereq_,module,exports){ -'use strict'; -module.exports = function (str) { - var tail = str.length; - - while (/[\s\uFEFF\u00A0]/.test(str[tail - 1])) { - tail--; + /** + * 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; + }; + +/***/ }), +/* 609 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + /* -*- 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 = __webpack_require__(61); + + /** + * 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; } - return str.slice(0, tail); -}; - -},{}],610:[function(_dereq_,module,exports){ -(function (process){ -var Module = _dereq_(1); - -var resolve = module.exports = function (loc, _require) { - try { - return (_require || _dereq_).resolve(loc); - } catch (err) { - return null; - } -}; - -var relativeMod; - -resolve.relative = function (loc) { - // we're in the browser, probably - if (typeof Module === "object") return null; - - if (!relativeMod) { - relativeMod = new Module; - relativeMod.paths = Module._nodeModulePaths(process.cwd()); - } - - try { - return Module._resolveFilename(loc, relativeMod); - } catch (err) { - return null; - } -}; - -}).call(this,_dereq_(10)) -},{"1":1,"10":10}],611:[function(_dereq_,module,exports){ -module.exports={ - "name": "babel-core", - "version": "5.8.34", - "description": "A compiler for writing next generation JavaScript", - "author": "Sebastian McKenzie ", - "homepage": "https://babeljs.io/", - "license": "MIT", - "repository": "babel/babel", - "browser": { - "./lib/api/register/node.js": "./lib/api/register/browser.js" - }, - "keywords": [ - "6to5", - "babel", - "classes", - "const", - "es6", - "harmony", - "let", - "modules", - "transpile", - "transpiler", - "var" - ], - "scripts": { - "bench": "make bench", - "test": "make test" - }, - "dependencies": { - "babel-plugin-constant-folding": "^1.0.1", - "babel-plugin-dead-code-elimination": "^1.0.2", - "babel-plugin-eval": "^1.0.1", - "babel-plugin-inline-environment-variables": "^1.0.1", - "babel-plugin-jscript": "^1.0.4", - "babel-plugin-member-expression-literals": "^1.0.1", - "babel-plugin-property-literals": "^1.0.1", - "babel-plugin-proto-to-assign": "^1.0.3", - "babel-plugin-react-constant-elements": "^1.0.3", - "babel-plugin-react-display-name": "^1.0.3", - "babel-plugin-remove-console": "^1.0.1", - "babel-plugin-remove-debugger": "^1.0.1", - "babel-plugin-runtime": "^1.0.7", - "babel-plugin-undeclared-variables-check": "^1.0.2", - "babel-plugin-undefined-to-void": "^1.1.6", - "babylon": "^5.8.34", - "bluebird": "^2.9.33", - "chalk": "^1.0.0", - "convert-source-map": "^1.1.0", - "core-js": "^1.0.0", - "debug": "^2.1.1", - "detect-indent": "^3.0.0", - "esutils": "^2.0.0", - "fs-readdir-recursive": "^0.1.0", - "globals": "^6.4.0", - "home-or-tmp": "^1.0.0", - "is-integer": "^1.0.4", - "js-tokens": "1.0.1", - "json5": "^0.4.0", - "line-numbers": "0.2.0", - "lodash": "^3.10.0", - "minimatch": "^2.0.3", - "output-file-sync": "^1.1.0", - "path-exists": "^1.0.0", - "path-is-absolute": "^1.0.0", - "private": "^0.1.6", - "regenerator": "0.8.40", - "regexpu": "^1.3.0", - "repeating": "^1.1.2", - "resolve": "^1.1.6", - "shebang-regex": "^1.0.0", - "slash": "^1.0.0", - "source-map": "^0.5.0", - "source-map-support": "^0.2.10", - "to-fast-properties": "^1.0.0", - "trim-right": "^1.0.0", - "try-resolve": "^1.0.0" - } -} -},{}],612:[function(_dereq_,module,exports){ -module.exports={"abstract-expression-call":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"PROPERTY"},"property":{"type":"MemberExpression","object":{"type":"Identifier","name":"Symbol"},"property":{"type":"Identifier","name":"referenceGet"},"computed":false},"computed":true},"arguments":[{"type":"Identifier","name":"OBJECT"}]},"property":{"type":"Identifier","name":"call"},"computed":false},"arguments":[{"type":"Identifier","name":"OBJECT"}]}}]},"abstract-expression-delete":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"PROPERTY"},"property":{"type":"MemberExpression","object":{"type":"Identifier","name":"Symbol"},"property":{"type":"Identifier","name":"referenceDelete"},"computed":false},"computed":true},"arguments":[{"type":"Identifier","name":"OBJECT"}]}}]},"abstract-expression-get":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"PROPERTY"},"property":{"type":"MemberExpression","object":{"type":"Identifier","name":"Symbol"},"property":{"type":"Identifier","name":"referenceGet"},"computed":false},"computed":true},"arguments":[{"type":"Identifier","name":"OBJECT"}]}}]},"abstract-expression-set":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"PROPERTY"},"property":{"type":"MemberExpression","object":{"type":"Identifier","name":"Symbol"},"property":{"type":"Identifier","name":"referenceSet"},"computed":false},"computed":true},"arguments":[{"type":"Identifier","name":"OBJECT"},{"type":"Identifier","name":"VALUE"}]}}]},"array-comprehension-container":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[],"body":{"type":"BlockStatement","body":[{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"KEY"},"init":{"type":"ArrayExpression","elements":[]}}],"kind":"var"},{"type":"ReturnStatement","argument":{"type":"Identifier","name":"KEY"}}]},"parenthesizedExpression":true},"arguments":[]}}]},"array-from":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"Array"},"property":{"type":"Identifier","name":"from"},"computed":false},"arguments":[{"type":"Identifier","name":"VALUE"}]}}]},"array-push":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"KEY"},"property":{"type":"Identifier","name":"push"},"computed":false},"arguments":[{"type":"Identifier","name":"STATEMENT"}]}}]},"call":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"OBJECT"},"property":{"type":"Identifier","name":"call"},"computed":false},"arguments":[{"type":"Identifier","name":"CONTEXT"}]}}]},"class-decorator":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"Identifier","name":"CLASS_REF"},"right":{"type":"LogicalExpression","left":{"type":"CallExpression","callee":{"type":"Identifier","name":"DECORATOR"},"arguments":[{"type":"Identifier","name":"CLASS_REF"}]},"operator":"||","right":{"type":"Identifier","name":"CLASS_REF"}}}}]},"class-derived-default-constructor":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[],"body":{"type":"BlockStatement","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"Super"},"arguments":[{"type":"SpreadElement","argument":{"type":"Identifier","name":"arguments"}}]}}]},"parenthesizedExpression":true}}]},"default-parameter-assign":{"type":"Program","body":[{"type":"IfStatement","test":{"type":"BinaryExpression","left":{"type":"Identifier","name":"VARIABLE_NAME"},"operator":"===","right":{"type":"Identifier","name":"undefined"}},"consequent":{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"Identifier","name":"VARIABLE_NAME"},"right":{"type":"Identifier","name":"DEFAULT_VALUE"}}},"alternate":null}]},"default-parameter":{"type":"Program","body":[{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"VARIABLE_NAME"},"init":{"type":"ConditionalExpression","test":{"type":"LogicalExpression","left":{"type":"BinaryExpression","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"ARGUMENTS"},"property":{"type":"Identifier","name":"length"},"computed":false},"operator":"<=","right":{"type":"Identifier","name":"ARGUMENT_KEY"}},"operator":"||","right":{"type":"BinaryExpression","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"ARGUMENTS"},"property":{"type":"Identifier","name":"ARGUMENT_KEY"},"computed":true},"operator":"===","right":{"type":"Identifier","name":"undefined"}}},"consequent":{"type":"Identifier","name":"DEFAULT_VALUE"},"alternate":{"type":"MemberExpression","object":{"type":"Identifier","name":"ARGUMENTS"},"property":{"type":"Identifier","name":"ARGUMENT_KEY"},"computed":true}}}],"kind":"let"}]},"exports-assign":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"exports"},"property":{"type":"Identifier","name":"KEY"},"computed":false},"right":{"type":"Identifier","name":"VALUE"}}}]},"exports-default-assign":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"module"},"property":{"type":"Identifier","name":"exports"},"computed":false},"right":{"type":"Identifier","name":"VALUE"}}}]},"exports-from-assign":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"Object"},"property":{"type":"Identifier","name":"defineProperty"},"computed":false},"arguments":[{"type":"Identifier","name":"exports"},{"type":"Identifier","name":"ID"},{"type":"ObjectExpression","properties":[{"type":"Property","method":false,"shorthand":false,"computed":false,"key":{"type":"Identifier","name":"enumerable"},"value":{"type":"Literal","value":true},"kind":"init"},{"type":"Property","method":false,"shorthand":false,"computed":false,"key":{"type":"Identifier","name":"get"},"value":{"type":"FunctionExpression","id":{"type":"Identifier","name":"get"},"generator":false,"expression":false,"params":[],"body":{"type":"BlockStatement","body":[{"type":"ReturnStatement","argument":{"type":"Identifier","name":"INIT"}}]}},"kind":"init"}]}]}}]},"exports-module-declaration-loose":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"exports"},"property":{"type":"Identifier","name":"__esModule"},"computed":false},"right":{"type":"Literal","value":true}}}]},"exports-module-declaration":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"Object"},"property":{"type":"Identifier","name":"defineProperty"},"computed":false},"arguments":[{"type":"Identifier","name":"exports"},{"type":"Literal","value":"__esModule"},{"type":"ObjectExpression","properties":[{"type":"Property","method":false,"shorthand":false,"computed":false,"key":{"type":"Identifier","name":"value"},"value":{"type":"Literal","value":true},"kind":"init"}]}]}}]},"for-of-array":{"type":"Program","body":[{"type":"ForStatement","init":{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"KEY"},"init":{"type":"Literal","value":0}}],"kind":"var"},"test":{"type":"BinaryExpression","left":{"type":"Identifier","name":"KEY"},"operator":"<","right":{"type":"MemberExpression","object":{"type":"Identifier","name":"ARR"},"property":{"type":"Identifier","name":"length"},"computed":false}},"update":{"type":"UpdateExpression","operator":"++","prefix":false,"argument":{"type":"Identifier","name":"KEY"}},"body":{"type":"ExpressionStatement","expression":{"type":"Identifier","name":"BODY"}}}]},"for-of-loose":{"type":"Program","body":[{"type":"ForStatement","init":{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"LOOP_OBJECT"},"init":{"type":"Identifier","name":"OBJECT"}},{"type":"VariableDeclarator","id":{"type":"Identifier","name":"IS_ARRAY"},"init":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"Array"},"property":{"type":"Identifier","name":"isArray"},"computed":false},"arguments":[{"type":"Identifier","name":"LOOP_OBJECT"}]}},{"type":"VariableDeclarator","id":{"type":"Identifier","name":"INDEX"},"init":{"type":"Literal","value":0}},{"type":"VariableDeclarator","id":{"type":"Identifier","name":"LOOP_OBJECT"},"init":{"type":"ConditionalExpression","test":{"type":"Identifier","name":"IS_ARRAY"},"consequent":{"type":"Identifier","name":"LOOP_OBJECT"},"alternate":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"LOOP_OBJECT"},"property":{"type":"MemberExpression","object":{"type":"Identifier","name":"Symbol"},"property":{"type":"Identifier","name":"iterator"},"computed":false},"computed":true},"arguments":[]}}}],"kind":"var"},"test":null,"update":null,"body":{"type":"BlockStatement","body":[{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"ID"},"init":null}],"kind":"var"},{"type":"IfStatement","test":{"type":"Identifier","name":"IS_ARRAY"},"consequent":{"type":"BlockStatement","body":[{"type":"IfStatement","test":{"type":"BinaryExpression","left":{"type":"Identifier","name":"INDEX"},"operator":">=","right":{"type":"MemberExpression","object":{"type":"Identifier","name":"LOOP_OBJECT"},"property":{"type":"Identifier","name":"length"},"computed":false}},"consequent":{"type":"BreakStatement","label":null},"alternate":null},{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"Identifier","name":"ID"},"right":{"type":"MemberExpression","object":{"type":"Identifier","name":"LOOP_OBJECT"},"property":{"type":"UpdateExpression","operator":"++","prefix":false,"argument":{"type":"Identifier","name":"INDEX"}},"computed":true}}}]},"alternate":{"type":"BlockStatement","body":[{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"Identifier","name":"INDEX"},"right":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"LOOP_OBJECT"},"property":{"type":"Identifier","name":"next"},"computed":false},"arguments":[]}}},{"type":"IfStatement","test":{"type":"MemberExpression","object":{"type":"Identifier","name":"INDEX"},"property":{"type":"Identifier","name":"done"},"computed":false},"consequent":{"type":"BreakStatement","label":null},"alternate":null},{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"Identifier","name":"ID"},"right":{"type":"MemberExpression","object":{"type":"Identifier","name":"INDEX"},"property":{"type":"Identifier","name":"value"},"computed":false}}}]}}]}}]},"for-of":{"type":"Program","body":[{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"ITERATOR_COMPLETION"},"init":{"type":"Literal","value":true}}],"kind":"var"},{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"ITERATOR_HAD_ERROR_KEY"},"init":{"type":"Literal","value":false}}],"kind":"var"},{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"ITERATOR_ERROR_KEY"},"init":{"type":"Identifier","name":"undefined"}}],"kind":"var"},{"type":"TryStatement","block":{"type":"BlockStatement","body":[{"type":"ForStatement","init":{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"ITERATOR_KEY"},"init":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"OBJECT"},"property":{"type":"MemberExpression","object":{"type":"Identifier","name":"Symbol"},"property":{"type":"Identifier","name":"iterator"},"computed":false},"computed":true},"arguments":[]}},{"type":"VariableDeclarator","id":{"type":"Identifier","name":"STEP_KEY"},"init":null}],"kind":"var"},"test":{"type":"UnaryExpression","operator":"!","prefix":true,"argument":{"type":"AssignmentExpression","operator":"=","left":{"type":"Identifier","name":"ITERATOR_COMPLETION"},"right":{"type":"MemberExpression","object":{"type":"AssignmentExpression","operator":"=","left":{"type":"Identifier","name":"STEP_KEY"},"right":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"ITERATOR_KEY"},"property":{"type":"Identifier","name":"next"},"computed":false},"arguments":[]},"parenthesizedExpression":true},"property":{"type":"Identifier","name":"done"},"computed":false},"parenthesizedExpression":true}},"update":{"type":"AssignmentExpression","operator":"=","left":{"type":"Identifier","name":"ITERATOR_COMPLETION"},"right":{"type":"Literal","value":true}},"body":{"type":"BlockStatement","body":[]}}]},"handler":{"type":"CatchClause","param":{"type":"Identifier","name":"err"},"body":{"type":"BlockStatement","body":[{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"Identifier","name":"ITERATOR_HAD_ERROR_KEY"},"right":{"type":"Literal","value":true}}},{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"Identifier","name":"ITERATOR_ERROR_KEY"},"right":{"type":"Identifier","name":"err"}}}]}},"guardedHandlers":[],"finalizer":{"type":"BlockStatement","body":[{"type":"TryStatement","block":{"type":"BlockStatement","body":[{"type":"IfStatement","test":{"type":"LogicalExpression","left":{"type":"UnaryExpression","operator":"!","prefix":true,"argument":{"type":"Identifier","name":"ITERATOR_COMPLETION"}},"operator":"&&","right":{"type":"MemberExpression","object":{"type":"Identifier","name":"ITERATOR_KEY"},"property":{"type":"Literal","value":"return"},"computed":true}},"consequent":{"type":"BlockStatement","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"ITERATOR_KEY"},"property":{"type":"Literal","value":"return"},"computed":true},"arguments":[]}}]},"alternate":null}]},"handler":null,"guardedHandlers":[],"finalizer":{"type":"BlockStatement","body":[{"type":"IfStatement","test":{"type":"Identifier","name":"ITERATOR_HAD_ERROR_KEY"},"consequent":{"type":"BlockStatement","body":[{"type":"ThrowStatement","argument":{"type":"Identifier","name":"ITERATOR_ERROR_KEY"}}]},"alternate":null}]}}]}}]},"helper-async-to-generator":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"fn"}],"body":{"type":"BlockStatement","body":[{"type":"ReturnStatement","argument":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[],"body":{"type":"BlockStatement","body":[{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"gen"},"init":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"fn"},"property":{"type":"Identifier","name":"apply"},"computed":false},"arguments":[{"type":"ThisExpression"},{"type":"Identifier","name":"arguments"}]}}],"kind":"var"},{"type":"ReturnStatement","argument":{"type":"NewExpression","callee":{"type":"Identifier","name":"Promise"},"arguments":[{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"resolve"},{"type":"Identifier","name":"reject"}],"body":{"type":"BlockStatement","body":[{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"callNext"},"init":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"step"},"property":{"type":"Identifier","name":"bind"},"computed":false},"arguments":[{"type":"Literal","value":null,"rawValue":null},{"type":"Literal","value":"next"}]}}],"kind":"var"},{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"callThrow"},"init":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"step"},"property":{"type":"Identifier","name":"bind"},"computed":false},"arguments":[{"type":"Literal","value":null,"rawValue":null},{"type":"Literal","value":"throw"}]}}],"kind":"var"},{"type":"FunctionDeclaration","id":{"type":"Identifier","name":"step"},"generator":false,"expression":false,"params":[{"type":"Identifier","name":"key"},{"type":"Identifier","name":"arg"}],"body":{"type":"BlockStatement","body":[{"type":"TryStatement","block":{"type":"BlockStatement","body":[{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"info"},"init":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"gen"},"property":{"type":"Identifier","name":"key"},"computed":true},"arguments":[{"type":"Identifier","name":"arg"}]}}],"kind":"var"},{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"value"},"init":{"type":"MemberExpression","object":{"type":"Identifier","name":"info"},"property":{"type":"Identifier","name":"value"},"computed":false}}],"kind":"var"}]},"handler":{"type":"CatchClause","param":{"type":"Identifier","name":"error"},"body":{"type":"BlockStatement","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"Identifier","name":"reject"},"arguments":[{"type":"Identifier","name":"error"}]}},{"type":"ReturnStatement","argument":null}]}},"guardedHandlers":[],"finalizer":null},{"type":"IfStatement","test":{"type":"MemberExpression","object":{"type":"Identifier","name":"info"},"property":{"type":"Identifier","name":"done"},"computed":false},"consequent":{"type":"BlockStatement","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"Identifier","name":"resolve"},"arguments":[{"type":"Identifier","name":"value"}]}}]},"alternate":{"type":"BlockStatement","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"Promise"},"property":{"type":"Identifier","name":"resolve"},"computed":false},"arguments":[{"type":"Identifier","name":"value"}]},"property":{"type":"Identifier","name":"then"},"computed":false},"arguments":[{"type":"Identifier","name":"callNext"},{"type":"Identifier","name":"callThrow"}]}}]}}]}},{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"Identifier","name":"callNext"},"arguments":[]}}]}}]}}]}}}]},"parenthesizedExpression":true}}]},"helper-bind":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"MemberExpression","object":{"type":"MemberExpression","object":{"type":"Identifier","name":"Function"},"property":{"type":"Identifier","name":"prototype"},"computed":false},"property":{"type":"Identifier","name":"bind"},"computed":false}}]},"helper-class-call-check":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"instance"},{"type":"Identifier","name":"Constructor"}],"body":{"type":"BlockStatement","body":[{"type":"IfStatement","test":{"type":"UnaryExpression","operator":"!","prefix":true,"argument":{"type":"BinaryExpression","left":{"type":"Identifier","name":"instance"},"operator":"instanceof","right":{"type":"Identifier","name":"Constructor"},"parenthesizedExpression":true}},"consequent":{"type":"BlockStatement","body":[{"type":"ThrowStatement","argument":{"type":"NewExpression","callee":{"type":"Identifier","name":"TypeError"},"arguments":[{"type":"Literal","value":"Cannot call a class as a function"}]}}]},"alternate":null}]},"parenthesizedExpression":true}}]},"helper-create-class":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[],"body":{"type":"BlockStatement","body":[{"type":"FunctionDeclaration","id":{"type":"Identifier","name":"defineProperties"},"generator":false,"expression":false,"params":[{"type":"Identifier","name":"target"},{"type":"Identifier","name":"props"}],"body":{"type":"BlockStatement","body":[{"type":"ForStatement","init":{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"i"},"init":{"type":"Literal","value":0}}],"kind":"var"},"test":{"type":"BinaryExpression","left":{"type":"Identifier","name":"i"},"operator":"<","right":{"type":"MemberExpression","object":{"type":"Identifier","name":"props"},"property":{"type":"Identifier","name":"length"},"computed":false}},"update":{"type":"UpdateExpression","operator":"++","prefix":false,"argument":{"type":"Identifier","name":"i"}},"body":{"type":"BlockStatement","body":[{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"descriptor"},"init":{"type":"MemberExpression","object":{"type":"Identifier","name":"props"},"property":{"type":"Identifier","name":"i"},"computed":true}}],"kind":"var"},{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor"},"property":{"type":"Identifier","name":"enumerable"},"computed":false},"right":{"type":"LogicalExpression","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor"},"property":{"type":"Identifier","name":"enumerable"},"computed":false},"operator":"||","right":{"type":"Literal","value":false}}}},{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor"},"property":{"type":"Identifier","name":"configurable"},"computed":false},"right":{"type":"Literal","value":true}}},{"type":"IfStatement","test":{"type":"BinaryExpression","left":{"type":"Literal","value":"value"},"operator":"in","right":{"type":"Identifier","name":"descriptor"}},"consequent":{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor"},"property":{"type":"Identifier","name":"writable"},"computed":false},"right":{"type":"Literal","value":true}}},"alternate":null},{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"Object"},"property":{"type":"Identifier","name":"defineProperty"},"computed":false},"arguments":[{"type":"Identifier","name":"target"},{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor"},"property":{"type":"Identifier","name":"key"},"computed":false},{"type":"Identifier","name":"descriptor"}]}}]}}]}},{"type":"ReturnStatement","argument":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"Constructor"},{"type":"Identifier","name":"protoProps"},{"type":"Identifier","name":"staticProps"}],"body":{"type":"BlockStatement","body":[{"type":"IfStatement","test":{"type":"Identifier","name":"protoProps"},"consequent":{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"Identifier","name":"defineProperties"},"arguments":[{"type":"MemberExpression","object":{"type":"Identifier","name":"Constructor"},"property":{"type":"Identifier","name":"prototype"},"computed":false},{"type":"Identifier","name":"protoProps"}]}},"alternate":null},{"type":"IfStatement","test":{"type":"Identifier","name":"staticProps"},"consequent":{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"Identifier","name":"defineProperties"},"arguments":[{"type":"Identifier","name":"Constructor"},{"type":"Identifier","name":"staticProps"}]}},"alternate":null},{"type":"ReturnStatement","argument":{"type":"Identifier","name":"Constructor"}}]}}}]},"parenthesizedExpression":true},"arguments":[]}}]},"helper-create-decorated-class":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[],"body":{"type":"BlockStatement","body":[{"type":"FunctionDeclaration","id":{"type":"Identifier","name":"defineProperties"},"generator":false,"expression":false,"params":[{"type":"Identifier","name":"target"},{"type":"Identifier","name":"descriptors"},{"type":"Identifier","name":"initializers"}],"body":{"type":"BlockStatement","body":[{"type":"ForStatement","init":{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"i"},"init":{"type":"Literal","value":0}}],"kind":"var"},"test":{"type":"BinaryExpression","left":{"type":"Identifier","name":"i"},"operator":"<","right":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptors"},"property":{"type":"Identifier","name":"length"},"computed":false}},"update":{"type":"UpdateExpression","operator":"++","prefix":false,"argument":{"type":"Identifier","name":"i"}},"body":{"type":"BlockStatement","body":[{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"descriptor"},"init":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptors"},"property":{"type":"Identifier","name":"i"},"computed":true}}],"kind":"var"},{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"decorators"},"init":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor"},"property":{"type":"Identifier","name":"decorators"},"computed":false}}],"kind":"var"},{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"key"},"init":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor"},"property":{"type":"Identifier","name":"key"},"computed":false}}],"kind":"var"},{"type":"ExpressionStatement","expression":{"type":"UnaryExpression","operator":"delete","prefix":true,"argument":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor","leadingComments":null},"property":{"type":"Identifier","name":"key"},"computed":false,"leadingComments":null},"leadingComments":null}},{"type":"ExpressionStatement","expression":{"type":"UnaryExpression","operator":"delete","prefix":true,"argument":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor"},"property":{"type":"Identifier","name":"decorators"},"computed":false}}},{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor"},"property":{"type":"Identifier","name":"enumerable"},"computed":false},"right":{"type":"LogicalExpression","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor"},"property":{"type":"Identifier","name":"enumerable"},"computed":false},"operator":"||","right":{"type":"Literal","value":false}}}},{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor"},"property":{"type":"Identifier","name":"configurable"},"computed":false},"right":{"type":"Literal","value":true}}},{"type":"IfStatement","test":{"type":"LogicalExpression","left":{"type":"BinaryExpression","left":{"type":"Literal","value":"value"},"operator":"in","right":{"type":"Identifier","name":"descriptor"}},"operator":"||","right":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor"},"property":{"type":"Identifier","name":"initializer"},"computed":false}},"consequent":{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor"},"property":{"type":"Identifier","name":"writable"},"computed":false},"right":{"type":"Literal","value":true}}},"alternate":null},{"type":"IfStatement","test":{"type":"Identifier","name":"decorators"},"consequent":{"type":"BlockStatement","body":[{"type":"ForStatement","init":{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"f"},"init":{"type":"Literal","value":0}}],"kind":"var"},"test":{"type":"BinaryExpression","left":{"type":"Identifier","name":"f"},"operator":"<","right":{"type":"MemberExpression","object":{"type":"Identifier","name":"decorators"},"property":{"type":"Identifier","name":"length"},"computed":false}},"update":{"type":"UpdateExpression","operator":"++","prefix":false,"argument":{"type":"Identifier","name":"f"}},"body":{"type":"BlockStatement","body":[{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"decorator"},"init":{"type":"MemberExpression","object":{"type":"Identifier","name":"decorators"},"property":{"type":"Identifier","name":"f"},"computed":true}}],"kind":"var"},{"type":"IfStatement","test":{"type":"BinaryExpression","left":{"type":"UnaryExpression","operator":"typeof","prefix":true,"argument":{"type":"Identifier","name":"decorator"}},"operator":"===","right":{"type":"Literal","value":"function"}},"consequent":{"type":"BlockStatement","body":[{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"Identifier","name":"descriptor"},"right":{"type":"LogicalExpression","left":{"type":"CallExpression","callee":{"type":"Identifier","name":"decorator"},"arguments":[{"type":"Identifier","name":"target"},{"type":"Identifier","name":"key"},{"type":"Identifier","name":"descriptor"}]},"operator":"||","right":{"type":"Identifier","name":"descriptor"}}}}]},"alternate":{"type":"BlockStatement","body":[{"type":"ThrowStatement","argument":{"type":"NewExpression","callee":{"type":"Identifier","name":"TypeError"},"arguments":[{"type":"BinaryExpression","left":{"type":"BinaryExpression","left":{"type":"BinaryExpression","left":{"type":"Literal","value":"The decorator for method "},"operator":"+","right":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor"},"property":{"type":"Identifier","name":"key"},"computed":false}},"operator":"+","right":{"type":"Literal","value":" is of the invalid type "}},"operator":"+","right":{"type":"UnaryExpression","operator":"typeof","prefix":true,"argument":{"type":"Identifier","name":"decorator"}}}]}}]}}]}},{"type":"IfStatement","test":{"type":"BinaryExpression","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor"},"property":{"type":"Identifier","name":"initializer"},"computed":false},"operator":"!==","right":{"type":"Identifier","name":"undefined"}},"consequent":{"type":"BlockStatement","body":[{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"initializers"},"property":{"type":"Identifier","name":"key"},"computed":true},"right":{"type":"Identifier","name":"descriptor"}}},{"type":"ContinueStatement","label":null}]},"alternate":null}]},"alternate":null},{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"Object"},"property":{"type":"Identifier","name":"defineProperty"},"computed":false},"arguments":[{"type":"Identifier","name":"target"},{"type":"Identifier","name":"key"},{"type":"Identifier","name":"descriptor"}]}}]}}]}},{"type":"ReturnStatement","argument":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"Constructor"},{"type":"Identifier","name":"protoProps"},{"type":"Identifier","name":"staticProps"},{"type":"Identifier","name":"protoInitializers"},{"type":"Identifier","name":"staticInitializers"}],"body":{"type":"BlockStatement","body":[{"type":"IfStatement","test":{"type":"Identifier","name":"protoProps"},"consequent":{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"Identifier","name":"defineProperties"},"arguments":[{"type":"MemberExpression","object":{"type":"Identifier","name":"Constructor"},"property":{"type":"Identifier","name":"prototype"},"computed":false},{"type":"Identifier","name":"protoProps"},{"type":"Identifier","name":"protoInitializers"}]}},"alternate":null},{"type":"IfStatement","test":{"type":"Identifier","name":"staticProps"},"consequent":{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"Identifier","name":"defineProperties"},"arguments":[{"type":"Identifier","name":"Constructor"},{"type":"Identifier","name":"staticProps"},{"type":"Identifier","name":"staticInitializers"}]}},"alternate":null},{"type":"ReturnStatement","argument":{"type":"Identifier","name":"Constructor"}}]}}}]},"parenthesizedExpression":true},"arguments":[]}}]},"helper-create-decorated-object":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"descriptors"}],"body":{"type":"BlockStatement","body":[{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"target"},"init":{"type":"ObjectExpression","properties":[]}}],"kind":"var"},{"type":"ForStatement","init":{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"i"},"init":{"type":"Literal","value":0}}],"kind":"var"},"test":{"type":"BinaryExpression","left":{"type":"Identifier","name":"i"},"operator":"<","right":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptors"},"property":{"type":"Identifier","name":"length"},"computed":false}},"update":{"type":"UpdateExpression","operator":"++","prefix":false,"argument":{"type":"Identifier","name":"i"}},"body":{"type":"BlockStatement","body":[{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"descriptor"},"init":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptors"},"property":{"type":"Identifier","name":"i"},"computed":true}}],"kind":"var"},{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"decorators"},"init":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor"},"property":{"type":"Identifier","name":"decorators"},"computed":false}}],"kind":"var"},{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"key"},"init":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor"},"property":{"type":"Identifier","name":"key"},"computed":false}}],"kind":"var"},{"type":"ExpressionStatement","expression":{"type":"UnaryExpression","operator":"delete","prefix":true,"argument":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor","leadingComments":null},"property":{"type":"Identifier","name":"key"},"computed":false,"leadingComments":null},"leadingComments":null}},{"type":"ExpressionStatement","expression":{"type":"UnaryExpression","operator":"delete","prefix":true,"argument":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor"},"property":{"type":"Identifier","name":"decorators"},"computed":false}}},{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor"},"property":{"type":"Identifier","name":"enumerable"},"computed":false},"right":{"type":"Literal","value":true}}},{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor"},"property":{"type":"Identifier","name":"configurable"},"computed":false},"right":{"type":"Literal","value":true}}},{"type":"IfStatement","test":{"type":"LogicalExpression","left":{"type":"BinaryExpression","left":{"type":"Literal","value":"value"},"operator":"in","right":{"type":"Identifier","name":"descriptor"}},"operator":"||","right":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor"},"property":{"type":"Identifier","name":"initializer"},"computed":false}},"consequent":{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor"},"property":{"type":"Identifier","name":"writable"},"computed":false},"right":{"type":"Literal","value":true}}},"alternate":null},{"type":"IfStatement","test":{"type":"Identifier","name":"decorators"},"consequent":{"type":"BlockStatement","body":[{"type":"ForStatement","init":{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"f"},"init":{"type":"Literal","value":0}}],"kind":"var"},"test":{"type":"BinaryExpression","left":{"type":"Identifier","name":"f"},"operator":"<","right":{"type":"MemberExpression","object":{"type":"Identifier","name":"decorators"},"property":{"type":"Identifier","name":"length"},"computed":false}},"update":{"type":"UpdateExpression","operator":"++","prefix":false,"argument":{"type":"Identifier","name":"f"}},"body":{"type":"BlockStatement","body":[{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"decorator"},"init":{"type":"MemberExpression","object":{"type":"Identifier","name":"decorators"},"property":{"type":"Identifier","name":"f"},"computed":true}}],"kind":"var"},{"type":"IfStatement","test":{"type":"BinaryExpression","left":{"type":"UnaryExpression","operator":"typeof","prefix":true,"argument":{"type":"Identifier","name":"decorator"}},"operator":"===","right":{"type":"Literal","value":"function"}},"consequent":{"type":"BlockStatement","body":[{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"Identifier","name":"descriptor"},"right":{"type":"LogicalExpression","left":{"type":"CallExpression","callee":{"type":"Identifier","name":"decorator"},"arguments":[{"type":"Identifier","name":"target"},{"type":"Identifier","name":"key"},{"type":"Identifier","name":"descriptor"}]},"operator":"||","right":{"type":"Identifier","name":"descriptor"}}}}]},"alternate":{"type":"BlockStatement","body":[{"type":"ThrowStatement","argument":{"type":"NewExpression","callee":{"type":"Identifier","name":"TypeError"},"arguments":[{"type":"BinaryExpression","left":{"type":"BinaryExpression","left":{"type":"BinaryExpression","left":{"type":"Literal","value":"The decorator for method "},"operator":"+","right":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor"},"property":{"type":"Identifier","name":"key"},"computed":false}},"operator":"+","right":{"type":"Literal","value":" is of the invalid type "}},"operator":"+","right":{"type":"UnaryExpression","operator":"typeof","prefix":true,"argument":{"type":"Identifier","name":"decorator"}}}]}}]}}]}}]},"alternate":null},{"type":"IfStatement","test":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor"},"property":{"type":"Identifier","name":"initializer"},"computed":false},"consequent":{"type":"BlockStatement","body":[{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor"},"property":{"type":"Identifier","name":"value"},"computed":false},"right":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor"},"property":{"type":"Identifier","name":"initializer"},"computed":false},"property":{"type":"Identifier","name":"call"},"computed":false},"arguments":[{"type":"Identifier","name":"target"}]}}}]},"alternate":null},{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"Object"},"property":{"type":"Identifier","name":"defineProperty"},"computed":false},"arguments":[{"type":"Identifier","name":"target"},{"type":"Identifier","name":"key"},{"type":"Identifier","name":"descriptor"}]}}]}},{"type":"ReturnStatement","argument":{"type":"Identifier","name":"target"}}]},"parenthesizedExpression":true}}]},"helper-default-props":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"defaultProps"},{"type":"Identifier","name":"props"}],"body":{"type":"BlockStatement","body":[{"type":"IfStatement","test":{"type":"Identifier","name":"defaultProps"},"consequent":{"type":"BlockStatement","body":[{"type":"ForInStatement","left":{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"propName"},"init":null}],"kind":"var"},"right":{"type":"Identifier","name":"defaultProps"},"body":{"type":"BlockStatement","body":[{"type":"IfStatement","test":{"type":"BinaryExpression","left":{"type":"UnaryExpression","operator":"typeof","prefix":true,"argument":{"type":"MemberExpression","object":{"type":"Identifier","name":"props"},"property":{"type":"Identifier","name":"propName"},"computed":true}},"operator":"===","right":{"type":"Literal","value":"undefined"}},"consequent":{"type":"BlockStatement","body":[{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"props"},"property":{"type":"Identifier","name":"propName"},"computed":true},"right":{"type":"MemberExpression","object":{"type":"Identifier","name":"defaultProps"},"property":{"type":"Identifier","name":"propName"},"computed":true}}}]},"alternate":null}]}}]},"alternate":null},{"type":"ReturnStatement","argument":{"type":"Identifier","name":"props"}}]},"parenthesizedExpression":true}}]},"helper-defaults":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"obj"},{"type":"Identifier","name":"defaults"}],"body":{"type":"BlockStatement","body":[{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"keys"},"init":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"Object"},"property":{"type":"Identifier","name":"getOwnPropertyNames"},"computed":false},"arguments":[{"type":"Identifier","name":"defaults"}]}}],"kind":"var"},{"type":"ForStatement","init":{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"i"},"init":{"type":"Literal","value":0}}],"kind":"var"},"test":{"type":"BinaryExpression","left":{"type":"Identifier","name":"i"},"operator":"<","right":{"type":"MemberExpression","object":{"type":"Identifier","name":"keys"},"property":{"type":"Identifier","name":"length"},"computed":false}},"update":{"type":"UpdateExpression","operator":"++","prefix":false,"argument":{"type":"Identifier","name":"i"}},"body":{"type":"BlockStatement","body":[{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"key"},"init":{"type":"MemberExpression","object":{"type":"Identifier","name":"keys"},"property":{"type":"Identifier","name":"i"},"computed":true}}],"kind":"var"},{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"value"},"init":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"Object"},"property":{"type":"Identifier","name":"getOwnPropertyDescriptor"},"computed":false},"arguments":[{"type":"Identifier","name":"defaults"},{"type":"Identifier","name":"key"}]}}],"kind":"var"},{"type":"IfStatement","test":{"type":"LogicalExpression","left":{"type":"LogicalExpression","left":{"type":"Identifier","name":"value"},"operator":"&&","right":{"type":"MemberExpression","object":{"type":"Identifier","name":"value"},"property":{"type":"Identifier","name":"configurable"},"computed":false}},"operator":"&&","right":{"type":"BinaryExpression","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"obj"},"property":{"type":"Identifier","name":"key"},"computed":true},"operator":"===","right":{"type":"Identifier","name":"undefined"}}},"consequent":{"type":"BlockStatement","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"Object"},"property":{"type":"Identifier","name":"defineProperty"},"computed":false},"arguments":[{"type":"Identifier","name":"obj"},{"type":"Identifier","name":"key"},{"type":"Identifier","name":"value"}]}}]},"alternate":null}]}},{"type":"ReturnStatement","argument":{"type":"Identifier","name":"obj"}}]},"parenthesizedExpression":true}}]},"helper-define-decorated-property-descriptor":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"target"},{"type":"Identifier","name":"key"},{"type":"Identifier","name":"descriptors"}],"body":{"type":"BlockStatement","body":[{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"_descriptor"},"init":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptors"},"property":{"type":"Identifier","name":"key"},"computed":true}}],"kind":"var"},{"type":"IfStatement","test":{"type":"UnaryExpression","operator":"!","prefix":true,"argument":{"type":"Identifier","name":"_descriptor"}},"consequent":{"type":"ReturnStatement","argument":null,"leadingComments":null,"trailingComments":null},"alternate":null},{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"descriptor","leadingComments":null},"init":{"type":"ObjectExpression","properties":[]},"leadingComments":null}],"kind":"var"},{"type":"ForInStatement","left":{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"_key"},"init":null}],"kind":"var"},"right":{"type":"Identifier","name":"_descriptor"},"body":{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor"},"property":{"type":"Identifier","name":"_key"},"computed":true},"right":{"type":"MemberExpression","object":{"type":"Identifier","name":"_descriptor"},"property":{"type":"Identifier","name":"_key"},"computed":true}},"trailingComments":null}},{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor","leadingComments":null},"property":{"type":"Identifier","name":"value"},"computed":false,"leadingComments":null},"right":{"type":"ConditionalExpression","test":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor"},"property":{"type":"Identifier","name":"initializer"},"computed":false},"consequent":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"MemberExpression","object":{"type":"Identifier","name":"descriptor"},"property":{"type":"Identifier","name":"initializer"},"computed":false},"property":{"type":"Identifier","name":"call"},"computed":false},"arguments":[{"type":"Identifier","name":"target"}]},"alternate":{"type":"Identifier","name":"undefined"}},"leadingComments":null}},{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"Object"},"property":{"type":"Identifier","name":"defineProperty"},"computed":false},"arguments":[{"type":"Identifier","name":"target"},{"type":"Identifier","name":"key"},{"type":"Identifier","name":"descriptor"}]}}]},"parenthesizedExpression":true}}]},"helper-define-property":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"obj"},{"type":"Identifier","name":"key"},{"type":"Identifier","name":"value"}],"body":{"type":"BlockStatement","body":[{"type":"IfStatement","test":{"type":"BinaryExpression","left":{"type":"Identifier","name":"key","leadingComments":null},"operator":"in","right":{"type":"Identifier","name":"obj"},"leadingComments":null},"consequent":{"type":"BlockStatement","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"Object"},"property":{"type":"Identifier","name":"defineProperty"},"computed":false},"arguments":[{"type":"Identifier","name":"obj"},{"type":"Identifier","name":"key"},{"type":"ObjectExpression","properties":[{"type":"Property","method":false,"shorthand":false,"computed":false,"key":{"type":"Identifier","name":"value"},"value":{"type":"Identifier","name":"value"},"kind":"init"},{"type":"Property","method":false,"shorthand":false,"computed":false,"key":{"type":"Identifier","name":"enumerable"},"value":{"type":"Literal","value":true},"kind":"init"},{"type":"Property","method":false,"shorthand":false,"computed":false,"key":{"type":"Identifier","name":"configurable"},"value":{"type":"Literal","value":true},"kind":"init"},{"type":"Property","method":false,"shorthand":false,"computed":false,"key":{"type":"Identifier","name":"writable"},"value":{"type":"Literal","value":true},"kind":"init"}]}]}}]},"alternate":{"type":"BlockStatement","body":[{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"obj"},"property":{"type":"Identifier","name":"key"},"computed":true},"right":{"type":"Identifier","name":"value"}}}]}},{"type":"ReturnStatement","argument":{"type":"Identifier","name":"obj"}}]},"parenthesizedExpression":true}}]},"helper-extends":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"LogicalExpression","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"Object"},"property":{"type":"Identifier","name":"assign"},"computed":false},"operator":"||","right":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"target"}],"body":{"type":"BlockStatement","body":[{"type":"ForStatement","init":{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"i"},"init":{"type":"Literal","value":1}}],"kind":"var"},"test":{"type":"BinaryExpression","left":{"type":"Identifier","name":"i"},"operator":"<","right":{"type":"MemberExpression","object":{"type":"Identifier","name":"arguments"},"property":{"type":"Identifier","name":"length"},"computed":false}},"update":{"type":"UpdateExpression","operator":"++","prefix":false,"argument":{"type":"Identifier","name":"i"}},"body":{"type":"BlockStatement","body":[{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"source"},"init":{"type":"MemberExpression","object":{"type":"Identifier","name":"arguments"},"property":{"type":"Identifier","name":"i"},"computed":true}}],"kind":"var"},{"type":"ForInStatement","left":{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"key"},"init":null}],"kind":"var"},"right":{"type":"Identifier","name":"source"},"body":{"type":"BlockStatement","body":[{"type":"IfStatement","test":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"MemberExpression","object":{"type":"MemberExpression","object":{"type":"Identifier","name":"Object"},"property":{"type":"Identifier","name":"prototype"},"computed":false},"property":{"type":"Identifier","name":"hasOwnProperty"},"computed":false},"property":{"type":"Identifier","name":"call"},"computed":false},"arguments":[{"type":"Identifier","name":"source"},{"type":"Identifier","name":"key"}]},"consequent":{"type":"BlockStatement","body":[{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"target"},"property":{"type":"Identifier","name":"key"},"computed":true},"right":{"type":"MemberExpression","object":{"type":"Identifier","name":"source"},"property":{"type":"Identifier","name":"key"},"computed":true}}}]},"alternate":null}]}}]}},{"type":"ReturnStatement","argument":{"type":"Identifier","name":"target"}}]}}}}]},"helper-get":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"FunctionExpression","id":{"type":"Identifier","name":"get"},"generator":false,"expression":false,"params":[{"type":"Identifier","name":"object"},{"type":"Identifier","name":"property"},{"type":"Identifier","name":"receiver"}],"body":{"type":"BlockStatement","body":[{"type":"IfStatement","test":{"type":"BinaryExpression","left":{"type":"Identifier","name":"object"},"operator":"===","right":{"type":"Literal","value":null,"rawValue":null}},"consequent":{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"Identifier","name":"object"},"right":{"type":"MemberExpression","object":{"type":"Identifier","name":"Function"},"property":{"type":"Identifier","name":"prototype"},"computed":false}}},"alternate":null},{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"desc"},"init":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"Object"},"property":{"type":"Identifier","name":"getOwnPropertyDescriptor"},"computed":false},"arguments":[{"type":"Identifier","name":"object"},{"type":"Identifier","name":"property"}]}}],"kind":"var"},{"type":"IfStatement","test":{"type":"BinaryExpression","left":{"type":"Identifier","name":"desc"},"operator":"===","right":{"type":"Identifier","name":"undefined"}},"consequent":{"type":"BlockStatement","body":[{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"parent"},"init":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"Object"},"property":{"type":"Identifier","name":"getPrototypeOf"},"computed":false},"arguments":[{"type":"Identifier","name":"object"}]}}],"kind":"var"},{"type":"IfStatement","test":{"type":"BinaryExpression","left":{"type":"Identifier","name":"parent"},"operator":"===","right":{"type":"Literal","value":null,"rawValue":null}},"consequent":{"type":"BlockStatement","body":[{"type":"ReturnStatement","argument":{"type":"Identifier","name":"undefined"}}]},"alternate":{"type":"BlockStatement","body":[{"type":"ReturnStatement","argument":{"type":"CallExpression","callee":{"type":"Identifier","name":"get"},"arguments":[{"type":"Identifier","name":"parent"},{"type":"Identifier","name":"property"},{"type":"Identifier","name":"receiver"}]}}]}}]},"alternate":{"type":"IfStatement","test":{"type":"BinaryExpression","left":{"type":"Literal","value":"value"},"operator":"in","right":{"type":"Identifier","name":"desc"}},"consequent":{"type":"BlockStatement","body":[{"type":"ReturnStatement","argument":{"type":"MemberExpression","object":{"type":"Identifier","name":"desc"},"property":{"type":"Identifier","name":"value"},"computed":false}}]},"alternate":{"type":"BlockStatement","body":[{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"getter"},"init":{"type":"MemberExpression","object":{"type":"Identifier","name":"desc"},"property":{"type":"Identifier","name":"get"},"computed":false}}],"kind":"var"},{"type":"IfStatement","test":{"type":"BinaryExpression","left":{"type":"Identifier","name":"getter"},"operator":"===","right":{"type":"Identifier","name":"undefined"}},"consequent":{"type":"BlockStatement","body":[{"type":"ReturnStatement","argument":{"type":"Identifier","name":"undefined"}}]},"alternate":null},{"type":"ReturnStatement","argument":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"getter"},"property":{"type":"Identifier","name":"call"},"computed":false},"arguments":[{"type":"Identifier","name":"receiver"}]}}]}}}]},"parenthesizedExpression":true}}]},"helper-has-own":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"MemberExpression","object":{"type":"MemberExpression","object":{"type":"Identifier","name":"Object"},"property":{"type":"Identifier","name":"prototype"},"computed":false},"property":{"type":"Identifier","name":"hasOwnProperty"},"computed":false}}]},"helper-inherits":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"subClass"},{"type":"Identifier","name":"superClass"}],"body":{"type":"BlockStatement","body":[{"type":"IfStatement","test":{"type":"LogicalExpression","left":{"type":"BinaryExpression","left":{"type":"UnaryExpression","operator":"typeof","prefix":true,"argument":{"type":"Identifier","name":"superClass"}},"operator":"!==","right":{"type":"Literal","value":"function"}},"operator":"&&","right":{"type":"BinaryExpression","left":{"type":"Identifier","name":"superClass"},"operator":"!==","right":{"type":"Literal","value":null,"rawValue":null}}},"consequent":{"type":"BlockStatement","body":[{"type":"ThrowStatement","argument":{"type":"NewExpression","callee":{"type":"Identifier","name":"TypeError"},"arguments":[{"type":"BinaryExpression","left":{"type":"Literal","value":"Super expression must either be null or a function, not "},"operator":"+","right":{"type":"UnaryExpression","operator":"typeof","prefix":true,"argument":{"type":"Identifier","name":"superClass"}}}]}}]},"alternate":null},{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"subClass"},"property":{"type":"Identifier","name":"prototype"},"computed":false},"right":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"Object"},"property":{"type":"Identifier","name":"create"},"computed":false},"arguments":[{"type":"LogicalExpression","left":{"type":"Identifier","name":"superClass"},"operator":"&&","right":{"type":"MemberExpression","object":{"type":"Identifier","name":"superClass"},"property":{"type":"Identifier","name":"prototype"},"computed":false}},{"type":"ObjectExpression","properties":[{"type":"Property","method":false,"shorthand":false,"computed":false,"key":{"type":"Identifier","name":"constructor"},"value":{"type":"ObjectExpression","properties":[{"type":"Property","method":false,"shorthand":false,"computed":false,"key":{"type":"Identifier","name":"value"},"value":{"type":"Identifier","name":"subClass"},"kind":"init"},{"type":"Property","method":false,"shorthand":false,"computed":false,"key":{"type":"Identifier","name":"enumerable"},"value":{"type":"Literal","value":false},"kind":"init"},{"type":"Property","method":false,"shorthand":false,"computed":false,"key":{"type":"Identifier","name":"writable"},"value":{"type":"Literal","value":true},"kind":"init"},{"type":"Property","method":false,"shorthand":false,"computed":false,"key":{"type":"Identifier","name":"configurable"},"value":{"type":"Literal","value":true},"kind":"init"}]},"kind":"init"}]}]}}},{"type":"IfStatement","test":{"type":"Identifier","name":"superClass"},"consequent":{"type":"ExpressionStatement","expression":{"type":"ConditionalExpression","test":{"type":"MemberExpression","object":{"type":"Identifier","name":"Object"},"property":{"type":"Identifier","name":"setPrototypeOf"},"computed":false},"consequent":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"Object"},"property":{"type":"Identifier","name":"setPrototypeOf"},"computed":false},"arguments":[{"type":"Identifier","name":"subClass"},{"type":"Identifier","name":"superClass"}]},"alternate":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"subClass"},"property":{"type":"Identifier","name":"__proto__"},"computed":false},"right":{"type":"Identifier","name":"superClass"}}}},"alternate":null}]},"parenthesizedExpression":true}}]},"helper-instanceof":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"left"},{"type":"Identifier","name":"right"}],"body":{"type":"BlockStatement","body":[{"type":"IfStatement","test":{"type":"LogicalExpression","left":{"type":"BinaryExpression","left":{"type":"Identifier","name":"right"},"operator":"!=","right":{"type":"Literal","value":null,"rawValue":null}},"operator":"&&","right":{"type":"MemberExpression","object":{"type":"Identifier","name":"right"},"property":{"type":"MemberExpression","object":{"type":"Identifier","name":"Symbol"},"property":{"type":"Identifier","name":"hasInstance"},"computed":false},"computed":true}},"consequent":{"type":"BlockStatement","body":[{"type":"ReturnStatement","argument":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"right"},"property":{"type":"MemberExpression","object":{"type":"Identifier","name":"Symbol"},"property":{"type":"Identifier","name":"hasInstance"},"computed":false},"computed":true},"arguments":[{"type":"Identifier","name":"left"}]}}]},"alternate":{"type":"BlockStatement","body":[{"type":"ReturnStatement","argument":{"type":"BinaryExpression","left":{"type":"Identifier","name":"left"},"operator":"instanceof","right":{"type":"Identifier","name":"right"}}}]}}]},"parenthesizedExpression":true}}]},"helper-interop-export-wildcard":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"obj"},{"type":"Identifier","name":"defaults"}],"body":{"type":"BlockStatement","body":[{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"newObj"},"init":{"type":"CallExpression","callee":{"type":"Identifier","name":"defaults"},"arguments":[{"type":"ObjectExpression","properties":[]},{"type":"Identifier","name":"obj"}]}}],"kind":"var"},{"type":"ExpressionStatement","expression":{"type":"UnaryExpression","operator":"delete","prefix":true,"argument":{"type":"MemberExpression","object":{"type":"Identifier","name":"newObj"},"property":{"type":"Literal","value":"default"},"computed":true}}},{"type":"ReturnStatement","argument":{"type":"Identifier","name":"newObj"}}]},"parenthesizedExpression":true}}]},"helper-interop-require-default":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"obj"}],"body":{"type":"BlockStatement","body":[{"type":"ReturnStatement","argument":{"type":"ConditionalExpression","test":{"type":"LogicalExpression","left":{"type":"Identifier","name":"obj"},"operator":"&&","right":{"type":"MemberExpression","object":{"type":"Identifier","name":"obj"},"property":{"type":"Identifier","name":"__esModule"},"computed":false}},"consequent":{"type":"Identifier","name":"obj"},"alternate":{"type":"ObjectExpression","properties":[{"type":"Property","method":false,"shorthand":false,"computed":false,"key":{"type":"Literal","value":"default"},"value":{"type":"Identifier","name":"obj"},"kind":"init"}]}}}]},"parenthesizedExpression":true}}]},"helper-interop-require-wildcard":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"obj"}],"body":{"type":"BlockStatement","body":[{"type":"IfStatement","test":{"type":"LogicalExpression","left":{"type":"Identifier","name":"obj"},"operator":"&&","right":{"type":"MemberExpression","object":{"type":"Identifier","name":"obj"},"property":{"type":"Identifier","name":"__esModule"},"computed":false}},"consequent":{"type":"BlockStatement","body":[{"type":"ReturnStatement","argument":{"type":"Identifier","name":"obj"}}]},"alternate":{"type":"BlockStatement","body":[{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"newObj"},"init":{"type":"ObjectExpression","properties":[]}}],"kind":"var"},{"type":"IfStatement","test":{"type":"BinaryExpression","left":{"type":"Identifier","name":"obj"},"operator":"!=","right":{"type":"Literal","value":null,"rawValue":null}},"consequent":{"type":"BlockStatement","body":[{"type":"ForInStatement","left":{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"key"},"init":null}],"kind":"var"},"right":{"type":"Identifier","name":"obj"},"body":{"type":"BlockStatement","body":[{"type":"IfStatement","test":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"MemberExpression","object":{"type":"MemberExpression","object":{"type":"Identifier","name":"Object"},"property":{"type":"Identifier","name":"prototype"},"computed":false},"property":{"type":"Identifier","name":"hasOwnProperty"},"computed":false},"property":{"type":"Identifier","name":"call"},"computed":false},"arguments":[{"type":"Identifier","name":"obj"},{"type":"Identifier","name":"key"}]},"consequent":{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"newObj"},"property":{"type":"Identifier","name":"key"},"computed":true},"right":{"type":"MemberExpression","object":{"type":"Identifier","name":"obj"},"property":{"type":"Identifier","name":"key"},"computed":true}}},"alternate":null}]}}]},"alternate":null},{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"newObj"},"property":{"type":"Literal","value":"default"},"computed":true},"right":{"type":"Identifier","name":"obj"}}},{"type":"ReturnStatement","argument":{"type":"Identifier","name":"newObj"}}]}}]},"parenthesizedExpression":true}}]},"helper-interop-require":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"obj"}],"body":{"type":"BlockStatement","body":[{"type":"ReturnStatement","argument":{"type":"ConditionalExpression","test":{"type":"LogicalExpression","left":{"type":"Identifier","name":"obj"},"operator":"&&","right":{"type":"MemberExpression","object":{"type":"Identifier","name":"obj"},"property":{"type":"Identifier","name":"__esModule"},"computed":false}},"consequent":{"type":"MemberExpression","object":{"type":"Identifier","name":"obj"},"property":{"type":"Literal","value":"default"},"computed":true},"alternate":{"type":"Identifier","name":"obj"}}}]},"parenthesizedExpression":true}}]},"helper-new-arrow-check":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"innerThis"},{"type":"Identifier","name":"boundThis"}],"body":{"type":"BlockStatement","body":[{"type":"IfStatement","test":{"type":"BinaryExpression","left":{"type":"Identifier","name":"innerThis"},"operator":"!==","right":{"type":"Identifier","name":"boundThis"}},"consequent":{"type":"BlockStatement","body":[{"type":"ThrowStatement","argument":{"type":"NewExpression","callee":{"type":"Identifier","name":"TypeError"},"arguments":[{"type":"Literal","value":"Cannot instantiate an arrow function"}]}}]},"alternate":null}]},"parenthesizedExpression":true}}]},"helper-object-destructuring-empty":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"obj"}],"body":{"type":"BlockStatement","body":[{"type":"IfStatement","test":{"type":"BinaryExpression","left":{"type":"Identifier","name":"obj"},"operator":"==","right":{"type":"Literal","value":null,"rawValue":null}},"consequent":{"type":"ThrowStatement","argument":{"type":"NewExpression","callee":{"type":"Identifier","name":"TypeError"},"arguments":[{"type":"Literal","value":"Cannot destructure undefined"}]}},"alternate":null}]},"parenthesizedExpression":true}}]},"helper-object-without-properties":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"obj"},{"type":"Identifier","name":"keys"}],"body":{"type":"BlockStatement","body":[{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"target"},"init":{"type":"ObjectExpression","properties":[]}}],"kind":"var"},{"type":"ForInStatement","left":{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"i"},"init":null}],"kind":"var"},"right":{"type":"Identifier","name":"obj"},"body":{"type":"BlockStatement","body":[{"type":"IfStatement","test":{"type":"BinaryExpression","left":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"keys"},"property":{"type":"Identifier","name":"indexOf"},"computed":false},"arguments":[{"type":"Identifier","name":"i"}]},"operator":">=","right":{"type":"Literal","value":0}},"consequent":{"type":"ContinueStatement","label":null},"alternate":null},{"type":"IfStatement","test":{"type":"UnaryExpression","operator":"!","prefix":true,"argument":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"MemberExpression","object":{"type":"MemberExpression","object":{"type":"Identifier","name":"Object"},"property":{"type":"Identifier","name":"prototype"},"computed":false},"property":{"type":"Identifier","name":"hasOwnProperty"},"computed":false},"property":{"type":"Identifier","name":"call"},"computed":false},"arguments":[{"type":"Identifier","name":"obj"},{"type":"Identifier","name":"i"}]}},"consequent":{"type":"ContinueStatement","label":null},"alternate":null},{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"target"},"property":{"type":"Identifier","name":"i"},"computed":true},"right":{"type":"MemberExpression","object":{"type":"Identifier","name":"obj"},"property":{"type":"Identifier","name":"i"},"computed":true}}}]}},{"type":"ReturnStatement","argument":{"type":"Identifier","name":"target"}}]},"parenthesizedExpression":true}}]},"helper-self-global":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"ConditionalExpression","test":{"type":"BinaryExpression","left":{"type":"UnaryExpression","operator":"typeof","prefix":true,"argument":{"type":"Identifier","name":"global"}},"operator":"===","right":{"type":"Literal","value":"undefined"}},"consequent":{"type":"Identifier","name":"self"},"alternate":{"type":"Identifier","name":"global"}}}]},"helper-set":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"FunctionExpression","id":{"type":"Identifier","name":"set"},"generator":false,"expression":false,"params":[{"type":"Identifier","name":"object"},{"type":"Identifier","name":"property"},{"type":"Identifier","name":"value"},{"type":"Identifier","name":"receiver"}],"body":{"type":"BlockStatement","body":[{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"desc"},"init":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"Object"},"property":{"type":"Identifier","name":"getOwnPropertyDescriptor"},"computed":false},"arguments":[{"type":"Identifier","name":"object"},{"type":"Identifier","name":"property"}]}}],"kind":"var"},{"type":"IfStatement","test":{"type":"BinaryExpression","left":{"type":"Identifier","name":"desc"},"operator":"===","right":{"type":"Identifier","name":"undefined"}},"consequent":{"type":"BlockStatement","body":[{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"parent"},"init":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"Object"},"property":{"type":"Identifier","name":"getPrototypeOf"},"computed":false},"arguments":[{"type":"Identifier","name":"object"}]}}],"kind":"var"},{"type":"IfStatement","test":{"type":"BinaryExpression","left":{"type":"Identifier","name":"parent"},"operator":"!==","right":{"type":"Literal","value":null,"rawValue":null}},"consequent":{"type":"BlockStatement","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"Identifier","name":"set"},"arguments":[{"type":"Identifier","name":"parent"},{"type":"Identifier","name":"property"},{"type":"Identifier","name":"value"},{"type":"Identifier","name":"receiver"}]}}]},"alternate":null}]},"alternate":{"type":"IfStatement","test":{"type":"LogicalExpression","left":{"type":"BinaryExpression","left":{"type":"Literal","value":"value"},"operator":"in","right":{"type":"Identifier","name":"desc"}},"operator":"&&","right":{"type":"MemberExpression","object":{"type":"Identifier","name":"desc"},"property":{"type":"Identifier","name":"writable"},"computed":false}},"consequent":{"type":"BlockStatement","body":[{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"desc"},"property":{"type":"Identifier","name":"value"},"computed":false},"right":{"type":"Identifier","name":"value"}}}]},"alternate":{"type":"BlockStatement","body":[{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"setter"},"init":{"type":"MemberExpression","object":{"type":"Identifier","name":"desc"},"property":{"type":"Identifier","name":"set"},"computed":false}}],"kind":"var"},{"type":"IfStatement","test":{"type":"BinaryExpression","left":{"type":"Identifier","name":"setter"},"operator":"!==","right":{"type":"Identifier","name":"undefined"}},"consequent":{"type":"BlockStatement","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"setter"},"property":{"type":"Identifier","name":"call"},"computed":false},"arguments":[{"type":"Identifier","name":"receiver"},{"type":"Identifier","name":"value"}]}}]},"alternate":null}]}}},{"type":"ReturnStatement","argument":{"type":"Identifier","name":"value"}}]},"parenthesizedExpression":true}}]},"helper-slice":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"MemberExpression","object":{"type":"MemberExpression","object":{"type":"Identifier","name":"Array"},"property":{"type":"Identifier","name":"prototype"},"computed":false},"property":{"type":"Identifier","name":"slice"},"computed":false}}]},"helper-sliced-to-array-loose":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"arr"},{"type":"Identifier","name":"i"}],"body":{"type":"BlockStatement","body":[{"type":"IfStatement","test":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"Array"},"property":{"type":"Identifier","name":"isArray"},"computed":false},"arguments":[{"type":"Identifier","name":"arr"}]},"consequent":{"type":"BlockStatement","body":[{"type":"ReturnStatement","argument":{"type":"Identifier","name":"arr"}}]},"alternate":{"type":"IfStatement","test":{"type":"BinaryExpression","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"Symbol"},"property":{"type":"Identifier","name":"iterator"},"computed":false},"operator":"in","right":{"type":"CallExpression","callee":{"type":"Identifier","name":"Object"},"arguments":[{"type":"Identifier","name":"arr"}]}},"consequent":{"type":"BlockStatement","body":[{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"_arr"},"init":{"type":"ArrayExpression","elements":[]}}],"kind":"var"},{"type":"ForStatement","init":{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"_iterator"},"init":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"arr"},"property":{"type":"MemberExpression","object":{"type":"Identifier","name":"Symbol"},"property":{"type":"Identifier","name":"iterator"},"computed":false},"computed":true},"arguments":[]}},{"type":"VariableDeclarator","id":{"type":"Identifier","name":"_step"},"init":null}],"kind":"var"},"test":{"type":"UnaryExpression","operator":"!","prefix":true,"argument":{"type":"MemberExpression","object":{"type":"AssignmentExpression","operator":"=","left":{"type":"Identifier","name":"_step"},"right":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"_iterator"},"property":{"type":"Identifier","name":"next"},"computed":false},"arguments":[]},"parenthesizedExpression":true},"property":{"type":"Identifier","name":"done"},"computed":false}},"update":null,"body":{"type":"BlockStatement","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"_arr"},"property":{"type":"Identifier","name":"push"},"computed":false},"arguments":[{"type":"MemberExpression","object":{"type":"Identifier","name":"_step"},"property":{"type":"Identifier","name":"value"},"computed":false}]}},{"type":"IfStatement","test":{"type":"LogicalExpression","left":{"type":"Identifier","name":"i"},"operator":"&&","right":{"type":"BinaryExpression","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"_arr"},"property":{"type":"Identifier","name":"length"},"computed":false},"operator":"===","right":{"type":"Identifier","name":"i"}}},"consequent":{"type":"BreakStatement","label":null},"alternate":null}]}},{"type":"ReturnStatement","argument":{"type":"Identifier","name":"_arr"}}]},"alternate":{"type":"BlockStatement","body":[{"type":"ThrowStatement","argument":{"type":"NewExpression","callee":{"type":"Identifier","name":"TypeError"},"arguments":[{"type":"Literal","value":"Invalid attempt to destructure non-iterable instance"}]}}]}}}]},"parenthesizedExpression":true}}]},"helper-sliced-to-array":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[],"body":{"type":"BlockStatement","body":[{"type":"FunctionDeclaration","id":{"type":"Identifier","name":"sliceIterator","leadingComments":null},"generator":false,"expression":false,"params":[{"type":"Identifier","name":"arr"},{"type":"Identifier","name":"i"}],"body":{"type":"BlockStatement","body":[{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"_arr","leadingComments":null},"init":{"type":"ArrayExpression","elements":[]},"leadingComments":null}],"kind":"var"},{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"_n"},"init":{"type":"Literal","value":true}}],"kind":"var"},{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"_d"},"init":{"type":"Literal","value":false}}],"kind":"var"},{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"_e"},"init":{"type":"Identifier","name":"undefined"}}],"kind":"var"},{"type":"TryStatement","block":{"type":"BlockStatement","body":[{"type":"ForStatement","init":{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"_i"},"init":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"arr"},"property":{"type":"MemberExpression","object":{"type":"Identifier","name":"Symbol"},"property":{"type":"Identifier","name":"iterator"},"computed":false},"computed":true},"arguments":[]}},{"type":"VariableDeclarator","id":{"type":"Identifier","name":"_s"},"init":null}],"kind":"var"},"test":{"type":"UnaryExpression","operator":"!","prefix":true,"argument":{"type":"AssignmentExpression","operator":"=","left":{"type":"Identifier","name":"_n"},"right":{"type":"MemberExpression","object":{"type":"AssignmentExpression","operator":"=","left":{"type":"Identifier","name":"_s"},"right":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"_i"},"property":{"type":"Identifier","name":"next"},"computed":false},"arguments":[]},"parenthesizedExpression":true},"property":{"type":"Identifier","name":"done"},"computed":false},"parenthesizedExpression":true}},"update":{"type":"AssignmentExpression","operator":"=","left":{"type":"Identifier","name":"_n"},"right":{"type":"Literal","value":true}},"body":{"type":"BlockStatement","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"_arr"},"property":{"type":"Identifier","name":"push"},"computed":false},"arguments":[{"type":"MemberExpression","object":{"type":"Identifier","name":"_s"},"property":{"type":"Identifier","name":"value"},"computed":false}]}},{"type":"IfStatement","test":{"type":"LogicalExpression","left":{"type":"Identifier","name":"i"},"operator":"&&","right":{"type":"BinaryExpression","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"_arr"},"property":{"type":"Identifier","name":"length"},"computed":false},"operator":"===","right":{"type":"Identifier","name":"i"}}},"consequent":{"type":"BreakStatement","label":null},"alternate":null}]}}]},"handler":{"type":"CatchClause","param":{"type":"Identifier","name":"err"},"body":{"type":"BlockStatement","body":[{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"Identifier","name":"_d"},"right":{"type":"Literal","value":true}}},{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"Identifier","name":"_e"},"right":{"type":"Identifier","name":"err"}}}]}},"guardedHandlers":[],"finalizer":{"type":"BlockStatement","body":[{"type":"TryStatement","block":{"type":"BlockStatement","body":[{"type":"IfStatement","test":{"type":"LogicalExpression","left":{"type":"UnaryExpression","operator":"!","prefix":true,"argument":{"type":"Identifier","name":"_n"}},"operator":"&&","right":{"type":"MemberExpression","object":{"type":"Identifier","name":"_i"},"property":{"type":"Literal","value":"return"},"computed":true}},"consequent":{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"_i"},"property":{"type":"Literal","value":"return"},"computed":true},"arguments":[]}},"alternate":null}]},"handler":null,"guardedHandlers":[],"finalizer":{"type":"BlockStatement","body":[{"type":"IfStatement","test":{"type":"Identifier","name":"_d"},"consequent":{"type":"ThrowStatement","argument":{"type":"Identifier","name":"_e"}},"alternate":null}]}}]}},{"type":"ReturnStatement","argument":{"type":"Identifier","name":"_arr"}}]}},{"type":"ReturnStatement","argument":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"arr"},{"type":"Identifier","name":"i"}],"body":{"type":"BlockStatement","body":[{"type":"IfStatement","test":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"Array"},"property":{"type":"Identifier","name":"isArray"},"computed":false},"arguments":[{"type":"Identifier","name":"arr"}]},"consequent":{"type":"BlockStatement","body":[{"type":"ReturnStatement","argument":{"type":"Identifier","name":"arr"}}]},"alternate":{"type":"IfStatement","test":{"type":"BinaryExpression","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"Symbol"},"property":{"type":"Identifier","name":"iterator"},"computed":false},"operator":"in","right":{"type":"CallExpression","callee":{"type":"Identifier","name":"Object"},"arguments":[{"type":"Identifier","name":"arr"}]}},"consequent":{"type":"BlockStatement","body":[{"type":"ReturnStatement","argument":{"type":"CallExpression","callee":{"type":"Identifier","name":"sliceIterator"},"arguments":[{"type":"Identifier","name":"arr"},{"type":"Identifier","name":"i"}]}}]},"alternate":{"type":"BlockStatement","body":[{"type":"ThrowStatement","argument":{"type":"NewExpression","callee":{"type":"Identifier","name":"TypeError"},"arguments":[{"type":"Literal","value":"Invalid attempt to destructure non-iterable instance"}]}}]}}}]}}}]},"parenthesizedExpression":true},"arguments":[]}}]},"helper-tagged-template-literal-loose":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"strings"},{"type":"Identifier","name":"raw"}],"body":{"type":"BlockStatement","body":[{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"strings"},"property":{"type":"Identifier","name":"raw"},"computed":false},"right":{"type":"Identifier","name":"raw"}}},{"type":"ReturnStatement","argument":{"type":"Identifier","name":"strings"}}]},"parenthesizedExpression":true}}]},"helper-tagged-template-literal":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"strings"},{"type":"Identifier","name":"raw"}],"body":{"type":"BlockStatement","body":[{"type":"ReturnStatement","argument":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"Object"},"property":{"type":"Identifier","name":"freeze"},"computed":false},"arguments":[{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"Object"},"property":{"type":"Identifier","name":"defineProperties"},"computed":false},"arguments":[{"type":"Identifier","name":"strings"},{"type":"ObjectExpression","properties":[{"type":"Property","method":false,"shorthand":false,"computed":false,"key":{"type":"Identifier","name":"raw"},"value":{"type":"ObjectExpression","properties":[{"type":"Property","method":false,"shorthand":false,"computed":false,"key":{"type":"Identifier","name":"value"},"value":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"Object"},"property":{"type":"Identifier","name":"freeze"},"computed":false},"arguments":[{"type":"Identifier","name":"raw"}]},"kind":"init"}]},"kind":"init"}]}]}]}}]},"parenthesizedExpression":true}}]},"helper-temporal-assert-defined":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"val"},{"type":"Identifier","name":"name"},{"type":"Identifier","name":"undef"}],"body":{"type":"BlockStatement","body":[{"type":"IfStatement","test":{"type":"BinaryExpression","left":{"type":"Identifier","name":"val"},"operator":"===","right":{"type":"Identifier","name":"undef"}},"consequent":{"type":"BlockStatement","body":[{"type":"ThrowStatement","argument":{"type":"NewExpression","callee":{"type":"Identifier","name":"ReferenceError"},"arguments":[{"type":"BinaryExpression","left":{"type":"Identifier","name":"name"},"operator":"+","right":{"type":"Literal","value":" is not defined - temporal dead zone"}}]}}]},"alternate":null},{"type":"ReturnStatement","argument":{"type":"Literal","value":true}}]},"parenthesizedExpression":true}}]},"helper-temporal-undefined":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"ObjectExpression","properties":[],"parenthesizedExpression":true}}]},"helper-to-array":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"arr"}],"body":{"type":"BlockStatement","body":[{"type":"ReturnStatement","argument":{"type":"ConditionalExpression","test":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"Array"},"property":{"type":"Identifier","name":"isArray"},"computed":false},"arguments":[{"type":"Identifier","name":"arr"}]},"consequent":{"type":"Identifier","name":"arr"},"alternate":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"Array"},"property":{"type":"Identifier","name":"from"},"computed":false},"arguments":[{"type":"Identifier","name":"arr"}]}}}]},"parenthesizedExpression":true}}]},"helper-to-consumable-array":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"arr"}],"body":{"type":"BlockStatement","body":[{"type":"IfStatement","test":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"Array"},"property":{"type":"Identifier","name":"isArray"},"computed":false},"arguments":[{"type":"Identifier","name":"arr"}]},"consequent":{"type":"BlockStatement","body":[{"type":"ForStatement","init":{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"i"},"init":{"type":"Literal","value":0}},{"type":"VariableDeclarator","id":{"type":"Identifier","name":"arr2"},"init":{"type":"CallExpression","callee":{"type":"Identifier","name":"Array"},"arguments":[{"type":"MemberExpression","object":{"type":"Identifier","name":"arr"},"property":{"type":"Identifier","name":"length"},"computed":false}]}}],"kind":"var"},"test":{"type":"BinaryExpression","left":{"type":"Identifier","name":"i"},"operator":"<","right":{"type":"MemberExpression","object":{"type":"Identifier","name":"arr"},"property":{"type":"Identifier","name":"length"},"computed":false}},"update":{"type":"UpdateExpression","operator":"++","prefix":false,"argument":{"type":"Identifier","name":"i"}},"body":{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"arr2"},"property":{"type":"Identifier","name":"i"},"computed":true},"right":{"type":"MemberExpression","object":{"type":"Identifier","name":"arr"},"property":{"type":"Identifier","name":"i"},"computed":true}}}},{"type":"ReturnStatement","argument":{"type":"Identifier","name":"arr2"}}]},"alternate":{"type":"BlockStatement","body":[{"type":"ReturnStatement","argument":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"Array"},"property":{"type":"Identifier","name":"from"},"computed":false},"arguments":[{"type":"Identifier","name":"arr"}]}}]}}]},"parenthesizedExpression":true}}]},"helper-typeof-react-element":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"LogicalExpression","left":{"type":"LogicalExpression","left":{"type":"LogicalExpression","left":{"type":"BinaryExpression","left":{"type":"UnaryExpression","operator":"typeof","prefix":true,"argument":{"type":"Identifier","name":"Symbol"}},"operator":"===","right":{"type":"Literal","value":"function"}},"operator":"&&","right":{"type":"MemberExpression","object":{"type":"Identifier","name":"Symbol"},"property":{"type":"Literal","value":"for"},"computed":true}},"operator":"&&","right":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"Symbol"},"property":{"type":"Literal","value":"for"},"computed":true},"arguments":[{"type":"Literal","value":"react.element"}]}},"operator":"||","right":{"type":"Literal","value":60103}}}]},"helper-typeof":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"obj"}],"body":{"type":"BlockStatement","body":[{"type":"ReturnStatement","argument":{"type":"ConditionalExpression","test":{"type":"LogicalExpression","left":{"type":"Identifier","name":"obj"},"operator":"&&","right":{"type":"BinaryExpression","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"obj"},"property":{"type":"Identifier","name":"constructor"},"computed":false},"operator":"===","right":{"type":"Identifier","name":"Symbol"}}},"consequent":{"type":"Literal","value":"symbol"},"alternate":{"type":"UnaryExpression","operator":"typeof","prefix":true,"argument":{"type":"Identifier","name":"obj"}}}}]},"parenthesizedExpression":true}}]},"let-scoping-return":{"type":"Program","body":[{"type":"IfStatement","test":{"type":"BinaryExpression","left":{"type":"UnaryExpression","operator":"typeof","prefix":true,"argument":{"type":"Identifier","name":"RETURN"}},"operator":"===","right":{"type":"Literal","value":"object"}},"consequent":{"type":"ReturnStatement","argument":{"type":"MemberExpression","object":{"type":"Identifier","name":"RETURN"},"property":{"type":"Identifier","name":"v"},"computed":false}},"alternate":null}]},"named-function":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[],"body":{"type":"BlockStatement","body":[{"type":"FunctionDeclaration","id":{"type":"Identifier","name":"GET_OUTER_ID"},"generator":false,"expression":false,"params":[],"body":{"type":"BlockStatement","body":[{"type":"ReturnStatement","argument":{"type":"Identifier","name":"FUNCTION_ID"}}]}},{"type":"ReturnStatement","argument":{"type":"Identifier","name":"FUNCTION"}}]},"parenthesizedExpression":true},"arguments":[]}}]},"property-method-assignment-wrapper-generator":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"FUNCTION_KEY"}],"body":{"type":"BlockStatement","body":[{"type":"FunctionDeclaration","id":{"type":"Identifier","name":"FUNCTION_ID"},"generator":true,"expression":false,"params":[],"body":{"type":"BlockStatement","body":[{"type":"ReturnStatement","argument":{"type":"YieldExpression","delegate":true,"argument":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"FUNCTION_KEY"},"property":{"type":"Identifier","name":"apply"},"computed":false},"arguments":[{"type":"ThisExpression"},{"type":"Identifier","name":"arguments"}]}}}]}},{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"FUNCTION_ID"},"property":{"type":"Identifier","name":"toString"},"computed":false},"right":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[],"body":{"type":"BlockStatement","body":[{"type":"ReturnStatement","argument":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"FUNCTION_KEY"},"property":{"type":"Identifier","name":"toString"},"computed":false},"arguments":[]}}]}}}},{"type":"ReturnStatement","argument":{"type":"Identifier","name":"FUNCTION_ID"}}]},"parenthesizedExpression":true},"arguments":[{"type":"Identifier","name":"FUNCTION"}]}}]},"property-method-assignment-wrapper":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"FUNCTION_KEY"}],"body":{"type":"BlockStatement","body":[{"type":"FunctionDeclaration","id":{"type":"Identifier","name":"FUNCTION_ID"},"generator":false,"expression":false,"params":[],"body":{"type":"BlockStatement","body":[{"type":"ReturnStatement","argument":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"FUNCTION_KEY"},"property":{"type":"Identifier","name":"apply"},"computed":false},"arguments":[{"type":"ThisExpression"},{"type":"Identifier","name":"arguments"}]}}]}},{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"FUNCTION_ID"},"property":{"type":"Identifier","name":"toString"},"computed":false},"right":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[],"body":{"type":"BlockStatement","body":[{"type":"ReturnStatement","argument":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"FUNCTION_KEY"},"property":{"type":"Identifier","name":"toString"},"computed":false},"arguments":[]}}]}}}},{"type":"ReturnStatement","argument":{"type":"Identifier","name":"FUNCTION_ID"}}]},"parenthesizedExpression":true},"arguments":[{"type":"Identifier","name":"FUNCTION"}]}}]},"prototype-identifier":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"MemberExpression","object":{"type":"Identifier","name":"CLASS_NAME"},"property":{"type":"Identifier","name":"prototype"},"computed":false}}]},"require-assign-key":{"type":"Program","body":[{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"VARIABLE_NAME"},"init":{"type":"MemberExpression","object":{"type":"CallExpression","callee":{"type":"Identifier","name":"require"},"arguments":[{"type":"Identifier","name":"MODULE_NAME"}]},"property":{"type":"Identifier","name":"KEY"},"computed":false}}],"kind":"var"}]},"require":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"Identifier","name":"require"},"arguments":[{"type":"Identifier","name":"MODULE_NAME"}]}}]},"rest":{"type":"Program","body":[{"type":"ForStatement","init":{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"LEN"},"init":{"type":"MemberExpression","object":{"type":"Identifier","name":"ARGUMENTS"},"property":{"type":"Identifier","name":"length"},"computed":false}},{"type":"VariableDeclarator","id":{"type":"Identifier","name":"ARRAY"},"init":{"type":"CallExpression","callee":{"type":"Identifier","name":"Array"},"arguments":[{"type":"Identifier","name":"ARRAY_LEN"}]}},{"type":"VariableDeclarator","id":{"type":"Identifier","name":"KEY"},"init":{"type":"Identifier","name":"START"}}],"kind":"var"},"test":{"type":"BinaryExpression","left":{"type":"Identifier","name":"KEY"},"operator":"<","right":{"type":"Identifier","name":"LEN"}},"update":{"type":"UpdateExpression","operator":"++","prefix":false,"argument":{"type":"Identifier","name":"KEY"}},"body":{"type":"BlockStatement","body":[{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"ARRAY"},"property":{"type":"Identifier","name":"ARRAY_KEY"},"computed":true},"right":{"type":"MemberExpression","object":{"type":"Identifier","name":"ARGUMENTS"},"property":{"type":"Identifier","name":"KEY"},"computed":true}}}]}}]},"self-contained-helpers-head":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"exports"},"property":{"type":"Literal","value":"default"},"computed":true},"right":{"type":"Identifier","name":"HELPER"}}},{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"exports"},"property":{"type":"Identifier","name":"__esModule"},"computed":false},"right":{"type":"Literal","value":true}}}]},"system":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"MemberExpression","object":{"type":"Identifier","name":"System"},"property":{"type":"Identifier","name":"register"},"computed":false},"arguments":[{"type":"Identifier","name":"MODULE_NAME"},{"type":"Identifier","name":"MODULE_DEPENDENCIES"},{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"EXPORT_IDENTIFIER"}],"body":{"type":"BlockStatement","body":[{"type":"ReturnStatement","argument":{"type":"ObjectExpression","properties":[{"type":"Property","method":false,"shorthand":false,"computed":false,"key":{"type":"Identifier","name":"setters"},"value":{"type":"Identifier","name":"SETTERS"},"kind":"init"},{"type":"Property","method":false,"shorthand":false,"computed":false,"key":{"type":"Identifier","name":"execute"},"value":{"type":"Identifier","name":"EXECUTE"},"kind":"init"}]}}]}}]}}]},"tail-call-body":{"type":"Program","body":[{"type":"BlockStatement","body":[{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"AGAIN_ID"},"init":{"type":"Literal","value":true}}],"kind":"var"},{"type":"LabeledStatement","body":{"type":"WhileStatement","test":{"type":"Identifier","name":"AGAIN_ID"},"body":{"type":"ExpressionStatement","expression":{"type":"Identifier","name":"BLOCK"}}},"label":{"type":"Identifier","name":"FUNCTION_ID"}}]}]},"test-exports":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"BinaryExpression","left":{"type":"UnaryExpression","operator":"typeof","prefix":true,"argument":{"type":"Identifier","name":"exports"}},"operator":"!==","right":{"type":"Literal","value":"undefined"}}}]},"test-module":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"BinaryExpression","left":{"type":"UnaryExpression","operator":"typeof","prefix":true,"argument":{"type":"Identifier","name":"module"}},"operator":"!==","right":{"type":"Literal","value":"undefined"}}}]},"umd-commonjs-strict":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"root"},{"type":"Identifier","name":"factory"}],"body":{"type":"BlockStatement","body":[{"type":"IfStatement","test":{"type":"LogicalExpression","left":{"type":"BinaryExpression","left":{"type":"UnaryExpression","operator":"typeof","prefix":true,"argument":{"type":"Identifier","name":"define"}},"operator":"===","right":{"type":"Literal","value":"function"}},"operator":"&&","right":{"type":"MemberExpression","object":{"type":"Identifier","name":"define"},"property":{"type":"Identifier","name":"amd"},"computed":false}},"consequent":{"type":"BlockStatement","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"Identifier","name":"define"},"arguments":[{"type":"Identifier","name":"AMD_ARGUMENTS"},{"type":"Identifier","name":"factory"}]}}]},"alternate":{"type":"IfStatement","test":{"type":"BinaryExpression","left":{"type":"UnaryExpression","operator":"typeof","prefix":true,"argument":{"type":"Identifier","name":"exports"}},"operator":"===","right":{"type":"Literal","value":"object"}},"consequent":{"type":"BlockStatement","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"Identifier","name":"factory"},"arguments":[{"type":"Identifier","name":"COMMON_ARGUMENTS"}]}}]},"alternate":{"type":"BlockStatement","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"Identifier","name":"factory"},"arguments":[{"type":"Identifier","name":"BROWSER_ARGUMENTS"}]}}]}}}]},"parenthesizedExpression":true},"arguments":[{"type":"Identifier","name":"UMD_ROOT"},{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"FACTORY_PARAMETERS"}],"body":{"type":"BlockStatement","body":[{"type":"ExpressionStatement","expression":{"type":"Identifier","name":"FACTORY_BODY"}}]}}]}}]},"umd-runner-body":{"type":"Program","body":[{"type":"ExpressionStatement","expression":{"type":"FunctionExpression","id":null,"generator":false,"expression":false,"params":[{"type":"Identifier","name":"global"},{"type":"Identifier","name":"factory"}],"body":{"type":"BlockStatement","body":[{"type":"IfStatement","test":{"type":"LogicalExpression","left":{"type":"BinaryExpression","left":{"type":"UnaryExpression","operator":"typeof","prefix":true,"argument":{"type":"Identifier","name":"define"}},"operator":"===","right":{"type":"Literal","value":"function"}},"operator":"&&","right":{"type":"MemberExpression","object":{"type":"Identifier","name":"define"},"property":{"type":"Identifier","name":"amd"},"computed":false}},"consequent":{"type":"BlockStatement","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"Identifier","name":"define"},"arguments":[{"type":"Identifier","name":"AMD_ARGUMENTS"},{"type":"Identifier","name":"factory"}]}}]},"alternate":{"type":"IfStatement","test":{"type":"Identifier","name":"COMMON_TEST"},"consequent":{"type":"BlockStatement","body":[{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"Identifier","name":"factory"},"arguments":[{"type":"Identifier","name":"COMMON_ARGUMENTS"}]}}]},"alternate":{"type":"BlockStatement","body":[{"type":"VariableDeclaration","declarations":[{"type":"VariableDeclarator","id":{"type":"Identifier","name":"mod"},"init":{"type":"ObjectExpression","properties":[{"type":"Property","method":false,"shorthand":false,"computed":false,"key":{"type":"Identifier","name":"exports"},"value":{"type":"ObjectExpression","properties":[]},"kind":"init"}]}}],"kind":"var"},{"type":"ExpressionStatement","expression":{"type":"CallExpression","callee":{"type":"Identifier","name":"factory"},"arguments":[{"type":"MemberExpression","object":{"type":"Identifier","name":"mod"},"property":{"type":"Identifier","name":"exports"},"computed":false},{"type":"Identifier","name":"BROWSER_ARGUMENTS"}]}},{"type":"ExpressionStatement","expression":{"type":"AssignmentExpression","operator":"=","left":{"type":"MemberExpression","object":{"type":"Identifier","name":"global"},"property":{"type":"Identifier","name":"GLOBAL_ARG"},"computed":false},"right":{"type":"MemberExpression","object":{"type":"Identifier","name":"mod"},"property":{"type":"Identifier","name":"exports"},"computed":false}}}]}}}]},"parenthesizedExpression":true}}]}} -},{}],613:[function(_dereq_,module,exports){ -"use strict"; - -exports.__esModule = true; -exports.parse = parse; -// istanbul ignore next - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } - -var _parser = _dereq_(617); - -var _parser2 = _interopRequireDefault(_parser); - -_dereq_(622); - -_dereq_(621); - -_dereq_(619); - -_dereq_(616); - -_dereq_(620); - -_dereq_(618); - -_dereq_(615); - -var _tokenizerTypes = _dereq_(629); - -_dereq_(627); - -_dereq_(626); - -var _pluginsFlow = _dereq_(623); - -var _pluginsFlow2 = _interopRequireDefault(_pluginsFlow); - -var _pluginsJsx = _dereq_(624); - -var _pluginsJsx2 = _interopRequireDefault(_pluginsJsx); - -_parser.plugins.flow = _pluginsFlow2["default"]; -_parser.plugins.jsx = _pluginsJsx2["default"]; - -function parse(input, options) { - return new _parser2["default"](options, input).parse(); -} - -exports.tokTypes = _tokenizerTypes.types; -},{"615":615,"616":616,"617":617,"618":618,"619":619,"620":620,"621":621,"622":622,"623":623,"624":624,"626":626,"627":627,"629":629}],614:[function(_dereq_,module,exports){ -// A second optional argument can be given to further configure -// the parser process. These options are recognized: - -"use strict"; - -exports.__esModule = true; -exports.getOptions = getOptions; -var defaultOptions = { - // Source type ("script" or "module") for different semantics - sourceType: "script", - // By default, reserved words are not enforced. Disable - // `allowReserved` to enforce them. When this option has the - // value "never", reserved words and keywords can also not be - // used as property names. - allowReserved: true, - // When enabled, a return at the top level is not considered an - // error. - allowReturnOutsideFunction: false, - // When enabled, import/export statements are not constrained to - // appearing at the top of the program. - allowImportExportEverywhere: false, - plugins: {}, - // Babel-specific options - features: {}, - strictMode: null -}; - -exports.defaultOptions = defaultOptions; -// Interpret and default an options object - -function getOptions(opts) { - var options = {}; - for (var key in defaultOptions) { - options[key] = opts && key in opts ? opts[key] : defaultOptions[key]; - } - return options; -} -},{}],615:[function(_dereq_,module,exports){ -/** - * Based on the comment attachment algorithm used in espree and estraverse. - * - * 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. - * - * 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 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. - */ - -"use strict"; - -// istanbul ignore next - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } - -var _index = _dereq_(617); - -var _index2 = _interopRequireDefault(_index); - -function last(stack) { - return stack[stack.length - 1]; -} - -var pp = _index2["default"].prototype; - -pp.addComment = function (comment) { - this.state.trailingComments.push(comment); - this.state.leadingComments.push(comment); -}; - -pp.processComment = function (node) { - if (node.type === "Program" && node.body.length > 0) return; - - var stack = this.state.commentStack; - - var lastChild, trailingComments, i; - - if (this.state.trailingComments.length > 0) { - // If the first comment in trailingComments comes after the - // current node, then we're good - all comments in the array will - // come after the node and so it's safe to add them as official - // trailingComments. - if (this.state.trailingComments[0].start >= node.end) { - trailingComments = this.state.trailingComments; - this.state.trailingComments = []; - } else { - // Otherwise, if the first comment doesn't come after the - // current node, that means we have a mix of leading and trailing - // comments in the array and that leadingComments contains the - // same items as trailingComments. Reset trailingComments to - // zero items and we'll handle this by evaluating leadingComments - // later. - this.state.trailingComments.length = 0; - } - } else { - var lastInStack = last(stack); - if (stack.length > 0 && lastInStack.trailingComments && lastInStack.trailingComments[0].start >= node.end) { - trailingComments = lastInStack.trailingComments; - lastInStack.trailingComments = null; - } - } - - // Eating the stack. - while (stack.length > 0 && last(stack).start >= node.start) { - lastChild = stack.pop(); - } - - if (lastChild) { - if (lastChild.leadingComments) { - if (lastChild !== node && last(lastChild.leadingComments).end <= node.start) { - node.leadingComments = lastChild.leadingComments; - lastChild.leadingComments = null; - } else { - // A leading comment for an anonymous class had been stolen by its first MethodDefinition, - // so this takes back the leading comment. - // See also: https://github.com/eslint/espree/issues/158 - for (i = lastChild.leadingComments.length - 2; i >= 0; --i) { - if (lastChild.leadingComments[i].end <= node.start) { - node.leadingComments = lastChild.leadingComments.splice(0, i + 1); - break; - } - } - } - } - } else if (this.state.leadingComments.length > 0) { - if (last(this.state.leadingComments).end <= node.start) { - node.leadingComments = this.state.leadingComments; - this.state.leadingComments = []; - } else { - // https://github.com/eslint/espree/issues/2 - // - // In special cases, such as return (without a value) and - // debugger, all comments will end up as leadingComments and - // will otherwise be eliminated. This step runs when the - // commentStack is empty and there are comments left - // in leadingComments. - // - // This loop figures out the stopping point between the actual - // leading and trailing comments by finding the location of the - // first comment that comes after the given node. - for (i = 0; i < this.state.leadingComments.length; i++) { - if (this.state.leadingComments[i].end > node.start) { - break; - } - } - - // Split the array based on the location of the first comment - // that comes after the node. Keep in mind that this could - // result in an empty array, and if so, the array must be - // deleted. - node.leadingComments = this.state.leadingComments.slice(0, i); - if (node.leadingComments.length === 0) { - node.leadingComments = null; - } - - // Similarly, trailing comments are attached later. The variable - // must be reset to null if there are no trailing comments. - trailingComments = this.state.leadingComments.slice(i); - if (trailingComments.length === 0) { - trailingComments = null; - } - } - } - - if (trailingComments) { - if (trailingComments.length && trailingComments[0].start >= node.start && last(trailingComments).end <= node.end) { - node.innerComments = trailingComments; - } else { - node.trailingComments = trailingComments; - } - } - - stack.push(node); -}; -},{"617":617}],616:[function(_dereq_,module,exports){ -// A recursive descent parser operates by defining functions for all -// syntactic elements, and recursively calling those, each function -// advancing the input stream and returning an AST node. Precedence -// of constructs (for example, the fact that `!x[1]` means `!(x[1])` -// instead of `(!x)[1]` is handled by the fact that the parser -// function that parses unary prefix operators is called first, and -// in turn calls the function that parses `[]` subscripts — that -// way, it'll receive the node for `x[1]` already parsed, and wraps -// *that* in the unary operator node. -// -// Acorn uses an [operator precedence parser][opp] to handle binary -// operator precedence, because it is much more compact than using -// the technique outlined above, which uses different, nesting -// functions to specify precedence, for all of the ten binary -// precedence levels that JavaScript defines. -// -// [opp]: http://en.wikipedia.org/wiki/Operator-precedence_parser - -"use strict"; - -// istanbul ignore next - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } - -var _tokenizerTypes = _dereq_(629); - -var _index = _dereq_(617); - -var _index2 = _interopRequireDefault(_index); - -var _utilIdentifier = _dereq_(630); - -var pp = _index2["default"].prototype; - -// Check if property name clashes with already added. -// Object/class getters and setters are not allowed to clash — -// either with each other or with an init property — and in -// strict mode, init properties are also not allowed to be repeated. - -pp.checkPropClash = function (prop, propHash) { - if (prop.computed || prop.method || prop.shorthand) return; - - var key = prop.key, - name = undefined; - switch (key.type) { - case "Identifier": - name = key.name;break; - case "Literal": - name = String(key.value);break; - default: - return; - } - - var kind = prop.kind; - if (name === "__proto__" && kind === "init") { - if (propHash.proto) this.raise(key.start, "Redefinition of __proto__ property"); - propHash.proto = true; - } -}; - -// ### Expression parsing - -// These nest, from the most general expression type at the top to -// 'atomic', nondivisible expression types at the bottom. Most of -// the functions will simply let the function (s) below them parse, -// and, *if* the syntactic construct they handle is present, wrap -// the AST node that the inner parser gave them in another node. - -// Parse a full expression. The optional arguments are used to -// forbid the `in` operator (in for loops initalization expressions) -// and provide reference for storing '=' operator inside shorthand -// property assignment in contexts where both object expression -// and object pattern might appear (so it's possible to raise -// delayed syntax error at correct position). - -pp.parseExpression = function (noIn, refShorthandDefaultPos) { - var startPos = this.state.start, - startLoc = this.state.startLoc; - var expr = this.parseMaybeAssign(noIn, refShorthandDefaultPos); - if (this.match(_tokenizerTypes.types.comma)) { - var node = this.startNodeAt(startPos, startLoc); - node.expressions = [expr]; - while (this.eat(_tokenizerTypes.types.comma)) { - node.expressions.push(this.parseMaybeAssign(noIn, refShorthandDefaultPos)); - } - this.toReferencedList(node.expressions); - return this.finishNode(node, "SequenceExpression"); - } - return expr; -}; - -// Parse an assignment expression. This includes applications of -// operators like `+=`. - -pp.parseMaybeAssign = function (noIn, refShorthandDefaultPos, afterLeftParse) { - if (this.match(_tokenizerTypes.types._yield) && this.state.inGenerator) { - return this.parseYield(); - } - - var failOnShorthandAssign = undefined; - if (!refShorthandDefaultPos) { - refShorthandDefaultPos = { start: 0 }; - failOnShorthandAssign = true; - } else { - failOnShorthandAssign = false; - } - var startPos = this.state.start, - startLoc = this.state.startLoc; - if (this.match(_tokenizerTypes.types.parenL) || this.match(_tokenizerTypes.types.name)) { - this.state.potentialArrowAt = this.state.start; - } - var left = this.parseMaybeConditional(noIn, refShorthandDefaultPos); - if (afterLeftParse) left = afterLeftParse.call(this, left, startPos, startLoc); - if (this.state.type.isAssign) { - var node = this.startNodeAt(startPos, startLoc); - node.operator = this.state.value; - node.left = this.match(_tokenizerTypes.types.eq) ? this.toAssignable(left) : left; - refShorthandDefaultPos.start = 0; // reset because shorthand default was used correctly - this.checkLVal(left); - if (left.parenthesizedExpression) { - var errorMsg = undefined; - if (left.type === "ObjectPattern") { - errorMsg = "`({a}) = 0` use `({a} = 0)`"; - } else if (left.type === "ArrayPattern") { - errorMsg = "`([a]) = 0` use `([a] = 0)`"; - } - if (errorMsg) { - this.raise(left.start, "You're trying to assign to a parenthesized expression, eg. instead of " + errorMsg); - } - } - this.next(); - node.right = this.parseMaybeAssign(noIn); - return this.finishNode(node, "AssignmentExpression"); - } else if (failOnShorthandAssign && refShorthandDefaultPos.start) { - this.unexpected(refShorthandDefaultPos.start); - } - return left; -}; - -// Parse a ternary conditional (`?:`) operator. - -pp.parseMaybeConditional = function (noIn, refShorthandDefaultPos) { - var startPos = this.state.start, - startLoc = this.state.startLoc; - var expr = this.parseExprOps(noIn, refShorthandDefaultPos); - if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr; - if (this.eat(_tokenizerTypes.types.question)) { - var node = this.startNodeAt(startPos, startLoc); - node.test = expr; - node.consequent = this.parseMaybeAssign(); - this.expect(_tokenizerTypes.types.colon); - node.alternate = this.parseMaybeAssign(noIn); - return this.finishNode(node, "ConditionalExpression"); - } - return expr; -}; - -// Start the precedence parser. - -pp.parseExprOps = function (noIn, refShorthandDefaultPos) { - var startPos = this.state.start, - startLoc = this.state.startLoc; - var expr = this.parseMaybeUnary(refShorthandDefaultPos); - if (refShorthandDefaultPos && refShorthandDefaultPos.start) { - return expr; - } else { - return this.parseExprOp(expr, startPos, startLoc, -1, noIn); - } -}; - -// Parse binary operators with the operator precedence parsing -// algorithm. `left` is the left-hand side of the operator. -// `minPrec` provides context that allows the function to stop and -// defer further parser to one of its callers when it encounters an -// operator that has a lower precedence than the set it is parsing. - -pp.parseExprOp = function (left, leftStartPos, leftStartLoc, minPrec, noIn) { - var prec = this.state.type.binop; - if (prec != null && (!noIn || !this.match(_tokenizerTypes.types._in))) { - if (prec > minPrec) { - var node = this.startNodeAt(leftStartPos, leftStartLoc); - node.left = left; - node.operator = this.state.value; - var op = this.state.type; - this.next(); - var startPos = this.state.start, - startLoc = this.state.startLoc; - node.right = this.parseExprOp(this.parseMaybeUnary(), startPos, startLoc, op.rightAssociative ? prec - 1 : prec, noIn); - this.finishNode(node, op === _tokenizerTypes.types.logicalOR || op === _tokenizerTypes.types.logicalAND ? "LogicalExpression" : "BinaryExpression"); - return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn); - } - } - return left; -}; - -// Parse unary operators, both prefix and postfix. - -pp.parseMaybeUnary = function (refShorthandDefaultPos) { - if (this.state.type.prefix) { - var node = this.startNode(), - update = this.match(_tokenizerTypes.types.incDec); - node.operator = this.state.value; - node.prefix = true; - this.next(); - node.argument = this.parseMaybeUnary(); - if (refShorthandDefaultPos && refShorthandDefaultPos.start) this.unexpected(refShorthandDefaultPos.start); - if (update) { - this.checkLVal(node.argument); - } else if (this.strict && node.operator === "delete" && node.argument.type === "Identifier") { - this.raise(node.start, "Deleting local variable in strict mode"); - } - return this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression"); - } - - var startPos = this.state.start, - startLoc = this.state.startLoc; - var expr = this.parseExprSubscripts(refShorthandDefaultPos); - if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr; - while (this.state.type.postfix && !this.canInsertSemicolon()) { - var node = this.startNodeAt(startPos, startLoc); - node.operator = this.state.value; - node.prefix = false; - node.argument = expr; - this.checkLVal(expr); - this.next(); - expr = this.finishNode(node, "UpdateExpression"); - } - return expr; -}; - -// Parse call, dot, and `[]`-subscript expressions. - -pp.parseExprSubscripts = function (refShorthandDefaultPos) { - var startPos = this.state.start, - startLoc = this.state.startLoc; - var expr = this.parseExprAtom(refShorthandDefaultPos); - if (refShorthandDefaultPos && refShorthandDefaultPos.start) { - return expr; - } else { - return this.parseSubscripts(expr, startPos, startLoc); - } -}; - -pp.parseSubscripts = function (base, startPos, startLoc, noCalls) { - for (;;) { - if (!noCalls && this.eat(_tokenizerTypes.types.doubleColon)) { - var node = this.startNodeAt(startPos, startLoc); - node.object = base; - node.callee = this.parseNoCallExpr(); - return this.parseSubscripts(this.finishNode(node, "BindExpression"), startPos, startLoc, noCalls); - } else if (this.eat(_tokenizerTypes.types.dot)) { - var node = this.startNodeAt(startPos, startLoc); - node.object = base; - node.property = this.parseIdent(true); - node.computed = false; - base = this.finishNode(node, "MemberExpression"); - } else if (this.eat(_tokenizerTypes.types.bracketL)) { - var node = this.startNodeAt(startPos, startLoc); - node.object = base; - node.property = this.parseExpression(); - node.computed = true; - this.expect(_tokenizerTypes.types.bracketR); - base = this.finishNode(node, "MemberExpression"); - } else if (!noCalls && this.match(_tokenizerTypes.types.parenL)) { - var possibleAsync = base.type === "Identifier" && base.name === "async" && !this.canInsertSemicolon(); - this.next(); - - var node = this.startNodeAt(startPos, startLoc); - node.callee = base; - node.arguments = this.parseExprList(_tokenizerTypes.types.parenR, this.options.features["es7.trailingFunctionCommas"]); - base = this.finishNode(node, "CallExpression"); - - if (possibleAsync && (this.match(_tokenizerTypes.types.colon) || this.match(_tokenizerTypes.types.arrow))) { - base = this.parseAsyncArrowFromCallExpression(this.startNodeAt(startPos, startLoc), node); - } else { - this.toReferencedList(node.arguments); - } - } else if (this.match(_tokenizerTypes.types.backQuote)) { - var node = this.startNodeAt(startPos, startLoc); - node.tag = base; - node.quasi = this.parseTemplate(); - base = this.finishNode(node, "TaggedTemplateExpression"); - } else { - return base; - } - } -}; - -pp.parseAsyncArrowFromCallExpression = function (node, call) { - if (!this.options.features["es7.asyncFunctions"]) this.unexpected(); - this.expect(_tokenizerTypes.types.arrow); - return this.parseArrowExpression(node, call.arguments, true); -}; - -// Parse a no-call expression (like argument of `new` or `::` operators). - -pp.parseNoCallExpr = function () { - var startPos = this.state.start, - startLoc = this.state.startLoc; - return this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true); -}; - -// Parse an atomic expression — either a single token that is an -// expression, an expression started by a keyword like `function` or -// `new`, or an expression wrapped in punctuation like `()`, `[]`, -// or `{}`. - -pp.parseExprAtom = function (refShorthandDefaultPos) { - var node = undefined, - canBeArrow = this.state.potentialArrowAt === this.state.start; - switch (this.state.type) { - case _tokenizerTypes.types._super: - if (!this.state.inFunction) this.raise(this.state.start, "'super' outside of function or class"); - case _tokenizerTypes.types._this: - var type = this.match(_tokenizerTypes.types._this) ? "ThisExpression" : "Super"; - node = this.startNode(); - this.next(); - return this.finishNode(node, type); - - case _tokenizerTypes.types._yield: - if (this.state.inGenerator) this.unexpected(); - - case _tokenizerTypes.types._do: - if (this.options.features["es7.doExpressions"]) { - var _node = this.startNode(); - this.next(); - var oldInFunction = this.state.inFunction; - var oldLabels = this.state.labels; - this.state.labels = []; - this.state.inFunction = false; - _node.body = this.parseBlock(); - this.state.inFunction = oldInFunction; - this.state.labels = oldLabels; - return this.finishNode(_node, "DoExpression"); - } - - case _tokenizerTypes.types.name: - node = this.startNode(); - var id = this.parseIdent(true); - - if (this.options.features["es7.asyncFunctions"]) { - if (id.name === "await") { - if (this.inAsync) return this.parseAwait(node); - } else if (id.name === "async" && this.match(_tokenizerTypes.types._function) && !this.canInsertSemicolon()) { - this.next(); - return this.parseFunction(node, false, false, true); - } else if (canBeArrow && id.name === "async" && this.match(_tokenizerTypes.types.name)) { - var params = [this.parseIdent()]; - this.expect(_tokenizerTypes.types.arrow); - // var foo = bar => {}; - return this.parseArrowExpression(node, params, true); - } - } - - if (canBeArrow && !this.canInsertSemicolon() && this.eat(_tokenizerTypes.types.arrow)) { - return this.parseArrowExpression(node, [id]); - } - - return id; - - case _tokenizerTypes.types.regexp: - var value = this.state.value; - node = this.parseLiteral(value.value); - node.regex = { pattern: value.pattern, flags: value.flags }; - return node; - - case _tokenizerTypes.types.num:case _tokenizerTypes.types.string: - return this.parseLiteral(this.state.value); - - case _tokenizerTypes.types._null:case _tokenizerTypes.types._true:case _tokenizerTypes.types._false: - node = this.startNode(); - node.rawValue = node.value = this.match(_tokenizerTypes.types._null) ? null : this.match(_tokenizerTypes.types._true); - node.raw = this.state.type.keyword; - this.next(); - return this.finishNode(node, "Literal"); - - case _tokenizerTypes.types.parenL: - return this.parseParenAndDistinguishExpression(null, null, canBeArrow); - - case _tokenizerTypes.types.bracketL: - node = this.startNode(); - this.next(); - // check whether this is array comprehension or regular array - if (this.options.features["es7.comprehensions"] && this.match(_tokenizerTypes.types._for)) { - return this.parseComprehension(node, false); - } - node.elements = this.parseExprList(_tokenizerTypes.types.bracketR, true, true, refShorthandDefaultPos); - this.toReferencedList(node.elements); - return this.finishNode(node, "ArrayExpression"); - - case _tokenizerTypes.types.braceL: - return this.parseObj(false, refShorthandDefaultPos); - - case _tokenizerTypes.types._function: - node = this.startNode(); - this.next(); - return this.parseFunction(node, false); - - case _tokenizerTypes.types.at: - this.parseDecorators(); - - case _tokenizerTypes.types._class: - node = this.startNode(); - this.takeDecorators(node); - return this.parseClass(node, false); - - case _tokenizerTypes.types._new: - return this.parseNew(); - - case _tokenizerTypes.types.backQuote: - return this.parseTemplate(); - - case _tokenizerTypes.types.doubleColon: - node = this.startNode(); - this.next(); - node.object = null; - var callee = node.callee = this.parseNoCallExpr(); - if (callee.type === "MemberExpression") { - return this.finishNode(node, "BindExpression"); - } else { - this.raise(callee.start, "Binding should be performed on object property."); - } - - default: - this.unexpected(); - } -}; - -pp.parseLiteral = function (value) { - var node = this.startNode(); - node.rawValue = node.value = value; - node.raw = this.input.slice(this.state.start, this.state.end); - this.next(); - return this.finishNode(node, "Literal"); -}; - -pp.parseParenExpression = function () { - this.expect(_tokenizerTypes.types.parenL); - var val = this.parseExpression(); - this.expect(_tokenizerTypes.types.parenR); - return val; -}; - -pp.parseParenAndDistinguishExpression = function (startPos, startLoc, canBeArrow, isAsync) { - startPos = startPos || this.state.start; - startLoc = startLoc || this.state.startLoc; - var val = undefined; - this.next(); - - if (this.options.features["es7.comprehensions"] && this.match(_tokenizerTypes.types._for)) { - return this.parseComprehension(this.startNodeAt(startPos, startLoc), true); - } - - var innerStartPos = this.state.start, - innerStartLoc = this.state.startLoc; - var exprList = [], - first = true; - var refShorthandDefaultPos = { start: 0 }, - spreadStart = undefined, - innerParenStart = undefined, - optionalCommaStart = undefined; - while (!this.match(_tokenizerTypes.types.parenR)) { - if (first) { - first = false; - } else { - this.expect(_tokenizerTypes.types.comma); - if (this.match(_tokenizerTypes.types.parenR) && this.options.features["es7.trailingFunctionCommas"]) { - optionalCommaStart = this.state.start; - break; - } - } - - if (this.match(_tokenizerTypes.types.ellipsis)) { - var spreadNodeStartPos = this.state.start, - spreadNodeStartLoc = this.state.startLoc; - spreadStart = this.state.start; - exprList.push(this.parseParenItem(this.parseRest(), spreadNodeStartLoc, spreadNodeStartPos)); - break; - } else { - if (this.match(_tokenizerTypes.types.parenL) && !innerParenStart) { - innerParenStart = this.state.start; - } - exprList.push(this.parseMaybeAssign(false, refShorthandDefaultPos, this.parseParenItem)); - } - } - var innerEndPos = this.state.start; - var innerEndLoc = this.state.startLoc; - this.expect(_tokenizerTypes.types.parenR); - - if (canBeArrow && !this.canInsertSemicolon() && this.eat(_tokenizerTypes.types.arrow)) { - if (innerParenStart) this.unexpected(innerParenStart); - return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, isAsync); - } - - if (!exprList.length) { - if (isAsync) { - return; - } else { - this.unexpected(this.state.lastTokStart); - } - } - if (optionalCommaStart) this.unexpected(optionalCommaStart); - if (spreadStart) this.unexpected(spreadStart); - if (refShorthandDefaultPos.start) this.unexpected(refShorthandDefaultPos.start); - - if (exprList.length > 1) { - val = this.startNodeAt(innerStartPos, innerStartLoc); - val.expressions = exprList; - this.toReferencedList(val.expressions); - this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc); - } else { - val = exprList[0]; - } - - val.parenthesizedExpression = true; - return val; -}; - -pp.parseParenItem = function (node) { - return node; -}; - -// New's precedence is slightly tricky. It must allow its argument -// to be a `[]` or dot subscript expression, but not a call — at -// least, not without wrapping it in parentheses. Thus, it uses the - -pp.parseNew = function () { - var node = this.startNode(); - var meta = this.parseIdent(true); - - if (this.eat(_tokenizerTypes.types.dot)) { - node.meta = meta; - node.property = this.parseIdent(true); - - if (node.property.name !== "target") { - this.raise(node.property.start, "The only valid meta property for new is new.target"); - } - - return this.finishNode(node, "MetaProperty"); - } - - node.callee = this.parseNoCallExpr(); - - if (this.eat(_tokenizerTypes.types.parenL)) { - node.arguments = this.parseExprList(_tokenizerTypes.types.parenR, this.options.features["es7.trailingFunctionCommas"]); - this.toReferencedList(node.arguments); - } else { - node.arguments = []; - } - - return this.finishNode(node, "NewExpression"); -}; - -// Parse template expression. - -pp.parseTemplateElement = function () { - var elem = this.startNode(); - elem.value = { - raw: this.input.slice(this.state.start, this.state.end).replace(/\r\n?/g, "\n"), - cooked: this.state.value - }; - this.next(); - elem.tail = this.match(_tokenizerTypes.types.backQuote); - return this.finishNode(elem, "TemplateElement"); -}; - -pp.parseTemplate = function () { - var node = this.startNode(); - this.next(); - node.expressions = []; - var curElt = this.parseTemplateElement(); - node.quasis = [curElt]; - while (!curElt.tail) { - this.expect(_tokenizerTypes.types.dollarBraceL); - node.expressions.push(this.parseExpression()); - this.expect(_tokenizerTypes.types.braceR); - node.quasis.push(curElt = this.parseTemplateElement()); - } - this.next(); - return this.finishNode(node, "TemplateLiteral"); -}; - -// Parse an object literal or binding pattern. - -pp.parseObj = function (isPattern, refShorthandDefaultPos) { - var node = this.startNode(), - first = true, - propHash = Object.create(null); - node.properties = []; - var decorators = []; - this.next(); - while (!this.eat(_tokenizerTypes.types.braceR)) { - if (first) { - first = false; - } else { - this.expect(_tokenizerTypes.types.comma); - if (this.eat(_tokenizerTypes.types.braceR)) break; - } - - while (this.match(_tokenizerTypes.types.at)) { - decorators.push(this.parseDecorator()); - } - - var prop = this.startNode(), - isGenerator = false, - isAsync = false, - startPos = undefined, - startLoc = undefined; - if (decorators.length) { - prop.decorators = decorators; - decorators = []; - } - if (this.options.features["es7.objectRestSpread"] && this.match(_tokenizerTypes.types.ellipsis)) { - prop = this.parseSpread(); - prop.type = "SpreadProperty"; - node.properties.push(prop); - continue; - } - prop.method = false; - prop.shorthand = false; - if (isPattern || refShorthandDefaultPos) { - startPos = this.state.start; - startLoc = this.state.startLoc; - } - if (!isPattern) { - isGenerator = this.eat(_tokenizerTypes.types.star); - } - if (!isPattern && this.options.features["es7.asyncFunctions"] && this.isContextual("async")) { - if (isGenerator) this.unexpected(); - var asyncId = this.parseIdent(); - if (this.match(_tokenizerTypes.types.colon) || this.match(_tokenizerTypes.types.parenL) || this.match(_tokenizerTypes.types.braceR)) { - prop.key = asyncId; - } else { - isAsync = true; - this.parsePropertyName(prop); - } - } else { - this.parsePropertyName(prop); - } - this.parseObjPropValue(prop, startPos, startLoc, isGenerator, isAsync, isPattern, refShorthandDefaultPos); - this.checkPropClash(prop, propHash); - node.properties.push(this.finishNode(prop, "Property")); - } - if (decorators.length) { - this.raise(this.state.start, "You have trailing decorators with no property"); - } - return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression"); -}; - -pp.parseObjPropValue = function (prop, startPos, startLoc, isGenerator, isAsync, isPattern, refShorthandDefaultPos) { - if (this.eat(_tokenizerTypes.types.colon)) { - prop.value = isPattern ? this.parseMaybeDefault(this.state.start, this.state.startLoc) : this.parseMaybeAssign(false, refShorthandDefaultPos); - prop.kind = "init"; - } else if (this.match(_tokenizerTypes.types.parenL)) { - if (isPattern) this.unexpected(); - prop.kind = "init"; - prop.method = true; - prop.value = this.parseMethod(isGenerator, isAsync); - } else if (!prop.computed && prop.key.type === "Identifier" && (prop.key.name === "get" || prop.key.name === "set") && !this.match(_tokenizerTypes.types.comma) && !this.match(_tokenizerTypes.types.braceR)) { - if (isGenerator || isAsync || isPattern) this.unexpected(); - prop.kind = prop.key.name; - this.parsePropertyName(prop); - prop.value = this.parseMethod(false); - var paramCount = prop.kind === "get" ? 0 : 1; - if (prop.value.params.length !== paramCount) { - var start = prop.value.start; - if (prop.kind === "get") this.raise(start, "getter should have no params");else this.raise(start, "setter should have exactly one param"); - } - } else if (!prop.computed && prop.key.type === "Identifier") { - prop.kind = "init"; - if (isPattern) { - if (this.isKeyword(prop.key.name) || this.strict && (_utilIdentifier.reservedWords.strictBind(prop.key.name) || _utilIdentifier.reservedWords.strict(prop.key.name)) || !this.options.allowReserved && this.isReservedWord(prop.key.name)) this.raise(prop.key.start, "Binding " + prop.key.name); - prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key.__clone()); - } else if (this.match(_tokenizerTypes.types.eq) && refShorthandDefaultPos) { - if (!refShorthandDefaultPos.start) refShorthandDefaultPos.start = this.state.start; - prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key.__clone()); - } else { - prop.value = prop.key.__clone(); - } - prop.shorthand = true; - } else { - this.unexpected(); - } -}; - -pp.parsePropertyName = function (prop) { - if (this.eat(_tokenizerTypes.types.bracketL)) { - prop.computed = true; - prop.key = this.parseMaybeAssign(); - this.expect(_tokenizerTypes.types.bracketR); - return prop.key; - } else { - prop.computed = false; - return prop.key = this.match(_tokenizerTypes.types.num) || this.match(_tokenizerTypes.types.string) ? this.parseExprAtom() : this.parseIdent(true); - } -}; - -// Initialize empty function node. - -pp.initFunction = function (node, isAsync) { - node.id = null; - node.generator = false; - node.expression = false; - if (this.options.features["es7.asyncFunctions"]) { - node.async = !!isAsync; - } -}; - -// Parse object or class method. - -pp.parseMethod = function (isGenerator, isAsync) { - var node = this.startNode(); - this.initFunction(node, isAsync); - this.expect(_tokenizerTypes.types.parenL); - node.params = this.parseBindingList(_tokenizerTypes.types.parenR, false, this.options.features["es7.trailingFunctionCommas"]); - node.generator = isGenerator; - this.parseFunctionBody(node); - return this.finishNode(node, "FunctionExpression"); -}; - -// Parse arrow function expression with given parameters. - -pp.parseArrowExpression = function (node, params, isAsync) { - this.initFunction(node, isAsync); - node.params = this.toAssignableList(params, true); - this.parseFunctionBody(node, true); - return this.finishNode(node, "ArrowFunctionExpression"); -}; - -// Parse function body and check parameters. - -pp.parseFunctionBody = function (node, allowExpression) { - var isExpression = allowExpression && !this.match(_tokenizerTypes.types.braceL); - - var oldInAsync = this.inAsync; - this.inAsync = node.async; - if (isExpression) { - node.body = this.parseMaybeAssign(); - node.expression = true; - } else { - // Start a new scope with regard to labels and the `inFunction` - // flag (restore them to their old value afterwards). - var oldInFunc = this.state.inFunction, - oldInGen = this.state.inGenerator, - oldLabels = this.state.labels; - this.state.inFunction = true;this.state.inGenerator = node.generator;this.state.labels = []; - node.body = this.parseBlock(true); - node.expression = false; - this.state.inFunction = oldInFunc;this.state.inGenerator = oldInGen;this.state.labels = oldLabels; - } - this.inAsync = oldInAsync; - - // If this is a strict mode function, verify that argument names - // are not repeated, and it does not try to bind the words `eval` - // or `arguments`. - if (this.strict || !isExpression && node.body.body.length && this.isUseStrict(node.body.body[0])) { - var nameHash = Object.create(null), - oldStrict = this.strict; - this.strict = true; - if (node.id) { - this.checkLVal(node.id, true); - } - var _arr = node.params; - for (var _i = 0; _i < _arr.length; _i++) { - var param = _arr[_i]; - this.checkLVal(param, true, nameHash); - } - this.strict = oldStrict; - } -}; - -// Parses a comma-separated list of expressions, and returns them as -// an array. `close` is the token type that ends the list, and -// `allowEmpty` can be turned on to allow subsequent commas with -// nothing in between them to be parsed as `null` (which is needed -// for array literals). - -pp.parseExprList = function (close, allowTrailingComma, allowEmpty, refShorthandDefaultPos) { - var elts = [], - first = true; - while (!this.eat(close)) { - if (first) { - first = false; - } else { - this.expect(_tokenizerTypes.types.comma); - if (allowTrailingComma && this.eat(close)) break; - } - - elts.push(this.parseExprListItem(allowEmpty, refShorthandDefaultPos)); - } - return elts; -}; - -pp.parseExprListItem = function (allowEmpty, refShorthandDefaultPos) { - var elt = undefined; - if (allowEmpty && this.match(_tokenizerTypes.types.comma)) { - elt = null; - } else if (this.match(_tokenizerTypes.types.ellipsis)) { - elt = this.parseSpread(refShorthandDefaultPos); - } else { - elt = this.parseMaybeAssign(false, refShorthandDefaultPos); - } - return elt; -}; - -// Parse the next token as an identifier. If `liberal` is true (used -// when parsing properties), it will also convert keywords into -// identifiers. - -pp.parseIdent = function (liberal) { - var node = this.startNode(); - if (this.match(_tokenizerTypes.types.name)) { - if (!liberal && (!this.options.allowReserved && this.isReservedWord(this.state.value) || this.strict && _utilIdentifier.reservedWords.strict(this.state.value))) this.raise(this.state.start, "The keyword '" + this.state.value + "' is reserved"); - node.name = this.state.value; - } else if (liberal && this.state.type.keyword) { - node.name = this.state.type.keyword; - } else { - this.unexpected(); - } - this.next(); - return this.finishNode(node, "Identifier"); -}; - -// Parses await expression inside async function. - -pp.parseAwait = function (node) { - if (this.eat(_tokenizerTypes.types.semi) || this.canInsertSemicolon()) { - this.unexpected(); - } - node.all = this.eat(_tokenizerTypes.types.star); - node.argument = this.parseMaybeUnary(); - return this.finishNode(node, "AwaitExpression"); -}; - -// Parses yield expression inside generator. - -pp.parseYield = function () { - var node = this.startNode(); - this.next(); - if (this.match(_tokenizerTypes.types.semi) || this.canInsertSemicolon() || !this.match(_tokenizerTypes.types.star) && !this.state.type.startsExpr) { - node.delegate = false; - node.argument = null; - } else { - node.delegate = this.eat(_tokenizerTypes.types.star); - node.argument = this.parseMaybeAssign(); - } - return this.finishNode(node, "YieldExpression"); -}; - -// Parses array and generator comprehensions. - -pp.parseComprehension = function (node, isGenerator) { - node.blocks = []; - while (this.match(_tokenizerTypes.types._for)) { - var block = this.startNode(); - this.next(); - this.expect(_tokenizerTypes.types.parenL); - block.left = this.parseBindingAtom(); - this.checkLVal(block.left, true); - this.expectContextual("of"); - block.right = this.parseExpression(); - this.expect(_tokenizerTypes.types.parenR); - node.blocks.push(this.finishNode(block, "ComprehensionBlock")); - } - node.filter = this.eat(_tokenizerTypes.types._if) ? this.parseParenExpression() : null; - node.body = this.parseExpression(); - this.expect(isGenerator ? _tokenizerTypes.types.parenR : _tokenizerTypes.types.bracketR); - node.generator = isGenerator; - return this.finishNode(node, "ComprehensionExpression"); -}; -},{"617":617,"629":629,"630":630}],617:[function(_dereq_,module,exports){ -"use strict"; - -exports.__esModule = true; -// istanbul ignore next - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } - -// istanbul ignore next - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -// istanbul ignore next - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var _utilIdentifier = _dereq_(630); - -var _options = _dereq_(614); - -var _tokenizer = _dereq_(627); - -var _tokenizer2 = _interopRequireDefault(_tokenizer); - -// Registered plugins - -var plugins = {}; - -exports.plugins = plugins; - -var Parser = (function (_Tokenizer) { - _inherits(Parser, _Tokenizer); - - function Parser(options, input) { - _classCallCheck(this, Parser); - - _Tokenizer.call(this, input); - - this.options = _options.getOptions(options); - this.isKeyword = _utilIdentifier.isKeyword; - this.isReservedWord = _utilIdentifier.reservedWords[6]; - this.input = input; - this.loadPlugins(this.options.plugins); - - // Figure out if it's a module code. - this.inModule = this.options.sourceType === "module"; - this.strict = this.options.strictMode === false ? false : this.inModule; - - // If enabled, skip leading hashbang line. - if (this.state.pos === 0 && this.input[0] === "#" && this.input[1] === "!") { - this.skipLineComment(2); - } - } - - Parser.prototype.extend = function extend(name, f) { - this[name] = f(this[name]); - }; - - Parser.prototype.loadPlugins = function loadPlugins(plugins) { - for (var _name in plugins) { - var plugin = exports.plugins[_name]; - if (!plugin) throw new Error("Plugin '" + _name + "' not found"); - plugin(this, plugins[_name]); - } - }; - - Parser.prototype.parse = function parse() { - var file = this.startNode(); - var program = this.startNode(); - this.nextToken(); - return this.parseTopLevel(file, program); - }; - - return Parser; -})(_tokenizer2["default"]); - -exports["default"] = Parser; -},{"614":614,"627":627,"630":630}],618:[function(_dereq_,module,exports){ -"use strict"; - -// istanbul ignore next - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } - -var _utilLocation = _dereq_(631); - -var _index = _dereq_(617); - -var _index2 = _interopRequireDefault(_index); - -var pp = _index2["default"].prototype; - -// This function is used to raise exceptions on parse errors. It -// takes an offset integer (into the current `input`) to indicate -// the location of the error, attaches the position to the end -// of the error message, and then raises a `SyntaxError` with that -// message. - -pp.raise = function (pos, message) { - var loc = _utilLocation.getLineInfo(this.input, pos); - message += " (" + loc.line + ":" + loc.column + ")"; - var err = new SyntaxError(message); - err.pos = pos; - err.loc = loc; - throw err; -}; -},{"617":617,"631":631}],619:[function(_dereq_,module,exports){ -"use strict"; - -// istanbul ignore next - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } - -var _tokenizerTypes = _dereq_(629); - -var _index = _dereq_(617); - -var _index2 = _interopRequireDefault(_index); - -var _utilIdentifier = _dereq_(630); - -var pp = _index2["default"].prototype; - -// Convert existing expression atom to assignable pattern -// if possible. - -pp.toAssignable = function (node, isBinding) { - if (node) { - switch (node.type) { - case "Identifier": - case "ObjectPattern": - case "ArrayPattern": - case "AssignmentPattern": - break; - - case "ObjectExpression": - node.type = "ObjectPattern"; - var _arr = node.properties; - for (var _i = 0; _i < _arr.length; _i++) { - var prop = _arr[_i]; - if (prop.type === "SpreadProperty") continue; - if (prop.kind !== "init") this.raise(prop.key.start, "Object pattern can't contain getter or setter"); - this.toAssignable(prop.value, isBinding); - } - break; - - case "ArrayExpression": - node.type = "ArrayPattern"; - this.toAssignableList(node.elements, isBinding); - break; - - case "AssignmentExpression": - if (node.operator === "=") { - node.type = "AssignmentPattern"; - delete node.operator; - } else { - this.raise(node.left.end, "Only '=' operator can be used for specifying default value."); - } - break; - - case "MemberExpression": - if (!isBinding) break; - - default: - this.raise(node.start, "Assigning to rvalue"); - } - } - return node; -}; - -// Convert list of expression atoms to binding list. - -pp.toAssignableList = function (exprList, isBinding) { - var end = exprList.length; - if (end) { - var last = exprList[end - 1]; - if (last && last.type === "RestElement") { - --end; - } else if (last && last.type === "SpreadElement") { - last.type = "RestElement"; - var arg = last.argument; - this.toAssignable(arg, isBinding); - if (arg.type !== "Identifier" && arg.type !== "MemberExpression" && arg.type !== "ArrayPattern") { - this.unexpected(arg.start); - } - --end; - } - } - for (var i = 0; i < end; i++) { - var elt = exprList[i]; - if (elt) this.toAssignable(elt, isBinding); - } - return exprList; -}; - -// Convert list of expression atoms to a list of - -pp.toReferencedList = function (exprList) { - return exprList; -}; - -// Parses spread element. - -pp.parseSpread = function (refShorthandDefaultPos) { - var node = this.startNode(); - this.next(); - node.argument = this.parseMaybeAssign(refShorthandDefaultPos); - return this.finishNode(node, "SpreadElement"); -}; - -pp.parseRest = function () { - var node = this.startNode(); - this.next(); - node.argument = this.match(_tokenizerTypes.types.name) || this.match(_tokenizerTypes.types.bracketL) ? this.parseBindingAtom() : this.unexpected(); - return this.finishNode(node, "RestElement"); -}; - -// Parses lvalue (assignable) atom. - -pp.parseBindingAtom = function () { - switch (this.state.type) { - case _tokenizerTypes.types.name: - return this.parseIdent(); - - case _tokenizerTypes.types.bracketL: - var node = this.startNode(); - this.next(); - node.elements = this.parseBindingList(_tokenizerTypes.types.bracketR, true, true); - return this.finishNode(node, "ArrayPattern"); - - case _tokenizerTypes.types.braceL: - return this.parseObj(true); - - default: - this.unexpected(); - } -}; - -pp.parseBindingList = function (close, allowEmpty, allowTrailingComma) { - var elts = [], - first = true; - while (!this.eat(close)) { - if (first) first = false;else this.expect(_tokenizerTypes.types.comma); - if (allowEmpty && this.match(_tokenizerTypes.types.comma)) { - elts.push(null); - } else if (allowTrailingComma && this.eat(close)) { - break; - } else if (this.match(_tokenizerTypes.types.ellipsis)) { - elts.push(this.parseAssignableListItemTypes(this.parseRest())); - this.expect(close); - break; - } else { - var left = this.parseMaybeDefault(); - this.parseAssignableListItemTypes(left); - elts.push(this.parseMaybeDefault(null, null, left)); - } - } - return elts; -}; - -pp.parseAssignableListItemTypes = function (param) { - return param; -}; - -// Parses assignment pattern around given atom if possible. - -pp.parseMaybeDefault = function (startPos, startLoc, left) { - startLoc = startLoc || this.state.startLoc; - startPos = startPos || this.state.start; - left = left || this.parseBindingAtom(); - if (!this.eat(_tokenizerTypes.types.eq)) return left; - - var node = this.startNodeAt(startPos, startLoc); - node.left = left; - node.right = this.parseMaybeAssign(); - return this.finishNode(node, "AssignmentPattern"); -}; - -// Verify that a node is an lval — something that can be assigned -// to. - -pp.checkLVal = function (expr, isBinding, checkClashes) { - switch (expr.type) { - case "Identifier": - if (this.strict && (_utilIdentifier.reservedWords.strictBind(expr.name) || _utilIdentifier.reservedWords.strict(expr.name))) this.raise(expr.start, (isBinding ? "Binding " : "Assigning to ") + expr.name + " in strict mode"); - if (checkClashes) { - if (checkClashes[expr.name]) { - this.raise(expr.start, "Argument name clash in strict mode"); - } else { - checkClashes[expr.name] = true; - } - } - break; - - case "MemberExpression": - if (isBinding) this.raise(expr.start, (isBinding ? "Binding" : "Assigning to") + " member expression"); - break; - - case "ObjectPattern": - var _arr2 = expr.properties; - - for (var _i2 = 0; _i2 < _arr2.length; _i2++) { - var prop = _arr2[_i2]; - if (prop.type === "Property") prop = prop.value; - this.checkLVal(prop, isBinding, checkClashes); - } - break; - - case "ArrayPattern": - var _arr3 = expr.elements; - - for (var _i3 = 0; _i3 < _arr3.length; _i3++) { - var elem = _arr3[_i3]; - if (elem) this.checkLVal(elem, isBinding, checkClashes); - } - break; - - case "AssignmentPattern": - this.checkLVal(expr.left, isBinding, checkClashes); - break; - - case "SpreadProperty": - case "RestElement": - this.checkLVal(expr.argument, isBinding, checkClashes); - break; - - default: - this.raise(expr.start, (isBinding ? "Binding" : "Assigning to") + " rvalue"); - } -}; -},{"617":617,"629":629,"630":630}],620:[function(_dereq_,module,exports){ -"use strict"; - -exports.__esModule = true; -// istanbul ignore next - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } - -// istanbul ignore next - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -var _index = _dereq_(617); - -var _index2 = _interopRequireDefault(_index); - -var _utilLocation = _dereq_(631); - -// Start an AST node, attaching a start offset. - -var pp = _index2["default"].prototype; - -var Node = (function () { - function Node(parser, pos, loc) { - _classCallCheck(this, Node); - - this.type = ""; - this.start = pos; - this.end = 0; - this.loc = new _utilLocation.SourceLocation(loc); - } - - Node.prototype.__clone = function __clone() { - var node2 = new Node(); - for (var key in this) node2[key] = this[key]; - return node2; - }; - - return Node; -})(); - -exports.Node = Node; - -pp.startNode = function () { - return new Node(this, this.state.start, this.state.startLoc); -}; - -pp.startNodeAt = function (pos, loc) { - return new Node(this, pos, loc); -}; - -function finishNodeAt(node, type, pos, loc) { - node.type = type; - node.end = pos; - node.loc.end = loc; - this.processComment(node); - return node; -} - -// Finish an AST node, adding `type` and `end` properties. - -pp.finishNode = function (node, type) { - return finishNodeAt.call(this, node, type, this.state.lastTokEnd, this.state.lastTokEndLoc); -}; - -// Finish node at given position - -pp.finishNodeAt = function (node, type, pos, loc) { - return finishNodeAt.call(this, node, type, pos, loc); -}; -},{"617":617,"631":631}],621:[function(_dereq_,module,exports){ -"use strict"; - -// istanbul ignore next - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } - -var _tokenizerTypes = _dereq_(629); - -var _index = _dereq_(617); - -var _index2 = _interopRequireDefault(_index); - -var _utilWhitespace = _dereq_(632); - -var pp = _index2["default"].prototype; - -// ### Statement parsing - -// Parse a program. Initializes the parser, reads any number of -// statements, and wraps them in a Program node. Optionally takes a -// `program` argument. If present, the statements will be appended -// to its body instead of creating a new node. - -pp.parseTopLevel = function (file, program) { - program.sourceType = this.options.sourceType; - program.body = []; - - var first = true; - while (!this.match(_tokenizerTypes.types.eof)) { - var stmt = this.parseStatement(true, true); - program.body.push(stmt); - if (first) { - if (this.isUseStrict(stmt)) this.setStrict(true); - first = false; - } - } - this.next(); - - file.program = this.finishNode(program, "Program"); - file.comments = this.state.comments; - file.tokens = this.state.tokens; - - return this.finishNode(file, "File"); -}; - -var loopLabel = { kind: "loop" }, - switchLabel = { kind: "switch" }; - -// Parse a single statement. -// -// If expecting a statement and finding a slash operator, parse a -// regular expression literal. This is to handle cases like -// `if (foo) /blah/.exec(foo)`, where looking at the previous token -// does not help. - -pp.parseStatement = function (declaration, topLevel) { - if (this.match(_tokenizerTypes.types.at)) { - this.parseDecorators(true); - } - - var starttype = this.state.type, - node = this.startNode(); - - // Most types of statements are recognized by the keyword they - // start with. Many are trivial to parse, some require a bit of - // complexity. - - switch (starttype) { - case _tokenizerTypes.types._break:case _tokenizerTypes.types._continue: - return this.parseBreakContinueStatement(node, starttype.keyword); - case _tokenizerTypes.types._debugger: - return this.parseDebuggerStatement(node); - case _tokenizerTypes.types._do: - return this.parseDoStatement(node); - case _tokenizerTypes.types._for: - return this.parseForStatement(node); - case _tokenizerTypes.types._function: - if (!declaration) this.unexpected(); - return this.parseFunctionStatement(node); - - case _tokenizerTypes.types._class: - if (!declaration) this.unexpected(); - this.takeDecorators(node); - return this.parseClass(node, true); - - case _tokenizerTypes.types._if: - return this.parseIfStatement(node); - case _tokenizerTypes.types._return: - return this.parseReturnStatement(node); - case _tokenizerTypes.types._switch: - return this.parseSwitchStatement(node); - case _tokenizerTypes.types._throw: - return this.parseThrowStatement(node); - case _tokenizerTypes.types._try: - return this.parseTryStatement(node); - case _tokenizerTypes.types._let:case _tokenizerTypes.types._const: - if (!declaration) this.unexpected(); // NOTE: falls through to _var - case _tokenizerTypes.types._var: - return this.parseVarStatement(node, starttype); - case _tokenizerTypes.types._while: - return this.parseWhileStatement(node); - case _tokenizerTypes.types._with: - return this.parseWithStatement(node); - case _tokenizerTypes.types.braceL: - return this.parseBlock(); - case _tokenizerTypes.types.semi: - return this.parseEmptyStatement(node); - case _tokenizerTypes.types._export: - case _tokenizerTypes.types._import: - if (!this.options.allowImportExportEverywhere) { - if (!topLevel) this.raise(this.state.start, "'import' and 'export' may only appear at the top level"); - - if (!this.inModule) this.raise(this.state.start, "'import' and 'export' may appear only with 'sourceType: module'"); - } - return starttype === _tokenizerTypes.types._import ? this.parseImport(node) : this.parseExport(node); - - case _tokenizerTypes.types.name: - if (this.options.features["es7.asyncFunctions"] && this.state.value === "async") { - // peek ahead and see if next token is a function - var state = this.state.clone(); - this.next(); - if (this.match(_tokenizerTypes.types._function) && !this.canInsertSemicolon()) { - this.expect(_tokenizerTypes.types._function); - return this.parseFunction(node, true, false, true); - } else { - this.state = state; - } - } - - // If the statement does not start with a statement keyword or a - // brace, it's an ExpressionStatement or LabeledStatement. We - // simply start parsing an expression, and afterwards, if the - // next token is a colon and the expression was a simple - // Identifier node, we switch to interpreting it as a label. - default: - var maybeName = this.state.value, - expr = this.parseExpression(); - - if (starttype === _tokenizerTypes.types.name && expr.type === "Identifier" && this.eat(_tokenizerTypes.types.colon)) { - return this.parseLabeledStatement(node, maybeName, expr); - } else { - return this.parseExpressionStatement(node, expr); - } - } -}; - -pp.takeDecorators = function (node) { - if (this.state.decorators.length) { - node.decorators = this.state.decorators; - this.state.decorators = []; - } -}; - -pp.parseDecorators = function (allowExport) { - while (this.match(_tokenizerTypes.types.at)) { - this.state.decorators.push(this.parseDecorator()); - } - - if (allowExport && this.match(_tokenizerTypes.types._export)) { - return; - } - - if (!this.match(_tokenizerTypes.types._class)) { - this.raise(this.state.start, "Leading decorators must be attached to a class declaration"); - } -}; - -pp.parseDecorator = function () { - if (!this.options.features["es7.decorators"]) { - this.unexpected(); - } - var node = this.startNode(); - this.next(); - node.expression = this.parseMaybeAssign(); - return this.finishNode(node, "Decorator"); -}; - -pp.parseBreakContinueStatement = function (node, keyword) { - var isBreak = keyword === "break"; - this.next(); - - if (this.eat(_tokenizerTypes.types.semi) || this.canInsertSemicolon()) { - node.label = null; - } else if (!this.match(_tokenizerTypes.types.name)) { - this.unexpected(); - } else { - node.label = this.parseIdent(); - this.semicolon(); - } - - // Verify that there is an actual destination to break or - // continue to. - for (var i = 0; i < this.state.labels.length; ++i) { - var lab = this.state.labels[i]; - if (node.label == null || lab.name === node.label.name) { - if (lab.kind != null && (isBreak || lab.kind === "loop")) break; - if (node.label && isBreak) break; - } - } - if (i === this.state.labels.length) this.raise(node.start, "Unsyntactic " + keyword); - return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement"); -}; - -pp.parseDebuggerStatement = function (node) { - this.next(); - this.semicolon(); - return this.finishNode(node, "DebuggerStatement"); -}; - -pp.parseDoStatement = function (node) { - this.next(); - this.state.labels.push(loopLabel); - node.body = this.parseStatement(false); - this.state.labels.pop(); - this.expect(_tokenizerTypes.types._while); - node.test = this.parseParenExpression(); - this.eat(_tokenizerTypes.types.semi); - return this.finishNode(node, "DoWhileStatement"); -}; - -// Disambiguating between a `for` and a `for`/`in` or `for`/`of` -// loop is non-trivial. Basically, we have to parse the init `var` -// statement or expression, disallowing the `in` operator (see -// the second parameter to `parseExpression`), and then check -// whether the next token is `in` or `of`. When there is no init -// part (semicolon immediately after the opening parenthesis), it -// is a regular `for` loop. - -pp.parseForStatement = function (node) { - this.next(); - this.state.labels.push(loopLabel); - this.expect(_tokenizerTypes.types.parenL); - - if (this.match(_tokenizerTypes.types.semi)) { - return this.parseFor(node, null); - } - - if (this.match(_tokenizerTypes.types._var) || this.match(_tokenizerTypes.types._let) || this.match(_tokenizerTypes.types._const)) { - var _init = this.startNode(), - varKind = this.state.type; - this.next(); - this.parseVar(_init, true, varKind); - this.finishNode(_init, "VariableDeclaration"); - if ((this.match(_tokenizerTypes.types._in) || this.isContextual("of")) && _init.declarations.length === 1 && !(varKind !== _tokenizerTypes.types._var && _init.declarations[0].init)) return this.parseForIn(node, _init); - return this.parseFor(node, _init); - } - - var refShorthandDefaultPos = { start: 0 }; - var init = this.parseExpression(true, refShorthandDefaultPos); - if (this.match(_tokenizerTypes.types._in) || this.isContextual("of")) { - this.toAssignable(init); - this.checkLVal(init); - return this.parseForIn(node, init); - } else if (refShorthandDefaultPos.start) { - this.unexpected(refShorthandDefaultPos.start); - } - return this.parseFor(node, init); -}; - -pp.parseFunctionStatement = function (node) { - this.next(); - return this.parseFunction(node, true); -}; - -pp.parseIfStatement = function (node) { - this.next(); - node.test = this.parseParenExpression(); - node.consequent = this.parseStatement(false); - node.alternate = this.eat(_tokenizerTypes.types._else) ? this.parseStatement(false) : null; - return this.finishNode(node, "IfStatement"); -}; - -pp.parseReturnStatement = function (node) { - if (!this.state.inFunction && !this.options.allowReturnOutsideFunction) { - this.raise(this.state.start, "'return' outside of function"); - } - - this.next(); - - // In `return` (and `break`/`continue`), the keywords with - // optional arguments, we eagerly look for a semicolon or the - // possibility to insert one. - - if (this.eat(_tokenizerTypes.types.semi) || this.canInsertSemicolon()) { - node.argument = null; - } else { - node.argument = this.parseExpression(); - this.semicolon(); - } - - return this.finishNode(node, "ReturnStatement"); -}; - -pp.parseSwitchStatement = function (node) { - this.next(); - node.discriminant = this.parseParenExpression(); - node.cases = []; - this.expect(_tokenizerTypes.types.braceL); - this.state.labels.push(switchLabel); - - // Statements under must be grouped (by label) in SwitchCase - // nodes. `cur` is used to keep the node that we are currently - // adding statements to. - - for (var cur, sawDefault; !this.match(_tokenizerTypes.types.braceR);) { - if (this.match(_tokenizerTypes.types._case) || this.match(_tokenizerTypes.types._default)) { - var isCase = this.match(_tokenizerTypes.types._case); - if (cur) this.finishNode(cur, "SwitchCase"); - node.cases.push(cur = this.startNode()); - cur.consequent = []; - this.next(); - if (isCase) { - cur.test = this.parseExpression(); - } else { - if (sawDefault) this.raise(this.state.lastTokStart, "Multiple default clauses"); - sawDefault = true; - cur.test = null; - } - this.expect(_tokenizerTypes.types.colon); - } else { - if (!cur) this.unexpected(); - cur.consequent.push(this.parseStatement(true)); - } - } - if (cur) this.finishNode(cur, "SwitchCase"); - this.next(); // Closing brace - this.state.labels.pop(); - return this.finishNode(node, "SwitchStatement"); -}; - -pp.parseThrowStatement = function (node) { - this.next(); - if (_utilWhitespace.lineBreak.test(this.input.slice(this.state.lastTokEnd, this.state.start))) this.raise(this.state.lastTokEnd, "Illegal newline after throw"); - node.argument = this.parseExpression(); - this.semicolon(); - return this.finishNode(node, "ThrowStatement"); -}; - -// Reused empty array added for node fields that are always empty. - -var empty = []; - -pp.parseTryStatement = function (node) { - this.next(); - node.block = this.parseBlock(); - node.handler = null; - if (this.match(_tokenizerTypes.types._catch)) { - var clause = this.startNode(); - this.next(); - this.expect(_tokenizerTypes.types.parenL); - clause.param = this.parseBindingAtom(); - this.checkLVal(clause.param, true); - this.expect(_tokenizerTypes.types.parenR); - clause.body = this.parseBlock(); - node.handler = this.finishNode(clause, "CatchClause"); - } - - node.guardedHandlers = empty; - node.finalizer = this.eat(_tokenizerTypes.types._finally) ? this.parseBlock() : null; - - if (!node.handler && !node.finalizer) { - this.raise(node.start, "Missing catch or finally clause"); - } - - return this.finishNode(node, "TryStatement"); -}; - -pp.parseVarStatement = function (node, kind) { - this.next(); - this.parseVar(node, false, kind); - this.semicolon(); - return this.finishNode(node, "VariableDeclaration"); -}; - -pp.parseWhileStatement = function (node) { - this.next(); - node.test = this.parseParenExpression(); - this.state.labels.push(loopLabel); - node.body = this.parseStatement(false); - this.state.labels.pop(); - return this.finishNode(node, "WhileStatement"); -}; - -pp.parseWithStatement = function (node) { - if (this.strict) this.raise(this.state.start, "'with' in strict mode"); - this.next(); - node.object = this.parseParenExpression(); - node.body = this.parseStatement(false); - return this.finishNode(node, "WithStatement"); -}; - -pp.parseEmptyStatement = function (node) { - this.next(); - return this.finishNode(node, "EmptyStatement"); -}; - -pp.parseLabeledStatement = function (node, maybeName, expr) { - var _arr = this.state.labels; - - for (var _i = 0; _i < _arr.length; _i++) { - var label = _arr[_i]; - if (label.name === maybeName) { - this.raise(expr.start, "Label '" + maybeName + "' is already declared"); - } - } - - var kind = this.state.type.isLoop ? "loop" : this.match(_tokenizerTypes.types._switch) ? "switch" : null; - for (var i = this.state.labels.length - 1; i >= 0; i--) { - var label = this.state.labels[i]; - if (label.statementStart === node.start) { - label.statementStart = this.state.start; - label.kind = kind; - } else { - break; - } - } - - this.state.labels.push({ name: maybeName, kind: kind, statementStart: this.state.start }); - node.body = this.parseStatement(true); - this.state.labels.pop(); - node.label = expr; - return this.finishNode(node, "LabeledStatement"); -}; - -pp.parseExpressionStatement = function (node, expr) { - node.expression = expr; - this.semicolon(); - return this.finishNode(node, "ExpressionStatement"); -}; - -// Parse a semicolon-enclosed block of statements, handling `"use -// strict"` declarations when `allowStrict` is true (used for -// function bodies). - -pp.parseBlock = function (allowStrict) { - var node = this.startNode(), - first = true, - oldStrict = undefined; - node.body = []; - this.expect(_tokenizerTypes.types.braceL); - while (!this.eat(_tokenizerTypes.types.braceR)) { - var stmt = this.parseStatement(true); - node.body.push(stmt); - if (first && allowStrict && this.isUseStrict(stmt)) { - oldStrict = this.strict; - this.setStrict(this.strict = true); - } - first = false; - } - if (oldStrict === false) this.setStrict(false); - return this.finishNode(node, "BlockStatement"); -}; - -// Parse a regular `for` loop. The disambiguation code in -// `parseStatement` will already have parsed the init statement or -// expression. - -pp.parseFor = function (node, init) { - node.init = init; - this.expect(_tokenizerTypes.types.semi); - node.test = this.match(_tokenizerTypes.types.semi) ? null : this.parseExpression(); - this.expect(_tokenizerTypes.types.semi); - node.update = this.match(_tokenizerTypes.types.parenR) ? null : this.parseExpression(); - this.expect(_tokenizerTypes.types.parenR); - node.body = this.parseStatement(false); - this.state.labels.pop(); - return this.finishNode(node, "ForStatement"); -}; - -// Parse a `for`/`in` and `for`/`of` loop, which are almost -// same from parser's perspective. - -pp.parseForIn = function (node, init) { - var type = this.match(_tokenizerTypes.types._in) ? "ForInStatement" : "ForOfStatement"; - this.next(); - node.left = init; - node.right = this.parseExpression(); - this.expect(_tokenizerTypes.types.parenR); - node.body = this.parseStatement(false); - this.state.labels.pop(); - return this.finishNode(node, type); -}; - -// Parse a list of variable declarations. - -pp.parseVar = function (node, isFor, kind) { - node.declarations = []; - node.kind = kind.keyword; - for (;;) { - var decl = this.startNode(); - this.parseVarHead(decl); - if (this.eat(_tokenizerTypes.types.eq)) { - decl.init = this.parseMaybeAssign(isFor); - } else if (kind === _tokenizerTypes.types._const && !(this.match(_tokenizerTypes.types._in) || this.isContextual("of"))) { - this.unexpected(); - } else if (decl.id.type !== "Identifier" && !(isFor && (this.match(_tokenizerTypes.types._in) || this.isContextual("of")))) { - this.raise(this.state.lastTokEnd, "Complex binding patterns require an initialization value"); - } else { - decl.init = null; - } - node.declarations.push(this.finishNode(decl, "VariableDeclarator")); - if (!this.eat(_tokenizerTypes.types.comma)) break; - } - return node; -}; - -pp.parseVarHead = function (decl) { - decl.id = this.parseBindingAtom(); - this.checkLVal(decl.id, true); -}; - -// Parse a function declaration or literal (depending on the -// `isStatement` parameter). - -pp.parseFunction = function (node, isStatement, allowExpressionBody, isAsync) { - this.initFunction(node, isAsync); - node.generator = this.eat(_tokenizerTypes.types.star); - - if (isStatement || this.match(_tokenizerTypes.types.name)) { - node.id = this.parseIdent(); - } - - this.parseFunctionParams(node); - this.parseFunctionBody(node, allowExpressionBody); - return this.finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression"); -}; - -pp.parseFunctionParams = function (node) { - this.expect(_tokenizerTypes.types.parenL); - node.params = this.parseBindingList(_tokenizerTypes.types.parenR, false, this.options.features["es7.trailingFunctionCommas"]); -}; - -// Parse a class declaration or literal (depending on the -// `isStatement` parameter). - -pp.parseClass = function (node, isStatement) { - this.next(); - this.parseClassId(node, isStatement); - this.parseClassSuper(node); - var classBody = this.startNode(); - var hadConstructor = false; - classBody.body = []; - this.expect(_tokenizerTypes.types.braceL); - var decorators = []; - while (!this.eat(_tokenizerTypes.types.braceR)) { - if (this.eat(_tokenizerTypes.types.semi)) continue; - if (this.match(_tokenizerTypes.types.at)) { - decorators.push(this.parseDecorator()); - continue; - } - var method = this.startNode(); - if (decorators.length) { - method.decorators = decorators; - decorators = []; - } - var isMaybeStatic = this.match(_tokenizerTypes.types.name) && this.state.value === "static"; - var isGenerator = this.eat(_tokenizerTypes.types.star), - isAsync = false; - this.parsePropertyName(method); - method["static"] = isMaybeStatic && !this.match(_tokenizerTypes.types.parenL); - if (method["static"]) { - if (isGenerator) this.unexpected(); - isGenerator = this.eat(_tokenizerTypes.types.star); - this.parsePropertyName(method); - } - if (!isGenerator && method.key.type === "Identifier" && !method.computed && this.isClassProperty()) { - classBody.body.push(this.parseClassProperty(method)); - continue; - } - if (this.options.features["es7.asyncFunctions"] && !this.match(_tokenizerTypes.types.parenL) && !method.computed && method.key.type === "Identifier" && method.key.name === "async") { - isAsync = true; - this.parsePropertyName(method); - } - var isGetSet = false; - method.kind = "method"; - if (!method.computed) { - var key = method.key; - - if (!isAsync && !isGenerator && key.type === "Identifier" && !this.match(_tokenizerTypes.types.parenL) && (key.name === "get" || key.name === "set")) { - isGetSet = true; - method.kind = key.name; - key = this.parsePropertyName(method); - } - if (!method["static"] && (key.type === "Identifier" && key.name === "constructor" || key.type === "Literal" && key.value === "constructor")) { - if (hadConstructor) this.raise(key.start, "Duplicate constructor in the same class"); - if (isGetSet) this.raise(key.start, "Constructor can't have get/set modifier"); - if (isGenerator) this.raise(key.start, "Constructor can't be a generator"); - if (isAsync) this.raise(key.start, "Constructor can't be an async function"); - method.kind = "constructor"; - hadConstructor = true; - } - } - if (method.kind === "constructor" && method.decorators) { - this.raise(method.start, "You can't attach decorators to a class constructor"); - } - this.parseClassMethod(classBody, method, isGenerator, isAsync); - if (isGetSet) { - var paramCount = method.kind === "get" ? 0 : 1; - if (method.value.params.length !== paramCount) { - var start = method.value.start; - if (method.kind === "get") { - this.raise(start, "getter should have no params"); - } else { - this.raise(start, "setter should have exactly one param"); - } - } - } - } - - if (decorators.length) { - this.raise(this.state.start, "You have trailing decorators with no method"); - } - - node.body = this.finishNode(classBody, "ClassBody"); - return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression"); -}; - -pp.isClassProperty = function () { - return this.match(_tokenizerTypes.types.eq) || this.match(_tokenizerTypes.types.semi) || this.canInsertSemicolon(); -}; - -pp.parseClassProperty = function (node) { - if (this.match(_tokenizerTypes.types.eq)) { - if (!this.options.features["es7.classProperties"]) this.unexpected(); - this.next(); - node.value = this.parseMaybeAssign(); - } else { - node.value = null; - } - this.semicolon(); - return this.finishNode(node, "ClassProperty"); -}; - -pp.parseClassMethod = function (classBody, method, isGenerator, isAsync) { - method.value = this.parseMethod(isGenerator, isAsync); - classBody.body.push(this.finishNode(method, "MethodDefinition")); -}; - -pp.parseClassId = function (node, isStatement) { - node.id = this.match(_tokenizerTypes.types.name) ? this.parseIdent() : isStatement ? this.unexpected() : null; -}; - -pp.parseClassSuper = function (node) { - node.superClass = this.eat(_tokenizerTypes.types._extends) ? this.parseExprSubscripts() : null; -}; - -// Parses module export declaration. - -pp.parseExport = function (node) { - this.next(); - // export * from '...' - if (this.match(_tokenizerTypes.types.star)) { - var specifier = this.startNode(); - this.next(); - if (this.options.features["es7.exportExtensions"] && this.eatContextual("as")) { - specifier.exported = this.parseIdent(); - node.specifiers = [this.finishNode(specifier, "ExportNamespaceSpecifier")]; - this.parseExportSpecifiersMaybe(node); - this.parseExportFrom(node, true); - } else { - this.parseExportFrom(node, true); - return this.finishNode(node, "ExportAllDeclaration"); - } - } else if (this.options.features["es7.exportExtensions"] && this.isExportDefaultSpecifier()) { - var specifier = this.startNode(); - specifier.exported = this.parseIdent(true); - node.specifiers = [this.finishNode(specifier, "ExportDefaultSpecifier")]; - if (this.match(_tokenizerTypes.types.comma) && this.lookahead().type === _tokenizerTypes.types.star) { - this.expect(_tokenizerTypes.types.comma); - var _specifier = this.startNode(); - this.expect(_tokenizerTypes.types.star); - this.expectContextual("as"); - _specifier.exported = this.parseIdent(); - node.specifiers.push(this.finishNode(_specifier, "ExportNamespaceSpecifier")); - } else { - this.parseExportSpecifiersMaybe(node); - } - this.parseExportFrom(node, true); - } else if (this.eat(_tokenizerTypes.types._default)) { - // export default ... - var possibleDeclaration = this.match(_tokenizerTypes.types._function) || this.match(_tokenizerTypes.types._class); - var expr = this.parseMaybeAssign(); - var needsSemi = true; - if (possibleDeclaration) { - needsSemi = false; - if (expr.id) { - expr.type = expr.type === "FunctionExpression" ? "FunctionDeclaration" : "ClassDeclaration"; - } - } - node.declaration = expr; - if (needsSemi) this.semicolon(); - this.checkExport(node); - return this.finishNode(node, "ExportDefaultDeclaration"); - } else if (this.state.type.keyword || this.shouldParseExportDeclaration()) { - node.specifiers = []; - node.source = null; - node.declaration = this.parseExportDeclaration(node); - } else { - // export { x, y as z } [from '...'] - node.declaration = null; - node.specifiers = this.parseExportSpecifiers(); - this.parseExportFrom(node); - } - this.checkExport(node); - return this.finishNode(node, "ExportNamedDeclaration"); -}; - -pp.parseExportDeclaration = function () { - return this.parseStatement(true); -}; - -pp.isExportDefaultSpecifier = function () { - if (this.match(_tokenizerTypes.types.name)) { - return this.state.value !== "type" && this.state.value !== "async"; - } - - if (!this.match(_tokenizerTypes.types._default)) { - return false; - } - - var lookahead = this.lookahead(); - return lookahead.type === _tokenizerTypes.types.comma || lookahead.type === _tokenizerTypes.types.name && lookahead.value === "from"; -}; - -pp.parseExportSpecifiersMaybe = function (node) { - if (this.eat(_tokenizerTypes.types.comma)) { - node.specifiers = node.specifiers.concat(this.parseExportSpecifiers()); - } -}; - -pp.parseExportFrom = function (node, expect) { - if (this.eatContextual("from")) { - node.source = this.match(_tokenizerTypes.types.string) ? this.parseExprAtom() : this.unexpected(); - this.checkExport(node); - } else { - if (expect) { - this.unexpected(); - } else { - node.source = null; - } - } - - this.semicolon(); -}; - -pp.shouldParseExportDeclaration = function () { - return this.options.features["es7.asyncFunctions"] && this.isContextual("async"); -}; - -pp.checkExport = function (node) { - if (this.state.decorators.length) { - var isClass = node.declaration && (node.declaration.type === "ClassDeclaration" || node.declaration.type === "ClassExpression"); - if (!node.declaration || !isClass) { - this.raise(node.start, "You can only use decorators on an export when exporting a class"); - } - this.takeDecorators(node.declaration); - } -}; - -// Parses a comma-separated list of module exports. - -pp.parseExportSpecifiers = function () { - var nodes = [], - first = true; - // export { x, y as z } [from '...'] - this.expect(_tokenizerTypes.types.braceL); - - while (!this.eat(_tokenizerTypes.types.braceR)) { - if (first) { - first = false; - } else { - this.expect(_tokenizerTypes.types.comma); - if (this.eat(_tokenizerTypes.types.braceR)) break; - } - - var node = this.startNode(); - node.local = this.parseIdent(this.match(_tokenizerTypes.types._default)); - node.exported = this.eatContextual("as") ? this.parseIdent(true) : node.local.__clone(); - nodes.push(this.finishNode(node, "ExportSpecifier")); - } - - return nodes; -}; - -// Parses import declaration. - -pp.parseImport = function (node) { - this.next(); - - // import '...' - if (this.match(_tokenizerTypes.types.string)) { - node.specifiers = []; - node.source = this.parseExprAtom(); - } else { - node.specifiers = []; - this.parseImportSpecifiers(node); - this.expectContextual("from"); - node.source = this.match(_tokenizerTypes.types.string) ? this.parseExprAtom() : this.unexpected(); - } - this.semicolon(); - return this.finishNode(node, "ImportDeclaration"); -}; - -// Parses a comma-separated list of module imports. - -pp.parseImportSpecifiers = function (node) { - var first = true; - if (this.match(_tokenizerTypes.types.name)) { - // import defaultObj, { x, y as z } from '...' - var startPos = this.state.start, - startLoc = this.state.startLoc; - node.specifiers.push(this.parseImportSpecifierDefault(this.parseIdent(), startPos, startLoc)); - if (!this.eat(_tokenizerTypes.types.comma)) return; - } - - if (this.match(_tokenizerTypes.types.star)) { - var specifier = this.startNode(); - this.next(); - this.expectContextual("as"); - specifier.local = this.parseIdent(); - this.checkLVal(specifier.local, true); - node.specifiers.push(this.finishNode(specifier, "ImportNamespaceSpecifier")); - return; - } - - this.expect(_tokenizerTypes.types.braceL); - while (!this.eat(_tokenizerTypes.types.braceR)) { - if (first) { - first = false; - } else { - this.expect(_tokenizerTypes.types.comma); - if (this.eat(_tokenizerTypes.types.braceR)) break; - } - - var specifier = this.startNode(); - specifier.imported = this.parseIdent(true); - specifier.local = this.eatContextual("as") ? this.parseIdent() : specifier.imported.__clone(); - this.checkLVal(specifier.local, true); - node.specifiers.push(this.finishNode(specifier, "ImportSpecifier")); - } -}; - -pp.parseImportSpecifierDefault = function (id, startPos, startLoc) { - var node = this.startNodeAt(startPos, startLoc); - node.local = id; - this.checkLVal(node.local, true); - return this.finishNode(node, "ImportDefaultSpecifier"); -}; -},{"617":617,"629":629,"632":632}],622:[function(_dereq_,module,exports){ -"use strict"; - -// istanbul ignore next - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } - -var _tokenizerTypes = _dereq_(629); - -var _index = _dereq_(617); - -var _index2 = _interopRequireDefault(_index); - -var _utilWhitespace = _dereq_(632); - -var pp = _index2["default"].prototype; - -// ## Parser utilities - -// Test whether a statement node is the string literal `"use strict"`. - -pp.isUseStrict = function (stmt) { - return stmt.type === "ExpressionStatement" && stmt.expression.type === "Literal" && stmt.expression.raw.slice(1, -1) === "use strict"; -}; - -// TODO - -pp.isRelational = function (op) { - return this.match(_tokenizerTypes.types.relational) && this.state.value === op; -}; - -// TODO - -pp.expectRelational = function (op) { - if (this.isRelational(op)) { - this.next(); - } else { - this.unexpected(); - } -}; - -// Tests whether parsed token is a contextual keyword. - -pp.isContextual = function (name) { - return this.match(_tokenizerTypes.types.name) && this.state.value === name; -}; - -// Consumes contextual keyword if possible. - -pp.eatContextual = function (name) { - return this.state.value === name && this.eat(_tokenizerTypes.types.name); -}; - -// Asserts that following token is given contextual keyword. - -pp.expectContextual = function (name) { - if (!this.eatContextual(name)) this.unexpected(); -}; - -// Test whether a semicolon can be inserted at the current position. - -pp.canInsertSemicolon = function () { - return this.match(_tokenizerTypes.types.eof) || this.match(_tokenizerTypes.types.braceR) || _utilWhitespace.lineBreak.test(this.input.slice(this.state.lastTokEnd, this.state.start)); -}; - -// Consume a semicolon, or, failing that, see if we are allowed to -// pretend that there is a semicolon at this position. - -pp.semicolon = function () { - if (!this.eat(_tokenizerTypes.types.semi) && !this.canInsertSemicolon()) this.unexpected(); -}; - -// Expect a token of a given type. If found, consume it, otherwise, -// raise an unexpected token error. - -pp.expect = function (type) { - return this.eat(type) || this.unexpected(); -}; - -// Raise an unexpected token error. - -pp.unexpected = function (pos) { - this.raise(pos != null ? pos : this.state.start, "Unexpected token"); -}; -},{"617":617,"629":629,"632":632}],623:[function(_dereq_,module,exports){ -"use strict"; - -exports.__esModule = true; -// istanbul ignore next - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } - -var _tokenizerTypes = _dereq_(629); - -var _parser = _dereq_(617); - -var _parser2 = _interopRequireDefault(_parser); - -var pp = _parser2["default"].prototype; - -pp.flowParseTypeInitialiser = function (tok) { - var oldInType = this.state.inType; - this.state.inType = true; - this.expect(tok || _tokenizerTypes.types.colon); - var type = this.flowParseType(); - this.state.inType = oldInType; - return type; -}; - -pp.flowParseDeclareClass = function (node) { - this.next(); - this.flowParseInterfaceish(node, true); - return this.finishNode(node, "DeclareClass"); -}; - -pp.flowParseDeclareFunction = function (node) { - this.next(); - - var id = node.id = this.parseIdent(); - - var typeNode = this.startNode(); - var typeContainer = this.startNode(); - - if (this.isRelational("<")) { - typeNode.typeParameters = this.flowParseTypeParameterDeclaration(); - } else { - typeNode.typeParameters = null; - } - - this.expect(_tokenizerTypes.types.parenL); - var tmp = this.flowParseFunctionTypeParams(); - typeNode.params = tmp.params; - typeNode.rest = tmp.rest; - this.expect(_tokenizerTypes.types.parenR); - typeNode.returnType = this.flowParseTypeInitialiser(); - - typeContainer.typeAnnotation = this.finishNode(typeNode, "FunctionTypeAnnotation"); - id.typeAnnotation = this.finishNode(typeContainer, "TypeAnnotation"); - - this.finishNode(id, id.type); - - this.semicolon(); - - return this.finishNode(node, "DeclareFunction"); -}; - -pp.flowParseDeclare = function (node) { - if (this.match(_tokenizerTypes.types._class)) { - return this.flowParseDeclareClass(node); - } else if (this.match(_tokenizerTypes.types._function)) { - return this.flowParseDeclareFunction(node); - } else if (this.match(_tokenizerTypes.types._var)) { - return this.flowParseDeclareVariable(node); - } else if (this.isContextual("module")) { - return this.flowParseDeclareModule(node); - } else { - this.unexpected(); - } -}; - -pp.flowParseDeclareVariable = function (node) { - this.next(); - node.id = this.flowParseTypeAnnotatableIdentifier(); - this.semicolon(); - return this.finishNode(node, "DeclareVariable"); -}; - -pp.flowParseDeclareModule = function (node) { - this.next(); - - if (this.match(_tokenizerTypes.types.string)) { - node.id = this.parseExprAtom(); - } else { - node.id = this.parseIdent(); - } - - var bodyNode = node.body = this.startNode(); - var body = bodyNode.body = []; - this.expect(_tokenizerTypes.types.braceL); - while (!this.match(_tokenizerTypes.types.braceR)) { - var node2 = this.startNode(); - - // todo: declare check - this.next(); - - body.push(this.flowParseDeclare(node2)); - } - this.expect(_tokenizerTypes.types.braceR); - - this.finishNode(bodyNode, "BlockStatement"); - return this.finishNode(node, "DeclareModule"); -}; - -// Interfaces - -pp.flowParseInterfaceish = function (node, allowStatic) { - node.id = this.parseIdent(); - - if (this.isRelational("<")) { - node.typeParameters = this.flowParseTypeParameterDeclaration(); - } else { - node.typeParameters = null; - } - - node["extends"] = []; - - if (this.eat(_tokenizerTypes.types._extends)) { - do { - node["extends"].push(this.flowParseInterfaceExtends()); - } while (this.eat(_tokenizerTypes.types.comma)); - } - - node.body = this.flowParseObjectType(allowStatic); -}; - -pp.flowParseInterfaceExtends = function () { - var node = this.startNode(); - - node.id = this.parseIdent(); - if (this.isRelational("<")) { - node.typeParameters = this.flowParseTypeParameterInstantiation(); - } else { - node.typeParameters = null; - } - - return this.finishNode(node, "InterfaceExtends"); -}; - -pp.flowParseInterface = function (node) { - this.flowParseInterfaceish(node, false); - return this.finishNode(node, "InterfaceDeclaration"); -}; - -// Type aliases - -pp.flowParseTypeAlias = function (node) { - node.id = this.parseIdent(); - - if (this.isRelational("<")) { - node.typeParameters = this.flowParseTypeParameterDeclaration(); - } else { - node.typeParameters = null; - } - - node.right = this.flowParseTypeInitialiser(_tokenizerTypes.types.eq); - this.semicolon(); - - return this.finishNode(node, "TypeAlias"); -}; - -// Type annotations - -pp.flowParseTypeParameterDeclaration = function () { - var node = this.startNode(); - node.params = []; - - this.expectRelational("<"); - while (!this.isRelational(">")) { - node.params.push(this.flowParseTypeAnnotatableIdentifier()); - if (!this.isRelational(">")) { - this.expect(_tokenizerTypes.types.comma); - } - } - this.expectRelational(">"); - - return this.finishNode(node, "TypeParameterDeclaration"); -}; - -pp.flowParseTypeParameterInstantiation = function () { - var node = this.startNode(), - oldInType = this.state.inType; - node.params = []; - - this.state.inType = true; - - this.expectRelational("<"); - while (!this.isRelational(">")) { - node.params.push(this.flowParseType()); - if (!this.isRelational(">")) { - this.expect(_tokenizerTypes.types.comma); - } - } - this.expectRelational(">"); - - this.state.inType = oldInType; - - return this.finishNode(node, "TypeParameterInstantiation"); -}; - -pp.flowParseObjectPropertyKey = function () { - return this.match(_tokenizerTypes.types.num) || this.match(_tokenizerTypes.types.string) ? this.parseExprAtom() : this.parseIdent(true); -}; - -pp.flowParseObjectTypeIndexer = function (node, isStatic) { - node["static"] = isStatic; - - this.expect(_tokenizerTypes.types.bracketL); - node.id = this.flowParseObjectPropertyKey(); - node.key = this.flowParseTypeInitialiser(); - this.expect(_tokenizerTypes.types.bracketR); - node.value = this.flowParseTypeInitialiser(); - - this.flowObjectTypeSemicolon(); - return this.finishNode(node, "ObjectTypeIndexer"); -}; - -pp.flowParseObjectTypeMethodish = function (node) { - node.params = []; - node.rest = null; - node.typeParameters = null; - - if (this.isRelational("<")) { - node.typeParameters = this.flowParseTypeParameterDeclaration(); - } - - this.expect(_tokenizerTypes.types.parenL); - while (this.match(_tokenizerTypes.types.name)) { - node.params.push(this.flowParseFunctionTypeParam()); - if (!this.match(_tokenizerTypes.types.parenR)) { - this.expect(_tokenizerTypes.types.comma); - } - } - - if (this.eat(_tokenizerTypes.types.ellipsis)) { - node.rest = this.flowParseFunctionTypeParam(); - } - this.expect(_tokenizerTypes.types.parenR); - node.returnType = this.flowParseTypeInitialiser(); - - return this.finishNode(node, "FunctionTypeAnnotation"); -}; - -pp.flowParseObjectTypeMethod = function (startPos, startLoc, isStatic, key) { - var node = this.startNodeAt(startPos, startLoc); - node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(startPos, startLoc)); - node["static"] = isStatic; - node.key = key; - node.optional = false; - this.flowObjectTypeSemicolon(); - return this.finishNode(node, "ObjectTypeProperty"); -}; - -pp.flowParseObjectTypeCallProperty = function (node, isStatic) { - var valueNode = this.startNode(); - node["static"] = isStatic; - node.value = this.flowParseObjectTypeMethodish(valueNode); - this.flowObjectTypeSemicolon(); - return this.finishNode(node, "ObjectTypeCallProperty"); -}; - -pp.flowParseObjectType = function (allowStatic) { - var nodeStart = this.startNode(); - var node; - var propertyKey; - var isStatic; - - nodeStart.callProperties = []; - nodeStart.properties = []; - nodeStart.indexers = []; - - this.expect(_tokenizerTypes.types.braceL); - - while (!this.match(_tokenizerTypes.types.braceR)) { - var optional = false; - var startPos = this.state.start, - startLoc = this.state.startLoc; - node = this.startNode(); - if (allowStatic && this.isContextual("static")) { - this.next(); - isStatic = true; - } - - if (this.match(_tokenizerTypes.types.bracketL)) { - nodeStart.indexers.push(this.flowParseObjectTypeIndexer(node, isStatic)); - } else if (this.match(_tokenizerTypes.types.parenL) || this.isRelational("<")) { - nodeStart.callProperties.push(this.flowParseObjectTypeCallProperty(node, allowStatic)); - } else { - if (isStatic && this.match(_tokenizerTypes.types.colon)) { - propertyKey = this.parseIdent(); - } else { - propertyKey = this.flowParseObjectPropertyKey(); - } - if (this.isRelational("<") || this.match(_tokenizerTypes.types.parenL)) { - // This is a method property - nodeStart.properties.push(this.flowParseObjectTypeMethod(startPos, startLoc, isStatic, propertyKey)); - } else { - if (this.eat(_tokenizerTypes.types.question)) { - optional = true; - } - node.key = propertyKey; - node.value = this.flowParseTypeInitialiser(); - node.optional = optional; - node["static"] = isStatic; - this.flowObjectTypeSemicolon(); - nodeStart.properties.push(this.finishNode(node, "ObjectTypeProperty")); - } - } - } - - this.expect(_tokenizerTypes.types.braceR); - - return this.finishNode(nodeStart, "ObjectTypeAnnotation"); -}; - -pp.flowObjectTypeSemicolon = function () { - if (!this.eat(_tokenizerTypes.types.semi) && !this.eat(_tokenizerTypes.types.comma) && !this.match(_tokenizerTypes.types.braceR)) { - this.unexpected(); - } -}; - -pp.flowParseGenericType = function (startPos, startLoc, id) { - var node = this.startNodeAt(startPos, startLoc); - - node.typeParameters = null; - node.id = id; - - while (this.eat(_tokenizerTypes.types.dot)) { - var node2 = this.startNodeAt(startPos, startLoc); - node2.qualification = node.id; - node2.id = this.parseIdent(); - node.id = this.finishNode(node2, "QualifiedTypeIdentifier"); - } - - if (this.isRelational("<")) { - node.typeParameters = this.flowParseTypeParameterInstantiation(); - } - - return this.finishNode(node, "GenericTypeAnnotation"); -}; - -pp.flowParseTypeofType = function () { - var node = this.startNode(); - this.expect(_tokenizerTypes.types._typeof); - node.argument = this.flowParsePrimaryType(); - return this.finishNode(node, "TypeofTypeAnnotation"); -}; - -pp.flowParseTupleType = function () { - var node = this.startNode(); - node.types = []; - this.expect(_tokenizerTypes.types.bracketL); - // We allow trailing commas - while (this.state.pos < this.input.length && !this.match(_tokenizerTypes.types.bracketR)) { - node.types.push(this.flowParseType()); - if (this.match(_tokenizerTypes.types.bracketR)) break; - this.expect(_tokenizerTypes.types.comma); - } - this.expect(_tokenizerTypes.types.bracketR); - return this.finishNode(node, "TupleTypeAnnotation"); -}; - -pp.flowParseFunctionTypeParam = function () { - var optional = false; - var node = this.startNode(); - node.name = this.parseIdent(); - if (this.eat(_tokenizerTypes.types.question)) { - optional = true; - } - node.optional = optional; - node.typeAnnotation = this.flowParseTypeInitialiser(); - return this.finishNode(node, "FunctionTypeParam"); -}; - -pp.flowParseFunctionTypeParams = function () { - var ret = { params: [], rest: null }; - while (this.match(_tokenizerTypes.types.name)) { - ret.params.push(this.flowParseFunctionTypeParam()); - if (!this.match(_tokenizerTypes.types.parenR)) { - this.expect(_tokenizerTypes.types.comma); - } - } - if (this.eat(_tokenizerTypes.types.ellipsis)) { - ret.rest = this.flowParseFunctionTypeParam(); - } - return ret; -}; - -pp.flowIdentToTypeAnnotation = function (startPos, startLoc, node, id) { - switch (id.name) { - case "any": - return this.finishNode(node, "AnyTypeAnnotation"); - - case "void": - return this.finishNode(node, "VoidTypeAnnotation"); - - case "bool": - case "boolean": - return this.finishNode(node, "BooleanTypeAnnotation"); - - case "mixed": - return this.finishNode(node, "MixedTypeAnnotation"); - - case "number": - return this.finishNode(node, "NumberTypeAnnotation"); - - case "string": - return this.finishNode(node, "StringTypeAnnotation"); - - default: - return this.flowParseGenericType(startPos, startLoc, id); - } -}; - -// The parsing of types roughly parallels the parsing of expressions, and -// primary types are kind of like primary expressions...they're the -// primitives with which other types are constructed. -pp.flowParsePrimaryType = function () { - var startPos = this.state.start, - startLoc = this.state.startLoc; - var node = this.startNode(); - var tmp; - var type; - var isGroupedType = false; - - switch (this.state.type) { - case _tokenizerTypes.types.name: - return this.flowIdentToTypeAnnotation(startPos, startLoc, node, this.parseIdent()); - - case _tokenizerTypes.types.braceL: - return this.flowParseObjectType(); - - case _tokenizerTypes.types.bracketL: - return this.flowParseTupleType(); - - case _tokenizerTypes.types.relational: - if (this.state.value === "<") { - node.typeParameters = this.flowParseTypeParameterDeclaration(); - this.expect(_tokenizerTypes.types.parenL); - tmp = this.flowParseFunctionTypeParams(); - node.params = tmp.params; - node.rest = tmp.rest; - this.expect(_tokenizerTypes.types.parenR); - - this.expect(_tokenizerTypes.types.arrow); - - node.returnType = this.flowParseType(); - - return this.finishNode(node, "FunctionTypeAnnotation"); - } - - case _tokenizerTypes.types.parenL: - this.next(); - - // Check to see if this is actually a grouped type - if (!this.match(_tokenizerTypes.types.parenR) && !this.match(_tokenizerTypes.types.ellipsis)) { - if (this.match(_tokenizerTypes.types.name)) { - var token = this.lookahead().type; - isGroupedType = token !== _tokenizerTypes.types.question && token !== _tokenizerTypes.types.colon; - } else { - isGroupedType = true; - } - } - - if (isGroupedType) { - type = this.flowParseType(); - this.expect(_tokenizerTypes.types.parenR); - - // If we see a => next then someone was probably confused about - // function types, so we can provide a better error message - if (this.eat(_tokenizerTypes.types.arrow)) { - this.raise(node, "Unexpected token =>. It looks like " + "you are trying to write a function type, but you ended up " + "writing a grouped type followed by an =>, which is a syntax " + "error. Remember, function type parameters are named so function " + "types look like (name1: type1, name2: type2) => returnType. You " + "probably wrote (type1) => returnType"); - } - - return type; - } - - tmp = this.flowParseFunctionTypeParams(); - node.params = tmp.params; - node.rest = tmp.rest; - - this.expect(_tokenizerTypes.types.parenR); - - this.expect(_tokenizerTypes.types.arrow); - - node.returnType = this.flowParseType(); - node.typeParameters = null; - - return this.finishNode(node, "FunctionTypeAnnotation"); - - case _tokenizerTypes.types.string: - node.rawValue = node.value = this.state.value; - node.raw = this.input.slice(this.state.start, this.state.end); - this.next(); - return this.finishNode(node, "StringLiteralTypeAnnotation"); - - case _tokenizerTypes.types._true:case _tokenizerTypes.types._false: - node.value = this.match(_tokenizerTypes.types._true); - this.next(); - return this.finishNode(node, "BooleanLiteralTypeAnnotation"); - - case _tokenizerTypes.types.num: - node.rawValue = node.value = this.state.value; - node.raw = this.input.slice(this.state.start, this.state.end); - this.next(); - return this.finishNode(node, "NumberLiteralTypeAnnotation"); - - default: - if (this.state.type.keyword === "typeof") { - return this.flowParseTypeofType(); - } - } - - this.unexpected(); -}; - -pp.flowParsePostfixType = function () { - var node = this.startNode(); - var type = node.elementType = this.flowParsePrimaryType(); - if (this.match(_tokenizerTypes.types.bracketL)) { - this.expect(_tokenizerTypes.types.bracketL); - this.expect(_tokenizerTypes.types.bracketR); - return this.finishNode(node, "ArrayTypeAnnotation"); - } else { - return type; - } -}; - -pp.flowParsePrefixType = function () { - var node = this.startNode(); - if (this.eat(_tokenizerTypes.types.question)) { - node.typeAnnotation = this.flowParsePrefixType(); - return this.finishNode(node, "NullableTypeAnnotation"); - } else { - return this.flowParsePostfixType(); - } -}; - -pp.flowParseIntersectionType = function () { - var node = this.startNode(); - var type = this.flowParsePrefixType(); - node.types = [type]; - while (this.eat(_tokenizerTypes.types.bitwiseAND)) { - node.types.push(this.flowParsePrefixType()); - } - return node.types.length === 1 ? type : this.finishNode(node, "IntersectionTypeAnnotation"); -}; - -pp.flowParseUnionType = function () { - var node = this.startNode(); - var type = this.flowParseIntersectionType(); - node.types = [type]; - while (this.eat(_tokenizerTypes.types.bitwiseOR)) { - node.types.push(this.flowParseIntersectionType()); - } - return node.types.length === 1 ? type : this.finishNode(node, "UnionTypeAnnotation"); -}; - -pp.flowParseType = function () { - var oldInType = this.state.inType; - this.state.inType = true; - var type = this.flowParseUnionType(); - this.state.inType = oldInType; - return type; -}; - -pp.flowParseTypeAnnotation = function () { - var node = this.startNode(); - node.typeAnnotation = this.flowParseTypeInitialiser(); - return this.finishNode(node, "TypeAnnotation"); -}; - -pp.flowParseTypeAnnotatableIdentifier = function (requireTypeAnnotation, canBeOptionalParam) { - var ident = this.parseIdent(); - var isOptionalParam = false; - - if (canBeOptionalParam && this.eat(_tokenizerTypes.types.question)) { - this.expect(_tokenizerTypes.types.question); - isOptionalParam = true; - } - - if (requireTypeAnnotation || this.match(_tokenizerTypes.types.colon)) { - ident.typeAnnotation = this.flowParseTypeAnnotation(); - this.finishNode(ident, ident.type); - } - - if (isOptionalParam) { - ident.optional = true; - this.finishNode(ident, ident.type); - } - - return ident; -}; - -exports["default"] = function (instance) { - // function name(): string {} - instance.extend("parseFunctionBody", function (inner) { - return function (node, allowExpression) { - if (this.match(_tokenizerTypes.types.colon) && !allowExpression) { - // if allowExpression is true then we're parsing an arrow function and if - // there's a return type then it's been handled elsewhere - node.returnType = this.flowParseTypeAnnotation(); - } - - return inner.call(this, node, allowExpression); - }; - }); - - instance.extend("parseStatement", function (inner) { - return function (declaration, topLevel) { - // strict mode handling of `interface` since it's a reserved word - if (this.strict && this.match(_tokenizerTypes.types.name) && this.state.value === "interface") { - var node = this.startNode(); - this.next(); - return this.flowParseInterface(node); - } else { - return inner.call(this, declaration, topLevel); - } - }; - }); - - instance.extend("parseExpressionStatement", function (inner) { - return function (node, expr) { - if (expr.type === "Identifier") { - if (expr.name === "declare") { - if (this.match(_tokenizerTypes.types._class) || this.match(_tokenizerTypes.types.name) || this.match(_tokenizerTypes.types._function) || this.match(_tokenizerTypes.types._var)) { - return this.flowParseDeclare(node); - } - } else if (this.match(_tokenizerTypes.types.name)) { - if (expr.name === "interface") { - return this.flowParseInterface(node); - } else if (expr.name === "type") { - return this.flowParseTypeAlias(node); - } - } - } - - return inner.call(this, node, expr); - }; - }); - - instance.extend("shouldParseExportDeclaration", function (inner) { - return function () { - return this.isContextual("type") || inner.call(this); - }; - }); - - instance.extend("parseParenItem", function () { - return function (node, startLoc, startPos, forceArrow) { - if (this.match(_tokenizerTypes.types.colon)) { - var typeCastNode = this.startNodeAt(startLoc, startPos); - typeCastNode.expression = node; - typeCastNode.typeAnnotation = this.flowParseTypeAnnotation(); - - if (forceArrow && !this.match(_tokenizerTypes.types.arrow)) { - this.unexpected(); - } - - if (this.eat(_tokenizerTypes.types.arrow)) { - // ((lol): number => {}); - var func = this.parseArrowExpression(this.startNodeAt(startLoc, startPos), [node]); - func.returnType = typeCastNode.typeAnnotation; - return func; - } else { - return this.finishNode(typeCastNode, "TypeCastExpression"); - } - } else { - return node; - } - }; - }); - - instance.extend("parseExport", function (inner) { - return function (node) { - node = inner.call(this, node); - if (node.type === "ExportNamedDeclaration") { - node.exportKind = node.exportKind || "value"; - } - return node; - }; - }); - - instance.extend("parseExportDeclaration", function (inner) { - return function (node) { - if (this.isContextual("type")) { - node.exportKind = "type"; - - var declarationNode = this.startNode(); - this.next(); - - if (this.match(_tokenizerTypes.types.braceL)) { - // export type { foo, bar }; - node.specifiers = this.parseExportSpecifiers(); - this.parseExportFrom(node); - return null; - } else { - // export type Foo = Bar; - return this.flowParseTypeAlias(declarationNode); - } - } else { - return inner.call(this, node); - } - }; - }); - - instance.extend("parseClassId", function (inner) { - return function (node, isStatement) { - inner.call(this, node, isStatement); - if (this.isRelational("<")) { - node.typeParameters = this.flowParseTypeParameterDeclaration(); - } - }; - }); - - // don't consider `void` to be a keyword as then it'll use the void token type - // and set startExpr - instance.extend("isKeyword", function (inner) { - return function (name) { - if (this.state.inType && name === "void") { - return false; - } else { - return inner.call(this, name); - } - }; - }); - - instance.extend("readToken", function (inner) { - return function (code) { - if (this.state.inType && (code === 62 || code === 60)) { - return this.finishOp(_tokenizerTypes.types.relational, 1); - } else { - return inner.call(this, code); - } - }; - }); - - instance.extend("jsx_readToken", function (inner) { - return function () { - if (!this.state.inType) return inner.call(this); - }; - }); - - function typeCastToParameter(node) { - node.expression.typeAnnotation = node.typeAnnotation; - return node.expression; - } - - instance.extend("toAssignableList", function (inner) { - return function (exprList, isBinding) { - for (var i = 0; i < exprList.length; i++) { - var expr = exprList[i]; - if (expr && expr.type === "TypeCastExpression") { - exprList[i] = typeCastToParameter(expr); - } - } - return inner.call(this, exprList, isBinding); - }; - }); - - instance.extend("toReferencedList", function () { - return function (exprList) { - for (var i = 0; i < exprList.length; i++) { - var expr = exprList[i]; - if (expr && expr._exprListItem && expr.type === "TypeCastExpression") { - this.raise(expr.start, "Unexpected type cast"); - } - } - - return exprList; - }; - }); - - instance.extend("parseExprListItem", function (inner) { - return function (allowEmpty, refShorthandDefaultPos) { - var container = this.startNode(); - var node = inner.call(this, allowEmpty, refShorthandDefaultPos); - if (this.match(_tokenizerTypes.types.colon)) { - container._exprListItem = true; - container.expression = node; - container.typeAnnotation = this.flowParseTypeAnnotation(); - return this.finishNode(container, "TypeCastExpression"); - } else { - return node; - } - }; - }); - - instance.extend("parseClassProperty", function (inner) { - return function (node) { - if (this.match(_tokenizerTypes.types.colon)) { - node.typeAnnotation = this.flowParseTypeAnnotation(); - } - return inner.call(this, node); - }; - }); - - instance.extend("isClassProperty", function (inner) { - return function () { - return this.match(_tokenizerTypes.types.colon) || inner.call(this); - }; - }); - - instance.extend("parseClassMethod", function () { - return function (classBody, method, isGenerator, isAsync) { - var typeParameters; - if (this.isRelational("<")) { - typeParameters = this.flowParseTypeParameterDeclaration(); - } - method.value = this.parseMethod(isGenerator, isAsync); - method.value.typeParameters = typeParameters; - classBody.body.push(this.finishNode(method, "MethodDefinition")); - }; - }); - - instance.extend("parseClassSuper", function (inner) { - return function (node, isStatement) { - inner.call(this, node, isStatement); - if (node.superClass && this.isRelational("<")) { - node.superTypeParameters = this.flowParseTypeParameterInstantiation(); - } - if (this.isContextual("implements")) { - this.next(); - var implemented = node["implements"] = []; - do { - var _node = this.startNode(); - _node.id = this.parseIdent(); - if (this.isRelational("<")) { - _node.typeParameters = this.flowParseTypeParameterInstantiation(); - } else { - _node.typeParameters = null; - } - implemented.push(this.finishNode(_node, "ClassImplements")); - } while (this.eat(_tokenizerTypes.types.comma)); - } - }; - }); - - instance.extend("parseObjPropValue", function (inner) { - return function (prop) { - var typeParameters; - - // method shorthand - if (this.isRelational("<")) { - typeParameters = this.flowParseTypeParameterDeclaration(); - if (!this.match(_tokenizerTypes.types.parenL)) this.unexpected(); - } - - inner.apply(this, arguments); - - // add typeParameters if we found them - if (typeParameters) { - prop.value.typeParameters = typeParameters; - } - }; - }); - - instance.extend("parseAssignableListItemTypes", function () { - return function (param) { - if (this.eat(_tokenizerTypes.types.question)) { - param.optional = true; - } - if (this.match(_tokenizerTypes.types.colon)) { - param.typeAnnotation = this.flowParseTypeAnnotation(); - } - this.finishNode(param, param.type); - return param; - }; - }); - - instance.extend("parseImportSpecifiers", function (inner) { - return function (node) { - node.importKind = "value"; - - var kind = this.match(_tokenizerTypes.types._typeof) ? "typeof" : this.isContextual("type") ? "type" : null; - if (kind) { - var lh = this.lookahead(); - if (lh.type === _tokenizerTypes.types.name && lh.value !== "from" || lh.type === _tokenizerTypes.types.braceL || lh.type === _tokenizerTypes.types.star) { - this.next(); - node.importKind = kind; - } - } - - inner.call(this, node); - }; - }); - - // function foo() {} - instance.extend("parseFunctionParams", function (inner) { - return function (node) { - if (this.isRelational("<")) { - node.typeParameters = this.flowParseTypeParameterDeclaration(); - } - inner.call(this, node); - }; - }); - - // var foo: string = bar - instance.extend("parseVarHead", function (inner) { - return function (decl) { - inner.call(this, decl); - if (this.match(_tokenizerTypes.types.colon)) { - decl.id.typeAnnotation = this.flowParseTypeAnnotation(); - this.finishNode(decl.id, decl.id.type); - } - }; - }); - - // var foo = (async (): number => {}); - instance.extend("parseAsyncArrowFromCallExpression", function (inner) { - return function (node, call) { - if (this.match(_tokenizerTypes.types.colon)) { - node.returnType = this.flowParseTypeAnnotation(); - } - - return inner.call(this, node, call); - }; - }); - - instance.extend("parseParenAndDistinguishExpression", function (inner) { - return function (startPos, startLoc, canBeArrow, isAsync) { - startPos = startPos || this.state.start; - startLoc = startLoc || this.state.startLoc; - - if (this.lookahead().type === _tokenizerTypes.types.parenR) { - // var foo = (): number => {}; - this.expect(_tokenizerTypes.types.parenL); - this.expect(_tokenizerTypes.types.parenR); - - var node = this.startNodeAt(startPos, startLoc); - if (this.match(_tokenizerTypes.types.colon)) node.returnType = this.flowParseTypeAnnotation(); - this.expect(_tokenizerTypes.types.arrow); - return this.parseArrowExpression(node, [], isAsync); - } else { - // var foo = (foo): number => {}; - var node = inner.call(this, startPos, startLoc, canBeArrow, isAsync); - - if (this.match(_tokenizerTypes.types.colon)) { - var state = this.state.clone(); - try { - return this.parseParenItem(node, startPos, startLoc, true); - } catch (err) { - if (err instanceof SyntaxError) { - this.state = state; - return node; - } else { - throw err; - } - } - } else { - return node; - } - } - }; - }); -}; - -module.exports = exports["default"]; -},{"617":617,"629":629}],624:[function(_dereq_,module,exports){ -"use strict"; - -exports.__esModule = true; -// istanbul ignore next - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } - -var _xhtml = _dereq_(625); - -var _xhtml2 = _interopRequireDefault(_xhtml); - -var _tokenizerTypes = _dereq_(629); - -var _tokenizerContext = _dereq_(626); - -var _parser = _dereq_(617); - -var _parser2 = _interopRequireDefault(_parser); - -var _utilIdentifier = _dereq_(630); - -var _utilWhitespace = _dereq_(632); - -var HEX_NUMBER = /^[\da-fA-F]+$/; -var DECIMAL_NUMBER = /^\d+$/; - -_tokenizerContext.types.j_oTag = new _tokenizerContext.TokContext("...", true, true); - -_tokenizerTypes.types.jsxName = new _tokenizerTypes.TokenType("jsxName"); -_tokenizerTypes.types.jsxText = new _tokenizerTypes.TokenType("jsxText", { beforeExpr: true }); -_tokenizerTypes.types.jsxTagStart = new _tokenizerTypes.TokenType("jsxTagStart"); -_tokenizerTypes.types.jsxTagEnd = new _tokenizerTypes.TokenType("jsxTagEnd"); - -_tokenizerTypes.types.jsxTagStart.updateContext = function () { - this.state.context.push(_tokenizerContext.types.j_expr); // treat as beginning of JSX expression - this.state.context.push(_tokenizerContext.types.j_oTag); // start opening tag context - this.state.exprAllowed = false; -}; - -_tokenizerTypes.types.jsxTagEnd.updateContext = function (prevType) { - var out = this.state.context.pop(); - if (out === _tokenizerContext.types.j_oTag && prevType === _tokenizerTypes.types.slash || out === _tokenizerContext.types.j_cTag) { - this.state.context.pop(); - this.state.exprAllowed = this.curContext() === _tokenizerContext.types.j_expr; - } else { - this.state.exprAllowed = true; - } -}; - -var pp = _parser2["default"].prototype; - -// Reads inline JSX contents token. - -pp.jsxReadToken = function () { - var out = "", - chunkStart = this.state.pos; - for (;;) { - if (this.state.pos >= this.input.length) { - this.raise(this.state.start, "Unterminated JSX contents"); - } - - var ch = this.input.charCodeAt(this.state.pos); - - switch (ch) { - case 60: // "<" - case 123: - // "{" - if (this.state.pos === this.state.start) { - if (ch === 60 && this.state.exprAllowed) { - ++this.state.pos; - return this.finishToken(_tokenizerTypes.types.jsxTagStart); - } - return this.getTokenFromCode(ch); - } - out += this.input.slice(chunkStart, this.state.pos); - return this.finishToken(_tokenizerTypes.types.jsxText, out); - - case 38: - // "&" - out += this.input.slice(chunkStart, this.state.pos); - out += this.jsxReadEntity(); - chunkStart = this.state.pos; - break; - - default: - if (_utilWhitespace.isNewLine(ch)) { - out += this.input.slice(chunkStart, this.state.pos); - out += this.jsxReadNewLine(true); - chunkStart = this.state.pos; - } else { - ++this.state.pos; - } - } - } -}; - -pp.jsxReadNewLine = function (normalizeCRLF) { - var ch = this.input.charCodeAt(this.state.pos); - var out; - ++this.state.pos; - if (ch === 13 && this.input.charCodeAt(this.state.pos) === 10) { - ++this.state.pos; - out = normalizeCRLF ? "\n" : "\r\n"; - } else { - out = String.fromCharCode(ch); - } - ++this.state.curLine; - this.state.lineStart = this.state.pos; - - return out; -}; - -pp.jsxReadString = function (quote) { - var out = "", - chunkStart = ++this.state.pos; - for (;;) { - if (this.state.pos >= this.input.length) { - this.raise(this.state.start, "Unterminated string constant"); - } - - var ch = this.input.charCodeAt(this.state.pos); - if (ch === quote) break; - if (ch === 38) { - // "&" - out += this.input.slice(chunkStart, this.state.pos); - out += this.jsxReadEntity(); - chunkStart = this.state.pos; - } else if (_utilWhitespace.isNewLine(ch)) { - out += this.input.slice(chunkStart, this.state.pos); - out += this.jsxReadNewLine(false); - chunkStart = this.state.pos; - } else { - ++this.state.pos; - } - } - out += this.input.slice(chunkStart, this.state.pos++); - return this.finishToken(_tokenizerTypes.types.string, out); -}; - -pp.jsxReadEntity = function () { - var str = "", - count = 0, - entity; - var ch = this.input[this.state.pos]; - - var startPos = ++this.state.pos; - while (this.state.pos < this.input.length && count++ < 10) { - ch = this.input[this.state.pos++]; - if (ch === ";") { - if (str[0] === "#") { - if (str[1] === "x") { - str = str.substr(2); - if (HEX_NUMBER.test(str)) entity = String.fromCharCode(parseInt(str, 16)); - } else { - str = str.substr(1); - if (DECIMAL_NUMBER.test(str)) entity = String.fromCharCode(parseInt(str, 10)); - } - } else { - entity = _xhtml2["default"][str]; - } - break; - } - str += ch; - } - if (!entity) { - this.state.pos = startPos; - return "&"; - } - return entity; -}; - -// Read a JSX identifier (valid tag or attribute name). -// -// Optimized version since JSX identifiers can"t contain -// escape characters and so can be read as single slice. -// Also assumes that first character was already checked -// by isIdentifierStart in readToken. - -pp.jsxReadWord = function () { - var ch, - start = this.state.pos; - do { - ch = this.input.charCodeAt(++this.state.pos); - } while (_utilIdentifier.isIdentifierChar(ch) || ch === 45); // "-" - return this.finishToken(_tokenizerTypes.types.jsxName, this.input.slice(start, this.state.pos)); -}; - -// Transforms JSX element name to string. - -function getQualifiedJSXName(object) { - if (object.type === "JSXIdentifier") { - return object.name; - } - - if (object.type === "JSXNamespacedName") { - return object.namespace.name + ":" + object.name.name; - } - - if (object.type === "JSXMemberExpression") { - return getQualifiedJSXName(object.object) + "." + getQualifiedJSXName(object.property); - } -} - -// Parse next token as JSX identifier - -pp.jsxParseIdentifier = function () { - var node = this.startNode(); - if (this.match(_tokenizerTypes.types.jsxName)) { - node.name = this.state.value; - } else if (this.state.type.keyword) { - node.name = this.state.type.keyword; - } else { - this.unexpected(); - } - this.next(); - return this.finishNode(node, "JSXIdentifier"); -}; - -// Parse namespaced identifier. - -pp.jsxParseNamespacedName = function () { - var startPos = this.state.start, - startLoc = this.state.startLoc; - var name = this.jsxParseIdentifier(); - if (!this.eat(_tokenizerTypes.types.colon)) return name; - - var node = this.startNodeAt(startPos, startLoc); - node.namespace = name; - node.name = this.jsxParseIdentifier(); - return this.finishNode(node, "JSXNamespacedName"); -}; - -// Parses element name in any form - namespaced, member -// or single identifier. - -pp.jsxParseElementName = function () { - var startPos = this.state.start, - startLoc = this.state.startLoc; - var node = this.jsxParseNamespacedName(); - while (this.eat(_tokenizerTypes.types.dot)) { - var newNode = this.startNodeAt(startPos, startLoc); - newNode.object = node; - newNode.property = this.jsxParseIdentifier(); - node = this.finishNode(newNode, "JSXMemberExpression"); - } - return node; -}; - -// Parses any type of JSX attribute value. - -pp.jsxParseAttributeValue = function () { - var node; - switch (this.state.type) { - case _tokenizerTypes.types.braceL: - node = this.jsxParseExpressionContainer(); - if (node.expression.type === "JSXEmptyExpression") { - this.raise(node.start, "JSX attributes must only be assigned a non-empty expression"); - } else { - return node; - } - - case _tokenizerTypes.types.jsxTagStart: - case _tokenizerTypes.types.string: - node = this.parseExprAtom(); - node.rawValue = null; - return node; - - default: - this.raise(this.state.start, "JSX value should be either an expression or a quoted JSX text"); - } -}; - -// JSXEmptyExpression is unique type since it doesn"t actually parse anything, -// and so it should start at the end of last read token (left brace) and finish -// at the beginning of the next one (right brace). - -pp.jsxParseEmptyExpression = function () { - var tmp = this.state.start; - this.state.start = this.state.lastTokEnd; - this.state.lastTokEnd = tmp; - - tmp = this.state.startLoc; - this.state.startLoc = this.state.lastTokEndLoc; - this.state.lastTokEndLoc = tmp; - - return this.finishNode(this.startNode(), "JSXEmptyExpression"); -}; - -// Parses JSX expression enclosed into curly brackets. - -pp.jsxParseExpressionContainer = function () { - var node = this.startNode(); - this.next(); - if (this.match(_tokenizerTypes.types.braceR)) { - node.expression = this.jsxParseEmptyExpression(); - } else { - node.expression = this.parseExpression(); - } - this.expect(_tokenizerTypes.types.braceR); - return this.finishNode(node, "JSXExpressionContainer"); -}; - -// Parses following JSX attribute name-value pair. - -pp.jsxParseAttribute = function () { - var node = this.startNode(); - if (this.eat(_tokenizerTypes.types.braceL)) { - this.expect(_tokenizerTypes.types.ellipsis); - node.argument = this.parseMaybeAssign(); - this.expect(_tokenizerTypes.types.braceR); - return this.finishNode(node, "JSXSpreadAttribute"); - } - node.name = this.jsxParseNamespacedName(); - node.value = this.eat(_tokenizerTypes.types.eq) ? this.jsxParseAttributeValue() : null; - return this.finishNode(node, "JSXAttribute"); -}; - -// Parses JSX opening tag starting after "<". - -pp.jsxParseOpeningElementAt = function (startPos, startLoc) { - var node = this.startNodeAt(startPos, startLoc); - node.attributes = []; - node.name = this.jsxParseElementName(); - while (!this.match(_tokenizerTypes.types.slash) && !this.match(_tokenizerTypes.types.jsxTagEnd)) { - node.attributes.push(this.jsxParseAttribute()); - } - node.selfClosing = this.eat(_tokenizerTypes.types.slash); - this.expect(_tokenizerTypes.types.jsxTagEnd); - return this.finishNode(node, "JSXOpeningElement"); -}; - -// Parses JSX closing tag starting after ""); - } - } - - node.openingElement = openingElement; - node.closingElement = closingElement; - node.children = children; - if (this.match(_tokenizerTypes.types.relational) && this.state.value === "<") { - this.raise(this.state.start, "Adjacent JSX elements must be wrapped in an enclosing tag"); - } - return this.finishNode(node, "JSXElement"); -}; - -// Parses entire JSX element from current position. - -pp.jsxParseElement = function () { - var startPos = this.state.start, - startLoc = this.state.startLoc; - this.next(); - return this.jsxParseElementAt(startPos, startLoc); -}; - -exports["default"] = function (instance) { - instance.extend("parseExprAtom", function (inner) { - return function (refShortHandDefaultPos) { - if (this.match(_tokenizerTypes.types.jsxText)) { - var node = this.parseLiteral(this.state.value); - // https://github.com/babel/babel/issues/2078 - node.rawValue = null; - return node; - } else if (this.match(_tokenizerTypes.types.jsxTagStart)) { - return this.jsxParseElement(); - } else { - return inner.call(this, refShortHandDefaultPos); - } - }; - }); - - instance.extend("readToken", function (inner) { - return function (code) { - var context = this.curContext(); - - if (context === _tokenizerContext.types.j_expr) { - return this.jsxReadToken(); - } - - if (context === _tokenizerContext.types.j_oTag || context === _tokenizerContext.types.j_cTag) { - if (_utilIdentifier.isIdentifierStart(code)) { - return this.jsxReadWord(); - } - - if (code === 62) { - ++this.state.pos; - return this.finishToken(_tokenizerTypes.types.jsxTagEnd); - } - - if ((code === 34 || code === 39) && context === _tokenizerContext.types.j_oTag) { - return this.jsxReadString(code); - } - } - - if (code === 60 && this.state.exprAllowed) { - ++this.state.pos; - return this.finishToken(_tokenizerTypes.types.jsxTagStart); - } - - return inner.call(this, code); - }; - }); - - instance.extend("updateContext", function (inner) { - return function (prevType) { - if (this.match(_tokenizerTypes.types.braceL)) { - var curContext = this.curContext(); - if (curContext === _tokenizerContext.types.j_oTag) { - this.state.context.push(_tokenizerContext.types.b_expr); - } else if (curContext === _tokenizerContext.types.j_expr) { - this.state.context.push(_tokenizerContext.types.b_tmpl); - } else { - inner.call(this, prevType); - } - this.state.exprAllowed = true; - } else if (this.match(_tokenizerTypes.types.slash) && prevType === _tokenizerTypes.types.jsxTagStart) { - this.state.context.length -= 2; // do not consider JSX expr -> JSX open tag -> ... anymore - this.state.context.push(_tokenizerContext.types.j_cTag); // reconsider as closing tag context - this.state.exprAllowed = false; - } else { - return inner.call(this, prevType); - } - }; - }); -}; - -module.exports = exports["default"]; -},{"617":617,"625":625,"626":626,"629":629,"630":630,"632":632}],625:[function(_dereq_,module,exports){ -"use strict"; - -exports.__esModule = true; -exports["default"] = { - quot: "\"", - amp: "&", - apos: "'", - lt: "<", - gt: ">", - nbsp: " ", - iexcl: "¡", - cent: "¢", - pound: "£", - curren: "¤", - yen: "¥", - brvbar: "¦", - sect: "§", - uml: "¨", - copy: "©", - ordf: "ª", - laquo: "«", - not: "¬", - shy: "­", - reg: "®", - macr: "¯", - deg: "°", - plusmn: "±", - sup2: "²", - sup3: "³", - acute: "´", - micro: "µ", - para: "¶", - middot: "·", - cedil: "¸", - sup1: "¹", - ordm: "º", - raquo: "»", - frac14: "¼", - frac12: "½", - frac34: "¾", - iquest: "¿", - Agrave: "À", - Aacute: "Á", - Acirc: "Â", - Atilde: "Ã", - Auml: "Ä", - Aring: "Å", - AElig: "Æ", - Ccedil: "Ç", - Egrave: "È", - Eacute: "É", - Ecirc: "Ê", - Euml: "Ë", - Igrave: "Ì", - Iacute: "Í", - Icirc: "Î", - Iuml: "Ï", - ETH: "Ð", - Ntilde: "Ñ", - Ograve: "Ò", - Oacute: "Ó", - Ocirc: "Ô", - Otilde: "Õ", - Ouml: "Ö", - times: "×", - Oslash: "Ø", - Ugrave: "Ù", - Uacute: "Ú", - Ucirc: "Û", - Uuml: "Ü", - Yacute: "Ý", - THORN: "Þ", - szlig: "ß", - agrave: "à", - aacute: "á", - acirc: "â", - atilde: "ã", - auml: "ä", - aring: "å", - aelig: "æ", - ccedil: "ç", - egrave: "è", - eacute: "é", - ecirc: "ê", - euml: "ë", - igrave: "ì", - iacute: "í", - icirc: "î", - iuml: "ï", - eth: "ð", - ntilde: "ñ", - ograve: "ò", - oacute: "ó", - ocirc: "ô", - otilde: "õ", - ouml: "ö", - divide: "÷", - oslash: "ø", - ugrave: "ù", - uacute: "ú", - ucirc: "û", - uuml: "ü", - yacute: "ý", - thorn: "þ", - yuml: "ÿ", - OElig: "Œ", - oelig: "œ", - Scaron: "Š", - scaron: "š", - Yuml: "Ÿ", - fnof: "ƒ", - circ: "ˆ", - tilde: "˜", - Alpha: "Α", - Beta: "Β", - Gamma: "Γ", - Delta: "Δ", - Epsilon: "Ε", - Zeta: "Ζ", - Eta: "Η", - Theta: "Θ", - Iota: "Ι", - Kappa: "Κ", - Lambda: "Λ", - Mu: "Μ", - Nu: "Ν", - Xi: "Ξ", - Omicron: "Ο", - Pi: "Π", - Rho: "Ρ", - Sigma: "Σ", - Tau: "Τ", - Upsilon: "Υ", - Phi: "Φ", - Chi: "Χ", - Psi: "Ψ", - Omega: "Ω", - alpha: "α", - beta: "β", - gamma: "γ", - delta: "δ", - epsilon: "ε", - zeta: "ζ", - eta: "η", - theta: "θ", - iota: "ι", - kappa: "κ", - lambda: "λ", - mu: "μ", - nu: "ν", - xi: "ξ", - omicron: "ο", - pi: "π", - rho: "ρ", - sigmaf: "ς", - sigma: "σ", - tau: "τ", - upsilon: "υ", - phi: "φ", - chi: "χ", - psi: "ψ", - omega: "ω", - thetasym: "ϑ", - upsih: "ϒ", - piv: "ϖ", - ensp: " ", - emsp: " ", - thinsp: " ", - zwnj: "‌", - zwj: "‍", - lrm: "‎", - rlm: "‏", - ndash: "–", - mdash: "—", - lsquo: "‘", - rsquo: "’", - sbquo: "‚", - ldquo: "“", - rdquo: "”", - bdquo: "„", - dagger: "†", - Dagger: "‡", - bull: "•", - hellip: "…", - permil: "‰", - prime: "′", - Prime: "″", - lsaquo: "‹", - rsaquo: "›", - oline: "‾", - frasl: "⁄", - euro: "€", - image: "ℑ", - weierp: "℘", - real: "ℜ", - trade: "™", - alefsym: "ℵ", - larr: "←", - uarr: "↑", - rarr: "→", - darr: "↓", - harr: "↔", - crarr: "↵", - lArr: "⇐", - uArr: "⇑", - rArr: "⇒", - dArr: "⇓", - hArr: "⇔", - forall: "∀", - part: "∂", - exist: "∃", - empty: "∅", - nabla: "∇", - isin: "∈", - notin: "∉", - ni: "∋", - prod: "∏", - sum: "∑", - minus: "−", - lowast: "∗", - radic: "√", - prop: "∝", - infin: "∞", - ang: "∠", - and: "∧", - or: "∨", - cap: "∩", - cup: "∪", - "int": "∫", - there4: "∴", - sim: "∼", - cong: "≅", - asymp: "≈", - ne: "≠", - equiv: "≡", - le: "≤", - ge: "≥", - sub: "⊂", - sup: "⊃", - nsub: "⊄", - sube: "⊆", - supe: "⊇", - oplus: "⊕", - otimes: "⊗", - perp: "⊥", - sdot: "⋅", - lceil: "⌈", - rceil: "⌉", - lfloor: "⌊", - rfloor: "⌋", - lang: "〈", - rang: "〉", - loz: "◊", - spades: "♠", - clubs: "♣", - hearts: "♥", - diams: "♦" -}; -module.exports = exports["default"]; -},{}],626:[function(_dereq_,module,exports){ -// The algorithm used to determine whether a regexp can appear at a -// given point in the program is loosely based on sweet.js' approach. -// See https://github.com/mozilla/sweet.js/wiki/design - -"use strict"; - -exports.__esModule = true; -// istanbul ignore next - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -var _types = _dereq_(629); - -var TokContext = function TokContext(token, isExpr, preserveSpace, override) { - _classCallCheck(this, TokContext); - - this.token = token; - this.isExpr = !!isExpr; - this.preserveSpace = !!preserveSpace; - this.override = override; -}; - -exports.TokContext = TokContext; -var types = { - b_stat: new TokContext("{", false), - b_expr: new TokContext("{", true), - b_tmpl: new TokContext("${", true), - p_stat: new TokContext("(", false), - p_expr: new TokContext("(", true), - q_tmpl: new TokContext("`", true, true, function (p) { - return p.readTmplToken(); - }), - f_expr: new TokContext("function", true) -}; - -exports.types = types; -// Token-specific context update code - -_types.types.parenR.updateContext = _types.types.braceR.updateContext = function () { - if (this.state.context.length === 1) { - this.state.exprAllowed = true; - return; - } - - var out = this.state.context.pop(); - if (out === types.b_stat && this.curContext() === types.f_expr) { - this.state.context.pop(); - this.state.exprAllowed = false; - } else if (out === types.b_tmpl) { - this.state.exprAllowed = true; - } else { - this.state.exprAllowed = !out.isExpr; - } -}; - -_types.types.braceL.updateContext = function (prevType) { - this.state.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr); - this.state.exprAllowed = true; -}; - -_types.types.dollarBraceL.updateContext = function () { - this.state.context.push(types.b_tmpl); - this.state.exprAllowed = true; -}; - -_types.types.parenL.updateContext = function (prevType) { - var statementParens = prevType === _types.types._if || prevType === _types.types._for || prevType === _types.types._with || prevType === _types.types._while; - this.state.context.push(statementParens ? types.p_stat : types.p_expr); - this.state.exprAllowed = true; -}; - -_types.types.incDec.updateContext = function () { - // tokExprAllowed stays unchanged -}; - -_types.types._function.updateContext = function () { - if (this.curContext() !== types.b_stat) { - this.state.context.push(types.f_expr); - } - - this.state.exprAllowed = false; -}; - -_types.types.backQuote.updateContext = function () { - if (this.curContext() === types.q_tmpl) { - this.state.context.pop(); - } else { - this.state.context.push(types.q_tmpl); - } - this.state.exprAllowed = false; -}; -},{"629":629}],627:[function(_dereq_,module,exports){ -"use strict"; - -exports.__esModule = true; -// istanbul ignore next - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } - -// istanbul ignore next - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -var _utilIdentifier = _dereq_(630); - -var _types = _dereq_(629); - -var _context = _dereq_(626); - -var _utilLocation = _dereq_(631); - -var _utilWhitespace = _dereq_(632); - -var _state = _dereq_(628); - -var _state2 = _interopRequireDefault(_state); - -// Object type used to represent tokens. Note that normally, tokens -// simply exist as properties on the parser object. This is only -// used for the onToken callback and the external tokenizer. - -var Token = function Token(state) { - _classCallCheck(this, Token); - - this.type = state.type; - this.value = state.value; - this.start = state.start; - this.end = state.end; - this.loc = new _utilLocation.SourceLocation(state.startLoc, state.endLoc); -} - -// ## Tokenizer - -// Are we running under Rhino? -/* global Packages */ -; - -exports.Token = Token; -var isRhino = typeof Packages === "object" && Object.prototype.toString.call(Packages) === "[object JavaPackage]"; - -// Parse a regular expression. Some context-awareness is necessary, -// since a '/' inside a '[]' set does not end the expression. - -function tryCreateRegexp(src, flags, throwErrorStart) { - try { - return new RegExp(src, flags); - } catch (e) { - if (throwErrorStart !== undefined) { - if (e instanceof SyntaxError) this.raise(throwErrorStart, "Error parsing regular expression: " + e.message); - this.raise(e); - } - } -} - -var regexpUnicodeSupport = !!tryCreateRegexp("￿", "u"); - -function codePointToString(code) { - // UTF-16 Decoding - if (code <= 0xFFFF) return String.fromCharCode(code); - return String.fromCharCode((code - 0x10000 >> 10) + 0xD800, (code - 0x10000 & 1023) + 0xDC00); -} - -var Tokenizer = (function () { - function Tokenizer(input) { - _classCallCheck(this, Tokenizer); - - this.state = new _state2["default"](); - this.state.init(input); - } - - // Move to the next token - - Tokenizer.prototype.next = function next() { - this.state.tokens.push(new Token(this.state)); - - this.state.lastTokEnd = this.state.end; - this.state.lastTokStart = this.state.start; - this.state.lastTokEndLoc = this.state.endLoc; - this.state.lastTokStartLoc = this.state.startLoc; - this.nextToken(); - }; - - // TODO - - Tokenizer.prototype.eat = function eat(type) { - if (this.match(type)) { - this.next(); - return true; - } else { - return false; - } - }; - - // TODO - - Tokenizer.prototype.match = function match(type) { - return this.state.type === type; - }; - - // TODO - - Tokenizer.prototype.lookahead = function lookahead() { - var old = this.state; - this.state = old.clone(); - this.next(); - var curr = this.state.clone(); - this.state = old; - return curr; - }; - - // Toggle strict mode. Re-reads the next number or string to please - // pedantic tests (`"use strict"; 010;` should fail). - - Tokenizer.prototype.setStrict = function setStrict(strict) { - this.strict = strict; - if (!this.match(_types.types.num) && !this.match(_types.types.string)) return; - this.state.pos = this.state.start; - while (this.state.pos < this.state.lineStart) { - this.state.lineStart = this.input.lastIndexOf("\n", this.state.lineStart - 2) + 1; - --this.state.curLine; - } - this.nextToken(); - }; - - Tokenizer.prototype.curContext = function curContext() { - return this.state.context[this.state.context.length - 1]; - }; - - // Read a single token, updating the parser object's token-related - // properties. - - Tokenizer.prototype.nextToken = function nextToken() { - var curContext = this.curContext(); - if (!curContext || !curContext.preserveSpace) this.skipSpace(); - - this.state.start = this.state.pos; - this.state.startLoc = this.state.curPosition(); - if (this.state.pos >= this.input.length) return this.finishToken(_types.types.eof); - - if (curContext.override) { - return curContext.override(this); - } else { - return this.readToken(this.fullCharCodeAtPos()); - } - }; - - Tokenizer.prototype.readToken = function readToken(code) { - // Identifier or keyword. '\uXXXX' sequences are allowed in - // identifiers, so '\' also dispatches to that. - if (_utilIdentifier.isIdentifierStart(code, true) || code === 92 /* '\' */) return this.readWord(); - - return this.getTokenFromCode(code); - }; - - Tokenizer.prototype.fullCharCodeAtPos = function fullCharCodeAtPos() { - var code = this.input.charCodeAt(this.state.pos); - if (code <= 0xd7ff || code >= 0xe000) return code; - - var next = this.input.charCodeAt(this.state.pos + 1); - return (code << 10) + next - 0x35fdc00; - }; - - Tokenizer.prototype.pushComment = function pushComment(block, text, start, end, startLoc, endLoc) { - var comment = { - type: block ? "CommentBlock" : "CommentLine", - value: text, - start: start, - end: end, - loc: new _utilLocation.SourceLocation(startLoc, endLoc), - range: [start, end] - }; - - this.state.tokens.push(comment); - this.state.comments.push(comment); - this.addComment(comment); - }; - - Tokenizer.prototype.skipBlockComment = function skipBlockComment() { - var startLoc = this.state.curPosition(); - var start = this.state.pos, - end = this.input.indexOf("*/", this.state.pos += 2); - if (end === -1) this.raise(this.state.pos - 2, "Unterminated comment"); - - this.state.pos = end + 2; - _utilWhitespace.lineBreakG.lastIndex = start; - var match = undefined; - while ((match = _utilWhitespace.lineBreakG.exec(this.input)) && match.index < this.state.pos) { - ++this.state.curLine; - this.state.lineStart = match.index + match[0].length; - } - - this.pushComment(true, this.input.slice(start + 2, end), start, this.state.pos, startLoc, this.state.curPosition()); - }; - - Tokenizer.prototype.skipLineComment = function skipLineComment(startSkip) { - var start = this.state.pos; - var startLoc = this.state.curPosition(); - var ch = this.input.charCodeAt(this.state.pos += startSkip); - while (this.state.pos < this.input.length && ch !== 10 && ch !== 13 && ch !== 8232 && ch !== 8233) { - ++this.state.pos; - ch = this.input.charCodeAt(this.state.pos); - } - - this.pushComment(false, this.input.slice(start + startSkip, this.state.pos), start, this.state.pos, startLoc, this.state.curPosition()); - }; - - // Called at the start of the parse and after every token. Skips - // whitespace and comments, and. - - Tokenizer.prototype.skipSpace = function skipSpace() { - loop: while (this.state.pos < this.input.length) { - var ch = this.input.charCodeAt(this.state.pos); - switch (ch) { - case 32:case 160: - // ' ' - ++this.state.pos; - break; - - case 13: - if (this.input.charCodeAt(this.state.pos + 1) === 10) { - ++this.state.pos; - } - - case 10:case 8232:case 8233: - ++this.state.pos; - ++this.state.curLine; - this.state.lineStart = this.state.pos; - break; - - case 47: - // '/' - switch (this.input.charCodeAt(this.state.pos + 1)) { - case 42: - // '*' - this.skipBlockComment(); - break; - - case 47: - this.skipLineComment(2); - break; - - default: - break loop; - } - break; - - default: - if (ch > 8 && ch < 14 || ch >= 5760 && _utilWhitespace.nonASCIIwhitespace.test(String.fromCharCode(ch))) { - ++this.state.pos; - } else { - break loop; - } - } - } - }; - - // Called at the end of every token. Sets `end`, `val`, and - // maintains `context` and `exprAllowed`, and skips the space after - // the token, so that the next one's `start` will point at the - // right position. - - Tokenizer.prototype.finishToken = function finishToken(type, val) { - this.state.end = this.state.pos; - this.state.endLoc = this.state.curPosition(); - var prevType = this.state.type; - this.state.type = type; - this.state.value = val; - - this.updateContext(prevType); - }; - - // ### Token reading - - // This is the function that is called to fetch the next token. It - // is somewhat obscure, because it works in character codes rather - // than characters, and because operator parsing has been inlined - // into it. - // - // All in the name of speed. - // - - Tokenizer.prototype.readToken_dot = function readToken_dot() { - var next = this.input.charCodeAt(this.state.pos + 1); - if (next >= 48 && next <= 57) { - return this.readNumber(true); - } - - var next2 = this.input.charCodeAt(this.state.pos + 2); - if (next === 46 && next2 === 46) { - // 46 = dot '.' - this.state.pos += 3; - return this.finishToken(_types.types.ellipsis); - } else { - ++this.state.pos; - return this.finishToken(_types.types.dot); - } - }; - - Tokenizer.prototype.readToken_slash = function readToken_slash() { - // '/' - if (this.state.exprAllowed) { - ++this.state.pos; - return this.readRegexp(); - } - - var next = this.input.charCodeAt(this.state.pos + 1); - if (next === 61) { - return this.finishOp(_types.types.assign, 2); - } else { - return this.finishOp(_types.types.slash, 1); - } - }; - - Tokenizer.prototype.readToken_mult_modulo = function readToken_mult_modulo(code) { - // '%*' - var type = code === 42 ? _types.types.star : _types.types.modulo; - var width = 1; - var next = this.input.charCodeAt(this.state.pos + 1); - - if (next === 42 && this.options.features["es7.exponentiationOperator"]) { - // '*' - width++; - next = this.input.charCodeAt(this.state.pos + 2); - type = _types.types.exponent; - } - - if (next === 61) { - width++; - type = _types.types.assign; - } - - return this.finishOp(type, width); - }; - - Tokenizer.prototype.readToken_pipe_amp = function readToken_pipe_amp(code) { - // '|&' - var next = this.input.charCodeAt(this.state.pos + 1); - if (next === code) return this.finishOp(code === 124 ? _types.types.logicalOR : _types.types.logicalAND, 2); - if (next === 61) return this.finishOp(_types.types.assign, 2); - return this.finishOp(code === 124 ? _types.types.bitwiseOR : _types.types.bitwiseAND, 1); - }; - - Tokenizer.prototype.readToken_caret = function readToken_caret() { - // '^' - var next = this.input.charCodeAt(this.state.pos + 1); - if (next === 61) { - return this.finishOp(_types.types.assign, 2); - } else { - return this.finishOp(_types.types.bitwiseXOR, 1); - } - }; - - Tokenizer.prototype.readToken_plus_min = function readToken_plus_min(code) { - // '+-' - var next = this.input.charCodeAt(this.state.pos + 1); - - if (next === code) { - if (next === 45 && this.input.charCodeAt(this.state.pos + 2) === 62 && _utilWhitespace.lineBreak.test(this.input.slice(this.state.lastTokEnd, this.state.pos))) { - // A `-->` line comment - this.skipLineComment(3); - this.skipSpace(); - return this.nextToken(); - } - return this.finishOp(_types.types.incDec, 2); - } - - if (next === 61) { - return this.finishOp(_types.types.assign, 2); - } else { - return this.finishOp(_types.types.plusMin, 1); - } - }; - - Tokenizer.prototype.readToken_lt_gt = function readToken_lt_gt(code) { - // '<>' - var next = this.input.charCodeAt(this.state.pos + 1); - var size = 1; - - if (next === code) { - size = code === 62 && this.input.charCodeAt(this.state.pos + 2) === 62 ? 3 : 2; - if (this.input.charCodeAt(this.state.pos + size) === 61) return this.finishOp(_types.types.assign, size + 1); - return this.finishOp(_types.types.bitShift, size); - } - - if (next === 33 && code === 60 && this.input.charCodeAt(this.state.pos + 2) === 45 && this.input.charCodeAt(this.state.pos + 3) === 45) { - if (this.inModule) this.unexpected(); - // `