UNPKG

89.9 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.moduleResolve = moduleResolve;
7exports.resolve = resolve;
8
9function _url() {
10 const data = require("url");
11
12 _url = function () {
13 return data;
14 };
15
16 return data;
17}
18
19function _fs() {
20 const data = _interopRequireWildcard(require("fs"), true);
21
22 _fs = function () {
23 return data;
24 };
25
26 return data;
27}
28
29function _path() {
30 const data = require("path");
31
32 _path = function () {
33 return data;
34 };
35
36 return data;
37}
38
39function _assert() {
40 const data = require("assert");
41
42 _assert = function () {
43 return data;
44 };
45
46 return data;
47}
48
49function _util() {
50 const data = require("util");
51
52 _util = function () {
53 return data;
54 };
55
56 return data;
57}
58
59function _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); }
60
61function _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; }
62
63function 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); } }
64
65function _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); }); }; }
66
67function createCommonjsModule(fn) {
68 var module = {
69 exports: {}
70 };
71 return fn(module, module.exports), module.exports;
72}
73
74const SEMVER_SPEC_VERSION = '2.0.0';
75const MAX_LENGTH$2 = 256;
76const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER || 9007199254740991;
77const MAX_SAFE_COMPONENT_LENGTH = 16;
78var constants = {
79 SEMVER_SPEC_VERSION,
80 MAX_LENGTH: MAX_LENGTH$2,
81 MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1,
82 MAX_SAFE_COMPONENT_LENGTH
83};
84const debug = typeof process === 'object' && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error('SEMVER', ...args) : () => {};
85var debug_1 = debug;
86var re_1 = createCommonjsModule(function (module, exports) {
87 const {
88 MAX_SAFE_COMPONENT_LENGTH
89 } = constants;
90 exports = module.exports = {};
91 const re = exports.re = [];
92 const src = exports.src = [];
93 const t = exports.t = {};
94 let R = 0;
95
96 const createToken = (name, value, isGlobal) => {
97 const index = R++;
98 debug_1(index, value);
99 t[name] = index;
100 src[index] = value;
101 re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
102 };
103
104 createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
105 createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+');
106 createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*');
107 createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` + `(${src[t.NUMERICIDENTIFIER]})\\.` + `(${src[t.NUMERICIDENTIFIER]})`);
108 createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + `(${src[t.NUMERICIDENTIFIERLOOSE]})`);
109 createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]}|${src[t.NONNUMERICIDENTIFIER]})`);
110 createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]}|${src[t.NONNUMERICIDENTIFIER]})`);
111 createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
112 createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
113 createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+');
114 createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
115 createToken('FULLPLAIN', `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
116 createToken('FULL', `^${src[t.FULLPLAIN]}$`);
117 createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
118 createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
119 createToken('GTLT', '((?:<|>)?=?)');
120 createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
121 createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
122 createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + `(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?` + `)?)?`);
123 createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?` + `)?)?`);
124 createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
125 createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
126 createToken('COERCE', `${'(^|[^\\d])' + '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + `(?:$|[^\\d])`);
127 createToken('COERCERTL', src[t.COERCE], true);
128 createToken('LONETILDE', '(?:~>?)');
129 createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
130 exports.tildeTrimReplace = '$1~';
131 createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
132 createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
133 createToken('LONECARET', '(?:\\^)');
134 createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
135 exports.caretTrimReplace = '$1^';
136 createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
137 createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
138 createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
139 createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
140 createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
141 exports.comparatorTrimReplace = '$1$2$3';
142 createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` + `\\s+-\\s+` + `(${src[t.XRANGEPLAIN]})` + `\\s*$`);
143 createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + `\\s+-\\s+` + `(${src[t.XRANGEPLAINLOOSE]})` + `\\s*$`);
144 createToken('STAR', '(<|>)?=?\\s*\\*');
145 createToken('GTE0', '^\\s*>=\\s*0\.0\.0\\s*$');
146 createToken('GTE0PRE', '^\\s*>=\\s*0\.0\.0-0\\s*$');
147});
148const opts = ['includePrerelease', 'loose', 'rtl'];
149
150const parseOptions = options => !options ? {} : typeof options !== 'object' ? {
151 loose: true
152} : opts.filter(k => options[k]).reduce((options, k) => {
153 options[k] = true;
154 return options;
155}, {});
156
157var parseOptions_1 = parseOptions;
158const numeric = /^[0-9]+$/;
159
160const compareIdentifiers$1 = (a, b) => {
161 const anum = numeric.test(a);
162 const bnum = numeric.test(b);
163
164 if (anum && bnum) {
165 a = +a;
166 b = +b;
167 }
168
169 return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
170};
171
172const rcompareIdentifiers = (a, b) => compareIdentifiers$1(b, a);
173
174var identifiers = {
175 compareIdentifiers: compareIdentifiers$1,
176 rcompareIdentifiers
177};
178const {
179 MAX_LENGTH: MAX_LENGTH$1,
180 MAX_SAFE_INTEGER
181} = constants;
182const {
183 re: re$4,
184 t: t$4
185} = re_1;
186const {
187 compareIdentifiers
188} = identifiers;
189
190class SemVer {
191 constructor(version, options) {
192 options = parseOptions_1(options);
193
194 if (version instanceof SemVer) {
195 if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
196 return version;
197 } else {
198 version = version.version;
199 }
200 } else if (typeof version !== 'string') {
201 throw new TypeError(`Invalid Version: ${version}`);
202 }
203
204 if (version.length > MAX_LENGTH$1) {
205 throw new TypeError(`version is longer than ${MAX_LENGTH$1} characters`);
206 }
207
208 debug_1('SemVer', version, options);
209 this.options = options;
210 this.loose = !!options.loose;
211 this.includePrerelease = !!options.includePrerelease;
212 const m = version.trim().match(options.loose ? re$4[t$4.LOOSE] : re$4[t$4.FULL]);
213
214 if (!m) {
215 throw new TypeError(`Invalid Version: ${version}`);
216 }
217
218 this.raw = version;
219 this.major = +m[1];
220 this.minor = +m[2];
221 this.patch = +m[3];
222
223 if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
224 throw new TypeError('Invalid major version');
225 }
226
227 if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
228 throw new TypeError('Invalid minor version');
229 }
230
231 if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
232 throw new TypeError('Invalid patch version');
233 }
234
235 if (!m[4]) {
236 this.prerelease = [];
237 } else {
238 this.prerelease = m[4].split('.').map(id => {
239 if (/^[0-9]+$/.test(id)) {
240 const num = +id;
241
242 if (num >= 0 && num < MAX_SAFE_INTEGER) {
243 return num;
244 }
245 }
246
247 return id;
248 });
249 }
250
251 this.build = m[5] ? m[5].split('.') : [];
252 this.format();
253 }
254
255 format() {
256 this.version = `${this.major}.${this.minor}.${this.patch}`;
257
258 if (this.prerelease.length) {
259 this.version += `-${this.prerelease.join('.')}`;
260 }
261
262 return this.version;
263 }
264
265 toString() {
266 return this.version;
267 }
268
269 compare(other) {
270 debug_1('SemVer.compare', this.version, this.options, other);
271
272 if (!(other instanceof SemVer)) {
273 if (typeof other === 'string' && other === this.version) {
274 return 0;
275 }
276
277 other = new SemVer(other, this.options);
278 }
279
280 if (other.version === this.version) {
281 return 0;
282 }
283
284 return this.compareMain(other) || this.comparePre(other);
285 }
286
287 compareMain(other) {
288 if (!(other instanceof SemVer)) {
289 other = new SemVer(other, this.options);
290 }
291
292 return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
293 }
294
295 comparePre(other) {
296 if (!(other instanceof SemVer)) {
297 other = new SemVer(other, this.options);
298 }
299
300 if (this.prerelease.length && !other.prerelease.length) {
301 return -1;
302 } else if (!this.prerelease.length && other.prerelease.length) {
303 return 1;
304 } else if (!this.prerelease.length && !other.prerelease.length) {
305 return 0;
306 }
307
308 let i = 0;
309
310 do {
311 const a = this.prerelease[i];
312 const b = other.prerelease[i];
313 debug_1('prerelease compare', i, a, b);
314
315 if (a === undefined && b === undefined) {
316 return 0;
317 } else if (b === undefined) {
318 return 1;
319 } else if (a === undefined) {
320 return -1;
321 } else if (a === b) {
322 continue;
323 } else {
324 return compareIdentifiers(a, b);
325 }
326 } while (++i);
327 }
328
329 compareBuild(other) {
330 if (!(other instanceof SemVer)) {
331 other = new SemVer(other, this.options);
332 }
333
334 let i = 0;
335
336 do {
337 const a = this.build[i];
338 const b = other.build[i];
339 debug_1('prerelease compare', i, a, b);
340
341 if (a === undefined && b === undefined) {
342 return 0;
343 } else if (b === undefined) {
344 return 1;
345 } else if (a === undefined) {
346 return -1;
347 } else if (a === b) {
348 continue;
349 } else {
350 return compareIdentifiers(a, b);
351 }
352 } while (++i);
353 }
354
355 inc(release, identifier) {
356 switch (release) {
357 case 'premajor':
358 this.prerelease.length = 0;
359 this.patch = 0;
360 this.minor = 0;
361 this.major++;
362 this.inc('pre', identifier);
363 break;
364
365 case 'preminor':
366 this.prerelease.length = 0;
367 this.patch = 0;
368 this.minor++;
369 this.inc('pre', identifier);
370 break;
371
372 case 'prepatch':
373 this.prerelease.length = 0;
374 this.inc('patch', identifier);
375 this.inc('pre', identifier);
376 break;
377
378 case 'prerelease':
379 if (this.prerelease.length === 0) {
380 this.inc('patch', identifier);
381 }
382
383 this.inc('pre', identifier);
384 break;
385
386 case 'major':
387 if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
388 this.major++;
389 }
390
391 this.minor = 0;
392 this.patch = 0;
393 this.prerelease = [];
394 break;
395
396 case 'minor':
397 if (this.patch !== 0 || this.prerelease.length === 0) {
398 this.minor++;
399 }
400
401 this.patch = 0;
402 this.prerelease = [];
403 break;
404
405 case 'patch':
406 if (this.prerelease.length === 0) {
407 this.patch++;
408 }
409
410 this.prerelease = [];
411 break;
412
413 case 'pre':
414 if (this.prerelease.length === 0) {
415 this.prerelease = [0];
416 } else {
417 let i = this.prerelease.length;
418
419 while (--i >= 0) {
420 if (typeof this.prerelease[i] === 'number') {
421 this.prerelease[i]++;
422 i = -2;
423 }
424 }
425
426 if (i === -1) {
427 this.prerelease.push(0);
428 }
429 }
430
431 if (identifier) {
432 if (this.prerelease[0] === identifier) {
433 if (isNaN(this.prerelease[1])) {
434 this.prerelease = [identifier, 0];
435 }
436 } else {
437 this.prerelease = [identifier, 0];
438 }
439 }
440
441 break;
442
443 default:
444 throw new Error(`invalid increment argument: ${release}`);
445 }
446
447 this.format();
448 this.raw = this.version;
449 return this;
450 }
451
452}
453
454var semver$1 = SemVer;
455const {
456 MAX_LENGTH
457} = constants;
458const {
459 re: re$3,
460 t: t$3
461} = re_1;
462
463const parse = (version, options) => {
464 options = parseOptions_1(options);
465
466 if (version instanceof semver$1) {
467 return version;
468 }
469
470 if (typeof version !== 'string') {
471 return null;
472 }
473
474 if (version.length > MAX_LENGTH) {
475 return null;
476 }
477
478 const r = options.loose ? re$3[t$3.LOOSE] : re$3[t$3.FULL];
479
480 if (!r.test(version)) {
481 return null;
482 }
483
484 try {
485 return new semver$1(version, options);
486 } catch (er) {
487 return null;
488 }
489};
490
491var parse_1 = parse;
492
493const valid$1 = (version, options) => {
494 const v = parse_1(version, options);
495 return v ? v.version : null;
496};
497
498var valid_1 = valid$1;
499
500const clean = (version, options) => {
501 const s = parse_1(version.trim().replace(/^[=v]+/, ''), options);
502 return s ? s.version : null;
503};
504
505var clean_1 = clean;
506
507const inc = (version, release, options, identifier) => {
508 if (typeof options === 'string') {
509 identifier = options;
510 options = undefined;
511 }
512
513 try {
514 return new semver$1(version, options).inc(release, identifier).version;
515 } catch (er) {
516 return null;
517 }
518};
519
520var inc_1 = inc;
521
522const compare = (a, b, loose) => new semver$1(a, loose).compare(new semver$1(b, loose));
523
524var compare_1 = compare;
525
526const eq = (a, b, loose) => compare_1(a, b, loose) === 0;
527
528var eq_1 = eq;
529
530const diff = (version1, version2) => {
531 if (eq_1(version1, version2)) {
532 return null;
533 } else {
534 const v1 = parse_1(version1);
535 const v2 = parse_1(version2);
536 const hasPre = v1.prerelease.length || v2.prerelease.length;
537 const prefix = hasPre ? 'pre' : '';
538 const defaultResult = hasPre ? 'prerelease' : '';
539
540 for (const key in v1) {
541 if (key === 'major' || key === 'minor' || key === 'patch') {
542 if (v1[key] !== v2[key]) {
543 return prefix + key;
544 }
545 }
546 }
547
548 return defaultResult;
549 }
550};
551
552var diff_1 = diff;
553
554const major = (a, loose) => new semver$1(a, loose).major;
555
556var major_1 = major;
557
558const minor = (a, loose) => new semver$1(a, loose).minor;
559
560var minor_1 = minor;
561
562const patch = (a, loose) => new semver$1(a, loose).patch;
563
564var patch_1 = patch;
565
566const prerelease = (version, options) => {
567 const parsed = parse_1(version, options);
568 return parsed && parsed.prerelease.length ? parsed.prerelease : null;
569};
570
571var prerelease_1 = prerelease;
572
573const rcompare = (a, b, loose) => compare_1(b, a, loose);
574
575var rcompare_1 = rcompare;
576
577const compareLoose = (a, b) => compare_1(a, b, true);
578
579var compareLoose_1 = compareLoose;
580
581const compareBuild = (a, b, loose) => {
582 const versionA = new semver$1(a, loose);
583 const versionB = new semver$1(b, loose);
584 return versionA.compare(versionB) || versionA.compareBuild(versionB);
585};
586
587var compareBuild_1 = compareBuild;
588
589const sort = (list, loose) => list.sort((a, b) => compareBuild_1(a, b, loose));
590
591var sort_1 = sort;
592
593const rsort = (list, loose) => list.sort((a, b) => compareBuild_1(b, a, loose));
594
595var rsort_1 = rsort;
596
597const gt = (a, b, loose) => compare_1(a, b, loose) > 0;
598
599var gt_1 = gt;
600
601const lt = (a, b, loose) => compare_1(a, b, loose) < 0;
602
603var lt_1 = lt;
604
605const neq = (a, b, loose) => compare_1(a, b, loose) !== 0;
606
607var neq_1 = neq;
608
609const gte = (a, b, loose) => compare_1(a, b, loose) >= 0;
610
611var gte_1 = gte;
612
613const lte = (a, b, loose) => compare_1(a, b, loose) <= 0;
614
615var lte_1 = lte;
616
617const cmp = (a, op, b, loose) => {
618 switch (op) {
619 case '===':
620 if (typeof a === 'object') a = a.version;
621 if (typeof b === 'object') b = b.version;
622 return a === b;
623
624 case '!==':
625 if (typeof a === 'object') a = a.version;
626 if (typeof b === 'object') b = b.version;
627 return a !== b;
628
629 case '':
630 case '=':
631 case '==':
632 return eq_1(a, b, loose);
633
634 case '!=':
635 return neq_1(a, b, loose);
636
637 case '>':
638 return gt_1(a, b, loose);
639
640 case '>=':
641 return gte_1(a, b, loose);
642
643 case '<':
644 return lt_1(a, b, loose);
645
646 case '<=':
647 return lte_1(a, b, loose);
648
649 default:
650 throw new TypeError(`Invalid operator: ${op}`);
651 }
652};
653
654var cmp_1 = cmp;
655const {
656 re: re$2,
657 t: t$2
658} = re_1;
659
660const coerce = (version, options) => {
661 if (version instanceof semver$1) {
662 return version;
663 }
664
665 if (typeof version === 'number') {
666 version = String(version);
667 }
668
669 if (typeof version !== 'string') {
670 return null;
671 }
672
673 options = options || {};
674 let match = null;
675
676 if (!options.rtl) {
677 match = version.match(re$2[t$2.COERCE]);
678 } else {
679 let next;
680
681 while ((next = re$2[t$2.COERCERTL].exec(version)) && (!match || match.index + match[0].length !== version.length)) {
682 if (!match || next.index + next[0].length !== match.index + match[0].length) {
683 match = next;
684 }
685
686 re$2[t$2.COERCERTL].lastIndex = next.index + next[1].length + next[2].length;
687 }
688
689 re$2[t$2.COERCERTL].lastIndex = -1;
690 }
691
692 if (match === null) return null;
693 return parse_1(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options);
694};
695
696var coerce_1 = coerce;
697
698var iterator = function (Yallist) {
699 Yallist.prototype[Symbol.iterator] = function* () {
700 for (let walker = this.head; walker; walker = walker.next) {
701 yield walker.value;
702 }
703 };
704};
705
706var yallist = Yallist;
707Yallist.Node = Node;
708Yallist.create = Yallist;
709
710function Yallist(list) {
711 var self = this;
712
713 if (!(self instanceof Yallist)) {
714 self = new Yallist();
715 }
716
717 self.tail = null;
718 self.head = null;
719 self.length = 0;
720
721 if (list && typeof list.forEach === 'function') {
722 list.forEach(function (item) {
723 self.push(item);
724 });
725 } else if (arguments.length > 0) {
726 for (var i = 0, l = arguments.length; i < l; i++) {
727 self.push(arguments[i]);
728 }
729 }
730
731 return self;
732}
733
734Yallist.prototype.removeNode = function (node) {
735 if (node.list !== this) {
736 throw new Error('removing node which does not belong to this list');
737 }
738
739 var next = node.next;
740 var prev = node.prev;
741
742 if (next) {
743 next.prev = prev;
744 }
745
746 if (prev) {
747 prev.next = next;
748 }
749
750 if (node === this.head) {
751 this.head = next;
752 }
753
754 if (node === this.tail) {
755 this.tail = prev;
756 }
757
758 node.list.length--;
759 node.next = null;
760 node.prev = null;
761 node.list = null;
762 return next;
763};
764
765Yallist.prototype.unshiftNode = function (node) {
766 if (node === this.head) {
767 return;
768 }
769
770 if (node.list) {
771 node.list.removeNode(node);
772 }
773
774 var head = this.head;
775 node.list = this;
776 node.next = head;
777
778 if (head) {
779 head.prev = node;
780 }
781
782 this.head = node;
783
784 if (!this.tail) {
785 this.tail = node;
786 }
787
788 this.length++;
789};
790
791Yallist.prototype.pushNode = function (node) {
792 if (node === this.tail) {
793 return;
794 }
795
796 if (node.list) {
797 node.list.removeNode(node);
798 }
799
800 var tail = this.tail;
801 node.list = this;
802 node.prev = tail;
803
804 if (tail) {
805 tail.next = node;
806 }
807
808 this.tail = node;
809
810 if (!this.head) {
811 this.head = node;
812 }
813
814 this.length++;
815};
816
817Yallist.prototype.push = function () {
818 for (var i = 0, l = arguments.length; i < l; i++) {
819 push(this, arguments[i]);
820 }
821
822 return this.length;
823};
824
825Yallist.prototype.unshift = function () {
826 for (var i = 0, l = arguments.length; i < l; i++) {
827 unshift(this, arguments[i]);
828 }
829
830 return this.length;
831};
832
833Yallist.prototype.pop = function () {
834 if (!this.tail) {
835 return undefined;
836 }
837
838 var res = this.tail.value;
839 this.tail = this.tail.prev;
840
841 if (this.tail) {
842 this.tail.next = null;
843 } else {
844 this.head = null;
845 }
846
847 this.length--;
848 return res;
849};
850
851Yallist.prototype.shift = function () {
852 if (!this.head) {
853 return undefined;
854 }
855
856 var res = this.head.value;
857 this.head = this.head.next;
858
859 if (this.head) {
860 this.head.prev = null;
861 } else {
862 this.tail = null;
863 }
864
865 this.length--;
866 return res;
867};
868
869Yallist.prototype.forEach = function (fn, thisp) {
870 thisp = thisp || this;
871
872 for (var walker = this.head, i = 0; walker !== null; i++) {
873 fn.call(thisp, walker.value, i, this);
874 walker = walker.next;
875 }
876};
877
878Yallist.prototype.forEachReverse = function (fn, thisp) {
879 thisp = thisp || this;
880
881 for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
882 fn.call(thisp, walker.value, i, this);
883 walker = walker.prev;
884 }
885};
886
887Yallist.prototype.get = function (n) {
888 for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
889 walker = walker.next;
890 }
891
892 if (i === n && walker !== null) {
893 return walker.value;
894 }
895};
896
897Yallist.prototype.getReverse = function (n) {
898 for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
899 walker = walker.prev;
900 }
901
902 if (i === n && walker !== null) {
903 return walker.value;
904 }
905};
906
907Yallist.prototype.map = function (fn, thisp) {
908 thisp = thisp || this;
909 var res = new Yallist();
910
911 for (var walker = this.head; walker !== null;) {
912 res.push(fn.call(thisp, walker.value, this));
913 walker = walker.next;
914 }
915
916 return res;
917};
918
919Yallist.prototype.mapReverse = function (fn, thisp) {
920 thisp = thisp || this;
921 var res = new Yallist();
922
923 for (var walker = this.tail; walker !== null;) {
924 res.push(fn.call(thisp, walker.value, this));
925 walker = walker.prev;
926 }
927
928 return res;
929};
930
931Yallist.prototype.reduce = function (fn, initial) {
932 var acc;
933 var walker = this.head;
934
935 if (arguments.length > 1) {
936 acc = initial;
937 } else if (this.head) {
938 walker = this.head.next;
939 acc = this.head.value;
940 } else {
941 throw new TypeError('Reduce of empty list with no initial value');
942 }
943
944 for (var i = 0; walker !== null; i++) {
945 acc = fn(acc, walker.value, i);
946 walker = walker.next;
947 }
948
949 return acc;
950};
951
952Yallist.prototype.reduceReverse = function (fn, initial) {
953 var acc;
954 var walker = this.tail;
955
956 if (arguments.length > 1) {
957 acc = initial;
958 } else if (this.tail) {
959 walker = this.tail.prev;
960 acc = this.tail.value;
961 } else {
962 throw new TypeError('Reduce of empty list with no initial value');
963 }
964
965 for (var i = this.length - 1; walker !== null; i--) {
966 acc = fn(acc, walker.value, i);
967 walker = walker.prev;
968 }
969
970 return acc;
971};
972
973Yallist.prototype.toArray = function () {
974 var arr = new Array(this.length);
975
976 for (var i = 0, walker = this.head; walker !== null; i++) {
977 arr[i] = walker.value;
978 walker = walker.next;
979 }
980
981 return arr;
982};
983
984Yallist.prototype.toArrayReverse = function () {
985 var arr = new Array(this.length);
986
987 for (var i = 0, walker = this.tail; walker !== null; i++) {
988 arr[i] = walker.value;
989 walker = walker.prev;
990 }
991
992 return arr;
993};
994
995Yallist.prototype.slice = function (from, to) {
996 to = to || this.length;
997
998 if (to < 0) {
999 to += this.length;
1000 }
1001
1002 from = from || 0;
1003
1004 if (from < 0) {
1005 from += this.length;
1006 }
1007
1008 var ret = new Yallist();
1009
1010 if (to < from || to < 0) {
1011 return ret;
1012 }
1013
1014 if (from < 0) {
1015 from = 0;
1016 }
1017
1018 if (to > this.length) {
1019 to = this.length;
1020 }
1021
1022 for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
1023 walker = walker.next;
1024 }
1025
1026 for (; walker !== null && i < to; i++, walker = walker.next) {
1027 ret.push(walker.value);
1028 }
1029
1030 return ret;
1031};
1032
1033Yallist.prototype.sliceReverse = function (from, to) {
1034 to = to || this.length;
1035
1036 if (to < 0) {
1037 to += this.length;
1038 }
1039
1040 from = from || 0;
1041
1042 if (from < 0) {
1043 from += this.length;
1044 }
1045
1046 var ret = new Yallist();
1047
1048 if (to < from || to < 0) {
1049 return ret;
1050 }
1051
1052 if (from < 0) {
1053 from = 0;
1054 }
1055
1056 if (to > this.length) {
1057 to = this.length;
1058 }
1059
1060 for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
1061 walker = walker.prev;
1062 }
1063
1064 for (; walker !== null && i > from; i--, walker = walker.prev) {
1065 ret.push(walker.value);
1066 }
1067
1068 return ret;
1069};
1070
1071Yallist.prototype.splice = function (start, deleteCount, ...nodes) {
1072 if (start > this.length) {
1073 start = this.length - 1;
1074 }
1075
1076 if (start < 0) {
1077 start = this.length + start;
1078 }
1079
1080 for (var i = 0, walker = this.head; walker !== null && i < start; i++) {
1081 walker = walker.next;
1082 }
1083
1084 var ret = [];
1085
1086 for (var i = 0; walker && i < deleteCount; i++) {
1087 ret.push(walker.value);
1088 walker = this.removeNode(walker);
1089 }
1090
1091 if (walker === null) {
1092 walker = this.tail;
1093 }
1094
1095 if (walker !== this.head && walker !== this.tail) {
1096 walker = walker.prev;
1097 }
1098
1099 for (var i = 0; i < nodes.length; i++) {
1100 walker = insert(this, walker, nodes[i]);
1101 }
1102
1103 return ret;
1104};
1105
1106Yallist.prototype.reverse = function () {
1107 var head = this.head;
1108 var tail = this.tail;
1109
1110 for (var walker = head; walker !== null; walker = walker.prev) {
1111 var p = walker.prev;
1112 walker.prev = walker.next;
1113 walker.next = p;
1114 }
1115
1116 this.head = tail;
1117 this.tail = head;
1118 return this;
1119};
1120
1121function insert(self, node, value) {
1122 var inserted = node === self.head ? new Node(value, null, node, self) : new Node(value, node, node.next, self);
1123
1124 if (inserted.next === null) {
1125 self.tail = inserted;
1126 }
1127
1128 if (inserted.prev === null) {
1129 self.head = inserted;
1130 }
1131
1132 self.length++;
1133 return inserted;
1134}
1135
1136function push(self, item) {
1137 self.tail = new Node(item, self.tail, null, self);
1138
1139 if (!self.head) {
1140 self.head = self.tail;
1141 }
1142
1143 self.length++;
1144}
1145
1146function unshift(self, item) {
1147 self.head = new Node(item, null, self.head, self);
1148
1149 if (!self.tail) {
1150 self.tail = self.head;
1151 }
1152
1153 self.length++;
1154}
1155
1156function Node(value, prev, next, list) {
1157 if (!(this instanceof Node)) {
1158 return new Node(value, prev, next, list);
1159 }
1160
1161 this.list = list;
1162 this.value = value;
1163
1164 if (prev) {
1165 prev.next = this;
1166 this.prev = prev;
1167 } else {
1168 this.prev = null;
1169 }
1170
1171 if (next) {
1172 next.prev = this;
1173 this.next = next;
1174 } else {
1175 this.next = null;
1176 }
1177}
1178
1179try {
1180 iterator(Yallist);
1181} catch (er) {}
1182
1183const MAX = Symbol('max');
1184const LENGTH = Symbol('length');
1185const LENGTH_CALCULATOR = Symbol('lengthCalculator');
1186const ALLOW_STALE = Symbol('allowStale');
1187const MAX_AGE = Symbol('maxAge');
1188const DISPOSE = Symbol('dispose');
1189const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet');
1190const LRU_LIST = Symbol('lruList');
1191const CACHE = Symbol('cache');
1192const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet');
1193
1194const naiveLength = () => 1;
1195
1196class LRUCache {
1197 constructor(options) {
1198 if (typeof options === 'number') options = {
1199 max: options
1200 };
1201 if (!options) options = {};
1202 if (options.max && (typeof options.max !== 'number' || options.max < 0)) throw new TypeError('max must be a non-negative number');
1203 this[MAX] = options.max || Infinity;
1204 const lc = options.length || naiveLength;
1205 this[LENGTH_CALCULATOR] = typeof lc !== 'function' ? naiveLength : lc;
1206 this[ALLOW_STALE] = options.stale || false;
1207 if (options.maxAge && typeof options.maxAge !== 'number') throw new TypeError('maxAge must be a number');
1208 this[MAX_AGE] = options.maxAge || 0;
1209 this[DISPOSE] = options.dispose;
1210 this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false;
1211 this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false;
1212 this.reset();
1213 }
1214
1215 set max(mL) {
1216 if (typeof mL !== 'number' || mL < 0) throw new TypeError('max must be a non-negative number');
1217 this[MAX] = mL || Infinity;
1218 trim(this);
1219 }
1220
1221 get max() {
1222 return this[MAX];
1223 }
1224
1225 set allowStale(allowStale) {
1226 this[ALLOW_STALE] = !!allowStale;
1227 }
1228
1229 get allowStale() {
1230 return this[ALLOW_STALE];
1231 }
1232
1233 set maxAge(mA) {
1234 if (typeof mA !== 'number') throw new TypeError('maxAge must be a non-negative number');
1235 this[MAX_AGE] = mA;
1236 trim(this);
1237 }
1238
1239 get maxAge() {
1240 return this[MAX_AGE];
1241 }
1242
1243 set lengthCalculator(lC) {
1244 if (typeof lC !== 'function') lC = naiveLength;
1245
1246 if (lC !== this[LENGTH_CALCULATOR]) {
1247 this[LENGTH_CALCULATOR] = lC;
1248 this[LENGTH] = 0;
1249 this[LRU_LIST].forEach(hit => {
1250 hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key);
1251 this[LENGTH] += hit.length;
1252 });
1253 }
1254
1255 trim(this);
1256 }
1257
1258 get lengthCalculator() {
1259 return this[LENGTH_CALCULATOR];
1260 }
1261
1262 get length() {
1263 return this[LENGTH];
1264 }
1265
1266 get itemCount() {
1267 return this[LRU_LIST].length;
1268 }
1269
1270 rforEach(fn, thisp) {
1271 thisp = thisp || this;
1272
1273 for (let walker = this[LRU_LIST].tail; walker !== null;) {
1274 const prev = walker.prev;
1275 forEachStep(this, fn, walker, thisp);
1276 walker = prev;
1277 }
1278 }
1279
1280 forEach(fn, thisp) {
1281 thisp = thisp || this;
1282
1283 for (let walker = this[LRU_LIST].head; walker !== null;) {
1284 const next = walker.next;
1285 forEachStep(this, fn, walker, thisp);
1286 walker = next;
1287 }
1288 }
1289
1290 keys() {
1291 return this[LRU_LIST].toArray().map(k => k.key);
1292 }
1293
1294 values() {
1295 return this[LRU_LIST].toArray().map(k => k.value);
1296 }
1297
1298 reset() {
1299 if (this[DISPOSE] && this[LRU_LIST] && this[LRU_LIST].length) {
1300 this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value));
1301 }
1302
1303 this[CACHE] = new Map();
1304 this[LRU_LIST] = new yallist();
1305 this[LENGTH] = 0;
1306 }
1307
1308 dump() {
1309 return this[LRU_LIST].map(hit => isStale(this, hit) ? false : {
1310 k: hit.key,
1311 v: hit.value,
1312 e: hit.now + (hit.maxAge || 0)
1313 }).toArray().filter(h => h);
1314 }
1315
1316 dumpLru() {
1317 return this[LRU_LIST];
1318 }
1319
1320 set(key, value, maxAge) {
1321 maxAge = maxAge || this[MAX_AGE];
1322 if (maxAge && typeof maxAge !== 'number') throw new TypeError('maxAge must be a number');
1323 const now = maxAge ? Date.now() : 0;
1324 const len = this[LENGTH_CALCULATOR](value, key);
1325
1326 if (this[CACHE].has(key)) {
1327 if (len > this[MAX]) {
1328 del(this, this[CACHE].get(key));
1329 return false;
1330 }
1331
1332 const node = this[CACHE].get(key);
1333 const item = node.value;
1334
1335 if (this[DISPOSE]) {
1336 if (!this[NO_DISPOSE_ON_SET]) this[DISPOSE](key, item.value);
1337 }
1338
1339 item.now = now;
1340 item.maxAge = maxAge;
1341 item.value = value;
1342 this[LENGTH] += len - item.length;
1343 item.length = len;
1344 this.get(key);
1345 trim(this);
1346 return true;
1347 }
1348
1349 const hit = new Entry(key, value, len, now, maxAge);
1350
1351 if (hit.length > this[MAX]) {
1352 if (this[DISPOSE]) this[DISPOSE](key, value);
1353 return false;
1354 }
1355
1356 this[LENGTH] += hit.length;
1357 this[LRU_LIST].unshift(hit);
1358 this[CACHE].set(key, this[LRU_LIST].head);
1359 trim(this);
1360 return true;
1361 }
1362
1363 has(key) {
1364 if (!this[CACHE].has(key)) return false;
1365 const hit = this[CACHE].get(key).value;
1366 return !isStale(this, hit);
1367 }
1368
1369 get(key) {
1370 return get(this, key, true);
1371 }
1372
1373 peek(key) {
1374 return get(this, key, false);
1375 }
1376
1377 pop() {
1378 const node = this[LRU_LIST].tail;
1379 if (!node) return null;
1380 del(this, node);
1381 return node.value;
1382 }
1383
1384 del(key) {
1385 del(this, this[CACHE].get(key));
1386 }
1387
1388 load(arr) {
1389 this.reset();
1390 const now = Date.now();
1391
1392 for (let l = arr.length - 1; l >= 0; l--) {
1393 const hit = arr[l];
1394 const expiresAt = hit.e || 0;
1395 if (expiresAt === 0) this.set(hit.k, hit.v);else {
1396 const maxAge = expiresAt - now;
1397
1398 if (maxAge > 0) {
1399 this.set(hit.k, hit.v, maxAge);
1400 }
1401 }
1402 }
1403 }
1404
1405 prune() {
1406 this[CACHE].forEach((value, key) => get(this, key, false));
1407 }
1408
1409}
1410
1411const get = (self, key, doUse) => {
1412 const node = self[CACHE].get(key);
1413
1414 if (node) {
1415 const hit = node.value;
1416
1417 if (isStale(self, hit)) {
1418 del(self, node);
1419 if (!self[ALLOW_STALE]) return undefined;
1420 } else {
1421 if (doUse) {
1422 if (self[UPDATE_AGE_ON_GET]) node.value.now = Date.now();
1423 self[LRU_LIST].unshiftNode(node);
1424 }
1425 }
1426
1427 return hit.value;
1428 }
1429};
1430
1431const isStale = (self, hit) => {
1432 if (!hit || !hit.maxAge && !self[MAX_AGE]) return false;
1433 const diff = Date.now() - hit.now;
1434 return hit.maxAge ? diff > hit.maxAge : self[MAX_AGE] && diff > self[MAX_AGE];
1435};
1436
1437const trim = self => {
1438 if (self[LENGTH] > self[MAX]) {
1439 for (let walker = self[LRU_LIST].tail; self[LENGTH] > self[MAX] && walker !== null;) {
1440 const prev = walker.prev;
1441 del(self, walker);
1442 walker = prev;
1443 }
1444 }
1445};
1446
1447const del = (self, node) => {
1448 if (node) {
1449 const hit = node.value;
1450 if (self[DISPOSE]) self[DISPOSE](hit.key, hit.value);
1451 self[LENGTH] -= hit.length;
1452 self[CACHE].delete(hit.key);
1453 self[LRU_LIST].removeNode(node);
1454 }
1455};
1456
1457class Entry {
1458 constructor(key, value, length, now, maxAge) {
1459 this.key = key;
1460 this.value = value;
1461 this.length = length;
1462 this.now = now;
1463 this.maxAge = maxAge || 0;
1464 }
1465
1466}
1467
1468const forEachStep = (self, fn, node, thisp) => {
1469 let hit = node.value;
1470
1471 if (isStale(self, hit)) {
1472 del(self, node);
1473 if (!self[ALLOW_STALE]) hit = undefined;
1474 }
1475
1476 if (hit) fn.call(thisp, hit.value, hit.key, self);
1477};
1478
1479var lruCache = LRUCache;
1480
1481class Range {
1482 constructor(range, options) {
1483 options = parseOptions_1(options);
1484
1485 if (range instanceof Range) {
1486 if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
1487 return range;
1488 } else {
1489 return new Range(range.raw, options);
1490 }
1491 }
1492
1493 if (range instanceof comparator) {
1494 this.raw = range.value;
1495 this.set = [[range]];
1496 this.format();
1497 return this;
1498 }
1499
1500 this.options = options;
1501 this.loose = !!options.loose;
1502 this.includePrerelease = !!options.includePrerelease;
1503 this.raw = range;
1504 this.set = range.split(/\s*\|\|\s*/).map(range => this.parseRange(range.trim())).filter(c => c.length);
1505
1506 if (!this.set.length) {
1507 throw new TypeError(`Invalid SemVer Range: ${range}`);
1508 }
1509
1510 if (this.set.length > 1) {
1511 const first = this.set[0];
1512 this.set = this.set.filter(c => !isNullSet(c[0]));
1513 if (this.set.length === 0) this.set = [first];else if (this.set.length > 1) {
1514 for (const c of this.set) {
1515 if (c.length === 1 && isAny(c[0])) {
1516 this.set = [c];
1517 break;
1518 }
1519 }
1520 }
1521 }
1522
1523 this.format();
1524 }
1525
1526 format() {
1527 this.range = this.set.map(comps => {
1528 return comps.join(' ').trim();
1529 }).join('||').trim();
1530 return this.range;
1531 }
1532
1533 toString() {
1534 return this.range;
1535 }
1536
1537 parseRange(range) {
1538 range = range.trim();
1539 const memoOpts = Object.keys(this.options).join(',');
1540 const memoKey = `parseRange:${memoOpts}:${range}`;
1541 const cached = cache.get(memoKey);
1542 if (cached) return cached;
1543 const loose = this.options.loose;
1544 const hr = loose ? re$1[t$1.HYPHENRANGELOOSE] : re$1[t$1.HYPHENRANGE];
1545 range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
1546 debug_1('hyphen replace', range);
1547 range = range.replace(re$1[t$1.COMPARATORTRIM], comparatorTrimReplace);
1548 debug_1('comparator trim', range, re$1[t$1.COMPARATORTRIM]);
1549 range = range.replace(re$1[t$1.TILDETRIM], tildeTrimReplace);
1550 range = range.replace(re$1[t$1.CARETTRIM], caretTrimReplace);
1551 range = range.split(/\s+/).join(' ');
1552 const compRe = loose ? re$1[t$1.COMPARATORLOOSE] : re$1[t$1.COMPARATOR];
1553 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));
1554 rangeList.length;
1555 const rangeMap = new Map();
1556
1557 for (const comp of rangeList) {
1558 if (isNullSet(comp)) return [comp];
1559 rangeMap.set(comp.value, comp);
1560 }
1561
1562 if (rangeMap.size > 1 && rangeMap.has('')) rangeMap.delete('');
1563 const result = [...rangeMap.values()];
1564 cache.set(memoKey, result);
1565 return result;
1566 }
1567
1568 intersects(range, options) {
1569 if (!(range instanceof Range)) {
1570 throw new TypeError('a Range is required');
1571 }
1572
1573 return this.set.some(thisComparators => {
1574 return isSatisfiable(thisComparators, options) && range.set.some(rangeComparators => {
1575 return isSatisfiable(rangeComparators, options) && thisComparators.every(thisComparator => {
1576 return rangeComparators.every(rangeComparator => {
1577 return thisComparator.intersects(rangeComparator, options);
1578 });
1579 });
1580 });
1581 });
1582 }
1583
1584 test(version) {
1585 if (!version) {
1586 return false;
1587 }
1588
1589 if (typeof version === 'string') {
1590 try {
1591 version = new semver$1(version, this.options);
1592 } catch (er) {
1593 return false;
1594 }
1595 }
1596
1597 for (let i = 0; i < this.set.length; i++) {
1598 if (testSet(this.set[i], version, this.options)) {
1599 return true;
1600 }
1601 }
1602
1603 return false;
1604 }
1605
1606}
1607
1608var range = Range;
1609const cache = new lruCache({
1610 max: 1000
1611});
1612const {
1613 re: re$1,
1614 t: t$1,
1615 comparatorTrimReplace,
1616 tildeTrimReplace,
1617 caretTrimReplace
1618} = re_1;
1619
1620const isNullSet = c => c.value === '<0.0.0-0';
1621
1622const isAny = c => c.value === '';
1623
1624const isSatisfiable = (comparators, options) => {
1625 let result = true;
1626 const remainingComparators = comparators.slice();
1627 let testComparator = remainingComparators.pop();
1628
1629 while (result && remainingComparators.length) {
1630 result = remainingComparators.every(otherComparator => {
1631 return testComparator.intersects(otherComparator, options);
1632 });
1633 testComparator = remainingComparators.pop();
1634 }
1635
1636 return result;
1637};
1638
1639const parseComparator = (comp, options) => {
1640 debug_1('comp', comp, options);
1641 comp = replaceCarets(comp, options);
1642 debug_1('caret', comp);
1643 comp = replaceTildes(comp, options);
1644 debug_1('tildes', comp);
1645 comp = replaceXRanges(comp, options);
1646 debug_1('xrange', comp);
1647 comp = replaceStars(comp, options);
1648 debug_1('stars', comp);
1649 return comp;
1650};
1651
1652const isX = id => !id || id.toLowerCase() === 'x' || id === '*';
1653
1654const replaceTildes = (comp, options) => comp.trim().split(/\s+/).map(comp => {
1655 return replaceTilde(comp, options);
1656}).join(' ');
1657
1658const replaceTilde = (comp, options) => {
1659 const r = options.loose ? re$1[t$1.TILDELOOSE] : re$1[t$1.TILDE];
1660 return comp.replace(r, (_, M, m, p, pr) => {
1661 debug_1('tilde', comp, _, M, m, p, pr);
1662 let ret;
1663
1664 if (isX(M)) {
1665 ret = '';
1666 } else if (isX(m)) {
1667 ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
1668 } else if (isX(p)) {
1669 ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
1670 } else if (pr) {
1671 debug_1('replaceTilde pr', pr);
1672 ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
1673 } else {
1674 ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
1675 }
1676
1677 debug_1('tilde return', ret);
1678 return ret;
1679 });
1680};
1681
1682const replaceCarets = (comp, options) => comp.trim().split(/\s+/).map(comp => {
1683 return replaceCaret(comp, options);
1684}).join(' ');
1685
1686const replaceCaret = (comp, options) => {
1687 debug_1('caret', comp, options);
1688 const r = options.loose ? re$1[t$1.CARETLOOSE] : re$1[t$1.CARET];
1689 const z = options.includePrerelease ? '-0' : '';
1690 return comp.replace(r, (_, M, m, p, pr) => {
1691 debug_1('caret', comp, _, M, m, p, pr);
1692 let ret;
1693
1694 if (isX(M)) {
1695 ret = '';
1696 } else if (isX(m)) {
1697 ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
1698 } else if (isX(p)) {
1699 if (M === '0') {
1700 ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
1701 } else {
1702 ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
1703 }
1704 } else if (pr) {
1705 debug_1('replaceCaret pr', pr);
1706
1707 if (M === '0') {
1708 if (m === '0') {
1709 ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
1710 } else {
1711 ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
1712 }
1713 } else {
1714 ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
1715 }
1716 } else {
1717 debug_1('no pr');
1718
1719 if (M === '0') {
1720 if (m === '0') {
1721 ret = `>=${M}.${m}.${p}${z} <${M}.${m}.${+p + 1}-0`;
1722 } else {
1723 ret = `>=${M}.${m}.${p}${z} <${M}.${+m + 1}.0-0`;
1724 }
1725 } else {
1726 ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
1727 }
1728 }
1729
1730 debug_1('caret return', ret);
1731 return ret;
1732 });
1733};
1734
1735const replaceXRanges = (comp, options) => {
1736 debug_1('replaceXRanges', comp, options);
1737 return comp.split(/\s+/).map(comp => {
1738 return replaceXRange(comp, options);
1739 }).join(' ');
1740};
1741
1742const replaceXRange = (comp, options) => {
1743 comp = comp.trim();
1744 const r = options.loose ? re$1[t$1.XRANGELOOSE] : re$1[t$1.XRANGE];
1745 return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
1746 debug_1('xRange', comp, ret, gtlt, M, m, p, pr);
1747 const xM = isX(M);
1748 const xm = xM || isX(m);
1749 const xp = xm || isX(p);
1750 const anyX = xp;
1751
1752 if (gtlt === '=' && anyX) {
1753 gtlt = '';
1754 }
1755
1756 pr = options.includePrerelease ? '-0' : '';
1757
1758 if (xM) {
1759 if (gtlt === '>' || gtlt === '<') {
1760 ret = '<0.0.0-0';
1761 } else {
1762 ret = '*';
1763 }
1764 } else if (gtlt && anyX) {
1765 if (xm) {
1766 m = 0;
1767 }
1768
1769 p = 0;
1770
1771 if (gtlt === '>') {
1772 gtlt = '>=';
1773
1774 if (xm) {
1775 M = +M + 1;
1776 m = 0;
1777 p = 0;
1778 } else {
1779 m = +m + 1;
1780 p = 0;
1781 }
1782 } else if (gtlt === '<=') {
1783 gtlt = '<';
1784
1785 if (xm) {
1786 M = +M + 1;
1787 } else {
1788 m = +m + 1;
1789 }
1790 }
1791
1792 if (gtlt === '<') pr = '-0';
1793 ret = `${gtlt + M}.${m}.${p}${pr}`;
1794 } else if (xm) {
1795 ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
1796 } else if (xp) {
1797 ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
1798 }
1799
1800 debug_1('xRange return', ret);
1801 return ret;
1802 });
1803};
1804
1805const replaceStars = (comp, options) => {
1806 debug_1('replaceStars', comp, options);
1807 return comp.trim().replace(re$1[t$1.STAR], '');
1808};
1809
1810const replaceGTE0 = (comp, options) => {
1811 debug_1('replaceGTE0', comp, options);
1812 return comp.trim().replace(re$1[options.includePrerelease ? t$1.GTE0PRE : t$1.GTE0], '');
1813};
1814
1815const hyphenReplace = incPr => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) => {
1816 if (isX(fM)) {
1817 from = '';
1818 } else if (isX(fm)) {
1819 from = `>=${fM}.0.0${incPr ? '-0' : ''}`;
1820 } else if (isX(fp)) {
1821 from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}`;
1822 } else if (fpr) {
1823 from = `>=${from}`;
1824 } else {
1825 from = `>=${from}${incPr ? '-0' : ''}`;
1826 }
1827
1828 if (isX(tM)) {
1829 to = '';
1830 } else if (isX(tm)) {
1831 to = `<${+tM + 1}.0.0-0`;
1832 } else if (isX(tp)) {
1833 to = `<${tM}.${+tm + 1}.0-0`;
1834 } else if (tpr) {
1835 to = `<=${tM}.${tm}.${tp}-${tpr}`;
1836 } else if (incPr) {
1837 to = `<${tM}.${tm}.${+tp + 1}-0`;
1838 } else {
1839 to = `<=${to}`;
1840 }
1841
1842 return `${from} ${to}`.trim();
1843};
1844
1845const testSet = (set, version, options) => {
1846 for (let i = 0; i < set.length; i++) {
1847 if (!set[i].test(version)) {
1848 return false;
1849 }
1850 }
1851
1852 if (version.prerelease.length && !options.includePrerelease) {
1853 for (let i = 0; i < set.length; i++) {
1854 debug_1(set[i].semver);
1855
1856 if (set[i].semver === comparator.ANY) {
1857 continue;
1858 }
1859
1860 if (set[i].semver.prerelease.length > 0) {
1861 const allowed = set[i].semver;
1862
1863 if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
1864 return true;
1865 }
1866 }
1867 }
1868
1869 return false;
1870 }
1871
1872 return true;
1873};
1874
1875const ANY$2 = Symbol('SemVer ANY');
1876
1877class Comparator {
1878 static get ANY() {
1879 return ANY$2;
1880 }
1881
1882 constructor(comp, options) {
1883 options = parseOptions_1(options);
1884
1885 if (comp instanceof Comparator) {
1886 if (comp.loose === !!options.loose) {
1887 return comp;
1888 } else {
1889 comp = comp.value;
1890 }
1891 }
1892
1893 debug_1('comparator', comp, options);
1894 this.options = options;
1895 this.loose = !!options.loose;
1896 this.parse(comp);
1897
1898 if (this.semver === ANY$2) {
1899 this.value = '';
1900 } else {
1901 this.value = this.operator + this.semver.version;
1902 }
1903
1904 debug_1('comp', this);
1905 }
1906
1907 parse(comp) {
1908 const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
1909 const m = comp.match(r);
1910
1911 if (!m) {
1912 throw new TypeError(`Invalid comparator: ${comp}`);
1913 }
1914
1915 this.operator = m[1] !== undefined ? m[1] : '';
1916
1917 if (this.operator === '=') {
1918 this.operator = '';
1919 }
1920
1921 if (!m[2]) {
1922 this.semver = ANY$2;
1923 } else {
1924 this.semver = new semver$1(m[2], this.options.loose);
1925 }
1926 }
1927
1928 toString() {
1929 return this.value;
1930 }
1931
1932 test(version) {
1933 debug_1('Comparator.test', version, this.options.loose);
1934
1935 if (this.semver === ANY$2 || version === ANY$2) {
1936 return true;
1937 }
1938
1939 if (typeof version === 'string') {
1940 try {
1941 version = new semver$1(version, this.options);
1942 } catch (er) {
1943 return false;
1944 }
1945 }
1946
1947 return cmp_1(version, this.operator, this.semver, this.options);
1948 }
1949
1950 intersects(comp, options) {
1951 if (!(comp instanceof Comparator)) {
1952 throw new TypeError('a Comparator is required');
1953 }
1954
1955 if (!options || typeof options !== 'object') {
1956 options = {
1957 loose: !!options,
1958 includePrerelease: false
1959 };
1960 }
1961
1962 if (this.operator === '') {
1963 if (this.value === '') {
1964 return true;
1965 }
1966
1967 return new range(comp.value, options).test(this.value);
1968 } else if (comp.operator === '') {
1969 if (comp.value === '') {
1970 return true;
1971 }
1972
1973 return new range(this.value, options).test(comp.semver);
1974 }
1975
1976 const sameDirectionIncreasing = (this.operator === '>=' || this.operator === '>') && (comp.operator === '>=' || comp.operator === '>');
1977 const sameDirectionDecreasing = (this.operator === '<=' || this.operator === '<') && (comp.operator === '<=' || comp.operator === '<');
1978 const sameSemVer = this.semver.version === comp.semver.version;
1979 const differentDirectionsInclusive = (this.operator === '>=' || this.operator === '<=') && (comp.operator === '>=' || comp.operator === '<=');
1980 const oppositeDirectionsLessThan = cmp_1(this.semver, '<', comp.semver, options) && (this.operator === '>=' || this.operator === '>') && (comp.operator === '<=' || comp.operator === '<');
1981 const oppositeDirectionsGreaterThan = cmp_1(this.semver, '>', comp.semver, options) && (this.operator === '<=' || this.operator === '<') && (comp.operator === '>=' || comp.operator === '>');
1982 return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan;
1983 }
1984
1985}
1986
1987var comparator = Comparator;
1988const {
1989 re,
1990 t
1991} = re_1;
1992
1993const satisfies = (version, range$1, options) => {
1994 try {
1995 range$1 = new range(range$1, options);
1996 } catch (er) {
1997 return false;
1998 }
1999
2000 return range$1.test(version);
2001};
2002
2003var satisfies_1 = satisfies;
2004
2005const toComparators = (range$1, options) => new range(range$1, options).set.map(comp => comp.map(c => c.value).join(' ').trim().split(' '));
2006
2007var toComparators_1 = toComparators;
2008
2009const maxSatisfying = (versions, range$1, options) => {
2010 let max = null;
2011 let maxSV = null;
2012 let rangeObj = null;
2013
2014 try {
2015 rangeObj = new range(range$1, options);
2016 } catch (er) {
2017 return null;
2018 }
2019
2020 versions.forEach(v => {
2021 if (rangeObj.test(v)) {
2022 if (!max || maxSV.compare(v) === -1) {
2023 max = v;
2024 maxSV = new semver$1(max, options);
2025 }
2026 }
2027 });
2028 return max;
2029};
2030
2031var maxSatisfying_1 = maxSatisfying;
2032
2033const minSatisfying = (versions, range$1, options) => {
2034 let min = null;
2035 let minSV = null;
2036 let rangeObj = null;
2037
2038 try {
2039 rangeObj = new range(range$1, options);
2040 } catch (er) {
2041 return null;
2042 }
2043
2044 versions.forEach(v => {
2045 if (rangeObj.test(v)) {
2046 if (!min || minSV.compare(v) === 1) {
2047 min = v;
2048 minSV = new semver$1(min, options);
2049 }
2050 }
2051 });
2052 return min;
2053};
2054
2055var minSatisfying_1 = minSatisfying;
2056
2057const minVersion = (range$1, loose) => {
2058 range$1 = new range(range$1, loose);
2059 let minver = new semver$1('0.0.0');
2060
2061 if (range$1.test(minver)) {
2062 return minver;
2063 }
2064
2065 minver = new semver$1('0.0.0-0');
2066
2067 if (range$1.test(minver)) {
2068 return minver;
2069 }
2070
2071 minver = null;
2072
2073 for (let i = 0; i < range$1.set.length; ++i) {
2074 const comparators = range$1.set[i];
2075 let setMin = null;
2076 comparators.forEach(comparator => {
2077 const compver = new semver$1(comparator.semver.version);
2078
2079 switch (comparator.operator) {
2080 case '>':
2081 if (compver.prerelease.length === 0) {
2082 compver.patch++;
2083 } else {
2084 compver.prerelease.push(0);
2085 }
2086
2087 compver.raw = compver.format();
2088
2089 case '':
2090 case '>=':
2091 if (!setMin || gt_1(compver, setMin)) {
2092 setMin = compver;
2093 }
2094
2095 break;
2096
2097 case '<':
2098 case '<=':
2099 break;
2100
2101 default:
2102 throw new Error(`Unexpected operation: ${comparator.operator}`);
2103 }
2104 });
2105 if (setMin && (!minver || gt_1(minver, setMin))) minver = setMin;
2106 }
2107
2108 if (minver && range$1.test(minver)) {
2109 return minver;
2110 }
2111
2112 return null;
2113};
2114
2115var minVersion_1 = minVersion;
2116
2117const validRange = (range$1, options) => {
2118 try {
2119 return new range(range$1, options).range || '*';
2120 } catch (er) {
2121 return null;
2122 }
2123};
2124
2125var valid = validRange;
2126const {
2127 ANY: ANY$1
2128} = comparator;
2129
2130const outside = (version, range$1, hilo, options) => {
2131 version = new semver$1(version, options);
2132 range$1 = new range(range$1, options);
2133 let gtfn, ltefn, ltfn, comp, ecomp;
2134
2135 switch (hilo) {
2136 case '>':
2137 gtfn = gt_1;
2138 ltefn = lte_1;
2139 ltfn = lt_1;
2140 comp = '>';
2141 ecomp = '>=';
2142 break;
2143
2144 case '<':
2145 gtfn = lt_1;
2146 ltefn = gte_1;
2147 ltfn = gt_1;
2148 comp = '<';
2149 ecomp = '<=';
2150 break;
2151
2152 default:
2153 throw new TypeError('Must provide a hilo val of "<" or ">"');
2154 }
2155
2156 if (satisfies_1(version, range$1, options)) {
2157 return false;
2158 }
2159
2160 for (let i = 0; i < range$1.set.length; ++i) {
2161 const comparators = range$1.set[i];
2162 let high = null;
2163 let low = null;
2164 comparators.forEach(comparator$1 => {
2165 if (comparator$1.semver === ANY$1) {
2166 comparator$1 = new comparator('>=0.0.0');
2167 }
2168
2169 high = high || comparator$1;
2170 low = low || comparator$1;
2171
2172 if (gtfn(comparator$1.semver, high.semver, options)) {
2173 high = comparator$1;
2174 } else if (ltfn(comparator$1.semver, low.semver, options)) {
2175 low = comparator$1;
2176 }
2177 });
2178
2179 if (high.operator === comp || high.operator === ecomp) {
2180 return false;
2181 }
2182
2183 if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
2184 return false;
2185 } else if (low.operator === ecomp && ltfn(version, low.semver)) {
2186 return false;
2187 }
2188 }
2189
2190 return true;
2191};
2192
2193var outside_1 = outside;
2194
2195const gtr = (version, range, options) => outside_1(version, range, '>', options);
2196
2197var gtr_1 = gtr;
2198
2199const ltr = (version, range, options) => outside_1(version, range, '<', options);
2200
2201var ltr_1 = ltr;
2202
2203const intersects = (r1, r2, options) => {
2204 r1 = new range(r1, options);
2205 r2 = new range(r2, options);
2206 return r1.intersects(r2);
2207};
2208
2209var intersects_1 = intersects;
2210
2211var simplify = (versions, range, options) => {
2212 const set = [];
2213 let min = null;
2214 let prev = null;
2215 const v = versions.sort((a, b) => compare_1(a, b, options));
2216
2217 for (const version of v) {
2218 const included = satisfies_1(version, range, options);
2219
2220 if (included) {
2221 prev = version;
2222 if (!min) min = version;
2223 } else {
2224 if (prev) {
2225 set.push([min, prev]);
2226 }
2227
2228 prev = null;
2229 min = null;
2230 }
2231 }
2232
2233 if (min) set.push([min, null]);
2234 const ranges = [];
2235
2236 for (const [min, max] of set) {
2237 if (min === max) ranges.push(min);else if (!max && min === v[0]) ranges.push('*');else if (!max) ranges.push(`>=${min}`);else if (min === v[0]) ranges.push(`<=${max}`);else ranges.push(`${min} - ${max}`);
2238 }
2239
2240 const simplified = ranges.join(' || ');
2241 const original = typeof range.raw === 'string' ? range.raw : String(range);
2242 return simplified.length < original.length ? simplified : range;
2243};
2244
2245const {
2246 ANY
2247} = comparator;
2248
2249const subset = (sub, dom, options = {}) => {
2250 if (sub === dom) return true;
2251 sub = new range(sub, options);
2252 dom = new range(dom, options);
2253 let sawNonNull = false;
2254
2255 OUTER: for (const simpleSub of sub.set) {
2256 for (const simpleDom of dom.set) {
2257 const isSub = simpleSubset(simpleSub, simpleDom, options);
2258 sawNonNull = sawNonNull || isSub !== null;
2259 if (isSub) continue OUTER;
2260 }
2261
2262 if (sawNonNull) return false;
2263 }
2264
2265 return true;
2266};
2267
2268const simpleSubset = (sub, dom, options) => {
2269 if (sub === dom) return true;
2270
2271 if (sub.length === 1 && sub[0].semver === ANY) {
2272 if (dom.length === 1 && dom[0].semver === ANY) return true;else if (options.includePrerelease) sub = [new comparator('>=0.0.0-0')];else sub = [new comparator('>=0.0.0')];
2273 }
2274
2275 if (dom.length === 1 && dom[0].semver === ANY) {
2276 if (options.includePrerelease) return true;else dom = [new comparator('>=0.0.0')];
2277 }
2278
2279 const eqSet = new Set();
2280 let gt, lt;
2281
2282 for (const c of sub) {
2283 if (c.operator === '>' || c.operator === '>=') gt = higherGT(gt, c, options);else if (c.operator === '<' || c.operator === '<=') lt = lowerLT(lt, c, options);else eqSet.add(c.semver);
2284 }
2285
2286 if (eqSet.size > 1) return null;
2287 let gtltComp;
2288
2289 if (gt && lt) {
2290 gtltComp = compare_1(gt.semver, lt.semver, options);
2291 if (gtltComp > 0) return null;else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) return null;
2292 }
2293
2294 for (const eq of eqSet) {
2295 if (gt && !satisfies_1(eq, String(gt), options)) return null;
2296 if (lt && !satisfies_1(eq, String(lt), options)) return null;
2297
2298 for (const c of dom) {
2299 if (!satisfies_1(eq, String(c), options)) return false;
2300 }
2301
2302 return true;
2303 }
2304
2305 let higher, lower;
2306 let hasDomLT, hasDomGT;
2307 let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false;
2308 let needDomGTPre = gt && !options.includePrerelease && gt.semver.prerelease.length ? gt.semver : false;
2309
2310 if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === '<' && needDomLTPre.prerelease[0] === 0) {
2311 needDomLTPre = false;
2312 }
2313
2314 for (const c of dom) {
2315 hasDomGT = hasDomGT || c.operator === '>' || c.operator === '>=';
2316 hasDomLT = hasDomLT || c.operator === '<' || c.operator === '<=';
2317
2318 if (gt) {
2319 if (needDomGTPre) {
2320 if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch) {
2321 needDomGTPre = false;
2322 }
2323 }
2324
2325 if (c.operator === '>' || c.operator === '>=') {
2326 higher = higherGT(gt, c, options);
2327 if (higher === c && higher !== gt) return false;
2328 } else if (gt.operator === '>=' && !satisfies_1(gt.semver, String(c), options)) return false;
2329 }
2330
2331 if (lt) {
2332 if (needDomLTPre) {
2333 if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) {
2334 needDomLTPre = false;
2335 }
2336 }
2337
2338 if (c.operator === '<' || c.operator === '<=') {
2339 lower = lowerLT(lt, c, options);
2340 if (lower === c && lower !== lt) return false;
2341 } else if (lt.operator === '<=' && !satisfies_1(lt.semver, String(c), options)) return false;
2342 }
2343
2344 if (!c.operator && (lt || gt) && gtltComp !== 0) return false;
2345 }
2346
2347 if (gt && hasDomLT && !lt && gtltComp !== 0) return false;
2348 if (lt && hasDomGT && !gt && gtltComp !== 0) return false;
2349 if (needDomGTPre || needDomLTPre) return false;
2350 return true;
2351};
2352
2353const higherGT = (a, b, options) => {
2354 if (!a) return b;
2355 const comp = compare_1(a.semver, b.semver, options);
2356 return comp > 0 ? a : comp < 0 ? b : b.operator === '>' && a.operator === '>=' ? b : a;
2357};
2358
2359const lowerLT = (a, b, options) => {
2360 if (!a) return b;
2361 const comp = compare_1(a.semver, b.semver, options);
2362 return comp < 0 ? a : comp > 0 ? b : b.operator === '<' && a.operator === '<=' ? b : a;
2363};
2364
2365var subset_1 = subset;
2366var semver = {
2367 re: re_1.re,
2368 src: re_1.src,
2369 tokens: re_1.t,
2370 SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
2371 SemVer: semver$1,
2372 compareIdentifiers: identifiers.compareIdentifiers,
2373 rcompareIdentifiers: identifiers.rcompareIdentifiers,
2374 parse: parse_1,
2375 valid: valid_1,
2376 clean: clean_1,
2377 inc: inc_1,
2378 diff: diff_1,
2379 major: major_1,
2380 minor: minor_1,
2381 patch: patch_1,
2382 prerelease: prerelease_1,
2383 compare: compare_1,
2384 rcompare: rcompare_1,
2385 compareLoose: compareLoose_1,
2386 compareBuild: compareBuild_1,
2387 sort: sort_1,
2388 rsort: rsort_1,
2389 gt: gt_1,
2390 lt: lt_1,
2391 eq: eq_1,
2392 neq: neq_1,
2393 gte: gte_1,
2394 lte: lte_1,
2395 cmp: cmp_1,
2396 coerce: coerce_1,
2397 Comparator: comparator,
2398 Range: range,
2399 satisfies: satisfies_1,
2400 toComparators: toComparators_1,
2401 maxSatisfying: maxSatisfying_1,
2402 minSatisfying: minSatisfying_1,
2403 minVersion: minVersion_1,
2404 validRange: valid,
2405 outside: outside_1,
2406 gtr: gtr_1,
2407 ltr: ltr_1,
2408 intersects: intersects_1,
2409 simplifyRange: simplify,
2410 subset: subset_1
2411};
2412
2413var builtins = function ({
2414 version = process.version,
2415 experimental = false
2416} = {}) {
2417 var coreModules = ['assert', 'buffer', 'child_process', 'cluster', 'console', 'constants', 'crypto', 'dgram', 'dns', 'domain', 'events', 'fs', 'http', 'https', 'module', 'net', 'os', 'path', 'punycode', 'querystring', 'readline', 'repl', 'stream', 'string_decoder', 'sys', 'timers', 'tls', 'tty', 'url', 'util', 'vm', 'zlib'];
2418 if (semver.lt(version, '6.0.0')) coreModules.push('freelist');
2419 if (semver.gte(version, '1.0.0')) coreModules.push('v8');
2420 if (semver.gte(version, '1.1.0')) coreModules.push('process');
2421 if (semver.gte(version, '8.0.0')) coreModules.push('inspector');
2422 if (semver.gte(version, '8.1.0')) coreModules.push('async_hooks');
2423 if (semver.gte(version, '8.4.0')) coreModules.push('http2');
2424 if (semver.gte(version, '8.5.0')) coreModules.push('perf_hooks');
2425 if (semver.gte(version, '10.0.0')) coreModules.push('trace_events');
2426
2427 if (semver.gte(version, '10.5.0') && (experimental || semver.gte(version, '12.0.0'))) {
2428 coreModules.push('worker_threads');
2429 }
2430
2431 if (semver.gte(version, '12.16.0') && experimental) {
2432 coreModules.push('wasi');
2433 }
2434
2435 return coreModules;
2436};
2437
2438const reader = {
2439 read
2440};
2441
2442function read(jsonPath) {
2443 return find(_path().dirname(jsonPath));
2444}
2445
2446function find(dir) {
2447 try {
2448 const string = _fs().default.readFileSync(_path().toNamespacedPath(_path().join(dir, 'package.json')), 'utf8');
2449
2450 return {
2451 string
2452 };
2453 } catch (error) {
2454 if (error.code === 'ENOENT') {
2455 const parent = _path().dirname(dir);
2456
2457 if (dir !== parent) return find(parent);
2458 return {
2459 string: undefined
2460 };
2461 }
2462
2463 throw error;
2464 }
2465}
2466
2467const isWindows = process.platform === 'win32';
2468const own$1 = {}.hasOwnProperty;
2469const codes = {};
2470const messages = new Map();
2471const nodeInternalPrefix = '__node_internal_';
2472let userStackTraceLimit;
2473codes.ERR_INVALID_MODULE_SPECIFIER = createError('ERR_INVALID_MODULE_SPECIFIER', (request, reason, base = undefined) => {
2474 return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ''}`;
2475}, TypeError);
2476codes.ERR_INVALID_PACKAGE_CONFIG = createError('ERR_INVALID_PACKAGE_CONFIG', (path, base, message) => {
2477 return `Invalid package config ${path}${base ? ` while importing ${base}` : ''}${message ? `. ${message}` : ''}`;
2478}, Error);
2479codes.ERR_INVALID_PACKAGE_TARGET = createError('ERR_INVALID_PACKAGE_TARGET', (pkgPath, key, target, isImport = false, base = undefined) => {
2480 const relError = typeof target === 'string' && !isImport && target.length > 0 && !target.startsWith('./');
2481
2482 if (key === '.') {
2483 _assert()(isImport === false);
2484
2485 return `Invalid "exports" main target ${JSON.stringify(target)} defined ` + `in the package config ${pkgPath}package.json${base ? ` imported from ${base}` : ''}${relError ? '; targets must start with "./"' : ''}`;
2486 }
2487
2488 return `Invalid "${isImport ? 'imports' : 'exports'}" target ${JSON.stringify(target)} defined for '${key}' in the package config ${pkgPath}package.json${base ? ` imported from ${base}` : ''}${relError ? '; targets must start with "./"' : ''}`;
2489}, Error);
2490codes.ERR_MODULE_NOT_FOUND = createError('ERR_MODULE_NOT_FOUND', (path, base, type = 'package') => {
2491 return `Cannot find ${type} '${path}' imported from ${base}`;
2492}, Error);
2493codes.ERR_PACKAGE_IMPORT_NOT_DEFINED = createError('ERR_PACKAGE_IMPORT_NOT_DEFINED', (specifier, packagePath, base) => {
2494 return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath}package.json` : ''} imported from ${base}`;
2495}, TypeError);
2496codes.ERR_PACKAGE_PATH_NOT_EXPORTED = createError('ERR_PACKAGE_PATH_NOT_EXPORTED', (pkgPath, subpath, base = undefined) => {
2497 if (subpath === '.') return `No "exports" main defined in ${pkgPath}package.json${base ? ` imported from ${base}` : ''}`;
2498 return `Package subpath '${subpath}' is not defined by "exports" in ${pkgPath}package.json${base ? ` imported from ${base}` : ''}`;
2499}, Error);
2500codes.ERR_UNSUPPORTED_DIR_IMPORT = createError('ERR_UNSUPPORTED_DIR_IMPORT', "Directory import '%s' is not supported " + 'resolving ES modules imported from %s', Error);
2501codes.ERR_UNKNOWN_FILE_EXTENSION = createError('ERR_UNKNOWN_FILE_EXTENSION', 'Unknown file extension "%s" for %s', TypeError);
2502codes.ERR_INVALID_ARG_VALUE = createError('ERR_INVALID_ARG_VALUE', (name, value, reason = 'is invalid') => {
2503 let inspected = (0, _util().inspect)(value);
2504
2505 if (inspected.length > 128) {
2506 inspected = `${inspected.slice(0, 128)}...`;
2507 }
2508
2509 const type = name.includes('.') ? 'property' : 'argument';
2510 return `The ${type} '${name}' ${reason}. Received ${inspected}`;
2511}, TypeError);
2512codes.ERR_UNSUPPORTED_ESM_URL_SCHEME = createError('ERR_UNSUPPORTED_ESM_URL_SCHEME', url => {
2513 let message = 'Only file and data URLs are supported by the default ESM loader';
2514
2515 if (isWindows && url.protocol.length === 2) {
2516 message += '. On Windows, absolute paths must be valid file:// URLs';
2517 }
2518
2519 message += `. Received protocol '${url.protocol}'`;
2520 return message;
2521}, Error);
2522
2523function createError(sym, value, def) {
2524 messages.set(sym, value);
2525 return makeNodeErrorWithCode(def, sym);
2526}
2527
2528function makeNodeErrorWithCode(Base, key) {
2529 return NodeError;
2530
2531 function NodeError(...args) {
2532 const limit = Error.stackTraceLimit;
2533 if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0;
2534 const error = new Base();
2535 if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit;
2536 const message = getMessage(key, args, error);
2537 Object.defineProperty(error, 'message', {
2538 value: message,
2539 enumerable: false,
2540 writable: true,
2541 configurable: true
2542 });
2543 Object.defineProperty(error, 'toString', {
2544 value() {
2545 return `${this.name} [${key}]: ${this.message}`;
2546 },
2547
2548 enumerable: false,
2549 writable: true,
2550 configurable: true
2551 });
2552 addCodeToName(error, Base.name, key);
2553 error.code = key;
2554 return error;
2555 }
2556}
2557
2558const addCodeToName = hideStackFrames(function (error, name, code) {
2559 error = captureLargerStackTrace(error);
2560 error.name = `${name} [${code}]`;
2561 error.stack;
2562
2563 if (name === 'SystemError') {
2564 Object.defineProperty(error, 'name', {
2565 value: name,
2566 enumerable: false,
2567 writable: true,
2568 configurable: true
2569 });
2570 } else {
2571 delete error.name;
2572 }
2573});
2574
2575function isErrorStackTraceLimitWritable() {
2576 const desc = Object.getOwnPropertyDescriptor(Error, 'stackTraceLimit');
2577
2578 if (desc === undefined) {
2579 return Object.isExtensible(Error);
2580 }
2581
2582 return own$1.call(desc, 'writable') ? desc.writable : desc.set !== undefined;
2583}
2584
2585function hideStackFrames(fn) {
2586 const hidden = nodeInternalPrefix + fn.name;
2587 Object.defineProperty(fn, 'name', {
2588 value: hidden
2589 });
2590 return fn;
2591}
2592
2593const captureLargerStackTrace = hideStackFrames(function (error) {
2594 const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
2595
2596 if (stackTraceLimitIsWritable) {
2597 userStackTraceLimit = Error.stackTraceLimit;
2598 Error.stackTraceLimit = Number.POSITIVE_INFINITY;
2599 }
2600
2601 Error.captureStackTrace(error);
2602 if (stackTraceLimitIsWritable) Error.stackTraceLimit = userStackTraceLimit;
2603 return error;
2604});
2605
2606function getMessage(key, args, self) {
2607 const message = messages.get(key);
2608
2609 if (typeof message === 'function') {
2610 _assert()(message.length <= args.length, `Code: ${key}; The provided arguments length (${args.length}) does not ` + `match the required ones (${message.length}).`);
2611
2612 return Reflect.apply(message, self, args);
2613 }
2614
2615 const expectedLength = (message.match(/%[dfijoOs]/g) || []).length;
2616
2617 _assert()(expectedLength === args.length, `Code: ${key}; The provided arguments length (${args.length}) does not ` + `match the required ones (${expectedLength}).`);
2618
2619 if (args.length === 0) return message;
2620 args.unshift(message);
2621 return Reflect.apply(_util().format, null, args);
2622}
2623
2624const {
2625 ERR_UNKNOWN_FILE_EXTENSION
2626} = codes;
2627const extensionFormatMap = {
2628 __proto__: null,
2629 '.cjs': 'commonjs',
2630 '.js': 'module',
2631 '.mjs': 'module'
2632};
2633
2634function defaultGetFormat(url) {
2635 if (url.startsWith('node:')) {
2636 return {
2637 format: 'builtin'
2638 };
2639 }
2640
2641 const parsed = new (_url().URL)(url);
2642
2643 if (parsed.protocol === 'data:') {
2644 const {
2645 1: mime
2646 } = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(parsed.pathname) || [null, null];
2647 const format = mime === 'text/javascript' ? 'module' : null;
2648 return {
2649 format
2650 };
2651 }
2652
2653 if (parsed.protocol === 'file:') {
2654 const ext = _path().extname(parsed.pathname);
2655
2656 let format;
2657
2658 if (ext === '.js') {
2659 format = getPackageType(parsed.href) === 'module' ? 'module' : 'commonjs';
2660 } else {
2661 format = extensionFormatMap[ext];
2662 }
2663
2664 if (!format) {
2665 throw new ERR_UNKNOWN_FILE_EXTENSION(ext, (0, _url().fileURLToPath)(url));
2666 }
2667
2668 return {
2669 format: format || null
2670 };
2671 }
2672
2673 return {
2674 format: null
2675 };
2676}
2677
2678const listOfBuiltins = builtins();
2679const {
2680 ERR_INVALID_MODULE_SPECIFIER,
2681 ERR_INVALID_PACKAGE_CONFIG,
2682 ERR_INVALID_PACKAGE_TARGET,
2683 ERR_MODULE_NOT_FOUND,
2684 ERR_PACKAGE_IMPORT_NOT_DEFINED,
2685 ERR_PACKAGE_PATH_NOT_EXPORTED,
2686 ERR_UNSUPPORTED_DIR_IMPORT,
2687 ERR_UNSUPPORTED_ESM_URL_SCHEME,
2688 ERR_INVALID_ARG_VALUE
2689} = codes;
2690const own = {}.hasOwnProperty;
2691const DEFAULT_CONDITIONS = Object.freeze(['node', 'import']);
2692const DEFAULT_CONDITIONS_SET = new Set(DEFAULT_CONDITIONS);
2693const invalidSegmentRegEx = /(^|\\|\/)(\.\.?|node_modules)(\\|\/|$)/;
2694const patternRegEx = /\*/g;
2695const encodedSepRegEx = /%2f|%2c/i;
2696const emittedPackageWarnings = new Set();
2697const packageJsonCache = new Map();
2698
2699function emitFolderMapDeprecation(match, pjsonUrl, isExports, base) {
2700 const pjsonPath = (0, _url().fileURLToPath)(pjsonUrl);
2701 if (emittedPackageWarnings.has(pjsonPath + '|' + match)) return;
2702 emittedPackageWarnings.add(pjsonPath + '|' + match);
2703 process.emitWarning(`Use of deprecated folder mapping "${match}" in the ${isExports ? '"exports"' : '"imports"'} field module resolution of the package at ${pjsonPath}${base ? ` imported from ${(0, _url().fileURLToPath)(base)}` : ''}.\n` + `Update this package.json to use a subpath pattern like "${match}*".`, 'DeprecationWarning', 'DEP0148');
2704}
2705
2706function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
2707 const {
2708 format
2709 } = defaultGetFormat(url.href);
2710 if (format !== 'module') return;
2711 const path = (0, _url().fileURLToPath)(url.href);
2712 const pkgPath = (0, _url().fileURLToPath)(new (_url().URL)('.', packageJsonUrl));
2713 const basePath = (0, _url().fileURLToPath)(base);
2714 if (main) process.emitWarning(`Package ${pkgPath} has a "main" field set to ${JSON.stringify(main)}, ` + `excluding the full filename and extension to the resolved file at "${path.slice(pkgPath.length)}", imported from ${basePath}.\n Automatic extension resolution of the "main" field is` + 'deprecated for ES modules.', 'DeprecationWarning', 'DEP0151');else process.emitWarning(`No "main" or "exports" field defined in the package.json for ${pkgPath} resolving the main entry point "${path.slice(pkgPath.length)}", imported from ${basePath}.\nDefault "index" lookups for the main are deprecated for ES modules.`, 'DeprecationWarning', 'DEP0151');
2715}
2716
2717function getConditionsSet(conditions) {
2718 if (conditions !== undefined && conditions !== DEFAULT_CONDITIONS) {
2719 if (!Array.isArray(conditions)) {
2720 throw new ERR_INVALID_ARG_VALUE('conditions', conditions, 'expected an array');
2721 }
2722
2723 return new Set(conditions);
2724 }
2725
2726 return DEFAULT_CONDITIONS_SET;
2727}
2728
2729function tryStatSync(path) {
2730 try {
2731 return (0, _fs().statSync)(path);
2732 } catch (_unused) {
2733 return new (_fs().Stats)();
2734 }
2735}
2736
2737function getPackageConfig(path, specifier, base) {
2738 const existing = packageJsonCache.get(path);
2739
2740 if (existing !== undefined) {
2741 return existing;
2742 }
2743
2744 const source = reader.read(path).string;
2745
2746 if (source === undefined) {
2747 const packageConfig = {
2748 pjsonPath: path,
2749 exists: false,
2750 main: undefined,
2751 name: undefined,
2752 type: 'none',
2753 exports: undefined,
2754 imports: undefined
2755 };
2756 packageJsonCache.set(path, packageConfig);
2757 return packageConfig;
2758 }
2759
2760 let packageJson;
2761
2762 try {
2763 packageJson = JSON.parse(source);
2764 } catch (error) {
2765 throw new ERR_INVALID_PACKAGE_CONFIG(path, (base ? `"${specifier}" from ` : '') + (0, _url().fileURLToPath)(base || specifier), error.message);
2766 }
2767
2768 const {
2769 exports,
2770 imports,
2771 main,
2772 name,
2773 type
2774 } = packageJson;
2775 const packageConfig = {
2776 pjsonPath: path,
2777 exists: true,
2778 main: typeof main === 'string' ? main : undefined,
2779 name: typeof name === 'string' ? name : undefined,
2780 type: type === 'module' || type === 'commonjs' ? type : 'none',
2781 exports,
2782 imports: imports && typeof imports === 'object' ? imports : undefined
2783 };
2784 packageJsonCache.set(path, packageConfig);
2785 return packageConfig;
2786}
2787
2788function getPackageScopeConfig(resolved) {
2789 let packageJsonUrl = new (_url().URL)('./package.json', resolved);
2790
2791 while (true) {
2792 const packageJsonPath = packageJsonUrl.pathname;
2793 if (packageJsonPath.endsWith('node_modules/package.json')) break;
2794 const packageConfig = getPackageConfig((0, _url().fileURLToPath)(packageJsonUrl), resolved);
2795 if (packageConfig.exists) return packageConfig;
2796 const lastPackageJsonUrl = packageJsonUrl;
2797 packageJsonUrl = new (_url().URL)('../package.json', packageJsonUrl);
2798 if (packageJsonUrl.pathname === lastPackageJsonUrl.pathname) break;
2799 }
2800
2801 const packageJsonPath = (0, _url().fileURLToPath)(packageJsonUrl);
2802 const packageConfig = {
2803 pjsonPath: packageJsonPath,
2804 exists: false,
2805 main: undefined,
2806 name: undefined,
2807 type: 'none',
2808 exports: undefined,
2809 imports: undefined
2810 };
2811 packageJsonCache.set(packageJsonPath, packageConfig);
2812 return packageConfig;
2813}
2814
2815function fileExists(url) {
2816 return tryStatSync((0, _url().fileURLToPath)(url)).isFile();
2817}
2818
2819function legacyMainResolve(packageJsonUrl, packageConfig, base) {
2820 let guess;
2821
2822 if (packageConfig.main !== undefined) {
2823 guess = new (_url().URL)(`./${packageConfig.main}`, packageJsonUrl);
2824 if (fileExists(guess)) return guess;
2825 const tries = [`./${packageConfig.main}.js`, `./${packageConfig.main}.json`, `./${packageConfig.main}.node`, `./${packageConfig.main}/index.js`, `./${packageConfig.main}/index.json`, `./${packageConfig.main}/index.node`];
2826 let i = -1;
2827
2828 while (++i < tries.length) {
2829 guess = new (_url().URL)(tries[i], packageJsonUrl);
2830 if (fileExists(guess)) break;
2831 guess = undefined;
2832 }
2833
2834 if (guess) {
2835 emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
2836 return guess;
2837 }
2838 }
2839
2840 const tries = ['./index.js', './index.json', './index.node'];
2841 let i = -1;
2842
2843 while (++i < tries.length) {
2844 guess = new (_url().URL)(tries[i], packageJsonUrl);
2845 if (fileExists(guess)) break;
2846 guess = undefined;
2847 }
2848
2849 if (guess) {
2850 emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
2851 return guess;
2852 }
2853
2854 throw new ERR_MODULE_NOT_FOUND((0, _url().fileURLToPath)(new (_url().URL)('.', packageJsonUrl)), (0, _url().fileURLToPath)(base));
2855}
2856
2857function finalizeResolution(resolved, base) {
2858 if (encodedSepRegEx.test(resolved.pathname)) throw new ERR_INVALID_MODULE_SPECIFIER(resolved.pathname, 'must not include encoded "/" or "\\" characters', (0, _url().fileURLToPath)(base));
2859 const path = (0, _url().fileURLToPath)(resolved);
2860 const stats = tryStatSync(path.endsWith('/') ? path.slice(-1) : path);
2861
2862 if (stats.isDirectory()) {
2863 const error = new ERR_UNSUPPORTED_DIR_IMPORT(path, (0, _url().fileURLToPath)(base));
2864 error.url = String(resolved);
2865 throw error;
2866 }
2867
2868 if (!stats.isFile()) {
2869 throw new ERR_MODULE_NOT_FOUND(path || resolved.pathname, base && (0, _url().fileURLToPath)(base), 'module');
2870 }
2871
2872 return resolved;
2873}
2874
2875function throwImportNotDefined(specifier, packageJsonUrl, base) {
2876 throw new ERR_PACKAGE_IMPORT_NOT_DEFINED(specifier, packageJsonUrl && (0, _url().fileURLToPath)(new (_url().URL)('.', packageJsonUrl)), (0, _url().fileURLToPath)(base));
2877}
2878
2879function throwExportsNotFound(subpath, packageJsonUrl, base) {
2880 throw new ERR_PACKAGE_PATH_NOT_EXPORTED((0, _url().fileURLToPath)(new (_url().URL)('.', packageJsonUrl)), subpath, base && (0, _url().fileURLToPath)(base));
2881}
2882
2883function throwInvalidSubpath(subpath, packageJsonUrl, internal, base) {
2884 const reason = `request is not a valid subpath for the "${internal ? 'imports' : 'exports'}" resolution of ${(0, _url().fileURLToPath)(packageJsonUrl)}`;
2885 throw new ERR_INVALID_MODULE_SPECIFIER(subpath, reason, base && (0, _url().fileURLToPath)(base));
2886}
2887
2888function throwInvalidPackageTarget(subpath, target, packageJsonUrl, internal, base) {
2889 target = typeof target === 'object' && target !== null ? JSON.stringify(target, null, '') : `${target}`;
2890 throw new ERR_INVALID_PACKAGE_TARGET((0, _url().fileURLToPath)(new (_url().URL)('.', packageJsonUrl)), subpath, target, internal, base && (0, _url().fileURLToPath)(base));
2891}
2892
2893function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base, pattern, internal, conditions) {
2894 if (subpath !== '' && !pattern && target[target.length - 1] !== '/') throwInvalidPackageTarget(match, target, packageJsonUrl, internal, base);
2895
2896 if (!target.startsWith('./')) {
2897 if (internal && !target.startsWith('../') && !target.startsWith('/')) {
2898 let isURL = false;
2899
2900 try {
2901 new (_url().URL)(target);
2902 isURL = true;
2903 } catch (_unused2) {}
2904
2905 if (!isURL) {
2906 const exportTarget = pattern ? target.replace(patternRegEx, subpath) : target + subpath;
2907 return packageResolve(exportTarget, packageJsonUrl, conditions);
2908 }
2909 }
2910
2911 throwInvalidPackageTarget(match, target, packageJsonUrl, internal, base);
2912 }
2913
2914 if (invalidSegmentRegEx.test(target.slice(2))) throwInvalidPackageTarget(match, target, packageJsonUrl, internal, base);
2915 const resolved = new (_url().URL)(target, packageJsonUrl);
2916 const resolvedPath = resolved.pathname;
2917 const packagePath = new (_url().URL)('.', packageJsonUrl).pathname;
2918 if (!resolvedPath.startsWith(packagePath)) throwInvalidPackageTarget(match, target, packageJsonUrl, internal, base);
2919 if (subpath === '') return resolved;
2920 if (invalidSegmentRegEx.test(subpath)) throwInvalidSubpath(match + subpath, packageJsonUrl, internal, base);
2921 if (pattern) return new (_url().URL)(resolved.href.replace(patternRegEx, subpath));
2922 return new (_url().URL)(subpath, resolved);
2923}
2924
2925function isArrayIndex(key) {
2926 const keyNumber = Number(key);
2927 if (`${keyNumber}` !== key) return false;
2928 return keyNumber >= 0 && keyNumber < 0xffffffff;
2929}
2930
2931function resolvePackageTarget(packageJsonUrl, target, subpath, packageSubpath, base, pattern, internal, conditions) {
2932 if (typeof target === 'string') {
2933 return resolvePackageTargetString(target, subpath, packageSubpath, packageJsonUrl, base, pattern, internal, conditions);
2934 }
2935
2936 if (Array.isArray(target)) {
2937 const targetList = target;
2938 if (targetList.length === 0) return null;
2939 let lastException;
2940 let i = -1;
2941
2942 while (++i < targetList.length) {
2943 const targetItem = targetList[i];
2944 let resolved;
2945
2946 try {
2947 resolved = resolvePackageTarget(packageJsonUrl, targetItem, subpath, packageSubpath, base, pattern, internal, conditions);
2948 } catch (error) {
2949 lastException = error;
2950 if (error.code === 'ERR_INVALID_PACKAGE_TARGET') continue;
2951 throw error;
2952 }
2953
2954 if (resolved === undefined) continue;
2955
2956 if (resolved === null) {
2957 lastException = null;
2958 continue;
2959 }
2960
2961 return resolved;
2962 }
2963
2964 if (lastException === undefined || lastException === null) {
2965 return lastException;
2966 }
2967
2968 throw lastException;
2969 }
2970
2971 if (typeof target === 'object' && target !== null) {
2972 const keys = Object.getOwnPropertyNames(target);
2973 let i = -1;
2974
2975 while (++i < keys.length) {
2976 const key = keys[i];
2977
2978 if (isArrayIndex(key)) {
2979 throw new ERR_INVALID_PACKAGE_CONFIG((0, _url().fileURLToPath)(packageJsonUrl), base, '"exports" cannot contain numeric property keys.');
2980 }
2981 }
2982
2983 i = -1;
2984
2985 while (++i < keys.length) {
2986 const key = keys[i];
2987
2988 if (key === 'default' || conditions && conditions.has(key)) {
2989 const conditionalTarget = target[key];
2990 const resolved = resolvePackageTarget(packageJsonUrl, conditionalTarget, subpath, packageSubpath, base, pattern, internal, conditions);
2991 if (resolved === undefined) continue;
2992 return resolved;
2993 }
2994 }
2995
2996 return undefined;
2997 }
2998
2999 if (target === null) {
3000 return null;
3001 }
3002
3003 throwInvalidPackageTarget(packageSubpath, target, packageJsonUrl, internal, base);
3004}
3005
3006function isConditionalExportsMainSugar(exports, packageJsonUrl, base) {
3007 if (typeof exports === 'string' || Array.isArray(exports)) return true;
3008 if (typeof exports !== 'object' || exports === null) return false;
3009 const keys = Object.getOwnPropertyNames(exports);
3010 let isConditionalSugar = false;
3011 let i = 0;
3012 let j = -1;
3013
3014 while (++j < keys.length) {
3015 const key = keys[j];
3016 const curIsConditionalSugar = key === '' || key[0] !== '.';
3017
3018 if (i++ === 0) {
3019 isConditionalSugar = curIsConditionalSugar;
3020 } else if (isConditionalSugar !== curIsConditionalSugar) {
3021 throw new ERR_INVALID_PACKAGE_CONFIG((0, _url().fileURLToPath)(packageJsonUrl), base, '"exports" cannot contain some keys starting with \'.\' and some not.' + ' The exports object must either be an object of package subpath keys' + ' or an object of main entry condition name keys only.');
3022 }
3023 }
3024
3025 return isConditionalSugar;
3026}
3027
3028function packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions) {
3029 let exports = packageConfig.exports;
3030 if (isConditionalExportsMainSugar(exports, packageJsonUrl, base)) exports = {
3031 '.': exports
3032 };
3033
3034 if (own.call(exports, packageSubpath)) {
3035 const target = exports[packageSubpath];
3036 const resolved = resolvePackageTarget(packageJsonUrl, target, '', packageSubpath, base, false, false, conditions);
3037 if (resolved === null || resolved === undefined) throwExportsNotFound(packageSubpath, packageJsonUrl, base);
3038 return {
3039 resolved,
3040 exact: true
3041 };
3042 }
3043
3044 let bestMatch = '';
3045 const keys = Object.getOwnPropertyNames(exports);
3046 let i = -1;
3047
3048 while (++i < keys.length) {
3049 const key = keys[i];
3050
3051 if (key[key.length - 1] === '*' && packageSubpath.startsWith(key.slice(0, -1)) && packageSubpath.length >= key.length && key.length > bestMatch.length) {
3052 bestMatch = key;
3053 } else if (key[key.length - 1] === '/' && packageSubpath.startsWith(key) && key.length > bestMatch.length) {
3054 bestMatch = key;
3055 }
3056 }
3057
3058 if (bestMatch) {
3059 const target = exports[bestMatch];
3060 const pattern = bestMatch[bestMatch.length - 1] === '*';
3061 const subpath = packageSubpath.slice(bestMatch.length - (pattern ? 1 : 0));
3062 const resolved = resolvePackageTarget(packageJsonUrl, target, subpath, bestMatch, base, pattern, false, conditions);
3063 if (resolved === null || resolved === undefined) throwExportsNotFound(packageSubpath, packageJsonUrl, base);
3064 if (!pattern) emitFolderMapDeprecation(bestMatch, packageJsonUrl, true, base);
3065 return {
3066 resolved,
3067 exact: pattern
3068 };
3069 }
3070
3071 throwExportsNotFound(packageSubpath, packageJsonUrl, base);
3072}
3073
3074function packageImportsResolve(name, base, conditions) {
3075 if (name === '#' || name.startsWith('#/')) {
3076 const reason = 'is not a valid internal imports specifier name';
3077 throw new ERR_INVALID_MODULE_SPECIFIER(name, reason, (0, _url().fileURLToPath)(base));
3078 }
3079
3080 let packageJsonUrl;
3081 const packageConfig = getPackageScopeConfig(base);
3082
3083 if (packageConfig.exists) {
3084 packageJsonUrl = (0, _url().pathToFileURL)(packageConfig.pjsonPath);
3085 const imports = packageConfig.imports;
3086
3087 if (imports) {
3088 if (own.call(imports, name)) {
3089 const resolved = resolvePackageTarget(packageJsonUrl, imports[name], '', name, base, false, true, conditions);
3090 if (resolved !== null) return {
3091 resolved,
3092 exact: true
3093 };
3094 } else {
3095 let bestMatch = '';
3096 const keys = Object.getOwnPropertyNames(imports);
3097 let i = -1;
3098
3099 while (++i < keys.length) {
3100 const key = keys[i];
3101
3102 if (key[key.length - 1] === '*' && name.startsWith(key.slice(0, -1)) && name.length >= key.length && key.length > bestMatch.length) {
3103 bestMatch = key;
3104 } else if (key[key.length - 1] === '/' && name.startsWith(key) && key.length > bestMatch.length) {
3105 bestMatch = key;
3106 }
3107 }
3108
3109 if (bestMatch) {
3110 const target = imports[bestMatch];
3111 const pattern = bestMatch[bestMatch.length - 1] === '*';
3112 const subpath = name.slice(bestMatch.length - (pattern ? 1 : 0));
3113 const resolved = resolvePackageTarget(packageJsonUrl, target, subpath, bestMatch, base, pattern, true, conditions);
3114
3115 if (resolved !== null) {
3116 if (!pattern) emitFolderMapDeprecation(bestMatch, packageJsonUrl, false, base);
3117 return {
3118 resolved,
3119 exact: pattern
3120 };
3121 }
3122 }
3123 }
3124 }
3125 }
3126
3127 throwImportNotDefined(name, packageJsonUrl, base);
3128}
3129
3130function getPackageType(url) {
3131 const packageConfig = getPackageScopeConfig(url);
3132 return packageConfig.type;
3133}
3134
3135function parsePackageName(specifier, base) {
3136 let separatorIndex = specifier.indexOf('/');
3137 let validPackageName = true;
3138 let isScoped = false;
3139
3140 if (specifier[0] === '@') {
3141 isScoped = true;
3142
3143 if (separatorIndex === -1 || specifier.length === 0) {
3144 validPackageName = false;
3145 } else {
3146 separatorIndex = specifier.indexOf('/', separatorIndex + 1);
3147 }
3148 }
3149
3150 const packageName = separatorIndex === -1 ? specifier : specifier.slice(0, separatorIndex);
3151 let i = -1;
3152
3153 while (++i < packageName.length) {
3154 if (packageName[i] === '%' || packageName[i] === '\\') {
3155 validPackageName = false;
3156 break;
3157 }
3158 }
3159
3160 if (!validPackageName) {
3161 throw new ERR_INVALID_MODULE_SPECIFIER(specifier, 'is not a valid package name', (0, _url().fileURLToPath)(base));
3162 }
3163
3164 const packageSubpath = '.' + (separatorIndex === -1 ? '' : specifier.slice(separatorIndex));
3165 return {
3166 packageName,
3167 packageSubpath,
3168 isScoped
3169 };
3170}
3171
3172function packageResolve(specifier, base, conditions) {
3173 const {
3174 packageName,
3175 packageSubpath,
3176 isScoped
3177 } = parsePackageName(specifier, base);
3178 const packageConfig = getPackageScopeConfig(base);
3179
3180 if (packageConfig.exists) {
3181 const packageJsonUrl = (0, _url().pathToFileURL)(packageConfig.pjsonPath);
3182
3183 if (packageConfig.name === packageName && packageConfig.exports !== undefined && packageConfig.exports !== null) {
3184 return packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions).resolved;
3185 }
3186 }
3187
3188 let packageJsonUrl = new (_url().URL)('./node_modules/' + packageName + '/package.json', base);
3189 let packageJsonPath = (0, _url().fileURLToPath)(packageJsonUrl);
3190 let lastPath;
3191
3192 do {
3193 const stat = tryStatSync(packageJsonPath.slice(0, -13));
3194
3195 if (!stat.isDirectory()) {
3196 lastPath = packageJsonPath;
3197 packageJsonUrl = new (_url().URL)((isScoped ? '../../../../node_modules/' : '../../../node_modules/') + packageName + '/package.json', packageJsonUrl);
3198 packageJsonPath = (0, _url().fileURLToPath)(packageJsonUrl);
3199 continue;
3200 }
3201
3202 const packageConfig = getPackageConfig(packageJsonPath, specifier, base);
3203 if (packageConfig.exports !== undefined && packageConfig.exports !== null) return packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions).resolved;
3204 if (packageSubpath === '.') return legacyMainResolve(packageJsonUrl, packageConfig, base);
3205 return new (_url().URL)(packageSubpath, packageJsonUrl);
3206 } while (packageJsonPath.length !== lastPath.length);
3207
3208 throw new ERR_MODULE_NOT_FOUND(packageName, (0, _url().fileURLToPath)(base));
3209}
3210
3211function isRelativeSpecifier(specifier) {
3212 if (specifier[0] === '.') {
3213 if (specifier.length === 1 || specifier[1] === '/') return true;
3214
3215 if (specifier[1] === '.' && (specifier.length === 2 || specifier[2] === '/')) {
3216 return true;
3217 }
3218 }
3219
3220 return false;
3221}
3222
3223function shouldBeTreatedAsRelativeOrAbsolutePath(specifier) {
3224 if (specifier === '') return false;
3225 if (specifier[0] === '/') return true;
3226 return isRelativeSpecifier(specifier);
3227}
3228
3229function moduleResolve(specifier, base, conditions) {
3230 let resolved;
3231
3232 if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) {
3233 resolved = new (_url().URL)(specifier, base);
3234 } else if (specifier[0] === '#') {
3235 ({
3236 resolved
3237 } = packageImportsResolve(specifier, base, conditions));
3238 } else {
3239 try {
3240 resolved = new (_url().URL)(specifier);
3241 } catch (_unused3) {
3242 resolved = packageResolve(specifier, base, conditions);
3243 }
3244 }
3245
3246 return finalizeResolution(resolved, base);
3247}
3248
3249function defaultResolve(specifier, context = {}) {
3250 const {
3251 parentURL
3252 } = context;
3253 let parsed;
3254
3255 try {
3256 parsed = new (_url().URL)(specifier);
3257
3258 if (parsed.protocol === 'data:') {
3259 return {
3260 url: specifier
3261 };
3262 }
3263 } catch (_unused4) {}
3264
3265 if (parsed && parsed.protocol === 'node:') return {
3266 url: specifier
3267 };
3268 if (parsed && parsed.protocol !== 'file:' && parsed.protocol !== 'data:') throw new ERR_UNSUPPORTED_ESM_URL_SCHEME(parsed);
3269
3270 if (listOfBuiltins.includes(specifier)) {
3271 return {
3272 url: 'node:' + specifier
3273 };
3274 }
3275
3276 if (parentURL.startsWith('data:')) {
3277 new (_url().URL)(specifier, parentURL);
3278 }
3279
3280 const conditions = getConditionsSet(context.conditions);
3281 let url = moduleResolve(specifier, new (_url().URL)(parentURL), conditions);
3282 const urlPath = (0, _url().fileURLToPath)(url);
3283 const real = (0, _fs().realpathSync)(urlPath);
3284 const old = url;
3285 url = (0, _url().pathToFileURL)(real + (urlPath.endsWith(_path().sep) ? '/' : ''));
3286 url.search = old.search;
3287 url.hash = old.hash;
3288 return {
3289 url: `${url}`
3290 };
3291}
3292
3293function resolve(_x, _x2) {
3294 return _resolve.apply(this, arguments);
3295}
3296
3297function _resolve() {
3298 _resolve = _asyncToGenerator(function* (specifier, parent) {
3299 if (!parent) {
3300 throw new Error('Please pass `parent`: `import-meta-resolve` cannot ponyfill that');
3301 }
3302
3303 try {
3304 return defaultResolve(specifier, {
3305 parentURL: parent
3306 }).url;
3307 } catch (error) {
3308 return error.code === 'ERR_UNSUPPORTED_DIR_IMPORT' ? error.url : Promise.reject(error);
3309 }
3310 });
3311 return _resolve.apply(this, arguments);
3312}
\No newline at end of file