@leofcoin/chain 1.5.39 → 1.5.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/exports/browser/browser-2c73e2ef-2c73e2ef.js +25 -0
- package/exports/browser/chain.js +3038 -10
- package/exports/browser/{index-34c93510-db72e006.js → index-7dedefe5-b92d7eab.js} +2 -2
- package/exports/browser/{index-526fd466.js → index-c3bd3090.js} +1 -1
- package/exports/browser/{messages-b7f41cba-61105b71.js → messages-7cab2a51-aba26369.js} +2 -2
- package/exports/browser/{node-browser-e7da3b14.js → node-browser-ccc3409e.js} +316 -76
- package/exports/browser/node-browser.js +2 -2
- package/exports/chain.js +12 -9
- package/exports/node-browser.d.ts +1 -0
- package/exports/node.d.ts +1 -0
- package/exports/node.js +1 -0
- package/exports/version-control.d.ts +1 -0
- package/package.json +1 -1
- package/exports/browser/client-493cbd83-493cbd83.js +0 -10783
package/exports/browser/chain.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as BigNumber, L as Logger, v as version$1, h as hexZeroPad, i as isBigNumberish, a as arrayify, b as isBytes, T as TransactionMessage, t as toBase58, C as ContractMessage, R as RawTransactionMessage, c as BlockMessage, d as BWMessage, e as BWRequestMessage } from './index-
|
|
1
|
+
import { B as BigNumber, L as Logger, v as version$1, h as hexZeroPad, i as isBigNumberish, a as arrayify, b as isBytes, T as TransactionMessage, t as toBase58, C as ContractMessage, R as RawTransactionMessage, g as getDefaultExportFromCjs, c as BlockMessage, d as BWMessage, e as BWRequestMessage } from './index-c3bd3090.js';
|
|
2
2
|
|
|
3
3
|
const logger$1 = new Logger(version$1);
|
|
4
4
|
const _constructorGuard = {};
|
|
@@ -468,6 +468,3032 @@ const signTransaction = async (transaction, wallet) => {
|
|
|
468
468
|
return { ...transaction, signature };
|
|
469
469
|
};
|
|
470
470
|
|
|
471
|
+
var re$2 = {exports: {}};
|
|
472
|
+
|
|
473
|
+
// Note: this is the semver.org version of the spec that it implements
|
|
474
|
+
// Not necessarily the package version of this code.
|
|
475
|
+
const SEMVER_SPEC_VERSION = '2.0.0';
|
|
476
|
+
|
|
477
|
+
const MAX_LENGTH$1 = 256;
|
|
478
|
+
const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER ||
|
|
479
|
+
/* istanbul ignore next */ 9007199254740991;
|
|
480
|
+
|
|
481
|
+
// Max safe segment length for coercion.
|
|
482
|
+
const MAX_SAFE_COMPONENT_LENGTH = 16;
|
|
483
|
+
|
|
484
|
+
// Max safe length for a build identifier. The max length minus 6 characters for
|
|
485
|
+
// the shortest version with a build 0.0.0+BUILD.
|
|
486
|
+
const MAX_SAFE_BUILD_LENGTH = MAX_LENGTH$1 - 6;
|
|
487
|
+
|
|
488
|
+
const RELEASE_TYPES = [
|
|
489
|
+
'major',
|
|
490
|
+
'premajor',
|
|
491
|
+
'minor',
|
|
492
|
+
'preminor',
|
|
493
|
+
'patch',
|
|
494
|
+
'prepatch',
|
|
495
|
+
'prerelease',
|
|
496
|
+
];
|
|
497
|
+
|
|
498
|
+
var constants$1 = {
|
|
499
|
+
MAX_LENGTH: MAX_LENGTH$1,
|
|
500
|
+
MAX_SAFE_COMPONENT_LENGTH,
|
|
501
|
+
MAX_SAFE_BUILD_LENGTH,
|
|
502
|
+
MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1,
|
|
503
|
+
RELEASE_TYPES,
|
|
504
|
+
SEMVER_SPEC_VERSION,
|
|
505
|
+
FLAG_INCLUDE_PRERELEASE: 0b001,
|
|
506
|
+
FLAG_LOOSE: 0b010,
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
const debug$1 = (
|
|
510
|
+
typeof process === 'object' &&
|
|
511
|
+
process.env &&
|
|
512
|
+
process.env.NODE_DEBUG &&
|
|
513
|
+
/\bsemver\b/i.test(process.env.NODE_DEBUG)
|
|
514
|
+
) ? (...args) => console.error('SEMVER', ...args)
|
|
515
|
+
: () => {};
|
|
516
|
+
|
|
517
|
+
var debug_1 = debug$1;
|
|
518
|
+
|
|
519
|
+
(function (module, exports) {
|
|
520
|
+
const {
|
|
521
|
+
MAX_SAFE_COMPONENT_LENGTH,
|
|
522
|
+
MAX_SAFE_BUILD_LENGTH,
|
|
523
|
+
MAX_LENGTH,
|
|
524
|
+
} = constants$1;
|
|
525
|
+
const debug = debug_1;
|
|
526
|
+
exports = module.exports = {};
|
|
527
|
+
|
|
528
|
+
// The actual regexps go on exports.re
|
|
529
|
+
const re = exports.re = [];
|
|
530
|
+
const safeRe = exports.safeRe = [];
|
|
531
|
+
const src = exports.src = [];
|
|
532
|
+
const t = exports.t = {};
|
|
533
|
+
let R = 0;
|
|
534
|
+
|
|
535
|
+
const LETTERDASHNUMBER = '[a-zA-Z0-9-]';
|
|
536
|
+
|
|
537
|
+
// Replace some greedy regex tokens to prevent regex dos issues. These regex are
|
|
538
|
+
// used internally via the safeRe object since all inputs in this library get
|
|
539
|
+
// normalized first to trim and collapse all extra whitespace. The original
|
|
540
|
+
// regexes are exported for userland consumption and lower level usage. A
|
|
541
|
+
// future breaking change could export the safer regex only with a note that
|
|
542
|
+
// all input should have extra whitespace removed.
|
|
543
|
+
const safeRegexReplacements = [
|
|
544
|
+
['\\s', 1],
|
|
545
|
+
['\\d', MAX_LENGTH],
|
|
546
|
+
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH],
|
|
547
|
+
];
|
|
548
|
+
|
|
549
|
+
const makeSafeRegex = (value) => {
|
|
550
|
+
for (const [token, max] of safeRegexReplacements) {
|
|
551
|
+
value = value
|
|
552
|
+
.split(`${token}*`).join(`${token}{0,${max}}`)
|
|
553
|
+
.split(`${token}+`).join(`${token}{1,${max}}`);
|
|
554
|
+
}
|
|
555
|
+
return value
|
|
556
|
+
};
|
|
557
|
+
|
|
558
|
+
const createToken = (name, value, isGlobal) => {
|
|
559
|
+
const safe = makeSafeRegex(value);
|
|
560
|
+
const index = R++;
|
|
561
|
+
debug(name, index, value);
|
|
562
|
+
t[name] = index;
|
|
563
|
+
src[index] = value;
|
|
564
|
+
re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
|
|
565
|
+
safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined);
|
|
566
|
+
};
|
|
567
|
+
|
|
568
|
+
// The following Regular Expressions can be used for tokenizing,
|
|
569
|
+
// validating, and parsing SemVer version strings.
|
|
570
|
+
|
|
571
|
+
// ## Numeric Identifier
|
|
572
|
+
// A single `0`, or a non-zero digit followed by zero or more digits.
|
|
573
|
+
|
|
574
|
+
createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
|
|
575
|
+
createToken('NUMERICIDENTIFIERLOOSE', '\\d+');
|
|
576
|
+
|
|
577
|
+
// ## Non-numeric Identifier
|
|
578
|
+
// Zero or more digits, followed by a letter or hyphen, and then zero or
|
|
579
|
+
// more letters, digits, or hyphens.
|
|
580
|
+
|
|
581
|
+
createToken('NONNUMERICIDENTIFIER', `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
|
|
582
|
+
|
|
583
|
+
// ## Main Version
|
|
584
|
+
// Three dot-separated numeric identifiers.
|
|
585
|
+
|
|
586
|
+
createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` +
|
|
587
|
+
`(${src[t.NUMERICIDENTIFIER]})\\.` +
|
|
588
|
+
`(${src[t.NUMERICIDENTIFIER]})`);
|
|
589
|
+
|
|
590
|
+
createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
|
|
591
|
+
`(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
|
|
592
|
+
`(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
593
|
+
|
|
594
|
+
// ## Pre-release Version Identifier
|
|
595
|
+
// A numeric identifier, or a non-numeric identifier.
|
|
596
|
+
|
|
597
|
+
createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]
|
|
598
|
+
}|${src[t.NONNUMERICIDENTIFIER]})`);
|
|
599
|
+
|
|
600
|
+
createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]
|
|
601
|
+
}|${src[t.NONNUMERICIDENTIFIER]})`);
|
|
602
|
+
|
|
603
|
+
// ## Pre-release Version
|
|
604
|
+
// Hyphen, followed by one or more dot-separated pre-release version
|
|
605
|
+
// identifiers.
|
|
606
|
+
|
|
607
|
+
createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]
|
|
608
|
+
}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
|
609
|
+
|
|
610
|
+
createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
|
|
611
|
+
}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
|
|
612
|
+
|
|
613
|
+
// ## Build Metadata Identifier
|
|
614
|
+
// Any combination of digits, letters, or hyphens.
|
|
615
|
+
|
|
616
|
+
createToken('BUILDIDENTIFIER', `${LETTERDASHNUMBER}+`);
|
|
617
|
+
|
|
618
|
+
// ## Build Metadata
|
|
619
|
+
// Plus sign, followed by one or more period-separated build metadata
|
|
620
|
+
// identifiers.
|
|
621
|
+
|
|
622
|
+
createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]
|
|
623
|
+
}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
|
|
624
|
+
|
|
625
|
+
// ## Full Version String
|
|
626
|
+
// A main version, followed optionally by a pre-release version and
|
|
627
|
+
// build metadata.
|
|
628
|
+
|
|
629
|
+
// Note that the only major, minor, patch, and pre-release sections of
|
|
630
|
+
// the version string are capturing groups. The build metadata is not a
|
|
631
|
+
// capturing group, because it should not ever be used in version
|
|
632
|
+
// comparison.
|
|
633
|
+
|
|
634
|
+
createToken('FULLPLAIN', `v?${src[t.MAINVERSION]
|
|
635
|
+
}${src[t.PRERELEASE]}?${
|
|
636
|
+
src[t.BUILD]}?`);
|
|
637
|
+
|
|
638
|
+
createToken('FULL', `^${src[t.FULLPLAIN]}$`);
|
|
639
|
+
|
|
640
|
+
// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
|
|
641
|
+
// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
|
|
642
|
+
// common in the npm registry.
|
|
643
|
+
createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]
|
|
644
|
+
}${src[t.PRERELEASELOOSE]}?${
|
|
645
|
+
src[t.BUILD]}?`);
|
|
646
|
+
|
|
647
|
+
createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
|
|
648
|
+
|
|
649
|
+
createToken('GTLT', '((?:<|>)?=?)');
|
|
650
|
+
|
|
651
|
+
// Something like "2.*" or "1.2.x".
|
|
652
|
+
// Note that "x.x" is a valid xRange identifer, meaning "any version"
|
|
653
|
+
// Only the first item is strictly required.
|
|
654
|
+
createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
|
|
655
|
+
createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
|
|
656
|
+
|
|
657
|
+
createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` +
|
|
658
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
|
|
659
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
|
|
660
|
+
`(?:${src[t.PRERELEASE]})?${
|
|
661
|
+
src[t.BUILD]}?` +
|
|
662
|
+
`)?)?`);
|
|
663
|
+
|
|
664
|
+
createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +
|
|
665
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
|
|
666
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
|
|
667
|
+
`(?:${src[t.PRERELEASELOOSE]})?${
|
|
668
|
+
src[t.BUILD]}?` +
|
|
669
|
+
`)?)?`);
|
|
670
|
+
|
|
671
|
+
createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
|
672
|
+
createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
|
673
|
+
|
|
674
|
+
// Coercion.
|
|
675
|
+
// Extract anything that could conceivably be a part of a valid semver
|
|
676
|
+
createToken('COERCE', `${'(^|[^\\d])' +
|
|
677
|
+
'(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
|
|
678
|
+
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
|
|
679
|
+
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
|
|
680
|
+
`(?:$|[^\\d])`);
|
|
681
|
+
createToken('COERCERTL', src[t.COERCE], true);
|
|
682
|
+
|
|
683
|
+
// Tilde ranges.
|
|
684
|
+
// Meaning is "reasonably at or greater than"
|
|
685
|
+
createToken('LONETILDE', '(?:~>?)');
|
|
686
|
+
|
|
687
|
+
createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
|
688
|
+
exports.tildeTrimReplace = '$1~';
|
|
689
|
+
|
|
690
|
+
createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
|
691
|
+
createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
692
|
+
|
|
693
|
+
// Caret ranges.
|
|
694
|
+
// Meaning is "at least and backwards compatible with"
|
|
695
|
+
createToken('LONECARET', '(?:\\^)');
|
|
696
|
+
|
|
697
|
+
createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
|
|
698
|
+
exports.caretTrimReplace = '$1^';
|
|
699
|
+
|
|
700
|
+
createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
|
701
|
+
createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
702
|
+
|
|
703
|
+
// A simple gt/lt/eq thing, or just "" to indicate "any version"
|
|
704
|
+
createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
|
705
|
+
createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
|
706
|
+
|
|
707
|
+
// An expression to strip any whitespace between the gtlt and the thing
|
|
708
|
+
// it modifies, so that `> 1.2.3` ==> `>1.2.3`
|
|
709
|
+
createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
|
|
710
|
+
}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
|
|
711
|
+
exports.comparatorTrimReplace = '$1$2$3';
|
|
712
|
+
|
|
713
|
+
// Something like `1.2.3 - 1.2.4`
|
|
714
|
+
// Note that these all use the loose form, because they'll be
|
|
715
|
+
// checked against either the strict or loose comparator form
|
|
716
|
+
// later.
|
|
717
|
+
createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
|
|
718
|
+
`\\s+-\\s+` +
|
|
719
|
+
`(${src[t.XRANGEPLAIN]})` +
|
|
720
|
+
`\\s*$`);
|
|
721
|
+
|
|
722
|
+
createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
|
|
723
|
+
`\\s+-\\s+` +
|
|
724
|
+
`(${src[t.XRANGEPLAINLOOSE]})` +
|
|
725
|
+
`\\s*$`);
|
|
726
|
+
|
|
727
|
+
// Star ranges basically just allow anything at all.
|
|
728
|
+
createToken('STAR', '(<|>)?=?\\s*\\*');
|
|
729
|
+
// >=0.0.0 is like a star
|
|
730
|
+
createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$');
|
|
731
|
+
createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$');
|
|
732
|
+
} (re$2, re$2.exports));
|
|
733
|
+
|
|
734
|
+
var reExports = re$2.exports;
|
|
735
|
+
|
|
736
|
+
// parse out just the options we care about
|
|
737
|
+
const looseOption = Object.freeze({ loose: true });
|
|
738
|
+
const emptyOpts = Object.freeze({ });
|
|
739
|
+
const parseOptions$1 = options => {
|
|
740
|
+
if (!options) {
|
|
741
|
+
return emptyOpts
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
if (typeof options !== 'object') {
|
|
745
|
+
return looseOption
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
return options
|
|
749
|
+
};
|
|
750
|
+
var parseOptions_1 = parseOptions$1;
|
|
751
|
+
|
|
752
|
+
const numeric = /^[0-9]+$/;
|
|
753
|
+
const compareIdentifiers$1 = (a, b) => {
|
|
754
|
+
const anum = numeric.test(a);
|
|
755
|
+
const bnum = numeric.test(b);
|
|
756
|
+
|
|
757
|
+
if (anum && bnum) {
|
|
758
|
+
a = +a;
|
|
759
|
+
b = +b;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
return a === b ? 0
|
|
763
|
+
: (anum && !bnum) ? -1
|
|
764
|
+
: (bnum && !anum) ? 1
|
|
765
|
+
: a < b ? -1
|
|
766
|
+
: 1
|
|
767
|
+
};
|
|
768
|
+
|
|
769
|
+
const rcompareIdentifiers = (a, b) => compareIdentifiers$1(b, a);
|
|
770
|
+
|
|
771
|
+
var identifiers$1 = {
|
|
772
|
+
compareIdentifiers: compareIdentifiers$1,
|
|
773
|
+
rcompareIdentifiers,
|
|
774
|
+
};
|
|
775
|
+
|
|
776
|
+
const debug = debug_1;
|
|
777
|
+
const { MAX_LENGTH, MAX_SAFE_INTEGER } = constants$1;
|
|
778
|
+
const { safeRe: re$1, t: t$1 } = reExports;
|
|
779
|
+
|
|
780
|
+
const parseOptions = parseOptions_1;
|
|
781
|
+
const { compareIdentifiers } = identifiers$1;
|
|
782
|
+
let SemVer$d = class SemVer {
|
|
783
|
+
constructor (version, options) {
|
|
784
|
+
options = parseOptions(options);
|
|
785
|
+
|
|
786
|
+
if (version instanceof SemVer) {
|
|
787
|
+
if (version.loose === !!options.loose &&
|
|
788
|
+
version.includePrerelease === !!options.includePrerelease) {
|
|
789
|
+
return version
|
|
790
|
+
} else {
|
|
791
|
+
version = version.version;
|
|
792
|
+
}
|
|
793
|
+
} else if (typeof version !== 'string') {
|
|
794
|
+
throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`)
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
if (version.length > MAX_LENGTH) {
|
|
798
|
+
throw new TypeError(
|
|
799
|
+
`version is longer than ${MAX_LENGTH} characters`
|
|
800
|
+
)
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
debug('SemVer', version, options);
|
|
804
|
+
this.options = options;
|
|
805
|
+
this.loose = !!options.loose;
|
|
806
|
+
// this isn't actually relevant for versions, but keep it so that we
|
|
807
|
+
// don't run into trouble passing this.options around.
|
|
808
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
809
|
+
|
|
810
|
+
const m = version.trim().match(options.loose ? re$1[t$1.LOOSE] : re$1[t$1.FULL]);
|
|
811
|
+
|
|
812
|
+
if (!m) {
|
|
813
|
+
throw new TypeError(`Invalid Version: ${version}`)
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
this.raw = version;
|
|
817
|
+
|
|
818
|
+
// these are actually numbers
|
|
819
|
+
this.major = +m[1];
|
|
820
|
+
this.minor = +m[2];
|
|
821
|
+
this.patch = +m[3];
|
|
822
|
+
|
|
823
|
+
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
|
824
|
+
throw new TypeError('Invalid major version')
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
|
|
828
|
+
throw new TypeError('Invalid minor version')
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
|
832
|
+
throw new TypeError('Invalid patch version')
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
// numberify any prerelease numeric ids
|
|
836
|
+
if (!m[4]) {
|
|
837
|
+
this.prerelease = [];
|
|
838
|
+
} else {
|
|
839
|
+
this.prerelease = m[4].split('.').map((id) => {
|
|
840
|
+
if (/^[0-9]+$/.test(id)) {
|
|
841
|
+
const num = +id;
|
|
842
|
+
if (num >= 0 && num < MAX_SAFE_INTEGER) {
|
|
843
|
+
return num
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
return id
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
this.build = m[5] ? m[5].split('.') : [];
|
|
851
|
+
this.format();
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
format () {
|
|
855
|
+
this.version = `${this.major}.${this.minor}.${this.patch}`;
|
|
856
|
+
if (this.prerelease.length) {
|
|
857
|
+
this.version += `-${this.prerelease.join('.')}`;
|
|
858
|
+
}
|
|
859
|
+
return this.version
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
toString () {
|
|
863
|
+
return this.version
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
compare (other) {
|
|
867
|
+
debug('SemVer.compare', this.version, this.options, other);
|
|
868
|
+
if (!(other instanceof SemVer)) {
|
|
869
|
+
if (typeof other === 'string' && other === this.version) {
|
|
870
|
+
return 0
|
|
871
|
+
}
|
|
872
|
+
other = new SemVer(other, this.options);
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
if (other.version === this.version) {
|
|
876
|
+
return 0
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
return this.compareMain(other) || this.comparePre(other)
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
compareMain (other) {
|
|
883
|
+
if (!(other instanceof SemVer)) {
|
|
884
|
+
other = new SemVer(other, this.options);
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
return (
|
|
888
|
+
compareIdentifiers(this.major, other.major) ||
|
|
889
|
+
compareIdentifiers(this.minor, other.minor) ||
|
|
890
|
+
compareIdentifiers(this.patch, other.patch)
|
|
891
|
+
)
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
comparePre (other) {
|
|
895
|
+
if (!(other instanceof SemVer)) {
|
|
896
|
+
other = new SemVer(other, this.options);
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
// NOT having a prerelease is > having one
|
|
900
|
+
if (this.prerelease.length && !other.prerelease.length) {
|
|
901
|
+
return -1
|
|
902
|
+
} else if (!this.prerelease.length && other.prerelease.length) {
|
|
903
|
+
return 1
|
|
904
|
+
} else if (!this.prerelease.length && !other.prerelease.length) {
|
|
905
|
+
return 0
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
let i = 0;
|
|
909
|
+
do {
|
|
910
|
+
const a = this.prerelease[i];
|
|
911
|
+
const b = other.prerelease[i];
|
|
912
|
+
debug('prerelease compare', i, a, b);
|
|
913
|
+
if (a === undefined && b === undefined) {
|
|
914
|
+
return 0
|
|
915
|
+
} else if (b === undefined) {
|
|
916
|
+
return 1
|
|
917
|
+
} else if (a === undefined) {
|
|
918
|
+
return -1
|
|
919
|
+
} else if (a === b) {
|
|
920
|
+
continue
|
|
921
|
+
} else {
|
|
922
|
+
return compareIdentifiers(a, b)
|
|
923
|
+
}
|
|
924
|
+
} while (++i)
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
compareBuild (other) {
|
|
928
|
+
if (!(other instanceof SemVer)) {
|
|
929
|
+
other = new SemVer(other, this.options);
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
let i = 0;
|
|
933
|
+
do {
|
|
934
|
+
const a = this.build[i];
|
|
935
|
+
const b = other.build[i];
|
|
936
|
+
debug('prerelease compare', i, a, b);
|
|
937
|
+
if (a === undefined && b === undefined) {
|
|
938
|
+
return 0
|
|
939
|
+
} else if (b === undefined) {
|
|
940
|
+
return 1
|
|
941
|
+
} else if (a === undefined) {
|
|
942
|
+
return -1
|
|
943
|
+
} else if (a === b) {
|
|
944
|
+
continue
|
|
945
|
+
} else {
|
|
946
|
+
return compareIdentifiers(a, b)
|
|
947
|
+
}
|
|
948
|
+
} while (++i)
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
// preminor will bump the version up to the next minor release, and immediately
|
|
952
|
+
// down to pre-release. premajor and prepatch work the same way.
|
|
953
|
+
inc (release, identifier, identifierBase) {
|
|
954
|
+
switch (release) {
|
|
955
|
+
case 'premajor':
|
|
956
|
+
this.prerelease.length = 0;
|
|
957
|
+
this.patch = 0;
|
|
958
|
+
this.minor = 0;
|
|
959
|
+
this.major++;
|
|
960
|
+
this.inc('pre', identifier, identifierBase);
|
|
961
|
+
break
|
|
962
|
+
case 'preminor':
|
|
963
|
+
this.prerelease.length = 0;
|
|
964
|
+
this.patch = 0;
|
|
965
|
+
this.minor++;
|
|
966
|
+
this.inc('pre', identifier, identifierBase);
|
|
967
|
+
break
|
|
968
|
+
case 'prepatch':
|
|
969
|
+
// If this is already a prerelease, it will bump to the next version
|
|
970
|
+
// drop any prereleases that might already exist, since they are not
|
|
971
|
+
// relevant at this point.
|
|
972
|
+
this.prerelease.length = 0;
|
|
973
|
+
this.inc('patch', identifier, identifierBase);
|
|
974
|
+
this.inc('pre', identifier, identifierBase);
|
|
975
|
+
break
|
|
976
|
+
// If the input is a non-prerelease version, this acts the same as
|
|
977
|
+
// prepatch.
|
|
978
|
+
case 'prerelease':
|
|
979
|
+
if (this.prerelease.length === 0) {
|
|
980
|
+
this.inc('patch', identifier, identifierBase);
|
|
981
|
+
}
|
|
982
|
+
this.inc('pre', identifier, identifierBase);
|
|
983
|
+
break
|
|
984
|
+
|
|
985
|
+
case 'major':
|
|
986
|
+
// If this is a pre-major version, bump up to the same major version.
|
|
987
|
+
// Otherwise increment major.
|
|
988
|
+
// 1.0.0-5 bumps to 1.0.0
|
|
989
|
+
// 1.1.0 bumps to 2.0.0
|
|
990
|
+
if (
|
|
991
|
+
this.minor !== 0 ||
|
|
992
|
+
this.patch !== 0 ||
|
|
993
|
+
this.prerelease.length === 0
|
|
994
|
+
) {
|
|
995
|
+
this.major++;
|
|
996
|
+
}
|
|
997
|
+
this.minor = 0;
|
|
998
|
+
this.patch = 0;
|
|
999
|
+
this.prerelease = [];
|
|
1000
|
+
break
|
|
1001
|
+
case 'minor':
|
|
1002
|
+
// If this is a pre-minor version, bump up to the same minor version.
|
|
1003
|
+
// Otherwise increment minor.
|
|
1004
|
+
// 1.2.0-5 bumps to 1.2.0
|
|
1005
|
+
// 1.2.1 bumps to 1.3.0
|
|
1006
|
+
if (this.patch !== 0 || this.prerelease.length === 0) {
|
|
1007
|
+
this.minor++;
|
|
1008
|
+
}
|
|
1009
|
+
this.patch = 0;
|
|
1010
|
+
this.prerelease = [];
|
|
1011
|
+
break
|
|
1012
|
+
case 'patch':
|
|
1013
|
+
// If this is not a pre-release version, it will increment the patch.
|
|
1014
|
+
// If it is a pre-release it will bump up to the same patch version.
|
|
1015
|
+
// 1.2.0-5 patches to 1.2.0
|
|
1016
|
+
// 1.2.0 patches to 1.2.1
|
|
1017
|
+
if (this.prerelease.length === 0) {
|
|
1018
|
+
this.patch++;
|
|
1019
|
+
}
|
|
1020
|
+
this.prerelease = [];
|
|
1021
|
+
break
|
|
1022
|
+
// This probably shouldn't be used publicly.
|
|
1023
|
+
// 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
|
|
1024
|
+
case 'pre': {
|
|
1025
|
+
const base = Number(identifierBase) ? 1 : 0;
|
|
1026
|
+
|
|
1027
|
+
if (!identifier && identifierBase === false) {
|
|
1028
|
+
throw new Error('invalid increment argument: identifier is empty')
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
if (this.prerelease.length === 0) {
|
|
1032
|
+
this.prerelease = [base];
|
|
1033
|
+
} else {
|
|
1034
|
+
let i = this.prerelease.length;
|
|
1035
|
+
while (--i >= 0) {
|
|
1036
|
+
if (typeof this.prerelease[i] === 'number') {
|
|
1037
|
+
this.prerelease[i]++;
|
|
1038
|
+
i = -2;
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
if (i === -1) {
|
|
1042
|
+
// didn't increment anything
|
|
1043
|
+
if (identifier === this.prerelease.join('.') && identifierBase === false) {
|
|
1044
|
+
throw new Error('invalid increment argument: identifier already exists')
|
|
1045
|
+
}
|
|
1046
|
+
this.prerelease.push(base);
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
if (identifier) {
|
|
1050
|
+
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
|
|
1051
|
+
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
|
|
1052
|
+
let prerelease = [identifier, base];
|
|
1053
|
+
if (identifierBase === false) {
|
|
1054
|
+
prerelease = [identifier];
|
|
1055
|
+
}
|
|
1056
|
+
if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
|
|
1057
|
+
if (isNaN(this.prerelease[1])) {
|
|
1058
|
+
this.prerelease = prerelease;
|
|
1059
|
+
}
|
|
1060
|
+
} else {
|
|
1061
|
+
this.prerelease = prerelease;
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
break
|
|
1065
|
+
}
|
|
1066
|
+
default:
|
|
1067
|
+
throw new Error(`invalid increment argument: ${release}`)
|
|
1068
|
+
}
|
|
1069
|
+
this.raw = this.format();
|
|
1070
|
+
if (this.build.length) {
|
|
1071
|
+
this.raw += `+${this.build.join('.')}`;
|
|
1072
|
+
}
|
|
1073
|
+
return this
|
|
1074
|
+
}
|
|
1075
|
+
};
|
|
1076
|
+
|
|
1077
|
+
var semver$2 = SemVer$d;
|
|
1078
|
+
|
|
1079
|
+
const SemVer$c = semver$2;
|
|
1080
|
+
const parse$6 = (version, options, throwErrors = false) => {
|
|
1081
|
+
if (version instanceof SemVer$c) {
|
|
1082
|
+
return version
|
|
1083
|
+
}
|
|
1084
|
+
try {
|
|
1085
|
+
return new SemVer$c(version, options)
|
|
1086
|
+
} catch (er) {
|
|
1087
|
+
if (!throwErrors) {
|
|
1088
|
+
return null
|
|
1089
|
+
}
|
|
1090
|
+
throw er
|
|
1091
|
+
}
|
|
1092
|
+
};
|
|
1093
|
+
|
|
1094
|
+
var parse_1 = parse$6;
|
|
1095
|
+
|
|
1096
|
+
const parse$5 = parse_1;
|
|
1097
|
+
const valid$2 = (version, options) => {
|
|
1098
|
+
const v = parse$5(version, options);
|
|
1099
|
+
return v ? v.version : null
|
|
1100
|
+
};
|
|
1101
|
+
var valid_1 = valid$2;
|
|
1102
|
+
|
|
1103
|
+
const parse$4 = parse_1;
|
|
1104
|
+
const clean$1 = (version, options) => {
|
|
1105
|
+
const s = parse$4(version.trim().replace(/^[=v]+/, ''), options);
|
|
1106
|
+
return s ? s.version : null
|
|
1107
|
+
};
|
|
1108
|
+
var clean_1 = clean$1;
|
|
1109
|
+
|
|
1110
|
+
const SemVer$b = semver$2;
|
|
1111
|
+
|
|
1112
|
+
const inc$1 = (version, release, options, identifier, identifierBase) => {
|
|
1113
|
+
if (typeof (options) === 'string') {
|
|
1114
|
+
identifierBase = identifier;
|
|
1115
|
+
identifier = options;
|
|
1116
|
+
options = undefined;
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
try {
|
|
1120
|
+
return new SemVer$b(
|
|
1121
|
+
version instanceof SemVer$b ? version.version : version,
|
|
1122
|
+
options
|
|
1123
|
+
).inc(release, identifier, identifierBase).version
|
|
1124
|
+
} catch (er) {
|
|
1125
|
+
return null
|
|
1126
|
+
}
|
|
1127
|
+
};
|
|
1128
|
+
var inc_1 = inc$1;
|
|
1129
|
+
|
|
1130
|
+
const parse$3 = parse_1;
|
|
1131
|
+
|
|
1132
|
+
const diff$1 = (version1, version2) => {
|
|
1133
|
+
const v1 = parse$3(version1, null, true);
|
|
1134
|
+
const v2 = parse$3(version2, null, true);
|
|
1135
|
+
const comparison = v1.compare(v2);
|
|
1136
|
+
|
|
1137
|
+
if (comparison === 0) {
|
|
1138
|
+
return null
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
const v1Higher = comparison > 0;
|
|
1142
|
+
const highVersion = v1Higher ? v1 : v2;
|
|
1143
|
+
const lowVersion = v1Higher ? v2 : v1;
|
|
1144
|
+
const highHasPre = !!highVersion.prerelease.length;
|
|
1145
|
+
const lowHasPre = !!lowVersion.prerelease.length;
|
|
1146
|
+
|
|
1147
|
+
if (lowHasPre && !highHasPre) {
|
|
1148
|
+
// Going from prerelease -> no prerelease requires some special casing
|
|
1149
|
+
|
|
1150
|
+
// If the low version has only a major, then it will always be a major
|
|
1151
|
+
// Some examples:
|
|
1152
|
+
// 1.0.0-1 -> 1.0.0
|
|
1153
|
+
// 1.0.0-1 -> 1.1.1
|
|
1154
|
+
// 1.0.0-1 -> 2.0.0
|
|
1155
|
+
if (!lowVersion.patch && !lowVersion.minor) {
|
|
1156
|
+
return 'major'
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
// Otherwise it can be determined by checking the high version
|
|
1160
|
+
|
|
1161
|
+
if (highVersion.patch) {
|
|
1162
|
+
// anything higher than a patch bump would result in the wrong version
|
|
1163
|
+
return 'patch'
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
if (highVersion.minor) {
|
|
1167
|
+
// anything higher than a minor bump would result in the wrong version
|
|
1168
|
+
return 'minor'
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
// bumping major/minor/patch all have same result
|
|
1172
|
+
return 'major'
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
// add the `pre` prefix if we are going to a prerelease version
|
|
1176
|
+
const prefix = highHasPre ? 'pre' : '';
|
|
1177
|
+
|
|
1178
|
+
if (v1.major !== v2.major) {
|
|
1179
|
+
return prefix + 'major'
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
if (v1.minor !== v2.minor) {
|
|
1183
|
+
return prefix + 'minor'
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
if (v1.patch !== v2.patch) {
|
|
1187
|
+
return prefix + 'patch'
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
// high and low are preleases
|
|
1191
|
+
return 'prerelease'
|
|
1192
|
+
};
|
|
1193
|
+
|
|
1194
|
+
var diff_1 = diff$1;
|
|
1195
|
+
|
|
1196
|
+
const SemVer$a = semver$2;
|
|
1197
|
+
const major$1 = (a, loose) => new SemVer$a(a, loose).major;
|
|
1198
|
+
var major_1 = major$1;
|
|
1199
|
+
|
|
1200
|
+
const SemVer$9 = semver$2;
|
|
1201
|
+
const minor$1 = (a, loose) => new SemVer$9(a, loose).minor;
|
|
1202
|
+
var minor_1 = minor$1;
|
|
1203
|
+
|
|
1204
|
+
const SemVer$8 = semver$2;
|
|
1205
|
+
const patch$1 = (a, loose) => new SemVer$8(a, loose).patch;
|
|
1206
|
+
var patch_1 = patch$1;
|
|
1207
|
+
|
|
1208
|
+
const parse$2 = parse_1;
|
|
1209
|
+
const prerelease$1 = (version, options) => {
|
|
1210
|
+
const parsed = parse$2(version, options);
|
|
1211
|
+
return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
|
|
1212
|
+
};
|
|
1213
|
+
var prerelease_1 = prerelease$1;
|
|
1214
|
+
|
|
1215
|
+
const SemVer$7 = semver$2;
|
|
1216
|
+
const compare$b = (a, b, loose) =>
|
|
1217
|
+
new SemVer$7(a, loose).compare(new SemVer$7(b, loose));
|
|
1218
|
+
|
|
1219
|
+
var compare_1 = compare$b;
|
|
1220
|
+
|
|
1221
|
+
const compare$a = compare_1;
|
|
1222
|
+
const rcompare$1 = (a, b, loose) => compare$a(b, a, loose);
|
|
1223
|
+
var rcompare_1 = rcompare$1;
|
|
1224
|
+
|
|
1225
|
+
const compare$9 = compare_1;
|
|
1226
|
+
const compareLoose$1 = (a, b) => compare$9(a, b, true);
|
|
1227
|
+
var compareLoose_1 = compareLoose$1;
|
|
1228
|
+
|
|
1229
|
+
const SemVer$6 = semver$2;
|
|
1230
|
+
const compareBuild$3 = (a, b, loose) => {
|
|
1231
|
+
const versionA = new SemVer$6(a, loose);
|
|
1232
|
+
const versionB = new SemVer$6(b, loose);
|
|
1233
|
+
return versionA.compare(versionB) || versionA.compareBuild(versionB)
|
|
1234
|
+
};
|
|
1235
|
+
var compareBuild_1 = compareBuild$3;
|
|
1236
|
+
|
|
1237
|
+
const compareBuild$2 = compareBuild_1;
|
|
1238
|
+
const sort$1 = (list, loose) => list.sort((a, b) => compareBuild$2(a, b, loose));
|
|
1239
|
+
var sort_1 = sort$1;
|
|
1240
|
+
|
|
1241
|
+
const compareBuild$1 = compareBuild_1;
|
|
1242
|
+
const rsort$1 = (list, loose) => list.sort((a, b) => compareBuild$1(b, a, loose));
|
|
1243
|
+
var rsort_1 = rsort$1;
|
|
1244
|
+
|
|
1245
|
+
const compare$8 = compare_1;
|
|
1246
|
+
const gt$4 = (a, b, loose) => compare$8(a, b, loose) > 0;
|
|
1247
|
+
var gt_1 = gt$4;
|
|
1248
|
+
|
|
1249
|
+
const compare$7 = compare_1;
|
|
1250
|
+
const lt$3 = (a, b, loose) => compare$7(a, b, loose) < 0;
|
|
1251
|
+
var lt_1 = lt$3;
|
|
1252
|
+
|
|
1253
|
+
const compare$6 = compare_1;
|
|
1254
|
+
const eq$2 = (a, b, loose) => compare$6(a, b, loose) === 0;
|
|
1255
|
+
var eq_1 = eq$2;
|
|
1256
|
+
|
|
1257
|
+
const compare$5 = compare_1;
|
|
1258
|
+
const neq$2 = (a, b, loose) => compare$5(a, b, loose) !== 0;
|
|
1259
|
+
var neq_1 = neq$2;
|
|
1260
|
+
|
|
1261
|
+
const compare$4 = compare_1;
|
|
1262
|
+
const gte$3 = (a, b, loose) => compare$4(a, b, loose) >= 0;
|
|
1263
|
+
var gte_1 = gte$3;
|
|
1264
|
+
|
|
1265
|
+
const compare$3 = compare_1;
|
|
1266
|
+
const lte$3 = (a, b, loose) => compare$3(a, b, loose) <= 0;
|
|
1267
|
+
var lte_1 = lte$3;
|
|
1268
|
+
|
|
1269
|
+
const eq$1 = eq_1;
|
|
1270
|
+
const neq$1 = neq_1;
|
|
1271
|
+
const gt$3 = gt_1;
|
|
1272
|
+
const gte$2 = gte_1;
|
|
1273
|
+
const lt$2 = lt_1;
|
|
1274
|
+
const lte$2 = lte_1;
|
|
1275
|
+
|
|
1276
|
+
const cmp$1 = (a, op, b, loose) => {
|
|
1277
|
+
switch (op) {
|
|
1278
|
+
case '===':
|
|
1279
|
+
if (typeof a === 'object') {
|
|
1280
|
+
a = a.version;
|
|
1281
|
+
}
|
|
1282
|
+
if (typeof b === 'object') {
|
|
1283
|
+
b = b.version;
|
|
1284
|
+
}
|
|
1285
|
+
return a === b
|
|
1286
|
+
|
|
1287
|
+
case '!==':
|
|
1288
|
+
if (typeof a === 'object') {
|
|
1289
|
+
a = a.version;
|
|
1290
|
+
}
|
|
1291
|
+
if (typeof b === 'object') {
|
|
1292
|
+
b = b.version;
|
|
1293
|
+
}
|
|
1294
|
+
return a !== b
|
|
1295
|
+
|
|
1296
|
+
case '':
|
|
1297
|
+
case '=':
|
|
1298
|
+
case '==':
|
|
1299
|
+
return eq$1(a, b, loose)
|
|
1300
|
+
|
|
1301
|
+
case '!=':
|
|
1302
|
+
return neq$1(a, b, loose)
|
|
1303
|
+
|
|
1304
|
+
case '>':
|
|
1305
|
+
return gt$3(a, b, loose)
|
|
1306
|
+
|
|
1307
|
+
case '>=':
|
|
1308
|
+
return gte$2(a, b, loose)
|
|
1309
|
+
|
|
1310
|
+
case '<':
|
|
1311
|
+
return lt$2(a, b, loose)
|
|
1312
|
+
|
|
1313
|
+
case '<=':
|
|
1314
|
+
return lte$2(a, b, loose)
|
|
1315
|
+
|
|
1316
|
+
default:
|
|
1317
|
+
throw new TypeError(`Invalid operator: ${op}`)
|
|
1318
|
+
}
|
|
1319
|
+
};
|
|
1320
|
+
var cmp_1 = cmp$1;
|
|
1321
|
+
|
|
1322
|
+
const SemVer$5 = semver$2;
|
|
1323
|
+
const parse$1 = parse_1;
|
|
1324
|
+
const { safeRe: re, t } = reExports;
|
|
1325
|
+
|
|
1326
|
+
const coerce$1 = (version, options) => {
|
|
1327
|
+
if (version instanceof SemVer$5) {
|
|
1328
|
+
return version
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
if (typeof version === 'number') {
|
|
1332
|
+
version = String(version);
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
if (typeof version !== 'string') {
|
|
1336
|
+
return null
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
options = options || {};
|
|
1340
|
+
|
|
1341
|
+
let match = null;
|
|
1342
|
+
if (!options.rtl) {
|
|
1343
|
+
match = version.match(re[t.COERCE]);
|
|
1344
|
+
} else {
|
|
1345
|
+
// Find the right-most coercible string that does not share
|
|
1346
|
+
// a terminus with a more left-ward coercible string.
|
|
1347
|
+
// Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
|
|
1348
|
+
//
|
|
1349
|
+
// Walk through the string checking with a /g regexp
|
|
1350
|
+
// Manually set the index so as to pick up overlapping matches.
|
|
1351
|
+
// Stop when we get a match that ends at the string end, since no
|
|
1352
|
+
// coercible string can be more right-ward without the same terminus.
|
|
1353
|
+
let next;
|
|
1354
|
+
while ((next = re[t.COERCERTL].exec(version)) &&
|
|
1355
|
+
(!match || match.index + match[0].length !== version.length)
|
|
1356
|
+
) {
|
|
1357
|
+
if (!match ||
|
|
1358
|
+
next.index + next[0].length !== match.index + match[0].length) {
|
|
1359
|
+
match = next;
|
|
1360
|
+
}
|
|
1361
|
+
re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length;
|
|
1362
|
+
}
|
|
1363
|
+
// leave it in a clean state
|
|
1364
|
+
re[t.COERCERTL].lastIndex = -1;
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
if (match === null) {
|
|
1368
|
+
return null
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
return parse$1(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options)
|
|
1372
|
+
};
|
|
1373
|
+
var coerce_1 = coerce$1;
|
|
1374
|
+
|
|
1375
|
+
var iterator;
|
|
1376
|
+
var hasRequiredIterator;
|
|
1377
|
+
|
|
1378
|
+
function requireIterator () {
|
|
1379
|
+
if (hasRequiredIterator) return iterator;
|
|
1380
|
+
hasRequiredIterator = 1;
|
|
1381
|
+
iterator = function (Yallist) {
|
|
1382
|
+
Yallist.prototype[Symbol.iterator] = function* () {
|
|
1383
|
+
for (let walker = this.head; walker; walker = walker.next) {
|
|
1384
|
+
yield walker.value;
|
|
1385
|
+
}
|
|
1386
|
+
};
|
|
1387
|
+
};
|
|
1388
|
+
return iterator;
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
var yallist;
|
|
1392
|
+
var hasRequiredYallist;
|
|
1393
|
+
|
|
1394
|
+
function requireYallist () {
|
|
1395
|
+
if (hasRequiredYallist) return yallist;
|
|
1396
|
+
hasRequiredYallist = 1;
|
|
1397
|
+
yallist = Yallist;
|
|
1398
|
+
|
|
1399
|
+
Yallist.Node = Node;
|
|
1400
|
+
Yallist.create = Yallist;
|
|
1401
|
+
|
|
1402
|
+
function Yallist (list) {
|
|
1403
|
+
var self = this;
|
|
1404
|
+
if (!(self instanceof Yallist)) {
|
|
1405
|
+
self = new Yallist();
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
self.tail = null;
|
|
1409
|
+
self.head = null;
|
|
1410
|
+
self.length = 0;
|
|
1411
|
+
|
|
1412
|
+
if (list && typeof list.forEach === 'function') {
|
|
1413
|
+
list.forEach(function (item) {
|
|
1414
|
+
self.push(item);
|
|
1415
|
+
});
|
|
1416
|
+
} else if (arguments.length > 0) {
|
|
1417
|
+
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
1418
|
+
self.push(arguments[i]);
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
return self
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
Yallist.prototype.removeNode = function (node) {
|
|
1426
|
+
if (node.list !== this) {
|
|
1427
|
+
throw new Error('removing node which does not belong to this list')
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
var next = node.next;
|
|
1431
|
+
var prev = node.prev;
|
|
1432
|
+
|
|
1433
|
+
if (next) {
|
|
1434
|
+
next.prev = prev;
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
if (prev) {
|
|
1438
|
+
prev.next = next;
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
if (node === this.head) {
|
|
1442
|
+
this.head = next;
|
|
1443
|
+
}
|
|
1444
|
+
if (node === this.tail) {
|
|
1445
|
+
this.tail = prev;
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
node.list.length--;
|
|
1449
|
+
node.next = null;
|
|
1450
|
+
node.prev = null;
|
|
1451
|
+
node.list = null;
|
|
1452
|
+
|
|
1453
|
+
return next
|
|
1454
|
+
};
|
|
1455
|
+
|
|
1456
|
+
Yallist.prototype.unshiftNode = function (node) {
|
|
1457
|
+
if (node === this.head) {
|
|
1458
|
+
return
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
if (node.list) {
|
|
1462
|
+
node.list.removeNode(node);
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
var head = this.head;
|
|
1466
|
+
node.list = this;
|
|
1467
|
+
node.next = head;
|
|
1468
|
+
if (head) {
|
|
1469
|
+
head.prev = node;
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
this.head = node;
|
|
1473
|
+
if (!this.tail) {
|
|
1474
|
+
this.tail = node;
|
|
1475
|
+
}
|
|
1476
|
+
this.length++;
|
|
1477
|
+
};
|
|
1478
|
+
|
|
1479
|
+
Yallist.prototype.pushNode = function (node) {
|
|
1480
|
+
if (node === this.tail) {
|
|
1481
|
+
return
|
|
1482
|
+
}
|
|
1483
|
+
|
|
1484
|
+
if (node.list) {
|
|
1485
|
+
node.list.removeNode(node);
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
var tail = this.tail;
|
|
1489
|
+
node.list = this;
|
|
1490
|
+
node.prev = tail;
|
|
1491
|
+
if (tail) {
|
|
1492
|
+
tail.next = node;
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
this.tail = node;
|
|
1496
|
+
if (!this.head) {
|
|
1497
|
+
this.head = node;
|
|
1498
|
+
}
|
|
1499
|
+
this.length++;
|
|
1500
|
+
};
|
|
1501
|
+
|
|
1502
|
+
Yallist.prototype.push = function () {
|
|
1503
|
+
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
1504
|
+
push(this, arguments[i]);
|
|
1505
|
+
}
|
|
1506
|
+
return this.length
|
|
1507
|
+
};
|
|
1508
|
+
|
|
1509
|
+
Yallist.prototype.unshift = function () {
|
|
1510
|
+
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
1511
|
+
unshift(this, arguments[i]);
|
|
1512
|
+
}
|
|
1513
|
+
return this.length
|
|
1514
|
+
};
|
|
1515
|
+
|
|
1516
|
+
Yallist.prototype.pop = function () {
|
|
1517
|
+
if (!this.tail) {
|
|
1518
|
+
return undefined
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1521
|
+
var res = this.tail.value;
|
|
1522
|
+
this.tail = this.tail.prev;
|
|
1523
|
+
if (this.tail) {
|
|
1524
|
+
this.tail.next = null;
|
|
1525
|
+
} else {
|
|
1526
|
+
this.head = null;
|
|
1527
|
+
}
|
|
1528
|
+
this.length--;
|
|
1529
|
+
return res
|
|
1530
|
+
};
|
|
1531
|
+
|
|
1532
|
+
Yallist.prototype.shift = function () {
|
|
1533
|
+
if (!this.head) {
|
|
1534
|
+
return undefined
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
var res = this.head.value;
|
|
1538
|
+
this.head = this.head.next;
|
|
1539
|
+
if (this.head) {
|
|
1540
|
+
this.head.prev = null;
|
|
1541
|
+
} else {
|
|
1542
|
+
this.tail = null;
|
|
1543
|
+
}
|
|
1544
|
+
this.length--;
|
|
1545
|
+
return res
|
|
1546
|
+
};
|
|
1547
|
+
|
|
1548
|
+
Yallist.prototype.forEach = function (fn, thisp) {
|
|
1549
|
+
thisp = thisp || this;
|
|
1550
|
+
for (var walker = this.head, i = 0; walker !== null; i++) {
|
|
1551
|
+
fn.call(thisp, walker.value, i, this);
|
|
1552
|
+
walker = walker.next;
|
|
1553
|
+
}
|
|
1554
|
+
};
|
|
1555
|
+
|
|
1556
|
+
Yallist.prototype.forEachReverse = function (fn, thisp) {
|
|
1557
|
+
thisp = thisp || this;
|
|
1558
|
+
for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
|
|
1559
|
+
fn.call(thisp, walker.value, i, this);
|
|
1560
|
+
walker = walker.prev;
|
|
1561
|
+
}
|
|
1562
|
+
};
|
|
1563
|
+
|
|
1564
|
+
Yallist.prototype.get = function (n) {
|
|
1565
|
+
for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
|
|
1566
|
+
// abort out of the list early if we hit a cycle
|
|
1567
|
+
walker = walker.next;
|
|
1568
|
+
}
|
|
1569
|
+
if (i === n && walker !== null) {
|
|
1570
|
+
return walker.value
|
|
1571
|
+
}
|
|
1572
|
+
};
|
|
1573
|
+
|
|
1574
|
+
Yallist.prototype.getReverse = function (n) {
|
|
1575
|
+
for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
|
|
1576
|
+
// abort out of the list early if we hit a cycle
|
|
1577
|
+
walker = walker.prev;
|
|
1578
|
+
}
|
|
1579
|
+
if (i === n && walker !== null) {
|
|
1580
|
+
return walker.value
|
|
1581
|
+
}
|
|
1582
|
+
};
|
|
1583
|
+
|
|
1584
|
+
Yallist.prototype.map = function (fn, thisp) {
|
|
1585
|
+
thisp = thisp || this;
|
|
1586
|
+
var res = new Yallist();
|
|
1587
|
+
for (var walker = this.head; walker !== null;) {
|
|
1588
|
+
res.push(fn.call(thisp, walker.value, this));
|
|
1589
|
+
walker = walker.next;
|
|
1590
|
+
}
|
|
1591
|
+
return res
|
|
1592
|
+
};
|
|
1593
|
+
|
|
1594
|
+
Yallist.prototype.mapReverse = function (fn, thisp) {
|
|
1595
|
+
thisp = thisp || this;
|
|
1596
|
+
var res = new Yallist();
|
|
1597
|
+
for (var walker = this.tail; walker !== null;) {
|
|
1598
|
+
res.push(fn.call(thisp, walker.value, this));
|
|
1599
|
+
walker = walker.prev;
|
|
1600
|
+
}
|
|
1601
|
+
return res
|
|
1602
|
+
};
|
|
1603
|
+
|
|
1604
|
+
Yallist.prototype.reduce = function (fn, initial) {
|
|
1605
|
+
var acc;
|
|
1606
|
+
var walker = this.head;
|
|
1607
|
+
if (arguments.length > 1) {
|
|
1608
|
+
acc = initial;
|
|
1609
|
+
} else if (this.head) {
|
|
1610
|
+
walker = this.head.next;
|
|
1611
|
+
acc = this.head.value;
|
|
1612
|
+
} else {
|
|
1613
|
+
throw new TypeError('Reduce of empty list with no initial value')
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
for (var i = 0; walker !== null; i++) {
|
|
1617
|
+
acc = fn(acc, walker.value, i);
|
|
1618
|
+
walker = walker.next;
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
return acc
|
|
1622
|
+
};
|
|
1623
|
+
|
|
1624
|
+
Yallist.prototype.reduceReverse = function (fn, initial) {
|
|
1625
|
+
var acc;
|
|
1626
|
+
var walker = this.tail;
|
|
1627
|
+
if (arguments.length > 1) {
|
|
1628
|
+
acc = initial;
|
|
1629
|
+
} else if (this.tail) {
|
|
1630
|
+
walker = this.tail.prev;
|
|
1631
|
+
acc = this.tail.value;
|
|
1632
|
+
} else {
|
|
1633
|
+
throw new TypeError('Reduce of empty list with no initial value')
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
for (var i = this.length - 1; walker !== null; i--) {
|
|
1637
|
+
acc = fn(acc, walker.value, i);
|
|
1638
|
+
walker = walker.prev;
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1641
|
+
return acc
|
|
1642
|
+
};
|
|
1643
|
+
|
|
1644
|
+
Yallist.prototype.toArray = function () {
|
|
1645
|
+
var arr = new Array(this.length);
|
|
1646
|
+
for (var i = 0, walker = this.head; walker !== null; i++) {
|
|
1647
|
+
arr[i] = walker.value;
|
|
1648
|
+
walker = walker.next;
|
|
1649
|
+
}
|
|
1650
|
+
return arr
|
|
1651
|
+
};
|
|
1652
|
+
|
|
1653
|
+
Yallist.prototype.toArrayReverse = function () {
|
|
1654
|
+
var arr = new Array(this.length);
|
|
1655
|
+
for (var i = 0, walker = this.tail; walker !== null; i++) {
|
|
1656
|
+
arr[i] = walker.value;
|
|
1657
|
+
walker = walker.prev;
|
|
1658
|
+
}
|
|
1659
|
+
return arr
|
|
1660
|
+
};
|
|
1661
|
+
|
|
1662
|
+
Yallist.prototype.slice = function (from, to) {
|
|
1663
|
+
to = to || this.length;
|
|
1664
|
+
if (to < 0) {
|
|
1665
|
+
to += this.length;
|
|
1666
|
+
}
|
|
1667
|
+
from = from || 0;
|
|
1668
|
+
if (from < 0) {
|
|
1669
|
+
from += this.length;
|
|
1670
|
+
}
|
|
1671
|
+
var ret = new Yallist();
|
|
1672
|
+
if (to < from || to < 0) {
|
|
1673
|
+
return ret
|
|
1674
|
+
}
|
|
1675
|
+
if (from < 0) {
|
|
1676
|
+
from = 0;
|
|
1677
|
+
}
|
|
1678
|
+
if (to > this.length) {
|
|
1679
|
+
to = this.length;
|
|
1680
|
+
}
|
|
1681
|
+
for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
|
|
1682
|
+
walker = walker.next;
|
|
1683
|
+
}
|
|
1684
|
+
for (; walker !== null && i < to; i++, walker = walker.next) {
|
|
1685
|
+
ret.push(walker.value);
|
|
1686
|
+
}
|
|
1687
|
+
return ret
|
|
1688
|
+
};
|
|
1689
|
+
|
|
1690
|
+
Yallist.prototype.sliceReverse = function (from, to) {
|
|
1691
|
+
to = to || this.length;
|
|
1692
|
+
if (to < 0) {
|
|
1693
|
+
to += this.length;
|
|
1694
|
+
}
|
|
1695
|
+
from = from || 0;
|
|
1696
|
+
if (from < 0) {
|
|
1697
|
+
from += this.length;
|
|
1698
|
+
}
|
|
1699
|
+
var ret = new Yallist();
|
|
1700
|
+
if (to < from || to < 0) {
|
|
1701
|
+
return ret
|
|
1702
|
+
}
|
|
1703
|
+
if (from < 0) {
|
|
1704
|
+
from = 0;
|
|
1705
|
+
}
|
|
1706
|
+
if (to > this.length) {
|
|
1707
|
+
to = this.length;
|
|
1708
|
+
}
|
|
1709
|
+
for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
|
|
1710
|
+
walker = walker.prev;
|
|
1711
|
+
}
|
|
1712
|
+
for (; walker !== null && i > from; i--, walker = walker.prev) {
|
|
1713
|
+
ret.push(walker.value);
|
|
1714
|
+
}
|
|
1715
|
+
return ret
|
|
1716
|
+
};
|
|
1717
|
+
|
|
1718
|
+
Yallist.prototype.splice = function (start, deleteCount, ...nodes) {
|
|
1719
|
+
if (start > this.length) {
|
|
1720
|
+
start = this.length - 1;
|
|
1721
|
+
}
|
|
1722
|
+
if (start < 0) {
|
|
1723
|
+
start = this.length + start;
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
for (var i = 0, walker = this.head; walker !== null && i < start; i++) {
|
|
1727
|
+
walker = walker.next;
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
var ret = [];
|
|
1731
|
+
for (var i = 0; walker && i < deleteCount; i++) {
|
|
1732
|
+
ret.push(walker.value);
|
|
1733
|
+
walker = this.removeNode(walker);
|
|
1734
|
+
}
|
|
1735
|
+
if (walker === null) {
|
|
1736
|
+
walker = this.tail;
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
if (walker !== this.head && walker !== this.tail) {
|
|
1740
|
+
walker = walker.prev;
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
1744
|
+
walker = insert(this, walker, nodes[i]);
|
|
1745
|
+
}
|
|
1746
|
+
return ret;
|
|
1747
|
+
};
|
|
1748
|
+
|
|
1749
|
+
Yallist.prototype.reverse = function () {
|
|
1750
|
+
var head = this.head;
|
|
1751
|
+
var tail = this.tail;
|
|
1752
|
+
for (var walker = head; walker !== null; walker = walker.prev) {
|
|
1753
|
+
var p = walker.prev;
|
|
1754
|
+
walker.prev = walker.next;
|
|
1755
|
+
walker.next = p;
|
|
1756
|
+
}
|
|
1757
|
+
this.head = tail;
|
|
1758
|
+
this.tail = head;
|
|
1759
|
+
return this
|
|
1760
|
+
};
|
|
1761
|
+
|
|
1762
|
+
function insert (self, node, value) {
|
|
1763
|
+
var inserted = node === self.head ?
|
|
1764
|
+
new Node(value, null, node, self) :
|
|
1765
|
+
new Node(value, node, node.next, self);
|
|
1766
|
+
|
|
1767
|
+
if (inserted.next === null) {
|
|
1768
|
+
self.tail = inserted;
|
|
1769
|
+
}
|
|
1770
|
+
if (inserted.prev === null) {
|
|
1771
|
+
self.head = inserted;
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
self.length++;
|
|
1775
|
+
|
|
1776
|
+
return inserted
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
function push (self, item) {
|
|
1780
|
+
self.tail = new Node(item, self.tail, null, self);
|
|
1781
|
+
if (!self.head) {
|
|
1782
|
+
self.head = self.tail;
|
|
1783
|
+
}
|
|
1784
|
+
self.length++;
|
|
1785
|
+
}
|
|
1786
|
+
|
|
1787
|
+
function unshift (self, item) {
|
|
1788
|
+
self.head = new Node(item, null, self.head, self);
|
|
1789
|
+
if (!self.tail) {
|
|
1790
|
+
self.tail = self.head;
|
|
1791
|
+
}
|
|
1792
|
+
self.length++;
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1795
|
+
function Node (value, prev, next, list) {
|
|
1796
|
+
if (!(this instanceof Node)) {
|
|
1797
|
+
return new Node(value, prev, next, list)
|
|
1798
|
+
}
|
|
1799
|
+
|
|
1800
|
+
this.list = list;
|
|
1801
|
+
this.value = value;
|
|
1802
|
+
|
|
1803
|
+
if (prev) {
|
|
1804
|
+
prev.next = this;
|
|
1805
|
+
this.prev = prev;
|
|
1806
|
+
} else {
|
|
1807
|
+
this.prev = null;
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
if (next) {
|
|
1811
|
+
next.prev = this;
|
|
1812
|
+
this.next = next;
|
|
1813
|
+
} else {
|
|
1814
|
+
this.next = null;
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
|
|
1818
|
+
try {
|
|
1819
|
+
// add if support for Symbol.iterator is present
|
|
1820
|
+
requireIterator()(Yallist);
|
|
1821
|
+
} catch (er) {}
|
|
1822
|
+
return yallist;
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1825
|
+
var lruCache;
|
|
1826
|
+
var hasRequiredLruCache;
|
|
1827
|
+
|
|
1828
|
+
function requireLruCache () {
|
|
1829
|
+
if (hasRequiredLruCache) return lruCache;
|
|
1830
|
+
hasRequiredLruCache = 1;
|
|
1831
|
+
|
|
1832
|
+
// A linked list to keep track of recently-used-ness
|
|
1833
|
+
const Yallist = requireYallist();
|
|
1834
|
+
|
|
1835
|
+
const MAX = Symbol('max');
|
|
1836
|
+
const LENGTH = Symbol('length');
|
|
1837
|
+
const LENGTH_CALCULATOR = Symbol('lengthCalculator');
|
|
1838
|
+
const ALLOW_STALE = Symbol('allowStale');
|
|
1839
|
+
const MAX_AGE = Symbol('maxAge');
|
|
1840
|
+
const DISPOSE = Symbol('dispose');
|
|
1841
|
+
const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet');
|
|
1842
|
+
const LRU_LIST = Symbol('lruList');
|
|
1843
|
+
const CACHE = Symbol('cache');
|
|
1844
|
+
const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet');
|
|
1845
|
+
|
|
1846
|
+
const naiveLength = () => 1;
|
|
1847
|
+
|
|
1848
|
+
// lruList is a yallist where the head is the youngest
|
|
1849
|
+
// item, and the tail is the oldest. the list contains the Hit
|
|
1850
|
+
// objects as the entries.
|
|
1851
|
+
// Each Hit object has a reference to its Yallist.Node. This
|
|
1852
|
+
// never changes.
|
|
1853
|
+
//
|
|
1854
|
+
// cache is a Map (or PseudoMap) that matches the keys to
|
|
1855
|
+
// the Yallist.Node object.
|
|
1856
|
+
class LRUCache {
|
|
1857
|
+
constructor (options) {
|
|
1858
|
+
if (typeof options === 'number')
|
|
1859
|
+
options = { max: options };
|
|
1860
|
+
|
|
1861
|
+
if (!options)
|
|
1862
|
+
options = {};
|
|
1863
|
+
|
|
1864
|
+
if (options.max && (typeof options.max !== 'number' || options.max < 0))
|
|
1865
|
+
throw new TypeError('max must be a non-negative number')
|
|
1866
|
+
// Kind of weird to have a default max of Infinity, but oh well.
|
|
1867
|
+
this[MAX] = options.max || Infinity;
|
|
1868
|
+
|
|
1869
|
+
const lc = options.length || naiveLength;
|
|
1870
|
+
this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc;
|
|
1871
|
+
this[ALLOW_STALE] = options.stale || false;
|
|
1872
|
+
if (options.maxAge && typeof options.maxAge !== 'number')
|
|
1873
|
+
throw new TypeError('maxAge must be a number')
|
|
1874
|
+
this[MAX_AGE] = options.maxAge || 0;
|
|
1875
|
+
this[DISPOSE] = options.dispose;
|
|
1876
|
+
this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false;
|
|
1877
|
+
this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false;
|
|
1878
|
+
this.reset();
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1881
|
+
// resize the cache when the max changes.
|
|
1882
|
+
set max (mL) {
|
|
1883
|
+
if (typeof mL !== 'number' || mL < 0)
|
|
1884
|
+
throw new TypeError('max must be a non-negative number')
|
|
1885
|
+
|
|
1886
|
+
this[MAX] = mL || Infinity;
|
|
1887
|
+
trim(this);
|
|
1888
|
+
}
|
|
1889
|
+
get max () {
|
|
1890
|
+
return this[MAX]
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1893
|
+
set allowStale (allowStale) {
|
|
1894
|
+
this[ALLOW_STALE] = !!allowStale;
|
|
1895
|
+
}
|
|
1896
|
+
get allowStale () {
|
|
1897
|
+
return this[ALLOW_STALE]
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
set maxAge (mA) {
|
|
1901
|
+
if (typeof mA !== 'number')
|
|
1902
|
+
throw new TypeError('maxAge must be a non-negative number')
|
|
1903
|
+
|
|
1904
|
+
this[MAX_AGE] = mA;
|
|
1905
|
+
trim(this);
|
|
1906
|
+
}
|
|
1907
|
+
get maxAge () {
|
|
1908
|
+
return this[MAX_AGE]
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1911
|
+
// resize the cache when the lengthCalculator changes.
|
|
1912
|
+
set lengthCalculator (lC) {
|
|
1913
|
+
if (typeof lC !== 'function')
|
|
1914
|
+
lC = naiveLength;
|
|
1915
|
+
|
|
1916
|
+
if (lC !== this[LENGTH_CALCULATOR]) {
|
|
1917
|
+
this[LENGTH_CALCULATOR] = lC;
|
|
1918
|
+
this[LENGTH] = 0;
|
|
1919
|
+
this[LRU_LIST].forEach(hit => {
|
|
1920
|
+
hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key);
|
|
1921
|
+
this[LENGTH] += hit.length;
|
|
1922
|
+
});
|
|
1923
|
+
}
|
|
1924
|
+
trim(this);
|
|
1925
|
+
}
|
|
1926
|
+
get lengthCalculator () { return this[LENGTH_CALCULATOR] }
|
|
1927
|
+
|
|
1928
|
+
get length () { return this[LENGTH] }
|
|
1929
|
+
get itemCount () { return this[LRU_LIST].length }
|
|
1930
|
+
|
|
1931
|
+
rforEach (fn, thisp) {
|
|
1932
|
+
thisp = thisp || this;
|
|
1933
|
+
for (let walker = this[LRU_LIST].tail; walker !== null;) {
|
|
1934
|
+
const prev = walker.prev;
|
|
1935
|
+
forEachStep(this, fn, walker, thisp);
|
|
1936
|
+
walker = prev;
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
forEach (fn, thisp) {
|
|
1941
|
+
thisp = thisp || this;
|
|
1942
|
+
for (let walker = this[LRU_LIST].head; walker !== null;) {
|
|
1943
|
+
const next = walker.next;
|
|
1944
|
+
forEachStep(this, fn, walker, thisp);
|
|
1945
|
+
walker = next;
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
|
|
1949
|
+
keys () {
|
|
1950
|
+
return this[LRU_LIST].toArray().map(k => k.key)
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1953
|
+
values () {
|
|
1954
|
+
return this[LRU_LIST].toArray().map(k => k.value)
|
|
1955
|
+
}
|
|
1956
|
+
|
|
1957
|
+
reset () {
|
|
1958
|
+
if (this[DISPOSE] &&
|
|
1959
|
+
this[LRU_LIST] &&
|
|
1960
|
+
this[LRU_LIST].length) {
|
|
1961
|
+
this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value));
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1964
|
+
this[CACHE] = new Map(); // hash of items by key
|
|
1965
|
+
this[LRU_LIST] = new Yallist(); // list of items in order of use recency
|
|
1966
|
+
this[LENGTH] = 0; // length of items in the list
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1969
|
+
dump () {
|
|
1970
|
+
return this[LRU_LIST].map(hit =>
|
|
1971
|
+
isStale(this, hit) ? false : {
|
|
1972
|
+
k: hit.key,
|
|
1973
|
+
v: hit.value,
|
|
1974
|
+
e: hit.now + (hit.maxAge || 0)
|
|
1975
|
+
}).toArray().filter(h => h)
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
dumpLru () {
|
|
1979
|
+
return this[LRU_LIST]
|
|
1980
|
+
}
|
|
1981
|
+
|
|
1982
|
+
set (key, value, maxAge) {
|
|
1983
|
+
maxAge = maxAge || this[MAX_AGE];
|
|
1984
|
+
|
|
1985
|
+
if (maxAge && typeof maxAge !== 'number')
|
|
1986
|
+
throw new TypeError('maxAge must be a number')
|
|
1987
|
+
|
|
1988
|
+
const now = maxAge ? Date.now() : 0;
|
|
1989
|
+
const len = this[LENGTH_CALCULATOR](value, key);
|
|
1990
|
+
|
|
1991
|
+
if (this[CACHE].has(key)) {
|
|
1992
|
+
if (len > this[MAX]) {
|
|
1993
|
+
del(this, this[CACHE].get(key));
|
|
1994
|
+
return false
|
|
1995
|
+
}
|
|
1996
|
+
|
|
1997
|
+
const node = this[CACHE].get(key);
|
|
1998
|
+
const item = node.value;
|
|
1999
|
+
|
|
2000
|
+
// dispose of the old one before overwriting
|
|
2001
|
+
// split out into 2 ifs for better coverage tracking
|
|
2002
|
+
if (this[DISPOSE]) {
|
|
2003
|
+
if (!this[NO_DISPOSE_ON_SET])
|
|
2004
|
+
this[DISPOSE](key, item.value);
|
|
2005
|
+
}
|
|
2006
|
+
|
|
2007
|
+
item.now = now;
|
|
2008
|
+
item.maxAge = maxAge;
|
|
2009
|
+
item.value = value;
|
|
2010
|
+
this[LENGTH] += len - item.length;
|
|
2011
|
+
item.length = len;
|
|
2012
|
+
this.get(key);
|
|
2013
|
+
trim(this);
|
|
2014
|
+
return true
|
|
2015
|
+
}
|
|
2016
|
+
|
|
2017
|
+
const hit = new Entry(key, value, len, now, maxAge);
|
|
2018
|
+
|
|
2019
|
+
// oversized objects fall out of cache automatically.
|
|
2020
|
+
if (hit.length > this[MAX]) {
|
|
2021
|
+
if (this[DISPOSE])
|
|
2022
|
+
this[DISPOSE](key, value);
|
|
2023
|
+
|
|
2024
|
+
return false
|
|
2025
|
+
}
|
|
2026
|
+
|
|
2027
|
+
this[LENGTH] += hit.length;
|
|
2028
|
+
this[LRU_LIST].unshift(hit);
|
|
2029
|
+
this[CACHE].set(key, this[LRU_LIST].head);
|
|
2030
|
+
trim(this);
|
|
2031
|
+
return true
|
|
2032
|
+
}
|
|
2033
|
+
|
|
2034
|
+
has (key) {
|
|
2035
|
+
if (!this[CACHE].has(key)) return false
|
|
2036
|
+
const hit = this[CACHE].get(key).value;
|
|
2037
|
+
return !isStale(this, hit)
|
|
2038
|
+
}
|
|
2039
|
+
|
|
2040
|
+
get (key) {
|
|
2041
|
+
return get(this, key, true)
|
|
2042
|
+
}
|
|
2043
|
+
|
|
2044
|
+
peek (key) {
|
|
2045
|
+
return get(this, key, false)
|
|
2046
|
+
}
|
|
2047
|
+
|
|
2048
|
+
pop () {
|
|
2049
|
+
const node = this[LRU_LIST].tail;
|
|
2050
|
+
if (!node)
|
|
2051
|
+
return null
|
|
2052
|
+
|
|
2053
|
+
del(this, node);
|
|
2054
|
+
return node.value
|
|
2055
|
+
}
|
|
2056
|
+
|
|
2057
|
+
del (key) {
|
|
2058
|
+
del(this, this[CACHE].get(key));
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2061
|
+
load (arr) {
|
|
2062
|
+
// reset the cache
|
|
2063
|
+
this.reset();
|
|
2064
|
+
|
|
2065
|
+
const now = Date.now();
|
|
2066
|
+
// A previous serialized cache has the most recent items first
|
|
2067
|
+
for (let l = arr.length - 1; l >= 0; l--) {
|
|
2068
|
+
const hit = arr[l];
|
|
2069
|
+
const expiresAt = hit.e || 0;
|
|
2070
|
+
if (expiresAt === 0)
|
|
2071
|
+
// the item was created without expiration in a non aged cache
|
|
2072
|
+
this.set(hit.k, hit.v);
|
|
2073
|
+
else {
|
|
2074
|
+
const maxAge = expiresAt - now;
|
|
2075
|
+
// dont add already expired items
|
|
2076
|
+
if (maxAge > 0) {
|
|
2077
|
+
this.set(hit.k, hit.v, maxAge);
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
|
|
2083
|
+
prune () {
|
|
2084
|
+
this[CACHE].forEach((value, key) => get(this, key, false));
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
|
|
2088
|
+
const get = (self, key, doUse) => {
|
|
2089
|
+
const node = self[CACHE].get(key);
|
|
2090
|
+
if (node) {
|
|
2091
|
+
const hit = node.value;
|
|
2092
|
+
if (isStale(self, hit)) {
|
|
2093
|
+
del(self, node);
|
|
2094
|
+
if (!self[ALLOW_STALE])
|
|
2095
|
+
return undefined
|
|
2096
|
+
} else {
|
|
2097
|
+
if (doUse) {
|
|
2098
|
+
if (self[UPDATE_AGE_ON_GET])
|
|
2099
|
+
node.value.now = Date.now();
|
|
2100
|
+
self[LRU_LIST].unshiftNode(node);
|
|
2101
|
+
}
|
|
2102
|
+
}
|
|
2103
|
+
return hit.value
|
|
2104
|
+
}
|
|
2105
|
+
};
|
|
2106
|
+
|
|
2107
|
+
const isStale = (self, hit) => {
|
|
2108
|
+
if (!hit || (!hit.maxAge && !self[MAX_AGE]))
|
|
2109
|
+
return false
|
|
2110
|
+
|
|
2111
|
+
const diff = Date.now() - hit.now;
|
|
2112
|
+
return hit.maxAge ? diff > hit.maxAge
|
|
2113
|
+
: self[MAX_AGE] && (diff > self[MAX_AGE])
|
|
2114
|
+
};
|
|
2115
|
+
|
|
2116
|
+
const trim = self => {
|
|
2117
|
+
if (self[LENGTH] > self[MAX]) {
|
|
2118
|
+
for (let walker = self[LRU_LIST].tail;
|
|
2119
|
+
self[LENGTH] > self[MAX] && walker !== null;) {
|
|
2120
|
+
// We know that we're about to delete this one, and also
|
|
2121
|
+
// what the next least recently used key will be, so just
|
|
2122
|
+
// go ahead and set it now.
|
|
2123
|
+
const prev = walker.prev;
|
|
2124
|
+
del(self, walker);
|
|
2125
|
+
walker = prev;
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
};
|
|
2129
|
+
|
|
2130
|
+
const del = (self, node) => {
|
|
2131
|
+
if (node) {
|
|
2132
|
+
const hit = node.value;
|
|
2133
|
+
if (self[DISPOSE])
|
|
2134
|
+
self[DISPOSE](hit.key, hit.value);
|
|
2135
|
+
|
|
2136
|
+
self[LENGTH] -= hit.length;
|
|
2137
|
+
self[CACHE].delete(hit.key);
|
|
2138
|
+
self[LRU_LIST].removeNode(node);
|
|
2139
|
+
}
|
|
2140
|
+
};
|
|
2141
|
+
|
|
2142
|
+
class Entry {
|
|
2143
|
+
constructor (key, value, length, now, maxAge) {
|
|
2144
|
+
this.key = key;
|
|
2145
|
+
this.value = value;
|
|
2146
|
+
this.length = length;
|
|
2147
|
+
this.now = now;
|
|
2148
|
+
this.maxAge = maxAge || 0;
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2152
|
+
const forEachStep = (self, fn, node, thisp) => {
|
|
2153
|
+
let hit = node.value;
|
|
2154
|
+
if (isStale(self, hit)) {
|
|
2155
|
+
del(self, node);
|
|
2156
|
+
if (!self[ALLOW_STALE])
|
|
2157
|
+
hit = undefined;
|
|
2158
|
+
}
|
|
2159
|
+
if (hit)
|
|
2160
|
+
fn.call(thisp, hit.value, hit.key, self);
|
|
2161
|
+
};
|
|
2162
|
+
|
|
2163
|
+
lruCache = LRUCache;
|
|
2164
|
+
return lruCache;
|
|
2165
|
+
}
|
|
2166
|
+
|
|
2167
|
+
var range;
|
|
2168
|
+
var hasRequiredRange;
|
|
2169
|
+
|
|
2170
|
+
function requireRange () {
|
|
2171
|
+
if (hasRequiredRange) return range;
|
|
2172
|
+
hasRequiredRange = 1;
|
|
2173
|
+
// hoisted class for cyclic dependency
|
|
2174
|
+
class Range {
|
|
2175
|
+
constructor (range, options) {
|
|
2176
|
+
options = parseOptions(options);
|
|
2177
|
+
|
|
2178
|
+
if (range instanceof Range) {
|
|
2179
|
+
if (
|
|
2180
|
+
range.loose === !!options.loose &&
|
|
2181
|
+
range.includePrerelease === !!options.includePrerelease
|
|
2182
|
+
) {
|
|
2183
|
+
return range
|
|
2184
|
+
} else {
|
|
2185
|
+
return new Range(range.raw, options)
|
|
2186
|
+
}
|
|
2187
|
+
}
|
|
2188
|
+
|
|
2189
|
+
if (range instanceof Comparator) {
|
|
2190
|
+
// just put it in the set and return
|
|
2191
|
+
this.raw = range.value;
|
|
2192
|
+
this.set = [[range]];
|
|
2193
|
+
this.format();
|
|
2194
|
+
return this
|
|
2195
|
+
}
|
|
2196
|
+
|
|
2197
|
+
this.options = options;
|
|
2198
|
+
this.loose = !!options.loose;
|
|
2199
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
2200
|
+
|
|
2201
|
+
// First reduce all whitespace as much as possible so we do not have to rely
|
|
2202
|
+
// on potentially slow regexes like \s*. This is then stored and used for
|
|
2203
|
+
// future error messages as well.
|
|
2204
|
+
this.raw = range
|
|
2205
|
+
.trim()
|
|
2206
|
+
.split(/\s+/)
|
|
2207
|
+
.join(' ');
|
|
2208
|
+
|
|
2209
|
+
// First, split on ||
|
|
2210
|
+
this.set = this.raw
|
|
2211
|
+
.split('||')
|
|
2212
|
+
// map the range to a 2d array of comparators
|
|
2213
|
+
.map(r => this.parseRange(r.trim()))
|
|
2214
|
+
// throw out any comparator lists that are empty
|
|
2215
|
+
// this generally means that it was not a valid range, which is allowed
|
|
2216
|
+
// in loose mode, but will still throw if the WHOLE range is invalid.
|
|
2217
|
+
.filter(c => c.length);
|
|
2218
|
+
|
|
2219
|
+
if (!this.set.length) {
|
|
2220
|
+
throw new TypeError(`Invalid SemVer Range: ${this.raw}`)
|
|
2221
|
+
}
|
|
2222
|
+
|
|
2223
|
+
// if we have any that are not the null set, throw out null sets.
|
|
2224
|
+
if (this.set.length > 1) {
|
|
2225
|
+
// keep the first one, in case they're all null sets
|
|
2226
|
+
const first = this.set[0];
|
|
2227
|
+
this.set = this.set.filter(c => !isNullSet(c[0]));
|
|
2228
|
+
if (this.set.length === 0) {
|
|
2229
|
+
this.set = [first];
|
|
2230
|
+
} else if (this.set.length > 1) {
|
|
2231
|
+
// if we have any that are *, then the range is just *
|
|
2232
|
+
for (const c of this.set) {
|
|
2233
|
+
if (c.length === 1 && isAny(c[0])) {
|
|
2234
|
+
this.set = [c];
|
|
2235
|
+
break
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
|
|
2241
|
+
this.format();
|
|
2242
|
+
}
|
|
2243
|
+
|
|
2244
|
+
format () {
|
|
2245
|
+
this.range = this.set
|
|
2246
|
+
.map((comps) => comps.join(' ').trim())
|
|
2247
|
+
.join('||')
|
|
2248
|
+
.trim();
|
|
2249
|
+
return this.range
|
|
2250
|
+
}
|
|
2251
|
+
|
|
2252
|
+
toString () {
|
|
2253
|
+
return this.range
|
|
2254
|
+
}
|
|
2255
|
+
|
|
2256
|
+
parseRange (range) {
|
|
2257
|
+
// memoize range parsing for performance.
|
|
2258
|
+
// this is a very hot path, and fully deterministic.
|
|
2259
|
+
const memoOpts =
|
|
2260
|
+
(this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) |
|
|
2261
|
+
(this.options.loose && FLAG_LOOSE);
|
|
2262
|
+
const memoKey = memoOpts + ':' + range;
|
|
2263
|
+
const cached = cache.get(memoKey);
|
|
2264
|
+
if (cached) {
|
|
2265
|
+
return cached
|
|
2266
|
+
}
|
|
2267
|
+
|
|
2268
|
+
const loose = this.options.loose;
|
|
2269
|
+
// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
|
|
2270
|
+
const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
|
|
2271
|
+
range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
|
|
2272
|
+
debug('hyphen replace', range);
|
|
2273
|
+
|
|
2274
|
+
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
|
|
2275
|
+
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
|
|
2276
|
+
debug('comparator trim', range);
|
|
2277
|
+
|
|
2278
|
+
// `~ 1.2.3` => `~1.2.3`
|
|
2279
|
+
range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
|
|
2280
|
+
debug('tilde trim', range);
|
|
2281
|
+
|
|
2282
|
+
// `^ 1.2.3` => `^1.2.3`
|
|
2283
|
+
range = range.replace(re[t.CARETTRIM], caretTrimReplace);
|
|
2284
|
+
debug('caret trim', range);
|
|
2285
|
+
|
|
2286
|
+
// At this point, the range is completely trimmed and
|
|
2287
|
+
// ready to be split into comparators.
|
|
2288
|
+
|
|
2289
|
+
let rangeList = range
|
|
2290
|
+
.split(' ')
|
|
2291
|
+
.map(comp => parseComparator(comp, this.options))
|
|
2292
|
+
.join(' ')
|
|
2293
|
+
.split(/\s+/)
|
|
2294
|
+
// >=0.0.0 is equivalent to *
|
|
2295
|
+
.map(comp => replaceGTE0(comp, this.options));
|
|
2296
|
+
|
|
2297
|
+
if (loose) {
|
|
2298
|
+
// in loose mode, throw out any that are not valid comparators
|
|
2299
|
+
rangeList = rangeList.filter(comp => {
|
|
2300
|
+
debug('loose invalid filter', comp, this.options);
|
|
2301
|
+
return !!comp.match(re[t.COMPARATORLOOSE])
|
|
2302
|
+
});
|
|
2303
|
+
}
|
|
2304
|
+
debug('range list', rangeList);
|
|
2305
|
+
|
|
2306
|
+
// if any comparators are the null set, then replace with JUST null set
|
|
2307
|
+
// if more than one comparator, remove any * comparators
|
|
2308
|
+
// also, don't include the same comparator more than once
|
|
2309
|
+
const rangeMap = new Map();
|
|
2310
|
+
const comparators = rangeList.map(comp => new Comparator(comp, this.options));
|
|
2311
|
+
for (const comp of comparators) {
|
|
2312
|
+
if (isNullSet(comp)) {
|
|
2313
|
+
return [comp]
|
|
2314
|
+
}
|
|
2315
|
+
rangeMap.set(comp.value, comp);
|
|
2316
|
+
}
|
|
2317
|
+
if (rangeMap.size > 1 && rangeMap.has('')) {
|
|
2318
|
+
rangeMap.delete('');
|
|
2319
|
+
}
|
|
2320
|
+
|
|
2321
|
+
const result = [...rangeMap.values()];
|
|
2322
|
+
cache.set(memoKey, result);
|
|
2323
|
+
return result
|
|
2324
|
+
}
|
|
2325
|
+
|
|
2326
|
+
intersects (range, options) {
|
|
2327
|
+
if (!(range instanceof Range)) {
|
|
2328
|
+
throw new TypeError('a Range is required')
|
|
2329
|
+
}
|
|
2330
|
+
|
|
2331
|
+
return this.set.some((thisComparators) => {
|
|
2332
|
+
return (
|
|
2333
|
+
isSatisfiable(thisComparators, options) &&
|
|
2334
|
+
range.set.some((rangeComparators) => {
|
|
2335
|
+
return (
|
|
2336
|
+
isSatisfiable(rangeComparators, options) &&
|
|
2337
|
+
thisComparators.every((thisComparator) => {
|
|
2338
|
+
return rangeComparators.every((rangeComparator) => {
|
|
2339
|
+
return thisComparator.intersects(rangeComparator, options)
|
|
2340
|
+
})
|
|
2341
|
+
})
|
|
2342
|
+
)
|
|
2343
|
+
})
|
|
2344
|
+
)
|
|
2345
|
+
})
|
|
2346
|
+
}
|
|
2347
|
+
|
|
2348
|
+
// if ANY of the sets match ALL of its comparators, then pass
|
|
2349
|
+
test (version) {
|
|
2350
|
+
if (!version) {
|
|
2351
|
+
return false
|
|
2352
|
+
}
|
|
2353
|
+
|
|
2354
|
+
if (typeof version === 'string') {
|
|
2355
|
+
try {
|
|
2356
|
+
version = new SemVer(version, this.options);
|
|
2357
|
+
} catch (er) {
|
|
2358
|
+
return false
|
|
2359
|
+
}
|
|
2360
|
+
}
|
|
2361
|
+
|
|
2362
|
+
for (let i = 0; i < this.set.length; i++) {
|
|
2363
|
+
if (testSet(this.set[i], version, this.options)) {
|
|
2364
|
+
return true
|
|
2365
|
+
}
|
|
2366
|
+
}
|
|
2367
|
+
return false
|
|
2368
|
+
}
|
|
2369
|
+
}
|
|
2370
|
+
|
|
2371
|
+
range = Range;
|
|
2372
|
+
|
|
2373
|
+
const LRU = requireLruCache();
|
|
2374
|
+
const cache = new LRU({ max: 1000 });
|
|
2375
|
+
|
|
2376
|
+
const parseOptions = parseOptions_1;
|
|
2377
|
+
const Comparator = requireComparator();
|
|
2378
|
+
const debug = debug_1;
|
|
2379
|
+
const SemVer = semver$2;
|
|
2380
|
+
const {
|
|
2381
|
+
safeRe: re,
|
|
2382
|
+
t,
|
|
2383
|
+
comparatorTrimReplace,
|
|
2384
|
+
tildeTrimReplace,
|
|
2385
|
+
caretTrimReplace,
|
|
2386
|
+
} = reExports;
|
|
2387
|
+
const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = constants$1;
|
|
2388
|
+
|
|
2389
|
+
const isNullSet = c => c.value === '<0.0.0-0';
|
|
2390
|
+
const isAny = c => c.value === '';
|
|
2391
|
+
|
|
2392
|
+
// take a set of comparators and determine whether there
|
|
2393
|
+
// exists a version which can satisfy it
|
|
2394
|
+
const isSatisfiable = (comparators, options) => {
|
|
2395
|
+
let result = true;
|
|
2396
|
+
const remainingComparators = comparators.slice();
|
|
2397
|
+
let testComparator = remainingComparators.pop();
|
|
2398
|
+
|
|
2399
|
+
while (result && remainingComparators.length) {
|
|
2400
|
+
result = remainingComparators.every((otherComparator) => {
|
|
2401
|
+
return testComparator.intersects(otherComparator, options)
|
|
2402
|
+
});
|
|
2403
|
+
|
|
2404
|
+
testComparator = remainingComparators.pop();
|
|
2405
|
+
}
|
|
2406
|
+
|
|
2407
|
+
return result
|
|
2408
|
+
};
|
|
2409
|
+
|
|
2410
|
+
// comprised of xranges, tildes, stars, and gtlt's at this point.
|
|
2411
|
+
// already replaced the hyphen ranges
|
|
2412
|
+
// turn into a set of JUST comparators.
|
|
2413
|
+
const parseComparator = (comp, options) => {
|
|
2414
|
+
debug('comp', comp, options);
|
|
2415
|
+
comp = replaceCarets(comp, options);
|
|
2416
|
+
debug('caret', comp);
|
|
2417
|
+
comp = replaceTildes(comp, options);
|
|
2418
|
+
debug('tildes', comp);
|
|
2419
|
+
comp = replaceXRanges(comp, options);
|
|
2420
|
+
debug('xrange', comp);
|
|
2421
|
+
comp = replaceStars(comp, options);
|
|
2422
|
+
debug('stars', comp);
|
|
2423
|
+
return comp
|
|
2424
|
+
};
|
|
2425
|
+
|
|
2426
|
+
const isX = id => !id || id.toLowerCase() === 'x' || id === '*';
|
|
2427
|
+
|
|
2428
|
+
// ~, ~> --> * (any, kinda silly)
|
|
2429
|
+
// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0
|
|
2430
|
+
// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0
|
|
2431
|
+
// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0
|
|
2432
|
+
// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
|
|
2433
|
+
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
|
|
2434
|
+
// ~0.0.1 --> >=0.0.1 <0.1.0-0
|
|
2435
|
+
const replaceTildes = (comp, options) => {
|
|
2436
|
+
return comp
|
|
2437
|
+
.trim()
|
|
2438
|
+
.split(/\s+/)
|
|
2439
|
+
.map((c) => replaceTilde(c, options))
|
|
2440
|
+
.join(' ')
|
|
2441
|
+
};
|
|
2442
|
+
|
|
2443
|
+
const replaceTilde = (comp, options) => {
|
|
2444
|
+
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
|
|
2445
|
+
return comp.replace(r, (_, M, m, p, pr) => {
|
|
2446
|
+
debug('tilde', comp, _, M, m, p, pr);
|
|
2447
|
+
let ret;
|
|
2448
|
+
|
|
2449
|
+
if (isX(M)) {
|
|
2450
|
+
ret = '';
|
|
2451
|
+
} else if (isX(m)) {
|
|
2452
|
+
ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
|
|
2453
|
+
} else if (isX(p)) {
|
|
2454
|
+
// ~1.2 == >=1.2.0 <1.3.0-0
|
|
2455
|
+
ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
|
|
2456
|
+
} else if (pr) {
|
|
2457
|
+
debug('replaceTilde pr', pr);
|
|
2458
|
+
ret = `>=${M}.${m}.${p}-${pr
|
|
2459
|
+
} <${M}.${+m + 1}.0-0`;
|
|
2460
|
+
} else {
|
|
2461
|
+
// ~1.2.3 == >=1.2.3 <1.3.0-0
|
|
2462
|
+
ret = `>=${M}.${m}.${p
|
|
2463
|
+
} <${M}.${+m + 1}.0-0`;
|
|
2464
|
+
}
|
|
2465
|
+
|
|
2466
|
+
debug('tilde return', ret);
|
|
2467
|
+
return ret
|
|
2468
|
+
})
|
|
2469
|
+
};
|
|
2470
|
+
|
|
2471
|
+
// ^ --> * (any, kinda silly)
|
|
2472
|
+
// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0
|
|
2473
|
+
// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0
|
|
2474
|
+
// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0
|
|
2475
|
+
// ^1.2.3 --> >=1.2.3 <2.0.0-0
|
|
2476
|
+
// ^1.2.0 --> >=1.2.0 <2.0.0-0
|
|
2477
|
+
// ^0.0.1 --> >=0.0.1 <0.0.2-0
|
|
2478
|
+
// ^0.1.0 --> >=0.1.0 <0.2.0-0
|
|
2479
|
+
const replaceCarets = (comp, options) => {
|
|
2480
|
+
return comp
|
|
2481
|
+
.trim()
|
|
2482
|
+
.split(/\s+/)
|
|
2483
|
+
.map((c) => replaceCaret(c, options))
|
|
2484
|
+
.join(' ')
|
|
2485
|
+
};
|
|
2486
|
+
|
|
2487
|
+
const replaceCaret = (comp, options) => {
|
|
2488
|
+
debug('caret', comp, options);
|
|
2489
|
+
const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
|
|
2490
|
+
const z = options.includePrerelease ? '-0' : '';
|
|
2491
|
+
return comp.replace(r, (_, M, m, p, pr) => {
|
|
2492
|
+
debug('caret', comp, _, M, m, p, pr);
|
|
2493
|
+
let ret;
|
|
2494
|
+
|
|
2495
|
+
if (isX(M)) {
|
|
2496
|
+
ret = '';
|
|
2497
|
+
} else if (isX(m)) {
|
|
2498
|
+
ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
|
|
2499
|
+
} else if (isX(p)) {
|
|
2500
|
+
if (M === '0') {
|
|
2501
|
+
ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
|
|
2502
|
+
} else {
|
|
2503
|
+
ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
|
|
2504
|
+
}
|
|
2505
|
+
} else if (pr) {
|
|
2506
|
+
debug('replaceCaret pr', pr);
|
|
2507
|
+
if (M === '0') {
|
|
2508
|
+
if (m === '0') {
|
|
2509
|
+
ret = `>=${M}.${m}.${p}-${pr
|
|
2510
|
+
} <${M}.${m}.${+p + 1}-0`;
|
|
2511
|
+
} else {
|
|
2512
|
+
ret = `>=${M}.${m}.${p}-${pr
|
|
2513
|
+
} <${M}.${+m + 1}.0-0`;
|
|
2514
|
+
}
|
|
2515
|
+
} else {
|
|
2516
|
+
ret = `>=${M}.${m}.${p}-${pr
|
|
2517
|
+
} <${+M + 1}.0.0-0`;
|
|
2518
|
+
}
|
|
2519
|
+
} else {
|
|
2520
|
+
debug('no pr');
|
|
2521
|
+
if (M === '0') {
|
|
2522
|
+
if (m === '0') {
|
|
2523
|
+
ret = `>=${M}.${m}.${p
|
|
2524
|
+
}${z} <${M}.${m}.${+p + 1}-0`;
|
|
2525
|
+
} else {
|
|
2526
|
+
ret = `>=${M}.${m}.${p
|
|
2527
|
+
}${z} <${M}.${+m + 1}.0-0`;
|
|
2528
|
+
}
|
|
2529
|
+
} else {
|
|
2530
|
+
ret = `>=${M}.${m}.${p
|
|
2531
|
+
} <${+M + 1}.0.0-0`;
|
|
2532
|
+
}
|
|
2533
|
+
}
|
|
2534
|
+
|
|
2535
|
+
debug('caret return', ret);
|
|
2536
|
+
return ret
|
|
2537
|
+
})
|
|
2538
|
+
};
|
|
2539
|
+
|
|
2540
|
+
const replaceXRanges = (comp, options) => {
|
|
2541
|
+
debug('replaceXRanges', comp, options);
|
|
2542
|
+
return comp
|
|
2543
|
+
.split(/\s+/)
|
|
2544
|
+
.map((c) => replaceXRange(c, options))
|
|
2545
|
+
.join(' ')
|
|
2546
|
+
};
|
|
2547
|
+
|
|
2548
|
+
const replaceXRange = (comp, options) => {
|
|
2549
|
+
comp = comp.trim();
|
|
2550
|
+
const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
|
|
2551
|
+
return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
|
|
2552
|
+
debug('xRange', comp, ret, gtlt, M, m, p, pr);
|
|
2553
|
+
const xM = isX(M);
|
|
2554
|
+
const xm = xM || isX(m);
|
|
2555
|
+
const xp = xm || isX(p);
|
|
2556
|
+
const anyX = xp;
|
|
2557
|
+
|
|
2558
|
+
if (gtlt === '=' && anyX) {
|
|
2559
|
+
gtlt = '';
|
|
2560
|
+
}
|
|
2561
|
+
|
|
2562
|
+
// if we're including prereleases in the match, then we need
|
|
2563
|
+
// to fix this to -0, the lowest possible prerelease value
|
|
2564
|
+
pr = options.includePrerelease ? '-0' : '';
|
|
2565
|
+
|
|
2566
|
+
if (xM) {
|
|
2567
|
+
if (gtlt === '>' || gtlt === '<') {
|
|
2568
|
+
// nothing is allowed
|
|
2569
|
+
ret = '<0.0.0-0';
|
|
2570
|
+
} else {
|
|
2571
|
+
// nothing is forbidden
|
|
2572
|
+
ret = '*';
|
|
2573
|
+
}
|
|
2574
|
+
} else if (gtlt && anyX) {
|
|
2575
|
+
// we know patch is an x, because we have any x at all.
|
|
2576
|
+
// replace X with 0
|
|
2577
|
+
if (xm) {
|
|
2578
|
+
m = 0;
|
|
2579
|
+
}
|
|
2580
|
+
p = 0;
|
|
2581
|
+
|
|
2582
|
+
if (gtlt === '>') {
|
|
2583
|
+
// >1 => >=2.0.0
|
|
2584
|
+
// >1.2 => >=1.3.0
|
|
2585
|
+
gtlt = '>=';
|
|
2586
|
+
if (xm) {
|
|
2587
|
+
M = +M + 1;
|
|
2588
|
+
m = 0;
|
|
2589
|
+
p = 0;
|
|
2590
|
+
} else {
|
|
2591
|
+
m = +m + 1;
|
|
2592
|
+
p = 0;
|
|
2593
|
+
}
|
|
2594
|
+
} else if (gtlt === '<=') {
|
|
2595
|
+
// <=0.7.x is actually <0.8.0, since any 0.7.x should
|
|
2596
|
+
// pass. Similarly, <=7.x is actually <8.0.0, etc.
|
|
2597
|
+
gtlt = '<';
|
|
2598
|
+
if (xm) {
|
|
2599
|
+
M = +M + 1;
|
|
2600
|
+
} else {
|
|
2601
|
+
m = +m + 1;
|
|
2602
|
+
}
|
|
2603
|
+
}
|
|
2604
|
+
|
|
2605
|
+
if (gtlt === '<') {
|
|
2606
|
+
pr = '-0';
|
|
2607
|
+
}
|
|
2608
|
+
|
|
2609
|
+
ret = `${gtlt + M}.${m}.${p}${pr}`;
|
|
2610
|
+
} else if (xm) {
|
|
2611
|
+
ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
|
|
2612
|
+
} else if (xp) {
|
|
2613
|
+
ret = `>=${M}.${m}.0${pr
|
|
2614
|
+
} <${M}.${+m + 1}.0-0`;
|
|
2615
|
+
}
|
|
2616
|
+
|
|
2617
|
+
debug('xRange return', ret);
|
|
2618
|
+
|
|
2619
|
+
return ret
|
|
2620
|
+
})
|
|
2621
|
+
};
|
|
2622
|
+
|
|
2623
|
+
// Because * is AND-ed with everything else in the comparator,
|
|
2624
|
+
// and '' means "any version", just remove the *s entirely.
|
|
2625
|
+
const replaceStars = (comp, options) => {
|
|
2626
|
+
debug('replaceStars', comp, options);
|
|
2627
|
+
// Looseness is ignored here. star is always as loose as it gets!
|
|
2628
|
+
return comp
|
|
2629
|
+
.trim()
|
|
2630
|
+
.replace(re[t.STAR], '')
|
|
2631
|
+
};
|
|
2632
|
+
|
|
2633
|
+
const replaceGTE0 = (comp, options) => {
|
|
2634
|
+
debug('replaceGTE0', comp, options);
|
|
2635
|
+
return comp
|
|
2636
|
+
.trim()
|
|
2637
|
+
.replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '')
|
|
2638
|
+
};
|
|
2639
|
+
|
|
2640
|
+
// This function is passed to string.replace(re[t.HYPHENRANGE])
|
|
2641
|
+
// M, m, patch, prerelease, build
|
|
2642
|
+
// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
|
|
2643
|
+
// 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do
|
|
2644
|
+
// 1.2 - 3.4 => >=1.2.0 <3.5.0-0
|
|
2645
|
+
const hyphenReplace = incPr => ($0,
|
|
2646
|
+
from, fM, fm, fp, fpr, fb,
|
|
2647
|
+
to, tM, tm, tp, tpr, tb) => {
|
|
2648
|
+
if (isX(fM)) {
|
|
2649
|
+
from = '';
|
|
2650
|
+
} else if (isX(fm)) {
|
|
2651
|
+
from = `>=${fM}.0.0${incPr ? '-0' : ''}`;
|
|
2652
|
+
} else if (isX(fp)) {
|
|
2653
|
+
from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}`;
|
|
2654
|
+
} else if (fpr) {
|
|
2655
|
+
from = `>=${from}`;
|
|
2656
|
+
} else {
|
|
2657
|
+
from = `>=${from}${incPr ? '-0' : ''}`;
|
|
2658
|
+
}
|
|
2659
|
+
|
|
2660
|
+
if (isX(tM)) {
|
|
2661
|
+
to = '';
|
|
2662
|
+
} else if (isX(tm)) {
|
|
2663
|
+
to = `<${+tM + 1}.0.0-0`;
|
|
2664
|
+
} else if (isX(tp)) {
|
|
2665
|
+
to = `<${tM}.${+tm + 1}.0-0`;
|
|
2666
|
+
} else if (tpr) {
|
|
2667
|
+
to = `<=${tM}.${tm}.${tp}-${tpr}`;
|
|
2668
|
+
} else if (incPr) {
|
|
2669
|
+
to = `<${tM}.${tm}.${+tp + 1}-0`;
|
|
2670
|
+
} else {
|
|
2671
|
+
to = `<=${to}`;
|
|
2672
|
+
}
|
|
2673
|
+
|
|
2674
|
+
return `${from} ${to}`.trim()
|
|
2675
|
+
};
|
|
2676
|
+
|
|
2677
|
+
const testSet = (set, version, options) => {
|
|
2678
|
+
for (let i = 0; i < set.length; i++) {
|
|
2679
|
+
if (!set[i].test(version)) {
|
|
2680
|
+
return false
|
|
2681
|
+
}
|
|
2682
|
+
}
|
|
2683
|
+
|
|
2684
|
+
if (version.prerelease.length && !options.includePrerelease) {
|
|
2685
|
+
// Find the set of versions that are allowed to have prereleases
|
|
2686
|
+
// For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
|
|
2687
|
+
// That should allow `1.2.3-pr.2` to pass.
|
|
2688
|
+
// However, `1.2.4-alpha.notready` should NOT be allowed,
|
|
2689
|
+
// even though it's within the range set by the comparators.
|
|
2690
|
+
for (let i = 0; i < set.length; i++) {
|
|
2691
|
+
debug(set[i].semver);
|
|
2692
|
+
if (set[i].semver === Comparator.ANY) {
|
|
2693
|
+
continue
|
|
2694
|
+
}
|
|
2695
|
+
|
|
2696
|
+
if (set[i].semver.prerelease.length > 0) {
|
|
2697
|
+
const allowed = set[i].semver;
|
|
2698
|
+
if (allowed.major === version.major &&
|
|
2699
|
+
allowed.minor === version.minor &&
|
|
2700
|
+
allowed.patch === version.patch) {
|
|
2701
|
+
return true
|
|
2702
|
+
}
|
|
2703
|
+
}
|
|
2704
|
+
}
|
|
2705
|
+
|
|
2706
|
+
// Version has a -pre, but it's not one of the ones we like.
|
|
2707
|
+
return false
|
|
2708
|
+
}
|
|
2709
|
+
|
|
2710
|
+
return true
|
|
2711
|
+
};
|
|
2712
|
+
return range;
|
|
2713
|
+
}
|
|
2714
|
+
|
|
2715
|
+
var comparator;
|
|
2716
|
+
var hasRequiredComparator;
|
|
2717
|
+
|
|
2718
|
+
function requireComparator () {
|
|
2719
|
+
if (hasRequiredComparator) return comparator;
|
|
2720
|
+
hasRequiredComparator = 1;
|
|
2721
|
+
const ANY = Symbol('SemVer ANY');
|
|
2722
|
+
// hoisted class for cyclic dependency
|
|
2723
|
+
class Comparator {
|
|
2724
|
+
static get ANY () {
|
|
2725
|
+
return ANY
|
|
2726
|
+
}
|
|
2727
|
+
|
|
2728
|
+
constructor (comp, options) {
|
|
2729
|
+
options = parseOptions(options);
|
|
2730
|
+
|
|
2731
|
+
if (comp instanceof Comparator) {
|
|
2732
|
+
if (comp.loose === !!options.loose) {
|
|
2733
|
+
return comp
|
|
2734
|
+
} else {
|
|
2735
|
+
comp = comp.value;
|
|
2736
|
+
}
|
|
2737
|
+
}
|
|
2738
|
+
|
|
2739
|
+
comp = comp.trim().split(/\s+/).join(' ');
|
|
2740
|
+
debug('comparator', comp, options);
|
|
2741
|
+
this.options = options;
|
|
2742
|
+
this.loose = !!options.loose;
|
|
2743
|
+
this.parse(comp);
|
|
2744
|
+
|
|
2745
|
+
if (this.semver === ANY) {
|
|
2746
|
+
this.value = '';
|
|
2747
|
+
} else {
|
|
2748
|
+
this.value = this.operator + this.semver.version;
|
|
2749
|
+
}
|
|
2750
|
+
|
|
2751
|
+
debug('comp', this);
|
|
2752
|
+
}
|
|
2753
|
+
|
|
2754
|
+
parse (comp) {
|
|
2755
|
+
const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
|
|
2756
|
+
const m = comp.match(r);
|
|
2757
|
+
|
|
2758
|
+
if (!m) {
|
|
2759
|
+
throw new TypeError(`Invalid comparator: ${comp}`)
|
|
2760
|
+
}
|
|
2761
|
+
|
|
2762
|
+
this.operator = m[1] !== undefined ? m[1] : '';
|
|
2763
|
+
if (this.operator === '=') {
|
|
2764
|
+
this.operator = '';
|
|
2765
|
+
}
|
|
2766
|
+
|
|
2767
|
+
// if it literally is just '>' or '' then allow anything.
|
|
2768
|
+
if (!m[2]) {
|
|
2769
|
+
this.semver = ANY;
|
|
2770
|
+
} else {
|
|
2771
|
+
this.semver = new SemVer(m[2], this.options.loose);
|
|
2772
|
+
}
|
|
2773
|
+
}
|
|
2774
|
+
|
|
2775
|
+
toString () {
|
|
2776
|
+
return this.value
|
|
2777
|
+
}
|
|
2778
|
+
|
|
2779
|
+
test (version) {
|
|
2780
|
+
debug('Comparator.test', version, this.options.loose);
|
|
2781
|
+
|
|
2782
|
+
if (this.semver === ANY || version === ANY) {
|
|
2783
|
+
return true
|
|
2784
|
+
}
|
|
2785
|
+
|
|
2786
|
+
if (typeof version === 'string') {
|
|
2787
|
+
try {
|
|
2788
|
+
version = new SemVer(version, this.options);
|
|
2789
|
+
} catch (er) {
|
|
2790
|
+
return false
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2793
|
+
|
|
2794
|
+
return cmp(version, this.operator, this.semver, this.options)
|
|
2795
|
+
}
|
|
2796
|
+
|
|
2797
|
+
intersects (comp, options) {
|
|
2798
|
+
if (!(comp instanceof Comparator)) {
|
|
2799
|
+
throw new TypeError('a Comparator is required')
|
|
2800
|
+
}
|
|
2801
|
+
|
|
2802
|
+
if (this.operator === '') {
|
|
2803
|
+
if (this.value === '') {
|
|
2804
|
+
return true
|
|
2805
|
+
}
|
|
2806
|
+
return new Range(comp.value, options).test(this.value)
|
|
2807
|
+
} else if (comp.operator === '') {
|
|
2808
|
+
if (comp.value === '') {
|
|
2809
|
+
return true
|
|
2810
|
+
}
|
|
2811
|
+
return new Range(this.value, options).test(comp.semver)
|
|
2812
|
+
}
|
|
2813
|
+
|
|
2814
|
+
options = parseOptions(options);
|
|
2815
|
+
|
|
2816
|
+
// Special cases where nothing can possibly be lower
|
|
2817
|
+
if (options.includePrerelease &&
|
|
2818
|
+
(this.value === '<0.0.0-0' || comp.value === '<0.0.0-0')) {
|
|
2819
|
+
return false
|
|
2820
|
+
}
|
|
2821
|
+
if (!options.includePrerelease &&
|
|
2822
|
+
(this.value.startsWith('<0.0.0') || comp.value.startsWith('<0.0.0'))) {
|
|
2823
|
+
return false
|
|
2824
|
+
}
|
|
2825
|
+
|
|
2826
|
+
// Same direction increasing (> or >=)
|
|
2827
|
+
if (this.operator.startsWith('>') && comp.operator.startsWith('>')) {
|
|
2828
|
+
return true
|
|
2829
|
+
}
|
|
2830
|
+
// Same direction decreasing (< or <=)
|
|
2831
|
+
if (this.operator.startsWith('<') && comp.operator.startsWith('<')) {
|
|
2832
|
+
return true
|
|
2833
|
+
}
|
|
2834
|
+
// same SemVer and both sides are inclusive (<= or >=)
|
|
2835
|
+
if (
|
|
2836
|
+
(this.semver.version === comp.semver.version) &&
|
|
2837
|
+
this.operator.includes('=') && comp.operator.includes('=')) {
|
|
2838
|
+
return true
|
|
2839
|
+
}
|
|
2840
|
+
// opposite directions less than
|
|
2841
|
+
if (cmp(this.semver, '<', comp.semver, options) &&
|
|
2842
|
+
this.operator.startsWith('>') && comp.operator.startsWith('<')) {
|
|
2843
|
+
return true
|
|
2844
|
+
}
|
|
2845
|
+
// opposite directions greater than
|
|
2846
|
+
if (cmp(this.semver, '>', comp.semver, options) &&
|
|
2847
|
+
this.operator.startsWith('<') && comp.operator.startsWith('>')) {
|
|
2848
|
+
return true
|
|
2849
|
+
}
|
|
2850
|
+
return false
|
|
2851
|
+
}
|
|
2852
|
+
}
|
|
2853
|
+
|
|
2854
|
+
comparator = Comparator;
|
|
2855
|
+
|
|
2856
|
+
const parseOptions = parseOptions_1;
|
|
2857
|
+
const { safeRe: re, t } = reExports;
|
|
2858
|
+
const cmp = cmp_1;
|
|
2859
|
+
const debug = debug_1;
|
|
2860
|
+
const SemVer = semver$2;
|
|
2861
|
+
const Range = requireRange();
|
|
2862
|
+
return comparator;
|
|
2863
|
+
}
|
|
2864
|
+
|
|
2865
|
+
const Range$9 = requireRange();
|
|
2866
|
+
const satisfies$4 = (version, range, options) => {
|
|
2867
|
+
try {
|
|
2868
|
+
range = new Range$9(range, options);
|
|
2869
|
+
} catch (er) {
|
|
2870
|
+
return false
|
|
2871
|
+
}
|
|
2872
|
+
return range.test(version)
|
|
2873
|
+
};
|
|
2874
|
+
var satisfies_1 = satisfies$4;
|
|
2875
|
+
|
|
2876
|
+
const Range$8 = requireRange();
|
|
2877
|
+
|
|
2878
|
+
// Mostly just for testing and legacy API reasons
|
|
2879
|
+
const toComparators$1 = (range, options) =>
|
|
2880
|
+
new Range$8(range, options).set
|
|
2881
|
+
.map(comp => comp.map(c => c.value).join(' ').trim().split(' '));
|
|
2882
|
+
|
|
2883
|
+
var toComparators_1 = toComparators$1;
|
|
2884
|
+
|
|
2885
|
+
const SemVer$4 = semver$2;
|
|
2886
|
+
const Range$7 = requireRange();
|
|
2887
|
+
|
|
2888
|
+
const maxSatisfying$1 = (versions, range, options) => {
|
|
2889
|
+
let max = null;
|
|
2890
|
+
let maxSV = null;
|
|
2891
|
+
let rangeObj = null;
|
|
2892
|
+
try {
|
|
2893
|
+
rangeObj = new Range$7(range, options);
|
|
2894
|
+
} catch (er) {
|
|
2895
|
+
return null
|
|
2896
|
+
}
|
|
2897
|
+
versions.forEach((v) => {
|
|
2898
|
+
if (rangeObj.test(v)) {
|
|
2899
|
+
// satisfies(v, range, options)
|
|
2900
|
+
if (!max || maxSV.compare(v) === -1) {
|
|
2901
|
+
// compare(max, v, true)
|
|
2902
|
+
max = v;
|
|
2903
|
+
maxSV = new SemVer$4(max, options);
|
|
2904
|
+
}
|
|
2905
|
+
}
|
|
2906
|
+
});
|
|
2907
|
+
return max
|
|
2908
|
+
};
|
|
2909
|
+
var maxSatisfying_1 = maxSatisfying$1;
|
|
2910
|
+
|
|
2911
|
+
const SemVer$3 = semver$2;
|
|
2912
|
+
const Range$6 = requireRange();
|
|
2913
|
+
const minSatisfying$1 = (versions, range, options) => {
|
|
2914
|
+
let min = null;
|
|
2915
|
+
let minSV = null;
|
|
2916
|
+
let rangeObj = null;
|
|
2917
|
+
try {
|
|
2918
|
+
rangeObj = new Range$6(range, options);
|
|
2919
|
+
} catch (er) {
|
|
2920
|
+
return null
|
|
2921
|
+
}
|
|
2922
|
+
versions.forEach((v) => {
|
|
2923
|
+
if (rangeObj.test(v)) {
|
|
2924
|
+
// satisfies(v, range, options)
|
|
2925
|
+
if (!min || minSV.compare(v) === 1) {
|
|
2926
|
+
// compare(min, v, true)
|
|
2927
|
+
min = v;
|
|
2928
|
+
minSV = new SemVer$3(min, options);
|
|
2929
|
+
}
|
|
2930
|
+
}
|
|
2931
|
+
});
|
|
2932
|
+
return min
|
|
2933
|
+
};
|
|
2934
|
+
var minSatisfying_1 = minSatisfying$1;
|
|
2935
|
+
|
|
2936
|
+
const SemVer$2 = semver$2;
|
|
2937
|
+
const Range$5 = requireRange();
|
|
2938
|
+
const gt$2 = gt_1;
|
|
2939
|
+
|
|
2940
|
+
const minVersion$1 = (range, loose) => {
|
|
2941
|
+
range = new Range$5(range, loose);
|
|
2942
|
+
|
|
2943
|
+
let minver = new SemVer$2('0.0.0');
|
|
2944
|
+
if (range.test(minver)) {
|
|
2945
|
+
return minver
|
|
2946
|
+
}
|
|
2947
|
+
|
|
2948
|
+
minver = new SemVer$2('0.0.0-0');
|
|
2949
|
+
if (range.test(minver)) {
|
|
2950
|
+
return minver
|
|
2951
|
+
}
|
|
2952
|
+
|
|
2953
|
+
minver = null;
|
|
2954
|
+
for (let i = 0; i < range.set.length; ++i) {
|
|
2955
|
+
const comparators = range.set[i];
|
|
2956
|
+
|
|
2957
|
+
let setMin = null;
|
|
2958
|
+
comparators.forEach((comparator) => {
|
|
2959
|
+
// Clone to avoid manipulating the comparator's semver object.
|
|
2960
|
+
const compver = new SemVer$2(comparator.semver.version);
|
|
2961
|
+
switch (comparator.operator) {
|
|
2962
|
+
case '>':
|
|
2963
|
+
if (compver.prerelease.length === 0) {
|
|
2964
|
+
compver.patch++;
|
|
2965
|
+
} else {
|
|
2966
|
+
compver.prerelease.push(0);
|
|
2967
|
+
}
|
|
2968
|
+
compver.raw = compver.format();
|
|
2969
|
+
/* fallthrough */
|
|
2970
|
+
case '':
|
|
2971
|
+
case '>=':
|
|
2972
|
+
if (!setMin || gt$2(compver, setMin)) {
|
|
2973
|
+
setMin = compver;
|
|
2974
|
+
}
|
|
2975
|
+
break
|
|
2976
|
+
case '<':
|
|
2977
|
+
case '<=':
|
|
2978
|
+
/* Ignore maximum versions */
|
|
2979
|
+
break
|
|
2980
|
+
/* istanbul ignore next */
|
|
2981
|
+
default:
|
|
2982
|
+
throw new Error(`Unexpected operation: ${comparator.operator}`)
|
|
2983
|
+
}
|
|
2984
|
+
});
|
|
2985
|
+
if (setMin && (!minver || gt$2(minver, setMin))) {
|
|
2986
|
+
minver = setMin;
|
|
2987
|
+
}
|
|
2988
|
+
}
|
|
2989
|
+
|
|
2990
|
+
if (minver && range.test(minver)) {
|
|
2991
|
+
return minver
|
|
2992
|
+
}
|
|
2993
|
+
|
|
2994
|
+
return null
|
|
2995
|
+
};
|
|
2996
|
+
var minVersion_1 = minVersion$1;
|
|
2997
|
+
|
|
2998
|
+
const Range$4 = requireRange();
|
|
2999
|
+
const validRange$1 = (range, options) => {
|
|
3000
|
+
try {
|
|
3001
|
+
// Return '*' instead of '' so that truthiness works.
|
|
3002
|
+
// This will throw if it's invalid anyway
|
|
3003
|
+
return new Range$4(range, options).range || '*'
|
|
3004
|
+
} catch (er) {
|
|
3005
|
+
return null
|
|
3006
|
+
}
|
|
3007
|
+
};
|
|
3008
|
+
var valid$1 = validRange$1;
|
|
3009
|
+
|
|
3010
|
+
const SemVer$1 = semver$2;
|
|
3011
|
+
const Comparator$2 = requireComparator();
|
|
3012
|
+
const { ANY: ANY$1 } = Comparator$2;
|
|
3013
|
+
const Range$3 = requireRange();
|
|
3014
|
+
const satisfies$3 = satisfies_1;
|
|
3015
|
+
const gt$1 = gt_1;
|
|
3016
|
+
const lt$1 = lt_1;
|
|
3017
|
+
const lte$1 = lte_1;
|
|
3018
|
+
const gte$1 = gte_1;
|
|
3019
|
+
|
|
3020
|
+
const outside$3 = (version, range, hilo, options) => {
|
|
3021
|
+
version = new SemVer$1(version, options);
|
|
3022
|
+
range = new Range$3(range, options);
|
|
3023
|
+
|
|
3024
|
+
let gtfn, ltefn, ltfn, comp, ecomp;
|
|
3025
|
+
switch (hilo) {
|
|
3026
|
+
case '>':
|
|
3027
|
+
gtfn = gt$1;
|
|
3028
|
+
ltefn = lte$1;
|
|
3029
|
+
ltfn = lt$1;
|
|
3030
|
+
comp = '>';
|
|
3031
|
+
ecomp = '>=';
|
|
3032
|
+
break
|
|
3033
|
+
case '<':
|
|
3034
|
+
gtfn = lt$1;
|
|
3035
|
+
ltefn = gte$1;
|
|
3036
|
+
ltfn = gt$1;
|
|
3037
|
+
comp = '<';
|
|
3038
|
+
ecomp = '<=';
|
|
3039
|
+
break
|
|
3040
|
+
default:
|
|
3041
|
+
throw new TypeError('Must provide a hilo val of "<" or ">"')
|
|
3042
|
+
}
|
|
3043
|
+
|
|
3044
|
+
// If it satisfies the range it is not outside
|
|
3045
|
+
if (satisfies$3(version, range, options)) {
|
|
3046
|
+
return false
|
|
3047
|
+
}
|
|
3048
|
+
|
|
3049
|
+
// From now on, variable terms are as if we're in "gtr" mode.
|
|
3050
|
+
// but note that everything is flipped for the "ltr" function.
|
|
3051
|
+
|
|
3052
|
+
for (let i = 0; i < range.set.length; ++i) {
|
|
3053
|
+
const comparators = range.set[i];
|
|
3054
|
+
|
|
3055
|
+
let high = null;
|
|
3056
|
+
let low = null;
|
|
3057
|
+
|
|
3058
|
+
comparators.forEach((comparator) => {
|
|
3059
|
+
if (comparator.semver === ANY$1) {
|
|
3060
|
+
comparator = new Comparator$2('>=0.0.0');
|
|
3061
|
+
}
|
|
3062
|
+
high = high || comparator;
|
|
3063
|
+
low = low || comparator;
|
|
3064
|
+
if (gtfn(comparator.semver, high.semver, options)) {
|
|
3065
|
+
high = comparator;
|
|
3066
|
+
} else if (ltfn(comparator.semver, low.semver, options)) {
|
|
3067
|
+
low = comparator;
|
|
3068
|
+
}
|
|
3069
|
+
});
|
|
3070
|
+
|
|
3071
|
+
// If the edge version comparator has a operator then our version
|
|
3072
|
+
// isn't outside it
|
|
3073
|
+
if (high.operator === comp || high.operator === ecomp) {
|
|
3074
|
+
return false
|
|
3075
|
+
}
|
|
3076
|
+
|
|
3077
|
+
// If the lowest version comparator has an operator and our version
|
|
3078
|
+
// is less than it then it isn't higher than the range
|
|
3079
|
+
if ((!low.operator || low.operator === comp) &&
|
|
3080
|
+
ltefn(version, low.semver)) {
|
|
3081
|
+
return false
|
|
3082
|
+
} else if (low.operator === ecomp && ltfn(version, low.semver)) {
|
|
3083
|
+
return false
|
|
3084
|
+
}
|
|
3085
|
+
}
|
|
3086
|
+
return true
|
|
3087
|
+
};
|
|
3088
|
+
|
|
3089
|
+
var outside_1 = outside$3;
|
|
3090
|
+
|
|
3091
|
+
// Determine if version is greater than all the versions possible in the range.
|
|
3092
|
+
const outside$2 = outside_1;
|
|
3093
|
+
const gtr$1 = (version, range, options) => outside$2(version, range, '>', options);
|
|
3094
|
+
var gtr_1 = gtr$1;
|
|
3095
|
+
|
|
3096
|
+
const outside$1 = outside_1;
|
|
3097
|
+
// Determine if version is less than all the versions possible in the range
|
|
3098
|
+
const ltr$1 = (version, range, options) => outside$1(version, range, '<', options);
|
|
3099
|
+
var ltr_1 = ltr$1;
|
|
3100
|
+
|
|
3101
|
+
const Range$2 = requireRange();
|
|
3102
|
+
const intersects$1 = (r1, r2, options) => {
|
|
3103
|
+
r1 = new Range$2(r1, options);
|
|
3104
|
+
r2 = new Range$2(r2, options);
|
|
3105
|
+
return r1.intersects(r2, options)
|
|
3106
|
+
};
|
|
3107
|
+
var intersects_1 = intersects$1;
|
|
3108
|
+
|
|
3109
|
+
// given a set of versions and a range, create a "simplified" range
|
|
3110
|
+
// that includes the same versions that the original range does
|
|
3111
|
+
// If the original range is shorter than the simplified one, return that.
|
|
3112
|
+
const satisfies$2 = satisfies_1;
|
|
3113
|
+
const compare$2 = compare_1;
|
|
3114
|
+
var simplify = (versions, range, options) => {
|
|
3115
|
+
const set = [];
|
|
3116
|
+
let first = null;
|
|
3117
|
+
let prev = null;
|
|
3118
|
+
const v = versions.sort((a, b) => compare$2(a, b, options));
|
|
3119
|
+
for (const version of v) {
|
|
3120
|
+
const included = satisfies$2(version, range, options);
|
|
3121
|
+
if (included) {
|
|
3122
|
+
prev = version;
|
|
3123
|
+
if (!first) {
|
|
3124
|
+
first = version;
|
|
3125
|
+
}
|
|
3126
|
+
} else {
|
|
3127
|
+
if (prev) {
|
|
3128
|
+
set.push([first, prev]);
|
|
3129
|
+
}
|
|
3130
|
+
prev = null;
|
|
3131
|
+
first = null;
|
|
3132
|
+
}
|
|
3133
|
+
}
|
|
3134
|
+
if (first) {
|
|
3135
|
+
set.push([first, null]);
|
|
3136
|
+
}
|
|
3137
|
+
|
|
3138
|
+
const ranges = [];
|
|
3139
|
+
for (const [min, max] of set) {
|
|
3140
|
+
if (min === max) {
|
|
3141
|
+
ranges.push(min);
|
|
3142
|
+
} else if (!max && min === v[0]) {
|
|
3143
|
+
ranges.push('*');
|
|
3144
|
+
} else if (!max) {
|
|
3145
|
+
ranges.push(`>=${min}`);
|
|
3146
|
+
} else if (min === v[0]) {
|
|
3147
|
+
ranges.push(`<=${max}`);
|
|
3148
|
+
} else {
|
|
3149
|
+
ranges.push(`${min} - ${max}`);
|
|
3150
|
+
}
|
|
3151
|
+
}
|
|
3152
|
+
const simplified = ranges.join(' || ');
|
|
3153
|
+
const original = typeof range.raw === 'string' ? range.raw : String(range);
|
|
3154
|
+
return simplified.length < original.length ? simplified : range
|
|
3155
|
+
};
|
|
3156
|
+
|
|
3157
|
+
const Range$1 = requireRange();
|
|
3158
|
+
const Comparator$1 = requireComparator();
|
|
3159
|
+
const { ANY } = Comparator$1;
|
|
3160
|
+
const satisfies$1 = satisfies_1;
|
|
3161
|
+
const compare$1 = compare_1;
|
|
3162
|
+
|
|
3163
|
+
// Complex range `r1 || r2 || ...` is a subset of `R1 || R2 || ...` iff:
|
|
3164
|
+
// - Every simple range `r1, r2, ...` is a null set, OR
|
|
3165
|
+
// - Every simple range `r1, r2, ...` which is not a null set is a subset of
|
|
3166
|
+
// some `R1, R2, ...`
|
|
3167
|
+
//
|
|
3168
|
+
// Simple range `c1 c2 ...` is a subset of simple range `C1 C2 ...` iff:
|
|
3169
|
+
// - If c is only the ANY comparator
|
|
3170
|
+
// - If C is only the ANY comparator, return true
|
|
3171
|
+
// - Else if in prerelease mode, return false
|
|
3172
|
+
// - else replace c with `[>=0.0.0]`
|
|
3173
|
+
// - If C is only the ANY comparator
|
|
3174
|
+
// - if in prerelease mode, return true
|
|
3175
|
+
// - else replace C with `[>=0.0.0]`
|
|
3176
|
+
// - Let EQ be the set of = comparators in c
|
|
3177
|
+
// - If EQ is more than one, return true (null set)
|
|
3178
|
+
// - Let GT be the highest > or >= comparator in c
|
|
3179
|
+
// - Let LT be the lowest < or <= comparator in c
|
|
3180
|
+
// - If GT and LT, and GT.semver > LT.semver, return true (null set)
|
|
3181
|
+
// - If any C is a = range, and GT or LT are set, return false
|
|
3182
|
+
// - If EQ
|
|
3183
|
+
// - If GT, and EQ does not satisfy GT, return true (null set)
|
|
3184
|
+
// - If LT, and EQ does not satisfy LT, return true (null set)
|
|
3185
|
+
// - If EQ satisfies every C, return true
|
|
3186
|
+
// - Else return false
|
|
3187
|
+
// - If GT
|
|
3188
|
+
// - If GT.semver is lower than any > or >= comp in C, return false
|
|
3189
|
+
// - If GT is >=, and GT.semver does not satisfy every C, return false
|
|
3190
|
+
// - If GT.semver has a prerelease, and not in prerelease mode
|
|
3191
|
+
// - If no C has a prerelease and the GT.semver tuple, return false
|
|
3192
|
+
// - If LT
|
|
3193
|
+
// - If LT.semver is greater than any < or <= comp in C, return false
|
|
3194
|
+
// - If LT is <=, and LT.semver does not satisfy every C, return false
|
|
3195
|
+
// - If GT.semver has a prerelease, and not in prerelease mode
|
|
3196
|
+
// - If no C has a prerelease and the LT.semver tuple, return false
|
|
3197
|
+
// - Else return true
|
|
3198
|
+
|
|
3199
|
+
const subset$1 = (sub, dom, options = {}) => {
|
|
3200
|
+
if (sub === dom) {
|
|
3201
|
+
return true
|
|
3202
|
+
}
|
|
3203
|
+
|
|
3204
|
+
sub = new Range$1(sub, options);
|
|
3205
|
+
dom = new Range$1(dom, options);
|
|
3206
|
+
let sawNonNull = false;
|
|
3207
|
+
|
|
3208
|
+
OUTER: for (const simpleSub of sub.set) {
|
|
3209
|
+
for (const simpleDom of dom.set) {
|
|
3210
|
+
const isSub = simpleSubset(simpleSub, simpleDom, options);
|
|
3211
|
+
sawNonNull = sawNonNull || isSub !== null;
|
|
3212
|
+
if (isSub) {
|
|
3213
|
+
continue OUTER
|
|
3214
|
+
}
|
|
3215
|
+
}
|
|
3216
|
+
// the null set is a subset of everything, but null simple ranges in
|
|
3217
|
+
// a complex range should be ignored. so if we saw a non-null range,
|
|
3218
|
+
// then we know this isn't a subset, but if EVERY simple range was null,
|
|
3219
|
+
// then it is a subset.
|
|
3220
|
+
if (sawNonNull) {
|
|
3221
|
+
return false
|
|
3222
|
+
}
|
|
3223
|
+
}
|
|
3224
|
+
return true
|
|
3225
|
+
};
|
|
3226
|
+
|
|
3227
|
+
const minimumVersionWithPreRelease = [new Comparator$1('>=0.0.0-0')];
|
|
3228
|
+
const minimumVersion = [new Comparator$1('>=0.0.0')];
|
|
3229
|
+
|
|
3230
|
+
const simpleSubset = (sub, dom, options) => {
|
|
3231
|
+
if (sub === dom) {
|
|
3232
|
+
return true
|
|
3233
|
+
}
|
|
3234
|
+
|
|
3235
|
+
if (sub.length === 1 && sub[0].semver === ANY) {
|
|
3236
|
+
if (dom.length === 1 && dom[0].semver === ANY) {
|
|
3237
|
+
return true
|
|
3238
|
+
} else if (options.includePrerelease) {
|
|
3239
|
+
sub = minimumVersionWithPreRelease;
|
|
3240
|
+
} else {
|
|
3241
|
+
sub = minimumVersion;
|
|
3242
|
+
}
|
|
3243
|
+
}
|
|
3244
|
+
|
|
3245
|
+
if (dom.length === 1 && dom[0].semver === ANY) {
|
|
3246
|
+
if (options.includePrerelease) {
|
|
3247
|
+
return true
|
|
3248
|
+
} else {
|
|
3249
|
+
dom = minimumVersion;
|
|
3250
|
+
}
|
|
3251
|
+
}
|
|
3252
|
+
|
|
3253
|
+
const eqSet = new Set();
|
|
3254
|
+
let gt, lt;
|
|
3255
|
+
for (const c of sub) {
|
|
3256
|
+
if (c.operator === '>' || c.operator === '>=') {
|
|
3257
|
+
gt = higherGT(gt, c, options);
|
|
3258
|
+
} else if (c.operator === '<' || c.operator === '<=') {
|
|
3259
|
+
lt = lowerLT(lt, c, options);
|
|
3260
|
+
} else {
|
|
3261
|
+
eqSet.add(c.semver);
|
|
3262
|
+
}
|
|
3263
|
+
}
|
|
3264
|
+
|
|
3265
|
+
if (eqSet.size > 1) {
|
|
3266
|
+
return null
|
|
3267
|
+
}
|
|
3268
|
+
|
|
3269
|
+
let gtltComp;
|
|
3270
|
+
if (gt && lt) {
|
|
3271
|
+
gtltComp = compare$1(gt.semver, lt.semver, options);
|
|
3272
|
+
if (gtltComp > 0) {
|
|
3273
|
+
return null
|
|
3274
|
+
} else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) {
|
|
3275
|
+
return null
|
|
3276
|
+
}
|
|
3277
|
+
}
|
|
3278
|
+
|
|
3279
|
+
// will iterate one or zero times
|
|
3280
|
+
for (const eq of eqSet) {
|
|
3281
|
+
if (gt && !satisfies$1(eq, String(gt), options)) {
|
|
3282
|
+
return null
|
|
3283
|
+
}
|
|
3284
|
+
|
|
3285
|
+
if (lt && !satisfies$1(eq, String(lt), options)) {
|
|
3286
|
+
return null
|
|
3287
|
+
}
|
|
3288
|
+
|
|
3289
|
+
for (const c of dom) {
|
|
3290
|
+
if (!satisfies$1(eq, String(c), options)) {
|
|
3291
|
+
return false
|
|
3292
|
+
}
|
|
3293
|
+
}
|
|
3294
|
+
|
|
3295
|
+
return true
|
|
3296
|
+
}
|
|
3297
|
+
|
|
3298
|
+
let higher, lower;
|
|
3299
|
+
let hasDomLT, hasDomGT;
|
|
3300
|
+
// if the subset has a prerelease, we need a comparator in the superset
|
|
3301
|
+
// with the same tuple and a prerelease, or it's not a subset
|
|
3302
|
+
let needDomLTPre = lt &&
|
|
3303
|
+
!options.includePrerelease &&
|
|
3304
|
+
lt.semver.prerelease.length ? lt.semver : false;
|
|
3305
|
+
let needDomGTPre = gt &&
|
|
3306
|
+
!options.includePrerelease &&
|
|
3307
|
+
gt.semver.prerelease.length ? gt.semver : false;
|
|
3308
|
+
// exception: <1.2.3-0 is the same as <1.2.3
|
|
3309
|
+
if (needDomLTPre && needDomLTPre.prerelease.length === 1 &&
|
|
3310
|
+
lt.operator === '<' && needDomLTPre.prerelease[0] === 0) {
|
|
3311
|
+
needDomLTPre = false;
|
|
3312
|
+
}
|
|
3313
|
+
|
|
3314
|
+
for (const c of dom) {
|
|
3315
|
+
hasDomGT = hasDomGT || c.operator === '>' || c.operator === '>=';
|
|
3316
|
+
hasDomLT = hasDomLT || c.operator === '<' || c.operator === '<=';
|
|
3317
|
+
if (gt) {
|
|
3318
|
+
if (needDomGTPre) {
|
|
3319
|
+
if (c.semver.prerelease && c.semver.prerelease.length &&
|
|
3320
|
+
c.semver.major === needDomGTPre.major &&
|
|
3321
|
+
c.semver.minor === needDomGTPre.minor &&
|
|
3322
|
+
c.semver.patch === needDomGTPre.patch) {
|
|
3323
|
+
needDomGTPre = false;
|
|
3324
|
+
}
|
|
3325
|
+
}
|
|
3326
|
+
if (c.operator === '>' || c.operator === '>=') {
|
|
3327
|
+
higher = higherGT(gt, c, options);
|
|
3328
|
+
if (higher === c && higher !== gt) {
|
|
3329
|
+
return false
|
|
3330
|
+
}
|
|
3331
|
+
} else if (gt.operator === '>=' && !satisfies$1(gt.semver, String(c), options)) {
|
|
3332
|
+
return false
|
|
3333
|
+
}
|
|
3334
|
+
}
|
|
3335
|
+
if (lt) {
|
|
3336
|
+
if (needDomLTPre) {
|
|
3337
|
+
if (c.semver.prerelease && c.semver.prerelease.length &&
|
|
3338
|
+
c.semver.major === needDomLTPre.major &&
|
|
3339
|
+
c.semver.minor === needDomLTPre.minor &&
|
|
3340
|
+
c.semver.patch === needDomLTPre.patch) {
|
|
3341
|
+
needDomLTPre = false;
|
|
3342
|
+
}
|
|
3343
|
+
}
|
|
3344
|
+
if (c.operator === '<' || c.operator === '<=') {
|
|
3345
|
+
lower = lowerLT(lt, c, options);
|
|
3346
|
+
if (lower === c && lower !== lt) {
|
|
3347
|
+
return false
|
|
3348
|
+
}
|
|
3349
|
+
} else if (lt.operator === '<=' && !satisfies$1(lt.semver, String(c), options)) {
|
|
3350
|
+
return false
|
|
3351
|
+
}
|
|
3352
|
+
}
|
|
3353
|
+
if (!c.operator && (lt || gt) && gtltComp !== 0) {
|
|
3354
|
+
return false
|
|
3355
|
+
}
|
|
3356
|
+
}
|
|
3357
|
+
|
|
3358
|
+
// if there was a < or >, and nothing in the dom, then must be false
|
|
3359
|
+
// UNLESS it was limited by another range in the other direction.
|
|
3360
|
+
// Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0
|
|
3361
|
+
if (gt && hasDomLT && !lt && gtltComp !== 0) {
|
|
3362
|
+
return false
|
|
3363
|
+
}
|
|
3364
|
+
|
|
3365
|
+
if (lt && hasDomGT && !gt && gtltComp !== 0) {
|
|
3366
|
+
return false
|
|
3367
|
+
}
|
|
3368
|
+
|
|
3369
|
+
// we needed a prerelease range in a specific tuple, but didn't get one
|
|
3370
|
+
// then this isn't a subset. eg >=1.2.3-pre is not a subset of >=1.0.0,
|
|
3371
|
+
// because it includes prereleases in the 1.2.3 tuple
|
|
3372
|
+
if (needDomGTPre || needDomLTPre) {
|
|
3373
|
+
return false
|
|
3374
|
+
}
|
|
3375
|
+
|
|
3376
|
+
return true
|
|
3377
|
+
};
|
|
3378
|
+
|
|
3379
|
+
// >=1.2.3 is lower than >1.2.3
|
|
3380
|
+
const higherGT = (a, b, options) => {
|
|
3381
|
+
if (!a) {
|
|
3382
|
+
return b
|
|
3383
|
+
}
|
|
3384
|
+
const comp = compare$1(a.semver, b.semver, options);
|
|
3385
|
+
return comp > 0 ? a
|
|
3386
|
+
: comp < 0 ? b
|
|
3387
|
+
: b.operator === '>' && a.operator === '>=' ? b
|
|
3388
|
+
: a
|
|
3389
|
+
};
|
|
3390
|
+
|
|
3391
|
+
// <=1.2.3 is higher than <1.2.3
|
|
3392
|
+
const lowerLT = (a, b, options) => {
|
|
3393
|
+
if (!a) {
|
|
3394
|
+
return b
|
|
3395
|
+
}
|
|
3396
|
+
const comp = compare$1(a.semver, b.semver, options);
|
|
3397
|
+
return comp < 0 ? a
|
|
3398
|
+
: comp > 0 ? b
|
|
3399
|
+
: b.operator === '<' && a.operator === '<=' ? b
|
|
3400
|
+
: a
|
|
3401
|
+
};
|
|
3402
|
+
|
|
3403
|
+
var subset_1 = subset$1;
|
|
3404
|
+
|
|
3405
|
+
// just pre-load all the stuff that index.js lazily exports
|
|
3406
|
+
const internalRe = reExports;
|
|
3407
|
+
const constants = constants$1;
|
|
3408
|
+
const SemVer = semver$2;
|
|
3409
|
+
const identifiers = identifiers$1;
|
|
3410
|
+
const parse = parse_1;
|
|
3411
|
+
const valid = valid_1;
|
|
3412
|
+
const clean = clean_1;
|
|
3413
|
+
const inc = inc_1;
|
|
3414
|
+
const diff = diff_1;
|
|
3415
|
+
const major = major_1;
|
|
3416
|
+
const minor = minor_1;
|
|
3417
|
+
const patch = patch_1;
|
|
3418
|
+
const prerelease = prerelease_1;
|
|
3419
|
+
const compare = compare_1;
|
|
3420
|
+
const rcompare = rcompare_1;
|
|
3421
|
+
const compareLoose = compareLoose_1;
|
|
3422
|
+
const compareBuild = compareBuild_1;
|
|
3423
|
+
const sort = sort_1;
|
|
3424
|
+
const rsort = rsort_1;
|
|
3425
|
+
const gt = gt_1;
|
|
3426
|
+
const lt = lt_1;
|
|
3427
|
+
const eq = eq_1;
|
|
3428
|
+
const neq = neq_1;
|
|
3429
|
+
const gte = gte_1;
|
|
3430
|
+
const lte = lte_1;
|
|
3431
|
+
const cmp = cmp_1;
|
|
3432
|
+
const coerce = coerce_1;
|
|
3433
|
+
const Comparator = requireComparator();
|
|
3434
|
+
const Range = requireRange();
|
|
3435
|
+
const satisfies = satisfies_1;
|
|
3436
|
+
const toComparators = toComparators_1;
|
|
3437
|
+
const maxSatisfying = maxSatisfying_1;
|
|
3438
|
+
const minSatisfying = minSatisfying_1;
|
|
3439
|
+
const minVersion = minVersion_1;
|
|
3440
|
+
const validRange = valid$1;
|
|
3441
|
+
const outside = outside_1;
|
|
3442
|
+
const gtr = gtr_1;
|
|
3443
|
+
const ltr = ltr_1;
|
|
3444
|
+
const intersects = intersects_1;
|
|
3445
|
+
const simplifyRange = simplify;
|
|
3446
|
+
const subset = subset_1;
|
|
3447
|
+
var semver = {
|
|
3448
|
+
parse,
|
|
3449
|
+
valid,
|
|
3450
|
+
clean,
|
|
3451
|
+
inc,
|
|
3452
|
+
diff,
|
|
3453
|
+
major,
|
|
3454
|
+
minor,
|
|
3455
|
+
patch,
|
|
3456
|
+
prerelease,
|
|
3457
|
+
compare,
|
|
3458
|
+
rcompare,
|
|
3459
|
+
compareLoose,
|
|
3460
|
+
compareBuild,
|
|
3461
|
+
sort,
|
|
3462
|
+
rsort,
|
|
3463
|
+
gt,
|
|
3464
|
+
lt,
|
|
3465
|
+
eq,
|
|
3466
|
+
neq,
|
|
3467
|
+
gte,
|
|
3468
|
+
lte,
|
|
3469
|
+
cmp,
|
|
3470
|
+
coerce,
|
|
3471
|
+
Comparator,
|
|
3472
|
+
Range,
|
|
3473
|
+
satisfies,
|
|
3474
|
+
toComparators,
|
|
3475
|
+
maxSatisfying,
|
|
3476
|
+
minSatisfying,
|
|
3477
|
+
minVersion,
|
|
3478
|
+
validRange,
|
|
3479
|
+
outside,
|
|
3480
|
+
gtr,
|
|
3481
|
+
ltr,
|
|
3482
|
+
intersects,
|
|
3483
|
+
simplifyRange,
|
|
3484
|
+
subset,
|
|
3485
|
+
SemVer,
|
|
3486
|
+
re: internalRe.re,
|
|
3487
|
+
src: internalRe.src,
|
|
3488
|
+
tokens: internalRe.t,
|
|
3489
|
+
SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
|
|
3490
|
+
RELEASE_TYPES: constants.RELEASE_TYPES,
|
|
3491
|
+
compareIdentifiers: identifiers.compareIdentifiers,
|
|
3492
|
+
rcompareIdentifiers: identifiers.rcompareIdentifiers,
|
|
3493
|
+
};
|
|
3494
|
+
|
|
3495
|
+
var semver$1 = /*@__PURE__*/getDefaultExportFromCjs(semver);
|
|
3496
|
+
|
|
471
3497
|
const limit = 1800;
|
|
472
3498
|
const transactionLimit = 1800;
|
|
473
3499
|
const requestTimeout = 30000;
|
|
@@ -1670,9 +4696,13 @@ class VersionControl extends State {
|
|
|
1670
4696
|
constructor(config) {
|
|
1671
4697
|
super(config);
|
|
1672
4698
|
}
|
|
4699
|
+
#currentVersion;
|
|
4700
|
+
async #setCurrentVersion() {
|
|
4701
|
+
this.version = this.#currentVersion;
|
|
4702
|
+
await globalThis.chainStore.put('version', this.version);
|
|
4703
|
+
}
|
|
1673
4704
|
async init() {
|
|
1674
4705
|
super.init && (await super.init());
|
|
1675
|
-
console.log('init');
|
|
1676
4706
|
try {
|
|
1677
4707
|
const version = await globalThis.chainStore.get('version');
|
|
1678
4708
|
this.version = new TextDecoder().decode(version);
|
|
@@ -1683,18 +4713,16 @@ class VersionControl extends State {
|
|
|
1683
4713
|
* in the future we want newer nodes to handle the new changes and still confirm old version transactions
|
|
1684
4714
|
* unless there is a security issue!
|
|
1685
4715
|
*/
|
|
1686
|
-
if (this.version
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
await globalThis.chainStore.put('version', this.version);
|
|
4716
|
+
if (semver$1.compare(this.#currentVersion, this.version) === 1) {
|
|
4717
|
+
// await this.clearAll()
|
|
4718
|
+
this.#setCurrentVersion();
|
|
1690
4719
|
}
|
|
1691
4720
|
// if (version)
|
|
1692
4721
|
}
|
|
1693
4722
|
catch (e) {
|
|
1694
4723
|
console.log(e);
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
await globalThis.chainStore.put('version', this.version);
|
|
4724
|
+
// await this.clearAll()
|
|
4725
|
+
this.#setCurrentVersion();
|
|
1698
4726
|
}
|
|
1699
4727
|
}
|
|
1700
4728
|
}
|
|
@@ -2033,7 +5061,7 @@ class Chain extends VersionControl {
|
|
|
2033
5061
|
// }
|
|
2034
5062
|
// }, [])
|
|
2035
5063
|
const peers = {};
|
|
2036
|
-
for (const entry of globalThis.peernet.
|
|
5064
|
+
for (const entry of globalThis.peernet.peers) {
|
|
2037
5065
|
peers[entry[0]] = entry[1];
|
|
2038
5066
|
}
|
|
2039
5067
|
for (const validator of Object.keys(validators)) {
|