UNPKG

@babel/core

Version:
2,008 lines (1,596 loc) 94.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.moduleResolve = moduleResolve; exports.resolve = resolve; function _url() { const data = require("url"); _url = function () { return data; }; return data; } function _fs() { const data = _interopRequireWildcard(require("fs"), true); _fs = function () { return data; }; return data; } function _path() { const data = require("path"); _path = function () { return data; }; return data; } function _assert() { const data = require("assert"); _assert = function () { return data; }; return data; } function _util() { const data = require("util"); _util = function () { return data; }; return data; } function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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 asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } var re$3 = { exports: {} }; const SEMVER_SPEC_VERSION = '2.0.0'; const MAX_LENGTH$2 = 256; const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER || 9007199254740991; const MAX_SAFE_COMPONENT_LENGTH = 16; var constants = { SEMVER_SPEC_VERSION, MAX_LENGTH: MAX_LENGTH$2, MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1, MAX_SAFE_COMPONENT_LENGTH }; const debug$1 = typeof process === 'object' && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error('SEMVER', ...args) : () => {}; var debug_1 = debug$1; (function (module, exports) { const { MAX_SAFE_COMPONENT_LENGTH } = constants; const debug = debug_1; exports = module.exports = {}; const re = exports.re = []; const src = exports.src = []; const t = exports.t = {}; let R = 0; const createToken = (name, value, isGlobal) => { const index = R++; debug(index, value); t[name] = index; src[index] = value; re[index] = new RegExp(value, isGlobal ? 'g' : undefined); }; createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*'); createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+'); createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*'); createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` + `(${src[t.NUMERICIDENTIFIER]})\\.` + `(${src[t.NUMERICIDENTIFIER]})`); createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + `(${src[t.NUMERICIDENTIFIERLOOSE]})`); createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]}|${src[t.NONNUMERICIDENTIFIER]})`); createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]}|${src[t.NONNUMERICIDENTIFIER]})`); createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`); createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`); createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+'); createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`); createToken('FULLPLAIN', `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`); createToken('FULL', `^${src[t.FULLPLAIN]}$`); createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`); createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`); createToken('GTLT', '((?:<|>)?=?)'); createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`); createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`); createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + `(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?` + `)?)?`); createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?` + `)?)?`); createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`); createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`); createToken('COERCE', `${'(^|[^\\d])' + '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + `(?:$|[^\\d])`); createToken('COERCERTL', src[t.COERCE], true); createToken('LONETILDE', '(?:~>?)'); createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true); exports.tildeTrimReplace = '$1~'; createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`); createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`); createToken('LONECARET', '(?:\\^)'); createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true); exports.caretTrimReplace = '$1^'; createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`); createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`); createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`); createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`); createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true); exports.comparatorTrimReplace = '$1$2$3'; createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` + `\\s+-\\s+` + `(${src[t.XRANGEPLAIN]})` + `\\s*$`); createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + `\\s+-\\s+` + `(${src[t.XRANGEPLAINLOOSE]})` + `\\s*$`); createToken('STAR', '(<|>)?=?\\s*\\*'); createToken('GTE0', '^\\s*>=\\s*0\.0\.0\\s*$'); createToken('GTE0PRE', '^\\s*>=\\s*0\.0\.0-0\\s*$'); })(re$3, re$3.exports); const opts = ['includePrerelease', 'loose', 'rtl']; const parseOptions$2 = options => !options ? {} : typeof options !== 'object' ? { loose: true } : opts.filter(k => options[k]).reduce((options, k) => { options[k] = true; return options; }, {}); var parseOptions_1 = parseOptions$2; const numeric = /^[0-9]+$/; const compareIdentifiers$1 = (a, b) => { const anum = numeric.test(a); const bnum = numeric.test(b); if (anum && bnum) { a = +a; b = +b; } return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1; }; const rcompareIdentifiers = (a, b) => compareIdentifiers$1(b, a); var identifiers = { compareIdentifiers: compareIdentifiers$1, rcompareIdentifiers }; const debug = debug_1; const { MAX_LENGTH: MAX_LENGTH$1, MAX_SAFE_INTEGER } = constants; const { re: re$2, t: t$2 } = re$3.exports; const parseOptions$1 = parseOptions_1; const { compareIdentifiers } = identifiers; class SemVer$c { constructor(version, options) { options = parseOptions$1(options); if (version instanceof SemVer$c) { if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) { return version; } else { version = version.version; } } else if (typeof version !== 'string') { throw new TypeError(`Invalid Version: ${version}`); } if (version.length > MAX_LENGTH$1) { throw new TypeError(`version is longer than ${MAX_LENGTH$1} characters`); } debug('SemVer', version, options); this.options = options; this.loose = !!options.loose; this.includePrerelease = !!options.includePrerelease; const m = version.trim().match(options.loose ? re$2[t$2.LOOSE] : re$2[t$2.FULL]); if (!m) { throw new TypeError(`Invalid Version: ${version}`); } this.raw = version; this.major = +m[1]; this.minor = +m[2]; this.patch = +m[3]; if (this.major > MAX_SAFE_INTEGER || this.major < 0) { throw new TypeError('Invalid major version'); } if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { throw new TypeError('Invalid minor version'); } if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { throw new TypeError('Invalid patch version'); } if (!m[4]) { this.prerelease = []; } else { this.prerelease = m[4].split('.').map(id => { if (/^[0-9]+$/.test(id)) { const num = +id; if (num >= 0 && num < MAX_SAFE_INTEGER) { return num; } } return id; }); } this.build = m[5] ? m[5].split('.') : []; this.format(); } format() { this.version = `${this.major}.${this.minor}.${this.patch}`; if (this.prerelease.length) { this.version += `-${this.prerelease.join('.')}`; } return this.version; } toString() { return this.version; } compare(other) { debug('SemVer.compare', this.version, this.options, other); if (!(other instanceof SemVer$c)) { if (typeof other === 'string' && other === this.version) { return 0; } other = new SemVer$c(other, this.options); } if (other.version === this.version) { return 0; } return this.compareMain(other) || this.comparePre(other); } compareMain(other) { if (!(other instanceof SemVer$c)) { other = new SemVer$c(other, this.options); } return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch); } comparePre(other) { if (!(other instanceof SemVer$c)) { other = new SemVer$c(other, this.options); } if (this.prerelease.length && !other.prerelease.length) { return -1; } else if (!this.prerelease.length && other.prerelease.length) { return 1; } else if (!this.prerelease.length && !other.prerelease.length) { return 0; } let i = 0; do { const a = this.prerelease[i]; const b = other.prerelease[i]; debug('prerelease compare', i, a, b); if (a === undefined && b === undefined) { return 0; } else if (b === undefined) { return 1; } else if (a === undefined) { return -1; } else if (a === b) { continue; } else { return compareIdentifiers(a, b); } } while (++i); } compareBuild(other) { if (!(other instanceof SemVer$c)) { other = new SemVer$c(other, this.options); } let i = 0; do { const a = this.build[i]; const b = other.build[i]; debug('prerelease compare', i, a, b); if (a === undefined && b === undefined) { return 0; } else if (b === undefined) { return 1; } else if (a === undefined) { return -1; } else if (a === b) { continue; } else { return compareIdentifiers(a, b); } } while (++i); } inc(release, identifier) { switch (release) { case 'premajor': this.prerelease.length = 0; this.patch = 0; this.minor = 0; this.major++; this.inc('pre', identifier); break; case 'preminor': this.prerelease.length = 0; this.patch = 0; this.minor++; this.inc('pre', identifier); break; case 'prepatch': this.prerelease.length = 0; this.inc('patch', identifier); this.inc('pre', identifier); break; case 'prerelease': if (this.prerelease.length === 0) { this.inc('patch', identifier); } this.inc('pre', identifier); break; case 'major': if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) { this.major++; } this.minor = 0; this.patch = 0; this.prerelease = []; break; case 'minor': if (this.patch !== 0 || this.prerelease.length === 0) { this.minor++; } this.patch = 0; this.prerelease = []; break; case 'patch': if (this.prerelease.length === 0) { this.patch++; } this.prerelease = []; break; case 'pre': if (this.prerelease.length === 0) { this.prerelease = [0]; } else { let i = this.prerelease.length; while (--i >= 0) { if (typeof this.prerelease[i] === 'number') { this.prerelease[i]++; i = -2; } } if (i === -1) { this.prerelease.push(0); } } if (identifier) { if (this.prerelease[0] === identifier) { if (isNaN(this.prerelease[1])) { this.prerelease = [identifier, 0]; } } else { this.prerelease = [identifier, 0]; } } break; default: throw new Error(`invalid increment argument: ${release}`); } this.format(); this.raw = this.version; return this; } } var semver$2 = SemVer$c; const { MAX_LENGTH } = constants; const { re: re$1, t: t$1 } = re$3.exports; const SemVer$b = semver$2; const parseOptions = parseOptions_1; const parse$5 = (version, options) => { options = parseOptions(options); if (version instanceof SemVer$b) { return version; } if (typeof version !== 'string') { return null; } if (version.length > MAX_LENGTH) { return null; } const r = options.loose ? re$1[t$1.LOOSE] : re$1[t$1.FULL]; if (!r.test(version)) { return null; } try { return new SemVer$b(version, options); } catch (er) { return null; } }; var parse_1 = parse$5; const parse$4 = parse_1; const valid$1 = (version, options) => { const v = parse$4(version, options); return v ? v.version : null; }; var valid_1 = valid$1; const parse$3 = parse_1; const clean = (version, options) => { const s = parse$3(version.trim().replace(/^[=v]+/, ''), options); return s ? s.version : null; }; var clean_1 = clean; const SemVer$a = semver$2; const inc = (version, release, options, identifier) => { if (typeof options === 'string') { identifier = options; options = undefined; } try { return new SemVer$a(version, options).inc(release, identifier).version; } catch (er) { return null; } }; var inc_1 = inc; const SemVer$9 = semver$2; const compare$a = (a, b, loose) => new SemVer$9(a, loose).compare(new SemVer$9(b, loose)); var compare_1 = compare$a; const compare$9 = compare_1; const eq$2 = (a, b, loose) => compare$9(a, b, loose) === 0; var eq_1 = eq$2; const parse$2 = parse_1; const eq$1 = eq_1; const diff = (version1, version2) => { if (eq$1(version1, version2)) { return null; } else { const v1 = parse$2(version1); const v2 = parse$2(version2); const hasPre = v1.prerelease.length || v2.prerelease.length; const prefix = hasPre ? 'pre' : ''; const defaultResult = hasPre ? 'prerelease' : ''; for (const key in v1) { if (key === 'major' || key === 'minor' || key === 'patch') { if (v1[key] !== v2[key]) { return prefix + key; } } } return defaultResult; } }; var diff_1 = diff; const SemVer$8 = semver$2; const major = (a, loose) => new SemVer$8(a, loose).major; var major_1 = major; const SemVer$7 = semver$2; const minor = (a, loose) => new SemVer$7(a, loose).minor; var minor_1 = minor; const SemVer$6 = semver$2; const patch = (a, loose) => new SemVer$6(a, loose).patch; var patch_1 = patch; const parse$1 = parse_1; const prerelease = (version, options) => { const parsed = parse$1(version, options); return parsed && parsed.prerelease.length ? parsed.prerelease : null; }; var prerelease_1 = prerelease; const compare$8 = compare_1; const rcompare = (a, b, loose) => compare$8(b, a, loose); var rcompare_1 = rcompare; const compare$7 = compare_1; const compareLoose = (a, b) => compare$7(a, b, true); var compareLoose_1 = compareLoose; const SemVer$5 = semver$2; const compareBuild$2 = (a, b, loose) => { const versionA = new SemVer$5(a, loose); const versionB = new SemVer$5(b, loose); return versionA.compare(versionB) || versionA.compareBuild(versionB); }; var compareBuild_1 = compareBuild$2; const compareBuild$1 = compareBuild_1; const sort = (list, loose) => list.sort((a, b) => compareBuild$1(a, b, loose)); var sort_1 = sort; const compareBuild = compareBuild_1; const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose)); var rsort_1 = rsort; const compare$6 = compare_1; const gt$3 = (a, b, loose) => compare$6(a, b, loose) > 0; var gt_1 = gt$3; const compare$5 = compare_1; const lt$2 = (a, b, loose) => compare$5(a, b, loose) < 0; var lt_1 = lt$2; const compare$4 = compare_1; const neq$1 = (a, b, loose) => compare$4(a, b, loose) !== 0; var neq_1 = neq$1; const compare$3 = compare_1; const gte$2 = (a, b, loose) => compare$3(a, b, loose) >= 0; var gte_1 = gte$2; const compare$2 = compare_1; const lte$2 = (a, b, loose) => compare$2(a, b, loose) <= 0; var lte_1 = lte$2; const eq = eq_1; const neq = neq_1; const gt$2 = gt_1; const gte$1 = gte_1; const lt$1 = lt_1; const lte$1 = lte_1; const cmp = (a, op, b, loose) => { switch (op) { case '===': if (typeof a === 'object') a = a.version; if (typeof b === 'object') b = b.version; return a === b; case '!==': if (typeof a === 'object') a = a.version; if (typeof b === 'object') b = b.version; return a !== b; case '': case '=': case '==': return eq(a, b, loose); case '!=': return neq(a, b, loose); case '>': return gt$2(a, b, loose); case '>=': return gte$1(a, b, loose); case '<': return lt$1(a, b, loose); case '<=': return lte$1(a, b, loose); default: throw new TypeError(`Invalid operator: ${op}`); } }; var cmp_1 = cmp; const SemVer$4 = semver$2; const parse = parse_1; const { re, t } = re$3.exports; const coerce = (version, options) => { if (version instanceof SemVer$4) { return version; } if (typeof version === 'number') { version = String(version); } if (typeof version !== 'string') { return null; } options = options || {}; let match = null; if (!options.rtl) { match = version.match(re[t.COERCE]); } else { let next; while ((next = re[t.COERCERTL].exec(version)) && (!match || match.index + match[0].length !== version.length)) { if (!match || next.index + next[0].length !== match.index + match[0].length) { match = next; } re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length; } re[t.COERCERTL].lastIndex = -1; } if (match === null) return null; return parse(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options); }; var coerce_1 = coerce; var iterator; var hasRequiredIterator; function requireIterator() { if (hasRequiredIterator) return iterator; hasRequiredIterator = 1; iterator = function (Yallist) { Yallist.prototype[Symbol.iterator] = function* () { for (let walker = this.head; walker; walker = walker.next) { yield walker.value; } }; }; return iterator; } var yallist; var hasRequiredYallist; function requireYallist() { if (hasRequiredYallist) return yallist; hasRequiredYallist = 1; yallist = Yallist; Yallist.Node = Node; Yallist.create = Yallist; function Yallist(list) { var self = this; if (!(self instanceof Yallist)) { self = new Yallist(); } self.tail = null; self.head = null; self.length = 0; if (list && typeof list.forEach === 'function') { list.forEach(function (item) { self.push(item); }); } else if (arguments.length > 0) { for (var i = 0, l = arguments.length; i < l; i++) { self.push(arguments[i]); } } return self; } Yallist.prototype.removeNode = function (node) { if (node.list !== this) { throw new Error('removing node which does not belong to this list'); } var next = node.next; var prev = node.prev; if (next) { next.prev = prev; } if (prev) { prev.next = next; } if (node === this.head) { this.head = next; } if (node === this.tail) { this.tail = prev; } node.list.length--; node.next = null; node.prev = null; node.list = null; return next; }; Yallist.prototype.unshiftNode = function (node) { if (node === this.head) { return; } if (node.list) { node.list.removeNode(node); } var head = this.head; node.list = this; node.next = head; if (head) { head.prev = node; } this.head = node; if (!this.tail) { this.tail = node; } this.length++; }; Yallist.prototype.pushNode = function (node) { if (node === this.tail) { return; } if (node.list) { node.list.removeNode(node); } var tail = this.tail; node.list = this; node.prev = tail; if (tail) { tail.next = node; } this.tail = node; if (!this.head) { this.head = node; } this.length++; }; Yallist.prototype.push = function () { for (var i = 0, l = arguments.length; i < l; i++) { push(this, arguments[i]); } return this.length; }; Yallist.prototype.unshift = function () { for (var i = 0, l = arguments.length; i < l; i++) { unshift(this, arguments[i]); } return this.length; }; Yallist.prototype.pop = function () { if (!this.tail) { return undefined; } var res = this.tail.value; this.tail = this.tail.prev; if (this.tail) { this.tail.next = null; } else { this.head = null; } this.length--; return res; }; Yallist.prototype.shift = function () { if (!this.head) { return undefined; } var res = this.head.value; this.head = this.head.next; if (this.head) { this.head.prev = null; } else { this.tail = null; } this.length--; return res; }; Yallist.prototype.forEach = function (fn, thisp) { thisp = thisp || this; for (var walker = this.head, i = 0; walker !== null; i++) { fn.call(thisp, walker.value, i, this); walker = walker.next; } }; Yallist.prototype.forEachReverse = function (fn, thisp) { thisp = thisp || this; for (var walker = this.tail, i = this.length - 1; walker !== null; i--) { fn.call(thisp, walker.value, i, this); walker = walker.prev; } }; Yallist.prototype.get = function (n) { for (var i = 0, walker = this.head; walker !== null && i < n; i++) { walker = walker.next; } if (i === n && walker !== null) { return walker.value; } }; Yallist.prototype.getReverse = function (n) { for (var i = 0, walker = this.tail; walker !== null && i < n; i++) { walker = walker.prev; } if (i === n && walker !== null) { return walker.value; } }; Yallist.prototype.map = function (fn, thisp) { thisp = thisp || this; var res = new Yallist(); for (var walker = this.head; walker !== null;) { res.push(fn.call(thisp, walker.value, this)); walker = walker.next; } return res; }; Yallist.prototype.mapReverse = function (fn, thisp) { thisp = thisp || this; var res = new Yallist(); for (var walker = this.tail; walker !== null;) { res.push(fn.call(thisp, walker.value, this)); walker = walker.prev; } return res; }; Yallist.prototype.reduce = function (fn, initial) { var acc; var walker = this.head; if (arguments.length > 1) { acc = initial; } else if (this.head) { walker = this.head.next; acc = this.head.value; } else { throw new TypeError('Reduce of empty list with no initial value'); } for (var i = 0; walker !== null; i++) { acc = fn(acc, walker.value, i); walker = walker.next; } return acc; }; Yallist.prototype.reduceReverse = function (fn, initial) { var acc; var walker = this.tail; if (arguments.length > 1) { acc = initial; } else if (this.tail) { walker = this.tail.prev; acc = this.tail.value; } else { throw new TypeError('Reduce of empty list with no initial value'); } for (var i = this.length - 1; walker !== null; i--) { acc = fn(acc, walker.value, i); walker = walker.prev; } return acc; }; Yallist.prototype.toArray = function () { var arr = new Array(this.length); for (var i = 0, walker = this.head; walker !== null; i++) { arr[i] = walker.value; walker = walker.next; } return arr; }; Yallist.prototype.toArrayReverse = function () { var arr = new Array(this.length); for (var i = 0, walker = this.tail; walker !== null; i++) { arr[i] = walker.value; walker = walker.prev; } return arr; }; Yallist.prototype.slice = function (from, to) { to = to || this.length; if (to < 0) { to += this.length; } from = from || 0; if (from < 0) { from += this.length; } var ret = new Yallist(); if (to < from || to < 0) { return ret; } if (from < 0) { from = 0; } if (to > this.length) { to = this.length; } for (var i = 0, walker = this.head; walker !== null && i < from; i++) { walker = walker.next; } for (; walker !== null && i < to; i++, walker = walker.next) { ret.push(walker.value); } return ret; }; Yallist.prototype.sliceReverse = function (from, to) { to = to || this.length; if (to < 0) { to += this.length; } from = from || 0; if (from < 0) { from += this.length; } var ret = new Yallist(); if (to < from || to < 0) { return ret; } if (from < 0) { from = 0; } if (to > this.length) { to = this.length; } for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) { walker = walker.prev; } for (; walker !== null && i > from; i--, walker = walker.prev) { ret.push(walker.value); } return ret; }; Yallist.prototype.splice = function (start, deleteCount, ...nodes) { if (start > this.length) { start = this.length - 1; } if (start < 0) { start = this.length + start; } for (var i = 0, walker = this.head; walker !== null && i < start; i++) { walker = walker.next; } var ret = []; for (var i = 0; walker && i < deleteCount; i++) { ret.push(walker.value); walker = this.removeNode(walker); } if (walker === null) { walker = this.tail; } if (walker !== this.head && walker !== this.tail) { walker = walker.prev; } for (var i = 0; i < nodes.length; i++) { walker = insert(this, walker, nodes[i]); } return ret; }; Yallist.prototype.reverse = function () { var head = this.head; var tail = this.tail; for (var walker = head; walker !== null; walker = walker.prev) { var p = walker.prev; walker.prev = walker.next; walker.next = p; } this.head = tail; this.tail = head; return this; }; function insert(self, node, value) { var inserted = node === self.head ? new Node(value, null, node, self) : new Node(value, node, node.next, self); if (inserted.next === null) { self.tail = inserted; } if (inserted.prev === null) { self.head = inserted; } self.length++; return inserted; } function push(self, item) { self.tail = new Node(item, self.tail, null, self); if (!self.head) { self.head = self.tail; } self.length++; } function unshift(self, item) { self.head = new Node(item, null, self.head, self); if (!self.tail) { self.tail = self.head; } self.length++; } function Node(value, prev, next, list) { if (!(this instanceof Node)) { return new Node(value, prev, next, list); } this.list = list; this.value = value; if (prev) { prev.next = this; this.prev = prev; } else { this.prev = null; } if (next) { next.prev = this; this.next = next; } else { this.next = null; } } try { requireIterator()(Yallist); } catch (er) {} return yallist; } var lruCache; var hasRequiredLruCache; function requireLruCache() { if (hasRequiredLruCache) return lruCache; hasRequiredLruCache = 1; const Yallist = requireYallist(); const MAX = Symbol('max'); const LENGTH = Symbol('length'); const LENGTH_CALCULATOR = Symbol('lengthCalculator'); const ALLOW_STALE = Symbol('allowStale'); const MAX_AGE = Symbol('maxAge'); const DISPOSE = Symbol('dispose'); const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet'); const LRU_LIST = Symbol('lruList'); const CACHE = Symbol('cache'); const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet'); const naiveLength = () => 1; class LRUCache { constructor(options) { if (typeof options === 'number') options = { max: options }; if (!options) options = {}; if (options.max && (typeof options.max !== 'number' || options.max < 0)) throw new TypeError('max must be a non-negative number'); this[MAX] = options.max || Infinity; const lc = options.length || naiveLength; this[LENGTH_CALCULATOR] = typeof lc !== 'function' ? naiveLength : lc; this[ALLOW_STALE] = options.stale || false; if (options.maxAge && typeof options.maxAge !== 'number') throw new TypeError('maxAge must be a number'); this[MAX_AGE] = options.maxAge || 0; this[DISPOSE] = options.dispose; this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false; this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false; this.reset(); } set max(mL) { if (typeof mL !== 'number' || mL < 0) throw new TypeError('max must be a non-negative number'); this[MAX] = mL || Infinity; trim(this); } get max() { return this[MAX]; } set allowStale(allowStale) { this[ALLOW_STALE] = !!allowStale; } get allowStale() { return this[ALLOW_STALE]; } set maxAge(mA) { if (typeof mA !== 'number') throw new TypeError('maxAge must be a non-negative number'); this[MAX_AGE] = mA; trim(this); } get maxAge() { return this[MAX_AGE]; } set lengthCalculator(lC) { if (typeof lC !== 'function') lC = naiveLength; if (lC !== this[LENGTH_CALCULATOR]) { this[LENGTH_CALCULATOR] = lC; this[LENGTH] = 0; this[LRU_LIST].forEach(hit => { hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key); this[LENGTH] += hit.length; }); } trim(this); } get lengthCalculator() { return this[LENGTH_CALCULATOR]; } get length() { return this[LENGTH]; } get itemCount() { return this[LRU_LIST].length; } rforEach(fn, thisp) { thisp = thisp || this; for (let walker = this[LRU_LIST].tail; walker !== null;) { const prev = walker.prev; forEachStep(this, fn, walker, thisp); walker = prev; } } forEach(fn, thisp) { thisp = thisp || this; for (let walker = this[LRU_LIST].head; walker !== null;) { const next = walker.next; forEachStep(this, fn, walker, thisp); walker = next; } } keys() { return this[LRU_LIST].toArray().map(k => k.key); } values() { return this[LRU_LIST].toArray().map(k => k.value); } reset() { if (this[DISPOSE] && this[LRU_LIST] && this[LRU_LIST].length) { this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value)); } this[CACHE] = new Map(); this[LRU_LIST] = new Yallist(); this[LENGTH] = 0; } dump() { return this[LRU_LIST].map(hit => isStale(this, hit) ? false : { k: hit.key, v: hit.value, e: hit.now + (hit.maxAge || 0) }).toArray().filter(h => h); } dumpLru() { return this[LRU_LIST]; } set(key, value, maxAge) { maxAge = maxAge || this[MAX_AGE]; if (maxAge && typeof maxAge !== 'number') throw new TypeError('maxAge must be a number'); const now = maxAge ? Date.now() : 0; const len = this[LENGTH_CALCULATOR](value, key); if (this[CACHE].has(key)) { if (len > this[MAX]) { del(this, this[CACHE].get(key)); return false; } const node = this[CACHE].get(key); const item = node.value; if (this[DISPOSE]) { if (!this[NO_DISPOSE_ON_SET]) this[DISPOSE](key, item.value); } item.now = now; item.maxAge = maxAge; item.value = value; this[LENGTH] += len - item.length; item.length = len; this.get(key); trim(this); return true; } const hit = new Entry(key, value, len, now, maxAge); if (hit.length > this[MAX]) { if (this[DISPOSE]) this[DISPOSE](key, value); return false; } this[LENGTH] += hit.length; this[LRU_LIST].unshift(hit); this[CACHE].set(key, this[LRU_LIST].head); trim(this); return true; } has(key) { if (!this[CACHE].has(key)) return false; const hit = this[CACHE].get(key).value; return !isStale(this, hit); } get(key) { return get(this, key, true); } peek(key) { return get(this, key, false); } pop() { const node = this[LRU_LIST].tail; if (!node) return null; del(this, node); return node.value; } del(key) { del(this, this[CACHE].get(key)); } load(arr) { this.reset(); const now = Date.now(); for (let l = arr.length - 1; l >= 0; l--) { const hit = arr[l]; const expiresAt = hit.e || 0; if (expiresAt === 0) this.set(hit.k, hit.v);else { const maxAge = expiresAt - now; if (maxAge > 0) { this.set(hit.k, hit.v, maxAge); } } } } prune() { this[CACHE].forEach((value, key) => get(this, key, false)); } } const get = (self, key, doUse) => { const node = self[CACHE].get(key); if (node) { const hit = node.value; if (isStale(self, hit)) { del(self, node); if (!self[ALLOW_STALE]) return undefined; } else { if (doUse) { if (self[UPDATE_AGE_ON_GET]) node.value.now = Date.now(); self[LRU_LIST].unshiftNode(node); } } return hit.value; } }; const isStale = (self, hit) => { if (!hit || !hit.maxAge && !self[MAX_AGE]) return false; const diff = Date.now() - hit.now; return hit.maxAge ? diff > hit.maxAge : self[MAX_AGE] && diff > self[MAX_AGE]; }; const trim = self => { if (self[LENGTH] > self[MAX]) { for (let walker = self[LRU_LIST].tail; self[LENGTH] > self[MAX] && walker !== null;) { const prev = walker.prev; del(self, walker); walker = prev; } } }; const del = (self, node) => { if (node) { const hit = node.value; if (self[DISPOSE]) self[DISPOSE](hit.key, hit.value); self[LENGTH] -= hit.length; self[CACHE].delete(hit.key); self[LRU_LIST].removeNode(node); } }; class Entry { constructor(key, value, length, now, maxAge) { this.key = key; this.value = value; this.length = length; this.now = now; this.maxAge = maxAge || 0; } } const forEachStep = (self, fn, node, thisp) => { let hit = node.value; if (isStale(self, hit)) { del(self, node); if (!self[ALLOW_STALE]) hit = undefined; } if (hit) fn.call(thisp, hit.value, hit.key, self); }; lruCache = LRUCache; return lruCache; } var range; var hasRequiredRange; function requireRange() { if (hasRequiredRange) return range; hasRequiredRange = 1; class Range { constructor(range, options) { options = parseOptions(options); if (range instanceof Range) { if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) { return range; } else { return new Range(range.raw, options); } } if (range instanceof Comparator) { this.raw = range.value; this.set = [[range]]; this.format(); return this; } this.options = options; this.loose = !!options.loose; this.includePrerelease = !!options.includePrerelease; this.raw = range; this.set = range.split(/\s*\|\|\s*/).map(range => this.parseRange(range.trim())).filter(c => c.length); if (!this.set.length) { throw new TypeError(`Invalid SemVer Range: ${range}`); } if (this.set.length > 1) { const first = this.set[0]; this.set = this.set.filter(c => !isNullSet(c[0])); if (this.set.length === 0) this.set = [first];else if (this.set.length > 1) { for (const c of this.set) { if (c.length === 1 && isAny(c[0])) { this.set = [c]; break; } } } } this.format(); } format() { this.range = this.set.map(comps => { return comps.join(' ').trim(); }).join('||').trim(); return this.range; } toString() { return this.range; } parseRange(range) { range = range.trim(); const memoOpts = Object.keys(this.options).join(','); const memoKey = `parseRange:${memoOpts}:${range}`; const cached = cache.get(memoKey); if (cached) return cached; const loose = this.options.loose; const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE]; range = range.replace(hr, hyphenReplace(this.options.includePrerelease)); debug('hyphen replace', range); range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace); debug('comparator trim', range, re[t.COMPARATORTRIM]); range = range.replace(re[t.TILDETRIM], tildeTrimReplace); range = range.replace(re[t.CARETTRIM], caretTrimReplace); range = range.split(/\s+/).join(' '); const compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]; const rangeList = range.split(' ').map(comp => parseComparator(comp, this.options)).join(' ').split(/\s+/).map(comp => replaceGTE0(comp, this.options)).filter(this.options.loose ? comp => !!comp.match(compRe) : () => true).map(comp => new Comparator(comp, this.options)); rangeList.length; const rangeMap = new Map(); for (const comp of rangeList) { if (isNullSet(comp)) return [comp]; rangeMap.set(comp.value, comp); } if (rangeMap.size > 1 && rangeMap.has('')) rangeMap.delete(''); const result = [...rangeMap.values()]; cache.set(memoKey, result); return result; } intersects(range, options) { if (!(range instanceof Range)) { throw new TypeError('a Range is required'); } return this.set.some(thisComparators => { return isSatisfiable(thisComparators, options) && range.set.some(rangeComparators => { return isSatisfiable(rangeComparators, options) && thisComparators.every(thisComparator => { return rangeComparators.every(rangeComparator => { return thisComparator.intersects(rangeComparator, options); }); }); }); }); } test(version) { if (!version) { return false; } if (typeof version === 'string') { try { version = new SemVer(version, this.options); } catch (er) { return false; } } for (let i = 0; i < this.set.length; i++) { if (testSet(this.set[i], version, this.options)) { return true; } } return false; } } range = Range; const LRU = requireLruCache(); const cache = new LRU({ max: 1000 }); const parseOptions = parseOptions_1; const Comparator = requireComparator(); const debug = debug_1; const SemVer = semver$2; const { re, t, comparatorTrimReplace, tildeTrimReplace, caretTrimReplace } = re$3.exports; const isNullSet = c => c.value === '<0.0.0-0'; const isAny = c => c.value === ''; const isSatisfiable = (comparators, options) => { let result = true; const remainingComparators = comparators.slice(); let testComparator = remainingComparators.pop(); while (result && remainingComparators.length) { result = remainingComparators.every(otherComparator => { return testComparator.intersects(otherComparator, options); }); testComparator = remainingComparators.pop(); } return result; }; const parseComparator = (comp, options) => { debug('comp', comp, options); comp = replaceCarets(comp, options); debug('caret', comp); comp = replaceTildes(comp, options); debug('tildes', comp); comp = replaceXRanges(comp, options); debug('xrange', comp); comp = replaceStars(comp, options); debug('stars', comp); return comp; }; const isX = id => !id || id.toLowerCase() === 'x' || id === '*'; const replaceTildes = (comp, options) => comp.trim().split(/\s+/).map(comp => { return replaceTilde(comp, options); }).join(' '); const replaceTilde = (comp, options) => { const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE]; return comp.replace(r, (_, M, m, p, pr) => { debug('tilde', comp, _, M, m, p, pr); let ret; if (isX(M)) { ret = ''; } else if (isX(m)) { ret = `>=${M}.0.0 <${+M + 1}.0.0-0`; } else if (isX(p)) { ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`; } else if (pr) { debug('replaceTilde pr', pr); ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`; } else { ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`; } debug('tilde return', ret); return ret; }); }; const replaceCarets = (comp, options) => comp.trim().split(/\s+/).map(comp => { return replaceCaret(comp, options); }).join(' '); const replaceCaret = (comp, options) => { debug('caret', comp, options); const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET]; const z = options.includePrerelease ? '-0' : ''; return comp.replace(r, (_, M, m, p, pr) => { debug('caret', comp, _, M, m, p, pr); let ret; if (isX(M)) { ret = ''; } else if (isX(m)) { ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`; } else if (isX(p)) { if (M === '0') { ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`; } else { ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`; } } else if (pr) { debug('replaceCaret pr', pr); if (M === '0') { if (m === '0') { ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`; } else { ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`; } } else { ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`; } } else { debug('no pr'); if (M === '0') { if (m === '0') { ret = `>=${M}.${m}.${p}${z} <${M}.${m}.${+p + 1}-0`; } else { ret = `>=${M}.${m}.${p}${z} <${M}.${+m + 1}.0-0`; } } else { ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`; } } debug('caret return', ret); return ret; }); }; const replaceXRanges = (comp, options) => { debug('replaceXRanges', comp, options); return comp.split(/\s+/).map(comp => { return replaceXRange(comp, options); }).join(' '); }; const replaceXRange = (comp, options) => { comp = comp.trim(); const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE]; return comp.replace(r, (ret, gtlt, M, m, p, pr) => { debug('xRange', comp, ret, gtlt, M, m, p, pr); const xM = isX(M); const xm = xM || isX(m); const xp = xm || isX(p); const anyX = xp; if (gtlt === '=' && anyX) { gtlt = ''; } pr = options.includePrerelease ? '-0' : ''; if (xM) { if (gtlt === '>' || gtlt === '<') { ret = '<0.0.0-0'; } else { ret = '*'; } } else if (gtlt && anyX) { if (xm) { m = 0; } p = 0; if (gtlt === '>') { gtlt = '>='; if (xm) { M = +M + 1; m = 0; p = 0; } else { m = +m + 1; p = 0; } } else if (gtlt === '<=') { gtlt = '<'; if (xm) { M = +M + 1; } else { m = +m + 1; } } if (gtlt === '<') pr = '-0'; ret = `${gtlt + M}.${m}.${p}${pr}`; } else if (xm) { ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`; } else if (xp) { ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`; } debug('xRange return', ret); return ret; }); }; const replaceStars = (comp, options) => { debug('replaceStars', comp, options); return comp.trim().replace(re[t.STAR], ''); }; const replaceGTE0 = (comp, options) => { debug('replaceGTE0', comp, options); return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], ''); }; const hyphenReplace = incPr => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) => { if (isX(fM)) { from = ''; } else if (isX(fm)) { from = `>=${fM}.0.0${incPr ? '-0' : ''}`; } else if (isX(fp)) { from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}`; } else if (fpr) { from = `>=${from}`; } else { from = `>=${from}${incPr ? '-0' : ''}`; } if (isX(tM)) { to = ''; } else if (isX(tm)) { to = `<${+tM + 1}.0.0-0`; } else if (isX(tp)) { to = `<${tM}.${+tm + 1}.0-0`; } else if (tpr) { to = `<=${tM}.${tm}.${tp}-${tpr}`; } else if (incPr) { to = `<${tM}.${tm}.${+tp + 1}-0`; } else { to = `<=${to}`; } return `${from} ${to}`.trim(); }; const testSet = (set, version, options) => { for (let i = 0; i < set.length; i++) { if (!set[i].test(version)) { return false; } } if (version.prerelease.length && !options.includePrerelease) { for (let i = 0; i < set.length; i++) { debug(set[i].semver); if (set[i].semver === Comparator.ANY) { continue; } if (set[i].semver.prerelease.length > 0) { const allowed = set[i].semver; if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) { return true; } } } return false; } return true; }; return range; } var comparator; var hasRequiredComparator; function requireComparator() { if (hasRequiredComparator) return comparator; hasRequiredComparator = 1; const ANY = Symbol('SemVer ANY'); class Comparator { static get ANY() { return ANY; } constructor(comp, options) { options = parseOptions(options); if (comp instanceof Comparator) { if (comp.loose === !!options.loose) { return comp; } else { comp = comp.value; } } debug('comparator', comp, options); this.options = options; this.loose = !!options.loose; this.parse(comp); if (this.semver === ANY) { this.value = ''; } else { this.value = this.operator + this.semver.version; } debug('comp', this); } parse(comp) { const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]; const m = comp.match(r); if (!m) { throw new TypeError(`Invalid comparator: ${comp}`); } this.operator = m[1] !== undefined ? m[1] : ''; if (this.operator === '=') { this.operator = ''; } if (!m[2]) { this.semver = ANY; } else { this.semver = new SemVer(m[2], this.options.loose); } }