From 588bbde6de6f97481846c6e1a1fd4d898b95a61d Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Sun, 23 Feb 2020 12:39:05 -0500 Subject: [PATCH] Regenerate docs/bundle.js with latest implementation. Command: npx browserify -s regenerator ./main.js > docs/bundle.js --- docs/bundle.js | 21615 ++++++++++++++++++++++++++--------------------- 1 file changed, 12082 insertions(+), 9533 deletions(-) diff --git a/docs/bundle.js b/docs/bundle.js index 043fcced9..df2e385b2 100644 --- a/docs/bundle.js +++ b/docs/bundle.js @@ -98,7 +98,7 @@ exports.isReference = function(path, name) { } }; -},{"assert":191,"recast":451}],2:[function(require,module,exports){ +},{"assert":196,"recast":456}],2:[function(require,module,exports){ /** * Copyright (c) 2014-present, Facebook, Inc. * @@ -146,7 +146,7 @@ function injectRuntime(program) { body.unshift.apply(body, runtimeBody); } -},{"..":3,"./util.js":1,"@babel/core":22,"recast":451,"regenerator-preset":506}],3:[function(require,module,exports){ +},{"..":3,"./util.js":1,"@babel/core":23,"recast":456,"regenerator-preset":491}],3:[function(require,module,exports){ /** * Copyright (c) 2014-present, Facebook, Inc. * @@ -234,7 +234,7 @@ exports.compile = compile; // To modify an AST directly, call require("regenerator").transform(ast). exports.transform = transform; -},{"./lib/util":1,"./lib/visit":2,"@babel/core":22,"fs":197,"recast":451,"regenerator-preset":506,"regenerator-runtime":508,"regenerator-runtime/path.js":507,"through":499}],4:[function(require,module,exports){ +},{"./lib/util":1,"./lib/visit":2,"@babel/core":23,"fs":202,"recast":456,"regenerator-preset":491,"regenerator-runtime":493,"regenerator-runtime/path.js":492,"through":517}],4:[function(require,module,exports){ (function (process){ "use strict"; @@ -244,17 +244,11 @@ Object.defineProperty(exports, "__esModule", { exports.codeFrameColumns = codeFrameColumns; exports.default = _default; -function _highlight() { - const data = _interopRequireWildcard(require("@babel/highlight")); +var _highlight = _interopRequireWildcard(require("@babel/highlight")); - _highlight = function () { - return data; - }; - - return data; -} +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } let deprecationWarningShown = false; @@ -273,7 +267,7 @@ function getMarkerLines(loc, source, opts) { column: 0, line: -1 }, loc.start); - const endLoc = Object.assign({}, startLoc, loc.end); + const endLoc = Object.assign({}, startLoc, {}, loc.end); const { linesAbove = 2, linesBelow = 3 @@ -304,7 +298,7 @@ function getMarkerLines(loc, source, opts) { markerLines[lineNumber] = true; } else if (i === 0) { const sourceLength = source[lineNumber - 1].length; - markerLines[lineNumber] = [startColumn, sourceLength - startColumn]; + markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1]; } else if (i === lineDiff) { markerLines[lineNumber] = [0, endColumn]; } else { @@ -332,15 +326,14 @@ function getMarkerLines(loc, source, opts) { } function codeFrameColumns(rawLines, loc, opts = {}) { - const highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight().shouldHighlight)(opts); - const chalk = (0, _highlight().getChalk)(opts); + const highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight.shouldHighlight)(opts); + const chalk = (0, _highlight.getChalk)(opts); const defs = getDefs(chalk); const maybeHighlight = (chalkFn, string) => { return highlighted ? chalkFn(string) : string; }; - if (highlighted) rawLines = (0, _highlight().default)(rawLines, opts); const lines = rawLines.split(NEWLINE); const { start, @@ -349,7 +342,8 @@ function codeFrameColumns(rawLines, loc, opts = {}) { } = getMarkerLines(loc, lines, opts); const hasColumns = loc.start && typeof loc.start.column === "number"; const numberMaxWidth = String(end).length; - let frame = lines.slice(start, end).map((line, index) => { + const highlightedLines = highlighted ? (0, _highlight.default)(rawLines, opts) : rawLines; + let frame = highlightedLines.split(NEWLINE).slice(start, end).map((line, index) => { const number = start + 1 + index; const paddedNumber = ` ${number}`.slice(-numberMaxWidth); const gutter = ` ${paddedNumber} | `; @@ -410,80 +404,183 @@ function _default(rawLines, lineNumber, colNumber, opts = {}) { return codeFrameColumns(rawLines, location, opts); } }).call(this,require('_process')) -},{"@babel/highlight":70,"_process":426}],5:[function(require,module,exports){ +},{"@babel/highlight":72,"_process":433}],5:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.makeStrongCache = makeStrongCache; exports.makeWeakCache = makeWeakCache; +exports.makeWeakCacheSync = makeWeakCacheSync; +exports.makeStrongCache = makeStrongCache; +exports.makeStrongCacheSync = makeStrongCacheSync; exports.assertSimpleType = assertSimpleType; -function makeStrongCache(handler) { - return makeCachedFunction(new Map(), handler); +function _gensync() { + const data = _interopRequireDefault(require("gensync")); + + _gensync = function () { + return data; + }; + + return data; +} + +var _async = require("../gensync-utils/async"); + +var _util = require("./util"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +const synchronize = gen => { + return (0, _gensync().default)(gen).sync; +}; + +function* genTrue(data) { + return true; } function makeWeakCache(handler) { - return makeCachedFunction(new WeakMap(), handler); + return makeCachedFunction(WeakMap, handler); } -function makeCachedFunction(callCache, handler) { - return function cachedFunction(arg, data) { - let cachedValue = callCache.get(arg); +function makeWeakCacheSync(handler) { + return synchronize(makeWeakCache(handler)); +} - if (cachedValue) { - for (const _ref of cachedValue) { - const { - value, - valid - } = _ref; - if (valid(data)) return value; - } - } +function makeStrongCache(handler) { + return makeCachedFunction(Map, handler); +} - const cache = new CacheConfigurator(data); - const value = handler(arg, cache); - if (!cache.configured()) cache.forever(); - cache.deactivate(); +function makeStrongCacheSync(handler) { + return synchronize(makeStrongCache(handler)); +} - switch (cache.mode()) { - case "forever": - cachedValue = [{ - value, - valid: () => true - }]; - callCache.set(arg, cachedValue); - break; +function makeCachedFunction(CallCache, handler) { + const callCacheSync = new CallCache(); + const callCacheAsync = new CallCache(); + const futureCache = new CallCache(); + return function* cachedFunction(arg, data) { + const asyncContext = yield* (0, _async.isAsync)(); + const callCache = asyncContext ? callCacheAsync : callCacheSync; + const cached = yield* getCachedValueOrWait(asyncContext, callCache, futureCache, arg, data); + if (cached.valid) return cached.value; + const cache = new CacheConfigurator(data); + const handlerResult = handler(arg, cache); + let finishLock; + let value; - case "invalidate": - cachedValue = [{ - value, - valid: cache.validator() - }]; - callCache.set(arg, cachedValue); - break; + if ((0, _util.isIterableIterator)(handlerResult)) { + const gen = handlerResult; + value = yield* (0, _async.onFirstPause)(gen, () => { + finishLock = setupAsyncLocks(cache, futureCache, arg); + }); + } else { + value = handlerResult; + } - case "valid": - if (cachedValue) { - cachedValue.push({ - value, - valid: cache.validator() - }); - } else { - cachedValue = [{ - value, - valid: cache.validator() - }]; - callCache.set(arg, cachedValue); - } + updateFunctionCache(callCache, cache, arg, value); + if (finishLock) { + futureCache.delete(arg); + finishLock.release(value); } return value; }; } +function* getCachedValue(cache, arg, data) { + const cachedValue = cache.get(arg); + + if (cachedValue) { + for (const { + value, + valid + } of cachedValue) { + if (yield* valid(data)) return { + valid: true, + value + }; + } + } + + return { + valid: false, + value: null + }; +} + +function* getCachedValueOrWait(asyncContext, callCache, futureCache, arg, data) { + const cached = yield* getCachedValue(callCache, arg, data); + + if (cached.valid) { + return cached; + } + + if (asyncContext) { + const cached = yield* getCachedValue(futureCache, arg, data); + + if (cached.valid) { + const value = yield* (0, _async.waitFor)(cached.value.promise); + return { + valid: true, + value + }; + } + } + + return { + valid: false, + value: null + }; +} + +function setupAsyncLocks(config, futureCache, arg) { + const finishLock = new Lock(); + updateFunctionCache(futureCache, config, arg, finishLock); + return finishLock; +} + +function updateFunctionCache(cache, config, arg, value) { + if (!config.configured()) config.forever(); + let cachedValue = cache.get(arg); + config.deactivate(); + + switch (config.mode()) { + case "forever": + cachedValue = [{ + value, + valid: genTrue + }]; + cache.set(arg, cachedValue); + break; + + case "invalidate": + cachedValue = [{ + value, + valid: config.validator() + }]; + cache.set(arg, cachedValue); + break; + + case "valid": + if (cachedValue) { + cachedValue.push({ + value, + valid: config.validator() + }); + } else { + cachedValue = [{ + value, + valid: config.validator() + }]; + cache.set(arg, cachedValue); + } + + } +} + class CacheConfigurator { constructor(data) { this._active = true; @@ -543,33 +640,35 @@ class CacheConfigurator { this._configured = true; const key = handler(this._data); + const fn = (0, _async.maybeAsync)(handler, `You appear to be using an async cache handler, but Babel has been called synchronously`); + + if ((0, _async.isThenable)(key)) { + return key.then(key => { + this._pairs.push([key, fn]); + + return key; + }); + } - this._pairs.push([key, handler]); + this._pairs.push([key, fn]); return key; } invalidate(handler) { - if (!this._active) { - throw new Error("Cannot change caching after evaluation has completed."); - } - - if (this._never || this._forever) { - throw new Error("Caching has already been configured with .never or .forever()"); - } - this._invalidate = true; - this._configured = true; - const key = handler(this._data); - - this._pairs.push([key, handler]); - - return key; + return this.using(handler); } validator() { const pairs = this._pairs; - return data => pairs.every(([key, fn]) => key === fn(data)); + return function* (data) { + for (const [key, fn] of pairs) { + if (key !== (yield* fn(data))) return false; + } + + return true; + }; } deactivate() { @@ -604,13 +703,33 @@ function makeSimpleConfigurator(cache) { } function assertSimpleType(value) { + if ((0, _async.isThenable)(value)) { + throw new Error(`You appear to be using an async cache handler, ` + `which your current version of Babel does not support. ` + `We may add support for this in the future, ` + `but if you're on the most recent version of @babel/core and still ` + `seeing this error, then you'll need to synchronously handle your caching logic.`); + } + if (value != null && typeof value !== "string" && typeof value !== "boolean" && typeof value !== "number") { throw new Error("Cache keys must be either string, boolean, number, null, or undefined."); } return value; } -},{}],6:[function(require,module,exports){ + +class Lock { + constructor() { + this.released = false; + this.promise = new Promise(resolve => { + this._resolve = resolve; + }); + } + + release(value) { + this.released = true; + + this._resolve(value); + } + +} +},{"../gensync-utils/async":22,"./util":17,"gensync":220}],6:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -654,8 +773,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de const debug = (0, _debug().default)("babel:config:config-chain"); -function buildPresetChain(arg, context) { - const chain = buildPresetChainWalker(arg, context); +function* buildPresetChain(arg, context) { + const chain = yield* buildPresetChainWalker(arg, context); if (!chain) return null; return { plugins: dedupDescriptors(chain.plugins), @@ -672,13 +791,13 @@ const buildPresetChainWalker = makeChainWalker({ overridesEnv: (preset, index, envName) => loadPresetOverridesEnvDescriptors(preset)(index)(envName) }); exports.buildPresetChainWalker = buildPresetChainWalker; -const loadPresetDescriptors = (0, _caching.makeWeakCache)(preset => buildRootDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors)); -const loadPresetEnvDescriptors = (0, _caching.makeWeakCache)(preset => (0, _caching.makeStrongCache)(envName => buildEnvDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors, envName))); -const loadPresetOverridesDescriptors = (0, _caching.makeWeakCache)(preset => (0, _caching.makeStrongCache)(index => buildOverrideDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors, index))); -const loadPresetOverridesEnvDescriptors = (0, _caching.makeWeakCache)(preset => (0, _caching.makeStrongCache)(index => (0, _caching.makeStrongCache)(envName => buildOverrideEnvDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors, index, envName)))); +const loadPresetDescriptors = (0, _caching.makeWeakCacheSync)(preset => buildRootDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors)); +const loadPresetEnvDescriptors = (0, _caching.makeWeakCacheSync)(preset => (0, _caching.makeStrongCacheSync)(envName => buildEnvDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors, envName))); +const loadPresetOverridesDescriptors = (0, _caching.makeWeakCacheSync)(preset => (0, _caching.makeStrongCacheSync)(index => buildOverrideDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors, index))); +const loadPresetOverridesEnvDescriptors = (0, _caching.makeWeakCacheSync)(preset => (0, _caching.makeStrongCacheSync)(index => (0, _caching.makeStrongCacheSync)(envName => buildOverrideEnvDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors, index, envName)))); -function buildRootChain(opts, context) { - const programmaticChain = loadProgrammaticChain({ +function* buildRootChain(opts, context) { + const programmaticChain = yield* loadProgrammaticChain({ options: opts, dirname: context.cwd }, context); @@ -686,9 +805,9 @@ function buildRootChain(opts, context) { let configFile; if (typeof opts.configFile === "string") { - configFile = (0, _files.loadConfig)(opts.configFile, context.cwd, context.envName, context.caller); + configFile = yield* (0, _files.loadConfig)(opts.configFile, context.cwd, context.envName, context.caller); } else if (opts.configFile !== false) { - configFile = (0, _files.findRootConfig)(context.root, context.envName, context.caller); + configFile = yield* (0, _files.findRootConfig)(context.root, context.envName, context.caller); } let { @@ -700,7 +819,7 @@ function buildRootChain(opts, context) { if (configFile) { const validatedFile = validateConfigFile(configFile); - const result = loadFileChain(validatedFile, context); + const result = yield* loadFileChain(validatedFile, context); if (!result) return null; if (babelrc === undefined) { @@ -715,7 +834,7 @@ function buildRootChain(opts, context) { mergeChain(configFileChain, result); } - const pkgData = typeof context.filename === "string" ? (0, _files.findPackageData)(context.filename) : null; + const pkgData = typeof context.filename === "string" ? yield* (0, _files.findPackageData)(context.filename) : null; let ignoreFile, babelrcFile; const fileChain = emptyChain(); @@ -723,14 +842,14 @@ function buildRootChain(opts, context) { ({ ignore: ignoreFile, config: babelrcFile - } = (0, _files.findRelativeConfig)(pkgData, context.envName, context.caller)); + } = yield* (0, _files.findRelativeConfig)(pkgData, context.envName, context.caller)); if (ignoreFile && shouldIgnore(context, ignoreFile.ignore, null, ignoreFile.dirname)) { return null; } if (babelrcFile) { - const result = loadFileChain(validateBabelrcFile(babelrcFile), context); + const result = yield* loadFileChain(validateBabelrcFile(babelrcFile), context); if (!result) return null; mergeChain(fileChain, result); } @@ -776,17 +895,17 @@ function babelrcLoadEnabled(context, pkgData, babelrcRoots, babelrcRootsDirector }); } -const validateConfigFile = (0, _caching.makeWeakCache)(file => ({ +const validateConfigFile = (0, _caching.makeWeakCacheSync)(file => ({ filepath: file.filepath, dirname: file.dirname, options: (0, _options.validate)("configfile", file.options) })); -const validateBabelrcFile = (0, _caching.makeWeakCache)(file => ({ +const validateBabelrcFile = (0, _caching.makeWeakCacheSync)(file => ({ filepath: file.filepath, dirname: file.dirname, options: (0, _options.validate)("babelrcfile", file.options) })); -const validateExtendFile = (0, _caching.makeWeakCache)(file => ({ +const validateExtendFile = (0, _caching.makeWeakCacheSync)(file => ({ filepath: file.filepath, dirname: file.dirname, options: (0, _options.validate)("extendsfile", file.options) @@ -803,10 +922,10 @@ const loadFileChain = makeChainWalker({ overrides: (file, index) => loadFileOverridesDescriptors(file)(index), overridesEnv: (file, index, envName) => loadFileOverridesEnvDescriptors(file)(index)(envName) }); -const loadFileDescriptors = (0, _caching.makeWeakCache)(file => buildRootDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors)); -const loadFileEnvDescriptors = (0, _caching.makeWeakCache)(file => (0, _caching.makeStrongCache)(envName => buildEnvDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors, envName))); -const loadFileOverridesDescriptors = (0, _caching.makeWeakCache)(file => (0, _caching.makeStrongCache)(index => buildOverrideDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors, index))); -const loadFileOverridesEnvDescriptors = (0, _caching.makeWeakCache)(file => (0, _caching.makeStrongCache)(index => (0, _caching.makeStrongCache)(envName => buildOverrideEnvDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors, index, envName)))); +const loadFileDescriptors = (0, _caching.makeWeakCacheSync)(file => buildRootDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors)); +const loadFileEnvDescriptors = (0, _caching.makeWeakCacheSync)(file => (0, _caching.makeStrongCacheSync)(envName => buildEnvDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors, envName))); +const loadFileOverridesDescriptors = (0, _caching.makeWeakCacheSync)(file => (0, _caching.makeStrongCacheSync)(index => buildOverrideDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors, index))); +const loadFileOverridesEnvDescriptors = (0, _caching.makeWeakCacheSync)(file => (0, _caching.makeStrongCacheSync)(index => (0, _caching.makeStrongCacheSync)(envName => buildOverrideEnvDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors, index, envName)))); function buildRootDescriptors({ dirname, @@ -848,7 +967,7 @@ function makeChainWalker({ overrides, overridesEnv }) { - return (input, context, files = new Set()) => { + return function* (input, context, files = new Set()) { const { dirname } = input; @@ -889,7 +1008,7 @@ function makeChainWalker({ const chain = emptyChain(); for (const op of flattenedConfigs) { - if (!mergeExtendsChain(chain, op.options, dirname, context, files)) { + if (!(yield* mergeExtendsChain(chain, op.options, dirname, context, files))) { return null; } @@ -900,16 +1019,16 @@ function makeChainWalker({ }; } -function mergeExtendsChain(chain, opts, dirname, context, files) { +function* mergeExtendsChain(chain, opts, dirname, context, files) { if (opts.extends === undefined) return true; - const file = (0, _files.loadConfig)(opts.extends, dirname, context.envName, context.caller); + const file = yield* (0, _files.loadConfig)(opts.extends, dirname, context.envName, context.caller); if (files.has(file)) { throw new Error(`Configuration cycle detected loading ${file.filepath}.\n` + `File already loaded following the config chain:\n` + Array.from(files, file => ` - ${file.filepath}`).join("\n")); } files.add(file); - const fileChain = loadFileChain(validateExtendFile(file), context, files); + const fileChain = yield* loadFileChain(validateExtendFile(file), context, files); files.delete(file); if (!fileChain) return false; mergeChain(chain, fileChain); @@ -956,7 +1075,7 @@ function normalizeOptions(opts) { delete options.include; delete options.exclude; - if (options.hasOwnProperty("sourceMap")) { + if (Object.prototype.hasOwnProperty.call(options, "sourceMap")) { options.sourceMaps = options.sourceMap; delete options.sourceMap; } @@ -1050,7 +1169,7 @@ function matchPattern(pattern, dirname, pathToTest, context) { return pattern.test(pathToTest); } -},{"./caching":5,"./config-descriptors":7,"./files":8,"./pattern-to-regex":15,"./validation/options":19,"debug":207,"path":423}],7:[function(require,module,exports){ +},{"./caching":5,"./config-descriptors":7,"./files":8,"./pattern-to-regex":15,"./validation/options":19,"debug":212,"path":430}],7:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -1106,14 +1225,14 @@ function createUncachedDescriptors(dirname, options, alias) { } const PRESET_DESCRIPTOR_CACHE = new WeakMap(); -const createCachedPresetDescriptors = (0, _caching.makeWeakCache)((items, cache) => { +const createCachedPresetDescriptors = (0, _caching.makeWeakCacheSync)((items, cache) => { const dirname = cache.using(dir => dir); - return (0, _caching.makeStrongCache)(alias => (0, _caching.makeStrongCache)(passPerPreset => createPresetDescriptors(items, dirname, alias, passPerPreset).map(desc => loadCachedDescriptor(PRESET_DESCRIPTOR_CACHE, desc)))); + return (0, _caching.makeStrongCacheSync)(alias => (0, _caching.makeStrongCacheSync)(passPerPreset => createPresetDescriptors(items, dirname, alias, passPerPreset).map(desc => loadCachedDescriptor(PRESET_DESCRIPTOR_CACHE, desc)))); }); const PLUGIN_DESCRIPTOR_CACHE = new WeakMap(); -const createCachedPluginDescriptors = (0, _caching.makeWeakCache)((items, cache) => { +const createCachedPluginDescriptors = (0, _caching.makeWeakCacheSync)((items, cache) => { const dirname = cache.using(dir => dir); - return (0, _caching.makeStrongCache)(alias => createPluginDescriptors(items, dirname, alias).map(desc => loadCachedDescriptor(PLUGIN_DESCRIPTOR_CACHE, desc))); + return (0, _caching.makeStrongCacheSync)(alias => createPluginDescriptors(items, dirname, alias).map(desc => loadCachedDescriptor(PLUGIN_DESCRIPTOR_CACHE, desc))); }); const DEFAULT_OPTIONS = {}; @@ -1255,7 +1374,8 @@ function assertNoDuplicates(items) { } if (nameMap.has(item.name)) { - throw new Error([`Duplicate plugin/preset detected.`, `If you'd like to use two separate instances of a plugin,`, `they need separate names, e.g.`, ``, ` plugins: [`, ` ['some-plugin', {}],`, ` ['some-plugin', {}, 'some unique name'],`, ` ]`].join("\n")); + const conflicts = items.filter(i => i.value === item.value); + throw new Error([`Duplicate plugin/preset detected.`, `If you'd like to use two separate instances of a plugin,`, `they need separate names, e.g.`, ``, ` plugins: [`, ` ['some-plugin', {}],`, ` ['some-plugin', {}, 'some unique name'],`, ` ]`, ``, `Duplicates detected are:`, `${JSON.stringify(conflicts, null, 2)}`].join("\n")); } nameMap.add(item.name); @@ -1276,12 +1396,13 @@ exports.resolvePlugin = resolvePlugin; exports.resolvePreset = resolvePreset; exports.loadPlugin = loadPlugin; exports.loadPreset = loadPreset; +exports.ROOT_CONFIG_FILENAMES = void 0; -function findConfigUpwards(rootDir) { +function* findConfigUpwards(rootDir) { return null; } -function findPackageData(filepath) { +function* findPackageData(filepath) { return { filepath, directories: [], @@ -1290,7 +1411,7 @@ function findPackageData(filepath) { }; } -function findRelativeConfig(pkgData, envName, caller) { +function* findRelativeConfig(pkgData, envName, caller) { return { pkg: null, config: null, @@ -1298,14 +1419,17 @@ function findRelativeConfig(pkgData, envName, caller) { }; } -function findRootConfig(dirname, envName, caller) { +function* findRootConfig(dirname, envName, caller) { return null; } -function loadConfig(name, dirname, envName, caller) { +function* loadConfig(name, dirname, envName, caller) { throw new Error(`Cannot load ${name} relative to ${dirname} in a browser`); } +const ROOT_CONFIG_FILENAMES = []; +exports.ROOT_CONFIG_FILENAMES = ROOT_CONFIG_FILENAMES; + function resolvePlugin(name, dirname) { return null; } @@ -1327,7 +1451,19 @@ function loadPreset(name, dirname) { Object.defineProperty(exports, "__esModule", { value: true }); -exports.default = loadFullConfig; +exports.default = void 0; + +function _gensync() { + const data = _interopRequireDefault(require("gensync")); + + _gensync = function () { + return data; + }; + + return data; +} + +var _async = require("../gensync-utils/async"); var _util = require("./util"); @@ -1359,12 +1495,14 @@ var _configApi = _interopRequireDefault(require("./helpers/config-api")); var _partial = _interopRequireDefault(require("./partial")); -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -function loadFullConfig(inputOpts) { - const result = (0, _partial.default)(inputOpts); +var _default = (0, _gensync().default)(function* loadFullConfig(inputOpts) { + const result = yield* (0, _partial.default)(inputOpts); if (!result) { return null; @@ -1387,35 +1525,55 @@ function loadFullConfig(inputOpts) { throw new Error("Assertion failure - plugins and presets exist"); } - const ignored = function recurseDescriptors(config, pass) { - const plugins = config.plugins.reduce((acc, descriptor) => { + const ignored = yield* function* recurseDescriptors(config, pass) { + const plugins = []; + + for (let i = 0; i < config.plugins.length; i++) { + const descriptor = config.plugins[i]; + if (descriptor.options !== false) { - acc.push(loadPluginDescriptor(descriptor, context)); + try { + plugins.push((yield* loadPluginDescriptor(descriptor, context))); + } catch (e) { + if (i > 0 && e.code === "BABEL_UNKNOWN_PLUGIN_PROPERTY") { + (0, _options.checkNoUnwrappedItemOptionPairs)(config.plugins[i - 1], descriptor, "plugin", i, e); + } + + throw e; + } } + } + + const presets = []; + + for (let i = 0; i < config.presets.length; i++) { + const descriptor = config.presets[i]; - return acc; - }, []); - const presets = config.presets.reduce((acc, descriptor) => { if (descriptor.options !== false) { - acc.push({ - preset: loadPresetDescriptor(descriptor, context), - pass: descriptor.ownPass ? [] : pass - }); - } + try { + presets.push({ + preset: yield* loadPresetDescriptor(descriptor, context), + pass: descriptor.ownPass ? [] : pass + }); + } catch (e) { + if (i > 0 && e.code === "BABEL_UNKNOWN_OPTION") { + (0, _options.checkNoUnwrappedItemOptionPairs)(config.presets[i - 1], descriptor, "preset", i, e); + } - return acc; - }, []); + throw e; + } + } + } if (presets.length > 0) { passes.splice(1, 0, ...presets.map(o => o.pass).filter(p => p !== pass)); - for (const _ref of presets) { - const { - preset, - pass - } = _ref; + for (const { + preset, + pass + } of presets) { if (!preset) return true; - const ignored = recurseDescriptors({ + const ignored = yield* recurseDescriptors({ plugins: preset.plugins, presets: preset.presets }, pass); @@ -1449,7 +1607,6 @@ function loadFullConfig(inputOpts) { return desc; }) }, passes[0]); - if (ignored) return null; } catch (e) { if (!/^\[BABEL\]/.test(e.message)) { @@ -1470,20 +1627,21 @@ function loadFullConfig(inputOpts) { options: opts, passes: passes }; -} +}); -const loadDescriptor = (0, _caching.makeWeakCache)(({ +exports.default = _default; +const loadDescriptor = (0, _caching.makeWeakCache)(function* ({ value, options, dirname, alias -}, cache) => { +}, cache) { if (options === false) throw new Error("Assertion failure"); options = options || {}; let item = value; if (typeof value === "function") { - const api = Object.assign({}, context, (0, _configApi.default)(cache)); + const api = Object.assign({}, context, {}, (0, _configApi.default)(cache)); try { item = value(api, options, dirname); @@ -1501,7 +1659,8 @@ const loadDescriptor = (0, _caching.makeWeakCache)(({ } if (typeof item.then === "function") { - throw new Error(`You appear to be using an async plugin, ` + `which your current version of Babel does not support.` + `If you're using a published plugin, ` + `you may need to upgrade your @babel/core version.`); + yield* []; + throw new Error(`You appear to be using an async plugin, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, ` + `you may need to upgrade your @babel/core version.`); } return { @@ -1512,7 +1671,7 @@ const loadDescriptor = (0, _caching.makeWeakCache)(({ }; }); -function loadPluginDescriptor(descriptor, context) { +function* loadPluginDescriptor(descriptor, context) { if (descriptor.value instanceof _plugin.default) { if (descriptor.options) { throw new Error("Passed options to an existing Plugin instance will not work."); @@ -1521,15 +1680,15 @@ function loadPluginDescriptor(descriptor, context) { return descriptor.value; } - return instantiatePlugin(loadDescriptor(descriptor, context), context); + return yield* instantiatePlugin((yield* loadDescriptor(descriptor, context)), context); } -const instantiatePlugin = (0, _caching.makeWeakCache)(({ +const instantiatePlugin = (0, _caching.makeWeakCache)(function* ({ value, options, dirname, alias -}, cache) => { +}, cache) { const pluginObj = (0, _plugins.validatePluginObject)(value); const plugin = Object.assign({}, pluginObj); @@ -1545,7 +1704,9 @@ const instantiatePlugin = (0, _caching.makeWeakCache)(({ options, dirname }; - const inherits = cache.invalidate(data => loadPluginDescriptor(inheritsDescriptor, data)); + const inherits = yield* (0, _async.forwardAsync)(loadPluginDescriptor, run => { + return cache.invalidate(data => run(inheritsDescriptor, data)); + }); plugin.pre = chain(inherits.pre, plugin.pre); plugin.post = chain(inherits.post, plugin.post); plugin.manipulateOptions = chain(inherits.manipulateOptions, plugin.manipulateOptions); @@ -1555,11 +1716,33 @@ const instantiatePlugin = (0, _caching.makeWeakCache)(({ return new _plugin.default(plugin, options, alias); }); -const loadPresetDescriptor = (descriptor, context) => { - return (0, _configChain.buildPresetChain)(instantiatePreset(loadDescriptor(descriptor, context)), context); +const validateIfOptionNeedsFilename = (options, descriptor) => { + if (options.test || options.include || options.exclude) { + const formattedPresetName = descriptor.name ? `"${descriptor.name}"` : "/* your preset */"; + throw new Error([`Preset ${formattedPresetName} requires a filename to be set when babel is called directly,`, `\`\`\``, `babel.transform(code, { filename: 'file.ts', presets: [${formattedPresetName}] });`, `\`\`\``, `See https://babeljs.io/docs/en/options#filename for more information.`].join("\n")); + } }; -const instantiatePreset = (0, _caching.makeWeakCache)(({ +const validatePreset = (preset, context, descriptor) => { + if (!context.filename) { + const { + options + } = preset; + validateIfOptionNeedsFilename(options, descriptor); + + if (options.overrides) { + options.overrides.forEach(overrideOptions => validateIfOptionNeedsFilename(overrideOptions, descriptor)); + } + } +}; + +function* loadPresetDescriptor(descriptor, context) { + const preset = instantiatePreset((yield* loadDescriptor(descriptor, context))); + validatePreset(preset, context, descriptor); + return yield* (0, _configChain.buildPresetChain)(preset, context); +} + +const instantiatePreset = (0, _caching.makeWeakCacheSync)(({ value, dirname, alias @@ -1580,7 +1763,7 @@ function chain(a, b) { } }; } -},{"../index":22,"./caching":5,"./config-chain":6,"./helpers/config-api":10,"./item":13,"./partial":14,"./plugin":16,"./util":17,"./validation/options":19,"./validation/plugins":20,"@babel/traverse":92}],10:[function(require,module,exports){ +},{"../gensync-utils/async":22,"../index":23,"./caching":5,"./config-chain":6,"./helpers/config-api":10,"./item":13,"./partial":14,"./plugin":16,"./util":17,"./validation/options":19,"./validation/plugins":20,"@babel/traverse":97,"gensync":220}],10:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -1667,7 +1850,7 @@ function assertVersion(range) { range }); } -},{"../../":22,"../caching":5,"semver":37}],11:[function(require,module,exports){ +},{"../../":23,"../caching":5,"semver":39}],11:[function(require,module,exports){ (function (process){ "use strict"; @@ -1680,25 +1863,29 @@ function getEnv(defaultValue = "development") { return process.env.BABEL_ENV || process.env.NODE_ENV || defaultValue; } }).call(this,require('_process')) -},{"_process":426}],12:[function(require,module,exports){ +},{"_process":433}],12:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.loadOptions = loadOptions; Object.defineProperty(exports, "default", { enumerable: true, get: function () { return _full.default; } }); -Object.defineProperty(exports, "loadPartialConfig", { - enumerable: true, - get: function () { - return _partial.loadPartialConfig; - } -}); +exports.loadOptionsAsync = exports.loadOptionsSync = exports.loadOptions = exports.loadPartialConfigAsync = exports.loadPartialConfigSync = exports.loadPartialConfig = void 0; + +function _gensync() { + const data = _interopRequireDefault(require("gensync")); + + _gensync = function () { + return data; + }; + + return data; +} var _full = _interopRequireDefault(require("./full")); @@ -1706,11 +1893,33 @@ var _partial = require("./partial"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -function loadOptions(opts) { - const config = (0, _full.default)(opts); +const loadOptionsRunner = (0, _gensync().default)(function* (opts) { + const config = yield* (0, _full.default)(opts); return config ? config.options : null; -} -},{"./full":9,"./partial":14}],13:[function(require,module,exports){ +}); + +const maybeErrback = runner => (opts, callback) => { + if (callback === undefined && typeof opts === "function") { + callback = opts; + opts = undefined; + } + + return callback ? runner.errback(opts, callback) : runner.sync(opts); +}; + +const loadPartialConfig = maybeErrback(_partial.loadPartialConfig); +exports.loadPartialConfig = loadPartialConfig; +const loadPartialConfigSync = _partial.loadPartialConfig.sync; +exports.loadPartialConfigSync = loadPartialConfigSync; +const loadPartialConfigAsync = _partial.loadPartialConfig.async; +exports.loadPartialConfigAsync = loadPartialConfigAsync; +const loadOptions = maybeErrback(loadOptionsRunner); +exports.loadOptions = loadOptions; +const loadOptionsSync = loadOptionsRunner.sync; +exports.loadOptionsSync = loadOptionsSync; +const loadOptionsAsync = loadOptionsRunner.async; +exports.loadOptionsAsync = loadOptionsAsync; +},{"./full":9,"./partial":14,"gensync":220}],13:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -1777,14 +1986,14 @@ class ConfigItem { } Object.freeze(ConfigItem.prototype); -},{"./config-descriptors":7,"path":423}],14:[function(require,module,exports){ +},{"./config-descriptors":7,"path":430}],14:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = loadPrivatePartialConfig; -exports.loadPartialConfig = loadPartialConfig; +exports.loadPartialConfig = void 0; function _path() { const data = _interopRequireDefault(require("path")); @@ -1796,6 +2005,16 @@ function _path() { return data; } +function _gensync() { + const data = _interopRequireDefault(require("gensync")); + + _gensync = function () { + return data; + }; + + return data; +} + var _plugin = _interopRequireDefault(require("./plugin")); var _util = require("./util"); @@ -1812,33 +2031,33 @@ var _files = require("./files"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -function resolveRootMode(rootDir, rootMode) { +function* resolveRootMode(rootDir, rootMode) { switch (rootMode) { case "root": return rootDir; case "upward-optional": { - const upwardRootDir = (0, _files.findConfigUpwards)(rootDir); + const upwardRootDir = yield* (0, _files.findConfigUpwards)(rootDir); return upwardRootDir === null ? rootDir : upwardRootDir; } case "upward": { - const upwardRootDir = (0, _files.findConfigUpwards)(rootDir); + const upwardRootDir = yield* (0, _files.findConfigUpwards)(rootDir); if (upwardRootDir !== null) return upwardRootDir; - throw Object.assign(new Error(`Babel was run with rootMode:"upward" but a root could not ` + `be found when searching upward from "${rootDir}"`), { + throw Object.assign(new Error(`Babel was run with rootMode:"upward" but a root could not ` + `be found when searching upward from "${rootDir}".\n` + `One of the following config files must be in the directory tree: ` + `"${_files.ROOT_CONFIG_FILENAMES.join(", ")}".`), { code: "BABEL_ROOT_NOT_FOUND", dirname: rootDir }); } default: - throw new Error(`Assertion failure - unknown rootMode value`); + throw new Error(`Assertion failure - unknown rootMode value.`); } } -function loadPrivatePartialConfig(inputOpts) { +function* loadPrivatePartialConfig(inputOpts) { if (inputOpts != null && (typeof inputOpts !== "object" || Array.isArray(inputOpts))) { throw new Error("Babel options must be an object, null, or undefined"); } @@ -1854,7 +2073,7 @@ function loadPrivatePartialConfig(inputOpts) { const absoluteCwd = _path().default.resolve(cwd); - const absoluteRootDir = resolveRootMode(_path().default.resolve(absoluteCwd, rootDir), rootMode); + const absoluteRootDir = yield* resolveRootMode(_path().default.resolve(absoluteCwd, rootDir), rootMode); const context = { filename: typeof args.filename === "string" ? _path().default.resolve(cwd, args.filename) : undefined, cwd: absoluteCwd, @@ -1862,7 +2081,7 @@ function loadPrivatePartialConfig(inputOpts) { envName, caller }; - const configChain = (0, _configChain.buildRootChain)(args, context); + const configChain = yield* (0, _configChain.buildRootChain)(args, context); if (!configChain) return null; const options = {}; configChain.options.forEach(opts => { @@ -1886,8 +2105,8 @@ function loadPrivatePartialConfig(inputOpts) { }; } -function loadPartialConfig(inputOpts) { - const result = loadPrivatePartialConfig(inputOpts); +const loadPartialConfig = (0, _gensync().default)(function* (inputOpts) { + const result = yield* loadPrivatePartialConfig(inputOpts); if (!result) return null; const { options, @@ -1901,7 +2120,8 @@ function loadPartialConfig(inputOpts) { } }); return new PartialConfig(options, babelrc ? babelrc.filepath : undefined, ignore ? ignore.filepath : undefined, config ? config.filepath : undefined); -} +}); +exports.loadPartialConfig = loadPartialConfig; class PartialConfig { constructor(options, babelrc, ignore, config) { @@ -1919,7 +2139,7 @@ class PartialConfig { } Object.freeze(PartialConfig.prototype); -},{"./config-chain":6,"./files":8,"./helpers/environment":11,"./item":13,"./plugin":16,"./util":17,"./validation/options":19,"path":423}],15:[function(require,module,exports){ +},{"./config-chain":6,"./files":8,"./helpers/environment":11,"./item":13,"./plugin":16,"./util":17,"./validation/options":19,"gensync":220,"path":430}],15:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -1972,7 +2192,7 @@ function pathToPattern(pattern, dirname) { return (0, _escapeRegExp().default)(part) + (last ? endSep : sep); })].join("")); } -},{"lodash/escapeRegExp":383,"path":423}],16:[function(require,module,exports){ +},{"lodash/escapeRegExp":389,"path":430}],16:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -2002,6 +2222,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.mergeOptions = mergeOptions; +exports.isIterableIterator = isIterableIterator; function mergeOptions(target, source) { for (const k of Object.keys(source)) { @@ -2026,6 +2247,10 @@ function mergeDefaultFields(target, source) { if (val !== undefined) target[k] = val; } } + +function isIterableIterator(value) { + return !!value && typeof value.next === "function" && typeof value[Symbol.iterator] === "function"; +} },{}],18:[function(require,module,exports){ "use strict"; @@ -2194,7 +2419,7 @@ function assertIgnoreList(loc, value) { function assertIgnoreItem(loc, value) { if (typeof value !== "string" && typeof value !== "function" && !(value instanceof RegExp)) { - throw new Error(`${msg(loc)} must be an array of string/Funtion/RegExp values, or undefined`); + throw new Error(`${msg(loc)} must be an array of string/Function/RegExp values, or undefined`); } return value; @@ -2269,7 +2494,7 @@ function assertPluginItem(loc, value) { if (value.length > 1) { const opts = value[1]; - if (opts !== undefined && opts !== false && (typeof opts !== "object" || Array.isArray(opts))) { + if (opts !== undefined && opts !== false && (typeof opts !== "object" || Array.isArray(opts) || opts === null)) { throw new Error(`${msg(access(loc, 1))} must be an object, false, or undefined`); } } @@ -2302,6 +2527,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.validate = validate; +exports.checkNoUnwrappedItemOptionPairs = checkNoUnwrappedItemOptionPairs; var _plugin = _interopRequireDefault(require("../plugin")); @@ -2415,10 +2641,11 @@ function throwUnknownError(loc) { message, version = 5 } = _removed.default[key]; - throw new ReferenceError(`Using removed Babel ${version} option: ${(0, _optionAssertions.msg)(loc)} - ${message}`); + throw new Error(`Using removed Babel ${version} option: ${(0, _optionAssertions.msg)(loc)} - ${message}`); } else { - const unknownOptErr = `Unknown option: ${(0, _optionAssertions.msg)(loc)}. Check out https://babeljs.io/docs/en/babel-core/#options for more information about options.`; - throw new ReferenceError(unknownOptErr); + const unknownOptErr = new Error(`Unknown option: ${(0, _optionAssertions.msg)(loc)}. Check out https://babeljs.io/docs/en/babel-core/#options for more information about options.`); + unknownOptErr.code = "BABEL_UNKNOWN_OPTION"; + throw unknownOptErr; } } @@ -2484,6 +2711,12 @@ function assertOverridesList(loc, value) { return arr; } + +function checkNoUnwrappedItemOptionPairs(lastItem, thisItem, type, index, e) { + if (lastItem.file && lastItem.options === undefined && typeof thisItem.value === "object") { + e.message += `\n- Maybe you meant to use\n` + `"${type}": [\n ["${lastItem.file.request}", ${JSON.stringify(thisItem.value, undefined, 2)}]\n]\n` + `To be a valid ${type}, its name and options should be wrapped in a pair of brackets`; + } +} },{"../plugin":16,"./option-assertions":18,"./removed":21}],20:[function(require,module,exports){ "use strict"; @@ -2534,9 +2767,22 @@ function assertVisitorHandler(key, value) { } function validatePluginObject(obj) { + const rootPath = { + type: "root", + source: "plugin" + }; Object.keys(obj).forEach(key => { const validator = VALIDATORS[key]; - if (validator) validator(key, obj[key]);else throw new Error(`.${key} is not a valid Plugin property`); + const optLoc = { + type: "option", + name: key, + parent: rootPath + }; + if (validator) validator(optLoc, obj[key]);else { + const invalidPluginPropertyError = new Error(`.${key} is not a valid Plugin property`); + invalidPluginPropertyError.code = "BABEL_UNKNOWN_PLUGIN_PROPERTY"; + throw invalidPluginPropertyError; + } }); return obj; } @@ -2610,6 +2856,96 @@ exports.default = _default; },{}],22:[function(require,module,exports){ "use strict"; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.maybeAsync = maybeAsync; +exports.forwardAsync = forwardAsync; +exports.isThenable = isThenable; +exports.waitFor = exports.onFirstPause = exports.isAsync = void 0; + +function _gensync() { + const data = _interopRequireDefault(require("gensync")); + + _gensync = function () { + return data; + }; + + return data; +} + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +const id = x => x; + +const runGenerator = (0, _gensync().default)(function* (item) { + return yield* item; +}); +const isAsync = (0, _gensync().default)({ + sync: () => false, + errback: cb => cb(null, true) +}); +exports.isAsync = isAsync; + +function maybeAsync(fn, message) { + return (0, _gensync().default)({ + sync(...args) { + const result = fn.apply(this, args); + if (isThenable(result)) throw new Error(message); + return result; + }, + + async(...args) { + return Promise.resolve(fn.apply(this, args)); + } + + }); +} + +const withKind = (0, _gensync().default)({ + sync: cb => cb("sync"), + async: cb => cb("async") +}); + +function forwardAsync(action, cb) { + const g = (0, _gensync().default)(action); + return withKind(kind => { + const adapted = g[kind]; + return cb(adapted); + }); +} + +const onFirstPause = (0, _gensync().default)({ + name: "onFirstPause", + arity: 2, + sync: function (item) { + return runGenerator.sync(item); + }, + errback: function (item, firstPause, cb) { + let completed = false; + runGenerator.errback(item, (err, value) => { + completed = true; + cb(err, value); + }); + + if (!completed) { + firstPause(); + } + } +}); +exports.onFirstPause = onFirstPause; +const waitFor = (0, _gensync().default)({ + sync: id, + async: id +}); +exports.waitFor = waitFor; + +function isThenable(val) { + return !!val && (typeof val === "object" || typeof val === "function") && !!val.then && typeof val.then === "function"; +} +},{"gensync":220}],23:[function(require,module,exports){ +"use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); @@ -2680,12 +3016,36 @@ Object.defineProperty(exports, "loadPartialConfig", { return _config.loadPartialConfig; } }); +Object.defineProperty(exports, "loadPartialConfigSync", { + enumerable: true, + get: function () { + return _config.loadPartialConfigSync; + } +}); +Object.defineProperty(exports, "loadPartialConfigAsync", { + enumerable: true, + get: function () { + return _config.loadPartialConfigAsync; + } +}); Object.defineProperty(exports, "loadOptions", { enumerable: true, get: function () { return _config.loadOptions; } }); +Object.defineProperty(exports, "loadOptionsSync", { + enumerable: true, + get: function () { + return _config.loadOptionsSync; + } +}); +Object.defineProperty(exports, "loadOptionsAsync", { + enumerable: true, + get: function () { + return _config.loadOptionsAsync; + } +}); Object.defineProperty(exports, "transform", { enumerable: true, get: function () { @@ -2829,7 +3189,9 @@ var _transformAst = require("./transform-ast"); var _parse = require("./parse"); -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -2848,75 +3210,396 @@ exports.OptionManager = OptionManager; function Plugin(alias) { throw new Error(`The (${alias}) Babel 5 plugin is being run with an unsupported Babel version.`); } -},{"../package.json":38,"./config":12,"./config/files":8,"./config/helpers/environment":11,"./config/item":13,"./parse":23,"./tools/build-external-helpers":24,"./transform":27,"./transform-ast":25,"./transform-file":26,"./transformation/file/file":29,"@babel/parser":71,"@babel/template":83,"@babel/traverse":92,"@babel/types":155}],23:[function(require,module,exports){ -(function (process){ +},{"../package.json":40,"./config":12,"./config/files":8,"./config/helpers/environment":11,"./config/item":13,"./parse":24,"./tools/build-external-helpers":27,"./transform":30,"./transform-ast":28,"./transform-file":29,"./transformation/file/file":32,"@babel/parser":73,"@babel/template":88,"@babel/traverse":97,"@babel/types":160}],24:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.parseSync = parseSync; -exports.parseAsync = parseAsync; -exports.parse = void 0; +exports.parseAsync = exports.parseSync = exports.parse = void 0; + +function _gensync() { + const data = _interopRequireDefault(require("gensync")); + + _gensync = function () { + return data; + }; + + return data; +} var _config = _interopRequireDefault(require("./config")); -var _normalizeFile = _interopRequireDefault(require("./transformation/normalize-file")); +var _parser = _interopRequireDefault(require("./parser")); var _normalizeOpts = _interopRequireDefault(require("./transformation/normalize-opts")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +const parseRunner = (0, _gensync().default)(function* parse(code, opts) { + const config = yield* (0, _config.default)(opts); + + if (config === null) { + return null; + } + + return yield* (0, _parser.default)(config.passes, (0, _normalizeOpts.default)(config), code); +}); + const parse = function parse(code, opts, callback) { if (typeof opts === "function") { callback = opts; opts = undefined; } - if (callback === undefined) return parseSync(code, opts); - const config = (0, _config.default)(opts); + if (callback === undefined) return parseRunner.sync(code, opts); + parseRunner.errback(code, opts, callback); +}; - if (config === null) { - return null; - } +exports.parse = parse; +const parseSync = parseRunner.sync; +exports.parseSync = parseSync; +const parseAsync = parseRunner.async; +exports.parseAsync = parseAsync; +},{"./config":12,"./parser":25,"./transformation/normalize-opts":37,"gensync":220}],25:[function(require,module,exports){ +"use strict"; - const cb = callback; - process.nextTick(() => { - let ast = null; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = parser; - try { - const cfg = (0, _config.default)(opts); - if (cfg === null) return cb(null, null); - ast = (0, _normalizeFile.default)(cfg.passes, (0, _normalizeOpts.default)(cfg), code).ast; - } catch (err) { - return cb(err); +function _parser() { + const data = require("@babel/parser"); + + _parser = function () { + return data; + }; + + return data; +} + +function _codeFrame() { + const data = require("@babel/code-frame"); + + _codeFrame = function () { + return data; + }; + + return data; +} + +var _missingPluginHelper = _interopRequireDefault(require("./util/missing-plugin-helper")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function* parser(pluginPasses, { + parserOpts, + highlightCode = true, + filename = "unknown" +}, code) { + try { + const results = []; + + for (const plugins of pluginPasses) { + for (const plugin of plugins) { + const { + parserOverride + } = plugin; + + if (parserOverride) { + const ast = parserOverride(code, parserOpts, _parser().parse); + if (ast !== undefined) results.push(ast); + } + } } - cb(null, ast); - }); -}; + if (results.length === 0) { + return (0, _parser().parse)(code, parserOpts); + } else if (results.length === 1) { + yield* []; -exports.parse = parse; + if (typeof results[0].then === "function") { + throw new Error(`You appear to be using an async parser plugin, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, you may need to upgrade ` + `your @babel/core version.`); + } + + return results[0]; + } -function parseSync(code, opts) { - const config = (0, _config.default)(opts); + throw new Error("More than one plugin attempted to override parsing."); + } catch (err) { + if (err.code === "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED") { + err.message += "\nConsider renaming the file to '.mjs', or setting sourceType:module " + "or sourceType:unambiguous in your Babel config for this file."; + } - if (config === null) { - return null; - } + const { + loc, + missingPlugin + } = err; + + if (loc) { + const codeFrame = (0, _codeFrame().codeFrameColumns)(code, { + start: { + line: loc.line, + column: loc.column + 1 + } + }, { + highlightCode + }); + + if (missingPlugin) { + err.message = `${filename}: ` + (0, _missingPluginHelper.default)(missingPlugin[0], loc, codeFrame); + } else { + err.message = `${filename}: ${err.message}\n\n` + codeFrame; + } - return (0, _normalizeFile.default)(config.passes, (0, _normalizeOpts.default)(config), code).ast; + err.code = "BABEL_PARSE_ERROR"; + } + + throw err; + } } +},{"./util/missing-plugin-helper":26,"@babel/code-frame":4,"@babel/parser":73}],26:[function(require,module,exports){ +"use strict"; -function parseAsync(code, opts) { - return new Promise((res, rej) => { - parse(code, opts, (err, result) => { - if (err == null) res(result);else rej(err); - }); - }); +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = generateMissingPluginMessage; +const pluginNameMap = { + classProperties: { + syntax: { + name: "@babel/plugin-syntax-class-properties", + url: "https://git.io/vb4yQ" + }, + transform: { + name: "@babel/plugin-proposal-class-properties", + url: "https://git.io/vb4SL" + } + }, + decorators: { + syntax: { + name: "@babel/plugin-syntax-decorators", + url: "https://git.io/vb4y9" + }, + transform: { + name: "@babel/plugin-proposal-decorators", + url: "https://git.io/vb4ST" + } + }, + doExpressions: { + syntax: { + name: "@babel/plugin-syntax-do-expressions", + url: "https://git.io/vb4yh" + }, + transform: { + name: "@babel/plugin-proposal-do-expressions", + url: "https://git.io/vb4S3" + } + }, + dynamicImport: { + syntax: { + name: "@babel/plugin-syntax-dynamic-import", + url: "https://git.io/vb4Sv" + } + }, + exportDefaultFrom: { + syntax: { + name: "@babel/plugin-syntax-export-default-from", + url: "https://git.io/vb4SO" + }, + transform: { + name: "@babel/plugin-proposal-export-default-from", + url: "https://git.io/vb4yH" + } + }, + exportNamespaceFrom: { + syntax: { + name: "@babel/plugin-syntax-export-namespace-from", + url: "https://git.io/vb4Sf" + }, + transform: { + name: "@babel/plugin-proposal-export-namespace-from", + url: "https://git.io/vb4SG" + } + }, + flow: { + syntax: { + name: "@babel/plugin-syntax-flow", + url: "https://git.io/vb4yb" + }, + transform: { + name: "@babel/plugin-transform-flow-strip-types", + url: "https://git.io/vb49g" + } + }, + functionBind: { + syntax: { + name: "@babel/plugin-syntax-function-bind", + url: "https://git.io/vb4y7" + }, + transform: { + name: "@babel/plugin-proposal-function-bind", + url: "https://git.io/vb4St" + } + }, + functionSent: { + syntax: { + name: "@babel/plugin-syntax-function-sent", + url: "https://git.io/vb4yN" + }, + transform: { + name: "@babel/plugin-proposal-function-sent", + url: "https://git.io/vb4SZ" + } + }, + importMeta: { + syntax: { + name: "@babel/plugin-syntax-import-meta", + url: "https://git.io/vbKK6" + } + }, + jsx: { + syntax: { + name: "@babel/plugin-syntax-jsx", + url: "https://git.io/vb4yA" + }, + transform: { + name: "@babel/plugin-transform-react-jsx", + url: "https://git.io/vb4yd" + } + }, + logicalAssignment: { + syntax: { + name: "@babel/plugin-syntax-logical-assignment-operators", + url: "https://git.io/vAlBp" + }, + transform: { + name: "@babel/plugin-proposal-logical-assignment-operators", + url: "https://git.io/vAlRe" + } + }, + numericSeparator: { + syntax: { + name: "@babel/plugin-syntax-numeric-separator", + url: "https://git.io/vb4Sq" + }, + transform: { + name: "@babel/plugin-proposal-numeric-separator", + url: "https://git.io/vb4yS" + } + }, + optionalChaining: { + syntax: { + name: "@babel/plugin-syntax-optional-chaining", + url: "https://git.io/vb4Sc" + }, + transform: { + name: "@babel/plugin-proposal-optional-chaining", + url: "https://git.io/vb4Sk" + } + }, + pipelineOperator: { + syntax: { + name: "@babel/plugin-syntax-pipeline-operator", + url: "https://git.io/vb4yj" + }, + transform: { + name: "@babel/plugin-proposal-pipeline-operator", + url: "https://git.io/vb4SU" + } + }, + throwExpressions: { + syntax: { + name: "@babel/plugin-syntax-throw-expressions", + url: "https://git.io/vb4SJ" + }, + transform: { + name: "@babel/plugin-proposal-throw-expressions", + url: "https://git.io/vb4yF" + } + }, + typescript: { + syntax: { + name: "@babel/plugin-syntax-typescript", + url: "https://git.io/vb4SC" + }, + transform: { + name: "@babel/plugin-transform-typescript", + url: "https://git.io/vb4Sm" + } + }, + asyncGenerators: { + syntax: { + name: "@babel/plugin-syntax-async-generators", + url: "https://git.io/vb4SY" + }, + transform: { + name: "@babel/plugin-proposal-async-generator-functions", + url: "https://git.io/vb4yp" + } + }, + nullishCoalescingOperator: { + syntax: { + name: "@babel/plugin-syntax-nullish-coalescing-operator", + url: "https://git.io/vb4yx" + }, + transform: { + name: "@babel/plugin-proposal-nullish-coalescing-operator", + url: "https://git.io/vb4Se" + } + }, + objectRestSpread: { + syntax: { + name: "@babel/plugin-syntax-object-rest-spread", + url: "https://git.io/vb4y5" + }, + transform: { + name: "@babel/plugin-proposal-object-rest-spread", + url: "https://git.io/vb4Ss" + } + }, + optionalCatchBinding: { + syntax: { + name: "@babel/plugin-syntax-optional-catch-binding", + url: "https://git.io/vb4Sn" + }, + transform: { + name: "@babel/plugin-proposal-optional-catch-binding", + url: "https://git.io/vb4SI" + } + } +}; + +const getNameURLCombination = ({ + name, + url +}) => `${name} (${url})`; + +function generateMissingPluginMessage(missingPluginName, loc, codeFrame) { + let helpMessage = `Support for the experimental syntax '${missingPluginName}' isn't currently enabled ` + `(${loc.line}:${loc.column + 1}):\n\n` + codeFrame; + const pluginInfo = pluginNameMap[missingPluginName]; + + if (pluginInfo) { + const { + syntax: syntaxPlugin, + transform: transformPlugin + } = pluginInfo; + + if (syntaxPlugin) { + if (transformPlugin) { + const transformPluginInfo = getNameURLCombination(transformPlugin); + helpMessage += `\n\nAdd ${transformPluginInfo} to the 'plugins' section of your Babel config ` + `to enable transformation.`; + } else { + const syntaxPluginInfo = getNameURLCombination(syntaxPlugin); + helpMessage += `\n\nAdd ${syntaxPluginInfo} to the 'plugins' section of your Babel config ` + `to enable parsing.`; + } + } + } + + return helpMessage; } -}).call(this,require('_process')) -},{"./config":12,"./transformation/normalize-file":33,"./transformation/normalize-opts":34,"_process":426}],24:[function(require,module,exports){ +},{}],27:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -2966,7 +3649,9 @@ function t() { 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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } const buildUmdWrapper = replacements => _template().default` (function (root, factory) { @@ -3060,16 +3745,23 @@ function _default(whitelist, outputType = "global") { return (0, _generator().default)(tree).code; } -},{"@babel/generator":52,"@babel/helpers":69,"@babel/template":83,"@babel/types":155}],25:[function(require,module,exports){ -(function (process){ +},{"@babel/generator":54,"@babel/helpers":71,"@babel/template":88,"@babel/types":160}],28:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.transformFromAstSync = transformFromAstSync; -exports.transformFromAstAsync = transformFromAstAsync; -exports.transformFromAst = void 0; +exports.transformFromAstAsync = exports.transformFromAstSync = exports.transformFromAst = void 0; + +function _gensync() { + const data = _interopRequireDefault(require("gensync")); + + _gensync = function () { + return data; + }; + + return data; +} var _config = _interopRequireDefault(require("./config")); @@ -3077,47 +3769,32 @@ var _transformation = require("./transformation"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +const transformFromAstRunner = (0, _gensync().default)(function* (ast, code, opts) { + const config = yield* (0, _config.default)(opts); + if (config === null) return null; + if (!ast) throw new Error("No AST given"); + return yield* (0, _transformation.run)(config, code, ast); +}); + const transformFromAst = function transformFromAst(ast, code, opts, callback) { if (typeof opts === "function") { callback = opts; opts = undefined; } - if (callback === undefined) return transformFromAstSync(ast, code, opts); - const cb = callback; - process.nextTick(() => { - let cfg; - - try { - cfg = (0, _config.default)(opts); - if (cfg === null) return cb(null, null); - } catch (err) { - return cb(err); - } + if (callback === undefined) { + return transformFromAstRunner.sync(ast, code, opts); + } - if (!ast) return cb(new Error("No AST given")); - (0, _transformation.runAsync)(cfg, code, ast, cb); - }); + transformFromAstRunner.errback(ast, code, opts, callback); }; exports.transformFromAst = transformFromAst; - -function transformFromAstSync(ast, code, opts) { - const config = (0, _config.default)(opts); - if (config === null) return null; - if (!ast) throw new Error("No AST given"); - return (0, _transformation.runSync)(config, code, ast); -} - -function transformFromAstAsync(ast, code, opts) { - return new Promise((res, rej) => { - transformFromAst(ast, code, opts, (err, result) => { - if (err == null) res(result);else rej(err); - }); - }); -} -}).call(this,require('_process')) -},{"./config":12,"./transformation":32,"_process":426}],26:[function(require,module,exports){ +const transformFromAstSync = transformFromAstRunner.sync; +exports.transformFromAstSync = transformFromAstSync; +const transformFromAstAsync = transformFromAstRunner.async; +exports.transformFromAstAsync = transformFromAstAsync; +},{"./config":12,"./transformation":35,"gensync":220}],29:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -3144,16 +3821,23 @@ function transformFileSync() { function transformFileAsync() { return Promise.reject(new Error("Transforming files is not supported in browsers")); } -},{}],27:[function(require,module,exports){ -(function (process){ +},{}],30:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.transformSync = transformSync; -exports.transformAsync = transformAsync; -exports.transform = void 0; +exports.transformAsync = exports.transformSync = exports.transform = void 0; + +function _gensync() { + const data = _interopRequireDefault(require("gensync")); + + _gensync = function () { + return data; + }; + + return data; +} var _config = _interopRequireDefault(require("./config")); @@ -3161,45 +3845,28 @@ var _transformation = require("./transformation"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +const transformRunner = (0, _gensync().default)(function* transform(code, opts) { + const config = yield* (0, _config.default)(opts); + if (config === null) return null; + return yield* (0, _transformation.run)(config, code); +}); + const transform = function transform(code, opts, callback) { if (typeof opts === "function") { callback = opts; opts = undefined; } - if (callback === undefined) return transformSync(code, opts); - const cb = callback; - process.nextTick(() => { - let cfg; - - try { - cfg = (0, _config.default)(opts); - if (cfg === null) return cb(null, null); - } catch (err) { - return cb(err); - } - - (0, _transformation.runAsync)(cfg, code, null, cb); - }); + if (callback === undefined) return transformRunner.sync(code, opts); + transformRunner.errback(code, opts, callback); }; exports.transform = transform; - -function transformSync(code, opts) { - const config = (0, _config.default)(opts); - if (config === null) return null; - return (0, _transformation.runSync)(config, code); -} - -function transformAsync(code, opts) { - return new Promise((res, rej) => { - transform(code, opts, (err, result) => { - if (err == null) res(result);else rej(err); - }); - }); -} -}).call(this,require('_process')) -},{"./config":12,"./transformation":32,"_process":426}],28:[function(require,module,exports){ +const transformSync = transformRunner.sync; +exports.transformSync = transformSync; +const transformAsync = transformRunner.async; +exports.transformAsync = transformAsync; +},{"./config":12,"./transformation":35,"gensync":220}],31:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -3225,11 +3892,12 @@ let LOADED_PLUGIN; function loadBlockHoistPlugin() { if (!LOADED_PLUGIN) { - const config = (0, _config.default)({ + const config = _config.default.sync({ babelrc: false, configFile: false, plugins: [blockHoistPlugin] }); + LOADED_PLUGIN = config ? config.passes[0][0] : undefined; if (!LOADED_PLUGIN) throw new Error("Assertion failure"); } @@ -3267,7 +3935,7 @@ const blockHoistPlugin = { } } }; -},{"../config":12,"lodash/sortBy":412}],29:[function(require,module,exports){ +},{"../config":12,"lodash/sortBy":418}],32:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -3327,7 +3995,9 @@ function _semver() { 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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } const errorVisitor = { enter(path, state) { @@ -3468,6 +4138,7 @@ class File { if (res) return res; } + helpers().ensure(name); const uid = this.declarations[name] = this.scope.generateUidIdentifier(name); const dependencies = {}; @@ -3501,7 +4172,6 @@ class File { buildCodeFrameError(node, msg, Error = SyntaxError) { let loc = node && (node.loc || node._loc); - msg = `${this.opts.filename}: ${msg}`; if (!loc && node) { const state = { @@ -3522,7 +4192,11 @@ class File { start: { line: loc.start.line, column: loc.start.column + 1 - } + }, + end: loc.end && loc.start.line === loc.end.line ? { + line: loc.end.line, + column: loc.end.column + 1 + } : undefined }, { highlightCode }); @@ -3534,7 +4208,7 @@ class File { } exports.default = File; -},{"@babel/code-frame":4,"@babel/helpers":69,"@babel/traverse":92,"@babel/types":155,"semver":37}],30:[function(require,module,exports){ +},{"@babel/code-frame":4,"@babel/helpers":71,"@babel/traverse":97,"@babel/types":160,"semver":39}],33:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -3596,7 +4270,7 @@ function generateCode(pluginPasses, file) { result = results[0]; if (typeof result.then === "function") { - throw new Error(`You appear to be using an async parser plugin, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, ` + `you may need to upgrade your @babel/core version.`); + throw new Error(`You appear to be using an async codegen plugin, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, ` + `you may need to upgrade your @babel/core version.`); } } else { throw new Error("More than one plugin attempted to override codegen."); @@ -3624,7 +4298,7 @@ function generateCode(pluginPasses, file) { outputMap }; } -},{"./merge-map":31,"@babel/generator":52,"convert-source-map":205}],31:[function(require,module,exports){ +},{"./merge-map":34,"@babel/generator":54,"convert-source-map":210}],34:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -3649,11 +4323,9 @@ function mergeSourceMap(inputMap, map) { const output = buildMappingData(map); const mergedGenerator = new (_sourceMap().default.SourceMapGenerator)(); - for (const _ref of input.sources) { - const { - source - } = _ref; - + for (const { + source + } of input.sources) { if (typeof source.content === "string") { mergedGenerator.setSourceContent(source.path, source.content); } @@ -3722,11 +4394,9 @@ function makeMappingKey(item) { function eachOverlappingGeneratedOutputRange(outputFile, inputGeneratedRange, callback) { const overlappingOriginal = filterApplicableOriginalRanges(outputFile, inputGeneratedRange); - for (const _ref2 of overlappingOriginal) { - const { - generated - } = _ref2; - + for (const { + generated + } of overlappingOriginal) { for (const item of generated) { callback(item); } @@ -3752,18 +4422,14 @@ function filterApplicableOriginalRanges({ } function eachInputGeneratedRange(map, callback) { - for (const _ref3 of map.sources) { - const { - source, - mappings - } = _ref3; - - for (const _ref4 of mappings) { - const { - original, - generated - } = _ref4; - + for (const { + source, + mappings + } of map.sources) { + for (const { + original, + generated + } of mappings) { for (const item of generated) { callback(item, original, source); } @@ -3880,14 +4546,13 @@ function filterSortedArray(array, callback) { return results; } -},{"source-map":496}],32:[function(require,module,exports){ +},{"source-map":513}],35:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.runAsync = runAsync; -exports.runSync = runSync; +exports.run = run; function _traverse() { const data = _interopRequireDefault(require("@babel/traverse")); @@ -3911,26 +4576,45 @@ var _generate = _interopRequireDefault(require("./file/generate")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -function runAsync(config, code, ast, callback) { - let result; +function* run(config, code, ast) { + const file = yield* (0, _normalizeFile.default)(config.passes, (0, _normalizeOpts.default)(config), code, ast); + const opts = file.opts; try { - result = runSync(config, code, ast); - } catch (err) { - return callback(err); + yield* transformFile(file, config.passes); + } catch (e) { + var _opts$filename; + + e.message = `${(_opts$filename = opts.filename) != null ? _opts$filename : "unknown"}: ${e.message}`; + + if (!e.code) { + e.code = "BABEL_TRANSFORM_ERROR"; + } + + throw e; } - return callback(null, result); -} + let outputCode, outputMap; + + try { + if (opts.code !== false) { + ({ + outputCode, + outputMap + } = (0, _generate.default)(config.passes, file)); + } + } catch (e) { + var _opts$filename2; + + e.message = `${(_opts$filename2 = opts.filename) != null ? _opts$filename2 : "unknown"}: ${e.message}`; + + if (!e.code) { + e.code = "BABEL_GENERATE_ERROR"; + } + + throw e; + } -function runSync(config, code, ast) { - const file = (0, _normalizeFile.default)(config.passes, (0, _normalizeOpts.default)(config), code, ast); - transformFile(file, config.passes); - const opts = file.opts; - const { - outputCode, - outputMap - } = opts.code !== false ? (0, _generate.default)(config.passes, file) : {}; return { metadata: file.metadata, options: opts, @@ -3941,7 +4625,7 @@ function runSync(config, code, ast) { }; } -function transformFile(file, pluginPasses) { +function* transformFile(file, pluginPasses) { for (const pluginPairs of pluginPasses) { const passPairs = []; const passes = []; @@ -3959,9 +4643,10 @@ function transformFile(file, pluginPasses) { if (fn) { const result = fn.call(pass, file); + yield* []; if (isThenable(result)) { - throw new Error(`You appear to be using an plugin with an async .pre, ` + `which your current version of Babel does not support.` + `If you're using a published plugin, you may need to upgrade ` + `your @babel/core version.`); + throw new Error(`You appear to be using an plugin with an async .pre, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, you may need to upgrade ` + `your @babel/core version.`); } } } @@ -3975,9 +4660,10 @@ function transformFile(file, pluginPasses) { if (fn) { const result = fn.call(pass, file); + yield* []; if (isThenable(result)) { - throw new Error(`You appear to be using an plugin with an async .post, ` + `which your current version of Babel does not support.` + `If you're using a published plugin, you may need to upgrade ` + `your @babel/core version.`); + throw new Error(`You appear to be using an plugin with an async .post, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, you may need to upgrade ` + `your @babel/core version.`); } } } @@ -3987,7 +4673,7 @@ function transformFile(file, pluginPasses) { function isThenable(val) { return !!val && (typeof val === "object" || typeof val === "function") && !!val.then && typeof val.then === "function"; } -},{"./block-hoist-plugin":28,"./file/generate":30,"./normalize-file":33,"./normalize-opts":34,"./plugin-pass":35,"@babel/traverse":92}],33:[function(require,module,exports){ +},{"./block-hoist-plugin":31,"./file/generate":33,"./normalize-file":36,"./normalize-opts":37,"./plugin-pass":38,"@babel/traverse":97}],36:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -3995,6 +4681,16 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = normalizeFile; +function _fs() { + const data = _interopRequireDefault(require("fs")); + + _fs = function () { + return data; + }; + + return data; +} + function _path() { const data = _interopRequireDefault(require("path")); @@ -4045,38 +4741,34 @@ function _convertSourceMap() { return data; } -function _parser() { - const data = require("@babel/parser"); - - _parser = function () { - return data; - }; - - return data; -} - -function _codeFrame() { - const data = require("@babel/code-frame"); - - _codeFrame = function () { - return data; - }; - - return data; -} - var _file = _interopRequireDefault(require("./file/file")); -var _missingPluginHelper = _interopRequireDefault(require("./util/missing-plugin-helper")); +var _parser = _interopRequireDefault(require("../parser")); -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const debug = (0, _debug().default)("babel:transform:file"); +const LARGE_INPUT_SOURCEMAP_THRESHOLD = 1000000; -function normalizeFile(pluginPasses, options, code, ast) { +function* normalizeFile(pluginPasses, options, code, ast) { code = `${code || ""}`; + + if (ast) { + if (ast.type === "Program") { + ast = t().file(ast, [], []); + } else if (ast.type !== "File") { + throw new Error("AST root must be a Program or File node"); + } + + ast = (0, _cloneDeep().default)(ast); + } else { + ast = yield* (0, _parser.default)(pluginPasses, options, code); + } + let inputMap = null; if (options.inputSourceMap !== false) { @@ -4085,49 +4777,40 @@ function normalizeFile(pluginPasses, options, code, ast) { } if (!inputMap) { - try { - inputMap = _convertSourceMap().default.fromSource(code); + const lastComment = extractComments(INLINE_SOURCEMAP_REGEX, ast); - if (inputMap) { - code = _convertSourceMap().default.removeComments(code); + if (lastComment) { + try { + inputMap = _convertSourceMap().default.fromComment(lastComment); + } catch (err) { + debug("discarding unknown inline input sourcemap", err); } - } catch (err) { - debug("discarding unknown inline input sourcemap", err); - code = _convertSourceMap().default.removeComments(code); } } if (!inputMap) { - if (typeof options.filename === "string") { + const lastComment = extractComments(EXTERNAL_SOURCEMAP_REGEX, ast); + + if (typeof options.filename === "string" && lastComment) { try { - inputMap = _convertSourceMap().default.fromMapFileSource(code, _path().default.dirname(options.filename)); + const match = EXTERNAL_SOURCEMAP_REGEX.exec(lastComment); - if (inputMap) { - code = _convertSourceMap().default.removeMapFileComments(code); + const inputMapContent = _fs().default.readFileSync(_path().default.resolve(_path().default.dirname(options.filename), match[1])); + + if (inputMapContent.length > LARGE_INPUT_SOURCEMAP_THRESHOLD) { + debug("skip merging input map > 1 MB"); + } else { + inputMap = _convertSourceMap().default.fromJSON(inputMapContent); } } catch (err) { debug("discarding unknown file input sourcemap", err); - code = _convertSourceMap().default.removeMapFileComments(code); } - } else { + } else if (lastComment) { debug("discarding un-loadable file input sourcemap"); - code = _convertSourceMap().default.removeMapFileComments(code); } } } - if (ast) { - if (ast.type === "Program") { - ast = t().file(ast, [], []); - } else if (ast.type !== "File") { - throw new Error("AST root must be a Program or File node"); - } - - ast = (0, _cloneDeep().default)(ast); - } else { - ast = parser(pluginPasses, options, code); - } - return new _file.default(options, { code, ast, @@ -4135,71 +4818,36 @@ function normalizeFile(pluginPasses, options, code, ast) { }); } -function parser(pluginPasses, { - parserOpts, - highlightCode = true, - filename = "unknown" -}, code) { - try { - const results = []; - - for (const plugins of pluginPasses) { - for (const plugin of plugins) { - const { - parserOverride - } = plugin; - - if (parserOverride) { - const ast = parserOverride(code, parserOpts, _parser().parse); - if (ast !== undefined) results.push(ast); - } - } - } +const INLINE_SOURCEMAP_REGEX = /^[@#]\s+sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+?;)?base64,(?:.*)$/; +const EXTERNAL_SOURCEMAP_REGEX = /^[@#][ \t]+sourceMappingURL=([^\s'"`]+)[ \t]*$/; - if (results.length === 0) { - return (0, _parser().parse)(code, parserOpts); - } else if (results.length === 1) { - if (typeof results[0].then === "function") { - throw new Error(`You appear to be using an async codegen plugin, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, you may need to upgrade ` + `your @babel/core version.`); +function extractCommentsFromList(regex, comments, lastComment) { + if (comments) { + comments = comments.filter(({ + value + }) => { + if (regex.test(value)) { + lastComment = value; + return false; } - return results[0]; - } - - throw new Error("More than one plugin attempted to override parsing."); - } catch (err) { - if (err.code === "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED") { - err.message += "\nConsider renaming the file to '.mjs', or setting sourceType:module " + "or sourceType:unambiguous in your Babel config for this file."; - } - - const { - loc, - missingPlugin - } = err; - - if (loc) { - const codeFrame = (0, _codeFrame().codeFrameColumns)(code, { - start: { - line: loc.line, - column: loc.column + 1 - } - }, { - highlightCode - }); - - if (missingPlugin) { - err.message = `${filename}: ` + (0, _missingPluginHelper.default)(missingPlugin[0], loc, codeFrame); - } else { - err.message = `${filename}: ${err.message}\n\n` + codeFrame; - } + return true; + }); + } - err.code = "BABEL_PARSE_ERROR"; - } + return [comments, lastComment]; +} - throw err; - } +function extractComments(regex, ast) { + let lastComment = null; + t().traverseFast(ast, node => { + [node.leadingComments, lastComment] = extractCommentsFromList(regex, node.leadingComments, lastComment); + [node.innerComments, lastComment] = extractCommentsFromList(regex, node.innerComments, lastComment); + [node.trailingComments, lastComment] = extractCommentsFromList(regex, node.trailingComments, lastComment); + }); + return lastComment; } -},{"./file/file":29,"./util/missing-plugin-helper":36,"@babel/code-frame":4,"@babel/parser":71,"@babel/types":155,"convert-source-map":205,"debug":207,"lodash/cloneDeep":379,"path":423}],34:[function(require,module,exports){ +},{"../parser":25,"./file/file":32,"@babel/types":160,"convert-source-map":210,"debug":212,"fs":202,"lodash/cloneDeep":385,"path":430}],37:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -4265,7 +4913,7 @@ function normalizeOptions(config) { return options; } -},{"path":423}],35:[function(require,module,exports){ +},{"path":430}],38:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -4314,247 +4962,7 @@ class PluginPass { } exports.default = PluginPass; -},{}],36:[function(require,module,exports){ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = generateMissingPluginMessage; -const pluginNameMap = { - classProperties: { - syntax: { - name: "@babel/plugin-syntax-class-properties", - url: "https://git.io/vb4yQ" - }, - transform: { - name: "@babel/plugin-proposal-class-properties", - url: "https://git.io/vb4SL" - } - }, - decorators: { - syntax: { - name: "@babel/plugin-syntax-decorators", - url: "https://git.io/vb4y9" - }, - transform: { - name: "@babel/plugin-proposal-decorators", - url: "https://git.io/vb4ST" - } - }, - doExpressions: { - syntax: { - name: "@babel/plugin-syntax-do-expressions", - url: "https://git.io/vb4yh" - }, - transform: { - name: "@babel/plugin-proposal-do-expressions", - url: "https://git.io/vb4S3" - } - }, - dynamicImport: { - syntax: { - name: "@babel/plugin-syntax-dynamic-import", - url: "https://git.io/vb4Sv" - } - }, - exportDefaultFrom: { - syntax: { - name: "@babel/plugin-syntax-export-default-from", - url: "https://git.io/vb4SO" - }, - transform: { - name: "@babel/plugin-proposal-export-default-from", - url: "https://git.io/vb4yH" - } - }, - exportNamespaceFrom: { - syntax: { - name: "@babel/plugin-syntax-export-namespace-from", - url: "https://git.io/vb4Sf" - }, - transform: { - name: "@babel/plugin-proposal-export-namespace-from", - url: "https://git.io/vb4SG" - } - }, - flow: { - syntax: { - name: "@babel/plugin-syntax-flow", - url: "https://git.io/vb4yb" - }, - transform: { - name: "@babel/plugin-transform-flow-strip-types", - url: "https://git.io/vb49g" - } - }, - functionBind: { - syntax: { - name: "@babel/plugin-syntax-function-bind", - url: "https://git.io/vb4y7" - }, - transform: { - name: "@babel/plugin-proposal-function-bind", - url: "https://git.io/vb4St" - } - }, - functionSent: { - syntax: { - name: "@babel/plugin-syntax-function-sent", - url: "https://git.io/vb4yN" - }, - transform: { - name: "@babel/plugin-proposal-function-sent", - url: "https://git.io/vb4SZ" - } - }, - importMeta: { - syntax: { - name: "@babel/plugin-syntax-import-meta", - url: "https://git.io/vbKK6" - } - }, - jsx: { - syntax: { - name: "@babel/plugin-syntax-jsx", - url: "https://git.io/vb4yA" - }, - transform: { - name: "@babel/plugin-transform-react-jsx", - url: "https://git.io/vb4yd" - } - }, - logicalAssignment: { - syntax: { - name: "@babel/plugin-syntax-logical-assignment-operators", - url: "https://git.io/vAlBp" - }, - transform: { - name: "@babel/plugin-proposal-logical-assignment-operators", - url: "https://git.io/vAlRe" - } - }, - nullishCoalescingOperator: { - syntax: { - name: "@babel/plugin-syntax-nullish-coalescing-operator", - url: "https://git.io/vb4yx" - }, - transform: { - name: "@babel/plugin-proposal-nullish-coalescing-operator", - url: "https://git.io/vb4Se" - } - }, - numericSeparator: { - syntax: { - name: "@babel/plugin-syntax-numeric-separator", - url: "https://git.io/vb4Sq" - }, - transform: { - name: "@babel/plugin-proposal-numeric-separator", - url: "https://git.io/vb4yS" - } - }, - optionalChaining: { - syntax: { - name: "@babel/plugin-syntax-optional-chaining", - url: "https://git.io/vb4Sc" - }, - transform: { - name: "@babel/plugin-proposal-optional-chaining", - url: "https://git.io/vb4Sk" - } - }, - pipelineOperator: { - syntax: { - name: "@babel/plugin-syntax-pipeline-operator", - url: "https://git.io/vb4yj" - }, - transform: { - name: "@babel/plugin-proposal-pipeline-operator", - url: "https://git.io/vb4SU" - } - }, - throwExpressions: { - syntax: { - name: "@babel/plugin-syntax-throw-expressions", - url: "https://git.io/vb4SJ" - }, - transform: { - name: "@babel/plugin-proposal-throw-expressions", - url: "https://git.io/vb4yF" - } - }, - typescript: { - syntax: { - name: "@babel/plugin-syntax-typescript", - url: "https://git.io/vb4SC" - }, - transform: { - name: "@babel/plugin-transform-typescript", - url: "https://git.io/vb4Sm" - } - }, - asyncGenerators: { - syntax: { - name: "@babel/plugin-syntax-async-generators", - url: "https://git.io/vb4SY" - }, - transform: { - name: "@babel/plugin-proposal-async-generator-functions", - url: "https://git.io/vb4yp" - } - }, - objectRestSpread: { - syntax: { - name: "@babel/plugin-syntax-object-rest-spread", - url: "https://git.io/vb4y5" - }, - transform: { - name: "@babel/plugin-proposal-object-rest-spread", - url: "https://git.io/vb4Ss" - } - }, - optionalCatchBinding: { - syntax: { - name: "@babel/plugin-syntax-optional-catch-binding", - url: "https://git.io/vb4Sn" - }, - transform: { - name: "@babel/plugin-proposal-optional-catch-binding", - url: "https://git.io/vb4SI" - } - } -}; - -const getNameURLCombination = ({ - name, - url -}) => `${name} (${url})`; - -function generateMissingPluginMessage(missingPluginName, loc, codeFrame) { - let helpMessage = `Support for the experimental syntax '${missingPluginName}' isn't currently enabled ` + `(${loc.line}:${loc.column + 1}):\n\n` + codeFrame; - const pluginInfo = pluginNameMap[missingPluginName]; - - if (pluginInfo) { - const { - syntax: syntaxPlugin, - transform: transformPlugin - } = pluginInfo; - - if (syntaxPlugin) { - if (transformPlugin) { - const transformPluginInfo = getNameURLCombination(transformPlugin); - helpMessage += `\n\nAdd ${transformPluginInfo} to the 'plugins' section of your Babel config ` + `to enable transformation.`; - } else { - const syntaxPluginInfo = getNameURLCombination(syntaxPlugin); - helpMessage += `\n\nAdd ${syntaxPluginInfo} to the 'plugins' section of your Babel config ` + `to enable parsing.`; - } - } - } - - return helpMessage; -} -},{}],37:[function(require,module,exports){ +},{}],39:[function(require,module,exports){ (function (process){ exports = module.exports = SemVer @@ -6041,31 +6449,31 @@ function coerce (version) { } }).call(this,require('_process')) -},{"_process":426}],38:[function(require,module,exports){ +},{"_process":433}],40:[function(require,module,exports){ module.exports={ - "_from": "@babel/core@^7.4.4", - "_id": "@babel/core@7.4.4", + "_from": "@babel/core@^7.8.4", + "_id": "@babel/core@7.8.4", "_inBundle": false, - "_integrity": "sha512-lQgGX3FPRgbz2SKmhMtYgJvVzGZrmjaF4apZ2bLwofAKiSjxU0drPh4S/VasyYXwaTs+A1gvQ45BN8SQJzHsQQ==", + "_integrity": "sha512-0LiLrB2PwrVI+a2/IEskBopDYSd8BCb3rOvH7D5tzoWd696TBEduBvuLVm4Nx6rltrLZqvI3MCalB2K2aVzQjA==", "_location": "/@babel/core", "_phantomChildren": {}, "_requested": { "type": "range", "registry": true, - "raw": "@babel/core@^7.4.4", + "raw": "@babel/core@^7.8.4", "name": "@babel/core", "escapedName": "@babel%2fcore", "scope": "@babel", - "rawSpec": "^7.4.4", + "rawSpec": "^7.8.4", "saveSpec": null, - "fetchSpec": "^7.4.4" + "fetchSpec": "^7.8.4" }, "_requiredBy": [ "/" ], - "_resolved": "https://registry.npmjs.org/@babel/core/-/core-7.4.4.tgz", - "_shasum": "84055750b05fcd50f9915a826b44fa347a825250", - "_spec": "@babel/core@^7.4.4", + "_resolved": "https://registry.npmjs.org/@babel/core/-/core-7.8.4.tgz", + "_shasum": "d496799e5c12195b3602d0fddd77294e3e38e80e", + "_spec": "@babel/core@^7.8.4", "_where": "/Users/ben/dev/regenerator", "author": { "name": "Sebastian McKenzie", @@ -6073,21 +6481,24 @@ module.exports={ }, "browser": { "./lib/config/files/index.js": "./lib/config/files/index-browser.js", - "./lib/transform-file.js": "./lib/transform-file-browser.js" + "./lib/transform-file.js": "./lib/transform-file-browser.js", + "./src/config/files/index.js": "./src/config/files/index-browser.js", + "./src/transform-file.js": "./src/transform-file-browser.js" }, "bundleDependencies": false, "dependencies": { - "@babel/code-frame": "^7.0.0", - "@babel/generator": "^7.4.4", - "@babel/helpers": "^7.4.4", - "@babel/parser": "^7.4.4", - "@babel/template": "^7.4.4", - "@babel/traverse": "^7.4.4", - "@babel/types": "^7.4.4", - "convert-source-map": "^1.1.0", + "@babel/code-frame": "^7.8.3", + "@babel/generator": "^7.8.4", + "@babel/helpers": "^7.8.4", + "@babel/parser": "^7.8.4", + "@babel/template": "^7.8.3", + "@babel/traverse": "^7.8.4", + "@babel/types": "^7.8.3", + "convert-source-map": "^1.7.0", "debug": "^4.1.0", + "gensync": "^1.0.0-beta.1", "json5": "^2.1.0", - "lodash": "^4.17.11", + "lodash": "^4.17.13", "resolve": "^1.3.2", "semver": "^5.4.1", "source-map": "^0.5.0" @@ -6095,13 +6506,16 @@ module.exports={ "deprecated": false, "description": "Babel compiler core.", "devDependencies": { - "@babel/helper-transform-fixture-test-runner": "^7.4.4", - "@babel/register": "^7.4.4" + "@babel/helper-transform-fixture-test-runner": "^7.8.3" }, "engines": { "node": ">=6.9.0" }, - "gitHead": "2c88694388831b1e5b88e4bbed6781eb2be1edba", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + }, + "gitHead": "5c2e6bc07fed3d28801d93168622c99ae622653a", "homepage": "https://babeljs.io/", "keywords": [ "6to5", @@ -6128,29 +6542,16 @@ module.exports={ "type": "git", "url": "https://github.com/babel/babel/tree/master/packages/babel-core" }, - "version": "7.4.4" + "version": "7.8.4" } -},{}],39:[function(require,module,exports){ +},{}],41:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; - -function _trimRight() { - const data = _interopRequireDefault(require("trim-right")); - - _trimRight = function () { - return data; - }; - - return data; -} - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - const SPACES_RE = /^[ \t]+$/; class Buffer { @@ -6178,7 +6579,7 @@ class Buffer { const map = this._map; const result = { - code: (0, _trimRight().default)(this._buf.join("")), + code: this._buf.join("").trimRight(), map: null, rawMappings: map && map.getRawMappings() }; @@ -6389,7 +6790,7 @@ class Buffer { } exports.default = Buffer; -},{"trim-right":502}],40:[function(require,module,exports){ +},{}],42:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -6487,7 +6888,7 @@ function Placeholder(node) { this.semicolon(); } } -},{}],41:[function(require,module,exports){ +},{}],43:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -6501,20 +6902,14 @@ exports.ClassMethod = ClassMethod; exports.ClassPrivateMethod = ClassPrivateMethod; exports._classMethodHead = _classMethodHead; -function t() { - const data = _interopRequireWildcard(require("@babel/types")); - - t = function () { - return data; - }; +var t = _interopRequireWildcard(require("@babel/types")); - return data; -} +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function ClassDeclaration(node, parent) { - if (!this.format.decoratorsBeforeExport || !t().isExportDefaultDeclaration(parent) && !t().isExportNamedDeclaration(parent)) { + if (!this.format.decoratorsBeforeExport || !t.isExportDefaultDeclaration(parent) && !t.isExportNamedDeclaration(parent)) { this.printJoin(node.decorators, node); } @@ -6574,26 +6969,7 @@ function ClassBody(node) { function ClassProperty(node) { this.printJoin(node.decorators, node); - - if (node.accessibility) { - this.word(node.accessibility); - this.space(); - } - - if (node.static) { - this.word("static"); - this.space(); - } - - if (node.abstract) { - this.word("abstract"); - this.space(); - } - - if (node.readonly) { - this.word("readonly"); - this.space(); - } + this.tsPrintClassMemberModifiers(node, true); if (node.computed) { this.token("["); @@ -6660,25 +7036,11 @@ function ClassPrivateMethod(node) { function _classMethodHead(node) { this.printJoin(node.decorators, node); - - if (node.accessibility) { - this.word(node.accessibility); - this.space(); - } - - if (node.abstract) { - this.word("abstract"); - this.space(); - } - - if (node.static) { - this.word("static"); - this.space(); - } + this.tsPrintClassMemberModifiers(node, false); this._methodHead(node); } -},{"@babel/types":155}],42:[function(require,module,exports){ +},{"@babel/types":160}],44:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -6706,21 +7068,16 @@ exports.BindExpression = BindExpression; exports.MemberExpression = MemberExpression; exports.MetaProperty = MetaProperty; exports.PrivateName = PrivateName; +exports.V8IntrinsicIdentifier = V8IntrinsicIdentifier; exports.AwaitExpression = exports.YieldExpression = void 0; -function t() { - const data = _interopRequireWildcard(require("@babel/types")); - - t = function () { - return data; - }; - - return data; -} +var t = _interopRequireWildcard(require("@babel/types")); var n = _interopRequireWildcard(require("../node")); -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function UnaryExpression(node) { if (node.operator === "void" || node.operator === "delete" || node.operator === "typeof" || node.operator === "throw") { @@ -6774,9 +7131,9 @@ function NewExpression(node, parent) { this.space(); this.print(node.callee, node); - if (this.format.minified && node.arguments.length === 0 && !node.optional && !t().isCallExpression(parent, { + if (this.format.minified && node.arguments.length === 0 && !node.optional && !t.isCallExpression(parent, { callee: node - }) && !t().isMemberExpression(parent) && !t().isNewExpression(parent)) { + }) && !t.isMemberExpression(parent) && !t.isNewExpression(parent)) { return; } @@ -6813,13 +7170,13 @@ function Decorator(node) { function OptionalMemberExpression(node) { this.print(node.object, node); - if (!node.computed && t().isMemberExpression(node.property)) { + if (!node.computed && t.isMemberExpression(node.property)) { throw new TypeError("Got a MemberExpression for MemberExpression property"); } let computed = node.computed; - if (t().isLiteral(node.property) && typeof node.property.value === "number") { + if (t.isLiteral(node.property) && typeof node.property.value === "number") { computed = true; } @@ -6941,13 +7298,13 @@ function BindExpression(node) { function MemberExpression(node) { this.print(node.object, node); - if (!node.computed && t().isMemberExpression(node.property)) { + if (!node.computed && t.isMemberExpression(node.property)) { throw new TypeError("Got a MemberExpression for MemberExpression property"); } let computed = node.computed; - if (t().isLiteral(node.property) && typeof node.property.value === "number") { + if (t.isLiteral(node.property) && typeof node.property.value === "number") { computed = true; } @@ -6971,7 +7328,12 @@ function PrivateName(node) { this.token("#"); this.print(node.id, node); } -},{"../node":53,"@babel/types":155}],43:[function(require,module,exports){ + +function V8IntrinsicIdentifier(node) { + this.token("%"); + this.word(node.name); +} +},{"../node":55,"@babel/types":160}],45:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -6994,6 +7356,15 @@ exports.DeclareOpaqueType = DeclareOpaqueType; exports.DeclareVariable = DeclareVariable; exports.DeclareExportDeclaration = DeclareExportDeclaration; exports.DeclareExportAllDeclaration = DeclareExportAllDeclaration; +exports.EnumDeclaration = EnumDeclaration; +exports.EnumBooleanBody = EnumBooleanBody; +exports.EnumNumberBody = EnumNumberBody; +exports.EnumStringBody = EnumStringBody; +exports.EnumSymbolBody = EnumSymbolBody; +exports.EnumDefaultedMember = EnumDefaultedMember; +exports.EnumBooleanMember = EnumBooleanMember; +exports.EnumNumberMember = EnumNumberMember; +exports.EnumStringMember = EnumStringMember; exports.ExistsTypeAnnotation = ExistsTypeAnnotation; exports.FunctionTypeAnnotation = FunctionTypeAnnotation; exports.FunctionTypeParam = FunctionTypeParam; @@ -7040,21 +7411,15 @@ Object.defineProperty(exports, "StringLiteralTypeAnnotation", { } }); -function t() { - const data = _interopRequireWildcard(require("@babel/types")); - - t = function () { - return data; - }; - - return data; -} +var t = _interopRequireWildcard(require("@babel/types")); var _modules = require("./modules"); var _types2 = require("./types"); -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function AnyTypeAnnotation() { this.word("any"); @@ -7079,7 +7444,7 @@ function NullLiteralTypeAnnotation() { } function DeclareClass(node, parent) { - if (!t().isDeclareExportDeclaration(parent)) { + if (!t.isDeclareExportDeclaration(parent)) { this.word("declare"); this.space(); } @@ -7091,7 +7456,7 @@ function DeclareClass(node, parent) { } function DeclareFunction(node, parent) { - if (!t().isDeclareExportDeclaration(parent)) { + if (!t.isDeclareExportDeclaration(parent)) { this.word("declare"); this.space(); } @@ -7154,7 +7519,7 @@ function DeclareTypeAlias(node) { } function DeclareOpaqueType(node, parent) { - if (!t().isDeclareExportDeclaration(parent)) { + if (!t.isDeclareExportDeclaration(parent)) { this.word("declare"); this.space(); } @@ -7163,7 +7528,7 @@ function DeclareOpaqueType(node, parent) { } function DeclareVariable(node, parent) { - if (!t().isDeclareExportDeclaration(parent)) { + if (!t.isDeclareExportDeclaration(parent)) { this.word("declare"); this.space(); } @@ -7196,11 +7561,112 @@ function DeclareExportAllDeclaration() { _modules.ExportAllDeclaration.apply(this, arguments); } +function EnumDeclaration(node) { + const { + id, + body + } = node; + this.word("enum"); + this.space(); + this.print(id, node); + this.print(body, node); +} + +function enumExplicitType(context, name, hasExplicitType) { + if (hasExplicitType) { + context.space(); + context.word("of"); + context.space(); + context.word(name); + } + + context.space(); +} + +function enumBody(context, node) { + const { + members + } = node; + context.token("{"); + context.indent(); + context.newline(); + + for (const member of members) { + context.print(member, node); + context.newline(); + } + + context.dedent(); + context.token("}"); +} + +function EnumBooleanBody(node) { + const { + explicitType + } = node; + enumExplicitType(this, "boolean", explicitType); + enumBody(this, node); +} + +function EnumNumberBody(node) { + const { + explicitType + } = node; + enumExplicitType(this, "number", explicitType); + enumBody(this, node); +} + +function EnumStringBody(node) { + const { + explicitType + } = node; + enumExplicitType(this, "string", explicitType); + enumBody(this, node); +} + +function EnumSymbolBody(node) { + enumExplicitType(this, "symbol", true); + enumBody(this, node); +} + +function EnumDefaultedMember(node) { + const { + id + } = node; + this.print(id, node); + this.token(","); +} + +function enumInitializedMember(context, node) { + const { + id, + init + } = node; + context.print(id, node); + context.space(); + context.token("="); + context.space(); + context.print(init, node); + context.token(","); +} + +function EnumBooleanMember(node) { + enumInitializedMember(this, node); +} + +function EnumNumberMember(node) { + enumInitializedMember(this, node); +} + +function EnumStringMember(node) { + enumInitializedMember(this, node); +} + function FlowExportDeclaration(node) { if (node.declaration) { const declar = node.declaration; this.print(declar, node); - if (!t().isStatement(declar)) this.semicolon(); + if (!t.isStatement(declar)) this.semicolon(); } else { this.token("{"); @@ -7466,7 +7932,7 @@ function ObjectTypeAnnotation(node) { indent: true, statement: true, iterator: () => { - if (props.length !== 1) { + if (props.length !== 1 || node.inexact) { this.token(","); this.space(); } @@ -7475,6 +7941,17 @@ function ObjectTypeAnnotation(node) { this.space(); } + if (node.inexact) { + this.indent(); + this.token("..."); + + if (props.length) { + this.newline(); + } + + this.dedent(); + } + if (node.exact) { this.token("|}"); } else { @@ -7600,7 +8077,7 @@ function Variance(node) { function VoidTypeAnnotation() { this.word("void"); } -},{"./modules":47,"./types":50,"@babel/types":155}],44:[function(require,module,exports){ +},{"./modules":49,"./types":52,"@babel/types":160}],46:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -7738,7 +8215,7 @@ Object.keys(_typescript).forEach(function (key) { } }); }); -},{"./base":40,"./classes":41,"./expressions":42,"./flow":43,"./jsx":45,"./methods":46,"./modules":47,"./statements":48,"./template-literals":49,"./types":50,"./typescript":51}],45:[function(require,module,exports){ +},{"./base":42,"./classes":43,"./expressions":44,"./flow":45,"./jsx":47,"./methods":48,"./modules":49,"./statements":50,"./template-literals":51,"./types":52,"./typescript":53}],47:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -7884,7 +8361,7 @@ function JSXClosingFragment() { this.token(""); } -},{}],46:[function(require,module,exports){ +},{}],48:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -7899,17 +8376,11 @@ exports._functionHead = _functionHead; exports.FunctionDeclaration = exports.FunctionExpression = FunctionExpression; exports.ArrowFunctionExpression = ArrowFunctionExpression; -function t() { - const data = _interopRequireWildcard(require("@babel/types")); - - t = function () { - return data; - }; +var t = _interopRequireWildcard(require("@babel/types")); - return data; -} +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _params(node) { this.print(node.typeParameters, node); @@ -8019,7 +8490,7 @@ function ArrowFunctionExpression(node) { const firstParam = node.params[0]; - if (node.params.length === 1 && t().isIdentifier(firstParam) && !hasTypes(node, firstParam)) { + if (node.params.length === 1 && t.isIdentifier(firstParam) && !hasTypes(node, firstParam)) { if (this.format.retainLines && node.loc && node.body.loc && node.loc.start.line < node.body.loc.start.line) { this.token("("); @@ -8052,7 +8523,7 @@ function ArrowFunctionExpression(node) { function hasTypes(node, param) { return node.typeParameters || node.returnType || param.typeAnnotation || param.optional || param.trailingComments; } -},{"@babel/types":155}],47:[function(require,module,exports){ +},{"@babel/types":160}],49:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -8069,17 +8540,11 @@ exports.ExportDefaultDeclaration = ExportDefaultDeclaration; exports.ImportDeclaration = ImportDeclaration; exports.ImportNamespaceSpecifier = ImportNamespaceSpecifier; -function t() { - const data = _interopRequireWildcard(require("@babel/types")); - - t = function () { - return data; - }; +var t = _interopRequireWildcard(require("@babel/types")); - return data; -} +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function ImportSpecifier(node) { if (node.importKind === "type" || node.importKind === "typeof") { @@ -8142,7 +8607,7 @@ function ExportAllDeclaration(node) { } function ExportNamedDeclaration(node) { - if (this.format.decoratorsBeforeExport && t().isClassDeclaration(node.declaration)) { + if (this.format.decoratorsBeforeExport && t.isClassDeclaration(node.declaration)) { this.printJoin(node.declaration.decorators, node); } @@ -8152,7 +8617,7 @@ function ExportNamedDeclaration(node) { } function ExportDefaultDeclaration(node) { - if (this.format.decoratorsBeforeExport && t().isClassDeclaration(node.declaration)) { + if (this.format.decoratorsBeforeExport && t.isClassDeclaration(node.declaration)) { this.printJoin(node.declaration.decorators, node); } @@ -8167,7 +8632,7 @@ function ExportDeclaration(node) { if (node.declaration) { const declar = node.declaration; this.print(declar, node); - if (!t().isStatement(declar)) this.semicolon(); + if (!t.isStatement(declar)) this.semicolon(); } else { if (node.exportKind === "type") { this.word("type"); @@ -8180,7 +8645,7 @@ function ExportDeclaration(node) { while (true) { const first = specifiers[0]; - if (t().isExportDefaultSpecifier(first) || t().isExportNamespaceSpecifier(first)) { + if (t.isExportDefaultSpecifier(first) || t.isExportNamespaceSpecifier(first)) { hasSpecial = true; this.print(specifiers.shift(), node); @@ -8231,7 +8696,7 @@ function ImportDeclaration(node) { while (true) { const first = specifiers[0]; - if (t().isImportDefaultSpecifier(first) || t().isImportNamespaceSpecifier(first)) { + if (t.isImportDefaultSpecifier(first) || t.isImportNamespaceSpecifier(first)) { this.print(specifiers.shift(), node); if (specifiers.length) { @@ -8267,7 +8732,7 @@ function ImportNamespaceSpecifier(node) { this.space(); this.print(node.local, node); } -},{"@babel/types":155}],48:[function(require,module,exports){ +},{"@babel/types":160}],50:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -8288,17 +8753,11 @@ exports.VariableDeclaration = VariableDeclaration; exports.VariableDeclarator = VariableDeclarator; exports.ThrowStatement = exports.BreakStatement = exports.ReturnStatement = exports.ContinueStatement = exports.ForOfStatement = exports.ForInStatement = void 0; -function t() { - const data = _interopRequireWildcard(require("@babel/types")); +var t = _interopRequireWildcard(require("@babel/types")); - t = function () { - return data; - }; - - return data; -} +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function WithStatement(node) { this.word("with"); @@ -8316,7 +8775,7 @@ function IfStatement(node) { this.print(node.test, node); this.token(")"); this.space(); - const needsBlock = node.alternate && t().isIfStatement(getLastStatement(node.consequent)); + const needsBlock = node.alternate && t.isIfStatement(getLastStatement(node.consequent)); if (needsBlock) { this.token("{"); @@ -8341,7 +8800,7 @@ function IfStatement(node) { } function getLastStatement(statement) { - if (!t().isStatement(statement.body)) return statement; + if (!t.isStatement(statement.body)) return statement; return getLastStatement(statement.body); } @@ -8550,7 +9009,7 @@ function VariableDeclaration(node, parent) { this.space(); let hasInits = false; - if (!t().isFor(parent)) { + if (!t.isFor(parent)) { for (const declar of node.declarations) { if (declar.init) { hasInits = true; @@ -8568,7 +9027,7 @@ function VariableDeclaration(node, parent) { separator }); - if (t().isFor(parent)) { + if (t.isFor(parent)) { if (parent.left === node || parent.init === node) return; } @@ -8587,7 +9046,7 @@ function VariableDeclarator(node) { this.print(node.init, node); } } -},{"@babel/types":155}],49:[function(require,module,exports){ +},{"@babel/types":160}],51:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -8621,7 +9080,7 @@ function TemplateLiteral(node) { } } } -},{}],50:[function(require,module,exports){ +},{}],52:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -8644,29 +9103,15 @@ exports.PipelineTopicExpression = PipelineTopicExpression; exports.PipelineBareFunction = PipelineBareFunction; exports.PipelinePrimaryTopicReference = PipelinePrimaryTopicReference; -function t() { - const data = _interopRequireWildcard(require("@babel/types")); - - t = function () { - return data; - }; +var t = _interopRequireWildcard(require("@babel/types")); - return data; -} - -function _jsesc() { - const data = _interopRequireDefault(require("jsesc")); - - _jsesc = function () { - return data; - }; - - return data; -} +var _jsesc = _interopRequireDefault(require("jsesc")); 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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function Identifier(node) { this.exactSource(node.loc, () => { @@ -8717,14 +9162,14 @@ function ObjectProperty(node) { this.print(node.key, node); this.token("]"); } else { - if (t().isAssignmentPattern(node.value) && t().isIdentifier(node.key) && node.key.name === node.value.left.name) { + if (t.isAssignmentPattern(node.value) && t.isIdentifier(node.key) && node.key.name === node.value.left.name) { this.print(node.value, node); return; } this.print(node.key, node); - if (node.shorthand && t().isIdentifier(node.key) && t().isIdentifier(node.value) && node.key.name === node.value.name) { + if (node.shorthand && t.isIdentifier(node.key) && t.isIdentifier(node.value) && node.key.name === node.value.name) { return; } } @@ -8794,7 +9239,7 @@ function StringLiteral(node) { opts.json = true; } - const val = (0, _jsesc().default)(node.value, opts); + const val = (0, _jsesc.default)(node.value, opts); return this.token(val); } @@ -8820,7 +9265,7 @@ function PipelineBareFunction(node) { function PipelinePrimaryTopicReference() { this.token("#"); } -},{"@babel/types":155,"jsesc":222}],51:[function(require,module,exports){ +},{"@babel/types":160,"jsesc":228}],53:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -8840,6 +9285,7 @@ exports.tsPrintPropertyOrMethodName = tsPrintPropertyOrMethodName; exports.TSMethodSignature = TSMethodSignature; exports.TSIndexSignature = TSIndexSignature; exports.TSAnyKeyword = TSAnyKeyword; +exports.TSBigIntKeyword = TSBigIntKeyword; exports.TSUnknownKeyword = TSUnknownKeyword; exports.TSNumberKeyword = TSNumberKeyword; exports.TSObjectKeyword = TSObjectKeyword; @@ -8891,6 +9337,7 @@ exports.TSNonNullExpression = TSNonNullExpression; exports.TSExportAssignment = TSExportAssignment; exports.TSNamespaceExportDeclaration = TSNamespaceExportDeclaration; exports.tsPrintSignatureDeclarationBase = tsPrintSignatureDeclarationBase; +exports.tsPrintClassMemberModifiers = tsPrintClassMemberModifiers; function TSTypeAnnotation(node) { this.token(":"); @@ -8962,12 +9409,14 @@ function TSQualifiedName(node) { function TSCallSignatureDeclaration(node) { this.tsPrintSignatureDeclarationBase(node); + this.token(";"); } function TSConstructSignatureDeclaration(node) { this.word("new"); this.space(); this.tsPrintSignatureDeclarationBase(node); + this.token(";"); } function TSPropertySignature(node) { @@ -9039,6 +9488,10 @@ function TSAnyKeyword() { this.word("any"); } +function TSBigIntKeyword() { + this.word("bigint"); +} + function TSUnknownKeyword() { this.word("unknown"); } @@ -9116,11 +9569,19 @@ function TSTypeReference(node) { } function TSTypePredicate(node) { + if (node.asserts) { + this.word("asserts"); + this.space(); + } + this.print(node.parameterName); - this.space(); - this.word("is"); - this.space(); - this.print(node.typeAnnotation.typeAnnotation); + + if (node.typeAnnotation) { + this.space(); + this.word("is"); + this.space(); + this.print(node.typeAnnotation.typeAnnotation); + } } function TSTypeQuery(node) { @@ -9536,7 +9997,34 @@ function tsPrintSignatureDeclarationBase(node) { this.token(")"); this.print(node.typeAnnotation, node); } -},{}],52:[function(require,module,exports){ + +function tsPrintClassMemberModifiers(node, isField) { + if (isField && node.declare) { + this.word("declare"); + this.space(); + } + + if (node.accessibility) { + this.word(node.accessibility); + this.space(); + } + + if (node.static) { + this.word("static"); + this.space(); + } + + if (node.abstract) { + this.word("abstract"); + this.space(); + } + + if (isField && node.readonly) { + this.word("readonly"); + this.space(); + } +} +},{}],54:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -9629,7 +10117,7 @@ function _default(ast, opts, code) { const gen = new Generator(ast, opts, code); return gen.generate(); } -},{"./printer":56,"./source-map":57}],53:[function(require,module,exports){ +},{"./printer":58,"./source-map":59}],55:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -9644,17 +10132,11 @@ var whitespace = _interopRequireWildcard(require("./whitespace")); var parens = _interopRequireWildcard(require("./parentheses")); -function t() { - const data = _interopRequireWildcard(require("@babel/types")); +var t = _interopRequireWildcard(require("@babel/types")); - t = function () { - return data; - }; +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } - return data; -} - -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function expandAliases(obj) { const newObj = {}; @@ -9668,7 +10150,7 @@ function expandAliases(obj) { } for (const type of Object.keys(obj)) { - const aliases = t().FLIPPED_ALIAS_KEYS[type]; + const aliases = t.FLIPPED_ALIAS_KEYS[type]; if (aliases) { for (const alias of aliases) { @@ -9692,11 +10174,11 @@ function find(obj, node, parent, printStack) { } function isOrHasCallExpression(node) { - if (t().isCallExpression(node)) { + if (t.isCallExpression(node)) { return true; } - if (t().isMemberExpression(node)) { + if (t.isMemberExpression(node)) { return isOrHasCallExpression(node.object) || !node.computed && isOrHasCallExpression(node.property); } else { return false; @@ -9706,7 +10188,7 @@ function isOrHasCallExpression(node) { function needsWhitespace(node, parent, type) { if (!node) return 0; - if (t().isExpressionStatement(node)) { + if (t.isExpressionStatement(node)) { node = node.expression; } @@ -9741,13 +10223,14 @@ function needsWhitespaceAfter(node, parent) { function needsParens(node, parent, printStack) { if (!parent) return false; - if (t().isNewExpression(parent) && parent.callee === node) { + if (t.isNewExpression(parent) && parent.callee === node) { if (isOrHasCallExpression(node)) return true; } + if (t.isLogicalExpression(node) && parent.operator === "??") return true; return find(expandedParens, node, parent, printStack); } -},{"./parentheses":54,"./whitespace":55,"@babel/types":155}],54:[function(require,module,exports){ +},{"./parentheses":56,"./whitespace":57,"@babel/types":160}],56:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -9775,20 +10258,15 @@ exports.OptionalMemberExpression = OptionalMemberExpression; exports.AssignmentExpression = AssignmentExpression; exports.NewExpression = NewExpression; -function t() { - const data = _interopRequireWildcard(require("@babel/types")); +var t = _interopRequireWildcard(require("@babel/types")); - t = function () { - return data; - }; +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } - return data; -} - -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } const PRECEDENCE = { "||": 0, + "??": 0, "&&": 1, "|": 2, "^": 3, @@ -9814,22 +10292,22 @@ const PRECEDENCE = { "**": 10 }; -const isClassExtendsClause = (node, parent) => (t().isClassDeclaration(parent) || t().isClassExpression(parent)) && parent.superClass === node; +const isClassExtendsClause = (node, parent) => (t.isClassDeclaration(parent) || t.isClassExpression(parent)) && parent.superClass === node; function NullableTypeAnnotation(node, parent) { - return t().isArrayTypeAnnotation(parent); + return t.isArrayTypeAnnotation(parent); } -function FunctionTypeAnnotation(node, parent) { - return t().isUnionTypeAnnotation(parent) || t().isIntersectionTypeAnnotation(parent) || t().isArrayTypeAnnotation(parent); +function FunctionTypeAnnotation(node, parent, printStack) { + return t.isUnionTypeAnnotation(parent) || t.isIntersectionTypeAnnotation(parent) || t.isArrayTypeAnnotation(parent) || t.isTypeAnnotation(parent) && t.isArrowFunctionExpression(printStack[printStack.length - 3]); } function UpdateExpression(node, parent) { - return t().isMemberExpression(parent, { + return t.isMemberExpression(parent, { object: node - }) || t().isCallExpression(parent, { + }) || t.isCallExpression(parent, { callee: node - }) || t().isNewExpression(parent, { + }) || t.isNewExpression(parent, { callee: node }) || isClassExtendsClause(node, parent); } @@ -9845,7 +10323,7 @@ function DoExpression(node, parent, printStack) { } function Binary(node, parent) { - if (node.operator === "**" && t().isBinaryExpression(parent, { + if (node.operator === "**" && t.isBinaryExpression(parent, { operator: "**" })) { return parent.left === node; @@ -9855,17 +10333,17 @@ function Binary(node, parent) { return true; } - if ((t().isCallExpression(parent) || t().isNewExpression(parent)) && parent.callee === node || t().isUnaryLike(parent) || t().isMemberExpression(parent) && parent.object === node || t().isAwaitExpression(parent)) { + if ((t.isCallExpression(parent) || t.isNewExpression(parent)) && parent.callee === node || t.isUnaryLike(parent) || t.isMemberExpression(parent) && parent.object === node || t.isAwaitExpression(parent)) { return true; } - if (t().isBinary(parent)) { + if (t.isBinary(parent)) { const parentOp = parent.operator; const parentPos = PRECEDENCE[parentOp]; const nodeOp = node.operator; const nodePos = PRECEDENCE[nodeOp]; - if (parentPos === nodePos && parent.right === node && !t().isLogicalExpression(parent) || parentPos > nodePos) { + if (parentPos === nodePos && parent.right === node && !t.isLogicalExpression(parent) || parentPos > nodePos) { return true; } } @@ -9874,7 +10352,7 @@ function Binary(node, parent) { } function UnionTypeAnnotation(node, parent) { - return t().isArrayTypeAnnotation(parent) || t().isNullableTypeAnnotation(parent) || t().isIntersectionTypeAnnotation(parent) || t().isUnionTypeAnnotation(parent); + return t.isArrayTypeAnnotation(parent) || t.isNullableTypeAnnotation(parent) || t.isIntersectionTypeAnnotation(parent) || t.isUnionTypeAnnotation(parent); } function TSAsExpression() { @@ -9886,15 +10364,15 @@ function TSTypeAssertion() { } function TSUnionType(node, parent) { - return t().isTSArrayType(parent) || t().isTSOptionalType(parent) || t().isTSIntersectionType(parent) || t().isTSUnionType(parent) || t().isTSRestType(parent); + return t.isTSArrayType(parent) || t.isTSOptionalType(parent) || t.isTSIntersectionType(parent) || t.isTSUnionType(parent) || t.isTSRestType(parent); } function BinaryExpression(node, parent) { - return node.operator === "in" && (t().isVariableDeclarator(parent) || t().isFor(parent)); + return node.operator === "in" && (t.isVariableDeclarator(parent) || t.isFor(parent)); } function SequenceExpression(node, parent) { - if (t().isForStatement(parent) || t().isThrowStatement(parent) || t().isReturnStatement(parent) || t().isIfStatement(parent) && parent.test === node || t().isWhileStatement(parent) && parent.test === node || t().isForInStatement(parent) && parent.right === node || t().isSwitchStatement(parent) && parent.discriminant === node || t().isExpressionStatement(parent) && parent.expression === node) { + if (t.isForStatement(parent) || t.isThrowStatement(parent) || t.isReturnStatement(parent) || t.isIfStatement(parent) && parent.test === node || t.isWhileStatement(parent) && parent.test === node || t.isForInStatement(parent) && parent.right === node || t.isSwitchStatement(parent) && parent.discriminant === node || t.isExpressionStatement(parent) && parent.expression === node) { return false; } @@ -9902,7 +10380,7 @@ function SequenceExpression(node, parent) { } function YieldExpression(node, parent) { - return t().isBinary(parent) || t().isUnaryLike(parent) || t().isCallExpression(parent) || t().isMemberExpression(parent) || t().isNewExpression(parent) || t().isAwaitExpression(parent) && t().isYieldExpression(node) || t().isConditionalExpression(parent) && node === parent.test || isClassExtendsClause(node, parent); + return t.isBinary(parent) || t.isUnaryLike(parent) || t.isCallExpression(parent) || t.isMemberExpression(parent) || t.isNewExpression(parent) || t.isAwaitExpression(parent) && t.isYieldExpression(node) || t.isConditionalExpression(parent) && node === parent.test || isClassExtendsClause(node, parent); } function ClassExpression(node, parent, printStack) { @@ -9912,13 +10390,13 @@ function ClassExpression(node, parent, printStack) { } function UnaryLike(node, parent) { - return t().isMemberExpression(parent, { + return t.isMemberExpression(parent, { object: node - }) || t().isCallExpression(parent, { + }) || t.isCallExpression(parent, { callee: node - }) || t().isNewExpression(parent, { + }) || t.isNewExpression(parent, { callee: node - }) || t().isBinaryExpression(parent, { + }) || t.isBinaryExpression(parent, { operator: "**", left: node }) || isClassExtendsClause(node, parent); @@ -9931,13 +10409,13 @@ function FunctionExpression(node, parent, printStack) { } function ArrowFunctionExpression(node, parent) { - return t().isExportDeclaration(parent) || ConditionalExpression(node, parent); + return t.isExportDeclaration(parent) || ConditionalExpression(node, parent); } function ConditionalExpression(node, parent) { - if (t().isUnaryLike(parent) || t().isBinary(parent) || t().isConditionalExpression(parent, { + if (t.isUnaryLike(parent) || t.isBinary(parent) || t.isConditionalExpression(parent, { test: node - }) || t().isAwaitExpression(parent) || t().isOptionalMemberExpression(parent) || t().isTaggedTemplateExpression(parent) || t().isTSTypeAssertion(parent) || t().isTSAsExpression(parent)) { + }) || t.isAwaitExpression(parent) || t.isOptionalMemberExpression(parent) || t.isTaggedTemplateExpression(parent) || t.isTSTypeAssertion(parent) || t.isTSAsExpression(parent)) { return true; } @@ -9945,11 +10423,11 @@ function ConditionalExpression(node, parent) { } function OptionalMemberExpression(node, parent) { - return t().isCallExpression(parent) || t().isMemberExpression(parent); + return t.isCallExpression(parent) || t.isMemberExpression(parent); } function AssignmentExpression(node) { - if (t().isObjectPattern(node.left)) { + if (t.isObjectPattern(node.left)) { return true; } else { return ConditionalExpression(...arguments); @@ -9970,25 +10448,25 @@ function isFirstInStatement(printStack, { let parent = printStack[i]; while (i > 0) { - if (t().isExpressionStatement(parent, { + if (t.isExpressionStatement(parent, { expression: node - }) || t().isTaggedTemplateExpression(parent) || considerDefaultExports && t().isExportDefaultDeclaration(parent, { + }) || t.isTaggedTemplateExpression(parent) || considerDefaultExports && t.isExportDefaultDeclaration(parent, { declaration: node - }) || considerArrow && t().isArrowFunctionExpression(parent, { + }) || considerArrow && t.isArrowFunctionExpression(parent, { body: node })) { return true; } - if (t().isCallExpression(parent, { + if (t.isCallExpression(parent, { callee: node - }) || t().isSequenceExpression(parent) && parent.expressions[0] === node || t().isMemberExpression(parent, { + }) || t.isSequenceExpression(parent) && parent.expressions[0] === node || t.isMemberExpression(parent, { object: node - }) || t().isConditional(parent, { + }) || t.isConditional(parent, { test: node - }) || t().isBinary(parent, { + }) || t.isBinary(parent, { left: node - }) || t().isAssignmentExpression(parent, { + }) || t.isAssignmentExpression(parent, { left: node })) { node = parent; @@ -10001,7 +10479,7 @@ function isFirstInStatement(printStack, { return false; } -},{"@babel/types":155}],55:[function(require,module,exports){ +},{"@babel/types":160}],57:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -10009,31 +10487,25 @@ Object.defineProperty(exports, "__esModule", { }); exports.list = exports.nodes = void 0; -function t() { - const data = _interopRequireWildcard(require("@babel/types")); +var t = _interopRequireWildcard(require("@babel/types")); - t = function () { - return data; - }; +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } - return data; -} - -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function crawl(node, state = {}) { - if (t().isMemberExpression(node)) { + if (t.isMemberExpression(node)) { crawl(node.object, state); if (node.computed) crawl(node.property, state); - } else if (t().isBinary(node) || t().isAssignmentExpression(node)) { + } else if (t.isBinary(node) || t.isAssignmentExpression(node)) { crawl(node.left, state); crawl(node.right, state); - } else if (t().isCallExpression(node)) { + } else if (t.isCallExpression(node)) { state.hasCall = true; crawl(node.callee, state); - } else if (t().isFunction(node)) { + } else if (t.isFunction(node)) { state.hasFunction = true; - } else if (t().isIdentifier(node)) { + } else if (t.isIdentifier(node)) { state.hasHelper = state.hasHelper || isHelper(node.callee); } @@ -10041,21 +10513,21 @@ function crawl(node, state = {}) { } function isHelper(node) { - if (t().isMemberExpression(node)) { + if (t.isMemberExpression(node)) { return isHelper(node.object) || isHelper(node.property); - } else if (t().isIdentifier(node)) { + } else if (t.isIdentifier(node)) { return node.name === "require" || node.name[0] === "_"; - } else if (t().isCallExpression(node)) { + } else if (t.isCallExpression(node)) { return isHelper(node.callee); - } else if (t().isBinary(node) || t().isAssignmentExpression(node)) { - return t().isIdentifier(node.left) && isHelper(node.left) || isHelper(node.right); + } else if (t.isBinary(node) || t.isAssignmentExpression(node)) { + return t.isIdentifier(node.left) && isHelper(node.left) || isHelper(node.right); } else { return false; } } function isType(node) { - return t().isLiteral(node) || t().isObjectExpression(node) || t().isArrayExpression(node) || t().isIdentifier(node) || t().isMemberExpression(node); + return t.isLiteral(node) || t.isObjectExpression(node) || t.isArrayExpression(node) || t.isIdentifier(node) || t.isMemberExpression(node); } const nodes = { @@ -10078,7 +10550,7 @@ const nodes = { }, LogicalExpression(node) { - if (t().isFunction(node.left) || t().isFunction(node.right)) { + if (t.isFunction(node.left) || t.isFunction(node.right)) { return { after: true }; @@ -10094,7 +10566,7 @@ const nodes = { }, CallExpression(node) { - if (t().isFunction(node.callee) || isHelper(node)) { + if (t.isFunction(node.callee) || isHelper(node)) { return { before: true, after: true @@ -10122,7 +10594,7 @@ const nodes = { }, IfStatement(node) { - if (t().isBlockStatement(node.consequent)) { + if (t.isBlockStatement(node.consequent)) { return { before: true, after: true @@ -10188,13 +10660,13 @@ exports.list = list; }; } - [type].concat(t().FLIPPED_ALIAS_KEYS[type] || []).forEach(function (type) { + [type].concat(t.FLIPPED_ALIAS_KEYS[type] || []).forEach(function (type) { nodes[type] = function () { return amounts; }; }); }); -},{"@babel/types":155}],56:[function(require,module,exports){ +},{"@babel/types":160}],58:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -10202,43 +10674,21 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = void 0; -function _isInteger() { - const data = _interopRequireDefault(require("lodash/isInteger")); - - _isInteger = function () { - return data; - }; - - return data; -} +var _isInteger = _interopRequireDefault(require("lodash/isInteger")); -function _repeat() { - const data = _interopRequireDefault(require("lodash/repeat")); - - _repeat = function () { - return data; - }; - - return data; -} +var _repeat = _interopRequireDefault(require("lodash/repeat")); var _buffer = _interopRequireDefault(require("./buffer")); var n = _interopRequireWildcard(require("./node")); -function t() { - const data = _interopRequireWildcard(require("@babel/types")); - - t = function () { - return data; - }; - - return data; -} +var t = _interopRequireWildcard(require("@babel/types")); var generatorFunctions = _interopRequireWildcard(require("./generators")); -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -10317,7 +10767,7 @@ class Printer { number(str) { this.word(str); - this._endsWithInteger = (0, _isInteger().default)(+str) && !NON_DECIMAL_LITERAL.test(str) && !SCIENTIFIC_NOTATION.test(str) && !ZERO_DECIMAL_INTEGER.test(str) && str[str.length - 1] !== "."; + this._endsWithInteger = (0, _isInteger.default)(+str) && !NON_DECIMAL_LITERAL.test(str) && !SCIENTIFIC_NOTATION.test(str) && !ZERO_DECIMAL_INTEGER.test(str) && str[str.length - 1] !== "."; } token(str) { @@ -10436,7 +10886,7 @@ class Printer { } _getIndent() { - return (0, _repeat().default)(this.format.indent.style, this._indent); + return (0, _repeat.default)(this.format.indent.style, this._indent); } startTerminatorless(isLabel = false) { @@ -10491,7 +10941,7 @@ class Printer { this._printLeadingComments(node); - const loc = t().isProgram(node) || t().isFile(node) ? null : node.loc; + const loc = t.isProgram(node) || t.isFile(node) ? null : node.loc; this.withSource("start", loc, () => { printMethod.call(this, node, parent); }); @@ -10582,7 +11032,7 @@ class Printer { printBlock(parent) { const node = parent.body; - if (!t().isEmptyStatement(node)) { + if (!t.isEmptyStatement(node)) { this.space(); } @@ -10669,7 +11119,7 @@ class Printer { } const indentSize = Math.max(this._getIndent().length, this._buf.getCurrentColumn()); - val = val.replace(/\n(?!$)/g, `\n${(0, _repeat().default)(" ", indentSize)}`); + val = val.replace(/\n(?!$)/g, `\n${(0, _repeat.default)(" ", indentSize)}`); } if (this.endsWith("/")) this._space(); @@ -10696,7 +11146,7 @@ function commaSeparator() { this.token(","); this.space(); } -},{"./buffer":39,"./generators":44,"./node":53,"@babel/types":155,"lodash/isInteger":395,"lodash/repeat":411}],57:[function(require,module,exports){ +},{"./buffer":41,"./generators":46,"./node":55,"@babel/types":160,"lodash/isInteger":401,"lodash/repeat":417}],59:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -10704,15 +11154,7 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = void 0; -function _sourceMap() { - const data = _interopRequireDefault(require("source-map")); - - _sourceMap = function () { - return data; - }; - - return data; -} +var _sourceMap = _interopRequireDefault(require("source-map")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -10726,20 +11168,20 @@ class SourceMap { get() { if (!this._cachedMap) { - const map = this._cachedMap = new (_sourceMap().default.SourceMapGenerator)({ + const map = this._cachedMap = new _sourceMap.default.SourceMapGenerator({ sourceRoot: this._opts.sourceRoot }); const code = this._code; if (typeof code === "string") { - map.setSourceContent(this._opts.sourceFileName, code); + map.setSourceContent(this._opts.sourceFileName.replace(/\\/g, "/"), code); } else if (typeof code === "object") { Object.keys(code).forEach(sourceFileName => { - map.setSourceContent(sourceFileName, code[sourceFileName]); + map.setSourceContent(sourceFileName.replace(/\\/g, "/"), code[sourceFileName]); }); } - this._rawMappings.forEach(map.addMapping, map); + this._rawMappings.forEach(mapping => map.addMapping(mapping), map); } return this._cachedMap.toJSON(); @@ -10767,7 +11209,7 @@ class SourceMap { line: generatedLine, column: generatedColumn }, - source: line == null ? undefined : filename || this._opts.sourceFileName, + source: line == null ? undefined : (filename || this._opts.sourceFileName).replace(/\\/g, "/"), original: line == null ? undefined : { line: line, column: column @@ -10778,7 +11220,7 @@ class SourceMap { } exports.default = SourceMap; -},{"source-map":496}],58:[function(require,module,exports){ +},{"source-map":513}],60:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -10786,17 +11228,11 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = annotateAsPure; -function t() { - const data = _interopRequireWildcard(require("@babel/types")); +var t = _interopRequireWildcard(require("@babel/types")); - t = function () { - return data; - }; +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } - return data; -} - -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } const PURE_ANNOTATION = "#__PURE__"; @@ -10811,9 +11247,9 @@ function annotateAsPure(pathOrNode) { return; } - t().addComment(node, "leading", PURE_ANNOTATION); + t.addComment(node, "leading", PURE_ANNOTATION); } -},{"@babel/types":155}],59:[function(require,module,exports){ +},{"@babel/types":160}],61:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -10825,42 +11261,20 @@ exports.toComputedObjectFromClass = toComputedObjectFromClass; exports.toClassObject = toClassObject; exports.toDefineObject = toDefineObject; -function _helperFunctionName() { - const data = _interopRequireDefault(require("@babel/helper-function-name")); - - _helperFunctionName = function () { - return data; - }; - - return data; -} - -function _has() { - const data = _interopRequireDefault(require("lodash/has")); - - _has = function () { - return data; - }; +var _helperFunctionName = _interopRequireDefault(require("@babel/helper-function-name")); - return data; -} +var _has = _interopRequireDefault(require("lodash/has")); -function t() { - const data = _interopRequireWildcard(require("@babel/types")); +var t = _interopRequireWildcard(require("@babel/types")); - t = function () { - return data; - }; +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } - return data; -} - -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function toKind(node) { - if (t().isClassMethod(node) || t().isObjectMethod(node)) { + if (t.isClassMethod(node) || t.isObjectMethod(node)) { if (node.kind === "get" || node.kind === "set") { return node.kind; } @@ -10870,9 +11284,9 @@ function toKind(node) { } function push(mutatorMap, node, kind, file, scope) { - const alias = t().toKeyAlias(node); + const alias = t.toKeyAlias(node); let map = {}; - if ((0, _has().default)(mutatorMap, alias)) map = mutatorMap[alias]; + if ((0, _has.default)(mutatorMap, alias)) map = mutatorMap[alias]; mutatorMap[alias] = map; map._inherits = map._inherits || []; @@ -10885,7 +11299,7 @@ function push(mutatorMap, node, kind, file, scope) { } if (node.decorators) { - const decorators = map.decorators = map.decorators || t().arrayExpression([]); + const decorators = map.decorators = map.decorators || t.arrayExpression([]); decorators.elements = decorators.elements.concat(node.decorators.map(dec => dec.expression).reverse()); } @@ -10895,14 +11309,14 @@ function push(mutatorMap, node, kind, file, scope) { let key, value; - if (t().isObjectProperty(node) || t().isObjectMethod(node) || t().isClassMethod(node)) { - key = t().toComputedKey(node, node.key); + if (t.isObjectProperty(node) || t.isObjectMethod(node) || t.isClassMethod(node)) { + key = t.toComputedKey(node, node.key); } - if (t().isProperty(node)) { + if (t.isProperty(node)) { value = node.value; - } else if (t().isObjectMethod(node) || t().isClassMethod(node)) { - value = t().functionExpression(null, node.params, node.body, node.generator, node.async); + } else if (t.isObjectMethod(node) || t.isClassMethod(node)) { + value = t.functionExpression(null, node.params, node.body, node.generator, node.async); value.returnType = node.returnType; } @@ -10912,8 +11326,8 @@ function push(mutatorMap, node, kind, file, scope) { kind = inheritedKind; } - if (scope && t().isStringLiteral(key) && (kind === "value" || kind === "initializer") && t().isFunctionExpression(value)) { - value = (0, _helperFunctionName().default)({ + if (scope && t.isStringLiteral(key) && (kind === "value" || kind === "initializer") && t.isFunctionExpression(value)) { + value = (0, _helperFunctionName.default)({ id: key, node: value, scope @@ -10921,7 +11335,7 @@ function push(mutatorMap, node, kind, file, scope) { } if (value) { - t().inheritsComments(value, node); + t.inheritsComments(value, node); map[kind] = value; } @@ -10939,12 +11353,12 @@ function hasComputed(mutatorMap) { } function toComputedObjectFromClass(obj) { - const objExpr = t().arrayExpression([]); + const objExpr = t.arrayExpression([]); for (let i = 0; i < obj.properties.length; i++) { const prop = obj.properties[i]; const val = prop.value; - val.properties.unshift(t().objectProperty(t().identifier("key"), t().toComputedKey(prop))); + val.properties.unshift(t.objectProperty(t.identifier("key"), t.toComputedKey(prop))); objExpr.elements.push(val); } @@ -10952,17 +11366,17 @@ function toComputedObjectFromClass(obj) { } function toClassObject(mutatorMap) { - const objExpr = t().objectExpression([]); + const objExpr = t.objectExpression([]); Object.keys(mutatorMap).forEach(function (mutatorMapKey) { const map = mutatorMap[mutatorMapKey]; - const mapNode = t().objectExpression([]); - const propNode = t().objectProperty(map._key, mapNode, map._computed); + const mapNode = t.objectExpression([]); + const propNode = t.objectProperty(map._key, mapNode, map._computed); Object.keys(map).forEach(function (key) { const node = map[key]; if (key[0] === "_") return; - const prop = t().objectProperty(t().identifier(key), node); - t().inheritsComments(prop, node); - t().removeComments(node); + const prop = t.objectProperty(t.identifier(key), node); + t.inheritsComments(prop, node); + t.removeComments(node); mapNode.properties.push(prop); }); objExpr.properties.push(propNode); @@ -10973,13 +11387,13 @@ function toClassObject(mutatorMap) { function toDefineObject(mutatorMap) { Object.keys(mutatorMap).forEach(function (key) { const map = mutatorMap[key]; - if (map.value) map.writable = t().booleanLiteral(true); - map.configurable = t().booleanLiteral(true); - map.enumerable = t().booleanLiteral(true); + if (map.value) map.writable = t.booleanLiteral(true); + map.configurable = t.booleanLiteral(true); + map.enumerable = t.booleanLiteral(true); }); return toClassObject(mutatorMap); } -},{"@babel/helper-function-name":60,"@babel/types":155,"lodash/has":386}],60:[function(require,module,exports){ +},{"@babel/helper-function-name":62,"@babel/types":160,"lodash/has":392}],62:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -10987,41 +11401,19 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = _default; -function _helperGetFunctionArity() { - const data = _interopRequireDefault(require("@babel/helper-get-function-arity")); +var _helperGetFunctionArity = _interopRequireDefault(require("@babel/helper-get-function-arity")); - _helperGetFunctionArity = function () { - return data; - }; - - return data; -} - -function _template() { - const data = _interopRequireDefault(require("@babel/template")); +var _template = _interopRequireDefault(require("@babel/template")); - _template = function () { - return data; - }; +var t = _interopRequireWildcard(require("@babel/types")); - return data; -} +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } -function t() { - const data = _interopRequireWildcard(require("@babel/types")); - - t = function () { - return data; - }; - - return data; -} - -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -const buildPropertyMethodAssignmentWrapper = (0, _template().default)(` +const buildPropertyMethodAssignmentWrapper = (0, _template.default)(` (function (FUNCTION_KEY) { function FUNCTION_ID() { return FUNCTION_KEY.apply(this, arguments); @@ -11034,7 +11426,7 @@ const buildPropertyMethodAssignmentWrapper = (0, _template().default)(` return FUNCTION_ID; })(FUNCTION) `); -const buildGeneratorPropertyMethodAssignmentWrapper = (0, _template().default)(` +const buildGeneratorPropertyMethodAssignmentWrapper = (0, _template.default)(` (function (FUNCTION_KEY) { function* FUNCTION_ID() { return yield* FUNCTION_KEY.apply(this, arguments); @@ -11059,15 +11451,15 @@ const visitor = { }; function getNameFromLiteralId(id) { - if (t().isNullLiteral(id)) { + if (t.isNullLiteral(id)) { return "null"; } - if (t().isRegExpLiteral(id)) { + if (t.isRegExpLiteral(id)) { return `_${id.pattern}_${id.flags}`; } - if (t().isTemplateLiteral(id)) { + if (t.isTemplateLiteral(id)) { return id.quasis.map(quasi => quasi.value.raw).join(""); } @@ -11083,7 +11475,7 @@ function wrap(state, method, id, scope) { if (scope.hasBinding(id.name) && !scope.hasGlobal(id.name)) { scope.rename(id.name); } else { - if (!t().isFunction(method)) return; + if (!t.isFunction(method)) return; let build = buildPropertyMethodAssignmentWrapper; if (method.generator) { @@ -11097,7 +11489,7 @@ function wrap(state, method, id, scope) { }).expression; const params = template.callee.body.body[0].params; - for (let i = 0, len = (0, _helperGetFunctionArity().default)(method); i < len; i++) { + for (let i = 0, len = (0, _helperGetFunctionArity.default)(method); i < len; i++) { params.push(scope.generateUidIdentifier("x")); } @@ -11138,23 +11530,23 @@ function _default({ }, localBinding = false) { if (node.id) return; - if ((t().isObjectProperty(parent) || t().isObjectMethod(parent, { + if ((t.isObjectProperty(parent) || t.isObjectMethod(parent, { kind: "method" - })) && (!parent.computed || t().isLiteral(parent.key))) { + })) && (!parent.computed || t.isLiteral(parent.key))) { id = parent.key; - } else if (t().isVariableDeclarator(parent)) { + } else if (t.isVariableDeclarator(parent)) { id = parent.id; - if (t().isIdentifier(id) && !localBinding) { + if (t.isIdentifier(id) && !localBinding) { const binding = scope.parent.getBinding(id.name); if (binding && binding.constant && scope.getBinding(id.name) === binding) { - node.id = t().cloneNode(id); - node.id[t().NOT_LOCAL_BINDING] = true; + node.id = t.cloneNode(id); + node.id[t.NOT_LOCAL_BINDING] = true; return; } } - } else if (t().isAssignmentExpression(parent)) { + } else if (t.isAssignmentExpression(parent)) { id = parent.left; } else if (!id) { return; @@ -11162,9 +11554,9 @@ function _default({ let name; - if (id && t().isLiteral(id)) { + if (id && t.isLiteral(id)) { name = getNameFromLiteralId(id); - } else if (id && t().isIdentifier(id)) { + } else if (id && t.isIdentifier(id)) { name = id.name; } @@ -11172,13 +11564,13 @@ function _default({ return; } - name = t().toBindingIdentifierName(name); - id = t().identifier(name); - id[t().NOT_LOCAL_BINDING] = true; + name = t.toBindingIdentifierName(name); + id = t.identifier(name); + id[t.NOT_LOCAL_BINDING] = true; const state = visit(node, name, scope); return wrap(state, node, id, scope) || node; } -},{"@babel/helper-get-function-arity":61,"@babel/template":83,"@babel/types":155}],61:[function(require,module,exports){ +},{"@babel/helper-get-function-arity":63,"@babel/template":88,"@babel/types":160}],63:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11186,17 +11578,11 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = _default; -function t() { - const data = _interopRequireWildcard(require("@babel/types")); +var t = _interopRequireWildcard(require("@babel/types")); - t = function () { - return data; - }; - - return data; -} +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _default(node) { const params = node.params; @@ -11204,14 +11590,14 @@ function _default(node) { for (let i = 0; i < params.length; i++) { const param = params[i]; - if (t().isAssignmentPattern(param) || t().isRestElement(param)) { + if (t.isAssignmentPattern(param) || t.isRestElement(param)) { return i; } } return params.length; } -},{"@babel/types":155}],62:[function(require,module,exports){ +},{"@babel/types":160}],64:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11219,17 +11605,11 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = memberExpressionToFunctions; -function t() { - const data = _interopRequireWildcard(require("@babel/types")); +var t = _interopRequireWildcard(require("@babel/types")); - t = function () { - return data; - }; - - return data; -} +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } class AssignmentMemoiser { constructor() { @@ -11251,7 +11631,7 @@ class AssignmentMemoiser { record.count--; if (record.count === 0) { - return t().assignmentExpression("=", value, key); + return t.assignmentExpression("=", value, key); } return value; @@ -11284,7 +11664,7 @@ const handle = { prefix } = parent; this.memoise(member, 2); - const value = t().binaryExpression(operator[0], t().unaryExpression("+", this.get(member)), t().numericLiteral(1)); + const value = t.binaryExpression(operator[0], t.unaryExpression("+", this.get(member)), t.numericLiteral(1)); if (prefix) { parentPath.replaceWith(this.set(member, value)); @@ -11296,8 +11676,8 @@ const handle = { scope.push({ id: ref }); - value.left = t().assignmentExpression("=", t().cloneNode(ref), value.left); - parentPath.replaceWith(t().sequenceExpression([this.set(member, value), t().cloneNode(ref)])); + value.left = t.assignmentExpression("=", t.cloneNode(ref), value.left); + parentPath.replaceWith(t.sequenceExpression([this.set(member, value), t.cloneNode(ref)])); } return; @@ -11314,7 +11694,7 @@ const handle = { if (operator !== "=") { this.memoise(member, 2); - value = t().binaryExpression(operator.slice(0, -1), this.get(member), value); + value = t.binaryExpression(operator.slice(0, -1), this.get(member), value); } parentPath.replaceWith(this.set(member, value)); @@ -11331,17 +11711,30 @@ const handle = { return; } + if (parentPath.isObjectProperty({ + value: node + }) && parentPath.parentPath.isObjectPattern() || parentPath.isAssignmentPattern({ + left: node + }) && parentPath.parentPath.isObjectProperty({ + value: parent + }) && parentPath.parentPath.parentPath.isObjectPattern() || parentPath.isArrayPattern() || parentPath.isAssignmentPattern({ + left: node + }) && parentPath.parentPath.isArrayPattern() || parentPath.isRestElement()) { + member.replaceWith(this.destructureSet(member)); + return; + } + member.replaceWith(this.get(member)); } }; function memberExpressionToFunctions(path, visitor, state) { - path.traverse(visitor, Object.assign({}, handle, state, { + path.traverse(visitor, Object.assign({}, handle, {}, state, { memoiser: new AssignmentMemoiser() })); } -},{"@babel/types":155}],63:[function(require,module,exports){ +},{"@babel/types":160}],65:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11349,28 +11742,22 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = _default; -function t() { - const data = _interopRequireWildcard(require("@babel/types")); +var t = _interopRequireWildcard(require("@babel/types")); - t = function () { - return data; - }; - - return data; -} +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _default(callee, thisNode, args) { - if (args.length === 1 && t().isSpreadElement(args[0]) && t().isIdentifier(args[0].argument, { + if (args.length === 1 && t.isSpreadElement(args[0]) && t.isIdentifier(args[0].argument, { name: "arguments" })) { - return t().callExpression(t().memberExpression(callee, t().identifier("apply")), [thisNode, args[0].argument]); + return t.callExpression(t.memberExpression(callee, t.identifier("apply")), [thisNode, args[0].argument]); } else { - return t().callExpression(t().memberExpression(callee, t().identifier("call")), [thisNode, ...args]); + return t.callExpression(t.memberExpression(callee, t.identifier("call")), [thisNode, ...args]); } } -},{"@babel/types":155}],64:[function(require,module,exports){ +},{"@babel/types":160}],66:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11404,7 +11791,7 @@ function copyApiObject(api) { } } - return Object.assign({}, proto, api); + return Object.assign({}, proto, {}, api); } function has(obj, key) { @@ -11448,7 +11835,7 @@ function throwVersionError(range, version) { range }); } -},{}],65:[function(require,module,exports){ +},{}],67:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11456,54 +11843,24 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = exports.environmentVisitor = void 0; -function _traverse() { - const data = _interopRequireDefault(require("@babel/traverse")); - - _traverse = function () { - return data; - }; - - return data; -} - -function _helperMemberExpressionToFunctions() { - const data = _interopRequireDefault(require("@babel/helper-member-expression-to-functions")); - - _helperMemberExpressionToFunctions = function () { - return data; - }; - - return data; -} - -function _helperOptimiseCallExpression() { - const data = _interopRequireDefault(require("@babel/helper-optimise-call-expression")); +var _traverse = _interopRequireDefault(require("@babel/traverse")); - _helperOptimiseCallExpression = function () { - return data; - }; +var _helperMemberExpressionToFunctions = _interopRequireDefault(require("@babel/helper-member-expression-to-functions")); - return data; -} +var _helperOptimiseCallExpression = _interopRequireDefault(require("@babel/helper-optimise-call-expression")); -function t() { - const data = _interopRequireWildcard(require("@babel/types")); - - t = function () { - return data; - }; +var t = _interopRequireWildcard(require("@babel/types")); - return data; -} +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function getPrototypeOfExpression(objectRef, isStatic, file, isPrivateMethod) { - objectRef = t().cloneNode(objectRef); - const targetRef = isStatic || isPrivateMethod ? objectRef : t().memberExpression(objectRef, t().identifier("prototype")); - return t().callExpression(file.addHelper("getPrototypeOf"), [targetRef]); + objectRef = t.cloneNode(objectRef); + const targetRef = isStatic || isPrivateMethod ? objectRef : t.memberExpression(objectRef, t.identifier("prototype")); + return t.callExpression(file.addHelper("getPrototypeOf"), [targetRef]); } function skipAllButComputedKey(path) { @@ -11512,7 +11869,7 @@ function skipAllButComputedKey(path) { return; } - const keys = t().VISITOR_KEYS[path.type]; + const keys = t.VISITOR_KEYS[path.type]; for (const key of keys) { if (key !== "key") path.skipKey(key); @@ -11537,7 +11894,7 @@ const environmentVisitor = { }; exports.environmentVisitor = environmentVisitor; -const visitor = _traverse().default.visitors.merge([environmentVisitor, { +const visitor = _traverse.default.visitors.merge([environmentVisitor, { Super(path, state) { const { node, @@ -11582,26 +11939,30 @@ const specHandlers = { } = superMember.node; if (this.memoiser.has(property)) { - return t().cloneNode(this.memoiser.get(property)); + return t.cloneNode(this.memoiser.get(property)); } if (computed) { - return t().cloneNode(property); + return t.cloneNode(property); } - return t().stringLiteral(property.name); + return t.stringLiteral(property.name); }, get(superMember) { - return t().callExpression(this.file.addHelper("get"), [getPrototypeOfExpression(this.getObjectRef(), this.isStatic, this.file, this.isPrivateMethod), this.prop(superMember), t().thisExpression()]); + return t.callExpression(this.file.addHelper("get"), [getPrototypeOfExpression(this.getObjectRef(), this.isStatic, this.file, this.isPrivateMethod), this.prop(superMember), t.thisExpression()]); }, set(superMember, value) { - return t().callExpression(this.file.addHelper("set"), [getPrototypeOfExpression(this.getObjectRef(), this.isStatic, this.file, this.isPrivateMethod), this.prop(superMember), value, t().thisExpression(), t().booleanLiteral(superMember.isInStrictMode())]); + return t.callExpression(this.file.addHelper("set"), [getPrototypeOfExpression(this.getObjectRef(), this.isStatic, this.file, this.isPrivateMethod), this.prop(superMember), value, t.thisExpression(), t.booleanLiteral(superMember.isInStrictMode())]); + }, + + destructureSet(superMember) { + throw superMember.buildCodeFrameError(`Destructuring to a super field is not supported yet.`); }, call(superMember, args) { - return (0, _helperOptimiseCallExpression().default)(this.get(superMember), t().thisExpression(), args); + return (0, _helperOptimiseCallExpression.default)(this.get(superMember), t.thisExpression(), args); } }; @@ -11612,10 +11973,10 @@ const looseHandlers = Object.assign({}, specHandlers, { } = superMember.node; if (this.memoiser.has(property)) { - return t().cloneNode(this.memoiser.get(property)); + return t.cloneNode(this.memoiser.get(property)); } - return t().cloneNode(property); + return t.cloneNode(property); }, get(superMember) { @@ -11630,12 +11991,12 @@ const looseHandlers = Object.assign({}, specHandlers, { let object; if (isStatic) { - object = superRef ? t().cloneNode(superRef) : t().memberExpression(t().identifier("Function"), t().identifier("prototype")); + object = superRef ? t.cloneNode(superRef) : t.memberExpression(t.identifier("Function"), t.identifier("prototype")); } else { - object = superRef ? t().memberExpression(t().cloneNode(superRef), t().identifier("prototype")) : t().memberExpression(t().identifier("Object"), t().identifier("prototype")); + object = superRef ? t.memberExpression(t.cloneNode(superRef), t.identifier("prototype")) : t.memberExpression(t.identifier("Object"), t.identifier("prototype")); } - return t().memberExpression(object, prop, computed); + return t.memberExpression(object, prop, computed); }, set(superMember, value) { @@ -11643,7 +12004,15 @@ const looseHandlers = Object.assign({}, specHandlers, { computed } = superMember.node; const prop = this.prop(superMember); - return t().assignmentExpression("=", t().memberExpression(t().thisExpression(), prop, computed), value); + return t.assignmentExpression("=", t.memberExpression(t.thisExpression(), prop, computed), value); + }, + + destructureSet(superMember) { + const { + computed + } = superMember.node; + const prop = this.prop(superMember); + return t.memberExpression(t.thisExpression(), prop, computed); } }); @@ -11661,12 +12030,12 @@ class ReplaceSupers { } getObjectRef() { - return t().cloneNode(this.opts.objectRef || this.opts.getObjectRef()); + return t.cloneNode(this.opts.objectRef || this.opts.getObjectRef()); } replace() { const handler = this.isLoose ? looseHandlers : specHandlers; - (0, _helperMemberExpressionToFunctions().default)(this.methodPath, visitor, Object.assign({ + (0, _helperMemberExpressionToFunctions.default)(this.methodPath, visitor, Object.assign({ file: this.file, isStatic: this.isStatic, isPrivateMethod: this.isPrivateMethod, @@ -11678,7 +12047,7 @@ class ReplaceSupers { } exports.default = ReplaceSupers; -},{"@babel/helper-member-expression-to-functions":62,"@babel/helper-optimise-call-expression":63,"@babel/traverse":92,"@babel/types":155}],66:[function(require,module,exports){ +},{"@babel/helper-member-expression-to-functions":64,"@babel/helper-optimise-call-expression":65,"@babel/traverse":97,"@babel/types":160}],68:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11686,17 +12055,11 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = splitExportDeclaration; -function t() { - const data = _interopRequireWildcard(require("@babel/types")); +var t = _interopRequireWildcard(require("@babel/types")); - t = function () { - return data; - }; +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } - return data; -} - -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function splitExportDeclaration(exportDeclaration) { if (!exportDeclaration.isExportDeclaration()) { @@ -11718,12 +12081,12 @@ function splitExportDeclaration(exportDeclaration) { id = scope.generateUidIdentifier("default"); if (standaloneDeclaration || declaration.isFunctionExpression() || declaration.isClassExpression()) { - declaration.node.id = t().cloneNode(id); + declaration.node.id = t.cloneNode(id); } } - const updatedDeclaration = standaloneDeclaration ? declaration : t().variableDeclaration("var", [t().variableDeclarator(t().cloneNode(id), declaration.node)]); - const updatedExportDeclaration = t().exportNamedDeclaration(null, [t().exportSpecifier(t().cloneNode(id), t().identifier("default"))]); + const updatedDeclaration = standaloneDeclaration ? declaration : t.variableDeclaration("var", [t.variableDeclarator(t.cloneNode(id), declaration.node)]); + const updatedExportDeclaration = t.exportNamedDeclaration(null, [t.exportSpecifier(t.cloneNode(id), t.identifier("default"))]); exportDeclaration.insertAfter(updatedExportDeclaration); exportDeclaration.replaceWith(updatedDeclaration); @@ -11740,14 +12103,14 @@ function splitExportDeclaration(exportDeclaration) { const bindingIdentifiers = declaration.getOuterBindingIdentifiers(); const specifiers = Object.keys(bindingIdentifiers).map(name => { - return t().exportSpecifier(t().identifier(name), t().identifier(name)); + return t.exportSpecifier(t.identifier(name), t.identifier(name)); }); - const aliasDeclar = t().exportNamedDeclaration(null, specifiers); + const aliasDeclar = t.exportNamedDeclaration(null, specifiers); exportDeclaration.insertAfter(aliasDeclar); exportDeclaration.replaceWith(declaration.node); return exportDeclaration; } -},{"@babel/types":155}],67:[function(require,module,exports){ +},{"@babel/types":160}],69:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11755,41 +12118,19 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = wrapFunction; -function _helperFunctionName() { - const data = _interopRequireDefault(require("@babel/helper-function-name")); - - _helperFunctionName = function () { - return data; - }; - - return data; -} - -function _template() { - const data = _interopRequireDefault(require("@babel/template")); - - _template = function () { - return data; - }; - - return data; -} +var _helperFunctionName = _interopRequireDefault(require("@babel/helper-function-name")); -function t() { - const data = _interopRequireWildcard(require("@babel/types")); +var _template = _interopRequireDefault(require("@babel/template")); - t = function () { - return data; - }; +var t = _interopRequireWildcard(require("@babel/types")); - return data; -} +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -const buildAnonymousExpressionWrapper = _template().default.expression(` +const buildAnonymousExpressionWrapper = _template.default.expression(` (function () { var REF = FUNCTION; return function NAME(PARAMS) { @@ -11798,7 +12139,7 @@ const buildAnonymousExpressionWrapper = _template().default.expression(` })() `); -const buildNamedExpressionWrapper = _template().default.expression(` +const buildNamedExpressionWrapper = _template.default.expression(` (function () { var REF = FUNCTION; function NAME(PARAMS) { @@ -11808,7 +12149,7 @@ const buildNamedExpressionWrapper = _template().default.expression(` })() `); -const buildDeclarationWrapper = (0, _template().default)(` +const buildDeclarationWrapper = (0, _template.default)(` function NAME(PARAMS) { return REF.apply(this, arguments); } function REF() { REF = FUNCTION; @@ -11819,8 +12160,8 @@ const buildDeclarationWrapper = (0, _template().default)(` function classOrObjectMethod(path, callId) { const node = path.node; const body = node.body; - const container = t().functionExpression(null, [], t().blockStatement(body.body), true); - body.body = [t().returnStatement(t().callExpression(t().callExpression(callId, [container]), []))]; + const container = t.functionExpression(null, [], t.blockStatement(body.body), true); + body.body = [t.returnStatement(t.callExpression(t.callExpression(callId, [container]), []))]; node.async = false; node.generator = false; path.get("body.body.0.argument.callee.arguments.0").unwrapFunctionEnvironment(); @@ -11842,13 +12183,13 @@ function plainFunction(path, callId) { node.type = "FunctionExpression"; } - const built = t().callExpression(callId, [node]); + const built = t.callExpression(callId, [node]); const container = wrapper({ NAME: functionId || null, REF: path.scope.generateUidIdentifier(functionId ? functionId.name : "ref"), FUNCTION: built, PARAMS: node.params.reduce((acc, param) => { - acc.done = acc.done || t().isAssignmentPattern(param) || t().isRestElement(param); + acc.done = acc.done || t.isAssignmentPattern(param) || t.isRestElement(param); if (!acc.done) { acc.params.push(path.scope.generateUidIdentifier("x")); @@ -11868,7 +12209,7 @@ function plainFunction(path, callId) { const retFunction = container.callee.body.body[1].argument; if (!functionId) { - (0, _helperFunctionName().default)({ + (0, _helperFunctionName.default)({ node: retFunction, parent: path.parent, scope: path.scope @@ -11890,7 +12231,7 @@ function wrapFunction(path, callId) { plainFunction(path, callId); } } -},{"@babel/helper-function-name":60,"@babel/template":83,"@babel/types":155}],68:[function(require,module,exports){ +},{"@babel/helper-function-name":62,"@babel/template":88,"@babel/types":160}],70:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11898,15 +12239,7 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = void 0; -function _template() { - const data = _interopRequireDefault(require("@babel/template")); - - _template = function () { - return data; - }; - - return data; -} +var _template = _interopRequireDefault(require("@babel/template")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -11916,11 +12249,13 @@ exports.default = _default; const helper = minVersion => tpl => ({ minVersion, - ast: () => _template().default.program.ast(tpl) + ast: () => _template.default.program.ast(tpl) }); helpers.typeof = helper("7.0.0-beta.0")` export default function _typeof(obj) { + "@babel/helpers - typeof"; + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function (obj) { return typeof obj; }; } else { @@ -11940,7 +12275,7 @@ helpers.jsx = helper("7.0.0-beta.0")` export default function _createRawReactElement(type, props, key, children) { if (!REACT_ELEMENT_TYPE) { REACT_ELEMENT_TYPE = ( - typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") + typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element") ) || 0xeac7; } @@ -11954,15 +12289,6 @@ helpers.jsx = helper("7.0.0-beta.0")` children: void 0, }; } - if (props && defaultProps) { - for (var propName in defaultProps) { - if (props[propName] === void 0) { - props[propName] = defaultProps[propName]; - } - } - } else if (!props) { - props = defaultProps || {}; - } if (childrenLength === 1) { props.children = children; @@ -11974,6 +12300,16 @@ helpers.jsx = helper("7.0.0-beta.0")` props.children = childArray; } + if (props && defaultProps) { + for (var propName in defaultProps) { + if (props[propName] === void 0) { + props[propName] = defaultProps[propName]; + } + } + } else if (!props) { + props = defaultProps || {}; + } + return { $$typeof: REACT_ELEMENT_TYPE, type: type, @@ -12039,7 +12375,7 @@ helpers.AsyncGenerator = helper("7.0.0-beta.0")` Promise.resolve(wrappedAwait ? value.wrapped : value).then( function (arg) { if (wrappedAwait) { - resume("next", arg); + resume(key === "return" ? "return" : "next", arg); return } @@ -12138,6 +12474,10 @@ helpers.asyncGeneratorDelegate = helper("7.0.0-beta.0")` if (typeof inner.return === "function") { iter.return = function (value) { + if (waiting) { + waiting = false; + return value; + } return pump("return", value); }; } @@ -12283,7 +12623,7 @@ helpers.objectSpread = helper("7.0.0-beta.0")` export default function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { - var source = (arguments[i] != null) ? arguments[i] : {}; + var source = (arguments[i] != null) ? Object(arguments[i]) : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) { @@ -12297,6 +12637,47 @@ helpers.objectSpread = helper("7.0.0-beta.0")` return target; } `; +helpers.objectSpread2 = helper("7.5.0")` + import defineProperty from "defineProperty"; + + // This function is different to "Reflect.ownKeys". The enumerableOnly + // filters on symbol properties only. Returned string properties are always + // enumerable. It is good to use in objectSpread. + + function ownKeys(object, enumerableOnly) { + var keys = Object.keys(object); + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + if (enumerableOnly) symbols = symbols.filter(function (sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + }); + keys.push.apply(keys, symbols); + } + return keys; + } + + export default function _objectSpread2(target) { + for (var i = 1; i < arguments.length; i++) { + var source = (arguments[i] != null) ? arguments[i] : {}; + if (i % 2) { + ownKeys(Object(source), true).forEach(function (key) { + defineProperty(target, key, source[key]); + }); + } else if (Object.getOwnPropertyDescriptors) { + Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); + } else { + ownKeys(Object(source)).forEach(function (key) { + Object.defineProperty( + target, + key, + Object.getOwnPropertyDescriptor(source, key) + ); + }); + } + } + return target; + } +`; helpers.inherits = helper("7.0.0-beta.0")` import setPrototypeOf from "setPrototypeOf"; @@ -12433,7 +12814,7 @@ helpers.wrapNativeSuper = helper("7.0.0-beta.0")` helpers.instanceof = helper("7.0.0-beta.0")` export default function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { - return right[Symbol.hasInstance](left); + return !!right[Symbol.hasInstance](left); } else { return left instanceof right; } @@ -12445,28 +12826,47 @@ helpers.interopRequireDefault = helper("7.0.0-beta.0")` } `; helpers.interopRequireWildcard = helper("7.0.0-beta.0")` + function _getRequireWildcardCache() { + if (typeof WeakMap !== "function") return null; + + var cache = new WeakMap(); + _getRequireWildcardCache = function () { return cache; }; + return cache; + } + export default 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)) { - var desc = Object.defineProperty && Object.getOwnPropertyDescriptor - ? Object.getOwnPropertyDescriptor(obj, key) - : {}; - if (desc.get || desc.set) { - Object.defineProperty(newObj, key, desc); - } else { - newObj[key] = obj[key]; - } - } + } + + if (obj === null || (typeof obj !== "object" && typeof obj !== "function")) { + return { default: obj } + } + + var cache = _getRequireWildcardCache(); + if (cache && cache.has(obj)) { + return cache.get(obj); + } + + var newObj = {}; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor + ? Object.getOwnPropertyDescriptor(obj, key) + : null; + if (desc && (desc.get || desc.set)) { + Object.defineProperty(newObj, key, desc); + } else { + newObj[key] = obj[key]; } } - newObj.default = obj; - return newObj; } + newObj.default = obj; + if (cache) { + cache.set(obj, newObj); + } + return newObj; } `; helpers.newArrowCheck = helper("7.0.0-beta.0")` @@ -12551,7 +12951,6 @@ helpers.superPropBase = helper("7.0.0-beta.0")` } `; helpers.get = helper("7.0.0-beta.0")` - import getPrototypeOf from "getPrototypeOf"; import superPropBase from "superPropBase"; export default function _get(target, property, receiver) { @@ -12575,7 +12974,6 @@ helpers.get = helper("7.0.0-beta.0")` } `; helpers.set = helper("7.0.0-beta.0")` - import getPrototypeOf from "getPrototypeOf"; import superPropBase from "superPropBase"; import defineProperty from "defineProperty"; @@ -12646,17 +13044,6 @@ helpers.taggedTemplateLiteralLoose = helper("7.0.0-beta.0")` return strings; } `; -helpers.temporalRef = helper("7.0.0-beta.0")` - import undef from "temporalUndefined"; - - export default function _temporalRef(val, name) { - if (val === undef) { - throw new ReferenceError(name + " is not defined - temporal dead zone"); - } else { - return val; - } - } -`; helpers.readOnlyError = helper("7.0.0-beta.0")` export default function _readOnlyError(name) { throw new Error("\\"" + name + "\\" is read-only"); @@ -12668,7 +13055,22 @@ helpers.classNameTDZError = helper("7.0.0-beta.0")` } `; helpers.temporalUndefined = helper("7.0.0-beta.0")` - export default {}; + // This function isn't mean to be called, but to be used as a reference. + // We can't use a normal object because it isn't hoisted. + export default function _temporalUndefined() {} +`; +helpers.tdz = helper("7.5.5")` + export default function _tdzError(name) { + throw new ReferenceError(name + " is not defined - temporal dead zone"); + } +`; +helpers.temporalRef = helper("7.0.0-beta.0")` + import undef from "temporalUndefined"; + import err from "tdz"; + + export default function _temporalRef(val, name) { + return val === undef ? err(name) : val; + } `; helpers.slicedToArray = helper("7.0.0-beta.0")` import arrayWithHoles from "arrayWithHoles"; @@ -12731,14 +13133,16 @@ helpers.iterableToArrayLimit = helper("7.0.0-beta.0")` export default function _iterableToArrayLimit(arr, i) { // this is an expanded form of \`for...of\` that properly supports abrupt completions of // iterators etc. variable names have been minimised to reduce the size of this massive - // helper. sometimes spec compliancy is annoying :( + // helper. sometimes spec compliance is annoying :( // // _n = _iteratorNormalCompletion // _d = _didIteratorError // _e = _iteratorError // _i = _iterator // _s = _step - + if (!( + Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]" + )) { return } var _arr = []; var _n = true; var _d = false; @@ -12763,6 +13167,9 @@ helpers.iterableToArrayLimit = helper("7.0.0-beta.0")` `; helpers.iterableToArrayLimitLoose = helper("7.0.0-beta.0")` export default function _iterableToArrayLimitLoose(arr, i) { + if (!( + Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]" + )) { return } var _arr = []; for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { _arr.push(_step.value); @@ -12817,9 +13224,7 @@ helpers.initializerWarningHelper = helper("7.0.0-beta.0")` export default function _initializerWarningHelper(descriptor, context){ throw new Error( 'Decorating class property failed. Please ensure that ' + - 'proposal-class-properties is enabled and set to use loose mode. ' + - 'To use proposal-class-properties in spec mode with decorators, wait for ' + - 'the next major version of decorators in stage 2.' + 'proposal-class-properties is enabled and runs after the decorators transform.' ); } `; @@ -12882,10 +13287,10 @@ helpers.classPrivateFieldLooseBase = helper("7.0.0-beta.0")` `; helpers.classPrivateFieldGet = helper("7.0.0-beta.0")` export default function _classPrivateFieldGet(receiver, privateMap) { - if (!privateMap.has(receiver)) { + var descriptor = privateMap.get(receiver); + if (!descriptor) { throw new TypeError("attempted to get private field on non-instance"); } - var descriptor = privateMap.get(receiver); if (descriptor.get) { return descriptor.get.call(receiver); } @@ -12894,10 +13299,10 @@ helpers.classPrivateFieldGet = helper("7.0.0-beta.0")` `; helpers.classPrivateFieldSet = helper("7.0.0-beta.0")` export default function _classPrivateFieldSet(receiver, privateMap, value) { - if (!privateMap.has(receiver)) { + var descriptor = privateMap.get(receiver); + if (!descriptor) { throw new TypeError("attempted to set private field on non-instance"); } - var descriptor = privateMap.get(receiver); if (descriptor.set) { descriptor.set.call(receiver, value); } else { @@ -12914,11 +13319,41 @@ helpers.classPrivateFieldSet = helper("7.0.0-beta.0")` return value; } `; +helpers.classPrivateFieldDestructureSet = helper("7.4.4")` + export default function _classPrivateFieldDestructureSet(receiver, privateMap) { + if (!privateMap.has(receiver)) { + throw new TypeError("attempted to set private field on non-instance"); + } + var descriptor = privateMap.get(receiver); + if (descriptor.set) { + if (!("__destrObj" in descriptor)) { + descriptor.__destrObj = { + set value(v) { + descriptor.set.call(receiver, v) + }, + }; + } + return descriptor.__destrObj; + } else { + if (!descriptor.writable) { + // This should only throw in strict mode, but class bodies are + // always strict and private fields can only be used inside + // class bodies. + throw new TypeError("attempted to set read only private field"); + } + + return descriptor; + } + } +`; helpers.classStaticPrivateFieldSpecGet = helper("7.0.2")` export default function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } + if (descriptor.get) { + return descriptor.get.call(receiver); + } return descriptor.value; } `; @@ -12927,13 +13362,18 @@ helpers.classStaticPrivateFieldSpecSet = helper("7.0.2")` if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } - if (!descriptor.writable) { - // This should only throw in strict mode, but class bodies are - // always strict and private fields can only be used inside - // class bodies. - throw new TypeError("attempted to set read only private field"); + if (descriptor.set) { + descriptor.set.call(receiver, value); + } else { + if (!descriptor.writable) { + // This should only throw in strict mode, but class bodies are + // always strict and private fields can only be used inside + // class bodies. + throw new TypeError("attempted to set read only private field"); + } + descriptor.value = value; } - descriptor.value = value; + return value; } `; @@ -13644,16 +14084,17 @@ helpers.wrapRegExp = helper("7.2.6")` export default function _wrapRegExp(re, groups) { _wrapRegExp = function(re, groups) { - return new BabelRegExp(re, groups); + return new BabelRegExp(re, undefined, groups); }; var _RegExp = wrapNativeSuper(RegExp); var _super = RegExp.prototype; var _groups = new WeakMap(); - function BabelRegExp(re, groups) { - var _this = _RegExp.call(this, re); - _groups.set(_this, groups); + function BabelRegExp(re, flags, groups) { + var _this = _RegExp.call(this, re, flags); + // if the regex is recreated with 'g' flag + _groups.set(_this, groups || _groups.get(re)); return _this; } inherits(BabelRegExp, _RegExp); @@ -13707,7 +14148,7 @@ helpers.wrapRegExp = helper("7.2.6")` return _wrapRegExp.apply(this, arguments); } `; -},{"@babel/template":83}],69:[function(require,module,exports){ +},{"@babel/template":88}],71:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -13716,31 +14157,18 @@ Object.defineProperty(exports, "__esModule", { exports.get = get; exports.minVersion = minVersion; exports.getDependencies = getDependencies; +exports.ensure = ensure; exports.default = exports.list = void 0; -function _traverse() { - const data = _interopRequireDefault(require("@babel/traverse")); - - _traverse = function () { - return data; - }; - - return data; -} - -function t() { - const data = _interopRequireWildcard(require("@babel/types")); - - t = function () { - return data; - }; +var _traverse = _interopRequireDefault(require("@babel/traverse")); - return data; -} +var t = _interopRequireWildcard(require("@babel/types")); var _helpers = _interopRequireDefault(require("./helpers")); -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -13764,7 +14192,7 @@ function getHelperMetadata(file) { const exportBindingAssignments = []; const importPaths = []; const importBindingsReferences = []; - (0, _traverse().default)(file, { + (0, _traverse.default)(file, { ImportDeclaration(child) { const name = child.node.source.value; @@ -13809,7 +14237,7 @@ function getHelperMetadata(file) { } }); - (0, _traverse().default)(file, { + (0, _traverse.default)(file, { Program(path) { const bindings = path.scope.getAllBindings(); Object.keys(bindings).forEach(name => { @@ -13893,7 +14321,7 @@ function permuteHelperAST(file, metadata, id, localBindings, getDependency) { toRename[exportName] = id.name; } - (0, _traverse().default)(file, { + (0, _traverse.default)(file, { Program(path) { const exp = path.get(exportPath); const imps = importPaths.map(p => path.get(p)); @@ -13904,18 +14332,18 @@ function permuteHelperAST(file, metadata, id, localBindings, getDependency) { if (decl.isFunctionDeclaration()) { exp.replaceWith(decl); } else { - exp.replaceWith(t().variableDeclaration("var", [t().variableDeclarator(id, decl.node)])); + exp.replaceWith(t.variableDeclaration("var", [t.variableDeclarator(id, decl.node)])); } } else if (id.type === "MemberExpression") { if (decl.isFunctionDeclaration()) { exportBindingAssignments.forEach(assignPath => { const assign = path.get(assignPath); - assign.replaceWith(t().assignmentExpression("=", id, assign.node)); + assign.replaceWith(t.assignmentExpression("=", id, assign.node)); }); exp.replaceWith(decl); - path.pushContainer("body", t().expressionStatement(t().assignmentExpression("=", id, t().identifier(exportName)))); + path.pushContainer("body", t.expressionStatement(t.assignmentExpression("=", id, t.identifier(exportName)))); } else { - exp.replaceWith(t().expressionStatement(t().assignmentExpression("=", id, decl.node))); + exp.replaceWith(t.expressionStatement(t.assignmentExpression("=", id, decl.node))); } } else { throw new Error("Unexpected helper format."); @@ -13928,7 +14356,7 @@ function permuteHelperAST(file, metadata, id, localBindings, getDependency) { for (const path of imps) path.remove(); for (const path of impsBindingRefs) { - const node = t().cloneNode(dependenciesRefs[path.node.name]); + const node = t.cloneNode(dependenciesRefs[path.node.name]); path.replaceWith(node); } @@ -13952,7 +14380,7 @@ function loadHelper(name) { } const fn = () => { - return t().file(helper.ast()); + return t.file(helper.ast()); }; const metadata = getHelperMetadata(fn()); @@ -13989,11 +14417,15 @@ function getDependencies(name) { return Array.from(loadHelper(name).dependencies.values()); } +function ensure(name) { + loadHelper(name); +} + const list = Object.keys(_helpers.default).map(name => name.replace(/^_/, "")).filter(name => name !== "__esModule"); exports.list = list; var _default = get; exports.default = _default; -},{"./helpers":68,"@babel/traverse":92,"@babel/types":155}],70:[function(require,module,exports){ +},{"./helpers":70,"@babel/traverse":97,"@babel/types":160}],72:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -14003,39 +14435,17 @@ exports.shouldHighlight = shouldHighlight; exports.getChalk = getChalk; exports.default = highlight; -function _jsTokens() { - const data = _interopRequireWildcard(require("js-tokens")); +var _jsTokens = _interopRequireWildcard(require("js-tokens")); - _jsTokens = function () { - return data; - }; +var _esutils = _interopRequireDefault(require("esutils")); - return data; -} - -function _esutils() { - const data = _interopRequireDefault(require("esutils")); - - _esutils = function () { - return data; - }; - - return data; -} - -function _chalk() { - const data = _interopRequireDefault(require("chalk")); - - _chalk = function () { - return data; - }; - - return data; -} +var _chalk = _interopRequireDefault(require("chalk")); 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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function getDefs(chalk) { return { @@ -14057,10 +14467,10 @@ const BRACKET = /^[()[\]{}]$/; function getTokenType(match) { const [offset, text] = match.slice(-2); - const token = (0, _jsTokens().matchToToken)(match); + const token = (0, _jsTokens.matchToToken)(match); if (token.type === "name") { - if (_esutils().default.keyword.isReservedWordES6(token.value)) { + if (_esutils.default.keyword.isReservedWordES6(token.value)) { return "keyword"; } @@ -14085,7 +14495,7 @@ function getTokenType(match) { } function highlightTokens(defs, text) { - return text.replace(_jsTokens().default, function (...args) { + return text.replace(_jsTokens.default, function (...args) { const type = getTokenType(args); const colorize = defs[type]; @@ -14098,14 +14508,14 @@ function highlightTokens(defs, text) { } function shouldHighlight(options) { - return _chalk().default.supportsColor || options.forceColor; + return _chalk.default.supportsColor || options.forceColor; } function getChalk(options) { - let chalk = _chalk().default; + let chalk = _chalk.default; if (options.forceColor) { - chalk = new (_chalk().default.constructor)({ + chalk = new _chalk.default.constructor({ enabled: true, level: 1 }); @@ -14123,7 +14533,7 @@ function highlight(code, options = {}) { return code; } } -},{"chalk":199,"esutils":213,"js-tokens":221}],71:[function(require,module,exports){ +},{"chalk":204,"esutils":218,"js-tokens":227}],73:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); @@ -14278,7 +14688,11 @@ const types = { prefix, startsExpr }), - modulo: createBinop("%", 10), + modulo: new TokenType("%", { + beforeExpr, + binop: 10, + startsExpr + }), star: createBinop("*", 10), slash: createBinop("/", 10), exponent: new TokenType("**", { @@ -14381,17 +14795,18 @@ const types = { }) }; -const SCOPE_OTHER = 0b000000000, - SCOPE_PROGRAM = 0b000000001, - SCOPE_FUNCTION = 0b000000010, - SCOPE_ASYNC = 0b000000100, - SCOPE_GENERATOR = 0b000001000, - SCOPE_ARROW = 0b000010000, - SCOPE_SIMPLE_CATCH = 0b000100000, - SCOPE_SUPER = 0b001000000, - SCOPE_DIRECT_SUPER = 0b010000000, - SCOPE_CLASS = 0b100000000, - SCOPE_VAR = SCOPE_PROGRAM | SCOPE_FUNCTION; +const SCOPE_OTHER = 0b0000000000, + SCOPE_PROGRAM = 0b0000000001, + SCOPE_FUNCTION = 0b0000000010, + SCOPE_ASYNC = 0b0000000100, + SCOPE_GENERATOR = 0b0000001000, + SCOPE_ARROW = 0b0000010000, + SCOPE_SIMPLE_CATCH = 0b0000100000, + SCOPE_SUPER = 0b0001000000, + SCOPE_DIRECT_SUPER = 0b0010000000, + SCOPE_CLASS = 0b0100000000, + SCOPE_TS_MODULE = 0b1000000000, + SCOPE_VAR = SCOPE_PROGRAM | SCOPE_FUNCTION | SCOPE_TS_MODULE; function functionFlags(isAsync, isGenerator) { return SCOPE_FUNCTION | (isAsync ? SCOPE_ASYNC : 0) | (isGenerator ? SCOPE_GENERATOR : 0); } @@ -14412,11 +14827,20 @@ const BIND_CLASS = BIND_KIND_VALUE | BIND_KIND_TYPE | BIND_SCOPE_LEXICAL | BIND_ BIND_TS_INTERFACE = 0 | BIND_KIND_TYPE | 0 | BIND_FLAGS_CLASS, BIND_TS_TYPE = 0 | BIND_KIND_TYPE | 0 | 0, BIND_TS_ENUM = BIND_KIND_VALUE | BIND_KIND_TYPE | BIND_SCOPE_LEXICAL | BIND_FLAGS_TS_ENUM, - BIND_TS_FN_TYPE = 0 | 0 | 0 | BIND_FLAGS_TS_EXPORT_ONLY, + BIND_TS_AMBIENT = 0 | 0 | 0 | BIND_FLAGS_TS_EXPORT_ONLY, BIND_NONE = 0 | 0 | 0 | BIND_FLAGS_NONE, BIND_OUTSIDE = BIND_KIND_VALUE | 0 | 0 | BIND_FLAGS_NONE, BIND_TS_CONST_ENUM = BIND_TS_ENUM | BIND_FLAGS_TS_CONST_ENUM, - BIND_TS_NAMESPACE = BIND_TS_FN_TYPE; + BIND_TS_NAMESPACE = 0 | 0 | 0 | BIND_FLAGS_TS_EXPORT_ONLY; +const CLASS_ELEMENT_FLAG_STATIC = 0b100, + CLASS_ELEMENT_KIND_GETTER = 0b010, + CLASS_ELEMENT_KIND_SETTER = 0b001, + CLASS_ELEMENT_KIND_ACCESSOR = CLASS_ELEMENT_KIND_GETTER | CLASS_ELEMENT_KIND_SETTER; +const CLASS_ELEMENT_STATIC_GETTER = CLASS_ELEMENT_KIND_GETTER | CLASS_ELEMENT_FLAG_STATIC, + CLASS_ELEMENT_STATIC_SETTER = CLASS_ELEMENT_KIND_SETTER | CLASS_ELEMENT_FLAG_STATIC, + CLASS_ELEMENT_INSTANCE_GETTER = CLASS_ELEMENT_KIND_GETTER, + CLASS_ELEMENT_INSTANCE_SETTER = CLASS_ELEMENT_KIND_SETTER, + CLASS_ELEMENT_OTHER = 0; function isSimpleProperty(node) { return node != null && node.type === "Property" && node.kind === "init" && node.method === false; @@ -14441,6 +14865,13 @@ var estree = (superClass => class extends superClass { return node; } + estreeParseBigIntLiteral(value) { + const bigInt = typeof BigInt !== "undefined" ? BigInt(value) : null; + const node = this.estreeParseLiteral(bigInt); + node.bigint = String(node.value || value); + return node; + } + estreeParseLiteral(value) { return this.parseLiteral(value, "Literal"); } @@ -14480,27 +14911,25 @@ var estree = (superClass => class extends superClass { } else { this.raise(start, "setter must have exactly one formal parameter"); } - } - - if (prop.kind === "set" && prop.value.params[0].type === "RestElement") { + } else if (prop.kind === "set" && prop.value.params[0].type === "RestElement") { this.raise(start, "setter function argument must not be a rest parameter"); } } - checkLVal(expr, bindingType = BIND_NONE, checkClashes, contextDescription) { + checkLVal(expr, bindingType = BIND_NONE, checkClashes, contextDescription, disallowLetBinding) { switch (expr.type) { case "ObjectPattern": expr.properties.forEach(prop => { - this.checkLVal(prop.type === "Property" ? prop.value : prop, bindingType, checkClashes, "object destructuring pattern"); + this.checkLVal(prop.type === "Property" ? prop.value : prop, bindingType, checkClashes, "object destructuring pattern", disallowLetBinding); }); break; default: - super.checkLVal(expr, bindingType, checkClashes, contextDescription); + super.checkLVal(expr, bindingType, checkClashes, contextDescription, disallowLetBinding); } } - checkPropClash(prop, propHash) { + checkDuplicatedProto(prop, protoRef, refExpressionErrors) { if (prop.type === "SpreadElement" || prop.computed || prop.method || prop.shorthand) { return; } @@ -14509,30 +14938,16 @@ var estree = (superClass => class extends superClass { const name = key.type === "Identifier" ? key.name : String(key.value); if (name === "__proto__" && prop.kind === "init") { - if (propHash.proto) { - this.raise(key.start, "Redefinition of __proto__ property"); - } - - propHash.proto = true; - } - } - - isStrictBody(node) { - const isBlockStatement = node.body.type === "BlockStatement"; - - if (isBlockStatement && node.body.body.length > 0) { - for (let _i = 0, _node$body$body = node.body.body; _i < _node$body$body.length; _i++) { - const directive = _node$body$body[_i]; - - if (directive.type === "ExpressionStatement" && directive.expression.type === "Literal") { - if (directive.expression.value === "use strict") return true; + if (protoRef.used) { + if (refExpressionErrors && refExpressionErrors.doubleProto === -1) { + refExpressionErrors.doubleProto = key.start; } else { - break; + this.raise(key.start, "Redefinition of __proto__ property"); } } - } - return false; + protoRef.used = true; + } } isValidDirective(stmt) { @@ -14564,15 +14979,18 @@ var estree = (superClass => class extends superClass { classBody.body.push(method); } - parseExprAtom(refShorthandDefaultPos) { + parseExprAtom(refExpressionErrors) { switch (this.state.type) { - case types.regexp: - return this.estreeParseRegExpLiteral(this.state.value); - case types.num: case types.string: return this.estreeParseLiteral(this.state.value); + case types.regexp: + return this.estreeParseRegExpLiteral(this.state.value); + + case types.bigint: + return this.estreeParseBigIntLiteral(this.state.value); + case types._null: return this.estreeParseLiteral(null); @@ -14583,7 +15001,7 @@ var estree = (superClass => class extends superClass { return this.estreeParseLiteral(false); default: - return super.parseExprAtom(refShorthandDefaultPos); + return super.parseExprAtom(refExpressionErrors); } } @@ -14622,8 +15040,8 @@ var estree = (superClass => class extends superClass { return node; } - parseObjectProperty(prop, startPos, startLoc, isPattern, refShorthandDefaultPos) { - const node = super.parseObjectProperty(prop, startPos, startLoc, isPattern, refShorthandDefaultPos); + parseObjectProperty(prop, startPos, startLoc, isPattern, refExpressionErrors) { + const node = super.parseObjectProperty(prop, startPos, startLoc, isPattern, refExpressionErrors); if (node) { node.kind = "init"; @@ -14633,23 +15051,44 @@ var estree = (superClass => class extends superClass { return node; } - toAssignable(node, isBinding, contextDescription) { + toAssignable(node) { if (isSimpleProperty(node)) { - this.toAssignable(node.value, isBinding, contextDescription); + this.toAssignable(node.value); return node; } - return super.toAssignable(node, isBinding, contextDescription); + return super.toAssignable(node); } - toAssignableObjectExpressionProp(prop, isBinding, isLast) { + toAssignableObjectExpressionProp(prop, isLast) { if (prop.kind === "get" || prop.kind === "set") { - this.raise(prop.key.start, "Object pattern can't contain getter or setter"); + throw this.raise(prop.key.start, "Object pattern can't contain getter or setter"); } else if (prop.method) { - this.raise(prop.key.start, "Object pattern can't contain methods"); + throw this.raise(prop.key.start, "Object pattern can't contain methods"); } else { - super.toAssignableObjectExpressionProp(prop, isBinding, isLast); + super.toAssignableObjectExpressionProp(prop, isLast); + } + } + + finishCallExpression(node, optional) { + super.finishCallExpression(node, optional); + + if (node.callee.type === "Import") { + node.type = "ImportExpression"; + node.source = node.arguments[0]; + delete node.arguments; + delete node.callee; + } + + return node; + } + + toReferencedListDeep(exprList, isParenthesizedExpr) { + if (!exprList) { + return; } + + super.toReferencedListDeep(exprList, isParenthesizedExpr); } }); @@ -14793,15 +15232,18 @@ const reservedWords = { strictBind: ["eval", "arguments"] }; const reservedWordsStrictSet = new Set(reservedWords.strict); -const reservedWordsStrictBindSet = new Set(reservedWords.strict.concat(reservedWords.strictBind)); +const reservedWordsStrictBindSet = new Set(reservedWords.strictBind); const isReservedWord = (word, inModule) => { return inModule && word === "await" || word === "enum"; }; function isStrictReservedWord(word, inModule) { return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word); } +function isStrictBindOnlyReservedWord(word) { + return reservedWordsStrictBindSet.has(word); +} function isStrictBindReservedWord(word, inModule) { - return isReservedWord(word, inModule) || reservedWordsStrictBindSet.has(word); + return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word); } function isKeyword(word) { return keywords.has(word); @@ -14858,7 +15300,7 @@ function isIdentifierChar(code) { return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes); } -const reservedTypes = ["any", "bool", "boolean", "empty", "false", "mixed", "null", "number", "static", "string", "true", "typeof", "void", "interface", "extends", "_"]; +const reservedTypes = new Set(["_", "any", "bool", "boolean", "empty", "extends", "false", "interface", "mixed", "null", "number", "static", "string", "true", "typeof", "void"]); function isEsModuleType(bodyElement) { return bodyElement.type === "DeclareExportAllDeclaration" || bodyElement.type === "DeclareExportDeclaration" && (!bodyElement.declaration || bodyElement.declaration.type !== "TypeAlias" && bodyElement.declaration.type !== "InterfaceDeclaration"); @@ -14901,8 +15343,12 @@ var flow = (superClass => class extends superClass { return this.getPluginOption("flow", "all") || this.flowPragma === "flow"; } + shouldParseEnums() { + return !!this.getPluginOption("flow", "enums"); + } + finishToken(type, val) { - if (!(type === types.string || type === types.semi)) { + if (type !== types.string && type !== types.semi && type !== types.interpreterDirective) { if (this.flowPragma === undefined) { this.flowPragma = null; } @@ -15005,7 +15451,7 @@ var flow = (superClass => class extends superClass { [typeNode.returnType, node.predicate] = this.flowParseTypeAndPredicateInitialiser(); typeContainer.typeAnnotation = this.finishNode(typeNode, "FunctionTypeAnnotation"); id.typeAnnotation = this.finishNode(typeContainer, "TypeAnnotation"); - this.finishNode(id, id.type); + this.resetEndLocation(id); this.semicolon(); return this.finishNode(node, "DeclareFunction"); } @@ -15017,12 +15463,12 @@ var flow = (superClass => class extends superClass { return this.flowParseDeclareFunction(node); } else if (this.match(types._var)) { return this.flowParseDeclareVariable(node); - } else if (this.isContextual("module")) { - if (this.lookahead().type === types.dot) { + } else if (this.eatContextual("module")) { + if (this.match(types.dot)) { return this.flowParseDeclareModuleExports(node); } else { if (insideModule) { - this.unexpected(null, "`declare module` cannot be used inside another `declare module`"); + this.raise(this.state.lastTokStart, "`declare module` cannot be used inside another `declare module`"); } return this.flowParseDeclareModule(node); @@ -15043,12 +15489,12 @@ var flow = (superClass => class extends superClass { flowParseDeclareVariable(node) { this.next(); node.id = this.flowParseTypeAnnotatableIdentifier(true); + this.scope.declareName(node.id.name, BIND_VAR, node.id.start); this.semicolon(); return this.finishNode(node, "DeclareVariable"); } flowParseDeclareModule(node) { - this.next(); this.scope.enter(SCOPE_OTHER); if (this.match(types.string)) { @@ -15065,13 +15511,12 @@ var flow = (superClass => class extends superClass { let bodyNode = this.startNode(); if (this.match(types._import)) { - const lookahead = this.lookahead(); + this.next(); - if (lookahead.value !== "type" && lookahead.value !== "typeof") { - this.unexpected(null, "Imports within a `declare module` body must always be `import type` or `import typeof`"); + if (!this.isContextual("type") && !this.match(types._typeof)) { + this.raise(this.state.lastTokStart, "Imports within a `declare module` body must always be `import type` or `import typeof`"); } - this.next(); this.parseImport(bodyNode); } else { this.expectContextual("declare", "Only declares and type imports are allowed inside declare module"); @@ -15090,16 +15535,16 @@ var flow = (superClass => class extends superClass { body.forEach(bodyElement => { if (isEsModuleType(bodyElement)) { if (kind === "CommonJS") { - this.unexpected(bodyElement.start, errorMessage); + this.raise(bodyElement.start, errorMessage); } kind = "ES"; } else if (bodyElement.type === "DeclareModuleExports") { if (hasModuleExport) { - this.unexpected(bodyElement.start, "Duplicate `declare module.exports` statement"); + this.raise(bodyElement.start, "Duplicate `declare module.exports` statement"); } - if (kind === "ES") this.unexpected(bodyElement.start, errorMessage); + if (kind === "ES") this.raise(bodyElement.start, errorMessage); kind = "CommonJS"; hasModuleExport = true; } @@ -15150,8 +15595,7 @@ var flow = (superClass => class extends superClass { } flowParseDeclareModuleExports(node) { - this.expectContextual("module"); - this.expect(types.dot); + this.next(); this.expectContextual("exports"); node.typeAnnotation = this.flowParseTypeAnnotation(); this.semicolon(); @@ -15161,13 +15605,15 @@ var flow = (superClass => class extends superClass { flowParseDeclareTypeAlias(node) { this.next(); this.flowParseTypeAlias(node); - return this.finishNode(node, "DeclareTypeAlias"); + node.type = "DeclareTypeAlias"; + return node; } flowParseDeclareOpaqueType(node) { this.next(); this.flowParseOpaqueType(node, true); - return this.finishNode(node, "DeclareOpaqueType"); + node.type = "DeclareOpaqueType"; + return node; } flowParseDeclareInterface(node) { @@ -15177,7 +15623,8 @@ var flow = (superClass => class extends superClass { } flowParseInterfaceish(node, isClass = false) { - node.id = this.flowParseRestrictedIdentifier(!isClass); + node.id = this.flowParseRestrictedIdentifier(!isClass, true); + this.scope.declareName(node.id.name, isClass ? BIND_FUNCTION : BIND_LEXICAL, node.id.start); if (this.isRelational("<")) { node.typeParameters = this.flowParseTypeParameterDeclaration(); @@ -15240,23 +15687,28 @@ var flow = (superClass => class extends superClass { checkNotUnderscore(word) { if (word === "_") { - throw this.unexpected(null, "`_` is only allowed as a type argument to call or new"); + this.raise(this.state.start, "`_` is only allowed as a type argument to call or new"); } } - checkReservedType(word, startLoc) { - if (reservedTypes.indexOf(word) > -1) { + checkReservedType(word, startLoc, declaration) { + if (!reservedTypes.has(word)) return; + + if (declaration) { this.raise(startLoc, `Cannot overwrite reserved type ${word}`); + return; } + + this.raise(startLoc, `Unexpected reserved type ${word}`); } - flowParseRestrictedIdentifier(liberal) { - this.checkReservedType(this.state.value, this.state.start); + flowParseRestrictedIdentifier(liberal, declaration) { + this.checkReservedType(this.state.value, this.state.start, declaration); return this.parseIdentifier(liberal); } flowParseTypeAlias(node) { - node.id = this.flowParseRestrictedIdentifier(); + node.id = this.flowParseRestrictedIdentifier(false, true); this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.start); if (this.isRelational("<")) { @@ -15272,7 +15724,7 @@ var flow = (superClass => class extends superClass { flowParseOpaqueType(node, declare) { this.expectContextual("type"); - node.id = this.flowParseRestrictedIdentifier(true); + node.id = this.flowParseRestrictedIdentifier(true, true); this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.start); if (this.isRelational("<")) { @@ -15297,11 +15749,7 @@ var flow = (superClass => class extends superClass { return this.finishNode(node, "OpaqueType"); } - flowParseTypeParameter(allowDefault = true, requireDefault = false) { - if (!allowDefault && requireDefault) { - throw new Error("Cannot disallow a default value (`allowDefault`) while also requiring it (`requireDefault`)."); - } - + flowParseTypeParameter(requireDefault = false) { const nodeStart = this.state.start; const node = this.startNode(); const variance = this.flowParseVariance(); @@ -15311,22 +15759,18 @@ var flow = (superClass => class extends superClass { node.bound = ident.typeAnnotation; if (this.match(types.eq)) { - if (allowDefault) { - this.eat(types.eq); - node.default = this.flowParseType(); - } else { - this.unexpected(); - } + this.eat(types.eq); + node.default = this.flowParseType(); } else { if (requireDefault) { - this.unexpected(nodeStart, "Type parameter declaration needs a default, since a preceding type parameter declaration has a default."); + this.raise(nodeStart, "Type parameter declaration needs a default, since a preceding type parameter declaration has a default."); } } return this.finishNode(node, "TypeParameter"); } - flowParseTypeParameterDeclaration(allowDefault = true) { + flowParseTypeParameterDeclaration() { const oldInType = this.state.inType; const node = this.startNode(); node.params = []; @@ -15341,7 +15785,7 @@ var flow = (superClass => class extends superClass { let defaultRequired = false; do { - const typeParameter = this.flowParseTypeParameter(allowDefault, defaultRequired); + const typeParameter = this.flowParseTypeParameter(defaultRequired); node.params.push(typeParameter); if (typeParameter.default) { @@ -15472,7 +15916,7 @@ var flow = (superClass => class extends superClass { node.typeParameters = null; if (this.isRelational("<")) { - node.typeParameters = this.flowParseTypeParameterDeclaration(false); + node.typeParameters = this.flowParseTypeParameterDeclaration(); } this.expect(types.parenL); @@ -15534,6 +15978,7 @@ var flow = (superClass => class extends superClass { while (!this.match(endDelim)) { let isStatic = false; let protoStart = null; + let inexactStart = null; const node = this.startNode(); if (allowProto && this.isContextual("proto")) { @@ -15593,16 +16038,21 @@ var flow = (superClass => class extends superClass { } } - const propOrInexact = this.flowParseObjectTypeProperty(node, isStatic, protoStart, variance, kind, allowSpread, allowInexact); + const propOrInexact = this.flowParseObjectTypeProperty(node, isStatic, protoStart, variance, kind, allowSpread, allowInexact != null ? allowInexact : !exact); if (propOrInexact === null) { inexact = true; + inexactStart = this.state.lastTokStart; } else { nodeStart.properties.push(propOrInexact); } } this.flowObjectTypeSemicolon(); + + if (inexactStart && !this.match(types.braceR) && !this.match(types.braceBarR)) { + this.raise(inexactStart, "Explicit inexact syntax must appear at the end of an inexact object"); + } } this.expect(endDelim); @@ -15617,33 +16067,33 @@ var flow = (superClass => class extends superClass { } flowParseObjectTypeProperty(node, isStatic, protoStart, variance, kind, allowSpread, allowInexact) { - if (this.match(types.ellipsis)) { - if (!allowSpread) { - this.unexpected(null, "Spread operator cannot appear in class or interface definitions"); - } + if (this.eat(types.ellipsis)) { + const isInexactToken = this.match(types.comma) || this.match(types.semi) || this.match(types.braceR) || this.match(types.braceBarR); - if (protoStart != null) { - this.unexpected(protoStart); - } + if (isInexactToken) { + if (!allowSpread) { + this.raise(this.state.lastTokStart, "Explicit inexact syntax cannot appear in class or interface definitions"); + } else if (!allowInexact) { + this.raise(this.state.lastTokStart, "Explicit inexact syntax cannot appear inside an explicit exact object type"); + } - if (variance) { - this.unexpected(variance.start, "Spread properties cannot have variance"); - } + if (variance) { + this.raise(variance.start, "Explicit inexact syntax cannot have variance"); + } - this.expect(types.ellipsis); - const isInexactToken = this.eat(types.comma) || this.eat(types.semi); + return null; + } - if (this.match(types.braceR)) { - if (allowInexact) return null; - this.unexpected(null, "Explicit inexact syntax is only allowed inside inexact objects"); + if (!allowSpread) { + this.raise(this.state.lastTokStart, "Spread operator cannot appear in class or interface definitions"); } - if (this.match(types.braceBarR)) { - this.unexpected(null, "Explicit inexact syntax cannot appear inside an explicit exact object type"); + if (protoStart != null) { + this.unexpected(protoStart); } - if (isInexactToken) { - this.unexpected(null, "Explicit inexact syntax must appear at the end of an inexact object"); + if (variance) { + this.raise(variance.start, "Spread properties cannot have variance"); } node.argument = this.flowParseType(); @@ -15715,12 +16165,12 @@ var flow = (superClass => class extends superClass { flowParseQualifiedTypeIdentifier(startPos, startLoc, id) { startPos = startPos || this.state.start; startLoc = startLoc || this.state.startLoc; - let node = id || this.parseIdentifier(); + let node = id || this.flowParseRestrictedIdentifier(true); while (this.eat(types.dot)) { const node2 = this.startNodeAt(startPos, startLoc); node2.qualification = node; - node2.id = this.parseIdentifier(); + node2.id = this.flowParseRestrictedIdentifier(true); node = this.finishNode(node2, "QualifiedTypeIdentifier"); } @@ -15878,11 +16328,14 @@ var flow = (superClass => class extends superClass { }); case types.bracketL: - return this.flowParseTupleType(); + this.state.noAnonFunctionType = false; + type = this.flowParseTupleType(); + this.state.noAnonFunctionType = oldNoAnonFunctionType; + return type; case types.relational: if (this.state.value === "<") { - node.typeParameters = this.flowParseTypeParameterDeclaration(false); + node.typeParameters = this.flowParseTypeParameterDeclaration(); this.expect(types.parenL); tmp = this.flowParseFunctionTypeParams(); node.params = tmp.params; @@ -15947,11 +16400,15 @@ var flow = (superClass => class extends superClass { if (this.state.value === "-") { this.next(); - if (!this.match(types.num)) { - this.unexpected(null, `Unexpected token, expected "number"`); + if (this.match(types.num)) { + return this.parseLiteral(-this.state.value, "NumberLiteralTypeAnnotation", node.start, node.loc.start); } - return this.parseLiteral(-this.state.value, "NumberLiteralTypeAnnotation", node.start, node.loc.start); + if (this.match(types.bigint)) { + return this.parseLiteral(-this.state.value, "BigIntLiteralTypeAnnotation", node.start, node.loc.start); + } + + throw this.raise(this.state.start, `Unexpected token, expected "number" or "bigint"`); } this.unexpected(); @@ -15959,6 +16416,9 @@ var flow = (superClass => class extends superClass { case types.num: return this.parseLiteral(this.state.value, "NumberLiteralTypeAnnotation"); + case types.bigint: + return this.parseLiteral(this.state.value, "BigIntLiteralTypeAnnotation"); + case types._void: this.next(); return this.finishNode(node, "VoidTypeAnnotation"); @@ -16088,7 +16548,7 @@ var flow = (superClass => class extends superClass { if (this.match(types.colon)) { ident.typeAnnotation = this.flowParseTypeAnnotation(); - this.finishNode(ident, ident.type); + this.resetEndLocation(ident); } return ident; @@ -16096,7 +16556,8 @@ var flow = (superClass => class extends superClass { typeCastToParameter(node) { node.expression.typeAnnotation = node.typeAnnotation; - return this.finishNodeAt(node.expression, node.expression.type, node.typeAnnotation.end, node.typeAnnotation.loc.end); + this.resetEndLocation(node.expression, node.typeAnnotation.end, node.typeAnnotation.loc.end); + return node.expression; } flowParseVariance() { @@ -16141,6 +16602,10 @@ var flow = (superClass => class extends superClass { const node = this.startNode(); this.next(); return this.flowParseInterface(node); + } else if (this.shouldParseEnums() && this.isContextual("enum")) { + const node = this.startNode(); + this.next(); + return this.flowParseEnumDeclaration(node); } else { const stmt = super.parseStatement(context, topLevel); @@ -16173,34 +16638,40 @@ var flow = (superClass => class extends superClass { } shouldParseExportDeclaration() { - return this.isContextual("type") || this.isContextual("interface") || this.isContextual("opaque") || super.shouldParseExportDeclaration(); + return this.isContextual("type") || this.isContextual("interface") || this.isContextual("opaque") || this.shouldParseEnums() && this.isContextual("enum") || super.shouldParseExportDeclaration(); } isExportDefaultSpecifier() { - if (this.match(types.name) && (this.state.value === "type" || this.state.value === "interface" || this.state.value === "opaque")) { + if (this.match(types.name) && (this.state.value === "type" || this.state.value === "interface" || this.state.value === "opaque" || this.shouldParseEnums() && this.state.value === "enum")) { return false; } return super.isExportDefaultSpecifier(); } + parseExportDefaultExpression() { + if (this.shouldParseEnums() && this.isContextual("enum")) { + const node = this.startNode(); + this.next(); + return this.flowParseEnumDeclaration(node); + } + + return super.parseExportDefaultExpression(); + } + parseConditional(expr, noIn, startPos, startLoc, refNeedsArrowPos) { if (!this.match(types.question)) return expr; if (refNeedsArrowPos) { - const state = this.state.clone(); + const result = this.tryParse(() => super.parseConditional(expr, noIn, startPos, startLoc)); - try { - return super.parseConditional(expr, noIn, startPos, startLoc); - } catch (err) { - if (err instanceof SyntaxError) { - this.state = state; - refNeedsArrowPos.start = err.pos || this.state.start; - return expr; - } else { - throw err; - } + if (!result.node) { + refNeedsArrowPos.start = result.error.pos || this.state.start; + return expr; } + + if (result.error) this.state = result.failState; + return result.node; } this.expect(types.question); @@ -16243,10 +16714,9 @@ var flow = (superClass => class extends superClass { failed } = this.tryParseConditionalConsequent()); } - - this.getArrowLikeExpressions(consequent, true); } + this.getArrowLikeExpressions(consequent, true); this.state.noArrowAt = originalNoArrowAt; this.expect(types.colon); node.test = expr; @@ -16275,10 +16745,7 @@ var flow = (superClass => class extends superClass { if (node.type === "ArrowFunctionExpression") { if (node.typeParameters || !node.returnType) { - this.toAssignableList(node.params, true, "arrow function parameters"); - this.scope.enter(functionFlags(false, false) | SCOPE_ARROW); - super.checkParams(node, false, true); - this.scope.exit(); + this.finishArrowValidation(node); } else { arrows.push(node); } @@ -16291,21 +16758,20 @@ var flow = (superClass => class extends superClass { } if (disallowInvalid) { - for (let i = 0; i < arrows.length; i++) { - this.toAssignableList(node.params, true, "arrow function parameters"); - } - + arrows.forEach(node => this.finishArrowValidation(node)); return [arrows, []]; } - return partition(arrows, node => { - try { - this.toAssignableList(node.params, true, "arrow function parameters"); - return true; - } catch (err) { - return false; - } - }); + return partition(arrows, node => node.params.every(param => this.isAssignable(param, true))); + } + + finishArrowValidation(node) { + var _node$extra; + + this.toAssignableList(node.params, (_node$extra = node.extra) == null ? void 0 : _node$extra.trailingComma); + this.scope.enter(functionFlags(false, false) | SCOPE_ARROW); + super.checkParams(node, false, true); + this.scope.exit(); } forwardNoArrowParamsConversionAt(node, parse) { @@ -16327,6 +16793,7 @@ var flow = (superClass => class extends superClass { if (this.eat(types.question)) { node.optional = true; + this.resetEndLocation(node); } if (this.match(types.colon)) { @@ -16380,6 +16847,11 @@ var flow = (superClass => class extends superClass { const declarationNode = this.startNode(); this.next(); return this.flowParseInterface(declarationNode); + } else if (this.shouldParseEnums() && this.isContextual("enum")) { + node.exportKind = "value"; + const declarationNode = this.startNode(); + this.next(); + return this.flowParseEnumDeclaration(declarationNode); } else { return super.parseExportDeclaration(node); } @@ -16432,15 +16904,56 @@ var flow = (superClass => class extends superClass { } } - toAssignable(node, isBinding, contextDescription) { + isAssignable(node, isBinding) { + switch (node.type) { + case "Identifier": + case "ObjectPattern": + case "ArrayPattern": + case "AssignmentPattern": + return true; + + case "ObjectExpression": + { + const last = node.properties.length - 1; + return node.properties.every((prop, i) => { + return prop.type !== "ObjectMethod" && (i === last || prop.type === "SpreadElement") && this.isAssignable(prop); + }); + } + + case "ObjectProperty": + return this.isAssignable(node.value); + + case "SpreadElement": + return this.isAssignable(node.argument); + + case "ArrayExpression": + return node.elements.every(element => this.isAssignable(element)); + + case "AssignmentExpression": + return node.operator === "="; + + case "ParenthesizedExpression": + case "TypeCastExpression": + return this.isAssignable(node.expression); + + case "MemberExpression": + case "OptionalMemberExpression": + return !isBinding; + + default: + return false; + } + } + + toAssignable(node) { if (node.type === "TypeCastExpression") { - return super.toAssignable(this.typeCastToParameter(node), isBinding, contextDescription); + return super.toAssignable(this.typeCastToParameter(node)); } else { - return super.toAssignable(node, isBinding, contextDescription); + return super.toAssignable(node); } } - toAssignableList(exprList, isBinding, contextDescription) { + toAssignableList(exprList, trailingCommaPos) { for (let i = 0; i < exprList.length; i++) { const expr = exprList[i]; @@ -16449,7 +16962,7 @@ var flow = (superClass => class extends superClass { } } - return super.toAssignableList(exprList, isBinding, contextDescription); + return super.toAssignableList(exprList, trailingCommaPos); } toReferencedList(exprList, isParenthesizedExpr) { @@ -16506,7 +17019,7 @@ var flow = (superClass => class extends superClass { delete method.variance; if (this.isRelational("<")) { - method.typeParameters = this.flowParseTypeParameterDeclaration(false); + method.typeParameters = this.flowParseTypeParameterDeclaration(); } super.pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper); @@ -16552,14 +17065,14 @@ var flow = (superClass => class extends superClass { } } - parsePropertyName(node) { + parsePropertyName(node, isPrivateNameAllowed) { const variance = this.flowParseVariance(); - const key = super.parsePropertyName(node); + const key = super.parsePropertyName(node, isPrivateNameAllowed); node.variance = variance; return key; } - parseObjPropValue(prop, startPos, startLoc, isGenerator, isAsync, isPattern, refShorthandDefaultPos, containsEsc) { + parseObjPropValue(prop, startPos, startLoc, isGenerator, isAsync, isPattern, refExpressionErrors, containsEsc) { if (prop.variance) { this.unexpected(prop.variance.start); } @@ -16568,11 +17081,11 @@ var flow = (superClass => class extends superClass { let typeParameters; if (this.isRelational("<")) { - typeParameters = this.flowParseTypeParameterDeclaration(false); + typeParameters = this.flowParseTypeParameterDeclaration(); if (!this.match(types.parenL)) this.unexpected(); } - super.parseObjPropValue(prop, startPos, startLoc, isGenerator, isAsync, isPattern, refShorthandDefaultPos, containsEsc); + super.parseObjPropValue(prop, startPos, startLoc, isGenerator, isAsync, isPattern, refExpressionErrors, containsEsc); if (typeParameters) { (prop.value || prop).typeParameters = typeParameters; @@ -16582,7 +17095,7 @@ var flow = (superClass => class extends superClass { parseAssignableListItemTypes(param) { if (this.eat(types.question)) { if (param.type !== "Identifier") { - throw this.raise(param.start, "A binding pattern parameter cannot be optional in an implementation signature."); + this.raise(param.start, "A binding pattern parameter cannot be optional in an implementation signature."); } param.optional = true; @@ -16592,7 +17105,7 @@ var flow = (superClass => class extends superClass { param.typeAnnotation = this.flowParseTypeAnnotation(); } - this.finishNode(param, param.type); + this.resetEndLocation(param); return param; } @@ -16615,7 +17128,7 @@ var flow = (superClass => class extends superClass { } parseImportSpecifierLocal(node, specifier, type, contextDescription) { - specifier.local = hasTypeImportKind(node) ? this.flowParseRestrictedIdentifier(true) : this.parseIdentifier(); + specifier.local = hasTypeImportKind(node) ? this.flowParseRestrictedIdentifier(true, true) : this.parseIdentifier(); this.checkLVal(specifier.local, BIND_LEXICAL, undefined, contextDescription); node.specifiers.push(this.finishNode(specifier, type)); } @@ -16697,7 +17210,7 @@ var flow = (superClass => class extends superClass { } if (nodeIsTypeImport || specifierIsTypeImport) { - this.checkReservedType(specifier.local.name, specifier.local.start); + this.checkReservedType(specifier.local.name, specifier.local.start, true); } if (isBinding && !nodeIsTypeImport && !specifierIsTypeImport) { @@ -16712,7 +17225,7 @@ var flow = (superClass => class extends superClass { const kind = node.kind; if (kind !== "get" && kind !== "set" && this.isRelational("<")) { - node.typeParameters = this.flowParseTypeParameterDeclaration(false); + node.typeParameters = this.flowParseTypeParameterDeclaration(); } super.parseFunctionParams(node, allowModifiers); @@ -16723,7 +17236,7 @@ var flow = (superClass => class extends superClass { if (this.match(types.colon)) { decl.id.typeAnnotation = this.flowParseTypeAnnotation(); - this.finishNode(decl.id, decl.id.type); + this.resetEndLocation(decl.id); } } @@ -16742,60 +17255,59 @@ var flow = (superClass => class extends superClass { return this.match(types.colon) || super.shouldParseAsyncArrow(); } - parseMaybeAssign(noIn, refShorthandDefaultPos, afterLeftParse, refNeedsArrowPos) { - let jsxError = null; + parseMaybeAssign(noIn, refExpressionErrors, afterLeftParse, refNeedsArrowPos) { + let state = null; + let jsx; if (this.hasPlugin("jsx") && (this.match(types.jsxTagStart) || this.isRelational("<"))) { - const state = this.state.clone(); - - try { - return super.parseMaybeAssign(noIn, refShorthandDefaultPos, afterLeftParse, refNeedsArrowPos); - } catch (err) { - if (err instanceof SyntaxError) { - this.state = state; - const cLength = this.state.context.length; - - if (this.state.context[cLength - 1] === types$1.j_oTag) { - this.state.context.length -= 2; - } + state = this.state.clone(); + jsx = this.tryParse(() => super.parseMaybeAssign(noIn, refExpressionErrors, afterLeftParse, refNeedsArrowPos), state); + if (!jsx.error) return jsx.node; + const { + context + } = this.state; - jsxError = err; - } else { - throw err; - } + if (context[context.length - 1] === types$1.j_oTag) { + context.length -= 2; + } else if (context[context.length - 1] === types$1.j_expr) { + context.length -= 1; } } - if (jsxError != null || this.isRelational("<")) { - let arrowExpression; + if (jsx && jsx.error || this.isRelational("<")) { + state = state || this.state.clone(); let typeParameters; - - try { + const arrow = this.tryParse(() => { typeParameters = this.flowParseTypeParameterDeclaration(); - arrowExpression = this.forwardNoArrowParamsConversionAt(typeParameters, () => super.parseMaybeAssign(noIn, refShorthandDefaultPos, afterLeftParse, refNeedsArrowPos)); + const arrowExpression = this.forwardNoArrowParamsConversionAt(typeParameters, () => super.parseMaybeAssign(noIn, refExpressionErrors, afterLeftParse, refNeedsArrowPos)); arrowExpression.typeParameters = typeParameters; this.resetStartLocationFromNode(arrowExpression, typeParameters); - } catch (err) { - throw jsxError || err; + return arrowExpression; + }, state); + const arrowExpression = arrow.node && arrow.node.type === "ArrowFunctionExpression" ? arrow.node : null; + if (!arrow.error && arrowExpression) return arrowExpression; + + if (jsx && jsx.node) { + this.state = jsx.failState; + return jsx.node; } - if (arrowExpression.type === "ArrowFunctionExpression") { + if (arrowExpression) { + this.state = arrow.failState; return arrowExpression; - } else if (jsxError != null) { - throw jsxError; - } else { - this.raise(typeParameters.start, "Expected an arrow function after this type parameter declaration"); } + + if (jsx && jsx.thrown) throw jsx.error; + if (arrow.thrown) throw arrow.error; + throw this.raise(typeParameters.start, "Expected an arrow function after this type parameter declaration"); } - return super.parseMaybeAssign(noIn, refShorthandDefaultPos, afterLeftParse, refNeedsArrowPos); + return super.parseMaybeAssign(noIn, refExpressionErrors, afterLeftParse, refNeedsArrowPos); } parseArrow(node) { if (this.match(types.colon)) { - const state = this.state.clone(); - - try { + const result = this.tryParse(() => { const oldNoAnonFunctionType = this.state.noAnonFunctionType; this.state.noAnonFunctionType = true; const typeNode = this.startNode(); @@ -16803,14 +17315,11 @@ var flow = (superClass => class extends superClass { this.state.noAnonFunctionType = oldNoAnonFunctionType; if (this.canInsertSemicolon()) this.unexpected(); if (!this.match(types.arrow)) this.unexpected(); - node.returnType = typeNode.typeAnnotation ? this.finishNode(typeNode, "TypeAnnotation") : null; - } catch (err) { - if (err instanceof SyntaxError) { - this.state = state; - } else { - throw err; - } - } + return typeNode; + }); + if (result.thrown) return null; + if (result.error) this.state = result.failState; + node.returnType = result.node.typeAnnotation ? this.finishNode(result.node, "TypeAnnotation") : null; } return super.parseArrow(node); @@ -16833,7 +17342,7 @@ var flow = (superClass => class extends superClass { return; } - return super.checkParams(node, allowDuplicates, isArrowFunction); + return super.checkParams(...arguments); } parseParenAndDistinguishExpression(canBeArrow) { @@ -16849,30 +17358,29 @@ var flow = (superClass => class extends superClass { base = this.finishNode(node, "CallExpression"); } else if (base.type === "Identifier" && base.name === "async" && this.isRelational("<")) { const state = this.state.clone(); - let error; + const arrow = this.tryParse(abort => this.parseAsyncArrowWithTypeParameters(startPos, startLoc) || abort(), state); + if (!arrow.error && !arrow.aborted) return arrow.node; + const result = this.tryParse(() => super.parseSubscripts(base, startPos, startLoc, noCalls), state); + if (result.node && !result.error) return result.node; - try { - const node = this.parseAsyncArrowWithTypeParameters(startPos, startLoc); - if (node) return node; - } catch (e) { - error = e; + if (arrow.node) { + this.state = arrow.failState; + return arrow.node; } - this.state = state; - - try { - return super.parseSubscripts(base, startPos, startLoc, noCalls); - } catch (e) { - throw error || e; + if (result.node) { + this.state = result.failState; + return result.node; } + + throw arrow.error || result.error; } return super.parseSubscripts(base, startPos, startLoc, noCalls); } - parseSubscript(base, startPos, startLoc, noCalls, subscriptState, maybeAsyncArrow) { + parseSubscript(base, startPos, startLoc, noCalls, subscriptState) { if (this.match(types.questionDot) && this.isLookaheadRelational("<")) { - this.expectPlugin("optionalChaining"); subscriptState.optionalChainMember = true; if (noCalls) { @@ -16887,50 +17395,32 @@ var flow = (superClass => class extends superClass { this.expect(types.parenL); node.arguments = this.parseCallExpressionArguments(types.parenR, false); node.optional = true; - return this.finishNode(node, "OptionalCallExpression"); + return this.finishCallExpression(node, true); } else if (!noCalls && this.shouldParseTypes() && this.isRelational("<")) { const node = this.startNodeAt(startPos, startLoc); node.callee = base; - const state = this.state.clone(); - - try { + const result = this.tryParse(() => { node.typeArguments = this.flowParseTypeParameterInstantiationCallOrNew(); this.expect(types.parenL); node.arguments = this.parseCallExpressionArguments(types.parenR, false); + if (subscriptState.optionalChainMember) node.optional = false; + return this.finishCallExpression(node, subscriptState.optionalChainMember); + }); - if (subscriptState.optionalChainMember) { - node.optional = false; - return this.finishNode(node, "OptionalCallExpression"); - } - - return this.finishNode(node, "CallExpression"); - } catch (e) { - if (e instanceof SyntaxError) { - this.state = state; - } else { - throw e; - } + if (result.node) { + if (result.error) this.state = result.failState; + return result.node; } } - return super.parseSubscript(base, startPos, startLoc, noCalls, subscriptState, maybeAsyncArrow); + return super.parseSubscript(base, startPos, startLoc, noCalls, subscriptState); } parseNewArguments(node) { let targs = null; if (this.shouldParseTypes() && this.isRelational("<")) { - const state = this.state.clone(); - - try { - targs = this.flowParseTypeParameterInstantiationCallOrNew(); - } catch (e) { - if (e instanceof SyntaxError) { - this.state = state; - } else { - throw e; - } - } + targs = this.tryParse(() => this.flowParseTypeParameterInstantiationCallOrNew()).node; } node.typeArguments = targs; @@ -16972,7 +17462,7 @@ var flow = (superClass => class extends superClass { const fileNode = super.parseTopLevel(file, program); if (this.state.hasFlowComment) { - this.unexpected(null, "Unterminated flow-comment"); + this.raise(this.state.pos, "Unterminated flow-comment"); } return fileNode; @@ -16992,7 +17482,11 @@ var flow = (superClass => class extends superClass { if (this.state.hasFlowComment) { const end = this.input.indexOf("*-/", this.state.pos += 2); - if (end === -1) this.raise(this.state.pos - 2, "Unterminated comment"); + + if (end === -1) { + throw this.raise(this.state.pos - 2, "Unterminated comment"); + } + this.state.pos = end + 3; return; } @@ -17032,8 +17526,442 @@ var flow = (superClass => class extends superClass { const end = this.input.indexOf("*/", this.state.pos); if (end === -1) { - this.raise(this.state.pos, "Unterminated comment"); + throw this.raise(this.state.pos, "Unterminated comment"); + } + } + + flowEnumErrorBooleanMemberNotInitialized(pos, { + enumName, + memberName + }) { + this.raise(pos, `Boolean enum members need to be initialized. Use either \`${memberName} = true,\` ` + `or \`${memberName} = false,\` in enum \`${enumName}\`.`); + } + + flowEnumErrorInvalidMemberName(pos, { + enumName, + memberName + }) { + const suggestion = memberName[0].toUpperCase() + memberName.slice(1); + this.raise(pos, `Enum member names cannot start with lowercase 'a' through 'z'. Instead of using ` + `\`${memberName}\`, consider using \`${suggestion}\`, in enum \`${enumName}\`.`); + } + + flowEnumErrorDuplicateMemberName(pos, { + enumName, + memberName + }) { + this.raise(pos, `Enum member names need to be unique, but the name \`${memberName}\` has already been used ` + `before in enum \`${enumName}\`.`); + } + + flowEnumErrorInconsistentMemberValues(pos, { + enumName + }) { + this.raise(pos, `Enum \`${enumName}\` has inconsistent member initializers. Either use no initializers, or ` + `consistently use literals (either booleans, numbers, or strings) for all member initializers.`); + } + + flowEnumErrorInvalidExplicitType(pos, { + enumName, + suppliedType + }) { + const suggestion = `Use one of \`boolean\`, \`number\`, \`string\`, or \`symbol\` in ` + `enum \`${enumName}\`.`; + const message = suppliedType === null ? `Supplied enum type is not valid. ${suggestion}` : `Enum type \`${suppliedType}\` is not valid. ${suggestion}`; + return this.raise(pos, message); + } + + flowEnumErrorInvalidMemberInitializer(pos, { + enumName, + explicitType, + memberName + }) { + let message = null; + + switch (explicitType) { + case "boolean": + case "number": + case "string": + message = `Enum \`${enumName}\` has type \`${explicitType}\`, so the initializer of ` + `\`${memberName}\` needs to be a ${explicitType} literal.`; + break; + + case "symbol": + message = `Symbol enum members cannot be initialized. Use \`${memberName},\` in ` + `enum \`${enumName}\`.`; + break; + + default: + message = `The enum member initializer for \`${memberName}\` needs to be a literal (either ` + `a boolean, number, or string) in enum \`${enumName}\`.`; + } + + return this.raise(pos, message); + } + + flowEnumErrorNumberMemberNotInitialized(pos, { + enumName, + memberName + }) { + this.raise(pos, `Number enum members need to be initialized, e.g. \`${memberName} = 1\` in enum \`${enumName}\`.`); + } + + flowEnumErrorStringMemberInconsistentlyInitailized(pos, { + enumName + }) { + this.raise(pos, `String enum members need to consistently either all use initializers, or use no initializers, ` + `in enum \`${enumName}\`.`); + } + + flowEnumMemberInit() { + const startPos = this.state.start; + + const endOfInit = () => this.match(types.comma) || this.match(types.braceR); + + switch (this.state.type) { + case types.num: + { + const literal = this.parseLiteral(this.state.value, "NumericLiteral"); + + if (endOfInit()) { + return { + type: "number", + pos: literal.start, + value: literal + }; + } + + return { + type: "invalid", + pos: startPos + }; + } + + case types.string: + { + const literal = this.parseLiteral(this.state.value, "StringLiteral"); + + if (endOfInit()) { + return { + type: "string", + pos: literal.start, + value: literal + }; + } + + return { + type: "invalid", + pos: startPos + }; + } + + case types._true: + case types._false: + { + const literal = this.parseBooleanLiteral(); + + if (endOfInit()) { + return { + type: "boolean", + pos: literal.start, + value: literal + }; + } + + return { + type: "invalid", + pos: startPos + }; + } + + default: + return { + type: "invalid", + pos: startPos + }; + } + } + + flowEnumMemberRaw() { + const pos = this.state.start; + const id = this.parseIdentifier(true); + const init = this.eat(types.eq) ? this.flowEnumMemberInit() : { + type: "none", + pos + }; + return { + id, + init + }; + } + + flowEnumCheckExplicitTypeMismatch(pos, context, expectedType) { + const { + explicitType + } = context; + + if (explicitType === null) { + return; } + + if (explicitType !== expectedType) { + this.flowEnumErrorInvalidMemberInitializer(pos, context); + } + } + + flowEnumMembers({ + enumName, + explicitType + }) { + const seenNames = new Set(); + const members = { + booleanMembers: [], + numberMembers: [], + stringMembers: [], + defaultedMembers: [] + }; + + while (!this.match(types.braceR)) { + const memberNode = this.startNode(); + const { + id, + init + } = this.flowEnumMemberRaw(); + const memberName = id.name; + + if (memberName === "") { + continue; + } + + if (/^[a-z]/.test(memberName)) { + this.flowEnumErrorInvalidMemberName(id.start, { + enumName, + memberName + }); + } + + if (seenNames.has(memberName)) { + this.flowEnumErrorDuplicateMemberName(id.start, { + enumName, + memberName + }); + } + + seenNames.add(memberName); + const context = { + enumName, + explicitType, + memberName + }; + memberNode.id = id; + + switch (init.type) { + case "boolean": + { + this.flowEnumCheckExplicitTypeMismatch(init.pos, context, "boolean"); + memberNode.init = init.value; + members.booleanMembers.push(this.finishNode(memberNode, "EnumBooleanMember")); + break; + } + + case "number": + { + this.flowEnumCheckExplicitTypeMismatch(init.pos, context, "number"); + memberNode.init = init.value; + members.numberMembers.push(this.finishNode(memberNode, "EnumNumberMember")); + break; + } + + case "string": + { + this.flowEnumCheckExplicitTypeMismatch(init.pos, context, "string"); + memberNode.init = init.value; + members.stringMembers.push(this.finishNode(memberNode, "EnumStringMember")); + break; + } + + case "invalid": + { + throw this.flowEnumErrorInvalidMemberInitializer(init.pos, context); + } + + case "none": + { + switch (explicitType) { + case "boolean": + this.flowEnumErrorBooleanMemberNotInitialized(init.pos, context); + break; + + case "number": + this.flowEnumErrorNumberMemberNotInitialized(init.pos, context); + break; + + default: + members.defaultedMembers.push(this.finishNode(memberNode, "EnumDefaultedMember")); + } + } + } + + if (!this.match(types.braceR)) { + this.expect(types.comma); + } + } + + return members; + } + + flowEnumStringMembers(initializedMembers, defaultedMembers, { + enumName + }) { + if (initializedMembers.length === 0) { + return defaultedMembers; + } else if (defaultedMembers.length === 0) { + return initializedMembers; + } else if (defaultedMembers.length > initializedMembers.length) { + for (let _i = 0; _i < initializedMembers.length; _i++) { + const member = initializedMembers[_i]; + this.flowEnumErrorStringMemberInconsistentlyInitailized(member.start, { + enumName + }); + } + + return defaultedMembers; + } else { + for (let _i2 = 0; _i2 < defaultedMembers.length; _i2++) { + const member = defaultedMembers[_i2]; + this.flowEnumErrorStringMemberInconsistentlyInitailized(member.start, { + enumName + }); + } + + return initializedMembers; + } + } + + flowEnumParseExplicitType({ + enumName + }) { + if (this.eatContextual("of")) { + if (!this.match(types.name)) { + throw this.flowEnumErrorInvalidExplicitType(this.state.start, { + enumName, + suppliedType: null + }); + } + + const { + value + } = this.state; + this.next(); + + if (value !== "boolean" && value !== "number" && value !== "string" && value !== "symbol") { + this.flowEnumErrorInvalidExplicitType(this.state.start, { + enumName, + suppliedType: value + }); + } + + return value; + } + + return null; + } + + flowEnumBody(node, { + enumName, + nameLoc + }) { + const explicitType = this.flowEnumParseExplicitType({ + enumName + }); + this.expect(types.braceL); + const members = this.flowEnumMembers({ + enumName, + explicitType + }); + + switch (explicitType) { + case "boolean": + node.explicitType = true; + node.members = members.booleanMembers; + this.expect(types.braceR); + return this.finishNode(node, "EnumBooleanBody"); + + case "number": + node.explicitType = true; + node.members = members.numberMembers; + this.expect(types.braceR); + return this.finishNode(node, "EnumNumberBody"); + + case "string": + node.explicitType = true; + node.members = this.flowEnumStringMembers(members.stringMembers, members.defaultedMembers, { + enumName + }); + this.expect(types.braceR); + return this.finishNode(node, "EnumStringBody"); + + case "symbol": + node.members = members.defaultedMembers; + this.expect(types.braceR); + return this.finishNode(node, "EnumSymbolBody"); + + default: + { + const empty = () => { + node.members = []; + this.expect(types.braceR); + return this.finishNode(node, "EnumStringBody"); + }; + + node.explicitType = false; + const boolsLen = members.booleanMembers.length; + const numsLen = members.numberMembers.length; + const strsLen = members.stringMembers.length; + const defaultedLen = members.defaultedMembers.length; + + if (!boolsLen && !numsLen && !strsLen && !defaultedLen) { + return empty(); + } else if (!boolsLen && !numsLen) { + node.members = this.flowEnumStringMembers(members.stringMembers, members.defaultedMembers, { + enumName + }); + this.expect(types.braceR); + return this.finishNode(node, "EnumStringBody"); + } else if (!numsLen && !strsLen && boolsLen >= defaultedLen) { + for (let _i3 = 0, _members$defaultedMem = members.defaultedMembers; _i3 < _members$defaultedMem.length; _i3++) { + const member = _members$defaultedMem[_i3]; + this.flowEnumErrorBooleanMemberNotInitialized(member.start, { + enumName, + memberName: member.id.name + }); + } + + node.members = members.booleanMembers; + this.expect(types.braceR); + return this.finishNode(node, "EnumBooleanBody"); + } else if (!boolsLen && !strsLen && numsLen >= defaultedLen) { + for (let _i4 = 0, _members$defaultedMem2 = members.defaultedMembers; _i4 < _members$defaultedMem2.length; _i4++) { + const member = _members$defaultedMem2[_i4]; + this.flowEnumErrorNumberMemberNotInitialized(member.start, { + enumName, + memberName: member.id.name + }); + } + + node.members = members.numberMembers; + this.expect(types.braceR); + return this.finishNode(node, "EnumNumberBody"); + } else { + this.flowEnumErrorInconsistentMemberValues(nameLoc, { + enumName + }); + return empty(); + } + } + } + } + + flowParseEnumDeclaration(node) { + const id = this.parseIdentifier(); + node.id = id; + node.body = this.flowEnumBody(this.startNode(), { + enumName: id.name, + nameLoc: id.start + }); + return this.finishNode(node, "EnumDeclaration"); } }); @@ -17352,7 +18280,7 @@ var jsx = (superClass => class extends superClass { for (;;) { if (this.state.pos >= this.length) { - this.raise(this.state.start, "Unterminated JSX contents"); + throw this.raise(this.state.start, "Unterminated JSX contents"); } const ch = this.input.charCodeAt(this.state.pos); @@ -17414,7 +18342,7 @@ var jsx = (superClass => class extends superClass { for (;;) { if (this.state.pos >= this.length) { - this.raise(this.state.start, "Unterminated string constant"); + throw this.raise(this.state.start, "Unterminated string constant"); } const ch = this.input.charCodeAt(this.state.pos); @@ -17522,6 +18450,10 @@ var jsx = (superClass => class extends superClass { const startLoc = this.state.startLoc; let node = this.jsxParseNamespacedName(); + if (node.type === "JSXNamespacedName") { + return node; + } + while (this.eat(types.dot)) { const newNode = this.startNodeAt(startPos, startLoc); newNode.object = node; @@ -17537,14 +18469,16 @@ var jsx = (superClass => class extends superClass { switch (this.state.type) { case types.braceL: - node = this.jsxParseExpressionContainer(); + node = this.startNode(); + this.next(); + node = this.jsxParseExpressionContainer(node); if (node.expression.type === "JSXEmptyExpression") { - throw this.raise(node.start, "JSX attributes must only be assigned a non-empty expression"); - } else { - return node; + this.raise(node.start, "JSX attributes must only be assigned a non-empty expression"); } + return node; + case types.jsxTagStart: case types.string: return this.parseExprAtom(); @@ -17559,19 +18493,14 @@ var jsx = (superClass => class extends superClass { return this.finishNodeAt(node, "JSXEmptyExpression", this.state.start, this.state.startLoc); } - jsxParseSpreadChild() { - const node = this.startNode(); - this.expect(types.braceL); - this.expect(types.ellipsis); + jsxParseSpreadChild(node) { + this.next(); node.expression = this.parseExpression(); this.expect(types.braceR); return this.finishNode(node, "JSXSpreadChild"); } - jsxParseExpressionContainer() { - const node = this.startNode(); - this.next(); - + jsxParseExpressionContainer(node) { if (this.match(types.braceR)) { node.expression = this.jsxParseEmptyExpression(); } else { @@ -17662,13 +18591,18 @@ var jsx = (superClass => class extends superClass { break; case types.braceL: - if (this.lookahead().type === types.ellipsis) { - children.push(this.jsxParseSpreadChild()); - } else { - children.push(this.jsxParseExpressionContainer()); - } + { + const node = this.startNode(); + this.next(); + + if (this.match(types.ellipsis)) { + children.push(this.jsxParseSpreadChild(node)); + } else { + children.push(this.jsxParseExpressionContainer(node)); + } - break; + break; + } default: throw this.unexpected(); @@ -17696,8 +18630,8 @@ var jsx = (superClass => class extends superClass { node.children = children; - if (this.match(types.relational) && this.state.value === "<") { - this.raise(this.state.start, "Adjacent JSX elements must be wrapped in an enclosing tag. " + "Did you want a JSX fragment <>...?"); + if (this.isRelational("<")) { + throw this.raise(this.state.start, "Adjacent JSX elements must be wrapped in an enclosing tag. " + "Did you want a JSX fragment <>...?"); } return isFragment(openingElement) ? this.finishNode(node, "JSXFragment") : this.finishNode(node, "JSXElement"); @@ -17710,7 +18644,7 @@ var jsx = (superClass => class extends superClass { return this.jsxParseElementAt(startPos, startLoc); } - parseExprAtom(refShortHandDefaultPos) { + parseExprAtom(refExpressionErrors) { if (this.match(types.jsxText)) { return this.parseLiteral(this.state.value, "JSXText"); } else if (this.match(types.jsxTagStart)) { @@ -17719,7 +18653,7 @@ var jsx = (superClass => class extends superClass { this.finishToken(types.jsxTagStart); return this.jsxParseElement(); } else { - return super.parseExprAtom(refShortHandDefaultPos); + return super.parseExprAtom(refExpressionErrors); } } @@ -17791,6 +18725,7 @@ class ScopeHandler { constructor(raise, inModule) { this.scopeStack = []; this.undefinedExports = new Map(); + this.undefinedPrivateNames = new Map(); this.raise = raise; this.inModule = inModule; } @@ -17804,7 +18739,17 @@ class ScopeHandler { } get inAsync() { - return (this.currentVarScope().flags & SCOPE_ASYNC) > 0; + for (let i = this.scopeStack.length - 1;; i--) { + const scope = this.scopeStack[i]; + const isVarScope = scope.flags & SCOPE_VAR; + const isClassScope = scope.flags & SCOPE_CLASS; + + if (isClassScope && !isVarScope) { + return false; + } else if (isVarScope) { + return (scope.flags & SCOPE_ASYNC) > 0; + } + } } get allowSuper() { @@ -17815,6 +18760,10 @@ class ScopeHandler { return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0; } + get inClass() { + return (this.currentThisScope().flags & SCOPE_CLASS) > 0; + } + get inNonArrowFunction() { return (this.currentThisScope().flags & SCOPE_FUNCTION) > 0; } @@ -18082,6 +19031,24 @@ var typescript = (superClass => class extends superClass { return undefined; } + tsParseModifiers(allowedModifiers) { + const modifiers = Object.create(null); + + while (true) { + const startPos = this.state.start; + const modifier = this.tsParseModifier(allowedModifiers); + if (!modifier) break; + + if (Object.hasOwnProperty.call(modifiers, modifier)) { + this.raise(startPos, `Duplicate modifier: '${modifier}'`); + } + + modifiers[modifier] = true; + } + + return modifiers; + } + tsIsListTerminator(kind) { switch (kind) { case "EnumMembers": @@ -18115,10 +19082,6 @@ var typescript = (superClass => class extends superClass { return nonNull(this.tsParseDelimitedListWorker(kind, parseElement, true)); } - tsTryParseDelimitedList(kind, parseElement) { - return this.tsParseDelimitedListWorker(kind, parseElement, false); - } - tsParseDelimitedListWorker(kind, parseElement, expectSuccess) { const result = []; @@ -18179,7 +19142,7 @@ var typescript = (superClass => class extends superClass { this.expect(types.parenL); if (!this.match(types.string)) { - throw this.unexpected(null, "Argument in a type import must be a string literal"); + this.raise(this.state.start, "Argument in a type import must be a string literal"); } node.argument = this.parseExprAtom(); @@ -18297,9 +19260,9 @@ var typescript = (superClass => class extends superClass { } tsParseBindingListForSignature() { - return this.parseBindingList(types.parenR).map(pattern => { + return this.parseBindingList(types.parenR, 41).map(pattern => { if (pattern.type !== "Identifier" && pattern.type !== "RestElement" && pattern.type !== "ObjectPattern" && pattern.type !== "ArrayPattern") { - throw this.unexpected(pattern.start, `Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got ${pattern.type}`); + this.raise(pattern.start, "Name in a signature must be an Identifier, ObjectPattern or ArrayPattern," + `instead got ${pattern.type}`); } return pattern; @@ -18312,13 +19275,7 @@ var typescript = (superClass => class extends superClass { } } - tsParseSignatureMember(kind) { - const node = this.startNode(); - - if (kind === "TSConstructSignatureDeclaration") { - this.expect(types._new); - } - + tsParseSignatureMember(kind, node) { this.tsFillSignature(types.colon, node); this.tsParseTypeMemberSemicolon(); return this.finishNode(node, kind); @@ -18337,7 +19294,7 @@ var typescript = (superClass => class extends superClass { this.expect(types.bracketL); const id = this.parseIdentifier(); id.typeAnnotation = this.tsParseTypeAnnotation(); - this.finishNode(id, "Identifier"); + this.resetEndLocation(id); this.expect(types.bracketR); node.parameters = [id]; const type = this.tsTryParseTypeAnnotation(); @@ -18347,7 +19304,6 @@ var typescript = (superClass => class extends superClass { } tsParsePropertyOrMethodSignature(node, readonly) { - this.parsePropertyName(node); if (this.eat(types.question)) node.optional = true; const nodeAny = node; @@ -18367,15 +19323,24 @@ var typescript = (superClass => class extends superClass { } tsParseTypeMember() { + const node = this.startNode(); + if (this.match(types.parenL) || this.isRelational("<")) { - return this.tsParseSignatureMember("TSCallSignatureDeclaration"); + return this.tsParseSignatureMember("TSCallSignatureDeclaration", node); } - if (this.match(types._new) && this.tsLookAhead(this.tsIsStartOfConstructSignature.bind(this))) { - return this.tsParseSignatureMember("TSConstructSignatureDeclaration"); + if (this.match(types._new)) { + const id = this.startNode(); + this.next(); + + if (this.match(types.parenL) || this.isRelational("<")) { + return this.tsParseSignatureMember("TSConstructSignatureDeclaration", node); + } else { + node.key = this.createIdentifier(id, "new"); + return this.tsParsePropertyOrMethodSignature(node, false); + } } - const node = this.startNode(); const readonly = !!this.tsParseModifier(["readonly"]); const idx = this.tsTryParseIndexSignature(node); @@ -18384,14 +19349,10 @@ var typescript = (superClass => class extends superClass { return idx; } + this.parsePropertyName(node, false); return this.tsParsePropertyOrMethodSignature(node, readonly); } - tsIsStartOfConstructSignature() { - this.next(); - return this.match(types.parenL) || this.isRelational("<"); - } - tsParseTypeLiteral() { const node = this.startNode(); node.members = this.tsParseObjectTypeMembers(); @@ -18486,7 +19447,11 @@ var typescript = (superClass => class extends superClass { const restNode = this.startNode(); this.next(); restNode.typeAnnotation = this.tsParseType(); - this.checkCommaAfterRest(); + + if (this.match(types.comma) && this.lookaheadCharCode() !== 93) { + this.raiseRestNotLast(this.state.start); + } + return this.finishNode(restNode, "TSRestType"); } @@ -18544,13 +19509,23 @@ var typescript = (superClass => class extends superClass { const templateNode = this.parseTemplate(false); if (templateNode.expressions.length > 0) { - throw this.raise(templateNode.expressions[0].start, "Template literal types cannot have any substitution"); + this.raise(templateNode.expressions[0].start, "Template literal types cannot have any substitution"); } node.literal = templateNode; return this.finishNode(node, "TSLiteralType"); } + tsParseThisTypeOrThisTypePredicate() { + const thisKeyword = this.tsParseThisTypeNode(); + + if (this.isContextual("is") && !this.hasPrecedingLineBreak()) { + return this.tsParseThisTypePredicate(thisKeyword); + } else { + return thisKeyword; + } + } + tsParseNonArrayType() { switch (this.state.type) { case types.name: @@ -18559,7 +19534,7 @@ var typescript = (superClass => class extends superClass { { const type = this.match(types._void) ? "TSVoidKeyword" : this.match(types._null) ? "TSNullKeyword" : keywordTypeFromName(this.state.value); - if (type !== undefined && this.lookahead().type !== types.dot) { + if (type !== undefined && this.lookaheadCharCode() !== 46) { const node = this.startNode(); this.next(); return this.finishNode(node, type); @@ -18589,15 +19564,7 @@ var typescript = (superClass => class extends superClass { break; case types._this: - { - const thisKeyword = this.tsParseThisTypeNode(); - - if (this.isContextual("is") && !this.hasPrecedingLineBreak()) { - return this.tsParseThisTypePredicate(thisKeyword); - } else { - return thisKeyword; - } - } + return this.tsParseThisTypeOrThisTypePredicate(); case types._typeof: return this.tsParseTypeQuery(); @@ -18786,16 +19753,43 @@ var typescript = (superClass => class extends superClass { return this.tsInType(() => { const t = this.startNode(); this.expect(returnToken); + const asserts = this.tsTryParse(this.tsParseTypePredicateAsserts.bind(this)); + + if (asserts && this.match(types._this)) { + let thisTypePredicate = this.tsParseThisTypeOrThisTypePredicate(); + + if (thisTypePredicate.type === "TSThisType") { + const node = this.startNodeAtNode(t); + node.parameterName = thisTypePredicate; + node.asserts = true; + thisTypePredicate = this.finishNode(node, "TSTypePredicate"); + } else { + thisTypePredicate.asserts = true; + } + + t.typeAnnotation = thisTypePredicate; + return this.finishNode(t, "TSTypeAnnotation"); + } + const typePredicateVariable = this.tsIsIdentifier() && this.tsTryParse(this.tsParseTypePredicatePrefix.bind(this)); if (!typePredicateVariable) { - return this.tsParseTypeAnnotation(false, t); + if (!asserts) { + return this.tsParseTypeAnnotation(false, t); + } + + const node = this.startNodeAtNode(t); + node.parameterName = this.parseIdentifier(); + node.asserts = asserts; + t.typeAnnotation = this.finishNode(node, "TSTypePredicate"); + return this.finishNode(t, "TSTypeAnnotation"); } const type = this.tsParseTypeAnnotation(false); - const node = this.startNodeAtNode(typePredicateVariable); + const node = this.startNodeAtNode(t); node.parameterName = typePredicateVariable; node.typeAnnotation = type; + node.asserts = asserts; t.typeAnnotation = this.finishNode(node, "TSTypePredicate"); return this.finishNode(t, "TSTypeAnnotation"); }); @@ -18822,6 +19816,25 @@ var typescript = (superClass => class extends superClass { } } + tsParseTypePredicateAsserts() { + if (!this.match(types.name) || this.state.value !== "asserts" || this.hasPrecedingLineBreak()) { + return false; + } + + const containsEsc = this.state.containsEsc; + this.next(); + + if (!this.match(types.name) && !this.match(types._this)) { + return false; + } + + if (containsEsc) { + this.raise(this.state.lastTokStart, "Escape sequence in keyword asserts"); + } + + return true; + } + tsParseTypeAnnotation(eatColon = true, t = this.startNode()) { this.tsInType(() => { if (eatColon) this.expect(types.colon); @@ -19000,7 +20013,9 @@ var typescript = (superClass => class extends superClass { this.tsParseModuleOrNamespaceDeclaration(inner, true); node.body = inner; } else { + this.scope.enter(SCOPE_TS_MODULE); node.body = this.tsParseModuleBlock(); + this.scope.exit(); } return this.finishNode(node, "TSModuleDeclaration"); @@ -19017,7 +20032,9 @@ var typescript = (superClass => class extends superClass { } if (this.match(types.braceL)) { + this.scope.enter(SCOPE_TS_MODULE); node.body = this.tsParseModuleBlock(); + this.scope.exit(); } else { this.semicolon(); } @@ -19028,6 +20045,7 @@ var typescript = (superClass => class extends superClass { tsParseImportEqualsDeclaration(node, isExport) { node.isExport = isExport || false; node.id = this.parseIdentifier(); + this.checkLVal(node.id, BIND_LEXICAL, undefined, "import equals declaration"); this.expect(types.eq); node.moduleReference = this.tsParseModuleReference(); this.semicolon(); @@ -19035,7 +20053,7 @@ var typescript = (superClass => class extends superClass { } tsIsExternalModuleReference() { - return this.isContextual("require") && this.lookahead().type === types.parenL; + return this.isContextual("require") && this.lookaheadCharCode() === 40; } tsParseModuleReference() { @@ -19064,18 +20082,10 @@ var typescript = (superClass => class extends superClass { } tsTryParseAndCatch(f) { - const state = this.state.clone(); - - try { - return f(); - } catch (e) { - if (e instanceof SyntaxError) { - this.state = state; - return undefined; - } - - throw e; - } + const result = this.tryParse(abort => f() || abort()); + if (result.aborted || !result.node) return undefined; + if (result.error) this.state = result.failState; + return result.node; } tsTryParse(f) { @@ -19090,24 +20100,6 @@ var typescript = (superClass => class extends superClass { } } - nodeWithSamePosition(original, type) { - const node = this.startNodeAtNode(original); - node.type = type; - node.end = original.end; - node.loc.end = original.loc.end; - - if (original.leadingComments) { - node.leadingComments = original.leadingComments; - } - - if (original.trailingComments) { - node.trailingComments = original.trailingComments; - } - - if (original.innerComments) node.innerComments = original.innerComments; - return node; - } - tsTryParseDeclare(nany) { if (this.isLineTerminator()) { return; @@ -19126,6 +20118,7 @@ var typescript = (superClass => class extends superClass { return this.parseFunctionStatement(nany, false, true); case types._class: + nany.declare = true; return this.parseClass(nany, true, false); case types._const: @@ -19172,10 +20165,12 @@ var typescript = (superClass => class extends superClass { case "global": if (this.match(types.braceL)) { + this.scope.enter(SCOPE_TS_MODULE); const mod = node; mod.global = true; mod.id = expr; mod.body = this.tsParseModuleBlock(); + this.scope.exit(); return this.finishNode(mod, "TSModuleDeclaration"); } @@ -19256,6 +20251,10 @@ var typescript = (superClass => class extends superClass { } tsTryParseGenericAsyncArrowFunction(startPos, startLoc) { + if (!this.isRelational("<")) { + return undefined; + } + const res = this.tsTryParseAndCatch(() => { const node = this.startNodeAt(startPos, startLoc); node.typeParameters = this.tsParseTypeParameters(); @@ -19331,7 +20330,7 @@ var typescript = (superClass => class extends superClass { if (readonly) pp.readonly = readonly; if (elt.type !== "Identifier" && elt.type !== "AssignmentPattern") { - throw this.raise(pp.start, "A parameter property may not be declared using a binding pattern."); + this.raise(pp.start, "A parameter property may not be declared using a binding pattern."); } pp.parameter = elt; @@ -19360,15 +20359,15 @@ var typescript = (superClass => class extends superClass { super.parseFunctionBodyAndFinish(node, type, isMethod); } - checkFunctionStatementId(node) { + registerFunctionStatementId(node) { if (!node.body && node.id) { - this.checkLVal(node.id, BIND_TS_FN_TYPE, null, "function name"); + this.checkLVal(node.id, BIND_TS_AMBIENT, null, "function name"); } else { - super.checkFunctionStatementId(...arguments); + super.registerFunctionStatementId(...arguments); } } - parseSubscript(base, startPos, startLoc, noCalls, state, maybeAsyncArrow) { + parseSubscript(base, startPos, startLoc, noCalls, state) { if (!this.hasPrecedingLineBreak() && this.match(types.bang)) { this.state.exprAllowed = false; this.next(); @@ -19395,7 +20394,7 @@ var typescript = (superClass => class extends superClass { if (!noCalls && this.eat(types.parenL)) { node.arguments = this.parseCallExpressionArguments(types.parenR, false); node.typeParameters = typeArguments; - return this.finishCallExpression(node); + return this.finishCallExpression(node, state.optionalChainMember); } else if (this.match(types.backQuote)) { return this.parseTaggedTemplateExpression(startPos, startLoc, base, state, typeArguments); } @@ -19406,7 +20405,7 @@ var typescript = (superClass => class extends superClass { if (result) return result; } - return super.parseSubscript(base, startPos, startLoc, noCalls, state, maybeAsyncArrow); + return super.parseSubscript(base, startPos, startLoc, noCalls, state); } parseNewArguments(node) { @@ -19524,42 +20523,25 @@ var typescript = (superClass => class extends superClass { } parseClassMemberWithIsStatic(classBody, member, state, isStatic, constructorAllowsSuper) { - const methodOrProp = member; - const prop = member; - const propOrIdx = member; - let abstract = false, - readonly = false; - const mod = this.tsParseModifier(["abstract", "readonly"]); - - switch (mod) { - case "readonly": - readonly = true; - abstract = !!this.tsParseModifier(["abstract"]); - break; + const modifiers = this.tsParseModifiers(["abstract", "readonly", "declare"]); + Object.assign(member, modifiers); + const idx = this.tsTryParseIndexSignature(member); - case "abstract": - abstract = true; - readonly = !!this.tsParseModifier(["readonly"]); - break; - } + if (idx) { + classBody.body.push(idx); - if (abstract) methodOrProp.abstract = true; - if (readonly) propOrIdx.readonly = true; + if (modifiers.abstract) { + this.raise(member.start, "Index signatures cannot have the 'abstract' modifier"); + } - if (!abstract && !isStatic && !methodOrProp.accessibility) { - const idx = this.tsTryParseIndexSignature(member); + if (isStatic) { + this.raise(member.start, "Index signatures cannot have the 'static' modifier"); + } - if (idx) { - classBody.body.push(idx); - return; + if (member.accessibility) { + this.raise(member.start, `Index signatures cannot have an accessibility modifier ('${member.accessibility}')`); } - } - if (readonly) { - methodOrProp.static = isStatic; - this.parseClassPropertyName(prop); - this.parsePostMemberNameModifiers(methodOrProp); - this.pushClassProperty(classBody, prop); return; } @@ -19569,6 +20551,14 @@ var typescript = (superClass => class extends superClass { parsePostMemberNameModifiers(methodOrProp) { const optional = this.eat(types.question); if (optional) methodOrProp.optional = true; + + if (methodOrProp.readonly && this.match(types.parenL)) { + this.raise(methodOrProp.start, "Class methods cannot have the 'readonly' modifier"); + } + + if (methodOrProp.declare && this.match(types.parenL)) { + this.raise(methodOrProp.start, "Class methods cannot have the 'declare' modifier"); + } } parseExpressionStatement(node, expr) { @@ -19586,19 +20576,15 @@ var typescript = (superClass => class extends superClass { return super.parseConditional(expr, noIn, startPos, startLoc, refNeedsArrowPos); } - const state = this.state.clone(); + const result = this.tryParse(() => super.parseConditional(expr, noIn, startPos, startLoc)); - try { - return super.parseConditional(expr, noIn, startPos, startLoc); - } catch (err) { - if (!(err instanceof SyntaxError)) { - throw err; - } - - this.state = state; - refNeedsArrowPos.start = err.pos || this.state.start; + if (!result.node) { + refNeedsArrowPos.start = result.error.pos || this.state.start; return expr; } + + if (result.error) this.state = result.failState; + return result.node; } parseParenItem(node, startPos, startLoc) { @@ -19606,6 +20592,7 @@ var typescript = (superClass => class extends superClass { if (this.eat(types.question)) { node.optional = true; + this.resetEndLocation(node); } if (this.match(types.colon)) { @@ -19615,7 +20602,7 @@ var typescript = (superClass => class extends superClass { return this.finishNode(typeCastNode, "TSTypeCastExpression"); } - return this.finishNode(node, node.type); + return node; } parseExportDeclaration(node) { @@ -19645,21 +20632,43 @@ var typescript = (superClass => class extends superClass { return; } - super.parseClassId(...arguments); + super.parseClassId(node, isStatement, optionalId, node.declare ? BIND_TS_AMBIENT : BIND_CLASS); const typeParameters = this.tsTryParseTypeParameters(); if (typeParameters) node.typeParameters = typeParameters; } - parseClassProperty(node) { + parseClassPropertyAnnotation(node) { if (!node.optional && this.eat(types.bang)) { node.definite = true; } const type = this.tsTryParseTypeAnnotation(); if (type) node.typeAnnotation = type; + } + + parseClassProperty(node) { + this.parseClassPropertyAnnotation(node); + + if (node.declare && this.match(types.equal)) { + this.raise(this.state.start, "'declare' class fields cannot have an initializer"); + } + return super.parseClassProperty(node); } + parseClassPrivateProperty(node) { + if (node.abstract) { + this.raise(node.start, "Private elements cannot have the 'abstract' modifier."); + } + + if (node.accessibility) { + this.raise(node.start, `Private elements cannot have an accessibility modifier ('${node.accessibility}')`); + } + + this.parseClassPropertyAnnotation(node); + return super.parseClassPrivateProperty(node); + } + pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) { const typeParameters = this.tsTryParseTypeParameters(); if (typeParameters) method.typeParameters = typeParameters; @@ -19707,7 +20716,7 @@ var typescript = (superClass => class extends superClass { if (type) { decl.id.typeAnnotation = type; - this.finishNode(decl.id, decl.id.type); + this.resetEndLocation(decl.id); } } @@ -19720,90 +20729,95 @@ var typescript = (superClass => class extends superClass { } parseMaybeAssign(...args) { - let jsxError; + let state; + let jsx; + let typeCast; if (this.match(types.jsxTagStart)) { - const context = this.curContext(); - assert(context === types$1.j_oTag); - assert(this.state.context[this.state.context.length - 2] === types$1.j_expr); - const state = this.state.clone(); - - try { - return super.parseMaybeAssign(...args); - } catch (err) { - if (!(err instanceof SyntaxError)) { - throw err; - } + state = this.state.clone(); + jsx = this.tryParse(() => super.parseMaybeAssign(...args), state); + if (!jsx.error) return jsx.node; + const { + context + } = this.state; - this.state = state; - assert(this.curContext() === types$1.j_oTag); - this.state.context.pop(); - assert(this.curContext() === types$1.j_expr); - this.state.context.pop(); - jsxError = err; + if (context[context.length - 1] === types$1.j_oTag) { + context.length -= 2; + } else if (context[context.length - 1] === types$1.j_expr) { + context.length -= 1; } } - if (jsxError === undefined && !this.isRelational("<")) { + if (!(jsx && jsx.error) && !this.isRelational("<")) { return super.parseMaybeAssign(...args); } - let arrowExpression; let typeParameters; - const state = this.state.clone(); - - try { + state = state || this.state.clone(); + const arrow = this.tryParse(abort => { typeParameters = this.tsParseTypeParameters(); - arrowExpression = super.parseMaybeAssign(...args); + const expr = super.parseMaybeAssign(...args); - if (arrowExpression.type !== "ArrowFunctionExpression" || arrowExpression.extra && arrowExpression.extra.parenthesized) { - this.unexpected(); - } - } catch (err) { - if (!(err instanceof SyntaxError)) { - throw err; + if (expr.type !== "ArrowFunctionExpression" || expr.extra && expr.extra.parenthesized) { + abort(); } - if (jsxError) { - throw jsxError; + if (typeParameters && typeParameters.params.length !== 0) { + this.resetStartLocationFromNode(expr, typeParameters); } + expr.typeParameters = typeParameters; + return expr; + }, state); + if (!arrow.error && !arrow.aborted) return arrow.node; + + if (!jsx) { assert(!this.hasPlugin("jsx")); - this.state = state; - return super.parseMaybeAssign(...args); + typeCast = this.tryParse(() => super.parseMaybeAssign(...args), state); + if (!typeCast.error) return typeCast.node; + } + + if (jsx && jsx.node) { + this.state = jsx.failState; + return jsx.node; } - if (typeParameters && typeParameters.params.length !== 0) { - this.resetStartLocationFromNode(arrowExpression, typeParameters); + if (arrow.node) { + this.state = arrow.failState; + return arrow.node; } - arrowExpression.typeParameters = typeParameters; - return arrowExpression; + if (typeCast && typeCast.node) { + this.state = typeCast.failState; + return typeCast.node; + } + + if (jsx && jsx.thrown) throw jsx.error; + if (arrow.thrown) throw arrow.error; + if (typeCast && typeCast.thrown) throw typeCast.error; + throw jsx && jsx.error || arrow.error || typeCast && typeCast.error; } - parseMaybeUnary(refShorthandDefaultPos) { + parseMaybeUnary(refExpressionErrors) { if (!this.hasPlugin("jsx") && this.isRelational("<")) { return this.tsParseTypeAssertion(); } else { - return super.parseMaybeUnary(refShorthandDefaultPos); + return super.parseMaybeUnary(refExpressionErrors); } } parseArrow(node) { if (this.match(types.colon)) { - const state = this.state.clone(); - - try { + const result = this.tryParse(abort => { const returnType = this.tsParseTypeOrTypePredicateAnnotation(types.colon); - if (this.canInsertSemicolon()) this.unexpected(); - if (!this.match(types.arrow)) this.unexpected(); - node.returnType = returnType; - } catch (err) { - if (err instanceof SyntaxError) { - this.state = state; - } else { - throw err; - } + if (this.canInsertSemicolon() || !this.match(types.arrow)) abort(); + return returnType; + }); + if (result.aborted) return; + + if (!result.thrown) { + if (result.error) this.state = result.failState; + node.returnType = result.node; } } @@ -19813,7 +20827,7 @@ var typescript = (superClass => class extends superClass { parseAssignableListItemTypes(param) { if (this.eat(types.question)) { if (param.type !== "Identifier") { - throw this.raise(param.start, "A binding pattern parameter cannot be optional in an implementation signature."); + this.raise(param.start, "A binding pattern parameter cannot be optional in an implementation signature."); } param.optional = true; @@ -19821,25 +20835,26 @@ var typescript = (superClass => class extends superClass { const type = this.tsTryParseTypeAnnotation(); if (type) param.typeAnnotation = type; - return this.finishNode(param, param.type); + this.resetEndLocation(param); + return param; } - toAssignable(node, isBinding, contextDescription) { + toAssignable(node) { switch (node.type) { case "TSTypeCastExpression": - return super.toAssignable(this.typeCastToParameter(node), isBinding, contextDescription); + return super.toAssignable(this.typeCastToParameter(node)); case "TSParameterProperty": - return super.toAssignable(node, isBinding, contextDescription); + return super.toAssignable(node); case "TSAsExpression": case "TSNonNullExpression": case "TSTypeAssertion": - node.expression = this.toAssignable(node.expression, isBinding, contextDescription); + node.expression = this.toAssignable(node.expression); return node; default: - return super.toAssignable(node, isBinding, contextDescription); + return super.toAssignable(node); } } @@ -19916,7 +20931,7 @@ var typescript = (superClass => class extends superClass { } } - toAssignableList(exprList, isBinding, contextDescription) { + toAssignableList(exprList) { for (let i = 0; i < exprList.length; i++) { const expr = exprList[i]; if (!expr) continue; @@ -19928,24 +20943,30 @@ var typescript = (superClass => class extends superClass { case "TSAsExpression": case "TSTypeAssertion": - this.raise(expr.start, "Unexpected type cast in parameter position."); + if (!this.state.maybeInArrowParameters) { + exprList[i] = this.typeCastToParameter(expr); + } else { + this.raise(expr.start, "Unexpected type cast in parameter position."); + } + break; } } - return super.toAssignableList(exprList, isBinding, contextDescription); + return super.toAssignableList(...arguments); } typeCastToParameter(node) { node.expression.typeAnnotation = node.typeAnnotation; - return this.finishNodeAt(node.expression, node.expression.type, node.typeAnnotation.end, node.typeAnnotation.loc.end); + this.resetEndLocation(node.expression, node.typeAnnotation.end, node.typeAnnotation.loc.end); + return node.expression; } toReferencedList(exprList, isInParens) { for (let i = 0; i < exprList.length; i++) { const expr = exprList[i]; - if (expr && expr._exprListItem && expr.type === "TsTypeCastExpression") { + if (expr && expr.type === "TSTypeCastExpression") { this.raise(expr.start, "Did not expect a type annotation here."); } } @@ -19966,8 +20987,11 @@ var typescript = (superClass => class extends superClass { } jsxParseOpeningElementAfterName(node) { - const typeArguments = this.tsTryParseAndCatch(() => this.tsParseTypeArguments()); - if (typeArguments) node.typeParameters = typeArguments; + if (this.isRelational("<")) { + const typeArguments = this.tsTryParseAndCatch(() => this.tsParseTypeArguments()); + if (typeArguments) node.typeParameters = typeArguments; + } + return super.jsxParseOpeningElementAfterName(node); } @@ -19997,8 +21021,9 @@ var placeholders = (superClass => class extends superClass { } finishPlaceholder(node, expectedNode) { + const isFinished = !!(node.expectedNode && node.type === "Placeholder"); node.expectedNode = expectedNode; - return this.finishNode(node, "Placeholder"); + return isFinished ? node : this.finishNode(node, "Placeholder"); } getTokenFromCode(code) { @@ -20166,6 +21191,33 @@ var placeholders = (superClass => class extends superClass { }); +var v8intrinsic = (superClass => class extends superClass { + parseV8Intrinsic() { + if (this.match(types.modulo)) { + const v8IntrinsicStart = this.state.start; + const node = this.startNode(); + this.eat(types.modulo); + + if (this.match(types.name)) { + const name = this.parseIdentifierName(this.state.start); + const identifier = this.createIdentifier(node, name); + identifier.type = "V8IntrinsicIdentifier"; + + if (this.match(types.parenL)) { + return identifier; + } + } + + this.unexpected(v8IntrinsicStart); + } + } + + parseExprAtom() { + return this.parseV8Intrinsic() || super.parseExprAtom(...arguments); + } + +}); + function hasPlugin(plugins, name) { return plugins.some(plugin => { if (Array.isArray(plugin)) { @@ -20190,7 +21242,7 @@ function getPluginOption(plugins, name, option) { return null; } -const PIPELINE_PROPOSALS = ["minimal", "smart"]; +const PIPELINE_PROPOSALS = ["minimal", "smart", "fsharp"]; function validatePlugins(plugins) { if (hasPlugin(plugins, "decorators")) { if (hasPlugin(plugins, "decorators-legacy")) { @@ -20210,6 +21262,10 @@ function validatePlugins(plugins) { throw new Error("Cannot combine flow and typescript plugins."); } + if (hasPlugin(plugins, "placeholders") && hasPlugin(plugins, "v8intrinsic")) { + throw new Error("Cannot combine placeholders and v8intrinsic plugins."); + } + if (hasPlugin(plugins, "pipelineOperator") && !PIPELINE_PROPOSALS.includes(getPluginOption(plugins, "pipelineOperator", "proposal"))) { throw new Error("'pipelineOperator' requires 'proposal' option whose value should be one of: " + PIPELINE_PROPOSALS.map(p => `'${p}'`).join(", ")); } @@ -20219,6 +21275,7 @@ const mixinPlugins = { jsx, flow, typescript, + v8intrinsic, placeholders }; const mixinPluginNames = Object.keys(mixinPlugins); @@ -20231,11 +21288,13 @@ const defaultOptions = { allowReturnOutsideFunction: false, allowImportExportEverywhere: false, allowSuperOutsideMethod: false, + allowUndeclaredExports: false, plugins: [], strictMode: null, ranges: false, tokens: false, - createParenthesizedExpressions: false + createParenthesizedExpressions: false, + errorRecovery: false }; function getOptions(opts) { const options = {}; @@ -20279,6 +21338,7 @@ function getLineInfo(input, offset) { class BaseParser { constructor() { this.sawUnambiguousESM = false; + this.ambiguousScriptDifferentAst = false; } hasPlugin(name) { @@ -20302,6 +21362,59 @@ class CommentsParser extends BaseParser { this.state.leadingComments.push(comment); } + adjustCommentsAfterTrailingComma(node, elements, takeAllComments) { + if (this.state.leadingComments.length === 0) { + return; + } + + let lastElement = null; + let i = elements.length; + + while (lastElement === null && i > 0) { + lastElement = elements[--i]; + } + + if (lastElement === null) { + return; + } + + for (let j = 0; j < this.state.leadingComments.length; j++) { + if (this.state.leadingComments[j].end < this.state.commentPreviousNode.end) { + this.state.leadingComments.splice(j, 1); + j--; + } + } + + const newTrailingComments = []; + + for (let i = 0; i < this.state.leadingComments.length; i++) { + const leadingComment = this.state.leadingComments[i]; + + if (leadingComment.end < node.end) { + newTrailingComments.push(leadingComment); + + if (!takeAllComments) { + this.state.leadingComments.splice(i, 1); + i--; + } + } else { + if (node.trailingComments === undefined) { + node.trailingComments = []; + } + + node.trailingComments.push(leadingComment); + } + } + + if (takeAllComments) this.state.leadingComments = []; + + if (newTrailingComments.length > 0) { + lastElement.trailingComments = newTrailingComments; + } else if (lastElement.trailingComments !== undefined) { + lastElement.trailingComments = []; + } + } + processComment(node) { if (node.type === "Program" && node.body.length > 0) return; const stack = this.state.commentStack; @@ -20333,44 +21446,30 @@ class CommentsParser extends BaseParser { if (!lastChild && firstChild) lastChild = firstChild; - if (firstChild && this.state.leadingComments.length > 0) { - const lastComment = last(this.state.leadingComments); + if (firstChild) { + switch (node.type) { + case "ObjectExpression": + this.adjustCommentsAfterTrailingComma(node, node.properties); + break; - if (firstChild.type === "ObjectProperty") { - if (lastComment.start >= node.start) { - if (this.state.commentPreviousNode) { - for (j = 0; j < this.state.leadingComments.length; j++) { - if (this.state.leadingComments[j].end < this.state.commentPreviousNode.end) { - this.state.leadingComments.splice(j, 1); - j--; - } - } + case "ObjectPattern": + this.adjustCommentsAfterTrailingComma(node, node.properties, true); + break; - if (this.state.leadingComments.length > 0) { - firstChild.trailingComments = this.state.leadingComments; - this.state.leadingComments = []; - } - } - } - } else if (node.type === "CallExpression" && node.arguments && node.arguments.length) { - const lastArg = last(node.arguments); + case "CallExpression": + this.adjustCommentsAfterTrailingComma(node, node.arguments); + break; - if (lastArg && lastComment.start >= lastArg.start && lastComment.end <= node.end) { - if (this.state.commentPreviousNode) { - for (j = 0; j < this.state.leadingComments.length; j++) { - if (this.state.leadingComments[j].end < this.state.commentPreviousNode.end) { - this.state.leadingComments.splice(j, 1); - j--; - } - } + case "ArrayExpression": + this.adjustCommentsAfterTrailingComma(node, node.elements); + break; - if (this.state.leadingComments.length > 0) { - lastArg.trailingComments = this.state.leadingComments; - this.state.leadingComments = []; - } - } - } + case "ArrayPattern": + this.adjustCommentsAfterTrailingComma(node, node.elements, true); + break; } + } else if (this.state.commentPreviousNode && (this.state.commentPreviousNode.type === "ImportSpecifier" && node.type !== "ImportSpecifier" || this.state.commentPreviousNode.type === "ExportSpecifier" && node.type !== "ExportSpecifier")) { + this.adjustCommentsAfterTrailingComma(node, [this.state.commentPreviousNode]); } if (lastChild) { @@ -20439,11 +21538,17 @@ class CommentsParser extends BaseParser { } class LocationParser extends CommentsParser { + getLocationForPosition(pos) { + let loc; + if (pos === this.state.start) loc = this.state.startLoc;else if (pos === this.state.lastTokStart) loc = this.state.lastTokStartLoc;else if (pos === this.state.end) loc = this.state.endLoc;else if (pos === this.state.lastTokEnd) loc = this.state.lastTokEndLoc;else loc = getLineInfo(this.input, pos); + return loc; + } + raise(pos, message, { missingPluginNames, code } = {}) { - const loc = getLineInfo(this.input, pos); + const loc = this.getLocationForPosition(pos); message += ` (${loc.line}:${loc.column})`; const err = new SyntaxError(message); err.pos = pos; @@ -20457,36 +21562,40 @@ class LocationParser extends CommentsParser { err.code = code; } - throw err; + if (this.options.errorRecovery) { + if (!this.isLookahead) this.state.errors.push(err); + return err; + } else { + throw err; + } } } class State { constructor() { + this.errors = []; this.potentialArrowAt = -1; this.noArrowAt = []; this.noArrowParamsConversionAt = []; - this.commaAfterSpreadAt = -1; this.inParameters = false; this.maybeInArrowParameters = false; this.inPipeline = false; this.inType = false; this.noAnonFunctionType = false; this.inPropertyName = false; - this.inClassProperty = false; this.hasFlowComment = false; this.isIterator = false; this.topicContext = { maxNumOfResolvableTopics: 0, maxTopicIndex: null }; - this.classLevel = 0; + this.soloAwait = false; + this.inFSharpPipelineDirectBody = false; this.labels = []; this.decoratorStack = [[]]; - this.yieldPos = 0; - this.awaitPos = 0; - this.tokens = []; + this.yieldPos = -1; + this.awaitPos = -1; this.comments = []; this.trailingComments = []; this.leadingComments = []; @@ -20508,7 +21617,7 @@ class State { this.containsOctal = false; this.octalPosition = null; this.exportedIdentifiers = []; - this.invalidTemplateEscapePosition = null; + this.tokensLength = 0; } init(options) { @@ -20529,7 +21638,7 @@ class State { const key = keys[i]; let val = this[key]; - if ((!skipArrays || key === "context") && Array.isArray(val)) { + if (!skipArrays && Array.isArray(val)) { val = val.slice(); } @@ -20567,6 +21676,7 @@ class Token { class Tokenizer extends LocationParser { constructor(options, input) { super(); + this.tokens = []; this.state = new State(); this.state.init(options); this.input = input; @@ -20574,9 +21684,19 @@ class Tokenizer extends LocationParser { this.isLookahead = false; } + pushToken(token) { + this.tokens.length = this.state.tokensLength; + this.tokens.push(token); + ++this.state.tokensLength; + } + next() { - if (this.options.tokens && !this.isLookahead) { - this.state.tokens.push(new Token(this.state)); + if (!this.isLookahead) { + this.checkKeywordEscapes(); + + if (this.options.tokens) { + this.pushToken(new Token(this.state)); + } } this.state.lastTokEnd = this.state.end; @@ -20610,6 +21730,17 @@ class Tokenizer extends LocationParser { return curr; } + nextTokenStart() { + const thisTokEnd = this.state.pos; + skipWhiteSpace.lastIndex = thisTokEnd; + const skip = skipWhiteSpace.exec(this.input); + return thisTokEnd + skip[0].length; + } + + lookaheadCharCode() { + return this.input.charCodeAt(this.nextTokenStart()); + } + setStrict(strict) { this.state.strict = strict; if (!this.match(types.num) && !this.match(types.string)) return; @@ -20655,19 +21786,16 @@ class Tokenizer extends LocationParser { end: end, loc: new SourceLocation(startLoc, endLoc) }; - - if (!this.isLookahead) { - if (this.options.tokens) this.state.tokens.push(comment); - this.state.comments.push(comment); - this.addComment(comment); - } + if (this.options.tokens) this.pushToken(comment); + this.state.comments.push(comment); + this.addComment(comment); } skipBlockComment() { const startLoc = this.state.curPosition(); const start = this.state.pos; - const end = this.input.indexOf("*/", this.state.pos += 2); - if (end === -1) this.raise(this.state.pos - 2, "Unterminated comment"); + const end = this.input.indexOf("*/", this.state.pos + 2); + if (end === -1) throw this.raise(start, "Unterminated comment"); this.state.pos = end + 2; lineBreakG.lastIndex = start; let match; @@ -20677,6 +21805,7 @@ class Tokenizer extends LocationParser { this.state.lineStart = match.index + match[0].length; } + if (this.isLookahead) return; this.pushComment(true, this.input.slice(start + 2, end), start, this.state.pos, startLoc, this.state.curPosition()); } @@ -20686,11 +21815,12 @@ class Tokenizer extends LocationParser { let ch = this.input.charCodeAt(this.state.pos += startSkip); if (this.state.pos < this.length) { - while (ch !== 10 && ch !== 13 && ch !== 8232 && ch !== 8233 && ++this.state.pos < this.length) { + while (!isNewLine(ch) && ++this.state.pos < this.length) { ch = this.input.charCodeAt(this.state.pos); } } + if (this.isLookahead) return; this.pushComment(false, this.input.slice(start + startSkip, this.state.pos), start, this.state.pos, startLoc, this.state.curPosition()); } @@ -20751,7 +21881,7 @@ class Tokenizer extends LocationParser { const prevType = this.state.type; this.state.type = type; this.state.value = val; - this.updateContext(prevType); + if (!this.isLookahead) this.updateContext(prevType); } readToken_numberSign() { @@ -20763,17 +21893,13 @@ class Tokenizer extends LocationParser { const next = this.input.charCodeAt(nextPos); if (next >= 48 && next <= 57) { - this.raise(this.state.pos, "Unexpected digit after hash token"); + throw this.raise(this.state.pos, "Unexpected digit after hash token"); } - if ((this.hasPlugin("classPrivateProperties") || this.hasPlugin("classPrivateMethods")) && this.state.classLevel > 0) { - ++this.state.pos; - this.finishToken(types.hash); - return; - } else if (this.getPluginOption("pipelineOperator", "proposal") === "smart") { + if (this.hasPlugin("classPrivateProperties") || this.hasPlugin("classPrivateMethods") || this.getPluginOption("pipelineOperator", "proposal") === "smart") { this.finishOp(types.hash, 1); } else { - this.raise(this.state.pos, "Unexpected character '#'"); + throw this.raise(this.state.pos, "Unexpected character '#'"); } } @@ -20785,9 +21911,7 @@ class Tokenizer extends LocationParser { return; } - const next2 = this.input.charCodeAt(this.state.pos + 2); - - if (next === 46 && next2 === 46) { + if (next === 46 && this.input.charCodeAt(this.state.pos + 2) === 46) { this.state.pos += 3; this.finishToken(types.ellipsis); } else { @@ -20819,7 +21943,7 @@ class Tokenizer extends LocationParser { let ch = this.input.charCodeAt(this.state.pos); if (ch !== 33) return false; - while (ch !== 10 && ch !== 13 && ch !== 8232 && ch !== 8233 && ++this.state.pos < this.length) { + while (!isNewLine(ch) && ++this.state.pos < this.length) { ch = this.input.charCodeAt(this.state.pos); } @@ -21134,7 +22258,7 @@ class Tokenizer extends LocationParser { } - this.raise(this.state.pos, `Unexpected character '${String.fromCodePoint(code)}'`); + throw this.raise(this.state.pos, `Unexpected character '${String.fromCodePoint(code)}'`); } finishOp(type, size) { @@ -21149,13 +22273,13 @@ class Tokenizer extends LocationParser { for (;;) { if (this.state.pos >= this.length) { - this.raise(start, "Unterminated regular expression"); + throw this.raise(start, "Unterminated regular expression"); } const ch = this.input.charAt(this.state.pos); if (lineBreak.test(ch)) { - this.raise(start, "Unterminated regular expression"); + throw this.raise(start, "Unterminated regular expression"); } if (escaped) { @@ -21187,14 +22311,14 @@ class Tokenizer extends LocationParser { if (mods.indexOf(char) > -1) { this.raise(this.state.pos + 1, "Duplicate regular expression flag"); } - - ++this.state.pos; - mods += char; } else if (isIdentifierChar(charCode) || charCode === 92) { this.raise(this.state.pos + 1, "Invalid regular expression flag"); } else { break; } + + ++this.state.pos; + mods += char; } this.finishToken(types.regexp, { @@ -21203,10 +22327,11 @@ class Tokenizer extends LocationParser { }); } - readInt(radix, len) { + readInt(radix, len, forceLen, allowNumSeparator = true) { const start = this.state.pos; const forbiddenSiblings = radix === 16 ? forbiddenNumericSeparatorSiblings.hex : forbiddenNumericSeparatorSiblings.decBinOct; const allowedSiblings = radix === 16 ? allowedNumericSeparatorSiblings.hex : radix === 10 ? allowedNumericSeparatorSiblings.dec : radix === 8 ? allowedNumericSeparatorSiblings.oct : allowedNumericSeparatorSiblings.bin; + let invalid = false; let total = 0; for (let i = 0, e = len == null ? Infinity : len; i < e; ++i) { @@ -21214,16 +22339,18 @@ class Tokenizer extends LocationParser { let val; if (this.hasPlugin("numericSeparator")) { - const prev = this.input.charCodeAt(this.state.pos - 1); - const next = this.input.charCodeAt(this.state.pos + 1); - if (code === 95) { + const prev = this.input.charCodeAt(this.state.pos - 1); + const next = this.input.charCodeAt(this.state.pos + 1); + if (allowedSiblings.indexOf(next) === -1) { - this.raise(this.state.pos, "Invalid or unexpected token"); + this.raise(this.state.pos, "A numeric separator is only allowed between two digits"); + } else if (forbiddenSiblings.indexOf(prev) > -1 || forbiddenSiblings.indexOf(next) > -1 || Number.isNaN(next)) { + this.raise(this.state.pos, "A numeric separator is only allowed between two digits"); } - if (forbiddenSiblings.indexOf(prev) > -1 || forbiddenSiblings.indexOf(next) > -1 || Number.isNaN(next)) { - this.raise(this.state.pos, "Invalid or unexpected token"); + if (!allowNumSeparator) { + this.raise(this.state.pos, "Numeric separators are not allowed inside unicode escape sequences or hex escape sequences"); } ++this.state.pos; @@ -21241,12 +22368,23 @@ class Tokenizer extends LocationParser { val = Infinity; } - if (val >= radix) break; + if (val >= radix) { + if (this.options.errorRecovery && val <= 9) { + val = 0; + this.raise(this.state.start + i + 2, "Expected number in radix " + radix); + } else if (forceLen) { + val = 0; + invalid = true; + } else { + break; + } + } + ++this.state.pos; total = total * radix + val; } - if (this.state.pos === start || len != null && this.state.pos - start !== len) { + if (this.state.pos === start || len != null && this.state.pos - start !== len || invalid) { return null; } @@ -21271,7 +22409,7 @@ class Tokenizer extends LocationParser { } if (isIdentifierStart(this.input.codePointAt(this.state.pos))) { - this.raise(this.state.pos, "Identifier directly after number"); + throw this.raise(this.state.pos, "Identifier directly after number"); } if (isBigInt) { @@ -21287,6 +22425,7 @@ class Tokenizer extends LocationParser { const start = this.state.pos; let isFloat = false; let isBigInt = false; + let isNonOctalDecimalInt = false; if (!startsWithDot && this.readInt(10) === null) { this.raise(start, "Invalid number"); @@ -21301,6 +22440,7 @@ class Tokenizer extends LocationParser { if (/[89]/.test(this.input.slice(start, this.state.pos))) { octal = false; + isNonOctalDecimalInt = true; } } @@ -21325,16 +22465,27 @@ class Tokenizer extends LocationParser { next = this.input.charCodeAt(this.state.pos); } + if (this.hasPlugin("numericSeparator") && (octal || isNonOctalDecimalInt)) { + const underscorePos = this.input.slice(start, this.state.pos).indexOf("_"); + + if (underscorePos > 0) { + this.raise(underscorePos + start, "Numeric separator can not be used after leading 0"); + } + } + if (this.hasPlugin("bigInt")) { if (next === 110) { - if (isFloat || octal) this.raise(start, "Invalid BigIntLiteral"); + if (isFloat || octal || isNonOctalDecimalInt) { + this.raise(start, "Invalid BigIntLiteral"); + } + ++this.state.pos; isBigInt = true; } } if (isIdentifierStart(this.input.codePointAt(this.state.pos))) { - this.raise(this.state.pos, "Identifier directly after number"); + throw this.raise(this.state.pos, "Identifier directly after number"); } const str = this.input.slice(start, this.state.pos).replace(/[_n]/g, ""); @@ -21354,21 +22505,18 @@ class Tokenizer extends LocationParser { if (ch === 123) { const codePos = ++this.state.pos; - code = this.readHexChar(this.input.indexOf("}", this.state.pos) - this.state.pos, throwOnInvalid); + code = this.readHexChar(this.input.indexOf("}", this.state.pos) - this.state.pos, true, throwOnInvalid); ++this.state.pos; - if (code === null) { - --this.state.invalidTemplateEscapePosition; - } else if (code > 0x10ffff) { + if (code !== null && code > 0x10ffff) { if (throwOnInvalid) { this.raise(codePos, "Code point out of bounds"); } else { - this.state.invalidTemplateEscapePosition = codePos - 2; return null; } } } else { - code = this.readHexChar(4, throwOnInvalid); + code = this.readHexChar(4, false, throwOnInvalid); } return code; @@ -21380,7 +22528,7 @@ class Tokenizer extends LocationParser { for (;;) { if (this.state.pos >= this.length) { - this.raise(this.state.start, "Unterminated string constant"); + throw this.raise(this.state.start, "Unterminated string constant"); } const ch = this.input.charCodeAt(this.state.pos); @@ -21393,8 +22541,9 @@ class Tokenizer extends LocationParser { } else if (ch === 8232 || ch === 8233) { ++this.state.pos; ++this.state.curLine; + this.state.lineStart = this.state.pos; } else if (isNewLine(ch)) { - this.raise(this.state.start, "Unterminated string constant"); + throw this.raise(this.state.start, "Unterminated string constant"); } else { ++this.state.pos; } @@ -21411,7 +22560,7 @@ class Tokenizer extends LocationParser { for (;;) { if (this.state.pos >= this.length) { - this.raise(this.state.start, "Unterminated template"); + throw this.raise(this.state.start, "Unterminated template"); } const ch = this.input.charCodeAt(this.state.pos); @@ -21487,7 +22636,7 @@ class Tokenizer extends LocationParser { case 120: { - const code = this.readHexChar(2, throwOnInvalid); + const code = this.readHexChar(2, false, throwOnInvalid); return code === null ? null : String.fromCharCode(code); } @@ -21522,6 +22671,12 @@ class Tokenizer extends LocationParser { case 8233: return ""; + case 56: + case 57: + if (inTemplate) { + return null; + } + default: if (ch >= 48 && ch <= 55) { const codePos = this.state.pos - 1; @@ -21538,7 +22693,6 @@ class Tokenizer extends LocationParser { if (octalStr !== "0" || next === 56 || next === 57) { if (inTemplate) { - this.state.invalidTemplateEscapePosition = codePos; return null; } else if (this.state.strict) { this.raise(codePos, "Octal literal in strict mode"); @@ -21555,16 +22709,15 @@ class Tokenizer extends LocationParser { } } - readHexChar(len, throwOnInvalid) { + readHexChar(len, forceLen, throwOnInvalid) { const codePos = this.state.pos; - const n = this.readInt(16, len); + const n = this.readInt(16, len, forceLen, false); if (n === null) { if (throwOnInvalid) { this.raise(codePos, "Bad character escape sequence"); } else { this.state.pos = codePos - 1; - this.state.invalidTemplateEscapePosition = codePos - 1; } } @@ -21592,16 +22745,20 @@ class Tokenizer extends LocationParser { if (this.input.charCodeAt(++this.state.pos) !== 117) { this.raise(this.state.pos, "Expecting Unicode escape sequence \\uXXXX"); + continue; } ++this.state.pos; const esc = this.readCodePoint(true); - if (!identifierCheck(esc, true)) { - this.raise(escStart, "Invalid Unicode escape"); + if (esc !== null) { + if (!identifierCheck(esc)) { + this.raise(escStart, "Invalid Unicode escape"); + } + + word += String.fromCodePoint(esc); } - word += String.fromCodePoint(esc); chunkStart = this.state.pos; } else { break; @@ -21619,10 +22776,6 @@ class Tokenizer extends LocationParser { const word = this.readWord1(); const type = keywords.get(word) || types.name; - if (type.keyword && this.state.containsEsc) { - this.raise(this.state.pos, `Escape sequence in keyword ${word}`); - } - if (this.state.isIterator && (!this.isIterator(word) || !this.state.inType)) { this.raise(this.state.pos, `Invalid identifier ${word}`); } @@ -21630,6 +22783,14 @@ class Tokenizer extends LocationParser { this.finishToken(type, word); } + checkKeywordEscapes() { + const kw = this.state.type.keyword; + + if (kw && this.state.containsEsc) { + this.raise(this.state.start, `Escape sequence in keyword ${kw}`); + } + } + braceIsBlock(prevType) { const parent = this.curContext(); @@ -21692,8 +22853,18 @@ class UtilParser extends Tokenizer { } isLookaheadRelational(op) { - const l = this.lookahead(); - return l.type === types.relational && l.value === op; + const next = this.nextTokenStart(); + + if (this.input.charAt(next) === op) { + if (next + 1 === this.input.length) { + return true; + } + + const afterNext = this.input.charCodeAt(next + 1); + return afterNext !== op.charCodeAt(0) && afterNext !== 61; + } + + return false; } expectRelational(op) { @@ -21704,22 +22875,18 @@ class UtilParser extends Tokenizer { } } - eatRelational(op) { - if (this.isRelational(op)) { - this.next(); - return true; - } - - return false; - } - isContextual(name) { return this.match(types.name) && this.state.value === name && !this.state.containsEsc; } + isUnparsedContextual(nameStart, name) { + const nameEnd = nameStart + name.length; + return this.input.slice(nameStart, nameEnd) === name && (nameEnd === this.input.length || !isIdentifierChar(this.input.charCodeAt(nameEnd))); + } + isLookaheadContextual(name) { - const l = this.lookahead(); - return l.type === types.name && l.value === name; + const next = this.nextTokenStart(); + return this.isUnparsedContextual(next, name); } eatContextual(name) { @@ -21783,11 +22950,11 @@ class UtilParser extends Tokenizer { } checkYieldAwaitInDefaultParams() { - if (this.state.yieldPos && (!this.state.awaitPos || this.state.yieldPos < this.state.awaitPos)) { + if (this.state.yieldPos !== -1 && (this.state.awaitPos === -1 || this.state.yieldPos < this.state.awaitPos)) { this.raise(this.state.yieldPos, "Yield cannot be used as name inside a generator function"); } - if (this.state.awaitPos) { + if (this.state.awaitPos !== -1) { this.raise(this.state.awaitPos, "Await cannot be used as name inside an async function"); } } @@ -21811,6 +22978,88 @@ class UtilParser extends Tokenizer { return false; } + tryParse(fn, oldState = this.state.clone()) { + const abortSignal = { + node: null + }; + + try { + const node = fn((node = null) => { + abortSignal.node = node; + throw abortSignal; + }); + + if (this.state.errors.length > oldState.errors.length) { + const failState = this.state; + this.state = oldState; + return { + node, + error: failState.errors[oldState.errors.length], + thrown: false, + aborted: false, + failState + }; + } + + return { + node, + error: null, + thrown: false, + aborted: false, + failState: null + }; + } catch (error) { + const failState = this.state; + this.state = oldState; + + if (error instanceof SyntaxError) { + return { + node: null, + error, + thrown: true, + aborted: false, + failState + }; + } + + if (error === abortSignal) { + return { + node: abortSignal.node, + error: null, + thrown: false, + aborted: true, + failState + }; + } + + throw error; + } + } + + checkExpressionErrors(refExpressionErrors, andThrow) { + if (!refExpressionErrors) return false; + const { + shorthandAssign, + doubleProto + } = refExpressionErrors; + if (!andThrow) return shorthandAssign >= 0 || doubleProto >= 0; + + if (shorthandAssign >= 0) { + this.unexpected(shorthandAssign); + } + + if (doubleProto >= 0) { + this.raise(doubleProto, "Redefinition of __proto__ property"); + } + } + +} +class ExpressionErrors { + constructor() { + this.shorthandAssign = -1; + this.doubleProto = -1; + } + } class Node { @@ -21858,6 +23107,7 @@ class NodeUtils extends UtilParser { } finishNodeAt(node, type, pos, loc) { + node.type = type; node.end = pos; node.loc.end = loc; @@ -21872,91 +23122,108 @@ class NodeUtils extends UtilParser { if (this.options.ranges) node.range[0] = start; } + resetEndLocation(node, end = this.state.lastTokEnd, endLoc = this.state.lastTokEndLoc) { + node.end = end; + node.loc.end = endLoc; + if (this.options.ranges) node.range[1] = end; + } + resetStartLocationFromNode(node, locationNode) { this.resetStartLocation(node, locationNode.start, locationNode.loc.start); } } +const unwrapParenthesizedExpression = node => { + return node.type === "ParenthesizedExpression" ? unwrapParenthesizedExpression(node.expression) : node; +}; + class LValParser extends NodeUtils { - toAssignable(node, isBinding, contextDescription) { - if (node) { - switch (node.type) { - case "Identifier": - case "ObjectPattern": - case "ArrayPattern": - case "AssignmentPattern": - break; + toAssignable(node) { + var _node$extra, _node$extra3; - case "ObjectExpression": - node.type = "ObjectPattern"; + let parenthesized = undefined; - for (let i = 0, length = node.properties.length, last = length - 1; i < length; i++) { - const prop = node.properties[i]; - const isLast = i === last; - this.toAssignableObjectExpressionProp(prop, isBinding, isLast); - } + if (node.type === "ParenthesizedExpression" || ((_node$extra = node.extra) == null ? void 0 : _node$extra.parenthesized)) { + parenthesized = unwrapParenthesizedExpression(node); - break; + if (parenthesized.type !== "Identifier" && parenthesized.type !== "MemberExpression") { + this.raise(node.start, "Invalid parenthesized assignment pattern"); + } + } - case "ObjectProperty": - this.toAssignable(node.value, isBinding, contextDescription); - break; + switch (node.type) { + case "Identifier": + case "ObjectPattern": + case "ArrayPattern": + case "AssignmentPattern": + break; - case "SpreadElement": - { - this.checkToRestConversion(node); - node.type = "RestElement"; - const arg = node.argument; - this.toAssignable(arg, isBinding, contextDescription); - break; - } + case "ObjectExpression": + node.type = "ObjectPattern"; - case "ArrayExpression": - node.type = "ArrayPattern"; - this.toAssignableList(node.elements, isBinding, contextDescription); - break; + for (let i = 0, length = node.properties.length, last = length - 1; i < length; i++) { + var _node$extra2; - 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."); + const prop = node.properties[i]; + const isLast = i === last; + this.toAssignableObjectExpressionProp(prop, isLast); + + if (isLast && prop.type === "RestElement" && ((_node$extra2 = node.extra) == null ? void 0 : _node$extra2.trailingComma)) { + this.raiseRestNotLast(node.extra.trailingComma); } + } - break; + break; - case "ParenthesizedExpression": - node.expression = this.toAssignable(node.expression, isBinding, contextDescription); + case "ObjectProperty": + this.toAssignable(node.value); + break; + + case "SpreadElement": + { + this.checkToRestConversion(node); + node.type = "RestElement"; + const arg = node.argument; + this.toAssignable(arg); break; + } - case "MemberExpression": - if (!isBinding) break; + case "ArrayExpression": + node.type = "ArrayPattern"; + this.toAssignableList(node.elements, (_node$extra3 = node.extra) == null ? void 0 : _node$extra3.trailingComma); + break; - default: - { - const message = "Invalid left-hand side" + (contextDescription ? " in " + contextDescription : "expression"); - this.raise(node.start, message); - } - } + case "AssignmentExpression": + if (node.operator !== "=") { + this.raise(node.left.end, "Only '=' operator can be used for specifying default value."); + } + + node.type = "AssignmentPattern"; + delete node.operator; + this.toAssignable(node.left); + break; + + case "ParenthesizedExpression": + this.toAssignable(parenthesized); + break; } return node; } - toAssignableObjectExpressionProp(prop, isBinding, isLast) { + toAssignableObjectExpressionProp(prop, isLast) { if (prop.type === "ObjectMethod") { const error = prop.kind === "get" || prop.kind === "set" ? "Object pattern can't contain getter or setter" : "Object pattern can't contain methods"; this.raise(prop.key.start, error); } else if (prop.type === "SpreadElement" && !isLast) { this.raiseRestNotLast(prop.start); } else { - this.toAssignable(prop, isBinding, "object destructuring pattern"); + this.toAssignable(prop); } } - toAssignableList(exprList, isBinding, contextDescription) { + toAssignableList(exprList, trailingCommaPos) { let end = exprList.length; if (end) { @@ -21967,12 +23234,16 @@ class LValParser extends NodeUtils { } else if (last && last.type === "SpreadElement") { last.type = "RestElement"; const arg = last.argument; - this.toAssignable(arg, isBinding, contextDescription); + this.toAssignable(arg); if (arg.type !== "Identifier" && arg.type !== "MemberExpression" && arg.type !== "ArrayPattern" && arg.type !== "ObjectPattern") { this.unexpected(arg.start); } + if (trailingCommaPos) { + this.raiseTrailingCommaAfterRest(trailingCommaPos); + } + --end; } } @@ -21981,7 +23252,7 @@ class LValParser extends NodeUtils { const elt = exprList[i]; if (elt) { - this.toAssignable(elt, isBinding, contextDescription); + this.toAssignable(elt); if (elt.type === "RestElement") { this.raiseRestNotLast(elt.start); @@ -22006,19 +23277,12 @@ class LValParser extends NodeUtils { this.toReferencedListDeep(expr.elements); } } - - return exprList; } - parseSpread(refShorthandDefaultPos, refNeedsArrowPos) { + parseSpread(refExpressionErrors, refNeedsArrowPos) { const node = this.startNode(); this.next(); - node.argument = this.parseMaybeAssign(false, refShorthandDefaultPos, undefined, refNeedsArrowPos); - - if (this.state.commaAfterSpreadAt === -1 && this.match(types.comma)) { - this.state.commaAfterSpreadAt = this.state.start; - } - + node.argument = this.parseMaybeAssign(false, refExpressionErrors, undefined, refNeedsArrowPos); return this.finishNode(node, "SpreadElement"); } @@ -22035,7 +23299,7 @@ class LValParser extends NodeUtils { { const node = this.startNode(); this.next(); - node.elements = this.parseBindingList(types.bracketR, true); + node.elements = this.parseBindingList(types.bracketR, 93, true); return this.finishNode(node, "ArrayPattern"); } @@ -22046,7 +23310,7 @@ class LValParser extends NodeUtils { return this.parseIdentifier(); } - parseBindingList(close, allowEmpty, allowModifiers) { + parseBindingList(close, closeCharCode, allowEmpty, allowModifiers) { const elts = []; let first = true; @@ -22063,7 +23327,7 @@ class LValParser extends NodeUtils { break; } else if (this.match(types.ellipsis)) { elts.push(this.parseAssignableListItemTypes(this.parseRestBinding())); - this.checkCommaAfterRest(); + this.checkCommaAfterRest(closeCharCode); this.expect(close); break; } else { @@ -22111,10 +23375,10 @@ class LValParser extends NodeUtils { return this.finishNode(node, "AssignmentPattern"); } - checkLVal(expr, bindingType = BIND_NONE, checkClashes, contextDescription) { + checkLVal(expr, bindingType = BIND_NONE, checkClashes, contextDescription, disallowLetBinding, strictModeChanged = false) { switch (expr.type) { case "Identifier": - if (this.state.strict && isStrictBindReservedWord(expr.name, this.inModule)) { + if (this.state.strict && (strictModeChanged ? isStrictBindReservedWord(expr.name, this.inModule) : isStrictBindOnlyReservedWord(expr.name))) { this.raise(expr.start, `${bindingType === BIND_NONE ? "Assigning to" : "Binding"} '${expr.name}' in strict mode`); } @@ -22128,6 +23392,10 @@ class LValParser extends NodeUtils { } } + if (disallowLetBinding && expr.name === "let") { + this.raise(expr.start, "'let' is not allowed to be used as a name in 'let' or 'const' declarations."); + } + if (!(bindingType & BIND_NONE)) { this.scope.declareName(expr.name, bindingType, expr.start); } @@ -22144,8 +23412,8 @@ class LValParser extends NodeUtils { case "ObjectPattern": for (let _i2 = 0, _expr$properties = expr.properties; _i2 < _expr$properties.length; _i2++) { let prop = _expr$properties[_i2]; - if (prop.type === "ObjectProperty") prop = prop.value; - this.checkLVal(prop, bindingType, checkClashes, "object destructuring pattern"); + if (prop.type === "ObjectProperty") prop = prop.value;else if (prop.type === "ObjectMethod") continue; + this.checkLVal(prop, bindingType, checkClashes, "object destructuring pattern", disallowLetBinding); } break; @@ -22155,7 +23423,7 @@ class LValParser extends NodeUtils { const elem = _expr$elements[_i3]; if (elem) { - this.checkLVal(elem, bindingType, checkClashes, "array destructuring pattern"); + this.checkLVal(elem, bindingType, checkClashes, "array destructuring pattern", disallowLetBinding); } } @@ -22187,30 +23455,28 @@ class LValParser extends NodeUtils { } } - checkCommaAfterRest() { + checkCommaAfterRest(close) { if (this.match(types.comma)) { - this.raiseRestNotLast(this.state.start); + if (this.lookaheadCharCode() === close) { + this.raiseTrailingCommaAfterRest(this.state.start); + } else { + this.raiseRestNotLast(this.state.start); + } } } - checkCommaAfterRestFromSpread() { - if (this.state.commaAfterSpreadAt > -1) { - this.raiseRestNotLast(this.state.commaAfterSpreadAt); - } + raiseRestNotLast(pos) { + throw this.raise(pos, `Rest element must be last element`); } - raiseRestNotLast(pos) { - this.raise(pos, `Rest element must be last element`); + raiseTrailingCommaAfterRest(pos) { + this.raise(pos, `Unexpected trailing comma after rest element`); } } -const unwrapParenthesizedExpression = node => { - return node.type === "ParenthesizedExpression" ? unwrapParenthesizedExpression(node.expression) : node; -}; - class ExpressionParser extends LValParser { - checkPropClash(prop, propHash) { + checkDuplicatedProto(prop, protoRef, refExpressionErrors) { if (prop.type === "SpreadElement" || prop.computed || prop.kind || prop.shorthand) { return; } @@ -22219,16 +23485,28 @@ class ExpressionParser extends LValParser { const name = key.type === "Identifier" ? key.name : String(key.value); if (name === "__proto__") { - if (propHash.proto) { - this.raise(key.start, "Redefinition of __proto__ property"); + if (protoRef.used) { + if (refExpressionErrors) { + if (refExpressionErrors.doubleProto === -1) { + refExpressionErrors.doubleProto = key.start; + } + } else { + this.raise(key.start, "Redefinition of __proto__ property"); + } } - propHash.proto = true; + protoRef.used = true; } } getExpression() { - this.scope.enter(SCOPE_PROGRAM); + let scopeFlags = SCOPE_PROGRAM; + + if (this.hasPlugin("topLevelAwait") && this.inModule) { + scopeFlags |= SCOPE_ASYNC; + } + + this.scope.enter(scopeFlags); this.nextToken(); const expr = this.parseExpression(); @@ -22237,20 +23515,21 @@ class ExpressionParser extends LValParser { } expr.comments = this.state.comments; + expr.errors = this.state.errors; return expr; } - parseExpression(noIn, refShorthandDefaultPos) { + parseExpression(noIn, refExpressionErrors) { const startPos = this.state.start; const startLoc = this.state.startLoc; - const expr = this.parseMaybeAssign(noIn, refShorthandDefaultPos); + const expr = this.parseMaybeAssign(noIn, refExpressionErrors); if (this.match(types.comma)) { const node = this.startNodeAt(startPos, startLoc); node.expressions = [expr]; while (this.eat(types.comma)) { - node.expressions.push(this.parseMaybeAssign(noIn, refShorthandDefaultPos)); + node.expressions.push(this.parseMaybeAssign(noIn, refExpressionErrors)); } this.toReferencedList(node.expressions); @@ -22260,7 +23539,7 @@ class ExpressionParser extends LValParser { return expr; } - parseMaybeAssign(noIn, refShorthandDefaultPos, afterLeftParse, refNeedsArrowPos) { + parseMaybeAssign(noIn, refExpressionErrors, afterLeftParse, refNeedsArrowPos) { const startPos = this.state.start; const startLoc = this.state.startLoc; @@ -22278,24 +23557,20 @@ class ExpressionParser extends LValParser { } } - const oldCommaAfterSpreadAt = this.state.commaAfterSpreadAt; - this.state.commaAfterSpreadAt = -1; - let failOnShorthandAssign; + let ownExpressionErrors; - if (refShorthandDefaultPos) { - failOnShorthandAssign = false; + if (refExpressionErrors) { + ownExpressionErrors = false; } else { - refShorthandDefaultPos = { - start: 0 - }; - failOnShorthandAssign = true; + refExpressionErrors = new ExpressionErrors(); + ownExpressionErrors = true; } if (this.match(types.parenL) || this.match(types.name)) { this.state.potentialArrowAt = this.state.start; } - let left = this.parseMaybeConditional(noIn, refShorthandDefaultPos, refNeedsArrowPos); + let left = this.parseMaybeConditional(noIn, refExpressionErrors, refNeedsArrowPos); if (afterLeftParse) { left = afterLeftParse.call(this, left, startPos, startLoc); @@ -22307,7 +23582,6 @@ class ExpressionParser extends LValParser { node.operator = operator; if (operator === "??=") { - this.expectPlugin("nullishCoalescingOperator"); this.expectPlugin("logicalAssignment"); } @@ -22315,46 +23589,39 @@ class ExpressionParser extends LValParser { this.expectPlugin("logicalAssignment"); } - node.left = this.match(types.eq) ? this.toAssignable(left, undefined, "assignment expression") : left; - refShorthandDefaultPos.start = 0; - this.checkLVal(left, undefined, undefined, "assignment expression"); - const maybePattern = unwrapParenthesizedExpression(left); - let patternErrorMsg; - - if (maybePattern.type === "ObjectPattern") { - patternErrorMsg = "`({a}) = 0` use `({a} = 0)`"; - } else if (maybePattern.type === "ArrayPattern") { - patternErrorMsg = "`([a]) = 0` use `([a] = 0)`"; + if (this.match(types.eq)) { + node.left = this.toAssignable(left); + refExpressionErrors.doubleProto = -1; + } else { + node.left = left; } - if (patternErrorMsg && (left.extra && left.extra.parenthesized || left.type === "ParenthesizedExpression")) { - this.raise(maybePattern.start, `You're trying to assign to a parenthesized expression, eg. instead of ${patternErrorMsg}`); + if (refExpressionErrors.shorthandAssign >= node.left.start) { + refExpressionErrors.shorthandAssign = -1; } - if (patternErrorMsg) this.checkCommaAfterRestFromSpread(); - this.state.commaAfterSpreadAt = oldCommaAfterSpreadAt; + this.checkLVal(left, undefined, undefined, "assignment expression"); this.next(); node.right = this.parseMaybeAssign(noIn); return this.finishNode(node, "AssignmentExpression"); - } else if (failOnShorthandAssign && refShorthandDefaultPos.start) { - this.unexpected(refShorthandDefaultPos.start); + } else if (ownExpressionErrors) { + this.checkExpressionErrors(refExpressionErrors, true); } - this.state.commaAfterSpreadAt = oldCommaAfterSpreadAt; return left; } - parseMaybeConditional(noIn, refShorthandDefaultPos, refNeedsArrowPos) { + parseMaybeConditional(noIn, refExpressionErrors, refNeedsArrowPos) { const startPos = this.state.start; const startLoc = this.state.startLoc; const potentialArrowAt = this.state.potentialArrowAt; - const expr = this.parseExprOps(noIn, refShorthandDefaultPos); + const expr = this.parseExprOps(noIn, refExpressionErrors); if (expr.type === "ArrowFunctionExpression" && expr.start === potentialArrowAt) { return expr; } - if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr; + if (this.checkExpressionErrors(refExpressionErrors, false)) return expr; return this.parseConditional(expr, noIn, startPos, startLoc, refNeedsArrowPos); } @@ -22371,17 +23638,17 @@ class ExpressionParser extends LValParser { return expr; } - parseExprOps(noIn, refShorthandDefaultPos) { + parseExprOps(noIn, refExpressionErrors) { const startPos = this.state.start; const startLoc = this.state.startLoc; const potentialArrowAt = this.state.potentialArrowAt; - const expr = this.parseMaybeUnary(refShorthandDefaultPos); + const expr = this.parseMaybeUnary(refExpressionErrors); if (expr.type === "ArrowFunctionExpression" && expr.start === potentialArrowAt) { return expr; } - if (refShorthandDefaultPos && refShorthandDefaultPos.start) { + if (this.checkExpressionErrors(refExpressionErrors, false)) { return expr; } @@ -22389,12 +23656,17 @@ class ExpressionParser extends LValParser { } parseExprOp(left, leftStartPos, leftStartLoc, minPrec, noIn) { - const prec = this.state.type.binop; + let prec = this.state.type.binop; if (prec != null && (!noIn || !this.match(types._in))) { if (prec > minPrec) { - const node = this.startNodeAt(leftStartPos, leftStartLoc); const operator = this.state.value; + + if (operator === "|>" && this.state.inFSharpPipelineDirectBody) { + return left; + } + + const node = this.startNodeAt(leftStartPos, leftStartLoc); node.left = left; node.operator = operator; @@ -22403,13 +23675,15 @@ class ExpressionParser extends LValParser { } const op = this.state.type; + const logical = op === types.logicalOR || op === types.logicalAND; + const coalesce = op === types.nullishCoalescing; if (op === types.pipeline) { this.expectPlugin("pipelineOperator"); this.state.inPipeline = true; this.checkPipelineAtInfixOperator(left, leftStartPos); - } else if (op === types.nullishCoalescing) { - this.expectPlugin("nullishCoalescingOperator"); + } else if (coalesce) { + prec = types.logicalAND.binop; } this.next(); @@ -22421,7 +23695,13 @@ class ExpressionParser extends LValParser { } node.right = this.parseExprOpRightExpr(op, prec, noIn); - this.finishNode(node, op === types.logicalOR || op === types.logicalAND || op === types.nullishCoalescing ? "LogicalExpression" : "BinaryExpression"); + this.finishNode(node, logical || coalesce ? "LogicalExpression" : "BinaryExpression"); + const nextOp = this.state.type; + + if (coalesce && (nextOp === types.logicalOR || nextOp === types.logicalAND) || logical && nextOp === types.nullishCoalescing) { + throw this.raise(this.state.start, `Nullish coalescing operator(??) requires parens when mixing with logical operators`); + } + return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn); } } @@ -22430,14 +23710,21 @@ class ExpressionParser extends LValParser { } parseExprOpRightExpr(op, prec, noIn) { + const startPos = this.state.start; + const startLoc = this.state.startLoc; + switch (op) { case types.pipeline: - if (this.getPluginOption("pipelineOperator", "proposal") === "smart") { - const startPos = this.state.start; - const startLoc = this.state.startLoc; - return this.withTopicPermittingContext(() => { - return this.parseSmartPipelineBody(this.parseExprOpBaseRightExpr(op, prec, noIn), startPos, startLoc); - }); + switch (this.getPluginOption("pipelineOperator", "proposal")) { + case "smart": + return this.withTopicPermittingContext(() => { + return this.parseSmartPipelineBody(this.parseExprOpBaseRightExpr(op, prec, noIn), startPos, startLoc); + }); + + case "fsharp": + return this.withSoloAwaitPermittingContext(() => { + return this.parseFSharpPipelineBody(prec, noIn); + }); } default: @@ -22451,8 +23738,8 @@ class ExpressionParser extends LValParser { return this.parseExprOp(this.parseMaybeUnary(), startPos, startLoc, op.rightAssociative ? prec - 1 : prec, noIn); } - parseMaybeUnary(refShorthandDefaultPos) { - if (this.isContextual("await") && (this.scope.inAsync || !this.scope.inFunction && this.options.allowAwaitOutsideFunction)) { + parseMaybeUnary(refExpressionErrors) { + if (this.isContextual("await") && this.isAwaitAllowed()) { return this.parseAwait(); } else if (this.state.type.prefix) { const node = this.startNode(); @@ -22466,10 +23753,7 @@ class ExpressionParser extends LValParser { this.next(); node.argument = this.parseMaybeUnary(); - - if (refShorthandDefaultPos && refShorthandDefaultPos.start) { - this.unexpected(refShorthandDefaultPos.start); - } + this.checkExpressionErrors(refExpressionErrors, true); if (update) { this.checkLVal(node.argument, undefined, undefined, "prefix operation"); @@ -22488,8 +23772,8 @@ class ExpressionParser extends LValParser { const startPos = this.state.start; const startLoc = this.state.startLoc; - let expr = this.parseExprSubscripts(refShorthandDefaultPos); - if (refShorthandDefaultPos && refShorthandDefaultPos.start) return expr; + let expr = this.parseExprSubscripts(refExpressionErrors); + if (this.checkExpressionErrors(refExpressionErrors, false)) return expr; while (this.state.type.postfix && !this.canInsertSemicolon()) { const node = this.startNodeAt(startPos, startLoc); @@ -22504,135 +23788,118 @@ class ExpressionParser extends LValParser { return expr; } - parseExprSubscripts(refShorthandDefaultPos) { + parseExprSubscripts(refExpressionErrors) { const startPos = this.state.start; const startLoc = this.state.startLoc; const potentialArrowAt = this.state.potentialArrowAt; - const expr = this.parseExprAtom(refShorthandDefaultPos); + const expr = this.parseExprAtom(refExpressionErrors); if (expr.type === "ArrowFunctionExpression" && expr.start === potentialArrowAt) { return expr; } - if (refShorthandDefaultPos && refShorthandDefaultPos.start) { - return expr; - } - return this.parseSubscripts(expr, startPos, startLoc); } parseSubscripts(base, startPos, startLoc, noCalls) { - const maybeAsyncArrow = this.atPossibleAsync(base); const state = { optionalChainMember: false, + maybeAsyncArrow: this.atPossibleAsync(base), stop: false }; do { - base = this.parseSubscript(base, startPos, startLoc, noCalls, state, maybeAsyncArrow); + base = this.parseSubscript(base, startPos, startLoc, noCalls, state); + state.maybeAsyncArrow = false; } while (!state.stop); return base; } - parseSubscript(base, startPos, startLoc, noCalls, state, maybeAsyncArrow) { + parseSubscript(base, startPos, startLoc, noCalls, state) { if (!noCalls && this.eat(types.doubleColon)) { const node = this.startNodeAt(startPos, startLoc); node.object = base; node.callee = this.parseNoCallExpr(); state.stop = true; return this.parseSubscripts(this.finishNode(node, "BindExpression"), startPos, startLoc, noCalls); - } else if (this.match(types.questionDot)) { - this.expectPlugin("optionalChaining"); - state.optionalChainMember = true; + } + + let optional = false; - if (noCalls && this.lookahead().type === types.parenL) { + if (this.match(types.questionDot)) { + state.optionalChainMember = optional = true; + + if (noCalls && this.lookaheadCharCode() === 40) { state.stop = true; return base; } this.next(); - const node = this.startNodeAt(startPos, startLoc); + } - if (this.eat(types.bracketL)) { - node.object = base; - node.property = this.parseExpression(); - node.computed = true; - node.optional = true; - this.expect(types.bracketR); - return this.finishNode(node, "OptionalMemberExpression"); - } else if (this.eat(types.parenL)) { - node.callee = base; - node.arguments = this.parseCallExpressionArguments(types.parenR, false); - node.optional = true; - return this.finishNode(node, "OptionalCallExpression"); - } else { - node.object = base; - node.property = this.parseIdentifier(true); - node.computed = false; - node.optional = true; - return this.finishNode(node, "OptionalMemberExpression"); - } - } else if (this.eat(types.dot)) { + const computed = this.eat(types.bracketL); + + if (optional && !this.match(types.parenL) && !this.match(types.backQuote) || computed || this.eat(types.dot)) { const node = this.startNodeAt(startPos, startLoc); node.object = base; - node.property = this.parseMaybePrivateName(); - node.computed = false; + node.property = computed ? this.parseExpression() : optional ? this.parseIdentifier(true) : this.parseMaybePrivateName(true); + node.computed = computed; - if (state.optionalChainMember) { - node.optional = false; - return this.finishNode(node, "OptionalMemberExpression"); + if (node.property.type === "PrivateName") { + if (node.object.type === "Super") { + this.raise(startPos, "Private fields can't be accessed on super"); + } + + this.classScope.usePrivateName(node.property.id.name, node.property.start); } - return this.finishNode(node, "MemberExpression"); - } else if (this.eat(types.bracketL)) { - const node = this.startNodeAt(startPos, startLoc); - node.object = base; - node.property = this.parseExpression(); - node.computed = true; - this.expect(types.bracketR); + if (computed) { + this.expect(types.bracketR); + } if (state.optionalChainMember) { - node.optional = false; + node.optional = optional; return this.finishNode(node, "OptionalMemberExpression"); + } else { + return this.finishNode(node, "MemberExpression"); } - - return this.finishNode(node, "MemberExpression"); } else if (!noCalls && this.match(types.parenL)) { const oldMaybeInArrowParameters = this.state.maybeInArrowParameters; const oldYieldPos = this.state.yieldPos; const oldAwaitPos = this.state.awaitPos; this.state.maybeInArrowParameters = true; - this.state.yieldPos = 0; - this.state.awaitPos = 0; + this.state.yieldPos = -1; + this.state.awaitPos = -1; this.next(); let node = this.startNodeAt(startPos, startLoc); node.callee = base; - const oldCommaAfterSpreadAt = this.state.commaAfterSpreadAt; - this.state.commaAfterSpreadAt = -1; - node.arguments = this.parseCallExpressionArguments(types.parenR, maybeAsyncArrow, base.type === "Import", base.type !== "Super"); - if (!state.optionalChainMember) { - this.finishCallExpression(node); + if (optional) { + node.optional = true; + node.arguments = this.parseCallExpressionArguments(types.parenR, false); } else { - this.finishOptionalCallExpression(node); + node.arguments = this.parseCallExpressionArguments(types.parenR, state.maybeAsyncArrow, base.type === "Import", base.type !== "Super", node); } - if (maybeAsyncArrow && this.shouldParseAsyncArrow()) { + this.finishCallExpression(node, state.optionalChainMember); + + if (state.maybeAsyncArrow && this.shouldParseAsyncArrow() && !optional) { state.stop = true; - this.checkCommaAfterRestFromSpread(); node = this.parseAsyncArrowFromCallExpression(this.startNodeAt(startPos, startLoc), node); this.checkYieldAwaitInDefaultParams(); this.state.yieldPos = oldYieldPos; this.state.awaitPos = oldAwaitPos; } else { this.toReferencedListDeep(node.arguments); - this.state.yieldPos = oldYieldPos || this.state.yieldPos; - this.state.awaitPos = oldAwaitPos || this.state.awaitPos; + if (oldYieldPos !== -1) this.state.yieldPos = oldYieldPos; + + if (!this.isAwaitAllowed() && !oldMaybeInArrowParameters || oldAwaitPos !== -1) { + this.state.awaitPos = oldAwaitPos; + } } this.state.maybeInArrowParameters = oldMaybeInArrowParameters; - this.state.commaAfterSpreadAt = oldCommaAfterSpreadAt; return node; } else if (this.match(types.backQuote)) { return this.parseTaggedTemplateExpression(startPos, startLoc, base, state); @@ -22659,42 +23926,28 @@ class ExpressionParser extends LValParser { return base.type === "Identifier" && base.name === "async" && this.state.lastTokEnd === base.end && !this.canInsertSemicolon() && this.input.slice(base.start, base.end) === "async"; } - finishCallExpression(node) { - if (node.callee.type === "Import") { - if (node.arguments.length !== 1) { - this.raise(node.start, "import() requires exactly one argument"); - } - - const importArg = node.arguments[0]; - - if (importArg && importArg.type === "SpreadElement") { - this.raise(importArg.start, "... is not allowed in import()"); - } - } - - return this.finishNode(node, "CallExpression"); - } - - finishOptionalCallExpression(node) { + finishCallExpression(node, optional) { if (node.callee.type === "Import") { if (node.arguments.length !== 1) { this.raise(node.start, "import() requires exactly one argument"); - } - - const importArg = node.arguments[0]; + } else { + const importArg = node.arguments[0]; - if (importArg && importArg.type === "SpreadElement") { - this.raise(importArg.start, "... is not allowed in import()"); + if (importArg && importArg.type === "SpreadElement") { + this.raise(importArg.start, "... is not allowed in import()"); + } } } - return this.finishNode(node, "OptionalCallExpression"); + return this.finishNode(node, optional ? "OptionalCallExpression" : "CallExpression"); } - parseCallExpressionArguments(close, possibleAsyncArrow, dynamicImport, allowPlaceholder) { + parseCallExpressionArguments(close, possibleAsyncArrow, dynamicImport, allowPlaceholder, nodeForExtra) { const elts = []; let innerParenStart; let first = true; + const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody; + this.state.inFSharpPipelineDirectBody = false; while (!this.eat(close)) { if (first) { @@ -22702,11 +23955,16 @@ class ExpressionParser extends LValParser { } else { this.expect(types.comma); - if (this.eat(close)) { + if (this.match(close)) { if (dynamicImport) { this.raise(this.state.lastTokStart, "Trailing comma is disallowed inside import(...) arguments"); } + if (nodeForExtra) { + this.addExtra(nodeForExtra, "trailingComma", this.state.lastTokStart); + } + + this.next(); break; } } @@ -22715,9 +23973,7 @@ class ExpressionParser extends LValParser { innerParenStart = this.state.start; } - elts.push(this.parseExprListItem(false, possibleAsyncArrow ? { - start: 0 - } : undefined, possibleAsyncArrow ? { + elts.push(this.parseExprListItem(false, possibleAsyncArrow ? new ExpressionErrors() : undefined, possibleAsyncArrow ? { start: 0 } : undefined, allowPlaceholder)); } @@ -22726,6 +23982,7 @@ class ExpressionParser extends LValParser { this.unexpected(); } + this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody; return elts; } @@ -22734,8 +23991,10 @@ class ExpressionParser extends LValParser { } parseAsyncArrowFromCallExpression(node, call) { + var _call$extra; + this.expect(types.arrow); - this.parseArrowExpression(node, call.arguments, true); + this.parseArrowExpression(node, call.arguments, true, (_call$extra = call.extra) == null ? void 0 : _call$extra.trailingComma); return node; } @@ -22745,41 +24004,38 @@ class ExpressionParser extends LValParser { return this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true); } - parseExprAtom(refShorthandDefaultPos) { + parseExprAtom(refExpressionErrors) { if (this.state.type === types.slash) this.readRegexp(); const canBeArrow = this.state.potentialArrowAt === this.state.start; let node; switch (this.state.type) { case types._super: - if (!this.scope.allowSuper && !this.options.allowSuperOutsideMethod) { - this.raise(this.state.start, "super is only allowed in object methods and classes"); - } - node = this.startNode(); this.next(); if (this.match(types.parenL) && !this.scope.allowDirectSuper && !this.options.allowSuperOutsideMethod) { this.raise(node.start, "super() is only valid inside a class constructor of a subclass. " + "Maybe a typo in the method name ('constructor') or not extending another class?"); + } else if (!this.scope.allowSuper && !this.options.allowSuperOutsideMethod) { + this.raise(node.start, "super is only allowed in object methods and classes"); } if (!this.match(types.parenL) && !this.match(types.bracketL) && !this.match(types.dot)) { - this.unexpected(); + this.raise(node.start, "super can only be used with function calls (i.e. super()) or " + "in property accesses (i.e. super.prop or super[prop])"); } return this.finishNode(node, "Super"); case types._import: - if (this.lookahead().type === types.dot) { - return this.parseImportMetaProperty(); - } - - this.expectPlugin("dynamicImport"); node = this.startNode(); this.next(); + if (this.match(types.dot)) { + return this.parseImportMetaProperty(node); + } + if (!this.match(types.parenL)) { - this.unexpected(null, types.parenL); + this.raise(this.state.lastTokStart, "import can only be used in import() or import.meta"); } return this.finishNode(node, "Import"); @@ -22796,11 +24052,28 @@ class ExpressionParser extends LValParser { const id = this.parseIdentifier(); if (!containsEsc && id.name === "async" && this.match(types._function) && !this.canInsertSemicolon()) { + const last = this.state.context.length - 1; + + if (this.state.context[last] !== types$1.functionStatement) { + throw new Error("Internal error"); + } + + this.state.context[last] = types$1.functionExpression; this.next(); return this.parseFunction(node, undefined, true); } else if (canBeArrow && !containsEsc && id.name === "async" && this.match(types.name) && !this.canInsertSemicolon()) { + const oldMaybeInArrowParameters = this.state.maybeInArrowParameters; + const oldYieldPos = this.state.yieldPos; + const oldAwaitPos = this.state.awaitPos; + this.state.maybeInArrowParameters = true; + this.state.yieldPos = -1; + this.state.awaitPos = -1; const params = [this.parseIdentifier()]; this.expect(types.arrow); + this.checkYieldAwaitInDefaultParams(); + this.state.maybeInArrowParameters = oldMaybeInArrowParameters; + this.state.yieldPos = oldYieldPos; + this.state.awaitPos = oldAwaitPos; this.parseArrowExpression(node, params, true); return node; } @@ -22857,18 +24130,29 @@ class ExpressionParser extends LValParser { return this.parseParenAndDistinguishExpression(canBeArrow); case types.bracketL: - node = this.startNode(); - this.next(); - node.elements = this.parseExprList(types.bracketR, true, refShorthandDefaultPos); + { + const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody; + this.state.inFSharpPipelineDirectBody = false; + node = this.startNode(); + this.next(); + node.elements = this.parseExprList(types.bracketR, true, refExpressionErrors, node); - if (!this.state.maybeInArrowParameters) { - this.toReferencedList(node.elements); - } + if (!this.state.maybeInArrowParameters) { + this.toReferencedList(node.elements); + } - return this.finishNode(node, "ArrayExpression"); + this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody; + return this.finishNode(node, "ArrayExpression"); + } case types.braceL: - return this.parseObj(false, refShorthandDefaultPos); + { + const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody; + this.state.inFSharpPipelineDirectBody = false; + const ret = this.parseObj(false, refExpressionErrors); + this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody; + return ret; + } case types._function: return this.parseFunctionExpression(); @@ -22912,12 +24196,12 @@ class ExpressionParser extends LValParser { this.next(); - if (this.primaryTopicReferenceIsAllowedInCurrentTopicContext()) { - this.registerTopicReference(); - return this.finishNode(node, "PipelinePrimaryTopicReference"); - } else { - throw this.raise(node.start, `Topic reference was used in a lexical context without topic binding`); + if (!this.primaryTopicReferenceIsAllowedInCurrentTopicContext()) { + this.raise(node.start, `Topic reference was used in a lexical context without topic binding`); } + + this.registerTopicReference(); + return this.finishNode(node, "PipelinePrimaryTopicReference"); } } @@ -22933,11 +24217,16 @@ class ExpressionParser extends LValParser { return this.finishNode(node, "BooleanLiteral"); } - parseMaybePrivateName() { + parseMaybePrivateName(isPrivateNameAllowed) { const isPrivate = this.match(types.hash); if (isPrivate) { this.expectOnePlugin(["classPrivateProperties", "classPrivateMethods"]); + + if (!isPrivateNameAllowed) { + this.raise(this.state.pos, "Private names can only be used as the name of a class element (i.e. class C { #p = 42; #m() {} } )\n or a property of member expression (i.e. this.#p)."); + } + const node = this.startNode(); this.next(); this.assertNoSpace("Unexpected space between # and identifier"); @@ -22982,26 +24271,24 @@ class ExpressionParser extends LValParser { return this.finishNode(node, "MetaProperty"); } - parseImportMetaProperty() { - const node = this.startNode(); - const id = this.parseIdentifier(true); + parseImportMetaProperty(node) { + const id = this.createIdentifier(this.startNodeAtNode(node), "import"); this.expect(types.dot); - if (id.name === "import") { - if (this.isContextual("meta")) { - this.expectPlugin("importMeta"); - } else if (!this.hasPlugin("importMeta")) { - this.raise(id.start, `Dynamic imports require a parameter: import('a.js')`); + if (this.isContextual("meta")) { + this.expectPlugin("importMeta"); + + if (!this.inModule) { + this.raise(id.start, `import.meta may appear only with 'sourceType: "module"'`, { + code: "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED" + }); } - } - if (!this.inModule) { - this.raise(id.start, `import.meta may appear only with 'sourceType: "module"'`, { - code: "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED" - }); + this.sawUnambiguousESM = true; + } else if (!this.hasPlugin("importMeta")) { + this.raise(id.start, `Dynamic imports require a parameter: import('a.js')`); } - this.sawUnambiguousESM = true; return this.parseMetaProperty(node, id, "meta"); } @@ -23024,15 +24311,15 @@ class ExpressionParser extends LValParser { const oldMaybeInArrowParameters = this.state.maybeInArrowParameters; const oldYieldPos = this.state.yieldPos; const oldAwaitPos = this.state.awaitPos; + const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody; this.state.maybeInArrowParameters = true; - this.state.yieldPos = 0; - this.state.awaitPos = 0; + this.state.yieldPos = -1; + this.state.awaitPos = -1; + this.state.inFSharpPipelineDirectBody = false; const innerStartPos = this.state.start; const innerStartLoc = this.state.startLoc; const exprList = []; - const refShorthandDefaultPos = { - start: 0 - }; + const refExpressionErrors = new ExpressionErrors(); const refNeedsArrowPos = { start: 0 }; @@ -23057,10 +24344,10 @@ class ExpressionParser extends LValParser { const spreadNodeStartLoc = this.state.startLoc; spreadStart = this.state.start; exprList.push(this.parseParenItem(this.parseRestBinding(), spreadNodeStartPos, spreadNodeStartLoc)); - this.checkCommaAfterRest(); + this.checkCommaAfterRest(41); break; } else { - exprList.push(this.parseMaybeAssign(false, refShorthandDefaultPos, this.parseParenItem, refNeedsArrowPos)); + exprList.push(this.parseMaybeAssign(false, refExpressionErrors, this.parseParenItem, refNeedsArrowPos)); } } @@ -23068,6 +24355,7 @@ class ExpressionParser extends LValParser { const innerEndLoc = this.state.startLoc; this.expect(types.parenR); this.state.maybeInArrowParameters = oldMaybeInArrowParameters; + this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody; let arrowNode = this.startNodeAt(startPos, startLoc); if (canBeArrow && this.shouldParseArrow() && (arrowNode = this.parseArrow(arrowNode))) { @@ -23087,8 +24375,8 @@ class ExpressionParser extends LValParser { return arrowNode; } - this.state.yieldPos = oldYieldPos || this.state.yieldPos; - this.state.awaitPos = oldAwaitPos || this.state.awaitPos; + if (oldYieldPos !== -1) this.state.yieldPos = oldYieldPos; + if (oldAwaitPos !== -1) this.state.awaitPos = oldAwaitPos; if (!exprList.length) { this.unexpected(this.state.lastTokStart); @@ -23096,11 +24384,7 @@ class ExpressionParser extends LValParser { if (optionalCommaStart) this.unexpected(optionalCommaStart); if (spreadStart) this.unexpected(spreadStart); - - if (refShorthandDefaultPos.start) { - this.unexpected(refShorthandDefaultPos.start); - } - + this.checkExpressionErrors(refExpressionErrors, true); if (refNeedsArrowPos.start) this.unexpected(refNeedsArrowPos.start); this.toReferencedListDeep(exprList, true); @@ -23140,12 +24424,14 @@ class ExpressionParser extends LValParser { parseNew() { const node = this.startNode(); - const meta = this.parseIdentifier(true); + let meta = this.startNode(); + this.next(); + meta = this.createIdentifier(meta, "new"); if (this.eat(types.dot)) { const metaProp = this.parseMetaProperty(node, meta, "target"); - if (!this.scope.inNonArrowFunction && !this.state.inClassProperty) { + if (!this.scope.inNonArrowFunction && !this.scope.inClass) { let error = "new.target can only be used in functions"; if (this.hasPlugin("classProperties")) { @@ -23187,9 +24473,7 @@ class ExpressionParser extends LValParser { if (this.state.value === null) { if (!isTagged) { - this.raise(this.state.invalidTemplateEscapePosition || 0, "Invalid escape sequence in template"); - } else { - this.state.invalidTemplateEscapePosition = null; + this.raise(this.state.start + 1, "Invalid escape sequence in template"); } } @@ -23220,7 +24504,7 @@ class ExpressionParser extends LValParser { return this.finishNode(node, "TemplateLiteral"); } - parseObj(isPattern, refShorthandDefaultPos) { + parseObj(isPattern, refExpressionErrors) { const propHash = Object.create(null); let first = true; const node = this.startNode(); @@ -23232,11 +24516,19 @@ class ExpressionParser extends LValParser { first = false; } else { this.expect(types.comma); - if (this.eat(types.braceR)) break; + + if (this.match(types.braceR)) { + this.addExtra(node, "trailingComma", this.state.lastTokStart); + this.next(); + break; + } } - const prop = this.parseObjectMember(isPattern, refShorthandDefaultPos); - if (!isPattern) this.checkPropClash(prop, propHash); + const prop = this.parseObjectMember(isPattern, refExpressionErrors); + + if (!isPattern) { + this.checkDuplicatedProto(prop, propHash, refExpressionErrors); + } if (prop.shorthand) { this.addExtra(prop, "shorthand", true); @@ -23252,16 +24544,16 @@ class ExpressionParser extends LValParser { return !prop.computed && prop.key.type === "Identifier" && prop.key.name === "async" && (this.match(types.name) || this.match(types.num) || this.match(types.string) || this.match(types.bracketL) || this.state.type.keyword || this.match(types.star)) && !this.hasPrecedingLineBreak(); } - parseObjectMember(isPattern, refShorthandDefaultPos) { + parseObjectMember(isPattern, refExpressionErrors) { let decorators = []; if (this.match(types.at)) { if (this.hasPlugin("decorators")) { this.raise(this.state.start, "Stage 2 decorators disallow object literal property decorators"); - } else { - while (this.match(types.at)) { - decorators.push(this.parseDecorator()); - } + } + + while (this.match(types.at)) { + decorators.push(this.parseDecorator()); } } @@ -23277,7 +24569,7 @@ class ExpressionParser extends LValParser { if (isPattern) { this.next(); prop.argument = this.parseIdentifier(); - this.checkCommaAfterRest(); + this.checkCommaAfterRest(125); return this.finishNode(prop, "RestElement"); } @@ -23291,7 +24583,7 @@ class ExpressionParser extends LValParser { prop.method = false; - if (isPattern || refShorthandDefaultPos) { + if (isPattern || refExpressionErrors) { startPos = this.state.start; startLoc = this.state.startLoc; } @@ -23301,17 +24593,17 @@ class ExpressionParser extends LValParser { } const containsEsc = this.state.containsEsc; - this.parsePropertyName(prop); + this.parsePropertyName(prop, false); if (!isPattern && !containsEsc && !isGenerator && this.isAsyncProp(prop)) { isAsync = true; isGenerator = this.eat(types.star); - this.parsePropertyName(prop); + this.parsePropertyName(prop, false); } else { isAsync = false; } - this.parseObjPropValue(prop, startPos, startLoc, isGenerator, isAsync, isPattern, refShorthandDefaultPos, containsEsc); + this.parseObjPropValue(prop, startPos, startLoc, isGenerator, isAsync, isPattern, refExpressionErrors, containsEsc); return prop; } @@ -23351,18 +24643,18 @@ class ExpressionParser extends LValParser { if (!containsEsc && this.isGetterOrSetterMethod(prop, isPattern)) { if (isGenerator || isAsync) this.unexpected(); prop.kind = prop.key.name; - this.parsePropertyName(prop); + this.parsePropertyName(prop, false); this.parseMethod(prop, false, false, false, false, "ObjectMethod"); this.checkGetterSetterParams(prop); return prop; } } - parseObjectProperty(prop, startPos, startLoc, isPattern, refShorthandDefaultPos) { + parseObjectProperty(prop, startPos, startLoc, isPattern, refExpressionErrors) { prop.shorthand = false; if (this.eat(types.colon)) { - prop.value = isPattern ? this.parseMaybeDefault(this.state.start, this.state.startLoc) : this.parseMaybeAssign(false, refShorthandDefaultPos); + prop.value = isPattern ? this.parseMaybeDefault(this.state.start, this.state.startLoc) : this.parseMaybeAssign(false, refExpressionErrors); return this.finishNode(prop, "ObjectProperty"); } @@ -23371,9 +24663,9 @@ class ExpressionParser extends LValParser { if (isPattern) { prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key.__clone()); - } else if (this.match(types.eq) && refShorthandDefaultPos) { - if (!refShorthandDefaultPos.start) { - refShorthandDefaultPos.start = this.state.start; + } else if (this.match(types.eq) && refExpressionErrors) { + if (refExpressionErrors.shorthandAssign === -1) { + refExpressionErrors.shorthandAssign = this.state.start; } prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key.__clone()); @@ -23386,13 +24678,13 @@ class ExpressionParser extends LValParser { } } - parseObjPropValue(prop, startPos, startLoc, isGenerator, isAsync, isPattern, refShorthandDefaultPos, containsEsc) { - const node = this.parseObjectMethod(prop, isGenerator, isAsync, isPattern, containsEsc) || this.parseObjectProperty(prop, startPos, startLoc, isPattern, refShorthandDefaultPos); + parseObjPropValue(prop, startPos, startLoc, isGenerator, isAsync, isPattern, refExpressionErrors, containsEsc) { + const node = this.parseObjectMethod(prop, isGenerator, isAsync, isPattern, containsEsc) || this.parseObjectProperty(prop, startPos, startLoc, isPattern, refExpressionErrors); if (!node) this.unexpected(); return node; } - parsePropertyName(prop) { + parsePropertyName(prop, isPrivateNameAllowed) { if (this.eat(types.bracketL)) { prop.computed = true; prop.key = this.parseMaybeAssign(); @@ -23400,7 +24692,7 @@ class ExpressionParser extends LValParser { } else { const oldInPropertyName = this.state.inPropertyName; this.state.inPropertyName = true; - prop.key = this.match(types.num) || this.match(types.string) ? this.parseExprAtom() : this.parseMaybePrivateName(); + prop.key = this.match(types.num) || this.match(types.string) || this.match(types.bigint) ? this.parseExprAtom() : this.parseMaybePrivateName(isPrivateNameAllowed); if (prop.key.type !== "PrivateName") { prop.computed = false; @@ -23421,14 +24713,13 @@ class ExpressionParser extends LValParser { parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope = false) { const oldYieldPos = this.state.yieldPos; const oldAwaitPos = this.state.awaitPos; - this.state.yieldPos = 0; - this.state.awaitPos = 0; + this.state.yieldPos = -1; + this.state.awaitPos = -1; this.initFunction(node, isAsync); node.generator = !!isGenerator; const allowModifiers = isConstructor; this.scope.enter(functionFlags(isAsync, node.generator) | SCOPE_SUPER | (inClassScope ? SCOPE_CLASS : 0) | (allowDirectSuper ? SCOPE_DIRECT_SUPER : 0)); this.parseFunctionParams(node, allowModifiers); - this.checkYieldAwaitInDefaultParams(); this.parseFunctionBodyAndFinish(node, type, true); this.scope.exit(); this.state.yieldPos = oldYieldPos; @@ -23436,16 +24727,21 @@ class ExpressionParser extends LValParser { return node; } - parseArrowExpression(node, params, isAsync) { + parseArrowExpression(node, params, isAsync, trailingCommaPos) { this.scope.enter(functionFlags(isAsync, false) | SCOPE_ARROW); this.initFunction(node, isAsync); const oldMaybeInArrowParameters = this.state.maybeInArrowParameters; const oldYieldPos = this.state.yieldPos; const oldAwaitPos = this.state.awaitPos; + + if (params) { + this.state.maybeInArrowParameters = true; + this.setArrowFunctionParameters(node, params, trailingCommaPos); + } + this.state.maybeInArrowParameters = false; - this.state.yieldPos = 0; - this.state.awaitPos = 0; - if (params) this.setArrowFunctionParameters(node, params); + this.state.yieldPos = -1; + this.state.awaitPos = -1; this.parseFunctionBody(node, true); this.scope.exit(); this.state.maybeInArrowParameters = oldMaybeInArrowParameters; @@ -23454,24 +24750,8 @@ class ExpressionParser extends LValParser { return this.finishNode(node, "ArrowFunctionExpression"); } - setArrowFunctionParameters(node, params) { - node.params = this.toAssignableList(params, true, "arrow function parameters"); - } - - isStrictBody(node) { - const isBlockStatement = node.body.type === "BlockStatement"; - - if (isBlockStatement && node.body.directives.length) { - for (let _i2 = 0, _node$body$directives = node.body.directives; _i2 < _node$body$directives.length; _i2++) { - const directive = _node$body$directives[_i2]; - - if (directive.value.value === "use strict") { - return true; - } - } - } - - return false; + setArrowFunctionParameters(node, params, trailingCommaPos) { + node.params = this.toAssignableList(params, trailingCommaPos); } parseFunctionBodyAndFinish(node, type, isMethod = false) { @@ -23488,7 +24768,7 @@ class ExpressionParser extends LValParser { if (isExpression) { node.body = this.parseMaybeAssign(); - this.checkParams(node, false, allowExpression); + this.checkParams(node, false, allowExpression, false); } else { const nonSimple = !this.isSimpleParamList(node.params); @@ -23504,7 +24784,7 @@ class ExpressionParser extends LValParser { const oldLabels = this.state.labels; this.state.labels = []; if (useStrict) this.state.strict = true; - this.checkParams(node, !oldStrict && !useStrict && !allowExpression && !isMethod && !nonSimple, allowExpression); + this.checkParams(node, !oldStrict && !useStrict && !allowExpression && !isMethod && !nonSimple, allowExpression, !oldStrict && useStrict); node.body = this.parseBlock(true, false); this.state.labels = oldLabels; } @@ -23512,7 +24792,7 @@ class ExpressionParser extends LValParser { this.state.inParameters = oldInParameters; if (this.state.strict && node.id) { - this.checkLVal(node.id, BIND_OUTSIDE, undefined, "function name"); + this.checkLVal(node.id, BIND_OUTSIDE, undefined, "function name", undefined, !oldStrict && useStrict); } this.state.strict = oldStrict; @@ -23526,15 +24806,15 @@ class ExpressionParser extends LValParser { return true; } - checkParams(node, allowDuplicates, isArrowFunction) { + checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged = true) { const nameHash = Object.create(null); for (let i = 0; i < node.params.length; i++) { - this.checkLVal(node.params[i], BIND_VAR, allowDuplicates ? null : nameHash, "function paramter list"); + this.checkLVal(node.params[i], BIND_VAR, allowDuplicates ? null : nameHash, "function parameter list", undefined, strictModeChanged); } } - parseExprList(close, allowEmpty, refShorthandDefaultPos) { + parseExprList(close, allowEmpty, refExpressionErrors, nodeForExtra) { const elts = []; let first = true; @@ -23543,16 +24823,24 @@ class ExpressionParser extends LValParser { first = false; } else { this.expect(types.comma); - if (this.eat(close)) break; + + if (this.match(close)) { + if (nodeForExtra) { + this.addExtra(nodeForExtra, "trailingComma", this.state.lastTokStart); + } + + this.next(); + break; + } } - elts.push(this.parseExprListItem(allowEmpty, refShorthandDefaultPos)); + elts.push(this.parseExprListItem(allowEmpty, refExpressionErrors)); } return elts; } - parseExprListItem(allowEmpty, refShorthandDefaultPos, refNeedsArrowPos, allowPlaceholder) { + parseExprListItem(allowEmpty, refExpressionErrors, refNeedsArrowPos, allowPlaceholder) { let elt; if (allowEmpty && this.match(types.comma)) { @@ -23560,7 +24848,7 @@ class ExpressionParser extends LValParser { } else if (this.match(types.ellipsis)) { const spreadNodeStartPos = this.state.start; const spreadNodeStartLoc = this.state.startLoc; - elt = this.parseParenItem(this.parseSpread(refShorthandDefaultPos, refNeedsArrowPos), spreadNodeStartPos, spreadNodeStartLoc); + elt = this.parseParenItem(this.parseSpread(refExpressionErrors, refNeedsArrowPos), spreadNodeStartPos, spreadNodeStartLoc); } else if (this.match(types.question)) { this.expectPlugin("partialApplication"); @@ -23572,7 +24860,7 @@ class ExpressionParser extends LValParser { this.next(); elt = this.finishNode(node, "ArgumentPlaceholder"); } else { - elt = this.parseMaybeAssign(false, refShorthandDefaultPos, this.parseParenItem, refNeedsArrowPos); + elt = this.parseMaybeAssign(false, refExpressionErrors, this.parseParenItem, refNeedsArrowPos); } return elt; @@ -23605,7 +24893,9 @@ class ExpressionParser extends LValParser { throw this.unexpected(); } - if (!liberal) { + if (liberal) { + this.state.type = types.name; + } else { this.checkReservedWord(name, this.state.start, !!this.state.type.keyword, false); } @@ -23616,18 +24906,28 @@ class ExpressionParser extends LValParser { checkReservedWord(word, startLoc, checkKeywords, isBinding) { if (this.scope.inGenerator && word === "yield") { this.raise(startLoc, "Can not use 'yield' as identifier inside a generator"); + return; } - if (this.scope.inAsync && word === "await") { - this.raise(startLoc, "Can not use 'await' as identifier inside an async function"); + if (word === "await") { + if (this.scope.inAsync) { + this.raise(startLoc, "Can not use 'await' as identifier inside an async function"); + return; + } + + if (this.state.awaitPos === -1 && (this.state.maybeInArrowParameters || this.isAwaitAllowed())) { + this.state.awaitPos = this.state.start; + } } - if (this.state.inClassProperty && word === "arguments") { + if (this.scope.inClass && !this.scope.inNonArrowFunction && word === "arguments") { this.raise(startLoc, "'arguments' is not allowed in class field initializer"); + return; } if (checkKeywords && isKeyword(word)) { this.raise(startLoc, `Unexpected keyword '${word}'`); + return; } const reservedTest = !this.state.strict ? isReservedWord : isBinding ? isStrictBindReservedWord : isStrictReservedWord; @@ -23635,46 +24935,64 @@ class ExpressionParser extends LValParser { if (reservedTest(word, this.inModule)) { if (!this.scope.inAsync && word === "await") { this.raise(startLoc, "Can not use keyword 'await' outside an async function"); + } else { + this.raise(startLoc, `Unexpected reserved word '${word}'`); } - - this.raise(startLoc, `Unexpected reserved word '${word}'`); } } - parseAwait() { - if (!this.state.awaitPos) { - this.state.awaitPos = this.state.start; + isAwaitAllowed() { + if (this.scope.inFunction) return this.scope.inAsync; + if (this.options.allowAwaitOutsideFunction) return true; + + if (this.hasPlugin("topLevelAwait")) { + return this.inModule && this.scope.inAsync; } + return false; + } + + parseAwait() { const node = this.startNode(); this.next(); if (this.state.inParameters) { this.raise(node.start, "await is not allowed in async function parameters"); + } else if (this.state.awaitPos === -1) { + this.state.awaitPos = node.start; } - if (this.match(types.star)) { + if (this.eat(types.star)) { this.raise(node.start, "await* has been removed from the async functions proposal. Use Promise.all() instead."); } - node.argument = this.parseMaybeUnary(); + if (!this.scope.inFunction && !this.options.allowAwaitOutsideFunction) { + if (this.hasPrecedingLineBreak() || this.match(types.plusMin) || this.match(types.parenL) || this.match(types.bracketL) || this.match(types.backQuote) || this.match(types.regexp) || this.match(types.slash) || this.hasPlugin("v8intrinsic") && this.match(types.modulo)) { + this.ambiguousScriptDifferentAst = true; + } else { + this.sawUnambiguousESM = true; + } + } + + if (!this.state.soloAwait) { + node.argument = this.parseMaybeUnary(); + } + return this.finishNode(node, "AwaitExpression"); } parseYield(noIn) { - if (!this.state.yieldPos) { - this.state.yieldPos = this.state.start; - } - const node = this.startNode(); if (this.state.inParameters) { this.raise(node.start, "yield is not allowed in generator parameters"); + } else if (this.state.yieldPos === -1) { + this.state.yieldPos = node.start; } this.next(); - if (this.match(types.semi) || !this.match(types.star) && !this.state.type.startsExpr || this.canInsertSemicolon()) { + if (this.match(types.semi) || !this.match(types.star) && !this.state.type.startsExpr || this.hasPrecedingLineBreak()) { node.delegate = false; node.argument = null; } else { @@ -23688,7 +25006,7 @@ class ExpressionParser extends LValParser { checkPipelineAtInfixOperator(left, leftStartPos) { if (this.getPluginOption("pipelineOperator", "proposal") === "smart") { if (left.type === "SequenceExpression") { - throw this.raise(leftStartPos, `Pipeline head should not be a comma-separated sequence expression`); + this.raise(leftStartPos, `Pipeline head should not be a comma-separated sequence expression`); } } } @@ -23703,7 +25021,7 @@ class ExpressionParser extends LValParser { if (this.match(types.arrow)) { throw this.raise(this.state.start, `Unexpected arrow "=>" after pipeline body; arrow function in pipeline body must be parenthesized`); } else if (pipelineStyle === "PipelineTopicExpression" && childExpression.type === "SequenceExpression") { - throw this.raise(startPos, `Pipeline body may not be a comma-separated sequence expression`); + this.raise(startPos, `Pipeline body may not be a comma-separated sequence expression`); } } @@ -23725,14 +25043,14 @@ class ExpressionParser extends LValParser { case "PipelineTopicExpression": if (!this.topicReferenceWasUsedInCurrentTopicContext()) { - throw this.raise(startPos, `Pipeline is in topic style but does not use topic reference`); + this.raise(startPos, `Pipeline is in topic style but does not use topic reference`); } bodyNode.expression = childExpression; break; default: - throw this.raise(startPos, `Unknown pipeline style ${pipelineStyle}`); + throw new Error(`Internal @babel/parser error: Unknown pipeline style (${pipelineStyle})`); } return this.finishNode(bodyNode, pipelineStyle); @@ -23786,6 +25104,17 @@ class ExpressionParser extends LValParser { } } + withSoloAwaitPermittingContext(callback) { + const outerContextSoloAwaitState = this.state.soloAwait; + this.state.soloAwait = true; + + try { + return callback(); + } finally { + this.state.soloAwait = outerContextSoloAwaitState; + } + } + registerTopicReference() { this.state.topicContext.maxTopicIndex = 0; } @@ -23798,9 +25127,19 @@ class ExpressionParser extends LValParser { return this.state.topicContext.maxTopicIndex != null && this.state.topicContext.maxTopicIndex >= 0; } + parseFSharpPipelineBody(prec, noIn) { + const startPos = this.state.start; + const startLoc = this.state.startLoc; + this.state.potentialArrowAt = this.state.start; + const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody; + this.state.inFSharpPipelineDirectBody = true; + const ret = this.parseExprOp(this.parseMaybeUnary(), startPos, startLoc, prec, noIn); + this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody; + return ret; + } + } -const empty = []; const loopLabel = { kind: "loop" }, @@ -23817,7 +25156,7 @@ class StatementParser extends ExpressionParser { program.interpreter = this.parseInterpreterDirective(); this.parseBlockBody(program, true, true, types.eof); - if (this.inModule && this.scope.undefinedExports.size > 0) { + if (this.inModule && !this.options.allowUndeclaredExports && this.scope.undefinedExports.size > 0) { for (let _i = 0, _Array$from = Array.from(this.scope.undefinedExports); _i < _Array$from.length; _i++) { const [name] = _Array$from[_i]; const pos = this.scope.undefinedExports.get(name); @@ -23827,7 +25166,7 @@ class StatementParser extends ExpressionParser { file.program = this.finishNode(program, "Program"); file.comments = this.state.comments; - if (this.options.tokens) file.tokens = this.state.tokens; + if (this.options.tokens) file.tokens = this.tokens; return this.finishNode(file, "File"); } @@ -23859,9 +25198,7 @@ class StatementParser extends ExpressionParser { return false; } - skipWhiteSpace.lastIndex = this.state.pos; - const skip = skipWhiteSpace.exec(this.input); - const next = this.state.pos + skip[0].length; + const next = this.nextTokenStart(); const nextCh = this.input.charCodeAt(next); if (nextCh === 91) return true; if (context) return false; @@ -23914,7 +25251,7 @@ class StatementParser extends ExpressionParser { return this.parseForStatement(node); case types._function: - if (this.lookahead().type === types.dot) break; + if (this.lookaheadCharCode() === 46) break; if (context) { if (this.state.strict) { @@ -23950,7 +25287,7 @@ class StatementParser extends ExpressionParser { kind = kind || this.state.value; if (context && kind !== "var") { - this.unexpected(this.state.start, "Lexical declaration cannot appear in a single-statement context"); + this.raise(this.state.start, "Lexical declaration cannot appear in a single-statement context"); } return this.parseVarStatement(node, kind); @@ -23970,9 +25307,9 @@ class StatementParser extends ExpressionParser { case types._export: case types._import: { - const nextToken = this.lookahead(); + const nextTokenCharCode = this.lookaheadCharCode(); - if (nextToken.type === types.parenL || nextToken.type === types.dot) { + if (nextTokenCharCode === 40 || nextTokenCharCode === 46) { break; } @@ -24005,7 +25342,7 @@ class StatementParser extends ExpressionParser { { if (this.isAsyncFunction()) { if (context) { - this.unexpected(null, "Async functions can only be declared at the top level or inside a block"); + this.raise(this.state.start, "Async functions can only be declared at the top level or inside a block"); } this.next(); @@ -24063,7 +25400,7 @@ class StatementParser extends ExpressionParser { this.raise(this.state.start, "Using the export keyword between a decorator and a class is not allowed. " + "Please use `export @dec class` instead."); } } else if (!this.canHaveLeadingDecorator()) { - this.raise(this.state.start, "Leading decorators must be attached to a class declaration"); + throw this.raise(this.state.start, "Leading decorators must be attached to a class declaration"); } } @@ -24096,7 +25433,7 @@ class StatementParser extends ExpressionParser { node.expression = this.parseMaybeDecoratorArguments(expr); this.state.decoratorStack.pop(); } else { - node.expression = this.parseMaybeAssign(); + node.expression = this.parseExprSubscripts(); } return this.finishNode(node, "Decorator"); @@ -24176,7 +25513,7 @@ class StatementParser extends ExpressionParser { this.state.labels.push(loopLabel); let awaitAt = -1; - if ((this.scope.inAsync || !this.scope.inFunction && this.options.allowAwaitOutsideFunction) && this.eatContextual("await")) { + if (this.isAwaitAllowed() && this.eatContextual("await")) { awaitAt = this.state.lastTokStart; } @@ -24211,18 +25548,16 @@ class StatementParser extends ExpressionParser { return this.parseFor(node, init); } - const refShorthandDefaultPos = { - start: 0 - }; - const init = this.parseExpression(true, refShorthandDefaultPos); + const refExpressionErrors = new ExpressionErrors(); + const init = this.parseExpression(true, refExpressionErrors); if (this.match(types._in) || this.isContextual("of")) { + this.toAssignable(init); const description = this.isContextual("of") ? "for-of statement" : "for-in statement"; - this.toAssignable(init, undefined, description); this.checkLVal(init, undefined, undefined, description); return this.parseForIn(node, init, awaitAt); - } else if (refShorthandDefaultPos.start) { - this.unexpected(refShorthandDefaultPos.start); + } else { + this.checkExpressionErrors(refExpressionErrors, true); } if (awaitAt > -1) { @@ -24345,7 +25680,6 @@ class StatementParser extends ExpressionParser { node.handler = this.finishNode(clause, "CatchClause"); } - node.guardedHandlers = empty; node.finalizer = this.eat(types._finally) ? this.parseBlock() : null; if (!node.handler && !node.finalizer) { @@ -24559,12 +25893,8 @@ class StatementParser extends ExpressionParser { } parseVarId(decl, kind) { - if ((kind === "const" || kind === "let") && this.isContextual("let")) { - this.unexpected(null, "let is disallowed as a lexically bound name"); - } - decl.id = this.parseBindingAtom(); - this.checkLVal(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, undefined, "variable declaration"); + this.checkLVal(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, undefined, "variable declaration", kind !== "var"); } parseFunction(node, statement = FUNC_NO_FLAGS, isAsync = false) { @@ -24574,7 +25904,7 @@ class StatementParser extends ExpressionParser { this.initFunction(node, isAsync); if (this.match(types.star) && isHangingStatement) { - this.unexpected(this.state.start, "Generators can only be declared at the top level or inside a block"); + this.raise(this.state.start, "Generators can only be declared at the top level or inside a block"); } node.generator = this.eat(types.star); @@ -24583,12 +25913,12 @@ class StatementParser extends ExpressionParser { node.id = this.parseFunctionId(requireId); } - const oldInClassProperty = this.state.inClassProperty; + const oldMaybeInArrowParameters = this.state.maybeInArrowParameters; const oldYieldPos = this.state.yieldPos; const oldAwaitPos = this.state.awaitPos; - this.state.inClassProperty = false; - this.state.yieldPos = 0; - this.state.awaitPos = 0; + this.state.maybeInArrowParameters = false; + this.state.yieldPos = -1; + this.state.awaitPos = -1; this.scope.enter(functionFlags(node.async, node.generator)); if (!isStatement) { @@ -24602,10 +25932,10 @@ class StatementParser extends ExpressionParser { this.scope.exit(); if (isStatement && !isHangingStatement) { - this.checkFunctionStatementId(node); + this.registerFunctionStatementId(node); } - this.state.inClassProperty = oldInClassProperty; + this.state.maybeInArrowParameters = oldMaybeInArrowParameters; this.state.yieldPos = oldYieldPos; this.state.awaitPos = oldAwaitPos; return node; @@ -24619,14 +25949,14 @@ class StatementParser extends ExpressionParser { const oldInParameters = this.state.inParameters; this.state.inParameters = true; this.expect(types.parenL); - node.params = this.parseBindingList(types.parenR, false, allowModifiers); + node.params = this.parseBindingList(types.parenR, 41, false, allowModifiers); this.state.inParameters = oldInParameters; this.checkYieldAwaitInDefaultParams(); } - checkFunctionStatementId(node) { + registerFunctionStatementId(node) { if (!node.id) return; - this.checkLVal(node.id, this.state.strict || node.generator || node.async ? this.scope.treatFunctionsAsVar ? BIND_VAR : BIND_LEXICAL : BIND_FUNCTION, null, "function name"); + this.scope.declareName(node.id.name, this.state.strict || node.generator || node.async ? this.scope.treatFunctionsAsVar ? BIND_VAR : BIND_LEXICAL : BIND_FUNCTION, node.id.start); } parseClass(node, isStatement, optionalId) { @@ -24654,7 +25984,7 @@ class StatementParser extends ExpressionParser { } parseClassBody(constructorAllowsSuper) { - this.state.classLevel++; + this.classScope.enter(); const state = { hadConstructor: false }; @@ -24666,7 +25996,7 @@ class StatementParser extends ExpressionParser { while (!this.eat(types.braceR)) { if (this.eat(types.semi)) { if (decorators.length > 0) { - this.raise(this.state.lastTokEnd, "Decorators must not be followed by a semicolon"); + throw this.raise(this.state.lastTokEnd, "Decorators must not be followed by a semicolon"); } continue; @@ -24694,10 +26024,10 @@ class StatementParser extends ExpressionParser { }); if (decorators.length) { - this.raise(this.state.start, "You have trailing decorators with no method"); + throw this.raise(this.state.start, "You have trailing decorators with no method"); } - this.state.classLevel--; + this.classScope.exit(); return this.finishNode(classBody, "ClassBody"); } @@ -24763,6 +26093,7 @@ class StatementParser extends ExpressionParser { const key = this.parseClassPropertyName(member); const isPrivate = key.type === "PrivateName"; const isSimple = key.type === "Identifier"; + const maybeQuestionTokenStart = this.state.start; this.parsePostMemberNameModifiers(publicMember); if (this.isClassMethod()) { @@ -24779,10 +26110,6 @@ class StatementParser extends ExpressionParser { if (isConstructor) { publicMethod.kind = "constructor"; - if (publicMethod.decorators) { - this.raise(publicMethod.start, "You can't attach decorators to a class constructor"); - } - if (state.hadConstructor && !this.hasPlugin("typescript")) { this.raise(key.start, "Duplicate constructor in the same class"); } @@ -24800,8 +26127,14 @@ class StatementParser extends ExpressionParser { } } else if (isSimple && key.name === "async" && !containsEsc && !this.isLineTerminator()) { const isGenerator = this.eat(types.star); + + if (publicMember.optional) { + this.unexpected(maybeQuestionTokenStart); + } + method.kind = "method"; this.parseClassPropertyName(method); + this.parsePostMemberNameModifiers(publicMember); if (method.key.type === "PrivateName") { this.pushClassPrivateMethod(classBody, privateMethod, isGenerator, true); @@ -24839,7 +26172,7 @@ class StatementParser extends ExpressionParser { } parseClassPropertyName(member) { - const key = this.parsePropertyName(member); + const key = this.parsePropertyName(member, true); if (!member.computed && member.static && (key.name === "prototype" || key.value === "prototype")) { this.raise(key.start, "Classes may not have static property named prototype"); @@ -24853,8 +26186,8 @@ class StatementParser extends ExpressionParser { } pushClassProperty(classBody, prop) { - if (this.isNonstaticConstructor(prop)) { - this.raise(prop.key.start, "Classes may not have a non-static field named 'constructor'"); + if (!prop.computed && (prop.key.name === "constructor" || prop.key.value === "constructor")) { + this.raise(prop.key.start, "Classes may not have a field named 'constructor'"); } classBody.body.push(this.parseClassProperty(prop)); @@ -24862,7 +26195,9 @@ class StatementParser extends ExpressionParser { pushClassPrivateProperty(classBody, prop) { this.expectPlugin("classPrivateProperties", prop.key.start); - classBody.body.push(this.parseClassPrivateProperty(prop)); + const node = this.parseClassPrivateProperty(prop); + classBody.body.push(node); + this.classScope.declarePrivateName(node.key.id.name, CLASS_ELEMENT_OTHER, node.key.start); } pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) { @@ -24871,7 +26206,10 @@ class StatementParser extends ExpressionParser { pushClassPrivateMethod(classBody, method, isGenerator, isAsync) { this.expectPlugin("classPrivateMethods", method.key.start); - classBody.body.push(this.parseMethod(method, isGenerator, isAsync, false, false, "ClassPrivateMethod", true)); + const node = this.parseMethod(method, isGenerator, isAsync, false, false, "ClassPrivateMethod", true); + classBody.body.push(node); + const kind = node.kind === "get" ? node.static ? CLASS_ELEMENT_STATIC_GETTER : CLASS_ELEMENT_INSTANCE_GETTER : node.kind === "set" ? node.static ? CLASS_ELEMENT_STATIC_SETTER : CLASS_ELEMENT_INSTANCE_SETTER : CLASS_ELEMENT_OTHER; + this.classScope.declarePrivateName(node.key.id.name, kind, node.key.start); } parsePostMemberNameModifiers(methodOrProp) {} @@ -24881,11 +26219,9 @@ class StatementParser extends ExpressionParser { } parseClassPrivateProperty(node) { - this.state.inClassProperty = true; this.scope.enter(SCOPE_CLASS | SCOPE_SUPER); node.value = this.eat(types.eq) ? this.parseMaybeAssign() : null; this.semicolon(); - this.state.inClassProperty = false; this.scope.exit(); return this.finishNode(node, "ClassPrivateProperty"); } @@ -24895,7 +26231,6 @@ class StatementParser extends ExpressionParser { this.expectPlugin("classProperties"); } - this.state.inClassProperty = true; this.scope.enter(SCOPE_CLASS | SCOPE_SUPER); if (this.match(types.eq)) { @@ -24907,17 +26242,16 @@ class StatementParser extends ExpressionParser { } this.semicolon(); - this.state.inClassProperty = false; this.scope.exit(); return this.finishNode(node, "ClassProperty"); } - parseClassId(node, isStatement, optionalId) { + parseClassId(node, isStatement, optionalId, bindingType = BIND_CLASS) { if (this.match(types.name)) { node.id = this.parseIdentifier(); if (isStatement) { - this.checkLVal(node.id, BIND_CLASS, undefined, "class name"); + this.checkLVal(node.id, bindingType, undefined, "class name"); } } else { if (optionalId || !isStatement) { @@ -24994,7 +26328,6 @@ class StatementParser extends ExpressionParser { maybeParseExportNamespaceSpecifier(node) { if (this.isContextual("as")) { if (!node.specifiers) node.specifiers = []; - this.expectPlugin("exportNamespaceFrom"); const specifier = this.startNodeAt(this.state.lastTokStart, this.state.lastTokStartLoc); this.next(); specifier.exported = this.parseIdentifier(true); @@ -25020,10 +26353,10 @@ class StatementParser extends ExpressionParser { maybeParseExportDeclaration(node) { if (this.shouldParseExportDeclaration()) { if (this.isContextual("async")) { - const next = this.lookahead(); + const next = this.nextTokenStart(); - if (next.type !== types._function) { - this.unexpected(next.start, `Unexpected token, expected "function"`); + if (!this.isUnparsedContextual(next, "function")) { + this.unexpected(next, `Unexpected token, expected "function"`); } } @@ -25038,14 +26371,8 @@ class StatementParser extends ExpressionParser { isAsyncFunction() { if (!this.isContextual("async")) return false; - const { - pos - } = this.state; - skipWhiteSpace.lastIndex = pos; - const skip = skipWhiteSpace.exec(this.input); - if (!skip || !skip.length) return false; - const next = pos + skip[0].length; - return !lineBreak.test(this.input.slice(pos, next)) && this.input.slice(next, next + 8) === "function" && (next + 8 === this.length || !isIdentifierChar(this.input.charCodeAt(next + 8))); + const next = this.nextTokenStart(); + return !lineBreak.test(this.input.slice(this.state.pos, next)) && this.isUnparsedContextual(next, "function"); } parseExportDefaultExpression() { @@ -25064,13 +26391,13 @@ class StatementParser extends ExpressionParser { return this.parseClass(expr, true, true); } else if (this.match(types.at)) { if (this.hasPlugin("decorators") && this.getPluginOption("decorators", "decoratorsBeforeExport")) { - this.unexpected(this.state.start, "Decorators must be placed *before* the 'export' keyword." + " You can set the 'decoratorsBeforeExport' option to false to use" + " the 'export @decorator class {}' syntax"); + this.raise(this.state.start, "Decorators must be placed *before* the 'export' keyword." + " You can set the 'decoratorsBeforeExport' option to false to use" + " the 'export @decorator class {}' syntax"); } this.parseDecorators(false); return this.parseClass(expr, true, true); } else if (this.match(types._const) || this.match(types._var) || this.isLet()) { - return this.raise(this.state.start, "Only expressions, functions or classes are allowed as the `default` export."); + throw this.raise(this.state.start, "Only expressions, functions or classes are allowed as the `default` export."); } else { const res = this.parseMaybeAssign(); this.semicolon(); @@ -25091,8 +26418,8 @@ class StatementParser extends ExpressionParser { return false; } - const lookahead = this.lookahead(); - return lookahead.type === types.comma || lookahead.type === types.name && lookahead.value === "from"; + const next = this.nextTokenStart(); + return this.input.charCodeAt(next) === 44 || this.isUnparsedContextual(next, "from"); } parseExportFrom(node, expect) { @@ -25194,7 +26521,7 @@ class StatementParser extends ExpressionParser { checkDuplicateExports(node, name) { if (this.state.exportedIdentifiers.indexOf(name) > -1) { - throw this.raise(node.start, name === "default" ? "Only one default export allowed per module." : `\`${name}\` has already been exported. Exported identifiers must be unique.`); + this.raise(node.start, name === "default" ? "Only one default export allowed per module." : `\`${name}\` has already been exported. Exported identifiers must be unique.`); } this.state.exportedIdentifiers.push(name); @@ -25283,7 +26610,7 @@ class StatementParser extends ExpressionParser { first = false; } else { if (this.eat(types.colon)) { - this.unexpected(null, "ES2015 named imports do not destructure. " + "Use another statement for destructuring after the import."); + throw this.raise(this.state.start, "ES2015 named imports do not destructure. " + "Use another statement for destructuring after the import."); } this.expect(types.comma); @@ -25311,6 +26638,94 @@ class StatementParser extends ExpressionParser { } +class ClassScope { + constructor() { + this.privateNames = new Set(); + this.loneAccessors = new Map(); + this.undefinedPrivateNames = new Map(); + } + +} +class ClassScopeHandler { + constructor(raise) { + this.stack = []; + this.undefinedPrivateNames = new Map(); + this.raise = raise; + } + + current() { + return this.stack[this.stack.length - 1]; + } + + enter() { + this.stack.push(new ClassScope()); + } + + exit() { + const oldClassScope = this.stack.pop(); + const current = this.current(); + + for (let _i = 0, _Array$from = Array.from(oldClassScope.undefinedPrivateNames); _i < _Array$from.length; _i++) { + const [name, pos] = _Array$from[_i]; + + if (current) { + if (!current.undefinedPrivateNames.has(name)) { + current.undefinedPrivateNames.set(name, pos); + } + } else { + this.raiseUndeclaredPrivateName(name, pos); + } + } + } + + declarePrivateName(name, elementType, pos) { + const classScope = this.current(); + let redefined = classScope.privateNames.has(name); + + if (elementType & CLASS_ELEMENT_KIND_ACCESSOR) { + const accessor = redefined && classScope.loneAccessors.get(name); + + if (accessor) { + const oldStatic = accessor & CLASS_ELEMENT_FLAG_STATIC; + const newStatic = elementType & CLASS_ELEMENT_FLAG_STATIC; + const oldKind = accessor & CLASS_ELEMENT_KIND_ACCESSOR; + const newKind = elementType & CLASS_ELEMENT_KIND_ACCESSOR; + redefined = oldKind === newKind || oldStatic !== newStatic; + if (!redefined) classScope.loneAccessors.delete(name); + } else if (!redefined) { + classScope.loneAccessors.set(name, elementType); + } + } + + if (redefined) { + this.raise(pos, `Duplicate private name #${name}`); + } + + classScope.privateNames.add(name); + classScope.undefinedPrivateNames.delete(name); + } + + usePrivateName(name, pos) { + let classScope; + + for (let _i2 = 0, _this$stack = this.stack; _i2 < _this$stack.length; _i2++) { + classScope = _this$stack[_i2]; + if (classScope.privateNames.has(name)) return; + } + + if (classScope) { + classScope.undefinedPrivateNames.set(name, pos); + } else { + this.raiseUndeclaredPrivateName(name, pos); + } + } + + raiseUndeclaredPrivateName(name, pos) { + this.raise(pos, `Private name #${name} is not defined`); + } + +} + class Parser extends StatementParser { constructor(options, input) { options = getOptions(options); @@ -25319,6 +26734,7 @@ class Parser extends StatementParser { this.options = options; this.inModule = this.options.sourceType === "module"; this.scope = new ScopeHandler(this.raise.bind(this), this.inModule); + this.classScope = new ClassScopeHandler(this.raise.bind(this)); this.plugins = pluginsMap(this.options.plugins); this.filename = options.sourceFilename; } @@ -25328,11 +26744,20 @@ class Parser extends StatementParser { } parse() { - this.scope.enter(SCOPE_PROGRAM); + let scopeFlags = SCOPE_PROGRAM; + + if (this.hasPlugin("topLevelAwait") && this.inModule) { + scopeFlags |= SCOPE_ASYNC; + } + + this.scope.enter(scopeFlags); const file = this.startNode(); const program = this.startNode(); this.nextToken(); - return this.parseTopLevel(file, program); + file.errors = null; + this.parseTopLevel(file, program); + file.errors = this.state.errors; + return file; } } @@ -25357,13 +26782,26 @@ function parse(input, options) { options.sourceType = "module"; const parser = getParser(options, input); const ast = parser.parse(); - if (!parser.sawUnambiguousESM) ast.program.sourceType = "script"; + + if (parser.sawUnambiguousESM) { + return ast; + } + + if (parser.ambiguousScriptDifferentAst) { + try { + options.sourceType = "script"; + return getParser(options, input).parse(); + } catch (_unused) {} + } else { + ast.program.sourceType = "script"; + } + return ast; } catch (moduleError) { try { options.sourceType = "script"; return getParser(options, input).parse(); - } catch (scriptError) {} + } catch (_unused2) {} throw moduleError; } @@ -25417,7 +26855,8 @@ exports.parse = parse; exports.parseExpression = parseExpression; exports.tokTypes = types; -},{}],72:[function(require,module,exports){ + +},{}],74:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -25425,58 +26864,26 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = void 0; -function _helperPluginUtils() { - const data = require("@babel/helper-plugin-utils"); - - _helperPluginUtils = function () { - return data; - }; - - return data; -} - -function _pluginSyntaxFunctionSent() { - const data = _interopRequireDefault(require("@babel/plugin-syntax-function-sent")); - - _pluginSyntaxFunctionSent = function () { - return data; - }; - - return data; -} - -function _helperWrapFunction() { - const data = _interopRequireDefault(require("@babel/helper-wrap-function")); - - _helperWrapFunction = function () { - return data; - }; - - return data; -} +var _helperPluginUtils = require("@babel/helper-plugin-utils"); -function _core() { - const data = require("@babel/core"); +var _pluginSyntaxFunctionSent = _interopRequireDefault(require("@babel/plugin-syntax-function-sent")); - _core = function () { - return data; - }; +var _helperWrapFunction = _interopRequireDefault(require("@babel/helper-wrap-function")); - return data; -} +var _core = require("@babel/core"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -var _default = (0, _helperPluginUtils().declare)(api => { +var _default = (0, _helperPluginUtils.declare)(api => { api.assertVersion(7); - const isFunctionSent = node => _core().types.isIdentifier(node.meta, { + const isFunctionSent = node => _core.types.isIdentifier(node.meta, { name: "function" - }) && _core().types.isIdentifier(node.property, { + }) && _core.types.isIdentifier(node.property, { name: "sent" }); - const hasBeenReplaced = (node, sentId) => _core().types.isAssignmentExpression(node) && _core().types.isIdentifier(node.left, { + const hasBeenReplaced = (node, sentId) => _core.types.isAssignmentExpression(node) && _core.types.isIdentifier(node.left, { name: sentId }); @@ -25487,20 +26894,20 @@ var _default = (0, _helperPluginUtils().declare)(api => { YieldExpression(path) { if (!hasBeenReplaced(path.parent, this.sentId)) { - path.replaceWith(_core().types.assignmentExpression("=", _core().types.identifier(this.sentId), path.node)); + path.replaceWith(_core.types.assignmentExpression("=", _core.types.identifier(this.sentId), path.node)); } }, MetaProperty(path) { if (isFunctionSent(path.node)) { - path.replaceWith(_core().types.identifier(this.sentId)); + path.replaceWith(_core.types.identifier(this.sentId)); } } }; return { name: "proposal-function-sent", - inherits: _pluginSyntaxFunctionSent().default, + inherits: _pluginSyntaxFunctionSent.default, visitor: { MetaProperty(path, state) { if (!isFunctionSent(path.node)) return; @@ -25514,8 +26921,8 @@ var _default = (0, _helperPluginUtils().declare)(api => { fnPath.traverse(yieldVisitor, { sentId }); - fnPath.node.body.body.unshift(_core().types.variableDeclaration("let", [_core().types.variableDeclarator(_core().types.identifier(sentId), _core().types.yieldExpression())])); - (0, _helperWrapFunction().default)(fnPath, state.addHelper("skipFirstGeneratorNext")); + fnPath.node.body.body.unshift(_core.types.variableDeclaration("let", [_core.types.variableDeclarator(_core.types.identifier(sentId), _core.types.yieldExpression())])); + (0, _helperWrapFunction.default)(fnPath, state.addHelper("skipFirstGeneratorNext")); } } @@ -25523,7 +26930,7 @@ var _default = (0, _helperPluginUtils().declare)(api => { }); exports.default = _default; -},{"@babel/core":22,"@babel/helper-plugin-utils":64,"@babel/helper-wrap-function":67,"@babel/plugin-syntax-function-sent":74}],73:[function(require,module,exports){ +},{"@babel/core":23,"@babel/helper-plugin-utils":66,"@babel/helper-wrap-function":69,"@babel/plugin-syntax-function-sent":76}],75:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -25531,17 +26938,9 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = void 0; -function _helperPluginUtils() { - const data = require("@babel/helper-plugin-utils"); - - _helperPluginUtils = function () { - return data; - }; - - return data; -} +var _helperPluginUtils = require("@babel/helper-plugin-utils"); -var _default = (0, _helperPluginUtils().declare)(api => { +var _default = (0, _helperPluginUtils.declare)(api => { api.assertVersion(7); return { name: "syntax-async-generators", @@ -25554,7 +26953,7 @@ var _default = (0, _helperPluginUtils().declare)(api => { }); exports.default = _default; -},{"@babel/helper-plugin-utils":64}],74:[function(require,module,exports){ +},{"@babel/helper-plugin-utils":66}],76:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -25562,17 +26961,9 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = void 0; -function _helperPluginUtils() { - const data = require("@babel/helper-plugin-utils"); - - _helperPluginUtils = function () { - return data; - }; - - return data; -} +var _helperPluginUtils = require("@babel/helper-plugin-utils"); -var _default = (0, _helperPluginUtils().declare)(api => { +var _default = (0, _helperPluginUtils.declare)(api => { api.assertVersion(7); return { name: "syntax-function-sent", @@ -25585,7 +26976,7 @@ var _default = (0, _helperPluginUtils().declare)(api => { }); exports.default = _default; -},{"@babel/helper-plugin-utils":64}],75:[function(require,module,exports){ +},{"@babel/helper-plugin-utils":66}],77:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -25593,17 +26984,9 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = void 0; -function _helperPluginUtils() { - const data = require("@babel/helper-plugin-utils"); - - _helperPluginUtils = function () { - return data; - }; - - return data; -} +var _helperPluginUtils = require("@babel/helper-plugin-utils"); -var _default = (0, _helperPluginUtils().declare)((api, options) => { +var _default = (0, _helperPluginUtils.declare)((api, options) => { api.assertVersion(7); const { spec @@ -25624,7 +27007,7 @@ var _default = (0, _helperPluginUtils().declare)((api, options) => { }); exports.default = _default; -},{"@babel/helper-plugin-utils":64}],76:[function(require,module,exports){ +},{"@babel/helper-plugin-utils":66}],78:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -25632,53 +27015,21 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = void 0; -function _helperPluginUtils() { - const data = require("@babel/helper-plugin-utils"); - - _helperPluginUtils = function () { - return data; - }; - - return data; -} +var _helperPluginUtils = require("@babel/helper-plugin-utils"); var _tdz = require("./tdz"); -function _values() { - const data = _interopRequireDefault(require("lodash/values")); - - _values = function () { - return data; - }; - - return data; -} - -function _extend() { - const data = _interopRequireDefault(require("lodash/extend")); - - _extend = function () { - return data; - }; - - return data; -} +var _values = _interopRequireDefault(require("lodash/values")); -function _core() { - const data = require("@babel/core"); - - _core = function () { - return data; - }; +var _extend = _interopRequireDefault(require("lodash/extend")); - return data; -} +var _core = require("@babel/core"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const DONE = new WeakSet(); -var _default = (0, _helperPluginUtils().declare)((api, opts) => { +var _default = (0, _helperPluginUtils.declare)((api, opts) => { api.assertVersion(7); const { throwIfClosureRequired = false, @@ -25690,7 +27041,7 @@ var _default = (0, _helperPluginUtils().declare)((api, opts) => { } if (typeof tdzEnabled !== "boolean") { - throw new Error(`.throwIfClosureRequired must be a boolean, or undefined`); + throw new Error(`.tdz must be a boolean, or undefined`); } return { @@ -25711,20 +27062,17 @@ var _default = (0, _helperPluginUtils().declare)((api, opts) => { for (let i = 0; i < node.declarations.length; i++) { const decl = node.declarations[i]; - if (decl.init) { - const assign = _core().types.assignmentExpression("=", decl.id, decl.init); - - assign._ignoreBlockScopingTDZ = true; - nodes.push(_core().types.expressionStatement(assign)); - } + const assign = _core.types.assignmentExpression("=", decl.id, decl.init || scope.buildUndefinedNode()); + assign._ignoreBlockScopingTDZ = true; + nodes.push(_core.types.expressionStatement(assign)); decl.init = this.addHelper("temporalUndefined"); } node._blockHoist = 2; if (path.isCompletionRecord()) { - nodes.push(_core().types.expressionStatement(scope.buildUndefinedNode())); + nodes.push(_core.types.expressionStatement(scope.buildUndefinedNode())); } path.replaceWithMultiple(nodes); @@ -25765,16 +27113,16 @@ var _default = (0, _helperPluginUtils().declare)((api, opts) => { exports.default = _default; function ignoreBlock(path) { - return _core().types.isLoop(path.parent) || _core().types.isCatchClause(path.parent); + return _core.types.isLoop(path.parent) || _core.types.isCatchClause(path.parent); } -const buildRetCheck = (0, _core().template)(` +const buildRetCheck = (0, _core.template)(` if (typeof RETURN === "object") return RETURN.v; `); function isBlockScoped(node) { - if (!_core().types.isVariableDeclaration(node)) return false; - if (node[_core().types.BLOCK_SCOPED_SYMBOL]) return true; + if (!_core.types.isVariableDeclaration(node)) return false; + if (node[_core.types.BLOCK_SCOPED_SYMBOL]) return true; if (node.kind !== "let" && node.kind !== "const") return false; return true; } @@ -25789,14 +27137,14 @@ function convertBlockScopedToVar(path, node, parent, scope, moveBindingsToParent node = path.node; } - if (isInLoop(path) && !_core().types.isFor(parent)) { + if (isInLoop(path) && !_core.types.isFor(parent)) { for (let i = 0; i < node.declarations.length; i++) { const declar = node.declarations[i]; declar.init = declar.init || scope.buildUndefinedNode(); } } - node[_core().types.BLOCK_SCOPED_SYMBOL] = true; + node[_core.types.BLOCK_SCOPED_SYMBOL] = true; node.kind = "var"; if (moveBindingsToParent) { @@ -25811,12 +27159,12 @@ function convertBlockScopedToVar(path, node, parent, scope, moveBindingsToParent } function isVar(node) { - return _core().types.isVariableDeclaration(node, { + return _core.types.isVariableDeclaration(node, { kind: "var" }) && !isBlockScoped(node); } -const letReferenceBlockVisitor = _core().traverse.visitors.merge([{ +const letReferenceBlockVisitor = _core.traverse.visitors.merge([{ Loop: { enter(path, state) { state.loopDepth++; @@ -25831,6 +27179,8 @@ const letReferenceBlockVisitor = _core().traverse.visitors.merge([{ Function(path, state) { if (state.loopDepth > 0) { path.traverse(letReferenceFunctionVisitor, state); + } else { + path.traverse(_tdz.visitor, state); } return path.skip(); @@ -25838,7 +27188,7 @@ const letReferenceBlockVisitor = _core().traverse.visitors.merge([{ }, _tdz.visitor]); -const letReferenceFunctionVisitor = _core().traverse.visitors.merge([{ +const letReferenceFunctionVisitor = _core.traverse.visitors.merge([{ ReferencedIdentifier(path, state) { const ref = state.letReferences[path.node.name]; if (!ref) return; @@ -25863,7 +27213,7 @@ const hoistVarDeclarationsVisitor = { if (nodes.length === 1) { node.init = nodes[0]; } else { - node.init = _core().types.sequenceExpression(nodes); + node.init = _core.types.sequenceExpression(nodes); } } } else if (path.isFor()) { @@ -25872,7 +27222,7 @@ const hoistVarDeclarationsVisitor = { node.left = node.left.declarations[0].id; } } else if (isVar(node, parent)) { - path.replaceWithMultiple(self.pushDeclar(node).map(expr => _core().types.expressionStatement(expr))); + path.replaceWithMultiple(self.pushDeclar(node).map(expr => _core.types.expressionStatement(expr))); } else if (path.isFunction()) { return path.skip(); } @@ -25905,9 +27255,9 @@ const continuationVisitor = { }; function loopNodeTo(node) { - if (_core().types.isBreakStatement(node)) { + if (_core.types.isBreakStatement(node)) { return "break"; - } else if (_core().types.isContinueStatement(node)) { + } else if (_core.types.isContinueStatement(node)) { return "continue"; } } @@ -25951,24 +27301,24 @@ const loopVisitor = { loopText = `${loopText}|${node.label.name}`; } else { if (state.ignoreLabeless) return; - if (_core().types.isBreakStatement(node) && state.inSwitchCase) return; + if (_core.types.isBreakStatement(node) && state.inSwitchCase) return; } state.hasBreakContinue = true; state.map[loopText] = node; - replace = _core().types.stringLiteral(loopText); + replace = _core.types.stringLiteral(loopText); } if (path.isReturnStatement()) { state.hasReturn = true; - replace = _core().types.objectExpression([_core().types.objectProperty(_core().types.identifier("v"), node.argument || scope.buildUndefinedNode())]); + replace = _core.types.objectExpression([_core.types.objectProperty(_core.types.identifier("v"), node.argument || scope.buildUndefinedNode())]); } if (replace) { - replace = _core().types.returnStatement(replace); + replace = _core.types.returnStatement(replace); replace[this.LOOP_IGNORE] = true; path.skip(); - path.replaceWith(_core().types.inherits(replace, node)); + path.replaceWith(_core.types.inherits(replace, node)); } } @@ -25990,7 +27340,7 @@ class BlockScoping { if (loopPath) { this.loopParent = loopPath.parent; - this.loopLabel = _core().types.isLabeledStatement(this.loopParent) && this.loopParent.label; + this.loopLabel = _core.types.isLabeledStatement(this.loopParent) && this.loopParent.label; this.loopPath = loopPath; this.loop = loopPath.node; } @@ -26003,7 +27353,7 @@ class BlockScoping { const needsClosure = this.getLetReferences(); this.checkConstants(); - if (_core().types.isFunction(this.parent) || _core().types.isProgram(this.block)) { + if (_core.types.isFunction(this.parent) || _core.types.isProgram(this.block)) { this.updateScopeInfo(); return; } @@ -26018,8 +27368,8 @@ class BlockScoping { this.updateScopeInfo(needsClosure); - if (this.loopLabel && !_core().types.isLabeledStatement(this.loopParent)) { - return _core().types.labeledStatement(this.loopLabel, this.loop); + if (this.loopLabel && !_core.types.isLabeledStatement(this.loopParent)) { + return _core.types.labeledStatement(this.loopLabel, this.loop); } } @@ -26034,37 +27384,39 @@ class BlockScoping { for (const violation of binding.constantViolations) { const readOnlyError = state.addHelper("readOnlyError"); - const throwNode = _core().types.callExpression(readOnlyError, [_core().types.stringLiteral(name)]); + const throwNode = _core.types.callExpression(readOnlyError, [_core.types.stringLiteral(name)]); if (violation.isAssignmentExpression()) { - violation.get("right").replaceWith(_core().types.sequenceExpression([throwNode, violation.get("right").node])); + violation.get("right").replaceWith(_core.types.sequenceExpression([throwNode, violation.get("right").node])); } else if (violation.isUpdateExpression()) { - violation.replaceWith(_core().types.sequenceExpression([throwNode, violation.node])); + violation.replaceWith(_core.types.sequenceExpression([throwNode, violation.node])); } else if (violation.isForXStatement()) { violation.ensureBlock(); - violation.node.body.body.unshift(_core().types.expressionStatement(throwNode)); + violation.node.body.body.unshift(_core.types.expressionStatement(throwNode)); } } } } updateScopeInfo(wrappedInClosure) { - const scope = this.scope; - const parentScope = scope.getFunctionParent() || scope.getProgramParent(); + const blockScope = this.blockPath.scope; + const parentScope = blockScope.getFunctionParent() || blockScope.getProgramParent(); const letRefs = this.letReferences; for (const key of Object.keys(letRefs)) { const ref = letRefs[key]; - const binding = scope.getBinding(ref.name); + const binding = blockScope.getBinding(ref.name); if (!binding) continue; if (binding.kind === "let" || binding.kind === "const") { binding.kind = "var"; if (wrappedInClosure) { - scope.removeBinding(ref.name); + if (blockScope.hasOwnBinding(ref.name)) { + blockScope.removeBinding(ref.name); + } } else { - scope.moveBindingTo(ref.name, parentScope); + blockScope.moveBindingTo(ref.name, parentScope); } } } @@ -26123,31 +27475,31 @@ class BlockScoping { this.has = this.checkLoop(); this.hoistVarDeclarations(); - const args = (0, _values().default)(outsideRefs).map(id => _core().types.cloneNode(id)); - const params = args.map(id => _core().types.cloneNode(id)); + const args = (0, _values.default)(outsideRefs).map(id => _core.types.cloneNode(id)); + const params = args.map(id => _core.types.cloneNode(id)); const isSwitch = this.blockPath.isSwitchStatement(); - const fn = _core().types.functionExpression(null, params, _core().types.blockStatement(isSwitch ? [block] : block.body)); + const fn = _core.types.functionExpression(null, params, _core.types.blockStatement(isSwitch ? [block] : block.body)); this.addContinuations(fn); - let call = _core().types.callExpression(_core().types.nullLiteral(), args); + let call = _core.types.callExpression(_core.types.nullLiteral(), args); let basePath = ".callee"; - const hasYield = _core().traverse.hasType(fn.body, "YieldExpression", _core().types.FUNCTION_TYPES); + const hasYield = _core.traverse.hasType(fn.body, "YieldExpression", _core.types.FUNCTION_TYPES); if (hasYield) { fn.generator = true; - call = _core().types.yieldExpression(call, true); + call = _core.types.yieldExpression(call, true); basePath = ".argument" + basePath; } - const hasAsync = _core().traverse.hasType(fn.body, "AwaitExpression", _core().types.FUNCTION_TYPES); + const hasAsync = _core.traverse.hasType(fn.body, "AwaitExpression", _core.types.FUNCTION_TYPES); if (hasAsync) { fn.async = true; - call = _core().types.awaitExpression(call); + call = _core.types.awaitExpression(call); basePath = ".argument" + basePath; } @@ -26156,12 +27508,12 @@ class BlockScoping { if (this.has.hasReturn || this.has.hasBreakContinue) { const ret = this.scope.generateUid("ret"); - this.body.push(_core().types.variableDeclaration("var", [_core().types.variableDeclarator(_core().types.identifier(ret), call)])); + this.body.push(_core.types.variableDeclaration("var", [_core.types.variableDeclarator(_core.types.identifier(ret), call)])); placeholderPath = "declarations.0.init" + basePath; index = this.body.length - 1; this.buildHas(ret); } else { - this.body.push(_core().types.expressionStatement(call)); + this.body.push(_core.types.expressionStatement(call)); placeholderPath = "expression" + basePath; index = this.body.length - 1; } @@ -26186,8 +27538,8 @@ class BlockScoping { if (this.loop) { const loopId = this.scope.generateUid("loop"); - const p = this.loopPath.insertBefore(_core().types.variableDeclaration("var", [_core().types.variableDeclarator(_core().types.identifier(loopId), fn)])); - placeholder.replaceWith(_core().types.identifier(loopId)); + const p = this.loopPath.insertBefore(_core.types.variableDeclaration("var", [_core.types.variableDeclarator(_core.types.identifier(loopId), fn)])); + placeholder.replaceWith(_core.types.identifier(loopId)); fnPath = p[0].get("declarations.0.init"); } else { placeholder.replaceWith(fn); @@ -26210,12 +27562,12 @@ class BlockScoping { if (!state.reassignments[param.name]) continue; const paramName = param.name; const newParamName = this.scope.generateUid(param.name); - fn.params[i] = _core().types.identifier(newParamName); + fn.params[i] = _core.types.identifier(newParamName); this.scope.rename(paramName, newParamName, fn); state.returnStatements.forEach(returnStatement => { - returnStatement.insertBefore(_core().types.expressionStatement(_core().types.assignmentExpression("=", _core().types.identifier(paramName), _core().types.identifier(newParamName)))); + returnStatement.insertBefore(_core.types.expressionStatement(_core.types.assignmentExpression("=", _core.types.identifier(paramName), _core.types.identifier(newParamName)))); }); - fn.body.body.push(_core().types.expressionStatement(_core().types.assignmentExpression("=", _core().types.identifier(paramName), _core().types.identifier(newParamName)))); + fn.body.body.push(_core.types.expressionStatement(_core.types.assignmentExpression("=", _core.types.identifier(paramName), _core.types.identifier(newParamName)))); } } @@ -26228,14 +27580,14 @@ class BlockScoping { if (isBlockScoped(init)) { declarators.push(init); - (0, _extend().default)(this.outsideLetReferences, _core().types.getBindingIdentifiers(init)); + (0, _extend.default)(this.outsideLetReferences, _core.types.getBindingIdentifiers(init)); } } const addDeclarationsFromChild = (path, node) => { node = node || path.node; - if (_core().types.isClassDeclaration(node) || _core().types.isFunctionDeclaration(node) || isBlockScoped(node)) { + if (_core.types.isClassDeclaration(node) || _core.types.isFunctionDeclaration(node) || isBlockScoped(node)) { if (isBlockScoped(node)) { convertBlockScopedToVar(path, node, block, this.scope); } @@ -26243,7 +27595,7 @@ class BlockScoping { declarators = declarators.concat(node.declarations || node); } - if (_core().types.isLabeledStatement(node)) { + if (_core.types.isLabeledStatement(node)) { addDeclarationsFromChild(path.get("body"), node.body); } }; @@ -26272,9 +27624,9 @@ class BlockScoping { for (let i = 0; i < declarators.length; i++) { const declar = declarators[i]; - const keys = _core().types.getBindingIdentifiers(declar, false, true); + const keys = _core.types.getBindingIdentifiers(declar, false, true); - (0, _extend().default)(this.letReferences, keys); + (0, _extend.default)(this.letReferences, keys); this.hasLetReferences = true; } @@ -26284,7 +27636,7 @@ class BlockScoping { closurify: false, loopDepth: 0, tdzEnabled: this.tdzEnabled, - addHelper: name => this.addHelper(name) + addHelper: name => this.state.addHelper(name) }; if (isInLoop(this.blockPath)) { @@ -26318,22 +27670,22 @@ class BlockScoping { pushDeclar(node) { const declars = []; - const names = _core().types.getBindingIdentifiers(node); + const names = _core.types.getBindingIdentifiers(node); for (const name of Object.keys(names)) { - declars.push(_core().types.variableDeclarator(names[name])); + declars.push(_core.types.variableDeclarator(names[name])); } - this.body.push(_core().types.variableDeclaration(node.kind, declars)); + this.body.push(_core.types.variableDeclaration(node.kind, declars)); const replace = []; for (let i = 0; i < node.declarations.length; i++) { const declar = node.declarations[i]; if (!declar.init) continue; - const expr = _core().types.assignmentExpression("=", _core().types.cloneNode(declar.id), _core().types.cloneNode(declar.init)); + const expr = _core.types.assignmentExpression("=", _core.types.cloneNode(declar.id), _core.types.cloneNode(declar.init)); - replace.push(_core().types.inherits(expr, declar)); + replace.push(_core.types.inherits(expr, declar)); } return replace; @@ -26347,38 +27699,38 @@ class BlockScoping { if (has.hasReturn) { retCheck = buildRetCheck({ - RETURN: _core().types.identifier(ret) + RETURN: _core.types.identifier(ret) }); } if (has.hasBreakContinue) { for (const key of Object.keys(has.map)) { - cases.push(_core().types.switchCase(_core().types.stringLiteral(key), [has.map[key]])); + cases.push(_core.types.switchCase(_core.types.stringLiteral(key), [has.map[key]])); } if (has.hasReturn) { - cases.push(_core().types.switchCase(null, [retCheck])); + cases.push(_core.types.switchCase(null, [retCheck])); } if (cases.length === 1) { const single = cases[0]; - body.push(_core().types.ifStatement(_core().types.binaryExpression("===", _core().types.identifier(ret), single.test), single.consequent[0])); + body.push(_core.types.ifStatement(_core.types.binaryExpression("===", _core.types.identifier(ret), single.test), single.consequent[0])); } else { if (this.loop) { for (let i = 0; i < cases.length; i++) { const caseConsequent = cases[i].consequent[0]; - if (_core().types.isBreakStatement(caseConsequent) && !caseConsequent.label) { + if (_core.types.isBreakStatement(caseConsequent) && !caseConsequent.label) { if (!this.loopLabel) { this.loopLabel = this.scope.generateUidIdentifier("loop"); } - caseConsequent.label = _core().types.cloneNode(this.loopLabel); + caseConsequent.label = _core.types.cloneNode(this.loopLabel); } } } - body.push(_core().types.switchStatement(_core().types.identifier(ret), cases)); + body.push(_core.types.switchStatement(_core.types.identifier(ret), cases)); } } else { if (has.hasReturn) { @@ -26388,7 +27740,7 @@ class BlockScoping { } } -},{"./tdz":77,"@babel/core":22,"@babel/helper-plugin-utils":64,"lodash/extend":384,"lodash/values":420}],77:[function(require,module,exports){ +},{"./tdz":79,"@babel/core":23,"@babel/helper-plugin-utils":66,"lodash/extend":390,"lodash/values":426}],79:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -26396,30 +27748,22 @@ Object.defineProperty(exports, "__esModule", { }); exports.visitor = void 0; -function _core() { - const data = require("@babel/core"); - - _core = function () { - return data; - }; - - return data; -} +var _core = require("@babel/core"); function getTDZStatus(refPath, bindingPath) { const executionStatus = bindingPath._guessExecutionStatusRelativeTo(refPath); if (executionStatus === "before") { - return "inside"; - } else if (executionStatus === "after") { return "outside"; + } else if (executionStatus === "after") { + return "inside"; } else { return "maybe"; } } function buildTDZAssert(node, state) { - return _core().types.callExpression(state.addHelper("temporalRef"), [node, _core().types.stringLiteral(node.name)]); + return _core.types.callExpression(state.addHelper("temporalRef"), [node, _core.types.stringLiteral(node.name)]); } function isReference(node, scope, state) { @@ -26443,7 +27787,7 @@ const visitor = { const bindingPath = scope.getBinding(node.name).path; if (bindingPath.isFunctionDeclaration()) return; const status = getTDZStatus(path, bindingPath); - if (status === "inside") return; + if (status === "outside") return; if (status === "maybe") { const assert = buildTDZAssert(node, state); @@ -26452,12 +27796,12 @@ const visitor = { if (path.parentPath.isUpdateExpression()) { if (parent._ignoreBlockScopingTDZ) return; - path.parentPath.replaceWith(_core().types.sequenceExpression([assert, parent])); + path.parentPath.replaceWith(_core.types.sequenceExpression([assert, parent])); } else { path.replaceWith(assert); } - } else if (status === "outside") { - path.replaceWith(_core().types.throwStatement(_core().types.inherits(_core().types.newExpression(_core().types.identifier("ReferenceError"), [_core().types.stringLiteral(`${node.name} is not defined - temporal dead zone`)]), node))); + } else if (status === "inside") { + path.replaceWith(_core.template.ast`${state.addHelper("tdz")}("${node.name}")`); } }, @@ -26475,21 +27819,21 @@ const visitor = { const id = ids[name]; if (isReference(id, path.scope, state)) { - nodes.push(buildTDZAssert(id, state)); + nodes.push(id); } } if (nodes.length) { node._ignoreBlockScopingTDZ = true; nodes.push(node); - path.replaceWithMultiple(nodes.map(_core().types.expressionStatement)); + path.replaceWithMultiple(nodes.map(n => _core.types.expressionStatement(n))); } } } }; exports.visitor = visitor; -},{"@babel/core":22}],78:[function(require,module,exports){ +},{"@babel/core":23}],80:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -26497,75 +27841,27 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = void 0; -function _helperPluginUtils() { - const data = require("@babel/helper-plugin-utils"); +var _helperPluginUtils = require("@babel/helper-plugin-utils"); - _helperPluginUtils = function () { - return data; - }; - - return data; -} - -function _helperAnnotateAsPure() { - const data = _interopRequireDefault(require("@babel/helper-annotate-as-pure")); - - _helperAnnotateAsPure = function () { - return data; - }; - - return data; -} - -function _helperFunctionName() { - const data = _interopRequireDefault(require("@babel/helper-function-name")); - - _helperFunctionName = function () { - return data; - }; - - return data; -} +var _helperAnnotateAsPure = _interopRequireDefault(require("@babel/helper-annotate-as-pure")); -function _helperSplitExportDeclaration() { - const data = _interopRequireDefault(require("@babel/helper-split-export-declaration")); +var _helperFunctionName = _interopRequireDefault(require("@babel/helper-function-name")); - _helperSplitExportDeclaration = function () { - return data; - }; +var _helperSplitExportDeclaration = _interopRequireDefault(require("@babel/helper-split-export-declaration")); - return data; -} - -function _core() { - const data = require("@babel/core"); - - _core = function () { - return data; - }; - - return data; -} - -function _globals() { - const data = _interopRequireDefault(require("globals")); - - _globals = function () { - return data; - }; +var _core = require("@babel/core"); - return data; -} +var _globals = _interopRequireDefault(require("globals")); var _transformClass = _interopRequireDefault(require("./transformClass")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -const getBuiltinClasses = category => Object.keys(_globals().default[category]).filter(name => /^[A-Z]/.test(name)); +const getBuiltinClasses = category => Object.keys(_globals.default[category]).filter(name => /^[A-Z]/.test(name)); const builtinClasses = new Set([...getBuiltinClasses("builtin"), ...getBuiltinClasses("browser")]); -var _default = (0, _helperPluginUtils().declare)((api, options) => { +var _default = (0, _helperPluginUtils.declare)((api, options) => { api.assertVersion(7); const { loose @@ -26576,7 +27872,7 @@ var _default = (0, _helperPluginUtils().declare)((api, options) => { visitor: { ExportDefaultDeclaration(path) { if (!path.get("declaration").isClassDeclaration()) return; - (0, _helperSplitExportDeclaration().default)(path); + (0, _helperSplitExportDeclaration.default)(path); }, ClassDeclaration(path) { @@ -26584,7 +27880,7 @@ var _default = (0, _helperPluginUtils().declare)((api, options) => { node } = path; const ref = node.id || path.scope.generateUidIdentifier("class"); - path.replaceWith(_core().types.variableDeclaration("let", [_core().types.variableDeclarator(ref, _core().types.toExpression(node))])); + path.replaceWith(_core.types.variableDeclaration("let", [_core.types.variableDeclarator(ref, _core.types.toExpression(node))])); }, ClassExpression(path, state) { @@ -26592,7 +27888,7 @@ var _default = (0, _helperPluginUtils().declare)((api, options) => { node } = path; if (node[VISITED]) return; - const inferred = (0, _helperFunctionName().default)(path); + const inferred = (0, _helperFunctionName.default)(path); if (inferred && inferred !== node) { path.replaceWith(inferred); @@ -26603,7 +27899,7 @@ var _default = (0, _helperPluginUtils().declare)((api, options) => { path.replaceWith((0, _transformClass.default)(path, state.file, builtinClasses, loose)); if (path.isCallExpression()) { - (0, _helperAnnotateAsPure().default)(path); + (0, _helperAnnotateAsPure.default)(path); if (path.get("callee").isArrowFunctionExpression()) { path.get("callee").arrowFunctionToExpression(); @@ -26616,7 +27912,7 @@ var _default = (0, _helperPluginUtils().declare)((api, options) => { }); exports.default = _default; -},{"./transformClass":79,"@babel/core":22,"@babel/helper-annotate-as-pure":58,"@babel/helper-function-name":60,"@babel/helper-plugin-utils":64,"@babel/helper-split-export-declaration":66,"globals":216}],79:[function(require,module,exports){ +},{"./transformClass":81,"@babel/core":23,"@babel/helper-annotate-as-pure":60,"@babel/helper-function-name":62,"@babel/helper-plugin-utils":66,"@babel/helper-split-export-declaration":68,"globals":222}],81:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -26624,64 +27920,26 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = transformClass; -function _helperFunctionName() { - const data = _interopRequireDefault(require("@babel/helper-function-name")); - - _helperFunctionName = function () { - return data; - }; - - return data; -} - -function _helperReplaceSupers() { - const data = _interopRequireWildcard(require("@babel/helper-replace-supers")); - - _helperReplaceSupers = function () { - return data; - }; - - return data; -} - -function _helperOptimiseCallExpression() { - const data = _interopRequireDefault(require("@babel/helper-optimise-call-expression")); - - _helperOptimiseCallExpression = function () { - return data; - }; +var _helperFunctionName = _interopRequireDefault(require("@babel/helper-function-name")); - return data; -} +var _helperReplaceSupers = _interopRequireWildcard(require("@babel/helper-replace-supers")); -function defineMap() { - const data = _interopRequireWildcard(require("@babel/helper-define-map")); +var _helperOptimiseCallExpression = _interopRequireDefault(require("@babel/helper-optimise-call-expression")); - defineMap = function () { - return data; - }; +var defineMap = _interopRequireWildcard(require("@babel/helper-define-map")); - return data; -} +var _core = require("@babel/core"); -function _core() { - const data = require("@babel/core"); +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } - _core = function () { - return data; - }; - - return data; -} - -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function buildConstructor(classRef, constructorBody, node) { - const func = _core().types.functionDeclaration(_core().types.cloneNode(classRef), [], constructorBody); + const func = _core.types.functionDeclaration(_core.types.cloneNode(classRef), [], constructorBody); - _core().types.inherits(func, node); + _core.types.inherits(func, node); return func; } @@ -26723,7 +27981,7 @@ function transformClass(path, file, builtinClasses, isLoose) { Object.assign(classState, newState); }; - const findThisesVisitor = _core().traverse.visitors.merge([_helperReplaceSupers().environmentVisitor, { + const findThisesVisitor = _core.traverse.visitors.merge([_helperReplaceSupers.environmentVisitor, { ThisExpression(path) { classState.superThises.push(path); } @@ -26745,10 +28003,10 @@ function transformClass(path, file, builtinClasses, isLoose) { mutatorMap = classState.instanceMutatorMap; } - const map = defineMap().push(mutatorMap, node, kind, classState.file, scope); + const map = defineMap.push(mutatorMap, node, kind, classState.file, scope); if (enumerable) { - map.enumerable = _core().types.booleanLiteral(true); + map.enumerable = _core.types.booleanLiteral(true); } return map; @@ -26767,7 +28025,7 @@ function transformClass(path, file, builtinClasses, isLoose) { let params, body; if (classState.isDerived) { - const constructor = _core().template.expression.ast` + const constructor = _core.template.expression.ast` (function () { super(...arguments); }) @@ -26776,10 +28034,10 @@ function transformClass(path, file, builtinClasses, isLoose) { body = constructor.body; } else { params = []; - body = _core().types.blockStatement([]); + body = _core.types.blockStatement([]); } - classState.path.get("body").unshiftContainer("body", _core().types.classMethod("constructor", _core().types.identifier("constructor"), params, body)); + classState.path.get("body").unshiftContainer("body", _core.types.classMethod("constructor", _core.types.identifier("constructor"), params, body)); } function buildBody() { @@ -26795,9 +28053,9 @@ function transformClass(path, file, builtinClasses, isLoose) { } = classState; constructorBody.body = constructorBody.body.concat(userConstructor.body.body); - _core().types.inherits(construct, userConstructor); + _core.types.inherits(construct, userConstructor); - _core().types.inherits(constructorBody, userConstructor.body); + _core.types.inherits(constructorBody, userConstructor.body); } pushDescriptors(); @@ -26817,9 +28075,9 @@ function transformClass(path, file, builtinClasses, isLoose) { throw path.buildCodeFrameError("Method has decorators, put the decorator plugin before the classes one."); } - if (_core().types.isClassMethod(node)) { + if (_core.types.isClassMethod(node)) { const isConstructor = node.kind === "constructor"; - const replaceSupers = new (_helperReplaceSupers().default)({ + const replaceSupers = new _helperReplaceSupers.default({ methodPath: path, objectRef: classState.classRef, superRef: classState.superName, @@ -26828,7 +28086,7 @@ function transformClass(path, file, builtinClasses, isLoose) { }); replaceSupers.replace(); const superReturns = []; - path.traverse(_core().traverse.visitors.merge([_helperReplaceSupers().environmentVisitor, { + path.traverse(_core.traverse.visitors.merge([_helperReplaceSupers.environmentVisitor, { ReturnStatement(path) { if (!path.getFunctionParent().isArrowFunctionExpression()) { superReturns.push(path); @@ -26864,33 +28122,33 @@ function transformClass(path, file, builtinClasses, isLoose) { let staticProps; if (classState.hasInstanceDescriptors) { - instanceProps = defineMap().toClassObject(classState.instanceMutatorMap); + instanceProps = defineMap.toClassObject(classState.instanceMutatorMap); } if (classState.hasStaticDescriptors) { - staticProps = defineMap().toClassObject(classState.staticMutatorMap); + staticProps = defineMap.toClassObject(classState.staticMutatorMap); } if (instanceProps || staticProps) { if (instanceProps) { - instanceProps = defineMap().toComputedObjectFromClass(instanceProps); + instanceProps = defineMap.toComputedObjectFromClass(instanceProps); } if (staticProps) { - staticProps = defineMap().toComputedObjectFromClass(staticProps); + staticProps = defineMap.toComputedObjectFromClass(staticProps); } - let args = [_core().types.cloneNode(classState.classRef), _core().types.nullLiteral(), _core().types.nullLiteral()]; + let args = [_core.types.cloneNode(classState.classRef), _core.types.nullLiteral(), _core.types.nullLiteral()]; if (instanceProps) args[1] = instanceProps; if (staticProps) args[2] = staticProps; let lastNonNullIndex = 0; for (let i = 0; i < args.length; i++) { - if (!_core().types.isNullLiteral(args[i])) lastNonNullIndex = i; + if (!_core.types.isNullLiteral(args[i])) lastNonNullIndex = i; } args = args.slice(0, lastNonNullIndex + 1); - body.push(_core().types.expressionStatement(_core().types.callExpression(classState.file.addHelper("createClass"), args))); + body.push(_core.types.expressionStatement(_core.types.callExpression(classState.file.addHelper("createClass"), args))); } clearDescriptors(); @@ -26901,31 +28159,31 @@ function transformClass(path, file, builtinClasses, isLoose) { let call; if (classState.isLoose) { - bareSuperNode.arguments.unshift(_core().types.thisExpression()); + bareSuperNode.arguments.unshift(_core.types.thisExpression()); - if (bareSuperNode.arguments.length === 2 && _core().types.isSpreadElement(bareSuperNode.arguments[1]) && _core().types.isIdentifier(bareSuperNode.arguments[1].argument, { + if (bareSuperNode.arguments.length === 2 && _core.types.isSpreadElement(bareSuperNode.arguments[1]) && _core.types.isIdentifier(bareSuperNode.arguments[1].argument, { name: "arguments" })) { bareSuperNode.arguments[1] = bareSuperNode.arguments[1].argument; - bareSuperNode.callee = _core().types.memberExpression(_core().types.cloneNode(superRef), _core().types.identifier("apply")); + bareSuperNode.callee = _core.types.memberExpression(_core.types.cloneNode(superRef), _core.types.identifier("apply")); } else { - bareSuperNode.callee = _core().types.memberExpression(_core().types.cloneNode(superRef), _core().types.identifier("call")); + bareSuperNode.callee = _core.types.memberExpression(_core.types.cloneNode(superRef), _core.types.identifier("call")); } - call = _core().types.logicalExpression("||", bareSuperNode, _core().types.thisExpression()); + call = _core.types.logicalExpression("||", bareSuperNode, _core.types.thisExpression()); } else { - bareSuperNode = (0, _helperOptimiseCallExpression().default)(_core().types.callExpression(classState.file.addHelper("getPrototypeOf"), [_core().types.cloneNode(classState.classRef)]), _core().types.thisExpression(), bareSuperNode.arguments); - call = _core().types.callExpression(classState.file.addHelper("possibleConstructorReturn"), [_core().types.thisExpression(), bareSuperNode]); + bareSuperNode = (0, _helperOptimiseCallExpression.default)(_core.types.callExpression(classState.file.addHelper("getPrototypeOf"), [_core.types.cloneNode(classState.classRef)]), _core.types.thisExpression(), bareSuperNode.arguments); + call = _core.types.callExpression(classState.file.addHelper("possibleConstructorReturn"), [_core.types.thisExpression(), bareSuperNode]); } if (bareSuper.parentPath.isExpressionStatement() && bareSuper.parentPath.container === body.node.body && body.node.body.length - 1 === bareSuper.parentPath.key) { if (classState.superThises.length) { - call = _core().types.assignmentExpression("=", thisRef(), call); + call = _core.types.assignmentExpression("=", thisRef(), call); } - bareSuper.parentPath.replaceWith(_core().types.returnStatement(call)); + bareSuper.parentPath.replaceWith(_core.types.returnStatement(call)); } else { - bareSuper.replaceWith(_core().types.assignmentExpression("=", thisRef(), call)); + bareSuper.replaceWith(_core.types.assignmentExpression("=", thisRef(), call)); } } @@ -26938,7 +28196,7 @@ function transformClass(path, file, builtinClasses, isLoose) { let thisRef = function () { const ref = path.scope.generateDeclaredUidIdentifier("this"); - thisRef = () => _core().types.cloneNode(ref); + thisRef = () => _core.types.cloneNode(ref); return ref; }; @@ -26956,11 +28214,11 @@ function transformClass(path, file, builtinClasses, isLoose) { continue; } - thisPath.replaceWith(_core().types.callExpression(classState.file.addHelper("assertThisInitialized"), [thisRef()])); + thisPath.replaceWith(_core.types.callExpression(classState.file.addHelper("assertThisInitialized"), [thisRef()])); } const bareSupers = new Set(); - path.traverse(_core().traverse.visitors.merge([_helperReplaceSupers().environmentVisitor, { + path.traverse(_core.traverse.visitors.merge([_helperReplaceSupers.environmentVisitor, { Super(path) { const { node, @@ -26998,18 +28256,18 @@ function transformClass(path, file, builtinClasses, isLoose) { if (classState.isLoose) { wrapReturn = returnArg => { - const thisExpr = _core().types.callExpression(classState.file.addHelper("assertThisInitialized"), [thisRef()]); + const thisExpr = _core.types.callExpression(classState.file.addHelper("assertThisInitialized"), [thisRef()]); - return returnArg ? _core().types.logicalExpression("||", returnArg, thisExpr) : thisExpr; + return returnArg ? _core.types.logicalExpression("||", returnArg, thisExpr) : thisExpr; }; } else { - wrapReturn = returnArg => _core().types.callExpression(classState.file.addHelper("possibleConstructorReturn"), [thisRef()].concat(returnArg || [])); + wrapReturn = returnArg => _core.types.callExpression(classState.file.addHelper("possibleConstructorReturn"), [thisRef()].concat(returnArg || [])); } const bodyPaths = body.get("body"); if (!bodyPaths.length || !bodyPaths.pop().isReturnStatement()) { - body.pushContainer("body", _core().types.returnStatement(guaranteedSuperBeforeFinish ? thisRef() : wrapReturn())); + body.pushContainer("body", _core.types.returnStatement(guaranteedSuperBeforeFinish ? thisRef() : wrapReturn())); } for (const returnPath of classState.superReturns) { @@ -27038,25 +28296,25 @@ function transformClass(path, file, builtinClasses, isLoose) { classRef = classState.protoAlias; } - const methodName = _core().types.memberExpression(_core().types.cloneNode(classRef), node.key, node.computed || _core().types.isLiteral(node.key)); + const methodName = _core.types.memberExpression(_core.types.cloneNode(classRef), node.key, node.computed || _core.types.isLiteral(node.key)); - let func = _core().types.functionExpression(null, node.params, node.body, node.generator, node.async); + let func = _core.types.functionExpression(null, node.params, node.body, node.generator, node.async); - _core().types.inherits(func, node); + _core.types.inherits(func, node); - const key = _core().types.toComputedKey(node, node.key); + const key = _core.types.toComputedKey(node, node.key); - if (_core().types.isStringLiteral(key)) { - func = (0, _helperFunctionName().default)({ + if (_core.types.isStringLiteral(key)) { + func = (0, _helperFunctionName.default)({ node: func, id: key, scope }); } - const expr = _core().types.expressionStatement(_core().types.assignmentExpression("=", methodName, func)); + const expr = _core.types.expressionStatement(_core.types.assignmentExpression("=", methodName, func)); - _core().types.inheritsComments(expr, node); + _core.types.inheritsComments(expr, node); classState.body.push(expr); return true; @@ -27071,9 +28329,9 @@ function transformClass(path, file, builtinClasses, isLoose) { protoAlias: classState.scope.generateUidIdentifier("proto") }); - const classProto = _core().types.memberExpression(classState.classRef, _core().types.identifier("prototype")); + const classProto = _core.types.memberExpression(classState.classRef, _core.types.identifier("prototype")); - const protoDeclaration = _core().types.variableDeclaration("var", [_core().types.variableDeclarator(classState.protoAlias, classProto)]); + const protoDeclaration = _core.types.variableDeclaration("var", [_core.types.variableDeclarator(classState.protoAlias, classProto)]); classState.body.push(protoDeclaration); } @@ -27094,11 +28352,11 @@ function transformClass(path, file, builtinClasses, isLoose) { construct } = classState; - _core().types.inheritsComments(construct, method); + _core.types.inheritsComments(construct, method); construct.params = method.params; - _core().types.inherits(construct.body, method.body); + _core.types.inherits(construct.body, method.body); construct.body.directives = method.body.directives; pushConstructorToBody(); @@ -27121,7 +28379,7 @@ function transformClass(path, file, builtinClasses, isLoose) { setState({ pushedInherits: true }); - classState.body.unshift(_core().types.expressionStatement(_core().types.callExpression(classState.file.addHelper(classState.isLoose ? "inheritsLoose" : "inherits"), [_core().types.cloneNode(classState.classRef), _core().types.cloneNode(classState.superName)]))); + classState.body.unshift(_core.types.expressionStatement(_core.types.callExpression(classState.file.addHelper(classState.isLoose ? "inheritsLoose" : "inherits"), [_core.types.cloneNode(classState.classRef), _core.types.cloneNode(classState.superName)]))); } function setupClosureParamsArgs() { @@ -27132,12 +28390,12 @@ function transformClass(path, file, builtinClasses, isLoose) { const closureArgs = []; if (classState.isDerived) { - const arg = classState.extendsNative ? _core().types.callExpression(classState.file.addHelper("wrapNativeSuper"), [_core().types.cloneNode(superName)]) : _core().types.cloneNode(superName); + const arg = classState.extendsNative ? _core.types.callExpression(classState.file.addHelper("wrapNativeSuper"), [_core.types.cloneNode(superName)]) : _core.types.cloneNode(superName); const param = classState.scope.generateUidIdentifierBasedOnNode(superName); closureParams.push(param); closureArgs.push(arg); setState({ - superName: _core().types.cloneNode(param) + superName: _core.types.cloneNode(param) }); } @@ -27158,10 +28416,10 @@ function transformClass(path, file, builtinClasses, isLoose) { }); setState({ classId: classState.node.id, - classRef: classState.node.id ? _core().types.identifier(classState.node.id.name) : classState.scope.generateUidIdentifier("class"), + classRef: classState.node.id ? _core.types.identifier(classState.node.id.name) : classState.scope.generateUidIdentifier("class"), superName: classState.node.superClass, isDerived: !!classState.node.superClass, - constructorBody: _core().types.blockStatement([]) + constructorBody: _core.types.blockStatement([]) }); setState({ extendsNative: classState.isDerived && builtinClasses.has(classState.superName.name) && !classState.scope.hasBinding(classState.superName.name, true) @@ -27184,16 +28442,16 @@ function transformClass(path, file, builtinClasses, isLoose) { buildBody(); if (!classState.isLoose) { - constructorBody.body.unshift(_core().types.expressionStatement(_core().types.callExpression(classState.file.addHelper("classCallCheck"), [_core().types.thisExpression(), _core().types.cloneNode(classState.classRef)]))); + constructorBody.body.unshift(_core.types.expressionStatement(_core.types.callExpression(classState.file.addHelper("classCallCheck"), [_core.types.thisExpression(), _core.types.cloneNode(classState.classRef)]))); } - body = body.concat(classState.staticPropBody.map(fn => fn(_core().types.cloneNode(classState.classRef)))); + body = body.concat(classState.staticPropBody.map(fn => fn(_core.types.cloneNode(classState.classRef)))); const isStrict = path.isInStrictMode(); let constructorOnly = classState.classId && body.length === 1; if (constructorOnly && !isStrict) { for (const param of classState.construct.params) { - if (!_core().types.isIdentifier(param)) { + if (!_core.types.isIdentifier(param)) { constructorOnly = false; break; } @@ -27203,23 +28461,23 @@ function transformClass(path, file, builtinClasses, isLoose) { const directives = constructorOnly ? body[0].body.directives : []; if (!isStrict) { - directives.push(_core().types.directive(_core().types.directiveLiteral("use strict"))); + directives.push(_core.types.directive(_core.types.directiveLiteral("use strict"))); } if (constructorOnly) { - return _core().types.toExpression(body[0]); + return _core.types.toExpression(body[0]); } - body.push(_core().types.returnStatement(_core().types.cloneNode(classState.classRef))); + body.push(_core.types.returnStatement(_core.types.cloneNode(classState.classRef))); - const container = _core().types.arrowFunctionExpression(closureParams, _core().types.blockStatement(body, directives)); + const container = _core.types.arrowFunctionExpression(closureParams, _core.types.blockStatement(body, directives)); - return _core().types.callExpression(container, closureArgs); + return _core.types.callExpression(container, closureArgs); } return classTransformer(path, file, builtinClasses, isLoose); } -},{"@babel/core":22,"@babel/helper-define-map":59,"@babel/helper-function-name":60,"@babel/helper-optimise-call-expression":63,"@babel/helper-replace-supers":65}],80:[function(require,module,exports){ +},{"@babel/core":23,"@babel/helper-define-map":61,"@babel/helper-function-name":62,"@babel/helper-optimise-call-expression":65,"@babel/helper-replace-supers":67}],82:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -27227,27 +28485,11 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = void 0; -function _helperPluginUtils() { - const data = require("@babel/helper-plugin-utils"); +var _helperPluginUtils = require("@babel/helper-plugin-utils"); - _helperPluginUtils = function () { - return data; - }; +var _core = require("@babel/core"); - return data; -} - -function _core() { - const data = require("@babel/core"); - - _core = function () { - return data; - }; - - return data; -} - -var _default = (0, _helperPluginUtils().declare)((api, options) => { +var _default = (0, _helperPluginUtils.declare)((api, options) => { api.assertVersion(7); const { loose, @@ -27269,33 +28511,39 @@ var _default = (0, _helperPluginUtils().declare)((api, options) => { const { left, right, - body + body, + await: isAwait } = path.node; + + if (isAwait) { + return; + } + const i = scope.generateUidIdentifier("i"); let array = scope.maybeGenerateMemoised(right, true); - const inits = [_core().types.variableDeclarator(i, _core().types.numericLiteral(0))]; + const inits = [_core.types.variableDeclarator(i, _core.types.numericLiteral(0))]; if (array) { - inits.push(_core().types.variableDeclarator(array, right)); + inits.push(_core.types.variableDeclarator(array, right)); } else { array = right; } - const item = _core().types.memberExpression(_core().types.cloneNode(array), _core().types.cloneNode(i), true); + const item = _core.types.memberExpression(_core.types.cloneNode(array), _core.types.cloneNode(i), true); let assignment; - if (_core().types.isVariableDeclaration(left)) { + if (_core.types.isVariableDeclaration(left)) { assignment = left; assignment.declarations[0].init = item; } else { - assignment = _core().types.expressionStatement(_core().types.assignmentExpression("=", left, item)); + assignment = _core.types.expressionStatement(_core.types.assignmentExpression("=", left, item)); } - const block = _core().types.toBlock(body); + const block = _core.types.toBlock(body); block.body.unshift(assignment); - path.replaceWith(_core().types.forStatement(_core().types.variableDeclaration("let", inits), _core().types.binaryExpression("<", _core().types.cloneNode(i), _core().types.memberExpression(_core().types.cloneNode(array), _core().types.identifier("length"))), _core().types.updateExpression("++", _core().types.cloneNode(i)), block)); + path.replaceWith(_core.types.forStatement(_core.types.variableDeclaration("let", inits), _core.types.binaryExpression("<", _core.types.cloneNode(i), _core.types.memberExpression(_core.types.cloneNode(array), _core.types.identifier("length"))), _core.types.updateExpression("++", _core.types.cloneNode(i)), block)); } } @@ -27303,10 +28551,10 @@ var _default = (0, _helperPluginUtils().declare)((api, options) => { } const pushComputedProps = loose ? pushComputedPropsLoose : pushComputedPropsSpec; - const buildForOfArray = (0, _core().template)(` + const buildForOfArray = (0, _core.template)(` for (var KEY = 0, NAME = ARR; KEY < NAME.length; KEY++) BODY; `); - const buildForOfLoose = (0, _core().template)(` + const buildForOfLoose = (0, _core.template)(` for (var LOOP_OBJECT = OBJECT, IS_ARRAY = Array.isArray(LOOP_OBJECT), INDEX = 0, @@ -27322,7 +28570,7 @@ var _default = (0, _helperPluginUtils().declare)((api, options) => { } } `); - const buildForOf = (0, _core().template)(` + const buildForOf = (0, _core.template)(` var ITERATOR_COMPLETION = true; var ITERATOR_HAD_ERROR_KEY = false; var ITERATOR_ERROR_KEY = undefined; @@ -27362,23 +28610,23 @@ var _default = (0, _helperPluginUtils().declare)((api, options) => { ARR: node.right }); - _core().types.inherits(loop, node); + _core.types.inherits(loop, node); - _core().types.ensureBlock(loop); + _core.types.ensureBlock(loop); - const iterationValue = _core().types.memberExpression(_core().types.cloneNode(right), _core().types.cloneNode(iterationKey), true); + const iterationValue = _core.types.memberExpression(_core.types.cloneNode(right), _core.types.cloneNode(iterationKey), true); const left = node.left; - if (_core().types.isVariableDeclaration(left)) { + if (_core.types.isVariableDeclaration(left)) { left.declarations[0].init = iterationValue; loop.body.body.unshift(left); } else { - loop.body.body.unshift(_core().types.expressionStatement(_core().types.assignmentExpression("=", left, iterationValue))); + loop.body.body.unshift(_core.types.expressionStatement(_core.types.assignmentExpression("=", left, iterationValue))); } if (path.parentPath.isLabeledStatement()) { - loop = _core().types.labeledStatement(path.parentPath.node.label, loop); + loop = _core.types.labeledStatement(path.parentPath.node.label, loop); } return [loop]; @@ -27398,7 +28646,7 @@ var _default = (0, _helperPluginUtils().declare)((api, options) => { ForOfStatement(path, state) { const right = path.get("right"); - if (right.isArrayExpression() || right.isGenericType("Array") || _core().types.isArrayTypeAnnotation(right.getTypeAnnotation())) { + if (right.isArrayExpression() || right.isGenericType("Array") || _core.types.isArrayTypeAnnotation(right.getTypeAnnotation())) { replaceWithArray(path); return; } @@ -27418,9 +28666,9 @@ var _default = (0, _helperPluginUtils().declare)((api, options) => { block.body = block.body.concat(node.body.body); - _core().types.inherits(loop, node); + _core.types.inherits(loop, node); - _core().types.inherits(loop.body, node.body); + _core.types.inherits(loop.body, node.body); if (build.replaceParent) { path.parentPath.replaceWithMultiple(build.node); @@ -27444,13 +28692,13 @@ var _default = (0, _helperPluginUtils().declare)((api, options) => { } = node; let declar, id, intermediate; - if (_core().types.isIdentifier(left) || _core().types.isPattern(left) || _core().types.isMemberExpression(left)) { + if (_core.types.isIdentifier(left) || _core.types.isPattern(left) || _core.types.isMemberExpression(left)) { id = left; intermediate = null; - } else if (_core().types.isVariableDeclaration(left)) { + } else if (_core.types.isVariableDeclaration(left)) { id = scope.generateUidIdentifier("ref"); - declar = _core().types.variableDeclaration(left.kind, [_core().types.variableDeclarator(left.declarations[0].id, _core().types.identifier(id.name))]); - intermediate = _core().types.variableDeclaration("var", [_core().types.variableDeclarator(_core().types.identifier(id.name))]); + declar = _core.types.variableDeclaration(left.kind, [_core.types.variableDeclarator(left.declarations[0].id, _core.types.identifier(id.name))]); + intermediate = _core.types.variableDeclaration("var", [_core.types.variableDeclarator(_core.types.identifier(id.name))]); } else { throw file.buildCodeFrameError(left, `Unknown node type ${left.type} in ForStatement`); } @@ -27466,12 +28714,12 @@ var _default = (0, _helperPluginUtils().declare)((api, options) => { INTERMEDIATE: intermediate }); - const isLabeledParent = _core().types.isLabeledStatement(parent); + const isLabeledParent = _core.types.isLabeledStatement(parent); let labeled; if (isLabeledParent) { - labeled = _core().types.labeledStatement(parent.label, loop); + labeled = _core.types.labeledStatement(parent.label, loop); } return { @@ -27492,12 +28740,12 @@ var _default = (0, _helperPluginUtils().declare)((api, options) => { let declar; const stepKey = scope.generateUid("step"); - const stepValue = _core().types.memberExpression(_core().types.identifier(stepKey), _core().types.identifier("value")); + const stepValue = _core.types.memberExpression(_core.types.identifier(stepKey), _core.types.identifier("value")); - if (_core().types.isIdentifier(left) || _core().types.isPattern(left) || _core().types.isMemberExpression(left)) { - declar = _core().types.expressionStatement(_core().types.assignmentExpression("=", left, stepValue)); - } else if (_core().types.isVariableDeclaration(left)) { - declar = _core().types.variableDeclaration(left.kind, [_core().types.variableDeclarator(left.declarations[0].id, stepValue)]); + if (_core.types.isIdentifier(left) || _core.types.isPattern(left) || _core.types.isMemberExpression(left)) { + declar = _core.types.expressionStatement(_core.types.assignmentExpression("=", left, stepValue)); + } else if (_core.types.isVariableDeclaration(left)) { + declar = _core.types.variableDeclaration(left.kind, [_core.types.variableDeclarator(left.declarations[0].id, stepValue)]); } else { throw file.buildCodeFrameError(left, `Unknown node type ${left.type} in ForStatement`); } @@ -27507,17 +28755,17 @@ var _default = (0, _helperPluginUtils().declare)((api, options) => { ITERATOR_COMPLETION: scope.generateUidIdentifier("iteratorNormalCompletion"), ITERATOR_ERROR_KEY: scope.generateUidIdentifier("iteratorError"), ITERATOR_KEY: scope.generateUidIdentifier("iterator"), - STEP_KEY: _core().types.identifier(stepKey), + STEP_KEY: _core.types.identifier(stepKey), OBJECT: node.right }); - const isLabeledParent = _core().types.isLabeledStatement(parent); + const isLabeledParent = _core.types.isLabeledStatement(parent); const tryBody = template[3].block.body; const loop = tryBody[0]; if (isLabeledParent) { - tryBody[0] = _core().types.labeledStatement(parent.label, loop); + tryBody[0] = _core.types.labeledStatement(parent.label, loop); } return { @@ -27530,7 +28778,89 @@ var _default = (0, _helperPluginUtils().declare)((api, options) => { }); exports.default = _default; -},{"@babel/core":22,"@babel/helper-plugin-utils":64}],81:[function(require,module,exports){ +},{"@babel/core":23,"@babel/helper-plugin-utils":66}],83:[function(require,module,exports){ +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { + "default": obj + }; +} + +module.exports = _interopRequireDefault; +},{}],84:[function(require,module,exports){ +var _typeof = require("../helpers/typeof"); + +function _getRequireWildcardCache() { + if (typeof WeakMap !== "function") return null; + var cache = new WeakMap(); + + _getRequireWildcardCache = function _getRequireWildcardCache() { + return cache; + }; + + return cache; +} + +function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } + + if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { + return { + "default": obj + }; + } + + var cache = _getRequireWildcardCache(); + + if (cache && cache.has(obj)) { + return cache.get(obj); + } + + var newObj = {}; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + + if (desc && (desc.get || desc.set)) { + Object.defineProperty(newObj, key, desc); + } else { + newObj[key] = obj[key]; + } + } + } + + newObj["default"] = obj; + + if (cache) { + cache.set(obj, newObj); + } + + return newObj; +} + +module.exports = _interopRequireWildcard; +},{"../helpers/typeof":85}],85:[function(require,module,exports){ +function _typeof(obj) { + "@babel/helpers - typeof"; + + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + module.exports = _typeof = function _typeof(obj) { + return typeof obj; + }; + } else { + module.exports = _typeof = function _typeof(obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); +} + +module.exports = _typeof; +},{}],86:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -27614,7 +28944,7 @@ function extendedTrace(fn) { } }; } -},{"./literal":84,"./options":85,"./string":88}],82:[function(require,module,exports){ +},{"./literal":89,"./options":90,"./string":93}],87:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -27678,7 +29008,7 @@ const program = { unwrap: ast => ast.program }; exports.program = program; -},{}],83:[function(require,module,exports){ +},{}],88:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -27692,7 +29022,9 @@ var _builder = _interopRequireDefault(require("./builder")); 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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } const smart = (0, _builder.default)(formatters.smart); exports.smart = smart; @@ -27715,7 +29047,7 @@ var _default = Object.assign(smart.bind(undefined), { }); exports.default = _default; -},{"./builder":81,"./formatters":82}],84:[function(require,module,exports){ +},{"./builder":86,"./formatters":87}],89:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -27798,7 +29130,7 @@ function buildTemplateCode(tpl, prefix) { code }; } -},{"./options":85,"./parse":86,"./populate":87}],85:[function(require,module,exports){ +},{"./options":90,"./parse":91,"./populate":92}],90:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -27818,7 +29150,7 @@ function merge(a, b) { syntacticPlaceholders = a.syntacticPlaceholders } = b; return { - parser: Object.assign({}, a.parser, b.parser), + parser: Object.assign({}, a.parser, {}, b.parser), placeholderWhitelist, placeholderPattern, preserveComments, @@ -27881,7 +29213,7 @@ function normalizeReplacements(replacements) { throw new Error("Template replacements must be an array, object, null, or undefined"); } -},{}],86:[function(require,module,exports){ +},{}],91:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -27889,37 +29221,15 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = parseAndBuildMetadata; -function t() { - const data = _interopRequireWildcard(require("@babel/types")); +var t = _interopRequireWildcard(require("@babel/types")); - t = function () { - return data; - }; +var _parser = require("@babel/parser"); - return data; -} +var _codeFrame = require("@babel/code-frame"); -function _parser() { - const data = require("@babel/parser"); +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } - _parser = function () { - return data; - }; - - return data; -} - -function _codeFrame() { - const data = require("@babel/code-frame"); - - _codeFrame = function () { - return data; - }; - - return data; -} - -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } const PATTERN = /^[_$A-Z0-9]+$/; @@ -27931,7 +29241,7 @@ function parseAndBuildMetadata(formatter, code, opts) { preserveComments, syntacticPlaceholders } = opts; - t().removePropertiesDeep(ast, { + t.removePropertiesDeep(ast, { preserveComments }); formatter.validate(ast); @@ -27946,7 +29256,7 @@ function parseAndBuildMetadata(formatter, code, opts) { const isLegacyRef = { value: undefined }; - t().traverse(ast, placeholderVisitorHandler, { + t.traverse(ast, placeholderVisitorHandler, { syntactic, legacy, isLegacyRef, @@ -27962,7 +29272,7 @@ function parseAndBuildMetadata(formatter, code, opts) { function placeholderVisitorHandler(node, ancestors, state) { let name; - if (t().isPlaceholder(node)) { + if (t.isPlaceholder(node)) { if (state.syntacticPlaceholders === false) { throw new Error("%%foo%%-style placeholders can't be used when " + "'.syntacticPlaceholders' is false."); } else { @@ -27971,10 +29281,10 @@ function placeholderVisitorHandler(node, ancestors, state) { } } else if (state.isLegacyRef.value === false || state.syntacticPlaceholders) { return; - } else if (t().isIdentifier(node) || t().isJSXIdentifier(node)) { + } else if (t.isIdentifier(node) || t.isJSXIdentifier(node)) { name = node.name; state.isLegacyRef.value = true; - } else if (t().isStringLiteral(node)) { + } else if (t.isStringLiteral(node)) { name = node.value; state.isLegacyRef.value = true; } else { @@ -27996,16 +29306,16 @@ function placeholderVisitorHandler(node, ancestors, state) { } = ancestors[ancestors.length - 1]; let type; - if (t().isStringLiteral(node) || t().isPlaceholder(node, { + if (t.isStringLiteral(node) || t.isPlaceholder(node, { expectedNode: "StringLiteral" })) { type = "string"; - } else if (t().isNewExpression(parent) && key === "arguments" || t().isCallExpression(parent) && key === "arguments" || t().isFunction(parent) && key === "params") { + } else if (t.isNewExpression(parent) && key === "arguments" || t.isCallExpression(parent) && key === "arguments" || t.isFunction(parent) && key === "params") { type = "param"; - } else if (t().isExpressionStatement(parent) && !t().isPlaceholder(node)) { + } else if (t.isExpressionStatement(parent) && !t.isPlaceholder(node)) { type = "statement"; ancestors = ancestors.slice(0, -1); - } else if (t().isStatement(node) && t().isPlaceholder(node)) { + } else if (t.isStatement(node) && t.isPlaceholder(node)) { type = "statement"; } else { type = "other"; @@ -28061,12 +29371,12 @@ function parseWithCodeFrame(code, parserOpts) { }); try { - return (0, _parser().parse)(code, parserOpts); + return (0, _parser.parse)(code, parserOpts); } catch (err) { const loc = err.loc; if (loc) { - err.message += "\n" + (0, _codeFrame().codeFrameColumns)(code, { + err.message += "\n" + (0, _codeFrame.codeFrameColumns)(code, { start: loc }); err.code = "BABEL_TEMPLATE_PARSE_ERROR"; @@ -28075,7 +29385,7 @@ function parseWithCodeFrame(code, parserOpts) { throw err; } } -},{"@babel/code-frame":4,"@babel/parser":71,"@babel/types":155}],87:[function(require,module,exports){ +},{"@babel/code-frame":4,"@babel/parser":73,"@babel/types":160}],92:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -28083,20 +29393,14 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = populatePlaceholders; -function t() { - const data = _interopRequireWildcard(require("@babel/types")); - - t = function () { - return data; - }; +var t = _interopRequireWildcard(require("@babel/types")); - return data; -} +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function populatePlaceholders(metadata, replacements) { - const ast = t().cloneNode(metadata.ast); + const ast = t.cloneNode(metadata.ast); if (replacements) { metadata.placeholders.forEach(placeholder => { @@ -28129,9 +29433,9 @@ function populatePlaceholders(metadata, replacements) { function applyReplacement(placeholder, ast, replacement) { if (placeholder.isDuplicate) { if (Array.isArray(replacement)) { - replacement = replacement.map(node => t().cloneNode(node)); + replacement = replacement.map(node => t.cloneNode(node)); } else if (typeof replacement === "object") { - replacement = t().cloneNode(replacement); + replacement = t.cloneNode(replacement); } } @@ -28143,43 +29447,43 @@ function applyReplacement(placeholder, ast, replacement) { if (placeholder.type === "string") { if (typeof replacement === "string") { - replacement = t().stringLiteral(replacement); + replacement = t.stringLiteral(replacement); } - if (!replacement || !t().isStringLiteral(replacement)) { + if (!replacement || !t.isStringLiteral(replacement)) { throw new Error("Expected string substitution"); } } else if (placeholder.type === "statement") { if (index === undefined) { if (!replacement) { - replacement = t().emptyStatement(); + replacement = t.emptyStatement(); } else if (Array.isArray(replacement)) { - replacement = t().blockStatement(replacement); + replacement = t.blockStatement(replacement); } else if (typeof replacement === "string") { - replacement = t().expressionStatement(t().identifier(replacement)); - } else if (!t().isStatement(replacement)) { - replacement = t().expressionStatement(replacement); + replacement = t.expressionStatement(t.identifier(replacement)); + } else if (!t.isStatement(replacement)) { + replacement = t.expressionStatement(replacement); } } else { if (replacement && !Array.isArray(replacement)) { if (typeof replacement === "string") { - replacement = t().identifier(replacement); + replacement = t.identifier(replacement); } - if (!t().isStatement(replacement)) { - replacement = t().expressionStatement(replacement); + if (!t.isStatement(replacement)) { + replacement = t.expressionStatement(replacement); } } } } else if (placeholder.type === "param") { if (typeof replacement === "string") { - replacement = t().identifier(replacement); + replacement = t.identifier(replacement); } if (index === undefined) throw new Error("Assertion failure."); } else { if (typeof replacement === "string") { - replacement = t().identifier(replacement); + replacement = t.identifier(replacement); } if (Array.isArray(replacement)) { @@ -28188,7 +29492,7 @@ function applyReplacement(placeholder, ast, replacement) { } if (index === undefined) { - t().validate(parent, key, replacement); + t.validate(parent, key, replacement); parent[key] = replacement; } else { const items = parent[key].slice(); @@ -28205,11 +29509,11 @@ function applyReplacement(placeholder, ast, replacement) { items[index] = replacement; } - t().validate(parent, key, items); + t.validate(parent, key, items); parent[key] = items; } } -},{"@babel/types":155}],88:[function(require,module,exports){ +},{"@babel/types":160}],93:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -28234,7 +29538,7 @@ function stringTemplate(formatter, code, opts) { return formatter.unwrap((0, _populate.default)(metadata, replacements)); }; } -},{"./options":85,"./parse":86,"./populate":87}],89:[function(require,module,exports){ +},{"./options":90,"./parse":91,"./populate":92}],94:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -28261,7 +29565,7 @@ function clearPath() { function clearScope() { exports.scope = scope = new WeakMap(); } -},{}],90:[function(require,module,exports){ +},{}],95:[function(require,module,exports){ (function (process){ "use strict"; @@ -28272,17 +29576,11 @@ exports.default = void 0; var _path = _interopRequireDefault(require("./path")); -function t() { - const data = _interopRequireWildcard(require("@babel/types")); +var t = _interopRequireWildcard(require("@babel/types")); - t = function () { - return data; - }; - - return data; -} +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -28301,7 +29599,7 @@ class TraversalContext { const opts = this.opts; if (opts.enter || opts.exit) return true; if (opts[node.type]) return true; - const keys = t().VISITOR_KEYS[node.type]; + const keys = t.VISITOR_KEYS[node.type]; if (!keys || !keys.length) return false; for (const key of keys) { @@ -28416,7 +29714,7 @@ class TraversalContext { exports.default = TraversalContext; }).call(this,require('_process')) -},{"./path":99,"@babel/types":155,"_process":426}],91:[function(require,module,exports){ +},{"./path":104,"@babel/types":160,"_process":433}],96:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -28440,7 +29738,7 @@ class Hub { } exports.default = Hub; -},{}],92:[function(require,module,exports){ +},{}],97:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -28473,25 +29771,9 @@ var visitors = _interopRequireWildcard(require("./visitors")); exports.visitors = visitors; -function _includes() { - const data = _interopRequireDefault(require("lodash/includes")); +var _includes = _interopRequireDefault(require("lodash/includes")); - _includes = function () { - return data; - }; - - return data; -} - -function t() { - const data = _interopRequireWildcard(require("@babel/types")); - - t = function () { - return data; - }; - - return data; -} +var t = _interopRequireWildcard(require("@babel/types")); var cache = _interopRequireWildcard(require("./cache")); @@ -28501,7 +29783,9 @@ var _scope = _interopRequireDefault(require("./scope")); var _hub = _interopRequireDefault(require("./hub")); -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -28515,6 +29799,10 @@ function traverse(parent, opts, scope, state, parentPath) { } } + if (!t.VISITOR_KEYS[parent.type]) { + return; + } + visitors.explode(opts); traverse.node(parent, opts, scope, state, parentPath); } @@ -28524,11 +29812,11 @@ traverse.verify = visitors.verify; traverse.explode = visitors.explode; traverse.cheap = function (node, enter) { - return t().traverseFast(node, enter); + return t.traverseFast(node, enter); }; traverse.node = function (node, opts, scope, state, parentPath, skipKeys) { - const keys = t().VISITOR_KEYS[node.type]; + const keys = t.VISITOR_KEYS[node.type]; if (!keys) return; const context = new _context.default(scope, opts, state, parentPath); @@ -28539,12 +29827,12 @@ traverse.node = function (node, opts, scope, state, parentPath, skipKeys) { }; traverse.clearNode = function (node, opts) { - t().removeProperties(node, opts); + t.removeProperties(node, opts); cache.path.delete(node); }; traverse.removeProperties = function (tree, opts) { - t().traverseFast(tree, traverse.clearNode, opts); + t.traverseFast(tree, traverse.clearNode, opts); return tree; }; @@ -28556,7 +29844,7 @@ function hasBlacklistedType(path, state) { } traverse.hasType = function (tree, type, blacklistTypes) { - if ((0, _includes().default)(blacklistTypes, tree.type)) return false; + if ((0, _includes.default)(blacklistTypes, tree.type)) return false; if (tree.type === type) return true; const state = { has: false, @@ -28571,7 +29859,7 @@ traverse.hasType = function (tree, type, blacklistTypes) { }; traverse.cache = cache; -},{"./cache":89,"./context":90,"./hub":91,"./path":99,"./scope":111,"./visitors":113,"@babel/types":155,"lodash/includes":389}],93:[function(require,module,exports){ +},{"./cache":94,"./context":95,"./hub":96,"./path":104,"./scope":116,"./visitors":118,"@babel/types":160,"lodash/includes":395}],98:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -28588,21 +29876,15 @@ exports.isAncestor = isAncestor; exports.isDescendant = isDescendant; exports.inType = inType; -function t() { - const data = _interopRequireWildcard(require("@babel/types")); - - t = function () { - return data; - }; - - return data; -} +var t = _interopRequireWildcard(require("@babel/types")); var _index = _interopRequireDefault(require("./index")); 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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function findParent(callback) { let path = this; @@ -28649,7 +29931,7 @@ function getStatementParent() { function getEarliestCommonAncestorFrom(paths) { return this.getDeepestCommonAncestorFrom(paths, function (deepest, i, ancestries) { let earliest; - const keys = t().VISITOR_KEYS[deepest.type]; + const keys = t.VISITOR_KEYS[deepest.type]; for (const ancestry of ancestries) { const path = ancestry[i + 1]; @@ -28760,7 +30042,7 @@ function inType() { return false; } -},{"./index":99,"@babel/types":155}],94:[function(require,module,exports){ +},{"./index":104,"@babel/types":160}],99:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -28770,17 +30052,11 @@ exports.shareCommentsWithSiblings = shareCommentsWithSiblings; exports.addComment = addComment; exports.addComments = addComments; -function t() { - const data = _interopRequireWildcard(require("@babel/types")); - - t = function () { - return data; - }; +var t = _interopRequireWildcard(require("@babel/types")); - return data; -} +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function shareCommentsWithSiblings() { if (typeof this.key === "string") return; @@ -28802,13 +30078,13 @@ function shareCommentsWithSiblings() { } function addComment(type, content, line) { - t().addComment(this.node, type, content, line); + t.addComment(this.node, type, content, line); } function addComments(type, comments) { - t().addComments(this.node, type, comments); + t.addComments(this.node, type, comments); } -},{"@babel/types":155}],95:[function(require,module,exports){ +},{"@babel/types":160}],100:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -28837,6 +30113,8 @@ exports._getQueueContexts = _getQueueContexts; var _index = _interopRequireDefault(require("../index")); +var _index2 = require("./index"); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function call(key) { @@ -28864,7 +30142,7 @@ function _call(fns) { const ret = fn.call(this.state, this, this.state); if (ret && typeof ret === "object" && typeof ret.then === "function") { - throw new Error(`You appear to be using a plugin with an async traversal visitor, ` + `which your current version of Babel does not support.` + `If you're using a published plugin, you may need to upgrade ` + `your @babel/core version.`); + throw new Error(`You appear to be using a plugin with an async traversal visitor, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, you may need to upgrade ` + `your @babel/core version.`); } if (ret) { @@ -28872,7 +30150,7 @@ function _call(fns) { } if (this.node !== node) return true; - if (this.shouldStop || this.shouldSkip || this.removed) return true; + if (this._traverseFlags > 0) return true; } return false; @@ -28896,7 +30174,7 @@ function visit() { return false; } - if (this.call("enter") || this.shouldSkip) { + if (this.shouldSkip || this.call("enter") || this.shouldSkip) { this.debug("Skip..."); return this.shouldStop; } @@ -28914,12 +30192,15 @@ function skip() { } function skipKey(key) { + if (this.skipKeys == null) { + this.skipKeys = {}; + } + this.skipKeys[key] = true; } function stop() { - this.shouldStop = true; - this.shouldSkip = true; + this._traverseFlags |= _index2.SHOULD_SKIP | _index2.SHOULD_STOP; } function setScope() { @@ -28938,10 +30219,11 @@ function setScope() { } function setContext(context) { - this.shouldSkip = false; - this.shouldStop = false; - this.removed = false; - this.skipKeys = {}; + if (this.skipKeys != null) { + this.skipKeys = {}; + } + + this._traverseFlags = 0; if (context) { this.context = context; @@ -29019,9 +30301,7 @@ function pushContext(context) { } function setup(parentPath, container, listKey, key) { - this.inList = !!listKey; this.listKey = listKey; - this.parentKey = listKey || key; this.container = container; this.parentPath = parentPath || this.parentPath; this.setKey(key); @@ -29054,7 +30334,7 @@ function _getQueueContexts() { return contexts; } -},{"../index":92}],96:[function(require,module,exports){ +},{"../index":97,"./index":104}],101:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -29066,29 +30346,15 @@ exports.arrowFunctionToShadowed = arrowFunctionToShadowed; exports.unwrapFunctionEnvironment = unwrapFunctionEnvironment; exports.arrowFunctionToExpression = arrowFunctionToExpression; -function t() { - const data = _interopRequireWildcard(require("@babel/types")); - - t = function () { - return data; - }; - - return data; -} - -function _helperFunctionName() { - const data = _interopRequireDefault(require("@babel/helper-function-name")); +var t = _interopRequireWildcard(require("@babel/types")); - _helperFunctionName = function () { - return data; - }; - - return data; -} +var _helperFunctionName = _interopRequireDefault(require("@babel/helper-function-name")); 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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function toComputedKey() { const node = this.node; @@ -29103,7 +30369,7 @@ function toComputedKey() { } if (!node.computed) { - if (t().isIdentifier(key)) key = t().stringLiteral(key.name); + if (t.isIdentifier(key)) key = t.stringLiteral(key.name); } return key; @@ -29139,14 +30405,14 @@ function ensureBlock() { if (this.isFunction()) { key = "argument"; - statements.push(t().returnStatement(body.node)); + statements.push(t.returnStatement(body.node)); } else { key = "expression"; - statements.push(t().expressionStatement(body.node)); + statements.push(t.expressionStatement(body.node)); } } - this.node.body = t().blockStatement(statements); + this.node.body = t.blockStatement(statements); const parentPath = this.get(stringPath); body.setup(parentPath, listKey ? parentPath.node[listKey] : parentPath.node, listKey, key); return this.node; @@ -29183,12 +30449,12 @@ function arrowFunctionToExpression({ if (checkBinding) { this.parentPath.scope.push({ id: checkBinding, - init: t().objectExpression([]) + init: t.objectExpression([]) }); } - this.get("body").unshiftContainer("body", t().expressionStatement(t().callExpression(this.hub.addHelper("newArrowCheck"), [t().thisExpression(), checkBinding ? t().identifier(checkBinding.name) : t().identifier(thisBinding)]))); - this.replaceWith(t().callExpression(t().memberExpression((0, _helperFunctionName().default)(this, true) || this.node, t().identifier("bind")), [checkBinding ? t().identifier(checkBinding.name) : t().thisExpression()])); + this.get("body").unshiftContainer("body", t.expressionStatement(t.callExpression(this.hub.addHelper("newArrowCheck"), [t.thisExpression(), checkBinding ? t.identifier(checkBinding.name) : t.identifier(thisBinding)]))); + this.replaceWith(t.callExpression(t.memberExpression((0, _helperFunctionName.default)(this, true) || this.node, t.identifier("bind")), [checkBinding ? t.identifier(checkBinding.name) : t.thisExpression()])); } } @@ -29236,40 +30502,25 @@ function hoistFunctionEnvironment(fnPath, specCompliant = false, allowInsertArro }); const superBinding = getSuperBinding(thisEnvFn); allSuperCalls.forEach(superCall => { - const callee = t().identifier(superBinding); + const callee = t.identifier(superBinding); callee.loc = superCall.node.callee.loc; superCall.get("callee").replaceWith(callee); }); } - let thisBinding; - - if (thisPaths.length > 0 || specCompliant) { - thisBinding = getThisBinding(thisEnvFn, inConstructor); - - if (!specCompliant || inConstructor && hasSuperClass(thisEnvFn)) { - thisPaths.forEach(thisChild => { - const thisRef = thisChild.isJSX() ? t().jsxIdentifier(thisBinding) : t().identifier(thisBinding); - thisRef.loc = thisChild.node.loc; - thisChild.replaceWith(thisRef); - }); - if (specCompliant) thisBinding = null; - } - } - if (argumentsPaths.length > 0) { - const argumentsBinding = getBinding(thisEnvFn, "arguments", () => t().identifier("arguments")); + const argumentsBinding = getBinding(thisEnvFn, "arguments", () => t.identifier("arguments")); argumentsPaths.forEach(argumentsChild => { - const argsRef = t().identifier(argumentsBinding); + const argsRef = t.identifier(argumentsBinding); argsRef.loc = argumentsChild.node.loc; argumentsChild.replaceWith(argsRef); }); } if (newTargetPaths.length > 0) { - const newTargetBinding = getBinding(thisEnvFn, "newtarget", () => t().metaProperty(t().identifier("new"), t().identifier("target"))); + const newTargetBinding = getBinding(thisEnvFn, "newtarget", () => t.metaProperty(t.identifier("new"), t.identifier("target"))); newTargetPaths.forEach(targetChild => { - const targetRef = t().identifier(newTargetBinding); + const targetRef = t.identifier(newTargetBinding); targetRef.loc = targetChild.node.loc; targetChild.replaceWith(targetRef); }); @@ -29283,41 +30534,53 @@ function hoistFunctionEnvironment(fnPath, specCompliant = false, allowInsertArro const flatSuperProps = superProps.reduce((acc, superProp) => acc.concat(standardizeSuperProperty(superProp)), []); flatSuperProps.forEach(superProp => { const key = superProp.node.computed ? "" : superProp.get("property").node.name; - - if (superProp.parentPath.isCallExpression({ + const isAssignment = superProp.parentPath.isAssignmentExpression({ + left: superProp.node + }); + const isCall = superProp.parentPath.isCallExpression({ callee: superProp.node - })) { - const superBinding = getSuperPropCallBinding(thisEnvFn, key); + }); + const superBinding = getSuperPropBinding(thisEnvFn, isAssignment, key); + const args = []; - if (superProp.node.computed) { - const prop = superProp.get("property").node; - superProp.replaceWith(t().identifier(superBinding)); - superProp.parentPath.node.arguments.unshift(prop); - } else { - superProp.replaceWith(t().identifier(superBinding)); - } - } else { - const isAssignment = superProp.parentPath.isAssignmentExpression({ - left: superProp.node - }); - const superBinding = getSuperPropBinding(thisEnvFn, isAssignment, key); - const args = []; + if (superProp.node.computed) { + args.push(superProp.get("property").node); + } - if (superProp.node.computed) { - args.push(superProp.get("property").node); - } + if (isAssignment) { + const value = superProp.parentPath.node.right; + args.push(value); + } - if (isAssignment) { - const value = superProp.parentPath.node.right; - args.push(value); - superProp.parentPath.replaceWith(t().callExpression(t().identifier(superBinding), args)); - } else { - superProp.replaceWith(t().callExpression(t().identifier(superBinding), args)); - } + const call = t.callExpression(t.identifier(superBinding), args); + + if (isCall) { + superProp.parentPath.unshiftContainer("arguments", t.thisExpression()); + superProp.replaceWith(t.memberExpression(call, t.identifier("call"))); + thisPaths.push(superProp.parentPath.get("arguments.0")); + } else if (isAssignment) { + superProp.parentPath.replaceWith(call); + } else { + superProp.replaceWith(call); } }); } + let thisBinding; + + if (thisPaths.length > 0 || specCompliant) { + thisBinding = getThisBinding(thisEnvFn, inConstructor); + + if (!specCompliant || inConstructor && hasSuperClass(thisEnvFn)) { + thisPaths.forEach(thisChild => { + const thisRef = thisChild.isJSX() ? t.jsxIdentifier(thisBinding) : t.identifier(thisBinding); + thisRef.loc = thisChild.node.loc; + thisChild.replaceWith(thisRef); + }); + if (specCompliant) thisBinding = null; + } + } + return thisBinding; } @@ -29330,11 +30593,11 @@ function standardizeSuperProperty(superProp) { if (superProp.node.computed) { const tmp = superProp.scope.generateDeclaredUidIdentifier("tmp"); - assignmentPath.get("left").replaceWith(t().memberExpression(superProp.node.object, t().assignmentExpression("=", tmp, superProp.node.property), true)); - assignmentPath.get("right").replaceWith(t().binaryExpression(op, t().memberExpression(superProp.node.object, t().identifier(tmp.name), true), value)); + assignmentPath.get("left").replaceWith(t.memberExpression(superProp.node.object, t.assignmentExpression("=", tmp, superProp.node.property), true)); + assignmentPath.get("right").replaceWith(t.binaryExpression(op, t.memberExpression(superProp.node.object, t.identifier(tmp.name), true), value)); } else { - assignmentPath.get("left").replaceWith(t().memberExpression(superProp.node.object, superProp.node.property)); - assignmentPath.get("right").replaceWith(t().binaryExpression(op, t().memberExpression(superProp.node.object, t().identifier(superProp.node.property.name)), value)); + assignmentPath.get("left").replaceWith(t.memberExpression(superProp.node.object, superProp.node.property)); + assignmentPath.get("right").replaceWith(t.binaryExpression(op, t.memberExpression(superProp.node.object, t.identifier(superProp.node.property.name)), value)); } return [assignmentPath.get("left"), assignmentPath.get("right").get("left")]; @@ -29342,13 +30605,13 @@ function standardizeSuperProperty(superProp) { const updateExpr = superProp.parentPath; const tmp = superProp.scope.generateDeclaredUidIdentifier("tmp"); const computedKey = superProp.node.computed ? superProp.scope.generateDeclaredUidIdentifier("prop") : null; - const parts = [t().assignmentExpression("=", tmp, t().memberExpression(superProp.node.object, computedKey ? t().assignmentExpression("=", computedKey, superProp.node.property) : superProp.node.property, superProp.node.computed)), t().assignmentExpression("=", t().memberExpression(superProp.node.object, computedKey ? t().identifier(computedKey.name) : superProp.node.property, superProp.node.computed), t().binaryExpression("+", t().identifier(tmp.name), t().numericLiteral(1)))]; + const parts = [t.assignmentExpression("=", tmp, t.memberExpression(superProp.node.object, computedKey ? t.assignmentExpression("=", computedKey, superProp.node.property) : superProp.node.property, superProp.node.computed)), t.assignmentExpression("=", t.memberExpression(superProp.node.object, computedKey ? t.identifier(computedKey.name) : superProp.node.property, superProp.node.computed), t.binaryExpression("+", t.identifier(tmp.name), t.numericLiteral(1)))]; if (!superProp.parentPath.node.prefix) { - parts.push(t().identifier(tmp.name)); + parts.push(t.identifier(tmp.name)); } - updateExpr.replaceWith(t().sequenceExpression(parts)); + updateExpr.replaceWith(t.sequenceExpression(parts)); const left = updateExpr.get("expressions.0.right"); const right = updateExpr.get("expressions.1.left"); return [left, right]; @@ -29363,7 +30626,7 @@ function hasSuperClass(thisEnvFn) { function getThisBinding(thisEnvFn, inConstructor) { return getBinding(thisEnvFn, "this", thisBinding => { - if (!inConstructor || !hasSuperClass(thisEnvFn)) return t().thisExpression(); + if (!inConstructor || !hasSuperClass(thisEnvFn)) return t.thisExpression(); const supers = new WeakSet(); thisEnvFn.traverse({ Function(child) { @@ -29379,7 +30642,7 @@ function getThisBinding(thisEnvFn, inConstructor) { if (!child.get("callee").isSuper()) return; if (supers.has(child.node)) return; supers.add(child.node); - child.replaceWithMultiple([child.node, t().assignmentExpression("=", t().identifier(thisBinding), t().identifier("this"))]); + child.replaceWithMultiple([child.node, t.assignmentExpression("=", t.identifier(thisBinding), t.identifier("this"))]); } }); @@ -29389,25 +30652,7 @@ function getThisBinding(thisEnvFn, inConstructor) { function getSuperBinding(thisEnvFn) { return getBinding(thisEnvFn, "supercall", () => { const argsBinding = thisEnvFn.scope.generateUidIdentifier("args"); - return t().arrowFunctionExpression([t().restElement(argsBinding)], t().callExpression(t().super(), [t().spreadElement(t().identifier(argsBinding.name))])); - }); -} - -function getSuperPropCallBinding(thisEnvFn, propName) { - return getBinding(thisEnvFn, `superprop_call:${propName || ""}`, () => { - const argsBinding = thisEnvFn.scope.generateUidIdentifier("args"); - const argsList = [t().restElement(argsBinding)]; - let fnBody; - - if (propName) { - fnBody = t().callExpression(t().memberExpression(t().super(), t().identifier(propName)), [t().spreadElement(t().identifier(argsBinding.name))]); - } else { - const method = thisEnvFn.scope.generateUidIdentifier("prop"); - argsList.unshift(method); - fnBody = t().callExpression(t().memberExpression(t().super(), t().identifier(method.name), true), [t().spreadElement(t().identifier(argsBinding.name))]); - } - - return t().arrowFunctionExpression(argsList, fnBody); + return t.arrowFunctionExpression([t.restElement(argsBinding)], t.callExpression(t.super(), [t.spreadElement(t.identifier(argsBinding.name))])); }); } @@ -29418,20 +30663,20 @@ function getSuperPropBinding(thisEnvFn, isAssignment, propName) { let fnBody; if (propName) { - fnBody = t().memberExpression(t().super(), t().identifier(propName)); + fnBody = t.memberExpression(t.super(), t.identifier(propName)); } else { const method = thisEnvFn.scope.generateUidIdentifier("prop"); argsList.unshift(method); - fnBody = t().memberExpression(t().super(), t().identifier(method.name), true); + fnBody = t.memberExpression(t.super(), t.identifier(method.name), true); } if (isAssignment) { const valueIdent = thisEnvFn.scope.generateUidIdentifier("value"); argsList.push(valueIdent); - fnBody = t().assignmentExpression("=", fnBody, t().identifier(valueIdent.name)); + fnBody = t.assignmentExpression("=", fnBody, t.identifier(valueIdent.name)); } - return t().arrowFunctionExpression(argsList, fnBody); + return t.arrowFunctionExpression(argsList, fnBody); }); } @@ -29518,7 +30763,7 @@ function getScopeInformation(fnPath) { superCalls }; } -},{"@babel/helper-function-name":60,"@babel/types":155}],97:[function(require,module,exports){ +},{"@babel/helper-function-name":62,"@babel/types":160}],102:[function(require,module,exports){ (function (global){ "use strict"; @@ -29925,7 +31170,7 @@ function evaluate() { }; } }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],98:[function(require,module,exports){ +},{}],103:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -29948,17 +31193,11 @@ exports.getOuterBindingIdentifierPaths = getOuterBindingIdentifierPaths; var _index = _interopRequireDefault(require("./index")); -function t() { - const data = _interopRequireWildcard(require("@babel/types")); +var t = _interopRequireWildcard(require("@babel/types")); - t = function () { - return data; - }; +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } - return data; -} - -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -29975,6 +31214,57 @@ function addCompletionRecords(path, paths) { return paths; } +function completionRecordForSwitch(cases, paths) { + let isLastCaseWithConsequent = true; + + for (let i = cases.length - 1; i >= 0; i--) { + const switchCase = cases[i]; + const consequent = switchCase.get("consequent"); + let breakStatement; + + findBreak: for (const statement of consequent) { + if (statement.isBlockStatement()) { + for (const statementInBlock of statement.get("body")) { + if (statementInBlock.isBreakStatement()) { + breakStatement = statementInBlock; + break findBreak; + } + } + } else if (statement.isBreakStatement()) { + breakStatement = statement; + break; + } + } + + if (breakStatement) { + while (breakStatement.key === 0 && breakStatement.parentPath.isBlockStatement()) { + breakStatement = breakStatement.parentPath; + } + + const prevSibling = breakStatement.getPrevSibling(); + + if (breakStatement.key > 0 && (prevSibling.isExpressionStatement() || prevSibling.isBlockStatement())) { + paths = addCompletionRecords(prevSibling, paths); + breakStatement.remove(); + } else { + breakStatement.replaceWith(breakStatement.scope.buildUndefinedNode()); + paths = addCompletionRecords(breakStatement, paths); + } + } else if (isLastCaseWithConsequent) { + const statementFinder = statement => !statement.isBlockStatement() || statement.get("body").some(statementFinder); + + const hasConsequent = consequent.some(statementFinder); + + if (hasConsequent) { + paths = addCompletionRecords(consequent[consequent.length - 1], paths); + isLastCaseWithConsequent = false; + } + } + } + + return paths; +} + function getCompletionRecords() { let paths = []; @@ -29990,9 +31280,10 @@ function getCompletionRecords() { } else if (this.isTryStatement()) { paths = addCompletionRecords(this.get("block"), paths); paths = addCompletionRecords(this.get("handler"), paths); - paths = addCompletionRecords(this.get("finalizer"), paths); } else if (this.isCatchClause()) { paths = addCompletionRecords(this.get("body"), paths); + } else if (this.isSwitchStatement()) { + paths = completionRecordForSwitch(this.get("cases"), paths); } else { paths.push(this); } @@ -30098,11 +31389,11 @@ function _getPattern(parts, context) { } function getBindingIdentifiers(duplicates) { - return t().getBindingIdentifiers(this.node, duplicates); + return t.getBindingIdentifiers(this.node, duplicates); } function getOuterBindingIdentifiers(duplicates) { - return t().getOuterBindingIdentifiers(this.node, duplicates); + return t.getOuterBindingIdentifiers(this.node, duplicates); } function getBindingIdentifierPaths(duplicates = false, outerOnly = false) { @@ -30114,7 +31405,7 @@ function getBindingIdentifierPaths(duplicates = false, outerOnly = false) { const id = search.shift(); if (!id) continue; if (!id.node) continue; - const keys = t().getBindingIdentifiers.keys[id.node.type]; + const keys = t.getBindingIdentifiers.keys[id.node.type]; if (id.isIdentifier()) { if (duplicates) { @@ -30167,51 +31458,27 @@ function getBindingIdentifierPaths(duplicates = false, outerOnly = false) { function getOuterBindingIdentifierPaths(duplicates) { return this.getBindingIdentifierPaths(duplicates, true); } -},{"./index":99,"@babel/types":155}],99:[function(require,module,exports){ +},{"./index":104,"@babel/types":160}],104:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.default = void 0; +exports.default = exports.SHOULD_SKIP = exports.SHOULD_STOP = exports.REMOVED = void 0; var virtualTypes = _interopRequireWildcard(require("./lib/virtual-types")); -function _debug() { - const data = _interopRequireDefault(require("debug")); - - _debug = function () { - return data; - }; - - return data; -} +var _debug = _interopRequireDefault(require("debug")); var _index = _interopRequireDefault(require("../index")); var _scope = _interopRequireDefault(require("../scope")); -function t() { - const data = _interopRequireWildcard(require("@babel/types")); - - t = function () { - return data; - }; - - return data; -} +var t = _interopRequireWildcard(require("@babel/types")); var _cache = require("../cache"); -function _generator() { - const data = _interopRequireDefault(require("@babel/generator")); - - _generator = function () { - return data; - }; - - return data; -} +var _generator = _interopRequireDefault(require("@babel/generator")); var NodePath_ancestry = _interopRequireWildcard(require("./ancestry")); @@ -30237,19 +31504,25 @@ var NodePath_comments = _interopRequireWildcard(require("./comments")); 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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } -const debug = (0, _debug().default)("babel"); +const debug = (0, _debug.default)("babel"); +const REMOVED = 1 << 0; +exports.REMOVED = REMOVED; +const SHOULD_STOP = 1 << 1; +exports.SHOULD_STOP = SHOULD_STOP; +const SHOULD_SKIP = 1 << 2; +exports.SHOULD_SKIP = SHOULD_SKIP; class NodePath { constructor(hub, parent) { this.parent = parent; this.hub = hub; this.contexts = []; - this.data = Object.create(null); - this.shouldSkip = false; - this.shouldStop = false; - this.removed = false; + this.data = null; + this._traverseFlags = 0; this.state = null; this.opts = null; this.skipKeys = null; @@ -30257,13 +31530,10 @@ class NodePath { 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; } static get({ @@ -30314,10 +31584,18 @@ class NodePath { } setData(key, val) { + if (this.data == null) { + this.data = Object.create(null); + } + return this.data[key] = val; } getData(key, def) { + if (this.data == null) { + this.data = Object.create(null); + } + let val = this.data[key]; if (val === undefined && def !== undefined) val = this.data[key] = def; return val; @@ -30332,7 +31610,7 @@ class NodePath { } set(key, node) { - t().validate(this.node, key, node); + t.validate(this.node, key, node); this.node[key] = node; } @@ -30355,7 +31633,57 @@ class NodePath { } toString() { - return (0, _generator().default)(this.node).code; + return (0, _generator.default)(this.node).code; + } + + get inList() { + return !!this.listKey; + } + + set inList(inList) { + if (!inList) { + this.listKey = null; + } + } + + get parentKey() { + return this.listKey || this.key; + } + + get shouldSkip() { + return !!(this._traverseFlags & SHOULD_SKIP); + } + + set shouldSkip(v) { + if (v) { + this._traverseFlags |= SHOULD_SKIP; + } else { + this._traverseFlags &= ~SHOULD_SKIP; + } + } + + get shouldStop() { + return !!(this._traverseFlags & SHOULD_STOP); + } + + set shouldStop(v) { + if (v) { + this._traverseFlags |= SHOULD_STOP; + } else { + this._traverseFlags &= ~SHOULD_STOP; + } + } + + get removed() { + return !!(this._traverseFlags & REMOVED); + } + + set removed(v) { + if (v) { + this._traverseFlags |= REMOVED; + } else { + this._traverseFlags &= ~REMOVED; + } } } @@ -30363,9 +31691,9 @@ class NodePath { exports.default = NodePath; Object.assign(NodePath.prototype, NodePath_ancestry, NodePath_inference, NodePath_replacement, NodePath_evaluation, NodePath_conversion, NodePath_introspection, NodePath_context, NodePath_removal, NodePath_modification, NodePath_family, NodePath_comments); -for (const type of t().TYPES) { +for (const type of t.TYPES) { const typeKey = `is${type}`; - const fn = t()[typeKey]; + const fn = t[typeKey]; NodePath.prototype[typeKey] = function (opts) { return fn(this.node, opts); @@ -30380,14 +31708,14 @@ for (const type of t().TYPES) { for (const type of Object.keys(virtualTypes)) { if (type[0] === "_") continue; - if (t().TYPES.indexOf(type) < 0) t().TYPES.push(type); + if (t.TYPES.indexOf(type) < 0) t.TYPES.push(type); const virtualType = virtualTypes[type]; NodePath.prototype[`is${type}`] = function (opts) { return virtualType.checkPath(this, opts); }; } -},{"../cache":89,"../index":92,"../scope":111,"./ancestry":93,"./comments":94,"./context":95,"./conversion":96,"./evaluation":97,"./family":98,"./inference":100,"./introspection":103,"./lib/virtual-types":106,"./modification":107,"./removal":108,"./replacement":109,"@babel/generator":52,"@babel/types":155,"debug":207}],100:[function(require,module,exports){ +},{"../cache":94,"../index":97,"../scope":116,"./ancestry":98,"./comments":99,"./context":100,"./conversion":101,"./evaluation":102,"./family":103,"./inference":105,"./introspection":108,"./lib/virtual-types":111,"./modification":112,"./removal":113,"./replacement":114,"@babel/generator":54,"@babel/types":160,"debug":212}],105:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -30402,22 +31730,16 @@ exports.isGenericType = isGenericType; var inferers = _interopRequireWildcard(require("./inferers")); -function t() { - const data = _interopRequireWildcard(require("@babel/types")); - - t = function () { - return data; - }; +var t = _interopRequireWildcard(require("@babel/types")); - return data; -} +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function getTypeAnnotation() { if (this.typeAnnotation) return this.typeAnnotation; - let type = this._getTypeAnnotation() || t().anyTypeAnnotation(); - if (t().isTypeAnnotation(type)) type = type.typeAnnotation; + let type = this._getTypeAnnotation() || t.anyTypeAnnotation(); + if (t.isTypeAnnotation(type)) type = type.typeAnnotation; return this.typeAnnotation = type; } @@ -30430,14 +31752,14 @@ function _getTypeAnnotation() { const declarParent = declar.parentPath; if (declar.key === "left" && declarParent.isForInStatement()) { - return t().stringTypeAnnotation(); + return t.stringTypeAnnotation(); } if (declar.key === "left" && declarParent.isForOfStatement()) { - return t().anyTypeAnnotation(); + return t.anyTypeAnnotation(); } - return t().voidTypeAnnotation(); + return t.voidTypeAnnotation(); } else { return; } @@ -30466,19 +31788,19 @@ function isBaseType(baseName, soft) { function _isBaseType(baseName, type, soft) { if (baseName === "string") { - return t().isStringTypeAnnotation(type); + return t.isStringTypeAnnotation(type); } else if (baseName === "number") { - return t().isNumberTypeAnnotation(type); + return t.isNumberTypeAnnotation(type); } else if (baseName === "boolean") { - return t().isBooleanTypeAnnotation(type); + return t.isBooleanTypeAnnotation(type); } else if (baseName === "any") { - return t().isAnyTypeAnnotation(type); + return t.isAnyTypeAnnotation(type); } else if (baseName === "mixed") { - return t().isMixedTypeAnnotation(type); + return t.isMixedTypeAnnotation(type); } else if (baseName === "empty") { - return t().isEmptyTypeAnnotation(type); + return t.isEmptyTypeAnnotation(type); } else if (baseName === "void") { - return t().isVoidTypeAnnotation(type); + return t.isVoidTypeAnnotation(type); } else { if (soft) { return false; @@ -30490,11 +31812,11 @@ function _isBaseType(baseName, type, soft) { function couldBeBaseType(name) { const type = this.getTypeAnnotation(); - if (t().isAnyTypeAnnotation(type)) return true; + if (t.isAnyTypeAnnotation(type)) return true; - if (t().isUnionTypeAnnotation(type)) { + if (t.isUnionTypeAnnotation(type)) { for (const type2 of type.types) { - if (t().isAnyTypeAnnotation(type2) || _isBaseType(name, type2, true)) { + if (t.isAnyTypeAnnotation(type2) || _isBaseType(name, type2, true)) { return true; } } @@ -30509,18 +31831,18 @@ function baseTypeStrictlyMatches(right) { const left = this.getTypeAnnotation(); right = right.getTypeAnnotation(); - if (!t().isAnyTypeAnnotation(left) && t().isFlowBaseAnnotation(left)) { + if (!t.isAnyTypeAnnotation(left) && t.isFlowBaseAnnotation(left)) { return right.type === left.type; } } function isGenericType(genericName) { const type = this.getTypeAnnotation(); - return t().isGenericTypeAnnotation(type) && t().isIdentifier(type.id, { + return t.isGenericTypeAnnotation(type) && t.isIdentifier(type.id, { name: genericName }); } -},{"./inferers":102,"@babel/types":155}],101:[function(require,module,exports){ +},{"./inferers":107,"@babel/types":160}],106:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -30528,17 +31850,11 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = _default; -function t() { - const data = _interopRequireWildcard(require("@babel/types")); - - t = function () { - return data; - }; +var t = _interopRequireWildcard(require("@babel/types")); - return data; -} +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _default(node) { if (!this.isReferenced()) return; @@ -30553,9 +31869,9 @@ function _default(node) { } if (node.name === "undefined") { - return t().voidTypeAnnotation(); + return t.voidTypeAnnotation(); } else if (node.name === "NaN" || node.name === "Infinity") { - return t().numberTypeAnnotation(); + return t.numberTypeAnnotation(); } else if (node.name === "arguments") {} } @@ -30580,7 +31896,7 @@ function getTypeAnnotationBindingConstantViolations(binding, path, name) { } if (types.length) { - return t().createUnionTypeAnnotation(types); + return t.createUnionTypeAnnotation(types); } } @@ -30592,7 +31908,7 @@ function getConstantViolationsBefore(binding, path, functions) { const status = violation._guessExecutionStatusRelativeTo(path); - if (functions && status === "function") functions.push(violation); + if (functions && status === "unknown") functions.push(violation); return status === "before"; }); } @@ -30618,8 +31934,8 @@ function inferAnnotationFromBinaryExpression(name, path) { return target.getTypeAnnotation(); } - if (t().BOOLEAN_NUMBER_BINARY_OPERATORS.indexOf(operator) >= 0) { - return t().numberTypeAnnotation(); + if (t.BOOLEAN_NUMBER_BINARY_OPERATORS.indexOf(operator) >= 0) { + return t.numberTypeAnnotation(); } return; @@ -30649,7 +31965,7 @@ function inferAnnotationFromBinaryExpression(name, path) { if (!typePath.isLiteral()) return; const typeValue = typePath.node.value; if (typeof typeValue !== "string") return; - return t().createTypeAnnotationBasedOnTypeof(typeValue); + return t.createTypeAnnotationBasedOnTypeof(typeValue); } function getParentConditionalPath(binding, path, name) { @@ -30695,14 +32011,14 @@ function getConditionalAnnotation(binding, path, name) { if (types.length) { return { - typeAnnotation: t().createUnionTypeAnnotation(types), + typeAnnotation: t.createUnionTypeAnnotation(types), ifStatement }; } return getConditionalAnnotation(ifStatement, name); } -},{"@babel/types":155}],102:[function(require,module,exports){ +},{"@babel/types":160}],107:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -30738,21 +32054,15 @@ Object.defineProperty(exports, "Identifier", { } }); -function t() { - const data = _interopRequireWildcard(require("@babel/types")); - - t = function () { - return data; - }; - - return data; -} +var t = _interopRequireWildcard(require("@babel/types")); var _infererReference = _interopRequireDefault(require("./inferer-reference")); 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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function VariableDeclarator() { const id = this.get("id"); @@ -30779,55 +32089,55 @@ TypeCastExpression.validParent = true; function NewExpression(node) { if (this.get("callee").isIdentifier()) { - return t().genericTypeAnnotation(node.callee); + return t.genericTypeAnnotation(node.callee); } } function TemplateLiteral() { - return t().stringTypeAnnotation(); + return t.stringTypeAnnotation(); } function UnaryExpression(node) { const operator = node.operator; if (operator === "void") { - return t().voidTypeAnnotation(); - } else if (t().NUMBER_UNARY_OPERATORS.indexOf(operator) >= 0) { - return t().numberTypeAnnotation(); - } else if (t().STRING_UNARY_OPERATORS.indexOf(operator) >= 0) { - return t().stringTypeAnnotation(); - } else if (t().BOOLEAN_UNARY_OPERATORS.indexOf(operator) >= 0) { - return t().booleanTypeAnnotation(); + return t.voidTypeAnnotation(); + } else if (t.NUMBER_UNARY_OPERATORS.indexOf(operator) >= 0) { + return t.numberTypeAnnotation(); + } else if (t.STRING_UNARY_OPERATORS.indexOf(operator) >= 0) { + return t.stringTypeAnnotation(); + } else if (t.BOOLEAN_UNARY_OPERATORS.indexOf(operator) >= 0) { + return t.booleanTypeAnnotation(); } } function BinaryExpression(node) { const operator = node.operator; - if (t().NUMBER_BINARY_OPERATORS.indexOf(operator) >= 0) { - return t().numberTypeAnnotation(); - } else if (t().BOOLEAN_BINARY_OPERATORS.indexOf(operator) >= 0) { - return t().booleanTypeAnnotation(); + if (t.NUMBER_BINARY_OPERATORS.indexOf(operator) >= 0) { + return t.numberTypeAnnotation(); + } else if (t.BOOLEAN_BINARY_OPERATORS.indexOf(operator) >= 0) { + return t.booleanTypeAnnotation(); } else if (operator === "+") { const right = this.get("right"); const left = this.get("left"); if (left.isBaseType("number") && right.isBaseType("number")) { - return t().numberTypeAnnotation(); + return t.numberTypeAnnotation(); } else if (left.isBaseType("string") || right.isBaseType("string")) { - return t().stringTypeAnnotation(); + return t.stringTypeAnnotation(); } - return t().unionTypeAnnotation([t().stringTypeAnnotation(), t().numberTypeAnnotation()]); + return t.unionTypeAnnotation([t.stringTypeAnnotation(), t.numberTypeAnnotation()]); } } function LogicalExpression() { - return t().createUnionTypeAnnotation([this.get("left").getTypeAnnotation(), this.get("right").getTypeAnnotation()]); + return t.createUnionTypeAnnotation([this.get("left").getTypeAnnotation(), this.get("right").getTypeAnnotation()]); } function ConditionalExpression() { - return t().createUnionTypeAnnotation([this.get("consequent").getTypeAnnotation(), this.get("alternate").getTypeAnnotation()]); + return t.createUnionTypeAnnotation([this.get("consequent").getTypeAnnotation(), this.get("alternate").getTypeAnnotation()]); } function SequenceExpression() { @@ -30846,36 +32156,36 @@ function UpdateExpression(node) { const operator = node.operator; if (operator === "++" || operator === "--") { - return t().numberTypeAnnotation(); + return t.numberTypeAnnotation(); } } function StringLiteral() { - return t().stringTypeAnnotation(); + return t.stringTypeAnnotation(); } function NumericLiteral() { - return t().numberTypeAnnotation(); + return t.numberTypeAnnotation(); } function BooleanLiteral() { - return t().booleanTypeAnnotation(); + return t.booleanTypeAnnotation(); } function NullLiteral() { - return t().nullLiteralTypeAnnotation(); + return t.nullLiteralTypeAnnotation(); } function RegExpLiteral() { - return t().genericTypeAnnotation(t().identifier("RegExp")); + return t.genericTypeAnnotation(t.identifier("RegExp")); } function ObjectExpression() { - return t().genericTypeAnnotation(t().identifier("Object")); + return t.genericTypeAnnotation(t.identifier("Object")); } function ArrayExpression() { - return t().genericTypeAnnotation(t().identifier("Array")); + return t.genericTypeAnnotation(t.identifier("Array")); } function RestElement() { @@ -30885,13 +32195,13 @@ function RestElement() { RestElement.validParent = true; function Func() { - return t().genericTypeAnnotation(t().identifier("Function")); + return t.genericTypeAnnotation(t.identifier("Function")); } -const isArrayFrom = t().buildMatchMemberExpression("Array.from"); -const isObjectKeys = t().buildMatchMemberExpression("Object.keys"); -const isObjectValues = t().buildMatchMemberExpression("Object.values"); -const isObjectEntries = t().buildMatchMemberExpression("Object.entries"); +const isArrayFrom = t.buildMatchMemberExpression("Array.from"); +const isObjectKeys = t.buildMatchMemberExpression("Object.keys"); +const isObjectValues = t.buildMatchMemberExpression("Object.values"); +const isObjectEntries = t.buildMatchMemberExpression("Object.entries"); function CallExpression() { const { @@ -30899,11 +32209,11 @@ function CallExpression() { } = this.node; if (isObjectKeys(callee)) { - return t().arrayTypeAnnotation(t().stringTypeAnnotation()); + return t.arrayTypeAnnotation(t.stringTypeAnnotation()); } else if (isArrayFrom(callee) || isObjectValues(callee)) { - return t().arrayTypeAnnotation(t().anyTypeAnnotation()); + return t.arrayTypeAnnotation(t.anyTypeAnnotation()); } else if (isObjectEntries(callee)) { - return t().arrayTypeAnnotation(t().tupleTypeAnnotation([t().stringTypeAnnotation(), t().anyTypeAnnotation()])); + return t.arrayTypeAnnotation(t.tupleTypeAnnotation([t.stringTypeAnnotation(), t.anyTypeAnnotation()])); } return resolveCall(this.get("callee")); @@ -30919,9 +32229,9 @@ function resolveCall(callee) { if (callee.isFunction()) { if (callee.is("async")) { if (callee.is("generator")) { - return t().genericTypeAnnotation(t().identifier("AsyncIterator")); + return t.genericTypeAnnotation(t.identifier("AsyncIterator")); } else { - return t().genericTypeAnnotation(t().identifier("Promise")); + return t.genericTypeAnnotation(t.identifier("Promise")); } } else { if (callee.node.returnType) { @@ -30930,7 +32240,7 @@ function resolveCall(callee) { } } } -},{"./inferer-reference":101,"@babel/types":155}],103:[function(require,module,exports){ +},{"./inferer-reference":106,"@babel/types":160}],108:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -30957,32 +32267,18 @@ exports.isConstantExpression = isConstantExpression; exports.isInStrictMode = isInStrictMode; exports.is = void 0; -function _includes() { - const data = _interopRequireDefault(require("lodash/includes")); +var _includes = _interopRequireDefault(require("lodash/includes")); - _includes = function () { - return data; - }; +var t = _interopRequireWildcard(require("@babel/types")); - return data; -} +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } -function t() { - const data = _interopRequireWildcard(require("@babel/types")); - - t = function () { - return data; - }; - - return data; -} - -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function matchesPattern(pattern, allowPartial) { - return t().matchesPattern(this.node, pattern, allowPartial); + return t.matchesPattern(this.node, pattern, allowPartial); } function has(key) { @@ -31011,7 +32307,7 @@ function equals(key, value) { } function isNodeType(type) { - return t().isType(this.type, type); + return t.isType(this.type, type); } function canHaveVariableDeclarationOrExpression() { @@ -31024,9 +32320,9 @@ function canSwapBetweenExpressionAndStatement(replacement) { } if (this.isExpression()) { - return t().isBlockStatement(replacement); + return t.isBlockStatement(replacement); } else if (this.isBlockStatement()) { - return t().isExpression(replacement); + return t.isExpression(replacement); } return false; @@ -31054,10 +32350,10 @@ function isCompletionRecord(allowInsideFunction) { } function isStatementOrBlock() { - if (this.parentPath.isLabeledStatement() || t().isBlockStatement(this.container)) { + if (this.parentPath.isLabeledStatement() || t.isBlockStatement(this.container)) { return false; } else { - return (0, _includes().default)(t().STATEMENT_OR_BLOCK_KEYS, this.key); + return (0, _includes.default)(t.STATEMENT_OR_BLOCK_KEYS, this.key); } } @@ -31105,81 +32401,147 @@ function willIMaybeExecuteBefore(target) { return this._guessExecutionStatusRelativeTo(target) !== "after"; } -function _guessExecutionStatusRelativeTo(target) { - const targetFuncParent = target.scope.getFunctionParent() || target.scope.getProgramParent(); - const selfFuncParent = this.scope.getFunctionParent() || target.scope.getProgramParent(); +function getOuterFunction(path) { + return (path.scope.getFunctionParent() || path.scope.getProgramParent()).path; +} - if (targetFuncParent.node !== selfFuncParent.node) { - const status = this._guessExecutionStatusRelativeToDifferentFunctions(targetFuncParent); +function isExecutionUncertain(type, key) { + switch (type) { + case "LogicalExpression": + return key === "right"; - if (status) { - return status; - } else { - target = targetFuncParent.path; + case "ConditionalExpression": + case "IfStatement": + return key === "consequent" || key === "alternate"; + + case "WhileStatement": + case "DoWhileStatement": + case "ForInStatement": + case "ForOfStatement": + return key === "body"; + + case "ForStatement": + return key === "body" || key === "update"; + + case "SwitchStatement": + return key === "cases"; + + case "TryStatement": + return key === "handler"; + + case "AssignmentPattern": + return key === "right"; + + case "OptionalMemberExpression": + return key === "property"; + + case "OptionalCallExpression": + return key === "arguments"; + + default: + return false; + } +} + +function isExecutionUncertainInList(paths, maxIndex) { + for (let i = 0; i < maxIndex; i++) { + const path = paths[i]; + + if (isExecutionUncertain(path.parent.type, path.parentKey)) { + return true; } } - const targetPaths = target.getAncestry(); - if (targetPaths.indexOf(this) >= 0) return "after"; - const selfPaths = this.getAncestry(); + return false; +} + +function _guessExecutionStatusRelativeTo(target) { + const funcParent = { + this: getOuterFunction(this), + target: getOuterFunction(target) + }; + + if (funcParent.target.node !== funcParent.this.node) { + return this._guessExecutionStatusRelativeToDifferentFunctions(funcParent.target); + } + + const paths = { + target: target.getAncestry(), + this: this.getAncestry() + }; + if (paths.target.indexOf(this) >= 0) return "after"; + if (paths.this.indexOf(target) >= 0) return "before"; let commonPath; - let targetIndex; - let selfIndex; + const commonIndex = { + target: 0, + this: 0 + }; - for (selfIndex = 0; selfIndex < selfPaths.length; selfIndex++) { - const selfPath = selfPaths[selfIndex]; - targetIndex = targetPaths.indexOf(selfPath); + while (!commonPath && commonIndex.this < paths.this.length) { + const path = paths.this[commonIndex.this]; + commonIndex.target = paths.target.indexOf(path); - if (targetIndex >= 0) { - commonPath = selfPath; - break; + if (commonIndex.target >= 0) { + commonPath = path; + } else { + commonIndex.this++; } } if (!commonPath) { - return "before"; + throw new Error("Internal Babel error - The two compared nodes" + " don't appear to belong to the same program."); } - const targetRelationship = targetPaths[targetIndex - 1]; - const selfRelationship = selfPaths[selfIndex - 1]; - - if (!targetRelationship || !selfRelationship) { - return "before"; + if (isExecutionUncertainInList(paths.this, commonIndex.this - 1) || isExecutionUncertainInList(paths.target, commonIndex.target - 1)) { + return "unknown"; } - if (targetRelationship.listKey && targetRelationship.container === selfRelationship.container) { - return targetRelationship.key > selfRelationship.key ? "before" : "after"; + const divergence = { + this: paths.this[commonIndex.this - 1], + target: paths.target[commonIndex.target - 1] + }; + + if (divergence.target.listKey && divergence.this.listKey && divergence.target.container === divergence.this.container) { + return divergence.target.key > divergence.this.key ? "before" : "after"; } - const keys = t().VISITOR_KEYS[commonPath.type]; - const targetKeyPosition = keys.indexOf(targetRelationship.key); - const selfKeyPosition = keys.indexOf(selfRelationship.key); - return targetKeyPosition > selfKeyPosition ? "before" : "after"; + const keys = t.VISITOR_KEYS[commonPath.type]; + const keyPosition = { + this: keys.indexOf(divergence.this.parentKey), + target: keys.indexOf(divergence.target.parentKey) + }; + return keyPosition.target > keyPosition.this ? "before" : "after"; } -function _guessExecutionStatusRelativeToDifferentFunctions(targetFuncParent) { - const targetFuncPath = targetFuncParent.path; - if (!targetFuncPath.isFunctionDeclaration()) return; - const binding = targetFuncPath.scope.getBinding(targetFuncPath.node.id.name); - if (!binding.references) return "before"; - const referencePaths = binding.referencePaths; +const executionOrderCheckedNodes = new WeakSet(); - for (const path of referencePaths) { - if (path.key !== "callee" || !path.parentPath.isCallExpression()) { - return; - } +function _guessExecutionStatusRelativeToDifferentFunctions(target) { + if (!target.isFunctionDeclaration() || target.parentPath.isExportDeclaration()) { + return "unknown"; } + const binding = target.scope.getBinding(target.node.id.name); + if (!binding.references) return "before"; + const referencePaths = binding.referencePaths; let allStatus; for (const path of referencePaths) { - const childOfFunction = !!path.find(path => path.node === targetFuncPath.node); + const childOfFunction = !!path.find(path => path.node === target.node); if (childOfFunction) continue; + if (path.key !== "callee" || !path.parentPath.isCallExpression()) { + return "unknown"; + } + + if (executionOrderCheckedNodes.has(path.node)) continue; + executionOrderCheckedNodes.add(path.node); + const status = this._guessExecutionStatusRelativeTo(path); - if (allStatus) { - if (allStatus !== status) return; + executionOrderCheckedNodes.delete(path.node); + + if (allStatus && allStatus !== status) { + return "unknown"; } else { allStatus = status; } @@ -31216,7 +32578,7 @@ function _resolve(dangerous, resolved) { return this.get("expression").resolve(dangerous, resolved); } else if (dangerous && this.isMemberExpression()) { const targetKey = this.toComputedKey(); - if (!t().isLiteral(targetKey)) return; + if (!t.isLiteral(targetKey)) return; const targetName = targetKey.value; const target = this.get("object").resolve(dangerous, resolved); @@ -31302,7 +32664,7 @@ function isInStrictMode() { }); return !!strictParent; } -},{"@babel/types":155,"lodash/includes":389}],104:[function(require,module,exports){ +},{"@babel/types":160,"lodash/includes":395}],109:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -31310,21 +32672,15 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = void 0; -function t() { - const data = _interopRequireWildcard(require("@babel/types")); +var t = _interopRequireWildcard(require("@babel/types")); - t = function () { - return data; - }; - - return data; -} +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } const referenceVisitor = { ReferencedIdentifier(path, state) { - if (path.isJSXIdentifier() && t().react.isCompatTag(path.node.name) && !path.parentPath.isJSXMemberExpression()) { + if (path.isJSXIdentifier() && t.react.isCompatTag(path.node.name) && !path.parentPath.isJSXMemberExpression()) { return; } @@ -31342,6 +32698,15 @@ const referenceVisitor = { const binding = path.scope.getBinding(path.node.name); if (!binding) return; + + for (const violation of binding.constantViolations) { + if (violation.scope !== binding.path.scope) { + state.mutableBinding = true; + path.stop(); + return; + } + } + if (binding !== state.scope.getBinding(path.node.name)) return; state.bindings[path.node.name] = binding; } @@ -31352,6 +32717,7 @@ class PathHoister { constructor(path, scope) { this.breakOnScopePaths = []; this.bindings = {}; + this.mutableBinding = false; this.scopes = []; this.scope = scope; this.path = path; @@ -31470,28 +32836,29 @@ class PathHoister { run() { this.path.traverse(referenceVisitor, this); + if (this.mutableBinding) return; this.getCompatibleScopes(); const attachTo = this.getAttachmentPath(); if (!attachTo) return; if (attachTo.getFunctionParent() === this.path.getFunctionParent()) return; let uid = attachTo.scope.generateUidIdentifier("ref"); - const declarator = t().variableDeclarator(uid, this.path.node); + const declarator = t.variableDeclarator(uid, this.path.node); const insertFn = this.attachAfter ? "insertAfter" : "insertBefore"; - const [attached] = attachTo[insertFn]([attachTo.isVariableDeclarator() ? declarator : t().variableDeclaration("var", [declarator])]); + const [attached] = attachTo[insertFn]([attachTo.isVariableDeclarator() ? declarator : t.variableDeclaration("var", [declarator])]); const parent = this.path.parentPath; if (parent.isJSXElement() && this.path.container === parent.node.children) { - uid = t().JSXExpressionContainer(uid); + uid = t.JSXExpressionContainer(uid); } - this.path.replaceWith(t().cloneNode(uid)); + this.path.replaceWith(t.cloneNode(uid)); return attachTo.isVariableDeclarator() ? attached.get("init") : attached.get("declarations.0.init"); } } exports.default = PathHoister; -},{"@babel/types":155}],105:[function(require,module,exports){ +},{"@babel/types":160}],110:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -31530,7 +32897,7 @@ const hooks = [function (self, parent) { } }]; exports.hooks = hooks; -},{}],106:[function(require,module,exports){ +},{}],111:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -31538,17 +32905,11 @@ Object.defineProperty(exports, "__esModule", { }); exports.ForAwaitStatement = exports.NumericLiteralTypeAnnotation = exports.ExistentialTypeParam = exports.SpreadProperty = exports.RestProperty = exports.Flow = exports.Pure = exports.Generated = exports.User = exports.Var = exports.BlockScoped = exports.Referenced = exports.Scope = exports.Expression = exports.Statement = exports.BindingIdentifier = exports.ReferencedMemberExpression = exports.ReferencedIdentifier = void 0; -function t() { - const data = _interopRequireWildcard(require("@babel/types")); - - t = function () { - return data; - }; +var t = _interopRequireWildcard(require("@babel/types")); - return data; -} +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } const ReferencedIdentifier = { types: ["Identifier", "JSXIdentifier"], @@ -31559,15 +32920,15 @@ const ReferencedIdentifier = { parent } = path; - if (!t().isIdentifier(node, opts) && !t().isJSXMemberExpression(parent, opts)) { - if (t().isJSXIdentifier(node, opts)) { - if (t().react.isCompatTag(node.name)) return false; + if (!t.isIdentifier(node, opts) && !t.isJSXMemberExpression(parent, opts)) { + if (t.isJSXIdentifier(node, opts)) { + if (t.react.isCompatTag(node.name)) return false; } else { return false; } } - return t().isReferenced(node, parent, path.parentPath.parent); + return t.isReferenced(node, parent, path.parentPath.parent); } }; @@ -31579,7 +32940,7 @@ const ReferencedMemberExpression = { node, parent }) { - return t().isMemberExpression(node) && t().isReferenced(node, parent); + return t.isMemberExpression(node) && t.isReferenced(node, parent); } }; @@ -31593,7 +32954,7 @@ const BindingIdentifier = { parent } = path; const grandparent = path.parentPath.parent; - return t().isIdentifier(node) && t().isBinding(node, parent, grandparent); + return t.isIdentifier(node) && t.isBinding(node, parent, grandparent); } }; @@ -31605,12 +32966,12 @@ const Statement = { node, parent }) { - if (t().isStatement(node)) { - if (t().isVariableDeclaration(node)) { - if (t().isForXStatement(parent, { + if (t.isStatement(node)) { + if (t.isVariableDeclaration(node)) { + if (t.isForXStatement(parent, { left: node })) return false; - if (t().isForStatement(parent, { + if (t.isForStatement(parent, { init: node })) return false; } @@ -31630,31 +32991,31 @@ const Expression = { if (path.isIdentifier()) { return path.isReferencedIdentifier(); } else { - return t().isExpression(path.node); + return t.isExpression(path.node); } } }; exports.Expression = Expression; const Scope = { - types: ["Scopable"], + types: ["Scopable", "Pattern"], checkPath(path) { - return t().isScope(path.node, path.parent); + return t.isScope(path.node, path.parent); } }; exports.Scope = Scope; const Referenced = { checkPath(path) { - return t().isReferenced(path.node, path.parent); + return t.isReferenced(path.node, path.parent); } }; exports.Referenced = Referenced; const BlockScoped = { checkPath(path) { - return t().isBlockScoped(path.node); + return t.isBlockScoped(path.node); } }; @@ -31663,7 +33024,7 @@ const Var = { types: ["VariableDeclaration"], checkPath(path) { - return t().isVar(path.node); + return t.isVar(path.node); } }; @@ -31695,13 +33056,13 @@ const Flow = { checkPath({ node }) { - if (t().isFlow(node)) { + if (t.isFlow(node)) { return true; - } else if (t().isImportDeclaration(node)) { + } else if (t.isImportDeclaration(node)) { return node.importKind === "type" || node.importKind === "typeof"; - } else if (t().isExportDeclaration(node)) { + } else if (t.isExportDeclaration(node)) { return node.exportKind === "type"; - } else if (t().isImportSpecifier(node)) { + } else if (t.isImportSpecifier(node)) { return node.importKind === "type" || node.importKind === "typeof"; } else { return false; @@ -31747,7 +33108,7 @@ const ForAwaitStatement = { }; exports.ForAwaitStatement = ForAwaitStatement; -},{"@babel/types":155}],107:[function(require,module,exports){ +},{"@babel/types":160}],112:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -31770,17 +33131,11 @@ var _hoister = _interopRequireDefault(require("./lib/hoister")); var _index = _interopRequireDefault(require("./index")); -function t() { - const data = _interopRequireWildcard(require("@babel/types")); +var t = _interopRequireWildcard(require("@babel/types")); - t = function () { - return data; - }; +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } - return data; -} - -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -31794,14 +33149,14 @@ function insertBefore(nodes) { if (parentPath.isExpressionStatement() || parentPath.isLabeledStatement() || parentPath.isExportNamedDeclaration() || parentPath.isExportDefaultDeclaration() && this.isDeclaration()) { return parentPath.insertBefore(nodes); - } else if (this.isNodeType("Expression") && this.listKey !== "params" && this.listKey !== "arguments" || parentPath.isForStatement() && this.key === "init") { + } else if (this.isNodeType("Expression") && !this.isJSXElement() || parentPath.isForStatement() && this.key === "init") { if (this.node) nodes.push(this.node); return this.replaceExpressionWithStatements(nodes); } else if (Array.isArray(this.container)) { return this._containerInsertBefore(nodes); } else if (this.isStatementOrBlock()) { const shouldInsertCurrentNode = this.node && (!this.isExpressionStatement() || this.node.expression != null); - this.replaceWith(t().blockStatement(shouldInsertCurrentNode ? [this.node] : [])); + this.replaceWith(t.blockStatement(shouldInsertCurrentNode ? [this.node] : [])); return this.unshiftContainer("body", nodes); } else { throw new Error("We don't know what to do with this node type. " + "We were previously a Statement but we can't fit in here?"); @@ -31855,9 +33210,9 @@ function insertAfter(nodes) { if (parentPath.isExpressionStatement() || parentPath.isLabeledStatement() || parentPath.isExportNamedDeclaration() || parentPath.isExportDefaultDeclaration() && this.isDeclaration()) { return parentPath.insertAfter(nodes.map(node => { - return t().isExpression(node) ? t().expressionStatement(node) : node; + return t.isExpression(node) ? t.expressionStatement(node) : node; })); - } else if (this.isNodeType("Expression") && !this.isJSXElement() || parentPath.isForStatement() && this.key === "init") { + } else if (this.isNodeType("Expression") && !this.isJSXElement() && !parentPath.isJSXElement() || parentPath.isForStatement() && this.key === "init") { if (this.node) { let { scope @@ -31871,8 +33226,8 @@ function insertAfter(nodes) { } const temp = scope.generateDeclaredUidIdentifier(); - nodes.unshift(t().expressionStatement(t().assignmentExpression("=", t().cloneNode(temp), this.node))); - nodes.push(t().expressionStatement(t().cloneNode(temp))); + nodes.unshift(t.expressionStatement(t.assignmentExpression("=", t.cloneNode(temp), this.node))); + nodes.push(t.expressionStatement(t.cloneNode(temp))); } return this.replaceExpressionWithStatements(nodes); @@ -31880,7 +33235,7 @@ function insertAfter(nodes) { return this._containerInsertAfter(nodes); } else if (this.isStatementOrBlock()) { const shouldInsertCurrentNode = this.node && (!this.isExpressionStatement() || this.node.expression != null); - this.replaceWith(t().blockStatement(shouldInsertCurrentNode ? [this.node] : [])); + this.replaceWith(t.blockStatement(shouldInsertCurrentNode ? [this.node] : [])); return this.pushContainer("body", nodes); } else { throw new Error("We don't know what to do with this node type. " + "We were previously a Statement but we can't fit in here?"); @@ -31946,7 +33301,7 @@ function unshiftContainer(listKey, nodes) { key: 0 }); - return path.insertBefore(nodes); + return path._containerInsertBefore(nodes); } function pushContainer(listKey, nodes) { @@ -31970,7 +33325,7 @@ function hoist(scope = this.scope) { const hoister = new _hoister.default(this, scope); return hoister.run(); } -},{"../cache":89,"./index":99,"./lib/hoister":104,"@babel/types":155}],108:[function(require,module,exports){ +},{"../cache":94,"./index":104,"./lib/hoister":109,"@babel/types":160}],113:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -31985,6 +33340,8 @@ exports._assertUnremoved = _assertUnremoved; var _removalHooks = require("./lib/removal-hooks"); +var _index = require("./index"); + function remove() { this._assertUnremoved(); @@ -32026,8 +33383,7 @@ function _remove() { } function _markRemoved() { - this.shouldSkip = true; - this.removed = true; + this._traverseFlags |= _index.SHOULD_SKIP | _index.REMOVED; this.node = null; } @@ -32036,7 +33392,7 @@ function _assertUnremoved() { throw this.buildCodeFrameError("NodePath has been removed so is read-only."); } } -},{"./lib/removal-hooks":105}],109:[function(require,module,exports){ +},{"./index":104,"./lib/removal-hooks":110}],114:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -32049,41 +33405,19 @@ exports._replaceWith = _replaceWith; exports.replaceExpressionWithStatements = replaceExpressionWithStatements; exports.replaceInline = replaceInline; -function _codeFrame() { - const data = require("@babel/code-frame"); - - _codeFrame = function () { - return data; - }; - - return data; -} +var _codeFrame = require("@babel/code-frame"); var _index = _interopRequireDefault(require("../index")); var _index2 = _interopRequireDefault(require("./index")); -function _parser() { - const data = require("@babel/parser"); - - _parser = function () { - return data; - }; - - return data; -} - -function t() { - const data = _interopRequireWildcard(require("@babel/types")); +var _parser = require("@babel/parser"); - t = function () { - return data; - }; +var t = _interopRequireWildcard(require("@babel/types")); - return data; -} +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -32106,7 +33440,7 @@ const hoistVariablesVisitor = { for (const declar of path.node.declarations) { if (declar.init) { - exprs.push(t().expressionStatement(t().assignmentExpression("=", declar.id, declar.init))); + exprs.push(t.expressionStatement(t.assignmentExpression("=", declar.id, declar.init))); } } @@ -32118,8 +33452,8 @@ const hoistVariablesVisitor = { function replaceWithMultiple(nodes) { this.resync(); nodes = this._verifyNodeList(nodes); - t().inheritLeadingComments(nodes[0], this.node); - t().inheritTrailingComments(nodes[nodes.length - 1], this.node); + t.inheritLeadingComments(nodes[0], this.node); + t.inheritTrailingComments(nodes[nodes.length - 1], this.node); this.node = this.container[this.key] = null; const paths = this.insertAfter(nodes); @@ -32137,12 +33471,12 @@ function replaceWithSourceString(replacement) { try { replacement = `(${replacement})`; - replacement = (0, _parser().parse)(replacement); + replacement = (0, _parser.parse)(replacement); } catch (err) { const loc = err.loc; if (loc) { - err.message += " - make sure this is an expression.\n" + (0, _codeFrame().codeFrameColumns)(replacement, { + err.message += " - make sure this is an expression.\n" + (0, _codeFrame.codeFrameColumns)(replacement, { start: { line: loc.line, column: loc.column + 1 @@ -32180,7 +33514,7 @@ function replaceWith(replacement) { return [this]; } - if (this.isProgram() && !t().isProgram(replacement)) { + if (this.isProgram() && !t.isProgram(replacement)) { throw new Error("You can only replace a Program root node with another Program node"); } @@ -32194,14 +33528,14 @@ function replaceWith(replacement) { let nodePath = ""; - if (this.isNodeType("Statement") && t().isExpression(replacement)) { + if (this.isNodeType("Statement") && t.isExpression(replacement)) { if (!this.canHaveVariableDeclarationOrExpression() && !this.canSwapBetweenExpressionAndStatement(replacement) && !this.parentPath.isExportDefaultDeclaration()) { - replacement = t().expressionStatement(replacement); + replacement = t.expressionStatement(replacement); nodePath = "expression"; } } - if (this.isNodeType("Expression") && t().isStatement(replacement)) { + if (this.isNodeType("Expression") && t.isStatement(replacement)) { if (!this.canHaveVariableDeclarationOrExpression() && !this.canSwapBetweenExpressionAndStatement(replacement)) { return this.replaceExpressionWithStatements([replacement]); } @@ -32210,8 +33544,8 @@ function replaceWith(replacement) { const oldNode = this.node; if (oldNode) { - t().inheritsComments(replacement, oldNode); - t().removeComments(oldNode); + t.inheritsComments(replacement, oldNode); + t.removeComments(oldNode); } this._replaceWith(replacement); @@ -32228,9 +33562,9 @@ function _replaceWith(node) { } if (this.inList) { - t().validate(this.parent, this.key, [node]); + t.validate(this.parent, this.key, [node]); } else { - t().validate(this.parent, this.key, node); + t.validate(this.parent, this.key, node); } this.debug(`Replace with ${node && node.type}`); @@ -32239,14 +33573,16 @@ function _replaceWith(node) { function replaceExpressionWithStatements(nodes) { this.resync(); - const toSequenceExpression = t().toSequenceExpression(nodes, this.scope); + const toSequenceExpression = t.toSequenceExpression(nodes, this.scope); if (toSequenceExpression) { return this.replaceWith(toSequenceExpression)[0].get("expressions"); } - const container = t().arrowFunctionExpression([], t().blockStatement(nodes)); - this.replaceWith(t().callExpression(container, [])); + const functionParent = this.getFunctionParent(); + const isParentAsync = functionParent && functionParent.is("async"); + const container = t.arrowFunctionExpression([], t.blockStatement(nodes)); + this.replaceWith(t.callExpression(container, [])); this.traverse(hoistVariablesVisitor); const completionRecords = this.get("callee").getCompletionRecords(); @@ -32260,20 +33596,26 @@ function replaceExpressionWithStatements(nodes) { if (!uid) { const callee = this.get("callee"); uid = callee.scope.generateDeclaredUidIdentifier("ret"); - callee.get("body").pushContainer("body", t().returnStatement(t().cloneNode(uid))); + callee.get("body").pushContainer("body", t.returnStatement(t.cloneNode(uid))); loop.setData("expressionReplacementReturnUid", uid); } else { - uid = t().identifier(uid.name); + uid = t.identifier(uid.name); } - path.get("expression").replaceWith(t().assignmentExpression("=", t().cloneNode(uid), path.node.expression)); + path.get("expression").replaceWith(t.assignmentExpression("=", t.cloneNode(uid), path.node.expression)); } else { - path.replaceWith(t().returnStatement(path.node.expression)); + path.replaceWith(t.returnStatement(path.node.expression)); } } const callee = this.get("callee"); callee.arrowFunctionToExpression(); + + if (isParentAsync && _index.default.hasType(this.get("callee.body").node, "AwaitExpression", t.FUNCTION_TYPES)) { + callee.set("async", true); + this.replaceWith(t.awaitExpression(this.node)); + } + return callee.get("body.body"); } @@ -32295,7 +33637,7 @@ function replaceInline(nodes) { return this.replaceWith(nodes); } } -},{"../index":92,"./index":99,"@babel/code-frame":4,"@babel/parser":71,"@babel/types":155}],110:[function(require,module,exports){ +},{"../index":97,"./index":104,"@babel/code-frame":4,"@babel/parser":73,"@babel/types":160}],115:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -32367,7 +33709,7 @@ class Binding { } exports.default = Binding; -},{}],111:[function(require,module,exports){ +},{}],116:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -32375,70 +33717,32 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = void 0; -function _includes() { - const data = _interopRequireDefault(require("lodash/includes")); +var _includes = _interopRequireDefault(require("lodash/includes")); - _includes = function () { - return data; - }; - - return data; -} - -function _repeat() { - const data = _interopRequireDefault(require("lodash/repeat")); - - _repeat = function () { - return data; - }; - - return data; -} +var _repeat = _interopRequireDefault(require("lodash/repeat")); var _renamer = _interopRequireDefault(require("./lib/renamer")); var _index = _interopRequireDefault(require("../index")); -function _defaults() { - const data = _interopRequireDefault(require("lodash/defaults")); - - _defaults = function () { - return data; - }; - - return data; -} +var _defaults = _interopRequireDefault(require("lodash/defaults")); var _binding = _interopRequireDefault(require("./binding")); -function _globals() { - const data = _interopRequireDefault(require("globals")); +var _globals = _interopRequireDefault(require("globals")); - _globals = function () { - return data; - }; - - return data; -} - -function t() { - const data = _interopRequireWildcard(require("@babel/types")); - - t = function () { - return data; - }; - - return data; -} +var t = _interopRequireWildcard(require("@babel/types")); var _cache = require("../cache"); -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function gatherNodeParts(node, parts) { - if (t().isModuleDeclaration(node)) { + if (t.isModuleDeclaration(node)) { if (node.source) { gatherNodeParts(node.source, parts); } else if (node.specifiers && node.specifiers.length) { @@ -32448,33 +33752,33 @@ function gatherNodeParts(node, parts) { } else if (node.declaration) { gatherNodeParts(node.declaration, parts); } - } else if (t().isModuleSpecifier(node)) { + } else if (t.isModuleSpecifier(node)) { gatherNodeParts(node.local, parts); - } else if (t().isMemberExpression(node)) { + } else if (t.isMemberExpression(node)) { gatherNodeParts(node.object, parts); gatherNodeParts(node.property, parts); - } else if (t().isIdentifier(node)) { + } else if (t.isIdentifier(node)) { parts.push(node.name); - } else if (t().isLiteral(node)) { + } else if (t.isLiteral(node)) { parts.push(node.value); - } else if (t().isCallExpression(node)) { + } else if (t.isCallExpression(node)) { gatherNodeParts(node.callee, parts); - } else if (t().isObjectExpression(node) || t().isObjectPattern(node)) { + } else if (t.isObjectExpression(node) || t.isObjectPattern(node)) { for (const prop of node.properties) { gatherNodeParts(prop.key || prop.argument, parts); } - } else if (t().isPrivateName(node)) { + } else if (t.isPrivateName(node)) { gatherNodeParts(node.id, parts); - } else if (t().isThisExpression(node)) { + } else if (t.isThisExpression(node)) { parts.push("this"); - } else if (t().isSuper(node)) { + } else if (t.isSuper(node)) { parts.push("super"); } } const collectorVisitor = { For(path) { - for (const key of t().FOR_INIT_KEYS) { + for (const key of t.FOR_INIT_KEYS) { const declar = path.get(key); if (declar.isVar()) { @@ -32515,14 +33819,14 @@ const collectorVisitor = { } = path; const declar = node.declaration; - if (t().isClassDeclaration(declar) || t().isFunctionDeclaration(declar)) { + if (t.isClassDeclaration(declar) || t.isFunctionDeclaration(declar)) { const id = declar.id; if (!id) return; const binding = scope.getBinding(id.name); if (binding) binding.reference(path); - } else if (t().isVariableDeclaration(declar)) { + } else if (t.isVariableDeclaration(declar)) { for (const decl of declar.declarations) { - for (const name of Object.keys(t().getBindingIdentifiers(decl))) { + for (const name of Object.keys(t.getBindingIdentifiers(decl))) { const binding = scope.getBinding(name); if (binding) binding.reference(path); } @@ -32554,14 +33858,14 @@ const collectorVisitor = { BlockScoped(path) { let scope = path.scope; if (scope.path === path) scope = scope.parent; - scope.getBlockParent().registerDeclaration(path); - }, + const parent = scope.getBlockParent(); + parent.registerDeclaration(path); - ClassDeclaration(path) { - const id = path.node.id; - if (!id) return; - const name = id.name; - path.scope.bindings[name] = path.scope.getBinding(name); + if (path.isClassDeclaration() && path.node.id) { + const id = path.node.id; + const name = id.name; + path.scope.bindings[name] = path.scope.parent.getBinding(name); + } }, Block(path) { @@ -32619,15 +33923,15 @@ class Scope { this.push({ id }); - return t().cloneNode(id); + return t.cloneNode(id); } generateUidIdentifier(name) { - return t().identifier(this.generateUid(name)); + return t.identifier(this.generateUid(name)); } generateUid(name = "temp") { - name = t().toIdentifier(name).replace(/^_+/, "").replace(/[0-9]+$/g, ""); + name = t.toIdentifier(name).replace(/^_+/, "").replace(/[0-9]+$/g, ""); let uid; let i = 0; @@ -32651,11 +33955,11 @@ class Scope { generateUidBasedOnNode(parent, defaultName) { let node = parent; - if (t().isAssignmentExpression(parent)) { + if (t.isAssignmentExpression(parent)) { node = parent.left; - } else if (t().isVariableDeclarator(parent)) { + } else if (t.isVariableDeclarator(parent)) { node = parent.id; - } else if (t().isObjectProperty(node) || t().isObjectMethod(node)) { + } else if (t.isObjectProperty(node) || t.isObjectMethod(node)) { node = node.key; } @@ -32667,15 +33971,15 @@ class Scope { } generateUidIdentifierBasedOnNode(parent, defaultName) { - return t().identifier(this.generateUidBasedOnNode(parent, defaultName)); + return t.identifier(this.generateUidBasedOnNode(parent, defaultName)); } isStatic(node) { - if (t().isThisExpression(node) || t().isSuper(node)) { + if (t.isThisExpression(node) || t.isSuper(node)) { return true; } - if (t().isIdentifier(node)) { + if (t.isIdentifier(node)) { const binding = this.getBinding(node.name); if (binding) { @@ -32698,7 +34002,7 @@ class Scope { this.push({ id }); - return t().cloneNode(id); + return t.cloneNode(id); } return id; @@ -32732,7 +34036,7 @@ class Scope { } dump() { - const sep = (0, _repeat().default)("-", 60); + const sep = (0, _repeat.default)("-", 60); console.log(sep); let scope = this; @@ -32754,7 +34058,7 @@ class Scope { } toArray(node, i) { - if (t().isIdentifier(node)) { + if (t.isIdentifier(node)) { const binding = this.getBinding(node.name); if (binding && binding.constant && binding.path.isGenericType("Array")) { @@ -32762,14 +34066,14 @@ class Scope { } } - if (t().isArrayExpression(node)) { + if (t.isArrayExpression(node)) { return node; } - if (t().isIdentifier(node, { + if (t.isIdentifier(node, { name: "arguments" })) { - return t().callExpression(t().memberExpression(t().memberExpression(t().memberExpression(t().identifier("Array"), t().identifier("prototype")), t().identifier("slice")), t().identifier("call")), [node]); + return t.callExpression(t.memberExpression(t.memberExpression(t.memberExpression(t.identifier("Array"), t.identifier("prototype")), t.identifier("slice")), t.identifier("call")), [node]); } let helperName; @@ -32778,13 +34082,13 @@ class Scope { if (i === true) { helperName = "toConsumableArray"; } else if (i) { - args.push(t().numericLiteral(i)); + args.push(t.numericLiteral(i)); helperName = "slicedToArray"; } else { helperName = "toArray"; } - return t().callExpression(this.hub.addHelper(helperName), args); + return t.callExpression(this.hub.addHelper(helperName), args); } hasLabel(name) { @@ -32830,11 +34134,7 @@ class Scope { } buildUndefinedNode() { - if (this.hasBinding("undefined")) { - return t().unaryExpression("void", t().numericLiteral(0), true); - } else { - return t().identifier("undefined"); - } + return t.unaryExpression("void", t.numericLiteral(0), true); } registerConstantViolation(path) { @@ -32922,56 +34222,56 @@ class Scope { } isPure(node, constantsOnly) { - if (t().isIdentifier(node)) { + if (t.isIdentifier(node)) { const binding = this.getBinding(node.name); if (!binding) return false; if (constantsOnly) return binding.constant; return true; - } else if (t().isClass(node)) { + } else if (t.isClass(node)) { if (node.superClass && !this.isPure(node.superClass, constantsOnly)) { return false; } return this.isPure(node.body, constantsOnly); - } else if (t().isClassBody(node)) { + } else if (t.isClassBody(node)) { for (const method of node.body) { if (!this.isPure(method, constantsOnly)) return false; } return true; - } else if (t().isBinary(node)) { + } else if (t.isBinary(node)) { return this.isPure(node.left, constantsOnly) && this.isPure(node.right, constantsOnly); - } else if (t().isArrayExpression(node)) { + } else if (t.isArrayExpression(node)) { for (const elem of node.elements) { if (!this.isPure(elem, constantsOnly)) return false; } return true; - } else if (t().isObjectExpression(node)) { + } else if (t.isObjectExpression(node)) { for (const prop of node.properties) { if (!this.isPure(prop, constantsOnly)) return false; } return true; - } else if (t().isClassMethod(node)) { + } else if (t.isClassMethod(node)) { if (node.computed && !this.isPure(node.key, constantsOnly)) return false; if (node.kind === "get" || node.kind === "set") return false; return true; - } else if (t().isProperty(node)) { + } else if (t.isProperty(node)) { if (node.computed && !this.isPure(node.key, constantsOnly)) return false; return this.isPure(node.value, constantsOnly); - } else if (t().isUnaryExpression(node)) { + } else if (t.isUnaryExpression(node)) { return this.isPure(node.argument, constantsOnly); - } else if (t().isTaggedTemplateExpression(node)) { - return t().matchesPattern(node.tag, "String.raw") && !this.hasBinding("String", true) && this.isPure(node.quasi, constantsOnly); - } else if (t().isTemplateLiteral(node)) { + } else if (t.isTaggedTemplateExpression(node)) { + return t.matchesPattern(node.tag, "String.raw") && !this.hasBinding("String", true) && this.isPure(node.quasi, constantsOnly); + } else if (t.isTemplateLiteral(node)) { for (const expression of node.expressions) { if (!this.isPure(expression, constantsOnly)) return false; } return true; } else { - return t().isPureish(node); + return t.isPureish(node); } } @@ -33010,20 +34310,20 @@ class Scope { this.data = Object.create(null); if (path.isLoop()) { - for (const key of t().FOR_INIT_KEYS) { + for (const key of t.FOR_INIT_KEYS) { const node = path.get(key); if (node.isBlockScoped()) this.registerBinding(node.node.kind, node); } } if (path.isFunctionExpression() && path.has("id")) { - if (!path.get("id").node[t().NOT_LOCAL_BINDING]) { + if (!path.get("id").node[t.NOT_LOCAL_BINDING]) { this.registerBinding("local", path.get("id"), path); } } if (path.isClassExpression() && path.has("id")) { - if (!path.get("id").node[t().NOT_LOCAL_BINDING]) { + if (!path.get("id").node[t.NOT_LOCAL_BINDING]) { this.registerBinding("local", path); } } @@ -33102,13 +34402,13 @@ class Scope { let declarPath = !unique && path.getData(dataKey); if (!declarPath) { - const declar = t().variableDeclaration(kind, []); + const declar = t.variableDeclaration(kind, []); declar._blockHoist = blockHoist; [declarPath] = path.unshiftContainer("body", [declar]); if (!unique) path.setData(dataKey, declarPath); } - const declarator = t().variableDeclarator(opts.id, opts.init); + const declarator = t.variableDeclarator(opts.id, opts.init); declarPath.node.declarations.push(declarator); this.registerBinding(kind, declarPath.get("declarations").pop()); } @@ -33154,7 +34454,7 @@ class Scope { let scope = this; do { - (0, _defaults().default)(ids, scope.bindings); + (0, _defaults.default)(ids, scope.bindings); scope = scope.parent; } while (scope); @@ -33186,10 +34486,18 @@ class Scope { getBinding(name) { let scope = this; + let previousPath; do { const binding = scope.getOwnBinding(name); - if (binding) return binding; + + if (binding) { + if (previousPath && previousPath.isPattern() && previousPath.parentPath.isFunction() && binding.kind !== "param") {} else { + return binding; + } + } + + previousPath = scope.path; } while (scope = scope.parent); } @@ -33216,8 +34524,8 @@ class Scope { if (this.hasOwnBinding(name)) return true; if (this.parentHasBinding(name, noGlobals)) return true; if (this.hasUid(name)) return true; - if (!noGlobals && (0, _includes().default)(Scope.globals, name)) return true; - if (!noGlobals && (0, _includes().default)(Scope.contextVariables, name)) return true; + if (!noGlobals && (0, _includes.default)(Scope.globals, name)) return true; + if (!noGlobals && (0, _includes.default)(Scope.contextVariables, name)) return true; return false; } @@ -33258,9 +34566,9 @@ class Scope { } exports.default = Scope; -Scope.globals = Object.keys(_globals().default.builtin); +Scope.globals = Object.keys(_globals.default.builtin); Scope.contextVariables = ["arguments", "undefined", "Infinity", "NaN"]; -},{"../cache":89,"../index":92,"./binding":110,"./lib/renamer":112,"@babel/types":155,"globals":216,"lodash/defaults":381,"lodash/includes":389,"lodash/repeat":411}],112:[function(require,module,exports){ +},{"../cache":94,"../index":97,"./binding":115,"./lib/renamer":117,"@babel/types":160,"globals":222,"lodash/defaults":387,"lodash/includes":395,"lodash/repeat":417}],117:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -33270,27 +34578,13 @@ exports.default = void 0; var _binding = _interopRequireDefault(require("../binding")); -function _helperSplitExportDeclaration() { - const data = _interopRequireDefault(require("@babel/helper-split-export-declaration")); +var _helperSplitExportDeclaration = _interopRequireDefault(require("@babel/helper-split-export-declaration")); - _helperSplitExportDeclaration = function () { - return data; - }; +var t = _interopRequireWildcard(require("@babel/types")); - return data; -} - -function t() { - const data = _interopRequireWildcard(require("@babel/types")); - - t = function () { - return data; - }; +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } - return data; -} - -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -33337,27 +34631,27 @@ class Renamer { return; } - (0, _helperSplitExportDeclaration().default)(maybeExportDeclar); + (0, _helperSplitExportDeclaration.default)(maybeExportDeclar); } maybeConvertFromClassFunctionDeclaration(path) { return; if (!path.isFunctionDeclaration() && !path.isClassDeclaration()) return; if (this.binding.kind !== "hoisted") return; - path.node.id = t().identifier(this.oldName); + path.node.id = t.identifier(this.oldName); path.node._blockHoist = 3; - path.replaceWith(t().variableDeclaration("let", [t().variableDeclarator(t().identifier(this.newName), t().toExpression(path.node))])); + path.replaceWith(t.variableDeclaration("let", [t.variableDeclarator(t.identifier(this.newName), t.toExpression(path.node))])); } maybeConvertFromClassFunctionExpression(path) { return; if (!path.isFunctionExpression() && !path.isClassExpression()) return; if (this.binding.kind !== "local") return; - path.node.id = t().identifier(this.oldName); + path.node.id = t.identifier(this.oldName); this.binding.scope.parent.push({ - id: t().identifier(this.newName) + id: t.identifier(this.newName) }); - path.replaceWith(t().assignmentExpression("=", t().identifier(this.newName), path.node)); + path.replaceWith(t.assignmentExpression("=", t.identifier(this.newName), path.node)); } rename(block) { @@ -33399,7 +34693,7 @@ class Renamer { } exports.default = Renamer; -},{"../binding":110,"@babel/helper-split-export-declaration":66,"@babel/types":155}],113:[function(require,module,exports){ +},{"../binding":115,"@babel/helper-split-export-declaration":68,"@babel/types":160}],118:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -33411,29 +34705,15 @@ exports.merge = merge; var virtualTypes = _interopRequireWildcard(require("./path/lib/virtual-types")); -function t() { - const data = _interopRequireWildcard(require("@babel/types")); +var t = _interopRequireWildcard(require("@babel/types")); - t = function () { - return data; - }; - - return data; -} - -function _clone() { - const data = _interopRequireDefault(require("lodash/clone")); - - _clone = function () { - return data; - }; - - return data; -} +var _clone = _interopRequireDefault(require("lodash/clone")); 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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function explode(visitor) { if (visitor._exploded) return visitor; @@ -33484,8 +34764,8 @@ function explode(visitor) { for (const nodeType of Object.keys(visitor)) { if (shouldIgnoreKey(nodeType)) continue; const fns = visitor[nodeType]; - let aliases = t().FLIPPED_ALIAS_KEYS[nodeType]; - const deprecratedKey = t().DEPRECATED_KEYS[nodeType]; + let aliases = t.FLIPPED_ALIAS_KEYS[nodeType]; + const deprecratedKey = t.DEPRECATED_KEYS[nodeType]; if (deprecratedKey) { console.trace(`Visitor defined for ${nodeType} but it has been renamed to ${deprecratedKey}`); @@ -33501,7 +34781,7 @@ function explode(visitor) { if (existing) { mergePair(existing, fns); } else { - visitor[alias] = (0, _clone().default)(fns); + visitor[alias] = (0, _clone.default)(fns); } } } @@ -33528,7 +34808,7 @@ function verify(visitor) { if (shouldIgnoreKey(nodeType)) continue; - if (t().TYPES.indexOf(nodeType) < 0) { + if (t.TYPES.indexOf(nodeType) < 0) { throw new Error(`You gave us a visitor for the node type ${nodeType} but it's not a valid type`); } @@ -33600,6 +34880,10 @@ function wrapWithStateOrWrapper(oldVisitor, state, wrapper) { newFn = wrapper(state.key, key, newFn); } + if (newFn !== fn) { + newFn.toString = () => fn.toString(); + } + return newFn; }); newVisitor[key] = fns; @@ -33654,7 +34938,7 @@ function mergePair(dest, src) { dest[key] = [].concat(dest[key] || [], src[key]); } } -},{"./path/lib/virtual-types":106,"@babel/types":155,"lodash/clone":378}],114:[function(require,module,exports){ +},{"./path/lib/virtual-types":111,"@babel/types":160,"lodash/clone":384}],119:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -33672,7 +34956,7 @@ function assertNode(node) { throw new TypeError(`Not a valid node of type "${type}"`); } } -},{"../validators/isNode":176}],115:[function(require,module,exports){ +},{"../validators/isNode":181}],120:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -33733,8 +35017,8 @@ exports.assertAssignmentPattern = assertAssignmentPattern; exports.assertArrayPattern = assertArrayPattern; exports.assertArrowFunctionExpression = assertArrowFunctionExpression; exports.assertClassBody = assertClassBody; -exports.assertClassDeclaration = assertClassDeclaration; exports.assertClassExpression = assertClassExpression; +exports.assertClassDeclaration = assertClassDeclaration; exports.assertExportAllDeclaration = assertExportAllDeclaration; exports.assertExportDefaultDeclaration = assertExportDefaultDeclaration; exports.assertExportNamedDeclaration = assertExportNamedDeclaration; @@ -33806,6 +35090,15 @@ exports.assertTypeParameterInstantiation = assertTypeParameterInstantiation; exports.assertUnionTypeAnnotation = assertUnionTypeAnnotation; exports.assertVariance = assertVariance; exports.assertVoidTypeAnnotation = assertVoidTypeAnnotation; +exports.assertEnumDeclaration = assertEnumDeclaration; +exports.assertEnumBooleanBody = assertEnumBooleanBody; +exports.assertEnumNumberBody = assertEnumNumberBody; +exports.assertEnumStringBody = assertEnumStringBody; +exports.assertEnumSymbolBody = assertEnumSymbolBody; +exports.assertEnumBooleanMember = assertEnumBooleanMember; +exports.assertEnumNumberMember = assertEnumNumberMember; +exports.assertEnumStringMember = assertEnumStringMember; +exports.assertEnumDefaultedMember = assertEnumDefaultedMember; exports.assertJSXAttribute = assertJSXAttribute; exports.assertJSXClosingElement = assertJSXClosingElement; exports.assertJSXElement = assertJSXElement; @@ -33823,6 +35116,7 @@ exports.assertJSXOpeningFragment = assertJSXOpeningFragment; exports.assertJSXClosingFragment = assertJSXClosingFragment; exports.assertNoop = assertNoop; exports.assertPlaceholder = assertPlaceholder; +exports.assertV8IntrinsicIdentifier = assertV8IntrinsicIdentifier; exports.assertArgumentPlaceholder = assertArgumentPlaceholder; exports.assertAwaitExpression = assertAwaitExpression; exports.assertBindExpression = assertBindExpression; @@ -33851,16 +35145,17 @@ exports.assertTSPropertySignature = assertTSPropertySignature; exports.assertTSMethodSignature = assertTSMethodSignature; exports.assertTSIndexSignature = assertTSIndexSignature; exports.assertTSAnyKeyword = assertTSAnyKeyword; -exports.assertTSUnknownKeyword = assertTSUnknownKeyword; +exports.assertTSBooleanKeyword = assertTSBooleanKeyword; +exports.assertTSBigIntKeyword = assertTSBigIntKeyword; +exports.assertTSNeverKeyword = assertTSNeverKeyword; +exports.assertTSNullKeyword = assertTSNullKeyword; exports.assertTSNumberKeyword = assertTSNumberKeyword; exports.assertTSObjectKeyword = assertTSObjectKeyword; -exports.assertTSBooleanKeyword = assertTSBooleanKeyword; exports.assertTSStringKeyword = assertTSStringKeyword; exports.assertTSSymbolKeyword = assertTSSymbolKeyword; -exports.assertTSVoidKeyword = assertTSVoidKeyword; exports.assertTSUndefinedKeyword = assertTSUndefinedKeyword; -exports.assertTSNullKeyword = assertTSNullKeyword; -exports.assertTSNeverKeyword = assertTSNeverKeyword; +exports.assertTSUnknownKeyword = assertTSUnknownKeyword; +exports.assertTSVoidKeyword = assertTSVoidKeyword; exports.assertTSThisType = assertTSThisType; exports.assertTSFunctionType = assertTSFunctionType; exports.assertTSConstructorType = assertTSConstructorType; @@ -33939,6 +35234,8 @@ exports.assertFlowType = assertFlowType; exports.assertFlowBaseAnnotation = assertFlowBaseAnnotation; exports.assertFlowDeclaration = assertFlowDeclaration; exports.assertFlowPredicate = assertFlowPredicate; +exports.assertEnumBody = assertEnumBody; +exports.assertEnumMember = assertEnumMember; exports.assertJSX = assertJSX; exports.assertPrivate = assertPrivate; exports.assertTSTypeElement = assertTSTypeElement; @@ -33954,7 +35251,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de function assert(type, node, opts) { if (!(0, _is.default)(type, node, opts)) { - throw new Error(`Expected type "${type}" with option ${JSON.stringify(opts)}, but instead got "${node.type}".`); + throw new Error(`Expected type "${type}" with option ${JSON.stringify(opts)}, ` + `but instead got "${node.type}".`); } } @@ -34178,14 +35475,14 @@ function assertClassBody(node, opts = {}) { assert("ClassBody", node, opts); } -function assertClassDeclaration(node, opts = {}) { - assert("ClassDeclaration", node, opts); -} - function assertClassExpression(node, opts = {}) { assert("ClassExpression", node, opts); } +function assertClassDeclaration(node, opts = {}) { + assert("ClassDeclaration", node, opts); +} + function assertExportAllDeclaration(node, opts = {}) { assert("ExportAllDeclaration", node, opts); } @@ -34470,6 +35767,42 @@ function assertVoidTypeAnnotation(node, opts = {}) { assert("VoidTypeAnnotation", node, opts); } +function assertEnumDeclaration(node, opts = {}) { + assert("EnumDeclaration", node, opts); +} + +function assertEnumBooleanBody(node, opts = {}) { + assert("EnumBooleanBody", node, opts); +} + +function assertEnumNumberBody(node, opts = {}) { + assert("EnumNumberBody", node, opts); +} + +function assertEnumStringBody(node, opts = {}) { + assert("EnumStringBody", node, opts); +} + +function assertEnumSymbolBody(node, opts = {}) { + assert("EnumSymbolBody", node, opts); +} + +function assertEnumBooleanMember(node, opts = {}) { + assert("EnumBooleanMember", node, opts); +} + +function assertEnumNumberMember(node, opts = {}) { + assert("EnumNumberMember", node, opts); +} + +function assertEnumStringMember(node, opts = {}) { + assert("EnumStringMember", node, opts); +} + +function assertEnumDefaultedMember(node, opts = {}) { + assert("EnumDefaultedMember", node, opts); +} + function assertJSXAttribute(node, opts = {}) { assert("JSXAttribute", node, opts); } @@ -34538,6 +35871,10 @@ function assertPlaceholder(node, opts = {}) { assert("Placeholder", node, opts); } +function assertV8IntrinsicIdentifier(node, opts = {}) { + assert("V8IntrinsicIdentifier", node, opts); +} + function assertArgumentPlaceholder(node, opts = {}) { assert("ArgumentPlaceholder", node, opts); } @@ -34650,8 +35987,20 @@ function assertTSAnyKeyword(node, opts = {}) { assert("TSAnyKeyword", node, opts); } -function assertTSUnknownKeyword(node, opts = {}) { - assert("TSUnknownKeyword", node, opts); +function assertTSBooleanKeyword(node, opts = {}) { + assert("TSBooleanKeyword", node, opts); +} + +function assertTSBigIntKeyword(node, opts = {}) { + assert("TSBigIntKeyword", node, opts); +} + +function assertTSNeverKeyword(node, opts = {}) { + assert("TSNeverKeyword", node, opts); +} + +function assertTSNullKeyword(node, opts = {}) { + assert("TSNullKeyword", node, opts); } function assertTSNumberKeyword(node, opts = {}) { @@ -34662,10 +36011,6 @@ function assertTSObjectKeyword(node, opts = {}) { assert("TSObjectKeyword", node, opts); } -function assertTSBooleanKeyword(node, opts = {}) { - assert("TSBooleanKeyword", node, opts); -} - function assertTSStringKeyword(node, opts = {}) { assert("TSStringKeyword", node, opts); } @@ -34674,20 +36019,16 @@ function assertTSSymbolKeyword(node, opts = {}) { assert("TSSymbolKeyword", node, opts); } -function assertTSVoidKeyword(node, opts = {}) { - assert("TSVoidKeyword", node, opts); -} - function assertTSUndefinedKeyword(node, opts = {}) { assert("TSUndefinedKeyword", node, opts); } -function assertTSNullKeyword(node, opts = {}) { - assert("TSNullKeyword", node, opts); +function assertTSUnknownKeyword(node, opts = {}) { + assert("TSUnknownKeyword", node, opts); } -function assertTSNeverKeyword(node, opts = {}) { - assert("TSNeverKeyword", node, opts); +function assertTSVoidKeyword(node, opts = {}) { + assert("TSVoidKeyword", node, opts); } function assertTSThisType(node, opts = {}) { @@ -35002,6 +36343,14 @@ function assertFlowPredicate(node, opts = {}) { assert("FlowPredicate", node, opts); } +function assertEnumBody(node, opts = {}) { + assert("EnumBody", node, opts); +} + +function assertEnumMember(node, opts = {}) { + assert("EnumMember", node, opts); +} + function assertJSX(node, opts = {}) { assert("JSX", node, opts); } @@ -35037,7 +36386,7 @@ function assertSpreadProperty(node, opts) { console.trace("The node type SpreadProperty has been renamed to SpreadElement"); assert("SpreadProperty", node, opts); } -},{"../../validators/is":171}],116:[function(require,module,exports){ +},{"../../validators/is":176}],121:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -35045,15 +36394,7 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = builder; -function _clone() { - const data = _interopRequireDefault(require("lodash/clone")); - - _clone = function () { - return data; - }; - - return data; -} +var _clone = _interopRequireDefault(require("lodash/clone")); var _definitions = require("../definitions"); @@ -35077,7 +36418,7 @@ function builder(type, ...args) { const field = _definitions.NODE_FIELDS[type][key]; let arg; if (i < countArgs) arg = args[i]; - if (arg === undefined) arg = (0, _clone().default)(field.default); + if (arg === undefined) arg = (0, _clone.default)(field.default); node[key] = arg; i++; }); @@ -35088,7 +36429,7 @@ function builder(type, ...args) { return node; } -},{"../definitions":149,"../validators/validate":189,"lodash/clone":378}],117:[function(require,module,exports){ +},{"../definitions":154,"../validators/validate":194,"lodash/clone":384}],122:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -35117,7 +36458,7 @@ function createTypeAnnotationBasedOnTypeof(type) { throw new Error("Invalid typeof value"); } } -},{"../generated":119}],118:[function(require,module,exports){ +},{"../generated":124}],123:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -35140,7 +36481,7 @@ function createUnionTypeAnnotation(types) { return (0, _generated.unionTypeAnnotation)(flattened); } } -},{"../../modifications/flow/removeTypeDuplicates":157,"../generated":119}],119:[function(require,module,exports){ +},{"../../modifications/flow/removeTypeDuplicates":162,"../generated":124}],124:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -35201,8 +36542,8 @@ exports.assignmentPattern = exports.AssignmentPattern = AssignmentPattern; exports.arrayPattern = exports.ArrayPattern = ArrayPattern; exports.arrowFunctionExpression = exports.ArrowFunctionExpression = ArrowFunctionExpression; exports.classBody = exports.ClassBody = ClassBody; -exports.classDeclaration = exports.ClassDeclaration = ClassDeclaration; exports.classExpression = exports.ClassExpression = ClassExpression; +exports.classDeclaration = exports.ClassDeclaration = ClassDeclaration; exports.exportAllDeclaration = exports.ExportAllDeclaration = ExportAllDeclaration; exports.exportDefaultDeclaration = exports.ExportDefaultDeclaration = ExportDefaultDeclaration; exports.exportNamedDeclaration = exports.ExportNamedDeclaration = ExportNamedDeclaration; @@ -35274,6 +36615,15 @@ exports.typeParameterInstantiation = exports.TypeParameterInstantiation = TypePa exports.unionTypeAnnotation = exports.UnionTypeAnnotation = UnionTypeAnnotation; exports.variance = exports.Variance = Variance; exports.voidTypeAnnotation = exports.VoidTypeAnnotation = VoidTypeAnnotation; +exports.enumDeclaration = exports.EnumDeclaration = EnumDeclaration; +exports.enumBooleanBody = exports.EnumBooleanBody = EnumBooleanBody; +exports.enumNumberBody = exports.EnumNumberBody = EnumNumberBody; +exports.enumStringBody = exports.EnumStringBody = EnumStringBody; +exports.enumSymbolBody = exports.EnumSymbolBody = EnumSymbolBody; +exports.enumBooleanMember = exports.EnumBooleanMember = EnumBooleanMember; +exports.enumNumberMember = exports.EnumNumberMember = EnumNumberMember; +exports.enumStringMember = exports.EnumStringMember = EnumStringMember; +exports.enumDefaultedMember = exports.EnumDefaultedMember = EnumDefaultedMember; exports.jSXAttribute = exports.jsxAttribute = exports.JSXAttribute = JSXAttribute; exports.jSXClosingElement = exports.jsxClosingElement = exports.JSXClosingElement = JSXClosingElement; exports.jSXElement = exports.jsxElement = exports.JSXElement = JSXElement; @@ -35291,6 +36641,7 @@ exports.jSXOpeningFragment = exports.jsxOpeningFragment = exports.JSXOpeningFrag exports.jSXClosingFragment = exports.jsxClosingFragment = exports.JSXClosingFragment = JSXClosingFragment; exports.noop = exports.Noop = Noop; exports.placeholder = exports.Placeholder = Placeholder; +exports.v8IntrinsicIdentifier = exports.V8IntrinsicIdentifier = V8IntrinsicIdentifier; exports.argumentPlaceholder = exports.ArgumentPlaceholder = ArgumentPlaceholder; exports.awaitExpression = exports.AwaitExpression = AwaitExpression; exports.bindExpression = exports.BindExpression = BindExpression; @@ -35319,16 +36670,17 @@ exports.tSPropertySignature = exports.tsPropertySignature = exports.TSPropertySi exports.tSMethodSignature = exports.tsMethodSignature = exports.TSMethodSignature = TSMethodSignature; exports.tSIndexSignature = exports.tsIndexSignature = exports.TSIndexSignature = TSIndexSignature; exports.tSAnyKeyword = exports.tsAnyKeyword = exports.TSAnyKeyword = TSAnyKeyword; -exports.tSUnknownKeyword = exports.tsUnknownKeyword = exports.TSUnknownKeyword = TSUnknownKeyword; +exports.tSBooleanKeyword = exports.tsBooleanKeyword = exports.TSBooleanKeyword = TSBooleanKeyword; +exports.tSBigIntKeyword = exports.tsBigIntKeyword = exports.TSBigIntKeyword = TSBigIntKeyword; +exports.tSNeverKeyword = exports.tsNeverKeyword = exports.TSNeverKeyword = TSNeverKeyword; +exports.tSNullKeyword = exports.tsNullKeyword = exports.TSNullKeyword = TSNullKeyword; exports.tSNumberKeyword = exports.tsNumberKeyword = exports.TSNumberKeyword = TSNumberKeyword; exports.tSObjectKeyword = exports.tsObjectKeyword = exports.TSObjectKeyword = TSObjectKeyword; -exports.tSBooleanKeyword = exports.tsBooleanKeyword = exports.TSBooleanKeyword = TSBooleanKeyword; exports.tSStringKeyword = exports.tsStringKeyword = exports.TSStringKeyword = TSStringKeyword; exports.tSSymbolKeyword = exports.tsSymbolKeyword = exports.TSSymbolKeyword = TSSymbolKeyword; -exports.tSVoidKeyword = exports.tsVoidKeyword = exports.TSVoidKeyword = TSVoidKeyword; exports.tSUndefinedKeyword = exports.tsUndefinedKeyword = exports.TSUndefinedKeyword = TSUndefinedKeyword; -exports.tSNullKeyword = exports.tsNullKeyword = exports.TSNullKeyword = TSNullKeyword; -exports.tSNeverKeyword = exports.tsNeverKeyword = exports.TSNeverKeyword = TSNeverKeyword; +exports.tSUnknownKeyword = exports.tsUnknownKeyword = exports.TSUnknownKeyword = TSUnknownKeyword; +exports.tSVoidKeyword = exports.tsVoidKeyword = exports.TSVoidKeyword = TSVoidKeyword; exports.tSThisType = exports.tsThisType = exports.TSThisType = TSThisType; exports.tSFunctionType = exports.tsFunctionType = exports.TSFunctionType = TSFunctionType; exports.tSConstructorType = exports.tsConstructorType = exports.TSConstructorType = TSConstructorType; @@ -35598,14 +36950,14 @@ function ClassBody(...args) { return (0, _builder.default)("ClassBody", ...args); } -function ClassDeclaration(...args) { - return (0, _builder.default)("ClassDeclaration", ...args); -} - function ClassExpression(...args) { return (0, _builder.default)("ClassExpression", ...args); } +function ClassDeclaration(...args) { + return (0, _builder.default)("ClassDeclaration", ...args); +} + function ExportAllDeclaration(...args) { return (0, _builder.default)("ExportAllDeclaration", ...args); } @@ -35890,6 +37242,42 @@ function VoidTypeAnnotation(...args) { return (0, _builder.default)("VoidTypeAnnotation", ...args); } +function EnumDeclaration(...args) { + return (0, _builder.default)("EnumDeclaration", ...args); +} + +function EnumBooleanBody(...args) { + return (0, _builder.default)("EnumBooleanBody", ...args); +} + +function EnumNumberBody(...args) { + return (0, _builder.default)("EnumNumberBody", ...args); +} + +function EnumStringBody(...args) { + return (0, _builder.default)("EnumStringBody", ...args); +} + +function EnumSymbolBody(...args) { + return (0, _builder.default)("EnumSymbolBody", ...args); +} + +function EnumBooleanMember(...args) { + return (0, _builder.default)("EnumBooleanMember", ...args); +} + +function EnumNumberMember(...args) { + return (0, _builder.default)("EnumNumberMember", ...args); +} + +function EnumStringMember(...args) { + return (0, _builder.default)("EnumStringMember", ...args); +} + +function EnumDefaultedMember(...args) { + return (0, _builder.default)("EnumDefaultedMember", ...args); +} + function JSXAttribute(...args) { return (0, _builder.default)("JSXAttribute", ...args); } @@ -35958,6 +37346,10 @@ function Placeholder(...args) { return (0, _builder.default)("Placeholder", ...args); } +function V8IntrinsicIdentifier(...args) { + return (0, _builder.default)("V8IntrinsicIdentifier", ...args); +} + function ArgumentPlaceholder(...args) { return (0, _builder.default)("ArgumentPlaceholder", ...args); } @@ -36070,8 +37462,20 @@ function TSAnyKeyword(...args) { return (0, _builder.default)("TSAnyKeyword", ...args); } -function TSUnknownKeyword(...args) { - return (0, _builder.default)("TSUnknownKeyword", ...args); +function TSBooleanKeyword(...args) { + return (0, _builder.default)("TSBooleanKeyword", ...args); +} + +function TSBigIntKeyword(...args) { + return (0, _builder.default)("TSBigIntKeyword", ...args); +} + +function TSNeverKeyword(...args) { + return (0, _builder.default)("TSNeverKeyword", ...args); +} + +function TSNullKeyword(...args) { + return (0, _builder.default)("TSNullKeyword", ...args); } function TSNumberKeyword(...args) { @@ -36082,10 +37486,6 @@ function TSObjectKeyword(...args) { return (0, _builder.default)("TSObjectKeyword", ...args); } -function TSBooleanKeyword(...args) { - return (0, _builder.default)("TSBooleanKeyword", ...args); -} - function TSStringKeyword(...args) { return (0, _builder.default)("TSStringKeyword", ...args); } @@ -36094,20 +37494,16 @@ function TSSymbolKeyword(...args) { return (0, _builder.default)("TSSymbolKeyword", ...args); } -function TSVoidKeyword(...args) { - return (0, _builder.default)("TSVoidKeyword", ...args); -} - function TSUndefinedKeyword(...args) { return (0, _builder.default)("TSUndefinedKeyword", ...args); } -function TSNullKeyword(...args) { - return (0, _builder.default)("TSNullKeyword", ...args); +function TSUnknownKeyword(...args) { + return (0, _builder.default)("TSUnknownKeyword", ...args); } -function TSNeverKeyword(...args) { - return (0, _builder.default)("TSNeverKeyword", ...args); +function TSVoidKeyword(...args) { + return (0, _builder.default)("TSVoidKeyword", ...args); } function TSThisType(...args) { @@ -36289,7 +37685,7 @@ function SpreadProperty(...args) { console.trace("The node type SpreadProperty has been renamed to SpreadElement"); return SpreadProperty("SpreadProperty", ...args); } -},{"../builder":116}],120:[function(require,module,exports){ +},{"../builder":121}],125:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -36321,7 +37717,7 @@ function buildChildren(node) { return elements; } -},{"../../utils/react/cleanJSXElementLiteralChild":167,"../../validators/generated":170}],121:[function(require,module,exports){ +},{"../../utils/react/cleanJSXElementLiteralChild":172,"../../validators/generated":175}],126:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -36336,7 +37732,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de function clone(node) { return (0, _cloneNode.default)(node, false); } -},{"./cloneNode":123}],122:[function(require,module,exports){ +},{"./cloneNode":128}],127:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -36351,7 +37747,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de function cloneDeep(node) { return (0, _cloneNode.default)(node); } -},{"./cloneNode":123}],123:[function(require,module,exports){ +},{"./cloneNode":128}],128:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -36430,7 +37826,7 @@ function cloneNode(node, deep = true) { return newNode; } -},{"../definitions":149}],124:[function(require,module,exports){ +},{"../definitions":154}],129:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -36447,7 +37843,7 @@ function cloneWithoutLoc(node) { newNode.loc = null; return newNode; } -},{"./clone":121}],125:[function(require,module,exports){ +},{"./clone":126}],130:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -36465,7 +37861,7 @@ function addComment(node, type, content, line) { value: content }]); } -},{"./addComments":126}],126:[function(require,module,exports){ +},{"./addComments":131}],131:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -36489,7 +37885,7 @@ function addComments(node, type, comments) { return node; } -},{}],127:[function(require,module,exports){ +},{}],132:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -36504,7 +37900,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de function inheritInnerComments(child, parent) { (0, _inherit.default)("innerComments", child, parent); } -},{"../utils/inherit":166}],128:[function(require,module,exports){ +},{"../utils/inherit":171}],133:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -36519,7 +37915,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de function inheritLeadingComments(child, parent) { (0, _inherit.default)("leadingComments", child, parent); } -},{"../utils/inherit":166}],129:[function(require,module,exports){ +},{"../utils/inherit":171}],134:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -36534,7 +37930,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de function inheritTrailingComments(child, parent) { (0, _inherit.default)("trailingComments", child, parent); } -},{"../utils/inherit":166}],130:[function(require,module,exports){ +},{"../utils/inherit":171}],135:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -36556,7 +37952,7 @@ function inheritsComments(child, parent) { (0, _inheritInnerComments.default)(child, parent); return child; } -},{"./inheritInnerComments":127,"./inheritLeadingComments":128,"./inheritTrailingComments":129}],131:[function(require,module,exports){ +},{"./inheritInnerComments":132,"./inheritLeadingComments":133,"./inheritTrailingComments":134}],136:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -36573,13 +37969,13 @@ function removeComments(node) { return node; } -},{"../constants":133}],132:[function(require,module,exports){ +},{"../constants":138}],137:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.TSTYPE_TYPES = exports.TSTYPEELEMENT_TYPES = exports.PRIVATE_TYPES = exports.JSX_TYPES = exports.FLOWPREDICATE_TYPES = exports.FLOWDECLARATION_TYPES = exports.FLOWBASEANNOTATION_TYPES = exports.FLOWTYPE_TYPES = exports.FLOW_TYPES = exports.MODULESPECIFIER_TYPES = exports.EXPORTDECLARATION_TYPES = exports.MODULEDECLARATION_TYPES = exports.CLASS_TYPES = exports.PATTERN_TYPES = exports.UNARYLIKE_TYPES = exports.PROPERTY_TYPES = exports.OBJECTMEMBER_TYPES = exports.METHOD_TYPES = exports.USERWHITESPACABLE_TYPES = exports.IMMUTABLE_TYPES = exports.LITERAL_TYPES = exports.TSENTITYNAME_TYPES = exports.LVAL_TYPES = exports.PATTERNLIKE_TYPES = exports.DECLARATION_TYPES = exports.PUREISH_TYPES = exports.FUNCTIONPARENT_TYPES = exports.FUNCTION_TYPES = exports.FORXSTATEMENT_TYPES = exports.FOR_TYPES = exports.EXPRESSIONWRAPPER_TYPES = exports.WHILE_TYPES = exports.LOOP_TYPES = exports.CONDITIONAL_TYPES = exports.COMPLETIONSTATEMENT_TYPES = exports.TERMINATORLESS_TYPES = exports.STATEMENT_TYPES = exports.BLOCK_TYPES = exports.BLOCKPARENT_TYPES = exports.SCOPABLE_TYPES = exports.BINARY_TYPES = exports.EXPRESSION_TYPES = void 0; +exports.TSTYPE_TYPES = exports.TSTYPEELEMENT_TYPES = exports.PRIVATE_TYPES = exports.JSX_TYPES = exports.ENUMMEMBER_TYPES = exports.ENUMBODY_TYPES = exports.FLOWPREDICATE_TYPES = exports.FLOWDECLARATION_TYPES = exports.FLOWBASEANNOTATION_TYPES = exports.FLOWTYPE_TYPES = exports.FLOW_TYPES = exports.MODULESPECIFIER_TYPES = exports.EXPORTDECLARATION_TYPES = exports.MODULEDECLARATION_TYPES = exports.CLASS_TYPES = exports.PATTERN_TYPES = exports.UNARYLIKE_TYPES = exports.PROPERTY_TYPES = exports.OBJECTMEMBER_TYPES = exports.METHOD_TYPES = exports.USERWHITESPACABLE_TYPES = exports.IMMUTABLE_TYPES = exports.LITERAL_TYPES = exports.TSENTITYNAME_TYPES = exports.LVAL_TYPES = exports.PATTERNLIKE_TYPES = exports.DECLARATION_TYPES = exports.PUREISH_TYPES = exports.FUNCTIONPARENT_TYPES = exports.FUNCTION_TYPES = exports.FORXSTATEMENT_TYPES = exports.FOR_TYPES = exports.EXPRESSIONWRAPPER_TYPES = exports.WHILE_TYPES = exports.LOOP_TYPES = exports.CONDITIONAL_TYPES = exports.COMPLETIONSTATEMENT_TYPES = exports.TERMINATORLESS_TYPES = exports.STATEMENT_TYPES = exports.BLOCK_TYPES = exports.BLOCKPARENT_TYPES = exports.SCOPABLE_TYPES = exports.BINARY_TYPES = exports.EXPRESSION_TYPES = void 0; var _definitions = require("../../definitions"); @@ -36659,6 +38055,10 @@ const FLOWDECLARATION_TYPES = _definitions.FLIPPED_ALIAS_KEYS["FlowDeclaration"] exports.FLOWDECLARATION_TYPES = FLOWDECLARATION_TYPES; const FLOWPREDICATE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["FlowPredicate"]; exports.FLOWPREDICATE_TYPES = FLOWPREDICATE_TYPES; +const ENUMBODY_TYPES = _definitions.FLIPPED_ALIAS_KEYS["EnumBody"]; +exports.ENUMBODY_TYPES = ENUMBODY_TYPES; +const ENUMMEMBER_TYPES = _definitions.FLIPPED_ALIAS_KEYS["EnumMember"]; +exports.ENUMMEMBER_TYPES = ENUMMEMBER_TYPES; const JSX_TYPES = _definitions.FLIPPED_ALIAS_KEYS["JSX"]; exports.JSX_TYPES = JSX_TYPES; const PRIVATE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Private"]; @@ -36667,13 +38067,13 @@ const TSTYPEELEMENT_TYPES = _definitions.FLIPPED_ALIAS_KEYS["TSTypeElement"]; exports.TSTYPEELEMENT_TYPES = TSTYPEELEMENT_TYPES; const TSTYPE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["TSType"]; exports.TSTYPE_TYPES = TSTYPE_TYPES; -},{"../../definitions":149}],133:[function(require,module,exports){ +},{"../../definitions":154}],138:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.NOT_LOCAL_BINDING = exports.BLOCK_SCOPED_SYMBOL = exports.INHERIT_KEYS = exports.UNARY_OPERATORS = exports.STRING_UNARY_OPERATORS = exports.NUMBER_UNARY_OPERATORS = exports.BOOLEAN_UNARY_OPERATORS = exports.BINARY_OPERATORS = exports.NUMBER_BINARY_OPERATORS = exports.BOOLEAN_BINARY_OPERATORS = exports.COMPARISON_BINARY_OPERATORS = exports.EQUALITY_BINARY_OPERATORS = exports.BOOLEAN_NUMBER_BINARY_OPERATORS = exports.UPDATE_OPERATORS = exports.LOGICAL_OPERATORS = exports.COMMENT_KEYS = exports.FOR_INIT_KEYS = exports.FLATTENABLE_KEYS = exports.STATEMENT_OR_BLOCK_KEYS = void 0; +exports.NOT_LOCAL_BINDING = exports.BLOCK_SCOPED_SYMBOL = exports.INHERIT_KEYS = exports.UNARY_OPERATORS = exports.STRING_UNARY_OPERATORS = exports.NUMBER_UNARY_OPERATORS = exports.BOOLEAN_UNARY_OPERATORS = exports.ASSIGNMENT_OPERATORS = exports.BINARY_OPERATORS = exports.NUMBER_BINARY_OPERATORS = exports.BOOLEAN_BINARY_OPERATORS = exports.COMPARISON_BINARY_OPERATORS = exports.EQUALITY_BINARY_OPERATORS = exports.BOOLEAN_NUMBER_BINARY_OPERATORS = exports.UPDATE_OPERATORS = exports.LOGICAL_OPERATORS = exports.COMMENT_KEYS = exports.FOR_INIT_KEYS = exports.FLATTENABLE_KEYS = exports.STATEMENT_OR_BLOCK_KEYS = void 0; const STATEMENT_OR_BLOCK_KEYS = ["consequent", "body", "alternate"]; exports.STATEMENT_OR_BLOCK_KEYS = STATEMENT_OR_BLOCK_KEYS; const FLATTENABLE_KEYS = ["body", "expressions"]; @@ -36698,6 +38098,8 @@ const NUMBER_BINARY_OPERATORS = ["-", "/", "%", "*", "**", "&", "|", ">>", ">>>" exports.NUMBER_BINARY_OPERATORS = NUMBER_BINARY_OPERATORS; const BINARY_OPERATORS = ["+", ...NUMBER_BINARY_OPERATORS, ...BOOLEAN_BINARY_OPERATORS]; exports.BINARY_OPERATORS = BINARY_OPERATORS; +const ASSIGNMENT_OPERATORS = ["=", "+=", ...NUMBER_BINARY_OPERATORS.map(op => op + "=")]; +exports.ASSIGNMENT_OPERATORS = ASSIGNMENT_OPERATORS; const BOOLEAN_UNARY_OPERATORS = ["delete", "!"]; exports.BOOLEAN_UNARY_OPERATORS = BOOLEAN_UNARY_OPERATORS; const NUMBER_UNARY_OPERATORS = ["+", "-", "~"]; @@ -36715,7 +38117,7 @@ const BLOCK_SCOPED_SYMBOL = Symbol.for("var used to be block scoped"); exports.BLOCK_SCOPED_SYMBOL = BLOCK_SCOPED_SYMBOL; const NOT_LOCAL_BINDING = Symbol.for("should not be considered a local binding"); exports.NOT_LOCAL_BINDING = NOT_LOCAL_BINDING; -},{}],134:[function(require,module,exports){ +},{}],139:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -36730,7 +38132,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de function ensureBlock(node, key = "body") { return node[key] = (0, _toBlock.default)(node[key], node); } -},{"./toBlock":137}],135:[function(require,module,exports){ +},{"./toBlock":142}],140:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -36804,7 +38206,7 @@ function gatherSequenceExpressions(nodes, scope, declars) { return (0, _generated2.sequenceExpression)(exprs); } } -},{"../builders/generated":119,"../clone/cloneNode":123,"../retrievers/getBindingIdentifiers":162,"../validators/generated":170}],136:[function(require,module,exports){ +},{"../builders/generated":124,"../clone/cloneNode":128,"../retrievers/getBindingIdentifiers":167,"../validators/generated":175}],141:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -36821,7 +38223,7 @@ function toBindingIdentifierName(name) { if (name === "eval" || name === "arguments") name = "_" + name; return name; } -},{"./toIdentifier":140}],137:[function(require,module,exports){ +},{"./toIdentifier":145}],142:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -36856,7 +38258,7 @@ function toBlock(node, parent) { return (0, _generated2.blockStatement)(blockNodes); } -},{"../builders/generated":119,"../validators/generated":170}],138:[function(require,module,exports){ +},{"../builders/generated":124,"../validators/generated":175}],143:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -36872,7 +38274,7 @@ function toComputedKey(node, key = node.key || node.property) { if (!node.computed && (0, _generated.isIdentifier)(key)) key = (0, _generated2.stringLiteral)(key.name); return key; } -},{"../builders/generated":119,"../validators/generated":170}],139:[function(require,module,exports){ +},{"../builders/generated":124,"../validators/generated":175}],144:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -36903,7 +38305,7 @@ function toExpression(node) { return node; } -},{"../validators/generated":170}],140:[function(require,module,exports){ +},{"../validators/generated":175}],145:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -36929,7 +38331,7 @@ function toIdentifier(name) { return name || "_"; } -},{"../validators/isValidIdentifier":184}],141:[function(require,module,exports){ +},{"../validators/isValidIdentifier":189}],146:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -36978,7 +38380,7 @@ toKeyAlias.increment = function () { return toKeyAlias.uid++; } }; -},{"../clone/cloneNode":123,"../modifications/removePropertiesDeep":161,"../validators/generated":170}],142:[function(require,module,exports){ +},{"../clone/cloneNode":128,"../modifications/removePropertiesDeep":166,"../validators/generated":175}],147:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -37002,7 +38404,7 @@ function toSequenceExpression(nodes, scope) { return result; } -},{"./gatherSequenceExpressions":135}],143:[function(require,module,exports){ +},{"./gatherSequenceExpressions":140}],148:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -37047,7 +38449,7 @@ function toStatement(node, ignore) { node.type = newType; return node; } -},{"../builders/generated":119,"../validators/generated":170}],144:[function(require,module,exports){ +},{"../builders/generated":124,"../validators/generated":175}],149:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -37055,25 +38457,9 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = valueToNode; -function _isPlainObject() { - const data = _interopRequireDefault(require("lodash/isPlainObject")); - - _isPlainObject = function () { - return data; - }; - - return data; -} +var _isPlainObject = _interopRequireDefault(require("lodash/isPlainObject")); -function _isRegExp() { - const data = _interopRequireDefault(require("lodash/isRegExp")); - - _isRegExp = function () { - return data; - }; - - return data; -} +var _isRegExp = _interopRequireDefault(require("lodash/isRegExp")); var _isValidIdentifier = _interopRequireDefault(require("../validators/isValidIdentifier")); @@ -37122,7 +38508,7 @@ function valueToNode(value) { return result; } - if ((0, _isRegExp().default)(value)) { + if ((0, _isRegExp.default)(value)) { const pattern = value.source; const flags = value.toString().match(/\/([a-z]+|)$/)[1]; return (0, _generated.regExpLiteral)(pattern, flags); @@ -37132,7 +38518,7 @@ function valueToNode(value) { return (0, _generated.arrayExpression)(value.map(valueToNode)); } - if ((0, _isPlainObject().default)(value)) { + if ((0, _isPlainObject.default)(value)) { const props = []; for (const key of Object.keys(value)) { @@ -37152,7 +38538,8 @@ function valueToNode(value) { throw new Error("don't know how to turn this value into a node"); } -},{"../builders/generated":119,"../validators/isValidIdentifier":184,"lodash/isPlainObject":400,"lodash/isRegExp":401}],145:[function(require,module,exports){ +},{"../builders/generated":124,"../validators/isValidIdentifier":189,"lodash/isPlainObject":406,"lodash/isRegExp":407}],150:[function(require,module,exports){ +(function (process){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -37160,13 +38547,17 @@ Object.defineProperty(exports, "__esModule", { }); exports.patternLikeCommon = exports.functionDeclarationCommon = exports.functionTypeAnnotationCommon = exports.functionCommon = void 0; -var _isValidIdentifier = _interopRequireDefault(require("../validators/isValidIdentifier")); +var _esutils = _interopRequireDefault(require("esutils")); + +var _is = _interopRequireDefault(require("../validators/is")); var _constants = require("../constants"); var _utils = _interopRequireWildcard(require("./utils")); -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -37174,7 +38565,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de fields: { elements: { validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeOrValueType)("null", "Expression", "SpreadElement"))), - default: [] + default: !process.env.BABEL_TYPES_8_BREAKING ? [] : undefined } }, visitor: ["elements"], @@ -37183,10 +38574,21 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de (0, _utils.default)("AssignmentExpression", { fields: { operator: { - validate: (0, _utils.assertValueType)("string") + validate: function () { + if (!process.env.BABEL_TYPES_8_BREAKING) { + return (0, _utils.assertValueType)("string"); + } + + const identifier = (0, _utils.assertOneOf)(..._constants.ASSIGNMENT_OPERATORS); + const pattern = (0, _utils.assertOneOf)("="); + return function (node, key, val) { + const validator = (0, _is.default)("Pattern", node.left) ? pattern : identifier; + validator(node, key, val); + }; + }() }, left: { - validate: (0, _utils.assertNodeType)("LVal") + validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("LVal") : (0, _utils.assertNodeType)("Identifier", "MemberExpression", "ArrayPattern", "ObjectPattern") }, right: { validate: (0, _utils.assertNodeType)("Expression") @@ -37264,17 +38666,19 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de visitor: ["callee", "arguments", "typeParameters", "typeArguments"], builder: ["callee", "arguments"], aliases: ["Expression"], - fields: { + fields: Object.assign({ callee: { - validate: (0, _utils.assertNodeType)("Expression") + validate: (0, _utils.assertNodeType)("Expression", "V8IntrinsicIdentifier") }, arguments: { validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression", "SpreadElement", "JSXNamespacedName", "ArgumentPlaceholder"))) - }, + } + }, !process.env.BABEL_TYPES_8_BREAKING ? { optional: { validate: (0, _utils.assertOneOf)(true, false), optional: true - }, + } + } : {}, { typeArguments: { validate: (0, _utils.assertNodeType)("TypeParameterInstantiation"), optional: true @@ -37283,13 +38687,13 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de validate: (0, _utils.assertNodeType)("TSTypeParameterInstantiation"), optional: true } - } + }) }); (0, _utils.default)("CatchClause", { visitor: ["param", "body"], fields: { param: { - validate: (0, _utils.assertNodeType)("Identifier"), + validate: (0, _utils.assertNodeType)("Identifier", "ArrayPattern", "ObjectPattern"), optional: true }, body: { @@ -37364,7 +38768,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de aliases: ["Scopable", "Statement", "For", "BlockParent", "Loop", "ForXStatement"], fields: { left: { - validate: (0, _utils.assertNodeType)("VariableDeclaration", "LVal") + validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("VariableDeclaration", "LVal") : (0, _utils.assertNodeType)("VariableDeclaration", "Identifier", "MemberExpression", "ArrayPattern", "ObjectPattern") }, right: { validate: (0, _utils.assertNodeType)("Expression") @@ -37400,11 +38804,9 @@ const functionCommon = { validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Identifier", "Pattern", "RestElement", "TSParameterProperty"))) }, generator: { - default: false, - validate: (0, _utils.assertValueType)("boolean") + default: false }, async: { - validate: (0, _utils.assertValueType)("boolean"), default: false } }; @@ -37434,17 +38836,26 @@ exports.functionDeclarationCommon = functionDeclarationCommon; (0, _utils.default)("FunctionDeclaration", { builder: ["id", "params", "body", "generator", "async"], visitor: ["id", "params", "body", "returnType", "typeParameters"], - fields: Object.assign({}, functionDeclarationCommon, functionTypeAnnotationCommon, { + fields: Object.assign({}, functionDeclarationCommon, {}, functionTypeAnnotationCommon, { body: { validate: (0, _utils.assertNodeType)("BlockStatement") } }), - aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Statement", "Pureish", "Declaration"] + aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Statement", "Pureish", "Declaration"], + validate: function () { + if (!process.env.BABEL_TYPES_8_BREAKING) return () => {}; + const identifier = (0, _utils.assertNodeType)("Identifier"); + return function (parent, key, node) { + if (!(0, _is.default)("ExportDefaultDeclaration", parent)) { + identifier(node, "id", node.id); + } + }; + }() }); (0, _utils.default)("FunctionExpression", { inherits: "FunctionDeclaration", aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Expression", "Pureish"], - fields: Object.assign({}, functionCommon, functionTypeAnnotationCommon, { + fields: Object.assign({}, functionCommon, {}, functionTypeAnnotationCommon, { id: { validate: (0, _utils.assertNodeType)("Identifier"), optional: true @@ -37470,15 +38881,52 @@ exports.patternLikeCommon = patternLikeCommon; aliases: ["Expression", "PatternLike", "LVal", "TSEntityName"], fields: Object.assign({}, patternLikeCommon, { name: { - validate: (0, _utils.chain)(function (node, key, val) { - if (!(0, _isValidIdentifier.default)(val)) {} - }, (0, _utils.assertValueType)("string")) + validate: (0, _utils.chain)((0, _utils.assertValueType)("string"), function (node, key, val) { + if (!process.env.BABEL_TYPES_8_BREAKING) return; + + if (!_esutils.default.keyword.isIdentifierNameES6(val)) { + throw new TypeError(`"${val}" is not a valid identifier name`); + } + }) }, optional: { validate: (0, _utils.assertValueType)("boolean"), optional: true } - }) + }), + + validate(parent, key, node) { + if (!process.env.BABEL_TYPES_8_BREAKING) return; + const match = /\.(\w+)$/.exec(key); + if (!match) return; + const [, parentKey] = match; + const nonComp = { + computed: false + }; + + if (parentKey === "property") { + if ((0, _is.default)("MemberExpression", parent, nonComp)) return; + if ((0, _is.default)("OptionalMemberExpression", parent, nonComp)) return; + } else if (parentKey === "key") { + if ((0, _is.default)("Property", parent, nonComp)) return; + if ((0, _is.default)("Method", parent, nonComp)) return; + } else if (parentKey === "exported") { + if ((0, _is.default)("ExportSpecifier", parent)) return; + } else if (parentKey === "imported") { + if ((0, _is.default)("ImportSpecifier", parent, { + imported: node + })) return; + } else if (parentKey === "meta") { + if ((0, _is.default)("MetaProperty", parent, { + meta: node + })) return; + } + + if (_esutils.default.keyword.isReservedWordES6(node.name, false) && node.name !== "this") { + throw new TypeError(`"${node.name}" is not a valid identifer`); + } + } + }); (0, _utils.default)("IfStatement", { visitor: ["test", "consequent", "alternate"], @@ -37548,7 +38996,14 @@ exports.patternLikeCommon = patternLikeCommon; validate: (0, _utils.assertValueType)("string") }, flags: { - validate: (0, _utils.assertValueType)("string"), + validate: (0, _utils.chain)((0, _utils.assertValueType)("string"), function (node, key, val) { + if (!process.env.BABEL_TYPES_8_BREAKING) return; + const invalid = /[^gimsuy]/.exec(val); + + if (invalid) { + throw new TypeError(`"${invalid[0]}" is not a valid RegExp flag`); + } + }), default: "" } } @@ -37573,7 +39028,7 @@ exports.patternLikeCommon = patternLikeCommon; builder: ["object", "property", "computed", "optional"], visitor: ["object", "property"], aliases: ["Expression", "LVal"], - fields: { + fields: Object.assign({ object: { validate: (0, _utils.assertNodeType)("Expression") }, @@ -37589,12 +39044,13 @@ exports.patternLikeCommon = patternLikeCommon; }, computed: { default: false - }, + } + }, !process.env.BABEL_TYPES_8_BREAKING ? { optional: { validate: (0, _utils.assertOneOf)(true, false), optional: true } - } + } : {}) }); (0, _utils.default)("NewExpression", { inherits: "CallExpression" @@ -37635,14 +39091,14 @@ exports.patternLikeCommon = patternLikeCommon; } }); (0, _utils.default)("ObjectMethod", { - builder: ["kind", "key", "params", "body", "computed"], - fields: Object.assign({}, functionCommon, functionTypeAnnotationCommon, { - kind: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("string"), (0, _utils.assertOneOf)("method", "get", "set")), + builder: ["kind", "key", "params", "body", "computed", "generator", "async"], + fields: Object.assign({}, functionCommon, {}, functionTypeAnnotationCommon, { + kind: Object.assign({ + validate: (0, _utils.assertOneOf)("method", "get", "set") + }, !process.env.BABEL_TYPES_8_BREAKING ? { default: "method" - }, + } : {}), computed: { - validate: (0, _utils.assertValueType)("boolean"), default: false }, key: { @@ -37656,7 +39112,8 @@ exports.patternLikeCommon = patternLikeCommon; }() }, decorators: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))) + validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), + optional: true }, body: { validate: (0, _utils.assertNodeType)("BlockStatement") @@ -37666,10 +39123,9 @@ exports.patternLikeCommon = patternLikeCommon; aliases: ["UserWhitespacable", "Function", "Scopable", "BlockParent", "FunctionParent", "Method", "ObjectMember"] }); (0, _utils.default)("ObjectProperty", { - builder: ["key", "value", "computed", "shorthand", "decorators"], + builder: ["key", "value", "computed", "shorthand", ...(!process.env.BABEL_TYPES_8_BREAKING ? ["decorators"] : [])], fields: { computed: { - validate: (0, _utils.assertValueType)("boolean"), default: false }, key: { @@ -37686,7 +39142,19 @@ exports.patternLikeCommon = patternLikeCommon; validate: (0, _utils.assertNodeType)("Expression", "PatternLike") }, shorthand: { - validate: (0, _utils.assertValueType)("boolean"), + validate: (0, _utils.chain)((0, _utils.assertValueType)("boolean"), function (node, key, val) { + if (!process.env.BABEL_TYPES_8_BREAKING) return; + + if (val && node.computed) { + throw new TypeError("Property shorthand of ObjectProperty cannot be true if computed is true"); + } + }, function (node, key, val) { + if (!process.env.BABEL_TYPES_8_BREAKING) return; + + if (val && !(0, _is.default)("Identifier", node.key)) { + throw new TypeError("Property shorthand of ObjectProperty cannot be true if key is not an Identifier"); + } + }), default: false }, decorators: { @@ -37695,7 +39163,16 @@ exports.patternLikeCommon = patternLikeCommon; } }, visitor: ["key", "value", "decorators"], - aliases: ["UserWhitespacable", "Property", "ObjectMember"] + aliases: ["UserWhitespacable", "Property", "ObjectMember"], + validate: function () { + const pattern = (0, _utils.assertNodeType)("Identifier", "Pattern"); + const expression = (0, _utils.assertNodeType)("Expression"); + return function (parent, key, node) { + if (!process.env.BABEL_TYPES_8_BREAKING) return; + const validator = (0, _is.default)("ObjectPattern", parent) ? pattern : expression; + validator(node, "value", node.value); + }; + }() }); (0, _utils.default)("RestElement", { visitor: ["argument", "typeAnnotation"], @@ -37704,9 +39181,21 @@ exports.patternLikeCommon = patternLikeCommon; deprecatedAlias: "RestProperty", fields: Object.assign({}, patternLikeCommon, { argument: { - validate: (0, _utils.assertNodeType)("LVal") + validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("LVal") : (0, _utils.assertNodeType)("Identifier", "Pattern", "MemberExpression") } - }) + }), + + validate(parent, key) { + if (!process.env.BABEL_TYPES_8_BREAKING) return; + const match = /(\w+)\[(\d+)\]/.exec(key); + if (!match) throw new Error("Internal Babel error: malformed key."); + const [, listKey, index] = match; + + if (parent[listKey].length > index + 1) { + throw new TypeError(`RestElement must be last element of ${listKey}`); + } + } + }); (0, _utils.default)("ReturnStatement", { visitor: ["argument"], @@ -37777,7 +39266,13 @@ exports.patternLikeCommon = patternLikeCommon; aliases: ["Statement"], fields: { block: { - validate: (0, _utils.assertNodeType)("BlockStatement") + validate: (0, _utils.chain)((0, _utils.assertNodeType)("BlockStatement"), function (node) { + if (!process.env.BABEL_TYPES_8_BREAKING) return; + + if (!node.handler && !node.finalizer) { + throw new TypeError("TryStatement expects either a handler or finalizer, or both"); + } + }) }, handler: { optional: true, @@ -37812,7 +39307,7 @@ exports.patternLikeCommon = patternLikeCommon; default: false }, argument: { - validate: (0, _utils.assertNodeType)("Expression") + validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("Expression") : (0, _utils.assertNodeType)("Identifier", "MemberExpression") }, operator: { validate: (0, _utils.assertOneOf)(..._constants.UPDATE_OPERATORS) @@ -37831,18 +39326,41 @@ exports.patternLikeCommon = patternLikeCommon; optional: true }, kind: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("string"), (0, _utils.assertOneOf)("var", "let", "const")) + validate: (0, _utils.assertOneOf)("var", "let", "const") }, declarations: { validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("VariableDeclarator"))) } + }, + + validate(parent, key, node) { + if (!process.env.BABEL_TYPES_8_BREAKING) return; + if (!(0, _is.default)("ForXStatement", parent, { + left: node + })) return; + + if (node.declarations.length !== 1) { + throw new TypeError(`Exactly one VariableDeclarator is required in the VariableDeclaration of a ${parent.type}`); + } } + }); (0, _utils.default)("VariableDeclarator", { visitor: ["id", "init"], fields: { id: { - validate: (0, _utils.assertNodeType)("LVal") + validate: function () { + if (!process.env.BABEL_TYPES_8_BREAKING) { + return (0, _utils.assertNodeType)("LVal"); + } + + const normal = (0, _utils.assertNodeType)("Identifier", "ArrayPattern", "ObjectPattern"); + const without = (0, _utils.assertNodeType)("Identifier"); + return function (node, key, val) { + const validator = node.init ? normal : without; + validator(node, key, val); + }; + }() }, definite: { optional: true, @@ -37862,7 +39380,7 @@ exports.patternLikeCommon = patternLikeCommon; validate: (0, _utils.assertNodeType)("Expression") }, body: { - validate: (0, _utils.assertNodeType)("BlockStatement", "Statement") + validate: (0, _utils.assertNodeType)("Statement") } } }); @@ -37874,11 +39392,13 @@ exports.patternLikeCommon = patternLikeCommon; validate: (0, _utils.assertNodeType)("Expression") }, body: { - validate: (0, _utils.assertNodeType)("BlockStatement", "Statement") + validate: (0, _utils.assertNodeType)("Statement") } } }); -},{"../constants":133,"../validators/isValidIdentifier":184,"./utils":154}],146:[function(require,module,exports){ +}).call(this,require('_process')) +},{"../constants":138,"../validators/is":176,"./utils":159,"_process":433,"esutils":218}],151:[function(require,module,exports){ +(function (process){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -37890,7 +39410,13 @@ var _utils = _interopRequireWildcard(require("./utils")); var _core = require("./core"); -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +var _is = _interopRequireDefault(require("../validators/is")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } (0, _utils.default)("AssignmentPattern", { visitor: ["left", "right", "decorators"], @@ -37898,13 +39424,14 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; aliases: ["Pattern", "PatternLike", "LVal"], fields: Object.assign({}, _core.patternLikeCommon, { left: { - validate: (0, _utils.assertNodeType)("Identifier", "ObjectPattern", "ArrayPattern") + validate: (0, _utils.assertNodeType)("Identifier", "ObjectPattern", "ArrayPattern", "MemberExpression") }, right: { validate: (0, _utils.assertNodeType)("Expression") }, decorators: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))) + validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), + optional: true } }) }); @@ -37914,10 +39441,11 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; aliases: ["Pattern", "PatternLike", "LVal"], fields: Object.assign({}, _core.patternLikeCommon, { elements: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("PatternLike"))) + validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeOrValueType)("null", "PatternLike"))) }, decorators: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))) + validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), + optional: true } }) }); @@ -37925,7 +39453,7 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; builder: ["params", "body", "async"], visitor: ["params", "body", "returnType", "typeParameters"], aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Expression", "Pureish"], - fields: Object.assign({}, _core.functionCommon, _core.functionTypeAnnotationCommon, { + fields: Object.assign({}, _core.functionCommon, {}, _core.functionTypeAnnotationCommon, { expression: { validate: (0, _utils.assertValueType)("boolean") }, @@ -37942,57 +39470,18 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } } }); -const classCommon = { - typeParameters: { - validate: (0, _utils.assertNodeType)("TypeParameterDeclaration", "TSTypeParameterDeclaration", "Noop"), - optional: true - }, - body: { - validate: (0, _utils.assertNodeType)("ClassBody") - }, - superClass: { - optional: true, - validate: (0, _utils.assertNodeType)("Expression") - }, - superTypeParameters: { - validate: (0, _utils.assertNodeType)("TypeParameterInstantiation", "TSTypeParameterInstantiation"), - optional: true - }, - implements: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TSExpressionWithTypeArguments", "ClassImplements"))), - optional: true - } -}; -(0, _utils.default)("ClassDeclaration", { +(0, _utils.default)("ClassExpression", { builder: ["id", "superClass", "body", "decorators"], visitor: ["id", "body", "superClass", "mixins", "typeParameters", "superTypeParameters", "implements", "decorators"], - aliases: ["Scopable", "Class", "Statement", "Declaration", "Pureish"], - fields: Object.assign({}, classCommon, { - declare: { - validate: (0, _utils.assertValueType)("boolean"), - optional: true - }, - abstract: { - validate: (0, _utils.assertValueType)("boolean"), - optional: true - }, + aliases: ["Scopable", "Class", "Expression", "Pureish"], + fields: { id: { validate: (0, _utils.assertNodeType)("Identifier"), optional: true }, - decorators: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), + typeParameters: { + validate: (0, _utils.assertNodeType)("TypeParameterDeclaration", "TSTypeParameterDeclaration", "Noop"), optional: true - } - }) -}); -(0, _utils.default)("ClassExpression", { - inherits: "ClassDeclaration", - aliases: ["Scopable", "Class", "Expression", "Pureish"], - fields: Object.assign({}, classCommon, { - id: { - optional: true, - validate: (0, _utils.assertNodeType)("Identifier") }, body: { validate: (0, _utils.assertNodeType)("ClassBody") @@ -38001,11 +39490,43 @@ const classCommon = { optional: true, validate: (0, _utils.assertNodeType)("Expression") }, + superTypeParameters: { + validate: (0, _utils.assertNodeType)("TypeParameterInstantiation", "TSTypeParameterInstantiation"), + optional: true + }, + implements: { + validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TSExpressionWithTypeArguments", "ClassImplements"))), + optional: true + }, decorators: { validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), optional: true } - }) + } +}); +(0, _utils.default)("ClassDeclaration", { + inherits: "ClassExpression", + aliases: ["Scopable", "Class", "Statement", "Declaration", "Pureish"], + fields: { + declare: { + validate: (0, _utils.assertValueType)("boolean"), + optional: true + }, + abstract: { + validate: (0, _utils.assertValueType)("boolean"), + optional: true + } + }, + validate: function () { + const identifier = (0, _utils.assertNodeType)("Identifier"); + return function (parent, key, node) { + if (!process.env.BABEL_TYPES_8_BREAKING) return; + + if (!(0, _is.default)("ExportDefaultDeclaration", parent)) { + identifier(node, "id", node.id); + } + }; + }() }); (0, _utils.default)("ExportAllDeclaration", { visitor: ["source"], @@ -38030,16 +39551,38 @@ const classCommon = { aliases: ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"], fields: { declaration: { - validate: (0, _utils.assertNodeType)("Declaration"), - optional: true + optional: true, + validate: (0, _utils.chain)((0, _utils.assertNodeType)("Declaration"), function (node, key, val) { + if (!process.env.BABEL_TYPES_8_BREAKING) return; + + if (val && node.specifiers.length) { + throw new TypeError("Only declaration or specifiers is allowed on ExportNamedDeclaration"); + } + }, function (node, key, val) { + if (!process.env.BABEL_TYPES_8_BREAKING) return; + + if (val && node.source) { + throw new TypeError("Cannot export a declaration from a source"); + } + }) }, specifiers: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ExportSpecifier", "ExportDefaultSpecifier", "ExportNamespaceSpecifier"))) + default: [], + validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)(function () { + const sourced = (0, _utils.assertNodeType)("ExportSpecifier", "ExportDefaultSpecifier", "ExportNamespaceSpecifier"); + const sourceless = (0, _utils.assertNodeType)("ExportSpecifier"); + if (!process.env.BABEL_TYPES_8_BREAKING) return sourced; + return function (node, key, val) { + const validator = node.source ? sourced : sourceless; + validator(node, key, val); + }; + }())) }, source: { validate: (0, _utils.assertNodeType)("StringLiteral"), optional: true - } + }, + exportKind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("type", "value")) } }); (0, _utils.default)("ExportSpecifier", { @@ -38056,10 +39599,25 @@ const classCommon = { }); (0, _utils.default)("ForOfStatement", { visitor: ["left", "right", "body"], + builder: ["left", "right", "body", "await"], aliases: ["Scopable", "Statement", "For", "BlockParent", "Loop", "ForXStatement"], fields: { left: { - validate: (0, _utils.assertNodeType)("VariableDeclaration", "LVal") + validate: function () { + if (!process.env.BABEL_TYPES_8_BREAKING) { + return (0, _utils.assertNodeType)("VariableDeclaration", "LVal"); + } + + const declaration = (0, _utils.assertNodeType)("VariableDeclaration"); + const lval = (0, _utils.assertNodeType)("Identifier", "MemberExpression", "ArrayPattern", "ObjectPattern"); + return function (node, key, val) { + if ((0, _is.default)("VariableDeclaration", val)) { + declaration(node, key, val); + } else { + lval(node, key, val); + } + }; + }() }, right: { validate: (0, _utils.assertNodeType)("Expression") @@ -38068,8 +39626,7 @@ const classCommon = { validate: (0, _utils.assertNodeType)("Statement") }, await: { - default: false, - validate: (0, _utils.assertValueType)("boolean") + default: false } } }); @@ -38128,7 +39685,30 @@ const classCommon = { aliases: ["Expression"], fields: { meta: { - validate: (0, _utils.assertNodeType)("Identifier") + validate: (0, _utils.chain)((0, _utils.assertNodeType)("Identifier"), function (node, key, val) { + if (!process.env.BABEL_TYPES_8_BREAKING) return; + let property; + + switch (val.name) { + case "function": + property = "sent"; + break; + + case "new": + property = "target"; + break; + + case "import": + property = "meta"; + break; + } + + if (!(0, _is.default)("Identifier", node.property, { + name: property + })) { + throw new TypeError("Unrecognised MetaProperty"); + } + }) }, property: { validate: (0, _utils.assertNodeType)("Identifier") @@ -38141,16 +39721,14 @@ const classMethodOrPropertyCommon = { optional: true }, accessibility: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("string"), (0, _utils.assertOneOf)("public", "private", "protected")), + validate: (0, _utils.assertOneOf)("public", "private", "protected"), optional: true }, static: { - validate: (0, _utils.assertValueType)("boolean"), - optional: true + default: false }, computed: { - default: false, - validate: (0, _utils.assertValueType)("boolean") + default: false }, optional: { validate: (0, _utils.assertValueType)("boolean"), @@ -38168,9 +39746,9 @@ const classMethodOrPropertyCommon = { } }; exports.classMethodOrPropertyCommon = classMethodOrPropertyCommon; -const classMethodOrDeclareMethodCommon = Object.assign({}, _core.functionCommon, classMethodOrPropertyCommon, { +const classMethodOrDeclareMethodCommon = Object.assign({}, _core.functionCommon, {}, classMethodOrPropertyCommon, { kind: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("string"), (0, _utils.assertOneOf)("get", "set", "method", "constructor")), + validate: (0, _utils.assertOneOf)("get", "set", "method", "constructor"), default: "method" }, access: { @@ -38185,9 +39763,9 @@ const classMethodOrDeclareMethodCommon = Object.assign({}, _core.functionCommon, exports.classMethodOrDeclareMethodCommon = classMethodOrDeclareMethodCommon; (0, _utils.default)("ClassMethod", { aliases: ["Function", "Scopable", "BlockParent", "FunctionParent", "Method"], - builder: ["kind", "key", "params", "body", "computed", "static"], + builder: ["kind", "key", "params", "body", "computed", "static", "generator", "async"], visitor: ["key", "params", "body", "decorators", "returnType", "typeParameters"], - fields: Object.assign({}, classMethodOrDeclareMethodCommon, _core.functionTypeAnnotationCommon, { + fields: Object.assign({}, classMethodOrDeclareMethodCommon, {}, _core.functionTypeAnnotationCommon, { body: { validate: (0, _utils.assertNodeType)("BlockStatement") } @@ -38235,9 +39813,18 @@ exports.classMethodOrDeclareMethodCommon = classMethodOrDeclareMethodCommon; (0, _utils.default)("TemplateElement", { builder: ["value", "tail"], fields: { - value: {}, + value: { + validate: (0, _utils.assertShape)({ + raw: { + validate: (0, _utils.assertValueType)("string") + }, + cooked: { + validate: (0, _utils.assertValueType)("string"), + optional: true + } + }) + }, tail: { - validate: (0, _utils.assertValueType)("boolean"), default: false } } @@ -38250,7 +39837,11 @@ exports.classMethodOrDeclareMethodCommon = classMethodOrDeclareMethodCommon; validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TemplateElement"))) }, expressions: { - validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression"))) + validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression")), function (node, key, val) { + if (node.quasis.length !== val.length + 1) { + throw new TypeError(`Number of ${node.type} quasis should be exactly one more than the number of expressions.\nExpected ${val.length + 1} quasis but got ${node.quasis.length}`); + } + }) } } }); @@ -38260,7 +39851,13 @@ exports.classMethodOrDeclareMethodCommon = classMethodOrDeclareMethodCommon; aliases: ["Expression", "Terminatorless"], fields: { delegate: { - validate: (0, _utils.assertValueType)("boolean"), + validate: (0, _utils.chain)((0, _utils.assertValueType)("boolean"), function (node, key, val) { + if (!process.env.BABEL_TYPES_8_BREAKING) return; + + if (val && !node.argument) { + throw new TypeError("Property delegate of YieldExpression cannot be true if there is no argument"); + } + }), default: false }, argument: { @@ -38269,14 +39866,18 @@ exports.classMethodOrDeclareMethodCommon = classMethodOrDeclareMethodCommon; } } }); -},{"./core":145,"./utils":154}],147:[function(require,module,exports){ +}).call(this,require('_process')) +},{"../validators/is":176,"./core":150,"./utils":159,"_process":433}],152:[function(require,module,exports){ +(function (process){ "use strict"; var _utils = _interopRequireWildcard(require("./utils")); var _es = require("./es2015"); -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } (0, _utils.default)("ArgumentPlaceholder", {}); (0, _utils.default)("AwaitExpression", { @@ -38292,11 +39893,18 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; (0, _utils.default)("BindExpression", { visitor: ["object", "callee"], aliases: ["Expression"], - fields: {} + fields: !process.env.BABEL_TYPES_8_BREAKING ? {} : { + object: { + validate: (0, _utils.assertNodeType)("Expression") + }, + callee: { + validate: (0, _utils.assertNodeType)("Expression") + } + } }); (0, _utils.default)("ClassProperty", { visitor: ["key", "value", "typeAnnotation", "decorators"], - builder: ["key", "value", "typeAnnotation", "decorators", "computed"], + builder: ["key", "value", "typeAnnotation", "decorators", "computed", "static"], aliases: ["Property"], fields: Object.assign({}, _es.classMethodOrPropertyCommon, { value: { @@ -38318,6 +39926,10 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; readonly: { validate: (0, _utils.assertValueType)("boolean"), optional: true + }, + declare: { + validate: (0, _utils.assertValueType)("boolean"), + optional: true } }) }); @@ -38393,8 +40005,8 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } }); (0, _utils.default)("ClassPrivateProperty", { - visitor: ["key", "value"], - builder: ["key", "value"], + visitor: ["key", "value", "decorators"], + builder: ["key", "value", "decorators"], aliases: ["Property", "Private"], fields: { key: { @@ -38403,6 +40015,10 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; value: { validate: (0, _utils.assertNodeType)("Expression"), optional: true + }, + decorators: { + validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), + optional: true } } }); @@ -38475,12 +40091,15 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; }, aliases: ["Expression", "Pureish", "Literal", "Immutable"] }); -},{"./es2015":146,"./utils":154}],148:[function(require,module,exports){ +}).call(this,require('_process')) +},{"./es2015":151,"./utils":159,"_process":433}],153:[function(require,module,exports){ "use strict"; var _utils = _interopRequireWildcard(require("./utils")); -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } const defineInterfaceishType = (name, typeParameterType = "TypeParameterDeclaration") => { (0, _utils.default)(name, { @@ -38596,7 +40215,7 @@ defineInterfaceishType("DeclareInterface"); aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"], fields: { source: (0, _utils.validateType)("StringLiteral"), - exportKind: (0, _utils.validateOptional)((0, _utils.assertOneOf)(["type", "value"])) + exportKind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("type", "value")) } }); (0, _utils.default)("DeclaredPredicate", { @@ -38862,7 +40481,77 @@ defineInterfaceishType("InterfaceDeclaration"); (0, _utils.default)("VoidTypeAnnotation", { aliases: ["Flow", "FlowType", "FlowBaseAnnotation"] }); -},{"./utils":154}],149:[function(require,module,exports){ +(0, _utils.default)("EnumDeclaration", { + aliases: ["Declaration"], + visitor: ["id", "body"], + fields: { + id: (0, _utils.validateType)("Identifier"), + body: (0, _utils.validateType)(["EnumBooleanBody", "EnumNumberBody", "EnumStringBody", "EnumSymbolBody"]) + } +}); +(0, _utils.default)("EnumBooleanBody", { + aliases: ["EnumBody"], + visitor: ["members"], + fields: { + explicit: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), + members: (0, _utils.validateArrayOfType)("EnumBooleanMember") + } +}); +(0, _utils.default)("EnumNumberBody", { + aliases: ["EnumBody"], + visitor: ["members"], + fields: { + explicit: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), + members: (0, _utils.validateArrayOfType)("EnumNumberMember") + } +}); +(0, _utils.default)("EnumStringBody", { + aliases: ["EnumBody"], + visitor: ["members"], + fields: { + explicit: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), + members: (0, _utils.validateArrayOfType)(["EnumStringMember", "EnumDefaultedMember"]) + } +}); +(0, _utils.default)("EnumSymbolBody", { + aliases: ["EnumBody"], + visitor: ["members"], + fields: { + members: (0, _utils.validateArrayOfType)("EnumDefaultedMember") + } +}); +(0, _utils.default)("EnumBooleanMember", { + aliases: ["EnumMember"], + visitor: ["id"], + fields: { + id: (0, _utils.validateType)("Identifier"), + init: (0, _utils.validateType)("BooleanLiteral") + } +}); +(0, _utils.default)("EnumNumberMember", { + aliases: ["EnumMember"], + visitor: ["id", "init"], + fields: { + id: (0, _utils.validateType)("Identifier"), + init: (0, _utils.validateType)("NumericLiteral") + } +}); +(0, _utils.default)("EnumStringMember", { + aliases: ["EnumMember"], + visitor: ["id", "init"], + fields: { + id: (0, _utils.validateType)("Identifier"), + init: (0, _utils.validateType)("StringLiteral") + } +}); +(0, _utils.default)("EnumDefaultedMember", { + aliases: ["EnumMember"], + visitor: ["id"], + fields: { + id: (0, _utils.validateType)("Identifier") + } +}); +},{"./utils":159}],154:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -38904,6 +40593,12 @@ Object.defineProperty(exports, "DEPRECATED_KEYS", { return _utils.DEPRECATED_KEYS; } }); +Object.defineProperty(exports, "NODE_PARENT_VALIDATIONS", { + enumerable: true, + get: function () { + return _utils.NODE_PARENT_VALIDATIONS; + } +}); Object.defineProperty(exports, "PLACEHOLDERS", { enumerable: true, get: function () { @@ -38924,15 +40619,7 @@ Object.defineProperty(exports, "PLACEHOLDERS_FLIPPED_ALIAS", { }); exports.TYPES = void 0; -function _toFastProperties() { - const data = _interopRequireDefault(require("to-fast-properties")); - - _toFastProperties = function () { - return data; - }; - - return data; -} +var _toFastProperties = _interopRequireDefault(require("to-fast-properties")); require("./core"); @@ -38954,22 +40641,24 @@ var _placeholders = require("./placeholders"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -(0, _toFastProperties().default)(_utils.VISITOR_KEYS); -(0, _toFastProperties().default)(_utils.ALIAS_KEYS); -(0, _toFastProperties().default)(_utils.FLIPPED_ALIAS_KEYS); -(0, _toFastProperties().default)(_utils.NODE_FIELDS); -(0, _toFastProperties().default)(_utils.BUILDER_KEYS); -(0, _toFastProperties().default)(_utils.DEPRECATED_KEYS); -(0, _toFastProperties().default)(_placeholders.PLACEHOLDERS_ALIAS); -(0, _toFastProperties().default)(_placeholders.PLACEHOLDERS_FLIPPED_ALIAS); +(0, _toFastProperties.default)(_utils.VISITOR_KEYS); +(0, _toFastProperties.default)(_utils.ALIAS_KEYS); +(0, _toFastProperties.default)(_utils.FLIPPED_ALIAS_KEYS); +(0, _toFastProperties.default)(_utils.NODE_FIELDS); +(0, _toFastProperties.default)(_utils.BUILDER_KEYS); +(0, _toFastProperties.default)(_utils.DEPRECATED_KEYS); +(0, _toFastProperties.default)(_placeholders.PLACEHOLDERS_ALIAS); +(0, _toFastProperties.default)(_placeholders.PLACEHOLDERS_FLIPPED_ALIAS); const TYPES = Object.keys(_utils.VISITOR_KEYS).concat(Object.keys(_utils.FLIPPED_ALIAS_KEYS)).concat(Object.keys(_utils.DEPRECATED_KEYS)); exports.TYPES = TYPES; -},{"./core":145,"./es2015":146,"./experimental":147,"./flow":148,"./jsx":150,"./misc":151,"./placeholders":152,"./typescript":153,"./utils":154,"to-fast-properties":501}],150:[function(require,module,exports){ +},{"./core":150,"./es2015":151,"./experimental":152,"./flow":153,"./jsx":155,"./misc":156,"./placeholders":157,"./typescript":158,"./utils":159,"to-fast-properties":519}],155:[function(require,module,exports){ "use strict"; var _utils = _interopRequireWildcard(require("./utils")); -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } (0, _utils.default)("JSXAttribute", { visitor: ["name", "value"], @@ -38989,7 +40678,7 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; aliases: ["JSX", "Immutable"], fields: { name: { - validate: (0, _utils.assertNodeType)("JSXIdentifier", "JSXMemberExpression") + validate: (0, _utils.assertNodeType)("JSXIdentifier", "JSXMemberExpression", "JSXNamespacedName") } } }); @@ -39070,11 +40759,10 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; aliases: ["JSX", "Immutable"], fields: { name: { - validate: (0, _utils.assertNodeType)("JSXIdentifier", "JSXMemberExpression") + validate: (0, _utils.assertNodeType)("JSXIdentifier", "JSXMemberExpression", "JSXNamespacedName") }, selfClosing: { - default: false, - validate: (0, _utils.assertValueType)("boolean") + default: false }, attributes: { validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("JSXAttribute", "JSXSpreadAttribute"))) @@ -39125,14 +40813,16 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; (0, _utils.default)("JSXClosingFragment", { aliases: ["JSX", "Immutable"] }); -},{"./utils":154}],151:[function(require,module,exports){ +},{"./utils":159}],156:[function(require,module,exports){ "use strict"; var _utils = _interopRequireWildcard(require("./utils")); var _placeholders = require("./placeholders"); -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } (0, _utils.default)("Noop", { visitor: [] @@ -39149,7 +40839,15 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } } }); -},{"./placeholders":152,"./utils":154}],152:[function(require,module,exports){ +(0, _utils.default)("V8IntrinsicIdentifier", { + builder: ["name"], + fields: { + name: { + validate: (0, _utils.assertValueType)("string") + } + } +}); +},{"./placeholders":157,"./utils":159}],157:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -39183,7 +40881,7 @@ Object.keys(PLACEHOLDERS_ALIAS).forEach(type => { PLACEHOLDERS_FLIPPED_ALIAS[alias].push(type); }); }); -},{"./utils":154}],153:[function(require,module,exports){ +},{"./utils":159}],158:[function(require,module,exports){ "use strict"; var _utils = _interopRequireWildcard(require("./utils")); @@ -39192,7 +40890,9 @@ var _core = require("./core"); var _es = require("./es2015"); -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } const bool = (0, _utils.assertValueType)("boolean"); const tSFunctionTypeAnnotationCommon = { @@ -39225,11 +40925,11 @@ const tSFunctionTypeAnnotationCommon = { (0, _utils.default)("TSDeclareFunction", { aliases: ["Statement", "Declaration"], visitor: ["id", "typeParameters", "params", "returnType"], - fields: Object.assign({}, _core.functionDeclarationCommon, tSFunctionTypeAnnotationCommon) + fields: Object.assign({}, _core.functionDeclarationCommon, {}, tSFunctionTypeAnnotationCommon) }); (0, _utils.default)("TSDeclareMethod", { visitor: ["decorators", "key", "typeParameters", "params", "returnType"], - fields: Object.assign({}, _es.classMethodOrDeclareMethodCommon, tSFunctionTypeAnnotationCommon) + fields: Object.assign({}, _es.classMethodOrDeclareMethodCommon, {}, tSFunctionTypeAnnotationCommon) }); (0, _utils.default)("TSQualifiedName", { aliases: ["TSEntityName"], @@ -39268,7 +40968,7 @@ const namedTypeElementCommon = { (0, _utils.default)("TSMethodSignature", { aliases: ["TSTypeElement"], visitor: ["key", "typeParameters", "parameters", "typeAnnotation"], - fields: Object.assign({}, signatureDeclarationCommon, namedTypeElementCommon) + fields: Object.assign({}, signatureDeclarationCommon, {}, namedTypeElementCommon) }); (0, _utils.default)("TSIndexSignature", { aliases: ["TSTypeElement"], @@ -39279,7 +40979,7 @@ const namedTypeElementCommon = { typeAnnotation: (0, _utils.validateOptionalType)("TSTypeAnnotation") } }); -const tsKeywordTypes = ["TSAnyKeyword", "TSUnknownKeyword", "TSNumberKeyword", "TSObjectKeyword", "TSBooleanKeyword", "TSStringKeyword", "TSSymbolKeyword", "TSVoidKeyword", "TSUndefinedKeyword", "TSNullKeyword", "TSNeverKeyword"]; +const tsKeywordTypes = ["TSAnyKeyword", "TSBooleanKeyword", "TSBigIntKeyword", "TSNeverKeyword", "TSNullKeyword", "TSNumberKeyword", "TSObjectKeyword", "TSStringKeyword", "TSSymbolKeyword", "TSUndefinedKeyword", "TSUnknownKeyword", "TSVoidKeyword"]; for (const type of tsKeywordTypes) { (0, _utils.default)(type, { @@ -39312,9 +41012,11 @@ const fnOrCtr = { (0, _utils.default)("TSTypePredicate", { aliases: ["TSType"], visitor: ["parameterName", "typeAnnotation"], + builder: ["parameterName", "typeAnnotation", "asserts"], fields: { parameterName: (0, _utils.validateType)(["Identifier", "TSThisType"]), - typeAnnotation: (0, _utils.validateType)("TSTypeAnnotation") + typeAnnotation: (0, _utils.validateOptionalType)("TSTypeAnnotation"), + asserts: (0, _utils.validateOptional)(bool) } }); (0, _utils.default)("TSTypeQuery", { @@ -39505,6 +41207,7 @@ const unionOrIntersection = { } }); (0, _utils.default)("TSModuleBlock", { + aliases: ["Scopable", "Block", "BlockParent"], visitor: ["body"], fields: { body: (0, _utils.validateArrayOfType)("Statement") @@ -39580,6 +41283,7 @@ const unionOrIntersection = { } }); (0, _utils.default)("TSTypeParameter", { + builder: ["constraint", "default", "name"], visitor: ["constraint", "default"], fields: { name: { @@ -39595,7 +41299,8 @@ const unionOrIntersection = { } } }); -},{"./core":145,"./es2015":146,"./utils":154}],154:[function(require,module,exports){ +},{"./core":150,"./es2015":151,"./utils":159}],159:[function(require,module,exports){ +(function (process){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -39614,12 +41319,15 @@ exports.assertOneOf = assertOneOf; exports.assertNodeType = assertNodeType; exports.assertNodeOrValueType = assertNodeOrValueType; exports.assertValueType = assertValueType; +exports.assertShape = assertShape; exports.chain = chain; exports.default = defineType; -exports.DEPRECATED_KEYS = exports.BUILDER_KEYS = exports.NODE_FIELDS = exports.FLIPPED_ALIAS_KEYS = exports.ALIAS_KEYS = exports.VISITOR_KEYS = void 0; +exports.NODE_PARENT_VALIDATIONS = exports.DEPRECATED_KEYS = exports.BUILDER_KEYS = exports.NODE_FIELDS = exports.FLIPPED_ALIAS_KEYS = exports.ALIAS_KEYS = exports.VISITOR_KEYS = void 0; var _is = _interopRequireDefault(require("../validators/is")); +var _validate = require("../validators/validate"); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const VISITOR_KEYS = {}; @@ -39634,14 +41342,14 @@ const BUILDER_KEYS = {}; exports.BUILDER_KEYS = BUILDER_KEYS; const DEPRECATED_KEYS = {}; exports.DEPRECATED_KEYS = DEPRECATED_KEYS; +const NODE_PARENT_VALIDATIONS = {}; +exports.NODE_PARENT_VALIDATIONS = NODE_PARENT_VALIDATIONS; 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; } @@ -39692,7 +41400,10 @@ function assertEach(callback) { if (!Array.isArray(val)) return; for (let i = 0; i < val.length; i++) { - callback(node, `${key}[${i}]`, val[i]); + const subkey = `${key}[${i}]`; + const v = val[i]; + callback(node, subkey, v); + if (process.env.BABEL_TYPES_8_BREAKING) (0, _validate.validateChild)(node, subkey, v); } } @@ -39713,18 +41424,14 @@ function assertOneOf(...values) { function assertNodeType(...types) { function validate(node, key, val) { - let valid = false; - for (const type of types) { if ((0, _is.default)(type, val)) { - valid = true; - break; + (0, _validate.validateChild)(node, key, val); + return; } } - if (!valid) { - throw new TypeError(`Property ${key} of ${node.type} expected node to be of a type ${JSON.stringify(types)} ` + `but instead got ${JSON.stringify(val && val.type)}`); - } + throw new TypeError(`Property ${key} of ${node.type} expected node to be of a type ${JSON.stringify(types)} but instead got ${JSON.stringify(val && val.type)}`); } validate.oneOfNodeTypes = types; @@ -39733,18 +41440,14 @@ function assertNodeType(...types) { function assertNodeOrValueType(...types) { function validate(node, key, val) { - let valid = false; - for (const type of types) { if (getType(val) === type || (0, _is.default)(type, val)) { - valid = true; - break; + (0, _validate.validateChild)(node, key, val); + return; } } - if (!valid) { - throw new TypeError(`Property ${key} of ${node.type} expected node to be of a type ${JSON.stringify(types)} ` + `but instead got ${JSON.stringify(val && val.type)}`); - } + throw new TypeError(`Property ${key} of ${node.type} expected node to be of a type ${JSON.stringify(types)} but instead got ${JSON.stringify(val && val.type)}`); } validate.oneOfNodeOrValueTypes = types; @@ -39764,6 +41467,32 @@ function assertValueType(type) { return validate; } +function assertShape(shape) { + function validate(node, key, val) { + const errors = []; + + for (const property of Object.keys(shape)) { + try { + (0, _validate.validateField)(node, property, val[property], shape[property]); + } catch (error) { + if (error instanceof TypeError) { + errors.push(error.message); + continue; + } + + throw error; + } + } + + if (errors.length) { + throw new TypeError(`Property ${key} of ${node.type} expected to have the following:\n${errors.join("\n")}`); + } + } + + validate.shapeOf = shape; + return validate; +} + function chain(...fns) { function validate(...args) { for (const fn of fns) { @@ -39775,13 +41504,40 @@ function chain(...fns) { return validate; } +const validTypeOpts = ["aliases", "builder", "deprecatedAlias", "fields", "inherits", "visitor", "validate"]; +const validFieldKeys = ["default", "optional", "validate"]; + function defineType(type, opts = {}) { const inherits = opts.inherits && store[opts.inherits] || {}; - const fields = opts.fields || inherits.fields || {}; + let fields = opts.fields; + + if (!fields) { + fields = {}; + + if (inherits.fields) { + const keys = Object.getOwnPropertyNames(inherits.fields); + + for (const key of keys) { + const field = inherits.fields[key]; + fields[key] = { + default: field.default, + optional: field.optional, + validate: field.validate + }; + } + } + } + const visitor = opts.visitor || inherits.visitor || []; const aliases = opts.aliases || inherits.aliases || []; const builder = opts.builder || inherits.builder || opts.visitor || []; + for (const k of Object.keys(opts)) { + if (validTypeOpts.indexOf(k) === -1) { + throw new Error(`Unknown type option "${k}" on ${type}`); + } + } + if (opts.deprecatedAlias) { DEPRECATED_KEYS[opts.deprecatedAlias] = type; } @@ -39793,15 +41549,21 @@ function defineType(type, opts = {}) { for (const key of Object.keys(fields)) { const field = fields[key]; - if (builder.indexOf(key) === -1) { + if (field.default !== undefined && builder.indexOf(key) === -1) { field.optional = true; } if (field.default === undefined) { field.default = null; - } else if (!field.validate) { + } else if (!field.validate && field.default != null) { field.validate = assertValueType(getType(field.default)); } + + for (const k of Object.keys(field)) { + if (validFieldKeys.indexOf(k) === -1) { + throw new Error(`Unknown field key "${k}" on ${type}.${key}`); + } + } } VISITOR_KEYS[type] = opts.visitor = visitor; @@ -39812,11 +41574,17 @@ function defineType(type, opts = {}) { FLIPPED_ALIAS_KEYS[alias] = FLIPPED_ALIAS_KEYS[alias] || []; FLIPPED_ALIAS_KEYS[alias].push(type); }); + + if (opts.validate) { + NODE_PARENT_VALIDATIONS[type] = opts.validate; + } + store[type] = opts; } const store = {}; -},{"../validators/is":171}],155:[function(require,module,exports){ +}).call(this,require('_process')) +},{"../validators/is":176,"../validators/validate":194,"_process":433}],160:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -40396,7 +42164,7 @@ const react = { buildChildren: _buildChildren.default }; exports.react = react; -},{"./asserts/assertNode":114,"./asserts/generated":115,"./builders/flow/createTypeAnnotationBasedOnTypeof":117,"./builders/flow/createUnionTypeAnnotation":118,"./builders/generated":119,"./builders/react/buildChildren":120,"./clone/clone":121,"./clone/cloneDeep":122,"./clone/cloneNode":123,"./clone/cloneWithoutLoc":124,"./comments/addComment":125,"./comments/addComments":126,"./comments/inheritInnerComments":127,"./comments/inheritLeadingComments":128,"./comments/inheritTrailingComments":129,"./comments/inheritsComments":130,"./comments/removeComments":131,"./constants":133,"./constants/generated":132,"./converters/ensureBlock":134,"./converters/toBindingIdentifierName":136,"./converters/toBlock":137,"./converters/toComputedKey":138,"./converters/toExpression":139,"./converters/toIdentifier":140,"./converters/toKeyAlias":141,"./converters/toSequenceExpression":142,"./converters/toStatement":143,"./converters/valueToNode":144,"./definitions":149,"./modifications/appendToMemberExpression":156,"./modifications/flow/removeTypeDuplicates":157,"./modifications/inherits":158,"./modifications/prependToMemberExpression":159,"./modifications/removeProperties":160,"./modifications/removePropertiesDeep":161,"./retrievers/getBindingIdentifiers":162,"./retrievers/getOuterBindingIdentifiers":163,"./traverse/traverse":164,"./traverse/traverseFast":165,"./utils/shallowEqual":168,"./validators/buildMatchMemberExpression":169,"./validators/generated":170,"./validators/is":171,"./validators/isBinding":172,"./validators/isBlockScoped":173,"./validators/isImmutable":174,"./validators/isLet":175,"./validators/isNode":176,"./validators/isNodesEquivalent":177,"./validators/isPlaceholderType":178,"./validators/isReferenced":179,"./validators/isScope":180,"./validators/isSpecifierDefault":181,"./validators/isType":182,"./validators/isValidES3Identifier":183,"./validators/isValidIdentifier":184,"./validators/isVar":185,"./validators/matchesPattern":186,"./validators/react/isCompatTag":187,"./validators/react/isReactComponent":188,"./validators/validate":189}],156:[function(require,module,exports){ +},{"./asserts/assertNode":119,"./asserts/generated":120,"./builders/flow/createTypeAnnotationBasedOnTypeof":122,"./builders/flow/createUnionTypeAnnotation":123,"./builders/generated":124,"./builders/react/buildChildren":125,"./clone/clone":126,"./clone/cloneDeep":127,"./clone/cloneNode":128,"./clone/cloneWithoutLoc":129,"./comments/addComment":130,"./comments/addComments":131,"./comments/inheritInnerComments":132,"./comments/inheritLeadingComments":133,"./comments/inheritTrailingComments":134,"./comments/inheritsComments":135,"./comments/removeComments":136,"./constants":138,"./constants/generated":137,"./converters/ensureBlock":139,"./converters/toBindingIdentifierName":141,"./converters/toBlock":142,"./converters/toComputedKey":143,"./converters/toExpression":144,"./converters/toIdentifier":145,"./converters/toKeyAlias":146,"./converters/toSequenceExpression":147,"./converters/toStatement":148,"./converters/valueToNode":149,"./definitions":154,"./modifications/appendToMemberExpression":161,"./modifications/flow/removeTypeDuplicates":162,"./modifications/inherits":163,"./modifications/prependToMemberExpression":164,"./modifications/removeProperties":165,"./modifications/removePropertiesDeep":166,"./retrievers/getBindingIdentifiers":167,"./retrievers/getOuterBindingIdentifiers":168,"./traverse/traverse":169,"./traverse/traverseFast":170,"./utils/shallowEqual":173,"./validators/buildMatchMemberExpression":174,"./validators/generated":175,"./validators/is":176,"./validators/isBinding":177,"./validators/isBlockScoped":178,"./validators/isImmutable":179,"./validators/isLet":180,"./validators/isNode":181,"./validators/isNodesEquivalent":182,"./validators/isPlaceholderType":183,"./validators/isReferenced":184,"./validators/isScope":185,"./validators/isSpecifierDefault":186,"./validators/isType":187,"./validators/isValidES3Identifier":188,"./validators/isValidIdentifier":189,"./validators/isVar":190,"./validators/matchesPattern":191,"./validators/react/isCompatTag":192,"./validators/react/isReactComponent":193,"./validators/validate":194}],161:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -40412,7 +42180,7 @@ function appendToMemberExpression(member, append, computed = false) { member.computed = !!computed; return member; } -},{"../builders/generated":119}],157:[function(require,module,exports){ +},{"../builders/generated":124}],162:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -40487,7 +42255,7 @@ function removeTypeDuplicates(nodes) { return types; } -},{"../../validators/generated":170}],158:[function(require,module,exports){ +},{"../../validators/generated":175}],163:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -40521,7 +42289,7 @@ function inherits(child, parent) { (0, _inheritsComments.default)(child, parent); return child; } -},{"../comments/inheritsComments":130,"../constants":133}],159:[function(require,module,exports){ +},{"../comments/inheritsComments":135,"../constants":138}],164:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -40535,7 +42303,7 @@ function prependToMemberExpression(member, prepend) { member.object = (0, _generated.memberExpression)(prepend, member.object); return member; } -},{"../builders/generated":119}],160:[function(require,module,exports){ +},{"../builders/generated":124}],165:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -40566,7 +42334,7 @@ function removeProperties(node, opts = {}) { node[sym] = null; } } -},{"../constants":133}],161:[function(require,module,exports){ +},{"../constants":138}],166:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -40584,7 +42352,7 @@ function removePropertiesDeep(tree, opts) { (0, _traverseFast.default)(tree, _removeProperties.default, opts); return tree; } -},{"../traverse/traverseFast":165,"./removeProperties":160}],162:[function(require,module,exports){ +},{"../traverse/traverseFast":170,"./removeProperties":165}],167:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -40688,7 +42456,7 @@ getBindingIdentifiers.keys = { VariableDeclaration: ["declarations"], VariableDeclarator: ["id"] }; -},{"../validators/generated":170}],163:[function(require,module,exports){ +},{"../validators/generated":175}],168:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -40703,7 +42471,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de function getOuterBindingIdentifiers(node, duplicates) { return (0, _getBindingIdentifiers.default)(node, duplicates, true); } -},{"./getBindingIdentifiers":162}],164:[function(require,module,exports){ +},{"./getBindingIdentifiers":167}],169:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -40759,7 +42527,7 @@ function traverseSimpleImpl(node, enter, exit, state, ancestors) { if (exit) exit(node, ancestors, state); } -},{"../definitions":149}],165:[function(require,module,exports){ +},{"../definitions":154}],170:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -40788,7 +42556,7 @@ function traverseFast(node, enter, opts) { } } } -},{"../definitions":149}],166:[function(require,module,exports){ +},{"../definitions":154}],171:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -40796,24 +42564,16 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = inherit; -function _uniq() { - const data = _interopRequireDefault(require("lodash/uniq")); - - _uniq = function () { - return data; - }; - - return data; -} +var _uniq = _interopRequireDefault(require("lodash/uniq")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function inherit(key, child, parent) { if (child && parent) { - child[key] = (0, _uniq().default)([].concat(child[key], parent[key]).filter(Boolean)); + child[key] = (0, _uniq.default)([].concat(child[key], parent[key]).filter(Boolean)); } } -},{"lodash/uniq":419}],167:[function(require,module,exports){ +},{"lodash/uniq":425}],172:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -40861,7 +42621,7 @@ function cleanJSXElementLiteralChild(child, args) { if (str) args.push((0, _generated.stringLiteral)(str)); } -},{"../../builders/generated":119}],168:[function(require,module,exports){ +},{"../../builders/generated":124}],173:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -40880,7 +42640,7 @@ function shallowEqual(actual, expected) { return true; } -},{}],169:[function(require,module,exports){ +},{}],174:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -40896,7 +42656,7 @@ function buildMatchMemberExpression(match, allowPartial) { const parts = match.split("."); return member => (0, _matchesPattern.default)(member, parts, allowPartial); } -},{"./matchesPattern":186}],170:[function(require,module,exports){ +},{"./matchesPattern":191}],175:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -40957,8 +42717,8 @@ exports.isAssignmentPattern = isAssignmentPattern; exports.isArrayPattern = isArrayPattern; exports.isArrowFunctionExpression = isArrowFunctionExpression; exports.isClassBody = isClassBody; -exports.isClassDeclaration = isClassDeclaration; exports.isClassExpression = isClassExpression; +exports.isClassDeclaration = isClassDeclaration; exports.isExportAllDeclaration = isExportAllDeclaration; exports.isExportDefaultDeclaration = isExportDefaultDeclaration; exports.isExportNamedDeclaration = isExportNamedDeclaration; @@ -41030,6 +42790,15 @@ exports.isTypeParameterInstantiation = isTypeParameterInstantiation; exports.isUnionTypeAnnotation = isUnionTypeAnnotation; exports.isVariance = isVariance; exports.isVoidTypeAnnotation = isVoidTypeAnnotation; +exports.isEnumDeclaration = isEnumDeclaration; +exports.isEnumBooleanBody = isEnumBooleanBody; +exports.isEnumNumberBody = isEnumNumberBody; +exports.isEnumStringBody = isEnumStringBody; +exports.isEnumSymbolBody = isEnumSymbolBody; +exports.isEnumBooleanMember = isEnumBooleanMember; +exports.isEnumNumberMember = isEnumNumberMember; +exports.isEnumStringMember = isEnumStringMember; +exports.isEnumDefaultedMember = isEnumDefaultedMember; exports.isJSXAttribute = isJSXAttribute; exports.isJSXClosingElement = isJSXClosingElement; exports.isJSXElement = isJSXElement; @@ -41047,6 +42816,7 @@ exports.isJSXOpeningFragment = isJSXOpeningFragment; exports.isJSXClosingFragment = isJSXClosingFragment; exports.isNoop = isNoop; exports.isPlaceholder = isPlaceholder; +exports.isV8IntrinsicIdentifier = isV8IntrinsicIdentifier; exports.isArgumentPlaceholder = isArgumentPlaceholder; exports.isAwaitExpression = isAwaitExpression; exports.isBindExpression = isBindExpression; @@ -41075,16 +42845,17 @@ exports.isTSPropertySignature = isTSPropertySignature; exports.isTSMethodSignature = isTSMethodSignature; exports.isTSIndexSignature = isTSIndexSignature; exports.isTSAnyKeyword = isTSAnyKeyword; -exports.isTSUnknownKeyword = isTSUnknownKeyword; +exports.isTSBooleanKeyword = isTSBooleanKeyword; +exports.isTSBigIntKeyword = isTSBigIntKeyword; +exports.isTSNeverKeyword = isTSNeverKeyword; +exports.isTSNullKeyword = isTSNullKeyword; exports.isTSNumberKeyword = isTSNumberKeyword; exports.isTSObjectKeyword = isTSObjectKeyword; -exports.isTSBooleanKeyword = isTSBooleanKeyword; exports.isTSStringKeyword = isTSStringKeyword; exports.isTSSymbolKeyword = isTSSymbolKeyword; -exports.isTSVoidKeyword = isTSVoidKeyword; exports.isTSUndefinedKeyword = isTSUndefinedKeyword; -exports.isTSNullKeyword = isTSNullKeyword; -exports.isTSNeverKeyword = isTSNeverKeyword; +exports.isTSUnknownKeyword = isTSUnknownKeyword; +exports.isTSVoidKeyword = isTSVoidKeyword; exports.isTSThisType = isTSThisType; exports.isTSFunctionType = isTSFunctionType; exports.isTSConstructorType = isTSConstructorType; @@ -41163,6 +42934,8 @@ exports.isFlowType = isFlowType; exports.isFlowBaseAnnotation = isFlowBaseAnnotation; exports.isFlowDeclaration = isFlowDeclaration; exports.isFlowPredicate = isFlowPredicate; +exports.isEnumBody = isEnumBody; +exports.isEnumMember = isEnumMember; exports.isJSX = isJSX; exports.isPrivate = isPrivate; exports.isTSTypeElement = isTSTypeElement; @@ -42001,11 +43774,11 @@ function isClassBody(node, opts) { return false; } -function isClassDeclaration(node, opts) { +function isClassExpression(node, opts) { if (!node) return false; const nodeType = node.type; - if (nodeType === "ClassDeclaration") { + if (nodeType === "ClassExpression") { if (typeof opts === "undefined") { return true; } else { @@ -42016,11 +43789,11 @@ function isClassDeclaration(node, opts) { return false; } -function isClassExpression(node, opts) { +function isClassDeclaration(node, opts) { if (!node) return false; const nodeType = node.type; - if (nodeType === "ClassExpression") { + if (nodeType === "ClassDeclaration") { if (typeof opts === "undefined") { return true; } else { @@ -43096,6 +44869,141 @@ function isVoidTypeAnnotation(node, opts) { return false; } +function isEnumDeclaration(node, opts) { + if (!node) return false; + const nodeType = node.type; + + if (nodeType === "EnumDeclaration") { + if (typeof opts === "undefined") { + return true; + } else { + return (0, _shallowEqual.default)(node, opts); + } + } + + return false; +} + +function isEnumBooleanBody(node, opts) { + if (!node) return false; + const nodeType = node.type; + + if (nodeType === "EnumBooleanBody") { + if (typeof opts === "undefined") { + return true; + } else { + return (0, _shallowEqual.default)(node, opts); + } + } + + return false; +} + +function isEnumNumberBody(node, opts) { + if (!node) return false; + const nodeType = node.type; + + if (nodeType === "EnumNumberBody") { + if (typeof opts === "undefined") { + return true; + } else { + return (0, _shallowEqual.default)(node, opts); + } + } + + return false; +} + +function isEnumStringBody(node, opts) { + if (!node) return false; + const nodeType = node.type; + + if (nodeType === "EnumStringBody") { + if (typeof opts === "undefined") { + return true; + } else { + return (0, _shallowEqual.default)(node, opts); + } + } + + return false; +} + +function isEnumSymbolBody(node, opts) { + if (!node) return false; + const nodeType = node.type; + + if (nodeType === "EnumSymbolBody") { + if (typeof opts === "undefined") { + return true; + } else { + return (0, _shallowEqual.default)(node, opts); + } + } + + return false; +} + +function isEnumBooleanMember(node, opts) { + if (!node) return false; + const nodeType = node.type; + + if (nodeType === "EnumBooleanMember") { + if (typeof opts === "undefined") { + return true; + } else { + return (0, _shallowEqual.default)(node, opts); + } + } + + return false; +} + +function isEnumNumberMember(node, opts) { + if (!node) return false; + const nodeType = node.type; + + if (nodeType === "EnumNumberMember") { + if (typeof opts === "undefined") { + return true; + } else { + return (0, _shallowEqual.default)(node, opts); + } + } + + return false; +} + +function isEnumStringMember(node, opts) { + if (!node) return false; + const nodeType = node.type; + + if (nodeType === "EnumStringMember") { + if (typeof opts === "undefined") { + return true; + } else { + return (0, _shallowEqual.default)(node, opts); + } + } + + return false; +} + +function isEnumDefaultedMember(node, opts) { + if (!node) return false; + const nodeType = node.type; + + if (nodeType === "EnumDefaultedMember") { + if (typeof opts === "undefined") { + return true; + } else { + return (0, _shallowEqual.default)(node, opts); + } + } + + return false; +} + function isJSXAttribute(node, opts) { if (!node) return false; const nodeType = node.type; @@ -43351,6 +45259,21 @@ function isPlaceholder(node, opts) { return false; } +function isV8IntrinsicIdentifier(node, opts) { + if (!node) return false; + const nodeType = node.type; + + if (nodeType === "V8IntrinsicIdentifier") { + if (typeof opts === "undefined") { + return true; + } else { + return (0, _shallowEqual.default)(node, opts); + } + } + + return false; +} + function isArgumentPlaceholder(node, opts) { if (!node) return false; const nodeType = node.type; @@ -43771,11 +45694,11 @@ function isTSAnyKeyword(node, opts) { return false; } -function isTSUnknownKeyword(node, opts) { +function isTSBooleanKeyword(node, opts) { if (!node) return false; const nodeType = node.type; - if (nodeType === "TSUnknownKeyword") { + if (nodeType === "TSBooleanKeyword") { if (typeof opts === "undefined") { return true; } else { @@ -43786,11 +45709,11 @@ function isTSUnknownKeyword(node, opts) { return false; } -function isTSNumberKeyword(node, opts) { +function isTSBigIntKeyword(node, opts) { if (!node) return false; const nodeType = node.type; - if (nodeType === "TSNumberKeyword") { + if (nodeType === "TSBigIntKeyword") { if (typeof opts === "undefined") { return true; } else { @@ -43801,11 +45724,11 @@ function isTSNumberKeyword(node, opts) { return false; } -function isTSObjectKeyword(node, opts) { +function isTSNeverKeyword(node, opts) { if (!node) return false; const nodeType = node.type; - if (nodeType === "TSObjectKeyword") { + if (nodeType === "TSNeverKeyword") { if (typeof opts === "undefined") { return true; } else { @@ -43816,11 +45739,41 @@ function isTSObjectKeyword(node, opts) { return false; } -function isTSBooleanKeyword(node, opts) { +function isTSNullKeyword(node, opts) { if (!node) return false; const nodeType = node.type; - if (nodeType === "TSBooleanKeyword") { + if (nodeType === "TSNullKeyword") { + if (typeof opts === "undefined") { + return true; + } else { + return (0, _shallowEqual.default)(node, opts); + } + } + + return false; +} + +function isTSNumberKeyword(node, opts) { + if (!node) return false; + const nodeType = node.type; + + if (nodeType === "TSNumberKeyword") { + if (typeof opts === "undefined") { + return true; + } else { + return (0, _shallowEqual.default)(node, opts); + } + } + + return false; +} + +function isTSObjectKeyword(node, opts) { + if (!node) return false; + const nodeType = node.type; + + if (nodeType === "TSObjectKeyword") { if (typeof opts === "undefined") { return true; } else { @@ -43861,21 +45814,6 @@ function isTSSymbolKeyword(node, opts) { return false; } -function isTSVoidKeyword(node, opts) { - if (!node) return false; - const nodeType = node.type; - - if (nodeType === "TSVoidKeyword") { - if (typeof opts === "undefined") { - return true; - } else { - return (0, _shallowEqual.default)(node, opts); - } - } - - return false; -} - function isTSUndefinedKeyword(node, opts) { if (!node) return false; const nodeType = node.type; @@ -43891,11 +45829,11 @@ function isTSUndefinedKeyword(node, opts) { return false; } -function isTSNullKeyword(node, opts) { +function isTSUnknownKeyword(node, opts) { if (!node) return false; const nodeType = node.type; - if (nodeType === "TSNullKeyword") { + if (nodeType === "TSUnknownKeyword") { if (typeof opts === "undefined") { return true; } else { @@ -43906,11 +45844,11 @@ function isTSNullKeyword(node, opts) { return false; } -function isTSNeverKeyword(node, opts) { +function isTSVoidKeyword(node, opts) { if (!node) return false; const nodeType = node.type; - if (nodeType === "TSNeverKeyword") { + if (nodeType === "TSVoidKeyword") { if (typeof opts === "undefined") { return true; } else { @@ -44555,7 +46493,7 @@ function isScopable(node, opts) { if (!node) return false; const nodeType = node.type; - if (nodeType === "Scopable" || "BlockStatement" === nodeType || "CatchClause" === nodeType || "DoWhileStatement" === nodeType || "ForInStatement" === nodeType || "ForStatement" === nodeType || "FunctionDeclaration" === nodeType || "FunctionExpression" === nodeType || "Program" === nodeType || "ObjectMethod" === nodeType || "SwitchStatement" === nodeType || "WhileStatement" === nodeType || "ArrowFunctionExpression" === nodeType || "ClassDeclaration" === nodeType || "ClassExpression" === nodeType || "ForOfStatement" === nodeType || "ClassMethod" === nodeType || "ClassPrivateMethod" === nodeType || nodeType === "Placeholder" && "BlockStatement" === node.expectedNode) { + if (nodeType === "Scopable" || "BlockStatement" === nodeType || "CatchClause" === nodeType || "DoWhileStatement" === nodeType || "ForInStatement" === nodeType || "ForStatement" === nodeType || "FunctionDeclaration" === nodeType || "FunctionExpression" === nodeType || "Program" === nodeType || "ObjectMethod" === nodeType || "SwitchStatement" === nodeType || "WhileStatement" === nodeType || "ArrowFunctionExpression" === nodeType || "ClassExpression" === nodeType || "ClassDeclaration" === nodeType || "ForOfStatement" === nodeType || "ClassMethod" === nodeType || "ClassPrivateMethod" === nodeType || "TSModuleBlock" === nodeType || nodeType === "Placeholder" && "BlockStatement" === node.expectedNode) { if (typeof opts === "undefined") { return true; } else { @@ -44570,7 +46508,7 @@ function isBlockParent(node, opts) { if (!node) return false; const nodeType = node.type; - if (nodeType === "BlockParent" || "BlockStatement" === nodeType || "CatchClause" === nodeType || "DoWhileStatement" === nodeType || "ForInStatement" === nodeType || "ForStatement" === nodeType || "FunctionDeclaration" === nodeType || "FunctionExpression" === nodeType || "Program" === nodeType || "ObjectMethod" === nodeType || "SwitchStatement" === nodeType || "WhileStatement" === nodeType || "ArrowFunctionExpression" === nodeType || "ForOfStatement" === nodeType || "ClassMethod" === nodeType || "ClassPrivateMethod" === nodeType || nodeType === "Placeholder" && "BlockStatement" === node.expectedNode) { + if (nodeType === "BlockParent" || "BlockStatement" === nodeType || "CatchClause" === nodeType || "DoWhileStatement" === nodeType || "ForInStatement" === nodeType || "ForStatement" === nodeType || "FunctionDeclaration" === nodeType || "FunctionExpression" === nodeType || "Program" === nodeType || "ObjectMethod" === nodeType || "SwitchStatement" === nodeType || "WhileStatement" === nodeType || "ArrowFunctionExpression" === nodeType || "ForOfStatement" === nodeType || "ClassMethod" === nodeType || "ClassPrivateMethod" === nodeType || "TSModuleBlock" === nodeType || nodeType === "Placeholder" && "BlockStatement" === node.expectedNode) { if (typeof opts === "undefined") { return true; } else { @@ -44585,7 +46523,7 @@ function isBlock(node, opts) { if (!node) return false; const nodeType = node.type; - if (nodeType === "Block" || "BlockStatement" === nodeType || "Program" === nodeType || nodeType === "Placeholder" && "BlockStatement" === node.expectedNode) { + if (nodeType === "Block" || "BlockStatement" === nodeType || "Program" === nodeType || "TSModuleBlock" === nodeType || nodeType === "Placeholder" && "BlockStatement" === node.expectedNode) { if (typeof opts === "undefined") { return true; } else { @@ -44765,7 +46703,7 @@ function isPureish(node, opts) { if (!node) return false; const nodeType = node.type; - if (nodeType === "Pureish" || "FunctionDeclaration" === nodeType || "FunctionExpression" === nodeType || "StringLiteral" === nodeType || "NumericLiteral" === nodeType || "NullLiteral" === nodeType || "BooleanLiteral" === nodeType || "ArrowFunctionExpression" === nodeType || "ClassDeclaration" === nodeType || "ClassExpression" === nodeType || "BigIntLiteral" === nodeType || nodeType === "Placeholder" && "StringLiteral" === node.expectedNode) { + if (nodeType === "Pureish" || "FunctionDeclaration" === nodeType || "FunctionExpression" === nodeType || "StringLiteral" === nodeType || "NumericLiteral" === nodeType || "NullLiteral" === nodeType || "BooleanLiteral" === nodeType || "ArrowFunctionExpression" === nodeType || "ClassExpression" === nodeType || "ClassDeclaration" === nodeType || "BigIntLiteral" === nodeType || nodeType === "Placeholder" && "StringLiteral" === node.expectedNode) { if (typeof opts === "undefined") { return true; } else { @@ -44780,7 +46718,7 @@ function isDeclaration(node, opts) { if (!node) return false; const nodeType = node.type; - if (nodeType === "Declaration" || "FunctionDeclaration" === nodeType || "VariableDeclaration" === nodeType || "ClassDeclaration" === nodeType || "ExportAllDeclaration" === nodeType || "ExportDefaultDeclaration" === nodeType || "ExportNamedDeclaration" === nodeType || "ImportDeclaration" === nodeType || "DeclareClass" === nodeType || "DeclareFunction" === nodeType || "DeclareInterface" === nodeType || "DeclareModule" === nodeType || "DeclareModuleExports" === nodeType || "DeclareTypeAlias" === nodeType || "DeclareOpaqueType" === nodeType || "DeclareVariable" === nodeType || "DeclareExportDeclaration" === nodeType || "DeclareExportAllDeclaration" === nodeType || "InterfaceDeclaration" === nodeType || "OpaqueType" === nodeType || "TypeAlias" === nodeType || "TSDeclareFunction" === nodeType || "TSInterfaceDeclaration" === nodeType || "TSTypeAliasDeclaration" === nodeType || "TSEnumDeclaration" === nodeType || "TSModuleDeclaration" === nodeType || nodeType === "Placeholder" && "Declaration" === node.expectedNode) { + if (nodeType === "Declaration" || "FunctionDeclaration" === nodeType || "VariableDeclaration" === nodeType || "ClassDeclaration" === nodeType || "ExportAllDeclaration" === nodeType || "ExportDefaultDeclaration" === nodeType || "ExportNamedDeclaration" === nodeType || "ImportDeclaration" === nodeType || "DeclareClass" === nodeType || "DeclareFunction" === nodeType || "DeclareInterface" === nodeType || "DeclareModule" === nodeType || "DeclareModuleExports" === nodeType || "DeclareTypeAlias" === nodeType || "DeclareOpaqueType" === nodeType || "DeclareVariable" === nodeType || "DeclareExportDeclaration" === nodeType || "DeclareExportAllDeclaration" === nodeType || "InterfaceDeclaration" === nodeType || "OpaqueType" === nodeType || "TypeAlias" === nodeType || "EnumDeclaration" === nodeType || "TSDeclareFunction" === nodeType || "TSInterfaceDeclaration" === nodeType || "TSTypeAliasDeclaration" === nodeType || "TSEnumDeclaration" === nodeType || "TSModuleDeclaration" === nodeType || nodeType === "Placeholder" && "Declaration" === node.expectedNode) { if (typeof opts === "undefined") { return true; } else { @@ -44960,7 +46898,7 @@ function isClass(node, opts) { if (!node) return false; const nodeType = node.type; - if (nodeType === "Class" || "ClassDeclaration" === nodeType || "ClassExpression" === nodeType) { + if (nodeType === "Class" || "ClassExpression" === nodeType || "ClassDeclaration" === nodeType) { if (typeof opts === "undefined") { return true; } else { @@ -45091,6 +47029,36 @@ function isFlowPredicate(node, opts) { return false; } +function isEnumBody(node, opts) { + if (!node) return false; + const nodeType = node.type; + + if (nodeType === "EnumBody" || "EnumBooleanBody" === nodeType || "EnumNumberBody" === nodeType || "EnumStringBody" === nodeType || "EnumSymbolBody" === nodeType) { + if (typeof opts === "undefined") { + return true; + } else { + return (0, _shallowEqual.default)(node, opts); + } + } + + return false; +} + +function isEnumMember(node, opts) { + if (!node) return false; + const nodeType = node.type; + + if (nodeType === "EnumMember" || "EnumBooleanMember" === nodeType || "EnumNumberMember" === nodeType || "EnumStringMember" === nodeType || "EnumDefaultedMember" === nodeType) { + if (typeof opts === "undefined") { + return true; + } else { + return (0, _shallowEqual.default)(node, opts); + } + } + + return false; +} + function isJSX(node, opts) { if (!node) return false; const nodeType = node.type; @@ -45140,7 +47108,7 @@ function isTSType(node, opts) { if (!node) return false; const nodeType = node.type; - if (nodeType === "TSType" || "TSAnyKeyword" === nodeType || "TSUnknownKeyword" === nodeType || "TSNumberKeyword" === nodeType || "TSObjectKeyword" === nodeType || "TSBooleanKeyword" === nodeType || "TSStringKeyword" === nodeType || "TSSymbolKeyword" === nodeType || "TSVoidKeyword" === nodeType || "TSUndefinedKeyword" === nodeType || "TSNullKeyword" === nodeType || "TSNeverKeyword" === nodeType || "TSThisType" === nodeType || "TSFunctionType" === nodeType || "TSConstructorType" === nodeType || "TSTypeReference" === nodeType || "TSTypePredicate" === nodeType || "TSTypeQuery" === nodeType || "TSTypeLiteral" === nodeType || "TSArrayType" === nodeType || "TSTupleType" === nodeType || "TSOptionalType" === nodeType || "TSRestType" === nodeType || "TSUnionType" === nodeType || "TSIntersectionType" === nodeType || "TSConditionalType" === nodeType || "TSInferType" === nodeType || "TSParenthesizedType" === nodeType || "TSTypeOperator" === nodeType || "TSIndexedAccessType" === nodeType || "TSMappedType" === nodeType || "TSLiteralType" === nodeType || "TSExpressionWithTypeArguments" === nodeType || "TSImportType" === nodeType) { + if (nodeType === "TSType" || "TSAnyKeyword" === nodeType || "TSBooleanKeyword" === nodeType || "TSBigIntKeyword" === nodeType || "TSNeverKeyword" === nodeType || "TSNullKeyword" === nodeType || "TSNumberKeyword" === nodeType || "TSObjectKeyword" === nodeType || "TSStringKeyword" === nodeType || "TSSymbolKeyword" === nodeType || "TSUndefinedKeyword" === nodeType || "TSUnknownKeyword" === nodeType || "TSVoidKeyword" === nodeType || "TSThisType" === nodeType || "TSFunctionType" === nodeType || "TSConstructorType" === nodeType || "TSTypeReference" === nodeType || "TSTypePredicate" === nodeType || "TSTypeQuery" === nodeType || "TSTypeLiteral" === nodeType || "TSArrayType" === nodeType || "TSTupleType" === nodeType || "TSOptionalType" === nodeType || "TSRestType" === nodeType || "TSUnionType" === nodeType || "TSIntersectionType" === nodeType || "TSConditionalType" === nodeType || "TSInferType" === nodeType || "TSParenthesizedType" === nodeType || "TSTypeOperator" === nodeType || "TSIndexedAccessType" === nodeType || "TSMappedType" === nodeType || "TSLiteralType" === nodeType || "TSExpressionWithTypeArguments" === nodeType || "TSImportType" === nodeType) { if (typeof opts === "undefined") { return true; } else { @@ -45214,7 +47182,7 @@ function isSpreadProperty(node, opts) { return false; } -},{"../../utils/shallowEqual":168}],171:[function(require,module,exports){ +},{"../../utils/shallowEqual":173}],176:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -45250,7 +47218,7 @@ function is(type, node, opts) { return (0, _shallowEqual.default)(node, opts); } } -},{"../definitions":149,"../utils/shallowEqual":168,"./isPlaceholderType":178,"./isType":182}],172:[function(require,module,exports){ +},{"../definitions":154,"../utils/shallowEqual":173,"./isPlaceholderType":183,"./isType":187}],177:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -45284,7 +47252,7 @@ function isBinding(node, parent, grandparent) { return false; } -},{"../retrievers/getBindingIdentifiers":162}],173:[function(require,module,exports){ +},{"../retrievers/getBindingIdentifiers":167}],178:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -45301,7 +47269,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de function isBlockScoped(node) { return (0, _generated.isFunctionDeclaration)(node) || (0, _generated.isClassDeclaration)(node) || (0, _isLet.default)(node); } -},{"./generated":170,"./isLet":175}],174:[function(require,module,exports){ +},{"./generated":175,"./isLet":180}],179:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -45328,7 +47296,7 @@ function isImmutable(node) { return false; } -},{"./generated":170,"./isType":182}],175:[function(require,module,exports){ +},{"./generated":175,"./isType":187}],180:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -45343,7 +47311,7 @@ var _constants = require("../constants"); function isLet(node) { return (0, _generated.isVariableDeclaration)(node) && (node.kind !== "var" || node[_constants.BLOCK_SCOPED_SYMBOL]); } -},{"../constants":133,"./generated":170}],176:[function(require,module,exports){ +},{"../constants":138,"./generated":175}],181:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -45356,7 +47324,7 @@ var _definitions = require("../definitions"); function isNode(node) { return !!(node && _definitions.VISITOR_KEYS[node.type]); } -},{"../definitions":149}],177:[function(require,module,exports){ +},{"../definitions":154}],182:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -45424,7 +47392,7 @@ function isNodesEquivalent(a, b) { return true; } -},{"../definitions":149}],178:[function(require,module,exports){ +},{"../definitions":154}],183:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -45446,7 +47414,7 @@ function isPlaceholderType(placeholderType, targetType) { return false; } -},{"../definitions":149}],179:[function(require,module,exports){ +},{"../definitions":154}],184:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -45559,7 +47527,7 @@ function isReferenced(node, parent, grandparent) { return true; } -},{}],180:[function(require,module,exports){ +},{}],185:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -45582,9 +47550,13 @@ function isScope(node, parent) { return false; } + if ((0, _generated.isPattern)(node) && (0, _generated.isFunction)(parent)) { + return true; + } + return (0, _generated.isScopable)(node); } -},{"./generated":170}],181:[function(require,module,exports){ +},{"./generated":175}],186:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -45599,7 +47571,7 @@ function isSpecifierDefault(specifier) { name: "default" }); } -},{"./generated":170}],182:[function(require,module,exports){ +},{"./generated":175}],187:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -45624,7 +47596,7 @@ function isType(nodeType, targetType) { return false; } -},{"../definitions":149}],183:[function(require,module,exports){ +},{"../definitions":154}],188:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -45641,7 +47613,7 @@ const RESERVED_WORDS_ES3_ONLY = new Set(["abstract", "boolean", "byte", "char", function isValidES3Identifier(name) { return (0, _isValidIdentifier.default)(name) && !RESERVED_WORDS_ES3_ONLY.has(name); } -},{"./isValidIdentifier":184}],184:[function(require,module,exports){ +},{"./isValidIdentifier":189}],189:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -45649,28 +47621,24 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = isValidIdentifier; -function _esutils() { - const data = _interopRequireDefault(require("esutils")); - - _esutils = function () { - return data; - }; - - return data; -} +var _esutils = _interopRequireDefault(require("esutils")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -function isValidIdentifier(name) { - if (typeof name !== "string" || _esutils().default.keyword.isReservedWordES6(name, true)) { - return false; - } else if (name === "await") { - return false; - } else { - return _esutils().default.keyword.isIdentifierNameES6(name); +function isValidIdentifier(name, reserved = true) { + if (typeof name !== "string") return false; + + if (reserved) { + if (_esutils.default.keyword.isReservedWordES6(name, true)) { + return false; + } else if (name === "await") { + return false; + } } + + return _esutils.default.keyword.isIdentifierNameES6(name); } -},{"esutils":213}],185:[function(require,module,exports){ +},{"esutils":218}],190:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -45687,7 +47655,7 @@ function isVar(node) { kind: "var" }) && !node[_constants.BLOCK_SCOPED_SYMBOL]; } -},{"../constants":133,"./generated":170}],186:[function(require,module,exports){ +},{"../constants":138,"./generated":175}],191:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -45728,7 +47696,7 @@ function matchesPattern(member, match, allowPartial) { return true; } -},{"./generated":170}],187:[function(require,module,exports){ +},{"./generated":175}],192:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -45739,7 +47707,7 @@ exports.default = isCompatTag; function isCompatTag(tagName) { return !!tagName && /^[a-z]/.test(tagName); } -},{}],188:[function(require,module,exports){ +},{}],193:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -45754,13 +47722,15 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de const isReactComponent = (0, _buildMatchMemberExpression.default)("React.Component"); var _default = isReactComponent; exports.default = _default; -},{"../buildMatchMemberExpression":169}],189:[function(require,module,exports){ +},{"../buildMatchMemberExpression":174}],194:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = validate; +exports.validateField = validateField; +exports.validateChild = validateChild; var _definitions = require("../definitions"); @@ -45769,11 +47739,23 @@ function validate(node, key, val) { const fields = _definitions.NODE_FIELDS[node.type]; if (!fields) return; const field = fields[key]; + validateField(node, key, val, field); + validateChild(node, key, val); +} + +function validateField(node, key, val, field) { if (!field || !field.validate) return; if (field.optional && val == null) return; field.validate(node, key, val); } -},{"../definitions":149}],190:[function(require,module,exports){ + +function validateChild(node, key, val) { + if (val == null) return; + const validate = _definitions.NODE_PARENT_VALIDATIONS[val.type]; + if (!validate) return; + validate(node, key, val); +} +},{"../definitions":154}],195:[function(require,module,exports){ 'use strict'; const colorConvert = require('color-convert'); @@ -45940,10 +47922,12 @@ Object.defineProperty(module, 'exports', { get: assembleStyles }); -},{"color-convert":202}],191:[function(require,module,exports){ +},{"color-convert":207}],196:[function(require,module,exports){ (function (global){ 'use strict'; +var objectAssign = require('object-assign'); + // compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js // original notice: @@ -45985,6 +47969,8 @@ function isBuffer(b) { } // based on node assert, original notice: +// NB: The URL to the CommonJS spec is kept just for tradition. +// node-assert has evolved a lot since then, both in API and behavior. // http://wiki.commonjs.org/wiki/Unit_Testing/1.0 // @@ -46425,6 +48411,18 @@ assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) { assert.ifError = function(err) { if (err) throw err; }; +// Expose a strict only variant of assert +function strict(value, message) { + if (!value) fail(value, true, message, '==', strict); +} +assert.strict = objectAssign(strict, assert, { + equal: assert.strictEqual, + deepEqual: assert.deepStrictEqual, + notEqual: assert.notStrictEqual, + notDeepEqual: assert.notDeepStrictEqual +}); +assert.strict.strict = assert.strict; + var objectKeys = Object.keys || function (obj) { var keys = []; for (var key in obj) { @@ -46434,7 +48432,7 @@ var objectKeys = Object.keys || function (obj) { }; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"util/":194}],192:[function(require,module,exports){ +},{"object-assign":428,"util/":199}],197:[function(require,module,exports){ if (typeof Object.create === 'function') { // implementation from standard node.js 'util' module module.exports = function inherits(ctor, superCtor) { @@ -46459,14 +48457,14 @@ if (typeof Object.create === 'function') { } } -},{}],193:[function(require,module,exports){ +},{}],198:[function(require,module,exports){ module.exports = function isBuffer(arg) { return arg && typeof arg === 'object' && typeof arg.copy === 'function' && typeof arg.fill === 'function' && typeof arg.readUInt8 === 'function'; } -},{}],194:[function(require,module,exports){ +},{}],199:[function(require,module,exports){ (function (process,global){ // Copyright Joyent, Inc. and other Node contributors. // @@ -47056,7 +49054,7 @@ function hasOwnProperty(obj, prop) { } }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./support/isBuffer":193,"_process":426,"inherits":192}],195:[function(require,module,exports){ +},{"./support/isBuffer":198,"_process":433,"inherits":197}],200:[function(require,module,exports){ 'use strict' exports.byteLength = byteLength @@ -47124,7 +49122,8 @@ function toByteArray (b64) { ? validLen - 4 : validLen - for (var i = 0; i < len; i += 4) { + var i + for (i = 0; i < len; i += 4) { tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | @@ -47209,11 +49208,11 @@ function fromByteArray (uint8) { return parts.join('') } -},{}],196:[function(require,module,exports){ +},{}],201:[function(require,module,exports){ -},{}],197:[function(require,module,exports){ -arguments[4][196][0].apply(exports,arguments) -},{"dup":196}],198:[function(require,module,exports){ +},{}],202:[function(require,module,exports){ +arguments[4][201][0].apply(exports,arguments) +},{"dup":201}],203:[function(require,module,exports){ (function (Buffer){ /*! * The buffer module from node.js, for the browser. @@ -47227,6 +49226,10 @@ arguments[4][196][0].apply(exports,arguments) var base64 = require('base64-js') var ieee754 = require('ieee754') +var customInspectSymbol = + (typeof Symbol === 'function' && typeof Symbol.for === 'function') + ? Symbol.for('nodejs.util.inspect.custom') + : null exports.Buffer = Buffer exports.SlowBuffer = SlowBuffer @@ -47263,7 +49266,9 @@ function typedArraySupport () { // Can typed array instances can be augmented? try { var arr = new Uint8Array(1) - arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } } + var proto = { foo: function () { return 42 } } + Object.setPrototypeOf(proto, Uint8Array.prototype) + Object.setPrototypeOf(arr, proto) return arr.foo() === 42 } catch (e) { return false @@ -47292,7 +49297,7 @@ function createBuffer (length) { } // Return an augmented `Uint8Array` instance var buf = new Uint8Array(length) - buf.__proto__ = Buffer.prototype + Object.setPrototypeOf(buf, Buffer.prototype) return buf } @@ -47342,7 +49347,7 @@ function from (value, encodingOrOffset, length) { } if (value == null) { - throw TypeError( + throw new TypeError( 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + 'or Array-like Object. Received type ' + (typeof value) ) @@ -47394,8 +49399,8 @@ Buffer.from = function (value, encodingOrOffset, length) { // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: // https://github.com/feross/buffer/pull/148 -Buffer.prototype.__proto__ = Uint8Array.prototype -Buffer.__proto__ = Uint8Array +Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype) +Object.setPrototypeOf(Buffer, Uint8Array) function assertSize (size) { if (typeof size !== 'number') { @@ -47499,7 +49504,8 @@ function fromArrayBuffer (array, byteOffset, length) { } // Return an augmented `Uint8Array` instance - buf.__proto__ = Buffer.prototype + Object.setPrototypeOf(buf, Buffer.prototype) + return buf } @@ -47821,6 +49827,9 @@ Buffer.prototype.inspect = function inspect () { if (this.length > max) str += ' ... ' return '' } +if (customInspectSymbol) { + Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect +} Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { if (isInstance(target, Uint8Array)) { @@ -47946,7 +49955,7 @@ function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) } } - return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) + return arrayIndexOf(buffer, [val], byteOffset, encoding, dir) } throw new TypeError('val must be string, number or Buffer') @@ -48275,7 +50284,7 @@ function hexSlice (buf, start, end) { var out = '' for (var i = start; i < end; ++i) { - out += toHex(buf[i]) + out += hexSliceLookupTable[buf[i]] } return out } @@ -48312,7 +50321,8 @@ Buffer.prototype.slice = function slice (start, end) { var newBuf = this.subarray(start, end) // Return an augmented `Uint8Array` instance - newBuf.__proto__ = Buffer.prototype + Object.setPrototypeOf(newBuf, Buffer.prototype) + return newBuf } @@ -48801,6 +50811,8 @@ Buffer.prototype.fill = function fill (val, start, end, encoding) { } } else if (typeof val === 'number') { val = val & 255 + } else if (typeof val === 'boolean') { + val = Number(val) } // Invalid ranges are not set to a default, so can range check early. @@ -48858,11 +50870,6 @@ function base64clean (str) { return str } -function toHex (n) { - if (n < 16) return '0' + n.toString(16) - return n.toString(16) -} - function utf8ToBytes (string, units) { units = units || Infinity var codePoint @@ -48993,8 +51000,22 @@ function numberIsNaN (obj) { return obj !== obj // eslint-disable-line no-self-compare } +// Create lookup table for `toString('hex')` +// See: https://github.com/feross/buffer/issues/219 +var hexSliceLookupTable = (function () { + var alphabet = '0123456789abcdef' + var table = new Array(256) + for (var i = 0; i < 16; ++i) { + var i16 = i * 16 + for (var j = 0; j < 16; ++j) { + table[i16 + j] = alphabet[i] + alphabet[j] + } + } + return table +})() + }).call(this,require("buffer").Buffer) -},{"base64-js":195,"buffer":198,"ieee754":217}],199:[function(require,module,exports){ +},{"base64-js":200,"buffer":203,"ieee754":223}],204:[function(require,module,exports){ (function (process){ 'use strict'; const escapeStringRegexp = require('escape-string-regexp'); @@ -49226,7 +51247,7 @@ module.exports.supportsColor = stdoutColor; module.exports.default = module.exports; // For TypeScript }).call(this,require('_process')) -},{"./templates.js":200,"_process":426,"ansi-styles":190,"escape-string-regexp":209,"supports-color":498}],200:[function(require,module,exports){ +},{"./templates.js":205,"_process":433,"ansi-styles":195,"escape-string-regexp":214,"supports-color":516}],205:[function(require,module,exports){ 'use strict'; const TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi; const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g; @@ -49356,7 +51377,7 @@ module.exports = (chalk, tmp) => { return chunks.join(''); }; -},{}],201:[function(require,module,exports){ +},{}],206:[function(require,module,exports){ /* MIT license */ var cssKeywords = require('color-name'); @@ -50226,7 +52247,7 @@ convert.rgb.gray = function (rgb) { return [val / 255 * 100]; }; -},{"color-name":204}],202:[function(require,module,exports){ +},{"color-name":209}],207:[function(require,module,exports){ var conversions = require('./conversions'); var route = require('./route'); @@ -50306,7 +52327,7 @@ models.forEach(function (fromModel) { module.exports = convert; -},{"./conversions":201,"./route":203}],203:[function(require,module,exports){ +},{"./conversions":206,"./route":208}],208:[function(require,module,exports){ var conversions = require('./conversions'); /* @@ -50405,7 +52426,7 @@ module.exports = function (fromModel) { }; -},{"./conversions":201}],204:[function(require,module,exports){ +},{"./conversions":206}],209:[function(require,module,exports){ 'use strict' module.exports = { @@ -50559,7 +52580,7 @@ module.exports = { "yellowgreen": [154, 205, 50] }; -},{}],205:[function(require,module,exports){ +},{}],210:[function(require,module,exports){ 'use strict'; var fs = require('fs'); var path = require('path'); @@ -50697,7 +52718,7 @@ exports.generateMapFileComment = function (file, options) { return options && options.multiline ? '/*# ' + data + ' */' : '//# ' + data; }; -},{"fs":197,"path":423,"safe-buffer":485}],206:[function(require,module,exports){ +},{"fs":201,"path":430,"safe-buffer":502}],211:[function(require,module,exports){ (function (Buffer){ // Copyright Joyent, Inc. and other Node contributors. // @@ -50808,7 +52829,7 @@ function objectToString(o) { } }).call(this,{"isBuffer":require("../../is-buffer/index.js")}) -},{"../../is-buffer/index.js":219}],207:[function(require,module,exports){ +},{"../../is-buffer/index.js":225}],212:[function(require,module,exports){ (function (process){ /* eslint-env browser */ @@ -51076,7 +53097,7 @@ formatters.j = function (v) { }; }).call(this,require('_process')) -},{"./common":208,"_process":426}],208:[function(require,module,exports){ +},{"./common":213,"_process":433}],213:[function(require,module,exports){ /** * This is the common logic for both the Node.js and web browser @@ -51344,7 +53365,7 @@ function setup(env) { module.exports = setup; -},{"ms":421}],209:[function(require,module,exports){ +},{"ms":427}],214:[function(require,module,exports){ 'use strict'; var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g; @@ -51357,7 +53378,7 @@ module.exports = function (str) { return str.replace(matchOperatorsRe, '\\$&'); }; -},{}],210:[function(require,module,exports){ +},{}],215:[function(require,module,exports){ /* Copyright (C) 2013 Yusuke Suzuki @@ -51503,7 +53524,7 @@ module.exports = function (str) { }()); /* vim: set sw=4 ts=4 et tw=80 : */ -},{}],211:[function(require,module,exports){ +},{}],216:[function(require,module,exports){ /* Copyright (C) 2013-2014 Yusuke Suzuki Copyright (C) 2014 Ivan Nikulin @@ -51536,17 +53557,17 @@ module.exports = function (str) { // See `tools/generate-identifier-regex.js`. ES5Regex = { - // ECMAScript 5.1/Unicode v7.0.0 NonAsciiIdentifierStart: - NonAsciiIdentifierStart: /[\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-\u08B2\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\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\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\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-\u13F4\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\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\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\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\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\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\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-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\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-\uAB5F\uAB64\uAB65\uABC0-\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]/, - // ECMAScript 5.1/Unicode v7.0.0 NonAsciiIdentifierPart: - NonAsciiIdentifierPart: /[\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]/ + // ECMAScript 5.1/Unicode v9.0.0 NonAsciiIdentifierStart: + NonAsciiIdentifierStart: /[\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-\u1884\u1887-\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\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\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\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\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]/, + // ECMAScript 5.1/Unicode v9.0.0 NonAsciiIdentifierPart: + NonAsciiIdentifierPart: /[\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-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\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\u0AF9\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-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\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\u0D54-\u0D57\u0D5F-\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-\u13F5\u13F8-\u13FD\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\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFB-\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-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\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-\uAB65\uAB70-\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-\uFE2F\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]/ }; ES6Regex = { - // ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierStart: - NonAsciiIdentifierStart: /[\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-\u08B2\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\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\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\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-\u13F4\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\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\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-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\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-\uAB5F\uAB64\uAB65\uABC0-\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]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDE00-\uDE11\uDE13-\uDE2B\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDE00-\uDE2F\uDE44\uDE80-\uDEAA]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|\uD809[\uDC00-\uDC6E]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD87E[\uDC00-\uDE1D]/, - // ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierPart: - NonAsciiIdentifierPart: /[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\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\u1369-\u1371\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-\u19DA\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\u2118-\u211D\u2124\u2126\u2128\u212A-\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\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\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]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDD0-\uDDDA\uDE00-\uDE11\uDE13-\uDE37\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF01-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|\uD809[\uDC00-\uDC6E]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/ + // ECMAScript 6/Unicode v9.0.0 NonAsciiIdentifierStart: + NonAsciiIdentifierStart: /[\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]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]/, + // ECMAScript 6/Unicode v9.0.0 NonAsciiIdentifierPart: + NonAsciiIdentifierPart: /[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\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-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\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\u0AF9\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-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\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\u0D54-\u0D57\u0D5F-\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\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\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-\u19DA\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\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFB-\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\u2118-\u211D\u2124\u2126\u2128\u212A-\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\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\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-\uAB65\uAB70-\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-\uFE2F\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]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/ }; function isDecimalDigit(ch) { @@ -51566,7 +53587,7 @@ module.exports = function (str) { // 7.2 White Space NON_ASCII_WHITESPACES = [ - 0x1680, 0x180E, + 0x1680, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, @@ -51640,7 +53661,7 @@ module.exports = function (str) { }()); /* vim: set sw=4 ts=4 et tw=80 : */ -},{}],212:[function(require,module,exports){ +},{}],217:[function(require,module,exports){ /* Copyright (C) 2013 Yusuke Suzuki @@ -51807,7 +53828,7 @@ module.exports = function (str) { }()); /* vim: set sw=4 ts=4 et tw=80 : */ -},{"./code":211}],213:[function(require,module,exports){ +},{"./code":216}],218:[function(require,module,exports){ /* Copyright (C) 2013 Yusuke Suzuki @@ -51842,7 +53863,7 @@ module.exports = function (str) { }()); /* vim: set sw=4 ts=4 et tw=80 : */ -},{"./ast":210,"./code":211,"./keyword":212}],214:[function(require,module,exports){ +},{"./ast":215,"./code":216,"./keyword":217}],219:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -52367,7 +54388,375 @@ function functionBindPolyfill(context) { }; } -},{}],215:[function(require,module,exports){ +},{}],220:[function(require,module,exports){ +"use strict"; + +// These use the global symbol registry so that multiple copies of this +// library can work together in case they are not deduped. +const GENSYNC_START = Symbol.for("gensync:v1:start"); +const GENSYNC_SUSPEND = Symbol.for("gensync:v1:suspend"); + +const GENSYNC_EXPECTED_START = "GENSYNC_EXPECTED_START"; +const GENSYNC_EXPECTED_SUSPEND = "GENSYNC_EXPECTED_SUSPEND"; +const GENSYNC_OPTIONS_ERROR = "GENSYNC_OPTIONS_ERROR"; +const GENSYNC_RACE_NONEMPTY = "GENSYNC_RACE_NONEMPTY"; +const GENSYNC_ERRBACK_NO_CALLBACK = "GENSYNC_ERRBACK_NO_CALLBACK"; + +module.exports = Object.assign( + function gensync(optsOrFn) { + let genFn = optsOrFn; + if (typeof optsOrFn !== "function") { + genFn = newGenerator(optsOrFn); + } else { + genFn = wrapGenerator(optsOrFn); + } + + return Object.assign(genFn, makeFunctionAPI(genFn)); + }, + { + all: buildOperation({ + name: "all", + arity: 1, + sync: function(args) { + const items = Array.from(args[0]); + return items.map(item => evaluateSync(item)); + }, + async: function(args, resolve, reject) { + const items = Array.from(args[0]); + + let count = 0; + const results = items.map(() => undefined); + items.forEach((item, i) => { + evaluateAsync( + item, + val => { + results[i] = val; + count += 1; + + if (count === results.length) resolve(results); + }, + reject + ); + }); + }, + }), + race: buildOperation({ + name: "race", + arity: 1, + sync: function(args) { + const items = Array.from(args[0]); + if (items.length === 0) { + throw makeError("Must race at least 1 item", GENSYNC_RACE_NONEMPTY); + } + + return evaluateSync(items[0]); + }, + async: function(args, resolve, reject) { + const items = Array.from(args[0]); + if (items.length === 0) { + throw makeError("Must race at least 1 item", GENSYNC_RACE_NONEMPTY); + } + + for (const item of items) { + evaluateAsync(item, resolve, reject); + } + }, + }), + } +); + +/** + * Given a generator function, return the standard API object that executes + * the generator and calls the callbacks. + */ +function makeFunctionAPI(genFn) { + const fns = { + sync: function(...args) { + return evaluateSync(genFn.apply(this, args)); + }, + async: function(...args) { + return new Promise((resolve, reject) => { + evaluateAsync(genFn.apply(this, args), resolve, reject); + }); + }, + errback: function(...args) { + const cb = args.pop(); + if (typeof cb !== "function") { + throw makeError( + "Asynchronous function called without callback", + GENSYNC_ERRBACK_NO_CALLBACK + ); + } + + let gen; + try { + gen = genFn.apply(this, args); + } catch (err) { + cb(err); + return; + } + + evaluateAsync(gen, val => cb(undefined, val), err => cb(err)); + }, + }; + return fns; +} + +function assertTypeof(type, name, value, allowUndefined) { + if ( + typeof value === type || + (allowUndefined && typeof value === "undefined") + ) { + return; + } + + let msg; + if (allowUndefined) { + msg = `Expected opts.${name} to be either a ${type}, or undefined.`; + } else { + msg = `Expected opts.${name} to be a ${type}.`; + } + + throw makeError(msg, GENSYNC_OPTIONS_ERROR); +} +function makeError(msg, code) { + return Object.assign(new Error(msg), { code }); +} + +/** + * Given an options object, return a new generator that dispatches the + * correct handler based on sync or async execution. + */ +function newGenerator({ name, arity, sync, async, errback }) { + assertTypeof("string", "name", name, true /* allowUndefined */); + assertTypeof("number", "arity", arity, true /* allowUndefined */); + assertTypeof("function", "sync", sync); + assertTypeof("function", "async", async, true /* allowUndefined */); + assertTypeof("function", "errback", errback, true /* allowUndefined */); + if (async && errback) { + throw makeError( + "Expected one of either opts.async or opts.errback, but got _both_.", + GENSYNC_OPTIONS_ERROR + ); + } + + if (typeof name !== "string") { + let fnName; + if (errback && errback.name && errback.name !== "errback") { + fnName = errback.name; + } + if (async && async.name && async.name !== "async") { + fnName = async.name.replace(/Async$/, ""); + } + if (sync && sync.name && sync.name !== "sync") { + fnName = sync.name.replace(/Sync$/, ""); + } + + if (typeof fnName === "string") { + name = fnName; + } + } + + if (typeof arity !== "number") { + arity = sync.length; + } + + return buildOperation({ + name, + arity, + sync: function(args) { + return sync.apply(this, args); + }, + async: function(args, resolve, reject) { + if (async) { + async.apply(this, args).then(resolve, reject); + } else if (errback) { + errback.call(this, ...args, (err, value) => { + if (err == null) resolve(value); + else reject(err); + }); + } else { + resolve(sync.apply(this, args)); + } + }, + }); +} + +function wrapGenerator(genFn) { + return setFunctionMetadata(genFn.name, genFn.length, function(...args) { + return genFn.apply(this, args); + }); +} + +function buildOperation({ name, arity, sync, async }) { + return setFunctionMetadata(name, arity, function*(...args) { + const resume = yield GENSYNC_START; + if (!resume) { + return sync.call(this, args); + } + + let result; + try { + async.call( + this, + args, + value => { + if (result) return; + + result = { value }; + resume(); + }, + err => { + if (result) return; + + result = { err }; + resume(); + } + ); + } catch (err) { + result = { err }; + resume(); + } + + // Suspend until the callbacks run. Will resume synchronously if the + // callback was already called. + yield GENSYNC_SUSPEND; + + if (result.hasOwnProperty("err")) { + throw result.err; + } + + return result.value; + }); +} + +function evaluateSync(gen) { + let value; + while (!({ value } = gen.next()).done) { + assertStart(value, gen); + } + return value; +} + +function evaluateAsync(gen, resolve, reject) { + (function step() { + try { + let value; + while (!({ value } = gen.next()).done) { + assertStart(value, gen); + + // If this throws, it is considered to have broken the contract + // established for async handlers. If these handlers are called + // synchronously, it is also considered bad behavior. + let sync = true; + let didSyncResume = false; + const out = gen.next(() => { + if (sync) { + didSyncResume = true; + } else { + step(); + } + }); + sync = false; + + assertSuspend(out, gen); + + if (!didSyncResume) { + // Callback wasn't called synchronously, so break out of the loop + // and let it call 'step' later. + return; + } + } + + return resolve(value); + } catch (err) { + return reject(err); + } + })(); +} + +function assertStart(value, gen) { + if (value === GENSYNC_START) return; + + throwError( + gen, + makeError( + `Got unexpected yielded value in gensync generator: ${JSON.stringify( + value + )}. Did you perhaps mean to use 'yield*' instead of 'yield'?`, + GENSYNC_EXPECTED_START + ) + ); +} +function assertSuspend({ value, done }, gen) { + if (!done && value === GENSYNC_SUSPEND) return; + + throwError( + gen, + makeError( + done + ? "Unexpected generator completion. If you get this, it is probably a gensync bug." + : `Expected GENSYNC_SUSPEND, got ${JSON.stringify( + value + )}. If you get this, it is probably a gensync bug.`, + GENSYNC_EXPECTED_SUSPEND + ) + ); +} + +function throwError(gen, err) { + // Call `.throw` so that users can step in a debugger to easily see which + // 'yield' passed an unexpected value. If the `.throw` call didn't throw + // back to the generator, we explicitly do it to stop the error + // from being swallowed by user code try/catches. + if (gen.throw) gen.throw(err); + throw err; +} + +function isIterable(value) { + return ( + !!value && + (typeof value === "object" || typeof value === "function") && + !value[Symbol.iterator] + ); +} + +function setFunctionMetadata(name, arity, fn) { + if (typeof name === "string") { + // This should always work on the supported Node versions, but for the + // sake of users that are compiling to older versions, we check for + // configurability so we don't throw. + const nameDesc = Object.getOwnPropertyDescriptor(fn, "name"); + if (!nameDesc || nameDesc.configurable) { + Object.defineProperty( + fn, + "name", + Object.assign(nameDesc || {}, { + configurable: true, + value: name, + }) + ); + } + } + + if (typeof arity === "number") { + const lengthDesc = Object.getOwnPropertyDescriptor(fn, "length"); + if (!lengthDesc || lengthDesc.configurable) { + Object.defineProperty( + fn, + "length", + Object.assign(lengthDesc || {}, { + configurable: true, + value: arity, + }) + ); + } + } + + return fn; +} + +},{}],221:[function(require,module,exports){ module.exports={ "builtin": { "Array": false, @@ -53932,11 +56321,11 @@ module.exports={ } } -},{}],216:[function(require,module,exports){ +},{}],222:[function(require,module,exports){ 'use strict'; module.exports = require('./globals.json'); -},{"./globals.json":215}],217:[function(require,module,exports){ +},{"./globals.json":221}],223:[function(require,module,exports){ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m var eLen = (nBytes * 8) - mLen - 1 @@ -54022,9 +56411,36 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { buffer[offset + i - d] |= s * 128 } -},{}],218:[function(require,module,exports){ -arguments[4][192][0].apply(exports,arguments) -},{"dup":192}],219:[function(require,module,exports){ +},{}],224:[function(require,module,exports){ +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }) + } + }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } + } +} + +},{}],225:[function(require,module,exports){ /*! * Determine if an object is a Buffer * @@ -54047,14 +56463,14 @@ function isSlowBuffer (obj) { return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) } -},{}],220:[function(require,module,exports){ +},{}],226:[function(require,module,exports){ var toString = {}.toString; module.exports = Array.isArray || function (arr) { return toString.call(arr) == '[object Array]'; }; -},{}],221:[function(require,module,exports){ +},{}],227:[function(require,module,exports){ // Copyright 2014, 2015, 2016, 2017, 2018 Simon Lydell // License: MIT. (See LICENSE.) @@ -54079,7 +56495,7 @@ exports.matchToToken = function(match) { return token } -},{}],222:[function(require,module,exports){ +},{}],228:[function(require,module,exports){ (function (Buffer){ 'use strict'; @@ -54412,7 +56828,7 @@ jsesc.version = '2.5.2'; module.exports = jsesc; }).call(this,{"isBuffer":require("../is-buffer/index.js")}) -},{"../is-buffer/index.js":219}],223:[function(require,module,exports){ +},{"../is-buffer/index.js":225}],229:[function(require,module,exports){ var getNative = require('./_getNative'), root = require('./_root'); @@ -54421,7 +56837,7 @@ var DataView = getNative(root, 'DataView'); module.exports = DataView; -},{"./_getNative":318,"./_root":362}],224:[function(require,module,exports){ +},{"./_getNative":324,"./_root":368}],230:[function(require,module,exports){ var hashClear = require('./_hashClear'), hashDelete = require('./_hashDelete'), hashGet = require('./_hashGet'), @@ -54455,7 +56871,7 @@ Hash.prototype.set = hashSet; module.exports = Hash; -},{"./_hashClear":326,"./_hashDelete":327,"./_hashGet":328,"./_hashHas":329,"./_hashSet":330}],225:[function(require,module,exports){ +},{"./_hashClear":332,"./_hashDelete":333,"./_hashGet":334,"./_hashHas":335,"./_hashSet":336}],231:[function(require,module,exports){ var listCacheClear = require('./_listCacheClear'), listCacheDelete = require('./_listCacheDelete'), listCacheGet = require('./_listCacheGet'), @@ -54489,7 +56905,7 @@ ListCache.prototype.set = listCacheSet; module.exports = ListCache; -},{"./_listCacheClear":342,"./_listCacheDelete":343,"./_listCacheGet":344,"./_listCacheHas":345,"./_listCacheSet":346}],226:[function(require,module,exports){ +},{"./_listCacheClear":348,"./_listCacheDelete":349,"./_listCacheGet":350,"./_listCacheHas":351,"./_listCacheSet":352}],232:[function(require,module,exports){ var getNative = require('./_getNative'), root = require('./_root'); @@ -54498,7 +56914,7 @@ var Map = getNative(root, 'Map'); module.exports = Map; -},{"./_getNative":318,"./_root":362}],227:[function(require,module,exports){ +},{"./_getNative":324,"./_root":368}],233:[function(require,module,exports){ var mapCacheClear = require('./_mapCacheClear'), mapCacheDelete = require('./_mapCacheDelete'), mapCacheGet = require('./_mapCacheGet'), @@ -54532,7 +56948,7 @@ MapCache.prototype.set = mapCacheSet; module.exports = MapCache; -},{"./_mapCacheClear":347,"./_mapCacheDelete":348,"./_mapCacheGet":349,"./_mapCacheHas":350,"./_mapCacheSet":351}],228:[function(require,module,exports){ +},{"./_mapCacheClear":353,"./_mapCacheDelete":354,"./_mapCacheGet":355,"./_mapCacheHas":356,"./_mapCacheSet":357}],234:[function(require,module,exports){ var getNative = require('./_getNative'), root = require('./_root'); @@ -54541,7 +56957,7 @@ var Promise = getNative(root, 'Promise'); module.exports = Promise; -},{"./_getNative":318,"./_root":362}],229:[function(require,module,exports){ +},{"./_getNative":324,"./_root":368}],235:[function(require,module,exports){ var getNative = require('./_getNative'), root = require('./_root'); @@ -54550,7 +56966,7 @@ var Set = getNative(root, 'Set'); module.exports = Set; -},{"./_getNative":318,"./_root":362}],230:[function(require,module,exports){ +},{"./_getNative":324,"./_root":368}],236:[function(require,module,exports){ var MapCache = require('./_MapCache'), setCacheAdd = require('./_setCacheAdd'), setCacheHas = require('./_setCacheHas'); @@ -54579,7 +56995,7 @@ SetCache.prototype.has = setCacheHas; module.exports = SetCache; -},{"./_MapCache":227,"./_setCacheAdd":363,"./_setCacheHas":364}],231:[function(require,module,exports){ +},{"./_MapCache":233,"./_setCacheAdd":369,"./_setCacheHas":370}],237:[function(require,module,exports){ var ListCache = require('./_ListCache'), stackClear = require('./_stackClear'), stackDelete = require('./_stackDelete'), @@ -54608,7 +57024,7 @@ Stack.prototype.set = stackSet; module.exports = Stack; -},{"./_ListCache":225,"./_stackClear":368,"./_stackDelete":369,"./_stackGet":370,"./_stackHas":371,"./_stackSet":372}],232:[function(require,module,exports){ +},{"./_ListCache":231,"./_stackClear":374,"./_stackDelete":375,"./_stackGet":376,"./_stackHas":377,"./_stackSet":378}],238:[function(require,module,exports){ var root = require('./_root'); /** Built-in value references. */ @@ -54616,7 +57032,7 @@ var Symbol = root.Symbol; module.exports = Symbol; -},{"./_root":362}],233:[function(require,module,exports){ +},{"./_root":368}],239:[function(require,module,exports){ var root = require('./_root'); /** Built-in value references. */ @@ -54624,7 +57040,7 @@ var Uint8Array = root.Uint8Array; module.exports = Uint8Array; -},{"./_root":362}],234:[function(require,module,exports){ +},{"./_root":368}],240:[function(require,module,exports){ var getNative = require('./_getNative'), root = require('./_root'); @@ -54633,7 +57049,7 @@ var WeakMap = getNative(root, 'WeakMap'); module.exports = WeakMap; -},{"./_getNative":318,"./_root":362}],235:[function(require,module,exports){ +},{"./_getNative":324,"./_root":368}],241:[function(require,module,exports){ /** * A faster alternative to `Function#apply`, this function invokes `func` * with the `this` binding of `thisArg` and the arguments of `args`. @@ -54656,7 +57072,7 @@ function apply(func, thisArg, args) { module.exports = apply; -},{}],236:[function(require,module,exports){ +},{}],242:[function(require,module,exports){ /** * A specialized version of `_.forEach` for arrays without support for * iteratee shorthands. @@ -54680,7 +57096,7 @@ function arrayEach(array, iteratee) { module.exports = arrayEach; -},{}],237:[function(require,module,exports){ +},{}],243:[function(require,module,exports){ /** * A specialized version of `_.filter` for arrays without support for * iteratee shorthands. @@ -54707,7 +57123,7 @@ function arrayFilter(array, predicate) { module.exports = arrayFilter; -},{}],238:[function(require,module,exports){ +},{}],244:[function(require,module,exports){ var baseIndexOf = require('./_baseIndexOf'); /** @@ -54726,7 +57142,7 @@ function arrayIncludes(array, value) { module.exports = arrayIncludes; -},{"./_baseIndexOf":261}],239:[function(require,module,exports){ +},{"./_baseIndexOf":267}],245:[function(require,module,exports){ /** * This function is like `arrayIncludes` except that it accepts a comparator. * @@ -54750,7 +57166,7 @@ function arrayIncludesWith(array, value, comparator) { module.exports = arrayIncludesWith; -},{}],240:[function(require,module,exports){ +},{}],246:[function(require,module,exports){ var baseTimes = require('./_baseTimes'), isArguments = require('./isArguments'), isArray = require('./isArray'), @@ -54801,7 +57217,7 @@ function arrayLikeKeys(value, inherited) { module.exports = arrayLikeKeys; -},{"./_baseTimes":285,"./_isIndex":335,"./isArguments":390,"./isArray":391,"./isBuffer":393,"./isTypedArray":405}],241:[function(require,module,exports){ +},{"./_baseTimes":291,"./_isIndex":341,"./isArguments":396,"./isArray":397,"./isBuffer":399,"./isTypedArray":411}],247:[function(require,module,exports){ /** * A specialized version of `_.map` for arrays without support for iteratee * shorthands. @@ -54824,7 +57240,7 @@ function arrayMap(array, iteratee) { module.exports = arrayMap; -},{}],242:[function(require,module,exports){ +},{}],248:[function(require,module,exports){ /** * Appends the elements of `values` to `array`. * @@ -54846,7 +57262,7 @@ function arrayPush(array, values) { module.exports = arrayPush; -},{}],243:[function(require,module,exports){ +},{}],249:[function(require,module,exports){ /** * A specialized version of `_.some` for arrays without support for iteratee * shorthands. @@ -54871,7 +57287,7 @@ function arraySome(array, predicate) { module.exports = arraySome; -},{}],244:[function(require,module,exports){ +},{}],250:[function(require,module,exports){ var baseAssignValue = require('./_baseAssignValue'), eq = require('./eq'); @@ -54901,7 +57317,7 @@ function assignValue(object, key, value) { module.exports = assignValue; -},{"./_baseAssignValue":248,"./eq":382}],245:[function(require,module,exports){ +},{"./_baseAssignValue":254,"./eq":388}],251:[function(require,module,exports){ var eq = require('./eq'); /** @@ -54924,7 +57340,7 @@ function assocIndexOf(array, key) { module.exports = assocIndexOf; -},{"./eq":382}],246:[function(require,module,exports){ +},{"./eq":388}],252:[function(require,module,exports){ var copyObject = require('./_copyObject'), keys = require('./keys'); @@ -54943,7 +57359,7 @@ function baseAssign(object, source) { module.exports = baseAssign; -},{"./_copyObject":301,"./keys":406}],247:[function(require,module,exports){ +},{"./_copyObject":307,"./keys":412}],253:[function(require,module,exports){ var copyObject = require('./_copyObject'), keysIn = require('./keysIn'); @@ -54962,7 +57378,7 @@ function baseAssignIn(object, source) { module.exports = baseAssignIn; -},{"./_copyObject":301,"./keysIn":407}],248:[function(require,module,exports){ +},{"./_copyObject":307,"./keysIn":413}],254:[function(require,module,exports){ var defineProperty = require('./_defineProperty'); /** @@ -54989,7 +57405,7 @@ function baseAssignValue(object, key, value) { module.exports = baseAssignValue; -},{"./_defineProperty":309}],249:[function(require,module,exports){ +},{"./_defineProperty":315}],255:[function(require,module,exports){ var Stack = require('./_Stack'), arrayEach = require('./_arrayEach'), assignValue = require('./_assignValue'), @@ -55132,16 +57548,10 @@ function baseClone(value, bitmask, customizer, key, object, stack) { value.forEach(function(subValue) { result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack)); }); - - return result; - } - - if (isMap(value)) { + } else if (isMap(value)) { value.forEach(function(subValue, key) { result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack)); }); - - return result; } var keysFunc = isFull @@ -55162,7 +57572,7 @@ function baseClone(value, bitmask, customizer, key, object, stack) { module.exports = baseClone; -},{"./_Stack":231,"./_arrayEach":236,"./_assignValue":244,"./_baseAssign":246,"./_baseAssignIn":247,"./_cloneBuffer":293,"./_copyArray":300,"./_copySymbols":302,"./_copySymbolsIn":303,"./_getAllKeys":314,"./_getAllKeysIn":315,"./_getTag":323,"./_initCloneArray":331,"./_initCloneByTag":332,"./_initCloneObject":333,"./isArray":391,"./isBuffer":393,"./isMap":397,"./isObject":398,"./isSet":402,"./keys":406}],250:[function(require,module,exports){ +},{"./_Stack":237,"./_arrayEach":242,"./_assignValue":250,"./_baseAssign":252,"./_baseAssignIn":253,"./_cloneBuffer":299,"./_copyArray":306,"./_copySymbols":308,"./_copySymbolsIn":309,"./_getAllKeys":320,"./_getAllKeysIn":321,"./_getTag":329,"./_initCloneArray":337,"./_initCloneByTag":338,"./_initCloneObject":339,"./isArray":397,"./isBuffer":399,"./isMap":403,"./isObject":404,"./isSet":408,"./keys":412}],256:[function(require,module,exports){ var isObject = require('./isObject'); /** Built-in value references. */ @@ -55194,7 +57604,7 @@ var baseCreate = (function() { module.exports = baseCreate; -},{"./isObject":398}],251:[function(require,module,exports){ +},{"./isObject":404}],257:[function(require,module,exports){ var baseForOwn = require('./_baseForOwn'), createBaseEach = require('./_createBaseEach'); @@ -55210,7 +57620,7 @@ var baseEach = createBaseEach(baseForOwn); module.exports = baseEach; -},{"./_baseForOwn":255,"./_createBaseEach":306}],252:[function(require,module,exports){ +},{"./_baseForOwn":261,"./_createBaseEach":312}],258:[function(require,module,exports){ /** * The base implementation of `_.findIndex` and `_.findLastIndex` without * support for iteratee shorthands. @@ -55236,7 +57646,7 @@ function baseFindIndex(array, predicate, fromIndex, fromRight) { module.exports = baseFindIndex; -},{}],253:[function(require,module,exports){ +},{}],259:[function(require,module,exports){ var arrayPush = require('./_arrayPush'), isFlattenable = require('./_isFlattenable'); @@ -55276,7 +57686,7 @@ function baseFlatten(array, depth, predicate, isStrict, result) { module.exports = baseFlatten; -},{"./_arrayPush":242,"./_isFlattenable":334}],254:[function(require,module,exports){ +},{"./_arrayPush":248,"./_isFlattenable":340}],260:[function(require,module,exports){ var createBaseFor = require('./_createBaseFor'); /** @@ -55294,7 +57704,7 @@ var baseFor = createBaseFor(); module.exports = baseFor; -},{"./_createBaseFor":307}],255:[function(require,module,exports){ +},{"./_createBaseFor":313}],261:[function(require,module,exports){ var baseFor = require('./_baseFor'), keys = require('./keys'); @@ -55312,7 +57722,7 @@ function baseForOwn(object, iteratee) { module.exports = baseForOwn; -},{"./_baseFor":254,"./keys":406}],256:[function(require,module,exports){ +},{"./_baseFor":260,"./keys":412}],262:[function(require,module,exports){ var castPath = require('./_castPath'), toKey = require('./_toKey'); @@ -55338,7 +57748,7 @@ function baseGet(object, path) { module.exports = baseGet; -},{"./_castPath":291,"./_toKey":375}],257:[function(require,module,exports){ +},{"./_castPath":297,"./_toKey":381}],263:[function(require,module,exports){ var arrayPush = require('./_arrayPush'), isArray = require('./isArray'); @@ -55360,7 +57770,7 @@ function baseGetAllKeys(object, keysFunc, symbolsFunc) { module.exports = baseGetAllKeys; -},{"./_arrayPush":242,"./isArray":391}],258:[function(require,module,exports){ +},{"./_arrayPush":248,"./isArray":397}],264:[function(require,module,exports){ var Symbol = require('./_Symbol'), getRawTag = require('./_getRawTag'), objectToString = require('./_objectToString'); @@ -55390,7 +57800,7 @@ function baseGetTag(value) { module.exports = baseGetTag; -},{"./_Symbol":232,"./_getRawTag":320,"./_objectToString":359}],259:[function(require,module,exports){ +},{"./_Symbol":238,"./_getRawTag":326,"./_objectToString":365}],265:[function(require,module,exports){ /** Used for built-in method references. */ var objectProto = Object.prototype; @@ -55411,7 +57821,7 @@ function baseHas(object, key) { module.exports = baseHas; -},{}],260:[function(require,module,exports){ +},{}],266:[function(require,module,exports){ /** * The base implementation of `_.hasIn` without support for deep paths. * @@ -55426,7 +57836,7 @@ function baseHasIn(object, key) { module.exports = baseHasIn; -},{}],261:[function(require,module,exports){ +},{}],267:[function(require,module,exports){ var baseFindIndex = require('./_baseFindIndex'), baseIsNaN = require('./_baseIsNaN'), strictIndexOf = require('./_strictIndexOf'); @@ -55448,7 +57858,7 @@ function baseIndexOf(array, value, fromIndex) { module.exports = baseIndexOf; -},{"./_baseFindIndex":252,"./_baseIsNaN":267,"./_strictIndexOf":373}],262:[function(require,module,exports){ +},{"./_baseFindIndex":258,"./_baseIsNaN":273,"./_strictIndexOf":379}],268:[function(require,module,exports){ var baseGetTag = require('./_baseGetTag'), isObjectLike = require('./isObjectLike'); @@ -55468,7 +57878,7 @@ function baseIsArguments(value) { module.exports = baseIsArguments; -},{"./_baseGetTag":258,"./isObjectLike":399}],263:[function(require,module,exports){ +},{"./_baseGetTag":264,"./isObjectLike":405}],269:[function(require,module,exports){ var baseIsEqualDeep = require('./_baseIsEqualDeep'), isObjectLike = require('./isObjectLike'); @@ -55498,7 +57908,7 @@ function baseIsEqual(value, other, bitmask, customizer, stack) { module.exports = baseIsEqual; -},{"./_baseIsEqualDeep":264,"./isObjectLike":399}],264:[function(require,module,exports){ +},{"./_baseIsEqualDeep":270,"./isObjectLike":405}],270:[function(require,module,exports){ var Stack = require('./_Stack'), equalArrays = require('./_equalArrays'), equalByTag = require('./_equalByTag'), @@ -55583,7 +57993,7 @@ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { module.exports = baseIsEqualDeep; -},{"./_Stack":231,"./_equalArrays":310,"./_equalByTag":311,"./_equalObjects":312,"./_getTag":323,"./isArray":391,"./isBuffer":393,"./isTypedArray":405}],265:[function(require,module,exports){ +},{"./_Stack":237,"./_equalArrays":316,"./_equalByTag":317,"./_equalObjects":318,"./_getTag":329,"./isArray":397,"./isBuffer":399,"./isTypedArray":411}],271:[function(require,module,exports){ var getTag = require('./_getTag'), isObjectLike = require('./isObjectLike'); @@ -55603,7 +58013,7 @@ function baseIsMap(value) { module.exports = baseIsMap; -},{"./_getTag":323,"./isObjectLike":399}],266:[function(require,module,exports){ +},{"./_getTag":329,"./isObjectLike":405}],272:[function(require,module,exports){ var Stack = require('./_Stack'), baseIsEqual = require('./_baseIsEqual'); @@ -55667,7 +58077,7 @@ function baseIsMatch(object, source, matchData, customizer) { module.exports = baseIsMatch; -},{"./_Stack":231,"./_baseIsEqual":263}],267:[function(require,module,exports){ +},{"./_Stack":237,"./_baseIsEqual":269}],273:[function(require,module,exports){ /** * The base implementation of `_.isNaN` without support for number objects. * @@ -55681,7 +58091,7 @@ function baseIsNaN(value) { module.exports = baseIsNaN; -},{}],268:[function(require,module,exports){ +},{}],274:[function(require,module,exports){ var isFunction = require('./isFunction'), isMasked = require('./_isMasked'), isObject = require('./isObject'), @@ -55730,7 +58140,7 @@ function baseIsNative(value) { module.exports = baseIsNative; -},{"./_isMasked":339,"./_toSource":376,"./isFunction":394,"./isObject":398}],269:[function(require,module,exports){ +},{"./_isMasked":345,"./_toSource":382,"./isFunction":400,"./isObject":404}],275:[function(require,module,exports){ var baseGetTag = require('./_baseGetTag'), isObjectLike = require('./isObjectLike'); @@ -55750,7 +58160,7 @@ function baseIsRegExp(value) { module.exports = baseIsRegExp; -},{"./_baseGetTag":258,"./isObjectLike":399}],270:[function(require,module,exports){ +},{"./_baseGetTag":264,"./isObjectLike":405}],276:[function(require,module,exports){ var getTag = require('./_getTag'), isObjectLike = require('./isObjectLike'); @@ -55770,7 +58180,7 @@ function baseIsSet(value) { module.exports = baseIsSet; -},{"./_getTag":323,"./isObjectLike":399}],271:[function(require,module,exports){ +},{"./_getTag":329,"./isObjectLike":405}],277:[function(require,module,exports){ var baseGetTag = require('./_baseGetTag'), isLength = require('./isLength'), isObjectLike = require('./isObjectLike'); @@ -55832,7 +58242,7 @@ function baseIsTypedArray(value) { module.exports = baseIsTypedArray; -},{"./_baseGetTag":258,"./isLength":396,"./isObjectLike":399}],272:[function(require,module,exports){ +},{"./_baseGetTag":264,"./isLength":402,"./isObjectLike":405}],278:[function(require,module,exports){ var baseMatches = require('./_baseMatches'), baseMatchesProperty = require('./_baseMatchesProperty'), identity = require('./identity'), @@ -55865,7 +58275,7 @@ function baseIteratee(value) { module.exports = baseIteratee; -},{"./_baseMatches":276,"./_baseMatchesProperty":277,"./identity":388,"./isArray":391,"./property":410}],273:[function(require,module,exports){ +},{"./_baseMatches":282,"./_baseMatchesProperty":283,"./identity":394,"./isArray":397,"./property":416}],279:[function(require,module,exports){ var isPrototype = require('./_isPrototype'), nativeKeys = require('./_nativeKeys'); @@ -55897,7 +58307,7 @@ function baseKeys(object) { module.exports = baseKeys; -},{"./_isPrototype":340,"./_nativeKeys":356}],274:[function(require,module,exports){ +},{"./_isPrototype":346,"./_nativeKeys":362}],280:[function(require,module,exports){ var isObject = require('./isObject'), isPrototype = require('./_isPrototype'), nativeKeysIn = require('./_nativeKeysIn'); @@ -55932,7 +58342,7 @@ function baseKeysIn(object) { module.exports = baseKeysIn; -},{"./_isPrototype":340,"./_nativeKeysIn":357,"./isObject":398}],275:[function(require,module,exports){ +},{"./_isPrototype":346,"./_nativeKeysIn":363,"./isObject":404}],281:[function(require,module,exports){ var baseEach = require('./_baseEach'), isArrayLike = require('./isArrayLike'); @@ -55956,7 +58366,7 @@ function baseMap(collection, iteratee) { module.exports = baseMap; -},{"./_baseEach":251,"./isArrayLike":392}],276:[function(require,module,exports){ +},{"./_baseEach":257,"./isArrayLike":398}],282:[function(require,module,exports){ var baseIsMatch = require('./_baseIsMatch'), getMatchData = require('./_getMatchData'), matchesStrictComparable = require('./_matchesStrictComparable'); @@ -55980,7 +58390,7 @@ function baseMatches(source) { module.exports = baseMatches; -},{"./_baseIsMatch":266,"./_getMatchData":317,"./_matchesStrictComparable":353}],277:[function(require,module,exports){ +},{"./_baseIsMatch":272,"./_getMatchData":323,"./_matchesStrictComparable":359}],283:[function(require,module,exports){ var baseIsEqual = require('./_baseIsEqual'), get = require('./get'), hasIn = require('./hasIn'), @@ -56015,7 +58425,7 @@ function baseMatchesProperty(path, srcValue) { module.exports = baseMatchesProperty; -},{"./_baseIsEqual":263,"./_isKey":337,"./_isStrictComparable":341,"./_matchesStrictComparable":353,"./_toKey":375,"./get":385,"./hasIn":387}],278:[function(require,module,exports){ +},{"./_baseIsEqual":269,"./_isKey":343,"./_isStrictComparable":347,"./_matchesStrictComparable":359,"./_toKey":381,"./get":391,"./hasIn":393}],284:[function(require,module,exports){ var arrayMap = require('./_arrayMap'), baseIteratee = require('./_baseIteratee'), baseMap = require('./_baseMap'), @@ -56051,7 +58461,7 @@ function baseOrderBy(collection, iteratees, orders) { module.exports = baseOrderBy; -},{"./_arrayMap":241,"./_baseIteratee":272,"./_baseMap":275,"./_baseSortBy":284,"./_baseUnary":287,"./_compareMultiple":299,"./identity":388}],279:[function(require,module,exports){ +},{"./_arrayMap":247,"./_baseIteratee":278,"./_baseMap":281,"./_baseSortBy":290,"./_baseUnary":293,"./_compareMultiple":305,"./identity":394}],285:[function(require,module,exports){ /** * The base implementation of `_.property` without support for deep paths. * @@ -56067,7 +58477,7 @@ function baseProperty(key) { module.exports = baseProperty; -},{}],280:[function(require,module,exports){ +},{}],286:[function(require,module,exports){ var baseGet = require('./_baseGet'); /** @@ -56085,7 +58495,7 @@ function basePropertyDeep(path) { module.exports = basePropertyDeep; -},{"./_baseGet":256}],281:[function(require,module,exports){ +},{"./_baseGet":262}],287:[function(require,module,exports){ /** Used as references for various `Number` constants. */ var MAX_SAFE_INTEGER = 9007199254740991; @@ -56122,7 +58532,7 @@ function baseRepeat(string, n) { module.exports = baseRepeat; -},{}],282:[function(require,module,exports){ +},{}],288:[function(require,module,exports){ var identity = require('./identity'), overRest = require('./_overRest'), setToString = require('./_setToString'); @@ -56141,7 +58551,7 @@ function baseRest(func, start) { module.exports = baseRest; -},{"./_overRest":361,"./_setToString":366,"./identity":388}],283:[function(require,module,exports){ +},{"./_overRest":367,"./_setToString":372,"./identity":394}],289:[function(require,module,exports){ var constant = require('./constant'), defineProperty = require('./_defineProperty'), identity = require('./identity'); @@ -56165,7 +58575,7 @@ var baseSetToString = !defineProperty ? identity : function(func, string) { module.exports = baseSetToString; -},{"./_defineProperty":309,"./constant":380,"./identity":388}],284:[function(require,module,exports){ +},{"./_defineProperty":315,"./constant":386,"./identity":394}],290:[function(require,module,exports){ /** * The base implementation of `_.sortBy` which uses `comparer` to define the * sort order of `array` and replaces criteria objects with their corresponding @@ -56188,7 +58598,7 @@ function baseSortBy(array, comparer) { module.exports = baseSortBy; -},{}],285:[function(require,module,exports){ +},{}],291:[function(require,module,exports){ /** * The base implementation of `_.times` without support for iteratee shorthands * or max array length checks. @@ -56210,7 +58620,7 @@ function baseTimes(n, iteratee) { module.exports = baseTimes; -},{}],286:[function(require,module,exports){ +},{}],292:[function(require,module,exports){ var Symbol = require('./_Symbol'), arrayMap = require('./_arrayMap'), isArray = require('./isArray'), @@ -56249,7 +58659,7 @@ function baseToString(value) { module.exports = baseToString; -},{"./_Symbol":232,"./_arrayMap":241,"./isArray":391,"./isSymbol":404}],287:[function(require,module,exports){ +},{"./_Symbol":238,"./_arrayMap":247,"./isArray":397,"./isSymbol":410}],293:[function(require,module,exports){ /** * The base implementation of `_.unary` without support for storing metadata. * @@ -56265,7 +58675,7 @@ function baseUnary(func) { module.exports = baseUnary; -},{}],288:[function(require,module,exports){ +},{}],294:[function(require,module,exports){ var SetCache = require('./_SetCache'), arrayIncludes = require('./_arrayIncludes'), arrayIncludesWith = require('./_arrayIncludesWith'), @@ -56339,7 +58749,7 @@ function baseUniq(array, iteratee, comparator) { module.exports = baseUniq; -},{"./_SetCache":230,"./_arrayIncludes":238,"./_arrayIncludesWith":239,"./_cacheHas":290,"./_createSet":308,"./_setToArray":365}],289:[function(require,module,exports){ +},{"./_SetCache":236,"./_arrayIncludes":244,"./_arrayIncludesWith":245,"./_cacheHas":296,"./_createSet":314,"./_setToArray":371}],295:[function(require,module,exports){ var arrayMap = require('./_arrayMap'); /** @@ -56360,7 +58770,7 @@ function baseValues(object, props) { module.exports = baseValues; -},{"./_arrayMap":241}],290:[function(require,module,exports){ +},{"./_arrayMap":247}],296:[function(require,module,exports){ /** * Checks if a `cache` value for `key` exists. * @@ -56375,7 +58785,7 @@ function cacheHas(cache, key) { module.exports = cacheHas; -},{}],291:[function(require,module,exports){ +},{}],297:[function(require,module,exports){ var isArray = require('./isArray'), isKey = require('./_isKey'), stringToPath = require('./_stringToPath'), @@ -56398,7 +58808,7 @@ function castPath(value, object) { module.exports = castPath; -},{"./_isKey":337,"./_stringToPath":374,"./isArray":391,"./toString":418}],292:[function(require,module,exports){ +},{"./_isKey":343,"./_stringToPath":380,"./isArray":397,"./toString":424}],298:[function(require,module,exports){ var Uint8Array = require('./_Uint8Array'); /** @@ -56416,7 +58826,7 @@ function cloneArrayBuffer(arrayBuffer) { module.exports = cloneArrayBuffer; -},{"./_Uint8Array":233}],293:[function(require,module,exports){ +},{"./_Uint8Array":239}],299:[function(require,module,exports){ var root = require('./_root'); /** Detect free variable `exports`. */ @@ -56453,7 +58863,7 @@ function cloneBuffer(buffer, isDeep) { module.exports = cloneBuffer; -},{"./_root":362}],294:[function(require,module,exports){ +},{"./_root":368}],300:[function(require,module,exports){ var cloneArrayBuffer = require('./_cloneArrayBuffer'); /** @@ -56471,7 +58881,7 @@ function cloneDataView(dataView, isDeep) { module.exports = cloneDataView; -},{"./_cloneArrayBuffer":292}],295:[function(require,module,exports){ +},{"./_cloneArrayBuffer":298}],301:[function(require,module,exports){ /** Used to match `RegExp` flags from their coerced string values. */ var reFlags = /\w*$/; @@ -56490,7 +58900,7 @@ function cloneRegExp(regexp) { module.exports = cloneRegExp; -},{}],296:[function(require,module,exports){ +},{}],302:[function(require,module,exports){ var Symbol = require('./_Symbol'); /** Used to convert symbols to primitives and strings. */ @@ -56510,7 +58920,7 @@ function cloneSymbol(symbol) { module.exports = cloneSymbol; -},{"./_Symbol":232}],297:[function(require,module,exports){ +},{"./_Symbol":238}],303:[function(require,module,exports){ var cloneArrayBuffer = require('./_cloneArrayBuffer'); /** @@ -56528,7 +58938,7 @@ function cloneTypedArray(typedArray, isDeep) { module.exports = cloneTypedArray; -},{"./_cloneArrayBuffer":292}],298:[function(require,module,exports){ +},{"./_cloneArrayBuffer":298}],304:[function(require,module,exports){ var isSymbol = require('./isSymbol'); /** @@ -56571,7 +58981,7 @@ function compareAscending(value, other) { module.exports = compareAscending; -},{"./isSymbol":404}],299:[function(require,module,exports){ +},{"./isSymbol":410}],305:[function(require,module,exports){ var compareAscending = require('./_compareAscending'); /** @@ -56617,7 +59027,7 @@ function compareMultiple(object, other, orders) { module.exports = compareMultiple; -},{"./_compareAscending":298}],300:[function(require,module,exports){ +},{"./_compareAscending":304}],306:[function(require,module,exports){ /** * Copies the values of `source` to `array`. * @@ -56639,7 +59049,7 @@ function copyArray(source, array) { module.exports = copyArray; -},{}],301:[function(require,module,exports){ +},{}],307:[function(require,module,exports){ var assignValue = require('./_assignValue'), baseAssignValue = require('./_baseAssignValue'); @@ -56681,7 +59091,7 @@ function copyObject(source, props, object, customizer) { module.exports = copyObject; -},{"./_assignValue":244,"./_baseAssignValue":248}],302:[function(require,module,exports){ +},{"./_assignValue":250,"./_baseAssignValue":254}],308:[function(require,module,exports){ var copyObject = require('./_copyObject'), getSymbols = require('./_getSymbols'); @@ -56699,7 +59109,7 @@ function copySymbols(source, object) { module.exports = copySymbols; -},{"./_copyObject":301,"./_getSymbols":321}],303:[function(require,module,exports){ +},{"./_copyObject":307,"./_getSymbols":327}],309:[function(require,module,exports){ var copyObject = require('./_copyObject'), getSymbolsIn = require('./_getSymbolsIn'); @@ -56717,7 +59127,7 @@ function copySymbolsIn(source, object) { module.exports = copySymbolsIn; -},{"./_copyObject":301,"./_getSymbolsIn":322}],304:[function(require,module,exports){ +},{"./_copyObject":307,"./_getSymbolsIn":328}],310:[function(require,module,exports){ var root = require('./_root'); /** Used to detect overreaching core-js shims. */ @@ -56725,7 +59135,7 @@ var coreJsData = root['__core-js_shared__']; module.exports = coreJsData; -},{"./_root":362}],305:[function(require,module,exports){ +},{"./_root":368}],311:[function(require,module,exports){ var baseRest = require('./_baseRest'), isIterateeCall = require('./_isIterateeCall'); @@ -56764,7 +59174,7 @@ function createAssigner(assigner) { module.exports = createAssigner; -},{"./_baseRest":282,"./_isIterateeCall":336}],306:[function(require,module,exports){ +},{"./_baseRest":288,"./_isIterateeCall":342}],312:[function(require,module,exports){ var isArrayLike = require('./isArrayLike'); /** @@ -56798,7 +59208,7 @@ function createBaseEach(eachFunc, fromRight) { module.exports = createBaseEach; -},{"./isArrayLike":392}],307:[function(require,module,exports){ +},{"./isArrayLike":398}],313:[function(require,module,exports){ /** * Creates a base function for methods like `_.forIn` and `_.forOwn`. * @@ -56825,7 +59235,7 @@ function createBaseFor(fromRight) { module.exports = createBaseFor; -},{}],308:[function(require,module,exports){ +},{}],314:[function(require,module,exports){ var Set = require('./_Set'), noop = require('./noop'), setToArray = require('./_setToArray'); @@ -56846,7 +59256,7 @@ var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop module.exports = createSet; -},{"./_Set":229,"./_setToArray":365,"./noop":409}],309:[function(require,module,exports){ +},{"./_Set":235,"./_setToArray":371,"./noop":415}],315:[function(require,module,exports){ var getNative = require('./_getNative'); var defineProperty = (function() { @@ -56859,7 +59269,7 @@ var defineProperty = (function() { module.exports = defineProperty; -},{"./_getNative":318}],310:[function(require,module,exports){ +},{"./_getNative":324}],316:[function(require,module,exports){ var SetCache = require('./_SetCache'), arraySome = require('./_arraySome'), cacheHas = require('./_cacheHas'); @@ -56944,7 +59354,7 @@ function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { module.exports = equalArrays; -},{"./_SetCache":230,"./_arraySome":243,"./_cacheHas":290}],311:[function(require,module,exports){ +},{"./_SetCache":236,"./_arraySome":249,"./_cacheHas":296}],317:[function(require,module,exports){ var Symbol = require('./_Symbol'), Uint8Array = require('./_Uint8Array'), eq = require('./eq'), @@ -57058,7 +59468,7 @@ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { module.exports = equalByTag; -},{"./_Symbol":232,"./_Uint8Array":233,"./_equalArrays":310,"./_mapToArray":352,"./_setToArray":365,"./eq":382}],312:[function(require,module,exports){ +},{"./_Symbol":238,"./_Uint8Array":239,"./_equalArrays":316,"./_mapToArray":358,"./_setToArray":371,"./eq":388}],318:[function(require,module,exports){ var getAllKeys = require('./_getAllKeys'); /** Used to compose bitmasks for value comparisons. */ @@ -57149,7 +59559,7 @@ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { module.exports = equalObjects; -},{"./_getAllKeys":314}],313:[function(require,module,exports){ +},{"./_getAllKeys":320}],319:[function(require,module,exports){ (function (global){ /** Detect free variable `global` from Node.js. */ var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; @@ -57157,7 +59567,7 @@ var freeGlobal = typeof global == 'object' && global && global.Object === Object module.exports = freeGlobal; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],314:[function(require,module,exports){ +},{}],320:[function(require,module,exports){ var baseGetAllKeys = require('./_baseGetAllKeys'), getSymbols = require('./_getSymbols'), keys = require('./keys'); @@ -57175,7 +59585,7 @@ function getAllKeys(object) { module.exports = getAllKeys; -},{"./_baseGetAllKeys":257,"./_getSymbols":321,"./keys":406}],315:[function(require,module,exports){ +},{"./_baseGetAllKeys":263,"./_getSymbols":327,"./keys":412}],321:[function(require,module,exports){ var baseGetAllKeys = require('./_baseGetAllKeys'), getSymbolsIn = require('./_getSymbolsIn'), keysIn = require('./keysIn'); @@ -57194,7 +59604,7 @@ function getAllKeysIn(object) { module.exports = getAllKeysIn; -},{"./_baseGetAllKeys":257,"./_getSymbolsIn":322,"./keysIn":407}],316:[function(require,module,exports){ +},{"./_baseGetAllKeys":263,"./_getSymbolsIn":328,"./keysIn":413}],322:[function(require,module,exports){ var isKeyable = require('./_isKeyable'); /** @@ -57214,7 +59624,7 @@ function getMapData(map, key) { module.exports = getMapData; -},{"./_isKeyable":338}],317:[function(require,module,exports){ +},{"./_isKeyable":344}],323:[function(require,module,exports){ var isStrictComparable = require('./_isStrictComparable'), keys = require('./keys'); @@ -57240,7 +59650,7 @@ function getMatchData(object) { module.exports = getMatchData; -},{"./_isStrictComparable":341,"./keys":406}],318:[function(require,module,exports){ +},{"./_isStrictComparable":347,"./keys":412}],324:[function(require,module,exports){ var baseIsNative = require('./_baseIsNative'), getValue = require('./_getValue'); @@ -57259,7 +59669,7 @@ function getNative(object, key) { module.exports = getNative; -},{"./_baseIsNative":268,"./_getValue":324}],319:[function(require,module,exports){ +},{"./_baseIsNative":274,"./_getValue":330}],325:[function(require,module,exports){ var overArg = require('./_overArg'); /** Built-in value references. */ @@ -57267,7 +59677,7 @@ var getPrototype = overArg(Object.getPrototypeOf, Object); module.exports = getPrototype; -},{"./_overArg":360}],320:[function(require,module,exports){ +},{"./_overArg":366}],326:[function(require,module,exports){ var Symbol = require('./_Symbol'); /** Used for built-in method references. */ @@ -57315,7 +59725,7 @@ function getRawTag(value) { module.exports = getRawTag; -},{"./_Symbol":232}],321:[function(require,module,exports){ +},{"./_Symbol":238}],327:[function(require,module,exports){ var arrayFilter = require('./_arrayFilter'), stubArray = require('./stubArray'); @@ -57347,7 +59757,7 @@ var getSymbols = !nativeGetSymbols ? stubArray : function(object) { module.exports = getSymbols; -},{"./_arrayFilter":237,"./stubArray":413}],322:[function(require,module,exports){ +},{"./_arrayFilter":243,"./stubArray":419}],328:[function(require,module,exports){ var arrayPush = require('./_arrayPush'), getPrototype = require('./_getPrototype'), getSymbols = require('./_getSymbols'), @@ -57374,7 +59784,7 @@ var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) { module.exports = getSymbolsIn; -},{"./_arrayPush":242,"./_getPrototype":319,"./_getSymbols":321,"./stubArray":413}],323:[function(require,module,exports){ +},{"./_arrayPush":248,"./_getPrototype":325,"./_getSymbols":327,"./stubArray":419}],329:[function(require,module,exports){ var DataView = require('./_DataView'), Map = require('./_Map'), Promise = require('./_Promise'), @@ -57434,7 +59844,7 @@ if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || module.exports = getTag; -},{"./_DataView":223,"./_Map":226,"./_Promise":228,"./_Set":229,"./_WeakMap":234,"./_baseGetTag":258,"./_toSource":376}],324:[function(require,module,exports){ +},{"./_DataView":229,"./_Map":232,"./_Promise":234,"./_Set":235,"./_WeakMap":240,"./_baseGetTag":264,"./_toSource":382}],330:[function(require,module,exports){ /** * Gets the value at `key` of `object`. * @@ -57449,7 +59859,7 @@ function getValue(object, key) { module.exports = getValue; -},{}],325:[function(require,module,exports){ +},{}],331:[function(require,module,exports){ var castPath = require('./_castPath'), isArguments = require('./isArguments'), isArray = require('./isArray'), @@ -57490,7 +59900,7 @@ function hasPath(object, path, hasFunc) { module.exports = hasPath; -},{"./_castPath":291,"./_isIndex":335,"./_toKey":375,"./isArguments":390,"./isArray":391,"./isLength":396}],326:[function(require,module,exports){ +},{"./_castPath":297,"./_isIndex":341,"./_toKey":381,"./isArguments":396,"./isArray":397,"./isLength":402}],332:[function(require,module,exports){ var nativeCreate = require('./_nativeCreate'); /** @@ -57507,7 +59917,7 @@ function hashClear() { module.exports = hashClear; -},{"./_nativeCreate":355}],327:[function(require,module,exports){ +},{"./_nativeCreate":361}],333:[function(require,module,exports){ /** * Removes `key` and its value from the hash. * @@ -57526,7 +59936,7 @@ function hashDelete(key) { module.exports = hashDelete; -},{}],328:[function(require,module,exports){ +},{}],334:[function(require,module,exports){ var nativeCreate = require('./_nativeCreate'); /** Used to stand-in for `undefined` hash values. */ @@ -57558,7 +59968,7 @@ function hashGet(key) { module.exports = hashGet; -},{"./_nativeCreate":355}],329:[function(require,module,exports){ +},{"./_nativeCreate":361}],335:[function(require,module,exports){ var nativeCreate = require('./_nativeCreate'); /** Used for built-in method references. */ @@ -57583,7 +59993,7 @@ function hashHas(key) { module.exports = hashHas; -},{"./_nativeCreate":355}],330:[function(require,module,exports){ +},{"./_nativeCreate":361}],336:[function(require,module,exports){ var nativeCreate = require('./_nativeCreate'); /** Used to stand-in for `undefined` hash values. */ @@ -57608,7 +60018,7 @@ function hashSet(key, value) { module.exports = hashSet; -},{"./_nativeCreate":355}],331:[function(require,module,exports){ +},{"./_nativeCreate":361}],337:[function(require,module,exports){ /** Used for built-in method references. */ var objectProto = Object.prototype; @@ -57636,7 +60046,7 @@ function initCloneArray(array) { module.exports = initCloneArray; -},{}],332:[function(require,module,exports){ +},{}],338:[function(require,module,exports){ var cloneArrayBuffer = require('./_cloneArrayBuffer'), cloneDataView = require('./_cloneDataView'), cloneRegExp = require('./_cloneRegExp'), @@ -57715,7 +60125,7 @@ function initCloneByTag(object, tag, isDeep) { module.exports = initCloneByTag; -},{"./_cloneArrayBuffer":292,"./_cloneDataView":294,"./_cloneRegExp":295,"./_cloneSymbol":296,"./_cloneTypedArray":297}],333:[function(require,module,exports){ +},{"./_cloneArrayBuffer":298,"./_cloneDataView":300,"./_cloneRegExp":301,"./_cloneSymbol":302,"./_cloneTypedArray":303}],339:[function(require,module,exports){ var baseCreate = require('./_baseCreate'), getPrototype = require('./_getPrototype'), isPrototype = require('./_isPrototype'); @@ -57735,7 +60145,7 @@ function initCloneObject(object) { module.exports = initCloneObject; -},{"./_baseCreate":250,"./_getPrototype":319,"./_isPrototype":340}],334:[function(require,module,exports){ +},{"./_baseCreate":256,"./_getPrototype":325,"./_isPrototype":346}],340:[function(require,module,exports){ var Symbol = require('./_Symbol'), isArguments = require('./isArguments'), isArray = require('./isArray'); @@ -57757,7 +60167,7 @@ function isFlattenable(value) { module.exports = isFlattenable; -},{"./_Symbol":232,"./isArguments":390,"./isArray":391}],335:[function(require,module,exports){ +},{"./_Symbol":238,"./isArguments":396,"./isArray":397}],341:[function(require,module,exports){ /** Used as references for various `Number` constants. */ var MAX_SAFE_INTEGER = 9007199254740991; @@ -57784,7 +60194,7 @@ function isIndex(value, length) { module.exports = isIndex; -},{}],336:[function(require,module,exports){ +},{}],342:[function(require,module,exports){ var eq = require('./eq'), isArrayLike = require('./isArrayLike'), isIndex = require('./_isIndex'), @@ -57816,7 +60226,7 @@ function isIterateeCall(value, index, object) { module.exports = isIterateeCall; -},{"./_isIndex":335,"./eq":382,"./isArrayLike":392,"./isObject":398}],337:[function(require,module,exports){ +},{"./_isIndex":341,"./eq":388,"./isArrayLike":398,"./isObject":404}],343:[function(require,module,exports){ var isArray = require('./isArray'), isSymbol = require('./isSymbol'); @@ -57847,7 +60257,7 @@ function isKey(value, object) { module.exports = isKey; -},{"./isArray":391,"./isSymbol":404}],338:[function(require,module,exports){ +},{"./isArray":397,"./isSymbol":410}],344:[function(require,module,exports){ /** * Checks if `value` is suitable for use as unique object key. * @@ -57864,7 +60274,7 @@ function isKeyable(value) { module.exports = isKeyable; -},{}],339:[function(require,module,exports){ +},{}],345:[function(require,module,exports){ var coreJsData = require('./_coreJsData'); /** Used to detect methods masquerading as native. */ @@ -57886,7 +60296,7 @@ function isMasked(func) { module.exports = isMasked; -},{"./_coreJsData":304}],340:[function(require,module,exports){ +},{"./_coreJsData":310}],346:[function(require,module,exports){ /** Used for built-in method references. */ var objectProto = Object.prototype; @@ -57906,7 +60316,7 @@ function isPrototype(value) { module.exports = isPrototype; -},{}],341:[function(require,module,exports){ +},{}],347:[function(require,module,exports){ var isObject = require('./isObject'); /** @@ -57923,7 +60333,7 @@ function isStrictComparable(value) { module.exports = isStrictComparable; -},{"./isObject":398}],342:[function(require,module,exports){ +},{"./isObject":404}],348:[function(require,module,exports){ /** * Removes all key-value entries from the list cache. * @@ -57938,7 +60348,7 @@ function listCacheClear() { module.exports = listCacheClear; -},{}],343:[function(require,module,exports){ +},{}],349:[function(require,module,exports){ var assocIndexOf = require('./_assocIndexOf'); /** Used for built-in method references. */ @@ -57975,7 +60385,7 @@ function listCacheDelete(key) { module.exports = listCacheDelete; -},{"./_assocIndexOf":245}],344:[function(require,module,exports){ +},{"./_assocIndexOf":251}],350:[function(require,module,exports){ var assocIndexOf = require('./_assocIndexOf'); /** @@ -57996,7 +60406,7 @@ function listCacheGet(key) { module.exports = listCacheGet; -},{"./_assocIndexOf":245}],345:[function(require,module,exports){ +},{"./_assocIndexOf":251}],351:[function(require,module,exports){ var assocIndexOf = require('./_assocIndexOf'); /** @@ -58014,7 +60424,7 @@ function listCacheHas(key) { module.exports = listCacheHas; -},{"./_assocIndexOf":245}],346:[function(require,module,exports){ +},{"./_assocIndexOf":251}],352:[function(require,module,exports){ var assocIndexOf = require('./_assocIndexOf'); /** @@ -58042,7 +60452,7 @@ function listCacheSet(key, value) { module.exports = listCacheSet; -},{"./_assocIndexOf":245}],347:[function(require,module,exports){ +},{"./_assocIndexOf":251}],353:[function(require,module,exports){ var Hash = require('./_Hash'), ListCache = require('./_ListCache'), Map = require('./_Map'); @@ -58065,7 +60475,7 @@ function mapCacheClear() { module.exports = mapCacheClear; -},{"./_Hash":224,"./_ListCache":225,"./_Map":226}],348:[function(require,module,exports){ +},{"./_Hash":230,"./_ListCache":231,"./_Map":232}],354:[function(require,module,exports){ var getMapData = require('./_getMapData'); /** @@ -58085,7 +60495,7 @@ function mapCacheDelete(key) { module.exports = mapCacheDelete; -},{"./_getMapData":316}],349:[function(require,module,exports){ +},{"./_getMapData":322}],355:[function(require,module,exports){ var getMapData = require('./_getMapData'); /** @@ -58103,7 +60513,7 @@ function mapCacheGet(key) { module.exports = mapCacheGet; -},{"./_getMapData":316}],350:[function(require,module,exports){ +},{"./_getMapData":322}],356:[function(require,module,exports){ var getMapData = require('./_getMapData'); /** @@ -58121,7 +60531,7 @@ function mapCacheHas(key) { module.exports = mapCacheHas; -},{"./_getMapData":316}],351:[function(require,module,exports){ +},{"./_getMapData":322}],357:[function(require,module,exports){ var getMapData = require('./_getMapData'); /** @@ -58145,7 +60555,7 @@ function mapCacheSet(key, value) { module.exports = mapCacheSet; -},{"./_getMapData":316}],352:[function(require,module,exports){ +},{"./_getMapData":322}],358:[function(require,module,exports){ /** * Converts `map` to its key-value pairs. * @@ -58165,7 +60575,7 @@ function mapToArray(map) { module.exports = mapToArray; -},{}],353:[function(require,module,exports){ +},{}],359:[function(require,module,exports){ /** * A specialized version of `matchesProperty` for source values suitable * for strict equality comparisons, i.e. `===`. @@ -58187,7 +60597,7 @@ function matchesStrictComparable(key, srcValue) { module.exports = matchesStrictComparable; -},{}],354:[function(require,module,exports){ +},{}],360:[function(require,module,exports){ var memoize = require('./memoize'); /** Used as the maximum memoize cache size. */ @@ -58215,7 +60625,7 @@ function memoizeCapped(func) { module.exports = memoizeCapped; -},{"./memoize":408}],355:[function(require,module,exports){ +},{"./memoize":414}],361:[function(require,module,exports){ var getNative = require('./_getNative'); /* Built-in method references that are verified to be native. */ @@ -58223,7 +60633,7 @@ var nativeCreate = getNative(Object, 'create'); module.exports = nativeCreate; -},{"./_getNative":318}],356:[function(require,module,exports){ +},{"./_getNative":324}],362:[function(require,module,exports){ var overArg = require('./_overArg'); /* Built-in method references for those with the same name as other `lodash` methods. */ @@ -58231,7 +60641,7 @@ var nativeKeys = overArg(Object.keys, Object); module.exports = nativeKeys; -},{"./_overArg":360}],357:[function(require,module,exports){ +},{"./_overArg":366}],363:[function(require,module,exports){ /** * This function is like * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) @@ -58253,7 +60663,7 @@ function nativeKeysIn(object) { module.exports = nativeKeysIn; -},{}],358:[function(require,module,exports){ +},{}],364:[function(require,module,exports){ var freeGlobal = require('./_freeGlobal'); /** Detect free variable `exports`. */ @@ -58285,7 +60695,7 @@ var nodeUtil = (function() { module.exports = nodeUtil; -},{"./_freeGlobal":313}],359:[function(require,module,exports){ +},{"./_freeGlobal":319}],365:[function(require,module,exports){ /** Used for built-in method references. */ var objectProto = Object.prototype; @@ -58309,7 +60719,7 @@ function objectToString(value) { module.exports = objectToString; -},{}],360:[function(require,module,exports){ +},{}],366:[function(require,module,exports){ /** * Creates a unary function that invokes `func` with its argument transformed. * @@ -58326,7 +60736,7 @@ function overArg(func, transform) { module.exports = overArg; -},{}],361:[function(require,module,exports){ +},{}],367:[function(require,module,exports){ var apply = require('./_apply'); /* Built-in method references for those with the same name as other `lodash` methods. */ @@ -58364,7 +60774,7 @@ function overRest(func, start, transform) { module.exports = overRest; -},{"./_apply":235}],362:[function(require,module,exports){ +},{"./_apply":241}],368:[function(require,module,exports){ var freeGlobal = require('./_freeGlobal'); /** Detect free variable `self`. */ @@ -58375,7 +60785,7 @@ var root = freeGlobal || freeSelf || Function('return this')(); module.exports = root; -},{"./_freeGlobal":313}],363:[function(require,module,exports){ +},{"./_freeGlobal":319}],369:[function(require,module,exports){ /** Used to stand-in for `undefined` hash values. */ var HASH_UNDEFINED = '__lodash_hash_undefined__'; @@ -58396,7 +60806,7 @@ function setCacheAdd(value) { module.exports = setCacheAdd; -},{}],364:[function(require,module,exports){ +},{}],370:[function(require,module,exports){ /** * Checks if `value` is in the array cache. * @@ -58412,7 +60822,7 @@ function setCacheHas(value) { module.exports = setCacheHas; -},{}],365:[function(require,module,exports){ +},{}],371:[function(require,module,exports){ /** * Converts `set` to an array of its values. * @@ -58432,7 +60842,7 @@ function setToArray(set) { module.exports = setToArray; -},{}],366:[function(require,module,exports){ +},{}],372:[function(require,module,exports){ var baseSetToString = require('./_baseSetToString'), shortOut = require('./_shortOut'); @@ -58448,7 +60858,7 @@ var setToString = shortOut(baseSetToString); module.exports = setToString; -},{"./_baseSetToString":283,"./_shortOut":367}],367:[function(require,module,exports){ +},{"./_baseSetToString":289,"./_shortOut":373}],373:[function(require,module,exports){ /** Used to detect hot functions by number of calls within a span of milliseconds. */ var HOT_COUNT = 800, HOT_SPAN = 16; @@ -58487,7 +60897,7 @@ function shortOut(func) { module.exports = shortOut; -},{}],368:[function(require,module,exports){ +},{}],374:[function(require,module,exports){ var ListCache = require('./_ListCache'); /** @@ -58504,7 +60914,7 @@ function stackClear() { module.exports = stackClear; -},{"./_ListCache":225}],369:[function(require,module,exports){ +},{"./_ListCache":231}],375:[function(require,module,exports){ /** * Removes `key` and its value from the stack. * @@ -58524,7 +60934,7 @@ function stackDelete(key) { module.exports = stackDelete; -},{}],370:[function(require,module,exports){ +},{}],376:[function(require,module,exports){ /** * Gets the stack value for `key`. * @@ -58540,7 +60950,7 @@ function stackGet(key) { module.exports = stackGet; -},{}],371:[function(require,module,exports){ +},{}],377:[function(require,module,exports){ /** * Checks if a stack value for `key` exists. * @@ -58556,7 +60966,7 @@ function stackHas(key) { module.exports = stackHas; -},{}],372:[function(require,module,exports){ +},{}],378:[function(require,module,exports){ var ListCache = require('./_ListCache'), Map = require('./_Map'), MapCache = require('./_MapCache'); @@ -58592,7 +61002,7 @@ function stackSet(key, value) { module.exports = stackSet; -},{"./_ListCache":225,"./_Map":226,"./_MapCache":227}],373:[function(require,module,exports){ +},{"./_ListCache":231,"./_Map":232,"./_MapCache":233}],379:[function(require,module,exports){ /** * A specialized version of `_.indexOf` which performs strict equality * comparisons of values, i.e. `===`. @@ -58617,7 +61027,7 @@ function strictIndexOf(array, value, fromIndex) { module.exports = strictIndexOf; -},{}],374:[function(require,module,exports){ +},{}],380:[function(require,module,exports){ var memoizeCapped = require('./_memoizeCapped'); /** Used to match property names within property paths. */ @@ -58646,7 +61056,7 @@ var stringToPath = memoizeCapped(function(string) { module.exports = stringToPath; -},{"./_memoizeCapped":354}],375:[function(require,module,exports){ +},{"./_memoizeCapped":360}],381:[function(require,module,exports){ var isSymbol = require('./isSymbol'); /** Used as references for various `Number` constants. */ @@ -58669,7 +61079,7 @@ function toKey(value) { module.exports = toKey; -},{"./isSymbol":404}],376:[function(require,module,exports){ +},{"./isSymbol":410}],382:[function(require,module,exports){ /** Used for built-in method references. */ var funcProto = Function.prototype; @@ -58697,7 +61107,7 @@ function toSource(func) { module.exports = toSource; -},{}],377:[function(require,module,exports){ +},{}],383:[function(require,module,exports){ var copyObject = require('./_copyObject'), createAssigner = require('./_createAssigner'), keysIn = require('./keysIn'); @@ -58739,7 +61149,7 @@ var assignIn = createAssigner(function(object, source) { module.exports = assignIn; -},{"./_copyObject":301,"./_createAssigner":305,"./keysIn":407}],378:[function(require,module,exports){ +},{"./_copyObject":307,"./_createAssigner":311,"./keysIn":413}],384:[function(require,module,exports){ var baseClone = require('./_baseClone'); /** Used to compose bitmasks for cloning. */ @@ -58777,7 +61187,7 @@ function clone(value) { module.exports = clone; -},{"./_baseClone":249}],379:[function(require,module,exports){ +},{"./_baseClone":255}],385:[function(require,module,exports){ var baseClone = require('./_baseClone'); /** Used to compose bitmasks for cloning. */ @@ -58808,7 +61218,7 @@ function cloneDeep(value) { module.exports = cloneDeep; -},{"./_baseClone":249}],380:[function(require,module,exports){ +},{"./_baseClone":255}],386:[function(require,module,exports){ /** * Creates a function that returns `value`. * @@ -58836,7 +61246,7 @@ function constant(value) { module.exports = constant; -},{}],381:[function(require,module,exports){ +},{}],387:[function(require,module,exports){ var baseRest = require('./_baseRest'), eq = require('./eq'), isIterateeCall = require('./_isIterateeCall'), @@ -58902,7 +61312,7 @@ var defaults = baseRest(function(object, sources) { module.exports = defaults; -},{"./_baseRest":282,"./_isIterateeCall":336,"./eq":382,"./keysIn":407}],382:[function(require,module,exports){ +},{"./_baseRest":288,"./_isIterateeCall":342,"./eq":388,"./keysIn":413}],388:[function(require,module,exports){ /** * Performs a * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) @@ -58941,7 +61351,7 @@ function eq(value, other) { module.exports = eq; -},{}],383:[function(require,module,exports){ +},{}],389:[function(require,module,exports){ var toString = require('./toString'); /** @@ -58975,10 +61385,10 @@ function escapeRegExp(string) { module.exports = escapeRegExp; -},{"./toString":418}],384:[function(require,module,exports){ +},{"./toString":424}],390:[function(require,module,exports){ module.exports = require('./assignIn'); -},{"./assignIn":377}],385:[function(require,module,exports){ +},{"./assignIn":383}],391:[function(require,module,exports){ var baseGet = require('./_baseGet'); /** @@ -59013,7 +61423,7 @@ function get(object, path, defaultValue) { module.exports = get; -},{"./_baseGet":256}],386:[function(require,module,exports){ +},{"./_baseGet":262}],392:[function(require,module,exports){ var baseHas = require('./_baseHas'), hasPath = require('./_hasPath'); @@ -59050,7 +61460,7 @@ function has(object, path) { module.exports = has; -},{"./_baseHas":259,"./_hasPath":325}],387:[function(require,module,exports){ +},{"./_baseHas":265,"./_hasPath":331}],393:[function(require,module,exports){ var baseHasIn = require('./_baseHasIn'), hasPath = require('./_hasPath'); @@ -59086,7 +61496,7 @@ function hasIn(object, path) { module.exports = hasIn; -},{"./_baseHasIn":260,"./_hasPath":325}],388:[function(require,module,exports){ +},{"./_baseHasIn":266,"./_hasPath":331}],394:[function(require,module,exports){ /** * This method returns the first argument it receives. * @@ -59109,7 +61519,7 @@ function identity(value) { module.exports = identity; -},{}],389:[function(require,module,exports){ +},{}],395:[function(require,module,exports){ var baseIndexOf = require('./_baseIndexOf'), isArrayLike = require('./isArrayLike'), isString = require('./isString'), @@ -59164,7 +61574,7 @@ function includes(collection, value, fromIndex, guard) { module.exports = includes; -},{"./_baseIndexOf":261,"./isArrayLike":392,"./isString":403,"./toInteger":416,"./values":420}],390:[function(require,module,exports){ +},{"./_baseIndexOf":267,"./isArrayLike":398,"./isString":409,"./toInteger":422,"./values":426}],396:[function(require,module,exports){ var baseIsArguments = require('./_baseIsArguments'), isObjectLike = require('./isObjectLike'); @@ -59202,7 +61612,7 @@ var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsAr module.exports = isArguments; -},{"./_baseIsArguments":262,"./isObjectLike":399}],391:[function(require,module,exports){ +},{"./_baseIsArguments":268,"./isObjectLike":405}],397:[function(require,module,exports){ /** * Checks if `value` is classified as an `Array` object. * @@ -59230,7 +61640,7 @@ var isArray = Array.isArray; module.exports = isArray; -},{}],392:[function(require,module,exports){ +},{}],398:[function(require,module,exports){ var isFunction = require('./isFunction'), isLength = require('./isLength'); @@ -59265,7 +61675,7 @@ function isArrayLike(value) { module.exports = isArrayLike; -},{"./isFunction":394,"./isLength":396}],393:[function(require,module,exports){ +},{"./isFunction":400,"./isLength":402}],399:[function(require,module,exports){ var root = require('./_root'), stubFalse = require('./stubFalse'); @@ -59305,7 +61715,7 @@ var isBuffer = nativeIsBuffer || stubFalse; module.exports = isBuffer; -},{"./_root":362,"./stubFalse":414}],394:[function(require,module,exports){ +},{"./_root":368,"./stubFalse":420}],400:[function(require,module,exports){ var baseGetTag = require('./_baseGetTag'), isObject = require('./isObject'); @@ -59344,7 +61754,7 @@ function isFunction(value) { module.exports = isFunction; -},{"./_baseGetTag":258,"./isObject":398}],395:[function(require,module,exports){ +},{"./_baseGetTag":264,"./isObject":404}],401:[function(require,module,exports){ var toInteger = require('./toInteger'); /** @@ -59379,7 +61789,7 @@ function isInteger(value) { module.exports = isInteger; -},{"./toInteger":416}],396:[function(require,module,exports){ +},{"./toInteger":422}],402:[function(require,module,exports){ /** Used as references for various `Number` constants. */ var MAX_SAFE_INTEGER = 9007199254740991; @@ -59416,7 +61826,7 @@ function isLength(value) { module.exports = isLength; -},{}],397:[function(require,module,exports){ +},{}],403:[function(require,module,exports){ var baseIsMap = require('./_baseIsMap'), baseUnary = require('./_baseUnary'), nodeUtil = require('./_nodeUtil'); @@ -59445,7 +61855,7 @@ var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap; module.exports = isMap; -},{"./_baseIsMap":265,"./_baseUnary":287,"./_nodeUtil":358}],398:[function(require,module,exports){ +},{"./_baseIsMap":271,"./_baseUnary":293,"./_nodeUtil":364}],404:[function(require,module,exports){ /** * Checks if `value` is the * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) @@ -59478,7 +61888,7 @@ function isObject(value) { module.exports = isObject; -},{}],399:[function(require,module,exports){ +},{}],405:[function(require,module,exports){ /** * Checks if `value` is object-like. A value is object-like if it's not `null` * and has a `typeof` result of "object". @@ -59509,7 +61919,7 @@ function isObjectLike(value) { module.exports = isObjectLike; -},{}],400:[function(require,module,exports){ +},{}],406:[function(require,module,exports){ var baseGetTag = require('./_baseGetTag'), getPrototype = require('./_getPrototype'), isObjectLike = require('./isObjectLike'); @@ -59573,7 +61983,7 @@ function isPlainObject(value) { module.exports = isPlainObject; -},{"./_baseGetTag":258,"./_getPrototype":319,"./isObjectLike":399}],401:[function(require,module,exports){ +},{"./_baseGetTag":264,"./_getPrototype":325,"./isObjectLike":405}],407:[function(require,module,exports){ var baseIsRegExp = require('./_baseIsRegExp'), baseUnary = require('./_baseUnary'), nodeUtil = require('./_nodeUtil'); @@ -59602,7 +62012,7 @@ var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp; module.exports = isRegExp; -},{"./_baseIsRegExp":269,"./_baseUnary":287,"./_nodeUtil":358}],402:[function(require,module,exports){ +},{"./_baseIsRegExp":275,"./_baseUnary":293,"./_nodeUtil":364}],408:[function(require,module,exports){ var baseIsSet = require('./_baseIsSet'), baseUnary = require('./_baseUnary'), nodeUtil = require('./_nodeUtil'); @@ -59631,7 +62041,7 @@ var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet; module.exports = isSet; -},{"./_baseIsSet":270,"./_baseUnary":287,"./_nodeUtil":358}],403:[function(require,module,exports){ +},{"./_baseIsSet":276,"./_baseUnary":293,"./_nodeUtil":364}],409:[function(require,module,exports){ var baseGetTag = require('./_baseGetTag'), isArray = require('./isArray'), isObjectLike = require('./isObjectLike'); @@ -59663,7 +62073,7 @@ function isString(value) { module.exports = isString; -},{"./_baseGetTag":258,"./isArray":391,"./isObjectLike":399}],404:[function(require,module,exports){ +},{"./_baseGetTag":264,"./isArray":397,"./isObjectLike":405}],410:[function(require,module,exports){ var baseGetTag = require('./_baseGetTag'), isObjectLike = require('./isObjectLike'); @@ -59694,7 +62104,7 @@ function isSymbol(value) { module.exports = isSymbol; -},{"./_baseGetTag":258,"./isObjectLike":399}],405:[function(require,module,exports){ +},{"./_baseGetTag":264,"./isObjectLike":405}],411:[function(require,module,exports){ var baseIsTypedArray = require('./_baseIsTypedArray'), baseUnary = require('./_baseUnary'), nodeUtil = require('./_nodeUtil'); @@ -59723,7 +62133,7 @@ var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedA module.exports = isTypedArray; -},{"./_baseIsTypedArray":271,"./_baseUnary":287,"./_nodeUtil":358}],406:[function(require,module,exports){ +},{"./_baseIsTypedArray":277,"./_baseUnary":293,"./_nodeUtil":364}],412:[function(require,module,exports){ var arrayLikeKeys = require('./_arrayLikeKeys'), baseKeys = require('./_baseKeys'), isArrayLike = require('./isArrayLike'); @@ -59762,7 +62172,7 @@ function keys(object) { module.exports = keys; -},{"./_arrayLikeKeys":240,"./_baseKeys":273,"./isArrayLike":392}],407:[function(require,module,exports){ +},{"./_arrayLikeKeys":246,"./_baseKeys":279,"./isArrayLike":398}],413:[function(require,module,exports){ var arrayLikeKeys = require('./_arrayLikeKeys'), baseKeysIn = require('./_baseKeysIn'), isArrayLike = require('./isArrayLike'); @@ -59796,7 +62206,7 @@ function keysIn(object) { module.exports = keysIn; -},{"./_arrayLikeKeys":240,"./_baseKeysIn":274,"./isArrayLike":392}],408:[function(require,module,exports){ +},{"./_arrayLikeKeys":246,"./_baseKeysIn":280,"./isArrayLike":398}],414:[function(require,module,exports){ var MapCache = require('./_MapCache'); /** Error message constants. */ @@ -59871,7 +62281,7 @@ memoize.Cache = MapCache; module.exports = memoize; -},{"./_MapCache":227}],409:[function(require,module,exports){ +},{"./_MapCache":233}],415:[function(require,module,exports){ /** * This method returns `undefined`. * @@ -59890,7 +62300,7 @@ function noop() { module.exports = noop; -},{}],410:[function(require,module,exports){ +},{}],416:[function(require,module,exports){ var baseProperty = require('./_baseProperty'), basePropertyDeep = require('./_basePropertyDeep'), isKey = require('./_isKey'), @@ -59924,7 +62334,7 @@ function property(path) { module.exports = property; -},{"./_baseProperty":279,"./_basePropertyDeep":280,"./_isKey":337,"./_toKey":375}],411:[function(require,module,exports){ +},{"./_baseProperty":285,"./_basePropertyDeep":286,"./_isKey":343,"./_toKey":381}],417:[function(require,module,exports){ var baseRepeat = require('./_baseRepeat'), isIterateeCall = require('./_isIterateeCall'), toInteger = require('./toInteger'), @@ -59963,7 +62373,7 @@ function repeat(string, n, guard) { module.exports = repeat; -},{"./_baseRepeat":281,"./_isIterateeCall":336,"./toInteger":416,"./toString":418}],412:[function(require,module,exports){ +},{"./_baseRepeat":287,"./_isIterateeCall":342,"./toInteger":422,"./toString":424}],418:[function(require,module,exports){ var baseFlatten = require('./_baseFlatten'), baseOrderBy = require('./_baseOrderBy'), baseRest = require('./_baseRest'), @@ -60013,7 +62423,7 @@ var sortBy = baseRest(function(collection, iteratees) { module.exports = sortBy; -},{"./_baseFlatten":253,"./_baseOrderBy":278,"./_baseRest":282,"./_isIterateeCall":336}],413:[function(require,module,exports){ +},{"./_baseFlatten":259,"./_baseOrderBy":284,"./_baseRest":288,"./_isIterateeCall":342}],419:[function(require,module,exports){ /** * This method returns a new empty array. * @@ -60038,7 +62448,7 @@ function stubArray() { module.exports = stubArray; -},{}],414:[function(require,module,exports){ +},{}],420:[function(require,module,exports){ /** * This method returns `false`. * @@ -60058,7 +62468,7 @@ function stubFalse() { module.exports = stubFalse; -},{}],415:[function(require,module,exports){ +},{}],421:[function(require,module,exports){ var toNumber = require('./toNumber'); /** Used as references for various `Number` constants. */ @@ -60102,7 +62512,7 @@ function toFinite(value) { module.exports = toFinite; -},{"./toNumber":417}],416:[function(require,module,exports){ +},{"./toNumber":423}],422:[function(require,module,exports){ var toFinite = require('./toFinite'); /** @@ -60140,7 +62550,7 @@ function toInteger(value) { module.exports = toInteger; -},{"./toFinite":415}],417:[function(require,module,exports){ +},{"./toFinite":421}],423:[function(require,module,exports){ var isObject = require('./isObject'), isSymbol = require('./isSymbol'); @@ -60208,7 +62618,7 @@ function toNumber(value) { module.exports = toNumber; -},{"./isObject":398,"./isSymbol":404}],418:[function(require,module,exports){ +},{"./isObject":404,"./isSymbol":410}],424:[function(require,module,exports){ var baseToString = require('./_baseToString'); /** @@ -60238,7 +62648,7 @@ function toString(value) { module.exports = toString; -},{"./_baseToString":286}],419:[function(require,module,exports){ +},{"./_baseToString":292}],425:[function(require,module,exports){ var baseUniq = require('./_baseUniq'); /** @@ -60265,7 +62675,7 @@ function uniq(array) { module.exports = uniq; -},{"./_baseUniq":288}],420:[function(require,module,exports){ +},{"./_baseUniq":294}],426:[function(require,module,exports){ var baseValues = require('./_baseValues'), keys = require('./keys'); @@ -60301,7 +62711,7 @@ function values(object) { module.exports = values; -},{"./_baseValues":289,"./keys":406}],421:[function(require,module,exports){ +},{"./_baseValues":295,"./keys":412}],427:[function(require,module,exports){ /** * Helpers. */ @@ -60332,7 +62742,7 @@ module.exports = function(val, options) { var type = typeof val; if (type === 'string' && val.length > 0) { return parse(val); - } else if (type === 'number' && isNaN(val) === false) { + } else if (type === 'number' && isFinite(val)) { return options.long ? fmtLong(val) : fmtShort(val); } throw new Error( @@ -60354,7 +62764,7 @@ function parse(str) { if (str.length > 100) { return; } - var match = /^((?:\d+)?\-?\d?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec( + var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec( str ); if (!match) { @@ -60465,7 +62875,99 @@ function plural(ms, msAbs, n, name) { return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : ''); } -},{}],422:[function(require,module,exports){ +},{}],428:[function(require,module,exports){ +/* +object-assign +(c) Sindre Sorhus +@license MIT +*/ + +'use strict'; +/* eslint-disable no-unused-vars */ +var getOwnPropertySymbols = Object.getOwnPropertySymbols; +var hasOwnProperty = Object.prototype.hasOwnProperty; +var propIsEnumerable = Object.prototype.propertyIsEnumerable; + +function toObject(val) { + if (val === null || val === undefined) { + throw new TypeError('Object.assign cannot be called with null or undefined'); + } + + return Object(val); +} + +function shouldUseNative() { + try { + if (!Object.assign) { + return false; + } + + // Detect buggy property enumeration order in older V8 versions. + + // https://bugs.chromium.org/p/v8/issues/detail?id=4118 + var test1 = new String('abc'); // eslint-disable-line no-new-wrappers + test1[5] = 'de'; + if (Object.getOwnPropertyNames(test1)[0] === '5') { + return false; + } + + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test2 = {}; + for (var i = 0; i < 10; i++) { + test2['_' + String.fromCharCode(i)] = i; + } + var order2 = Object.getOwnPropertyNames(test2).map(function (n) { + return test2[n]; + }); + if (order2.join('') !== '0123456789') { + return false; + } + + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test3 = {}; + 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { + test3[letter] = letter; + }); + if (Object.keys(Object.assign({}, test3)).join('') !== + 'abcdefghijklmnopqrst') { + return false; + } + + return true; + } catch (err) { + // We don't expect any of the above to throw, but better to be safe. + return false; + } +} + +module.exports = shouldUseNative() ? Object.assign : function (target, source) { + var from; + var to = toObject(target); + var symbols; + + for (var s = 1; s < arguments.length; s++) { + from = Object(arguments[s]); + + for (var key in from) { + if (hasOwnProperty.call(from, key)) { + to[key] = from[key]; + } + } + + if (getOwnPropertySymbols) { + symbols = getOwnPropertySymbols(from); + for (var i = 0; i < symbols.length; i++) { + if (propIsEnumerable.call(from, symbols[i])) { + to[symbols[i]] = from[symbols[i]]; + } + } + } + } + + return to; +}; + +},{}],429:[function(require,module,exports){ exports.endianness = function () { return 'LE' }; exports.hostname = function () { @@ -60516,7 +63018,7 @@ exports.homedir = function () { return '/' }; -},{}],423:[function(require,module,exports){ +},{}],430:[function(require,module,exports){ (function (process){ // .dirname, .basename, and .extname methods are extracted from Node.js v8.11.1, // backported and transplited with Babel, with backwards-compat fixes @@ -60822,7 +63324,7 @@ var substr = 'ab'.substr(-1) === 'b' ; }).call(this,require('_process')) -},{"_process":426}],424:[function(require,module,exports){ +},{"_process":433}],431:[function(require,module,exports){ "use strict"; var originalObject = Object; @@ -60953,11 +63455,12 @@ function makeAccessor(secretCreatorFn) { exports.makeAccessor = makeAccessor; -},{}],425:[function(require,module,exports){ +},{}],432:[function(require,module,exports){ (function (process){ 'use strict'; -if (!process.version || +if (typeof process === 'undefined' || + !process.version || process.version.indexOf('v0.') === 0 || process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) { module.exports = { nextTick: nextTick }; @@ -61001,7 +63504,7 @@ function nextTick(fn, arg1, arg2, arg3) { }).call(this,require('_process')) -},{"_process":426}],426:[function(require,module,exports){ +},{"_process":433}],433:[function(require,module,exports){ // shim for using process in browser var process = module.exports = {}; @@ -61187,10 +63690,10 @@ process.chdir = function (dir) { }; process.umask = function() { return 0; }; -},{}],427:[function(require,module,exports){ +},{}],434:[function(require,module,exports){ module.exports = require('./lib/_stream_duplex.js'); -},{"./lib/_stream_duplex.js":428}],428:[function(require,module,exports){ +},{"./lib/_stream_duplex.js":435}],435:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -61236,7 +63739,7 @@ var objectKeys = Object.keys || function (obj) { module.exports = Duplex; /**/ -var util = require('core-util-is'); +var util = Object.create(require('core-util-is')); util.inherits = require('inherits'); /**/ @@ -61322,7 +63825,7 @@ Duplex.prototype._destroy = function (err, cb) { pna.nextTick(cb, err); }; -},{"./_stream_readable":430,"./_stream_writable":432,"core-util-is":206,"inherits":218,"process-nextick-args":425}],429:[function(require,module,exports){ +},{"./_stream_readable":437,"./_stream_writable":439,"core-util-is":211,"inherits":224,"process-nextick-args":432}],436:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -61355,7 +63858,7 @@ module.exports = PassThrough; var Transform = require('./_stream_transform'); /**/ -var util = require('core-util-is'); +var util = Object.create(require('core-util-is')); util.inherits = require('inherits'); /**/ @@ -61370,7 +63873,7 @@ function PassThrough(options) { PassThrough.prototype._transform = function (chunk, encoding, cb) { cb(null, chunk); }; -},{"./_stream_transform":431,"core-util-is":206,"inherits":218}],430:[function(require,module,exports){ +},{"./_stream_transform":438,"core-util-is":211,"inherits":224}],437:[function(require,module,exports){ (function (process,global){ // Copyright Joyent, Inc. and other Node contributors. // @@ -61438,7 +63941,7 @@ function _isUint8Array(obj) { /**/ /**/ -var util = require('core-util-is'); +var util = Object.create(require('core-util-is')); util.inherits = require('inherits'); /**/ @@ -62392,7 +64895,7 @@ function indexOf(xs, x) { return -1; } }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./_stream_duplex":428,"./internal/streams/BufferList":433,"./internal/streams/destroy":434,"./internal/streams/stream":435,"_process":426,"core-util-is":206,"events":214,"inherits":218,"isarray":220,"process-nextick-args":425,"safe-buffer":485,"string_decoder/":436,"util":196}],431:[function(require,module,exports){ +},{"./_stream_duplex":435,"./internal/streams/BufferList":440,"./internal/streams/destroy":441,"./internal/streams/stream":442,"_process":433,"core-util-is":211,"events":219,"inherits":224,"isarray":226,"process-nextick-args":432,"safe-buffer":502,"string_decoder/":515,"util":201}],438:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -62463,7 +64966,7 @@ module.exports = Transform; var Duplex = require('./_stream_duplex'); /**/ -var util = require('core-util-is'); +var util = Object.create(require('core-util-is')); util.inherits = require('inherits'); /**/ @@ -62607,7 +65110,7 @@ function done(stream, er, data) { return stream.push(null); } -},{"./_stream_duplex":428,"core-util-is":206,"inherits":218}],432:[function(require,module,exports){ +},{"./_stream_duplex":435,"core-util-is":211,"inherits":224}],439:[function(require,module,exports){ (function (process,global,setImmediate){ // Copyright Joyent, Inc. and other Node contributors. // @@ -62675,7 +65178,7 @@ var Duplex; Writable.WritableState = WritableState; /**/ -var util = require('core-util-is'); +var util = Object.create(require('core-util-is')); util.inherits = require('inherits'); /**/ @@ -63297,7 +65800,7 @@ Writable.prototype._destroy = function (err, cb) { cb(err); }; }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate) -},{"./_stream_duplex":428,"./internal/streams/destroy":434,"./internal/streams/stream":435,"_process":426,"core-util-is":206,"inherits":218,"process-nextick-args":425,"safe-buffer":485,"timers":500,"util-deprecate":503}],433:[function(require,module,exports){ +},{"./_stream_duplex":435,"./internal/streams/destroy":441,"./internal/streams/stream":442,"_process":433,"core-util-is":211,"inherits":224,"process-nextick-args":432,"safe-buffer":502,"timers":518,"util-deprecate":520}],440:[function(require,module,exports){ 'use strict'; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -63377,7 +65880,7 @@ if (util && util.inspect && util.inspect.custom) { return this.constructor.name + ' ' + obj; }; } -},{"safe-buffer":485,"util":196}],434:[function(require,module,exports){ +},{"safe-buffer":502,"util":201}],441:[function(require,module,exports){ 'use strict'; /**/ @@ -63452,310 +65955,13 @@ module.exports = { destroy: destroy, undestroy: undestroy }; -},{"process-nextick-args":425}],435:[function(require,module,exports){ +},{"process-nextick-args":432}],442:[function(require,module,exports){ module.exports = require('events').EventEmitter; -},{"events":214}],436:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -'use strict'; - -/**/ - -var Buffer = require('safe-buffer').Buffer; -/**/ - -var isEncoding = Buffer.isEncoding || function (encoding) { - encoding = '' + encoding; - switch (encoding && encoding.toLowerCase()) { - case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw': - return true; - default: - return false; - } -}; - -function _normalizeEncoding(enc) { - if (!enc) return 'utf8'; - var retried; - while (true) { - switch (enc) { - case 'utf8': - case 'utf-8': - return 'utf8'; - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return 'utf16le'; - case 'latin1': - case 'binary': - return 'latin1'; - case 'base64': - case 'ascii': - case 'hex': - return enc; - default: - if (retried) return; // undefined - enc = ('' + enc).toLowerCase(); - retried = true; - } - } -}; - -// Do not cache `Buffer.isEncoding` when checking encoding names as some -// modules monkey-patch it to support additional encodings -function normalizeEncoding(enc) { - var nenc = _normalizeEncoding(enc); - if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc); - return nenc || enc; -} - -// StringDecoder provides an interface for efficiently splitting a series of -// buffers into a series of JS strings without breaking apart multi-byte -// characters. -exports.StringDecoder = StringDecoder; -function StringDecoder(encoding) { - this.encoding = normalizeEncoding(encoding); - var nb; - switch (this.encoding) { - case 'utf16le': - this.text = utf16Text; - this.end = utf16End; - nb = 4; - break; - case 'utf8': - this.fillLast = utf8FillLast; - nb = 4; - break; - case 'base64': - this.text = base64Text; - this.end = base64End; - nb = 3; - break; - default: - this.write = simpleWrite; - this.end = simpleEnd; - return; - } - this.lastNeed = 0; - this.lastTotal = 0; - this.lastChar = Buffer.allocUnsafe(nb); -} - -StringDecoder.prototype.write = function (buf) { - if (buf.length === 0) return ''; - var r; - var i; - if (this.lastNeed) { - r = this.fillLast(buf); - if (r === undefined) return ''; - i = this.lastNeed; - this.lastNeed = 0; - } else { - i = 0; - } - if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i); - return r || ''; -}; - -StringDecoder.prototype.end = utf8End; - -// Returns only complete characters in a Buffer -StringDecoder.prototype.text = utf8Text; - -// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer -StringDecoder.prototype.fillLast = function (buf) { - if (this.lastNeed <= buf.length) { - buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed); - return this.lastChar.toString(this.encoding, 0, this.lastTotal); - } - buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length); - this.lastNeed -= buf.length; -}; - -// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a -// continuation byte. If an invalid byte is detected, -2 is returned. -function utf8CheckByte(byte) { - if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4; - return byte >> 6 === 0x02 ? -1 : -2; -} - -// Checks at most 3 bytes at the end of a Buffer in order to detect an -// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4) -// needed to complete the UTF-8 character (if applicable) are returned. -function utf8CheckIncomplete(self, buf, i) { - var j = buf.length - 1; - if (j < i) return 0; - var nb = utf8CheckByte(buf[j]); - if (nb >= 0) { - if (nb > 0) self.lastNeed = nb - 1; - return nb; - } - if (--j < i || nb === -2) return 0; - nb = utf8CheckByte(buf[j]); - if (nb >= 0) { - if (nb > 0) self.lastNeed = nb - 2; - return nb; - } - if (--j < i || nb === -2) return 0; - nb = utf8CheckByte(buf[j]); - if (nb >= 0) { - if (nb > 0) { - if (nb === 2) nb = 0;else self.lastNeed = nb - 3; - } - return nb; - } - return 0; -} - -// Validates as many continuation bytes for a multi-byte UTF-8 character as -// needed or are available. If we see a non-continuation byte where we expect -// one, we "replace" the validated continuation bytes we've seen so far with -// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding -// behavior. The continuation byte check is included three times in the case -// where all of the continuation bytes for a character exist in the same buffer. -// It is also done this way as a slight performance increase instead of using a -// loop. -function utf8CheckExtraBytes(self, buf, p) { - if ((buf[0] & 0xC0) !== 0x80) { - self.lastNeed = 0; - return '\ufffd'; - } - if (self.lastNeed > 1 && buf.length > 1) { - if ((buf[1] & 0xC0) !== 0x80) { - self.lastNeed = 1; - return '\ufffd'; - } - if (self.lastNeed > 2 && buf.length > 2) { - if ((buf[2] & 0xC0) !== 0x80) { - self.lastNeed = 2; - return '\ufffd'; - } - } - } -} - -// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer. -function utf8FillLast(buf) { - var p = this.lastTotal - this.lastNeed; - var r = utf8CheckExtraBytes(this, buf, p); - if (r !== undefined) return r; - if (this.lastNeed <= buf.length) { - buf.copy(this.lastChar, p, 0, this.lastNeed); - return this.lastChar.toString(this.encoding, 0, this.lastTotal); - } - buf.copy(this.lastChar, p, 0, buf.length); - this.lastNeed -= buf.length; -} - -// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a -// partial character, the character's bytes are buffered until the required -// number of bytes are available. -function utf8Text(buf, i) { - var total = utf8CheckIncomplete(this, buf, i); - if (!this.lastNeed) return buf.toString('utf8', i); - this.lastTotal = total; - var end = buf.length - (total - this.lastNeed); - buf.copy(this.lastChar, 0, end); - return buf.toString('utf8', i, end); -} - -// For UTF-8, a replacement character is added when ending on a partial -// character. -function utf8End(buf) { - var r = buf && buf.length ? this.write(buf) : ''; - if (this.lastNeed) return r + '\ufffd'; - return r; -} - -// UTF-16LE typically needs two bytes per character, but even if we have an even -// number of bytes available, we need to check if we end on a leading/high -// surrogate. In that case, we need to wait for the next two bytes in order to -// decode the last character properly. -function utf16Text(buf, i) { - if ((buf.length - i) % 2 === 0) { - var r = buf.toString('utf16le', i); - if (r) { - var c = r.charCodeAt(r.length - 1); - if (c >= 0xD800 && c <= 0xDBFF) { - this.lastNeed = 2; - this.lastTotal = 4; - this.lastChar[0] = buf[buf.length - 2]; - this.lastChar[1] = buf[buf.length - 1]; - return r.slice(0, -1); - } - } - return r; - } - this.lastNeed = 1; - this.lastTotal = 2; - this.lastChar[0] = buf[buf.length - 1]; - return buf.toString('utf16le', i, buf.length - 1); -} - -// For UTF-16LE we do not explicitly append special replacement characters if we -// end on a partial character, we simply let v8 handle that. -function utf16End(buf) { - var r = buf && buf.length ? this.write(buf) : ''; - if (this.lastNeed) { - var end = this.lastTotal - this.lastNeed; - return r + this.lastChar.toString('utf16le', 0, end); - } - return r; -} - -function base64Text(buf, i) { - var n = (buf.length - i) % 3; - if (n === 0) return buf.toString('base64', i); - this.lastNeed = 3 - n; - this.lastTotal = 3; - if (n === 1) { - this.lastChar[0] = buf[buf.length - 1]; - } else { - this.lastChar[0] = buf[buf.length - 2]; - this.lastChar[1] = buf[buf.length - 1]; - } - return buf.toString('base64', i, buf.length - n); -} - -function base64End(buf) { - var r = buf && buf.length ? this.write(buf) : ''; - if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed); - return r; -} - -// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex) -function simpleWrite(buf) { - return buf.toString(this.encoding); -} - -function simpleEnd(buf) { - return buf && buf.length ? this.write(buf) : ''; -} -},{"safe-buffer":485}],437:[function(require,module,exports){ +},{"events":219}],443:[function(require,module,exports){ module.exports = require('./readable').PassThrough -},{"./readable":438}],438:[function(require,module,exports){ +},{"./readable":444}],444:[function(require,module,exports){ exports = module.exports = require('./lib/_stream_readable.js'); exports.Stream = exports; exports.Readable = exports; @@ -63764,23 +65970,30 @@ exports.Duplex = require('./lib/_stream_duplex.js'); exports.Transform = require('./lib/_stream_transform.js'); exports.PassThrough = require('./lib/_stream_passthrough.js'); -},{"./lib/_stream_duplex.js":428,"./lib/_stream_passthrough.js":429,"./lib/_stream_readable.js":430,"./lib/_stream_transform.js":431,"./lib/_stream_writable.js":432}],439:[function(require,module,exports){ +},{"./lib/_stream_duplex.js":435,"./lib/_stream_passthrough.js":436,"./lib/_stream_readable.js":437,"./lib/_stream_transform.js":438,"./lib/_stream_writable.js":439}],445:[function(require,module,exports){ module.exports = require('./readable').Transform -},{"./readable":438}],440:[function(require,module,exports){ +},{"./readable":444}],446:[function(require,module,exports){ module.exports = require('./lib/_stream_writable.js'); -},{"./lib/_stream_writable.js":432}],441:[function(require,module,exports){ +},{"./lib/_stream_writable.js":439}],447:[function(require,module,exports){ "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; Object.defineProperty(exports, "__esModule", { value: true }); var assert_1 = __importDefault(require("assert")); -var types_1 = __importDefault(require("./types")); -var n = types_1.default.namedTypes; -var isArray = types_1.default.builtInTypes.array; -var isObject = types_1.default.builtInTypes.object; +var types = __importStar(require("ast-types")); +var n = types.namedTypes; +var isArray = types.builtInTypes.array; +var isObject = types.builtInTypes.object; var lines_1 = require("./lines"); var util_1 = require("./util"); var private_1 = require("private"); @@ -63819,7 +66032,7 @@ function getSortedChildNodes(node, lines, resultArray) { names = Object.keys(node); } else if (isObject.check(node)) { - names = types_1.default.getFieldNames(node); + names = types.getFieldNames(node); } else { return; @@ -64048,7 +66261,7 @@ function printComments(path, print) { var value = path.getValue(); var innerLines = print(path); var comments = n.Node.check(value) && - types_1.default.getFieldValue(value, "comments"); + types.getFieldValue(value, "comments"); if (!comments || comments.length === 0) { return innerLines; } @@ -64056,8 +66269,8 @@ function printComments(path, print) { var trailingParts = [innerLines]; path.each(function (commentPath) { var comment = commentPath.getValue(); - var leading = types_1.default.getFieldValue(comment, "leading"); - var trailing = types_1.default.getFieldValue(comment, "trailing"); + var leading = types.getFieldValue(comment, "leading"); + var trailing = types.getFieldValue(comment, "trailing"); if (leading || (trailing && !(n.Statement.check(value) || comment.type === "Block" || comment.type === "CommentBlock"))) { @@ -64073,8 +66286,8 @@ function printComments(path, print) { exports.printComments = printComments; ; -},{"./lines":443,"./types":449,"./util":450,"assert":191,"private":424}],442:[function(require,module,exports){ -"use strict";; +},{"./lines":449,"./util":455,"assert":196,"ast-types":477,"private":431}],448:[function(require,module,exports){ +"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; @@ -64087,10 +66300,10 @@ var __importStar = (this && this.__importStar) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); var assert_1 = __importDefault(require("assert")); -var types_1 = __importDefault(require("./types")); -var n = types_1.default.namedTypes; -var isArray = types_1.default.builtInTypes.array; -var isNumber = types_1.default.builtInTypes.number; +var types = __importStar(require("ast-types")); +var n = types.namedTypes; +var isArray = types.builtInTypes.array; +var isNumber = types.builtInTypes.number; var util = __importStar(require("./util")); var FastPath = function FastPath(value) { assert_1.default.ok(this instanceof FastPath); @@ -64103,7 +66316,7 @@ FastPath.from = function (obj) { // Return a defensive copy of any existing FastPath instances. return obj.copy(); } - if (obj instanceof types_1.default.NodePath) { + if (obj instanceof types.NodePath) { // For backwards compatibility, unroll NodePath instances into // lightweight FastPath [..., name, value] stacks. var copy = Object.create(FastPath.prototype); @@ -64467,6 +66680,13 @@ FPp.needsParens = function (assumeExpressionContext) { return true; } break; + case 'TSAsExpression': + if (parent.type === 'ArrowFunctionExpression' && + name === 'body' && + node.expression.type === 'ObjectExpression') { + return true; + } + break; case "CallExpression": if (name === "declaration" && n.ExportDefaultDeclaration.check(parent) && @@ -64522,9 +66742,7 @@ function containsCallExpression(node) { return node.some(containsCallExpression); } if (n.Node.check(node)) { - return types_1.default.someField(node, function (_name, child) { - return containsCallExpression(child); - }); + return types.someField(node, function (_name, child) { return containsCallExpression(child); }); } return false; } @@ -64613,9 +66831,8 @@ FPp.firstInStatement = function () { return true; }; exports.default = FastPath; -module.exports = exports["default"]; -},{"./types":449,"./util":450,"assert":191}],443:[function(require,module,exports){ +},{"./util":455,"assert":196,"ast-types":477}],449:[function(require,module,exports){ "use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { @@ -64751,15 +66968,15 @@ var Lines = /** @class */ (function () { return this; var lines = new Lines(this.infos.map(function (info, i) { if (info.line && (i > 0 || !skipFirstLine)) { - info = __assign({}, info, { indent: Math.max(0, info.indent - width) }); + info = __assign(__assign({}, info), { indent: Math.max(0, info.indent - width) }); } return info; })); if (this.mappings.length > 0) { - var newMappings = lines.mappings; - assert_1.default.strictEqual(newMappings.length, 0); + var newMappings_1 = lines.mappings; + assert_1.default.strictEqual(newMappings_1.length, 0); this.mappings.forEach(function (mapping) { - newMappings.push(mapping.indent(width, skipFirstLine, true)); + newMappings_1.push(mapping.indent(width, skipFirstLine, true)); }); } return lines; @@ -64770,15 +66987,15 @@ var Lines = /** @class */ (function () { } var lines = new Lines(this.infos.map(function (info) { if (info.line && !info.locked) { - info = __assign({}, info, { indent: info.indent + by }); + info = __assign(__assign({}, info), { indent: info.indent + by }); } return info; })); if (this.mappings.length > 0) { - var newMappings = lines.mappings; - assert_1.default.strictEqual(newMappings.length, 0); + var newMappings_2 = lines.mappings; + assert_1.default.strictEqual(newMappings_2.length, 0); this.mappings.forEach(function (mapping) { - newMappings.push(mapping.indent(by)); + newMappings_2.push(mapping.indent(by)); }); } return lines; @@ -64792,15 +67009,15 @@ var Lines = /** @class */ (function () { } var lines = new Lines(this.infos.map(function (info, i) { if (i > 0 && info.line && !info.locked) { - info = __assign({}, info, { indent: info.indent + by }); + info = __assign(__assign({}, info), { indent: info.indent + by }); } return info; })); if (this.mappings.length > 0) { - var newMappings = lines.mappings; - assert_1.default.strictEqual(newMappings.length, 0); + var newMappings_3 = lines.mappings; + assert_1.default.strictEqual(newMappings_3.length, 0); this.mappings.forEach(function (mapping) { - newMappings.push(mapping.indent(by, true)); + newMappings_3.push(mapping.indent(by, true)); }); } return lines; @@ -64809,9 +67026,7 @@ var Lines = /** @class */ (function () { if (this.length < 2) { return this; } - return new Lines(this.infos.map(function (info, i) { - return __assign({}, info, { locked: i > 0 }); - })); + return new Lines(this.infos.map(function (info, i) { return (__assign(__assign({}, info), { locked: i > 0 })); })); }; Lines.prototype.getIndentAt = function (line) { assert_1.default.ok(line >= 1, "no line " + line + " (line numbers start from 1)"); @@ -65025,12 +67240,12 @@ var Lines = /** @class */ (function () { } var lines = new Lines(sliced); if (this.mappings.length > 0) { - var newMappings = lines.mappings; - assert_1.default.strictEqual(newMappings.length, 0); + var newMappings_4 = lines.mappings; + assert_1.default.strictEqual(newMappings_4.length, 0); this.mappings.forEach(function (mapping) { var sliced = mapping.slice(this, start, end); if (sliced) { - newMappings.push(sliced); + newMappings_4.push(sliced); } }, this); } @@ -65059,10 +67274,10 @@ var Lines = /** @class */ (function () { info = sliceInfo(info, 0, end.column); } var indent = Math.max(info.indent, 0); - var before = info.line.slice(0, info.sliceStart); + var before_1 = info.line.slice(0, info.sliceStart); if (options.reuseWhitespace && - isOnlyWhitespace(before) && - countSpaces(before, options.tabWidth) === indent) { + isOnlyWhitespace(before_1) && + countSpaces(before_1, options.tabWidth) === indent) { // Reuse original spaces if the indentation is correct. parts.push(info.line.slice(0, info.sliceEnd)); continue; @@ -65100,8 +67315,8 @@ var Lines = /** @class */ (function () { if (prevInfo) { var info = linesOrNull.infos[0]; var indent = new Array(info.indent + 1).join(" "); - var prevLine = infos.length; - var prevColumn = Math.max(prevInfo.indent, 0) + + var prevLine_1 = infos.length; + var prevColumn_1 = 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); // If any part of a line is indentation-locked, the whole line @@ -65110,7 +67325,7 @@ var Lines = /** @class */ (function () { prevInfo.sliceEnd = prevInfo.line.length; if (linesOrNull.mappings.length > 0) { linesOrNull.mappings.forEach(function (mapping) { - mappings.push(mapping.add(prevLine, prevColumn)); + mappings.push(mapping.add(prevLine_1, prevColumn_1)); }); } } @@ -65285,8 +67500,8 @@ exports.concat = concat; // Lines.prototype will be fully populated. var emptyLines = fromString(""); -},{"./mapping":444,"./options":445,"./util":450,"assert":191,"source-map":483}],444:[function(require,module,exports){ -"use strict";; +},{"./mapping":450,"./options":451,"./util":455,"assert":196,"source-map":489}],450:[function(require,module,exports){ +"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; @@ -65488,9 +67703,8 @@ function skipChars(sourceLines, sourceFromPos, targetLines, targetFromPos, targe } return sourceCursor; } -module.exports = exports["default"]; -},{"./util":450,"assert":191}],445:[function(require,module,exports){ +},{"./util":455,"assert":196}],451:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var defaults = { @@ -65513,7 +67727,8 @@ var defaults = { arrowParensAlways: false, flowObjectCommas: true, tokens: true -}, hasOwn = defaults.hasOwnProperty; +}; +var hasOwn = defaults.hasOwnProperty; // Copy options and fill in default values. function normalize(opts) { var options = opts || defaults; @@ -65547,7 +67762,7 @@ function normalize(opts) { exports.normalize = normalize; ; -},{"../parsers/esprima":484,"os":422}],446:[function(require,module,exports){ +},{"../parsers/esprima":490,"os":429}],452:[function(require,module,exports){ "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -65561,10 +67776,10 @@ var __importStar = (this && this.__importStar) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); var assert_1 = __importDefault(require("assert")); -var types_1 = __importDefault(require("./types")); -var b = types_1.default.builders; -var isObject = types_1.default.builtInTypes.object; -var isArray = types_1.default.builtInTypes.array; +var types = __importStar(require("ast-types")); +var b = types.builders; +var isObject = types.builtInTypes.object; +var isArray = types.builtInTypes.array; var options_1 = require("./options"); var lines_1 = require("./lines"); var comments_1 = require("./comments"); @@ -65806,7 +68021,7 @@ TCp.findTokenRange = function (loc) { loc.end.token = this.endTokenIndex; }; -},{"./comments":441,"./lines":443,"./options":445,"./types":449,"./util":450,"assert":191,"esprima":472}],447:[function(require,module,exports){ +},{"./comments":447,"./lines":449,"./options":451,"./util":455,"assert":196,"ast-types":477,"esprima":478}],453:[function(require,module,exports){ "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -65821,16 +68036,16 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); var assert_1 = __importDefault(require("assert")); var linesModule = __importStar(require("./lines")); -var types_1 = __importDefault(require("./types")); -var Printable = types_1.default.namedTypes.Printable; -var Expression = types_1.default.namedTypes.Expression; -var ReturnStatement = types_1.default.namedTypes.ReturnStatement; -var SourceLocation = types_1.default.namedTypes.SourceLocation; +var types = __importStar(require("ast-types")); +var Printable = types.namedTypes.Printable; +var Expression = types.namedTypes.Expression; +var ReturnStatement = types.namedTypes.ReturnStatement; +var SourceLocation = types.namedTypes.SourceLocation; var util_1 = require("./util"); var fast_path_1 = __importDefault(require("./fast-path")); -var isObject = types_1.default.builtInTypes.object; -var isArray = types_1.default.builtInTypes.array; -var isString = types_1.default.builtInTypes.string; +var isObject = types.builtInTypes.object; +var isArray = types.builtInTypes.array; +var isString = types.builtInTypes.string; var riskyAdjoiningCharExp = /[0-9a-z_$]/i; var Patcher = function Patcher(lines) { assert_1.default.ok(this instanceof Patcher); @@ -65857,9 +68072,7 @@ var Patcher = function Patcher(lines) { assert_1.default.ok(util_1.comparePos(from, to) <= 0); toConcat.push(lines.slice(from, to)); } - replacements.sort(function (a, b) { - return util_1.comparePos(a.start, b.start); - }).forEach(function (rep) { + replacements.sort(function (a, b) { return util_1.comparePos(a.start, b.start); }).forEach(function (rep) { if (util_1.comparePos(sliceFrom, rep.start) > 0) { // Ignore nested replacement ranges. } @@ -66108,6 +68321,16 @@ function findObjectReprints(newPath, oldPath, reprints) { if (!Printable.check(oldNode)) { return false; } + var newParentNode = newPath.getParentNode(); + var oldParentNode = oldPath.getParentNode(); + if (oldParentNode !== null && oldParentNode.type === 'FunctionTypeAnnotation' + && newParentNode !== null && newParentNode.type === 'FunctionTypeAnnotation') { + var oldNeedsParens = oldParentNode.params.length !== 1 || !!oldParentNode.params[0].name; + var newNeedParens = newParentNode.params.length !== 1 || !!newParentNode.params[0].name; + if (!oldNeedsParens && newNeedParens) { + 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) { @@ -66181,8 +68404,8 @@ function findChildReprints(newPath, oldPath, reprints) { // parsers like Babylon. continue; } - newPath.stack.push(k, types_1.default.getFieldValue(newNode, k)); - oldPath.stack.push(k, types_1.default.getFieldValue(oldNode, k)); + 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; @@ -66200,7 +68423,7 @@ function findChildReprints(newPath, oldPath, reprints) { return true; } -},{"./fast-path":442,"./lines":443,"./types":449,"./util":450,"assert":191}],448:[function(require,module,exports){ +},{"./fast-path":448,"./lines":449,"./util":455,"assert":196,"ast-types":477}],454:[function(require,module,exports){ "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -66218,10 +68441,10 @@ var comments_1 = require("./comments"); var lines_1 = require("./lines"); var options_1 = require("./options"); var patcher_1 = require("./patcher"); -var types_1 = __importDefault(require("./types")); -var namedTypes = types_1.default.namedTypes; -var isString = types_1.default.builtInTypes.string; -var isObject = types_1.default.builtInTypes.object; +var types = __importStar(require("ast-types")); +var namedTypes = types.namedTypes; +var isString = types.builtInTypes.string; +var isObject = types.builtInTypes.object; var fast_path_1 = __importDefault(require("./fast-path")); var util = __importStar(require("./util")); var PrintResult = function PrintResult(code, sourceMap) { @@ -66257,9 +68480,7 @@ var Printer = function Printer(config) { // new print function that uses the modified options. function makePrintFunctionWith(options, overrides) { options = Object.assign({}, options, overrides); - return function (path) { - return print(path, options); - }; + return function (path) { return print(path, options); }; } function print(path, options) { assert_1.default.ok(path instanceof fast_path_1.default); @@ -66310,12 +68531,10 @@ var Printer = function Printer(config) { } // Print the entire AST generically. function printGenerically(path) { - return comments_1.printComments(path, function (path) { - return genericPrint(path, config, { - includeComments: true, - avoidRootParens: false - }, printGenerically); - }); + return comments_1.printComments(path, function (path) { return genericPrint(path, config, { + includeComments: true, + avoidRootParens: false + }, printGenerically); }); } var path = fast_path_1.default.from(ast); var oldReuseWhitespace = config.reuseWhitespace; @@ -66385,9 +68604,7 @@ function genericPrintNoParens(path, options, print) { if (n.interpreter) { parts.push(path.call(print, "interpreter")); } - parts.push(path.call(function (bodyPath) { - return printStatementSequence(bodyPath, options, print); - }, "body")); + parts.push(path.call(function (bodyPath) { return printStatementSequence(bodyPath, options, print); }, "body")); return lines_1.concat(parts); case "Noop": // Babel extension. case "EmptyStatement": @@ -66414,7 +68631,7 @@ function genericPrintNoParens(path, options, print) { case "OptionalMemberExpression": parts.push(path.call(print, "object")); var property = path.call(print, "property"); - var optional = n.type === "OptionalMemberExpression"; + var optional = n.type === "OptionalMemberExpression" && n.optional; if (n.computed) { parts.push(optional ? "?.[" : "[", property, "]"); } @@ -66469,6 +68686,11 @@ function genericPrintNoParens(path, options, print) { if (n.id) { parts.push(" ", path.call(print, "id"), path.call(print, "typeParameters")); } + else { + if (n.typeParameters) { + parts.push(path.call(print, "typeParameters")); + } + } parts.push("(", printFunctionParams(path, options, print), ")", path.call(print, "returnType")); if (n.body) { parts.push(" ", path.call(print, "body")); @@ -66643,9 +68865,7 @@ function genericPrintNoParens(path, options, print) { return lines_1.concat(parts); } case "BlockStatement": - var naked = path.call(function (bodyPath) { - return printStatementSequence(bodyPath, options, print); - }, "body"); + var naked = path.call(function (bodyPath) { return printStatementSequence(bodyPath, options, print); }, "body"); if (naked.isEmpty()) { if (!n.directives || n.directives.length === 0) { return lines_1.fromString("{}"); @@ -66655,7 +68875,7 @@ function genericPrintNoParens(path, options, print) { // Babel 6 if (n.directives) { path.each(function (childPath) { - parts.push(print(childPath).indent(options.tabWidth), ";", n.directives.length > 1 || !naked.isEmpty() ? "\n" : ""); + parts.push(maybeAddSemicolon(print(childPath).indent(options.tabWidth)), n.directives.length > 1 || !naked.isEmpty() ? "\n" : ""); }, "directives"); } parts.push(naked.indent(options.tabWidth)); @@ -66680,6 +68900,12 @@ function genericPrintNoParens(path, options, print) { case "CallExpression": case "OptionalCallExpression": parts.push(path.call(print, "callee")); + if (n.typeParameters) { + parts.push(path.call(print, "typeParameters")); + } + if (n.typeArguments) { + parts.push(path.call(print, "typeArguments")); + } if (n.type === "OptionalCallExpression" && n.callee.type !== "OptionalMemberExpression") { parts.push("?."); @@ -66770,6 +68996,9 @@ function genericPrintNoParens(path, options, print) { if (n.method || n.kind === "get" || n.kind === "set") { return printMethod(path, options, print); } + if (n.shorthand && n.value.type === "AssignmentPattern") { + return path.call(print, "value"); + } var key = path.call(print, "key"); if (n.computed) { parts.push("[", key, "]"); @@ -66819,15 +69048,15 @@ function genericPrintNoParens(path, options, print) { parts.push(","); } else { - var lines = printed[i]; + var lines_3 = printed[i]; if (oneLine) { if (i > 0) parts.push(" "); } else { - lines = lines.indent(options.tabWidth); + lines_3 = lines_3.indent(options.tabWidth); } - parts.push(lines); + parts.push(lines_3); if (i < len - 1 || (!oneLine && util.isTrailingCommaEnabled(options, "arrays"))) parts.push(","); if (!oneLine) @@ -66840,6 +69069,9 @@ function genericPrintNoParens(path, options, print) { else { parts.push("]"); } + if (n.typeAnnotation) { + parts.push(path.call(print, "typeAnnotation")); + } return lines_1.concat(parts); case "SequenceExpression": return lines_1.fromString(", ").join(path.map(print, "expressions")); @@ -66907,6 +69139,12 @@ function genericPrintNoParens(path, options, print) { ]); case "NewExpression": parts.push("new ", path.call(print, "callee")); + if (n.typeParameters) { + parts.push(path.call(print, "typeParameters")); + } + if (n.typeArguments) { + parts.push(path.call(print, "typeArguments")); + } var args = n.arguments; if (args) { parts.push(printArgumentsList(path, options, print)); @@ -67015,9 +69253,7 @@ function genericPrintNoParens(path, options, print) { parts.push(" (", path.call(print, "test"), ");"); return lines_1.concat(parts); case "DoExpression": - var statements = path.call(function (bodyPath) { - return printStatementSequence(bodyPath, options, print); - }, "body"); + var statements = path.call(function (bodyPath) { return printStatementSequence(bodyPath, options, print); }, "body"); return lines_1.concat([ "do {\n", statements.indent(options.tabWidth), @@ -67086,9 +69322,7 @@ function genericPrintNoParens(path, options, print) { 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)); + parts.push("\n", path.call(function (consequentPath) { return printStatementSequence(consequentPath, options, print); }, "consequent").indent(options.tabWidth)); } return lines_1.concat(parts); case "DebuggerStatement": @@ -67187,9 +69421,7 @@ function genericPrintNoParens(path, options, print) { } return lines_1.concat([ "{\n", - path.call(function (bodyPath) { - return printStatementSequence(bodyPath, options, print); - }, "body").indent(options.tabWidth), + path.call(function (bodyPath) { return printStatementSequence(bodyPath, options, print); }, "body").indent(options.tabWidth), "\n}" ]); case "ClassPropertyDefinition": @@ -67198,6 +69430,9 @@ function genericPrintNoParens(path, options, print) { parts.push(";"); return lines_1.concat(parts); case "ClassProperty": + if (n.declare) { + parts.push("declare "); + } var access = n.accessibility || n.access; if (typeof access === "string") { parts.push(access, " "); @@ -67366,15 +69601,15 @@ function genericPrintNoParens(path, options, print) { parts.push(","); } else { - var lines = printed[i]; + var lines_4 = printed[i]; if (oneLine) { if (i > 0) parts.push(" "); } else { - lines = lines.indent(options.tabWidth); + lines_4 = lines_4.indent(options.tabWidth); } - parts.push(lines); + parts.push(lines_4); if (i < n.types.length - 1 || (!oneLine && util.isTrailingCommaEnabled(options, "arrays"))) parts.push(","); if (!oneLine) @@ -67454,11 +69689,13 @@ function genericPrintNoParens(path, options, print) { (namedTypes.ObjectTypeInternalSlot.check(parent) && parent.method) || namedTypes.DeclareFunction.check(path.getParentNode(2))); var needsColon = isArrowFunctionTypeAnnotation && - !namedTypes.FunctionTypeParam.check(parent); + !namedTypes.FunctionTypeParam.check(parent) && + !namedTypes.TypeAlias.check(parent); if (needsColon) { parts.push(": "); } - parts.push("(", printFunctionParams(path, options, print), ")"); + var needsParens = n.params.length !== 1 || n.params[0].name; + parts.push(needsParens ? "(" : '', printFunctionParams(path, options, print), needsParens ? ")" : ''); // The returnType is not wrapped in a TypeAnnotation, so the colon // needs to be added separately. if (n.returnType) { @@ -67466,12 +69703,16 @@ function genericPrintNoParens(path, options, print) { } return lines_1.concat(parts); case "FunctionTypeParam": - return lines_1.concat([ - path.call(print, "name"), - n.optional ? '?' : '', - ": ", - path.call(print, "typeAnnotation"), - ]); + var name = path.call(print, "name"); + parts.push(name); + if (n.optional) { + parts.push('?'); + } + if (name.infos[0].line) { + parts.push(': '); + } + parts.push(path.call(print, "typeAnnotation")); + return lines_1.concat(parts); case "GenericTypeAnnotation": return lines_1.concat([ path.call(print, "id"), @@ -67679,7 +69920,6 @@ function genericPrintNoParens(path, options, print) { ")" ]); case "TSFunctionType": - case "TSConstructorType": return lines_1.concat([ path.call(print, "typeParameters"), "(", @@ -67687,6 +69927,15 @@ function genericPrintNoParens(path, options, print) { ")", path.call(print, "typeAnnotation") ]); + case "TSConstructorType": + return lines_1.concat([ + "new ", + path.call(print, 'typeParameters'), + "(", + printFunctionParams(path, options, print), + ")", + path.call(print, "typeAnnotation") + ]); case "TSMappedType": { parts.push(n.readonly ? "readonly " : "", "[", path.call(print, "typeParameter"), "]", n.optional ? "?" : ""); if (n.typeAnnotation) { @@ -67793,7 +70042,7 @@ function genericPrintNoParens(path, options, print) { // in a type predicate, it takes the for u is U var parent = path.getParentNode(0); var prefix = ": "; - if (namedTypes.TSFunctionType.check(parent)) { + if (namedTypes.TSFunctionType.check(parent) || namedTypes.TSConstructorType.check(parent)) { prefix = " => "; } if (namedTypes.TSTypePredicate.check(parent)) { @@ -67956,12 +70205,12 @@ function genericPrintNoParens(path, options, print) { else if (n.loc && n.loc.lines && n.id.loc) { - var prefix_1 = n.loc.lines.sliceString(n.loc.start, n.id.loc.start); + var prefix = n.loc.lines.sliceString(n.loc.start, n.id.loc.start); // These keywords are fundamentally ambiguous in the // Babylon parser, and not reflected in the AST, so // the best we can do is to match the original code, // when possible. - if (prefix_1.indexOf("module") >= 0) { + if (prefix.indexOf("module") >= 0) { parts.push("module "); } else { @@ -67989,9 +70238,7 @@ function genericPrintNoParens(path, options, print) { return lines_1.concat(parts); } case "TSModuleBlock": - return path.call(function (bodyPath) { - return printStatementSequence(bodyPath, options, print); - }, "body"); + return path.call(function (bodyPath) { return printStatementSequence(bodyPath, options, print); }, "body"); // 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. @@ -68214,9 +70461,7 @@ function printMethod(path, options, print) { } } else { - parts.push(path.call(print, "value", "typeParameters"), "(", path.call(function (valuePath) { - return printFunctionParams(valuePath, options, print); - }, "value"), ")", path.call(print, "value", "returnType")); + parts.push(path.call(print, "value", "typeParameters"), "(", path.call(function (valuePath) { return printFunctionParams(valuePath, options, print); }, "value"), ")", path.call(print, "value", "returnType")); if (nodeValue.body) { parts.push(" ", path.call(print, "value", "body")); } @@ -68320,9 +70565,9 @@ function printExportDeclaration(path, options, print) { parts.push(lines); }); if (bracedSpecifiers_2.length > 0) { - var lines_3 = lines_1.fromString(", ").join(bracedSpecifiers_2); - if (lines_3.getLineLength(1) > options.wrapColumn) { - lines_3 = lines_1.concat([ + var lines_5 = lines_1.fromString(", ").join(bracedSpecifiers_2); + if (lines_5.getLineLength(1) > options.wrapColumn) { + lines_5 = lines_1.concat([ lines_1.fromString(",\n").join(bracedSpecifiers_2).indent(options.tabWidth), "," ]); @@ -68330,14 +70575,14 @@ function printExportDeclaration(path, options, print) { if (unbracedSpecifiers_2.length > 0) { parts.push(", "); } - if (lines_3.length > 1) { - parts.push("{\n", lines_3, "\n}"); + if (lines_5.length > 1) { + parts.push("{\n", lines_5, "\n}"); } else if (options.objectCurlySpacing) { - parts.push("{ ", lines_3, " }"); + parts.push("{ ", lines_5, " }"); } else { - parts.push("{", lines_3, "}"); + parts.push("{", lines_5, "}"); } } } @@ -68408,9 +70653,7 @@ function endsWithBrace(lines) { return lastNonSpaceCharacter(lines) === "}"; } function swapQuotes(str) { - return str.replace(/['"]/g, function (m) { - return m === '"' ? '\'' : '"'; - }); + return str.replace(/['"]/g, function (m) { return m === '"' ? '\'' : '"'; }); } function nodeStr(str, options) { isString.assert(str); @@ -68433,33 +70676,22 @@ function maybeAddSemicolon(lines) { return lines; } -},{"./comments":441,"./fast-path":442,"./lines":443,"./options":445,"./patcher":447,"./types":449,"./util":450,"assert":191}],449:[function(require,module,exports){ -"use strict";; -function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; -} -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// 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. -var ast_types_1 = __importDefault(require("ast-types")); -exports.default = ast_types_1.default; -__export(require("ast-types")); -module.exports = exports["default"]; - -},{"ast-types":471}],450:[function(require,module,exports){ +},{"./comments":447,"./fast-path":448,"./lines":449,"./options":451,"./patcher":453,"./util":455,"assert":196,"ast-types":477}],455:[function(require,module,exports){ "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; Object.defineProperty(exports, "__esModule", { value: true }); var assert_1 = __importDefault(require("assert")); -var types_1 = __importDefault(require("./types")); -var n = types_1.default.namedTypes; +var types = __importStar(require("ast-types")); +var n = types.namedTypes; var source_map_1 = __importDefault(require("source-map")); var SourceMapConsumer = source_map_1.default.SourceMapConsumer; var SourceMapGenerator = source_map_1.default.SourceMapGenerator; @@ -68785,26 +71017,63 @@ function isTrailingCommaEnabled(options, context) { exports.isTrailingCommaEnabled = isTrailingCommaEnabled; ; -},{"./types":449,"assert":191,"source-map":483}],451:[function(require,module,exports){ +},{"assert":196,"ast-types":477,"source-map":489}],456:[function(require,module,exports){ (function (process){ -"use strict";; +"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; Object.defineProperty(exports, "__esModule", { value: true }); var fs_1 = __importDefault(require("fs")); -var types_1 = __importDefault(require("./lib/types")); +var types = __importStar(require("ast-types")); +exports.types = types; var parser_1 = require("./lib/parser"); +exports.parse = parser_1.parse; var printer_1 = require("./lib/printer"); +/** + * 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); + * } + * }); + */ +var ast_types_1 = require("ast-types"); +exports.visit = ast_types_1.visit; +/** + * Reprint a modified syntax tree using as much of the original source + * code as possible. + */ function print(node, options) { return new printer_1.Printer(options).print(node); } +exports.print = print; +/** + * Print without attempting to reuse any original source code. + */ function prettyPrint(node, options) { return new printer_1.Printer(options).printGenerically(node); } +exports.prettyPrint = prettyPrint; +/** + * Convenient command-line interface (see e.g. example/add-braces). + */ function run(transformer, options) { return runFile(process.argv[2], transformer, options); } +exports.run = run; function runFile(path, transformer, options) { fs_1.default.readFile(path, "utf-8", function (err, code) { if (err) { @@ -68823,68 +71092,9 @@ function runString(code, transformer, options) { writeback(print(node, options).code); }); } -var main = {}; -Object.defineProperties(main, { - /** - * Parse a string of code into an augmented syntax tree suitable for - * arbitrary modification and reprinting. - */ - parse: { - enumerable: true, - value: parser_1.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_1.default.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_1.default - }, - /** - * Convenient command-line interface (see e.g. example/add-braces). - */ - run: { - enumerable: false, - value: run - } -}); -exports.default = main; -module.exports = exports["default"]; }).call(this,require('_process')) -},{"./lib/parser":446,"./lib/printer":448,"./lib/types":449,"_process":426,"fs":196}],452:[function(require,module,exports){ +},{"./lib/parser":452,"./lib/printer":454,"_process":433,"ast-types":477,"fs":201}],457:[function(require,module,exports){ "use strict";; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -69144,7 +71354,7 @@ function default_1(fork) { exports.default = default_1; module.exports = exports["default"]; -},{"../lib/shared":469,"../lib/types":470,"./es7":457}],453:[function(require,module,exports){ +},{"../lib/shared":475,"../lib/types":476,"./es7":462}],458:[function(require,module,exports){ "use strict";; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -69159,7 +71369,7 @@ function default_1(fork) { exports.default = default_1; module.exports = exports["default"]; -},{"./babel-core":452,"./flow":459}],454:[function(require,module,exports){ +},{"./babel-core":457,"./flow":464}],459:[function(require,module,exports){ "use strict";; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -69319,8 +71529,7 @@ function default_1(fork) { .build("id", "init") .field("id", def("Pattern")) .field("init", or(def("Expression"), null), defaults["null"]); - // TODO Are all Expressions really Patterns? - def("Expression").bases("Node", "Pattern"); + def("Expression").bases("Node"); def("ThisExpression").bases("Expression").build(); def("ArrayExpression") .bases("Expression") @@ -69363,7 +71572,7 @@ function default_1(fork) { .bases("Expression") .build("operator", "left", "right") .field("operator", AssignmentOperator) - .field("left", def("Pattern")) + .field("left", or(def("Pattern"), def("MemberExpression"))) .field("right", def("Expression")); var UpdateOperator = or("++", "--"); def("UpdateExpression") @@ -69420,14 +71629,12 @@ function default_1(fork) { .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") + .bases("Expression", "Pattern") .build("name") .field("name", String) .field("optional", Boolean, defaults["false"]); def("Literal") - // But aren't Expressions already Nodes? TODO Report this. - .bases("Node", "Expression") + .bases("Expression") .build("value") .field("value", or(String, Boolean, null, Number, RegExp)) .field("regex", or({ @@ -69464,7 +71671,7 @@ function default_1(fork) { exports.default = default_1; module.exports = exports["default"]; -},{"../lib/shared":469,"../lib/types":470}],455:[function(require,module,exports){ +},{"../lib/shared":475,"../lib/types":476}],460:[function(require,module,exports){ "use strict";; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -69501,7 +71708,7 @@ function default_1(fork) { exports.default = default_1; module.exports = exports["default"]; -},{"../lib/shared":469,"../lib/types":470,"./core":454}],456:[function(require,module,exports){ +},{"../lib/shared":475,"../lib/types":476,"./core":459}],461:[function(require,module,exports){ "use strict";; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -69715,7 +71922,7 @@ function default_1(fork) { exports.default = default_1; module.exports = exports["default"]; -},{"../lib/shared":469,"../lib/types":470,"./core":454}],457:[function(require,module,exports){ +},{"../lib/shared":475,"../lib/types":476,"./core":459}],462:[function(require,module,exports){ "use strict";; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -69753,7 +71960,7 @@ function default_1(fork) { exports.default = default_1; module.exports = exports["default"]; -},{"../lib/shared":469,"../lib/types":470,"./es6":456}],458:[function(require,module,exports){ +},{"../lib/shared":475,"../lib/types":476,"./es6":461}],463:[function(require,module,exports){ "use strict";; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -69806,7 +72013,7 @@ function default_1(fork) { exports.default = default_1; module.exports = exports["default"]; -},{"../lib/shared":469,"../lib/types":470,"./es7":457}],459:[function(require,module,exports){ +},{"../lib/shared":475,"../lib/types":476,"./es7":462}],464:[function(require,module,exports){ "use strict";; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -70094,11 +72301,15 @@ function default_1(fork) { .bases("FlowPredicate") .build("value") .field("value", def("Expression")); + def("CallExpression") + .field("typeArguments", or(null, def("TypeParameterInstantiation")), defaults["null"]); + def("NewExpression") + .field("typeArguments", or(null, def("TypeParameterInstantiation")), defaults["null"]); } exports.default = default_1; module.exports = exports["default"]; -},{"../lib/shared":469,"../lib/types":470,"./es7":457,"./type-annotations":461}],460:[function(require,module,exports){ +},{"../lib/shared":475,"../lib/types":476,"./es7":462,"./type-annotations":466}],465:[function(require,module,exports){ "use strict";; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -70205,7 +72416,7 @@ function default_1(fork) { exports.default = default_1; module.exports = exports["default"]; -},{"../lib/shared":469,"../lib/types":470,"./es7":457}],461:[function(require,module,exports){ +},{"../lib/shared":475,"../lib/types":476,"./es7":462}],466:[function(require,module,exports){ "use strict";; /** * Type annotation defs shared between Flow and TypeScript. @@ -70249,7 +72460,7 @@ function default_1(fork) { exports.default = default_1; module.exports = exports["default"]; -},{"../lib/shared":469,"../lib/types":470}],462:[function(require,module,exports){ +},{"../lib/shared":475,"../lib/types":476}],467:[function(require,module,exports){ "use strict";; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -70306,13 +72517,13 @@ function default_1(fork) { .field("left", TSEntityName) .field("right", TSEntityName); def("TSAsExpression") - .bases("Expression") - .build("expression") + .bases("Expression", "Pattern") + .build("expression", "typeAnnotation") .field("expression", def("Expression")) .field("typeAnnotation", def("TSType")) .field("extra", or({ parenthesized: Boolean }, null), defaults["null"]); def("TSNonNullExpression") - .bases("Expression") + .bases("Expression", "Pattern") .build("expression") .field("expression", def("Expression")); [ @@ -70496,7 +72707,7 @@ function default_1(fork) { .field("constraint", or(def("TSType"), void 0), defaults["undefined"]) .field("default", or(def("TSType"), void 0), defaults["undefined"]); def("TSTypeAssertion") - .bases("Expression") + .bases("Expression", "Pattern") .build("typeAnnotation", "expression") .field("typeAnnotation", def("TSType")) .field("expression", def("Expression")) @@ -70590,7 +72801,7 @@ function default_1(fork) { exports.default = default_1; module.exports = exports["default"]; -},{"../lib/shared":469,"../lib/types":470,"./babel-core":452,"./type-annotations":461}],463:[function(require,module,exports){ +},{"../lib/shared":475,"../lib/types":476,"./babel-core":457,"./type-annotations":466}],468:[function(require,module,exports){ "use strict";; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -70607,7 +72818,7 @@ function default_1(defs) { defs.forEach(fork.use); types.finalize(); var PathVisitor = fork.use(path_visitor_1.default); - var exports = { + return { Type: types.Type, builtInTypes: types.builtInTypes, namedTypes: types.namedTypes, @@ -70627,7 +72838,6 @@ function default_1(defs) { use: fork.use, visit: PathVisitor.visit, }; - return exports; } exports.default = default_1; function createFork() { @@ -70647,7 +72857,14 @@ function createFork() { } module.exports = exports["default"]; -},{"./lib/equiv":464,"./lib/node-path":465,"./lib/path":467,"./lib/path-visitor":466,"./lib/types":470}],464:[function(require,module,exports){ +},{"./lib/equiv":470,"./lib/node-path":471,"./lib/path":473,"./lib/path-visitor":472,"./lib/types":476}],469:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var namedTypes; +(function (namedTypes) { +})(namedTypes = exports.namedTypes || (exports.namedTypes = {})); + +},{}],470:[function(require,module,exports){ "use strict";; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -70805,7 +73022,7 @@ function default_1(fork) { exports.default = default_1; module.exports = exports["default"]; -},{"./types":470}],465:[function(require,module,exports){ +},{"./types":476}],471:[function(require,module,exports){ "use strict";; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -70971,20 +73188,22 @@ function nodePathPlugin(fork) { return this.name === "object" && parent.object === node; case "BinaryExpression": - case "LogicalExpression": + case "LogicalExpression": { + var n_1 = node; var po = parent.operator; - var pp = PRECEDENCE[po]; - var no = node.operator; + var pp_1 = PRECEDENCE[po]; + var no = n_1.operator; var np = PRECEDENCE[no]; - if (pp > np) { + if (pp_1 > np) { return true; } - if (pp === np && this.name === "right") { - if (parent.right !== node) { + if (pp_1 === np && this.name === "right") { + if (parent.right !== n_1) { throw new Error("Nodes must be equal"); } return true; } + } default: return false; } @@ -71218,7 +73437,7 @@ function nodePathPlugin(fork) { exports.default = nodePathPlugin; module.exports = exports["default"]; -},{"./path":467,"./scope":468,"./types":470}],466:[function(require,module,exports){ +},{"./path":473,"./scope":474,"./types":476}],472:[function(require,module,exports){ "use strict";; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -71565,7 +73784,7 @@ function pathVisitorPlugin(fork) { exports.default = pathVisitorPlugin; module.exports = exports["default"]; -},{"./node-path":465,"./types":470}],467:[function(require,module,exports){ +},{"./node-path":471,"./types":476}],473:[function(require,module,exports){ "use strict";; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -71900,7 +74119,7 @@ function pathPlugin(fork) { exports.default = pathPlugin; module.exports = exports["default"]; -},{"./types":470}],468:[function(require,module,exports){ +},{"./types":476}],474:[function(require,module,exports){ "use strict";; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -72107,7 +74326,9 @@ function scopePlugin(fork) { addPattern(path.get("id"), bindings); } else if (ScopeType.check(node)) { - if (namedTypes.CatchClause.check(node)) { + if (namedTypes.CatchClause.check(node) && + // TODO Broaden this to accept any pattern. + namedTypes.Identifier.check(node.param)) { var catchParamName = node.param.name; var hadBinding = hasOwn.call(bindings, catchParamName); // Any declarations that occur inside the catch body that do @@ -72217,7 +74438,7 @@ function scopePlugin(fork) { exports.default = scopePlugin; module.exports = exports["default"]; -},{"./types":470}],469:[function(require,module,exports){ +},{"./types":476}],475:[function(require,module,exports){ "use strict";; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -72268,7 +74489,7 @@ function default_1(fork) { exports.default = default_1; module.exports = exports["default"]; -},{"./types":470}],470:[function(require,module,exports){ +},{"./types":476}],476:[function(require,module,exports){ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { @@ -73051,8 +75272,8 @@ function typesPlugin(_fork) { exports.default = typesPlugin; ; -},{}],471:[function(require,module,exports){ -"use strict";; +},{}],477:[function(require,module,exports){ +"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; @@ -73067,7 +75288,9 @@ var esprima_1 = __importDefault(require("./def/esprima")); var babel_1 = __importDefault(require("./def/babel")); var typescript_1 = __importDefault(require("./def/typescript")); var es_proposals_1 = __importDefault(require("./def/es-proposals")); -var defs = [ +var namedTypes_1 = require("./gen/namedTypes"); +exports.namedTypes = namedTypes_1.namedTypes; +var _a = fork_1.default([ // This core module of AST types captures ES5 as it is parsed today by // git://github.com/ariya/esprima.git#master. core_1.default, @@ -73081,12 +75304,29 @@ var defs = [ babel_1.default, typescript_1.default, es_proposals_1.default, -]; -var main = fork_1.default(defs); -exports.default = main; -module.exports = exports["default"]; +]), astNodesAreEquivalent = _a.astNodesAreEquivalent, builders = _a.builders, builtInTypes = _a.builtInTypes, defineMethod = _a.defineMethod, eachField = _a.eachField, finalize = _a.finalize, getBuilderName = _a.getBuilderName, getFieldNames = _a.getFieldNames, getFieldValue = _a.getFieldValue, getSupertypeNames = _a.getSupertypeNames, n = _a.namedTypes, NodePath = _a.NodePath, Path = _a.Path, PathVisitor = _a.PathVisitor, someField = _a.someField, Type = _a.Type, use = _a.use, visit = _a.visit; +exports.astNodesAreEquivalent = astNodesAreEquivalent; +exports.builders = builders; +exports.builtInTypes = builtInTypes; +exports.defineMethod = defineMethod; +exports.eachField = eachField; +exports.finalize = finalize; +exports.getBuilderName = getBuilderName; +exports.getFieldNames = getFieldNames; +exports.getFieldValue = getFieldValue; +exports.getSupertypeNames = getSupertypeNames; +exports.NodePath = NodePath; +exports.Path = Path; +exports.PathVisitor = PathVisitor; +exports.someField = someField; +exports.Type = Type; +exports.use = use; +exports.visit = visit; +// Populate the exported fields of the namedTypes namespace, while still +// retaining its member types. +Object.assign(namedTypes_1.namedTypes, n); -},{"./def/babel":453,"./def/core":454,"./def/es-proposals":455,"./def/es6":456,"./def/es7":457,"./def/esprima":458,"./def/flow":459,"./def/jsx":460,"./def/typescript":462,"./fork":463}],472:[function(require,module,exports){ +},{"./def/babel":458,"./def/core":459,"./def/es-proposals":460,"./def/es6":461,"./def/es7":462,"./def/esprima":463,"./def/flow":464,"./def/jsx":465,"./def/typescript":467,"./fork":468,"./gen/namedTypes":469}],478:[function(require,module,exports){ (function webpackUniversalModuleDefinition(root, factory) { /* istanbul ignore next */ if(typeof exports === 'object' && typeof module === 'object') @@ -79796,7 +82036,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ ]) }); ; -},{}],473:[function(require,module,exports){ +},{}],479:[function(require,module,exports){ /* -*- Mode: js; js-indent-level: 2; -*- */ /* * Copyright 2011 Mozilla Foundation and contributors @@ -79919,7 +82159,7 @@ ArraySet.prototype.toArray = function ArraySet_toArray() { exports.ArraySet = ArraySet; -},{"./util":482}],474:[function(require,module,exports){ +},{"./util":488}],480:[function(require,module,exports){ /* -*- Mode: js; js-indent-level: 2; -*- */ /* * Copyright 2011 Mozilla Foundation and contributors @@ -80061,7 +82301,7 @@ exports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) { aOutParam.rest = aIndex; }; -},{"./base64":475}],475:[function(require,module,exports){ +},{"./base64":481}],481:[function(require,module,exports){ /* -*- Mode: js; js-indent-level: 2; -*- */ /* * Copyright 2011 Mozilla Foundation and contributors @@ -80130,7 +82370,7 @@ exports.decode = function (charCode) { return -1; }; -},{}],476:[function(require,module,exports){ +},{}],482:[function(require,module,exports){ /* -*- Mode: js; js-indent-level: 2; -*- */ /* * Copyright 2011 Mozilla Foundation and contributors @@ -80243,7 +82483,7 @@ exports.search = function search(aNeedle, aHaystack, aCompare, aBias) { return index; }; -},{}],477:[function(require,module,exports){ +},{}],483:[function(require,module,exports){ /* -*- Mode: js; js-indent-level: 2; -*- */ /* * Copyright 2014 Mozilla Foundation and contributors @@ -80324,7 +82564,7 @@ MappingList.prototype.toArray = function MappingList_toArray() { exports.MappingList = MappingList; -},{"./util":482}],478:[function(require,module,exports){ +},{"./util":488}],484:[function(require,module,exports){ /* -*- Mode: js; js-indent-level: 2; -*- */ /* * Copyright 2011 Mozilla Foundation and contributors @@ -80440,7 +82680,7 @@ exports.quickSort = function (ary, comparator) { doQuickSort(ary, comparator, 0, ary.length - 1); }; -},{}],479:[function(require,module,exports){ +},{}],485:[function(require,module,exports){ /* -*- Mode: js; js-indent-level: 2; -*- */ /* * Copyright 2011 Mozilla Foundation and contributors @@ -81587,7 +83827,7 @@ IndexedSourceMapConsumer.prototype._parseMappings = exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer; -},{"./array-set":473,"./base64-vlq":474,"./binary-search":476,"./quick-sort":478,"./util":482}],480:[function(require,module,exports){ +},{"./array-set":479,"./base64-vlq":480,"./binary-search":482,"./quick-sort":484,"./util":488}],486:[function(require,module,exports){ /* -*- Mode: js; js-indent-level: 2; -*- */ /* * Copyright 2011 Mozilla Foundation and contributors @@ -82014,7 +84254,7 @@ SourceMapGenerator.prototype.toString = exports.SourceMapGenerator = SourceMapGenerator; -},{"./array-set":473,"./base64-vlq":474,"./mapping-list":477,"./util":482}],481:[function(require,module,exports){ +},{"./array-set":479,"./base64-vlq":480,"./mapping-list":483,"./util":488}],487:[function(require,module,exports){ /* -*- Mode: js; js-indent-level: 2; -*- */ /* * Copyright 2011 Mozilla Foundation and contributors @@ -82429,7 +84669,7 @@ SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSou exports.SourceNode = SourceNode; -},{"./source-map-generator":480,"./util":482}],482:[function(require,module,exports){ +},{"./source-map-generator":486,"./util":488}],488:[function(require,module,exports){ /* -*- Mode: js; js-indent-level: 2; -*- */ /* * Copyright 2011 Mozilla Foundation and contributors @@ -82919,7 +85159,7 @@ function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) { } exports.computeSourceURL = computeSourceURL; -},{}],483:[function(require,module,exports){ +},{}],489:[function(require,module,exports){ /* * Copyright 2009-2011 Mozilla Foundation and contributors * Licensed under the New BSD license. See LICENSE.txt or: @@ -82929,7 +85169,7 @@ exports.SourceMapGenerator = require('./lib/source-map-generator').SourceMapGene exports.SourceMapConsumer = require('./lib/source-map-consumer').SourceMapConsumer; exports.SourceNode = require('./lib/source-node').SourceNode; -},{"./lib/source-map-consumer":479,"./lib/source-map-generator":480,"./lib/source-node":481}],484:[function(require,module,exports){ +},{"./lib/source-map-consumer":485,"./lib/source-map-generator":486,"./lib/source-node":487}],490:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); // This module is suitable for passing as options.parser when calling @@ -82959,5469 +85199,5778 @@ function parse(source, options) { exports.parse = parse; ; -},{"../lib/util":450,"esprima":472}],485:[function(require,module,exports){ -/* eslint-disable node/no-deprecated-api */ -var buffer = require('buffer') -var Buffer = buffer.Buffer - -// alternative to using Object.keys for old browsers -function copyProps (src, dst) { - for (var key in src) { - dst[key] = src[key] - } -} -if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { - module.exports = buffer -} else { - // Copy properties from require('buffer') - copyProps(buffer, exports) - exports.Buffer = SafeBuffer -} +},{"../lib/util":455,"esprima":478}],491:[function(require,module,exports){ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ -function SafeBuffer (arg, encodingOrOffset, length) { - return Buffer(arg, encodingOrOffset, length) -} +module.exports = { + plugins: [ + require("@babel/plugin-syntax-async-generators"), + require("@babel/plugin-proposal-function-sent"), + require("@babel/plugin-transform-classes"), + require("@babel/plugin-transform-arrow-functions"), + require("@babel/plugin-transform-block-scoping"), + require("@babel/plugin-transform-for-of"), + require("regenerator-transform").default + ] +}; -// Copy static methods from Buffer -copyProps(Buffer, SafeBuffer) +},{"@babel/plugin-proposal-function-sent":74,"@babel/plugin-syntax-async-generators":75,"@babel/plugin-transform-arrow-functions":77,"@babel/plugin-transform-block-scoping":78,"@babel/plugin-transform-classes":80,"@babel/plugin-transform-for-of":82,"regenerator-transform":496}],492:[function(require,module,exports){ +(function (__dirname){ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ -SafeBuffer.from = function (arg, encodingOrOffset, length) { - if (typeof arg === 'number') { - throw new TypeError('Argument must not be a number') - } - return Buffer(arg, encodingOrOffset, length) -} +exports.path = require("path").join( + __dirname, + "runtime.js" +); -SafeBuffer.alloc = function (size, fill, encoding) { - if (typeof size !== 'number') { - throw new TypeError('Argument must be a number') - } - var buf = Buffer(size) - if (fill !== undefined) { - if (typeof encoding === 'string') { - buf.fill(fill, encoding) - } else { - buf.fill(fill) - } - } else { - buf.fill(0) - } - return buf -} +}).call(this,"/node_modules/regenerator-runtime") +},{"path":430}],493:[function(require,module,exports){ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ -SafeBuffer.allocUnsafe = function (size) { - if (typeof size !== 'number') { - throw new TypeError('Argument must be a number') - } - return Buffer(size) -} +var runtime = (function (exports) { + "use strict"; -SafeBuffer.allocUnsafeSlow = function (size) { - if (typeof size !== 'number') { - throw new TypeError('Argument must be a number') - } - return buffer.SlowBuffer(size) -} + var Op = Object.prototype; + var hasOwn = Op.hasOwnProperty; + var undefined; // More compressible than void 0. + var $Symbol = typeof Symbol === "function" ? Symbol : {}; + var iteratorSymbol = $Symbol.iterator || "@@iterator"; + var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; + var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; -},{"buffer":198}],486:[function(require,module,exports){ -arguments[4][473][0].apply(exports,arguments) -},{"./util":495,"dup":473}],487:[function(require,module,exports){ -arguments[4][474][0].apply(exports,arguments) -},{"./base64":488,"dup":474}],488:[function(require,module,exports){ -arguments[4][475][0].apply(exports,arguments) -},{"dup":475}],489:[function(require,module,exports){ -arguments[4][476][0].apply(exports,arguments) -},{"dup":476}],490:[function(require,module,exports){ -arguments[4][477][0].apply(exports,arguments) -},{"./util":495,"dup":477}],491:[function(require,module,exports){ -arguments[4][478][0].apply(exports,arguments) -},{"dup":478}],492:[function(require,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 - */ + function wrap(innerFn, outerFn, self, tryLocsList) { + // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. + var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; + var generator = Object.create(protoGenerator.prototype); + var context = new Context(tryLocsList || []); -var util = require('./util'); -var binarySearch = require('./binary-search'); -var ArraySet = require('./array-set').ArraySet; -var base64VLQ = require('./base64-vlq'); -var quickSort = require('./quick-sort').quickSort; + // The ._invoke method unifies the implementations of the .next, + // .throw, and .return methods. + generator._invoke = makeInvokeMethod(innerFn, self, context); -function SourceMapConsumer(aSourceMap) { - var sourceMap = aSourceMap; - if (typeof aSourceMap === 'string') { - sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, '')); + return generator; } + exports.wrap = wrap; - return sourceMap.sections != null - ? new IndexedSourceMapConsumer(sourceMap) - : new BasicSourceMapConsumer(sourceMap); -} + // 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 }; + } + } -SourceMapConsumer.fromSourceMap = function(aSourceMap) { - return BasicSourceMapConsumer.fromSourceMap(aSourceMap); -} + var GenStateSuspendedStart = "suspendedStart"; + var GenStateSuspendedYield = "suspendedYield"; + var GenStateExecuting = "executing"; + var GenStateCompleted = "completed"; -/** - * The version of the source mapping spec that we are consuming. - */ -SourceMapConsumer.prototype._version = 3; + // Returning this object from the innerFn has the same effect as + // breaking out of the dispatch switch statement. + var ContinueSentinel = {}; -// `__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. + // 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() {} -SourceMapConsumer.prototype.__generatedMappings = null; -Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', { - get: function () { - if (!this.__generatedMappings) { - this._parseMappings(this._mappings, this.sourceRoot); - } + // This is a polyfill for %IteratorPrototype% for environments that + // don't natively support it. + var IteratorPrototype = {}; + IteratorPrototype[iteratorSymbol] = function () { + return this; + }; - return this.__generatedMappings; + var getProto = Object.getPrototypeOf; + var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); + if (NativeIteratorPrototype && + NativeIteratorPrototype !== Op && + hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { + // This environment has a native %IteratorPrototype%; use it instead + // of the polyfill. + IteratorPrototype = NativeIteratorPrototype; } -}); -SourceMapConsumer.prototype.__originalMappings = null; -Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', { - get: function () { - if (!this.__originalMappings) { - this._parseMappings(this._mappings, this.sourceRoot); - } + var Gp = GeneratorFunctionPrototype.prototype = + Generator.prototype = Object.create(IteratorPrototype); + GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; + GeneratorFunctionPrototype.constructor = GeneratorFunction; + GeneratorFunctionPrototype[toStringTagSymbol] = + GeneratorFunction.displayName = "GeneratorFunction"; - return this.__originalMappings; + // 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); + }; + }); } -}); -SourceMapConsumer.prototype._charIsMappingSeparator = - function SourceMapConsumer_charIsMappingSeparator(aStr, index) { - var c = aStr.charAt(index); - return c === ";" || c === ","; + exports.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; }; -/** - * 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"); + exports.mark = function(genFun) { + if (Object.setPrototypeOf) { + Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); + } else { + genFun.__proto__ = GeneratorFunctionPrototype; + if (!(toStringTagSymbol in genFun)) { + genFun[toStringTagSymbol] = "GeneratorFunction"; + } + } + genFun.prototype = Object.create(Gp); + return genFun; }; -SourceMapConsumer.GENERATED_ORDER = 1; -SourceMapConsumer.ORIGINAL_ORDER = 2; - -SourceMapConsumer.GREATEST_LOWER_BOUND = 1; -SourceMapConsumer.LEAST_UPPER_BOUND = 2; + // Within the body of any async function, `await x` is transformed to + // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test + // `hasOwn.call(value, "__await")` to determine if the yielded value is + // meant to be awaited. + exports.awrap = function(arg) { + return { __await: arg }; + }; -/** - * 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; + function AsyncIterator(generator, PromiseImpl) { + function invoke(method, arg, resolve, reject) { + var record = tryCatch(generator[method], generator, arg); + if (record.type === "throw") { + reject(record.arg); + } else { + var result = record.arg; + var value = result.value; + if (value && + typeof value === "object" && + hasOwn.call(value, "__await")) { + return PromiseImpl.resolve(value.__await).then(function(value) { + invoke("next", value, resolve, reject); + }, function(err) { + invoke("throw", err, resolve, reject); + }); + } - 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."); + return PromiseImpl.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. + result.value = unwrapped; + resolve(result); + }, function(error) { + // If a rejected Promise was yielded, throw the rejection back + // into the async generator function so it can be handled there. + return invoke("throw", error, resolve, reject); + }); + } } - 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); + var previousPromise; + + function enqueue(method, arg) { + function callInvokeWithMethodAndArg() { + return new PromiseImpl(function(resolve, reject) { + invoke(method, arg, resolve, reject); + }); } - 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 []; + 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 + ) : callInvokeWithMethodAndArg(); } - needle.source = this._sources.indexOf(needle.source); - var mappings = []; + // Define the unified helper method that is used to implement .next, + // .throw, and .return (see defineIteratorMethods). + this._invoke = enqueue; + } - var index = this._findMapping(needle, - this._originalMappings, - "originalLine", - "originalColumn", - util.compareByOriginalPositions, - binarySearch.LEAST_UPPER_BOUND); - if (index >= 0) { - var mapping = this._originalMappings[index]; + defineIteratorMethods(AsyncIterator.prototype); + AsyncIterator.prototype[asyncIteratorSymbol] = function () { + return this; + }; + exports.AsyncIterator = AsyncIterator; - if (aArgs.column === undefined) { - var originalLine = mapping.originalLine; + // 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. + exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) { + if (PromiseImpl === void 0) PromiseImpl = Promise; - // 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) - }); + var iter = new AsyncIterator( + wrap(innerFn, outerFn, self, tryLocsList), + PromiseImpl + ); - mapping = this._originalMappings[++index]; - } - } else { - var originalColumn = mapping.originalColumn; + return exports.isGeneratorFunction(outerFn) + ? iter // If outerFn is a generator, return the full iterator. + : iter.next().then(function(result) { + return result.done ? result.value : iter.next(); + }); + }; - // 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) - }); + function makeInvokeMethod(innerFn, self, context) { + var state = GenStateSuspendedStart; - mapping = this._originalMappings[++index]; - } + return function invoke(method, arg) { + if (state === GenStateExecuting) { + throw new Error("Generator is already running"); } - } - return mappings; - }; + if (state === GenStateCompleted) { + if (method === "throw") { + throw arg; + } -exports.SourceMapConsumer = SourceMapConsumer; + // Be forgiving, per 25.3.3.3.3 of the spec: + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume + return doneResult(); + } -/** - * 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(/^\)\]\}'/, '')); - } + context.method = method; + context.arg = arg; - 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); + while (true) { + var delegate = context.delegate; + if (delegate) { + var delegateResult = maybeInvokeDelegate(delegate, context); + if (delegateResult) { + if (delegateResult === ContinueSentinel) continue; + return delegateResult; + } + } - // 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); - } + if (context.method === "next") { + // Setting context._sent for legacy support of Babel's + // function.sent implementation. + context.sent = context._sent = context.arg; - sources = sources - .map(String) - // 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; - }); + } else if (context.method === "throw") { + if (state === GenStateSuspendedStart) { + state = GenStateCompleted; + throw context.arg; + } - // 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.map(String), true); - this._sources = ArraySet.fromArray(sources, true); + context.dispatchException(context.arg); - this.sourceRoot = sourceRoot; - this.sourcesContent = sourcesContent; - this._mappings = mappings; - this.file = file; -} + } else if (context.method === "return") { + context.abrupt("return", context.arg); + } -BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype); -BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer; + state = GenStateExecuting; -/** - * 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 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 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; + if (record.arg === ContinueSentinel) { + continue; + } - // 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. + return { + value: record.arg, + done: context.done + }; - var generatedMappings = aSourceMap._mappings.toArray().slice(); - var destGeneratedMappings = smc.__generatedMappings = []; - var destOriginalMappings = smc.__originalMappings = []; + } else if (record.type === "throw") { + state = GenStateCompleted; + // Dispatch the exception by looping back around to the + // context.dispatchException(context.arg) call above. + context.method = "throw"; + context.arg = record.arg; + } + } + }; + } - 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; + // Call delegate.iterator[context.method](context.arg) and handle the + // result, either by returning a { value, done } result from the + // delegate iterator, or by modifying context.method and context.arg, + // setting context.delegate to null, and returning the ContinueSentinel. + function maybeInvokeDelegate(delegate, context) { + var method = delegate.iterator[context.method]; + if (method === undefined) { + // A .throw or .return when the delegate iterator has no .throw + // method always terminates the yield* loop. + context.delegate = null; - if (srcMapping.source) { - destMapping.source = sources.indexOf(srcMapping.source); - destMapping.originalLine = srcMapping.originalLine; - destMapping.originalColumn = srcMapping.originalColumn; + if (context.method === "throw") { + // Note: ["return"] must be used for ES3 parsing compatibility. + if (delegate.iterator["return"]) { + // If the delegate iterator has a return method, give it a + // chance to clean up. + context.method = "return"; + context.arg = undefined; + maybeInvokeDelegate(delegate, context); - if (srcMapping.name) { - destMapping.name = names.indexOf(srcMapping.name); + if (context.method === "throw") { + // If maybeInvokeDelegate(context) changed context.method from + // "return" to "throw", let that override the TypeError below. + return ContinueSentinel; + } } - destOriginalMappings.push(destMapping); + context.method = "throw"; + context.arg = new TypeError( + "The iterator does not provide a 'throw' method"); } - destGeneratedMappings.push(destMapping); + return ContinueSentinel; } - quickSort(smc.__originalMappings, util.compareByOriginalPositions); + var record = tryCatch(method, delegate.iterator, context.arg); - return smc; - }; + if (record.type === "throw") { + context.method = "throw"; + context.arg = record.arg; + context.delegate = null; + return ContinueSentinel; + } -/** - * The version of the source mapping spec that we are consuming. - */ -BasicSourceMapConsumer.prototype._version = 3; + var info = record.arg; -/** - * 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); - } -}); + if (! info) { + context.method = "throw"; + context.arg = new TypeError("iterator result is not an object"); + context.delegate = null; + return ContinueSentinel; + } -/** - * 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; -} + if (info.done) { + // Assign the result of the finished delegate to the temporary + // variable specified by delegate.resultName (see delegateYield). + context[delegate.resultName] = info.value; -/** - * 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; + // Resume execution at the desired location (see delegateYield). + context.next = delegate.nextLoc; - while (index < length) { - if (aStr.charAt(index) === ';') { - generatedLine++; - index++; - previousGeneratedColumn = 0; - } - else if (aStr.charAt(index) === ',') { - index++; + // If context.method was "throw" but the delegate handled the + // exception, let the outer generator proceed normally. If + // context.method was "next", forget context.arg since it has been + // "consumed" by the delegate iterator. If context.method was + // "return", allow the original .return call to continue in the + // outer generator. + if (context.method !== "return") { + context.method = "next"; + context.arg = undefined; } - 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'); - } + } else { + // Re-yield the result returned by the delegate method. + return info; + } - if (segment.length === 3) { - throw new Error('Found a source and line, but no column'); - } + // The delegate iterator is finished, so forget it and continue with + // the outer generator. + context.delegate = null; + return ContinueSentinel; + } - cachedSegments[str] = segment; - } + // Define Generator.prototype.{next,throw,return} in terms of the + // unified ._invoke helper method. + defineIteratorMethods(Gp); - // Generated column. - mapping.generatedColumn = previousGeneratedColumn + segment[0]; - previousGeneratedColumn = mapping.generatedColumn; + Gp[toStringTagSymbol] = "Generator"; - if (segment.length > 1) { - // Original source. - mapping.source = previousSource + segment[1]; - previousSource += segment[1]; + // A Generator should always return itself as the iterator object when the + // @@iterator function is called on it. Some browsers' implementations of the + // iterator prototype chain incorrectly implement this, causing the Generator + // object to not be returned from this call. This ensures that doesn't happen. + // See https://github.com/facebook/regenerator/issues/274 for more details. + Gp[iteratorSymbol] = function() { + return this; + }; - // Original line. - mapping.originalLine = previousOriginalLine + segment[2]; - previousOriginalLine = mapping.originalLine; - // Lines are stored 0-based - mapping.originalLine += 1; + Gp.toString = function() { + return "[object Generator]"; + }; - // Original column. - mapping.originalColumn = previousOriginalColumn + segment[3]; - previousOriginalColumn = mapping.originalColumn; + function pushTryEntry(locs) { + var entry = { tryLoc: locs[0] }; - if (segment.length > 4) { - // Original name. - mapping.name = previousName + segment[4]; - previousName += segment[4]; - } - } + if (1 in locs) { + entry.catchLoc = locs[1]; + } - generatedMappings.push(mapping); - if (typeof mapping.originalLine === 'number') { - originalMappings.push(mapping); - } - } + if (2 in locs) { + entry.finallyLoc = locs[2]; + entry.afterLoc = locs[3]; } - quickSort(generatedMappings, util.compareByGeneratedPositionsDeflated); - this.__generatedMappings = generatedMappings; + this.tryEntries.push(entry); + } - quickSort(originalMappings, util.compareByOriginalPositions); - this.__originalMappings = originalMappings; - }; + function resetTryEntry(entry) { + var record = entry.completion || {}; + record.type = "normal"; + delete record.arg; + entry.completion = record; + } -/** - * 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. + 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); + } - 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]); + exports.keys = function(object) { + var keys = []; + for (var key in object) { + keys.push(key); } + keys.reverse(); - 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; + // 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; } } - // 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') + // 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; }; + }; - var index = this._findMapping( - needle, - this._generatedMappings, - "generatedLine", - "generatedColumn", - util.compareByGeneratedPositionsDeflated, - util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND) - ); + function values(iterable) { + if (iterable) { + var iteratorMethod = iterable[iteratorSymbol]; + if (iteratorMethod) { + return iteratorMethod.call(iterable); + } - if (index >= 0) { - var mapping = this._generatedMappings[index]; + if (typeof iterable.next === "function") { + return iterable; + } - 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); + 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; + } } - } - 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 + + next.value = undefined; + next.done = true; + + return next; }; + + return next.next = next; } } - return { - source: null, - line: null, - column: null, - name: null - }; - }; + // Return an iterator with no values. + return { next: doneResult }; + } + exports.values = values; -/** - * 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; }); - }; + function doneResult() { + return { value: undefined, done: true }; + } -/** - * 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; - } + Context.prototype = { + constructor: Context, - if (this.sourceRoot != null) { - aSource = util.relative(this.sourceRoot, aSource); - } + reset: function(skipTempReset) { + this.prev = 0; + this.next = 0; + // Resetting context._sent for legacy support of Babel's + // function.sent implementation. + this.sent = this._sent = undefined; + this.done = false; + this.delegate = null; - if (this._sources.has(aSource)) { - return this.sourcesContent[this._sources.indexOf(aSource)]; - } + this.method = "next"; + this.arg = undefined; - 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)] - } + this.tryEntries.forEach(resetTryEntry); - if ((!url.path || url.path == "/") - && this._sources.has("/" + aSource)) { - return this.sourcesContent[this._sources.indexOf("/" + aSource)]; + 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; + } + } } - } + }, - // 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.'); - } - }; + stop: function() { + this.done = true; -/** - * 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 rootEntry = this.tryEntries[0]; + var rootRecord = rootEntry.completion; + if (rootRecord.type === "throw") { + throw rootRecord.arg; + } - var needle = { - source: source, - originalLine: util.getArg(aArgs, 'line'), - originalColumn: util.getArg(aArgs, 'column') - }; + return this.rval; + }, - var index = this._findMapping( - needle, - this._originalMappings, - "originalLine", - "originalColumn", - util.compareByOriginalPositions, - util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND) - ); + dispatchException: function(exception) { + if (this.done) { + throw exception; + } - if (index >= 0) { - var mapping = this._originalMappings[index]; + var context = this; + function handle(loc, caught) { + record.type = "throw"; + record.arg = exception; + context.next = loc; - if (mapping.source === needle.source) { - return { - line: util.getArg(mapping, 'generatedLine', null), - column: util.getArg(mapping, 'generatedColumn', null), - lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null) - }; + if (caught) { + // If the dispatched exception was caught by a catch block, + // then let that catch block handle the exception normally. + context.method = "next"; + context.arg = undefined; + } + + return !! caught; } - } - return { - line: null, - column: null, - lastColumn: null - }; - }; + for (var i = this.tryEntries.length - 1; i >= 0; --i) { + var entry = this.tryEntries[i]; + var record = entry.completion; -exports.BasicSourceMapConsumer = BasicSourceMapConsumer; + 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"); + } -/** - * 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(/^\)\]\}'/, '')); - } + if (entry.tryLoc <= this.prev) { + var hasCatch = hasOwn.call(entry, "catchLoc"); + var hasFinally = hasOwn.call(entry, "finallyLoc"); - var version = util.getArg(sourceMap, 'version'); - var sections = util.getArg(sourceMap, 'sections'); + if (hasCatch && hasFinally) { + if (this.prev < entry.catchLoc) { + return handle(entry.catchLoc, true); + } else if (this.prev < entry.finallyLoc) { + return handle(entry.finallyLoc); + } - if (version != this._version) { - throw new Error('Unsupported version: ' + version); - } + } else if (hasCatch) { + if (this.prev < entry.catchLoc) { + return handle(entry.catchLoc, true); + } - this._sources = new ArraySet(); - this._names = new ArraySet(); + } else if (hasFinally) { + if (this.prev < entry.finallyLoc) { + return handle(entry.finallyLoc); + } - 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'); + } else { + throw new Error("try statement without catch or finally"); + } + } + } + }, - if (offsetLine < lastOffset.line || - (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) { - throw new Error('Section offsets must be ordered and non-overlapping.'); - } - lastOffset = offset; + 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; + } + } - 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')) - } - }); -} + 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; + } -IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype); -IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer; + var record = finallyEntry ? finallyEntry.completion : {}; + record.type = type; + record.arg = arg; -/** - * The version of the source mapping spec that we are consuming. - */ -IndexedSourceMapConsumer.prototype._version = 3; + if (finallyEntry) { + this.method = "next"; + this.next = finallyEntry.finallyLoc; + return ContinueSentinel; + } -/** - * 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 this.complete(record); + }, + + complete: function(record, afterLoc) { + if (record.type === "throw") { + throw record.arg; } - } - 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; - } + if (record.type === "break" || + record.type === "continue") { + this.next = record.arg; + } else if (record.type === "return") { + this.rval = this.arg = record.arg; + this.method = "return"; + this.next = "end"; + } else if (record.type === "normal" && afterLoc) { + this.next = afterLoc; + } - return (needle.generatedColumn - - section.generatedOffset.generatedColumn); - }); - var section = this._sections[sectionIndex]; + return ContinueSentinel; + }, - if (!section) { - return { - source: null, - line: null, - column: null, - name: null - }; - } + 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; + } + } + }, - 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 - }); - }; + "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; + } + } -/** - * 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(); - }); - }; + // 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"); + }, -/** - * 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]; + delegateYield: function(iterable, resultName, nextLoc) { + this.delegate = { + iterator: values(iterable), + resultName: resultName, + nextLoc: nextLoc + }; - var content = section.consumer.sourceContentFor(aSource, true); - if (content) { - return content; + if (this.method === "next") { + // Deliberately forget the last sent value so that we don't + // accidentally pass it on to the delegate. + this.arg = undefined; } - } - 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 ContinueSentinel; } - - 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); + // Regardless of whether this script is executing as a CommonJS module + // or not, return the runtime object so that we can declare the variable + // regeneratorRuntime in the outer scope, which allows this module to be + // injected easily by `bin/regenerator --include-runtime script.js`. + return exports; - var name = section.consumer._names.at(mapping.name); - this._names.add(name); - name = this._names.indexOf(name); +}( + // If this script is executing as a CommonJS module, use module.exports + // as the regeneratorRuntime namespace. Otherwise create a new empty + // object. Either way, the resulting object will be used to initialize + // the regeneratorRuntime variable at the top of this file. + typeof module === "object" ? module.exports : {} +)); - // 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 - }; +try { + regeneratorRuntime = runtime; +} catch (accidentalStrictMode) { + // This module should not be running in strict mode, so the above + // assignment should always work unless something is misconfigured. Just + // in case runtime.js accidentally runs in strict mode, we can escape + // strict mode using a global Function call. This could conceivably fail + // if a Content Security Policy forbids using Function, but in that case + // the proper solution is to fix the accidental strict mode problem. If + // you've misconfigured your bundler to force strict mode and applied a + // CSP to forbid Function, and you're not willing to fix either of those + // problems, please detail your unique predicament in a GitHub issue. + Function("r", "regeneratorRuntime = r")(runtime); +} - this.__generatedMappings.push(adjustedMapping); - if (typeof adjustedMapping.originalLine === 'number') { - this.__originalMappings.push(adjustedMapping); - } - } - } +},{}],494:[function(require,module,exports){ +"use strict"; - quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated); - quickSort(this.__originalMappings, util.compareByOriginalPositions); - }; +var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); -exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer; +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -},{"./array-set":486,"./base64-vlq":487,"./binary-search":489,"./quick-sort":491,"./util":495}],493:[function(require,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 _assert = _interopRequireDefault(require("assert")); -var base64VLQ = require('./base64-vlq'); -var util = require('./util'); -var ArraySet = require('./array-set').ArraySet; -var MappingList = require('./mapping-list').MappingList; +var leap = _interopRequireWildcard(require("./leap")); -/** - * 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; -} +var meta = _interopRequireWildcard(require("./meta")); -SourceMapGenerator.prototype._version = 3; +var util = _interopRequireWildcard(require("./util")); /** - * Creates a new SourceMapGenerator based on a SourceMapConsumer + * Copyright (c) 2014-present, Facebook, Inc. * - * @param aSourceMapConsumer The SourceMap. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ -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 - } - }; +var hasOwn = Object.prototype.hasOwnProperty; - if (mapping.source != null) { - newMapping.source = mapping.source; - if (sourceRoot != null) { - newMapping.source = util.relative(sourceRoot, newMapping.source); - } +function Emitter(contextId) { + _assert["default"].ok(this instanceof Emitter); - newMapping.original = { - line: mapping.originalLine, - column: mapping.originalColumn - }; + util.getTypes().assertIdentifier(contextId); // Used to generate unique temporary names. - if (mapping.name != null) { - newMapping.name = mapping.name; - } - } + this.nextTempId = 0; // 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". - generator.addMapping(newMapping); - }); - aSourceMapConsumer.sources.forEach(function (sourceFile) { - var content = aSourceMapConsumer.sourceContentFor(sourceFile); - if (content != null) { - generator.setSourceContent(sourceFile, content); - } - }); - return generator; - }; + this.contextId = contextId; // An append-only list of Statements that grows each time this.emit is + // called. -/** - * 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); + this.listing = []; // A sparse array whose keys correspond to locations in this.listing + // that have been marked as branch/jump targets. - if (!this._skipValidation) { - this._validateMapping(generated, original, source, name); - } + this.marked = [true]; + this.insertedLocs = new Set(); // The last location will be marked when this.getDispatchLoop is + // called. - if (source != null) { - source = String(source); - if (!this._sources.has(source)) { - this._sources.add(source); - } - } + this.finalLoc = this.loc(); // A list of all leap.TryEntry statements emitted. - if (name != null) { - name = String(name); - if (!this._names.has(name)) { - this._names.add(name); - } - } + this.tryEntries = []; // 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. - this._mappings.add({ - generatedLine: generated.line, - generatedColumn: generated.column, - originalLine: original != null && original.line, - originalColumn: original != null && original.column, - source: source, - name: name - }); - }; + this.leapManager = new leap.LeapManager(this); +} -/** - * 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); - } +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. - if (aSourceContent != null) { - // Add the source content to the _sourcesContents map. - // Create a new _sourcesContents map if the property is null. - if (!this._sourcesContents) { - this._sourcesContents = Object.create(null); - } - this._sourcesContents[util.toSetString(source)] = aSourceContent; - } else if (this._sourcesContents) { - // Remove the source file from the _sourcesContents map. - // If the _sourcesContents map is empty, set the property to null. - delete this._sourcesContents[util.toSetString(source)]; - if (Object.keys(this._sourcesContents).length === 0) { - this._sourcesContents = null; - } - } - }; +Ep.loc = function () { + var l = util.getTypes().numericLiteral(-1); + this.insertedLocs.add(l); + return l; +}; -/** - * 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(); +Ep.getInsertedLocs = function () { + return this.insertedLocs; +}; - // 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; - } - } - } +Ep.getContextId = function () { + return util.getTypes().clone(this.contextId); +}; // Sets the exact value of the given location to the offset of the next +// Statement emitted. - 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); - } +Ep.mark = function (loc) { + util.getTypes().assertLiteral(loc); + var index = this.listing.length; - }, this); - this._sources = newSources; - this._names = newNames; + if (loc.value === -1) { + loc.value = index; + } else { + // Locations can be marked redundantly, but their values cannot change + // once set the first time. + _assert["default"].strictEqual(loc.value, index); + } - // 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); - }; + this.marked[index] = true; + return loc; +}; -/** - * A mapping can have one of the three levels of data: - * - * 1. Just the generated position. - * 2. The Generated position, original position, and original source. - * 3. Generated and original position, original source, as well as a name - * token. - * - * To maintain consistency, we validate that any new mapping being added falls - * in to one of these categories. - */ -SourceMapGenerator.prototype._validateMapping = - function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource, - aName) { - // When aOriginal is truthy but has empty values for .line and .column, - // it is most likely a programmer error. In this case we throw a very - // specific error message to try to guide them the right way. - // For example: https://github.com/Polymer/polymer-bundler/pull/519 - if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') { - throw new Error( - 'original.line and original.column are not numbers -- you probably meant to omit ' + - 'the original mapping entirely and only map the generated position. If so, pass ' + - 'null for the original mapping instead of an object with empty or null values.' - ); - } +Ep.emit = function (node) { + var t = util.getTypes(); - 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 - })); - } - }; + if (t.isExpression(node)) { + node = t.expressionStatement(node); + } -/** - * Serialize the accumulated mappings in to the stream of base 64 VLQs - * specified by the source map format. - */ -SourceMapGenerator.prototype._serializeMappings = - function SourceMapGenerator_serializeMappings() { - var previousGeneratedColumn = 0; - var previousGeneratedLine = 1; - var previousOriginalColumn = 0; - var previousOriginalLine = 0; - var previousName = 0; - var previousSource = 0; - var result = ''; - var next; - var mapping; - var nameIdx; - var sourceIdx; + t.assertStatement(node); + this.listing.push(node); +}; // Shorthand for emitting assignment statements. This will come in handy +// for assignments to temporary variables. - var mappings = this._mappings.toArray(); - for (var i = 0, len = mappings.length; i < len; i++) { - mapping = mappings[i]; - next = '' - if (mapping.generatedLine !== previousGeneratedLine) { - previousGeneratedColumn = 0; - while (mapping.generatedLine !== previousGeneratedLine) { - next += ';'; - previousGeneratedLine++; - } - } - else { - if (i > 0) { - if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) { - continue; - } - next += ','; - } - } +Ep.emitAssign = function (lhs, rhs) { + this.emit(this.assign(lhs, rhs)); + return lhs; +}; // Shorthand for an assignment statement. - next += base64VLQ.encode(mapping.generatedColumn - - previousGeneratedColumn); - previousGeneratedColumn = mapping.generatedColumn; - if (mapping.source != null) { - sourceIdx = this._sources.indexOf(mapping.source); - next += base64VLQ.encode(sourceIdx - previousSource); - previousSource = sourceIdx; +Ep.assign = function (lhs, rhs) { + var t = util.getTypes(); + return t.expressionStatement(t.assignmentExpression("=", t.cloneDeep(lhs), rhs)); +}; // Convenience function for generating expressions like context.next, +// context.sent, and context.rval. - // lines are stored 0-based in SourceMap spec version 3 - next += base64VLQ.encode(mapping.originalLine - 1 - - previousOriginalLine); - previousOriginalLine = mapping.originalLine - 1; - next += base64VLQ.encode(mapping.originalColumn - - previousOriginalColumn); - previousOriginalColumn = mapping.originalColumn; +Ep.contextProperty = function (name, computed) { + var t = util.getTypes(); + return t.memberExpression(this.getContextId(), computed ? t.stringLiteral(name) : t.identifier(name), !!computed); +}; // Shorthand for setting context.rval and jumping to `context.stop()`. - if (mapping.name != null) { - nameIdx = this._names.indexOf(mapping.name); - next += base64VLQ.encode(nameIdx - previousName); - previousName = nameIdx; - } - } - result += next; - } +Ep.stop = function (rval) { + if (rval) { + this.setReturnValue(rval); + } - return result; - }; + this.jump(this.finalLoc); +}; -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); - }; +Ep.setReturnValue = function (valuePath) { + util.getTypes().assertExpression(valuePath.value); + this.emitAssign(this.contextProperty("rval"), this.explodeExpression(valuePath)); +}; -/** - * 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); - } +Ep.clearPendingException = function (tryLoc, assignee) { + var t = util.getTypes(); + t.assertLiteral(tryLoc); + var catchCall = t.callExpression(this.contextProperty("catch", true), [t.clone(tryLoc)]); - return map; - }; + 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. -/** - * Render the source map being generated to a string. - */ -SourceMapGenerator.prototype.toString = - function SourceMapGenerator_toString() { - return JSON.stringify(this.toJSON()); - }; -exports.SourceMapGenerator = SourceMapGenerator; +Ep.jump = function (toLoc) { + this.emitAssign(this.contextProperty("next"), toLoc); + this.emit(util.getTypes().breakStatement()); +}; // Conditional jump. -},{"./array-set":486,"./base64-vlq":487,"./mapping-list":490,"./util":495}],494:[function(require,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 = require('./source-map-generator').SourceMapGenerator; -var util = require('./util'); +Ep.jumpIf = function (test, toLoc) { + var t = util.getTypes(); + t.assertExpression(test); + t.assertLiteral(toLoc); + this.emit(t.ifStatement(test, t.blockStatement([this.assign(this.contextProperty("next"), toLoc), t.breakStatement()]))); +}; // Conditional jump, with the condition negated. -// 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; +Ep.jumpIfNot = function (test, toLoc) { + var t = util.getTypes(); + t.assertExpression(test); + t.assertLiteral(toLoc); + var negatedTest; -// 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$$$"; + if (t.isUnaryExpression(test) && test.operator === "!") { + // Avoid double negation. + negatedTest = test.argument; + } else { + negatedTest = t.unaryExpression("!", test); + } -/** - * 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); -} + this.emit(t.ifStatement(negatedTest, t.blockStatement([this.assign(this.contextProperty("next"), toLoc), t.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. -/** - * Creates a SourceNode from generated code and a SourceMapConsumer. - * - * @param aGeneratedCode The generated code - * @param aSourceMapConsumer The SourceMap for the generated code - * @param aRelativePath Optional. The path that relative sources in the - * SourceMapConsumer should be relative to. - */ -SourceNode.fromStringWithSourceMap = - function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) { - // The SourceNode we want to fill with the generated code - // and the SourceMap - var node = new SourceNode(); - // All even indices of this array are one line of the generated code, - // while all odd indices are the newlines between two adjacent lines - // (since `REGEX_NEWLINE` captures its match). - // Processed fragments are accessed by calling `shiftNextLine`. - var remainingLines = aGeneratedCode.split(REGEX_NEWLINE); - var remainingLinesIndex = 0; - var shiftNextLine = function() { - var lineContents = getNextLine(); - // The last line of a file might not have a newline. - var newLine = getNextLine() || ""; - return lineContents + newLine; +Ep.makeTempVar = function () { + return this.contextProperty("t" + this.nextTempId++); +}; - function getNextLine() { - return remainingLinesIndex < remainingLines.length ? - remainingLines[remainingLinesIndex++] : undefined; - } - }; +Ep.getContextFunction = function (id) { + var t = util.getTypes(); + return t.functionExpression(id || null + /*Anonymous*/ + , [this.getContextId()], t.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. - // 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; +Ep.getDispatchLoop = function () { + var self = this; + var t = util.getTypes(); + 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. - aSourceMapConsumer.eachMapping(function (mapping) { - if (lastMapping !== null) { - // We add the code from "lastMapping" to "mapping": - // First check if there is a new line in between. - if (lastGeneratedLine < mapping.generatedLine) { - // Associate first line with "lastMapping" - addMappingWithCode(lastMapping, shiftNextLine()); - lastGeneratedLine++; - lastGeneratedColumn = 0; - // The remaining code is added without mapping - } else { - // There is no new line in between. - // Associate the code between "lastGeneratedColumn" and - // "mapping.generatedColumn" with "lastMapping" - var nextLine = remainingLines[remainingLinesIndex]; - var code = nextLine.substr(0, mapping.generatedColumn - - lastGeneratedColumn); - remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn - - lastGeneratedColumn); - lastGeneratedColumn = mapping.generatedColumn; - addMappingWithCode(lastMapping, code); - // No more remaining code, continue - lastMapping = mapping; - return; - } - } - // We add the generated code until the first mapping - // to the SourceNode without any mapping. - // Each line is added as separate string. - while (lastGeneratedLine < mapping.generatedLine) { - node.add(shiftNextLine()); - lastGeneratedLine++; - } - if (lastGeneratedColumn < mapping.generatedColumn) { - var nextLine = remainingLines[remainingLinesIndex]; - node.add(nextLine.substr(0, mapping.generatedColumn)); - remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn); - lastGeneratedColumn = mapping.generatedColumn; - } - lastMapping = mapping; - }, this); - // We have processed all mappings. - if (remainingLinesIndex < remainingLines.length) { - if (lastMapping) { - // Associate the remaining code in the current line with "lastMapping" - addMappingWithCode(lastMapping, shiftNextLine()); - } - // and add the remaining lines without any mapping - node.add(remainingLines.splice(remainingLinesIndex).join("")); + var alreadyEnded = false; + self.listing.forEach(function (stmt, i) { + if (self.marked.hasOwnProperty(i)) { + cases.push(t.switchCase(t.numericLiteral(i), current = [])); + alreadyEnded = false; } - // 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)); - } + if (!alreadyEnded) { + current.push(stmt); + if (t.isCompletionStatement(stmt)) alreadyEnded = true; } - }; + }); // Now that we know how many statements there will be in this.listing, + // we can finally resolve this.finalLoc.value. -/** - * 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; + this.finalLoc.value = this.listing.length; + cases.push(t.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. + t.switchCase(t.stringLiteral("end"), [// This will check/clear both context.thrown and context.rval. + t.returnStatement(t.callExpression(this.contextProperty("stop"), []))])); + return t.whileStatement(t.numericLiteral(1), t.switchStatement(t.assignmentExpression("=", this.contextProperty("prev"), this.contextProperty("next")), cases)); }; -/** - * 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 - ); +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; } - 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 }); - } - } - } -}; + var t = util.getTypes(); + var lastLocValue = 0; + return t.arrayExpression(this.tryEntries.map(function (tryEntry) { + var thisLocValue = tryEntry.firstLoc.value; -/** - * 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; -}; + _assert["default"].ok(thisLocValue >= lastLocValue, "try entries out of order"); -/** - * 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; - }; + 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]; -/** - * 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); - } + if (fe) { + locs[2] = fe.firstLoc; + locs[3] = fe.afterLoc; } - 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 t.arrayExpression(locs.map(function (loc) { + return loc && t.clone(loc); + })); + })); +}; // 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. -/** - * 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); - }); +Ep.explode = function (path, ignoreResult) { + var t = util.getTypes(); + var node = path.node; + var self = this; + t.assertNode(node); + if (t.isDeclaration(node)) throw getDeclError(node); + if (t.isStatement(node)) return self.explodeStatement(path); + if (t.isExpression(node)) return self.explodeExpression(path, ignoreResult); - return { code: generated.code, map: map }; -}; + switch (node.type) { + case "Program": + return path.get("body").map(self.explodeStatement, self); -exports.SourceNode = SourceNode; + case "VariableDeclarator": + throw getDeclError(node); + // These node types should be handled by their parent nodes + // (ObjectExpression, SwitchStatement, and TryStatement, respectively). -},{"./source-map-generator":493,"./util":495}],495:[function(require,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 - */ + case "Property": + case "SwitchCase": + case "CatchClause": + throw new Error(node.type + " nodes should be handled by their parents"); -/** - * 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.'); + default: + throw new Error("unknown Node of type " + JSON.stringify(node.type)); } -} -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] - }; +function getDeclError(node) { + return new Error("all declarations should have been transformed into " + "assignments before the Exploder began its work: " + JSON.stringify(node)); } -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; +Ep.explodeStatement = function (path, labelId) { + var t = util.getTypes(); + var stmt = path.node; + var self = this; + var before, after, head; + t.assertStatement(stmt); -/** - * 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); + if (labelId) { + t.assertIdentifier(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. - 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 (t.isBlockStatement(stmt)) { + path.get("body").forEach(function (path) { + self.explodeStatement(path); + }); + return; } - if (url) { - url.path = path; - return urlGenerate(url); + 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; } - 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 || '/'; - } + switch (stmt.type) { + case "ExpressionStatement": + self.explodeExpression(path.get("expression"), true); + break; - // `join(foo, '//www.example.org')` - if (aPathUrl && !aPathUrl.scheme) { - if (aRootUrl) { - aPathUrl.scheme = aRootUrl.scheme; - } - return urlGenerate(aPathUrl); - } + case "LabeledStatement": + after = this.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. - if (aPathUrl || aPath.match(dataUrlRegexp)) { - return aPath; - } + self.leapManager.withEntry(new leap.LabeledEntry(after, stmt.label), function () { + self.explodeStatement(path.get("body"), stmt.label); + }); + self.mark(after); + break; - // `join('http://', 'www.example.com')` - if (aRootUrl && !aRootUrl.host && !aRootUrl.path) { - aRootUrl.host = aPath; - return urlGenerate(aRootUrl); - } + case "WhileStatement": + before = this.loc(); + after = this.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; - var joined = aPath.charAt(0) === '/' - ? aPath - : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath); + case "DoWhileStatement": + var first = this.loc(); + var test = this.loc(); + after = this.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; - if (aRootUrl) { - aRootUrl.path = joined; - return urlGenerate(aRootUrl); - } - return joined; -} -exports.join = join; + case "ForStatement": + head = this.loc(); + var update = this.loc(); + after = this.loc(); -exports.isAbsolute = function (aPath) { - return aPath.charAt(0) === '/' || !!aPath.match(urlRegexp); -}; + 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); + } -/** - * 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 = "."; - } + self.mark(head); - aRoot = aRoot.replace(/\/$/, ''); + if (stmt.test) { + self.jumpIfNot(self.explodeExpression(path.get("test")), after); + } else {// No test means continue unconditionally. + } - // 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; - } + self.leapManager.withEntry(new leap.LoopEntry(after, update, labelId), function () { + self.explodeStatement(path.get("body")); + }); + self.mark(update); - // 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; - } + 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); + } - ++level; - } + self.jump(head); + self.mark(after); + break; - // 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; + case "TypeCastExpression": + return self.explodeExpression(path.get("expression")); -var supportsNullProto = (function () { - var obj = Object.create(null); - return !('__proto__' in obj); -}()); + case "ForInStatement": + head = this.loc(); + after = this.loc(); + var keyIterNextFn = self.makeTempVar(); + self.emitAssign(keyIterNextFn, t.callExpression(util.runtimeProperty("keys"), [self.explodeExpression(path.get("right"))])); + self.mark(head); + var keyInfoTmpVar = self.makeTempVar(); + self.jumpIf(t.memberExpression(t.assignmentExpression("=", keyInfoTmpVar, t.callExpression(t.cloneDeep(keyIterNextFn), [])), t.identifier("done"), false), after); + self.emitAssign(stmt.left, t.memberExpression(t.cloneDeep(keyInfoTmpVar), t.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; -function identity (s) { - return s; -} + case "BreakStatement": + self.emitAbruptCompletion({ + type: "break", + target: self.leapManager.getBreakLoc(stmt.label) + }); + break; -/** - * 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; - } + case "ContinueStatement": + self.emitAbruptCompletion({ + type: "continue", + target: self.leapManager.getContinueLoc(stmt.label) + }); + break; - return aStr; -} -exports.toSetString = supportsNullProto ? identity : toSetString; + 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"))); + after = this.loc(); + var defaultLoc = this.loc(); + var condition = defaultLoc; + var caseLocs = []; // If there are no cases, .cases might be undefined. -function fromSetString(aStr) { - if (isProtoString(aStr)) { - return aStr.slice(1); - } + var cases = stmt.cases || []; - return aStr; -} -exports.fromSetString = supportsNullProto ? identity : fromSetString; + for (var i = cases.length - 1; i >= 0; --i) { + var c = cases[i]; + t.assertSwitchCase(c); -function isProtoString(s) { - if (!s) { - return false; - } + if (c.test) { + condition = t.conditionalExpression(t.binaryExpression("===", t.cloneDeep(disc), c.test), caseLocs[i] = this.loc(), condition); + } else { + caseLocs[i] = defaultLoc; + } + } - var length = s.length; + var discriminant = path.get("discriminant"); + util.replaceWithOrRemove(discriminant, condition); + self.jump(self.explodeExpression(discriminant)); + self.leapManager.withEntry(new leap.SwitchEntry(after), function () { + path.get("cases").forEach(function (casePath) { + var i = casePath.key; + self.mark(caseLocs[i]); + casePath.get("consequent").forEach(function (path) { + self.explodeStatement(path); + }); + }); + }); + self.mark(after); - if (length < 9 /* "__proto__".length */) { - return false; - } + if (defaultLoc.value === -1) { + self.mark(defaultLoc); - 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; - } + _assert["default"].strictEqual(after.value, defaultLoc.value); + } - for (var i = length - 10; i >= 0; i--) { - if (s.charCodeAt(i) !== 36 /* '$' */) { - return false; - } - } + break; - return true; -} + case "IfStatement": + var elseLoc = stmt.alternate && this.loc(); + after = this.loc(); + self.jumpIfNot(self.explodeExpression(path.get("test")), elseLoc || after); + self.explodeStatement(path.get("consequent")); -/** - * 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; - } + if (elseLoc) { + self.jump(after); + self.mark(elseLoc); + self.explodeStatement(path.get("alternate")); + } - cmp = mappingA.originalLine - mappingB.originalLine; - if (cmp !== 0) { - return cmp; - } + self.mark(after); + break; - cmp = mappingA.originalColumn - mappingB.originalColumn; - if (cmp !== 0 || onlyCompareOriginal) { - return cmp; - } + case "ReturnStatement": + self.emitAbruptCompletion({ + type: "return", + value: self.explodeExpression(path.get("argument")) + }); + break; - cmp = mappingA.generatedColumn - mappingB.generatedColumn; - if (cmp !== 0) { - return cmp; - } + case "WithStatement": + throw new Error("WithStatement not supported in generator functions."); - cmp = mappingA.generatedLine - mappingB.generatedLine; - if (cmp !== 0) { - return cmp; - } + case "TryStatement": + after = this.loc(); + var handler = stmt.handler; + var catchLoc = handler && this.loc(); + var catchEntry = catchLoc && new leap.CatchEntry(catchLoc, handler.param); + var finallyLoc = stmt.finalizer && this.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")); - return mappingA.name - mappingB.name; -} -exports.compareByOriginalPositions = compareByOriginalPositions; + 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); + } -/** - * 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; - } + self.updateContextPrevLoc(self.mark(catchLoc)); + var bodyPath = path.get("handler.body"); + var safeParam = self.makeTempVar(); + self.clearPendingException(tryEntry.firstLoc, safeParam); + bodyPath.traverse(catchParamVisitor, { + getSafeParam: function getSafeParam() { + return t.cloneDeep(safeParam); + }, + catchParamName: handler.param.name + }); + self.leapManager.withEntry(catchEntry, function () { + self.explodeStatement(bodyPath); + }); + } - cmp = mappingA.generatedColumn - mappingB.generatedColumn; - if (cmp !== 0 || onlyCompareGenerated) { - return cmp; - } + if (finallyLoc) { + self.updateContextPrevLoc(self.mark(finallyLoc)); + self.leapManager.withEntry(finallyEntry, function () { + self.explodeStatement(path.get("finalizer")); + }); + self.emit(t.returnStatement(t.callExpression(self.contextProperty("finish"), [finallyEntry.firstLoc]))); + } + }); + self.mark(after); + break; - cmp = mappingA.source - mappingB.source; - if (cmp !== 0) { - return cmp; + case "ThrowStatement": + self.emit(t.throwStatement(self.explodeExpression(path.get("argument")))); + break; + + default: + throw new Error("unknown Statement of type " + JSON.stringify(stmt.type)); } +}; - cmp = mappingA.originalLine - mappingB.originalLine; - if (cmp !== 0) { - return cmp; +var catchParamVisitor = { + Identifier: function Identifier(path, state) { + if (path.node.name === state.catchParamName && util.isReference(path)) { + util.replaceWithOrRemove(path, state.getSafeParam()); + } + }, + Scope: function Scope(path, state) { + if (path.scope.hasOwnBinding(state.catchParamName)) { + // Don't descend into nested scopes that shadow the catch + // parameter with their own declarations. + path.skip(); + } } +}; - cmp = mappingA.originalColumn - mappingB.originalColumn; - if (cmp !== 0) { - return cmp; +Ep.emitAbruptCompletion = function (record) { + if (!isValidCompletion(record)) { + _assert["default"].ok(false, "invalid completion record: " + JSON.stringify(record)); } - return mappingA.name - mappingB.name; -} -exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated; + _assert["default"].notStrictEqual(record.type, "normal", "normal completions are not abrupt"); -function strcmp(aStr1, aStr2) { - if (aStr1 === aStr2) { - return 0; - } + var t = util.getTypes(); + var abruptArgs = [t.stringLiteral(record.type)]; - if (aStr1 > aStr2) { - return 1; + if (record.type === "break" || record.type === "continue") { + t.assertLiteral(record.target); + abruptArgs[1] = this.insertedLocs.has(record.target) ? record.target : t.cloneDeep(record.target); + } else if (record.type === "return" || record.type === "throw") { + if (record.value) { + t.assertExpression(record.value); + abruptArgs[1] = this.insertedLocs.has(record.value) ? record.value : t.cloneDeep(record.value); + } } - return -1; -} + this.emit(t.returnStatement(t.callExpression(this.contextProperty("abrupt"), abruptArgs))); +}; -/** - * 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; - } +function isValidCompletion(record) { + var type = record.type; - cmp = mappingA.generatedColumn - mappingB.generatedColumn; - if (cmp !== 0) { - return cmp; + if (type === "normal") { + return !hasOwn.call(record, "target"); } - cmp = strcmp(mappingA.source, mappingB.source); - if (cmp !== 0) { - return cmp; + if (type === "break" || type === "continue") { + return !hasOwn.call(record, "value") && util.getTypes().isLiteral(record.target); } - cmp = mappingA.originalLine - mappingB.originalLine; - if (cmp !== 0) { - return cmp; + if (type === "return" || type === "throw") { + return hasOwn.call(record, "value") && !hasOwn.call(record, "target"); } - cmp = mappingA.originalColumn - mappingB.originalColumn; - if (cmp !== 0) { - return cmp; - } + 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. - return strcmp(mappingA.name, mappingB.name); -} -exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated; -},{}],496:[function(require,module,exports){ -arguments[4][483][0].apply(exports,arguments) -},{"./lib/source-map-consumer":492,"./lib/source-map-generator":493,"./lib/source-node":494,"dup":483}],497:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. +Ep.getUnmarkedCurrentLoc = function () { + return util.getTypes().numericLiteral(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. -module.exports = Stream; -var EE = require('events').EventEmitter; -var inherits = require('inherits'); +Ep.updateContextPrevLoc = function (loc) { + var t = util.getTypes(); -inherits(Stream, EE); -Stream.Readable = require('readable-stream/readable.js'); -Stream.Writable = require('readable-stream/writable.js'); -Stream.Duplex = require('readable-stream/duplex.js'); -Stream.Transform = require('readable-stream/transform.js'); -Stream.PassThrough = require('readable-stream/passthrough.js'); + if (loc) { + t.assertLiteral(loc); -// Backwards-compat with node 0.4.x -Stream.Stream = Stream; + 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["default"].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); +}; -// old-style streams. Note that the pipe method (the only relevant -// part of this class) is overridden in the Readable class. +Ep.explodeExpression = function (path, ignoreResult) { + var t = util.getTypes(); + var expr = path.node; -function Stream() { - EE.call(this); -} + if (expr) { + t.assertExpression(expr); + } else { + return expr; + } -Stream.prototype.pipe = function(dest, options) { - var source = this; + var self = this; + var result; // Used optionally by several cases below. - function ondata(chunk) { - if (dest.writable) { - if (false === dest.write(chunk) && source.pause) { - source.pause(); - } - } - } + var after; - source.on('data', ondata); + function finish(expr) { + t.assertExpression(expr); - function ondrain() { - if (source.readable && source.resume) { - source.resume(); + if (ignoreResult) { + self.emit(expr); + } else { + return expr; } - } - - dest.on('drain', ondrain); + } // If the expression does not contain a leap, then we either emit the + // expression as a standalone statement or return it whole. - // If the 'end' option is not supplied, dest.end() will be called when - // source gets the 'end' or 'close' events. Only dest.end() once. - if (!dest._isStdio && (!options || options.end !== false)) { - source.on('end', onend); - source.on('close', onclose); - } - var didOnEnd = false; - function onend() { - if (didOnEnd) return; - didOnEnd = true; + 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). - dest.end(); - } + 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 onclose() { - if (didOnEnd) return; - didOnEnd = true; + function explodeViaTempVar(tempVar, childPath, ignoreChildResult) { + _assert["default"].ok(!ignoreChildResult || !tempVar, "Ignoring the result of a child expression but forcing it to " + "be assigned to a temporary variable?"); - if (typeof dest.destroy === 'function') dest.destroy(); - } + var result = self.explodeExpression(childPath, ignoreChildResult); - // don't leave dangling pipes when there are errors. - function onerror(er) { - cleanup(); - if (EE.listenerCount(this, 'error') === 0) { - throw er; // Unhandled stream error in pipe. + if (ignoreChildResult) {// Side effects already emitted above. + } else if (tempVar || hasLeapingChildren && !t.isLiteral(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); } - } - source.on('error', onerror); - dest.on('error', onerror); - - // remove all the event listeners that were added. - function cleanup() { - source.removeListener('data', ondata); - dest.removeListener('drain', ondrain); + 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. - source.removeListener('end', onend); - source.removeListener('close', onclose); - source.removeListener('error', onerror); - dest.removeListener('error', onerror); + switch (expr.type) { + case "MemberExpression": + return finish(t.memberExpression(self.explodeExpression(path.get("object")), expr.computed ? explodeViaTempVar(null, path.get("property")) : expr.property, expr.computed)); - source.removeListener('end', cleanup); - source.removeListener('close', cleanup); + case "CallExpression": + var calleePath = path.get("callee"); + var argsPath = path.get("arguments"); + var newCallee; + var newArgs = []; + var hasLeapingArgs = false; + argsPath.forEach(function (argPath) { + hasLeapingArgs = hasLeapingArgs || meta.containsLeap(argPath.node); + }); - dest.removeListener('close', cleanup); - } + if (t.isMemberExpression(calleePath.node)) { + 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.node.computed ? explodeViaTempVar(null, calleePath.get("property")) : calleePath.node.property; + newArgs.unshift(newObject); + newCallee = t.memberExpression(t.memberExpression(t.cloneDeep(newObject), newProperty, calleePath.node.computed), t.identifier("call"), false); + } else { + newCallee = self.explodeExpression(calleePath); + } + } else { + newCallee = explodeViaTempVar(null, calleePath); - source.on('end', cleanup); - source.on('close', cleanup); + if (t.isMemberExpression(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 = t.sequenceExpression([t.numericLiteral(0), t.cloneDeep(newCallee)]); + } + } - dest.on('close', cleanup); + argsPath.forEach(function (argPath) { + newArgs.push(explodeViaTempVar(null, argPath)); + }); + return finish(t.callExpression(newCallee, newArgs.map(function (arg) { + return t.cloneDeep(arg); + }))); - dest.emit('pipe', source); + case "NewExpression": + return finish(t.newExpression(explodeViaTempVar(null, path.get("callee")), path.get("arguments").map(function (argPath) { + return explodeViaTempVar(null, argPath); + }))); - // Allow for unix-like usage: A.pipe(B).pipe(C) - return dest; -}; + case "ObjectExpression": + return finish(t.objectExpression(path.get("properties").map(function (propPath) { + if (propPath.isObjectProperty()) { + return t.objectProperty(propPath.node.key, explodeViaTempVar(null, propPath.get("value")), propPath.node.computed); + } else { + return propPath.node; + } + }))); -},{"events":214,"inherits":218,"readable-stream/duplex.js":427,"readable-stream/passthrough.js":437,"readable-stream/readable.js":438,"readable-stream/transform.js":439,"readable-stream/writable.js":440}],498:[function(require,module,exports){ -'use strict'; -module.exports = { - stdout: false, - stderr: false -}; + case "ArrayExpression": + return finish(t.arrayExpression(path.get("elements").map(function (elemPath) { + return explodeViaTempVar(null, elemPath); + }))); -},{}],499:[function(require,module,exports){ -(function (process){ -var Stream = require('stream') + case "SequenceExpression": + var lastIndex = expr.expressions.length - 1; + path.get("expressions").forEach(function (exprPath) { + if (exprPath.key === lastIndex) { + result = self.explodeExpression(exprPath, ignoreResult); + } else { + self.explodeExpression(exprPath, true); + } + }); + return result; -// through -// -// a stream that does nothing but re-emit the input. -// useful for aggregating a series of changing but not ending streams into one stream) + case "LogicalExpression": + after = this.loc(); -exports = module.exports = through -through.through = through + if (!ignoreResult) { + result = self.makeTempVar(); + } -//create a readable writable stream. + var left = explodeViaTempVar(result, path.get("left")); -function through (write, end, opts) { - write = write || function (data) { this.queue(data) } - end = end || function () { this.queue(null) } + if (expr.operator === "&&") { + self.jumpIfNot(left, after); + } else { + _assert["default"].strictEqual(expr.operator, "||"); - var ended = false, destroyed = false, buffer = [], _ended = false - var stream = new Stream() - stream.readable = stream.writable = true - stream.paused = false + self.jumpIf(left, after); + } -// stream.autoPause = !(opts && opts.autoPause === false) - stream.autoDestroy = !(opts && opts.autoDestroy === false) + explodeViaTempVar(result, path.get("right"), ignoreResult); + self.mark(after); + return result; - stream.write = function (data) { - write.call(this, data) - return !stream.paused - } + case "ConditionalExpression": + var elseLoc = this.loc(); + after = this.loc(); + var test = self.explodeExpression(path.get("test")); + self.jumpIfNot(test, elseLoc); - function drain() { - while(buffer.length && !stream.paused) { - var data = buffer.shift() - if(null === data) - return stream.emit('end') - else - stream.emit('data', data) - } - } + if (!ignoreResult) { + result = self.makeTempVar(); + } - stream.queue = stream.push = function (data) { -// console.error(ended) - if(_ended) return stream - if(data === null) _ended = true - buffer.push(data) - drain() - return stream - } + explodeViaTempVar(result, path.get("consequent"), ignoreResult); + self.jump(after); + self.mark(elseLoc); + explodeViaTempVar(result, path.get("alternate"), ignoreResult); + self.mark(after); + return result; - //this will be registered as the first 'end' listener - //must call destroy next tick, to make sure we're after any - //stream piped from here. - //this is only a problem if end is not emitted synchronously. - //a nicer way to do this is to make sure this is the last listener for 'end' + case "UnaryExpression": + return finish(t.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)); - stream.on('end', function () { - stream.readable = false - if(!stream.writable && stream.autoDestroy) - process.nextTick(function () { - stream.destroy() - }) - }) + case "BinaryExpression": + return finish(t.binaryExpression(expr.operator, explodeViaTempVar(null, path.get("left")), explodeViaTempVar(null, path.get("right")))); - function _end () { - stream.writable = false - end.call(stream) - if(!stream.readable && stream.autoDestroy) - stream.destroy() - } + case "AssignmentExpression": + if (expr.operator === "=") { + // If this is a simple assignment, the left hand side does not need + // to be read before the right hand side is evaluated, so we can + // avoid the more complicated logic below. + return finish(t.assignmentExpression(expr.operator, self.explodeExpression(path.get("left")), self.explodeExpression(path.get("right")))); + } - stream.end = function (data) { - if(ended) return - ended = true - if(arguments.length) stream.write(data) - _end() // will emit or queue - return stream - } + var lhs = self.explodeExpression(path.get("left")); + var temp = self.emitAssign(self.makeTempVar(), lhs); // For example, + // + // x += yield y + // + // becomes + // + // context.t0 = x + // x = context.t0 += yield y + // + // so that the left-hand side expression is read before the yield. + // Fixes https://github.com/facebook/regenerator/issues/345. - stream.destroy = function () { - if(destroyed) return - destroyed = true - ended = true - buffer.length = 0 - stream.writable = stream.readable = false - stream.emit('close') - return stream - } + return finish(t.assignmentExpression("=", t.cloneDeep(lhs), t.assignmentExpression(expr.operator, t.cloneDeep(temp), self.explodeExpression(path.get("right"))))); - stream.pause = function () { - if(stream.paused) return - stream.paused = true - return stream - } + case "UpdateExpression": + return finish(t.updateExpression(expr.operator, self.explodeExpression(path.get("argument")), expr.prefix)); - stream.resume = function () { - if(stream.paused) { - stream.paused = false - stream.emit('resume') - } - drain() - //may have become paused again, - //as drain emits 'data'. - if(!stream.paused) - stream.emit('drain') - return stream - } - return stream -} + case "YieldExpression": + after = this.loc(); + var arg = expr.argument && self.explodeExpression(path.get("argument")); + if (arg && expr.delegate) { + var _result = self.makeTempVar(); -}).call(this,require('_process')) -},{"_process":426,"stream":497}],500:[function(require,module,exports){ -(function (setImmediate,clearImmediate){ -var nextTick = require('process/browser.js').nextTick; -var apply = Function.prototype.apply; -var slice = Array.prototype.slice; -var immediateIds = {}; -var nextImmediateId = 0; + var _ret = t.returnStatement(t.callExpression(self.contextProperty("delegateYield"), [arg, t.stringLiteral(_result.property.name), after])); -// DOM APIs, for completeness + _ret.loc = expr.loc; + self.emit(_ret); + self.mark(after); + return _result; + } -exports.setTimeout = function() { - return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout); -}; -exports.setInterval = function() { - return new Timeout(apply.call(setInterval, window, arguments), clearInterval); -}; -exports.clearTimeout = -exports.clearInterval = function(timeout) { timeout.close(); }; + self.emitAssign(self.contextProperty("next"), after); + var ret = t.returnStatement(t.cloneDeep(arg) || null); // Preserve the `yield` location so that source mappings for the statements + // link back to the yield properly. -function Timeout(id, clearFn) { - this._id = id; - this._clearFn = clearFn; -} -Timeout.prototype.unref = Timeout.prototype.ref = function() {}; -Timeout.prototype.close = function() { - this._clearFn.call(window, this._id); -}; + ret.loc = expr.loc; + self.emit(ret); + self.mark(after); + return self.contextProperty("sent"); -// Does not start the time, just sets up the members needed. -exports.enroll = function(item, msecs) { - clearTimeout(item._idleTimeoutId); - item._idleTimeout = msecs; + default: + throw new Error("unknown Expression of type " + JSON.stringify(expr.type)); + } }; +},{"./leap":497,"./meta":498,"./util":500,"@babel/runtime/helpers/interopRequireDefault":83,"@babel/runtime/helpers/interopRequireWildcard":84,"assert":196}],495:[function(require,module,exports){ +"use strict"; -exports.unenroll = function(item) { - clearTimeout(item._idleTimeoutId); - item._idleTimeout = -1; -}; +var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); -exports._unrefActive = exports.active = function(item) { - clearTimeout(item._idleTimeoutId); +var util = _interopRequireWildcard(require("./util")); - var msecs = item._idleTimeout; - if (msecs >= 0) { - item._idleTimeoutId = setTimeout(function onTimeout() { - if (item._onTimeout) - item._onTimeout(); - }, msecs); +/** + * Copyright (c) 2014-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +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) { + var t = util.getTypes(); + t.assertFunction(funPath.node); + var vars = {}; + + function varDeclToExpr(_ref, includeIdentifiers) { + var vdec = _ref.node, + scope = _ref.scope; + 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); // Remove the binding, to avoid "duplicate declaration" errors when it will + // be injected again. + + scope.removeBinding(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); } -}; -// That's not how node.js implements it but the exposed api is the same. -exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) { - var id = nextImmediateId++; - var args = arguments.length < 2 ? false : slice.call(arguments, 1); + funPath.get("body").traverse({ + VariableDeclaration: { + exit: function exit(path) { + var expr = varDeclToExpr(path, false); - immediateIds[id] = true; + 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. + util.replaceWithOrRemove(path, t.expressionStatement(expr)); + } // Since the original node has been either removed or replaced, + // avoid traversing it any further. - nextTick(function onNextTick() { - if (immediateIds[id]) { - // fn.call() is faster so we optimize for the common use-case - // @see http://jsperf.com/call-apply-segu - if (args) { - fn.apply(null, args); - } else { - fn.call(null); + + path.skip(); } - // Prevent ids from leaking - exports.clearImmediate(id); - } - }); + }, + ForStatement: function ForStatement(path) { + var init = path.get("init"); - return id; -}; + if (init.isVariableDeclaration()) { + util.replaceWithOrRemove(init, varDeclToExpr(init, false)); + } + }, + ForXStatement: function ForXStatement(path) { + var left = path.get("left"); -exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) { - delete immediateIds[id]; -}; -}).call(this,require("timers").setImmediate,require("timers").clearImmediate) -},{"process/browser.js":426,"timers":500}],501:[function(require,module,exports){ -'use strict'; + if (left.isVariableDeclaration()) { + util.replaceWithOrRemove(left, varDeclToExpr(left, true)); + } + }, + FunctionDeclaration: function FunctionDeclaration(path) { + var node = path.node; + vars[node.id.name] = node.id; + var assignment = t.expressionStatement(t.assignmentExpression("=", t.clone(node.id), t.functionExpression(path.scope.generateUidIdentifierBasedOnNode(node), node.params, node.body, node.generator, node.expression))); -let fastProto = null; + 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. -// Creates an object with permanently fast properties in V8. See Toon Verwaest's -// post https://medium.com/@tverwaes/setting-up-prototypes-in-v8-ec9c9491dfe2#5f62 -// for more details. Use %HasFastProperties(object) and the Node.js flag -// --allow-natives-syntax to check whether an object has fast properties. -function FastObject(o) { - // A prototype object will have "fast properties" enabled once it is checked - // against the inline property cache of a function, e.g. fastProto.property: - // https://github.com/v8/v8/blob/6.0.122/test/mjsunit/fast-prototype.js#L48-L63 - if (fastProto !== null && typeof fastProto.property) { - const result = fastProto; - fastProto = FastObject.prototype = null; - return result; - } - fastProto = FastObject.prototype = o == null ? Object.create(null) : o; - return new FastObject; -} + 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. + util.replaceWithOrRemove(path, assignment); + } // Remove the binding, to avoid "duplicate declaration" errors when it will + // be injected again. -// Initialize the inline property cache of FastObject -FastObject(); -module.exports = function toFastproperties(o) { - return FastObject(o); -}; + path.scope.removeBinding(node.id.name); // Don't hoist variables out of inner functions. -},{}],502:[function(require,module,exports){ -'use strict'; -module.exports = function (str) { - var tail = str.length; + path.skip(); + }, + FunctionExpression: function FunctionExpression(path) { + // Don't descend into nested function expressions. + path.skip(); + }, + ArrowFunctionExpression: function ArrowFunctionExpression(path) { + // Don't descend into nested function expressions. + path.skip(); + } + }); + var paramNames = {}; + funPath.get("params").forEach(function (paramPath) { + var param = paramPath.node; - while (/[\s\uFEFF\u00A0]/.test(str[tail - 1])) { - tail--; - } + if (t.isIdentifier(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(t.variableDeclarator(vars[name], null)); + } + }); - return str.slice(0, tail); -}; + if (declarations.length === 0) { + return null; // Be sure to handle this case! + } -},{}],503:[function(require,module,exports){ -(function (global){ + return t.variableDeclaration("var", declarations); +}; +},{"./util":500,"@babel/runtime/helpers/interopRequireWildcard":84}],496:[function(require,module,exports){ +"use strict"; -/** - * Module exports. - */ +exports.__esModule = true; +exports["default"] = _default; -module.exports = deprecate; +var _visit = require("./visit"); /** - * Mark that a method should not be used. - * Returns a modified function which warns once by default. - * - * If `localStorage.noDeprecation = true` is set, then it is a no-op. - * - * If `localStorage.throwDeprecation = true` is set, then deprecated functions - * will throw an Error when invoked. - * - * If `localStorage.traceDeprecation = true` is set, then deprecated functions - * will invoke `console.trace()` instead of `console.error()`. + * Copyright (c) 2014-present, Facebook, Inc. * - * @param {Function} fn - the function to deprecate - * @param {String} msg - the string to print to the console when `fn` is invoked - * @returns {Function} a new "deprecated" version of `fn` - * @api public + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ +function _default(context) { + var plugin = { + visitor: (0, _visit.getVisitor)(context) + }; // Some presets manually call child presets, but fail to pass along the + // context object. Out of an abundance of caution, we verify that it + // exists first to avoid causing unnecessary breaking changes. -function deprecate (fn, msg) { - if (config('noDeprecation')) { - return fn; + var version = context && context.version; // The "name" property is not allowed in older versions of Babel (6.x) + // and will cause the plugin validator to throw an exception. + + if (version && parseInt(version, 10) >= 7) { + plugin.name = "regenerator-transform"; } - var warned = false; - function deprecated() { - if (!warned) { - if (config('throwDeprecation')) { - throw new Error(msg); - } else if (config('traceDeprecation')) { - console.trace(msg); - } else { - console.warn(msg); - } - warned = true; - } - return fn.apply(this, arguments); - } - - return deprecated; + return plugin; } +},{"./visit":501}],497:[function(require,module,exports){ +"use strict"; -/** - * Checks `localStorage` for boolean values for the given `name`. - * - * @param {String} name - * @returns {Boolean} - * @api private - */ - -function config (name) { - // accessing global.localStorage can trigger a DOMException in sandboxed iframes - try { - if (!global.localStorage) return false; - } catch (_) { - return false; - } - var val = global.localStorage[name]; - if (null == val) return false; - return String(val).toLowerCase() === 'true'; -} +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],504:[function(require,module,exports){ -arguments[4][193][0].apply(exports,arguments) -},{"dup":193}],505:[function(require,module,exports){ -arguments[4][194][0].apply(exports,arguments) -},{"./support/isBuffer":504,"_process":426,"dup":194,"inherits":218}],506:[function(require,module,exports){ -/** - * Copyright (c) 2014-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ +var _assert = _interopRequireDefault(require("assert")); -module.exports = { - plugins: [ - require("@babel/plugin-syntax-async-generators"), - require("@babel/plugin-proposal-function-sent"), - require("@babel/plugin-transform-classes"), - require("@babel/plugin-transform-arrow-functions"), - require("@babel/plugin-transform-block-scoping"), - require("@babel/plugin-transform-for-of"), - require("regenerator-transform").default - ] -}; +var _emit = require("./emit"); -},{"@babel/plugin-proposal-function-sent":72,"@babel/plugin-syntax-async-generators":73,"@babel/plugin-transform-arrow-functions":75,"@babel/plugin-transform-block-scoping":76,"@babel/plugin-transform-classes":78,"@babel/plugin-transform-for-of":80,"regenerator-transform":511}],507:[function(require,module,exports){ -(function (__dirname){ -/** - * Copyright (c) 2014-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ +var _util = require("util"); -exports.path = require("path").join( - __dirname, - "runtime.js" -); +var _util2 = require("./util"); -}).call(this,"/node_modules/regenerator-runtime") -},{"path":423}],508:[function(require,module,exports){ /** * Copyright (c) 2014-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ +function Entry() { + _assert["default"].ok(this instanceof Entry); +} -var runtime = (function (exports) { - "use strict"; - - var Op = Object.prototype; - var hasOwn = Op.hasOwnProperty; - var undefined; // More compressible than void 0. - var $Symbol = typeof Symbol === "function" ? Symbol : {}; - var iteratorSymbol = $Symbol.iterator || "@@iterator"; - var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; - var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; +function FunctionEntry(returnLoc) { + Entry.call(this); + (0, _util2.getTypes)().assertLiteral(returnLoc); + this.returnLoc = returnLoc; +} - function wrap(innerFn, outerFn, self, tryLocsList) { - // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. - var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; - var generator = Object.create(protoGenerator.prototype); - var context = new Context(tryLocsList || []); +(0, _util.inherits)(FunctionEntry, Entry); +exports.FunctionEntry = FunctionEntry; - // The ._invoke method unifies the implementations of the .next, - // .throw, and .return methods. - generator._invoke = makeInvokeMethod(innerFn, self, context); +function LoopEntry(breakLoc, continueLoc, label) { + Entry.call(this); + var t = (0, _util2.getTypes)(); + t.assertLiteral(breakLoc); + t.assertLiteral(continueLoc); - return generator; + if (label) { + t.assertIdentifier(label); + } else { + label = null; } - exports.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 }; - } - } + this.breakLoc = breakLoc; + this.continueLoc = continueLoc; + this.label = label; +} - var GenStateSuspendedStart = "suspendedStart"; - var GenStateSuspendedYield = "suspendedYield"; - var GenStateExecuting = "executing"; - var GenStateCompleted = "completed"; +(0, _util.inherits)(LoopEntry, Entry); +exports.LoopEntry = LoopEntry; - // Returning this object from the innerFn has the same effect as - // breaking out of the dispatch switch statement. - var ContinueSentinel = {}; +function SwitchEntry(breakLoc) { + Entry.call(this); + (0, _util2.getTypes)().assertLiteral(breakLoc); + this.breakLoc = breakLoc; +} - // 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() {} +(0, _util.inherits)(SwitchEntry, Entry); +exports.SwitchEntry = SwitchEntry; - // This is a polyfill for %IteratorPrototype% for environments that - // don't natively support it. - var IteratorPrototype = {}; - IteratorPrototype[iteratorSymbol] = function () { - return this; - }; +function TryEntry(firstLoc, catchEntry, finallyEntry) { + Entry.call(this); + var t = (0, _util2.getTypes)(); + t.assertLiteral(firstLoc); - var getProto = Object.getPrototypeOf; - var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); - if (NativeIteratorPrototype && - NativeIteratorPrototype !== Op && - hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { - // This environment has a native %IteratorPrototype%; use it instead - // of the polyfill. - IteratorPrototype = NativeIteratorPrototype; + if (catchEntry) { + _assert["default"].ok(catchEntry instanceof CatchEntry); + } else { + catchEntry = null; } - var Gp = GeneratorFunctionPrototype.prototype = - Generator.prototype = Object.create(IteratorPrototype); - GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; - GeneratorFunctionPrototype.constructor = GeneratorFunction; - GeneratorFunctionPrototype[toStringTagSymbol] = - GeneratorFunction.displayName = "GeneratorFunction"; + if (finallyEntry) { + _assert["default"].ok(finallyEntry instanceof FinallyEntry); + } else { + finallyEntry = null; + } // Have to have one or the other (or both). - // 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); - }; - }); - } - exports.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; - }; + _assert["default"].ok(catchEntry || finallyEntry); - exports.mark = function(genFun) { - if (Object.setPrototypeOf) { - Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); - } else { - genFun.__proto__ = GeneratorFunctionPrototype; - if (!(toStringTagSymbol in genFun)) { - genFun[toStringTagSymbol] = "GeneratorFunction"; - } - } - genFun.prototype = Object.create(Gp); - return genFun; - }; + this.firstLoc = firstLoc; + this.catchEntry = catchEntry; + this.finallyEntry = finallyEntry; +} - // Within the body of any async function, `await x` is transformed to - // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test - // `hasOwn.call(value, "__await")` to determine if the yielded value is - // meant to be awaited. - exports.awrap = function(arg) { - return { __await: arg }; - }; +(0, _util.inherits)(TryEntry, Entry); +exports.TryEntry = TryEntry; - function AsyncIterator(generator) { - function invoke(method, arg, resolve, reject) { - var record = tryCatch(generator[method], generator, arg); - if (record.type === "throw") { - reject(record.arg); - } else { - var result = record.arg; - var value = result.value; - if (value && - typeof value === "object" && - hasOwn.call(value, "__await")) { - return Promise.resolve(value.__await).then(function(value) { - invoke("next", value, resolve, reject); - }, function(err) { - invoke("throw", err, resolve, reject); - }); - } +function CatchEntry(firstLoc, paramId) { + Entry.call(this); + var t = (0, _util2.getTypes)(); + t.assertLiteral(firstLoc); + t.assertIdentifier(paramId); + this.firstLoc = firstLoc; + this.paramId = paramId; +} - return 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. - result.value = unwrapped; - resolve(result); - }, function(error) { - // If a rejected Promise was yielded, throw the rejection back - // into the async generator function so it can be handled there. - return invoke("throw", error, resolve, reject); - }); - } - } +(0, _util.inherits)(CatchEntry, Entry); +exports.CatchEntry = CatchEntry; - var previousPromise; +function FinallyEntry(firstLoc, afterLoc) { + Entry.call(this); + var t = (0, _util2.getTypes)(); + t.assertLiteral(firstLoc); + t.assertLiteral(afterLoc); + this.firstLoc = firstLoc; + this.afterLoc = afterLoc; +} - function enqueue(method, arg) { - function callInvokeWithMethodAndArg() { - return new Promise(function(resolve, reject) { - invoke(method, arg, resolve, reject); - }); - } +(0, _util.inherits)(FinallyEntry, Entry); +exports.FinallyEntry = FinallyEntry; - 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 - ) : callInvokeWithMethodAndArg(); - } +function LabeledEntry(breakLoc, label) { + Entry.call(this); + var t = (0, _util2.getTypes)(); + t.assertLiteral(breakLoc); + t.assertIdentifier(label); + this.breakLoc = breakLoc; + this.label = label; +} - // Define the unified helper method that is used to implement .next, - // .throw, and .return (see defineIteratorMethods). - this._invoke = enqueue; - } +(0, _util.inherits)(LabeledEntry, Entry); +exports.LabeledEntry = LabeledEntry; - defineIteratorMethods(AsyncIterator.prototype); - AsyncIterator.prototype[asyncIteratorSymbol] = function () { - return this; - }; - exports.AsyncIterator = AsyncIterator; +function LeapManager(emitter) { + _assert["default"].ok(this instanceof LeapManager); - // 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. - exports.async = function(innerFn, outerFn, self, tryLocsList) { - var iter = new AsyncIterator( - wrap(innerFn, outerFn, self, tryLocsList) - ); + _assert["default"].ok(emitter instanceof _emit.Emitter); - return exports.isGeneratorFunction(outerFn) - ? iter // If outerFn is a generator, return the full iterator. - : iter.next().then(function(result) { - return result.done ? result.value : iter.next(); - }); - }; + this.emitter = emitter; + this.entryStack = [new FunctionEntry(emitter.finalLoc)]; +} - function makeInvokeMethod(innerFn, self, context) { - var state = GenStateSuspendedStart; +var LMp = LeapManager.prototype; +exports.LeapManager = LeapManager; - return function invoke(method, arg) { - if (state === GenStateExecuting) { - throw new Error("Generator is already running"); - } +LMp.withEntry = function (entry, callback) { + _assert["default"].ok(entry instanceof Entry); - if (state === GenStateCompleted) { - if (method === "throw") { - throw arg; - } + this.entryStack.push(entry); - // Be forgiving, per 25.3.3.3.3 of the spec: - // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume - return doneResult(); - } + try { + callback.call(this.emitter); + } finally { + var popped = this.entryStack.pop(); - context.method = method; - context.arg = arg; + _assert["default"].strictEqual(popped, entry); + } +}; - while (true) { - var delegate = context.delegate; - if (delegate) { - var delegateResult = maybeInvokeDelegate(delegate, context); - if (delegateResult) { - if (delegateResult === ContinueSentinel) continue; - return delegateResult; - } - } +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 (context.method === "next") { - // Setting context._sent for legacy support of Babel's - // function.sent implementation. - context.sent = context._sent = context.arg; + 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; + } + } + } - } else if (context.method === "throw") { - if (state === GenStateSuspendedStart) { - state = GenStateCompleted; - throw context.arg; - } + return null; +}; - context.dispatchException(context.arg); +LMp.getBreakLoc = function (label) { + return this._findLeapLocation("breakLoc", label); +}; - } else if (context.method === "return") { - context.abrupt("return", context.arg); - } +LMp.getContinueLoc = function (label) { + return this._findLeapLocation("continueLoc", label); +}; +},{"./emit":494,"./util":500,"@babel/runtime/helpers/interopRequireDefault":83,"assert":196,"util":523}],498:[function(require,module,exports){ +"use strict"; - state = GenStateExecuting; +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - 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 _assert = _interopRequireDefault(require("assert")); - if (record.arg === ContinueSentinel) { - continue; - } +var _util = require("./util.js"); - return { - value: record.arg, - done: context.done - }; +var _private = require("private"); - } else if (record.type === "throw") { - state = GenStateCompleted; - // Dispatch the exception by looping back around to the - // context.dispatchException(context.arg) call above. - context.method = "throw"; - context.arg = record.arg; - } - } - }; - } +/** + * Copyright (c) 2014-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +var m = (0, _private.makeAccessor)(); +var hasOwn = Object.prototype.hasOwnProperty; - // Call delegate.iterator[context.method](context.arg) and handle the - // result, either by returning a { value, done } result from the - // delegate iterator, or by modifying context.method and context.arg, - // setting context.delegate to null, and returning the ContinueSentinel. - function maybeInvokeDelegate(delegate, context) { - var method = delegate.iterator[context.method]; - if (method === undefined) { - // A .throw or .return when the delegate iterator has no .throw - // method always terminates the yield* loop. - context.delegate = null; +function makePredicate(propertyName, knownTypes) { + function onlyChildren(node) { + var t = (0, _util.getTypes)(); + t.assertNode(node); // Assume no side effects until we find out otherwise. - if (context.method === "throw") { - // Note: ["return"] must be used for ES3 parsing compatibility. - if (delegate.iterator["return"]) { - // If the delegate iterator has a return method, give it a - // chance to clean up. - context.method = "return"; - context.arg = undefined; - maybeInvokeDelegate(delegate, context); + var result = false; - if (context.method === "throw") { - // If maybeInvokeDelegate(context) changed context.method from - // "return" to "throw", let that override the TypeError below. - return ContinueSentinel; - } - } + function check(child) { + if (result) {// Do nothing. + } else if (Array.isArray(child)) { + child.some(check); + } else if (t.isNode(child)) { + _assert["default"].strictEqual(result, false); - context.method = "throw"; - context.arg = new TypeError( - "The iterator does not provide a 'throw' method"); + result = predicate(child); } - return ContinueSentinel; + return result; } - var record = tryCatch(method, delegate.iterator, context.arg); + var keys = t.VISITOR_KEYS[node.type]; - if (record.type === "throw") { - context.method = "throw"; - context.arg = record.arg; - context.delegate = null; - return ContinueSentinel; + if (keys) { + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var child = node[key]; + check(child); + } } - var info = record.arg; + return result; + } - if (! info) { - context.method = "throw"; - context.arg = new TypeError("iterator result is not an object"); - context.delegate = null; - return ContinueSentinel; - } + function predicate(node) { + (0, _util.getTypes)().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 (info.done) { - // Assign the result of the finished delegate to the temporary - // variable specified by delegate.resultName (see delegateYield). - context[delegate.resultName] = info.value; + 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); + } - // Resume execution at the desired location (see delegateYield). - context.next = delegate.nextLoc; + predicate.onlyChildren = onlyChildren; + return predicate; +} - // If context.method was "throw" but the delegate handled the - // exception, let the outer generator proceed normally. If - // context.method was "next", forget context.arg since it has been - // "consumed" by the delegate iterator. If context.method was - // "return", allow the original .return call to continue in the - // outer generator. - if (context.method !== "return") { - context.method = "next"; - context.arg = undefined; - } +var opaqueTypes = { + FunctionExpression: true, + ArrowFunctionExpression: true +}; // These types potentially have side effects regardless of what side +// effects their subexpressions have. - } else { - // Re-yield the result returned by the delegate method. - return info; - } +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. - // The delegate iterator is finished, so forget it and continue with - // the outer generator. - context.delegate = null; - return ContinueSentinel; +}; // 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]; } +} - // Define Generator.prototype.{next,throw,return} in terms of the - // unified ._invoke helper method. - defineIteratorMethods(Gp); +exports.hasSideEffects = makePredicate("hasSideEffects", sideEffectTypes); +exports.containsLeap = makePredicate("containsLeap", leapTypes); +},{"./util.js":500,"@babel/runtime/helpers/interopRequireDefault":83,"assert":196,"private":431}],499:[function(require,module,exports){ +"use strict"; - Gp[toStringTagSymbol] = "Generator"; +var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); - // A Generator should always return itself as the iterator object when the - // @@iterator function is called on it. Some browsers' implementations of the - // iterator prototype chain incorrectly implement this, causing the Generator - // object to not be returned from this call. This ensures that doesn't happen. - // See https://github.com/facebook/regenerator/issues/274 for more details. - Gp[iteratorSymbol] = function() { - return this; - }; +exports.__esModule = true; +exports["default"] = replaceShorthandObjectMethod; - Gp.toString = function() { - return "[object Generator]"; - }; +var util = _interopRequireWildcard(require("./util")); - function pushTryEntry(locs) { - var entry = { tryLoc: locs[0] }; +/** + * Copyright (c) 2014-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +// 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) { + var t = util.getTypes(); - if (1 in locs) { - entry.catchLoc = locs[1]; - } + 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 (2 in locs) { - entry.finallyLoc = locs[2]; - entry.afterLoc = locs[3]; - } - this.tryEntries.push(entry); - } + if (!t.isObjectMethod(path.node)) { + return path; + } // this function only replaces generators. - 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); + if (!path.node.generator) { + return path; } - exports.keys = function(object) { - var keys = []; - for (var key in object) { - keys.push(key); - } - keys.reverse(); + 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); + util.replaceWithOrRemove(path, 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. - // 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; - } - } + return path.get("value"); +} +},{"./util":500,"@babel/runtime/helpers/interopRequireWildcard":84}],500:[function(require,module,exports){ +"use strict"; - // 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; - }; - }; +exports.__esModule = true; +exports.wrapWithTypes = wrapWithTypes; +exports.getTypes = getTypes; +exports.runtimeProperty = runtimeProperty; +exports.isReference = isReference; +exports.replaceWithOrRemove = replaceWithOrRemove; - function values(iterable) { - if (iterable) { - var iteratorMethod = iterable[iteratorSymbol]; - if (iteratorMethod) { - return iteratorMethod.call(iterable); - } +/** + * Copyright (c) 2014-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +var currentTypes = null; - if (typeof iterable.next === "function") { - return iterable; +function wrapWithTypes(types, fn) { + return function () { + var oldTypes = currentTypes; + currentTypes = types; + + try { + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; } - 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; - } - } + return fn.apply(this, args); + } finally { + currentTypes = oldTypes; + } + }; +} - next.value = undefined; - next.done = true; +function getTypes() { + return currentTypes; +} - return next; - }; +function runtimeProperty(name) { + var t = getTypes(); + return t.memberExpression(t.identifier("regeneratorRuntime"), t.identifier(name), false); +} - return next.next = next; - } - } +function isReference(path) { + return path.isReferenced() || path.parentPath.isAssignmentExpression({ + left: path.node + }); +} - // Return an iterator with no values. - return { next: doneResult }; +function replaceWithOrRemove(path, replacement) { + if (replacement) { + path.replaceWith(replacement); + } else { + path.remove(); } - exports.values = values; +} +},{}],501:[function(require,module,exports){ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +"use strict"; - function doneResult() { - return { value: undefined, done: true }; - } +var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); - Context.prototype = { - constructor: Context, +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - reset: function(skipTempReset) { - this.prev = 0; - this.next = 0; - // Resetting context._sent for legacy support of Babel's - // function.sent implementation. - this.sent = this._sent = undefined; - this.done = false; - this.delegate = null; +var _assert = _interopRequireDefault(require("assert")); - this.method = "next"; - this.arg = undefined; +var _hoist = require("./hoist"); - this.tryEntries.forEach(resetTryEntry); +var _emit = require("./emit"); - 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; - } - } - } - }, +var _replaceShorthandObjectMethod = _interopRequireDefault(require("./replaceShorthandObjectMethod")); - stop: function() { - this.done = true; +var util = _interopRequireWildcard(require("./util")); - var rootEntry = this.tryEntries[0]; - var rootRecord = rootEntry.completion; - if (rootRecord.type === "throw") { - throw rootRecord.arg; - } +var _private = require("private"); - return this.rval; - }, +exports.getVisitor = function (_ref) { + var t = _ref.types; + return { + Method: function Method(path, state) { + var node = path.node; + if (!shouldRegenerate(node, state)) return; + var container = t.functionExpression(null, [], t.cloneNode(node.body, false), node.generator, node.async); + path.get("body").set("body", [t.returnStatement(t.callExpression(container, []))]); // Regardless of whether or not the wrapped function is a an async method + // or generator the outer function should not be - dispatchException: function(exception) { - if (this.done) { - throw exception; - } + node.async = false; + node.generator = false; // Unwrap the wrapper IIFE's environment so super and this and such still work. - var context = this; - function handle(loc, caught) { - record.type = "throw"; - record.arg = exception; - context.next = loc; + path.get("body.body.0.argument.callee").unwrapFunctionEnvironment(); + }, + Function: { + exit: util.wrapWithTypes(t, function (path, state) { + var node = path.node; + if (!shouldRegenerate(node, state)) return; // if this is an ObjectMethod, we need to convert it to an ObjectProperty - if (caught) { - // If the dispatched exception was caught by a catch block, - // then let that catch block handle the exception normally. - context.method = "next"; - context.arg = undefined; + path = (0, _replaceShorthandObjectMethod["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); } - return !! caught; - } + bodyBlockPath.traverse(functionSentVisitor, { + context: contextId + }); + var outerBody = []; + var innerBody = []; + bodyBlockPath.get("body").forEach(function (childPath) { + var node = childPath.node; - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; - var record = entry.completion; + 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 (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 (outerBody.length > 0) { + // Only replace the inner body if we actually hoisted any statements + // to the outer body. + bodyBlockPath.node.body = innerBody; } - if (entry.tryLoc <= this.prev) { - var hasCatch = hasOwn.call(entry, "catchLoc"); - var hasFinally = hasOwn.call(entry, "finallyLoc"); + 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. - if (hasCatch && hasFinally) { - if (this.prev < entry.catchLoc) { - return handle(entry.catchLoc, true); - } else if (this.prev < entry.finallyLoc) { - return handle(entry.finallyLoc); - } + 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. - } else if (hasCatch) { - if (this.prev < entry.catchLoc) { - return handle(entry.catchLoc, true); - } + var vars = (0, _hoist.hoist)(path); + var context = { + usesThis: false, + usesArguments: false, + getArgsId: function getArgsId() { + return t.clone(argsId); + } + }; + path.traverse(argumentsThisVisitor, context); - } else if (hasFinally) { - if (this.prev < entry.finallyLoc) { - return handle(entry.finallyLoc); - } + if (context.usesArguments) { + vars = vars || t.variableDeclaration("var", []); + var argumentIdentifier = t.identifier("arguments"); // we need to do this as otherwise arguments in arrow functions gets hoisted - } else { - throw new Error("try statement without catch or finally"); - } + argumentIdentifier._shadowedFunctionLiteral = path; + vars.declarations.push(t.variableDeclarator(t.clone(argsId), argumentIdentifier)); } - } - }, - 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; - } - } + var emitter = new _emit.Emitter(contextId); + emitter.explode(path.get("body")); - 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; - } + if (vars && vars.declarations.length > 0) { + outerBody.push(vars); + } - var record = finallyEntry ? finallyEntry.completion : {}; - record.type = type; - record.arg = arg; + var wrapArgs = [emitter.getContextFunction(innerFnId)]; + var tryLocsList = emitter.getTryLocsList(); - if (finallyEntry) { - this.method = "next"; - this.next = finallyEntry.finallyLoc; - return ContinueSentinel; - } + if (node.generator) { + wrapArgs.push(outerFnExpr); + } else if (context.usesThis || tryLocsList || node.async) { + // 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. + wrapArgs.push(t.nullLiteral()); + } - return this.complete(record); - }, + if (context.usesThis) { + wrapArgs.push(t.thisExpression()); + } else if (tryLocsList || node.async) { + wrapArgs.push(t.nullLiteral()); + } - complete: function(record, afterLoc) { - if (record.type === "throw") { - throw record.arg; - } + if (tryLocsList) { + wrapArgs.push(tryLocsList); + } else if (node.async) { + wrapArgs.push(t.nullLiteral()); + } - if (record.type === "break" || - record.type === "continue") { - this.next = record.arg; - } else if (record.type === "return") { - this.rval = this.arg = record.arg; - this.method = "return"; - this.next = "end"; - } else if (record.type === "normal" && afterLoc) { - this.next = afterLoc; - } + if (node.async) { + // Rename any locally declared "Promise" variable, + // to use the global one. + var currentScope = path.scope; - return ContinueSentinel; - }, + do { + if (currentScope.hasOwnBinding("Promise")) currentScope.rename("Promise"); + } while (currentScope = currentScope.parent); - 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; + wrapArgs.push(t.identifier("Promise")); } - } - }, - "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; + var wrapCall = t.callExpression(util.runtimeProperty(node.async ? "async" : "wrap"), wrapArgs); + outerBody.push(t.returnStatement(wrapCall)); + node.body = t.blockStatement(outerBody); // We injected a few new variable declarations (for every hoisted var), + // so we need to add them to the scope. + + path.get("body.body").forEach(function (p) { + return p.scope.registerDeclaration(p); + }); + 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; } - } - // 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"); - }, + var wasGeneratorFunction = node.generator; - delegateYield: function(iterable, resultName, nextLoc) { - this.delegate = { - iterator: values(iterable), - resultName: resultName, - nextLoc: nextLoc - }; + if (wasGeneratorFunction) { + node.generator = false; + } - if (this.method === "next") { - // Deliberately forget the last sent value so that we don't - // accidentally pass it on to the delegate. - this.arg = undefined; - } + if (node.async) { + node.async = false; + } - return ContinueSentinel; + if (wasGeneratorFunction && t.isExpression(node)) { + util.replaceWithOrRemove(path, t.callExpression(util.runtimeProperty("mark"), [node])); + path.addComment("leading", "#__PURE__"); + } + + var insertedLocs = emitter.getInsertedLocs(); + path.traverse({ + NumericLiteral: function NumericLiteral(path) { + if (!insertedLocs.has(path.node)) { + return; + } + + path.replaceWith(t.numericLiteral(path.node.value)); + } + }); // 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(); + }) } }; +}; // Check if a node should be transformed by regenerator - // Regardless of whether this script is executing as a CommonJS module - // or not, return the runtime object so that we can declare the variable - // regeneratorRuntime in the outer scope, which allows this module to be - // injected easily by `bin/regenerator --include-runtime script.js`. - return exports; - -}( - // If this script is executing as a CommonJS module, use module.exports - // as the regeneratorRuntime namespace. Otherwise create a new empty - // object. Either way, the resulting object will be used to initialize - // the regeneratorRuntime variable at the top of this file. - typeof module === "object" ? module.exports : {} -)); -try { - regeneratorRuntime = runtime; -} catch (accidentalStrictMode) { - // This module should not be running in strict mode, so the above - // assignment should always work unless something is misconfigured. Just - // in case runtime.js accidentally runs in strict mode, we can escape - // strict mode using a global Function call. This could conceivably fail - // if a Content Security Policy forbids using Function, but in that case - // the proper solution is to fix the accidental strict mode problem. If - // you've misconfigured your bundler to force strict mode and applied a - // CSP to forbid Function, and you're not willing to fix either of those - // problems, please detail your unique predicament in a GitHub issue. - Function("r", "regeneratorRuntime = r")(runtime); -} +function shouldRegenerate(node, state) { + if (node.generator) { + if (node.async) { + // Async generator + return state.opts.asyncGenerators !== false; + } else { + // Plain generator + return state.opts.generators !== false; + } + } else if (node.async) { + // Async function + return state.opts.async !== false; + } else { + // Not a generator or async function. + return false; + } +} // 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. -},{}],509:[function(require,module,exports){ -"use strict"; -var _assert = _interopRequireDefault(require("assert")); +function getOuterFnExpr(funPath) { + var t = util.getTypes(); + var node = funPath.node; + t.assertFunction(node); -var leap = _interopRequireWildcard(require("./leap")); + 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"); + } -var meta = _interopRequireWildcard(require("./meta")); + if (node.generator && // Non-generator functions don't need to be marked. + t.isFunctionDeclaration(node)) { + // Return the identifier returned by runtime.mark(). + return getMarkedFunctionId(funPath); + } -var util = _interopRequireWildcard(require("./util")); + return t.clone(node.id); +} -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } } +var getMarkInfo = (0, _private.makeAccessor)(); -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } +function getMarkedFunctionId(funPath) { + var t = util.getTypes(); + var node = funPath.node; + t.assertIdentifier(node.id); + var blockPath = funPath.findParent(function (path) { + return path.isProgram() || path.isBlockStatement(); + }); -/** - * Copyright (c) 2014-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -var hasOwn = Object.prototype.hasOwnProperty; + if (!blockPath) { + return node.id; + } -function Emitter(contextId) { - _assert["default"].ok(this instanceof Emitter); + var block = blockPath.node; - util.getTypes().assertIdentifier(contextId); // Used to generate unique temporary names. + _assert["default"].ok(Array.isArray(block.body)); - this.nextTempId = 0; // 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". + var info = getMarkInfo(block); - this.contextId = contextId; // An append-only list of Statements that grows each time this.emit is - // called. + if (!info.decl) { + info.decl = t.variableDeclaration("var", []); + blockPath.unshiftContainer("body", info.decl); + info.declPath = blockPath.get("body.0"); + } - this.listing = []; // A sparse array whose keys correspond to locations in this.listing - // that have been marked as branch/jump targets. + _assert["default"].strictEqual(info.declPath.node, info.decl); // Get a new unique identifier for our marked variable. - this.marked = [true]; - this.insertedLocs = new Set(); // The last location will be marked when this.getDispatchLoop is - // called. - this.finalLoc = this.loc(); // A list of all leap.TryEntry statements emitted. + var markedId = blockPath.scope.generateUidIdentifier("marked"); + var markCallExp = t.callExpression(util.runtimeProperty("mark"), [t.clone(node.id)]); + var index = info.decl.declarations.push(t.variableDeclarator(markedId, markCallExp)) - 1; + var markCallExpPath = info.declPath.get("declarations." + index + ".init"); - this.tryEntries = []; // 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. + _assert["default"].strictEqual(markCallExpPath.node, markCallExp); - this.leapManager = new leap.LeapManager(this); + markCallExpPath.addComment("leading", "#__PURE__"); + return t.clone(markedId); } -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. - -Ep.loc = function () { - var l = util.getTypes().numericLiteral(-1); - this.insertedLocs.add(l); - return l; +var argumentsThisVisitor = { + "FunctionExpression|FunctionDeclaration|Method": function FunctionExpressionFunctionDeclarationMethod(path) { + path.skip(); + }, + Identifier: function Identifier(path, state) { + if (path.node.name === "arguments" && util.isReference(path)) { + util.replaceWithOrRemove(path, state.getArgsId()); + state.usesArguments = true; + } + }, + ThisExpression: function ThisExpression(path, state) { + state.usesThis = true; + } }; +var functionSentVisitor = { + MetaProperty: function MetaProperty(path) { + var node = path.node; -Ep.getInsertedLocs = function () { - return this.insertedLocs; + if (node.meta.name === "function" && node.property.name === "sent") { + var t = util.getTypes(); + util.replaceWithOrRemove(path, t.memberExpression(t.clone(this.context), t.identifier("_sent"))); + } + } }; +var awaitVisitor = { + Function: function Function(path) { + path.skip(); // Don't descend into nested function scopes. + }, + AwaitExpression: function AwaitExpression(path) { + var t = util.getTypes(); // Convert await expressions to yield expressions. -Ep.getContextId = function () { - return util.getTypes().clone(this.contextId); -}; // Sets the exact value of the given location to the offset of the next -// Statement emitted. - - -Ep.mark = function (loc) { - util.getTypes().assertLiteral(loc); - var index = this.listing.length; + 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. - if (loc.value === -1) { - loc.value = index; - } else { - // Locations can be marked redundantly, but their values cannot change - // once set the first time. - _assert["default"].strictEqual(loc.value, index); + util.replaceWithOrRemove(path, t.yieldExpression(t.callExpression(util.runtimeProperty("awrap"), [argument]), false)); } - - this.marked[index] = true; - return loc; }; +},{"./emit":494,"./hoist":495,"./replaceShorthandObjectMethod":499,"./util":500,"@babel/runtime/helpers/interopRequireDefault":83,"@babel/runtime/helpers/interopRequireWildcard":84,"assert":196,"private":431}],502:[function(require,module,exports){ +/* eslint-disable node/no-deprecated-api */ +var buffer = require('buffer') +var Buffer = buffer.Buffer -Ep.emit = function (node) { - var t = util.getTypes(); - - if (t.isExpression(node)) { - node = t.expressionStatement(node); +// alternative to using Object.keys for old browsers +function copyProps (src, dst) { + for (var key in src) { + dst[key] = src[key] } +} +if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { + module.exports = buffer +} else { + // Copy properties from require('buffer') + copyProps(buffer, exports) + exports.Buffer = SafeBuffer +} - t.assertStatement(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) { - var t = util.getTypes(); - return t.expressionStatement(t.assignmentExpression("=", t.cloneDeep(lhs), rhs)); -}; // Convenience function for generating expressions like context.next, -// context.sent, and context.rval. - - -Ep.contextProperty = function (name, computed) { - var t = util.getTypes(); - return t.memberExpression(this.getContextId(), computed ? t.stringLiteral(name) : t.identifier(name), !!computed); -}; // Shorthand for setting context.rval and jumping to `context.stop()`. +function SafeBuffer (arg, encodingOrOffset, length) { + return Buffer(arg, encodingOrOffset, length) +} +// Copy static methods from Buffer +copyProps(Buffer, SafeBuffer) -Ep.stop = function (rval) { - if (rval) { - this.setReturnValue(rval); +SafeBuffer.from = function (arg, encodingOrOffset, length) { + if (typeof arg === 'number') { + throw new TypeError('Argument must not be a number') } + return Buffer(arg, encodingOrOffset, length) +} - this.jump(this.finalLoc); -}; - -Ep.setReturnValue = function (valuePath) { - util.getTypes().assertExpression(valuePath.value); - this.emitAssign(this.contextProperty("rval"), this.explodeExpression(valuePath)); -}; - -Ep.clearPendingException = function (tryLoc, assignee) { - var t = util.getTypes(); - t.assertLiteral(tryLoc); - var catchCall = t.callExpression(this.contextProperty("catch", true), [t.clone(tryLoc)]); - - if (assignee) { - this.emitAssign(assignee, catchCall); +SafeBuffer.alloc = function (size, fill, encoding) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + var buf = Buffer(size) + if (fill !== undefined) { + if (typeof encoding === 'string') { + buf.fill(fill, encoding) + } else { + buf.fill(fill) + } } else { - this.emit(catchCall); + buf.fill(0) } -}; // 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(util.getTypes().breakStatement()); -}; // Conditional jump. + return buf +} +SafeBuffer.allocUnsafe = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return Buffer(size) +} -Ep.jumpIf = function (test, toLoc) { - var t = util.getTypes(); - t.assertExpression(test); - t.assertLiteral(toLoc); - this.emit(t.ifStatement(test, t.blockStatement([this.assign(this.contextProperty("next"), toLoc), t.breakStatement()]))); -}; // Conditional jump, with the condition negated. +SafeBuffer.allocUnsafeSlow = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return buffer.SlowBuffer(size) +} +},{"buffer":203}],503:[function(require,module,exports){ +arguments[4][479][0].apply(exports,arguments) +},{"./util":512,"dup":479}],504:[function(require,module,exports){ +arguments[4][480][0].apply(exports,arguments) +},{"./base64":505,"dup":480}],505:[function(require,module,exports){ +arguments[4][481][0].apply(exports,arguments) +},{"dup":481}],506:[function(require,module,exports){ +arguments[4][482][0].apply(exports,arguments) +},{"dup":482}],507:[function(require,module,exports){ +arguments[4][483][0].apply(exports,arguments) +},{"./util":512,"dup":483}],508:[function(require,module,exports){ +arguments[4][484][0].apply(exports,arguments) +},{"dup":484}],509:[function(require,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 + */ -Ep.jumpIfNot = function (test, toLoc) { - var t = util.getTypes(); - t.assertExpression(test); - t.assertLiteral(toLoc); - var negatedTest; +var util = require('./util'); +var binarySearch = require('./binary-search'); +var ArraySet = require('./array-set').ArraySet; +var base64VLQ = require('./base64-vlq'); +var quickSort = require('./quick-sort').quickSort; - if (t.isUnaryExpression(test) && test.operator === "!") { - // Avoid double negation. - negatedTest = test.argument; - } else { - negatedTest = t.unaryExpression("!", test); +function SourceMapConsumer(aSourceMap) { + var sourceMap = aSourceMap; + if (typeof aSourceMap === 'string') { + sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, '')); } - this.emit(t.ifStatement(negatedTest, t.blockStatement([this.assign(this.contextProperty("next"), toLoc), t.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. + return sourceMap.sections != null + ? new IndexedSourceMapConsumer(sourceMap) + : new BasicSourceMapConsumer(sourceMap); +} +SourceMapConsumer.fromSourceMap = function(aSourceMap) { + return BasicSourceMapConsumer.fromSourceMap(aSourceMap); +} -Ep.makeTempVar = function () { - return this.contextProperty("t" + this.nextTempId++); -}; +/** + * The version of the source mapping spec that we are consuming. + */ +SourceMapConsumer.prototype._version = 3; -Ep.getContextFunction = function (id) { - var t = util.getTypes(); - return t.functionExpression(id || null - /*Anonymous*/ - , [this.getContextId()], t.blockStatement([this.getDispatchLoop()]), false, // Not a generator anymore! - false // Nor an expression. - ); -}; // Turns this.listing into a loop of the form +// `__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. // -// while (1) switch (context.next) { -// case 0: -// ... -// case n: -// return context.stop(); -// } +// Each object in the arrays is of the form: // -// Each marked location in this.listing will correspond to one generated -// case statement. - - -Ep.getDispatchLoop = function () { - var self = this; - var t = util.getTypes(); - 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. +// { +// 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. - var alreadyEnded = false; - self.listing.forEach(function (stmt, i) { - if (self.marked.hasOwnProperty(i)) { - cases.push(t.switchCase(t.numericLiteral(i), current = [])); - alreadyEnded = false; +SourceMapConsumer.prototype.__generatedMappings = null; +Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', { + get: function () { + if (!this.__generatedMappings) { + this._parseMappings(this._mappings, this.sourceRoot); } - if (!alreadyEnded) { - current.push(stmt); - if (t.isCompletionStatement(stmt)) alreadyEnded = true; - } - }); // Now that we know how many statements there will be in this.listing, - // we can finally resolve this.finalLoc.value. + return this.__generatedMappings; + } +}); - this.finalLoc.value = this.listing.length; - cases.push(t.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. - t.switchCase(t.stringLiteral("end"), [// This will check/clear both context.thrown and context.rval. - t.returnStatement(t.callExpression(this.contextProperty("stop"), []))])); - return t.whileStatement(t.numericLiteral(1), t.switchStatement(t.assignmentExpression("=", this.contextProperty("prev"), this.contextProperty("next")), cases)); -}; +SourceMapConsumer.prototype.__originalMappings = null; +Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', { + get: function () { + if (!this.__originalMappings) { + this._parseMappings(this._mappings, this.sourceRoot); + } -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; + return this.__originalMappings; } +}); - var t = util.getTypes(); - var lastLocValue = 0; - return t.arrayExpression(this.tryEntries.map(function (tryEntry) { - var thisLocValue = tryEntry.firstLoc.value; +SourceMapConsumer.prototype._charIsMappingSeparator = + function SourceMapConsumer_charIsMappingSeparator(aStr, index) { + var c = aStr.charAt(index); + return c === ";" || c === ","; + }; - _assert["default"].ok(thisLocValue >= lastLocValue, "try entries out of order"); +/** + * 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"); + }; - 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]; +SourceMapConsumer.GENERATED_ORDER = 1; +SourceMapConsumer.ORIGINAL_ORDER = 2; - if (fe) { - locs[2] = fe.firstLoc; - locs[3] = fe.afterLoc; +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."); } - return t.arrayExpression(locs.map(function (loc) { - return loc && t.clone(loc); - })); - })); -}; // 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. + 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'); -Ep.explode = function (path, ignoreResult) { - var t = util.getTypes(); - var node = path.node; - var self = this; - t.assertNode(node); - if (t.isDeclaration(node)) throw getDeclError(node); - if (t.isStatement(node)) return self.explodeStatement(path); - if (t.isExpression(node)) return self.explodeExpression(path, ignoreResult); + // 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) + }; - switch (node.type) { - case "Program": - return path.get("body").map(self.explodeStatement, self); + 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); - case "VariableDeclarator": - throw getDeclError(node); - // These node types should be handled by their parent nodes - // (ObjectExpression, SwitchStatement, and TryStatement, respectively). + var mappings = []; - case "Property": - case "SwitchCase": - case "CatchClause": - throw new Error(node.type + " nodes should be handled by their parents"); + var index = this._findMapping(needle, + this._originalMappings, + "originalLine", + "originalColumn", + util.compareByOriginalPositions, + binarySearch.LEAST_UPPER_BOUND); + if (index >= 0) { + var mapping = this._originalMappings[index]; - default: - throw new Error("unknown Node of type " + JSON.stringify(node.type)); - } -}; + if (aArgs.column === undefined) { + var originalLine = mapping.originalLine; -function getDeclError(node) { - return new Error("all declarations should have been transformed into " + "assignments before the Exploder began its work: " + JSON.stringify(node)); -} + // 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) + }); -Ep.explodeStatement = function (path, labelId) { - var t = util.getTypes(); - var stmt = path.node; - var self = this; - var before, after, head; - t.assertStatement(stmt); + mapping = this._originalMappings[++index]; + } + } else { + var originalColumn = mapping.originalColumn; - if (labelId) { - t.assertIdentifier(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. + // 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]; + } + } + } - if (t.isBlockStatement(stmt)) { - path.get("body").forEach(function (path) { - self.explodeStatement(path); - }); - return; + 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(/^\)\]\}'/, '')); } - 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; + 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); } - switch (stmt.type) { - case "ExpressionStatement": - self.explodeExpression(path.get("expression"), true); - break; + sources = sources + .map(String) + // 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; + }); - case "LabeledStatement": - after = this.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. + // 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.map(String), true); + this._sources = ArraySet.fromArray(sources, true); - self.leapManager.withEntry(new leap.LabeledEntry(after, stmt.label), function () { - self.explodeStatement(path.get("body"), stmt.label); - }); - self.mark(after); - break; + this.sourceRoot = sourceRoot; + this.sourcesContent = sourcesContent; + this._mappings = mappings; + this.file = file; +} - case "WhileStatement": - before = this.loc(); - after = this.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; +BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype); +BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer; - case "DoWhileStatement": - var first = this.loc(); - var test = this.loc(); - after = this.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; +/** + * 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); - case "ForStatement": - head = this.loc(); - var update = this.loc(); - after = this.loc(); + 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; - 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); - } + // 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. - self.mark(head); + var generatedMappings = aSourceMap._mappings.toArray().slice(); + var destGeneratedMappings = smc.__generatedMappings = []; + var destOriginalMappings = smc.__originalMappings = []; - if (stmt.test) { - self.jumpIfNot(self.explodeExpression(path.get("test")), after); - } else {// No test means continue unconditionally. - } + 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; - self.leapManager.withEntry(new leap.LoopEntry(after, update, labelId), function () { - self.explodeStatement(path.get("body")); - }); - self.mark(update); + if (srcMapping.source) { + destMapping.source = sources.indexOf(srcMapping.source); + destMapping.originalLine = srcMapping.originalLine; + destMapping.originalColumn = srcMapping.originalColumn; - 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); + if (srcMapping.name) { + destMapping.name = names.indexOf(srcMapping.name); + } + + destOriginalMappings.push(destMapping); } - self.jump(head); - self.mark(after); - break; + destGeneratedMappings.push(destMapping); + } - case "TypeCastExpression": - return self.explodeExpression(path.get("expression")); + quickSort(smc.__originalMappings, util.compareByOriginalPositions); - case "ForInStatement": - head = this.loc(); - after = this.loc(); - var keyIterNextFn = self.makeTempVar(); - self.emitAssign(keyIterNextFn, t.callExpression(util.runtimeProperty("keys"), [self.explodeExpression(path.get("right"))])); - self.mark(head); - var keyInfoTmpVar = self.makeTempVar(); - self.jumpIf(t.memberExpression(t.assignmentExpression("=", keyInfoTmpVar, t.callExpression(t.cloneDeep(keyIterNextFn), [])), t.identifier("done"), false), after); - self.emitAssign(stmt.left, t.memberExpression(t.cloneDeep(keyInfoTmpVar), t.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; + return smc; + }; - case "BreakStatement": - self.emitAbruptCompletion({ - type: "break", - target: self.leapManager.getBreakLoc(stmt.label) - }); - break; +/** + * The version of the source mapping spec that we are consuming. + */ +BasicSourceMapConsumer.prototype._version = 3; - case "ContinueStatement": - self.emitAbruptCompletion({ - type: "continue", - target: self.leapManager.getContinueLoc(stmt.label) - }); - break; +/** + * 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); + } +}); - 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"))); - after = this.loc(); - var defaultLoc = this.loc(); - var condition = defaultLoc; - var caseLocs = []; // If there are no cases, .cases might be undefined. +/** + * 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; +} - var cases = stmt.cases || []; +/** + * 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; - for (var i = cases.length - 1; i >= 0; --i) { - var c = cases[i]; - t.assertSwitchCase(c); + while (index < length) { + if (aStr.charAt(index) === ';') { + generatedLine++; + index++; + previousGeneratedColumn = 0; + } + else if (aStr.charAt(index) === ',') { + index++; + } + else { + mapping = new Mapping(); + mapping.generatedLine = generatedLine; - if (c.test) { - condition = t.conditionalExpression(t.binaryExpression("===", t.cloneDeep(disc), c.test), caseLocs[i] = this.loc(), condition); - } else { - caseLocs[i] = defaultLoc; + // 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); - var discriminant = path.get("discriminant"); - util.replaceWithOrRemove(discriminant, condition); - self.jump(self.explodeExpression(discriminant)); - self.leapManager.withEntry(new leap.SwitchEntry(after), function () { - path.get("cases").forEach(function (casePath) { - var i = casePath.key; - self.mark(caseLocs[i]); - casePath.get("consequent").forEach(function (path) { - self.explodeStatement(path); - }); - }); - }); - self.mark(after); - - if (defaultLoc.value === -1) { - self.mark(defaultLoc); - - _assert["default"].strictEqual(after.value, defaultLoc.value); - } + 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); + } - break; + if (segment.length === 2) { + throw new Error('Found a source, but no line and column'); + } - case "IfStatement": - var elseLoc = stmt.alternate && this.loc(); - after = this.loc(); - self.jumpIfNot(self.explodeExpression(path.get("test")), elseLoc || after); - self.explodeStatement(path.get("consequent")); + if (segment.length === 3) { + throw new Error('Found a source and line, but no column'); + } - if (elseLoc) { - self.jump(after); - self.mark(elseLoc); - self.explodeStatement(path.get("alternate")); - } + cachedSegments[str] = segment; + } - self.mark(after); - break; + // Generated column. + mapping.generatedColumn = previousGeneratedColumn + segment[0]; + previousGeneratedColumn = mapping.generatedColumn; - case "ReturnStatement": - self.emitAbruptCompletion({ - type: "return", - value: self.explodeExpression(path.get("argument")) - }); - break; + if (segment.length > 1) { + // Original source. + mapping.source = previousSource + segment[1]; + previousSource += segment[1]; - case "WithStatement": - throw new Error("WithStatement not supported in generator functions."); + // Original line. + mapping.originalLine = previousOriginalLine + segment[2]; + previousOriginalLine = mapping.originalLine; + // Lines are stored 0-based + mapping.originalLine += 1; - case "TryStatement": - after = this.loc(); - var handler = stmt.handler; - var catchLoc = handler && this.loc(); - var catchEntry = catchLoc && new leap.CatchEntry(catchLoc, handler.param); - var finallyLoc = stmt.finalizer && this.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")); + // Original column. + mapping.originalColumn = previousOriginalColumn + segment[3]; + previousOriginalColumn = mapping.originalColumn; - 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); + if (segment.length > 4) { + // Original name. + mapping.name = previousName + segment[4]; + previousName += segment[4]; } - - self.updateContextPrevLoc(self.mark(catchLoc)); - var bodyPath = path.get("handler.body"); - var safeParam = self.makeTempVar(); - self.clearPendingException(tryEntry.firstLoc, safeParam); - bodyPath.traverse(catchParamVisitor, { - getSafeParam: function getSafeParam() { - return t.cloneDeep(safeParam); - }, - catchParamName: handler.param.name - }); - 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(t.returnStatement(t.callExpression(self.contextProperty("finish"), [finallyEntry.firstLoc]))); + generatedMappings.push(mapping); + if (typeof mapping.originalLine === 'number') { + originalMappings.push(mapping); } - }); - self.mark(after); - break; - - case "ThrowStatement": - self.emit(t.throwStatement(self.explodeExpression(path.get("argument")))); - break; - - default: - throw new Error("unknown Statement of type " + JSON.stringify(stmt.type)); - } -}; - -var catchParamVisitor = { - Identifier: function Identifier(path, state) { - if (path.node.name === state.catchParamName && util.isReference(path)) { - util.replaceWithOrRemove(path, state.getSafeParam()); - } - }, - Scope: function Scope(path, state) { - if (path.scope.hasOwnBinding(state.catchParamName)) { - // Don't descend into nested scopes that shadow the catch - // parameter with their own declarations. - path.skip(); + } } - } -}; -Ep.emitAbruptCompletion = function (record) { - if (!isValidCompletion(record)) { - _assert["default"].ok(false, "invalid completion record: " + JSON.stringify(record)); - } + quickSort(generatedMappings, util.compareByGeneratedPositionsDeflated); + this.__generatedMappings = generatedMappings; - _assert["default"].notStrictEqual(record.type, "normal", "normal completions are not abrupt"); + quickSort(originalMappings, util.compareByOriginalPositions); + this.__originalMappings = originalMappings; + }; - var t = util.getTypes(); - var abruptArgs = [t.stringLiteral(record.type)]; +/** + * 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 (record.type === "break" || record.type === "continue") { - t.assertLiteral(record.target); - abruptArgs[1] = this.insertedLocs.has(record.target) ? record.target : t.cloneDeep(record.target); - } else if (record.type === "return" || record.type === "throw") { - if (record.value) { - t.assertExpression(record.value); - abruptArgs[1] = this.insertedLocs.has(record.value) ? record.value : t.cloneDeep(record.value); + 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]); } - } - - this.emit(t.returnStatement(t.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") && util.getTypes().isLiteral(record.target); - } + return binarySearch.search(aNeedle, aMappings, aComparator, aBias); + }; - if (type === "return" || type === "throw") { - return hasOwn.call(record, "value") && !hasOwn.call(record, "target"); - } +/** + * 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]; - 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. + // 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; + } + } -Ep.getUnmarkedCurrentLoc = function () { - return util.getTypes().numericLiteral(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. + // 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') + }; -Ep.updateContextPrevLoc = function (loc) { - var t = util.getTypes(); + var index = this._findMapping( + needle, + this._generatedMappings, + "generatedLine", + "generatedColumn", + util.compareByGeneratedPositionsDeflated, + util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND) + ); - if (loc) { - t.assertLiteral(loc); + if (index >= 0) { + var mapping = this._generatedMappings[index]; - 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["default"].strictEqual(loc.value, this.listing.length); + 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 + }; + } } - } 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. + return { + source: null, + line: null, + column: null, + name: null + }; + }; - this.emitAssign(this.contextProperty("prev"), loc); -}; - -Ep.explodeExpression = function (path, ignoreResult) { - var t = util.getTypes(); - var expr = path.node; +/** + * 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; }); + }; - if (expr) { - t.assertExpression(expr); - } else { - return expr; - } +/** + * 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; + } - var self = this; - var result; // Used optionally by several cases below. + if (this.sourceRoot != null) { + aSource = util.relative(this.sourceRoot, aSource); + } - var after; + if (this._sources.has(aSource)) { + return this.sourcesContent[this._sources.indexOf(aSource)]; + } - function finish(expr) { - t.assertExpression(expr); + 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 (ignoreResult) { - self.emit(expr); - } else { - return expr; + if ((!url.path || url.path == "/") + && this._sources.has("/" + aSource)) { + return this.sourcesContent[this._sources.indexOf("/" + aSource)]; + } } - } // 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). + // 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 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. + var needle = { + source: source, + originalLine: util.getArg(aArgs, 'line'), + originalColumn: util.getArg(aArgs, 'column') + }; - function explodeViaTempVar(tempVar, childPath, ignoreChildResult) { - _assert["default"].ok(!ignoreChildResult || !tempVar, "Ignoring the result of a child expression but forcing it to " + "be assigned to a temporary variable?"); + var index = this._findMapping( + needle, + this._originalMappings, + "originalLine", + "originalColumn", + util.compareByOriginalPositions, + util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND) + ); - var result = self.explodeExpression(childPath, ignoreChildResult); + if (index >= 0) { + var mapping = this._originalMappings[index]; - if (ignoreChildResult) {// Side effects already emitted above. - } else if (tempVar || hasLeapingChildren && !t.isLiteral(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); + 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 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. - + return { + line: null, + column: null, + lastColumn: null + }; + }; - switch (expr.type) { - case "MemberExpression": - return finish(t.memberExpression(self.explodeExpression(path.get("object")), expr.computed ? explodeViaTempVar(null, path.get("property")) : expr.property, expr.computed)); +exports.BasicSourceMapConsumer = BasicSourceMapConsumer; - case "CallExpression": - var calleePath = path.get("callee"); - var argsPath = path.get("arguments"); - var newCallee; - var newArgs = []; - var hasLeapingArgs = false; - argsPath.forEach(function (argPath) { - hasLeapingArgs = hasLeapingArgs || meta.containsLeap(argPath.node); - }); +/** + * 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(/^\)\]\}'/, '')); + } - if (t.isMemberExpression(calleePath.node)) { - 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.node.computed ? explodeViaTempVar(null, calleePath.get("property")) : calleePath.node.property; - newArgs.unshift(newObject); - newCallee = t.memberExpression(t.memberExpression(t.cloneDeep(newObject), newProperty, calleePath.node.computed), t.identifier("call"), false); - } else { - newCallee = self.explodeExpression(calleePath); - } - } else { - newCallee = explodeViaTempVar(null, calleePath); + var version = util.getArg(sourceMap, 'version'); + var sections = util.getArg(sourceMap, 'sections'); - if (t.isMemberExpression(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 = t.sequenceExpression([t.numericLiteral(0), t.cloneDeep(newCallee)]); - } - } + if (version != this._version) { + throw new Error('Unsupported version: ' + version); + } - argsPath.forEach(function (argPath) { - newArgs.push(explodeViaTempVar(null, argPath)); - }); - return finish(t.callExpression(newCallee, newArgs.map(function (arg) { - return t.cloneDeep(arg); - }))); + this._sources = new ArraySet(); + this._names = new ArraySet(); - case "NewExpression": - return finish(t.newExpression(explodeViaTempVar(null, path.get("callee")), path.get("arguments").map(function (argPath) { - return explodeViaTempVar(null, argPath); - }))); + 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'); - case "ObjectExpression": - return finish(t.objectExpression(path.get("properties").map(function (propPath) { - if (propPath.isObjectProperty()) { - return t.objectProperty(propPath.node.key, explodeViaTempVar(null, propPath.get("value")), propPath.node.computed); - } else { - return propPath.node; - } - }))); + if (offsetLine < lastOffset.line || + (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) { + throw new Error('Section offsets must be ordered and non-overlapping.'); + } + lastOffset = offset; - case "ArrayExpression": - return finish(t.arrayExpression(path.get("elements").map(function (elemPath) { - return explodeViaTempVar(null, elemPath); - }))); + 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')) + } + }); +} - case "SequenceExpression": - var lastIndex = expr.expressions.length - 1; - path.get("expressions").forEach(function (exprPath) { - if (exprPath.key === lastIndex) { - result = self.explodeExpression(exprPath, ignoreResult); - } else { - self.explodeExpression(exprPath, true); +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); }); - return result; + var section = this._sections[sectionIndex]; - case "LogicalExpression": - after = this.loc(); + if (!section) { + return { + source: null, + line: null, + column: null, + name: null + }; + } - if (!ignoreResult) { - result = self.makeTempVar(); - } + 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 + }); + }; - var left = explodeViaTempVar(result, path.get("left")); +/** + * 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(); + }); + }; - if (expr.operator === "&&") { - self.jumpIfNot(left, after); - } else { - _assert["default"].strictEqual(expr.operator, "||"); +/** + * 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]; - self.jumpIf(left, after); + 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.'); + } + }; - explodeViaTempVar(result, path.get("right"), ignoreResult); - self.mark(after); - return result; - - case "ConditionalExpression": - var elseLoc = this.loc(); - after = this.loc(); - var test = self.explodeExpression(path.get("test")); - self.jumpIfNot(test, elseLoc); +/** + * 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]; - if (!ignoreResult) { - result = self.makeTempVar(); + // 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; } + } - explodeViaTempVar(result, path.get("consequent"), ignoreResult); - self.jump(after); - self.mark(elseLoc); - explodeViaTempVar(result, path.get("alternate"), ignoreResult); - self.mark(after); - return result; + return { + line: null, + column: null + }; + }; - case "UnaryExpression": - return finish(t.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)); +/** + * 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]; - case "BinaryExpression": - return finish(t.binaryExpression(expr.operator, explodeViaTempVar(null, path.get("left")), explodeViaTempVar(null, path.get("right")))); + 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); - case "AssignmentExpression": - if (expr.operator === "=") { - // If this is a simple assignment, the left hand side does not need - // to be read before the right hand side is evaluated, so we can - // avoid the more complicated logic below. - return finish(t.assignmentExpression(expr.operator, self.explodeExpression(path.get("left")), self.explodeExpression(path.get("right")))); + 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); + } } + } - var lhs = self.explodeExpression(path.get("left")); - var temp = self.emitAssign(self.makeTempVar(), lhs); // For example, - // - // x += yield y - // - // becomes - // - // context.t0 = x - // x = context.t0 += yield y - // - // so that the left-hand side expression is read before the yield. - // Fixes https://github.com/facebook/regenerator/issues/345. + quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated); + quickSort(this.__originalMappings, util.compareByOriginalPositions); + }; - return finish(t.assignmentExpression("=", t.cloneDeep(lhs), t.assignmentExpression(expr.operator, t.cloneDeep(temp), self.explodeExpression(path.get("right"))))); +exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer; - case "UpdateExpression": - return finish(t.updateExpression(expr.operator, self.explodeExpression(path.get("argument")), expr.prefix)); +},{"./array-set":503,"./base64-vlq":504,"./binary-search":506,"./quick-sort":508,"./util":512}],510:[function(require,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 + */ - case "YieldExpression": - after = this.loc(); - var arg = expr.argument && self.explodeExpression(path.get("argument")); +var base64VLQ = require('./base64-vlq'); +var util = require('./util'); +var ArraySet = require('./array-set').ArraySet; +var MappingList = require('./mapping-list').MappingList; - if (arg && expr.delegate) { - var _result = self.makeTempVar(); +/** + * 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; +} - var _ret = t.returnStatement(t.callExpression(self.contextProperty("delegateYield"), [arg, t.stringLiteral(_result.property.name), after])); +SourceMapGenerator.prototype._version = 3; - _ret.loc = expr.loc; - self.emit(_ret); - self.mark(after); - return _result; +/** + * 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; + } } - self.emitAssign(self.contextProperty("next"), after); - var ret = t.returnStatement(t.cloneDeep(arg) || null); // Preserve the `yield` location so that source mappings for the statements - // link back to the yield properly. + generator.addMapping(newMapping); + }); + aSourceMapConsumer.sources.forEach(function (sourceFile) { + var content = aSourceMapConsumer.sourceContentFor(sourceFile); + if (content != null) { + generator.setSourceContent(sourceFile, content); + } + }); + return generator; + }; - ret.loc = expr.loc; - self.emit(ret); - self.mark(after); - return self.contextProperty("sent"); +/** + * 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); - default: - throw new Error("unknown Expression of type " + JSON.stringify(expr.type)); - } + if (!this._skipValidation) { + this._validateMapping(generated, original, source, name); + } + + if (source != null) { + source = String(source); + if (!this._sources.has(source)) { + this._sources.add(source); + } + } + + if (name != null) { + name = String(name); + if (!this._names.has(name)) { + this._names.add(name); + } + } + + this._mappings.add({ + generatedLine: generated.line, + generatedColumn: generated.column, + originalLine: original != null && original.line, + originalColumn: original != null && original.column, + source: source, + name: name + }); + }; + +/** + * Set the source content for a source file. + */ +SourceMapGenerator.prototype.setSourceContent = + function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) { + var source = aSourceFile; + if (this._sourceRoot != null) { + source = util.relative(this._sourceRoot, source); + } + + if (aSourceContent != null) { + // Add the source content to the _sourcesContents map. + // Create a new _sourcesContents map if the property is null. + if (!this._sourcesContents) { + this._sourcesContents = Object.create(null); + } + this._sourcesContents[util.toSetString(source)] = aSourceContent; + } else if (this._sourcesContents) { + // Remove the source file from the _sourcesContents map. + // If the _sourcesContents map is empty, set the property to null. + delete this._sourcesContents[util.toSetString(source)]; + if (Object.keys(this._sourcesContents).length === 0) { + this._sourcesContents = null; + } + } + }; + +/** + * Applies the mappings of a sub-source-map for a specific source file to the + * source map being generated. Each mapping to the supplied source file is + * rewritten using the supplied source map. Note: The resolution for the + * resulting mappings is the minimium of this map and the supplied map. + * + * @param aSourceMapConsumer The source map to be applied. + * @param aSourceFile Optional. The filename of the source file. + * If omitted, SourceMapConsumer's file property will be used. + * @param aSourceMapPath Optional. The dirname of the path to the source map + * to be applied. If relative, it is relative to the SourceMapConsumer. + * This parameter is needed when the two source maps aren't in the same + * directory, and the source map to be applied contains relative source + * paths. If so, those relative source paths need to be rewritten + * relative to the SourceMapGenerator. + */ +SourceMapGenerator.prototype.applySourceMap = + function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) { + var sourceFile = aSourceFile; + // If aSourceFile is omitted, we will use the file property of the SourceMap + if (aSourceFile == null) { + if (aSourceMapConsumer.file == null) { + throw new Error( + 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' + + 'or the source map\'s "file" property. Both were omitted.' + ); + } + sourceFile = aSourceMapConsumer.file; + } + var sourceRoot = this._sourceRoot; + // Make "sourceFile" relative if an absolute Url is passed. + if (sourceRoot != null) { + sourceFile = util.relative(sourceRoot, sourceFile); + } + // Applying the SourceMap can add and remove items from the sources and + // the names array. + var newSources = new ArraySet(); + var newNames = new ArraySet(); + + // Find mappings for the "sourceFile" + this._mappings.unsortedForEach(function (mapping) { + if (mapping.source === sourceFile && mapping.originalLine != null) { + // Check if it can be mapped by the source map, then update the mapping. + var original = aSourceMapConsumer.originalPositionFor({ + line: mapping.originalLine, + column: mapping.originalColumn + }); + if (original.source != null) { + // Copy mapping + mapping.source = original.source; + if (aSourceMapPath != null) { + mapping.source = util.join(aSourceMapPath, mapping.source) + } + if (sourceRoot != null) { + mapping.source = util.relative(sourceRoot, mapping.source); + } + mapping.originalLine = original.line; + mapping.originalColumn = original.column; + if (original.name != null) { + mapping.name = original.name; + } + } + } + + var source = mapping.source; + if (source != null && !newSources.has(source)) { + newSources.add(source); + } + + var name = mapping.name; + if (name != null && !newNames.has(name)) { + newNames.add(name); + } + + }, this); + this._sources = newSources; + this._names = newNames; + + // Copy sourcesContents of applied map. + aSourceMapConsumer.sources.forEach(function (sourceFile) { + var content = aSourceMapConsumer.sourceContentFor(sourceFile); + if (content != null) { + if (aSourceMapPath != null) { + sourceFile = util.join(aSourceMapPath, sourceFile); + } + if (sourceRoot != null) { + sourceFile = util.relative(sourceRoot, sourceFile); + } + this.setSourceContent(sourceFile, content); + } + }, this); + }; + +/** + * A mapping can have one of the three levels of data: + * + * 1. Just the generated position. + * 2. The Generated position, original position, and original source. + * 3. Generated and original position, original source, as well as a name + * token. + * + * To maintain consistency, we validate that any new mapping being added falls + * in to one of these categories. + */ +SourceMapGenerator.prototype._validateMapping = + function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource, + aName) { + // When aOriginal is truthy but has empty values for .line and .column, + // it is most likely a programmer error. In this case we throw a very + // specific error message to try to guide them the right way. + // For example: https://github.com/Polymer/polymer-bundler/pull/519 + if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') { + throw new Error( + 'original.line and original.column are not numbers -- you probably meant to omit ' + + 'the original mapping entirely and only map the generated position. If so, pass ' + + 'null for the original mapping instead of an object with empty or null values.' + ); + } + + if (aGenerated && 'line' in aGenerated && 'column' in aGenerated + && aGenerated.line > 0 && aGenerated.column >= 0 + && !aOriginal && !aSource && !aName) { + // Case 1. + return; + } + else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated + && aOriginal && 'line' in aOriginal && 'column' in aOriginal + && aGenerated.line > 0 && aGenerated.column >= 0 + && aOriginal.line > 0 && aOriginal.column >= 0 + && aSource) { + // Cases 2 and 3. + return; + } + else { + throw new Error('Invalid mapping: ' + JSON.stringify({ + generated: aGenerated, + source: aSource, + original: aOriginal, + name: aName + })); + } + }; + +/** + * Serialize the accumulated mappings in to the stream of base 64 VLQs + * specified by the source map format. + */ +SourceMapGenerator.prototype._serializeMappings = + function SourceMapGenerator_serializeMappings() { + var previousGeneratedColumn = 0; + var previousGeneratedLine = 1; + var previousOriginalColumn = 0; + var previousOriginalLine = 0; + var previousName = 0; + var previousSource = 0; + var result = ''; + var next; + var mapping; + var nameIdx; + var sourceIdx; + + var mappings = this._mappings.toArray(); + for (var i = 0, len = mappings.length; i < len; i++) { + mapping = mappings[i]; + next = '' + + if (mapping.generatedLine !== previousGeneratedLine) { + previousGeneratedColumn = 0; + while (mapping.generatedLine !== previousGeneratedLine) { + next += ';'; + previousGeneratedLine++; + } + } + else { + if (i > 0) { + if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) { + continue; + } + next += ','; + } + } + + next += base64VLQ.encode(mapping.generatedColumn + - previousGeneratedColumn); + previousGeneratedColumn = mapping.generatedColumn; + + if (mapping.source != null) { + sourceIdx = this._sources.indexOf(mapping.source); + next += base64VLQ.encode(sourceIdx - previousSource); + previousSource = sourceIdx; + + // lines are stored 0-based in SourceMap spec version 3 + next += base64VLQ.encode(mapping.originalLine - 1 + - previousOriginalLine); + previousOriginalLine = mapping.originalLine - 1; + + next += base64VLQ.encode(mapping.originalColumn + - previousOriginalColumn); + previousOriginalColumn = mapping.originalColumn; + + if (mapping.name != null) { + nameIdx = this._names.indexOf(mapping.name); + next += base64VLQ.encode(nameIdx - previousName); + previousName = nameIdx; + } + } + + result += next; + } + + return result; + }; + +SourceMapGenerator.prototype._generateSourcesContent = + function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) { + return aSources.map(function (source) { + if (!this._sourcesContents) { + return null; + } + if (aSourceRoot != null) { + source = util.relative(aSourceRoot, source); + } + var key = util.toSetString(source); + return Object.prototype.hasOwnProperty.call(this._sourcesContents, key) + ? this._sourcesContents[key] + : null; + }, this); + }; + +/** + * Externalize the source map. + */ +SourceMapGenerator.prototype.toJSON = + function SourceMapGenerator_toJSON() { + var map = { + version: this._version, + sources: this._sources.toArray(), + names: this._names.toArray(), + mappings: this._serializeMappings() + }; + if (this._file != null) { + map.file = this._file; + } + if (this._sourceRoot != null) { + map.sourceRoot = this._sourceRoot; + } + if (this._sourcesContents) { + map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot); + } + + return map; + }; + +/** + * Render the source map being generated to a string. + */ +SourceMapGenerator.prototype.toString = + function SourceMapGenerator_toString() { + return JSON.stringify(this.toJSON()); + }; + +exports.SourceMapGenerator = SourceMapGenerator; + +},{"./array-set":503,"./base64-vlq":504,"./mapping-list":507,"./util":512}],511:[function(require,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 = require('./source-map-generator').SourceMapGenerator; +var util = require('./util'); + +// Matches a Windows-style `\r\n` newline or a `\n` newline used by all other +// operating systems these days (capturing the result). +var REGEX_NEWLINE = /(\r?\n)/; + +// Newline character code for charCodeAt() comparisons +var NEWLINE_CODE = 10; + +// Private symbol for identifying `SourceNode`s when multiple versions of +// the source-map library are loaded. This MUST NOT CHANGE across +// versions! +var isSourceNode = "$$$isSourceNode$$$"; + +/** + * SourceNodes provide a way to abstract over interpolating/concatenating + * snippets of generated JavaScript source code while maintaining the line and + * column information associated with the original source code. + * + * @param aLine The original line number. + * @param aColumn The original column number. + * @param aSource The original source's filename. + * @param aChunks Optional. An array of strings which are snippets of + * generated JS, or other SourceNodes. + * @param aName The original identifier. + */ +function SourceNode(aLine, aColumn, aSource, aChunks, aName) { + this.children = []; + this.sourceContents = {}; + this.line = aLine == null ? null : aLine; + this.column = aColumn == null ? null : aColumn; + this.source = aSource == null ? null : aSource; + this.name = aName == null ? null : aName; + this[isSourceNode] = true; + if (aChunks != null) this.add(aChunks); +} + +/** + * Creates a SourceNode from generated code and a SourceMapConsumer. + * + * @param aGeneratedCode The generated code + * @param aSourceMapConsumer The SourceMap for the generated code + * @param aRelativePath Optional. The path that relative sources in the + * SourceMapConsumer should be relative to. + */ +SourceNode.fromStringWithSourceMap = + function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) { + // The SourceNode we want to fill with the generated code + // and the SourceMap + var node = new SourceNode(); + + // All even indices of this array are one line of the generated code, + // while all odd indices are the newlines between two adjacent lines + // (since `REGEX_NEWLINE` captures its match). + // Processed fragments are accessed by calling `shiftNextLine`. + var remainingLines = aGeneratedCode.split(REGEX_NEWLINE); + var remainingLinesIndex = 0; + var shiftNextLine = function() { + var lineContents = getNextLine(); + // The last line of a file might not have a newline. + var newLine = getNextLine() || ""; + return lineContents + newLine; + + function getNextLine() { + return remainingLinesIndex < remainingLines.length ? + remainingLines[remainingLinesIndex++] : undefined; + } + }; + + // We need to remember the position of "remainingLines" + var lastGeneratedLine = 1, lastGeneratedColumn = 0; + + // The generate SourceNodes we need a code range. + // To extract it current and last mapping is used. + // Here we store the last mapping. + var lastMapping = null; + + aSourceMapConsumer.eachMapping(function (mapping) { + if (lastMapping !== null) { + // We add the code from "lastMapping" to "mapping": + // First check if there is a new line in between. + if (lastGeneratedLine < mapping.generatedLine) { + // Associate first line with "lastMapping" + addMappingWithCode(lastMapping, shiftNextLine()); + lastGeneratedLine++; + lastGeneratedColumn = 0; + // The remaining code is added without mapping + } else { + // There is no new line in between. + // Associate the code between "lastGeneratedColumn" and + // "mapping.generatedColumn" with "lastMapping" + var nextLine = remainingLines[remainingLinesIndex]; + var code = nextLine.substr(0, mapping.generatedColumn - + lastGeneratedColumn); + remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn - + lastGeneratedColumn); + lastGeneratedColumn = mapping.generatedColumn; + addMappingWithCode(lastMapping, code); + // No more remaining code, continue + lastMapping = mapping; + return; + } + } + // We add the generated code until the first mapping + // to the SourceNode without any mapping. + // Each line is added as separate string. + while (lastGeneratedLine < mapping.generatedLine) { + node.add(shiftNextLine()); + lastGeneratedLine++; + } + if (lastGeneratedColumn < mapping.generatedColumn) { + var nextLine = remainingLines[remainingLinesIndex]; + node.add(nextLine.substr(0, mapping.generatedColumn)); + remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn); + lastGeneratedColumn = mapping.generatedColumn; + } + lastMapping = mapping; + }, this); + // We have processed all mappings. + if (remainingLinesIndex < remainingLines.length) { + if (lastMapping) { + // Associate the remaining code in the current line with "lastMapping" + addMappingWithCode(lastMapping, shiftNextLine()); + } + // and add the remaining lines without any mapping + node.add(remainingLines.splice(remainingLinesIndex).join("")); + } + + // Copy sourcesContent into SourceNode + aSourceMapConsumer.sources.forEach(function (sourceFile) { + var content = aSourceMapConsumer.sourceContentFor(sourceFile); + if (content != null) { + if (aRelativePath != null) { + sourceFile = util.join(aRelativePath, sourceFile); + } + node.setSourceContent(sourceFile, content); + } + }); + + return node; + + function addMappingWithCode(mapping, code) { + if (mapping === null || mapping.source === undefined) { + node.add(code); + } else { + var source = aRelativePath + ? util.join(aRelativePath, mapping.source) + : mapping.source; + node.add(new SourceNode(mapping.originalLine, + mapping.originalColumn, + source, + code, + mapping.name)); + } + } + }; + +/** + * Add a chunk of generated JS to this source node. + * + * @param aChunk A string snippet of generated JS code, another instance of + * SourceNode, or an array where each member is one of those things. + */ +SourceNode.prototype.add = function SourceNode_add(aChunk) { + if (Array.isArray(aChunk)) { + aChunk.forEach(function (chunk) { + this.add(chunk); + }, this); + } + else if (aChunk[isSourceNode] || typeof aChunk === "string") { + if (aChunk) { + this.children.push(aChunk); + } + } + else { + throw new TypeError( + "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk + ); + } + return this; }; -},{"./leap":512,"./meta":513,"./util":515,"assert":191}],510:[function(require,module,exports){ -"use strict"; -var util = _interopRequireWildcard(require("./util")); +/** + * 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; + +},{"./source-map-generator":510,"./util":512}],512:[function(require,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 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 ? '/' : '.'; + } -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } } + if (url) { + url.path = path; + return urlGenerate(url); + } + return path; +} +exports.normalize = normalize; /** - * Copyright (c) 2014-present, Facebook, Inc. + * Joins two paths/URLs. * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * @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. */ -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) { - var t = util.getTypes(); - t.assertFunction(funPath.node); - var vars = {}; - - function varDeclToExpr(_ref, includeIdentifiers) { - var vdec = _ref.node, - scope = _ref.scope; - 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); // Remove the binding, to avoid "duplicate declaration" errors when it will - // be injected again. - - scope.removeBinding(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); +function join(aRoot, aPath) { + if (aRoot === "") { + aRoot = "."; + } + if (aPath === "") { + aPath = "."; + } + var aPathUrl = urlParse(aPath); + var aRootUrl = urlParse(aRoot); + if (aRootUrl) { + aRoot = aRootUrl.path || '/'; } - funPath.get("body").traverse({ - VariableDeclaration: { - exit: function exit(path) { - var expr = varDeclToExpr(path, 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. - util.replaceWithOrRemove(path, t.expressionStatement(expr)); - } // Since the original node has been either removed or replaced, - // avoid traversing it any further. - + // `join(foo, '//www.example.org')` + if (aPathUrl && !aPathUrl.scheme) { + if (aRootUrl) { + aPathUrl.scheme = aRootUrl.scheme; + } + return urlGenerate(aPathUrl); + } - path.skip(); - } - }, - ForStatement: function ForStatement(path) { - var init = path.get("init"); + if (aPathUrl || aPath.match(dataUrlRegexp)) { + return aPath; + } - if (init.isVariableDeclaration()) { - util.replaceWithOrRemove(init, varDeclToExpr(init, false)); - } - }, - ForXStatement: function ForXStatement(path) { - var left = path.get("left"); + // `join('http://', 'www.example.com')` + if (aRootUrl && !aRootUrl.host && !aRootUrl.path) { + aRootUrl.host = aPath; + return urlGenerate(aRootUrl); + } - if (left.isVariableDeclaration()) { - util.replaceWithOrRemove(left, varDeclToExpr(left, true)); - } - }, - FunctionDeclaration: function FunctionDeclaration(path) { - var node = path.node; - vars[node.id.name] = node.id; - var assignment = t.expressionStatement(t.assignmentExpression("=", t.clone(node.id), t.functionExpression(path.scope.generateUidIdentifierBasedOnNode(node), node.params, node.body, node.generator, node.expression))); + var joined = aPath.charAt(0) === '/' + ? aPath + : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath); - 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. + if (aRootUrl) { + aRootUrl.path = joined; + return urlGenerate(aRootUrl); + } + return joined; +} +exports.join = join; - 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. - util.replaceWithOrRemove(path, assignment); - } // Remove the binding, to avoid "duplicate declaration" errors when it will - // be injected again. +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 = "."; + } - path.scope.removeBinding(node.id.name); // Don't hoist variables out of inner functions. + aRoot = aRoot.replace(/\/$/, ''); - path.skip(); - }, - FunctionExpression: function FunctionExpression(path) { - // Don't descend into nested function expressions. - path.skip(); - }, - ArrowFunctionExpression: function ArrowFunctionExpression(path) { - // Don't descend into nested function expressions. - path.skip(); + // 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; } - }); - 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 = []; - Object.keys(vars).forEach(function (name) { - if (!hasOwn.call(paramNames, name)) { - declarations.push(t.variableDeclarator(vars[name], null)); + // 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; } - }); - if (declarations.length === 0) { - return null; // Be sure to handle this case! + ++level; } - return t.variableDeclaration("var", declarations); -}; -},{"./util":515}],511:[function(require,module,exports){ -"use strict"; + // 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; -exports.__esModule = true; -exports["default"] = _default; +var supportsNullProto = (function () { + var obj = Object.create(null); + return !('__proto__' in obj); +}()); -var _visit = require("./visit"); +function identity (s) { + return s; +} /** - * Copyright (c) 2014-present, Facebook, Inc. + * Because behavior goes wacky when you set `__proto__` on objects, we + * have to prefix all the strings in our set with an arbitrary character. * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * See https://github.com/mozilla/source-map/pull/31 and + * https://github.com/mozilla/source-map/issues/30 + * + * @param String aStr */ -function _default(context) { - var plugin = { - visitor: (0, _visit.getVisitor)(context) - }; // Some presets manually call child presets, but fail to pass along the - // context object. Out of an abundance of caution, we verify that it - // exists first to avoid causing unnecessary breaking changes. - - var version = context && context.version; // The "name" property is not allowed in older versions of Babel (6.x) - // and will cause the plugin validator to throw an exception. - - if (version && parseInt(version, 10) >= 7) { - plugin.name = "regenerator-transform"; +function toSetString(aStr) { + if (isProtoString(aStr)) { + return '$' + aStr; } - return plugin; + return aStr; } -},{"./visit":516}],512:[function(require,module,exports){ -"use strict"; - -var _assert = _interopRequireDefault(require("assert")); - -var _emit = require("./emit"); - -var _util = require("util"); - -var _util2 = require("./util"); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } +exports.toSetString = supportsNullProto ? identity : toSetString; -/** - * Copyright (c) 2014-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -function Entry() { - _assert["default"].ok(this instanceof Entry); -} +function fromSetString(aStr) { + if (isProtoString(aStr)) { + return aStr.slice(1); + } -function FunctionEntry(returnLoc) { - Entry.call(this); - (0, _util2.getTypes)().assertLiteral(returnLoc); - this.returnLoc = returnLoc; + return aStr; } +exports.fromSetString = supportsNullProto ? identity : fromSetString; -(0, _util.inherits)(FunctionEntry, Entry); -exports.FunctionEntry = FunctionEntry; +function isProtoString(s) { + if (!s) { + return false; + } -function LoopEntry(breakLoc, continueLoc, label) { - Entry.call(this); - var t = (0, _util2.getTypes)(); - t.assertLiteral(breakLoc); - t.assertLiteral(continueLoc); + var length = s.length; - if (label) { - t.assertIdentifier(label); - } else { - label = null; + if (length < 9 /* "__proto__".length */) { + return false; } - this.breakLoc = breakLoc; - this.continueLoc = continueLoc; - this.label = label; -} + 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; + } -(0, _util.inherits)(LoopEntry, Entry); -exports.LoopEntry = LoopEntry; + for (var i = length - 10; i >= 0; i--) { + if (s.charCodeAt(i) !== 36 /* '$' */) { + return false; + } + } -function SwitchEntry(breakLoc) { - Entry.call(this); - (0, _util2.getTypes)().assertLiteral(breakLoc); - this.breakLoc = breakLoc; + return true; } -(0, _util.inherits)(SwitchEntry, Entry); -exports.SwitchEntry = SwitchEntry; - -function TryEntry(firstLoc, catchEntry, finallyEntry) { - Entry.call(this); - var t = (0, _util2.getTypes)(); - t.assertLiteral(firstLoc); +/** + * 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; + } - if (catchEntry) { - _assert["default"].ok(catchEntry instanceof CatchEntry); - } else { - catchEntry = null; + cmp = mappingA.originalLine - mappingB.originalLine; + if (cmp !== 0) { + return cmp; } - if (finallyEntry) { - _assert["default"].ok(finallyEntry instanceof FinallyEntry); - } else { - finallyEntry = null; - } // Have to have one or the other (or both). + cmp = mappingA.originalColumn - mappingB.originalColumn; + if (cmp !== 0 || onlyCompareOriginal) { + return cmp; + } + cmp = mappingA.generatedColumn - mappingB.generatedColumn; + if (cmp !== 0) { + return cmp; + } - _assert["default"].ok(catchEntry || finallyEntry); + cmp = mappingA.generatedLine - mappingB.generatedLine; + if (cmp !== 0) { + return cmp; + } - this.firstLoc = firstLoc; - this.catchEntry = catchEntry; - this.finallyEntry = finallyEntry; + return mappingA.name - mappingB.name; } +exports.compareByOriginalPositions = compareByOriginalPositions; -(0, _util.inherits)(TryEntry, Entry); -exports.TryEntry = TryEntry; +/** + * 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; + } -function CatchEntry(firstLoc, paramId) { - Entry.call(this); - var t = (0, _util2.getTypes)(); - t.assertLiteral(firstLoc); - t.assertIdentifier(paramId); - this.firstLoc = firstLoc; - this.paramId = paramId; -} + cmp = mappingA.generatedColumn - mappingB.generatedColumn; + if (cmp !== 0 || onlyCompareGenerated) { + return cmp; + } -(0, _util.inherits)(CatchEntry, Entry); -exports.CatchEntry = CatchEntry; + cmp = mappingA.source - mappingB.source; + if (cmp !== 0) { + return cmp; + } -function FinallyEntry(firstLoc, afterLoc) { - Entry.call(this); - var t = (0, _util2.getTypes)(); - t.assertLiteral(firstLoc); - t.assertLiteral(afterLoc); - this.firstLoc = firstLoc; - this.afterLoc = afterLoc; -} + cmp = mappingA.originalLine - mappingB.originalLine; + if (cmp !== 0) { + return cmp; + } -(0, _util.inherits)(FinallyEntry, Entry); -exports.FinallyEntry = FinallyEntry; + cmp = mappingA.originalColumn - mappingB.originalColumn; + if (cmp !== 0) { + return cmp; + } -function LabeledEntry(breakLoc, label) { - Entry.call(this); - var t = (0, _util2.getTypes)(); - t.assertLiteral(breakLoc); - t.assertIdentifier(label); - this.breakLoc = breakLoc; - this.label = label; + return mappingA.name - mappingB.name; } +exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated; -(0, _util.inherits)(LabeledEntry, Entry); -exports.LabeledEntry = LabeledEntry; - -function LeapManager(emitter) { - _assert["default"].ok(this instanceof LeapManager); +function strcmp(aStr1, aStr2) { + if (aStr1 === aStr2) { + return 0; + } - _assert["default"].ok(emitter instanceof _emit.Emitter); + if (aStr1 > aStr2) { + return 1; + } - this.emitter = emitter; - this.entryStack = [new FunctionEntry(emitter.finalLoc)]; + return -1; } -var LMp = LeapManager.prototype; -exports.LeapManager = LeapManager; - -LMp.withEntry = function (entry, callback) { - _assert["default"].ok(entry instanceof Entry); - - this.entryStack.push(entry); +/** + * 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; + } - try { - callback.call(this.emitter); - } finally { - var popped = this.entryStack.pop(); + cmp = mappingA.generatedColumn - mappingB.generatedColumn; + if (cmp !== 0) { + return cmp; + } - _assert["default"].strictEqual(popped, entry); + cmp = strcmp(mappingA.source, mappingB.source); + if (cmp !== 0) { + return cmp; } -}; -LMp._findLeapLocation = function (property, label) { - for (var i = this.entryStack.length - 1; i >= 0; --i) { - var entry = this.entryStack[i]; - var loc = entry[property]; + cmp = mappingA.originalLine - mappingB.originalLine; + if (cmp !== 0) { + return cmp; + } - 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; - } - } + cmp = mappingA.originalColumn - mappingB.originalColumn; + if (cmp !== 0) { + return cmp; } - return null; -}; + return strcmp(mappingA.name, mappingB.name); +} +exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated; -LMp.getBreakLoc = function (label) { - return this._findLeapLocation("breakLoc", label); -}; +},{}],513:[function(require,module,exports){ +arguments[4][489][0].apply(exports,arguments) +},{"./lib/source-map-consumer":509,"./lib/source-map-generator":510,"./lib/source-node":511,"dup":489}],514:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. -LMp.getContinueLoc = function (label) { - return this._findLeapLocation("continueLoc", label); -}; -},{"./emit":509,"./util":515,"assert":191,"util":505}],513:[function(require,module,exports){ -"use strict"; +module.exports = Stream; -var _assert = _interopRequireDefault(require("assert")); +var EE = require('events').EventEmitter; +var inherits = require('inherits'); -var _util = require("./util.js"); +inherits(Stream, EE); +Stream.Readable = require('readable-stream/readable.js'); +Stream.Writable = require('readable-stream/writable.js'); +Stream.Duplex = require('readable-stream/duplex.js'); +Stream.Transform = require('readable-stream/transform.js'); +Stream.PassThrough = require('readable-stream/passthrough.js'); -var _private = require("private"); +// Backwards-compat with node 0.4.x +Stream.Stream = Stream; -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } -/** - * Copyright (c) 2014-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -var m = (0, _private.makeAccessor)(); -var hasOwn = Object.prototype.hasOwnProperty; -function makePredicate(propertyName, knownTypes) { - function onlyChildren(node) { - var t = (0, _util.getTypes)(); - t.assertNode(node); // Assume no side effects until we find out otherwise. +// old-style streams. Note that the pipe method (the only relevant +// part of this class) is overridden in the Readable class. - var result = false; +function Stream() { + EE.call(this); +} - function check(child) { - if (result) {// Do nothing. - } else if (Array.isArray(child)) { - child.some(check); - } else if (t.isNode(child)) { - _assert["default"].strictEqual(result, false); +Stream.prototype.pipe = function(dest, options) { + var source = this; - result = predicate(child); + function ondata(chunk) { + if (dest.writable) { + if (false === dest.write(chunk) && source.pause) { + source.pause(); } - - return result; } + } - var keys = t.VISITOR_KEYS[node.type]; + source.on('data', ondata); - if (keys) { - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - var child = node[key]; - check(child); - } + function ondrain() { + if (source.readable && source.resume) { + source.resume(); } + } - return result; + dest.on('drain', ondrain); + + // If the 'end' option is not supplied, dest.end() will be called when + // source gets the 'end' or 'close' events. Only dest.end() once. + if (!dest._isStdio && (!options || options.end !== false)) { + source.on('end', onend); + source.on('close', onclose); } - function predicate(node) { - (0, _util.getTypes)().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. + var didOnEnd = false; + function onend() { + if (didOnEnd) return; + didOnEnd = true; - 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); + dest.end(); } - 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. + function onclose() { + if (didOnEnd) return; + didOnEnd = true; -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. + if (typeof dest.destroy === 'function') dest.destroy(); + } -}; // These types are the direct cause of all leaps in control flow. + // don't leave dangling pipes when there are errors. + function onerror(er) { + cleanup(); + if (EE.listenerCount(this, 'error') === 0) { + throw er; // Unhandled stream error in pipe. + } + } -var leapTypes = { - YieldExpression: true, - BreakStatement: true, - ContinueStatement: true, - ReturnStatement: true, - ThrowStatement: true -}; // All leap types are also side effect types. + source.on('error', onerror); + dest.on('error', onerror); -for (var type in leapTypes) { - if (hasOwn.call(leapTypes, type)) { - sideEffectTypes[type] = leapTypes[type]; + // remove all the event listeners that were added. + function cleanup() { + source.removeListener('data', ondata); + dest.removeListener('drain', ondrain); + + source.removeListener('end', onend); + source.removeListener('close', onclose); + + source.removeListener('error', onerror); + dest.removeListener('error', onerror); + + source.removeListener('end', cleanup); + source.removeListener('close', cleanup); + + dest.removeListener('close', cleanup); } -} -exports.hasSideEffects = makePredicate("hasSideEffects", sideEffectTypes); -exports.containsLeap = makePredicate("containsLeap", leapTypes); -},{"./util.js":515,"assert":191,"private":424}],514:[function(require,module,exports){ -"use strict"; + source.on('end', cleanup); + source.on('close', cleanup); -exports.__esModule = true; -exports["default"] = replaceShorthandObjectMethod; + dest.on('close', cleanup); -var util = _interopRequireWildcard(require("./util")); + dest.emit('pipe', source); -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } } + // Allow for unix-like usage: A.pipe(B).pipe(C) + return dest; +}; -/** - * Copyright (c) 2014-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -// 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. +},{"events":219,"inherits":224,"readable-stream/duplex.js":434,"readable-stream/passthrough.js":443,"readable-stream/readable.js":444,"readable-stream/transform.js":445,"readable-stream/writable.js":446}],515:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. // -// 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) +// 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: // -// In either case, though, the caller can count on the fact that the return value -// is a Function AST node path. +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. // -// 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) { - var t = util.getTypes(); +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. - 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). +'use strict'; +/**/ - if (!t.isObjectMethod(path.node)) { - return path; - } // this function only replaces generators. +var Buffer = require('safe-buffer').Buffer; +/**/ +var isEncoding = Buffer.isEncoding || function (encoding) { + encoding = '' + encoding; + switch (encoding && encoding.toLowerCase()) { + case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw': + return true; + default: + return false; + } +}; - if (!path.node.generator) { - return path; +function _normalizeEncoding(enc) { + if (!enc) return 'utf8'; + var retried; + while (true) { + switch (enc) { + case 'utf8': + case 'utf-8': + return 'utf8'; + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return 'utf16le'; + case 'latin1': + case 'binary': + return 'latin1'; + case 'base64': + case 'ascii': + case 'hex': + return enc; + default: + if (retried) return; // undefined + enc = ('' + enc).toLowerCase(); + retried = true; + } } +}; - 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); - util.replaceWithOrRemove(path, 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. +// Do not cache `Buffer.isEncoding` when checking encoding names as some +// modules monkey-patch it to support additional encodings +function normalizeEncoding(enc) { + var nenc = _normalizeEncoding(enc); + if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc); + return nenc || enc; +} - return path.get("value"); +// StringDecoder provides an interface for efficiently splitting a series of +// buffers into a series of JS strings without breaking apart multi-byte +// characters. +exports.StringDecoder = StringDecoder; +function StringDecoder(encoding) { + this.encoding = normalizeEncoding(encoding); + var nb; + switch (this.encoding) { + case 'utf16le': + this.text = utf16Text; + this.end = utf16End; + nb = 4; + break; + case 'utf8': + this.fillLast = utf8FillLast; + nb = 4; + break; + case 'base64': + this.text = base64Text; + this.end = base64End; + nb = 3; + break; + default: + this.write = simpleWrite; + this.end = simpleEnd; + return; + } + this.lastNeed = 0; + this.lastTotal = 0; + this.lastChar = Buffer.allocUnsafe(nb); } -},{"./util":515}],515:[function(require,module,exports){ -"use strict"; -exports.__esModule = true; -exports.wrapWithTypes = wrapWithTypes; -exports.getTypes = getTypes; -exports.runtimeProperty = runtimeProperty; -exports.isReference = isReference; -exports.replaceWithOrRemove = replaceWithOrRemove; +StringDecoder.prototype.write = function (buf) { + if (buf.length === 0) return ''; + var r; + var i; + if (this.lastNeed) { + r = this.fillLast(buf); + if (r === undefined) return ''; + i = this.lastNeed; + this.lastNeed = 0; + } else { + i = 0; + } + if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i); + return r || ''; +}; -/** - * Copyright (c) 2014-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -var currentTypes = null; +StringDecoder.prototype.end = utf8End; -function wrapWithTypes(types, fn) { - return function () { - var oldTypes = currentTypes; - currentTypes = types; +// Returns only complete characters in a Buffer +StringDecoder.prototype.text = utf8Text; - try { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } +// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer +StringDecoder.prototype.fillLast = function (buf) { + if (this.lastNeed <= buf.length) { + buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed); + return this.lastChar.toString(this.encoding, 0, this.lastTotal); + } + buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length); + this.lastNeed -= buf.length; +}; - return fn.apply(this, args); - } finally { - currentTypes = oldTypes; +// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a +// continuation byte. If an invalid byte is detected, -2 is returned. +function utf8CheckByte(byte) { + if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4; + return byte >> 6 === 0x02 ? -1 : -2; +} + +// Checks at most 3 bytes at the end of a Buffer in order to detect an +// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4) +// needed to complete the UTF-8 character (if applicable) are returned. +function utf8CheckIncomplete(self, buf, i) { + var j = buf.length - 1; + if (j < i) return 0; + var nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) self.lastNeed = nb - 1; + return nb; + } + if (--j < i || nb === -2) return 0; + nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) self.lastNeed = nb - 2; + return nb; + } + if (--j < i || nb === -2) return 0; + nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) { + if (nb === 2) nb = 0;else self.lastNeed = nb - 3; } - }; + return nb; + } + return 0; } -function getTypes() { - return currentTypes; +// Validates as many continuation bytes for a multi-byte UTF-8 character as +// needed or are available. If we see a non-continuation byte where we expect +// one, we "replace" the validated continuation bytes we've seen so far with +// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding +// behavior. The continuation byte check is included three times in the case +// where all of the continuation bytes for a character exist in the same buffer. +// It is also done this way as a slight performance increase instead of using a +// loop. +function utf8CheckExtraBytes(self, buf, p) { + if ((buf[0] & 0xC0) !== 0x80) { + self.lastNeed = 0; + return '\ufffd'; + } + if (self.lastNeed > 1 && buf.length > 1) { + if ((buf[1] & 0xC0) !== 0x80) { + self.lastNeed = 1; + return '\ufffd'; + } + if (self.lastNeed > 2 && buf.length > 2) { + if ((buf[2] & 0xC0) !== 0x80) { + self.lastNeed = 2; + return '\ufffd'; + } + } + } } -function runtimeProperty(name) { - var t = getTypes(); - return t.memberExpression(t.identifier("regeneratorRuntime"), t.identifier(name), false); +// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer. +function utf8FillLast(buf) { + var p = this.lastTotal - this.lastNeed; + var r = utf8CheckExtraBytes(this, buf, p); + if (r !== undefined) return r; + if (this.lastNeed <= buf.length) { + buf.copy(this.lastChar, p, 0, this.lastNeed); + return this.lastChar.toString(this.encoding, 0, this.lastTotal); + } + buf.copy(this.lastChar, p, 0, buf.length); + this.lastNeed -= buf.length; } -function isReference(path) { - return path.isReferenced() || path.parentPath.isAssignmentExpression({ - left: path.node - }); +// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a +// partial character, the character's bytes are buffered until the required +// number of bytes are available. +function utf8Text(buf, i) { + var total = utf8CheckIncomplete(this, buf, i); + if (!this.lastNeed) return buf.toString('utf8', i); + this.lastTotal = total; + var end = buf.length - (total - this.lastNeed); + buf.copy(this.lastChar, 0, end); + return buf.toString('utf8', i, end); } -function replaceWithOrRemove(path, replacement) { - if (replacement) { - path.replaceWith(replacement); +// For UTF-8, a replacement character is added when ending on a partial +// character. +function utf8End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) return r + '\ufffd'; + return r; +} + +// UTF-16LE typically needs two bytes per character, but even if we have an even +// number of bytes available, we need to check if we end on a leading/high +// surrogate. In that case, we need to wait for the next two bytes in order to +// decode the last character properly. +function utf16Text(buf, i) { + if ((buf.length - i) % 2 === 0) { + var r = buf.toString('utf16le', i); + if (r) { + var c = r.charCodeAt(r.length - 1); + if (c >= 0xD800 && c <= 0xDBFF) { + this.lastNeed = 2; + this.lastTotal = 4; + this.lastChar[0] = buf[buf.length - 2]; + this.lastChar[1] = buf[buf.length - 1]; + return r.slice(0, -1); + } + } + return r; + } + this.lastNeed = 1; + this.lastTotal = 2; + this.lastChar[0] = buf[buf.length - 1]; + return buf.toString('utf16le', i, buf.length - 1); +} + +// For UTF-16LE we do not explicitly append special replacement characters if we +// end on a partial character, we simply let v8 handle that. +function utf16End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) { + var end = this.lastTotal - this.lastNeed; + return r + this.lastChar.toString('utf16le', 0, end); + } + return r; +} + +function base64Text(buf, i) { + var n = (buf.length - i) % 3; + if (n === 0) return buf.toString('base64', i); + this.lastNeed = 3 - n; + this.lastTotal = 3; + if (n === 1) { + this.lastChar[0] = buf[buf.length - 1]; } else { - path.remove(); + this.lastChar[0] = buf[buf.length - 2]; + this.lastChar[1] = buf[buf.length - 1]; } + return buf.toString('base64', i, buf.length - n); } -},{}],516:[function(require,module,exports){ -/** - * Copyright (c) 2014-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -"use strict"; - -var _assert = _interopRequireDefault(require("assert")); - -var _hoist = require("./hoist"); - -var _emit = require("./emit"); -var _replaceShorthandObjectMethod = _interopRequireDefault(require("./replaceShorthandObjectMethod")); - -var util = _interopRequireWildcard(require("./util")); - -var _private = require("private"); - -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)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } } +function base64End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed); + return r; +} -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } +// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex) +function simpleWrite(buf) { + return buf.toString(this.encoding); +} -exports.getVisitor = function (_ref) { - var t = _ref.types; - return { - Method: function Method(path, state) { - var node = path.node; - if (!shouldRegenerate(node, state)) return; - var container = t.functionExpression(null, [], t.cloneNode(node.body, false), node.generator, node.async); - path.get("body").set("body", [t.returnStatement(t.callExpression(container, []))]); // Regardless of whether or not the wrapped function is a an async method - // or generator the outer function should not be +function simpleEnd(buf) { + return buf && buf.length ? this.write(buf) : ''; +} +},{"safe-buffer":502}],516:[function(require,module,exports){ +'use strict'; +module.exports = { + stdout: false, + stderr: false +}; - node.async = false; - node.generator = false; // Unwrap the wrapper IIFE's environment so super and this and such still work. +},{}],517:[function(require,module,exports){ +(function (process){ +var Stream = require('stream') - path.get("body.body.0.argument.callee").unwrapFunctionEnvironment(); - }, - Function: { - exit: util.wrapWithTypes(t, function (path, state) { - var node = path.node; - if (!shouldRegenerate(node, state)) return; // if this is an ObjectMethod, we need to convert it to an ObjectProperty +// through +// +// a stream that does nothing but re-emit the input. +// useful for aggregating a series of changing but not ending streams into one stream) - path = (0, _replaceShorthandObjectMethod["default"])(path); - node = path.node; - var contextId = path.scope.generateUidIdentifier("context"); - var argsId = path.scope.generateUidIdentifier("args"); - path.ensureBlock(); - var bodyBlockPath = path.get("body"); +exports = module.exports = through +through.through = through - if (node.async) { - bodyBlockPath.traverse(awaitVisitor); - } +//create a readable writable stream. - bodyBlockPath.traverse(functionSentVisitor, { - context: contextId - }); - var outerBody = []; - var innerBody = []; - bodyBlockPath.get("body").forEach(function (childPath) { - var node = childPath.node; +function through (write, end, opts) { + write = write || function (data) { this.queue(data) } + end = end || function () { this.queue(null) } - 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); - } - }); + var ended = false, destroyed = false, buffer = [], _ended = false + var stream = new Stream() + stream.readable = stream.writable = true + stream.paused = false - if (outerBody.length > 0) { - // Only replace the inner body if we actually hoisted any statements - // to the outer body. - bodyBlockPath.node.body = innerBody; - } +// stream.autoPause = !(opts && opts.autoPause === false) + stream.autoDestroy = !(opts && opts.autoDestroy === false) - 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. + stream.write = function (data) { + write.call(this, data) + return !stream.paused + } - 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. + function drain() { + while(buffer.length && !stream.paused) { + var data = buffer.shift() + if(null === data) + return stream.emit('end') + else + stream.emit('data', data) + } + } - var vars = (0, _hoist.hoist)(path); - var context = { - usesThis: false, - usesArguments: false, - getArgsId: function getArgsId() { - return t.clone(argsId); - } - }; - path.traverse(argumentsThisVisitor, context); + stream.queue = stream.push = function (data) { +// console.error(ended) + if(_ended) return stream + if(data === null) _ended = true + buffer.push(data) + drain() + return stream + } - if (context.usesArguments) { - vars = vars || t.variableDeclaration("var", []); - var argumentIdentifier = t.identifier("arguments"); // we need to do this as otherwise arguments in arrow functions gets hoisted + //this will be registered as the first 'end' listener + //must call destroy next tick, to make sure we're after any + //stream piped from here. + //this is only a problem if end is not emitted synchronously. + //a nicer way to do this is to make sure this is the last listener for 'end' - argumentIdentifier._shadowedFunctionLiteral = path; - vars.declarations.push(t.variableDeclarator(t.clone(argsId), argumentIdentifier)); - } + stream.on('end', function () { + stream.readable = false + if(!stream.writable && stream.autoDestroy) + process.nextTick(function () { + stream.destroy() + }) + }) - var emitter = new _emit.Emitter(contextId); - emitter.explode(path.get("body")); + function _end () { + stream.writable = false + end.call(stream) + if(!stream.readable && stream.autoDestroy) + stream.destroy() + } - if (vars && vars.declarations.length > 0) { - outerBody.push(vars); - } + stream.end = function (data) { + if(ended) return + ended = true + if(arguments.length) stream.write(data) + _end() // will emit or queue + return stream + } - var wrapArgs = [emitter.getContextFunction(innerFnId)]; - var tryLocsList = emitter.getTryLocsList(); + stream.destroy = function () { + if(destroyed) return + destroyed = true + ended = true + buffer.length = 0 + stream.writable = stream.readable = false + stream.emit('close') + return stream + } - if (node.generator) { - wrapArgs.push(outerFnExpr); - } else if (context.usesThis || tryLocsList) { - // 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. - wrapArgs.push(t.nullLiteral()); - } + stream.pause = function () { + if(stream.paused) return + stream.paused = true + return stream + } - if (context.usesThis) { - wrapArgs.push(t.thisExpression()); - } else if (tryLocsList) { - wrapArgs.push(t.nullLiteral()); - } + stream.resume = function () { + if(stream.paused) { + stream.paused = false + stream.emit('resume') + } + drain() + //may have become paused again, + //as drain emits 'data'. + if(!stream.paused) + stream.emit('drain') + return stream + } + return stream +} - 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; +}).call(this,require('_process')) +},{"_process":433,"stream":514}],518:[function(require,module,exports){ +(function (setImmediate,clearImmediate){ +var nextTick = require('process/browser.js').nextTick; +var apply = Function.prototype.apply; +var slice = Array.prototype.slice; +var immediateIds = {}; +var nextImmediateId = 0; - if (oldDirectives) { - // Babylon represents directives like "use strict" as elements of - // a bodyBlockPath.node.directives array. (#248) - node.body.directives = oldDirectives; - } +// DOM APIs, for completeness - var wasGeneratorFunction = node.generator; +exports.setTimeout = function() { + return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout); +}; +exports.setInterval = function() { + return new Timeout(apply.call(setInterval, window, arguments), clearInterval); +}; +exports.clearTimeout = +exports.clearInterval = function(timeout) { timeout.close(); }; - if (wasGeneratorFunction) { - node.generator = false; - } +function Timeout(id, clearFn) { + this._id = id; + this._clearFn = clearFn; +} +Timeout.prototype.unref = Timeout.prototype.ref = function() {}; +Timeout.prototype.close = function() { + this._clearFn.call(window, this._id); +}; - if (node.async) { - node.async = false; - } +// Does not start the time, just sets up the members needed. +exports.enroll = function(item, msecs) { + clearTimeout(item._idleTimeoutId); + item._idleTimeout = msecs; +}; - if (wasGeneratorFunction && t.isExpression(node)) { - util.replaceWithOrRemove(path, t.callExpression(util.runtimeProperty("mark"), [node])); - path.addComment("leading", "#__PURE__"); - } +exports.unenroll = function(item) { + clearTimeout(item._idleTimeoutId); + item._idleTimeout = -1; +}; - var insertedLocs = emitter.getInsertedLocs(); - path.traverse({ - NumericLiteral: function NumericLiteral(path) { - if (!insertedLocs.has(path.node)) { - return; - } +exports._unrefActive = exports.active = function(item) { + clearTimeout(item._idleTimeoutId); - path.replaceWith(t.numericLiteral(path.node.value)); - } - }); // 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. + var msecs = item._idleTimeout; + if (msecs >= 0) { + item._idleTimeoutId = setTimeout(function onTimeout() { + if (item._onTimeout) + item._onTimeout(); + }, msecs); + } +}; - path.requeue(); - }) - } - }; -}; // Check if a node should be transformed by regenerator +// That's not how node.js implements it but the exposed api is the same. +exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) { + var id = nextImmediateId++; + var args = arguments.length < 2 ? false : slice.call(arguments, 1); + immediateIds[id] = true; -function shouldRegenerate(node, state) { - if (node.generator) { - if (node.async) { - // Async generator - return state.opts.asyncGenerators !== false; - } else { - // Plain generator - return state.opts.generators !== false; + nextTick(function onNextTick() { + if (immediateIds[id]) { + // fn.call() is faster so we optimize for the common use-case + // @see http://jsperf.com/call-apply-segu + if (args) { + fn.apply(null, args); + } else { + fn.call(null); + } + // Prevent ids from leaking + exports.clearImmediate(id); } - } else if (node.async) { - // Async function - return state.opts.async !== false; - } else { - // Not a generator or async function. - return false; - } -} // 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 t = util.getTypes(); - var node = funPath.node; - t.assertFunction(node); + return id; +}; - 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"); - } +exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) { + delete immediateIds[id]; +}; +}).call(this,require("timers").setImmediate,require("timers").clearImmediate) +},{"process/browser.js":433,"timers":518}],519:[function(require,module,exports){ +'use strict'; - if (node.generator && // Non-generator functions don't need to be marked. - t.isFunctionDeclaration(node)) { - // Return the identifier returned by runtime.mark(). - return getMarkedFunctionId(funPath); - } +let fastProto = null; - return t.clone(node.id); +// Creates an object with permanently fast properties in V8. See Toon Verwaest's +// post https://medium.com/@tverwaes/setting-up-prototypes-in-v8-ec9c9491dfe2#5f62 +// for more details. Use %HasFastProperties(object) and the Node.js flag +// --allow-natives-syntax to check whether an object has fast properties. +function FastObject(o) { + // A prototype object will have "fast properties" enabled once it is checked + // against the inline property cache of a function, e.g. fastProto.property: + // https://github.com/v8/v8/blob/6.0.122/test/mjsunit/fast-prototype.js#L48-L63 + if (fastProto !== null && typeof fastProto.property) { + const result = fastProto; + fastProto = FastObject.prototype = null; + return result; + } + fastProto = FastObject.prototype = o == null ? Object.create(null) : o; + return new FastObject; } -var getMarkInfo = (0, _private.makeAccessor)(); +// Initialize the inline property cache of FastObject +FastObject(); -function getMarkedFunctionId(funPath) { - var t = util.getTypes(); - var node = funPath.node; - t.assertIdentifier(node.id); - var blockPath = funPath.findParent(function (path) { - return path.isProgram() || path.isBlockStatement(); - }); +module.exports = function toFastproperties(o) { + return FastObject(o); +}; - if (!blockPath) { - return node.id; - } +},{}],520:[function(require,module,exports){ +(function (global){ - var block = blockPath.node; +/** + * Module exports. + */ - _assert["default"].ok(Array.isArray(block.body)); +module.exports = deprecate; - var info = getMarkInfo(block); +/** + * Mark that a method should not be used. + * Returns a modified function which warns once by default. + * + * If `localStorage.noDeprecation = true` is set, then it is a no-op. + * + * If `localStorage.throwDeprecation = true` is set, then deprecated functions + * will throw an Error when invoked. + * + * If `localStorage.traceDeprecation = true` is set, then deprecated functions + * will invoke `console.trace()` instead of `console.error()`. + * + * @param {Function} fn - the function to deprecate + * @param {String} msg - the string to print to the console when `fn` is invoked + * @returns {Function} a new "deprecated" version of `fn` + * @api public + */ - if (!info.decl) { - info.decl = t.variableDeclaration("var", []); - blockPath.unshiftContainer("body", info.decl); - info.declPath = blockPath.get("body.0"); +function deprecate (fn, msg) { + if (config('noDeprecation')) { + return fn; } - _assert["default"].strictEqual(info.declPath.node, info.decl); // Get a new unique identifier for our marked variable. - - - var markedId = blockPath.scope.generateUidIdentifier("marked"); - var markCallExp = t.callExpression(util.runtimeProperty("mark"), [t.clone(node.id)]); - var index = info.decl.declarations.push(t.variableDeclarator(markedId, markCallExp)) - 1; - var markCallExpPath = info.declPath.get("declarations." + index + ".init"); - - _assert["default"].strictEqual(markCallExpPath.node, markCallExp); - - markCallExpPath.addComment("leading", "#__PURE__"); - return t.clone(markedId); -} - -var argumentsThisVisitor = { - "FunctionExpression|FunctionDeclaration|Method": function FunctionExpressionFunctionDeclarationMethod(path) { - path.skip(); - }, - Identifier: function Identifier(path, state) { - if (path.node.name === "arguments" && util.isReference(path)) { - util.replaceWithOrRemove(path, state.getArgsId()); - state.usesArguments = true; + var warned = false; + function deprecated() { + if (!warned) { + if (config('throwDeprecation')) { + throw new Error(msg); + } else if (config('traceDeprecation')) { + console.trace(msg); + } else { + console.warn(msg); + } + warned = true; } - }, - ThisExpression: function ThisExpression(path, state) { - state.usesThis = true; + return fn.apply(this, arguments); } -}; -var functionSentVisitor = { - MetaProperty: function MetaProperty(path) { - var node = path.node; - if (node.meta.name === "function" && node.property.name === "sent") { - var t = util.getTypes(); - util.replaceWithOrRemove(path, t.memberExpression(t.clone(this.context), t.identifier("_sent"))); - } - } -}; -var awaitVisitor = { - Function: function Function(path) { - path.skip(); // Don't descend into nested function scopes. - }, - AwaitExpression: function AwaitExpression(path) { - var t = util.getTypes(); // Convert await expressions to yield expressions. + return deprecated; +} - 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. +/** + * Checks `localStorage` for boolean values for the given `name`. + * + * @param {String} name + * @returns {Boolean} + * @api private + */ - util.replaceWithOrRemove(path, t.yieldExpression(t.callExpression(util.runtimeProperty("awrap"), [argument]), false)); +function config (name) { + // accessing global.localStorage can trigger a DOMException in sandboxed iframes + try { + if (!global.localStorage) return false; + } catch (_) { + return false; } -}; -},{"./emit":509,"./hoist":510,"./replaceShorthandObjectMethod":514,"./util":515,"assert":191,"private":424}]},{},[3])(3) + var val = global.localStorage[name]; + if (null == val) return false; + return String(val).toLowerCase() === 'true'; +} + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],521:[function(require,module,exports){ +arguments[4][197][0].apply(exports,arguments) +},{"dup":197}],522:[function(require,module,exports){ +arguments[4][198][0].apply(exports,arguments) +},{"dup":198}],523:[function(require,module,exports){ +arguments[4][199][0].apply(exports,arguments) +},{"./support/isBuffer":522,"_process":433,"dup":199,"inherits":521}]},{},[3])(3) });