UNPKG

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